-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Workday API #18842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Workday API #18842
Changes from 16 commits
3473117
653fda0
5537759
899677d
a00a355
972de83
8175f00
35134f5
a78b196
6f9e603
d956cd7
77f64ec
eb27b30
caa98c3
b8dd91f
8978c7c
61047ea
91833f6
d87e92f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import workday from "../../workday.app.mjs"; | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| key: "workday-close-mentorship", | ||
| name: "Close Mentorship", | ||
| description: "End a mentorship for a given ID. [See the Documentation](https://community.workday.com/sites/default/files/file-hosting/restapi/#talentManagement/v2/post-/mentorships/-ID-/close)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
|
|
||
| type: "action", | ||
| props: { | ||
| workday, | ||
| mentorshipId: { | ||
| propDefinition: [ | ||
| workday, | ||
| "mentorshipId", | ||
| ], | ||
| }, | ||
| comment: { | ||
| type: "string", | ||
| label: "Comment", | ||
| description: "Last event comment (optional). Example: `Lorem ipsum dolor sit amet, ...`", | ||
| optional: true, | ||
| }, | ||
| startDate: { | ||
| type: "string", | ||
| label: "Start Date", | ||
| description: "Start date for the mentorship (ISO 8601). Example: `2025-10-18T07:00:00.000Z`", | ||
| }, | ||
| endDate: { | ||
| type: "string", | ||
| label: "End Date", | ||
| description: "End date for the mentorship (ISO 8601). Example: `2025-10-18T07:00:00.000Z`", | ||
| }, | ||
| closeMentorshipReason: { | ||
| type: "object", | ||
| label: "Close Mentorship Reason", | ||
| description: "Example: `{ \"id\": \"00000000000000000000000000000000\" }`", | ||
| }, | ||
| descriptor: { | ||
| type: "string", | ||
| label: "Descriptor", | ||
| description: "Display name. Example: `Lorem ipsum dolor sit ame`", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| if ( | ||
| !this.closeMentorshipReason || | ||
| typeof this.closeMentorshipReason !== "object" || | ||
| !this.closeMentorshipReason.id || | ||
| !this.closeMentorshipReason.id.trim() | ||
| ) { | ||
| throw new ConfigurationError("closeMentorshipReason is required and must be an object with a non-empty id property."); | ||
| } | ||
|
|
||
| const data = { | ||
| closeMentorshipReason: this.closeMentorshipReason, | ||
| startDate: this.startDate, | ||
| endDate: this.endDate, | ||
| }; | ||
| if (this.comment) data.comment = this.comment; | ||
| if (this.descriptor) data.descriptor = this.descriptor; | ||
|
|
||
| const response = await this.workday.closeMentorship({ | ||
| id: this.mentorshipId, | ||
| data, | ||
| $, | ||
| }); | ||
| $.export("$summary", `Mentorship ${this.mentorshipId} closed`); | ||
| return response; | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,91 @@ | ||||||||||||||||||
| import workday from "../../workday.app.mjs"; | ||||||||||||||||||
| import { ConfigurationError } from "@pipedream/platform"; | ||||||||||||||||||
| import utils from "../../sources/common/utils.mjs"; | ||||||||||||||||||
|
|
||||||||||||||||||
| export default { | ||||||||||||||||||
| key: "workday-create-digital-course", | ||||||||||||||||||
| name: "Create Digital Course", | ||||||||||||||||||
| description: "Create a digital learning course. [See the Documentation](https://community.workday.com/sites/default/files/file-hosting/restapi/#learning/v1/post-/manageDigitalCourses)", | ||||||||||||||||||
| version: "0.0.1", | ||||||||||||||||||
| annotations: { | ||||||||||||||||||
| destructiveHint: false, | ||||||||||||||||||
| openWorldHint: true, | ||||||||||||||||||
| readOnlyHint: false, | ||||||||||||||||||
| }, | ||||||||||||||||||
| type: "action", | ||||||||||||||||||
| props: { | ||||||||||||||||||
| workday, | ||||||||||||||||||
| topics: { | ||||||||||||||||||
| type: "string[]", | ||||||||||||||||||
| label: "Topics", | ||||||||||||||||||
| description: "The topics of the learning course event. Example: `[ { \"descriptor\": \"Leadership\", \"id\": \"topic-id-1\" } ]`", | ||||||||||||||||||
| }, | ||||||||||||||||||
| title: { | ||||||||||||||||||
| type: "string", | ||||||||||||||||||
| label: "Title", | ||||||||||||||||||
| description: "Course title. Example: `Digital Leadership 101`", | ||||||||||||||||||
| }, | ||||||||||||||||||
| availabilityStatus: { | ||||||||||||||||||
| type: "object", | ||||||||||||||||||
| label: "Availability Status", | ||||||||||||||||||
| description: "The status of the learning course event. Example: `{ \"id\": \"status-id-1\" }`", | ||||||||||||||||||
| }, | ||||||||||||||||||
| lessons: { | ||||||||||||||||||
| type: "string[]", | ||||||||||||||||||
| label: "Lessons", | ||||||||||||||||||
| description: "The course lessons of the learning course event. Example: `[ { \"title\": \"Lesson 1\", \"type\": { \"id\": \"type-id\" }, \"order\": 1, \"url\": \"https://...\", \"required\": true } ]`", | ||||||||||||||||||
| }, | ||||||||||||||||||
| description: { | ||||||||||||||||||
| type: "string", | ||||||||||||||||||
| label: "Description", | ||||||||||||||||||
| description: "Course description. Example: `Learn digital leadership strategies for remote teams.`", | ||||||||||||||||||
| }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| async run({ $ }) { | ||||||||||||||||||
| const parsedTopics = utils.parseJsonInput(this.topics); | ||||||||||||||||||
| const parsedLessons = utils.parseJsonInput(this.lessons); | ||||||||||||||||||
|
|
||||||||||||||||||
| if (!Array.isArray(parsedTopics) || parsedTopics.length === 0) { | ||||||||||||||||||
| throw new ConfigurationError("`topics` must be a non-empty array."); | ||||||||||||||||||
| } | ||||||||||||||||||
| for (const t of parsedTopics) { | ||||||||||||||||||
| if (!t.id || !t.descriptor) { | ||||||||||||||||||
| throw new ConfigurationError("Each topic must have both `id` and `descriptor`."); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| if (!Array.isArray(parsedLessons) || parsedLessons.length === 0) { | ||||||||||||||||||
| throw new ConfigurationError("`lessons` must be a non-empty array."); | ||||||||||||||||||
| } | ||||||||||||||||||
| for (const l of parsedLessons) { | ||||||||||||||||||
| if (!l.title || !l.type?.id || typeof l.order !== "number" || !l.url) { | ||||||||||||||||||
| throw new ConfigurationError("Each lesson must include `title`, `type` (object with id), `order` (integer), and `url`."); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| if (!this.title || !this.title.trim()) { | ||||||||||||||||||
| throw new ConfigurationError("`title` is required."); | ||||||||||||||||||
| } | ||||||||||||||||||
| if (!this.availabilityStatus || typeof this.availabilityStatus !== "object" || !this.availabilityStatus.id) { | ||||||||||||||||||
| throw new ConfigurationError("`availabilityStatus` is required and must be an object with a non-empty 'id'."); | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+69
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure - if (!this.availabilityStatus || typeof this.availabilityStatus !== "object" || !this.availabilityStatus.id) {
+ if (!this.availabilityStatus || typeof this.availabilityStatus !== "object"
+ || typeof this.availabilityStatus.id !== "string"
+ || !this.availabilityStatus.id.trim()) {
throw new ConfigurationError("`availabilityStatus` is required and must be an object with a non-empty 'id'.");
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| if (!this.description || !this.description.trim()) { | ||||||||||||||||||
| throw new ConfigurationError("`description` is required."); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| const data = { | ||||||||||||||||||
| topics: parsedTopics, | ||||||||||||||||||
| title: this.title, | ||||||||||||||||||
| availabilityStatus: this.availabilityStatus, | ||||||||||||||||||
| lessons: parsedLessons, | ||||||||||||||||||
| description: this.description, | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| const response = await this.workday.createDigitalCourse({ | ||||||||||||||||||
| $, | ||||||||||||||||||
| data, | ||||||||||||||||||
| }); | ||||||||||||||||||
| $.export("$summary", "Digital course created"); | ||||||||||||||||||
| return response; | ||||||||||||||||||
| }, | ||||||||||||||||||
| }; | ||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| import workday from "../../workday.app.mjs"; | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| key: "workday-create-distribution-request", | ||
| name: "Create Distribution Request", | ||
| description: "Create a new distribution request. [See the Documentation](https://community.workday.com/sites/default/files/file-hosting/restapi/#journeys/v1/post-/distributionRequests)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| workday, | ||
| builder: { | ||
| type: "object", | ||
| label: "Builder", | ||
| description: "A journey builder object. Example: `{ \"id\": \"00000000000000000000000000000000\" }`", | ||
| }, | ||
| category: { | ||
| type: "object", | ||
| label: "Category", | ||
| description: "A journey category object. Example: `{ \"id\": \"00000000000000000000000000000000\" }`", | ||
| }, | ||
| discoverableBuilder: { | ||
| type: "object", | ||
| label: "Discoverable Builder", | ||
| description: "A discoverable journey builder object. Example: `{ \"id\": \"00000000000000000000000000000000\" }`", | ||
| }, | ||
|
Comment on lines
+27
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Props marked required but treated optional in code
discoverableBuilder: {
type: "object",
label: "Discoverable Builder",
description: "A discoverable journey builder object. Example: `{ \"id\": \"00000000000000000000000000000000\" }`",
+ optional: true,
},
@@
relatedRole: {
type: "object",
label: "Related Role",
description: "Related role object. Example: `{ \"id\": \"00000000000000000000000000000000\" }`",
+ optional: true,
},Also applies to: 38-42 🤖 Prompt for AI Agents |
||
| includePreviousRecipients: { | ||
| type: "boolean", | ||
| label: "Include Previous Recipients", | ||
| description: "Whether to include previous recipients. Example: `true`", | ||
| optional: true, | ||
| }, | ||
| relatedRole: { | ||
| type: "object", | ||
| label: "Related Role", | ||
| description: "Related role object. Example: `{ \"id\": \"00000000000000000000000000000000\" }`", | ||
| }, | ||
| descriptor: { | ||
| type: "string", | ||
| label: "Descriptor", | ||
| description: "Display name for the instance. Example: `Distribution Request for Training`", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| if (!this.builder || typeof this.builder !== "object" || !this.builder.id || !this.builder.id.trim()) { | ||
| throw new ConfigurationError("Builder is required and must be an object with a non-empty id property."); | ||
| } | ||
| if (!this.category || typeof this.category !== "object" || !this.category.id || !this.category.id.trim()) { | ||
| throw new ConfigurationError("Category is required and must be an object with a non-empty id property."); | ||
| } | ||
| if (this.discoverableBuilder && (typeof this.discoverableBuilder !== "object" || !this.discoverableBuilder.id || !this.discoverableBuilder.id.trim())) { | ||
| throw new ConfigurationError("Discoverable Builder (if provided) must be an object with a non-empty id property."); | ||
| } | ||
| if (this.relatedRole && (typeof this.relatedRole !== "object" || !this.relatedRole.id || !this.relatedRole.id.trim())) { | ||
| throw new ConfigurationError("Related Role (if provided) must be an object with a non-empty id property."); | ||
| } | ||
|
|
||
| const data = { | ||
| builder: this.builder, | ||
| category: this.category, | ||
| }; | ||
| if (this.discoverableBuilder) data.discoverableBuilder = this.discoverableBuilder; | ||
| if (typeof this.includePreviousRecipients === "boolean") data.includePreviousRecipients = this.includePreviousRecipients; | ||
| if (this.relatedRole) data.relatedRole = this.relatedRole; | ||
| if (this.descriptor) data.descriptor = this.descriptor; | ||
|
|
||
| const response = await this.workday.createDistributionRequest({ | ||
| $, | ||
| data, | ||
| }); | ||
| $.export("$summary", "Distribution request created"); | ||
| return response; | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import workday from "../../workday.app.mjs"; | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| key: "workday-create-home-contact-information-change", | ||
| name: "create Home Contact Information Change", | ||
| description: "creates a home contact change for a worker. [See the Documentation](https://community.workday.com/sites/default/files/file-hosting/restapi/#person/v4/)", | ||
Lokeshchand33 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| workday, | ||
| workerId: { | ||
| propDefinition: [ | ||
| workday, | ||
| "workerId", | ||
| ], | ||
| }, | ||
| }, | ||
Lokeshchand33 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| async run({ $ }) { | ||
| if (!this.workerId || !this.workerId.trim()) { | ||
| throw new ConfigurationError("Worker ID is required."); | ||
| } | ||
| const response = await this.workday.createHomeContactInformationChange({ | ||
| workerId: this.workerId, | ||
| data: {}, | ||
| $, | ||
| }); | ||
Lokeshchand33 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| $.export("$summary", `Home contact change event created for worker ID ${this.workerId}`); | ||
| return response; | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import workday from "../../workday.app.mjs"; | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| key: "workday-create-mentorship-for-me", | ||
| name: "Create Mentorship For Current User", | ||
| description: "Creates a mentorship for the current user. [See the Documentation](https://community.workday.com/sites/default/files/file-hosting/restapi/#talentManagement/v2/post-/createMentorshipForMe)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| workday, | ||
| endDate: { | ||
| type: "string", | ||
| label: "End Date", | ||
| description: "Proposed end date (ISO 8601 format). Example: '2025-10-18T07:00:00.000Z'", | ||
| }, | ||
| startDate: { | ||
| type: "string", | ||
| label: "Start Date", | ||
| description: "Proposed start date (ISO 8601 format). Example: '2025-10-18T07:00:00.000Z'", | ||
| }, | ||
| purpose: { | ||
| type: "string", | ||
| label: "Purpose", | ||
| description: "Purpose of the mentorship.", | ||
| }, | ||
| mentor: { | ||
| type: "object", | ||
| label: "Mentor", | ||
| description: "Object with at least an `id`. Example: `{ id: \"00000000000000000000000000000000\"}`", | ||
| }, | ||
| comment: { | ||
| type: "string", | ||
| label: "Comment", | ||
| description: "Optional. Comment field for notes or special requests.", | ||
| optional: true, | ||
| }, | ||
| mentorType: { | ||
| type: "object", | ||
| label: "Mentor Type", | ||
| description: "Object with at least an `id`. Example: `{ id: \"00000000000000000000000000000000\"}`", | ||
| optional: true, | ||
| }, | ||
| descriptor: { | ||
| type: "string", | ||
| label: "Descriptor", | ||
| description: "Optional. Display name of the mentorship.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| if (!this.endDate || !this.endDate.trim()) throw new ConfigurationError("End Date is required and cannot be empty."); | ||
| if (!this.startDate || !this.startDate.trim()) throw new ConfigurationError("Start Date is required and cannot be empty."); | ||
| if (!this.purpose || !this.purpose.trim()) throw new ConfigurationError("Purpose is required and cannot be empty."); | ||
| if (!this.mentor || typeof this.mentor !== "object" || !this.mentor.id || !this.mentor.id.trim()) { | ||
| throw new ConfigurationError("Mentor is required and must be an object with a non-empty id property."); | ||
| } | ||
| if (this.mentorType !== undefined) { | ||
| if (typeof this.mentorType !== "object" || !this.mentorType.id || !this.mentorType.id.trim()) { | ||
| throw new ConfigurationError("If provided, mentorType must be an object with a non-empty id property."); | ||
| } | ||
| } | ||
|
|
||
| const data = { | ||
| endDate: this.endDate, | ||
| startDate: this.startDate, | ||
| purpose: this.purpose, | ||
| mentor: this.mentor, | ||
| }; | ||
| if (this.comment) data.comment = this.comment; | ||
| if (this.mentorType) data.mentorType = this.mentorType; | ||
| if (this.descriptor) data.descriptor = this.descriptor; | ||
|
|
||
| const response = await this.workday.createMentorshipForMe({ | ||
| $, | ||
| data, | ||
| }); | ||
| $.export("$summary", "Mentorship created for current user"); | ||
| return response; | ||
| }, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Add validation for required date fields.
The
startDateandendDatefields are required but lack validation. This is inconsistent with the validation provided forcloseMentorshipReason(lines 53-60). Without validation, the action could fail with unclear errors if these fields are missing or empty.Apply this diff to add validation:
async run({ $ }) { + if (!this.startDate || !this.startDate.trim()) { + throw new ConfigurationError("Start Date is required and cannot be empty."); + } + if (!this.endDate || !this.endDate.trim()) { + throw new ConfigurationError("End Date is required and cannot be empty."); + } if ( !this.closeMentorshipReason ||🤖 Prompt for AI Agents