AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
fix(workday): run Get Report through RaaS, add an Integration System User connection, fix broken actions (#16526)
Kishan Parmarad0f1a7e20d4
diff --git a/packages/pieces/community/workday/package.json b/packages/pieces/community/workday/package.jsonindex a4f7dab7852..c5be92fb637 100644--- a/packages/pieces/community/workday/package.json+++ b/packages/pieces/community/workday/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/piece-workday",- "version": "0.1.1",+ "version": "0.2.0","type": "commonjs","main": "./dist/src/index.js","types": "./dist/src/index.d.ts",diff --git a/packages/pieces/community/workday/src/index.ts b/packages/pieces/community/workday/src/index.tsindex d11d83e0618..536164e5910 100644--- a/packages/pieces/community/workday/src/index.ts+++ b/packages/pieces/community/workday/src/index.ts@@ -1,113 +1,108 @@-import {- OAuth2PropertyValue,- createPiece,-} from '@activepieces/pieces-framework';-import { PieceCategory } from '@activepieces/pieces-framework';import { createCustomApiCallAction } from '@activepieces/pieces-common';+import { PieceCategory } from '@activepieces/pieces-framework';+import { createPiece } from '@activepieces/pieces-framework';+import { approveTaskAction } from './lib/actions/approve-task';+import { callOperationAction } from './lib/actions/call-operation';+import { changeJobAction } from './lib/actions/change-job';+import { createJobRequisitionAction } from './lib/actions/create-job-requisition';+import { createPreHireAction } from './lib/actions/create-pre-hire';+import { createSupplierCreditMemoAction } from './lib/actions/create-supplier-credit-memo';+import { createTimeOffRequestAction } from './lib/actions/create-time-off-request';+import { createUpdateCustomObjectAction } from './lib/actions/create-update-custom-object';+import { createWorkerTimeBlockAction } from './lib/actions/create-worker-time-block';+import { findPurchaseOrderAction } from './lib/actions/find-purchase-order';+import { findRecordsWqlAction } from './lib/actions/find-records-wql';+import { findSupplierAction } from './lib/actions/find-supplier';+import { findSupplierInvoiceAction } from './lib/actions/find-supplier-invoice';+import { findSupplierPaymentAction } from './lib/actions/find-supplier-payment';+import { getBusinessObjectDetailsBatchAction } from './lib/actions/get-business-object-details-batch';+import { getCustomObjectsAction } from './lib/actions/get-custom-objects';+import { getReportAction } from './lib/actions/get-report';+import { getReportWqlBatchAction } from './lib/actions/get-report-wql-batch';+import { hireEmployeeAction } from './lib/actions/hire-employee';+import { listCustomObjectDefinitionsBatchAction } from './lib/actions/list-custom-object-definitions-batch';+import { searchBusinessObjectBatchAction } from './lib/actions/search-business-object-batch';+import { updateBusinessObjectAction } from './lib/actions/update-business-object';+import { updateSupplierAction } from './lib/actions/update-supplier';+import { updateSupplierInvoiceAction } from './lib/actions/update-supplier-invoice';import { workdayAuth } from './lib/auth';--import { approveTask } from './lib/action/approve-task';-import { changeJob } from './lib/action/change-job';-import { createJobRequisition } from './lib/action/create-job-requisition';-import { createPreHire } from './lib/action/create-pre-hire';-import { createSupplierCreditMemo } from './lib/action/create-supplier-credit-memo';-import { createTimeOffRequest } from './lib/action/create-time-off-request';-import { createWorkerTimeBlock } from './lib/action/create-worker-time-block';-import { findPurchaseOrder } from './lib/action/find-purchase-order';-import { findRecordsWql } from './lib/action/find-records-wql';-import { findSupplier } from './lib/action/find-supplier';-import { findSupplierInvoice } from './lib/action/find-supplier-invoice';-import { findSupplierPayment } from './lib/action/find-supplier-payment';-import { hireEmployee } from './lib/action/hire-employee';-import { updateSupplier } from './lib/action/update-supplier';-import { updateSupplierInvoice } from './lib/action/update-supplier-invoice';--import { callOperation } from './lib/action/call-operation';-import { createUpdateCustomObject } from './lib/action/create-update-custom-object';-import { getBusinessObjectDetailsBatch } from './lib/action/get-business-object-details-batch';-import { getCustomObjects } from './lib/action/get-custom-objects';-import { getReport } from './lib/action/get-report';-import { getReportWqlBatch } from './lib/action/get-report-wql-batch';-import { listCustomObjectDefinitionsBatch } from './lib/action/list-custom-object-definitions-batch';-import { searchBusinessObjectBatch } from './lib/action/search-business-object-batch';-import { updateBusinessObject } from './lib/action/update-business-object';--import { businessProcessCompleted } from './lib/trigger/business-process-completed';-import { employeeTerminated } from './lib/trigger/employee-terminated';-import { expenseReportSubmitted } from './lib/trigger/expense-report-submitted';-import { leaveRequestSubmitted } from './lib/trigger/leave-request-submitted';-import { newHireCreated } from './lib/trigger/new-hire-created';-import { newInboxTask } from './lib/trigger/new-inbox-task';-import { newSupplier } from './lib/trigger/new-supplier';-import { newSupplierInvoice } from './lib/trigger/new-supplier-invoice';-import { runWqlQuery } from './lib/trigger/run-wql-query';-import { updatedSupplier } from './lib/trigger/updated-supplier';--import { newOrUpdatedBusinessObject } from './lib/trigger/new-or-updated-business-object';-import { newOrUpdatedBusinessObjectBatch } from './lib/trigger/new-or-updated-business-object-batch';-import { scheduledReportFetchBatch } from './lib/trigger/scheduled-report-fetch-batch';-import { scheduledReportFetchWqlBatch } from './lib/trigger/scheduled-report-fetch-wql-batch';+import { workdayClient } from './lib/common/client';+import { businessProcessCompletedTrigger } from './lib/triggers/business-process-completed';+import { employeeTerminatedTrigger } from './lib/triggers/employee-terminated';+import { expenseReportSubmittedTrigger } from './lib/triggers/expense-report-submitted';+import { leaveRequestSubmittedTrigger } from './lib/triggers/leave-request-submitted';+import { newHireCreatedTrigger } from './lib/triggers/new-hire-created';+import { newInboxTaskTrigger } from './lib/triggers/new-inbox-task';+import { newOrUpdatedBusinessObjectTrigger } from './lib/triggers/new-or-updated-business-object';+import { newOrUpdatedBusinessObjectBatchTrigger } from './lib/triggers/new-or-updated-business-object-batch';+import { newSupplierTrigger } from './lib/triggers/new-supplier';+import { newSupplierInvoiceTrigger } from './lib/triggers/new-supplier-invoice';+import { runWqlQueryTrigger } from './lib/triggers/run-wql-query';+import { scheduledReportFetchBatchTrigger } from './lib/triggers/scheduled-report-fetch-batch';+import { scheduledReportFetchWqlBatchTrigger } from './lib/triggers/scheduled-report-fetch-wql-batch';+import { updatedSupplierTrigger } from './lib/triggers/updated-supplier';export const workday = createPiece({displayName: 'Workday',- description:- 'Cloud-based enterprise platform for human resources, finance, and planning.',+ description: 'Cloud-based enterprise platform for human resources, finance, and planning.',minimumSupportedRelease: '0.36.1',logoUrl: 'https://cdn.activepieces.com/pieces/workday.jpg',authors: [],categories: [PieceCategory.HUMAN_RESOURCES],auth: workdayAuth,actions: [- approveTask,- changeJob,- createJobRequisition,- createPreHire,- createSupplierCreditMemo,- createTimeOffRequest,- createWorkerTimeBlock,- findPurchaseOrder,- findRecordsWql,- findSupplier,- findSupplierInvoice,- findSupplierPayment,- hireEmployee,- updateSupplier,- updateSupplierInvoice,- getBusinessObjectDetailsBatch,- searchBusinessObjectBatch,- updateBusinessObject,- callOperation,- getCustomObjects,- getReport,- getReportWqlBatch,- listCustomObjectDefinitionsBatch,- createUpdateCustomObject,+ approveTaskAction,+ changeJobAction,+ createJobRequisitionAction,+ createPreHireAction,+ createSupplierCreditMemoAction,+ createTimeOffRequestAction,+ createWorkerTimeBlockAction,+ findPurchaseOrderAction,+ findRecordsWqlAction,+ findSupplierAction,+ findSupplierInvoiceAction,+ findSupplierPaymentAction,+ hireEmployeeAction,+ updateSupplierAction,+ updateSupplierInvoiceAction,+ getBusinessObjectDetailsBatchAction,+ searchBusinessObjectBatchAction,+ updateBusinessObjectAction,+ callOperationAction,+ getCustomObjectsAction,+ getReportAction,+ getReportWqlBatchAction,+ listCustomObjectDefinitionsBatchAction,+ createUpdateCustomObjectAction,createCustomApiCallAction({baseUrl: (auth) => {- const value = auth as OAuth2PropertyValue;- return `https://${value.props?.['apiHost']}/ccx/api/v1/${value.props?.['tenant']}`;+ if (!auth) {+ throw new Error('Connect Workday first.');+ }+ return workdayClient.baseUrl({ auth });},auth: workdayAuth,authMapping: async (auth) => ({- Authorization: `Bearer ${(auth as OAuth2PropertyValue).access_token}`,+ Authorization: `Bearer ${workdayClient.bearerToken({ auth })}`,}),}),],triggers: [- businessProcessCompleted,- employeeTerminated,- expenseReportSubmitted,- leaveRequestSubmitted,- newHireCreated,- newInboxTask,- newSupplier,- newSupplierInvoice,- runWqlQuery,- updatedSupplier,- newOrUpdatedBusinessObject,- newOrUpdatedBusinessObjectBatch,- scheduledReportFetchBatch,- scheduledReportFetchWqlBatch,+ businessProcessCompletedTrigger,+ employeeTerminatedTrigger,+ expenseReportSubmittedTrigger,+ leaveRequestSubmittedTrigger,+ newHireCreatedTrigger,+ newInboxTaskTrigger,+ newSupplierTrigger,+ newSupplierInvoiceTrigger,+ runWqlQueryTrigger,+ updatedSupplierTrigger,+ newOrUpdatedBusinessObjectTrigger,+ newOrUpdatedBusinessObjectBatchTrigger,+ scheduledReportFetchBatchTrigger,+ scheduledReportFetchWqlBatchTrigger,],});diff --git a/packages/pieces/community/workday/src/lib/action/actions.test.ts b/packages/pieces/community/workday/src/lib/action/actions.test.tsdeleted file mode 100644index c6a25a61a92..00000000000--- a/packages/pieces/community/workday/src/lib/action/actions.test.ts+++ /dev/null@@ -1,240 +0,0 @@-import {- HttpMethod,- HttpRequest,- HttpResponse,- httpClient,-} from '@activepieces/pieces-common';-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';-import { callOperation } from './call-operation';-import { createUpdateCustomObject } from './create-update-custom-object';-import { getBusinessObjectDetailsBatch } from './get-business-object-details-batch';-import { getCustomObjects } from './get-custom-objects';-import { getReport } from './get-report';-import { getReportWqlBatch } from './get-report-wql-batch';-import { listCustomObjectDefinitionsBatch } from './list-custom-object-definitions-batch';-import { searchBusinessObjectBatch } from './search-business-object-batch';-import { updateBusinessObject } from './update-business-object';--const AUTH = {- access_token: 'tok',- props: { apiHost: 'wd2-impl-services1.workday.com', tenant: 'mytenant' },-};--const AUTH_WITH_ISU = {- access_token: 'tok',- props: {- apiHost: 'wd2-impl-services1.workday.com',- tenant: 'mytenant',- isuUsername: 'isu@mytenant',- isuPassword: 'secret',- },-};--function resp(body: unknown): HttpResponse {- return { status: 200, headers: {}, body };-}--function context(propsValue: Record<string, unknown>, auth: unknown = AUTH) {- return { auth, propsValue } as never;-}--let sendRequest: ReturnType<typeof vi.spyOn>;--function requests(): HttpRequest[] {- return sendRequest.mock.calls.map((c) => c[0] as HttpRequest);-}--beforeEach(() => {- sendRequest = vi.spyOn(httpClient, 'sendRequest');-});--afterEach(() => {- vi.restoreAllMocks();-});--describe('get_business_object_details_batch', () => {- it('fetches each id and returns standardized records', async () => {- sendRequest.mockImplementation(async (request: HttpRequest) => {- const id = request.url.split('/').pop();- return resp({ id, title: `Req ${id}`, applicationStatus: 'Open' });- });-- const out = (await getBusinessObjectDetailsBatch.run(- context({- module: 'recruiting',- businessObject: { objectType: 'jobRequisitions' },- objectIds: [{ id: '1' }, { id: '2' }],- }),- )) as { total_count: number; records: Record<string, unknown>[] };-- expect(out.total_count).toBe(2);- expect(out.records[0]).toMatchObject({ job_requisition_id: '1', title: 'Req 1' });- expect(requests()[0].url).toBe(- 'https://wd2-impl-services1.workday.com/ccx/api/staffing/v6/mytenant/jobRequisitions/1',- );- });-});--describe('search_business_object_batch', () => {- it('paginates and returns standardized records', async () => {- sendRequest.mockResolvedValue(- resp({ data: [{ id: 'w-1', descriptor: 'Jane', hireDate: '2025-01-01' }], total: 1 }),- );-- const out = (await searchBusinessObjectBatch.run(- context({- module: 'onboarding',- businessObject: { objectType: 'workers' },- queryParams: { status: 'Active' },- }),- )) as { total_count: number; records: Record<string, unknown>[] };-- expect(out.total_count).toBe(1);- expect(out.records[0]).toMatchObject({ employee_id: 'w-1', name: 'Jane' });- });-});--describe('update_business_object', () => {- it('PUTs to the record path and standardizes the response', async () => {- sendRequest.mockResolvedValue(resp({ id: 'w-1', status: 'Inactive' }));-- await updateBusinessObject.run(- context({- module: 'onboarding',- businessObject: { objectType: 'workers' },- objectId: 'w-1',- body: { status: 'Inactive' },- }),- );-- const req = requests()[0];- expect(req.method).toBe(HttpMethod.PUT);- expect(req.url).toBe(- 'https://wd2-impl-services1.workday.com/ccx/api/staffing/v6/mytenant/workers/w-1',- );- expect(req.body).toEqual({ status: 'Inactive' });- });-});--describe('call_operation', () => {- it('calls a REST sub-resource with the chosen method', async () => {- sendRequest.mockResolvedValue(resp({ id: 'req-1', status: 'Closed' }));-- await callOperation.run(- context({- module: 'recruiting',- businessObject: { objectType: 'jobRequisitions' },- operationType: 'rest',- operationName: '1/close',- httpMethod: 'POST',- }),- );-- const req = requests()[0];- expect(req.method).toBe(HttpMethod.POST);- expect(req.url).toBe(- 'https://wd2-impl-services1.workday.com/ccx/api/staffing/v6/mytenant/jobRequisitions/1/close',- );- });-- it('calls a SOAP operation when operationType is soap', async () => {- sendRequest.mockResolvedValue(- resp(- '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><Result>ok</Result></soapenv:Body></soapenv:Envelope>',- ),- );-- await callOperation.run(- context(- {- module: 'recruiting',- businessObject: { objectType: 'jobRequisitions' },- operationType: 'soap',- operationName: 'Submit_Job_Requisition',- soapService: 'Staffing',- },- AUTH_WITH_ISU,- ),- );-- const req = requests()[0];- expect(req.url).toContain('/ccx/service/mytenant/Staffing/');- expect(String(req.body)).toContain('soapenv:Envelope');- });-});--describe('get_custom_objects', () => {- it('GETs a custom object instance and flattens it', async () => {- sendRequest.mockResolvedValue(resp({ id: 'obj-1', data: { name: 'X' } }));-- const out = (await getCustomObjects.run(- context({ definitionId: 'def-1', objectId: 'obj-1' }),- )) as Record<string, unknown>;-- expect(out['data_name']).toBe('X');- expect(requests()[0].url).toContain('/customObjects/v1/mytenant/customObjects/def-1');- });-});--describe('get_report', () => {- it('returns flattened report rows from Report_Entry', async () => {- sendRequest.mockResolvedValue(- resp({ Report_Entry: [{ employee_id: 'w-1' }, { employee_id: 'w-2' }] }),- );-- const out = (await getReport.run(- context({ reportId: 'Worker_Report', reportParameters: undefined }),- )) as { total_count: number; report_id: string };-- expect(out.total_count).toBe(2);- expect(out.report_id).toBe('Worker_Report');- });-});--describe('get_report_wql_batch', () => {- it('runs a WQL query and returns all rows', async () => {- sendRequest.mockResolvedValue(resp({ data: [{ id: 1 }, { id: 2 }, { id: 3 }] }));-- const out = (await getReportWqlBatch.run(- context({ query: 'SELECT id FROM workers' }),- )) as { total_count: number };-- expect(out.total_count).toBe(3);- });-});--describe('list_custom_object_definitions_batch', () => {- it('lists definitions with a count', async () => {- sendRequest.mockResolvedValue(resp({ data: [{ id: 'def-1' }, { id: 'def-2' }] }));-- const out = (await listCustomObjectDefinitionsBatch.run(context({}))) as {- total_count: number;- };-- expect(out.total_count).toBe(2);- });-});--describe('create_update_custom_object', () => {- it('creates a custom object (no id) with PUT', async () => {- sendRequest.mockResolvedValue(resp({ id: 'obj-1' }));-- await createUpdateCustomObject.run(- context({ definitionId: 'def-1', objectId: undefined, body: { name: 'X' } }),- );-- const req = requests()[0];- expect(req.method).toBe(HttpMethod.PUT);- expect(req.body).toEqual({ name: 'X' });- });-- it('injects the id into the body when updating', async () => {- sendRequest.mockResolvedValue(resp({ id: 'obj-1' }));-- await createUpdateCustomObject.run(- context({ definitionId: 'def-1', objectId: 'obj-1', body: { name: 'X' } }),- );-- expect(requests()[0].body).toEqual({ name: 'X', id: 'obj-1' });- });-});diff --git a/packages/pieces/community/workday/src/lib/action/approve-task.ts b/packages/pieces/community/workday/src/lib/action/approve-task.tsdeleted file mode 100644index c8854b34a21..00000000000--- a/packages/pieces/community/workday/src/lib/action/approve-task.ts+++ /dev/null@@ -1,64 +0,0 @@-import {- OAuth2PropertyValue,- Property,- createAction,-} from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdaySoapRequest } from '../common';--export const approveTask = createAction({- auth: workdayAuth,- name: 'approve_task',- classification: 'WRITE',- displayName: 'Approve Task',- description: 'Approves an inbox task in Workday.',- audience: 'both',- aiMetadata: {- description:- 'Approves a pending Workday business-process inbox task, identified by its task WID, optionally attaching an approval comment. Use to advance an awaiting-approval step (e.g. a time-off or hiring request) once a decision is made. Not idempotent: it submits an approval event each call and the task can only be approved once.',- idempotent: false,- },- props: {- taskId: Property.ShortText({- displayName: 'Task ID',- description: 'The ID of the inbox task to approve.',- required: true,- }),- comment: Property.LongText({- displayName: 'Comment',- description: 'Optional comment for the approval.',- required: false,- }),- },- async run(ctx) {- const { taskId, comment } = ctx.propsValue;-- const escapeXml = (s: string) =>- s- .replace(/&/g, '&')- .replace(/</g, '<')- .replace(/>/g, '>')- .replace(/"/g, '"');-- let commentXml = '';- if (comment) {- commentXml = `- <bsvc:Business_Process_Comment_Data>- <bsvc:Comment>${escapeXml(comment)}</bsvc:Comment>- </bsvc:Business_Process_Comment_Data>`;- }-- const operationXml = `- <bsvc:Approve_Business_Process_Request bsvc:version="v46.0" xmlns:bsvc="urn:com.workday/bsvc">- <bsvc:Event_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(taskId)}</bsvc:ID>- </bsvc:Event_Reference>${commentXml}- </bsvc:Approve_Business_Process_Request>`;-- return workdaySoapRequest(- ctx.auth as OAuth2PropertyValue,- 'Integrations',- operationXml,- );- },-});diff --git a/packages/pieces/community/workday/src/lib/action/call-operation.ts b/packages/pieces/community/workday/src/lib/action/call-operation.tsdeleted file mode 100644index cc9c4b2eff1..00000000000--- a/packages/pieces/community/workday/src/lib/action/call-operation.ts+++ /dev/null@@ -1,110 +0,0 @@-import { HttpMethod } from '@activepieces/pieces-common';-import { Property, createAction } from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdayRequest, workdaySoapRequest } from '../common';-import { flattenRecord } from '../common/fields';-import { resolveBusinessObject } from '../common/modules';-import { operationNameProperty, sharedModuleProps } from '../common/props';--export const callOperation = createAction({- auth: workdayAuth,- name: 'call_operation',- classification: 'WRITE',- displayName: 'Call Operation',- description:- 'Calls a Workday REST sub-resource or SOAP operation (e.g. approve, close, submit).',- audience: 'both',- aiMetadata: {- description:- 'Invokes a Workday operation that has no dedicated action, in one of two modes: a REST sub-resource call (POST, PUT, or PATCH against a business-object path such as /jobRequisitions/{id}/close) or a raw SOAP operation against a named web service such as Staffing. Use as the escape hatch for verbs like approve, close, or submit, and prefer the specific action (e.g. Approve Task, Update Business Object) whenever one exists. Requires the operation name, plus the SOAP service name when running in SOAP mode. Not idempotent: each call submits the operation as a fresh event.',- idempotent: false,- },- props: {- ...sharedModuleProps,- operationType: Property.StaticDropdown({- displayName: 'Operation Type',- required: true,- defaultValue: 'rest',- options: {- disabled: false,- options: [- { label: 'REST sub-resource', value: 'rest' },- { label: 'SOAP operation', value: 'soap' },- ],- },- }),- operationName: operationNameProperty,- soapService: Property.ShortText({- displayName: 'SOAP Service Name',- description: 'Required for SOAP operations, e.g. `Staffing` or `Human_Resources`.',- required: false,- }),- httpMethod: Property.StaticDropdown({- displayName: 'HTTP Method',- required: false,- defaultValue: 'POST',- options: {- disabled: false,- options: [- { label: 'POST', value: 'POST' },- { label: 'PUT', value: 'PUT' },- { label: 'PATCH', value: 'PATCH' },- ],- },- }),- body: Property.Json({- displayName: 'Request Body (JSON)',- description: 'JSON payload for REST operations.',- required: false,- }),- soapBody: Property.LongText({- displayName: 'SOAP Body (XML)',- description:- 'Raw SOAP operation XML, used only for SOAP operations. Leave empty to send an empty operation element.',- required: false,- }),- },- async run({ auth, propsValue }) {- if (propsValue.operationType === 'soap') {- if (!propsValue.soapService) {- throw new Error('SOAP Service Name is required for SOAP operations.');- }- const xml =- propsValue.soapBody && propsValue.soapBody.trim().length > 0- ? propsValue.soapBody- : `<${propsValue.operationName} xmlns:bsvc="urn:com.workday/bsvc"/>`;- const result = await workdaySoapRequest(auth, propsValue.soapService, xml);- return flattenRecord(result);- }-- const bo = propsValue.businessObject as {- objectType?: string;- customPath?: string;- customService?: string;- };- const config = resolveBusinessObject(- propsValue.module,- bo.objectType,- bo.customPath,- bo.customService,- );- const path = propsValue.operationName.startsWith('/')- ? propsValue.operationName- : `${config.path}/${propsValue.operationName}`;- const method = (propsValue.httpMethod ?? 'POST') as HttpMethod;- const body =- propsValue.body && typeof propsValue.body === 'object'- ? (propsValue.body as Record<string, unknown>)- : undefined;-- const response = await workdayRequest<Record<string, unknown>>(- auth,- method,- path,- body,- undefined,- config.service,- );- return flattenRecord(response.body);- },-});diff --git a/packages/pieces/community/workday/src/lib/action/change-job.ts b/packages/pieces/community/workday/src/lib/action/change-job.tsdeleted file mode 100644index f99c22a3e23..00000000000--- a/packages/pieces/community/workday/src/lib/action/change-job.ts+++ /dev/null@@ -1,121 +0,0 @@-import {- OAuth2PropertyValue,- Property,- createAction,-} from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdaySoapRequest } from '../common';--export const changeJob = createAction({- auth: workdayAuth,- name: 'change_job',- classification: 'WRITE',- displayName: 'Change Job',- description: 'Changes the job for a worker in Workday.',- audience: 'both',- aiMetadata: {- description:- "Initiates and auto-completes a Change Job business process for an existing worker (by worker WID), effective on a given date with a reason WID, optionally moving them to a new job profile, supervisory organization, and/or position. Use to record a worker's transfer, promotion, or reorganization. Not idempotent: each call submits a new job-change event.",- idempotent: false,- },- props: {- workerId: Property.ShortText({- displayName: 'Worker ID',- description: 'The ID of the worker whose job to change.',- required: true,- }),- effectiveDate: Property.ShortText({- displayName: 'Effective Date',- description: 'Effective date of the job change (YYYY-MM-DD).',- required: true,- }),- reasonId: Property.ShortText({- displayName: 'Reason ID',- description: 'The reason for the job change.',- required: true,- }),- jobProfileId: Property.ShortText({- displayName: 'Job Profile ID',- description: 'New job profile reference ID.',- required: false,- }),- supervisoryOrganizationId: Property.ShortText({- displayName: 'Supervisory Organization ID',- description: 'New supervisory organization reference ID.',- required: false,- }),- positionId: Property.ShortText({- displayName: 'Position ID',- description: 'New position reference ID.',- required: false,- }),- },- async run(ctx) {- const {- workerId,- effectiveDate,- reasonId,- jobProfileId,- supervisoryOrganizationId,- positionId,- } = ctx.propsValue;-- const escapeXml = (s: string) =>- s- .replace(/&/g, '&')- .replace(/</g, '<')- .replace(/>/g, '>')- .replace(/"/g, '"');-- let supervisoryOrgXml = '';- if (supervisoryOrganizationId) {- supervisoryOrgXml = `- <bsvc:Supervisory_Organization_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(supervisoryOrganizationId)}</bsvc:ID>- </bsvc:Supervisory_Organization_Reference>`;- }-- let jobDetailsXml = '';- if (jobProfileId) {- jobDetailsXml = `- <bsvc:Job_Details_Data>- <bsvc:Job_Profile_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(jobProfileId)}</bsvc:ID>- </bsvc:Job_Profile_Reference>- </bsvc:Job_Details_Data>`;- }-- let positionXml = '';- if (positionId) {- positionXml = `- <bsvc:Position_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(positionId)}</bsvc:ID>- </bsvc:Position_Reference>`;- }-- const operationXml = `- <bsvc:Change_Job_Request bsvc:version="v46.0" xmlns:bsvc="urn:com.workday/bsvc">- <bsvc:Business_Process_Parameters>- <bsvc:Auto_Complete>true</bsvc:Auto_Complete>- <bsvc:Run_Now>true</bsvc:Run_Now>- </bsvc:Business_Process_Parameters>- <bsvc:Change_Job_Data>- <bsvc:Worker_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(workerId)}</bsvc:ID>- </bsvc:Worker_Reference>${positionXml}- <bsvc:Effective_Date>${escapeXml(effectiveDate)}</bsvc:Effective_Date>- <bsvc:Change_Job_Detail_Data>- <bsvc:Reason_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(reasonId)}</bsvc:ID>- </bsvc:Reason_Reference>${supervisoryOrgXml}${jobDetailsXml}- </bsvc:Change_Job_Detail_Data>- </bsvc:Change_Job_Data>- </bsvc:Change_Job_Request>`;-- return workdaySoapRequest(- ctx.auth as OAuth2PropertyValue,- 'Staffing',- operationXml,- );- },-});diff --git a/packages/pieces/community/workday/src/lib/action/create-job-requisition.ts b/packages/pieces/community/workday/src/lib/action/create-job-requisition.tsdeleted file mode 100644index 1b886406c25..00000000000--- a/packages/pieces/community/workday/src/lib/action/create-job-requisition.ts+++ /dev/null@@ -1,121 +0,0 @@-import {- OAuth2PropertyValue,- Property,- createAction,-} from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdaySoapRequest } from '../common';--export const createJobRequisition = createAction({- auth: workdayAuth,- name: 'create_job_requisition',- classification: 'WRITE',- displayName: 'Create Job Requisition',- description: 'Creates a new job requisition in Workday.',- audience: 'both',- aiMetadata: {- description:- 'Creates and auto-completes a job requisition under a supervisory organization (by WID) with a creation-reason WID, posting title, and number of openings, optionally setting job profile, location, recruiting-start, and target-hire dates. Use to open a new req before recruiting/hiring. Not idempotent: each call creates a separate requisition.',- idempotent: false,- },- props: {- supervisoryOrganizationId: Property.ShortText({- displayName: 'Supervisory Organization ID',- description: 'The supervisory organization for the requisition.',- required: true,- }),- reasonId: Property.ShortText({- displayName: 'Reason ID',- description: 'The reason for creating the requisition.',- required: true,- }),- jobPostingTitle: Property.ShortText({- displayName: 'Job Posting Title',- description: 'The title for the job posting.',- required: true,- }),- numberOfOpenings: Property.Number({- displayName: 'Number of Openings',- description: 'Number of openings (default: 1).',- required: false,- defaultValue: 1,- }),- jobProfileId: Property.ShortText({- displayName: 'Job Profile ID',- description: 'Job profile reference ID.',- required: false,- }),- primaryLocationId: Property.ShortText({- displayName: 'Primary Location ID',- description: 'Primary location reference ID.',- required: false,- }),- recruitingStartDate: Property.ShortText({- displayName: 'Recruiting Start Date',- description: 'Date to start recruiting (YYYY-MM-DD).',- required: false,- }),- targetHireDate: Property.ShortText({- displayName: 'Target Hire Date',- description: 'Target date for hiring (YYYY-MM-DD).',- required: false,- }),- },- async run(ctx) {- const {- supervisoryOrganizationId,- reasonId,- jobPostingTitle,- numberOfOpenings,- recruitingStartDate,- targetHireDate,- } = ctx.propsValue;-- const escapeXml = (s: string) =>- s- .replace(/&/g, '&')- .replace(/</g, '<')- .replace(/>/g, '>')- .replace(/"/g, '"');-- const openings = numberOfOpenings ?? 1;-- let recruitingStartDateXml = '';- if (recruitingStartDate) {- recruitingStartDateXml = `- <bsvc:Recruiting_Start_Date>${escapeXml(recruitingStartDate)}</bsvc:Recruiting_Start_Date>`;- }-- let targetHireDateXml = '';- if (targetHireDate) {- targetHireDateXml = `- <bsvc:Target_Hire_Date>${escapeXml(targetHireDate)}</bsvc:Target_Hire_Date>`;- }-- const operationXml = `- <bsvc:Create_Requisition_Request bsvc:version="v46.0" xmlns:bsvc="urn:com.workday/bsvc">- <bsvc:Business_Process_Parameters>- <bsvc:Auto_Complete>true</bsvc:Auto_Complete>- <bsvc:Run_Now>true</bsvc:Run_Now>- </bsvc:Business_Process_Parameters>- <bsvc:Create_Job_Requisition_Data>- <bsvc:Supervisory_Organization_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(supervisoryOrganizationId)}</bsvc:ID>- </bsvc:Supervisory_Organization_Reference>- <bsvc:Create_Job_Requisition_Reason_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(reasonId)}</bsvc:ID>- </bsvc:Create_Job_Requisition_Reason_Reference>- <bsvc:Job_Requisition_Data>- <bsvc:Job_Posting_Title>${escapeXml(jobPostingTitle)}</bsvc:Job_Posting_Title>- <bsvc:Number_of_Openings>${openings}</bsvc:Number_of_Openings>${recruitingStartDateXml}${targetHireDateXml}- </bsvc:Job_Requisition_Data>- </bsvc:Create_Job_Requisition_Data>- </bsvc:Create_Requisition_Request>`;-- return workdaySoapRequest(- ctx.auth as OAuth2PropertyValue,- 'Recruiting',- operationXml,- );- },-});diff --git a/packages/pieces/community/workday/src/lib/action/create-pre-hire.ts b/packages/pieces/community/workday/src/lib/action/create-pre-hire.tsdeleted file mode 100644index 6f5562095d8..00000000000--- a/packages/pieces/community/workday/src/lib/action/create-pre-hire.ts+++ /dev/null@@ -1,119 +0,0 @@-import {- OAuth2PropertyValue,- Property,- createAction,-} from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdaySoapRequest } from '../common';--export const createPreHire = createAction({- auth: workdayAuth,- name: 'create_pre_hire',- classification: 'WRITE',- displayName: 'Create Pre-Hire',- description: 'Creates a new pre-hire record in Workday.',- audience: 'both',- aiMetadata: {- description:- 'Creates a pre-hire/applicant record in Workday with legal name, contact details (email plus optional phone), and an ISO 3166-1 Alpha-3 country code. Use to register a candidate before running the Hire Employee action against them. Country is required by Workday. Not idempotent: each call submits a new applicant, with no key to update an existing one.',- idempotent: false,- },- props: {- firstName: Property.ShortText({- displayName: 'First Name',- description: 'Legal first name of the pre-hire.',- required: true,- }),- lastName: Property.ShortText({- displayName: 'Last Name',- description: 'Legal last name of the pre-hire.',- required: true,- }),- email: Property.ShortText({- displayName: 'Email',- description: 'Email address (at least one of email, phone, or address is required).',- required: true,- }),- phone: Property.ShortText({- displayName: 'Phone',- description: 'Phone number.',- required: false,- }),- dateOfBirth: Property.ShortText({- displayName: 'Date of Birth',- description: 'Date of birth (YYYY-MM-DD).',- required: false,- }),- country: Property.ShortText({- displayName: 'Country',- description: 'ISO 3166-1 Alpha-3 country code (e.g., "USA", "GBR", "DEU"). Required by Workday.',- required: true,- defaultValue: 'USA',- }),- },- async run(ctx) {- const { firstName, lastName, email, phone, country } = ctx.propsValue;-- const escapeXml = (s: string) =>- s- .replace(/&/g, '&')- .replace(/</g, '<')- .replace(/>/g, '>')- .replace(/"/g, '"');-- let phoneXml = '';- if (phone) {- phoneXml = `- <bsvc:Phone_Data>- <bsvc:Phone_Number>${escapeXml(phone)}</bsvc:Phone_Number>- <bsvc:Phone_Device_Type_Reference>- <bsvc:ID bsvc:type="Phone_Device_Type_ID">Mobile</bsvc:ID>- </bsvc:Phone_Device_Type_Reference>- <bsvc:Usage_Data bsvc:Public="true">- <bsvc:Type_Data bsvc:Primary="true">- <bsvc:Type_Reference>- <bsvc:ID bsvc:type="Communication_Usage_Type_ID">WORK</bsvc:ID>- </bsvc:Type_Reference>- </bsvc:Type_Data>- </bsvc:Usage_Data>- </bsvc:Phone_Data>`;- }-- const operationXml = `- <bsvc:Put_Applicant_Request bsvc:version="v46.0" xmlns:bsvc="urn:com.workday/bsvc">- <bsvc:Applicant_Data>- <bsvc:Personal_Data>- <bsvc:Name_Data>- <bsvc:Legal_Name_Data>- <bsvc:Name_Detail_Data>- <bsvc:Country_Reference>- <bsvc:ID bsvc:type="ISO_3166-1_Alpha-3_Code">${escapeXml(country)}</bsvc:ID>- </bsvc:Country_Reference>- <bsvc:First_Name>${escapeXml(firstName)}</bsvc:First_Name>- <bsvc:Last_Name>${escapeXml(lastName)}</bsvc:Last_Name>- </bsvc:Name_Detail_Data>- </bsvc:Legal_Name_Data>- </bsvc:Name_Data>- <bsvc:Contact_Data>- <bsvc:Email_Address_Data>- <bsvc:Email_Address>${escapeXml(email)}</bsvc:Email_Address>- <bsvc:Usage_Data bsvc:Public="true">- <bsvc:Type_Data bsvc:Primary="true">- <bsvc:Type_Reference>- <bsvc:ID bsvc:type="Communication_Usage_Type_ID">WORK</bsvc:ID>- </bsvc:Type_Reference>- </bsvc:Type_Data>- </bsvc:Usage_Data>- </bsvc:Email_Address_Data>${phoneXml}- </bsvc:Contact_Data>- </bsvc:Personal_Data>- </bsvc:Applicant_Data>- </bsvc:Put_Applicant_Request>`;-- return workdaySoapRequest(- ctx.auth as OAuth2PropertyValue,- 'Staffing',- operationXml,- );- },-});diff --git a/packages/pieces/community/workday/src/lib/action/create-supplier-credit-memo.ts b/packages/pieces/community/workday/src/lib/action/create-supplier-credit-memo.tsdeleted file mode 100644index 177feccaba5..00000000000--- a/packages/pieces/community/workday/src/lib/action/create-supplier-credit-memo.ts+++ /dev/null@@ -1,85 +0,0 @@-import {- OAuth2PropertyValue,- Property,- createAction,-} from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdaySoapRequest } from '../common';--export const createSupplierCreditMemo = createAction({- auth: workdayAuth,- name: 'create_supplier_credit_memo',- classification: 'WRITE',- displayName: 'Create Supplier Credit Memo',- description: 'Creates a new supplier credit memo in Workday.',- audience: 'both',- aiMetadata: {- description:- 'Submits a supplier invoice adjustment (credit memo) against a supplier (by WID) with an adjustment date and control-total amount, plus an optional memo. Use to record a credit owed by a supplier. Not idempotent: each call submits a separate credit memo.',- idempotent: false,- },- props: {- supplierId: Property.ShortText({- displayName: 'Supplier ID',- description: 'The ID of the supplier.',- required: true,- }),- memoDate: Property.ShortText({- displayName: 'Memo Date',- description: 'Credit memo date (YYYY-MM-DD).',- required: true,- }),- amount: Property.ShortText({- displayName: 'Amount',- description: 'Credit memo amount.',- required: true,- }),- description: Property.LongText({- displayName: 'Description',- description: 'Description of the credit memo.',- required: false,- }),- additionalData: Property.Object({- displayName: 'Additional Data',- description: 'Additional fields as key-value pairs.',- required: false,- }),- },- async run(ctx) {- const { supplierId, memoDate, amount, description } = ctx.propsValue;-- const escapeXml = (s: string) =>- s- .replace(/&/g, '&')- .replace(/</g, '<')- .replace(/>/g, '>')- .replace(/"/g, '"');-- let memoXml = '';- if (description) {- memoXml = `- <bsvc:Document_Memo>${escapeXml(description)}</bsvc:Document_Memo>`;- }-- const operationXml = `- <bsvc:Submit_Supplier_Invoice_Adjustment_Request bsvc:version="v46.0" xmlns:bsvc="urn:com.workday/bsvc">- <bsvc:Business_Process_Parameters>- <bsvc:Auto_Complete>true</bsvc:Auto_Complete>- </bsvc:Business_Process_Parameters>- <bsvc:Supplier_Invoice_Adjustment_Data>- <bsvc:Submit>true</bsvc:Submit>- <bsvc:Supplier_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(supplierId)}</bsvc:ID>- </bsvc:Supplier_Reference>- <bsvc:Adjustment_Date>${escapeXml(memoDate)}</bsvc:Adjustment_Date>- <bsvc:Control_Total_Amount>${escapeXml(amount)}</bsvc:Control_Total_Amount>${memoXml}- </bsvc:Supplier_Invoice_Adjustment_Data>- </bsvc:Submit_Supplier_Invoice_Adjustment_Request>`;-- return workdaySoapRequest(- ctx.auth as OAuth2PropertyValue,- 'Resource_Management',- operationXml,- );- },-});diff --git a/packages/pieces/community/workday/src/lib/action/create-time-off-request.ts b/packages/pieces/community/workday/src/lib/action/create-time-off-request.tsdeleted file mode 100644index e2727ac1ad2..00000000000--- a/packages/pieces/community/workday/src/lib/action/create-time-off-request.ts+++ /dev/null@@ -1,96 +0,0 @@-import {- OAuth2PropertyValue,- Property,- createAction,-} from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdaySoapRequest } from '../common';--export const createTimeOffRequest = createAction({- auth: workdayAuth,- name: 'create_time_off_request',- classification: 'WRITE',- displayName: 'Create Time Off Request',- description: 'Creates a new time off request in Workday.',- audience: 'both',- aiMetadata: {- description:- 'Submits and auto-completes a time-off request for a worker (by WID) of a given time-off type, entering 8 requested hours for each day in the inclusive start-to-end date range, with an optional comment. Use to book vacation, sick, or other leave on a worker’s behalf. Not idempotent: each call enters a new time-off request.',- idempotent: false,- },- props: {- workerId: Property.ShortText({- displayName: 'Worker ID',- description: 'The ID of the worker requesting time off.',- required: true,- }),- timeOffTypeId: Property.ShortText({- displayName: 'Time Off Type ID',- description: 'The time off type reference ID (e.g., vacation, sick).',- required: true,- }),- startDate: Property.ShortText({- displayName: 'Start Date',- description: 'Start date of the time off (YYYY-MM-DD).',- required: true,- }),- endDate: Property.ShortText({- displayName: 'End Date',- description: 'End date of the time off (YYYY-MM-DD).',- required: true,- }),- comment: Property.LongText({- displayName: 'Comment',- description: 'Optional comment for the request.',- required: false,- }),- },- async run(ctx) {- const { workerId, timeOffTypeId, startDate, endDate, comment } =- ctx.propsValue;-- const escapeXml = (s: string) =>- s- .replace(/&/g, '&')- .replace(/</g, '<')- .replace(/>/g, '>')- .replace(/"/g, '"');-- // Build entry for each day between start and end- const start = new Date(startDate);- const end = new Date(endDate);- let entriesXml = '';- const current = new Date(start);- while (current <= end) {- const dateStr = current.toISOString().split('T')[0];- entriesXml += `- <bsvc:Enter_Time_Off_Entry_Data>- <bsvc:Date>${dateStr}</bsvc:Date>- <bsvc:Requested>8</bsvc:Requested>- <bsvc:Time_Off_Type_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(timeOffTypeId)}</bsvc:ID>- </bsvc:Time_Off_Type_Reference>${comment ? `\n <bsvc:Comment>${escapeXml(comment)}</bsvc:Comment>` : ''}- </bsvc:Enter_Time_Off_Entry_Data>`;- current.setDate(current.getDate() + 1);- }-- const operationXml = `- <bsvc:Enter_Time_Off_Request bsvc:version="v46.0" xmlns:bsvc="urn:com.workday/bsvc">- <bsvc:Business_Process_Parameters>- <bsvc:Auto_Complete>true</bsvc:Auto_Complete>- <bsvc:Run_Now>true</bsvc:Run_Now>- </bsvc:Business_Process_Parameters>- <bsvc:Enter_Time_Off_Data>- <bsvc:Worker_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(workerId)}</bsvc:ID>- </bsvc:Worker_Reference>${entriesXml}- </bsvc:Enter_Time_Off_Data>- </bsvc:Enter_Time_Off_Request>`;-- return workdaySoapRequest(- ctx.auth as OAuth2PropertyValue,- 'Absence_Management',- operationXml,- );- },-});diff --git a/packages/pieces/community/workday/src/lib/action/create-update-custom-object.ts b/packages/pieces/community/workday/src/lib/action/create-update-custom-object.tsdeleted file mode 100644index a323e459084..00000000000--- a/packages/pieces/community/workday/src/lib/action/create-update-custom-object.ts+++ /dev/null@@ -1,44 +0,0 @@-import { Property, createAction } from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdayUpsertCustomObject } from '../common';-import { flattenRecord } from '../common/fields';-import { customObjectDefinitionProperty, requestBodyProperty } from '../common/props';--export const createUpdateCustomObject = createAction({- auth: workdayAuth,- name: 'create_update_custom_object',- classification: 'WRITE',- displayName: 'Create/Update Custom Object',- description: 'Creates or updates a Workday custom object instance (PUT upsert).',- audience: 'both',- aiMetadata: {- description:- 'Writes an instance of a tenant-defined Workday custom object, chosen by its custom object definition ID, with the field values supplied as a JSON body. Leaving the Custom Object ID blank creates a new instance, while supplying an existing ID updates that instance in place. Call List Custom Object Definitions (Batch) first when the definition ID is unknown. Not idempotent: with no object ID every call creates another instance.',- idempotent: false,- },- props: {- definitionId: customObjectDefinitionProperty,- objectId: Property.ShortText({- displayName: 'Custom Object ID',- description:- 'Optional ID for update. Leave blank to create a new custom object.',- required: false,- }),- body: requestBodyProperty,- },- async run({ auth, propsValue }) {- const body: Record<string, unknown> =- typeof propsValue.body === 'string'- ? JSON.parse(propsValue.body)- : { ...(propsValue.body as Record<string, unknown>) };- if (propsValue.objectId) {- body['id'] = propsValue.objectId;- }- const result = await workdayUpsertCustomObject(- auth,- propsValue.definitionId,- body,- );- return flattenRecord(result);- },-});diff --git a/packages/pieces/community/workday/src/lib/action/create-worker-time-block.ts b/packages/pieces/community/workday/src/lib/action/create-worker-time-block.tsdeleted file mode 100644index 1f8592d2777..00000000000--- a/packages/pieces/community/workday/src/lib/action/create-worker-time-block.ts+++ /dev/null@@ -1,89 +0,0 @@-import {- OAuth2PropertyValue,- Property,- createAction,-} from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdaySoapRequest } from '../common';--export const createWorkerTimeBlock = createAction({- auth: workdayAuth,- name: 'create_worker_time_block',- classification: 'WRITE',- displayName: 'Create Worker Time Block',- description: 'Creates a new worker time block in Workday.',- audience: 'both',- aiMetadata: {- description:- 'Imports a reported time block for a worker (by WID) on a given date with a quantity of hours, optionally tagged with a time-entry-code WID and a comment. Use to log hours worked into Workday Time Tracking. Not idempotent: each call appends another reported time block.',- idempotent: false,- },- props: {- workerId: Property.ShortText({- displayName: 'Worker ID',- description: 'The ID of the worker.',- required: true,- }),- date: Property.ShortText({- displayName: 'Date',- description: 'Date of the time block (YYYY-MM-DD).',- required: true,- }),- hours: Property.Number({- displayName: 'Hours',- description: 'Number of hours worked.',- required: true,- }),- timeTypeId: Property.ShortText({- displayName: 'Time Type ID',- description: 'Time type reference ID.',- required: false,- }),- comment: Property.LongText({- displayName: 'Comment',- description: 'Optional comment.',- required: false,- }),- },- async run(ctx) {- const { workerId, date, hours, timeTypeId, comment } = ctx.propsValue;-- const escapeXml = (s: string) =>- s- .replace(/&/g, '&')- .replace(/</g, '<')- .replace(/>/g, '>')- .replace(/"/g, '"');-- let timeEntryCodeXml = '';- if (timeTypeId) {- timeEntryCodeXml = `- <bsvc:Time_Entry_Code_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(timeTypeId)}</bsvc:ID>- </bsvc:Time_Entry_Code_Reference>`;- }-- let commentXml = '';- if (comment) {- commentXml = `- <bsvc:Comment>${escapeXml(comment)}</bsvc:Comment>`;- }-- const operationXml = `- <bsvc:Import_Reported_Time_Blocks_Request bsvc:version="v46.0" xmlns:bsvc="urn:com.workday/bsvc">- <bsvc:Reported_Time_Block_Data>- <bsvc:Worker_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(workerId)}</bsvc:ID>- </bsvc:Worker_Reference>- <bsvc:Date>${escapeXml(date)}</bsvc:Date>- <bsvc:Quantity>${hours}</bsvc:Quantity>${timeEntryCodeXml}${commentXml}- </bsvc:Reported_Time_Block_Data>- </bsvc:Import_Reported_Time_Blocks_Request>`;-- return workdaySoapRequest(- ctx.auth as OAuth2PropertyValue,- 'Time_Tracking',- operationXml,- );- },-});diff --git a/packages/pieces/community/workday/src/lib/action/find-supplier-invoice.ts b/packages/pieces/community/workday/src/lib/action/find-supplier-invoice.tsdeleted file mode 100644index 462e083baba..00000000000--- a/packages/pieces/community/workday/src/lib/action/find-supplier-invoice.ts+++ /dev/null@@ -1,36 +0,0 @@-import {- OAuth2PropertyValue,- Property,- createAction,-} from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { escapeWql, workdayWqlRequest } from '../common';--export const findSupplierInvoice = createAction({- auth: workdayAuth,- name: 'find_supplier_invoice',- classification: 'READ',- displayName: 'Find Supplier Invoice',- description: 'Finds a supplier invoice by ID in Workday using WQL.',- audience: 'both',- aiMetadata: {- description:- 'Looks up a single supplier invoice by its ID via a Workday Query Language (WQL) query against the supplierInvoices dataset. Use to resolve or verify a supplier invoice when you already have its ID. Read-only and idempotent.',- idempotent: true,- },- props: {- invoiceId: Property.ShortText({- displayName: 'Invoice ID',- description: 'The ID of the supplier invoice to find.',- required: true,- }),- },- async run(ctx) {- const { invoiceId } = ctx.propsValue;- const response = await workdayWqlRequest(- ctx.auth as OAuth2PropertyValue,- `SELECT supplierInvoice FROM supplierInvoices WHERE supplierInvoice = '${escapeWql(invoiceId)}'`,- );- return response.body;- },-});diff --git a/packages/pieces/community/workday/src/lib/action/get-business-object-details-batch.ts b/packages/pieces/community/workday/src/lib/action/get-business-object-details-batch.tsdeleted file mode 100644index c6219fe0474..00000000000--- a/packages/pieces/community/workday/src/lib/action/get-business-object-details-batch.ts+++ /dev/null@@ -1,62 +0,0 @@-import { HttpMethod } from '@activepieces/pieces-common';-import { createAction } from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdayRequest } from '../common';-import { formatWorkdayOutput } from '../common/fields';-import { resolveBusinessObject, toWorkdayModule } from '../common/modules';-import { objectIdsProperty, sharedModuleProps } from '../common/props';--export const getBusinessObjectDetailsBatch = createAction({- auth: workdayAuth,- name: 'get_business_object_details_batch',- classification: 'READ',- displayName: 'Get Business Object Details (Batch)',- description:- 'Retrieves details for one or more business objects by ID in a single step.',- audience: 'both',- aiMetadata: {- description:- 'Fetches the full record for one or more Workday business objects by ID in a single step, after selecting the module (Recruiting, Onboarding, or HR Services & Time Tracking) and an object type such as Job Requisition, Candidate, or Worker, or supplying a custom REST path instead. Use when the record IDs are already known; use Search Business Object (Batch) to find records by criteria. Read-only and idempotent.',- idempotent: true,- },- props: {- ...sharedModuleProps,- objectIds: objectIdsProperty,- },- async run({ auth, propsValue }) {- const bo = propsValue.businessObject as {- objectType?: string;- customPath?: string;- customService?: string;- };- const businessObjectConfig = resolveBusinessObject(- propsValue.module,- bo.objectType,- bo.customPath,- bo.customService,- );- const module = toWorkdayModule(propsValue.module);- const ids = (propsValue.objectIds as Array<{ id: string }>).map(- (item) => item.id,- );-- const records = await Promise.all(- ids.map(async (id) => {- const response = await workdayRequest<Record<string, unknown>>(- auth,- HttpMethod.GET,- `${businessObjectConfig.path}/${id}`,- undefined,- undefined,- businessObjectConfig.service,- );- return formatWorkdayOutput(response.body, module);- }),- );-- return {- total_count: records.length,- records,- };- },-});diff --git a/packages/pieces/community/workday/src/lib/action/get-custom-objects.ts b/packages/pieces/community/workday/src/lib/action/get-custom-objects.tsdeleted file mode 100644index 291636d479d..00000000000--- a/packages/pieces/community/workday/src/lib/action/get-custom-objects.ts+++ /dev/null@@ -1,35 +0,0 @@-import { Property, createAction } from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdayGetCustomObject } from '../common';-import { flattenRecord } from '../common/fields';-import { customObjectDefinitionProperty } from '../common/props';--export const getCustomObjects = createAction({- auth: workdayAuth,- name: 'get_custom_objects',- classification: 'READ',- displayName: 'Get Custom Objects',- description: 'Retrieves a custom object instance by definition ID and object ID.',- audience: 'both',- aiMetadata: {- description:- 'Retrieves a single instance of a tenant-defined Workday custom object, addressed by its custom object definition ID plus the instance ID. Use when both IDs are known; call List Custom Object Definitions (Batch) first to discover the definition ID, and use Get Business Object Details (Batch) for standard objects such as workers or job requisitions. Read-only and idempotent.',- idempotent: true,- },- props: {- definitionId: customObjectDefinitionProperty,- objectId: Property.ShortText({- displayName: 'Custom Object ID',- description: 'ID of the custom object instance.',- required: true,- }),- },- async run({ auth, propsValue }) {- const result = await workdayGetCustomObject(- auth,- propsValue.definitionId,- propsValue.objectId,- );- return flattenRecord(result);- },-});diff --git a/packages/pieces/community/workday/src/lib/action/get-report.ts b/packages/pieces/community/workday/src/lib/action/get-report.tsdeleted file mode 100644index ef3db5b772a..00000000000--- a/packages/pieces/community/workday/src/lib/action/get-report.ts+++ /dev/null@@ -1,46 +0,0 @@-import { QueryParams } from '@activepieces/pieces-common';-import { Property, createAction } from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdayGetReport } from '../common';-import { flattenRecord } from '../common/fields';-import { reportIdProperty } from '../common/props';--export const getReport = createAction({- auth: workdayAuth,- name: 'get_report',- classification: 'READ',- displayName: 'Get Report',- description: 'Fetches a Workday report by ID or web service alias.',- audience: 'both',- aiMetadata: {- description:- 'Runs a published Workday custom report, addressed by its report ID or web service alias, and returns its rows, optionally passing report prompt values as JSON. Use when the data is already shaped by a report definition in the tenant; prefer Find Records (WQL) or Get Report using WQL (Batch) when the query can be expressed in WQL instead. Read-only and idempotent.',- idempotent: true,- },- props: {- reportId: reportIdProperty,- reportParameters: Property.Json({- displayName: 'Report Parameters (JSON)',- description: 'Optional report prompt values as JSON key-value pairs.',- required: false,- }),- },- async run({ auth, propsValue }) {- const report = await workdayGetReport(- auth,- propsValue.reportId,- propsValue.reportParameters as QueryParams | undefined,- );- const rows = Array.isArray(report['data'])- ? (report['data'] as Record<string, unknown>[])- : Array.isArray(report['Report_Entry'])- ? (report['Report_Entry'] as Record<string, unknown>[])- : [report];-- return {- total_count: rows.length,- report_id: propsValue.reportId,- records: rows.map((row) => flattenRecord(row)),- };- },-});diff --git a/packages/pieces/community/workday/src/lib/action/search-business-object-batch.ts b/packages/pieces/community/workday/src/lib/action/search-business-object-batch.tsdeleted file mode 100644index 26b20d1635c..00000000000--- a/packages/pieces/community/workday/src/lib/action/search-business-object-batch.ts+++ /dev/null@@ -1,55 +0,0 @@-import { createAction } from '@activepieces/pieces-framework';-import { QueryParams } from '@activepieces/pieces-common';-import { workdayAuth } from '../auth';-import { fetchAllPages } from '../common';-import { formatWorkdayOutputs } from '../common/fields';-import { resolveBusinessObject, toWorkdayModule } from '../common/modules';-import { optionalQueryParamsProperty, sharedModuleProps } from '../common/props';--export const searchBusinessObjectBatch = createAction({- auth: workdayAuth,- name: 'search_business_object_batch',- classification: 'SEARCH',- displayName: 'Search Business Object (Batch)',- description:- 'Searches business objects with pagination and returns all matching records.',- audience: 'both',- aiMetadata: {- description:- 'Pages through a Workday business object collection and returns every matching record, after selecting the module (Recruiting, Onboarding, or HR Services & Time Tracking) and an object type such as Job Requisition, Candidate, or Worker, or supplying a custom REST path instead. Optional JSON query parameters narrow the results; omitting them returns all records of that type. Use to find records by criteria, and Get Business Object Details (Batch) when the IDs are already known. Read-only and idempotent.',- idempotent: true,- },- props: {- ...sharedModuleProps,- queryParams: optionalQueryParamsProperty,- },- async run({ auth, propsValue }) {- const bo = propsValue.businessObject as {- objectType?: string;- customPath?: string;- customService?: string;- };- const businessObjectConfig = resolveBusinessObject(- propsValue.module,- bo.objectType,- bo.customPath,- bo.customService,- );- const module = toWorkdayModule(propsValue.module);- const queryParams = (propsValue.queryParams as QueryParams) ?? {};-- const records = await fetchAllPages<Record<string, unknown>>(- auth,- businessObjectConfig.path,- queryParams,- 'data',- businessObjectConfig.service,- );- const formatted = formatWorkdayOutputs(records, module);-- return {- total_count: formatted.length,- records: formatted,- };- },-});diff --git a/packages/pieces/community/workday/src/lib/action/update-business-object.ts b/packages/pieces/community/workday/src/lib/action/update-business-object.tsdeleted file mode 100644index 3c70d1ab766..00000000000--- a/packages/pieces/community/workday/src/lib/action/update-business-object.ts+++ /dev/null@@ -1,58 +0,0 @@-import { HttpMethod } from '@activepieces/pieces-common';-import { Property, createAction } from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdayRequest } from '../common';-import { formatWorkdayOutput } from '../common/fields';-import { resolveBusinessObject, toWorkdayModule } from '../common/modules';-import { requestBodyProperty, sharedModuleProps } from '../common/props';--export const updateBusinessObject = createAction({- auth: workdayAuth,- name: 'update_business_object',- classification: 'WRITE',- displayName: 'Update Business Object',- description: 'Updates an existing business object by ID using the REST API.',- audience: 'both',- aiMetadata: {- description:- 'Updates one existing Workday business object by its ID, sending the new field values as a JSON body, after selecting the module (Recruiting, Onboarding, or HR Services & Time Tracking) and an object type such as Job Requisition, Candidate, or Worker, or supplying a custom REST path instead. Use for generic edits to recruiting, onboarding, or HR and time-tracking records, and prefer the dedicated action (e.g. Update Supplier, Change Job) when one exists. Requires the record ID and a JSON body. Idempotent: keyed on the object ID, so re-sending the same body converges to the same state.',- idempotent: true,- },- props: {- ...sharedModuleProps,- objectId: Property.ShortText({- displayName: 'Object ID',- description: 'Workday ID of the record to update.',- required: true,- }),- body: requestBodyProperty,- },- async run({ auth, propsValue }) {- const bo = propsValue.businessObject as {- objectType?: string;- customPath?: string;- customService?: string;- };- const businessObjectConfig = resolveBusinessObject(- propsValue.module,- bo.objectType,- bo.customPath,- bo.customService,- );- const module = toWorkdayModule(propsValue.module);- const body =- typeof propsValue.body === 'string'- ? JSON.parse(propsValue.body)- : propsValue.body;-- const response = await workdayRequest<Record<string, unknown>>(- auth,- HttpMethod.PUT,- `${businessObjectConfig.path}/${propsValue.objectId}`,- body,- undefined,- businessObjectConfig.service,- );- return formatWorkdayOutput(response.body, module);- },-});diff --git a/packages/pieces/community/workday/src/lib/action/update-supplier-invoice.ts b/packages/pieces/community/workday/src/lib/action/update-supplier-invoice.tsdeleted file mode 100644index 4d4a2706780..00000000000--- a/packages/pieces/community/workday/src/lib/action/update-supplier-invoice.ts+++ /dev/null@@ -1,87 +0,0 @@-import {- OAuth2PropertyValue,- Property,- createAction,-} from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdaySoapRequest } from '../common';--export const updateSupplierInvoice = createAction({- auth: workdayAuth,- name: 'update_supplier_invoice',- classification: 'WRITE',- displayName: 'Update Supplier Invoice',- description: 'Updates an existing supplier invoice in Workday.',- audience: 'both',- aiMetadata: {- description:- 'Updates an existing supplier invoice (identified by its invoice WID) in Workday, setting any of invoice date, invoice number, and total amount. Use to amend an existing supplier invoice. Idempotent: keyed on the invoice ID, so re-sending the same field values converges to the same state.',- idempotent: true,- },- props: {- invoiceId: Property.ShortText({- displayName: 'Invoice ID',- description: 'The ID of the supplier invoice to update.',- required: true,- }),- invoiceDate: Property.ShortText({- displayName: 'Invoice Date',- description: 'Invoice date (YYYY-MM-DD).',- required: false,- }),- invoiceNumber: Property.ShortText({- displayName: 'Invoice Number',- description: 'Invoice number.',- required: false,- }),- total: Property.ShortText({- displayName: 'Total Amount',- description: 'Invoice total amount.',- required: false,- }),- additionalData: Property.Object({- displayName: 'Additional Data',- description: 'Additional fields as key-value pairs.',- required: false,- }),- },- async run(ctx) {- const { invoiceId, invoiceDate, invoiceNumber, total } = ctx.propsValue;-- const escapeXml = (s: string) =>- s- .replace(/&/g, '&')- .replace(/</g, '<')- .replace(/>/g, '>')- .replace(/"/g, '"');-- let invoiceDataFields = '';- if (invoiceDate) {- invoiceDataFields += `- <bsvc:Invoice_Date>${escapeXml(invoiceDate)}</bsvc:Invoice_Date>`;- }- if (invoiceNumber) {- invoiceDataFields += `- <bsvc:Invoice_Number>${escapeXml(invoiceNumber)}</bsvc:Invoice_Number>`;- }- if (total) {- invoiceDataFields += `- <bsvc:Total_Amount>${escapeXml(total)}</bsvc:Total_Amount>`;- }-- const operationXml = `- <bsvc:Submit_Supplier_Invoice_Request bsvc:version="v46.0" xmlns:bsvc="urn:com.workday/bsvc">- <bsvc:Supplier_Invoice_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(invoiceId)}</bsvc:ID>- </bsvc:Supplier_Invoice_Reference>- <bsvc:Supplier_Invoice_Data>${invoiceDataFields}- </bsvc:Supplier_Invoice_Data>- </bsvc:Submit_Supplier_Invoice_Request>`;-- return workdaySoapRequest(- ctx.auth as OAuth2PropertyValue,- 'Resource_Management',- operationXml,- );- },-});diff --git a/packages/pieces/community/workday/src/lib/action/update-supplier.ts b/packages/pieces/community/workday/src/lib/action/update-supplier.tsdeleted file mode 100644index caf011818fa..00000000000--- a/packages/pieces/community/workday/src/lib/action/update-supplier.ts+++ /dev/null@@ -1,89 +0,0 @@-import {- OAuth2PropertyValue,- Property,- createAction,-} from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdaySoapRequest } from '../common';--export const updateSupplier = createAction({- auth: workdayAuth,- name: 'update_supplier',- classification: 'WRITE',- displayName: 'Update Supplier',- description: 'Updates an existing supplier in Workday.',- audience: 'both',- aiMetadata: {- description:- 'Updates an existing supplier (identified by its supplier WID) in Workday, setting any of name, tax ID, and payment-terms WID. Use to amend supplier master data. Idempotent: keyed on the supplier ID, so re-sending the same field values converges to the same state.',- idempotent: true,- },- props: {- supplierId: Property.ShortText({- displayName: 'Supplier ID',- description: 'The ID of the supplier to update.',- required: true,- }),- supplierName: Property.ShortText({- displayName: 'Supplier Name',- description: 'Updated supplier name.',- required: false,- }),- taxId: Property.ShortText({- displayName: 'Tax ID',- description: 'Supplier tax identification number.',- required: false,- }),- paymentTermsId: Property.ShortText({- displayName: 'Payment Terms ID',- description: 'Payment terms reference ID.',- required: false,- }),- additionalData: Property.Object({- displayName: 'Additional Data',- description: 'Additional fields as key-value pairs.',- required: false,- }),- },- async run(ctx) {- const { supplierId, supplierName, taxId, paymentTermsId } = ctx.propsValue;-- const escapeXml = (s: string) =>- s- .replace(/&/g, '&')- .replace(/</g, '<')- .replace(/>/g, '>')- .replace(/"/g, '"');-- let supplierDataFields = '';- if (supplierName) {- supplierDataFields += `- <bsvc:Supplier_Name>${escapeXml(supplierName)}</bsvc:Supplier_Name>`;- }- if (taxId) {- supplierDataFields += `- <bsvc:Tax_ID>${escapeXml(taxId)}</bsvc:Tax_ID>`;- }- if (paymentTermsId) {- supplierDataFields += `- <bsvc:Payment_Terms_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(paymentTermsId)}</bsvc:ID>- </bsvc:Payment_Terms_Reference>`;- }-- const operationXml = `- <bsvc:Submit_Supplier_Request bsvc:version="v46.0" xmlns:bsvc="urn:com.workday/bsvc">- <bsvc:Supplier_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(supplierId)}</bsvc:ID>- </bsvc:Supplier_Reference>- <bsvc:Supplier_Data>${supplierDataFields}- </bsvc:Supplier_Data>- </bsvc:Submit_Supplier_Request>`;-- return workdaySoapRequest(- ctx.auth as OAuth2PropertyValue,- 'Resource_Management',- operationXml,- );- },-});diff --git a/packages/pieces/community/workday/src/lib/actions/approve-task.ts b/packages/pieces/community/workday/src/lib/actions/approve-task.tsnew file mode 100644index 00000000000..edaa8be69a6--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/approve-task.ts@@ -0,0 +1,37 @@+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';++export const approveTaskAction = createAction({+ auth: workdayAuth,+ name: 'approve_task',+ classification: 'WRITE',+ displayName: 'Approve Task',+ description: 'Approves an inbox task in Workday.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Approves a pending Workday business-process inbox task, identified by its task WID, optionally attaching an approval comment. Use to advance an awaiting-approval step (e.g. a time-off or hiring request) once a decision is made. Not idempotent: it submits an approval event each call and the task can only be approved once.',+ idempotent: false,+ },+ props: {+ taskId: Property.ShortText({+ displayName: 'Task ID',+ description: 'The ID of the inbox task to approve.',+ required: true,+ }),+ comment: Property.LongText({+ displayName: 'Comment',+ description: 'Optional comment for the approval.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ return await workdayApi.approveTask({+ auth,+ taskId: propsValue.taskId,+ comment: propsValue.comment,+ });+ },+});diff --git a/packages/pieces/community/workday/src/lib/actions/call-operation.ts b/packages/pieces/community/workday/src/lib/actions/call-operation.tsnew file mode 100644index 00000000000..aaadf352fd2--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/call-operation.ts@@ -0,0 +1,108 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';+import { workdayProps } from '../common/props';+import { workdayUtils } from '../common/utils';++export const callOperationAction = createAction({+ auth: workdayAuth,+ name: 'call_operation',+ classification: 'WRITE',+ displayName: 'Call Operation',+ description: 'Calls a Workday REST sub-resource or SOAP operation (e.g. approve, close, submit).',+ audience: 'both',+ aiMetadata: {+ description:+ 'Invokes a Workday operation that has no dedicated action, in one of two modes: a REST sub-resource call (POST, PUT, or PATCH against a business-object path such as /cases/{id}/reopen) or a raw SOAP operation against a named web service such as Staffing. Use as the escape hatch for verbs like approve, close, or submit, and prefer the specific action (e.g. Approve Task, Update Business Object) whenever one exists. Requires the operation name, plus the SOAP service name when running in SOAP mode. Not idempotent: each call submits the operation as a fresh event.',+ idempotent: false,+ },+ props: {+ module: workdayProps.module({ required: true }),+ businessObject: workdayProps.businessObject({ required: true }),+ operationType: Property.StaticDropdown({+ displayName: 'Operation Type',+ required: true,+ defaultValue: 'rest',+ options: {+ disabled: false,+ options: [+ { label: 'REST sub-resource', value: 'rest' },+ { label: 'SOAP operation', value: 'soap' },+ ],+ },+ }),+ operationName: Property.ShortText({+ displayName: 'Operation Name',+ description:+ 'REST sub-resource or SOAP operation path, e.g. `/cases/{id}/reopen` or `Close_Job_Requisition`.',+ required: true,+ }),+ soapService: Property.ShortText({+ displayName: 'SOAP Service Name',+ description: 'Required for SOAP operations, e.g. `Staffing` or `Human_Resources`.',+ required: false,+ }),+ httpMethod: Property.StaticDropdown<HttpMethod, false>({+ displayName: 'HTTP Method',+ required: false,+ defaultValue: HttpMethod.POST,+ options: {+ disabled: false,+ options: [+ { label: 'POST', value: HttpMethod.POST },+ { label: 'PUT', value: HttpMethod.PUT },+ { label: 'PATCH', value: HttpMethod.PATCH },+ ],+ },+ }),+ body: Property.Json({+ displayName: 'Request Body (JSON)',+ description: 'JSON payload for REST operations.',+ required: false,+ }),+ soapBody: Property.LongText({+ displayName: 'SOAP Body (XML)',+ description:+ 'Raw SOAP operation XML, used only for SOAP operations. Leave empty to send an empty operation element.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ if (propsValue.operationType === 'soap') {+ if (!propsValue.soapService) {+ throw new Error('SOAP Service Name is required for SOAP operations.');+ }+ const xml =+ propsValue.soapBody && propsValue.soapBody.trim().length > 0+ ? propsValue.soapBody+ : `<bsvc:${propsValue.operationName} xmlns:bsvc="urn:com.workday/bsvc"/>`;+ const result = await workdayApi.callSoapOperation({+ auth,+ service: propsValue.soapService,+ operationXml: xml,+ });+ return workdayUtils.flattenRecord({ value: result });+ }++ const config = workdayUtils.resolveBusinessObject({+ module: propsValue.module,+ selection: propsValue.businessObject,+ });+ const path = propsValue.operationName.startsWith('/')+ ? propsValue.operationName+ : `${config.path}/${propsValue.operationName}`;+ const body =+ propsValue.body && typeof propsValue.body === 'object' ? propsValue.body : undefined;++ const result = await workdayApi.callRestOperation({+ auth,+ method: propsValue.httpMethod ?? HttpMethod.POST,+ path,+ body,+ service: config.service,+ });+ return workdayUtils.flattenRecord({ value: result });+ },+});diff --git a/packages/pieces/community/workday/src/lib/actions/change-job.ts b/packages/pieces/community/workday/src/lib/actions/change-job.tsnew file mode 100644index 00000000000..13e1eb7516b--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/change-job.ts@@ -0,0 +1,61 @@+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';++export const changeJobAction = createAction({+ auth: workdayAuth,+ name: 'change_job',+ classification: 'WRITE',+ displayName: 'Change Job',+ description: 'Changes the job for a worker in Workday.',+ audience: 'both',+ aiMetadata: {+ description:+ "Initiates and auto-completes a Change Job business process for an existing worker (by worker WID), effective on a given date with a reason WID, optionally moving them to a new job profile, supervisory organization, and/or position. Use to record a worker's transfer, promotion, or reorganization. Not idempotent: each call submits a new job-change event.",+ idempotent: false,+ },+ props: {+ workerId: Property.ShortText({+ displayName: 'Worker ID',+ description: 'The ID of the worker whose job to change.',+ required: true,+ }),+ effectiveDate: Property.ShortText({+ displayName: 'Effective Date',+ description: 'Effective date of the job change (YYYY-MM-DD).',+ required: true,+ }),+ reasonId: Property.ShortText({+ displayName: 'Reason ID',+ description: 'The reason for the job change.',+ required: true,+ }),+ jobProfileId: Property.ShortText({+ displayName: 'Job Profile ID',+ description: 'New job profile reference ID.',+ required: false,+ }),+ supervisoryOrganizationId: Property.ShortText({+ displayName: 'Supervisory Organization ID',+ description: 'New supervisory organization reference ID.',+ required: false,+ }),+ positionId: Property.ShortText({+ displayName: 'Position ID',+ description: 'New position reference ID.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ return await workdayApi.changeJob({+ auth,+ workerId: propsValue.workerId,+ effectiveDate: propsValue.effectiveDate,+ reasonId: propsValue.reasonId,+ jobProfileId: propsValue.jobProfileId,+ supervisoryOrganizationId: propsValue.supervisoryOrganizationId,+ positionId: propsValue.positionId,+ });+ },+});diff --git a/packages/pieces/community/workday/src/lib/actions/create-job-requisition.ts b/packages/pieces/community/workday/src/lib/actions/create-job-requisition.tsnew file mode 100644index 00000000000..3d414a15a83--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/create-job-requisition.ts@@ -0,0 +1,89 @@+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';++export const createJobRequisitionAction = createAction({+ auth: workdayAuth,+ name: 'create_job_requisition',+ classification: 'WRITE',+ displayName: 'Create Job Requisition',+ description: 'Creates a new job requisition in Workday.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Creates and auto-completes a job requisition under a supervisory organization (by WID) with a creation-reason WID, posting title, and number of openings, optionally setting job profile, location, recruiting-start, and target-hire dates. Use to open a new req before recruiting/hiring. Not idempotent: each call creates a separate requisition.',+ idempotent: false,+ },+ props: {+ supervisoryOrganizationId: Property.ShortText({+ displayName: 'Supervisory Organization ID',+ description: 'The supervisory organization for the requisition.',+ required: true,+ }),+ reasonId: Property.ShortText({+ displayName: 'Reason ID',+ description:+ 'Creation reason as a General_Event_Subcategory_ID (e.g. `Create_Job_Requisition_Administrative_Non_Competitive_Fill_No_Recruiting_Required`) or a WID.',+ required: true,+ }),+ jobPostingTitle: Property.ShortText({+ displayName: 'Job Posting Title',+ description: 'The title for the job posting.',+ required: true,+ }),+ numberOfOpenings: Property.Number({+ displayName: 'Number of Openings',+ description: 'Number of openings (default: 1).',+ required: false,+ defaultValue: 1,+ }),+ jobProfileId: Property.ShortText({+ displayName: 'Job Profile ID',+ description: 'Job profile reference ID.',+ required: false,+ }),+ workerTypeId: Property.ShortText({+ displayName: 'Worker Type ID',+ description:+ 'Worker type reference ID (Worker_Type_ID), e.g. `EE`. Required when the tenant has no default.',+ required: false,+ }),+ workerSubTypeId: Property.ShortText({+ displayName: 'Worker Sub-Type ID',+ description:+ 'Worker sub-type reference ID (Employee_Type_ID), e.g. `Regular`. Required when the tenant has no default.',+ required: false,+ }),+ primaryLocationId: Property.ShortText({+ displayName: 'Primary Location ID',+ description: 'Primary location WID, also used as the primary job posting location.',+ required: false,+ }),+ recruitingStartDate: Property.ShortText({+ displayName: 'Recruiting Start Date',+ description: 'Date to start recruiting (YYYY-MM-DD). Required by Workday.',+ required: true,+ }),+ targetHireDate: Property.ShortText({+ displayName: 'Target Hire Date',+ description: 'Target date for hiring (YYYY-MM-DD). Required by Workday.',+ required: true,+ }),+ },+ async run({ auth, propsValue }) {+ return await workdayApi.createJobRequisition({+ auth,+ supervisoryOrganizationId: propsValue.supervisoryOrganizationId,+ reasonId: propsValue.reasonId,+ jobPostingTitle: propsValue.jobPostingTitle,+ numberOfOpenings: propsValue.numberOfOpenings,+ jobProfileId: propsValue.jobProfileId,+ workerTypeId: propsValue.workerTypeId,+ workerSubTypeId: propsValue.workerSubTypeId,+ primaryLocationId: propsValue.primaryLocationId,+ recruitingStartDate: propsValue.recruitingStartDate,+ targetHireDate: propsValue.targetHireDate,+ });+ },+});diff --git a/packages/pieces/community/workday/src/lib/actions/create-pre-hire.ts b/packages/pieces/community/workday/src/lib/actions/create-pre-hire.tsnew file mode 100644index 00000000000..03320b8d3ce--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/create-pre-hire.ts@@ -0,0 +1,57 @@+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';++export const createPreHireAction = createAction({+ auth: workdayAuth,+ name: 'create_pre_hire',+ classification: 'WRITE',+ displayName: 'Create Pre-Hire',+ description: 'Creates a new pre-hire record in Workday.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Creates a pre-hire/applicant record in Workday with legal name, contact details (email plus optional phone), and an ISO 3166-1 Alpha-3 country code. Use to register a candidate before running the Hire Employee action against them. Country is required by Workday. Not idempotent: each call submits a new applicant, with no key to update an existing one.',+ idempotent: false,+ },+ props: {+ firstName: Property.ShortText({+ displayName: 'First Name',+ description: 'Legal first name of the pre-hire.',+ required: true,+ }),+ lastName: Property.ShortText({+ displayName: 'Last Name',+ description: 'Legal last name of the pre-hire.',+ required: true,+ }),+ email: Property.ShortText({+ displayName: 'Email',+ description: 'Email address (at least one of email, phone, or address is required).',+ required: true,+ }),+ phone: Property.ShortText({+ displayName: 'Phone',+ description: 'Phone number.',+ required: false,+ }),+ country: Property.ShortText({+ displayName: 'Country',+ description:+ 'ISO 3166-1 Alpha-3 country code (e.g., "USA", "GBR", "DEU"). Required by Workday.',+ required: true,+ defaultValue: 'USA',+ }),+ },+ async run({ auth, propsValue }) {+ return await workdayApi.createPreHire({+ auth,+ firstName: propsValue.firstName,+ lastName: propsValue.lastName,+ email: propsValue.email,+ phone: propsValue.phone,+ country: propsValue.country,+ });+ },+});diff --git a/packages/pieces/community/workday/src/lib/actions/create-supplier-credit-memo.ts b/packages/pieces/community/workday/src/lib/actions/create-supplier-credit-memo.tsnew file mode 100644index 00000000000..c314134f4ca--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/create-supplier-credit-memo.ts@@ -0,0 +1,49 @@+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';++export const createSupplierCreditMemoAction = createAction({+ auth: workdayAuth,+ name: 'create_supplier_credit_memo',+ classification: 'WRITE',+ displayName: 'Create Supplier Credit Memo',+ description: 'Creates a new supplier credit memo in Workday.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Submits a supplier invoice adjustment (credit memo) against a supplier (by WID) with an adjustment date and control-total amount, plus an optional memo. Use to record a credit owed by a supplier. Not idempotent: each call submits a separate credit memo.',+ idempotent: false,+ },+ props: {+ supplierId: Property.ShortText({+ displayName: 'Supplier ID',+ description: 'The ID of the supplier.',+ required: true,+ }),+ memoDate: Property.ShortText({+ displayName: 'Memo Date',+ description: 'Credit memo date (YYYY-MM-DD).',+ required: true,+ }),+ amount: Property.ShortText({+ displayName: 'Amount',+ description: 'Credit memo amount.',+ required: true,+ }),+ description: Property.LongText({+ displayName: 'Description',+ description: 'Description of the credit memo.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ return await workdayApi.createSupplierCreditMemo({+ auth,+ supplierId: propsValue.supplierId,+ memoDate: propsValue.memoDate,+ amount: propsValue.amount,+ description: propsValue.description,+ });+ },+});diff --git a/packages/pieces/community/workday/src/lib/actions/create-time-off-request.ts b/packages/pieces/community/workday/src/lib/actions/create-time-off-request.tsnew file mode 100644index 00000000000..916263d5f16--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/create-time-off-request.ts@@ -0,0 +1,64 @@+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';++export const createTimeOffRequestAction = createAction({+ auth: workdayAuth,+ name: 'create_time_off_request',+ classification: 'WRITE',+ displayName: 'Create Time Off Request',+ description: 'Creates a new time off request in Workday.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Submits and auto-completes a time-off request for a worker (by WID) of a given time-off type, entering 8 requested hours for each day in the inclusive start-to-end date range, with an optional comment. Use to book vacation, sick, or other leave on a worker’s behalf. Not idempotent: each call enters a new time-off request.',+ idempotent: false,+ },+ props: {+ workerId: Property.ShortText({+ displayName: 'Worker ID',+ description: 'The ID of the worker requesting time off.',+ required: true,+ }),+ timeOffTypeId: Property.ShortText({+ displayName: 'Time Off Type ID',+ description:+ 'Time off type as a Time_Off_Type_ID (e.g. `Vacation_Hours`, `Sick_Hours`) or a WID.',+ required: true,+ }),+ startDate: Property.ShortText({+ displayName: 'Start Date',+ description: 'Start date of the time off (YYYY-MM-DD).',+ required: true,+ }),+ endDate: Property.ShortText({+ displayName: 'End Date',+ description: 'End date of the time off (YYYY-MM-DD).',+ required: true,+ }),+ comment: Property.LongText({+ displayName: 'Comment',+ description: 'Optional comment for the request.',+ required: false,+ }),+ hoursPerDay: Property.Number({+ displayName: 'Hours per Day',+ description:+ 'Hours requested for each weekday in the range (default: 8). Weekends are skipped.',+ required: false,+ defaultValue: 8,+ }),+ },+ async run({ auth, propsValue }) {+ return await workdayApi.createTimeOffRequest({+ auth,+ workerId: propsValue.workerId,+ timeOffTypeId: propsValue.timeOffTypeId,+ startDate: propsValue.startDate,+ endDate: propsValue.endDate,+ comment: propsValue.comment,+ hoursPerDay: propsValue.hoursPerDay,+ });+ },+});diff --git a/packages/pieces/community/workday/src/lib/actions/create-update-custom-object.ts b/packages/pieces/community/workday/src/lib/actions/create-update-custom-object.tsnew file mode 100644index 00000000000..997c30cb4cc--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/create-update-custom-object.ts@@ -0,0 +1,41 @@+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';+import { workdayProps } from '../common/props';+import { workdayUtils } from '../common/utils';++export const createUpdateCustomObjectAction = createAction({+ auth: workdayAuth,+ name: 'create_update_custom_object',+ classification: 'WRITE',+ displayName: 'Create/Update Custom Object',+ description: 'Creates or updates a Workday custom object record.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Writes a record of a tenant-defined Workday custom object, chosen by its definition alias, with the field values supplied as a JSON body keyed by field alias. Without a record ID the body must name the record it is attached to, e.g. `{ "worker": { "id": "<worker WID>" }, "note": "..." }`; a single-instance object that already has a record is updated instead of duplicated. With a record ID only the given fields of that record are updated. Call List Custom Object Definitions (Batch) first when the alias is unknown. Not idempotent for multi-instance objects: with no record ID every call creates another record.',+ idempotent: false,+ },+ props: {+ definitionId: workdayProps.customObjectDefinition({ required: true }),+ objectId: Property.ShortText({+ displayName: 'Record ID',+ description:+ 'Record ID to update. Leave blank to create; the body must then reference the record it is attached to, e.g. `{ "worker": { "id": "..." } }`.',+ required: false,+ }),+ body: workdayProps.requestBody({ required: true }),+ },+ async run({ auth, propsValue }) {+ const body: Record<string, unknown> =+ typeof propsValue.body === 'string' ? JSON.parse(propsValue.body) : { ...propsValue.body };+ const result = await workdayApi.upsertCustomObject({+ auth,+ alias: propsValue.definitionId,+ objectId: propsValue.objectId,+ body,+ });+ return workdayUtils.flattenRecord({ value: result });+ },+});diff --git a/packages/pieces/community/workday/src/lib/actions/create-worker-time-block.ts b/packages/pieces/community/workday/src/lib/actions/create-worker-time-block.tsnew file mode 100644index 00000000000..18cbaec240b--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/create-worker-time-block.ts@@ -0,0 +1,55 @@+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';++export const createWorkerTimeBlockAction = createAction({+ auth: workdayAuth,+ name: 'create_worker_time_block',+ classification: 'WRITE',+ displayName: 'Create Worker Time Block',+ description: 'Creates a new worker time block in Workday.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Reports a time block for a worker (by WID) on a given date with a quantity of hours, optionally tagged with a time-entry-code WID and a comment. Use to log hours worked into Workday Time Tracking. Not idempotent: each call appends another reported time block.',+ idempotent: false,+ },+ props: {+ workerId: Property.ShortText({+ displayName: 'Worker ID',+ description: 'The ID of the worker.',+ required: true,+ }),+ date: Property.ShortText({+ displayName: 'Date',+ description: 'Date of the time block (YYYY-MM-DD).',+ required: true,+ }),+ hours: Property.Number({+ displayName: 'Hours',+ description: 'Number of hours worked.',+ required: true,+ }),+ timeTypeId: Property.ShortText({+ displayName: 'Time Type ID',+ description: 'Time type reference ID.',+ required: false,+ }),+ comment: Property.LongText({+ displayName: 'Comment',+ description: 'Optional comment.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ return await workdayApi.createWorkerTimeBlock({+ auth,+ workerId: propsValue.workerId,+ date: propsValue.date,+ hours: propsValue.hours,+ timeTypeId: propsValue.timeTypeId,+ comment: propsValue.comment,+ });+ },+});diff --git a/packages/pieces/community/workday/src/lib/action/find-purchase-order.ts b/packages/pieces/community/workday/src/lib/actions/find-purchase-order.tssimilarity index 59%rename from packages/pieces/community/workday/src/lib/action/find-purchase-order.tsrename to packages/pieces/community/workday/src/lib/actions/find-purchase-order.tsindex 35d348bd00e..436d4b45d7a 100644--- a/packages/pieces/community/workday/src/lib/action/find-purchase-order.ts+++ b/packages/pieces/community/workday/src/lib/actions/find-purchase-order.ts@@ -1,12 +1,9 @@-import {- OAuth2PropertyValue,- Property,- createAction,-} from '@activepieces/pieces-framework';+import { Property, createAction } from '@activepieces/pieces-framework';+import { workdayAuth } from '../auth';-import { escapeWql, workdayWqlRequest } from '../common';+import { workdayApi } from '../common/api';-export const findPurchaseOrder = createAction({+export const findPurchaseOrderAction = createAction({auth: workdayAuth,name: 'find_purchase_order',classification: 'READ',@@ -25,12 +22,10 @@ export const findPurchaseOrder = createAction({required: true,}),},- async run(ctx) {- const { purchaseOrderId } = ctx.propsValue;- const response = await workdayWqlRequest(- ctx.auth as OAuth2PropertyValue,- `SELECT purchaseOrder FROM purchaseOrders WHERE purchaseOrder = '${escapeWql(purchaseOrderId)}'`,- );- return response.body;+ async run({ auth, propsValue }) {+ return await workdayApi.findPurchaseOrder({+ auth,+ purchaseOrderId: propsValue.purchaseOrderId,+ });},});diff --git a/packages/pieces/community/workday/src/lib/action/find-records-wql.ts b/packages/pieces/community/workday/src/lib/actions/find-records-wql.tssimilarity index 64%rename from packages/pieces/community/workday/src/lib/action/find-records-wql.tsrename to packages/pieces/community/workday/src/lib/actions/find-records-wql.tsindex 4e6ad3f10fb..afa4c74bba4 100644--- a/packages/pieces/community/workday/src/lib/action/find-records-wql.ts+++ b/packages/pieces/community/workday/src/lib/actions/find-records-wql.ts@@ -1,18 +1,14 @@-import {- OAuth2PropertyValue,- Property,- createAction,-} from '@activepieces/pieces-framework';+import { Property, createAction } from '@activepieces/pieces-framework';+import { workdayAuth } from '../auth';-import { workdayWqlRequest } from '../common';+import { workdayApi } from '../common/api';-export const findRecordsWql = createAction({+export const findRecordsWqlAction = createAction({auth: workdayAuth,name: 'find_records_wql',classification: 'SEARCH',displayName: 'Find Records (WQL)',- description:- 'Executes a Workday Query Language (WQL) query and returns the results.',+ description: 'Executes a Workday Query Language (WQL) query and returns the results.',audience: 'both',aiMetadata: {description:@@ -27,11 +23,7 @@ export const findRecordsWql = createAction({required: true,}),},- async run(ctx) {- const response = await workdayWqlRequest(- ctx.auth as OAuth2PropertyValue,- ctx.propsValue.query,- );- return response.body;+ async run({ auth, propsValue }) {+ return await workdayApi.runWql({ auth, query: propsValue.query });},});diff --git a/packages/pieces/community/workday/src/lib/actions/find-supplier-invoice.ts b/packages/pieces/community/workday/src/lib/actions/find-supplier-invoice.tsnew file mode 100644index 00000000000..ef4c0ef4974--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/find-supplier-invoice.ts@@ -0,0 +1,34 @@+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';++export const findSupplierInvoiceAction = createAction({+ auth: workdayAuth,+ name: 'find_supplier_invoice',+ classification: 'READ',+ displayName: 'Find Supplier Invoice',+ description: 'Finds a supplier invoice by its Workday ID or Supplier Invoice ID.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Looks up a single supplier invoice through the Resource_Management Get_Supplier_Invoices web service, by its Workday ID (32-character WID) or its Supplier Invoice ID (e.g. `SUPPLIER_INVOICE-11-894`). The supplier-facing invoice number (e.g. `SINV-10000885`) is not a lookup key. Returns the invoice data with its reference IDs. Requires ISU credentials on the connection. Read-only and idempotent.',+ idempotent: true,+ },+ props: {+ invoiceId: Property.ShortText({+ displayName: 'Invoice ID',+ description:+ 'The invoice Workday ID (WID) or Supplier Invoice ID, e.g. `SUPPLIER_INVOICE-11-894`. The invoice number (e.g. `SINV-10000885`) is not accepted.',+ required: true,+ }),+ },+ async run({ auth, propsValue }) {+ const invoiceId = propsValue.invoiceId.trim();+ const invoice = await workdayApi.getSupplierInvoice({ auth, invoiceId });+ if (!invoice) {+ throw new Error(`No supplier invoice found for ID "${invoiceId}".`);+ }+ return invoice;+ },+});diff --git a/packages/pieces/community/workday/src/lib/action/find-supplier-payment.ts b/packages/pieces/community/workday/src/lib/actions/find-supplier-payment.tssimilarity index 56%rename from packages/pieces/community/workday/src/lib/action/find-supplier-payment.tsrename to packages/pieces/community/workday/src/lib/actions/find-supplier-payment.tsindex 627f4db097e..bc46826fc7e 100644--- a/packages/pieces/community/workday/src/lib/action/find-supplier-payment.ts+++ b/packages/pieces/community/workday/src/lib/actions/find-supplier-payment.ts@@ -1,12 +1,9 @@-import {- OAuth2PropertyValue,- Property,- createAction,-} from '@activepieces/pieces-framework';+import { Property, createAction } from '@activepieces/pieces-framework';+import { workdayAuth } from '../auth';-import { escapeWql, workdayWqlRequest } from '../common';+import { workdayApi } from '../common/api';-export const findSupplierPayment = createAction({+export const findSupplierPaymentAction = createAction({auth: workdayAuth,name: 'find_supplier_payment',classification: 'SEARCH',@@ -30,18 +27,11 @@ export const findSupplierPayment = createAction({required: false,}),},- async run(ctx) {- const { supplierId, paymentId } = ctx.propsValue;- const conditions: string[] = [];- if (supplierId) conditions.push(`supplier = '${escapeWql(supplierId)}'`);- if (paymentId) conditions.push(`supplierPayment = '${escapeWql(paymentId)}'`);-- const whereClause =- conditions.length > 0 ? ` WHERE ${conditions.join(' AND ')}` : '';- const response = await workdayWqlRequest(- ctx.auth as OAuth2PropertyValue,- `SELECT supplierPayment FROM supplierPayments${whereClause}`,- );- return response.body;+ async run({ auth, propsValue }) {+ return await workdayApi.findSupplierPayments({+ auth,+ supplierId: propsValue.supplierId,+ paymentId: propsValue.paymentId,+ });},});diff --git a/packages/pieces/community/workday/src/lib/action/find-supplier.ts b/packages/pieces/community/workday/src/lib/actions/find-supplier.tssimilarity index 59%rename from packages/pieces/community/workday/src/lib/action/find-supplier.tsrename to packages/pieces/community/workday/src/lib/actions/find-supplier.tsindex c82d7134940..36ff40b034f 100644--- a/packages/pieces/community/workday/src/lib/action/find-supplier.ts+++ b/packages/pieces/community/workday/src/lib/actions/find-supplier.ts@@ -1,12 +1,9 @@-import {- OAuth2PropertyValue,- Property,- createAction,-} from '@activepieces/pieces-framework';+import { Property, createAction } from '@activepieces/pieces-framework';+import { workdayAuth } from '../auth';-import { escapeWql, workdayWqlRequest } from '../common';+import { workdayApi } from '../common/api';-export const findSupplier = createAction({+export const findSupplierAction = createAction({auth: workdayAuth,name: 'find_supplier',classification: 'READ',@@ -25,12 +22,7 @@ export const findSupplier = createAction({required: true,}),},- async run(ctx) {- const { supplierId } = ctx.propsValue;- const response = await workdayWqlRequest(- ctx.auth as OAuth2PropertyValue,- `SELECT supplier, supplierName FROM suppliers WHERE supplier = '${escapeWql(supplierId)}'`,- );- return response.body;+ async run({ auth, propsValue }) {+ return await workdayApi.findSupplier({ auth, supplierId: propsValue.supplierId });},});diff --git a/packages/pieces/community/workday/src/lib/actions/get-business-object-details-batch.ts b/packages/pieces/community/workday/src/lib/actions/get-business-object-details-batch.tsnew file mode 100644index 00000000000..0b7d051d5f0--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/get-business-object-details-batch.ts@@ -0,0 +1,57 @@+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';+import { workdayProps } from '../common/props';+import { workdayUtils } from '../common/utils';++export const getBusinessObjectDetailsBatchAction = createAction({+ auth: workdayAuth,+ name: 'get_business_object_details_batch',+ classification: 'READ',+ displayName: 'Get Business Object Details (Batch)',+ description: 'Retrieves details for one or more business objects by ID in a single step.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Fetches the full record for one or more Workday business objects by ID in a single step, after selecting the module (Recruiting, Onboarding, or HR Services & Time Tracking) and an object type (Worker, Case, or Time Entry), or supplying a custom REST path instead. Use when the record IDs are already known; use Search Business Object (Batch) to find records by criteria. Read-only and idempotent.',+ idempotent: true,+ },+ props: {+ module: workdayProps.module({ required: true }),+ businessObject: workdayProps.businessObject({ required: true }),+ objectIds: Property.Array({+ displayName: 'Object IDs',+ description: 'One or more Workday record IDs to retrieve.',+ required: true,+ properties: {+ id: Property.ShortText({+ displayName: 'ID',+ required: true,+ }),+ },+ }),+ },+ async run({ auth, propsValue }) {+ const businessObject = workdayUtils.resolveBusinessObject({+ module: propsValue.module,+ selection: propsValue.businessObject,+ });+ const module = workdayUtils.toWorkdayModule({ module: propsValue.module });+ const ids = propsValue.objectIds.flatMap((item) =>+ typeof item === 'object' && item !== null && 'id' in item ? [String(item.id)] : [],+ );++ const records = await Promise.all(+ ids.map(async (id) => {+ const record = await workdayApi.getBusinessObject({ auth, businessObject, objectId: id });+ return workdayUtils.formatOutput({ record, module });+ }),+ );++ return {+ total_count: records.length,+ records,+ };+ },+});diff --git a/packages/pieces/community/workday/src/lib/actions/get-custom-objects.ts b/packages/pieces/community/workday/src/lib/actions/get-custom-objects.tsnew file mode 100644index 00000000000..56e215a5132--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/get-custom-objects.ts@@ -0,0 +1,38 @@+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';+import { workdayProps } from '../common/props';+import { workdayUtils } from '../common/utils';++export const getCustomObjectsAction = createAction({+ auth: workdayAuth,+ name: 'get_custom_objects',+ classification: 'READ',+ displayName: 'Get Custom Objects',+ description:+ 'Retrieves a custom object record by its record ID or, for single-instance objects, by the parent record ID.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Retrieves one record of a tenant-defined Workday custom object, addressed by the definition alias plus either the record ID or, for a single-instance object, the ID of the record it is attached to (e.g. the worker WID). Call List Custom Object Definitions (Batch) first to discover the alias, and use Get Business Object Details (Batch) for standard objects such as workers or job requisitions. Read-only and idempotent.',+ idempotent: true,+ },+ props: {+ definitionId: workdayProps.customObjectDefinition({ required: true }),+ objectId: Property.ShortText({+ displayName: 'Record ID',+ description:+ 'The custom object record ID, or for a single-instance object the ID of the record it is attached to (e.g. the worker WID).',+ required: true,+ }),+ },+ async run({ auth, propsValue }) {+ const result = await workdayApi.getCustomObject({+ auth,+ alias: propsValue.definitionId,+ objectId: propsValue.objectId,+ });+ return workdayUtils.flattenRecord({ value: result });+ },+});diff --git a/packages/pieces/community/workday/src/lib/action/get-report-wql-batch.ts b/packages/pieces/community/workday/src/lib/actions/get-report-wql-batch.tssimilarity index 61%rename from packages/pieces/community/workday/src/lib/action/get-report-wql-batch.tsrename to packages/pieces/community/workday/src/lib/actions/get-report-wql-batch.tsindex 657acf89a70..40161aed697 100644--- a/packages/pieces/community/workday/src/lib/action/get-report-wql-batch.ts+++ b/packages/pieces/community/workday/src/lib/actions/get-report-wql-batch.ts@@ -1,16 +1,16 @@import { createAction } from '@activepieces/pieces-framework';+import { workdayAuth } from '../auth';-import { workdayWqlRequestAll } from '../common';-import { flattenRecord } from '../common/fields';-import { wqlQueryProperty } from '../common/props';+import { workdayApi } from '../common/api';+import { workdayProps } from '../common/props';+import { workdayUtils } from '../common/utils';-export const getReportWqlBatch = createAction({+export const getReportWqlBatchAction = createAction({auth: workdayAuth,name: 'get_report_wql_batch',classification: 'SEARCH',displayName: 'Get Report using WQL (Batch)',- description:- 'Executes a WQL query and returns all rows (use for report-style datasets).',+ description: 'Executes a WQL query and returns all rows (use for report-style datasets).',audience: 'both',aiMetadata: {description:@@ -18,11 +18,11 @@ export const getReportWqlBatch = createAction({idempotent: true,},props: {- query: wqlQueryProperty,+ query: workdayProps.wqlQuery({ required: true }),},async run({ auth, propsValue }) {- const records = await workdayWqlRequestAll(auth, propsValue.query);- const flattened = records.map((row) => flattenRecord(row));+ const records = await workdayApi.runWqlAll({ auth, query: propsValue.query });+ const flattened = records.map((row) => workdayUtils.flattenRecord({ value: row }));return {total_count: flattened.length,records: flattened,diff --git a/packages/pieces/community/workday/src/lib/actions/get-report.ts b/packages/pieces/community/workday/src/lib/actions/get-report.tsnew file mode 100644index 00000000000..fc51dd19052--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/get-report.ts@@ -0,0 +1,53 @@+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';+import { workdayProps } from '../common/props';+import { workdayUtils } from '../common/utils';++export const getReportAction = createAction({+ auth: workdayAuth,+ name: 'get_report',+ classification: 'READ',+ displayName: 'Get Report',+ description: 'Runs a Workday custom report through Reports-as-a-Service (RaaS).',+ audience: 'both',+ aiMetadata: {+ description:+ 'Runs a Workday custom report that is enabled as a web service (RaaS), addressed by its RaaS URL or `owner/report_name`, and returns its rows as JSON or the raw CSV, optionally passing prompt values keyed by prompt XML alias. Use when the data is already shaped by a report definition in the tenant; prefer Find Records (WQL) or Get Report using WQL (Batch) when the query can be expressed in WQL instead. Read-only and idempotent.',+ idempotent: true,+ },+ props: {+ reportId: workdayProps.reportId({ required: true }),+ reportParameters: workdayProps.reportParameters({ required: false }),+ format: Property.StaticDropdown({+ displayName: 'Format',+ description: 'JSON returns the rows; CSV returns the report as CSV text.',+ required: false,+ defaultValue: 'json',+ options: {+ disabled: false,+ options: [+ { label: 'JSON', value: 'json' },+ { label: 'CSV', value: 'csv' },+ ],+ },+ }),+ },+ async run({ auth, propsValue }) {+ const report = await workdayApi.getReport({+ auth,+ report: propsValue.reportId,+ parameters: propsValue.reportParameters,+ format: propsValue.format === 'csv' ? 'csv' : 'json',+ });+ if (report.format === 'csv') {+ return { report_id: report.reportPath, csv: report.csv };+ }+ return {+ total_count: report.rows.length,+ report_id: report.reportPath,+ records: report.rows.map((row) => workdayUtils.flattenRecord({ value: row })),+ };+ },+});diff --git a/packages/pieces/community/workday/src/lib/action/hire-employee.ts b/packages/pieces/community/workday/src/lib/actions/hire-employee.tssimilarity index 50%rename from packages/pieces/community/workday/src/lib/action/hire-employee.tsrename to packages/pieces/community/workday/src/lib/actions/hire-employee.tsindex 00af67a2a22..8244707c9b5 100644--- a/packages/pieces/community/workday/src/lib/action/hire-employee.ts+++ b/packages/pieces/community/workday/src/lib/actions/hire-employee.ts@@ -1,12 +1,12 @@-import {- OAuth2PropertyValue,- Property,- createAction,-} from '@activepieces/pieces-framework';+import { Property, createAction } from '@activepieces/pieces-framework';+import { workdayAuth } from '../auth';-import { workdaySoapRequest } from '../common';+import { workdayApi } from '../common/api';++const DEFAULT_HIRE_REASON_ID = 'Hire_Employee_Hire_Employee_New_Hire';+const DEFAULT_EMPLOYEE_TYPE_ID = 'Regular';-export const hireEmployee = createAction({+export const hireEmployeeAction = createAction({auth: workdayAuth,name: 'hire_employee',classification: 'WRITE',@@ -44,47 +44,30 @@ export const hireEmployee = createAction({description: 'Position reference ID.',required: false,}),+ hireReasonId: Property.ShortText({+ displayName: 'Hire Reason ID',+ description:+ 'Hire reason reference ID (General_Event_Subcategory_ID), e.g. `Hire_Employee_Hire_Employee_New_Hire`.',+ required: false,+ defaultValue: DEFAULT_HIRE_REASON_ID,+ }),+ employeeTypeId: Property.ShortText({+ displayName: 'Employee Type ID',+ description: 'Employee type reference ID (Employee_Type_ID), e.g. `Regular`.',+ required: false,+ defaultValue: DEFAULT_EMPLOYEE_TYPE_ID,+ }),},- async run(ctx) {- const {- applicantId,- hireDate,- positionId,- } = ctx.propsValue;-- const escapeXml = (s: string) =>- s- .replace(/&/g, '&')- .replace(/</g, '<')- .replace(/>/g, '>')- .replace(/"/g, '"');-- let positionXml = '';- if (positionId) {- positionXml = `- <bsvc:Position_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(positionId)}</bsvc:ID>- </bsvc:Position_Reference>`;- }-- const operationXml = `- <bsvc:Hire_Employee_Request bsvc:version="v46.0" xmlns:bsvc="urn:com.workday/bsvc">- <bsvc:Business_Process_Parameters>- <bsvc:Auto_Complete>true</bsvc:Auto_Complete>- <bsvc:Run_Now>true</bsvc:Run_Now>- </bsvc:Business_Process_Parameters>- <bsvc:Hire_Employee_Data>- <bsvc:Applicant_Reference>- <bsvc:ID bsvc:type="WID">${escapeXml(applicantId)}</bsvc:ID>- </bsvc:Applicant_Reference>${positionXml}- <bsvc:Hire_Date>${escapeXml(hireDate)}</bsvc:Hire_Date>- </bsvc:Hire_Employee_Data>- </bsvc:Hire_Employee_Request>`;-- return workdaySoapRequest(- ctx.auth as OAuth2PropertyValue,- 'Staffing',- operationXml,- );+ async run({ auth, propsValue }) {+ return await workdayApi.hireEmployee({+ auth,+ applicantId: propsValue.applicantId,+ hireDate: propsValue.hireDate,+ positionId: propsValue.positionId,+ supervisoryOrganizationId: propsValue.supervisoryOrganizationId,+ jobProfileId: propsValue.jobProfileId,+ hireReasonId: propsValue.hireReasonId || DEFAULT_HIRE_REASON_ID,+ employeeTypeId: propsValue.employeeTypeId || DEFAULT_EMPLOYEE_TYPE_ID,+ });},});diff --git a/packages/pieces/community/workday/src/lib/action/list-custom-object-definitions-batch.ts b/packages/pieces/community/workday/src/lib/actions/list-custom-object-definitions-batch.tssimilarity index 62%rename from packages/pieces/community/workday/src/lib/action/list-custom-object-definitions-batch.tsrename to packages/pieces/community/workday/src/lib/actions/list-custom-object-definitions-batch.tsindex 2fe1d2e971e..57b9181055c 100644--- a/packages/pieces/community/workday/src/lib/action/list-custom-object-definitions-batch.ts+++ b/packages/pieces/community/workday/src/lib/actions/list-custom-object-definitions-batch.ts@@ -1,15 +1,15 @@import { createAction } from '@activepieces/pieces-framework';+import { workdayAuth } from '../auth';-import { workdayListCustomObjectDefinitions } from '../common';-import { flattenRecord } from '../common/fields';+import { workdayApi } from '../common/api';+import { workdayUtils } from '../common/utils';-export const listCustomObjectDefinitionsBatch = createAction({+export const listCustomObjectDefinitionsBatchAction = createAction({auth: workdayAuth,name: 'list_custom_object_definitions_batch',classification: 'SEARCH',displayName: 'List Custom Object Definitions (Batch)',- description:- 'Lists all custom object definitions available in your Workday tenant.',+ description: 'Lists all custom object definitions available in your Workday tenant.',audience: 'both',aiMetadata: {description:@@ -18,8 +18,8 @@ export const listCustomObjectDefinitionsBatch = createAction({},props: {},async run({ auth }) {- const definitions = await workdayListCustomObjectDefinitions(auth);- const flattened = definitions.map((item) => flattenRecord(item));+ const definitions = await workdayApi.listCustomObjectDefinitions({ auth });+ const flattened = definitions.map((item) => workdayUtils.flattenRecord({ value: item }));return {total_count: flattened.length,definitions: flattened,diff --git a/packages/pieces/community/workday/src/lib/actions/search-business-object-batch.ts b/packages/pieces/community/workday/src/lib/actions/search-business-object-batch.tsnew file mode 100644index 00000000000..c6503dacb93--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/search-business-object-batch.ts@@ -0,0 +1,48 @@+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';+import { workdayProps } from '../common/props';+import { workdayUtils } from '../common/utils';++export const searchBusinessObjectBatchAction = createAction({+ auth: workdayAuth,+ name: 'search_business_object_batch',+ classification: 'SEARCH',+ displayName: 'Search Business Object (Batch)',+ description: 'Searches business objects with pagination and returns all matching records.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Pages through a Workday business object collection and returns every matching record, after selecting the module (Recruiting, Onboarding, or HR Services & Time Tracking) and an object type (Worker, Case, or Time Entry), or supplying a custom REST path instead. Optional JSON query parameters narrow the results; omitting them returns all records of that type. Use to find records by criteria, and Get Business Object Details (Batch) when the IDs are already known. Read-only and idempotent.',+ idempotent: true,+ },+ props: {+ module: workdayProps.module({ required: true }),+ businessObject: workdayProps.businessObject({ required: true }),+ queryParams: Property.Json({+ displayName: 'Query Parameters (JSON)',+ description: 'Optional REST query parameters, e.g. `{ "limit": 50, "status": "Open" }`.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ const businessObject = workdayUtils.resolveBusinessObject({+ module: propsValue.module,+ selection: propsValue.businessObject,+ });+ const module = workdayUtils.toWorkdayModule({ module: propsValue.module });++ const records = await workdayApi.searchBusinessObjects({+ auth,+ businessObject,+ query: workdayUtils.toQueryParams({ value: propsValue.queryParams }),+ });+ const formatted = workdayUtils.formatOutputs({ records, module });++ return {+ total_count: formatted.length,+ records: formatted,+ };+ },+});diff --git a/packages/pieces/community/workday/src/lib/actions/update-business-object.ts b/packages/pieces/community/workday/src/lib/actions/update-business-object.tsnew file mode 100644index 00000000000..4c88adf47ce--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/update-business-object.ts@@ -0,0 +1,47 @@+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';+import { workdayProps } from '../common/props';+import { workdayUtils } from '../common/utils';++export const updateBusinessObjectAction = createAction({+ auth: workdayAuth,+ name: 'update_business_object',+ classification: 'WRITE',+ displayName: 'Update Business Object',+ description: 'Updates an existing business object by ID using the REST API.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Updates one existing Workday business object by its ID, sending the new field values as a JSON body, after selecting the module (Recruiting, Onboarding, or HR Services & Time Tracking) and an object type (Worker, Case, or Time Entry), or supplying a custom REST path instead. Use for generic edits to worker, case, or time-entry records, and prefer the dedicated action (e.g. Update Supplier, Change Job) when one exists. Requires the record ID and a JSON body. Idempotent: keyed on the object ID, so re-sending the same body converges to the same state.',+ idempotent: true,+ },+ props: {+ module: workdayProps.module({ required: true }),+ businessObject: workdayProps.businessObject({ required: true }),+ objectId: Property.ShortText({+ displayName: 'Object ID',+ description: 'Workday ID of the record to update.',+ required: true,+ }),+ body: workdayProps.requestBody({ required: true }),+ },+ async run({ auth, propsValue }) {+ const businessObject = workdayUtils.resolveBusinessObject({+ module: propsValue.module,+ selection: propsValue.businessObject,+ });+ const module = workdayUtils.toWorkdayModule({ module: propsValue.module });+ const body =+ typeof propsValue.body === 'string' ? JSON.parse(propsValue.body) : propsValue.body;++ const record = await workdayApi.updateBusinessObject({+ auth,+ businessObject,+ objectId: propsValue.objectId,+ body,+ });+ return workdayUtils.formatOutput({ record, module });+ },+});diff --git a/packages/pieces/community/workday/src/lib/actions/update-supplier-invoice.ts b/packages/pieces/community/workday/src/lib/actions/update-supplier-invoice.tsnew file mode 100644index 00000000000..973d569c3ae--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/update-supplier-invoice.ts@@ -0,0 +1,49 @@+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';++export const updateSupplierInvoiceAction = createAction({+ auth: workdayAuth,+ name: 'update_supplier_invoice',+ classification: 'WRITE',+ displayName: 'Update Supplier Invoice',+ description: 'Updates an existing supplier invoice in Workday.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Updates an existing supplier invoice (identified by its invoice WID) in Workday, setting any of invoice date, invoice number, and total amount. Use to amend an existing supplier invoice. Idempotent: keyed on the invoice ID, so re-sending the same field values converges to the same state.',+ idempotent: true,+ },+ props: {+ invoiceId: Property.ShortText({+ displayName: 'Invoice ID',+ description: 'The ID of the supplier invoice to update.',+ required: true,+ }),+ invoiceDate: Property.ShortText({+ displayName: 'Invoice Date',+ description: 'Invoice date (YYYY-MM-DD).',+ required: false,+ }),+ invoiceNumber: Property.ShortText({+ displayName: 'Invoice Number',+ description: 'Invoice number.',+ required: false,+ }),+ total: Property.ShortText({+ displayName: 'Total Amount',+ description: 'Invoice total amount.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ return await workdayApi.updateSupplierInvoice({+ auth,+ invoiceId: propsValue.invoiceId,+ invoiceDate: propsValue.invoiceDate,+ invoiceNumber: propsValue.invoiceNumber,+ total: propsValue.total,+ });+ },+});diff --git a/packages/pieces/community/workday/src/lib/actions/update-supplier.ts b/packages/pieces/community/workday/src/lib/actions/update-supplier.tsnew file mode 100644index 00000000000..7bac191d35f--- /dev/null+++ b/packages/pieces/community/workday/src/lib/actions/update-supplier.ts@@ -0,0 +1,56 @@+import { Property, createAction } from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';++export const updateSupplierAction = createAction({+ auth: workdayAuth,+ name: 'update_supplier',+ classification: 'WRITE',+ displayName: 'Update Supplier',+ description: 'Updates an existing supplier in Workday.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Updates an existing supplier (identified by its supplier WID) in Workday, setting any of name, a tax ID with its Tax ID Type (e.g. USA-EIN; other tax IDs are kept), and payment-terms WID. Use to amend supplier master data. Idempotent: keyed on the supplier ID, so re-sending the same field values converges to the same state.',+ idempotent: true,+ },+ props: {+ supplierId: Property.ShortText({+ displayName: 'Supplier ID',+ description: 'The ID of the supplier to update.',+ required: true,+ }),+ supplierName: Property.ShortText({+ displayName: 'Supplier Name',+ description: 'Updated supplier name.',+ required: false,+ }),+ taxId: Property.ShortText({+ displayName: 'Tax ID',+ description:+ 'Supplier tax identification number. Needs Tax ID Type. Adds or replaces the tax ID of that type only; other tax IDs are kept.',+ required: false,+ }),+ taxIdType: Property.ShortText({+ displayName: 'Tax ID Type',+ description: 'Workday Tax ID Type reference ID, e.g. `USA-EIN`. Required when Tax ID is set.',+ required: false,+ }),+ paymentTermsId: Property.ShortText({+ displayName: 'Payment Terms ID',+ description: 'Payment terms reference ID.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ return await workdayApi.updateSupplier({+ auth,+ supplierId: propsValue.supplierId,+ supplierName: propsValue.supplierName,+ taxId: propsValue.taxId,+ taxIdType: propsValue.taxIdType,+ paymentTermsId: propsValue.paymentTermsId,+ });+ },+});diff --git a/packages/pieces/community/workday/src/lib/auth.ts b/packages/pieces/community/workday/src/lib/auth.tsindex b1b5bc91a39..47be5c56dc8 100644--- a/packages/pieces/community/workday/src/lib/auth.ts+++ b/packages/pieces/community/workday/src/lib/auth.ts@@ -1,25 +1,38 @@-import { PieceAuth, Property } from '@activepieces/pieces-framework';+import { AppConnectionType, PieceAuth, Property } from '@activepieces/pieces-framework';-export const workdayAuth = PieceAuth.OAuth2({+import { workdayApi } from './common/api';++const apiHostDescription =+ 'Your Workday services host, without https://, e.g. `wd2-impl-services1.workday.com`. It is the host of the Token Endpoint or Workday REST API Endpoint shown in **View API Clients**.';++const tenantDescription =+ 'Your Workday tenant name, e.g. `acme_impl`. It is the part after the host in your Workday URL (`https://<host>/<tenant>/...`).';++const wwsVersionProperty = Property.ShortText({+ displayName: 'WWS Version',+ description: 'Workday Web Services (SOAP) version, e.g. `v47.0`. Leave empty for v47.0.',+ required: false,+ defaultValue: 'v47.0',+});++export const workdayOAuth2Auth = PieceAuth.OAuth2({props: {authHost: Property.ShortText({displayName: 'Authorization Host',description:- 'The host for OAuth authorization (e.g., "impl.workday.com" for sandbox). Found in your Authorization Endpoint URL.',+ 'The Authorization Endpoint from **View API Clients**, without https:// and without `/<tenant>/authorize`, e.g. `wd2-impl.workday.com` or `impl.wd5.myworkday.com/wday/authgwy`.',required: true,defaultValue: 'impl.workday.com',}),apiHost: Property.ShortText({displayName: 'API Host',- description:- 'Your Workday API/services host (e.g., "wd2-impl-services1.workday.com" for sandbox). Found in your Token Endpoint or REST API Endpoint URL.',+ description: apiHostDescription,required: true,defaultValue: 'wd2-impl-services1.workday.com',}),tenant: Property.ShortText({displayName: 'Tenant',- description:- 'Your Workday tenant identifier. Found in your Workday URL.',+ description: tenantDescription,required: true,}),isuUsername: Property.ShortText({@@ -30,15 +43,63 @@ export const workdayAuth = PieceAuth.OAuth2({}),isuPassword: PieceAuth.SecretText({displayName: 'ISU Password (for write operations)',- description:- 'Integration System User password for SOAP API write operations.',+ description: 'Integration System User password for SOAP API write operations.',required: false,}),+ wwsVersion: wwsVersionProperty,},required: true,description: 'Authenticate with Workday',authUrl: 'https://{authHost}/{tenant}/authorize',- tokenUrl:- 'https://{apiHost}/ccx/oauth2/{tenant}/token',+ tokenUrl: 'https://{apiHost}/ccx/oauth2/{tenant}/token',scope: ['staffing', 'expenses', 'timeTracking', 'resourceManagement'],});++export const workdayIsuAuth = PieceAuth.CustomAuth({+ displayName: 'Integration System User',+ description: `Connect with a Workday Integration System User (ISU) instead of OAuth 2.0.++This connection runs SOAP actions (hire, job changes, time off, suppliers, invoices, Call Operation in SOAP mode) and Get Report / Scheduled Report Fetch. Actions that use Workday's REST API or WQL need the OAuth 2.0 connection.++The ISU needs a security group with access to the domains and business processes your flows use. For reports, share the report with the ISU.`,+ required: true,+ props: {+ apiHost: Property.ShortText({+ displayName: 'API Host',+ description: apiHostDescription,+ required: true,+ }),+ tenant: Property.ShortText({+ displayName: 'Tenant',+ description: tenantDescription,+ required: true,+ }),+ username: Property.ShortText({+ displayName: 'Username',+ description:+ 'The ISU username, e.g. `isu_activepieces` (`@<tenant>` is added for SOAP when missing).',+ required: true,+ }),+ password: PieceAuth.SecretText({+ displayName: 'Password',+ required: true,+ }),+ wwsVersion: wwsVersionProperty,+ },+ validate: async ({ auth }) => {+ try {+ await workdayApi.getServerTimestamp({+ auth: { type: AppConnectionType.CUSTOM_AUTH, props: auth },+ });+ return { valid: true };+ } catch (e) {+ const message = e instanceof Error ? e.message : String(e);+ if (/invalid username or password/i.test(message)) {+ return { valid: false, error: 'Workday rejected the username or password.' };+ }+ return { valid: false, error: `Could not reach Workday with these details. ${message}` };+ }+ },+});++export const workdayAuth = [workdayOAuth2Auth, workdayIsuAuth];diff --git a/packages/pieces/community/workday/src/lib/common/api.ts b/packages/pieces/community/workday/src/lib/common/api.tsnew file mode 100644index 00000000000..7dc601d2797--- /dev/null+++ b/packages/pieces/community/workday/src/lib/common/api.ts@@ -0,0 +1,1114 @@+import dayjs from 'dayjs';++import { HttpMethod, QueryParams } from '@activepieces/pieces-common';++import { workdayClient } from './client';+import { workdayUtils } from './utils';++import type {+ WorkdayAuthValue,+ WorkdayBusinessObject,+ WorkdayPage,+ WorkdayRecord,+ WorkdayReport,+ WorkdaySupplierInvoicesBody,+} from './types';++async function getServerTimestamp({ auth }: { auth: WorkdayAuthValue }): Promise<WorkdayRecord> {+ return await workdayClient.soap({+ auth,+ service: 'Human_Resources',+ operationXml: '<bsvc:Server_Timestamp_Get xmlns:bsvc="urn:com.workday/bsvc"/>',+ });+}++async function listCustomObjectDefinitions({+ auth,+}: {+ auth: WorkdayAuthValue;+}): Promise<WorkdayRecord[]> {+ return await workdayClient.paginate<WorkdayRecord>({+ auth,+ path: '/definitions',+ service: 'customObjectDefinition/v1',+ });+}++async function getCustomObject({+ auth,+ alias,+ objectId,+}: {+ auth: WorkdayAuthValue;+ alias: string;+ objectId: string;+}): Promise<WorkdayRecord> {+ return await workdayClient.request<WorkdayRecord>({+ auth,+ method: HttpMethod.GET,+ path: `/customObjects/${encodeURIComponent(alias)}/${encodeURIComponent(objectId)}`,+ });+}++async function upsertCustomObject({+ auth,+ alias,+ objectId,+ body,+}: {+ auth: WorkdayAuthValue;+ alias: string;+ objectId?: string;+ body: WorkdayRecord;+}): Promise<WorkdayRecord> {+ const path = `/customObjects/${encodeURIComponent(alias)}`;+ if (objectId) {+ return await workdayClient.request<WorkdayRecord>({+ auth,+ method: HttpMethod.PUT,+ path: `${path}/${encodeURIComponent(objectId)}`,+ body,+ });+ }+ return await workdayClient.request<WorkdayRecord>({+ auth,+ method: HttpMethod.POST,+ path,+ body,+ query: { updateIfExists: 'true' },+ });+}++async function getBusinessObject({+ auth,+ businessObject,+ objectId,+}: {+ auth: WorkdayAuthValue;+ businessObject: WorkdayBusinessObject;+ objectId: string;+}): Promise<WorkdayRecord> {+ return await workdayClient.request<WorkdayRecord>({+ auth,+ method: HttpMethod.GET,+ path: `${businessObject.path}/${objectId}`,+ service: businessObject.service,+ });+}++async function searchBusinessObjects({+ auth,+ businessObject,+ query,+}: {+ auth: WorkdayAuthValue;+ businessObject: WorkdayBusinessObject;+ query: QueryParams;+}): Promise<WorkdayRecord[]> {+ return await workdayClient.paginate<WorkdayRecord>({+ auth,+ path: businessObject.path,+ query,+ service: businessObject.service,+ });+}++async function listBusinessObjects({+ auth,+ businessObject,+ query,+}: {+ auth: WorkdayAuthValue;+ businessObject: WorkdayBusinessObject;+ query: QueryParams;+}): Promise<WorkdayRecord[]> {+ const page = await workdayClient.request<WorkdayPage<WorkdayRecord>>({+ auth,+ method: HttpMethod.GET,+ path: businessObject.path,+ query,+ service: businessObject.service,+ });+ return page.data ?? [];+}++async function updateBusinessObject({+ auth,+ businessObject,+ objectId,+ body,+}: {+ auth: WorkdayAuthValue;+ businessObject: WorkdayBusinessObject;+ objectId: string;+ body: unknown;+}): Promise<WorkdayRecord> {+ return await workdayClient.request<WorkdayRecord>({+ auth,+ method: HttpMethod.PUT,+ path: `${businessObject.path}/${objectId}`,+ body,+ service: businessObject.service,+ });+}++async function callRestOperation({+ auth,+ method,+ path,+ body,+ service,+}: {+ auth: WorkdayAuthValue;+ method: HttpMethod;+ path: string;+ body?: WorkdayRecord;+ service: string;+}): Promise<WorkdayRecord> {+ return await workdayClient.request<WorkdayRecord>({ auth, method, path, body, service });+}++async function callSoapOperation({+ auth,+ service,+ operationXml,+}: {+ auth: WorkdayAuthValue;+ service: string;+ operationXml: string;+}): Promise<WorkdayRecord> {+ return await workdayClient.soap({ auth, service, operationXml });+}++async function runWql({+ auth,+ query,+}: {+ auth: WorkdayAuthValue;+ query: string;+}): Promise<WorkdayPage<WorkdayRecord>> {+ return await workdayClient.wql<WorkdayPage<WorkdayRecord>>({ auth, query });+}++async function runWqlAll({+ auth,+ query,+}: {+ auth: WorkdayAuthValue;+ query: string;+}): Promise<WorkdayRecord[]> {+ return await workdayClient.wqlAll<WorkdayRecord>({ auth, query });+}++async function findSupplier({+ auth,+ supplierId,+}: {+ auth: WorkdayAuthValue;+ supplierId: string;+}): Promise<WorkdayPage<WorkdayRecord>> {+ return await runWql({+ auth,+ query: `SELECT supplier, supplierName FROM suppliers WHERE supplier = '${escapeWql({+ value: supplierId,+ })}'`,+ });+}++async function findPurchaseOrder({+ auth,+ purchaseOrderId,+}: {+ auth: WorkdayAuthValue;+ purchaseOrderId: string;+}): Promise<WorkdayPage<WorkdayRecord>> {+ return await runWql({+ auth,+ query: `SELECT purchaseOrder FROM purchaseOrders(dataSourceFilter = purchaseOrdersFilter) WHERE purchaseOrder = '${escapeWql(+ {+ value: purchaseOrderId,+ },+ )}'`,+ });+}++async function findSupplierPayments({+ auth,+ supplierId,+ paymentId,+}: {+ auth: WorkdayAuthValue;+ supplierId?: string;+ paymentId?: string;+}): Promise<WorkdayPage<WorkdayRecord>> {+ const conditions: string[] = [];+ if (supplierId) conditions.push(`supplier = '${escapeWql({ value: supplierId })}'`);+ if (paymentId) conditions.push(`supplierPayment = '${escapeWql({ value: paymentId })}'`);++ const companies = await runWqlAll({ auth, query: 'SELECT company FROM companies' });+ const companyIds = companies+ .map((row) => workdayUtils.readNestedId({ value: row['company'] }))+ .filter((id): id is string => typeof id === 'string' && WID_PATTERN.test(id));+ if (companyIds.length === 0) {+ return { total: 0, data: [] };+ }++ const whereClause = conditions.length > 0 ? ` WHERE ${conditions.join(' AND ')}` : '';+ return await runWql({+ auth,+ query: `SELECT supplierPayment FROM supplierPayments(dataSourceFilter = supplierPaymentsFilter, company = (${companyIds.join(+ ', ',+ )}))${whereClause}`,+ });+}++async function listInboxTasks({ auth }: { auth: WorkdayAuthValue }): Promise<WorkdayRecord[]> {+ const page = await runWql({+ auth,+ query: `SELECT businessProcess FROM businessProcessTransactionsAwaitingMyAction LIMIT 100`,+ });+ return page.data ?? [];+}++async function listTerminations({+ auth,+ sinceEpochMS,+}: {+ auth: WorkdayAuthValue;+ sinceEpochMS: number;+}): Promise<WorkdayRecord[]> {+ const since = dayjs(sinceEpochMS).toISOString();+ const limit = sinceEpochMS === 0 ? ' LIMIT 10' : '';+ return await runWqlAll({+ auth,+ query: `SELECT worker, effectiveDate, primaryTerminationReason, dateAndTimeCompleted FROM terminations WHERE dateAndTimeCompleted > '${since}' ORDER BY dateAndTimeCompleted DESC${limit}`,+ });+}++async function listNewHires({+ auth,+ sinceEpochMS,+}: {+ auth: WorkdayAuthValue;+ sinceEpochMS: number;+}): Promise<WorkdayRecord[]> {+ const since = dayjs(sinceEpochMS).toISOString();+ const limit = sinceEpochMS === 0 ? ' LIMIT 10' : '';+ return await runWqlAll({+ auth,+ query: `SELECT worker, hireDate, createdMoment FROM allWorkers WHERE createdMoment > '${since}' ORDER BY createdMoment DESC${limit}`,+ });+}++async function listBusinessProcessTransactions({+ auth,+ momentField,+ sinceEpochMS,+ typeIds,+ completedOnly,+}: {+ auth: WorkdayAuthValue;+ momentField: 'dateAndTimeInitiated' | 'dateAndTimeCompleted';+ sinceEpochMS: number;+ typeIds?: string[];+ completedOnly?: boolean;+}): Promise<WorkdayRecord[]> {+ const conditions = [`${momentField} > '${new Date(sinceEpochMS).toISOString()}'`];+ if (typeIds && typeIds.length > 0) {+ conditions.push(+ `businessProcessType in (${typeIds.map((id) => `'${escapeWql({ value: id })}'`).join(', ')})`,+ );+ }+ if (completedOnly) {+ conditions.push(`status = 'Successfully Completed'`);+ }+ const limit = sinceEpochMS === 0 ? ' LIMIT 10' : '';+ return await runWqlAll({+ auth,+ query: `SELECT businessProcessEvent, businessProcessType, status, worker, subject, dateAndTimeInitiated, dateAndTimeCompleted FROM businessProcessTransactions WHERE ${conditions.join(+ ' AND ',+ )} ORDER BY ${momentField} DESC${limit}`,+ });+}++async function getReport({+ auth,+ report,+ parameters,+ format = 'json',+}: {+ auth: WorkdayAuthValue;+ report: string;+ parameters?: WorkdayRecord;+ format?: 'json' | 'csv';+}): Promise<WorkdayReport> {+ const { owner, name, urlParameters } = parseReportReference({ auth, report });+ const reportPath = `${owner}/${name}`;+ const body = await workdayClient.report({+ auth,+ owner,+ name,+ query: { ...urlParameters, ...toPromptValues({ parameters }), format },+ });+ if (format === 'csv') {+ return { reportPath, format, csv: typeof body === 'string' ? body : '' };+ }+ return { reportPath, format, rows: readReportEntries({ body }) };+}++async function getSupplierInvoice({+ auth,+ invoiceId,+}: {+ auth: WorkdayAuthValue;+ invoiceId: string;+}): Promise<WorkdayRecord | undefined> {+ const idType = WID_PATTERN.test(invoiceId) ? 'WID' : 'Supplier_Invoice_Reference_ID';+ const operationXml = `+ <bsvc:Get_Supplier_Invoices_Request xmlns:bsvc="urn:com.workday/bsvc">+ <bsvc:Request_References>+ <bsvc:Supplier_Invoice_Reference>+ <bsvc:ID bsvc:type="${idType}">${workdayUtils.escapeXml({ value: invoiceId })}</bsvc:ID>+ </bsvc:Supplier_Invoice_Reference>+ </bsvc:Request_References>+ </bsvc:Get_Supplier_Invoices_Request>`;++ const body = await workdayClient.soap<WorkdaySupplierInvoicesBody>({+ auth,+ service: 'Resource_Management',+ operationXml,+ });+ const invoice = body.Get_Supplier_Invoices_Response?.Response_Data?.Supplier_Invoice;+ return Array.isArray(invoice) ? invoice[0] : invoice;+}++async function approveTask({+ auth,+ taskId,+ comment,+}: {+ auth: WorkdayAuthValue;+ taskId: string;+ comment?: string;+}): Promise<WorkdayRecord> {+ let commentXml = '';+ if (comment) {+ commentXml = `+ <bsvc:Approve_Business_Process_Data>+ <bsvc:Comment>${workdayUtils.escapeXml({ value: comment })}</bsvc:Comment>+ </bsvc:Approve_Business_Process_Data>`;+ }++ const operationXml = `+ <bsvc:Approve_Business_Process_Request xmlns:bsvc="urn:com.workday/bsvc">+ <bsvc:Event_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({ value: taskId })}</bsvc:ID>+ </bsvc:Event_Reference>${commentXml}+ </bsvc:Approve_Business_Process_Request>`;++ return await workdayClient.soap({ auth, service: 'Integrations', operationXml });+}++async function changeJob({+ auth,+ workerId,+ effectiveDate,+ reasonId,+ jobProfileId,+ supervisoryOrganizationId,+ positionId,+}: {+ auth: WorkdayAuthValue;+ workerId: string;+ effectiveDate: string;+ reasonId: string;+ jobProfileId?: string;+ supervisoryOrganizationId?: string;+ positionId?: string;+}): Promise<WorkdayRecord> {+ let supervisoryOrgXml = '';+ if (supervisoryOrganizationId) {+ supervisoryOrgXml = `+ <bsvc:Supervisory_Organization_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({+ value: supervisoryOrganizationId,+ })}</bsvc:ID>+ </bsvc:Supervisory_Organization_Reference>`;+ }++ let jobDetailsXml = '';+ if (jobProfileId) {+ jobDetailsXml = `+ <bsvc:Job_Details_Data>+ <bsvc:Job_Profile_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({ value: jobProfileId })}</bsvc:ID>+ </bsvc:Job_Profile_Reference>+ </bsvc:Job_Details_Data>`;+ }++ let positionXml = '';+ if (positionId) {+ positionXml = `+ <bsvc:Position_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({ value: positionId })}</bsvc:ID>+ </bsvc:Position_Reference>`;+ }++ const operationXml = `+ <bsvc:Change_Job_Request xmlns:bsvc="urn:com.workday/bsvc">+ <bsvc:Business_Process_Parameters>+ <bsvc:Auto_Complete>true</bsvc:Auto_Complete>+ <bsvc:Run_Now>true</bsvc:Run_Now>+ </bsvc:Business_Process_Parameters>+ <bsvc:Change_Job_Data>+ <bsvc:Worker_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({ value: workerId })}</bsvc:ID>+ </bsvc:Worker_Reference>${positionXml}+ <bsvc:Effective_Date>${workdayUtils.escapeXml({+ value: effectiveDate,+ })}</bsvc:Effective_Date>+ <bsvc:Change_Job_Detail_Data>+ <bsvc:Reason_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({ value: reasonId })}</bsvc:ID>+ </bsvc:Reason_Reference>${supervisoryOrgXml}${jobDetailsXml}+ </bsvc:Change_Job_Detail_Data>+ </bsvc:Change_Job_Data>+ </bsvc:Change_Job_Request>`;++ return await workdayClient.soap({ auth, service: 'Staffing', operationXml });+}++async function createJobRequisition({+ auth,+ supervisoryOrganizationId,+ reasonId,+ jobPostingTitle,+ numberOfOpenings,+ jobProfileId,+ workerTypeId,+ workerSubTypeId,+ primaryLocationId,+ recruitingStartDate,+ targetHireDate,+}: {+ auth: WorkdayAuthValue;+ supervisoryOrganizationId: string;+ reasonId: string;+ jobPostingTitle: string;+ numberOfOpenings?: number;+ jobProfileId?: string;+ workerTypeId?: string;+ workerSubTypeId?: string;+ primaryLocationId?: string;+ recruitingStartDate: string;+ targetHireDate: string;+}): Promise<WorkdayRecord> {+ const openings = numberOfOpenings ?? 1;++ const recruitingStartDateXml = `+ <bsvc:Recruiting_Start_Date>${workdayUtils.escapeXml({+ value: recruitingStartDate,+ })}</bsvc:Recruiting_Start_Date>`;++ const targetHireDateXml = `+ <bsvc:Target_Hire_Date>${workdayUtils.escapeXml({+ value: targetHireDate,+ })}</bsvc:Target_Hire_Date>`;++ const jobProfileXml = jobProfileId+ ? `+ <bsvc:Job_Profile_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({ value: jobProfileId })}</bsvc:ID>+ </bsvc:Job_Profile_Reference>`+ : '';++ const primaryLocationXml = primaryLocationId+ ? `+ <bsvc:Primary_Location_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({+ value: primaryLocationId,+ })}</bsvc:ID>+ </bsvc:Primary_Location_Reference>+ <bsvc:Primary_Job_Posting_Location_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({+ value: primaryLocationId,+ })}</bsvc:ID>+ </bsvc:Primary_Job_Posting_Location_Reference>`+ : '';++ const workerTypeXml = workerTypeId+ ? `+ <bsvc:Worker_Type_Reference>+ <bsvc:ID bsvc:type="Worker_Type_ID">${workdayUtils.escapeXml({+ value: workerTypeId,+ })}</bsvc:ID>+ </bsvc:Worker_Type_Reference>`+ : '';++ const workerSubTypeXml = workerSubTypeId+ ? `+ <bsvc:Worker_Sub-Type_Reference>+ <bsvc:ID bsvc:type="Employee_Type_ID">${workdayUtils.escapeXml({+ value: workerSubTypeId,+ })}</bsvc:ID>+ </bsvc:Worker_Sub-Type_Reference>`+ : '';++ const reasonIdKind = WID_PATTERN.test(reasonId) ? 'WID' : 'General_Event_Subcategory_ID';++ const operationXml = `+ <bsvc:Create_Requisition_Request xmlns:bsvc="urn:com.workday/bsvc">+ <bsvc:Business_Process_Parameters>+ <bsvc:Auto_Complete>true</bsvc:Auto_Complete>+ <bsvc:Run_Now>true</bsvc:Run_Now>+ </bsvc:Business_Process_Parameters>+ <bsvc:Create_Job_Requisition_Data>+ <bsvc:Supervisory_Organization_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({+ value: supervisoryOrganizationId,+ })}</bsvc:ID>+ </bsvc:Supervisory_Organization_Reference>+ <bsvc:Create_Job_Requisition_Reason_Reference>+ <bsvc:ID bsvc:type="${reasonIdKind}">${workdayUtils.escapeXml({+ value: reasonId,+ })}</bsvc:ID>+ </bsvc:Create_Job_Requisition_Reason_Reference>+ <bsvc:Number_of_Openings>${openings}</bsvc:Number_of_Openings>+ <bsvc:Job_Requisition_Data>+ <bsvc:Job_Posting_Title>${workdayUtils.escapeXml({+ value: jobPostingTitle,+ })}</bsvc:Job_Posting_Title>${recruitingStartDateXml}${targetHireDateXml}${jobProfileXml}${workerTypeXml}${workerSubTypeXml}${primaryLocationXml}+ </bsvc:Job_Requisition_Data>+ </bsvc:Create_Job_Requisition_Data>+ </bsvc:Create_Requisition_Request>`;++ return await workdayClient.soap({ auth, service: 'Recruiting', operationXml });+}++async function createPreHire({+ auth,+ firstName,+ lastName,+ email,+ phone,+ country,+}: {+ auth: WorkdayAuthValue;+ firstName: string;+ lastName: string;+ email: string;+ phone?: string;+ country: string;+}): Promise<WorkdayRecord> {+ let phoneXml = '';+ if (phone) {+ phoneXml = `+ <bsvc:Phone_Data>+ <bsvc:Country_ISO_Code>${workdayUtils.escapeXml({+ value: country,+ })}</bsvc:Country_ISO_Code>+ <bsvc:Phone_Number>${workdayUtils.escapeXml({ value: phone })}</bsvc:Phone_Number>+ <bsvc:Phone_Device_Type_Reference>+ <bsvc:ID bsvc:type="Phone_Device_Type_ID">Mobile</bsvc:ID>+ </bsvc:Phone_Device_Type_Reference>+ <bsvc:Usage_Data bsvc:Public="true">+ <bsvc:Type_Data bsvc:Primary="true">+ <bsvc:Type_Reference>+ <bsvc:ID bsvc:type="Communication_Usage_Type_ID">WORK</bsvc:ID>+ </bsvc:Type_Reference>+ </bsvc:Type_Data>+ </bsvc:Usage_Data>+ </bsvc:Phone_Data>`;+ }++ const operationXml = `+ <bsvc:Put_Applicant_Request xmlns:bsvc="urn:com.workday/bsvc">+ <bsvc:Applicant_Data>+ <bsvc:Personal_Data>+ <bsvc:Name_Data>+ <bsvc:Legal_Name_Data>+ <bsvc:Name_Detail_Data>+ <bsvc:Country_Reference>+ <bsvc:ID bsvc:type="ISO_3166-1_Alpha-3_Code">${workdayUtils.escapeXml({+ value: country,+ })}</bsvc:ID>+ </bsvc:Country_Reference>+ <bsvc:First_Name>${workdayUtils.escapeXml({ value: firstName })}</bsvc:First_Name>+ <bsvc:Last_Name>${workdayUtils.escapeXml({ value: lastName })}</bsvc:Last_Name>+ </bsvc:Name_Detail_Data>+ </bsvc:Legal_Name_Data>+ </bsvc:Name_Data>+ <bsvc:Contact_Data>+ <bsvc:Email_Address_Data>+ <bsvc:Email_Address>${workdayUtils.escapeXml({ value: email })}</bsvc:Email_Address>+ <bsvc:Usage_Data bsvc:Public="true">+ <bsvc:Type_Data bsvc:Primary="true">+ <bsvc:Type_Reference>+ <bsvc:ID bsvc:type="Communication_Usage_Type_ID">WORK</bsvc:ID>+ </bsvc:Type_Reference>+ </bsvc:Type_Data>+ </bsvc:Usage_Data>+ </bsvc:Email_Address_Data>${phoneXml}+ </bsvc:Contact_Data>+ </bsvc:Personal_Data>+ </bsvc:Applicant_Data>+ </bsvc:Put_Applicant_Request>`;++ return await workdayClient.soap({ auth, service: 'Staffing', operationXml });+}++async function createSupplierCreditMemo({+ auth,+ supplierId,+ memoDate,+ amount,+ description,+}: {+ auth: WorkdayAuthValue;+ supplierId: string;+ memoDate: string;+ amount: string;+ description?: string;+}): Promise<WorkdayRecord> {+ let memoXml = '';+ if (description) {+ memoXml = `+ <bsvc:Document_Memo>${workdayUtils.escapeXml({ value: description })}</bsvc:Document_Memo>`;+ }++ const operationXml = `+ <bsvc:Submit_Supplier_Invoice_Adjustment_Request xmlns:bsvc="urn:com.workday/bsvc">+ <bsvc:Business_Process_Parameters>+ <bsvc:Auto_Complete>true</bsvc:Auto_Complete>+ </bsvc:Business_Process_Parameters>+ <bsvc:Supplier_Invoice_Adjustment_Data>+ <bsvc:Submit>true</bsvc:Submit>+ <bsvc:Supplier_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({ value: supplierId })}</bsvc:ID>+ </bsvc:Supplier_Reference>+ <bsvc:Adjustment_Date>${workdayUtils.escapeXml({ value: memoDate })}</bsvc:Adjustment_Date>+ <bsvc:Control_Total_Amount>${workdayUtils.escapeXml({+ value: amount,+ })}</bsvc:Control_Total_Amount>${memoXml}+ </bsvc:Supplier_Invoice_Adjustment_Data>+ </bsvc:Submit_Supplier_Invoice_Adjustment_Request>`;++ return await workdayClient.soap({ auth, service: 'Resource_Management', operationXml });+}++async function createTimeOffRequest({+ auth,+ workerId,+ timeOffTypeId,+ startDate,+ endDate,+ comment,+ hoursPerDay,+}: {+ auth: WorkdayAuthValue;+ workerId: string;+ timeOffTypeId: string;+ startDate: string;+ endDate: string;+ comment?: string;+ hoursPerDay?: number;+}): Promise<WorkdayRecord> {+ const typeIdKind = WID_PATTERN.test(timeOffTypeId) ? 'WID' : 'Time_Off_Type_ID';+ const requested = hoursPerDay ?? 8;+ const start = parseIsoDate({ value: startDate, label: 'Start Date' });+ const end = parseIsoDate({ value: endDate, label: 'End Date' });+ if (end < start) {+ throw new Error('End Date must be on or after Start Date.');+ }+ let entriesXml = '';+ const current = new Date(start);+ while (current <= end) {+ const isWeekend = current.getUTCDay() === 0 || current.getUTCDay() === 6;+ if (!isWeekend) {+ const dateStr = current.toISOString().split('T')[0];+ entriesXml += `+ <bsvc:Enter_Time_Off_Entry_Data>+ <bsvc:Date>${dateStr}</bsvc:Date>+ <bsvc:Requested>${requested}</bsvc:Requested>+ <bsvc:Time_Off_Type_Reference>+ <bsvc:ID bsvc:type="${typeIdKind}">${workdayUtils.escapeXml({+ value: timeOffTypeId,+ })}</bsvc:ID>+ </bsvc:Time_Off_Type_Reference>${+ comment+ ? `\n <bsvc:Comment>${workdayUtils.escapeXml({+ value: comment,+ })}</bsvc:Comment>`+ : ''+ }+ </bsvc:Enter_Time_Off_Entry_Data>`;+ }+ current.setUTCDate(current.getUTCDate() + 1);+ }+ if (entriesXml === '') {+ throw new Error('The date range has no weekdays to request time off for.');+ }++ const operationXml = `+ <bsvc:Enter_Time_Off_Request xmlns:bsvc="urn:com.workday/bsvc">+ <bsvc:Business_Process_Parameters>+ <bsvc:Auto_Complete>true</bsvc:Auto_Complete>+ <bsvc:Run_Now>true</bsvc:Run_Now>+ </bsvc:Business_Process_Parameters>+ <bsvc:Enter_Time_Off_Data>+ <bsvc:Worker_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({ value: workerId })}</bsvc:ID>+ </bsvc:Worker_Reference>${entriesXml}+ </bsvc:Enter_Time_Off_Data>+ </bsvc:Enter_Time_Off_Request>`;++ return await workdayClient.soap({ auth, service: 'Absence_Management', operationXml });+}++async function createWorkerTimeBlock({+ auth,+ workerId,+ date,+ hours,+ timeTypeId,+ comment,+}: {+ auth: WorkdayAuthValue;+ workerId: string;+ date: string;+ hours: number;+ timeTypeId?: string;+ comment?: string;+}): Promise<WorkdayRecord> {+ let timeEntryCodeXml = '';+ if (timeTypeId) {+ timeEntryCodeXml = `+ <bsvc:Time_Entry_Code_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({ value: timeTypeId })}</bsvc:ID>+ </bsvc:Time_Entry_Code_Reference>`;+ }++ let commentXml = '';+ if (comment) {+ commentXml = `+ <bsvc:Comment>${workdayUtils.escapeXml({ value: comment })}</bsvc:Comment>`;+ }++ const operationXml = `+ <bsvc:Put_Reported_Time_Blocks_for_Worker_Request xmlns:bsvc="urn:com.workday/bsvc">+ <bsvc:Reported_Time_Block_Data>+ <bsvc:Worker_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({ value: workerId })}</bsvc:ID>+ </bsvc:Worker_Reference>+ <bsvc:Date>${workdayUtils.escapeXml({ value: date })}</bsvc:Date>+ <bsvc:Quantity>${hours}</bsvc:Quantity>${timeEntryCodeXml}${commentXml}+ </bsvc:Reported_Time_Block_Data>+ </bsvc:Put_Reported_Time_Blocks_for_Worker_Request>`;++ return await workdayClient.soap({ auth, service: 'Time_Tracking', operationXml });+}++async function hireEmployee({+ auth,+ applicantId,+ hireDate,+ positionId,+ supervisoryOrganizationId,+ jobProfileId,+ hireReasonId,+ employeeTypeId,+}: {+ auth: WorkdayAuthValue;+ applicantId: string;+ hireDate: string;+ positionId?: string;+ supervisoryOrganizationId?: string;+ jobProfileId?: string;+ hireReasonId: string;+ employeeTypeId: string;+}): Promise<WorkdayRecord> {+ let positionXml = '';+ if (positionId) {+ positionXml = `+ <bsvc:Position_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({ value: positionId })}</bsvc:ID>+ </bsvc:Position_Reference>`;+ }++ const organizationXml = supervisoryOrganizationId+ ? `+ <bsvc:Organization_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({+ value: supervisoryOrganizationId,+ })}</bsvc:ID>+ </bsvc:Organization_Reference>`+ : '';++ const jobProfileXml = jobProfileId+ ? `+ <bsvc:Job_Profile_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({ value: jobProfileId })}</bsvc:ID>+ </bsvc:Job_Profile_Reference>`+ : '';++ const operationXml = `+ <bsvc:Hire_Employee_Request xmlns:bsvc="urn:com.workday/bsvc">+ <bsvc:Business_Process_Parameters>+ <bsvc:Auto_Complete>true</bsvc:Auto_Complete>+ <bsvc:Run_Now>true</bsvc:Run_Now>+ </bsvc:Business_Process_Parameters>+ <bsvc:Hire_Employee_Data>+ <bsvc:Applicant_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({ value: applicantId })}</bsvc:ID>+ </bsvc:Applicant_Reference>${organizationXml}${positionXml}+ <bsvc:Hire_Date>${workdayUtils.escapeXml({ value: hireDate })}</bsvc:Hire_Date>+ <bsvc:Hire_Employee_Event_Data>+ <bsvc:Hire_Reason_Reference>+ <bsvc:ID bsvc:type="General_Event_Subcategory_ID">${workdayUtils.escapeXml({+ value: hireReasonId,+ })}</bsvc:ID>+ </bsvc:Hire_Reason_Reference>+ <bsvc:Employee_Type_Reference>+ <bsvc:ID bsvc:type="Employee_Type_ID">${workdayUtils.escapeXml({+ value: employeeTypeId,+ })}</bsvc:ID>+ </bsvc:Employee_Type_Reference>+ <bsvc:First_Day_of_Work>${workdayUtils.escapeXml({+ value: hireDate,+ })}</bsvc:First_Day_of_Work>+ <bsvc:Position_Details>${jobProfileXml}+ </bsvc:Position_Details>+ </bsvc:Hire_Employee_Event_Data>+ </bsvc:Hire_Employee_Data>+ </bsvc:Hire_Employee_Request>`;++ return await workdayClient.soap({ auth, service: 'Staffing', operationXml });+}++async function updateSupplier({+ auth,+ supplierId,+ supplierName,+ taxId,+ taxIdType,+ paymentTermsId,+}: {+ auth: WorkdayAuthValue;+ supplierId: string;+ supplierName?: string;+ taxId?: string;+ taxIdType?: string;+ paymentTermsId?: string;+}): Promise<WorkdayRecord> {+ if (Boolean(taxId) !== Boolean(taxIdType)) {+ throw new Error('Tax ID and Tax ID Type must be set together, e.g. Tax ID Type `USA-EIN`.');+ }+ let supplierDataFields = '';+ if (supplierName) {+ supplierDataFields += `+ <bsvc:Supplier_Name>${workdayUtils.escapeXml({+ value: supplierName,+ })}</bsvc:Supplier_Name>`;+ }+ if (taxId && taxIdType) {+ supplierDataFields += `+ <bsvc:Tax_ID_Widget_Data bsvc:Replace_All="false">+ <bsvc:Tax_ID_Data>+ <bsvc:Tax_ID_Text>${workdayUtils.escapeXml({ value: taxId })}</bsvc:Tax_ID_Text>+ <bsvc:Tax_ID_Type_Reference>+ <bsvc:ID bsvc:type="Tax_ID_Type">${workdayUtils.escapeXml({+ value: taxIdType,+ })}</bsvc:ID>+ </bsvc:Tax_ID_Type_Reference>+ </bsvc:Tax_ID_Data>+ </bsvc:Tax_ID_Widget_Data>`;+ }+ if (paymentTermsId) {+ supplierDataFields += `+ <bsvc:Payment_Terms_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({ value: paymentTermsId })}</bsvc:ID>+ </bsvc:Payment_Terms_Reference>`;+ }++ const operationXml = `+ <bsvc:Submit_Supplier_Request xmlns:bsvc="urn:com.workday/bsvc">+ <bsvc:Supplier_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({ value: supplierId })}</bsvc:ID>+ </bsvc:Supplier_Reference>+ <bsvc:Supplier_Data>${supplierDataFields}+ </bsvc:Supplier_Data>+ </bsvc:Submit_Supplier_Request>`;++ return await workdayClient.soap({ auth, service: 'Resource_Management', operationXml });+}++async function updateSupplierInvoice({+ auth,+ invoiceId,+ invoiceDate,+ invoiceNumber,+ total,+}: {+ auth: WorkdayAuthValue;+ invoiceId: string;+ invoiceDate?: string;+ invoiceNumber?: string;+ total?: string;+}): Promise<WorkdayRecord> {+ let invoiceDataFields = '';+ if (invoiceNumber) {+ invoiceDataFields += `+ <bsvc:Invoice_Number>${workdayUtils.escapeXml({+ value: invoiceNumber,+ })}</bsvc:Invoice_Number>`;+ }+ if (invoiceDate) {+ invoiceDataFields += `+ <bsvc:Invoice_Date>${workdayUtils.escapeXml({ value: invoiceDate })}</bsvc:Invoice_Date>`;+ }+ if (total) {+ invoiceDataFields += `+ <bsvc:Control_Amount_Total>${workdayUtils.escapeXml({+ value: total,+ })}</bsvc:Control_Amount_Total>`;+ }++ const operationXml = `+ <bsvc:Submit_Supplier_Invoice_Request xmlns:bsvc="urn:com.workday/bsvc">+ <bsvc:Supplier_Invoice_Reference>+ <bsvc:ID bsvc:type="WID">${workdayUtils.escapeXml({ value: invoiceId })}</bsvc:ID>+ </bsvc:Supplier_Invoice_Reference>+ <bsvc:Supplier_Invoice_Data>${invoiceDataFields}+ </bsvc:Supplier_Invoice_Data>+ </bsvc:Submit_Supplier_Invoice_Request>`;++ return await workdayClient.soap({ auth, service: 'Resource_Management', operationXml });+}++function parseIsoDate({ value, label }: { value: string; label: string }): Date {+ const trimmed = value.trim();+ const date = new Date(`${trimmed}T00:00:00.000Z`);+ if (+ !/^\d{4}-\d{2}-\d{2}$/.test(trimmed) ||+ Number.isNaN(date.getTime()) ||+ date.toISOString().slice(0, 10) !== trimmed+ ) {+ throw new Error(`${label} must be a date in YYYY-MM-DD format, e.g. 2026-11-03.`);+ }+ return date;+}++function escapeWql({ value }: { value: string }): string {+ return value.replace(/\\/g, '\\\\').replace(/'/g, "\\'");+}++function parseReportReference({ auth, report }: { auth: WorkdayAuthValue; report: string }): {+ owner: string;+ name: string;+ urlParameters: Record<string, string>;+} {+ const value = report.trim();+ if (!/^https?:\/\//i.test(value)) {+ const parts = value.split('/');+ if (parts.length !== 2 || !parts[0] || !parts[1]) {+ throw new Error(+ 'Enter the report as `owner/report_name` (e.g. `lmcneil/PT_Workers`) or paste its RaaS URL.',+ );+ }+ return { owner: parts[0], name: parts[1], urlParameters: {} };+ }+ const url = new URL(value);+ const host = workdayClient.apiHost({ auth });+ if (url.hostname.toLowerCase() !== host.toLowerCase()) {+ throw new Error(+ `The report URL host "${url.hostname}" does not match the connection's API host "${host}".`,+ );+ }+ const match = /^\/ccx\/service\/customreport2\/([^/]+)\/([^/]+)\/([^/]+)\/?$/.exec(url.pathname);+ if (!match) {+ throw new Error(+ 'The URL is not a Workday RaaS URL (expected /ccx/service/customreport2/{tenant}/{owner}/{report}).',+ );+ }+ const tenant = workdayClient.tenant({ auth });+ if (decodeURIComponent(match[1]) !== tenant) {+ throw new Error(+ `The report URL tenant "${decodeURIComponent(+ match[1],+ )}" does not match the connection's tenant "${tenant}".`,+ );+ }+ const urlParameters = Object.fromEntries(+ [...url.searchParams.entries()].filter(([key]) => key !== 'format'),+ );+ return {+ owner: decodeURIComponent(match[2]),+ name: decodeURIComponent(match[3]),+ urlParameters,+ };+}++function toPromptValues({+ parameters,+}: {+ parameters: WorkdayRecord | undefined;+}): Record<string, string> {+ if (!parameters) {+ return {};+ }+ return Object.fromEntries(+ Object.entries(parameters)+ .filter(([, value]) => value !== undefined && value !== null)+ .map(([key, value]) => [+ key,+ Array.isArray(value) ? value.map(String).join('!') : String(value),+ ]),+ );+}++function readReportEntries({ body }: { body: unknown }): WorkdayRecord[] {+ if (typeof body !== 'object' || body === null || !('Report_Entry' in body)) {+ return [];+ }+ const entries = body.Report_Entry;+ const list = Array.isArray(entries) ? entries : [entries];+ return list.filter(+ (entry): entry is WorkdayRecord => typeof entry === 'object' && entry !== null,+ );+}++export const workdayApi = {+ getServerTimestamp,+ listCustomObjectDefinitions,+ getCustomObject,+ upsertCustomObject,+ getBusinessObject,+ searchBusinessObjects,+ listBusinessObjects,+ updateBusinessObject,+ callRestOperation,+ callSoapOperation,+ runWql,+ runWqlAll,+ findSupplier,+ findPurchaseOrder,+ findSupplierPayments,+ listInboxTasks,+ listTerminations,+ listNewHires,+ listBusinessProcessTransactions,+ getReport,+ getSupplierInvoice,+ approveTask,+ changeJob,+ createJobRequisition,+ createPreHire,+ createSupplierCreditMemo,+ createTimeOffRequest,+ createWorkerTimeBlock,+ hireEmployee,+ updateSupplier,+ updateSupplierInvoice,+};++const WID_PATTERN = /^[0-9a-f]{32}$/i;diff --git a/packages/pieces/community/workday/src/lib/common/client.ts b/packages/pieces/community/workday/src/lib/common/client.tsnew file mode 100644index 00000000000..ede9178761d--- /dev/null+++ b/packages/pieces/community/workday/src/lib/common/client.ts@@ -0,0 +1,318 @@+import { XMLParser } from 'fast-xml-parser';++import {+ AuthenticationType,+ HttpMethod,+ HttpRequest,+ QueryParams,+ httpClient,+} from '@activepieces/pieces-common';+import { AppConnectionType } from '@activepieces/pieces-framework';++import { workdayUtils } from './utils';++import type { WorkdayAuthValue, WorkdayPage, WorkdayRecord, WorkdaySoapEnvelope } from './types';++function apiHost({ auth }: { auth: WorkdayAuthValue }): string {+ return readConnectionProp({ auth, key: 'apiHost' }) ?? '';+}++function tenant({ auth }: { auth: WorkdayAuthValue }): string {+ return readConnectionProp({ auth, key: 'tenant' }) ?? '';+}++function baseUrl({ auth, service = 'v1' }: { auth: WorkdayAuthValue; service?: string }): string {+ return `https://${apiHost({ auth })}/ccx/api/${service}/${tenant({ auth })}`;+}++function bearerToken({ auth }: { auth: WorkdayAuthValue }): string {+ if (auth.type === AppConnectionType.CUSTOM_AUTH) {+ throw new Error(+ "This action uses Workday's REST API, which needs the OAuth 2.0 connection. Select a Workday OAuth 2.0 connection for this step.",+ );+ }+ return auth.access_token;+}++async function request<T>({+ auth,+ method,+ path,+ query,+ body,+ service,+}: RequestParams & { auth: WorkdayAuthValue }): Promise<T> {+ const response = await httpClient.sendRequest<T>({+ method,+ url: `${baseUrl({ auth, service })}${path}`,+ body,+ queryParams: query,+ authentication: {+ type: AuthenticationType.BEARER_TOKEN,+ token: bearerToken({ auth }),+ },+ });+ return response.body;+}++async function paginate<T>({+ auth,+ path,+ query,+ service,+}: PaginateParams & { auth: WorkdayAuthValue }): Promise<T[]> {+ const allItems: T[] = [];+ let offset = 0;+ let hasMore = true;++ while (hasMore) {+ const page = await request<WorkdayPage<T>>({+ auth,+ method: HttpMethod.GET,+ path,+ query: { ...query, limit: String(REST_PAGE_SIZE), offset: String(offset) },+ service,+ });++ const items = page.data ?? [];+ allItems.push(...items);+ offset += REST_PAGE_SIZE;++ if (items.length < REST_PAGE_SIZE) {+ hasMore = false;+ } else {+ hasMore = typeof page.total !== 'number' || offset < page.total;+ }+ }++ return allItems;+}++async function wql<T>({+ auth,+ query,+ limit,+ offset,+}: WqlParams & { auth: WorkdayAuthValue }): Promise<T> {+ const token = bearerToken({ auth });+ const queryParams: QueryParams = {};+ if (limit !== undefined) queryParams['limit'] = String(limit);+ if (offset !== undefined) queryParams['offset'] = String(offset);+ const response = await httpClient.sendRequest<T>({+ method: HttpMethod.POST,+ url: `https://${apiHost({ auth })}/ccx/api/wql/v1/${tenant({ auth })}/data`,+ body: { query },+ queryParams,+ authentication: {+ type: AuthenticationType.BEARER_TOKEN,+ token,+ },+ });+ return response.body;+}++async function wqlAll<T>({ auth, query }: { auth: WorkdayAuthValue; query: string }): Promise<T[]> {+ const allRows: T[] = [];+ let offset = 0;++ while (true) {+ const page = await wql<WorkdayPage<T>>({ auth, query, limit: WQL_PAGE_SIZE, offset });+ const rows = page.data ?? [];+ allRows.push(...rows);++ if (rows.length < WQL_PAGE_SIZE) {+ break;+ }+ offset += WQL_PAGE_SIZE;+ if (typeof page.total === 'number' && offset >= page.total) {+ break;+ }+ }++ return allRows;+}++async function soap<T extends WorkdayRecord = WorkdayRecord>({+ auth,+ service,+ operationXml,+}: SoapParams & { auth: WorkdayAuthValue }): Promise<T> {+ const { username, password } = isuCredentials({ auth });+ const envelope = buildSoapEnvelope({+ username: username.includes('@') ? username : `${username}@${tenant({ auth })}`,+ password,+ operationXml,+ });++ const response = await httpClient.sendRequest({+ method: HttpMethod.POST,+ url: `https://${apiHost({ auth })}/ccx/service/${tenant({ auth })}/${service}/${wwsVersion({+ auth,+ })}`,+ headers: {+ 'Content-Type': 'text/xml;charset=UTF-8',+ },+ body: envelope,+ });++ const parser = new XMLParser({+ ignoreAttributes: false,+ removeNSPrefix: true,+ parseAttributeValue: true,+ });++ const parsed: WorkdaySoapEnvelope<T> = parser.parse(+ typeof response.body === 'string' ? response.body : JSON.stringify(response.body),+ );+ const soapBody = parsed.Envelope?.Body;++ if (soapBody?.Fault) {+ const faultString = soapBody.Fault.faultstring ?? soapBody.Fault.Reason ?? 'Unknown SOAP fault';+ throw new Error(`Workday SOAP Error: ${JSON.stringify(faultString)}`);+ }+ if (!soapBody) {+ throw new Error('Workday returned a response without a SOAP body.');+ }++ return soapBody;+}++async function report({+ auth,+ owner,+ name,+ query,+}: ReportParams & { auth: WorkdayAuthValue }): Promise<unknown> {+ const response = await httpClient.sendRequest<unknown>({+ method: HttpMethod.GET,+ url: `https://${apiHost({ auth })}/ccx/service/customreport2/${encodeURIComponent(+ tenant({ auth }),+ )}/${encodeURIComponent(owner)}/${encodeURIComponent(name)}`,+ queryParams: query,+ authentication: reportAuthentication({ auth }),+ });+ return response.body;+}++function readConnectionProp({+ auth,+ key,+}: {+ auth: WorkdayAuthValue;+ key: 'apiHost' | 'tenant' | 'wwsVersion' | 'isuUsername' | 'isuPassword';+}): string | undefined {+ const props: Record<string, unknown> | undefined = auth.props;+ const value = props?.[key];+ return typeof value === 'string' ? value : undefined;+}++function wwsVersion({ auth }: { auth: WorkdayAuthValue }): string {+ const version = readConnectionProp({ auth, key: 'wwsVersion' })?.trim() || DEFAULT_WWS_VERSION;+ if (!/^v\d+(\.\d+)?$/.test(version)) {+ throw new Error(`WWS Version "${version}" is not valid. Use a version like v47.0.`);+ }+ return version;+}++function isuCredentials({ auth }: { auth: WorkdayAuthValue }): {+ username: string;+ password: string;+} {+ if (auth.type === AppConnectionType.CUSTOM_AUTH) {+ return { username: auth.props.username.trim(), password: auth.props.password };+ }+ const username = readConnectionProp({ auth, key: 'isuUsername' })?.trim();+ const password = readConnectionProp({ auth, key: 'isuPassword' });+ if (!username || !password) {+ throw new Error(+ 'ISU Username and Password are required for write operations. Please update your Workday connection with Integration System User credentials.',+ );+ }+ return { username, password };+}++function reportAuthentication({ auth }: { auth: WorkdayAuthValue }): HttpRequest['authentication'] {+ if (auth.type === AppConnectionType.CUSTOM_AUTH) {+ return {+ type: AuthenticationType.BASIC,+ username: auth.props.username.trim().split('@')[0],+ password: auth.props.password,+ };+ }+ return { type: AuthenticationType.BEARER_TOKEN, token: auth.access_token };+}++function buildSoapEnvelope({+ username,+ password,+ operationXml,+}: {+ username: string;+ password: string;+ operationXml: string;+}): string {+ return `<?xml version="1.0" encoding="UTF-8"?>+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bsvc="urn:com.workday/bsvc">+ <soapenv:Header>+ <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">+ <wsse:UsernameToken>+ <wsse:Username>${workdayUtils.escapeXml({ value: username })}</wsse:Username>+ <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">${workdayUtils.escapeXml(+ { value: password },+ )}</wsse:Password>+ </wsse:UsernameToken>+ </wsse:Security>+ </soapenv:Header>+ <soapenv:Body>+ ${operationXml}+ </soapenv:Body>+</soapenv:Envelope>`;+}++export const workdayClient = {+ apiHost,+ tenant,+ baseUrl,+ bearerToken,+ request,+ paginate,+ wql,+ wqlAll,+ soap,+ report,+};++const DEFAULT_WWS_VERSION = 'v47.0';+const REST_PAGE_SIZE = 100;+const WQL_PAGE_SIZE = 1000;++type RequestParams = {+ method: HttpMethod;+ path: string;+ query?: QueryParams;+ body?: unknown;+ service?: string;+};++type PaginateParams = {+ path: string;+ query?: QueryParams;+ service?: string;+};++type WqlParams = {+ query: string;+ limit?: number;+ offset?: number;+};++type SoapParams = {+ service: string;+ operationXml: string;+};++type ReportParams = {+ owner: string;+ name: string;+ query: QueryParams;+};diff --git a/packages/pieces/community/workday/src/lib/common/fields.test.ts b/packages/pieces/community/workday/src/lib/common/fields.test.tsdeleted file mode 100644index 993e79915bf..00000000000--- a/packages/pieces/community/workday/src/lib/common/fields.test.ts+++ /dev/null@@ -1,108 +0,0 @@-import { describe, expect, it } from 'vitest';-import {- flattenRecord,- formatWorkdayOutput,- getRecordTimestamp,-} from './fields';--describe('flattenRecord', () => {- it('flattens nested objects with underscore-joined keys', () => {- expect(flattenRecord({ worker: { id: 1, descriptor: 'Jane' } })).toEqual({- worker_id: 1,- worker_descriptor: 'Jane',- });- });-- it('JSON-stringifies nested arrays under their key', () => {- expect(flattenRecord({ lines: [{ id: 1 }] })).toEqual({- lines: JSON.stringify([{ id: 1 }]),- });- });-- it('puts a top-level array under "items"', () => {- expect(flattenRecord([1, 2])).toEqual({ items: JSON.stringify([1, 2]) });- });-- it('preserves null leaf values', () => {- expect(flattenRecord({ status: null })).toEqual({ status: null });- });-});--describe('formatWorkdayOutput', () => {- it('maps recruiting fields, resolving nested descriptors/ids', () => {- const out = formatWorkdayOutput(- {- id: 'req-1',- title: 'Engineer',- location: { descriptor: 'San Francisco' },- candidate: { id: 'cand-9' },- applicationStatus: 'In Progress',- },- 'recruiting',- );- expect(out).toMatchObject({- job_requisition_id: 'req-1',- title: 'Engineer',- location: 'San Francisco',- candidate_id: 'cand-9',- application_status: 'In Progress',- });- });-- it('maps onboarding fields with worker fallback', () => {- const out = formatWorkdayOutput(- { worker: { id: 'w-1', descriptor: 'Jane Doe' }, hireDate: '2025-01-02', status: 'Active' },- 'onboarding',- );- expect(out).toMatchObject({- employee_id: 'w-1',- name: 'Jane Doe',- hire_date: '2025-01-02',- status: 'Active',- });- });-- it('maps HR case fields without setting time_entry_id', () => {- const out = formatWorkdayOutput(- { id: 'case-1', worker: { id: 'w-2' }, description: 'Payroll question', status: 'Open' },- 'hr_services_time_tracking',- );- expect(out).toMatchObject({- case_id: 'case-1',- employee_id: 'w-2',- description: 'Payroll question',- status: 'Open',- });- expect(out['time_entry_id']).toBeUndefined();- });-- it('maps HR time-entry fields without polluting case_id', () => {- const out = formatWorkdayOutput(- { id: 'te-1', worker: { id: 'w-2' }, date: '2025-03-01', hours: 8, status: 'Submitted' },- 'hr_services_time_tracking',- );- expect(out).toMatchObject({- time_entry_id: 'te-1',- employee_id: 'w-2',- date: '2025-03-01',- hours: 8,- });- expect(out['case_id']).toBeUndefined();- });-});--describe('getRecordTimestamp', () => {- it('prefers the provided field', () => {- expect(- getRecordTimestamp({ myDate: '2025-01-01', createdMoment: '2024-01-01' }, 'myDate'),- ).toBe('2025-01-01');- });-- it('falls back through the standard timestamp fields', () => {- expect(getRecordTimestamp({ updatedMoment: '2025-05-05' })).toBe('2025-05-05');- });-- it('returns undefined when no timestamp is present', () => {- expect(getRecordTimestamp({ foo: 'bar' })).toBeUndefined();- });-});diff --git a/packages/pieces/community/workday/src/lib/common/fields.ts b/packages/pieces/community/workday/src/lib/common/fields.tsdeleted file mode 100644index b6a3e3cfd24..00000000000--- a/packages/pieces/community/workday/src/lib/common/fields.ts+++ /dev/null@@ -1,139 +0,0 @@-const MAX_FLATTEN_DEPTH = 4;--export function flattenRecord(- value: unknown,- prefix = '',- depth = 0,-): Record<string, unknown> {- if (value === null || value === undefined) {- return prefix ? { [prefix]: value } : {};- }- if (Array.isArray(value)) {- return prefix- ? { [prefix]: JSON.stringify(value) }- : { items: JSON.stringify(value) };- }- if (typeof value !== 'object') {- return prefix ? { [prefix]: value } : { value };- }- if (depth >= MAX_FLATTEN_DEPTH) {- return prefix ? { [prefix]: JSON.stringify(value) } : {};- }- const result: Record<string, unknown> = {};- for (const [key, nested] of Object.entries(value as Record<string, unknown>)) {- const nextKey = prefix ? `${prefix}_${key}` : key;- Object.assign(result, flattenRecord(nested, nextKey, depth + 1));- }- return result;-}--export function formatWorkdayOutput(- record: Record<string, unknown>,- module: WorkdayModule,-): Record<string, unknown> {- const flat = flattenRecord(record);- const standard: Record<string, unknown> = {};-- if (module === 'recruiting') {- standard['job_requisition_id'] =- record['id'] ?? record['workdayID'] ?? readNestedId(record['jobRequisition']);- standard['title'] =- record['title'] ?? record['descriptor'] ?? readNestedDescriptor(record['jobRequisition']);- standard['location'] = readNestedDescriptor(record['location']) ?? record['location'];- standard['candidate_id'] = readNestedId(record['candidate']);- standard['application_status'] =- record['applicationStatus'] ?? record['status'] ?? record['stage'];- } else if (module === 'onboarding') {- standard['employee_id'] =- record['id'] ?? record['workdayID'] ?? readNestedId(record['worker']);- standard['name'] =- record['descriptor'] ?? record['fullName'] ?? readNestedDescriptor(record['worker']);- standard['hire_date'] = record['hireDate'] ?? record['createdMoment'];- standard['status'] = record['status'] ?? record['workerStatus'];- } else if (module === 'hr_services_time_tracking') {- standard['employee_id'] =- readNestedId(record['worker']) ?? readNestedId(record['employee']) ?? record['workerId'];- standard['status'] = record['status'];-- // This module covers both Cases and Time Entries. Deriving both case_id and- // time_entry_id from the generic `id` would set the wrong field on whichever- // object type isn't being queried, so classify by the time-entry-specific- // fields and populate only the matching identifier/fields.- const isTimeEntry =- 'hours' in record ||- 'quantity' in record ||- 'reportedQuantity' in record ||- 'timeBlockDate' in record ||- 'entryDate' in record ||- 'timeEntryId' in record;-- if (isTimeEntry) {- standard['time_entry_id'] = record['id'] ?? record['timeEntryId'];- standard['date'] = record['date'] ?? record['entryDate'] ?? record['timeBlockDate'];- standard['hours'] = record['hours'] ?? record['quantity'] ?? record['reportedQuantity'];- } else {- standard['case_id'] = record['id'] ?? record['workdayID'];- standard['description'] =- record['description'] ?? record['descriptor'] ?? record['subject'];- }- }-- return { ...flat, ...standard };-}--export function formatWorkdayOutputs(- records: Record<string, unknown>[],- module: WorkdayModule,-): Record<string, unknown>[] {- return records.map((record) => formatWorkdayOutput(record, module));-}--export function getRecordTimestamp(- record: Record<string, unknown>,- preferredField?: string,-): string | undefined {- const candidates = [- preferredField,- 'lastFunctionallyUpdated',- 'updatedMoment',- 'updatedDate',- 'createdMoment',- 'createdDate',- 'hireDate',- 'date',- ].filter((field): field is string => Boolean(field));-- for (const field of candidates) {- const value = record[field];- if (typeof value === 'string' && value.length > 0) {- return value;- }- }- return undefined;-}--function readNestedId(value: unknown): unknown {- if (value === null || value === undefined) {- return null;- }- if (typeof value === 'object' && value !== null && 'id' in value) {- return (value as { id: unknown }).id;- }- return value;-}--function readNestedDescriptor(value: unknown): unknown {- if (value === null || value === undefined) {- return null;- }- if (typeof value === 'object' && value !== null) {- const obj = value as Record<string, unknown>;- return obj['descriptor'] ?? obj['name'] ?? obj['fullName'] ?? null;- }- return value;-}--export type WorkdayModule =- | 'recruiting'- | 'onboarding'- | 'hr_services_time_tracking';diff --git a/packages/pieces/community/workday/src/lib/common/index.test.ts b/packages/pieces/community/workday/src/lib/common/index.test.tsdeleted file mode 100644index 422f682a3a5..00000000000--- a/packages/pieces/community/workday/src/lib/common/index.test.ts+++ /dev/null@@ -1,170 +0,0 @@-import {- HttpMethod,- HttpRequest,- HttpResponse,- httpClient,-} from '@activepieces/pieces-common';-import { OAuth2PropertyValue } from '@activepieces/pieces-framework';-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';-import {- escapeWql,- fetchAllPages,- workdayGetCustomObject,- workdayGetReport,- workdayListCustomObjectDefinitions,- workdayRequest,- workdayUpsertCustomObject,- workdayWqlRequestAll,- WorkdayService,-} from './index';--const AUTH = {- access_token: 'tok',- props: {- apiHost: 'wd2-impl-services1.workday.com',- tenant: 'mytenant',- },-} as unknown as OAuth2PropertyValue;--function resp(body: unknown): HttpResponse {- return { status: 200, headers: {}, body };-}--let sendRequest: ReturnType<typeof vi.spyOn>;--beforeEach(() => {- sendRequest = vi.spyOn(httpClient, 'sendRequest');-});--afterEach(() => {- vi.restoreAllMocks();-});--describe('workdayRequest', () => {- it('builds the tenant-scoped REST URL with a bearer token', async () => {- sendRequest.mockResolvedValue(resp({ id: 1 }));-- await workdayRequest(- AUTH,- HttpMethod.GET,- '/jobRequisitions/1',- undefined,- undefined,- WorkdayService.staffing,- );-- const req = sendRequest.mock.calls[0][0] as HttpRequest;- expect(req.url).toBe(- 'https://wd2-impl-services1.workday.com/ccx/api/staffing/v6/mytenant/jobRequisitions/1',- );- expect(req.authentication).toMatchObject({ token: 'tok' });- });-});--describe('fetchAllPages', () => {- it('paginates until fewer than a full page is returned', async () => {- const fullPage = Array.from({ length: 100 }, (_, i) => ({ id: i }));- const lastPage = Array.from({ length: 50 }, (_, i) => ({ id: 100 + i }));- sendRequest.mockImplementation(async (request: HttpRequest) => {- const offset = Number(request.queryParams?.['offset'] ?? 0);- return resp({ data: offset === 0 ? fullPage : lastPage, total: 150 });- });-- const all = await fetchAllPages(AUTH, '/workers');- expect(all).toHaveLength(150);- expect(sendRequest.mock.calls).toHaveLength(2);- });-- it('keeps paginating past the first full page when the API omits total', async () => {- const fullPage = Array.from({ length: 100 }, (_, i) => ({ id: i }));- const lastPage = Array.from({ length: 10 }, (_, i) => ({ id: 100 + i }));- sendRequest.mockImplementation(async (request: HttpRequest) => {- const offset = Number(request.queryParams?.['offset'] ?? 0);- return resp({ data: offset === 0 ? fullPage : lastPage });- });-- const all = await fetchAllPages(AUTH, '/workers');- expect(all).toHaveLength(110);- expect(sendRequest.mock.calls).toHaveLength(2);- });-});--describe('workdayWqlRequestAll', () => {- it('returns the data array from the WQL response', async () => {- sendRequest.mockResolvedValue(resp({ data: [{ id: 1 }, { id: 2 }] }));- const rows = await workdayWqlRequestAll(AUTH, 'SELECT id FROM workers');- expect(rows).toHaveLength(2);- const req = sendRequest.mock.calls[0][0] as HttpRequest;- expect(req.url).toContain('/ccx/api/wql/v1/mytenant/data');- });-- it('paginates until all rows are fetched', async () => {- const fullPage = Array.from({ length: 1000 }, (_, i) => ({ id: i }));- const lastPage = Array.from({ length: 500 }, (_, i) => ({ id: 1000 + i }));- sendRequest.mockImplementation(async (request: HttpRequest) => {- const offset = Number(request.queryParams?.['offset'] ?? 0);- return resp({ data: offset === 0 ? fullPage : lastPage, total: 1500 });- });-- const rows = await workdayWqlRequestAll(AUTH, 'SELECT id FROM workers');- expect(rows).toHaveLength(1500);- expect(sendRequest.mock.calls).toHaveLength(2);- });-- it('keeps paginating past the first full page when the API omits total', async () => {- const fullPage = Array.from({ length: 1000 }, (_, i) => ({ id: i }));- const lastPage = Array.from({ length: 25 }, (_, i) => ({ id: 1000 + i }));- sendRequest.mockImplementation(async (request: HttpRequest) => {- const offset = Number(request.queryParams?.['offset'] ?? 0);- return resp({ data: offset === 0 ? fullPage : lastPage });- });-- const rows = await workdayWqlRequestAll(AUTH, 'SELECT id FROM workers');- expect(rows).toHaveLength(1025);- expect(sendRequest.mock.calls).toHaveLength(2);- });-});--describe('workdayGetReport', () => {- it('GETs the report by id on the common service', async () => {- sendRequest.mockResolvedValue(resp({ Report_Entry: [{ id: 1 }] }));- await workdayGetReport(AUTH, 'Worker_Report');- const req = sendRequest.mock.calls[0][0] as HttpRequest;- expect(req.url).toBe(- 'https://wd2-impl-services1.workday.com/ccx/api/v1/mytenant/reports/Worker_Report',- );- });-});--describe('custom object helpers', () => {- it('lists custom object definitions', async () => {- sendRequest.mockResolvedValue(resp({ data: [{ id: 'def-1' }] }));- const defs = await workdayListCustomObjectDefinitions(AUTH);- expect(defs).toHaveLength(1);- expect((sendRequest.mock.calls[0][0] as HttpRequest).url).toContain(- '/customObjects/v1/mytenant/customObjectDefinitions',- );- });-- it('gets a custom object instance by id', async () => {- sendRequest.mockResolvedValue(resp({ id: 'obj-1' }));- await workdayGetCustomObject(AUTH, 'def-1', 'obj-1');- const req = sendRequest.mock.calls[0][0] as HttpRequest;- expect(req.url).toContain('/customObjects/v1/mytenant/customObjects/def-1');- expect(req.queryParams).toEqual({ id: 'obj-1' });- });-- it('upserts a custom object with PUT', async () => {- sendRequest.mockResolvedValue(resp({ id: 'obj-1' }));- await workdayUpsertCustomObject(AUTH, 'def-1', { name: 'x' });- const req = sendRequest.mock.calls[0][0] as HttpRequest;- expect(req.method).toBe(HttpMethod.PUT);- expect(req.body).toEqual({ name: 'x' });- });-});--describe('escapeWql', () => {- it('doubles single quotes', () => {- expect(escapeWql("O'Brien")).toBe("O''Brien");- });-});diff --git a/packages/pieces/community/workday/src/lib/common/index.ts b/packages/pieces/community/workday/src/lib/common/index.tsdeleted file mode 100644index 6559a8ff886..00000000000--- a/packages/pieces/community/workday/src/lib/common/index.ts+++ /dev/null@@ -1,307 +0,0 @@-import {- AuthenticationType,- HttpMethod,- HttpMessageBody,- HttpResponse,- httpClient,- QueryParams,-} from '@activepieces/pieces-common';-import { OAuth2PropertyValue } from '@activepieces/pieces-framework';-import { XMLParser } from 'fast-xml-parser';--const DEFAULT_HOST = 'wd2-impl-services1.workday.com';-const WQL_BASE = 'wql/v1';-const SOAP_VERSION = 'v46.0';--function getHost(auth: OAuth2PropertyValue): string {- return (auth?.props?.['apiHost'] as string) ?? DEFAULT_HOST;-}--export const WorkdayService = {- common: 'v1',- staffing: 'staffing/v6',- resourceManagement: 'resourceManagement/v3',- expenseManagement: 'expenseManagement/v1',- inbox: 'inbox/v1',- leaveManagement: 'absenceManagement/v1',- timeTracking: 'time/v2',-} as const;--export type ServicePath = typeof WorkdayService[keyof typeof WorkdayService];--function getTenant(auth: OAuth2PropertyValue): string {- if (!auth) return '';- return auth.props?.['tenant'] ?? '';-}--export async function workdayRequest<T extends HttpMessageBody>(- auth: OAuth2PropertyValue,- method: HttpMethod,- path: string,- body?: Record<string, unknown>,- queryParams?: QueryParams,- service: ServicePath = WorkdayService.common,-): Promise<HttpResponse<T>> {- const tenant = getTenant(auth);- return httpClient.sendRequest<T>({- method,- url: `https://${getHost(auth)}/ccx/api/${service}/${tenant}${path}`,- body,- queryParams,- authentication: {- type: AuthenticationType.BEARER_TOKEN,- token: auth.access_token,- },- });-}--export async function workdayWqlRequest<T extends HttpMessageBody>(- auth: OAuth2PropertyValue,- query: string,- limit?: number,- offset?: number,-): Promise<HttpResponse<T>> {- if (!auth || !auth.access_token) {- throw new Error('Workday connection is not configured. Please select a valid Workday connection.');- }- const tenant = getTenant(auth);- const queryParams: QueryParams = {};- if (limit !== undefined) queryParams['limit'] = String(limit);- if (offset !== undefined) queryParams['offset'] = String(offset);- return httpClient.sendRequest<T>({- method: HttpMethod.POST,- url: `https://${getHost(auth)}/ccx/api/${WQL_BASE}/${tenant}/data`,- body: { query },- queryParams,- authentication: {- type: AuthenticationType.BEARER_TOKEN,- token: auth.access_token,- },- });-}--export async function fetchAllPages<T>(- auth: OAuth2PropertyValue,- path: string,- queryParams?: QueryParams,- dataKey = 'data',- service: ServicePath = WorkdayService.common,-): Promise<T[]> {- const allItems: T[] = [];- const limit = 100;- let offset = 0;- let hasMore = true;-- while (hasMore) {- const response = await workdayRequest<Record<string, unknown>>(- auth,- HttpMethod.GET,- path,- undefined,- { ...queryParams, limit: String(limit), offset: String(offset) },- service,- );-- const items = (response.body[dataKey] ?? []) as T[];- allItems.push(...items);- offset += limit;-- // A short page is the only reliable end signal. `total` stops us one- // round-trip early, but ONLY when the API returns it — falling back to- // allItems.length would halt after the first full page.- if (items.length < limit) {- hasMore = false;- } else {- const total = response.body['total'];- hasMore = typeof total !== 'number' || offset < total;- }- }-- return allItems;-}--function getIsuCredentials(auth: OAuth2PropertyValue): {- username: string;- password: string;-} {- const username = auth.props?.['isuUsername'] as string | undefined;- const password = auth.props?.['isuPassword'] as string | undefined;- if (!username || !password) {- throw new Error(- 'ISU Username and Password are required for write operations. Please update your Workday connection with Integration System User credentials.',- );- }- return { username, password };-}--function buildSoapEnvelope(- username: string,- password: string,- operationXml: string,-): string {- return `<?xml version="1.0" encoding="UTF-8"?>-<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bsvc="urn:com.workday/bsvc">- <soapenv:Header>- <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">- <wsse:UsernameToken>- <wsse:Username>${username}</wsse:Username>- <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">${password}</wsse:Password>- </wsse:UsernameToken>- </wsse:Security>- </soapenv:Header>- <soapenv:Body>- ${operationXml}- </soapenv:Body>-</soapenv:Envelope>`;-}--export async function workdaySoapRequest(- auth: OAuth2PropertyValue,- soapService: string,- operationXml: string,-): Promise<Record<string, unknown>> {- const tenant = getTenant(auth);- const { username, password } = getIsuCredentials(auth);- const envelope = buildSoapEnvelope(username, password, operationXml);-- const response = await httpClient.sendRequest({- method: HttpMethod.POST,- url: `https://${getHost(auth)}/ccx/service/${tenant}/${soapService}/${SOAP_VERSION}`,- headers: {- 'Content-Type': 'text/xml;charset=UTF-8',- },- body: envelope,- });-- const parser = new XMLParser({- ignoreAttributes: false,- removeNSPrefix: true,- parseAttributeValue: true,- });-- const parsed = parser.parse(- typeof response.body === 'string'- ? response.body- : JSON.stringify(response.body),- ) as Record<string, unknown>;-- const soapEnvelope = parsed['Envelope'] as Record<string, unknown> | undefined;- const soapBody = soapEnvelope?.['Body'] as Record<string, unknown> | undefined;-- if (soapBody?.['Fault']) {- const fault = soapBody['Fault'] as Record<string, unknown>;- const faultString = fault['faultstring'] ?? fault['Reason'] ?? 'Unknown SOAP fault';- throw new Error(`Workday SOAP Error: ${JSON.stringify(faultString)}`);- }-- return soapBody ?? parsed;-}--export function escapeWql(value: string): string {- return value.replace(/'/g, "''");-}--export function getApiHost(auth: OAuth2PropertyValue): string {- return getHost(auth);-}--export async function workdayWqlRequestAll(- auth: OAuth2PropertyValue,- query: string,-): Promise<Record<string, unknown>[]> {- const allRows: Record<string, unknown>[] = [];- const limit = 1000;- let offset = 0;-- while (true) {- const response = await workdayWqlRequest<{- data?: Record<string, unknown>[];- total?: number;- }>(auth, query, limit, offset);- const rows = response.body.data ?? [];- allRows.push(...rows);-- // A short page is the only reliable end-of-data signal. `total` is used to- // stop one round-trip early, but ONLY when the API actually returns it —- // falling back to allRows.length would halt after the first full page.- if (rows.length < limit) {- break;- }- offset += limit;- const total = response.body.total;- if (typeof total === 'number' && offset >= total) {- break;- }- }-- return allRows;-}--export async function workdayGetReport(- auth: OAuth2PropertyValue,- reportId: string,- queryParams?: QueryParams,-): Promise<Record<string, unknown>> {- const response = await workdayRequest<Record<string, unknown>>(- auth,- HttpMethod.GET,- `/reports/${reportId}`,- undefined,- queryParams,- WorkdayService.common,- );- return response.body;-}--export async function workdayListCustomObjectDefinitions(- auth: OAuth2PropertyValue,-): Promise<Record<string, unknown>[]> {- const tenant = getTenant(auth);- const response = await httpClient.sendRequest<{- data?: Record<string, unknown>[];- }>({- method: HttpMethod.GET,- url: `https://${getHost(auth)}/ccx/api/customObjects/v1/${tenant}/customObjectDefinitions`,- authentication: {- type: AuthenticationType.BEARER_TOKEN,- token: auth.access_token,- },- });- return response.body.data ?? [];-}--export async function workdayGetCustomObject(- auth: OAuth2PropertyValue,- definitionId: string,- objectId: string,-): Promise<Record<string, unknown>> {- const tenant = getTenant(auth);- const response = await httpClient.sendRequest<Record<string, unknown>>({- method: HttpMethod.GET,- url: `https://${getHost(auth)}/ccx/api/customObjects/v1/${tenant}/customObjects/${definitionId}`,- queryParams: { id: objectId },- authentication: {- type: AuthenticationType.BEARER_TOKEN,- token: auth.access_token,- },- });- return response.body;-}--export async function workdayUpsertCustomObject(- auth: OAuth2PropertyValue,- definitionId: string,- body: Record<string, unknown>,-): Promise<Record<string, unknown>> {- const tenant = getTenant(auth);- const response = await httpClient.sendRequest<Record<string, unknown>>({- method: HttpMethod.PUT,- url: `https://${getHost(auth)}/ccx/api/customObjects/v1/${tenant}/customObjects/${definitionId}`,- body,- authentication: {- type: AuthenticationType.BEARER_TOKEN,- token: auth.access_token,- },- });- return response.body;-}diff --git a/packages/pieces/community/workday/src/lib/common/modules.test.ts b/packages/pieces/community/workday/src/lib/common/modules.test.tsdeleted file mode 100644index b98fb2e15f6..00000000000--- a/packages/pieces/community/workday/src/lib/common/modules.test.ts+++ /dev/null@@ -1,44 +0,0 @@-import { describe, expect, it } from 'vitest';-import { resolveBusinessObject, toWorkdayModule } from './modules';-import { WorkdayService } from './index';--describe('resolveBusinessObject', () => {- it('resolves a standard business object for a module', () => {- const config = resolveBusinessObject('recruiting', 'jobRequisitions', undefined, undefined);- expect(config.path).toBe('/jobRequisitions');- expect(config.service).toBe(WorkdayService.staffing);- });-- it('builds a custom object config from a path', () => {- const config = resolveBusinessObject('recruiting', '__custom__', 'invoices', WorkdayService.common);- expect(config.path).toBe('/invoices');- expect(config.service).toBe(WorkdayService.common);- });-- it('prefixes a missing slash on custom paths', () => {- const config = resolveBusinessObject('onboarding', '__custom__', 'workers', undefined);- expect(config.path).toBe('/workers');- });-- it('throws when a custom path is missing', () => {- expect(() => resolveBusinessObject('recruiting', '__custom__', '', undefined)).toThrow(- 'Custom Business Object Path is required',- );- });-- it('throws for an unknown business object', () => {- expect(() => resolveBusinessObject('recruiting', 'nope', undefined, undefined)).toThrow();- });-});--describe('toWorkdayModule', () => {- it('accepts the three supported modules', () => {- expect(toWorkdayModule('recruiting')).toBe('recruiting');- expect(toWorkdayModule('onboarding')).toBe('onboarding');- expect(toWorkdayModule('hr_services_time_tracking')).toBe('hr_services_time_tracking');- });-- it('throws for an invalid module', () => {- expect(() => toWorkdayModule('finance')).toThrow();- });-});diff --git a/packages/pieces/community/workday/src/lib/common/modules.ts b/packages/pieces/community/workday/src/lib/common/modules.tsdeleted file mode 100644index 05bef2a6e90..00000000000--- a/packages/pieces/community/workday/src/lib/common/modules.ts+++ /dev/null@@ -1,165 +0,0 @@-import { Property } from '@activepieces/pieces-framework';-import { ServicePath, WorkdayService } from './index';-import { WorkdayModule } from './fields';--export const WORKDAY_MODULE_OPTIONS = [- { label: 'Recruiting', value: 'recruiting' },- { label: 'Onboarding', value: 'onboarding' },- { label: 'HR Services & Time Tracking', value: 'hr_services_time_tracking' },-];--export const BUSINESS_OBJECTS_BY_MODULE: Record<string, BusinessObjectConfig[]> = {- recruiting: [- {- label: 'Job Requisition',- value: 'jobRequisitions',- path: '/jobRequisitions',- service: WorkdayService.staffing,- wqlDataSource: 'jobRequisitions',- },- {- label: 'Job Application',- value: 'jobApplications',- path: '/jobApplications',- service: WorkdayService.staffing,- wqlDataSource: 'jobApplications',- },- {- label: 'Candidate',- value: 'candidates',- path: '/candidates',- service: WorkdayService.staffing,- wqlDataSource: 'candidates',- },- ],- onboarding: [- {- label: 'Worker',- value: 'workers',- path: '/workers',- service: WorkdayService.staffing,- wqlDataSource: 'allWorkers',- },- {- label: 'Pre-Hire',- value: 'preHires',- path: '/preHires',- service: WorkdayService.staffing,- wqlDataSource: 'preHires',- },- ],- hr_services_time_tracking: [- {- label: 'Case',- value: 'cases',- path: '/cases',- service: WorkdayService.common,- wqlDataSource: 'cases',- },- {- label: 'Time Entry',- value: 'timeEntries',- path: '/timeEntries',- service: WorkdayService.timeTracking,- wqlDataSource: 'workerTimeBlocks',- },- ],-};--export const moduleProperty = Property.StaticDropdown({- displayName: 'Module',- description:- 'Workday functional area: Recruiting, Onboarding, or HR Services & Time Tracking.',- required: true,- options: {- disabled: false,- options: WORKDAY_MODULE_OPTIONS,- },-});--export const customBusinessObjectProperty = Property.ShortText({- displayName: 'Custom Business Object Path',- description:- 'REST path segment when using a custom object, e.g. `/jobRequisitions`.',- required: false,-});--export const customServiceProperty = Property.StaticDropdown({- displayName: 'Custom API Service',- description: 'API service prefix for custom business object paths.',- required: false,- options: {- disabled: false,- options: [- { label: 'Common (v1)', value: WorkdayService.common },- { label: 'Staffing (v6)', value: WorkdayService.staffing },- { label: 'Time Tracking (v2)', value: WorkdayService.timeTracking },- { label: 'Expense Management', value: WorkdayService.expenseManagement },- { label: 'Resource Management', value: WorkdayService.resourceManagement },- ],- },-});--export function resolveBusinessObject(- module: string | undefined,- businessObject: string | undefined,- customPath: string | undefined,- customService: string | undefined,-): BusinessObjectConfig {- if (businessObject === '__custom__') {- if (!customPath?.trim()) {- throw new Error('Custom Business Object Path is required for custom objects.');- }- const path = customPath.startsWith('/') ? customPath : `/${customPath}`;- return {- label: 'Custom',- value: 'custom',- path,- service: (customService as ServicePath) ?? WorkdayService.common,- };- }- const objects = BUSINESS_OBJECTS_BY_MODULE[module ?? ''] ?? [];- const found = objects.find((item) => item.value === businessObject);- if (!found) {- throw new Error('Select a valid business object for the chosen module.');- }- return found;-}--export function businessObjectPropertyForModule(module: string) {- const moduleObjects = BUSINESS_OBJECTS_BY_MODULE[module] ?? [];- return Property.StaticDropdown({- displayName: 'Business Object',- description: 'Workday business object to work with.',- required: true,- options: {- disabled: moduleObjects.length === 0,- options: [- ...moduleObjects.map((item) => ({- label: item.label,- value: item.value,- })),- { label: 'Custom object (path below)', value: '__custom__' },- ],- },- });-}--export function toWorkdayModule(module: string): WorkdayModule {- if (- module === 'recruiting' ||- module === 'onboarding' ||- module === 'hr_services_time_tracking'- ) {- return module;- }- throw new Error('Invalid Workday module selected.');-}--export type BusinessObjectConfig = {- label: string;- value: string;- path: string;- service: ServicePath;- wqlDataSource?: string;-};diff --git a/packages/pieces/community/workday/src/lib/common/props.ts b/packages/pieces/community/workday/src/lib/common/props.tsindex e3bb23a5291..87d62e04476 100644--- a/packages/pieces/community/workday/src/lib/common/props.ts+++ b/packages/pieces/community/workday/src/lib/common/props.ts@@ -1,95 +1,208 @@-import { DynamicPropsValue, Property } from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';import {- businessObjectPropertyForModule,- customBusinessObjectProperty,- customServiceProperty,- moduleProperty,-} from './modules';--export const sharedModuleProps = {- module: moduleProperty,- businessObject: Property.DynamicProperties({- displayName: 'Business Object',- required: true,+ AppConnectionType,+ DropdownState,+ DynamicPropsValue,+ Property,+} from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from './api';+import { workdayUtils } from './utils';++function module<R extends boolean>({+ required,+ displayName = 'Module',+ description = 'Workday functional area: Recruiting, Onboarding, or HR Services & Time Tracking.',+}: PropParams<R>) {+ return Property.StaticDropdown({+ displayName,+ description,+ required,+ options: {+ disabled: false,+ options: MODULE_OPTIONS,+ },+ });+}++function businessObject<R extends boolean>({+ required,+ displayName = 'Business Object',+ description,+}: PropParams<R>) {+ return Property.DynamicProperties({+ displayName,+ description,+ required,refreshers: ['module'],auth: workdayAuth,props: async ({ module }): Promise<DynamicPropsValue> => {- if (!module) {+ if (typeof module !== 'string' || !module) {return {objectType: Property.ShortText({displayName: 'Business Object',description: 'Select a module first.',required: true,}),- customPath: customBusinessObjectProperty,- customService: customServiceProperty,+ customPath: customBusinessObjectPath(),+ customService: customService(),};}return {- objectType: businessObjectPropertyForModule(module as unknown as string),- customPath: customBusinessObjectProperty,- customService: customServiceProperty,+ objectType: businessObjectType({ module }),+ customPath: customBusinessObjectPath(),+ customService: customService(),};},- }),+ });+}++function customObjectDefinition<R extends boolean>({+ required,+ displayName = 'Custom Object Definition',+ description = 'The custom object definition; its value is the definition alias, e.g. `apTestInfo`.',+}: PropParams<R>) {+ return Property.Dropdown({+ auth: workdayAuth,+ displayName,+ description,+ required,+ refreshers: [],+ options: async ({ auth }) => {+ if (!auth) {+ return disabledOptions({ placeholder: 'Connect your Workday account first.' });+ }+ if (auth.type === AppConnectionType.CUSTOM_AUTH) {+ return disabledOptions({ placeholder: 'Custom objects need the OAuth 2.0 connection.' });+ }+ const definitions = await workdayApi.listCustomObjectDefinitions({ auth });+ return {+ disabled: false,+ options: definitions.map((definition) => ({+ label: String(definition['name'] ?? definition['descriptor'] ?? definition['alias']),+ value: String(definition['alias']),+ })),+ };+ },+ });+}++function reportId<R extends boolean>({+ required,+ displayName = 'Report',+ description = "The custom report's RaaS URL (on the report: Actions → Web Service → View URLs, copy the JSON link) or `owner/report_name`, e.g. `lmcneil/PT_Workers`. The report must have Enable As Web Service ticked. Prompt values in a pasted URL are kept.",+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function reportParameters<R extends boolean>({+ required,+ displayName = 'Report Prompts (JSON)',+ description = 'Prompt values keyed by the prompt XML alias, e.g. `{ "Start_Date": "2026-10-01", "Organizations!WID": "<WID>" }`. A list is sent as multiple values. These override prompts in a pasted URL.',+}: PropParams<R>) {+ return Property.Json({ displayName, description, required });+}++function wqlQuery<R extends boolean>({+ required,+ displayName = 'WQL Query',+ description = 'Workday Query Language query. Include a date/timestamp column for polling triggers.',+}: PropParams<R>) {+ return Property.LongText({ displayName, description, required });+}++function dateField<R extends boolean>({+ required,+ displayName = 'Date Field Name',+ description = 'Field used to detect new/updated records (e.g. `lastFunctionallyUpdated`).',+}: PropParams<R>) {+ return Property.ShortText({+ displayName,+ description,+ required,+ defaultValue: 'lastFunctionallyUpdated',+ });+}++function requestBody<R extends boolean>({+ required,+ displayName = 'Request Body (JSON)',+ description = 'JSON payload for create or update operations.',+}: PropParams<R>) {+ return Property.Json({ displayName, description, required });+}++function businessObjectType({ module }: { module: string }) {+ const moduleObjects = workdayUtils.businessObjectsForModule({ module });+ return Property.StaticDropdown({+ displayName: 'Business Object',+ description: 'Workday business object to work with.',+ required: true,+ options: {+ disabled: false,+ options: [+ ...moduleObjects.map((item) => ({+ label: item.label,+ value: item.value,+ })),+ { label: 'Custom object (path below)', value: '__custom__' },+ ],+ },+ });+}++function customBusinessObjectPath() {+ return Property.ShortText({+ displayName: 'Custom Business Object Path',+ description:+ 'REST path segment when using a custom object, e.g. `/jobPostings` with the Recruiting (v4) service.',+ required: false,+ });+}++function customService() {+ return Property.StaticDropdown({+ displayName: 'Custom API Service',+ description: 'API service prefix for custom business object paths.',+ required: false,+ options: {+ disabled: false,+ options: [+ { label: 'Common (v1)', value: 'v1' },+ { label: 'Staffing (v6)', value: 'staffing/v6' },+ { label: 'Recruiting (v4)', value: 'recruiting/v4' },+ { label: 'Time Tracking (v7)', value: 'timeTracking/v7' },+ { label: 'Expense Management', value: 'expense/v1' },+ { label: 'Procurement (v5)', value: 'procurement/v5' },+ { label: 'Accounts Payable (v1)', value: 'accountsPayable/v1' },+ ],+ },+ });+}++function disabledOptions({ placeholder }: { placeholder: string }): DropdownState<never> {+ return { disabled: true, options: [], placeholder };+}++export const workdayProps = {+ module,+ businessObject,+ customObjectDefinition,+ reportId,+ reportParameters,+ wqlQuery,+ dateField,+ requestBody,};-export const optionalQueryParamsProperty = Property.Json({- displayName: 'Query Parameters (JSON)',- description:- 'Optional REST query parameters, e.g. `{ "limit": 50, "status": "Open" }`.',- required: false,-});--export const requestBodyProperty = Property.Json({- displayName: 'Request Body (JSON)',- description: 'JSON payload for create or update operations.',- required: true,-});--export const wqlQueryProperty = Property.LongText({- displayName: 'WQL Query',- description:- 'Workday Query Language query. Include a date/timestamp column for polling triggers.',- required: true,-});--export const reportIdProperty = Property.ShortText({- displayName: 'Report ID or Alias',- description: 'Workday report ID or web service alias from the report definition.',- required: true,-});--export const dateFieldProperty = Property.ShortText({- displayName: 'Date Field Name',- description:- 'Field used to detect new/updated records (e.g. `lastFunctionallyUpdated`).',- required: false,- defaultValue: 'lastFunctionallyUpdated',-});--export const customObjectDefinitionProperty = Property.ShortText({- displayName: 'Custom Object Definition ID',- description: 'Custom object definition alias or ID from Workday.',- required: true,-});--export const operationNameProperty = Property.ShortText({- displayName: 'Operation Name',- description:- 'REST sub-resource or SOAP operation path, e.g. `/jobRequisitions/{id}/close` or `Submit_Job_Requisition`.',- required: true,-});--export const objectIdsProperty = Property.Array({- displayName: 'Object IDs',- description: 'One or more Workday record IDs to retrieve.',- required: true,- properties: {- id: Property.ShortText({- displayName: 'ID',- required: true,- }),- },-});+const MODULE_OPTIONS = [+ { label: 'Recruiting', value: 'recruiting' },+ { label: 'Onboarding', value: 'onboarding' },+ { label: 'HR Services & Time Tracking', value: 'hr_services_time_tracking' },+];++export type PropParams<R extends boolean> = {+ required: R;+ displayName?: string;+ description?: string;+};diff --git a/packages/pieces/community/workday/src/lib/common/types.ts b/packages/pieces/community/workday/src/lib/common/types.tsnew file mode 100644index 00000000000..8a7b273ef8c--- /dev/null+++ b/packages/pieces/community/workday/src/lib/common/types.ts@@ -0,0 +1,60 @@+import type { AppConnectionType } from '@activepieces/pieces-framework';++export type WorkdayOAuth2AuthValue = {+ type: AppConnectionType.OAUTH2;+ access_token: string;+ props?: Record<string, unknown>;+};++export type WorkdayIsuAuthValue = {+ type: AppConnectionType.CUSTOM_AUTH;+ props: {+ apiHost: string;+ tenant: string;+ username: string;+ password: string;+ wwsVersion?: string;+ };+};++export type WorkdayAuthValue = WorkdayOAuth2AuthValue | WorkdayIsuAuthValue;++export type WorkdayModule = 'recruiting' | 'onboarding' | 'hr_services_time_tracking';++export type WorkdayBusinessObject = {+ label: string;+ value: string;+ path: string;+ service: string;+ wqlDataSource?: string;+};++export type WorkdayRecord = Record<string, unknown>;++export type WorkdayPage<T> = {+ data?: T[];+ total?: number;+};++export type WorkdayReport =+ | { reportPath: string; format: 'json'; rows: WorkdayRecord[] }+ | { reportPath: string; format: 'csv'; csv: string };++export type WorkdaySoapEnvelope<T extends WorkdayRecord> = {+ Envelope?: {+ Body?: T & {+ Fault?: {+ faultstring?: unknown;+ Reason?: unknown;+ };+ };+ };+};++export type WorkdaySupplierInvoicesBody = {+ Get_Supplier_Invoices_Response?: {+ Response_Data?: {+ Supplier_Invoice?: WorkdayRecord | WorkdayRecord[];+ };+ };+};diff --git a/packages/pieces/community/workday/src/lib/common/utils.ts b/packages/pieces/community/workday/src/lib/common/utils.tsnew file mode 100644index 00000000000..a439fbcce33--- /dev/null+++ b/packages/pieces/community/workday/src/lib/common/utils.ts@@ -0,0 +1,264 @@+import type { QueryParams } from '@activepieces/pieces-common';++import type { WorkdayBusinessObject, WorkdayModule, WorkdayRecord } from './types';++function escapeXml({ value }: { value: string }): string {+ return value+ .replace(/&/g, '&')+ .replace(/</g, '<')+ .replace(/>/g, '>')+ .replace(/"/g, '"')+ .replace(/'/g, ''');+}++function flattenRecord({+ value,+ prefix = '',+ depth = 0,+}: {+ value: unknown;+ prefix?: string;+ depth?: number;+}): WorkdayRecord {+ if (value === null || value === undefined) {+ return prefix ? { [prefix]: value } : {};+ }+ if (Array.isArray(value)) {+ return prefix ? { [prefix]: JSON.stringify(value) } : { items: JSON.stringify(value) };+ }+ if (typeof value !== 'object') {+ return prefix ? { [prefix]: value } : { value };+ }+ if (depth >= MAX_FLATTEN_DEPTH) {+ return prefix ? { [prefix]: JSON.stringify(value) } : {};+ }+ const result: WorkdayRecord = {};+ for (const [key, nested] of Object.entries(value)) {+ const nextKey = prefix ? `${prefix}_${key}` : key;+ Object.assign(result, flattenRecord({ value: nested, prefix: nextKey, depth: depth + 1 }));+ }+ return result;+}++function formatOutput({+ record,+ module,+}: {+ record: WorkdayRecord;+ module: WorkdayModule;+}): WorkdayRecord {+ const flat = flattenRecord({ value: record });+ const standard: WorkdayRecord = {};++ if (module === 'recruiting') {+ standard['job_requisition_id'] =+ record['id'] ?? record['workdayID'] ?? readNestedId({ value: record['jobRequisition'] });+ standard['title'] =+ record['title'] ??+ record['descriptor'] ??+ readNestedDescriptor({ value: record['jobRequisition'] });+ standard['location'] =+ readNestedDescriptor({ value: record['location'] }) ?? record['location'];+ standard['candidate_id'] = readNestedId({ value: record['candidate'] });+ standard['application_status'] =+ record['applicationStatus'] ?? record['status'] ?? record['stage'];+ } else if (module === 'onboarding') {+ standard['employee_id'] =+ record['id'] ?? record['workdayID'] ?? readNestedId({ value: record['worker'] });+ standard['name'] =+ record['descriptor'] ??+ record['fullName'] ??+ readNestedDescriptor({ value: record['worker'] });+ standard['hire_date'] = record['hireDate'] ?? record['createdMoment'];+ standard['status'] = record['status'] ?? record['workerStatus'];+ } else if (module === 'hr_services_time_tracking') {+ standard['employee_id'] =+ readNestedId({ value: record['worker'] }) ??+ readNestedId({ value: record['employee'] }) ??+ record['workerId'];+ standard['status'] = record['status'];++ const isTimeEntry =+ 'hours' in record ||+ 'quantity' in record ||+ 'reportedQuantity' in record ||+ 'timeBlockDate' in record ||+ 'entryDate' in record ||+ 'timeEntryId' in record;++ if (isTimeEntry) {+ standard['time_entry_id'] = record['id'] ?? record['timeEntryId'];+ standard['date'] =+ record['date'] ?? record['entryDate'] ?? record['timeBlockDate'] ?? record['calendarDate'];+ standard['hours'] = record['hours'] ?? record['quantity'] ?? record['reportedQuantity'];+ } else {+ standard['case_id'] = record['id'] ?? record['workdayID'];+ standard['description'] = record['description'] ?? record['descriptor'] ?? record['subject'];+ }+ }++ return { ...flat, ...standard };+}++function formatOutputs({+ records,+ module,+}: {+ records: WorkdayRecord[];+ module: WorkdayModule;+}): WorkdayRecord[] {+ return records.map((record) => formatOutput({ record, module }));+}++function getRecordTimestamp({+ record,+ preferredField,+}: {+ record: WorkdayRecord;+ preferredField?: string;+}): string | undefined {+ const candidates = [+ preferredField,+ 'lastFunctionallyUpdated',+ 'updatedMoment',+ 'updatedDate',+ 'createdMoment',+ 'createdDate',+ 'hireDate',+ 'date',+ ].filter((field): field is string => Boolean(field));++ for (const field of candidates) {+ const value = record[field];+ if (typeof value === 'string' && value.length > 0) {+ return value;+ }+ }+ return undefined;+}++function readNestedId({ value }: { value: unknown }): unknown {+ if (value === null || value === undefined) {+ return null;+ }+ if (typeof value === 'object' && 'id' in value) {+ return value.id;+ }+ return value;+}++function readNestedDescriptor({ value }: { value: unknown }): unknown {+ if (value === null || value === undefined) {+ return null;+ }+ if (typeof value === 'object') {+ const descriptor = 'descriptor' in value ? value.descriptor : undefined;+ const name = 'name' in value ? value.name : undefined;+ const fullName = 'fullName' in value ? value.fullName : undefined;+ return descriptor ?? name ?? fullName ?? null;+ }+ return value;+}++function toQueryParams({ value }: { value: WorkdayRecord | undefined }): QueryParams {+ return Object.fromEntries(Object.entries(value ?? {}).map(([key, item]) => [key, String(item)]));+}++function businessObjectsForModule({ module }: { module: string }): WorkdayBusinessObject[] {+ return BUSINESS_OBJECTS_BY_MODULE[module] ?? [];+}++function resolveBusinessObject({+ module,+ selection,+}: {+ module: string | undefined;+ selection: WorkdayRecord | undefined;+}): WorkdayBusinessObject {+ const objectType = selection?.['objectType'];+ if (objectType === CUSTOM_BUSINESS_OBJECT) {+ const customPath = selection?.['customPath'];+ if (typeof customPath !== 'string' || !customPath.trim()) {+ throw new Error('Custom Business Object Path is required for custom objects.');+ }+ const rawService = selection?.['customService'];+ const customService = typeof rawService === 'string' ? rawService : undefined;+ const path = customPath.startsWith('/') ? customPath : `/${customPath}`;+ return {+ label: 'Custom',+ value: 'custom',+ path,+ service: LEGACY_SERVICE_PATHS[customService ?? ''] ?? customService ?? 'v1',+ };+ }+ const found = businessObjectsForModule({ module: module ?? '' }).find(+ (item) => item.value === objectType,+ );+ if (!found) {+ throw new Error('Select a valid business object for the chosen module.');+ }+ return found;+}++function toWorkdayModule({ module }: { module: string }): WorkdayModule {+ if (+ module === 'recruiting' ||+ module === 'onboarding' ||+ module === 'hr_services_time_tracking'+ ) {+ return module;+ }+ throw new Error('Invalid Workday module selected.');+}++export const workdayUtils = {+ escapeXml,+ flattenRecord,+ formatOutput,+ formatOutputs,+ getRecordTimestamp,+ toQueryParams,+ readNestedId,+ readNestedDescriptor,+ businessObjectsForModule,+ resolveBusinessObject,+ toWorkdayModule,+};++const MAX_FLATTEN_DEPTH = 4;+const CUSTOM_BUSINESS_OBJECT = '__custom__';++const BUSINESS_OBJECTS_BY_MODULE: Record<string, WorkdayBusinessObject[]> = {+ recruiting: [],+ onboarding: [+ {+ label: 'Worker',+ value: 'workers',+ path: '/workers',+ service: 'staffing/v6',+ wqlDataSource: 'allWorkers',+ },+ ],+ hr_services_time_tracking: [+ {+ label: 'Case',+ value: 'cases',+ path: '/cases',+ service: 'helpCase/v4',+ wqlDataSource: 'cases',+ },+ {+ label: 'Time Entry',+ value: 'timeEntries',+ path: '/workerTimeBlocks',+ service: 'timeTracking/v7',+ wqlDataSource: 'workerTimeBlocks',+ },+ ],+};++const LEGACY_SERVICE_PATHS: Record<string, string> = {+ 'expenseManagement/v1': 'expense/v1',+ 'time/v2': 'timeTracking/v7',+ 'resourceManagement/v3': 'procurement/v5',+};diff --git a/packages/pieces/community/workday/src/lib/trigger/business-process-completed.ts b/packages/pieces/community/workday/src/lib/trigger/business-process-completed.tsdeleted file mode 100644index c168fc6c1bf..00000000000--- a/packages/pieces/community/workday/src/lib/trigger/business-process-completed.ts+++ /dev/null@@ -1,39 +0,0 @@-import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';-import { AppConnectionValueForAuthProperty, TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdayWqlRequest } from '../common';--const polling: Polling<AppConnectionValueForAuthProperty<typeof workdayAuth>, Record<string, never>> = {- strategy: DedupeStrategy.LAST_ITEM,- items: async ({ auth }) => {- const response = await workdayWqlRequest<{ total: number; data: Array<Record<string, unknown>> }>(- auth,- `SELECT worker, fullName FROM allActiveEmployees LIMIT 100`,- );-- const items = response.body.data ?? [];- return items.map((item) => ({- id: JSON.stringify(item),- data: item,- }));- },-};--export const businessProcessCompleted = createTrigger({- auth: workdayAuth,- name: 'business_process_completed',- classification: 'READ',- displayName: 'Business Process Event Completed',- description: 'Triggers when a business process event is completed in Workday.',- aiMetadata: {- description:- 'Fires when a Workday business process completes (e.g. a hire, change-job, or approval workflow reaches its end state). Polls active workers as the change signal. Use to run downstream automation once a Workday workflow finishes.',- },- props: {},- sampleData: { id: 'bp-001', descriptor: 'Hire: John Smith', completedDate: '2026-04-01T14:30:00Z' },- type: TriggerStrategy.POLLING,- async test(ctx) { return await pollingHelper.test(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },- async onEnable(ctx) { await pollingHelper.onEnable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async onDisable(ctx) { await pollingHelper.onDisable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async run(ctx) { return await pollingHelper.poll(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },-});diff --git a/packages/pieces/community/workday/src/lib/trigger/employee-terminated.ts b/packages/pieces/community/workday/src/lib/trigger/employee-terminated.tsdeleted file mode 100644index c5d28e8626e..00000000000--- a/packages/pieces/community/workday/src/lib/trigger/employee-terminated.ts+++ /dev/null@@ -1,40 +0,0 @@-import { DedupeStrategy, HttpMethod, Polling, pollingHelper } from '@activepieces/pieces-common';-import { AppConnectionValueForAuthProperty, TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';-import dayjs from 'dayjs';-import { workdayAuth } from '../auth';-import { workdayRequest, WorkdayService } from '../common';--const polling: Polling<AppConnectionValueForAuthProperty<typeof workdayAuth>, Record<string, never>> = {- strategy: DedupeStrategy.TIMEBASED,- items: async ({ auth, lastFetchEpochMS }) => {- const terminatedAfter = dayjs(lastFetchEpochMS).toISOString();- const response = await workdayRequest<{- data: { id: string; descriptor: string; terminationDate: string }[];- }>(auth, HttpMethod.GET, '/workers', undefined, { terminatedAfter }, WorkdayService.staffing);-- const items = response.body.data ?? [];- return items.map((item) => ({- epochMilliSeconds: dayjs(item.terminationDate).valueOf(),- data: item,- }));- },-};--export const employeeTerminated = createTrigger({- auth: workdayAuth,- name: 'employee_terminated',- classification: 'READ',- displayName: 'Employee Terminated',- description: 'Triggers when an employee is terminated in Workday.',- aiMetadata: {- description:- 'Fires for each worker whose termination is recorded in Workday after the trigger was enabled, detected by polling workers by termination date. Represents an employee offboarding event. Use to drive offboarding workflows (access revocation, notifications).',- },- props: {},- sampleData: { id: '3aa5550b7fe348b98d7b5741afc65534', descriptor: 'Jane Doe', terminationDate: '2026-04-01' },- type: TriggerStrategy.POLLING,- async test(ctx) { return await pollingHelper.test(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },- async onEnable(ctx) { await pollingHelper.onEnable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async onDisable(ctx) { await pollingHelper.onDisable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async run(ctx) { return await pollingHelper.poll(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },-});diff --git a/packages/pieces/community/workday/src/lib/trigger/expense-report-submitted.ts b/packages/pieces/community/workday/src/lib/trigger/expense-report-submitted.tsdeleted file mode 100644index 6b0320b4f4c..00000000000--- a/packages/pieces/community/workday/src/lib/trigger/expense-report-submitted.ts+++ /dev/null@@ -1,39 +0,0 @@-import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';-import { AppConnectionValueForAuthProperty, TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdayWqlRequest } from '../common';--const polling: Polling<AppConnectionValueForAuthProperty<typeof workdayAuth>, Record<string, never>> = {- strategy: DedupeStrategy.LAST_ITEM,- items: async ({ auth }) => {- const response = await workdayWqlRequest<{ total: number; data: Array<Record<string, unknown>> }>(- auth,- `SELECT expenseItem FROM expenseItems LIMIT 100`,- );-- const items = response.body.data ?? [];- return items.map((item) => ({- id: JSON.stringify(item),- data: item,- }));- },-};--export const expenseReportSubmitted = createTrigger({- auth: workdayAuth,- name: 'expense_report_submitted',- classification: 'READ',- displayName: 'Expense Report Submitted',- description: 'Triggers when an expense report is submitted in Workday.',- aiMetadata: {- description:- 'Fires when a new expense report (expense item) appears in Workday, detected by polling the expenseItems dataset. Represents an expense submission event. Use to start expense review or reimbursement automation.',- },- props: {},- sampleData: { id: 'exp-001', descriptor: 'Q1 Travel Expenses', createdDate: '2026-04-01T09:00:00Z' },- type: TriggerStrategy.POLLING,- async test(ctx) { return await pollingHelper.test(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },- async onEnable(ctx) { await pollingHelper.onEnable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async onDisable(ctx) { await pollingHelper.onDisable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async run(ctx) { return await pollingHelper.poll(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },-});diff --git a/packages/pieces/community/workday/src/lib/trigger/leave-request-submitted.ts b/packages/pieces/community/workday/src/lib/trigger/leave-request-submitted.tsdeleted file mode 100644index 565352b304b..00000000000--- a/packages/pieces/community/workday/src/lib/trigger/leave-request-submitted.ts+++ /dev/null@@ -1,39 +0,0 @@-import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';-import { AppConnectionValueForAuthProperty, TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdayWqlRequest } from '../common';--const polling: Polling<AppConnectionValueForAuthProperty<typeof workdayAuth>, Record<string, never>> = {- strategy: DedupeStrategy.LAST_ITEM,- items: async ({ auth }) => {- const response = await workdayWqlRequest<{ total: number; data: Array<Record<string, unknown>> }>(- auth,- `SELECT timeOffType FROM allTimeOffs LIMIT 100`,- );-- const items = response.body.data ?? [];- return items.map((item) => ({- id: JSON.stringify(item),- data: item,- }));- },-};--export const leaveRequestSubmitted = createTrigger({- auth: workdayAuth,- name: 'leave_request_submitted',- classification: 'READ',- displayName: 'Leave Request Submitted',- description: 'Triggers when a leave request is submitted in Workday.',- aiMetadata: {- description:- 'Fires when a new leave/time-off entry appears in Workday, detected by polling the allTimeOffs dataset. Represents a leave-request submission event. Use to start leave approval or coverage-planning automation.',- },- props: {},- sampleData: { id: 'lr-001', descriptor: 'Vacation Request - John Smith', createdDate: '2026-04-01T11:00:00Z' },- type: TriggerStrategy.POLLING,- async test(ctx) { return await pollingHelper.test(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },- async onEnable(ctx) { await pollingHelper.onEnable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async onDisable(ctx) { await pollingHelper.onDisable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async run(ctx) { return await pollingHelper.poll(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },-});diff --git a/packages/pieces/community/workday/src/lib/trigger/new-hire-created.ts b/packages/pieces/community/workday/src/lib/trigger/new-hire-created.tsdeleted file mode 100644index a7a5a143097..00000000000--- a/packages/pieces/community/workday/src/lib/trigger/new-hire-created.ts+++ /dev/null@@ -1,61 +0,0 @@-import {- DedupeStrategy,- HttpMethod,- Polling,- pollingHelper,-} from '@activepieces/pieces-common';-import {- AppConnectionValueForAuthProperty,- TriggerStrategy,- createTrigger,-} from '@activepieces/pieces-framework';-import dayjs from 'dayjs';-import { workdayAuth } from '../auth';-import { workdayRequest, WorkdayService } from '../common';--const polling: Polling<AppConnectionValueForAuthProperty<typeof workdayAuth>, Record<string, never>> = {- strategy: DedupeStrategy.TIMEBASED,- items: async ({ auth, lastFetchEpochMS }) => {- const hiredAfter = dayjs(lastFetchEpochMS).toISOString();- const response = await workdayRequest<{- data: { id: string; descriptor: string; hireDate: string }[];- }>(auth, HttpMethod.GET, '/workers', undefined, { hiredAfter }, WorkdayService.staffing);-- const items = response.body.data ?? [];- return items.map((item) => ({- epochMilliSeconds: dayjs(item.hireDate).valueOf(),- data: item,- }));- },-};--export const newHireCreated = createTrigger({- auth: workdayAuth,- name: 'new_hire_created',- classification: 'READ',- displayName: 'New Hire Created',- description: 'Triggers when a new employee is hired in Workday.',- aiMetadata: {- description:- 'Fires for each worker hired in Workday after the trigger was enabled, detected by polling workers by hire date. Represents an employee onboarding event. Use to drive onboarding workflows (account provisioning, welcome notifications).',- },- props: {},- sampleData: {- id: '3aa5550b7fe348b98d7b5741afc65534',- descriptor: 'John Smith',- hireDate: '2026-04-01',- },- type: TriggerStrategy.POLLING,- async test(ctx) {- return await pollingHelper.test(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files });- },- async onEnable(ctx) {- await pollingHelper.onEnable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue });- },- async onDisable(ctx) {- await pollingHelper.onDisable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue });- },- async run(ctx) {- return await pollingHelper.poll(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files });- },-});diff --git a/packages/pieces/community/workday/src/lib/trigger/new-inbox-task.ts b/packages/pieces/community/workday/src/lib/trigger/new-inbox-task.tsdeleted file mode 100644index 4e4ec5d85c4..00000000000--- a/packages/pieces/community/workday/src/lib/trigger/new-inbox-task.ts+++ /dev/null@@ -1,39 +0,0 @@-import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';-import { AppConnectionValueForAuthProperty, TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdayWqlRequest } from '../common';--const polling: Polling<AppConnectionValueForAuthProperty<typeof workdayAuth>, Record<string, never>> = {- strategy: DedupeStrategy.LAST_ITEM,- items: async ({ auth }) => {- const response = await workdayWqlRequest<{ total: number; data: Array<Record<string, unknown>> }>(- auth,- `SELECT businessProcess FROM businessProcessTransactionsAwaitingMyAction LIMIT 100`,- );-- const items = response.body.data ?? [];- return items.map((item) => ({- id: JSON.stringify(item),- data: item,- }));- },-};--export const newInboxTask = createTrigger({- auth: workdayAuth,- name: 'new_inbox_task',- classification: 'READ',- displayName: 'New Inbox Task',- description: 'Triggers when a new inbox task is assigned in Workday.',- aiMetadata: {- description:- 'Fires when a new business-process task awaiting the connected user’s action appears in their Workday inbox, detected by polling transactions awaiting action. Represents a pending approval/review assignment. Use to auto-handle or notify on incoming Workday tasks (pair with the Approve Task action).',- },- props: {},- sampleData: { id: 'task-001', descriptor: 'Approve Time Off Request', assignedDate: '2026-04-01T08:00:00Z' },- type: TriggerStrategy.POLLING,- async test(ctx) { return await pollingHelper.test(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },- async onEnable(ctx) { await pollingHelper.onEnable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async onDisable(ctx) { await pollingHelper.onDisable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async run(ctx) { return await pollingHelper.poll(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },-});diff --git a/packages/pieces/community/workday/src/lib/trigger/new-supplier-invoice.ts b/packages/pieces/community/workday/src/lib/trigger/new-supplier-invoice.tsdeleted file mode 100644index a17b82cb898..00000000000--- a/packages/pieces/community/workday/src/lib/trigger/new-supplier-invoice.ts+++ /dev/null@@ -1,39 +0,0 @@-import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';-import { AppConnectionValueForAuthProperty, TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdayWqlRequest } from '../common';--const polling: Polling<AppConnectionValueForAuthProperty<typeof workdayAuth>, Record<string, never>> = {- strategy: DedupeStrategy.LAST_ITEM,- items: async ({ auth }) => {- const response = await workdayWqlRequest<{ total: number; data: Array<Record<string, unknown>> }>(- auth,- `SELECT supplier, supplierName FROM suppliers LIMIT 100`,- );-- const items = response.body.data ?? [];- return items.map((item) => ({- id: JSON.stringify(item),- data: item,- }));- },-};--export const newSupplierInvoice = createTrigger({- auth: workdayAuth,- name: 'new_supplier_invoice',- classification: 'READ',- displayName: 'New Supplier Invoice',- description: 'Triggers when a new supplier invoice is created in Workday.',- aiMetadata: {- description:- 'Fires when a new supplier invoice is created in Workday. Represents a supplier-invoice creation event. Use to route invoices into approval, accounting, or payment automation.',- },- props: {},- sampleData: { id: 'inv-001', descriptor: 'Invoice #12345 - Acme Corp', createdDate: '2026-04-01T12:00:00Z' },- type: TriggerStrategy.POLLING,- async test(ctx) { return await pollingHelper.test(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },- async onEnable(ctx) { await pollingHelper.onEnable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async onDisable(ctx) { await pollingHelper.onDisable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async run(ctx) { return await pollingHelper.poll(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },-});diff --git a/packages/pieces/community/workday/src/lib/trigger/new-supplier.ts b/packages/pieces/community/workday/src/lib/trigger/new-supplier.tsdeleted file mode 100644index 6bd2a5a36fb..00000000000--- a/packages/pieces/community/workday/src/lib/trigger/new-supplier.ts+++ /dev/null@@ -1,39 +0,0 @@-import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';-import { AppConnectionValueForAuthProperty, TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdayWqlRequest } from '../common';--const polling: Polling<AppConnectionValueForAuthProperty<typeof workdayAuth>, Record<string, never>> = {- strategy: DedupeStrategy.LAST_ITEM,- items: async ({ auth }) => {- const response = await workdayWqlRequest<{ total: number; data: Array<Record<string, unknown>> }>(- auth,- `SELECT supplier, supplierName FROM suppliers LIMIT 100`,- );-- const items = response.body.data ?? [];- return items.map((item) => ({- id: JSON.stringify(item),- data: item,- }));- },-};--export const newSupplier = createTrigger({- auth: workdayAuth,- name: 'new_supplier',- classification: 'READ',- displayName: 'New Supplier',- description: 'Triggers when a new supplier is created in Workday.',- aiMetadata: {- description:- 'Fires when a new supplier appears in Workday, detected by polling the suppliers dataset. Represents a supplier-creation event. Use to sync new vendors into downstream systems or kick off supplier onboarding.',- },- props: {},- sampleData: { id: 'sup-001', descriptor: 'Acme Corp', createdDate: '2026-04-01T10:00:00Z' },- type: TriggerStrategy.POLLING,- async test(ctx) { return await pollingHelper.test(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },- async onEnable(ctx) { await pollingHelper.onEnable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async onDisable(ctx) { await pollingHelper.onDisable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async run(ctx) { return await pollingHelper.poll(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },-});diff --git a/packages/pieces/community/workday/src/lib/trigger/run-wql-query.ts b/packages/pieces/community/workday/src/lib/trigger/run-wql-query.tsdeleted file mode 100644index e8badd60dec..00000000000--- a/packages/pieces/community/workday/src/lib/trigger/run-wql-query.ts+++ /dev/null@@ -1,54 +0,0 @@-import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';-import { AppConnectionValueForAuthProperty, Property, StaticPropsValue, TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';-import dayjs from 'dayjs';-import { workdayAuth } from '../auth';-import { workdayWqlRequest } from '../common';--const props = {- query: Property.LongText({- displayName: 'WQL Query',- description: 'The Workday Query Language (WQL) query to execute. Must include a date/timestamp column for deduplication.',- required: true,- }),- dateField: Property.ShortText({- displayName: 'Date Field Name',- description: 'The name of the date/timestamp field in your query results used for detecting new records (e.g., "createdDate").',- required: true,- defaultValue: 'createdDate',- }),-};--const polling: Polling<AppConnectionValueForAuthProperty<typeof workdayAuth>, StaticPropsValue<typeof props>> = {- strategy: DedupeStrategy.TIMEBASED,- items: async ({ auth, propsValue, lastFetchEpochMS }) => {- const response = await workdayWqlRequest<{ data: Record<string, unknown>[] }>(auth, propsValue.query);- const dateField = propsValue.dateField;- const items = response.body.data ?? [];- return items- .filter((item) => {- const dateValue = item[dateField];- if (typeof dateValue !== 'string') return false;- return dayjs(dateValue).valueOf() > lastFetchEpochMS;- })- .map((item) => ({ epochMilliSeconds: dayjs(item[dateField] as string).valueOf(), data: item }));- },-};--export const runWqlQuery = createTrigger({- auth: workdayAuth,- name: 'run_wql_query',- classification: 'READ',- displayName: 'Run WQL Query',- description: 'Triggers when new records are returned by a Workday Query Language (WQL) query.',- aiMetadata: {- description:- 'Fires when a custom Workday Query Language (WQL) query returns rows newer than the last poll, judged by a caller-named date/timestamp field. General-purpose change detector for any Workday dataset; use when no dedicated trigger fits. The query must select a date column and you must name it in the Date Field input.',- },- props,- sampleData: { id: 'record-001', createdDate: '2026-04-01T10:00:00Z', descriptor: 'Sample Record' },- type: TriggerStrategy.POLLING,- async test(ctx) { return await pollingHelper.test(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },- async onEnable(ctx) { await pollingHelper.onEnable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async onDisable(ctx) { await pollingHelper.onDisable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async run(ctx) { return await pollingHelper.poll(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },-});diff --git a/packages/pieces/community/workday/src/lib/trigger/scheduled-report-fetch-batch.ts b/packages/pieces/community/workday/src/lib/trigger/scheduled-report-fetch-batch.tsdeleted file mode 100644index 98ba6c07f41..00000000000--- a/packages/pieces/community/workday/src/lib/trigger/scheduled-report-fetch-batch.ts+++ /dev/null@@ -1,115 +0,0 @@-import {- DedupeStrategy,- Polling,- QueryParams,- pollingHelper,-} from '@activepieces/pieces-common';-import {- AppConnectionValueForAuthProperty,- Property,- StaticPropsValue,- TriggerStrategy,- createTrigger,-} from '@activepieces/pieces-framework';-import dayjs from 'dayjs';-import { workdayAuth } from '../auth';-import { workdayGetReport } from '../common';-import { flattenRecord } from '../common/fields';-import { reportIdProperty } from '../common/props';--const props = {- reportId: reportIdProperty,- reportParameters: Property.Json({- displayName: 'Report Parameters (JSON)',- description: 'Optional report prompt values as JSON key-value pairs.',- required: false,- }),-};--const polling: Polling<- AppConnectionValueForAuthProperty<typeof workdayAuth>,- StaticPropsValue<typeof props>-> = {- strategy: DedupeStrategy.TIMEBASED,- items: async ({ auth, propsValue, lastFetchEpochMS }) => {- const isTest = lastFetchEpochMS === 0;- const report = await workdayGetReport(- auth,- propsValue.reportId,- propsValue.reportParameters as QueryParams | undefined,- );- const rows = Array.isArray(report['data'])- ? (report['data'] as Record<string, unknown>[])- : Array.isArray(report['Report_Entry'])- ? (report['Report_Entry'] as Record<string, unknown>[])- : [report];-- const limitedRows = isTest ? rows.slice(0, 10) : rows;- const flattened = limitedRows.map((row) => flattenRecord(row));- if (flattened.length === 0) {- return [];- }-- return [- {- epochMilliSeconds: Date.now(),- data: {- total_count: flattened.length,- records: flattened,- report_id: propsValue.reportId,- fetched_at: dayjs().toISOString(),- },- },- ];- },-};--export const scheduledReportFetchBatch = createTrigger({- auth: workdayAuth,- name: 'scheduled_report_fetch_batch',- classification: 'READ',- displayName: 'Scheduled Report Fetch (Batch)',- description:- 'Polls a Workday report on a schedule and returns all rows as a batch.',- aiMetadata: {- description:- 'Fires on every poll with the full row set of a published Workday custom report, identified by report ID or web service alias and optionally given prompt values as JSON. The whole report is re-fetched each cycle rather than only changed rows, so treat it as a scheduled extract, not a change feed. Use Scheduled Report Fetch using WQL (Batch) instead when the data comes from a WQL query.',- },- props,- sampleData: {- total_count: 1,- report_id: 'Worker_Report',- records: [{ employee_id: 'worker-001', name: 'Jane Doe' }],- },- type: TriggerStrategy.POLLING,- async test(ctx) {- return await pollingHelper.test(polling, {- auth: ctx.auth,- store: ctx.store,- propsValue: ctx.propsValue,- files: ctx.files,- });- },- async onEnable(ctx) {- await pollingHelper.onEnable(polling, {- auth: ctx.auth,- store: ctx.store,- propsValue: ctx.propsValue,- });- },- async onDisable(ctx) {- await pollingHelper.onDisable(polling, {- auth: ctx.auth,- store: ctx.store,- propsValue: ctx.propsValue,- });- },- async run(ctx) {- return await pollingHelper.poll(polling, {- auth: ctx.auth,- store: ctx.store,- propsValue: ctx.propsValue,- files: ctx.files,- });- },-});diff --git a/packages/pieces/community/workday/src/lib/trigger/triggers.test.ts b/packages/pieces/community/workday/src/lib/trigger/triggers.test.tsdeleted file mode 100644index 6d02411a7af..00000000000--- a/packages/pieces/community/workday/src/lib/trigger/triggers.test.ts+++ /dev/null@@ -1,167 +0,0 @@-import { HttpResponse, httpClient } from '@activepieces/pieces-common';-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';-import { newOrUpdatedBusinessObject } from './new-or-updated-business-object';-import { newOrUpdatedBusinessObjectBatch } from './new-or-updated-business-object-batch';-import { scheduledReportFetchBatch } from './scheduled-report-fetch-batch';-import { scheduledReportFetchWqlBatch } from './scheduled-report-fetch-wql-batch';--const AUTH = {- access_token: 'tok',- props: { apiHost: 'wd2-impl-services1.workday.com', tenant: 'mytenant' },-};--function resp(body: unknown): HttpResponse {- return { status: 200, headers: {}, body };-}--function makeStore(initial: Record<string, unknown> = {}) {- const data: Record<string, unknown> = { ...initial };- return {- get: async (key: string) => (key in data ? data[key] : undefined),- put: async (key: string, value: unknown) => {- data[key] = value;- return value;- },- delete: async (key: string) => {- delete data[key];- },- };-}--function triggerContext(- propsValue: Record<string, unknown>,- store: ReturnType<typeof makeStore>,-) {- return { auth: AUTH, store, propsValue, files: {} } as never;-}--let sendRequest: ReturnType<typeof vi.spyOn>;--beforeEach(() => {- sendRequest = vi.spyOn(httpClient, 'sendRequest');-});--afterEach(() => {- vi.restoreAllMocks();-});--describe('new_or_updated_business_object', () => {- it('test() returns standardized records', async () => {- sendRequest.mockResolvedValue(- resp({- data: [- {- id: 'r1',- title: 'Engineer',- applicationStatus: 'Open',- lastFunctionallyUpdated: '2025-06-01T00:00:00Z',- },- ],- }),- );-- const items = (await newOrUpdatedBusinessObject.test(- triggerContext(- {- module: 'recruiting',- businessObject: { objectType: 'jobRequisitions' },- dateField: 'lastFunctionallyUpdated',- additionalFilters: undefined,- },- makeStore(),- ),- )) as Record<string, unknown>[];-- expect(items).toHaveLength(1);- expect(items[0]).toMatchObject({ job_requisition_id: 'r1', application_status: 'Open' });- });-- it('run() returns only records newer than the last poll', async () => {- const lastPoll = Date.parse('2025-01-01T00:00:00Z');- sendRequest.mockResolvedValue(- resp({- data: [- { id: 'new', title: 'New', lastFunctionallyUpdated: '2025-06-01T00:00:00Z' },- { id: 'old', title: 'Old', lastFunctionallyUpdated: '2024-06-01T00:00:00Z' },- ],- }),- );-- const items = (await newOrUpdatedBusinessObject.run(- triggerContext(- {- module: 'recruiting',- businessObject: { objectType: 'jobRequisitions' },- dateField: 'lastFunctionallyUpdated',- additionalFilters: undefined,- },- makeStore({ lastPoll }),- ),- )) as Record<string, unknown>[];-- expect(items).toHaveLength(1);- expect(items[0]['job_requisition_id']).toBe('new');- });-});--describe('new_or_updated_business_object_batch', () => {- it('test() returns a single batch item with all records', async () => {- sendRequest.mockResolvedValue(- resp({- data: [- { id: 'r1', title: 'A', lastFunctionallyUpdated: '2025-06-01T00:00:00Z' },- { id: 'r2', title: 'B', lastFunctionallyUpdated: '2025-06-02T00:00:00Z' },- ],- }),- );-- const items = (await newOrUpdatedBusinessObjectBatch.test(- triggerContext(- {- module: 'recruiting',- businessObject: { objectType: 'jobRequisitions' },- dateField: 'lastFunctionallyUpdated',- additionalFilters: undefined,- },- makeStore(),- ),- )) as Array<{ total_count: number; records: Record<string, unknown>[] }>;-- expect(items).toHaveLength(1);- expect(items[0].total_count).toBe(2);- });-});--describe('scheduled_report_fetch_batch', () => {- it('test() returns the report rows as one batch', async () => {- sendRequest.mockResolvedValue(- resp({ Report_Entry: [{ employee_id: 'w-1' }, { employee_id: 'w-2' }] }),- );-- const items = (await scheduledReportFetchBatch.test(- triggerContext({ reportId: 'Worker_Report', reportParameters: undefined }, makeStore()),- )) as Array<{ total_count: number; report_id: string }>;-- expect(items).toHaveLength(1);- expect(items[0].total_count).toBe(2);- expect(items[0].report_id).toBe('Worker_Report');- });-});--describe('scheduled_report_fetch_wql_batch', () => {- it('test() returns WQL rows as one batch', async () => {- sendRequest.mockResolvedValue(- resp({ data: [{ employee_id: 'w-1', lastFunctionallyUpdated: '2025-06-01T00:00:00Z' }] }),- );-- const items = (await scheduledReportFetchWqlBatch.test(- triggerContext(- { query: 'SELECT employee_id FROM workers', dateField: 'lastFunctionallyUpdated' },- makeStore(),- ),- )) as Array<{ total_count: number }>;-- expect(items).toHaveLength(1);- expect(items[0].total_count).toBe(1);- });-});diff --git a/packages/pieces/community/workday/src/lib/trigger/updated-supplier.ts b/packages/pieces/community/workday/src/lib/trigger/updated-supplier.tsdeleted file mode 100644index 5d235945056..00000000000--- a/packages/pieces/community/workday/src/lib/trigger/updated-supplier.ts+++ /dev/null@@ -1,36 +0,0 @@-import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';-import { AppConnectionValueForAuthProperty, TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';-import { workdayAuth } from '../auth';-import { workdayWqlRequest } from '../common';--const polling: Polling<AppConnectionValueForAuthProperty<typeof workdayAuth>, Record<string, never>> = {- strategy: DedupeStrategy.LAST_ITEM,- items: async ({ auth }) => {- const response = await workdayWqlRequest<{ total: number; data: Array<Record<string, unknown>> }>(- auth,- `SELECT supplier, supplierName FROM suppliers LIMIT 100`,- );-- const items = response.body.data ?? [];- return items.map((item) => ({- id: JSON.stringify(item),- data: item,- }));- },-};--export const updatedSupplier = createTrigger({- auth: workdayAuth,- name: 'updated_supplier',- classification: 'READ',- displayName: 'Updated Supplier',- description: 'Triggers when a supplier is updated in Workday.',- aiMetadata: { description: 'Fires when an existing supplier record is updated in Workday (polling). Use to react to supplier changes such as contact, banking, or status updates.' },- props: {},- sampleData: { id: 'sup-001', descriptor: 'Acme Corp', lastUpdated: '2026-04-01T10:00:00Z' },- type: TriggerStrategy.POLLING,- async test(ctx) { return await pollingHelper.test(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },- async onEnable(ctx) { await pollingHelper.onEnable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async onDisable(ctx) { await pollingHelper.onDisable(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue }); },- async run(ctx) { return await pollingHelper.poll(polling, { auth: ctx.auth, store: ctx.store, propsValue: ctx.propsValue, files: ctx.files }); },-});diff --git a/packages/pieces/community/workday/src/lib/triggers/business-process-completed.ts b/packages/pieces/community/workday/src/lib/triggers/business-process-completed.tsnew file mode 100644index 00000000000..e7833a0aafb--- /dev/null+++ b/packages/pieces/community/workday/src/lib/triggers/business-process-completed.ts@@ -0,0 +1,67 @@+import dayjs from 'dayjs';++import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';+import {+ AppConnectionValueForAuthProperty,+ TriggerStrategy,+ createTrigger,+} from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';+import { workdayUtils } from '../common/utils';++const polling: Polling<+ AppConnectionValueForAuthProperty<typeof workdayAuth>,+ Record<string, never>+> = {+ strategy: DedupeStrategy.TIMEBASED,+ items: async ({ auth, lastFetchEpochMS }) => {+ const rows = await workdayApi.listBusinessProcessTransactions({+ auth,+ momentField: 'dateAndTimeCompleted',+ sinceEpochMS: lastFetchEpochMS,+ completedOnly: true,+ });+ return rows.map((row) => ({+ epochMilliSeconds: dayjs(String(row['dateAndTimeCompleted'])).valueOf(),+ data: {+ id: workdayUtils.readNestedId({ value: row['businessProcessEvent'] }),+ descriptor: workdayUtils.readNestedDescriptor({ value: row['businessProcessEvent'] }),+ completedDate: row['dateAndTimeCompleted'],+ ...row,+ },+ }));+ },+};++export const businessProcessCompletedTrigger = createTrigger({+ auth: workdayAuth,+ name: 'business_process_completed',+ classification: 'READ',+ displayName: 'Business Process Event Completed',+ description: 'Triggers when a business process event is completed in Workday.',+ aiMetadata: {+ description:+ 'Fires when a Workday business process completes (e.g. a hire, change-job, or approval workflow reaches its end state), detected by polling business process transactions with status Successfully Completed by their completion time. Use to run downstream automation once a Workday workflow finishes.',+ },+ props: {},+ sampleData: {+ id: 'bp-001',+ descriptor: 'Hire: John Smith',+ completedDate: '2026-04-01T14:30:00Z',+ },+ type: TriggerStrategy.POLLING,+ async test(context) {+ return await pollingHelper.test(polling, context);+ },+ async onEnable(context) {+ await pollingHelper.onEnable(polling, context);+ },+ async onDisable(context) {+ await pollingHelper.onDisable(polling, context);+ },+ async run(context) {+ return await pollingHelper.poll(polling, context);+ },+});diff --git a/packages/pieces/community/workday/src/lib/triggers/employee-terminated.ts b/packages/pieces/community/workday/src/lib/triggers/employee-terminated.tsnew file mode 100644index 00000000000..2e3b7fa8ed9--- /dev/null+++ b/packages/pieces/community/workday/src/lib/triggers/employee-terminated.ts@@ -0,0 +1,64 @@+import dayjs from 'dayjs';++import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';+import {+ AppConnectionValueForAuthProperty,+ TriggerStrategy,+ createTrigger,+} from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';+import { workdayUtils } from '../common/utils';++const polling: Polling<+ AppConnectionValueForAuthProperty<typeof workdayAuth>,+ Record<string, never>+> = {+ strategy: DedupeStrategy.TIMEBASED,+ items: async ({ auth, lastFetchEpochMS }) => {+ const rows = await workdayApi.listTerminations({ auth, sinceEpochMS: lastFetchEpochMS });+ return rows.map((row) => {+ return {+ epochMilliSeconds: dayjs(String(row['dateAndTimeCompleted'])).valueOf(),+ data: {+ id: workdayUtils.readNestedId({ value: row['worker'] }),+ descriptor: workdayUtils.readNestedDescriptor({ value: row['worker'] }),+ terminationDate: row['effectiveDate'],+ ...row,+ },+ };+ });+ },+};++export const employeeTerminatedTrigger = createTrigger({+ auth: workdayAuth,+ name: 'employee_terminated',+ classification: 'READ',+ displayName: 'Employee Terminated',+ description: 'Triggers when an employee is terminated in Workday.',+ aiMetadata: {+ description:+ 'Fires for each worker whose termination is recorded in Workday after the trigger was enabled, detected by polling workers by termination date. Represents an employee offboarding event. Use to drive offboarding workflows (access revocation, notifications).',+ },+ props: {},+ sampleData: {+ id: '3aa5550b7fe348b98d7b5741afc65534',+ descriptor: 'Jane Doe',+ terminationDate: '2026-04-01',+ },+ type: TriggerStrategy.POLLING,+ async test(context) {+ return await pollingHelper.test(polling, context);+ },+ async onEnable(context) {+ await pollingHelper.onEnable(polling, context);+ },+ async onDisable(context) {+ await pollingHelper.onDisable(polling, context);+ },+ async run(context) {+ return await pollingHelper.poll(polling, context);+ },+});diff --git a/packages/pieces/community/workday/src/lib/triggers/expense-report-submitted.ts b/packages/pieces/community/workday/src/lib/triggers/expense-report-submitted.tsnew file mode 100644index 00000000000..92aa7b04232--- /dev/null+++ b/packages/pieces/community/workday/src/lib/triggers/expense-report-submitted.ts@@ -0,0 +1,69 @@+import dayjs from 'dayjs';++import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';+import {+ AppConnectionValueForAuthProperty,+ TriggerStrategy,+ createTrigger,+} from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';+import { workdayUtils } from '../common/utils';++const polling: Polling<+ AppConnectionValueForAuthProperty<typeof workdayAuth>,+ Record<string, never>+> = {+ strategy: DedupeStrategy.TIMEBASED,+ items: async ({ auth, lastFetchEpochMS }) => {+ const rows = await workdayApi.listBusinessProcessTransactions({+ auth,+ momentField: 'dateAndTimeInitiated',+ sinceEpochMS: lastFetchEpochMS,+ typeIds: [EXPENSE_REPORT_EVENT_TYPE_ID],+ });+ return rows.map((row) => ({+ epochMilliSeconds: dayjs(String(row['dateAndTimeInitiated'])).valueOf(),+ data: {+ id: workdayUtils.readNestedId({ value: row['businessProcessEvent'] }),+ descriptor: workdayUtils.readNestedDescriptor({ value: row['businessProcessEvent'] }),+ createdDate: row['dateAndTimeInitiated'],+ ...row,+ },+ }));+ },+};++export const expenseReportSubmittedTrigger = createTrigger({+ auth: workdayAuth,+ name: 'expense_report_submitted',+ classification: 'READ',+ displayName: 'Expense Report Submitted',+ description: 'Triggers when an expense report is submitted in Workday.',+ aiMetadata: {+ description:+ 'Fires when an expense report is submitted in Workday, detected by polling Expense Report Event business process transactions by their initiation time. Represents an expense submission event. Use to start expense review or reimbursement automation.',+ },+ props: {},+ sampleData: {+ id: 'exp-001',+ descriptor: 'Q1 Travel Expenses',+ createdDate: '2026-04-01T09:00:00Z',+ },+ type: TriggerStrategy.POLLING,+ async test(context) {+ return await pollingHelper.test(polling, context);+ },+ async onEnable(context) {+ await pollingHelper.onEnable(polling, context);+ },+ async onDisable(context) {+ await pollingHelper.onDisable(polling, context);+ },+ async run(context) {+ return await pollingHelper.poll(polling, context);+ },+});++const EXPENSE_REPORT_EVENT_TYPE_ID = '77705ce8252a4a089feff77ee9c8417e';diff --git a/packages/pieces/community/workday/src/lib/triggers/leave-request-submitted.ts b/packages/pieces/community/workday/src/lib/triggers/leave-request-submitted.tsnew file mode 100644index 00000000000..782f52d0310--- /dev/null+++ b/packages/pieces/community/workday/src/lib/triggers/leave-request-submitted.ts@@ -0,0 +1,70 @@+import dayjs from 'dayjs';++import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';+import {+ AppConnectionValueForAuthProperty,+ TriggerStrategy,+ createTrigger,+} from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';+import { workdayUtils } from '../common/utils';++const polling: Polling<+ AppConnectionValueForAuthProperty<typeof workdayAuth>,+ Record<string, never>+> = {+ strategy: DedupeStrategy.TIMEBASED,+ items: async ({ auth, lastFetchEpochMS }) => {+ const rows = await workdayApi.listBusinessProcessTransactions({+ auth,+ momentField: 'dateAndTimeInitiated',+ sinceEpochMS: lastFetchEpochMS,+ typeIds: [REQUEST_TIME_OFF_TYPE_ID, REQUEST_LEAVE_OF_ABSENCE_TYPE_ID],+ });+ return rows.map((row) => ({+ epochMilliSeconds: dayjs(String(row['dateAndTimeInitiated'])).valueOf(),+ data: {+ id: workdayUtils.readNestedId({ value: row['businessProcessEvent'] }),+ descriptor: workdayUtils.readNestedDescriptor({ value: row['businessProcessEvent'] }),+ createdDate: row['dateAndTimeInitiated'],+ ...row,+ },+ }));+ },+};++export const leaveRequestSubmittedTrigger = createTrigger({+ auth: workdayAuth,+ name: 'leave_request_submitted',+ classification: 'READ',+ displayName: 'Leave Request Submitted',+ description: 'Triggers when a leave request is submitted in Workday.',+ aiMetadata: {+ description:+ 'Fires when a time-off or leave-of-absence request is submitted in Workday, detected by polling Request Time Off and Request Leave of Absence business process transactions by their initiation time. Use to start leave approval or coverage-planning automation.',+ },+ props: {},+ sampleData: {+ id: 'lr-001',+ descriptor: 'Vacation Request - John Smith',+ createdDate: '2026-04-01T11:00:00Z',+ },+ type: TriggerStrategy.POLLING,+ async test(context) {+ return await pollingHelper.test(polling, context);+ },+ async onEnable(context) {+ await pollingHelper.onEnable(polling, context);+ },+ async onDisable(context) {+ await pollingHelper.onDisable(polling, context);+ },+ async run(context) {+ return await pollingHelper.poll(polling, context);+ },+});++const REQUEST_TIME_OFF_TYPE_ID = '6e3795247ebf4915bbb22924af08119f';+const REQUEST_LEAVE_OF_ABSENCE_TYPE_ID = '1d07c509cca34688b3fb9c0c3dba4789';diff --git a/packages/pieces/community/workday/src/lib/triggers/new-hire-created.ts b/packages/pieces/community/workday/src/lib/triggers/new-hire-created.tsnew file mode 100644index 00000000000..2d325611c37--- /dev/null+++ b/packages/pieces/community/workday/src/lib/triggers/new-hire-created.ts@@ -0,0 +1,63 @@+import dayjs from 'dayjs';++import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';+import {+ AppConnectionValueForAuthProperty,+ TriggerStrategy,+ createTrigger,+} from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';+import { workdayUtils } from '../common/utils';++const polling: Polling<+ AppConnectionValueForAuthProperty<typeof workdayAuth>,+ Record<string, never>+> = {+ strategy: DedupeStrategy.TIMEBASED,+ items: async ({ auth, lastFetchEpochMS }) => {+ const rows = await workdayApi.listNewHires({ auth, sinceEpochMS: lastFetchEpochMS });+ return rows.map((row) => {+ return {+ epochMilliSeconds: dayjs(String(row['createdMoment'])).valueOf(),+ data: {+ id: workdayUtils.readNestedId({ value: row['worker'] }),+ descriptor: workdayUtils.readNestedDescriptor({ value: row['worker'] }),+ ...row,+ },+ };+ });+ },+};++export const newHireCreatedTrigger = createTrigger({+ auth: workdayAuth,+ name: 'new_hire_created',+ classification: 'READ',+ displayName: 'New Hire Created',+ description: 'Triggers when a new employee is hired in Workday.',+ aiMetadata: {+ description:+ 'Fires for each worker hired in Workday after the trigger was enabled, detected by polling workers by hire date. Represents an employee onboarding event. Use to drive onboarding workflows (account provisioning, welcome notifications).',+ },+ props: {},+ sampleData: {+ id: '3aa5550b7fe348b98d7b5741afc65534',+ descriptor: 'John Smith',+ hireDate: '2026-04-01',+ },+ type: TriggerStrategy.POLLING,+ async test(context) {+ return await pollingHelper.test(polling, context);+ },+ async onEnable(context) {+ await pollingHelper.onEnable(polling, context);+ },+ async onDisable(context) {+ await pollingHelper.onDisable(polling, context);+ },+ async run(context) {+ return await pollingHelper.poll(polling, context);+ },+});diff --git a/packages/pieces/community/workday/src/lib/triggers/new-inbox-task.ts b/packages/pieces/community/workday/src/lib/triggers/new-inbox-task.tsnew file mode 100644index 00000000000..8eced900843--- /dev/null+++ b/packages/pieces/community/workday/src/lib/triggers/new-inbox-task.ts@@ -0,0 +1,54 @@+import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';+import {+ AppConnectionValueForAuthProperty,+ TriggerStrategy,+ createTrigger,+} from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';++const polling: Polling<+ AppConnectionValueForAuthProperty<typeof workdayAuth>,+ Record<string, never>+> = {+ strategy: DedupeStrategy.LAST_ITEM,+ items: async ({ auth }) => {+ const items = await workdayApi.listInboxTasks({ auth });+ return items.map((item) => ({+ id: JSON.stringify(item),+ data: item,+ }));+ },+};++export const newInboxTaskTrigger = createTrigger({+ auth: workdayAuth,+ name: 'new_inbox_task',+ classification: 'READ',+ displayName: 'New Inbox Task',+ description: 'Triggers when a new inbox task is assigned in Workday.',+ aiMetadata: {+ description:+ 'Fires when a new business-process task awaiting the connected user’s action appears in their Workday inbox, detected by polling transactions awaiting action. Represents a pending approval/review assignment. Use to auto-handle or notify on incoming Workday tasks (pair with the Approve Task action).',+ },+ props: {},+ sampleData: {+ id: 'task-001',+ descriptor: 'Approve Time Off Request',+ assignedDate: '2026-04-01T08:00:00Z',+ },+ type: TriggerStrategy.POLLING,+ async test(context) {+ return await pollingHelper.test(polling, context);+ },+ async onEnable(context) {+ await pollingHelper.onEnable(polling, context);+ },+ async onDisable(context) {+ await pollingHelper.onDisable(polling, context);+ },+ async run(context) {+ return await pollingHelper.poll(polling, context);+ },+});diff --git a/packages/pieces/community/workday/src/lib/trigger/new-or-updated-business-object-batch.ts b/packages/pieces/community/workday/src/lib/triggers/new-or-updated-business-object-batch.tssimilarity index 50%rename from packages/pieces/community/workday/src/lib/trigger/new-or-updated-business-object-batch.tsrename to packages/pieces/community/workday/src/lib/triggers/new-or-updated-business-object-batch.tsindex 42c925f5953..c0c06daacde 100644--- a/packages/pieces/community/workday/src/lib/trigger/new-or-updated-business-object-batch.ts+++ b/packages/pieces/community/workday/src/lib/triggers/new-or-updated-business-object-batch.ts@@ -1,10 +1,6 @@-import {- DedupeStrategy,- HttpMethod,- Polling,- QueryParams,- pollingHelper,-} from '@activepieces/pieces-common';+import dayjs from 'dayjs';++import { DedupeStrategy, Polling, QueryParams, pollingHelper } from '@activepieces/pieces-common';import {AppConnectionValueForAuthProperty,Property,@@ -12,16 +8,16 @@ import {TriggerStrategy,createTrigger,} from '@activepieces/pieces-framework';-import dayjs from 'dayjs';+import { workdayAuth } from '../auth';-import { fetchAllPages, workdayRequest } from '../common';-import { formatWorkdayOutputs, getRecordTimestamp } from '../common/fields';-import { resolveBusinessObject, toWorkdayModule } from '../common/modules';-import { dateFieldProperty, sharedModuleProps } from '../common/props';+import { workdayApi } from '../common/api';+import { workdayProps } from '../common/props';+import { workdayUtils } from '../common/utils';const props = {- ...sharedModuleProps,- dateField: dateFieldProperty,+ module: workdayProps.module({ required: true }),+ businessObject: workdayProps.businessObject({ required: true }),+ dateField: workdayProps.dateField({ required: false }),additionalFilters: Property.Json({displayName: 'Additional Filters (JSON)',required: false,@@ -34,17 +30,10 @@ const polling: Polling<> = {strategy: DedupeStrategy.TIMEBASED,items: async ({ auth, propsValue, lastFetchEpochMS }) => {- const bo = propsValue.businessObject as {- objectType?: string;- customPath?: string;- customService?: string;- };- const config = resolveBusinessObject(- propsValue.module,- bo.objectType,- bo.customPath,- bo.customService,- );+ const businessObject = workdayUtils.resolveBusinessObject({+ module: propsValue.module,+ selection: propsValue.businessObject,+ });const isTest = lastFetchEpochMS === 0;const updatedAfter = isTest? dayjs().subtract(7, 'day').toISOString()@@ -52,36 +41,25 @@ const polling: Polling<const queryParams: QueryParams = {updatedSince: updatedAfter,- ...(propsValue.additionalFilters as Record<string, string> | undefined),+ ...workdayUtils.toQueryParams({ value: propsValue.additionalFilters }),};const records = isTest- ? (- await workdayRequest<{ data?: Record<string, unknown>[] }>(- auth,- HttpMethod.GET,- config.path,- undefined,- { ...queryParams, limit: '10' },- config.service,- )- ).body.data ?? []- : await fetchAllPages<Record<string, unknown>>(+ ? await workdayApi.listBusinessObjects({auth,- config.path,- queryParams,- 'data',- config.service,- );+ businessObject,+ query: { ...queryParams, limit: '10' },+ })+ : await workdayApi.searchBusinessObjects({ auth, businessObject, query: queryParams });- const module = toWorkdayModule(propsValue.module);- const formatted = formatWorkdayOutputs(records, module);+ const module = workdayUtils.toWorkdayModule({ module: propsValue.module });+ const formatted = workdayUtils.formatOutputs({ records, module });if (formatted.length === 0) {return [];}const latestTimestamp = formatted.reduce((latest, record) => {- const raw = getRecordTimestamp(record, propsValue.dateField);+ const raw = workdayUtils.getRecordTimestamp({ record, preferredField: propsValue.dateField });const value = raw ? dayjs(raw).valueOf() : 0;return Math.max(latest, value);}, 0);@@ -98,13 +76,12 @@ const polling: Polling<},};-export const newOrUpdatedBusinessObjectBatch = createTrigger({+export const newOrUpdatedBusinessObjectBatchTrigger = createTrigger({auth: workdayAuth,name: 'new_or_updated_business_object_batch',classification: 'READ',displayName: 'New/Updated Business Object (Batch)',- description:- 'Triggers with a batch of new or updated business objects in a single poll cycle.',+ description: 'Triggers with a batch of new or updated business objects in a single poll cycle.',aiMetadata: {description:'Fires once per poll cycle carrying every Workday business object created or changed since the previous poll as a single batch, for the module (Recruiting, Onboarding, or HR Services & Time Tracking) and object type selected, or for a custom REST path. Recency is judged by a configurable date field, defaulting to lastFunctionallyUpdated. Use when the whole changed set should be processed at once instead of one flow run per record.',@@ -122,34 +99,16 @@ export const newOrUpdatedBusinessObjectBatch = createTrigger({],},type: TriggerStrategy.POLLING,- async test(ctx) {- return await pollingHelper.test(polling, {- auth: ctx.auth,- store: ctx.store,- propsValue: ctx.propsValue,- files: ctx.files,- });+ async test(context) {+ return await pollingHelper.test(polling, context);},- async onEnable(ctx) {- await pollingHelper.onEnable(polling, {- auth: ctx.auth,- store: ctx.store,- propsValue: ctx.propsValue,- });+ async onEnable(context) {+ await pollingHelper.onEnable(polling, context);},- async onDisable(ctx) {- await pollingHelper.onDisable(polling, {- auth: ctx.auth,- store: ctx.store,- propsValue: ctx.propsValue,- });+ async onDisable(context) {+ await pollingHelper.onDisable(polling, context);},- async run(ctx) {- return await pollingHelper.poll(polling, {- auth: ctx.auth,- store: ctx.store,- propsValue: ctx.propsValue,- files: ctx.files,- });+ async run(context) {+ return await pollingHelper.poll(polling, context);},});diff --git a/packages/pieces/community/workday/src/lib/trigger/new-or-updated-business-object.ts b/packages/pieces/community/workday/src/lib/triggers/new-or-updated-business-object.tssimilarity index 53%rename from packages/pieces/community/workday/src/lib/trigger/new-or-updated-business-object.tsrename to packages/pieces/community/workday/src/lib/triggers/new-or-updated-business-object.tsindex 3f9c02f1783..a83281c7304 100644--- a/packages/pieces/community/workday/src/lib/trigger/new-or-updated-business-object.ts+++ b/packages/pieces/community/workday/src/lib/triggers/new-or-updated-business-object.ts@@ -1,10 +1,6 @@-import {- DedupeStrategy,- HttpMethod,- Polling,- QueryParams,- pollingHelper,-} from '@activepieces/pieces-common';+import dayjs from 'dayjs';++import { DedupeStrategy, Polling, QueryParams, pollingHelper } from '@activepieces/pieces-common';import {AppConnectionValueForAuthProperty,Property,@@ -12,16 +8,16 @@ import {TriggerStrategy,createTrigger,} from '@activepieces/pieces-framework';-import dayjs from 'dayjs';+import { workdayAuth } from '../auth';-import { workdayRequest } from '../common';-import { formatWorkdayOutput, getRecordTimestamp } from '../common/fields';-import { resolveBusinessObject, toWorkdayModule } from '../common/modules';-import { dateFieldProperty, sharedModuleProps } from '../common/props';+import { workdayApi } from '../common/api';+import { workdayProps } from '../common/props';+import { workdayUtils } from '../common/utils';const props = {- ...sharedModuleProps,- dateField: dateFieldProperty,+ module: workdayProps.module({ required: true }),+ businessObject: workdayProps.businessObject({ required: true }),+ dateField: workdayProps.dateField({ required: false }),additionalFilters: Property.Json({displayName: 'Additional Filters (JSON)',required: false,@@ -34,18 +30,11 @@ const polling: Polling<> = {strategy: DedupeStrategy.TIMEBASED,items: async ({ auth, propsValue, lastFetchEpochMS }) => {- const bo = propsValue.businessObject as {- objectType?: string;- customPath?: string;- customService?: string;- };- const config = resolveBusinessObject(- propsValue.module,- bo.objectType,- bo.customPath,- bo.customService,- );- const module = toWorkdayModule(propsValue.module);+ const businessObject = workdayUtils.resolveBusinessObject({+ module: propsValue.module,+ selection: propsValue.businessObject,+ });+ const module = workdayUtils.toWorkdayModule({ module: propsValue.module });const isTest = lastFetchEpochMS === 0;const updatedAfter = isTest? dayjs().subtract(7, 'day').toISOString()@@ -53,33 +42,29 @@ const polling: Polling<const queryParams: QueryParams = {updatedSince: updatedAfter,- ...(propsValue.additionalFilters as Record<string, string> | undefined),+ ...workdayUtils.toQueryParams({ value: propsValue.additionalFilters }),};queryParams['limit'] = isTest ? '10' : '50';- const response = await workdayRequest<{ data?: Record<string, unknown>[] }>(+ const records = await workdayApi.listBusinessObjects({auth,- HttpMethod.GET,- config.path,- undefined,- queryParams,- config.service,- );- const records = response.body.data ?? [];+ businessObject,+ query: queryParams,+ });return records.map((record) => {const timestamp =- getRecordTimestamp(record, propsValue.dateField) ??+ workdayUtils.getRecordTimestamp({ record, preferredField: propsValue.dateField }) ??new Date().toISOString();return {epochMilliSeconds: dayjs(timestamp).valueOf(),- data: formatWorkdayOutput(record, module),+ data: workdayUtils.formatOutput({ record, module }),};});},};-export const newOrUpdatedBusinessObject = createTrigger({+export const newOrUpdatedBusinessObjectTrigger = createTrigger({auth: workdayAuth,name: 'new_or_updated_business_object',classification: 'READ',@@ -99,34 +84,16 @@ export const newOrUpdatedBusinessObject = createTrigger({application_status: 'In Progress',},type: TriggerStrategy.POLLING,- async test(ctx) {- return await pollingHelper.test(polling, {- auth: ctx.auth,- store: ctx.store,- propsValue: ctx.propsValue,- files: ctx.files,- });+ async test(context) {+ return await pollingHelper.test(polling, context);},- async onEnable(ctx) {- await pollingHelper.onEnable(polling, {- auth: ctx.auth,- store: ctx.store,- propsValue: ctx.propsValue,- });+ async onEnable(context) {+ await pollingHelper.onEnable(polling, context);},- async onDisable(ctx) {- await pollingHelper.onDisable(polling, {- auth: ctx.auth,- store: ctx.store,- propsValue: ctx.propsValue,- });+ async onDisable(context) {+ await pollingHelper.onDisable(polling, context);},- async run(ctx) {- return await pollingHelper.poll(polling, {- auth: ctx.auth,- store: ctx.store,- propsValue: ctx.propsValue,- files: ctx.files,- });+ async run(context) {+ return await pollingHelper.poll(polling, context);},});diff --git a/packages/pieces/community/workday/src/lib/triggers/new-supplier-invoice.ts b/packages/pieces/community/workday/src/lib/triggers/new-supplier-invoice.tsnew file mode 100644index 00000000000..b51d496cb2d--- /dev/null+++ b/packages/pieces/community/workday/src/lib/triggers/new-supplier-invoice.ts@@ -0,0 +1,69 @@+import dayjs from 'dayjs';++import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';+import {+ AppConnectionValueForAuthProperty,+ TriggerStrategy,+ createTrigger,+} from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';+import { workdayUtils } from '../common/utils';++const polling: Polling<+ AppConnectionValueForAuthProperty<typeof workdayAuth>,+ Record<string, never>+> = {+ strategy: DedupeStrategy.TIMEBASED,+ items: async ({ auth, lastFetchEpochMS }) => {+ const rows = await workdayApi.listBusinessProcessTransactions({+ auth,+ momentField: 'dateAndTimeInitiated',+ sinceEpochMS: lastFetchEpochMS,+ typeIds: [SUPPLIER_INVOICE_EVENT_TYPE_ID],+ });+ return rows.map((row) => ({+ epochMilliSeconds: dayjs(String(row['dateAndTimeInitiated'])).valueOf(),+ data: {+ id: workdayUtils.readNestedId({ value: row['subject'] }),+ descriptor: workdayUtils.readNestedDescriptor({ value: row['subject'] }),+ createdDate: row['dateAndTimeInitiated'],+ ...row,+ },+ }));+ },+};++export const newSupplierInvoiceTrigger = createTrigger({+ auth: workdayAuth,+ name: 'new_supplier_invoice',+ classification: 'READ',+ displayName: 'New Supplier Invoice',+ description: 'Triggers when a new supplier invoice is created in Workday.',+ aiMetadata: {+ description:+ 'Fires when a new supplier invoice is created in Workday, detected by polling Supplier Invoice Event business process transactions by their initiation time. Represents a supplier-invoice creation event. Use to route invoices into approval, accounting, or payment automation.',+ },+ props: {},+ sampleData: {+ id: 'inv-001',+ descriptor: 'Invoice #12345 - Acme Corp',+ createdDate: '2026-04-01T12:00:00Z',+ },+ type: TriggerStrategy.POLLING,+ async test(context) {+ return await pollingHelper.test(polling, context);+ },+ async onEnable(context) {+ await pollingHelper.onEnable(polling, context);+ },+ async onDisable(context) {+ await pollingHelper.onDisable(polling, context);+ },+ async run(context) {+ return await pollingHelper.poll(polling, context);+ },+});++const SUPPLIER_INVOICE_EVENT_TYPE_ID = '48b49c6d25a74247b7b9d0d6f6593d72';diff --git a/packages/pieces/community/workday/src/lib/triggers/new-supplier.ts b/packages/pieces/community/workday/src/lib/triggers/new-supplier.tsnew file mode 100644index 00000000000..c9958952cf7--- /dev/null+++ b/packages/pieces/community/workday/src/lib/triggers/new-supplier.ts@@ -0,0 +1,65 @@+import dayjs from 'dayjs';++import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';+import {+ AppConnectionValueForAuthProperty,+ TriggerStrategy,+ createTrigger,+} from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';+import { workdayUtils } from '../common/utils';++const polling: Polling<+ AppConnectionValueForAuthProperty<typeof workdayAuth>,+ Record<string, never>+> = {+ strategy: DedupeStrategy.TIMEBASED,+ items: async ({ auth, lastFetchEpochMS }) => {+ const rows = await workdayApi.listBusinessProcessTransactions({+ auth,+ momentField: 'dateAndTimeInitiated',+ sinceEpochMS: lastFetchEpochMS,+ typeIds: [SUPPLIER_EVENT_TYPE_ID],+ });+ return rows.map((row) => ({+ epochMilliSeconds: dayjs(String(row['dateAndTimeInitiated'])).valueOf(),+ data: {+ id: workdayUtils.readNestedId({ value: row['subject'] }),+ descriptor: workdayUtils.readNestedDescriptor({ value: row['subject'] }),+ createdDate: row['dateAndTimeInitiated'],+ ...row,+ },+ }));+ },+};++export const newSupplierTrigger = createTrigger({+ auth: workdayAuth,+ name: 'new_supplier',+ classification: 'READ',+ displayName: 'New Supplier',+ description: 'Triggers when a new supplier is created in Workday.',+ aiMetadata: {+ description:+ 'Fires when a new supplier is created in Workday, detected by polling Supplier Event business process transactions by their initiation time. Represents a supplier-creation event. Use to sync new vendors into downstream systems or kick off supplier onboarding.',+ },+ props: {},+ sampleData: { id: 'sup-001', descriptor: 'Acme Corp', createdDate: '2026-04-01T10:00:00Z' },+ type: TriggerStrategy.POLLING,+ async test(context) {+ return await pollingHelper.test(polling, context);+ },+ async onEnable(context) {+ await pollingHelper.onEnable(polling, context);+ },+ async onDisable(context) {+ await pollingHelper.onDisable(polling, context);+ },+ async run(context) {+ return await pollingHelper.poll(polling, context);+ },+});++const SUPPLIER_EVENT_TYPE_ID = 'fbb860b6147b1000101faa99aeb40004';diff --git a/packages/pieces/community/workday/src/lib/triggers/run-wql-query.ts b/packages/pieces/community/workday/src/lib/triggers/run-wql-query.tsnew file mode 100644index 00000000000..1dffbd95e08--- /dev/null+++ b/packages/pieces/community/workday/src/lib/triggers/run-wql-query.ts@@ -0,0 +1,78 @@+import dayjs from 'dayjs';++import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';+import {+ AppConnectionValueForAuthProperty,+ Property,+ StaticPropsValue,+ TriggerStrategy,+ createTrigger,+} from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';++const props = {+ query: Property.LongText({+ displayName: 'WQL Query',+ description:+ 'The Workday Query Language (WQL) query to execute. Must include a date/timestamp column for deduplication.',+ required: true,+ }),+ dateField: Property.ShortText({+ displayName: 'Date Field Name',+ description:+ 'The name of the date/timestamp field in your query results used for detecting new records (e.g., "createdDate").',+ required: true,+ defaultValue: 'createdDate',+ }),+};++const polling: Polling<+ AppConnectionValueForAuthProperty<typeof workdayAuth>,+ StaticPropsValue<typeof props>+> = {+ strategy: DedupeStrategy.TIMEBASED,+ items: async ({ auth, propsValue, lastFetchEpochMS }) => {+ const page = await workdayApi.runWql({ auth, query: propsValue.query });+ const dateField = propsValue.dateField;+ const items = page.data ?? [];+ return items.flatMap((item) => {+ const dateValue = item[dateField];+ if (typeof dateValue !== 'string') return [];+ const epochMilliSeconds = dayjs(dateValue).valueOf();+ return epochMilliSeconds > lastFetchEpochMS ? [{ epochMilliSeconds, data: item }] : [];+ });+ },+};++export const runWqlQueryTrigger = createTrigger({+ auth: workdayAuth,+ name: 'run_wql_query',+ classification: 'READ',+ displayName: 'Run WQL Query',+ description: 'Triggers when new records are returned by a Workday Query Language (WQL) query.',+ aiMetadata: {+ description:+ 'Fires when a custom Workday Query Language (WQL) query returns rows newer than the last poll, judged by a caller-named date/timestamp field. General-purpose change detector for any Workday dataset; use when no dedicated trigger fits. The query must select a date column and you must name it in the Date Field input.',+ },+ props,+ sampleData: {+ id: 'record-001',+ createdDate: '2026-04-01T10:00:00Z',+ descriptor: 'Sample Record',+ },+ type: TriggerStrategy.POLLING,+ async test(context) {+ return await pollingHelper.test(polling, context);+ },+ async onEnable(context) {+ await pollingHelper.onEnable(polling, context);+ },+ async onDisable(context) {+ await pollingHelper.onDisable(polling, context);+ },+ async run(context) {+ return await pollingHelper.poll(polling, context);+ },+});diff --git a/packages/pieces/community/workday/src/lib/triggers/scheduled-report-fetch-batch.ts b/packages/pieces/community/workday/src/lib/triggers/scheduled-report-fetch-batch.tsnew file mode 100644index 00000000000..0dafb9a8b0b--- /dev/null+++ b/packages/pieces/community/workday/src/lib/triggers/scheduled-report-fetch-batch.ts@@ -0,0 +1,84 @@+import dayjs from 'dayjs';++import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';+import {+ AppConnectionValueForAuthProperty,+ StaticPropsValue,+ TriggerStrategy,+ createTrigger,+} from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';+import { workdayProps } from '../common/props';+import { workdayUtils } from '../common/utils';++const props = {+ reportId: workdayProps.reportId({ required: true }),+ reportParameters: workdayProps.reportParameters({ required: false }),+};++const polling: Polling<+ AppConnectionValueForAuthProperty<typeof workdayAuth>,+ StaticPropsValue<typeof props>+> = {+ strategy: DedupeStrategy.TIMEBASED,+ items: async ({ auth, propsValue, lastFetchEpochMS }) => {+ const isTest = lastFetchEpochMS === 0;+ const report = await workdayApi.getReport({+ auth,+ report: propsValue.reportId,+ parameters: propsValue.reportParameters,+ });+ const rows = report.format === 'json' ? report.rows : [];++ const limitedRows = isTest ? rows.slice(0, 10) : rows;+ const flattened = limitedRows.map((row) => workdayUtils.flattenRecord({ value: row }));+ if (flattened.length === 0) {+ return [];+ }++ return [+ {+ epochMilliSeconds: Date.now(),+ data: {+ total_count: flattened.length,+ records: flattened,+ report_id: report.reportPath,+ fetched_at: dayjs().toISOString(),+ },+ },+ ];+ },+};++export const scheduledReportFetchBatchTrigger = createTrigger({+ auth: workdayAuth,+ name: 'scheduled_report_fetch_batch',+ classification: 'READ',+ displayName: 'Scheduled Report Fetch (Batch)',+ description: 'Polls a Workday report on a schedule and returns all rows as a batch.',+ aiMetadata: {+ description:+ 'Fires on every poll with the full row set of a Workday custom report enabled as a web service (RaaS), identified by its RaaS URL or `owner/report_name` and optionally given prompt values keyed by prompt XML alias. The whole report is re-fetched each cycle rather than only changed rows, so treat it as a scheduled extract, not a change feed. Use Scheduled Report Fetch using WQL (Batch) instead when the data comes from a WQL query.',+ },+ props,+ sampleData: {+ total_count: 1,+ report_id: 'lmcneil/PT_Workers',+ records: [{ employee_id: 'worker-001', name: 'Jane Doe' }],+ },+ type: TriggerStrategy.POLLING,+ async test(context) {+ return await pollingHelper.test(polling, context);+ },+ async onEnable(context) {+ await pollingHelper.onEnable(polling, context);+ },+ async onDisable(context) {+ await pollingHelper.onDisable(polling, context);+ },+ async run(context) {+ return await pollingHelper.poll(polling, context);+ },+});diff --git a/packages/pieces/community/workday/src/lib/trigger/scheduled-report-fetch-wql-batch.ts b/packages/pieces/community/workday/src/lib/triggers/scheduled-report-fetch-wql-batch.tssimilarity index 65%rename from packages/pieces/community/workday/src/lib/trigger/scheduled-report-fetch-wql-batch.tsrename to packages/pieces/community/workday/src/lib/triggers/scheduled-report-fetch-wql-batch.tsindex 696d0351397..1756f6aa2ba 100644--- a/packages/pieces/community/workday/src/lib/trigger/scheduled-report-fetch-wql-batch.ts+++ b/packages/pieces/community/workday/src/lib/triggers/scheduled-report-fetch-wql-batch.ts@@ -1,3 +1,5 @@+import dayjs from 'dayjs';+import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';import {AppConnectionValueForAuthProperty,@@ -5,15 +7,15 @@ import {TriggerStrategy,createTrigger,} from '@activepieces/pieces-framework';-import dayjs from 'dayjs';+import { workdayAuth } from '../auth';-import { workdayWqlRequestAll } from '../common';-import { flattenRecord } from '../common/fields';-import { dateFieldProperty, wqlQueryProperty } from '../common/props';+import { workdayApi } from '../common/api';+import { workdayProps } from '../common/props';+import { workdayUtils } from '../common/utils';const props = {- query: wqlQueryProperty,- dateField: dateFieldProperty,+ query: workdayProps.wqlQuery({ required: true }),+ dateField: workdayProps.dateField({ required: false }),};const polling: Polling<@@ -22,7 +24,7 @@ const polling: Polling<> = {strategy: DedupeStrategy.TIMEBASED,items: async ({ auth, propsValue, lastFetchEpochMS }) => {- const records = await workdayWqlRequestAll(auth, propsValue.query);+ const records = await workdayApi.runWqlAll({ auth, query: propsValue.query });const dateField = propsValue.dateField ?? 'lastFunctionallyUpdated';const isTest = lastFetchEpochMS === 0;@@ -37,7 +39,7 @@ const polling: Polling<return dayjs(dateValue).valueOf() > lastFetchEpochMS;});const limited = isTest ? filtered.slice(0, 10) : filtered;- const flattened = limited.map((row) => flattenRecord(row));+ const flattened = limited.map((row) => workdayUtils.flattenRecord({ value: row }));if (flattened.length === 0) {return [];}@@ -63,13 +65,12 @@ const polling: Polling<},};-export const scheduledReportFetchWqlBatch = createTrigger({+export const scheduledReportFetchWqlBatchTrigger = createTrigger({auth: workdayAuth,name: 'scheduled_report_fetch_wql_batch',classification: 'READ',displayName: 'Scheduled Report Fetch using WQL (Batch)',- description:- 'Polls a WQL query on a schedule and returns matching rows as a batch.',+ description: 'Polls a WQL query on a schedule and returns matching rows as a batch.',aiMetadata: {description:'Fires on every poll with the rows of a Workday Query Language (WQL) query that are newer than the previous run, delivered as one batch. Recency is judged by a configurable date field, defaulting to lastFunctionallyUpdated, so the query must select that column. Use for scheduled WQL extracts; use Scheduled Report Fetch (Batch) when the data comes from a published report definition instead.',@@ -80,34 +81,16 @@ export const scheduledReportFetchWqlBatch = createTrigger({records: [{ employee_id: 'worker-001', name: 'Jane Doe', status: 'Active' }],},type: TriggerStrategy.POLLING,- async test(ctx) {- return await pollingHelper.test(polling, {- auth: ctx.auth,- store: ctx.store,- propsValue: ctx.propsValue,- files: ctx.files,- });+ async test(context) {+ return await pollingHelper.test(polling, context);},- async onEnable(ctx) {- await pollingHelper.onEnable(polling, {- auth: ctx.auth,- store: ctx.store,- propsValue: ctx.propsValue,- });+ async onEnable(context) {+ await pollingHelper.onEnable(polling, context);},- async onDisable(ctx) {- await pollingHelper.onDisable(polling, {- auth: ctx.auth,- store: ctx.store,- propsValue: ctx.propsValue,- });+ async onDisable(context) {+ await pollingHelper.onDisable(polling, context);},- async run(ctx) {- return await pollingHelper.poll(polling, {- auth: ctx.auth,- store: ctx.store,- propsValue: ctx.propsValue,- files: ctx.files,- });+ async run(context) {+ return await pollingHelper.poll(polling, context);},});diff --git a/packages/pieces/community/workday/src/lib/triggers/updated-supplier.ts b/packages/pieces/community/workday/src/lib/triggers/updated-supplier.tsnew file mode 100644index 00000000000..25f525348fc--- /dev/null+++ b/packages/pieces/community/workday/src/lib/triggers/updated-supplier.ts@@ -0,0 +1,66 @@+import dayjs from 'dayjs';++import { DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';+import {+ AppConnectionValueForAuthProperty,+ TriggerStrategy,+ createTrigger,+} from '@activepieces/pieces-framework';++import { workdayAuth } from '../auth';+import { workdayApi } from '../common/api';+import { workdayUtils } from '../common/utils';++const polling: Polling<+ AppConnectionValueForAuthProperty<typeof workdayAuth>,+ Record<string, never>+> = {+ strategy: DedupeStrategy.TIMEBASED,+ items: async ({ auth, lastFetchEpochMS }) => {+ const rows = await workdayApi.listBusinessProcessTransactions({+ auth,+ momentField: 'dateAndTimeCompleted',+ sinceEpochMS: lastFetchEpochMS,+ typeIds: [SUPPLIER_CHANGE_EVENT_TYPE_ID],+ completedOnly: true,+ });+ return rows.map((row) => ({+ epochMilliSeconds: dayjs(String(row['dateAndTimeCompleted'])).valueOf(),+ data: {+ id: workdayUtils.readNestedId({ value: row['subject'] }),+ descriptor: workdayUtils.readNestedDescriptor({ value: row['subject'] }),+ lastUpdated: row['dateAndTimeCompleted'],+ ...row,+ },+ }));+ },+};++export const updatedSupplierTrigger = createTrigger({+ auth: workdayAuth,+ name: 'updated_supplier',+ classification: 'READ',+ displayName: 'Updated Supplier',+ description: 'Triggers when a supplier is updated in Workday.',+ aiMetadata: {+ description:+ 'Fires when an existing supplier record is updated in Workday (polling). Use to react to supplier changes such as contact, banking, or status updates.',+ },+ props: {},+ sampleData: { id: 'sup-001', descriptor: 'Acme Corp', lastUpdated: '2026-04-01T10:00:00Z' },+ type: TriggerStrategy.POLLING,+ async test(context) {+ return await pollingHelper.test(polling, context);+ },+ async onEnable(context) {+ await pollingHelper.onEnable(polling, context);+ },+ async onDisable(context) {+ await pollingHelper.onDisable(polling, context);+ },+ async run(context) {+ return await pollingHelper.poll(polling, context);+ },+});++const SUPPLIER_CHANGE_EVENT_TYPE_ID = '753afb929c24100007bb327a66aa0011';diff --git a/packages/pieces/community/workday/test/actions.test.ts b/packages/pieces/community/workday/test/actions.test.tsnew file mode 100644index 00000000000..7f3afdd6451--- /dev/null+++ b/packages/pieces/community/workday/test/actions.test.ts@@ -0,0 +1,399 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { HttpMethod, HttpRequest, HttpResponse, httpClient } from '@activepieces/pieces-common';++import { callOperationAction } from '../src/lib/actions/call-operation';+import { createTimeOffRequestAction } from '../src/lib/actions/create-time-off-request';+import { createUpdateCustomObjectAction } from '../src/lib/actions/create-update-custom-object';+import { findSupplierInvoiceAction } from '../src/lib/actions/find-supplier-invoice';+import { getBusinessObjectDetailsBatchAction } from '../src/lib/actions/get-business-object-details-batch';+import { getCustomObjectsAction } from '../src/lib/actions/get-custom-objects';+import { getReportAction } from '../src/lib/actions/get-report';+import { getReportWqlBatchAction } from '../src/lib/actions/get-report-wql-batch';+import { listCustomObjectDefinitionsBatchAction } from '../src/lib/actions/list-custom-object-definitions-batch';+import { searchBusinessObjectBatchAction } from '../src/lib/actions/search-business-object-batch';+import { updateBusinessObjectAction } from '../src/lib/actions/update-business-object';++const AUTH = {+ access_token: 'tok',+ props: { apiHost: 'wd2-impl-services1.workday.com', tenant: 'mytenant' },+};++const AUTH_WITH_ISU = {+ access_token: 'tok',+ props: {+ apiHost: 'wd2-impl-services1.workday.com',+ tenant: 'mytenant',+ isuUsername: 'isu@mytenant',+ isuPassword: 'secret',+ },+};++function resp(body: unknown): HttpResponse {+ return { status: 200, headers: {}, body };+}++function context(propsValue: Record<string, unknown>, auth: unknown = AUTH) {+ return { auth, propsValue } as never;+}++let sendRequest: ReturnType<typeof vi.spyOn>;++function requests(): HttpRequest[] {+ return sendRequest.mock.calls.map((c) => c[0] as HttpRequest);+}++beforeEach(() => {+ sendRequest = vi.spyOn(httpClient, 'sendRequest');+});++afterEach(() => {+ vi.restoreAllMocks();+});++describe('get_business_object_details_batch', () => {+ it('fetches each id and returns standardized records', async () => {+ sendRequest.mockImplementation(async (request: HttpRequest) => {+ const id = request.url.split('/').pop();+ return resp({ id, title: `Req ${id}`, applicationStatus: 'Open' });+ });++ const out = (await getBusinessObjectDetailsBatchAction.run(+ context({+ module: 'recruiting',+ businessObject: {+ objectType: '__custom__',+ customPath: '/jobPostings',+ customService: 'recruiting/v4',+ },+ objectIds: [{ id: '1' }, { id: '2' }],+ }),+ )) as { total_count: number; records: Record<string, unknown>[] };++ expect(out.total_count).toBe(2);+ expect(out.records[0]).toMatchObject({+ job_requisition_id: '1',+ title: 'Req 1',+ });+ expect(requests()[0].url).toBe(+ 'https://wd2-impl-services1.workday.com/ccx/api/recruiting/v4/mytenant/jobPostings/1',+ );+ });+});++describe('search_business_object_batch', () => {+ it('paginates and returns standardized records', async () => {+ sendRequest.mockResolvedValue(+ resp({+ data: [{ id: 'w-1', descriptor: 'Jane', hireDate: '2025-01-01' }],+ total: 1,+ }),+ );++ const out = (await searchBusinessObjectBatchAction.run(+ context({+ module: 'onboarding',+ businessObject: { objectType: 'workers' },+ queryParams: { status: 'Active' },+ }),+ )) as { total_count: number; records: Record<string, unknown>[] };++ expect(out.total_count).toBe(1);+ expect(out.records[0]).toMatchObject({ employee_id: 'w-1', name: 'Jane' });+ });+});++describe('update_business_object', () => {+ it('PUTs to the record path and standardizes the response', async () => {+ sendRequest.mockResolvedValue(resp({ id: 'w-1', status: 'Inactive' }));++ await updateBusinessObjectAction.run(+ context({+ module: 'onboarding',+ businessObject: { objectType: 'workers' },+ objectId: 'w-1',+ body: { status: 'Inactive' },+ }),+ );++ const req = requests()[0];+ expect(req.method).toBe(HttpMethod.PUT);+ expect(req.url).toBe(+ 'https://wd2-impl-services1.workday.com/ccx/api/staffing/v6/mytenant/workers/w-1',+ );+ expect(req.body).toEqual({ status: 'Inactive' });+ });+});++describe('call_operation', () => {+ it('calls a REST sub-resource with the chosen method', async () => {+ sendRequest.mockResolvedValue(resp({ id: 'req-1', status: 'Closed' }));++ await callOperationAction.run(+ context({+ module: 'hr_services_time_tracking',+ businessObject: { objectType: 'cases' },+ operationType: 'rest',+ operationName: 'c-1/reopen',+ httpMethod: 'POST',+ }),+ );++ const req = requests()[0];+ expect(req.method).toBe(HttpMethod.POST);+ expect(req.url).toBe(+ 'https://wd2-impl-services1.workday.com/ccx/api/helpCase/v4/mytenant/cases/c-1/reopen',+ );+ });++ it('calls a SOAP operation when operationType is soap', async () => {+ sendRequest.mockResolvedValue(+ resp(+ '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><Result>ok</Result></soapenv:Body></soapenv:Envelope>',+ ),+ );++ await callOperationAction.run(+ context(+ {+ module: 'recruiting',+ businessObject: {+ objectType: '__custom__',+ customPath: '/jobPostings',+ customService: 'recruiting/v4',+ },+ operationType: 'soap',+ operationName: 'Close_Job_Requisition',+ soapService: 'Recruiting',+ },+ AUTH_WITH_ISU,+ ),+ );++ const req = requests()[0];+ expect(req.url).toContain('/ccx/service/mytenant/Recruiting/');+ expect(String(req.body)).toContain('soapenv:Envelope');+ expect(String(req.body)).toContain(+ '<bsvc:Close_Job_Requisition xmlns:bsvc="urn:com.workday/bsvc"/>',+ );+ });+});++describe('get_custom_objects', () => {+ it('GETs a custom object instance and flattens it', async () => {+ sendRequest.mockResolvedValue(resp({ id: 'obj-1', data: { name: 'X' } }));++ const out = (await getCustomObjectsAction.run(+ context({ definitionId: 'apTestInfo', objectId: 'obj-1' }),+ )) as Record<string, unknown>;++ expect(out['data_name']).toBe('X');+ expect(requests()[0].url).toContain('/v1/mytenant/customObjects/apTestInfo/obj-1');+ });+});++describe('get_report', () => {+ it('returns flattened report rows from Report_Entry', async () => {+ sendRequest.mockResolvedValue(+ resp({ Report_Entry: [{ employee_id: 'w-1' }, { employee_id: 'w-2' }] }),+ );++ const out = (await getReportAction.run(+ context({+ reportId: 'lmcneil/PT_Workers',+ reportParameters: undefined,+ format: undefined,+ }),+ )) as { total_count: number; report_id: string };++ expect(out.total_count).toBe(2);+ expect(out.report_id).toBe('lmcneil/PT_Workers');+ expect(requests()[0].url).toContain('/ccx/service/customreport2/mytenant/lmcneil/PT_Workers');+ });++ it('returns CSV text when the format is csv', async () => {+ sendRequest.mockResolvedValue(resp('Worker\nA\n'));++ const out = await getReportAction.run(+ context({+ reportId: 'lmcneil/PT_Workers',+ reportParameters: undefined,+ format: 'csv',+ }),+ );++ expect(out).toEqual({+ report_id: 'lmcneil/PT_Workers',+ csv: 'Worker\nA\n',+ });+ });+});++describe('get_report_wql_batch', () => {+ it('runs a WQL query and returns all rows', async () => {+ sendRequest.mockResolvedValue(resp({ data: [{ id: 1 }, { id: 2 }, { id: 3 }] }));++ const out = (await getReportWqlBatchAction.run(+ context({ query: 'SELECT id FROM workers' }),+ )) as { total_count: number };++ expect(out.total_count).toBe(3);+ });+});++describe('list_custom_object_definitions_batch', () => {+ it('lists definitions with a count', async () => {+ sendRequest.mockResolvedValue(resp({ data: [{ id: 'def-1' }, { id: 'def-2' }] }));++ const out = (await listCustomObjectDefinitionsBatchAction.run(context({}))) as {+ total_count: number;+ };++ expect(out.total_count).toBe(2);+ expect(requests()[0].url).toContain('/ccx/api/customObjectDefinition/v1/mytenant/definitions');+ });+});++describe('create_update_custom_object', () => {+ it('creates with POST and updateIfExists when no record id is given', async () => {+ sendRequest.mockResolvedValue(resp({ ok: 'Created' }));++ await createUpdateCustomObjectAction.run(+ context({+ definitionId: 'apTestInfo',+ objectId: undefined,+ body: { worker: { id: 'w1' }, note: 'X' },+ }),+ );++ const req = requests()[0];+ expect(req.method).toBe(HttpMethod.POST);+ expect(req.url).toBe(+ 'https://wd2-impl-services1.workday.com/ccx/api/v1/mytenant/customObjects/apTestInfo',+ );+ expect(req.queryParams).toEqual({ updateIfExists: 'true' });+ expect(req.body).toEqual({ worker: { id: 'w1' }, note: 'X' });+ });++ it('updates the record with PUT when a record id is given', async () => {+ sendRequest.mockResolvedValue(resp({ ok: 'OK' }));++ await createUpdateCustomObjectAction.run(+ context({+ definitionId: 'apTestInfo',+ objectId: 'obj-1',+ body: { note: 'X' },+ }),+ );++ const req = requests()[0];+ expect(req.method).toBe(HttpMethod.PUT);+ expect(req.url).toContain('/v1/mytenant/customObjects/apTestInfo/obj-1');+ expect(req.body).toEqual({ note: 'X' });+ });+});++describe('create_time_off_request', () => {+ it('skips weekends and sends a reference ID as Time_Off_Type_ID', async () => {+ sendRequest.mockResolvedValue(+ resp(+ '<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><ok/></env:Body></env:Envelope>',+ ),+ );+ await createTimeOffRequestAction.run(+ context(+ {+ workerId: 'w1',+ timeOffTypeId: 'Vacation_Hours',+ startDate: '2026-11-06',+ endDate: '2026-11-09',+ hoursPerDay: 4,+ },+ AUTH_WITH_ISU,+ ),+ );+ const body = String(requests()[0].body);+ expect(body.match(/<bsvc:Date>/g)).toHaveLength(2);+ expect(body).toContain('<bsvc:Date>2026-11-06</bsvc:Date>');+ expect(body).toContain('<bsvc:Date>2026-11-09</bsvc:Date>');+ expect(body).toContain('<bsvc:Requested>4</bsvc:Requested>');+ expect(body).toContain('bsvc:type="Time_Off_Type_ID">Vacation_Hours<');+ });++ it('sends a 32-character hex value as a WID', async () => {+ sendRequest.mockResolvedValue(+ resp(+ '<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><ok/></env:Body></env:Envelope>',+ ),+ );+ await createTimeOffRequestAction.run(+ context(+ {+ workerId: 'w1',+ timeOffTypeId: '693618e08cc11001896716301cde0000',+ startDate: '2026-11-02',+ endDate: '2026-11-02',+ },+ AUTH_WITH_ISU,+ ),+ );+ expect(String(requests()[0].body)).toContain(+ 'bsvc:type="WID">693618e08cc11001896716301cde0000<',+ );+ });++ it('rejects a range with no weekdays', async () => {+ await expect(+ createTimeOffRequestAction.run(+ context(+ {+ workerId: 'w1',+ timeOffTypeId: 'Vacation_Hours',+ startDate: '2026-11-07',+ endDate: '2026-11-08',+ },+ AUTH_WITH_ISU,+ ),+ ),+ ).rejects.toThrow('no weekdays');+ });+});++describe('find_supplier_invoice', () => {+ const ENVELOPE =+ '<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><wd:Get_Supplier_Invoices_Response xmlns:wd="urn:com.workday/bsvc"><wd:Response_Data><wd:Supplier_Invoice><wd:Supplier_Invoice_Data><wd:Invoice_Number>SINV-1</wd:Invoice_Number></wd:Supplier_Invoice_Data></wd:Supplier_Invoice></wd:Response_Data></wd:Get_Supplier_Invoices_Response></env:Body></env:Envelope>';++ it('looks up a Supplier Invoice ID and returns the invoice', async () => {+ sendRequest.mockResolvedValue(resp(ENVELOPE));+ const out = (await findSupplierInvoiceAction.run(+ context({ invoiceId: ' SUPPLIER_INVOICE-11-894 ' }, AUTH_WITH_ISU),+ )) as Record<string, Record<string, unknown>>;+ const req = requests()[0];+ expect(req.url).toContain('/ccx/service/mytenant/Resource_Management/');+ expect(String(req.body)).toContain(+ 'bsvc:type="Supplier_Invoice_Reference_ID">SUPPLIER_INVOICE-11-894<',+ );+ expect(out['Supplier_Invoice_Data']['Invoice_Number']).toBe('SINV-1');+ });++ it('sends a 32-character hex value as a WID', async () => {+ sendRequest.mockResolvedValue(resp(ENVELOPE));+ await findSupplierInvoiceAction.run(+ context({ invoiceId: '91d942dfcc7a9001456f855817a50000' }, AUTH_WITH_ISU),+ );+ expect(String(requests()[0].body)).toContain(+ 'bsvc:type="WID">91d942dfcc7a9001456f855817a50000<',+ );+ });++ it('throws when no invoice comes back', async () => {+ sendRequest.mockResolvedValue(+ resp(+ '<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><wd:Get_Supplier_Invoices_Response xmlns:wd="urn:com.workday/bsvc"/></env:Body></env:Envelope>',+ ),+ );+ await expect(+ findSupplierInvoiceAction.run(context({ invoiceId: 'SUPPLIER_INVOICE-0' }, AUTH_WITH_ISU)),+ ).rejects.toThrow('No supplier invoice found');+ });+});diff --git a/packages/pieces/community/workday/test/api.test.ts b/packages/pieces/community/workday/test/api.test.tsnew file mode 100644index 00000000000..13b3841a3aa--- /dev/null+++ b/packages/pieces/community/workday/test/api.test.ts@@ -0,0 +1,478 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { HttpMethod, HttpRequest, HttpResponse, httpClient } from '@activepieces/pieces-common';+import { AppConnectionType } from '@activepieces/pieces-framework';++import { workdayApi } from '../src/lib/common/api';+import { workdayClient } from '../src/lib/common/client';++const AUTH = {+ type: AppConnectionType.OAUTH2,+ access_token: 'tok',+ props: {+ apiHost: 'wd2-impl-services1.workday.com',+ tenant: 'mytenant',+ },+} as const;++const ISU_AUTH = {+ type: AppConnectionType.CUSTOM_AUTH,+ props: {+ apiHost: 'wd2-impl-services1.workday.com',+ tenant: 'mytenant',+ username: 'isu_ap',+ password: 'p<&>"\'w',+ wwsVersion: '',+ },+} as const;+const SOAP_OK =+ '<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><ok/></env:Body></env:Envelope>';++function resp(body: unknown): HttpResponse {+ return { status: 200, headers: {}, body };+}++let sendRequest: ReturnType<typeof vi.spyOn>;++beforeEach(() => {+ sendRequest = vi.spyOn(httpClient, 'sendRequest');+});++afterEach(() => {+ vi.restoreAllMocks();+});++describe('workdayClient.request', () => {+ it('builds the tenant-scoped REST URL with a bearer token', async () => {+ sendRequest.mockResolvedValue(resp({ id: 1 }));++ await workdayClient.request({+ auth: AUTH,+ method: HttpMethod.GET,+ path: '/workers/1',+ service: 'staffing/v6',+ });++ const req = sendRequest.mock.calls[0][0] as HttpRequest;+ expect(req.url).toBe(+ 'https://wd2-impl-services1.workday.com/ccx/api/staffing/v6/mytenant/workers/1',+ );+ expect(req.authentication).toMatchObject({ token: 'tok' });+ });+});++describe('workdayClient.paginate', () => {+ it('paginates until fewer than a full page is returned', async () => {+ const fullPage = Array.from({ length: 100 }, (_, i) => ({ id: i }));+ const lastPage = Array.from({ length: 50 }, (_, i) => ({ id: 100 + i }));+ sendRequest.mockImplementation(async (request: HttpRequest) => {+ const offset = Number(request.queryParams?.['offset'] ?? 0);+ return resp({ data: offset === 0 ? fullPage : lastPage, total: 150 });+ });++ const all = await workdayClient.paginate({ auth: AUTH, path: '/workers' });+ expect(all).toHaveLength(150);+ expect(sendRequest.mock.calls).toHaveLength(2);+ });++ it('keeps paginating past the first full page when the API omits total', async () => {+ const fullPage = Array.from({ length: 100 }, (_, i) => ({ id: i }));+ const lastPage = Array.from({ length: 10 }, (_, i) => ({ id: 100 + i }));+ sendRequest.mockImplementation(async (request: HttpRequest) => {+ const offset = Number(request.queryParams?.['offset'] ?? 0);+ return resp({ data: offset === 0 ? fullPage : lastPage });+ });++ const all = await workdayClient.paginate({ auth: AUTH, path: '/workers' });+ expect(all).toHaveLength(110);+ expect(sendRequest.mock.calls).toHaveLength(2);+ });+});++describe('workdayApi.runWqlAll', () => {+ it('returns the data array from the WQL response', async () => {+ sendRequest.mockResolvedValue(resp({ data: [{ id: 1 }, { id: 2 }] }));+ const rows = await workdayApi.runWqlAll({+ auth: AUTH,+ query: 'SELECT id FROM workers',+ });+ expect(rows).toHaveLength(2);+ const req = sendRequest.mock.calls[0][0] as HttpRequest;+ expect(req.url).toContain('/ccx/api/wql/v1/mytenant/data');+ });++ it('paginates until all rows are fetched', async () => {+ const fullPage = Array.from({ length: 1000 }, (_, i) => ({ id: i }));+ const lastPage = Array.from({ length: 500 }, (_, i) => ({ id: 1000 + i }));+ sendRequest.mockImplementation(async (request: HttpRequest) => {+ const offset = Number(request.queryParams?.['offset'] ?? 0);+ return resp({ data: offset === 0 ? fullPage : lastPage, total: 1500 });+ });++ const rows = await workdayApi.runWqlAll({+ auth: AUTH,+ query: 'SELECT id FROM workers',+ });+ expect(rows).toHaveLength(1500);+ expect(sendRequest.mock.calls).toHaveLength(2);+ });++ it('keeps paginating past the first full page when the API omits total', async () => {+ const fullPage = Array.from({ length: 1000 }, (_, i) => ({ id: i }));+ const lastPage = Array.from({ length: 25 }, (_, i) => ({ id: 1000 + i }));+ sendRequest.mockImplementation(async (request: HttpRequest) => {+ const offset = Number(request.queryParams?.['offset'] ?? 0);+ return resp({ data: offset === 0 ? fullPage : lastPage });+ });++ const rows = await workdayApi.runWqlAll({+ auth: AUTH,+ query: 'SELECT id FROM workers',+ });+ expect(rows).toHaveLength(1025);+ expect(sendRequest.mock.calls).toHaveLength(2);+ });+});++describe('workdayApi.getReport', () => {+ const RAAS =+ 'https://wd2-impl-services1.workday.com/ccx/service/customreport2/mytenant/lmcneil/PT_Workers';++ it('calls RaaS for owner/report with prompts and format', async () => {+ sendRequest.mockResolvedValue(resp({ Report_Entry: [{ Worker: 'A' }] }));+ const report = await workdayApi.getReport({+ auth: AUTH,+ report: 'lmcneil/PT_Workers',+ parameters: {+ Start_Date: '2026-10-01',+ 'Organizations!WID': ['o1', 'o2'],+ Count: 2,+ },+ });+ const req = sendRequest.mock.calls[0][0] as HttpRequest;+ expect(req.url).toBe(RAAS);+ expect(req.queryParams).toEqual({+ Start_Date: '2026-10-01',+ 'Organizations!WID': 'o1!o2',+ Count: '2',+ format: 'json',+ });+ expect(req.authentication).toMatchObject({ token: 'tok' });+ expect(report).toEqual({+ reportPath: 'lmcneil/PT_Workers',+ format: 'json',+ rows: [{ Worker: 'A' }],+ });+ });++ it('rebuilds a pasted RaaS URL and keeps its prompts, letting explicit prompts override', async () => {+ sendRequest.mockResolvedValue(resp({ Report_Entry: [] }));+ await workdayApi.getReport({+ auth: AUTH,+ report: ` ${RAAS}?Start_Date=2026-01-01&Employee_ID_s_=21001&format=csv `,+ parameters: { Start_Date: '2026-10-01' },+ });+ const req = sendRequest.mock.calls[0][0] as HttpRequest;+ expect(req.url).toBe(RAAS);+ expect(req.queryParams).toEqual({+ Start_Date: '2026-10-01',+ Employee_ID_s_: '21001',+ format: 'json',+ });+ });++ it('returns no rows for a report without Report_Entry', async () => {+ sendRequest.mockResolvedValue(resp({}));+ const report = await workdayApi.getReport({+ auth: AUTH,+ report: 'lmcneil/PT_Workers',+ });+ expect(report).toEqual({+ reportPath: 'lmcneil/PT_Workers',+ format: 'json',+ rows: [],+ });+ });++ it('refuses a URL on another host', async () => {+ await expect(+ workdayApi.getReport({+ auth: AUTH,+ report: 'https://evil.example.com/ccx/service/customreport2/mytenant/lmcneil/PT_Workers',+ }),+ ).rejects.toThrow("does not match the connection's API host");+ expect(sendRequest).not.toHaveBeenCalled();+ });++ it('refuses a URL for another tenant', async () => {+ await expect(+ workdayApi.getReport({+ auth: AUTH,+ report:+ 'https://wd2-impl-services1.workday.com/ccx/service/customreport2/other/lmcneil/PT_Workers',+ }),+ ).rejects.toThrow("does not match the connection's tenant");+ });++ it('refuses a reference that is neither a RaaS URL nor owner/report', async () => {+ await expect(workdayApi.getReport({ auth: AUTH, report: 'Worker_Report' })).rejects.toThrow(+ 'owner/report_name',+ );+ await expect(+ workdayApi.getReport({+ auth: AUTH,+ report: 'https://wd2-impl-services1.workday.com/ccx/api/v1/mytenant/reports/x',+ }),+ ).rejects.toThrow('not a Workday RaaS URL');+ });+});++describe('WQL escaping', () => {+ it('backslash-escapes single quotes and backslashes in lookups', async () => {+ sendRequest.mockResolvedValue(resp({ data: [] }));+ await workdayApi.findSupplier({ auth: AUTH, supplierId: "a\\'b" });+ const query = (sendRequest.mock.calls[0][0] as HttpRequest<{ query: string }>).body?.query;+ expect(query).toBe("SELECT supplier, supplierName FROM suppliers WHERE supplier = 'a\\\\\\'b'");+ });+});++describe('workdayApi.findPurchaseOrder', () => {+ it('names the required purchase orders filter', async () => {+ sendRequest.mockResolvedValue(resp({ data: [] }));+ await workdayApi.findPurchaseOrder({ auth: AUTH, purchaseOrderId: 'po-1' });+ const query = (sendRequest.mock.calls[0][0] as HttpRequest<{ query: string }>).body?.query;+ expect(query).toBe(+ "SELECT purchaseOrder FROM purchaseOrders(dataSourceFilter = purchaseOrdersFilter) WHERE purchaseOrder = 'po-1'",+ );+ });+});++describe('workdayApi.findSupplierPayments', () => {+ it('filters the data source by every visible company', async () => {+ const companyA = 'a'.repeat(32);+ const companyB = 'b'.repeat(32);+ sendRequest+ .mockResolvedValueOnce(+ resp({+ data: [{ company: { id: companyA } }, { company: { id: companyB } }],+ }),+ )+ .mockResolvedValueOnce(resp({ total: 0, data: [] }));+ await workdayApi.findSupplierPayments({ auth: AUTH, supplierId: 's1' });+ const query = (sendRequest.mock.calls[1][0] as HttpRequest<{ query: string }>).body?.query;+ expect(query).toBe(+ `SELECT supplierPayment FROM supplierPayments(dataSourceFilter = supplierPaymentsFilter, company = (${companyA}, ${companyB})) WHERE supplier = 's1'`,+ );+ });++ it('returns an empty page without querying payments when no company is visible', async () => {+ sendRequest.mockResolvedValueOnce(resp({ data: [] }));+ const page = await workdayApi.findSupplierPayments({ auth: AUTH });+ expect(page).toEqual({ total: 0, data: [] });+ expect(sendRequest).toHaveBeenCalledTimes(1);+ });+});++describe('workdayApi.listBusinessProcessTransactions', () => {+ it('filters by moment, type and status and orders newest first', async () => {+ sendRequest.mockResolvedValue(resp({ data: [] }));+ await workdayApi.listBusinessProcessTransactions({+ auth: AUTH,+ momentField: 'dateAndTimeCompleted',+ sinceEpochMS: Date.parse('2026-10-14T00:00:00.000Z'),+ typeIds: ['t1', 't2'],+ completedOnly: true,+ });+ const query = (sendRequest.mock.calls[0][0] as HttpRequest<{ query: string }>).body?.query;+ expect(query).toBe(+ "SELECT businessProcessEvent, businessProcessType, status, worker, subject, dateAndTimeInitiated, dateAndTimeCompleted FROM businessProcessTransactions WHERE dateAndTimeCompleted > '2026-10-14T00:00:00.000Z' AND businessProcessType in ('t1', 't2') AND status = 'Successfully Completed' ORDER BY dateAndTimeCompleted DESC",+ );+ });++ it('limits the first test fetch to 10 rows', async () => {+ sendRequest.mockResolvedValue(resp({ data: [] }));+ await workdayApi.listBusinessProcessTransactions({+ auth: AUTH,+ momentField: 'dateAndTimeInitiated',+ sinceEpochMS: 0,+ });+ const query = (sendRequest.mock.calls[0][0] as HttpRequest<{ query: string }>).body?.query;+ expect(query).toContain(+ "dateAndTimeInitiated > '1970-01-01T00:00:00.000Z' ORDER BY dateAndTimeInitiated DESC LIMIT 10",+ );+ });+});++describe('Integration System User connection', () => {+ it('sends SOAP to the default v47.0 with username@tenant and XML-escaped credentials', async () => {+ sendRequest.mockResolvedValue(resp(SOAP_OK));+ await workdayApi.getServerTimestamp({ auth: ISU_AUTH });+ const req = sendRequest.mock.calls[0][0] as HttpRequest;+ expect(req.url).toBe(+ 'https://wd2-impl-services1.workday.com/ccx/service/mytenant/Human_Resources/v47.0',+ );+ expect(String(req.body)).toContain('<wsse:Username>isu_ap@mytenant</wsse:Username>');+ expect(String(req.body)).toContain('>p<&>"'w</wsse:Password>');+ });++ it('uses the configured WWS version and rejects a malformed one', async () => {+ sendRequest.mockResolvedValue(resp(SOAP_OK));+ await workdayClient.soap({+ auth: { ...ISU_AUTH, props: { ...ISU_AUTH.props, wwsVersion: 'v45.0' } },+ service: 'Staffing',+ operationXml: '<x/>',+ });+ expect((sendRequest.mock.calls[0][0] as HttpRequest).url).toContain('/Staffing/v45.0');+ await expect(+ workdayClient.soap({+ auth: {+ ...ISU_AUTH,+ props: { ...ISU_AUTH.props, wwsVersion: '../v1' },+ },+ service: 'Staffing',+ operationXml: '<x/>',+ }),+ ).rejects.toThrow('is not valid');+ });++ it('runs RaaS with Basic auth and the bare username', async () => {+ sendRequest.mockResolvedValue(resp({ Report_Entry: [] }));+ await workdayApi.getReport({+ auth: {+ ...ISU_AUTH,+ props: { ...ISU_AUTH.props, username: 'isu_ap@mytenant' },+ },+ report: 'lmcneil/PT_Workers',+ });+ expect((sendRequest.mock.calls[0][0] as HttpRequest).authentication).toEqual({+ type: 'BASIC',+ username: 'isu_ap',+ password: 'p<&>"\'w',+ });+ });++ it('refuses REST and WQL calls with a clear message', async () => {+ await expect(+ workdayClient.request({+ auth: ISU_AUTH,+ method: HttpMethod.GET,+ path: '/workers',+ }),+ ).rejects.toThrow('needs the OAuth 2.0 connection');+ await expect(+ workdayApi.runWqlAll({+ auth: ISU_AUTH,+ query: 'SELECT worker FROM allWorkers',+ }),+ ).rejects.toThrow('needs the OAuth 2.0 connection');+ expect(sendRequest).not.toHaveBeenCalled();+ });+});++describe('SOAP request bodies', () => {+ it('reads time off dates as strict UTC YYYY-MM-DD and rejects anything else', async () => {+ sendRequest.mockResolvedValue(resp(SOAP_OK));+ const request = {+ auth: ISU_AUTH,+ workerId: 'w',+ timeOffTypeId: 'Vacation',+ };+ await workdayApi.createTimeOffRequest({+ ...request,+ startDate: ' 2026-11-03 ',+ endDate: '2026-11-03',+ });+ expect(String((sendRequest.mock.calls[0][0] as HttpRequest).body)).toContain(+ '<bsvc:Date>2026-11-03</bsvc:Date>',+ );+ await expect(+ workdayApi.createTimeOffRequest({+ ...request,+ startDate: '11/03/2026',+ endDate: '2026-11-03',+ }),+ ).rejects.toThrow('Start Date must be a date in YYYY-MM-DD format');+ await expect(+ workdayApi.createTimeOffRequest({+ ...request,+ startDate: '2026-11-03',+ endDate: '2026-02-30',+ }),+ ).rejects.toThrow('End Date must be a date in YYYY-MM-DD format');+ await expect(+ workdayApi.createTimeOffRequest({+ ...request,+ startDate: '2026-11-10',+ endDate: '2026-11-03',+ }),+ ).rejects.toThrow('End Date must be on or after Start Date.');+ });++ it('reports time blocks synchronously so Workday validates them in the call', async () => {+ sendRequest.mockResolvedValue(resp(SOAP_OK));+ await workdayApi.createWorkerTimeBlock({+ auth: ISU_AUTH,+ workerId: 'w',+ date: '2026-10-13',+ hours: 1,+ });+ const req = sendRequest.mock.calls[0][0] as HttpRequest;+ expect(req.url).toContain('/Time_Tracking/');+ expect(String(req.body)).toContain('<bsvc:Put_Reported_Time_Blocks_for_Worker_Request');+ });++ it('sends the approval comment inside Approve_Business_Process_Data', async () => {+ sendRequest.mockResolvedValue(resp(SOAP_OK));+ await workdayApi.approveTask({+ auth: ISU_AUTH,+ taskId: 'e',+ comment: 'ok',+ });+ const body = String((sendRequest.mock.calls[0][0] as HttpRequest).body);+ expect(body).toContain(+ '<bsvc:Approve_Business_Process_Data>\n <bsvc:Comment>ok</bsvc:Comment>',+ );+ expect(body).not.toContain('Business_Process_Comment_Data');+ });++ it('sends a supplier tax ID with its type without replacing other tax IDs', async () => {+ sendRequest.mockResolvedValue(resp(SOAP_OK));+ await workdayApi.updateSupplier({+ auth: ISU_AUTH,+ supplierId: 's',+ taxId: '12-3456789',+ taxIdType: 'USA-EIN',+ });+ const body = String((sendRequest.mock.calls[0][0] as HttpRequest).body);+ expect(body).toContain('<bsvc:Tax_ID_Widget_Data bsvc:Replace_All="false">');+ expect(body).toContain('<bsvc:Tax_ID_Text>12-3456789</bsvc:Tax_ID_Text>');+ expect(body).toContain('<bsvc:ID bsvc:type="Tax_ID_Type">USA-EIN</bsvc:ID>');+ expect(body).not.toContain('<bsvc:Tax_ID>');+ });++ it('sends supplier invoice fields with schema names in schema order', async () => {+ sendRequest.mockResolvedValue(resp(SOAP_OK));+ await workdayApi.updateSupplierInvoice({+ auth: ISU_AUTH,+ invoiceId: 'i',+ invoiceDate: '2026-10-14',+ invoiceNumber: 'SINV-1',+ total: '100.00',+ });+ const body = String((sendRequest.mock.calls[0][0] as HttpRequest).body);+ expect(body).toContain('<bsvc:Control_Amount_Total>100.00</bsvc:Control_Amount_Total>');+ expect(body).not.toContain('Total_Amount>100');+ expect(body.indexOf('<bsvc:Invoice_Number>')).toBeLessThan(body.indexOf('<bsvc:Invoice_Date>'));+ });++ it('rejects a tax ID without its type', async () => {+ await expect(+ workdayApi.updateSupplier({+ auth: ISU_AUTH,+ supplierId: 's',+ taxId: '12-3456789',+ }),+ ).rejects.toThrow('Tax ID and Tax ID Type must be set together');+ expect(sendRequest).not.toHaveBeenCalled();+ });+});diff --git a/packages/pieces/community/workday/test/triggers.test.ts b/packages/pieces/community/workday/test/triggers.test.tsnew file mode 100644index 00000000000..e1edf51e27d--- /dev/null+++ b/packages/pieces/community/workday/test/triggers.test.ts@@ -0,0 +1,257 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { HttpResponse, httpClient } from '@activepieces/pieces-common';++import { employeeTerminatedTrigger } from '../src/lib/triggers/employee-terminated';+import { newHireCreatedTrigger } from '../src/lib/triggers/new-hire-created';+import { newOrUpdatedBusinessObjectTrigger } from '../src/lib/triggers/new-or-updated-business-object';+import { newOrUpdatedBusinessObjectBatchTrigger } from '../src/lib/triggers/new-or-updated-business-object-batch';+import { scheduledReportFetchBatchTrigger } from '../src/lib/triggers/scheduled-report-fetch-batch';+import { scheduledReportFetchWqlBatchTrigger } from '../src/lib/triggers/scheduled-report-fetch-wql-batch';++const AUTH = {+ access_token: 'tok',+ props: { apiHost: 'wd2-impl-services1.workday.com', tenant: 'mytenant' },+};++function resp(body: unknown): HttpResponse {+ return { status: 200, headers: {}, body };+}++function makeStore(initial: Record<string, unknown> = {}) {+ const data: Record<string, unknown> = { ...initial };+ return {+ get: async (key: string) => (key in data ? data[key] : undefined),+ put: async (key: string, value: unknown) => {+ data[key] = value;+ return value;+ },+ delete: async (key: string) => {+ delete data[key];+ },+ };+}++function triggerContext(propsValue: Record<string, unknown>, store: ReturnType<typeof makeStore>) {+ return { auth: AUTH, store, propsValue, files: {} } as never;+}++let sendRequest: ReturnType<typeof vi.spyOn>;++beforeEach(() => {+ sendRequest = vi.spyOn(httpClient, 'sendRequest');+});++afterEach(() => {+ vi.restoreAllMocks();+});++describe('new_or_updated_business_object', () => {+ it('test() returns standardized records', async () => {+ sendRequest.mockResolvedValue(+ resp({+ data: [+ {+ id: 'r1',+ title: 'Engineer',+ applicationStatus: 'Open',+ lastFunctionallyUpdated: '2025-06-01T00:00:00Z',+ },+ ],+ }),+ );++ const items = (await newOrUpdatedBusinessObjectTrigger.test(+ triggerContext(+ {+ module: 'recruiting',+ businessObject: {+ objectType: '__custom__',+ customPath: '/jobPostings',+ customService: 'recruiting/v4',+ },+ dateField: 'lastFunctionallyUpdated',+ additionalFilters: undefined,+ },+ makeStore(),+ ),+ )) as Record<string, unknown>[];++ expect(items).toHaveLength(1);+ expect(items[0]).toMatchObject({+ job_requisition_id: 'r1',+ application_status: 'Open',+ });+ });++ it('run() returns only records newer than the last poll', async () => {+ const lastPoll = Date.parse('2025-01-01T00:00:00Z');+ sendRequest.mockResolvedValue(+ resp({+ data: [+ {+ id: 'new',+ title: 'New',+ lastFunctionallyUpdated: '2025-06-01T00:00:00Z',+ },+ {+ id: 'old',+ title: 'Old',+ lastFunctionallyUpdated: '2024-06-01T00:00:00Z',+ },+ ],+ }),+ );++ const items = (await newOrUpdatedBusinessObjectTrigger.run(+ triggerContext(+ {+ module: 'recruiting',+ businessObject: {+ objectType: '__custom__',+ customPath: '/jobPostings',+ customService: 'recruiting/v4',+ },+ dateField: 'lastFunctionallyUpdated',+ additionalFilters: undefined,+ },+ makeStore({ lastPoll }),+ ),+ )) as Record<string, unknown>[];++ expect(items).toHaveLength(1);+ expect(items[0]['job_requisition_id']).toBe('new');+ });+});++describe('new_or_updated_business_object_batch', () => {+ it('test() returns a single batch item with all records', async () => {+ sendRequest.mockResolvedValue(+ resp({+ data: [+ {+ id: 'r1',+ title: 'A',+ lastFunctionallyUpdated: '2025-06-01T00:00:00Z',+ },+ {+ id: 'r2',+ title: 'B',+ lastFunctionallyUpdated: '2025-06-02T00:00:00Z',+ },+ ],+ }),+ );++ const items = (await newOrUpdatedBusinessObjectBatchTrigger.test(+ triggerContext(+ {+ module: 'recruiting',+ businessObject: {+ objectType: '__custom__',+ customPath: '/jobPostings',+ customService: 'recruiting/v4',+ },+ dateField: 'lastFunctionallyUpdated',+ additionalFilters: undefined,+ },+ makeStore(),+ ),+ )) as Array<{ total_count: number; records: Record<string, unknown>[] }>;++ expect(items).toHaveLength(1);+ expect(items[0].total_count).toBe(2);+ });+});++describe('scheduled_report_fetch_batch', () => {+ it('test() returns the report rows as one batch', async () => {+ sendRequest.mockResolvedValue(+ resp({ Report_Entry: [{ employee_id: 'w-1' }, { employee_id: 'w-2' }] }),+ );++ const items = (await scheduledReportFetchBatchTrigger.test(+ triggerContext({ reportId: 'lmcneil/PT_Workers', reportParameters: undefined }, makeStore()),+ )) as Array<{ total_count: number; report_id: string }>;++ expect(items).toHaveLength(1);+ expect(items[0].total_count).toBe(2);+ expect(items[0].report_id).toBe('lmcneil/PT_Workers');+ });+});++describe('scheduled_report_fetch_wql_batch', () => {+ it('test() returns WQL rows as one batch', async () => {+ sendRequest.mockResolvedValue(+ resp({+ data: [+ {+ employee_id: 'w-1',+ lastFunctionallyUpdated: '2025-06-01T00:00:00Z',+ },+ ],+ }),+ );++ const items = (await scheduledReportFetchWqlBatchTrigger.test(+ triggerContext(+ {+ query: 'SELECT employee_id FROM workers',+ dateField: 'lastFunctionallyUpdated',+ },+ makeStore(),+ ),+ )) as Array<{ total_count: number }>;++ expect(items).toHaveLength(1);+ expect(items[0].total_count).toBe(1);+ });+});++describe('new_hire_created', () => {+ it('polls allWorkers by createdMoment and keeps the id/descriptor keys', async () => {+ sendRequest.mockResolvedValue(+ resp({+ data: [+ {+ worker: { id: 'w-9', descriptor: 'Pat Doe' },+ hireDate: '2027-11-30',+ createdMoment: '2026-10-14T08:00:00.000Z',+ },+ ],+ }),+ );+ const events = await newHireCreatedTrigger.test(triggerContext({}, makeStore()));+ const query = (sendRequest.mock.calls[0][0] as { body: { query: string } }).body.query;+ expect(query).toContain("FROM allWorkers WHERE createdMoment > '1970-01-01T00:00:00.000Z'");+ expect(events[0]).toMatchObject({+ id: 'w-9',+ descriptor: 'Pat Doe',+ hireDate: '2027-11-30',+ });+ });+});++describe('employee_terminated', () => {+ it('polls completed terminations and maps the effective date to terminationDate', async () => {+ sendRequest.mockResolvedValue(+ resp({+ data: [+ {+ worker: { id: 'w-3', descriptor: 'Sam Roe' },+ effectiveDate: '2026-10-31',+ dateAndTimeCompleted: '2026-10-14T09:00:00.000Z',+ },+ ],+ }),+ );+ const events = await employeeTerminatedTrigger.test(triggerContext({}, makeStore()));+ const query = (sendRequest.mock.calls[0][0] as { body: { query: string } }).body.query;+ expect(query).toContain('FROM terminations WHERE dateAndTimeCompleted >');+ expect(events[0]).toMatchObject({+ id: 'w-3',+ descriptor: 'Sam Roe',+ terminationDate: '2026-10-31',+ });+ });+});diff --git a/packages/pieces/community/workday/test/utils.test.ts b/packages/pieces/community/workday/test/utils.test.tsnew file mode 100644index 00000000000..2ea3f6b6335--- /dev/null+++ b/packages/pieces/community/workday/test/utils.test.ts@@ -0,0 +1,271 @@+import { describe, expect, it } from 'vitest';++import { workdayUtils } from '../src/lib/common/utils';++describe('flattenRecord', () => {+ it('flattens nested objects with underscore-joined keys', () => {+ expect(+ workdayUtils.flattenRecord({+ value: { worker: { id: 1, descriptor: 'Jane' } },+ }),+ ).toEqual({+ worker_id: 1,+ worker_descriptor: 'Jane',+ });+ });++ it('JSON-stringifies nested arrays under their key', () => {+ expect(workdayUtils.flattenRecord({ value: { lines: [{ id: 1 }] } })).toEqual({+ lines: JSON.stringify([{ id: 1 }]),+ });+ });++ it('puts a top-level array under "items"', () => {+ expect(workdayUtils.flattenRecord({ value: [1, 2] })).toEqual({+ items: JSON.stringify([1, 2]),+ });+ });++ it('preserves null leaf values', () => {+ expect(workdayUtils.flattenRecord({ value: { status: null } })).toEqual({+ status: null,+ });+ });+});++describe('formatOutput', () => {+ it('maps recruiting fields, resolving nested descriptors/ids', () => {+ const out = workdayUtils.formatOutput({+ record: {+ id: 'req-1',+ title: 'Engineer',+ location: { descriptor: 'San Francisco' },+ candidate: { id: 'cand-9' },+ applicationStatus: 'In Progress',+ },+ module: 'recruiting',+ });+ expect(out).toMatchObject({+ job_requisition_id: 'req-1',+ title: 'Engineer',+ location: 'San Francisco',+ candidate_id: 'cand-9',+ application_status: 'In Progress',+ });+ });++ it('maps onboarding fields with worker fallback', () => {+ const out = workdayUtils.formatOutput({+ record: {+ worker: { id: 'w-1', descriptor: 'Jane Doe' },+ hireDate: '2025-01-02',+ status: 'Active',+ },+ module: 'onboarding',+ });+ expect(out).toMatchObject({+ employee_id: 'w-1',+ name: 'Jane Doe',+ hire_date: '2025-01-02',+ status: 'Active',+ });+ });++ it('maps HR case fields without setting time_entry_id', () => {+ const out = workdayUtils.formatOutput({+ record: {+ id: 'case-1',+ worker: { id: 'w-2' },+ description: 'Payroll question',+ status: 'Open',+ },+ module: 'hr_services_time_tracking',+ });+ expect(out).toMatchObject({+ case_id: 'case-1',+ employee_id: 'w-2',+ description: 'Payroll question',+ status: 'Open',+ });+ expect(out['time_entry_id']).toBeUndefined();+ });++ it('maps HR time-entry fields without polluting case_id', () => {+ const out = workdayUtils.formatOutput({+ record: {+ id: 'te-1',+ worker: { id: 'w-2' },+ date: '2025-03-01',+ hours: 8,+ status: 'Submitted',+ },+ module: 'hr_services_time_tracking',+ });+ expect(out).toMatchObject({+ time_entry_id: 'te-1',+ employee_id: 'w-2',+ date: '2025-03-01',+ hours: 8,+ });+ expect(out['case_id']).toBeUndefined();+ });++ it('maps a timeTracking v7 worker time block', () => {+ const out = workdayUtils.formatOutput({+ record: {+ id: 'tb-1',+ worker: { id: 'w-3' },+ calendarDate: '2026-10-14',+ reportedQuantity: 4,+ },+ module: 'hr_services_time_tracking',+ });+ expect(out).toMatchObject({+ time_entry_id: 'tb-1',+ employee_id: 'w-3',+ date: '2026-10-14',+ hours: 4,+ });+ });+});++describe('getRecordTimestamp', () => {+ it('prefers the provided field', () => {+ expect(+ workdayUtils.getRecordTimestamp({+ record: { myDate: '2025-01-01', createdMoment: '2024-01-01' },+ preferredField: 'myDate',+ }),+ ).toBe('2025-01-01');+ });++ it('falls back through the standard timestamp fields', () => {+ expect(+ workdayUtils.getRecordTimestamp({+ record: { updatedMoment: '2025-05-05' },+ }),+ ).toBe('2025-05-05');+ });++ it('returns undefined when no timestamp is present', () => {+ expect(workdayUtils.getRecordTimestamp({ record: { foo: 'bar' } })).toBeUndefined();+ });+});++describe('resolveBusinessObject', () => {+ it('resolves a standard business object for a module', () => {+ const config = workdayUtils.resolveBusinessObject({+ module: 'onboarding',+ selection: { objectType: 'workers' },+ });+ expect(config.path).toBe('/workers');+ expect(config.service).toBe('staffing/v6');+ });++ it('builds a custom object config from a path', () => {+ const config = workdayUtils.resolveBusinessObject({+ module: 'recruiting',+ selection: {+ objectType: '__custom__',+ customPath: 'invoices',+ customService: 'v1',+ },+ });+ expect(config.path).toBe('/invoices');+ expect(config.service).toBe('v1');+ });++ it('maps the retired expenseManagement/v1 service to expense/v1', () => {+ const config = workdayUtils.resolveBusinessObject({+ module: 'onboarding',+ selection: {+ objectType: '__custom__',+ customPath: '/reports',+ customService: 'expenseManagement/v1',+ },+ });+ expect(config.service).toBe('expense/v1');+ });++ it('maps the retired time/v2 service to timeTracking/v7', () => {+ const config = workdayUtils.resolveBusinessObject({+ module: 'onboarding',+ selection: {+ objectType: '__custom__',+ customPath: '/workerTimeBlocks',+ customService: 'time/v2',+ },+ });+ expect(config.service).toBe('timeTracking/v7');+ });++ it('maps the retired resourceManagement/v3 service to procurement/v5', () => {+ const config = workdayUtils.resolveBusinessObject({+ module: 'onboarding',+ selection: {+ objectType: '__custom__',+ customPath: '/purchaseOrders',+ customService: 'resourceManagement/v3',+ },+ });+ expect(config.service).toBe('procurement/v5');+ });++ it('resolves Case to the helpCase/v4 service', () => {+ const config = workdayUtils.resolveBusinessObject({+ module: 'hr_services_time_tracking',+ selection: { objectType: 'cases' },+ });+ expect(config.path).toBe('/cases');+ expect(config.service).toBe('helpCase/v4');+ });++ it('resolves Time Entry to worker time blocks', () => {+ const config = workdayUtils.resolveBusinessObject({+ module: 'hr_services_time_tracking',+ selection: { objectType: 'timeEntries' },+ });+ expect(config.path).toBe('/workerTimeBlocks');+ expect(config.service).toBe('timeTracking/v7');+ });++ it('prefixes a missing slash on custom paths', () => {+ const config = workdayUtils.resolveBusinessObject({+ module: 'onboarding',+ selection: { objectType: '__custom__', customPath: 'workers' },+ });+ expect(config.path).toBe('/workers');+ });++ it('throws when a custom path is missing', () => {+ expect(() =>+ workdayUtils.resolveBusinessObject({+ module: 'recruiting',+ selection: { objectType: '__custom__', customPath: '' },+ }),+ ).toThrow('Custom Business Object Path is required');+ });++ it('throws for an unknown business object', () => {+ expect(() =>+ workdayUtils.resolveBusinessObject({+ module: 'recruiting',+ selection: { objectType: 'nope' },+ }),+ ).toThrow();+ });+});++describe('toWorkdayModule', () => {+ it('accepts the three supported modules', () => {+ expect(workdayUtils.toWorkdayModule({ module: 'recruiting' })).toBe('recruiting');+ expect(workdayUtils.toWorkdayModule({ module: 'onboarding' })).toBe('onboarding');+ expect(workdayUtils.toWorkdayModule({ module: 'hr_services_time_tracking' })).toBe(+ 'hr_services_time_tracking',+ );+ });++ it('throws for an invalid module', () => {+ expect(() => workdayUtils.toWorkdayModule({ module: 'finance' })).toThrow();+ });+});