@worknice/js-sdk 0.0.1 → 0.0.3
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.
- package/dist/_types-BXw9D0Qi.d.ts +642 -0
- package/dist/api/WorkniceIntegrationLogger.d.ts +99 -0
- package/dist/api/WorkniceIntegrationLogger.js +173 -0
- package/dist/api/WorkniceIntegrationLogger.js.map +1 -0
- package/dist/api/_generated.d.ts +357 -22
- package/dist/api/_generated.js.map +1 -1
- package/dist/api/_types.d.ts +2 -2
- package/dist/api/_types.js +1 -0
- package/dist/api/_types.js.map +1 -1
- package/dist/api/createApiOperation.d.ts +1 -1
- package/dist/api/createWorkniceClient.d.ts +1 -1
- package/dist/api/createWorkniceClient.js +22 -2
- package/dist/api/createWorkniceClient.js.map +1 -1
- package/dist/api/operations/activateIntegration.d.ts +1 -1
- package/dist/api/operations/authorizeIntegration.d.ts +20 -0
- package/dist/api/operations/authorizeIntegration.js +23 -0
- package/dist/api/operations/authorizeIntegration.js.map +1 -0
- package/dist/api/operations/completeSync.d.ts +20 -0
- package/dist/api/operations/completeSync.js +23 -0
- package/dist/api/operations/completeSync.js.map +1 -0
- package/dist/api/operations/createApiToken.d.ts +1 -1
- package/dist/api/operations/createDataImport.d.ts +12 -0
- package/dist/api/operations/createDataImport.js +25 -0
- package/dist/api/operations/createDataImport.js.map +1 -0
- package/dist/api/operations/createPersonConnection.d.ts +132 -0
- package/dist/api/operations/createPersonConnection.js +65 -0
- package/dist/api/operations/createPersonConnection.js.map +1 -0
- package/dist/api/operations/createPersonDataImportLine.d.ts +22 -0
- package/dist/api/operations/createPersonDataImportLine.js +49 -0
- package/dist/api/operations/createPersonDataImportLine.js.map +1 -0
- package/dist/api/operations/deleteApiToken.d.ts +1 -1
- package/dist/api/operations/deletePersonConnection.d.ts +10 -0
- package/dist/api/operations/deletePersonConnection.js +21 -0
- package/dist/api/operations/deletePersonConnection.js.map +1 -0
- package/dist/api/operations/getApiTokens.d.ts +1 -1
- package/dist/api/operations/getIntegration.d.ts +65 -0
- package/dist/api/operations/getIntegration.js +32 -0
- package/dist/api/operations/getIntegration.js.map +1 -0
- package/dist/api/operations/getPeople.d.ts +65 -0
- package/dist/api/operations/getPeople.js +79 -0
- package/dist/api/operations/getPeople.js.map +1 -0
- package/dist/api/operations/getPersonConnections.d.ts +107 -0
- package/dist/api/operations/getPersonConnections.js +43 -0
- package/dist/api/operations/getPersonConnections.js.map +1 -0
- package/dist/api/operations/initializeIntegration.d.ts +1 -1
- package/dist/api/operations/updatePersonConnection.d.ts +132 -0
- package/dist/api/operations/updatePersonConnection.js +65 -0
- package/dist/api/operations/updatePersonConnection.js.map +1 -0
- package/dist/employee-records/EQUALITY_CHECKS.d.ts +1 -0
- package/dist/employee-records/EQUALITY_CHECKS.js +1 -2
- package/dist/employee-records/EQUALITY_CHECKS.js.map +1 -1
- package/dist/employee-records/_types.d.ts +13 -12
- package/dist/employee-records/comparePersonDataTransferLines.d.ts +1 -0
- package/dist/employee-records/comparePersonDataTransferLines.js +0 -3
- package/dist/employee-records/comparePersonDataTransferLines.js.map +1 -1
- package/dist/employee-records/index.d.ts +5 -4
- package/dist/employee-records/mergePersonDataTransferLines.d.ts +1 -0
- package/dist/employee-records/mergePersonDataTransferLines.js +0 -1
- package/dist/employee-records/mergePersonDataTransferLines.js.map +1 -1
- package/dist/employee-records/validatePersonDataTransferLine.d.ts +1 -0
- package/dist/employee-records/validatePersonDataTransferLineBankAccounts.d.ts +1 -0
- package/dist/employee-records/validatePersonDataTransferLineBankAccounts.js +10 -9
- package/dist/employee-records/validatePersonDataTransferLineBankAccounts.js.map +1 -1
- package/dist/employee-records/validatePersonDataTransferLineEmergencyContacts.d.ts +1 -0
- package/dist/employee-records/validatePersonDataTransferLinePersonalDetails.d.ts +1 -0
- package/dist/employee-records/validatePersonDataTransferLinePersonalDetails.js +1 -3
- package/dist/employee-records/validatePersonDataTransferLinePersonalDetails.js.map +1 -1
- package/dist/employee-records/validatePersonDataTransferLinePostalAddress.d.ts +1 -0
- package/dist/employee-records/validatePersonDataTransferLineResidentialAddress.d.ts +1 -0
- package/dist/employee-records/validatePersonDataTransferLineSuperFunds.d.ts +1 -0
- package/dist/employee-records/validatePersonDataTransferLineTaxDetails.d.ts +1 -0
- package/dist/employee-records/validatePersonDataTransferLineTenure.d.ts +1 -0
- package/dist/employee-records/validatePersonDataTransferLineTenure.js +1 -1
- package/dist/employee-records/validatePersonDataTransferLineTenure.js.map +1 -1
- package/dist/helpers/_types.d.ts +7 -6
- package/dist/helpers/handleCreateIntegrationWebhook.d.ts +3 -2
- package/dist/helpers/handleCreateIntegrationWebhook.js +6 -4
- package/dist/helpers/handleCreateIntegrationWebhook.js.map +1 -1
- package/dist/helpers/handleGetAuthorizationUrlWebhook.d.ts +3 -2
- package/dist/helpers/handleGetAuthorizationUrlWebhook.js +4 -1
- package/dist/helpers/handleGetAuthorizationUrlWebhook.js.map +1 -1
- package/dist/helpers/handleGetLeaveBalancesWebhook.d.ts +14 -0
- package/dist/helpers/handleGetLeaveBalancesWebhook.js +22 -0
- package/dist/helpers/handleGetLeaveBalancesWebhook.js.map +1 -0
- package/dist/helpers/handleRequestWithWorknice.d.ts +9 -14
- package/dist/helpers/handleRequestWithWorknice.js +40 -19
- package/dist/helpers/handleRequestWithWorknice.js.map +1 -1
- package/dist/helpers/handleTriggerIntegrationSyncWebhook.d.ts +72 -0
- package/dist/helpers/handleTriggerIntegrationSyncWebhook.js +600 -0
- package/dist/helpers/handleTriggerIntegrationSyncWebhook.js.map +1 -0
- package/dist/helpers/index.d.ts +8 -2
- package/dist/helpers/index.js +9 -1
- package/dist/helpers/index.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/utils/disambiguatePersonConnections.d.ts +25 -0
- package/dist/utils/disambiguatePersonConnections.js +18 -0
- package/dist/utils/disambiguatePersonConnections.js.map +1 -0
- package/dist/utils/isAfter.d.ts +4 -4
- package/dist/utils/isAfter.js +1 -1
- package/dist/utils/isAfter.js.map +1 -1
- package/dist/utils/isNotNullable.d.ts +10 -0
- package/dist/utils/isNotNullable.js +6 -0
- package/dist/utils/isNotNullable.js.map +1 -0
- package/dist/utils/isSamePlainDate.d.ts +1 -1
- package/dist/utils/isSamePlainDate.js +1 -1
- package/dist/utils/isSamePlainDate.js.map +1 -1
- package/dist/utils/isValidPlainDate.d.ts +1 -1
- package/dist/utils/isValidPlainDate.js +1 -1
- package/dist/utils/isValidPlainDate.js.map +1 -1
- package/dist/utils/parsePlainDate.d.ts +1 -1
- package/dist/utils/parsePlainDate.js +1 -1
- package/dist/utils/parsePlainDate.js.map +1 -1
- package/dist/webhooks.d.ts +42 -0
- package/dist/webhooks.js +1 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +11 -7
- package/dist/_types-DsB4q143.d.ts +0 -127
|
@@ -0,0 +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,UAAI;AACF,eAAO,QAAQ,UAAU,QAAQ,aAAa;AAE9C,eAAO,OAAO,gCAA2B;AAEzC,cAAM,cAAc,MAAM,SAAS,eAAe;AAAA,UAChD,eAAe,QAAQ;AAAA,QACzB,CAAC;AAED,YAAI,YAAY,UAAU;AACxB,iBAAO,KAAK,yCAAyC;AACrD;AAAA,QACF;AAEA,YAAI,YAAY,WAAW,WAAW;AACpC,iBAAO,KAAK,4DAA4D;AACxE;AAAA,QACF;AAEA,eAAO,KAAK,sCAAsC;AAElD,cAAM,oBAAoB,MAAM,SAAS,qBAAqB;AAAA,UAC5D,eAAe,QAAQ;AAAA,QACzB,CAAC;AAED,eAAO,KAAK,aAAa,kBAAkB,MAAM,sCAAsC;AAEvF,cAAM,SAAS,MAAM,SAAS,UAAU,EAAE,OAAO,YAAY,IAAI,GAAG,CAAC;AAErE,eAAO,KAAK,aAAa,OAAO,MAAM,2BAA2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AAe,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/dist/helpers/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export { default as handleCreateIntegrationWebhook } from './handleCreateIntegrationWebhook.js';
|
|
2
|
-
|
|
2
|
+
export { default as handleGetAuthorizationUrlWebhook } from './handleGetAuthorizationUrlWebhook.js';
|
|
3
|
+
export { default as handleGetLeaveBalancesWebhook } from './handleGetLeaveBalancesWebhook.js';
|
|
4
|
+
export { default as handleRequestWithWorknice } from './handleRequestWithWorknice.js';
|
|
5
|
+
export { default as handleTriggerIntegrationSyncWebhook } from './handleTriggerIntegrationSyncWebhook.js';
|
|
6
|
+
import '../webhooks.js';
|
|
3
7
|
import './_types.js';
|
|
4
|
-
import '../_types-
|
|
8
|
+
import '../_types-BXw9D0Qi.js';
|
|
5
9
|
import '../api/_generated.js';
|
|
10
|
+
import '../api/WorkniceIntegrationLogger.js';
|
|
11
|
+
import '../employee-records/_types.js';
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { default as default2 } from "./handleCreateIntegrationWebhook.js";
|
|
2
|
+
import { default as default3 } from "./handleGetAuthorizationUrlWebhook.js";
|
|
3
|
+
import { default as default4 } from "./handleGetLeaveBalancesWebhook.js";
|
|
4
|
+
import { default as default5 } from "./handleRequestWithWorknice.js";
|
|
5
|
+
import { default as default6 } from "./handleTriggerIntegrationSyncWebhook.js";
|
|
2
6
|
export {
|
|
3
|
-
default2 as handleCreateIntegrationWebhook
|
|
7
|
+
default2 as handleCreateIntegrationWebhook,
|
|
8
|
+
default3 as handleGetAuthorizationUrlWebhook,
|
|
9
|
+
default4 as handleGetLeaveBalancesWebhook,
|
|
10
|
+
default5 as handleRequestWithWorknice,
|
|
11
|
+
default6 as handleTriggerIntegrationSyncWebhook
|
|
4
12
|
};
|
|
5
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/helpers/index.ts"],"sourcesContent":["export { default as handleCreateIntegrationWebhook } from \"./handleCreateIntegrationWebhook.js\";\n"],"mappings":"AAAA,SAAoB,WAAXA,gBAAiD;","names":["default"]}
|
|
1
|
+
{"version":3,"sources":["../../src/helpers/index.ts"],"sourcesContent":["export { default as handleCreateIntegrationWebhook } from \"./handleCreateIntegrationWebhook.js\";\nexport { default as handleGetAuthorizationUrlWebhook } from \"./handleGetAuthorizationUrlWebhook.js\";\nexport { default as handleGetLeaveBalancesWebhook } from \"./handleGetLeaveBalancesWebhook.js\";\nexport { default as handleRequestWithWorknice } from \"./handleRequestWithWorknice.js\";\nexport { default as handleTriggerIntegrationSyncWebhook } from \"./handleTriggerIntegrationSyncWebhook.js\";\n"],"mappings":"AAAA,SAAoB,WAAXA,gBAAiD;AAC1D,SAAoB,WAAXA,gBAAmD;AAC5D,SAAoB,WAAXA,gBAAgD;AACzD,SAAoB,WAAXA,gBAA4C;AACrD,SAAoB,WAAXA,gBAAsD;","names":["default"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export { default as validatePersonDataTransferLineSuperFunds } from './employee-
|
|
|
10
10
|
export { default as validatePersonDataTransferLineTaxDetails } from './employee-records/validatePersonDataTransferLineTaxDetails.js';
|
|
11
11
|
export { default as validatePersonDataTransferLineTenure } from './employee-records/validatePersonDataTransferLineTenure.js';
|
|
12
12
|
export { PartialPersonDataTransferLine, PersonDataTransferLine, PersonDataTransferLineDiff } from './employee-records/_types.js';
|
|
13
|
-
export { default as isAfter } from '@worknice/
|
|
14
|
-
export { default as isSamePlainDate } from '@worknice/
|
|
15
|
-
export { default as isValidPlainDate } from '@worknice/
|
|
16
|
-
export { default as parsePlainDate } from '@worknice/
|
|
13
|
+
export { default as isAfter } from '@worknice/utils/utils/isAfter';
|
|
14
|
+
export { default as isSamePlainDate } from '@worknice/utils/utils/isSamePlainDate';
|
|
15
|
+
export { default as isValidPlainDate } from '@worknice/utils/utils/isValidPlainDate';
|
|
16
|
+
export { default as parsePlainDate } from '@worknice/utils/utils/parsePlainDate';
|
|
17
|
+
import './api/_generated.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ConnectionStatus, PersonConnection } from '../api/_generated.js';
|
|
2
|
+
|
|
3
|
+
declare const disambiguatePersonConnections: <T extends {
|
|
4
|
+
status: ConnectionStatus;
|
|
5
|
+
remote?: Partial<PersonConnection["remote"]>;
|
|
6
|
+
person?: Partial<PersonConnection["person"]>;
|
|
7
|
+
}>(connection: T) => (T & {
|
|
8
|
+
status: ConnectionStatus.Connected;
|
|
9
|
+
remote: NonNullable<T["remote"]>;
|
|
10
|
+
person: NonNullable<T["person"]>;
|
|
11
|
+
}) | (T & {
|
|
12
|
+
status: ConnectionStatus.Merged;
|
|
13
|
+
remote: NonNullable<T["remote"]>;
|
|
14
|
+
person: NonNullable<T["person"]>;
|
|
15
|
+
}) | (T & {
|
|
16
|
+
status: ConnectionStatus.LocalOnly;
|
|
17
|
+
person: NonNullable<T["person"]>;
|
|
18
|
+
remote: null;
|
|
19
|
+
}) | (T & {
|
|
20
|
+
status: ConnectionStatus.RemoteOnly;
|
|
21
|
+
remote: NonNullable<T["remote"]>;
|
|
22
|
+
person: null;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { disambiguatePersonConnections as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ConnectionStatus } from "../api/_types.js";
|
|
2
|
+
const disambiguatePersonConnections = (connection) => {
|
|
3
|
+
switch (connection.status) {
|
|
4
|
+
case ConnectionStatus.Connected:
|
|
5
|
+
return connection;
|
|
6
|
+
case ConnectionStatus.Merged:
|
|
7
|
+
return connection;
|
|
8
|
+
case ConnectionStatus.LocalOnly:
|
|
9
|
+
return connection;
|
|
10
|
+
case ConnectionStatus.RemoteOnly:
|
|
11
|
+
return connection;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var disambiguatePersonConnections_default = disambiguatePersonConnections;
|
|
15
|
+
export {
|
|
16
|
+
disambiguatePersonConnections_default as default
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=disambiguatePersonConnections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/disambiguatePersonConnections.ts"],"sourcesContent":["import { ConnectionStatus, type PersonConnection } from \"../api/_types.js\";\n\nconst disambiguatePersonConnections = <\n T extends {\n status: ConnectionStatus;\n remote?: Partial<PersonConnection[\"remote\"]>;\n person?: Partial<PersonConnection[\"person\"]>;\n },\n>(\n connection: T,\n) => {\n type Remote = NonNullable<T[\"remote\"]>;\n type Person = NonNullable<T[\"person\"]>;\n switch (connection.status) {\n case ConnectionStatus.Connected:\n return connection as T & {\n status: ConnectionStatus.Connected;\n remote: Remote;\n person: Person;\n };\n case ConnectionStatus.Merged:\n return connection as T & {\n status: ConnectionStatus.Merged;\n remote: Remote;\n person: Person;\n };\n case ConnectionStatus.LocalOnly:\n return connection as T & {\n status: ConnectionStatus.LocalOnly;\n person: Person;\n remote: null;\n };\n case ConnectionStatus.RemoteOnly:\n return connection as T & {\n status: ConnectionStatus.RemoteOnly;\n remote: Remote;\n person: null;\n };\n }\n};\n\nexport default disambiguatePersonConnections;\n"],"mappings":"AAAA,SAAS,wBAA+C;AAExD,MAAM,gCAAgC,CAOpC,eACG;AAGH,UAAQ,WAAW,QAAQ;AAAA,IACzB,KAAK,iBAAiB;AACpB,aAAO;AAAA,IAKT,KAAK,iBAAiB;AACpB,aAAO;AAAA,IAKT,KAAK,iBAAiB;AACpB,aAAO;AAAA,IAKT,KAAK,iBAAiB;AACpB,aAAO;AAAA,EAKX;AACF;AAEA,IAAO,wCAAQ;","names":[]}
|
package/dist/utils/isAfter.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default } from '@worknice/
|
|
2
|
-
import '@worknice/
|
|
3
|
-
import '@worknice/
|
|
4
|
-
import '@worknice/
|
|
1
|
+
export { default } from '@worknice/utils/utils/isAfter';
|
|
2
|
+
import '@worknice/utils/utils/isSamePlainDate';
|
|
3
|
+
import '@worknice/utils/utils/isValidPlainDate';
|
|
4
|
+
import '@worknice/utils/utils/parsePlainDate';
|
package/dist/utils/isAfter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/isAfter.ts"],"sourcesContent":["export { default } from \"@worknice/
|
|
1
|
+
{"version":3,"sources":["../../src/utils/isAfter.ts"],"sourcesContent":["export { default } from \"@worknice/utils/utils/isAfter\";\n"],"mappings":"AAAA,SAAS,WAAAA,gBAAe;","names":["default"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard to check if a value is not null or undefined. Can be used in an
|
|
3
|
+
* array filter to remove null or undefined values in a type safe way.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const newArray: Array<T> = (myArray as Array<T | null>).filter(isNotNullable);
|
|
7
|
+
*/
|
|
8
|
+
declare const isNotNullable: <T>(value: T | null | undefined) => value is T;
|
|
9
|
+
|
|
10
|
+
export { isNotNullable as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/isNotNullable.ts"],"sourcesContent":["/**\n * Type guard to check if a value is not null or undefined. Can be used in an\n * array filter to remove null or undefined values in a type safe way.\n *\n * @example\n * const newArray: Array<T> = (myArray as Array<T | null>).filter(isNotNullable);\n */\nconst isNotNullable = <T>(value: T | null | undefined): value is T =>\n value !== null && value !== undefined;\n\nexport default isNotNullable;\n"],"mappings":"AAOA,MAAM,gBAAgB,CAAI,UACxB,UAAU,QAAQ,UAAU;AAE9B,IAAO,wBAAQ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from '@worknice/
|
|
1
|
+
export { default } from '@worknice/utils/utils/isSamePlainDate';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/isSamePlainDate.ts"],"sourcesContent":["export { default } from \"@worknice/
|
|
1
|
+
{"version":3,"sources":["../../src/utils/isSamePlainDate.ts"],"sourcesContent":["export { default } from \"@worknice/utils/utils/isSamePlainDate\";\n"],"mappings":"AAAA,SAAS,WAAAA,gBAAe;","names":["default"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from '@worknice/
|
|
1
|
+
export { default } from '@worknice/utils/utils/isValidPlainDate';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/isValidPlainDate.ts"],"sourcesContent":["export { default } from \"@worknice/
|
|
1
|
+
{"version":3,"sources":["../../src/utils/isValidPlainDate.ts"],"sourcesContent":["export { default } from \"@worknice/utils/utils/isValidPlainDate\";\n"],"mappings":"AAAA,SAAS,WAAAA,gBAAe;","names":["default"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from '@worknice/
|
|
1
|
+
export { default } from '@worknice/utils/utils/parsePlainDate';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/parsePlainDate.ts"],"sourcesContent":["export { default } from \"@worknice/
|
|
1
|
+
{"version":3,"sources":["../../src/utils/parsePlainDate.ts"],"sourcesContent":["export { default } from \"@worknice/utils/utils/parsePlainDate\";\n"],"mappings":"AAAA,SAAS,WAAAA,gBAAe;","names":["default"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
type CreateIntegrationRequestPayload = {
|
|
2
|
+
apiToken: string;
|
|
3
|
+
integrationId: string;
|
|
4
|
+
};
|
|
5
|
+
type GetAuthorizationUrlRequestPayload = {
|
|
6
|
+
integrationId: string;
|
|
7
|
+
};
|
|
8
|
+
type GetAuthorizationUrlResponsePayload = {
|
|
9
|
+
authorizationUrl: string;
|
|
10
|
+
};
|
|
11
|
+
type GetLeaveBalancesRequestPayload = {
|
|
12
|
+
integrationId: string;
|
|
13
|
+
remoteId: string;
|
|
14
|
+
};
|
|
15
|
+
type GetLeaveBalancesResponsePayload = Array<{
|
|
16
|
+
accruedAmount: string;
|
|
17
|
+
id: string;
|
|
18
|
+
leaveCategory: {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
type PersonConnectedRequestPayload = {
|
|
24
|
+
id: string;
|
|
25
|
+
integration: {
|
|
26
|
+
id: string;
|
|
27
|
+
};
|
|
28
|
+
person: {
|
|
29
|
+
displayName: string;
|
|
30
|
+
id: string;
|
|
31
|
+
} | null;
|
|
32
|
+
remote: {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
} | null;
|
|
36
|
+
status: "CONNECTED" | "LOCAL_ONLY" | "MERGED" | "REMOTE_ONLY";
|
|
37
|
+
};
|
|
38
|
+
type TriggerIntegrationSyncRequestPayload = {
|
|
39
|
+
integrationId: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type { CreateIntegrationRequestPayload, GetAuthorizationUrlRequestPayload, GetAuthorizationUrlResponsePayload, GetLeaveBalancesRequestPayload, GetLeaveBalancesResponsePayload, PersonConnectedRequestPayload, TriggerIntegrationSyncRequestPayload };
|
package/dist/webhooks.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@worknice/js-sdk",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
7
7
|
"files": [
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"dedent": "^0.7.0",
|
|
38
|
-
"
|
|
38
|
+
"uuid": "^8.3.2",
|
|
39
|
+
"@worknice/utils": "^0.0.3"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@graphql-codegen/add": "^5.0.0",
|
|
@@ -46,26 +47,29 @@
|
|
|
46
47
|
"@total-typescript/tsconfig": "^1.0.4",
|
|
47
48
|
"@types/dedent": "^0.7.0",
|
|
48
49
|
"@types/node": "^20.16.10",
|
|
50
|
+
"@types/uuid": "^8.3.1",
|
|
49
51
|
"@typescript-eslint/eslint-plugin": "^8.7.0",
|
|
50
52
|
"@typescript-eslint/parser": "^8.7.0",
|
|
51
53
|
"currency.js": "^2.0.4",
|
|
52
54
|
"eslint": "^8.57.1",
|
|
55
|
+
"temporal-polyfill": "^0.2.1",
|
|
53
56
|
"tsup": "^8.2.4",
|
|
54
57
|
"typescript": "~5.5.0"
|
|
55
58
|
},
|
|
56
59
|
"peerDependencies": {
|
|
57
|
-
"currency.js": "^2.0.4"
|
|
60
|
+
"currency.js": "^2.0.4",
|
|
61
|
+
"temporal-polyfill": "^0.2.1"
|
|
58
62
|
},
|
|
59
63
|
"scripts": {
|
|
60
|
-
"build": "rm -rf ./dist && tsup",
|
|
61
|
-
"dev": "pnpm run --stream \"/^dev:.*/\"",
|
|
64
|
+
"build": "cp ../../apps/notebook/src/utils/webhooks.ts ./src && rm -rf ./dist && tsup",
|
|
65
|
+
"dev": "cp ../../apps/notebook/src/utils/webhooks.ts ./src && pnpm run --stream \"/^dev:.*/\"",
|
|
62
66
|
"dev:tsup": "rm -rf ./dist && tsup --watch",
|
|
63
67
|
"dev:codegen": "graphql-codegen -c graphql.config.json -w",
|
|
64
68
|
"gen:types": "graphql-codegen -c graphql.config.json",
|
|
65
|
-
"release": "pnpm dlx @jsdevtools/version-bump-prompt --commit \"chore(js-sdk): release v%s\" --tag \"js-sdk-v%s\"",
|
|
69
|
+
"release": "pnpm build && pnpm dlx @jsdevtools/version-bump-prompt --commit \"chore(js-sdk): release v%s\" --tag \"js-sdk-v%s\" && pnpm publish --access public",
|
|
66
70
|
"test": "if [[ -z $TURBO_HASH ]]; then echo 'Use `pnpm turbo test` to run tests.\n' && exit 1; else exit 0; fi",
|
|
67
71
|
"test:lint": "eslint src --color",
|
|
68
72
|
"test:prettier": "prettier -c '**/*.{js,ts,tsx,css}'",
|
|
69
|
-
"test:types": "tsc --noEmit --pretty"
|
|
73
|
+
"test:types": "cp ../../apps/notebook/src/utils/webhooks.ts ./src && tsc --noEmit --pretty"
|
|
70
74
|
}
|
|
71
75
|
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { Exact, Scalars, InputMaybe } from './api/_generated.js';
|
|
2
|
-
|
|
3
|
-
declare const createWorkniceClient: (clientConfig?: ClientConfig) => {
|
|
4
|
-
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
5
|
-
/**
|
|
6
|
-
* Transitions an integration with an 'UNAUTHORIZED' or 'UNCONFIGURED'
|
|
7
|
-
* status to an 'ACTIVE' status. Optionally, the name of the integration can
|
|
8
|
-
* be set at the same time.
|
|
9
|
-
*/
|
|
10
|
-
activateIntegration: (variables: Pick<Exact<{
|
|
11
|
-
id: Scalars["ID"]["input"];
|
|
12
|
-
name?: InputMaybe<Scalars["String"]["input"]>;
|
|
13
|
-
rename: Scalars["Boolean"]["input"];
|
|
14
|
-
}>, "id" | "name">, fetchOptions?: FetchOptions) => Promise<{
|
|
15
|
-
id: string;
|
|
16
|
-
} | {
|
|
17
|
-
id: string;
|
|
18
|
-
} | {
|
|
19
|
-
id: string;
|
|
20
|
-
} | {
|
|
21
|
-
id: string;
|
|
22
|
-
} | {
|
|
23
|
-
id: string;
|
|
24
|
-
}>;
|
|
25
|
-
/**
|
|
26
|
-
* Creates a new API token belonging to the current person.
|
|
27
|
-
*/
|
|
28
|
-
createApiToken: (variables: Exact<{
|
|
29
|
-
name: Scalars["String"]["input"];
|
|
30
|
-
}>, fetchOptions?: FetchOptions) => Promise<{
|
|
31
|
-
token: string;
|
|
32
|
-
id: string;
|
|
33
|
-
name: string;
|
|
34
|
-
}>;
|
|
35
|
-
/**
|
|
36
|
-
* Permanently deletes an API token belonging to the current person.
|
|
37
|
-
*/
|
|
38
|
-
deleteApiToken: (variables: Exact<{
|
|
39
|
-
tokenId: Scalars["ID"]["input"];
|
|
40
|
-
}>, fetchOptions?: FetchOptions) => Promise<boolean>;
|
|
41
|
-
/**
|
|
42
|
-
* Transitions an integration with an 'UNINITIALIZED' status to an 'UNAUTHORIZED' status.
|
|
43
|
-
*/
|
|
44
|
-
initializeIntegration: (variables: Exact<{
|
|
45
|
-
id: Scalars["ID"]["input"];
|
|
46
|
-
}>, fetchOptions?: FetchOptions) => Promise<{
|
|
47
|
-
id: string;
|
|
48
|
-
} | {
|
|
49
|
-
id: string;
|
|
50
|
-
} | {
|
|
51
|
-
id: string;
|
|
52
|
-
} | {
|
|
53
|
-
id: string;
|
|
54
|
-
} | {
|
|
55
|
-
id: string;
|
|
56
|
-
}>;
|
|
57
|
-
/**
|
|
58
|
-
* Returns a list of API tokens belonging to the current person. This will not
|
|
59
|
-
* include the token values themselves as they are only available when the
|
|
60
|
-
* token is initially created.
|
|
61
|
-
*
|
|
62
|
-
* If there is no person associated with the session, a `NO_PERSON` error will
|
|
63
|
-
* be thrown.
|
|
64
|
-
*/
|
|
65
|
-
getApiTokens: (variables: Exact<{
|
|
66
|
-
[key: string]: never;
|
|
67
|
-
}>, fetchOptions?: FetchOptions) => Promise<{
|
|
68
|
-
createdAt: string;
|
|
69
|
-
id: string;
|
|
70
|
-
name: string;
|
|
71
|
-
}[]>;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
type SuccessfulQueryResult<Data extends object = object> = Readonly<{
|
|
75
|
-
data: Data;
|
|
76
|
-
}> | Readonly<{
|
|
77
|
-
data: Data;
|
|
78
|
-
errors: ReadonlyArray<GraphQLFormattedError>;
|
|
79
|
-
}>;
|
|
80
|
-
type FailedQueryResult = Readonly<{
|
|
81
|
-
data: null;
|
|
82
|
-
errors: ReadonlyArray<GraphQLFormattedError>;
|
|
83
|
-
}> | Readonly<{
|
|
84
|
-
errors: ReadonlyArray<GraphQLFormattedError>;
|
|
85
|
-
}>;
|
|
86
|
-
type QueryResult<Data extends object = object> = SuccessfulQueryResult<Data> | FailedQueryResult;
|
|
87
|
-
type FetchOptions = {
|
|
88
|
-
signal?: AbortSignal;
|
|
89
|
-
};
|
|
90
|
-
type ClientConfig = {
|
|
91
|
-
accessToken?: string;
|
|
92
|
-
apiUrl?: string;
|
|
93
|
-
};
|
|
94
|
-
type WorkniceClient = ReturnType<typeof createWorkniceClient>;
|
|
95
|
-
interface GraphQLFormattedError {
|
|
96
|
-
/**
|
|
97
|
-
* A short, human-readable summary of the problem that **SHOULD NOT** change
|
|
98
|
-
* from occurrence to occurrence of the problem, except for purposes of
|
|
99
|
-
* localization.
|
|
100
|
-
*/
|
|
101
|
-
readonly message: string;
|
|
102
|
-
/**
|
|
103
|
-
* If an error can be associated to a particular point in the requested
|
|
104
|
-
* GraphQL document, it should contain a list of locations.
|
|
105
|
-
*/
|
|
106
|
-
readonly locations?: ReadonlyArray<SourceLocation>;
|
|
107
|
-
/**
|
|
108
|
-
* If an error can be associated to a particular field in the GraphQL result,
|
|
109
|
-
* it _must_ contain an entry with the key `path` that details the path of
|
|
110
|
-
* the response field which experienced the error. This allows clients to
|
|
111
|
-
* identify whether a null result is intentional or caused by a runtime error.
|
|
112
|
-
*/
|
|
113
|
-
readonly path?: ReadonlyArray<string | number>;
|
|
114
|
-
/**
|
|
115
|
-
* Reserved for implementors to extend the protocol however they see fit,
|
|
116
|
-
* and hence there are no additional restrictions on its contents.
|
|
117
|
-
*/
|
|
118
|
-
readonly extensions?: {
|
|
119
|
-
[key: string]: unknown;
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
interface SourceLocation {
|
|
123
|
-
readonly line: number;
|
|
124
|
-
readonly column: number;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export { type ClientConfig as C, type FetchOptions as F, type QueryResult as Q, type SuccessfulQueryResult as S, type WorkniceClient as W, type FailedQueryResult as a, createWorkniceClient as c };
|