@transcend-io/cli 10.23.8 → 10.24.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 +4 -149
- package/dist/{app-DZSLD7Zd.mjs → app-CEnc-Nu_.mjs} +19 -19
- package/dist/{app-DZSLD7Zd.mjs.map → app-CEnc-Nu_.mjs.map} +1 -1
- package/dist/{approvePrivacyRequests-hhD_2eJf.mjs → approvePrivacyRequests-CFRmsV6_.mjs} +2 -2
- package/dist/{approvePrivacyRequests-hhD_2eJf.mjs.map → approvePrivacyRequests-CFRmsV6_.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-Cnrp7JLV.mjs → buildExamples-C5Qixoo3.mjs} +2 -2
- package/dist/{buildExamples-Cnrp7JLV.mjs.map → buildExamples-C5Qixoo3.mjs.map} +1 -1
- package/dist/{buildXdiSyncEndpoint-sYqyWMOz.mjs → buildXdiSyncEndpoint-CluKDQfe.mjs} +2 -2
- package/dist/{buildXdiSyncEndpoint-sYqyWMOz.mjs.map → buildXdiSyncEndpoint-CluKDQfe.mjs.map} +1 -1
- package/dist/{bulkRestartRequests-j6w5C-Yl.mjs → bulkRestartRequests-BtVqUJT_.mjs} +2 -2
- package/dist/{bulkRestartRequests-j6w5C-Yl.mjs.map → bulkRestartRequests-BtVqUJT_.mjs.map} +1 -1
- package/dist/{bulkRetryEnrichers-4f6JgEy5.mjs → bulkRetryEnrichers-Q6u3zkse.mjs} +2 -2
- package/dist/{bulkRetryEnrichers-4f6JgEy5.mjs.map → bulkRetryEnrichers-Q6u3zkse.mjs.map} +1 -1
- package/dist/{cancelPrivacyRequests-CuAvkjPr.mjs → cancelPrivacyRequests-CBJb09I0.mjs} +2 -2
- package/dist/{cancelPrivacyRequests-CuAvkjPr.mjs.map → cancelPrivacyRequests-CBJb09I0.mjs.map} +1 -1
- package/dist/codecs-HQHBtqht.mjs +2 -0
- package/dist/codecs-HQHBtqht.mjs.map +1 -0
- package/dist/{command-DwHmc02K.mjs → command-B-Wbg7NG.mjs} +2 -2
- package/dist/{command-DwHmc02K.mjs.map → command-B-Wbg7NG.mjs.map} +1 -1
- package/dist/constants-BRGOkSyL.mjs +2 -0
- package/dist/constants-BRGOkSyL.mjs.map +1 -0
- package/dist/{constants-ykNINvFg.mjs → constants-C9xZJ9YW.mjs} +2 -2
- package/dist/{constants-ykNINvFg.mjs.map → constants-C9xZJ9YW.mjs.map} +1 -1
- package/dist/{constants-B44yUGaB.mjs → constants-DNF09zFX.mjs} +3 -3
- package/dist/{constants-B44yUGaB.mjs.map → constants-DNF09zFX.mjs.map} +1 -1
- package/dist/{createExtraKeyHandler-CRxI4Ado.mjs → createExtraKeyHandler-CUmHemC-.mjs} +2 -2
- package/dist/{createExtraKeyHandler-CRxI4Ado.mjs.map → createExtraKeyHandler-CUmHemC-.mjs.map} +1 -1
- package/dist/{downloadPrivacyRequestFiles-ATBxJH1e.mjs → downloadPrivacyRequestFiles-Q7yjKWw5.mjs} +2 -2
- package/dist/{downloadPrivacyRequestFiles-ATBxJH1e.mjs.map → downloadPrivacyRequestFiles-Q7yjKWw5.mjs.map} +1 -1
- package/dist/enums-UlIe_AeF.mjs +2 -0
- package/dist/enums-UlIe_AeF.mjs.map +1 -0
- package/dist/{fetchAllRequests-Bya6iwzL.mjs → fetchAllRequests-DP24WqrP.mjs} +2 -2
- package/dist/{fetchAllRequests-Bya6iwzL.mjs.map → fetchAllRequests-DP24WqrP.mjs.map} +1 -1
- package/dist/{fuzzyMatchColumns-Ds0TqtJ5.mjs → fuzzyMatchColumns-C1STZ_T1.mjs} +2 -2
- package/dist/{fuzzyMatchColumns-Ds0TqtJ5.mjs.map → fuzzyMatchColumns-C1STZ_T1.mjs.map} +1 -1
- package/dist/{generateCrossAccountApiKeys-DshdzdNz.mjs → generateCrossAccountApiKeys-BgH7sl_l.mjs} +2 -2
- package/dist/{generateCrossAccountApiKeys-DshdzdNz.mjs.map → generateCrossAccountApiKeys-BgH7sl_l.mjs.map} +1 -1
- package/dist/{impl-XOp8GnrL.mjs → impl-1m4lrA4w.mjs} +2 -2
- package/dist/{impl-XOp8GnrL.mjs.map → impl-1m4lrA4w.mjs.map} +1 -1
- package/dist/{impl-BbYjouAP.mjs → impl-B7EZYaor.mjs} +2 -2
- package/dist/{impl-BbYjouAP.mjs.map → impl-B7EZYaor.mjs.map} +1 -1
- package/dist/{impl-DEMY1lQi2.mjs → impl-BAvLMjQi2.mjs} +2 -2
- package/dist/{impl-DEMY1lQi2.mjs.map → impl-BAvLMjQi2.mjs.map} +1 -1
- package/dist/{impl-D8O-FWCh2.mjs → impl-BCMRCTM42.mjs} +2 -2
- package/dist/{impl-D8O-FWCh2.mjs.map → impl-BCMRCTM42.mjs.map} +1 -1
- package/dist/{impl-DK3TWXv_.mjs → impl-BDqOMoB2.mjs} +2 -2
- package/dist/{impl-DK3TWXv_.mjs.map → impl-BDqOMoB2.mjs.map} +1 -1
- package/dist/{impl-C5RWQxAV.mjs → impl-BF9Ekyjn.mjs} +2 -2
- package/dist/{impl-C5RWQxAV.mjs.map → impl-BF9Ekyjn.mjs.map} +1 -1
- package/dist/{impl-B76khOE7.mjs → impl-BJVn23x5.mjs} +2 -2
- package/dist/{impl-B76khOE7.mjs.map → impl-BJVn23x5.mjs.map} +1 -1
- package/dist/{impl-Cr2Ir47_.mjs → impl-BMmNVfdJ.mjs} +2 -2
- package/dist/{impl-Cr2Ir47_.mjs.map → impl-BMmNVfdJ.mjs.map} +1 -1
- package/dist/{impl-BtuIVPDm2.mjs → impl-BUWrRWyd2.mjs} +2 -2
- package/dist/{impl-BtuIVPDm2.mjs.map → impl-BUWrRWyd2.mjs.map} +1 -1
- package/dist/{impl-CdZ-nr1b.mjs → impl-Bgg6AZQS.mjs} +4 -4
- package/dist/{impl-CdZ-nr1b.mjs.map → impl-Bgg6AZQS.mjs.map} +1 -1
- package/dist/{impl-C-OjUv4u.mjs → impl-BhJjrC0k.mjs} +2 -2
- package/dist/{impl-C-OjUv4u.mjs.map → impl-BhJjrC0k.mjs.map} +1 -1
- package/dist/{impl-DJC-VIp42.mjs → impl-BlzePr452.mjs} +2 -2
- package/dist/{impl-DJC-VIp42.mjs.map → impl-BlzePr452.mjs.map} +1 -1
- package/dist/impl-BmLB3P0l.mjs +2 -0
- package/dist/{impl-pEfJLCEa.mjs.map → impl-BmLB3P0l.mjs.map} +1 -1
- package/dist/{impl-BQw1FEg8.mjs → impl-BuIIMGEW.mjs} +2 -2
- package/dist/{impl-BQw1FEg8.mjs.map → impl-BuIIMGEW.mjs.map} +1 -1
- package/dist/{impl-BbIP694E.mjs → impl-BvLjryD7.mjs} +2 -2
- package/dist/{impl-BbIP694E.mjs.map → impl-BvLjryD7.mjs.map} +1 -1
- package/dist/{impl-CjEGfVkB2.mjs → impl-C-EJ0OgG2.mjs} +2 -2
- package/dist/{impl-CjEGfVkB2.mjs.map → impl-C-EJ0OgG2.mjs.map} +1 -1
- package/dist/{impl-CiA-v1ol.mjs → impl-C8azdMaD.mjs} +2 -2
- package/dist/{impl-CiA-v1ol.mjs.map → impl-C8azdMaD.mjs.map} +1 -1
- package/dist/{impl-BMHxBLc9.mjs → impl-CMy3oVzy.mjs} +2 -2
- package/dist/{impl-BMHxBLc9.mjs.map → impl-CMy3oVzy.mjs.map} +1 -1
- package/dist/{impl-g9N2A5pD2.mjs → impl-CdyQGZz92.mjs} +2 -2
- package/dist/{impl-g9N2A5pD2.mjs.map → impl-CdyQGZz92.mjs.map} +1 -1
- package/dist/{impl-z5dBnPm5.mjs → impl-CtbuXbCF.mjs} +3 -3
- package/dist/{impl-z5dBnPm5.mjs.map → impl-CtbuXbCF.mjs.map} +1 -1
- package/dist/{impl-CSJ2N_Ir2.mjs → impl-CtlHGmIq2.mjs} +2 -2
- package/dist/{impl-CSJ2N_Ir2.mjs.map → impl-CtlHGmIq2.mjs.map} +1 -1
- package/dist/{impl-BWenu3QG.mjs → impl-D-JYZ74k.mjs} +6 -6
- package/dist/{impl-BWenu3QG.mjs.map → impl-D-JYZ74k.mjs.map} +1 -1
- package/dist/{impl-C69Nh_YS.mjs → impl-D9VysVCe.mjs} +2 -2
- package/dist/{impl-C69Nh_YS.mjs.map → impl-D9VysVCe.mjs.map} +1 -1
- package/dist/{impl-CURLfWZf2.mjs → impl-DGINIoCJ2.mjs} +2 -2
- package/dist/{impl-CURLfWZf2.mjs.map → impl-DGINIoCJ2.mjs.map} +1 -1
- package/dist/{impl-DvbLtWTm.mjs → impl-DHMG3jYs.mjs} +2 -2
- package/dist/{impl-DvbLtWTm.mjs.map → impl-DHMG3jYs.mjs.map} +1 -1
- package/dist/{impl-C5qBXz5m.mjs → impl-DS_GASDh.mjs} +2 -2
- package/dist/{impl-C5qBXz5m.mjs.map → impl-DS_GASDh.mjs.map} +1 -1
- package/dist/{impl-BlLlNM7E.mjs → impl-DTibva_h.mjs} +2 -2
- package/dist/{impl-BlLlNM7E.mjs.map → impl-DTibva_h.mjs.map} +1 -1
- package/dist/{impl-DMtn2boK.mjs → impl-DUHcGmOB.mjs} +2 -2
- package/dist/{impl-DMtn2boK.mjs.map → impl-DUHcGmOB.mjs.map} +1 -1
- package/dist/{impl-Bu7tLm_r2.mjs → impl-DVDYa4nY2.mjs} +2 -2
- package/dist/{impl-Bu7tLm_r2.mjs.map → impl-DVDYa4nY2.mjs.map} +1 -1
- package/dist/{impl-BTVlQk44.mjs → impl-DXaJO0Be.mjs} +2 -2
- package/dist/{impl-BTVlQk44.mjs.map → impl-DXaJO0Be.mjs.map} +1 -1
- package/dist/impl-DgkExXp2.mjs +2 -0
- package/dist/{impl-DQ-kymSs.mjs.map → impl-DgkExXp2.mjs.map} +1 -1
- package/dist/{impl-DFS1gsy22.mjs → impl-DvNqAXGT2.mjs} +2 -2
- package/dist/{impl-DFS1gsy22.mjs.map → impl-DvNqAXGT2.mjs.map} +1 -1
- package/dist/{impl-D4Hkgaot2.mjs → impl-DyafKnkC2.mjs} +2 -2
- package/dist/{impl-D4Hkgaot2.mjs.map → impl-DyafKnkC2.mjs.map} +1 -1
- package/dist/{impl-Hh10oJIo2.mjs → impl-E4gkfRn62.mjs} +2 -2
- package/dist/{impl-Hh10oJIo2.mjs.map → impl-E4gkfRn62.mjs.map} +1 -1
- package/dist/{impl-DAw16pQt2.mjs → impl-QPZxf2r12.mjs} +2 -2
- package/dist/{impl-DAw16pQt2.mjs.map → impl-QPZxf2r12.mjs.map} +1 -1
- package/dist/{impl-Cp0-VLGQ.mjs → impl-XAperaA4.mjs} +2 -2
- package/dist/{impl-Cp0-VLGQ.mjs.map → impl-XAperaA4.mjs.map} +1 -1
- package/dist/{impl-BBV4vPP_2.mjs → impl-ZThj9UJR2.mjs} +2 -2
- package/dist/{impl-BBV4vPP_2.mjs.map → impl-ZThj9UJR2.mjs.map} +1 -1
- package/dist/{impl-DxedWglk.mjs → impl-apM0F6S8.mjs} +2 -2
- package/dist/{impl-DxedWglk.mjs.map → impl-apM0F6S8.mjs.map} +1 -1
- package/dist/{impl-CG447cmJ2.mjs → impl-b-f7EHNd2.mjs} +2 -2
- package/dist/{impl-CG447cmJ2.mjs.map → impl-b-f7EHNd2.mjs.map} +1 -1
- package/dist/{impl-CNMCdcui2.mjs → impl-k7qZIvQv2.mjs} +2 -2
- package/dist/{impl-CNMCdcui2.mjs.map → impl-k7qZIvQv2.mjs.map} +1 -1
- package/dist/{impl-YnuTTo-82.mjs → impl-ke0B8AS62.mjs} +2 -2
- package/dist/{impl-YnuTTo-82.mjs.map → impl-ke0B8AS62.mjs.map} +1 -1
- package/dist/{impl-BOQdMQ9g.mjs → impl-umRpmzyN.mjs} +2 -2
- package/dist/{impl-BOQdMQ9g.mjs.map → impl-umRpmzyN.mjs.map} +1 -1
- package/dist/{impl-BO2Eujga.mjs → impl-xbezKzrD.mjs} +2 -2
- package/dist/{impl-BO2Eujga.mjs.map → impl-xbezKzrD.mjs.map} +1 -1
- package/dist/index.d.mts +70 -628
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/{inquirer-AEchly0b.mjs → inquirer-B0OF_nRe.mjs} +2 -2
- package/dist/{inquirer-AEchly0b.mjs.map → inquirer-B0OF_nRe.mjs.map} +1 -1
- package/dist/{markRequestDataSiloIdsCompleted-CBt4i1QN.mjs → markRequestDataSiloIdsCompleted-CRFzgT1M.mjs} +2 -2
- package/dist/{markRequestDataSiloIdsCompleted-CBt4i1QN.mjs.map → markRequestDataSiloIdsCompleted-CRFzgT1M.mjs.map} +1 -1
- package/dist/{markSilentPrivacyRequests-KZal6Opm.mjs → markSilentPrivacyRequests-C6JvvCwA.mjs} +2 -2
- package/dist/{markSilentPrivacyRequests-KZal6Opm.mjs.map → markSilentPrivacyRequests-C6JvvCwA.mjs.map} +1 -1
- package/dist/{notifyPrivacyRequestsAdditionalTime-B6TzDKUV.mjs → notifyPrivacyRequestsAdditionalTime-BjkY34ky.mjs} +2 -2
- package/dist/{notifyPrivacyRequestsAdditionalTime-B6TzDKUV.mjs.map → notifyPrivacyRequestsAdditionalTime-BjkY34ky.mjs.map} +1 -1
- package/dist/parseVariablesFromString-6ZwJyWSu.mjs +3 -0
- package/dist/parseVariablesFromString-6ZwJyWSu.mjs.map +1 -0
- package/dist/{pullChunkedCustomSiloOutstandingIdentifiers-A-Z4EQMp.mjs → pullChunkedCustomSiloOutstandingIdentifiers-BNzirY7h.mjs} +2 -2
- package/dist/{pullChunkedCustomSiloOutstandingIdentifiers-A-Z4EQMp.mjs.map → pullChunkedCustomSiloOutstandingIdentifiers-BNzirY7h.mjs.map} +1 -1
- package/dist/{pullManualEnrichmentIdentifiersToCsv-BzxaTka2.mjs → pullManualEnrichmentIdentifiersToCsv-CJ-RzL_W.mjs} +2 -2
- package/dist/{pullManualEnrichmentIdentifiersToCsv-BzxaTka2.mjs.map → pullManualEnrichmentIdentifiersToCsv-CJ-RzL_W.mjs.map} +1 -1
- package/dist/pullTranscendConfiguration-C21Yq51h.mjs +58 -0
- package/dist/pullTranscendConfiguration-C21Yq51h.mjs.map +1 -0
- package/dist/{pushCronIdentifiersFromCsv-p6h-NCbw.mjs → pushCronIdentifiersFromCsv-DFpAUerC.mjs} +2 -2
- package/dist/{pushCronIdentifiersFromCsv-p6h-NCbw.mjs.map → pushCronIdentifiersFromCsv-DFpAUerC.mjs.map} +1 -1
- package/dist/{pushManualEnrichmentIdentifiersFromCsv-HkQoMTNw.mjs → pushManualEnrichmentIdentifiersFromCsv-CncYwlfj.mjs} +2 -2
- package/dist/{pushManualEnrichmentIdentifiersFromCsv-HkQoMTNw.mjs.map → pushManualEnrichmentIdentifiersFromCsv-CncYwlfj.mjs.map} +1 -1
- package/dist/readCsv--FfP8n-H.mjs +2 -0
- package/dist/{readCsv-C84Jhrzx.mjs.map → readCsv--FfP8n-H.mjs.map} +1 -1
- package/dist/{readTranscendYaml-dI3G3Og9.mjs → readTranscendYaml-CWIS9ki1.mjs} +3 -3
- package/dist/{readTranscendYaml-dI3G3Og9.mjs.map → readTranscendYaml-CWIS9ki1.mjs.map} +1 -1
- package/dist/{removeUnverifiedRequestIdentifiers-Ba96pjVd.mjs → removeUnverifiedRequestIdentifiers-C10H-SXP.mjs} +2 -2
- package/dist/{removeUnverifiedRequestIdentifiers-Ba96pjVd.mjs.map → removeUnverifiedRequestIdentifiers-C10H-SXP.mjs.map} +1 -1
- package/dist/{retryRequestDataSilos-CHVwnmWX.mjs → retryRequestDataSilos-BHBF_efU.mjs} +2 -2
- package/dist/{retryRequestDataSilos-CHVwnmWX.mjs.map → retryRequestDataSilos-BHBF_efU.mjs.map} +1 -1
- package/dist/{skipPreflightJobs-BUkkg1Tu.mjs → skipPreflightJobs-myWphrMG.mjs} +2 -2
- package/dist/{skipPreflightJobs-BUkkg1Tu.mjs.map → skipPreflightJobs-myWphrMG.mjs.map} +1 -1
- package/dist/{skipRequestDataSilos-CiYe8sWw.mjs → skipRequestDataSilos-B-rKjXXQ.mjs} +2 -2
- package/dist/{skipRequestDataSilos-CiYe8sWw.mjs.map → skipRequestDataSilos-B-rKjXXQ.mjs.map} +1 -1
- package/dist/{streamPrivacyRequestsToCsv-C5s3sEvM.mjs → streamPrivacyRequestsToCsv-DMg8lq8p.mjs} +2 -2
- package/dist/{streamPrivacyRequestsToCsv-C5s3sEvM.mjs.map → streamPrivacyRequestsToCsv-DMg8lq8p.mjs.map} +1 -1
- package/dist/{updateConsentManagerVersionToLatest-CcKQntwQ.mjs → updateConsentManagerVersionToLatest-DwXxt7ky.mjs} +2 -2
- package/dist/{updateConsentManagerVersionToLatest-CcKQntwQ.mjs.map → updateConsentManagerVersionToLatest-DwXxt7ky.mjs.map} +1 -1
- package/dist/{uploadConsents-CzKKRVfa.mjs → uploadConsents-D7yIkRw8.mjs} +2 -2
- package/dist/{uploadConsents-CzKKRVfa.mjs.map → uploadConsents-D7yIkRw8.mjs.map} +1 -1
- package/dist/{uploadCookiesFromCsv-DGL_OBLV.mjs → uploadCookiesFromCsv-DFu7YhFQ.mjs} +2 -2
- package/dist/{uploadCookiesFromCsv-DGL_OBLV.mjs.map → uploadCookiesFromCsv-DFu7YhFQ.mjs.map} +1 -1
- package/dist/{uploadDataFlowsFromCsv-BfRys5XH.mjs → uploadDataFlowsFromCsv-DETWx8Bg.mjs} +2 -2
- package/dist/{uploadDataFlowsFromCsv-BfRys5XH.mjs.map → uploadDataFlowsFromCsv-DETWx8Bg.mjs.map} +1 -1
- package/dist/{uploadPrivacyRequestsFromCsv-6Q7zYhbN.mjs → uploadPrivacyRequestsFromCsv-HUqJ-bti.mjs} +2 -2
- package/dist/{uploadPrivacyRequestsFromCsv-6Q7zYhbN.mjs.map → uploadPrivacyRequestsFromCsv-HUqJ-bti.mjs.map} +1 -1
- package/dist/validateTranscendAuth-CbYKgCP5.mjs +2 -0
- package/dist/{validateTranscendAuth-DhzCBA3F.mjs.map → validateTranscendAuth-CbYKgCP5.mjs.map} +1 -1
- package/package.json +5 -7
- package/dist/codecs-Dch3sv5m.mjs +0 -2
- package/dist/codecs-Dch3sv5m.mjs.map +0 -1
- package/dist/constants-KDQK82Fx.mjs +0 -2
- package/dist/constants-KDQK82Fx.mjs.map +0 -1
- package/dist/enums-BymyVyqr.mjs +0 -2
- package/dist/enums-BymyVyqr.mjs.map +0 -1
- package/dist/impl-DQ-kymSs.mjs +0 -2
- package/dist/impl-pEfJLCEa.mjs +0 -2
- package/dist/parseVariablesFromString-RM3zV9Av.mjs +0 -3
- package/dist/parseVariablesFromString-RM3zV9Av.mjs.map +0 -1
- package/dist/pullTranscendConfiguration-C2LAOKG4.mjs +0 -58
- package/dist/pullTranscendConfiguration-C2LAOKG4.mjs.map +0 -1
- package/dist/readCsv-C84Jhrzx.mjs +0 -2
- package/dist/validateTranscendAuth-DhzCBA3F.mjs +0 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,t as a}from"./enums-BymyVyqr.mjs";import{a as o,c as s,d as c,f as l,g as u,h as d,i as f,l as p,m,n as h,o as g,p as _,r as v,s as y,t as b,u as x}from"./constants-KDQK82Fx.mjs";import{t as S}from"./logger-Ckep4QXn.mjs";import{$ as ee,A as te,B as ne,C as re,Ct as ie,D as ae,E as oe,F as se,G as ce,H as le,I as ue,J as de,K as fe,L as pe,M as me,N as he,O as ge,P as _e,Q as ve,R as ye,S as be,St as xe,T as C,U as w,V as T,W as E,X as D,Y as O,Z as k,_ as A,_t as j,a as M,at as Se,b as Ce,bt as we,c as Te,ct as Ee,d as De,dt as Oe,et as ke,f as Ae,ft as je,g as Me,gt as Ne,h as Pe,ht as Fe,i as Ie,it as Le,j as Re,k as ze,l as Be,lt as Ve,m as He,mt as Ue,n as We,nt as Ge,o as Ke,ot as qe,p as Je,pt as Ye,q as Xe,r as Ze,rt as Qe,s as $e,st as et,t as tt,tt as nt,u as rt,ut as it,v as at,vt as ot,w as st,wt as ct,x as lt,xt as ut,y as dt,yt as ft,z as pt}from"./codecs-Dch3sv5m.mjs";import{a as mt,i as ht,n as gt,r as _t,t as vt}from"./readTranscendYaml-dI3G3Og9.mjs";import{a as yt,i as bt,n as xt,r as St,t as Ct}from"./parseVariablesFromString-RM3zV9Av.mjs";import{a as wt,c as Tt,i as Et,l as Dt,n as Ot,o as kt,r as At,s as jt,t as Mt,u as Nt}from"./constants-ykNINvFg.mjs";import{n as Pt,t as Ft}from"./fuzzyMatchColumns-Ds0TqtJ5.mjs";import{a as It,c as Lt,d as Rt,f as zt,i as Bt,l as Vt,n as Ht,o as Ut,r as Wt,s as Gt,t as Kt,u as qt}from"./uploadPrivacyRequestsFromCsv-6Q7zYhbN.mjs";import{n as Jt,t as Yt}from"./parseAttributesFromString-CYcxsS3n.mjs";import{t as Xt}from"./readCsv-C84Jhrzx.mjs";import{n as Zt,t as Qt}from"./pullUnstructuredSubDataPointRecommendations-B9xIDPf2.mjs";import{a as $t,i as en,n as tn,o as nn,r as rn,t as an}from"./request-BIplTb3L.mjs";import{i as on,n as sn,r as cn,t as ln}from"./pullTranscendConfiguration-C2LAOKG4.mjs";import{i as un,n as dn,r as N,t as fn}from"./fetchAllRequests-Bya6iwzL.mjs";import{a as pn,i as mn,n as hn,r as gn,t as _n}from"./pullChunkedCustomSiloOutstandingIdentifiers-A-Z4EQMp.mjs";import{n as vn,r as yn,t as bn}from"./syncCodePackages-Dhm5jI6B.mjs";import{t as xn}from"./markSilentPrivacyRequests-KZal6Opm.mjs";import{a as Sn,i as Cn,n as wn,o as Tn,r as En,t as Dn}from"./downloadPrivacyRequestFiles-ATBxJH1e.mjs";import{n as On,r as kn,t as An}from"./extractClientError-X9wJVqGq.mjs";import{t as jn}from"./approvePrivacyRequests-hhD_2eJf.mjs";import{t as Mn}from"./notifyPrivacyRequestsAdditionalTime-B6TzDKUV.mjs";import{t as Nn}from"./cancelPrivacyRequests-CuAvkjPr.mjs";import{n as Pn,t as Fn}from"./bulkRestartRequests-j6w5C-Yl.mjs";import{t as In}from"./skipPreflightJobs-BUkkg1Tu.mjs";import{t as Ln}from"./bulkRetryEnrichers-4f6JgEy5.mjs";import{t as Rn}from"./retryRequestDataSilos-CHVwnmWX.mjs";import{n as P,r as F,t as zn}from"./streamPrivacyRequestsToCsv-C5s3sEvM.mjs";import{n as Bn,r as Vn,t as Hn}from"./inquirer-AEchly0b.mjs";import{t as Un}from"./collectParquetFilesOrExit-DyZISY9X.mjs";import{t as Wn}from"./collectCsvFilesOrExit-C8-Pr9Hr.mjs";import{t as Gn}from"./parquetToCsvOneFile-13GirFzy.mjs";import{a as Kn,i as qn,n as Jn,o as Yn,r as Xn,s as Zn,t as Qn}from"./writeCsv-BMVkiMHM.mjs";import{t as $n}from"./skipRequestDataSilos-CiYe8sWw.mjs";import{t as er}from"./removeUnverifiedRequestIdentifiers-Ba96pjVd.mjs";import{t as tr}from"./updateConsentManagerVersionToLatest-CcKQntwQ.mjs";import{t as nr}from"./uploadDataFlowsFromCsv-BfRys5XH.mjs";import{t as rr}from"./uploadCookiesFromCsv-DGL_OBLV.mjs";import{t as ir}from"./pullConsentManagerMetrics-CR4WwUt6.mjs";import{n as ar,r as or,t as sr}from"./buildXdiSyncEndpoint-sYqyWMOz.mjs";import{t as cr}from"./consentManagersToBusinessEntities-DGzryQ3W.mjs";import{i as lr,n as ur,r as dr,t as fr}from"./uploadConsents-CzKKRVfa.mjs";import{n as pr,r as mr,t as hr}from"./pushCronIdentifiersFromCsv-p6h-NCbw.mjs";import{t as gr}from"./markRequestDataSiloIdsCompleted-CBt4i1QN.mjs";import{t as _r}from"./generateCrossAccountApiKeys-DshdzdNz.mjs";import{t as vr}from"./validateTranscendAuth-DhzCBA3F.mjs";import{t as yr}from"./listFiles-BPx3iDV6.mjs";import{t as br}from"./pullAllDatapoints-Bvv9KRR5.mjs";import{t as xr}from"./pullManualEnrichmentIdentifiersToCsv-BzxaTka2.mjs";import{n as Sr,r as Cr,t as wr}from"./pushManualEnrichmentIdentifiersFromCsv-HkQoMTNw.mjs";import{ChatCompletionRole as I,PromptRunProductArea as L,PromptStatus as R,QueueStatus as z}from"@transcend-io/privacy-types";import{chunk as B,difference as Tr,groupBy as Er,keyBy as V,uniq as Dr}from"lodash-es";import{apply as Or,decodeCodec as H,getValues as kr}from"@transcend-io/type-utils";import{readFileSync as Ar,readdirSync as jr,statSync as Mr}from"node:fs";import{join as Nr}from"node:path";import Pr from"fast-glob";import U from"colors";import{UPDATE_OR_CREATE_COOKIES as Fr,buildTranscendGraphQLClient as W,createSombraGotInstance as Ir,fetchAllAgentFiles as Lr,fetchAllAgents as G,fetchAllLargeLanguageModels as Rr,fetchAllPromptThreads as zr,fetchAllRequestIdentifiers as K,fetchConsentManagerId as Br,fetchPromptsWithVariables as Vr,makeGraphQLRequest as Hr,reportPromptRun as q,validateSombraVersion as Ur}from"@transcend-io/sdk";import{map as J,mapSeries as Y}from"@transcend-io/utils";import{createHandlebarsWithHelpers as X}from"@transcend-io/handlebars-utils";import{execSync as Z}from"child_process";async function Q(e,t){let n=await Br(e,{logger:S});await Y(B(t,100),async t=>{await Hr(e,Fr,{variables:{airgapBundleId:n,cookies:t.map(e=>({name:e.name,trackingPurposes:e.trackingPurposes&&e.trackingPurposes.length>0?e.trackingPurposes:void 0,description:e.description,service:e.service,status:e.status,attributes:e.attributes,isRegex:e.isRegex}))},logger:S})})}async function Wr(e,t){let n=!1;S.info(U.magenta(`Syncing "${t.length}" cookies...`));let r=t.filter(e=>t.filter(t=>e.name===t.name&&e.isRegex===t.isRegex).length>1);if(r.length>0)throw Error(`Failed to upload cookies as there were non-unique entries found: ${r.map(({name:e})=>e).join(`,`)}`);try{S.info(U.magenta(`Upserting "${t.length}" new cookies...`)),await Q(e,t),S.info(U.green(`Successfully synced ${t.length} cookies!`))}catch(e){n=!0,S.error(U.red(`Failed to create cookies! - ${e.message}`))}return!n}async function Gr({auth:e,sombraAuth:t,actions:n=[],statuses:r=[],identifierSearch:i,pageLimit:a=100,concurrency:s=1,transcendUrl:c=o,createdAtBefore:l,skipRequestIdentifiers:u=!1,createdAtAfter:d,updatedAtBefore:f,updatedAtAfter:p,isTest:m}){let h=W(c,e),g=await Ir(c,e,{logger:S,sombraApiKey:t,sombraUrl:process.env.SOMBRA_URL}),_=``;l&&(_+=` before ${l.toISOString()}`),d&&(_+=`${_?`, and`:``} after ${d.toISOString()}`),S.info(U.magenta(`${n.length>0?`Pulling requests of type "${n.join(`" , "`)}"`:`Pulling all requests`}${_}`));let v=s>1&&d&&l,y=v?P(d,l,s):[{createdAtAfter:d,createdAtBefore:l}];v&&S.info(U.magenta(`Splitting date range into ${s} parallel chunks`));let b=(await J(y,e=>N(h,{actions:n,text:i,statuses:r,createdAtBefore:e.createdAtBefore,createdAtAfter:e.createdAtAfter,updatedAtBefore:f,updatedAtAfter:p,isTest:m}),{concurrency:v?s:1})).flat();u||await Ur(h,{logger:S});let x=u?b.map(e=>({...e,requestIdentifiers:[]})):await J(b,async e=>{let t=await K(h,g,{filterBy:{requestId:e.id},skipSombraCheck:!0,logger:S});return{...e,requestIdentifiers:t}},{concurrency:a});return S.info(U.magenta(`Pulled ${x.length} requests`)),{requestsWithRequestIdentifiers:x,requestsFormattedForCsv:x.map(F)}}function Kr(e){try{return e?Ar(e,`utf8`):``}catch{return``}}function qr(e){return jr(e).filter(t=>Mr(Nr(e,t)).isDirectory())}function $(e){return RegExp(`<${e}>([\\s\\S]+?)<\\/${e}>`)}function Jr(e){return e}const Yr=e=>{try{return JSON.parse(e)}catch{return e}};var Xr=class{prompts;handlebarsOptions;promptContentMap;largeLanguageModels=[];agentsByName={};agentsByAgentId={};graphQLClient;defaultVariables;variables;handlebars;transcendApiKey;transcendUrl;requireApproval;cacheDuration;lastUpdatedAt;constructor({prompts:e,handlebarsOptions:t={},transcendUrl:n=o,transcendApiKey:r,requireApproval:i=!0,cacheDuration:a,defaultVariables:s={}}){this.prompts=e,this.transcendUrl=n,this.transcendApiKey=r,this.variables=s,this.defaultVariables=s,this.graphQLClient=W(n,typeof r==`object`?r.release():r),this.requireApproval=i,this.cacheDuration=a,this.handlebarsOptions=t,this.handlebars=X(t)}async fetchPromptsAndMetadata(){let e=kr(this.prompts),t=e.map(({id:e})=>e).filter(e=>!!e),n=e.map(({title:e})=>e).filter(e=>!!e),r=Dr(e.map(({agentNames:e})=>e||[]).flat()),[i,a,o]=await Promise.all([Vr(this.graphQLClient,{logger:S,filterBy:{ids:t,titles:n}}),Rr(this.graphQLClient,{logger:S}),G(this.graphQLClient,{logger:S,filterBy:{names:r}})]);this.agentsByName=V(o,`name`),this.agentsByAgentId=V(o,`agentId`),this.largeLanguageModels=a.filter(e=>e.isTranscendHosted===!1);let s=V(i.prompts,`title`),c=V(i.prompts,`id`);return this.variables={...i.calculatedVariables.reduce((e,t)=>Object.assign(e,{[t.name]:t.data?JSON.parse(t.data):t.data}),{}),...this.defaultVariables},this.handlebars=X({...this.handlebarsOptions,templates:[...this.handlebarsOptions.templates||[],...i.promptPartials.map(e=>({name:e.slug,content:e.content}))]}),this.promptContentMap=Or(this.prompts,({id:e,title:t})=>{let n=e?c[e]:t?s[t]:void 0;if(!n)throw Error(`Failed to find prompt with title: "${t}" and id: "${e}"`);return n}),this.lastUpdatedAt=new Date,i}async getAgentByName(e){let t=this.agentsByName[e];if(t)return t;let[n]=await G(this.graphQLClient,{logger:S,filterBy:{names:[e]}});if(n)return this.agentsByName[n.name]=n,this.agentsByAgentId[n.agentId]=n,n}async getPromptThreadBySlackTs(e){let[t]=await zr(this.graphQLClient,{logger:S,filterBy:{slackMessageTs:[e]}});return t}async getAgentsByName(e){if(e.length<1)throw Error(`Expected at least one name to be provided`);let{hasCache:t=[],missingCache:n=[]}=Er(e,e=>this.agentsByName[e]?`hasCache`:`missingCache`),r=t.map(e=>this.agentsByName[e]);if(n.length===0)return r;let i=B(n,50),a=[];return await Y(i,async e=>{let t=await G(this.graphQLClient,{logger:S,filterBy:{names:e}});t.forEach(e=>{this.agentsByName[e.name]=e,this.agentsByAgentId[e.agentId]=e}),a.push(...t)}),[...r,...a]}getAgentFiles(e){return Lr(this.graphQLClient,{logger:S,filterBy:e})}getLargeLanguageModel(e){let t=this.largeLanguageModels.find(t=>typeof e==`string`?t.id===e:t.name===e.name&&t.client===e.client);if(!t)throw Error(`Failed to find model matching: ${typeof e==`string`?e:JSON.stringify(e)}`);return t}async getPromptDefinition(e){(!this.lastUpdatedAt||this.cacheDuration===0||this.cacheDuration&&Date.now()-this.lastUpdatedAt.getTime()>this.cacheDuration)&&await this.fetchPromptsAndMetadata();let{promptContentMap:t}=this;if(!t)throw Error(`Expected this.promptContentMap to be defined`);let n=t[e];if(!n)throw Error(`Expected this.promptContentMap[${e}] to be defined`);return n}async compilePrompt(e,t){let n=await this.getPromptDefinition(e),r=this.prompts[e];if(!r)throw Error(`Expected this.prompts[${e}] to be defined`);if(this.requireApproval&&n.status!==R.Approved)throw Error(`Assessment "${n.title}" cannot be used because its in status: "${n.status}"`);if(n.status===R.Rejected)throw Error(`Assessment "${n.title}" cannot be used because it's in status: "${n.status}"`);return H(r.paramCodec,t),this.handlebars.compile(n.content)({currentDate:new Date().toISOString(),...this.variables,...t})}parseAiResponse(e,t){let n=this.prompts[e];if(!n)throw Error(`Expected this.prompts[${e}] to be defined`);let r=n.extractFromTag&&($(n.extractFromTag).exec(t)||[])[1]||t;return H(n.outputCodec,Yr(r),!1)}async reportAndParsePromptRun(e,{largeLanguageModel:t,...n}){(!this.lastUpdatedAt||this.cacheDuration===0||this.cacheDuration&&Date.now()-this.lastUpdatedAt.getTime()>this.cacheDuration)&&await this.fetchPromptsAndMetadata();let r=n.name||`@transcend-io/cli-prompt-run-${new Date().toISOString()}`;if(!this.promptContentMap)throw Error(`Expected this.promptContentMap to be defined`);let i=this.promptContentMap[e];if(!i)throw Error(`Expected this.prompts[${e}] to be defined`);if(n.promptRunMessages.length===0)throw Error(`promptRunMessages is expected to have length > 0`);if(n.promptRunMessages[0].role!==I.System)throw Error(`promptRunMessages[0].role is expected to be = ${I.System}`);if(n.promptRunMessages[n.promptRunMessages.length-1].role!==I.Assistant)throw Error(`promptRunMessages[${n.promptRunMessages.length-1}].role is expected to be = ${I.Assistant}`);let a=n.promptRunMessages[n.promptRunMessages.length-1].content,o;try{o=this.parseAiResponse(e,a)}catch(e){throw await q(this.graphQLClient,{productArea:L.PromptManager,...n,name:r,error:e.message,status:z.Error,...typeof t==`string`?{largeLanguageModelId:t}:{largeLanguageModelName:t.name,largeLanguageModelClient:t.client},promptId:i.id,promptRunMessages:n.promptRunMessages.map((e,t)=>({...e,...t===0?{template:i.content}:{}}))},{logger:S}),e}let s=await q(this.graphQLClient,{productArea:L.PromptManager,...n,name:r,status:z.Resolved,...typeof t==`string`?{largeLanguageModelId:t}:{largeLanguageModelName:t.name,largeLanguageModelClient:t.client},promptId:i.id,promptRunMessages:n.promptRunMessages.map((e,t)=>({...e,...t===0?{template:i.content}:{}}))},{logger:S});return{result:o,promptRunId:s,promptRunUrl:`https://app.transcend.io/prompts/runs/${s}`}}async reportPromptRunError(e,{largeLanguageModel:t,...n}){(!this.lastUpdatedAt||this.cacheDuration===0||this.cacheDuration&&Date.now()-this.lastUpdatedAt.getTime()>this.cacheDuration)&&await this.fetchPromptsAndMetadata();let r=n.name||`@transcend-io/cli-prompt-run-${new Date().toISOString()}`;if(!this.promptContentMap)throw Error(`Expected this.promptContentMap to be defined`);let i=this.promptContentMap[e];if(!i)throw Error(`Expected this.prompts[${e}] to be defined`);if(n.promptRunMessages.length===0)throw Error(`promptRunMessages is expected to have length > 0`);if(n.promptRunMessages[0].role!==I.System)throw Error(`promptRunMessages[0].role is expected to be = ${I.System}`);let a=await q(this.graphQLClient,{productArea:L.PromptManager,...n,name:r,status:z.Error,...typeof t==`string`?{largeLanguageModelId:t}:{largeLanguageModelName:t.name,largeLanguageModelClient:t.client},promptId:i.id,promptRunMessages:n.promptRunMessages.map((e,t)=>({...e,...t===0?{template:i.content}:{}}))},{logger:S});return{promptRunId:a,promptRunUrl:`https://app.transcend.io/prompts/runs/${a}`}}};function Zr(e){return e.replace(/(https?:\/\/[^\s]+)/g,`<link-omitted>`)}function Qr(e){return Object.entries(e).reduce((e,[t,n])=>n!=null&&n!==``&&!(Array.isArray(n)&&n.length===0)&&!(typeof n==`object`&&Object.keys(n).length===0)?Object.assign(e,{[t]:n}):e,{})}function $r({baseBranch:e,rootDirectory:t,githubRepo:n,excludedGlob:r=[],fileBlockList:i=[]}){Z(`git fetch origin ${e}`);let a=Z(`git ls-remote ${n} "refs/heads/${e}" | cut -f 1`,{encoding:`utf-8`}).split(`
|
|
2
|
-
`)[0],o=
|
|
3
|
-
`)[0];if(!a||!o)throw Error(`FAILED TO FIND COMMIT RANGE`);let s=
|
|
4
|
-
`).filter(e=>e),i),c=r.length>0?
|
|
1
|
+
import{i as e,n as t,r as n,t as r}from"./enums-UlIe_AeF.mjs";import{a as i,c as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,u as y}from"./constants-BRGOkSyL.mjs";import{t as b}from"./logger-Ckep4QXn.mjs";import{$ as x,A as S,B as ee,C as te,D as ne,E as re,F as ie,G as ae,H as oe,I as se,J as ce,K as C,L as w,M as T,N as E,O as D,P as O,Q as k,R as A,S as j,T as M,U as N,V as P,W as F,X as I,Y as L,Z as R,_ as z,a as B,at as V,b as H,c as U,ct as W,d as G,dt as le,et as ue,f as de,ft as fe,g as pe,h as me,i as he,it as ge,j as _e,k as ve,l as ye,lt as be,m as xe,n as Se,nt as Ce,o as we,ot as Te,p as Ee,pt as De,q as Oe,r as ke,rt as Ae,s as je,st as Me,t as Ne,tt as Pe,u as Fe,ut as Ie,v as Le,w as Re,x as ze,y as Be,z as Ve}from"./codecs-HQHBtqht.mjs";import{a as He,i as Ue,n as We,r as Ge,t as Ke}from"./readTranscendYaml-CWIS9ki1.mjs";import{a as qe,i as Je,n as Ye,r as Xe,t as Ze}from"./parseVariablesFromString-6ZwJyWSu.mjs";import{a as Qe,c as $e,i as et,l as tt,n as nt,o as rt,r as it,s as at,t as ot,u as st}from"./constants-C9xZJ9YW.mjs";import{n as ct,t as lt}from"./fuzzyMatchColumns-C1STZ_T1.mjs";import{a as ut,c as dt,d as ft,f as pt,i as mt,l as ht,n as gt,o as _t,r as vt,s as yt,t as bt,u as xt}from"./uploadPrivacyRequestsFromCsv-HUqJ-bti.mjs";import{n as St,t as Ct}from"./parseAttributesFromString-CYcxsS3n.mjs";import{t as wt}from"./readCsv--FfP8n-H.mjs";import{n as Tt,t as Et}from"./pullUnstructuredSubDataPointRecommendations-B9xIDPf2.mjs";import{a as Dt,i as Ot,n as kt,o as At,r as jt,t as Mt}from"./request-BIplTb3L.mjs";import{i as Nt,n as Pt,r as Ft,t as It}from"./pullTranscendConfiguration-C21Yq51h.mjs";import{i as Lt,n as Rt,r as K,t as zt}from"./fetchAllRequests-DP24WqrP.mjs";import{a as Bt,i as Vt,n as Ht,r as Ut,t as Wt}from"./pullChunkedCustomSiloOutstandingIdentifiers-BNzirY7h.mjs";import{n as Gt,r as Kt,t as qt}from"./syncCodePackages-Dhm5jI6B.mjs";import{t as Jt}from"./markSilentPrivacyRequests-C6JvvCwA.mjs";import{a as Yt,i as Xt,n as Zt,o as Qt,r as $t,t as en}from"./downloadPrivacyRequestFiles-Q7yjKWw5.mjs";import{n as tn,r as nn,t as rn}from"./extractClientError-X9wJVqGq.mjs";import{t as an}from"./approvePrivacyRequests-CFRmsV6_.mjs";import{t as on}from"./notifyPrivacyRequestsAdditionalTime-BjkY34ky.mjs";import{t as sn}from"./cancelPrivacyRequests-CBJb09I0.mjs";import{n as cn,t as ln}from"./bulkRestartRequests-BtVqUJT_.mjs";import{t as un}from"./skipPreflightJobs-myWphrMG.mjs";import{t as dn}from"./bulkRetryEnrichers-Q6u3zkse.mjs";import{t as fn}from"./retryRequestDataSilos-BHBF_efU.mjs";import{n as q,r as J,t as pn}from"./streamPrivacyRequestsToCsv-DMg8lq8p.mjs";import{n as mn,r as hn,t as gn}from"./inquirer-B0OF_nRe.mjs";import{t as _n}from"./collectParquetFilesOrExit-DyZISY9X.mjs";import{t as vn}from"./collectCsvFilesOrExit-C8-Pr9Hr.mjs";import{t as yn}from"./parquetToCsvOneFile-13GirFzy.mjs";import{a as bn,i as xn,n as Sn,o as Cn,r as wn,s as Tn,t as En}from"./writeCsv-BMVkiMHM.mjs";import{t as Dn}from"./skipRequestDataSilos-B-rKjXXQ.mjs";import{t as On}from"./removeUnverifiedRequestIdentifiers-C10H-SXP.mjs";import{t as kn}from"./updateConsentManagerVersionToLatest-DwXxt7ky.mjs";import{t as An}from"./uploadDataFlowsFromCsv-DETWx8Bg.mjs";import{t as jn}from"./uploadCookiesFromCsv-DFu7YhFQ.mjs";import{t as Mn}from"./pullConsentManagerMetrics-CR4WwUt6.mjs";import{n as Nn,r as Pn,t as Fn}from"./buildXdiSyncEndpoint-CluKDQfe.mjs";import{t as In}from"./consentManagersToBusinessEntities-DGzryQ3W.mjs";import{i as Ln,n as Rn,r as zn,t as Bn}from"./uploadConsents-D7yIkRw8.mjs";import{n as Vn,r as Hn,t as Un}from"./pushCronIdentifiersFromCsv-DFpAUerC.mjs";import{t as Wn}from"./markRequestDataSiloIdsCompleted-CRFzgT1M.mjs";import{t as Gn}from"./generateCrossAccountApiKeys-BgH7sl_l.mjs";import{t as Kn}from"./validateTranscendAuth-CbYKgCP5.mjs";import{t as qn}from"./listFiles-BPx3iDV6.mjs";import{t as Jn}from"./pullAllDatapoints-Bvv9KRR5.mjs";import{t as Yn}from"./pullManualEnrichmentIdentifiersToCsv-CJ-RzL_W.mjs";import{n as Xn,r as Zn,t as Qn}from"./pushManualEnrichmentIdentifiersFromCsv-CncYwlfj.mjs";import{chunk as $n,difference as er}from"lodash-es";import{readFileSync as tr,readdirSync as nr,statSync as rr}from"node:fs";import{join as ir}from"node:path";import Y from"fast-glob";import X from"colors";import{UPDATE_OR_CREATE_COOKIES as ar,buildTranscendGraphQLClient as or,createSombraGotInstance as sr,fetchAllRequestIdentifiers as cr,fetchConsentManagerId as lr,makeGraphQLRequest as ur,validateSombraVersion as dr}from"@transcend-io/sdk";import{map as Z,mapSeries as fr}from"@transcend-io/utils";import{execSync as Q}from"child_process";async function $(e,t){let n=await lr(e,{logger:b});await fr($n(t,100),async t=>{await ur(e,ar,{variables:{airgapBundleId:n,cookies:t.map(e=>({name:e.name,trackingPurposes:e.trackingPurposes&&e.trackingPurposes.length>0?e.trackingPurposes:void 0,description:e.description,service:e.service,status:e.status,attributes:e.attributes,isRegex:e.isRegex}))},logger:b})})}async function pr(e,t){let n=!1;b.info(X.magenta(`Syncing "${t.length}" cookies...`));let r=t.filter(e=>t.filter(t=>e.name===t.name&&e.isRegex===t.isRegex).length>1);if(r.length>0)throw Error(`Failed to upload cookies as there were non-unique entries found: ${r.map(({name:e})=>e).join(`,`)}`);try{b.info(X.magenta(`Upserting "${t.length}" new cookies...`)),await $(e,t),b.info(X.green(`Successfully synced ${t.length} cookies!`))}catch(e){n=!0,b.error(X.red(`Failed to create cookies! - ${e.message}`))}return!n}async function mr({auth:e,sombraAuth:t,actions:n=[],statuses:r=[],identifierSearch:a,pageLimit:o=100,concurrency:s=1,transcendUrl:c=i,createdAtBefore:l,skipRequestIdentifiers:u=!1,createdAtAfter:d,updatedAtBefore:f,updatedAtAfter:p,isTest:m}){let h=or(c,e),g=await sr(c,e,{logger:b,sombraApiKey:t,sombraUrl:process.env.SOMBRA_URL}),_=``;l&&(_+=` before ${l.toISOString()}`),d&&(_+=`${_?`, and`:``} after ${d.toISOString()}`),b.info(X.magenta(`${n.length>0?`Pulling requests of type "${n.join(`" , "`)}"`:`Pulling all requests`}${_}`));let v=s>1&&d&&l,y=v?q(d,l,s):[{createdAtAfter:d,createdAtBefore:l}];v&&b.info(X.magenta(`Splitting date range into ${s} parallel chunks`));let x=(await Z(y,e=>K(h,{actions:n,text:a,statuses:r,createdAtBefore:e.createdAtBefore,createdAtAfter:e.createdAtAfter,updatedAtBefore:f,updatedAtAfter:p,isTest:m}),{concurrency:v?s:1})).flat();u||await dr(h,{logger:b});let S=u?x.map(e=>({...e,requestIdentifiers:[]})):await Z(x,async e=>{let t=await cr(h,g,{filterBy:{requestId:e.id},skipSombraCheck:!0,logger:b});return{...e,requestIdentifiers:t}},{concurrency:o});return b.info(X.magenta(`Pulled ${S.length} requests`)),{requestsWithRequestIdentifiers:S,requestsFormattedForCsv:S.map(J)}}function hr(e){try{return e?tr(e,`utf8`):``}catch{return``}}function gr(e){return nr(e).filter(t=>rr(ir(e,t)).isDirectory())}function _r(e){return e.replace(/(https?:\/\/[^\s]+)/g,`<link-omitted>`)}function vr(e){return Object.entries(e).reduce((e,[t,n])=>n!=null&&n!==``&&!(Array.isArray(n)&&n.length===0)&&!(typeof n==`object`&&Object.keys(n).length===0)?Object.assign(e,{[t]:n}):e,{})}function yr({baseBranch:e,rootDirectory:t,githubRepo:n,excludedGlob:r=[],fileBlockList:i=[]}){Q(`git fetch origin ${e}`);let a=Q(`git ls-remote ${n} "refs/heads/${e}" | cut -f 1`,{encoding:`utf-8`}).split(`
|
|
2
|
+
`)[0],o=Q(`git rev-parse HEAD`,{encoding:`utf-8`}).split(`
|
|
3
|
+
`)[0];if(!a||!o)throw Error(`FAILED TO FIND COMMIT RANGE`);let s=er(Q(`git fetch && git diff --name-only "${e||a}...${o}" -- ${t}`,{encoding:`utf-8`}).split(`
|
|
4
|
+
`).filter(e=>e),i),c=r.length>0?Y.sync(s,{ignore:r}):s,l={};return c.forEach(e=>{l[e]=Q(`git show ${o}:${e}`,{encoding:`utf-8`})}),{changedFiles:s,fileDiffs:l,repoName:n.split(`/`).pop().split(`.`)[0],commit:o}}export{v as ADMIN_DASH,p as ADMIN_DASH_DATAPOINTS,g as ADMIN_DASH_INTEGRATIONS,Mt as APPROVE_PRIVACY_REQUEST,Nt as ASSESSMENT_TEMPLATES,Ne as ActionInput,Se as ActionItemCollectionInput,ke as ActionItemInput,he as ApiKeyInput,B as AssessmentAnswerOptionInput,we as AssessmentDisplayLogicInput,je as AssessmentInput,U as AssessmentNestedRuleInput,ye as AssessmentResourceInput,Fe as AssessmentRetentionScheduleInput,G as AssessmentRuleInput,de as AssessmentSectionInput,Ee as AssessmentSectionQuestionInput,xe as AssessmentTemplateInput,mt as AttestedExtraIdentifiers,me as AttributeInput,pe as AttributePreview,z as AttributeValueInput,ot as BLANK,nt as BULK_APPLY,Le as BusinessEntityInput,kt as CANCEL_PRIVACY_REQUEST,it as CAN_APPLY_IN_BULK,et as CachedFileState,Qe as CachedRequestState,Be as CodePackageInput,H as CodePackageSdk,rt as ColumnName,ze as ConsentManageExperienceInput,j as ConsentManagerInput,te as ConsentManagerServiceMetadata,Re as ConsentPreferenceTopic,M as ConsentPreferenceTopicOptionValue,re as ConsentPurpose,ne as CookieCsvInput,D as CookieInput,Ht as CronIdentifier,Vn as CronIdentifierPush,Ut as CronPartition,u as DEBUG,i as DEFAULT_TRANSCEND_API,m as DEFAULT_TRANSCEND_API_KEY,_ as DEFAULT_TRANSCEND_CONSENT_API,It as DEFAULT_TRANSCEND_PULL_RESOURCES,ve as DataCategoryGuessInput,S as DataCategoryInput,_e as DataCategoryPreviewInput,T as DataCategoryRecommendationInput,E as DataFlowCsvInput,O as DataFlowInput,ie as DataSiloInput,se as DataSubjectInput,w as DatapointInput,Tt as ENTRY_COUNT,Xn as EnrichPrivacyRequest,A as EnricherInput,Ve as FieldInput,at as IDENTIFIER_BLOCK_LIST,Fn as IP_ADDRESS_REGEX,$e as IS_REQUIRED,ee as IdentifierInput,P as ImportOnetrustAssessmentsInput,$t as IntlMessage,oe as IntlMessageInput,tt as NONE,jt as NOTIFY_ADDITIONAL_TIME,r as OneTrustFileFormat,t as OneTrustPullResource,n as OneTrustPullSource,Ct as ParsedAttributeInput,N as PartitionInput,F as PolicyInput,ae as PreferenceWorkflowConfigInput,C as PreferenceWorkflowConfigPurposeInput,Oe as PrivacyCenterInput,zt as PrivacyRequest,ut as PrivacyRequestInput,tn as PrivacyRequestResponse,ce as ProcessingActivityInput,L as ProcessingPurposeInput,I as ProcessingPurposePreviewInput,R as PromptAVendorEmailSettings,k as PromptGroupInput,x as PromptInput,ue as PromptPartialInput,Bn as PurposeMap,Ot as REQUESTS,Dt as REQUESTS_COUNT,a as RETRYABLE_BATCH_STATUSES,Pe as RegionInput,Ce as RepositoryInput,Xt as RequestFileMetadata,Yt as RequestFileMetadataResponse,Rt as RequestPurposeTrigger,Ae as RiskAssignmentInput,ge as RiskLogicInput,d as SCOPES_BY_TITLE,y as SCOPE_TITLES,V as SiloDiscoveryResultInput,Te as SoftwareDevelopmentKitInput,Me as StoredApiKey,st as SuccessfulRequest,o as TR_PULL_RESOURCE_SCOPE_MAP,s as TR_PUSH_RESOURCE_SCOPE_MAP,h as TR_YML_RESOURCE_TO_FIELD_NAME,W as TeamInput,be as TemplateInput,Ie as TranscendInput,e as TranscendPullResource,At as UPDATE_PRIVACY_REQUEST,Rn as USP_STRING_REGEX,Ke as VARIABLE_PARAMETERS_NAME,We as VARIABLE_PARAMETERS_REGEXP,le as VendorInput,fe as WebhookHeader,De as WorkflowConfigInput,En as appendCsvRowsOrdered,Sn as appendCsvSync,an as approvePrivacyRequests,Nn as buildXdiSyncEndpoint,ln as bulkRestartRequests,dn as bulkRetryEnrichers,sn as cancelPrivacyRequests,vn as collectCsvFilesOrExit,_n as collectParquetFilesOrExit,In as consentManagersToBusinessEntities,qt as createCodePackage,Ln as createConsentToken,l as description,Pn as domainToHost,en as downloadPrivacyRequestFiles,Zn as enrichPrivacyRequest,qe as ensureAllDataSubjectsExist,rn as extractClientError,Ft as fetchAllAssessmentTemplates,K as fetchAllRequests,Bt as fetchRequestDataSiloActiveCount,Lt as fetchRequestsTotalCount,vr as filterNullishValuesFromObject,xt as filterRows,J as formatRequestForCsv,lt as fuzzyMatchColumns,ct as fuzzySearch,Gn as generateCrossAccountApiKeys,Qt as getFileMetadataForPrivacyRequests,yr as getGitFilesThatChanged,ft as getUniqueValuesForColumn,wn as initCsvFile,gn as inquirerAutoComplete,mn as inquirerConfirmBoolean,hn as inquirerConfirmText,gr as listDirectories,qn as listFiles,gt as mapColumnsToAttributes,vt as mapColumnsToIdentifiers,ht as mapCsvColumnsToApi,_t as mapCsvRowsToRequestInputs,pt as mapEnumValues,dt as mapRequestEnumValues,Hn as markCronIdentifierCompleted,Wn as markRequestDataSiloIdsCompleted,Jt as markSilentPrivacyRequests,Ye as mergeTranscendInputs,f as name,yt as normalizeIdentifierValue,on as notifyPrivacyRequestsAdditionalTime,yn as parquetToCsvOneFile,St as parseAttributesFromString,xn as parseFilePath,Ze as parseVariablesFromString,Jn as pullAllDatapoints,Wt as pullChunkedCustomSiloOutstandingIdentifiers,Mn as pullConsentManagerMetrics,Vt as pullCronPageOfIdentifiers,Yn as pullManualEnrichmentIdentifiersToCsv,mr as pullPrivacyRequests,Pt as pullTranscendConfiguration,Et as pullUnstructuredSubDataPointRecommendations,Un as pushCronIdentifiersFromCsv,Qn as pushManualEnrichmentIdentifiersFromCsv,wt as readCsv,hr as readSafe,Ge as readTranscendYaml,_r as removeLinks,On as removeUnverifiedRequestIdentifiers,Ue as replaceVariablesInYaml,cn as restartPrivacyRequest,fn as retryRequestDataSilos,un as skipPreflightJobs,Dn as skipRequestDataSilos,q as splitDateRange,Zt as streamPrivacyRequestFiles,pn as streamPrivacyRequestsToCsv,nn as submitPrivacyRequest,Gt as syncCodePackages,Xe as syncConfigurationToTranscend,pr as syncCookies,Je as syncDataSilos,Kt as updateCodePackages,kn as updateConsentManagerVersionToLatest,$ as updateOrCreateCookies,zn as uploadConsents,jn as uploadCookiesFromCsv,An as uploadDataFlowsFromCsv,bt as uploadPrivacyRequestsFromCsv,Kn as validateTranscendAuth,c as version,bn as writeCsv,Cn as writeCsvSync,Tn as writeLargeCsv,He as writeTranscendYaml};
|
|
5
5
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/lib/graphql/syncCookies.ts","../src/lib/requests/pullPrivacyRequests.ts","../src/lib/helpers/readSafe.ts","../src/lib/api-keys/listDirectories.ts","../src/lib/ai/TranscendPromptManager.ts","../src/lib/ai/removeLinks.ts","../src/lib/ai/filterNullishValuesFromObject.ts","../src/lib/ai/getGitFilesThatChanged.ts"],"sourcesContent":["// import { keyBy } from 'lodash-es';\nimport {\n fetchConsentManagerId,\n makeGraphQLRequest,\n UPDATE_OR_CREATE_COOKIES,\n} from '@transcend-io/sdk';\nimport { mapSeries } from '@transcend-io/utils';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\nimport { chunk } from 'lodash-es';\n\nimport { CookieInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\n\nconst MAX_PAGE_SIZE = 100;\n\n/**\n * Update or create cookies that already existed\n *\n * @param client - GraphQL client\n * @param cookieInputs - List of cookie input\n */\nexport async function updateOrCreateCookies(\n client: GraphQLClient,\n cookieInputs: CookieInput[],\n): Promise<void> {\n const airgapBundleId = await fetchConsentManagerId(client, { logger });\n\n // TODO: https://transcend.height.app/T-19841 - add with custom purposes\n // const purposes = await fetchAllPurposes(client);\n // const purposeNameToId = keyBy(purposes, 'name');\n\n await mapSeries(chunk(cookieInputs, MAX_PAGE_SIZE), async (page) => {\n await makeGraphQLRequest(client, UPDATE_OR_CREATE_COOKIES, {\n variables: {\n airgapBundleId,\n cookies: page.map((cookie) => ({\n name: cookie.name,\n trackingPurposes:\n cookie.trackingPurposes && cookie.trackingPurposes.length > 0\n ? cookie.trackingPurposes\n : undefined,\n // TODO: https://transcend.height.app/T-19841 - add with custom purposes\n // purposeIds: cookie.trackingPurposes\n // ? cookie.trackingPurposes\n // .filter((purpose) => purpose !== 'Unknown')\n // .map((purpose) => purposeNameToId[purpose].id)\n // : undefined,\n description: cookie.description,\n service: cookie.service,\n status: cookie.status,\n attributes: cookie.attributes,\n isRegex: cookie.isRegex,\n // TODO: https://transcend.height.app/T-23718\n // owners,\n // teams,\n })),\n },\n logger,\n });\n });\n}\n\n/**\n * Sync the set of cookies from the YML interface into the product\n *\n * @param client - GraphQL client\n * @param cookies - Cookies to sync\n * @returns True upon success, false upon failure\n */\nexport async function syncCookies(client: GraphQLClient, cookies: CookieInput[]): Promise<boolean> {\n let encounteredError = false;\n logger.info(colors.magenta(`Syncing \"${cookies.length}\" cookies...`));\n\n // Ensure no duplicates are being uploaded\n const notUnique = cookies.filter(\n (cookie) =>\n cookies.filter((cook) => cookie.name === cook.name && cookie.isRegex === cook.isRegex)\n .length > 1,\n );\n if (notUnique.length > 0) {\n throw new Error(\n `Failed to upload cookies as there were non-unique entries found: ${notUnique\n .map(({ name }) => name)\n .join(',')}`,\n );\n }\n\n try {\n logger.info(colors.magenta(`Upserting \"${cookies.length}\" new cookies...`));\n await updateOrCreateCookies(client, cookies);\n logger.info(colors.green(`Successfully synced ${cookies.length} cookies!`));\n } catch (err) {\n encounteredError = true;\n logger.error(colors.red(`Failed to create cookies! - ${err.message}`));\n }\n\n return !encounteredError;\n}\n","import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllRequestIdentifiers,\n validateSombraVersion,\n type RequestIdentifier,\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 { fetchAllRequests } from '../graphql/index.js';\nimport { formatRequestForCsv, CsvRow, ExportedPrivacyRequest } from './formatRequestForCsv.js';\nimport { splitDateRange } from './splitDateRange.js';\n\n/**\n * Pull down a list of privacy requests\n *\n * @param options - Options\n * @returns The requests with request identifiers and requests formatted for CSV\n */\nexport async function pullPrivacyRequests({\n auth,\n sombraAuth,\n actions = [],\n statuses = [],\n identifierSearch,\n pageLimit = 100,\n concurrency = 1,\n transcendUrl = DEFAULT_TRANSCEND_API,\n createdAtBefore,\n skipRequestIdentifiers = false,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isTest,\n}: {\n /** Transcend API key authentication */\n auth: string;\n /** Search for a specific identifier */\n identifierSearch?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Statuses to filter on */\n statuses?: RequestStatus[];\n /** The request action to fetch */\n actions?: RequestAction[];\n /** Page limit when fetching requests */\n pageLimit?: number;\n /** Number of parallel date-range chunks */\n concurrency?: number;\n /** Filter for requests created before this date */\n createdAtBefore?: Date;\n /** Filter for requests created after this date */\n createdAtAfter?: Date;\n /** Filter for requests updated before this date */\n updatedAtBefore?: Date;\n /** Filter for requests updated after this date */\n updatedAtAfter?: Date;\n /** Return test requests */\n isTest?: boolean;\n /** Skip fetching request identifier */\n skipRequestIdentifiers?: boolean;\n}): Promise<{\n /** All request information with attached identifiers */\n requestsWithRequestIdentifiers: ExportedPrivacyRequest[];\n /** Requests that are formatted for CSV */\n requestsFormattedForCsv: CsvRow[];\n}> {\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 // Log date range\n let dateRange = '';\n if (createdAtBefore) {\n dateRange += ` before ${createdAtBefore.toISOString()}`;\n }\n if (createdAtAfter) {\n dateRange += `${dateRange ? ', and' : ''} after ${createdAtAfter.toISOString()}`;\n }\n logger.info(\n colors.magenta(\n `${\n actions.length > 0\n ? `Pulling requests of type \"${actions.join('\" , \"')}\"`\n : 'Pulling all requests'\n }${dateRange}`,\n ),\n );\n\n // Split into parallel date-range chunks when possible\n const useChunks = concurrency > 1 && createdAtAfter && createdAtBefore;\n const chunks = useChunks\n ? splitDateRange(createdAtAfter, createdAtBefore, concurrency)\n : [{ createdAtAfter, createdAtBefore }];\n\n if (useChunks) {\n logger.info(colors.magenta(`Splitting date range into ${concurrency} parallel chunks`));\n }\n\n // Fetch requests across all chunks in parallel\n const chunkResults = await map(\n chunks,\n (chunk) =>\n fetchAllRequests(client, {\n actions,\n text: identifierSearch,\n statuses,\n createdAtBefore: chunk.createdAtBefore,\n createdAtAfter: chunk.createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isTest,\n }),\n { concurrency: useChunks ? concurrency : 1 },\n );\n const requests = chunkResults.flat();\n\n // Validate Sombra version once before bulk-fetching identifiers\n if (!skipRequestIdentifiers) {\n await validateSombraVersion(client, { logger });\n }\n\n // Fetch the request identifiers for those requests\n const requestsWithRequestIdentifiers = skipRequestIdentifiers\n ? requests.map((request) => ({\n ...request,\n requestIdentifiers: [] as RequestIdentifier[],\n }))\n : await map(\n requests,\n async (request) => {\n const requestIdentifiers = await fetchAllRequestIdentifiers(client, sombra, {\n filterBy: { requestId: request.id },\n skipSombraCheck: true,\n logger,\n });\n return {\n ...request,\n requestIdentifiers,\n };\n },\n {\n concurrency: pageLimit,\n },\n );\n\n logger.info(colors.magenta(`Pulled ${requestsWithRequestIdentifiers.length} requests`));\n\n const data = requestsWithRequestIdentifiers.map(formatRequestForCsv);\n\n return { requestsWithRequestIdentifiers, requestsFormattedForCsv: data };\n}\n","import { readFileSync } from 'node:fs';\n\n/**\n * Safely reads the contents of a file as a UTF-8 string.\n * Returns an empty string if the path is not provided or if reading fails.\n *\n * @param p - The path to the file to read.\n * @returns The file contents as a string, or an empty string on error.\n */\nexport function readSafe(p?: string): string {\n try {\n return p ? readFileSync(p, 'utf8') : '';\n } catch {\n return '';\n }\n}\n","import { readdirSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * List the folders in a directory\n *\n * @param startDir - The base directory to list from\n * @returns The list of folders in that directory\n */\nexport function listDirectories(startDir: string): string[] {\n return readdirSync(startDir).filter((entryName) =>\n statSync(join(startDir, entryName)).isDirectory(),\n );\n}\n","import {\n HandlebarsInput,\n createHandlebarsWithHelpers,\n type Handlebars,\n} from '@transcend-io/handlebars-utils';\nimport {\n PromptStatus,\n ChatCompletionRole,\n PromptRunProductArea,\n QueueStatus,\n LargeLanguageModelClient,\n} from '@transcend-io/privacy-types';\nimport {\n type Agent,\n type AgentFile,\n type AgentFileFilterBy,\n buildTranscendGraphQLClient,\n fetchAllAgentFiles,\n fetchAllAgents,\n fetchAllLargeLanguageModels,\n fetchAllPromptThreads,\n fetchPromptsWithVariables,\n type LargeLanguageModel,\n type PromptThread,\n reportPromptRun,\n type ReportPromptRunInput,\n type TranscendPromptTemplated,\n type TranscendPromptsAndVariables,\n} from '@transcend-io/sdk';\nimport { Secret } from '@transcend-io/secret-value';\n/* eslint-disable max-lines */\nimport { Optionalize, Requirize, apply, decodeCodec, getValues } from '@transcend-io/type-utils';\nimport { mapSeries } from '@transcend-io/utils';\nimport { GraphQLClient } from 'graphql-request';\nimport * as t from 'io-ts';\nimport { groupBy, keyBy, uniq, chunk } from 'lodash-es';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\n\n/**\n * An LLM Prompt definition\n */\nexport type TranscendPrompt<TInputParams extends t.Any, TOutputCodec extends t.Any> = (\n | {\n /** ID of the prompt */\n id: string;\n /** Title of the prompt */\n title?: string;\n }\n | {\n /** ID of the prompt */\n id?: string;\n /** Title of the prompt */\n title: string;\n }\n) & {\n /** The names of the agents that should be loaded along with the prompt */\n agentNames?: string[];\n /** Codec to validate runtime input shape */\n paramCodec: TInputParams;\n /** Codec to validate output response */\n outputCodec: TOutputCodec;\n /**\n * If the output that needs to be parsed is returned within a tag\n * e.g. <tag> or <json> - this is the name of the tag\n */\n extractFromTag?: string;\n};\n\nexport interface PromptRunResult {\n /** The ID of the prompt run created on Transcend */\n promptRunId: string;\n /** The URL of the prompt run on Transcend */\n promptRunUrl: string;\n}\n\n/**\n * Create a regex to extract data from a tag\n *\n * Input:\n * \"here is some data <tag>Data</tag>...\"\n *\n * @param tagName - Name of tag\n * @returns Data within the tag\n */\nexport function createRegexForTag(tagName: string): RegExp {\n return new RegExp(`<${tagName}>([\\\\s\\\\S]+?)<\\\\/${tagName}>`);\n}\n\n/**\n * Helper function to declare prompts\n *\n * @param prompts - Prompt config\n * @returns Prompts as identity function - but type enforced\n */\nexport function defineTranscendPrompts<\n TPromptNames extends string,\n TPrompts extends { [k in TPromptNames]: TranscendPrompt<t.Any, t.Any> },\n>(prompts: TPrompts): TPrompts {\n return prompts;\n}\n\n/**\n * Helper to get the type of the parameter for a given prompt\n */\nexport type GetPromptParamType<\n TPromptName extends keyof TPrompts,\n TPrompts extends { [k in TPromptName]: TranscendPrompt<t.Any, t.Any> },\n> = t.TypeOf<TPrompts[TPromptName]['paramCodec']>;\n\n/**\n * Helper to get the type of the parameter for a given prompt\n */\nexport type GetPromptResponseType<\n TPromptName extends keyof TPrompts,\n TPrompts extends { [k in TPromptName]: TranscendPrompt<t.Any, t.Any> },\n> = t.TypeOf<TPrompts[TPromptName]['outputCodec']>;\n\n/**\n * Input for reporting a prompt run\n */\nexport interface ReportPromptRunOptions extends Optionalize<\n Omit<ReportPromptRunInput, 'status' | 'promptId' | 'largeLanguageModelId'>,\n 'name' | 'productArea'\n> {\n /** The large language model being run. Either the ID of the LLM or the client/name pairing */\n largeLanguageModel:\n | string\n | {\n /** Name of client */\n client: LargeLanguageModelClient;\n /** Name of the model */\n name: string;\n };\n}\n\nconst jsonParseSafe = (obj: string): unknown => {\n try {\n return JSON.parse(obj);\n } catch {\n return obj;\n }\n};\n\n/**\n * A class that is capable of loading and insert variables into prompts from\n * Transcend's Prompt Manager\n */\nexport class TranscendPromptManager<\n TPromptNames extends string,\n TPrompts extends { [k in TPromptNames]: TranscendPrompt<t.Any, t.Any> },\n> {\n /** Prompt definitions */\n public prompts: TPrompts;\n\n /** Options for configuring handlebars */\n public handlebarsOptions!: HandlebarsInput;\n\n /** Prompt name -> content map, populated by call to Transcend API */\n public promptContentMap?: { [k in TPromptNames]: TranscendPromptTemplated };\n\n /** The large language models that are registered to this organization for reporting */\n public largeLanguageModels: LargeLanguageModel[] = [];\n\n /** The agent definitions registered to this organization */\n private agentsByName: { [name in string]: Agent } = {};\n\n /** The agent definitions registered to this organization */\n private agentsByAgentId: { [id in string]: Agent } = {};\n\n /** The GraphQL client that can be used to call Transcend */\n public graphQLClient: GraphQLClient;\n\n /** The set of variables to expose in handlebars context specified at class initiation */\n public defaultVariables: { [k in string]: unknown };\n\n /**\n * The set of variables to expose in handlebars context,\n * merges defaults with calculated variables from the inventory\n */\n public variables: { [k in string]: unknown };\n\n /** Handlebars compiler */\n public handlebars: typeof Handlebars;\n\n /** The Transcend API key */\n public transcendApiKey: string | Secret<string>;\n\n /** API of Transcend to call */\n public transcendUrl: string;\n\n /** When true, throw an error if the prompt is not approved */\n public requireApproval: boolean;\n\n /**\n * The cache duration in ms for how long prompts and associated metadata should be cached\n * When undefined - prompts are cached indefinitely unless explicitly re-requested\n * When 0, prompts and metadata are fetched every time (not recommended)\n * Setting this to be an hour is a good rate that optimizes for performance and keeping up to date\n */\n public cacheDuration?: number;\n\n /**\n * The last time the metadata was fetched\n */\n public lastUpdatedAt?: Date;\n\n /**\n * Constructor\n *\n * @param options - Options\n */\n constructor({\n prompts,\n handlebarsOptions = {},\n transcendUrl = DEFAULT_TRANSCEND_API,\n transcendApiKey,\n requireApproval = true,\n cacheDuration,\n defaultVariables = {},\n }: {\n /** Prompt definitions to load */\n prompts: TPrompts;\n /** Options for configuring handlebars */\n handlebarsOptions?: HandlebarsInput;\n /** The Transcend API key */\n transcendApiKey: string | Secret<string>;\n /** API of Transcend to call */\n transcendUrl?: string;\n /** When true, throw an error if the prompt is not approved */\n requireApproval?: boolean;\n /** The set of variables to expose in handlebars context specified at class initiation */\n defaultVariables?: { [k in string]: unknown };\n /**\n * The cache duration in ms for how long prompts and associated metadata should be cached\n * When undefined - prompts are cached indefinitely unless explicitly re-requested\n * When 0, prompts and metadata are fetched every time (not recommended)\n * Setting this to be an hour is a good rate that optimizes for performance and keeping up to date\n */\n cacheDuration?: number;\n }) {\n this.prompts = prompts;\n this.transcendUrl = transcendUrl;\n this.transcendApiKey = transcendApiKey;\n this.variables = defaultVariables;\n this.defaultVariables = defaultVariables;\n this.graphQLClient = buildTranscendGraphQLClient(\n transcendUrl,\n typeof transcendApiKey === 'object' ? transcendApiKey.release() : transcendApiKey,\n );\n this.requireApproval = requireApproval;\n this.cacheDuration = cacheDuration;\n this.handlebarsOptions = handlebarsOptions;\n this.handlebars = createHandlebarsWithHelpers(handlebarsOptions);\n }\n\n /**\n * Fetch prompt metadata from Transcend and cache to the class definition\n *\n * @returns A function that can be used to call the prompt\n */\n async fetchPromptsAndMetadata(): Promise<TranscendPromptsAndVariables> {\n // Determine what to fetch\n const promptDefinitions = getValues(this.prompts) as TranscendPrompt<t.Any, t.Any>[];\n const promptIds = promptDefinitions.map(({ id }) => id).filter((x): x is string => !!x);\n const promptTitles = promptDefinitions\n .map(({ title }) => title)\n .filter((x): x is string => !!x);\n const agentNames = uniq(promptDefinitions.map(({ agentNames }) => agentNames || []).flat());\n\n // Fetch prompts and data\n const [response, largeLanguageModels, agents] = await Promise.all([\n fetchPromptsWithVariables(this.graphQLClient, {\n logger,\n filterBy: { ids: promptIds, titles: promptTitles },\n }),\n fetchAllLargeLanguageModels(this.graphQLClient, { logger }),\n fetchAllAgents(this.graphQLClient, { logger, filterBy: { names: agentNames } }),\n ]);\n this.agentsByName = keyBy(agents, 'name');\n this.agentsByAgentId = keyBy(agents, 'agentId');\n this.largeLanguageModels = largeLanguageModels.filter(\n (model) => model.isTranscendHosted === false,\n );\n\n // Lookup prompts by id/title\n const promptByTitle = keyBy(response.prompts, 'title');\n const promptById = keyBy(response.prompts, 'id');\n\n // Update variables\n this.variables = {\n ...response.calculatedVariables.reduce(\n (acc, v) =>\n Object.assign(acc, {\n [v.name]: v.data ? JSON.parse(v.data) : v.data,\n }),\n {},\n ),\n ...this.defaultVariables,\n };\n\n // Update partials\n this.handlebars = createHandlebarsWithHelpers({\n ...this.handlebarsOptions,\n templates: [\n ...(this.handlebarsOptions.templates || []),\n ...response.promptPartials.map((partial) => ({\n name: partial.slug,\n content: partial.content,\n })),\n ],\n });\n\n // Create mapping from prompt to content\n this.promptContentMap = apply(this.prompts, ({ id, title }) => {\n const result = id ? promptById[id] : title ? promptByTitle[title] : undefined;\n if (!result) {\n throw new Error(`Failed to find prompt with title: \"${title}\" and id: \"${id}\"`);\n }\n return result;\n });\n\n // For cache\n this.lastUpdatedAt = new Date();\n\n return response;\n }\n\n /**\n * Get an agent definition by name\n *\n * @param name - Name of the agent to grab\n * @returns Large language model configuration\n */\n async getAgentByName(name: string): Promise<Agent | undefined> {\n const agent = this.agentsByName[name];\n if (agent) {\n return agent;\n }\n const [remoteAgent] = await fetchAllAgents(this.graphQLClient, {\n logger,\n filterBy: { names: [name] },\n });\n if (!remoteAgent) {\n return undefined;\n }\n this.agentsByName[remoteAgent.name] = remoteAgent;\n this.agentsByAgentId[remoteAgent.agentId] = remoteAgent;\n return remoteAgent;\n }\n\n /**\n * Get a prompt thread by ts\n *\n * @param ts - the slack message timestamp to look up thread for\n * @returns Large language model configuration\n */\n async getPromptThreadBySlackTs(ts: string): Promise<PromptThread | undefined> {\n const [thread] = await fetchAllPromptThreads(this.graphQLClient, {\n logger,\n filterBy: { slackMessageTs: [ts] },\n });\n return thread;\n }\n\n /**\n * Get a list of agent definitions by name.\n * Pulls from cache and may return less agents\n * than requested if some are not found\n *\n * @param names - Names of agents to fetch\n * @returns The agents that were found matching the names\n */\n async getAgentsByName(names: string[]): Promise<Agent[]> {\n if (names.length < 1) {\n throw new Error('Expected at least one name to be provided');\n }\n const { hasCache = [], missingCache = [] } = groupBy(names, (name) =>\n this.agentsByName[name] ? 'hasCache' : 'missingCache',\n );\n const cachedAgents = hasCache.map((name) => this.agentsByName[name]);\n if (missingCache.length === 0) {\n return cachedAgents;\n }\n const chunkedNames = chunk(missingCache, 50);\n const remoteAgents: Agent[] = [];\n await mapSeries(chunkedNames, async (chunkedName) => {\n const pageOfAgents = await fetchAllAgents(this.graphQLClient, {\n logger,\n filterBy: { names: chunkedName },\n });\n pageOfAgents.forEach((agent) => {\n this.agentsByName[agent.name] = agent;\n this.agentsByAgentId[agent.agentId] = agent;\n });\n remoteAgents.push(...pageOfAgents);\n });\n return [...cachedAgents, ...remoteAgents];\n }\n\n /**\n * Fetch metadata on agent files\n *\n * @param filterBy - Filter by parameters\n * @returns The files found matching the filter\n */\n getAgentFiles(filterBy: AgentFileFilterBy): Promise<AgentFile[]> {\n return fetchAllAgentFiles(this.graphQLClient, { logger, filterBy });\n }\n\n /**\n * Look up the large language model to report on\n *\n * @param largeLanguageModel - Input\n * @returns Large language model configuration\n */\n getLargeLanguageModel(\n largeLanguageModel: ReportPromptRunOptions['largeLanguageModel'],\n ): LargeLanguageModel {\n const matching = this.largeLanguageModels.find((model) =>\n typeof largeLanguageModel === 'string'\n ? model.id === largeLanguageModel\n : model.name === largeLanguageModel.name && model.client === largeLanguageModel.client,\n );\n if (!matching) {\n throw new Error(\n `Failed to find model matching: ${\n typeof largeLanguageModel === 'string'\n ? largeLanguageModel\n : JSON.stringify(largeLanguageModel)\n }`,\n );\n }\n return matching;\n }\n\n /**\n * Get a prompt definition by name\n *\n * @param promptName - Prompt to compile\n * @returns Parsed content\n */\n async getPromptDefinition<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n ): Promise<TranscendPromptTemplated> {\n // Determine if prompts need to be fetched\n if (\n // never been fetched\n !this.lastUpdatedAt ||\n // fetch every run\n this.cacheDuration === 0 ||\n // If cache duration met\n (this.cacheDuration && Date.now() - this.lastUpdatedAt.getTime() > this.cacheDuration)\n ) {\n await this.fetchPromptsAndMetadata();\n }\n\n // Lookup prompt\n const { promptContentMap } = this;\n if (!promptContentMap) {\n throw new Error('Expected this.promptContentMap to be defined');\n }\n const promptTemplate = promptContentMap[promptName];\n if (!promptTemplate) {\n throw new Error(`Expected this.promptContentMap[${promptName}] to be defined`);\n }\n return promptTemplate;\n }\n\n /**\n * Validate the shape of the response from AI\n *\n * @param promptName - Prompt to compile\n * @param params - Runtime parameters\n * @returns Parsed content\n */\n async compilePrompt<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n params: t.TypeOf<TPrompts[TPromptName]['paramCodec']>,\n ): Promise<string> {\n // Grab the prompt\n const promptTemplate = await this.getPromptDefinition(promptName);\n const promptInput = this.prompts[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Ensure prompt is approved\n if (this.requireApproval && promptTemplate.status !== PromptStatus.Approved) {\n throw new Error(\n `Assessment \"${promptTemplate.title}\" cannot be used because its in status: \"${promptTemplate.status}\"`,\n );\n }\n\n // If prompt is rejected, throw error\n if (promptTemplate.status === PromptStatus.Rejected) {\n throw new Error(\n `Assessment \"${promptTemplate.title}\" cannot be used because it's in status: \"${promptTemplate.status}\"`,\n );\n }\n\n // Validate params\n decodeCodec(promptInput.paramCodec, params);\n\n // Compile prompt and template\n return this.handlebars.compile(promptTemplate.content)({\n // template in currentDate by default\n currentDate: new Date().toISOString(),\n ...this.variables,\n ...params,\n });\n }\n\n /**\n * Validate the shape of the response from AI\n *\n * @param promptName - Prompt to parse\n * @param response - AI response as string\n * @returns Parsed content\n */\n parseAiResponse<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n response: string,\n ): t.TypeOf<TPrompts[TPromptName]['outputCodec']> {\n // Look up prompt info\n const promptInput = this.prompts[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Extract from tag if needed\n const extracted = promptInput.extractFromTag\n ? (createRegexForTag(promptInput.extractFromTag).exec(response) || [])[1] || response\n : response;\n\n // Parse via codec\n return decodeCodec(promptInput.outputCodec, jsonParseSafe(extracted), false);\n }\n\n /**\n * Parse the AI response and report back to Transcend\n *\n * @param promptName - Prompt to parse\n * @param options - Options for reporting\n * @returns Parsed content\n */\n async reportAndParsePromptRun<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n { largeLanguageModel, ...options }: ReportPromptRunOptions,\n ): Promise<\n PromptRunResult & {\n /** Resulting prompt run */\n result: t.TypeOf<TPrompts[TPromptName]['outputCodec']>;\n }\n > {\n // Determine if prompts need to be fetched\n if (\n // never been fetched\n !this.lastUpdatedAt ||\n // fetch every run\n this.cacheDuration === 0 ||\n // If cache duration met\n (this.cacheDuration && Date.now() - this.lastUpdatedAt.getTime() > this.cacheDuration)\n ) {\n await this.fetchPromptsAndMetadata();\n }\n\n const name = options.name || `@transcend-io/cli-prompt-run-${new Date().toISOString()}`;\n\n if (!this.promptContentMap) {\n throw new Error('Expected this.promptContentMap to be defined');\n }\n // Look up prompt info\n const promptInput = this.promptContentMap[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Ensure the first message in `promptRunMessages` is of type=system\n if (options.promptRunMessages.length === 0) {\n throw new Error('promptRunMessages is expected to have length > 0');\n }\n if (options.promptRunMessages[0].role !== ChatCompletionRole.System) {\n throw new Error(`promptRunMessages[0].role is expected to be = ${ChatCompletionRole.System}`);\n }\n if (\n options.promptRunMessages[options.promptRunMessages.length - 1].role !==\n ChatCompletionRole.Assistant\n ) {\n throw new Error(\n `promptRunMessages[${\n options.promptRunMessages.length - 1\n }].role is expected to be = ${ChatCompletionRole.Assistant}`,\n );\n }\n const response = options.promptRunMessages[options.promptRunMessages.length - 1].content;\n\n let parsed: t.TypeOf<TPrompts[TPromptName]['outputCodec']>;\n try {\n // Parse the response\n parsed = this.parseAiResponse(promptName, response);\n } catch (err) {\n await reportPromptRun(\n this.graphQLClient,\n {\n productArea: PromptRunProductArea.PromptManager,\n ...options,\n name,\n error: err.message,\n status: QueueStatus.Error,\n ...(typeof largeLanguageModel === 'string'\n ? { largeLanguageModelId: largeLanguageModel }\n : {\n largeLanguageModelName: largeLanguageModel.name,\n largeLanguageModelClient: largeLanguageModel.client,\n }),\n promptId: promptInput.id,\n promptRunMessages: options.promptRunMessages.map((message, ind) => ({\n ...message,\n ...(ind === 0 ? { template: promptInput.content } : {}),\n })),\n },\n { logger },\n );\n throw err;\n }\n\n // report successful run\n const promptRunId = await reportPromptRun(\n this.graphQLClient,\n {\n productArea: PromptRunProductArea.PromptManager,\n ...options,\n name,\n status: QueueStatus.Resolved,\n ...(typeof largeLanguageModel === 'string'\n ? { largeLanguageModelId: largeLanguageModel }\n : {\n largeLanguageModelName: largeLanguageModel.name,\n largeLanguageModelClient: largeLanguageModel.client,\n }),\n promptId: promptInput.id,\n promptRunMessages: options.promptRunMessages.map((message, ind) => ({\n ...message,\n ...(ind === 0 ? { template: promptInput.content } : {}),\n })),\n },\n { logger },\n );\n\n return {\n result: parsed,\n promptRunId,\n promptRunUrl: `https://app.transcend.io/prompts/runs/${promptRunId}`,\n };\n }\n\n /**\n * Report an error for a particular prompt\n *\n * @param promptName - Prompt to parse\n * @param options - Options for reporting\n * @returns Parsed content\n */\n async reportPromptRunError<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n { largeLanguageModel, ...options }: Requirize<ReportPromptRunOptions, 'error'>,\n ): Promise<PromptRunResult> {\n // Determine if prompts need to be fetched\n if (\n // never been fetched\n !this.lastUpdatedAt ||\n // fetch every run\n this.cacheDuration === 0 ||\n // If cache duration met\n (this.cacheDuration && Date.now() - this.lastUpdatedAt.getTime() > this.cacheDuration)\n ) {\n await this.fetchPromptsAndMetadata();\n }\n\n const name = options.name || `@transcend-io/cli-prompt-run-${new Date().toISOString()}`;\n\n if (!this.promptContentMap) {\n throw new Error('Expected this.promptContentMap to be defined');\n }\n // Look up prompt info\n const promptInput = this.promptContentMap[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Ensure the first message in `promptRunMessages` is of type=system\n if (options.promptRunMessages.length === 0) {\n throw new Error('promptRunMessages is expected to have length > 0');\n }\n if (options.promptRunMessages[0].role !== ChatCompletionRole.System) {\n throw new Error(`promptRunMessages[0].role is expected to be = ${ChatCompletionRole.System}`);\n }\n\n const promptRunId = await reportPromptRun(\n this.graphQLClient,\n {\n productArea: PromptRunProductArea.PromptManager,\n ...options,\n name,\n status: QueueStatus.Error,\n ...(typeof largeLanguageModel === 'string'\n ? { largeLanguageModelId: largeLanguageModel }\n : {\n largeLanguageModelName: largeLanguageModel.name,\n largeLanguageModelClient: largeLanguageModel.client,\n }),\n promptId: promptInput.id,\n promptRunMessages: options.promptRunMessages.map((message, ind) => ({\n ...message,\n ...(ind === 0 ? { template: promptInput.content } : {}),\n })),\n },\n { logger },\n );\n\n return {\n promptRunId,\n promptRunUrl: `https://app.transcend.io/prompts/runs/${promptRunId}`,\n };\n }\n}\n/* eslint-enable max-lines */\n","/**\n * Remove links from a string\n *\n * @param inputString - String\n * @returns String without links\n */\nexport function removeLinks(inputString: string): string {\n const regex = /(https?:\\/\\/[^\\s]+)/g;\n return inputString.replace(regex, '<link-omitted>');\n}\n","import { ObjByString } from '@transcend-io/type-utils';\n\n/**\n * Given an object, remove all keys that are null-ish\n *\n * @param obj - Object\n * @returns Object with null-ish values removed\n */\nexport function filterNullishValuesFromObject<T extends ObjByString>(obj: T): T {\n return Object.entries(obj).reduce(\n (acc, [k, v]) =>\n v !== null &&\n v !== undefined &&\n v !== '' &&\n !(Array.isArray(v) && v.length === 0) &&\n !(typeof v === 'object' && Object.keys(v).length === 0)\n ? Object.assign(acc, { [k]: v })\n : acc,\n {} as T,\n );\n}\n","import { execSync } from 'child_process';\n\nimport fastGlob from 'fast-glob';\nimport { difference } from 'lodash-es';\n\n/**\n * Function thats gets the git files that have changed\n * and returns the code\n *\n * @param options - Options\n * @returns Changes files and diffs\n */\nexport function getGitFilesThatChanged({\n baseBranch,\n rootDirectory,\n githubRepo,\n excludedGlob = [],\n fileBlockList = [],\n}: {\n /** Base branch */\n baseBranch: string;\n /** Github repo name */\n githubRepo: string;\n /** Root directory */\n rootDirectory: string;\n /** A glob that excludes files */\n excludedGlob?: string[];\n /** Block list of files to not process */\n fileBlockList?: string[];\n}): {\n /** The list of files that changed */\n changedFiles: string[];\n /** Github repo name */\n repoName: string;\n /** Current commit */\n commit: string;\n /** File diffs */\n fileDiffs: { [k in string]: string };\n} {\n // Pull base branch\n execSync(`git fetch origin ${baseBranch}`);\n\n // Latest commit on base branch. If we are on the base branch, we take the prior commit\n const latestBasedCommit = execSync(\n `git ls-remote ${githubRepo} \"refs/heads/${baseBranch}\" | cut -f 1`,\n { encoding: 'utf-8' },\n ).split('\\n')[0];\n\n // This commit\n const latestThisCommit = execSync('git rev-parse HEAD', {\n encoding: 'utf-8',\n }).split('\\n')[0];\n\n // Ensure commits are present\n if (!latestBasedCommit || !latestThisCommit) {\n throw new Error('FAILED TO FIND COMMIT RANGE');\n }\n\n // Get the diff between the given branch and base branch\n const diff = execSync(\n `git fetch && git diff --name-only \"${\n baseBranch || latestBasedCommit\n }...${latestThisCommit}\" -- ${rootDirectory}`,\n { encoding: 'utf-8' },\n );\n\n // Filter out block list\n const changedFiles = difference(\n diff.split('\\n').filter((f) => f),\n fileBlockList,\n );\n\n // Filter out globs\n const filteredChanges =\n excludedGlob.length > 0 ? fastGlob.sync(changedFiles, { ignore: excludedGlob }) : changedFiles;\n\n // Get the contents of only the changed files\n const fileDiffs: { [k in string]: string } = {};\n filteredChanges.forEach((file) => {\n const contents = execSync(`git show ${latestThisCommit}:${file}`, {\n encoding: 'utf-8',\n });\n fileDiffs[file] = contents;\n });\n\n // Pull the github repo name\n const repoName = githubRepo.split('/').pop()!.split('.')[0];\n\n return {\n changedFiles,\n fileDiffs,\n repoName,\n commit: latestThisCommit,\n };\n}\n"],"mappings":"2qKAsBA,eAAsB,EACpB,EACA,EACe,CACf,IAAM,EAAiB,MAAM,GAAsB,EAAQ,CAAE,SAAQ,CAAC,CAMtE,MAAM,EAAU,EAAM,EAAc,IAAc,CAAE,KAAO,IAAS,CAClE,MAAM,GAAmB,EAAQ,GAA0B,CACzD,UAAW,CACT,iBACA,QAAS,EAAK,IAAK,IAAY,CAC7B,KAAM,EAAO,KACb,iBACE,EAAO,kBAAoB,EAAO,iBAAiB,OAAS,EACxD,EAAO,iBACP,IAAA,GAON,YAAa,EAAO,YACpB,QAAS,EAAO,QAChB,OAAQ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E,CAAC,SAAW,GACjD,OAAO,OAAO,EAAK,EAAG,GAAI,EAAG,CAAC,CAC9B,EACN,EAAE,CACH,CCPH,SAAgB,GAAuB,CACrC,aACA,gBACA,aACA,eAAe,EAAE,CACjB,gBAAgB,EAAE,EAqBlB,CAEA,EAAS,oBAAoB,IAAa,CAG1C,IAAM,EAAoB,EACxB,iBAAiB,EAAW,eAAe,EAAW,cACtD,CAAE,SAAU,QAAS,CACtB,CAAC,MAAM;EAAK,CAAC,GAGR,EAAmB,EAAS,qBAAsB,CACtD,SAAU,QACX,CAAC,CAAC,MAAM;EAAK,CAAC,GAGf,GAAI,CAAC,GAAqB,CAAC,EACzB,MAAU,MAAM,8BAA8B,CAYhD,IAAM,EAAe,GARR,EACX,sCACE,GAAc,EACf,KAAK,EAAiB,OAAO,IAC9B,CAAE,SAAU,QAAS,CAKjB,CAAC,MAAM;EAAK,CAAC,OAAQ,GAAM,EAAE,CACjC,EACD,CAGK,EACJ,EAAa,OAAS,EAAI,GAAS,KAAK,EAAc,CAAE,OAAQ,EAAc,CAAC,CAAG,EAG9E,EAAuC,EAAE,CAW/C,OAVA,EAAgB,QAAS,GAAS,CAIhC,EAAU,GAHO,EAAS,YAAY,EAAiB,GAAG,IAAQ,CAChE,SAAU,QACX,CACyB,EAC1B,CAKK,CACL,eACA,YACA,SALe,EAAW,MAAM,IAAI,CAAC,KAAK,CAAE,MAAM,IAAI,CAAC,GAMvD,OAAQ,EACT"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/lib/graphql/syncCookies.ts","../src/lib/requests/pullPrivacyRequests.ts","../src/lib/helpers/readSafe.ts","../src/lib/api-keys/listDirectories.ts","../src/lib/ai/removeLinks.ts","../src/lib/ai/filterNullishValuesFromObject.ts","../src/lib/ai/getGitFilesThatChanged.ts"],"sourcesContent":["// import { keyBy } from 'lodash-es';\nimport {\n fetchConsentManagerId,\n makeGraphQLRequest,\n UPDATE_OR_CREATE_COOKIES,\n} from '@transcend-io/sdk';\nimport { mapSeries } from '@transcend-io/utils';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\nimport { chunk } from 'lodash-es';\n\nimport { CookieInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\n\nconst MAX_PAGE_SIZE = 100;\n\n/**\n * Update or create cookies that already existed\n *\n * @param client - GraphQL client\n * @param cookieInputs - List of cookie input\n */\nexport async function updateOrCreateCookies(\n client: GraphQLClient,\n cookieInputs: CookieInput[],\n): Promise<void> {\n const airgapBundleId = await fetchConsentManagerId(client, { logger });\n\n // TODO: https://transcend.height.app/T-19841 - add with custom purposes\n // const purposes = await fetchAllPurposes(client);\n // const purposeNameToId = keyBy(purposes, 'name');\n\n await mapSeries(chunk(cookieInputs, MAX_PAGE_SIZE), async (page) => {\n await makeGraphQLRequest(client, UPDATE_OR_CREATE_COOKIES, {\n variables: {\n airgapBundleId,\n cookies: page.map((cookie) => ({\n name: cookie.name,\n trackingPurposes:\n cookie.trackingPurposes && cookie.trackingPurposes.length > 0\n ? cookie.trackingPurposes\n : undefined,\n // TODO: https://transcend.height.app/T-19841 - add with custom purposes\n // purposeIds: cookie.trackingPurposes\n // ? cookie.trackingPurposes\n // .filter((purpose) => purpose !== 'Unknown')\n // .map((purpose) => purposeNameToId[purpose].id)\n // : undefined,\n description: cookie.description,\n service: cookie.service,\n status: cookie.status,\n attributes: cookie.attributes,\n isRegex: cookie.isRegex,\n // TODO: https://transcend.height.app/T-23718\n // owners,\n // teams,\n })),\n },\n logger,\n });\n });\n}\n\n/**\n * Sync the set of cookies from the YML interface into the product\n *\n * @param client - GraphQL client\n * @param cookies - Cookies to sync\n * @returns True upon success, false upon failure\n */\nexport async function syncCookies(client: GraphQLClient, cookies: CookieInput[]): Promise<boolean> {\n let encounteredError = false;\n logger.info(colors.magenta(`Syncing \"${cookies.length}\" cookies...`));\n\n // Ensure no duplicates are being uploaded\n const notUnique = cookies.filter(\n (cookie) =>\n cookies.filter((cook) => cookie.name === cook.name && cookie.isRegex === cook.isRegex)\n .length > 1,\n );\n if (notUnique.length > 0) {\n throw new Error(\n `Failed to upload cookies as there were non-unique entries found: ${notUnique\n .map(({ name }) => name)\n .join(',')}`,\n );\n }\n\n try {\n logger.info(colors.magenta(`Upserting \"${cookies.length}\" new cookies...`));\n await updateOrCreateCookies(client, cookies);\n logger.info(colors.green(`Successfully synced ${cookies.length} cookies!`));\n } catch (err) {\n encounteredError = true;\n logger.error(colors.red(`Failed to create cookies! - ${err.message}`));\n }\n\n return !encounteredError;\n}\n","import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllRequestIdentifiers,\n validateSombraVersion,\n type RequestIdentifier,\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 { fetchAllRequests } from '../graphql/index.js';\nimport { formatRequestForCsv, CsvRow, ExportedPrivacyRequest } from './formatRequestForCsv.js';\nimport { splitDateRange } from './splitDateRange.js';\n\n/**\n * Pull down a list of privacy requests\n *\n * @param options - Options\n * @returns The requests with request identifiers and requests formatted for CSV\n */\nexport async function pullPrivacyRequests({\n auth,\n sombraAuth,\n actions = [],\n statuses = [],\n identifierSearch,\n pageLimit = 100,\n concurrency = 1,\n transcendUrl = DEFAULT_TRANSCEND_API,\n createdAtBefore,\n skipRequestIdentifiers = false,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isTest,\n}: {\n /** Transcend API key authentication */\n auth: string;\n /** Search for a specific identifier */\n identifierSearch?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Statuses to filter on */\n statuses?: RequestStatus[];\n /** The request action to fetch */\n actions?: RequestAction[];\n /** Page limit when fetching requests */\n pageLimit?: number;\n /** Number of parallel date-range chunks */\n concurrency?: number;\n /** Filter for requests created before this date */\n createdAtBefore?: Date;\n /** Filter for requests created after this date */\n createdAtAfter?: Date;\n /** Filter for requests updated before this date */\n updatedAtBefore?: Date;\n /** Filter for requests updated after this date */\n updatedAtAfter?: Date;\n /** Return test requests */\n isTest?: boolean;\n /** Skip fetching request identifier */\n skipRequestIdentifiers?: boolean;\n}): Promise<{\n /** All request information with attached identifiers */\n requestsWithRequestIdentifiers: ExportedPrivacyRequest[];\n /** Requests that are formatted for CSV */\n requestsFormattedForCsv: CsvRow[];\n}> {\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 // Log date range\n let dateRange = '';\n if (createdAtBefore) {\n dateRange += ` before ${createdAtBefore.toISOString()}`;\n }\n if (createdAtAfter) {\n dateRange += `${dateRange ? ', and' : ''} after ${createdAtAfter.toISOString()}`;\n }\n logger.info(\n colors.magenta(\n `${\n actions.length > 0\n ? `Pulling requests of type \"${actions.join('\" , \"')}\"`\n : 'Pulling all requests'\n }${dateRange}`,\n ),\n );\n\n // Split into parallel date-range chunks when possible\n const useChunks = concurrency > 1 && createdAtAfter && createdAtBefore;\n const chunks = useChunks\n ? splitDateRange(createdAtAfter, createdAtBefore, concurrency)\n : [{ createdAtAfter, createdAtBefore }];\n\n if (useChunks) {\n logger.info(colors.magenta(`Splitting date range into ${concurrency} parallel chunks`));\n }\n\n // Fetch requests across all chunks in parallel\n const chunkResults = await map(\n chunks,\n (chunk) =>\n fetchAllRequests(client, {\n actions,\n text: identifierSearch,\n statuses,\n createdAtBefore: chunk.createdAtBefore,\n createdAtAfter: chunk.createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isTest,\n }),\n { concurrency: useChunks ? concurrency : 1 },\n );\n const requests = chunkResults.flat();\n\n // Validate Sombra version once before bulk-fetching identifiers\n if (!skipRequestIdentifiers) {\n await validateSombraVersion(client, { logger });\n }\n\n // Fetch the request identifiers for those requests\n const requestsWithRequestIdentifiers = skipRequestIdentifiers\n ? requests.map((request) => ({\n ...request,\n requestIdentifiers: [] as RequestIdentifier[],\n }))\n : await map(\n requests,\n async (request) => {\n const requestIdentifiers = await fetchAllRequestIdentifiers(client, sombra, {\n filterBy: { requestId: request.id },\n skipSombraCheck: true,\n logger,\n });\n return {\n ...request,\n requestIdentifiers,\n };\n },\n {\n concurrency: pageLimit,\n },\n );\n\n logger.info(colors.magenta(`Pulled ${requestsWithRequestIdentifiers.length} requests`));\n\n const data = requestsWithRequestIdentifiers.map(formatRequestForCsv);\n\n return { requestsWithRequestIdentifiers, requestsFormattedForCsv: data };\n}\n","import { readFileSync } from 'node:fs';\n\n/**\n * Safely reads the contents of a file as a UTF-8 string.\n * Returns an empty string if the path is not provided or if reading fails.\n *\n * @param p - The path to the file to read.\n * @returns The file contents as a string, or an empty string on error.\n */\nexport function readSafe(p?: string): string {\n try {\n return p ? readFileSync(p, 'utf8') : '';\n } catch {\n return '';\n }\n}\n","import { readdirSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * List the folders in a directory\n *\n * @param startDir - The base directory to list from\n * @returns The list of folders in that directory\n */\nexport function listDirectories(startDir: string): string[] {\n return readdirSync(startDir).filter((entryName) =>\n statSync(join(startDir, entryName)).isDirectory(),\n );\n}\n","/**\n * Remove links from a string\n *\n * @param inputString - String\n * @returns String without links\n */\nexport function removeLinks(inputString: string): string {\n const regex = /(https?:\\/\\/[^\\s]+)/g;\n return inputString.replace(regex, '<link-omitted>');\n}\n","import { ObjByString } from '@transcend-io/type-utils';\n\n/**\n * Given an object, remove all keys that are null-ish\n *\n * @param obj - Object\n * @returns Object with null-ish values removed\n */\nexport function filterNullishValuesFromObject<T extends ObjByString>(obj: T): T {\n return Object.entries(obj).reduce(\n (acc, [k, v]) =>\n v !== null &&\n v !== undefined &&\n v !== '' &&\n !(Array.isArray(v) && v.length === 0) &&\n !(typeof v === 'object' && Object.keys(v).length === 0)\n ? Object.assign(acc, { [k]: v })\n : acc,\n {} as T,\n );\n}\n","import { execSync } from 'child_process';\n\nimport fastGlob from 'fast-glob';\nimport { difference } from 'lodash-es';\n\n/**\n * Function thats gets the git files that have changed\n * and returns the code\n *\n * @param options - Options\n * @returns Changes files and diffs\n */\nexport function getGitFilesThatChanged({\n baseBranch,\n rootDirectory,\n githubRepo,\n excludedGlob = [],\n fileBlockList = [],\n}: {\n /** Base branch */\n baseBranch: string;\n /** Github repo name */\n githubRepo: string;\n /** Root directory */\n rootDirectory: string;\n /** A glob that excludes files */\n excludedGlob?: string[];\n /** Block list of files to not process */\n fileBlockList?: string[];\n}): {\n /** The list of files that changed */\n changedFiles: string[];\n /** Github repo name */\n repoName: string;\n /** Current commit */\n commit: string;\n /** File diffs */\n fileDiffs: { [k in string]: string };\n} {\n // Pull base branch\n execSync(`git fetch origin ${baseBranch}`);\n\n // Latest commit on base branch. If we are on the base branch, we take the prior commit\n const latestBasedCommit = execSync(\n `git ls-remote ${githubRepo} \"refs/heads/${baseBranch}\" | cut -f 1`,\n { encoding: 'utf-8' },\n ).split('\\n')[0];\n\n // This commit\n const latestThisCommit = execSync('git rev-parse HEAD', {\n encoding: 'utf-8',\n }).split('\\n')[0];\n\n // Ensure commits are present\n if (!latestBasedCommit || !latestThisCommit) {\n throw new Error('FAILED TO FIND COMMIT RANGE');\n }\n\n // Get the diff between the given branch and base branch\n const diff = execSync(\n `git fetch && git diff --name-only \"${\n baseBranch || latestBasedCommit\n }...${latestThisCommit}\" -- ${rootDirectory}`,\n { encoding: 'utf-8' },\n );\n\n // Filter out block list\n const changedFiles = difference(\n diff.split('\\n').filter((f) => f),\n fileBlockList,\n );\n\n // Filter out globs\n const filteredChanges =\n excludedGlob.length > 0 ? fastGlob.sync(changedFiles, { ignore: excludedGlob }) : changedFiles;\n\n // Get the contents of only the changed files\n const fileDiffs: { [k in string]: string } = {};\n filteredChanges.forEach((file) => {\n const contents = execSync(`git show ${latestThisCommit}:${file}`, {\n encoding: 'utf-8',\n });\n fileDiffs[file] = contents;\n });\n\n // Pull the github repo name\n const repoName = githubRepo.split('/').pop()!.split('.')[0];\n\n return {\n changedFiles,\n fileDiffs,\n repoName,\n commit: latestThisCommit,\n };\n}\n"],"mappings":"slJAsBA,eAAsB,EACpB,EACA,EACe,CACf,IAAM,EAAiB,MAAM,GAAsB,EAAQ,CAAE,SAAQ,CAAC,CAMtE,MAAM,GAAU,GAAM,EAAc,IAAc,CAAE,KAAO,IAAS,CAClE,MAAM,GAAmB,EAAQ,GAA0B,CACzD,UAAW,CACT,iBACA,QAAS,EAAK,IAAK,IAAY,CAC7B,KAAM,EAAO,KACb,iBACE,EAAO,kBAAoB,EAAO,iBAAiB,OAAS,EACxD,EAAO,iBACP,IAAA,GAON,YAAa,EAAO,YACpB,QAAS,EAAO,QAChB,OAAQ,EAAO,OACf,WAAY,EAAO,WACnB,QAAS,EAAO,QAIjB,EAAE,CACJ,CACD,SACD,CAAC,EACF,CAUJ,eAAsB,GAAY,EAAuB,EAA0C,CACjG,IAAI,EAAmB,GACvB,EAAO,KAAK,EAAO,QAAQ,YAAY,EAAQ,OAAO,cAAc,CAAC,CAGrE,IAAM,EAAY,EAAQ,OACvB,GACC,EAAQ,OAAQ,GAAS,EAAO,OAAS,EAAK,MAAQ,EAAO,UAAY,EAAK,QAAQ,CACnF,OAAS,EACf,CACD,GAAI,EAAU,OAAS,EACrB,MAAU,MACR,oEAAoE,EACjE,KAAK,CAAE,UAAW,EAAK,CACvB,KAAK,IAAI,GACb,CAGH,GAAI,CACF,EAAO,KAAK,EAAO,QAAQ,cAAc,EAAQ,OAAO,kBAAkB,CAAC,CAC3E,MAAM,EAAsB,EAAQ,EAAQ,CAC5C,EAAO,KAAK,EAAO,MAAM,uBAAuB,EAAQ,OAAO,WAAW,CAAC,OACpE,EAAK,CACZ,EAAmB,GACnB,EAAO,MAAM,EAAO,IAAI,+BAA+B,EAAI,UAAU,CAAC,CAGxE,MAAO,CAAC,EC1EV,eAAsB,GAAoB,CACxC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,EAAc,CAAE,OAAQ,EAAc,CAAC,CAAG,EAG9E,EAAuC,EAAE,CAW/C,OAVA,EAAgB,QAAS,GAAS,CAIhC,EAAU,GAHO,EAAS,YAAY,EAAiB,GAAG,IAAQ,CAChE,SAAU,QACX,CACyB,EAC1B,CAKK,CACL,eACA,YACA,SALe,EAAW,MAAM,IAAI,CAAC,KAAK,CAAE,MAAM,IAAI,CAAC,GAMvD,OAAQ,EACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./fuzzyMatchColumns-
|
|
2
|
-
//# sourceMappingURL=inquirer-
|
|
1
|
+
import{n as e}from"./fuzzyMatchColumns-C1STZ_T1.mjs";import t from"inquirer";import n from"inquirer-autocomplete-prompt";async function r({message:e}){let{response:n}=await t.prompt([{name:`response`,message:e,type:`confirm`}]);return n}async function i({message:e}){let{response:n}=await t.prompt([{name:`response`,message:e,type:`text`,validate:e=>e.trim().length>0}]);return n}async function a({defaultValue:r,values:i,message:a}){t.registerPrompt(`autocomplete`,n);let{response:o}=await t.prompt([{name:`response`,message:a,type:`autocomplete`,default:r,source:(t,n)=>n?i.filter(t=>typeof t==`string`&&e(n,t)):i}]);return o}export{r as n,i as r,a as t};
|
|
2
|
+
//# sourceMappingURL=inquirer-B0OF_nRe.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inquirer-
|
|
1
|
+
{"version":3,"file":"inquirer-B0OF_nRe.mjs","names":[],"sources":["../src/lib/helpers/inquirer.ts"],"sourcesContent":["import { ObjByString } from '@transcend-io/type-utils';\nimport inquirer from 'inquirer';\nimport autoCompletePrompt from 'inquirer-autocomplete-prompt';\n\nimport { fuzzySearch } from '../requests/index.js';\n\n/**\n * Inquirer confirm text\n *\n * @param options - Options\n * @returns The response\n */\nexport async function inquirerConfirmBoolean({\n message,\n}: {\n /** Message */\n message: string;\n}): Promise<boolean> {\n const { response } = await inquirer.prompt<{\n /** confirmation */\n response: boolean;\n }>([\n {\n name: 'response',\n message,\n type: 'confirm',\n },\n ]);\n return response;\n}\n\n/**\n * Inquirer confirm text\n *\n * @param options - Options\n * @returns The response\n */\nexport async function inquirerConfirmText({\n message,\n}: {\n /** Message */\n message: string;\n}): Promise<string> {\n const { response } = await inquirer.prompt<{\n /** confirmation */\n response: string;\n }>([\n {\n name: 'response',\n message,\n type: 'text',\n validate: (x) => x.trim().length > 0,\n },\n ]);\n return response;\n}\n\n/**\n * Inquirer auto complete\n *\n * @param options - Options\n * @returns The response\n */\nexport async function inquirerAutoComplete({\n defaultValue,\n values,\n message,\n}: {\n /** Default value */\n defaultValue?: string;\n /** Message */\n message: string;\n /** Values to select */\n values: string[];\n}): Promise<string> {\n inquirer.registerPrompt('autocomplete', autoCompletePrompt);\n const { response } = await inquirer.prompt<{\n /** confirmation */\n response: string;\n }>([\n {\n name: 'response',\n message,\n type: 'autocomplete',\n default: defaultValue,\n source: (answersSoFar: ObjByString, input: string) =>\n !input ? values : values.filter((x) => typeof x === 'string' && fuzzySearch(input, x)),\n },\n ]);\n return response;\n}\n"],"mappings":"yHAYA,eAAsB,EAAuB,CAC3C,WAImB,CACnB,GAAM,CAAE,YAAa,MAAM,EAAS,OAGjC,CACD,CACE,KAAM,WACN,UACA,KAAM,UACP,CACF,CAAC,CACF,OAAO,EAST,eAAsB,EAAoB,CACxC,WAIkB,CAClB,GAAM,CAAE,YAAa,MAAM,EAAS,OAGjC,CACD,CACE,KAAM,WACN,UACA,KAAM,OACN,SAAW,GAAM,EAAE,MAAM,CAAC,OAAS,EACpC,CACF,CAAC,CACF,OAAO,EAST,eAAsB,EAAqB,CACzC,eACA,SACA,WAQkB,CAClB,EAAS,eAAe,eAAgB,EAAmB,CAC3D,GAAM,CAAE,YAAa,MAAM,EAAS,OAGjC,CACD,CACE,KAAM,WACN,UACA,KAAM,eACN,QAAS,EACT,QAAS,EAA2B,IACjC,EAAiB,EAAO,OAAQ,GAAM,OAAO,GAAM,UAAY,EAAY,EAAO,EAAE,CAAC,CAA7E,EACZ,CACF,CAAC,CACF,OAAO"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./constants-
|
|
2
|
-
//# sourceMappingURL=markRequestDataSiloIdsCompleted-
|
|
1
|
+
import{a as e}from"./constants-BRGOkSyL.mjs";import{t}from"./logger-Ckep4QXn.mjs";import{RequestDataSiloStatus as n}from"@transcend-io/privacy-types";import r from"colors";import{CHANGE_REQUEST_DATA_SILO_STATUS as i,buildTranscendGraphQLClient as a,fetchRequestDataSilo as o,makeGraphQLRequest as s}from"@transcend-io/sdk";import{map as c}from"@transcend-io/utils";import l from"cli-progress";async function u({requestIds:u,dataSiloId:d,auth:f,concurrency:p=100,status:m=n.Resolved,transcendUrl:h=e}){let g=a(h,f),_=new Date().getTime(),v=new l.SingleBar({},l.Presets.shades_classic);t.info(r.magenta(`Notifying Transcend for data silo "${d}" marking "${u.length}" requests as completed.`));let y=0;v.start(u.length,0),await c(u,async e=>{let n=await o(g,{logger:t,filterBy:{requestId:e,dataSiloId:d}});try{await s(g,i,{variables:{requestDataSiloId:n.id,status:m},logger:t})}catch(e){if(!e.message.includes(`Client error: Request must be active:`)&&!e.message.includes(`Failed to find RequestDataSilo`))throw e}y+=1,v.update(y)},{concurrency:p}),v.stop();let b=new Date().getTime()-_;return t.info(r.green(`Successfully notified Transcend in "${b/1e3}" seconds!`)),u.length}export{u as t};
|
|
2
|
+
//# sourceMappingURL=markRequestDataSiloIdsCompleted-CRFzgT1M.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markRequestDataSiloIdsCompleted-
|
|
1
|
+
{"version":3,"file":"markRequestDataSiloIdsCompleted-CRFzgT1M.mjs","names":[],"sources":["../src/lib/cron/markRequestDataSiloIdsCompleted.ts"],"sourcesContent":["import { RequestDataSiloStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n makeGraphQLRequest,\n CHANGE_REQUEST_DATA_SILO_STATUS,\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';\n\n/**\n * Given a CSV of Request IDs, mark associated RequestDataSilos as completed\n *\n * @param options - Options\n * @returns Number of items marked as completed\n */\nexport async function markRequestDataSiloIdsCompleted({\n requestIds,\n dataSiloId,\n auth,\n concurrency = 100,\n status = RequestDataSiloStatus.Resolved,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The list of request ids to mark as completed */\n requestIds: string[];\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** Status to update requests to */\n status?: RequestDataSiloStatus;\n /** Upload concurrency */\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 // Notify Transcend\n logger.info(\n colors.magenta(\n `Notifying Transcend for data silo \"${dataSiloId}\" marking \"${requestIds.length}\" requests as completed.`,\n ),\n );\n\n let total = 0;\n progressBar.start(requestIds.length, 0);\n await map(\n requestIds,\n async (requestId) => {\n const requestDataSilo = await fetchRequestDataSilo(client, {\n logger,\n filterBy: { requestId, dataSiloId },\n });\n\n try {\n await makeGraphQLRequest<{\n /** Whether we successfully uploaded the results */\n success: boolean;\n }>(client, CHANGE_REQUEST_DATA_SILO_STATUS, {\n variables: {\n requestDataSiloId: requestDataSilo.id,\n status,\n },\n logger,\n });\n } catch (err) {\n if (\n !err.message.includes('Client error: Request must be active:') &&\n !err.message.includes('Failed to find RequestDataSilo')\n ) {\n throw err;\n }\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(colors.green(`Successfully notified Transcend in \"${totalTime / 1000}\" seconds!`));\n return requestIds.length;\n}\n"],"mappings":"yYAoBA,eAAsB,EAAgC,CACpD,aACA,aACA,OACA,cAAc,IACd,SAAS,EAAsB,SAC/B,eAAe,GAcG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAGrF,EAAO,KACL,EAAO,QACL,sCAAsC,EAAW,aAAa,EAAW,OAAO,0BACjF,CACF,CAED,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAW,OAAQ,EAAE,CACvC,MAAM,EACJ,EACA,KAAO,IAAc,CACnB,IAAM,EAAkB,MAAM,EAAqB,EAAQ,CACzD,SACA,SAAU,CAAE,YAAW,aAAY,CACpC,CAAC,CAEF,GAAI,CACF,MAAM,EAGH,EAAQ,EAAiC,CAC1C,UAAW,CACT,kBAAmB,EAAgB,GACnC,SACD,CACD,SACD,CAAC,OACK,EAAK,CACZ,GACE,CAAC,EAAI,QAAQ,SAAS,wCAAwC,EAC9D,CAAC,EAAI,QAAQ,SAAS,iCAAiC,CAEvD,MAAM,EAIV,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EAGvB,OADA,EAAO,KAAK,EAAO,MAAM,uCAAuC,EAAY,IAAK,YAAY,CAAC,CACvF,EAAW"}
|
package/dist/{markSilentPrivacyRequests-KZal6Opm.mjs → markSilentPrivacyRequests-C6JvvCwA.mjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./constants-
|
|
2
|
-
//# sourceMappingURL=markSilentPrivacyRequests-
|
|
1
|
+
import{a as e}from"./constants-BRGOkSyL.mjs";import{t}from"./logger-Ckep4QXn.mjs";import{o as n}from"./request-BIplTb3L.mjs";import{r}from"./fetchAllRequests-DP24WqrP.mjs";import{RequestStatus as i}from"@transcend-io/privacy-types";import a from"colors";import{buildTranscendGraphQLClient as o,makeGraphQLRequest as s}from"@transcend-io/sdk";import{map as c}from"@transcend-io/utils";import l from"cli-progress";async function u({requestActions:u,auth:d,requestIds:f,statuses:p=[i.Compiling,i.RequestMade,i.Delayed,i.Approving,i.Secondary,i.Enriching,i.Waiting,i.SecondaryApproving],createdAtAfter:m,createdAtBefore:h,updatedAtBefore:g,updatedAtAfter:_,concurrency:v=100,transcendUrl:y=e}){let b=o(y,d),x=new Date().getTime(),S=new l.SingleBar({},l.Presets.shades_classic),C=await r(b,{actions:u,statuses:p,createdAtBefore:h,createdAtAfter:m,updatedAtBefore:g,updatedAtAfter:_,isSilent:!1,requestIds:f});t.info(a.magenta(`Marking "${C.length}" as silent mode.`));let w=0;S.start(C.length,0),await c(C,async e=>{await s(b,n,{variables:{input:{id:e.id,isSilent:!0}},logger:t}),w+=1,S.update(w)},{concurrency:v}),S.stop();let T=new Date().getTime()-x;return t.info(a.green(`Successfully marked ${w} requests as silent mode in "${T/1e3}" seconds!`)),C.length}export{u as t};
|
|
2
|
+
//# sourceMappingURL=markSilentPrivacyRequests-C6JvvCwA.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markSilentPrivacyRequests-
|
|
1
|
+
{"version":3,"file":"markSilentPrivacyRequests-C6JvvCwA.mjs","names":[],"sources":["../src/lib/requests/markSilentPrivacyRequests.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport { buildTranscendGraphQLClient, makeGraphQLRequest } 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 { UPDATE_PRIVACY_REQUEST, fetchAllRequests } from '../graphql/index.js';\n\n/**\n * Mark a set of privacy requests to be in silent mode\n *\n * @param options - Options\n * @returns The number of requests marked silent\n */\nexport async function markSilentPrivacyRequests({\n requestActions,\n auth,\n requestIds,\n statuses = [\n RequestStatus.Compiling,\n RequestStatus.RequestMade,\n RequestStatus.Delayed,\n RequestStatus.Approving,\n RequestStatus.Secondary,\n RequestStatus.Enriching,\n RequestStatus.Waiting,\n RequestStatus.SecondaryApproving,\n ],\n createdAtAfter,\n createdAtBefore,\n updatedAtBefore,\n updatedAtAfter,\n concurrency = 100,\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 /** Concurrency limit for approving */\n concurrency?: number;\n /** The request statuses to mark silent */\n statuses?: RequestStatus[];\n /** The set of privacy requests to mark silent */\n requestIds?: string[];\n /** Filter for requests created before this date */\n createdAtBefore?: Date;\n /** Filter for requests created after this date */\n createdAtAfter?: Date;\n /** Filter for requests updated before this date */\n updatedAtBefore?: Date;\n /** Filter for requests updated after this date */\n updatedAtAfter?: Date;\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,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isSilent: false,\n requestIds,\n });\n\n // Notify Transcend\n logger.info(colors.magenta(`Marking \"${allRequests.length}\" as silent mode.`));\n\n let total = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToMarkSilent) => {\n await makeGraphQLRequest(client, UPDATE_PRIVACY_REQUEST, {\n variables: {\n input: {\n id: requestToMarkSilent.id,\n isSilent: true,\n },\n },\n logger,\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 marked ${total} requests as silent mode in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n return allRequests.length;\n}\n"],"mappings":"4ZAgBA,eAAsB,EAA0B,CAC9C,iBACA,OACA,aACA,WAAW,CACT,EAAc,UACd,EAAc,YACd,EAAc,QACd,EAAc,UACd,EAAc,UACd,EAAc,UACd,EAAc,QACd,EAAc,mBACf,CACD,iBACA,kBACA,kBACA,iBACA,cAAc,IACd,eAAe,GAsBG,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,WACA,kBACA,iBACA,kBACA,iBACA,SAAU,GACV,aACD,CAAC,CAGF,EAAO,KAAK,EAAO,QAAQ,YAAY,EAAY,OAAO,mBAAmB,CAAC,CAE9E,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAY,OAAQ,EAAE,CACxC,MAAM,EACJ,EACA,KAAO,IAAwB,CAC7B,MAAM,EAAmB,EAAQ,EAAwB,CACvD,UAAW,CACT,MAAO,CACL,GAAI,EAAoB,GACxB,SAAU,GACX,CACF,CACD,SACD,CAAC,CAEF,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EAOvB,OALA,EAAO,KACL,EAAO,MACL,uBAAuB,EAAM,+BAA+B,EAAY,IAAK,YAC9E,CACF,CACM,EAAY"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./constants-
|
|
2
|
-
//# sourceMappingURL=notifyPrivacyRequestsAdditionalTime-
|
|
1
|
+
import{a as e}from"./constants-BRGOkSyL.mjs";import{t}from"./logger-Ckep4QXn.mjs";import{r as n}from"./request-BIplTb3L.mjs";import{r}from"./fetchAllRequests-DP24WqrP.mjs";import{RequestAction as i}from"@transcend-io/privacy-types";import a from"colors";import{buildTranscendGraphQLClient as o,fetchAllTemplates as s,makeGraphQLRequest as c}from"@transcend-io/sdk";import{map as l}from"@transcend-io/utils";import u from"cli-progress";async function d({requestActions:d=Object.values(i),auth:f,requestIds:p,createdAtBefore:m,days:h=45,daysLeft:g=10,createdAtAfter:_,updatedAtBefore:v,updatedAtAfter:y,emailTemplate:b=`Additional Time Needed`,concurrency:x=100,transcendUrl:S=e}){let C=o(S,f),w=new Date().getTime(),T=new u.SingleBar({},u.Presets.shades_classic),E=(await s(C,{logger:t,filterBy:{title:b}})).find(e=>e.title===b);if(!E)throw Error(`Failed to find a template with title: "${b}"`);let D=await r(C,{actions:d,createdAtBefore:m,createdAtAfter:_,updatedAtBefore:v,updatedAtAfter:y,isSilent:!1,isClosed:!1,requestIds:p});D=D.filter(e=>typeof e.daysRemaining==`number`&&e.daysRemaining<g),t.info(a.magenta(`Notifying "${D.length}" that more time is needed.`));let O=0;T.start(D.length,0),await l(D,async e=>{await c(C,n,{variables:{input:{requestId:e.id,template:E.template.defaultMessage,subject:E.subject.defaultMessage,additionalTime:h}},logger:t}),O+=1,T.update(O)},{concurrency:x}),T.stop();let k=new Date().getTime()-w;return t.info(a.green(`Successfully marked ${O} requests as silent mode in "${k/1e3}" seconds!`)),D.length}export{d as t};
|
|
2
|
+
//# sourceMappingURL=notifyPrivacyRequestsAdditionalTime-BjkY34ky.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifyPrivacyRequestsAdditionalTime-
|
|
1
|
+
{"version":3,"file":"notifyPrivacyRequestsAdditionalTime-BjkY34ky.mjs","names":[],"sources":["../src/lib/requests/notifyPrivacyRequestsAdditionalTime.ts"],"sourcesContent":["import { RequestAction } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n fetchAllTemplates,\n makeGraphQLRequest,\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 { NOTIFY_ADDITIONAL_TIME, fetchAllRequests } from '../graphql/index.js';\n\n/**\n * Mark a set of privacy requests to be in silent mode.\n * Note requests in silent mode are ignored\n *\n * @param options - Options\n * @returns The number of requests marked silent\n */\nexport async function notifyPrivacyRequestsAdditionalTime({\n requestActions = Object.values(RequestAction),\n auth,\n requestIds,\n createdAtBefore,\n days = 45,\n daysLeft = 10,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n emailTemplate = 'Additional Time Needed',\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The request actions that should be restarted */\n requestActions?: RequestAction[];\n /** Filter for requests created before this date */\n createdAtBefore: Date;\n /** Filter for requests created after this date */\n createdAtAfter?: Date;\n /** Filter for requests updated before this date */\n updatedAtBefore?: Date;\n /** Filter for requests updated after this date */\n updatedAtAfter?: Date;\n /** Email template */\n emailTemplate?: string;\n /** Transcend API key authentication */\n auth: string;\n /** Number of days to extend request by */\n days?: number;\n /**\n * Only notify requests that have less than this number of days until they are considered expired.\n * This allows for re-running the command without notifying the same users multiple times\n */\n daysLeft?: number;\n /** Concurrency limit for approving */\n concurrency?: number;\n /** The set of privacy requests to notify */\n requestIds?: string[];\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 // Grab the template with that title\n const matchingTemplates = await fetchAllTemplates(client, {\n logger,\n filterBy: { title: emailTemplate },\n });\n const exactTemplateMatch = matchingTemplates.find((template) => template.title === emailTemplate);\n if (!exactTemplateMatch) {\n throw new Error(`Failed to find a template with title: \"${emailTemplate}\"`);\n }\n\n // Pull in the requests\n let allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isSilent: false,\n isClosed: false,\n requestIds,\n });\n\n // Filter requests by daysLeft\n allRequests = allRequests.filter(\n (request) => typeof request.daysRemaining === 'number' && request.daysRemaining < daysLeft,\n );\n\n // Notify Transcend\n logger.info(colors.magenta(`Notifying \"${allRequests.length}\" that more time is needed.`));\n\n let total = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToNotify) => {\n await makeGraphQLRequest(client, NOTIFY_ADDITIONAL_TIME, {\n variables: {\n input: {\n requestId: requestToNotify.id,\n template: exactTemplateMatch.template.defaultMessage,\n subject: exactTemplateMatch.subject.defaultMessage,\n additionalTime: days,\n },\n },\n logger,\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 marked ${total} requests as silent mode in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n return allRequests.length;\n}\n"],"mappings":"mbAqBA,eAAsB,EAAoC,CACxD,iBAAiB,OAAO,OAAO,EAAc,CAC7C,OACA,aACA,kBACA,OAAO,GACP,WAAW,GACX,iBACA,kBACA,iBACA,gBAAgB,yBAChB,cAAc,IACd,eAAe,GA6BG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAO/E,GAAqB,MAJK,EAAkB,EAAQ,CACxD,SACA,SAAU,CAAE,MAAO,EAAe,CACnC,CAAC,EAC2C,KAAM,GAAa,EAAS,QAAU,EAAc,CACjG,GAAI,CAAC,EACH,MAAU,MAAM,0CAA0C,EAAc,GAAG,CAI7E,IAAI,EAAc,MAAM,EAAiB,EAAQ,CAC/C,QAAS,EACT,kBACA,iBACA,kBACA,iBACA,SAAU,GACV,SAAU,GACV,aACD,CAAC,CAGF,EAAc,EAAY,OACvB,GAAY,OAAO,EAAQ,eAAkB,UAAY,EAAQ,cAAgB,EACnF,CAGD,EAAO,KAAK,EAAO,QAAQ,cAAc,EAAY,OAAO,6BAA6B,CAAC,CAE1F,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAY,OAAQ,EAAE,CACxC,MAAM,EACJ,EACA,KAAO,IAAoB,CACzB,MAAM,EAAmB,EAAQ,EAAwB,CACvD,UAAW,CACT,MAAO,CACL,UAAW,EAAgB,GAC3B,SAAU,EAAmB,SAAS,eACtC,QAAS,EAAmB,QAAQ,eACpC,eAAgB,EACjB,CACF,CACD,SACD,CAAC,CAEF,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EAOvB,OALA,EAAO,KACL,EAAO,MACL,uBAAuB,EAAM,+BAA+B,EAAY,IAAK,YAC9E,CACF,CACM,EAAY"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{t as e}from"./logger-Ckep4QXn.mjs";import{chunk as t,difference as n,flatten as r,keyBy as i,uniq as a}from"lodash-es";import o from"colors";import{apply as s,getEntries as c}from"@transcend-io/type-utils";import{CREATE_DATA_SILOS as l,UPDATE_DATA_SILOS as u,UPDATE_OR_CREATE_DATA_POINT as d,convertToDataSubjectBlockList as f,createDataSubject as p,fetchAllActions as m,fetchAllAttributes as h,fetchAllDataSilos as g,fetchAllDataSubjects as _,fetchApiKeys as v,fetchIdentifiersAndCreateMissing as y,makeGraphQLRequest as b,syncAction as x,syncActionItemCollections as S,syncActionItems as C,syncAttribute as w,syncBusinessEntities as T,syncConsentManager as ee,syncConsentWorkflowTriggers as te,syncCookies as ne,syncDataCategories as re,syncDataFlows as ie,syncDataSiloDependencies as ae,syncDataSubject as oe,syncEnricher as se,syncIdentifier as ce,syncIntlMessages as le,syncPartitions as ue,syncPolicies as de,syncPreferenceOptionValues as fe,syncPreferenceTopics as pe,syncPrivacyCenter as me,syncProcessingActivities as he,syncProcessingPurposes as ge,syncPromptGroups as _e,syncPromptPartials as ve,syncPrompts as ye,syncPurposes as be,syncTeams as xe,syncTemplate as Se,syncVendors as Ce,syncWorkflowConfigs as we}from"@transcend-io/sdk";import{map as E,mapSeries as D}from"@transcend-io/utils";import O from"cli-progress";const k=/^[A-Za-z]+$/;function Te(e){let t=[],n=(e,n)=>{k.test(e)||t.push(`${n}: slug "${e}" is invalid — slugs must contain only alphabetical letters (A-Z, a-z). Topic slugs are normalized to PascalCase server-side, so YAML slugs should already be PascalCase or matching will break on subsequent pulls.`)};for(let t of e[`preference-options`]??[])n(t.slug,`preference-options`);for(let t of e.purposes??[])for(let e of t[`preference-topics`]??[]){n(e.slug,`purposes (topic "${e.title}")`);for(let t of e.options??[])n(t.slug,`purposes (topic "${e.title}" option "${t.title}")`)}return t}async function A({"data-silos":t=[],"data-subjects":s=[],"processing-activities":c=[],enrichers:l=[]},u,d=!1){let f=a([...r(t.map(e=>e[`data-subjects`]||[])||[]),...r(c.map(({dataSubjectTypes:e})=>e??[])??[]),...r(l.map(e=>e[`data-subjects`]||[])||[]),...s.map(e=>e.type)]);if(f.length===0&&!d)return{};let m=await _(u,{logger:e}),h=i(m,`type`),g=n(f,m.map(({type:e})=>e));if(g.length>0){e.info(o.magenta(`Creating ${g.length} new data subjects...`));for(let t of g){e.info(o.magenta(`Creating data subject ${t}...`));let n=await p(u,{input:t,logger:e});e.info(o.green(`Created data subject ${t}!`)),h[t]=n}}return h}async function j(n,r,{pageSize:a,dataSubjectsByName:c,apiKeysByTitle:p}){let m=!1,h=new Date().getTime();e.info(o.magenta(`Syncing "${n.length}" data silos...`));let _=i(await g(r,{titles:n.map(({title:e})=>e),pageSize:a,logger:e}),`title`),v=n.filter(({title:e})=>!_[e]);v.length>0&&(e.info(o.magenta(`Creating "${v.length}" data silos that did not exist...`)),await D(t(v,20),async t=>{let{createDataSilos:{dataSilos:n}}=await b(r,l,{variables:{input:t.map(e=>({name:e[`outer-type`]||e.integrationName,title:e.title,country:e.country,countrySubDivision:e.countrySubDivision,sombraId:e[`sombra-id`]}))},logger:e});n.forEach(e=>{_[e.title]=e})}),e.info(o.green(`Successfully created "${v.length}" data silos!`)));let y=t(n,20);await D(y,async(t,n)=>{e.info(o.magenta(`[Batch ${n+1}/${y.length}] Syncing "${t.length}" data silos`)),await b(r,u,{variables:{input:{dataSilos:t.map(e=>({id:_[e.title].id,country:e.country,countrySubDivision:e.countrySubDivision,url:e.url,headers:e.headers,description:e.description,identifiers:e[`identity-keys`],isLive:!e.disabled,ownerEmails:e.owners,teamNames:e.teams,dependedOnDataSiloTitles:e[`deletion-dependencies`]?void 0:[],apiKeyId:e[`api-key-title`]?p[e[`api-key-title`]].id:void 0,dataSubjectBlockListIds:e[`data-subjects`]?f(e[`data-subjects`],c):void 0,attributes:e.attributes,businessEntityTitles:e.businessEntityTitles,sombraId:e[`sombra-id`],notifyEmailAddress:e[`email-settings`]?.[`notify-email-address`],promptAVendorEmailSendFrequency:e[`email-settings`]?.[`send-frequency`],promptAVendorEmailSendType:e[`email-settings`]?.[`send-type`],promptAVendorEmailIncludeIdentifiersAttachment:e[`email-settings`]?.[`include-identifiers-attachment`],promptAVendorEmailCompletionLinkType:e[`email-settings`]?.[`completion-link-type`],manualWorkRetryFrequency:e[`email-settings`]?.[`manual-work-retry-frequency`]}))}},logger:e}),e.info(o.green(`[Batch ${n+1}/${y.length}] Synced "${t.length}" data silos!`))});let x=new O.SingleBar({},O.Presets.shades_classic),S=n.filter(({datapoints:e=[]})=>e.length>0),C=n.map(({datapoints:e=[]})=>e.length).reduce((e,t)=>e+t,0);e.info(o.magenta(`Syncing "${C}" datapoints from "${S.length}" data silos...`)),x.start(C,0);let w=0;await E(S,async({datapoints:t,title:n})=>{t&&await D(t,async t=>{let i=t.fields?t.fields.map(({key:e,description:t,categories:n,purposes:r,attributes:i,...a})=>({name:e,description:t,categories:n?n.map(e=>({...e,name:e.name||`Other`})):void 0,purposes:r?r.map(e=>({...e,name:e.name||`Other`})):void 0,attributes:i,accessRequestVisibilityEnabled:a[`access-request-visibility-enabled`],erasureRequestRedactionEnabled:a[`erasure-request-redaction-enabled`]})):void 0,a={dataSiloId:_[n].id,path:t.path,name:t.key,title:t.title,description:t.description,...t.owners?{ownerEmails:t.owners}:{},...t.teams?{teamNames:t.teams}:{},...t[`data-collection-tag`]?{dataCollectionTag:t[`data-collection-tag`]}:{},querySuggestions:t[`privacy-action-queries`]?Object.entries(t[`privacy-action-queries`]).map(([e,t])=>({requestType:e,suggestedQuery:t})):void 0,enabledActions:t[`privacy-actions`]||[],subDataPoints:i},s=(a.subDataPoints||[]).map(({name:e})=>e),c=s.filter((e,t)=>s.indexOf(e)!==t);if(c.length>0)e.info(o.red(`\nCannot update datapoint "${t.key}" as it has duplicate sub-datapoints with the same name: \n${c.join(`
|
|
2
|
+
`)}`)),m=!0;else try{await b(r,d,{variables:a,logger:e})}catch(r){e.info(o.red(`\nFailed to update datapoint "${t.key}" for data silo "${n}"! - \n${r.message}`)),m=!0}w+=1,x.update(w)})},{concurrency:10}),x.stop();let T=new Date().getTime()-h;return e.info(o.green(`Synced "${n.length}" data silos and "${C}" datapoints in "${T/1e3}" seconds!`)),{success:!m,dataSiloTitleToId:s(_,({id:e})=>e)}}async function M(t,n,{pageSize:r=50,publishToPrivacyCenter:i=!0,classifyService:a=!1,deleteExtraAttributeValues:s=!1,logger:c,warnings:l=[]}){let u=c??e,d=[],f=!1,p=(e,t,n)=>{d.push({resource:e,item:n,message:t}),f=!0};u.info(o.magenta(`Fetching data with page size ${r}...`));let{templates:g,attributes:b,actions:D,identifiers:O,"data-subjects":k,"business-entities":M,enrichers:N,cookies:P,"consent-manager":F,"data-silos":I,"data-flows":L,prompts:R,"prompt-groups":z,"prompt-partials":B,vendors:V,"data-categories":H,"processing-activities":U,"processing-purposes":W,"action-items":G,"action-item-collections":K,teams:q,"privacy-center":J,messages:Y,policies:Ee,partitions:De,"preference-workflow-configs":Oe,"workflow-configs":ke}=t,Ae=t[`preference-options`],X=t.purposes,je=Te(t);if(je.length>0){for(let e of je)p(`preference-slugs`,e);return{success:!1,errors:d,warnings:l.length>0?l:void 0}}let[Z,Q,Me]=await Promise.all([N||O?y(n,{input:t,skipPublish:!i,logger:e}):{},I||k||N||U?A(t,n):{},I&&I.map(e=>e[`api-key-title`]||[]).reduce((e,t)=>e+t.length,0)>0?v(n,{apiKeyInputs:t,logger:e}):{}]);if(Oe?.length&&(await te(n,Oe,{logger:u,pageSize:r})||p(`preference-workflow-configs`,`Failed to sync preference workflow configs`)),ke?.length&&(await we(n,ke,{logger:u})||p(`workflow-configs`,`Failed to sync workflow configs`)),Ae?.length&&(await fe(n,Ae,{logger:u})||p(`preference-options`,`Failed to sync preference option values`)),X?.length){let{success:e,purposeIdByTrackingType:t}=await be(n,X,{logger:u});e||p(`purposes`,`Failed to sync one or more purposes`);let r=X.flatMap(e=>(e[`preference-topics`]??[]).map(t=>({...t,"tracking-type":e.trackingType})));r.length>0&&(await pe(n,r,{logger:u,purposeIdByTrackingType:t})||p(`preference-topics`,`Failed to sync one or more preference topics`))}if(F){u.info(o.magenta(`Syncing consent manager...`));try{await ee(n,F,{logger:u}),u.info(o.green(`Successfully synced consent manager!`))}catch(e){p(`consent-manager`,e.message),u.error(o.red(`Failed to sync consent manager! - ${e.message}`))}}if(R){let t=await ye(n,R,{logger:e});f||=!t}if(B){let t=await ve(n,B,{logger:e});f||=!t}if(z){let t=await _e(n,z,{logger:e});f||=!t}if(q){let t=await xe(n,q,{logger:e});f||=!t}if(g&&(e.info(o.magenta(`Syncing "${g.length}" email templates...`)),await E(g,async t=>{e.info(o.magenta(`Syncing template "${t.title}"...`));try{await Se(n,t,{logger:e}),e.info(o.green(`Successfully synced template "${t.title}"!`))}catch(n){f=!0,e.error(o.red(`Failed to sync template "${t.title}"! - ${n.message}`))}},{concurrency:10}),e.info(o.green(`Synced "${g.length}" email templates!`))),M){let t=await T(n,M,{logger:e});f||=!t}if(V){let t=await Ce(n,V,{logger:e});f||=!t}if(H){let t=await re(n,H,{logger:e});f||=!t}if(W){let t=await ge(n,W,{logger:e});f||=!t}if(De){let t=await ue(n,De,{logger:e});f||=!t}if(P){let t=await ne(n,P,{logger:e});f||=!t}if(K){let t=await S(n,K,{logger:e});f||=!t}if(b){e.info(o.magenta(`Syncing "${b.length}" attributes...`));let t=await h(n,{logger:e});await E(b,async r=>{let i=t.find(e=>e.name===r.name);e.info(o.magenta(`Syncing attribute "${r.name}"...`));try{await w(n,r,{existingAttribute:i,deleteExtraAttributeValues:s,logger:e}),e.info(o.green(`Successfully synced attribute "${r.name}"!`))}catch(t){f=!0,e.error(o.red(`Failed to sync attribute "${r.name}"! - ${t.message}`))}},{concurrency:10}),e.info(o.green(`Synced "${b.length}" attributes!`))}if(G){let t=await C(n,G,{logger:e});f||=!t}if(N&&(e.info(o.magenta(`Syncing "${N.length}" enrichers...`)),await E(N,async t=>{e.info(o.magenta(`Syncing enricher "${t.title}"...`));try{await se(n,{input:t,identifierByName:Z,dataSubjectsByName:Q,logger:e}),e.info(o.green(`Successfully synced enricher "${t.title}"!`))}catch(n){f=!0,e.error(o.red(`Failed to sync enricher "${t.title}"! - ${n.message}`))}},{concurrency:10}),e.info(o.green(`Synced "${N.length}" enrichers!`))),O&&(e.info(o.magenta(`Syncing "${O.length}" identifiers...`)),await E(O,async t=>{let r=Z[t.name];if(!r)throw Error(`Failed to find identifier with name: ${t.type}. Should have been auto-created by cli.`);e.info(o.magenta(`Syncing identifier "${t.type}"...`));try{await ce(n,{input:t,dataSubjectsByName:Q,identifierId:r.id,skipPublish:!i,logger:e}),e.info(o.green(`Successfully synced identifier "${t.type}"!`))}catch(n){f=!0,e.info(o.red(`Failed to sync identifier "${t.type}"! - ${n.message}`))}},{concurrency:10}),e.info(o.green(`Synced "${O.length}" identifiers!`))),D){e.info(o.magenta(`Syncing "${D.length}" actions...`));let t=await m(n,{logger:e});await E(D,async r=>{let a=t.find(e=>e.type===r.type);if(!a)throw Error(`Failed to find action with type: ${r.type}. Should have already existing in the organization.`);e.info(o.magenta(`Syncing action "${r.type}"...`));try{await x(n,{action:r,actionId:a.id,skipPublish:!i},{logger:e}),e.info(o.green(`Successfully synced action "${r.type}"!`))}catch(t){f=!0,e.error(o.red(`Failed to sync action "${r.type}"! - ${t.message}`))}},{concurrency:10}),e.info(o.green(`Synced "${D.length}" actions!`))}if(k){e.info(o.magenta(`Syncing "${k.length}" data subjects...`));let t=await _(n,{logger:e});await E(k,async r=>{let a=t.find(e=>e.type===r.type);if(!a)throw Error(`Failed to find data subject with type: ${r.type}. Should have already existing in the organization.`);e.info(o.magenta(`Syncing data subject "${r.type}"...`));try{await oe(n,{input:r,dataSubjectId:a.id,skipPublish:!i,logger:e}),e.info(o.green(`Successfully synced data subject "${r.type}"!`))}catch(t){f=!0;let n=r.supportsAuthorizedAgent!==void 0&&/authorized.agent/i.test(t.message)?` (enable the Authorized Agents feature for this organization before setting "supportsAuthorizedAgent")`:``;e.info(o.red(`Failed to sync data subject "${r.type}"! - ${t.message}${n}`))}},{concurrency:10}),e.info(o.green(`Synced "${k.length}" data subjects!`))}if(L){let t=await ie(n,L,{classifyService:a,logger:e});f||=!t}if(J)try{await me(n,J,{logger:e,skipPublish:!i})||p(`privacy-center`,`Failed to sync privacy center`)}catch(e){p(`privacy-center`,e.message)}if(Y){let t=await le(n,Y,{logger:e});f||=!t}if(Ee){let t=await de(n,Ee,{logger:e});f||=!t}let $=[];if(I){let{success:e,dataSiloTitleToId:t}=await j(I,n,{dataSubjectsByName:Q,apiKeysByTitle:Me,pageSize:r});I?.forEach(e=>{e[`deletion-dependencies`]&&$.push([t[e.title],e[`deletion-dependencies`]])}),f||=!e}if($.length>0&&await ae(n,{input:$,logger:e}),U){let t=await he(n,U,{logger:e});f||=!t}return{success:!f,errors:d,warnings:l.length>0?l:void 0}}function N(e,...t){let n=JSON.parse(JSON.stringify(e));return t.forEach(e=>{c(e).forEach(([e,t])=>{n[e]===void 0?n[e]=t:Array.isArray(t)?n[e]=[...n[e],...t]:n[e]=t})}),n}function P(e){let t=e.split(`,`).filter(e=>!!e),n={};return t.forEach(e=>{let[t,r]=e.split(`:`);if(!t||!r)throw Error(`Invalid variable: ${e}. Expected format: key:value`);n[t]=r}),n}export{A as a,j as i,N as n,M as r,P as t};
|
|
3
|
+
//# sourceMappingURL=parseVariablesFromString-6ZwJyWSu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseVariablesFromString-6ZwJyWSu.mjs","names":[],"sources":["../src/lib/preference-management/validatePreferenceManagementSlugs.ts","../src/lib/graphql/ensureAllDataSubjectsExist.ts","../src/lib/graphql/syncDataSilos.ts","../src/lib/graphql/syncConfigurationToTranscend.ts","../src/lib/mergeTranscendInputs.ts","../src/lib/helpers/parseVariablesFromString.ts"],"sourcesContent":["import type { TranscendInput } from '../../codecs.js';\n\n/** Slugs for preference topics and option values must be alphabetical letters only. */\nexport const PREFERENCE_SLUG_REGEX = /^[A-Za-z]+$/;\n\n/**\n * Validate preference topic and option value slugs before push.\n *\n * @param input - Parsed transcend.yml input\n * @returns List of validation error messages (empty when valid)\n */\nexport function validatePreferenceManagementSlugs(input: TranscendInput): string[] {\n const errors: string[] = [];\n\n const validateSlug = (slug: string, context: string): void => {\n if (!PREFERENCE_SLUG_REGEX.test(slug)) {\n errors.push(\n `${context}: slug \"${slug}\" is invalid — slugs must contain only alphabetical letters (A-Z, a-z). ` +\n 'Topic slugs are normalized to PascalCase server-side, so YAML slugs should already be PascalCase ' +\n 'or matching will break on subsequent pulls.',\n );\n }\n };\n\n for (const option of input['preference-options'] ?? []) {\n validateSlug(option.slug, 'preference-options');\n }\n\n for (const purpose of input.purposes ?? []) {\n for (const topic of purpose['preference-topics'] ?? []) {\n validateSlug(topic.slug, `purposes (topic \"${topic.title}\")`);\n for (const option of topic.options ?? []) {\n validateSlug(option.slug, `purposes (topic \"${topic.title}\" option \"${option.title}\")`);\n }\n }\n }\n\n return errors;\n}\n","import { createDataSubject, fetchAllDataSubjects, type DataSubject } from '@transcend-io/sdk';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\nimport { keyBy, flatten, uniq, difference } from 'lodash-es';\n\nimport { TranscendInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\n\n/**\n * Fetch all of the data subjects in the organization\n *\n * @param input - Input to fetch\n * @param client - GraphQL client\n * @param fetchAll - When true, always fetch all subjects\n * @returns The list of data subjects\n */\nexport async function ensureAllDataSubjectsExist(\n {\n 'data-silos': dataSilos = [],\n 'data-subjects': dataSubjects = [],\n 'processing-activities': processingActivities = [],\n enrichers = [],\n }: TranscendInput,\n client: GraphQLClient,\n fetchAll = false,\n): Promise<{ [type in string]: DataSubject }> {\n const expectedDataSubjects = uniq([\n ...flatten(dataSilos.map((silo) => silo['data-subjects'] || []) || []),\n ...flatten(processingActivities.map(({ dataSubjectTypes }) => dataSubjectTypes ?? []) ?? []),\n ...flatten(enrichers.map((enricher) => enricher['data-subjects'] || []) || []),\n ...dataSubjects.map((subject) => subject.type),\n ]);\n if (expectedDataSubjects.length === 0 && !fetchAll) {\n return {};\n }\n\n const internalSubjects = await fetchAllDataSubjects(client, { logger });\n const dataSubjectByName = keyBy(internalSubjects, 'type');\n\n const missingDataSubjects = difference(\n expectedDataSubjects,\n internalSubjects.map(({ type }) => type),\n );\n\n if (missingDataSubjects.length > 0) {\n logger.info(colors.magenta(`Creating ${missingDataSubjects.length} new data subjects...`));\n for (const dataSubjectType of missingDataSubjects) {\n logger.info(colors.magenta(`Creating data subject ${dataSubjectType}...`));\n const created = await createDataSubject(client, { input: dataSubjectType, logger });\n logger.info(colors.green(`Created data subject ${dataSubjectType}!`));\n dataSubjectByName[dataSubjectType] = created;\n }\n }\n\n return dataSubjectByName;\n}\n","import {\n makeGraphQLRequest,\n ApiKey,\n convertToDataSubjectBlockList,\n type DataSubject,\n fetchAllDataSilos,\n type DataSilo,\n CREATE_DATA_SILOS,\n UPDATE_DATA_SILOS,\n UPDATE_OR_CREATE_DATA_POINT,\n} from '@transcend-io/sdk';\nimport { apply } from '@transcend-io/type-utils';\nimport { mapSeries, map } from '@transcend-io/utils';\n/* eslint-disable max-lines */\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\nimport { chunk, keyBy } from 'lodash-es';\n\nimport { DataSiloInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\n\nconst BATCH_SILOS_LIMIT = 20;\n\n/**\n * Sync a data silo configuration\n *\n * @param dataSilos - Data silos to sync\n * @param client - GraphQL client\n * @param options - Options\n * @returns Data silo info\n */\nexport async function syncDataSilos(\n dataSilos: DataSiloInput[],\n client: GraphQLClient,\n {\n pageSize,\n dataSubjectsByName,\n apiKeysByTitle,\n }: {\n /** Page size */\n pageSize: number;\n /** The data subjects in the organization */\n dataSubjectsByName: { [type in string]: DataSubject };\n /** API key title to API key */\n apiKeysByTitle: { [title in string]: ApiKey };\n },\n): Promise<{\n /** Whether successfully updated */\n success: boolean;\n /** A mapping between data silo title to data silo ID */\n dataSiloTitleToId: { [k in string]: string };\n}> {\n let encounteredError = false;\n\n // Time duration\n const t0 = new Date().getTime();\n logger.info(colors.magenta(`Syncing \"${dataSilos.length}\" data silos...`));\n\n // Determine the set of data silos that already exist\n const existingDataSilos = await fetchAllDataSilos(client, {\n titles: dataSilos.map(({ title }) => title),\n pageSize,\n logger,\n });\n\n // Create a mapping of title -> existing silo, if it exists\n const existingDataSiloByTitle = keyBy<Pick<DataSilo, 'id' | 'title'>>(existingDataSilos, 'title');\n\n // Create new silos that do not exist\n const newDataSiloInputs = dataSilos.filter(({ title }) => !existingDataSiloByTitle[title]);\n if (newDataSiloInputs.length > 0) {\n logger.info(\n colors.magenta(`Creating \"${newDataSiloInputs.length}\" data silos that did not exist...`),\n );\n\n // Batch the creation\n const chunked = chunk(newDataSiloInputs, BATCH_SILOS_LIMIT);\n await mapSeries(chunked, async (dependencyUpdateChunk) => {\n const {\n createDataSilos: { dataSilos },\n } = await makeGraphQLRequest<{\n /** Mutation result */\n createDataSilos: {\n /** New data silos */\n dataSilos: Pick<DataSilo, 'id' | 'title'>[];\n };\n }>(client, CREATE_DATA_SILOS, {\n variables: {\n input: dependencyUpdateChunk.map((input) => ({\n name: input['outer-type'] || input.integrationName,\n title: input.title,\n country: input.country,\n countrySubDivision: input.countrySubDivision,\n sombraId: input['sombra-id'],\n })),\n },\n logger,\n });\n\n // save mapping of title and id\n dataSilos.forEach((silo) => {\n existingDataSiloByTitle[silo.title] = silo;\n });\n });\n\n logger.info(colors.green(`Successfully created \"${newDataSiloInputs.length}\" data silos!`));\n }\n\n // Batch the updates\n const chunkedUpdates = chunk(dataSilos, BATCH_SILOS_LIMIT);\n await mapSeries(chunkedUpdates, async (dataSiloUpdateChunk, ind) => {\n logger.info(\n colors.magenta(\n `[Batch ${ind + 1}/${chunkedUpdates.length}] Syncing \"${\n dataSiloUpdateChunk.length\n }\" data silos`,\n ),\n );\n await makeGraphQLRequest<{\n /** Mutation result */\n updateDataSilos: {\n /** New data silos */\n dataSilos: Pick<DataSilo, 'id' | 'title'>[];\n };\n }>(client, UPDATE_DATA_SILOS, {\n variables: {\n input: {\n dataSilos: dataSiloUpdateChunk.map((input) => ({\n id: existingDataSiloByTitle[input.title].id,\n country: input.country,\n countrySubDivision: input.countrySubDivision,\n url: input.url,\n headers: input.headers,\n description: input.description,\n identifiers: input['identity-keys'],\n isLive: !input.disabled,\n ownerEmails: input.owners,\n teamNames: input.teams,\n // clear out if not specified, otherwise the update needs to be applied after\n // all data silos are created\n dependedOnDataSiloTitles: input['deletion-dependencies'] ? undefined : [],\n apiKeyId: input['api-key-title']\n ? apiKeysByTitle[input['api-key-title']].id\n : undefined,\n dataSubjectBlockListIds: input['data-subjects']\n ? convertToDataSubjectBlockList(input['data-subjects'], dataSubjectsByName)\n : undefined,\n attributes: input.attributes,\n businessEntityTitles: input.businessEntityTitles,\n sombraId: input['sombra-id'],\n // AVC settings\n notifyEmailAddress: input['email-settings']?.['notify-email-address'],\n promptAVendorEmailSendFrequency: input['email-settings']?.['send-frequency'],\n promptAVendorEmailSendType: input['email-settings']?.['send-type'],\n promptAVendorEmailIncludeIdentifiersAttachment:\n input['email-settings']?.['include-identifiers-attachment'],\n promptAVendorEmailCompletionLinkType: input['email-settings']?.['completion-link-type'],\n manualWorkRetryFrequency: input['email-settings']?.['manual-work-retry-frequency'],\n })),\n },\n },\n logger,\n });\n logger.info(\n colors.green(\n `[Batch ${ind + 1}/${chunkedUpdates.length}] Synced \"${\n dataSiloUpdateChunk.length\n }\" data silos!`,\n ),\n );\n });\n\n // Sync datapoints\n\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n const dataSilosWithDataPoints = dataSilos.filter(({ datapoints = [] }) => datapoints.length > 0);\n const totalDataPoints = dataSilos\n .map(({ datapoints = [] }) => datapoints.length)\n .reduce((acc, count) => acc + count, 0);\n logger.info(\n colors.magenta(\n `Syncing \"${totalDataPoints}\" datapoints from \"${dataSilosWithDataPoints.length}\" data silos...`,\n ),\n );\n progressBar.start(totalDataPoints, 0);\n let total = 0;\n\n await map(\n dataSilosWithDataPoints,\n async ({ datapoints, title }) => {\n if (datapoints) {\n await mapSeries(datapoints, async (datapoint) => {\n const fields = datapoint.fields\n ? datapoint.fields.map(\n ({ key, description, categories, purposes, attributes, ...rest }) =>\n // TODO: Support setting title separately from the 'key/name'\n ({\n name: key,\n description,\n categories: !categories\n ? undefined\n : categories.map((category) => ({\n ...category,\n name: category.name || 'Other',\n })),\n purposes: !purposes\n ? undefined\n : purposes.map((purpose) => ({\n ...purpose,\n name: purpose.name || 'Other',\n })),\n attributes,\n accessRequestVisibilityEnabled: rest['access-request-visibility-enabled'],\n erasureRequestRedactionEnabled: rest['erasure-request-redaction-enabled'],\n }),\n )\n : undefined;\n\n const payload = {\n dataSiloId: existingDataSiloByTitle[title].id,\n path: datapoint.path,\n name: datapoint.key,\n title: datapoint.title,\n description: datapoint.description,\n ...(datapoint.owners\n ? {\n ownerEmails: datapoint.owners,\n }\n : {}),\n ...(datapoint.teams\n ? {\n teamNames: datapoint.teams,\n }\n : {}),\n ...(datapoint['data-collection-tag']\n ? { dataCollectionTag: datapoint['data-collection-tag'] }\n : {}),\n querySuggestions: !datapoint['privacy-action-queries']\n ? undefined\n : Object.entries(datapoint['privacy-action-queries']).map(([key, value]) => ({\n requestType: key,\n suggestedQuery: value,\n })),\n enabledActions: datapoint['privacy-actions'] || [], // clear out when not specified\n subDataPoints: fields,\n };\n\n // Ensure no duplicate sub-datapoints are provided\n const subDataPointsToUpdate = (payload.subDataPoints || []).map(({ name }) => name);\n const duplicateDataPoints = subDataPointsToUpdate.filter(\n (name, index) => subDataPointsToUpdate.indexOf(name) !== index,\n );\n if (duplicateDataPoints.length > 0) {\n logger.info(\n colors.red(\n `\\nCannot update datapoint \"${\n datapoint.key\n }\" as it has duplicate sub-datapoints with the same name: \\n${duplicateDataPoints.join(\n '\\n',\n )}`,\n ),\n );\n encounteredError = true;\n } else {\n try {\n await makeGraphQLRequest(client, UPDATE_OR_CREATE_DATA_POINT, {\n variables: payload,\n logger,\n });\n } catch (err) {\n logger.info(\n colors.red(\n `\\nFailed to update datapoint \"${datapoint.key}\" for data silo \"${title}\"! - \\n${err.message}`,\n ),\n );\n encounteredError = true;\n }\n }\n total += 1;\n progressBar.update(total);\n });\n }\n },\n {\n concurrency: 10,\n },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Synced \"${dataSilos.length}\" data silos and \"${totalDataPoints}\" datapoints in \"${\n totalTime / 1000\n }\" seconds!`,\n ),\n );\n return {\n success: !encounteredError,\n dataSiloTitleToId: apply(existingDataSiloByTitle, ({ id }) => id),\n };\n}\n/* eslint-enable max-lines */\n","import {\n fetchAllActions,\n fetchAllAttributes,\n fetchAllDataSubjects,\n fetchApiKeys,\n fetchIdentifiersAndCreateMissing,\n syncAction,\n syncActionItemCollections,\n syncActionItems,\n syncAttribute,\n syncBusinessEntities,\n syncDataCategories,\n syncConsentManager,\n syncCookies,\n syncDataFlows,\n syncDataSubject,\n syncDataSiloDependencies,\n syncEnricher,\n syncIdentifier,\n syncIntlMessages,\n syncPartitions,\n syncPolicies,\n syncPrivacyCenter,\n syncProcessingActivities,\n syncProcessingPurposes,\n syncPromptGroups,\n syncPromptPartials,\n syncPrompts,\n syncConsentWorkflowTriggers,\n syncWorkflowConfigs,\n syncPreferenceOptionValues,\n syncPurposes,\n syncPreferenceTopics,\n syncTeams,\n syncTemplate,\n syncVendors,\n type Identifier,\n} from '@transcend-io/sdk';\nimport { map, type Logger, type SyncError, type SyncResult } from '@transcend-io/utils';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\n\n/* eslint-disable max-lines */\nimport { TranscendInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\nimport { validatePreferenceManagementSlugs } from '../preference-management/validatePreferenceManagementSlugs.js';\nimport { ensureAllDataSubjectsExist } from './ensureAllDataSubjectsExist.js';\nimport { syncDataSilos } from './syncDataSilos.js';\n\nconst CONCURRENCY = 10;\n\n/**\n * Sync the yaml input back to Transcend using the GraphQL APIs\n *\n * @param input - The yml input\n * @param client - GraphQL client\n * @param pageSize - Page size\n * @returns Structured sync result with per-resource errors\n */\nexport async function syncConfigurationToTranscend(\n input: TranscendInput,\n client: GraphQLClient,\n {\n pageSize = 50,\n // TODO: https://transcend.height.app/T-23779\n publishToPrivacyCenter = true,\n classifyService = false,\n deleteExtraAttributeValues = false,\n logger: syncLogger,\n warnings = [],\n }: {\n /** Page size */\n pageSize?: number;\n /** When true, skip publishing to privacy center */\n publishToPrivacyCenter?: boolean;\n /** When true, delete any attributes being synced up */\n deleteExtraAttributeValues?: boolean;\n /** classify data flow service if missing */\n classifyService?: boolean;\n /** Optional logger (e.g. collecting logger for MCP debug responses) */\n logger?: Logger;\n /** Non-fatal warnings to include in the result */\n warnings?: string[];\n },\n): Promise<SyncResult> {\n const activeLogger = syncLogger ?? logger;\n const errors: SyncError[] = [];\n let encounteredError = false;\n\n const recordError = (resource: string, message: string, item?: string): void => {\n errors.push({ resource, item, message });\n encounteredError = true;\n };\n\n activeLogger.info(colors.magenta(`Fetching data with page size ${pageSize}...`));\n\n const {\n templates,\n attributes,\n actions,\n identifiers,\n 'data-subjects': dataSubjects,\n 'business-entities': businessEntities,\n enrichers,\n cookies,\n 'consent-manager': consentManager,\n 'data-silos': dataSilos,\n 'data-flows': dataFlows,\n prompts,\n 'prompt-groups': promptGroups,\n 'prompt-partials': promptPartials,\n vendors,\n 'data-categories': dataCategories,\n 'processing-activities': processingActivities,\n 'processing-purposes': processingPurposes,\n 'action-items': actionItems,\n 'action-item-collections': actionItemCollections,\n teams,\n 'privacy-center': privacyCenter,\n messages,\n policies,\n partitions,\n 'preference-workflow-configs': preferenceWorkflowConfigs,\n 'workflow-configs': workflowConfigs,\n } = input;\n\n const preferenceOptions = input['preference-options'];\n const purposes = input.purposes;\n\n const preferenceSlugErrors = validatePreferenceManagementSlugs(input);\n if (preferenceSlugErrors.length > 0) {\n for (const message of preferenceSlugErrors) {\n recordError('preference-slugs', message);\n }\n return {\n success: false,\n errors,\n warnings: warnings.length > 0 ? warnings : undefined,\n };\n }\n\n const [identifierByName, dataSubjectsByName, apiKeyTitleMap] = await Promise.all([\n // Ensure all identifiers are created and create a map from name -> identifier.id\n enrichers || identifiers\n ? fetchIdentifiersAndCreateMissing(client, {\n input,\n skipPublish: !publishToPrivacyCenter,\n logger,\n })\n : ({} as { [k in string]: Identifier }),\n // Grab all data subjects in the organization\n dataSilos || dataSubjects || enrichers || processingActivities\n ? ensureAllDataSubjectsExist(input, client)\n : {},\n // Grab API keys\n dataSilos &&\n dataSilos\n .map((dataSilo) => dataSilo['api-key-title'] || [])\n .reduce((acc, lst) => acc + lst.length, 0) > 0\n ? fetchApiKeys(client, { apiKeyInputs: input, logger })\n : {},\n ]);\n\n if (preferenceWorkflowConfigs?.length) {\n const preferenceWorkflowConfigsSuccess = await syncConsentWorkflowTriggers(\n client,\n preferenceWorkflowConfigs,\n {\n logger: activeLogger,\n pageSize,\n },\n );\n if (!preferenceWorkflowConfigsSuccess) {\n recordError('preference-workflow-configs', 'Failed to sync preference workflow configs');\n }\n }\n\n if (workflowConfigs?.length) {\n const workflowConfigsSuccess = await syncWorkflowConfigs(client, workflowConfigs, {\n logger: activeLogger,\n });\n if (!workflowConfigsSuccess) {\n recordError('workflow-configs', 'Failed to sync workflow configs');\n }\n }\n\n if (preferenceOptions?.length) {\n const preferenceOptionsSuccess = await syncPreferenceOptionValues(client, preferenceOptions, {\n logger: activeLogger,\n });\n if (!preferenceOptionsSuccess) {\n recordError('preference-options', 'Failed to sync preference option values');\n }\n }\n\n // Sync consent purposes and their nested preference topics.\n // Order matters: option values (above) exist first, then purposes, then topics\n // (which link to their purpose by ID and to option values by slug).\n if (purposes?.length) {\n const { success: purposesSuccess, purposeIdByTrackingType } = await syncPurposes(\n client,\n purposes,\n { logger: activeLogger },\n );\n if (!purposesSuccess) {\n recordError('purposes', 'Failed to sync one or more purposes');\n }\n\n const topics = purposes.flatMap((purpose) =>\n (purpose['preference-topics'] ?? []).map((topic) => ({\n ...topic,\n 'tracking-type': purpose.trackingType,\n })),\n );\n if (topics.length > 0) {\n const topicsSuccess = await syncPreferenceTopics(client, topics, {\n logger: activeLogger,\n purposeIdByTrackingType,\n });\n if (!topicsSuccess) {\n recordError('preference-topics', 'Failed to sync one or more preference topics');\n }\n }\n }\n\n // Sync consent manager\n if (consentManager) {\n activeLogger.info(colors.magenta('Syncing consent manager...'));\n try {\n await syncConsentManager(client, consentManager, { logger: activeLogger });\n activeLogger.info(colors.green('Successfully synced consent manager!'));\n } catch (err) {\n recordError('consent-manager', (err as Error).message);\n activeLogger.error(colors.red(`Failed to sync consent manager! - ${(err as Error).message}`));\n }\n }\n\n // Sync prompts\n if (prompts) {\n const promptsSuccess = await syncPrompts(client, prompts, { logger });\n encounteredError = encounteredError || !promptsSuccess;\n }\n if (promptPartials) {\n const promptsSuccess = await syncPromptPartials(client, promptPartials, { logger });\n encounteredError = encounteredError || !promptsSuccess;\n }\n if (promptGroups) {\n const promptsSuccess = await syncPromptGroups(client, promptGroups, { logger });\n encounteredError = encounteredError || !promptsSuccess;\n }\n\n if (teams) {\n const teamsSuccess = await syncTeams(client, teams, { logger });\n encounteredError = encounteredError || !teamsSuccess;\n }\n\n // Sync email templates\n if (templates) {\n logger.info(colors.magenta(`Syncing \"${templates.length}\" email templates...`));\n await map(\n templates,\n async (template) => {\n logger.info(colors.magenta(`Syncing template \"${template.title}\"...`));\n try {\n await syncTemplate(client, template, { logger });\n logger.info(colors.green(`Successfully synced template \"${template.title}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.error(colors.red(`Failed to sync template \"${template.title}\"! - ${err.message}`));\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${templates.length}\" email templates!`));\n }\n\n // Sync business entities\n if (businessEntities) {\n const businessEntitySuccess = await syncBusinessEntities(client, businessEntities, { logger });\n encounteredError = encounteredError || !businessEntitySuccess;\n }\n\n // Sync vendors\n if (vendors) {\n const vendorsSuccess = await syncVendors(client, vendors, { logger });\n encounteredError = encounteredError || !vendorsSuccess;\n }\n\n // Sync data categories\n if (dataCategories) {\n const dataCategoriesSuccess = await syncDataCategories(client, dataCategories, { logger });\n encounteredError = encounteredError || !dataCategoriesSuccess;\n }\n\n // Sync processing purposes\n if (processingPurposes) {\n const processingPurposesSuccess = await syncProcessingPurposes(client, processingPurposes, {\n logger,\n });\n encounteredError = encounteredError || !processingPurposesSuccess;\n }\n\n // Sync partitions\n if (partitions) {\n const partitionsSuccess = await syncPartitions(client, partitions, { logger });\n encounteredError = encounteredError || !partitionsSuccess;\n }\n\n // Sync cookies\n if (cookies) {\n const cookiesSuccess = await syncCookies(client, cookies, { logger });\n encounteredError = encounteredError || !cookiesSuccess;\n }\n\n // Sync action item collections\n if (actionItemCollections) {\n const actionItemCollectionsSuccess = await syncActionItemCollections(\n client,\n actionItemCollections,\n { logger },\n );\n encounteredError = encounteredError || !actionItemCollectionsSuccess;\n }\n\n // Sync attributes\n if (attributes) {\n // Fetch existing\n logger.info(colors.magenta(`Syncing \"${attributes.length}\" attributes...`));\n const existingAttributes = await fetchAllAttributes(client, { logger });\n await map(\n attributes,\n async (attribute) => {\n const existing = existingAttributes.find((attr) => attr.name === attribute.name);\n\n logger.info(colors.magenta(`Syncing attribute \"${attribute.name}\"...`));\n try {\n await syncAttribute(client, attribute, {\n existingAttribute: existing,\n deleteExtraAttributeValues,\n logger,\n });\n logger.info(colors.green(`Successfully synced attribute \"${attribute.name}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.error(\n colors.red(`Failed to sync attribute \"${attribute.name}\"! - ${err.message}`),\n );\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${attributes.length}\" attributes!`));\n }\n\n // Sync action items\n if (actionItems) {\n const actionItemsSuccess = await syncActionItems(client, actionItems, { logger });\n encounteredError = encounteredError || !actionItemsSuccess;\n }\n\n // Sync enrichers\n if (enrichers) {\n logger.info(colors.magenta(`Syncing \"${enrichers.length}\" enrichers...`));\n await map(\n enrichers,\n async (enricher) => {\n logger.info(colors.magenta(`Syncing enricher \"${enricher.title}\"...`));\n try {\n await syncEnricher(client, {\n input: enricher,\n identifierByName,\n dataSubjectsByName,\n logger,\n });\n logger.info(colors.green(`Successfully synced enricher \"${enricher.title}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.error(colors.red(`Failed to sync enricher \"${enricher.title}\"! - ${err.message}`));\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${enrichers.length}\" enrichers!`));\n }\n\n // Sync identifiers\n if (identifiers) {\n // Fetch existing\n logger.info(colors.magenta(`Syncing \"${identifiers.length}\" identifiers...`));\n await map(\n identifiers,\n async (identifier) => {\n const existing = identifierByName[identifier.name];\n if (!existing) {\n throw new Error(\n `Failed to find identifier with name: ${identifier.type}. Should have been auto-created by cli.`,\n );\n }\n\n logger.info(colors.magenta(`Syncing identifier \"${identifier.type}\"...`));\n try {\n await syncIdentifier(client, {\n input: identifier,\n dataSubjectsByName,\n identifierId: existing.id,\n skipPublish: !publishToPrivacyCenter,\n logger,\n });\n logger.info(colors.green(`Successfully synced identifier \"${identifier.type}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.info(\n colors.red(`Failed to sync identifier \"${identifier.type}\"! - ${err.message}`),\n );\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${identifiers.length}\" identifiers!`));\n }\n\n // Sync actions\n if (actions) {\n // Fetch existing\n logger.info(colors.magenta(`Syncing \"${actions.length}\" actions...`));\n const existingActions = await fetchAllActions(client, { logger });\n await map(\n actions,\n async (action) => {\n const existing = existingActions.find((act) => act.type === action.type);\n if (!existing) {\n throw new Error(\n `Failed to find action with type: ${action.type}. Should have already existing in the organization.`,\n );\n }\n\n logger.info(colors.magenta(`Syncing action \"${action.type}\"...`));\n try {\n await syncAction(\n client,\n {\n action,\n actionId: existing.id,\n skipPublish: !publishToPrivacyCenter,\n },\n { logger },\n );\n logger.info(colors.green(`Successfully synced action \"${action.type}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.error(colors.red(`Failed to sync action \"${action.type}\"! - ${err.message}`));\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${actions.length}\" actions!`));\n }\n\n // Sync data subjects\n if (dataSubjects) {\n // Fetch existing\n logger.info(colors.magenta(`Syncing \"${dataSubjects.length}\" data subjects...`));\n const existingDataSubjects = await fetchAllDataSubjects(client, { logger });\n await map(\n dataSubjects,\n async (dataSubject) => {\n const existing = existingDataSubjects.find((subj) => subj.type === dataSubject.type);\n if (!existing) {\n throw new Error(\n `Failed to find data subject with type: ${dataSubject.type}. Should have already existing in the organization.`,\n );\n }\n\n logger.info(colors.magenta(`Syncing data subject \"${dataSubject.type}\"...`));\n try {\n await syncDataSubject(client, {\n input: dataSubject,\n dataSubjectId: existing.id,\n skipPublish: !publishToPrivacyCenter,\n logger,\n });\n logger.info(colors.green(`Successfully synced data subject \"${dataSubject.type}\"!`));\n } catch (err) {\n encounteredError = true;\n // supportsAuthorizedAgent is gated on the Authorized Agents feature being\n // enabled for the organization; surface a clearer hint than the raw API error\n const hint =\n dataSubject.supportsAuthorizedAgent !== undefined &&\n /authorized.agent/i.test(err.message)\n ? ' (enable the Authorized Agents feature for this organization before setting \"supportsAuthorizedAgent\")'\n : '';\n logger.info(\n colors.red(\n `Failed to sync data subject \"${dataSubject.type}\"! - ${err.message}${hint}`,\n ),\n );\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${dataSubjects.length}\" data subjects!`));\n }\n\n // Sync data flows\n if (dataFlows) {\n const syncedDataFlows = await syncDataFlows(client, dataFlows, { classifyService, logger });\n encounteredError = encounteredError || !syncedDataFlows;\n }\n\n // Sync privacy center\n if (privacyCenter) {\n try {\n const privacyCenterSuccess = await syncPrivacyCenter(client, privacyCenter, {\n logger,\n skipPublish: !publishToPrivacyCenter,\n });\n if (!privacyCenterSuccess) {\n recordError('privacy-center', 'Failed to sync privacy center');\n }\n } catch (err) {\n recordError('privacy-center', (err as Error).message);\n }\n }\n\n // Sync messages\n if (messages) {\n const messagesSuccess = await syncIntlMessages(client, messages, { logger });\n encounteredError = encounteredError || !messagesSuccess;\n }\n\n // Sync policies\n if (policies) {\n const policiesSuccess = await syncPolicies(client, policies, { logger });\n encounteredError = encounteredError || !policiesSuccess;\n }\n\n // Store dependency updates\n const dependencyUpdates: [string, string[]][] = [];\n // Sync data silos\n if (dataSilos) {\n const { success, dataSiloTitleToId } = await syncDataSilos(dataSilos, client, {\n dataSubjectsByName,\n apiKeysByTitle: apiKeyTitleMap,\n pageSize,\n });\n dataSilos?.forEach((dataSilo) => {\n // Queue up dependency update\n if (dataSilo['deletion-dependencies']) {\n dependencyUpdates.push([\n dataSiloTitleToId[dataSilo.title],\n dataSilo['deletion-dependencies'],\n ]);\n }\n });\n encounteredError = encounteredError || !success;\n }\n\n // Dependencies updated at the end after all data silos are created\n if (dependencyUpdates.length > 0) {\n await syncDataSiloDependencies(client, { input: dependencyUpdates, logger });\n }\n\n // Update processing activities\n if (processingActivities) {\n const processingActivitySuccess = await syncProcessingActivities(client, processingActivities, {\n logger,\n });\n encounteredError = encounteredError || !processingActivitySuccess;\n }\n\n if (publishToPrivacyCenter) {\n // TODO: https://transcend.height.app/T-23779\n }\n\n return {\n success: !encounteredError,\n errors,\n warnings: warnings.length > 0 ? warnings : undefined,\n };\n}\n/* eslint-enable max-lines */\n","import { getEntries } from '@transcend-io/type-utils';\n\nimport { TranscendInput } from '../codecs.js';\n\n/**\n * Combine a set of TranscendInput yaml files into a single yaml\n *\n * @param base - Base input\n * @param inputs - The list of inputs\n * @returns Merged input\n */\nexport function mergeTranscendInputs(\n base: TranscendInput,\n ...inputs: TranscendInput[]\n): TranscendInput {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const cloned: any = JSON.parse(JSON.stringify(base));\n inputs.forEach((input) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getEntries(input).forEach(([key, value]: [any, any]) => {\n if (cloned[key] === undefined) {\n cloned[key] = value;\n } else if (Array.isArray(value)) {\n cloned[key] = [...cloned[key], ...value];\n } else {\n cloned[key] = value;\n }\n });\n });\n return cloned;\n}\n","/**\n * Parse variables from string\n *\n * @param variables - Variables as string\n * @returns Variables as object\n */\nexport function parseVariablesFromString(variables: string): {\n [k in string]: string;\n} {\n // Parse out the variables\n const splitVars = variables.split(',').filter((x) => !!x);\n const vars: { [k in string]: string } = {};\n splitVars.forEach((variable) => {\n const [k, v] = variable.split(':');\n if (!k || !v) {\n throw new Error(`Invalid variable: ${variable}. Expected format: key:value`);\n }\n vars[k] = v;\n });\n return vars;\n}\n"],"mappings":"2zCAGA,MAAa,EAAwB,cAQrC,SAAgB,GAAkC,EAAiC,CACjF,IAAM,EAAmB,EAAE,CAErB,GAAgB,EAAc,IAA0B,CACvD,EAAsB,KAAK,EAAK,EACnC,EAAO,KACL,GAAG,EAAQ,UAAU,EAAK,sNAG3B,EAIL,IAAK,IAAM,KAAU,EAAM,uBAAyB,EAAE,CACpD,EAAa,EAAO,KAAM,qBAAqB,CAGjD,IAAK,IAAM,KAAW,EAAM,UAAY,EAAE,CACxC,IAAK,IAAM,KAAS,EAAQ,sBAAwB,EAAE,CAAE,CACtD,EAAa,EAAM,KAAM,oBAAoB,EAAM,MAAM,IAAI,CAC7D,IAAK,IAAM,KAAU,EAAM,SAAW,EAAE,CACtC,EAAa,EAAO,KAAM,oBAAoB,EAAM,MAAM,YAAY,EAAO,MAAM,IAAI,CAK7F,OAAO,ECrBT,eAAsB,EACpB,CACE,aAAc,EAAY,EAAE,CAC5B,gBAAiB,EAAe,EAAE,CAClC,wBAAyB,EAAuB,EAAE,CAClD,YAAY,EAAE,EAEhB,EACA,EAAW,GACiC,CAC5C,IAAM,EAAuB,EAAK,CAChC,GAAG,EAAQ,EAAU,IAAK,GAAS,EAAK,kBAAoB,EAAE,CAAC,EAAI,EAAE,CAAC,CACtE,GAAG,EAAQ,EAAqB,KAAK,CAAE,sBAAuB,GAAoB,EAAE,CAAC,EAAI,EAAE,CAAC,CAC5F,GAAG,EAAQ,EAAU,IAAK,GAAa,EAAS,kBAAoB,EAAE,CAAC,EAAI,EAAE,CAAC,CAC9E,GAAG,EAAa,IAAK,GAAY,EAAQ,KAAK,CAC/C,CAAC,CACF,GAAI,EAAqB,SAAW,G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AS,GAAa,CAE3B,EAAS,0BACX,EAAkB,KAAK,CACrB,EAAkB,EAAS,OAC3B,EAAS,yBACV,CAAC,EAEJ,CACF,IAAuC,CAAC,EAS1C,GALI,EAAkB,OAAS,GAC7B,MAAM,GAAyB,EAAQ,CAAE,MAAO,EAAmB,SAAQ,CAAC,CAI1E,EAAsB,CACxB,IAAM,EAA4B,MAAM,GAAyB,EAAQ,EAAsB,CAC7F,SACD,CAAC,CACF,IAAuC,CAAC,EAO1C,MAAO,CACL,QAAS,CAAC,EACV,SACA,SAAU,EAAS,OAAS,EAAI,EAAW,IAAA,GAC5C,CCnkBH,SAAgB,EACd,EACA,GAAG,EACa,CAEhB,IAAM,EAAc,KAAK,MAAM,KAAK,UAAU,EAAK,CAAC,CAapD,OAZA,EAAO,QAAS,GAAU,CAExB,EAAW,EAAM,CAAC,SAAS,CAAC,EAAK,KAAuB,CAClD,EAAO,KAAS,IAAA,GAClB,EAAO,GAAO,EACL,MAAM,QAAQ,EAAM,CAC7B,EAAO,GAAO,CAAC,GAAG,EAAO,GAAM,GAAG,EAAM,CAExC,EAAO,GAAO,GAEhB,EACF,CACK,ECvBT,SAAgB,EAAyB,EAEvC,CAEA,IAAM,EAAY,EAAU,MAAM,IAAI,CAAC,OAAQ,GAAM,CAAC,CAAC,EAAE,CACnD,EAAkC,EAAE,CAQ1C,OAPA,EAAU,QAAS,GAAa,CAC9B,GAAM,CAAC,EAAG,GAAK,EAAS,MAAM,IAAI,CAClC,GAAI,CAAC,GAAK,CAAC,EACT,MAAU,MAAM,qBAAqB,EAAS,8BAA8B,CAE9E,EAAK,GAAK,GACV,CACK"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./constants-
|
|
2
|
-
//# sourceMappingURL=pullChunkedCustomSiloOutstandingIdentifiers-
|
|
1
|
+
import{a as e}from"./constants-BRGOkSyL.mjs";import{t}from"./logger-Ckep4QXn.mjs";import n from"colors";import{decodeCodec as r}from"@transcend-io/type-utils";import*as i from"io-ts";import{REDUCED_REQUESTS_FOR_DATA_SILO_COUNT as a,buildTranscendGraphQLClient as o,createSombraGotInstance as s,makeGraphQLRequest as c,withTransientRetry as l}from"@transcend-io/sdk";import{mapSeries as u}from"@transcend-io/utils";import d from"cli-progress";async function f(e,{dataSiloId:n}){let{listReducedRequestsForDataSilo:{totalCount:r}}=await c(e,a,{variables:{input:{dataSiloId:n,isResolved:!1}},logger:t});return r}const p=i.type({id:i.string,name:i.string,partition:i.string}),m=i.intersection([i.type({identifier:i.string,type:i.string,coreIdentifier:i.string,dataSiloId:i.string,requestId:i.string,nonce:i.string,requestCreatedAt:i.string,daysUntilOverdue:i.number,attributes:i.array(i.type({key:i.string,values:i.array(i.string)}))}),i.partial({partition:i.union([p,i.null])})]);async function h(e,{dataSiloId:n,limit:a=100,offset:o=0,requestType:s}){try{let c=await l(`pullCronPageOfIdentifiers`,()=>e.get(`v1/data-silo/${n}/pending-requests/${s}`,{searchParams:{offset:o,limit:a}}).json(),{logger:t,maxAttempts:6,baseDelayMs:500}),{items:u}=r(i.type({items:i.array(m)}),c);return u}catch(e){throw Error(`Received an error from server: ${e?.response?.body||e?.message}`)}}async function g({dataSiloId:r,auth:i,sombraAuth:a,actions:c,apiPageSize:l=100,savePageSize:p=1e3,onSave:m,transcendUrl:g=e,skipRequestCount:_=!1}){if(p%l!==0)throw Error(`savePageSize must be a multiple of apiPageSize. savePageSize: ${p}, apiPageSize: ${l}`);let v=await s(g,i,{logger:t,sombraApiKey:a,sombraUrl:process.env.SOMBRA_URL}),y=o(g,i),b=0;_||(b=await f(y,{dataSiloId:r})),t.info(n.magenta(`Pulling ${_?`all`:b} outstanding request identifiers for data silo: "${r}" for requests of types "${c.join(`", "`)}"`));let x=new Date().getTime(),S=new d.SingleBar({},d.Presets.shades_classic),C=new Set,w=[],T=[];_||S.start(b,0),await u(c,async e=>{let i=0,a=!0;for(;a;){let o=await h(v,{dataSiloId:r,limit:l,offset:i,requestType:e}),s=o.map(t=>(C.add(t.requestId),{...t,action:e})),c=s.map(({attributes:e,partition:t,...n})=>({...n,...t?{partitionId:t.id,partitionName:t.name,partitionKey:t.partition}:{},...e.reduce((e,t)=>Object.assign(e,{[t.key]:t.values.join(`,`)}),{})}));w.push(...s),T.push(...c),T.length>=p&&(await m(T),T=[]),a=o.length===l,i+=l,_?t.info(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-BNzirY7h.mjs.map
|