@worknice/js-sdk 0.0.3 → 0.0.4

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.
@@ -17,6 +17,7 @@ type Person = PartialPersonDataTransferLine & {
17
17
  updatedAt: string;
18
18
  };
19
19
  profile: {
20
+ displayName: string;
20
21
  profileEmail: string | null;
21
22
  } | null;
22
23
  };
@@ -60,7 +60,7 @@ const handleTriggerIntegrationSyncWebhook = async (request, {
60
60
  logger.dedent(`Completed retrieving ${config.appName} data.`);
61
61
  logger.indent("Updating person connections\u2026");
62
62
  for (const remotePerson of remotePeople) {
63
- const remotePersonName = `${remotePerson.personalDetails?.givenName} ${remotePerson.personalDetails?.familyName}`;
63
+ const remotePersonName = personToName(remotePerson);
64
64
  try {
65
65
  const remotePersonConnection = personConnections.find(
66
66
  (connection) => connection.remote?.id === remotePerson.metadata.sourceId
@@ -71,7 +71,7 @@ const handleTriggerIntegrationSyncWebhook = async (request, {
71
71
  personConnectionId: remotePersonConnection.id
72
72
  });
73
73
  logger.info(
74
- `Deleted connection for "${remotePerson.personalDetails?.givenName} ${remotePerson.personalDetails?.familyName}" in ${config.appName} because they have been terminated.`
74
+ `Deleted connection for "${remotePersonName}" in ${config.appName} because they have been terminated.`
75
75
  );
76
76
  }
77
77
  } else {
@@ -255,7 +255,7 @@ ${error instanceof Error ? error.message : error}
255
255
  `Unable to find person in ${config.appName} with the ID "${personConnection.remote.id}".`
256
256
  );
257
257
  }
258
- const remotePersonName = `${remotePerson.personalDetails?.givenName} ${remotePerson.personalDetails?.familyName}`;
258
+ const remotePersonName = personToName(remotePerson);
259
259
  const worknicePersonDataTransferLine = {
260
260
  ...worknicePersonToPersonDataTransferLine(worknicePerson),
261
261
  metadata: {
@@ -266,6 +266,7 @@ ${error instanceof Error ? error.message : error}
266
266
  updatedAt: worknicePerson.updatedAt
267
267
  },
268
268
  profile: {
269
+ displayName: worknicePerson.displayName,
269
270
  profileEmail: worknicePerson.profileEmail ?? null
270
271
  }
271
272
  };
@@ -373,7 +374,7 @@ ${error instanceof Error ? error.message : error}
373
374
  `Unable to find person in ${config.appName} with the ID "${personConnection.remote.id}".`
374
375
  );
375
376
  }
376
- const remotePersonName = `${remotePerson.personalDetails?.givenName} ${remotePerson.personalDetails?.familyName}`;
377
+ const remotePersonName = personToName(remotePerson);
377
378
  logger.indent(
378
379
  `Merging Worknice person "${worknicePerson.displayName}" with ${config.appName} person "${remotePersonName}"\u2026`
379
380
  );
@@ -444,6 +445,7 @@ ${error instanceof Error ? error.message : error}
444
445
  updatedAt: worknicePerson.updatedAt
445
446
  },
446
447
  profile: {
448
+ displayName: worknicePerson.displayName,
447
449
  profileEmail: worknicePerson.profileEmail ?? null
448
450
  }
449
451
  },
@@ -503,6 +505,7 @@ ${error instanceof Error ? error.message : error}
503
505
  updatedAt: worknicePerson.updatedAt
504
506
  },
505
507
  profile: {
508
+ displayName: worknicePerson.displayName,
506
509
  profileEmail: worknicePerson.profileEmail ?? null
507
510
  }
508
511
  },
@@ -538,6 +541,15 @@ ${error instanceof Error ? error.message : error}
538
541
  },
539
542
  options
540
543
  );
544
+ const personToName = (person) => {
545
+ if ((person.personalDetails?.givenName ?? "").trim() !== "" && (person.personalDetails?.familyName ?? "").trim() !== "") {
546
+ return `${person.personalDetails?.givenName} ${person.personalDetails?.familyName}`;
547
+ }
548
+ if ((person.profile?.displayName ?? "").trim() !== "") {
549
+ return `${person.profile?.displayName}`;
550
+ }
551
+ return `(unnamed person ${person.metadata.sourceId})`;
552
+ };
541
553
  const worknicePersonToPersonDataTransferLine = (worknicePerson) => ({
542
554
  bankAccounts: worknicePerson.bankAccount1AllocationMethod ? {
543
555
  bankAccount1Allocation: worknicePerson.bankAccount1Allocation ?? null,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/helpers/handleTriggerIntegrationSyncWebhook.ts"],"sourcesContent":["import { Temporal } from \"temporal-polyfill\";\nimport { ConnectionStatus, type GetPeopleQuery, type WorkniceClient } from \"../api/_types.js\";\nimport type { PartialPersonDataTransferLine } from \"../employee-records/_types.js\";\nimport comparePersonDataTransferLines from \"../employee-records/comparePersonDataTransferLines.js\";\nimport mergePersonDataTransferLines from \"../employee-records/mergePersonDataTransferLines.js\";\nimport validatePersonDataTransferLineBankAccounts from \"../employee-records/validatePersonDataTransferLineBankAccounts.js\";\nimport validatePersonDataTransferLinePersonalDetails from \"../employee-records/validatePersonDataTransferLinePersonalDetails.js\";\nimport validatePersonDataTransferLineResidentialAddress from \"../employee-records/validatePersonDataTransferLineResidentialAddress.js\";\nimport isAfter from \"../utils/isAfter.js\";\nimport type { TriggerIntegrationSyncRequestPayload } from \"../webhooks.js\";\nimport type { HandlerOptions, TaskContext } from \"./_types.js\";\nimport handleRequestWithWorknice from \"./handleRequestWithWorknice.js\";\n\ntype Context<Env> = TaskContext<TriggerIntegrationSyncRequestPayload, Env> & {\n integration: Awaited<ReturnType<WorkniceClient[\"getIntegration\"]>>;\n};\n\ntype Person = PartialPersonDataTransferLine & {\n metadata: {\n deleted: boolean;\n employeeCode: string | null;\n sourceId: string;\n targetId: string | null;\n updatedAt: string;\n };\n profile: {\n profileEmail: string | null;\n } | null;\n};\n\ntype Tasks<Env> = {\n createRemotePerson?: (\n person: Person,\n context: Context<Env>,\n ) => Promise<{ id: string; name: string }>;\n getApiToken: (\n context: Pick<Context<Env>, \"env\" | \"logger\" | \"payload\" | \"request\">,\n ) => Promise<string>;\n getConfig: (context: Context<Env>) => Promise<Config>;\n getEnv: (context: Pick<Context<Env>, \"logger\" | \"payload\" | \"request\">) => Promise<Env>;\n getRemotePeople: (context: Context<Env>) => Promise<Array<Person>>;\n updateRemotePerson?: (person: Person, context: Context<Env>) => Promise<unknown>;\n};\n\ntype Config = {\n appName: string;\n automaticMatching?: boolean;\n mode?: \"connection-only\" | \"one-way\" | \"two-way\";\n syncFields?: {\n bankAccounts?: boolean;\n emergencyContacts?: boolean;\n personalDetails?: 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\n/**\n * The process for syncing 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 are unmatched and local-only. Mark the connections as merged.\n */\n\nconst handleTriggerIntegrationSyncWebhook = async <Env>(\n request: Request,\n {\n createRemotePerson,\n getApiToken,\n getConfig,\n getEnv,\n getRemotePeople,\n updateRemotePerson,\n }: Tasks<Env>,\n options?: HandlerOptions,\n) =>\n handleRequestWithWorknice<TriggerIntegrationSyncRequestPayload, undefined, Env>(\n request,\n {\n getApiToken,\n getEnv,\n handleRequest: async (context) => {\n const { logger, payload, worknice } = context;\n\n try {\n logger.connect(worknice, payload.integrationId);\n\n logger.indent(\"Retrieving Worknice data…\");\n\n const integration = await worknice.getIntegration({\n integrationId: payload.integrationId,\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 does not have a syncing status. Skipping sync.\");\n return;\n }\n\n logger.info(\"Retrieved integration from Worknice.\");\n\n const personConnections = await worknice.getPersonConnections({\n integrationId: payload.integrationId,\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 logger.info(\n config.automaticMatching\n ? \"Automatic matching enabled.\"\n : \"Automatic matching disabled.\",\n );\n logger.info(`Using a \"${config.mode}\" sync mode.`);\n\n logger.dedent(\"Finished loading configuration details.\");\n\n logger.indent(`Retrieving ${config.appName} data…`);\n\n const remotePeople = await getRemotePeople(contextWithIntegration);\n\n logger.info(`Retrieved ${remotePeople.length} people 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 = `${remotePerson.personalDetails?.givenName} ${remotePerson.personalDetails?.familyName}`;\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 \"${remotePerson.personalDetails?.givenName} ${remotePerson.personalDetails?.familyName}\" in ${config.appName} because they have been terminated.`,\n );\n }\n } else {\n // If there isn't a person connection for this remote person, one\n // should be created. If there is a person connection that is\n // remote-only, it should be automatically connected if there is a\n // person in Worknice with the same email address. If there is a\n // person connection and it's name doesn't match the remote\n // person's name, it should be updated.\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 (\n remotePersonConnection &&\n remotePersonConnection.remote?.name !== remotePersonName\n ) {\n // The employee's name has changed in MYOB and that needs to be\n // reflected in the person connection in 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.employeeCode !== null &&\n person.employeeCode === remotePerson.metadata.employeeCode) ||\n (person.personalEmail !== null &&\n person.personalEmail === remotePerson.personalDetails?.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 the same email address or\n // employee code as the remote person. The Worknice person should be\n // automatically connected to the 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 person \"${matchingWorknicePerson.displayName}\" in Worknice to person \"${remotePersonName}\" in ${config.appName} 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 person \"${matchingWorknicePerson.displayName}\" in Worknice and person \"${remotePersonName}\" in ${config.appName}.`,\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 person \"${matchingWorknicePerson.displayName}\" in Worknice to person \"${remotePersonName}\" in ${config.appName}.`,\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 person \"${remotePersonName}\" in ${config.appName} to person \"${matchingWorknicePerson.displayName}\" in Worknice.`,\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.integrationId,\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 person \"${remotePersonName}\" in ${config.appName} and automatically matched to person \"${matchingWorknicePerson.displayName}\" in Worknice.`,\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 const newPersonConnection = await worknice.createPersonConnection({\n integrationId: payload.integrationId,\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 person \"${remotePersonName}\" in ${config.appName}.`,\n );\n }\n }\n }\n } catch (error) {\n logger.info(\n `Unable to update person connection for person \"${remotePersonName}\" in ${config.appName} because of the following error:\\n\\n${error instanceof Error ? error.message : error}\\n`,\n );\n }\n }\n\n logger.dedent(\"Finished updating person connections.\");\n\n if (config.mode === \"one-way\" || config.mode === \"two-way\") {\n const dataImport = await worknice.createDataImport({\n integrationId: payload.integrationId,\n });\n\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(\n (person) => person.id === personConnection.person.id,\n );\n const remotePerson = remotePeople.find(\n (person) => person.metadata.sourceId === personConnection.remote.id,\n );\n\n if (!worknicePerson) {\n throw Error(\n `Unable to find person in Worknice with the ID \"${personConnection.person.id}\".`,\n );\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\n const remotePersonName = `${remotePerson.personalDetails?.givenName} ${remotePerson.personalDetails?.familyName}`;\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 profile: {\n profileEmail: worknicePerson.profileEmail ?? null,\n },\n };\n\n const myobPersonDataTransferLine = remotePerson;\n\n const comparison = comparePersonDataTransferLines(\n worknicePersonDataTransferLine,\n myobPersonDataTransferLine,\n );\n\n if (\n comparison.hasDifferences &&\n (comparison.sections.bankAccounts.hasDifferences ||\n comparison.sections.personalDetails.hasDifferences ||\n comparison.sections.residentialAddress.hasDifferences)\n ) {\n // Differences found between the Worknice person and the MYOB\n // employee. Update either the Worknice person or the MYOB employee\n // with details from the other.\n\n const worknicePersonUpdatedAt = Temporal.Instant.from(worknicePerson.updatedAt);\n const myobEmployeeUpdatedAt = Temporal.PlainDateTime.from(\n remotePerson.metadata.updatedAt,\n )\n .toZonedDateTime(Temporal.TimeZone.from(\"UTC\"))\n .toInstant();\n\n if (isAfter(worknicePersonUpdatedAt, myobEmployeeUpdatedAt)) {\n if (config.mode === \"two-way\") {\n // The Worknice person was updated more recently than the MYOB\n // employee. Update the MYOB employee 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(\n worknicePersonDataTransferLine,\n contextWithIntegration,\n );\n logger.info(`Updated person \"${remotePersonName}\" in ${config.appName}.`);\n } catch (error) {\n logger.info(\n `Unable to update person \"${remotePersonName}\" in ${config.appName} because of the following error:\\n\\n${error instanceof Error ? error.message : error}\\n`,\n );\n }\n }\n } else {\n // The MYOB employee was updated more recently than the Worknice\n // person. Update the Worknice person using details from MYOB.\n\n try {\n const personalDetails = validatePersonDataTransferLinePersonalDetails(\n myobPersonDataTransferLine.personalDetails,\n );\n const bankAccounts = validatePersonDataTransferLineBankAccounts(\n myobPersonDataTransferLine.bankAccounts,\n );\n const residentialAddress = validatePersonDataTransferLineResidentialAddress(\n myobPersonDataTransferLine.residentialAddress,\n );\n // // TODO: Enable syncing super funds. See PROD-2216.\n // const superFunds = validatePersonDataTransferLineSuperFunds(myobPersonDataTransferLine.superFunds);\n // // TODO: Enable syncing tax details. See PROD-2375.\n // const taxDetails = validatePersonDataTransferLineTaxDetails(myobPersonDataTransferLine.taxDetails);\n // // TODO: Enable syncing tenure. See PROD-1371.\n // const tenure = validatePersonDataTransferLineTenure(myobPersonDataTransferLine.tenure);\n\n await worknice.createPersonDataImportLine({\n bankAccounts,\n config: {\n bankAccounts: config.syncFields?.bankAccounts ?? false,\n emergencyContacts: config.syncFields?.emergencyContacts ?? false,\n personalDetails: config.syncFields?.personalDetails ?? false,\n postalAddress: config.syncFields?.personalDetails ?? 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 emergencyContacts: null,\n personalDetails,\n personId: worknicePerson.id,\n postalAddress: null,\n residentialAddress,\n // TODO: Enable syncing super funds. See PROD-2216.\n superFunds: null,\n // TODO: Enable syncing tax details. See PROD-2375.\n taxDetails: null,\n // TODO: Enable syncing tenure. See PROD-1371.\n tenure: null,\n });\n\n logger.info(`Updated person \"${worknicePerson.displayName}\" in Worknice.`);\n } catch (error) {\n logger.info(\n `Unable to update person \"${worknicePerson.displayName}\" in Worknice because of the following error:\\n\\n${error instanceof Error ? error.message : error}\\n`,\n );\n }\n }\n }\n }\n\n logger.dedent(\"Finished updating people with connections marked as merged.\");\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 const worknicePerson = people.find(\n (person) => person.id === personConnection.person.id,\n );\n const remotePerson = remotePeople.find(\n (person) => person.metadata.sourceId === personConnection.remote.id,\n );\n\n if (!worknicePerson) {\n throw Error(\n `Unable to find person in Worknice with the ID \"${personConnection.person.id}\".`,\n );\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\n const remotePersonName = `${remotePerson.personalDetails?.givenName} ${remotePerson.personalDetails?.familyName}`;\n\n logger.indent(\n `Merging Worknice person \"${worknicePerson.displayName}\" with ${config.appName} person \"${remotePersonName}\"…`,\n );\n\n try {\n const worknicePersonUpdatedAt = Temporal.Instant.from(worknicePerson.updatedAt);\n const myobEmployeeUpdatedAt = Temporal.PlainDateTime.from(\n remotePerson.metadata.updatedAt,\n )\n .toZonedDateTime(Temporal.TimeZone.from(\"UTC\"))\n .toInstant();\n const [primaryDataTransferLine, secondaryDataTransferLine] = isAfter(\n worknicePersonUpdatedAt,\n myobEmployeeUpdatedAt,\n )\n ? [worknicePersonToPersonDataTransferLine(worknicePerson), remotePerson]\n : [remotePerson, worknicePersonToPersonDataTransferLine(worknicePerson)];\n const mergedDataTransferLine = mergePersonDataTransferLines(\n primaryDataTransferLine,\n secondaryDataTransferLine,\n );\n\n const personalDetails = validatePersonDataTransferLinePersonalDetails(\n mergedDataTransferLine.personalDetails,\n );\n const bankAccounts = validatePersonDataTransferLineBankAccounts(\n mergedDataTransferLine.bankAccounts,\n );\n const residentialAddress = validatePersonDataTransferLineResidentialAddress(\n mergedDataTransferLine.residentialAddress,\n );\n // // TODO: Enable syncing super funds. See PROD-2216.\n // const superFunds = validatePersonDataTransferLineSuperFunds(mergedDataTransferLine.superFunds);\n // // TODO: Enable syncing tax details. See PROD-2375.\n // const taxDetails = validatePersonDataTransferLineTaxDetails(mergedDataTransferLine.taxDetails);\n // // TODO: Enable syncing tenure. See PROD-1371.\n // const tenure = validatePersonDataTransferLineTenure(mergedDataTransferLine.tenure);\n\n await worknice.createPersonDataImportLine({\n bankAccounts,\n config: {\n bankAccounts: config.syncFields?.bankAccounts ?? false,\n emergencyContacts: config.syncFields?.emergencyContacts ?? false,\n personalDetails: config.syncFields?.personalDetails ?? false,\n postalAddress: config.syncFields?.personalDetails ?? 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 emergencyContacts: null,\n personalDetails,\n personId: worknicePerson.id,\n postalAddress: null,\n residentialAddress,\n // TODO: Enable syncing super funds. See PROD-2216.\n superFunds: null,\n // TODO: Enable syncing tax details. See PROD-2375.\n taxDetails: null,\n // TODO: Enable syncing tenure. See PROD-1371.\n tenure: null,\n });\n\n logger.info(`Updated person \"${worknicePerson.displayName}\" in Worknice.`);\n\n if (config.mode === \"two-way\") {\n if (!updateRemotePerson) {\n throw Error(\n \"No updateRemotePerson function supplied to handleTriggerIntegrationSyncWebhook.\",\n );\n }\n\n await updateRemotePerson(\n {\n ...mergedDataTransferLine,\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 profile: {\n profileEmail: worknicePerson.profileEmail ?? null,\n },\n },\n contextWithIntegration,\n );\n\n logger.info(`Updated person \"${remotePersonName}\" in ${config.appName}.`);\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.info(\n `Unable to merge ${config.appName} person \"${remotePersonName}\" and Worknice person \"${worknicePerson.displayName}\" because of the following error:\\n\\n${error instanceof Error ? error.message : error}\\n`,\n );\n logger.dedent();\n }\n }\n\n logger.dedent(\"Finished merging unmerged connections.\");\n\n if (config.mode === \"two-way\") {\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(\n (person) => person.id === personConnection.person.id,\n );\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 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 profile: {\n profileEmail: worknicePerson.profileEmail ?? null,\n },\n },\n contextWithIntegration,\n );\n\n await worknice.updatePersonConnection({\n personConnectionId: personConnection.id,\n personId: personConnection.person.id,\n remote,\n status: ConnectionStatus.Merged,\n });\n\n logger.info(`Added new person \"${remote.name}\" to ${config.appName}.`);\n } catch (error) {\n logger.info(\n `Unable to add person \"${worknicePerson.displayName}\" in Worknice to ${config.appName} because of the following error:\\n\\n${error instanceof Error ? error.message : error}\\n`,\n );\n }\n }\n\n logger.dedent(`Finished adding new people to ${config.appName}.`);\n }\n }\n\n await worknice.completeSync({ integrationId: payload.integrationId });\n\n logger.info(\"Sync completed.\");\n } catch (error) {\n await worknice.completeSync({ integrationId: payload.integrationId });\n throw error;\n }\n },\n parsePayload: async ({ request }) => request.json(),\n },\n options,\n );\n\nconst worknicePersonToPersonDataTransferLine = (\n worknicePerson: NonNullable<GetPeopleQuery[\"org\"][\"people\"][number]>,\n): PartialPersonDataTransferLine => ({\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 emergencyContacts: null,\n personalDetails: worknicePerson.givenName\n ? {\n dateOfBirth: worknicePerson.dateOfBirth ?? null,\n familyName: worknicePerson.familyName ?? null,\n gender: worknicePerson.gender ?? null,\n givenName: worknicePerson.givenName ?? null,\n otherGivenNames: worknicePerson.otherGivenNames ?? null,\n personalEmail: worknicePerson.personalEmail ?? null,\n personalPhone: worknicePerson.personalPhone ?? null,\n }\n : null,\n postalAddress: 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 ?? null,\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 // TODO: Enable syncing tax details. See PROD-2375.\n taxDetails: null,\n // TODO: Enable syncing tenure. See PROD-1371.\n tenure: null,\n});\n\nexport default handleTriggerIntegrationSyncWebhook;\n"],"mappings":"AAAA,SAAS,gBAAgB;AACzB,SAAS,wBAAkE;AAE3E,OAAO,oCAAoC;AAC3C,OAAO,kCAAkC;AACzC,OAAO,gDAAgD;AACvD,OAAO,mDAAmD;AAC1D,OAAO,sDAAsD;AAC7D,OAAO,aAAa;AAGpB,OAAO,+BAA+B;AAuEtC,MAAM,sCAAsC,OAC1C,SACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GACA,YAEA;AAAA,EACE;AAAA,EACA;AAAA,IACE;AAAA,IACA;AAAA,IACA,eAAe,OAAO,YAAY;AAChC,YAAM,EAAE,QAAQ,SAAS,SAAS,IAAI;AAEtC,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AY;AAAA;AAAA,EAEZ,YAAY;AAAA;AAAA,EAEZ,QAAQ;AACV;AAEA,IAAO,8CAAQ;","names":["request"]}
1
+ {"version":3,"sources":["../../src/helpers/handleTriggerIntegrationSyncWebhook.ts"],"sourcesContent":["import { Temporal } from \"temporal-polyfill\";\nimport { ConnectionStatus, type GetPeopleQuery, type WorkniceClient } from \"../api/_types.js\";\nimport type { PartialPersonDataTransferLine } from \"../employee-records/_types.js\";\nimport comparePersonDataTransferLines from \"../employee-records/comparePersonDataTransferLines.js\";\nimport mergePersonDataTransferLines from \"../employee-records/mergePersonDataTransferLines.js\";\nimport validatePersonDataTransferLineBankAccounts from \"../employee-records/validatePersonDataTransferLineBankAccounts.js\";\nimport validatePersonDataTransferLinePersonalDetails from \"../employee-records/validatePersonDataTransferLinePersonalDetails.js\";\nimport validatePersonDataTransferLineResidentialAddress from \"../employee-records/validatePersonDataTransferLineResidentialAddress.js\";\nimport isAfter from \"../utils/isAfter.js\";\nimport type { TriggerIntegrationSyncRequestPayload } from \"../webhooks.js\";\nimport type { HandlerOptions, TaskContext } from \"./_types.js\";\nimport handleRequestWithWorknice from \"./handleRequestWithWorknice.js\";\n\ntype Context<Env> = TaskContext<TriggerIntegrationSyncRequestPayload, Env> & {\n integration: Awaited<ReturnType<WorkniceClient[\"getIntegration\"]>>;\n};\n\ntype Person = PartialPersonDataTransferLine & {\n metadata: {\n deleted: boolean;\n employeeCode: string | null;\n sourceId: string;\n targetId: string | null;\n updatedAt: string;\n };\n profile: {\n displayName: string;\n profileEmail: string | null;\n } | null;\n};\n\ntype Tasks<Env> = {\n createRemotePerson?: (\n person: Person,\n context: Context<Env>,\n ) => Promise<{ id: string; name: string }>;\n getApiToken: (\n context: Pick<Context<Env>, \"env\" | \"logger\" | \"payload\" | \"request\">,\n ) => Promise<string>;\n getConfig: (context: Context<Env>) => Promise<Config>;\n getEnv: (context: Pick<Context<Env>, \"logger\" | \"payload\" | \"request\">) => Promise<Env>;\n getRemotePeople: (context: Context<Env>) => Promise<Array<Person>>;\n updateRemotePerson?: (person: Person, context: Context<Env>) => Promise<unknown>;\n};\n\ntype Config = {\n appName: string;\n automaticMatching?: boolean;\n mode?: \"connection-only\" | \"one-way\" | \"two-way\";\n syncFields?: {\n bankAccounts?: boolean;\n emergencyContacts?: boolean;\n personalDetails?: 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\n/**\n * The process for syncing 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 are unmatched and local-only. Mark the connections as merged.\n */\n\nconst handleTriggerIntegrationSyncWebhook = async <Env>(\n request: Request,\n {\n createRemotePerson,\n getApiToken,\n getConfig,\n getEnv,\n getRemotePeople,\n updateRemotePerson,\n }: Tasks<Env>,\n options?: HandlerOptions,\n) =>\n handleRequestWithWorknice<TriggerIntegrationSyncRequestPayload, undefined, Env>(\n request,\n {\n getApiToken,\n getEnv,\n handleRequest: async (context) => {\n const { logger, payload, worknice } = context;\n\n try {\n logger.connect(worknice, payload.integrationId);\n\n logger.indent(\"Retrieving Worknice data…\");\n\n const integration = await worknice.getIntegration({\n integrationId: payload.integrationId,\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 does not have a syncing status. Skipping sync.\");\n return;\n }\n\n logger.info(\"Retrieved integration from Worknice.\");\n\n const personConnections = await worknice.getPersonConnections({\n integrationId: payload.integrationId,\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 logger.info(\n config.automaticMatching\n ? \"Automatic matching enabled.\"\n : \"Automatic matching disabled.\",\n );\n logger.info(`Using a \"${config.mode}\" sync mode.`);\n\n logger.dedent(\"Finished loading configuration details.\");\n\n logger.indent(`Retrieving ${config.appName} data…`);\n\n const remotePeople = await getRemotePeople(contextWithIntegration);\n\n logger.info(`Retrieved ${remotePeople.length} people 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 \"${remotePersonName}\" in ${config.appName} because they have been terminated.`,\n );\n }\n } else {\n // If there isn't a person connection for this remote person, one\n // should be created. If there is a person connection that is\n // remote-only, it should be automatically connected if there is a\n // person in Worknice with the same email address. If there is a\n // person connection and it's name doesn't match the remote\n // person's name, it should be updated.\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 (\n remotePersonConnection &&\n remotePersonConnection.remote?.name !== remotePersonName\n ) {\n // The employee's name has changed in MYOB and that needs to be\n // reflected in the person connection in 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.employeeCode !== null &&\n person.employeeCode === remotePerson.metadata.employeeCode) ||\n (person.personalEmail !== null &&\n person.personalEmail === remotePerson.personalDetails?.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 the same email address or\n // employee code as the remote person. The Worknice person should be\n // automatically connected to the 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 person \"${matchingWorknicePerson.displayName}\" in Worknice to person \"${remotePersonName}\" in ${config.appName} 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 person \"${matchingWorknicePerson.displayName}\" in Worknice and person \"${remotePersonName}\" in ${config.appName}.`,\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 person \"${matchingWorknicePerson.displayName}\" in Worknice to person \"${remotePersonName}\" in ${config.appName}.`,\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 person \"${remotePersonName}\" in ${config.appName} to person \"${matchingWorknicePerson.displayName}\" in Worknice.`,\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.integrationId,\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 person \"${remotePersonName}\" in ${config.appName} and automatically matched to person \"${matchingWorknicePerson.displayName}\" in Worknice.`,\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 const newPersonConnection = await worknice.createPersonConnection({\n integrationId: payload.integrationId,\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 person \"${remotePersonName}\" in ${config.appName}.`,\n );\n }\n }\n }\n } catch (error) {\n logger.info(\n `Unable to update person connection for person \"${remotePersonName}\" in ${config.appName} because of the following error:\\n\\n${error instanceof Error ? error.message : error}\\n`,\n );\n }\n }\n\n logger.dedent(\"Finished updating person connections.\");\n\n if (config.mode === \"one-way\" || config.mode === \"two-way\") {\n const dataImport = await worknice.createDataImport({\n integrationId: payload.integrationId,\n });\n\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(\n (person) => person.id === personConnection.person.id,\n );\n const remotePerson = remotePeople.find(\n (person) => person.metadata.sourceId === personConnection.remote.id,\n );\n\n if (!worknicePerson) {\n throw Error(\n `Unable to find person in Worknice with the ID \"${personConnection.person.id}\".`,\n );\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\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 profile: {\n displayName: worknicePerson.displayName,\n profileEmail: worknicePerson.profileEmail ?? null,\n },\n };\n\n const myobPersonDataTransferLine = remotePerson;\n\n const comparison = comparePersonDataTransferLines(\n worknicePersonDataTransferLine,\n myobPersonDataTransferLine,\n );\n\n if (\n comparison.hasDifferences &&\n (comparison.sections.bankAccounts.hasDifferences ||\n comparison.sections.personalDetails.hasDifferences ||\n comparison.sections.residentialAddress.hasDifferences)\n ) {\n // Differences found between the Worknice person and the MYOB\n // employee. Update either the Worknice person or the MYOB employee\n // with details from the other.\n\n const worknicePersonUpdatedAt = Temporal.Instant.from(worknicePerson.updatedAt);\n const myobEmployeeUpdatedAt = Temporal.PlainDateTime.from(\n remotePerson.metadata.updatedAt,\n )\n .toZonedDateTime(Temporal.TimeZone.from(\"UTC\"))\n .toInstant();\n\n if (isAfter(worknicePersonUpdatedAt, myobEmployeeUpdatedAt)) {\n if (config.mode === \"two-way\") {\n // The Worknice person was updated more recently than the MYOB\n // employee. Update the MYOB employee 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(\n worknicePersonDataTransferLine,\n contextWithIntegration,\n );\n logger.info(`Updated person \"${remotePersonName}\" in ${config.appName}.`);\n } catch (error) {\n logger.info(\n `Unable to update person \"${remotePersonName}\" in ${config.appName} because of the following error:\\n\\n${error instanceof Error ? error.message : error}\\n`,\n );\n }\n }\n } else {\n // The MYOB employee was updated more recently than the Worknice\n // person. Update the Worknice person using details from MYOB.\n\n try {\n const personalDetails = validatePersonDataTransferLinePersonalDetails(\n myobPersonDataTransferLine.personalDetails,\n );\n const bankAccounts = validatePersonDataTransferLineBankAccounts(\n myobPersonDataTransferLine.bankAccounts,\n );\n const residentialAddress = validatePersonDataTransferLineResidentialAddress(\n myobPersonDataTransferLine.residentialAddress,\n );\n // // TODO: Enable syncing super funds. See PROD-2216.\n // const superFunds = validatePersonDataTransferLineSuperFunds(myobPersonDataTransferLine.superFunds);\n // // TODO: Enable syncing tax details. See PROD-2375.\n // const taxDetails = validatePersonDataTransferLineTaxDetails(myobPersonDataTransferLine.taxDetails);\n // // TODO: Enable syncing tenure. See PROD-1371.\n // const tenure = validatePersonDataTransferLineTenure(myobPersonDataTransferLine.tenure);\n\n await worknice.createPersonDataImportLine({\n bankAccounts,\n config: {\n bankAccounts: config.syncFields?.bankAccounts ?? false,\n emergencyContacts: config.syncFields?.emergencyContacts ?? false,\n personalDetails: config.syncFields?.personalDetails ?? false,\n postalAddress: config.syncFields?.personalDetails ?? 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 emergencyContacts: null,\n personalDetails,\n personId: worknicePerson.id,\n postalAddress: null,\n residentialAddress,\n // TODO: Enable syncing super funds. See PROD-2216.\n superFunds: null,\n // TODO: Enable syncing tax details. See PROD-2375.\n taxDetails: null,\n // TODO: Enable syncing tenure. See PROD-1371.\n tenure: null,\n });\n\n logger.info(`Updated person \"${worknicePerson.displayName}\" in Worknice.`);\n } catch (error) {\n logger.info(\n `Unable to update person \"${worknicePerson.displayName}\" in Worknice because of the following error:\\n\\n${error instanceof Error ? error.message : error}\\n`,\n );\n }\n }\n }\n }\n\n logger.dedent(\"Finished updating people with connections marked as merged.\");\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 const worknicePerson = people.find(\n (person) => person.id === personConnection.person.id,\n );\n const remotePerson = remotePeople.find(\n (person) => person.metadata.sourceId === personConnection.remote.id,\n );\n\n if (!worknicePerson) {\n throw Error(\n `Unable to find person in Worknice with the ID \"${personConnection.person.id}\".`,\n );\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\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 const worknicePersonUpdatedAt = Temporal.Instant.from(worknicePerson.updatedAt);\n const myobEmployeeUpdatedAt = Temporal.PlainDateTime.from(\n remotePerson.metadata.updatedAt,\n )\n .toZonedDateTime(Temporal.TimeZone.from(\"UTC\"))\n .toInstant();\n const [primaryDataTransferLine, secondaryDataTransferLine] = isAfter(\n worknicePersonUpdatedAt,\n myobEmployeeUpdatedAt,\n )\n ? [worknicePersonToPersonDataTransferLine(worknicePerson), remotePerson]\n : [remotePerson, worknicePersonToPersonDataTransferLine(worknicePerson)];\n const mergedDataTransferLine = mergePersonDataTransferLines(\n primaryDataTransferLine,\n secondaryDataTransferLine,\n );\n\n const personalDetails = validatePersonDataTransferLinePersonalDetails(\n mergedDataTransferLine.personalDetails,\n );\n const bankAccounts = validatePersonDataTransferLineBankAccounts(\n mergedDataTransferLine.bankAccounts,\n );\n const residentialAddress = validatePersonDataTransferLineResidentialAddress(\n mergedDataTransferLine.residentialAddress,\n );\n // // TODO: Enable syncing super funds. See PROD-2216.\n // const superFunds = validatePersonDataTransferLineSuperFunds(mergedDataTransferLine.superFunds);\n // // TODO: Enable syncing tax details. See PROD-2375.\n // const taxDetails = validatePersonDataTransferLineTaxDetails(mergedDataTransferLine.taxDetails);\n // // TODO: Enable syncing tenure. See PROD-1371.\n // const tenure = validatePersonDataTransferLineTenure(mergedDataTransferLine.tenure);\n\n await worknice.createPersonDataImportLine({\n bankAccounts,\n config: {\n bankAccounts: config.syncFields?.bankAccounts ?? false,\n emergencyContacts: config.syncFields?.emergencyContacts ?? false,\n personalDetails: config.syncFields?.personalDetails ?? false,\n postalAddress: config.syncFields?.personalDetails ?? 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 emergencyContacts: null,\n personalDetails,\n personId: worknicePerson.id,\n postalAddress: null,\n residentialAddress,\n // TODO: Enable syncing super funds. See PROD-2216.\n superFunds: null,\n // TODO: Enable syncing tax details. See PROD-2375.\n taxDetails: null,\n // TODO: Enable syncing tenure. See PROD-1371.\n tenure: null,\n });\n\n logger.info(`Updated person \"${worknicePerson.displayName}\" in Worknice.`);\n\n if (config.mode === \"two-way\") {\n if (!updateRemotePerson) {\n throw Error(\n \"No updateRemotePerson function supplied to handleTriggerIntegrationSyncWebhook.\",\n );\n }\n\n await updateRemotePerson(\n {\n ...mergedDataTransferLine,\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 profile: {\n displayName: worknicePerson.displayName,\n profileEmail: worknicePerson.profileEmail ?? null,\n },\n },\n contextWithIntegration,\n );\n\n logger.info(`Updated person \"${remotePersonName}\" in ${config.appName}.`);\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.info(\n `Unable to merge ${config.appName} person \"${remotePersonName}\" and Worknice person \"${worknicePerson.displayName}\" because of the following error:\\n\\n${error instanceof Error ? error.message : error}\\n`,\n );\n logger.dedent();\n }\n }\n\n logger.dedent(\"Finished merging unmerged connections.\");\n\n if (config.mode === \"two-way\") {\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(\n (person) => person.id === personConnection.person.id,\n );\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 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 profile: {\n displayName: worknicePerson.displayName,\n profileEmail: worknicePerson.profileEmail ?? null,\n },\n },\n contextWithIntegration,\n );\n\n await worknice.updatePersonConnection({\n personConnectionId: personConnection.id,\n personId: personConnection.person.id,\n remote,\n status: ConnectionStatus.Merged,\n });\n\n logger.info(`Added new person \"${remote.name}\" to ${config.appName}.`);\n } catch (error) {\n logger.info(\n `Unable to add person \"${worknicePerson.displayName}\" in Worknice to ${config.appName} because of the following error:\\n\\n${error instanceof Error ? error.message : error}\\n`,\n );\n }\n }\n\n logger.dedent(`Finished adding new people to ${config.appName}.`);\n }\n }\n\n await worknice.completeSync({ integrationId: payload.integrationId });\n\n logger.info(\"Sync completed.\");\n } catch (error) {\n await worknice.completeSync({ integrationId: payload.integrationId });\n throw error;\n }\n },\n parsePayload: async ({ request }) => request.json(),\n },\n options,\n );\n\nconst personToName = (person: Person) => {\n if (\n (person.personalDetails?.givenName ?? \"\").trim() !== \"\" &&\n (person.personalDetails?.familyName ?? \"\").trim() !== \"\"\n ) {\n return `${person.personalDetails?.givenName} ${person.personalDetails?.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): PartialPersonDataTransferLine => ({\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 emergencyContacts: null,\n personalDetails: worknicePerson.givenName\n ? {\n dateOfBirth: worknicePerson.dateOfBirth ?? null,\n familyName: worknicePerson.familyName ?? null,\n gender: worknicePerson.gender ?? null,\n givenName: worknicePerson.givenName ?? null,\n otherGivenNames: worknicePerson.otherGivenNames ?? null,\n personalEmail: worknicePerson.personalEmail ?? null,\n personalPhone: worknicePerson.personalPhone ?? null,\n }\n : null,\n postalAddress: 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 ?? null,\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 // TODO: Enable syncing tax details. See PROD-2375.\n taxDetails: null,\n // TODO: Enable syncing tenure. See PROD-1371.\n tenure: null,\n});\n\nexport default handleTriggerIntegrationSyncWebhook;\n"],"mappings":"AAAA,SAAS,gBAA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nD,kBAAkB,eAAe,oBAAoB;AAAA,IACrD,oBAAoB,eAAe,sBAAsB;AAAA,EAC3D,IACA;AAAA,EACJ,mBAAmB;AAAA,EACnB,iBAAiB,eAAe,YAC5B;AAAA,IACE,aAAa,eAAe,eAAe;AAAA,IAC3C,YAAY,eAAe,cAAc;AAAA,IACzC,QAAQ,eAAe,UAAU;AAAA,IACjC,WAAW,eAAe,aAAa;AAAA,IACvC,iBAAiB,eAAe,mBAAmB;AAAA,IACnD,eAAe,eAAe,iBAAiB;AAAA,IAC/C,eAAe,eAAe,iBAAiB;AAAA,EACjD,IACA;AAAA,EACJ,eAAe;AAAA,EACf,oBAAoB,eAAe,0BAC/B;AAAA,IACE,wBAAwB,eAAe,0BAA0B;AAAA;AAAA,IAEjE,2BAA2B,eAAe,6BAA6B;AAAA,IACvE,yBAAyB,eAAe,2BAA2B;AAAA,IACnE,yBAAyB,eAAe,2BAA2B;AAAA,IACnE,4BAA4B,eAAe,8BAA8B;AAAA,IACzE,yBAAyB,eAAe,2BAA2B;AAAA,EACrE,IACA;AAAA;AAAA,EAEJ,YAAY;AAAA;AAAA,EAEZ,YAAY;AAAA;AAAA,EAEZ,QAAQ;AACV;AAEA,IAAO,8CAAQ;","names":["request"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@worknice/js-sdk",
3
3
  "description": "",
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "files": [