Skip to content

Commit 5d5fd71

Browse files
authored
Merging pull request #18022
* wip * new components * pnpm-lock.yaml * updates
1 parent 3666335 commit 5d5fd71

File tree

13 files changed

+549
-8
lines changed

13 files changed

+549
-8
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import workday from "../../workday.app.mjs";
2+
3+
export default {
4+
key: "workday-change-business-title",
5+
name: "Change Business Title",
6+
description: "Change the business title of a worker. [See the documentation](https://community.workday.com/sites/default/files/file-hosting/restapi/#common/v1/post-/workers/-ID-/businessTitleChanges)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
workday,
11+
workerId: {
12+
propDefinition: [
13+
workday,
14+
"workerId",
15+
],
16+
},
17+
proposedBusinessTitle: {
18+
type: "string",
19+
label: "Proposed Business Title",
20+
description: "The new business title for the worker",
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.workday.changeBusinessTitle({
25+
$,
26+
workerId: this.workerId,
27+
data: {
28+
proposedBusinessTitle: this.proposedBusinessTitle,
29+
},
30+
});
31+
$.export("$summary", `Successfully changed business title for worker ${this.workerId}`);
32+
return response;
33+
},
34+
};
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import workday from "../../workday.app.mjs";
2+
3+
export default {
4+
key: "workday-create-job-change",
5+
name: "Create Job Change",
6+
description: "Create a job change for a worker. [See the documentation](https://community.workday.com/sites/default/files/file-hosting/restapi/#common/v1/post-/workers/-ID-/jobChanges)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
workday,
11+
workerId: {
12+
propDefinition: [
13+
workday,
14+
"workerId",
15+
],
16+
},
17+
supervisoryOrganizationId: {
18+
propDefinition: [
19+
workday,
20+
"supervisoryOrganizationId",
21+
],
22+
},
23+
jobChangeReasonId: {
24+
propDefinition: [
25+
workday,
26+
"jobChangeReasonId",
27+
],
28+
},
29+
moveManagersTeam: {
30+
type: "boolean",
31+
label: "Move Managers Team",
32+
description: "Indicates whether teams reporting to the ~Manager~ moved with them during the Change Job Event",
33+
optional: true,
34+
},
35+
effective: {
36+
type: "string",
37+
label: "Effective",
38+
description: "The date this business process takes effect. Example: `2025-08-09T07:00:00.000Z`",
39+
optional: true,
40+
},
41+
},
42+
async run({ $ }) {
43+
const response = await this.workday.createJobChange({
44+
$,
45+
workerId: this.workerId,
46+
data: {
47+
supervisoryOrganization: {
48+
id: this.supervisoryOrganizationId,
49+
},
50+
jobChangeReason: {
51+
id: this.jobChangeReasonId,
52+
},
53+
moveManagersTeam: this.moveManagersTeam,
54+
effective: this.effective,
55+
},
56+
});
57+
$.export("$summary", `Successfully created job change for worker ${this.workerId}`);
58+
return response;
59+
},
60+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import workday from "../../workday.app.mjs";
2+
3+
export default {
4+
key: "workday-get-worker",
5+
name: "Get Worker",
6+
description: "Get a worker. [See the documentation](https://community.workday.com/sites/default/files/file-hosting/restapi/#common/v1/get-/workers/-ID-)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
workday,
11+
workerId: {
12+
propDefinition: [
13+
workday,
14+
"workerId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.workday.getWorker({
20+
$,
21+
workerId: this.workerId,
22+
});
23+
$.export("$summary", `Successfully fetched worker ${this.workerId}`);
24+
return response;
25+
},
26+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import workday from "../../workday.app.mjs";
2+
3+
export default {
4+
key: "workday-list-organization-types",
5+
name: "List Organization Types",
6+
description: "List organization types. [See the documentation](https://community.workday.com/sites/default/files/file-hosting/restapi/#common/v1/organizationTypes)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
workday,
11+
maxResults: {
12+
propDefinition: [
13+
workday,
14+
"maxResults",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const results = this.workday.paginate({
20+
fn: this.workday.listOrganizationTypes,
21+
args: {
22+
$,
23+
},
24+
max: this.maxResults,
25+
});
26+
27+
const data = [];
28+
for await (const result of results) {
29+
data.push(result);
30+
}
31+
32+
$.export("$summary", `Successfully fetched ${data.length} organization types`);
33+
return data;
34+
},
35+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import workday from "../../workday.app.mjs";
2+
3+
export default {
4+
key: "workday-list-supervisory-organizations",
5+
name: "List Supervisory Organizations",
6+
description: "List supervisory organizations. [See the documentation](https://community.workday.com/sites/default/files/file-hosting/restapi/#common/v1/get-/supervisoryOrganizations)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
workday,
11+
maxResults: {
12+
propDefinition: [
13+
workday,
14+
"maxResults",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const results = this.workday.paginate({
20+
fn: this.workday.listSupervisoryOrganizations,
21+
args: {
22+
$,
23+
},
24+
max: this.maxResults,
25+
});
26+
27+
const data = [];
28+
for await (const result of results) {
29+
data.push(result);
30+
}
31+
32+
$.export("$summary", `Successfully fetched ${data.length} supervisory organizations`);
33+
return data;
34+
},
35+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import workday from "../../workday.app.mjs";
2+
3+
export default {
4+
key: "workday-list-worker-payslips",
5+
name: "List Worker Payslips",
6+
description: "List the payslips for a worker. [See the documentation](https://community.workday.com/sites/default/files/file-hosting/restapi/#common/v1/get-/workers/-ID-/paySlips)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
workday,
11+
workerId: {
12+
propDefinition: [
13+
workday,
14+
"workerId",
15+
],
16+
},
17+
maxResults: {
18+
propDefinition: [
19+
workday,
20+
"maxResults",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const results = this.workday.paginate({
26+
fn: this.workday.listWorkerPayslips,
27+
args: {
28+
$,
29+
workerId: this.workerId,
30+
},
31+
max: this.maxResults,
32+
});
33+
34+
const data = [];
35+
for await (const result of results) {
36+
data.push(result);
37+
}
38+
39+
$.export("$summary", `Successfully fetched ${data.length} payslips for worker ${this.workerId}`);
40+
return data;
41+
},
42+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import workday from "../../workday.app.mjs";
2+
3+
export default {
4+
key: "workday-search-workers",
5+
name: "Search Workers",
6+
description: "Retrieve a list of workers based on a search query. [See the documentation](https://community.workday.com/sites/default/files/file-hosting/restapi/#common/v1/get-/workers)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
workday,
11+
search: {
12+
type: "string",
13+
label: "Search",
14+
description: "The search query to use to filter workers",
15+
optional: true,
16+
},
17+
maxResults: {
18+
propDefinition: [
19+
workday,
20+
"maxResults",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const results = this.workday.paginate({
26+
fn: this.workday.listWorkers,
27+
args: {
28+
$,
29+
params: {
30+
search: this.search,
31+
},
32+
},
33+
max: this.maxResults,
34+
});
35+
36+
const data = [];
37+
for await (const result of results) {
38+
data.push(result);
39+
}
40+
41+
$.export("$summary", `Successfully fetched ${data.length} workers`);
42+
return data;
43+
},
44+
};

components/workday/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/workday",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Workday Components",
55
"main": "workday.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.0"
1417
}
15-
}
18+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import workday from "../../workday.app.mjs";
2+
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
3+
4+
export default {
5+
props: {
6+
workday,
7+
db: "$.service.db",
8+
timer: {
9+
type: "$.interface.timer",
10+
default: {
11+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
12+
},
13+
},
14+
},
15+
methods: {},
16+
};
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import common from "../common/base-polling.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
...common,
6+
key: "workday-new-worker-created",
7+
name: "New Worker Created",
8+
description: "Emit new event for each new worker created in Workday. [See the documentation](https://community.workday.com/sites/default/files/file-hosting/restapi/#common/v1/get-/workers)",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
methods: {
13+
...common.methods,
14+
_getPreviousIds() {
15+
return this.db.get("previousIds") || {};
16+
},
17+
_setPreviousIds(ids) {
18+
this.db.set("previousIds", ids);
19+
},
20+
generateMeta(worker) {
21+
return {
22+
id: worker.id,
23+
summary: `New worker created: ${worker.descriptor}`,
24+
ts: Date.now(),
25+
};
26+
},
27+
async processEvent(limit) {
28+
const results = this.workday.paginate({
29+
fn: this.workday.listWorkers,
30+
});
31+
32+
const previousIds = this._getPreviousIds();
33+
let workers = [];
34+
35+
for await (const worker of results) {
36+
if (previousIds[worker.id]) {
37+
continue;
38+
}
39+
workers.push(worker);
40+
previousIds[worker.id] = true;
41+
}
42+
43+
this._setPreviousIds(previousIds);
44+
45+
if (!workers?.length) {
46+
return;
47+
}
48+
49+
if (limit) {
50+
workers = workers.slice(0, limit);
51+
}
52+
53+
for (const worker of workers) {
54+
const meta = this.generateMeta(worker);
55+
this.$emit(worker, meta);
56+
}
57+
},
58+
},
59+
hooks: {
60+
async deploy() {
61+
await this.processEvent(25);
62+
},
63+
},
64+
async run() {
65+
await this.processEvent();
66+
},
67+
sampleEmit,
68+
};

0 commit comments

Comments
 (0)