Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import workday from "../../workday.app.mjs";

export default {
key: "workday-change-business-title",
name: "Change Business Title",
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)",
version: "0.0.1",
type: "action",
props: {
workday,
workerId: {
propDefinition: [
workday,
"workerId",
],
},
proposedBusinessTitle: {
type: "string",
label: "Proposed Business Title",
description: "The new business title for the worker",
},
},
async run({ $ }) {
const response = await this.workday.changeBusinessTitle({
$,
workerId: this.workerId,
data: {
proposedBusinessTitle: this.proposedBusinessTitle,
},
});
$.export("$summary", `Successfully changed business title for worker ${this.workerId}`);
return response;
},
};
60 changes: 60 additions & 0 deletions components/workday/actions/create-job-change/create-job-change.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import workday from "../../workday.app.mjs";

export default {
key: "workday-create-job-change",
name: "Create Job Change",
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)",
version: "0.0.1",
type: "action",
props: {
workday,
workerId: {
propDefinition: [
workday,
"workerId",
],
},
supervisoryOrganizationId: {
propDefinition: [
workday,
"supervisoryOrganizationId",
],
},
jobChangeReasonId: {
propDefinition: [
workday,
"jobChangeReasonId",
],
},
moveManagersTeam: {
type: "boolean",
label: "Move Managers Team",
description: "Indicates whether teams reporting to the ~Manager~ moved with them during the Change Job Event",
optional: true,
},
effective: {
type: "string",
label: "Effective",
description: "The date this business process takes effect. Example: `2025-08-09T07:00:00.000Z`",
optional: true,
},
},
async run({ $ }) {
const response = await this.workday.createJobChange({
$,
workerId: this.workerId,
data: {
supervisoryOrganization: {
id: this.supervisoryOrganizationId,
},
jobChangeReason: {
id: this.jobChangeReasonId,
},
moveManagersTeam: this.moveManagersTeam,
effective: this.effective,
},
});
$.export("$summary", `Successfully created job change for worker ${this.workerId}`);
return response;
},
};
26 changes: 26 additions & 0 deletions components/workday/actions/get-worker/get-worker.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import workday from "../../workday.app.mjs";

export default {
key: "workday-get-worker",
name: "Get Worker",
description: "Get a worker. [See the documentation](https://community.workday.com/sites/default/files/file-hosting/restapi/#common/v1/get-/workers/-ID-)",
version: "0.0.1",
type: "action",
props: {
workday,
workerId: {
propDefinition: [
workday,
"workerId",
],
},
},
async run({ $ }) {
const response = await this.workday.getWorker({
$,
workerId: this.workerId,
});
$.export("$summary", `Successfully fetched worker ${this.workerId}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import workday from "../../workday.app.mjs";

export default {
key: "workday-list-organization-types",
name: "List Organization Types",
description: "List organization types. [See the documentation](https://community.workday.com/sites/default/files/file-hosting/restapi/#common/v1/organizationTypes)",
version: "0.0.1",
type: "action",
props: {
workday,
maxResults: {
propDefinition: [
workday,
"maxResults",
],
},
},
async run({ $ }) {
const results = this.workday.paginate({
fn: this.workday.listOrganizationTypes,
args: {
$,
},
max: this.maxResults,
});

const data = [];
for await (const result of results) {
data.push(result);
}

$.export("$summary", `Successfully fetched ${data.length} organization types`);
return data;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import workday from "../../workday.app.mjs";

export default {
key: "workday-list-supervisory-organizations",
name: "List Supervisory Organizations",
description: "List supervisory organizations. [See the documentation](https://community.workday.com/sites/default/files/file-hosting/restapi/#common/v1/get-/supervisoryOrganizations)",
version: "0.0.1",
type: "action",
props: {
workday,
maxResults: {
propDefinition: [
workday,
"maxResults",
],
},
},
async run({ $ }) {
const results = this.workday.paginate({
fn: this.workday.listSupervisoryOrganizations,
args: {
$,
},
max: this.maxResults,
});

const data = [];
for await (const result of results) {
data.push(result);
}

$.export("$summary", `Successfully fetched ${data.length} supervisory organizations`);
return data;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import workday from "../../workday.app.mjs";

export default {
key: "workday-list-worker-payslips",
name: "List Worker Payslips",
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)",
version: "0.0.1",
type: "action",
props: {
workday,
workerId: {
propDefinition: [
workday,
"workerId",
],
},
maxResults: {
propDefinition: [
workday,
"maxResults",
],
},
},
async run({ $ }) {
const results = this.workday.paginate({
fn: this.workday.listWorkerPayslips,
args: {
$,
workerId: this.workerId,
},
max: this.maxResults,
});

const data = [];
for await (const result of results) {
data.push(result);
}

$.export("$summary", `Successfully fetched ${data.length} payslips for worker ${this.workerId}`);
return data;
},
};
44 changes: 44 additions & 0 deletions components/workday/actions/search-workers/search-workers.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import workday from "../../workday.app.mjs";

export default {
key: "workday-search-workers",
name: "Search Workers",
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)",
version: "0.0.1",
type: "action",
props: {
workday,
search: {
type: "string",
label: "Search",
description: "The search query to use to filter workers",
optional: true,
},
maxResults: {
propDefinition: [
workday,
"maxResults",
],
},
},
async run({ $ }) {
const results = this.workday.paginate({
fn: this.workday.listWorkers,
args: {
$,
params: {
search: this.search,
},
},
max: this.maxResults,
});

const data = [];
for await (const result of results) {
data.push(result);
}

$.export("$summary", `Successfully fetched ${data.length} workers`);
return data;
},
};
7 changes: 5 additions & 2 deletions components/workday/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/workday",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Workday Components",
"main": "workday.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
}
15 changes: 15 additions & 0 deletions components/workday/sources/common/base-polling.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import workday from "../../workday.app.mjs";
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";

export default {
props: {
workday,
db: "$.service.db",
timer: {
type: "$.interface.timer",
default: {
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
},
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import common from "../common/base-polling.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "workday-new-worker-created",
name: "New Worker Created",
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)",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
_getPreviousIds() {
return this.db.get("previousIds") || {};
},
_setPreviousIds(ids) {
this.db.set("previousIds", ids);
},
generateMeta(worker) {
return {
id: worker.id,
summary: `New worker created: ${worker.descriptor}`,
ts: Date.now(),
};
},
async processEvent(limit) {
const results = this.workday.paginate({
fn: this.workday.listWorkers,
});

const previousIds = this._getPreviousIds();
let workers = [];

for await (const worker of results) {
if (previousIds[worker.id]) {
continue;
}
workers.push(worker);
previousIds[worker.id] = true;
}

this._setPreviousIds(previousIds);

if (!workers?.length) {
return;
}

if (limit) {
workers = workers.slice(0, limit);
}

for (const worker of workers) {
const meta = this.generateMeta(worker);
this.$emit(worker, meta);
}
},
},
hooks: {
async deploy() {
await this.processEvent(25);
},
},
async run() {
await this.processEvent();
},
sampleEmit,
};
Loading
Loading