@transcend-io/cli 10.0.1 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (404) hide show
  1. package/README.md +16 -5
  2. package/dist/{app-BfTrk2nc.mjs → app-C1m4rExX.mjs} +21 -21
  3. package/dist/{app-BfTrk2nc.mjs.map → app-C1m4rExX.mjs.map} +1 -1
  4. package/dist/approvePrivacyRequests-BIHcACAj.mjs +2 -0
  5. package/dist/approvePrivacyRequests-BIHcACAj.mjs.map +1 -0
  6. package/dist/bin/bash-complete.mjs +1 -1
  7. package/dist/bin/cli.mjs +1 -1
  8. package/dist/bin/deprecated-command.mjs +1 -1
  9. package/dist/buildXdiSyncEndpoint-CBbcir-p.mjs +9 -0
  10. package/dist/buildXdiSyncEndpoint-CBbcir-p.mjs.map +1 -0
  11. package/dist/bulkRestartRequests-ByH7TjH2.mjs +2 -0
  12. package/dist/bulkRestartRequests-ByH7TjH2.mjs.map +1 -0
  13. package/dist/bulkRetryEnrichers-DuYXD-64.mjs +2 -0
  14. package/dist/bulkRetryEnrichers-DuYXD-64.mjs.map +1 -0
  15. package/dist/cancelPrivacyRequests-DMgQOffA.mjs +2 -0
  16. package/dist/cancelPrivacyRequests-DMgQOffA.mjs.map +1 -0
  17. package/dist/{codecs-BE3Wmoh8.mjs → codecs-CeDPaLYa.mjs} +1 -1
  18. package/dist/{codecs-BE3Wmoh8.mjs.map → codecs-CeDPaLYa.mjs.map} +1 -1
  19. package/dist/collectCsvFilesOrExit-CbtyKAzu.mjs +2 -0
  20. package/dist/collectCsvFilesOrExit-CbtyKAzu.mjs.map +1 -0
  21. package/dist/collectParquetFilesOrExit-BJiAyaQ5.mjs +2 -0
  22. package/dist/collectParquetFilesOrExit-BJiAyaQ5.mjs.map +1 -0
  23. package/dist/{command-BXxoAjFo.mjs → command-DnoHX-eW.mjs} +2 -2
  24. package/dist/{command-BXxoAjFo.mjs.map → command-DnoHX-eW.mjs.map} +1 -1
  25. package/dist/commands/admin/chunk-csv/worker.d.mts +48 -0
  26. package/dist/commands/admin/chunk-csv/worker.d.mts.map +1 -0
  27. package/dist/commands/admin/chunk-csv/worker.mjs +2 -0
  28. package/dist/commands/admin/chunk-csv/worker.mjs.map +1 -0
  29. package/dist/commands/admin/parquet-to-csv/worker.d.mts +25 -0
  30. package/dist/commands/admin/parquet-to-csv/worker.d.mts.map +1 -0
  31. package/dist/commands/admin/parquet-to-csv/worker.mjs +2 -0
  32. package/dist/commands/admin/parquet-to-csv/worker.mjs.map +1 -0
  33. package/dist/{consentManagersToBusinessEntities-BDgOFga7.mjs → consentManagersToBusinessEntities-BdKDganK.mjs} +2 -2
  34. package/dist/{consentManagersToBusinessEntities-BDgOFga7.mjs.map → consentManagersToBusinessEntities-BdKDganK.mjs.map} +1 -1
  35. package/dist/{constants-AFtS5Nad.mjs → constants-BmwXDQu9.mjs} +2 -2
  36. package/dist/{constants-AFtS5Nad.mjs.map → constants-BmwXDQu9.mjs.map} +1 -1
  37. package/dist/{constants-lIvXgkdp.mjs → constants-ClkQQhJs.mjs} +1 -1
  38. package/dist/{constants-lIvXgkdp.mjs.map → constants-ClkQQhJs.mjs.map} +1 -1
  39. package/dist/constants-muOBBQA_.mjs +2 -0
  40. package/dist/constants-muOBBQA_.mjs.map +1 -0
  41. package/dist/{context-CdSyuBlf.mjs → context-bkKpii_t.mjs} +1 -1
  42. package/dist/{context-CdSyuBlf.mjs.map → context-bkKpii_t.mjs.map} +1 -1
  43. package/dist/createExtraKeyHandler-srtG2U7q.mjs +14 -0
  44. package/dist/createExtraKeyHandler-srtG2U7q.mjs.map +1 -0
  45. package/dist/{dataFlowsToDataSilos-NhvBw1iy.mjs → dataFlowsToDataSilos-Ca2DtTsd.mjs} +1 -1
  46. package/dist/dataFlowsToDataSilos-Ca2DtTsd.mjs.map +1 -0
  47. package/dist/{done-input-validation-DLR0-MJ7.mjs → done-input-validation-BcNBxhEs.mjs} +1 -1
  48. package/dist/{done-input-validation-DLR0-MJ7.mjs.map → done-input-validation-BcNBxhEs.mjs.map} +1 -1
  49. package/dist/downloadPrivacyRequestFiles-kKhGnFmx.mjs +2 -0
  50. package/dist/downloadPrivacyRequestFiles-kKhGnFmx.mjs.map +1 -0
  51. package/dist/{extractClientError-DPjv09EH.mjs → extractClientError-i-Tw_az7.mjs} +1 -1
  52. package/dist/{extractClientError-DPjv09EH.mjs.map → extractClientError-i-Tw_az7.mjs.map} +1 -1
  53. package/dist/fetchAllRequests-CHHdyb4Q.mjs +2 -0
  54. package/dist/fetchAllRequests-CHHdyb4Q.mjs.map +1 -0
  55. package/dist/generateCrossAccountApiKeys-C7yH3Rbi.mjs +2 -0
  56. package/dist/generateCrossAccountApiKeys-C7yH3Rbi.mjs.map +1 -0
  57. package/dist/impl-3VLH9aat.mjs +2 -0
  58. package/dist/impl-3VLH9aat.mjs.map +1 -0
  59. package/dist/{impl-Rt3C_fDF.mjs → impl-3sDUDXru.mjs} +2 -2
  60. package/dist/{impl-Rt3C_fDF.mjs.map → impl-3sDUDXru.mjs.map} +1 -1
  61. package/dist/{impl-Cgg_bv7j.mjs → impl-6mCOBlSD.mjs} +2 -2
  62. package/dist/{impl-Cgg_bv7j.mjs.map → impl-6mCOBlSD.mjs.map} +1 -1
  63. package/dist/impl-84ylH4aO.mjs +2 -0
  64. package/dist/{impl-CMmyv1cl.mjs.map → impl-84ylH4aO.mjs.map} +1 -1
  65. package/dist/impl-B62XN4tV.mjs +2 -0
  66. package/dist/impl-B62XN4tV.mjs.map +1 -0
  67. package/dist/{impl-DGiPB5Vq2.mjs → impl-B9BsXBxS.mjs} +2 -2
  68. package/dist/impl-B9BsXBxS.mjs.map +1 -0
  69. package/dist/{impl-KDuBh4bu2.mjs → impl-BNqmxytJ.mjs} +2 -2
  70. package/dist/impl-BNqmxytJ.mjs.map +1 -0
  71. package/dist/{impl-CqXFyvgV2.mjs → impl-BYf4MpWP.mjs} +2 -2
  72. package/dist/impl-BYf4MpWP.mjs.map +1 -0
  73. package/dist/impl-BaC9iEO_.mjs +2 -0
  74. package/dist/impl-BaC9iEO_.mjs.map +1 -0
  75. package/dist/impl-BhDS0QIt.mjs +2 -0
  76. package/dist/impl-BhDS0QIt.mjs.map +1 -0
  77. package/dist/{impl-CNez1OAw.mjs → impl-BjCQSRLu.mjs} +2 -2
  78. package/dist/{impl-CNez1OAw.mjs.map → impl-BjCQSRLu.mjs.map} +1 -1
  79. package/dist/impl-BjIylEKQ.mjs +4 -0
  80. package/dist/impl-BjIylEKQ.mjs.map +1 -0
  81. package/dist/impl-BwrEi3s7.mjs +2 -0
  82. package/dist/impl-BwrEi3s7.mjs.map +1 -0
  83. package/dist/impl-C4AI1Fsj.mjs +3 -0
  84. package/dist/impl-C4AI1Fsj.mjs.map +1 -0
  85. package/dist/{impl-fqOKTw5J.mjs → impl-CCAeEeMR.mjs} +2 -2
  86. package/dist/{impl-fqOKTw5J.mjs.map → impl-CCAeEeMR.mjs.map} +1 -1
  87. package/dist/{impl-P_NDC3cX.mjs → impl-CFI5y5U-.mjs} +2 -2
  88. package/dist/{impl-P_NDC3cX.mjs.map → impl-CFI5y5U-.mjs.map} +1 -1
  89. package/dist/{impl-BOUm7wly2.mjs → impl-CIfRN0ux.mjs} +2 -2
  90. package/dist/impl-CIfRN0ux.mjs.map +1 -0
  91. package/dist/impl-CLznNZ5F.mjs +2 -0
  92. package/dist/impl-CLznNZ5F.mjs.map +1 -0
  93. package/dist/impl-CUdo0Jyh.mjs +2 -0
  94. package/dist/impl-CUdo0Jyh.mjs.map +1 -0
  95. package/dist/{impl-MpkLBntW.mjs → impl-Cmj1Vi5Q.mjs} +2 -2
  96. package/dist/{impl-MpkLBntW.mjs.map → impl-Cmj1Vi5Q.mjs.map} +1 -1
  97. package/dist/impl-Cw3_0zqC.mjs +2 -0
  98. package/dist/impl-Cw3_0zqC.mjs.map +1 -0
  99. package/dist/{impl-D-cp0CYr.mjs → impl-CzvCA0Ev.mjs} +2 -2
  100. package/dist/{impl-D-cp0CYr.mjs.map → impl-CzvCA0Ev.mjs.map} +1 -1
  101. package/dist/{impl-CSChmq_t2.mjs → impl-D1DmW5-P.mjs} +2 -2
  102. package/dist/impl-D1DmW5-P.mjs.map +1 -0
  103. package/dist/{impl-CCUsnhoW2.mjs → impl-D41c_KGj.mjs} +2 -2
  104. package/dist/impl-D41c_KGj.mjs.map +1 -0
  105. package/dist/impl-DEpCg7UP.mjs +2 -0
  106. package/dist/{impl-tbGnvKFm.mjs.map → impl-DEpCg7UP.mjs.map} +1 -1
  107. package/dist/{impl-DGuwD_qz.mjs → impl-DHOh4ypd.mjs} +2 -2
  108. package/dist/{impl-DGuwD_qz.mjs.map → impl-DHOh4ypd.mjs.map} +1 -1
  109. package/dist/{impl-D9NjIwEi2.mjs → impl-DJg0Ibxs.mjs} +2 -2
  110. package/dist/impl-DJg0Ibxs.mjs.map +1 -0
  111. package/dist/impl-DUdbbIpf.mjs +2 -0
  112. package/dist/impl-DUdbbIpf.mjs.map +1 -0
  113. package/dist/impl-DXHqqWJb.mjs +7 -0
  114. package/dist/impl-DXHqqWJb.mjs.map +1 -0
  115. package/dist/impl-DXaA3sMt.mjs +2 -0
  116. package/dist/impl-DXaA3sMt.mjs.map +1 -0
  117. package/dist/impl-Dl4RcPKp.mjs +2 -0
  118. package/dist/{impl-DEWXA_QC.mjs.map → impl-Dl4RcPKp.mjs.map} +1 -1
  119. package/dist/{impl-c7rUQYDc2.mjs → impl-DvAwxl6Z.mjs} +2 -2
  120. package/dist/impl-DvAwxl6Z.mjs.map +1 -0
  121. package/dist/{impl-JThkrXiI2.mjs → impl-GRdcDZQ4.mjs} +2 -2
  122. package/dist/impl-GRdcDZQ4.mjs.map +1 -0
  123. package/dist/{impl-CNykdy3e2.mjs → impl-UMb9wjra.mjs} +2 -2
  124. package/dist/impl-UMb9wjra.mjs.map +1 -0
  125. package/dist/impl-Yq33AV90.mjs +2 -0
  126. package/dist/impl-Yq33AV90.mjs.map +1 -0
  127. package/dist/impl-aGDJJgGc.mjs +2 -0
  128. package/dist/impl-aGDJJgGc.mjs.map +1 -0
  129. package/dist/impl-fZQxhZRu.mjs +12 -0
  130. package/dist/impl-fZQxhZRu.mjs.map +1 -0
  131. package/dist/{impl-BUC4ZelU.mjs → impl-gitQPEo3.mjs} +2 -2
  132. package/dist/{impl-BUC4ZelU.mjs.map → impl-gitQPEo3.mjs.map} +1 -1
  133. package/dist/impl-i-vquwbD.mjs +2 -0
  134. package/dist/{impl-C2o0eDzJ.mjs.map → impl-i-vquwbD.mjs.map} +1 -1
  135. package/dist/impl-iteb85IZ.mjs +4 -0
  136. package/dist/impl-iteb85IZ.mjs.map +1 -0
  137. package/dist/impl-tYtVXUz2.mjs +2 -0
  138. package/dist/impl-tYtVXUz2.mjs.map +1 -0
  139. package/dist/{impl-DGzvE8aJ.mjs → impl-wcRtA0L3.mjs} +2 -2
  140. package/dist/{impl-DGzvE8aJ.mjs.map → impl-wcRtA0L3.mjs.map} +1 -1
  141. package/dist/impl-xtlx25UP.mjs +2 -0
  142. package/dist/impl-xtlx25UP.mjs.map +1 -0
  143. package/dist/impl-yMumZUUX.mjs +2 -0
  144. package/dist/impl-yMumZUUX.mjs.map +1 -0
  145. package/dist/index.d.mts +1135 -5125
  146. package/dist/index.d.mts.map +1 -1
  147. package/dist/index.mjs +4 -78
  148. package/dist/index.mjs.map +1 -1
  149. package/dist/{inquirer-BgNcicZ4.mjs → inquirer-BqZXFEt1.mjs} +2 -2
  150. package/dist/{inquirer-BgNcicZ4.mjs.map → inquirer-BqZXFEt1.mjs.map} +1 -1
  151. package/dist/{listFiles-qzyQMaYH.mjs → listFiles-D2wMHnEr.mjs} +1 -1
  152. package/dist/{listFiles-qzyQMaYH.mjs.map → listFiles-D2wMHnEr.mjs.map} +1 -1
  153. package/dist/{logger-B-LXIf3U.mjs → logger-Bj782ZYD.mjs} +1 -1
  154. package/dist/{logger-B-LXIf3U.mjs.map → logger-Bj782ZYD.mjs.map} +1 -1
  155. package/dist/markRequestDataSiloIdsCompleted-BaVxVfDe.mjs +2 -0
  156. package/dist/markRequestDataSiloIdsCompleted-BaVxVfDe.mjs.map +1 -0
  157. package/dist/markSilentPrivacyRequests-miaumnaC.mjs +2 -0
  158. package/dist/markSilentPrivacyRequests-miaumnaC.mjs.map +1 -0
  159. package/dist/notifyPrivacyRequestsAdditionalTime-BUdhSCNL.mjs +2 -0
  160. package/dist/notifyPrivacyRequestsAdditionalTime-BUdhSCNL.mjs.map +1 -0
  161. package/dist/parquetToCsvOneFile-B84XXInh.mjs +6 -0
  162. package/dist/parquetToCsvOneFile-B84XXInh.mjs.map +1 -0
  163. package/dist/parseAttributesFromString-D1Yl0xwT.mjs +2 -0
  164. package/dist/{parseAttributesFromString-CZStzJc0.mjs.map → parseAttributesFromString-D1Yl0xwT.mjs.map} +1 -1
  165. package/dist/parseVariablesFromString-BeKOGw5n.mjs +3 -0
  166. package/dist/parseVariablesFromString-BeKOGw5n.mjs.map +1 -0
  167. package/dist/pullAllDatapoints-Bbmky50p.mjs +45 -0
  168. package/dist/pullAllDatapoints-Bbmky50p.mjs.map +1 -0
  169. package/dist/pullChunkedCustomSiloOutstandingIdentifiers-BW5Vws25.mjs +2 -0
  170. package/dist/pullChunkedCustomSiloOutstandingIdentifiers-BW5Vws25.mjs.map +1 -0
  171. package/dist/pullConsentManagerMetrics-zKgjc3Ap.mjs +2 -0
  172. package/dist/pullConsentManagerMetrics-zKgjc3Ap.mjs.map +1 -0
  173. package/dist/pullManualEnrichmentIdentifiersToCsv-kpGy9H7T.mjs +2 -0
  174. package/dist/pullManualEnrichmentIdentifiersToCsv-kpGy9H7T.mjs.map +1 -0
  175. package/dist/pullTranscendConfiguration-DjOELnPo.mjs +58 -0
  176. package/dist/pullTranscendConfiguration-DjOELnPo.mjs.map +1 -0
  177. package/dist/{pullUnstructuredSubDataPointRecommendations-DZd2q6S2.mjs → pullUnstructuredSubDataPointRecommendations-D0z-vPgq.mjs} +4 -4
  178. package/dist/pullUnstructuredSubDataPointRecommendations-D0z-vPgq.mjs.map +1 -0
  179. package/dist/pushCronIdentifiersFromCsv-BZRA1n_8.mjs +2 -0
  180. package/dist/pushCronIdentifiersFromCsv-BZRA1n_8.mjs.map +1 -0
  181. package/dist/pushManualEnrichmentIdentifiersFromCsv-DXqf8WWy.mjs +2 -0
  182. package/dist/pushManualEnrichmentIdentifiersFromCsv-DXqf8WWy.mjs.map +1 -0
  183. package/dist/{readCsv-CyOL7eCc.mjs → readCsv-C4TyEs-r.mjs} +1 -1
  184. package/dist/{readCsv-CyOL7eCc.mjs.map → readCsv-C4TyEs-r.mjs.map} +1 -1
  185. package/dist/{readTranscendYaml-D-J1ilS0.mjs → readTranscendYaml-DVkQL2SC.mjs} +2 -2
  186. package/dist/{readTranscendYaml-D-J1ilS0.mjs.map → readTranscendYaml-DVkQL2SC.mjs.map} +1 -1
  187. package/dist/removeUnverifiedRequestIdentifiers-BxWSsJit.mjs +2 -0
  188. package/dist/removeUnverifiedRequestIdentifiers-BxWSsJit.mjs.map +1 -0
  189. package/dist/{request-CAsR6CMY.mjs → request-DfkRPQFr.mjs} +1 -1
  190. package/dist/{request-CAsR6CMY.mjs.map → request-DfkRPQFr.mjs.map} +1 -1
  191. package/dist/retryRequestDataSilos-BVrJz_GC.mjs +2 -0
  192. package/dist/retryRequestDataSilos-BVrJz_GC.mjs.map +1 -0
  193. package/dist/skipPreflightJobs-CYuoMG3z.mjs +2 -0
  194. package/dist/skipPreflightJobs-CYuoMG3z.mjs.map +1 -0
  195. package/dist/skipRequestDataSilos-BNspAsjR.mjs +2 -0
  196. package/dist/skipRequestDataSilos-BNspAsjR.mjs.map +1 -0
  197. package/dist/streamPrivacyRequestsToCsv-PoyTmQd6.mjs +2 -0
  198. package/dist/streamPrivacyRequestsToCsv-PoyTmQd6.mjs.map +1 -0
  199. package/dist/syncCodePackages-CAk_Hjyl.mjs +2 -0
  200. package/dist/syncCodePackages-CAk_Hjyl.mjs.map +1 -0
  201. package/dist/updateConsentManagerVersionToLatest-lAw3E1wm.mjs +2 -0
  202. package/dist/updateConsentManagerVersionToLatest-lAw3E1wm.mjs.map +1 -0
  203. package/dist/uploadConsents-BzmWrNc1.mjs +2 -0
  204. package/dist/uploadConsents-BzmWrNc1.mjs.map +1 -0
  205. package/dist/uploadCookiesFromCsv-TH10UBgw.mjs +2 -0
  206. package/dist/uploadCookiesFromCsv-TH10UBgw.mjs.map +1 -0
  207. package/dist/uploadDataFlowsFromCsv-DUSFCae9.mjs +2 -0
  208. package/dist/uploadDataFlowsFromCsv-DUSFCae9.mjs.map +1 -0
  209. package/dist/uploadPrivacyRequestsFromCsv-sKSFfE6q.mjs +2 -0
  210. package/dist/uploadPrivacyRequestsFromCsv-sKSFfE6q.mjs.map +1 -0
  211. package/dist/{validateTranscendAuth-1W1IylqE.mjs → validateTranscendAuth-Cuh2Qfdl.mjs} +2 -2
  212. package/dist/{validateTranscendAuth-1W1IylqE.mjs.map → validateTranscendAuth-Cuh2Qfdl.mjs.map} +1 -1
  213. package/dist/{writeCsv-B51ulrVl.mjs → writeCsv-C4pjXGsD.mjs} +1 -1
  214. package/dist/{writeCsv-B51ulrVl.mjs.map → writeCsv-C4pjXGsD.mjs.map} +1 -1
  215. package/package.json +13 -10
  216. package/dist/RateCounter-DFL_mnk2.mjs +0 -2
  217. package/dist/RateCounter-DFL_mnk2.mjs.map +0 -1
  218. package/dist/RequestDataSilo-_Iv44M9u.mjs +0 -51
  219. package/dist/RequestDataSilo-_Iv44M9u.mjs.map +0 -1
  220. package/dist/approvePrivacyRequests-CWGZR2N6.mjs +0 -2
  221. package/dist/approvePrivacyRequests-CWGZR2N6.mjs.map +0 -1
  222. package/dist/assessment-BDywVaGR.mjs +0 -284
  223. package/dist/assessment-BDywVaGR.mjs.map +0 -1
  224. package/dist/bluebird-CUitXgsY.mjs +0 -2
  225. package/dist/bluebird-CUitXgsY.mjs.map +0 -1
  226. package/dist/buildXdiSyncEndpoint-Cb-pvpak.mjs +0 -9
  227. package/dist/buildXdiSyncEndpoint-Cb-pvpak.mjs.map +0 -1
  228. package/dist/bulkRestartRequests-CKF_xpN0.mjs +0 -2
  229. package/dist/bulkRestartRequests-CKF_xpN0.mjs.map +0 -1
  230. package/dist/bulkRetryEnrichers-B-Szmin-.mjs +0 -2
  231. package/dist/bulkRetryEnrichers-B-Szmin-.mjs.map +0 -1
  232. package/dist/cancelPrivacyRequests-DNiL13E_.mjs +0 -2
  233. package/dist/cancelPrivacyRequests-DNiL13E_.mjs.map +0 -1
  234. package/dist/codecs-Dx_vGxsl.mjs +0 -2
  235. package/dist/codecs-Dx_vGxsl.mjs.map +0 -1
  236. package/dist/constants-CeMiHaHx.mjs +0 -2
  237. package/dist/constants-CeMiHaHx.mjs.map +0 -1
  238. package/dist/createExtraKeyHandler-tubeaEjA.mjs +0 -23
  239. package/dist/createExtraKeyHandler-tubeaEjA.mjs.map +0 -1
  240. package/dist/createPreferenceAccessTokens-DqmFctn3.mjs +0 -10
  241. package/dist/createPreferenceAccessTokens-DqmFctn3.mjs.map +0 -1
  242. package/dist/createSombraGotInstance-D1Il9zUE.mjs +0 -10
  243. package/dist/createSombraGotInstance-D1Il9zUE.mjs.map +0 -1
  244. package/dist/dataFlowsToDataSilos-NhvBw1iy.mjs.map +0 -1
  245. package/dist/dataSilo-DrFetFXw.mjs +0 -302
  246. package/dist/dataSilo-DrFetFXw.mjs.map +0 -1
  247. package/dist/dataSubject-y_aXI0pa.mjs +0 -92
  248. package/dist/dataSubject-y_aXI0pa.mjs.map +0 -1
  249. package/dist/downloadPrivacyRequestFiles-DlpgxqHF.mjs +0 -2
  250. package/dist/downloadPrivacyRequestFiles-DlpgxqHF.mjs.map +0 -1
  251. package/dist/extractErrorMessage-CPnTsT1S.mjs +0 -2
  252. package/dist/extractErrorMessage-CPnTsT1S.mjs.map +0 -1
  253. package/dist/fetchAllActions-BJsPdnxy.mjs +0 -832
  254. package/dist/fetchAllActions-BJsPdnxy.mjs.map +0 -1
  255. package/dist/fetchAllDataFlows-D248lO6_.mjs +0 -2
  256. package/dist/fetchAllDataFlows-D248lO6_.mjs.map +0 -1
  257. package/dist/fetchAllPreferenceTopics-ForE9GpZ.mjs +0 -36
  258. package/dist/fetchAllPreferenceTopics-ForE9GpZ.mjs.map +0 -1
  259. package/dist/fetchAllPurposes-ZdkO2fMp.mjs +0 -29
  260. package/dist/fetchAllPurposes-ZdkO2fMp.mjs.map +0 -1
  261. package/dist/fetchAllPurposesAndPreferences-DD6OyA5t.mjs +0 -2
  262. package/dist/fetchAllPurposesAndPreferences-DD6OyA5t.mjs.map +0 -1
  263. package/dist/fetchAllRequestEnrichers-CK-kk5eg.mjs +0 -42
  264. package/dist/fetchAllRequestEnrichers-CK-kk5eg.mjs.map +0 -1
  265. package/dist/fetchAllRequestIdentifiers-DrFFOt0m.mjs +0 -10
  266. package/dist/fetchAllRequestIdentifiers-DrFFOt0m.mjs.map +0 -1
  267. package/dist/fetchAllRequests-DNQQsY4s.mjs +0 -2
  268. package/dist/fetchAllRequests-DNQQsY4s.mjs.map +0 -1
  269. package/dist/fetchApiKeys-DjOr44xA.mjs +0 -33
  270. package/dist/fetchApiKeys-DjOr44xA.mjs.map +0 -1
  271. package/dist/fetchCatalogs-BM4FCbcS.mjs +0 -12
  272. package/dist/fetchCatalogs-BM4FCbcS.mjs.map +0 -1
  273. package/dist/fetchConsentManagerId-CFkg3-RS.mjs +0 -321
  274. package/dist/fetchConsentManagerId-CFkg3-RS.mjs.map +0 -1
  275. package/dist/fetchIdentifiers-pjQV4vUg.mjs +0 -54
  276. package/dist/fetchIdentifiers-pjQV4vUg.mjs.map +0 -1
  277. package/dist/fetchRequestDataSilo-P4yA7Lyc.mjs +0 -2
  278. package/dist/fetchRequestDataSilo-P4yA7Lyc.mjs.map +0 -1
  279. package/dist/fetchRequestFilesForRequest-BbxrEKFK.mjs +0 -33
  280. package/dist/fetchRequestFilesForRequest-BbxrEKFK.mjs.map +0 -1
  281. package/dist/generateCrossAccountApiKeys-Bxc_dzMG.mjs +0 -33
  282. package/dist/generateCrossAccountApiKeys-Bxc_dzMG.mjs.map +0 -1
  283. package/dist/impl-4ltdSmpl2.mjs +0 -4
  284. package/dist/impl-4ltdSmpl2.mjs.map +0 -1
  285. package/dist/impl-B19fH75P.mjs +0 -12
  286. package/dist/impl-B19fH75P.mjs.map +0 -1
  287. package/dist/impl-BBMjv5YQ.mjs +0 -2
  288. package/dist/impl-BBMjv5YQ.mjs.map +0 -1
  289. package/dist/impl-BKH3QRLi.mjs +0 -3
  290. package/dist/impl-BKH3QRLi.mjs.map +0 -1
  291. package/dist/impl-BOUm7wly2.mjs.map +0 -1
  292. package/dist/impl-BhTCp0kg.mjs +0 -2
  293. package/dist/impl-BhTCp0kg.mjs.map +0 -1
  294. package/dist/impl-BlHU1bbJ2.mjs +0 -2
  295. package/dist/impl-BlHU1bbJ2.mjs.map +0 -1
  296. package/dist/impl-BwjguKHC.mjs +0 -4
  297. package/dist/impl-BwjguKHC.mjs.map +0 -1
  298. package/dist/impl-C2o0eDzJ.mjs +0 -2
  299. package/dist/impl-C8HKnjw82.mjs +0 -2
  300. package/dist/impl-C8HKnjw82.mjs.map +0 -1
  301. package/dist/impl-CCUsnhoW2.mjs.map +0 -1
  302. package/dist/impl-CCc-wXqD.mjs +0 -2
  303. package/dist/impl-CCc-wXqD.mjs.map +0 -1
  304. package/dist/impl-CMmyv1cl.mjs +0 -2
  305. package/dist/impl-CNykdy3e2.mjs.map +0 -1
  306. package/dist/impl-CSChmq_t2.mjs.map +0 -1
  307. package/dist/impl-Ce9K4OCp.mjs +0 -2
  308. package/dist/impl-Ce9K4OCp.mjs.map +0 -1
  309. package/dist/impl-ChCqHkOc2.mjs +0 -2
  310. package/dist/impl-ChCqHkOc2.mjs.map +0 -1
  311. package/dist/impl-CqEwwWeD.mjs +0 -2
  312. package/dist/impl-CqEwwWeD.mjs.map +0 -1
  313. package/dist/impl-CqXFyvgV2.mjs.map +0 -1
  314. package/dist/impl-CxLSJk2P.mjs +0 -2
  315. package/dist/impl-CxLSJk2P.mjs.map +0 -1
  316. package/dist/impl-CzU9WTiW.mjs +0 -2
  317. package/dist/impl-CzU9WTiW.mjs.map +0 -1
  318. package/dist/impl-D9NjIwEi2.mjs.map +0 -1
  319. package/dist/impl-DEWXA_QC.mjs +0 -2
  320. package/dist/impl-DGiPB5Vq2.mjs.map +0 -1
  321. package/dist/impl-DTp9OQIZ.mjs +0 -7
  322. package/dist/impl-DTp9OQIZ.mjs.map +0 -1
  323. package/dist/impl-DhscnXSw.mjs +0 -2
  324. package/dist/impl-DhscnXSw.mjs.map +0 -1
  325. package/dist/impl-Dk7MdX-1.mjs +0 -2
  326. package/dist/impl-Dk7MdX-1.mjs.map +0 -1
  327. package/dist/impl-DsNPvet4.mjs +0 -2
  328. package/dist/impl-DsNPvet4.mjs.map +0 -1
  329. package/dist/impl-DxUFb0vv.mjs +0 -2
  330. package/dist/impl-DxUFb0vv.mjs.map +0 -1
  331. package/dist/impl-JThkrXiI2.mjs.map +0 -1
  332. package/dist/impl-KDuBh4bu2.mjs.map +0 -1
  333. package/dist/impl-c7rUQYDc2.mjs.map +0 -1
  334. package/dist/impl-oiBTZqQS2.mjs +0 -2
  335. package/dist/impl-oiBTZqQS2.mjs.map +0 -1
  336. package/dist/impl-tbGnvKFm.mjs +0 -2
  337. package/dist/makeGraphQLRequest-Cq26A_Lq.mjs +0 -2
  338. package/dist/makeGraphQLRequest-Cq26A_Lq.mjs.map +0 -1
  339. package/dist/markRequestDataSiloIdsCompleted-DzqJ5MNY.mjs +0 -2
  340. package/dist/markRequestDataSiloIdsCompleted-DzqJ5MNY.mjs.map +0 -1
  341. package/dist/markSilentPrivacyRequests-BKQUu6Ep.mjs +0 -2
  342. package/dist/markSilentPrivacyRequests-BKQUu6Ep.mjs.map +0 -1
  343. package/dist/mergeTranscendInputs-DGC4xUGu.mjs +0 -2
  344. package/dist/mergeTranscendInputs-DGC4xUGu.mjs.map +0 -1
  345. package/dist/notifyPrivacyRequestsAdditionalTime-TEHAJe4C.mjs +0 -2
  346. package/dist/notifyPrivacyRequestsAdditionalTime-TEHAJe4C.mjs.map +0 -1
  347. package/dist/package-C4J38oR1.mjs +0 -2
  348. package/dist/package-C4J38oR1.mjs.map +0 -1
  349. package/dist/parquetToCsvOneFile-DZVKXrjn.mjs +0 -6
  350. package/dist/parquetToCsvOneFile-DZVKXrjn.mjs.map +0 -1
  351. package/dist/parseAttributesFromString-CZStzJc0.mjs +0 -2
  352. package/dist/pullAllDatapoints-Cntwuzw7.mjs +0 -45
  353. package/dist/pullAllDatapoints-Cntwuzw7.mjs.map +0 -1
  354. package/dist/pullChunkedCustomSiloOutstandingIdentifiers-BT-GZpT1.mjs +0 -2
  355. package/dist/pullChunkedCustomSiloOutstandingIdentifiers-BT-GZpT1.mjs.map +0 -1
  356. package/dist/pullConsentManagerMetrics-FnhPEszu.mjs +0 -2
  357. package/dist/pullConsentManagerMetrics-FnhPEszu.mjs.map +0 -1
  358. package/dist/pullManualEnrichmentIdentifiersToCsv-B_4REnga.mjs +0 -2
  359. package/dist/pullManualEnrichmentIdentifiersToCsv-B_4REnga.mjs.map +0 -1
  360. package/dist/pullTranscendConfiguration-CqsgEf9A.mjs +0 -80
  361. package/dist/pullTranscendConfiguration-CqsgEf9A.mjs.map +0 -1
  362. package/dist/pullUnstructuredSubDataPointRecommendations-DZd2q6S2.mjs.map +0 -1
  363. package/dist/pushCronIdentifiersFromCsv-D2saGR5i.mjs +0 -2
  364. package/dist/pushCronIdentifiersFromCsv-D2saGR5i.mjs.map +0 -1
  365. package/dist/pushManualEnrichmentIdentifiersFromCsv-DOvAzMyt.mjs +0 -2
  366. package/dist/pushManualEnrichmentIdentifiersFromCsv-DOvAzMyt.mjs.map +0 -1
  367. package/dist/removeUnverifiedRequestIdentifiers-ChlwRmhd.mjs +0 -35
  368. package/dist/removeUnverifiedRequestIdentifiers-ChlwRmhd.mjs.map +0 -1
  369. package/dist/retryRequestDataSilos-DnwXA1YZ.mjs +0 -2
  370. package/dist/retryRequestDataSilos-DnwXA1YZ.mjs.map +0 -1
  371. package/dist/skipPreflightJobs-jK5lNlmv.mjs +0 -2
  372. package/dist/skipPreflightJobs-jK5lNlmv.mjs.map +0 -1
  373. package/dist/skipRequestDataSilos-DQGroOos.mjs +0 -2
  374. package/dist/skipRequestDataSilos-DQGroOos.mjs.map +0 -1
  375. package/dist/splitCsvToList-BRq_CIfd.mjs +0 -2
  376. package/dist/splitCsvToList-BRq_CIfd.mjs.map +0 -1
  377. package/dist/streamPrivacyRequestsToCsv-BK07Bm-T.mjs +0 -2
  378. package/dist/streamPrivacyRequestsToCsv-BK07Bm-T.mjs.map +0 -1
  379. package/dist/syncCodePackages-F-97FNjo.mjs +0 -232
  380. package/dist/syncCodePackages-F-97FNjo.mjs.map +0 -1
  381. package/dist/syncCookies-BxY36BeJ.mjs +0 -2
  382. package/dist/syncCookies-BxY36BeJ.mjs.map +0 -1
  383. package/dist/syncDataFlows-Cx5LZCen.mjs +0 -2
  384. package/dist/syncDataFlows-Cx5LZCen.mjs.map +0 -1
  385. package/dist/syncTemplates-BrH7Yr0V.mjs +0 -23
  386. package/dist/syncTemplates-BrH7Yr0V.mjs.map +0 -1
  387. package/dist/time-Bl_c3W8U.mjs +0 -2
  388. package/dist/time-Bl_c3W8U.mjs.map +0 -1
  389. package/dist/types-B4CVJCpj.mjs +0 -2
  390. package/dist/types-B4CVJCpj.mjs.map +0 -1
  391. package/dist/updateConsentManagerVersionToLatest-C221vAAw.mjs +0 -2
  392. package/dist/updateConsentManagerVersionToLatest-C221vAAw.mjs.map +0 -1
  393. package/dist/uploadConsents-BbR7_sSt.mjs +0 -2
  394. package/dist/uploadConsents-BbR7_sSt.mjs.map +0 -1
  395. package/dist/uploadCookiesFromCsv-roHWekOP.mjs +0 -2
  396. package/dist/uploadCookiesFromCsv-roHWekOP.mjs.map +0 -1
  397. package/dist/uploadDataFlowsFromCsv-DcTbrsv2.mjs +0 -2
  398. package/dist/uploadDataFlowsFromCsv-DcTbrsv2.mjs.map +0 -1
  399. package/dist/uploadPrivacyRequestsFromCsv-BUGTS-pY.mjs +0 -17
  400. package/dist/uploadPrivacyRequestsFromCsv-BUGTS-pY.mjs.map +0 -1
  401. package/dist/uploadSiloDiscoveryResults-D2fK92WR.mjs +0 -20
  402. package/dist/uploadSiloDiscoveryResults-D2fK92WR.mjs.map +0 -1
  403. package/dist/withPreferenceRetry-xLMZyTq9.mjs +0 -2
  404. package/dist/withPreferenceRetry-xLMZyTq9.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"impl-DGiPB5Vq2.mjs","names":[],"sources":["../src/commands/request/notify-additional-time/impl.ts"],"sourcesContent":["import type { RequestAction } from '@transcend-io/privacy-types';\n\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { notifyPrivacyRequestsAdditionalTime } from '../../../lib/requests/index.js';\n\nexport interface NotifyAdditionalTimeCommandFlags {\n auth: string;\n createdAtBefore: Date;\n createdAtAfter?: Date;\n updatedAtBefore?: Date;\n updatedAtAfter?: Date;\n actions?: RequestAction[];\n daysLeft: number;\n days: number;\n requestIds?: string[];\n emailTemplate: string;\n transcendUrl: string;\n concurrency: number;\n}\n\nexport async function notifyAdditionalTime(\n this: LocalContext,\n {\n auth,\n transcendUrl,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n actions,\n daysLeft,\n days,\n requestIds,\n emailTemplate,\n concurrency,\n }: NotifyAdditionalTimeCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n await notifyPrivacyRequestsAdditionalTime({\n transcendUrl,\n requestActions: actions,\n auth,\n emailTemplate,\n days,\n daysLeft,\n requestIds,\n concurrency,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n });\n}\n"],"mappings":"2HAqBA,eAAsB,EAEpB,CACE,OACA,eACA,kBACA,iBACA,kBACA,iBACA,UACA,WACA,OACA,aACA,gBACA,eAEa,CACf,EAAoB,KAAK,QAAQ,KAAK,CAEtC,MAAM,EAAoC,CACxC,eACA,eAAgB,EAChB,OACA,gBACA,OACA,WACA,aACA,cACA,kBACA,iBACA,kBACA,iBACD,CAAC"}
@@ -1,7 +0,0 @@
1
- import{t as e}from"./logger-B-LXIf3U.mjs";import{n as t,t as n}from"./bluebird-CUitXgsY.mjs";import{t as r}from"./createSombraGotInstance-D1Il9zUE.mjs";import{t as i}from"./fetchAllPurposes-ZdkO2fMp.mjs";import{t as a}from"./fetchAllPreferenceTopics-ForE9GpZ.mjs";import{n as o}from"./parseAttributesFromString-CZStzJc0.mjs";import{t as s}from"./splitCsvToList-BRq_CIfd.mjs";import{t as c}from"./readCsv-CyOL7eCc.mjs";import{r as l}from"./makeGraphQLRequest-Cq26A_Lq.mjs";import{n as u}from"./inquirer-BgNcicZ4.mjs";import{t as d}from"./done-input-validation-DLR0-MJ7.mjs";import{r as f}from"./codecs-Dx_vGxsl.mjs";import{t as p}from"./types-B4CVJCpj.mjs";import{t as m}from"./withPreferenceRetry-xLMZyTq9.mjs";import{PreferenceTopicType as h}from"@transcend-io/privacy-types";import{chunk as g,difference as _,groupBy as v,keyBy as y,uniq as b}from"lodash-es";import{apply as x,decodeCodec as S}from"@transcend-io/type-utils";import{readdirSync as C}from"node:fs";import{basename as w,join as T}from"node:path";import E from"colors";import*as D from"io-ts";import O from"inquirer";import k from"cli-progress";import{PersistedState as A}from"@transcend-io/persisted-state";function j({row:e,columnToPurposeName:t,purposeSlugs:n,preferenceTopics:r}){let i={};return Object.entries(t).forEach(([t,{purpose:a,preference:o,valueMapping:c}])=>{if(!n.includes(a))throw Error(`Invalid purpose slug: ${a}, expected: ${n.join(`, `)}`);let l=e[t];if(o){let e=r.find(e=>e.slug===o&&e.purpose.trackingType===a);if(!e){let e=r.filter(e=>e.purpose.trackingType===a).map(e=>e.slug);throw Error(`Invalid preference slug: ${o} for purpose: ${a}. Allowed preference slugs for purpose are: ${e.join(`,`)}`)}switch(i[a]||(i[a]={preferences:[]}),i[a].preferences||(i[a].preferences=[]),e.type){case h.Boolean:{let e=c[l];if(e===void 0&&l!==``)throw Error(`No preference mapping found for value "${l}" in column "${t}" (purpose=${a}, preference=${o})`);if(e==null)return;if(typeof e!=`boolean`)throw Error(`Invalid value for boolean preference: ${o}, expected boolean, got: ${l}`);i[a].preferences.push({topic:o,choice:{booleanValue:e}});break}case h.Select:{let n=c[l];if(n===void 0&&l!==``)throw Error(`No preference mapping found for value "${l}" in column "${t}" (purpose=${a}, preference=${o})`);if(n==null)return;if(typeof n!=`string`)throw Error(`Invalid value for select preference: ${o}, expected string, got: ${l}`);let r=n.trim()||null;if(r&&!e.preferenceOptionValues.map(({slug:e})=>e).includes(r))throw Error(`Invalid value for select preference: ${o}, expected one of: ${e.preferenceOptionValues.map(({slug:e})=>e).join(`, `)}, got: ${l}`);i[a].preferences.push({topic:o,choice:{selectValue:r}});break}case h.MultiSelect:{if(typeof l!=`string`)throw Error(`Invalid value for multi select preference: ${o}, expected string, got: ${l}`);let n=s(l).map(n=>{let r=c[n];if(r===void 0&&l!==``)throw Error(`No preference mapping found for multi select token "${l}" in column "${t}" (purpose=${a}, preference=${o})`);if(r==null)return null;if(typeof r!=`string`)throw Error(`Invalid value for multi select preference: ${o}, expected one of: ${e.preferenceOptionValues.map(({slug:e})=>e).join(`, `)}, got: ${n}`);return r}).filter(e=>e!==null).sort((e,t)=>e.localeCompare(t));n.length>0&&i[a].preferences.push({topic:o,choice:{selectValues:n}});break}default:throw Error(`Unknown preference type: ${e.type}`)}}else{let n=c[l];if(n===void 0&&l!==``)throw Error(`No preference mapping found for value "${l}" in column "${t}" (purpose=${a}, preference=∅) ${JSON.stringify(e)}`);if(n===null)return;i[a]?i[a].enabled=n===!0:i[a]={enabled:n===!0}}}),x(i,(e,t)=>{if(typeof e.enabled!=`boolean`)throw Error(`No mapping provided for purpose.enabled=true/false value: ${t}`);return{...e,enabled:e.enabled}})}function M({currentConsentRecord:e,pendingUpdates:t,preferenceTopics:n}){return Object.entries(t).every(([t,{preferences:r=[],enabled:i}])=>{let a=e.purposes.find(e=>e.purpose===t);return a&&a.enabled===i?r.every(({topic:e,choice:r})=>a.preferences&&a.preferences.find(i=>{if(i.topic!==e)return!1;let a=n.find(n=>n.slug===e&&n.purpose.trackingType===t);if(!a)throw Error(`Could not find preference topic for ${e}`);switch(a.type){case h.Boolean:return i.choice.booleanValue===r.booleanValue;case h.Select:return i.choice.selectValue===r.selectValue;case h.MultiSelect:let e=(i.choice.selectValues||[]).sort(),t=(r.selectValues||[]).sort();return e.length===t.length&&e.every((e,n)=>e===t[n]);default:throw Error(`Unknown preference topic type: ${a.type}`)}})):!1})}function N({currentConsentRecord:t,pendingUpdates:n,preferenceTopics:r,log:i}){return!!Object.entries(n).find(([n,{preferences:a=[],enabled:o}])=>{let s=t.purposes.find(e=>e.purpose===n);return s?s.enabled===o?!!a.find(({topic:a,choice:o})=>{let c=(s.preferences||[]).find(e=>e.topic===a);if(!c)return i&&e.warn(`No existing preference found for topic ${a} in purpose ${n} for user ${t.userId}.`),!1;let l=r.find(e=>e.slug===a&&e.purpose.trackingType===n);if(!l)throw Error(`Could not find preference topic for ${a}`);let u,d;switch(l.type){case h.Boolean:return u=c.choice.booleanValue!==o.booleanValue,i&&e.warn(`Preference topic ${a} boolean value conflict for user ${t.userId}. Expected: ${o.booleanValue}, Found: ${c.choice.booleanValue}`),u;case h.Select:return d=c.choice.selectValue!==o.selectValue,i&&e.warn(`Preference topic ${a} select value conflict for user ${t.userId}. Expected: ${o.selectValue}, Found: ${c.choice.selectValue}`),d;case h.MultiSelect:let n=(c.choice.selectValues||[]).sort(),r=(o.selectValues||[]).sort();return d=n.length!==r.length||!n.every((e,t)=>e===r[t]),i&&e.warn(`Preference topic ${a} multi-select value conflict for user ${t.userId}. Expected: ${r.join(`, `)}, Found: ${n.join(`, `)}`),d;default:throw Error(`Unknown preference topic type: ${l.type}`)}}):(i&&e.warn(`Purpose ${n} enabled value conflict for user ${t.userId}. Pending Value: ${o}, Current Value: ${s.enabled}`),!0):(i&&e.warn(`No existing purpose found for ${n} in consent record for ${t.userId}.`),!1)})}async function P(t,{identifiers:r,partitionKey:i,skipLogging:a=!1,concurrency:o=40}){let s=[],c=g(r,100),l=new Date().getTime(),u=new k.SingleBar({},k.Presets.shades_classic);a||u.start(r.length,0);let d=0;await n(c,async n=>{let r=S(p,await m(`Preference Query`,()=>t.post(`v1/preferences/${i}/query`,{json:{filter:{identifiers:n},limit:n.length}}).json(),{onRetry:(t,r,a)=>{e.warn(E.yellow(`[RETRY] group size=${n.length} partition=${i} attempt=${t}: ${a}`))}}));s.push(...r.nodes),d+=n.length,u.update(d)},{concurrency:o}),u.stop();let f=new Date().getTime()-l;return a||e.info(E.green(`Completed download in "${f/1e3}" seconds.`)),s}async function F(n,r,{purposeSlugs:i,preferenceTopics:a,forceTriggerWorkflows:o}){let c=_(b(n.map(e=>Object.keys(e)).flat()),[...r.identifierColumn?[r.identifierColumn]:[],...r.timestampColum?[r.timestampColum]:[]]);if(c.length===0){if(o)return r;throw Error(`No other columns to process`)}let l=[...i,...a.map(e=>`${e.purpose.trackingType}->${e.slug}`)];return await t(c,async o=>{let c=b(n.map(e=>e[o])),u=r.columnToPurposeName[o];if(u)e.info(E.magenta(`Column "${o}" is associated with purpose "${u.purpose}"`));else{let{purposeName:e}=await O.prompt([{name:`purposeName`,message:`Choose the purpose that column ${o} is associated with`,type:`list`,default:l.find(e=>e.startsWith(i[0])),choices:l}]),[t,n]=e.split(`->`);u={purpose:t,preference:n||null,valueMapping:{}}}await t(c,async n=>{if(u.valueMapping[n]!==void 0){e.info(E.magenta(`Value "${n}" is associated with purpose value "${u.valueMapping[n]}"`));return}if(u.preference===null){let{purposeValue:e}=await O.prompt([{name:`purposeValue`,message:`Choose the purpose value for value "${n}" associated with purpose "${u.purpose}"`,type:`confirm`,default:n!==`false`}]);u.valueMapping[n]=e}if(u.preference!==null){let r=a.find(e=>e.slug===u.preference);if(!r){e.error(E.red(`Preference topic "${u.preference}" not found`));return}let i=r.preferenceOptionValues.map(({slug:e})=>e);if(r.type===h.Boolean){let{preferenceValue:e}=await O.prompt([{name:`preferenceValue`,message:`Choose the preference value for "${r.slug}" value "${n}" associated with purpose "${u.purpose}"`,type:`confirm`,default:n!==`false`}]);u.valueMapping[n]=e;return}if(r.type===h.Select){let{preferenceValue:e}=await O.prompt([{name:`preferenceValue`,message:`Choose the preference value for "${r.slug}" value "${n}" associated with purpose "${u.purpose}"`,type:`list`,choices:i,default:i.find(e=>e===n)}]);u.valueMapping[n]=e;return}if(r.type===h.MultiSelect){await t(s(n),async e=>{if(u.valueMapping[e]!==void 0)return;let{preferenceValue:t}=await O.prompt([{name:`preferenceValue`,message:`Choose the preference value for "${r.slug}" value "${e}" associated with purpose "${u.purpose}"`,type:`list`,choices:i,default:i.find(t=>t===e)}]);u.valueMapping[e]=t});return}throw Error(`Unknown preference topic type: ${r.type}`)}}),r.columnToPurposeName[o]=u}),r}async function I(t,n){let r=_(b(t.map(e=>Object.keys(e)).flat()),[...n.identifierColumn?[n.identifierColumn]:[],...Object.keys(n.columnToPurposeName)]);if(!n.identifierColumn){let{identifierName:e}=await O.prompt([{name:`identifierName`,message:`Choose the column that will be used as the identifier to upload consent preferences by`,type:`list`,default:r.find(e=>e.toLowerCase().includes(`email`))||r[0],choices:r}]);n.identifierColumn=e}e.info(E.magenta(`Using identifier column "${n.identifierColumn}"`));let i=t.map((e,t)=>e[n.identifierColumn]?null:[t]).filter(e=>!!e).flat();if(i.length>0){let r=`The identifier column "${n.identifierColumn}" is missing a value for the following rows: ${i.join(`, `)}`;if(e.warn(E.yellow(r)),!await u({message:`Would you like to skip rows missing an identifier?`}))throw Error(r);let a=t.length;t=t.filter(e=>e[n.identifierColumn]),e.info(E.yellow(`Skipped ${a-t.length} rows missing an identifier`))}e.info(E.magenta(`The identifier column "${n.identifierColumn}" is present for all rows`));let a=v(t,n.identifierColumn),o=Object.entries(a).filter(([,e])=>e.length>1);if(o.length>0){let r=`The identifier column "${n.identifierColumn}" has duplicate values for the following rows: ${o.slice(0,10).map(([e,t])=>`${e} (${t.length})`).join(`
2
- `)}`;if(e.warn(E.yellow(r)),!await u({message:`Would you like to automatically take the latest update?`}))throw Error(r);t=Object.entries(a).map(([,e])=>e.sort((e,t)=>new Date(t[n.timestampColum]).getTime()-new Date(e[n.timestampColum]).getTime())[0]).filter(e=>e)}return{currentState:n,preferences:t}}async function L(t,n){let r=_(b(t.map(e=>Object.keys(e)).flat()),[...n.identifierColumn?[n.identifierColumn]:[],...Object.keys(n.columnToPurposeName)]);if(!n.timestampColum){let{timestampName:e}=await O.prompt([{name:`timestampName`,message:`Choose the column that will be used as the timestamp of last preference update`,type:`list`,default:r.find(e=>e.toLowerCase().includes(`date`))||r.find(e=>e.toLowerCase().includes(`time`))||r[0],choices:[...r,`[NONE]`]}]);n.timestampColum=e}if(e.info(E.magenta(`Using timestamp column "${n.timestampColum}"`)),n.timestampColum!==`[NONE]`){let r=t.map((e,t)=>e[n.timestampColum]?null:[t]).filter(e=>!!e).flat();if(r.length>0)throw Error(`The timestamp column "${n.timestampColum}" is missing a value for the following rows: ${r.join(`
3
- `)}`);e.info(E.magenta(`The timestamp column "${n.timestampColum}" is present for all row`))}return n}async function R({file:t,sombra:n,purposeSlugs:r,preferenceTopics:i,partitionKey:a,skipExistingRecordCheck:o,forceTriggerWorkflows:s},l){let u=new Date().getTime(),d=l.getValue(`fileMetadata`);e.info(E.magenta(`Reading in file: "${t}"`));let f=c(t,D.record(D.string,D.string)),p={columnToPurposeName:{},pendingSafeUpdates:{},pendingConflictUpdates:{},skippedUpdates:{},...d[t]||{},lastFetchedAt:new Date().toISOString()};p=await L(f,p),d[t]=p,await l.setValue(d,`fileMetadata`);let m=await I(f,p);p=m.currentState,f=m.preferences,d[t]=p,await l.setValue(d,`fileMetadata`),p=await F(f,p,{preferenceTopics:i,purposeSlugs:r,forceTriggerWorkflows:s}),d[t]=p,await l.setValue(d,`fileMetadata`);let h=f.map(e=>e[p.identifierColumn]),g=y(o?[]:await P(n,{identifiers:h.map(e=>({value:e})),partitionKey:a}),`userId`);p.pendingConflictUpdates={},p.pendingSafeUpdates={},p.skippedUpdates={},f.forEach(e=>{let t=e[p.identifierColumn],n=j({row:e,columnToPurposeName:p.columnToPurposeName,preferenceTopics:i,purposeSlugs:r}),a=g[t];if(s&&!a)throw Error(`No existing consent record found for user with id: ${t}.
4
- When 'forceTriggerWorkflows' is set all the user identifiers should contain a consent record`);if(a&&M({currentConsentRecord:a,pendingUpdates:n,preferenceTopics:i})&&!s){p.skippedUpdates[t]=e;return}if(a&&N({currentConsentRecord:a,pendingUpdates:n,preferenceTopics:i})){p.pendingConflictUpdates[t]={row:e,record:a};return}p.pendingSafeUpdates[t]=e}),d[t]=p,await l.setValue(d,`fileMetadata`);let _=new Date().getTime();e.info(E.green(`Successfully pre-processed file: "${t}" in ${(_-u)/1e3}s`))}async function z({auth:t,sombraAuth:s,receiptFilepath:c,file:u,partition:d,isSilent:p=!0,dryRun:m=!1,skipWorkflowTriggers:h=!1,skipConflictUpdates:_=!1,skipExistingRecordCheck:v=!1,attributes:y=[],transcendUrl:b,forceTriggerWorkflows:S=!1}){let C=o(y),w=new A(c,f,{fileMetadata:{},failingUpdates:{},pendingUpdates:{}}),T=w.getValue(`failingUpdates`),D=w.getValue(`pendingUpdates`),O=w.getValue(`fileMetadata`);e.info(E.magenta(`Restored cache, there are:
5
- ${Object.values(T).length} failing requests to be retried\n${Object.values(D).length} pending requests to be processed\nThe following files are stored in cache and will be used:\n${Object.keys(O).map(e=>e).join(`
6
- `)}\nThe following file will be processed: ${u}\n`));let M=l(b,t),[N,P,F]=await Promise.all([r(b,t,s),i(M),a(M)]);await R({file:u,purposeSlugs:P.map(e=>e.trackingType),preferenceTopics:F,sombra:N,partitionKey:d,skipExistingRecordCheck:v,forceTriggerWorkflows:S},w);let I={};O=w.getValue(`fileMetadata`);let L=O[u];if(e.info(E.magenta(`Found ${Object.entries(L.pendingSafeUpdates).length} safe updates in ${u}`)),e.info(E.magenta(`Found ${Object.entries(L.pendingConflictUpdates).length} conflict updates in ${u}`)),e.info(E.magenta(`Found ${Object.entries(L.skippedUpdates).length} skipped updates in ${u}`)),Object.entries({...L.pendingSafeUpdates,..._?{}:x(L.pendingConflictUpdates,({row:e})=>e)}).forEach(([e,t])=>{let n=L.timestampColum===`[NONE]`?new Date:new Date(t[L.timestampColum]),r=j({row:t,columnToPurposeName:L.columnToPurposeName,preferenceTopics:F,purposeSlugs:P.map(e=>e.trackingType)});I[e]={userId:e,partition:d,timestamp:n.toISOString(),purposes:Object.entries(r).map(([e,t])=>({...t,purpose:e,workflowSettings:{attributes:C,isSilent:p,skipWorkflowTrigger:h,...S?{forceTriggerWorkflow:S}:{}}}))}}),await w.setValue(I,`pendingUpdates`),await w.setValue({},`failingUpdates`),m){e.info(E.green(`Dry run complete, exiting. ${Object.values(I).length} pending updates. Check file: ${c}`));return}e.info(E.magenta(`Uploading ${Object.values(I).length} preferences to partition: ${d}`));let z=new Date().getTime(),B=new k.SingleBar({},k.Presets.shades_classic),V=0,H=Object.entries(I),U=g(H,h?100:10);B.start(H.length,0),await n(U,async t=>{try{await N.put(`v1/preferences`,{json:{records:t.map(([,e])=>e),skipWorkflowTriggers:h}}).json()}catch(n){try{let t=JSON.parse(n?.response?.body||`{}`);t.error&&e.error(E.red(`Error: ${t.error}`))}catch{}e.error(E.red(`Failed to upload ${t.length} user preferences to partition ${d}: ${n?.response?.body||n?.message}`));let r=w.getValue(`failingUpdates`);t.forEach(([e,t])=>{r[e]={uploadedAt:new Date().toISOString(),update:t,error:n?.response?.body||n?.message||`Unknown error`}}),await w.setValue(r,`failingUpdates`)}V+=t.length,B.update(V)},{concurrency:40}),B.stop();let W=new Date().getTime()-z;e.info(E.green(`Successfully uploaded ${H.length} user preferences to partition ${d} in "${W/1e3}" seconds!`))}async function B({auth:t,partition:r,sombraAuth:i,transcendUrl:a,file:o=``,directory:c,dryRun:l,skipExistingRecordCheck:u,receiptFileDir:f,skipWorkflowTriggers:p,forceTriggerWorkflows:m,skipConflictUpdates:h,isSilent:g,attributes:_,concurrency:v}){c&&o&&(e.error(E.red(`Cannot provide both a directory and a file. Please provide only one.`)),this.process.exit(1)),!o&&!c&&(e.error(E.red(`A file or directory must be provided. Please provide one using --file=./preferences.csv or --directory=./preferences`)),this.process.exit(1)),d(this.process.exit);let y=[];if(c)try{let t=C(c).filter(e=>e.endsWith(`.csv`));t.length===0&&(e.error(E.red(`No CSV files found in directory: ${c}`)),this.process.exit(1)),y.push(...t.map(e=>T(c,e)))}catch(t){e.error(E.red(`Failed to read directory: ${c}`)),e.error(E.red(t.message)),this.process.exit(1)}else try{o.endsWith(`.csv`)||(e.error(E.red(`File must be a CSV file`)),this.process.exit(1)),y.push(o)}catch(t){e.error(E.red(`Failed to access file: ${o}`)),e.error(E.red(t.message)),this.process.exit(1)}e.info(E.green(`Processing ${y.length} consent preferences files for partition: ${r}`)),e.debug(`Files to process: ${y.join(`, `)}`),u&&e.info(E.bgYellow(`Skipping existing record check: ${u}`)),await n(y,async e=>{await z({receiptFilepath:T(f,`${w(e).replace(`.csv`,``)}-receipts.json`),auth:t,sombraAuth:i,file:e,partition:r,transcendUrl:a,skipConflictUpdates:h,skipWorkflowTriggers:p,skipExistingRecordCheck:u,isSilent:g,dryRun:l,attributes:s(_),forceTriggerWorkflows:m})},{concurrency:v})}export{B as uploadPreferences};
7
- //# sourceMappingURL=impl-DTp9OQIZ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"impl-DTp9OQIZ.mjs","names":[],"sources":["../src/lib/preference-management/getPreferenceUpdatesFromRow.ts","../src/lib/preference-management/checkIfPendingPreferenceUpdatesAreNoOp.ts","../src/lib/preference-management/checkIfPendingPreferenceUpdatesCauseConflict.ts","../src/lib/preference-management/getPreferencesForIdentifiers.ts","../src/lib/preference-management/parsePreferenceAndPurposeValuesFromCsv.ts","../src/lib/preference-management/parsePreferenceIdentifiersFromCsv.ts","../src/lib/preference-management/parsePreferenceTimestampsFromCsv.ts","../src/lib/preference-management/parsePreferenceManagementCsv.ts","../src/lib/preference-management/uploadPreferenceManagementPreferencesInteractive.ts","../src/commands/consent/upload-preferences/impl.ts"],"sourcesContent":["import { PreferenceStorePurposeResponse, PreferenceTopicType } from '@transcend-io/privacy-types';\nimport { apply } from '@transcend-io/type-utils';\n\nimport { PreferenceTopic } from '../graphql/index.js';\nimport { splitCsvToList } from '../requests/index.js';\nimport { PurposeRowMapping } from './codecs.js';\n\n/**\n * Parse an arbitrary object to the Transcend PUT /v1/preference update shape\n * by using a mapping of column names to purpose/preference slugs.\n *\n * `columnToPurposeName` looks like:\n * {\n * 'my_purpose': { purpose: 'Marketing', preference: null, valueMapping: { 'true': true, 'false': false } },\n * 'has_topic_1': { purpose: 'Marketing', preference: 'BooleanPreference1', valueMapping: { 'true': true, 'false': false } },\n * 'has_topic_2': { purpose: 'Marketing', preference: 'SingleSelectPreference', valueMapping: { 'Option 1': 'Value1', 'Option 2': 'Value2' } }\n * }\n *\n * `row` looks like:\n * {\n * 'my_purpose': 'true',\n * 'has_topic_1': 'true',\n * 'has_topic_2': 'Option 1'\n * }\n *\n * OMISSION RULE:\n * - If `valueMapping[row[columnName]]`\n * returns `undefined` or `null`, we **omit** that column entirely (do not set purpose enabled, do not push a preference).\n * - For MultiSelect, **each token** is treated independently: tokens that map to `undefined|null` are skipped;\n * if all tokens are skipped, nothing is pushed.\n * - We still validate **types** for mapped values (e.g., boolean must map to boolean, select must map to string, etc.).\n *\n * NOTE:\n * - Final shape must have `enabled` for every purpose touched (enforced by `apply` below). If you omit all top-level purpose mappings,\n * but emit preferences, this will throw at the end. This preserves the existing “enabled required” contract.\n *\n * @param options - Options\n * @returns The parsed row\n */\nexport function getPreferenceUpdatesFromRow({\n row,\n columnToPurposeName,\n purposeSlugs,\n preferenceTopics,\n}: {\n /** Row to parse */\n row: Record<string, string>;\n /** Mapping from column name to parser config */\n columnToPurposeName: Record<string, PurposeRowMapping>;\n /** The set of allowed purpose slugs */\n purposeSlugs: string[];\n /** The preference topics */\n preferenceTopics: PreferenceTopic[];\n}): {\n [k in string]: Omit<PreferenceStorePurposeResponse, 'purpose'>;\n} {\n // Create a result object to store the parsed preferences\n const result: {\n [k in string]: Partial<PreferenceStorePurposeResponse>;\n } = {};\n\n // Iterate over each column and map to the purpose or preference\n Object.entries(columnToPurposeName).forEach(\n ([columnName, { purpose, preference, valueMapping }]) => {\n // Ensure the purpose is valid\n if (!purposeSlugs.includes(purpose)) {\n throw new Error(`Invalid purpose slug: ${purpose}, expected: ${purposeSlugs.join(', ')}`);\n }\n\n // The raw value from the CSV row for this column\n const rawValue = row[columnName];\n\n // Check if parsing a preference or just the top level purpose\n if (preference) {\n const preferenceTopic = preferenceTopics.find(\n (x) => x.slug === preference && x.purpose.trackingType === purpose,\n );\n if (!preferenceTopic) {\n const allowedTopics = preferenceTopics\n .filter((x) => x.purpose.trackingType === purpose)\n .map((x) => x.slug);\n throw new Error(\n `Invalid preference slug: ${preference} for purpose: ${purpose}. ` +\n `Allowed preference slugs for purpose are: ${allowedTopics.join(',')}`,\n );\n }\n\n // Ensure destination array\n if (!result[purpose]) {\n result[purpose] = {\n preferences: [],\n };\n }\n if (!result[purpose].preferences) {\n result[purpose].preferences = [];\n }\n\n // handle each type of preference\n switch (preferenceTopic.type) {\n case PreferenceTopicType.Boolean: {\n const mappedValue = valueMapping[rawValue];\n // Throw error on missing mapping\n if (mappedValue === undefined && rawValue !== '') {\n throw new Error(\n `No preference mapping found for value \"${rawValue}\" in column ` +\n `\"${columnName}\" (purpose=${purpose}, preference=${preference})`,\n );\n }\n\n // Purposefully missing mapping\n if (mappedValue === null || mappedValue === undefined) {\n return;\n }\n\n // Ensure boolean\n if (typeof mappedValue !== 'boolean') {\n throw new Error(\n `Invalid value for boolean preference: ${preference}, expected boolean, got: ${rawValue}`,\n );\n }\n result[purpose].preferences!.push({\n topic: preference,\n choice: { booleanValue: mappedValue },\n });\n break;\n }\n\n case PreferenceTopicType.Select: {\n const mappedValue = valueMapping[rawValue];\n // Throw error on missing mapping\n if (mappedValue === undefined && rawValue !== '') {\n throw new Error(\n `No preference mapping found for value \"${rawValue}\" in column ` +\n `\"${columnName}\" (purpose=${purpose}, preference=${preference})`,\n );\n }\n\n // Omit if null\n if (mappedValue === null || mappedValue === undefined) {\n return;\n }\n\n // Ensure string\n if (typeof mappedValue !== 'string') {\n throw new Error(\n `Invalid value for select preference: ${preference}, expected string, got: ${rawValue}`,\n );\n }\n const trimmed = mappedValue.trim() || null;\n\n if (\n trimmed &&\n !preferenceTopic.preferenceOptionValues.map(({ slug }) => slug).includes(trimmed)\n ) {\n throw new Error(\n `Invalid value for select preference: ${preference}, expected one of: ` +\n `${preferenceTopic.preferenceOptionValues\n .map(({ slug }) => slug)\n .join(', ')}, got: ${rawValue}`,\n );\n }\n\n result[purpose].preferences!.push({\n topic: preference,\n choice: { selectValue: trimmed },\n });\n break;\n }\n\n case PreferenceTopicType.MultiSelect: {\n if (typeof rawValue !== 'string') {\n throw new Error(\n `Invalid value for multi select preference: ${preference}, expected string, got: ${rawValue}`,\n );\n }\n\n // IMPORTANT: Do NOT rely on valueMapping[rawValue] for CSV.\n // Split and map per token with the new rule.\n const selectValues = splitCsvToList(rawValue)\n .map((token) => {\n const tokenMapped = valueMapping[token];\n // Throw error on missing mapping\n if (tokenMapped === undefined && rawValue !== '') {\n throw new Error(\n `No preference mapping found for multi select token \"${rawValue}\" in column ` +\n `\"${columnName}\" (purpose=${purpose}, preference=${preference})`,\n );\n }\n\n // Omit if null\n if (tokenMapped === null || tokenMapped === undefined) {\n return null;\n }\n\n // Ensure string\n if (typeof tokenMapped !== 'string') {\n throw new Error(\n `Invalid value for multi select preference: ${preference}, ` +\n `expected one of: ${preferenceTopic.preferenceOptionValues\n .map(({ slug }) => slug)\n .join(', ')}, got: ${token}`,\n );\n }\n return tokenMapped;\n })\n .filter((x): x is string => x !== null)\n .sort((a, b) => a.localeCompare(b));\n\n // Only push if at least one mapped token survived\n if (selectValues.length > 0) {\n result[purpose].preferences!.push({\n topic: preference,\n choice: { selectValues },\n });\n }\n break;\n }\n\n default:\n throw new Error(`Unknown preference type: ${preferenceTopic.type}`);\n }\n } else {\n // Top-level purpose (no preference)\n const mappedValue = valueMapping[rawValue];\n if (mappedValue === undefined && rawValue !== '') {\n throw new Error(\n `No preference mapping found for value \"${rawValue}\" in column ` +\n `\"${columnName}\" (purpose=${purpose}, preference=∅) ${JSON.stringify(row)}`,\n );\n }\n if (mappedValue === null) {\n return; // Omit if null\n }\n\n if (!result[purpose]) {\n // Top-level purpose: set enabled strictly from mapped boolean\n result[purpose] = { enabled: mappedValue === true };\n } else {\n // Preserve preferences; update enabled\n result[purpose].enabled = mappedValue === true;\n }\n }\n },\n );\n\n // Ensure that enabled is provided for any purpose that appears.\n // (This preserves the prior contract and existing tests.)\n return apply(result, (x, purposeName) => {\n if (typeof x.enabled !== 'boolean') {\n throw new Error(`No mapping provided for purpose.enabled=true/false value: ${purposeName}`);\n }\n return {\n ...x,\n enabled: x.enabled!,\n };\n });\n}\n","import {\n PreferenceQueryResponseItem,\n PreferenceStorePurposeResponse,\n PreferenceTopicType,\n} from '@transcend-io/privacy-types';\n\nimport { PreferenceTopic } from '../graphql/index.js';\n\n/**\n * Check if the pending set of updates are exactly the same as the current consent record.\n *\n * @param options - Options\n * @returns Whether the pending updates already exist in the preference store\n */\nexport function checkIfPendingPreferenceUpdatesAreNoOp({\n currentConsentRecord,\n pendingUpdates,\n preferenceTopics,\n}: {\n /** The current consent record */\n currentConsentRecord: PreferenceQueryResponseItem;\n /** The pending updates */\n pendingUpdates: {\n [purposeName in string]: Omit<PreferenceStorePurposeResponse, 'purpose'>;\n };\n /** The preference topic configurations */\n preferenceTopics: PreferenceTopic[];\n}): boolean {\n // Check each update\n return Object.entries(pendingUpdates).every(([purposeName, { preferences = [], enabled }]) => {\n // Ensure the purpose exists\n const currentPurpose = currentConsentRecord.purposes.find(\n (existingPurpose) => existingPurpose.purpose === purposeName,\n );\n\n // Ensure purpose.enabled is in sync\n // Also false if the purpose does not exist\n const enabledIsInSync = !!currentPurpose && currentPurpose.enabled === enabled;\n if (!enabledIsInSync) {\n return false;\n }\n\n // Compare the preferences are in sync\n return preferences.every(\n ({ topic, choice }) =>\n // ensure preferences exist on record\n currentPurpose.preferences &&\n currentPurpose.preferences.find((existingPreference) => {\n // find matching topic\n if (existingPreference.topic !== topic) {\n return false;\n }\n\n // Determine type of preference topic\n const preferenceTopic = preferenceTopics.find(\n (x) => x.slug === topic && x.purpose.trackingType === purposeName,\n );\n if (!preferenceTopic) {\n throw new Error(`Could not find preference topic for ${topic}`);\n }\n\n // Handle comparison based on type\n switch (preferenceTopic.type) {\n case PreferenceTopicType.Boolean:\n return existingPreference.choice.booleanValue === choice.booleanValue;\n case PreferenceTopicType.Select:\n return existingPreference.choice.selectValue === choice.selectValue;\n case PreferenceTopicType.MultiSelect:\n // eslint-disable-next-line no-case-declarations\n const sortedCurrentValues = (existingPreference.choice.selectValues || []).sort();\n // eslint-disable-next-line no-case-declarations\n const sortedNewValues = (choice.selectValues || []).sort();\n return (\n sortedCurrentValues.length === sortedNewValues.length &&\n sortedCurrentValues.every((x, i) => x === sortedNewValues[i])\n );\n default:\n throw new Error(`Unknown preference topic type: ${preferenceTopic.type}`);\n }\n }),\n );\n });\n}\n","import {\n PreferenceQueryResponseItem,\n PreferenceStorePurposeResponse,\n PreferenceTopicType,\n} from '@transcend-io/privacy-types';\n\nimport { logger } from '../../logger.js';\nimport { PreferenceTopic } from '../graphql/index.js';\n\n/**\n * Check if the pending set of updates will result in a change of\n * value to an existing purpose or preference in the preference store.\n *\n * @param options - Options\n * @returns True if conflict, false if no conflict and just adding new data for first time\n */\nexport function checkIfPendingPreferenceUpdatesCauseConflict({\n currentConsentRecord,\n pendingUpdates,\n preferenceTopics,\n log,\n}: {\n /** The current consent record */\n currentConsentRecord: PreferenceQueryResponseItem;\n /** The pending updates */\n pendingUpdates: {\n [purposeName in string]: Omit<PreferenceStorePurposeResponse, 'purpose'>;\n };\n /** The preference topic configurations */\n preferenceTopics: PreferenceTopic[];\n /** Whether to log the conflict */\n log?: boolean;\n}): boolean {\n // Check if any update has conflict\n return !!Object.entries(pendingUpdates).find(([purposeName, { preferences = [], enabled }]) => {\n // Ensure the purpose exists\n const currentPurpose = currentConsentRecord.purposes.find(\n (existingPurpose) => existingPurpose.purpose === purposeName,\n );\n\n // If no purpose exists, then it is not a conflict\n if (!currentPurpose) {\n if (log) {\n logger.warn(\n `No existing purpose found for ${purposeName} in consent record for ${currentConsentRecord.userId}.`,\n );\n }\n return false;\n }\n\n // If purpose.enabled value is off, this is a conflict\n if (currentPurpose.enabled !== enabled) {\n if (log) {\n logger.warn(\n `Purpose ${purposeName} enabled value conflict for user ${currentConsentRecord.userId}. ` +\n `Pending Value: ${enabled}, Current Value: ${currentPurpose.enabled}`,\n );\n }\n return true;\n }\n\n // Check if any preferences are out of sync\n return !!preferences.find(({ topic, choice }) => {\n // find matching topic\n const currentPreference = (currentPurpose.preferences || []).find(\n (existingPreference) => existingPreference.topic === topic,\n );\n\n // if no topic exists, no conflict\n if (!currentPreference) {\n if (log) {\n logger.warn(\n `No existing preference found for topic ${topic} in purpose ` +\n `${purposeName} for user ${currentConsentRecord.userId}.`,\n );\n }\n return false;\n }\n\n // Determine type of preference topic\n const preferenceTopic = preferenceTopics.find(\n (x) => x.slug === topic && x.purpose.trackingType === purposeName,\n );\n if (!preferenceTopic) {\n throw new Error(`Could not find preference topic for ${topic}`);\n }\n\n // Handle comparison based on type\n let boolMatch: boolean;\n let selectMatch: boolean;\n switch (preferenceTopic.type) {\n case PreferenceTopicType.Boolean:\n boolMatch = currentPreference.choice.booleanValue !== choice.booleanValue;\n if (log) {\n logger.warn(\n `Preference topic ${topic} boolean value conflict for user ` +\n `${currentConsentRecord.userId}. Expected: ${choice.booleanValue}, ` +\n `Found: ${currentPreference.choice.booleanValue}`,\n );\n }\n return boolMatch;\n case PreferenceTopicType.Select:\n selectMatch = currentPreference.choice.selectValue !== choice.selectValue;\n if (log) {\n logger.warn(\n `Preference topic ${topic} select value conflict for user ` +\n `${currentConsentRecord.userId}. Expected: ${choice.selectValue}, ` +\n `Found: ${currentPreference.choice.selectValue}`,\n );\n }\n return selectMatch;\n case PreferenceTopicType.MultiSelect:\n // eslint-disable-next-line no-case-declarations\n const sortedCurrentValues = (currentPreference.choice.selectValues || []).sort();\n // eslint-disable-next-line no-case-declarations\n const sortedNewValues = (choice.selectValues || []).sort();\n selectMatch =\n sortedCurrentValues.length !== sortedNewValues.length ||\n !sortedCurrentValues.every((x, i) => x === sortedNewValues[i]);\n if (log) {\n logger.warn(\n `Preference topic ${topic} multi-select value conflict for user ` +\n `${currentConsentRecord.userId}. Expected: ${sortedNewValues.join(\n ', ',\n )}, Found: ${sortedCurrentValues.join(', ')}`,\n );\n }\n return selectMatch;\n default:\n throw new Error(`Unknown preference topic type: ${preferenceTopic.type}`);\n }\n });\n });\n}\n","import { PreferenceQueryResponseItem } from '@transcend-io/privacy-types';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport type { Got } from 'got';\nimport { chunk } from 'lodash-es';\n\nimport { logger } from '../../logger.js';\nimport { map } from '../bluebird.js';\nimport { ConsentPreferenceResponse } from './types.js';\nimport { withPreferenceRetry } from './withPreferenceRetry.js';\n\n/**\n * Grab the current consent preference values for a list of identifiers\n *\n * @param sombra - Backend to make API call to\n * @param options - Options\n * @returns Plaintext context information\n */\nexport async function getPreferencesForIdentifiers(\n sombra: Got,\n {\n identifiers,\n partitionKey,\n skipLogging = false,\n concurrency = 40,\n }: {\n /** The list of identifiers to look up */\n identifiers: {\n /** The value of the identifier */\n value: string;\n }[];\n /** The partition key to look up */\n partitionKey: string;\n /** Whether to skip logging */\n skipLogging?: boolean;\n /** Concurrency for requests (default 40) */\n concurrency?: number;\n },\n): Promise<PreferenceQueryResponseItem[]> {\n const results: PreferenceQueryResponseItem[] = [];\n const groupedIdentifiers = chunk(identifiers, 100);\n\n // create a new progress bar instance and use shades_classic theme\n const t0 = new Date().getTime();\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n if (!skipLogging) {\n progressBar.start(identifiers.length, 0);\n }\n\n let total = 0;\n await map(\n groupedIdentifiers,\n async (group) => {\n const rawResult = await withPreferenceRetry(\n 'Preference Query',\n () =>\n sombra\n .post(`v1/preferences/${partitionKey}/query`, {\n json: {\n filter: { identifiers: group },\n limit: group.length,\n },\n })\n .json(),\n {\n onRetry: (attempt, _err, msg) => {\n logger.warn(\n colors.yellow(\n `[RETRY] group size=${group.length} partition=${partitionKey} attempt=${attempt}: ${msg}`,\n ),\n );\n },\n },\n );\n\n const result = decodeCodec(ConsentPreferenceResponse, rawResult);\n results.push(...result.nodes);\n total += group.length;\n progressBar.update(total);\n },\n {\n concurrency,\n },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n if (!skipLogging) {\n // Log completion time\n logger.info(colors.green(`Completed download in \"${totalTime / 1000}\" seconds.`));\n }\n\n return results;\n}\n","import { PreferenceTopicType } from '@transcend-io/privacy-types';\nimport colors from 'colors';\nimport inquirer from 'inquirer';\nimport { uniq, difference } from 'lodash-es';\n\nimport { logger } from '../../logger.js';\nimport { mapSeries } from '../bluebird.js';\nimport { PreferenceTopic } from '../graphql/index.js';\nimport { splitCsvToList } from '../requests/index.js';\nimport { FileMetadataState } from './codecs.js';\n\n/* eslint-disable no-param-reassign */\n\n/**\n * Parse out the purpose.enabled and preference values from a CSV file\n *\n * @param preferences - List of preferences\n * @param currentState - The current file metadata state for parsing this list\n * @param options - Options\n * @returns The updated file metadata state\n */\nexport async function parsePreferenceAndPurposeValuesFromCsv(\n preferences: Record<string, string>[],\n currentState: FileMetadataState,\n {\n purposeSlugs,\n preferenceTopics,\n forceTriggerWorkflows,\n }: {\n /** The purpose slugs that are allowed to be updated */\n purposeSlugs: string[];\n /** The preference topics */\n preferenceTopics: PreferenceTopic[];\n /** Force workflow triggers */\n forceTriggerWorkflows: boolean;\n },\n): Promise<FileMetadataState> {\n // Determine columns to map\n const columnNames = uniq(preferences.map((x) => Object.keys(x)).flat());\n\n // Determine the columns that could potentially be used for identifier\n const otherColumns = difference(columnNames, [\n ...(currentState.identifierColumn ? [currentState.identifierColumn] : []),\n ...(currentState.timestampColum ? [currentState.timestampColum] : []),\n ]);\n if (otherColumns.length === 0) {\n if (forceTriggerWorkflows) {\n return currentState;\n }\n throw new Error('No other columns to process');\n }\n\n // The purpose and preferences to map to\n const purposeNames = [\n ...purposeSlugs,\n ...preferenceTopics.map((x) => `${x.purpose.trackingType}->${x.slug}`),\n ];\n\n // Ensure all columns are accounted for\n await mapSeries(otherColumns, async (col) => {\n // Determine the unique values to map in this column\n const uniqueValues = uniq(preferences.map((x) => x[col]));\n\n // Map the column to a purpose\n let purposeMapping = currentState.columnToPurposeName[col];\n if (purposeMapping) {\n logger.info(\n colors.magenta(`Column \"${col}\" is associated with purpose \"${purposeMapping.purpose}\"`),\n );\n } else {\n const { purposeName } = await inquirer.prompt<{\n /** purpose name */\n purposeName: string;\n }>([\n {\n name: 'purposeName',\n message: `Choose the purpose that column ${col} is associated with`,\n type: 'list',\n default: purposeNames.find((x) => x.startsWith(purposeSlugs[0])),\n choices: purposeNames,\n },\n ]);\n const [purposeSlug, preferenceSlug] = purposeName.split('->');\n purposeMapping = {\n purpose: purposeSlug,\n preference: preferenceSlug || null,\n valueMapping: {},\n };\n }\n\n // map each value to the purpose value\n await mapSeries(uniqueValues, async (value) => {\n if (purposeMapping.valueMapping[value] !== undefined) {\n logger.info(\n colors.magenta(\n `Value \"${value}\" is associated with purpose value \"${purposeMapping.valueMapping[value]}\"`,\n ),\n );\n return;\n }\n // if preference is null, this column is just for the purpose\n if (purposeMapping.preference === null) {\n const { purposeValue } = await inquirer.prompt<{\n /** purpose value */\n purposeValue: boolean;\n }>([\n {\n name: 'purposeValue',\n message: `Choose the purpose value for value \"${value}\" associated with purpose \"${purposeMapping.purpose}\"`,\n type: 'confirm',\n default: value !== 'false',\n },\n ]);\n purposeMapping.valueMapping[value] = purposeValue;\n }\n\n // if preference is not null, this column is for a specific preference\n if (purposeMapping.preference !== null) {\n const preferenceTopic = preferenceTopics.find((x) => x.slug === purposeMapping.preference);\n if (!preferenceTopic) {\n logger.error(colors.red(`Preference topic \"${purposeMapping.preference}\" not found`));\n return;\n }\n const preferenceOptions = preferenceTopic.preferenceOptionValues.map(({ slug }) => slug);\n\n if (preferenceTopic.type === PreferenceTopicType.Boolean) {\n const { preferenceValue } = await inquirer.prompt<{\n /** purpose value */\n preferenceValue: boolean;\n }>([\n {\n name: 'preferenceValue',\n message:\n // eslint-disable-next-line max-len\n `Choose the preference value for \"${preferenceTopic.slug}\" value \"${value}\" associated with purpose \"${purposeMapping.purpose}\"`,\n type: 'confirm',\n default: value !== 'false',\n },\n ]);\n purposeMapping.valueMapping[value] = preferenceValue;\n return;\n }\n\n if (preferenceTopic.type === PreferenceTopicType.Select) {\n const { preferenceValue } = await inquirer.prompt<{\n /** purpose value */\n preferenceValue: boolean;\n }>([\n {\n name: 'preferenceValue',\n // eslint-disable-next-line max-len\n message: `Choose the preference value for \"${preferenceTopic.slug}\" value \"${value}\" associated with purpose \"${purposeMapping.purpose}\"`,\n type: 'list',\n choices: preferenceOptions,\n default: preferenceOptions.find((x) => x === value),\n },\n ]);\n purposeMapping.valueMapping[value] = preferenceValue;\n return;\n }\n\n if (preferenceTopic.type === PreferenceTopicType.MultiSelect) {\n const parsedValues = splitCsvToList(value);\n // need to do this serially\n await mapSeries(parsedValues, async (parsedValue) => {\n // if we already have a value, skip re-processing it again\n if (purposeMapping.valueMapping[parsedValue] !== undefined) {\n return;\n }\n const { preferenceValue } = await inquirer.prompt<{\n /** purpose value */\n preferenceValue: boolean;\n }>([\n {\n name: 'preferenceValue',\n // eslint-disable-next-line max-len\n message: `Choose the preference value for \"${preferenceTopic.slug}\" value \"${parsedValue}\" associated with purpose \"${purposeMapping.purpose}\"`,\n type: 'list',\n choices: preferenceOptions,\n default: preferenceOptions.find((x) => x === parsedValue),\n },\n ]);\n purposeMapping.valueMapping[parsedValue] = preferenceValue;\n });\n return;\n }\n\n throw new Error(`Unknown preference topic type: ${preferenceTopic.type}`);\n }\n });\n\n currentState.columnToPurposeName[col] = purposeMapping;\n });\n\n return currentState;\n}\n/* eslint-enable no-param-reassign */\n","import colors from 'colors';\nimport inquirer from 'inquirer';\nimport { uniq, groupBy, difference } from 'lodash-es';\n\nimport { logger } from '../../logger.js';\nimport { inquirerConfirmBoolean } from '../helpers/index.js';\nimport { FileMetadataState } from './codecs.js';\n\n/* eslint-disable no-param-reassign */\n\n/**\n * Parse identifiers from a CSV list of preferences\n *\n * Ensures that all rows have a valid identifier\n * and that all identifiers are unique.\n *\n * @param preferences - List of preferences\n * @param currentState - The current file metadata state for parsing this list\n * @returns The updated file metadata state\n */\nexport async function parsePreferenceIdentifiersFromCsv(\n preferences: Record<string, string>[],\n currentState: FileMetadataState,\n): Promise<{\n /** The updated state */\n currentState: FileMetadataState;\n /** The updated preferences */\n preferences: Record<string, string>[];\n}> {\n // Determine columns to map\n const columnNames = uniq(preferences.map((x) => Object.keys(x)).flat());\n\n // Determine the columns that could potentially be used for identifier\n const remainingColumnsForIdentifier = difference(columnNames, [\n ...(currentState.identifierColumn ? [currentState.identifierColumn] : []),\n ...Object.keys(currentState.columnToPurposeName),\n ]);\n\n // Determine the identifier column to work off of\n if (!currentState.identifierColumn) {\n const { identifierName } = await inquirer.prompt<{\n /** Identifier name */\n identifierName: string;\n }>([\n {\n name: 'identifierName',\n message:\n 'Choose the column that will be used as the identifier to upload consent preferences by',\n type: 'list',\n default:\n remainingColumnsForIdentifier.find((col) => col.toLowerCase().includes('email')) ||\n remainingColumnsForIdentifier[0],\n choices: remainingColumnsForIdentifier,\n },\n ]);\n currentState.identifierColumn = identifierName;\n }\n logger.info(colors.magenta(`Using identifier column \"${currentState.identifierColumn}\"`));\n\n // Validate that the identifier column is present for all rows and unique\n const identifierColumnsMissing = preferences\n .map((pref, ind) => (pref[currentState.identifierColumn!] ? null : [ind]))\n .filter((x): x is number[] => !!x)\n .flat();\n if (identifierColumnsMissing.length > 0) {\n const msg = `The identifier column \"${\n currentState.identifierColumn\n }\" is missing a value for the following rows: ${identifierColumnsMissing.join(', ')}`;\n logger.warn(colors.yellow(msg));\n\n // Ask user if they would like to skip rows missing an identifier\n const skip = await inquirerConfirmBoolean({\n message: 'Would you like to skip rows missing an identifier?',\n });\n if (!skip) {\n throw new Error(msg);\n }\n\n // Filter out rows missing an identifier\n const previous = preferences.length;\n preferences = preferences.filter((pref) => pref[currentState.identifierColumn!]);\n logger.info(\n colors.yellow(`Skipped ${previous - preferences.length} rows missing an identifier`),\n );\n }\n logger.info(\n colors.magenta(\n `The identifier column \"${currentState.identifierColumn}\" is present for all rows`,\n ),\n );\n\n // Validate that all identifiers are unique\n const rowsByUserId = groupBy(preferences, currentState.identifierColumn);\n const duplicateIdentifiers = Object.entries(rowsByUserId).filter(([, rows]) => rows.length > 1);\n if (duplicateIdentifiers.length > 0) {\n const msg = `The identifier column \"${\n currentState.identifierColumn\n }\" has duplicate values for the following rows: ${duplicateIdentifiers\n .slice(0, 10)\n .map(([userId, rows]) => `${userId} (${rows.length})`)\n .join('\\n')}`;\n logger.warn(colors.yellow(msg));\n\n // Ask user if they would like to take the most recent update\n // for each duplicate identifier\n const skip = await inquirerConfirmBoolean({\n message: 'Would you like to automatically take the latest update?',\n });\n if (!skip) {\n throw new Error(msg);\n }\n preferences = Object.entries(rowsByUserId)\n .map(([, rows]) => {\n const sorted = rows.sort(\n (a, b) =>\n new Date(b[currentState.timestampColum!]).getTime() -\n new Date(a[currentState.timestampColum!]).getTime(),\n );\n return sorted[0];\n })\n .filter((x) => x);\n }\n\n return { currentState, preferences };\n}\n/* eslint-enable no-param-reassign */\n","import colors from 'colors';\nimport inquirer from 'inquirer';\nimport { uniq, difference } from 'lodash-es';\n\nimport { logger } from '../../logger.js';\nimport { FileMetadataState } from './codecs.js';\n\nexport const NONE_PREFERENCE_MAP = '[NONE]';\n\n/* eslint-disable no-param-reassign */\n\n/**\n * Parse timestamps from a CSV list of preferences\n *\n * When timestamp is requested, this script\n * ensures that all rows have a valid timestamp.\n *\n * Error is throw if timestamp is missing\n *\n * @param preferences - List of preferences\n * @param currentState - The current file metadata state for parsing this list\n * @returns The updated file metadata state\n */\nexport async function parsePreferenceTimestampsFromCsv(\n preferences: Record<string, string>[],\n currentState: FileMetadataState,\n): Promise<FileMetadataState> {\n // Determine columns to map\n const columnNames = uniq(preferences.map((x) => Object.keys(x)).flat());\n\n // Determine the columns that could potentially be used for timestamp\n const remainingColumnsForTimestamp = difference(columnNames, [\n ...(currentState.identifierColumn ? [currentState.identifierColumn] : []),\n ...Object.keys(currentState.columnToPurposeName),\n ]);\n\n // Determine the timestamp column to work off of\n if (!currentState.timestampColum) {\n const { timestampName } = await inquirer.prompt<{\n /** timestamp name */\n timestampName: string;\n }>([\n {\n name: 'timestampName',\n message: 'Choose the column that will be used as the timestamp of last preference update',\n type: 'list',\n default:\n remainingColumnsForTimestamp.find((col) => col.toLowerCase().includes('date')) ||\n remainingColumnsForTimestamp.find((col) => col.toLowerCase().includes('time')) ||\n remainingColumnsForTimestamp[0],\n choices: [...remainingColumnsForTimestamp, NONE_PREFERENCE_MAP],\n },\n ]);\n currentState.timestampColum = timestampName;\n }\n logger.info(colors.magenta(`Using timestamp column \"${currentState.timestampColum}\"`));\n\n // Validate that all rows have valid timestamp\n if (currentState.timestampColum !== NONE_PREFERENCE_MAP) {\n const timestampColumnsMissing = preferences\n .map((pref, ind) => (pref[currentState.timestampColum!] ? null : [ind]))\n .filter((x): x is number[] => !!x)\n .flat();\n if (timestampColumnsMissing.length > 0) {\n throw new Error(\n `The timestamp column \"${\n currentState.timestampColum\n }\" is missing a value for the following rows: ${timestampColumnsMissing.join('\\n')}`,\n );\n }\n logger.info(\n colors.magenta(\n `The timestamp column \"${currentState.timestampColum}\" is present for all row`,\n ),\n );\n }\n return currentState;\n}\n/* eslint-enable no-param-reassign */\n","import { PersistedState } from '@transcend-io/persisted-state';\nimport colors from 'colors';\nimport type { Got } from 'got';\nimport * as t from 'io-ts';\nimport { keyBy } from 'lodash-es';\n\nimport { logger } from '../../logger.js';\nimport { PreferenceTopic } from '../graphql/index.js';\nimport { readCsv } from '../requests/index.js';\nimport { checkIfPendingPreferenceUpdatesAreNoOp } from './checkIfPendingPreferenceUpdatesAreNoOp.js';\nimport { checkIfPendingPreferenceUpdatesCauseConflict } from './checkIfPendingPreferenceUpdatesCauseConflict.js';\nimport { FileMetadataState, PreferenceState } from './codecs.js';\nimport { getPreferencesForIdentifiers } from './getPreferencesForIdentifiers.js';\nimport { getPreferenceUpdatesFromRow } from './getPreferenceUpdatesFromRow.js';\nimport { parsePreferenceAndPurposeValuesFromCsv } from './parsePreferenceAndPurposeValuesFromCsv.js';\nimport { parsePreferenceIdentifiersFromCsv } from './parsePreferenceIdentifiersFromCsv.js';\nimport { parsePreferenceTimestampsFromCsv } from './parsePreferenceTimestampsFromCsv.js';\n\n/**\n * Parse a file into the cache\n *\n *\n * @param options - Options\n * @param cache - The cache to store the parsed file in\n * @returns The cache with the parsed file\n */\nexport async function parsePreferenceManagementCsvWithCache(\n {\n file,\n sombra,\n purposeSlugs,\n preferenceTopics,\n partitionKey,\n skipExistingRecordCheck,\n forceTriggerWorkflows,\n }: {\n /** File to parse */\n file: string;\n /** The purpose slugs that are allowed to be updated */\n purposeSlugs: string[];\n /** The preference topics */\n preferenceTopics: PreferenceTopic[];\n /** Sombra got instance */\n sombra: Got;\n /** Partition key */\n partitionKey: string;\n /** Whether to skip the check for existing records. SHOULD ONLY BE USED FOR INITIAL UPLOAD */\n skipExistingRecordCheck: boolean;\n /** Whether to force workflow triggers */\n forceTriggerWorkflows: boolean;\n },\n cache: PersistedState<typeof PreferenceState>,\n): Promise<void> {\n // Start the timer\n const t0 = new Date().getTime();\n\n // Get the current metadata\n const fileMetadata = cache.getValue('fileMetadata');\n\n // Read in the file\n logger.info(colors.magenta(`Reading in file: \"${file}\"`));\n let preferences = readCsv(file, t.record(t.string, t.string));\n\n // start building the cache, can use previous cache as well\n let currentState: FileMetadataState = {\n columnToPurposeName: {},\n pendingSafeUpdates: {},\n pendingConflictUpdates: {},\n skippedUpdates: {},\n // Load in the last fetched time\n ...((fileMetadata[file] || {}) as Partial<FileMetadataState>),\n lastFetchedAt: new Date().toISOString(),\n };\n\n // Validate that all timestamps are present in the file\n currentState = await parsePreferenceTimestampsFromCsv(preferences, currentState);\n fileMetadata[file] = currentState;\n await cache.setValue(fileMetadata, 'fileMetadata');\n\n // Validate that all identifiers are present and unique\n const result = await parsePreferenceIdentifiersFromCsv(preferences, currentState);\n currentState = result.currentState;\n preferences = result.preferences;\n fileMetadata[file] = currentState;\n await cache.setValue(fileMetadata, 'fileMetadata');\n\n // Ensure all other columns are mapped to purpose and preference\n // slug values\n currentState = await parsePreferenceAndPurposeValuesFromCsv(preferences, currentState, {\n preferenceTopics,\n purposeSlugs,\n forceTriggerWorkflows,\n });\n fileMetadata[file] = currentState;\n await cache.setValue(fileMetadata, 'fileMetadata');\n\n // Grab existing preference store records\n const identifiers = preferences.map((pref) => pref[currentState.identifierColumn!]);\n const existingConsentRecords = skipExistingRecordCheck\n ? []\n : await getPreferencesForIdentifiers(sombra, {\n identifiers: identifiers.map((x) => ({ value: x })),\n partitionKey,\n });\n const consentRecordByIdentifier = keyBy(existingConsentRecords, 'userId');\n\n // Clear out previous updates\n currentState.pendingConflictUpdates = {};\n currentState.pendingSafeUpdates = {};\n currentState.skippedUpdates = {};\n\n // Process each row\n preferences.forEach((pref) => {\n // Grab unique Id for the user\n const userId = pref[currentState.identifierColumn!];\n\n // determine updates for user\n const pendingUpdates = getPreferenceUpdatesFromRow({\n row: pref,\n columnToPurposeName: currentState.columnToPurposeName,\n preferenceTopics,\n purposeSlugs,\n });\n\n // Grab current state of the update\n const currentConsentRecord = consentRecordByIdentifier[userId];\n if (forceTriggerWorkflows && !currentConsentRecord) {\n throw new Error(\n `No existing consent record found for user with id: ${userId}.\n When 'forceTriggerWorkflows' is set all the user identifiers should contain a consent record`,\n );\n }\n // Check if the update can be skipped\n // this is the case if a record exists, and the purpose\n // and preference values are all in sync\n if (\n currentConsentRecord &&\n checkIfPendingPreferenceUpdatesAreNoOp({\n currentConsentRecord,\n pendingUpdates,\n preferenceTopics,\n }) &&\n !forceTriggerWorkflows\n ) {\n currentState.skippedUpdates[userId] = pref;\n return;\n }\n\n // Determine if there are any conflicts\n if (\n currentConsentRecord &&\n checkIfPendingPreferenceUpdatesCauseConflict({\n currentConsentRecord,\n pendingUpdates,\n preferenceTopics,\n })\n ) {\n currentState.pendingConflictUpdates[userId] = {\n row: pref,\n record: currentConsentRecord,\n };\n return;\n }\n\n // Add to pending updates\n currentState.pendingSafeUpdates[userId] = pref;\n });\n\n // Read in the file\n fileMetadata[file] = currentState;\n await cache.setValue(fileMetadata, 'fileMetadata');\n const t1 = new Date().getTime();\n logger.info(colors.green(`Successfully pre-processed file: \"${file}\" in ${(t1 - t0) / 1000}s`));\n}\n","import { PersistedState } from '@transcend-io/persisted-state';\nimport { PreferenceUpdateItem } from '@transcend-io/privacy-types';\nimport { apply } from '@transcend-io/type-utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport { chunk } from 'lodash-es';\n\nimport { logger } from '../../logger.js';\nimport { map } from '../bluebird.js';\nimport {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllPurposes,\n fetchAllPreferenceTopics,\n} from '../graphql/index.js';\nimport { parseAttributesFromString } from '../requests/index.js';\nimport { PreferenceState } from './codecs.js';\nimport { getPreferenceUpdatesFromRow } from './getPreferenceUpdatesFromRow.js';\nimport { parsePreferenceManagementCsvWithCache } from './parsePreferenceManagementCsv.js';\nimport { NONE_PREFERENCE_MAP } from './parsePreferenceTimestampsFromCsv.js';\n\n/**\n * Upload a set of consent preferences\n *\n * @param options - Options\n */\nexport async function uploadPreferenceManagementPreferencesInteractive({\n auth,\n sombraAuth,\n receiptFilepath,\n file,\n partition,\n isSilent = true,\n dryRun = false,\n skipWorkflowTriggers = false,\n skipConflictUpdates = false,\n skipExistingRecordCheck = false,\n attributes = [],\n transcendUrl,\n forceTriggerWorkflows = false,\n}: {\n /** The Transcend API key */\n auth: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Partition key */\n partition: string;\n /** File where to store receipt and continue from where left off */\n receiptFilepath: string;\n /** The file to process */\n file: string;\n /** API URL for Transcend backend */\n transcendUrl: string;\n /** Whether to do a dry run */\n dryRun?: boolean;\n /** Whether to upload as isSilent */\n isSilent?: boolean;\n /** Attributes string pre-parse. In format Key:Value */\n attributes?: string[];\n /** Skip workflow triggers */\n skipWorkflowTriggers?: boolean;\n /**\n * When true, only update preferences that do not conflict with existing\n * preferences. When false, update all preferences in CSV based on timestamp.\n */\n skipConflictUpdates?: boolean;\n /** Whether to skip the check for existing records. SHOULD ONLY BE USED FOR INITIAL UPLOAD */\n skipExistingRecordCheck?: boolean;\n /** Whether to force trigger workflows */\n forceTriggerWorkflows?: boolean;\n}): Promise<void> {\n // Parse out the extra attributes to apply to all requests uploaded\n const parsedAttributes = parseAttributesFromString(attributes);\n\n // Create a new state file to store the requests from this run\n const preferenceState = new PersistedState(receiptFilepath, PreferenceState, {\n fileMetadata: {},\n failingUpdates: {},\n pendingUpdates: {},\n });\n const failingRequests = preferenceState.getValue('failingUpdates');\n const pendingRequests = preferenceState.getValue('pendingUpdates');\n let fileMetadata = preferenceState.getValue('fileMetadata');\n\n logger.info(\n colors.magenta(\n 'Restored cache, there are: \\n' +\n `${Object.values(failingRequests).length} failing requests to be retried\\n` +\n `${Object.values(pendingRequests).length} pending requests to be processed\\n` +\n `The following files are stored in cache and will be used:\\n${Object.keys(fileMetadata)\n .map((x) => x)\n .join('\\n')}\\n` +\n `The following file will be processed: ${file}\\n`,\n ),\n );\n\n // Create GraphQL client to connect to Transcend backend\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n const [sombra, purposes, preferenceTopics] = await Promise.all([\n // Create sombra instance to communicate with\n createSombraGotInstance(transcendUrl, auth, sombraAuth),\n // get all purposes and topics\n fetchAllPurposes(client),\n fetchAllPreferenceTopics(client),\n ]);\n\n // Process the file\n await parsePreferenceManagementCsvWithCache(\n {\n file,\n purposeSlugs: purposes.map((x) => x.trackingType),\n preferenceTopics,\n sombra,\n partitionKey: partition,\n skipExistingRecordCheck,\n forceTriggerWorkflows,\n },\n preferenceState,\n );\n\n // Construct the pending updates\n const pendingUpdates: Record<string, PreferenceUpdateItem> = {};\n fileMetadata = preferenceState.getValue('fileMetadata');\n const metadata = fileMetadata[file];\n\n logger.info(\n colors.magenta(\n `Found ${Object.entries(metadata.pendingSafeUpdates).length} safe updates in ${file}`,\n ),\n );\n logger.info(\n colors.magenta(\n `Found ${Object.entries(metadata.pendingConflictUpdates).length} conflict updates in ${file}`,\n ),\n );\n logger.info(\n colors.magenta(\n `Found ${Object.entries(metadata.skippedUpdates).length} skipped updates in ${file}`,\n ),\n );\n\n // Update either safe updates only or safe + conflict\n Object.entries({\n ...metadata.pendingSafeUpdates,\n ...(skipConflictUpdates ? {} : apply(metadata.pendingConflictUpdates, ({ row }) => row)),\n }).forEach(([userId, update]) => {\n // Determine timestamp\n const timestamp =\n metadata.timestampColum === NONE_PREFERENCE_MAP\n ? new Date()\n : new Date(update[metadata.timestampColum!]);\n\n // Determine updates\n const updates = getPreferenceUpdatesFromRow({\n row: update,\n columnToPurposeName: metadata.columnToPurposeName,\n preferenceTopics,\n purposeSlugs: purposes.map((x) => x.trackingType),\n });\n pendingUpdates[userId] = {\n userId,\n partition,\n timestamp: timestamp.toISOString(),\n purposes: Object.entries(updates).map(([purpose, value]) => ({\n ...value,\n purpose,\n workflowSettings: {\n attributes: parsedAttributes,\n isSilent,\n skipWorkflowTrigger: skipWorkflowTriggers,\n ...(forceTriggerWorkflows ? { forceTriggerWorkflow: forceTriggerWorkflows } : {}),\n },\n })),\n };\n });\n await preferenceState.setValue(pendingUpdates, 'pendingUpdates');\n await preferenceState.setValue({}, 'failingUpdates');\n\n // Exist early if dry run\n if (dryRun) {\n logger.info(\n colors.green(\n `Dry run complete, exiting. ${\n Object.values(pendingUpdates).length\n } pending updates. Check file: ${receiptFilepath}`,\n ),\n );\n return;\n }\n\n logger.info(\n colors.magenta(\n `Uploading ${Object.values(pendingUpdates).length} preferences to partition: ${partition}`,\n ),\n );\n\n // Time duration\n const t0 = new Date().getTime();\n\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Build a GraphQL client\n let total = 0;\n const updatesToRun = Object.entries(pendingUpdates);\n const chunkedUpdates = chunk(updatesToRun, skipWorkflowTriggers ? 100 : 10);\n progressBar.start(updatesToRun.length, 0);\n await map(\n chunkedUpdates,\n async (currentChunk) => {\n // Make the request\n try {\n await sombra\n .put('v1/preferences', {\n json: {\n records: currentChunk.map(([, update]) => update),\n skipWorkflowTriggers,\n },\n })\n .json();\n } catch (err) {\n try {\n const parsed = JSON.parse(err?.response?.body || '{}');\n if (parsed.error) {\n logger.error(colors.red(`Error: ${parsed.error}`));\n }\n } catch (e) {\n // continue\n }\n logger.error(\n colors.red(\n `Failed to upload ${currentChunk.length} user preferences to partition ${partition}: ${\n err?.response?.body || err?.message\n }`,\n ),\n );\n const failingUpdates = preferenceState.getValue('failingUpdates');\n currentChunk.forEach(([userId, update]) => {\n failingUpdates[userId] = {\n uploadedAt: new Date().toISOString(),\n update,\n error: err?.response?.body || err?.message || 'Unknown error',\n };\n });\n await preferenceState.setValue(failingUpdates, 'failingUpdates');\n }\n\n total += currentChunk.length;\n progressBar.update(total);\n },\n {\n concurrency: 40,\n },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n logger.info(\n colors.green(\n `Successfully uploaded ${\n updatesToRun.length\n } user preferences to partition ${partition} in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n}\n","import { readdirSync } from 'node:fs';\nimport { basename, join } from 'node:path';\n\nimport colors from 'colors';\n\nimport type { LocalContext } from '../../../context.js';\nimport { map } from '../../../lib/bluebird.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { uploadPreferenceManagementPreferencesInteractive } from '../../../lib/preference-management/index.js';\nimport { splitCsvToList } from '../../../lib/requests/index.js';\nimport { logger } from '../../../logger.js';\n\nexport interface UploadPreferencesCommandFlags {\n auth: string;\n partition: string;\n sombraAuth?: string;\n transcendUrl: string;\n file?: string;\n directory?: string;\n dryRun: boolean;\n skipExistingRecordCheck: boolean;\n receiptFileDir: string;\n skipWorkflowTriggers: boolean;\n forceTriggerWorkflows: boolean;\n skipConflictUpdates: boolean;\n isSilent: boolean;\n attributes: string;\n receiptFilepath: string;\n concurrency: number;\n}\n\nexport async function uploadPreferences(\n this: LocalContext,\n {\n auth,\n partition,\n sombraAuth,\n transcendUrl,\n file = '',\n directory,\n dryRun,\n skipExistingRecordCheck,\n receiptFileDir,\n skipWorkflowTriggers,\n forceTriggerWorkflows,\n skipConflictUpdates,\n isSilent,\n attributes,\n concurrency,\n }: UploadPreferencesCommandFlags,\n): Promise<void> {\n if (!!directory && !!file) {\n logger.error(\n colors.red('Cannot provide both a directory and a file. Please provide only one.'),\n );\n this.process.exit(1);\n }\n\n if (!file && !directory) {\n logger.error(\n colors.red(\n 'A file or directory must be provided. Please provide one using --file=./preferences.csv or --directory=./preferences',\n ),\n );\n this.process.exit(1);\n }\n\n doneInputValidation(this.process.exit);\n\n const files: string[] = [];\n\n if (directory) {\n try {\n const filesInDirectory = readdirSync(directory);\n const csvFiles = filesInDirectory.filter((file) => file.endsWith('.csv'));\n\n if (csvFiles.length === 0) {\n logger.error(colors.red(`No CSV files found in directory: ${directory}`));\n this.process.exit(1);\n }\n\n // Add full paths for each CSV file\n files.push(...csvFiles.map((file) => join(directory, file)));\n } catch (err) {\n logger.error(colors.red(`Failed to read directory: ${directory}`));\n logger.error(colors.red((err as Error).message));\n this.process.exit(1);\n }\n } else {\n try {\n // Verify file exists and is a CSV\n if (!file.endsWith('.csv')) {\n logger.error(colors.red('File must be a CSV file'));\n this.process.exit(1);\n }\n files.push(file);\n } catch (err) {\n logger.error(colors.red(`Failed to access file: ${file}`));\n logger.error(colors.red((err as Error).message));\n this.process.exit(1);\n }\n }\n\n logger.info(\n colors.green(\n `Processing ${files.length} consent preferences files for partition: ${partition}`,\n ),\n );\n logger.debug(`Files to process: ${files.join(', ')}`);\n\n if (skipExistingRecordCheck) {\n logger.info(colors.bgYellow(`Skipping existing record check: ${skipExistingRecordCheck}`));\n }\n\n await map(\n files,\n async (filePath) => {\n const fileName = basename(filePath).replace('.csv', '');\n await uploadPreferenceManagementPreferencesInteractive({\n receiptFilepath: join(receiptFileDir, `${fileName}-receipts.json`),\n auth,\n sombraAuth,\n file: filePath,\n partition,\n transcendUrl,\n skipConflictUpdates,\n skipWorkflowTriggers,\n skipExistingRecordCheck,\n isSilent,\n dryRun,\n attributes: splitCsvToList(attributes),\n forceTriggerWorkflows,\n });\n },\n { concurrency },\n );\n}\n"],"mappings":"qpCAuCA,SAAgB,EAA4B,CAC1C,MACA,sBACA,eACA,oBAYA,CAEA,IAAM,EAEF,EAAE,CA4LN,OAzLA,OAAO,QAAQ,EAAoB,CAAC,SACjC,CAAC,EAAY,CAAE,UAAS,aAAY,mBAAoB,CAEvD,GAAI,CAAC,EAAa,SAAS,EAAQ,CACjC,MAAU,MAAM,yBAAyB,EAAQ,cAAc,EAAa,KAAK,KAAK,GAAG,CAI3F,IAAM,EAAW,EAAI,GAGrB,GAAI,EAAY,CACd,IAAM,EAAkB,EAAiB,KACtC,GAAM,EAAE,OAAS,GAAc,EAAE,QAAQ,eAAiB,EAC5D,CACD,GAAI,CAAC,EAAiB,CACpB,IAAM,EAAgB,EACnB,OAAQ,GAAM,EAAE,QAAQ,eAAiB,EAAQ,CACjD,IAAK,GAAM,EAAE,KAAK,CACrB,MAAU,MACR,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EAAgB,GAFvB,EAAS,EAAS,CAAC,QAAQ,OAAQ,GAAG,CAEH,gBAAgB,CAClE,OACA,aACA,KAAM,EACN,YACA,eACA,sBACA,uBACA,0BACA,WACA,SACA,WAAY,EAAe,EAAW,CACtC,wBACD,CAAC,EAEJ,CAAE,cAAa,CAChB"}
@@ -1,2 +0,0 @@
1
- import{t as e}from"./logger-B-LXIf3U.mjs";import{n as t}from"./bluebird-CUitXgsY.mjs";import{t as n}from"./updateConsentManagerVersionToLatest-C221vAAw.mjs";import{t as r}from"./validateTranscendAuth-1W1IylqE.mjs";import{t as i}from"./done-input-validation-DLR0-MJ7.mjs";import{ConsentBundleType as a}from"@transcend-io/privacy-types";import o from"colors";async function s({auth:s,bundleTypes:c=[a.Production,a.Test],deploy:l,transcendUrl:u}){i(this.process.exit);let d=await r(s);typeof d==`string`?(await n({deploy:l,transcendUrl:u,auth:d,bundleTypes:c}),e.info(o.green(`Successfully updated Consent Manager!`))):(await t(d,async t=>{e.info(o.magenta(`Updating Consent Manager for organization "${t.organizationName}"...`)),await n({deploy:l,transcendUrl:u,auth:t.apiKey,bundleTypes:c}),e.info(o.green(`Successfully updated Consent Manager for organization "${t.organizationName}"!`))}),e.info(o.green(`Successfully updated Consent Managers!`)))}export{s as updateConsentManager};
2
- //# sourceMappingURL=impl-DhscnXSw.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"impl-DhscnXSw.mjs","names":[],"sources":["../src/commands/consent/update-consent-manager/impl.ts"],"sourcesContent":["import { ConsentBundleType } from '@transcend-io/privacy-types';\nimport colors from 'colors';\n\nimport type { LocalContext } from '../../../context.js';\nimport { validateTranscendAuth } from '../../../lib/api-keys/index.js';\nimport { mapSeries } from '../../../lib/bluebird.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { updateConsentManagerVersionToLatest } from '../../../lib/consent-manager/index.js';\nimport { logger } from '../../../logger.js';\n\nexport interface UpdateConsentManagerCommandFlags {\n auth: string;\n bundleTypes: ConsentBundleType[];\n deploy: boolean;\n transcendUrl: string;\n}\n\nexport async function updateConsentManager(\n this: LocalContext,\n {\n auth,\n bundleTypes = [ConsentBundleType.Production, ConsentBundleType.Test],\n deploy,\n transcendUrl,\n }: UpdateConsentManagerCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n // Parse authentication as API key or path to list of API keys\n const apiKeyOrList = await validateTranscendAuth(auth);\n\n // Handle single update\n if (typeof apiKeyOrList === 'string') {\n // Update consent manager\n await updateConsentManagerVersionToLatest({\n deploy,\n transcendUrl,\n auth: apiKeyOrList,\n bundleTypes,\n });\n logger.info(colors.green('Successfully updated Consent Manager!'));\n } else {\n await mapSeries(apiKeyOrList, async (apiKey) => {\n logger.info(\n colors.magenta(`Updating Consent Manager for organization \"${apiKey.organizationName}\"...`),\n );\n\n await updateConsentManagerVersionToLatest({\n deploy,\n transcendUrl,\n auth: apiKey.apiKey,\n bundleTypes,\n });\n\n logger.info(\n colors.green(\n `Successfully updated Consent Manager for organization \"${apiKey.organizationName}\"!`,\n ),\n );\n });\n logger.info(colors.green('Successfully updated Consent Managers!'));\n }\n}\n"],"mappings":"qWAiBA,eAAsB,EAEpB,CACE,OACA,cAAc,CAAC,EAAkB,WAAY,EAAkB,KAAK,CACpE,SACA,gBAEa,CACf,EAAoB,KAAK,QAAQ,KAAK,CAGtC,IAAM,EAAe,MAAM,EAAsB,EAAK,CAGlD,OAAO,GAAiB,UAE1B,MAAM,EAAoC,CACxC,SACA,eACA,KAAM,EACN,cACD,CAAC,CACF,EAAO,KAAK,EAAO,MAAM,wCAAwC,CAAC,GAElE,MAAM,EAAU,EAAc,KAAO,IAAW,CAC9C,EAAO,KACL,EAAO,QAAQ,8CAA8C,EAAO,iBAAiB,MAAM,CAC5F,CAED,MAAM,EAAoC,CACxC,SACA,eACA,KAAM,EAAO,OACb,cACD,CAAC,CAEF,EAAO,KACL,EAAO,MACL,0DAA0D,EAAO,iBAAiB,IACnF,CACF,EACD,CACF,EAAO,KAAK,EAAO,MAAM,yCAAyC,CAAC"}
@@ -1,2 +0,0 @@
1
- import{t as e}from"./logger-B-LXIf3U.mjs";import{t}from"./extractErrorMessage-CPnTsT1S.mjs";import{n,t as r}from"./parquetToCsvOneFile-DZVKXrjn.mjs";import{t as i}from"./done-input-validation-DLR0-MJ7.mjs";import{a,i as o,n as s,o as c,r as l,s as u,t as d}from"./createExtraKeyHandler-tubeaEjA.mjs";import f from"colors";function p(e){return l(e)}function m(e){return o(e)}const h={renderHeader:p,renderWorkers:m};async function g(){let n=Number(process.env.WORKER_ID||`0`);e.info(`[w${n}] ready pid=${process.pid}`),process.send?.({type:`ready`}),process.on(`message`,async i=>{if(!i||typeof i!=`object`||(i.type===`shutdown`&&process.exit(0),i.type!==`task`))return;let{filePath:a,options:o}=i.payload,{outputDir:s,clearOutputDir:c}=o;try{e.info(`[w${n}] processing ${a}`);let{DuckDBInstance:t}=await import(`@duckdb/node-api`);await r({filePath:a,outputDir:s,clearOutputDir:c,onProgress:(e,t)=>process.send?.({type:`progress`,payload:{filePath:a,processed:e,total:t}})},t),process.send?.({type:`result`,payload:{ok:!0,filePath:a}})}catch(r){let i=t(r);e.error(`[w${n}] ERROR ${a}: ${r.stack||i}`),process.send?.({type:`result`,payload:{ok:!1,filePath:a,error:i}})}}),await new Promise(()=>{})}function _(){return typeof __filename<`u`?__filename:process.argv[1]}async function v(t){i(this.process.exit);let{directory:r,outputDir:o,clearOutputDir:l,concurrency:p,viewerMode:m}=t,g=n(r,this),{poolSize:v,cpuCount:y}=u(p,g.length);e.info(f.green(`Converting ${g.length} Parquet file(s) → CSV with pool size ${v} (CPU=${y})`));let b=g.map(e=>({filePath:e,options:{outputDir:o,clearOutputDir:l}}));await s({title:`Parquet → CSV - ${r}`,baseDir:r||o||process.cwd(),childFlag:c,childModulePath:_(),poolSize:v,cpuCount:y,filesTotal:g.length,hooks:{nextTask:()=>b.shift(),taskLabel:e=>e.filePath,initTotals:()=>({}),initSlotProgress:()=>void 0,onProgress:e=>e,onResult:(e,t)=>({totals:e,ok:!!t.ok}),postProcess:async()=>{}},viewerMode:m,render:e=>a(e,h,m),extraKeyHandler:({logsBySlot:e,repaint:t,setPaused:n})=>d({logsBySlot:e,repaint:t,setPaused:n})})}process.argv.includes(`--as-child`)&&g().catch(t=>{e.error(t),process.exit(1)});export{v as parquetToCsv};
2
- //# sourceMappingURL=impl-Dk7MdX-1.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"impl-Dk7MdX-1.mjs","names":[],"sources":["../src/commands/admin/parquet-to-csv/ui/plugin.ts","../src/commands/admin/parquet-to-csv/worker.ts","../src/commands/admin/parquet-to-csv/impl.ts"],"sourcesContent":["import {\n makeHeader,\n makeWorkerRows,\n type ChunkSlotProgress,\n type CommonCtx,\n type DashboardPlugin,\n} from '../../../../lib/pooling/index.js';\n\n/**\n * Header for parquet-to-csv (no extra totals block).\n *\n * @param ctx - Dashboard context.\n * @returns Header lines.\n */\nfunction renderHeader<TTotals>(ctx: CommonCtx<TTotals, ChunkSlotProgress>): string[] {\n // no extra lines — reuse the shared header as-is\n return makeHeader(ctx);\n}\n\n/**\n * Worker rows for parquet-to-csv — share the generic row renderer.\n *\n * @param ctx - Dashboard context.\n * @returns Array of strings, each representing one worker row.\n */\nfunction renderWorkers<TTotals>(ctx: CommonCtx<TTotals, ChunkSlotProgress>): string[] {\n return makeWorkerRows(ctx);\n}\n\nexport const parquetToCsvPlugin: DashboardPlugin<unknown, ChunkSlotProgress> = {\n renderHeader,\n renderWorkers,\n // no extras\n};\n","import { parquetToCsvOneFile, extractErrorMessage } from '../../../lib/helpers/index.js';\nimport type { ToWorker } from '../../../lib/pooling/index.js';\nimport { logger } from '../../../logger.js';\n\nexport type ParquetTask = {\n /** Absolute path of the Parquet file to convert. */\n filePath: string;\n options: {\n /** Optional directory where CSV output files should be written. */\n outputDir?: string;\n /** Whether to clear any pre-existing output before writing new ones. */\n clearOutputDir: boolean;\n };\n};\n\nexport type ParquetProgress = {\n /** File being processed by the worker. */\n filePath: string;\n /** Rows processed so far. */\n processed: number;\n /** Optional known total rows (not always available). */\n total?: number;\n};\n\nexport type ParquetResult = {\n ok: boolean;\n filePath: string;\n error?: string;\n};\n\n/**\n * Worker loop: convert a single Parquet file to one or more CSV files.\n */\nexport async function runChild(): Promise<void> {\n const workerId = Number(process.env.WORKER_ID || '0');\n logger.info(`[w${workerId}] ready pid=${process.pid}`);\n process.send?.({ type: 'ready' });\n\n process.on('message', async (msg: ToWorker<ParquetTask>) => {\n if (!msg || typeof msg !== 'object') return;\n\n if (msg.type === 'shutdown') {\n process.exit(0);\n }\n if (msg.type !== 'task') return;\n\n const { filePath, options } = msg.payload;\n const { outputDir, clearOutputDir } = options;\n\n try {\n logger.info(`[w${workerId}] processing ${filePath}`);\n const { DuckDBInstance } = await import('@duckdb/node-api');\n await parquetToCsvOneFile(\n {\n filePath,\n outputDir,\n clearOutputDir,\n onProgress: (processed, total) =>\n process.send?.({\n type: 'progress',\n payload: { filePath, processed, total },\n }),\n },\n DuckDBInstance,\n );\n\n process.send?.({\n type: 'result',\n payload: { ok: true, filePath },\n });\n } catch (err) {\n const message = extractErrorMessage(err);\n logger.error(`[w${workerId}] ERROR ${filePath}: ${err.stack || message}`);\n process.send?.({\n type: 'result',\n payload: { ok: false, filePath, error: message },\n });\n }\n });\n\n // keep alive until shutdown\n await new Promise<never>(() => {\n // Do nothing\n });\n}\n","import colors from 'colors';\n\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { collectParquetFilesOrExit } from '../../../lib/helpers/index.js';\nimport {\n computePoolSize,\n createExtraKeyHandler,\n CHILD_FLAG,\n type PoolHooks,\n runPool,\n dashboardPlugin,\n} from '../../../lib/pooling/index.js';\nimport { logger } from '../../../logger.js';\nimport { parquetToCsvPlugin } from './ui/index.js';\nimport { runChild, type ParquetProgress, type ParquetResult, type ParquetTask } from './worker.js';\n\n/**\n * Returns the current module's path so the worker pool knows what file to re-exec.\n * In Node ESM, __filename is undefined, so we fall back to argv[1].\n *\n * @returns The current module's path.\n */\nfunction getCurrentModulePath(): string {\n if (typeof __filename !== 'undefined') {\n return __filename as unknown as string;\n }\n return process.argv[1];\n}\n\n/** No custom totals for the header; the runner’s built-ins suffice. */\ntype Totals = Record<string, never>;\n\nexport type ParquetToCsvCommandFlags = {\n directory: string;\n outputDir?: string;\n clearOutputDir: boolean;\n concurrency?: number;\n viewerMode: boolean;\n};\n\n/**\n * Convert all Parquet files in a directory to CSV, in parallel.\n *\n * @param flags - The command flags.\n */\nexport async function parquetToCsv(\n this: LocalContext,\n flags: ParquetToCsvCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n const { directory, outputDir, clearOutputDir, concurrency, viewerMode } = flags;\n\n /* 1) Discover .parquet inputs */\n const files = collectParquetFilesOrExit(directory, this);\n\n /* 2) Size the pool */\n const { poolSize, cpuCount } = computePoolSize(concurrency, files.length);\n\n logger.info(\n colors.green(\n `Converting ${files.length} Parquet file(s) → CSV with pool size ${poolSize} (CPU=${cpuCount})`,\n ),\n );\n\n /* 3) Build FIFO queue of tasks (one per file) */\n const queue = files.map<ParquetTask>((filePath) => ({\n filePath,\n options: { outputDir, clearOutputDir },\n }));\n\n /* 4) Pool hooks */\n const hooks: PoolHooks<ParquetTask, ParquetProgress, ParquetResult, Totals> = {\n nextTask: () => queue.shift(),\n taskLabel: (t) => t.filePath,\n initTotals: () => ({}) as Totals,\n initSlotProgress: () => undefined,\n onProgress: (totals) => totals,\n onResult: (totals, res) => ({ totals, ok: !!res.ok }),\n postProcess: async () => {\n // nothing special post-run\n },\n };\n\n /* 5) Launch the pool runner with custom dashboard plugin */\n await runPool({\n title: `Parquet → CSV - ${directory}`,\n baseDir: directory || outputDir || process.cwd(),\n childFlag: CHILD_FLAG,\n childModulePath: getCurrentModulePath(),\n poolSize,\n cpuCount,\n filesTotal: files.length,\n hooks,\n viewerMode,\n render: (input) => dashboardPlugin(input, parquetToCsvPlugin, viewerMode),\n extraKeyHandler: ({ logsBySlot, repaint, setPaused }) =>\n createExtraKeyHandler({ logsBySlot, repaint, setPaused }),\n });\n}\n\n/* -------------------------------------------------------------------------------------------------\n * If invoked directly as a child process, enter worker loop\n * ------------------------------------------------------------------------------------------------- */\nif (process.argv.includes(CHILD_FLAG)) {\n runChild().catch((err) => {\n logger.error(err);\n process.exit(1);\n });\n}\n"],"mappings":"kUAcA,SAAS,EAAsB,EAAsD,CAEnF,OAAO,EAAW,EAAI,CASxB,SAAS,EAAuB,EAAsD,CACpF,OAAO,EAAe,EAAI,CAG5B,MAAa,EAAkE,CAC7E,eACA,gBAED,CCAD,eAAsB,GAA0B,CAC9C,IAAM,EAAW,OAAO,QAAQ,IAAI,WAAa,IAAI,CACrD,EAAO,KAAK,KAAK,EAAS,cAAc,QAAQ,MAAM,CACtD,QAAQ,OAAO,CAAE,KAAM,QAAS,CAAC,CAEjC,QAAQ,GAAG,UAAW,KAAO,IAA+B,CAM1D,GALI,CAAC,GAAO,OAAO,GAAQ,WAEvB,EAAI,OAAS,YACf,QAAQ,KAAK,EAAE,CAEb,EAAI,OAAS,QAAQ,OAEzB,GAAM,CAAE,WAAU,WAAY,EAAI,QAC5B,CAAE,YAAW,kBAAmB,EAEtC,GAAI,CACF,EAAO,KAAK,KAAK,EAAS,eAAe,IAAW,CACpD,GAAM,CAAE,kBAAmB,MAAM,OAAO,oBACxC,MAAM,EACJ,CACE,WACA,YACA,iBACA,YAAa,EAAW,IACtB,QAAQ,OAAO,CACb,KAAM,WACN,QAAS,CAAE,WAAU,YAAW,QAAO,CACxC,CAAC,CACL,CACD,EACD,CAED,QAAQ,OAAO,CACb,KAAM,SACN,QAAS,CAAE,GAAI,GAAM,WAAU,CAChC,CAAC,OACK,EAAK,CACZ,IAAM,EAAU,EAAoB,EAAI,CACxC,EAAO,MAAM,KAAK,EAAS,UAAU,EAAS,IAAI,EAAI,OAAS,IAAU,CACzE,QAAQ,OAAO,CACb,KAAM,SACN,QAAS,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}from"./fetchIdentifiers-pjQV4vUg.mjs";import{t as r}from"./createSombraGotInstance-D1Il9zUE.mjs";import{r as i}from"./makeGraphQLRequest-Cq26A_Lq.mjs";import{t as a}from"./fetchAllPurposesAndPreferences-DD6OyA5t.mjs";import{c as o,i as s,n as c,o as l,t as u}from"./time-Bl_c3W8U.mjs";import{r as d,t as f}from"./writeCsv-B51ulrVl.mjs";import{t as p}from"./done-input-validation-DLR0-MJ7.mjs";import{t as m}from"./types-B4CVJCpj.mjs";import{t as h}from"./withPreferenceRetry-xLMZyTq9.mjs";import{decodeCodec as g}from"@transcend-io/type-utils";import _ from"colors";import v from"cli-progress";function y({identifiers:e=[],purposes:t=[],metadata:n=[],consentManagement:r={},system:i={decryptionStatus:`DECRYPTED`},...a},o){let s={...a,...i,...r};if(Array.isArray(e)){let t=new Map;for(let{name:n,value:r}of e)t.has(n)||t.set(n,new Set),r&&t.get(n).add(r);for(let[e,n]of t.entries())s[e]=Array.from(n).join(o)}if(Array.isArray(n)&&(s.metadata=JSON.stringify(n.reduce((e,{key:t,value:n})=>(e[t]=n,e),{}))),Array.isArray(t)){for(let{purpose:e,preferences:n,enabled:r}of t)if(s[e]=!!r,Array.isArray(n))for(let{topic:t,choice:r}of n){let n=`${e}_${t}`,i=null;i=typeof r.booleanValue==`boolean`?r.booleanValue:r.selectValue?r.selectValue:Array.isArray(r.selectValues)?r.selectValues.filter(e=>e.length>0).join(`,`):null,s[n]=i}}return s}function b(e,t,n,r=5e3){let i=Math.max(0,n.getTime()-t.getTime());if(i===0)return[];let a=new Date(Math.floor(t.getTime()/c)*c),o=Math.ceil(i/Math.max(1,r)),s=Math.max(c,o),l=Math.ceil((n.getTime()-a.getTime())/s),u=[];for(let t=0;t<l;t+=1){let r=a.getTime()+t*s,i=Math.min(n.getTime(),r+s)-1,o=Math.max(r,i),c=new Date(r).toISOString(),l=new Date(o).toISOString();e===`timestamp`?u.push({timestampAfter:c,timestampBefore:l}):u.push({system:{updatedAfter:c,updatedBefore:l}})}return u}function x(e,t){return e===`timestamp`?new Date(t.timestamp):t.system?.updatedAt?new Date(t.system.updatedAt):new Date}async function*S(t,n,r,i){let a;for(;;){let o={limit:i};r&&Object.keys(r).length&&(o.filter=r),a&&(o.cursor=a);let{nodes:s,cursor:c}=g(m,await h(`Preference Query`,()=>t.post(`v1/preferences/${n}/query`,{json:o}).json(),{onRetry:(t,n,r)=>{e.warn(_.yellow(`Retry attempt ${t} for iterateConsentPages due to error: ${r}`))}}));if(!s?.length||(yield s,!c))break;a=c}}function C(e){return e.timestampAfter||e.timestampBefore?`timestamp`:`updated`}function w(e,t){if(e===`timestamp`)return{after:t.timestampAfter?new Date(t.timestampAfter):void 0,before:t.timestampBefore?new Date(t.timestampBefore):void 0};let n=t.system??{};return{after:n.updatedAfter?new Date(n.updatedAfter):void 0,before:n.updatedBefore?new Date(n.updatedBefore):void 0}}function T(e,t,n){return e===`timestamp`?{...t,timestampBefore:n??t.timestampBefore}:{...t,system:{...t.system||{},...n?{updatedBefore:n}:{}},timestampAfter:void 0,timestampBefore:void 0}}async function E(t,n,r){e.info(_.magenta(`Single-record probe with filter: ${JSON.stringify(r)}`));let i=await S(t,n,r,1).next();if(i.done||!i.value||i.value.length===0)return e.info(_.yellow(`Probe result: no record`)),null;let a=i.value[0];return e.info(_.green(`Probe result: found record at ${x(C(r),a).toISOString()}`)),a}async function D(t,n){let{partition:r,mode:i,baseFilter:a,maxLookbackDays:s=3650}=n,c=await E(t,r,T(i,a));if(!c)return e.info(_.yellow(`No records found; defaulting earliest day to today.`)),o(new Date);let l=x(i,c);e.info(_.green(`Newest instant: ${l.toISOString()}`));let d=[1,7,30],f=0,p=d[0]*u,m=l,h=null;for(;;){let n=f<d.length?new Date(l.getTime()-d[f]*u):new Date(l.getTime()-p);if((o(new Date).getTime()-o(n).getTime())/864e5>s){e.warn(_.yellow(`Exponential jump exceeded maxLookbackDays=${s}. Using current bounds.`)),h=n;break}e.info(_.magenta(`Probing before=${n.toISOString()} (jump step ${f<d.length?`${d[f]}d`:`${Math.round(p/u)}d`})…`));let c=await E(t,r,T(i,a,n.toISOString()));if(c){m=x(i,c),e.info(_.green(`Found older record at ${m.toISOString()} — continue jumping back.`)),f<d.length-1?(f+=1,p=d[f]*u):f===d.length-1?(f+=1,p=d[d.length-1]*2*u):p*=2;continue}h=n,e.info(_.green(`No record before ${n.toISOString()} — established empty lower bound.`));break}h||=new Date(m.getTime()-u);let g=h,v=m,y=Math.max(u,Math.floor((v.getTime()-g.getTime())/64));e.info(_.magenta(`Exponential forward-from-empty start: empty=${g.toISOString()} found=${v.toISOString()} step=${Math.round(y/u)}d`));for(let n=0;n<8;n+=1){let n=new Date(g.getTime()+y);if(n.getTime()>=v.getTime())break;e.info(_.magenta(`Forward gallop probe before=${n.toISOString()}…`));let o=await E(t,r,T(i,a,n.toISOString()));if(o?(v=x(i,o),e.info(_.green(`Gallop hit at ${v.toISOString()} — tightening found bound. Next step halves.`)),y=Math.max(u,Math.floor(y/2))):(g.setTime(n.getTime()),e.info(_.yellow(`Gallop miss — advancing empty bound to ${g.toISOString()}. Next step doubles.`)),y=Math.min(v.getTime()-g.getTime(),y*2),y<864e5&&(y=u)),v.getTime()-g.getTime()<=864e5)break}for(;v.getTime()-g.getTime()>u;){let n=new Date(g.getTime()+Math.floor((v.getTime()-g.getTime())/2));e.info(_.magenta(`Binary probe before=${n.toISOString()}…`));let o=await E(t,r,T(i,a,n.toISOString()));if(o){let t=x(i,o);e.info(_.green(`Binary probe found record at ${t.toISOString()}.`)),v=t}else e.info(_.yellow(`Binary probe found no record.`)),g=n}let b=o(v);return e.info(_.green(`Earliest day (UTC) resolved to ${b.toISOString()} (instant ≈ ${v.toISOString()}).`)),b}async function O(t,n){let{partition:r,mode:i,baseFilter:a}=n;e.info(_.magenta(`Latest-day discovery: probing newest record…`));let s=await E(t,r,T(i,a));if(!s)return e.info(_.yellow(`No records found at all; defaulting latest day to today.`)),o(new Date);let c=x(i,s);e.info(_.green(`Newest record instant is ${c.toISOString()}.`));let l=o(c);return e.info(_.green(`Latest day (UTC) resolved to ${l.toISOString()} from instant ${c.toISOString()}.`)),l}function k(e,t,n){return e===`timestamp`?{...t,timestampAfter:n.timestampAfter??t.timestampAfter,timestampBefore:n.timestampBefore??t.timestampBefore,system:void 0}:{...t,system:{...t.system||{},...n.system?.updatedAfter?{updatedAfter:n.system.updatedAfter}:{},...n.system?.updatedBefore?{updatedBefore:n.system.updatedBefore}:{}},timestampAfter:void 0,timestampBefore:void 0}}async function A(n,{partition:r,filterBy:i={},limit:a=50,windowConcurrency:o=25,maxChunks:c=5e3,maxLookbackDays:u=3650,onItems:d}){let f=C(i);e.info(_.magenta(`Fetching consent preferences in chunks by ${f===`timestamp`?`timestamp`:`system.updatedAt`}...`));let{after:p,before:m}=w(f,i);if(e.info(_.magenta(`Initial bounds: after=${p?.toISOString()??`undefined`} before=${m?.toISOString()??`undefined`}`)),(!p||!m)&&(p||(e.info(_.magenta(`Discovering earliest day with data for partition ${r}...`)),p=await D(n,{partition:r,mode:f,baseFilter:i,maxLookbackDays:u}),e.info(_.green(`Discovered earliest day with data: ${p.toISOString()}`))),!m)){e.info(_.magenta(`Discovering latest day with data for partition ${r}...`));let t=await O(n,{partition:r,mode:f,baseFilter:i,earliest:p});m=s(t,1),e.info(_.green(`Discovered latest day with data: ${t.toISOString()}`))}e.info(_.green(`Final bounds (UTC): after=${p.toISOString()} before=${m.toISOString()}`));let h=b(f,p,m,c);e.info(_.magenta(`Fetching consent preferences from partition ${r} in ${h.length} chunks...`));let g=new v.SingleBar({format:`Downloading [{bar}] {percentage}% | chunks {value}/{total} | fetched {fetched}`},v.Presets.shades_classic),y=0,x=0;g.start(h.length,0,{fetched:x});let T=Date.now(),E=l(a),A=[];return await t(h.map((e,t)=>({windowFilter:e,idx:t})),async({windowFilter:e})=>{let t=k(f,i,e);for await(let e of S(n,r,t,E))x+=e.length,g.update(y,{fetched:x}),d?await d(e):A.push(...e);y+=1,g.update(y,{fetched:x})},{concurrency:Math.max(1,o)}),g.update(y,{fetched:x}),g.stop(),e.info(_.green(`Fetched ${x} consent preference records from partition ${r} in ${(Date.now()-T)/1e3}s.`)),d?[]:A}async function j(t,{partition:n,filterBy:r={},limit:i=50,onItems:a}){let o=[],s,c=r&&(Object.keys(r).length>0||r.system&&Object.keys(r.system).length>0),l=Math.max(1,Math.min(50,i??50));for(;;){let i={limit:l};c&&(i.filter=r),s&&(i.cursor=s);let{nodes:u,cursor:d}=g(m,await h(`Preference Query`,()=>t.post(`v1/preferences/${n}/query`,{json:i}).json(),{onRetry:(t,n,r)=>{e.warn(_.yellow(`Retry attempt ${t} for fetchConsentPreferences due to error: ${r}`))}}));if(!u||u.length===0||(a?await a(u):o.push(...u),!d))break;s=d}return a?[]:o}const M=[`userId`,`timestamp`,`partition`,`decryptionStatus`,`updatedAt`,`usp`,`gpp`,`tcf`,`airgapVersion`,`metadata`,`metadataTimestamp`];async function N({auth:t,partition:o,sombraAuth:s,file:c,transcendUrl:l,timestampBefore:u,timestampAfter:m,updatedBefore:h,updatedAfter:g,identifiers:v=[],concurrency:b,shouldChunk:x,windowConcurrency:S,maxChunks:C,exportIdentifiersWithDelimiter:w,maxLookbackDays:T}){p(this.process.exit);let E=await r(l,t,s),D=i(l,t),O=v.map(e=>{if(!e.includes(`:`))return{name:`email`,value:e};let[t,n]=e.split(`:`);return{name:t,value:n}}),k={...u?{timestampBefore:u.toISOString()}:{},...m?{timestampAfter:m.toISOString()}:{},...g||h?{system:{...h?{updatedBefore:h.toISOString()}:{},...g?{updatedAfter:g.toISOString()}:{}}}:{},...O.length>0?{identifiers:O}:{}};e.info(`Fetching consent preferences from partition ${o}, using mode=${x?`chunked-stream`:`paged-stream`}...`),e.info(_.magenta(`Preparing CSV at: ${c}`));let[N,P]=await Promise.all([a(D),n(D)]),F=P.map(e=>e.name),I=Array.from(new Set(N.flatMap(e=>e.topics?.map(t=>`${e.trackingType}_${t.slug}`)??[]))).sort((e,t)=>e.localeCompare(t)),L=Array.from(new Set(N.map(e=>e.trackingType))).sort((e,t)=>e.localeCompare(t)),R=[...M,...F,...L,...I],z=null,B=!1,V=e=>{if(!e||e.length===0)return;let t=e.map(e=>y(e,w));if(!B){let e=Object.keys(t[0]??{}),n=new Set;z=[...R,...e].filter(e=>e===void 0||n.has(e)?!1:(n.add(e),!0)),d(c,z),B=!0}f(c,t,z)};if(x){await A(E,{partition:o,filterBy:k,limit:b,windowConcurrency:S,maxChunks:C,maxLookbackDays:T,onItems:e=>V(e)}),e.info(_.green(`Finished writing CSV to ${c}`));return}await j(E,{partition:o,filterBy:k,limit:b,onItems:e=>V(e)}),e.info(_.green(`Finished writing CSV to ${c}`))}export{N as pullConsentPreferences};
2
- //# sourceMappingURL=impl-DsNPvet4.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"impl-DsNPvet4.mjs","names":["pmap"],"sources":["../src/lib/preference-management/transformPreferenceRecordToCsv.ts","../src/lib/preference-management/buildConsentChunks.ts","../src/lib/preference-management/getComparisonTimeForRecord.ts","../src/lib/preference-management/iterateConsentPages.ts","../src/lib/preference-management/pickConsentChunkMode.ts","../src/lib/preference-management/discoverConsentWindow.ts","../src/lib/preference-management/fetchConsentPreferencesChunked.ts","../src/lib/preference-management/fetchConsentPreferences.ts","../src/commands/consent/pull-consent-preferences/impl.ts"],"sourcesContent":["import type { PreferenceQueryResponseItem } from '@transcend-io/privacy-types';\n\n/**\n * Transforms the output of the consent preferences query into a CSV-friendly format.\n *\n * @param input - The input object containing consent preferences data.\n * @param exportIdentifiersWithDelimiter - Delimiter to use when combining multiple identifier values.\n * @returns A record representing the transformed CSV output.\n */\nexport function transformPreferenceRecordToCsv(\n {\n identifiers = [],\n purposes = [],\n metadata = [],\n consentManagement = {},\n system = {\n decryptionStatus: 'DECRYPTED',\n },\n // keep other top-level fields as-is (e.g., partition, timestamp, metadataTimestamp)\n ...topLevel\n }: PreferenceQueryResponseItem,\n exportIdentifiersWithDelimiter: string,\n): Record<string, unknown> {\n // Start with: all other top-level fields + spread system and consentManagement\n const out: Record<string, unknown> = {\n ...topLevel,\n ...system,\n ...consentManagement,\n };\n\n // ── identifiers: each identifier.name -> CSV of values\n if (Array.isArray(identifiers)) {\n const byName = new Map<string, Set<string>>();\n for (const { name, value } of identifiers) {\n if (!byName.has(name)) byName.set(name, new Set());\n if (value) byName.get(name)!.add(value);\n }\n for (const [name, set] of byName.entries()) {\n out[name] = Array.from(set).join(exportIdentifiersWithDelimiter);\n }\n }\n\n // ── metadata: serialize as JSON\n if (Array.isArray(metadata)) {\n out.metadata = JSON.stringify(\n metadata.reduce(\n (acc, { key, value }) => {\n acc[key] = value;\n return acc;\n },\n {} as Record<string, string>,\n ),\n );\n }\n\n // ── purposes:\n // - purpose.slug column => true/false (enabled)\n // - for each preference: purpose.slug_preference.slug => bool | single | CSV (multi)\n if (Array.isArray(purposes)) {\n for (const { purpose, preferences, enabled } of purposes) {\n out[purpose] = Boolean(enabled);\n\n // nested preferences\n if (Array.isArray(preferences)) {\n for (const { topic, choice } of preferences) {\n const col = `${purpose}_${topic}`;\n\n let val: unknown = null;\n\n if (typeof choice.booleanValue === 'boolean') {\n val = choice.booleanValue;\n } else if (choice.selectValue) {\n val = choice.selectValue;\n } else if (Array.isArray(choice.selectValues)) {\n const vs = choice.selectValues.filter((v) => v.length > 0);\n val = vs.join(',');\n } else {\n // no pref value present -> null\n val = null;\n }\n\n out[col] = val;\n }\n }\n }\n }\n\n return out;\n}\n","import { FIVE_MIN_MS } from '../helpers/index.js';\nimport type { ChunkMode, PreferencesQueryFilter } from './types.js';\n\n/**\n * Build chunk windows by splitting [lower, upperExclusive) into up to `maxChunks`\n * equal-sized ranges, with a minimum chunk span of 5 minutes. Boundaries are snapped\n * once at the start to the nearest 5-minute boundary for stability.\n *\n * Each returned window is already \"half-open\" for an *inclusive* backend:\n * we subtract 1ms from the exclusive end so adjacent chunks do not overlap.\n *\n * Example (timestamp mode): [10:00, 12:00) → { after=10:00:00.000Z, before=11:59:59.999Z }\n *\n * @param mode - 'timestamp' or 'updated'\n * @param lower - Lower bound (inclusive)\n * @param upperExclusive - Upper bound (exclusive)\n * @param maxChunks - Maximum number of chunks to create\n * @returns Array of chunked preference query filters\n */\nexport function buildConsentChunks(\n mode: ChunkMode,\n lower: Date,\n upperExclusive: Date,\n maxChunks = 5000,\n): Array<PreferencesQueryFilter> {\n const totalMs = Math.max(0, upperExclusive.getTime() - lower.getTime());\n if (totalMs === 0) return [];\n\n // Snap only the starting boundary to the nearest 5-minute boundary.\n // We avoid re-snapping every step to prevent cumulative drift.\n const seriesStart = new Date(Math.floor(lower.getTime() / FIVE_MIN_MS) * FIVE_MIN_MS);\n\n // Compute base chunk size (ceil to ensure ≤ maxChunks), enforced ≥ 5m.\n const rawChunkMs = Math.ceil(totalMs / Math.max(1, maxChunks));\n const chunkMs = Math.max(FIVE_MIN_MS, rawChunkMs);\n\n // Number of chunks needed to cover [seriesStart, upperExclusive)\n const count = Math.ceil((upperExclusive.getTime() - seriesStart.getTime()) / chunkMs);\n\n const chunks: PreferencesQueryFilter[] = [];\n\n for (let i = 0; i < count; i += 1) {\n const startMs = seriesStart.getTime() + i * chunkMs;\n const endExclusiveMs = Math.min(upperExclusive.getTime(), startMs + chunkMs);\n\n // Convert exclusive end to inclusive end for an inclusive backend: -1ms.\n const endInclusiveMs = endExclusiveMs - 1;\n\n // Guard: in degenerate cases (shouldn’t happen with the math above), clamp.\n const safeEndMs = Math.max(startMs, endInclusiveMs);\n\n const afterIso = new Date(startMs).toISOString();\n const beforeIso = new Date(safeEndMs).toISOString();\n\n if (mode === 'timestamp') {\n chunks.push({\n timestampAfter: afterIso,\n timestampBefore: beforeIso,\n });\n } else {\n chunks.push({\n system: {\n updatedAfter: afterIso,\n updatedBefore: beforeIso,\n },\n });\n }\n }\n\n return chunks;\n}\n","import type { PreferenceQueryResponseItem } from '@transcend-io/privacy-types';\n\nimport type { ChunkMode } from './types.js';\n\n/**\n * Get the comparison instant for sorting based on the chosen dimension.\n *\n * @param mode - Chunking mode\n * @param item - Preference item\n * @returns date\n */\nexport function getComparisonTimeForRecord(\n mode: ChunkMode,\n item: PreferenceQueryResponseItem,\n): Date {\n if (mode === 'timestamp') {\n return new Date(item.timestamp);\n }\n // mode === 'updated'\n return item.system?.updatedAt ? new Date(item.system.updatedAt) : new Date();\n}\n","import type { PreferenceQueryResponseItem } from '@transcend-io/privacy-types';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport colors from 'colors';\nimport type { Got } from 'got';\n\nimport { logger } from '../../logger.js';\nimport { ConsentPreferenceResponse, PreferencesQueryFilter } from './types.js';\nimport { withPreferenceRetry } from './withPreferenceRetry.js';\n\n/**\n * Async generator over pages for a given filter\n *\n * @param sombra - Sombra Got instance\n * @param partition - Partition key\n * @param filter - Query filter\n * @param pageSize - Number of items per page\n * @yields Pages of PreferenceQueryResponseItem\n */\nexport async function* iterateConsentPages(\n sombra: Got,\n partition: string,\n filter: PreferencesQueryFilter,\n pageSize: number,\n): AsyncGenerator<PreferenceQueryResponseItem[], void, void> {\n let cursor: string | undefined;\n\n while (true) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const body: any = { limit: pageSize };\n if (filter && Object.keys(filter).length) body.filter = filter;\n if (cursor) body.cursor = cursor;\n\n const resp = await withPreferenceRetry(\n 'Preference Query',\n () =>\n sombra\n .post(`v1/preferences/${partition}/query`, {\n json: body,\n })\n .json(),\n {\n onRetry: (attempt, _error, message) => {\n logger.warn(\n colors.yellow(\n `Retry attempt ${attempt} for iterateConsentPages due to error: ${message}`,\n ),\n );\n },\n },\n );\n\n const { nodes, cursor: nextCursor } = decodeCodec(ConsentPreferenceResponse, resp);\n if (!nodes?.length) break;\n\n yield nodes;\n\n if (!nextCursor) break;\n cursor = nextCursor;\n }\n}\n","import type { ChunkMode, PreferencesQueryFilter } from './types.js';\n\n/**\n * Decide which dimension to chunk on: 'timestamp' if timestamps provided, otherwise 'updated'\n *\n * @param filterBy - Filter to examine\n * @returns Chosen chunk mode\n */\nexport function pickConsentChunkMode(filterBy: PreferencesQueryFilter): ChunkMode {\n const hasTimestamp = !!filterBy.timestampAfter || !!filterBy.timestampBefore;\n return hasTimestamp ? 'timestamp' : 'updated';\n}\n","import type { PreferenceQueryResponseItem } from '@transcend-io/privacy-types';\n/* eslint-disable max-lines */\nimport colors from 'colors';\nimport type { Got } from 'got';\n\nimport { logger } from '../../logger.js';\nimport { startOfUtcDay, DAY_MS } from '../helpers/index.js';\nimport { getComparisonTimeForRecord } from './getComparisonTimeForRecord.js';\nimport { iterateConsentPages } from './iterateConsentPages.js';\nimport { pickConsentChunkMode } from './pickConsentChunkMode.js';\nimport { ChunkMode, PreferencesQueryFilter } from './types.js';\n\n/**\n * Get after/before bounds from filter for the given mode\n *\n * @param mode - Chunking mode\n * @param filterBy - Filter to examine\n * @returns after/before dates\n */\nexport function getBoundsFromConsentFilter(\n mode: ChunkMode,\n filterBy: PreferencesQueryFilter,\n): {\n /** After date */\n after?: Date;\n /** Before date */\n before?: Date;\n} {\n if (mode === 'timestamp') {\n return {\n after: filterBy.timestampAfter ? new Date(filterBy.timestampAfter) : undefined,\n before: filterBy.timestampBefore ? new Date(filterBy.timestampBefore) : undefined,\n };\n }\n const u = filterBy.system ?? {};\n return {\n after: u.updatedAfter ? new Date(u.updatedAfter) : undefined,\n before: u.updatedBefore ? new Date(u.updatedBefore) : undefined,\n };\n}\n\n/**\n * Merge base filter with a \"before\" bound (without mixing dimensions).\n *\n * @param mode - Chunking mode\n * @param base - Base filter to augment\n * @param beforeISO - ISO timestamp to apply as the exclusive *Before bound for the chosen dimension\n * @returns New filter with the appropriate *Before constraint applied\n */\nfunction withBeforeBound(\n mode: ChunkMode,\n base: PreferencesQueryFilter,\n beforeISO?: string,\n): PreferencesQueryFilter {\n if (mode === 'timestamp') {\n return {\n ...base,\n timestampBefore: beforeISO ?? base.timestampBefore,\n };\n }\n return {\n ...base,\n system: {\n ...(base.system || {}),\n ...(beforeISO ? { updatedBefore: beforeISO } : {}),\n },\n // ensure we don't mix dimensions\n timestampAfter: undefined,\n timestampBefore: undefined,\n };\n}\n\n/**\n * Fetch a single record (or null) with the given filter.\n *\n * @param sombra - Got instance configured for Sombra API\n * @param partition - Preference Store partition id\n * @param filter - Query filter to use (page size internally forced to 1)\n * @returns The first record or null if none\n */\nasync function fetchOne(\n sombra: Got,\n partition: string,\n filter: PreferencesQueryFilter,\n): Promise<PreferenceQueryResponseItem | null> {\n logger.info(colors.magenta(`Single-record probe with filter: ${JSON.stringify(filter)}`));\n const it = iterateConsentPages(sombra, partition, filter, /* pageSize */ 1);\n const res = await it.next();\n if (res.done || !res.value || res.value.length === 0) {\n logger.info(colors.yellow('Probe result: no record'));\n return null;\n }\n const item = res.value[0]!;\n logger.info(\n colors.green(\n `Probe result: found record at ${getComparisonTimeForRecord(\n pickConsentChunkMode(filter),\n item,\n ).toISOString()}`,\n ),\n );\n return item;\n}\n\n/**\n * Robust earliest-day search (UTC):\n * 1) Anchor at the newest record (single-record probe).\n * 2) Exponential “jump back” using seeds (1d, 7d, 30d) then doubling (60d, 120d, 240d, …)\n * to cross into an empty region and establish a lower empty bound.\n * 3) **Exponential forward-from-empty**: gallop forward from the empty bound toward the last-found\n * to land close to the frontier quickly.\n * 4) Tighten with a short binary search on time using single-record probes.\n *\n * (Implementation note: preserves the public signature and docs while improving efficiency.)\n *\n * @param sombra - Sombra\n * @param opts - Options\n * @returns Earliest day with data (UTC start-of-day)\n */\nexport async function findEarliestDayWithData(\n sombra: Got,\n opts: {\n /** Partition */\n partition: string;\n /** Chunking mode */\n mode: ChunkMode;\n /** Base filter */\n baseFilter: PreferencesQueryFilter;\n /** Optional safety cap in days to avoid unbounded lookback (default ~10 years) */\n maxLookbackDays?: number;\n },\n): Promise<Date> {\n const { partition, mode, baseFilter, maxLookbackDays = 3650 } = opts;\n\n // 1) Find newest record (anchors our backtracking).\n const newest = await fetchOne(sombra, partition, withBeforeBound(mode, baseFilter));\n if (!newest) {\n logger.info(colors.yellow('No records found; defaulting earliest day to today.'));\n return startOfUtcDay(new Date());\n }\n const newestInstant = getComparisonTimeForRecord(mode, newest);\n logger.info(colors.green(`Newest instant: ${newestInstant.toISOString()}`));\n\n // 2) Exponential jump back to find an empty region.\n const seedSteps = [1, 7, 30]; // days\n let stepDaysIdx = 0;\n let stepMs = seedSteps[0] * DAY_MS;\n\n let lastFoundInstant = newestInstant; // last instant we *could* find a record before\n let emptyBeforeInstant: Date | null = null; // first bound that yielded no results\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const probeBound =\n stepDaysIdx < seedSteps.length\n ? new Date(newestInstant.getTime() - seedSteps[stepDaysIdx] * DAY_MS)\n : new Date(newestInstant.getTime() - stepMs);\n\n // stop if we exceeded lookback cap\n const daysSince =\n (startOfUtcDay(new Date()).getTime() - startOfUtcDay(probeBound).getTime()) / DAY_MS;\n if (daysSince > maxLookbackDays) {\n logger.warn(\n colors.yellow(\n `Exponential jump exceeded maxLookbackDays=${maxLookbackDays}. Using current bounds.`,\n ),\n );\n emptyBeforeInstant = probeBound;\n break;\n }\n\n logger.info(\n colors.magenta(\n `Probing before=${probeBound.toISOString()} (jump step ${\n stepDaysIdx < seedSteps.length\n ? `${seedSteps[stepDaysIdx]}d`\n : `${Math.round(stepMs / DAY_MS)}d`\n })…`,\n ),\n );\n\n const hit = await fetchOne(\n sombra,\n partition,\n withBeforeBound(mode, baseFilter, probeBound.toISOString()),\n );\n\n if (hit) {\n lastFoundInstant = getComparisonTimeForRecord(mode, hit);\n logger.info(\n colors.green(\n `Found older record at ${lastFoundInstant.toISOString()} — continue jumping back.`,\n ),\n );\n // advance step\n if (stepDaysIdx < seedSteps.length - 1) {\n stepDaysIdx += 1;\n stepMs = seedSteps[stepDaysIdx] * DAY_MS;\n } else if (stepDaysIdx === seedSteps.length - 1) {\n stepDaysIdx += 1; // switch to doubling mode\n stepMs = seedSteps[seedSteps.length - 1] * 2 * DAY_MS; // start at 60d\n } else {\n stepMs *= 2;\n }\n // eslint-disable-next-line no-continue\n continue;\n }\n\n // crossed into an empty zone — remember this bound\n emptyBeforeInstant = probeBound;\n logger.info(\n colors.green(`No record before ${probeBound.toISOString()} — established empty lower bound.`),\n );\n break;\n }\n\n // Guard: if for some reason empty bound wasn't set, synthesize one “just before” lastFound.\n if (!emptyBeforeInstant) {\n emptyBeforeInstant = new Date(lastFoundInstant.getTime() - DAY_MS);\n }\n\n // 3) Exponential forward-from-empty toward the found frontier.\n // This “gallop” reduces the span dramatically before binary search.\n // We keep moving the empty bound forward with exponentially growing steps\n // until we get a hit; then we shrink onto that hit instant.\n let lo = emptyBeforeInstant; // known EMPTY (no data before this bound)\n let hi = lastFoundInstant; // known FOUND (there is data before this instant)\n let fwdStep = Math.max(DAY_MS, Math.floor((hi.getTime() - lo.getTime()) / 64)); // start small-ish\n logger.info(\n colors.magenta(\n `Exponential forward-from-empty start: empty=${lo.toISOString()} found=${hi.toISOString()} step=${Math.round(\n fwdStep / DAY_MS,\n )}d`,\n ),\n );\n\n // Do a few gallop iterations (bounded so we don't loop forever if distribution is dense)\n for (let i = 0; i < 8; i += 1) {\n const probe = new Date(lo.getTime() + fwdStep);\n if (probe.getTime() >= hi.getTime()) break;\n\n logger.info(colors.magenta(`Forward gallop probe before=${probe.toISOString()}…`));\n const hit = await fetchOne(\n sombra,\n partition,\n withBeforeBound(mode, baseFilter, probe.toISOString()),\n );\n\n if (hit) {\n // We crossed into data — tighten hi to the actual hit instant.\n hi = getComparisonTimeForRecord(mode, hit);\n logger.info(\n colors.green(\n `Gallop hit at ${hi.toISOString()} — tightening found bound. Next step halves.`,\n ),\n );\n fwdStep = Math.max(DAY_MS, Math.floor(fwdStep / 2));\n } else {\n // Still empty up to probe — advance lo and double the step.\n lo.setTime(probe.getTime());\n logger.info(\n colors.yellow(\n `Gallop miss — advancing empty bound to ${lo.toISOString()}. Next step doubles.`,\n ),\n );\n fwdStep = Math.min(hi.getTime() - lo.getTime(), fwdStep * 2);\n if (fwdStep < DAY_MS) fwdStep = DAY_MS;\n }\n\n if (hi.getTime() - lo.getTime() <= DAY_MS) break;\n }\n\n // 4) Finish with a short binary search between [lo (empty), hi (found)].\n while (hi.getTime() - lo.getTime() > DAY_MS) {\n const mid = new Date(lo.getTime() + Math.floor((hi.getTime() - lo.getTime()) / 2));\n logger.info(colors.magenta(`Binary probe before=${mid.toISOString()}…`));\n\n const hit = await fetchOne(\n sombra,\n partition,\n withBeforeBound(mode, baseFilter, mid.toISOString()),\n );\n\n if (hit) {\n const when = getComparisonTimeForRecord(mode, hit);\n logger.info(colors.green(`Binary probe found record at ${when.toISOString()}.`));\n hi = when; // there is data before mid -> earliest could be even earlier\n } else {\n logger.info(colors.yellow('Binary probe found no record.'));\n lo = mid; // still empty -> move low up\n }\n }\n\n const earliestDay = startOfUtcDay(hi);\n logger.info(\n colors.green(\n `Earliest day (UTC) resolved to ${earliestDay.toISOString()} (instant ≈ ${hi.toISOString()}).`,\n ),\n );\n return earliestDay;\n}\n\n/**\n * Find latest day with data using exponential growth forward from earliest (UTC day math).\n *\n * (Implementation note: per your request, we now fetch a single newest record to infer the latest day.)\n *\n * @param sombra - Sombra\n * @param opts - Options\n * @returns Latest day with data\n */\nexport async function findLatestDayWithData(\n sombra: Got,\n opts: {\n /** Partition */\n partition: string;\n /** Chunking mode */\n mode: ChunkMode;\n /** Base filter */\n baseFilter: PreferencesQueryFilter;\n /** Earliest date */\n earliest: Date; // inclusive day start\n },\n): Promise<Date> {\n const { partition, mode, baseFilter } = opts;\n\n logger.info(colors.magenta('Latest-day discovery: probing newest record…'));\n const latest = await fetchOne(sombra, partition, withBeforeBound(mode, baseFilter));\n if (!latest) {\n logger.info(colors.yellow('No records found at all; defaulting latest day to today.'));\n return startOfUtcDay(new Date());\n }\n\n const when = getComparisonTimeForRecord(mode, latest);\n logger.info(colors.green(`Newest record instant is ${when.toISOString()}.`));\n\n const latestDay = startOfUtcDay(when);\n logger.info(\n colors.green(\n `Latest day (UTC) resolved to ${latestDay.toISOString()} from instant ${when.toISOString()}.`,\n ),\n );\n\n return latestDay;\n}\n/* eslint-enable max-lines */\n","import type { PreferenceQueryResponseItem } from '@transcend-io/privacy-types';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport type { Got } from 'got';\n\nimport { logger } from '../../logger.js';\nimport { map as pmap } from '../bluebird.js';\nimport { addDaysUtc, clampPageSize } from '../helpers/index.js';\nimport { buildConsentChunks } from './buildConsentChunks.js';\nimport {\n findEarliestDayWithData,\n findLatestDayWithData,\n getBoundsFromConsentFilter,\n} from './discoverConsentWindow.js';\nimport { iterateConsentPages } from './iterateConsentPages.js';\nimport { pickConsentChunkMode } from './pickConsentChunkMode.js';\nimport { PreferencesQueryFilter, ChunkMode } from './types.js';\n\n/**\n * Merge baseFilter with a window filter, taking care not to mix timestamp/updated fields improperly.\n *\n * @param mode - The chunking mode\n * @param base - The base filter\n * @param window - The per-chunk window filter\n * @returns merged filter\n */\nfunction mergeFilter(\n mode: ChunkMode,\n base: PreferencesQueryFilter,\n window: PreferencesQueryFilter,\n): PreferencesQueryFilter {\n if (mode === 'timestamp') {\n return {\n ...base,\n timestampAfter: window.timestampAfter ?? base.timestampAfter,\n timestampBefore: window.timestampBefore ?? base.timestampBefore,\n // ensure we don't pass `system.*` when chunking by timestamp\n system: undefined,\n };\n }\n // mode === 'updated'\n return {\n ...base,\n system: {\n ...(base.system || {}),\n ...(window.system?.updatedAfter ? { updatedAfter: window.system.updatedAfter } : {}),\n ...(window.system?.updatedBefore ? { updatedBefore: window.system.updatedBefore } : {}),\n },\n // Ensure we don't mix dimensions\n timestampAfter: undefined,\n timestampBefore: undefined,\n };\n}\n\n/**\n * High-level chunked fetch with progress bar.\n *\n * If an `onItems` callback is provided, pages are streamed to the callback\n * as they are fetched (no accumulation in memory). If no callback is provided,\n * the function returns all items (legacy behavior).\n *\n * @param sombra - Got instance\n * @param options - Options\n * @returns preference items (only if onItems is not provided)\n */\nexport async function fetchConsentPreferencesChunked(\n sombra: Got,\n {\n partition,\n filterBy = {},\n limit = 50,\n windowConcurrency = 25,\n maxChunks = 5000,\n maxLookbackDays = 3650,\n onItems,\n }: {\n /** Partition */\n partition: string;\n /** Filter by preferences */\n filterBy?: PreferencesQueryFilter;\n /** Limit number of results (page size) */\n limit?: number;\n /** Window concurrency */\n windowConcurrency?: number;\n /** Max chunks */\n maxChunks?: number; // up to N chunks; min 1 hour per chunk\n /** Max lookback days for discovering bounds */\n maxLookbackDays?: number;\n /** Optional streaming sink; if provided, items are not accumulated */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onItems?: (items: PreferenceQueryResponseItem[]) => Promise<any> | any;\n },\n): Promise<PreferenceQueryResponseItem[]> {\n const mode: ChunkMode = pickConsentChunkMode(filterBy);\n logger.info(\n colors.magenta(\n `Fetching consent preferences in chunks by ${\n mode === 'timestamp' ? 'timestamp' : 'system.updatedAt'\n }...`,\n ),\n );\n\n // Resolve / discover bounds (UTC)\n let { after, before } = getBoundsFromConsentFilter(mode, filterBy);\n logger.info(\n colors.magenta(\n `Initial bounds: after=${after?.toISOString() ?? 'undefined'} before=${\n before?.toISOString() ?? 'undefined'\n }`,\n ),\n );\n\n if (!after || !before) {\n if (!after) {\n logger.info(\n colors.magenta(`Discovering earliest day with data for partition ${partition}...`),\n );\n after = await findEarliestDayWithData(sombra, {\n partition,\n mode,\n baseFilter: filterBy,\n maxLookbackDays,\n });\n logger.info(colors.green(`Discovered earliest day with data: ${after.toISOString()}`));\n }\n if (!before) {\n logger.info(colors.magenta(`Discovering latest day with data for partition ${partition}...`));\n const latestDay = await findLatestDayWithData(sombra, {\n partition,\n mode,\n baseFilter: filterBy,\n earliest: after,\n });\n // Exclusive upper bound = latest day start + 1 day (UTC)\n before = addDaysUtc(latestDay, 1);\n logger.info(colors.green(`Discovered latest day with data: ${latestDay.toISOString()}`));\n }\n }\n\n logger.info(\n colors.green(`Final bounds (UTC): after=${after.toISOString()} before=${before.toISOString()}`),\n );\n\n // Build up to `maxChunks` chunks, min 1 hour each\n const chunks = buildConsentChunks(mode, after, before, maxChunks);\n\n logger.info(\n colors.magenta(\n `Fetching consent preferences from partition ${partition} in ${chunks.length} chunks...`,\n ),\n );\n\n // Progress bar over chunks (unordered):\n // - value = completed chunks (out-of-order OK)\n // - payload fetched = total records fetched\n const bar = new cliProgress.SingleBar(\n {\n format: 'Downloading [{bar}] {percentage}% | chunks {value}/{total} | fetched {fetched}',\n },\n cliProgress.Presets.shades_classic,\n );\n\n let completed = 0; // finished chunks (out-of-order)\n let fetched = 0; // raw records counter\n\n bar.start(chunks.length, 0, { fetched });\n\n const t0 = Date.now();\n const pageSize = clampPageSize(limit);\n\n // If we are streaming, do not accumulate everything in memory.\n const out: PreferenceQueryResponseItem[] = [];\n\n await pmap(\n chunks.map((windowFilter, idx) => ({ windowFilter, idx })),\n async ({ windowFilter }) => {\n const filter = mergeFilter(mode, filterBy, windowFilter);\n\n // Stream this chunk page-by-page\n for await (const page of iterateConsentPages(sombra, partition, filter, pageSize)) {\n fetched += page.length;\n bar.update(completed, { fetched });\n\n if (onItems) {\n await onItems(page);\n } else {\n out.push(...page);\n }\n }\n\n completed += 1;\n bar.update(completed, { fetched });\n },\n { concurrency: Math.max(1, windowConcurrency) },\n );\n\n bar.update(completed, { fetched });\n bar.stop();\n\n logger.info(\n colors.green(\n `Fetched ${fetched} consent preference records from partition ${partition} in ${\n (Date.now() - t0) / 1000\n }s.`,\n ),\n );\n\n return onItems ? [] : out;\n}\n","import { PreferenceQueryResponseItem } from '@transcend-io/privacy-types';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport colors from 'colors';\nimport type { Got } from 'got';\n\nimport { logger } from '../../logger.js';\nimport { ConsentPreferenceResponse, PreferencesQueryFilter } from './types.js';\nimport { withPreferenceRetry } from './withPreferenceRetry.js';\n\n/**\n * Fetch consent preferences for the managed consent database (new query endpoint)\n *\n * Uses POST /v1/preferences/{partition}/query with cursor pagination.\n *\n * If `onItems` is provided, this streams pages to the callback and does not\n * accumulate results in memory. If omitted, the function returns all items.\n *\n * @param sombra - Sombra instance (must include auth headers)\n * @param options - Query options\n * @returns All nodes (only when onItems is not provided)\n */\nexport async function fetchConsentPreferences(\n sombra: Got,\n {\n partition,\n filterBy = {},\n limit = 50,\n onItems,\n }: {\n /** Partition key to fetch (moved to URL path on new endpoint) */\n partition: string;\n /** Query filter (wrapped under \"filter\" in request body) */\n filterBy?: PreferencesQueryFilter;\n /** Number of users per page (1–50 per API spec) */\n limit?: number;\n /** Optional streaming sink; if provided, pages are not accumulated */\n onItems?: (items: PreferenceQueryResponseItem[]) => Promise<void> | void;\n },\n): Promise<PreferenceQueryResponseItem[]> {\n const collected: PreferenceQueryResponseItem[] = [];\n\n // Cursor-based pagination per new endpoint\n let cursor: string | undefined;\n\n // Build the filter payload, omitting empty filter\n const hasFilter =\n filterBy &&\n (Object.keys(filterBy).length > 0 ||\n (filterBy.system && Object.keys(filterBy.system).length > 0));\n\n // Enforce API max (defensive; backend also validates)\n const pageSize = Math.max(1, Math.min(50, limit ?? 50));\n\n // Keep fetching until no cursor is returned\n // (The API returns an opaque cursor string for the next page)\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const body: {\n /** Filter by user identifiers (new shape) */\n filter?: PreferencesQueryFilter;\n /** Cursor for pagination */\n cursor?: string;\n /** Number of records per page */\n limit: number;\n } = { limit: pageSize };\n\n if (hasFilter) {\n body.filter = filterBy;\n }\n if (cursor) {\n body.cursor = cursor;\n }\n\n const response = await withPreferenceRetry(\n 'Preference Query',\n () =>\n sombra\n .post(`v1/preferences/${partition}/query`, {\n json: body,\n })\n .json(),\n {\n onRetry: (attempt, _error, message) => {\n logger.warn(\n colors.yellow(\n `Retry attempt ${attempt} for fetchConsentPreferences due to error: ${message}`,\n ),\n );\n },\n },\n );\n\n const { nodes, cursor: nextCursor } = decodeCodec(ConsentPreferenceResponse, response);\n\n if (!nodes || nodes.length === 0) {\n break;\n }\n\n if (onItems) {\n await onItems(nodes);\n } else {\n collected.push(...nodes);\n }\n\n if (!nextCursor) {\n break;\n }\n cursor = nextCursor;\n }\n\n return onItems ? [] : collected;\n}\n","import type { PreferenceQueryResponseItem } from '@transcend-io/privacy-types';\nimport colors from 'colors';\n\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllIdentifiers,\n fetchAllPurposesAndPreferences,\n} from '../../../lib/graphql/index.js';\nimport { initCsvFile, appendCsvRowsOrdered } from '../../../lib/helpers/index.js';\nimport {\n fetchConsentPreferences,\n fetchConsentPreferencesChunked,\n transformPreferenceRecordToCsv,\n type PreferenceIdentifier,\n} from '../../../lib/preference-management/index.js';\nimport { logger } from '../../../logger.js';\n\n// Known “core” columns your transformer usually produces up front.\n// Leave this list conservative; we’ll still union with transformer keys.\nconst CORE_COLS = [\n 'userId',\n 'timestamp',\n 'partition',\n 'decryptionStatus',\n 'updatedAt',\n 'usp',\n 'gpp',\n 'tcf',\n 'airgapVersion',\n 'metadata',\n 'metadataTimestamp',\n];\n\nexport interface PullConsentPreferencesCommandFlags {\n auth: string;\n partition: string;\n sombraAuth?: string;\n file: string;\n transcendUrl: string;\n timestampBefore?: Date;\n exportIdentifiersWithDelimiter: string;\n timestampAfter?: Date;\n updatedBefore?: Date;\n updatedAfter?: Date;\n identifiers?: string[];\n concurrency: number;\n shouldChunk: boolean;\n windowConcurrency: number;\n maxChunks: number;\n maxLookbackDays: number;\n}\n\nexport async function pullConsentPreferences(\n this: LocalContext,\n {\n auth,\n partition,\n sombraAuth,\n file,\n transcendUrl,\n timestampBefore,\n timestampAfter,\n updatedBefore,\n updatedAfter,\n identifiers = [],\n concurrency,\n shouldChunk,\n windowConcurrency,\n maxChunks,\n exportIdentifiersWithDelimiter,\n maxLookbackDays,\n }: PullConsentPreferencesCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, sombraAuth);\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Identifiers are key:value, parse to PreferenceIdentifier[]\n const parsedIdentifiers = identifiers.map((identifier): PreferenceIdentifier => {\n if (!identifier.includes(':')) {\n return {\n name: 'email',\n value: identifier,\n };\n }\n const [name, value] = identifier.split(':');\n return { name, value };\n });\n\n // Build filter\n const filterBy = {\n ...(timestampBefore ? { timestampBefore: timestampBefore.toISOString() } : {}),\n ...(timestampAfter ? { timestampAfter: timestampAfter.toISOString() } : {}),\n ...(updatedAfter || updatedBefore\n ? {\n system: {\n ...(updatedBefore ? { updatedBefore: updatedBefore.toISOString() } : {}),\n ...(updatedAfter ? { updatedAfter: updatedAfter.toISOString() } : {}),\n },\n }\n : {}),\n ...(parsedIdentifiers.length > 0 ? { identifiers: parsedIdentifiers } : {}),\n };\n\n logger.info(\n `Fetching consent preferences from partition ${partition}, using mode=${\n shouldChunk ? 'chunked-stream' : 'paged-stream'\n }...`,\n );\n\n logger.info(colors.magenta(`Preparing CSV at: ${file}`));\n\n // Fetch full sets (purposes+topics, identifiers) to ensure header completeness\n const [purposesWithTopics, allIdentifiers] = await Promise.all([\n fetchAllPurposesAndPreferences(client),\n fetchAllIdentifiers(client),\n ]);\n\n // Identifier columns: exactly the identifier names\n const identifierCols = allIdentifiers.map((i) => i.name);\n\n // Preference topic columns: topic names (de-duped)\n const topicCols = Array.from(\n new Set(\n purposesWithTopics.flatMap((p) => p.topics?.map((t) => `${p.trackingType}_${t.slug}`) ?? []),\n ),\n ).sort((a, b) => a.localeCompare(b));\n\n // Some setups also want a per-purpose boolean column (e.g., “Email”, “Sms”).\n // If your transformer includes those, list them here, derived from purposes:\n const purposeCols = Array.from(new Set(purposesWithTopics.map((p) => p.trackingType))).sort(\n (a, b) => a.localeCompare(b),\n );\n\n // Build the complete header skeleton.\n // We’ll still union with the first transformed row’s keys to be safe.\n const completeHeadersList = [...CORE_COLS, ...identifierCols, ...purposeCols, ...topicCols];\n\n // Lazily initialize CSV header order from the first transformed row.\n let headerOrder: string[] | null = null;\n let wroteHeader = false;\n const writeRows = (items: PreferenceQueryResponseItem[]): void => {\n if (!items || items.length === 0) return;\n const rows = items.map((row) =>\n transformPreferenceRecordToCsv(row, exportIdentifiersWithDelimiter),\n );\n if (!wroteHeader) {\n const firstKeys = Object.keys(rows[0] ?? {});\n const seen = new Set<string>();\n headerOrder = [...completeHeadersList, ...firstKeys].filter((k) => {\n if (k === undefined) return false;\n if (seen.has(k)) return false;\n seen.add(k);\n return true;\n });\n initCsvFile(file, headerOrder);\n wroteHeader = true;\n }\n appendCsvRowsOrdered(file, rows, headerOrder!);\n };\n\n if (shouldChunk) {\n // Stream via chunked fetcher with page callback\n await fetchConsentPreferencesChunked(sombra, {\n partition,\n filterBy,\n limit: concurrency,\n windowConcurrency,\n maxChunks,\n maxLookbackDays,\n onItems: (items) => writeRows(items),\n });\n\n logger.info(colors.green(`Finished writing CSV to ${file}`));\n return;\n }\n\n // Non-chunked path: still stream page-by-page via onItems (no in-memory accumulation)\n await fetchConsentPreferences(sombra, {\n partition,\n filterBy,\n limit: concurrency, // page size (API max 50 enforced internally)\n onItems: (items) => writeRows(items),\n });\n\n logger.info(colors.green(`Finished writing CSV to ${file}`));\n}\n"],"mappings":"irBASA,SAAgB,EACd,CACE,cAAc,EAAE,CAChB,WAAW,EAAE,CACb,WAAW,EAAE,CACb,oBAAoB,EAAE,CACtB,SAAS,CACP,iBAAkB,YACnB,CAED,GAAG,GAEL,EACyB,CAEzB,IAAM,EAA+B,CACnC,GAAG,EACH,GAAG,EACH,GAAG,EACJ,CAGD,GAAI,MAAM,QAAQ,EAAY,CAAE,CAC9B,IAAM,EAAS,IAAI,IACnB,IAAK,GAAM,CAAE,OAAM,WAAW,EACvB,EAAO,IAAI,EAAK,EAAE,EAAO,IAAI,EAAM,IAAI,IAAM,CAC9C,GAAO,EAAO,IAAI,EAAK,CAAE,IAAI,EAAM,CAEzC,IAAK,GAAM,CAAC,EAAM,KAAQ,EAAO,SAAS,CACxC,EAAI,GAAQ,MAAM,KAA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d2q6S2.mjs";import{r as n}from"./makeGraphQLRequest-Cq26A_Lq.mjs";import{s as r}from"./writeCsv-B51ulrVl.mjs";import{t as i}from"./done-input-validation-DLR0-MJ7.mjs";import{uniq as a}from"lodash-es";import o from"colors";async function s({auth:s,file:c,transcendUrl:l,dataSiloIds:u,subCategories:d,status:f,includeEncryptedSnippets:p}){i(this.process.exit);try{let i=await t(n(l,s),{dataSiloIds:u,subCategories:d,status:f,includeEncryptedSnippets:p});e.info(o.magenta(`Writing unstructured discovery files to file "${c}"...`));let m=[];await r(c,i.map(e=>{let t={"Entry ID":e.id,"Data Silo ID":e.dataSiloId,"Object Path ID":e.scannedObjectPathId,"Object ID":e.scannedObjectId,...p?{Entry:e.name,"Context Snippet":e.contextSnippet}:{},"Data Category":`${e.dataSubCategory.category}:${e.dataSubCategory.name}`,"Classification Status":e.status,"Confidence Score":e.confidence,"Classification Method":e.classificationMethod,"Classifier Version":e.classifierVersion};return m=a([...m,...Object.keys(t)]),t}),m)}catch(t){e.error(o.red(`An error occurred syncing the unstructured discovery files: ${t.message}`)),this.process.exit(1)}e.info(o.green(`Successfully synced unstructured discovery files to disk at ${c}!`))}export{s as pullUnstructuredDiscoveryFiles};
2
- //# sourceMappingURL=impl-DxUFb0vv.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"impl-DxUFb0vv.mjs","names":[],"sources":["../src/commands/inventory/pull-unstructured-discovery-files/impl.ts"],"sourcesContent":["import type { UnstructuredSubDataPointRecommendationStatus } from '@transcend-io/privacy-types';\nimport colors from 'colors';\nimport { uniq } from 'lodash-es';\n\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { pullUnstructuredSubDataPointRecommendations } from '../../../lib/data-inventory/index.js';\nimport { buildTranscendGraphQLClient } from '../../../lib/graphql/index.js';\nimport { writeLargeCsv } from '../../../lib/helpers/index.js';\nimport { logger } from '../../../logger.js';\n\nexport interface PullUnstructuredDiscoveryFilesCommandFlags {\n auth: string;\n file: string;\n transcendUrl: string;\n dataSiloIds?: string[];\n subCategories?: string[];\n status?: UnstructuredSubDataPointRecommendationStatus[];\n includeEncryptedSnippets: boolean;\n}\n\nexport async function pullUnstructuredDiscoveryFiles(\n this: LocalContext,\n {\n auth,\n file,\n transcendUrl,\n dataSiloIds,\n subCategories,\n status,\n includeEncryptedSnippets,\n }: PullUnstructuredDiscoveryFilesCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n try {\n // Create a GraphQL client\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n const entries = await pullUnstructuredSubDataPointRecommendations(client, {\n dataSiloIds,\n subCategories, // TODO: https://transcend.height.app/T-40482 - do by name not ID\n status,\n includeEncryptedSnippets,\n });\n\n logger.info(colors.magenta(`Writing unstructured discovery files to file \"${file}\"...`));\n let headers: string[] = [];\n const inputs = entries.map((entry) => {\n const result = {\n 'Entry ID': entry.id,\n 'Data Silo ID': entry.dataSiloId,\n 'Object Path ID': entry.scannedObjectPathId,\n 'Object ID': entry.scannedObjectId,\n ...(includeEncryptedSnippets\n ? { Entry: entry.name, 'Context Snippet': entry.contextSnippet }\n : {}),\n 'Data Category': `${entry.dataSubCategory.category}:${entry.dataSubCategory.name}`,\n 'Classification Status': entry.status,\n 'Confidence Score': entry.confidence,\n 'Classification Method': entry.classificationMethod,\n 'Classifier Version': entry.classifierVersion,\n };\n headers = uniq([...headers, ...Object.keys(result)]);\n return result;\n });\n await writeLargeCsv(file, inputs, headers);\n } catch (err) {\n logger.error(\n colors.red(`An error occurred syncing the unstructured discovery files: ${err.message}`),\n );\n this.process.exit(1);\n }\n\n // Indicate success\n logger.info(colors.green(`Successfully synced unstructured discovery files to disk at ${file}!`));\n}\n"],"mappings":"sUAqBA,eAAsB,EAEpB,CACE,OACA,OACA,eACA,cACA,gBACA,SACA,4BAEa,CACf,EAAoB,KAAK,QAAQ,KAAK,CAEtC,GAAI,CAIF,IAAM,EAAU,MAAM,EAFP,EAA4B,EAAc,EAAK,CAEY,CACxE,cACA,gBACA,SACA,2BACD,CAAC,CAEF,EAAO,KAAK,EAAO,QAAQ,iDAAiD,EAAK,MAAM,CAAC,CACxF,IAAI,EAAoB,EAAE,CAmB1B,MAAM,EAAc,EAlBL,EAAQ,IAAK,GAAU,CACpC,IAAM,EAAS,CACb,WAAY,EAAM,GAClB,eAAgB,EAAM,WACtB,iBAAkB,EAAM,oBACxB,YAAa,EAAM,gBACnB,GAAI,EACA,CAAE,MAAO,EAAM,KAAM,kBAAmB,EAAM,eAAgB,CAC9D,EAAE,CACN,gBAAiB,GAAG,EAAM,gBAAgB,SAAS,GAAG,EAAM,gBAAgB,OAC5E,wBAAyB,EAAM,OAC/B,mBAAoB,EAAM,WAC1B,wBAAyB,EAAM,qBAC/B,qBAAsB,EAAM,kBAC7B,CAED,MADA,GAAU,EAAK,CAAC,GAAG,EAAS,GAAG,OAAO,KAAK,EAAO,CAAC,CAAC,CAC7C,GACP,CACgC,EAAQ,OACnC,EAAK,CACZ,EAAO,MACL,EAAO,IAAI,+DAA+D,EAAI,UAAU,CACzF,CACD,KAAK,QAAQ,KAAK,EAAE,CAItB,EAAO,KAAK,EAAO,MAAM,+DAA+D,EAAK,GAAG,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"impl-JThkrXiI2.mjs","names":[],"sources":["../src/commands/request/restart/impl.ts"],"sourcesContent":["import type { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\n\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { bulkRestartRequests } from '../../../lib/requests/index.js';\n\nexport interface RestartCommandFlags {\n auth: string;\n actions: RequestAction[];\n statuses: RequestStatus[];\n transcendUrl: string;\n requestReceiptFolder: string;\n sombraAuth?: string;\n concurrency: number;\n requestIds?: string[];\n emailIsVerified: boolean;\n createdAt?: Date;\n silentModeBefore?: Date;\n createdAtBefore?: Date;\n createdAtAfter?: Date;\n updatedAtBefore?: Date;\n updatedAtAfter?: Date;\n sendEmailReceipt: boolean;\n copyIdentifiers: boolean;\n skipWaitingPeriod: boolean;\n}\n\nexport async function restart(\n this: LocalContext,\n {\n auth,\n requestReceiptFolder,\n sombraAuth,\n actions,\n statuses,\n requestIds,\n createdAt,\n emailIsVerified,\n silentModeBefore,\n sendEmailReceipt,\n copyIdentifiers,\n skipWaitingPeriod,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n concurrency,\n transcendUrl,\n }: RestartCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n await bulkRestartRequests({\n requestReceiptFolder,\n auth,\n sombraAuth,\n requestActions: actions,\n requestStatuses: statuses,\n requestIds,\n createdAt,\n emailIsVerified,\n silentModeBefore,\n sendEmailReceipt,\n copyIdentifiers,\n skipWaitingPeriod,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n concurrency,\n transcendUrl,\n });\n}\n"],"mappings":"2GA2BA,eAAsB,EAEpB,CACE,OACA,uBACA,aACA,UACA,WACA,aACA,YACA,kBACA,mBACA,mBACA,kBACA,oBACA,kBACA,iBACA,kBACA,iBACA,cACA,gBAEa,CACf,EAAoB,KAAK,QAAQ,KAAK,CAEtC,MAAM,EAAoB,CACxB,uBACA,OACA,aACA,eAAgB,EAChB,gBAAiB,EACjB,aACA,YACA,kBACA,mBACA,mBACA,kBACA,oBACA,kBACA,iBACA,kBACA,iBACA,cACA,eACD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"impl-KDuBh4bu2.mjs","names":[],"sources":["../src/commands/request/approve/impl.ts"],"sourcesContent":["import { RequestAction, RequestOrigin } from '@transcend-io/privacy-types';\n\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { approvePrivacyRequests } from '../../../lib/requests/index.js';\n\nexport interface ApproveCommandFlags {\n auth: string;\n actions: RequestAction[];\n origins?: RequestOrigin[];\n silentModeBefore?: Date;\n createdAtBefore?: Date;\n createdAtAfter?: Date;\n updatedAtBefore?: Date;\n updatedAtAfter?: Date;\n transcendUrl: string;\n concurrency: number;\n}\n\nexport async function approve(\n this: LocalContext,\n {\n auth,\n actions,\n origins,\n silentModeBefore,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n transcendUrl,\n concurrency,\n }: ApproveCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n await approvePrivacyRequests({\n transcendUrl,\n requestActions: actions,\n auth,\n requestOrigins: origins,\n concurrency,\n silentModeBefore,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n });\n}\n"],"mappings":"8GAmBA,eAAsB,EAEpB,CACE,OACA,UACA,UACA,mBACA,kBACA,iBACA,kBACA,iBACA,eACA,eAEa,CACf,EAAoB,KAAK,QAAQ,KAAK,CAEtC,MAAM,EAAuB,CAC3B,eACA,eAAgB,EAChB,OACA,eAAgB,EAChB,cACA,mBACA,kBACA,iBACA,kBACA,iBACD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"impl-c7rUQYDc2.mjs","names":[],"sources":["../src/commands/request/mark-silent/impl.ts"],"sourcesContent":["import type { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\n\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { markSilentPrivacyRequests } from '../../../lib/requests/index.js';\n\nexport interface MarkSilentCommandFlags {\n auth: string;\n actions: RequestAction[];\n statuses?: RequestStatus[];\n requestIds?: string[];\n createdAtBefore?: Date;\n createdAtAfter?: Date;\n updatedAtBefore?: Date;\n updatedAtAfter?: Date;\n transcendUrl: string;\n concurrency: number;\n}\n\nexport async function markSilent(\n this: LocalContext,\n {\n auth,\n transcendUrl,\n actions,\n statuses,\n requestIds,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n concurrency,\n }: MarkSilentCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n await markSilentPrivacyRequests({\n transcendUrl,\n requestActions: actions,\n auth,\n requestIds,\n statuses,\n concurrency,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n });\n}\n"],"mappings":"iHAmBA,eAAsB,EAEpB,CACE,OACA,eACA,UACA,WACA,aACA,kBACA,iBACA,kBACA,iBACA,eAEa,CACf,EAAoB,KAAK,QAAQ,KAAK,CAEtC,MAAM,EAA0B,CAC9B,eACA,eAAgB,EAChB,OACA,aACA,WACA,cACA,kBACA,iBACA,kBACA,iBACD,CAAC"}
@@ -1,2 +0,0 @@
1
- import{t as e}from"./constants-CeMiHaHx.mjs";import{t}from"./logger-B-LXIf3U.mjs";import{n}from"./syncCodePackages-F-97FNjo.mjs";import{r}from"./makeGraphQLRequest-Cq26A_Lq.mjs";import{t as i}from"./done-input-validation-DLR0-MJ7.mjs";import{t as a}from"./constants-AFtS5Nad.mjs";import{getEntries as o}from"@transcend-io/type-utils";import s from"colors";import{execSync as c}from"child_process";import l from"fast-glob";async function u({scanPath:e,ignoreDirs:n=[],repositoryName:r}){return(await Promise.all(o(a).map(async([i,a])=>{let{ignoreDirs:o,supportedFiles:c,scanFunction:u}=a,d=[...n,...o].filter(e=>e.length>0);try{let n=await l(`${e}/**/${c.join(`|`)}`,{ignore:d.map(t=>`${e}/**/${t}`),unique:!0,onlyFiles:!0});t.info(s.magenta(`Scanning: ${n.length} files of type ${i}`));let a=n.map(t=>u(t).map(n=>({...n,relativePath:t.replace(`${e}/`,``)}))).flat();return t.info(s.green(`Found: ${a.length} packages and ${a.map(({softwareDevelopmentKits:e=[]})=>e).flat().length} sdks`)),a.map(e=>({...e,type:i,repositoryName:r}))}catch(e){throw Error(`Error scanning globs ${c} with error: ${e}`)}}))).flat()}const d=`A repository name must be provided. You can specify using --repositoryName=$REPO_NAME or by ensuring the command "git config --get remote.origin.url" returns the name of the repository`;async function f({auth:a,scanPath:o,ignoreDirs:l,repositoryName:f,transcendUrl:p}){i(this.process.exit);let m=f;if(!m)try{let e=c(`cd ${o} && git config --get remote.origin.url`).toString(`utf-8`).trim();[m]=e.includes(`https:`)?e.split(`/`).slice(3).join(`/`).split(`.`):(e.split(`:`).pop()||``).split(`.`),m||(t.error(s.red(d)),this.process.exit(1))}catch(e){t.error(s.red(`${d} - Got error: ${e.message}`)),this.process.exit(1)}let h=r(p,a),g=await u({scanPath:o,ignoreDirs:l,repositoryName:m});await n(h,g);let _=new URL(e);_.pathname=`/code-scanning/code-packages`,t.info(s.green(`Scan found ${g.length} packages at ${o}! View results at '${_.href}'`))}export{f as scanPackages};
2
- //# sourceMappingURL=impl-oiBTZqQS2.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"impl-oiBTZqQS2.mjs","names":[],"sources":["../src/lib/code-scanning/findCodePackagesInFolder.ts","../src/commands/inventory/scan-packages/impl.ts"],"sourcesContent":["import { getEntries } from '@transcend-io/type-utils';\nimport colors from 'colors';\nimport fastGlob from 'fast-glob';\n\nimport { CodePackageInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\nimport { CODE_SCANNING_CONFIGS } from './constants.js';\n\n/**\n * Helper to scan and discovery all of the code packages within a folder\n *\n * @param options - Options\n * @returns the list of integrations\n */\nexport async function findCodePackagesInFolder({\n scanPath,\n ignoreDirs = [],\n repositoryName,\n}: {\n /** The name of the github repository reporting packages for */\n repositoryName: string;\n /** Where to look for package.json files */\n scanPath: string;\n /** The directories to ignore (excludes node_modules and serverless-build) */\n ignoreDirs?: string[];\n}): Promise<CodePackageInput[]> {\n const allCodePackages = await Promise.all(\n getEntries(CODE_SCANNING_CONFIGS).map(async ([codePackageType, config]) => {\n const { ignoreDirs: configIgnoreDirs, supportedFiles, scanFunction } = config;\n const dirsToIgnore = [...ignoreDirs, ...configIgnoreDirs].filter((dir) => dir.length > 0);\n try {\n const filesToScan: string[] = await fastGlob(`${scanPath}/**/${supportedFiles.join('|')}`, {\n ignore: dirsToIgnore.map((dir: string) => `${scanPath}/**/${dir}`),\n unique: true,\n onlyFiles: true,\n });\n logger.info(\n colors.magenta(`Scanning: ${filesToScan.length} files of type ${codePackageType}`),\n );\n const allPackages = filesToScan\n .map((filePath) =>\n scanFunction(filePath).map((result) => ({\n ...result,\n relativePath: filePath.replace(`${scanPath}/`, ''),\n })),\n )\n .flat();\n logger.info(\n colors.green(\n `Found: ${allPackages.length} packages and ${\n allPackages.map(({ softwareDevelopmentKits = [] }) => softwareDevelopmentKits).flat()\n .length\n } sdks`,\n ),\n );\n\n return allPackages.map(\n (pkg): CodePackageInput => ({\n ...pkg,\n type: codePackageType,\n repositoryName,\n }),\n );\n } catch (error) {\n throw new Error(`Error scanning globs ${supportedFiles} with error: ${error}`);\n }\n }),\n );\n\n return allCodePackages.flat();\n}\n","import { execSync } from 'child_process';\n\nimport colors from 'colors';\n\nimport { ADMIN_DASH } from '../../../constants.js';\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { findCodePackagesInFolder } from '../../../lib/code-scanning/index.js';\nimport { buildTranscendGraphQLClient, syncCodePackages } from '../../../lib/graphql/index.js';\nimport { logger } from '../../../logger.js';\n\nconst REPO_ERROR =\n 'A repository name must be provided. ' +\n 'You can specify using --repositoryName=$REPO_NAME or by ensuring the ' +\n 'command \"git config --get remote.origin.url\" returns the name of the repository';\n\nexport interface ScanPackagesCommandFlags {\n auth: string;\n scanPath: string;\n ignoreDirs?: string[];\n repositoryName?: string;\n transcendUrl: string;\n}\n\nexport async function scanPackages(\n this: LocalContext,\n { auth, scanPath, ignoreDirs, repositoryName, transcendUrl }: ScanPackagesCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n // Ensure repository name is specified\n let gitRepositoryName = repositoryName;\n if (!gitRepositoryName) {\n try {\n const name = execSync(`cd ${scanPath} && git config --get remote.origin.url`);\n // Trim and parse the URL\n const url = name.toString('utf-8').trim();\n [gitRepositoryName] = !url.includes('https:')\n ? (url.split(':').pop() || '').split('.')\n : url.split('/').slice(3).join('/').split('.');\n if (!gitRepositoryName) {\n logger.error(colors.red(REPO_ERROR));\n this.process.exit(1);\n }\n } catch (err) {\n logger.error(colors.red(`${REPO_ERROR} - Got error: ${err.message}`));\n this.process.exit(1);\n }\n }\n\n // Create a GraphQL client\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Scan the codebase to discovery packages\n const results = await findCodePackagesInFolder({\n scanPath,\n ignoreDirs,\n repositoryName: gitRepositoryName,\n });\n\n // Report scan to Transcend\n await syncCodePackages(client, results);\n\n const newUrl = new URL(ADMIN_DASH);\n newUrl.pathname = '/code-scanning/code-packages';\n\n // Indicate success\n logger.info(\n colors.green(\n `Scan found ${results.length} packages at ${scanPath}! ` + `View results at '${newUrl.href}'`,\n ),\n );\n}\n"],"mappings":"saAcA,eAAsB,EAAyB,CAC7C,WACA,aAAa,EAAE,CACf,kBAQ8B,CA4C9B,OA3CwB,MAAM,QAAQ,IACpC,EAAW,EAAsB,CAAC,IAAI,MAAO,CAAC,EAAiB,KAAY,CACzE,GAAM,CAAE,WAAY,EAAkB,iBAAgB,gBAAiB,EACjE,EAAe,CAAC,GAAG,EAAY,GAAG,EAAiB,CAAC,OAAQ,GAAQ,EAAI,OAAS,EAAE,CACzF,GAAI,CACF,IAAM,EAAwB,MAAM,EAAS,GAAG,EAAS,MAAM,EAAe,KAAK,IAAI,GAAI,CACzF,OAAQ,EAAa,IAAK,GAAgB,GAAG,EAAS,MAAM,IAAM,CAClE,OAAQ,GACR,UAAW,GACZ,CAAC,CACF,EAAO,KACL,EAAO,QAAQ,aAAa,EAAY,OAAO,iBAAiB,IAAkB,CACnF,CACD,IAAM,EAAc,EACjB,IAAK,GACJ,EAAa,EAAS,CAAC,IAAK,IAAY,CACtC,GAAG,EACH,aAAc,EAAS,QAAQ,GAAG,EAAS,GAAI,GAAG,CACnD,EAAE,CACJ,CACA,MAAM,CAUT,OATA,EAAO,KACL,EAAO,MACL,UAAU,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mjs";async function n({auth:n,transcendUrl:r,enricherIds:i}){t(this.process.exit),await e({transcendUrl:r,auth:n,enricherIds:i})}export{n as skipPreflightJobs};
2
- //# sourceMappingURL=impl-tbGnvKFm.mjs.map
@@ -1,2 +0,0 @@
1
- import{n as e}from"./package-C4J38oR1.mjs";import{t}from"./logger-B-LXIf3U.mjs";import n from"colors";import{GraphQLClient as r}from"graphql-request";function i(t,n){return new r(`${t}/graphql`,{headers:{...n,version:e}})}function a(e,t){return i(e,{Authorization:`Bearer ${t}`})}function o(e){return new Promise(t=>{setTimeout(()=>t(e),e)})}const s=[`syntax error`,`got invalid value`,`Client error`,`cannot affect row a second time`,`GRAPHQL_VALIDATION_FAILED`];async function c(e,r,i,a,c=4){let l=0;for(;;)try{return await e.request(r,i,a)}catch(e){if(e.message.includes(`API key is invalid`)&&(t.error(n.red("API key is invalid. Please ensure that the key provided to `transcendAuth` has the proper scope and is not expired, and that `transcendUrl` corresponds to the correct backend for your organization.")),process.exit(1)),s.some(t=>e.message.includes(t)))throw e;if(e.message.startsWith(`Client error: Too many requests`)){let r=e.response.headers?.get(`x-ratelimit-reset`),i=r?new Date(r).getTime()-new Date().getTime()+100:1e3*10;t.log(n.yellow(`DETECTED RATE LIMIT: ${e.message}. Sleeping for ${i}ms`)),await o(i)}if(l>=c)throw e;l+=1,t.log(n.yellow(`Retrying failed request (${l} / ${c}): ${e.message}`))}}export{i,o as n,a as r,c as t};
2
- //# sourceMappingURL=makeGraphQLRequest-Cq26A_Lq.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"makeGraphQLRequest-Cq26A_Lq.mjs","names":[],"sources":["../src/lib/graphql/buildTranscendGraphQLClient.ts","../src/lib/helpers/sleepPromise.ts","../src/lib/graphql/makeGraphQLRequest.ts"],"sourcesContent":["import { GraphQLClient } from 'graphql-request';\n\nimport { version } from '../../../package.json';\n\n/**\n * Create a GraphQL client\n *\n * @param transcendUrl - Transcend API URL\n * @param headers - Request headers to include in each request\n * @returns GraphQL client\n */\nexport function buildTranscendGraphQLClientGeneric(\n transcendUrl: string,\n headers: Record<string, string>,\n): GraphQLClient {\n // Create a GraphQL client\n return new GraphQLClient(`${transcendUrl}/graphql`, {\n headers: {\n ...headers,\n version,\n },\n });\n}\n\n/**\n * Create a GraphQL client capable of submitting requests with an API key\n *\n * @param transcendUrl - Transcend API URL\n * @param auth - API key to authenticate to API\n * @returns GraphQL client\n */\nexport function buildTranscendGraphQLClient(transcendUrl: string, auth: string): GraphQLClient {\n return buildTranscendGraphQLClientGeneric(transcendUrl, {\n Authorization: `Bearer ${auth}`,\n });\n}\n","/**\n * Sleep in a promise\n *\n * @param sleepTime - The time to sleep in milliseconds.\n * @returns Resolves promise\n */\nexport function sleepPromise(sleepTime: number): Promise<number> {\n return new Promise((resolve) => {\n setTimeout(() => resolve(sleepTime), sleepTime);\n });\n}\n","import colors from 'colors';\nimport type { GraphQLClient, RequestDocument, Variables } from 'graphql-request';\n\nimport { logger } from '../../logger.js';\nimport { sleepPromise } from '../helpers/index.js';\n\nconst MAX_RETRIES = 4;\n\nconst KNOWN_ERRORS = [\n 'syntax error',\n 'got invalid value',\n 'Client error',\n 'cannot affect row a second time',\n 'GRAPHQL_VALIDATION_FAILED',\n];\n\n/**\n * Make a GraphQL request with retries\n *\n * @param client - GraphQL client\n * @param document - document\n * @param variables - Variable\n * @param requestHeaders - Headers\n * @param maxRequests - Max number of requests\n * @returns Response\n */\nexport async function makeGraphQLRequest<T, V extends Variables = Variables>(\n client: GraphQLClient,\n document: RequestDocument,\n variables?: V,\n requestHeaders?: Record<string, string> | string[][] | Headers,\n maxRequests = MAX_RETRIES,\n): Promise<T> {\n let retryCount = 0;\n // eslint-disable-next-line no-constant-condition\n while (true) {\n try {\n const result = await client.request(document, variables, requestHeaders);\n return result as T;\n } catch (err) {\n if (err.message.includes('API key is invalid')) {\n logger.error(\n colors.red(\n 'API key is invalid. ' +\n 'Please ensure that the key provided to `transcendAuth` has the proper scope and is not expired, ' +\n 'and that `transcendUrl` corresponds to the correct backend for your organization.',\n ),\n );\n process.exit(1);\n }\n\n if (KNOWN_ERRORS.some((msg) => err.message.includes(msg))) {\n throw err;\n }\n\n // wait for rate limit to resolve\n if (err.message.startsWith('Client error: Too many requests')) {\n const rateLimitResetAt = err.response.headers?.get('x-ratelimit-reset');\n const sleepTime = rateLimitResetAt\n ? new Date(rateLimitResetAt).getTime() - new Date().getTime() + 100\n : 1000 * 10;\n logger.log(\n colors.yellow(`DETECTED RATE LIMIT: ${err.message}. Sleeping for ${sleepTime}ms`),\n );\n\n await sleepPromise(sleepTime);\n }\n\n if (retryCount >= maxRequests) {\n throw err;\n }\n retryCount += 1;\n logger.log(\n colors.yellow(`Retrying failed request (${retryCount} / ${maxRequests}): ${err.message}`),\n );\n }\n }\n}\n"],"mappings":"sJAWA,SAAgB,EACd,EACA,EACe,CAEf,OAAO,IAAI,EAAc,GAAG,EAAa,UAAW,CAClD,QAAS,CACP,GAAG,EACH,UACD,CACF,CAAC,CAUJ,SAAgB,EAA4B,EAAsB,EAA6B,CAC7F,OAAO,EAAmC,EAAc,CACtD,cAAe,UAAU,IAC1B,CAAC,CC5BJ,SAAgB,EAAa,EAAoC,CAC/D,OAAO,IAAI,QAAS,GAAY,CAC9B,eAAiB,EAAQ,EAAU,CAAE,EAAU,EAC/C,CCHJ,MAEM,EAAe,CACnB,eACA,oBACA,eACA,kCACA,4BACD,CAYD,eAAsB,EACpB,EACA,EACA,EACA,EACA,EAAc,EACF,CACZ,IAAI,EAAa,EAEjB,OACE,GAAI,CAEF,OADe,MAAM,EAAO,QAAQ,EAAU,EAAW,EAAe,OAEjE,EAAK,CAYZ,GAXI,EAAI,QAAQ,SAAS,qBAAqB,GAC5C,EAAO,MACL,EAAO,IACL,wMAGD,CACF,CACD,QAAQ,KAAK,EAAE,EAGb,EAAa,KAAM,GAAQ,EAAI,QAAQ,SAAS,EAAI,CAAC,CACvD,MAAM,EAIR,GAAI,EAAI,QAAQ,WAAW,kCAAkC,CAAE,CAC7D,IAAM,EAAmB,EAAI,SAAS,SAAS,IAAI,oBAAoB,CACjE,EAAY,EACd,IAAI,KAAK,EAAiB,CAAC,SAAS,CAAG,IAAI,MAAM,CAAC,SAAS,CAAG,IAC9D,IAAO,GACX,EAAO,IACL,EAAO,OAAO,wBAAwB,EAAI,QAAQ,iBAAiB,EAAU,IAAI,CAClF,CAED,MAAM,EAAa,EAAU,CAG/B,GAAI,GAAc,EAChB,MAAM,EAER,GAAc,EACd,EAAO,IACL,EAAO,OAAO,4BAA4B,EAAW,KAAK,EAAY,KAAK,EAAI,UAAU,CAC1F"}
@@ -1,2 +0,0 @@
1
- import{a as e}from"./constants-CeMiHaHx.mjs";import{t}from"./logger-B-LXIf3U.mjs";import{t as n}from"./bluebird-CUitXgsY.mjs";import{t as r}from"./RequestDataSilo-_Iv44M9u.mjs";import{r as i,t as a}from"./makeGraphQLRequest-Cq26A_Lq.mjs";import{t as o}from"./fetchRequestDataSilo-P4yA7Lyc.mjs";import{RequestDataSiloStatus as s}from"@transcend-io/privacy-types";import c from"colors";import l from"cli-progress";async function u({requestIds:u,dataSiloId:d,auth:f,concurrency:p=100,status:m=s.Resolved,transcendUrl:h=e}){let g=i(h,f),_=new Date().getTime(),v=new l.SingleBar({},l.Presets.shades_classic);t.info(c.magenta(`Notifying Transcend for data silo "${d}" marking "${u.length}" requests as completed.`));let y=0;v.start(u.length,0),await n(u,async e=>{let t=await o(g,{requestId:e,dataSiloId:d});try{await a(g,r,{requestDataSiloId:t.id,status:m})}catch(e){if(!e.message.includes(`Client error: Request must be active:`)&&!e.message.includes(`Failed to find RequestDataSilo`))throw e}y+=1,v.update(y)},{concurrency:p}),v.stop();let b=new Date().getTime()-_;return t.info(c.green(`Successfully notified Transcend in "${b/1e3}" seconds!`)),u.length}export{u as t};
2
- //# sourceMappingURL=markRequestDataSiloIdsCompleted-DzqJ5MNY.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markRequestDataSiloIdsCompleted-DzqJ5MNY.mjs","names":[],"sources":["../src/lib/cron/markRequestDataSiloIdsCompleted.ts"],"sourcesContent":["import { RequestDataSiloStatus } from '@transcend-io/privacy-types';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { map } from '../bluebird.js';\nimport {\n CHANGE_REQUEST_DATA_SILO_STATUS,\n fetchRequestDataSilo,\n makeGraphQLRequest,\n buildTranscendGraphQLClient,\n} from '../graphql/index.js';\n\n/**\n * Given a CSV of Request IDs, mark associated RequestDataSilos as completed\n *\n * @param options - Options\n * @returns Number of items marked as completed\n */\nexport async function markRequestDataSiloIdsCompleted({\n requestIds,\n dataSiloId,\n auth,\n concurrency = 100,\n status = RequestDataSiloStatus.Resolved,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The list of request ids to mark as completed */\n requestIds: string[];\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** Status to update requests to */\n status?: RequestDataSiloStatus;\n /** Upload concurrency */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Notify Transcend\n logger.info(\n colors.magenta(\n `Notifying Transcend for data silo \"${dataSiloId}\" marking \"${requestIds.length}\" requests as completed.`,\n ),\n );\n\n let total = 0;\n progressBar.start(requestIds.length, 0);\n await map(\n requestIds,\n async (requestId) => {\n const requestDataSilo = await fetchRequestDataSilo(client, {\n requestId,\n dataSiloId,\n });\n\n try {\n await makeGraphQLRequest<{\n /** Whether we successfully uploaded the results */\n success: boolean;\n }>(client, CHANGE_REQUEST_DATA_SILO_STATUS, {\n requestDataSiloId: requestDataSilo.id,\n status,\n });\n } catch (err) {\n if (\n !err.message.includes('Client error: Request must be active:') &&\n !err.message.includes('Failed to find RequestDataSilo')\n ) {\n throw err;\n }\n }\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(colors.green(`Successfully notified Transcend in \"${totalTime / 1000}\" seconds!`));\n return requestIds.length;\n}\n"],"mappings":"4ZAoBA,eAAsB,EAAgC,CACpD,aACA,aACA,OACA,cAAc,IACd,SAAS,EAAsB,SAC/B,eAAe,GAcG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAGrF,EAAO,KACL,EAAO,QACL,sCAAsC,EAAW,aAAa,EAAW,OAAO,0BACjF,CACF,CAED,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAW,OAAQ,EAAE,CACvC,MAAM,EACJ,EACA,KAAO,IAAc,CACnB,IAAM,EAAkB,MAAM,EAAqB,EAAQ,CACzD,YACA,aACD,CAAC,CAEF,GAAI,CACF,MAAM,EAGH,EAAQ,EAAiC,CAC1C,kBAAmB,EAAgB,GACnC,SACD,CAAC,OACK,EAAK,CACZ,GACE,CAAC,EAAI,QAAQ,SAAS,wCAAwC,EAC9D,CAAC,EAAI,QAAQ,SAAS,iCAAiC,CAEvD,MAAM,EAIV,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAGvB,OADA,EAAO,KAAK,EAAO,MAAM,uCAAuC,EAAY,IAAK,YAAY,CAAC,CACvF,EAAW"}
@@ -1,2 +0,0 @@
1
- import{a as e}from"./constants-CeMiHaHx.mjs";import{t}from"./logger-B-LXIf3U.mjs";import{t as n}from"./bluebird-CUitXgsY.mjs";import{o as r}from"./request-CAsR6CMY.mjs";import{r as i,t as a}from"./makeGraphQLRequest-Cq26A_Lq.mjs";import{r as o}from"./fetchAllRequests-DNQQsY4s.mjs";import{RequestStatus as s}from"@transcend-io/privacy-types";import c from"colors";import l from"cli-progress";async function u({requestActions:u,auth:d,requestIds:f,statuses:p=[s.Compiling,s.RequestMade,s.Delayed,s.Approving,s.Secondary,s.Enriching,s.Waiting,s.SecondaryApproving],createdAtAfter:m,createdAtBefore:h,updatedAtBefore:g,updatedAtAfter:_,concurrency:v=100,transcendUrl:y=e}){let b=i(y,d),x=new Date().getTime(),S=new l.SingleBar({},l.Presets.shades_classic),C=await o(b,{actions:u,statuses:p,createdAtBefore:h,createdAtAfter:m,updatedAtBefore:g,updatedAtAfter:_,isSilent:!1,requestIds:f});t.info(c.magenta(`Marking "${C.length}" as silent mode.`));let w=0;S.start(C.length,0),await n(C,async e=>{await a(b,r,{input:{id:e.id,isSilent:!0}}),w+=1,S.update(w)},{concurrency:v}),S.stop();let T=new Date().getTime()-x;return t.info(c.green(`Successfully marked ${w} requests as silent mode in "${T/1e3}" seconds!`)),C.length}export{u as t};
2
- //# sourceMappingURL=markSilentPrivacyRequests-BKQUu6Ep.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markSilentPrivacyRequests-BKQUu6Ep.mjs","names":[],"sources":["../src/lib/requests/markSilentPrivacyRequests.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { map } from '../bluebird.js';\nimport {\n UPDATE_PRIVACY_REQUEST,\n fetchAllRequests,\n makeGraphQLRequest,\n buildTranscendGraphQLClient,\n} from '../graphql/index.js';\n\n/**\n * Mark a set of privacy requests to be in silent mode\n *\n * @param options - Options\n * @returns The number of requests marked silent\n */\nexport async function markSilentPrivacyRequests({\n requestActions,\n auth,\n requestIds,\n statuses = [\n RequestStatus.Compiling,\n RequestStatus.RequestMade,\n RequestStatus.Delayed,\n RequestStatus.Approving,\n RequestStatus.Secondary,\n RequestStatus.Enriching,\n RequestStatus.Waiting,\n RequestStatus.SecondaryApproving,\n ],\n createdAtAfter,\n createdAtBefore,\n updatedAtBefore,\n updatedAtAfter,\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The request actions that should be restarted */\n requestActions: RequestAction[];\n /** Transcend API key authentication */\n auth: string;\n /** Concurrency limit for approving */\n concurrency?: number;\n /** The request statuses to mark silent */\n statuses?: RequestStatus[];\n /** The set of privacy requests to mark silent */\n requestIds?: string[];\n /** Filter for requests created before this date */\n createdAtBefore?: Date;\n /** Filter for requests created after this date */\n createdAtAfter?: Date;\n /** Filter for requests updated before this date */\n updatedAtBefore?: Date;\n /** Filter for requests updated after this date */\n updatedAtAfter?: Date;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Pull in the requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isSilent: false,\n requestIds,\n });\n\n // Notify Transcend\n logger.info(colors.magenta(`Marking \"${allRequests.length}\" as silent mode.`));\n\n let total = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToMarkSilent) => {\n await makeGraphQLRequest(client, UPDATE_PRIVACY_REQUEST, {\n input: {\n id: requestToMarkSilent.id,\n isSilent: true,\n },\n });\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully marked ${total} requests as silent mode in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n return allRequests.length;\n}\n"],"mappings":"wYAoBA,eAAsB,EAA0B,CAC9C,iBACA,OACA,aACA,WAAW,CACT,EAAc,UACd,EAAc,YACd,EAAc,QACd,EAAc,UACd,EAAc,UACd,EAAc,UACd,EAAc,QACd,EAAc,mBACf,CACD,iBACA,kBACA,kBACA,iBACA,cAAc,IACd,eAAe,GAsBG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAG/E,EAAc,MAAM,EAAiB,EAAQ,CACjD,QAAS,EACT,WACA,kBACA,iBACA,kBACA,iBACA,SAAU,GACV,aACD,CAAC,CAGF,EAAO,KAAK,EAAO,QAAQ,YAAY,EAAY,OAAO,mBAAmB,CAAC,CAE9E,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAY,OAAQ,EAAE,CACxC,MAAM,EACJ,EACA,KAAO,IAAwB,CAC7B,MAAM,EAAmB,EAAQ,EAAwB,CACvD,MAAO,CACL,GAAI,EAAoB,GACxB,SAAU,GACX,CACF,CAAC,CAEF,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAOvB,OALA,EAAO,KACL,EAAO,MACL,uBAAuB,EAAM,+BAA+B,EAAY,IAAK,YAC9E,CACF,CACM,EAAY"}