@transcend-io/cli 10.2.1 → 10.2.2

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.
Files changed (128) hide show
  1. package/dist/{app-DLzaZHc8.mjs → app-DcwjuHHn.mjs} +16 -16
  2. package/dist/{app-DLzaZHc8.mjs.map → app-DcwjuHHn.mjs.map} +1 -1
  3. package/dist/{approvePrivacyRequests-BlUcYXpH.mjs → approvePrivacyRequests-vTXeO7hC.mjs} +2 -2
  4. package/dist/{approvePrivacyRequests-BlUcYXpH.mjs.map → approvePrivacyRequests-vTXeO7hC.mjs.map} +1 -1
  5. package/dist/bin/bash-complete.mjs +1 -1
  6. package/dist/bin/cli.mjs +1 -1
  7. package/dist/bin/deprecated-command.mjs +1 -1
  8. package/dist/{buildXdiSyncEndpoint-D5GxPH6o.mjs → buildXdiSyncEndpoint-Bd9SRD1A.mjs} +2 -2
  9. package/dist/{buildXdiSyncEndpoint-D5GxPH6o.mjs.map → buildXdiSyncEndpoint-Bd9SRD1A.mjs.map} +1 -1
  10. package/dist/{bulkRestartRequests-DILDBdc1.mjs → bulkRestartRequests-BvURrcOl.mjs} +2 -2
  11. package/dist/{bulkRestartRequests-DILDBdc1.mjs.map → bulkRestartRequests-BvURrcOl.mjs.map} +1 -1
  12. package/dist/{bulkRetryEnrichers-CjSz1472.mjs → bulkRetryEnrichers-CTbBdTEm.mjs} +2 -2
  13. package/dist/{bulkRetryEnrichers-CjSz1472.mjs.map → bulkRetryEnrichers-CTbBdTEm.mjs.map} +1 -1
  14. package/dist/{cancelPrivacyRequests-BWJZmZVY.mjs → cancelPrivacyRequests-p9OEzUXv.mjs} +2 -2
  15. package/dist/{cancelPrivacyRequests-BWJZmZVY.mjs.map → cancelPrivacyRequests-p9OEzUXv.mjs.map} +1 -1
  16. package/dist/{command-BMa3UWax.mjs → command-CuxgABlk.mjs} +2 -2
  17. package/dist/{command-BMa3UWax.mjs.map → command-CuxgABlk.mjs.map} +1 -1
  18. package/dist/{constants-TpID7AXE.mjs → constants-D22_ckyl.mjs} +2 -2
  19. package/dist/{constants-TpID7AXE.mjs.map → constants-D22_ckyl.mjs.map} +1 -1
  20. package/dist/{createExtraKeyHandler-BO4lu0HO.mjs → createExtraKeyHandler-BkfSV_aF.mjs} +2 -2
  21. package/dist/{createExtraKeyHandler-BO4lu0HO.mjs.map → createExtraKeyHandler-BkfSV_aF.mjs.map} +1 -1
  22. package/dist/{downloadPrivacyRequestFiles-8DtRUNXp.mjs → downloadPrivacyRequestFiles-CqHT6HSU.mjs} +2 -2
  23. package/dist/{downloadPrivacyRequestFiles-8DtRUNXp.mjs.map → downloadPrivacyRequestFiles-CqHT6HSU.mjs.map} +1 -1
  24. package/dist/{generateCrossAccountApiKeys-D6hg9146.mjs → generateCrossAccountApiKeys-Cj3YCdZN.mjs} +2 -2
  25. package/dist/{generateCrossAccountApiKeys-D6hg9146.mjs.map → generateCrossAccountApiKeys-Cj3YCdZN.mjs.map} +1 -1
  26. package/dist/{impl-C71CkarV.mjs → impl-0w7yd5pK.mjs} +2 -2
  27. package/dist/{impl-C71CkarV.mjs.map → impl-0w7yd5pK.mjs.map} +1 -1
  28. package/dist/{impl-DmQAAT-u.mjs → impl-122G24x5.mjs} +2 -2
  29. package/dist/{impl-DmQAAT-u.mjs.map → impl-122G24x5.mjs.map} +1 -1
  30. package/dist/{impl--VlanXjT.mjs → impl-56wfH4jn.mjs} +2 -2
  31. package/dist/{impl--VlanXjT.mjs.map → impl-56wfH4jn.mjs.map} +1 -1
  32. package/dist/{impl-DTaM3UE3.mjs → impl-7rVYG2LQ.mjs} +2 -2
  33. package/dist/{impl-DTaM3UE3.mjs.map → impl-7rVYG2LQ.mjs.map} +1 -1
  34. package/dist/{impl-BaHZqboi.mjs → impl-B1YGN9Iu.mjs} +2 -2
  35. package/dist/{impl-BaHZqboi.mjs.map → impl-B1YGN9Iu.mjs.map} +1 -1
  36. package/dist/{impl-Du8quB1O.mjs → impl-BF0jh34q.mjs} +2 -2
  37. package/dist/{impl-Du8quB1O.mjs.map → impl-BF0jh34q.mjs.map} +1 -1
  38. package/dist/{impl-BECek1in.mjs → impl-BJTCOmGC.mjs} +2 -2
  39. package/dist/{impl-BECek1in.mjs.map → impl-BJTCOmGC.mjs.map} +1 -1
  40. package/dist/{impl-Dik9I7Bz.mjs → impl-BPqs_ltg.mjs} +2 -2
  41. package/dist/{impl-Dik9I7Bz.mjs.map → impl-BPqs_ltg.mjs.map} +1 -1
  42. package/dist/{impl-OxHej0UO.mjs → impl-BdafaDmy.mjs} +2 -2
  43. package/dist/{impl-OxHej0UO.mjs.map → impl-BdafaDmy.mjs.map} +1 -1
  44. package/dist/{impl-BuvbXmXj.mjs → impl-BnRNJ3pm.mjs} +2 -2
  45. package/dist/{impl-BuvbXmXj.mjs.map → impl-BnRNJ3pm.mjs.map} +1 -1
  46. package/dist/{impl-DAu079Yl.mjs → impl-Bu8p8dqt.mjs} +2 -2
  47. package/dist/{impl-DAu079Yl.mjs.map → impl-Bu8p8dqt.mjs.map} +1 -1
  48. package/dist/{impl-BTZOd3VN.mjs → impl-BzWh_Xg7.mjs} +2 -2
  49. package/dist/{impl-BTZOd3VN.mjs.map → impl-BzWh_Xg7.mjs.map} +1 -1
  50. package/dist/{impl-DbGCApR_.mjs → impl-C-1-lvCm.mjs} +2 -2
  51. package/dist/{impl-DbGCApR_.mjs.map → impl-C-1-lvCm.mjs.map} +1 -1
  52. package/dist/{impl-BC17WMY4.mjs → impl-CXBLyoPL.mjs} +2 -2
  53. package/dist/{impl-BC17WMY4.mjs.map → impl-CXBLyoPL.mjs.map} +1 -1
  54. package/dist/{impl-CR6tW9Jz.mjs → impl-CZrCBjBJ.mjs} +2 -2
  55. package/dist/{impl-CR6tW9Jz.mjs.map → impl-CZrCBjBJ.mjs.map} +1 -1
  56. package/dist/{impl-BKvcmB7W.mjs → impl-Cf-R4Ale.mjs} +2 -2
  57. package/dist/{impl-BKvcmB7W.mjs.map → impl-Cf-R4Ale.mjs.map} +1 -1
  58. package/dist/{impl-DWiE5RsV.mjs → impl-Ci8n7Ohd.mjs} +2 -2
  59. package/dist/{impl-DWiE5RsV.mjs.map → impl-Ci8n7Ohd.mjs.map} +1 -1
  60. package/dist/{impl-CYS38cQM.mjs → impl-CruHl43V.mjs} +2 -2
  61. package/dist/{impl-CYS38cQM.mjs.map → impl-CruHl43V.mjs.map} +1 -1
  62. package/dist/{impl-c7VvcNpZ.mjs → impl-Cziyty3N.mjs} +2 -2
  63. package/dist/{impl-c7VvcNpZ.mjs.map → impl-Cziyty3N.mjs.map} +1 -1
  64. package/dist/{impl-CxwEMQhw.mjs → impl-D3XO6Mas.mjs} +2 -2
  65. package/dist/{impl-CxwEMQhw.mjs.map → impl-D3XO6Mas.mjs.map} +1 -1
  66. package/dist/{impl-DpuPyy-w.mjs → impl-D50QXpV8.mjs} +2 -2
  67. package/dist/{impl-DpuPyy-w.mjs.map → impl-D50QXpV8.mjs.map} +1 -1
  68. package/dist/{impl-CIYSnaMG.mjs → impl-DCS69D4u.mjs} +2 -2
  69. package/dist/{impl-CIYSnaMG.mjs.map → impl-DCS69D4u.mjs.map} +1 -1
  70. package/dist/{impl-BtIsgTGn.mjs → impl-DCqgx2-j.mjs} +2 -2
  71. package/dist/{impl-BtIsgTGn.mjs.map → impl-DCqgx2-j.mjs.map} +1 -1
  72. package/dist/{impl-CScy-GrG.mjs → impl-DJFLycxa.mjs} +2 -2
  73. package/dist/{impl-CScy-GrG.mjs.map → impl-DJFLycxa.mjs.map} +1 -1
  74. package/dist/{impl-BNDNzc2I.mjs → impl-Di_93pXw.mjs} +2 -2
  75. package/dist/{impl-BNDNzc2I.mjs.map → impl-Di_93pXw.mjs.map} +1 -1
  76. package/dist/{impl-AEjPyfhu.mjs → impl-FIRoVM7G.mjs} +2 -2
  77. package/dist/{impl-AEjPyfhu.mjs.map → impl-FIRoVM7G.mjs.map} +1 -1
  78. package/dist/{impl-BXb07jBU.mjs → impl-HoctnN3Y.mjs} +2 -2
  79. package/dist/{impl-BXb07jBU.mjs.map → impl-HoctnN3Y.mjs.map} +1 -1
  80. package/dist/{impl-BsecIND0.mjs → impl-NkVnS7sH.mjs} +2 -2
  81. package/dist/{impl-BsecIND0.mjs.map → impl-NkVnS7sH.mjs.map} +1 -1
  82. package/dist/{impl-DZicly6r.mjs → impl-Ozxwpuoj.mjs} +2 -2
  83. package/dist/{impl-DZicly6r.mjs.map → impl-Ozxwpuoj.mjs.map} +1 -1
  84. package/dist/{impl-BhnojAfL.mjs → impl-SEFLf4jX.mjs} +2 -2
  85. package/dist/{impl-BhnojAfL.mjs.map → impl-SEFLf4jX.mjs.map} +1 -1
  86. package/dist/{impl-DgG4lZ9T.mjs → impl-Wbg70K6q.mjs} +2 -2
  87. package/dist/{impl-DgG4lZ9T.mjs.map → impl-Wbg70K6q.mjs.map} +1 -1
  88. package/dist/{impl-DAkBsgQN.mjs → impl-gSRG1ELM.mjs} +2 -2
  89. package/dist/{impl-DAkBsgQN.mjs.map → impl-gSRG1ELM.mjs.map} +1 -1
  90. package/dist/{impl-Djlx-Dqj.mjs → impl-jXl2dlnG.mjs} +2 -2
  91. package/dist/{impl-Djlx-Dqj.mjs.map → impl-jXl2dlnG.mjs.map} +1 -1
  92. package/dist/index.d.mts +62 -62
  93. package/dist/index.mjs +1 -1
  94. package/dist/{markRequestDataSiloIdsCompleted-sDBo1vUD.mjs → markRequestDataSiloIdsCompleted-DTfOjCUB.mjs} +2 -2
  95. package/dist/{markRequestDataSiloIdsCompleted-sDBo1vUD.mjs.map → markRequestDataSiloIdsCompleted-DTfOjCUB.mjs.map} +1 -1
  96. package/dist/{markSilentPrivacyRequests-Cmn1fxHI.mjs → markSilentPrivacyRequests-DWyW4Ndj.mjs} +2 -2
  97. package/dist/{markSilentPrivacyRequests-Cmn1fxHI.mjs.map → markSilentPrivacyRequests-DWyW4Ndj.mjs.map} +1 -1
  98. package/dist/{notifyPrivacyRequestsAdditionalTime-CmhFE4b0.mjs → notifyPrivacyRequestsAdditionalTime-BIr4P7lx.mjs} +2 -2
  99. package/dist/{notifyPrivacyRequestsAdditionalTime-CmhFE4b0.mjs.map → notifyPrivacyRequestsAdditionalTime-BIr4P7lx.mjs.map} +1 -1
  100. package/dist/{pullChunkedCustomSiloOutstandingIdentifiers-QRET4M0x.mjs → pullChunkedCustomSiloOutstandingIdentifiers-Cb7HbDD8.mjs} +2 -2
  101. package/dist/{pullChunkedCustomSiloOutstandingIdentifiers-QRET4M0x.mjs.map → pullChunkedCustomSiloOutstandingIdentifiers-Cb7HbDD8.mjs.map} +1 -1
  102. package/dist/{pullManualEnrichmentIdentifiersToCsv-8I6PgBQc.mjs → pullManualEnrichmentIdentifiersToCsv-WvXvuTGM.mjs} +2 -2
  103. package/dist/{pullManualEnrichmentIdentifiersToCsv-8I6PgBQc.mjs.map → pullManualEnrichmentIdentifiersToCsv-WvXvuTGM.mjs.map} +1 -1
  104. package/dist/{pushCronIdentifiersFromCsv-CBb2FvPD.mjs → pushCronIdentifiersFromCsv-DJywyHYU.mjs} +2 -2
  105. package/dist/{pushCronIdentifiersFromCsv-CBb2FvPD.mjs.map → pushCronIdentifiersFromCsv-DJywyHYU.mjs.map} +1 -1
  106. package/dist/{pushManualEnrichmentIdentifiersFromCsv-DYQq7hsN.mjs → pushManualEnrichmentIdentifiersFromCsv-DT4-FUe0.mjs} +2 -2
  107. package/dist/{pushManualEnrichmentIdentifiersFromCsv-DYQq7hsN.mjs.map → pushManualEnrichmentIdentifiersFromCsv-DT4-FUe0.mjs.map} +1 -1
  108. package/dist/{removeUnverifiedRequestIdentifiers-VCbL2BXD.mjs → removeUnverifiedRequestIdentifiers-Dt5hvhtq.mjs} +2 -2
  109. package/dist/{removeUnverifiedRequestIdentifiers-VCbL2BXD.mjs.map → removeUnverifiedRequestIdentifiers-Dt5hvhtq.mjs.map} +1 -1
  110. package/dist/{retryRequestDataSilos-BCe-WGdL.mjs → retryRequestDataSilos-Ds3bF0yd.mjs} +2 -2
  111. package/dist/{retryRequestDataSilos-BCe-WGdL.mjs.map → retryRequestDataSilos-Ds3bF0yd.mjs.map} +1 -1
  112. package/dist/{skipPreflightJobs-Bc0--Bvs.mjs → skipPreflightJobs-h8H7ZEX6.mjs} +2 -2
  113. package/dist/{skipPreflightJobs-Bc0--Bvs.mjs.map → skipPreflightJobs-h8H7ZEX6.mjs.map} +1 -1
  114. package/dist/{skipRequestDataSilos-BHbAQkpb.mjs → skipRequestDataSilos-C8y5PYaZ.mjs} +2 -2
  115. package/dist/{skipRequestDataSilos-BHbAQkpb.mjs.map → skipRequestDataSilos-C8y5PYaZ.mjs.map} +1 -1
  116. package/dist/{streamPrivacyRequestsToCsv-eB3gNhol.mjs → streamPrivacyRequestsToCsv-CipyYYbS.mjs} +2 -2
  117. package/dist/{streamPrivacyRequestsToCsv-eB3gNhol.mjs.map → streamPrivacyRequestsToCsv-CipyYYbS.mjs.map} +1 -1
  118. package/dist/{updateConsentManagerVersionToLatest-D6i1Xh6o.mjs → updateConsentManagerVersionToLatest-F6ywYQg4.mjs} +2 -2
  119. package/dist/{updateConsentManagerVersionToLatest-D6i1Xh6o.mjs.map → updateConsentManagerVersionToLatest-F6ywYQg4.mjs.map} +1 -1
  120. package/dist/{uploadConsents-BTM49EbZ.mjs → uploadConsents-C6gFr33S.mjs} +2 -2
  121. package/dist/{uploadConsents-BTM49EbZ.mjs.map → uploadConsents-C6gFr33S.mjs.map} +1 -1
  122. package/dist/{uploadCookiesFromCsv-DoC9rtEF.mjs → uploadCookiesFromCsv-DydhyjYq.mjs} +2 -2
  123. package/dist/{uploadCookiesFromCsv-DoC9rtEF.mjs.map → uploadCookiesFromCsv-DydhyjYq.mjs.map} +1 -1
  124. package/dist/{uploadDataFlowsFromCsv-DL1-cAit.mjs → uploadDataFlowsFromCsv-BDs2jS3I.mjs} +2 -2
  125. package/dist/{uploadDataFlowsFromCsv-DL1-cAit.mjs.map → uploadDataFlowsFromCsv-BDs2jS3I.mjs.map} +1 -1
  126. package/dist/{uploadPrivacyRequestsFromCsv-wXm4H4FH.mjs → uploadPrivacyRequestsFromCsv-oVE4Am-C.mjs} +2 -2
  127. package/dist/{uploadPrivacyRequestsFromCsv-wXm4H4FH.mjs.map → uploadPrivacyRequestsFromCsv-oVE4Am-C.mjs.map} +1 -1
  128. package/package.json +6 -6
@@ -1,2 +1,2 @@
1
- import{a as e}from"./constants-TpID7AXE.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{o as n,t as r}from"./request-DfkRPQFr.mjs";import{r as i}from"./fetchAllRequests-CHHdyb4Q.mjs";import{RequestStatus as a}from"@transcend-io/privacy-types";import o from"colors";import{buildTranscendGraphQLClient 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,requestOrigins:f,auth:p,silentModeBefore:m,createdAtAfter:h,createdAtBefore:g,updatedAtBefore:_,updatedAtAfter:v,concurrency:y=50,transcendUrl:b=e}){let x=s(b,p),S=new Date().getTime(),C=new u.SingleBar({},u.Presets.shades_classic),w=await i(x,{actions:d,statuses:[a.Approving],createdAtAfter:h,createdAtBefore:g,updatedAtBefore:_,updatedAtAfter:v,origins:f});t.info(o.magenta(`Approving "${w.length}" requests.`));let T=0,E=0;C.start(w.length,0),await l(w,async e=>{m&&new Date(m)>new Date(e.createdAt)&&await c(x,n,{variables:{input:{id:e.id,isSilent:!0}},logger:t});try{await c(x,r,{variables:{input:{requestId:e.id}},logger:t})}catch(e){e.message.includes(`Request must be in an approving state,`)&&(E+=1)}T+=1,C.update(T)},{concurrency:y}),C.stop();let D=new Date().getTime()-S;return E>0&&t.info(o.yellow(`${E} requests were skipped.`)),t.info(o.green(`Successfully approved ${T} requests in "${D/1e3}" seconds!`)),w.length}export{d as t};
2
- //# sourceMappingURL=approvePrivacyRequests-BlUcYXpH.mjs.map
1
+ import{a as e}from"./constants-D22_ckyl.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{o as n,t as r}from"./request-DfkRPQFr.mjs";import{r as i}from"./fetchAllRequests-CHHdyb4Q.mjs";import{RequestStatus as a}from"@transcend-io/privacy-types";import o from"colors";import{buildTranscendGraphQLClient 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,requestOrigins:f,auth:p,silentModeBefore:m,createdAtAfter:h,createdAtBefore:g,updatedAtBefore:_,updatedAtAfter:v,concurrency:y=50,transcendUrl:b=e}){let x=s(b,p),S=new Date().getTime(),C=new u.SingleBar({},u.Presets.shades_classic),w=await i(x,{actions:d,statuses:[a.Approving],createdAtAfter:h,createdAtBefore:g,updatedAtBefore:_,updatedAtAfter:v,origins:f});t.info(o.magenta(`Approving "${w.length}" requests.`));let T=0,E=0;C.start(w.length,0),await l(w,async e=>{m&&new Date(m)>new Date(e.createdAt)&&await c(x,n,{variables:{input:{id:e.id,isSilent:!0}},logger:t});try{await c(x,r,{variables:{input:{requestId:e.id}},logger:t})}catch(e){e.message.includes(`Request must be in an approving state,`)&&(E+=1)}T+=1,C.update(T)},{concurrency:y}),C.stop();let D=new Date().getTime()-S;return E>0&&t.info(o.yellow(`${E} requests were skipped.`)),t.info(o.green(`Successfully approved ${T} requests in "${D/1e3}" seconds!`)),w.length}export{d as t};
2
+ //# sourceMappingURL=approvePrivacyRequests-vTXeO7hC.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"approvePrivacyRequests-BlUcYXpH.mjs","names":[],"sources":["../src/lib/requests/approvePrivacyRequests.ts"],"sourcesContent":["import { RequestAction, RequestOrigin, 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 {\n UPDATE_PRIVACY_REQUEST,\n fetchAllRequests,\n APPROVE_PRIVACY_REQUEST,\n} from '../graphql/index.js';\n\n/**\n * Approve a set of privacy requests\n *\n * @param options - Options\n * @returns The number of requests approved\n */\nexport async function approvePrivacyRequests({\n requestActions,\n requestOrigins,\n auth,\n silentModeBefore,\n createdAtAfter,\n createdAtBefore,\n updatedAtBefore,\n updatedAtAfter,\n concurrency = 50,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The request actions that should be restarted */\n requestActions: RequestAction[];\n /** The request origins that should be restarted */\n requestOrigins?: RequestOrigin[];\n /** Transcend API key authentication */\n auth: string;\n /** Concurrency limit for approving */\n concurrency?: number;\n /** Mark these requests as silent mode if they were created before this date */\n silentModeBefore?: Date;\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: [RequestStatus.Approving],\n createdAtAfter,\n createdAtBefore,\n updatedAtBefore,\n updatedAtAfter,\n origins: requestOrigins,\n });\n\n // Notify Transcend\n logger.info(colors.magenta(`Approving \"${allRequests.length}\" requests.`));\n\n let total = 0;\n let skipped = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToApprove) => {\n // update request to silent mode if silentModeBefore is defined\n // and the request was created before silentModeBefore\n if (silentModeBefore && new Date(silentModeBefore) > new Date(requestToApprove.createdAt)) {\n await makeGraphQLRequest(client, UPDATE_PRIVACY_REQUEST, {\n variables: {\n input: {\n id: requestToApprove.id,\n isSilent: true,\n },\n },\n logger,\n });\n }\n\n try {\n // approve the request\n await makeGraphQLRequest(client, APPROVE_PRIVACY_REQUEST, {\n variables: { input: { requestId: requestToApprove.id } },\n logger,\n });\n } catch (err) {\n if (err.message.includes('Request must be in an approving state,')) {\n skipped += 1;\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 if (skipped > 0) {\n logger.info(colors.yellow(`${skipped} requests were skipped.`));\n }\n logger.info(\n colors.green(`Successfully approved ${total} requests in \"${totalTime / 1000}\" seconds!`),\n );\n return allRequests.length;\n}\n"],"mappings":"waAoBA,eAAsB,EAAuB,CAC3C,iBACA,iBACA,OACA,mBACA,iBACA,kBACA,kBACA,iBACA,cAAc,GACd,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,SAAU,CAAC,EAAc,UAAU,CACnC,iBACA,kBACA,kBACA,iBACA,QAAS,EACV,CAAC,CAGF,EAAO,KAAK,EAAO,QAAQ,cAAc,EAAY,OAAO,aAAa,CAAC,CAE1E,IAAI,EAAQ,EACR,EAAU,EACd,EAAY,MAAM,EAAY,OAAQ,EAAE,CACxC,MAAM,EACJ,EACA,KAAO,IAAqB,CAGtB,GAAoB,IAAI,KAAK,EAAiB,CAAG,IAAI,KAAK,EAAiB,UAAU,EACvF,MAAM,EAAmB,EAAQ,EAAwB,CACvD,UAAW,CACT,MAAO,CACL,GAAI,EAAiB,GACrB,SAAU,GACX,CACF,CACD,SACD,CAAC,CAGJ,GAAI,CAEF,MAAM,EAAmB,EAAQ,EAAyB,CACxD,UAAW,CAAE,MAAO,CAAE,UAAW,EAAiB,GAAI,CAAE,CACxD,SACD,CAAC,OACK,EAAK,CACR,EAAI,QAAQ,SAAS,yCAAyC,GAChE,GAAW,GAIf,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAOvB,OANI,EAAU,GACZ,EAAO,KAAK,EAAO,OAAO,GAAG,EAAQ,yBAAyB,CAAC,CAEjE,EAAO,KACL,EAAO,MAAM,yBAAyB,EAAM,gBAAgB,EAAY,IAAK,YAAY,CAC1F,CACM,EAAY"}
1
+ {"version":3,"file":"approvePrivacyRequests-vTXeO7hC.mjs","names":[],"sources":["../src/lib/requests/approvePrivacyRequests.ts"],"sourcesContent":["import { RequestAction, RequestOrigin, 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 {\n UPDATE_PRIVACY_REQUEST,\n fetchAllRequests,\n APPROVE_PRIVACY_REQUEST,\n} from '../graphql/index.js';\n\n/**\n * Approve a set of privacy requests\n *\n * @param options - Options\n * @returns The number of requests approved\n */\nexport async function approvePrivacyRequests({\n requestActions,\n requestOrigins,\n auth,\n silentModeBefore,\n createdAtAfter,\n createdAtBefore,\n updatedAtBefore,\n updatedAtAfter,\n concurrency = 50,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The request actions that should be restarted */\n requestActions: RequestAction[];\n /** The request origins that should be restarted */\n requestOrigins?: RequestOrigin[];\n /** Transcend API key authentication */\n auth: string;\n /** Concurrency limit for approving */\n concurrency?: number;\n /** Mark these requests as silent mode if they were created before this date */\n silentModeBefore?: Date;\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: [RequestStatus.Approving],\n createdAtAfter,\n createdAtBefore,\n updatedAtBefore,\n updatedAtAfter,\n origins: requestOrigins,\n });\n\n // Notify Transcend\n logger.info(colors.magenta(`Approving \"${allRequests.length}\" requests.`));\n\n let total = 0;\n let skipped = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToApprove) => {\n // update request to silent mode if silentModeBefore is defined\n // and the request was created before silentModeBefore\n if (silentModeBefore && new Date(silentModeBefore) > new Date(requestToApprove.createdAt)) {\n await makeGraphQLRequest(client, UPDATE_PRIVACY_REQUEST, {\n variables: {\n input: {\n id: requestToApprove.id,\n isSilent: true,\n },\n },\n logger,\n });\n }\n\n try {\n // approve the request\n await makeGraphQLRequest(client, APPROVE_PRIVACY_REQUEST, {\n variables: { input: { requestId: requestToApprove.id } },\n logger,\n });\n } catch (err) {\n if (err.message.includes('Request must be in an approving state,')) {\n skipped += 1;\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 if (skipped > 0) {\n logger.info(colors.yellow(`${skipped} requests were skipped.`));\n }\n logger.info(\n colors.green(`Successfully approved ${total} requests in \"${totalTime / 1000}\" seconds!`),\n );\n return allRequests.length;\n}\n"],"mappings":"waAoBA,eAAsB,EAAuB,CAC3C,iBACA,iBACA,OACA,mBACA,iBACA,kBACA,kBACA,iBACA,cAAc,GACd,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,SAAU,CAAC,EAAc,UAAU,CACnC,iBACA,kBACA,kBACA,iBACA,QAAS,EACV,CAAC,CAGF,EAAO,KAAK,EAAO,QAAQ,cAAc,EAAY,OAAO,aAAa,CAAC,CAE1E,IAAI,EAAQ,EACR,EAAU,EACd,EAAY,MAAM,EAAY,OAAQ,EAAE,CACxC,MAAM,EACJ,EACA,KAAO,IAAqB,CAGtB,GAAoB,IAAI,KAAK,EAAiB,CAAG,IAAI,KAAK,EAAiB,UAAU,EACvF,MAAM,EAAmB,EAAQ,EAAwB,CACvD,UAAW,CACT,MAAO,CACL,GAAI,EAAiB,GACrB,SAAU,GACX,CACF,CACD,SACD,CAAC,CAGJ,GAAI,CAEF,MAAM,EAAmB,EAAQ,EAAyB,CACxD,UAAW,CAAE,MAAO,CAAE,UAAW,EAAiB,GAAI,CAAE,CACxD,SACD,CAAC,OACK,EAAK,CACR,EAAI,QAAQ,SAAS,yCAAyC,GAChE,GAAW,GAIf,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAOvB,OANI,EAAU,GACZ,EAAO,KAAK,EAAO,OAAO,GAAG,EAAQ,yBAAyB,CAAC,CAEjE,EAAO,KACL,EAAO,MAAM,yBAAyB,EAAM,gBAAgB,EAAY,IAAK,YAAY,CAC1F,CACM,EAAY"}
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{t as e}from"../app-DLzaZHc8.mjs";import{t}from"../context-bkKpii_t.mjs";import{proposeCompletions as n}from"@stricli/core";async function r(){let r=process.argv.slice(3);process.env.COMP_LINE?.endsWith(` `)&&r.push(``),await n(e,r,t(process));try{for(let{completion:i}of await n(e,r,t(process)))process.stdout.write(`${i}\n`)}catch{}}r();export{};
2
+ import{t as e}from"../app-DcwjuHHn.mjs";import{t}from"../context-bkKpii_t.mjs";import{proposeCompletions as n}from"@stricli/core";async function r(){let r=process.argv.slice(3);process.env.COMP_LINE?.endsWith(` `)&&r.push(``),await n(e,r,t(process));try{for(let{completion:i}of await n(e,r,t(process)))process.stdout.write(`${i}\n`)}catch{}}r();export{};
3
3
  //# sourceMappingURL=bash-complete.mjs.map
package/dist/bin/cli.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{t as e}from"../app-DLzaZHc8.mjs";import{t}from"../context-bkKpii_t.mjs";import{run as n}from"@stricli/core";async function r(){await n(e,process.argv.slice(2),t(process))}r();export{};
2
+ import{t as e}from"../app-DcwjuHHn.mjs";import{t}from"../context-bkKpii_t.mjs";import{run as n}from"@stricli/core";async function r(){await n(e,process.argv.slice(2),t(process))}r();export{};
3
3
  //# sourceMappingURL=cli.mjs.map
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{t as e}from"../app-DLzaZHc8.mjs";import{t}from"../logger-Bj782ZYD.mjs";import{generateHelpTextForAllCommands as n}from"@stricli/core";const r={"tr-build-xdi-sync-endpoint":[`consent`,`build-xdi-sync-endpoint`],"tr-consent-manager-service-json-to-yml":[`inventory`,`consent-manager-service-json-to-yml`],"tr-consent-managers-to-business-entities":[`inventory`,`consent-managers-to-business-entities`],"tr-cron-mark-identifiers-completed":[`request`,`cron`,`mark-identifiers-completed`],"tr-cron-pull-identifiers":[`request`,`cron`,`pull-identifiers`],"tr-derive-data-silos-from-data-flows":[`inventory`,`derive-data-silos-from-data-flows`],"tr-derive-data-silos-from-data-flows-cross-instance":[`inventory`,`derive-data-silos-from-data-flows-cross-instance`],"tr-discover-silos":[`inventory`,`discover-silos`],"tr-generate-api-keys":[`admin`,`generate-api-keys`],"tr-manual-enrichment-pull-identifiers":[`request`,`preflight`,`pull-identifiers`],"tr-manual-enrichment-push-identifiers":[`request`,`preflight`,`push-identifiers`],"tr-mark-request-data-silos-completed":[`request`,`system`,`mark-request-data-silos-completed`],"tr-pull":[`inventory`,`pull`],"tr-pull-consent-metrics":[`consent`,`pull-consent-metrics`],"tr-pull-consent-preferences":[`consent`,`pull-consent-preferences`],"tr-pull-datapoints":[`inventory`,`pull-datapoints`],"tr-pull-pull-unstructured-discovery-files":[`inventory`,`pull-unstructured-discovery-files`],"tr-push":[`inventory`,`push`],"tr-request-approve":[`request`,`approve`],"tr-request-cancel":[`request`,`cancel`],"tr-request-download-files":[`request`,`download-files`],"tr-request-enricher-restart":[`request`,`enricher-restart`],"tr-request-export":[`request`,`export`],"tr-request-mark-silent":[`request`,`mark-silent`],"tr-request-notify-additional-time":[`request`,`notify-additional-time`],"tr-request-reject-unverified-identifiers":[`request`,`reject-unverified-identifiers`],"tr-request-restart":[`request`,`restart`],"tr-request-upload":[`request`,`upload`],"tr-retry-request-data-silos":[`request`,`system`,`retry-request-data-silos`],"tr-scan-packages":[`inventory`,`scan-packages`],"tr-skip-preflight-jobs":[`request`,`skip-preflight-jobs`],"tr-skip-request-data-silos":[`request`,`system`,`skip-request-data-silos`],"tr-sync-ot":[`migration`,`sync-ot`],"tr-update-consent-manager":[`consent`,`update-consent-manager`],"tr-upload-consent-preferences":[`consent`,`upload-consent-preferences`],"tr-upload-cookies-from-csv":[`consent`,`upload-cookies-from-csv`],"tr-upload-data-flows-from-csv":[`consent`,`upload-data-flows-from-csv`],"tr-upload-preferences":[`consent`,`upload-preferences`]};function i(t){return n(e).find(n=>n[0]===`${e.config.name} ${t.join(` `)}`)?.[1]}function a(n){t.log(`[DEPRECATION NOTICE]`);let a=r[n];if(!a){let n=Object.entries(r).map(([t,n])=>`\`${t}\` -> \`${e.config.name} ${n.join(` `)}\``).join(`
2
+ import{t as e}from"../app-DcwjuHHn.mjs";import{t}from"../logger-Bj782ZYD.mjs";import{generateHelpTextForAllCommands as n}from"@stricli/core";const r={"tr-build-xdi-sync-endpoint":[`consent`,`build-xdi-sync-endpoint`],"tr-consent-manager-service-json-to-yml":[`inventory`,`consent-manager-service-json-to-yml`],"tr-consent-managers-to-business-entities":[`inventory`,`consent-managers-to-business-entities`],"tr-cron-mark-identifiers-completed":[`request`,`cron`,`mark-identifiers-completed`],"tr-cron-pull-identifiers":[`request`,`cron`,`pull-identifiers`],"tr-derive-data-silos-from-data-flows":[`inventory`,`derive-data-silos-from-data-flows`],"tr-derive-data-silos-from-data-flows-cross-instance":[`inventory`,`derive-data-silos-from-data-flows-cross-instance`],"tr-discover-silos":[`inventory`,`discover-silos`],"tr-generate-api-keys":[`admin`,`generate-api-keys`],"tr-manual-enrichment-pull-identifiers":[`request`,`preflight`,`pull-identifiers`],"tr-manual-enrichment-push-identifiers":[`request`,`preflight`,`push-identifiers`],"tr-mark-request-data-silos-completed":[`request`,`system`,`mark-request-data-silos-completed`],"tr-pull":[`inventory`,`pull`],"tr-pull-consent-metrics":[`consent`,`pull-consent-metrics`],"tr-pull-consent-preferences":[`consent`,`pull-consent-preferences`],"tr-pull-datapoints":[`inventory`,`pull-datapoints`],"tr-pull-pull-unstructured-discovery-files":[`inventory`,`pull-unstructured-discovery-files`],"tr-push":[`inventory`,`push`],"tr-request-approve":[`request`,`approve`],"tr-request-cancel":[`request`,`cancel`],"tr-request-download-files":[`request`,`download-files`],"tr-request-enricher-restart":[`request`,`enricher-restart`],"tr-request-export":[`request`,`export`],"tr-request-mark-silent":[`request`,`mark-silent`],"tr-request-notify-additional-time":[`request`,`notify-additional-time`],"tr-request-reject-unverified-identifiers":[`request`,`reject-unverified-identifiers`],"tr-request-restart":[`request`,`restart`],"tr-request-upload":[`request`,`upload`],"tr-retry-request-data-silos":[`request`,`system`,`retry-request-data-silos`],"tr-scan-packages":[`inventory`,`scan-packages`],"tr-skip-preflight-jobs":[`request`,`skip-preflight-jobs`],"tr-skip-request-data-silos":[`request`,`system`,`skip-request-data-silos`],"tr-sync-ot":[`migration`,`sync-ot`],"tr-update-consent-manager":[`consent`,`update-consent-manager`],"tr-upload-consent-preferences":[`consent`,`upload-consent-preferences`],"tr-upload-cookies-from-csv":[`consent`,`upload-cookies-from-csv`],"tr-upload-data-flows-from-csv":[`consent`,`upload-data-flows-from-csv`],"tr-upload-preferences":[`consent`,`upload-preferences`]};function i(t){return n(e).find(n=>n[0]===`${e.config.name} ${t.join(` `)}`)?.[1]}function a(n){t.log(`[DEPRECATION NOTICE]`);let a=r[n];if(!a){let n=Object.entries(r).map(([t,n])=>`\`${t}\` -> \`${e.config.name} ${n.join(` `)}\``).join(`
3
3
  `);t.log(`This command is deprecated as of v7.0.0. Here is a list of new commands, mapped to their legacy command names:
4
4
  ${n}`);return}t.log(`\`${n}\` is deprecated as of v7.0.0.\nUse \`${e.config.name} ${a.join(` `)}\` instead.\n`);let o=i(a);if(!o)throw Error(`Failed to get help text for command: \`${a.join(` `)}\``);t.log(o)}function o(){let e=process.argv.at(-1)?.split(`/`).pop()?.trim();if(e)a(e);else throw Error(`Deprecated command`);process.exit(1)}o();export{};
5
5
  //# sourceMappingURL=deprecated-command.mjs.map
@@ -1,4 +1,4 @@
1
- import{a as e}from"./constants-TpID7AXE.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{difference as n}from"lodash-es";import r from"colors";import{buildTranscendGraphQLClient as i,fetchConsentManager as a}from"@transcend-io/sdk";import{map as o}from"@transcend-io/utils";const s=e=>new URL(`https://${e}`).hostname.split(`.`).slice(-2).join(`.`),c=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;async function l(l,{xdiLocation:u,transcendUrl:d=e,removeIpAddresses:f=!0,domainBlockList:p=[`localhost`],xdiAllowedCommands:m=`ConsentManager:Sync`}){let h=await o(Array.isArray(l)?l:[{apiKey:l,organizationId:``,organizationName:``}],async e=>(t.info(r.magenta(`Pulling consent metadata for organization - ${e.organizationName}`)),await a(i(d,e.apiKey),{logger:t})),{concurrency:5}),g={};return h.forEach(e=>{let t=e.partition?.partition||e.bundleURL.split(`/`).reverse()[1];g[t]||(g[t]=[]);let r=n(e.configuration.domains.filter(e=>!f||!c.test(e)).map(e=>s(e)),p);g[t]=[...new Set([...g[t]||[],...r])]}),{html:`
1
+ import{a as e}from"./constants-D22_ckyl.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{difference as n}from"lodash-es";import r from"colors";import{buildTranscendGraphQLClient as i,fetchConsentManager as a}from"@transcend-io/sdk";import{map as o}from"@transcend-io/utils";const s=e=>new URL(`https://${e}`).hostname.split(`.`).slice(-2).join(`.`),c=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;async function l(l,{xdiLocation:u,transcendUrl:d=e,removeIpAddresses:f=!0,domainBlockList:p=[`localhost`],xdiAllowedCommands:m=`ConsentManager:Sync`}){let h=await o(Array.isArray(l)?l:[{apiKey:l,organizationId:``,organizationName:``}],async e=>(t.info(r.magenta(`Pulling consent metadata for organization - ${e.organizationName}`)),await a(i(d,e.apiKey),{logger:t})),{concurrency:5}),g={};return h.forEach(e=>{let t=e.partition?.partition||e.bundleURL.split(`/`).reverse()[1];g[t]||(g[t]=[]);let r=n(e.configuration.domains.filter(e=>!f||!c.test(e)).map(e=>s(e)),p);g[t]=[...new Set([...g[t]||[],...r])]}),{html:`
2
2
  <!DOCTYPE html>
3
3
  <script
4
4
  src="${u}"
@@ -6,4 +6,4 @@ data-sync-groups='${JSON.stringify(g,null,2)}'
6
6
  data-xdi-commands="${m}"
7
7
  ><\/script>
8
8
  `,syncGroups:g}}export{l as n,s as r,c as t};
9
- //# sourceMappingURL=buildXdiSyncEndpoint-D5GxPH6o.mjs.map
9
+ //# sourceMappingURL=buildXdiSyncEndpoint-Bd9SRD1A.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildXdiSyncEndpoint-D5GxPH6o.mjs","names":[],"sources":["../src/lib/consent-manager/domainToHost.ts","../src/lib/consent-manager/buildXdiSyncEndpoint.ts"],"sourcesContent":["/**\n * Convert a domain to host\n *\n * @param domain - e.g. test.acme.com\n * @returns Host acme.com\n */\nexport const domainToHost = (domain: string): string =>\n new URL(`https://${domain}`).hostname.split('.').slice(-2).join('.');\n","import { buildTranscendGraphQLClient, fetchConsentManager } from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport colors from 'colors';\nimport { difference } from 'lodash-es';\n\nimport { StoredApiKey } from '../../codecs.js';\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { domainToHost } from './domainToHost.js';\n\n/**\n * Sync group configuration mapping\n * e.g.\n * {\n * \"abdb5e78-0d69-4554-a3bd-84b72ca3b3d9\": [\n * \"test.com\"\n * ],\n * \"f6b3ba87-c9df-444f-b420-6fac49e35910\": [\n * \"blue.com\"\n * ]\n * }\n */\nexport type XdiSyncGroups = { [k in string]: string[] };\n\n/** Regular expression for IP addresses - remove these from sync endpoint */\nexport const IP_ADDRESS_REGEX =\n // eslint-disable-next-line max-len\n /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;\n\n/**\n * Build the sync endpoint definition for a set of Transcend accounts\n *\n * @param apiKeys - The API keys that will be used to pull down configurations for\n * @param options - Options\n * @returns The XDI configuration\n */\nexport async function buildXdiSyncEndpoint(\n apiKeys: string | StoredApiKey[],\n {\n xdiLocation,\n transcendUrl = DEFAULT_TRANSCEND_API,\n removeIpAddresses = true,\n domainBlockList = ['localhost'],\n xdiAllowedCommands = 'ConsentManager:Sync',\n }: {\n /** The file location where the XDI file is hosted */\n xdiLocation: string;\n /** URL of Transcend API */\n transcendUrl?: string;\n /** When true, remove IP addresses (defaults to true) */\n removeIpAddresses?: boolean;\n /** Block list of domains to omit from sync endpoint - includes `localhost` by default */\n domainBlockList?: string[];\n /** Allows XDI commands */\n xdiAllowedCommands?: string;\n },\n): Promise<{\n /** Sync group configurations */\n syncGroups: XdiSyncGroups;\n /** The HTML string */\n html: string;\n}> {\n // Convert API keys to list\n const apiKeysAsList = Array.isArray(apiKeys)\n ? apiKeys\n : [{ apiKey: apiKeys, organizationId: '', organizationName: '' }];\n\n // Fetch configuration for each account\n const consentManagers = await map(\n apiKeysAsList,\n async (apiKey) => {\n logger.info(\n colors.magenta(`Pulling consent metadata for organization - ${apiKey.organizationName}`),\n );\n\n // Create a GraphQL client\n const client = buildTranscendGraphQLClient(transcendUrl, apiKey.apiKey);\n\n // Grab consent manager\n const consentManager = await fetchConsentManager(client, { logger });\n return consentManager;\n },\n { concurrency: 5 },\n );\n\n // construct the sync groups\n const syncGroups: XdiSyncGroups = {};\n consentManagers.forEach((consentManager) => {\n // grab the partition key\n const partitionKey =\n // take explicit key first\n consentManager.partition?.partition ||\n // fallback to bundle ID\n consentManager.bundleURL.split('/').reverse()[1];\n\n // Ensure that partition exists in the sync groups\n if (!syncGroups[partitionKey]) {\n syncGroups[partitionKey] = [];\n }\n\n // Map domain list to a host list\n const hosts = difference(\n consentManager.configuration.domains\n .filter(\n // ignore IP addresses\n (domain) => !removeIpAddresses || !IP_ADDRESS_REGEX.test(domain),\n )\n .map((domain) => domainToHost(domain)),\n // ignore block list\n domainBlockList,\n );\n // merge existing sync group with hosts for this consent manager\n syncGroups[partitionKey] = [...new Set([...(syncGroups[partitionKey] || []), ...hosts])];\n });\n\n // Construct the HTML\n const syncEndpointHtml = `\n<!DOCTYPE html>\n<script\nsrc=\"${xdiLocation}\"\ndata-sync-groups='${JSON.stringify(syncGroups, null, 2)}'\ndata-xdi-commands=\"${xdiAllowedCommands}\"\n></script>\n`;\n\n return {\n html: syncEndpointHtml,\n syncGroups,\n };\n}\n"],"mappings":"kRAMA,MAAa,EAAgB,GAC3B,IAAI,IAAI,WAAW,IAAS,CAAC,SAAS,MAAM,IAAI,CAAC,MAAM,GAAG,CAAC,KAAK,IAAI,CCkBzD,EAEX,mKASF,eAAsB,EACpB,EACA,CACE,cACA,eAAe,EACf,oBAAoB,GACpB,kBAAkB,CAAC,YAAY,CAC/B,qBAAqB,uBAkBtB,CAOD,IAAM,EAAkB,MAAM,EALR,MAAM,QAAQ,EAAQ,CACxC,EACA,CAAC,CAAE,OAAQ,EAAS,eAAgB,GAAI,iBAAkB,GAAI,CAAC,CAKjE,KAAO,KACL,EAAO,KACL,EAAO,QAAQ,+CAA+C,EAAO,mBAAmB,CACzF,CAMsB,MAAM,EAHd,EAA4B,EAAc,EAAO,OAAO,CAGd,CAAE,SAAQ,CAAC,EAGtE,CAAE,YAAa,EAAG,CACnB,CAGK,EAA4B,EAAE,CAuCpC,OAtCA,EAAgB,QAAS,GAAmB,CAE1C,IAAM,EAEJ,EAAe,WAAW,WAE1B,EAAe,UAAU,MAAM,IAAI,CAAC,SAAS,CAAC,GAG3C,EAAW,KACd,EAAW,GAAgB,EAAE,EAI/B,IAAM,EAAQ,EACZ,EAAe,cAAc,QAC1B,OAEE,GAAW,CAAC,GAAqB,CAAC,EAAiB,KAAK,EAAO,CACjE,CACA,IAAK,GAAW,EAAa,EAAO,CAAC,CAExC,EACD,CAED,EAAW,GAAgB,CAAC,GAAG,IAAI,IAAI,CAAC,GAAI,EAAW,IAAiB,EAAE,CAAG,GAAG,EAAM,CAAC,CAAC,EACxF,CAYK,CACL,KAVuB;;;OAGpB,EAAY;oBACC,KAAK,UAAU,EAAY,KAAM,EAAE,CAAC;qBACnC,EAAmB;;EAMpC,aACD"}
1
+ {"version":3,"file":"buildXdiSyncEndpoint-Bd9SRD1A.mjs","names":[],"sources":["../src/lib/consent-manager/domainToHost.ts","../src/lib/consent-manager/buildXdiSyncEndpoint.ts"],"sourcesContent":["/**\n * Convert a domain to host\n *\n * @param domain - e.g. test.acme.com\n * @returns Host acme.com\n */\nexport const domainToHost = (domain: string): string =>\n new URL(`https://${domain}`).hostname.split('.').slice(-2).join('.');\n","import { buildTranscendGraphQLClient, fetchConsentManager } from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport colors from 'colors';\nimport { difference } from 'lodash-es';\n\nimport { StoredApiKey } from '../../codecs.js';\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { domainToHost } from './domainToHost.js';\n\n/**\n * Sync group configuration mapping\n * e.g.\n * {\n * \"abdb5e78-0d69-4554-a3bd-84b72ca3b3d9\": [\n * \"test.com\"\n * ],\n * \"f6b3ba87-c9df-444f-b420-6fac49e35910\": [\n * \"blue.com\"\n * ]\n * }\n */\nexport type XdiSyncGroups = { [k in string]: string[] };\n\n/** Regular expression for IP addresses - remove these from sync endpoint */\nexport const IP_ADDRESS_REGEX =\n // eslint-disable-next-line max-len\n /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;\n\n/**\n * Build the sync endpoint definition for a set of Transcend accounts\n *\n * @param apiKeys - The API keys that will be used to pull down configurations for\n * @param options - Options\n * @returns The XDI configuration\n */\nexport async function buildXdiSyncEndpoint(\n apiKeys: string | StoredApiKey[],\n {\n xdiLocation,\n transcendUrl = DEFAULT_TRANSCEND_API,\n removeIpAddresses = true,\n domainBlockList = ['localhost'],\n xdiAllowedCommands = 'ConsentManager:Sync',\n }: {\n /** The file location where the XDI file is hosted */\n xdiLocation: string;\n /** URL of Transcend API */\n transcendUrl?: string;\n /** When true, remove IP addresses (defaults to true) */\n removeIpAddresses?: boolean;\n /** Block list of domains to omit from sync endpoint - includes `localhost` by default */\n domainBlockList?: string[];\n /** Allows XDI commands */\n xdiAllowedCommands?: string;\n },\n): Promise<{\n /** Sync group configurations */\n syncGroups: XdiSyncGroups;\n /** The HTML string */\n html: string;\n}> {\n // Convert API keys to list\n const apiKeysAsList = Array.isArray(apiKeys)\n ? apiKeys\n : [{ apiKey: apiKeys, organizationId: '', organizationName: '' }];\n\n // Fetch configuration for each account\n const consentManagers = await map(\n apiKeysAsList,\n async (apiKey) => {\n logger.info(\n colors.magenta(`Pulling consent metadata for organization - ${apiKey.organizationName}`),\n );\n\n // Create a GraphQL client\n const client = buildTranscendGraphQLClient(transcendUrl, apiKey.apiKey);\n\n // Grab consent manager\n const consentManager = await fetchConsentManager(client, { logger });\n return consentManager;\n },\n { concurrency: 5 },\n );\n\n // construct the sync groups\n const syncGroups: XdiSyncGroups = {};\n consentManagers.forEach((consentManager) => {\n // grab the partition key\n const partitionKey =\n // take explicit key first\n consentManager.partition?.partition ||\n // fallback to bundle ID\n consentManager.bundleURL.split('/').reverse()[1];\n\n // Ensure that partition exists in the sync groups\n if (!syncGroups[partitionKey]) {\n syncGroups[partitionKey] = [];\n }\n\n // Map domain list to a host list\n const hosts = difference(\n consentManager.configuration.domains\n .filter(\n // ignore IP addresses\n (domain) => !removeIpAddresses || !IP_ADDRESS_REGEX.test(domain),\n )\n .map((domain) => domainToHost(domain)),\n // ignore block list\n domainBlockList,\n );\n // merge existing sync group with hosts for this consent manager\n syncGroups[partitionKey] = [...new Set([...(syncGroups[partitionKey] || []), ...hosts])];\n });\n\n // Construct the HTML\n const syncEndpointHtml = `\n<!DOCTYPE html>\n<script\nsrc=\"${xdiLocation}\"\ndata-sync-groups='${JSON.stringify(syncGroups, null, 2)}'\ndata-xdi-commands=\"${xdiAllowedCommands}\"\n></script>\n`;\n\n return {\n html: syncEndpointHtml,\n syncGroups,\n };\n}\n"],"mappings":"kRAMA,MAAa,EAAgB,GAC3B,IAAI,IAAI,WAAW,IAAS,CAAC,SAAS,MAAM,IAAI,CAAC,MAAM,GAAG,CAAC,KAAK,IAAI,CCkBzD,EAEX,mKASF,eAAsB,EACpB,EACA,CACE,cACA,eAAe,EACf,oBAAoB,GACpB,kBAAkB,CAAC,YAAY,CAC/B,qBAAqB,uBAkBtB,CAOD,IAAM,EAAkB,MAAM,EALR,MAAM,QAAQ,EAAQ,CACxC,EACA,CAAC,CAAE,OAAQ,EAAS,eAAgB,GAAI,iBAAkB,GAAI,CAAC,CAKjE,KAAO,KACL,EAAO,KACL,EAAO,QAAQ,+CAA+C,EAAO,mBAAmB,CACzF,CAMsB,MAAM,EAHd,EAA4B,EAAc,EAAO,OAAO,CAGd,CAAE,SAAQ,CAAC,EAGtE,CAAE,YAAa,EAAG,CACnB,CAGK,EAA4B,EAAE,CAuCpC,OAtCA,EAAgB,QAAS,GAAmB,CAE1C,IAAM,EAEJ,EAAe,WAAW,WAE1B,EAAe,UAAU,MAAM,IAAI,CAAC,SAAS,CAAC,GAG3C,EAAW,KACd,EAAW,GAAgB,EAAE,EAI/B,IAAM,EAAQ,EACZ,EAAe,cAAc,QAC1B,OAEE,GAAW,CAAC,GAAqB,CAAC,EAAiB,KAAK,EAAO,CACjE,CACA,IAAK,GAAW,EAAa,EAAO,CAAC,CAExC,EACD,CAED,EAAW,GAAgB,CAAC,GAAG,IAAI,IAAI,CAAC,GAAI,EAAW,IAAiB,EAAE,CAAG,GAAG,EAAM,CAAC,CAAC,EACxF,CAYK,CACL,KAVuB;;;OAGpB,EAAY;oBACC,KAAK,UAAU,EAAY,KAAM,EAAE,CAAC;qBACnC,EAAmB;;EAMpC,aACD"}
@@ -1,2 +1,2 @@
1
- import{a as e}from"./constants-TpID7AXE.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{s as n,u as r}from"./constants-ClkQQhJs.mjs";import{r as i}from"./fetchAllRequests-CHHdyb4Q.mjs";import{n as a,t as o}from"./extractClientError-i-Tw_az7.mjs";import{IdentifierType as s}from"@transcend-io/privacy-types";import{difference as c,groupBy as l}from"lodash-es";import{apply as u,decodeCodec as d}from"@transcend-io/type-utils";import{join as f,resolve as p}from"node:path";import m from"colors";import*as h from"io-ts";import{buildTranscendGraphQLClient as g,createSombraGotInstance as _,fetchAllRequestIdentifiers as v,validateSombraVersion as y}from"@transcend-io/sdk";import{map as b}from"@transcend-io/utils";import x from"cli-progress";import{PersistedState as S}from"@transcend-io/persisted-state";async function C(e,t,{sendEmailReceipt:r=!1,skipWaitingPeriod:i=!1,emailIsVerified:o=!0,requestIdentifiers:c=[]}={}){let f=await e.post(`v1/data-subject-request`,{json:{type:t.type,subject:{coreIdentifier:t.coreIdentifier,email:t.email,emailIsVerified:o,...c.length>0?{attestedExtraIdentifiers:u(l(c.filter(e=>!(e.name===`email`&&e.value===t.email)&&!n.includes(e.name)).map(e=>({...e,type:Object.values(s).includes(e.name)?e.name:s.Custom})),`type`),(e,t)=>e.map(({name:e,value:n})=>({...t===s.Custom?{name:e}:{},value:n})))}:{}},requestId:t.id,subjectType:t.subjectType,isSilent:t.isSilent,isTest:t.isTest,locale:t.locale,skipWaitingPeriod:i,createdAt:t.createdAt,details:`Restarted by Transcend cli: "tr-request-restart" - ${t.details}`,skipSendingReceipt:!r}}).json(),{request:p}=d(h.type({request:a}),f);return p}const w=h.intersection([r,h.type({error:h.string})]),T=h.type({restartedRequests:h.array(r),failingRequests:h.array(w)});async function E({requestReceiptFolder:n,auth:r,sombraAuth:a,requestActions:s,requestStatuses:l,createdAtBefore:u,createdAtAfter:d,updatedAtBefore:h,updatedAtAfter:w,transcendUrl:E=e,requestIds:D=[],createdAt:O=new Date,silentModeBefore:k,sendEmailReceipt:A=!1,emailIsVerified:j=!0,copyIdentifiers:M=!1,skipWaitingPeriod:N=!1,concurrency:P=20}){let F=new Date().getTime(),I=new x.SingleBar({},x.Presets.shades_classic),L=f(n,`tr-request-restart-${new Date().toISOString()}.json`),R=new S(L,T,{restartedRequests:[],failingRequests:[]}),z=await _(E,r,{logger:t,sombraApiKey:a,sombraUrl:process.env.SOMBRA_URL}),B=g(E,r),V=(await i(B,{requestIds:D,actions:s,statuses:l,createdAtBefore:u,createdAtAfter:d,updatedAtBefore:h,updatedAtAfter:w})).filter(e=>new Date(e.createdAt)<O);if(t.info(`Found ${V.length} requests to restart`),M&&t.info(`copyIdentifiers detected - All Identifiers will be copied.`),A&&t.info(`sendEmailReceipt detected - Email receipts will be sent.`),N&&t.info(`skipWaitingPeriod detected - Waiting period will be skipped.`),D.length>0&&D.length!==V.length){let e=c(D,V.map(({id:e})=>e));e.length>0&&(t.error(m.red(`Failed to find the following requests by ID: ${e.join(`,`)}.`)),process.exit(1))}M&&await y(B,{logger:t});let H=0;I.start(V.length,0),await b(V,async(e,n)=>{try{let r=M?await v(B,z,{filterBy:{requestId:e.id},skipSombraCheck:!0,logger:t}):[],i=await C(z,{...e,isSilent:k&&new Date(e.createdAt)<k?!0:e.isSilent},{requestIdentifiers:r,skipWaitingPeriod:N,sendEmailReceipt:A,emailIsVerified:j}),a=R.getValue(`restartedRequests`);a.push({id:i.id,link:i.link,rowIndex:n,coreIdentifier:i.coreIdentifier,attemptedAt:new Date().toISOString()}),await R.setValue(a,`restartedRequests`)}catch(t){let r=`${t.message} - ${JSON.stringify(t.response?.body,null,2)}`,i=o(r),a=R.getValue(`failingRequests`);a.push({id:e.id,link:e.link,rowIndex:n,coreIdentifier:e.coreIdentifier,attemptedAt:new Date().toISOString(),error:i||r}),await R.setValue(a,`failingRequests`)}H+=1,I.update(H)},{concurrency:P}),I.stop();let U=new Date().getTime()-F;t.info(m.green(`Completed restarting of requests in "${U/1e3}" seconds.`)),R.getValue(`failingRequests`).length>0&&(t.error(m.red(`Encountered "${R.getValue(`failingRequests`).length}" errors. See "${p(L)}" to review the error messages and inputs.`)),process.exit(1))}export{C as n,E as t};
2
- //# sourceMappingURL=bulkRestartRequests-DILDBdc1.mjs.map
1
+ import{a as e}from"./constants-D22_ckyl.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{s as n,u as r}from"./constants-ClkQQhJs.mjs";import{r as i}from"./fetchAllRequests-CHHdyb4Q.mjs";import{n as a,t as o}from"./extractClientError-i-Tw_az7.mjs";import{IdentifierType as s}from"@transcend-io/privacy-types";import{difference as c,groupBy as l}from"lodash-es";import{apply as u,decodeCodec as d}from"@transcend-io/type-utils";import{join as f,resolve as p}from"node:path";import m from"colors";import*as h from"io-ts";import{buildTranscendGraphQLClient as g,createSombraGotInstance as _,fetchAllRequestIdentifiers as v,validateSombraVersion as y}from"@transcend-io/sdk";import{map as b}from"@transcend-io/utils";import x from"cli-progress";import{PersistedState as S}from"@transcend-io/persisted-state";async function C(e,t,{sendEmailReceipt:r=!1,skipWaitingPeriod:i=!1,emailIsVerified:o=!0,requestIdentifiers:c=[]}={}){let f=await e.post(`v1/data-subject-request`,{json:{type:t.type,subject:{coreIdentifier:t.coreIdentifier,email:t.email,emailIsVerified:o,...c.length>0?{attestedExtraIdentifiers:u(l(c.filter(e=>!(e.name===`email`&&e.value===t.email)&&!n.includes(e.name)).map(e=>({...e,type:Object.values(s).includes(e.name)?e.name:s.Custom})),`type`),(e,t)=>e.map(({name:e,value:n})=>({...t===s.Custom?{name:e}:{},value:n})))}:{}},requestId:t.id,subjectType:t.subjectType,isSilent:t.isSilent,isTest:t.isTest,locale:t.locale,skipWaitingPeriod:i,createdAt:t.createdAt,details:`Restarted by Transcend cli: "tr-request-restart" - ${t.details}`,skipSendingReceipt:!r}}).json(),{request:p}=d(h.type({request:a}),f);return p}const w=h.intersection([r,h.type({error:h.string})]),T=h.type({restartedRequests:h.array(r),failingRequests:h.array(w)});async function E({requestReceiptFolder:n,auth:r,sombraAuth:a,requestActions:s,requestStatuses:l,createdAtBefore:u,createdAtAfter:d,updatedAtBefore:h,updatedAtAfter:w,transcendUrl:E=e,requestIds:D=[],createdAt:O=new Date,silentModeBefore:k,sendEmailReceipt:A=!1,emailIsVerified:j=!0,copyIdentifiers:M=!1,skipWaitingPeriod:N=!1,concurrency:P=20}){let F=new Date().getTime(),I=new x.SingleBar({},x.Presets.shades_classic),L=f(n,`tr-request-restart-${new Date().toISOString()}.json`),R=new S(L,T,{restartedRequests:[],failingRequests:[]}),z=await _(E,r,{logger:t,sombraApiKey:a,sombraUrl:process.env.SOMBRA_URL}),B=g(E,r),V=(await i(B,{requestIds:D,actions:s,statuses:l,createdAtBefore:u,createdAtAfter:d,updatedAtBefore:h,updatedAtAfter:w})).filter(e=>new Date(e.createdAt)<O);if(t.info(`Found ${V.length} requests to restart`),M&&t.info(`copyIdentifiers detected - All Identifiers will be copied.`),A&&t.info(`sendEmailReceipt detected - Email receipts will be sent.`),N&&t.info(`skipWaitingPeriod detected - Waiting period will be skipped.`),D.length>0&&D.length!==V.length){let e=c(D,V.map(({id:e})=>e));e.length>0&&(t.error(m.red(`Failed to find the following requests by ID: ${e.join(`,`)}.`)),process.exit(1))}M&&await y(B,{logger:t});let H=0;I.start(V.length,0),await b(V,async(e,n)=>{try{let r=M?await v(B,z,{filterBy:{requestId:e.id},skipSombraCheck:!0,logger:t}):[],i=await C(z,{...e,isSilent:k&&new Date(e.createdAt)<k?!0:e.isSilent},{requestIdentifiers:r,skipWaitingPeriod:N,sendEmailReceipt:A,emailIsVerified:j}),a=R.getValue(`restartedRequests`);a.push({id:i.id,link:i.link,rowIndex:n,coreIdentifier:i.coreIdentifier,attemptedAt:new Date().toISOString()}),await R.setValue(a,`restartedRequests`)}catch(t){let r=`${t.message} - ${JSON.stringify(t.response?.body,null,2)}`,i=o(r),a=R.getValue(`failingRequests`);a.push({id:e.id,link:e.link,rowIndex:n,coreIdentifier:e.coreIdentifier,attemptedAt:new Date().toISOString(),error:i||r}),await R.setValue(a,`failingRequests`)}H+=1,I.update(H)},{concurrency:P}),I.stop();let U=new Date().getTime()-F;t.info(m.green(`Completed restarting of requests in "${U/1e3}" seconds.`)),R.getValue(`failingRequests`).length>0&&(t.error(m.red(`Encountered "${R.getValue(`failingRequests`).length}" errors. See "${p(L)}" to review the error messages and inputs.`)),process.exit(1))}export{C as n,E as t};
2
+ //# sourceMappingURL=bulkRestartRequests-BvURrcOl.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bulkRestartRequests-DILDBdc1.mjs","names":[],"sources":["../src/lib/requests/restartPrivacyRequest.ts","../src/lib/requests/bulkRestartRequests.ts"],"sourcesContent":["import { IdentifierType } from '@transcend-io/privacy-types';\nimport type { RequestIdentifier } from '@transcend-io/sdk';\nimport { apply, decodeCodec } from '@transcend-io/type-utils';\nimport type { Got } from 'got';\nimport * as t from 'io-ts';\nimport { groupBy } from 'lodash-es';\n\nimport type { PrivacyRequest } from '../graphql/index.js';\nimport { IDENTIFIER_BLOCK_LIST } from './constants.js';\nimport { PrivacyRequestResponse } from './submitPrivacyRequest.js';\n\n/**\n * Restart a privacy request to the Transcend API\n *\n * @param sombra - Sombra instance configured to make requests\n * @param request - Request to restart\n * @param input - Request input\n * @returns Successfully submitted request\n */\nexport async function restartPrivacyRequest(\n sombra: Got,\n request: PrivacyRequest,\n {\n sendEmailReceipt = false,\n skipWaitingPeriod = false,\n emailIsVerified = true,\n requestIdentifiers = [],\n }: {\n /** List of request identifiers to include */\n requestIdentifiers?: RequestIdentifier[];\n /** When true, send an email receipt to data subject */\n sendEmailReceipt?: boolean;\n /** Whether the email is verified */\n emailIsVerified?: boolean;\n /** Whether to skip waiting period */\n skipWaitingPeriod?: boolean;\n } = {},\n): Promise<PrivacyRequestResponse> {\n // Make the GraphQL request\n const response = await sombra\n .post('v1/data-subject-request', {\n json: {\n type: request.type,\n subject: {\n coreIdentifier: request.coreIdentifier,\n email: request.email,\n emailIsVerified,\n ...(requestIdentifiers.length > 0\n ? {\n attestedExtraIdentifiers: apply(\n groupBy(\n requestIdentifiers\n .filter(\n (ri) =>\n // these are already submitted above\n !(ri.name === 'email' && ri.value === request.email) &&\n !IDENTIFIER_BLOCK_LIST.includes(ri.name),\n )\n .map((ri) => ({\n ...ri,\n type: Object.values(IdentifierType).includes(\n ri.name as any, // eslint-disable-line @typescript-eslint/no-explicit-any\n )\n ? ri.name\n : IdentifierType.Custom,\n })),\n 'type',\n ),\n (values, type) =>\n values.map(({ name, value }) => ({\n ...(type === IdentifierType.Custom ? { name } : {}),\n value,\n })),\n ),\n }\n : {}),\n },\n requestId: request.id,\n subjectType: request.subjectType,\n isSilent: request.isSilent,\n isTest: request.isTest,\n locale: request.locale,\n skipWaitingPeriod,\n createdAt: request.createdAt,\n details: `Restarted by Transcend cli: \"tr-request-restart\" - ${request.details}`,\n skipSendingReceipt: !sendEmailReceipt,\n },\n })\n .json();\n\n const { request: requestResponse } = decodeCodec(\n t.type({\n request: PrivacyRequestResponse,\n }),\n response,\n );\n return requestResponse;\n}\n","import { join, resolve } from 'node:path';\n\nimport { PersistedState } from '@transcend-io/persisted-state';\nimport { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllRequestIdentifiers,\n validateSombraVersion,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport * as t from 'io-ts';\nimport { difference } from 'lodash-es';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { fetchAllRequests } from '../graphql/index.js';\nimport { SuccessfulRequest } from './constants.js';\nimport { extractClientError } from './extractClientError.js';\nimport { restartPrivacyRequest } from './restartPrivacyRequest.js';\n\n/** Minimal state we need to keep a list of requests */\nconst ErrorRequest = t.intersection([\n SuccessfulRequest,\n t.type({\n error: t.string,\n }),\n]);\n\n/** Type override */\ntype ErrorRequest = t.TypeOf<typeof ErrorRequest>;\n\n/** Persist this data between runs of the script */\nconst CachedRequestState = t.type({\n restartedRequests: t.array(SuccessfulRequest),\n failingRequests: t.array(ErrorRequest),\n});\n\n/**\n * Upload a set of privacy requests from CSV\n *\n * @param options - Options\n */\nexport async function bulkRestartRequests({\n requestReceiptFolder,\n auth,\n sombraAuth,\n requestActions,\n requestStatuses,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n transcendUrl = DEFAULT_TRANSCEND_API,\n requestIds = [],\n createdAt = new Date(),\n silentModeBefore,\n sendEmailReceipt = false,\n emailIsVerified = true,\n copyIdentifiers = false,\n skipWaitingPeriod = false,\n concurrency = 20,\n}: {\n /** Actions to filter for */\n requestActions: RequestAction[];\n /** Statues to filter for */\n requestStatuses: RequestStatus[];\n /** File where request receipts are stored */\n requestReceiptFolder: string;\n /** Transcend API key authentication */\n auth: string;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Request IDs to filter for */\n requestIds?: string[];\n /** Whether to re-verify the email when restarting the request */\n emailIsVerified?: boolean;\n /** Filter for requests that were submitted before this date */\n createdAt?: Date;\n /** Requests that have been open for this length of time should be marked as silent mode */\n silentModeBefore?: Date;\n /** Send an email receipt to the restarted requests */\n sendEmailReceipt?: boolean;\n /** Copy over all identifiers rather than restarting the request only with the core identifier */\n copyIdentifiers?: boolean;\n /** Skip the waiting period when restarting requests */\n skipWaitingPeriod?: boolean;\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 /** Concurrency to upload requests at */\n concurrency?: number;\n}): Promise<void> {\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 // Create a new state file to store the requests from this run\n const cacheFile = join(\n requestReceiptFolder,\n `tr-request-restart-${new Date().toISOString()}.json`,\n );\n const state = new PersistedState(cacheFile, CachedRequestState, {\n restartedRequests: [],\n failingRequests: [],\n });\n\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n const allRequests = await fetchAllRequests(client, {\n requestIds,\n actions: requestActions,\n statuses: requestStatuses,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n });\n const requests = allRequests.filter((request) => new Date(request.createdAt) < createdAt);\n logger.info(`Found ${requests.length} requests to restart`);\n\n if (copyIdentifiers) {\n logger.info('copyIdentifiers detected - All Identifiers will be copied.');\n }\n if (sendEmailReceipt) {\n logger.info('sendEmailReceipt detected - Email receipts will be sent.');\n }\n if (skipWaitingPeriod) {\n logger.info('skipWaitingPeriod detected - Waiting period will be skipped.');\n }\n\n // Validate request IDs\n if (requestIds.length > 0 && requestIds.length !== requests.length) {\n const missingRequests = difference(\n requestIds,\n requests.map(({ id }) => id),\n );\n if (missingRequests.length > 0) {\n logger.error(\n colors.red(`Failed to find the following requests by ID: ${missingRequests.join(',')}.`),\n );\n process.exit(1);\n }\n }\n\n if (copyIdentifiers) {\n await validateSombraVersion(client, { logger });\n }\n\n // Map over the requests\n let total = 0;\n progressBar.start(requests.length, 0);\n await map(\n requests,\n async (request, ind) => {\n try {\n // Pull the request identifiers\n const requestIdentifiers = copyIdentifiers\n ? await fetchAllRequestIdentifiers(client, sombra, {\n filterBy: { requestId: request.id },\n skipSombraCheck: true,\n logger,\n })\n : [];\n\n // Make the GraphQL request to restart the request\n const requestResponse = await restartPrivacyRequest(\n sombra,\n {\n ...request,\n // override silent mode\n isSilent:\n !!silentModeBefore && new Date(request.createdAt) < silentModeBefore\n ? true\n : request.isSilent,\n },\n {\n requestIdentifiers,\n skipWaitingPeriod,\n sendEmailReceipt,\n emailIsVerified,\n },\n );\n\n // Cache successful upload\n const restartedRequests = state.getValue('restartedRequests');\n restartedRequests.push({\n id: requestResponse.id,\n link: requestResponse.link,\n rowIndex: ind,\n coreIdentifier: requestResponse.coreIdentifier,\n attemptedAt: new Date().toISOString(),\n });\n await state.setValue(restartedRequests, 'restartedRequests');\n } catch (err) {\n const msg = `${err.message} - ${JSON.stringify(err.response?.body, null, 2)}`;\n const clientError = extractClientError(msg);\n\n const failingRequests = state.getValue('failingRequests');\n failingRequests.push({\n id: request.id,\n link: request.link,\n rowIndex: ind,\n coreIdentifier: request.coreIdentifier,\n attemptedAt: new Date().toISOString(),\n error: clientError || msg,\n });\n await state.setValue(failingRequests, 'failingRequests');\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 // Log completion time\n logger.info(colors.green(`Completed restarting of requests in \"${totalTime / 1000}\" seconds.`));\n\n // Log errors\n if (state.getValue('failingRequests').length > 0) {\n logger.error(\n colors.red(\n `Encountered \"${state.getValue('failingRequests').length}\" errors. ` +\n `See \"${resolve(cacheFile)}\" to review the error messages and inputs.`,\n ),\n );\n process.exit(1);\n }\n}\n"],"mappings":"myBAmBA,eAAsB,EACpB,EACA,EACA,CACE,mBAAmB,GACnB,oBAAoB,GACpB,kBAAkB,GAClB,qBAAqB,EAAE,EAUrB,EAAE,CAC2B,CAEjC,IAAM,EAAW,MAAM,EACpB,KAAK,0BAA2B,CAC/B,KAAM,CACJ,KAAM,EAAQ,KACd,QAAS,CACP,eAAgB,EAAQ,eACxB,MAAO,EAAQ,MACf,kBACA,GAAI,EAAmB,OAAS,EAC5B,CACE,yBAA0B,EACxB,EACE,EACG,OACE,GAEC,EAAE,EAAG,OAAS,SAAW,EAAG,QAAU,EAAQ,QAC9C,CAAC,EAAsB,SAAS,EAAG,KAAK,CAC3C,CACA,IAAK,IAAQ,CACZ,GAAG,EACH,KAAM,OAAO,OAAO,EAAe,CAAC,SAClC,EAAG,KACJ,CACG,EAAG,KACH,EAAe,OACpB,EAAE,CACL,OACD,EACA,EAAQ,IACP,EAAO,KAAK,CAAE,OAAM,YAAa,CAC/B,GAAI,IAAS,EAA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ErC,EAAkB,EAAM,SAAS,kBAAkB,CACzD,EAAgB,KAAK,CACnB,GAAI,EAAQ,GACZ,KAAM,EAAQ,KACd,SAAU,EACV,eAAgB,EAAQ,eACxB,YAAa,IAAI,MAAM,CAAC,aAAa,CACrC,MAAO,GAAe,EACvB,CAAC,CACF,MAAM,EAAM,SAAS,EAAiB,kBAAkB,CAE1D,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAGvB,EAAO,KAAK,EAAO,MAAM,wCAAwC,EAAY,IAAK,YAAY,CAAC,CAG3F,EAAM,SAAS,kBAAkB,CAAC,OAAS,IAC7C,EAAO,MACL,EAAO,IACL,gBAAgB,EAAM,SAAS,kBAAkB,CAAC,OAAO,iBAC/C,EAAQ,EAAU,CAAC,4CAC9B,CACF,CACD,QAAQ,KAAK,EAAE"}
1
+ {"version":3,"file":"bulkRestartRequests-BvURrcOl.mjs","names":[],"sources":["../src/lib/requests/restartPrivacyRequest.ts","../src/lib/requests/bulkRestartRequests.ts"],"sourcesContent":["import { IdentifierType } from '@transcend-io/privacy-types';\nimport type { RequestIdentifier } from '@transcend-io/sdk';\nimport { apply, decodeCodec } from '@transcend-io/type-utils';\nimport type { Got } from 'got';\nimport * as t from 'io-ts';\nimport { groupBy } from 'lodash-es';\n\nimport type { PrivacyRequest } from '../graphql/index.js';\nimport { IDENTIFIER_BLOCK_LIST } from './constants.js';\nimport { PrivacyRequestResponse } from './submitPrivacyRequest.js';\n\n/**\n * Restart a privacy request to the Transcend API\n *\n * @param sombra - Sombra instance configured to make requests\n * @param request - Request to restart\n * @param input - Request input\n * @returns Successfully submitted request\n */\nexport async function restartPrivacyRequest(\n sombra: Got,\n request: PrivacyRequest,\n {\n sendEmailReceipt = false,\n skipWaitingPeriod = false,\n emailIsVerified = true,\n requestIdentifiers = [],\n }: {\n /** List of request identifiers to include */\n requestIdentifiers?: RequestIdentifier[];\n /** When true, send an email receipt to data subject */\n sendEmailReceipt?: boolean;\n /** Whether the email is verified */\n emailIsVerified?: boolean;\n /** Whether to skip waiting period */\n skipWaitingPeriod?: boolean;\n } = {},\n): Promise<PrivacyRequestResponse> {\n // Make the GraphQL request\n const response = await sombra\n .post('v1/data-subject-request', {\n json: {\n type: request.type,\n subject: {\n coreIdentifier: request.coreIdentifier,\n email: request.email,\n emailIsVerified,\n ...(requestIdentifiers.length > 0\n ? {\n attestedExtraIdentifiers: apply(\n groupBy(\n requestIdentifiers\n .filter(\n (ri) =>\n // these are already submitted above\n !(ri.name === 'email' && ri.value === request.email) &&\n !IDENTIFIER_BLOCK_LIST.includes(ri.name),\n )\n .map((ri) => ({\n ...ri,\n type: Object.values(IdentifierType).includes(\n ri.name as any, // eslint-disable-line @typescript-eslint/no-explicit-any\n )\n ? ri.name\n : IdentifierType.Custom,\n })),\n 'type',\n ),\n (values, type) =>\n values.map(({ name, value }) => ({\n ...(type === IdentifierType.Custom ? { name } : {}),\n value,\n })),\n ),\n }\n : {}),\n },\n requestId: request.id,\n subjectType: request.subjectType,\n isSilent: request.isSilent,\n isTest: request.isTest,\n locale: request.locale,\n skipWaitingPeriod,\n createdAt: request.createdAt,\n details: `Restarted by Transcend cli: \"tr-request-restart\" - ${request.details}`,\n skipSendingReceipt: !sendEmailReceipt,\n },\n })\n .json();\n\n const { request: requestResponse } = decodeCodec(\n t.type({\n request: PrivacyRequestResponse,\n }),\n response,\n );\n return requestResponse;\n}\n","import { join, resolve } from 'node:path';\n\nimport { PersistedState } from '@transcend-io/persisted-state';\nimport { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllRequestIdentifiers,\n validateSombraVersion,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport * as t from 'io-ts';\nimport { difference } from 'lodash-es';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { fetchAllRequests } from '../graphql/index.js';\nimport { SuccessfulRequest } from './constants.js';\nimport { extractClientError } from './extractClientError.js';\nimport { restartPrivacyRequest } from './restartPrivacyRequest.js';\n\n/** Minimal state we need to keep a list of requests */\nconst ErrorRequest = t.intersection([\n SuccessfulRequest,\n t.type({\n error: t.string,\n }),\n]);\n\n/** Type override */\ntype ErrorRequest = t.TypeOf<typeof ErrorRequest>;\n\n/** Persist this data between runs of the script */\nconst CachedRequestState = t.type({\n restartedRequests: t.array(SuccessfulRequest),\n failingRequests: t.array(ErrorRequest),\n});\n\n/**\n * Upload a set of privacy requests from CSV\n *\n * @param options - Options\n */\nexport async function bulkRestartRequests({\n requestReceiptFolder,\n auth,\n sombraAuth,\n requestActions,\n requestStatuses,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n transcendUrl = DEFAULT_TRANSCEND_API,\n requestIds = [],\n createdAt = new Date(),\n silentModeBefore,\n sendEmailReceipt = false,\n emailIsVerified = true,\n copyIdentifiers = false,\n skipWaitingPeriod = false,\n concurrency = 20,\n}: {\n /** Actions to filter for */\n requestActions: RequestAction[];\n /** Statues to filter for */\n requestStatuses: RequestStatus[];\n /** File where request receipts are stored */\n requestReceiptFolder: string;\n /** Transcend API key authentication */\n auth: string;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Request IDs to filter for */\n requestIds?: string[];\n /** Whether to re-verify the email when restarting the request */\n emailIsVerified?: boolean;\n /** Filter for requests that were submitted before this date */\n createdAt?: Date;\n /** Requests that have been open for this length of time should be marked as silent mode */\n silentModeBefore?: Date;\n /** Send an email receipt to the restarted requests */\n sendEmailReceipt?: boolean;\n /** Copy over all identifiers rather than restarting the request only with the core identifier */\n copyIdentifiers?: boolean;\n /** Skip the waiting period when restarting requests */\n skipWaitingPeriod?: boolean;\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 /** Concurrency to upload requests at */\n concurrency?: number;\n}): Promise<void> {\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 // Create a new state file to store the requests from this run\n const cacheFile = join(\n requestReceiptFolder,\n `tr-request-restart-${new Date().toISOString()}.json`,\n );\n const state = new PersistedState(cacheFile, CachedRequestState, {\n restartedRequests: [],\n failingRequests: [],\n });\n\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n const allRequests = await fetchAllRequests(client, {\n requestIds,\n actions: requestActions,\n statuses: requestStatuses,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n });\n const requests = allRequests.filter((request) => new Date(request.createdAt) < createdAt);\n logger.info(`Found ${requests.length} requests to restart`);\n\n if (copyIdentifiers) {\n logger.info('copyIdentifiers detected - All Identifiers will be copied.');\n }\n if (sendEmailReceipt) {\n logger.info('sendEmailReceipt detected - Email receipts will be sent.');\n }\n if (skipWaitingPeriod) {\n logger.info('skipWaitingPeriod detected - Waiting period will be skipped.');\n }\n\n // Validate request IDs\n if (requestIds.length > 0 && requestIds.length !== requests.length) {\n const missingRequests = difference(\n requestIds,\n requests.map(({ id }) => id),\n );\n if (missingRequests.length > 0) {\n logger.error(\n colors.red(`Failed to find the following requests by ID: ${missingRequests.join(',')}.`),\n );\n process.exit(1);\n }\n }\n\n if (copyIdentifiers) {\n await validateSombraVersion(client, { logger });\n }\n\n // Map over the requests\n let total = 0;\n progressBar.start(requests.length, 0);\n await map(\n requests,\n async (request, ind) => {\n try {\n // Pull the request identifiers\n const requestIdentifiers = copyIdentifiers\n ? await fetchAllRequestIdentifiers(client, sombra, {\n filterBy: { requestId: request.id },\n skipSombraCheck: true,\n logger,\n })\n : [];\n\n // Make the GraphQL request to restart the request\n const requestResponse = await restartPrivacyRequest(\n sombra,\n {\n ...request,\n // override silent mode\n isSilent:\n !!silentModeBefore && new Date(request.createdAt) < silentModeBefore\n ? true\n : request.isSilent,\n },\n {\n requestIdentifiers,\n skipWaitingPeriod,\n sendEmailReceipt,\n emailIsVerified,\n },\n );\n\n // Cache successful upload\n const restartedRequests = state.getValue('restartedRequests');\n restartedRequests.push({\n id: requestResponse.id,\n link: requestResponse.link,\n rowIndex: ind,\n coreIdentifier: requestResponse.coreIdentifier,\n attemptedAt: new Date().toISOString(),\n });\n await state.setValue(restartedRequests, 'restartedRequests');\n } catch (err) {\n const msg = `${err.message} - ${JSON.stringify(err.response?.body, null, 2)}`;\n const clientError = extractClientError(msg);\n\n const failingRequests = state.getValue('failingRequests');\n failingRequests.push({\n id: request.id,\n link: request.link,\n rowIndex: ind,\n coreIdentifier: request.coreIdentifier,\n attemptedAt: new Date().toISOString(),\n error: clientError || msg,\n });\n await state.setValue(failingRequests, 'failingRequests');\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 // Log completion time\n logger.info(colors.green(`Completed restarting of requests in \"${totalTime / 1000}\" seconds.`));\n\n // Log errors\n if (state.getValue('failingRequests').length > 0) {\n logger.error(\n colors.red(\n `Encountered \"${state.getValue('failingRequests').length}\" errors. ` +\n `See \"${resolve(cacheFile)}\" to review the error messages and inputs.`,\n ),\n );\n process.exit(1);\n }\n}\n"],"mappings":"myBAmBA,eAAsB,EACpB,EACA,EACA,CACE,mBAAmB,GACnB,oBAAoB,GACpB,kBAAkB,GAClB,qBAAqB,EAAE,EAUrB,EAAE,CAC2B,CAEjC,IAAM,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,MAAM,EAC5B,EACA,CACE,GAAG,EAEH,SACI,GAAoB,IAAI,KAAK,EAAQ,UAAU,CAAG,EAChD,GACA,EAAQ,SACf,CACD,CACE,qBACA,oBACA,mBACA,kBACD,CACF,CAGK,EAAoB,EAAM,SAAS,oBAAoB,CAC7D,EAAkB,KAAK,CACrB,GAAI,EAAgB,GACpB,KAAM,EAAgB,KACtB,SAAU,EACV,eAAgB,EAAgB,eAChC,YAAa,IAAI,MAAM,CAAC,aAAa,CACtC,CAAC,CACF,MAAM,EAAM,SAAS,EAAmB,oBAAoB,OACrD,EAAK,CACZ,IAAM,EAAM,GAAG,EAAI,QAAQ,KAAK,KAAK,UAAU,EAAI,UAAU,KAAM,KAAM,EAAE,GACrE,EAAc,EAAmB,EAAI,CAErC,EAAkB,EAAM,SAAS,kBAAkB,CACzD,EAAgB,KAAK,CACnB,GAAI,EAAQ,GACZ,KAAM,EAAQ,KACd,SAAU,EACV,eAAgB,EAAQ,eACxB,YAAa,IAAI,MAAM,CAAC,aAAa,CACrC,MAAO,GAAe,EACvB,CAAC,CACF,MAAM,EAAM,SAAS,EAAiB,kBAAkB,CAE1D,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAGvB,EAAO,KAAK,EAAO,MAAM,wCAAwC,EAAY,IAAK,YAAY,CAAC,CAG3F,EAAM,SAAS,kBAAkB,CAAC,OAAS,IAC7C,EAAO,MACL,EAAO,IACL,gBAAgB,EAAM,SAAS,kBAAkB,CAAC,OAAO,iBAC/C,EAAQ,EAAU,CAAC,4CAC9B,CACF,CACD,QAAQ,KAAK,EAAE"}
@@ -1,2 +1,2 @@
1
- import{a as e}from"./constants-TpID7AXE.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{r as n}from"./fetchAllRequests-CHHdyb4Q.mjs";import{RequestEnricherStatus as r,RequestStatus as i}from"@transcend-io/privacy-types";import{difference as a}from"lodash-es";import o from"colors";import{buildTranscendGraphQLClient as s,fetchAllRequestEnrichers as c,retryRequestEnricher as l}from"@transcend-io/sdk";import{map as u}from"@transcend-io/utils";import d from"cli-progress";async function f({auth:f,requestActions:p=[],createdAtBefore:m,createdAtAfter:h,updatedAtBefore:g,updatedAtAfter:_,transcendUrl:v=e,requestEnricherStatuses:y=Object.values(r),requestIds:b=[],enricherId:x,concurrency:S=20}){let C=new Date().getTime(),w=new d.SingleBar({},d.Presets.shades_classic),T=s(v,f);t.info(o.magenta(`Fetching requests to restart...`));let E=await n(T,{actions:p,statuses:[i.Enriching],createdAtBefore:m,createdAtAfter:h,updatedAtBefore:g,updatedAtAfter:_,requestIds:b}),D=0;if(b.length>0&&b.length!==E.length){let e=a(b,E.map(({id:e})=>e));e.length>0&&(t.error(o.red(`Failed to find the following requests by ID: ${e.join(`,`)}.`)),process.exit(1))}let O=0;w.start(E.length,0),await u(E,async e=>{await u((await c(T,{filterBy:{requestId:e.id},logger:t})).filter(e=>e.enricher.id===x&&y.includes(e.status)),async e=>{await l(T,{id:e.id,logger:t}),D+=1}),O+=1,w.update(O)},{concurrency:S}),w.stop();let k=new Date().getTime()-C;t.info(o.green(`Completed restarting of ${E.length} requests and ${D} enrichers in "${k/1e3}" seconds.`))}export{f as t};
2
- //# sourceMappingURL=bulkRetryEnrichers-CjSz1472.mjs.map
1
+ import{a as e}from"./constants-D22_ckyl.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{r as n}from"./fetchAllRequests-CHHdyb4Q.mjs";import{RequestEnricherStatus as r,RequestStatus as i}from"@transcend-io/privacy-types";import{difference as a}from"lodash-es";import o from"colors";import{buildTranscendGraphQLClient as s,fetchAllRequestEnrichers as c,retryRequestEnricher as l}from"@transcend-io/sdk";import{map as u}from"@transcend-io/utils";import d from"cli-progress";async function f({auth:f,requestActions:p=[],createdAtBefore:m,createdAtAfter:h,updatedAtBefore:g,updatedAtAfter:_,transcendUrl:v=e,requestEnricherStatuses:y=Object.values(r),requestIds:b=[],enricherId:x,concurrency:S=20}){let C=new Date().getTime(),w=new d.SingleBar({},d.Presets.shades_classic),T=s(v,f);t.info(o.magenta(`Fetching requests to restart...`));let E=await n(T,{actions:p,statuses:[i.Enriching],createdAtBefore:m,createdAtAfter:h,updatedAtBefore:g,updatedAtAfter:_,requestIds:b}),D=0;if(b.length>0&&b.length!==E.length){let e=a(b,E.map(({id:e})=>e));e.length>0&&(t.error(o.red(`Failed to find the following requests by ID: ${e.join(`,`)}.`)),process.exit(1))}let O=0;w.start(E.length,0),await u(E,async e=>{await u((await c(T,{filterBy:{requestId:e.id},logger:t})).filter(e=>e.enricher.id===x&&y.includes(e.status)),async e=>{await l(T,{id:e.id,logger:t}),D+=1}),O+=1,w.update(O)},{concurrency:S}),w.stop();let k=new Date().getTime()-C;t.info(o.green(`Completed restarting of ${E.length} requests and ${D} enrichers in "${k/1e3}" seconds.`))}export{f as t};
2
+ //# sourceMappingURL=bulkRetryEnrichers-CTbBdTEm.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bulkRetryEnrichers-CjSz1472.mjs","names":[],"sources":["../src/lib/requests/bulkRetryEnrichers.ts"],"sourcesContent":["import { RequestAction, RequestEnricherStatus, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n fetchAllRequestEnrichers,\n retryRequestEnricher,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport { difference } from 'lodash-es';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { fetchAllRequests } from '../graphql/index.js';\n\n/**\n * Restart a bunch of request enrichers\n *\n * @param options - Options\n */\nexport async function bulkRetryEnrichers({\n auth,\n requestActions = [],\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n transcendUrl = DEFAULT_TRANSCEND_API,\n requestEnricherStatuses = Object.values(RequestEnricherStatus),\n requestIds = [],\n enricherId,\n concurrency = 20,\n}: {\n /** Actions to filter for */\n requestActions?: RequestAction[];\n /** Request enricher statuses to restart - defaults to all statuses */\n requestEnricherStatuses?: RequestEnricherStatus[];\n /** Transcend API key authentication */\n auth: string;\n /** The ID of the enricher to restart */\n enricherId: string;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Request IDs to filter for */\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 /** Concurrency to upload requests at */\n concurrency?: number;\n}): Promise<void> {\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 // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n logger.info(colors.magenta('Fetching requests to restart...'));\n\n const requests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses: [RequestStatus.Enriching],\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n requestIds,\n });\n\n let totalRestarted = 0;\n\n // Validate request IDs\n if (requestIds.length > 0 && requestIds.length !== requests.length) {\n const missingRequests = difference(\n requestIds,\n requests.map(({ id }) => id),\n );\n if (missingRequests.length > 0) {\n logger.error(\n colors.red(`Failed to find the following requests by ID: ${missingRequests.join(',')}.`),\n );\n process.exit(1);\n }\n }\n\n // Map over the requests\n let total = 0;\n progressBar.start(requests.length, 0);\n await map(\n requests,\n async (request) => {\n // Pull the request identifiers\n const requestEnrichers = await fetchAllRequestEnrichers(client, {\n filterBy: { requestId: request.id },\n logger,\n });\n const requestEnrichersToRestart = requestEnrichers.filter(\n (requestEnricher) =>\n requestEnricher.enricher.id === enricherId &&\n requestEnricherStatuses.includes(requestEnricher.status),\n );\n await map(requestEnrichersToRestart, async (requestEnricher) => {\n await retryRequestEnricher(client, { id: requestEnricher.id, logger });\n totalRestarted += 1;\n });\n\n // Cache successful upload\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 // Log completion time\n logger.info(\n colors.green(\n `Completed restarting of ${requests.length} requests and ${totalRestarted} enrichers in \"${\n totalTime / 1000\n }\" seconds.`,\n ),\n );\n}\n"],"mappings":"wdAoBA,eAAsB,EAAmB,CACvC,OACA,iBAAiB,EAAE,CACnB,kBACA,iBACA,kBACA,iBACA,eAAe,EACf,0BAA0B,OAAO,OAAO,EAAsB,CAC9D,aAAa,EAAE,CACf,aACA,cAAc,IAwBE,CAEhB,IAAM,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAG/E,EAAS,EAA4B,EAAc,EAAK,CAE9D,EAAO,KAAK,EAAO,QAAQ,kCAAkC,CAAC,CAE9D,IAAM,EAAW,MAAM,EAAiB,EAAQ,CAC9C,QAAS,EACT,SAAU,CAAC,EAAc,UAAU,CACnC,kBACA,iBACA,kBACA,iBACA,aACD,CAAC,CAEE,EAAiB,EAGrB,GAAI,EAAW,OAAS,GAAK,EAAW,SAAW,EAAS,OAAQ,CAClE,IAAM,EAAkB,EACtB,EACA,EAAS,KAAK,CAAE,QAAS,EAAG,CAC7B,CACG,EAAgB,OAAS,IAC3B,EAAO,MACL,EAAO,IAAI,gDAAgD,EAAgB,KAAK,IAAI,CAAC,GAAG,CACzF,CACD,QAAQ,KAAK,EAAE,EAKnB,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAS,OAAQ,EAAE,CACrC,MAAM,EACJ,EACA,KAAO,IAAY,CAWjB,MAAM,GATmB,MAAM,EAAyB,EAAQ,CAC9D,SAAU,CAAE,UAAW,EAAQ,GAAI,CACnC,SACD,CAAC,EACiD,OAChD,GACC,EAAgB,SAAS,KAAO,GAChC,EAAwB,SAAS,EAAgB,OAAO,CAC3D,CACoC,KAAO,IAAoB,CAC9D,MAAM,EAAqB,EAAQ,CAAE,GAAI,EAAgB,GAAI,SAAQ,CAAC,CACtE,GAAkB,GAClB,CAGF,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAGvB,EAAO,KACL,EAAO,MACL,2BAA2B,EAAS,OAAO,gBAAgB,EAAe,iBACxE,EAAY,IACb,YACF,CACF"}
1
+ {"version":3,"file":"bulkRetryEnrichers-CTbBdTEm.mjs","names":[],"sources":["../src/lib/requests/bulkRetryEnrichers.ts"],"sourcesContent":["import { RequestAction, RequestEnricherStatus, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n fetchAllRequestEnrichers,\n retryRequestEnricher,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport { difference } from 'lodash-es';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { fetchAllRequests } from '../graphql/index.js';\n\n/**\n * Restart a bunch of request enrichers\n *\n * @param options - Options\n */\nexport async function bulkRetryEnrichers({\n auth,\n requestActions = [],\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n transcendUrl = DEFAULT_TRANSCEND_API,\n requestEnricherStatuses = Object.values(RequestEnricherStatus),\n requestIds = [],\n enricherId,\n concurrency = 20,\n}: {\n /** Actions to filter for */\n requestActions?: RequestAction[];\n /** Request enricher statuses to restart - defaults to all statuses */\n requestEnricherStatuses?: RequestEnricherStatus[];\n /** Transcend API key authentication */\n auth: string;\n /** The ID of the enricher to restart */\n enricherId: string;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Request IDs to filter for */\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 /** Concurrency to upload requests at */\n concurrency?: number;\n}): Promise<void> {\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 // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n logger.info(colors.magenta('Fetching requests to restart...'));\n\n const requests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses: [RequestStatus.Enriching],\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n requestIds,\n });\n\n let totalRestarted = 0;\n\n // Validate request IDs\n if (requestIds.length > 0 && requestIds.length !== requests.length) {\n const missingRequests = difference(\n requestIds,\n requests.map(({ id }) => id),\n );\n if (missingRequests.length > 0) {\n logger.error(\n colors.red(`Failed to find the following requests by ID: ${missingRequests.join(',')}.`),\n );\n process.exit(1);\n }\n }\n\n // Map over the requests\n let total = 0;\n progressBar.start(requests.length, 0);\n await map(\n requests,\n async (request) => {\n // Pull the request identifiers\n const requestEnrichers = await fetchAllRequestEnrichers(client, {\n filterBy: { requestId: request.id },\n logger,\n });\n const requestEnrichersToRestart = requestEnrichers.filter(\n (requestEnricher) =>\n requestEnricher.enricher.id === enricherId &&\n requestEnricherStatuses.includes(requestEnricher.status),\n );\n await map(requestEnrichersToRestart, async (requestEnricher) => {\n await retryRequestEnricher(client, { id: requestEnricher.id, logger });\n totalRestarted += 1;\n });\n\n // Cache successful upload\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 // Log completion time\n logger.info(\n colors.green(\n `Completed restarting of ${requests.length} requests and ${totalRestarted} enrichers in \"${\n totalTime / 1000\n }\" seconds.`,\n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R,EAGvB,EAAO,KACL,EAAO,MACL,2BAA2B,EAAS,OAAO,gBAAgB,EAAe,iBACxE,EAAY,IACb,YACF,CACF"}
@@ -1,2 +1,2 @@
1
- import{a as e}from"./constants-TpID7AXE.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{n,o as r}from"./request-DfkRPQFr.mjs";import{r as i}from"./fetchAllRequests-CHHdyb4Q.mjs";import{RequestStatus as a}from"@transcend-io/privacy-types";import o from"colors";import{buildTranscendGraphQLClient as s,fetchAllTemplates as c,makeGraphQLRequest as l}from"@transcend-io/sdk";import{map as u}from"@transcend-io/utils";import d from"cli-progress";async function f({requestActions:f,cancellationTitle:p,auth:m,requestIds:h,silentModeBefore:g,createdAtBefore:_,createdAtAfter:v,updatedAtBefore:y,updatedAtAfter:b,statuses:x=[a.Compiling,a.RequestMade,a.Delayed,a.Approving,a.Secondary,a.Enriching,a.Waiting,a.SecondaryApproving],concurrency:S=50,transcendUrl:C=e}){let w=s(C,m),T=new Date().getTime(),E=new d.SingleBar({},d.Presets.shades_classic),D;if(p){let e=(await c(w,{logger:t,filterBy:{title:p}})).find(e=>e.title===p);if(!e)throw Error(`Failed to find a template with title: "${p}"`);D=e}let O=await i(w,{actions:f,createdAtBefore:_,createdAtAfter:v,updatedAtBefore:y,updatedAtAfter:b,statuses:x,requestIds:h});t.info(o.magenta(`Canceling "${O.length}" requests${D?` Using template: ${D.title}`:``}.`));let k=0;E.start(O.length,0),await u(O,async e=>{g&&new Date(g)>new Date(e.createdAt)&&await l(w,r,{variables:{input:{id:e.id,isSilent:!0}},logger:t}),await l(w,n,{variables:{input:{requestId:e.id,...D?{subject:`Re: ${D.subject.defaultMessage}`,template:D.template.defaultMessage}:{}}},logger:t}),k+=1,E.update(k)},{concurrency:S}),E.stop();let A=new Date().getTime()-T;return t.info(o.green(`Successfully canceled ${k} requests in "${A/1e3}" seconds!`)),O.length}export{f as t};
2
- //# sourceMappingURL=cancelPrivacyRequests-BWJZmZVY.mjs.map
1
+ import{a as e}from"./constants-D22_ckyl.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{n,o as r}from"./request-DfkRPQFr.mjs";import{r as i}from"./fetchAllRequests-CHHdyb4Q.mjs";import{RequestStatus as a}from"@transcend-io/privacy-types";import o from"colors";import{buildTranscendGraphQLClient as s,fetchAllTemplates as c,makeGraphQLRequest as l}from"@transcend-io/sdk";import{map as u}from"@transcend-io/utils";import d from"cli-progress";async function f({requestActions:f,cancellationTitle:p,auth:m,requestIds:h,silentModeBefore:g,createdAtBefore:_,createdAtAfter:v,updatedAtBefore:y,updatedAtAfter:b,statuses:x=[a.Compiling,a.RequestMade,a.Delayed,a.Approving,a.Secondary,a.Enriching,a.Waiting,a.SecondaryApproving],concurrency:S=50,transcendUrl:C=e}){let w=s(C,m),T=new Date().getTime(),E=new d.SingleBar({},d.Presets.shades_classic),D;if(p){let e=(await c(w,{logger:t,filterBy:{title:p}})).find(e=>e.title===p);if(!e)throw Error(`Failed to find a template with title: "${p}"`);D=e}let O=await i(w,{actions:f,createdAtBefore:_,createdAtAfter:v,updatedAtBefore:y,updatedAtAfter:b,statuses:x,requestIds:h});t.info(o.magenta(`Canceling "${O.length}" requests${D?` Using template: ${D.title}`:``}.`));let k=0;E.start(O.length,0),await u(O,async e=>{g&&new Date(g)>new Date(e.createdAt)&&await l(w,r,{variables:{input:{id:e.id,isSilent:!0}},logger:t}),await l(w,n,{variables:{input:{requestId:e.id,...D?{subject:`Re: ${D.subject.defaultMessage}`,template:D.template.defaultMessage}:{}}},logger:t}),k+=1,E.update(k)},{concurrency:S}),E.stop();let A=new Date().getTime()-T;return t.info(o.green(`Successfully canceled ${k} requests in "${A/1e3}" seconds!`)),O.length}export{f as t};
2
+ //# sourceMappingURL=cancelPrivacyRequests-p9OEzUXv.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cancelPrivacyRequests-BWJZmZVY.mjs","names":[],"sources":["../src/lib/requests/cancelPrivacyRequests.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n fetchAllTemplates,\n makeGraphQLRequest,\n type Template,\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 {\n UPDATE_PRIVACY_REQUEST,\n fetchAllRequests,\n CANCEL_PRIVACY_REQUEST,\n} from '../graphql/index.js';\n\n/**\n * Cancel a set of privacy requests\n *\n * @param options - Options\n * @returns The number of requests canceled\n */\nexport async function cancelPrivacyRequests({\n requestActions,\n cancellationTitle,\n auth,\n requestIds,\n silentModeBefore,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\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 concurrency = 50,\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 cancel */\n statuses?: RequestStatus[];\n /** The set of privacy requests to cancel */\n requestIds?: string[];\n /** Mark these requests as silent mode if they were created before this date */\n silentModeBefore?: Date;\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 /** The email template to use when canceling the requests */\n cancellationTitle?: 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 let cancelationTemplate: Template | undefined;\n if (cancellationTitle) {\n const matchingTemplates = await fetchAllTemplates(client, {\n logger,\n filterBy: { title: cancellationTitle },\n });\n const exactTitleMatch = matchingTemplates.find(\n (template) => template.title === cancellationTitle,\n );\n if (!exactTitleMatch) {\n throw new Error(`Failed to find a template with title: \"${cancellationTitle}\"`);\n }\n cancelationTemplate = exactTitleMatch;\n }\n\n // Pull in the requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n statuses,\n requestIds,\n });\n\n // Notify Transcend\n logger.info(\n colors.magenta(\n `Canceling \"${allRequests.length}\" requests${\n cancelationTemplate ? ` Using template: ${cancelationTemplate.title}` : ''\n }.`,\n ),\n );\n\n let total = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToCancel) => {\n // update request to silent mode if silentModeBefore is defined\n // and the request was created before silentModeBefore\n if (silentModeBefore && new Date(silentModeBefore) > new Date(requestToCancel.createdAt)) {\n await makeGraphQLRequest(client, UPDATE_PRIVACY_REQUEST, {\n variables: {\n input: {\n id: requestToCancel.id,\n isSilent: true,\n },\n },\n logger,\n });\n }\n\n // cancel the request\n await makeGraphQLRequest(client, CANCEL_PRIVACY_REQUEST, {\n variables: {\n input: {\n requestId: requestToCancel.id,\n ...(cancelationTemplate\n ? {\n subject: `Re: ${cancelationTemplate.subject.defaultMessage}`,\n template: cancelationTemplate.template.defaultMessage,\n }\n : {}),\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(`Successfully canceled ${total} requests in \"${totalTime / 1000}\" seconds!`),\n );\n return allRequests.length;\n}\n"],"mappings":"0bAyBA,eAAsB,EAAsB,CAC1C,iBACA,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AAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAKvB,OAHA,EAAO,KACL,EAAO,MAAM,yBAAyB,EAAM,gBAAgB,EAAY,IAAK,YAAY,CAC1F,CACM,EAAY"}
1
+ {"version":3,"file":"cancelPrivacyRequests-p9OEzUXv.mjs","names":[],"sources":["../src/lib/requests/cancelPrivacyRequests.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n fetchAllTemplates,\n makeGraphQLRequest,\n type Template,\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 {\n UPDATE_PRIVACY_REQUEST,\n fetchAllRequests,\n CANCEL_PRIVACY_REQUEST,\n} from '../graphql/index.js';\n\n/**\n * Cancel a set of privacy requests\n *\n * @param options - Options\n * @returns The number of requests canceled\n */\nexport async function cancelPrivacyRequests({\n requestActions,\n cancellationTitle,\n auth,\n requestIds,\n silentModeBefore,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\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 concurrency = 50,\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 cancel */\n statuses?: RequestStatus[];\n /** The set of privacy requests to cancel */\n requestIds?: string[];\n /** Mark these requests as silent mode if they were created before this date */\n silentModeBefore?: Date;\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 /** The email template to use when canceling the requests */\n cancellationTitle?: 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 let cancelationTemplate: Template | undefined;\n if (cancellationTitle) {\n const matchingTemplates = await fetchAllTemplates(client, {\n logger,\n filterBy: { title: cancellationTitle },\n });\n const exactTitleMatch = matchingTemplates.find(\n (template) => template.title === cancellationTitle,\n );\n if (!exactTitleMatch) {\n throw new Error(`Failed to find a template with title: \"${cancellationTitle}\"`);\n }\n cancelationTemplate = exactTitleMatch;\n }\n\n // Pull in the requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n statuses,\n requestIds,\n });\n\n // Notify Transcend\n logger.info(\n colors.magenta(\n `Canceling \"${allRequests.length}\" requests${\n cancelationTemplate ? ` Using template: ${cancelationTemplate.title}` : ''\n }.`,\n ),\n );\n\n let total = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToCancel) => {\n // update request to silent mode if silentModeBefore is defined\n // and the request was created before silentModeBefore\n if (silentModeBefore && new Date(silentModeBefore) > new Date(requestToCancel.createdAt)) {\n await makeGraphQLRequest(client, UPDATE_PRIVACY_REQUEST, {\n variables: {\n input: {\n id: requestToCancel.id,\n isSilent: true,\n },\n },\n logger,\n });\n }\n\n // cancel the request\n await makeGraphQLRequest(client, CANCEL_PRIVACY_REQUEST, {\n variables: {\n input: {\n requestId: requestToCancel.id,\n ...(cancelationTemplate\n ? {\n subject: `Re: ${cancelationTemplate.subject.defaultMessage}`,\n template: cancelationTemplate.template.defaultMessage,\n }\n : {}),\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(`Successfully canceled ${total} requests in \"${totalTime / 1000}\" seconds!`),\n );\n return allRequests.length;\n}\n"],"mappings":"0bAyBA,eAAsB,EAAsB,CAC1C,iBACA,oBACA,OACA,aACA,mBACA,kBACA,iBACA,kBACA,iBACA,WAAW,CACT,EAAc,UACd,EAAc,YACd,EAAc,QACd,EAAc,UACd,EAAc,UACd,EAAc,UACd,EAAc,QACd,EAAc,mBACf,CACD,cAAc,GACd,eAAe,GA0BG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAGjF,EACJ,GAAI,EAAmB,CAKrB,IAAM,GAJoB,MAAM,EAAkB,EAAQ,CACxD,SACA,SAAU,CAAE,MAAO,EAAmB,CACvC,CAAC,EACwC,KACvC,GAAa,EAAS,QAAU,EAClC,CACD,GAAI,CAAC,EACH,MAAU,MAAM,0CAA0C,EAAkB,GAAG,CAEjF,EAAsB,EAIxB,IAAM,EAAc,MAAM,EAAiB,EAAQ,CACjD,QAAS,EACT,kBACA,iBACA,kBACA,iBACA,WACA,aACD,CAAC,CAGF,EAAO,KACL,EAAO,QACL,cAAc,EAAY,OAAO,YAC/B,EAAsB,oBAAoB,EAAoB,QAAU,GACzE,GACF,CACF,CAED,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAY,OAAQ,EAAE,CACxC,MAAM,EACJ,EACA,KAAO,IAAoB,CAGrB,GAAoB,IAAI,KAAK,EAAiB,CAAG,IAAI,KAAK,EAAgB,UAAU,EACtF,MAAM,EAAmB,EAAQ,EAAwB,CACvD,UAAW,CACT,MAAO,CACL,GAAI,EAAgB,GACpB,SAAU,GACX,CACF,CACD,SACD,CAAC,CAIJ,MAAM,EAAmB,EAAQ,EAAwB,CACvD,UAAW,CACT,MAAO,CACL,UAAW,EAAgB,GAC3B,GAAI,EACA,CACE,QAAS,OAAO,EAAoB,QAAQ,iBAC5C,SAAU,EAAoB,SAAS,eACxC,CACD,EAAE,CACP,CACF,CACD,SACD,CAAC,CAEF,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAKvB,OAHA,EAAO,KACL,EAAO,MAAM,yBAAyB,EAAM,gBAAgB,EAAY,IAAK,YAAY,CAC1F,CACM,EAAY"}
@@ -1,4 +1,4 @@
1
- import{o as e}from"./enums-CyFTrzXY.mjs";import{a as t,o as n}from"./constants-TpID7AXE.mjs";import{buildCommand as r,numberParser as i}from"@stricli/core";import{ConsentTrackerStatus as a,ScopeName as o,TRANSCEND_SCOPES as s}from"@transcend-io/privacy-types";import c from"ms";function l(e){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e))throw Error(`Invalid UUID format: ${e}`);return e}function u(e){try{return new URL(e).toString().replace(/\/$/,``)}catch{throw Error(`Invalid URL format: ${e}`)}}function d(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function f(e){let t=new Date(e);if(Number.isNaN(t.getTime()))throw TypeError(`Invalid date: ${e}. Try using the ISO 8601 format (YYYY-MM-DDTHH:MM:SS.SSSZ)`);return t}function p(e){if(typeof e==`number`&&Number.isFinite(e))return Math.round(e*1e3);if(typeof e==`string`){let t=e.trim();if(t===``)throw Error(`Invalid duration. Examples: "45", "2d", "1h", "90 minutes", "10s".`);let n=Number(t);if(t!==``&&Number.isFinite(n))return Math.round(n*1e3);let r;try{r=c(t)}catch{throw Error(`Invalid duration. Examples: "45", "2d", "1h", "90 minutes", "10s".`)}if(typeof r==`number`&&Number.isFinite(r))return r}throw Error(`Invalid duration. Examples: "45", "2d", "1h", "90 minutes", "10s".`)}const m=({scopes:e,requiresSiloScope:t=!1})=>{let n={kind:`parsed`,parse:String,brief:`The Transcend API key.`};return t&&(n.brief+=` This key must be associated with the data silo(s) being operated on.`),e===`Varies`?{...n,brief:`${n.brief} The scopes required will vary depending on the operation performed. If in doubt, the ${s[o.FullAdmin].title} scope will always work.`}:e.length===0?{...n,brief:`${n.brief} No scopes are required for this command.`}:{...n,brief:`${n.brief} Requires scopes: ${e.map(e=>`"${s[e].title}"`).join(`, `)}`}},h=(e=t)=>({kind:`parsed`,parse:u,brief:`URL of the Transcend backend. Use https://api.us.transcend.io for US hosting`,default:e}),g=(e=n)=>({kind:`parsed`,parse:u,brief:`URL of the Transcend consent backend. Use https://consent.us.transcend.io for US hosting`,default:e}),_=()=>({kind:`parsed`,parse:String,brief:`The Sombra internal key, use for additional authentication when self-hosting Sombra`,optional:!0}),v=[e.DataSilos,e.Enrichers,e.Templates,e.ApiKeys],y=Object.values(a),b=r({loader:async()=>{let{pull:e}=await import(`./impl-BaHZqboi.mjs`);return e},parameters:{flags:{auth:m({scopes:`Varies`}),resources:{kind:`enum`,values:[`all`,...Object.values(e)],brief:`The different resource types to pull in. Defaults to ${v.join(`,`)}.`,variadic:`,`,optional:!0},file:{kind:`parsed`,parse:String,brief:`Path to the YAML file to pull into`,default:`./transcend.yml`},transcendUrl:h(),dataSiloIds:{kind:`parsed`,parse:String,variadic:`,`,brief:`The UUIDs of the data silos that should be pulled into the YAML file`,optional:!0},integrationNames:{kind:`parsed`,parse:String,variadic:`,`,brief:`The types of integrations to pull down`,optional:!0},trackerStatuses:{kind:`enum`,values:Object.values(a),variadic:`,`,brief:`The statuses of consent manager trackers to pull down. Defaults to all statuses.`,optional:!0},pageSize:{kind:`parsed`,parse:i,brief:`The page size to use when paginating over the API`,default:`50`},skipDatapoints:{kind:`boolean`,brief:`When true, skip pulling in datapoints alongside data silo resource`,default:!1},skipSubDatapoints:{kind:`boolean`,brief:`When true, skip pulling in subDatapoints alongside data silo resource`,default:!1},includeGuessedCategories:{kind:`boolean`,brief:`When true, included guessed data categories that came from the content classifier`,default:!1},debug:{kind:`boolean`,brief:`Set to true to include debug logs while pulling the configuration`,default:!1}}},docs:{brief:`Pull metadata from Transcend into transcend.yml`,fullDescription:`Generates a transcend.yml by pulling the configuration from your Transcend instance.
1
+ import{o as e}from"./enums-CyFTrzXY.mjs";import{a as t,o as n}from"./constants-D22_ckyl.mjs";import{buildCommand as r,numberParser as i}from"@stricli/core";import{ConsentTrackerStatus as a,ScopeName as o,TRANSCEND_SCOPES as s}from"@transcend-io/privacy-types";import c from"ms";function l(e){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e))throw Error(`Invalid UUID format: ${e}`);return e}function u(e){try{return new URL(e).toString().replace(/\/$/,``)}catch{throw Error(`Invalid URL format: ${e}`)}}function d(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function f(e){let t=new Date(e);if(Number.isNaN(t.getTime()))throw TypeError(`Invalid date: ${e}. Try using the ISO 8601 format (YYYY-MM-DDTHH:MM:SS.SSSZ)`);return t}function p(e){if(typeof e==`number`&&Number.isFinite(e))return Math.round(e*1e3);if(typeof e==`string`){let t=e.trim();if(t===``)throw Error(`Invalid duration. Examples: "45", "2d", "1h", "90 minutes", "10s".`);let n=Number(t);if(t!==``&&Number.isFinite(n))return Math.round(n*1e3);let r;try{r=c(t)}catch{throw Error(`Invalid duration. Examples: "45", "2d", "1h", "90 minutes", "10s".`)}if(typeof r==`number`&&Number.isFinite(r))return r}throw Error(`Invalid duration. Examples: "45", "2d", "1h", "90 minutes", "10s".`)}const m=({scopes:e,requiresSiloScope:t=!1})=>{let n={kind:`parsed`,parse:String,brief:`The Transcend API key.`};return t&&(n.brief+=` This key must be associated with the data silo(s) being operated on.`),e===`Varies`?{...n,brief:`${n.brief} The scopes required will vary depending on the operation performed. If in doubt, the ${s[o.FullAdmin].title} scope will always work.`}:e.length===0?{...n,brief:`${n.brief} No scopes are required for this command.`}:{...n,brief:`${n.brief} Requires scopes: ${e.map(e=>`"${s[e].title}"`).join(`, `)}`}},h=(e=t)=>({kind:`parsed`,parse:u,brief:`URL of the Transcend backend. Use https://api.us.transcend.io for US hosting`,default:e}),g=(e=n)=>({kind:`parsed`,parse:u,brief:`URL of the Transcend consent backend. Use https://consent.us.transcend.io for US hosting`,default:e}),_=()=>({kind:`parsed`,parse:String,brief:`The Sombra internal key, use for additional authentication when self-hosting Sombra`,optional:!0}),v=[e.DataSilos,e.Enrichers,e.Templates,e.ApiKeys],y=Object.values(a),b=r({loader:async()=>{let{pull:e}=await import(`./impl-B1YGN9Iu.mjs`);return e},parameters:{flags:{auth:m({scopes:`Varies`}),resources:{kind:`enum`,values:[`all`,...Object.values(e)],brief:`The different resource types to pull in. Defaults to ${v.join(`,`)}.`,variadic:`,`,optional:!0},file:{kind:`parsed`,parse:String,brief:`Path to the YAML file to pull into`,default:`./transcend.yml`},transcendUrl:h(),dataSiloIds:{kind:`parsed`,parse:String,variadic:`,`,brief:`The UUIDs of the data silos that should be pulled into the YAML file`,optional:!0},integrationNames:{kind:`parsed`,parse:String,variadic:`,`,brief:`The types of integrations to pull down`,optional:!0},trackerStatuses:{kind:`enum`,values:Object.values(a),variadic:`,`,brief:`The statuses of consent manager trackers to pull down. Defaults to all statuses.`,optional:!0},pageSize:{kind:`parsed`,parse:i,brief:`The page size to use when paginating over the API`,default:`50`},skipDatapoints:{kind:`boolean`,brief:`When true, skip pulling in datapoints alongside data silo resource`,default:!1},skipSubDatapoints:{kind:`boolean`,brief:`When true, skip pulling in subDatapoints alongside data silo resource`,default:!1},includeGuessedCategories:{kind:`boolean`,brief:`When true, included guessed data categories that came from the content classifier`,default:!1},debug:{kind:`boolean`,brief:`Set to true to include debug logs while pulling the configuration`,default:!1}}},docs:{brief:`Pull metadata from Transcend into transcend.yml`,fullDescription:`Generates a transcend.yml by pulling the configuration from your Transcend instance.
2
2
 
3
3
  The API key needs various scopes depending on the resources being pulled (see the CLI's README for more details).
4
4
 
@@ -6,4 +6,4 @@ This command can be helpful if you are looking to:
6
6
 
7
7
  - Copy your data into another instance
8
8
  - Generate a transcend.yml file as a starting point to maintain parts of your data inventory in code.`}});export{g as a,d as c,l as d,m as i,f as l,v as n,_ as o,b as r,h as s,y as t,p as u};
9
- //# sourceMappingURL=command-BMa3UWax.mjs.map
9
+ //# sourceMappingURL=command-CuxgABlk.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-BMa3UWax.mjs","names":[],"sources":["../src/lib/cli/parsers.ts","../src/lib/cli/common-parameters.ts","../src/commands/inventory/pull/command.ts"],"sourcesContent":["import ms, { type StringValue as MsStringValue } from 'ms';\n\n/**\n * Validates and returns a UUID string.\n *\n * @param input - The input string to validate as UUID\n * @returns The validated UUID string\n * @throws Error if input is not a valid UUID\n */\nexport function uuidParser(input: string): string {\n const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n if (!uuidRegex.test(input)) {\n throw new Error(`Invalid UUID format: ${input}`);\n }\n return input;\n}\n\n/**\n * Validates and returns a URL string.\n *\n * @param input - The input string to validate as URL\n * @returns The validated URL string\n * @throws Error if input is not a valid URL\n */\nexport function urlParser(input: string): string {\n try {\n const url = new URL(input);\n return url.toString().replace(/\\/$/, '');\n } catch {\n throw new Error(`Invalid URL format: ${input}`);\n }\n}\n\n/**\n * Parse a comma-separated string to array.\n * NOTE: Prefer using `variadic` for list arguments instead of this function. This should only be used for arguments which have a default value.\n *\n * @param input - The comma-separated string to parse\n * @returns Array of trimmed, non-empty strings\n */\nexport function arrayParser(input: string): string[] {\n return input\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n}\n\n/**\n * Parse a date string to a Date object.\n *\n * @param input - The date string to parse\n * @returns The parsed Date object\n * @throws TypeError if input is not a valid date\n */\nexport function dateParser(input: string): Date {\n const date = new Date(input);\n if (Number.isNaN(date.getTime())) {\n throw new TypeError(\n `Invalid date: ${input}. Try using the ISO 8601 format (YYYY-MM-DDTHH:MM:SS.SSSZ)`,\n );\n }\n return date;\n}\n\n/**\n * Parse a duration string to milliseconds.\n * Accepts concise/natural-ish strings (powered by `ms`) and returns milliseconds.\n * Examples: \"3600\", \"2d\", \"1h\", \"90 minutes\", \"10s\".\n *\n * @param input - The duration to parse\n * @returns The parsed duration in milliseconds\n * @throws Error if input is not a valid duration\n */\nexport function parseDurationToMs(input: unknown): number {\n if (typeof input === 'number' && Number.isFinite(input)) {\n // backward-compat: numbers => seconds\n return Math.round(input * 1000);\n }\n\n if (typeof input === 'string') {\n const trimmed = input.trim();\n // empty string → our standardized error (avoid ms throwing its own)\n if (trimmed === '') {\n throw new Error('Invalid duration. Examples: \"45\", \"2d\", \"1h\", \"90 minutes\", \"10s\".');\n }\n\n // bare numeric string => seconds (backward-compat)\n const asNumber = Number(trimmed);\n if (trimmed !== '' && Number.isFinite(asNumber)) {\n return Math.round(asNumber * 1000);\n }\n\n // let ms parse human strings\n let parsed: number | undefined;\n try {\n parsed = ms(trimmed as MsStringValue);\n } catch {\n // normalize ms' error to ours\n throw new Error('Invalid duration. Examples: \"45\", \"2d\", \"1h\", \"90 minutes\", \"10s\".');\n }\n if (typeof parsed === 'number' && Number.isFinite(parsed)) {\n return parsed;\n }\n }\n\n throw new Error('Invalid duration. Examples: \"45\", \"2d\", \"1h\", \"90 minutes\", \"10s\".');\n}\n","import type { TypedFlagParameter } from '@stricli/core';\nimport { ScopeName, TRANSCEND_SCOPES } from '@transcend-io/privacy-types';\n\nimport { DEFAULT_TRANSCEND_API, DEFAULT_TRANSCEND_CONSENT_API } from '../../constants.js';\nimport type { LocalContext } from '../../context.js';\nimport { urlParser } from './parsers.js';\n\n/**\n * Common parameter builders for CLI commands\n * These reduce duplication and ensure consistency across commands\n */\n\n/**\n * Creates a standard authentication parameter\n *\n * @param root0 - The scopes and whether it requires a silo scope\n * @returns The parameter object\n */\nexport const createAuthParameter = ({\n scopes,\n requiresSiloScope = false,\n}: {\n /** The scopes required for the command */\n scopes: ScopeName[] | 'Varies';\n /** Whether the command requires a silo scope */\n requiresSiloScope?: boolean;\n}): TypedFlagParameter<string, LocalContext> => {\n const parameter = {\n kind: 'parsed' as const,\n parse: String,\n brief: 'The Transcend API key.',\n };\n\n if (requiresSiloScope) {\n parameter.brief += ' This key must be associated with the data silo(s) being operated on.';\n }\n\n if (scopes === 'Varies') {\n return {\n ...parameter,\n brief: `${\n parameter.brief\n } The scopes required will vary depending on the operation performed. If in doubt, the ${\n TRANSCEND_SCOPES[ScopeName.FullAdmin].title\n } scope will always work.`,\n };\n }\n\n if (scopes.length === 0) {\n return {\n ...parameter,\n brief: `${parameter.brief} No scopes are required for this command.`,\n };\n }\n\n return {\n ...parameter,\n brief: `${parameter.brief} Requires scopes: ${scopes\n .map((s) => `\"${TRANSCEND_SCOPES[s].title}\"`)\n .join(', ')}`,\n };\n};\n\n/**\n * Creates a standard Transcend URL parameter\n *\n * @param defaultUrl - The default URL to use if not provided\n * @returns The parameter object\n */\nexport const createTranscendUrlParameter = (\n defaultUrl = DEFAULT_TRANSCEND_API,\n): TypedFlagParameter<string, LocalContext> => ({\n kind: 'parsed',\n parse: urlParser,\n brief: 'URL of the Transcend backend. Use https://api.us.transcend.io for US hosting',\n default: defaultUrl,\n});\n\n/**\n * Creates a standard Consent URL parameter\n *\n * @param defaultUrl - The default URL to use if not provided\n * @returns The parameter object\n */\nexport const createConsentUrlParameter = (\n defaultUrl = DEFAULT_TRANSCEND_CONSENT_API,\n): TypedFlagParameter<string, LocalContext> => ({\n kind: 'parsed',\n parse: urlParser,\n brief: 'URL of the Transcend consent backend. Use https://consent.us.transcend.io for US hosting',\n default: defaultUrl,\n});\n\n/**\n * Creates a standard Sombra authentication parameter\n *\n * @returns The parameter object\n */\nexport const createSombraAuthParameter = (): TypedFlagParameter<\n string | undefined,\n LocalContext\n> => ({\n kind: 'parsed',\n parse: String,\n brief: 'The Sombra internal key, use for additional authentication when self-hosting Sombra',\n optional: true,\n});\n","import { buildCommand, numberParser } from '@stricli/core';\nimport { ConsentTrackerStatus } from '@transcend-io/privacy-types';\n\nimport { TranscendPullResource } from '../../../enums.js';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters.js';\n\nexport const DEFAULT_TRANSCEND_PULL_RESOURCES = [\n TranscendPullResource.DataSilos,\n TranscendPullResource.Enrichers,\n TranscendPullResource.Templates,\n TranscendPullResource.ApiKeys,\n];\n\nexport const DEFAULT_CONSENT_TRACKER_STATUSES = Object.values(ConsentTrackerStatus);\n\nexport const pullCommand = buildCommand({\n loader: async () => {\n const { pull } = await import('./impl.js');\n return pull;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: 'Varies',\n }),\n resources: {\n kind: 'enum',\n values: ['all', ...Object.values(TranscendPullResource)],\n brief: `The different resource types to pull in. Defaults to ${DEFAULT_TRANSCEND_PULL_RESOURCES.join(\n ',',\n )}.`,\n variadic: ',',\n optional: true,\n },\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the YAML file to pull into',\n default: './transcend.yml',\n },\n transcendUrl: createTranscendUrlParameter(),\n dataSiloIds: {\n kind: 'parsed',\n parse: String,\n variadic: ',',\n brief: 'The UUIDs of the data silos that should be pulled into the YAML file',\n optional: true,\n },\n integrationNames: {\n kind: 'parsed',\n parse: String,\n variadic: ',',\n brief: 'The types of integrations to pull down',\n optional: true,\n },\n trackerStatuses: {\n kind: 'enum',\n values: Object.values(ConsentTrackerStatus),\n variadic: ',',\n brief: 'The statuses of consent manager trackers to pull down. Defaults to all statuses.',\n optional: true,\n },\n pageSize: {\n kind: 'parsed',\n parse: numberParser,\n brief: 'The page size to use when paginating over the API',\n default: '50',\n },\n skipDatapoints: {\n kind: 'boolean',\n brief: 'When true, skip pulling in datapoints alongside data silo resource',\n default: false,\n },\n skipSubDatapoints: {\n kind: 'boolean',\n brief: 'When true, skip pulling in subDatapoints alongside data silo resource',\n default: false,\n },\n includeGuessedCategories: {\n kind: 'boolean',\n brief: 'When true, included guessed data categories that came from the content classifier',\n default: false,\n },\n debug: {\n kind: 'boolean',\n brief: 'Set to true to include debug logs while pulling the configuration',\n default: false,\n },\n },\n },\n docs: {\n brief: 'Pull metadata from Transcend into transcend.yml',\n fullDescription: `Generates a transcend.yml by pulling the configuration from your Transcend instance.\n\nThe API key needs various scopes depending on the resources being pulled (see the CLI's README for more details).\n\nThis command can be helpful if you are looking to:\n\n- Copy your data into another instance\n- Generate a transcend.yml file as a starting point to maintain parts of your data inventory in code.`,\n },\n});\n"],"mappings":"sRASA,SAAgB,EAAW,EAAuB,CAEhD,GAAI,CADc,6EACH,KAAK,EAAM,CACxB,MAAU,MAAM,wBAAwB,IAAQ,CAElD,OAAO,EAUT,SAAgB,EAAU,EAAuB,CAC/C,GAAI,CAEF,OADY,IAAI,IAAI,EAAM,CACf,UAAU,CAAC,QAAQ,MAAO,GAAG,MAClC,CACN,MAAU,MAAM,uBAAuB,IAAQ,EAWnD,SAAgB,EAAY,EAAyB,CACnD,OAAO,EACJ,MAAM,IAAI,CACV,IAAK,GAAM,EAAE,MAAM,CAAC,CACpB,OAAQ,GAAM,EAAE,OAAS,EAAE,CAUhC,SAAgB,EAAW,EAAqB,CAC9C,IAAM,EAAO,IAAI,KAAK,EAAM,CAC5B,GAAI,OAAO,MAAM,EAAK,SAAS,CAAC,CAC9B,MAAU,UACR,iBAAiB,EAAM,4DACxB,CAEH,OAAO,EAYT,SAAgB,EAAkB,EAAwB,CACxD,GAAI,OAAO,GAAU,UAAY,OAAO,SAAS,EAAM,CAErD,OAAO,KAAK,MAAM,EAAQ,IAAK,CAGjC,GAAI,OAAO,GAAU,SAAU,CAC7B,IAAM,EAAU,EAAM,MAAM,CAE5B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W,CACT,KAAM,OACN,OAAQ,CAAC,MAAO,GAAG,OAAO,OAAO,EAAsB,CAAC,CACxD,MAAO,wDAAwD,EAAiC,KAC9F,IACD,CAAC,GACF,SAAU,IACV,SAAU,GACX,CACD,KAAM,CACJ,KAAM,SACN,MAAO,OACP,MAAO,qCACP,QAAS,kBACV,CACD,aAAc,GAA6B,CAC3C,YAAa,CACX,KAAM,SACN,MAAO,OACP,SAAU,IACV,MAAO,uEACP,SAAU,GACX,CACD,iBAAkB,CAChB,KAAM,SACN,MAAO,OACP,SAAU,IACV,MAAO,yCACP,SAAU,GACX,CACD,gBAAiB,CACf,KAAM,OACN,OAAQ,OAAO,OAAO,EAAqB,CAC3C,SAAU,IACV,MAAO,mFACP,SAAU,GACX,CACD,SAAU,CACR,KAAM,SACN,MAAO,EACP,MAAO,oDACP,QAAS,KACV,CACD,eAAgB,CACd,KAAM,UACN,MAAO,qEACP,QAAS,GACV,CACD,kBAAmB,CACjB,KAAM,UACN,MAAO,wEACP,QAAS,GACV,CACD,yBAA0B,CACxB,KAAM,UACN,MAAO,oFACP,QAAS,GACV,CACD,MAAO,CACL,KAAM,UACN,MAAO,oEACP,QAAS,GACV,CACF,CACF,CACD,KAAM,CACJ,MAAO,kDACP,gBAAiB;;;;;;;uGAQlB,CACF,CAAC"}
1
+ {"version":3,"file":"command-CuxgABlk.mjs","names":[],"sources":["../src/lib/cli/parsers.ts","../src/lib/cli/common-parameters.ts","../src/commands/inventory/pull/command.ts"],"sourcesContent":["import ms, { type StringValue as MsStringValue } from 'ms';\n\n/**\n * Validates and returns a UUID string.\n *\n * @param input - The input string to validate as UUID\n * @returns The validated UUID string\n * @throws Error if input is not a valid UUID\n */\nexport function uuidParser(input: string): string {\n const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n if (!uuidRegex.test(input)) {\n throw new Error(`Invalid UUID format: ${input}`);\n }\n return input;\n}\n\n/**\n * Validates and returns a URL string.\n *\n * @param input - The input string to validate as URL\n * @returns The validated URL string\n * @throws Error if input is not a valid URL\n */\nexport function urlParser(input: string): string {\n try {\n const url = new URL(input);\n return url.toString().replace(/\\/$/, '');\n } catch {\n throw new Error(`Invalid URL format: ${input}`);\n }\n}\n\n/**\n * Parse a comma-separated string to array.\n * NOTE: Prefer using `variadic` for list arguments instead of this function. This should only be used for arguments which have a default value.\n *\n * @param input - The comma-separated string to parse\n * @returns Array of trimmed, non-empty strings\n */\nexport function arrayParser(input: string): string[] {\n return input\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n}\n\n/**\n * Parse a date string to a Date object.\n *\n * @param input - The date string to parse\n * @returns The parsed Date object\n * @throws TypeError if input is not a valid date\n */\nexport function dateParser(input: string): Date {\n const date = new Date(input);\n if (Number.isNaN(date.getTime())) {\n throw new TypeError(\n `Invalid date: ${input}. Try using the ISO 8601 format (YYYY-MM-DDTHH:MM:SS.SSSZ)`,\n );\n }\n return date;\n}\n\n/**\n * Parse a duration string to milliseconds.\n * Accepts concise/natural-ish strings (powered by `ms`) and returns milliseconds.\n * Examples: \"3600\", \"2d\", \"1h\", \"90 minutes\", \"10s\".\n *\n * @param input - The duration to parse\n * @returns The parsed duration in milliseconds\n * @throws Error if input is not a valid duration\n */\nexport function parseDurationToMs(input: unknown): number {\n if (typeof input === 'number' && Number.isFinite(input)) {\n // backward-compat: numbers => seconds\n return Math.round(input * 1000);\n }\n\n if (typeof input === 'string') {\n const trimmed = input.trim();\n // empty string → our standardized error (avoid ms throwing its own)\n if (trimmed === '') {\n throw new Error('Invalid duration. Examples: \"45\", \"2d\", \"1h\", \"90 minutes\", \"10s\".');\n }\n\n // bare numeric string => seconds (backward-compat)\n const asNumber = Number(trimmed);\n if (trimmed !== '' && Number.isFinite(asNumber)) {\n return Math.round(asNumber * 1000);\n }\n\n // let ms parse human strings\n let parsed: number | undefined;\n try {\n parsed = ms(trimmed as MsStringValue);\n } catch {\n // normalize ms' error to ours\n throw new Error('Invalid duration. Examples: \"45\", \"2d\", \"1h\", \"90 minutes\", \"10s\".');\n }\n if (typeof parsed === 'number' && Number.isFinite(parsed)) {\n return parsed;\n }\n }\n\n throw new Error('Invalid duration. Examples: \"45\", \"2d\", \"1h\", \"90 minutes\", \"10s\".');\n}\n","import type { TypedFlagParameter } from '@stricli/core';\nimport { ScopeName, TRANSCEND_SCOPES } from '@transcend-io/privacy-types';\n\nimport { DEFAULT_TRANSCEND_API, DEFAULT_TRANSCEND_CONSENT_API } from '../../constants.js';\nimport type { LocalContext } from '../../context.js';\nimport { urlParser } from './parsers.js';\n\n/**\n * Common parameter builders for CLI commands\n * These reduce duplication and ensure consistency across commands\n */\n\n/**\n * Creates a standard authentication parameter\n *\n * @param root0 - The scopes and whether it requires a silo scope\n * @returns The parameter object\n */\nexport const createAuthParameter = ({\n scopes,\n requiresSiloScope = false,\n}: {\n /** The scopes required for the command */\n scopes: ScopeName[] | 'Varies';\n /** Whether the command requires a silo scope */\n requiresSiloScope?: boolean;\n}): TypedFlagParameter<string, LocalContext> => {\n const parameter = {\n kind: 'parsed' as const,\n parse: String,\n brief: 'The Transcend API key.',\n };\n\n if (requiresSiloScope) {\n parameter.brief += ' This key must be associated with the data silo(s) being operated on.';\n }\n\n if (scopes === 'Varies') {\n return {\n ...parameter,\n brief: `${\n parameter.brief\n } The scopes required will vary depending on the operation performed. If in doubt, the ${\n TRANSCEND_SCOPES[ScopeName.FullAdmin].title\n } scope will always work.`,\n };\n }\n\n if (scopes.length === 0) {\n return {\n ...parameter,\n brief: `${parameter.brief} No scopes are required for this command.`,\n };\n }\n\n return {\n ...parameter,\n brief: `${parameter.brief} Requires scopes: ${scopes\n .map((s) => `\"${TRANSCEND_SCOPES[s].title}\"`)\n .join(', ')}`,\n };\n};\n\n/**\n * Creates a standard Transcend URL parameter\n *\n * @param defaultUrl - The default URL to use if not provided\n * @returns The parameter object\n */\nexport const createTranscendUrlParameter = (\n defaultUrl = DEFAULT_TRANSCEND_API,\n): TypedFlagParameter<string, LocalContext> => ({\n kind: 'parsed',\n parse: urlParser,\n brief: 'URL of the Transcend backend. Use https://api.us.transcend.io for US hosting',\n default: defaultUrl,\n});\n\n/**\n * Creates a standard Consent URL parameter\n *\n * @param defaultUrl - The default URL to use if not provided\n * @returns The parameter object\n */\nexport const createConsentUrlParameter = (\n defaultUrl = DEFAULT_TRANSCEND_CONSENT_API,\n): TypedFlagParameter<string, LocalContext> => ({\n kind: 'parsed',\n parse: urlParser,\n brief: 'URL of the Transcend consent backend. Use https://consent.us.transcend.io for US hosting',\n default: defaultUrl,\n});\n\n/**\n * Creates a standard Sombra authentication parameter\n *\n * @returns The parameter object\n */\nexport const createSombraAuthParameter = (): TypedFlagParameter<\n string | undefined,\n LocalContext\n> => ({\n kind: 'parsed',\n parse: String,\n brief: 'The Sombra internal key, use for additional authentication when self-hosting Sombra',\n optional: true,\n});\n","import { buildCommand, numberParser } from '@stricli/core';\nimport { ConsentTrackerStatus } from '@transcend-io/privacy-types';\n\nimport { TranscendPullResource } from '../../../enums.js';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters.js';\n\nexport const DEFAULT_TRANSCEND_PULL_RESOURCES = [\n TranscendPullResource.DataSilos,\n TranscendPullResource.Enrichers,\n TranscendPullResource.Templates,\n TranscendPullResource.ApiKeys,\n];\n\nexport const DEFAULT_CONSENT_TRACKER_STATUSES = Object.values(ConsentTrackerStatus);\n\nexport const pullCommand = buildCommand({\n loader: async () => {\n const { pull } = await import('./impl.js');\n return pull;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: 'Varies',\n }),\n resources: {\n kind: 'enum',\n values: ['all', ...Object.values(TranscendPullResource)],\n brief: `The different resource types to pull in. Defaults to ${DEFAULT_TRANSCEND_PULL_RESOURCES.join(\n ',',\n )}.`,\n variadic: ',',\n optional: true,\n },\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the YAML file to pull into',\n default: './transcend.yml',\n },\n transcendUrl: createTranscendUrlParameter(),\n dataSiloIds: {\n kind: 'parsed',\n parse: String,\n variadic: ',',\n brief: 'The UUIDs of the data silos that should be pulled into the YAML file',\n optional: true,\n },\n integrationNames: {\n kind: 'parsed',\n parse: String,\n variadic: ',',\n brief: 'The types of integrations to pull down',\n optional: true,\n },\n trackerStatuses: {\n kind: 'enum',\n values: Object.values(ConsentTrackerStatus),\n variadic: ',',\n brief: 'The statuses of consent manager trackers to pull down. Defaults to all statuses.',\n optional: true,\n },\n pageSize: {\n kind: 'parsed',\n parse: numberParser,\n brief: 'The page size to use when paginating over the API',\n default: '50',\n },\n skipDatapoints: {\n kind: 'boolean',\n brief: 'When true, skip pulling in datapoints alongside data silo resource',\n default: false,\n },\n skipSubDatapoints: {\n kind: 'boolean',\n brief: 'When true, skip pulling in subDatapoints alongside data silo resource',\n default: false,\n },\n includeGuessedCategories: {\n kind: 'boolean',\n brief: 'When true, included guessed data categories that came from the content classifier',\n default: false,\n },\n debug: {\n kind: 'boolean',\n brief: 'Set to true to include debug logs while pulling the configuration',\n default: false,\n },\n },\n },\n docs: {\n brief: 'Pull metadata from Transcend into transcend.yml',\n fullDescription: `Generates a transcend.yml by pulling the configuration from your Transcend instance.\n\nThe API key needs various scopes depending on the resources being pulled (see the CLI's README for more details).\n\nThis command can be helpful if you are looking to:\n\n- Copy your data into another instance\n- Generate a transcend.yml file as a starting point to maintain parts of your data inventory in code.`,\n },\n});\n"],"mappings":"sRASA,SAAgB,EAAW,EAAuB,CAEhD,GAAI,CADc,6EACH,KAAK,EAAM,CACxB,MAAU,MAAM,wBAAwB,IAAQ,CAElD,OAAO,EAUT,SAAgB,EAAU,EAAuB,CAC/C,GAAI,CAEF,OADY,IAAI,IAAI,EAAM,CACf,UAAU,CAAC,QAAQ,MAAO,GAAG,MAClC,CACN,MAAU,MAAM,uBAAuB,IAAQ,EAWnD,SAAgB,EAAY,EAAyB,CACnD,OAAO,EACJ,MAAM,IAAI,CACV,IAA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1
- import{o as e}from"./enums-CyFTrzXY.mjs";import{ScopeName as t,TRANSCEND_SCOPES as n}from"@transcend-io/privacy-types";import{keyBy as r}from"lodash-es";var i=`10.2.1`,a=`A command line interface for programmatic operations across Transcend.`;const o=`transcend`,s=`https://app.transcend.io`,c=`${s}/infrastructure/integrations`,l=`${s}/data-map/data-inventory/data-points`,u=process.env.TRANSCEND_API_URL||`https://api.transcend.io`,d=process.env.TRANSCEND_CONSENT_API_URL||`https://consent.transcend.io`,f={[e.ApiKeys]:[t.ViewApiKeys],[e.Templates]:[t.ManageEmailTemplates],[e.DataSilos]:[t.ManageDataMap,t.ConnectDataSilos],[e.Enrichers]:[t.ManageRequestIdentities],[e.BusinessEntities]:[t.ManageDataInventory],[e.ProcessingActivities]:[t.ManageDataMap],[e.Identifiers]:[t.ManageRequestIdentities],[e.Attributes]:[t.ManageGlobalAttributes],[e.DataFlows]:[t.ManageDataFlow],[e.Cookies]:[t.ManageDataFlow],[e.ConsentManager]:[t.ManageConsentManagerDeveloperSettings],[e.Partitions]:[t.ManageConsentManagerDeveloperSettings],[e.Actions]:[t.ManageDataSubjectRequestSettings],[e.DataSubjects]:[t.ManageDataSubjectRequestSettings],[e.Prompts]:[t.ManagePrompts],[e.PromptPartials]:[t.ManagePrompts],[e.PromptGroups]:[t.ManagePrompts],[e.Agents]:[t.ManagePathfinder],[e.AgentFunctions]:[t.ManagePathfinder],[e.AgentFiles]:[t.ManagePathfinder],[e.Vendors]:[t.ManageDataInventory],[e.DataCategories]:[t.ManageDataInventory],[e.ProcessingPurposes]:[t.ManageDataInventory],[e.ActionItems]:[t.ManageAllActionItems,t.ViewGlobalAttributes],[e.ActionItemCollections]:[t.ManageActionItemCollections],[e.Teams]:[t.ManageAccessControl],[e.Messages]:[t.ManageIntlMessages],[e.PrivacyCenters]:[t.ManagePrivacyCenter],[e.Policies]:[t.ManagePolicies],[e.Assessments]:[t.ManageAssessments],[e.AssessmentTemplates]:[t.ManageAssessments],[e.Purposes]:[t.ManageConsentManager,t.ManagePreferenceStoreSettings],[e.SystemDiscovery]:[t.ManageDataMap]},p={[e.ApiKeys]:[t.ViewApiKeys],[e.Templates]:[t.ViewEmailTemplates],[e.DataSilos]:[t.ViewDataMap,t.ViewDataSubjectRequestSettings],[e.Enrichers]:[t.ViewRequestIdentitySettings],[e.BusinessEntities]:[t.ViewDataInventory],[e.ProcessingActivities]:[t.ViewDataInventory],[e.Identifiers]:[t.ViewRequestIdentitySettings],[e.Attributes]:[t.ViewGlobalAttributes],[e.DataFlows]:[t.ViewDataFlow],[e.Cookies]:[t.ViewDataFlow],[e.ConsentManager]:[t.ViewConsentManager],[e.Partitions]:[t.ViewConsentManager],[e.Actions]:[t.ViewDataSubjectRequestSettings],[e.DataSubjects]:[t.ViewDataSubjectRequestSettings],[e.Prompts]:[t.ViewPrompts],[e.PromptPartials]:[t.ViewPrompts],[e.PromptGroups]:[t.ViewPrompts],[e.Agents]:[t.ViewPathfinder],[e.AgentFunctions]:[t.ViewPathfinder],[e.AgentFiles]:[t.ViewPathfinder],[e.Vendors]:[t.ViewDataInventory],[e.DataCategories]:[t.ViewDataInventory],[e.ProcessingPurposes]:[t.ViewDataInventory],[e.ActionItemCollections]:[t.ViewAllActionItems],[e.ActionItems]:[t.ViewAllActionItems],[e.Teams]:[t.ViewScopes],[e.Messages]:[t.ViewIntlMessages],[e.PrivacyCenters]:[t.ViewPrivacyCenter],[e.Policies]:[t.ViewPolicies],[e.Assessments]:[t.ViewAssessments],[e.AssessmentTemplates]:[t.ViewAssessments],[e.Purposes]:[t.ViewConsentManager,t.ViewPreferenceStoreSettings],[e.SystemDiscovery]:[t.ViewDataMap]},m={[e.ApiKeys]:`api-keys`,[e.Attributes]:`attributes`,[e.DataFlows]:`data-flows`,[e.Cookies]:`cookies`,[e.ConsentManager]:`consent-manager`,[e.Partitions]:`partitions`,[e.Actions]:`actions`,[e.DataSubjects]:`data-subjects`,[e.BusinessEntities]:`business-entities`,[e.ProcessingActivities]:`processing-activities`,[e.Identifiers]:`identifiers`,[e.Enrichers]:`enrichers`,[e.DataSilos]:`data-silos`,[e.Templates]:`templates`,[e.Prompts]:`prompts`,[e.PromptPartials]:`prompt-partials`,[e.PromptGroups]:`prompt-groups`,[e.Agents]:`agents`,[e.AgentFunctions]:`agent-functions`,[e.AgentFiles]:`agent-files`,[e.Vendors]:`vendors`,[e.DataCategories]:`data-categories`,[e.ProcessingPurposes]:`processing-purposes`,[e.ActionItems]:`action-items`,[e.ActionItemCollections]:`action-item-collections`,[e.Teams]:`teams`,[e.Messages]:`messages`,[e.PrivacyCenters]:`privacy-center`,[e.Policies]:`policies`,[e.Assessments]:`assessments`,[e.AssessmentTemplates]:`assessment-templates`,[e.Purposes]:`purposes`,[e.SystemDiscovery]:`system-discovery`},h=r(Object.entries(n).map(([e,t])=>({...t,name:e})),`title`),g=Object.keys(h),_=new Set([429,502,500,504,329]),v=process.env.DEBUG===`1`;export{u as a,h as c,f as d,m as f,i as h,v as i,g as l,a as m,l as n,d as o,o as p,c as r,_ as s,s as t,p as u};
2
- //# sourceMappingURL=constants-TpID7AXE.mjs.map
1
+ import{o as e}from"./enums-CyFTrzXY.mjs";import{ScopeName as t,TRANSCEND_SCOPES as n}from"@transcend-io/privacy-types";import{keyBy as r}from"lodash-es";var i=`10.2.2`,a=`A command line interface for programmatic operations across Transcend.`;const o=`transcend`,s=`https://app.transcend.io`,c=`${s}/infrastructure/integrations`,l=`${s}/data-map/data-inventory/data-points`,u=process.env.TRANSCEND_API_URL||`https://api.transcend.io`,d=process.env.TRANSCEND_CONSENT_API_URL||`https://consent.transcend.io`,f={[e.ApiKeys]:[t.ViewApiKeys],[e.Templates]:[t.ManageEmailTemplates],[e.DataSilos]:[t.ManageDataMap,t.ConnectDataSilos],[e.Enrichers]:[t.ManageRequestIdentities],[e.BusinessEntities]:[t.ManageDataInventory],[e.ProcessingActivities]:[t.ManageDataMap],[e.Identifiers]:[t.ManageRequestIdentities],[e.Attributes]:[t.ManageGlobalAttributes],[e.DataFlows]:[t.ManageDataFlow],[e.Cookies]:[t.ManageDataFlow],[e.ConsentManager]:[t.ManageConsentManagerDeveloperSettings],[e.Partitions]:[t.ManageConsentManagerDeveloperSettings],[e.Actions]:[t.ManageDataSubjectRequestSettings],[e.DataSubjects]:[t.ManageDataSubjectRequestSettings],[e.Prompts]:[t.ManagePrompts],[e.PromptPartials]:[t.ManagePrompts],[e.PromptGroups]:[t.ManagePrompts],[e.Agents]:[t.ManagePathfinder],[e.AgentFunctions]:[t.ManagePathfinder],[e.AgentFiles]:[t.ManagePathfinder],[e.Vendors]:[t.ManageDataInventory],[e.DataCategories]:[t.ManageDataInventory],[e.ProcessingPurposes]:[t.ManageDataInventory],[e.ActionItems]:[t.ManageAllActionItems,t.ViewGlobalAttributes],[e.ActionItemCollections]:[t.ManageActionItemCollections],[e.Teams]:[t.ManageAccessControl],[e.Messages]:[t.ManageIntlMessages],[e.PrivacyCenters]:[t.ManagePrivacyCenter],[e.Policies]:[t.ManagePolicies],[e.Assessments]:[t.ManageAssessments],[e.AssessmentTemplates]:[t.ManageAssessments],[e.Purposes]:[t.ManageConsentManager,t.ManagePreferenceStoreSettings],[e.SystemDiscovery]:[t.ManageDataMap]},p={[e.ApiKeys]:[t.ViewApiKeys],[e.Templates]:[t.ViewEmailTemplates],[e.DataSilos]:[t.ViewDataMap,t.ViewDataSubjectRequestSettings],[e.Enrichers]:[t.ViewRequestIdentitySettings],[e.BusinessEntities]:[t.ViewDataInventory],[e.ProcessingActivities]:[t.ViewDataInventory],[e.Identifiers]:[t.ViewRequestIdentitySettings],[e.Attributes]:[t.ViewGlobalAttributes],[e.DataFlows]:[t.ViewDataFlow],[e.Cookies]:[t.ViewDataFlow],[e.ConsentManager]:[t.ViewConsentManager],[e.Partitions]:[t.ViewConsentManager],[e.Actions]:[t.ViewDataSubjectRequestSettings],[e.DataSubjects]:[t.ViewDataSubjectRequestSettings],[e.Prompts]:[t.ViewPrompts],[e.PromptPartials]:[t.ViewPrompts],[e.PromptGroups]:[t.ViewPrompts],[e.Agents]:[t.ViewPathfinder],[e.AgentFunctions]:[t.ViewPathfinder],[e.AgentFiles]:[t.ViewPathfinder],[e.Vendors]:[t.ViewDataInventory],[e.DataCategories]:[t.ViewDataInventory],[e.ProcessingPurposes]:[t.ViewDataInventory],[e.ActionItemCollections]:[t.ViewAllActionItems],[e.ActionItems]:[t.ViewAllActionItems],[e.Teams]:[t.ViewScopes],[e.Messages]:[t.ViewIntlMessages],[e.PrivacyCenters]:[t.ViewPrivacyCenter],[e.Policies]:[t.ViewPolicies],[e.Assessments]:[t.ViewAssessments],[e.AssessmentTemplates]:[t.ViewAssessments],[e.Purposes]:[t.ViewConsentManager,t.ViewPreferenceStoreSettings],[e.SystemDiscovery]:[t.ViewDataMap]},m={[e.ApiKeys]:`api-keys`,[e.Attributes]:`attributes`,[e.DataFlows]:`data-flows`,[e.Cookies]:`cookies`,[e.ConsentManager]:`consent-manager`,[e.Partitions]:`partitions`,[e.Actions]:`actions`,[e.DataSubjects]:`data-subjects`,[e.BusinessEntities]:`business-entities`,[e.ProcessingActivities]:`processing-activities`,[e.Identifiers]:`identifiers`,[e.Enrichers]:`enrichers`,[e.DataSilos]:`data-silos`,[e.Templates]:`templates`,[e.Prompts]:`prompts`,[e.PromptPartials]:`prompt-partials`,[e.PromptGroups]:`prompt-groups`,[e.Agents]:`agents`,[e.AgentFunctions]:`agent-functions`,[e.AgentFiles]:`agent-files`,[e.Vendors]:`vendors`,[e.DataCategories]:`data-categories`,[e.ProcessingPurposes]:`processing-purposes`,[e.ActionItems]:`action-items`,[e.ActionItemCollections]:`action-item-collections`,[e.Teams]:`teams`,[e.Messages]:`messages`,[e.PrivacyCenters]:`privacy-center`,[e.Policies]:`policies`,[e.Assessments]:`assessments`,[e.AssessmentTemplates]:`assessment-templates`,[e.Purposes]:`purposes`,[e.SystemDiscovery]:`system-discovery`},h=r(Object.entries(n).map(([e,t])=>({...t,name:e})),`title`),g=Object.keys(h),_=new Set([429,502,500,504,329]),v=process.env.DEBUG===`1`;export{u as a,h as c,f as d,m as f,i as h,v as i,g as l,a as m,l as n,d as o,o as p,c as r,_ as s,s as t,p as u};
2
+ //# sourceMappingURL=constants-D22_ckyl.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants-TpID7AXE.mjs","names":[],"sources":["../package.json","../src/constants.ts"],"sourcesContent":["","import { ScopeName, TRANSCEND_SCOPES, type ScopeDefinition } from '@transcend-io/privacy-types';\nimport { keyBy } from 'lodash-es';\n\nimport { TranscendInput } from './codecs.js';\nimport { TranscendPullResource } from './enums.js';\n\nexport { description, version } from '../package.json';\n/**\n * The name of the main binary for the CLI\n */\nexport const name = 'transcend';\n\nexport const ADMIN_DASH = 'https://app.transcend.io';\n\nexport const ADMIN_DASH_INTEGRATIONS = `${ADMIN_DASH}/infrastructure/integrations`;\nexport const ADMIN_DASH_DATAPOINTS = `${ADMIN_DASH}/data-map/data-inventory/data-points`;\n\n/**\n * Override default transcend API url using\n * TRANSCEND_API_URL=https://api.us.transcend.io transcend ...\n */\nexport const DEFAULT_TRANSCEND_API = process.env.TRANSCEND_API_URL || 'https://api.transcend.io';\n\n/**\n * Override default transcend API url using\n * TRANSCEND_CONSENT_API_URL=https://consent.us.transcend.io transcend ...\n */\nexport const DEFAULT_TRANSCEND_CONSENT_API =\n process.env.TRANSCEND_CONSENT_API_URL || 'https://consent.transcend.io';\n\n/**\n * Mapping between resource type and scopes required for cli\n */\nexport const TR_PUSH_RESOURCE_SCOPE_MAP: {\n [k in TranscendPullResource]: ScopeName[];\n} = {\n [TranscendPullResource.ApiKeys]: [ScopeName.ViewApiKeys],\n [TranscendPullResource.Templates]: [ScopeName.ManageEmailTemplates],\n [TranscendPullResource.DataSilos]: [ScopeName.ManageDataMap, ScopeName.ConnectDataSilos],\n [TranscendPullResource.Enrichers]: [ScopeName.ManageRequestIdentities],\n [TranscendPullResource.BusinessEntities]: [ScopeName.ManageDataInventory],\n [TranscendPullResource.ProcessingActivities]: [ScopeName.ManageDataMap],\n [TranscendPullResource.Identifiers]: [ScopeName.ManageRequestIdentities],\n [TranscendPullResource.Attributes]: [ScopeName.ManageGlobalAttributes],\n [TranscendPullResource.DataFlows]: [ScopeName.ManageDataFlow],\n [TranscendPullResource.Cookies]: [ScopeName.ManageDataFlow],\n [TranscendPullResource.ConsentManager]: [ScopeName.ManageConsentManagerDeveloperSettings],\n [TranscendPullResource.Partitions]: [ScopeName.ManageConsentManagerDeveloperSettings],\n [TranscendPullResource.Actions]: [ScopeName.ManageDataSubjectRequestSettings],\n [TranscendPullResource.DataSubjects]: [ScopeName.ManageDataSubjectRequestSettings],\n [TranscendPullResource.Prompts]: [ScopeName.ManagePrompts],\n [TranscendPullResource.PromptPartials]: [ScopeName.ManagePrompts],\n [TranscendPullResource.PromptGroups]: [ScopeName.ManagePrompts],\n [TranscendPullResource.Agents]: [ScopeName.ManagePathfinder],\n [TranscendPullResource.AgentFunctions]: [ScopeName.ManagePathfinder],\n [TranscendPullResource.AgentFiles]: [ScopeName.ManagePathfinder],\n [TranscendPullResource.Vendors]: [ScopeName.ManageDataInventory],\n [TranscendPullResource.DataCategories]: [ScopeName.ManageDataInventory],\n [TranscendPullResource.ProcessingPurposes]: [ScopeName.ManageDataInventory],\n [TranscendPullResource.ActionItems]: [\n ScopeName.ManageAllActionItems,\n ScopeName.ViewGlobalAttributes,\n ],\n [TranscendPullResource.ActionItemCollections]: [ScopeName.ManageActionItemCollections],\n [TranscendPullResource.Teams]: [ScopeName.ManageAccessControl],\n [TranscendPullResource.Messages]: [ScopeName.ManageIntlMessages],\n [TranscendPullResource.PrivacyCenters]: [ScopeName.ManagePrivacyCenter],\n [TranscendPullResource.Policies]: [ScopeName.ManagePolicies],\n [TranscendPullResource.Assessments]: [ScopeName.ManageAssessments],\n [TranscendPullResource.AssessmentTemplates]: [ScopeName.ManageAssessments],\n [TranscendPullResource.Purposes]: [\n ScopeName.ManageConsentManager,\n ScopeName.ManagePreferenceStoreSettings,\n ],\n [TranscendPullResource.SystemDiscovery]: [ScopeName.ManageDataMap],\n};\n\n/**\n * Mapping between resource type and scopes required for cli\n */\nexport const TR_PULL_RESOURCE_SCOPE_MAP: {\n [k in TranscendPullResource]: ScopeName[];\n} = {\n [TranscendPullResource.ApiKeys]: [ScopeName.ViewApiKeys],\n [TranscendPullResource.Templates]: [ScopeName.ViewEmailTemplates],\n [TranscendPullResource.DataSilos]: [\n ScopeName.ViewDataMap,\n ScopeName.ViewDataSubjectRequestSettings,\n ],\n [TranscendPullResource.Enrichers]: [ScopeName.ViewRequestIdentitySettings],\n [TranscendPullResource.BusinessEntities]: [ScopeName.ViewDataInventory],\n [TranscendPullResource.ProcessingActivities]: [ScopeName.ViewDataInventory],\n [TranscendPullResource.Identifiers]: [ScopeName.ViewRequestIdentitySettings],\n [TranscendPullResource.Attributes]: [ScopeName.ViewGlobalAttributes],\n [TranscendPullResource.DataFlows]: [ScopeName.ViewDataFlow],\n [TranscendPullResource.Cookies]: [ScopeName.ViewDataFlow],\n [TranscendPullResource.ConsentManager]: [ScopeName.ViewConsentManager],\n [TranscendPullResource.Partitions]: [ScopeName.ViewConsentManager],\n [TranscendPullResource.Actions]: [ScopeName.ViewDataSubjectRequestSettings],\n [TranscendPullResource.DataSubjects]: [ScopeName.ViewDataSubjectRequestSettings],\n [TranscendPullResource.Prompts]: [ScopeName.ViewPrompts],\n [TranscendPullResource.PromptPartials]: [ScopeName.ViewPrompts],\n [TranscendPullResource.PromptGroups]: [ScopeName.ViewPrompts],\n [TranscendPullResource.Agents]: [ScopeName.ViewPathfinder],\n [TranscendPullResource.AgentFunctions]: [ScopeName.ViewPathfinder],\n [TranscendPullResource.AgentFiles]: [ScopeName.ViewPathfinder],\n [TranscendPullResource.Vendors]: [ScopeName.ViewDataInventory],\n [TranscendPullResource.DataCategories]: [ScopeName.ViewDataInventory],\n [TranscendPullResource.ProcessingPurposes]: [ScopeName.ViewDataInventory],\n [TranscendPullResource.ActionItemCollections]: [ScopeName.ViewAllActionItems],\n [TranscendPullResource.ActionItems]: [ScopeName.ViewAllActionItems],\n [TranscendPullResource.Teams]: [ScopeName.ViewScopes],\n [TranscendPullResource.Messages]: [ScopeName.ViewIntlMessages],\n [TranscendPullResource.PrivacyCenters]: [ScopeName.ViewPrivacyCenter],\n [TranscendPullResource.Policies]: [ScopeName.ViewPolicies],\n [TranscendPullResource.Assessments]: [ScopeName.ViewAssessments],\n [TranscendPullResource.AssessmentTemplates]: [ScopeName.ViewAssessments],\n [TranscendPullResource.Purposes]: [\n ScopeName.ViewConsentManager,\n ScopeName.ViewPreferenceStoreSettings,\n ],\n [TranscendPullResource.SystemDiscovery]: [ScopeName.ViewDataMap],\n};\n\nexport const TR_YML_RESOURCE_TO_FIELD_NAME: Record<TranscendPullResource, keyof TranscendInput> = {\n [TranscendPullResource.ApiKeys]: 'api-keys',\n [TranscendPullResource.Attributes]: 'attributes',\n [TranscendPullResource.DataFlows]: 'data-flows',\n [TranscendPullResource.Cookies]: 'cookies',\n [TranscendPullResource.ConsentManager]: 'consent-manager',\n [TranscendPullResource.Partitions]: 'partitions',\n [TranscendPullResource.Actions]: 'actions',\n [TranscendPullResource.DataSubjects]: 'data-subjects',\n [TranscendPullResource.BusinessEntities]: 'business-entities',\n [TranscendPullResource.ProcessingActivities]: 'processing-activities',\n [TranscendPullResource.Identifiers]: 'identifiers',\n [TranscendPullResource.Enrichers]: 'enrichers',\n [TranscendPullResource.DataSilos]: 'data-silos',\n [TranscendPullResource.Templates]: 'templates',\n [TranscendPullResource.Prompts]: 'prompts',\n [TranscendPullResource.PromptPartials]: 'prompt-partials',\n [TranscendPullResource.PromptGroups]: 'prompt-groups',\n [TranscendPullResource.Agents]: 'agents',\n [TranscendPullResource.AgentFunctions]: 'agent-functions',\n [TranscendPullResource.AgentFiles]: 'agent-files',\n [TranscendPullResource.Vendors]: 'vendors',\n [TranscendPullResource.DataCategories]: 'data-categories',\n [TranscendPullResource.ProcessingPurposes]: 'processing-purposes',\n [TranscendPullResource.ActionItems]: 'action-items',\n [TranscendPullResource.ActionItemCollections]: 'action-item-collections',\n [TranscendPullResource.Teams]: 'teams',\n [TranscendPullResource.Messages]: 'messages',\n [TranscendPullResource.PrivacyCenters]: 'privacy-center',\n [TranscendPullResource.Policies]: 'policies',\n [TranscendPullResource.Assessments]: 'assessments',\n [TranscendPullResource.AssessmentTemplates]: 'assessment-templates',\n [TranscendPullResource.Purposes]: 'purposes',\n [TranscendPullResource.SystemDiscovery]: 'system-discovery',\n};\n\nexport const SCOPES_BY_TITLE = keyBy(\n Object.entries(TRANSCEND_SCOPES).map(([name, value]) => ({\n ...value,\n name,\n })),\n 'title',\n) as Record<\n string,\n ScopeDefinition & {\n /** The camelCased name which identifies the scope */\n name: ScopeName;\n }\n>;\n\nexport const SCOPE_TITLES = Object.keys(SCOPES_BY_TITLE);\n\n/**\n * HTTP statuses that should be retried *in place* without splitting.\n * 429: Rate-limited\n * 502: Upstream/edge gateway error\n * 329: Reserved for custom infra (kept defensively)\n */\nexport const RETRYABLE_BATCH_STATUSES = new Set([429, 502, 500, 504, 329] as const);\n\n/**\n * Debugging\n */\nexport const DEBUG = process.env.DEBUG === '1';\n"],"mappings":"mPCUA,MAAa,EAAO,YAEP,EAAa,2BAEb,EAA0B,GAAG,EAAW,8BACxC,EAAwB,GAAG,EAAW,sCAMtC,EAAwB,QAAQ,IAAI,mBAAqB,2BAMzD,EACX,QAAQ,IAAI,2BAA6B,+BAK9B,EAET,EACD,EAAsB,SAAU,CAAC,EAAU,YAAY,EACvD,EAAsB,WAAY,CAAC,EAAU,qBAAqB,EAClE,EAAsB,WAAY,CAAC,EAAU,cAAe,EAAU,iBAAiB,EACvF,EAAsB,WAAY,CAAC,EAAU,wBAAwB,EACrE,EAAsB,kBAAmB,CAAC,EAAU,oBAAoB,EACxE,EAAsB,sBAAuB,CAAC,EAAU,cAAc,EACtE,EAAsB,aAAc,CAAC,EAAU,wBAAwB,EACvE,EAAsB,YAAa,CAAC,EAAU,uBAAuB,EACrE,EAAsB,WA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,WAChC,EAAsB,gBAAiB,mBACvC,EAAsB,YAAa,cACnC,EAAsB,SAAU,WAChC,EAAsB,cAAe,iBACrC,EAAsB,kBAAmB,qBACzC,EAAsB,sBAAuB,yBAC7C,EAAsB,aAAc,eACpC,EAAsB,WAAY,aAClC,EAAsB,WAAY,cAClC,EAAsB,WAAY,aAClC,EAAsB,SAAU,WAChC,EAAsB,gBAAiB,mBACvC,EAAsB,cAAe,iBACrC,EAAsB,QAAS,UAC/B,EAAsB,gBAAiB,mBACvC,EAAsB,YAAa,eACnC,EAAsB,SAAU,WAChC,EAAsB,gBAAiB,mBACvC,EAAsB,oBAAqB,uBAC3C,EAAsB,aAAc,gBACpC,EAAsB,uBAAwB,2BAC9C,EAAsB,OAAQ,SAC9B,EAAsB,UAAW,YACjC,EAAsB,gBAAiB,kBACvC,EAAsB,UAAW,YACjC,EAAsB,aAAc,eACpC,EAAsB,qBAAsB,wBAC5C,EAAsB,UAAW,YACjC,EAAsB,iBAAkB,mBAC1C,CAEY,EAAkB,EAC7B,OAAO,QAAQ,EAAiB,CAAC,KAAK,CAAC,EAAM,MAAY,CACvD,GAAG,EACH,OACD,EAAE,CACH,QACD,CAQY,EAAe,OAAO,KAAK,EAAgB,CAQ3C,EAA2B,IAAI,IAAI,CAAC,IAAK,IAAK,IAAK,IAAK,IAAI,CAAU,CAKtE,EAAQ,QAAQ,IAAI,QAAU"}
1
+ {"version":3,"file":"constants-D22_ckyl.mjs","names":[],"sources":["../package.json","../src/constants.ts"],"sourcesContent":["","import { ScopeName, TRANSCEND_SCOPES, type ScopeDefinition } from '@transcend-io/privacy-types';\nimport { keyBy } from 'lodash-es';\n\nimport { TranscendInput } from './codecs.js';\nimport { TranscendPullResource } from './enums.js';\n\nexport { description, version } from '../package.json';\n/**\n * The name of the main binary for the CLI\n */\nexport const name = 'transcend';\n\nexport const ADMIN_DASH = 'https://app.transcend.io';\n\nexport const ADMIN_DASH_INTEGRATIONS = `${ADMIN_DASH}/infrastructure/integrations`;\nexport const ADMIN_DASH_DATAPOINTS = `${ADMIN_DASH}/data-map/data-inventory/data-points`;\n\n/**\n * Override default transcend API url using\n * TRANSCEND_API_URL=https://api.us.transcend.io transcend ...\n */\nexport const DEFAULT_TRANSCEND_API = process.env.TRANSCEND_API_URL || 'https://api.transcend.io';\n\n/**\n * Override default transcend API url using\n * TRANSCEND_CONSENT_API_URL=https://consent.us.transcend.io transcend ...\n */\nexport const DEFAULT_TRANSCEND_CONSENT_API =\n process.env.TRANSCEND_CONSENT_API_URL || 'https://consent.transcend.io';\n\n/**\n * Mapping between resource type and scopes required for cli\n */\nexport const TR_PUSH_RESOURCE_SCOPE_MAP: {\n [k in TranscendPullResource]: ScopeName[];\n} = {\n [TranscendPullResource.ApiKeys]: [ScopeName.ViewApiKeys],\n [TranscendPullResource.Templates]: [ScopeName.ManageEmailTemplates],\n [TranscendPullResource.DataSilos]: [ScopeName.ManageDataMap, ScopeName.ConnectDataSilos],\n [TranscendPullResource.Enrichers]: [ScopeName.ManageRequestIdentities],\n [TranscendPullResource.BusinessEntities]: [ScopeName.ManageDataInventory],\n [TranscendPullResource.ProcessingActivities]: [ScopeName.ManageDataMap],\n [TranscendPullResource.Identifiers]: [ScopeName.ManageRequestIdentities],\n [TranscendPullResource.Attributes]: [ScopeName.ManageGlobalAttributes],\n [TranscendPullResource.DataFlows]: [ScopeName.ManageDataFlow],\n [TranscendPullResource.Cookies]: [ScopeName.ManageDataFlow],\n [TranscendPullResource.ConsentManager]: [ScopeName.ManageConsentManagerDeveloperSettings],\n [TranscendPullResource.Partitions]: [ScopeName.ManageConsentManagerDeveloperSettings],\n [TranscendPullResource.Actions]: [ScopeName.ManageDataSubjectRequestSettings],\n [TranscendPullResource.DataSubjects]: [ScopeName.ManageDataSubjectRequestSettings],\n [TranscendPullResource.Prompts]: [ScopeName.ManagePrompts],\n [TranscendPullResource.PromptPartials]: [ScopeName.ManagePrompts],\n [TranscendPullResource.PromptGroups]: [ScopeName.ManagePrompts],\n [TranscendPullResource.Agents]: [ScopeName.ManagePathfinder],\n [TranscendPullResource.AgentFunctions]: [ScopeName.ManagePathfinder],\n [TranscendPullResource.AgentFiles]: [ScopeName.ManagePathfinder],\n [TranscendPullResource.Vendors]: [ScopeName.ManageDataInventory],\n [TranscendPullResource.DataCategories]: [ScopeName.ManageDataInventory],\n [TranscendPullResource.ProcessingPurposes]: [ScopeName.ManageDataInventory],\n [TranscendPullResource.ActionItems]: [\n ScopeName.ManageAllActionItems,\n ScopeName.ViewGlobalAttributes,\n ],\n [TranscendPullResource.ActionItemCollections]: [ScopeName.ManageActionItemCollections],\n [TranscendPullResource.Teams]: [ScopeName.ManageAccessControl],\n [TranscendPullResource.Messages]: [ScopeName.ManageIntlMessages],\n [TranscendPullResource.PrivacyCenters]: [ScopeName.ManagePrivacyCenter],\n [TranscendPullResource.Policies]: [ScopeName.ManagePolicies],\n [TranscendPullResource.Assessments]: [ScopeName.ManageAssessments],\n [TranscendPullResource.AssessmentTemplates]: [ScopeName.ManageAssessments],\n [TranscendPullResource.Purposes]: [\n ScopeName.ManageConsentManager,\n ScopeName.ManagePreferenceStoreSettings,\n ],\n [TranscendPullResource.SystemDiscovery]: [ScopeName.ManageDataMap],\n};\n\n/**\n * Mapping between resource type and scopes required for cli\n */\nexport const TR_PULL_RESOURCE_SCOPE_MAP: {\n [k in TranscendPullResource]: ScopeName[];\n} = {\n [TranscendPullResource.ApiKeys]: [ScopeName.ViewApiKeys],\n [TranscendPullResource.Templates]: [ScopeName.ViewEmailTemplates],\n [TranscendPullResource.DataSilos]: [\n ScopeName.ViewDataMap,\n ScopeName.ViewDataSubjectRequestSettings,\n ],\n [TranscendPullResource.Enrichers]: [ScopeName.ViewRequestIdentitySettings],\n [TranscendPullResource.BusinessEntities]: [ScopeName.ViewDataInventory],\n [TranscendPullResource.ProcessingActivities]: [ScopeName.ViewDataInventory],\n [TranscendPullResource.Identifiers]: [ScopeName.ViewRequestIdentitySettings],\n [TranscendPullResource.Attributes]: [ScopeName.ViewGlobalAttributes],\n [TranscendPullResource.DataFlows]: [ScopeName.ViewDataFlow],\n [TranscendPullResource.Cookies]: [ScopeName.ViewDataFlow],\n [TranscendPullResource.ConsentManager]: [ScopeName.ViewConsentManager],\n [TranscendPullResource.Partitions]: [ScopeName.ViewConsentManager],\n [TranscendPullResource.Actions]: [ScopeName.ViewDataSubjectRequestSettings],\n [TranscendPullResource.DataSubjects]: [ScopeName.ViewDataSubjectRequestSettings],\n [TranscendPullResource.Prompts]: [ScopeName.ViewPrompts],\n [TranscendPullResource.PromptPartials]: [ScopeName.ViewPrompts],\n [TranscendPullResource.PromptGroups]: [ScopeName.ViewPrompts],\n [TranscendPullResource.Agents]: [ScopeName.ViewPathfinder],\n [TranscendPullResource.AgentFunctions]: [ScopeName.ViewPathfinder],\n [TranscendPullResource.AgentFiles]: [ScopeName.ViewPathfinder],\n [TranscendPullResource.Vendors]: [ScopeName.ViewDataInventory],\n [TranscendPullResource.DataCategories]: [ScopeName.ViewDataInventory],\n [TranscendPullResource.ProcessingPurposes]: [ScopeName.ViewDataInventory],\n [TranscendPullResource.ActionItemCollections]: [ScopeName.ViewAllActionItems],\n [TranscendPullResource.ActionItems]: [ScopeName.ViewAllActionItems],\n [TranscendPullResource.Teams]: [ScopeName.ViewScopes],\n [TranscendPullResource.Messages]: [ScopeName.ViewIntlMessages],\n [TranscendPullResource.PrivacyCenters]: [ScopeName.ViewPrivacyCenter],\n [TranscendPullResource.Policies]: [ScopeName.ViewPolicies],\n [TranscendPullResource.Assessments]: [ScopeName.ViewAssessments],\n [TranscendPullResource.AssessmentTemplates]: [ScopeName.ViewAssessments],\n [TranscendPullResource.Purposes]: [\n ScopeName.ViewConsentManager,\n ScopeName.ViewPreferenceStoreSettings,\n ],\n [TranscendPullResource.SystemDiscovery]: [ScopeName.ViewDataMap],\n};\n\nexport const TR_YML_RESOURCE_TO_FIELD_NAME: Record<TranscendPullResource, keyof TranscendInput> = {\n [TranscendPullResource.ApiKeys]: 'api-keys',\n [TranscendPullResource.Attributes]: 'attributes',\n [TranscendPullResource.DataFlows]: 'data-flows',\n [TranscendPullResource.Cookies]: 'cookies',\n [TranscendPullResource.ConsentManager]: 'consent-manager',\n [TranscendPullResource.Partitions]: 'partitions',\n [TranscendPullResource.Actions]: 'actions',\n [TranscendPullResource.DataSubjects]: 'data-subjects',\n [TranscendPullResource.BusinessEntities]: 'business-entities',\n [TranscendPullResource.ProcessingActivities]: 'processing-activities',\n [TranscendPullResource.Identifiers]: 'identifiers',\n [TranscendPullResource.Enrichers]: 'enrichers',\n [TranscendPullResource.DataSilos]: 'data-silos',\n [TranscendPullResource.Templates]: 'templates',\n [TranscendPullResource.Prompts]: 'prompts',\n [TranscendPullResource.PromptPartials]: 'prompt-partials',\n [TranscendPullResource.PromptGroups]: 'prompt-groups',\n [TranscendPullResource.Agents]: 'agents',\n [TranscendPullResource.AgentFunctions]: 'agent-functions',\n [TranscendPullResource.AgentFiles]: 'agent-files',\n [TranscendPullResource.Vendors]: 'vendors',\n [TranscendPullResource.DataCategories]: 'data-categories',\n [TranscendPullResource.ProcessingPurposes]: 'processing-purposes',\n [TranscendPullResource.ActionItems]: 'action-items',\n [TranscendPullResource.ActionItemCollections]: 'action-item-collections',\n [TranscendPullResource.Teams]: 'teams',\n [TranscendPullResource.Messages]: 'messages',\n [TranscendPullResource.PrivacyCenters]: 'privacy-center',\n [TranscendPullResource.Policies]: 'policies',\n [TranscendPullResource.Assessments]: 'assessments',\n [TranscendPullResource.AssessmentTemplates]: 'assessment-templates',\n [TranscendPullResource.Purposes]: 'purposes',\n [TranscendPullResource.SystemDiscovery]: 'system-discovery',\n};\n\nexport const SCOPES_BY_TITLE = keyBy(\n Object.entries(TRANSCEND_SCOPES).map(([name, value]) => ({\n ...value,\n name,\n })),\n 'title',\n) as Record<\n string,\n ScopeDefinition & {\n /** The camelCased name which identifies the scope */\n name: ScopeName;\n }\n>;\n\nexport const SCOPE_TITLES = Object.keys(SCOPES_BY_TITLE);\n\n/**\n * HTTP statuses that should be retried *in place* without splitting.\n * 429: Rate-limited\n * 502: Upstream/edge gateway error\n * 329: Reserved for custom infra (kept defensively)\n */\nexport const RETRYABLE_BATCH_STATUSES = new Set([429, 502, 500, 504, 329] as const);\n\n/**\n * Debugging\n */\nexport const DEBUG = process.env.DEBUG === '1';\n"],"mappings":"mPCUA,MAAa,EAAO,YAEP,EAAa,2BAEb,EAA0B,GAAG,EAAW,8BACxC,EAAwB,GAAG,EAAW,sCAMtC,EAAwB,QAAQ,IAAI,mBAAqB,2BAMzD,EACX,QAAQ,IAAI,2BAA6B,+BAK9B,EAET,EACD,EAAsB,SAAU,CAAC,EAAU,YAAY,EACvD,EAAsB,WAAY,CAAC,EAAU,qBAAqB,EAClE,EAAsB,WAAY,CAAC,EAAU,cAAe,EAAU,iBAAiB,EACvF,EAAsB,WAAY,CAAC,EAAU,wBAAwB,EACrE,EAAsB,kBAAmB,CAAC,EAAU,oBAAoB,EACxE,EAAsB,sBAAuB,CAAC,EAAU,cAAc,EACtE,EAAsB,aAAc,CAAC,EAAU,wBAAwB,EACvE,EAAsB,YAAa,CAAC,EAAU,uBAAuB,EACrE,EAAsB,WAAY,CAAC,EAAU,eAAe,EAC5D,EAAsB,SAAU,CAAC,EAAU,eAAe,EAC1D,EAAsB,gBAAiB,CAAC,EAAU,sCAAsC,EACxF,EAAsB,YAAa,CAAC,EAAU,sCAAsC,EACpF,EAAsB,SAAU,CAAC,EAAU,iCAAiC,EAC5E,EAAsB,cAAe,CAAC,EAAU,iCAAiC,EACjF,EAAsB,SAAU,CAAC,EAAU,cAAc,EACzD,EAAsB,gBAAiB,CAAC,EAAU,cAAc,EAChE,EAAsB,cAAe,CAAC,EAAU,cAAc,EAC9D,EAAsB,QAAS,CAAC,EAAU,iBAAiB,EAC3D,EAAsB,gBAAiB,CAAC,EAAU,iBAAiB,EACnE,EAAsB,YAAa,CAAC,EAAU,iBAAiB,EAC/D,EAAsB,SAAU,CAAC,EAAU,oBAAoB,EAC/D,EAAsB,g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,UAAW,YACjC,EAAsB,aAAc,eACpC,EAAsB,qBAAsB,wBAC5C,EAAsB,UAAW,YACjC,EAAsB,iBAAkB,mBAC1C,CAEY,EAAkB,EAC7B,OAAO,QAAQ,EAAiB,CAAC,KAAK,CAAC,EAAM,MAAY,CACvD,GAAG,EACH,OACD,EAAE,CACH,QACD,CAQY,EAAe,OAAO,KAAK,EAAgB,CAQ3C,EAA2B,IAAI,IAAI,CAAC,IAAK,IAAK,IAAK,IAAK,IAAI,CAAU,CAKtE,EAAQ,QAAQ,IAAI,QAAU"}
@@ -1,4 +1,4 @@
1
- import{i as e}from"./constants-TpID7AXE.mjs";import{createReadStream as t,readFileSync as n,statSync as r}from"node:fs";import{basename as i}from"node:path";import a from"colors";import*as o from"node:readline";function s(e,t,r){process.stdout.write(`\x1B[2J\x1B[H`);let i=e=>/\b(ERROR|uncaughtException|unhandledRejection)\b/i.test(e),a=e=>/\b(WARN|WARNING)\b/i.test(e),o=[];for(let[,s]of e){if(!s)continue;let e=[];for(let n of t)n===`out`&&s.outPath&&e.push({path:s.outPath,src:`out`}),n===`err`&&s.errPath&&e.push({path:s.errPath,src:`err`}),n===`structured`&&s.structuredPath&&e.push({path:s.structuredPath,src:`structured`}),s.warnPath&&n===`warn`&&e.push({path:s.warnPath,src:`warn`}),s.infoPath&&n===`info`&&e.push({path:s.infoPath,src:`info`});for(let{path:t,src:s}of e){let e=``;try{e=n(t,`utf8`)}catch{continue}for(let t of e.split(`
1
+ import{i as e}from"./constants-D22_ckyl.mjs";import{createReadStream as t,readFileSync as n,statSync as r}from"node:fs";import{basename as i}from"node:path";import a from"colors";import*as o from"node:readline";function s(e,t,r){process.stdout.write(`\x1B[2J\x1B[H`);let i=e=>/\b(ERROR|uncaughtException|unhandledRejection)\b/i.test(e),a=e=>/\b(WARN|WARNING)\b/i.test(e),o=[];for(let[,s]of e){if(!s)continue;let e=[];for(let n of t)n===`out`&&s.outPath&&e.push({path:s.outPath,src:`out`}),n===`err`&&s.errPath&&e.push({path:s.errPath,src:`err`}),n===`structured`&&s.structuredPath&&e.push({path:s.structuredPath,src:`structured`}),s.warnPath&&n===`warn`&&e.push({path:s.warnPath,src:`warn`}),s.infoPath&&n===`info`&&e.push({path:s.infoPath,src:`info`});for(let{path:t,src:s}of e){let e=``;try{e=n(t,`utf8`)}catch{continue}for(let t of e.split(`
2
2
  `)){if(!t)continue;let e=t.replace(/\x1B\[[0-9;]*m/g,``);if(r===`all`){o.push(t);continue}if(r===`error`){i(e)&&o.push(t);continue}if(a(e)||s===`err`&&!i(e)){o.push(t);continue}}}}o.sort((e,t)=>{let n=e.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/)?.[0]??``,r=t.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/)?.[0]??``;return n.localeCompare(r)}),process.stdout.write(`${o.join(`
3
3
  `)}\n`),process.stdout.write(`
4
4
  Press Esc/Ctrl+] to return to dashboard.
@@ -11,4 +11,4 @@ Press Esc/Ctrl+] to return to dashboard.
11
11
  `);!e.final&&r===p||(p=r,e.final?process.stdout.write(`\x1B[?25h`):(process.stdout.write(`\x1B[?25l`),o.cursorTo(process.stdout,0,0),o.clearScreenDown(process.stdout)),process.stdout.write(`${r}\n`))}function g(e){return typeof e==`number`?e.toLocaleString():`0`}function _(e,t=40){let n=Math.max(0,Math.min(100,Math.floor(e))),r=Math.floor(n/100*t);return`█`.repeat(r)+`░`.repeat(t-r)}function v(e){let t=[...e.workerState.values()].filter(e=>e.busy).length,n=e.filesCompleted+e.filesFailed;return{done:n,inProgress:t,pct:e.filesTotal===0?100:Math.floor(n/Math.max(1,e.filesTotal)*100)}}function y(e,t=[]){let{title:n,poolSize:r,cpuCount:i,filesTotal:o,filesCompleted:s,filesFailed:c,throughput:l}=e,{inProgress:u,pct:d}=v(e),f=[`${a.bold(n)} — ${r} workers ${a.dim(`(CPU avail: ${i})`)}`,`${a.dim(`Files`)} ${g(o)} ${a.dim(`Completed`)} ${g(s)} ${a.dim(`Failed`)} ${c?a.red(g(c)):g(c)} ${a.dim(`In-flight`)} ${g(u)}`,`[${_(d)}] ${d}%`];if(l){let t=l.jobsR10s>0||l.jobsR60s>0,n=Math.round((t?l.jobsR10s:l.r10s)*3600).toLocaleString(),r=Math.round((t?l.jobsR60s:l.r60s)*3600).toLocaleString(),i=t?`rec`:`files`,o=e.throughput?.successSoFar==null?``:` Newly uploaded: ${g(e.throughput.successSoFar)}`;f.push(a.cyan(`Throughput: ${n} ${i}/hr (1h: ${r} ${i}/hr)${o}`))}return t.length?f.concat(t):f}function b(e,t=e=>e?i(e):`-`){return[...e.workerState.entries()].map(([e,n])=>{let r=n.lastLevel===`error`?a.red(`ERROR `):n.lastLevel===`warn`?a.yellow(`WARN `):n.busy?a.green(`WORKING`):a.dim(`IDLE `),i=t(n.file),o=n.startedAt?`${Math.floor((Date.now()-n.startedAt)/1e3)}s`:`-`,s=n.progress?.processed??0,c=n.progress?.total??0,l=c>0?Math.floor(s/c*100):0;return` [w${e}] ${r} | ${i} | ${o} | [${c>0?_(l,18):` `.repeat(18)}] ${c>0?`${s.toLocaleString()}/${c.toLocaleString()} (${l}%)`:a.dim(`—`)}`})}function x(e){let{logsBySlot:t,repaint:n,setPaused:r,exportMgr:i,exportStatus:a,custom:o}=e,c=e=>{process.stdout.write(`${e}\n`)},l=(e,t)=>{let r=Date.now(),i=a?.[e]??{path:t};a&&(a[e]={path:t||i.path,savedAt:r,exported:!0},n())},u=!1,d=(e,i)=>{u||(u=!0,r(!0),process.stdout.write(`\x1B[2J\x1B[H`),process.stdout.write(`Combined logs viewer (press Esc or Ctrl+] to return)
12
12
 
13
13
  `),(async()=>{try{await s(t,e,i)}catch{u=!1,r(!1),n()}})())},f=(e,n)=>{if(i)try{let r=i.exportCombinedLogs(t,e);c(`\nWrote combined ${n} logs to: ${r}`),l(e,r)}catch{c(`\nFailed to write combined ${n} logs`)}};return e=>{let t=e.toString(`utf8`);if(t===`e`){d([`err`],`error`);return}if(t===`w`){d([`warn`,`err`],`warn`);return}if(t===`i`){d([`info`],`all`);return}if(t===`l`){d([`out`,`err`,`structured`],`all`);return}if(t===`E`){f(`error`,`error`);return}if(t===`W`){f(`warn`,`warn`);return}if(t===`I`){f(`info`,`info`);return}if(t===`A`){f(`all`,`ALL`);return}let i=o?.[t];if(i){i({noteExport:l,say:c});return}(t===`\x1B`||t===``)&&(u=!1,r(!1),n())}}export{f as a,h as i,y as n,b as r,x as t};
14
- //# sourceMappingURL=createExtraKeyHandler-BO4lu0HO.mjs.map
14
+ //# sourceMappingURL=createExtraKeyHandler-BkfSV_aF.mjs.map