@transcend-io/cli 10.22.0 → 10.23.0
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/{app-k7HdVTDP.mjs → app-C9JuEKbr.mjs} +17 -17
- package/dist/{app-k7HdVTDP.mjs.map → app-C9JuEKbr.mjs.map} +1 -1
- package/dist/{approvePrivacyRequests-ChRsPJuq.mjs → approvePrivacyRequests-BMa5P15R.mjs} +2 -2
- package/dist/{approvePrivacyRequests-ChRsPJuq.mjs.map → approvePrivacyRequests-BMa5P15R.mjs.map} +1 -1
- package/dist/bin/bash-complete.mjs +1 -1
- package/dist/bin/cli.mjs +1 -1
- package/dist/bin/deprecated-command.mjs +1 -1
- package/dist/{buildExamples-DVJjTfkL.mjs → buildExamples-C1d7A08r.mjs} +2 -2
- package/dist/{buildExamples-DVJjTfkL.mjs.map → buildExamples-C1d7A08r.mjs.map} +1 -1
- package/dist/{buildXdiSyncEndpoint-CsT_eIC0.mjs → buildXdiSyncEndpoint-CZmu6rbU.mjs} +2 -2
- package/dist/{buildXdiSyncEndpoint-CsT_eIC0.mjs.map → buildXdiSyncEndpoint-CZmu6rbU.mjs.map} +1 -1
- package/dist/{bulkRestartRequests-D_rkhYHP.mjs → bulkRestartRequests-Bt1ywbss.mjs} +2 -2
- package/dist/{bulkRestartRequests-D_rkhYHP.mjs.map → bulkRestartRequests-Bt1ywbss.mjs.map} +1 -1
- package/dist/{bulkRetryEnrichers-B7Y2L-9j.mjs → bulkRetryEnrichers-B42uPqju.mjs} +2 -2
- package/dist/{bulkRetryEnrichers-B7Y2L-9j.mjs.map → bulkRetryEnrichers-B42uPqju.mjs.map} +1 -1
- package/dist/{cancelPrivacyRequests-DQ0FGpFC.mjs → cancelPrivacyRequests-BLWlXNF5.mjs} +2 -2
- package/dist/{cancelPrivacyRequests-DQ0FGpFC.mjs.map → cancelPrivacyRequests-BLWlXNF5.mjs.map} +1 -1
- package/dist/codecs-DH-hZonL.mjs +2 -0
- package/dist/codecs-DH-hZonL.mjs.map +1 -0
- package/dist/{command-Br4qaCbe.mjs → command-DSEJjlWi.mjs} +2 -2
- package/dist/{command-Br4qaCbe.mjs.map → command-DSEJjlWi.mjs.map} +1 -1
- package/dist/{constants-CL4uZK_i.mjs → constants-CgI8_Rfc.mjs} +2 -2
- package/dist/{constants-CL4uZK_i.mjs.map → constants-CgI8_Rfc.mjs.map} +1 -1
- package/dist/{createExtraKeyHandler-Dmf3seLV.mjs → createExtraKeyHandler-BdxKFYkG.mjs} +2 -2
- package/dist/{createExtraKeyHandler-Dmf3seLV.mjs.map → createExtraKeyHandler-BdxKFYkG.mjs.map} +1 -1
- package/dist/{downloadPrivacyRequestFiles-DZWJnqvZ.mjs → downloadPrivacyRequestFiles-B_Hj7D8R.mjs} +2 -2
- package/dist/{downloadPrivacyRequestFiles-DZWJnqvZ.mjs.map → downloadPrivacyRequestFiles-B_Hj7D8R.mjs.map} +1 -1
- package/dist/{generateCrossAccountApiKeys-BB_mGI0h.mjs → generateCrossAccountApiKeys-C8ZFxpdg.mjs} +2 -2
- package/dist/{generateCrossAccountApiKeys-BB_mGI0h.mjs.map → generateCrossAccountApiKeys-C8ZFxpdg.mjs.map} +1 -1
- package/dist/{impl-HrUgz4tG.mjs → impl-BAcwgZfx.mjs} +2 -2
- package/dist/{impl-HrUgz4tG.mjs.map → impl-BAcwgZfx.mjs.map} +1 -1
- package/dist/{impl-jNQ05KT3.mjs → impl-BFCZDhHg.mjs} +2 -2
- package/dist/{impl-jNQ05KT3.mjs.map → impl-BFCZDhHg.mjs.map} +1 -1
- package/dist/{impl-L9xPwNwz2.mjs → impl-BFZWp3UU2.mjs} +2 -2
- package/dist/{impl-L9xPwNwz2.mjs.map → impl-BFZWp3UU2.mjs.map} +1 -1
- package/dist/{impl-CKFy8off.mjs → impl-BHisOrKX.mjs} +2 -2
- package/dist/{impl-CKFy8off.mjs.map → impl-BHisOrKX.mjs.map} +1 -1
- package/dist/{impl-Dlq4QBj3.mjs → impl-BOCQpFcO.mjs} +2 -2
- package/dist/{impl-Dlq4QBj3.mjs.map → impl-BOCQpFcO.mjs.map} +1 -1
- package/dist/{impl-Bf0GGQao2.mjs → impl-BaeIbfQe2.mjs} +2 -2
- package/dist/{impl-Bf0GGQao2.mjs.map → impl-BaeIbfQe2.mjs.map} +1 -1
- package/dist/{impl-CNqAOFaW.mjs → impl-BeWMuac5.mjs} +2 -2
- package/dist/{impl-CNqAOFaW.mjs.map → impl-BeWMuac5.mjs.map} +1 -1
- package/dist/{impl-c0YrAaxs.mjs → impl-BoHg4UN1.mjs} +2 -2
- package/dist/{impl-c0YrAaxs.mjs.map → impl-BoHg4UN1.mjs.map} +1 -1
- package/dist/{impl-ChIESsn-.mjs → impl-BqBydC_y.mjs} +2 -2
- package/dist/{impl-ChIESsn-.mjs.map → impl-BqBydC_y.mjs.map} +1 -1
- package/dist/{impl-vUFXZXCy2.mjs → impl-C-bO3-ZT2.mjs} +2 -2
- package/dist/{impl-vUFXZXCy2.mjs.map → impl-C-bO3-ZT2.mjs.map} +1 -1
- package/dist/{impl-DysGumGV.mjs → impl-C2ZIXwmT.mjs} +2 -2
- package/dist/{impl-DysGumGV.mjs.map → impl-C2ZIXwmT.mjs.map} +1 -1
- package/dist/{impl-CF8ThZ09.mjs → impl-C930divP.mjs} +2 -2
- package/dist/{impl-CF8ThZ09.mjs.map → impl-C930divP.mjs.map} +1 -1
- package/dist/{impl-CWx3bY5-.mjs → impl-CPSwCOH3.mjs} +2 -2
- package/dist/{impl-CWx3bY5-.mjs.map → impl-CPSwCOH3.mjs.map} +1 -1
- package/dist/{impl-D4DM4YMs.mjs → impl-CXXgArMZ.mjs} +2 -2
- package/dist/{impl-D4DM4YMs.mjs.map → impl-CXXgArMZ.mjs.map} +1 -1
- package/dist/{impl-DaABRwZH2.mjs → impl-CcuqNyVQ2.mjs} +2 -2
- package/dist/{impl-DaABRwZH2.mjs.map → impl-CcuqNyVQ2.mjs.map} +1 -1
- package/dist/{impl-BvoC7ufZ.mjs → impl-CoLm9Dhn.mjs} +2 -2
- package/dist/{impl-BvoC7ufZ.mjs.map → impl-CoLm9Dhn.mjs.map} +1 -1
- package/dist/{impl-C66R8UJ9.mjs → impl-CoaEY_Xu.mjs} +2 -2
- package/dist/{impl-C66R8UJ9.mjs.map → impl-CoaEY_Xu.mjs.map} +1 -1
- package/dist/{impl-lJzO6Szh2.mjs → impl-D-0T5fxa2.mjs} +2 -2
- package/dist/{impl-lJzO6Szh2.mjs.map → impl-D-0T5fxa2.mjs.map} +1 -1
- package/dist/{impl-CHhCpncv.mjs → impl-D-kVJk0V.mjs} +2 -2
- package/dist/{impl-CHhCpncv.mjs.map → impl-D-kVJk0V.mjs.map} +1 -1
- package/dist/{impl-By84G6p2.mjs → impl-D1qyAnzc.mjs} +2 -2
- package/dist/{impl-By84G6p2.mjs.map → impl-D1qyAnzc.mjs.map} +1 -1
- package/dist/{impl-CkcUmrRl2.mjs → impl-D1y8T-ku2.mjs} +2 -2
- package/dist/{impl-CkcUmrRl2.mjs.map → impl-D1y8T-ku2.mjs.map} +1 -1
- package/dist/{impl-D1L6r4sY2.mjs → impl-D7ke0Gwy2.mjs} +2 -2
- package/dist/{impl-D1L6r4sY2.mjs.map → impl-D7ke0Gwy2.mjs.map} +1 -1
- package/dist/{impl-DLQT5on0.mjs → impl-DKzkdLQN.mjs} +2 -2
- package/dist/{impl-DLQT5on0.mjs.map → impl-DKzkdLQN.mjs.map} +1 -1
- package/dist/{impl-spb5yfh5.mjs → impl-DOQ5bwXl.mjs} +2 -2
- package/dist/{impl-spb5yfh5.mjs.map → impl-DOQ5bwXl.mjs.map} +1 -1
- package/dist/{impl-CbqDzZgA.mjs → impl-DPAGD55t.mjs} +2 -2
- package/dist/{impl-CbqDzZgA.mjs.map → impl-DPAGD55t.mjs.map} +1 -1
- package/dist/{impl-nePMEJkH.mjs → impl-DbW8OPcD.mjs} +2 -2
- package/dist/{impl-nePMEJkH.mjs.map → impl-DbW8OPcD.mjs.map} +1 -1
- package/dist/{impl-DczWZLXU.mjs → impl-DfUBAl_6.mjs} +2 -2
- package/dist/{impl-DczWZLXU.mjs.map → impl-DfUBAl_6.mjs.map} +1 -1
- package/dist/{impl-DopV2WpH.mjs → impl-DgUf3gA3.mjs} +2 -2
- package/dist/{impl-DopV2WpH.mjs.map → impl-DgUf3gA3.mjs.map} +1 -1
- package/dist/{impl-DwotW3m_.mjs → impl-DkwbYk5g.mjs} +2 -2
- package/dist/{impl-DwotW3m_.mjs.map → impl-DkwbYk5g.mjs.map} +1 -1
- package/dist/{impl-CaLW2sGU.mjs → impl-Dt0HArIu.mjs} +2 -2
- package/dist/{impl-CaLW2sGU.mjs.map → impl-Dt0HArIu.mjs.map} +1 -1
- package/dist/{impl-BFxef_1i.mjs → impl-DxkQuCp8.mjs} +2 -2
- package/dist/{impl-BFxef_1i.mjs.map → impl-DxkQuCp8.mjs.map} +1 -1
- package/dist/{impl-CiEmNCR6.mjs → impl-Qkau85p_.mjs} +2 -2
- package/dist/{impl-CiEmNCR6.mjs.map → impl-Qkau85p_.mjs.map} +1 -1
- package/dist/{impl-DW8CteEk2.mjs → impl-cIT5ehpg2.mjs} +2 -2
- package/dist/{impl-DW8CteEk2.mjs.map → impl-cIT5ehpg2.mjs.map} +1 -1
- package/dist/{impl-h_KDIeo4.mjs → impl-g_xHoYv8.mjs} +2 -2
- package/dist/{impl-h_KDIeo4.mjs.map → impl-g_xHoYv8.mjs.map} +1 -1
- package/dist/{impl-D18E8wLJ.mjs → impl-mDm2_MJM.mjs} +2 -2
- package/dist/{impl-D18E8wLJ.mjs.map → impl-mDm2_MJM.mjs.map} +1 -1
- package/dist/{impl-rbZRyuXb2.mjs → impl-ozhL5VUB2.mjs} +2 -2
- package/dist/{impl-rbZRyuXb2.mjs.map → impl-ozhL5VUB2.mjs.map} +1 -1
- package/dist/{impl-B1-zg8Ki.mjs → impl-qqLyjAc_.mjs} +2 -2
- package/dist/{impl-B1-zg8Ki.mjs.map → impl-qqLyjAc_.mjs.map} +1 -1
- package/dist/{impl-CDF30pp32.mjs → impl-sEqlxROi2.mjs} +2 -2
- package/dist/{impl-CDF30pp32.mjs.map → impl-sEqlxROi2.mjs.map} +1 -1
- package/dist/index.d.mts +86 -76
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{markRequestDataSiloIdsCompleted-rPtNCOCl.mjs → markRequestDataSiloIdsCompleted-CB_yZAXh.mjs} +2 -2
- package/dist/{markRequestDataSiloIdsCompleted-rPtNCOCl.mjs.map → markRequestDataSiloIdsCompleted-CB_yZAXh.mjs.map} +1 -1
- package/dist/{markSilentPrivacyRequests-L6fxUodG.mjs → markSilentPrivacyRequests-cfNU6f9-.mjs} +2 -2
- package/dist/{markSilentPrivacyRequests-L6fxUodG.mjs.map → markSilentPrivacyRequests-cfNU6f9-.mjs.map} +1 -1
- package/dist/{notifyPrivacyRequestsAdditionalTime-DjzVbnND.mjs → notifyPrivacyRequestsAdditionalTime-DYWo4N8w.mjs} +2 -2
- package/dist/{notifyPrivacyRequestsAdditionalTime-DjzVbnND.mjs.map → notifyPrivacyRequestsAdditionalTime-DYWo4N8w.mjs.map} +1 -1
- package/dist/{parseVariablesFromString-CfXnITrG.mjs → parseVariablesFromString-BH2VIMis.mjs} +2 -2
- package/dist/{parseVariablesFromString-CfXnITrG.mjs.map → parseVariablesFromString-BH2VIMis.mjs.map} +1 -1
- package/dist/{pullChunkedCustomSiloOutstandingIdentifiers-qZCnzDXQ.mjs → pullChunkedCustomSiloOutstandingIdentifiers-Czdfe35L.mjs} +2 -2
- package/dist/{pullChunkedCustomSiloOutstandingIdentifiers-qZCnzDXQ.mjs.map → pullChunkedCustomSiloOutstandingIdentifiers-Czdfe35L.mjs.map} +1 -1
- package/dist/{pullManualEnrichmentIdentifiersToCsv-Bg1P8r4K.mjs → pullManualEnrichmentIdentifiersToCsv-MCAxey_B.mjs} +2 -2
- package/dist/{pullManualEnrichmentIdentifiersToCsv-Bg1P8r4K.mjs.map → pullManualEnrichmentIdentifiersToCsv-MCAxey_B.mjs.map} +1 -1
- package/dist/pullTranscendConfiguration-BQCO6G7Z.mjs +58 -0
- package/dist/pullTranscendConfiguration-BQCO6G7Z.mjs.map +1 -0
- package/dist/{pushCronIdentifiersFromCsv-BJ_6eT7L.mjs → pushCronIdentifiersFromCsv-Bp93Ba9h.mjs} +2 -2
- package/dist/{pushCronIdentifiersFromCsv-BJ_6eT7L.mjs.map → pushCronIdentifiersFromCsv-Bp93Ba9h.mjs.map} +1 -1
- package/dist/{pushManualEnrichmentIdentifiersFromCsv-raZJbDoH.mjs → pushManualEnrichmentIdentifiersFromCsv-n1WyKiBi.mjs} +2 -2
- package/dist/{pushManualEnrichmentIdentifiersFromCsv-raZJbDoH.mjs.map → pushManualEnrichmentIdentifiersFromCsv-n1WyKiBi.mjs.map} +1 -1
- package/dist/{readTranscendYaml-B1FLjET0.mjs → readTranscendYaml-CVbI1N8S.mjs} +2 -2
- package/dist/{readTranscendYaml-B1FLjET0.mjs.map → readTranscendYaml-CVbI1N8S.mjs.map} +1 -1
- package/dist/{removeUnverifiedRequestIdentifiers-D4BS0YLI.mjs → removeUnverifiedRequestIdentifiers-CllBM6yg.mjs} +2 -2
- package/dist/{removeUnverifiedRequestIdentifiers-D4BS0YLI.mjs.map → removeUnverifiedRequestIdentifiers-CllBM6yg.mjs.map} +1 -1
- package/dist/{retryRequestDataSilos-CBxZHU59.mjs → retryRequestDataSilos-Bmh5RtDW.mjs} +2 -2
- package/dist/{retryRequestDataSilos-CBxZHU59.mjs.map → retryRequestDataSilos-Bmh5RtDW.mjs.map} +1 -1
- package/dist/{skipPreflightJobs-mqhLTi0f.mjs → skipPreflightJobs-5PcntUk7.mjs} +2 -2
- package/dist/{skipPreflightJobs-mqhLTi0f.mjs.map → skipPreflightJobs-5PcntUk7.mjs.map} +1 -1
- package/dist/{skipRequestDataSilos-8cK7x9K9.mjs → skipRequestDataSilos-GA77Dtwe.mjs} +2 -2
- package/dist/{skipRequestDataSilos-8cK7x9K9.mjs.map → skipRequestDataSilos-GA77Dtwe.mjs.map} +1 -1
- package/dist/{streamPrivacyRequestsToCsv-CaueBxWE.mjs → streamPrivacyRequestsToCsv-DgvBRjF-.mjs} +2 -2
- package/dist/{streamPrivacyRequestsToCsv-CaueBxWE.mjs.map → streamPrivacyRequestsToCsv-DgvBRjF-.mjs.map} +1 -1
- package/dist/{updateConsentManagerVersionToLatest-59LfKBYK.mjs → updateConsentManagerVersionToLatest-Db_3rBVb.mjs} +2 -2
- package/dist/{updateConsentManagerVersionToLatest-59LfKBYK.mjs.map → updateConsentManagerVersionToLatest-Db_3rBVb.mjs.map} +1 -1
- package/dist/{uploadConsents-CbPsjJ6G.mjs → uploadConsents-DYRO1JJQ.mjs} +2 -2
- package/dist/{uploadConsents-CbPsjJ6G.mjs.map → uploadConsents-DYRO1JJQ.mjs.map} +1 -1
- package/dist/{uploadCookiesFromCsv-DhDzLqvx.mjs → uploadCookiesFromCsv-D-b7vR50.mjs} +2 -2
- package/dist/{uploadCookiesFromCsv-DhDzLqvx.mjs.map → uploadCookiesFromCsv-D-b7vR50.mjs.map} +1 -1
- package/dist/{uploadDataFlowsFromCsv-Ca4JrvEd.mjs → uploadDataFlowsFromCsv-DSuBhPT4.mjs} +2 -2
- package/dist/{uploadDataFlowsFromCsv-Ca4JrvEd.mjs.map → uploadDataFlowsFromCsv-DSuBhPT4.mjs.map} +1 -1
- package/dist/{uploadPrivacyRequestsFromCsv-CprxpH-W.mjs → uploadPrivacyRequestsFromCsv-BcrzcKIL.mjs} +2 -2
- package/dist/{uploadPrivacyRequestsFromCsv-CprxpH-W.mjs.map → uploadPrivacyRequestsFromCsv-BcrzcKIL.mjs.map} +1 -1
- package/dist/{validateTranscendAuth-D14jsB5C.mjs → validateTranscendAuth-Bxc1ETtl.mjs} +2 -2
- package/dist/{validateTranscendAuth-D14jsB5C.mjs.map → validateTranscendAuth-Bxc1ETtl.mjs.map} +1 -1
- package/package.json +4 -4
- package/dist/codecs-_SjJhduF.mjs +0 -2
- package/dist/codecs-_SjJhduF.mjs.map +0 -1
- package/dist/pullTranscendConfiguration-BPkc-b3x.mjs +0 -58
- package/dist/pullTranscendConfiguration-BPkc-b3x.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullChunkedCustomSiloOutstandingIdentifiers-qZCnzDXQ.mjs","names":[],"sources":["../src/lib/graphql/fetchRequestDataSiloActiveCount.ts","../src/lib/cron/pullCronPageOfIdentifiers.ts","../src/lib/cron/pullChunkedCustomSiloOutstandingIdentifiers.ts"],"sourcesContent":["import { makeGraphQLRequest, REDUCED_REQUESTS_FOR_DATA_SILO_COUNT } from '@transcend-io/sdk';\nimport { GraphQLClient } from 'graphql-request';\n\nimport { logger } from '../../logger.js';\n\n/**\n * Get number of open requests for a data silo\n *\n * @param client - GraphQL client\n * @param options - Filter options\n * @returns List of request identifiers\n */\nexport async function fetchRequestDataSiloActiveCount(\n client: GraphQLClient,\n {\n dataSiloId,\n }: {\n /** Data silo ID */\n dataSiloId: string;\n },\n): Promise<number> {\n const {\n listReducedRequestsForDataSilo: { totalCount },\n } = await makeGraphQLRequest<{\n /** Requests */\n listReducedRequestsForDataSilo: {\n /** Total count */\n totalCount: number;\n };\n }>(client, REDUCED_REQUESTS_FOR_DATA_SILO_COUNT, {\n variables: {\n input: {\n dataSiloId,\n isResolved: false,\n },\n },\n logger,\n });\n\n return totalCount;\n}\n","import { RequestAction } from '@transcend-io/privacy-types';\nimport { withTransientRetry } from '@transcend-io/sdk';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport type { Got } from 'got';\nimport * as t from 'io-ts';\n\nimport { logger } from '../../logger.js';\n\n/** Consent partition metadata when a DSR is scoped to a partition */\nexport const CronPartition = t.type({\n /** ID of the partition */\n id: t.string,\n /** The human readable name of the partition */\n name: t.string,\n /** The unique identifying partition value */\n partition: t.string,\n});\n\n/** Type override */\nexport type CronPartition = t.TypeOf<typeof CronPartition>;\n\nexport const CronIdentifier = t.intersection([\n t.type({\n /** The identifier value */\n identifier: t.string,\n /** The type of identifier */\n type: t.string,\n /** The core identifier of the request */\n coreIdentifier: t.string,\n /** The ID of the underlying data silo */\n dataSiloId: t.string,\n /** The ID of the underlying request */\n requestId: t.string,\n /** The request nonce */\n nonce: t.string,\n /** The time the request was created */\n requestCreatedAt: t.string,\n /** The number of days until the request is overdue */\n daysUntilOverdue: t.number,\n /** Request attributes */\n attributes: t.array(\n t.type({\n key: t.string,\n values: t.array(t.string),\n }),\n ),\n }),\n t.partial({\n /** The consent partition that scopes this request, when applicable */\n partition: t.union([CronPartition, t.null]),\n }),\n]);\n\n/** Type override */\nexport type CronIdentifier = t.TypeOf<typeof CronIdentifier>;\n\n/**\n * Pull a offset of identifiers for a cron job\n *\n * @see https://docs.transcend.io/docs/api-reference/GET/v1/data-silo/(id)/pending-requests/(type)\n * @param sombra - Sombra instance configured to make requests\n * @param options - Additional options\n * @returns Successfully submitted request\n */\nexport async function pullCronPageOfIdentifiers(\n sombra: Got,\n {\n dataSiloId,\n limit = 100,\n offset = 0,\n requestType,\n }: {\n /** Data Silo ID */\n dataSiloId: string;\n /** Type of request */\n requestType: RequestAction;\n /** Number of identifiers to pull in */\n limit?: number;\n /** Page to pull in */\n offset?: number;\n },\n): Promise<CronIdentifier[]> {\n try {\n // `GET pending-requests` is a read and therefore safe to retry on transient\n // gateway / network errors. Customers running `transcend cron\n // pull-identifiers` against large silos would otherwise see the command\n // abort on a single 502 from the Sombra reverse tunnel.\n const response = await withTransientRetry(\n 'pullCronPageOfIdentifiers',\n () =>\n sombra\n .get(`v1/data-silo/${dataSiloId}/pending-requests/${requestType}`, {\n searchParams: {\n offset,\n limit,\n },\n })\n .json(),\n { logger, maxAttempts: 6, baseDelayMs: 500 },\n );\n\n const { items } = decodeCodec(\n t.type({\n items: t.array(CronIdentifier),\n }),\n response,\n );\n return items;\n } catch (err) {\n throw new Error(`Received an error from server: ${err?.response?.body || err?.message}`);\n }\n}\n","import { RequestAction } from '@transcend-io/privacy-types';\nimport { buildTranscendGraphQLClient, createSombraGotInstance } from '@transcend-io/sdk';\nimport { mapSeries } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { fetchRequestDataSiloActiveCount } from '../graphql/index.js';\nimport { pullCronPageOfIdentifiers, CronIdentifier } from './pullCronPageOfIdentifiers.js';\n\n/**\n * A CSV formatted identifier\n */\nexport type CsvFormattedIdentifier = {\n [k in string]: string | null | boolean | number;\n};\n\nexport interface CronIdentifierWithAction extends CronIdentifier {\n /** The request action that the identifier relates to */\n action: RequestAction;\n}\n\n/**\n * Pull the set of identifiers outstanding for a cron or AVC integration\n *\n * This function is designed to be used in a loop, and will call the onSave callback\n * with a chunk of identifiers when the savePageSize is reached.\n *\n * @param options - Options\n * @returns The identifiers and identifiers formatted for CSV\n */\nexport async function pullChunkedCustomSiloOutstandingIdentifiers({\n dataSiloId,\n auth,\n sombraAuth,\n actions,\n apiPageSize = 100,\n savePageSize = 1000,\n onSave,\n transcendUrl = DEFAULT_TRANSCEND_API,\n skipRequestCount = false,\n}: {\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** The request actions to fetch */\n actions: RequestAction[];\n /** How many identifiers to pull in a single call to the backend */\n apiPageSize: number;\n /** How many identifiers to save at a time (usually to a CSV file, should be a multiple of apiPageSize) */\n savePageSize: number;\n /** Callback function called when a chunk of identifiers is ready to be saved */\n onSave: (chunk: CsvFormattedIdentifier[]) => Promise<void>;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Skip request count */\n skipRequestCount?: boolean;\n}): Promise<{\n /** Raw Identifiers */\n identifiers: CronIdentifierWithAction[];\n}> {\n // Validate savePageSize\n if (savePageSize % apiPageSize !== 0) {\n throw new Error(\n `savePageSize must be a multiple of apiPageSize. savePageSize: ${savePageSize}, apiPageSize: ${apiPageSize}`,\n );\n }\n\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n // Create GraphQL client to connect to Transcend backend\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n let totalRequestCount = 0;\n if (!skipRequestCount) {\n totalRequestCount = await fetchRequestDataSiloActiveCount(client, {\n dataSiloId,\n });\n }\n\n logger.info(\n colors.magenta(\n `Pulling ${skipRequestCount ? 'all' : totalRequestCount} outstanding request identifiers ` +\n `for data silo: \"${dataSiloId}\" for requests of types \"${actions.join('\", \"')}\"`,\n ),\n );\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n const foundRequestIds = new Set<string>();\n\n // identifiers found in total\n const identifiers: CronIdentifierWithAction[] = [];\n // current chunk of identifiers to be saved\n let currentChunk: CsvFormattedIdentifier[] = [];\n\n // map over each action\n if (!skipRequestCount) {\n progressBar.start(totalRequestCount, 0);\n }\n await mapSeries(actions, async (action) => {\n let offset = 0;\n let shouldContinue = true;\n\n // Fetch a page of identifiers\n while (shouldContinue) {\n const pageIdentifiers = await pullCronPageOfIdentifiers(sombra, {\n dataSiloId,\n limit: apiPageSize,\n offset,\n requestType: action,\n });\n\n const identifiersWithAction: CronIdentifierWithAction[] = pageIdentifiers.map(\n (identifier) => {\n foundRequestIds.add(identifier.requestId);\n return {\n ...identifier,\n action,\n };\n },\n );\n\n const csvFormattedIdentifiers = identifiersWithAction.map(\n ({ attributes, partition, ...identifier }) => ({\n ...identifier,\n ...(partition\n ? {\n partitionId: partition.id,\n partitionName: partition.name,\n partitionKey: partition.partition,\n }\n : {}),\n ...attributes.reduce(\n (acc, val) =>\n Object.assign(acc, {\n [val.key]: val.values.join(','),\n }),\n {},\n ),\n }),\n );\n\n identifiers.push(...identifiersWithAction);\n currentChunk.push(...csvFormattedIdentifiers);\n\n // Check if we've reached the savePageSize and call the onSave callback\n if (currentChunk.length >= savePageSize) {\n await onSave(currentChunk);\n currentChunk = [];\n }\n\n shouldContinue = pageIdentifiers.length === apiPageSize;\n offset += apiPageSize;\n if (!skipRequestCount) {\n progressBar.update(foundRequestIds.size);\n } else {\n logger.info(\n colors.magenta(\n `Pulled ${pageIdentifiers.length} outstanding identifiers for ${foundRequestIds.size} requests`,\n ),\n );\n }\n }\n });\n\n // Save any remaining identifiers in the current chunk\n if (currentChunk.length > 0) {\n await onSave(currentChunk);\n }\n\n if (!skipRequestCount) {\n progressBar.stop();\n }\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully pulled ${identifiers.length} outstanding identifiers from ${\n foundRequestIds.size\n } requests in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n\n return { identifiers };\n}\n"],"mappings":"0bAYA,eAAsB,EACpB,EACA,CACE,cAKe,CACjB,GAAM,CACJ,+BAAgC,CAAE,eAChC,MAAM,EAMP,EAAQ,EAAsC,CAC/C,UAAW,CACT,MAAO,CACL,aACA,WAAY,GACb,CACF,CACD,SACD,CAAC,CAEF,OAAO,EC9BT,MAAa,EAAgB,EAAE,KAAK,CAElC,GAAI,EAAE,OAEN,KAAM,EAAE,OAER,UAAW,EAAE,OACd,CAAC,CAKW,EAAiB,EAAE,aAAa,CAC3C,EAAE,KAAK,CAEL,WAAY,EAAE,OAEd,KAAM,EAAE,OAER,eAAgB,EAAE,OAElB,WAAY,EAAE,OAEd,UAAW,EAAE,OAEb,MAAO,EAAE,OAET,iBAAkB,EAAE,OAEpB,iBAAkB,EAAE,OAEpB,WAAY,EAAE,MACZ,EAAE,KAAK,CACL,IAAK,EAAE,OACP,OAAQ,EAAE,MAAM,EAAE,OAAO,CAC1B,CAAC,CACH,CACF,CAAC,CACF,EAAE,QAAQ,CAER,UAAW,EAAE,MAAM,CAAC,EA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O,GAAgB,CACrB,IAAM,EAAkB,MAAM,EAA0B,EAAQ,CAC9D,aACA,MAAO,EACP,SACA,YAAa,EACd,CAAC,CAEI,EAAoD,EAAgB,IACvE,IACC,EAAgB,IAAI,EAAW,UAAU,CAClC,CACL,GAAG,EACH,SACD,EAEJ,CAEK,EAA0B,EAAsB,KACnD,CAAE,aAAY,YAAW,GAAG,MAAkB,CAC7C,GAAG,EACH,GAAI,EACA,CACE,YAAa,EAAU,GACvB,cAAe,EAAU,KACzB,aAAc,EAAU,UACzB,CACD,EAAE,CACN,GAAG,EAAW,QACX,EAAK,IACJ,OAAO,OAAO,EAAK,EAChB,EAAI,KAAM,EAAI,OAAO,KAAK,IAAI,CAChC,CAAC,CACJ,EAAE,CACH,CACF,EACF,CAED,EAAY,KAAK,GAAG,EAAsB,CAC1C,EAAa,KAAK,GAAG,EAAwB,CAGzC,EAAa,QAAU,IACzB,MAAM,EAAO,EAAa,CAC1B,EAAe,EAAE,EAGnB,EAAiB,EAAgB,SAAW,EAC5C,GAAU,EACL,EAGH,EAAO,KACL,EAAO,QACL,UAAU,EAAgB,OAAO,+BAA+B,EAAgB,KAAK,WACtF,CACF,CAND,EAAY,OAAO,EAAgB,KAAK,GAS5C,CAGE,EAAa,OAAS,GACxB,MAAM,EAAO,EAAa,CAGvB,GACH,EAAY,MAAM,CAGpB,IAAM,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EAUvB,OARA,EAAO,KACL,EAAO,MACL,uBAAuB,EAAY,OAAO,gCACxC,EAAgB,KACjB,gBAAgB,EAAY,IAAK,YACnC,CACF,CAEM,CAAE,cAAa"}
|
|
1
|
+
{"version":3,"file":"pullChunkedCustomSiloOutstandingIdentifiers-Czdfe35L.mjs","names":[],"sources":["../src/lib/graphql/fetchRequestDataSiloActiveCount.ts","../src/lib/cron/pullCronPageOfIdentifiers.ts","../src/lib/cron/pullChunkedCustomSiloOutstandingIdentifiers.ts"],"sourcesContent":["import { makeGraphQLRequest, REDUCED_REQUESTS_FOR_DATA_SILO_COUNT } from '@transcend-io/sdk';\nimport { GraphQLClient } from 'graphql-request';\n\nimport { logger } from '../../logger.js';\n\n/**\n * Get number of open requests for a data silo\n *\n * @param client - GraphQL client\n * @param options - Filter options\n * @returns List of request identifiers\n */\nexport async function fetchRequestDataSiloActiveCount(\n client: GraphQLClient,\n {\n dataSiloId,\n }: {\n /** Data silo ID */\n dataSiloId: string;\n },\n): Promise<number> {\n const {\n listReducedRequestsForDataSilo: { totalCount },\n } = await makeGraphQLRequest<{\n /** Requests */\n listReducedRequestsForDataSilo: {\n /** Total count */\n totalCount: number;\n };\n }>(client, REDUCED_REQUESTS_FOR_DATA_SILO_COUNT, {\n variables: {\n input: {\n dataSiloId,\n isResolved: false,\n },\n },\n logger,\n });\n\n return totalCount;\n}\n","import { RequestAction } from '@transcend-io/privacy-types';\nimport { withTransientRetry } from '@transcend-io/sdk';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport type { Got } from 'got';\nimport * as t from 'io-ts';\n\nimport { logger } from '../../logger.js';\n\n/** Consent partition metadata when a DSR is scoped to a partition */\nexport const CronPartition = t.type({\n /** ID of the partition */\n id: t.string,\n /** The human readable name of the partition */\n name: t.string,\n /** The unique identifying partition value */\n partition: t.string,\n});\n\n/** Type override */\nexport type CronPartition = t.TypeOf<typeof CronPartition>;\n\nexport const CronIdentifier = t.intersection([\n t.type({\n /** The identifier value */\n identifier: t.string,\n /** The type of identifier */\n type: t.string,\n /** The core identifier of the request */\n coreIdentifier: t.string,\n /** The ID of the underlying data silo */\n dataSiloId: t.string,\n /** The ID of the underlying request */\n requestId: t.string,\n /** The request nonce */\n nonce: t.string,\n /** The time the request was created */\n requestCreatedAt: t.string,\n /** The number of days until the request is overdue */\n daysUntilOverdue: t.number,\n /** Request attributes */\n attributes: t.array(\n t.type({\n key: t.string,\n values: t.array(t.string),\n }),\n ),\n }),\n t.partial({\n /** The consent partition that scopes this request, when applicable */\n partition: t.union([CronPartition, t.null]),\n }),\n]);\n\n/** Type override */\nexport type CronIdentifier = t.TypeOf<typeof CronIdentifier>;\n\n/**\n * Pull a offset of identifiers for a cron job\n *\n * @see https://docs.transcend.io/docs/api-reference/GET/v1/data-silo/(id)/pending-requests/(type)\n * @param sombra - Sombra instance configured to make requests\n * @param options - Additional options\n * @returns Successfully submitted request\n */\nexport async function pullCronPageOfIdentifiers(\n sombra: Got,\n {\n dataSiloId,\n limit = 100,\n offset = 0,\n requestType,\n }: {\n /** Data Silo ID */\n dataSiloId: string;\n /** Type of request */\n requestType: RequestAction;\n /** Number of identifiers to pull in */\n limit?: number;\n /** Page to pull in */\n offset?: number;\n },\n): Promise<CronIdentifier[]> {\n try {\n // `GET pending-requests` is a read and therefore safe to retry on transient\n // gateway / network errors. Customers running `transcend cron\n // pull-identifiers` against large silos would otherwise see the command\n // abort on a single 502 from the Sombra reverse tunnel.\n const response = await withTransientRetry(\n 'pullCronPageOfIdentifiers',\n () =>\n sombra\n .get(`v1/data-silo/${dataSiloId}/pending-requests/${requestType}`, {\n searchParams: {\n offset,\n limit,\n },\n })\n .json(),\n { logger, maxAttempts: 6, baseDelayMs: 500 },\n );\n\n const { items } = decodeCodec(\n t.type({\n items: t.array(CronIdentifier),\n }),\n response,\n );\n return items;\n } catch (err) {\n throw new Error(`Received an error from server: ${err?.response?.body || err?.message}`);\n }\n}\n","import { RequestAction } from '@transcend-io/privacy-types';\nimport { buildTranscendGraphQLClient, createSombraGotInstance } from '@transcend-io/sdk';\nimport { mapSeries } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { fetchRequestDataSiloActiveCount } from '../graphql/index.js';\nimport { pullCronPageOfIdentifiers, CronIdentifier } from './pullCronPageOfIdentifiers.js';\n\n/**\n * A CSV formatted identifier\n */\nexport type CsvFormattedIdentifier = {\n [k in string]: string | null | boolean | number;\n};\n\nexport interface CronIdentifierWithAction extends CronIdentifier {\n /** The request action that the identifier relates to */\n action: RequestAction;\n}\n\n/**\n * Pull the set of identifiers outstanding for a cron or AVC integration\n *\n * This function is designed to be used in a loop, and will call the onSave callback\n * with a chunk of identifiers when the savePageSize is reached.\n *\n * @param options - Options\n * @returns The identifiers and identifiers formatted for CSV\n */\nexport async function pullChunkedCustomSiloOutstandingIdentifiers({\n dataSiloId,\n auth,\n sombraAuth,\n actions,\n apiPageSize = 100,\n savePageSize = 1000,\n onSave,\n transcendUrl = DEFAULT_TRANSCEND_API,\n skipRequestCount = false,\n}: {\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** The request actions to fetch */\n actions: RequestAction[];\n /** How many identifiers to pull in a single call to the backend */\n apiPageSize: number;\n /** How many identifiers to save at a time (usually to a CSV file, should be a multiple of apiPageSize) */\n savePageSize: number;\n /** Callback function called when a chunk of identifiers is ready to be saved */\n onSave: (chunk: CsvFormattedIdentifier[]) => Promise<void>;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Skip request count */\n skipRequestCount?: boolean;\n}): Promise<{\n /** Raw Identifiers */\n identifiers: CronIdentifierWithAction[];\n}> {\n // Validate savePageSize\n if (savePageSize % apiPageSize !== 0) {\n throw new Error(\n `savePageSize must be a multiple of apiPageSize. savePageSize: ${savePageSize}, apiPageSize: ${apiPageSize}`,\n );\n }\n\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n // Create GraphQL client to connect to Transcend backend\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n let totalRequestCount = 0;\n if (!skipRequestCount) {\n totalRequestCount = await fetchRequestDataSiloActiveCount(client, {\n dataSiloId,\n });\n }\n\n logger.info(\n colors.magenta(\n `Pulling ${skipRequestCount ? 'all' : totalRequestCount} outstanding request identifiers ` +\n `for data silo: \"${dataSiloId}\" for requests of types \"${actions.join('\", \"')}\"`,\n ),\n );\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n const foundRequestIds = new Set<string>();\n\n // identifiers found in total\n const identifiers: CronIdentifierWithAction[] = [];\n // current chunk of identifiers to be saved\n let currentChunk: CsvFormattedIdentifier[] = [];\n\n // map over each action\n if (!skipRequestCount) {\n progressBar.start(totalRequestCount, 0);\n }\n await mapSeries(actions, async (action) => {\n let offset = 0;\n let shouldContinue = true;\n\n // Fetch a page of identifiers\n while (shouldContinue) {\n const pageIdentifiers = await pullCronPageOfIdentifiers(sombra, {\n dataSiloId,\n limit: apiPageSize,\n offset,\n requestType: action,\n });\n\n const identifiersWithAction: CronIdentifierWithAction[] = pageIdentifiers.map(\n (identifier) => {\n foundRequestIds.add(identifier.requestId);\n return {\n ...identifier,\n action,\n };\n },\n );\n\n const csvFormattedIdentifiers = identifiersWithAction.map(\n ({ attributes, partition, ...identifier }) => ({\n ...identifier,\n ...(partition\n ? {\n partitionId: partition.id,\n partitionName: partition.name,\n partitionKey: partition.partition,\n }\n : {}),\n ...attributes.reduce(\n (acc, val) =>\n Object.assign(acc, {\n [val.key]: val.values.join(','),\n }),\n {},\n ),\n }),\n );\n\n identifiers.push(...identifiersWithAction);\n currentChunk.push(...csvFormattedIdentifiers);\n\n // Check if we've reached the savePageSize and call the onSave callback\n if (currentChunk.length >= savePageSize) {\n await onSave(currentChunk);\n currentChunk = [];\n }\n\n shouldContinue = pageIdentifiers.length === apiPageSize;\n offset += apiPageSize;\n if (!skipRequestCount) {\n progressBar.update(foundRequestIds.size);\n } else {\n logger.info(\n colors.magenta(\n `Pulled ${pageIdentifiers.length} outstanding identifiers for ${foundRequestIds.size} requests`,\n ),\n );\n }\n }\n });\n\n // Save any remaining identifiers in the current chunk\n if (currentChunk.length > 0) {\n await onSave(currentChunk);\n }\n\n if (!skipRequestCount) {\n progressBar.stop();\n }\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully pulled ${identifiers.length} outstanding identifiers from ${\n foundRequestIds.size\n } requests in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n\n return { identifiers };\n}\n"],"mappings":"0bAYA,eAAsB,EACpB,EACA,CACE,cAKe,CACjB,GAAM,CACJ,+BAAgC,CAAE,eAChC,MAAM,EAMP,EAAQ,EAAsC,CAC/C,UAAW,CACT,MAAO,CACL,aACA,WAAY,GACb,CACF,CACD,SACD,CAAC,CAEF,OAAO,EC9BT,MAAa,EAAgB,EAAE,KAAK,CAElC,GAAI,EAAE,OAEN,KAAM,EAAE,OAER,UAAW,EAAE,OACd,CAAC,CAKW,EAAiB,EAAE,aAAa,CAC3C,EAAE,KAAK,CAEL,WAAY,EAAE,OAEd,KAAM,EAAE,OAER,eAAgB,EAAE,OAElB,WAAY,EAAE,OAEd,UAAW,EAAE,OAEb,MAAO,EAAE,OAET,iBAAkB,EAAE,OAEpB,iBAAkB,EAAE,OAEpB,WAAY,EAAE,MACZ,EAAE,KAAK,CACL,IAAK,EAAE,OACP,OAAQ,EAAE,MAAM,EAAE,OAAO,CAC1B,CAAC,CACH,CACF,CAAC,CACF,EAAE,QAAQ,CAER,UAAW,EAAE,MAAM,CAAC,EAAe,EAAE,KAAK,CAAC,CAC5C,CAAC,CACH,CAAC,CAaF,eAAsB,EACpB,EACA,CACE,aACA,QAAQ,IACR,SAAS,EACT,eAWyB,CAC3B,GAAI,CAKF,IAAM,EAAW,MAAM,EACrB,gCAEE,EACG,IAAI,gBAAgB,EAAW,oBAAoB,IAAe,CACjE,aAAc,CACZ,SACA,QACD,CACF,CAAC,CACD,MAAM,CACX,CAAE,SAAQ,YAAa,EAAG,YAAa,IAAK,CAC7C,CAEK,CAAE,SAAU,EAChB,EAAE,KAAK,CACL,MAAO,EAAE,MAAM,EAAe,CAC/B,CAAC,CACF,EACD,CACD,OAAO,QACA,E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,KAAM,EAAI,OAAO,KAAK,IAAI,CAChC,CAAC,CACJ,EAAE,CACH,CACF,EACF,CAED,EAAY,KAAK,GAAG,EAAsB,CAC1C,EAAa,KAAK,GAAG,EAAwB,CAGzC,EAAa,QAAU,IACzB,MAAM,EAAO,EAAa,CAC1B,EAAe,EAAE,EAGnB,EAAiB,EAAgB,SAAW,EAC5C,GAAU,EACL,EAGH,EAAO,KACL,EAAO,QACL,UAAU,EAAgB,OAAO,+BAA+B,EAAgB,KAAK,WACtF,CACF,CAND,EAAY,OAAO,EAAgB,KAAK,GAS5C,CAGE,EAAa,OAAS,GACxB,MAAM,EAAO,EAAa,CAGvB,GACH,EAAY,MAAM,CAGpB,IAAM,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EAUvB,OARA,EAAO,KACL,EAAO,MACL,uBAAuB,EAAY,OAAO,gCACxC,EAAgB,KACjB,gBAAgB,EAAY,IAAK,YACnC,CACF,CAEM,CAAE,cAAa"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./constants-
|
|
2
|
-
//# sourceMappingURL=pullManualEnrichmentIdentifiersToCsv-
|
|
1
|
+
import{a as e}from"./constants-CgI8_Rfc.mjs";import{t}from"./logger-B-LXIf3U.mjs";import{r as n}from"./fetchAllRequests-BCHpCeFo.mjs";import{a as r}from"./writeCsv-DDKM_rAU.mjs";import{RequestStatus as i}from"@transcend-io/privacy-types";import{groupBy as a,uniq as o}from"lodash-es";import s from"colors";import{buildTranscendGraphQLClient as c,createSombraGotInstance as l,fetchAllRequestEnrichers as u,fetchAllRequestIdentifiers as d,validateSombraVersion as f}from"@transcend-io/sdk";import{map as p}from"@transcend-io/utils";async function m({file:m,auth:h,sombraAuth:g,requestActions:_=[],concurrency:v=100,transcendUrl:y=e}){let b=c(y,h),x=await l(y,h,{logger:t,sombraApiKey:g,sombraUrl:process.env.SOMBRA_URL});t.info(s.magenta(`Pulling manual enrichment requests, filtered for actions: ${_.join(`,`)}`));let S=await n(b,{actions:_,statuses:[i.Enriching]});await f(b,{logger:t});let C=[];await p(S,async e=>{let n=await u(b,{filterBy:{requestId:e.id},logger:t});if(n.filter(({status:e})=>e===`ACTION_REQUIRED`)){let r=await d(b,x,{filterBy:{requestId:e.id},skipSombraCheck:!0,logger:t});C.push({...e,requestIdentifiers:r,requestEnrichers:n})}},{concurrency:v});let w=C.map(({attributeValues:e,requestIdentifiers:t,requestEnrichers:n,...r})=>({...r,...Object.entries(a(t,`name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({value:e})=>e).join(`,`)}),{}),...Object.entries(a(e,`attributeKey.name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({name:e})=>e).join(`,`)}),{})}));return await r(m,w,o(w.map(e=>Object.keys(e)).flat())),t.info(s.green(`Successfully wrote ${C.length} requests to file "${m}"`)),C}export{m as t};
|
|
2
|
+
//# sourceMappingURL=pullManualEnrichmentIdentifiersToCsv-MCAxey_B.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullManualEnrichmentIdentifiersToCsv-
|
|
1
|
+
{"version":3,"file":"pullManualEnrichmentIdentifiersToCsv-MCAxey_B.mjs","names":[],"sources":["../src/lib/manual-enrichment/pullManualEnrichmentIdentifiersToCsv.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllRequestEnrichers,\n fetchAllRequestIdentifiers,\n validateSombraVersion,\n type RequestEnricher,\n type RequestIdentifier,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport colors from 'colors';\nimport { groupBy, uniq } from 'lodash-es';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { type PrivacyRequest, fetchAllRequests } from '../graphql/index.js';\nimport { writeCsv } from '../helpers/writeCsv.js';\n\nexport interface PrivacyRequestWithIdentifiers extends PrivacyRequest {\n /** Request Enrichers */\n requestEnrichers: RequestEnricher[];\n /** Request Identifiers */\n requestIdentifiers: RequestIdentifier[];\n}\n\n/**\n * Pull the set of manual enrichment jobs to CSV\n *\n * @param options - Options\n * @returns List of requests with identifiers\n */\nexport async function pullManualEnrichmentIdentifiersToCsv({\n file,\n auth,\n sombraAuth,\n requestActions = [],\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** CSV file path */\n file: string;\n /** Transcend API key authentication */\n auth: string;\n /** Sombra API key */\n sombraAuth?: string;\n /** Concurrency */\n concurrency?: number;\n /** The request actions to fetch */\n requestActions?: RequestAction[];\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<PrivacyRequestWithIdentifiers[]> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n logger.info(\n colors.magenta(\n `Pulling manual enrichment requests, filtered for actions: ${requestActions.join(',')}`,\n ),\n );\n\n // Pull all privacy requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses: [RequestStatus.Enriching],\n });\n\n await validateSombraVersion(client, { logger });\n\n // Requests to save\n const savedRequests: PrivacyRequestWithIdentifiers[] = [];\n\n // Filter down requests to what is needed\n await map(\n allRequests,\n async (request) => {\n // Fetch enrichers\n const requestEnrichers = await fetchAllRequestEnrichers(client, {\n filterBy: { requestId: request.id },\n logger,\n });\n\n // Check if manual enrichment exists for that request\n const hasManualEnrichment = requestEnrichers.filter(\n ({ status }) => status === 'ACTION_REQUIRED',\n );\n\n // Save request to queue\n if (hasManualEnrichment) {\n const requestIdentifiers = await fetchAllRequestIdentifiers(client, sombra, {\n filterBy: { requestId: request.id },\n skipSombraCheck: true,\n logger,\n });\n savedRequests.push({\n ...request,\n requestIdentifiers,\n requestEnrichers,\n });\n }\n },\n {\n concurrency,\n },\n );\n\n const data = savedRequests.map(\n ({\n attributeValues,\n requestIdentifiers,\n requestEnrichers, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...request\n }) => ({\n ...request,\n // flatten identifiers\n ...Object.entries(groupBy(requestIdentifiers, 'name')).reduce(\n (acc, [key, values]) =>\n Object.assign(acc, {\n [key]: values.map(({ value }) => value).join(','),\n }),\n {},\n ),\n // flatten attributes\n ...Object.entries(groupBy(attributeValues, 'attributeKey.name')).reduce(\n (acc, [key, values]) =>\n Object.assign(acc, {\n [key]: values.map(({ name }) => name).join(','),\n }),\n {},\n ),\n }),\n );\n\n // Write out to CSV\n const headers = uniq(data.map((d) => Object.keys(d)).flat());\n await writeCsv(file, data, headers);\n\n logger.info(\n colors.green(`Successfully wrote ${savedRequests.length} requests to file \"${file}\"`),\n );\n\n return savedRequests;\n}\n"],"mappings":"khBAgCA,eAAsB,EAAqC,CACzD,OACA,OACA,aACA,iBAAiB,EAAE,CACnB,cAAc,IACd,eAAe,GAc4B,CAE3C,IAAM,EAAS,EAA4B,EAAc,EAAK,CACxD,EAAS,MAAM,EAAwB,EAAc,EAAM,CAC/D,SACA,aAAc,EACd,UAAW,QAAQ,IAAI,WACxB,CAAC,CAEF,EAAO,KACL,EAAO,QACL,6DAA6D,EAAe,KAAK,IAAI,GACtF,CACF,CAGD,IAAM,EAAc,MAAM,EAAiB,EAAQ,CACjD,QAAS,EACT,SAAU,CAAC,EAAc,UAAU,CACpC,CAAC,CAEF,MAAM,EAAsB,EAAQ,CAAE,SAAQ,CAAC,CAG/C,IAAM,EAAiD,EAAE,CAGzD,MAAM,EACJ,EACA,KAAO,IAAY,CAEjB,IAAM,EAAmB,MAAM,EAAyB,EAAQ,CAC9D,SAAU,CAAE,UAAW,EAAQ,GAAI,CACnC,SACD,CAAC,CAQF,GAL4B,EAAiB,QAC1C,CAAE,YAAa,IAAW,kBAIN,CAAE,CACvB,IAAM,EAAqB,MAAM,EAA2B,EAAQ,EAAQ,CAC1E,SAAU,CAAE,UAAW,EAAQ,GAAI,CACnC,gBAAiB,GACjB,SACD,CAAC,CACF,EAAc,KAAK,CACjB,GAAG,EACH,qBACA,mBACD,CAAC,GAGN,CACE,cACD,CACF,CAED,IAAM,EAAO,EAAc,KACxB,CACC,kBACA,qBACA,mBACA,GAAG,MACE,CACL,GAAG,EAEH,GAAG,OAAO,QAAQ,EAAQ,EAAoB,OAAO,CAAC,CAAC,QACpD,EAAK,CAAC,EAAK,KACV,OAAO,OAAO,EAAK,EAChB,GAAM,EAAO,KAAK,CAAE,WAAY,EAAM,CAAC,KAAK,IAAI,CAClD,CAAC,CACJ,EAAE,CACH,CAED,GAAG,OAAO,QAAQ,EAAQ,EAAiB,oBAAoB,CAAC,CAAC,QAC9D,EAAK,CAAC,EAAK,KACV,OAAO,OAAO,EAAK,EAChB,GAAM,EAAO,KAAK,CAAE,UAAW,EAAK,CAAC,KAAK,IAAI,CAChD,CAAC,CACJ,EAAE,CACH,CACF,EACF,CAUD,OANA,MAAM,EAAS,EAAM,EADL,EAAK,EAAK,IAAK,GAAM,OAAO,KAAK,EAAE,CAAC,CAAC,MAAM,CACzB,CAAC,CAEnC,EAAO,KACL,EAAO,MAAM,sBAAsB,EAAc,OAAO,qBAAqB,EAAK,GAAG,CACtF,CAEM"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import"./enums-BymyVyqr.mjs";import{t as e}from"./logger-B-LXIf3U.mjs";import{ActionItemCode as t,ConsentTrackerStatus as n,PreferenceTopicType as r,RequestAction as i,RetentionType as a,WorkflowConfigType as o}from"@transcend-io/privacy-types";import{flatten as s,groupBy as c,keyBy as l,mapValues as u}from"lodash-es";import d from"colors";import{ASSESSMENT_SECTION_FIELDS as f,convertToDataSubjectAllowlist as p,fetchAllActionItemCollections as m,fetchAllActionItems as h,fetchAllActions as g,fetchAllAgentFiles as _,fetchAllAgentFunctions as v,fetchAllAgents as y,fetchAllAssessments as b,fetchAllAttributes as x,fetchAllBusinessEntities as S,fetchAllConsentWorkflowTriggers as C,fetchAllCookies as w,fetchAllDataCategories as T,fetchAllDataFlows as E,fetchAllDataSubjects as D,fetchAllEnrichers as O,fetchAllIdentifiers as k,fetchAllMessages as ee,fetchAllPolicies as te,fetchAllPreferenceOptionValues as ne,fetchAllPrivacyCenters as re,fetchAllProcessingActivities as ie,fetchAllProcessingPurposes as ae,fetchAllPromptGroups as oe,fetchAllPromptPartials as se,fetchAllPrompts as ce,fetchAllPurposesAndPreferences as le,fetchAllSiloDiscoveryResults as ue,fetchAllTeams as de,fetchAllTemplates as fe,fetchAllVendors as pe,fetchAllWorkflowConfigs as A,fetchApiKeys as me,fetchConsentManager as he,fetchConsentManagerExperiences as ge,fetchConsentManagerTheme as _e,fetchConsentThemes as ve,fetchConsentVariants as ye,fetchEnrichedDataSilos as be,fetchPartitions as xe,formatAttributeValues as j,formatRegions as M,makeGraphQLRequest as N,parseAssessmentDisplayLogic as P,parseAssessmentRiskLogic as F,parsePurposesFromTriggerCondition as Se,resolveWorkflowTitleFromId as Ce,workflowConfigMatchKey as we}from"@transcend-io/sdk";import{gql as I}from"graphql-request";const L=I`
|
|
2
|
+
query TranscendCliAssessmentTemplates(
|
|
3
|
+
$first: Int!
|
|
4
|
+
$offset: Int!
|
|
5
|
+
$filterBy: AssessmentFormTemplateFiltersInput
|
|
6
|
+
) {
|
|
7
|
+
assessmentFormTemplates(
|
|
8
|
+
first: $first
|
|
9
|
+
offset: $offset
|
|
10
|
+
filterBy: $filterBy
|
|
11
|
+
) {
|
|
12
|
+
nodes {
|
|
13
|
+
id
|
|
14
|
+
creator {
|
|
15
|
+
id
|
|
16
|
+
email
|
|
17
|
+
name
|
|
18
|
+
}
|
|
19
|
+
lastEditor {
|
|
20
|
+
id
|
|
21
|
+
email
|
|
22
|
+
name
|
|
23
|
+
}
|
|
24
|
+
title
|
|
25
|
+
description
|
|
26
|
+
status
|
|
27
|
+
source
|
|
28
|
+
parentId
|
|
29
|
+
isLocked
|
|
30
|
+
isArchived
|
|
31
|
+
createdAt
|
|
32
|
+
updatedAt
|
|
33
|
+
retentionSchedule {
|
|
34
|
+
id
|
|
35
|
+
type
|
|
36
|
+
durationDays
|
|
37
|
+
operation
|
|
38
|
+
createdAt
|
|
39
|
+
updatedAt
|
|
40
|
+
}
|
|
41
|
+
assessmentEmailSet {
|
|
42
|
+
id
|
|
43
|
+
title
|
|
44
|
+
description
|
|
45
|
+
isDefault
|
|
46
|
+
templates {
|
|
47
|
+
id
|
|
48
|
+
title
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
sections {
|
|
52
|
+
${f}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
`;async function R(t){let n=[],r=0,i=!1;do{let{assessmentFormTemplates:{nodes:a}}=await N(t,L,{variables:{first:20,offset:r},logger:e});n.push(...a),r+=20,i=a.length===20}while(i);return n.sort((e,t)=>e.title.localeCompare(t.title))}const z=[`dataSilos`,`enrichers`,`templates`,`apiKeys`];async function B(f,{dataSiloIds:N,integrationNames:I,debug:L,resources:B=z,pageSize:V,skipDatapoints:Te,includeGuessedCategories:H,skipSubDatapoints:Ee,trackerStatuses:U=Object.values(n)}){if(N.length>0&&I.length>0)throw Error(`Only 1 of integrationNames OR dataSiloIds can be provided`);e.info(d.magenta(`Fetching data with page size ${V}...`));let[W,De,G,K,Oe,ke,Ae,je,Me,Ne,Pe,Fe,q,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,J,et,tt,nt,Y,X,rt,it]=await Promise.all([B.includes(`dataSilos`)||B.includes(`dataSubjects`)?D(f,{logger:e}):[],B.includes(`apiKeys`)?me(f,{fetchAll:!0,logger:e}):[],B.includes(`dataSilos`)?be(f,{ids:N,integrationNames:I,pageSize:V,debug:L,includeGuessedCategories:H,skipDatapoints:Te,skipSubDatapoints:Ee,logger:e}):[],B.includes(`enrichers`)?O(f,{logger:e}):[],B.includes(`dataFlows`)?[...U.includes(n.Live)?await E(f,{logger:e,filterBy:{status:n.Live}}):[],...U.includes(n.NeedsReview)?await E(f,{logger:e,filterBy:{status:n.NeedsReview}}):[]]:[],B.includes(`cookies`)?[...U.includes(n.Live)?await w(f,{logger:e,filterBy:{status:n.Live}}):[],...U.includes(n.NeedsReview)?await w(f,{logger:e,filterBy:{status:n.NeedsReview}}):[]]:[],B.includes(`customFields`)?x(f,{logger:e}):[],B.includes(`templates`)?fe(f,{logger:e}):[],B.includes(`identifiers`)?k(f,{logger:e}):[],B.includes(`actions`)?g(f,{logger:e}):[],B.includes(`businessEntities`)?S(f,{logger:e}):[],B.includes(`processingActivities`)?ie(f,{logger:e}):[],B.includes(`consentManager`)?he(f,{logger:e}):void 0,B.includes(`consentManager`)?ge(f,{logger:e}):[],B.includes(`consentManager`)?ye(f,{logger:e}):[],B.includes(`consentManager`)?ve(f,{logger:e}):[],B.includes(`prompts`)?ce(f,{logger:e}):[],B.includes(`promptPartials`)?se(f,{logger:e}):[],B.includes(`promptGroups`)?oe(f,{logger:e}):[],B.includes(`agents`)?y(f,{logger:e}):[],B.includes(`agentFunctions`)?v(f,{logger:e}):[],B.includes(`agentFiles`)?_(f,{logger:e}):[],B.includes(`vendors`)?pe(f,{logger:e}):[],B.includes(`dataCategories`)?T(f,{logger:e}):[],B.includes(`processingPurposes`)?ae(f,{logger:e}):[],B.includes(`actionItems`)?h(f,{logger:e,filterBy:{type:[t.Onboarding]}}):[],B.includes(`actionItemCollections`)?m(f,{logger:e}):[],B.includes(`teams`)?de(f,{logger:e}):[],B.includes(`policies`)?te(f,{logger:e}):[],B.includes(`privacyCenters`)?re(f,{logger:e}):[],B.includes(`messages`)?ee(f,{logger:e}):[],B.includes(`partitions`)?xe(f,{logger:e}):[],B.includes(`assessments`)?b(f,{logger:e}):[],B.includes(`assessmentTemplates`)?R(f):[],B.includes(`purposes`)?le(f,{logger:e}):[],B.includes(`preferenceWorkflowConfigs`)?C(f,{logger:e}):[],B.includes(`workflowConfigs`)?A(f,{logger:e,workflowConfigType:o.DSR}):[],B.includes(`preferenceOptions`)?ne(f,{logger:e}):[],B.includes(`systemDiscovery`)?ue(f,{logger:e}):[]]),Z=B.includes(`consentManager`)&&q?await _e(f,{logger:e,filterBy:{airgapBundleId:q.id}}):void 0,Q={},at=s(G.map(([{apiKeys:e}])=>e.map(({title:e})=>e))),$=Object.values(De).filter(({title:e})=>B.includes(`apiKeys`)?!0:at.includes(e));if($.length>0&&B.includes(`apiKeys`)&&(Q[`api-keys`]=$.map(({title:e})=>({title:e}))),J.length>0&&B.includes(`partitions`)&&(Q.partitions=J.map(({name:e,partition:t})=>({name:e,partition:t}))),q&&B.includes(`consentManager`)&&(Q[`consent-manager`]={bundleUrls:{TEST:q.testBundleURL,PRODUCTION:q.bundleURL},domains:q.configuration.domains||void 0,partition:q.configuration.partition||void 0,consentPrecedence:q.configuration.consentPrecedence||void 0,unknownRequestPolicy:q.configuration.unknownRequestPolicy||void 0,unknownCookiePolicy:q.configuration.unknownCookiePolicy||void 0,syncEndpoint:q.configuration.syncEndpoint||void 0,telemetryPartitioning:q.configuration.telemetryPartitioning||void 0,signedIabAgreement:q.configuration.signedIabAgreement||void 0,syncGroups:q.configuration.syncGroups||void 0,theme:Z?{primaryColor:Z.primaryColor||void 0,fontColor:Z.fontColor||void 0,privacyPolicy:Z.privacyPolicy||void 0,prompt:Z.prompt}:void 0,experiences:Ie.map(e=>({name:e.name,displayName:e.displayName||void 0,regions:e.regions.map(e=>({countrySubDivision:e.countrySubDivision||void 0,country:e.country||void 0})),onConsentExpiry:e.onConsentExpiry,consentExpiry:e.consentExpiry,operator:e.operator,displayPriority:e.displayPriority,viewState:e.viewState,purposes:e.purposes.map(e=>({trackingType:e.trackingType})),optedOutPurposes:e.optedOutPurposes.map(e=>({trackingType:e.trackingType})),browserLanguages:e.browserLanguages,browserTimeZones:e.browserTimeZones,consentUiVariantSlug:e.consentUiVariant?.slug})),consentVariants:Le.map(e=>({id:e.id,name:e.name,slug:e.slug,description:e.description||void 0,configuration:JSON.stringify(e.configuration),locales:e.locales,status:e.status,userFlow:e.userFlow||void 0,themeSlug:e.theme?.slug||void 0})),consentThemes:Re.map(e=>({id:e.id,name:e.name,slug:e.slug,configuration:JSON.stringify(e.configuration)}))}),et.length>0&&B.includes(`assessments`)&&(Q.assessments=et.map(({title:e,assessmentGroup:t,sections:n,creator:r,description:i,status:a,assignees:o,externalAssignees:s,reviewers:c,isLocked:l,isArchived:u,isExternallyCreated:d,dueDate:f,createdAt:p,assignedAt:m,submittedAt:h,approvedAt:g,rejectedAt:_,titleIsInternal:v,retentionSchedule:y,attributeValues:b,resources:x,syncedRows:S})=>({title:e,group:t.title,sections:n.map(({title:e,status:t,questions:n,assignees:r,isReviewed:i,externalAssignees:a})=>({title:e,status:t,questions:n.map(({title:e,type:t,subType:n,placeholder:r,description:i,isRequired:a,referenceId:o,displayLogic:s,riskLogic:c,riskCategories:l,riskFramework:u,answerOptions:d,selectedAnswers:f,allowedMimeTypes:p,allowSelectOther:m,syncModel:h,syncColumn:g,attributeKey:_,requireRiskEvaluation:v,requireRiskMatrixEvaluation:y})=>{let b=s?P(s):void 0;return{title:e,type:t,"sub-type":n,placeholder:r,description:i,"is-required":a,"reference-id":o,"display-logic":b&&Object.keys(b).length>0?{action:b.action,rule:b.rule?{"depends-on-question-reference-id":b.rule.dependsOnQuestionReferenceId,"comparison-operator":b.rule.comparisonOperator,"comparison-operands":`comparisonOperands`in b.rule?b.rule.comparisonOperands:void 0}:void 0,"nested-rule":b.nestedRule?{"logic-operator":b.nestedRule.logicOperator,rules:(b.nestedRule.rules||[]).map(e=>({"depends-on-question-reference-id":e.dependsOnQuestionReferenceId,"comparison-operator":e.comparisonOperator,"comparison-operands":`comparisonOperands`in e?e.comparisonOperands:void 0}))}:void 0}:void 0,"risk-logic":c.map(e=>{let t=F(e);return{"risk-level":t.riskAssignment?.riskLevelId,"comparison-operands":t.comparisonOperands,"comparison-operator":t.comparisonOperator}}),"risk-categories":l.map(({title:e})=>e),"risk-framework":u?.title,"answer-options":d.map(({value:e})=>({value:e})),"selected-answers":f.map(({value:e})=>e),"allowed-mime-types":p,"allow-select-other":m,"sync-model":h||void 0,"sync-column":g||void 0,"attribute-key":_?.name,"require-risk-evaluation":v,"require-risk-matrix-evaluation":y}}),assignees:r.map(({email:e})=>e),"external-assignees":a.map(({email:e})=>e),"is-reviewed":i})),creator:r?.email,description:i,status:a,assignees:o.map(({email:e})=>e),"external-assignees":s.map(({email:e})=>e),reviewers:c.map(({email:e})=>e),locked:l,archived:u,external:d,"title-is-internal":v,"due-date":f||void 0,"created-at":p||void 0,"assigned-at":m||void 0,"submitted-at":h||void 0,"approved-at":g||void 0,"rejected-at":_||void 0,"retention-schedule":y?{type:y.type,"duration-days":y.durationDays,operand:y.operation}:void 0,attributes:b!==void 0&&b.length>0?j(b):void 0,resources:x.map(({resourceType:e,title:t,name:n,category:r,type:i,purpose:a})=>({type:e,title:r?`${r} - ${n}`:a?`${a} - ${n}`:t||n||i||``})),rows:S.map(({resourceType:e,title:t,name:n,category:r,type:i,purpose:a})=>({type:e,title:r?`${r} - ${n}`:a?`${a} - ${n}`:t||n||i||``}))}))),tt.length>0&&B.includes(`assessmentTemplates`)&&(Q[`assessment-templates`]=tt.map(({title:e,description:t,sections:n,status:r,source:i,creator:a,isLocked:o,isArchived:s,createdAt:c,retentionSchedule:l})=>({title:e,description:t,sections:n.map(({title:e,questions:t})=>({title:e,questions:t.map(({title:e,type:t,subType:n,placeholder:r,description:i,isRequired:a,referenceId:o,displayLogic:s,riskLogic:c,riskCategories:l,riskFramework:u,answerOptions:d,allowedMimeTypes:f,allowSelectOther:p,syncModel:m,syncColumn:h,attributeKey:g,requireRiskEvaluation:_,requireRiskMatrixEvaluation:v})=>{let y=s?P(s):void 0;return{title:e,type:t,"sub-type":n,placeholder:r,description:i,"is-required":a,"reference-id":o,"display-logic":y&&Object.keys(y).length>0?{action:y.action,rule:y.rule?{"depends-on-question-reference-id":y.rule.dependsOnQuestionReferenceId,"comparison-operator":y.rule.comparisonOperator,"comparison-operands":`comparisonOperands`in y.rule?y.rule.comparisonOperands:void 0}:void 0,"nested-rule":y.nestedRule?{"logic-operator":y.nestedRule.logicOperator,rules:(y.nestedRule.rules||[]).map(e=>({"depends-on-question-reference-id":e.dependsOnQuestionReferenceId,"comparison-operator":e.comparisonOperator,"comparison-operands":`comparisonOperands`in e?e.comparisonOperands:void 0}))}:void 0}:void 0,"risk-logic":c.map(e=>{let t=F(e);return{"risk-level":t.riskAssignment?.riskLevelId,"risk-matrix-row":t.riskAssignment?.riskMatrixRowId,"risk-matrix-column":t.riskAssignment?.riskMatrixColumnId,"comparison-operands":t.comparisonOperands,"comparison-operator":t.comparisonOperator}}),"risk-categories":l.map(({title:e})=>e),"risk-framework":u?.title,"answer-options":d.map(({value:e})=>({value:e})),"allowed-mime-types":f,"allow-select-other":p,"sync-model":m||void 0,"sync-column":h||void 0,"attribute-key":g?.name,"require-risk-evaluation":_,"require-risk-matrix-evaluation":v}})})),status:r,source:i,creator:a?.email,locked:o,archived:s,"created-at":c||void 0,"retention-schedule":l?{type:l.type,"duration-days":l.durationDays,operand:l.operation}:void 0}))),it.length>0&&B.includes(`systemDiscovery`)&&(Q[`system-discovery`]=it.map(({title:e,resourceId:t,suggestedCatalog:{title:n},plugin:{dataSilo:{title:r}},country:i,countrySubDivision:a,plaintextContext:o,containsSensitiveData:s,status:c})=>({title:e,resourceId:t,suggestedCatalog:n,plugin:r,country:i||void 0,countrySubDivision:a||void 0,plaintextContext:o,containsSensitiveData:s,status:c}))),ze.length>0&&B.includes(`prompts`)&&(Q.prompts=ze.map(({title:e,content:t})=>({title:e,content:t}))),Be.length>0&&B.includes(`promptPartials`)&&(Q[`prompt-partials`]=Be.map(({title:e,content:t})=>({title:e,content:t}))),Ve.length>0&&B.includes(`promptGroups`)&&(Q[`prompt-groups`]=Ve.map(({title:e,description:t,prompts:n})=>({title:e,description:t,prompts:n.map(({title:e})=>e)}))),Xe.length>0&&B.includes(`teams`)&&(Q.teams=Xe.map(({name:e,description:t,ssoDepartment:n,ssoGroup:r,ssoTitle:i,users:a,scopes:o,parentTeam:s})=>({name:e,description:t,"sso-department":n||void 0,"sso-group":r||void 0,"sso-title":i||void 0,"parent-team-name":s?.name,users:a.map(({email:e})=>e),scopes:o.map(({name:e})=>e)}))),W.length>0&&B.includes(`dataSubjects`)&&(Q[`data-subjects`]=W.map(({type:e,title:t,active:n,adminDashboardDefaultSilentMode:r,supportsAuthorizedAgent:i,actions:a})=>({type:e,title:t?.defaultMessage,active:n,adminDashboardDefaultSilentMode:r,supportsAuthorizedAgent:i,actions:a.map(({type:e})=>e)}))),Ze.length>0&&(Q.policies=Ze.map(({title:e,type:t,versions:n,disabledLocales:r})=>({title:e?.defaultMessage,type:t,content:n?.[0]?.content?.defaultMessage,disabledLocales:r}))),$e.length>0&&(Q.messages=$e.map(({id:e,defaultMessage:t,targetReactIntlId:n,description:r,translations:i})=>({id:e,defaultMessage:t,description:r,targetReactIntlId:n||void 0,translations:i.reduce((e,{locale:t,value:n})=>Object.assign(e,{[t]:n}),{})}))),Qe.length>0){let e=Qe[0];Q[`privacy-center`]={isDisabled:e.isDisabled,showPrivacyRequestButton:e.showPrivacyRequestButton,showPolicies:e.showPolicies,showTrackingTechnologies:e.showTrackingTechnologies,showCookies:e.showCookies,showDataFlows:e.showDataFlows,showConsentManager:e.showConsentManager,showManageYourPrivacy:e.showManageYourPrivacy,showMarketingPreferences:e.showMarketingPreferences,locales:e.locales,defaultLocale:e.defaultLocale,preferBrowserDefaultLocale:e.preferBrowserDefaultLocale,supportEmail:e.supportEmail||void 0,replyToEmail:e.replyToEmail||void 0,useNoReplyEmailAddress:e.useNoReplyEmailAddress,useCustomEmailDomain:e.useCustomEmailDomain,transformAccessReportJsonToCsv:e.transformAccessReportJsonToCsv,home:e.home||void 0,expandSideMenuByDefault:e.expandSideMenuByDefault,workflowsCustomFieldsRequired:e.workflowsCustomFieldsRequired,footerLayout:e.footerLayout,...e.childOrganizations.length>0?{displayedChildOrganizationUris:e.childOrganizations.map(e=>e.uri)}:{},...e.footerLinks.length>0?{footerLinks:[...e.footerLinks].sort((e,t)=>e.displayOrder-t.displayOrder).map(e=>({title:e.title.defaultMessage,...e.url?{url:e.url}:{},...e.iconOnly?{iconOnly:e.iconOnly}:{}}))}:{},theme:e.theme}}if(Pe.length>0&&B.includes(`businessEntities`)&&(Q[`business-entities`]=Pe.map(({title:e,description:t,address:n,headquarterCountry:r,headquarterSubDivision:i,dataProtectionOfficerName:a,dataProtectionOfficerEmail:o,attributeValues:s})=>({title:e,description:t||void 0,address:n||void 0,headquarterCountry:r||void 0,headquarterSubDivision:i||void 0,dataProtectionOfficerName:a||void 0,dataProtectionOfficerEmail:o||void 0,attributes:s!==void 0&&s.length>0?j(s):void 0}))),Fe.length>0&&B.includes(`processingActivities`)&&(Q[`processing-activities`]=Fe.map(({title:e,description:t,securityMeasureDetails:n,controllerships:r,storageRegions:i,transferRegions:o,retentionType:s,retentionPeriod:c,dataProtectionImpactAssessmentLink:l,dataProtectionImpactAssessmentStatus:u,attributeValues:d,dataSilos:f,dataSubjects:p,teams:m,owners:h,processingPurposeSubCategories:g,dataSubCategories:_,saaSCategories:v})=>({title:e,description:t,securityMeasureDetails:n??void 0,controllerships:r.length>0?r:void 0,storageRegions:i.length>0?M(i):void 0,transferRegions:o.length>0?M(o):void 0,retentionType:s,retentionPeriod:s===a.StatedPeriod?c:void 0,dataProtectionImpactAssessmentLink:l??void 0,dataProtectionImpactAssessmentStatus:u,attributes:d!==void 0&&d.length>0?j(d):void 0,dataSiloTitles:f.length>0?f.map(({title:e})=>e):void 0,dataSubjectTypes:p.length>0?p.map(({type:e})=>e):void 0,teamNames:m.length>0?m.map(({name:e})=>e):void 0,ownerEmails:h.length>0?h.map(({email:e})=>e):void 0,processingSubPurposes:g.length>0?g.map(({name:e,purpose:t})=>({purpose:t,...e?{name:e}:{}})):void 0,dataSubCategories:_.length>0?_.map(({name:e,category:t})=>({category:t,...e?{name:e}:{}})):void 0,saaSCategories:v.length>0?v.map(({title:e})=>e):void 0}))),Ne.length>0&&B.includes(`actions`)&&(Q.actions=Ne.map(({type:e,skipSecondaryIfNoFiles:t,skipDownloadableStep:n,requiresReview:r,regionList:a,regionDetectionMethod:o,waitingPeriod:s})=>({type:e,...e===i.Erasure?{skipSecondaryIfNoFiles:t,skipDownloadableStep:n}:{},requiresReview:r,waitingPeriod:s,regionDetectionMethod:o,regionList:a.length>0?a:void 0}))),Me.length>0&&B.includes(`identifiers`)&&(Q.identifiers=Me.map(({name:e,type:t,regex:n,selectOptions:r,privacyCenterVisibility:i,isRequiredInForm:a,placeholder:o,displayTitle:s,dataSubjects:c,displayDescription:l,displayOrder:u,isUniqueOnPreferenceStore:d})=>({name:e,type:t,regex:n,selectOptions:r.length>0?r:void 0,privacyCenterVisibility:i.length>0?i:void 0,isRequiredInForm:a,placeholder:o||void 0,dataSubjects:c.length>0?c.map(({type:e})=>e):void 0,displayTitle:s?.defaultMessage,displayDescription:l?.defaultMessage,displayOrder:u,isUniqueOnPreferenceStore:d}))),He.length>0&&B.includes(`agents`)&&(Q.agents=He.map(({name:e,agentId:t,description:n,instructions:r,codeInterpreterEnabled:i,retrievalEnabled:a,prompt:o,largeLanguageModel:s,teams:c,owners:l,agentFunctions:u,agentFiles:d})=>({name:e,agentId:t,description:n||void 0,instructions:r,codeInterpreterEnabled:i,retrievalEnabled:a,prompt:o?.title,"large-language-model":{name:s.name,client:s.client},teams:c&&c.length>0?c.map(({name:e})=>e):void 0,owners:l&&l.length>0?l.map(({email:e})=>e):void 0,"agent-functions":u&&u.length>0?u.map(({name:e})=>e):void 0,"agent-files":d&&d.length>0?d.map(({name:e})=>e):void 0}))),Je.length>0&&B.includes(`actionItems`)&&(Q[`action-items`]=Je.map(({teams:e,users:t,customerExperienceActionItemIds:[n],dueDate:r,priority:i,resolved:a,collections:o,notes:s,link:c,title:l,type:u,attributeValues:d})=>({teams:e.map(({name:e})=>e),users:t.map(({email:e})=>e),dueDate:r||void 0,title:l,notes:s,customerExperienceActionItemId:n,collections:o.map(({title:e})=>e),link:c,priority:i||void 0,resolved:a,type:u,attributes:d!==void 0&&d.length>0?j(d):void 0}))),Ye.length>0&&B.includes(`actionItemCollections`)&&(Q[`action-item-collections`]=Ye.map(({title:e,description:t,hidden:n,productLine:r})=>({title:e,description:t||void 0,hidden:n,productLine:r}))),Ue.length>0&&B.includes(`agentFunctions`)&&(Q[`agent-functions`]=Ue.map(({name:e,description:t,parameters:n})=>({name:e,description:t,parameters:JSON.stringify(n)}))),We.length>0&&B.includes(`agentFiles`)&&(Q[`agent-files`]=We.map(({name:e,description:t,fileId:n,size:r,purpose:i})=>({name:e,description:t,fileId:n,size:r,purpose:i}))),Ge.length>0&&B.includes(`vendors`)&&(Q.vendors=Ge.map(({title:e,description:t,dataProcessingAgreementLink:n,contactName:r,contactPhone:i,address:a,headquarterCountry:o,headquarterSubDivision:s,websiteUrl:c,businessEntity:l,teams:u,owners:d,attributeValues:f})=>({title:e,description:t||void 0,dataProcessingAgreementLink:n||void 0,contactName:r||void 0,contactPhone:i||void 0,address:a||void 0,headquarterCountry:o||void 0,headquarterSubDivision:s||void 0,websiteUrl:c||void 0,businessEntity:l?.title,teams:u&&u.length>0?u.map(({name:e})=>e):void 0,owners:d&&d.length>0?d.map(({email:e})=>e):void 0,attributes:f!==void 0&&f.length>0?j(f):void 0}))),Ke.length>0&&B.includes(`dataCategories`)&&(Q[`data-categories`]=Ke.map(({name:e,category:t,description:n,regex:r,owners:i,teams:a,attributeValues:o})=>({name:e,category:t,description:n||void 0,regex:r||void 0,owners:i&&i.length>0?i.map(({email:e})=>e):void 0,teams:a&&a.length>0?a.map(({name:e})=>e):void 0,attributes:o!==void 0&&o.length>0?j(o):void 0}))),qe.length>0&&B.includes(`processingPurposes`)&&(Q[`processing-purposes`]=qe.map(({name:e,purpose:t,description:n,owners:r,teams:i,attributeValues:a})=>({name:e,purpose:t,description:n||void 0,owners:r&&r.length>0?r.map(({email:e})=>e):void 0,teams:i&&i.length>0?i.map(({name:e})=>e):void 0,attributes:a!==void 0&&a.length>0?j(a):void 0}))),Oe.length>0&&B.includes(`dataFlows`)&&(Q[`data-flows`]=Oe.map(({value:e,type:t,description:n,trackingType:r,service:i,status:a,owners:o,teams:s,attributeValues:c})=>({value:e,type:t,description:n||void 0,trackingPurposes:r,status:a,service:i?.integrationName,owners:o.map(({email:e})=>e),teams:s.map(({name:e})=>e),attributes:c!==void 0&&c.length>0?j(c):void 0}))),ke.length>0&&B.includes(`cookies`)&&(Q.cookies=ke.map(({name:e,isRegex:t,description:n,trackingPurposes:r,service:i,status:a,owners:o,teams:s,attributeValues:c})=>({name:e,isRegex:t,description:n||void 0,trackingPurposes:r,status:a,service:i?.integrationName,owners:o.map(({email:e})=>e),teams:s.map(({name:e})=>e),attributes:c!==void 0&&c.length>0?j(c):void 0}))),Ae.length>0&&B.includes(`customFields`)&&(Q.attributes=Ae.map(({description:e,name:t,type:n,values:r,enabledOn:i=[]})=>({description:e||void 0,resources:i,name:t,type:n,values:r.map(({name:e,color:t,description:n})=>({name:e,color:t||void 0,description:n}))}))),nt.length>0&&(Q.purposes=nt.map(({name:e,description:t,trackingType:n,defaultConsent:i,configurable:a,showInConsentManager:o,isActive:s,displayOrder:c,optOutSignals:l,authLevel:u,topics:d,showInPrivacyCenter:f,title:p})=>({name:e,title:p,description:t||void 0,trackingType:n,"default-consent":i,configurable:a,"show-in-consent-manager":o,"show-in-privacy-center":f,"is-active":s,"display-order":c,"opt-out-signals":l.length>0?l:void 0,"auth-level":u||void 0,"preference-topics":d.map(({slug:e,title:t,type:n,color:i,displayDescription:a,defaultConfiguration:o,showInPrivacyCenter:s,preferenceOptionValues:c})=>({slug:e,title:t.defaultMessage,type:n,color:i,description:a.defaultMessage,"default-configuration":o,"show-in-privacy-center":s,options:n===r.Boolean?[]:c.map(({title:e,slug:t})=>({title:e.defaultMessage,slug:t}))}))}))),X.length>0&&B.includes(`workflowConfigs`)){let t=X.map(e=>({title:e.title.defaultMessage,"action-type":e.action.type,...e.internalName?{"internal-name":e.internalName}:{},...e.subtitle?{subtitle:e.subtitle.defaultMessage}:{},...e.description?{description:e.description.defaultMessage}:{},...e.subject?{"data-subject-type":e.subject.type}:{},visibility:e.workflowConfigVisibility,type:e.workflowConfigType,...e.collectDataSubjectRegions?{"collect-data-subject-regions":e.collectDataSubjectRegions}:{},...e.regionList.length>0?{"region-list":e.regionList}:{},...e.expiryTime&&e.expiryTime.length>0?{"expiry-time":e.expiryTime}:{},...e.WorkflowConfigAttributeKeys&&e.WorkflowConfigAttributeKeys.length>0?{"attribute-keys":e.WorkflowConfigAttributeKeys.map(({attributeKey:e})=>e.name)}:{}})),n=c(X,we);for(let t of Object.values(n))if(t.length>1){let n=t[0];e.warn(`Found "${t.length}" workflow configs with the same title, action-type, data-subject-type, and region-list for "${n.title.defaultMessage}" (${n.action.type}). Push will fail until they are disambiguated (for example with unique internal names).`)}t.length>0&&(Q[`workflow-configs`]=t)}if(Y.length>0&&B.includes(`preferenceWorkflowConfigs`)){let t=Y.some(e=>e.workflowConfigId)?await A(f,{logger:e,workflowConfigType:o.DSR}):[];Q[`preference-workflow-configs`]=Y.map(e=>{let n=Se(e.triggerCondition),r={name:e.name,"data-subject-type":e.subject.type,"is-silent":e.isSilent,"allow-unauthenticated":e.allowUnauthenticated,"is-active":e.isActive,purposes:n};if(e.workflowConfigId){let n=Ce(t,e.workflowConfigId);if(n)return{...r,"workflow-title":n}}return{...r,"action-type":e.action.type,"data-silo-titles":e.dataSilos.length>0?e.dataSilos.map(e=>e.title):void 0}})}if(rt.length>0&&B.includes(`preferenceOptions`)&&(Q[`preference-options`]=rt.map(({slug:e,title:t})=>({slug:e,title:t.defaultMessage}))),N.length===0&&je.length>0&&B.includes(`templates`)&&(Q.templates=je.map(({title:e})=>({title:e}))),K.length>0&&B.includes(`enrichers`)&&(Q.enrichers=K.map(({title:e,url:t,type:n,inputIdentifier:r,identifiers:a,actions:o,testRegex:s,dataSubjects:c,expirationDuration:l,lookerQueryTitle:u,transitionRequestStatus:d,phoneNumbers:f,regionList:p})=>({title:e,url:t||void 0,type:n,"input-identifier":r?.name,"output-identifiers":a.map(({name:e})=>e),"privacy-actions":Object.values(i).length===o.length?void 0:o,testRegex:s||void 0,lookerQueryTitle:u||void 0,expirationDuration:parseInt(l,10),transitionRequestStatus:d||void 0,phoneNumbers:f&&f.length>0?f:void 0,regionList:p&&p.length>0?p:void 0,"data-subjects":c.map(({type:e})=>e)}))),G.length>0&&B.includes(`dataSilos`)){let e=l(W,`type`);Q[`data-silos`]=G.map(([{title:t,description:n,url:r,type:i,outerType:a,apiKeys:o,notifyEmailAddress:s,identifiers:c,dependentDataSilos:d,owners:f,country:m,countrySubDivision:h,teams:g,subjectBlocklist:_,isLive:v,promptAVendorEmailSendFrequency:y,promptAVendorEmailSendType:b,promptAVendorEmailIncludeIdentifiersAttachment:x,promptAVendorEmailCompletionLinkType:S,manualWorkRetryFrequency:C,catalog:w,attributeValues:T,discoveredBy:E,businessEntities:D,sombra:O},k])=>({title:t,description:n,integrationName:i,"outer-type":a||void 0,url:r||void 0,"api-key-title":o[0]?.title,"sombra-id":O?.id||void 0,"identity-keys":c.filter(({isConnected:e})=>e).map(({name:e})=>e),...d.length>0?{"deletion-dependencies":d.map(({title:e})=>e)}:{},...f.length>0?{owners:f.map(({email:e})=>e)}:{},...g.length>0?{teams:g.map(({name:e})=>e)}:{},...E.length>0?{discoveredBy:E.map(({title:e})=>e)}:{},...D.length>0?{businessEntities:D.map(({title:e})=>e)}:{},country:m||void 0,countrySubDivision:h||void 0,disabled:!v,"data-subjects":_.length>0?p(_.map(({type:e})=>e),e):void 0,...w.hasAvcFunctionality?{"email-settings":{"notify-email-address":s||void 0,"send-frequency":y,"send-type":b,"include-identifiers-attachment":x,"completion-link-type":S,"manual-work-retry-frequency":C}}:{},attributes:T!==void 0&&T.length>0?j(T):void 0,datapoints:k.map(e=>({key:e.name,title:e.title?.defaultMessage,description:e.description?.defaultMessage,owners:e.owners.map(({email:e})=>e),teams:e.teams.map(({name:e})=>e),...e.path.length>0?{path:e.path}:{},...e.dataCollection?.title?{"data-collection-tag":e.dataCollection.title.defaultMessage}:{},...e.dbIntegrationQueries.length>0?{"privacy-action-queries":u(l(e.dbIntegrationQueries,`requestType`),e=>e.suggestedQuery||e.query||void 0)}:{},...e.subDataPoints.length>0?{fields:e.subDataPoints.map(e=>({key:e.name,description:e.description,purposes:e.purposes,categories:e.categories,...H&&e.pendingCategoryGuesses?{"guessed-categories":e.pendingCategoryGuesses.filter(e=>e.status===`PENDING`).map(e=>({category:{name:e.category.name,category:e.category.category},status:e.status,confidence:e.confidence,classifierVersion:e.classifierVersion||void 0}))}:{},"access-request-visibility-enabled":e.accessRequestVisibilityEnabled,"erasure-request-redaction-enabled":e.erasureRequestRedactionEnabled,attributes:e.attributeValues!==void 0&&e.attributeValues.length>0?j(e.attributeValues):void 0})).sort((e,t)=>e.key.localeCompare(t.key))}:{},"privacy-actions":e.actionSettings.filter(({active:e})=>e).map(({type:e})=>e)})).sort((e,t)=>[...e.path??[],e.key].join(`.`).localeCompare([...t.path??[],t.key].join(`.`)))}))}return Q}export{L as i,B as n,R as r,z as t};
|
|
58
|
+
//# sourceMappingURL=pullTranscendConfiguration-BQCO6G7Z.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pullTranscendConfiguration-BQCO6G7Z.mjs","names":[],"sources":["../src/lib/graphql/gqls/assessmentTemplate.ts","../src/lib/graphql/fetchAllAssessmentTemplates.ts","../src/lib/graphql/pullTranscendConfiguration.ts"],"sourcesContent":["import { ASSESSMENT_SECTION_FIELDS } from '@transcend-io/sdk';\nimport { gql } from 'graphql-request';\n\n// TODO: https://transcend.height.app/T-27909 - enable optimizations\n// isExportCsv: true\n// useMaster: false\n// orderBy: [\n// { field: createdAt, direction: ASC }\n// { field: name, direction: ASC }\n// ]\nexport const ASSESSMENT_TEMPLATES = gql`\n query TranscendCliAssessmentTemplates(\n $first: Int!\n $offset: Int!\n $filterBy: AssessmentFormTemplateFiltersInput\n ) {\n assessmentFormTemplates(\n first: $first\n offset: $offset\n filterBy: $filterBy\n ) {\n nodes {\n id\n creator {\n id\n email\n name\n }\n lastEditor {\n id\n email\n name\n }\n title\n description\n status\n source\n parentId\n isLocked\n isArchived\n createdAt\n updatedAt\n retentionSchedule {\n id\n type\n durationDays\n operation\n createdAt\n updatedAt\n }\n assessmentEmailSet {\n id\n title\n description\n isDefault\n templates {\n id\n title\n }\n }\n sections {\n ${ASSESSMENT_SECTION_FIELDS}\n }\n }\n }\n }\n`;\n","import {\n AssessmentFormTemplateSource,\n AssessmentFormTemplateStatus,\n} from '@transcend-io/privacy-types';\nimport {\n makeGraphQLRequest,\n type AssessmentSection,\n type RetentionSchedule,\n type UserPreview,\n} from '@transcend-io/sdk';\nimport { GraphQLClient } from 'graphql-request';\n\nimport { logger } from '../../logger.js';\nimport { ASSESSMENT_TEMPLATES } from './gqls/index.js';\n\n/**\n * Represents an assessment template with various properties and metadata.\n */\nexport interface AssessmentTemplate {\n /** The ID of the assessment template */\n id: string;\n /** The user who created the assessment template */\n creator: UserPreview;\n /** The user who last edited the assessment template */\n lastEditor: UserPreview;\n /** The title of the assessment template */\n title: string;\n /** The description of the assessment template */\n description: string;\n /** The current status of the assessment template */\n status: AssessmentFormTemplateStatus;\n /** The source fo the form template */\n source: AssessmentFormTemplateSource;\n /** ID of parent template */\n parentId: string;\n /** Indicates if the assessment template is locked */\n isLocked: boolean;\n /** Indicates if the assessment template is archived */\n isArchived: boolean;\n /** The date when the assessment template was created */\n createdAt: string;\n /** The date when the assessment template was last updated */\n updatedAt: string;\n /** The retention schedule of the assessment template */\n retentionSchedule?: RetentionSchedule;\n /** The sections of the assessment template */\n sections: AssessmentSection[];\n}\n\nconst PAGE_SIZE = 20;\n\n/**\n * Fetch all assessment templates in the organization\n *\n * @param client - GraphQL client\n * @returns All assessment templates in the organization\n */\nexport async function fetchAllAssessmentTemplates(\n client: GraphQLClient,\n): Promise<AssessmentTemplate[]> {\n const assessmentTemplates: AssessmentTemplate[] = [];\n let offset = 0;\n\n let shouldContinue = false;\n do {\n const {\n assessmentFormTemplates: { nodes },\n } = await makeGraphQLRequest<{\n /** Templates */\n assessmentFormTemplates: {\n /** Nodes */\n nodes: AssessmentTemplate[];\n };\n }>(client, ASSESSMENT_TEMPLATES, {\n variables: { first: PAGE_SIZE, offset },\n logger,\n });\n assessmentTemplates.push(...nodes);\n offset += PAGE_SIZE;\n shouldContinue = nodes.length === PAGE_SIZE;\n } while (shouldContinue);\n\n return assessmentTemplates.sort((a, b) => a.title.localeCompare(b.title));\n}\n","import { LocaleValue } from '@transcend-io/internationalization';\nimport {\n RequestAction,\n ConsentTrackerStatus,\n ActionItemCode,\n RetentionType,\n PreferenceTopicType,\n WorkflowConfigType,\n type ConsentThemeInput,\n type ConsentVariantInput,\n} from '@transcend-io/privacy-types';\nimport {\n fetchAllActionItemCollections,\n fetchAllActionItems,\n fetchAllActions,\n fetchAllAgentFiles,\n fetchAllAgentFunctions,\n fetchAllAgents,\n fetchAllAssessments,\n fetchAllAttributes,\n fetchAllBusinessEntities,\n fetchAllCookies,\n fetchAllDataCategories,\n fetchAllDataFlows,\n fetchAllPolicies,\n fetchAllPrivacyCenters,\n fetchAllProcessingPurposes,\n fetchAllSiloDiscoveryResults,\n fetchAllTemplates,\n fetchConsentManager,\n fetchConsentManagerExperiences,\n fetchConsentVariants,\n fetchConsentThemes,\n fetchConsentManagerTheme,\n fetchAllEnrichers,\n fetchAllIdentifiers,\n fetchAllMessages,\n fetchAllPromptGroups,\n fetchAllPromptPartials,\n fetchAllProcessingActivities,\n fetchAllPrompts,\n fetchAllPurposesAndPreferences,\n fetchAllConsentWorkflowTriggers,\n fetchAllPreferenceOptionValues,\n fetchAllWorkflowConfigs,\n fetchPartitions,\n fetchAllTeams,\n fetchAllVendors,\n fetchApiKeys,\n formatAttributeValues,\n formatRegions,\n parseAssessmentDisplayLogic,\n parseAssessmentRiskLogic,\n parsePurposesFromTriggerCondition,\n resolveWorkflowTitleFromId,\n convertToDataSubjectAllowlist,\n fetchAllDataSubjects,\n fetchEnrichedDataSilos,\n workflowConfigMatchKey,\n type AssessmentRule,\n} from '@transcend-io/sdk';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\nimport { flatten, groupBy, keyBy, mapValues } from 'lodash-es';\n\n/* eslint-disable max-lines */\nimport {\n TranscendInput,\n ApiKeyInput,\n DataSiloInput,\n AttributeInput,\n ActionInput,\n IdentifierInput,\n BusinessEntityInput,\n EnricherInput,\n PromptGroupInput,\n DataFlowInput,\n PromptPartialInput,\n DataSubjectInput,\n CookieInput,\n PromptInput,\n DatapointInput,\n FieldInput,\n ProcessingPurposeInput,\n ProcessingActivityInput,\n DataCategoryInput,\n VendorInput,\n AgentFileInput,\n AgentFunctionInput,\n AgentInput,\n PolicyInput,\n IntlMessageInput,\n ActionItemInput,\n TeamInput,\n ActionItemCollectionInput,\n AssessmentInput,\n AssessmentTemplateInput,\n AssessmentSectionInput,\n AssessmentSectionQuestionInput,\n RiskLogicInput,\n ConsentPurpose,\n PreferenceWorkflowConfigInput,\n WorkflowConfigInput,\n ConsentPreferenceTopic,\n ConsentPreferenceTopicOptionValue,\n type SiloDiscoveryResultInput,\n} from '../../codecs.js';\nimport { TranscendPullResource } from '../../enums.js';\nimport { logger } from '../../logger.js';\nimport { fetchAllAssessmentTemplates } from './fetchAllAssessmentTemplates.js';\n\nexport const DEFAULT_TRANSCEND_PULL_RESOURCES = [\n TranscendPullResource.DataSilos,\n TranscendPullResource.Enrichers,\n TranscendPullResource.Templates,\n TranscendPullResource.ApiKeys,\n];\n\nexport interface TranscendPullConfigurationInput {\n /** Page size */\n pageSize: number;\n /** Enable debug logs */\n debug: boolean;\n /** The data silo IDs to sync. If empty list, pull all. */\n dataSiloIds: string[];\n /** Resources to pull in */\n resources?: TranscendPullResource[];\n /** The data silo types to sync.If empty list, pull all. */\n integrationNames: string[];\n /** The tracker statuses to pull */\n trackerStatuses?: ConsentTrackerStatus[];\n /** Skip fetching of datapoints */\n skipDatapoints?: boolean;\n /** Skip fetching of subdatapoints */\n skipSubDatapoints?: boolean;\n /** When true, metadata around guessed data categories should be included */\n includeGuessedCategories?: boolean;\n}\n\n/**\n * Pull a yaml configuration from Transcend\n *\n * @param client - GraphQL client\n * @param dataSiloIds - The data silos to sync. If empty list, pull all.\n * @returns The configuration\n */\nexport async function pullTranscendConfiguration(\n client: GraphQLClient,\n {\n dataSiloIds,\n integrationNames,\n debug,\n resources = DEFAULT_TRANSCEND_PULL_RESOURCES,\n pageSize,\n skipDatapoints,\n includeGuessedCategories,\n skipSubDatapoints,\n trackerStatuses = Object.values(ConsentTrackerStatus),\n }: TranscendPullConfigurationInput,\n): Promise<TranscendInput> {\n if (dataSiloIds.length > 0 && integrationNames.length > 0) {\n throw new Error('Only 1 of integrationNames OR dataSiloIds can be provided');\n }\n\n logger.info(colors.magenta(`Fetching data with page size ${pageSize}...`));\n\n // Fetch all data, but only conditional fetch data that is requested\n const [\n dataSubjects,\n apiKeyTitleMap,\n dataSilos,\n enrichers,\n dataFlows,\n cookies,\n attributes,\n templates,\n identifiers,\n actions,\n businessEntities,\n processingActivities,\n consentManager,\n consentManagerExperiences,\n consentVariants,\n consentThemes,\n prompts,\n promptPartials,\n promptGroups,\n agents,\n agentFunctions,\n agentFiles,\n vendors,\n dataCategories,\n processingPurposes,\n actionItems,\n actionItemCollections,\n teams,\n policies,\n privacyCenters,\n messages,\n partitions,\n assessments,\n assessmentTemplates,\n purposes,\n preferenceWorkflowConfigs,\n workflowConfigs,\n preferenceOptionValues,\n siloDiscoveryResults,\n ] = await Promise.all([\n // Grab all data subjects in the organization\n resources.includes(TranscendPullResource.DataSilos) ||\n resources.includes(TranscendPullResource.DataSubjects)\n ? fetchAllDataSubjects(client, { logger })\n : [],\n // Grab API keys\n resources.includes(TranscendPullResource.ApiKeys)\n ? fetchApiKeys(client, { fetchAll: true, logger })\n : [],\n // Fetch the data silos\n resources.includes(TranscendPullResource.DataSilos)\n ? fetchEnrichedDataSilos(client, {\n ids: dataSiloIds,\n integrationNames,\n pageSize,\n debug,\n includeGuessedCategories,\n skipDatapoints,\n skipSubDatapoints,\n logger,\n })\n : [],\n // Fetch enrichers\n resources.includes(TranscendPullResource.Enrichers)\n ? fetchAllEnrichers(client, { logger })\n : [],\n // Fetch data flows\n resources.includes(TranscendPullResource.DataFlows)\n ? [\n ...(trackerStatuses.includes(ConsentTrackerStatus.Live)\n ? await fetchAllDataFlows(client, {\n logger,\n filterBy: { status: ConsentTrackerStatus.Live },\n })\n : []),\n ...(trackerStatuses.includes(ConsentTrackerStatus.NeedsReview)\n ? await fetchAllDataFlows(client, {\n logger,\n filterBy: { status: ConsentTrackerStatus.NeedsReview },\n })\n : []),\n ]\n : [],\n // Fetch data flows\n resources.includes(TranscendPullResource.Cookies)\n ? [\n ...(trackerStatuses.includes(ConsentTrackerStatus.Live)\n ? await fetchAllCookies(client, {\n logger,\n filterBy: { status: ConsentTrackerStatus.Live },\n })\n : []),\n ...(trackerStatuses.includes(ConsentTrackerStatus.NeedsReview)\n ? await fetchAllCookies(client, {\n logger,\n filterBy: { status: ConsentTrackerStatus.NeedsReview },\n })\n : []),\n ]\n : [],\n // Fetch attributes\n resources.includes(TranscendPullResource.Attributes)\n ? fetchAllAttributes(client, { logger })\n : [],\n // Fetch email templates\n resources.includes(TranscendPullResource.Templates)\n ? fetchAllTemplates(client, { logger })\n : [],\n // Fetch identifiers\n resources.includes(TranscendPullResource.Identifiers)\n ? fetchAllIdentifiers(client, { logger })\n : [],\n // Fetch actions\n resources.includes(TranscendPullResource.Actions) ? fetchAllActions(client, { logger }) : [],\n // Fetch business entities\n resources.includes(TranscendPullResource.BusinessEntities)\n ? fetchAllBusinessEntities(client, { logger })\n : [],\n // Fetch processing activities\n resources.includes(TranscendPullResource.ProcessingActivities)\n ? fetchAllProcessingActivities(client, { logger })\n : [],\n // Fetch consent manager\n resources.includes(TranscendPullResource.ConsentManager)\n ? fetchConsentManager(client, { logger })\n : undefined,\n // Fetch consent manager experiences\n resources.includes(TranscendPullResource.ConsentManager)\n ? fetchConsentManagerExperiences(client, { logger })\n : [],\n // Fetch consent manager consent variants\n resources.includes(TranscendPullResource.ConsentManager)\n ? fetchConsentVariants(client, { logger })\n : [],\n // Fetch consent manager consent themes\n resources.includes(TranscendPullResource.ConsentManager)\n ? fetchConsentThemes(client, { logger })\n : [],\n // Fetch prompts\n resources.includes(TranscendPullResource.Prompts) ? fetchAllPrompts(client, { logger }) : [],\n // Fetch promptPartials\n resources.includes(TranscendPullResource.PromptPartials)\n ? fetchAllPromptPartials(client, { logger })\n : [],\n // Fetch promptGroups\n resources.includes(TranscendPullResource.PromptGroups)\n ? fetchAllPromptGroups(client, { logger })\n : [],\n // Fetch agents\n resources.includes(TranscendPullResource.Agents) ? fetchAllAgents(client, { logger }) : [],\n // Fetch agentFunctions\n resources.includes(TranscendPullResource.AgentFunctions)\n ? fetchAllAgentFunctions(client, { logger })\n : [],\n // Fetch agentFiles\n resources.includes(TranscendPullResource.AgentFiles)\n ? fetchAllAgentFiles(client, { logger })\n : [],\n // Fetch vendors\n resources.includes(TranscendPullResource.Vendors) ? fetchAllVendors(client, { logger }) : [],\n // Fetch dataCategories\n resources.includes(TranscendPullResource.DataCategories)\n ? fetchAllDataCategories(client, { logger })\n : [],\n // Fetch dataCategories\n resources.includes(TranscendPullResource.ProcessingPurposes)\n ? fetchAllProcessingPurposes(client, { logger })\n : [],\n // Fetch actionItems\n resources.includes(TranscendPullResource.ActionItems)\n ? fetchAllActionItems(client, {\n logger,\n filterBy: { type: [ActionItemCode.Onboarding] },\n })\n : [],\n // Fetch actionItemCollections\n resources.includes(TranscendPullResource.ActionItemCollections)\n ? fetchAllActionItemCollections(client, { logger })\n : [],\n // Fetch teams\n resources.includes(TranscendPullResource.Teams) ? fetchAllTeams(client, { logger }) : [],\n // Fetch policies\n resources.includes(TranscendPullResource.Policies) ? fetchAllPolicies(client, { logger }) : [],\n // Fetch privacy centers\n resources.includes(TranscendPullResource.PrivacyCenters)\n ? fetchAllPrivacyCenters(client, { logger })\n : [],\n // Fetch messages\n resources.includes(TranscendPullResource.Messages) ? fetchAllMessages(client, { logger }) : [],\n // Fetch partitions\n resources.includes(TranscendPullResource.Partitions) ? fetchPartitions(client, { logger }) : [],\n // Fetch assessments\n resources.includes(TranscendPullResource.Assessments)\n ? fetchAllAssessments(client, { logger })\n : [],\n // Fetch assessmentTemplates\n resources.includes(TranscendPullResource.AssessmentTemplates)\n ? fetchAllAssessmentTemplates(client)\n : [],\n // Fetch purpose and preferences\n resources.includes(TranscendPullResource.Purposes)\n ? fetchAllPurposesAndPreferences(client, { logger })\n : [],\n resources.includes(TranscendPullResource.PreferenceWorkflowConfigs)\n ? fetchAllConsentWorkflowTriggers(client, { logger })\n : [],\n resources.includes(TranscendPullResource.WorkflowConfigs)\n ? fetchAllWorkflowConfigs(client, {\n logger,\n workflowConfigType: WorkflowConfigType.DSR,\n })\n : [],\n resources.includes(TranscendPullResource.PreferenceOptions)\n ? fetchAllPreferenceOptionValues(client, { logger })\n : [],\n // Fetch silo discovery results\n resources.includes(TranscendPullResource.SystemDiscovery)\n ? fetchAllSiloDiscoveryResults(client, { logger })\n : [],\n ]);\n\n const consentManagerTheme =\n resources.includes(TranscendPullResource.ConsentManager) && consentManager\n ? await fetchConsentManagerTheme(client, {\n logger,\n filterBy: { airgapBundleId: consentManager.id },\n })\n : undefined;\n\n const result: TranscendInput = {};\n\n // Save API keys\n const apiKeyTitles = flatten(dataSilos.map(([{ apiKeys }]) => apiKeys.map(({ title }) => title)));\n const relevantApiKeys = Object.values(apiKeyTitleMap).filter(({ title }) =>\n resources.includes(TranscendPullResource.ApiKeys) ? true : apiKeyTitles.includes(title),\n );\n if (relevantApiKeys.length > 0 && resources.includes(TranscendPullResource.ApiKeys)) {\n result['api-keys'] = relevantApiKeys.map(\n ({ title }): ApiKeyInput => ({\n title,\n }),\n );\n }\n\n // Save Partitions\n if (partitions.length > 0 && resources.includes(TranscendPullResource.Partitions)) {\n result.partitions = partitions.map(({ name, partition }) => ({\n name,\n partition,\n }));\n }\n\n // Save Consent Manager\n if (consentManager && resources.includes(TranscendPullResource.ConsentManager)) {\n result['consent-manager'] = {\n bundleUrls: {\n TEST: consentManager.testBundleURL,\n PRODUCTION: consentManager.bundleURL,\n },\n domains: consentManager.configuration.domains || undefined,\n partition: consentManager.configuration.partition || undefined,\n consentPrecedence: consentManager.configuration.consentPrecedence || undefined,\n unknownRequestPolicy: consentManager.configuration.unknownRequestPolicy || undefined,\n unknownCookiePolicy: consentManager.configuration.unknownCookiePolicy || undefined,\n syncEndpoint: consentManager.configuration.syncEndpoint || undefined,\n telemetryPartitioning: consentManager.configuration.telemetryPartitioning || undefined,\n signedIabAgreement: consentManager.configuration.signedIabAgreement || undefined,\n // TODO: https://transcend.height.app/T-23919 - reconsider simpler yml shape\n syncGroups: consentManager.configuration.syncGroups || undefined,\n theme: !consentManagerTheme\n ? undefined\n : {\n primaryColor: consentManagerTheme.primaryColor || undefined,\n fontColor: consentManagerTheme.fontColor || undefined,\n privacyPolicy: consentManagerTheme.privacyPolicy || undefined,\n prompt: consentManagerTheme.prompt,\n },\n experiences: consentManagerExperiences.map((experience) => ({\n name: experience.name,\n displayName: experience.displayName || undefined,\n regions: experience.regions.map((region) => ({\n countrySubDivision: region.countrySubDivision || undefined,\n country: region.country || undefined,\n })),\n onConsentExpiry: experience.onConsentExpiry,\n consentExpiry: experience.consentExpiry,\n operator: experience.operator,\n displayPriority: experience.displayPriority,\n viewState: experience.viewState,\n purposes: experience.purposes.map((purpose) => ({\n trackingType: purpose.trackingType,\n })),\n optedOutPurposes: experience.optedOutPurposes.map((purpose) => ({\n trackingType: purpose.trackingType,\n })),\n browserLanguages: experience.browserLanguages,\n browserTimeZones: experience.browserTimeZones,\n consentUiVariantSlug: experience.consentUiVariant?.slug,\n })),\n consentVariants: consentVariants.map(\n (variant): ConsentVariantInput => ({\n id: variant.id,\n name: variant.name,\n slug: variant.slug,\n // Backend returns null when unset; omit from yaml rather than writing null\n description: variant.description || undefined,\n configuration: JSON.stringify(variant.configuration),\n locales: variant.locales as LocaleValue[],\n status: variant.status,\n userFlow: variant.userFlow || undefined,\n themeSlug: variant.theme?.slug || undefined,\n }),\n ),\n consentThemes: consentThemes.map(\n (theme): ConsentThemeInput => ({\n id: theme.id,\n name: theme.name,\n slug: theme.slug,\n configuration: JSON.stringify(theme.configuration),\n }),\n ),\n };\n }\n\n // Save assessments\n if (assessments.length > 0 && resources.includes(TranscendPullResource.Assessments)) {\n result.assessments = assessments.map(\n ({\n title,\n assessmentGroup,\n sections,\n creator,\n description,\n status,\n assignees,\n externalAssignees,\n reviewers,\n isLocked,\n isArchived,\n isExternallyCreated,\n dueDate,\n createdAt,\n assignedAt,\n submittedAt,\n approvedAt,\n rejectedAt,\n titleIsInternal,\n retentionSchedule,\n attributeValues,\n resources,\n syncedRows,\n }): AssessmentInput => ({\n title,\n group: assessmentGroup.title,\n sections: sections.map(\n ({\n title,\n status,\n questions,\n assignees,\n isReviewed,\n externalAssignees,\n }): AssessmentSectionInput => ({\n title,\n status,\n questions: questions.map(\n ({\n title,\n type,\n subType,\n placeholder,\n description,\n isRequired,\n referenceId,\n displayLogic,\n riskLogic,\n riskCategories,\n riskFramework,\n answerOptions,\n selectedAnswers,\n allowedMimeTypes,\n allowSelectOther,\n syncModel,\n syncColumn,\n attributeKey,\n requireRiskEvaluation,\n requireRiskMatrixEvaluation,\n }): AssessmentSectionQuestionInput => {\n const displayLogicParsed = displayLogic\n ? parseAssessmentDisplayLogic(displayLogic)\n : undefined;\n return {\n title,\n type,\n 'sub-type': subType,\n placeholder,\n description,\n 'is-required': isRequired,\n 'reference-id': referenceId,\n 'display-logic':\n displayLogicParsed && Object.keys(displayLogicParsed).length > 0\n ? {\n action: displayLogicParsed.action!,\n rule: displayLogicParsed.rule\n ? {\n 'depends-on-question-reference-id':\n displayLogicParsed.rule.dependsOnQuestionReferenceId,\n 'comparison-operator': displayLogicParsed.rule.comparisonOperator,\n 'comparison-operands':\n // Safely access property with a check\n 'comparisonOperands' in displayLogicParsed.rule\n ? displayLogicParsed.rule.comparisonOperands\n : undefined,\n }\n : undefined,\n 'nested-rule': displayLogicParsed.nestedRule\n ? {\n 'logic-operator': displayLogicParsed.nestedRule.logicOperator,\n rules: (displayLogicParsed.nestedRule.rules || []).map(\n (rule: AssessmentRule) => ({\n 'depends-on-question-reference-id':\n rule.dependsOnQuestionReferenceId,\n 'comparison-operator': rule.comparisonOperator,\n 'comparison-operands':\n // Safely access property on the nested rule\n 'comparisonOperands' in rule\n ? rule.comparisonOperands\n : undefined,\n }),\n ),\n }\n : undefined,\n }\n : undefined,\n 'risk-logic': riskLogic.map((logic): RiskLogicInput => {\n const parsed = parseAssessmentRiskLogic(logic);\n return {\n 'risk-level': parsed.riskAssignment?.riskLevelId,\n 'comparison-operands': parsed.comparisonOperands,\n 'comparison-operator': parsed.comparisonOperator,\n };\n }),\n 'risk-categories': riskCategories.map(({ title }) => title),\n 'risk-framework': riskFramework?.title,\n 'answer-options': answerOptions.map(({ value }) => ({\n value,\n })),\n 'selected-answers': selectedAnswers.map(({ value }) => value),\n 'allowed-mime-types': allowedMimeTypes,\n 'allow-select-other': allowSelectOther,\n 'sync-model': syncModel || undefined,\n 'sync-column': syncColumn || undefined,\n 'attribute-key': attributeKey?.name,\n 'require-risk-evaluation': requireRiskEvaluation,\n 'require-risk-matrix-evaluation': requireRiskMatrixEvaluation,\n };\n },\n ),\n assignees: assignees.map(({ email }) => email),\n 'external-assignees': externalAssignees.map(({ email }) => email),\n 'is-reviewed': isReviewed,\n }),\n ),\n creator: creator?.email,\n description,\n status,\n assignees: assignees.map(({ email }) => email),\n 'external-assignees': externalAssignees.map(({ email }) => email),\n reviewers: reviewers.map(({ email }) => email),\n locked: isLocked,\n archived: isArchived,\n external: isExternallyCreated,\n 'title-is-internal': titleIsInternal,\n 'due-date': dueDate || undefined,\n 'created-at': createdAt || undefined,\n 'assigned-at': assignedAt || undefined,\n 'submitted-at': submittedAt || undefined,\n 'approved-at': approvedAt || undefined,\n 'rejected-at': rejectedAt || undefined,\n 'retention-schedule': retentionSchedule\n ? {\n type: retentionSchedule.type,\n 'duration-days': retentionSchedule.durationDays,\n operand: retentionSchedule.operation,\n }\n : undefined,\n attributes:\n attributeValues !== undefined && attributeValues.length > 0\n ? formatAttributeValues(attributeValues)\n : undefined,\n resources: resources.map(({ resourceType, title, name, category, type, purpose }) => ({\n type: resourceType,\n title: category\n ? `${category} - ${name}`\n : purpose\n ? `${purpose} - ${name}`\n : title || name || type || '',\n })),\n rows: syncedRows.map(({ resourceType, title, name, category, type, purpose }) => ({\n type: resourceType,\n title: category\n ? `${category} - ${name}`\n : purpose\n ? `${purpose} - ${name}`\n : title || name || type || '',\n })),\n }),\n );\n }\n\n // Save assessmentTemplates\n if (\n assessmentTemplates.length > 0 &&\n resources.includes(TranscendPullResource.AssessmentTemplates)\n ) {\n result['assessment-templates'] = assessmentTemplates.map(\n ({\n title,\n description,\n sections,\n status,\n source,\n creator,\n isLocked,\n isArchived,\n createdAt,\n retentionSchedule,\n }): AssessmentTemplateInput => ({\n title,\n description,\n sections: sections.map(\n ({ title, questions }): AssessmentSectionInput => ({\n title,\n questions: questions.map(\n ({\n title,\n type,\n subType,\n placeholder,\n description,\n isRequired,\n referenceId,\n displayLogic,\n riskLogic,\n riskCategories,\n riskFramework,\n answerOptions,\n allowedMimeTypes,\n allowSelectOther,\n syncModel,\n syncColumn,\n attributeKey,\n requireRiskEvaluation,\n requireRiskMatrixEvaluation,\n }): AssessmentSectionQuestionInput => {\n const displayLogicParsed = displayLogic\n ? parseAssessmentDisplayLogic(displayLogic)\n : undefined;\n return {\n title,\n type,\n 'sub-type': subType,\n placeholder,\n description,\n 'is-required': isRequired,\n 'reference-id': referenceId,\n 'display-logic':\n displayLogicParsed && Object.keys(displayLogicParsed).length > 0\n ? {\n action: displayLogicParsed.action!,\n rule: displayLogicParsed.rule\n ? {\n 'depends-on-question-reference-id':\n displayLogicParsed.rule.dependsOnQuestionReferenceId,\n 'comparison-operator': displayLogicParsed.rule.comparisonOperator,\n 'comparison-operands':\n // Safely access property with a check\n 'comparisonOperands' in displayLogicParsed.rule\n ? displayLogicParsed.rule.comparisonOperands\n : undefined,\n }\n : undefined,\n 'nested-rule': displayLogicParsed.nestedRule\n ? {\n 'logic-operator': displayLogicParsed.nestedRule.logicOperator,\n rules: (displayLogicParsed.nestedRule.rules || []).map(\n (rule: AssessmentRule) => ({\n 'depends-on-question-reference-id':\n rule.dependsOnQuestionReferenceId,\n 'comparison-operator': rule.comparisonOperator,\n 'comparison-operands':\n // Safely access property on the nested rule\n 'comparisonOperands' in rule\n ? rule.comparisonOperands\n : undefined,\n }),\n ),\n }\n : undefined,\n }\n : undefined,\n 'risk-logic': riskLogic.map((logic): RiskLogicInput => {\n const parsed = parseAssessmentRiskLogic(logic);\n return {\n 'risk-level': parsed.riskAssignment?.riskLevelId,\n 'risk-matrix-row': parsed.riskAssignment?.riskMatrixRowId,\n 'risk-matrix-column': parsed.riskAssignment?.riskMatrixColumnId,\n 'comparison-operands': parsed.comparisonOperands,\n 'comparison-operator': parsed.comparisonOperator,\n };\n }),\n 'risk-categories': riskCategories.map(({ title }) => title),\n 'risk-framework': riskFramework?.title,\n 'answer-options': answerOptions.map(({ value }) => ({\n value,\n })),\n 'allowed-mime-types': allowedMimeTypes,\n 'allow-select-other': allowSelectOther,\n 'sync-model': syncModel || undefined,\n 'sync-column': syncColumn || undefined,\n 'attribute-key': attributeKey?.name,\n 'require-risk-evaluation': requireRiskEvaluation,\n 'require-risk-matrix-evaluation': requireRiskMatrixEvaluation,\n };\n },\n ),\n }),\n ),\n status,\n source,\n creator: creator?.email,\n locked: isLocked,\n archived: isArchived,\n 'created-at': createdAt || undefined,\n 'retention-schedule': retentionSchedule\n ? {\n type: retentionSchedule.type,\n 'duration-days': retentionSchedule.durationDays,\n operand: retentionSchedule.operation,\n }\n : undefined,\n }),\n );\n }\n\n // Save Silo Discovery Results\n if (\n siloDiscoveryResults.length > 0 &&\n resources.includes(TranscendPullResource.SystemDiscovery)\n ) {\n result['system-discovery'] = siloDiscoveryResults.map(\n ({\n title,\n resourceId,\n suggestedCatalog: { title: suggestedCatalogTitle },\n plugin: {\n dataSilo: { title: dataSiloTitle },\n },\n country,\n countrySubDivision,\n plaintextContext,\n containsSensitiveData,\n status,\n }): SiloDiscoveryResultInput => ({\n title,\n resourceId,\n suggestedCatalog: suggestedCatalogTitle,\n plugin: dataSiloTitle,\n country: country || undefined,\n countrySubDivision: countrySubDivision || undefined,\n plaintextContext,\n containsSensitiveData,\n status,\n }),\n );\n }\n\n // Save prompts\n if (prompts.length > 0 && resources.includes(TranscendPullResource.Prompts)) {\n result.prompts = prompts.map(\n ({ title, content }): PromptInput => ({\n title,\n content,\n }),\n );\n }\n\n // Save promptPartials\n if (promptPartials.length > 0 && resources.includes(TranscendPullResource.PromptPartials)) {\n result['prompt-partials'] = promptPartials.map(\n ({ title, content }): PromptPartialInput => ({\n title,\n content,\n }),\n );\n }\n\n // Save promptGroups\n if (promptGroups.length > 0 && resources.includes(TranscendPullResource.PromptGroups)) {\n result['prompt-groups'] = promptGroups.map(\n ({ title, description, prompts }): PromptGroupInput => ({\n title,\n description,\n prompts: prompts.map(({ title }) => title),\n }),\n );\n }\n\n // Save teams\n if (teams.length > 0 && resources.includes(TranscendPullResource.Teams)) {\n result.teams = teams.map(\n ({\n name,\n description,\n ssoDepartment,\n ssoGroup,\n ssoTitle,\n users,\n scopes,\n parentTeam,\n }): TeamInput => ({\n name,\n description,\n 'sso-department': ssoDepartment || undefined,\n 'sso-group': ssoGroup || undefined,\n 'sso-title': ssoTitle || undefined,\n 'parent-team-name': parentTeam?.name,\n users: users.map(({ email }) => email),\n scopes: scopes.map(({ name }) => name),\n }),\n );\n }\n\n // Save Data Subjects\n if (dataSubjects.length > 0 && resources.includes(TranscendPullResource.DataSubjects)) {\n result['data-subjects'] = dataSubjects.map(\n ({\n type,\n title,\n active,\n adminDashboardDefaultSilentMode,\n supportsAuthorizedAgent,\n actions,\n }): DataSubjectInput => ({\n type,\n title: title?.defaultMessage,\n active,\n adminDashboardDefaultSilentMode,\n supportsAuthorizedAgent,\n actions: actions.map(({ type }) => type),\n }),\n );\n }\n\n // Save privacy policies\n if (policies.length > 0) {\n result.policies = policies.map(\n ({ title, type, versions, disabledLocales }): PolicyInput => ({\n title: title?.defaultMessage,\n type,\n content: versions?.[0]?.content?.defaultMessage,\n disabledLocales,\n }),\n );\n }\n\n // Save messages\n if (messages.length > 0) {\n result.messages = messages.map(\n ({ id, defaultMessage, targetReactIntlId, description, translations }): IntlMessageInput => ({\n id,\n defaultMessage,\n description,\n targetReactIntlId: targetReactIntlId || undefined,\n translations: translations.reduce(\n (acc, { locale, value }) => Object.assign(acc, { [locale]: value }),\n {} as Record<LocaleValue, string>,\n ),\n }),\n );\n }\n\n // Save privacy center\n if (privacyCenters.length > 0) {\n const privacyCenter = privacyCenters[0];\n result['privacy-center'] = {\n isDisabled: privacyCenter.isDisabled,\n showPrivacyRequestButton: privacyCenter.showPrivacyRequestButton,\n showPolicies: privacyCenter.showPolicies,\n showTrackingTechnologies: privacyCenter.showTrackingTechnologies,\n showCookies: privacyCenter.showCookies,\n showDataFlows: privacyCenter.showDataFlows,\n showConsentManager: privacyCenter.showConsentManager,\n showManageYourPrivacy: privacyCenter.showManageYourPrivacy,\n showMarketingPreferences: privacyCenter.showMarketingPreferences,\n locales: privacyCenter.locales,\n defaultLocale: privacyCenter.defaultLocale,\n preferBrowserDefaultLocale: privacyCenter.preferBrowserDefaultLocale,\n supportEmail: privacyCenter.supportEmail || undefined,\n replyToEmail: privacyCenter.replyToEmail || undefined,\n useNoReplyEmailAddress: privacyCenter.useNoReplyEmailAddress,\n useCustomEmailDomain: privacyCenter.useCustomEmailDomain,\n transformAccessReportJsonToCsv: privacyCenter.transformAccessReportJsonToCsv,\n home: privacyCenter.home || undefined,\n expandSideMenuByDefault: privacyCenter.expandSideMenuByDefault,\n workflowsCustomFieldsRequired: privacyCenter.workflowsCustomFieldsRequired,\n footerLayout: privacyCenter.footerLayout,\n ...(privacyCenter.childOrganizations.length > 0\n ? {\n displayedChildOrganizationUris: privacyCenter.childOrganizations.map(\n (child) => child.uri,\n ),\n }\n : {}),\n ...(privacyCenter.footerLinks.length > 0\n ? {\n footerLinks: [...privacyCenter.footerLinks]\n .sort((a, b) => a.displayOrder - b.displayOrder)\n .map((link) => ({\n title: link.title.defaultMessage,\n ...(link.url ? { url: link.url } : {}),\n ...(link.iconOnly ? { iconOnly: link.iconOnly } : {}),\n })),\n }\n : {}),\n theme: privacyCenter.theme,\n };\n }\n\n // Save business entities\n if (businessEntities.length > 0 && resources.includes(TranscendPullResource.BusinessEntities)) {\n result['business-entities'] = businessEntities.map(\n ({\n title,\n description,\n address,\n headquarterCountry,\n headquarterSubDivision,\n dataProtectionOfficerName,\n dataProtectionOfficerEmail,\n attributeValues,\n }): BusinessEntityInput => ({\n title,\n description: description || undefined,\n address: address || undefined,\n headquarterCountry: headquarterCountry || undefined,\n headquarterSubDivision: headquarterSubDivision || undefined,\n dataProtectionOfficerName: dataProtectionOfficerName || undefined,\n dataProtectionOfficerEmail: dataProtectionOfficerEmail || undefined,\n attributes:\n attributeValues !== undefined && attributeValues.length > 0\n ? formatAttributeValues(attributeValues)\n : undefined,\n }),\n );\n }\n\n // Save processing activities\n if (\n processingActivities.length > 0 &&\n resources.includes(TranscendPullResource.ProcessingActivities)\n ) {\n result['processing-activities'] = processingActivities.map(\n ({\n title,\n description,\n securityMeasureDetails,\n controllerships,\n storageRegions,\n transferRegions,\n retentionType,\n retentionPeriod,\n dataProtectionImpactAssessmentLink,\n dataProtectionImpactAssessmentStatus,\n attributeValues,\n dataSilos,\n dataSubjects,\n teams,\n owners,\n processingPurposeSubCategories,\n dataSubCategories,\n saaSCategories,\n }): ProcessingActivityInput => ({\n title,\n description,\n securityMeasureDetails: securityMeasureDetails ?? undefined,\n controllerships: controllerships.length > 0 ? controllerships : undefined,\n storageRegions: storageRegions.length > 0 ? formatRegions(storageRegions) : undefined,\n transferRegions: transferRegions.length > 0 ? formatRegions(transferRegions) : undefined,\n retentionType,\n retentionPeriod: retentionType === RetentionType.StatedPeriod ? retentionPeriod : undefined,\n dataProtectionImpactAssessmentLink: dataProtectionImpactAssessmentLink ?? undefined,\n dataProtectionImpactAssessmentStatus,\n attributes:\n attributeValues !== undefined && attributeValues.length > 0\n ? formatAttributeValues(attributeValues)\n : undefined,\n dataSiloTitles: dataSilos.length > 0 ? dataSilos.map(({ title }) => title) : undefined,\n dataSubjectTypes:\n dataSubjects.length > 0 ? dataSubjects.map(({ type }) => type) : undefined,\n teamNames: teams.length > 0 ? teams.map(({ name }) => name) : undefined,\n ownerEmails: owners.length > 0 ? owners.map(({ email }) => email) : undefined,\n processingSubPurposes:\n processingPurposeSubCategories.length > 0\n ? processingPurposeSubCategories.map(({ name, purpose }) => ({\n purpose,\n ...(name ? { name } : {}),\n }))\n : undefined,\n dataSubCategories:\n dataSubCategories.length > 0\n ? dataSubCategories.map(({ name, category }) => ({\n category,\n ...(name ? { name } : {}),\n }))\n : undefined,\n saaSCategories:\n saaSCategories.length > 0 ? saaSCategories.map(({ title }) => title) : undefined,\n }),\n );\n }\n\n // Save Actions\n if (actions.length > 0 && resources.includes(TranscendPullResource.Actions)) {\n result.actions = actions.map(\n ({\n type,\n skipSecondaryIfNoFiles,\n skipDownloadableStep,\n requiresReview,\n regionList,\n regionDetectionMethod,\n waitingPeriod,\n }): ActionInput => ({\n type,\n ...(type === RequestAction.Erasure\n ? {\n skipSecondaryIfNoFiles,\n skipDownloadableStep,\n }\n : {}),\n requiresReview,\n waitingPeriod,\n regionDetectionMethod,\n regionList: regionList.length > 0 ? regionList : undefined,\n }),\n );\n }\n\n // Save identifiers\n if (identifiers.length > 0 && resources.includes(TranscendPullResource.Identifiers)) {\n result.identifiers = identifiers.map(\n ({\n name,\n type,\n regex,\n selectOptions,\n privacyCenterVisibility,\n isRequiredInForm,\n placeholder,\n displayTitle,\n dataSubjects,\n displayDescription,\n displayOrder,\n isUniqueOnPreferenceStore,\n }): IdentifierInput => ({\n name,\n type,\n regex,\n selectOptions: selectOptions.length > 0 ? selectOptions : undefined,\n privacyCenterVisibility:\n privacyCenterVisibility.length > 0 ? privacyCenterVisibility : undefined,\n isRequiredInForm,\n placeholder: placeholder || undefined,\n dataSubjects: dataSubjects.length > 0 ? dataSubjects.map(({ type }) => type) : undefined,\n displayTitle: displayTitle?.defaultMessage,\n displayDescription: displayDescription?.defaultMessage,\n displayOrder,\n isUniqueOnPreferenceStore,\n }),\n );\n }\n\n // Save agents\n if (agents.length > 0 && resources.includes(TranscendPullResource.Agents)) {\n result.agents = agents.map(\n ({\n name,\n agentId,\n description,\n instructions,\n codeInterpreterEnabled,\n retrievalEnabled,\n prompt,\n largeLanguageModel,\n teams,\n owners,\n agentFunctions,\n agentFiles,\n }): AgentInput => ({\n name,\n agentId,\n description: description || undefined,\n instructions,\n codeInterpreterEnabled,\n retrievalEnabled,\n prompt: prompt?.title,\n 'large-language-model': {\n name: largeLanguageModel.name,\n client: largeLanguageModel.client,\n },\n teams: teams && teams.length > 0 ? teams.map(({ name }) => name) : undefined,\n owners: owners && owners.length > 0 ? owners.map(({ email }) => email) : undefined,\n 'agent-functions':\n agentFunctions && agentFunctions.length > 0\n ? agentFunctions.map(({ name }) => name)\n : undefined,\n 'agent-files':\n agentFiles && agentFiles.length > 0 ? agentFiles.map(({ name }) => name) : undefined,\n }),\n );\n }\n\n // Save action items\n if (actionItems.length > 0 && resources.includes(TranscendPullResource.ActionItems)) {\n result['action-items'] = actionItems.map(\n ({\n teams,\n users,\n customerExperienceActionItemIds: [customerExperienceActionItemId],\n dueDate,\n priority,\n resolved,\n collections,\n notes,\n link,\n title,\n type,\n attributeValues,\n }): ActionItemInput => ({\n teams: teams.map(({ name }) => name),\n users: users.map(({ email }) => email),\n dueDate: dueDate || undefined,\n title,\n notes,\n customerExperienceActionItemId,\n collections: collections.map(({ title }) => title),\n link,\n priority: priority || undefined,\n resolved,\n type,\n attributes:\n attributeValues !== undefined && attributeValues.length > 0\n ? formatAttributeValues(attributeValues)\n : undefined,\n }),\n );\n }\n\n // Save action item collections\n if (\n actionItemCollections.length > 0 &&\n resources.includes(TranscendPullResource.ActionItemCollections)\n ) {\n result['action-item-collections'] = actionItemCollections.map(\n ({ title, description, hidden, productLine }): ActionItemCollectionInput => ({\n title,\n description: description || undefined,\n hidden,\n productLine,\n }),\n );\n }\n\n // Save agent functions\n if (agentFunctions.length > 0 && resources.includes(TranscendPullResource.AgentFunctions)) {\n result['agent-functions'] = agentFunctions.map(\n ({ name, description, parameters }): AgentFunctionInput => ({\n name,\n description,\n parameters: JSON.stringify(parameters),\n }),\n );\n }\n\n // Save agent files\n if (agentFiles.length > 0 && resources.includes(TranscendPullResource.AgentFiles)) {\n result['agent-files'] = agentFiles.map(\n ({ name, description, fileId, size, purpose }): AgentFileInput => ({\n name,\n description,\n fileId,\n size,\n purpose,\n }),\n );\n }\n\n // Save vendors\n if (vendors.length > 0 && resources.includes(TranscendPullResource.Vendors)) {\n result.vendors = vendors.map(\n ({\n title,\n description,\n dataProcessingAgreementLink,\n contactName,\n contactPhone,\n address,\n headquarterCountry,\n headquarterSubDivision,\n websiteUrl,\n businessEntity,\n teams,\n owners,\n attributeValues,\n }): VendorInput => ({\n title,\n description: description || undefined,\n dataProcessingAgreementLink: dataProcessingAgreementLink || undefined,\n contactName: contactName || undefined,\n contactPhone: contactPhone || undefined,\n address: address || undefined,\n headquarterCountry: headquarterCountry || undefined,\n headquarterSubDivision: headquarterSubDivision || undefined,\n websiteUrl: websiteUrl || undefined,\n businessEntity: businessEntity?.title,\n teams: teams && teams.length > 0 ? teams.map(({ name }) => name) : undefined,\n owners: owners && owners.length > 0 ? owners.map(({ email }) => email) : undefined,\n attributes:\n attributeValues !== undefined && attributeValues.length > 0\n ? formatAttributeValues(attributeValues)\n : undefined,\n }),\n );\n }\n\n // Save data categories\n if (dataCategories.length > 0 && resources.includes(TranscendPullResource.DataCategories)) {\n result['data-categories'] = dataCategories.map(\n ({\n name,\n category,\n description,\n regex,\n owners,\n teams,\n attributeValues,\n }): DataCategoryInput => ({\n name,\n category,\n description: description || undefined,\n regex: regex || undefined,\n owners: owners && owners.length > 0 ? owners.map(({ email }) => email) : undefined,\n teams: teams && teams.length > 0 ? teams.map(({ name }) => name) : undefined,\n attributes:\n attributeValues !== undefined && attributeValues.length > 0\n ? formatAttributeValues(attributeValues)\n : undefined,\n }),\n );\n }\n\n // Save processing purposes\n if (\n processingPurposes.length > 0 &&\n resources.includes(TranscendPullResource.ProcessingPurposes)\n ) {\n result['processing-purposes'] = processingPurposes.map(\n ({ name, purpose, description, owners, teams, attributeValues }): ProcessingPurposeInput => ({\n name,\n purpose,\n description: description || undefined,\n owners: owners && owners.length > 0 ? owners.map(({ email }) => email) : undefined,\n teams: teams && teams.length > 0 ? teams.map(({ name }) => name) : undefined,\n attributes:\n attributeValues !== undefined && attributeValues.length > 0\n ? formatAttributeValues(attributeValues)\n : undefined,\n }),\n );\n }\n\n // Save data flows\n if (dataFlows.length > 0 && resources.includes(TranscendPullResource.DataFlows)) {\n result['data-flows'] = dataFlows.map(\n ({\n value,\n type,\n description,\n trackingType,\n service,\n status,\n owners,\n teams,\n attributeValues,\n }): DataFlowInput => ({\n value,\n type,\n description: description || undefined,\n trackingPurposes: trackingType,\n status,\n service: service?.integrationName,\n owners: owners.map(({ email }) => email),\n teams: teams.map(({ name }) => name),\n attributes:\n attributeValues !== undefined && attributeValues.length > 0\n ? formatAttributeValues(attributeValues)\n : undefined,\n }),\n );\n }\n\n // Save cookies\n if (cookies.length > 0 && resources.includes(TranscendPullResource.Cookies)) {\n result.cookies = cookies.map(\n ({\n name,\n isRegex,\n description,\n trackingPurposes,\n service,\n status,\n owners,\n teams,\n attributeValues,\n }): CookieInput => ({\n name,\n isRegex,\n description: description || undefined,\n trackingPurposes,\n status,\n service: service?.integrationName,\n owners: owners.map(({ email }) => email),\n teams: teams.map(({ name }) => name),\n attributes:\n attributeValues !== undefined && attributeValues.length > 0\n ? formatAttributeValues(attributeValues)\n : undefined,\n }),\n );\n }\n\n // Save attributes\n if (attributes.length > 0 && resources.includes(TranscendPullResource.Attributes)) {\n result.attributes = attributes.map(\n ({ description, name, type, values, enabledOn = [] }): AttributeInput => ({\n description: description || undefined,\n resources: enabledOn,\n name,\n type,\n values: values.map(({ name, color, description }) => ({\n name,\n color: color || undefined,\n description,\n })),\n }),\n );\n }\n\n // save purposes\n if (purposes.length > 0) {\n result.purposes = purposes.map(\n ({\n name,\n description,\n trackingType,\n defaultConsent,\n configurable,\n showInConsentManager,\n isActive,\n displayOrder,\n optOutSignals,\n authLevel,\n topics,\n showInPrivacyCenter,\n title,\n }): ConsentPurpose => ({\n name,\n title,\n description: description || undefined,\n trackingType,\n 'default-consent': defaultConsent,\n configurable,\n 'show-in-consent-manager': showInConsentManager,\n 'show-in-privacy-center': showInPrivacyCenter,\n 'is-active': isActive,\n 'display-order': displayOrder,\n 'opt-out-signals': optOutSignals.length > 0 ? optOutSignals : undefined,\n 'auth-level': authLevel || undefined,\n 'preference-topics': topics.map(\n ({\n slug,\n title,\n type,\n color,\n displayDescription,\n defaultConfiguration,\n showInPrivacyCenter,\n preferenceOptionValues,\n }): ConsentPreferenceTopic => ({\n slug,\n title: title.defaultMessage,\n type,\n color,\n description: displayDescription.defaultMessage,\n 'default-configuration': defaultConfiguration,\n 'show-in-privacy-center': showInPrivacyCenter,\n options:\n type === PreferenceTopicType.Boolean\n ? []\n : preferenceOptionValues.map(({ title, slug }) => ({\n title: title.defaultMessage,\n slug,\n })),\n }),\n ),\n }),\n );\n }\n\n if (workflowConfigs.length > 0 && resources.includes(TranscendPullResource.WorkflowConfigs)) {\n const pulledWorkflowConfigs = workflowConfigs.map(\n (config): WorkflowConfigInput => ({\n title: config.title.defaultMessage,\n 'action-type': config.action.type,\n ...(config.internalName ? { 'internal-name': config.internalName } : {}),\n ...(config.subtitle ? { subtitle: config.subtitle.defaultMessage } : {}),\n ...(config.description ? { description: config.description.defaultMessage } : {}),\n ...(config.subject ? { 'data-subject-type': config.subject.type } : {}),\n visibility: config.workflowConfigVisibility,\n type: config.workflowConfigType,\n ...(config.collectDataSubjectRegions\n ? {\n 'collect-data-subject-regions': config.collectDataSubjectRegions,\n }\n : {}),\n ...(config.regionList.length > 0 ? { 'region-list': config.regionList } : {}),\n ...(config.expiryTime && config.expiryTime.length > 0\n ? { 'expiry-time': config.expiryTime }\n : {}),\n ...(config.WorkflowConfigAttributeKeys && config.WorkflowConfigAttributeKeys.length > 0\n ? {\n 'attribute-keys': config.WorkflowConfigAttributeKeys.map(\n ({ attributeKey }) => attributeKey.name,\n ),\n }\n : {}),\n }),\n );\n // TODO: https://linear.app/transcend/issue/WAL-10312 - remove once internalName is unique in DB\n const configsByMatchKey = groupBy(workflowConfigs, workflowConfigMatchKey);\n for (const configs of Object.values(configsByMatchKey)) {\n if (configs.length > 1) {\n const sample = configs[0];\n logger.warn(\n `Found \"${configs.length}\" workflow configs with the same title, action-type, ` +\n `data-subject-type, and region-list for \"${sample.title.defaultMessage}\" ` +\n `(${sample.action.type}). Push will fail until they are disambiguated ` +\n '(for example with unique internal names).',\n );\n }\n }\n if (pulledWorkflowConfigs.length > 0) {\n result['workflow-configs'] = pulledWorkflowConfigs;\n }\n }\n\n if (\n preferenceWorkflowConfigs.length > 0 &&\n resources.includes(TranscendPullResource.PreferenceWorkflowConfigs)\n ) {\n const needsWorkflowTitles = preferenceWorkflowConfigs.some(\n (trigger) => trigger.workflowConfigId,\n );\n const dsrWorkflows = needsWorkflowTitles\n ? await fetchAllWorkflowConfigs(client, {\n logger,\n workflowConfigType: WorkflowConfigType.DSR,\n })\n : [];\n\n result['preference-workflow-configs'] = preferenceWorkflowConfigs.map(\n (trigger): PreferenceWorkflowConfigInput => {\n const purposes = parsePurposesFromTriggerCondition(trigger.triggerCondition);\n const shared = {\n name: trigger.name,\n 'data-subject-type': trigger.subject.type,\n 'is-silent': trigger.isSilent,\n 'allow-unauthenticated': trigger.allowUnauthenticated,\n 'is-active': trigger.isActive,\n purposes,\n };\n\n if (trigger.workflowConfigId) {\n const workflowTitle = resolveWorkflowTitleFromId(dsrWorkflows, trigger.workflowConfigId);\n if (workflowTitle) {\n return {\n ...shared,\n 'workflow-title': workflowTitle,\n };\n }\n // Workflow deleted or unreadable — fall back to legacy fields so YAML stays usable\n }\n\n return {\n ...shared,\n 'action-type': trigger.action.type,\n 'data-silo-titles':\n trigger.dataSilos.length > 0 ? trigger.dataSilos.map((ds) => ds.title) : undefined,\n };\n },\n );\n }\n\n if (\n preferenceOptionValues.length > 0 &&\n resources.includes(TranscendPullResource.PreferenceOptions)\n ) {\n result['preference-options'] = preferenceOptionValues.map(\n ({ slug, title }): ConsentPreferenceTopicOptionValue => ({\n slug,\n title: title.defaultMessage,\n }),\n );\n }\n\n // save email templates\n if (\n dataSiloIds.length === 0 &&\n templates.length > 0 &&\n resources.includes(TranscendPullResource.Templates)\n ) {\n result.templates = templates.map(({ title }) => ({ title }));\n }\n\n // Save enrichers\n if (enrichers.length > 0 && resources.includes(TranscendPullResource.Enrichers)) {\n result.enrichers = enrichers.map(\n ({\n title,\n url,\n type,\n inputIdentifier,\n identifiers,\n actions,\n testRegex,\n dataSubjects,\n expirationDuration,\n lookerQueryTitle,\n transitionRequestStatus,\n phoneNumbers,\n regionList,\n }): EnricherInput => ({\n title,\n url: url || undefined,\n type,\n 'input-identifier': inputIdentifier?.name,\n 'output-identifiers': identifiers.map(({ name }) => name),\n 'privacy-actions':\n Object.values(RequestAction).length === actions.length ? undefined : actions,\n testRegex: testRegex || undefined,\n lookerQueryTitle: lookerQueryTitle || undefined,\n expirationDuration: parseInt(expirationDuration, 10),\n transitionRequestStatus: transitionRequestStatus || undefined,\n phoneNumbers: phoneNumbers && phoneNumbers.length > 0 ? phoneNumbers : undefined,\n regionList: regionList && regionList.length > 0 ? regionList : undefined,\n 'data-subjects': dataSubjects.map(({ type }) => type),\n }),\n );\n }\n\n // Save data silos\n if (dataSilos.length > 0 && resources.includes(TranscendPullResource.DataSilos)) {\n const indexedDataSubjects = keyBy(dataSubjects, 'type');\n result['data-silos'] = dataSilos.map(\n ([\n {\n title,\n description,\n url,\n type,\n outerType,\n apiKeys,\n notifyEmailAddress,\n identifiers,\n dependentDataSilos,\n owners,\n country,\n countrySubDivision,\n teams,\n subjectBlocklist,\n isLive,\n promptAVendorEmailSendFrequency,\n promptAVendorEmailSendType,\n promptAVendorEmailIncludeIdentifiersAttachment,\n promptAVendorEmailCompletionLinkType,\n manualWorkRetryFrequency,\n catalog,\n attributeValues,\n discoveredBy,\n businessEntities,\n sombra,\n },\n dataPoints,\n ]): DataSiloInput => ({\n title,\n description,\n integrationName: type,\n 'outer-type': outerType || undefined,\n url: url || undefined,\n 'api-key-title': apiKeys[0]?.title,\n 'sombra-id': sombra?.id || undefined,\n 'identity-keys': identifiers\n .filter(({ isConnected }) => isConnected)\n .map(({ name }) => name),\n ...(dependentDataSilos.length > 0\n ? {\n 'deletion-dependencies': dependentDataSilos.map(({ title }) => title),\n }\n : {}),\n ...(owners.length > 0 ? { owners: owners.map(({ email }) => email) } : {}),\n ...(teams.length > 0 ? { teams: teams.map(({ name }) => name) } : {}),\n ...(discoveredBy.length > 0\n ? { discoveredBy: discoveredBy.map(({ title }) => title) }\n : {}),\n ...(businessEntities.length > 0\n ? {\n businessEntities: businessEntities.map(({ title }) => title),\n }\n : {}),\n country: country || undefined,\n countrySubDivision: countrySubDivision || undefined,\n disabled: !isLive,\n 'data-subjects':\n subjectBlocklist.length > 0\n ? convertToDataSubjectAllowlist(\n subjectBlocklist.map(({ type }) => type),\n indexedDataSubjects,\n )\n : undefined,\n ...(catalog.hasAvcFunctionality\n ? {\n 'email-settings': {\n 'notify-email-address': notifyEmailAddress || undefined,\n 'send-frequency': promptAVendorEmailSendFrequency,\n 'send-type': promptAVendorEmailSendType,\n 'include-identifiers-attachment': promptAVendorEmailIncludeIdentifiersAttachment,\n 'completion-link-type': promptAVendorEmailCompletionLinkType,\n 'manual-work-retry-frequency': manualWorkRetryFrequency,\n },\n }\n : {}),\n attributes:\n attributeValues !== undefined && attributeValues.length > 0\n ? formatAttributeValues(attributeValues)\n : undefined,\n\n datapoints: dataPoints\n .map(\n (dataPoint): DatapointInput => ({\n key: dataPoint.name,\n title: dataPoint.title?.defaultMessage,\n description: dataPoint.description?.defaultMessage,\n owners: dataPoint.owners.map(({ email }) => email),\n teams: dataPoint.teams.map(({ name }) => name),\n ...(dataPoint.path.length > 0 ? { path: dataPoint.path } : {}),\n ...(dataPoint.dataCollection?.title\n ? {\n 'data-collection-tag': dataPoint.dataCollection.title.defaultMessage,\n }\n : {}),\n ...(dataPoint.dbIntegrationQueries.length > 0\n ? {\n 'privacy-action-queries': mapValues(\n keyBy(dataPoint.dbIntegrationQueries, 'requestType'),\n (databaseIntegrationQuery) =>\n databaseIntegrationQuery.suggestedQuery ||\n databaseIntegrationQuery.query ||\n undefined,\n ),\n }\n : {}),\n ...(dataPoint.subDataPoints.length > 0\n ? {\n fields: dataPoint.subDataPoints\n .map(\n (field): FieldInput => ({\n key: field.name,\n description: field.description,\n purposes: field.purposes,\n categories: field.categories,\n ...(includeGuessedCategories && field.pendingCategoryGuesses\n ? {\n 'guessed-categories': field.pendingCategoryGuesses\n .filter((guess) => guess.status === 'PENDING')\n .map((guess) => ({\n category: {\n name: guess.category.name,\n category: guess.category.category,\n },\n status: guess.status,\n confidence: guess.confidence,\n classifierVersion: guess.classifierVersion || undefined,\n })),\n }\n : {}),\n 'access-request-visibility-enabled': field.accessRequestVisibilityEnabled,\n 'erasure-request-redaction-enabled': field.erasureRequestRedactionEnabled,\n attributes:\n field.attributeValues !== undefined && field.attributeValues.length > 0\n ? formatAttributeValues(field.attributeValues)\n : undefined,\n }),\n )\n .sort((a, b) => a.key.localeCompare(b.key)),\n }\n : {}),\n 'privacy-actions': dataPoint.actionSettings\n .filter(({ active }) => active)\n .map(({ type }) => type),\n }),\n )\n .sort((a, b) =>\n [...(a.path ?? []), a.key]\n .join('.')\n .localeCompare([...(b.path ?? []), b.key].join('.')),\n ),\n }),\n );\n }\n return result;\n}\n/* eslint-enable max-lines */\n"],"mappings":"wuDAUA,MAAa,EAAuB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAmD3B,EAA0B;;;;;ECJtC,eAAsB,EACpB,EAC+B,CAC/B,IAAM,EAA4C,EAAE,CAChD,EAAS,EAET,EAAiB,GACrB,EAAG,CACD,GAAM,CACJ,wBAAyB,CAAE,UACzB,MAAM,EAMP,EAAQ,EAAsB,CAC/B,UAAW,CAAE,MAAO,GAAW,SAAQ,CACvC,SACD,CAAC,CACF,EAAoB,KAAK,GAAG,EAAM,CAClC,GAAU,GACV,EAAiB,EAAM,SAAW,SAC3B,GAET,OAAO,EAAoB,MAAM,EAAG,IAAM,EAAE,MAAM,cAAc,EAAE,MAAM,CAAC,CC6B3E,MAAa,EAAmC,+CAK/C,CA8BD,eAAsB,EACpB,EACA,CACE,cACA,mBACA,QACA,YAAY,EACZ,WACA,kBACA,2BACA,qBACA,kBAAkB,OAAO,OAAO,EAAqB,EAE9B,CACzB,GAAI,EAAY,OAAS,GAAK,EAAiB,OAAS,EACtD,MAAU,MAAM,4DAA4D,CAG9E,EAAO,KAAK,EAAO,QAAQ,gCAAgC,EAAS,KAAK,CAAC,CAG1E,GAAM,CACJ,EACA,GACA,EACA,EACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,EACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,EACA,GACA,GACA,GACA,EACA,EACA,GACA,IACE,MAAM,QAAQ,IAAI,CAEpB,EAAU,SAAA,YAAyC,EACnD,EAAU,SAAA,eAA4C,CAClD,EAAqB,EAAQ,CAAE,SAAQ,CAAC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,OAAO"}
|
package/dist/{pushCronIdentifiersFromCsv-BJ_6eT7L.mjs → pushCronIdentifiersFromCsv-Bp93Ba9h.mjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./constants-
|
|
2
|
-
//# sourceMappingURL=pushCronIdentifiersFromCsv-
|
|
1
|
+
import{a as e}from"./constants-CgI8_Rfc.mjs";import{t}from"./logger-B-LXIf3U.mjs";import{t as n}from"./readCsv-D1e7WRTc.mjs";import{chunk as r}from"lodash-es";import i from"colors";import*as a from"io-ts";import{createSombraGotInstance as o}from"@transcend-io/sdk";import{map as s,mapSeries as c}from"@transcend-io/utils";import l from"cli-progress";const u=a.type({nonce:a.string,identifier:a.string});async function d(e,{nonce:t,identifier:n}){try{return await e.put(`v1/data-silo`,{headers:{"x-transcend-nonce":t},json:{profiles:[{profileId:n}]}}),!0}catch(e){if(e.response?.statusCode===409)return!1;throw Error(`Received an error from server: ${e?.response?.body||e?.message}`)}}async function f({file:a,dataSiloId:f,auth:p,sombraAuth:m,concurrency:h=100,transcendUrl:g=e,sleepSeconds:_=10}){let v=await o(g,p,{logger:t,sombraApiKey:m,sombraUrl:process.env.SOMBRA_URL});t.info(i.magenta(`Reading "${a}" from disk`));let y=n(a,u);t.info(i.magenta(`Notifying Transcend for data silo "${f}" marking "${y.length}" identifiers as completed.`));let b=new Date().getTime(),x=new l.SingleBar({},l.Presets.shades_classic),S=0,C=0,w=0;x.start(y.length,0);let T=r(y,h),E=T.length;await c(T,async(e,n)=>{t.info(i.blue(`Processing chunk ${n+1}/${E} (${r.length} items)`)),await s(e,async e=>{try{await d(v,e)?S+=1:C+=1}catch(n){t.error(i.red(`Error notifying Transcend for identifier "${e.identifier}" - ${n?.message}`)),w+=1}x.update(S+C)}),_>0&&n<E-1&&(t.info(i.yellow(`Sleeping for ${_}s before next chunk...`)),await new Promise(e=>{setTimeout(e,_*1e3)}))}),x.stop();let D=new Date().getTime()-b;if(t.info(i.green(`Successfully notified Transcend for ${S} identifiers in "${D/1e3}" seconds!`)),C&&t.info(i.magenta(`There were ${C} identifiers that were not in a state to be updated.They likely have already been resolved.`)),w)throw t.error(i.red(`There were ${w} identifiers that failed to be updated. Please review the logs for more information.`)),Error(`Failed to update all identifiers`);return y.length}export{u as n,d as r,f as t};
|
|
2
|
+
//# sourceMappingURL=pushCronIdentifiersFromCsv-Bp93Ba9h.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushCronIdentifiersFromCsv-
|
|
1
|
+
{"version":3,"file":"pushCronIdentifiersFromCsv-Bp93Ba9h.mjs","names":[],"sources":["../src/lib/cron/markCronIdentifierCompleted.ts","../src/lib/cron/pushCronIdentifiersFromCsv.ts"],"sourcesContent":["import type { Got } from 'got';\nimport * as t from 'io-ts';\n\n/**\n * Minimal set required to mark as completed\n */\nexport const CronIdentifierPush = t.type({\n nonce: t.string,\n identifier: t.string,\n});\n\n/** Type override */\nexport type CronIdentifierPush = t.TypeOf<typeof CronIdentifierPush>;\n\n/**\n * Mark an identifier output by the cron job as completed.\n *\n * @see https://docs.transcend.io/docs/api-reference/PUT/v1/data-silo\n * @param sombra - Sombra instance configured to make requests\n * @param options - Additional options\n * @returns Successfully submitted request, false if not in a state to update\n */\nexport async function markCronIdentifierCompleted(\n sombra: Got,\n { nonce, identifier }: CronIdentifierPush,\n): Promise<boolean> {\n try {\n // Make the GraphQL request\n await sombra.put('v1/data-silo', {\n headers: {\n 'x-transcend-nonce': nonce,\n },\n json: {\n profiles: [\n {\n profileId: identifier,\n },\n ],\n },\n });\n return true;\n } catch (err) {\n // handle gracefully\n if (err.response?.statusCode === 409) {\n return false;\n }\n throw new Error(`Received an error from server: ${err?.response?.body || err?.message}`);\n }\n}\n","import { createSombraGotInstance } from '@transcend-io/sdk';\nimport { map, mapSeries } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport { chunk } from 'lodash-es';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { readCsv } from '../requests/index.js';\nimport { markCronIdentifierCompleted, CronIdentifierPush } from './markCronIdentifierCompleted.js';\n\n/**\n * Given a CSV of cron job outputs, mark all requests as completed in Transcend\n *\n * @param options - Options\n * @returns Number of items marked as completed\n */\nexport async function pushCronIdentifiersFromCsv({\n file,\n dataSiloId,\n auth,\n sombraAuth,\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n sleepSeconds = 10,\n}: {\n /** CSV file path */\n file: string;\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** Upload concurrency */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Sleep time in seconds between chunks of concurrent calls */\n sleepSeconds?: number;\n}): Promise<number> {\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n // Read from CSV\n logger.info(colors.magenta(`Reading \"${file}\" from disk`));\n const activeResults = readCsv(file, CronIdentifierPush);\n\n // Notify Transcend\n logger.info(\n colors.magenta(\n `Notifying Transcend for data silo \"${dataSiloId}\" marking \"${activeResults.length}\" identifiers as completed.`,\n ),\n );\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n let successCount = 0;\n let failureCount = 0;\n let errorCount = 0;\n progressBar.start(activeResults.length, 0);\n\n // Process in chunks with sleep intervals\n const chunks = chunk(activeResults, concurrency);\n const totalChunks = chunks.length;\n const processChunk = async (items: CronIdentifierPush[], chunkIndex: number): Promise<void> => {\n logger.info(\n colors.blue(`Processing chunk ${chunkIndex + 1}/${totalChunks} (${chunk.length} items)`),\n );\n\n // Process the items of the chunk concurrently\n await map(items, async (identifier) => {\n try {\n const success = await markCronIdentifierCompleted(sombra, identifier);\n if (success) {\n successCount += 1;\n } else {\n failureCount += 1;\n }\n } catch (e) {\n logger.error(\n colors.red(\n `Error notifying Transcend for identifier \"${identifier.identifier}\" - ${e?.message}`,\n ),\n );\n errorCount += 1;\n }\n progressBar.update(successCount + failureCount);\n });\n\n // Sleep between chunks (except for the last chunk)\n if (sleepSeconds > 0 && chunkIndex < totalChunks - 1) {\n logger.info(colors.yellow(`Sleeping for ${sleepSeconds}s before next chunk...`));\n\n await new Promise((resolve) => {\n setTimeout(resolve, sleepSeconds * 1000);\n });\n }\n };\n\n // Process all chunks sequentially\n await mapSeries(chunks, processChunk);\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully notified Transcend for ${successCount} identifiers in \"${\n totalTime / 1000\n }\" seconds!`,\n ),\n );\n if (failureCount) {\n logger.info(\n colors.magenta(\n `There were ${failureCount} identifiers that were not in a state to be updated.` +\n 'They likely have already been resolved.',\n ),\n );\n }\n if (errorCount) {\n logger.error(\n colors.red(\n `There were ${errorCount} identifiers that failed to be updated. Please review the logs for more information.`,\n ),\n );\n throw new Error('Failed to update all identifiers');\n }\n return activeResults.length;\n}\n"],"mappings":"8VAMA,MAAa,EAAqB,EAAE,KAAK,CACvC,MAAO,EAAE,OACT,WAAY,EAAE,OACf,CAAC,CAaF,eAAsB,EACpB,EACA,CAAE,QAAO,cACS,CAClB,GAAI,CAcF,OAZA,MAAM,EAAO,IAAI,eAAgB,CAC/B,QAAS,CACP,oBAAqB,EACtB,CACD,KAAM,CACJ,SAAU,CACR,CACE,UAAW,EACZ,CACF,CACF,CACF,CAAC,CACK,SACA,EAAK,CAEZ,GAAI,EAAI,UAAU,aAAe,IAC/B,MAAO,GAET,MAAU,MAAM,kCAAkC,GAAK,UAAU,MAAQ,GAAK,UAAU,EC7B5F,eAAsB,EAA2B,CAC/C,OACA,aACA,OACA,aACA,cAAc,IACd,eAAe,EACf,eAAe,IAgBG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a,6FAE5B,CACF,CAEC,EAMF,MALA,EAAO,MACL,EAAO,IACL,cAAc,EAAW,sFAC1B,CACF,CACS,MAAM,mCAAmC,CAErD,OAAO,EAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./constants-
|
|
2
|
-
//# sourceMappingURL=pushManualEnrichmentIdentifiersFromCsv-
|
|
1
|
+
import{a as e}from"./constants-CgI8_Rfc.mjs";import{t}from"./logger-B-LXIf3U.mjs";import{t as n}from"./readCsv-D1e7WRTc.mjs";import{o as r}from"./request-C4gYxn1p.mjs";import{uniq as i}from"lodash-es";import a from"colors";import*as o from"io-ts";import{buildTranscendGraphQLClient as s,createSombraGotInstance as c,makeGraphQLRequest as l}from"@transcend-io/sdk";import{map as u,splitCsvToList as d}from"@transcend-io/utils";const f=`https://app.transcend.io/privacy-requests/incoming-requests/`,p=o.record(o.string,o.string);async function m(e,{id:n,...r},o,s){if(!n){let e=`Request ID must be provided to enricher request.${s?` Found error in row: ${s}`:``}`;throw t.error(a.red(e)),Error(e)}let c=n.toLowerCase(),l=Object.entries(r).reduce((e,[t,n])=>i(d(n)).length===0?e:Object.assign(e,{[t]:i(d(n)).map(e=>({value:t===`email`?e.toLowerCase():e}))}),{});try{return await e.post(`v1/enrich-identifiers`,{headers:{"x-transcend-request-id":c,"x-transcend-enricher-id":o},json:{enrichedIdentifiers:l}}).json(),t.error(a.green(`Successfully enriched request: ${f}${c}`)),!0}catch(e){if(typeof e.response.body==`string`&&e.response.body.includes(`Cannot update a resolved RequestEnricher`))return t.warn(a.magenta(`Skipped enrichment for request: ${f}${c}, request is no longer in the enriching phase.`)),!1;throw t.error(a.red(`Failed to enricher identifiers for request with id: ${f}${c} - ${e.message} - ${e.response.body}`)),e}}async function h({file:i,auth:o,sombraAuth:d,enricherId:f,markSilent:h,concurrency:g=100,transcendUrl:_=e}){let v=await c(_,o,{logger:t,sombraApiKey:d,sombraUrl:process.env.SOMBRA_URL}),y=s(_,o);t.info(a.magenta(`Reading "${i}" from disk`));let b=n(i,p);t.info(a.magenta(`Enriching "${b.length}" privacy requests.`));let x=0,S=0,C=0;if(await u(b,async(e,n)=>{try{h&&(await l(y,r,{variables:{input:{id:e.id,isSilent:!0}},logger:t}),t.info(a.magenta(`Mark request as silent mode - ${e.id}`))),await m(v,e,f,n)?x+=1:S+=1}catch{C+=1}},{concurrency:g}),t.info(a.green(`Successfully notified Transcend! \n Success count: ${x}.`)),S>0&&t.info(a.magenta(`Skipped count: ${S}.`)),C>0)throw t.info(a.red(`Error Count: ${C}.`)),Error(`Failed to enrich: ${C} requests.`);return b.length}export{p as n,m as r,h as t};
|
|
2
|
+
//# sourceMappingURL=pushManualEnrichmentIdentifiersFromCsv-n1WyKiBi.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushManualEnrichmentIdentifiersFromCsv-
|
|
1
|
+
{"version":3,"file":"pushManualEnrichmentIdentifiersFromCsv-n1WyKiBi.mjs","names":[],"sources":["../src/lib/manual-enrichment/enrichPrivacyRequest.ts","../src/lib/manual-enrichment/pushManualEnrichmentIdentifiersFromCsv.ts"],"sourcesContent":["import { splitCsvToList } from '@transcend-io/utils';\nimport colors from 'colors';\nimport type { Got } from 'got';\nimport * as t from 'io-ts';\nimport { uniq } from 'lodash-es';\n\nimport { logger } from '../../logger.js';\n\nconst ADMIN_URL = 'https://app.transcend.io/privacy-requests/incoming-requests/';\n/**\n * Minimal set required to mark as completed\n */\nexport const EnrichPrivacyRequest = t.record(t.string, t.string);\n\n/** Type override */\nexport type EnrichPrivacyRequest = t.TypeOf<typeof EnrichPrivacyRequest>;\n\n/**\n * Upload identifiers to a privacy request or mark request as\n *\n * @param sombra - Sombra instance configured to make requests\n * @param request - Request to enricher\n * @param enricherId - The ID of the enricher being uploaded to\n * @param index - Index of request ID\n * @returns True if enriched successfully, false if skipped, throws error if failed\n */\nexport async function enrichPrivacyRequest(\n sombra: Got,\n { id: rawId, ...rest }: EnrichPrivacyRequest,\n enricherId: string,\n index?: number,\n): Promise<boolean> {\n if (!rawId) {\n // error\n const msg = `Request ID must be provided to enricher request.${\n index ? ` Found error in row: ${index}` : ''\n }`;\n logger.error(colors.red(msg));\n throw new Error(msg);\n }\n\n const id = rawId.toLowerCase();\n\n // Pull out the identifiers\n const enrichedIdentifiers = Object.entries(rest).reduce(\n (acc, [key, value]) => {\n const values = uniq(splitCsvToList(value));\n return values.length === 0\n ? acc\n : Object.assign(acc, {\n [key]: uniq(splitCsvToList(value)).map((val) => ({\n value: key === 'email' ? val.toLowerCase() : val,\n })),\n });\n },\n {} as Record<string, string[]>,\n );\n\n // Make the GraphQL request\n try {\n await sombra\n .post('v1/enrich-identifiers', {\n headers: {\n 'x-transcend-request-id': id,\n 'x-transcend-enricher-id': enricherId,\n },\n json: {\n enrichedIdentifiers,\n },\n })\n .json();\n\n logger.error(colors.green(`Successfully enriched request: ${ADMIN_URL}${id}`));\n return true;\n } catch (err) {\n // skip if already enriched\n if (\n typeof err.response.body === 'string' &&\n err.response.body.includes('Cannot update a resolved RequestEnricher')\n ) {\n logger.warn(\n colors.magenta(\n `Skipped enrichment for request: ${ADMIN_URL}${id}, request is no longer in the enriching phase.`,\n ),\n );\n return false;\n }\n\n // error\n logger.error(\n colors.red(\n `Failed to enricher identifiers for request with id: ${ADMIN_URL}${id} - ${err.message} - ${err.response.body}`,\n ),\n );\n throw err;\n }\n}\n","import {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n makeGraphQLRequest,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { UPDATE_PRIVACY_REQUEST } from '../graphql/index.js';\nimport { readCsv } from '../requests/index.js';\nimport { enrichPrivacyRequest, EnrichPrivacyRequest } from './enrichPrivacyRequest.js';\n\n/**\n * Push a CSV of enriched requests back into Transcend\n *\n * @param options - Options\n * @returns Number of items processed\n */\nexport async function pushManualEnrichmentIdentifiersFromCsv({\n file,\n auth,\n sombraAuth,\n enricherId,\n markSilent,\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** CSV file path */\n file: string;\n /** Transcend API key authentication */\n auth: string;\n /** ID of enricher being uploaded to */\n enricherId: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Concurrency */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Mark requests in silent mode before enriching */\n markSilent?: boolean;\n}): Promise<number> {\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Read from CSV\n logger.info(colors.magenta(`Reading \"${file}\" from disk`));\n const activeResults = readCsv(file, EnrichPrivacyRequest);\n\n // Notify Transcend\n logger.info(colors.magenta(`Enriching \"${activeResults.length}\" privacy requests.`));\n\n let successCount = 0;\n let skippedCount = 0;\n let errorCount = 0;\n\n await map(\n activeResults,\n async (request, index) => {\n try {\n // Mark requests in silent mode before a certain date\n if (markSilent) {\n await makeGraphQLRequest(client, UPDATE_PRIVACY_REQUEST, {\n variables: {\n input: {\n id: request.id,\n isSilent: true,\n },\n },\n logger,\n });\n\n logger.info(colors.magenta(`Mark request as silent mode - ${request.id}`));\n }\n\n const result = await enrichPrivacyRequest(sombra, request, enricherId, index);\n if (result) {\n successCount += 1;\n } else {\n skippedCount += 1;\n }\n } catch {\n errorCount += 1;\n }\n },\n { concurrency },\n );\n\n logger.info(colors.green(`Successfully notified Transcend! \\n Success count: ${successCount}.`));\n\n if (skippedCount > 0) {\n logger.info(colors.magenta(`Skipped count: ${skippedCount}.`));\n }\n\n if (errorCount > 0) {\n logger.info(colors.red(`Error Count: ${errorCount}.`));\n throw new Error(`Failed to enrich: ${errorCount} requests.`);\n }\n\n return activeResults.length;\n}\n"],"mappings":"0aAQA,MAAM,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EAAK,CAG9D,EAAO,KAAK,EAAO,QAAQ,YAAY,EAAK,aAAa,CAAC,CAC1D,IAAM,EAAgB,EAAQ,EAAM,EAAqB,CAGzD,EAAO,KAAK,EAAO,QAAQ,cAAc,EAAc,OAAO,qBAAqB,CAAC,CAEpF,IAAI,EAAe,EACf,EAAe,EACf,EAAa,EAwCjB,GAtCA,MAAM,EACJ,EACA,MAAO,EAAS,IAAU,CACxB,GAAI,CAEE,IACF,MAAM,EAAmB,EAAQ,EAAwB,CACvD,UAAW,CACT,MAAO,CACL,GAAI,EAAQ,GACZ,SAAU,GACX,CACF,CACD,SACD,CAAC,CAEF,EAAO,KAAK,EAAO,QAAQ,iCAAiC,EAAQ,KAAK,CAAC,EAIxE,MADiB,EAAqB,EAAQ,EAAS,EAAY,EAAM,CAE3E,GAAgB,EAEhB,GAAgB,OAEZ,CACN,GAAc,IAGlB,CAAE,cAAa,CAChB,CAED,EAAO,KAAK,EAAO,MAAM,sDAAsD,EAAa,GAAG,CAAC,CAE5F,EAAe,GACjB,EAAO,KAAK,EAAO,QAAQ,kBAAkB,EAAa,GAAG,CAAC,CAG5D,EAAa,EAEf,MADA,EAAO,KAAK,EAAO,IAAI,gBAAgB,EAAW,GAAG,CAAC,CAC5C,MAAM,qBAAqB,EAAW,YAAY,CAG9D,OAAO,EAAc"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{yt as e}from"./codecs-
|
|
1
|
+
import{yt as e}from"./codecs-DH-hZonL.mjs";import{decodeCodec as t}from"@transcend-io/type-utils";import{readFileSync as n,writeFileSync as r}from"node:fs";import i from"js-yaml";const a=/<<parameters\.(.+?)>>/,o=`parameters`;function s(e,t,n=``){let r=e;if(Object.entries(t).forEach(([e,t])=>{r=r.split(`<<${o}.${e}>>`).join(t)}),a.test(r)){let[,e]=a.exec(r)||[];throw Error(`Found variable that was not set: ${e}.
|
|
2
2
|
Make sure you are passing all parameters through the --${o}=${e}:value-for-param flag.
|
|
3
3
|
${n}`)}return r}function c(r,a={}){let o=s(n(r,`utf-8`),a,`Also check that there are no extra variables defined in your yaml: ${r}`);return t(e,i.load(o))}function l(n,a){r(n,i.dump(t(e,a)))}export{l as a,s as i,a as n,c as r,o as t};
|
|
4
|
-
//# sourceMappingURL=readTranscendYaml-
|
|
4
|
+
//# sourceMappingURL=readTranscendYaml-CVbI1N8S.mjs.map
|