@transcend-io/cli 10.22.1 → 10.23.1
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/README.md +92 -86
- package/dist/app-BJ1QlNA0.mjs +131 -0
- package/dist/app-BJ1QlNA0.mjs.map +1 -0
- package/dist/{approvePrivacyRequests-CY6dRaiJ.mjs → approvePrivacyRequests-C2EflZEJ.mjs} +2 -2
- package/dist/{approvePrivacyRequests-CY6dRaiJ.mjs.map → approvePrivacyRequests-C2EflZEJ.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-Dyfixa8C.mjs → buildExamples-DnV_tVZt.mjs} +2 -2
- package/dist/{buildExamples-Dyfixa8C.mjs.map → buildExamples-DnV_tVZt.mjs.map} +1 -1
- package/dist/{buildXdiSyncEndpoint-Cz2LSRjW.mjs → buildXdiSyncEndpoint-BYtXQ3Um.mjs} +2 -2
- package/dist/{buildXdiSyncEndpoint-Cz2LSRjW.mjs.map → buildXdiSyncEndpoint-BYtXQ3Um.mjs.map} +1 -1
- package/dist/{bulkRestartRequests-Dj3W8Smy.mjs → bulkRestartRequests-DROZyl0s.mjs} +2 -2
- package/dist/{bulkRestartRequests-Dj3W8Smy.mjs.map → bulkRestartRequests-DROZyl0s.mjs.map} +1 -1
- package/dist/{bulkRetryEnrichers-D6j9Ivc0.mjs → bulkRetryEnrichers-DHIt_YpU.mjs} +2 -2
- package/dist/{bulkRetryEnrichers-D6j9Ivc0.mjs.map → bulkRetryEnrichers-DHIt_YpU.mjs.map} +1 -1
- package/dist/{cancelPrivacyRequests-HT5NvgGF.mjs → cancelPrivacyRequests-DUmxmMsv.mjs} +2 -2
- package/dist/{cancelPrivacyRequests-HT5NvgGF.mjs.map → cancelPrivacyRequests-DUmxmMsv.mjs.map} +1 -1
- package/dist/codecs-Dch3sv5m.mjs +2 -0
- package/dist/codecs-Dch3sv5m.mjs.map +1 -0
- package/dist/{collectCsvFilesOrExit-BQdnr-m2.mjs → collectCsvFilesOrExit-C8-Pr9Hr.mjs} +2 -2
- package/dist/{collectCsvFilesOrExit-BQdnr-m2.mjs.map → collectCsvFilesOrExit-C8-Pr9Hr.mjs.map} +1 -1
- package/dist/{collectParquetFilesOrExit-BJ-GciNy.mjs → collectParquetFilesOrExit-DyZISY9X.mjs} +2 -2
- package/dist/{collectParquetFilesOrExit-BJ-GciNy.mjs.map → collectParquetFilesOrExit-DyZISY9X.mjs.map} +1 -1
- package/dist/{command-CJVah-g5.mjs → command-DsPVpqxX.mjs} +2 -2
- package/dist/{command-CJVah-g5.mjs.map → command-DsPVpqxX.mjs.map} +1 -1
- package/dist/commands/admin/chunk-csv/worker.mjs +1 -1
- package/dist/commands/admin/parquet-to-csv/worker.mjs +1 -1
- package/dist/{consentManagersToBusinessEntities-l8jRfpYN.mjs → consentManagersToBusinessEntities-DGzryQ3W.mjs} +2 -2
- package/dist/{consentManagersToBusinessEntities-l8jRfpYN.mjs.map → consentManagersToBusinessEntities-DGzryQ3W.mjs.map} +1 -1
- package/dist/{constants-DXUo-hl3.mjs → constants-B44yUGaB.mjs} +2 -2
- package/dist/{constants-DXUo-hl3.mjs.map → constants-B44yUGaB.mjs.map} +1 -1
- package/dist/constants-CEPYyv4h.mjs +2 -0
- package/dist/constants-CEPYyv4h.mjs.map +1 -0
- package/dist/{constants-BhZIv-FP.mjs → constants-FbK2iR--.mjs} +1 -1
- package/dist/{constants-BhZIv-FP.mjs.map → constants-FbK2iR--.mjs.map} +1 -1
- package/dist/{constants-KYaYveEQ.mjs → constants-ykNINvFg.mjs} +1 -1
- package/dist/{constants-KYaYveEQ.mjs.map → constants-ykNINvFg.mjs.map} +1 -1
- package/dist/{context-CdSyuBlf.mjs → context-Br0NHHOk.mjs} +1 -1
- package/dist/{context-CdSyuBlf.mjs.map → context-Br0NHHOk.mjs.map} +1 -1
- package/dist/{createExtraKeyHandler-CuarjDkw.mjs → createExtraKeyHandler-CJRmK224.mjs} +2 -2
- package/dist/{createExtraKeyHandler-CuarjDkw.mjs.map → createExtraKeyHandler-CJRmK224.mjs.map} +1 -1
- package/dist/{dataFlowsToDataSilos-Blo6-adp.mjs → dataFlowsToDataSilos-DRGrUosf.mjs} +1 -1
- package/dist/{dataFlowsToDataSilos-Blo6-adp.mjs.map → dataFlowsToDataSilos-DRGrUosf.mjs.map} +1 -1
- package/dist/{done-input-validation-CvwjeRWr.mjs → done-input-validation-uqIgnJcw.mjs} +1 -1
- package/dist/{done-input-validation-CvwjeRWr.mjs.map → done-input-validation-uqIgnJcw.mjs.map} +1 -1
- package/dist/{downloadPrivacyRequestFiles-Cn-cm-QI.mjs → downloadPrivacyRequestFiles-BX85Pey2.mjs} +2 -2
- package/dist/{downloadPrivacyRequestFiles-Cn-cm-QI.mjs.map → downloadPrivacyRequestFiles-BX85Pey2.mjs.map} +1 -1
- package/dist/{extractClientError-CaF_Kj-f.mjs → extractClientError-X9wJVqGq.mjs} +1 -1
- package/dist/{extractClientError-CaF_Kj-f.mjs.map → extractClientError-X9wJVqGq.mjs.map} +1 -1
- package/dist/{fetchAllRequests-BCHpCeFo.mjs → fetchAllRequests-Bya6iwzL.mjs} +2 -2
- package/dist/{fetchAllRequests-BCHpCeFo.mjs.map → fetchAllRequests-Bya6iwzL.mjs.map} +1 -1
- package/dist/{formatPolicyBundleVersionSummary-DvxPXykZ.mjs → formatPolicyBundleVersionSummary-Bo7DYxoy.mjs} +1 -1
- package/dist/{formatPolicyBundleVersionSummary-DvxPXykZ.mjs.map → formatPolicyBundleVersionSummary-Bo7DYxoy.mjs.map} +1 -1
- package/dist/{fuzzyMatchColumns-Dym9eeQe.mjs → fuzzyMatchColumns-Ds0TqtJ5.mjs} +2 -2
- package/dist/{fuzzyMatchColumns-Dym9eeQe.mjs.map → fuzzyMatchColumns-Ds0TqtJ5.mjs.map} +1 -1
- package/dist/{generateCrossAccountApiKeys-Dh8X4a3W.mjs → generateCrossAccountApiKeys-DELmDKBr.mjs} +2 -2
- package/dist/{generateCrossAccountApiKeys-Dh8X4a3W.mjs.map → generateCrossAccountApiKeys-DELmDKBr.mjs.map} +1 -1
- package/dist/{impl-BCLxAEup.mjs → impl-1y382i4y.mjs} +2 -2
- package/dist/{impl-BCLxAEup.mjs.map → impl-1y382i4y.mjs.map} +1 -1
- package/dist/impl-3kG5jsbx.mjs +2 -0
- package/dist/{impl-RPen9vPS.mjs.map → impl-3kG5jsbx.mjs.map} +1 -1
- package/dist/{impl-D7wDuTnD.mjs → impl-6M90fU9c.mjs} +2 -2
- package/dist/{impl-D7wDuTnD.mjs.map → impl-6M90fU9c.mjs.map} +1 -1
- package/dist/impl-B0AKcSoy.mjs +2 -0
- package/dist/impl-B0AKcSoy.mjs.map +1 -0
- package/dist/{impl-IsvQznAE.mjs → impl-B2Um3cCa.mjs} +2 -2
- package/dist/{impl-IsvQznAE.mjs.map → impl-B2Um3cCa.mjs.map} +1 -1
- package/dist/impl-BCEw1fsj.mjs +3 -0
- package/dist/impl-BCEw1fsj.mjs.map +1 -0
- package/dist/{impl-GZe4ti1_2.mjs → impl-BHKNOzzl2.mjs} +2 -2
- package/dist/{impl-GZe4ti1_2.mjs.map → impl-BHKNOzzl2.mjs.map} +1 -1
- package/dist/impl-BTp6QWcY.mjs +3 -0
- package/dist/impl-BTp6QWcY.mjs.map +1 -0
- package/dist/{impl-BMU2cg0K.mjs → impl-BWenu3QG.mjs} +2 -2
- package/dist/{impl-BMU2cg0K.mjs.map → impl-BWenu3QG.mjs.map} +1 -1
- package/dist/{impl-aZEhTcLa.mjs → impl-BZ0aEWLg.mjs} +2 -2
- package/dist/{impl-aZEhTcLa.mjs.map → impl-BZ0aEWLg.mjs.map} +1 -1
- package/dist/{impl-BB8jBITw2.mjs → impl-BZXxpO912.mjs} +2 -2
- package/dist/{impl-BB8jBITw2.mjs.map → impl-BZXxpO912.mjs.map} +1 -1
- package/dist/impl-B_4_7a-i.mjs +3 -0
- package/dist/impl-B_4_7a-i.mjs.map +1 -0
- package/dist/{impl-CqAhgJRN.mjs → impl-BbIP694E.mjs} +2 -2
- package/dist/{impl-CqAhgJRN.mjs.map → impl-BbIP694E.mjs.map} +1 -1
- package/dist/{impl-jEFmv3UE.mjs → impl-BnJiEB-x.mjs} +2 -2
- package/dist/{impl-jEFmv3UE.mjs.map → impl-BnJiEB-x.mjs.map} +1 -1
- package/dist/{impl-CH_2Ay0I2.mjs → impl-Bxbu4It12.mjs} +2 -2
- package/dist/{impl-CH_2Ay0I2.mjs.map → impl-Bxbu4It12.mjs.map} +1 -1
- package/dist/{impl-DRLH1TnS.mjs → impl-BzyN0wbS2.mjs} +2 -2
- package/dist/impl-BzyN0wbS2.mjs.map +1 -0
- package/dist/impl-C5RWQxAV.mjs +3 -0
- package/dist/{impl-BU5epQoJ.mjs.map → impl-C5RWQxAV.mjs.map} +1 -1
- package/dist/{impl-ChIESsn-.mjs → impl-C69Nh_YS.mjs} +2 -2
- package/dist/{impl-ChIESsn-.mjs.map → impl-C69Nh_YS.mjs.map} +1 -1
- package/dist/impl-C7Xp0Txd.mjs +3 -0
- package/dist/impl-C7Xp0Txd.mjs.map +1 -0
- package/dist/impl-CEkTnggY2.mjs +2 -0
- package/dist/impl-CEkTnggY2.mjs.map +1 -0
- package/dist/{impl-D_1lQVRR2.mjs → impl-CLhItW5v2.mjs} +2 -2
- package/dist/{impl-D_1lQVRR2.mjs.map → impl-CLhItW5v2.mjs.map} +1 -1
- package/dist/{impl-MJ89a6cJ.mjs → impl-CdZ-nr1b.mjs} +2 -2
- package/dist/{impl-MJ89a6cJ.mjs.map → impl-CdZ-nr1b.mjs.map} +1 -1
- package/dist/{impl-X-lj6p6X.mjs → impl-Ce4Ua3nx.mjs} +3 -3
- package/dist/{impl-X-lj6p6X.mjs.map → impl-Ce4Ua3nx.mjs.map} +1 -1
- package/dist/{impl-BonZXKcP2.mjs → impl-ChO9Br2_2.mjs} +2 -2
- package/dist/{impl-BonZXKcP2.mjs.map → impl-ChO9Br2_2.mjs.map} +1 -1
- package/dist/{impl-spb5yfh5.mjs → impl-CiA-v1ol.mjs} +2 -2
- package/dist/{impl-spb5yfh5.mjs.map → impl-CiA-v1ol.mjs.map} +1 -1
- package/dist/impl-CjsLPYCP2.mjs +2 -0
- package/dist/impl-CjsLPYCP2.mjs.map +1 -0
- package/dist/{impl-F9isBn8P.mjs → impl-CpGmNKVh.mjs} +2 -2
- package/dist/{impl-F9isBn8P.mjs.map → impl-CpGmNKVh.mjs.map} +1 -1
- package/dist/{impl-FT-AX6eL2.mjs → impl-CsFbPjie2.mjs} +2 -2
- package/dist/{impl-FT-AX6eL2.mjs.map → impl-CsFbPjie2.mjs.map} +1 -1
- package/dist/{impl-C2SPhoeN.mjs → impl-CuAUD_Ij2.mjs} +2 -2
- package/dist/impl-CuAUD_Ij2.mjs.map +1 -0
- package/dist/impl-CwJx90K82.mjs +2 -0
- package/dist/impl-CwJx90K82.mjs.map +1 -0
- package/dist/{impl-DJwjZCcH.mjs → impl-D0rQ-_u_.mjs} +2 -2
- package/dist/{impl-DJwjZCcH.mjs.map → impl-D0rQ-_u_.mjs.map} +1 -1
- package/dist/impl-D6rMK5Us.mjs +2 -0
- package/dist/{impl-CwBLpuAJ.mjs.map → impl-D6rMK5Us.mjs.map} +1 -1
- package/dist/{impl-4gOELmu7.mjs → impl-DF8-QsO52.mjs} +2 -2
- package/dist/impl-DF8-QsO52.mjs.map +1 -0
- package/dist/impl-DGQW5mVR.mjs +2 -0
- package/dist/impl-DGQW5mVR.mjs.map +1 -0
- package/dist/{impl-UxzUmcgG2.mjs → impl-DJFPeUq32.mjs} +2 -2
- package/dist/{impl-UxzUmcgG2.mjs.map → impl-DJFPeUq32.mjs.map} +1 -1
- package/dist/impl-DLNk5Voe.mjs +4 -0
- package/dist/{impl-C-JpeZru.mjs.map → impl-DLNk5Voe.mjs.map} +1 -1
- package/dist/{impl-HrUgz4tG.mjs → impl-DMtn2boK.mjs} +2 -2
- package/dist/{impl-HrUgz4tG.mjs.map → impl-DMtn2boK.mjs.map} +1 -1
- package/dist/{impl-nePMEJkH.mjs → impl-DQ-kymSs.mjs} +2 -2
- package/dist/{impl-nePMEJkH.mjs.map → impl-DQ-kymSs.mjs.map} +1 -1
- package/dist/{impl-VZ5AFBNm.mjs → impl-D_Zke9vp.mjs} +2 -2
- package/dist/{impl-VZ5AFBNm.mjs.map → impl-D_Zke9vp.mjs.map} +1 -1
- package/dist/{impl-Clfzhtnt.mjs → impl-DvrO6Zrd.mjs} +2 -2
- package/dist/{impl-Clfzhtnt.mjs.map → impl-DvrO6Zrd.mjs.map} +1 -1
- package/dist/{impl-ZdDrknSR2.mjs → impl-E0CjQexl2.mjs} +2 -2
- package/dist/{impl-ZdDrknSR2.mjs.map → impl-E0CjQexl2.mjs.map} +1 -1
- package/dist/{impl-ukQtDFFF.mjs → impl-EmiQDBEx2.mjs} +2 -2
- package/dist/impl-EmiQDBEx2.mjs.map +1 -0
- package/dist/{impl-D5Gsgyj6.mjs → impl-IT4hoGkx.mjs} +2 -2
- package/dist/{impl-D5Gsgyj6.mjs.map → impl-IT4hoGkx.mjs.map} +1 -1
- package/dist/{impl-DQGV2G5v.mjs → impl-NUMkBg7d.mjs} +2 -2
- package/dist/{impl-DQGV2G5v.mjs.map → impl-NUMkBg7d.mjs.map} +1 -1
- package/dist/{impl-DJz0q9FW2.mjs → impl-ToUQkHVL2.mjs} +2 -2
- package/dist/{impl-DJz0q9FW2.mjs.map → impl-ToUQkHVL2.mjs.map} +1 -1
- package/dist/impl-WHaoeim8.mjs +2 -0
- package/dist/{impl-Bzn3FMBY.mjs.map → impl-WHaoeim8.mjs.map} +1 -1
- package/dist/{impl-Bq3ZIpcG.mjs → impl-Zjvt9J28.mjs} +2 -2
- package/dist/{impl-Bq3ZIpcG.mjs.map → impl-Zjvt9J28.mjs.map} +1 -1
- package/dist/{impl-DctprvAs.mjs → impl-_HlLHVRO.mjs} +2 -2
- package/dist/{impl-DctprvAs.mjs.map → impl-_HlLHVRO.mjs.map} +1 -1
- package/dist/{impl-CYiMx1--.mjs → impl-cMFtIJUY2.mjs} +2 -2
- package/dist/impl-cMFtIJUY2.mjs.map +1 -0
- package/dist/impl-fiK_rZ7c.mjs +2 -0
- package/dist/{impl-C0n31a_O.mjs.map → impl-fiK_rZ7c.mjs.map} +1 -1
- package/dist/{impl-DV68fyyl.mjs → impl-rKM9h7Vg.mjs} +2 -2
- package/dist/{impl-DV68fyyl.mjs.map → impl-rKM9h7Vg.mjs.map} +1 -1
- package/dist/{impl-BDE-0f_J2.mjs → impl-x_rM8yTw.mjs} +2 -2
- package/dist/impl-x_rM8yTw.mjs.map +1 -0
- package/dist/{impl-C515J-j7.mjs → impl-z5dBnPm5.mjs} +3 -3
- package/dist/{impl-C515J-j7.mjs.map → impl-z5dBnPm5.mjs.map} +1 -1
- package/dist/index.d.mts +87 -77
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{inquirer-CXl1YWCs.mjs → inquirer-AEchly0b.mjs} +2 -2
- package/dist/{inquirer-CXl1YWCs.mjs.map → inquirer-AEchly0b.mjs.map} +1 -1
- package/dist/{listFiles-B1GqyM33.mjs → listFiles-BPx3iDV6.mjs} +1 -1
- package/dist/{listFiles-B1GqyM33.mjs.map → listFiles-BPx3iDV6.mjs.map} +1 -1
- package/dist/{logger-B-LXIf3U.mjs → logger-Ckep4QXn.mjs} +1 -1
- package/dist/{logger-B-LXIf3U.mjs.map → logger-Ckep4QXn.mjs.map} +1 -1
- package/dist/{markRequestDataSiloIdsCompleted-Dz8BpX68.mjs → markRequestDataSiloIdsCompleted-zFRxJN8D.mjs} +2 -2
- package/dist/{markRequestDataSiloIdsCompleted-Dz8BpX68.mjs.map → markRequestDataSiloIdsCompleted-zFRxJN8D.mjs.map} +1 -1
- package/dist/{markSilentPrivacyRequests-CNT4eigq.mjs → markSilentPrivacyRequests-t65ShOrn.mjs} +2 -2
- package/dist/{markSilentPrivacyRequests-CNT4eigq.mjs.map → markSilentPrivacyRequests-t65ShOrn.mjs.map} +1 -1
- package/dist/{notifyPrivacyRequestsAdditionalTime-D_MmmL_T.mjs → notifyPrivacyRequestsAdditionalTime-C7v7zo8q.mjs} +2 -2
- package/dist/{notifyPrivacyRequestsAdditionalTime-D_MmmL_T.mjs.map → notifyPrivacyRequestsAdditionalTime-C7v7zo8q.mjs.map} +1 -1
- package/dist/{parquetToCsvOneFile-DuyOOzqQ.mjs → parquetToCsvOneFile-13GirFzy.mjs} +2 -2
- package/dist/{parquetToCsvOneFile-DuyOOzqQ.mjs.map → parquetToCsvOneFile-13GirFzy.mjs.map} +1 -1
- package/dist/{parseAttributesFromString-ByzY22WY.mjs → parseAttributesFromString-CYcxsS3n.mjs} +2 -2
- package/dist/{parseAttributesFromString-ByzY22WY.mjs.map → parseAttributesFromString-CYcxsS3n.mjs.map} +1 -1
- package/dist/{parseVariablesFromString-CfXnITrG.mjs → parseVariablesFromString-RM3zV9Av.mjs} +3 -3
- package/dist/{parseVariablesFromString-CfXnITrG.mjs.map → parseVariablesFromString-RM3zV9Av.mjs.map} +1 -1
- package/dist/policyEngineCliError-BnBghLd1.mjs +3 -0
- package/dist/policyEngineCliError-BnBghLd1.mjs.map +1 -0
- package/dist/printResult-oXnpZu_9.mjs +33 -0
- package/dist/printResult-oXnpZu_9.mjs.map +1 -0
- package/dist/{pullAllDatapoints-D8mTXHun.mjs → pullAllDatapoints-Bvv9KRR5.mjs} +2 -2
- package/dist/{pullAllDatapoints-D8mTXHun.mjs.map → pullAllDatapoints-Bvv9KRR5.mjs.map} +1 -1
- package/dist/{pullChunkedCustomSiloOutstandingIdentifiers-DbzbpVC5.mjs → pullChunkedCustomSiloOutstandingIdentifiers-io0k95RW.mjs} +2 -2
- package/dist/{pullChunkedCustomSiloOutstandingIdentifiers-DbzbpVC5.mjs.map → pullChunkedCustomSiloOutstandingIdentifiers-io0k95RW.mjs.map} +1 -1
- package/dist/{pullConsentManagerMetrics-Cma2auCK.mjs → pullConsentManagerMetrics-CR4WwUt6.mjs} +2 -2
- package/dist/{pullConsentManagerMetrics-Cma2auCK.mjs.map → pullConsentManagerMetrics-CR4WwUt6.mjs.map} +1 -1
- package/dist/{pullManualEnrichmentIdentifiersToCsv-DV72-Ood.mjs → pullManualEnrichmentIdentifiersToCsv-CzhDjPw2.mjs} +2 -2
- package/dist/{pullManualEnrichmentIdentifiersToCsv-DV72-Ood.mjs.map → pullManualEnrichmentIdentifiersToCsv-CzhDjPw2.mjs.map} +1 -1
- package/dist/pullTranscendConfiguration-C2LAOKG4.mjs +58 -0
- package/dist/pullTranscendConfiguration-C2LAOKG4.mjs.map +1 -0
- package/dist/{pullUnstructuredSubDataPointRecommendations-DkQMoo7S.mjs → pullUnstructuredSubDataPointRecommendations-B9xIDPf2.mjs} +2 -2
- package/dist/{pullUnstructuredSubDataPointRecommendations-DkQMoo7S.mjs.map → pullUnstructuredSubDataPointRecommendations-B9xIDPf2.mjs.map} +1 -1
- package/dist/{pushCronIdentifiersFromCsv-Cc-POoSS.mjs → pushCronIdentifiersFromCsv-CehtFgXS.mjs} +2 -2
- package/dist/{pushCronIdentifiersFromCsv-Cc-POoSS.mjs.map → pushCronIdentifiersFromCsv-CehtFgXS.mjs.map} +1 -1
- package/dist/{pushManualEnrichmentIdentifiersFromCsv-C1k2t27x.mjs → pushManualEnrichmentIdentifiersFromCsv-CAl_kfHY.mjs} +2 -2
- package/dist/{pushManualEnrichmentIdentifiersFromCsv-C1k2t27x.mjs.map → pushManualEnrichmentIdentifiersFromCsv-CAl_kfHY.mjs.map} +1 -1
- package/dist/{readCsv-D1e7WRTc.mjs → readCsv-C84Jhrzx.mjs} +1 -1
- package/dist/{readCsv-D1e7WRTc.mjs.map → readCsv-C84Jhrzx.mjs.map} +1 -1
- package/dist/{readTranscendYaml-B1FLjET0.mjs → readTranscendYaml-dI3G3Og9.mjs} +2 -2
- package/dist/{readTranscendYaml-B1FLjET0.mjs.map → readTranscendYaml-dI3G3Og9.mjs.map} +1 -1
- package/dist/{removeUnverifiedRequestIdentifiers-CoqOTue3.mjs → removeUnverifiedRequestIdentifiers-CApHXROq.mjs} +2 -2
- package/dist/{removeUnverifiedRequestIdentifiers-CoqOTue3.mjs.map → removeUnverifiedRequestIdentifiers-CApHXROq.mjs.map} +1 -1
- package/dist/{renderTable-BgjVr6ch.mjs → renderTable-DKXvortp.mjs} +1 -1
- package/dist/{renderTable-BgjVr6ch.mjs.map → renderTable-DKXvortp.mjs.map} +1 -1
- package/dist/{request-C4gYxn1p.mjs → request-BIplTb3L.mjs} +1 -1
- package/dist/{request-C4gYxn1p.mjs.map → request-BIplTb3L.mjs.map} +1 -1
- package/dist/resolveBundleIdByName-By5Vl8Iz.mjs +2 -0
- package/dist/resolveBundleIdByName-By5Vl8Iz.mjs.map +1 -0
- package/dist/resolvePolicyBundleVersion-DO7IvEwb.mjs +2 -0
- package/dist/resolvePolicyBundleVersion-DO7IvEwb.mjs.map +1 -0
- package/dist/{retryRequestDataSilos-46M0IjN_.mjs → retryRequestDataSilos-Tou-97EC.mjs} +2 -2
- package/dist/{retryRequestDataSilos-46M0IjN_.mjs.map → retryRequestDataSilos-Tou-97EC.mjs.map} +1 -1
- package/dist/{runOpa-DGUkXzFZ.mjs → runOpa-D511z37u.mjs} +2 -2
- package/dist/{runOpa-DGUkXzFZ.mjs.map → runOpa-D511z37u.mjs.map} +1 -1
- package/dist/{skipPreflightJobs-C5CAhy9W.mjs → skipPreflightJobs-TL4bpgJ5.mjs} +2 -2
- package/dist/{skipPreflightJobs-C5CAhy9W.mjs.map → skipPreflightJobs-TL4bpgJ5.mjs.map} +1 -1
- package/dist/{skipRequestDataSilos-BeIEyLtB.mjs → skipRequestDataSilos-D4DQNs2F.mjs} +2 -2
- package/dist/{skipRequestDataSilos-BeIEyLtB.mjs.map → skipRequestDataSilos-D4DQNs2F.mjs.map} +1 -1
- package/dist/{streamPrivacyRequestsToCsv-GBm5edD3.mjs → streamPrivacyRequestsToCsv-BW7LayDe.mjs} +2 -2
- package/dist/{streamPrivacyRequestsToCsv-GBm5edD3.mjs.map → streamPrivacyRequestsToCsv-BW7LayDe.mjs.map} +1 -1
- package/dist/{syncCodePackages-CwPtA473.mjs → syncCodePackages-Dhm5jI6B.mjs} +2 -2
- package/dist/{syncCodePackages-CwPtA473.mjs.map → syncCodePackages-Dhm5jI6B.mjs.map} +1 -1
- package/dist/{updateConsentManagerVersionToLatest-CUu1TzQR.mjs → updateConsentManagerVersionToLatest-D22lm-RZ.mjs} +2 -2
- package/dist/{updateConsentManagerVersionToLatest-CUu1TzQR.mjs.map → updateConsentManagerVersionToLatest-D22lm-RZ.mjs.map} +1 -1
- package/dist/{uploadConsents-Bj6r4M0K.mjs → uploadConsents-7V2GfdKQ.mjs} +2 -2
- package/dist/{uploadConsents-Bj6r4M0K.mjs.map → uploadConsents-7V2GfdKQ.mjs.map} +1 -1
- package/dist/{uploadCookiesFromCsv-C50gkbUb.mjs → uploadCookiesFromCsv-AyQGnKOP.mjs} +2 -2
- package/dist/{uploadCookiesFromCsv-C50gkbUb.mjs.map → uploadCookiesFromCsv-AyQGnKOP.mjs.map} +1 -1
- package/dist/{uploadDataFlowsFromCsv-7a3Niqzl.mjs → uploadDataFlowsFromCsv-4Uw_-6pw.mjs} +2 -2
- package/dist/{uploadDataFlowsFromCsv-7a3Niqzl.mjs.map → uploadDataFlowsFromCsv-4Uw_-6pw.mjs.map} +1 -1
- package/dist/{uploadPrivacyRequestsFromCsv-C2EgMu_d.mjs → uploadPrivacyRequestsFromCsv-DuDL3uOz.mjs} +2 -2
- package/dist/{uploadPrivacyRequestsFromCsv-C2EgMu_d.mjs.map → uploadPrivacyRequestsFromCsv-DuDL3uOz.mjs.map} +1 -1
- package/dist/{validateTranscendAuth-D14jsB5C.mjs → validateTranscendAuth-DhzCBA3F.mjs} +2 -2
- package/dist/{validateTranscendAuth-D14jsB5C.mjs.map → validateTranscendAuth-DhzCBA3F.mjs.map} +1 -1
- package/dist/{writeCsv-DDKM_rAU.mjs → writeCsv-BMVkiMHM.mjs} +1 -1
- package/dist/{writeCsv-DDKM_rAU.mjs.map → writeCsv-BMVkiMHM.mjs.map} +1 -1
- package/package.json +4 -4
- package/dist/app-CaKX0swF.mjs +0 -131
- package/dist/app-CaKX0swF.mjs.map +0 -1
- package/dist/codecs-_SjJhduF.mjs +0 -2
- package/dist/codecs-_SjJhduF.mjs.map +0 -1
- package/dist/constants-cBzX_zyl.mjs +0 -2
- package/dist/constants-cBzX_zyl.mjs.map +0 -1
- package/dist/formatPolicyEngineRequestError-Dn_VYIIj.mjs +0 -2
- package/dist/formatPolicyEngineRequestError-Dn_VYIIj.mjs.map +0 -1
- package/dist/impl-4gOELmu7.mjs.map +0 -1
- package/dist/impl-BDE-0f_J2.mjs.map +0 -1
- package/dist/impl-BJ0wcQ7k.mjs +0 -2
- package/dist/impl-BJ0wcQ7k.mjs.map +0 -1
- package/dist/impl-BMteSe3O.mjs +0 -3
- package/dist/impl-BMteSe3O.mjs.map +0 -1
- package/dist/impl-BU5epQoJ.mjs +0 -3
- package/dist/impl-Bzn3FMBY.mjs +0 -2
- package/dist/impl-C-JpeZru.mjs +0 -4
- package/dist/impl-C0n31a_O.mjs +0 -2
- package/dist/impl-C2SPhoeN.mjs.map +0 -1
- package/dist/impl-CEQNDwPb.mjs +0 -2
- package/dist/impl-CEQNDwPb.mjs.map +0 -1
- package/dist/impl-CYiMx1--.mjs.map +0 -1
- package/dist/impl-CwBLpuAJ.mjs +0 -2
- package/dist/impl-DFfc5HBk.mjs +0 -3
- package/dist/impl-DFfc5HBk.mjs.map +0 -1
- package/dist/impl-DJR9yQoG.mjs +0 -2
- package/dist/impl-DJR9yQoG.mjs.map +0 -1
- package/dist/impl-DQRcwOlA.mjs +0 -2
- package/dist/impl-DQRcwOlA.mjs.map +0 -1
- package/dist/impl-DRLH1TnS.mjs.map +0 -1
- package/dist/impl-JU14ujB0.mjs +0 -3
- package/dist/impl-JU14ujB0.mjs.map +0 -1
- package/dist/impl-RPen9vPS.mjs +0 -2
- package/dist/impl-ouNg4TVN.mjs +0 -2
- package/dist/impl-ouNg4TVN.mjs.map +0 -1
- package/dist/impl-toPEtoCY.mjs +0 -2
- package/dist/impl-toPEtoCY.mjs.map +0 -1
- package/dist/impl-ukQtDFFF.mjs.map +0 -1
- package/dist/printResult-DdSpAx6T.mjs +0 -2
- package/dist/printResult-DdSpAx6T.mjs.map +0 -1
- package/dist/pullTranscendConfiguration-BPkc-b3x.mjs +0 -58
- package/dist/pullTranscendConfiguration-BPkc-b3x.mjs.map +0 -1
- package/dist/resolveBundleIdByName-C-M1UT8E.mjs +0 -2
- package/dist/resolveBundleIdByName-C-M1UT8E.mjs.map +0 -1
- package/dist/resolvePolicyBundleVersion-HwUipJxP.mjs +0 -2
- package/dist/resolvePolicyBundleVersion-HwUipJxP.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseAttributesFromString-
|
|
1
|
+
{"version":3,"file":"parseAttributesFromString-CYcxsS3n.mjs","names":[],"sources":["../src/lib/requests/parseAttributesFromString.ts"],"sourcesContent":["import colors from 'colors';\nimport * as t from 'io-ts';\n\nimport { logger } from '../../logger.js';\n\nexport const ParsedAttributeInput = t.type({\n /** Attribute key */\n key: t.string,\n /** Attribute values */\n values: t.array(t.string),\n});\n\n/** Type override */\nexport type ParsedAttributeInput = t.TypeOf<typeof ParsedAttributeInput>;\n\n/**\n * Parse out the extra attributes to apply to all requests uploaded\n *\n * @param attributes - input as string, e.g. ['key:value1;value2','key2:value3;value4']\n * @returns The parsed attributes\n */\nexport function parseAttributesFromString(attributes: string[]): ParsedAttributeInput[] {\n // Parse out the extra attributes to apply to all requests uploaded\n const parsedAttributes = attributes.map((attribute) => {\n const [attributeKey, attributeValuesRaw] = attribute.trim().split(':');\n if (!attributeValuesRaw) {\n throw new Error('Expected attributes in key:value1;value2,key2:value3;value4');\n }\n const attributeValues = attributeValuesRaw.split(';');\n return {\n key: attributeKey,\n values: attributeValues,\n };\n });\n logger.info(colors.magenta('Attributes to apply to all requests:'));\n logger.info(colors.magenta(JSON.stringify(parsedAttributes, null, 2)));\n return parsedAttributes;\n}\n"],"mappings":"wFAKA,MAAa,EAAuB,EAAE,KAAK,CAEzC,IAAK,EAAE,OAEP,OAAQ,EAAE,MAAM,EAAE,OAAO,CAC1B,CAAC,CAWF,SAAgB,EAA0B,EAA8C,CAEtF,IAAM,EAAmB,EAAW,IAAK,GAAc,CACrD,GAAM,CAAC,EAAc,GAAsB,EAAU,MAAM,CAAC,MAAM,IAAI,CACtE,GAAI,CAAC,EACH,MAAU,MAAM,8DAA8D,CAGhF,MAAO,CACL,IAAK,EACL,OAHsB,EAAmB,MAAM,IAGxB,CACxB,EACD,CAGF,OAFA,EAAO,KAAK,EAAO,QAAQ,uCAAuC,CAAC,CACnE,EAAO,KAAK,EAAO,QAAQ,KAAK,UAAU,EAAkB,KAAM,EAAE,CAAC,CAAC,CAC/D"}
|
package/dist/{parseVariablesFromString-CfXnITrG.mjs → parseVariablesFromString-RM3zV9Av.mjs}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t as e}from"./logger-
|
|
2
|
-
`)}`)),m=!0;else try{await b(r,d,{variables:a,logger:e})}catch(r){e.info(c.red(`\nFailed to update datapoint "${t.key}" for data silo "${n}"! - \n${r.message}`)),m=!0}w+=1,x.update(w)})},{concurrency:10}),x.stop();let T=new Date().getTime()-h;return e.info(c.green(`Synced "${n.length}" data silos and "${C}" datapoints in "${T/1e3}" seconds!`)),{success:!m,dataSiloTitleToId:o(_,({id:e})=>e)}}async function M(t,n,{pageSize:r=50,publishToPrivacyCenter:i=!0,classifyService:a=!1,deleteExtraAttributeValues:o=!1,logger:s,warnings:l=[]}){let u=s??e,d=[],f=!1,p=(e,t,n)=>{d.push({resource:e,item:n,message:t}),f=!0};u.info(c.magenta(`Fetching data with page size ${r}...`));let{templates:g,attributes:b,actions:D,identifiers:O,"data-subjects":k,"business-entities":M,enrichers:N,cookies:P,"consent-manager":F,"data-silos":I,"data-flows":L,prompts:R,"prompt-groups":z,"prompt-partials":B,agents:V,"agent-functions":H,"agent-files":U,vendors:W,"data-categories":G,"processing-activities":K,"processing-purposes":q,"action-items":J,"action-item-collections":ke,teams:Ae,"privacy-center":je,messages:Y,policies:Me,partitions:Ne,"preference-workflow-configs":Pe,"workflow-configs":Fe}=t,Ie=t[`preference-options`],X=t.purposes,Le=Oe(t);if(Le.length>0){for(let e of Le)p(`preference-slugs`,e);return{success:!1,errors:d,warnings:l.length>0?l:void 0}}let[Z,Q,Re]=await Promise.all([N||O?y(n,{input:t,skipPublish:!i,logger:e}):{},I||k||N||K?A(t,n):{},I&&I.map(e=>e[`api-key-title`]||[]).reduce((e,t)=>e+t.length,0)>0?v(n,{apiKeyInputs:t,logger:e}):{}]);if(Pe?.length&&(await ie(n,Pe,{logger:u,pageSize:r})||p(`preference-workflow-configs`,`Failed to sync preference workflow configs`)),Fe?.length&&(await De(n,Fe,{logger:u})||p(`workflow-configs`,`Failed to sync workflow configs`)),Ie?.length&&(await he(n,Ie,{logger:u})||p(`preference-options`,`Failed to sync preference option values`)),X?.length){let{success:e,purposeIdByTrackingType:t}=await Ce(n,X,{logger:u});e||p(`purposes`,`Failed to sync one or more purposes`);let r=X.flatMap(e=>(e[`preference-topics`]??[]).map(t=>({...t,"tracking-type":e.trackingType})));r.length>0&&(await ge(n,r,{logger:u,purposeIdByTrackingType:t})||p(`preference-topics`,`Failed to sync one or more preference topics`))}if(F){u.info(c.magenta(`Syncing consent manager...`));try{await re(n,F,{logger:u}),u.info(c.green(`Successfully synced consent manager!`))}catch(e){p(`consent-manager`,e.message),u.error(c.red(`Failed to sync consent manager! - ${e.message}`))}}if(R){let t=await Se(n,R,{logger:e});f||=!t}if(B){let t=await xe(n,B,{logger:e});f||=!t}if(z){let t=await be(n,z,{logger:e});f||=!t}if(Ae){let t=await we(n,Ae,{logger:e});f||=!t}if(g&&(e.info(c.magenta(`Syncing "${g.length}" email templates...`)),await E(g,async t=>{e.info(c.magenta(`Syncing template "${t.title}"...`));try{await Te(n,t,{logger:e}),e.info(c.green(`Successfully synced template "${t.title}"!`))}catch(n){f=!0,e.error(c.red(`Failed to sync template "${t.title}"! - ${n.message}`))}},{concurrency:10}),e.info(c.green(`Synced "${g.length}" email templates!`))),M){let t=await ne(n,M,{logger:e});f||=!t}if(W){let t=await Ee(n,W,{logger:e});f||=!t}if(G){let t=await oe(n,G,{logger:e});f||=!t}if(q){let t=await ye(n,q,{logger:e});f||=!t}if(Ne){let t=await pe(n,Ne,{logger:e});f||=!t}if(V){let t=await ee(n,V,{logger:e});f||=!t}if(H){let t=await T(n,H,{logger:e});f||=!t}if(U){let t=await w(n,U,{logger:e});f||=!t}if(P){let t=await ae(n,P,{logger:e});f||=!t}if(ke){let t=await S(n,ke,{logger:e});f||=!t}if(b){e.info(c.magenta(`Syncing "${b.length}" attributes...`));let t=await h(n,{logger:e});await E(b,async r=>{let i=t.find(e=>e.name===r.name);e.info(c.magenta(`Syncing attribute "${r.name}"...`));try{await te(n,r,{existingAttribute:i,deleteExtraAttributeValues:o,logger:e}),e.info(c.green(`Successfully synced attribute "${r.name}"!`))}catch(t){f=!0,e.error(c.red(`Failed to sync attribute "${r.name}"! - ${t.message}`))}},{concurrency:10}),e.info(c.green(`Synced "${b.length}" attributes!`))}if(J){let t=await C(n,J,{logger:e});f||=!t}if(N&&(e.info(c.magenta(`Syncing "${N.length}" enrichers...`)),await E(N,async t=>{e.info(c.magenta(`Syncing enricher "${t.title}"...`));try{await ue(n,{input:t,identifierByName:Z,dataSubjectsByName:Q,logger:e}),e.info(c.green(`Successfully synced enricher "${t.title}"!`))}catch(n){f=!0,e.error(c.red(`Failed to sync enricher "${t.title}"! - ${n.message}`))}},{concurrency:10}),e.info(c.green(`Synced "${N.length}" enrichers!`))),O&&(e.info(c.magenta(`Syncing "${O.length}" identifiers...`)),await E(O,async t=>{let r=Z[t.name];if(!r)throw Error(`Failed to find identifier with name: ${t.type}. Should have been auto-created by cli.`);e.info(c.magenta(`Syncing identifier "${t.type}"...`));try{await de(n,{input:t,dataSubjectsByName:Q,identifierId:r.id,skipPublish:!i,logger:e}),e.info(c.green(`Successfully synced identifier "${t.type}"!`))}catch(n){f=!0,e.info(c.red(`Failed to sync identifier "${t.type}"! - ${n.message}`))}},{concurrency:10}),e.info(c.green(`Synced "${O.length}" identifiers!`))),D){e.info(c.magenta(`Syncing "${D.length}" actions...`));let t=await m(n,{logger:e});await E(D,async r=>{let a=t.find(e=>e.type===r.type);if(!a)throw Error(`Failed to find action with type: ${r.type}. Should have already existing in the organization.`);e.info(c.magenta(`Syncing action "${r.type}"...`));try{await x(n,{action:r,actionId:a.id,skipPublish:!i},{logger:e}),e.info(c.green(`Successfully synced action "${r.type}"!`))}catch(t){f=!0,e.error(c.red(`Failed to sync action "${r.type}"! - ${t.message}`))}},{concurrency:10}),e.info(c.green(`Synced "${D.length}" actions!`))}if(k){e.info(c.magenta(`Syncing "${k.length}" data subjects...`));let t=await _(n,{logger:e});await E(k,async r=>{let a=t.find(e=>e.type===r.type);if(!a)throw Error(`Failed to find data subject with type: ${r.type}. Should have already existing in the organization.`);e.info(c.magenta(`Syncing data subject "${r.type}"...`));try{await le(n,{input:r,dataSubjectId:a.id,skipPublish:!i,logger:e}),e.info(c.green(`Successfully synced data subject "${r.type}"!`))}catch(t){f=!0
|
|
3
|
-
//# sourceMappingURL=parseVariablesFromString-
|
|
1
|
+
import{t as e}from"./logger-Ckep4QXn.mjs";import{chunk as t,difference as n,flatten as r,keyBy as i,uniq as a}from"lodash-es";import{apply as o,getEntries as s}from"@transcend-io/type-utils";import c from"colors";import{CREATE_DATA_SILOS as l,UPDATE_DATA_SILOS as u,UPDATE_OR_CREATE_DATA_POINT as d,convertToDataSubjectBlockList as f,createDataSubject as p,fetchAllActions as m,fetchAllAttributes as h,fetchAllDataSilos as g,fetchAllDataSubjects as _,fetchApiKeys as v,fetchIdentifiersAndCreateMissing as y,makeGraphQLRequest as b,syncAction as x,syncActionItemCollections as S,syncActionItems as C,syncAgentFiles as w,syncAgentFunctions as T,syncAgents as ee,syncAttribute as te,syncBusinessEntities as ne,syncConsentManager as re,syncConsentWorkflowTriggers as ie,syncCookies as ae,syncDataCategories as oe,syncDataFlows as se,syncDataSiloDependencies as ce,syncDataSubject as le,syncEnricher as ue,syncIdentifier as de,syncIntlMessages as fe,syncPartitions as pe,syncPolicies as me,syncPreferenceOptionValues as he,syncPreferenceTopics as ge,syncPrivacyCenter as _e,syncProcessingActivities as ve,syncProcessingPurposes as ye,syncPromptGroups as be,syncPromptPartials as xe,syncPrompts as Se,syncPurposes as Ce,syncTeams as we,syncTemplate as Te,syncVendors as Ee,syncWorkflowConfigs as De}from"@transcend-io/sdk";import{map as E,mapSeries as D}from"@transcend-io/utils";import O from"cli-progress";const k=/^[A-Za-z]+$/;function Oe(e){let t=[],n=(e,n)=>{k.test(e)||t.push(`${n}: slug "${e}" is invalid — slugs must contain only alphabetical letters (A-Z, a-z). Topic slugs are normalized to PascalCase server-side, so YAML slugs should already be PascalCase or matching will break on subsequent pulls.`)};for(let t of e[`preference-options`]??[])n(t.slug,`preference-options`);for(let t of e.purposes??[])for(let e of t[`preference-topics`]??[]){n(e.slug,`purposes (topic "${e.title}")`);for(let t of e.options??[])n(t.slug,`purposes (topic "${e.title}" option "${t.title}")`)}return t}async function A({"data-silos":t=[],"data-subjects":o=[],"processing-activities":s=[],enrichers:l=[]},u,d=!1){let f=a([...r(t.map(e=>e[`data-subjects`]||[])||[]),...r(s.map(({dataSubjectTypes:e})=>e??[])??[]),...r(l.map(e=>e[`data-subjects`]||[])||[]),...o.map(e=>e.type)]);if(f.length===0&&!d)return{};let m=await _(u,{logger:e}),h=i(m,`type`),g=n(f,m.map(({type:e})=>e));if(g.length>0){e.info(c.magenta(`Creating ${g.length} new data subjects...`));for(let t of g){e.info(c.magenta(`Creating data subject ${t}...`));let n=await p(u,{input:t,logger:e});e.info(c.green(`Created data subject ${t}!`)),h[t]=n}}return h}async function j(n,r,{pageSize:a,dataSubjectsByName:s,apiKeysByTitle:p}){let m=!1,h=new Date().getTime();e.info(c.magenta(`Syncing "${n.length}" data silos...`));let _=i(await g(r,{titles:n.map(({title:e})=>e),pageSize:a,logger:e}),`title`),v=n.filter(({title:e})=>!_[e]);v.length>0&&(e.info(c.magenta(`Creating "${v.length}" data silos that did not exist...`)),await D(t(v,20),async t=>{let{createDataSilos:{dataSilos:n}}=await b(r,l,{variables:{input:t.map(e=>({name:e[`outer-type`]||e.integrationName,title:e.title,country:e.country,countrySubDivision:e.countrySubDivision,sombraId:e[`sombra-id`]}))},logger:e});n.forEach(e=>{_[e.title]=e})}),e.info(c.green(`Successfully created "${v.length}" data silos!`)));let y=t(n,20);await D(y,async(t,n)=>{e.info(c.magenta(`[Batch ${n+1}/${y.length}] Syncing "${t.length}" data silos`)),await b(r,u,{variables:{input:{dataSilos:t.map(e=>({id:_[e.title].id,country:e.country,countrySubDivision:e.countrySubDivision,url:e.url,headers:e.headers,description:e.description,identifiers:e[`identity-keys`],isLive:!e.disabled,ownerEmails:e.owners,teamNames:e.teams,dependedOnDataSiloTitles:e[`deletion-dependencies`]?void 0:[],apiKeyId:e[`api-key-title`]?p[e[`api-key-title`]].id:void 0,dataSubjectBlockListIds:e[`data-subjects`]?f(e[`data-subjects`],s):void 0,attributes:e.attributes,businessEntityTitles:e.businessEntityTitles,sombraId:e[`sombra-id`],notifyEmailAddress:e[`email-settings`]?.[`notify-email-address`],promptAVendorEmailSendFrequency:e[`email-settings`]?.[`send-frequency`],promptAVendorEmailSendType:e[`email-settings`]?.[`send-type`],promptAVendorEmailIncludeIdentifiersAttachment:e[`email-settings`]?.[`include-identifiers-attachment`],promptAVendorEmailCompletionLinkType:e[`email-settings`]?.[`completion-link-type`],manualWorkRetryFrequency:e[`email-settings`]?.[`manual-work-retry-frequency`]}))}},logger:e}),e.info(c.green(`[Batch ${n+1}/${y.length}] Synced "${t.length}" data silos!`))});let x=new O.SingleBar({},O.Presets.shades_classic),S=n.filter(({datapoints:e=[]})=>e.length>0),C=n.map(({datapoints:e=[]})=>e.length).reduce((e,t)=>e+t,0);e.info(c.magenta(`Syncing "${C}" datapoints from "${S.length}" data silos...`)),x.start(C,0);let w=0;await E(S,async({datapoints:t,title:n})=>{t&&await D(t,async t=>{let i=t.fields?t.fields.map(({key:e,description:t,categories:n,purposes:r,attributes:i,...a})=>({name:e,description:t,categories:n?n.map(e=>({...e,name:e.name||`Other`})):void 0,purposes:r?r.map(e=>({...e,name:e.name||`Other`})):void 0,attributes:i,accessRequestVisibilityEnabled:a[`access-request-visibility-enabled`],erasureRequestRedactionEnabled:a[`erasure-request-redaction-enabled`]})):void 0,a={dataSiloId:_[n].id,path:t.path,name:t.key,title:t.title,description:t.description,...t.owners?{ownerEmails:t.owners}:{},...t.teams?{teamNames:t.teams}:{},...t[`data-collection-tag`]?{dataCollectionTag:t[`data-collection-tag`]}:{},querySuggestions:t[`privacy-action-queries`]?Object.entries(t[`privacy-action-queries`]).map(([e,t])=>({requestType:e,suggestedQuery:t})):void 0,enabledActions:t[`privacy-actions`]||[],subDataPoints:i},o=(a.subDataPoints||[]).map(({name:e})=>e),s=o.filter((e,t)=>o.indexOf(e)!==t);if(s.length>0)e.info(c.red(`\nCannot update datapoint "${t.key}" as it has duplicate sub-datapoints with the same name: \n${s.join(`
|
|
2
|
+
`)}`)),m=!0;else try{await b(r,d,{variables:a,logger:e})}catch(r){e.info(c.red(`\nFailed to update datapoint "${t.key}" for data silo "${n}"! - \n${r.message}`)),m=!0}w+=1,x.update(w)})},{concurrency:10}),x.stop();let T=new Date().getTime()-h;return e.info(c.green(`Synced "${n.length}" data silos and "${C}" datapoints in "${T/1e3}" seconds!`)),{success:!m,dataSiloTitleToId:o(_,({id:e})=>e)}}async function M(t,n,{pageSize:r=50,publishToPrivacyCenter:i=!0,classifyService:a=!1,deleteExtraAttributeValues:o=!1,logger:s,warnings:l=[]}){let u=s??e,d=[],f=!1,p=(e,t,n)=>{d.push({resource:e,item:n,message:t}),f=!0};u.info(c.magenta(`Fetching data with page size ${r}...`));let{templates:g,attributes:b,actions:D,identifiers:O,"data-subjects":k,"business-entities":M,enrichers:N,cookies:P,"consent-manager":F,"data-silos":I,"data-flows":L,prompts:R,"prompt-groups":z,"prompt-partials":B,agents:V,"agent-functions":H,"agent-files":U,vendors:W,"data-categories":G,"processing-activities":K,"processing-purposes":q,"action-items":J,"action-item-collections":ke,teams:Ae,"privacy-center":je,messages:Y,policies:Me,partitions:Ne,"preference-workflow-configs":Pe,"workflow-configs":Fe}=t,Ie=t[`preference-options`],X=t.purposes,Le=Oe(t);if(Le.length>0){for(let e of Le)p(`preference-slugs`,e);return{success:!1,errors:d,warnings:l.length>0?l:void 0}}let[Z,Q,Re]=await Promise.all([N||O?y(n,{input:t,skipPublish:!i,logger:e}):{},I||k||N||K?A(t,n):{},I&&I.map(e=>e[`api-key-title`]||[]).reduce((e,t)=>e+t.length,0)>0?v(n,{apiKeyInputs:t,logger:e}):{}]);if(Pe?.length&&(await ie(n,Pe,{logger:u,pageSize:r})||p(`preference-workflow-configs`,`Failed to sync preference workflow configs`)),Fe?.length&&(await De(n,Fe,{logger:u})||p(`workflow-configs`,`Failed to sync workflow configs`)),Ie?.length&&(await he(n,Ie,{logger:u})||p(`preference-options`,`Failed to sync preference option values`)),X?.length){let{success:e,purposeIdByTrackingType:t}=await Ce(n,X,{logger:u});e||p(`purposes`,`Failed to sync one or more purposes`);let r=X.flatMap(e=>(e[`preference-topics`]??[]).map(t=>({...t,"tracking-type":e.trackingType})));r.length>0&&(await ge(n,r,{logger:u,purposeIdByTrackingType:t})||p(`preference-topics`,`Failed to sync one or more preference topics`))}if(F){u.info(c.magenta(`Syncing consent manager...`));try{await re(n,F,{logger:u}),u.info(c.green(`Successfully synced consent manager!`))}catch(e){p(`consent-manager`,e.message),u.error(c.red(`Failed to sync consent manager! - ${e.message}`))}}if(R){let t=await Se(n,R,{logger:e});f||=!t}if(B){let t=await xe(n,B,{logger:e});f||=!t}if(z){let t=await be(n,z,{logger:e});f||=!t}if(Ae){let t=await we(n,Ae,{logger:e});f||=!t}if(g&&(e.info(c.magenta(`Syncing "${g.length}" email templates...`)),await E(g,async t=>{e.info(c.magenta(`Syncing template "${t.title}"...`));try{await Te(n,t,{logger:e}),e.info(c.green(`Successfully synced template "${t.title}"!`))}catch(n){f=!0,e.error(c.red(`Failed to sync template "${t.title}"! - ${n.message}`))}},{concurrency:10}),e.info(c.green(`Synced "${g.length}" email templates!`))),M){let t=await ne(n,M,{logger:e});f||=!t}if(W){let t=await Ee(n,W,{logger:e});f||=!t}if(G){let t=await oe(n,G,{logger:e});f||=!t}if(q){let t=await ye(n,q,{logger:e});f||=!t}if(Ne){let t=await pe(n,Ne,{logger:e});f||=!t}if(V){let t=await ee(n,V,{logger:e});f||=!t}if(H){let t=await T(n,H,{logger:e});f||=!t}if(U){let t=await w(n,U,{logger:e});f||=!t}if(P){let t=await ae(n,P,{logger:e});f||=!t}if(ke){let t=await S(n,ke,{logger:e});f||=!t}if(b){e.info(c.magenta(`Syncing "${b.length}" attributes...`));let t=await h(n,{logger:e});await E(b,async r=>{let i=t.find(e=>e.name===r.name);e.info(c.magenta(`Syncing attribute "${r.name}"...`));try{await te(n,r,{existingAttribute:i,deleteExtraAttributeValues:o,logger:e}),e.info(c.green(`Successfully synced attribute "${r.name}"!`))}catch(t){f=!0,e.error(c.red(`Failed to sync attribute "${r.name}"! - ${t.message}`))}},{concurrency:10}),e.info(c.green(`Synced "${b.length}" attributes!`))}if(J){let t=await C(n,J,{logger:e});f||=!t}if(N&&(e.info(c.magenta(`Syncing "${N.length}" enrichers...`)),await E(N,async t=>{e.info(c.magenta(`Syncing enricher "${t.title}"...`));try{await ue(n,{input:t,identifierByName:Z,dataSubjectsByName:Q,logger:e}),e.info(c.green(`Successfully synced enricher "${t.title}"!`))}catch(n){f=!0,e.error(c.red(`Failed to sync enricher "${t.title}"! - ${n.message}`))}},{concurrency:10}),e.info(c.green(`Synced "${N.length}" enrichers!`))),O&&(e.info(c.magenta(`Syncing "${O.length}" identifiers...`)),await E(O,async t=>{let r=Z[t.name];if(!r)throw Error(`Failed to find identifier with name: ${t.type}. Should have been auto-created by cli.`);e.info(c.magenta(`Syncing identifier "${t.type}"...`));try{await de(n,{input:t,dataSubjectsByName:Q,identifierId:r.id,skipPublish:!i,logger:e}),e.info(c.green(`Successfully synced identifier "${t.type}"!`))}catch(n){f=!0,e.info(c.red(`Failed to sync identifier "${t.type}"! - ${n.message}`))}},{concurrency:10}),e.info(c.green(`Synced "${O.length}" identifiers!`))),D){e.info(c.magenta(`Syncing "${D.length}" actions...`));let t=await m(n,{logger:e});await E(D,async r=>{let a=t.find(e=>e.type===r.type);if(!a)throw Error(`Failed to find action with type: ${r.type}. Should have already existing in the organization.`);e.info(c.magenta(`Syncing action "${r.type}"...`));try{await x(n,{action:r,actionId:a.id,skipPublish:!i},{logger:e}),e.info(c.green(`Successfully synced action "${r.type}"!`))}catch(t){f=!0,e.error(c.red(`Failed to sync action "${r.type}"! - ${t.message}`))}},{concurrency:10}),e.info(c.green(`Synced "${D.length}" actions!`))}if(k){e.info(c.magenta(`Syncing "${k.length}" data subjects...`));let t=await _(n,{logger:e});await E(k,async r=>{let a=t.find(e=>e.type===r.type);if(!a)throw Error(`Failed to find data subject with type: ${r.type}. Should have already existing in the organization.`);e.info(c.magenta(`Syncing data subject "${r.type}"...`));try{await le(n,{input:r,dataSubjectId:a.id,skipPublish:!i,logger:e}),e.info(c.green(`Successfully synced data subject "${r.type}"!`))}catch(t){f=!0;let n=r.supportsAuthorizedAgent!==void 0&&/authorized.agent/i.test(t.message)?` (enable the Authorized Agents feature for this organization before setting "supportsAuthorizedAgent")`:``;e.info(c.red(`Failed to sync data subject "${r.type}"! - ${t.message}${n}`))}},{concurrency:10}),e.info(c.green(`Synced "${k.length}" data subjects!`))}if(L){let t=await se(n,L,{classifyService:a,logger:e});f||=!t}if(je)try{await _e(n,je,{logger:e,skipPublish:!i})||p(`privacy-center`,`Failed to sync privacy center`)}catch(e){p(`privacy-center`,e.message)}if(Y){let t=await fe(n,Y,{logger:e});f||=!t}if(Me){let t=await me(n,Me,{logger:e});f||=!t}let $=[];if(I){let{success:e,dataSiloTitleToId:t}=await j(I,n,{dataSubjectsByName:Q,apiKeysByTitle:Re,pageSize:r});I?.forEach(e=>{e[`deletion-dependencies`]&&$.push([t[e.title],e[`deletion-dependencies`]])}),f||=!e}if($.length>0&&await ce(n,{input:$,logger:e}),K){let t=await ve(n,K,{logger:e});f||=!t}return{success:!f,errors:d,warnings:l.length>0?l:void 0}}function N(e,...t){let n=JSON.parse(JSON.stringify(e));return t.forEach(e=>{s(e).forEach(([e,t])=>{n[e]===void 0?n[e]=t:Array.isArray(t)?n[e]=[...n[e],...t]:n[e]=t})}),n}function P(e){let t=e.split(`,`).filter(e=>!!e),n={};return t.forEach(e=>{let[t,r]=e.split(`:`);if(!t||!r)throw Error(`Invalid variable: ${e}. Expected format: key:value`);n[t]=r}),n}export{A as a,j as i,N as n,M as r,P as t};
|
|
3
|
+
//# sourceMappingURL=parseVariablesFromString-RM3zV9Av.mjs.map
|
package/dist/{parseVariablesFromString-CfXnITrG.mjs.map → parseVariablesFromString-RM3zV9Av.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseVariablesFromString-CfXnITrG.mjs","names":[],"sources":["../src/lib/preference-management/validatePreferenceManagementSlugs.ts","../src/lib/graphql/ensureAllDataSubjectsExist.ts","../src/lib/graphql/syncDataSilos.ts","../src/lib/graphql/syncConfigurationToTranscend.ts","../src/lib/mergeTranscendInputs.ts","../src/lib/helpers/parseVariablesFromString.ts"],"sourcesContent":["import type { TranscendInput } from '../../codecs.js';\n\n/** Slugs for preference topics and option values must be alphabetical letters only. */\nexport const PREFERENCE_SLUG_REGEX = /^[A-Za-z]+$/;\n\n/**\n * Validate preference topic and option value slugs before push.\n *\n * @param input - Parsed transcend.yml input\n * @returns List of validation error messages (empty when valid)\n */\nexport function validatePreferenceManagementSlugs(input: TranscendInput): string[] {\n const errors: string[] = [];\n\n const validateSlug = (slug: string, context: string): void => {\n if (!PREFERENCE_SLUG_REGEX.test(slug)) {\n errors.push(\n `${context}: slug \"${slug}\" is invalid — slugs must contain only alphabetical letters (A-Z, a-z). ` +\n 'Topic slugs are normalized to PascalCase server-side, so YAML slugs should already be PascalCase ' +\n 'or matching will break on subsequent pulls.',\n );\n }\n };\n\n for (const option of input['preference-options'] ?? []) {\n validateSlug(option.slug, 'preference-options');\n }\n\n for (const purpose of input.purposes ?? []) {\n for (const topic of purpose['preference-topics'] ?? []) {\n validateSlug(topic.slug, `purposes (topic \"${topic.title}\")`);\n for (const option of topic.options ?? []) {\n validateSlug(option.slug, `purposes (topic \"${topic.title}\" option \"${option.title}\")`);\n }\n }\n }\n\n return errors;\n}\n","import { createDataSubject, fetchAllDataSubjects, type DataSubject } from '@transcend-io/sdk';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\nimport { keyBy, flatten, uniq, difference } from 'lodash-es';\n\nimport { TranscendInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\n\n/**\n * Fetch all of the data subjects in the organization\n *\n * @param input - Input to fetch\n * @param client - GraphQL client\n * @param fetchAll - When true, always fetch all subjects\n * @returns The list of data subjects\n */\nexport async function ensureAllDataSubjectsExist(\n {\n 'data-silos': dataSilos = [],\n 'data-subjects': dataSubjects = [],\n 'processing-activities': processingActivities = [],\n enrichers = [],\n }: TranscendInput,\n client: GraphQLClient,\n fetchAll = false,\n): Promise<{ [type in string]: DataSubject }> {\n const expectedDataSubjects = uniq([\n ...flatten(dataSilos.map((silo) => silo['data-subjects'] || []) || []),\n ...flatten(processingActivities.map(({ dataSubjectTypes }) => dataSubjectTypes ?? []) ?? []),\n ...flatten(enrichers.map((enricher) => enricher['data-subjects'] || []) || []),\n ...dataSubjects.map((subject) => subject.type),\n ]);\n if (expectedDataSubjects.length === 0 && !fetchAll) {\n return {};\n }\n\n const internalSubjects = await fetchAllDataSubjects(client, { logger });\n const dataSubjectByName = keyBy(internalSubjects, 'type');\n\n const missingDataSubjects = difference(\n expectedDataSubjects,\n internalSubjects.map(({ type }) => type),\n );\n\n if (missingDataSubjects.length > 0) {\n logger.info(colors.magenta(`Creating ${missingDataSubjects.length} new data subjects...`));\n for (const dataSubjectType of missingDataSubjects) {\n logger.info(colors.magenta(`Creating data subject ${dataSubjectType}...`));\n const created = await createDataSubject(client, { input: dataSubjectType, logger });\n logger.info(colors.green(`Created data subject ${dataSubjectType}!`));\n dataSubjectByName[dataSubjectType] = created;\n }\n }\n\n return dataSubjectByName;\n}\n","import {\n makeGraphQLRequest,\n ApiKey,\n convertToDataSubjectBlockList,\n type DataSubject,\n fetchAllDataSilos,\n type DataSilo,\n CREATE_DATA_SILOS,\n UPDATE_DATA_SILOS,\n UPDATE_OR_CREATE_DATA_POINT,\n} from '@transcend-io/sdk';\nimport { apply } from '@transcend-io/type-utils';\nimport { mapSeries, map } from '@transcend-io/utils';\n/* eslint-disable max-lines */\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\nimport { chunk, keyBy } from 'lodash-es';\n\nimport { DataSiloInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\n\nconst BATCH_SILOS_LIMIT = 20;\n\n/**\n * Sync a data silo configuration\n *\n * @param dataSilos - Data silos to sync\n * @param client - GraphQL client\n * @param options - Options\n * @returns Data silo info\n */\nexport async function syncDataSilos(\n dataSilos: DataSiloInput[],\n client: GraphQLClient,\n {\n pageSize,\n dataSubjectsByName,\n apiKeysByTitle,\n }: {\n /** Page size */\n pageSize: number;\n /** The data subjects in the organization */\n dataSubjectsByName: { [type in string]: DataSubject };\n /** API key title to API key */\n apiKeysByTitle: { [title in string]: ApiKey };\n },\n): Promise<{\n /** Whether successfully updated */\n success: boolean;\n /** A mapping between data silo title to data silo ID */\n dataSiloTitleToId: { [k in string]: string };\n}> {\n let encounteredError = false;\n\n // Time duration\n const t0 = new Date().getTime();\n logger.info(colors.magenta(`Syncing \"${dataSilos.length}\" data silos...`));\n\n // Determine the set of data silos that already exist\n const existingDataSilos = await fetchAllDataSilos(client, {\n titles: dataSilos.map(({ title }) => title),\n pageSize,\n logger,\n });\n\n // Create a mapping of title -> existing silo, if it exists\n const existingDataSiloByTitle = keyBy<Pick<DataSilo, 'id' | 'title'>>(existingDataSilos, 'title');\n\n // Create new silos that do not exist\n const newDataSiloInputs = dataSilos.filter(({ title }) => !existingDataSiloByTitle[title]);\n if (newDataSiloInputs.length > 0) {\n logger.info(\n colors.magenta(`Creating \"${newDataSiloInputs.length}\" data silos that did not exist...`),\n );\n\n // Batch the creation\n const chunked = chunk(newDataSiloInputs, BATCH_SILOS_LIMIT);\n await mapSeries(chunked, async (dependencyUpdateChunk) => {\n const {\n createDataSilos: { dataSilos },\n } = await makeGraphQLRequest<{\n /** Mutation result */\n createDataSilos: {\n /** New data silos */\n dataSilos: Pick<DataSilo, 'id' | 'title'>[];\n };\n }>(client, CREATE_DATA_SILOS, {\n variables: {\n input: dependencyUpdateChunk.map((input) => ({\n name: input['outer-type'] || input.integrationName,\n title: input.title,\n country: input.country,\n countrySubDivision: input.countrySubDivision,\n sombraId: input['sombra-id'],\n })),\n },\n logger,\n });\n\n // save mapping of title and id\n dataSilos.forEach((silo) => {\n existingDataSiloByTitle[silo.title] = silo;\n });\n });\n\n logger.info(colors.green(`Successfully created \"${newDataSiloInputs.length}\" data silos!`));\n }\n\n // Batch the updates\n const chunkedUpdates = chunk(dataSilos, BATCH_SILOS_LIMIT);\n await mapSeries(chunkedUpdates, async (dataSiloUpdateChunk, ind) => {\n logger.info(\n colors.magenta(\n `[Batch ${ind + 1}/${chunkedUpdates.length}] Syncing \"${\n dataSiloUpdateChunk.length\n }\" data silos`,\n ),\n );\n await makeGraphQLRequest<{\n /** Mutation result */\n updateDataSilos: {\n /** New data silos */\n dataSilos: Pick<DataSilo, 'id' | 'title'>[];\n };\n }>(client, UPDATE_DATA_SILOS, {\n variables: {\n input: {\n dataSilos: dataSiloUpdateChunk.map((input) => ({\n id: existingDataSiloByTitle[input.title].id,\n country: input.country,\n countrySubDivision: input.countrySubDivision,\n url: input.url,\n headers: input.headers,\n description: input.description,\n identifiers: input['identity-keys'],\n isLive: !input.disabled,\n ownerEmails: input.owners,\n teamNames: input.teams,\n // clear out if not specified, otherwise the update needs to be applied after\n // all data silos are created\n dependedOnDataSiloTitles: input['deletion-dependencies'] ? undefined : [],\n apiKeyId: input['api-key-title']\n ? apiKeysByTitle[input['api-key-title']].id\n : undefined,\n dataSubjectBlockListIds: input['data-subjects']\n ? convertToDataSubjectBlockList(input['data-subjects'], dataSubjectsByName)\n : undefined,\n attributes: input.attributes,\n businessEntityTitles: input.businessEntityTitles,\n sombraId: input['sombra-id'],\n // AVC settings\n notifyEmailAddress: input['email-settings']?.['notify-email-address'],\n promptAVendorEmailSendFrequency: input['email-settings']?.['send-frequency'],\n promptAVendorEmailSendType: input['email-settings']?.['send-type'],\n promptAVendorEmailIncludeIdentifiersAttachment:\n input['email-settings']?.['include-identifiers-attachment'],\n promptAVendorEmailCompletionLinkType: input['email-settings']?.['completion-link-type'],\n manualWorkRetryFrequency: input['email-settings']?.['manual-work-retry-frequency'],\n })),\n },\n },\n logger,\n });\n logger.info(\n colors.green(\n `[Batch ${ind + 1}/${chunkedUpdates.length}] Synced \"${\n dataSiloUpdateChunk.length\n }\" data silos!`,\n ),\n );\n });\n\n // Sync datapoints\n\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n const dataSilosWithDataPoints = dataSilos.filter(({ datapoints = [] }) => datapoints.length > 0);\n const totalDataPoints = dataSilos\n .map(({ datapoints = [] }) => datapoints.length)\n .reduce((acc, count) => acc + count, 0);\n logger.info(\n colors.magenta(\n `Syncing \"${totalDataPoints}\" datapoints from \"${dataSilosWithDataPoints.length}\" data silos...`,\n ),\n );\n progressBar.start(totalDataPoints, 0);\n let total = 0;\n\n await map(\n dataSilosWithDataPoints,\n async ({ datapoints, title }) => {\n if (datapoints) {\n await mapSeries(datapoints, async (datapoint) => {\n const fields = datapoint.fields\n ? datapoint.fields.map(\n ({ key, description, categories, purposes, attributes, ...rest }) =>\n // TODO: Support setting title separately from the 'key/name'\n ({\n name: key,\n description,\n categories: !categories\n ? undefined\n : categories.map((category) => ({\n ...category,\n name: category.name || 'Other',\n })),\n purposes: !purposes\n ? undefined\n : purposes.map((purpose) => ({\n ...purpose,\n name: purpose.name || 'Other',\n })),\n attributes,\n accessRequestVisibilityEnabled: rest['access-request-visibility-enabled'],\n erasureRequestRedactionEnabled: rest['erasure-request-redaction-enabled'],\n }),\n )\n : undefined;\n\n const payload = {\n dataSiloId: existingDataSiloByTitle[title].id,\n path: datapoint.path,\n name: datapoint.key,\n title: datapoint.title,\n description: datapoint.description,\n ...(datapoint.owners\n ? {\n ownerEmails: datapoint.owners,\n }\n : {}),\n ...(datapoint.teams\n ? {\n teamNames: datapoint.teams,\n }\n : {}),\n ...(datapoint['data-collection-tag']\n ? { dataCollectionTag: datapoint['data-collection-tag'] }\n : {}),\n querySuggestions: !datapoint['privacy-action-queries']\n ? undefined\n : Object.entries(datapoint['privacy-action-queries']).map(([key, value]) => ({\n requestType: key,\n suggestedQuery: value,\n })),\n enabledActions: datapoint['privacy-actions'] || [], // clear out when not specified\n subDataPoints: fields,\n };\n\n // Ensure no duplicate sub-datapoints are provided\n const subDataPointsToUpdate = (payload.subDataPoints || []).map(({ name }) => name);\n const duplicateDataPoints = subDataPointsToUpdate.filter(\n (name, index) => subDataPointsToUpdate.indexOf(name) !== index,\n );\n if (duplicateDataPoints.length > 0) {\n logger.info(\n colors.red(\n `\\nCannot update datapoint \"${\n datapoint.key\n }\" as it has duplicate sub-datapoints with the same name: \\n${duplicateDataPoints.join(\n '\\n',\n )}`,\n ),\n );\n encounteredError = true;\n } else {\n try {\n await makeGraphQLRequest(client, UPDATE_OR_CREATE_DATA_POINT, {\n variables: payload,\n logger,\n });\n } catch (err) {\n logger.info(\n colors.red(\n `\\nFailed to update datapoint \"${datapoint.key}\" for data silo \"${title}\"! - \\n${err.message}`,\n ),\n );\n encounteredError = true;\n }\n }\n total += 1;\n progressBar.update(total);\n });\n }\n },\n {\n concurrency: 10,\n },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Synced \"${dataSilos.length}\" data silos and \"${totalDataPoints}\" datapoints in \"${\n totalTime / 1000\n }\" seconds!`,\n ),\n );\n return {\n success: !encounteredError,\n dataSiloTitleToId: apply(existingDataSiloByTitle, ({ id }) => id),\n };\n}\n/* eslint-enable max-lines */\n","import {\n fetchAllActions,\n fetchAllAttributes,\n fetchAllDataSubjects,\n fetchApiKeys,\n fetchIdentifiersAndCreateMissing,\n syncAction,\n syncActionItemCollections,\n syncActionItems,\n syncAgentFiles,\n syncAgentFunctions,\n syncAgents,\n syncAttribute,\n syncBusinessEntities,\n syncDataCategories,\n syncConsentManager,\n syncCookies,\n syncDataFlows,\n syncDataSubject,\n syncDataSiloDependencies,\n syncEnricher,\n syncIdentifier,\n syncIntlMessages,\n syncPartitions,\n syncPolicies,\n syncPrivacyCenter,\n syncProcessingActivities,\n syncProcessingPurposes,\n syncPromptGroups,\n syncPromptPartials,\n syncPrompts,\n syncConsentWorkflowTriggers,\n syncWorkflowConfigs,\n syncPreferenceOptionValues,\n syncPurposes,\n syncPreferenceTopics,\n syncTeams,\n syncTemplate,\n syncVendors,\n type Identifier,\n} from '@transcend-io/sdk';\nimport { map, type Logger, type SyncError, type SyncResult } from '@transcend-io/utils';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\n\n/* eslint-disable max-lines */\nimport { TranscendInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\nimport { validatePreferenceManagementSlugs } from '../preference-management/validatePreferenceManagementSlugs.js';\nimport { ensureAllDataSubjectsExist } from './ensureAllDataSubjectsExist.js';\nimport { syncDataSilos } from './syncDataSilos.js';\n\nconst CONCURRENCY = 10;\n\n/**\n * Sync the yaml input back to Transcend using the GraphQL APIs\n *\n * @param input - The yml input\n * @param client - GraphQL client\n * @param pageSize - Page size\n * @returns Structured sync result with per-resource errors\n */\nexport async function syncConfigurationToTranscend(\n input: TranscendInput,\n client: GraphQLClient,\n {\n pageSize = 50,\n // TODO: https://transcend.height.app/T-23779\n publishToPrivacyCenter = true,\n classifyService = false,\n deleteExtraAttributeValues = false,\n logger: syncLogger,\n warnings = [],\n }: {\n /** Page size */\n pageSize?: number;\n /** When true, skip publishing to privacy center */\n publishToPrivacyCenter?: boolean;\n /** When true, delete any attributes being synced up */\n deleteExtraAttributeValues?: boolean;\n /** classify data flow service if missing */\n classifyService?: boolean;\n /** Optional logger (e.g. collecting logger for MCP debug responses) */\n logger?: Logger;\n /** Non-fatal warnings to include in the result */\n warnings?: string[];\n },\n): Promise<SyncResult> {\n const activeLogger = syncLogger ?? logger;\n const errors: SyncError[] = [];\n let encounteredError = false;\n\n const recordError = (resource: string, message: string, item?: string): void => {\n errors.push({ resource, item, message });\n encounteredError = true;\n };\n\n activeLogger.info(colors.magenta(`Fetching data with page size ${pageSize}...`));\n\n const {\n templates,\n attributes,\n actions,\n identifiers,\n 'data-subjects': dataSubjects,\n 'business-entities': businessEntities,\n enrichers,\n cookies,\n 'consent-manager': consentManager,\n 'data-silos': dataSilos,\n 'data-flows': dataFlows,\n prompts,\n 'prompt-groups': promptGroups,\n 'prompt-partials': promptPartials,\n agents,\n 'agent-functions': agentFunctions,\n 'agent-files': agentFiles,\n vendors,\n 'data-categories': dataCategories,\n 'processing-activities': processingActivities,\n 'processing-purposes': processingPurposes,\n 'action-items': actionItems,\n 'action-item-collections': actionItemCollections,\n teams,\n 'privacy-center': privacyCenter,\n messages,\n policies,\n partitions,\n 'preference-workflow-configs': preferenceWorkflowConfigs,\n 'workflow-configs': workflowConfigs,\n } = input;\n\n const preferenceOptions = input['preference-options'];\n const purposes = input.purposes;\n\n const preferenceSlugErrors = validatePreferenceManagementSlugs(input);\n if (preferenceSlugErrors.length > 0) {\n for (const message of preferenceSlugErrors) {\n recordError('preference-slugs', message);\n }\n return {\n success: false,\n errors,\n warnings: warnings.length > 0 ? warnings : undefined,\n };\n }\n\n const [identifierByName, dataSubjectsByName, apiKeyTitleMap] = await Promise.all([\n // Ensure all identifiers are created and create a map from name -> identifier.id\n enrichers || identifiers\n ? fetchIdentifiersAndCreateMissing(client, {\n input,\n skipPublish: !publishToPrivacyCenter,\n logger,\n })\n : ({} as { [k in string]: Identifier }),\n // Grab all data subjects in the organization\n dataSilos || dataSubjects || enrichers || processingActivities\n ? ensureAllDataSubjectsExist(input, client)\n : {},\n // Grab API keys\n dataSilos &&\n dataSilos\n .map((dataSilo) => dataSilo['api-key-title'] || [])\n .reduce((acc, lst) => acc + lst.length, 0) > 0\n ? fetchApiKeys(client, { apiKeyInputs: input, logger })\n : {},\n ]);\n\n if (preferenceWorkflowConfigs?.length) {\n const preferenceWorkflowConfigsSuccess = await syncConsentWorkflowTriggers(\n client,\n preferenceWorkflowConfigs,\n {\n logger: activeLogger,\n pageSize,\n },\n );\n if (!preferenceWorkflowConfigsSuccess) {\n recordError('preference-workflow-configs', 'Failed to sync preference workflow configs');\n }\n }\n\n if (workflowConfigs?.length) {\n const workflowConfigsSuccess = await syncWorkflowConfigs(client, workflowConfigs, {\n logger: activeLogger,\n });\n if (!workflowConfigsSuccess) {\n recordError('workflow-configs', 'Failed to sync workflow configs');\n }\n }\n\n if (preferenceOptions?.length) {\n const preferenceOptionsSuccess = await syncPreferenceOptionValues(client, preferenceOptions, {\n logger: activeLogger,\n });\n if (!preferenceOptionsSuccess) {\n recordError('preference-options', 'Failed to sync preference option values');\n }\n }\n\n // Sync consent purposes and their nested preference topics.\n // Order matters: option values (above) exist first, then purposes, then topics\n // (which link to their purpose by ID and to option values by slug).\n if (purposes?.length) {\n const { success: purposesSuccess, purposeIdByTrackingType } = await syncPurposes(\n client,\n purposes,\n { logger: activeLogger },\n );\n if (!purposesSuccess) {\n recordError('purposes', 'Failed to sync one or more purposes');\n }\n\n const topics = purposes.flatMap((purpose) =>\n (purpose['preference-topics'] ?? []).map((topic) => ({\n ...topic,\n 'tracking-type': purpose.trackingType,\n })),\n );\n if (topics.length > 0) {\n const topicsSuccess = await syncPreferenceTopics(client, topics, {\n logger: activeLogger,\n purposeIdByTrackingType,\n });\n if (!topicsSuccess) {\n recordError('preference-topics', 'Failed to sync one or more preference topics');\n }\n }\n }\n\n // Sync consent manager\n if (consentManager) {\n activeLogger.info(colors.magenta('Syncing consent manager...'));\n try {\n await syncConsentManager(client, consentManager, { logger: activeLogger });\n activeLogger.info(colors.green('Successfully synced consent manager!'));\n } catch (err) {\n recordError('consent-manager', (err as Error).message);\n activeLogger.error(colors.red(`Failed to sync consent manager! - ${(err as Error).message}`));\n }\n }\n\n // Sync prompts\n if (prompts) {\n const promptsSuccess = await syncPrompts(client, prompts, { logger });\n encounteredError = encounteredError || !promptsSuccess;\n }\n if (promptPartials) {\n const promptsSuccess = await syncPromptPartials(client, promptPartials, { logger });\n encounteredError = encounteredError || !promptsSuccess;\n }\n if (promptGroups) {\n const promptsSuccess = await syncPromptGroups(client, promptGroups, { logger });\n encounteredError = encounteredError || !promptsSuccess;\n }\n\n if (teams) {\n const teamsSuccess = await syncTeams(client, teams, { logger });\n encounteredError = encounteredError || !teamsSuccess;\n }\n\n // Sync email templates\n if (templates) {\n logger.info(colors.magenta(`Syncing \"${templates.length}\" email templates...`));\n await map(\n templates,\n async (template) => {\n logger.info(colors.magenta(`Syncing template \"${template.title}\"...`));\n try {\n await syncTemplate(client, template, { logger });\n logger.info(colors.green(`Successfully synced template \"${template.title}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.error(colors.red(`Failed to sync template \"${template.title}\"! - ${err.message}`));\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${templates.length}\" email templates!`));\n }\n\n // Sync business entities\n if (businessEntities) {\n const businessEntitySuccess = await syncBusinessEntities(client, businessEntities, { logger });\n encounteredError = encounteredError || !businessEntitySuccess;\n }\n\n // Sync vendors\n if (vendors) {\n const vendorsSuccess = await syncVendors(client, vendors, { logger });\n encounteredError = encounteredError || !vendorsSuccess;\n }\n\n // Sync data categories\n if (dataCategories) {\n const dataCategoriesSuccess = await syncDataCategories(client, dataCategories, { logger });\n encounteredError = encounteredError || !dataCategoriesSuccess;\n }\n\n // Sync processing purposes\n if (processingPurposes) {\n const processingPurposesSuccess = await syncProcessingPurposes(client, processingPurposes, {\n logger,\n });\n encounteredError = encounteredError || !processingPurposesSuccess;\n }\n\n // Sync partitions\n if (partitions) {\n const partitionsSuccess = await syncPartitions(client, partitions, { logger });\n encounteredError = encounteredError || !partitionsSuccess;\n }\n\n // Sync agents\n if (agents) {\n const agentsSuccess = await syncAgents(client, agents, { logger });\n encounteredError = encounteredError || !agentsSuccess;\n }\n\n // Sync agent functions\n if (agentFunctions) {\n const agentFunctionsSuccess = await syncAgentFunctions(client, agentFunctions, { logger });\n encounteredError = encounteredError || !agentFunctionsSuccess;\n }\n\n // Sync agent files\n if (agentFiles) {\n const agentFilesSuccess = await syncAgentFiles(client, agentFiles, { logger });\n encounteredError = encounteredError || !agentFilesSuccess;\n }\n\n // Sync cookies\n if (cookies) {\n const cookiesSuccess = await syncCookies(client, cookies, { logger });\n encounteredError = encounteredError || !cookiesSuccess;\n }\n\n // Sync action item collections\n if (actionItemCollections) {\n const actionItemCollectionsSuccess = await syncActionItemCollections(\n client,\n actionItemCollections,\n { logger },\n );\n encounteredError = encounteredError || !actionItemCollectionsSuccess;\n }\n\n // Sync attributes\n if (attributes) {\n // Fetch existing\n logger.info(colors.magenta(`Syncing \"${attributes.length}\" attributes...`));\n const existingAttributes = await fetchAllAttributes(client, { logger });\n await map(\n attributes,\n async (attribute) => {\n const existing = existingAttributes.find((attr) => attr.name === attribute.name);\n\n logger.info(colors.magenta(`Syncing attribute \"${attribute.name}\"...`));\n try {\n await syncAttribute(client, attribute, {\n existingAttribute: existing,\n deleteExtraAttributeValues,\n logger,\n });\n logger.info(colors.green(`Successfully synced attribute \"${attribute.name}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.error(\n colors.red(`Failed to sync attribute \"${attribute.name}\"! - ${err.message}`),\n );\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${attributes.length}\" attributes!`));\n }\n\n // Sync action items\n if (actionItems) {\n const actionItemsSuccess = await syncActionItems(client, actionItems, { logger });\n encounteredError = encounteredError || !actionItemsSuccess;\n }\n\n // Sync enrichers\n if (enrichers) {\n logger.info(colors.magenta(`Syncing \"${enrichers.length}\" enrichers...`));\n await map(\n enrichers,\n async (enricher) => {\n logger.info(colors.magenta(`Syncing enricher \"${enricher.title}\"...`));\n try {\n await syncEnricher(client, {\n input: enricher,\n identifierByName,\n dataSubjectsByName,\n logger,\n });\n logger.info(colors.green(`Successfully synced enricher \"${enricher.title}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.error(colors.red(`Failed to sync enricher \"${enricher.title}\"! - ${err.message}`));\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${enrichers.length}\" enrichers!`));\n }\n\n // Sync identifiers\n if (identifiers) {\n // Fetch existing\n logger.info(colors.magenta(`Syncing \"${identifiers.length}\" identifiers...`));\n await map(\n identifiers,\n async (identifier) => {\n const existing = identifierByName[identifier.name];\n if (!existing) {\n throw new Error(\n `Failed to find identifier with name: ${identifier.type}. Should have been auto-created by cli.`,\n );\n }\n\n logger.info(colors.magenta(`Syncing identifier \"${identifier.type}\"...`));\n try {\n await syncIdentifier(client, {\n input: identifier,\n dataSubjectsByName,\n identifierId: existing.id,\n skipPublish: !publishToPrivacyCenter,\n logger,\n });\n logger.info(colors.green(`Successfully synced identifier \"${identifier.type}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.info(\n colors.red(`Failed to sync identifier \"${identifier.type}\"! - ${err.message}`),\n );\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${identifiers.length}\" identifiers!`));\n }\n\n // Sync actions\n if (actions) {\n // Fetch existing\n logger.info(colors.magenta(`Syncing \"${actions.length}\" actions...`));\n const existingActions = await fetchAllActions(client, { logger });\n await map(\n actions,\n async (action) => {\n const existing = existingActions.find((act) => act.type === action.type);\n if (!existing) {\n throw new Error(\n `Failed to find action with type: ${action.type}. Should have already existing in the organization.`,\n );\n }\n\n logger.info(colors.magenta(`Syncing action \"${action.type}\"...`));\n try {\n await syncAction(\n client,\n {\n action,\n actionId: existing.id,\n skipPublish: !publishToPrivacyCenter,\n },\n { logger },\n );\n logger.info(colors.green(`Successfully synced action \"${action.type}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.error(colors.red(`Failed to sync action \"${action.type}\"! - ${err.message}`));\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${actions.length}\" actions!`));\n }\n\n // Sync data subjects\n if (dataSubjects) {\n // Fetch existing\n logger.info(colors.magenta(`Syncing \"${dataSubjects.length}\" data subjects...`));\n const existingDataSubjects = await fetchAllDataSubjects(client, { logger });\n await map(\n dataSubjects,\n async (dataSubject) => {\n const existing = existingDataSubjects.find((subj) => subj.type === dataSubject.type);\n if (!existing) {\n throw new Error(\n `Failed to find data subject with type: ${dataSubject.type}. Should have already existing in the organization.`,\n );\n }\n\n logger.info(colors.magenta(`Syncing data subject \"${dataSubject.type}\"...`));\n try {\n await syncDataSubject(client, {\n input: dataSubject,\n dataSubjectId: existing.id,\n skipPublish: !publishToPrivacyCenter,\n logger,\n });\n logger.info(colors.green(`Successfully synced data subject \"${dataSubject.type}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.info(\n colors.red(`Failed to sync data subject \"${dataSubject.type}\"! - ${err.message}`),\n );\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${dataSubjects.length}\" data subjects!`));\n }\n\n // Sync data flows\n if (dataFlows) {\n const syncedDataFlows = await syncDataFlows(client, dataFlows, { classifyService, logger });\n encounteredError = encounteredError || !syncedDataFlows;\n }\n\n // Sync privacy center\n if (privacyCenter) {\n try {\n const privacyCenterSuccess = await syncPrivacyCenter(client, privacyCenter, {\n logger,\n skipPublish: !publishToPrivacyCenter,\n });\n if (!privacyCenterSuccess) {\n recordError('privacy-center', 'Failed to sync privacy center');\n }\n } catch (err) {\n recordError('privacy-center', (err as Error).message);\n }\n }\n\n // Sync messages\n if (messages) {\n const messagesSuccess = await syncIntlMessages(client, messages, { logger });\n encounteredError = encounteredError || !messagesSuccess;\n }\n\n // Sync policies\n if (policies) {\n const policiesSuccess = await syncPolicies(client, policies, { logger });\n encounteredError = encounteredError || !policiesSuccess;\n }\n\n // Store dependency updates\n const dependencyUpdates: [string, string[]][] = [];\n // Sync data silos\n if (dataSilos) {\n const { success, dataSiloTitleToId } = await syncDataSilos(dataSilos, client, {\n dataSubjectsByName,\n apiKeysByTitle: apiKeyTitleMap,\n pageSize,\n });\n dataSilos?.forEach((dataSilo) => {\n // Queue up dependency update\n if (dataSilo['deletion-dependencies']) {\n dependencyUpdates.push([\n dataSiloTitleToId[dataSilo.title],\n dataSilo['deletion-dependencies'],\n ]);\n }\n });\n encounteredError = encounteredError || !success;\n }\n\n // Dependencies updated at the end after all data silos are created\n if (dependencyUpdates.length > 0) {\n await syncDataSiloDependencies(client, { input: dependencyUpdates, logger });\n }\n\n // Update processing activities\n if (processingActivities) {\n const processingActivitySuccess = await syncProcessingActivities(client, processingActivities, {\n logger,\n });\n encounteredError = encounteredError || !processingActivitySuccess;\n }\n\n if (publishToPrivacyCenter) {\n // TODO: https://transcend.height.app/T-23779\n }\n\n return {\n success: !encounteredError,\n errors,\n warnings: warnings.length > 0 ? warnings : undefined,\n };\n}\n/* eslint-enable max-lines */\n","import { getEntries } from '@transcend-io/type-utils';\n\nimport { TranscendInput } from '../codecs.js';\n\n/**\n * Combine a set of TranscendInput yaml files into a single yaml\n *\n * @param base - Base input\n * @param inputs - The list of inputs\n * @returns Merged input\n */\nexport function mergeTranscendInputs(\n base: TranscendInput,\n ...inputs: TranscendInput[]\n): TranscendInput {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const cloned: any = JSON.parse(JSON.stringify(base));\n inputs.forEach((input) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getEntries(input).forEach(([key, value]: [any, any]) => {\n if (cloned[key] === undefined) {\n cloned[key] = value;\n } else if (Array.isArray(value)) {\n cloned[key] = [...cloned[key], ...value];\n } else {\n cloned[key] = value;\n }\n });\n });\n return cloned;\n}\n","/**\n * Parse variables from string\n *\n * @param variables - Variables as string\n * @returns Variables as object\n */\nexport function parseVariablesFromString(variables: string): {\n [k in string]: string;\n} {\n // Parse out the variables\n const splitVars = variables.split(',').filter((x) => !!x);\n const vars: { [k in string]: string } = {};\n splitVars.forEach((variable) => {\n const [k, v] = variable.split(':');\n if (!k || !v) {\n throw new Error(`Invalid variable: ${variable}. Expected format: key:value`);\n }\n vars[k] = v;\n });\n return vars;\n}\n"],"mappings":"03CAGA,MAAa,EAAwB,cAQrC,SAAgB,GAAkC,EAAiC,CACjF,IAAM,EAAmB,EAAE,CAErB,GAAgB,EAAc,IAA0B,CACvD,EAAsB,KAAK,EAAK,EACnC,EAAO,KACL,GAAG,EAAQ,UAAU,EAAK,sNAG3B,EAIL,IAAK,IAAM,KAAU,EAAM,uBAAyB,EAAE,CACpD,EAAa,EAAO,KAAM,qBAAqB,CAGjD,IAAK,IAAM,KAAW,EAAM,UAAY,EAAE,CACxC,IAAK,IAAM,KAAS,EAAQ,sBAAwB,EAAE,CAAE,CACtD,EAAa,EAAM,KAAM,oBAAoB,EAAM,MAAM,IAAI,CAC7D,IAAK,IAAM,KAAU,EAAM,SAAW,EAAE,CACtC,EAAa,EAAO,KAAM,oBAAoB,EAAM,MAAM,YAAY,EAAO,MAAM,IAAI,CAK7F,OAAO,ECr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AO,QAAS,GAAU,CAExB,EAAW,EAAM,CAAC,SAAS,CAAC,EAAK,KAAuB,CAClD,EAAO,KAAS,IAAA,GAClB,EAAO,GAAO,EACL,MAAM,QAAQ,EAAM,CAC7B,EAAO,GAAO,CAAC,GAAG,EAAO,GAAM,GAAG,EAAM,CAExC,EAAO,GAAO,GAEhB,EACF,CACK,ECvBT,SAAgB,EAAyB,EAEvC,CAEA,IAAM,EAAY,EAAU,MAAM,IAAI,CAAC,OAAQ,GAAM,CAAC,CAAC,EAAE,CACnD,EAAkC,EAAE,CAQ1C,OAPA,EAAU,QAAS,GAAa,CAC9B,GAAM,CAAC,EAAG,GAAK,EAAS,MAAM,IAAI,CAClC,GAAI,CAAC,GAAK,CAAC,EACT,MAAU,MAAM,qBAAqB,EAAS,8BAA8B,CAE9E,EAAK,GAAK,GACV,CACK"}
|
|
1
|
+
{"version":3,"file":"parseVariablesFromString-RM3zV9Av.mjs","names":[],"sources":["../src/lib/preference-management/validatePreferenceManagementSlugs.ts","../src/lib/graphql/ensureAllDataSubjectsExist.ts","../src/lib/graphql/syncDataSilos.ts","../src/lib/graphql/syncConfigurationToTranscend.ts","../src/lib/mergeTranscendInputs.ts","../src/lib/helpers/parseVariablesFromString.ts"],"sourcesContent":["import type { TranscendInput } from '../../codecs.js';\n\n/** Slugs for preference topics and option values must be alphabetical letters only. */\nexport const PREFERENCE_SLUG_REGEX = /^[A-Za-z]+$/;\n\n/**\n * Validate preference topic and option value slugs before push.\n *\n * @param input - Parsed transcend.yml input\n * @returns List of validation error messages (empty when valid)\n */\nexport function validatePreferenceManagementSlugs(input: TranscendInput): string[] {\n const errors: string[] = [];\n\n const validateSlug = (slug: string, context: string): void => {\n if (!PREFERENCE_SLUG_REGEX.test(slug)) {\n errors.push(\n `${context}: slug \"${slug}\" is invalid — slugs must contain only alphabetical letters (A-Z, a-z). ` +\n 'Topic slugs are normalized to PascalCase server-side, so YAML slugs should already be PascalCase ' +\n 'or matching will break on subsequent pulls.',\n );\n }\n };\n\n for (const option of input['preference-options'] ?? []) {\n validateSlug(option.slug, 'preference-options');\n }\n\n for (const purpose of input.purposes ?? []) {\n for (const topic of purpose['preference-topics'] ?? []) {\n validateSlug(topic.slug, `purposes (topic \"${topic.title}\")`);\n for (const option of topic.options ?? []) {\n validateSlug(option.slug, `purposes (topic \"${topic.title}\" option \"${option.title}\")`);\n }\n }\n }\n\n return errors;\n}\n","import { createDataSubject, fetchAllDataSubjects, type DataSubject } from '@transcend-io/sdk';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\nimport { keyBy, flatten, uniq, difference } from 'lodash-es';\n\nimport { TranscendInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\n\n/**\n * Fetch all of the data subjects in the organization\n *\n * @param input - Input to fetch\n * @param client - GraphQL client\n * @param fetchAll - When true, always fetch all subjects\n * @returns The list of data subjects\n */\nexport async function ensureAllDataSubjectsExist(\n {\n 'data-silos': dataSilos = [],\n 'data-subjects': dataSubjects = [],\n 'processing-activities': processingActivities = [],\n enrichers = [],\n }: TranscendInput,\n client: GraphQLClient,\n fetchAll = false,\n): Promise<{ [type in string]: DataSubject }> {\n const expectedDataSubjects = uniq([\n ...flatten(dataSilos.map((silo) => silo['data-subjects'] || []) || []),\n ...flatten(processingActivities.map(({ dataSubjectTypes }) => dataSubjectTypes ?? []) ?? []),\n ...flatten(enrichers.map((enricher) => enricher['data-subjects'] || []) || []),\n ...dataSubjects.map((subject) => subject.type),\n ]);\n if (expectedDataSubjects.length === 0 && !fetchAll) {\n return {};\n }\n\n const internalSubjects = await fetchAllDataSubjects(client, { logger });\n const dataSubjectByName = keyBy(internalSubjects, 'type');\n\n const missingDataSubjects = difference(\n expectedDataSubjects,\n internalSubjects.map(({ type }) => type),\n );\n\n if (missingDataSubjects.length > 0) {\n logger.info(colors.magenta(`Creating ${missingDataSubjects.length} new data subjects...`));\n for (const dataSubjectType of missingDataSubjects) {\n logger.info(colors.magenta(`Creating data subject ${dataSubjectType}...`));\n const created = await createDataSubject(client, { input: dataSubjectType, logger });\n logger.info(colors.green(`Created data subject ${dataSubjectType}!`));\n dataSubjectByName[dataSubjectType] = created;\n }\n }\n\n return dataSubjectByName;\n}\n","import {\n makeGraphQLRequest,\n ApiKey,\n convertToDataSubjectBlockList,\n type DataSubject,\n fetchAllDataSilos,\n type DataSilo,\n CREATE_DATA_SILOS,\n UPDATE_DATA_SILOS,\n UPDATE_OR_CREATE_DATA_POINT,\n} from '@transcend-io/sdk';\nimport { apply } from '@transcend-io/type-utils';\nimport { mapSeries, map } from '@transcend-io/utils';\n/* eslint-disable max-lines */\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\nimport { chunk, keyBy } from 'lodash-es';\n\nimport { DataSiloInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\n\nconst BATCH_SILOS_LIMIT = 20;\n\n/**\n * Sync a data silo configuration\n *\n * @param dataSilos - Data silos to sync\n * @param client - GraphQL client\n * @param options - Options\n * @returns Data silo info\n */\nexport async function syncDataSilos(\n dataSilos: DataSiloInput[],\n client: GraphQLClient,\n {\n pageSize,\n dataSubjectsByName,\n apiKeysByTitle,\n }: {\n /** Page size */\n pageSize: number;\n /** The data subjects in the organization */\n dataSubjectsByName: { [type in string]: DataSubject };\n /** API key title to API key */\n apiKeysByTitle: { [title in string]: ApiKey };\n },\n): Promise<{\n /** Whether successfully updated */\n success: boolean;\n /** A mapping between data silo title to data silo ID */\n dataSiloTitleToId: { [k in string]: string };\n}> {\n let encounteredError = false;\n\n // Time duration\n const t0 = new Date().getTime();\n logger.info(colors.magenta(`Syncing \"${dataSilos.length}\" data silos...`));\n\n // Determine the set of data silos that already exist\n const existingDataSilos = await fetchAllDataSilos(client, {\n titles: dataSilos.map(({ title }) => title),\n pageSize,\n logger,\n });\n\n // Create a mapping of title -> existing silo, if it exists\n const existingDataSiloByTitle = keyBy<Pick<DataSilo, 'id' | 'title'>>(existingDataSilos, 'title');\n\n // Create new silos that do not exist\n const newDataSiloInputs = dataSilos.filter(({ title }) => !existingDataSiloByTitle[title]);\n if (newDataSiloInputs.length > 0) {\n logger.info(\n colors.magenta(`Creating \"${newDataSiloInputs.length}\" data silos that did not exist...`),\n );\n\n // Batch the creation\n const chunked = chunk(newDataSiloInputs, BATCH_SILOS_LIMIT);\n await mapSeries(chunked, async (dependencyUpdateChunk) => {\n const {\n createDataSilos: { dataSilos },\n } = await makeGraphQLRequest<{\n /** Mutation result */\n createDataSilos: {\n /** New data silos */\n dataSilos: Pick<DataSilo, 'id' | 'title'>[];\n };\n }>(client, CREATE_DATA_SILOS, {\n variables: {\n input: dependencyUpdateChunk.map((input) => ({\n name: input['outer-type'] || input.integrationName,\n title: input.title,\n country: input.country,\n countrySubDivision: input.countrySubDivision,\n sombraId: input['sombra-id'],\n })),\n },\n logger,\n });\n\n // save mapping of title and id\n dataSilos.forEach((silo) => {\n existingDataSiloByTitle[silo.title] = silo;\n });\n });\n\n logger.info(colors.green(`Successfully created \"${newDataSiloInputs.length}\" data silos!`));\n }\n\n // Batch the updates\n const chunkedUpdates = chunk(dataSilos, BATCH_SILOS_LIMIT);\n await mapSeries(chunkedUpdates, async (dataSiloUpdateChunk, ind) => {\n logger.info(\n colors.magenta(\n `[Batch ${ind + 1}/${chunkedUpdates.length}] Syncing \"${\n dataSiloUpdateChunk.length\n }\" data silos`,\n ),\n );\n await makeGraphQLRequest<{\n /** Mutation result */\n updateDataSilos: {\n /** New data silos */\n dataSilos: Pick<DataSilo, 'id' | 'title'>[];\n };\n }>(client, UPDATE_DATA_SILOS, {\n variables: {\n input: {\n dataSilos: dataSiloUpdateChunk.map((input) => ({\n id: existingDataSiloByTitle[input.title].id,\n country: input.country,\n countrySubDivision: input.countrySubDivision,\n url: input.url,\n headers: input.headers,\n description: input.description,\n identifiers: input['identity-keys'],\n isLive: !input.disabled,\n ownerEmails: input.owners,\n teamNames: input.teams,\n // clear out if not specified, otherwise the update needs to be applied after\n // all data silos are created\n dependedOnDataSiloTitles: input['deletion-dependencies'] ? undefined : [],\n apiKeyId: input['api-key-title']\n ? apiKeysByTitle[input['api-key-title']].id\n : undefined,\n dataSubjectBlockListIds: input['data-subjects']\n ? convertToDataSubjectBlockList(input['data-subjects'], dataSubjectsByName)\n : undefined,\n attributes: input.attributes,\n businessEntityTitles: input.businessEntityTitles,\n sombraId: input['sombra-id'],\n // AVC settings\n notifyEmailAddress: input['email-settings']?.['notify-email-address'],\n promptAVendorEmailSendFrequency: input['email-settings']?.['send-frequency'],\n promptAVendorEmailSendType: input['email-settings']?.['send-type'],\n promptAVendorEmailIncludeIdentifiersAttachment:\n input['email-settings']?.['include-identifiers-attachment'],\n promptAVendorEmailCompletionLinkType: input['email-settings']?.['completion-link-type'],\n manualWorkRetryFrequency: input['email-settings']?.['manual-work-retry-frequency'],\n })),\n },\n },\n logger,\n });\n logger.info(\n colors.green(\n `[Batch ${ind + 1}/${chunkedUpdates.length}] Synced \"${\n dataSiloUpdateChunk.length\n }\" data silos!`,\n ),\n );\n });\n\n // Sync datapoints\n\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n const dataSilosWithDataPoints = dataSilos.filter(({ datapoints = [] }) => datapoints.length > 0);\n const totalDataPoints = dataSilos\n .map(({ datapoints = [] }) => datapoints.length)\n .reduce((acc, count) => acc + count, 0);\n logger.info(\n colors.magenta(\n `Syncing \"${totalDataPoints}\" datapoints from \"${dataSilosWithDataPoints.length}\" data silos...`,\n ),\n );\n progressBar.start(totalDataPoints, 0);\n let total = 0;\n\n await map(\n dataSilosWithDataPoints,\n async ({ datapoints, title }) => {\n if (datapoints) {\n await mapSeries(datapoints, async (datapoint) => {\n const fields = datapoint.fields\n ? datapoint.fields.map(\n ({ key, description, categories, purposes, attributes, ...rest }) =>\n // TODO: Support setting title separately from the 'key/name'\n ({\n name: key,\n description,\n categories: !categories\n ? undefined\n : categories.map((category) => ({\n ...category,\n name: category.name || 'Other',\n })),\n purposes: !purposes\n ? undefined\n : purposes.map((purpose) => ({\n ...purpose,\n name: purpose.name || 'Other',\n })),\n attributes,\n accessRequestVisibilityEnabled: rest['access-request-visibility-enabled'],\n erasureRequestRedactionEnabled: rest['erasure-request-redaction-enabled'],\n }),\n )\n : undefined;\n\n const payload = {\n dataSiloId: existingDataSiloByTitle[title].id,\n path: datapoint.path,\n name: datapoint.key,\n title: datapoint.title,\n description: datapoint.description,\n ...(datapoint.owners\n ? {\n ownerEmails: datapoint.owners,\n }\n : {}),\n ...(datapoint.teams\n ? {\n teamNames: datapoint.teams,\n }\n : {}),\n ...(datapoint['data-collection-tag']\n ? { dataCollectionTag: datapoint['data-collection-tag'] }\n : {}),\n querySuggestions: !datapoint['privacy-action-queries']\n ? undefined\n : Object.entries(datapoint['privacy-action-queries']).map(([key, value]) => ({\n requestType: key,\n suggestedQuery: value,\n })),\n enabledActions: datapoint['privacy-actions'] || [], // clear out when not specified\n subDataPoints: fields,\n };\n\n // Ensure no duplicate sub-datapoints are provided\n const subDataPointsToUpdate = (payload.subDataPoints || []).map(({ name }) => name);\n const duplicateDataPoints = subDataPointsToUpdate.filter(\n (name, index) => subDataPointsToUpdate.indexOf(name) !== index,\n );\n if (duplicateDataPoints.length > 0) {\n logger.info(\n colors.red(\n `\\nCannot update datapoint \"${\n datapoint.key\n }\" as it has duplicate sub-datapoints with the same name: \\n${duplicateDataPoints.join(\n '\\n',\n )}`,\n ),\n );\n encounteredError = true;\n } else {\n try {\n await makeGraphQLRequest(client, UPDATE_OR_CREATE_DATA_POINT, {\n variables: payload,\n logger,\n });\n } catch (err) {\n logger.info(\n colors.red(\n `\\nFailed to update datapoint \"${datapoint.key}\" for data silo \"${title}\"! - \\n${err.message}`,\n ),\n );\n encounteredError = true;\n }\n }\n total += 1;\n progressBar.update(total);\n });\n }\n },\n {\n concurrency: 10,\n },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Synced \"${dataSilos.length}\" data silos and \"${totalDataPoints}\" datapoints in \"${\n totalTime / 1000\n }\" seconds!`,\n ),\n );\n return {\n success: !encounteredError,\n dataSiloTitleToId: apply(existingDataSiloByTitle, ({ id }) => id),\n };\n}\n/* eslint-enable max-lines */\n","import {\n fetchAllActions,\n fetchAllAttributes,\n fetchAllDataSubjects,\n fetchApiKeys,\n fetchIdentifiersAndCreateMissing,\n syncAction,\n syncActionItemCollections,\n syncActionItems,\n syncAgentFiles,\n syncAgentFunctions,\n syncAgents,\n syncAttribute,\n syncBusinessEntities,\n syncDataCategories,\n syncConsentManager,\n syncCookies,\n syncDataFlows,\n syncDataSubject,\n syncDataSiloDependencies,\n syncEnricher,\n syncIdentifier,\n syncIntlMessages,\n syncPartitions,\n syncPolicies,\n syncPrivacyCenter,\n syncProcessingActivities,\n syncProcessingPurposes,\n syncPromptGroups,\n syncPromptPartials,\n syncPrompts,\n syncConsentWorkflowTriggers,\n syncWorkflowConfigs,\n syncPreferenceOptionValues,\n syncPurposes,\n syncPreferenceTopics,\n syncTeams,\n syncTemplate,\n syncVendors,\n type Identifier,\n} from '@transcend-io/sdk';\nimport { map, type Logger, type SyncError, type SyncResult } from '@transcend-io/utils';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\n\n/* eslint-disable max-lines */\nimport { TranscendInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\nimport { validatePreferenceManagementSlugs } from '../preference-management/validatePreferenceManagementSlugs.js';\nimport { ensureAllDataSubjectsExist } from './ensureAllDataSubjectsExist.js';\nimport { syncDataSilos } from './syncDataSilos.js';\n\nconst CONCURRENCY = 10;\n\n/**\n * Sync the yaml input back to Transcend using the GraphQL APIs\n *\n * @param input - The yml input\n * @param client - GraphQL client\n * @param pageSize - Page size\n * @returns Structured sync result with per-resource errors\n */\nexport async function syncConfigurationToTranscend(\n input: TranscendInput,\n client: GraphQLClient,\n {\n pageSize = 50,\n // TODO: https://transcend.height.app/T-23779\n publishToPrivacyCenter = true,\n classifyService = false,\n deleteExtraAttributeValues = false,\n logger: syncLogger,\n warnings = [],\n }: {\n /** Page size */\n pageSize?: number;\n /** When true, skip publishing to privacy center */\n publishToPrivacyCenter?: boolean;\n /** When true, delete any attributes being synced up */\n deleteExtraAttributeValues?: boolean;\n /** classify data flow service if missing */\n classifyService?: boolean;\n /** Optional logger (e.g. collecting logger for MCP debug responses) */\n logger?: Logger;\n /** Non-fatal warnings to include in the result */\n warnings?: string[];\n },\n): Promise<SyncResult> {\n const activeLogger = syncLogger ?? logger;\n const errors: SyncError[] = [];\n let encounteredError = false;\n\n const recordError = (resource: string, message: string, item?: string): void => {\n errors.push({ resource, item, message });\n encounteredError = true;\n };\n\n activeLogger.info(colors.magenta(`Fetching data with page size ${pageSize}...`));\n\n const {\n templates,\n attributes,\n actions,\n identifiers,\n 'data-subjects': dataSubjects,\n 'business-entities': businessEntities,\n enrichers,\n cookies,\n 'consent-manager': consentManager,\n 'data-silos': dataSilos,\n 'data-flows': dataFlows,\n prompts,\n 'prompt-groups': promptGroups,\n 'prompt-partials': promptPartials,\n agents,\n 'agent-functions': agentFunctions,\n 'agent-files': agentFiles,\n vendors,\n 'data-categories': dataCategories,\n 'processing-activities': processingActivities,\n 'processing-purposes': processingPurposes,\n 'action-items': actionItems,\n 'action-item-collections': actionItemCollections,\n teams,\n 'privacy-center': privacyCenter,\n messages,\n policies,\n partitions,\n 'preference-workflow-configs': preferenceWorkflowConfigs,\n 'workflow-configs': workflowConfigs,\n } = input;\n\n const preferenceOptions = input['preference-options'];\n const purposes = input.purposes;\n\n const preferenceSlugErrors = validatePreferenceManagementSlugs(input);\n if (preferenceSlugErrors.length > 0) {\n for (const message of preferenceSlugErrors) {\n recordError('preference-slugs', message);\n }\n return {\n success: false,\n errors,\n warnings: warnings.length > 0 ? warnings : undefined,\n };\n }\n\n const [identifierByName, dataSubjectsByName, apiKeyTitleMap] = await Promise.all([\n // Ensure all identifiers are created and create a map from name -> identifier.id\n enrichers || identifiers\n ? fetchIdentifiersAndCreateMissing(client, {\n input,\n skipPublish: !publishToPrivacyCenter,\n logger,\n })\n : ({} as { [k in string]: Identifier }),\n // Grab all data subjects in the organization\n dataSilos || dataSubjects || enrichers || processingActivities\n ? ensureAllDataSubjectsExist(input, client)\n : {},\n // Grab API keys\n dataSilos &&\n dataSilos\n .map((dataSilo) => dataSilo['api-key-title'] || [])\n .reduce((acc, lst) => acc + lst.length, 0) > 0\n ? fetchApiKeys(client, { apiKeyInputs: input, logger })\n : {},\n ]);\n\n if (preferenceWorkflowConfigs?.length) {\n const preferenceWorkflowConfigsSuccess = await syncConsentWorkflowTriggers(\n client,\n preferenceWorkflowConfigs,\n {\n logger: activeLogger,\n pageSize,\n },\n );\n if (!preferenceWorkflowConfigsSuccess) {\n recordError('preference-workflow-configs', 'Failed to sync preference workflow configs');\n }\n }\n\n if (workflowConfigs?.length) {\n const workflowConfigsSuccess = await syncWorkflowConfigs(client, workflowConfigs, {\n logger: activeLogger,\n });\n if (!workflowConfigsSuccess) {\n recordError('workflow-configs', 'Failed to sync workflow configs');\n }\n }\n\n if (preferenceOptions?.length) {\n const preferenceOptionsSuccess = await syncPreferenceOptionValues(client, preferenceOptions, {\n logger: activeLogger,\n });\n if (!preferenceOptionsSuccess) {\n recordError('preference-options', 'Failed to sync preference option values');\n }\n }\n\n // Sync consent purposes and their nested preference topics.\n // Order matters: option values (above) exist first, then purposes, then topics\n // (which link to their purpose by ID and to option values by slug).\n if (purposes?.length) {\n const { success: purposesSuccess, purposeIdByTrackingType } = await syncPurposes(\n client,\n purposes,\n { logger: activeLogger },\n );\n if (!purposesSuccess) {\n recordError('purposes', 'Failed to sync one or more purposes');\n }\n\n const topics = purposes.flatMap((purpose) =>\n (purpose['preference-topics'] ?? []).map((topic) => ({\n ...topic,\n 'tracking-type': purpose.trackingType,\n })),\n );\n if (topics.length > 0) {\n const topicsSuccess = await syncPreferenceTopics(client, topics, {\n logger: activeLogger,\n purposeIdByTrackingType,\n });\n if (!topicsSuccess) {\n recordError('preference-topics', 'Failed to sync one or more preference topics');\n }\n }\n }\n\n // Sync consent manager\n if (consentManager) {\n activeLogger.info(colors.magenta('Syncing consent manager...'));\n try {\n await syncConsentManager(client, consentManager, { logger: activeLogger });\n activeLogger.info(colors.green('Successfully synced consent manager!'));\n } catch (err) {\n recordError('consent-manager', (err as Error).message);\n activeLogger.error(colors.red(`Failed to sync consent manager! - ${(err as Error).message}`));\n }\n }\n\n // Sync prompts\n if (prompts) {\n const promptsSuccess = await syncPrompts(client, prompts, { logger });\n encounteredError = encounteredError || !promptsSuccess;\n }\n if (promptPartials) {\n const promptsSuccess = await syncPromptPartials(client, promptPartials, { logger });\n encounteredError = encounteredError || !promptsSuccess;\n }\n if (promptGroups) {\n const promptsSuccess = await syncPromptGroups(client, promptGroups, { logger });\n encounteredError = encounteredError || !promptsSuccess;\n }\n\n if (teams) {\n const teamsSuccess = await syncTeams(client, teams, { logger });\n encounteredError = encounteredError || !teamsSuccess;\n }\n\n // Sync email templates\n if (templates) {\n logger.info(colors.magenta(`Syncing \"${templates.length}\" email templates...`));\n await map(\n templates,\n async (template) => {\n logger.info(colors.magenta(`Syncing template \"${template.title}\"...`));\n try {\n await syncTemplate(client, template, { logger });\n logger.info(colors.green(`Successfully synced template \"${template.title}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.error(colors.red(`Failed to sync template \"${template.title}\"! - ${err.message}`));\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${templates.length}\" email templates!`));\n }\n\n // Sync business entities\n if (businessEntities) {\n const businessEntitySuccess = await syncBusinessEntities(client, businessEntities, { logger });\n encounteredError = encounteredError || !businessEntitySuccess;\n }\n\n // Sync vendors\n if (vendors) {\n const vendorsSuccess = await syncVendors(client, vendors, { logger });\n encounteredError = encounteredError || !vendorsSuccess;\n }\n\n // Sync data categories\n if (dataCategories) {\n const dataCategoriesSuccess = await syncDataCategories(client, dataCategories, { logger });\n encounteredError = encounteredError || !dataCategoriesSuccess;\n }\n\n // Sync processing purposes\n if (processingPurposes) {\n const processingPurposesSuccess = await syncProcessingPurposes(client, processingPurposes, {\n logger,\n });\n encounteredError = encounteredError || !processingPurposesSuccess;\n }\n\n // Sync partitions\n if (partitions) {\n const partitionsSuccess = await syncPartitions(client, partitions, { logger });\n encounteredError = encounteredError || !partitionsSuccess;\n }\n\n // Sync agents\n if (agents) {\n const agentsSuccess = await syncAgents(client, agents, { logger });\n encounteredError = encounteredError || !agentsSuccess;\n }\n\n // Sync agent functions\n if (agentFunctions) {\n const agentFunctionsSuccess = await syncAgentFunctions(client, agentFunctions, { logger });\n encounteredError = encounteredError || !agentFunctionsSuccess;\n }\n\n // Sync agent files\n if (agentFiles) {\n const agentFilesSuccess = await syncAgentFiles(client, agentFiles, { logger });\n encounteredError = encounteredError || !agentFilesSuccess;\n }\n\n // Sync cookies\n if (cookies) {\n const cookiesSuccess = await syncCookies(client, cookies, { logger });\n encounteredError = encounteredError || !cookiesSuccess;\n }\n\n // Sync action item collections\n if (actionItemCollections) {\n const actionItemCollectionsSuccess = await syncActionItemCollections(\n client,\n actionItemCollections,\n { logger },\n );\n encounteredError = encounteredError || !actionItemCollectionsSuccess;\n }\n\n // Sync attributes\n if (attributes) {\n // Fetch existing\n logger.info(colors.magenta(`Syncing \"${attributes.length}\" attributes...`));\n const existingAttributes = await fetchAllAttributes(client, { logger });\n await map(\n attributes,\n async (attribute) => {\n const existing = existingAttributes.find((attr) => attr.name === attribute.name);\n\n logger.info(colors.magenta(`Syncing attribute \"${attribute.name}\"...`));\n try {\n await syncAttribute(client, attribute, {\n existingAttribute: existing,\n deleteExtraAttributeValues,\n logger,\n });\n logger.info(colors.green(`Successfully synced attribute \"${attribute.name}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.error(\n colors.red(`Failed to sync attribute \"${attribute.name}\"! - ${err.message}`),\n );\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${attributes.length}\" attributes!`));\n }\n\n // Sync action items\n if (actionItems) {\n const actionItemsSuccess = await syncActionItems(client, actionItems, { logger });\n encounteredError = encounteredError || !actionItemsSuccess;\n }\n\n // Sync enrichers\n if (enrichers) {\n logger.info(colors.magenta(`Syncing \"${enrichers.length}\" enrichers...`));\n await map(\n enrichers,\n async (enricher) => {\n logger.info(colors.magenta(`Syncing enricher \"${enricher.title}\"...`));\n try {\n await syncEnricher(client, {\n input: enricher,\n identifierByName,\n dataSubjectsByName,\n logger,\n });\n logger.info(colors.green(`Successfully synced enricher \"${enricher.title}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.error(colors.red(`Failed to sync enricher \"${enricher.title}\"! - ${err.message}`));\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${enrichers.length}\" enrichers!`));\n }\n\n // Sync identifiers\n if (identifiers) {\n // Fetch existing\n logger.info(colors.magenta(`Syncing \"${identifiers.length}\" identifiers...`));\n await map(\n identifiers,\n async (identifier) => {\n const existing = identifierByName[identifier.name];\n if (!existing) {\n throw new Error(\n `Failed to find identifier with name: ${identifier.type}. Should have been auto-created by cli.`,\n );\n }\n\n logger.info(colors.magenta(`Syncing identifier \"${identifier.type}\"...`));\n try {\n await syncIdentifier(client, {\n input: identifier,\n dataSubjectsByName,\n identifierId: existing.id,\n skipPublish: !publishToPrivacyCenter,\n logger,\n });\n logger.info(colors.green(`Successfully synced identifier \"${identifier.type}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.info(\n colors.red(`Failed to sync identifier \"${identifier.type}\"! - ${err.message}`),\n );\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${identifiers.length}\" identifiers!`));\n }\n\n // Sync actions\n if (actions) {\n // Fetch existing\n logger.info(colors.magenta(`Syncing \"${actions.length}\" actions...`));\n const existingActions = await fetchAllActions(client, { logger });\n await map(\n actions,\n async (action) => {\n const existing = existingActions.find((act) => act.type === action.type);\n if (!existing) {\n throw new Error(\n `Failed to find action with type: ${action.type}. Should have already existing in the organization.`,\n );\n }\n\n logger.info(colors.magenta(`Syncing action \"${action.type}\"...`));\n try {\n await syncAction(\n client,\n {\n action,\n actionId: existing.id,\n skipPublish: !publishToPrivacyCenter,\n },\n { logger },\n );\n logger.info(colors.green(`Successfully synced action \"${action.type}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.error(colors.red(`Failed to sync action \"${action.type}\"! - ${err.message}`));\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${actions.length}\" actions!`));\n }\n\n // Sync data subjects\n if (dataSubjects) {\n // Fetch existing\n logger.info(colors.magenta(`Syncing \"${dataSubjects.length}\" data subjects...`));\n const existingDataSubjects = await fetchAllDataSubjects(client, { logger });\n await map(\n dataSubjects,\n async (dataSubject) => {\n const existing = existingDataSubjects.find((subj) => subj.type === dataSubject.type);\n if (!existing) {\n throw new Error(\n `Failed to find data subject with type: ${dataSubject.type}. Should have already existing in the organization.`,\n );\n }\n\n logger.info(colors.magenta(`Syncing data subject \"${dataSubject.type}\"...`));\n try {\n await syncDataSubject(client, {\n input: dataSubject,\n dataSubjectId: existing.id,\n skipPublish: !publishToPrivacyCenter,\n logger,\n });\n logger.info(colors.green(`Successfully synced data subject \"${dataSubject.type}\"!`));\n } catch (err) {\n encounteredError = true;\n // supportsAuthorizedAgent is gated on the Authorized Agents feature being\n // enabled for the organization; surface a clearer hint than the raw API error\n const hint =\n dataSubject.supportsAuthorizedAgent !== undefined &&\n /authorized.agent/i.test(err.message)\n ? ' (enable the Authorized Agents feature for this organization before setting \"supportsAuthorizedAgent\")'\n : '';\n logger.info(\n colors.red(\n `Failed to sync data subject \"${dataSubject.type}\"! - ${err.message}${hint}`,\n ),\n );\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${dataSubjects.length}\" data subjects!`));\n }\n\n // Sync data flows\n if (dataFlows) {\n const syncedDataFlows = await syncDataFlows(client, dataFlows, { classifyService, logger });\n encounteredError = encounteredError || !syncedDataFlows;\n }\n\n // Sync privacy center\n if (privacyCenter) {\n try {\n const privacyCenterSuccess = await syncPrivacyCenter(client, privacyCenter, {\n logger,\n skipPublish: !publishToPrivacyCenter,\n });\n if (!privacyCenterSuccess) {\n recordError('privacy-center', 'Failed to sync privacy center');\n }\n } catch (err) {\n recordError('privacy-center', (err as Error).message);\n }\n }\n\n // Sync messages\n if (messages) {\n const messagesSuccess = await syncIntlMessages(client, messages, { logger });\n encounteredError = encounteredError || !messagesSuccess;\n }\n\n // Sync policies\n if (policies) {\n const policiesSuccess = await syncPolicies(client, policies, { logger });\n encounteredError = encounteredError || !policiesSuccess;\n }\n\n // Store dependency updates\n const dependencyUpdates: [string, string[]][] = [];\n // Sync data silos\n if (dataSilos) {\n const { success, dataSiloTitleToId } = await syncDataSilos(dataSilos, client, {\n dataSubjectsByName,\n apiKeysByTitle: apiKeyTitleMap,\n pageSize,\n });\n dataSilos?.forEach((dataSilo) => {\n // Queue up dependency update\n if (dataSilo['deletion-dependencies']) {\n dependencyUpdates.push([\n dataSiloTitleToId[dataSilo.title],\n dataSilo['deletion-dependencies'],\n ]);\n }\n });\n encounteredError = encounteredError || !success;\n }\n\n // Dependencies updated at the end after all data silos are created\n if (dependencyUpdates.length > 0) {\n await syncDataSiloDependencies(client, { input: dependencyUpdates, logger });\n }\n\n // Update processing activities\n if (processingActivities) {\n const processingActivitySuccess = await syncProcessingActivities(client, processingActivities, {\n logger,\n });\n encounteredError = encounteredError || !processingActivitySuccess;\n }\n\n if (publishToPrivacyCenter) {\n // TODO: https://transcend.height.app/T-23779\n }\n\n return {\n success: !encounteredError,\n errors,\n warnings: warnings.length > 0 ? warnings : undefined,\n };\n}\n/* eslint-enable max-lines */\n","import { getEntries } from '@transcend-io/type-utils';\n\nimport { TranscendInput } from '../codecs.js';\n\n/**\n * Combine a set of TranscendInput yaml files into a single yaml\n *\n * @param base - Base input\n * @param inputs - The list of inputs\n * @returns Merged input\n */\nexport function mergeTranscendInputs(\n base: TranscendInput,\n ...inputs: TranscendInput[]\n): TranscendInput {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const cloned: any = JSON.parse(JSON.stringify(base));\n inputs.forEach((input) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getEntries(input).forEach(([key, value]: [any, any]) => {\n if (cloned[key] === undefined) {\n cloned[key] = value;\n } else if (Array.isArray(value)) {\n cloned[key] = [...cloned[key], ...value];\n } else {\n cloned[key] = value;\n }\n });\n });\n return cloned;\n}\n","/**\n * Parse variables from string\n *\n * @param variables - Variables as string\n * @returns Variables as object\n */\nexport function parseVariablesFromString(variables: string): {\n [k in string]: string;\n} {\n // Parse out the variables\n const splitVars = variables.split(',').filter((x) => !!x);\n const vars: { [k in string]: string } = {};\n splitVars.forEach((variable) => {\n const [k, v] = variable.split(':');\n if (!k || !v) {\n throw new Error(`Invalid variable: ${variable}. Expected format: key:value`);\n }\n vars[k] = v;\n });\n return vars;\n}\n"],"mappings":"03CAGA,MAAa,EAAwB,cAQrC,SAAgB,GAAkC,EAAiC,CACjF,IAAM,EAAmB,EAAE,CAErB,GAAgB,EAAc,IAA0B,CACvD,EAAsB,KAAK,EAAK,EACnC,EAAO,KACL,GAAG,EAAQ,UAAU,EAAK,sNAG3B,EAIL,IAAK,IAAM,KAAU,EAAM,uBAAyB,EAAE,CACpD,EAAa,EAAO,KAAM,qBAAqB,CAGjD,IAAK,IAAM,KAAW,EAAM,UAAY,EAAE,CACxC,IAAK,IAAM,KAAS,EAAQ,sBAAwB,EAAE,CAAE,CACtD,EAAa,EAAM,KAAM,oBAAoB,EAAM,MAAM,IAAI,CAC7D,IAAK,IAAM,KAAU,EAAM,SAAW,EAAE,CACtC,EAAa,EAAO,KAAM,oBAAoB,EAAM,MAAM,YAAY,EAAO,MAAM,IAAI,CAK7F,OAAO,ECrBT,eAAsB,EACpB,CACE,aAAc,EAAY,EAAE,CAC5B,gBAAiB,EAAe,EAAE,CAClC,wBAAyB,EAAu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EAAO,QAAS,GAAU,CAExB,EAAW,EAAM,CAAC,SAAS,CAAC,EAAK,KAAuB,CAClD,EAAO,KAAS,IAAA,GAClB,EAAO,GAAO,EACL,MAAM,QAAQ,EAAM,CAC7B,EAAO,GAAO,CAAC,GAAG,EAAO,GAAM,GAAG,EAAM,CAExC,EAAO,GAAO,GAEhB,EACF,CACK,ECvBT,SAAgB,EAAyB,EAEvC,CAEA,IAAM,EAAY,EAAU,MAAM,IAAI,CAAC,OAAQ,GAAM,CAAC,CAAC,EAAE,CACnD,EAAkC,EAAE,CAQ1C,OAPA,EAAU,QAAS,GAAa,CAC9B,GAAM,CAAC,EAAG,GAAK,EAAS,MAAM,IAAI,CAClC,GAAI,CAAC,GAAK,CAAC,EACT,MAAU,MAAM,qBAAqB,EAAS,8BAA8B,CAE9E,EAAK,GAAK,GACV,CACK"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
let e=!1;function t(t){e=t}function n(){return e}var r=class extends Error{constructor(e,t){super(e,{cause:t?.cause}),this.name=`PolicyEngineCliError`}};function i(e){if(!n())return e.message;let t=[e.message,``,`Debug details:`],r=e.cause;return r instanceof Error?t.push(r.stack??r.message):r===void 0?t.push(`No underlying cause was recorded.`):t.push(String(r)),t.join(`
|
|
2
|
+
`)}function a(e){if(e instanceof r)return i(e)}function o(e){return a(e)||(e instanceof Error?n()?e.stack??String(e):e.message:String(e))}export{o as n,t as r,r as t};
|
|
3
|
+
//# sourceMappingURL=policyEngineCliError-BnBghLd1.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policyEngineCliError-BnBghLd1.mjs","names":[],"sources":["../src/commands/policy/helpers/policyEngineCliError.ts"],"sourcesContent":["/** Whether policy commands should include technical error details in output. */\nlet policyEngineCliDebugEnabled = false;\n\n/**\n * Enables or disables technical Policy Engine CLI error output for the current command run.\n *\n * @param enabled - When true, API causes and stack traces are included in failures\n */\nexport function setPolicyEngineCliDebug(enabled: boolean): void {\n policyEngineCliDebugEnabled = enabled;\n}\n\n/**\n * Returns true when `--debug` was passed to a policy command.\n *\n * @returns Whether debug output is enabled\n */\nexport function isPolicyEngineCliDebugEnabled(): boolean {\n return policyEngineCliDebugEnabled;\n}\n\n/**\n * User-facing Policy Engine CLI error without a stack trace by default.\n */\nexport class PolicyEngineCliError extends Error {\n /**\n * Creates a policy CLI error suitable for end-user output.\n *\n * @param message - User-readable error text\n * @param options - Optional underlying failure\n */\n constructor(\n message: string,\n options?: {\n /** Original failure, typically a got HTTPError */\n cause?: unknown;\n },\n ) {\n super(message, { cause: options?.cause });\n this.name = 'PolicyEngineCliError';\n }\n}\n\n/**\n * Formats a Policy Engine CLI error for terminal output.\n *\n * @param error - Thrown policy CLI error\n * @returns Message only by default; technical details when debug mode is enabled\n */\nexport function formatPolicyEngineCliErrorForTerminal(error: PolicyEngineCliError): string {\n if (!isPolicyEngineCliDebugEnabled()) {\n return error.message;\n }\n\n const parts = [error.message, '', 'Debug details:'];\n const cause = error.cause;\n\n if (cause instanceof Error) {\n parts.push(cause.stack ?? cause.message);\n } else if (cause !== undefined) {\n parts.push(String(cause));\n } else {\n parts.push('No underlying cause was recorded.');\n }\n\n return parts.join('\\n');\n}\n\n/**\n * Formats thrown values for Stricli, suppressing stacks for policy CLI errors unless debug is enabled.\n *\n * @param exc - Thrown value from a command\n * @returns Terminal-safe error text\n */\nexport function formatPolicyEngineCliException(exc: unknown): string | undefined {\n if (exc instanceof PolicyEngineCliError) {\n return formatPolicyEngineCliErrorForTerminal(exc);\n }\n\n return undefined;\n}\n\n/**\n * Formats any thrown command value for terminal output.\n *\n * `PolicyEngineCliError` values are formatted by `formatPolicyEngineCliException`.\n * Other errors (e.g. bundle-not-found, missing OPA binary, local OPA failures)\n * are plain `Error`s -- return only their message by default so operators don't\n * see a minified stack trace, and surface the stack only when a policy command\n * opted in via `--debug`.\n *\n * @param exc - Thrown value from a command\n * @returns Terminal-safe error text\n */\nexport function formatCliException(exc: unknown): string {\n const policyMessage = formatPolicyEngineCliException(exc);\n if (policyMessage) {\n return policyMessage;\n }\n\n if (exc instanceof Error) {\n return isPolicyEngineCliDebugEnabled() ? (exc.stack ?? String(exc)) : exc.message;\n }\n\n return String(exc);\n}\n"],"mappings":"AACA,IAAI,EAA8B,GAOlC,SAAgB,EAAwB,EAAwB,CAC9D,EAA8B,EAQhC,SAAgB,GAAyC,CACvD,OAAO,EAMT,IAAa,EAAb,cAA0C,KAAM,CAO9C,YACE,EACA,EAIA,CACA,MAAM,EAAS,CAAE,MAAO,GAAS,MAAO,CAAC,CACzC,KAAK,KAAO,yBAUhB,SAAgB,EAAsC,EAAqC,CACzF,GAAI,CAAC,GAA+B,CAClC,OAAO,EAAM,QAGf,IAAM,EAAQ,CAAC,EAAM,QAAS,GAAI,iBAAiB,CAC7C,EAAQ,EAAM,MAUpB,OARI,aAAiB,MACnB,EAAM,KAAK,EAAM,OAAS,EAAM,QAAQ,CAC/B,IAAU,IAAA,GAGnB,EAAM,KAAK,oCAAoC,CAF/C,EAAM,KAAK,OAAO,EAAM,CAAC,CAKpB,EAAM,KAAK;EAAK,CASzB,SAAgB,EAA+B,EAAkC,CAC/E,GAAI,aAAe,EACjB,OAAO,EAAsC,EAAI,CAkBrD,SAAgB,EAAmB,EAAsB,CAUvD,OATsB,EAA+B,EACjD,GAIA,aAAe,MACV,GAA+B,CAAI,EAAI,OAAS,OAAO,EAAI,CAAI,EAAI,QAGrE,OAAO,EAAI"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import{t as e}from"./policyEngineCliError-BnBghLd1.mjs";import t from"got";function n(e,n){let r=e.replace(/\/$/,``);if(/(^|\/)v1$/i.test(r))throw Error(`--transcend-url must not include a trailing "/v1" (the CLI appends it automatically). Got "${e}"; use "${r.replace(/\/v1$/i,``)}" instead.`);return t.extend({prefixUrl:r,headers:{Authorization:`Bearer ${n}`,accept:`application/json`}})}function r(e){if(typeof e==`string`)try{return JSON.parse(e).message}catch{return e.length>0?e:void 0}if(e&&typeof e==`object`&&`message`in e){let t=e.message;if(typeof t==`string`&&t.length>0)return t}}function i(e,t){if(!e)return;let n=e[t]??e[t.toLowerCase()];return Array.isArray(n)?n[0]:n}function a(e,t){if(e)return e;let n=i(t,`retry-after`),r=i(t,`x-ratelimit-reset`),a=`Rate limit exceeded (429 Too Many Requests).
|
|
2
|
+
|
|
3
|
+
Fix:
|
|
4
|
+
- Wait and retry the command`;return n?a+=`\n- Retry after ${n} second(s)`:r&&(a+=`\n- Retry after ${r}`),a}function o(e,t,n){switch(e){case 401:return`Authentication failed (401 Unauthorized).
|
|
5
|
+
|
|
6
|
+
Your Transcend API key is missing, invalid, or does not have permission for this command.
|
|
7
|
+
|
|
8
|
+
Fix:
|
|
9
|
+
- Set a valid API key: export TRANSCEND_API_KEY=<your-key>
|
|
10
|
+
or pass --auth=<your-key>
|
|
11
|
+
- Ensure the key has the required Policy Engine scopes (e.g. View/Manage/Activate Policy)
|
|
12
|
+
- Confirm you are pointing at the correct environment (--transcend-url)`;case 403:return t??`Access was denied (403 Forbidden). If this persists, contact your Transcend admin.`;case 404:return`Resource not found (404 Not Found).
|
|
13
|
+
|
|
14
|
+
The requested policy bundle or version does not exist.
|
|
15
|
+
|
|
16
|
+
Fix:
|
|
17
|
+
- Check the --bundle-name value
|
|
18
|
+
- Run \`transcend policy bundles\` to see available bundles
|
|
19
|
+
- Run \`transcend policy versions --bundle-name=<name>\` to see available versions`;case 400:return t??`The request was invalid. Check your command flags and try again.`;case 409:return t??`The request conflicted with the current policy bundle state.`;case 413:return t??`Policy bundle upload is too large (413 Payload Too Large).
|
|
20
|
+
|
|
21
|
+
Uploaded bundles must be at most 5 KiB compressed and 50 KiB decompressed gzip tarballs containing only manifest.json and .rego files.
|
|
22
|
+
|
|
23
|
+
Fix:
|
|
24
|
+
- Remove unnecessary files from the bundle directory before publishing
|
|
25
|
+
- Ensure the compiled .tar.gz stays within the upload limits`;case 429:return a(t,n);default:return e>=500?`Transcend server error (${e}). Try again in a few moments. If the problem persists, contact Transcend support.`:t??`Request failed with status code ${e}.`}}function s(e){if(!(e instanceof Error))return!1;let t=e.code;if(t===`ECONNREFUSED`||t===`ENOTFOUND`||t===`ETIMEDOUT`||t===`ECONNRESET`)return!0;let n=e.message.toLowerCase();return n.includes(`network`)||n.includes(`timeout`)||n.includes(`econnrefused`)||n.includes(`enotfound`)||n.includes(`etimedout`)}function c(e){if(s(e))return`Connection to Transcend failed.
|
|
26
|
+
|
|
27
|
+
The Policy Engine API could not be reached.
|
|
28
|
+
|
|
29
|
+
Fix:
|
|
30
|
+
- Check your network connection
|
|
31
|
+
- Confirm --transcend-url points at the correct environment
|
|
32
|
+
- Retry the command in a few moments`;if(e&&typeof e==`object`&&`response`in e){let t=e.response,n=t?.statusCode,i=r(t?.body);if(n)return o(n,i,t?.headers);if(i)return i}return e instanceof Error?e.message:String(e)}function l(t){throw new e(c(t),{cause:t})}async function u(e){try{return await e}catch(e){l(e)}}function d(e,t){if(t.json){e.write(`${JSON.stringify(t.data,null,2)}\n`);return}t.renderTable&&e.write(`${t.renderTable()}\n`)}export{n as i,u as n,l as r,d as t};
|
|
33
|
+
//# sourceMappingURL=printResult-oXnpZu_9.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"printResult-oXnpZu_9.mjs","names":[],"sources":["../src/commands/policy/helpers/buildPolicyEngineClient.ts","../src/commands/policy/helpers/formatPolicyEngineRequestError.ts","../src/commands/policy/helpers/printResult.ts"],"sourcesContent":["import got, { type Got } from 'got';\n\n/**\n * Creates a got client for Policy Engine REST endpoints on the monolith.\n *\n * The CLI appends `v1/...` paths to this base URL, so callers must NOT include\n * a trailing `/v1` (that would produce `/v1/v1/...` and an opaque `400`). We\n * detect and reject that mistake with a clear hint.\n *\n * @param transcendUrl - Transcend API base URL (without `/v1`)\n * @param auth - Transcend API key\n * @returns Configured got instance\n */\nexport function buildPolicyEngineClient(transcendUrl: string, auth: string): Got {\n const normalized = transcendUrl.replace(/\\/$/, '');\n if (/(^|\\/)v1$/i.test(normalized)) {\n throw new Error(\n `--transcend-url must not include a trailing \"/v1\" (the CLI appends it automatically). ` +\n `Got \"${transcendUrl}\"; use \"${normalized.replace(/\\/v1$/i, '')}\" instead.`,\n );\n }\n return got.extend({\n prefixUrl: normalized,\n headers: {\n Authorization: `Bearer ${auth}`,\n accept: 'application/json',\n },\n });\n}\n","import { PolicyEngineCliError } from './policyEngineCliError.js';\n\n/** Parsed JSON error body from a Policy Engine API response. */\ninterface PolicyEngineErrorBody {\n /** Human-readable error message */\n message?: string;\n}\n\n/** HTTP response metadata on a got HTTPError. */\ninterface PolicyEngineHttpResponse {\n /** HTTP status code */\n statusCode?: number;\n /** Response body (JSON or raw text) */\n body?: unknown;\n /** Response headers */\n headers?: Record<string, string | string[] | undefined>;\n}\n\n/** Shape of a got HTTPError with response metadata. */\ninterface PolicyEngineHttpError {\n /** HTTP response metadata */\n response?: PolicyEngineHttpResponse;\n}\n\nconst AUTH_ERROR_MESSAGE = `Authentication failed (401 Unauthorized).\n\nYour Transcend API key is missing, invalid, or does not have permission for this command.\n\nFix:\n- Set a valid API key: export TRANSCEND_API_KEY=<your-key>\n or pass --auth=<your-key>\n- Ensure the key has the required Policy Engine scopes (e.g. View/Manage/Activate Policy)\n- Confirm you are pointing at the correct environment (--transcend-url)`;\n\nconst NOT_FOUND_MESSAGE = `Resource not found (404 Not Found).\n\nThe requested policy bundle or version does not exist.\n\nFix:\n- Check the --bundle-name value\n- Run \\`transcend policy bundles\\` to see available bundles\n- Run \\`transcend policy versions --bundle-name=<name>\\` to see available versions`;\n\nconst PAYLOAD_TOO_LARGE_MESSAGE = `Policy bundle upload is too large (413 Payload Too Large).\n\nUploaded bundles must be at most 5 KiB compressed and 50 KiB decompressed gzip tarballs containing only manifest.json and .rego files.\n\nFix:\n- Remove unnecessary files from the bundle directory before publishing\n- Ensure the compiled .tar.gz stays within the upload limits`;\n\nconst NETWORK_ERROR_MESSAGE = `Connection to Transcend failed.\n\nThe Policy Engine API could not be reached.\n\nFix:\n- Check your network connection\n- Confirm --transcend-url points at the correct environment\n- Retry the command in a few moments`;\n\n/**\n * Extracts a human-readable message from a Policy Engine API error body.\n *\n * @param body - Raw or parsed response body\n * @returns API message when present\n */\nfunction extractApiMessage(body: unknown): string | undefined {\n if (typeof body === 'string') {\n try {\n const parsed = JSON.parse(body) as PolicyEngineErrorBody;\n return parsed.message;\n } catch {\n return body.length > 0 ? body : undefined;\n }\n }\n\n if (body && typeof body === 'object' && 'message' in body) {\n const message = (body as PolicyEngineErrorBody).message;\n if (typeof message === 'string' && message.length > 0) {\n return message;\n }\n }\n\n return undefined;\n}\n\n/**\n * Reads a single response header value.\n *\n * @param headers - Response headers\n * @param name - Header name\n * @returns Header value when present\n */\nfunction readResponseHeader(\n headers: Record<string, string | string[] | undefined> | undefined,\n name: string,\n): string | undefined {\n if (!headers) {\n return undefined;\n }\n\n const value = headers[name] ?? headers[name.toLowerCase()];\n if (Array.isArray(value)) {\n return value[0];\n }\n\n return value;\n}\n\n/**\n * Builds a rate-limit error message using response headers when available.\n *\n * @param apiMessage - Message from the response body, when present\n * @param headers - Response headers\n * @returns User-readable rate-limit text\n */\nfunction formatRateLimitMessage(\n apiMessage: string | undefined,\n headers: Record<string, string | string[] | undefined> | undefined,\n): string {\n if (apiMessage) {\n return apiMessage;\n }\n\n const retryAfter = readResponseHeader(headers, 'retry-after');\n const resetAt = readResponseHeader(headers, 'x-ratelimit-reset');\n\n let message = `Rate limit exceeded (429 Too Many Requests).\n\nFix:\n- Wait and retry the command`;\n\n if (retryAfter) {\n message += `\\n- Retry after ${retryAfter} second(s)`;\n } else if (resetAt) {\n message += `\\n- Retry after ${resetAt}`;\n }\n\n return message;\n}\n\n/**\n * Maps common HTTP status codes to actionable CLI messages.\n *\n * @param statusCode - HTTP status code\n * @param apiMessage - Message from the API response body, when present\n * @param headers - Response headers\n * @returns User-readable error text\n */\nfunction formatHttpStatusError(\n statusCode: number,\n apiMessage?: string,\n headers?: Record<string, string | string[] | undefined>,\n): string {\n switch (statusCode) {\n case 401:\n return AUTH_ERROR_MESSAGE;\n case 403:\n return (\n apiMessage ??\n 'Access was denied (403 Forbidden). If this persists, contact your Transcend admin.'\n );\n case 404:\n return NOT_FOUND_MESSAGE;\n case 400:\n return apiMessage ?? 'The request was invalid. Check your command flags and try again.';\n case 409:\n return apiMessage ?? 'The request conflicted with the current policy bundle state.';\n case 413:\n return apiMessage ?? PAYLOAD_TOO_LARGE_MESSAGE;\n case 429:\n return formatRateLimitMessage(apiMessage, headers);\n default:\n if (statusCode >= 500) {\n return `Transcend server error (${statusCode}). Try again in a few moments. If the problem persists, contact Transcend support.`;\n }\n return apiMessage ?? `Request failed with status code ${statusCode}.`;\n }\n}\n\n/**\n * Returns true when the error looks like a network or timeout failure.\n *\n * @param error - Thrown error\n * @returns Whether the error is likely a connectivity issue\n */\nfunction isNetworkError(error: unknown): boolean {\n if (!(error instanceof Error)) {\n return false;\n }\n\n const code = (error as NodeJS.ErrnoException).code;\n if (\n code === 'ECONNREFUSED' ||\n code === 'ENOTFOUND' ||\n code === 'ETIMEDOUT' ||\n code === 'ECONNRESET'\n ) {\n return true;\n }\n\n const message = error.message.toLowerCase();\n return (\n message.includes('network') ||\n message.includes('timeout') ||\n message.includes('econnrefused') ||\n message.includes('enotfound') ||\n message.includes('etimedout')\n );\n}\n\n/**\n * Extracts a useful error message from a failed Policy Engine HTTP request.\n *\n * @param error - The thrown error, typically a got `HTTPError`\n * @returns A message suitable for CLI output\n */\nexport function formatPolicyEngineRequestError(error: unknown): string {\n if (isNetworkError(error)) {\n return NETWORK_ERROR_MESSAGE;\n }\n\n if (error && typeof error === 'object' && 'response' in error) {\n const response = (error as PolicyEngineHttpError).response;\n const statusCode = response?.statusCode;\n const apiMessage = extractApiMessage(response?.body);\n\n if (statusCode) {\n return formatHttpStatusError(statusCode, apiMessage, response?.headers);\n }\n\n if (apiMessage) {\n return apiMessage;\n }\n }\n\n return error instanceof Error ? error.message : String(error);\n}\n\n/**\n * Rethrows a Policy Engine request failure with a user-readable message.\n *\n * @param error - The thrown error, typically a got `HTTPError`\n */\nexport function throwPolicyEngineRequestError(error: unknown): never {\n throw new PolicyEngineCliError(formatPolicyEngineRequestError(error), { cause: error });\n}\n\n/**\n * Awaits a Policy Engine HTTP request and maps failures to user-readable errors.\n *\n * @param request - Promise returned by a got client call (e.g. `.json()`)\n * @returns Parsed response body\n */\nexport async function policyEngineRequest<T>(request: Promise<T>): Promise<T> {\n try {\n return await request;\n } catch (error) {\n throwPolicyEngineRequestError(error);\n }\n}\n","/** Options for printing CLI command output. */\nexport interface PrintResultOptions {\n /** When true, print raw JSON */\n json: boolean;\n /** JSON-serializable payload */\n data: unknown;\n /** Table renderer used when json is false */\n renderTable?: () => string;\n}\n\n/**\n * Prints JSON or a human-readable table to stdout.\n *\n * @param stdout - Process stdout stream\n * @param options - Output options\n */\nexport function printResult(stdout: NodeJS.WriteStream, options: PrintResultOptions): void {\n if (options.json) {\n stdout.write(`${JSON.stringify(options.data, null, 2)}\\n`);\n return;\n }\n\n if (options.renderTable) {\n stdout.write(`${options.renderTable()}\\n`);\n }\n}\n"],"mappings":"2EAaA,SAAgB,EAAwB,EAAsB,EAAmB,CAC/E,IAAM,EAAa,EAAa,QAAQ,MAAO,GAAG,CAClD,GAAI,aAAa,KAAK,EAAW,CAC/B,MAAU,MACR,8FACU,EAAa,UAAU,EAAW,QAAQ,SAAU,GAAG,CAAC,YACnE,CAEH,OAAO,EAAI,OAAO,CAChB,UAAW,EACX,QAAS,CACP,cAAe,UAAU,IACzB,OAAQ,mBACT,CACF,CAAC,CCuCJ,SAAS,EAAkB,EAAmC,CAC5D,GAAI,OAAO,GAAS,SAClB,GAAI,CAEF,OADe,KAAK,MAAM,EACb,CAAC,aACR,CACN,OAAO,EAAK,OAAS,EAAI,EAAO,IAAA,GAIpC,GAAI,GAAQ,OAAO,GAAS,UAAY,YAAa,EAAM,CACzD,IAAM,EAAW,EAA+B,QAChD,GAAI,OAAO,G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GAAU,WACvB,EAAa,EAAkB,GAAU,KAAK,CAEpD,GAAI,EACF,OAAO,EAAsB,EAAY,EAAY,GAAU,QAAQ,CAGzE,GAAI,EACF,OAAO,EAIX,OAAO,aAAiB,MAAQ,EAAM,QAAU,OAAO,EAAM,CAQ/D,SAAgB,EAA8B,EAAuB,CACnE,MAAM,IAAI,EAAqB,EAA+B,EAAM,CAAE,CAAE,MAAO,EAAO,CAAC,CASzF,eAAsB,EAAuB,EAAiC,CAC5E,GAAI,CACF,OAAO,MAAM,QACN,EAAO,CACd,EAA8B,EAAM,EClPxC,SAAgB,EAAY,EAA4B,EAAmC,CACzF,GAAI,EAAQ,KAAM,CAChB,EAAO,MAAM,GAAG,KAAK,UAAU,EAAQ,KAAM,KAAM,EAAE,CAAC,IAAI,CAC1D,OAGE,EAAQ,aACV,EAAO,MAAM,GAAG,EAAQ,aAAa,CAAC,IAAI"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./logger-
|
|
1
|
+
import{t as e}from"./logger-Ckep4QXn.mjs";import{SubDataPointDataSubCategoryGuessStatus as t}from"@transcend-io/privacy-types";import{chunk as n,keyBy as r,sortBy as i,uniq as a}from"lodash-es";import o from"colors";import{DATAPOINT_EXPORT as s,DATA_SILO_EXPORT as c,SUB_DATA_POINTS_COUNT as l,makeGraphQLRequest as u}from"@transcend-io/sdk";import{mapSeries as d}from"@transcend-io/utils";import f from"cli-progress";import{gql as p}from"graphql-request";async function m(n,{dataSiloIds:r=[],includeGuessedCategories:a,includeAttributes:s,parentCategories:c=[],subCategories:d=[],pageSize:m=1e3}={}){let h=[],g=new Date().getTime(),_=new f.SingleBar({},f.Presets.shades_classic),v={...c.length>0?{category:c}:{},...d.length>0?{subCategoryIds:d}:{},...c.length+d.length>0&&!a?{status:t.Approved}:{},...r.length>0?{dataSilos:r}:{}},{subDataPoints:{totalCount:y}}=await u(n,l,{variables:{filterBy:v},logger:e});e.info(o.magenta(`[Step 1/3] Pulling in all subdatapoints`)),_.start(y,0);let b=0,x=!1,S,C=0;do try{let{subDataPoints:{nodes:t}}=await u(n,p`
|
|
2
2
|
query TranscendCliSubDataPointCsvExport(
|
|
3
3
|
$filterBy: SubDataPointFiltersInput
|
|
4
4
|
$first: Int!
|
|
@@ -42,4 +42,4 @@ import{t as e}from"./logger-B-LXIf3U.mjs";import{SubDataPointDataSubCategoryGues
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
`,{variables:{first:m,offset:C,filterBy:{...v}},logger:e});S=t[t.length-1]?.id,h.push(...t),x=t.length===m,b+=t.length,C+=t.length,_.update(b)}catch(t){throw e.error(o.red(`An error fetching subdatapoints for cursor ${S} and offset ${C}`)),t}while(x);_.stop();let w=new Date().getTime()-g,T=i(h,`name`);return e.info(o.green(`Successfully pulled in ${T.length} subdatapoints in ${w/1e3} seconds!`)),T}async function h(t,{dataPointIds:r=[],pageSize:i=100}){let a=[],c=new Date().getTime(),l=new f.SingleBar({},f.Presets.shades_classic);e.info(o.magenta(`[Step 2/3] Fetching metadata for ${r.length} datapoints`));let p=n(r,i);l.start(r.length,0);let m=0;await d(p,async n=>{try{let{dataPoints:{nodes:r}}=await u(t,s,{variables:{first:i,filterBy:{ids:n}},logger:e});a.push(...r),m+=n.length,l.update(m)}catch(t){throw e.error(o.red(`An error fetching subdatapoints for IDs ${n.join(`, `)}`)),t}}),l.stop();let h=new Date().getTime()-c;return e.info(o.green(`Successfully pulled in ${a.length} dataPoints in ${h/1e3} seconds!`)),a}async function g(t,{dataSiloIds:r=[],pageSize:i=100}){let a=[],s=new Date().getTime(),l=new f.SingleBar({},f.Presets.shades_classic);e.info(o.magenta(`[Step 3/3] Fetching metadata for ${r.length} data silos`));let p=n(r,i);l.start(r.length,0);let m=0;await d(p,async n=>{try{let{dataSilos:{nodes:r}}=await u(t,c,{variables:{first:i,filterBy:{ids:n}},logger:e});a.push(...r),m+=n.length,l.update(m)}catch(t){throw e.error(o.red(`An error fetching data silos for IDs ${n.join(`, `)}`)),t}}),l.stop();let h=new Date().getTime()-s;return e.info(o.green(`Successfully pulled in ${a.length} data silos in ${h/1e3} seconds!`)),a}async function _(e,{dataSiloIds:t=[],includeGuessedCategories:n,includeAttributes:i,parentCategories:o=[],subCategories:s=[],pageSize:c=1e3}={}){let l=await m(e,{dataSiloIds:t,includeGuessedCategories:n,includeAttributes:i,parentCategories:o,subCategories:s,pageSize:c}),u=r(await h(e,{dataPointIds:a(l.map(e=>e.dataPointId))}),`id`),d=r(await g(e,{dataSiloIds:a(l.map(e=>e.dataSiloId))}),`id`);return l.map(e=>({...e,dataPoint:u[e.dataPointId],dataSilo:d[e.dataSiloId]}))}export{_ as t};
|
|
45
|
-
//# sourceMappingURL=pullAllDatapoints-
|
|
45
|
+
//# sourceMappingURL=pullAllDatapoints-Bvv9KRR5.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullAllDatapoints-D8mTXHun.mjs","names":[],"sources":["../src/lib/data-inventory/pullAllDatapoints.ts"],"sourcesContent":["import {\n type DataCategoryType,\n SubDataPointDataSubCategoryGuessStatus,\n} from '@transcend-io/privacy-types';\nimport {\n makeGraphQLRequest,\n DATAPOINT_EXPORT,\n DATA_SILO_EXPORT,\n SUB_DATA_POINTS_COUNT,\n type DataSiloAttributeValue,\n} from '@transcend-io/sdk';\nimport { mapSeries } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport { gql, type GraphQLClient } from 'graphql-request';\n/* eslint-disable max-lines */\nimport { keyBy, uniq, chunk, sortBy } from 'lodash-es';\n\nimport type { DataCategoryInput, ProcessingPurposeInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\n\nexport interface DataSiloCsvPreview {\n /** ID of dataSilo */\n id: string;\n /** Name of dataSilo */\n title: string;\n}\n\nexport interface DataPointCsvPreview {\n /** ID of dataPoint */\n id: string;\n /** The path to this data point */\n path: string[];\n /** Description */\n description: {\n /** Default message */\n defaultMessage: string;\n };\n /** Name */\n name: string;\n}\n\nexport interface SubDataPointCsvPreview {\n /** ID of subDatapoint */\n id: string;\n /** Name (or key) of the subdatapoint */\n name: string;\n /** The description */\n description?: string;\n /** Personal data category */\n categories: DataCategoryInput[];\n /** Data point ID */\n dataPointId: string;\n /** The data silo ID */\n dataSiloId: string;\n /** The processing purpose for this sub datapoint */\n purposes: ProcessingPurposeInput[];\n /** Attribute attached to subdatapoint */\n attributeValues?: DataSiloAttributeValue[];\n /** Data category guesses that are output by the classifier */\n pendingCategoryGuesses?: {\n /** Data category being guessed */\n category: DataCategoryInput;\n /** Status of guess */\n status: SubDataPointDataSubCategoryGuessStatus;\n /** classifier version that produced the guess */\n classifierVersion: number;\n }[];\n}\n\nexport interface DatapointFilterOptions {\n /** IDs of data silos to filter down */\n dataSiloIds?: string[];\n /** Whether to include guessed categories, defaults to only approved categories */\n includeGuessedCategories?: boolean;\n /** Whether or not to include attributes */\n includeAttributes?: boolean;\n /** Parent categories to filter down for */\n parentCategories?: DataCategoryType[];\n /** Sub categories to filter down for */\n subCategories?: string[]; // TODO: https://transcend.height.app/T-40482 - do by name not ID\n}\n\n/**\n * Pull subdatapoint information\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @returns The subdatapoints\n */\nasync function pullSubDatapoints(\n client: GraphQLClient,\n {\n dataSiloIds = [],\n includeGuessedCategories,\n includeAttributes,\n parentCategories = [],\n subCategories = [],\n pageSize = 1000,\n }: DatapointFilterOptions & {\n /** Page size to pull in */\n pageSize?: number;\n } = {},\n): Promise<SubDataPointCsvPreview[]> {\n const subDataPoints: SubDataPointCsvPreview[] = [];\n\n // Time duration\n const t0 = new Date().getTime();\n\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Filters\n const filterBy = {\n ...(parentCategories.length > 0 ? { category: parentCategories } : {}),\n ...(subCategories.length > 0 ? { subCategoryIds: subCategories } : {}),\n // if parentCategories or subCategories and not includeGuessedCategories\n ...(parentCategories.length + subCategories.length > 0 && !includeGuessedCategories\n ? // then only show data points with approved data categories\n { status: SubDataPointDataSubCategoryGuessStatus.Approved }\n : {}),\n ...(dataSiloIds.length > 0 ? { dataSilos: dataSiloIds } : {}),\n };\n\n // Build a GraphQL client\n const {\n subDataPoints: { totalCount },\n } = await makeGraphQLRequest<{\n /** Query response */\n subDataPoints: {\n /** Count */\n totalCount: number;\n };\n }>(client, SUB_DATA_POINTS_COUNT, {\n variables: { filterBy },\n logger,\n });\n\n logger.info(colors.magenta('[Step 1/3] Pulling in all subdatapoints'));\n\n progressBar.start(totalCount, 0);\n let total = 0;\n let shouldContinue = false;\n let cursor: string | undefined;\n let offset = 0;\n do {\n try {\n const {\n subDataPoints: { nodes },\n } = await makeGraphQLRequest<{\n /** Query response */\n subDataPoints: {\n /** List of matches */\n nodes: SubDataPointCsvPreview[];\n };\n }>(\n client,\n gql`\n query TranscendCliSubDataPointCsvExport(\n $filterBy: SubDataPointFiltersInput\n $first: Int!\n $offset: Int!\n ) {\n subDataPoints(\n filterBy: $filterBy\n first: $first\n offset: $offset\n useMaster: false\n ) {\n nodes {\n id\n name\n description\n dataPointId\n dataSiloId\n purposes {\n name\n purpose\n }\n categories {\n name\n category\n }\n ${\n includeGuessedCategories\n ? `pendingCategoryGuesses {\n category {\n name\n category\n }\n status\n classifierVersion\n }`\n : ''\n }\n ${\n includeAttributes\n ? `attributeValues {\n attributeKey {\n name\n }\n name\n }`\n : ''\n }\n }\n }\n }\n `,\n {\n variables: {\n first: pageSize,\n offset,\n filterBy: {\n ...filterBy,\n // TODO: https://transcend.height.app/T-40484 - add cursor support\n // ...(cursor ? { cursor: { id: cursor } } : {}),\n },\n },\n logger,\n },\n );\n\n cursor = nodes[nodes.length - 1]?.id as string;\n subDataPoints.push(...nodes);\n shouldContinue = nodes.length === pageSize;\n total += nodes.length;\n offset += nodes.length;\n progressBar.update(total);\n } catch (err) {\n logger.error(\n colors.red(`An error fetching subdatapoints for cursor ${cursor} and offset ${offset}`),\n );\n throw err;\n }\n } while (shouldContinue);\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n const sorted = sortBy(subDataPoints, 'name');\n\n logger.info(\n colors.green(\n `Successfully pulled in ${sorted.length} subdatapoints in ${totalTime / 1000} seconds!`,\n ),\n );\n return sorted;\n}\n\n/**\n * Pull datapoint information\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @returns The datapoints\n */\nasync function pullDatapoints(\n client: GraphQLClient,\n {\n dataPointIds = [],\n pageSize = 100,\n }: {\n /** IDs of data points to filter down */\n dataPointIds: string[];\n /** Page size to pull in */\n pageSize?: number;\n },\n): Promise<DataPointCsvPreview[]> {\n const dataPoints: DataPointCsvPreview[] = [];\n\n // Time duration\n const t0 = new Date().getTime();\n\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n logger.info(colors.magenta(`[Step 2/3] Fetching metadata for ${dataPointIds.length} datapoints`));\n\n // Group by 100\n const dataPointsGrouped = chunk(dataPointIds, pageSize);\n\n progressBar.start(dataPointIds.length, 0);\n let total = 0;\n await mapSeries(dataPointsGrouped, async (dataPointIdsGroup) => {\n try {\n const {\n dataPoints: { nodes },\n } = await makeGraphQLRequest<{\n /** Query response */\n dataPoints: {\n /** List of matches */\n nodes: DataPointCsvPreview[];\n };\n }>(client, DATAPOINT_EXPORT, {\n variables: {\n first: pageSize,\n filterBy: {\n ids: dataPointIdsGroup,\n },\n },\n logger,\n });\n\n dataPoints.push(...nodes);\n total += dataPointIdsGroup.length;\n progressBar.update(total);\n } catch (err) {\n logger.error(\n colors.red(`An error fetching subdatapoints for IDs ${dataPointIdsGroup.join(', ')}`),\n );\n throw err;\n }\n });\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully pulled in ${dataPoints.length} dataPoints in ${totalTime / 1000} seconds!`,\n ),\n );\n return dataPoints;\n}\n\n/**\n * Pull data silo information\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @returns The data silos\n */\nasync function pullDataSilos(\n client: GraphQLClient,\n {\n dataSiloIds = [],\n pageSize = 100,\n }: {\n /** IDs of data silos to filter down */\n dataSiloIds: string[];\n /** Page size to pull in */\n pageSize?: number;\n },\n): Promise<DataSiloCsvPreview[]> {\n const dataSilos: DataSiloCsvPreview[] = [];\n\n // Time duration\n const t0 = new Date().getTime();\n\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n logger.info(colors.magenta(`[Step 3/3] Fetching metadata for ${dataSiloIds.length} data silos`));\n\n // Group by 100\n const dataSilosGrouped = chunk(dataSiloIds, pageSize);\n\n progressBar.start(dataSiloIds.length, 0);\n let total = 0;\n await mapSeries(dataSilosGrouped, async (dataSiloIdsGroup) => {\n try {\n const {\n dataSilos: { nodes },\n } = await makeGraphQLRequest<{\n /** Query response */\n dataSilos: {\n /** List of matches */\n nodes: DataSiloCsvPreview[];\n };\n }>(client, DATA_SILO_EXPORT, {\n variables: {\n first: pageSize,\n filterBy: {\n ids: dataSiloIdsGroup,\n },\n },\n logger,\n });\n\n dataSilos.push(...nodes);\n total += dataSiloIdsGroup.length;\n progressBar.update(total);\n } catch (err) {\n logger.error(\n colors.red(`An error fetching data silos for IDs ${dataSiloIdsGroup.join(', ')}`),\n );\n throw err;\n }\n });\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully pulled in ${dataSilos.length} data silos in ${totalTime / 1000} seconds!`,\n ),\n );\n return dataSilos;\n}\n\n/**\n * Pull all datapoints from the data inventory.\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @returns The datapoints and data silos\n */\nexport async function pullAllDatapoints(\n client: GraphQLClient,\n {\n dataSiloIds = [],\n includeGuessedCategories,\n includeAttributes,\n parentCategories = [],\n subCategories = [],\n pageSize = 1000,\n }: DatapointFilterOptions & {\n /** Page size to pull in */\n pageSize?: number;\n } = {},\n): Promise<\n (SubDataPointCsvPreview & {\n /** Data point information */\n dataPoint: DataPointCsvPreview;\n /** Data silo information */\n dataSilo: DataSiloCsvPreview;\n })[]\n> {\n // Subdatapoint information\n const subDatapoints = await pullSubDatapoints(client, {\n dataSiloIds,\n includeGuessedCategories,\n includeAttributes,\n parentCategories,\n subCategories,\n pageSize,\n });\n\n // The datapoint ids to grab\n const dataPointIds = uniq(subDatapoints.map((point) => point.dataPointId));\n const dataPoints = await pullDatapoints(client, {\n dataPointIds,\n });\n const dataPointById = keyBy(dataPoints, 'id');\n\n // The data silo IDs to grab\n const allDataSiloIds = uniq(subDatapoints.map((point) => point.dataSiloId));\n const dataSilos = await pullDataSilos(client, {\n dataSiloIds: allDataSiloIds,\n });\n const dataSiloById = keyBy(dataSilos, 'id');\n\n return subDatapoints.map((subDataPoint) => ({\n ...subDataPoint,\n dataPoint: dataPointById[subDataPoint.dataPointId],\n dataSilo: dataSiloById[subDataPoint.dataSiloId],\n }));\n}\n/* eslint-enable max-lines */\n"],"mappings":"wcA0FA,eAAe,EACb,EACA,CACE,cAAc,EAAE,CAChB,2BACA,oBACA,mBAAmB,EAAE,CACrB,gBAAgB,EAAE,CAClB,WAAW,KAIT,EAAE,CAC6B,CACnC,IAAM,EAA0C,EAAE,CAG5C,EAAK,IAAI,MAAM,CAAC,SAAS,CAGzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAG/E,EAAW,CACf,GAAI,EAAiB,OAAS,EAAI,CAAE,SAAU,EAAkB,CAAG,EAAE,CACrE,GAAI,EAAc,OAAS,EAAI,CAAE,eAAgB,EAAe,CAAG,EAAE,CAErE,GAAI,EAAiB,OAAS,EAAc,OAAS,GAAK,CAAC,EAEvD,CAAE,OAAQ,EAAuC,SAAU,CAC3D,EAAE,CACN,GAAI,EAAY,OAAS,EAAI,CAAE,UAAW,EAAa,CAAG,EAAE,CAC7D,CAGK,CACJ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M,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EAOvB,OALA,EAAO,KACL,EAAO,MACL,0BAA0B,EAAU,OAAO,iBAAiB,EAAY,IAAK,WAC9E,CACF,CACM,EAUT,eAAsB,EACpB,EACA,CACE,cAAc,EAAE,CAChB,2BACA,oBACA,mBAAmB,EAAE,CACrB,gBAAgB,EAAE,CAClB,WAAW,KAIT,EAAE,CAQN,CAEA,IAAM,EAAgB,MAAM,EAAkB,EAAQ,CACpD,cACA,2BACA,oBACA,mBACA,gBACA,WACD,CAAC,CAOI,EAAgB,EAAM,MAHH,EAAe,EAAQ,CAC9C,aAFmB,EAAK,EAAc,IAAK,GAAU,EAAM,YAAY,CAE3D,CACb,CAAC,CACsC,KAAK,CAOvC,EAAe,EAAM,MAHH,EAAc,EAAQ,CAC5C,YAFqB,EAAK,EAAc,IAAK,GAAU,EAAM,WAAW,CAE7C,CAC5B,CAAC,CACoC,KAAK,CAE3C,OAAO,EAAc,IAAK,IAAkB,CAC1C,GAAG,EACH,UAAW,EAAc,EAAa,aACtC,SAAU,EAAa,EAAa,YACrC,EAAE"}
|
|
1
|
+
{"version":3,"file":"pullAllDatapoints-Bvv9KRR5.mjs","names":[],"sources":["../src/lib/data-inventory/pullAllDatapoints.ts"],"sourcesContent":["import {\n type DataCategoryType,\n SubDataPointDataSubCategoryGuessStatus,\n} from '@transcend-io/privacy-types';\nimport {\n makeGraphQLRequest,\n DATAPOINT_EXPORT,\n DATA_SILO_EXPORT,\n SUB_DATA_POINTS_COUNT,\n type DataSiloAttributeValue,\n} from '@transcend-io/sdk';\nimport { mapSeries } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport { gql, type GraphQLClient } from 'graphql-request';\n/* eslint-disable max-lines */\nimport { keyBy, uniq, chunk, sortBy } from 'lodash-es';\n\nimport type { DataCategoryInput, ProcessingPurposeInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\n\nexport interface DataSiloCsvPreview {\n /** ID of dataSilo */\n id: string;\n /** Name of dataSilo */\n title: string;\n}\n\nexport interface DataPointCsvPreview {\n /** ID of dataPoint */\n id: string;\n /** The path to this data point */\n path: string[];\n /** Description */\n description: {\n /** Default message */\n defaultMessage: string;\n };\n /** Name */\n name: string;\n}\n\nexport interface SubDataPointCsvPreview {\n /** ID of subDatapoint */\n id: string;\n /** Name (or key) of the subdatapoint */\n name: string;\n /** The description */\n description?: string;\n /** Personal data category */\n categories: DataCategoryInput[];\n /** Data point ID */\n dataPointId: string;\n /** The data silo ID */\n dataSiloId: string;\n /** The processing purpose for this sub datapoint */\n purposes: ProcessingPurposeInput[];\n /** Attribute attached to subdatapoint */\n attributeValues?: DataSiloAttributeValue[];\n /** Data category guesses that are output by the classifier */\n pendingCategoryGuesses?: {\n /** Data category being guessed */\n category: DataCategoryInput;\n /** Status of guess */\n status: SubDataPointDataSubCategoryGuessStatus;\n /** classifier version that produced the guess */\n classifierVersion: number;\n }[];\n}\n\nexport interface DatapointFilterOptions {\n /** IDs of data silos to filter down */\n dataSiloIds?: string[];\n /** Whether to include guessed categories, defaults to only approved categories */\n includeGuessedCategories?: boolean;\n /** Whether or not to include attributes */\n includeAttributes?: boolean;\n /** Parent categories to filter down for */\n parentCategories?: DataCategoryType[];\n /** Sub categories to filter down for */\n subCategories?: string[]; // TODO: https://transcend.height.app/T-40482 - do by name not ID\n}\n\n/**\n * Pull subdatapoint information\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @returns The subdatapoints\n */\nasync function pullSubDatapoints(\n client: GraphQLClient,\n {\n dataSiloIds = [],\n includeGuessedCategories,\n includeAttributes,\n parentCategories = [],\n subCategories = [],\n pageSize = 1000,\n }: DatapointFilterOptions & {\n /** Page size to pull in */\n pageSize?: number;\n } = {},\n): Promise<SubDataPointCsvPreview[]> {\n const subDataPoints: SubDataPointCsvPreview[] = [];\n\n // Time duration\n const t0 = new Date().getTime();\n\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Filters\n const filterBy = {\n ...(parentCategories.length > 0 ? { category: parentCategories } : {}),\n ...(subCategories.length > 0 ? { subCategoryIds: subCategories } : {}),\n // if parentCategories or subCategories and not includeGuessedCategories\n ...(parentCategories.length + subCategories.length > 0 && !includeGuessedCategories\n ? // then only show data points with approved data categories\n { status: SubDataPointDataSubCategoryGuessStatus.Approved }\n : {}),\n ...(dataSiloIds.length > 0 ? { dataSilos: dataSiloIds } : {}),\n };\n\n // Build a GraphQL client\n const {\n subDataPoints: { totalCount },\n } = await makeGraphQLRequest<{\n /** Query response */\n subDataPoints: {\n /** Count */\n totalCount: number;\n };\n }>(client, SUB_DATA_POINTS_COUNT, {\n variables: { filterBy },\n logger,\n });\n\n logger.info(colors.magenta('[Step 1/3] Pulling in all subdatapoints'));\n\n progressBar.start(totalCount, 0);\n let total = 0;\n let shouldContinue = false;\n let cursor: string | undefined;\n let offset = 0;\n do {\n try {\n const {\n subDataPoints: { nodes },\n } = await makeGraphQLRequest<{\n /** Query response */\n subDataPoints: {\n /** List of matches */\n nodes: SubDataPointCsvPreview[];\n };\n }>(\n client,\n gql`\n query TranscendCliSubDataPointCsvExport(\n $filterBy: SubDataPointFiltersInput\n $first: Int!\n $offset: Int!\n ) {\n subDataPoints(\n filterBy: $filterBy\n first: $first\n offset: $offset\n useMaster: false\n ) {\n nodes {\n id\n name\n description\n dataPointId\n dataSiloId\n purposes {\n name\n purpose\n }\n categories {\n name\n category\n }\n ${\n includeGuessedCategories\n ? `pendingCategoryGuesses {\n category {\n name\n category\n }\n status\n classifierVersion\n }`\n : ''\n }\n ${\n includeAttributes\n ? `attributeValues {\n attributeKey {\n name\n }\n name\n }`\n : ''\n }\n }\n }\n }\n `,\n {\n variables: {\n first: pageSize,\n offset,\n filterBy: {\n ...filterBy,\n // TODO: https://transcend.height.app/T-40484 - add cursor support\n // ...(cursor ? { cursor: { id: cursor } } : {}),\n },\n },\n logger,\n },\n );\n\n cursor = nodes[nodes.length - 1]?.id as string;\n subDataPoints.push(...nodes);\n shouldContinue = nodes.length === pageSize;\n total += nodes.length;\n offset += nodes.length;\n progressBar.update(total);\n } catch (err) {\n logger.error(\n colors.red(`An error fetching subdatapoints for cursor ${cursor} and offset ${offset}`),\n );\n throw err;\n }\n } while (shouldContinue);\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n const sorted = sortBy(subDataPoints, 'name');\n\n logger.info(\n colors.green(\n `Successfully pulled in ${sorted.length} subdatapoints in ${totalTime / 1000} seconds!`,\n ),\n );\n return sorted;\n}\n\n/**\n * Pull datapoint information\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @returns The datapoints\n */\nasync function pullDatapoints(\n client: GraphQLClient,\n {\n dataPointIds = [],\n pageSize = 100,\n }: {\n /** IDs of data points to filter down */\n dataPointIds: string[];\n /** Page size to pull in */\n pageSize?: number;\n },\n): Promise<DataPointCsvPreview[]> {\n const dataPoints: DataPointCsvPreview[] = [];\n\n // Time duration\n const t0 = new Date().getTime();\n\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n logger.info(colors.magenta(`[Step 2/3] Fetching metadata for ${dataPointIds.length} datapoints`));\n\n // Group by 100\n const dataPointsGrouped = chunk(dataPointIds, pageSize);\n\n progressBar.start(dataPointIds.length, 0);\n let total = 0;\n await mapSeries(dataPointsGrouped, async (dataPointIdsGroup) => {\n try {\n const {\n dataPoints: { nodes },\n } = await makeGraphQLRequest<{\n /** Query response */\n dataPoints: {\n /** List of matches */\n nodes: DataPointCsvPreview[];\n };\n }>(client, DATAPOINT_EXPORT, {\n variables: {\n first: pageSize,\n filterBy: {\n ids: dataPointIdsGroup,\n },\n },\n logger,\n });\n\n dataPoints.push(...nodes);\n total += dataPointIdsGroup.length;\n progressBar.update(total);\n } catch (err) {\n logger.error(\n colors.red(`An error fetching subdatapoints for IDs ${dataPointIdsGroup.join(', ')}`),\n );\n throw err;\n }\n });\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully pulled in ${dataPoints.length} dataPoints in ${totalTime / 1000} seconds!`,\n ),\n );\n return dataPoints;\n}\n\n/**\n * Pull data silo information\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @returns The data silos\n */\nasync function pullDataSilos(\n client: GraphQLClient,\n {\n dataSiloIds = [],\n pageSize = 100,\n }: {\n /** IDs of data silos to filter down */\n dataSiloIds: string[];\n /** Page size to pull in */\n pageSize?: number;\n },\n): Promise<DataSiloCsvPreview[]> {\n const dataSilos: DataSiloCsvPreview[] = [];\n\n // Time duration\n const t0 = new Date().getTime();\n\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n logger.info(colors.magenta(`[Step 3/3] Fetching metadata for ${dataSiloIds.length} data silos`));\n\n // Group by 100\n const dataSilosGrouped = chunk(dataSiloIds, pageSize);\n\n progressBar.start(dataSiloIds.length, 0);\n let total = 0;\n await mapSeries(dataSilosGrouped, async (dataSiloIdsGroup) => {\n try {\n const {\n dataSilos: { nodes },\n } = await makeGraphQLRequest<{\n /** Query response */\n dataSilos: {\n /** List of matches */\n nodes: DataSiloCsvPreview[];\n };\n }>(client, DATA_SILO_EXPORT, {\n variables: {\n first: pageSize,\n filterBy: {\n ids: dataSiloIdsGroup,\n },\n },\n logger,\n });\n\n dataSilos.push(...nodes);\n total += dataSiloIdsGroup.length;\n progressBar.update(total);\n } catch (err) {\n logger.error(\n colors.red(`An error fetching data silos for IDs ${dataSiloIdsGroup.join(', ')}`),\n );\n throw err;\n }\n });\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully pulled in ${dataSilos.length} data silos in ${totalTime / 1000} seconds!`,\n ),\n );\n return dataSilos;\n}\n\n/**\n * Pull all datapoints from the data inventory.\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @returns The datapoints and data silos\n */\nexport async function pullAllDatapoints(\n client: GraphQLClient,\n {\n dataSiloIds = [],\n includeGuessedCategories,\n includeAttributes,\n parentCategories = [],\n subCategories = [],\n pageSize = 1000,\n }: DatapointFilterOptions & {\n /** Page size to pull in */\n pageSize?: number;\n } = {},\n): Promise<\n (SubDataPointCsvPreview & {\n /** Data point information */\n dataPoint: DataPointCsvPreview;\n /** Data silo information */\n dataSilo: DataSiloCsvPreview;\n })[]\n> {\n // Subdatapoint information\n const subDatapoints = await pullSubDatapoints(client, {\n dataSiloIds,\n includeGuessedCategories,\n includeAttributes,\n parentCategories,\n subCategories,\n pageSize,\n });\n\n // The datapoint ids to grab\n const dataPointIds = uniq(subDatapoints.map((point) => point.dataPointId));\n const dataPoints = await pullDatapoints(client, {\n dataPointIds,\n });\n const dataPointById = keyBy(dataPoints, 'id');\n\n // The data silo IDs to grab\n const allDataSiloIds = uniq(subDatapoints.map((point) => point.dataSiloId));\n const dataSilos = await pullDataSilos(client, {\n dataSiloIds: allDataSiloIds,\n });\n const dataSiloById = keyBy(dataSilos, 'id');\n\n return subDatapoints.map((subDataPoint) => ({\n ...subDataPoint,\n dataPoint: dataPointById[subDataPoint.dataPointId],\n dataSilo: dataSiloById[subDataPoint.dataSiloId],\n }));\n}\n/* eslint-enable max-lines */\n"],"mappings":"wcA0FA,eAAe,EACb,EACA,CACE,cAAc,EAAE,CAChB,2BACA,oBACA,mBAAmB,EAAE,CACrB,gBAAgB,EAAE,CAClB,WAAW,KAIT,EAAE,CAC6B,CACnC,IAAM,EAA0C,EAAE,CAG5C,EAAK,IAAI,MAAM,CAAC,SAAS,CAGzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAG/E,EAAW,CACf,GAAI,EAAiB,OAAS,EAAI,CAAE,SAAU,EAAkB,CAAG,EAAE,CACrE,GAAI,EAAc,OAAS,EAAI,CAAE,eAAgB,EAAe,CAAG,EAAE,CAErE,GAAI,EAAiB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AiB,OAC1B,EAAY,OAAO,EAAM,OAClB,EAAK,CAIZ,MAHA,EAAO,MACL,EAAO,IAAI,wCAAwC,EAAiB,KAAK,KAAK,GAAG,CAClF,CACK,IAER,CAEF,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EAOvB,OALA,EAAO,KACL,EAAO,MACL,0BAA0B,EAAU,OAAO,iBAAiB,EAAY,IAAK,WAC9E,CACF,CACM,EAUT,eAAsB,EACpB,EACA,CACE,cAAc,EAAE,CAChB,2BACA,oBACA,mBAAmB,EAAE,CACrB,gBAAgB,EAAE,CAClB,WAAW,KAIT,EAAE,CAQN,CAEA,IAAM,EAAgB,MAAM,EAAkB,EAAQ,CACpD,cACA,2BACA,oBACA,mBACA,gBACA,WACD,CAAC,CAOI,EAAgB,EAAM,MAHH,EAAe,EAAQ,CAC9C,aAFmB,EAAK,EAAc,IAAK,GAAU,EAAM,YAAY,CAE3D,CACb,CAAC,CACsC,KAAK,CAOvC,EAAe,EAAM,MAHH,EAAc,EAAQ,CAC5C,YAFqB,EAAK,EAAc,IAAK,GAAU,EAAM,WAAW,CAE7C,CAC5B,CAAC,CACoC,KAAK,CAE3C,OAAO,EAAc,IAAK,IAAkB,CAC1C,GAAG,EACH,UAAW,EAAc,EAAa,aACtC,SAAU,EAAa,EAAa,YACrC,EAAE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./constants-
|
|
2
|
-
//# sourceMappingURL=pullChunkedCustomSiloOutstandingIdentifiers-
|
|
1
|
+
import{a as e}from"./constants-CEPYyv4h.mjs";import{t}from"./logger-Ckep4QXn.mjs";import{decodeCodec as n}from"@transcend-io/type-utils";import r from"colors";import*as i from"io-ts";import{REDUCED_REQUESTS_FOR_DATA_SILO_COUNT as a,buildTranscendGraphQLClient as o,createSombraGotInstance as s,makeGraphQLRequest as c,withTransientRetry as l}from"@transcend-io/sdk";import{mapSeries as u}from"@transcend-io/utils";import d from"cli-progress";async function f(e,{dataSiloId:n}){let{listReducedRequestsForDataSilo:{totalCount:r}}=await c(e,a,{variables:{input:{dataSiloId:n,isResolved:!1}},logger:t});return r}const p=i.type({id:i.string,name:i.string,partition:i.string}),m=i.intersection([i.type({identifier:i.string,type:i.string,coreIdentifier:i.string,dataSiloId:i.string,requestId:i.string,nonce:i.string,requestCreatedAt:i.string,daysUntilOverdue:i.number,attributes:i.array(i.type({key:i.string,values:i.array(i.string)}))}),i.partial({partition:i.union([p,i.null])})]);async function h(e,{dataSiloId:r,limit:a=100,offset:o=0,requestType:s}){try{let c=await l(`pullCronPageOfIdentifiers`,()=>e.get(`v1/data-silo/${r}/pending-requests/${s}`,{searchParams:{offset:o,limit:a}}).json(),{logger:t,maxAttempts:6,baseDelayMs:500}),{items:u}=n(i.type({items:i.array(m)}),c);return u}catch(e){throw Error(`Received an error from server: ${e?.response?.body||e?.message}`)}}async function g({dataSiloId:n,auth:i,sombraAuth:a,actions:c,apiPageSize:l=100,savePageSize:p=1e3,onSave:m,transcendUrl:g=e,skipRequestCount:_=!1}){if(p%l!==0)throw Error(`savePageSize must be a multiple of apiPageSize. savePageSize: ${p}, apiPageSize: ${l}`);let v=await s(g,i,{logger:t,sombraApiKey:a,sombraUrl:process.env.SOMBRA_URL}),y=o(g,i),b=0;_||(b=await f(y,{dataSiloId:n})),t.info(r.magenta(`Pulling ${_?`all`:b} outstanding request identifiers for data silo: "${n}" for requests of types "${c.join(`", "`)}"`));let x=new Date().getTime(),S=new d.SingleBar({},d.Presets.shades_classic),C=new Set,w=[],T=[];_||S.start(b,0),await u(c,async e=>{let i=0,a=!0;for(;a;){let o=await h(v,{dataSiloId:n,limit:l,offset:i,requestType:e}),s=o.map(t=>(C.add(t.requestId),{...t,action:e})),c=s.map(({attributes:e,partition:t,...n})=>({...n,...t?{partitionId:t.id,partitionName:t.name,partitionKey:t.partition}:{},...e.reduce((e,t)=>Object.assign(e,{[t.key]:t.values.join(`,`)}),{})}));w.push(...s),T.push(...c),T.length>=p&&(await m(T),T=[]),a=o.length===l,i+=l,_?t.info(r.magenta(`Pulled ${o.length} outstanding identifiers for ${C.size} requests`)):S.update(C.size)}}),T.length>0&&await m(T),_||S.stop();let E=new Date().getTime()-x;return t.info(r.green(`Successfully pulled ${w.length} outstanding identifiers from ${C.size} requests in "${E/1e3}" seconds!`)),{identifiers:w}}export{f as a,h as i,m as n,p as r,g as t};
|
|
2
|
+
//# sourceMappingURL=pullChunkedCustomSiloOutstandingIdentifiers-io0k95RW.mjs.map
|