@transcend-io/cli 12.1.5 → 13.0.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 +64 -14
- package/dist/{app-BMLQABJX.mjs → app-Bms-wwFP.mjs} +19 -19
- package/dist/app-Bms-wwFP.mjs.map +1 -0
- package/dist/{approvePrivacyRequests-CY6rQT4J.mjs → approvePrivacyRequests-DyLb38gV.mjs} +2 -2
- package/dist/{approvePrivacyRequests-CY6rQT4J.mjs.map → approvePrivacyRequests-DyLb38gV.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-BNGtj-DW.mjs → buildExamples-Ck7gzWSG.mjs} +2 -2
- package/dist/{buildExamples-BNGtj-DW.mjs.map → buildExamples-Ck7gzWSG.mjs.map} +1 -1
- package/dist/{buildXdiSyncEndpoint-BNCfOc-g.mjs → buildXdiSyncEndpoint-etqb_c38.mjs} +2 -2
- package/dist/{buildXdiSyncEndpoint-BNCfOc-g.mjs.map → buildXdiSyncEndpoint-etqb_c38.mjs.map} +1 -1
- package/dist/{bulkRestartRequests-CGvODu3r.mjs → bulkRestartRequests-DWJ8N0fa.mjs} +2 -2
- package/dist/{bulkRestartRequests-CGvODu3r.mjs.map → bulkRestartRequests-DWJ8N0fa.mjs.map} +1 -1
- package/dist/{bulkRetryEnrichers-BgDd4GWH.mjs → bulkRetryEnrichers-J8CHMy_1.mjs} +2 -2
- package/dist/{bulkRetryEnrichers-BgDd4GWH.mjs.map → bulkRetryEnrichers-J8CHMy_1.mjs.map} +1 -1
- package/dist/{cancelPrivacyRequests-Ccsiwrnu.mjs → cancelPrivacyRequests-C9nFdfgW.mjs} +2 -2
- package/dist/{cancelPrivacyRequests-Ccsiwrnu.mjs.map → cancelPrivacyRequests-C9nFdfgW.mjs.map} +1 -1
- package/dist/codecs-8T8Jhxsr.mjs +2 -0
- package/dist/codecs-8T8Jhxsr.mjs.map +1 -0
- package/dist/{command-BjzdoKgJ.mjs → command-C-wEPTO5.mjs} +2 -2
- package/dist/{command-BjzdoKgJ.mjs.map → command-C-wEPTO5.mjs.map} +1 -1
- package/dist/constants-D6y_AX3P.mjs +2 -0
- package/dist/constants-D6y_AX3P.mjs.map +1 -0
- package/dist/{constants-FDjw7bPS.mjs → constants-I694qbRg.mjs} +2 -2
- package/dist/{constants-FDjw7bPS.mjs.map → constants-I694qbRg.mjs.map} +1 -1
- package/dist/{createPoolingCommandUi-BdtnLBBM.mjs → createPoolingCommandUi-BZr2HSiZ.mjs} +2 -2
- package/dist/{createPoolingCommandUi-BdtnLBBM.mjs.map → createPoolingCommandUi-BZr2HSiZ.mjs.map} +1 -1
- package/dist/{downloadPrivacyRequestFiles-C9-xSCpt.mjs → downloadPrivacyRequestFiles-CF_QjkR9.mjs} +2 -2
- package/dist/{downloadPrivacyRequestFiles-C9-xSCpt.mjs.map → downloadPrivacyRequestFiles-CF_QjkR9.mjs.map} +1 -1
- package/dist/fetchAllRequests-BV9K0wXv.mjs +2 -0
- package/dist/fetchAllRequests-BV9K0wXv.mjs.map +1 -0
- package/dist/{fuzzyMatchColumns-D18n9Beu.mjs → fuzzyMatchColumns-Djl3a7lV.mjs} +2 -2
- package/dist/{fuzzyMatchColumns-D18n9Beu.mjs.map → fuzzyMatchColumns-Djl3a7lV.mjs.map} +1 -1
- package/dist/{generateCrossAccountApiKeys-FtWwlf_L.mjs → generateCrossAccountApiKeys-BxW6xU40.mjs} +2 -2
- package/dist/{generateCrossAccountApiKeys-FtWwlf_L.mjs.map → generateCrossAccountApiKeys-BxW6xU40.mjs.map} +1 -1
- package/dist/{impl-SOebshza.mjs → impl-3VziEzJI.mjs} +2 -2
- package/dist/{impl-SOebshza.mjs.map → impl-3VziEzJI.mjs.map} +1 -1
- package/dist/{impl-DnDM9zcu.mjs → impl-7NFxUzSa.mjs} +2 -2
- package/dist/{impl-DnDM9zcu.mjs.map → impl-7NFxUzSa.mjs.map} +1 -1
- package/dist/{impl-Dg7XSQdO2.mjs → impl-7qTKg-YP2.mjs} +2 -2
- package/dist/{impl-Dg7XSQdO2.mjs.map → impl-7qTKg-YP2.mjs.map} +1 -1
- package/dist/{impl-zZd6fuXS.mjs → impl-AWYAfZ2C.mjs} +2 -2
- package/dist/{impl-zZd6fuXS.mjs.map → impl-AWYAfZ2C.mjs.map} +1 -1
- package/dist/{impl-B94dMG4x2.mjs → impl-B-BkGfqq2.mjs} +2 -2
- package/dist/{impl-B94dMG4x2.mjs.map → impl-B-BkGfqq2.mjs.map} +1 -1
- package/dist/{impl-Dd39KsYO.mjs → impl-B0NqrNcJ2.mjs} +2 -2
- package/dist/impl-B0NqrNcJ2.mjs.map +1 -0
- package/dist/{impl-C3vTm9zQ.mjs → impl-B5fkF8m2.mjs} +2 -2
- package/dist/{impl-C3vTm9zQ.mjs.map → impl-B5fkF8m2.mjs.map} +1 -1
- package/dist/{impl-xVmMN-Vt.mjs → impl-B9vbcV8J.mjs} +2 -2
- package/dist/{impl-xVmMN-Vt.mjs.map → impl-B9vbcV8J.mjs.map} +1 -1
- package/dist/{impl-CSnBFv5P.mjs → impl-BCTVuvlD.mjs} +2 -2
- package/dist/{impl-CSnBFv5P.mjs.map → impl-BCTVuvlD.mjs.map} +1 -1
- package/dist/impl-BfS6LtNo2.mjs +2 -0
- package/dist/impl-BfS6LtNo2.mjs.map +1 -0
- package/dist/{impl-qNF5eqX-.mjs → impl-BfU0GFmW.mjs} +1 -1
- package/dist/{impl-qNF5eqX-.mjs.map → impl-BfU0GFmW.mjs.map} +1 -1
- package/dist/{impl-BXGpJz21.mjs → impl-Bhmoagby.mjs} +2 -2
- package/dist/{impl-BXGpJz21.mjs.map → impl-Bhmoagby.mjs.map} +1 -1
- package/dist/{impl-COqlYiiw.mjs → impl-Bpiggf8H.mjs} +2 -2
- package/dist/{impl-COqlYiiw.mjs.map → impl-Bpiggf8H.mjs.map} +1 -1
- package/dist/{impl-D6frX-PK.mjs → impl-BsxD7toO.mjs} +2 -2
- package/dist/{impl-D6frX-PK.mjs.map → impl-BsxD7toO.mjs.map} +1 -1
- package/dist/{impl-Bs2pNgMK.mjs → impl-BvL9wElZ.mjs} +2 -2
- package/dist/{impl-Bs2pNgMK.mjs.map → impl-BvL9wElZ.mjs.map} +1 -1
- package/dist/{impl-DUYRVzMo.mjs → impl-BzzkiK_b.mjs} +1 -1
- package/dist/{impl-DUYRVzMo.mjs.map → impl-BzzkiK_b.mjs.map} +1 -1
- package/dist/{impl-DZoTWLfw2.mjs → impl-C-hBO0Wa2.mjs} +2 -2
- package/dist/{impl-DZoTWLfw2.mjs.map → impl-C-hBO0Wa2.mjs.map} +1 -1
- package/dist/{impl-bl6NF3Lr.mjs → impl-C6tbQV8G.mjs} +2 -2
- package/dist/{impl-bl6NF3Lr.mjs.map → impl-C6tbQV8G.mjs.map} +1 -1
- package/dist/{impl-BEiCEzl_2.mjs → impl-CHoglMch.mjs} +1 -1
- package/dist/impl-CHoglMch.mjs.map +1 -0
- package/dist/{impl-ClT3G845.mjs → impl-CQ3NctWn.mjs} +2 -2
- package/dist/{impl-ClT3G845.mjs.map → impl-CQ3NctWn.mjs.map} +1 -1
- package/dist/{impl-DhXzxQDN2.mjs → impl-CRif3TpB2.mjs} +2 -2
- package/dist/{impl-DhXzxQDN2.mjs.map → impl-CRif3TpB2.mjs.map} +1 -1
- package/dist/{impl-Cvyc-iTI2.mjs → impl-CWINXCFq2.mjs} +2 -2
- package/dist/{impl-Cvyc-iTI2.mjs.map → impl-CWINXCFq2.mjs.map} +1 -1
- package/dist/{impl-BLtOfbtk.mjs → impl-CaErz960.mjs} +2 -2
- package/dist/{impl-BLtOfbtk.mjs.map → impl-CaErz960.mjs.map} +1 -1
- package/dist/{impl-D6rMLiNB2.mjs → impl-CjOkPJJx.mjs} +2 -2
- package/dist/impl-CjOkPJJx.mjs.map +1 -0
- package/dist/{impl-yIVxAhCG2.mjs → impl-CpJIikeg2.mjs} +2 -2
- package/dist/{impl-yIVxAhCG2.mjs.map → impl-CpJIikeg2.mjs.map} +1 -1
- package/dist/{impl-XxYQHKO5.mjs → impl-CujcaHKR.mjs} +2 -2
- package/dist/{impl-XxYQHKO5.mjs.map → impl-CujcaHKR.mjs.map} +1 -1
- package/dist/{impl-BLOhoP-b2.mjs → impl-CzFfjx8n2.mjs} +2 -2
- package/dist/{impl-BLOhoP-b2.mjs.map → impl-CzFfjx8n2.mjs.map} +1 -1
- package/dist/{impl-QD3_9HTk.mjs → impl-CzgNvB64.mjs} +2 -2
- package/dist/{impl-QD3_9HTk.mjs.map → impl-CzgNvB64.mjs.map} +1 -1
- package/dist/{impl-B_N_fOq0.mjs → impl-D5BItJzQ.mjs} +2 -2
- package/dist/{impl-B_N_fOq0.mjs.map → impl-D5BItJzQ.mjs.map} +1 -1
- package/dist/{impl-DeCRXfAh2.mjs → impl-DEF-meSg2.mjs} +2 -2
- package/dist/{impl-DeCRXfAh2.mjs.map → impl-DEF-meSg2.mjs.map} +1 -1
- package/dist/{impl-CTOgxZFi.mjs → impl-DIz7yqDc.mjs} +2 -2
- package/dist/{impl-CTOgxZFi.mjs.map → impl-DIz7yqDc.mjs.map} +1 -1
- package/dist/{impl-DDVhG8Gf.mjs → impl-DLnVDCjy.mjs} +2 -2
- package/dist/{impl-DDVhG8Gf.mjs.map → impl-DLnVDCjy.mjs.map} +1 -1
- package/dist/{impl-DGtCNANL.mjs → impl-DMoMMAMW.mjs} +2 -2
- package/dist/{impl-DGtCNANL.mjs.map → impl-DMoMMAMW.mjs.map} +1 -1
- package/dist/{impl-ChQAmyBN.mjs → impl-DMwjar-u.mjs} +2 -2
- package/dist/{impl-ChQAmyBN.mjs.map → impl-DMwjar-u.mjs.map} +1 -1
- package/dist/{impl-Bz1wZxa-.mjs → impl-DUWlKcy6.mjs} +2 -2
- package/dist/{impl-Bz1wZxa-.mjs.map → impl-DUWlKcy6.mjs.map} +1 -1
- package/dist/{impl-D58JUOdA.mjs → impl-DY_TNWaO.mjs} +2 -2
- package/dist/{impl-D58JUOdA.mjs.map → impl-DY_TNWaO.mjs.map} +1 -1
- package/dist/{impl-Cp5o0Q2g.mjs → impl-D_8KoR4w.mjs} +2 -2
- package/dist/{impl-Cp5o0Q2g.mjs.map → impl-D_8KoR4w.mjs.map} +1 -1
- package/dist/{impl-VSo8bO-J.mjs → impl-DdL7paBD.mjs} +2 -2
- package/dist/{impl-VSo8bO-J.mjs.map → impl-DdL7paBD.mjs.map} +1 -1
- package/dist/{impl-0-_oxvck.mjs → impl-DioQW8jR.mjs} +2 -2
- package/dist/{impl-0-_oxvck.mjs.map → impl-DioQW8jR.mjs.map} +1 -1
- package/dist/{impl-EDwngLc7.mjs → impl-Dj4IYEXg.mjs} +2 -2
- package/dist/{impl-EDwngLc7.mjs.map → impl-Dj4IYEXg.mjs.map} +1 -1
- package/dist/{impl-BvwRiPSG.mjs → impl-DpW_rDzv.mjs} +2 -2
- package/dist/{impl-BvwRiPSG.mjs.map → impl-DpW_rDzv.mjs.map} +1 -1
- package/dist/{impl-Cb-7C1Ml2.mjs → impl-Dr1qLfh1.mjs} +12 -105
- package/dist/impl-Dr1qLfh1.mjs.map +1 -0
- package/dist/{impl-agm4lpyq.mjs → impl-HsRwcfRu.mjs} +2 -2
- package/dist/{impl-agm4lpyq.mjs.map → impl-HsRwcfRu.mjs.map} +1 -1
- package/dist/{impl-BHEAKFX02.mjs → impl-LT1FBKID2.mjs} +2 -2
- package/dist/{impl-BHEAKFX02.mjs.map → impl-LT1FBKID2.mjs.map} +1 -1
- package/dist/impl-Q2ZDQO_y2.mjs +2 -0
- package/dist/impl-Q2ZDQO_y2.mjs.map +1 -0
- package/dist/{impl-DFnWzZyY.mjs → impl-UtanPzK1.mjs} +2 -2
- package/dist/{impl-DFnWzZyY.mjs.map → impl-UtanPzK1.mjs.map} +1 -1
- package/dist/{impl-Ar7VAh0Z.mjs → impl-ZFp_SwYr.mjs} +2 -2
- package/dist/{impl-Ar7VAh0Z.mjs.map → impl-ZFp_SwYr.mjs.map} +1 -1
- package/dist/{impl-Hj5CgbWd.mjs → impl-eWsR0UvV.mjs} +2 -2
- package/dist/{impl-Hj5CgbWd.mjs.map → impl-eWsR0UvV.mjs.map} +1 -1
- package/dist/{impl-Ay6JeH-7.mjs → impl-kuuX5KaC.mjs} +2 -2
- package/dist/{impl-Ay6JeH-7.mjs.map → impl-kuuX5KaC.mjs.map} +1 -1
- package/dist/{impl-xY_5o78i.mjs → impl-mBJWy3lg.mjs} +2 -2
- package/dist/{impl-xY_5o78i.mjs.map → impl-mBJWy3lg.mjs.map} +1 -1
- package/dist/{impl-ojAnhhbi.mjs → impl-nWslO7Lu.mjs} +2 -2
- package/dist/{impl-ojAnhhbi.mjs.map → impl-nWslO7Lu.mjs.map} +1 -1
- package/dist/{impl-ApZGIx6l.mjs → impl-o66EB2o7.mjs} +2 -2
- package/dist/{impl-ApZGIx6l.mjs.map → impl-o66EB2o7.mjs.map} +1 -1
- package/dist/{impl-BCKUj-ko.mjs → impl-pqCx3OlD.mjs} +2 -2
- package/dist/{impl-BCKUj-ko.mjs.map → impl-pqCx3OlD.mjs.map} +1 -1
- package/dist/{impl-BpVe6fMe.mjs → impl-yxR3rwGm.mjs} +2 -2
- package/dist/{impl-BpVe6fMe.mjs.map → impl-yxR3rwGm.mjs.map} +1 -1
- package/dist/index.d.mts +36 -26
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{inquirer-jzIQWAvq.mjs → inquirer-DK1JbPA0.mjs} +2 -2
- package/dist/{inquirer-jzIQWAvq.mjs.map → inquirer-DK1JbPA0.mjs.map} +1 -1
- package/dist/{markRequestDataSiloIdsCompleted-JGJf33yp.mjs → markRequestDataSiloIdsCompleted-CRLlmf-g.mjs} +2 -2
- package/dist/{markRequestDataSiloIdsCompleted-JGJf33yp.mjs.map → markRequestDataSiloIdsCompleted-CRLlmf-g.mjs.map} +1 -1
- package/dist/{markSilentPrivacyRequests-BTI3rH-V.mjs → markSilentPrivacyRequests-CZIAGpw2.mjs} +2 -2
- package/dist/{markSilentPrivacyRequests-BTI3rH-V.mjs.map → markSilentPrivacyRequests-CZIAGpw2.mjs.map} +1 -1
- package/dist/{mergeTranscendInputs-B7WjxYMN.mjs → mergeTranscendInputs-9kQ3t5VY.mjs} +2 -2
- package/dist/{mergeTranscendInputs-B7WjxYMN.mjs.map → mergeTranscendInputs-9kQ3t5VY.mjs.map} +1 -1
- package/dist/{notifyPrivacyRequestsAdditionalTime-n5fvOJaA.mjs → notifyPrivacyRequestsAdditionalTime-KiF9dkuk.mjs} +2 -2
- package/dist/{notifyPrivacyRequestsAdditionalTime-n5fvOJaA.mjs.map → notifyPrivacyRequestsAdditionalTime-KiF9dkuk.mjs.map} +1 -1
- package/dist/{policy-bundle-manifest-DbbTXe0u.mjs → policy-bundle-manifest-DW1kUjMf.mjs} +2 -2
- package/dist/{policy-bundle-manifest-DbbTXe0u.mjs.map → policy-bundle-manifest-DW1kUjMf.mjs.map} +1 -1
- package/dist/{policy-project-discovery-DTSl0Gfl.mjs → policy-project-discovery-BSQ2Cow0.mjs} +4 -4
- package/dist/policy-project-discovery-BSQ2Cow0.mjs.map +1 -0
- package/dist/{policy-scaffold-config-RpxwwZ2H.mjs → policy-scaffold-config-B_Xbfv7q.mjs} +8 -8
- package/dist/policy-scaffold-config-B_Xbfv7q.mjs.map +1 -0
- package/dist/{project-discovery-BkHpTXDx.mjs → project-discovery-g29vd44a.mjs} +2 -2
- package/dist/{project-discovery-BkHpTXDx.mjs.map → project-discovery-g29vd44a.mjs.map} +1 -1
- package/dist/{pullChunkedCustomSiloOutstandingIdentifiers-DbybCU2T.mjs → pullChunkedCustomSiloOutstandingIdentifiers-ekuEZlzq.mjs} +2 -2
- package/dist/{pullChunkedCustomSiloOutstandingIdentifiers-DbybCU2T.mjs.map → pullChunkedCustomSiloOutstandingIdentifiers-ekuEZlzq.mjs.map} +1 -1
- package/dist/{pullManualEnrichmentIdentifiersToCsv-CxTPUfpV.mjs → pullManualEnrichmentIdentifiersToCsv-D710M8kt.mjs} +2 -2
- package/dist/{pullManualEnrichmentIdentifiersToCsv-CxTPUfpV.mjs.map → pullManualEnrichmentIdentifiersToCsv-D710M8kt.mjs.map} +1 -1
- package/dist/{pushCronIdentifiersFromCsv-CeRVlbFE.mjs → pushCronIdentifiersFromCsv-f8FSSFhM.mjs} +2 -2
- package/dist/{pushCronIdentifiersFromCsv-CeRVlbFE.mjs.map → pushCronIdentifiersFromCsv-f8FSSFhM.mjs.map} +1 -1
- package/dist/{pushManualEnrichmentIdentifiersFromCsv--4dYCvyv.mjs → pushManualEnrichmentIdentifiersFromCsv-6xOUhOpJ.mjs} +2 -2
- package/dist/{pushManualEnrichmentIdentifiersFromCsv--4dYCvyv.mjs.map → pushManualEnrichmentIdentifiersFromCsv-6xOUhOpJ.mjs.map} +1 -1
- package/dist/{readTranscendYaml-BfqQbPiT.mjs → readTranscendYaml-D576bvzR.mjs} +2 -2
- package/dist/{readTranscendYaml-BfqQbPiT.mjs.map → readTranscendYaml-D576bvzR.mjs.map} +1 -1
- package/dist/{removeUnverifiedRequestIdentifiers-CV6JGgt_.mjs → removeUnverifiedRequestIdentifiers-B8iIreP4.mjs} +2 -2
- package/dist/{removeUnverifiedRequestIdentifiers-CV6JGgt_.mjs.map → removeUnverifiedRequestIdentifiers-B8iIreP4.mjs.map} +1 -1
- package/dist/{retryRequestDataSilos-_OThvVwU.mjs → retryRequestDataSilos-BQuxZd4C.mjs} +2 -2
- package/dist/{retryRequestDataSilos-_OThvVwU.mjs.map → retryRequestDataSilos-BQuxZd4C.mjs.map} +1 -1
- package/dist/runRegalLintStep-DPaMm7Gg.mjs +3 -0
- package/dist/runRegalLintStep-DPaMm7Gg.mjs.map +1 -0
- package/dist/{scaffold-planning-BrX-pcz6.mjs → scaffold-planning-Bp_yqZWx.mjs} +2 -2
- package/dist/{scaffold-planning-BrX-pcz6.mjs.map → scaffold-planning-Bp_yqZWx.mjs.map} +1 -1
- package/dist/{skipPreflightJobs-D8og5pKe.mjs → skipPreflightJobs-BkTH4QOf.mjs} +2 -2
- package/dist/{skipPreflightJobs-D8og5pKe.mjs.map → skipPreflightJobs-BkTH4QOf.mjs.map} +1 -1
- package/dist/{skipRequestDataSilos-DUQ6AD_O.mjs → skipRequestDataSilos-sdfJ0gPn.mjs} +2 -2
- package/dist/{skipRequestDataSilos-DUQ6AD_O.mjs.map → skipRequestDataSilos-sdfJ0gPn.mjs.map} +1 -1
- package/dist/{streamPrivacyRequestsToCsv-BApu4dvI.mjs → streamPrivacyRequestsToCsv-D0PK8mjN.mjs} +2 -2
- package/dist/{streamPrivacyRequestsToCsv-BApu4dvI.mjs.map → streamPrivacyRequestsToCsv-D0PK8mjN.mjs.map} +1 -1
- package/dist/{updateConsentManagerVersionToLatest-BrgPZ5hX.mjs → updateConsentManagerVersionToLatest-EJaexjTY.mjs} +2 -2
- package/dist/{updateConsentManagerVersionToLatest-BrgPZ5hX.mjs.map → updateConsentManagerVersionToLatest-EJaexjTY.mjs.map} +1 -1
- package/dist/{uploadConsents-DRlDHQak.mjs → uploadConsents-DjvQVsIl.mjs} +2 -2
- package/dist/{uploadConsents-DRlDHQak.mjs.map → uploadConsents-DjvQVsIl.mjs.map} +1 -1
- package/dist/uploadPrivacyRequestsFromCsv-FvSx9zis.mjs +2 -0
- package/dist/uploadPrivacyRequestsFromCsv-FvSx9zis.mjs.map +1 -0
- package/dist/{validateTranscendAuth-D-dDINof.mjs → validateTranscendAuth-BrVGfq6X.mjs} +2 -2
- package/dist/{validateTranscendAuth-D-dDINof.mjs.map → validateTranscendAuth-BrVGfq6X.mjs.map} +1 -1
- package/package.json +6 -6
- package/dist/app-BMLQABJX.mjs.map +0 -1
- package/dist/codecs-CfcaFoZR.mjs +0 -2
- package/dist/codecs-CfcaFoZR.mjs.map +0 -1
- package/dist/constants-DlH2vWm_.mjs +0 -2
- package/dist/constants-DlH2vWm_.mjs.map +0 -1
- package/dist/fetchAllRequests-BI0tFl_a.mjs +0 -2
- package/dist/fetchAllRequests-BI0tFl_a.mjs.map +0 -1
- package/dist/impl-BEiCEzl_2.mjs.map +0 -1
- package/dist/impl-Cb-7C1Ml2.mjs.map +0 -1
- package/dist/impl-D6rMLiNB2.mjs.map +0 -1
- package/dist/impl-DNOgBcsu.mjs +0 -3
- package/dist/impl-DNOgBcsu.mjs.map +0 -1
- package/dist/impl-Dd39KsYO.mjs.map +0 -1
- package/dist/policy-project-discovery-DTSl0Gfl.mjs.map +0 -1
- package/dist/policy-scaffold-config-RpxwwZ2H.mjs.map +0 -1
- package/dist/uploadPrivacyRequestsFromCsv-FAGllBdd.mjs +0 -2
- package/dist/uploadPrivacyRequestsFromCsv-FAGllBdd.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-discovery-BkHpTXDx.mjs","names":[],"sources":["../src/lib/custom-functions/execution-context.ts","../src/lib/custom-functions/manifest.ts","../src/lib/custom-functions/project-discovery.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport { isIP } from 'node:net';\n\n/** Maximum environment value size supported by the local process. */\nexport const CUSTOM_FUNCTION_MAX_ENV_VALUE_BYTES = 64 * 1024;\n\nconst RESERVED_ENV_NAMES = new Set([\n 'DENO_CERT',\n 'DENO_DIR',\n 'DENO_TLS_CA_STORE',\n 'HTTP_PROXY',\n 'HTTPS_PROXY',\n 'NODE_EXTRA_CA_CERTS',\n 'NO_COLOR',\n 'NO_PROXY',\n 'NPM_CONFIG_REGISTRY',\n]);\n\n/**\n * Check whether a value matches Sombra's hostname/IP contract.\n *\n * @param host - Manifest allowed-host value\n * @returns Whether the host is valid\n */\nfunction isValidAllowedHost(host: string): boolean {\n const bracketedIp = /^\\[([^\\]]+)\\](?::(\\d+))?$/u.exec(host);\n if (bracketedIp) {\n const port = bracketedIp[2];\n return isIP(bracketedIp[1]!) === 6 && (!port || (Number(port) > 0 && Number(port) <= 65_535));\n }\n if (isIP(host) > 0) {\n return true;\n }\n const hostWithPort = /^([^:]+):(\\d+)$/u.exec(host);\n const hostname = hostWithPort?.[1] ?? host;\n const port = hostWithPort?.[2];\n return (\n (!port || (Number(port) > 0 && Number(port) <= 65_535)) &&\n hostname.length <= 253 &&\n hostname\n .split('.')\n .every(\n (label) =>\n label.length > 0 &&\n label.length <= 63 &&\n /^[A-Za-z\\d](?:[A-Za-z\\d-]*[A-Za-z\\d])?$/u.test(label),\n )\n );\n}\n\n/**\n * Validate execution settings shared by check, push, and local simulation.\n *\n * @param config - Environment and network settings\n */\nexport function validateCustomFunctionExecutionContext(config: {\n /** User-defined environment variables. */\n env?: Record<string, string>;\n /** Native network destinations. */\n allowedHosts?: string[];\n}): void {\n const environment = config.env ?? {};\n const envNames = Object.keys(environment);\n const malformedEnvNames = envNames.filter((name) => !/^[A-Za-z][A-Za-z\\d_]*$/u.test(name));\n const reservedEnvNames = envNames.filter(\n (name) => RESERVED_ENV_NAMES.has(name) || name.startsWith('DENO_'),\n );\n if (malformedEnvNames.length > 0 || reservedEnvNames.length > 0) {\n throw new Error(\n [\n malformedEnvNames.length > 0\n ? `Invalid environment variable names: ${malformedEnvNames.join(', ')}`\n : undefined,\n reservedEnvNames.length > 0\n ? `Reserved environment variable names: ${reservedEnvNames.join(', ')}`\n : undefined,\n ]\n .filter(Boolean)\n .join('. '),\n );\n }\n const oversizedEnvNames = envNames.filter(\n (name) => Buffer.byteLength(environment[name]!) > CUSTOM_FUNCTION_MAX_ENV_VALUE_BYTES,\n );\n if (oversizedEnvNames.length > 0) {\n throw new Error(\n `Environment values exceed ${CUSTOM_FUNCTION_MAX_ENV_VALUE_BYTES} bytes: ${oversizedEnvNames.join(', ')}`,\n );\n }\n const allowedHosts = config.allowedHosts ?? [];\n if (allowedHosts.length > 1 && allowedHosts.includes('*')) {\n throw new Error('allowed-hosts cannot combine \"*\" with specific hosts.');\n }\n const invalidHosts = allowedHosts.filter((host) => host !== '*' && !isValidAllowedHost(host));\n if (invalidHosts.length > 0) {\n throw new Error(`Invalid allowed-hosts: ${invalidHosts.join(', ')}`);\n }\n}\n","import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, isAbsolute, relative, resolve, sep } from 'node:path';\n\nimport { CustomFunctionPayloadType, CustomFunctionType } from '@transcend-io/privacy-types';\nimport type { CustomFunctionConfigInput } from '@transcend-io/sdk';\nimport { decodeCodec, type ObjByString } from '@transcend-io/type-utils';\nimport * as t from 'io-ts';\nimport yaml from 'js-yaml';\nimport { isMap, isScalar, isSeq, parseDocument } from 'yaml';\n\nimport { replaceVariablesInYaml } from '../readTranscendYaml.js';\nimport { validateCustomFunctionExecutionContext } from './execution-context.js';\n\nexport const CustomFunctionManifestEntry = t.intersection([\n t.type({\n /** Display name of the custom function — used as the sync key when no `id` is set */\n name: t.string,\n /** Path to the TypeScript source file, relative to the manifest */\n code: t.string,\n }),\n t.partial({\n /**\n * Custom function ID. Optional, but required to disambiguate when multiple\n * custom functions share a name. Written back by `push --updateManifest`.\n */\n id: t.string,\n /** Description shown in the Transcend dashboard */\n description: t.string,\n /** Custom function type. Defaults to GENERAL */\n type: t.union([t.literal(CustomFunctionType.Dsr), t.literal(CustomFunctionType.General)]),\n /** Data silo ID to attach to (required for DSR functions) */\n 'data-silo-id': t.string,\n /** The Sombra gateway the function belongs to */\n 'sombra-id': t.string,\n /**\n * Name of the environment variable holding the internal key of the\n * function's Sombra gateway. The key itself never lives in the manifest —\n * it is read from the CLI's process environment at push time. Overrides\n * `--sombraAuth` for this entry.\n */\n 'sombra-auth-env': t.string,\n /** Hosts the function may make network requests to */\n 'allowed-hosts': t.array(t.string),\n /** Execution timeout in milliseconds */\n 'timeout-ms': t.number,\n /** Whether the function may import third party modules */\n 'allow-third-party-imports': t.boolean,\n /** Environment variables to expose to the function */\n env: t.record(t.string, t.string),\n /**\n * Path to a JSON file (relative to the manifest) holding the test payload\n * to run the function with before pushing. When set, the function is\n * test-run after signing and only pushed/promoted when the test passes.\n * Shorthand for a single-item `test-payloads` list.\n */\n 'test-payload': t.string,\n /**\n * Which export to invoke when test-running a DSR function:\n * `DATA_POINT` invokes the default export, `REQUEST_ENRICHER` invokes the\n * `enricher` export. Defaults to DATA_POINT. Ignored for GENERAL functions.\n * Only valid alongside `test-payload`.\n */\n 'test-payload-type': t.union([\n t.literal(CustomFunctionPayloadType.DataPoint),\n t.literal(CustomFunctionPayloadType.RequestEnricher),\n ]),\n /**\n * Test payloads to run the function with before pushing. Every payload\n * runs and all must pass for the function to be pushed/promoted. DSR\n * functions should list one payload per export they implement\n * (`DATA_POINT` for the default export, `REQUEST_ENRICHER` for the\n * `enricher` export). Mutually exclusive with `test-payload`.\n */\n 'test-payloads': t.array(\n t.intersection([\n t.type({\n /** Path to the JSON payload file, relative to the manifest */\n payload: t.string,\n }),\n t.partial({\n /** Which export the payload invokes (DSR only). Defaults to DATA_POINT */\n 'payload-type': t.union([\n t.literal(CustomFunctionPayloadType.DataPoint),\n t.literal(CustomFunctionPayloadType.RequestEnricher),\n ]),\n }),\n ]),\n ),\n }),\n]);\n\n/** Override type */\nexport type CustomFunctionManifestEntry = t.TypeOf<typeof CustomFunctionManifestEntry>;\n\nexport const CustomFunctionsManifest = t.type({\n /** The custom functions to sync */\n functions: t.array(CustomFunctionManifestEntry),\n});\n\n/** Override type */\nexport type CustomFunctionsManifest = t.TypeOf<typeof CustomFunctionsManifest>;\n\n/**\n * Determine whether a relative manifest path stays inside the manifest's\n * directory after normalization.\n *\n * @param filePath - Path from a custom function manifest entry\n * @returns Whether the normalized path is contained by the manifest directory\n */\nexport function isCustomFunctionManifestPathContained(filePath: string): boolean {\n const manifestDirectory = resolve('/', '__custom-function-manifest__');\n const relativePath = relative(manifestDirectory, resolve(manifestDirectory, filePath));\n return relativePath !== '..' && !relativePath.startsWith(`..${sep}`) && !isAbsolute(relativePath);\n}\n\n/**\n * Validate semantic constraints shared by manifest readers and editors.\n *\n * @param manifest - Shape-validated custom function manifest\n * @param options - Validation behavior\n */\nexport function validateCustomFunctionsManifest(\n manifest: CustomFunctionsManifest,\n options: {\n /** Skip path validation while identifying candidate manifest files. */\n skipPathValidation?: boolean;\n } = {},\n): void {\n // IDs must be unique — two entries cannot target the same function\n const duplicateIds = manifest.functions\n .map(({ id }) => id)\n .filter((id, index, ids) => id !== undefined && ids.indexOf(id) !== index);\n if (duplicateIds.length > 0) {\n throw new Error(\n `Duplicate custom function ids in manifest: ${[...new Set(duplicateIds)].join(', ')}`,\n );\n }\n\n // Names may repeat only when every entry sharing the name carries an `id`\n // to disambiguate; an id-less entry syncs by name and would be ambiguous.\n const allNames = manifest.functions.map(({ name }) => name);\n const ambiguousNames = manifest.functions\n .filter(({ id, name }) => id === undefined && allNames.filter((n) => n === name).length > 1)\n .map(({ name }) => name);\n if (ambiguousNames.length > 0) {\n throw new Error(\n `Duplicate custom function names in manifest without ids: ${[...new Set(ambiguousNames)].join(', ')}. ` +\n 'Add an `id` field to each duplicated entry to disambiguate.',\n );\n }\n\n manifest.functions.forEach((entry) => {\n if (entry['test-payload'] !== undefined && entry['test-payloads'] !== undefined) {\n throw new Error(\n `Custom function \"${entry.name}\" sets both test-payload and test-payloads — ` +\n 'use test-payloads alone to define multiple payloads.',\n );\n }\n if (entry['test-payload-type'] !== undefined && entry['test-payload'] === undefined) {\n throw new Error(\n `Custom function \"${entry.name}\" sets test-payload-type without test-payload — ` +\n 'set payload-type per item in test-payloads instead.',\n );\n }\n if (\n entry.type !== CustomFunctionType.Dsr &&\n (entry['test-payload-type'] !== undefined ||\n entry['test-payloads']?.some(\n ({ ['payload-type']: payloadType }) => payloadType !== undefined,\n ))\n ) {\n throw new Error(\n `Custom function \"${entry.name}\" sets a DSR payload type but is not type DSR.`,\n );\n }\n\n const referencedPaths = [\n { field: 'code', path: entry.code },\n ...(entry['test-payload'] === undefined\n ? []\n : [{ field: 'test-payload', path: entry['test-payload'] }]),\n ...(entry['test-payloads'] ?? []).map(({ payload }, index) => ({\n field: `test-payloads[${index}].payload`,\n path: payload,\n })),\n ];\n referencedPaths.forEach(({ field, path }) => {\n if (!options.skipPathValidation && !isCustomFunctionManifestPathContained(path)) {\n throw new Error(\n `Custom function \"${entry.name}\" has a ${field} path outside the manifest directory: ${path}`,\n );\n }\n });\n });\n}\n\n/**\n * Parse and validate a custom functions manifest without resolving variables\n * or reading any referenced files.\n *\n * Unresolved `<<parameters.*>>` values remain plain strings in the returned\n * manifest.\n *\n * @param contents - Custom function manifest YAML\n * @param options - Validation behavior\n * @returns The parsed, shape-validated, and semantically valid manifest\n */\nexport function parseCustomFunctionsManifest(\n contents: string,\n options: {\n /** Skip path validation while identifying candidate manifest files. */\n skipPathValidation?: boolean;\n } = {},\n): CustomFunctionsManifest {\n const manifest = decodeCodec(CustomFunctionsManifest, yaml.load(contents));\n validateCustomFunctionsManifest(manifest, options);\n return manifest;\n}\n\n/**\n * A custom function config from the manifest, plus CLI-level settings that\n * are not part of the SDK sync input.\n */\nexport type CustomFunctionManifestConfig = CustomFunctionConfigInput & {\n /** Env variable name holding the internal key of the function's Sombra gateway */\n sombraAuthEnv?: string;\n /** Parsed JSON test payloads to run the function with before pushing */\n testPayloads?: {\n /** The parsed JSON payload */\n payload: object;\n /** Which export the payload invokes when test-running a DSR function */\n payloadType?: Exclude<CustomFunctionPayloadType, typeof CustomFunctionPayloadType.Maestro>;\n }[];\n};\n\n/**\n * Hydrate parsed manifest entries from their referenced files.\n *\n * @param filePath - Path to the manifest YAML file\n * @param manifest - Parsed manifest\n * @param assertPath - Optional safety check applied before referenced files are read\n * @returns Custom Function configs with code and payloads loaded\n */\nfunction hydrateCustomFunctionsManifest(\n filePath: string,\n manifest: CustomFunctionsManifest,\n assertPath?: (path: string) => void,\n): CustomFunctionManifestConfig[] {\n const manifestDir = dirname(resolve(filePath));\n\n /**\n * Load and parse a JSON test payload file.\n *\n * @param entryName - The manifest entry name, for error messages\n * @param payloadFile - The payload file path, relative to the manifest\n * @returns The parsed payload object\n */\n const loadTestPayload = (entryName: string, payloadFile: string): object => {\n const testPayloadPath = resolve(manifestDir, payloadFile);\n assertPath?.(testPayloadPath);\n if (!existsSync(testPayloadPath)) {\n throw new Error(\n `Test payload file for custom function \"${entryName}\" does not exist: ${testPayloadPath}`,\n );\n }\n const rawPayload = readFileSync(testPayloadPath, 'utf-8');\n try {\n return JSON.parse(rawPayload);\n } catch (err) {\n throw new Error(\n `Test payload file for custom function \"${entryName}\" is not valid JSON ` +\n `(${testPayloadPath}): ${(err as Error).message}`,\n );\n }\n };\n\n return manifest.functions.map((entry) => {\n validateCustomFunctionExecutionContext({\n ...(entry.env ? { env: entry.env } : {}),\n ...(entry['allowed-hosts'] ? { allowedHosts: entry['allowed-hosts'] } : {}),\n });\n const codePath = resolve(manifestDir, entry.code);\n assertPath?.(codePath);\n if (!existsSync(codePath)) {\n throw new Error(`Code file for custom function \"${entry.name}\" does not exist: ${codePath}`);\n }\n\n // `test-payload` is shorthand for a single-item `test-payloads` list\n let testPayloads: CustomFunctionManifestConfig['testPayloads'];\n if (entry['test-payload'] !== undefined) {\n testPayloads = [\n {\n payload: loadTestPayload(entry.name, entry['test-payload']),\n ...(entry['test-payload-type'] !== undefined\n ? { payloadType: entry['test-payload-type'] }\n : {}),\n },\n ];\n } else if (entry['test-payloads'] !== undefined && entry['test-payloads'].length > 0) {\n testPayloads = entry['test-payloads'].map((item) => ({\n payload: loadTestPayload(entry.name, item.payload),\n ...(item['payload-type'] !== undefined ? { payloadType: item['payload-type'] } : {}),\n }));\n }\n\n return {\n name: entry.name,\n code: readFileSync(codePath, 'utf-8'),\n ...(entry.id !== undefined ? { id: entry.id } : {}),\n ...(entry.description !== undefined ? { description: entry.description } : {}),\n ...(entry.type !== undefined ? { type: entry.type } : {}),\n ...(entry['data-silo-id'] !== undefined ? { dataSiloId: entry['data-silo-id'] } : {}),\n ...(entry['sombra-id'] !== undefined ? { sombraId: entry['sombra-id'] } : {}),\n ...(entry['sombra-auth-env'] !== undefined\n ? { sombraAuthEnv: entry['sombra-auth-env'] }\n : {}),\n ...(entry['allowed-hosts'] !== undefined ? { allowedHosts: entry['allowed-hosts'] } : {}),\n ...(entry['timeout-ms'] !== undefined ? { timeoutMs: entry['timeout-ms'] } : {}),\n ...(entry['allow-third-party-imports'] !== undefined\n ? { allowThirdPartyImports: entry['allow-third-party-imports'] }\n : {}),\n ...(entry.env !== undefined ? { env: entry.env } : {}),\n ...(testPayloads !== undefined ? { testPayloads } : {}),\n };\n });\n}\n\n/**\n * Read a custom functions manifest from disk, apply variable substitution,\n * validate it, and hydrate its referenced code and payload files.\n *\n * Variable substitution deliberately happens before parsing and hydration to\n * preserve push behavior.\n *\n * @param filePath - Path to the manifest YAML file\n * @param variables - Variables to fill into `<<parameters.x>>` placeholders\n * @param assertPath - Optional safety check applied before referenced files are read\n * @returns The custom function configs, with code loaded from disk\n */\nexport function readCustomFunctionsManifest(\n filePath: string,\n variables: ObjByString = {},\n assertPath?: (path: string) => void,\n): CustomFunctionManifestConfig[] {\n const fileContents = readFileSync(filePath, 'utf-8');\n const replacedVariables = replaceVariablesInYaml(\n fileContents,\n variables,\n `Also check that there are no extra variables defined in your manifest: ${filePath}`,\n );\n const manifest = parseCustomFunctionsManifest(replacedVariables);\n return hydrateCustomFunctionsManifest(filePath, manifest, assertPath);\n}\n\n/**\n * Resolve and hydrate one selected manifest entry.\n *\n * This lets local execution ignore unrelated entries whose files or\n * variables are currently incomplete.\n *\n * @param filePath - Path to the containing manifest\n * @param entry - Selected raw manifest entry\n * @param variables - Variables to fill into `<<parameters.x>>` placeholders\n * @param assertPath - Optional safety check applied before referenced files are read\n * @returns Hydrated selected configuration and its source path\n */\nexport function readCustomFunctionManifestEntry(\n filePath: string,\n entry: CustomFunctionManifestEntry,\n variables: ObjByString = {},\n assertPath?: (path: string) => void,\n): { config: CustomFunctionManifestConfig; sourcePath: string } {\n const entryContents = yaml.dump({ functions: [entry] });\n const replacedVariables = replaceVariablesInYaml(\n entryContents,\n variables,\n `Also check that there are no extra variables defined for \"${entry.name}\" in: ${filePath}`,\n );\n const manifest = parseCustomFunctionsManifest(replacedVariables);\n const resolvedEntry = manifest.functions[0]!;\n const manifestDirectory = dirname(resolve(filePath));\n const sourcePath = resolve(manifestDirectory, resolvedEntry.code);\n return {\n config: hydrateCustomFunctionsManifest(filePath, manifest, assertPath)[0]!,\n sourcePath,\n };\n}\n\n/**\n * Append an entry to a manifest YAML document while preserving the existing\n * document's comments, ordering, scalar styles, and unresolved placeholders.\n *\n * The complete result is parsed and validated with the same codec and\n * semantic rules used by {@link readCustomFunctionsManifest}.\n *\n * @param contents - Existing custom function manifest YAML\n * @param entry - Manifest entry to append\n * @returns Updated manifest YAML\n */\nexport function insertCustomFunctionManifestEntry(\n contents: string,\n entry: CustomFunctionManifestEntry,\n): string {\n const document = parseDocument(contents);\n if (document.errors.length > 0) {\n throw document.errors[0];\n }\n\n const functions = document.get('functions');\n if (!isSeq(functions)) {\n throw new Error('Expected a `functions` list in custom function manifest');\n }\n\n if (functions.items.length === 0) {\n functions.flow = false;\n }\n functions.add(document.createNode(entry));\n const updatedContents = document.toString();\n parseCustomFunctionsManifest(updatedContents);\n return updatedContents;\n}\n\n/**\n * The IDs assigned to a manifest entry during a push, to write back into the\n * manifest file.\n */\nexport interface CustomFunctionManifestIds {\n /** Custom function ID */\n id?: string;\n /** Data silo (DSR integration) ID, for DSR functions */\n dataSiloId?: string;\n}\n\n/**\n * Write custom function and data silo IDs back into a manifest file, so\n * future pushes match by ID instead of by (potentially non-unique) name and\n * DSR entries keep pointing at their integration.\n *\n * The raw file text is edited via a comment- and formatting-preserving YAML\n * document, so comments and un-substituted `<<parameters.x>>` placeholders\n * survive untouched. Only entries that are missing the respective key are\n * modified.\n *\n * @param filePath - Path to the manifest YAML file\n * @param idsByIndex - IDs for each manifest entry, by array index (undefined\n * entries are left unchanged)\n * @returns The number of entries that were updated\n */\nexport function writeCustomFunctionIdsToManifest(\n filePath: string,\n idsByIndex: (CustomFunctionManifestIds | undefined)[],\n): number {\n const document = parseDocument(readFileSync(filePath, 'utf-8'));\n const functions = document.get('functions');\n if (!isSeq(functions)) {\n throw new Error(`Expected a \\`functions\\` list in manifest: ${filePath}`);\n }\n\n let updated = 0;\n functions.items.forEach((item, index) => {\n const ids = idsByIndex[index];\n if (!ids || !isMap(item)) {\n return;\n }\n let changed = false;\n if (ids.id && !item.has('id')) {\n // Place `id` first so it reads as the entry's key\n item.items.unshift(document.createPair('id', ids.id));\n changed = true;\n }\n if (ids.dataSiloId && !item.has('data-silo-id')) {\n // Place `data-silo-id` right after `id` (or first when there is no id)\n const idIndex = item.items.findIndex((pair) => isScalar(pair.key) && pair.key.value === 'id');\n item.items.splice(idIndex + 1, 0, document.createPair('data-silo-id', ids.dataSiloId));\n changed = true;\n }\n if (changed) {\n updated += 1;\n }\n });\n\n if (updated > 0) {\n writeFileSync(filePath, document.toString());\n }\n return updated;\n}\n","import { extname, join, resolve } from 'node:path';\n\nimport type { LocalContext } from '../../context.js';\nimport {\n collectProjectRelativePaths,\n discoverProjectRepository,\n findExistingAncestor,\n findRepositoryRoot,\n} from '../scaffolding/project-discovery.js';\nimport { parseCustomFunctionsManifest } from './manifest.js';\nimport { DEFAULT_CUSTOM_FUNCTION_DIRECTORY, resolveCustomFunctionProjectPaths } from './paths.js';\nimport type { CustomFunctionProjectState } from './scaffold-model.js';\n\n/**\n * Find Custom Function manifests below the surrounding repository.\n *\n * @param context - CLI context\n * @param startDirectory - Existing directory from which to locate the repository\n * @returns Absolute manifest paths in stable order\n */\nexport function discoverCustomFunctionManifests(\n context: LocalContext,\n startDirectory: string,\n): string[] {\n const existingAncestor = findExistingAncestor(context, startDirectory);\n const root = findRepositoryRoot(context, existingAncestor) ?? existingAncestor;\n const manifests: string[] = [];\n const visit = (directory: string): void => {\n context.fs.readdirSync(directory, { withFileTypes: true }).forEach((entry) => {\n if (entry.name === '.git' || entry.name === '.worktrees' || entry.name === 'node_modules') {\n return;\n }\n const absolute = join(directory, entry.name);\n if (entry.isDirectory() && !entry.isSymbolicLink()) {\n visit(absolute);\n } else if (entry.isFile()) {\n if (entry.name === 'transcend-functions.yml') {\n manifests.push(absolute);\n return;\n }\n if (['.yml', '.yaml'].includes(extname(entry.name))) {\n try {\n if (context.fs.statSync(absolute).size > 256_000) {\n return;\n }\n parseCustomFunctionsManifest(context.fs.readFileSync(absolute, 'utf8'), {\n skipPathValidation: true,\n });\n manifests.push(absolute);\n } catch {\n // Most repository YAML files are not Custom Function manifests.\n }\n }\n }\n });\n };\n visit(root);\n return manifests.sort((left, right) => left.localeCompare(right));\n}\n\n/**\n * Collect all repository state required by the pure planners.\n *\n * @param context - CLI context\n * @param options - User-selected target paths\n * @returns Project state\n */\nexport function discoverCustomFunctionProject(\n context: LocalContext,\n options: {\n /** Optional positional directory. */\n directory?: string;\n /** Optional explicit manifest path. */\n manifest?: string;\n },\n): CustomFunctionProjectState {\n const cwd = context.process.cwd();\n const { manifestDirectory, manifestPath, targetDirectory } = resolveCustomFunctionProjectPaths(\n cwd,\n options,\n );\n const repository = discoverProjectRepository(context, {\n invocationDirectory: cwd,\n targetDirectory,\n standaloneProjectRoot:\n targetDirectory === resolve(cwd, DEFAULT_CUSTOM_FUNCTION_DIRECTORY) ? cwd : targetDirectory,\n });\n const denoJsonc = join(manifestDirectory, 'deno.jsonc');\n const denoJson = join(manifestDirectory, 'deno.json');\n const denoConfigPath = context.fs.existsSync(denoJsonc) ? denoJsonc : denoJson;\n\n return {\n invocationDirectory: cwd,\n targetDirectory,\n ...repository,\n manifestDirectory,\n manifestPath,\n denoConfigPath,\n relativePaths: collectProjectRelativePaths(context, manifestDirectory),\n };\n}\n"],"mappings":"grBAIA,MAAa,EAAsC,GAAK,KAElD,EAAqB,IAAI,IAAI,CACjC,YACA,WACA,oBACA,aACA,cACA,sBACA,WACA,WACA,sBACD,CAAC,CAQF,SAAS,EAAmB,EAAuB,CACjD,IAAM,EAAc,6BAA6B,KAAK,EAAK,CAC3D,GAAI,EAAa,CACf,IAAM,EAAO,EAAY,GACzB,OAAO,EAAK,EAAY,GAAI,GAAK,IAAM,CAAC,GA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,EAAM,EAC/E,CAAC,CACI,EAAY,EAAK,EAAmB,aAAa,CACjD,EAAW,EAAK,EAAmB,YAAY,CAC/C,EAAiB,EAAQ,GAAG,WAAW,EAAU,CAAG,EAAY,EAEtE,MAAO,CACL,oBAAqB,EACrB,kBACA,GAAG,EACH,oBACA,eACA,iBACA,cAAe,EAA4B,EAAS,EAAkB,CACvE"}
|
|
1
|
+
{"version":3,"file":"project-discovery-g29vd44a.mjs","names":[],"sources":["../src/lib/custom-functions/execution-context.ts","../src/lib/custom-functions/manifest.ts","../src/lib/custom-functions/project-discovery.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport { isIP } from 'node:net';\n\n/** Maximum environment value size supported by the local process. */\nexport const CUSTOM_FUNCTION_MAX_ENV_VALUE_BYTES = 64 * 1024;\n\nconst RESERVED_ENV_NAMES = new Set([\n 'DENO_CERT',\n 'DENO_DIR',\n 'DENO_TLS_CA_STORE',\n 'HTTP_PROXY',\n 'HTTPS_PROXY',\n 'NODE_EXTRA_CA_CERTS',\n 'NO_COLOR',\n 'NO_PROXY',\n 'NPM_CONFIG_REGISTRY',\n]);\n\n/**\n * Check whether a value matches Sombra's hostname/IP contract.\n *\n * @param host - Manifest allowed-host value\n * @returns Whether the host is valid\n */\nfunction isValidAllowedHost(host: string): boolean {\n const bracketedIp = /^\\[([^\\]]+)\\](?::(\\d+))?$/u.exec(host);\n if (bracketedIp) {\n const port = bracketedIp[2];\n return isIP(bracketedIp[1]!) === 6 && (!port || (Number(port) > 0 && Number(port) <= 65_535));\n }\n if (isIP(host) > 0) {\n return true;\n }\n const hostWithPort = /^([^:]+):(\\d+)$/u.exec(host);\n const hostname = hostWithPort?.[1] ?? host;\n const port = hostWithPort?.[2];\n return (\n (!port || (Number(port) > 0 && Number(port) <= 65_535)) &&\n hostname.length <= 253 &&\n hostname\n .split('.')\n .every(\n (label) =>\n label.length > 0 &&\n label.length <= 63 &&\n /^[A-Za-z\\d](?:[A-Za-z\\d-]*[A-Za-z\\d])?$/u.test(label),\n )\n );\n}\n\n/**\n * Validate execution settings shared by check, push, and local simulation.\n *\n * @param config - Environment and network settings\n */\nexport function validateCustomFunctionExecutionContext(config: {\n /** User-defined environment variables. */\n env?: Record<string, string>;\n /** Native network destinations. */\n allowedHosts?: string[];\n}): void {\n const environment = config.env ?? {};\n const envNames = Object.keys(environment);\n const malformedEnvNames = envNames.filter((name) => !/^[A-Za-z][A-Za-z\\d_]*$/u.test(name));\n const reservedEnvNames = envNames.filter(\n (name) => RESERVED_ENV_NAMES.has(name) || name.startsWith('DENO_'),\n );\n if (malformedEnvNames.length > 0 || reservedEnvNames.length > 0) {\n throw new Error(\n [\n malformedEnvNames.length > 0\n ? `Invalid environment variable names: ${malformedEnvNames.join(', ')}`\n : undefined,\n reservedEnvNames.length > 0\n ? `Reserved environment variable names: ${reservedEnvNames.join(', ')}`\n : undefined,\n ]\n .filter(Boolean)\n .join('. '),\n );\n }\n const oversizedEnvNames = envNames.filter(\n (name) => Buffer.byteLength(environment[name]!) > CUSTOM_FUNCTION_MAX_ENV_VALUE_BYTES,\n );\n if (oversizedEnvNames.length > 0) {\n throw new Error(\n `Environment values exceed ${CUSTOM_FUNCTION_MAX_ENV_VALUE_BYTES} bytes: ${oversizedEnvNames.join(', ')}`,\n );\n }\n const allowedHosts = config.allowedHosts ?? [];\n if (allowedHosts.length > 1 && allowedHosts.includes('*')) {\n throw new Error('allowed-hosts cannot combine \"*\" with specific hosts.');\n }\n const invalidHosts = allowedHosts.filter((host) => host !== '*' && !isValidAllowedHost(host));\n if (invalidHosts.length > 0) {\n throw new Error(`Invalid allowed-hosts: ${invalidHosts.join(', ')}`);\n }\n}\n","import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, isAbsolute, relative, resolve, sep } from 'node:path';\n\nimport { CustomFunctionPayloadType, CustomFunctionType } from '@transcend-io/privacy-types';\nimport type { CustomFunctionConfigInput } from '@transcend-io/sdk';\nimport { decodeCodec, type ObjByString } from '@transcend-io/type-utils';\nimport * as t from 'io-ts';\nimport yaml from 'js-yaml';\nimport { isMap, isScalar, isSeq, parseDocument } from 'yaml';\n\nimport { replaceVariablesInYaml } from '../readTranscendYaml.js';\nimport { validateCustomFunctionExecutionContext } from './execution-context.js';\n\nexport const CustomFunctionManifestEntry = t.intersection([\n t.type({\n /** Display name of the custom function — used as the sync key when no `id` is set */\n name: t.string,\n /** Path to the TypeScript source file, relative to the manifest */\n code: t.string,\n }),\n t.partial({\n /**\n * Custom function ID. Optional, but required to disambiguate when multiple\n * custom functions share a name. Written back by `push --updateManifest`.\n */\n id: t.string,\n /** Description shown in the Transcend dashboard */\n description: t.string,\n /** Custom function type. Defaults to GENERAL */\n type: t.union([t.literal(CustomFunctionType.Dsr), t.literal(CustomFunctionType.General)]),\n /** Data silo ID to attach to (required for DSR functions) */\n 'data-silo-id': t.string,\n /** The Sombra gateway the function belongs to */\n 'sombra-id': t.string,\n /**\n * Name of the environment variable holding the internal key of the\n * function's Sombra gateway. The key itself never lives in the manifest —\n * it is read from the CLI's process environment at push time. Overrides\n * `--sombraAuth` for this entry.\n */\n 'sombra-auth-env': t.string,\n /** Hosts the function may make network requests to */\n 'allowed-hosts': t.array(t.string),\n /** Execution timeout in milliseconds */\n 'timeout-ms': t.number,\n /** Whether the function may import third party modules */\n 'allow-third-party-imports': t.boolean,\n /** Environment variables to expose to the function */\n env: t.record(t.string, t.string),\n /**\n * Path to a JSON file (relative to the manifest) holding the test payload\n * to run the function with before pushing. When set, the function is\n * test-run after signing and only pushed/promoted when the test passes.\n * Shorthand for a single-item `test-payloads` list.\n */\n 'test-payload': t.string,\n /**\n * Which export to invoke when test-running a DSR function:\n * `DATA_POINT` invokes the default export, `REQUEST_ENRICHER` invokes the\n * `enricher` export. Defaults to DATA_POINT. Ignored for GENERAL functions.\n * Only valid alongside `test-payload`.\n */\n 'test-payload-type': t.union([\n t.literal(CustomFunctionPayloadType.DataPoint),\n t.literal(CustomFunctionPayloadType.RequestEnricher),\n ]),\n /**\n * Test payloads to run the function with before pushing. Every payload\n * runs and all must pass for the function to be pushed/promoted. DSR\n * functions should list one payload per export they implement\n * (`DATA_POINT` for the default export, `REQUEST_ENRICHER` for the\n * `enricher` export). Mutually exclusive with `test-payload`.\n */\n 'test-payloads': t.array(\n t.intersection([\n t.type({\n /** Path to the JSON payload file, relative to the manifest */\n payload: t.string,\n }),\n t.partial({\n /** Which export the payload invokes (DSR only). Defaults to DATA_POINT */\n 'payload-type': t.union([\n t.literal(CustomFunctionPayloadType.DataPoint),\n t.literal(CustomFunctionPayloadType.RequestEnricher),\n ]),\n }),\n ]),\n ),\n }),\n]);\n\n/** Override type */\nexport type CustomFunctionManifestEntry = t.TypeOf<typeof CustomFunctionManifestEntry>;\n\nexport const CustomFunctionsManifest = t.type({\n /** The custom functions to sync */\n functions: t.array(CustomFunctionManifestEntry),\n});\n\n/** Override type */\nexport type CustomFunctionsManifest = t.TypeOf<typeof CustomFunctionsManifest>;\n\n/**\n * Determine whether a relative manifest path stays inside the manifest's\n * directory after normalization.\n *\n * @param filePath - Path from a custom function manifest entry\n * @returns Whether the normalized path is contained by the manifest directory\n */\nexport function isCustomFunctionManifestPathContained(filePath: string): boolean {\n const manifestDirectory = resolve('/', '__custom-function-manifest__');\n const relativePath = relative(manifestDirectory, resolve(manifestDirectory, filePath));\n return relativePath !== '..' && !relativePath.startsWith(`..${sep}`) && !isAbsolute(relativePath);\n}\n\n/**\n * Validate semantic constraints shared by manifest readers and editors.\n *\n * @param manifest - Shape-validated custom function manifest\n * @param options - Validation behavior\n */\nexport function validateCustomFunctionsManifest(\n manifest: CustomFunctionsManifest,\n options: {\n /** Skip path validation while identifying candidate manifest files. */\n skipPathValidation?: boolean;\n } = {},\n): void {\n // IDs must be unique — two entries cannot target the same function\n const duplicateIds = manifest.functions\n .map(({ id }) => id)\n .filter((id, index, ids) => id !== undefined && ids.indexOf(id) !== index);\n if (duplicateIds.length > 0) {\n throw new Error(\n `Duplicate custom function ids in manifest: ${[...new Set(duplicateIds)].join(', ')}`,\n );\n }\n\n // Names may repeat only when every entry sharing the name carries an `id`\n // to disambiguate; an id-less entry syncs by name and would be ambiguous.\n const allNames = manifest.functions.map(({ name }) => name);\n const ambiguousNames = manifest.functions\n .filter(({ id, name }) => id === undefined && allNames.filter((n) => n === name).length > 1)\n .map(({ name }) => name);\n if (ambiguousNames.length > 0) {\n throw new Error(\n `Duplicate custom function names in manifest without ids: ${[...new Set(ambiguousNames)].join(', ')}. ` +\n 'Add an `id` field to each duplicated entry to disambiguate.',\n );\n }\n\n manifest.functions.forEach((entry) => {\n if (entry['test-payload'] !== undefined && entry['test-payloads'] !== undefined) {\n throw new Error(\n `Custom function \"${entry.name}\" sets both test-payload and test-payloads — ` +\n 'use test-payloads alone to define multiple payloads.',\n );\n }\n if (entry['test-payload-type'] !== undefined && entry['test-payload'] === undefined) {\n throw new Error(\n `Custom function \"${entry.name}\" sets test-payload-type without test-payload — ` +\n 'set payload-type per item in test-payloads instead.',\n );\n }\n if (\n entry.type !== CustomFunctionType.Dsr &&\n (entry['test-payload-type'] !== undefined ||\n entry['test-payloads']?.some(\n ({ ['payload-type']: payloadType }) => payloadType !== undefined,\n ))\n ) {\n throw new Error(\n `Custom function \"${entry.name}\" sets a DSR payload type but is not type DSR.`,\n );\n }\n\n const referencedPaths = [\n { field: 'code', path: entry.code },\n ...(entry['test-payload'] === undefined\n ? []\n : [{ field: 'test-payload', path: entry['test-payload'] }]),\n ...(entry['test-payloads'] ?? []).map(({ payload }, index) => ({\n field: `test-payloads[${index}].payload`,\n path: payload,\n })),\n ];\n referencedPaths.forEach(({ field, path }) => {\n if (!options.skipPathValidation && !isCustomFunctionManifestPathContained(path)) {\n throw new Error(\n `Custom function \"${entry.name}\" has a ${field} path outside the manifest directory: ${path}`,\n );\n }\n });\n });\n}\n\n/**\n * Parse and validate a custom functions manifest without resolving variables\n * or reading any referenced files.\n *\n * Unresolved `<<parameters.*>>` values remain plain strings in the returned\n * manifest.\n *\n * @param contents - Custom function manifest YAML\n * @param options - Validation behavior\n * @returns The parsed, shape-validated, and semantically valid manifest\n */\nexport function parseCustomFunctionsManifest(\n contents: string,\n options: {\n /** Skip path validation while identifying candidate manifest files. */\n skipPathValidation?: boolean;\n } = {},\n): CustomFunctionsManifest {\n const manifest = decodeCodec(CustomFunctionsManifest, yaml.load(contents));\n validateCustomFunctionsManifest(manifest, options);\n return manifest;\n}\n\n/**\n * A custom function config from the manifest, plus CLI-level settings that\n * are not part of the SDK sync input.\n */\nexport type CustomFunctionManifestConfig = CustomFunctionConfigInput & {\n /** Env variable name holding the internal key of the function's Sombra gateway */\n sombraAuthEnv?: string;\n /** Parsed JSON test payloads to run the function with before pushing */\n testPayloads?: {\n /** The parsed JSON payload */\n payload: object;\n /** Which export the payload invokes when test-running a DSR function */\n payloadType?: Exclude<CustomFunctionPayloadType, typeof CustomFunctionPayloadType.Maestro>;\n }[];\n};\n\n/**\n * Hydrate parsed manifest entries from their referenced files.\n *\n * @param filePath - Path to the manifest YAML file\n * @param manifest - Parsed manifest\n * @param assertPath - Optional safety check applied before referenced files are read\n * @returns Custom Function configs with code and payloads loaded\n */\nfunction hydrateCustomFunctionsManifest(\n filePath: string,\n manifest: CustomFunctionsManifest,\n assertPath?: (path: string) => void,\n): CustomFunctionManifestConfig[] {\n const manifestDir = dirname(resolve(filePath));\n\n /**\n * Load and parse a JSON test payload file.\n *\n * @param entryName - The manifest entry name, for error messages\n * @param payloadFile - The payload file path, relative to the manifest\n * @returns The parsed payload object\n */\n const loadTestPayload = (entryName: string, payloadFile: string): object => {\n const testPayloadPath = resolve(manifestDir, payloadFile);\n assertPath?.(testPayloadPath);\n if (!existsSync(testPayloadPath)) {\n throw new Error(\n `Test payload file for custom function \"${entryName}\" does not exist: ${testPayloadPath}`,\n );\n }\n const rawPayload = readFileSync(testPayloadPath, 'utf-8');\n try {\n return JSON.parse(rawPayload);\n } catch (err) {\n throw new Error(\n `Test payload file for custom function \"${entryName}\" is not valid JSON ` +\n `(${testPayloadPath}): ${(err as Error).message}`,\n );\n }\n };\n\n return manifest.functions.map((entry) => {\n validateCustomFunctionExecutionContext({\n ...(entry.env ? { env: entry.env } : {}),\n ...(entry['allowed-hosts'] ? { allowedHosts: entry['allowed-hosts'] } : {}),\n });\n const codePath = resolve(manifestDir, entry.code);\n assertPath?.(codePath);\n if (!existsSync(codePath)) {\n throw new Error(`Code file for custom function \"${entry.name}\" does not exist: ${codePath}`);\n }\n\n // `test-payload` is shorthand for a single-item `test-payloads` list\n let testPayloads: CustomFunctionManifestConfig['testPayloads'];\n if (entry['test-payload'] !== undefined) {\n testPayloads = [\n {\n payload: loadTestPayload(entry.name, entry['test-payload']),\n ...(entry['test-payload-type'] !== undefined\n ? { payloadType: entry['test-payload-type'] }\n : {}),\n },\n ];\n } else if (entry['test-payloads'] !== undefined && entry['test-payloads'].length > 0) {\n testPayloads = entry['test-payloads'].map((item) => ({\n payload: loadTestPayload(entry.name, item.payload),\n ...(item['payload-type'] !== undefined ? { payloadType: item['payload-type'] } : {}),\n }));\n }\n\n return {\n name: entry.name,\n code: readFileSync(codePath, 'utf-8'),\n ...(entry.id !== undefined ? { id: entry.id } : {}),\n ...(entry.description !== undefined ? { description: entry.description } : {}),\n ...(entry.type !== undefined ? { type: entry.type } : {}),\n ...(entry['data-silo-id'] !== undefined ? { dataSiloId: entry['data-silo-id'] } : {}),\n ...(entry['sombra-id'] !== undefined ? { sombraId: entry['sombra-id'] } : {}),\n ...(entry['sombra-auth-env'] !== undefined\n ? { sombraAuthEnv: entry['sombra-auth-env'] }\n : {}),\n ...(entry['allowed-hosts'] !== undefined ? { allowedHosts: entry['allowed-hosts'] } : {}),\n ...(entry['timeout-ms'] !== undefined ? { timeoutMs: entry['timeout-ms'] } : {}),\n ...(entry['allow-third-party-imports'] !== undefined\n ? { allowThirdPartyImports: entry['allow-third-party-imports'] }\n : {}),\n ...(entry.env !== undefined ? { env: entry.env } : {}),\n ...(testPayloads !== undefined ? { testPayloads } : {}),\n };\n });\n}\n\n/**\n * Read a custom functions manifest from disk, apply variable substitution,\n * validate it, and hydrate its referenced code and payload files.\n *\n * Variable substitution deliberately happens before parsing and hydration to\n * preserve push behavior.\n *\n * @param filePath - Path to the manifest YAML file\n * @param variables - Variables to fill into `<<parameters.x>>` placeholders\n * @param assertPath - Optional safety check applied before referenced files are read\n * @returns The custom function configs, with code loaded from disk\n */\nexport function readCustomFunctionsManifest(\n filePath: string,\n variables: ObjByString = {},\n assertPath?: (path: string) => void,\n): CustomFunctionManifestConfig[] {\n const fileContents = readFileSync(filePath, 'utf-8');\n const replacedVariables = replaceVariablesInYaml(\n fileContents,\n variables,\n `Also check that there are no extra variables defined in your manifest: ${filePath}`,\n );\n const manifest = parseCustomFunctionsManifest(replacedVariables);\n return hydrateCustomFunctionsManifest(filePath, manifest, assertPath);\n}\n\n/**\n * Resolve and hydrate one selected manifest entry.\n *\n * This lets local execution ignore unrelated entries whose files or\n * variables are currently incomplete.\n *\n * @param filePath - Path to the containing manifest\n * @param entry - Selected raw manifest entry\n * @param variables - Variables to fill into `<<parameters.x>>` placeholders\n * @param assertPath - Optional safety check applied before referenced files are read\n * @returns Hydrated selected configuration and its source path\n */\nexport function readCustomFunctionManifestEntry(\n filePath: string,\n entry: CustomFunctionManifestEntry,\n variables: ObjByString = {},\n assertPath?: (path: string) => void,\n): { config: CustomFunctionManifestConfig; sourcePath: string } {\n const entryContents = yaml.dump({ functions: [entry] });\n const replacedVariables = replaceVariablesInYaml(\n entryContents,\n variables,\n `Also check that there are no extra variables defined for \"${entry.name}\" in: ${filePath}`,\n );\n const manifest = parseCustomFunctionsManifest(replacedVariables);\n const resolvedEntry = manifest.functions[0]!;\n const manifestDirectory = dirname(resolve(filePath));\n const sourcePath = resolve(manifestDirectory, resolvedEntry.code);\n return {\n config: hydrateCustomFunctionsManifest(filePath, manifest, assertPath)[0]!,\n sourcePath,\n };\n}\n\n/**\n * Append an entry to a manifest YAML document while preserving the existing\n * document's comments, ordering, scalar styles, and unresolved placeholders.\n *\n * The complete result is parsed and validated with the same codec and\n * semantic rules used by {@link readCustomFunctionsManifest}.\n *\n * @param contents - Existing custom function manifest YAML\n * @param entry - Manifest entry to append\n * @returns Updated manifest YAML\n */\nexport function insertCustomFunctionManifestEntry(\n contents: string,\n entry: CustomFunctionManifestEntry,\n): string {\n const document = parseDocument(contents);\n if (document.errors.length > 0) {\n throw document.errors[0];\n }\n\n const functions = document.get('functions');\n if (!isSeq(functions)) {\n throw new Error('Expected a `functions` list in custom function manifest');\n }\n\n if (functions.items.length === 0) {\n functions.flow = false;\n }\n functions.add(document.createNode(entry));\n const updatedContents = document.toString();\n parseCustomFunctionsManifest(updatedContents);\n return updatedContents;\n}\n\n/**\n * The IDs assigned to a manifest entry during a push, to write back into the\n * manifest file.\n */\nexport interface CustomFunctionManifestIds {\n /** Custom function ID */\n id?: string;\n /** Data silo (DSR integration) ID, for DSR functions */\n dataSiloId?: string;\n}\n\n/**\n * Write custom function and data silo IDs back into a manifest file, so\n * future pushes match by ID instead of by (potentially non-unique) name and\n * DSR entries keep pointing at their integration.\n *\n * The raw file text is edited via a comment- and formatting-preserving YAML\n * document, so comments and un-substituted `<<parameters.x>>` placeholders\n * survive untouched. Only entries that are missing the respective key are\n * modified.\n *\n * @param filePath - Path to the manifest YAML file\n * @param idsByIndex - IDs for each manifest entry, by array index (undefined\n * entries are left unchanged)\n * @returns The number of entries that were updated\n */\nexport function writeCustomFunctionIdsToManifest(\n filePath: string,\n idsByIndex: (CustomFunctionManifestIds | undefined)[],\n): number {\n const document = parseDocument(readFileSync(filePath, 'utf-8'));\n const functions = document.get('functions');\n if (!isSeq(functions)) {\n throw new Error(`Expected a \\`functions\\` list in manifest: ${filePath}`);\n }\n\n let updated = 0;\n functions.items.forEach((item, index) => {\n const ids = idsByIndex[index];\n if (!ids || !isMap(item)) {\n return;\n }\n let changed = false;\n if (ids.id && !item.has('id')) {\n // Place `id` first so it reads as the entry's key\n item.items.unshift(document.createPair('id', ids.id));\n changed = true;\n }\n if (ids.dataSiloId && !item.has('data-silo-id')) {\n // Place `data-silo-id` right after `id` (or first when there is no id)\n const idIndex = item.items.findIndex((pair) => isScalar(pair.key) && pair.key.value === 'id');\n item.items.splice(idIndex + 1, 0, document.createPair('data-silo-id', ids.dataSiloId));\n changed = true;\n }\n if (changed) {\n updated += 1;\n }\n });\n\n if (updated > 0) {\n writeFileSync(filePath, document.toString());\n }\n return updated;\n}\n","import { extname, join, resolve } from 'node:path';\n\nimport type { LocalContext } from '../../context.js';\nimport {\n collectProjectRelativePaths,\n discoverProjectRepository,\n findExistingAncestor,\n findRepositoryRoot,\n} from '../scaffolding/project-discovery.js';\nimport { parseCustomFunctionsManifest } from './manifest.js';\nimport { DEFAULT_CUSTOM_FUNCTION_DIRECTORY, resolveCustomFunctionProjectPaths } from './paths.js';\nimport type { CustomFunctionProjectState } from './scaffold-model.js';\n\n/**\n * Find Custom Function manifests below the surrounding repository.\n *\n * @param context - CLI context\n * @param startDirectory - Existing directory from which to locate the repository\n * @returns Absolute manifest paths in stable order\n */\nexport function discoverCustomFunctionManifests(\n context: LocalContext,\n startDirectory: string,\n): string[] {\n const existingAncestor = findExistingAncestor(context, startDirectory);\n const root = findRepositoryRoot(context, existingAncestor) ?? existingAncestor;\n const manifests: string[] = [];\n const visit = (directory: string): void => {\n context.fs.readdirSync(directory, { withFileTypes: true }).forEach((entry) => {\n if (entry.name === '.git' || entry.name === '.worktrees' || entry.name === 'node_modules') {\n return;\n }\n const absolute = join(directory, entry.name);\n if (entry.isDirectory() && !entry.isSymbolicLink()) {\n visit(absolute);\n } else if (entry.isFile()) {\n if (entry.name === 'transcend-functions.yml') {\n manifests.push(absolute);\n return;\n }\n if (['.yml', '.yaml'].includes(extname(entry.name))) {\n try {\n if (context.fs.statSync(absolute).size > 256_000) {\n return;\n }\n parseCustomFunctionsManifest(context.fs.readFileSync(absolute, 'utf8'), {\n skipPathValidation: true,\n });\n manifests.push(absolute);\n } catch {\n // Most repository YAML files are not Custom Function manifests.\n }\n }\n }\n });\n };\n visit(root);\n return manifests.sort((left, right) => left.localeCompare(right));\n}\n\n/**\n * Collect all repository state required by the pure planners.\n *\n * @param context - CLI context\n * @param options - User-selected target paths\n * @returns Project state\n */\nexport function discoverCustomFunctionProject(\n context: LocalContext,\n options: {\n /** Optional positional directory. */\n directory?: string;\n /** Optional explicit manifest path. */\n manifest?: string;\n },\n): CustomFunctionProjectState {\n const cwd = context.process.cwd();\n const { manifestDirectory, manifestPath, targetDirectory } = resolveCustomFunctionProjectPaths(\n cwd,\n options,\n );\n const repository = discoverProjectRepository(context, {\n invocationDirectory: cwd,\n targetDirectory,\n standaloneProjectRoot:\n targetDirectory === resolve(cwd, DEFAULT_CUSTOM_FUNCTION_DIRECTORY) ? cwd : targetDirectory,\n });\n const denoJsonc = join(manifestDirectory, 'deno.jsonc');\n const denoJson = join(manifestDirectory, 'deno.json');\n const denoConfigPath = context.fs.existsSync(denoJsonc) ? denoJsonc : denoJson;\n\n return {\n invocationDirectory: cwd,\n targetDirectory,\n ...repository,\n manifestDirectory,\n manifestPath,\n denoConfigPath,\n relativePaths: collectProjectRelativePaths(context, manifestDirectory),\n };\n}\n"],"mappings":"grBAIA,MAAa,EAAsC,GAAK,KAElD,EAAqB,IAAI,IAAI,CACjC,YACA,WACA,oBACA,aACA,cACA,sBACA,WACA,WACA,sBACD,CAAC,CAQF,SAAS,EAAmB,EAAuB,CACjD,IAAM,EAAc,6BAA6B,KAAK,EAAK,CAC3D,GAAI,EAAa,CACf,IAAM,EAAO,EAAY,GACzB,OAAO,EAAK,EAAY,GAAI,GAAK,IAAM,CAAC,GAAS,OAAO,EAAK,CAAG,GAAK,OAAO,EAAK,EAAI,OAEvF,GAAI,EAAK,EAAK,CAAG,EACf,MAAO,GAET,IAAM,EAAe,mBAAmB,KAAK,EAAK,CAC5C,EAAW,IAAe,IAAM,EAChC,EAAO,IAAe,GAC5B,OACG,CAAC,GAAS,OAAO,EAAK,CAAG,GAAK,OAAO,EAAK,EAAI,QAC/C,E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-1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./constants-
|
|
2
|
-
//# sourceMappingURL=pullChunkedCustomSiloOutstandingIdentifiers-
|
|
1
|
+
import{a as e}from"./constants-I694qbRg.mjs";import{t}from"./logger-CPu6zbyQ.mjs";import n from"colors";import{mapSeries as r}from"@transcend-io/utils";import{decodeCodec as i}from"@transcend-io/type-utils";import*as a from"io-ts";import{REDUCED_REQUESTS_FOR_DATA_SILO_COUNT as o,buildTranscendGraphQLClient as s,createSombraGotInstance as c,makeGraphQLRequest as l,withTransientRetry as u}from"@transcend-io/sdk";import d from"cli-progress";async function f(e,{dataSiloId:n}){let{listReducedRequestsForDataSilo:{totalCount:r}}=await l(e,o,{variables:{input:{dataSiloId:n,isResolved:!1}},logger:t});return r}const p=a.type({id:a.string,name:a.string,partition:a.string}),m=a.intersection([a.type({identifier:a.string,type:a.string,coreIdentifier:a.string,dataSiloId:a.string,requestId:a.string,nonce:a.string,requestCreatedAt:a.string,daysUntilOverdue:a.number,attributes:a.array(a.type({key:a.string,values:a.array(a.string)}))}),a.partial({partition:a.union([p,a.null])})]);async function h(e,{dataSiloId:n,limit:r=100,offset:o=0,requestType:s}){try{let c=await u(`pullCronPageOfIdentifiers`,()=>e.get(`v1/data-silo/${n}/pending-requests/${s}`,{searchParams:{offset:o,limit:r}}).json(),{logger:t,maxAttempts:6,baseDelayMs:500}),{items:l}=i(a.type({items:a.array(m)}),c);return l}catch(e){throw Error(`Received an error from server: ${e?.response?.body||e?.message}`)}}async function g({dataSiloId:i,auth:a,sombraAuth:o,actions:l,apiPageSize:u=100,savePageSize:p=1e3,onSave:m,transcendUrl:g=e,skipRequestCount:_=!1}){if(p%u!==0)throw Error(`savePageSize must be a multiple of apiPageSize. savePageSize: ${p}, apiPageSize: ${u}`);let v=await c(g,a,{logger:t,sombraApiKey:o,sombraUrl:process.env.SOMBRA_URL}),y=s(g,a),b=0;_||(b=await f(y,{dataSiloId:i})),t.info(n.magenta(`Pulling ${_?`all`:b} outstanding request identifiers for data silo: "${i}" for requests of types "${l.join(`", "`)}"`));let x=new Date().getTime(),S=new d.SingleBar({},d.Presets.shades_classic),C=new Set,w=[],T=[];_||S.start(b,0),await r(l,async e=>{let r=0,a=!0;for(;a;){let o=await h(v,{dataSiloId:i,limit:u,offset:r,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===u,r+=u,_?t.info(n.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(n.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-ekuEZlzq.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullChunkedCustomSiloOutstandingIdentifiers-DbybCU2T.mjs","names":[],"sources":["../src/lib/graphql/fetchRequestDataSiloActiveCount.ts","../src/lib/cron/pullCronPageOfIdentifiers.ts","../src/lib/cron/pullChunkedCustomSiloOutstandingIdentifiers.ts"],"sourcesContent":["import { makeGraphQLRequest, REDUCED_REQUESTS_FOR_DATA_SILO_COUNT } from '@transcend-io/sdk';\nimport { GraphQLClient } from 'graphql-request';\n\nimport { logger } from '../../logger.js';\n\n/**\n * Get number of open requests for a data silo\n *\n * @param client - GraphQL client\n * @param options - Filter options\n * @returns List of request identifiers\n */\nexport async function fetchRequestDataSiloActiveCount(\n client: GraphQLClient,\n {\n dataSiloId,\n }: {\n /** Data silo ID */\n dataSiloId: string;\n },\n): Promise<number> {\n const {\n listReducedRequestsForDataSilo: { totalCount },\n } = await makeGraphQLRequest<{\n /** Requests */\n listReducedRequestsForDataSilo: {\n /** Total count */\n totalCount: number;\n };\n }>(client, REDUCED_REQUESTS_FOR_DATA_SILO_COUNT, {\n variables: {\n input: {\n dataSiloId,\n isResolved: false,\n },\n },\n logger,\n });\n\n return totalCount;\n}\n","import { RequestAction } from '@transcend-io/privacy-types';\nimport { withTransientRetry } from '@transcend-io/sdk';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport type { Got } from 'got';\nimport * as t from 'io-ts';\n\nimport { logger } from '../../logger.js';\n\n/** Consent partition metadata when a DSR is scoped to a partition */\nexport const CronPartition = t.type({\n /** ID of the partition */\n id: t.string,\n /** The human readable name of the partition */\n name: t.string,\n /** The unique identifying partition value */\n partition: t.string,\n});\n\n/** Type override */\nexport type CronPartition = t.TypeOf<typeof CronPartition>;\n\nexport const CronIdentifier = t.intersection([\n t.type({\n /** The identifier value */\n identifier: t.string,\n /** The type of identifier */\n type: t.string,\n /** The core identifier of the request */\n coreIdentifier: t.string,\n /** The ID of the underlying data silo */\n dataSiloId: t.string,\n /** The ID of the underlying request */\n requestId: t.string,\n /** The request nonce */\n nonce: t.string,\n /** The time the request was created */\n requestCreatedAt: t.string,\n /** The number of days until the request is overdue */\n daysUntilOverdue: t.number,\n /** Request attributes */\n attributes: t.array(\n t.type({\n key: t.string,\n values: t.array(t.string),\n }),\n ),\n }),\n t.partial({\n /** The consent partition that scopes this request, when applicable */\n partition: t.union([CronPartition, t.null]),\n }),\n]);\n\n/** Type override */\nexport type CronIdentifier = t.TypeOf<typeof CronIdentifier>;\n\n/**\n * Pull a offset of identifiers for a cron job\n *\n * @see https://docs.transcend.io/docs/api-reference/GET/v1/data-silo/(id)/pending-requests/(type)\n * @param sombra - Sombra instance configured to make requests\n * @param options - Additional options\n * @returns Successfully submitted request\n */\nexport async function pullCronPageOfIdentifiers(\n sombra: Got,\n {\n dataSiloId,\n limit = 100,\n offset = 0,\n requestType,\n }: {\n /** Data Silo ID */\n dataSiloId: string;\n /** Type of request */\n requestType: RequestAction;\n /** Number of identifiers to pull in */\n limit?: number;\n /** Page to pull in */\n offset?: number;\n },\n): Promise<CronIdentifier[]> {\n try {\n // `GET pending-requests` is a read and therefore safe to retry on transient\n // gateway / network errors. Customers running `transcend cron\n // pull-identifiers` against large silos would otherwise see the command\n // abort on a single 502 from the Sombra reverse tunnel.\n const response = await withTransientRetry(\n 'pullCronPageOfIdentifiers',\n () =>\n sombra\n .get(`v1/data-silo/${dataSiloId}/pending-requests/${requestType}`, {\n searchParams: {\n offset,\n limit,\n },\n })\n .json(),\n { logger, maxAttempts: 6, baseDelayMs: 500 },\n );\n\n const { items } = decodeCodec(\n t.type({\n items: t.array(CronIdentifier),\n }),\n response,\n );\n return items;\n } catch (err) {\n throw new Error(`Received an error from server: ${err?.response?.body || err?.message}`);\n }\n}\n","import { RequestAction } from '@transcend-io/privacy-types';\nimport { buildTranscendGraphQLClient, createSombraGotInstance } from '@transcend-io/sdk';\nimport { mapSeries } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { fetchRequestDataSiloActiveCount } from '../graphql/index.js';\nimport { pullCronPageOfIdentifiers, CronIdentifier } from './pullCronPageOfIdentifiers.js';\n\n/**\n * A CSV formatted identifier\n */\nexport type CsvFormattedIdentifier = {\n [k in string]: string | null | boolean | number;\n};\n\nexport interface CronIdentifierWithAction extends CronIdentifier {\n /** The request action that the identifier relates to */\n action: RequestAction;\n}\n\n/**\n * Pull the set of identifiers outstanding for a cron or AVC integration\n *\n * This function is designed to be used in a loop, and will call the onSave callback\n * with a chunk of identifiers when the savePageSize is reached.\n *\n * @param options - Options\n * @returns The identifiers and identifiers formatted for CSV\n */\nexport async function pullChunkedCustomSiloOutstandingIdentifiers({\n dataSiloId,\n auth,\n sombraAuth,\n actions,\n apiPageSize = 100,\n savePageSize = 1000,\n onSave,\n transcendUrl = DEFAULT_TRANSCEND_API,\n skipRequestCount = false,\n}: {\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** The request actions to fetch */\n actions: RequestAction[];\n /** How many identifiers to pull in a single call to the backend */\n apiPageSize: number;\n /** How many identifiers to save at a time (usually to a CSV file, should be a multiple of apiPageSize) */\n savePageSize: number;\n /** Callback function called when a chunk of identifiers is ready to be saved */\n onSave: (chunk: CsvFormattedIdentifier[]) => Promise<void>;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Skip request count */\n skipRequestCount?: boolean;\n}): Promise<{\n /** Raw Identifiers */\n identifiers: CronIdentifierWithAction[];\n}> {\n // Validate savePageSize\n if (savePageSize % apiPageSize !== 0) {\n throw new Error(\n `savePageSize must be a multiple of apiPageSize. savePageSize: ${savePageSize}, apiPageSize: ${apiPageSize}`,\n );\n }\n\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n // Create GraphQL client to connect to Transcend backend\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n let totalRequestCount = 0;\n if (!skipRequestCount) {\n totalRequestCount = await fetchRequestDataSiloActiveCount(client, {\n dataSiloId,\n });\n }\n\n logger.info(\n colors.magenta(\n `Pulling ${skipRequestCount ? 'all' : totalRequestCount} outstanding request identifiers ` +\n `for data silo: \"${dataSiloId}\" for requests of types \"${actions.join('\", \"')}\"`,\n ),\n );\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n const foundRequestIds = new Set<string>();\n\n // identifiers found in total\n const identifiers: CronIdentifierWithAction[] = [];\n // current chunk of identifiers to be saved\n let currentChunk: CsvFormattedIdentifier[] = [];\n\n // map over each action\n if (!skipRequestCount) {\n progressBar.start(totalRequestCount, 0);\n }\n await mapSeries(actions, async (action) => {\n let offset = 0;\n let shouldContinue = true;\n\n // Fetch a page of identifiers\n while (shouldContinue) {\n const pageIdentifiers = await pullCronPageOfIdentifiers(sombra, {\n dataSiloId,\n limit: apiPageSize,\n offset,\n requestType: action,\n });\n\n const identifiersWithAction: CronIdentifierWithAction[] = pageIdentifiers.map(\n (identifier) => {\n foundRequestIds.add(identifier.requestId);\n return {\n ...identifier,\n action,\n };\n },\n );\n\n const csvFormattedIdentifiers = identifiersWithAction.map(\n ({ attributes, partition, ...identifier }) => ({\n ...identifier,\n ...(partition\n ? {\n partitionId: partition.id,\n partitionName: partition.name,\n partitionKey: partition.partition,\n }\n : {}),\n ...attributes.reduce(\n (acc, val) =>\n Object.assign(acc, {\n [val.key]: val.values.join(','),\n }),\n {},\n ),\n }),\n );\n\n identifiers.push(...identifiersWithAction);\n currentChunk.push(...csvFormattedIdentifiers);\n\n // Check if we've reached the savePageSize and call the onSave callback\n if (currentChunk.length >= savePageSize) {\n await onSave(currentChunk);\n currentChunk = [];\n }\n\n shouldContinue = pageIdentifiers.length === apiPageSize;\n offset += apiPageSize;\n if (!skipRequestCount) {\n progressBar.update(foundRequestIds.size);\n } else {\n logger.info(\n colors.magenta(\n `Pulled ${pageIdentifiers.length} outstanding identifiers for ${foundRequestIds.size} requests`,\n ),\n );\n }\n }\n });\n\n // Save any remaining identifiers in the current chunk\n if (currentChunk.length > 0) {\n await onSave(currentChunk);\n }\n\n if (!skipRequestCount) {\n progressBar.stop();\n }\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully pulled ${identifiers.length} outstanding identifiers from ${\n foundRequestIds.size\n } requests in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n\n return { identifiers };\n}\n"],"mappings":"0bAYA,eAAsB,EACpB,EACA,CACE,cAKe,CACjB,GAAM,CACJ,+BAAgC,CAAE,eAChC,MAAM,EAMP,E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,OAAO,+BAA+B,EAAgB,KAAK,WACtF,CACF,CAND,EAAY,OAAO,EAAgB,KAAK,GAS5C,CAGE,EAAa,OAAS,GACxB,MAAM,EAAO,EAAa,CAGvB,GACH,EAAY,MAAM,CAGpB,IAAM,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EAUvB,OARA,EAAO,KACL,EAAO,MACL,uBAAuB,EAAY,OAAO,gCACxC,EAAgB,KACjB,gBAAgB,EAAY,IAAK,YACnC,CACF,CAEM,CAAE,cAAa"}
|
|
1
|
+
{"version":3,"file":"pullChunkedCustomSiloOutstandingIdentifiers-ekuEZlzq.mjs","names":[],"sources":["../src/lib/graphql/fetchRequestDataSiloActiveCount.ts","../src/lib/cron/pullCronPageOfIdentifiers.ts","../src/lib/cron/pullChunkedCustomSiloOutstandingIdentifiers.ts"],"sourcesContent":["import { makeGraphQLRequest, REDUCED_REQUESTS_FOR_DATA_SILO_COUNT } from '@transcend-io/sdk';\nimport { GraphQLClient } from 'graphql-request';\n\nimport { logger } from '../../logger.js';\n\n/**\n * Get number of open requests for a data silo\n *\n * @param client - GraphQL client\n * @param options - Filter options\n * @returns List of request identifiers\n */\nexport async function fetchRequestDataSiloActiveCount(\n client: GraphQLClient,\n {\n dataSiloId,\n }: {\n /** Data silo ID */\n dataSiloId: string;\n },\n): Promise<number> {\n const {\n listReducedRequestsForDataSilo: { totalCount },\n } = await makeGraphQLRequest<{\n /** Requests */\n listReducedRequestsForDataSilo: {\n /** Total count */\n totalCount: number;\n };\n }>(client, REDUCED_REQUESTS_FOR_DATA_SILO_COUNT, {\n variables: {\n input: {\n dataSiloId,\n isResolved: false,\n },\n },\n logger,\n });\n\n return totalCount;\n}\n","import { RequestAction } from '@transcend-io/privacy-types';\nimport { withTransientRetry } from '@transcend-io/sdk';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport type { Got } from 'got';\nimport * as t from 'io-ts';\n\nimport { logger } from '../../logger.js';\n\n/** Consent partition metadata when a DSR is scoped to a partition */\nexport const CronPartition = t.type({\n /** ID of the partition */\n id: t.string,\n /** The human readable name of the partition */\n name: t.string,\n /** The unique identifying partition value */\n partition: t.string,\n});\n\n/** Type override */\nexport type CronPartition = t.TypeOf<typeof CronPartition>;\n\nexport const CronIdentifier = t.intersection([\n t.type({\n /** The identifier value */\n identifier: t.string,\n /** The type of identifier */\n type: t.string,\n /** The core identifier of the request */\n coreIdentifier: t.string,\n /** The ID of the underlying data silo */\n dataSiloId: t.string,\n /** The ID of the underlying request */\n requestId: t.string,\n /** The request nonce */\n nonce: t.string,\n /** The time the request was created */\n requestCreatedAt: t.string,\n /** The number of days until the request is overdue */\n daysUntilOverdue: t.number,\n /** Request attributes */\n attributes: t.array(\n t.type({\n key: t.string,\n values: t.array(t.string),\n }),\n ),\n }),\n t.partial({\n /** The consent partition that scopes this request, when applicable */\n partition: t.union([CronPartition, t.null]),\n }),\n]);\n\n/** Type override */\nexport type CronIdentifier = t.TypeOf<typeof CronIdentifier>;\n\n/**\n * Pull a offset of identifiers for a cron job\n *\n * @see https://docs.transcend.io/docs/api-reference/GET/v1/data-silo/(id)/pending-requests/(type)\n * @param sombra - Sombra instance configured to make requests\n * @param options - Additional options\n * @returns Successfully submitted request\n */\nexport async function pullCronPageOfIdentifiers(\n sombra: Got,\n {\n dataSiloId,\n limit = 100,\n offset = 0,\n requestType,\n }: {\n /** Data Silo ID */\n dataSiloId: string;\n /** Type of request */\n requestType: RequestAction;\n /** Number of identifiers to pull in */\n limit?: number;\n /** Page to pull in */\n offset?: number;\n },\n): Promise<CronIdentifier[]> {\n try {\n // `GET pending-requests` is a read and therefore safe to retry on transient\n // gateway / network errors. Customers running `transcend cron\n // pull-identifiers` against large silos would otherwise see the command\n // abort on a single 502 from the Sombra reverse tunnel.\n const response = await withTransientRetry(\n 'pullCronPageOfIdentifiers',\n () =>\n sombra\n .get(`v1/data-silo/${dataSiloId}/pending-requests/${requestType}`, {\n searchParams: {\n offset,\n limit,\n },\n })\n .json(),\n { logger, maxAttempts: 6, baseDelayMs: 500 },\n );\n\n const { items } = decodeCodec(\n t.type({\n items: t.array(CronIdentifier),\n }),\n response,\n );\n return items;\n } catch (err) {\n throw new Error(`Received an error from server: ${err?.response?.body || err?.message}`);\n }\n}\n","import { RequestAction } from '@transcend-io/privacy-types';\nimport { buildTranscendGraphQLClient, createSombraGotInstance } from '@transcend-io/sdk';\nimport { mapSeries } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { fetchRequestDataSiloActiveCount } from '../graphql/index.js';\nimport { pullCronPageOfIdentifiers, CronIdentifier } from './pullCronPageOfIdentifiers.js';\n\n/**\n * A CSV formatted identifier\n */\nexport type CsvFormattedIdentifier = {\n [k in string]: string | null | boolean | number;\n};\n\nexport interface CronIdentifierWithAction extends CronIdentifier {\n /** The request action that the identifier relates to */\n action: RequestAction;\n}\n\n/**\n * Pull the set of identifiers outstanding for a cron or AVC integration\n *\n * This function is designed to be used in a loop, and will call the onSave callback\n * with a chunk of identifiers when the savePageSize is reached.\n *\n * @param options - Options\n * @returns The identifiers and identifiers formatted for CSV\n */\nexport async function pullChunkedCustomSiloOutstandingIdentifiers({\n dataSiloId,\n auth,\n sombraAuth,\n actions,\n apiPageSize = 100,\n savePageSize = 1000,\n onSave,\n transcendUrl = DEFAULT_TRANSCEND_API,\n skipRequestCount = false,\n}: {\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** The request actions to fetch */\n actions: RequestAction[];\n /** How many identifiers to pull in a single call to the backend */\n apiPageSize: number;\n /** How many identifiers to save at a time (usually to a CSV file, should be a multiple of apiPageSize) */\n savePageSize: number;\n /** Callback function called when a chunk of identifiers is ready to be saved */\n onSave: (chunk: CsvFormattedIdentifier[]) => Promise<void>;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Skip request count */\n skipRequestCount?: boolean;\n}): Promise<{\n /** Raw Identifiers */\n identifiers: CronIdentifierWithAction[];\n}> {\n // Validate savePageSize\n if (savePageSize % apiPageSize !== 0) {\n throw new Error(\n `savePageSize must be a multiple of apiPageSize. savePageSize: ${savePageSize}, apiPageSize: ${apiPageSize}`,\n );\n }\n\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n // Create GraphQL client to connect to Transcend backend\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n let totalRequestCount = 0;\n if (!skipRequestCount) {\n totalRequestCount = await fetchRequestDataSiloActiveCount(client, {\n dataSiloId,\n });\n }\n\n logger.info(\n colors.magenta(\n `Pulling ${skipRequestCount ? 'all' : totalRequestCount} outstanding request identifiers ` +\n `for data silo: \"${dataSiloId}\" for requests of types \"${actions.join('\", \"')}\"`,\n ),\n );\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n const foundRequestIds = new Set<string>();\n\n // identifiers found in total\n const identifiers: CronIdentifierWithAction[] = [];\n // current chunk of identifiers to be saved\n let currentChunk: CsvFormattedIdentifier[] = [];\n\n // map over each action\n if (!skipRequestCount) {\n progressBar.start(totalRequestCount, 0);\n }\n await mapSeries(actions, async (action) => {\n let offset = 0;\n let shouldContinue = true;\n\n // Fetch a page of identifiers\n while (shouldContinue) {\n const pageIdentifiers = await pullCronPageOfIdentifiers(sombra, {\n dataSiloId,\n limit: apiPageSize,\n offset,\n requestType: action,\n });\n\n const identifiersWithAction: CronIdentifierWithAction[] = pageIdentifiers.map(\n (identifier) => {\n foundRequestIds.add(identifier.requestId);\n return {\n ...identifier,\n action,\n };\n },\n );\n\n const csvFormattedIdentifiers = identifiersWithAction.map(\n ({ attributes, partition, ...identifier }) => ({\n ...identifier,\n ...(partition\n ? {\n partitionId: partition.id,\n partitionName: partition.name,\n partitionKey: partition.partition,\n }\n : {}),\n ...attributes.reduce(\n (acc, val) =>\n Object.assign(acc, {\n [val.key]: val.values.join(','),\n }),\n {},\n ),\n }),\n );\n\n identifiers.push(...identifiersWithAction);\n currentChunk.push(...csvFormattedIdentifiers);\n\n // Check if we've reached the savePageSize and call the onSave callback\n if (currentChunk.length >= savePageSize) {\n await onSave(currentChunk);\n currentChunk = [];\n }\n\n shouldContinue = pageIdentifiers.length === apiPageSize;\n offset += apiPageSize;\n if (!skipRequestCount) {\n progressBar.update(foundRequestIds.size);\n } else {\n logger.info(\n colors.magenta(\n `Pulled ${pageIdentifiers.length} outstanding identifiers for ${foundRequestIds.size} requests`,\n ),\n );\n }\n }\n });\n\n // Save any remaining identifiers in the current chunk\n if (currentChunk.length > 0) {\n await onSave(currentChunk);\n }\n\n if (!skipRequestCount) {\n progressBar.stop();\n }\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully pulled ${identifiers.length} outstanding identifiers from ${\n foundRequestIds.size\n } requests in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n\n return { identifiers };\n}\n"],"mappings":"0bAYA,eAAsB,EACpB,EACA,CACE,cAKe,CACjB,GAAM,CACJ,+BAAgC,CAAE,eAChC,MAAM,EAMP,EAAQ,EAAsC,CAC/C,UAAW,CACT,MAAO,CACL,aACA,WAAY,GACb,CACF,CACD,SACD,CAAC,CAEF,OAAO,EC9BT,MAAa,EAAgB,EAAE,KAAK,CAElC,GAAI,EAAE,OAEN,KAAM,EAAE,OAER,UAAW,EAAE,OACd,CAAC,CAKW,EAAiB,EAAE,aAAa,CAC3C,EAAE,KAAK,CAEL,WAAY,EAAE,OAEd,KAAM,EAAE,OAER,eAAgB,EAAE,OAElB,WAAY,EAAE,OAEd,UAAW,EAAE,OAEb,MAAO,EAAE,OAET,iBAAkB,EAAE,OAEpB,iBAAkB,EAAE,OAEpB,WAAY,EAAE,MAC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nrichmentIdentifiersToCsv-
|
|
1
|
+
import{a as e}from"./constants-I694qbRg.mjs";import{t}from"./logger-CPu6zbyQ.mjs";import{r as n}from"./fetchAllRequests-BV9K0wXv.mjs";import{a as r}from"./writeCsv-CNZrq3zU.mjs";import{RequestStatus as i}from"@transcend-io/privacy-types";import{groupBy as a,uniq as o}from"lodash-es";import s from"colors";import{map as c}from"@transcend-io/utils";import{buildTranscendGraphQLClient as l,createSombraGotInstance as u,fetchAllRequestEnrichers as d,fetchAllRequestIdentifiers as f,validateSombraVersion as p}from"@transcend-io/sdk";async function m({file:m,auth:h,sombraAuth:g,requestActions:_=[],concurrency:v=100,transcendUrl:y=e}){let b=l(y,h),x=await u(y,h,{logger:t,sombraApiKey:g,sombraUrl:process.env.SOMBRA_URL});t.info(s.magenta(`Pulling manual enrichment requests, filtered for actions: ${_.join(`,`)}`));let S=await n(b,{actions:_,statuses:[i.Enriching]});await p(b,{logger:t});let C=[];await c(S,async e=>{let n=await d(b,{filterBy:{requestId:e.id},logger:t});if(n.filter(({status:e})=>e===`ACTION_REQUIRED`)){let r=await f(b,x,{filterBy:{requestId:e.id},skipSombraCheck:!0,logger:t});C.push({...e,requestIdentifiers:r,requestEnrichers:n})}},{concurrency:v});let w=C.map(({attributeValues:e,requestIdentifiers:t,requestEnrichers:n,...r})=>({...r,...Object.entries(a(t,`name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({value:e})=>e).join(`,`)}),{}),...Object.entries(a(e,`attributeKey.name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({name:e})=>e).join(`,`)}),{})}));return await r(m,w,o(w.map(e=>Object.keys(e)).flat())),t.info(s.green(`Successfully wrote ${C.length} requests to file "${m}"`)),C}export{m as t};
|
|
2
|
+
//# sourceMappingURL=pullManualEnrichmentIdentifiersToCsv-D710M8kt.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullManualEnrichmentIdentifiersToCsv-
|
|
1
|
+
{"version":3,"file":"pullManualEnrichmentIdentifiersToCsv-D710M8kt.mjs","names":[],"sources":["../src/lib/manual-enrichment/pullManualEnrichmentIdentifiersToCsv.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllRequestEnrichers,\n fetchAllRequestIdentifiers,\n validateSombraVersion,\n type RequestEnricher,\n type RequestIdentifier,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport colors from 'colors';\nimport { groupBy, uniq } from 'lodash-es';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { type PrivacyRequest, fetchAllRequests } from '../graphql/index.js';\nimport { writeCsv } from '../helpers/writeCsv.js';\n\nexport interface PrivacyRequestWithIdentifiers extends PrivacyRequest {\n /** Request Enrichers */\n requestEnrichers: RequestEnricher[];\n /** Request Identifiers */\n requestIdentifiers: RequestIdentifier[];\n}\n\n/**\n * Pull the set of manual enrichment jobs to CSV\n *\n * @param options - Options\n * @returns List of requests with identifiers\n */\nexport async function pullManualEnrichmentIdentifiersToCsv({\n file,\n auth,\n sombraAuth,\n requestActions = [],\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** CSV file path */\n file: string;\n /** Transcend API key authentication */\n auth: string;\n /** Sombra API key */\n sombraAuth?: string;\n /** Concurrency */\n concurrency?: number;\n /** The request actions to fetch */\n requestActions?: RequestAction[];\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<PrivacyRequestWithIdentifiers[]> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n logger.info(\n colors.magenta(\n `Pulling manual enrichment requests, filtered for actions: ${requestActions.join(',')}`,\n ),\n );\n\n // Pull all privacy requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses: [RequestStatus.Enriching],\n });\n\n await validateSombraVersion(client, { logger });\n\n // Requests to save\n const savedRequests: PrivacyRequestWithIdentifiers[] = [];\n\n // Filter down requests to what is needed\n await map(\n allRequests,\n async (request) => {\n // Fetch enrichers\n const requestEnrichers = await fetchAllRequestEnrichers(client, {\n filterBy: { requestId: request.id },\n logger,\n });\n\n // Check if manual enrichment exists for that request\n const hasManualEnrichment = requestEnrichers.filter(\n ({ status }) => status === 'ACTION_REQUIRED',\n );\n\n // Save request to queue\n if (hasManualEnrichment) {\n const requestIdentifiers = await fetchAllRequestIdentifiers(client, sombra, {\n filterBy: { requestId: request.id },\n skipSombraCheck: true,\n logger,\n });\n savedRequests.push({\n ...request,\n requestIdentifiers,\n requestEnrichers,\n });\n }\n },\n {\n concurrency,\n },\n );\n\n const data = savedRequests.map(\n ({\n attributeValues,\n requestIdentifiers,\n requestEnrichers, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...request\n }) => ({\n ...request,\n // flatten identifiers\n ...Object.entries(groupBy(requestIdentifiers, 'name')).reduce(\n (acc, [key, values]) =>\n Object.assign(acc, {\n [key]: values.map(({ value }) => value).join(','),\n }),\n {},\n ),\n // flatten attributes\n ...Object.entries(groupBy(attributeValues, 'attributeKey.name')).reduce(\n (acc, [key, values]) =>\n Object.assign(acc, {\n [key]: values.map(({ name }) => name).join(','),\n }),\n {},\n ),\n }),\n );\n\n // Write out to CSV\n const headers = uniq(data.map((d) => Object.keys(d)).flat());\n await writeCsv(file, data, headers);\n\n logger.info(\n colors.green(`Successfully wrote ${savedRequests.length} requests to file \"${file}\"`),\n );\n\n return savedRequests;\n}\n"],"mappings":"khBAgCA,eAAsB,EAAqC,CACzD,OACA,OACA,aACA,iBAAiB,EAAE,CACnB,cAAc,IACd,eAAe,GAc4B,CAE3C,IAAM,EAAS,EAA4B,EAAc,EAAK,CACxD,EAAS,MAAM,EAAwB,EAAc,EAAM,CAC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CAAC,CAEnC,EAAO,KACL,EAAO,MAAM,sBAAsB,EAAc,OAAO,qBAAqB,EAAK,GAAG,CACtF,CAEM"}
|
package/dist/{pushCronIdentifiersFromCsv-CeRVlbFE.mjs → pushCronIdentifiersFromCsv-f8FSSFhM.mjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./constants-
|
|
2
|
-
//# sourceMappingURL=pushCronIdentifiersFromCsv-
|
|
1
|
+
import{a as e}from"./constants-I694qbRg.mjs";import{t}from"./logger-CPu6zbyQ.mjs";import{n}from"./readCsv-DNcJ_UfU.mjs";import{chunk as r}from"lodash-es";import i from"colors";import{map as a,mapSeries as o}from"@transcend-io/utils";import*as s from"io-ts";import{createSombraGotInstance as c}from"@transcend-io/sdk";import l from"cli-progress";const u=s.type({nonce:s.string,identifier:s.string});async function d(e,{nonce:t,identifier:n}){try{return await e.put(`v1/data-silo`,{headers:{"x-transcend-nonce":t},json:{profiles:[{profileId:n}]}}),!0}catch(e){if(e.response?.statusCode===409)return!1;throw Error(`Received an error from server: ${e?.response?.body||e?.message}`)}}async function f({file:s,dataSiloId:f,auth:p,sombraAuth:m,concurrency:h=100,transcendUrl:g=e,sleepSeconds:_=10}){let v=await c(g,p,{logger:t,sombraApiKey:m,sombraUrl:process.env.SOMBRA_URL});t.info(i.magenta(`Reading "${s}" from disk`));let y=n(s,u);t.info(i.magenta(`Notifying Transcend for data silo "${f}" marking "${y.length}" identifiers as completed.`));let b=new Date().getTime(),x=new l.SingleBar({},l.Presets.shades_classic),S=0,C=0,w=0;x.start(y.length,0);let T=r(y,h),E=T.length;await o(T,async(e,n)=>{t.info(i.blue(`Processing chunk ${n+1}/${E} (${r.length} items)`)),await a(e,async e=>{try{await d(v,e)?S+=1:C+=1}catch(n){t.error(i.red(`Error notifying Transcend for identifier "${e.identifier}" - ${n?.message}`)),w+=1}x.update(S+C)}),_>0&&n<E-1&&(t.info(i.yellow(`Sleeping for ${_}s before next chunk...`)),await new Promise(e=>{setTimeout(e,_*1e3)}))}),x.stop();let D=new Date().getTime()-b;if(t.info(i.green(`Successfully notified Transcend for ${S} identifiers in "${D/1e3}" seconds!`)),C&&t.info(i.magenta(`There were ${C} identifiers that were not in a state to be updated.They likely have already been resolved.`)),w)throw t.error(i.red(`There were ${w} identifiers that failed to be updated. Please review the logs for more information.`)),Error(`Failed to update all identifiers`);return y.length}export{u as n,d as r,f as t};
|
|
2
|
+
//# sourceMappingURL=pushCronIdentifiersFromCsv-f8FSSFhM.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushCronIdentifiersFromCsv-
|
|
1
|
+
{"version":3,"file":"pushCronIdentifiersFromCsv-f8FSSFhM.mjs","names":[],"sources":["../src/lib/cron/markCronIdentifierCompleted.ts","../src/lib/cron/pushCronIdentifiersFromCsv.ts"],"sourcesContent":["import type { Got } from 'got';\nimport * as t from 'io-ts';\n\n/**\n * Minimal set required to mark as completed\n */\nexport const CronIdentifierPush = t.type({\n nonce: t.string,\n identifier: t.string,\n});\n\n/** Type override */\nexport type CronIdentifierPush = t.TypeOf<typeof CronIdentifierPush>;\n\n/**\n * Mark an identifier output by the cron job as completed.\n *\n * @see https://docs.transcend.io/docs/api-reference/PUT/v1/data-silo\n * @param sombra - Sombra instance configured to make requests\n * @param options - Additional options\n * @returns Successfully submitted request, false if not in a state to update\n */\nexport async function markCronIdentifierCompleted(\n sombra: Got,\n { nonce, identifier }: CronIdentifierPush,\n): Promise<boolean> {\n try {\n // Make the GraphQL request\n await sombra.put('v1/data-silo', {\n headers: {\n 'x-transcend-nonce': nonce,\n },\n json: {\n profiles: [\n {\n profileId: identifier,\n },\n ],\n },\n });\n return true;\n } catch (err) {\n // handle gracefully\n if (err.response?.statusCode === 409) {\n return false;\n }\n throw new Error(`Received an error from server: ${err?.response?.body || err?.message}`);\n }\n}\n","import { createSombraGotInstance } from '@transcend-io/sdk';\nimport { map, mapSeries } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport { chunk } from 'lodash-es';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { readCsv } from '../requests/index.js';\nimport { markCronIdentifierCompleted, CronIdentifierPush } from './markCronIdentifierCompleted.js';\n\n/**\n * Given a CSV of cron job outputs, mark all requests as completed in Transcend\n *\n * @param options - Options\n * @returns Number of items marked as completed\n */\nexport async function pushCronIdentifiersFromCsv({\n file,\n dataSiloId,\n auth,\n sombraAuth,\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n sleepSeconds = 10,\n}: {\n /** CSV file path */\n file: string;\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** Upload concurrency */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Sleep time in seconds between chunks of concurrent calls */\n sleepSeconds?: number;\n}): Promise<number> {\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n // Read from CSV\n logger.info(colors.magenta(`Reading \"${file}\" from disk`));\n const activeResults = readCsv(file, CronIdentifierPush);\n\n // Notify Transcend\n logger.info(\n colors.magenta(\n `Notifying Transcend for data silo \"${dataSiloId}\" marking \"${activeResults.length}\" identifiers as completed.`,\n ),\n );\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n let successCount = 0;\n let failureCount = 0;\n let errorCount = 0;\n progressBar.start(activeResults.length, 0);\n\n // Process in chunks with sleep intervals\n const chunks = chunk(activeResults, concurrency);\n const totalChunks = chunks.length;\n const processChunk = async (items: CronIdentifierPush[], chunkIndex: number): Promise<void> => {\n logger.info(\n colors.blue(`Processing chunk ${chunkIndex + 1}/${totalChunks} (${chunk.length} items)`),\n );\n\n // Process the items of the chunk concurrently\n await map(items, async (identifier) => {\n try {\n const success = await markCronIdentifierCompleted(sombra, identifier);\n if (success) {\n successCount += 1;\n } else {\n failureCount += 1;\n }\n } catch (e) {\n logger.error(\n colors.red(\n `Error notifying Transcend for identifier \"${identifier.identifier}\" - ${e?.message}`,\n ),\n );\n errorCount += 1;\n }\n progressBar.update(successCount + failureCount);\n });\n\n // Sleep between chunks (except for the last chunk)\n if (sleepSeconds > 0 && chunkIndex < totalChunks - 1) {\n logger.info(colors.yellow(`Sleeping for ${sleepSeconds}s before next chunk...`));\n\n await new Promise((resolve) => {\n setTimeout(resolve, sleepSeconds * 1000);\n });\n }\n };\n\n // Process all chunks sequentially\n await mapSeries(chunks, processChunk);\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully notified Transcend for ${successCount} identifiers in \"${\n totalTime / 1000\n }\" seconds!`,\n ),\n );\n if (failureCount) {\n logger.info(\n colors.magenta(\n `There were ${failureCount} identifiers that were not in a state to be updated.` +\n 'They likely have already been resolved.',\n ),\n );\n }\n if (errorCount) {\n logger.error(\n colors.red(\n `There were ${errorCount} identifiers that failed to be updated. Please review the logs for more information.`,\n ),\n );\n throw new Error('Failed to update all identifiers');\n }\n return activeResults.length;\n}\n"],"mappings":"yVAMA,MAAa,EAAqB,EAAE,KAAK,CACvC,MAAO,EAAE,OACT,WAAY,EAAE,OACf,CAAC,CAaF,eAAsB,EACpB,EACA,CAAE,QAAO,cACS,CAClB,GAAI,CAcF,OAZA,MAAM,EAAO,IAAI,eAAgB,CAC/B,QAAS,CACP,oBAAqB,EACtB,CACD,KAAM,CACJ,SAAU,CACR,CACE,UAAW,EACZ,CACF,CACF,CACF,CAAC,CACK,SACA,EAAK,CAEZ,GAAI,EAAI,UAAU,aAAe,IAC/B,MAAO,GAET,MAAU,MAAM,kCAAkC,GAAK,UAAU,MAAQ,GAAK,UAAU,EC7B5F,e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AAa,mBAClD,EAAY,IACb,YACF,CACF,CACG,GACF,EAAO,KACL,EAAO,QACL,cAAc,EAAa,6FAE5B,CACF,CAEC,EAMF,MALA,EAAO,MACL,EAAO,IACL,cAAc,EAAW,sFAC1B,CACF,CACS,MAAM,mCAAmC,CAErD,OAAO,EAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./constants-
|
|
2
|
-
//# sourceMappingURL=pushManualEnrichmentIdentifiersFromCsv
|
|
1
|
+
import{a as e}from"./constants-I694qbRg.mjs";import{t}from"./logger-CPu6zbyQ.mjs";import{n}from"./readCsv-DNcJ_UfU.mjs";import{o as r}from"./request-BpKyN9Xm.mjs";import{uniq as i}from"lodash-es";import a from"colors";import{map as o,splitCsvToList as s}from"@transcend-io/utils";import*as c from"io-ts";import{buildTranscendGraphQLClient as l,createSombraGotInstance as u,makeGraphQLRequest as d}from"@transcend-io/sdk";const f=`https://app.transcend.io/privacy-requests/incoming-requests/`,p=c.record(c.string,c.string);async function m(e,{id:n,...r},o,c){if(!n){let e=`Request ID must be provided to enricher request.${c?` Found error in row: ${c}`:``}`;throw t.error(a.red(e)),Error(e)}let l=n.toLowerCase(),u=Object.entries(r).reduce((e,[t,n])=>i(s(n)).length===0?e:Object.assign(e,{[t]:i(s(n)).map(e=>({value:t===`email`?e.toLowerCase():e}))}),{});try{return await e.post(`v1/enrich-identifiers`,{headers:{"x-transcend-request-id":l,"x-transcend-enricher-id":o},json:{enrichedIdentifiers:u}}).json(),t.error(a.green(`Successfully enriched request: ${f}${l}`)),!0}catch(e){if(typeof e.response.body==`string`&&e.response.body.includes(`Cannot update a resolved RequestEnricher`))return t.warn(a.magenta(`Skipped enrichment for request: ${f}${l}, request is no longer in the enriching phase.`)),!1;throw t.error(a.red(`Failed to enricher identifiers for request with id: ${f}${l} - ${e.message} - ${e.response.body}`)),e}}async function h({file:i,auth:s,sombraAuth:c,enricherId:f,markSilent:h,concurrency:g=100,transcendUrl:_=e}){let v=await u(_,s,{logger:t,sombraApiKey:c,sombraUrl:process.env.SOMBRA_URL}),y=l(_,s);t.info(a.magenta(`Reading "${i}" from disk`));let b=n(i,p);t.info(a.magenta(`Enriching "${b.length}" privacy requests.`));let x=0,S=0,C=0;if(await o(b,async(e,n)=>{try{h&&(await d(y,r,{variables:{input:{id:e.id,isSilent:!0}},logger:t}),t.info(a.magenta(`Mark request as silent mode - ${e.id}`))),await m(v,e,f,n)?x+=1:S+=1}catch{C+=1}},{concurrency:g}),t.info(a.green(`Successfully notified Transcend! \n Success count: ${x}.`)),S>0&&t.info(a.magenta(`Skipped count: ${S}.`)),C>0)throw t.info(a.red(`Error Count: ${C}.`)),Error(`Failed to enrich: ${C} requests.`);return b.length}export{p as n,m as r,h as t};
|
|
2
|
+
//# sourceMappingURL=pushManualEnrichmentIdentifiersFromCsv-6xOUhOpJ.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushManualEnrichmentIdentifiersFromCsv
|
|
1
|
+
{"version":3,"file":"pushManualEnrichmentIdentifiersFromCsv-6xOUhOpJ.mjs","names":[],"sources":["../src/lib/manual-enrichment/enrichPrivacyRequest.ts","../src/lib/manual-enrichment/pushManualEnrichmentIdentifiersFromCsv.ts"],"sourcesContent":["import { splitCsvToList } from '@transcend-io/utils';\nimport colors from 'colors';\nimport type { Got } from 'got';\nimport * as t from 'io-ts';\nimport { uniq } from 'lodash-es';\n\nimport { logger } from '../../logger.js';\n\nconst ADMIN_URL = 'https://app.transcend.io/privacy-requests/incoming-requests/';\n/**\n * Minimal set required to mark as completed\n */\nexport const EnrichPrivacyRequest = t.record(t.string, t.string);\n\n/** Type override */\nexport type EnrichPrivacyRequest = t.TypeOf<typeof EnrichPrivacyRequest>;\n\n/**\n * Upload identifiers to a privacy request or mark request as\n *\n * @param sombra - Sombra instance configured to make requests\n * @param request - Request to enricher\n * @param enricherId - The ID of the enricher being uploaded to\n * @param index - Index of request ID\n * @returns True if enriched successfully, false if skipped, throws error if failed\n */\nexport async function enrichPrivacyRequest(\n sombra: Got,\n { id: rawId, ...rest }: EnrichPrivacyRequest,\n enricherId: string,\n index?: number,\n): Promise<boolean> {\n if (!rawId) {\n // error\n const msg = `Request ID must be provided to enricher request.${\n index ? ` Found error in row: ${index}` : ''\n }`;\n logger.error(colors.red(msg));\n throw new Error(msg);\n }\n\n const id = rawId.toLowerCase();\n\n // Pull out the identifiers\n const enrichedIdentifiers = Object.entries(rest).reduce(\n (acc, [key, value]) => {\n const values = uniq(splitCsvToList(value));\n return values.length === 0\n ? acc\n : Object.assign(acc, {\n [key]: uniq(splitCsvToList(value)).map((val) => ({\n value: key === 'email' ? val.toLowerCase() : val,\n })),\n });\n },\n {} as Record<string, string[]>,\n );\n\n // Make the GraphQL request\n try {\n await sombra\n .post('v1/enrich-identifiers', {\n headers: {\n 'x-transcend-request-id': id,\n 'x-transcend-enricher-id': enricherId,\n },\n json: {\n enrichedIdentifiers,\n },\n })\n .json();\n\n logger.error(colors.green(`Successfully enriched request: ${ADMIN_URL}${id}`));\n return true;\n } catch (err) {\n // skip if already enriched\n if (\n typeof err.response.body === 'string' &&\n err.response.body.includes('Cannot update a resolved RequestEnricher')\n ) {\n logger.warn(\n colors.magenta(\n `Skipped enrichment for request: ${ADMIN_URL}${id}, request is no longer in the enriching phase.`,\n ),\n );\n return false;\n }\n\n // error\n logger.error(\n colors.red(\n `Failed to enricher identifiers for request with id: ${ADMIN_URL}${id} - ${err.message} - ${err.response.body}`,\n ),\n );\n throw err;\n }\n}\n","import {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n makeGraphQLRequest,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { UPDATE_PRIVACY_REQUEST } from '../graphql/index.js';\nimport { readCsv } from '../requests/index.js';\nimport { enrichPrivacyRequest, EnrichPrivacyRequest } from './enrichPrivacyRequest.js';\n\n/**\n * Push a CSV of enriched requests back into Transcend\n *\n * @param options - Options\n * @returns Number of items processed\n */\nexport async function pushManualEnrichmentIdentifiersFromCsv({\n file,\n auth,\n sombraAuth,\n enricherId,\n markSilent,\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** CSV file path */\n file: string;\n /** Transcend API key authentication */\n auth: string;\n /** ID of enricher being uploaded to */\n enricherId: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Concurrency */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Mark requests in silent mode before enriching */\n markSilent?: boolean;\n}): Promise<number> {\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Read from CSV\n logger.info(colors.magenta(`Reading \"${file}\" from disk`));\n const activeResults = readCsv(file, EnrichPrivacyRequest);\n\n // Notify Transcend\n logger.info(colors.magenta(`Enriching \"${activeResults.length}\" privacy requests.`));\n\n let successCount = 0;\n let skippedCount = 0;\n let errorCount = 0;\n\n await map(\n activeResults,\n async (request, index) => {\n try {\n // Mark requests in silent mode before a certain date\n if (markSilent) {\n await makeGraphQLRequest(client, UPDATE_PRIVACY_REQUEST, {\n variables: {\n input: {\n id: request.id,\n isSilent: true,\n },\n },\n logger,\n });\n\n logger.info(colors.magenta(`Mark request as silent mode - ${request.id}`));\n }\n\n const result = await enrichPrivacyRequest(sombra, request, enricherId, index);\n if (result) {\n successCount += 1;\n } else {\n skippedCount += 1;\n }\n } catch {\n errorCount += 1;\n }\n },\n { concurrency },\n );\n\n logger.info(colors.green(`Successfully notified Transcend! \\n Success count: ${successCount}.`));\n\n if (skippedCount > 0) {\n logger.info(colors.magenta(`Skipped count: ${skippedCount}.`));\n }\n\n if (errorCount > 0) {\n logger.info(colors.red(`Error Count: ${errorCount}.`));\n throw new Error(`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SACA,aAAc,EACd,UAAW,QAAQ,IAAI,WACxB,CAAC,CACI,EAAS,EAA4B,EAAc,EAAK,CAG9D,EAAO,KAAK,EAAO,QAAQ,YAAY,EAAK,aAAa,CAAC,CAC1D,IAAM,EAAgB,EAAQ,EAAM,EAAqB,CAGzD,EAAO,KAAK,EAAO,QAAQ,cAAc,EAAc,OAAO,qBAAqB,CAAC,CAEpF,IAAI,EAAe,EACf,EAAe,EACf,EAAa,EAwCjB,GAtCA,MAAM,EACJ,EACA,MAAO,EAAS,IAAU,CACxB,GAAI,CAEE,IACF,MAAM,EAAmB,EAAQ,EAAwB,CACvD,UAAW,CACT,MAAO,CACL,GAAI,EAAQ,GACZ,SAAU,GACX,CACF,CACD,SACD,CAAC,CAEF,EAAO,KAAK,EAAO,QAAQ,iCAAiC,EAAQ,KAAK,CAAC,EAIxE,MADiB,EAAqB,EAAQ,EAAS,EAAY,EAAM,CAE3E,GAAgB,EAEhB,GAAgB,OAEZ,CACN,GAAc,IAGlB,CAAE,cAAa,CAChB,CAED,EAAO,KAAK,EAAO,MAAM,sDAAsD,EAAa,GAAG,CAAC,CAE5F,EAAe,GACjB,EAAO,KAAK,EAAO,QAAQ,kBAAkB,EAAa,GAAG,CAAC,CAG5D,EAAa,EAEf,MADA,EAAO,KAAK,EAAO,IAAI,gBAAgB,EAAW,GAAG,CAAC,CAC5C,MAAM,qBAAqB,EAAW,YAAY,CAG9D,OAAO,EAAc"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{ft as e,gt as t}from"./codecs-
|
|
1
|
+
import{ft as e,gt as t}from"./codecs-8T8Jhxsr.mjs";import n from"js-yaml";import{readFileSync as r,writeFileSync as i}from"node:fs";import{decodeCodec as a}from"@transcend-io/type-utils";const o=/<<parameters\.(.+?)>>/,s=`parameters`;function c(e,t,n=``){let r=Object.entries(t).reduce((e,[t,n])=>e.split(`<<${s}.${t}>>`).join(n),e);if(o.test(r)){let[,e]=o.exec(r)||[];throw Error(`Found variable that was not set: ${e}.
|
|
2
2
|
Make sure you are passing all variables through the --variables=${e}:value-for-variable flag.
|
|
3
3
|
${n}`)}return r}function l(r,i={},o){let s=c(r,i,o?`Also check that there are no extra variables defined in your yaml: ${o}`:``);return t(a(e,n.load(s)))}function u(r){return n.dump(a(e,t(r)))}function d(e,t={}){return l(r(e,`utf-8`),t,e)}function f(e,t){i(e,u(t))}export{c as a,d as i,o as n,u as o,l as r,f as s,s as t};
|
|
4
|
-
//# sourceMappingURL=readTranscendYaml-
|
|
4
|
+
//# sourceMappingURL=readTranscendYaml-D576bvzR.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readTranscendYaml-
|
|
1
|
+
{"version":3,"file":"readTranscendYaml-D576bvzR.mjs","names":[],"sources":["../src/lib/readTranscendYaml.ts"],"sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\n\nimport { decodeCodec, ObjByString } from '@transcend-io/type-utils';\nimport yaml from 'js-yaml';\n\nimport { normalizeTranscendInput, TranscendInput } from '../codecs.js';\n\nexport const VARIABLE_PARAMETERS_REGEXP = /<<parameters\\.(.+?)>>/;\nexport const VARIABLE_PARAMETERS_NAME = 'parameters';\n\n/**\n * Function that replaces variables in a text file.\n * Throws error if there are variables that have not been replaced\n *\n * @param input - Input text\n * @param variables - Variables to replace\n * @param extraErrorMessage - Additional error message text\n * @returns Output text\n */\nexport function replaceVariablesInYaml(\n input: string,\n variables: ObjByString,\n extraErrorMessage = '',\n): string {\n const contents = Object.entries(variables).reduce(\n (replaced, [name, value]) =>\n replaced.split(`<<${VARIABLE_PARAMETERS_NAME}.${name}>>`).join(value),\n input,\n );\n\n // Throw error if unfilled parameters\n if (VARIABLE_PARAMETERS_REGEXP.test(contents)) {\n const [, name] = VARIABLE_PARAMETERS_REGEXP.exec(contents) || [];\n throw new Error(\n `Found variable that was not set: ${name}.\nMake sure you are passing all variables through the --variables=${name}:value-for-variable flag.\n${extraErrorMessage}`,\n );\n }\n\n return contents;\n}\n\n/**\n * Parse YAML contents and validate that their shape matches the codec API.\n *\n * @param contents - YAML contents.\n * @param variables - Variables to fill in\n * @param sourcePath - Optional source path included in parameter errors.\n * @returns The parsed contents, type-checked.\n */\nexport function parseTranscendYaml(\n contents: string,\n variables: ObjByString = {},\n sourcePath?: string,\n): TranscendInput {\n const replacedVariables = replaceVariablesInYaml(\n contents,\n variables,\n sourcePath\n ? `Also check that there are no extra variables defined in your yaml: ${sourcePath}`\n : '',\n );\n\n return normalizeTranscendInput(decodeCodec(TranscendInput, yaml.load(replacedVariables)));\n}\n\n/**\n * Serialize a validated Transcend configuration as YAML.\n *\n * @param input - The input to serialize.\n * @returns YAML contents.\n */\nexport function serializeTranscendYaml(input: TranscendInput): string {\n return yaml.dump(decodeCodec(TranscendInput, normalizeTranscendInput(input)));\n}\n\n/**\n * Read in the contents of a YAML file and validate that its shape matches the codec API.\n *\n * @param filePath - Path to YAML file.\n * @param variables - Variables to fill in.\n * @returns The parsed contents, type-checked.\n */\nexport function readTranscendYaml(filePath: string, variables: ObjByString = {}): TranscendInput {\n return parseTranscendYaml(readFileSync(filePath, 'utf-8'), variables, filePath);\n}\n\n/**\n * Write a Transcend configuration to disk.\n *\n * @param filePath - Path to YAML file.\n * @param input - The input to write out.\n */\nexport function writeTranscendYaml(filePath: string, input: TranscendInput): void {\n writeFileSync(filePath, serializeTranscendYaml(input));\n}\n"],"mappings":"2LAOA,MAAa,EAA6B,wBAC7B,EAA2B,aAWxC,SAAgB,EACd,EACA,EACA,EAAoB,GACZ,CACR,IAAM,EAAW,OAAO,QAAQ,EAAU,CAAC,QACxC,EAAU,CAAC,EAAM,KAChB,EAAS,MAAM,KAAK,EAAyB,GAAG,EAAK,IAAI,CAAC,KAAK,EAAM,CACvE,EACD,CAGD,GAAI,EAA2B,KAAK,EAAS,CAAE,CAC7C,GAAM,EAAG,GAAQ,EAA2B,KAAK,EAAS,EAAI,EAAE,CAChE,MAAU,MACR,oCAAoC,EAAK;kEACmB,EAAK;EACrE,IACG,CAGH,OAAO,EAWT,SAAgB,EACd,EACA,EAAyB,EAAE,CAC3B,EACgB,CAChB,IAAM,EAAoB,EACxB,EACA,EACA,EACI,sEAAsE,IACtE,GACL,CAED,OAAO,EAAwB,EAAY,EAAgB,EAAK,KAAK,EAAkB,CAAC,CAAC,CAS3F,SAAgB,EAAuB,EAA+B,CACpE,OAAO,EAAK,KAAK,EAAY,EAAgB,EAAwB,EAAM,CAAC,CAAC,CAU/E,SAAgB,EAAkB,EAAkB,EAAyB,EAAE,CAAkB,CAC/F,OAAO,EAAmB,EAAa,EAAU,QAAQ,CAAE,EAAW,EAAS,CASjF,SAAgB,EAAmB,EAAkB,EAA6B,CAChF,EAAc,EAAU,EAAuB,EAAM,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./constants-
|
|
2
|
-
//# sourceMappingURL=removeUnverifiedRequestIdentifiers-
|
|
1
|
+
import{a as e}from"./constants-I694qbRg.mjs";import{t}from"./logger-CPu6zbyQ.mjs";import{r as n}from"./fetchAllRequests-BV9K0wXv.mjs";import{RequestStatus as r}from"@transcend-io/privacy-types";import i from"colors";import{map as a}from"@transcend-io/utils";import{REMOVE_REQUEST_IDENTIFIERS as o,buildTranscendGraphQLClient as s,fetchAllRequestIdentifierMetadata as c,makeGraphQLRequest as l}from"@transcend-io/sdk";import u from"cli-progress";async function d({requestActions:d,identifierNames:f,auth:p,concurrency:m=20,transcendUrl:h=e}){let g=s(h,p),_=new Date().getTime(),v=new u.SingleBar({},u.Presets.shades_classic),y=await n(g,{actions:d,statuses:[r.Enriching]});t.info(i.magenta(`Fetched requests in preflight/enriching state.`));let b=0,x=0;v.start(y.length,0),await a(y,async e=>{let n=(await c(g,{filterBy:{requestId:e.id},logger:t})).filter(({isVerifiedAtLeastOnce:e,name:t})=>e===!1&&f.includes(t)).map(({id:e})=>e);n.length>0&&(await l(g,o,{variables:{input:{requestId:e.id,requestIdentifierIds:n}},logger:t}),x+=n.length),b+=1,v.update(b)},{concurrency:m}),v.stop();let S=new Date().getTime()-_;return t.info(i.green(`Successfully cleared out unverified identifiers "${S/1e3}" seconds for ${b} requests, ${x} identifiers were cleared out!`)),y.length}export{d as t};
|
|
2
|
+
//# sourceMappingURL=removeUnverifiedRequestIdentifiers-B8iIreP4.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeUnverifiedRequestIdentifiers-
|
|
1
|
+
{"version":3,"file":"removeUnverifiedRequestIdentifiers-B8iIreP4.mjs","names":[],"sources":["../src/lib/requests/removeUnverifiedRequestIdentifiers.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n fetchAllRequestIdentifierMetadata,\n makeGraphQLRequest,\n REMOVE_REQUEST_IDENTIFIERS,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { fetchAllRequests } from '../graphql/index.js';\n\n/**\n * Remove a set of unverified request identifier\n *\n * @param options - Options\n * @returns Number of items marked as completed\n */\nexport async function removeUnverifiedRequestIdentifiers({\n requestActions,\n identifierNames,\n auth,\n concurrency = 20,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The request actions that should be restarted */\n requestActions: RequestAction[];\n /** Transcend API key authentication */\n auth: string;\n /** The set of identifier names to remove */\n identifierNames: string[];\n /** Concurrency to upload requests in parallel */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Pull in the requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses: [RequestStatus.Enriching],\n });\n\n // Notify Transcend\n logger.info(colors.magenta('Fetched requests in preflight/enriching state.'));\n\n let total = 0;\n let processed = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToRestart) => {\n const requestIdentifiers = await fetchAllRequestIdentifierMetadata(client, {\n filterBy: { requestId: requestToRestart.id },\n logger,\n });\n const clearOut = requestIdentifiers\n .filter(\n ({ isVerifiedAtLeastOnce, name }) =>\n isVerifiedAtLeastOnce === false && identifierNames.includes(name),\n )\n .map(({ id }) => id);\n\n if (clearOut.length > 0) {\n await makeGraphQLRequest<{\n /** Whether we successfully uploaded the results */\n success: boolean;\n }>(client, REMOVE_REQUEST_IDENTIFIERS, {\n variables: {\n input: {\n requestId: requestToRestart.id,\n requestIdentifierIds: clearOut,\n },\n },\n logger,\n });\n processed += clearOut.length;\n }\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\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 cleared out unverified identifiers \"${\n totalTime / 1000\n }\" seconds for ${total} requests, ${processed} identifiers were cleared out!`,\n ),\n );\n return allRequests.length;\n}\n"],"mappings":"6bAqBA,eAAsB,EAAmC,CACvD,iBACA,kBACA,OACA,cAAc,GACd,eAAe,GAYG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAG/E,EAAc,MAAM,EAAiB,EAAQ,CACjD,QAAS,EACT,SAAU,CAAC,EAAc,UAAU,CACpC,CAAC,CAGF,EAAO,KAAK,EAAO,QAAQ,iDAAiD,CAAC,CAE7E,IAAI,EAAQ,EACR,EAAY,EAChB,EAAY,MAAM,EAAY,OAAQ,EAAE,CACxC,MAAM,EACJ,EACA,KAAO,IAAqB,CAK1B,IAAM,GAAW,MAJgB,EAAkC,EAAQ,CACzE,SAAU,CAAE,UAAW,EAAiB,GAAI,CAC5C,SACD,CAAC,EAEC,QACE,CAAE,wBAAuB,UACxB,IAA0B,IAAS,EAAgB,SAAS,EAAK,CACpE,CACA,KAAK,CAAE,QAAS,EAAG,CAElB,EAAS,OAAS,IACpB,MAAM,EAGH,EAAQ,EAA4B,CACrC,UAAW,CACT,MAAO,CACL,UAAW,EAAiB,GAC5B,qBAAsB,EACvB,CACF,CACD,SACD,CAAC,CACF,GAAa,EAAS,QAGxB,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EASvB,OAPA,EAAO,KACL,EAAO,MACL,oDACE,EAAY,IACb,gBAAgB,EAAM,aAAa,EAAU,gCAC/C,CACF,CACM,EAAY"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./constants-
|
|
2
|
-
//# sourceMappingURL=retryRequestDataSilos-
|
|
1
|
+
import{a as e}from"./constants-I694qbRg.mjs";import{t}from"./logger-CPu6zbyQ.mjs";import{r as n}from"./fetchAllRequests-BV9K0wXv.mjs";import{RequestStatus as r}from"@transcend-io/privacy-types";import i from"colors";import{map as a}from"@transcend-io/utils";import{RETRY_REQUEST_DATA_SILO as o,buildTranscendGraphQLClient as s,fetchRequestDataSilo as c,makeGraphQLRequest as l}from"@transcend-io/sdk";import u from"cli-progress";async function d({requestActions:d,dataSiloId:f,auth:p,concurrency:m=20,transcendUrl:h=e}){let g=s(h,p),_=new Date().getTime(),v=new u.SingleBar({},u.Presets.shades_classic),y=await n(g,{actions:d,statuses:[r.Compiling,r.Approving]});t.info(i.magenta(`Retrying requests for Data Silo: "${f}", restarting "${y.length}" requests.`));let b=0,x=0;v.start(y.length,0),await a(y,async e=>{try{await l(g,o,{variables:{requestDataSiloId:(await c(g,{logger:t,filterBy:{requestId:e.id,dataSiloId:f}})).id},logger:t})}catch(e){if(!e.message.includes(`Failed to find RequestDataSilo`))throw e;x+=1}b+=1,v.update(b)},{concurrency:m}),v.stop();let S=new Date().getTime()-_;return t.info(i.green(`Successfully notified Transcend in "${S/1e3}" seconds for ${b} requests, ${x} requests were skipped because data silo was not attached to the request!`)),y.length}export{d as t};
|
|
2
|
+
//# sourceMappingURL=retryRequestDataSilos-BQuxZd4C.mjs.map
|
package/dist/{retryRequestDataSilos-_OThvVwU.mjs.map → retryRequestDataSilos-BQuxZd4C.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryRequestDataSilos-
|
|
1
|
+
{"version":3,"file":"retryRequestDataSilos-BQuxZd4C.mjs","names":[],"sources":["../src/lib/requests/retryRequestDataSilos.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n makeGraphQLRequest,\n RETRY_REQUEST_DATA_SILO,\n fetchRequestDataSilo,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { fetchAllRequests } from '../graphql/index.js';\n\n/**\n * Retry a set of RequestDataSilos\n *\n * @param options - Options\n * @returns Number of items marked as completed\n */\nexport async function retryRequestDataSilos({\n requestActions,\n dataSiloId,\n auth,\n concurrency = 20,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The request actions that should be restarted */\n requestActions: RequestAction[];\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** Concurrency to upload requests in parallel */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Pull in the requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses: [RequestStatus.Compiling, RequestStatus.Approving],\n });\n\n // Notify Transcend\n logger.info(\n colors.magenta(\n `Retrying requests for Data Silo: \"${dataSiloId}\", restarting \"${allRequests.length}\" requests.`,\n ),\n );\n\n let total = 0;\n let skipped = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToRestart) => {\n try {\n const requestDataSilo = await fetchRequestDataSilo(client, {\n logger,\n filterBy: { requestId: requestToRestart.id, dataSiloId },\n });\n\n await makeGraphQLRequest<{\n /** Whether we successfully uploaded the results */\n success: boolean;\n }>(client, RETRY_REQUEST_DATA_SILO, {\n variables: { requestDataSiloId: requestDataSilo.id },\n logger,\n });\n } catch (err) {\n // some requests may not have this data silo connected\n if (!err.message.includes('Failed to find RequestDataSilo')) {\n throw err;\n }\n skipped += 1;\n }\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\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 notified Transcend in \"${\n totalTime / 1000\n }\" seconds for ${total} requests, ${skipped} requests were skipped because data silo was not attached to the request!`,\n ),\n );\n return allRequests.length;\n}\n"],"mappings":"6aAqBA,eAAsB,EAAsB,CAC1C,iBACA,aACA,OACA,cAAc,GACd,eAAe,GAYG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAG/E,EAAc,MAAM,EAAiB,EAAQ,CACjD,QAAS,EACT,SAAU,CAAC,EAAc,UAAW,EAAc,UAAU,CAC7D,CAAC,CAGF,EAAO,KACL,EAAO,QACL,qCAAqC,EAAW,iBAAiB,EAAY,OAAO,aACrF,CACF,CAED,IAAI,EAAQ,EACR,EAAU,EACd,EAAY,MAAM,EAAY,OAAQ,EAAE,CACxC,MAAM,EACJ,EACA,KAAO,IAAqB,CAC1B,GAAI,CAMF,MAAM,EAGH,EAAQ,EAAyB,CAClC,UAAW,CAAE,mBAAmB,MATJ,EAAqB,EAAQ,CACzD,SACA,SAAU,CAAE,UAAW,EAAiB,GAAI,aAAY,CACzD,CAAC,EAMgD,GAAI,CACpD,SACD,CAAC,OACK,EAAK,CAEZ,GAAI,CAAC,EAAI,QAAQ,SAAS,iCAAiC,CACzD,MAAM,EAER,GAAW,EAGb,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EASvB,OAPA,EAAO,KACL,EAAO,MACL,uCACE,EAAY,IACb,gBAAgB,EAAM,aAAa,EAAQ,2EAC7C,CACF,CACM,EAAY"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{c as e,i as t,l as n,o as r,s as i}from"./policy-runtime-6jmkXlBk.mjs";import{n as a}from"./inquirer-DK1JbPA0.mjs";import{r as o}from"./prompts-BhXfYD6g.mjs";import s from"node:path";import c from"colors";function l(e,t){return[e.stdout.trim(),e.stderr.trim()].filter(Boolean).join(`
|
|
2
|
+
`)||t}function u(e,t){return[...new Set(e.split(/\r?\n/gu).map(e=>e.trim()).filter(Boolean).map(e=>s.isAbsolute(e)?s.relative(t,e).split(s.sep).join(`/`):e.split(s.sep).join(`/`)))].sort()}async function d(a,o){let s=[],c=null,u=null,d=`failed`,f=`failed`,p=await o(`opa`,[`version`],{cwd:a},this);if(p.error?.code===`ENOENT`)s.push({code:`opa.missing`,message:t});else{let t=`${p.stdout}\n${p.stderr}`,n=e(t);p.code!==0||n?s.push({code:`opa.version`,message:n??l(p,`Unable to determine the installed OPA version.`)}):(c=i(t).version,d=`passed`)}let m=await o(`regal`,[`version`],{cwd:a},this);if(m.error?.code===`ENOENT`)s.push({code:`regal.missing`,message:r});else{let e=`${m.stdout}\n${m.stderr}`,t=n(e);m.code!==0||t?s.push({code:`regal.version`,message:t??l(m,`Unable to determine the installed Regal version.`)}):(u=i(e).version,f=`passed`)}return{opa:c,regal:u,diagnostics:s,opaStatus:d,regalStatus:f}}async function f({resolvedDir:e,fix:t,noInteractive:n,json:r,fixCommandHint:i,runner:s}){let d=await s(`opa`,[`fmt`,`--list`,e],{cwd:e},this);if(d.code!==0)return{status:`failed`,unformattedFiles:[],fixedFiles:[],diagnostics:[{code:`opa.format`,message:l(d,`opa fmt --list failed with exit code ${d.code}`)}]};let f=u(d.stdout,e);if(f.length===0)return{status:`passed`,unformattedFiles:[],fixedFiles:[],diagnostics:[]};let p=t,m=o({json:r,noInteractive:n},this.process.stdin.isTTY,this.process.stderr.isTTY);if(!r&&!t){this.logger.error(c.red(`Policy files are not formatted:`)),f.forEach(e=>{this.logger.error(c.red(` - ${e}`))});let t=await s(`opa`,[`fmt`,`--diff`,e],{cwd:e},this),n=t.stdout.trim()||t.stderr.trim();n&&(this.logger.error(``),this.logger.error(n))}if(!t&&m)try{p=await a({message:`Format the unformatted policy files listed above?`})}catch(e){let t=e instanceof Error?e.message:String(e);throw/force closed|prompt.*cancel|user.*close|SIGINT/iu.test(t)&&this.process.exit(130),e}if(p){let t=await s(`opa`,[`fmt`,`--write`,e],{cwd:e},this);return t.code===0?{status:`passed`,unformattedFiles:f,fixedFiles:[...f],diagnostics:[]}:{status:`failed`,unformattedFiles:f,fixedFiles:[],diagnostics:[{code:`opa.format-fix`,message:l(t,`opa fmt --write failed with exit code ${t.code}`)}]}}return{status:`failed`,unformattedFiles:f,fixedFiles:[],diagnostics:[{code:`opa.format-required`,message:`Policy files are not formatted. Re-run \`${i}\` to repair them.`}]}}function p(e,t){let n=t;for(;;){let t=s.join(n,`.regal`,`config.yaml`);if(e.fs.existsSync(t))return t;let r=s.join(n,`.regal.yaml`);if(e.fs.existsSync(r))return r;let i=s.dirname(n);if(i===n)return;n=i}}async function m({resolvedDir:e,runner:t}){let n=p(this,e),r=await t(`regal`,[`lint`,`--fail-level`,`warning`,...n?[`--config-file`,n]:[],e],{cwd:e},this);return r.code===0?{status:`passed`,diagnostics:[]}:{status:`failed`,diagnostics:[{code:`regal.lint`,message:l(r,`regal lint failed with exit code ${r.code}`)}]}}export{l as i,f as n,d as r,m as t};
|
|
3
|
+
//# sourceMappingURL=runRegalLintStep-DPaMm7Gg.mjs.map
|