@worknice/js-sdk 0.11.12 → 0.11.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -35,7 +35,7 @@ const handleTriggerIntegrationSyncWebhook = async (request, tasks, options) => h
|
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
if (integration.status !== "SYNCING") {
|
|
38
|
-
logger.info(`Integration status is "${
|
|
38
|
+
logger.info(`Integration status is "${integration.status}". Skipping sync.`);
|
|
39
39
|
if (tasks.heartbeat) await tasks.heartbeat(context);
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/helpers/handleTriggerIntegrationSyncWebhook.ts"],"sourcesContent":["import { Temporal } from \"temporal-polyfill\";\n\nimport isInstantAfter from \"@worknice/utils/temporal/isInstantAfter\";\nimport isValidInstant from \"@worknice/utils/temporal/isValidInstant\";\nimport type { TriggerIntegrationSyncRequestPayload } from \"@worknice/utils/webhooks\";\n\nimport {\n ConnectionStatus,\n type GetPeopleQuery,\n type LeaveCategoryInput,\n LeaveRequestStatus,\n PersonRole,\n type WorkniceClient,\n} from \"../api/_types.js\";\nimport type { PersonDataTransferLine } from \"../employee-records/_types.js\";\nimport comparePersonDataTransferLines from \"../employee-records/comparePersonDataTransferLines.js\";\nimport mergePersonDataTransferLines from \"../employee-records/mergePersonDataTransferLines.js\";\nimport validatePersonDataTransferLine from \"../employee-records/validatePersonDataTransferLine.js\";\nimport validatePersonDataTransferLineBankAccounts from \"../employee-records/validatePersonDataTransferLineBankAccounts.js\";\nimport validatePersonDataTransferLineDateOfBirth from \"../employee-records/validatePersonDataTransferLineDateOfBirth.js\";\nimport validatePersonDataTransferLineFullName from \"../employee-records/validatePersonDataTransferLineFullName.js\";\nimport validatePersonDataTransferLineGender from \"../employee-records/validatePersonDataTransferLineGender.js\";\nimport validatePersonDataTransferLinePersonalEmail from \"../employee-records/validatePersonDataTransferLinePersonalEmail.js\";\nimport validatePersonDataTransferLinePersonalPhone from \"../employee-records/validatePersonDataTransferLinePersonalPhone.js\";\nimport validatePersonDataTransferLineProfile from \"../employee-records/validatePersonDataTransferLineProfile.js\";\nimport validatePersonDataTransferLineResidentialAddress from \"../employee-records/validatePersonDataTransferLineResidentialAddress.js\";\nimport validatePersonDataTransferLineTaxDetails from \"../employee-records/validatePersonDataTransferLineTaxDetails.js\";\nimport type { HandlerOptions, TaskContext } from \"./_types.js\";\nimport handleRequestWithWorknice from \"./handleRequestWithWorknice.js\";\n\n// TODO: Remove `integration` from the context once Notebook has been updated to\n// provide fresh integration details with each request. See PROD-3146.\ntype Context<Env, Req extends Request = Request> = TaskContext<\n TriggerIntegrationSyncRequestPayload,\n Env,\n Req\n> & {\n /**\n * @deprecated Use `payload.integration` instead.\n */\n integration: Awaited<ReturnType<WorkniceClient[\"getIntegration\"]>>;\n};\n\ntype ConnectionContext<Env, Req extends Request = Request> = Context<Env, Req> & {\n connection: Awaited<ReturnType<WorkniceClient[\"getPersonConnections\"]>>[number];\n};\n\ntype Person = Omit<PersonDataTransferLine, \"profile\"> & {\n profile: NonNullable<PersonDataTransferLine[\"profile\"]>;\n} & {\n metadata: {\n deleted: boolean;\n employeeCode: string | null;\n sourceId: string;\n targetId: string | null;\n updatedAt: string;\n };\n};\n\ntype LeaveRequest = {\n endDate: string;\n endTime: string | null;\n leaveCategory: LeaveCategoryInput;\n notes: string | null;\n personRemoteId: string;\n remoteId: string;\n startDate: string;\n startTime: string | null;\n status: LeaveRequestStatus;\n};\n\ntype Tasks<Env, Req extends Request = Request> = {\n createRemotePerson?: (\n person: Person,\n context: ConnectionContext<Env, Req>,\n ) => Promise<{\n id: string;\n name: string;\n status?: ConnectionStatus.Connected | ConnectionStatus.Merged;\n }>;\n getApiToken: (\n context: Pick<Context<Env, Req>, \"env\" | \"logger\" | \"payload\" | \"request\">,\n ) => Promise<string>;\n getConfig: (context: Context<Env, Req>) => Promise<Config>;\n getEnv: (context: Pick<Context<Env, Req>, \"logger\" | \"payload\" | \"request\">) => Promise<Env>;\n getRemoteLeaveRequests?: (\n context: Context<Env, Req> & { remotePeople: Array<Person> },\n ) => Promise<Array<LeaveRequest>>;\n getRemotePeople: (context: Context<Env, Req>) => Promise<Array<Person>>;\n heartbeat?: (context: Omit<Context<Env, Req>, \"integration\">) => Promise<void>;\n updateRemotePerson?: (person: Person, context: ConnectionContext<Env, Req>) => Promise<unknown>;\n};\n\ntype Config = {\n appName: string;\n /**\n * If true, new people will be automatically created in Worknice when a new\n * person is detected in the remote app, otherwise a person connection is\n * created with a \"remote-only\" status.\n */\n automaticCreation?: boolean;\n /**\n * If true, connections will be automatically matched if any of the\n * following conditions are met:\n *\n * - Worknice person employee code matches remote person employee code\n * - Worknice person personal email matches remote person personal email\n * - Worknice person profile email matches remote person profile email\n */\n automaticMatching?: boolean;\n /**\n * @value \"connection-only\" - Only update person connections.\n * @value \"remote-to-worknice\" - Update Worknice people with details from\n * remote people.\n * @value \"two-way\" - Update both Worknice people and remote people with\n * details from each other.\n * @value \"worknice-to-remote\" - Update remote people with details from\n * Worknice people.\n */\n mode?:\n | \"connection-only\"\n | \"remote-to-worknice\"\n | \"two-way\"\n | \"worknice-to-remote\"\n // Deprecated: Use `worknice-to-remote` instead.\n | \"one-way\";\n syncFields?: {\n bankAccounts?: boolean;\n dateOfBirth?: boolean;\n emergencyContacts?: boolean;\n fullName?: boolean;\n gender?: boolean;\n personalEmail?: boolean;\n personalPhone?: boolean;\n postalAddress?: boolean;\n profile?: boolean;\n remuneration?: boolean;\n residentialAddress?: boolean;\n superFunds?: boolean;\n taxDetails?: boolean;\n tenure?: boolean;\n };\n};\n\nconst handleTriggerIntegrationSyncWebhook = async <Env, Req extends Request = Request>(\n request: Req,\n tasks: Tasks<Env, Req>,\n options?: HandlerOptions,\n) =>\n handleRequestWithWorknice<TriggerIntegrationSyncRequestPayload, undefined, Env, Req>(\n request,\n {\n getApiToken: tasks.getApiToken,\n handleRequest: async (context) => {\n const { logger, payload, worknice } = context;\n try {\n logger.connect(worknice, payload.integration.id);\n\n const integration = await worknice.getIntegration({\n integrationId: payload.integration.id,\n });\n\n if (integration.archived) {\n logger.info(\"Integration is archived. Skipping sync.\");\n return;\n }\n\n if (integration.status !== \"SYNCING\") {\n logger.info(`Integration status is \"${payload.integration.status}\". Skipping sync.`);\n if (tasks.heartbeat) await tasks.heartbeat(context);\n return;\n }\n\n if (payload.integration.features.peopleSync === true) {\n logger.indent(\"Syncing people…\");\n\n const { remotePeople } = await handlePeopleSync<Env, Req>(tasks, {\n ...context,\n integration,\n });\n\n logger.dedent(\"Finished syncing people.\");\n\n if (payload.integration.features.leave === true) {\n if (tasks.getRemoteLeaveRequests !== undefined) {\n logger.indent(\"Syncing leave requests…\");\n\n await handleLeaveRequestsSync<Env, Req>(tasks, {\n ...context,\n integration,\n remotePeople,\n });\n\n logger.dedent(\"Finished syncing leave requests.\");\n } else {\n logger.debug(\n \"Skipping leave request sync: `getRemoteLeaveRequests` is not configured\",\n );\n }\n } else {\n logger.debug(\"Skipping leave request sync: leave not enabled\");\n }\n }\n await worknice.completeSync({ integrationId: payload.integration.id });\n } catch (error) {\n // TODO: Set the sync result to \"ERROR\". See PROD-2089.\n await worknice.completeSync({ integrationId: payload.integration.id });\n throw error;\n }\n },\n parseRequest: async (context) => {\n const payload = await context.request.json();\n return {\n env: await tasks.getEnv({ ...context, payload }),\n payload,\n };\n },\n },\n {\n processName: \"Sync\",\n ...options,\n },\n );\n\n/**\n * The process for syncing people has four steps:\n *\n * 1. Update person connections: Create new person connections for Worknice\n * people or remote people that don't have existing connections. If needed,\n * update names of existing person connections. If enabled, automatically\n * match connections.\n *\n * 2. Update merged people: Copy details from the Worknice people to remote\n * people or vice-versa (based on whichever one was updated most recently)\n * for person connections that are already marked as merged.\n *\n * 3. Merge matched people: Update both Worknice people and remote people for\n * person connections that are marked as matched using details from both\n * people merged together. Mark the connections as merged.\n *\n * 4. Add new people to the remote app: Create new people in the remote app for\n * connections that are unmatched and local-only. Mark the connections as\n * merged.\n */\nconst handlePeopleSync = async <Env, Req extends Request>(\n { createRemotePerson, getConfig, getRemotePeople, updateRemotePerson }: Tasks<Env, Req>,\n context: Context<Env, Req>,\n): Promise<{\n remotePeople: Array<Person>;\n}> => {\n const { logger, integration, payload, worknice } = context;\n\n let cachedDataImport: Awaited<ReturnType<WorkniceClient[\"createDataImport\"]>>;\n\n const getDataImport = async () => {\n if (!cachedDataImport) {\n cachedDataImport = await worknice.createDataImport({\n integrationId: payload.integration.id,\n });\n }\n\n return cachedDataImport;\n };\n\n logger.indent(\"Retrieving Worknice data…\");\n\n const personConnections = await worknice.getPersonConnections({\n integrationId: payload.integration.id,\n });\n\n logger.info(`Retrieved ${personConnections.length} person connection(s) from Worknice.`);\n\n const people = await worknice.getPeople({ orgId: integration.org.id });\n\n logger.info(`Retrieved ${people.length} person(s) from Worknice.`);\n\n logger.dedent(\"Completed retrieving Worknice data.\");\n\n const contextWithIntegration = {\n ...context,\n integration,\n };\n\n logger.indent(\"Loading configuration details…\");\n\n const config = await getConfig(contextWithIntegration);\n\n const mode =\n config.mode === \"one-way\" ? \"worknice-to-remote\" : (config.mode ?? \"connection-only\");\n\n logger.info(`Mode: ${mode}`);\n logger.info(\n `Automatically create new people in Worknice: ${config.automaticCreation ? \"enabled\" : \"disabled\"}`,\n );\n logger.info(\n `Automatically match people using email addresses and employee codes: ${config.automaticMatching ? \"enabled\" : \"disabled\"}`,\n );\n\n logger.dedent(\"Finished loading configuration details.\");\n\n logger.indent(`Retrieving ${config.appName} data…`);\n\n let remotePeople: Person[];\n\n try {\n remotePeople = await getRemotePeople(contextWithIntegration);\n } catch (error) {\n logger.info(`An error occurred while retrieving data from ${config.appName}.`);\n throw error;\n }\n\n logger.info(`Retrieved ${remotePeople.length} person(s) from ${config.appName}.`);\n\n logger.dedent(`Completed retrieving ${config.appName} data.`);\n\n logger.indent(\"Updating person connections…\");\n\n for (const remotePerson of remotePeople) {\n const remotePersonName = personToName(remotePerson);\n try {\n const remotePersonConnection = personConnections.find(\n (\n connection,\n ): connection is typeof connection & {\n status:\n | ConnectionStatus.Connected\n | ConnectionStatus.Merged\n | ConnectionStatus.RemoteOnly;\n } => connection.remote?.id === remotePerson.metadata.sourceId,\n );\n\n if (remotePerson.metadata.deleted) {\n // The remote person has been deleted. If they have a person\n // connection, it should be deleted.\n\n if (remotePersonConnection) {\n await worknice.deletePersonConnection({\n personConnectionId: remotePersonConnection.id,\n });\n\n logger.info(\n `Deleted connection for ${config.appName} person \"${remotePersonName}\" because they have been terminated.`,\n );\n }\n } else {\n // A connection for remote person should be added or updated in\n // Worknice.\n\n if (\n remotePersonConnection &&\n (remotePersonConnection.status === ConnectionStatus.Connected ||\n remotePersonConnection.status === ConnectionStatus.Merged)\n ) {\n // The remote person is already connected to a Worknice person.\n\n if (remotePersonConnection.remote?.name !== remotePersonName) {\n // The employee's name has changed in the remote app and that\n // needs to be reflected in the person connection in Worknice.\n\n const connection = await worknice.updatePersonConnection({\n personConnectionId: remotePersonConnection.id,\n personId: remotePersonConnection.person.id,\n remote: {\n id: remotePerson.metadata.sourceId,\n name: remotePersonName,\n },\n status: remotePersonConnection.status,\n });\n\n personConnections.splice(\n personConnections.indexOf(remotePersonConnection),\n 1,\n connection,\n );\n\n logger.info(\n `Updated person connection remote name from \"${remotePersonConnection.remote?.name}\" to \"${remotePersonName}\".`,\n );\n }\n } else {\n // The remote person is not already connected to a Worknice person, but\n // could already have a remote-only connection.\n\n if (remotePersonConnection && remotePersonConnection.remote?.name !== remotePersonName) {\n // The person's name has changed in the remote and that\n // needs to be reflected in the person connection in\n // Worknice.\n\n const connection = await worknice.updatePersonConnection({\n personConnectionId: remotePersonConnection.id,\n remote: {\n id: remotePerson.metadata.sourceId,\n name: remotePersonName,\n },\n status: remotePersonConnection.status,\n });\n\n personConnections.splice(\n personConnections.indexOf(remotePersonConnection),\n 1,\n connection,\n );\n\n logger.info(\n `Updated person connection remote name from \"${remotePersonConnection.remote?.name}\" to \"${remotePersonName}\".`,\n );\n }\n\n const matchingWorknicePerson =\n people.find(\n (person) =>\n person.id === remotePerson.metadata.targetId ||\n (person.employeeCode !== null &&\n person.employeeCode === remotePerson.metadata.employeeCode) ||\n (person.personalEmail !== null &&\n person.personalEmail === remotePerson.personalEmail?.personalEmail) ||\n (person.profileEmail !== null &&\n person.profileEmail === remotePerson.profile?.profileEmail),\n ) ?? null;\n\n if (config.automaticMatching === true && matchingWorknicePerson) {\n // There is a person in Worknice with an ID, employee code\n // or email address that matches the remote person. The\n // Worknice person should be automatically connected to the\n // remote person.\n\n const personConnection = personConnections.find(\n (\n connection,\n ): connection is typeof connection & {\n status:\n | ConnectionStatus.Connected\n | ConnectionStatus.LocalOnly\n | ConnectionStatus.Merged;\n } => connection.person?.id === matchingWorknicePerson.id,\n );\n\n if (\n personConnection?.status === ConnectionStatus.Connected ||\n personConnection?.status === ConnectionStatus.Merged\n ) {\n // The person is already matched with a different remote person.\n\n logger.info(\n `Unable to automatically match Worknice person \"${matchingWorknicePerson.displayName}\" to ${config.appName} person \"${remotePersonName}\" because the Worknice person has already been matched to a different ${config.appName} person.`,\n );\n } else {\n // The Worknice person is not yet matched to a remote person. The\n // Worknice person and remote person records should be matched.\n\n if (personConnection) {\n // The Worknice person already has a local-only connection in this\n // integration that can be updated to match to this remote person.\n\n if (remotePersonConnection) {\n // There are person connections for both the Worknice\n // person and the remote person that need to be combined\n // into a single person connection.\n\n await worknice.deletePersonConnection({\n personConnectionId: personConnection.id,\n });\n\n personConnections.splice(personConnections.indexOf(personConnection), 1);\n\n const updatedConnection = await worknice.updatePersonConnection({\n personConnectionId: remotePersonConnection.id,\n personId: matchingWorknicePerson.id,\n remote: {\n id: remotePerson.metadata.sourceId,\n name: remotePersonName,\n },\n status: ConnectionStatus.Connected,\n });\n\n personConnections.splice(\n personConnections.indexOf(remotePersonConnection),\n 1,\n updatedConnection,\n );\n\n logger.info(\n `Automatically matched and combined person connections for Worknice person \"${matchingWorknicePerson.displayName}\" and ${config.appName} person \"${remotePersonName}\".`,\n );\n } else {\n // There is a local-only connection for this Worknice person\n // that should be updated to connect to this remote person.\n\n const updatedConnection = await worknice.updatePersonConnection({\n personConnectionId: personConnection.id,\n personId: personConnection.person.id,\n remote: {\n id: remotePerson.metadata.sourceId,\n name: remotePersonName,\n },\n status: ConnectionStatus.Connected,\n });\n\n personConnections.splice(\n personConnections.indexOf(personConnection),\n 1,\n updatedConnection,\n );\n\n logger.info(\n `Automatically matched existing person connection for Worknice person \"${matchingWorknicePerson.displayName}\" to ${config.appName} person \"${remotePersonName}\".`,\n );\n }\n } else {\n // The Worknice person does not have a connection in this\n // integration and should be connected now.\n\n if (remotePersonConnection) {\n // There is a remote-only connection for this remote person that\n // should be updated to match to this Worknice person.\n\n const updatedConnection = await worknice.updatePersonConnection({\n personConnectionId: remotePersonConnection.id,\n personId: matchingWorknicePerson.id,\n remote: {\n ...remotePersonConnection.remote,\n name: remotePersonName,\n },\n status: ConnectionStatus.Connected,\n });\n\n personConnections.splice(\n personConnections.indexOf(remotePersonConnection),\n 1,\n updatedConnection,\n );\n\n logger.info(\n `Automatically matched existing person connection for ${config.appName} person \"${remotePersonName}\" to Worknice person \"${matchingWorknicePerson.displayName}\".`,\n );\n } else {\n // There is no connection for the remote person or the\n // Worknice person in this integration. A new connection\n // should be created.\n\n const newPersonConnection = await worknice.createPersonConnection({\n integrationId: payload.integration.id,\n personId: matchingWorknicePerson.id,\n remote: {\n id: remotePerson.metadata.sourceId,\n name: remotePersonName,\n },\n status: ConnectionStatus.Connected,\n });\n\n personConnections.push(newPersonConnection);\n\n logger.info(\n `Created new person connection for ${config.appName} person \"${remotePersonName}\" and automatically matched to Worknice person \"${matchingWorknicePerson.displayName}\".`,\n );\n }\n }\n }\n } else if (remotePersonConnection === undefined) {\n // There is no person in Worknice which should be automatically\n // connected to this remote person and there is no existing connection\n // for this remote person.\n\n if (config.automaticCreation === true) {\n const person = await worknice.createPerson({\n displayName: remotePersonName,\n role: PersonRole.Employee,\n });\n\n const newPersonConnection = await worknice.createPersonConnection({\n integrationId: payload.integration.id,\n personId: person.id,\n remote: {\n id: remotePerson.metadata.sourceId,\n name: remotePersonName,\n },\n status: ConnectionStatus.Connected,\n });\n\n personConnections.push(newPersonConnection);\n\n logger.info(\n `Automatically created new person \"${remotePersonName}\" in Worknice from \"${remotePersonName}\" in ${config.appName}.`,\n );\n } else {\n const newPersonConnection = await worknice.createPersonConnection({\n integrationId: payload.integration.id,\n remote: {\n id: remotePerson.metadata.sourceId,\n name: remotePersonName,\n },\n status: ConnectionStatus.RemoteOnly,\n });\n\n personConnections.push(newPersonConnection);\n\n logger.info(\n `New person connection created for ${config.appName} person \"${remotePersonName}\".`,\n );\n }\n }\n }\n }\n } catch (error) {\n logger.indent(\n `Unable to update person connection for ${config.appName} person \"${remotePersonName}\" because of the following error:`,\n );\n logger.error(error);\n logger.dedent();\n }\n }\n\n logger.dedent(\"Finished updating person connections.\");\n\n if (mode !== \"connection-only\") {\n logger.indent(\"Updating people with connections marked as merged…\");\n\n const mergedConnections = personConnections.filter(\n (\n personConnection,\n ): personConnection is typeof personConnection & {\n status: ConnectionStatus.Merged;\n } => personConnection.status === ConnectionStatus.Merged,\n );\n\n for (const personConnection of mergedConnections) {\n const worknicePerson = people.find((person) => person.id === personConnection.person.id);\n const remotePerson = remotePeople.find(\n (person) => person.metadata.sourceId === personConnection.remote.id,\n );\n\n try {\n if (!worknicePerson) {\n throw Error(\n `Unable to find person in Worknice with the ID \"${personConnection.person.id}\".`,\n );\n }\n if (!remotePerson) {\n throw Error(\n `Unable to find person in ${config.appName} with the ID \"${personConnection.remote.id}\".`,\n );\n }\n } catch (error) {\n logger.indent(\n `Unable to update Worknice person \"${personConnection.person.displayName}\" and/or ${config.appName} person \"${personConnection.remote.name}\" because of the following error:`,\n );\n logger.error(error);\n logger.dedent();\n continue;\n }\n\n const remotePersonName = personToName(remotePerson);\n\n const worknicePersonDataTransferLine = {\n ...worknicePersonToPersonDataTransferLine(worknicePerson),\n metadata: {\n deleted: false,\n employeeCode: worknicePerson.employeeCode ?? null,\n sourceId: worknicePerson.id,\n targetId: remotePerson.metadata.sourceId,\n updatedAt: worknicePerson.updatedAt,\n },\n };\n\n const remotePersonDataTransferLine = remotePerson;\n\n const comparison = comparePersonDataTransferLines(\n worknicePersonDataTransferLine,\n remotePersonDataTransferLine,\n );\n\n if (\n comparison.hasDifferences &&\n ((config.syncFields?.bankAccounts && comparison.sections.bankAccounts.hasDifferences) ||\n (config.syncFields?.dateOfBirth && comparison.sections.dateOfBirth.hasDifferences) ||\n (config.syncFields?.fullName && comparison.sections.fullName.hasDifferences) ||\n (config.syncFields?.gender && comparison.sections.gender.hasDifferences) ||\n (config.syncFields?.personalEmail && comparison.sections.personalEmail.hasDifferences) ||\n (config.syncFields?.personalPhone && comparison.sections.personalPhone.hasDifferences) ||\n (config.syncFields?.residentialAddress &&\n comparison.sections.residentialAddress.hasDifferences) ||\n (config.syncFields?.taxDetails && comparison.sections.taxDetails.hasDifferences))\n ) {\n // Differences found between the Worknice person and the remote\n // person. Update either the Worknice person or the remote\n // person with details from the other.\n\n const worknicePersonUpdatedAt =\n mode === \"remote-to-worknice\"\n ? Temporal.Instant.fromEpochMilliseconds(-8640000000000000)\n : Temporal.Instant.from(worknicePerson.updatedAt);\n\n if (!isValidInstant(remotePerson.metadata.updatedAt)) {\n throw Error(\n `Invalid updatedAt value for ${config.appName} person \"${remotePersonName}\". Must be in ISO 8601 format, including a date, a time, and a time zone offset.`,\n {\n cause: Error(`Unable to parse: ${remotePerson.metadata.updatedAt}`),\n },\n );\n }\n\n const remotePersonUpdatedAt =\n mode === \"worknice-to-remote\"\n ? Temporal.Instant.fromEpochMilliseconds(-8640000000000000)\n : Temporal.Instant.from(remotePerson.metadata.updatedAt);\n\n if (isInstantAfter(worknicePersonUpdatedAt, remotePersonUpdatedAt)) {\n // The Worknice person was updated more recently than the remote\n // person. Update the remote person using details from Worknice.\n\n if (!updateRemotePerson) {\n throw Error(\n \"No updateRemotePerson function supplied to handleTriggerIntegrationSyncWebhook.\",\n );\n }\n\n try {\n await updateRemotePerson(worknicePersonDataTransferLine, {\n ...contextWithIntegration,\n connection: personConnection,\n });\n logger.info(`Updated ${config.appName} person \"${remotePersonName}\".`);\n } catch (error) {\n logger.indent(\n `Unable to update ${config.appName} person \"${remotePersonName}\" because of the following error:`,\n );\n logger.error(error);\n logger.dedent();\n }\n } else {\n // The remote person was updated more recently than the\n // Worknice person. Update the Worknice person using details\n // from the remote.\n\n try {\n const bankAccounts = validatePersonDataTransferLineBankAccounts(\n remotePersonDataTransferLine.bankAccounts,\n );\n const dateOfBirth = validatePersonDataTransferLineDateOfBirth(\n remotePersonDataTransferLine.dateOfBirth,\n );\n // emergencyContacts\n const fullName = validatePersonDataTransferLineFullName(\n remotePersonDataTransferLine.fullName,\n );\n const gender = validatePersonDataTransferLineGender(\n remotePersonDataTransferLine.gender,\n );\n const personalEmail = validatePersonDataTransferLinePersonalEmail(\n remotePersonDataTransferLine.personalEmail,\n );\n const personalPhone = validatePersonDataTransferLinePersonalPhone(\n remotePersonDataTransferLine.personalPhone,\n );\n // postalAddress\n // profile\n // remuneration\n const residentialAddress = validatePersonDataTransferLineResidentialAddress(\n remotePersonDataTransferLine.residentialAddress,\n );\n // // TODO: Enable syncing super funds. See PROD-2216.\n // const superFunds = validatePersonDataTransferLineSuperFunds(remotePersonDataTransferLine.superFunds);\n const taxDetails = validatePersonDataTransferLineTaxDetails(\n remotePersonDataTransferLine.taxDetails,\n );\n // // TODO: Enable syncing tenure. See PROD-1371.\n // const tenure = validatePersonDataTransferLineTenure(remotePersonDataTransferLine.tenure);\n\n const dataImport = await getDataImport();\n\n await worknice.createPersonDataImportLine({\n bankAccounts,\n config: {\n bankAccounts: config.syncFields?.bankAccounts ?? false,\n dateOfBirth: config.syncFields?.dateOfBirth ?? false,\n emergencyContacts: config.syncFields?.emergencyContacts ?? false,\n fullName: config.syncFields?.fullName ?? false,\n gender: config.syncFields?.gender ?? false,\n personalEmail: config.syncFields?.personalEmail ?? false,\n personalPhone: config.syncFields?.personalPhone ?? false,\n postalAddress: config.syncFields?.postalAddress ?? false,\n profile: config.syncFields?.profile ?? false,\n remuneration: config.syncFields?.remuneration ?? false,\n residentialAddress: config.syncFields?.residentialAddress ?? false,\n superFunds: config.syncFields?.superFunds ?? false,\n taxDetails: config.syncFields?.taxDetails ?? false,\n tenure: config.syncFields?.tenure ?? false,\n },\n dataImportId: dataImport.id,\n dateOfBirth,\n emergencyContacts: null,\n fullName,\n gender,\n personalEmail,\n personalPhone,\n personId: worknicePerson.id,\n postalAddress: null,\n residentialAddress,\n // TODO: Enable syncing super funds. See PROD-2216.\n superFunds: null,\n taxDetails,\n // TODO: Enable syncing tenure. See PROD-1371.\n tenure: null,\n });\n\n logger.info(`Updated Worknice person \"${worknicePerson.displayName}\".`);\n } catch (error) {\n logger.indent(\n `Unable to update Worknice person \"${worknicePerson.displayName}\" because of the following error:`,\n );\n logger.error(error);\n logger.dedent();\n }\n }\n }\n }\n\n logger.dedent(\"Finished updating people with connections marked as merged.\");\n }\n\n logger.indent(\"Merging unmerged connections…\");\n\n const connectedConnections = personConnections.filter(\n (\n personConnection,\n ): personConnection is typeof personConnection & {\n status: ConnectionStatus.Connected;\n } => personConnection.status === ConnectionStatus.Connected,\n );\n\n for (const personConnection of connectedConnections) {\n let worknicePerson = people.find((person) => person.id === personConnection.person.id);\n\n const remotePerson = remotePeople.find(\n (person) => person.metadata.sourceId === personConnection.remote.id,\n );\n\n try {\n if (!worknicePerson) {\n throw Error(\n `Unable to find person in Worknice with the ID \"${personConnection.person.id}\".`,\n );\n }\n if (!remotePerson) {\n throw Error(\n `Unable to find person in ${config.appName} with the ID \"${personConnection.remote.id}\".`,\n );\n }\n } catch (error) {\n logger.indent(\n `Unable to merge Worknice person \"${personConnection.person.displayName}\" with ${config.appName} person \"${personConnection.remote.name}\" because of the following error:`,\n );\n logger.error(error);\n logger.dedent();\n continue;\n }\n\n const remotePersonName = personToName(remotePerson);\n\n logger.indent(\n `Merging Worknice person \"${worknicePerson.displayName}\" with ${config.appName} person \"${remotePersonName}\"…`,\n );\n\n try {\n if (mode !== \"connection-only\") {\n const worknicePersonUpdatedAt =\n mode === \"remote-to-worknice\"\n ? Temporal.Instant.fromEpochMilliseconds(-8640000000000000)\n : Temporal.Instant.from(worknicePerson.updatedAt);\n\n if (!isValidInstant(remotePerson.metadata.updatedAt)) {\n throw Error(\n `Invalid updatedAt value for ${config.appName} person \"${remotePersonName}\". Must be in ISO 8601 format, including a date, a time, and a time zone offset.`,\n {\n cause: Error(`Unable to parse: ${remotePerson.metadata.updatedAt}`),\n },\n );\n }\n\n const remotePersonUpdatedAt =\n mode === \"worknice-to-remote\"\n ? Temporal.Instant.fromEpochMilliseconds(-8640000000000000)\n : Temporal.Instant.from(remotePerson.metadata.updatedAt);\n\n const [primaryDataTransferLine, secondaryDataTransferLine] = isInstantAfter(\n worknicePersonUpdatedAt,\n remotePersonUpdatedAt,\n )\n ? [worknicePersonToPersonDataTransferLine(worknicePerson), remotePerson]\n : [remotePerson, worknicePersonToPersonDataTransferLine(worknicePerson)];\n const mergedDataTransferLine = mergePersonDataTransferLines(\n primaryDataTransferLine,\n secondaryDataTransferLine,\n );\n\n const bankAccounts = validatePersonDataTransferLineBankAccounts(\n mergedDataTransferLine.bankAccounts,\n );\n const dateOfBirth = validatePersonDataTransferLineDateOfBirth(\n mergedDataTransferLine.dateOfBirth,\n );\n // emergencyContacts\n const fullName = validatePersonDataTransferLineFullName(mergedDataTransferLine.fullName);\n const gender = validatePersonDataTransferLineGender(mergedDataTransferLine.gender);\n const personalEmail = validatePersonDataTransferLinePersonalEmail(\n mergedDataTransferLine.personalEmail,\n );\n const personalPhone = validatePersonDataTransferLinePersonalPhone(\n mergedDataTransferLine.personalPhone,\n );\n // postalAddress\n const profile = validatePersonDataTransferLineProfile(mergedDataTransferLine.profile);\n // remuneration\n const residentialAddress = validatePersonDataTransferLineResidentialAddress(\n mergedDataTransferLine.residentialAddress,\n );\n // // TODO: Enable syncing super funds. See PROD-2216.\n // const superFunds = validatePersonDataTransferLineSuperFunds(mergedDataTransferLine.superFunds);\n const taxDetails = validatePersonDataTransferLineTaxDetails(\n mergedDataTransferLine.taxDetails,\n );\n // // TODO: Enable syncing tenure. See PROD-1371.\n // const tenure = validatePersonDataTransferLineTenure(mergedDataTransferLine.tenure);\n\n if (mode !== \"worknice-to-remote\") {\n const dataImport = await getDataImport();\n\n await worknice.createPersonDataImportLine({\n bankAccounts,\n config: {\n bankAccounts: config.syncFields?.bankAccounts ?? false,\n dateOfBirth: config.syncFields?.dateOfBirth ?? false,\n emergencyContacts: config.syncFields?.emergencyContacts ?? false,\n fullName: config.syncFields?.fullName ?? false,\n gender: config.syncFields?.gender ?? false,\n personalEmail: config.syncFields?.personalEmail ?? false,\n personalPhone: config.syncFields?.personalPhone ?? false,\n postalAddress: config.syncFields?.postalAddress ?? false,\n profile: config.syncFields?.profile ?? false,\n remuneration: config.syncFields?.remuneration ?? false,\n residentialAddress: config.syncFields?.residentialAddress ?? false,\n superFunds: config.syncFields?.superFunds ?? false,\n taxDetails: config.syncFields?.taxDetails ?? false,\n tenure: config.syncFields?.tenure ?? false,\n },\n dataImportId: dataImport.id,\n dateOfBirth,\n emergencyContacts: null,\n fullName,\n gender,\n personalEmail,\n personalPhone,\n personId: worknicePerson.id,\n postalAddress: null,\n residentialAddress,\n // TODO: Enable syncing super funds. See PROD-2216.\n superFunds: null,\n taxDetails,\n // TODO: Enable syncing tenure. See PROD-1371.\n tenure: null,\n });\n\n worknicePerson = await worknice.updatePerson({\n displayName: profile?.displayName,\n employeeCode: remotePerson.metadata.employeeCode,\n personId: worknicePerson.id,\n profileEmail: profile?.profileEmail,\n profilePhone: profile?.profilePhone,\n });\n\n logger.info(`Updated Worknice person \"${worknicePerson.displayName}\".`);\n }\n\n if (mode !== \"remote-to-worknice\") {\n if (!updateRemotePerson) {\n throw Error(\n \"No updateRemotePerson function supplied to handleTriggerIntegrationSyncWebhook.\",\n );\n }\n\n await updateRemotePerson(\n {\n bankAccounts,\n dateOfBirth,\n emergencyContacts: null,\n fullName,\n gender,\n metadata: {\n deleted: false,\n employeeCode: worknicePerson.employeeCode ?? null,\n sourceId: worknicePerson.id,\n targetId: remotePerson.metadata.sourceId,\n updatedAt: worknicePerson.updatedAt,\n },\n personalEmail,\n personalPhone,\n postalAddress: null,\n profile: {\n displayName: worknicePerson.displayName,\n profileEmail: worknicePerson.profileEmail ?? null,\n profilePhone: worknicePerson.profilePhone ?? null,\n },\n residentialAddress,\n // TODO: Enable syncing super funds. See PROD-2216.\n superFunds: null,\n taxDetails,\n // TODO: Enable syncing tenure. See PROD-1371.\n tenure: null,\n },\n {\n ...contextWithIntegration,\n connection: personConnection,\n },\n );\n\n logger.info(`Updated ${config.appName} person \"${remotePersonName}\".`);\n }\n }\n\n await worknice.updatePersonConnection({\n personConnectionId: personConnection.id,\n personId: personConnection.person.id,\n remote: {\n id: remotePerson.metadata.sourceId,\n name: remotePersonName,\n },\n status: ConnectionStatus.Merged,\n });\n\n logger.dedent(`Finished merging.`);\n } catch (error) {\n logger.indent(\n `Unable to merge ${config.appName} person \"${remotePersonName}\" and Worknice person \"${worknicePerson.displayName}\" because of the following error:`,\n );\n logger.error(error);\n logger.dedent();\n logger.dedent();\n }\n }\n\n logger.dedent(\"Finished merging unmerged connections.\");\n\n if (mode === \"two-way\" || mode === \"worknice-to-remote\") {\n logger.indent(`Adding new people to ${config.appName}…`);\n\n const localOnlyConnections = personConnections.filter(\n (\n personConnection,\n ): personConnection is typeof personConnection & {\n status: ConnectionStatus.LocalOnly;\n } => personConnection.status === ConnectionStatus.LocalOnly,\n );\n\n for (const personConnection of localOnlyConnections) {\n const worknicePerson = people.find((person) => person.id === personConnection.person.id);\n\n if (!worknicePerson) {\n throw Error(\n `Unable to find person in Worknice with the ID \"${personConnection.person.id}\".`,\n );\n }\n\n try {\n if (!createRemotePerson) {\n throw Error(\n \"No createRemotePerson function supplied to handleTriggerIntegrationSyncWebhook.\",\n );\n }\n\n const { status, ...remote } = await createRemotePerson(\n {\n ...worknicePersonToPersonDataTransferLine(worknicePerson),\n metadata: {\n deleted: false,\n employeeCode: worknicePerson.employeeCode ?? null,\n sourceId: worknicePerson.id,\n targetId: null,\n updatedAt: worknicePerson.updatedAt,\n },\n },\n {\n ...contextWithIntegration,\n connection: personConnection,\n },\n );\n\n if (personConnections.some((connection) => connection.remote?.id === remote.id)) {\n throw Error(\n `A connection already exists for the ${config.appName} person \"${remote.name}\".`,\n );\n }\n\n await worknice.updatePersonConnection({\n personConnectionId: personConnection.id,\n personId: personConnection.person.id,\n remote,\n status: status ?? ConnectionStatus.Merged,\n });\n\n logger.info(`Added new person \"${remote.name}\" to ${config.appName}.`);\n } catch (error) {\n logger.indent(\n `Unable to add Worknice person \"${worknicePerson.displayName}\" to ${config.appName} because of the following error:`,\n );\n logger.error(error);\n logger.dedent();\n }\n }\n\n logger.dedent(`Finished adding new people to ${config.appName}.`);\n }\n\n return {\n remotePeople,\n };\n};\n\nconst personToName = (person: Person) => {\n if (\n (person.fullName?.givenName ?? \"\").trim() !== \"\" &&\n (person.fullName?.familyName ?? \"\").trim() !== \"\"\n ) {\n return `${person.fullName?.givenName} ${person.fullName?.familyName}`;\n }\n\n if ((person.profile?.displayName ?? \"\").trim() !== \"\") {\n return `${person.profile?.displayName}`;\n }\n\n return `(unnamed person ${person.metadata.sourceId})`;\n};\n\nconst worknicePersonToPersonDataTransferLine = (\n worknicePerson: NonNullable<GetPeopleQuery[\"org\"][\"people\"][number]>,\n): Omit<Person, \"metadata\"> => ({\n ...validatePersonDataTransferLine({\n bankAccounts: worknicePerson.bankAccount1AllocationMethod\n ? {\n bankAccount1Allocation: worknicePerson.bankAccount1Allocation ?? null,\n bankAccount1AllocationMethod: worknicePerson.bankAccount1AllocationMethod,\n bankAccount1Bsb: worknicePerson.bankAccount1Bsb ?? null,\n bankAccount1Name: worknicePerson.bankAccount1Name ?? null,\n bankAccount1Number: worknicePerson.bankAccount1Number ?? null,\n bankAccount2Allocation: worknicePerson.bankAccount2Allocation ?? null,\n bankAccount2AllocationMethod: worknicePerson.bankAccount2AllocationMethod ?? null,\n bankAccount2Bsb: worknicePerson.bankAccount2Bsb ?? null,\n bankAccount2Name: worknicePerson.bankAccount2Name ?? null,\n bankAccount2Number: worknicePerson.bankAccount2Number ?? null,\n bankAccount3Allocation: worknicePerson.bankAccount3Allocation ?? null,\n bankAccount3AllocationMethod: worknicePerson.bankAccount3AllocationMethod ?? null,\n bankAccount3Bsb: worknicePerson.bankAccount3Bsb ?? null,\n bankAccount3Name: worknicePerson.bankAccount3Name ?? null,\n bankAccount3Number: worknicePerson.bankAccount3Number ?? null,\n bankAccount4Allocation: worknicePerson.bankAccount4Allocation ?? null,\n bankAccount4AllocationMethod: worknicePerson.bankAccount4AllocationMethod ?? null,\n bankAccount4Bsb: worknicePerson.bankAccount4Bsb ?? null,\n bankAccount4Name: worknicePerson.bankAccount4Name ?? null,\n bankAccount4Number: worknicePerson.bankAccount4Number ?? null,\n bankAccount5Allocation: worknicePerson.bankAccount5Allocation ?? null,\n bankAccount5AllocationMethod: worknicePerson.bankAccount5AllocationMethod ?? null,\n bankAccount5Bsb: worknicePerson.bankAccount5Bsb ?? null,\n bankAccount5Name: worknicePerson.bankAccount5Name ?? null,\n bankAccount5Number: worknicePerson.bankAccount5Number ?? null,\n }\n : null,\n dateOfBirth: worknicePerson.dateOfBirth ? { dateOfBirth: worknicePerson.dateOfBirth } : null,\n emergencyContacts: null,\n fullName: worknicePerson.givenName\n ? {\n familyName: worknicePerson.familyName ?? null,\n givenName: worknicePerson.givenName,\n otherGivenNames: worknicePerson.otherGivenNames ?? null,\n }\n : null,\n gender: worknicePerson.gender\n ? {\n gender: worknicePerson.gender,\n }\n : null,\n personalEmail: worknicePerson.personalEmail\n ? {\n personalEmail: worknicePerson.personalEmail,\n }\n : null,\n personalPhone: worknicePerson.personalPhone\n ? {\n personalPhone: worknicePerson.personalPhone,\n }\n : null,\n postalAddress: null,\n profile: null,\n residentialAddress: worknicePerson.residentialAddressLine1\n ? {\n residentialAddressCity: worknicePerson.residentialAddressCity ?? null,\n // FIXME: This should not default to \"Australia\". See PROD-1085.\n residentialAddressCountry: worknicePerson.residentialAddressCountry ?? \"Australia\",\n residentialAddressLine1: worknicePerson.residentialAddressLine1,\n residentialAddressLine2: worknicePerson.residentialAddressLine2 ?? null,\n residentialAddressPostcode: worknicePerson.residentialAddressPostcode ?? null,\n residentialAddressState: worknicePerson.residentialAddressState ?? null,\n }\n : null,\n // TODO: Enable syncing super funds. See PROD-2216.\n superFunds: null,\n taxDetails: worknicePerson.taxFileNumberExemption\n ? {\n hasLoanOrStudentDebt: worknicePerson.hasLoanOrStudentDebt ?? null,\n residencyStatus: worknicePerson.residencyStatus ?? null,\n taxFileNumber: worknicePerson.taxFileNumber ?? null,\n taxFileNumberExemption: worknicePerson.taxFileNumberExemption ?? null,\n taxFreeThresholdClaimed: worknicePerson.taxFreeThresholdClaimed ?? null,\n }\n : null,\n // TODO: Enable syncing tenure. See PROD-1371.\n tenure: null,\n }),\n profile: {\n displayName: worknicePerson.displayName,\n profileEmail: worknicePerson.profileEmail ?? null,\n profilePhone: worknicePerson.profilePhone ?? null,\n },\n});\n\nconst handleLeaveRequestsSync = async <Env, Req extends Request>(\n { getConfig, getRemoteLeaveRequests }: Tasks<Env, Req>,\n context: Context<Env, Req> & { remotePeople: Array<Person> },\n) => {\n const { logger, payload, worknice } = context;\n\n if (!getRemoteLeaveRequests) {\n throw Error(\"getRemoteLeaveRequests is not defined\");\n }\n\n logger.indent(\"Retrieving Worknice data…\");\n\n const integration = await worknice.getIntegration({\n integrationId: payload.integration.id,\n });\n\n logger.info(\"Retrieved integration from Worknice.\");\n\n const personConnections = await worknice.getPersonConnections({\n integrationId: payload.integration.id,\n });\n\n logger.info(`Retrieved ${personConnections.length} person connection(s) from Worknice.`);\n\n const workniceLeaveRequests = await worknice.getLeaveRequests({ integrationId: integration.id });\n\n logger.info(`Retrieved ${workniceLeaveRequests.length} leave request(s) from Worknice.`);\n\n logger.dedent(\"Completed retrieving Worknice data.\");\n\n const contextWithIntegration = {\n ...context,\n integration,\n };\n\n logger.indent(\"Loading configuration details…\");\n\n const config = await getConfig(contextWithIntegration);\n\n logger.dedent(\"Finished loading configuration details.\");\n\n logger.indent(`Retrieving ${config.appName} data…`);\n\n let remoteLeaveRequests: Array<LeaveRequest>;\n\n try {\n remoteLeaveRequests = await getRemoteLeaveRequests(contextWithIntegration);\n } catch (error) {\n logger.info(`An error occurred while retrieving data from ${config.appName}.`);\n throw error;\n }\n\n logger.info(`Retrieved ${remoteLeaveRequests.length} leave request(s) from ${config.appName}.`);\n\n logger.dedent(`Completed retrieving ${config.appName} data.`);\n\n logger.indent(\"Updating leave requests…\");\n\n for (const remoteLeaveRequest of remoteLeaveRequests) {\n const workniceLeaveRequest = workniceLeaveRequests.find(\n (leaveRequest) => leaveRequest.remoteId === remoteLeaveRequest.remoteId,\n );\n\n const personConnection:\n | ((typeof personConnections)[number] & {\n remote: NonNullable<(typeof personConnections)[number][\"remote\"]>;\n })\n | undefined = personConnections\n .filter((x) => x.remote !== null)\n .find((connection) => connection.remote.id === remoteLeaveRequest.personRemoteId);\n\n if (personConnection === undefined) {\n logger.info(\n `No person connection found for ${config.appName} person with remote ID \"${remoteLeaveRequest.personRemoteId}\".`,\n );\n continue;\n }\n\n if (workniceLeaveRequest) {\n await worknice.updateLeaveRequest({\n endDate: remoteLeaveRequest.endDate,\n endTime: remoteLeaveRequest.endTime,\n id: workniceLeaveRequest.id,\n leaveCategory: {\n id: remoteLeaveRequest.leaveCategory.id,\n name: remoteLeaveRequest.leaveCategory.name,\n },\n notes: remoteLeaveRequest.notes,\n personConnectionId: workniceLeaveRequest.personConnection.id,\n remoteId: remoteLeaveRequest.remoteId,\n responsibleId: workniceLeaveRequest.responsible?.id,\n startDate: remoteLeaveRequest.startDate,\n startTime: remoteLeaveRequest.startTime,\n status: remoteLeaveRequest.status,\n });\n\n logger.info(\n `Updated leave request \"${workniceLeaveRequest.leaveCategory.name} ${workniceLeaveRequest.startDate}–${workniceLeaveRequest.endDate}\" for ${config.appName} person \"${personConnection.remote.name}\".`,\n );\n } else {\n await worknice.createLeaveRequest({\n endDate: remoteLeaveRequest.endDate,\n endTime: remoteLeaveRequest.endTime,\n leaveCategory: {\n id: remoteLeaveRequest.leaveCategory.id,\n name: remoteLeaveRequest.leaveCategory.name,\n },\n notes: remoteLeaveRequest.notes,\n personConnectionId: personConnection.id,\n remoteId: remoteLeaveRequest.remoteId,\n startDate: remoteLeaveRequest.startDate,\n startTime: remoteLeaveRequest.startTime,\n status: remoteLeaveRequest.status,\n });\n\n logger.info(\n `Created leave request \"${remoteLeaveRequest.leaveCategory.name} ${remoteLeaveRequest.startDate}–${remoteLeaveRequest.endDate}\" for ${config.appName} person \"${personConnection.remote.name}\".`,\n );\n }\n }\n\n logger.dedent(\"Finished updating leave requests.\");\n};\n\nexport default handleTriggerIntegrationSyncWebhook;\n"],"mappings":"AAAA,SAAS,gBAAgB;AAEzB,OAAO,oBAAoB;AAC3B,OAAO,oBAAoB;AAG3B;AAAA,EACE;AAAA,EAGA;AAAA,EACA;AAAA,OAEK;AAEP,OAAO,oCAAoC;AAC3C,OAAO,kCAAkC;AACzC,OAAO,oCAAoC;AAC3C,OAAO,gDAAgD;AACvD,OAAO,+CAA+C;AACtD,OAAO,4CAA4C;AACnD,OAAO,0CAA0C;AACjD,OAAO,iDAAiD;AACxD,OAAO,iDAAiD;AACxD,OAAO,2CAA2C;AAClD,OAAO,sDAAsD;AAC7D,OAAO,8CAA8C;AAErD,OAAO,+BAA+B;AAoHtC,MAAM,sCAAsC,OAC1C,SACA,OACA,YAEA;AAAA,EACE;AAAA,EACA;AAAA,IACE,aAAa,MAAM;AAAA,IACnB,eAAe,OAAO,YAAY;AAChC,YAAM,EAAE,QAAQ,SAAS,SAAS,IAAI;AACtC,UAAI;AACF,eAAO,QAAQ,UAA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,IAAI;AAAA,MAC9L;AAAA,IACF;AAAA,EACF;AAEA,SAAO,OAAO,mCAAmC;AACnD;AAEA,IAAO,8CAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/helpers/handleTriggerIntegrationSyncWebhook.ts"],"sourcesContent":["import { Temporal } from \"temporal-polyfill\";\n\nimport isInstantAfter from \"@worknice/utils/temporal/isInstantAfter\";\nimport isValidInstant from \"@worknice/utils/temporal/isValidInstant\";\nimport type { TriggerIntegrationSyncRequestPayload } from \"@worknice/utils/webhooks\";\n\nimport {\n ConnectionStatus,\n type GetPeopleQuery,\n type LeaveCategoryInput,\n LeaveRequestStatus,\n PersonRole,\n type WorkniceClient,\n} from \"../api/_types.js\";\nimport type { PersonDataTransferLine } from \"../employee-records/_types.js\";\nimport comparePersonDataTransferLines from \"../employee-records/comparePersonDataTransferLines.js\";\nimport mergePersonDataTransferLines from \"../employee-records/mergePersonDataTransferLines.js\";\nimport validatePersonDataTransferLine from \"../employee-records/validatePersonDataTransferLine.js\";\nimport validatePersonDataTransferLineBankAccounts from \"../employee-records/validatePersonDataTransferLineBankAccounts.js\";\nimport validatePersonDataTransferLineDateOfBirth from \"../employee-records/validatePersonDataTransferLineDateOfBirth.js\";\nimport validatePersonDataTransferLineFullName from \"../employee-records/validatePersonDataTransferLineFullName.js\";\nimport validatePersonDataTransferLineGender from \"../employee-records/validatePersonDataTransferLineGender.js\";\nimport validatePersonDataTransferLinePersonalEmail from \"../employee-records/validatePersonDataTransferLinePersonalEmail.js\";\nimport validatePersonDataTransferLinePersonalPhone from \"../employee-records/validatePersonDataTransferLinePersonalPhone.js\";\nimport validatePersonDataTransferLineProfile from \"../employee-records/validatePersonDataTransferLineProfile.js\";\nimport validatePersonDataTransferLineResidentialAddress from \"../employee-records/validatePersonDataTransferLineResidentialAddress.js\";\nimport validatePersonDataTransferLineTaxDetails from \"../employee-records/validatePersonDataTransferLineTaxDetails.js\";\nimport type { HandlerOptions, TaskContext } from \"./_types.js\";\nimport handleRequestWithWorknice from \"./handleRequestWithWorknice.js\";\n\n// TODO: Remove `integration` from the context once Notebook has been updated to\n// provide fresh integration details with each request. See PROD-3146.\ntype Context<Env, Req extends Request = Request> = TaskContext<\n TriggerIntegrationSyncRequestPayload,\n Env,\n Req\n> & {\n /**\n * @deprecated Use `payload.integration` instead.\n */\n integration: Awaited<ReturnType<WorkniceClient[\"getIntegration\"]>>;\n};\n\ntype ConnectionContext<Env, Req extends Request = Request> = Context<Env, Req> & {\n connection: Awaited<ReturnType<WorkniceClient[\"getPersonConnections\"]>>[number];\n};\n\ntype Person = Omit<PersonDataTransferLine, \"profile\"> & {\n profile: NonNullable<PersonDataTransferLine[\"profile\"]>;\n} & {\n metadata: {\n deleted: boolean;\n employeeCode: string | null;\n sourceId: string;\n targetId: string | null;\n updatedAt: string;\n };\n};\n\ntype LeaveRequest = {\n endDate: string;\n endTime: string | null;\n leaveCategory: LeaveCategoryInput;\n notes: string | null;\n personRemoteId: string;\n remoteId: string;\n startDate: string;\n startTime: string | null;\n status: LeaveRequestStatus;\n};\n\ntype Tasks<Env, Req extends Request = Request> = {\n createRemotePerson?: (\n person: Person,\n context: ConnectionContext<Env, Req>,\n ) => Promise<{\n id: string;\n name: string;\n status?: ConnectionStatus.Connected | ConnectionStatus.Merged;\n }>;\n getApiToken: (\n context: Pick<Context<Env, Req>, \"env\" | \"logger\" | \"payload\" | \"request\">,\n ) => Promise<string>;\n getConfig: (context: Context<Env, Req>) => Promise<Config>;\n getEnv: (context: Pick<Context<Env, Req>, \"logger\" | \"payload\" | \"request\">) => Promise<Env>;\n getRemoteLeaveRequests?: (\n context: Context<Env, Req> & { remotePeople: Array<Person> },\n ) => Promise<Array<LeaveRequest>>;\n getRemotePeople: (context: Context<Env, Req>) => Promise<Array<Person>>;\n heartbeat?: (context: Omit<Context<Env, Req>, \"integration\">) => Promise<void>;\n updateRemotePerson?: (person: Person, context: ConnectionContext<Env, Req>) => Promise<unknown>;\n};\n\ntype Config = {\n appName: string;\n /**\n * If true, new people will be automatically created in Worknice when a new\n * person is detected in the remote app, otherwise a person connection is\n * created with a \"remote-only\" status.\n */\n automaticCreation?: boolean;\n /**\n * If true, connections will be automatically matched if any of the\n * following conditions are met:\n *\n * - Worknice person employee code matches remote person employee code\n * - Worknice person personal email matches remote person personal email\n * - Worknice person profile email matches remote person profile email\n */\n automaticMatching?: boolean;\n /**\n * @value \"connection-only\" - Only update person connections.\n * @value \"remote-to-worknice\" - Update Worknice people with details from\n * remote people.\n * @value \"two-way\" - Update both Worknice people and remote people with\n * details from each other.\n * @value \"worknice-to-remote\" - Update remote people with details from\n * Worknice people.\n */\n mode?:\n | \"connection-only\"\n | \"remote-to-worknice\"\n | \"two-way\"\n | \"worknice-to-remote\"\n // Deprecated: Use `worknice-to-remote` instead.\n | \"one-way\";\n syncFields?: {\n bankAccounts?: boolean;\n dateOfBirth?: boolean;\n emergencyContacts?: boolean;\n fullName?: boolean;\n gender?: boolean;\n personalEmail?: boolean;\n personalPhone?: boolean;\n postalAddress?: boolean;\n profile?: boolean;\n remuneration?: boolean;\n residentialAddress?: boolean;\n superFunds?: boolean;\n taxDetails?: boolean;\n tenure?: boolean;\n };\n};\n\nconst handleTriggerIntegrationSyncWebhook = async <Env, Req extends Request = Request>(\n request: Req,\n tasks: Tasks<Env, Req>,\n options?: HandlerOptions,\n) =>\n handleRequestWithWorknice<TriggerIntegrationSyncRequestPayload, undefined, Env, Req>(\n request,\n {\n getApiToken: tasks.getApiToken,\n handleRequest: async (context) => {\n const { logger, payload, worknice } = context;\n try {\n logger.connect(worknice, payload.integration.id);\n\n const integration = await worknice.getIntegration({\n integrationId: payload.integration.id,\n });\n\n if (integration.archived) {\n logger.info(\"Integration is archived. Skipping sync.\");\n return;\n }\n\n if (integration.status !== \"SYNCING\") {\n logger.info(`Integration status is \"${integration.status}\". Skipping sync.`);\n if (tasks.heartbeat) await tasks.heartbeat(context);\n return;\n }\n\n if (payload.integration.features.peopleSync === true) {\n logger.indent(\"Syncing people…\");\n\n const { remotePeople } = await handlePeopleSync<Env, Req>(tasks, {\n ...context,\n integration,\n });\n\n logger.dedent(\"Finished syncing people.\");\n\n if (payload.integration.features.leave === true) {\n if (tasks.getRemoteLeaveRequests !== undefined) {\n logger.indent(\"Syncing leave requests…\");\n\n await handleLeaveRequestsSync<Env, Req>(tasks, {\n ...context,\n integration,\n remotePeople,\n });\n\n logger.dedent(\"Finished syncing leave requests.\");\n } else {\n logger.debug(\n \"Skipping leave request sync: `getRemoteLeaveRequests` is not configured\",\n );\n }\n } else {\n logger.debug(\"Skipping leave request sync: leave not enabled\");\n }\n }\n await worknice.completeSync({ integrationId: payload.integration.id });\n } catch (error) {\n // TODO: Set the sync result to \"ERROR\". See PROD-2089.\n await worknice.completeSync({ integrationId: payload.integration.id });\n throw error;\n }\n },\n parseRequest: async (context) => {\n const payload = await context.request.json();\n return {\n env: await tasks.getEnv({ ...context, payload }),\n payload,\n };\n },\n },\n {\n processName: \"Sync\",\n ...options,\n },\n );\n\n/**\n * The process for syncing people has four steps:\n *\n * 1. Update person connections: Create new person connections for Worknice\n * people or remote people that don't have existing connections. If needed,\n * update names of existing person connections. If enabled, automatically\n * match connections.\n *\n * 2. Update merged people: Copy details from the Worknice people to remote\n * people or vice-versa (based on whichever one was updated most recently)\n * for person connections that are already marked as merged.\n *\n * 3. Merge matched people: Update both Worknice people and remote people for\n * person connections that are marked as matched using details from both\n * people merged together. Mark the connections as merged.\n *\n * 4. Add new people to the remote app: Create new people in the remote app for\n * connections that are unmatched and local-only. Mark the connections as\n * merged.\n */\nconst handlePeopleSync = async <Env, Req extends Request>(\n { createRemotePerson, getConfig, getRemotePeople, updateRemotePerson }: Tasks<Env, Req>,\n context: Context<Env, Req>,\n): Promise<{\n remotePeople: Array<Person>;\n}> => {\n const { logger, integration, payload, worknice } = context;\n\n let cachedDataImport: Awaited<ReturnType<WorkniceClient[\"createDataImport\"]>>;\n\n const getDataImport = async () => {\n if (!cachedDataImport) {\n cachedDataImport = await worknice.createDataImport({\n integrationId: payload.integration.id,\n });\n }\n\n return cachedDataImport;\n };\n\n logger.indent(\"Retrieving Worknice data…\");\n\n const personConnections = await worknice.getPersonConnections({\n integrationId: payload.integration.id,\n });\n\n logger.info(`Retrieved ${personConnections.length} person connection(s) from Worknice.`);\n\n const people = await worknice.getPeople({ orgId: integration.org.id });\n\n logger.info(`Retrieved ${people.length} person(s) from Worknice.`);\n\n logger.dedent(\"Completed retrieving Worknice data.\");\n\n const contextWithIntegration = {\n ...context,\n integration,\n };\n\n logger.indent(\"Loading configuration details…\");\n\n const config = await getConfig(contextWithIntegration);\n\n const mode =\n config.mode === \"one-way\" ? \"worknice-to-remote\" : (config.mode ?? \"connection-only\");\n\n logger.info(`Mode: ${mode}`);\n logger.info(\n `Automatically create new people in Worknice: ${config.automaticCreation ? \"enabled\" : \"disabled\"}`,\n );\n logger.info(\n `Automatically match people using email addresses and employee codes: ${config.automaticMatching ? \"enabled\" : \"disabled\"}`,\n );\n\n logger.dedent(\"Finished loading configuration details.\");\n\n logger.indent(`Retrieving ${config.appName} data…`);\n\n let remotePeople: Person[];\n\n try {\n remotePeople = await getRemotePeople(contextWithIntegration);\n } catch (error) {\n logger.info(`An error occurred while retrieving data from ${config.appName}.`);\n throw error;\n }\n\n logger.info(`Retrieved ${remotePeople.length} person(s) from ${config.appName}.`);\n\n logger.dedent(`Completed retrieving ${config.appName} data.`);\n\n logger.indent(\"Updating person connections…\");\n\n for (const remotePerson of remotePeople) {\n const remotePersonName = personToName(remotePerson);\n try {\n const remotePersonConnection = personConnections.find(\n (\n connection,\n ): connection is typeof connection & {\n status:\n | ConnectionStatus.Connected\n | ConnectionStatus.Merged\n | ConnectionStatus.RemoteOnly;\n } => connection.remote?.id === remotePerson.metadata.sourceId,\n );\n\n if (remotePerson.metadata.deleted) {\n // The remote person has been deleted. If they have a person\n // connection, it should be deleted.\n\n if (remotePersonConnection) {\n await worknice.deletePersonConnection({\n personConnectionId: remotePersonConnection.id,\n });\n\n logger.info(\n `Deleted connection for ${config.appName} person \"${remotePersonName}\" because they have been terminated.`,\n );\n }\n } else {\n // A connection for remote person should be added or updated in\n // Worknice.\n\n if (\n remotePersonConnection &&\n (remotePersonConnection.status === ConnectionStatus.Connected ||\n remotePersonConnection.status === ConnectionStatus.Merged)\n ) {\n // The remote person is already connected to a Worknice person.\n\n if (remotePersonConnection.remote?.name !== remotePersonName) {\n // The employee's name has changed in the remote app and that\n // needs to be reflected in the person connection in Worknice.\n\n const connection = await worknice.updatePersonConnection({\n personConnectionId: remotePersonConnection.id,\n personId: remotePersonConnection.person.id,\n remote: {\n id: remotePerson.metadata.sourceId,\n name: remotePersonName,\n },\n status: remotePersonConnection.status,\n });\n\n personConnections.splice(\n personConnections.indexOf(remotePersonConnection),\n 1,\n connection,\n );\n\n logger.info(\n `Updated person connection remote name from \"${remotePersonConnection.remote?.name}\" to \"${remotePersonName}\".`,\n );\n }\n } else {\n // The remote person is not already connected to a Worknice person, but\n // could already have a remote-only connection.\n\n if (remotePersonConnection && remotePersonConnection.remote?.name !== remotePersonName) {\n // The person's name has changed in the remote and that\n // needs to be reflected in the person connection in\n // Worknice.\n\n const connection = await worknice.updatePersonConnection({\n personConnectionId: remotePersonConnection.id,\n remote: {\n id: remotePerson.metadata.sourceId,\n name: remotePersonName,\n },\n status: remotePersonConnection.status,\n });\n\n personConnections.splice(\n personConnections.indexOf(remotePersonConnection),\n 1,\n connection,\n );\n\n logger.info(\n `Updated person connection remote name from \"${remotePersonConnection.remote?.name}\" to \"${remotePersonName}\".`,\n );\n }\n\n const matchingWorknicePerson =\n people.find(\n (person) =>\n person.id === remotePerson.metadata.targetId ||\n (person.employeeCode !== null &&\n person.employeeCode === remotePerson.metadata.employeeCode) ||\n (person.personalEmail !== null &&\n person.personalEmail === remotePerson.personalEmail?.personalEmail) ||\n (person.profileEmail !== null &&\n person.profileEmail === remotePerson.profile?.profileEmail),\n ) ?? null;\n\n if (config.automaticMatching === true && matchingWorknicePerson) {\n // There is a person in Worknice with an ID, employee code\n // or email address that matches the remote person. The\n // Worknice person should be automatically connected to the\n // remote person.\n\n const personConnection = personConnections.find(\n (\n connection,\n ): connection is typeof connection & {\n status:\n | ConnectionStatus.Connected\n | ConnectionStatus.LocalOnly\n | ConnectionStatus.Merged;\n } => connection.person?.id === matchingWorknicePerson.id,\n );\n\n if (\n personConnection?.status === ConnectionStatus.Connected ||\n personConnection?.status === ConnectionStatus.Merged\n ) {\n // The person is already matched with a different remote person.\n\n logger.info(\n `Unable to automatically match Worknice person \"${matchingWorknicePerson.displayName}\" to ${config.appName} person \"${remotePersonName}\" because the Worknice person has already been matched to a different ${config.appName} person.`,\n );\n } else {\n // The Worknice person is not yet matched to a remote person. The\n // Worknice person and remote person records should be matched.\n\n if (personConnection) {\n // The Worknice person already has a local-only connection in this\n // integration that can be updated to match to this remote person.\n\n if (remotePersonConnection) {\n // There are person connections for both the Worknice\n // person and the remote person that need to be combined\n // into a single person connection.\n\n await worknice.deletePersonConnection({\n personConnectionId: personConnection.id,\n });\n\n personConnections.splice(personConnections.indexOf(personConnection), 1);\n\n const updatedConnection = await worknice.updatePersonConnection({\n personConnectionId: remotePersonConnection.id,\n personId: matchingWorknicePerson.id,\n remote: {\n id: remotePerson.metadata.sourceId,\n name: remotePersonName,\n },\n status: ConnectionStatus.Connected,\n });\n\n personConnections.splice(\n personConnections.indexOf(remotePersonConnection),\n 1,\n updatedConnection,\n );\n\n logger.info(\n `Automatically matched and combined person connections for Worknice person \"${matchingWorknicePerson.displayName}\" and ${config.appName} person \"${remotePersonName}\".`,\n );\n } else {\n // There is a local-only connection for this Worknice person\n // that should be updated to connect to this remote person.\n\n const updatedConnection = await worknice.updatePersonConnection({\n personConnectionId: personConnection.id,\n personId: personConnection.person.id,\n remote: {\n id: remotePerson.metadata.sourceId,\n name: remotePersonName,\n },\n status: ConnectionStatus.Connected,\n });\n\n personConnections.splice(\n personConnections.indexOf(personConnection),\n 1,\n updatedConnection,\n );\n\n logger.info(\n `Automatically matched existing person connection for Worknice person \"${matchingWorknicePerson.displayName}\" to ${config.appName} person \"${remotePersonName}\".`,\n );\n }\n } else {\n // The Worknice person does not have a connection in this\n // integration and should be connected now.\n\n if (remotePersonConnection) {\n // There is a remote-only connection for this remote person that\n // should be updated to match to this Worknice person.\n\n const updatedConnection = await worknice.updatePersonConnection({\n personConnectionId: remotePersonConnection.id,\n personId: matchingWorknicePerson.id,\n remote: {\n ...remotePersonConnection.remote,\n name: remotePersonName,\n },\n status: ConnectionStatus.Connected,\n });\n\n personConnections.splice(\n personConnections.indexOf(remotePersonConnection),\n 1,\n updatedConnection,\n );\n\n logger.info(\n `Automatically matched existing person connection for ${config.appName} person \"${remotePersonName}\" to Worknice person \"${matchingWorknicePerson.displayName}\".`,\n );\n } else {\n // There is no connection for the remote person or the\n // Worknice person in this integration. A new connection\n // should be created.\n\n const newPersonConnection = await worknice.createPersonConnection({\n integrationId: payload.integration.id,\n personId: matchingWorknicePerson.id,\n remote: {\n id: remotePerson.metadata.sourceId,\n name: remotePersonName,\n },\n status: ConnectionStatus.Connected,\n });\n\n personConnections.push(newPersonConnection);\n\n logger.info(\n `Created new person connection for ${config.appName} person \"${remotePersonName}\" and automatically matched to Worknice person \"${matchingWorknicePerson.displayName}\".`,\n );\n }\n }\n }\n } else if (remotePersonConnection === undefined) {\n // There is no person in Worknice which should be automatically\n // connected to this remote person and there is no existing connection\n // for this remote person.\n\n if (config.automaticCreation === true) {\n const person = await worknice.createPerson({\n displayName: remotePersonName,\n role: PersonRole.Employee,\n });\n\n const newPersonConnection = await worknice.createPersonConnection({\n integrationId: payload.integration.id,\n personId: person.id,\n remote: {\n id: remotePerson.metadata.sourceId,\n name: remotePersonName,\n },\n status: ConnectionStatus.Connected,\n });\n\n personConnections.push(newPersonConnection);\n\n logger.info(\n `Automatically created new person \"${remotePersonName}\" in Worknice from \"${remotePersonName}\" in ${config.appName}.`,\n );\n } else {\n const newPersonConnection = await worknice.createPersonConnection({\n integrationId: payload.integration.id,\n remote: {\n id: remotePerson.metadata.sourceId,\n name: remotePersonName,\n },\n status: ConnectionStatus.RemoteOnly,\n });\n\n personConnections.push(newPersonConnection);\n\n logger.info(\n `New person connection created for ${config.appName} person \"${remotePersonName}\".`,\n );\n }\n }\n }\n }\n } catch (error) {\n logger.indent(\n `Unable to update person connection for ${config.appName} person \"${remotePersonName}\" because of the following error:`,\n );\n logger.error(error);\n logger.dedent();\n }\n }\n\n logger.dedent(\"Finished updating person connections.\");\n\n if (mode !== \"connection-only\") {\n logger.indent(\"Updating people with connections marked as merged…\");\n\n const mergedConnections = personConnections.filter(\n (\n personConnection,\n ): personConnection is typeof personConnection & {\n status: ConnectionStatus.Merged;\n } => personConnection.status === ConnectionStatus.Merged,\n );\n\n for (const personConnection of mergedConnections) {\n const worknicePerson = people.find((person) => person.id === personConnection.person.id);\n const remotePerson = remotePeople.find(\n (person) => person.metadata.sourceId === personConnection.remote.id,\n );\n\n try {\n if (!worknicePerson) {\n throw Error(\n `Unable to find person in Worknice with the ID \"${personConnection.person.id}\".`,\n );\n }\n if (!remotePerson) {\n throw Error(\n `Unable to find person in ${config.appName} with the ID \"${personConnection.remote.id}\".`,\n );\n }\n } catch (error) {\n logger.indent(\n `Unable to update Worknice person \"${personConnection.person.displayName}\" and/or ${config.appName} person \"${personConnection.remote.name}\" because of the following error:`,\n );\n logger.error(error);\n logger.dedent();\n continue;\n }\n\n const remotePersonName = personToName(remotePerson);\n\n const worknicePersonDataTransferLine = {\n ...worknicePersonToPersonDataTransferLine(worknicePerson),\n metadata: {\n deleted: false,\n employeeCode: worknicePerson.employeeCode ?? null,\n sourceId: worknicePerson.id,\n targetId: remotePerson.metadata.sourceId,\n updatedAt: worknicePerson.updatedAt,\n },\n };\n\n const remotePersonDataTransferLine = remotePerson;\n\n const comparison = comparePersonDataTransferLines(\n worknicePersonDataTransferLine,\n remotePersonDataTransferLine,\n );\n\n if (\n comparison.hasDifferences &&\n ((config.syncFields?.bankAccounts && comparison.sections.bankAccounts.hasDifferences) ||\n (config.syncFields?.dateOfBirth && comparison.sections.dateOfBirth.hasDifferences) ||\n (config.syncFields?.fullName && comparison.sections.fullName.hasDifferences) ||\n (config.syncFields?.gender && comparison.sections.gender.hasDifferences) ||\n (config.syncFields?.personalEmail && comparison.sections.personalEmail.hasDifferences) ||\n (config.syncFields?.personalPhone && comparison.sections.personalPhone.hasDifferences) ||\n (config.syncFields?.residentialAddress &&\n comparison.sections.residentialAddress.hasDifferences) ||\n (config.syncFields?.taxDetails && comparison.sections.taxDetails.hasDifferences))\n ) {\n // Differences found between the Worknice person and the remote\n // person. Update either the Worknice person or the remote\n // person with details from the other.\n\n const worknicePersonUpdatedAt =\n mode === \"remote-to-worknice\"\n ? Temporal.Instant.fromEpochMilliseconds(-8640000000000000)\n : Temporal.Instant.from(worknicePerson.updatedAt);\n\n if (!isValidInstant(remotePerson.metadata.updatedAt)) {\n throw Error(\n `Invalid updatedAt value for ${config.appName} person \"${remotePersonName}\". Must be in ISO 8601 format, including a date, a time, and a time zone offset.`,\n {\n cause: Error(`Unable to parse: ${remotePerson.metadata.updatedAt}`),\n },\n );\n }\n\n const remotePersonUpdatedAt =\n mode === \"worknice-to-remote\"\n ? Temporal.Instant.fromEpochMilliseconds(-8640000000000000)\n : Temporal.Instant.from(remotePerson.metadata.updatedAt);\n\n if (isInstantAfter(worknicePersonUpdatedAt, remotePersonUpdatedAt)) {\n // The Worknice person was updated more recently than the remote\n // person. Update the remote person using details from Worknice.\n\n if (!updateRemotePerson) {\n throw Error(\n \"No updateRemotePerson function supplied to handleTriggerIntegrationSyncWebhook.\",\n );\n }\n\n try {\n await updateRemotePerson(worknicePersonDataTransferLine, {\n ...contextWithIntegration,\n connection: personConnection,\n });\n logger.info(`Updated ${config.appName} person \"${remotePersonName}\".`);\n } catch (error) {\n logger.indent(\n `Unable to update ${config.appName} person \"${remotePersonName}\" because of the following error:`,\n );\n logger.error(error);\n logger.dedent();\n }\n } else {\n // The remote person was updated more recently than the\n // Worknice person. Update the Worknice person using details\n // from the remote.\n\n try {\n const bankAccounts = validatePersonDataTransferLineBankAccounts(\n remotePersonDataTransferLine.bankAccounts,\n );\n const dateOfBirth = validatePersonDataTransferLineDateOfBirth(\n remotePersonDataTransferLine.dateOfBirth,\n );\n // emergencyContacts\n const fullName = validatePersonDataTransferLineFullName(\n remotePersonDataTransferLine.fullName,\n );\n const gender = validatePersonDataTransferLineGender(\n remotePersonDataTransferLine.gender,\n );\n const personalEmail = validatePersonDataTransferLinePersonalEmail(\n remotePersonDataTransferLine.personalEmail,\n );\n const personalPhone = validatePersonDataTransferLinePersonalPhone(\n remotePersonDataTransferLine.personalPhone,\n );\n // postalAddress\n // profile\n // remuneration\n const residentialAddress = validatePersonDataTransferLineResidentialAddress(\n remotePersonDataTransferLine.residentialAddress,\n );\n // // TODO: Enable syncing super funds. See PROD-2216.\n // const superFunds = validatePersonDataTransferLineSuperFunds(remotePersonDataTransferLine.superFunds);\n const taxDetails = validatePersonDataTransferLineTaxDetails(\n remotePersonDataTransferLine.taxDetails,\n );\n // // TODO: Enable syncing tenure. See PROD-1371.\n // const tenure = validatePersonDataTransferLineTenure(remotePersonDataTransferLine.tenure);\n\n const dataImport = await getDataImport();\n\n await worknice.createPersonDataImportLine({\n bankAccounts,\n config: {\n bankAccounts: config.syncFields?.bankAccounts ?? false,\n dateOfBirth: config.syncFields?.dateOfBirth ?? false,\n emergencyContacts: config.syncFields?.emergencyContacts ?? false,\n fullName: config.syncFields?.fullName ?? false,\n gender: config.syncFields?.gender ?? false,\n personalEmail: config.syncFields?.personalEmail ?? false,\n personalPhone: config.syncFields?.personalPhone ?? false,\n postalAddress: config.syncFields?.postalAddress ?? false,\n profile: config.syncFields?.profile ?? false,\n remuneration: config.syncFields?.remuneration ?? false,\n residentialAddress: config.syncFields?.residentialAddress ?? false,\n superFunds: config.syncFields?.superFunds ?? false,\n taxDetails: config.syncFields?.taxDetails ?? false,\n tenure: config.syncFields?.tenure ?? false,\n },\n dataImportId: dataImport.id,\n dateOfBirth,\n emergencyContacts: null,\n fullName,\n gender,\n personalEmail,\n personalPhone,\n personId: worknicePerson.id,\n postalAddress: null,\n residentialAddress,\n // TODO: Enable syncing super funds. See PROD-2216.\n superFunds: null,\n taxDetails,\n // TODO: Enable syncing tenure. See PROD-1371.\n tenure: null,\n });\n\n logger.info(`Updated Worknice person \"${worknicePerson.displayName}\".`);\n } catch (error) {\n logger.indent(\n `Unable to update Worknice person \"${worknicePerson.displayName}\" because of the following error:`,\n );\n logger.error(error);\n logger.dedent();\n }\n }\n }\n }\n\n logger.dedent(\"Finished updating people with connections marked as merged.\");\n }\n\n logger.indent(\"Merging unmerged connections…\");\n\n const connectedConnections = personConnections.filter(\n (\n personConnection,\n ): personConnection is typeof personConnection & {\n status: ConnectionStatus.Connected;\n } => personConnection.status === ConnectionStatus.Connected,\n );\n\n for (const personConnection of connectedConnections) {\n let worknicePerson = people.find((person) => person.id === personConnection.person.id);\n\n const remotePerson = remotePeople.find(\n (person) => person.metadata.sourceId === personConnection.remote.id,\n );\n\n try {\n if (!worknicePerson) {\n throw Error(\n `Unable to find person in Worknice with the ID \"${personConnection.person.id}\".`,\n );\n }\n if (!remotePerson) {\n throw Error(\n `Unable to find person in ${config.appName} with the ID \"${personConnection.remote.id}\".`,\n );\n }\n } catch (error) {\n logger.indent(\n `Unable to merge Worknice person \"${personConnection.person.displayName}\" with ${config.appName} person \"${personConnection.remote.name}\" because of the following error:`,\n );\n logger.error(error);\n logger.dedent();\n continue;\n }\n\n const remotePersonName = personToName(remotePerson);\n\n logger.indent(\n `Merging Worknice person \"${worknicePerson.displayName}\" with ${config.appName} person \"${remotePersonName}\"…`,\n );\n\n try {\n if (mode !== \"connection-only\") {\n const worknicePersonUpdatedAt =\n mode === \"remote-to-worknice\"\n ? Temporal.Instant.fromEpochMilliseconds(-8640000000000000)\n : Temporal.Instant.from(worknicePerson.updatedAt);\n\n if (!isValidInstant(remotePerson.metadata.updatedAt)) {\n throw Error(\n `Invalid updatedAt value for ${config.appName} person \"${remotePersonName}\". Must be in ISO 8601 format, including a date, a time, and a time zone offset.`,\n {\n cause: Error(`Unable to parse: ${remotePerson.metadata.updatedAt}`),\n },\n );\n }\n\n const remotePersonUpdatedAt =\n mode === \"worknice-to-remote\"\n ? Temporal.Instant.fromEpochMilliseconds(-8640000000000000)\n : Temporal.Instant.from(remotePerson.metadata.updatedAt);\n\n const [primaryDataTransferLine, secondaryDataTransferLine] = isInstantAfter(\n worknicePersonUpdatedAt,\n remotePersonUpdatedAt,\n )\n ? [worknicePersonToPersonDataTransferLine(worknicePerson), remotePerson]\n : [remotePerson, worknicePersonToPersonDataTransferLine(worknicePerson)];\n const mergedDataTransferLine = mergePersonDataTransferLines(\n primaryDataTransferLine,\n secondaryDataTransferLine,\n );\n\n const bankAccounts = validatePersonDataTransferLineBankAccounts(\n mergedDataTransferLine.bankAccounts,\n );\n const dateOfBirth = validatePersonDataTransferLineDateOfBirth(\n mergedDataTransferLine.dateOfBirth,\n );\n // emergencyContacts\n const fullName = validatePersonDataTransferLineFullName(mergedDataTransferLine.fullName);\n const gender = validatePersonDataTransferLineGender(mergedDataTransferLine.gender);\n const personalEmail = validatePersonDataTransferLinePersonalEmail(\n mergedDataTransferLine.personalEmail,\n );\n const personalPhone = validatePersonDataTransferLinePersonalPhone(\n mergedDataTransferLine.personalPhone,\n );\n // postalAddress\n const profile = validatePersonDataTransferLineProfile(mergedDataTransferLine.profile);\n // remuneration\n const residentialAddress = validatePersonDataTransferLineResidentialAddress(\n mergedDataTransferLine.residentialAddress,\n );\n // // TODO: Enable syncing super funds. See PROD-2216.\n // const superFunds = validatePersonDataTransferLineSuperFunds(mergedDataTransferLine.superFunds);\n const taxDetails = validatePersonDataTransferLineTaxDetails(\n mergedDataTransferLine.taxDetails,\n );\n // // TODO: Enable syncing tenure. See PROD-1371.\n // const tenure = validatePersonDataTransferLineTenure(mergedDataTransferLine.tenure);\n\n if (mode !== \"worknice-to-remote\") {\n const dataImport = await getDataImport();\n\n await worknice.createPersonDataImportLine({\n bankAccounts,\n config: {\n bankAccounts: config.syncFields?.bankAccounts ?? false,\n dateOfBirth: config.syncFields?.dateOfBirth ?? false,\n emergencyContacts: config.syncFields?.emergencyContacts ?? false,\n fullName: config.syncFields?.fullName ?? false,\n gender: config.syncFields?.gender ?? false,\n personalEmail: config.syncFields?.personalEmail ?? false,\n personalPhone: config.syncFields?.personalPhone ?? false,\n postalAddress: config.syncFields?.postalAddress ?? false,\n profile: config.syncFields?.profile ?? false,\n remuneration: config.syncFields?.remuneration ?? false,\n residentialAddress: config.syncFields?.residentialAddress ?? false,\n superFunds: config.syncFields?.superFunds ?? false,\n taxDetails: config.syncFields?.taxDetails ?? false,\n tenure: config.syncFields?.tenure ?? false,\n },\n dataImportId: dataImport.id,\n dateOfBirth,\n emergencyContacts: null,\n fullName,\n gender,\n personalEmail,\n personalPhone,\n personId: worknicePerson.id,\n postalAddress: null,\n residentialAddress,\n // TODO: Enable syncing super funds. See PROD-2216.\n superFunds: null,\n taxDetails,\n // TODO: Enable syncing tenure. See PROD-1371.\n tenure: null,\n });\n\n worknicePerson = await worknice.updatePerson({\n displayName: profile?.displayName,\n employeeCode: remotePerson.metadata.employeeCode,\n personId: worknicePerson.id,\n profileEmail: profile?.profileEmail,\n profilePhone: profile?.profilePhone,\n });\n\n logger.info(`Updated Worknice person \"${worknicePerson.displayName}\".`);\n }\n\n if (mode !== \"remote-to-worknice\") {\n if (!updateRemotePerson) {\n throw Error(\n \"No updateRemotePerson function supplied to handleTriggerIntegrationSyncWebhook.\",\n );\n }\n\n await updateRemotePerson(\n {\n bankAccounts,\n dateOfBirth,\n emergencyContacts: null,\n fullName,\n gender,\n metadata: {\n deleted: false,\n employeeCode: worknicePerson.employeeCode ?? null,\n sourceId: worknicePerson.id,\n targetId: remotePerson.metadata.sourceId,\n updatedAt: worknicePerson.updatedAt,\n },\n personalEmail,\n personalPhone,\n postalAddress: null,\n profile: {\n displayName: worknicePerson.displayName,\n profileEmail: worknicePerson.profileEmail ?? null,\n profilePhone: worknicePerson.profilePhone ?? null,\n },\n residentialAddress,\n // TODO: Enable syncing super funds. See PROD-2216.\n superFunds: null,\n taxDetails,\n // TODO: Enable syncing tenure. See PROD-1371.\n tenure: null,\n },\n {\n ...contextWithIntegration,\n connection: personConnection,\n },\n );\n\n logger.info(`Updated ${config.appName} person \"${remotePersonName}\".`);\n }\n }\n\n await worknice.updatePersonConnection({\n personConnectionId: personConnection.id,\n personId: personConnection.person.id,\n remote: {\n id: remotePerson.metadata.sourceId,\n name: remotePersonName,\n },\n status: ConnectionStatus.Merged,\n });\n\n logger.dedent(`Finished merging.`);\n } catch (error) {\n logger.indent(\n `Unable to merge ${config.appName} person \"${remotePersonName}\" and Worknice person \"${worknicePerson.displayName}\" because of the following error:`,\n );\n logger.error(error);\n logger.dedent();\n logger.dedent();\n }\n }\n\n logger.dedent(\"Finished merging unmerged connections.\");\n\n if (mode === \"two-way\" || mode === \"worknice-to-remote\") {\n logger.indent(`Adding new people to ${config.appName}…`);\n\n const localOnlyConnections = personConnections.filter(\n (\n personConnection,\n ): personConnection is typeof personConnection & {\n status: ConnectionStatus.LocalOnly;\n } => personConnection.status === ConnectionStatus.LocalOnly,\n );\n\n for (const personConnection of localOnlyConnections) {\n const worknicePerson = people.find((person) => person.id === personConnection.person.id);\n\n if (!worknicePerson) {\n throw Error(\n `Unable to find person in Worknice with the ID \"${personConnection.person.id}\".`,\n );\n }\n\n try {\n if (!createRemotePerson) {\n throw Error(\n \"No createRemotePerson function supplied to handleTriggerIntegrationSyncWebhook.\",\n );\n }\n\n const { status, ...remote } = await createRemotePerson(\n {\n ...worknicePersonToPersonDataTransferLine(worknicePerson),\n metadata: {\n deleted: false,\n employeeCode: worknicePerson.employeeCode ?? null,\n sourceId: worknicePerson.id,\n targetId: null,\n updatedAt: worknicePerson.updatedAt,\n },\n },\n {\n ...contextWithIntegration,\n connection: personConnection,\n },\n );\n\n if (personConnections.some((connection) => connection.remote?.id === remote.id)) {\n throw Error(\n `A connection already exists for the ${config.appName} person \"${remote.name}\".`,\n );\n }\n\n await worknice.updatePersonConnection({\n personConnectionId: personConnection.id,\n personId: personConnection.person.id,\n remote,\n status: status ?? ConnectionStatus.Merged,\n });\n\n logger.info(`Added new person \"${remote.name}\" to ${config.appName}.`);\n } catch (error) {\n logger.indent(\n `Unable to add Worknice person \"${worknicePerson.displayName}\" to ${config.appName} because of the following error:`,\n );\n logger.error(error);\n logger.dedent();\n }\n }\n\n logger.dedent(`Finished adding new people to ${config.appName}.`);\n }\n\n return {\n remotePeople,\n };\n};\n\nconst personToName = (person: Person) => {\n if (\n (person.fullName?.givenName ?? \"\").trim() !== \"\" &&\n (person.fullName?.familyName ?? \"\").trim() !== \"\"\n ) {\n return `${person.fullName?.givenName} ${person.fullName?.familyName}`;\n }\n\n if ((person.profile?.displayName ?? \"\").trim() !== \"\") {\n return `${person.profile?.displayName}`;\n }\n\n return `(unnamed person ${person.metadata.sourceId})`;\n};\n\nconst worknicePersonToPersonDataTransferLine = (\n worknicePerson: NonNullable<GetPeopleQuery[\"org\"][\"people\"][number]>,\n): Omit<Person, \"metadata\"> => ({\n ...validatePersonDataTransferLine({\n bankAccounts: worknicePerson.bankAccount1AllocationMethod\n ? {\n bankAccount1Allocation: worknicePerson.bankAccount1Allocation ?? null,\n bankAccount1AllocationMethod: worknicePerson.bankAccount1AllocationMethod,\n bankAccount1Bsb: worknicePerson.bankAccount1Bsb ?? null,\n bankAccount1Name: worknicePerson.bankAccount1Name ?? null,\n bankAccount1Number: worknicePerson.bankAccount1Number ?? null,\n bankAccount2Allocation: worknicePerson.bankAccount2Allocation ?? null,\n bankAccount2AllocationMethod: worknicePerson.bankAccount2AllocationMethod ?? null,\n bankAccount2Bsb: worknicePerson.bankAccount2Bsb ?? null,\n bankAccount2Name: worknicePerson.bankAccount2Name ?? null,\n bankAccount2Number: worknicePerson.bankAccount2Number ?? null,\n bankAccount3Allocation: worknicePerson.bankAccount3Allocation ?? null,\n bankAccount3AllocationMethod: worknicePerson.bankAccount3AllocationMethod ?? null,\n bankAccount3Bsb: worknicePerson.bankAccount3Bsb ?? null,\n bankAccount3Name: worknicePerson.bankAccount3Name ?? null,\n bankAccount3Number: worknicePerson.bankAccount3Number ?? null,\n bankAccount4Allocation: worknicePerson.bankAccount4Allocation ?? null,\n bankAccount4AllocationMethod: worknicePerson.bankAccount4AllocationMethod ?? null,\n bankAccount4Bsb: worknicePerson.bankAccount4Bsb ?? null,\n bankAccount4Name: worknicePerson.bankAccount4Name ?? null,\n bankAccount4Number: worknicePerson.bankAccount4Number ?? null,\n bankAccount5Allocation: worknicePerson.bankAccount5Allocation ?? null,\n bankAccount5AllocationMethod: worknicePerson.bankAccount5AllocationMethod ?? null,\n bankAccount5Bsb: worknicePerson.bankAccount5Bsb ?? null,\n bankAccount5Name: worknicePerson.bankAccount5Name ?? null,\n bankAccount5Number: worknicePerson.bankAccount5Number ?? null,\n }\n : null,\n dateOfBirth: worknicePerson.dateOfBirth ? { dateOfBirth: worknicePerson.dateOfBirth } : null,\n emergencyContacts: null,\n fullName: worknicePerson.givenName\n ? {\n familyName: worknicePerson.familyName ?? null,\n givenName: worknicePerson.givenName,\n otherGivenNames: worknicePerson.otherGivenNames ?? null,\n }\n : null,\n gender: worknicePerson.gender\n ? {\n gender: worknicePerson.gender,\n }\n : null,\n personalEmail: worknicePerson.personalEmail\n ? {\n personalEmail: worknicePerson.personalEmail,\n }\n : null,\n personalPhone: worknicePerson.personalPhone\n ? {\n personalPhone: worknicePerson.personalPhone,\n }\n : null,\n postalAddress: null,\n profile: null,\n residentialAddress: worknicePerson.residentialAddressLine1\n ? {\n residentialAddressCity: worknicePerson.residentialAddressCity ?? null,\n // FIXME: This should not default to \"Australia\". See PROD-1085.\n residentialAddressCountry: worknicePerson.residentialAddressCountry ?? \"Australia\",\n residentialAddressLine1: worknicePerson.residentialAddressLine1,\n residentialAddressLine2: worknicePerson.residentialAddressLine2 ?? null,\n residentialAddressPostcode: worknicePerson.residentialAddressPostcode ?? null,\n residentialAddressState: worknicePerson.residentialAddressState ?? null,\n }\n : null,\n // TODO: Enable syncing super funds. See PROD-2216.\n superFunds: null,\n taxDetails: worknicePerson.taxFileNumberExemption\n ? {\n hasLoanOrStudentDebt: worknicePerson.hasLoanOrStudentDebt ?? null,\n residencyStatus: worknicePerson.residencyStatus ?? null,\n taxFileNumber: worknicePerson.taxFileNumber ?? null,\n taxFileNumberExemption: worknicePerson.taxFileNumberExemption ?? null,\n taxFreeThresholdClaimed: worknicePerson.taxFreeThresholdClaimed ?? null,\n }\n : null,\n // TODO: Enable syncing tenure. See PROD-1371.\n tenure: null,\n }),\n profile: {\n displayName: worknicePerson.displayName,\n profileEmail: worknicePerson.profileEmail ?? null,\n profilePhone: worknicePerson.profilePhone ?? null,\n },\n});\n\nconst handleLeaveRequestsSync = async <Env, Req extends Request>(\n { getConfig, getRemoteLeaveRequests }: Tasks<Env, Req>,\n context: Context<Env, Req> & { remotePeople: Array<Person> },\n) => {\n const { logger, payload, worknice } = context;\n\n if (!getRemoteLeaveRequests) {\n throw Error(\"getRemoteLeaveRequests is not defined\");\n }\n\n logger.indent(\"Retrieving Worknice data…\");\n\n const integration = await worknice.getIntegration({\n integrationId: payload.integration.id,\n });\n\n logger.info(\"Retrieved integration from Worknice.\");\n\n const personConnections = await worknice.getPersonConnections({\n integrationId: payload.integration.id,\n });\n\n logger.info(`Retrieved ${personConnections.length} person connection(s) from Worknice.`);\n\n const workniceLeaveRequests = await worknice.getLeaveRequests({ integrationId: integration.id });\n\n logger.info(`Retrieved ${workniceLeaveRequests.length} leave request(s) from Worknice.`);\n\n logger.dedent(\"Completed retrieving Worknice data.\");\n\n const contextWithIntegration = {\n ...context,\n integration,\n };\n\n logger.indent(\"Loading configuration details…\");\n\n const config = await getConfig(contextWithIntegration);\n\n logger.dedent(\"Finished loading configuration details.\");\n\n logger.indent(`Retrieving ${config.appName} data…`);\n\n let remoteLeaveRequests: Array<LeaveRequest>;\n\n try {\n remoteLeaveRequests = await getRemoteLeaveRequests(contextWithIntegration);\n } catch (error) {\n logger.info(`An error occurred while retrieving data from ${config.appName}.`);\n throw error;\n }\n\n logger.info(`Retrieved ${remoteLeaveRequests.length} leave request(s) from ${config.appName}.`);\n\n logger.dedent(`Completed retrieving ${config.appName} data.`);\n\n logger.indent(\"Updating leave requests…\");\n\n for (const remoteLeaveRequest of remoteLeaveRequests) {\n const workniceLeaveRequest = workniceLeaveRequests.find(\n (leaveRequest) => leaveRequest.remoteId === remoteLeaveRequest.remoteId,\n );\n\n const personConnection:\n | ((typeof personConnections)[number] & {\n remote: NonNullable<(typeof personConnections)[number][\"remote\"]>;\n })\n | undefined = personConnections\n .filter((x) => x.remote !== null)\n .find((connection) => connection.remote.id === remoteLeaveRequest.personRemoteId);\n\n if (personConnection === undefined) {\n logger.info(\n `No person connection found for ${config.appName} person with remote ID \"${remoteLeaveRequest.personRemoteId}\".`,\n );\n continue;\n }\n\n if (workniceLeaveRequest) {\n await worknice.updateLeaveRequest({\n endDate: remoteLeaveRequest.endDate,\n endTime: remoteLeaveRequest.endTime,\n id: workniceLeaveRequest.id,\n leaveCategory: {\n id: remoteLeaveRequest.leaveCategory.id,\n name: remoteLeaveRequest.leaveCategory.name,\n },\n notes: remoteLeaveRequest.notes,\n personConnectionId: workniceLeaveRequest.personConnection.id,\n remoteId: remoteLeaveRequest.remoteId,\n responsibleId: workniceLeaveRequest.responsible?.id,\n startDate: remoteLeaveRequest.startDate,\n startTime: remoteLeaveRequest.startTime,\n status: remoteLeaveRequest.status,\n });\n\n logger.info(\n `Updated leave request \"${workniceLeaveRequest.leaveCategory.name} ${workniceLeaveRequest.startDate}–${workniceLeaveRequest.endDate}\" for ${config.appName} person \"${personConnection.remote.name}\".`,\n );\n } else {\n await worknice.createLeaveRequest({\n endDate: remoteLeaveRequest.endDate,\n endTime: remoteLeaveRequest.endTime,\n leaveCategory: {\n id: remoteLeaveRequest.leaveCategory.id,\n name: remoteLeaveRequest.leaveCategory.name,\n },\n notes: remoteLeaveRequest.notes,\n personConnectionId: personConnection.id,\n remoteId: remoteLeaveRequest.remoteId,\n startDate: remoteLeaveRequest.startDate,\n startTime: remoteLeaveRequest.startTime,\n status: remoteLeaveRequest.status,\n });\n\n logger.info(\n `Created leave request \"${remoteLeaveRequest.leaveCategory.name} ${remoteLeaveRequest.startDate}–${remoteLeaveRequest.endDate}\" for ${config.appName} person \"${personConnection.remote.name}\".`,\n );\n }\n }\n\n logger.dedent(\"Finished updating leave requests.\");\n};\n\nexport default handleTriggerIntegrationSyncWebhook;\n"],"mappings":"AAAA,SAAS,gBAAgB;AAEzB,OAAO,oBAAoB;AAC3B,OAAO,oBAAoB;AAG3B;AAAA,EACE;AAAA,EAGA;AAAA,EACA;AAAA,OAEK;AAEP,OAAO,oCAAoC;AAC3C,OAAO,kCAAkC;AACzC,OAAO,oCAAoC;AAC3C,OAAO,gDAAgD;AACvD,OAAO,+CAA+C;AACtD,OAAO,4CAA4C;AACnD,OAAO,0CAA0C;AACjD,OAAO,iDAAiD;AACxD,OAAO,iDAAiD;AACxD,OAAO,2CAA2C;AAClD,OAAO,sDAAsD;AAC7D,OAAO,8CAA8C;AAErD,OAAO,+BAA+B;AAoHtC,MAAM,sCAAsC,OAC1C,SACA,OACA,YAEA;AAAA,EACE;AAAA,EACA;AAAA,IACE,aAAa,MAAM;AAAA,IACnB,eAAe,OAAO,YAAY;AAChC,YAAM,EAAE,QAAQ,SAAS,SAAS,IAAI;AACtC,UAAI;AACF,eAAO,QAAQ,UAAU,QAAQ,YAAY,EAAE;AAE/C,cAAM,cAAc,MAAM,SAAS,eAAe;AAAA,UAChD,eAAe,QAAQ,YAAY;AAAA,QACrC,CAAC;AAED,YAAI,YAAY,UAAU;AACxB,iBAAO,KAAK,yCAAyC;AACrD;AAAA,QACF;AAEA,YAAI,YAAY,WAAW,WAAW;AACpC,iBAAO,KAAK,0BAA0B,YAAY,MAAM,mBAAmB;AAC3E,cAAI,MAAM,UAAW,OAAM,MAAM,UAAU,OAAO;AAClD;A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C,MAAM,mBAAmB,cAAc;AAAA,QACzC;AAAA,QACA,OAAO,mBAAmB;AAAA,QAC1B,oBAAoB,qBAAqB,iBAAiB;AAAA,QAC1D,UAAU,mBAAmB;AAAA,QAC7B,eAAe,qBAAqB,aAAa;AAAA,QACjD,WAAW,mBAAmB;AAAA,QAC9B,WAAW,mBAAmB;AAAA,QAC9B,QAAQ,mBAAmB;AAAA,MAC7B,CAAC;AAED,aAAO;AAAA,QACL,0BAA0B,qBAAqB,cAAc,IAAI,IAAI,qBAAqB,SAAS,SAAI,qBAAqB,OAAO,SAAS,OAAO,OAAO,YAAY,iBAAiB,OAAO,IAAI;AAAA,MACpM;AAAA,IACF,OAAO;AACL,YAAM,SAAS,mBAAmB;AAAA,QAChC,SAAS,mBAAmB;AAAA,QAC5B,SAAS,mBAAmB;AAAA,QAC5B,eAAe;AAAA,UACb,IAAI,mBAAmB,cAAc;AAAA,UACrC,MAAM,mBAAmB,cAAc;AAAA,QACzC;AAAA,QACA,OAAO,mBAAmB;AAAA,QAC1B,oBAAoB,iBAAiB;AAAA,QACrC,UAAU,mBAAmB;AAAA,QAC7B,WAAW,mBAAmB;AAAA,QAC9B,WAAW,mBAAmB;AAAA,QAC9B,QAAQ,mBAAmB;AAAA,MAC7B,CAAC;AAED,aAAO;AAAA,QACL,0BAA0B,mBAAmB,cAAc,IAAI,IAAI,mBAAmB,SAAS,SAAI,mBAAmB,OAAO,SAAS,OAAO,OAAO,YAAY,iBAAiB,OAAO,IAAI;AAAA,MAC9L;AAAA,IACF;AAAA,EACF;AAEA,SAAO,OAAO,mCAAmC;AACnD;AAEA,IAAO,8CAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@worknice/js-sdk",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.13",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
7
7
|
"files": [
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"dedent": "^0.7.0",
|
|
38
38
|
"uuid": "^11.0.5",
|
|
39
|
-
"@worknice/utils": "^0.6.
|
|
39
|
+
"@worknice/utils": "^0.6.23"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@anolilab/semantic-release-pnpm": "^1.1.10",
|