@transcend-io/cli 10.20.0 → 10.22.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 (166) hide show
  1. package/README.md +90 -76
  2. package/dist/{app-CwIs_xeP.mjs → app-k7HdVTDP.mjs} +18 -18
  3. package/dist/{app-CwIs_xeP.mjs.map → app-k7HdVTDP.mjs.map} +1 -1
  4. package/dist/{approvePrivacyRequests-BsNtrVwv.mjs → approvePrivacyRequests-ChRsPJuq.mjs} +2 -2
  5. package/dist/{approvePrivacyRequests-BsNtrVwv.mjs.map → approvePrivacyRequests-ChRsPJuq.mjs.map} +1 -1
  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/{buildExamples-FGTunLac.mjs → buildExamples-DVJjTfkL.mjs} +2 -2
  10. package/dist/{buildExamples-FGTunLac.mjs.map → buildExamples-DVJjTfkL.mjs.map} +1 -1
  11. package/dist/{buildXdiSyncEndpoint-DPo9Sw3F.mjs → buildXdiSyncEndpoint-CsT_eIC0.mjs} +2 -2
  12. package/dist/{buildXdiSyncEndpoint-DPo9Sw3F.mjs.map → buildXdiSyncEndpoint-CsT_eIC0.mjs.map} +1 -1
  13. package/dist/{bulkRestartRequests-iE9g9WBz.mjs → bulkRestartRequests-D_rkhYHP.mjs} +2 -2
  14. package/dist/{bulkRestartRequests-iE9g9WBz.mjs.map → bulkRestartRequests-D_rkhYHP.mjs.map} +1 -1
  15. package/dist/{bulkRetryEnrichers-DDA5OvCM.mjs → bulkRetryEnrichers-B7Y2L-9j.mjs} +2 -2
  16. package/dist/{bulkRetryEnrichers-DDA5OvCM.mjs.map → bulkRetryEnrichers-B7Y2L-9j.mjs.map} +1 -1
  17. package/dist/{cancelPrivacyRequests-SWJzauUB.mjs → cancelPrivacyRequests-DQ0FGpFC.mjs} +2 -2
  18. package/dist/{cancelPrivacyRequests-SWJzauUB.mjs.map → cancelPrivacyRequests-DQ0FGpFC.mjs.map} +1 -1
  19. package/dist/codecs-_SjJhduF.mjs +2 -0
  20. package/dist/codecs-_SjJhduF.mjs.map +1 -0
  21. package/dist/{command-Cr4p5WG-.mjs → command-Br4qaCbe.mjs} +2 -2
  22. package/dist/{command-Cr4p5WG-.mjs.map → command-Br4qaCbe.mjs.map} +1 -1
  23. package/dist/constants-CL4uZK_i.mjs +2 -0
  24. package/dist/constants-CL4uZK_i.mjs.map +1 -0
  25. package/dist/{createExtraKeyHandler-BfTP-FYM.mjs → createExtraKeyHandler-Dmf3seLV.mjs} +2 -2
  26. package/dist/{createExtraKeyHandler-BfTP-FYM.mjs.map → createExtraKeyHandler-Dmf3seLV.mjs.map} +1 -1
  27. package/dist/{downloadPrivacyRequestFiles-V9ITIuDi.mjs → downloadPrivacyRequestFiles-DZWJnqvZ.mjs} +2 -2
  28. package/dist/{downloadPrivacyRequestFiles-V9ITIuDi.mjs.map → downloadPrivacyRequestFiles-DZWJnqvZ.mjs.map} +1 -1
  29. package/dist/{enums-D53y231X.mjs → enums-BymyVyqr.mjs} +2 -2
  30. package/dist/enums-BymyVyqr.mjs.map +1 -0
  31. package/dist/{generateCrossAccountApiKeys-BjbmV5iK.mjs → generateCrossAccountApiKeys-BB_mGI0h.mjs} +2 -2
  32. package/dist/{generateCrossAccountApiKeys-BjbmV5iK.mjs.map → generateCrossAccountApiKeys-BB_mGI0h.mjs.map} +1 -1
  33. package/dist/{impl-DWRMbSmy.mjs → impl-B1-zg8Ki.mjs} +2 -2
  34. package/dist/{impl-DWRMbSmy.mjs.map → impl-B1-zg8Ki.mjs.map} +1 -1
  35. package/dist/{impl-DpkSquYY.mjs → impl-BFxef_1i.mjs} +2 -2
  36. package/dist/{impl-DpkSquYY.mjs.map → impl-BFxef_1i.mjs.map} +1 -1
  37. package/dist/{impl-CNKuWYpL2.mjs → impl-Bf0GGQao2.mjs} +2 -2
  38. package/dist/{impl-CNKuWYpL2.mjs.map → impl-Bf0GGQao2.mjs.map} +1 -1
  39. package/dist/{impl-nkCz_WoZ.mjs → impl-BvoC7ufZ.mjs} +2 -2
  40. package/dist/{impl-nkCz_WoZ.mjs.map → impl-BvoC7ufZ.mjs.map} +1 -1
  41. package/dist/{impl-Cs9AHT0v.mjs → impl-By84G6p2.mjs} +2 -2
  42. package/dist/{impl-Cs9AHT0v.mjs.map → impl-By84G6p2.mjs.map} +1 -1
  43. package/dist/{impl-BCTorB3_.mjs → impl-C515J-j7.mjs} +2 -2
  44. package/dist/{impl-BCTorB3_.mjs.map → impl-C515J-j7.mjs.map} +1 -1
  45. package/dist/{impl-B7_rAfK4.mjs → impl-C66R8UJ9.mjs} +2 -2
  46. package/dist/{impl-B7_rAfK4.mjs.map → impl-C66R8UJ9.mjs.map} +1 -1
  47. package/dist/{impl-7Nr7gpgv2.mjs → impl-CDF30pp32.mjs} +2 -2
  48. package/dist/{impl-7Nr7gpgv2.mjs.map → impl-CDF30pp32.mjs.map} +1 -1
  49. package/dist/{impl-CgIZUWGW.mjs → impl-CF8ThZ09.mjs} +2 -2
  50. package/dist/{impl-CgIZUWGW.mjs.map → impl-CF8ThZ09.mjs.map} +1 -1
  51. package/dist/{impl-CvNWIETy.mjs → impl-CHhCpncv.mjs} +2 -2
  52. package/dist/{impl-CvNWIETy.mjs.map → impl-CHhCpncv.mjs.map} +1 -1
  53. package/dist/{impl-DI1UENx5.mjs → impl-CKFy8off.mjs} +2 -2
  54. package/dist/{impl-DI1UENx5.mjs.map → impl-CKFy8off.mjs.map} +1 -1
  55. package/dist/{impl-CS5GsbS4.mjs → impl-CNqAOFaW.mjs} +2 -2
  56. package/dist/{impl-CS5GsbS4.mjs.map → impl-CNqAOFaW.mjs.map} +1 -1
  57. package/dist/{impl-j0JKrcEn.mjs → impl-CWx3bY5-.mjs} +2 -2
  58. package/dist/{impl-j0JKrcEn.mjs.map → impl-CWx3bY5-.mjs.map} +1 -1
  59. package/dist/{impl-BtYepbPW.mjs → impl-CaLW2sGU.mjs} +2 -2
  60. package/dist/{impl-BtYepbPW.mjs.map → impl-CaLW2sGU.mjs.map} +1 -1
  61. package/dist/{impl-BTP9SQTC.mjs → impl-CbqDzZgA.mjs} +2 -2
  62. package/dist/{impl-BTP9SQTC.mjs.map → impl-CbqDzZgA.mjs.map} +1 -1
  63. package/dist/{impl-BCPzfDOr.mjs → impl-ChIESsn-.mjs} +2 -2
  64. package/dist/{impl-BCPzfDOr.mjs.map → impl-ChIESsn-.mjs.map} +1 -1
  65. package/dist/{impl-DzR3gsYc.mjs → impl-CiEmNCR6.mjs} +2 -2
  66. package/dist/{impl-DzR3gsYc.mjs.map → impl-CiEmNCR6.mjs.map} +1 -1
  67. package/dist/{impl-7dSd5RHY2.mjs → impl-CkcUmrRl2.mjs} +2 -2
  68. package/dist/{impl-7dSd5RHY2.mjs.map → impl-CkcUmrRl2.mjs.map} +1 -1
  69. package/dist/{impl-q_vV3NSd.mjs → impl-D18E8wLJ.mjs} +2 -2
  70. package/dist/{impl-q_vV3NSd.mjs.map → impl-D18E8wLJ.mjs.map} +1 -1
  71. package/dist/{impl-DJAJ3NgX2.mjs → impl-D1L6r4sY2.mjs} +2 -2
  72. package/dist/{impl-DJAJ3NgX2.mjs.map → impl-D1L6r4sY2.mjs.map} +1 -1
  73. package/dist/{impl-BAAcCu2K.mjs → impl-D4DM4YMs.mjs} +2 -2
  74. package/dist/{impl-BAAcCu2K.mjs.map → impl-D4DM4YMs.mjs.map} +1 -1
  75. package/dist/{impl-CP2Musou.mjs → impl-DLQT5on0.mjs} +2 -2
  76. package/dist/{impl-CP2Musou.mjs.map → impl-DLQT5on0.mjs.map} +1 -1
  77. package/dist/{impl-umKPtZJS2.mjs → impl-DW8CteEk2.mjs} +2 -2
  78. package/dist/{impl-umKPtZJS2.mjs.map → impl-DW8CteEk2.mjs.map} +1 -1
  79. package/dist/{impl-k-AQAHRI2.mjs → impl-DaABRwZH2.mjs} +2 -2
  80. package/dist/{impl-k-AQAHRI2.mjs.map → impl-DaABRwZH2.mjs.map} +1 -1
  81. package/dist/{impl-CfRJByur.mjs → impl-DczWZLXU.mjs} +2 -2
  82. package/dist/{impl-CfRJByur.mjs.map → impl-DczWZLXU.mjs.map} +1 -1
  83. package/dist/{impl-C9ycytEX.mjs → impl-Dlq4QBj3.mjs} +2 -2
  84. package/dist/{impl-C9ycytEX.mjs.map → impl-Dlq4QBj3.mjs.map} +1 -1
  85. package/dist/{impl-BY4R2tG1.mjs → impl-DopV2WpH.mjs} +2 -2
  86. package/dist/{impl-BY4R2tG1.mjs.map → impl-DopV2WpH.mjs.map} +1 -1
  87. package/dist/{impl-tCrd3m6C.mjs → impl-DwotW3m_.mjs} +2 -2
  88. package/dist/{impl-tCrd3m6C.mjs.map → impl-DwotW3m_.mjs.map} +1 -1
  89. package/dist/{impl-vg65GYUd.mjs → impl-DysGumGV.mjs} +2 -2
  90. package/dist/{impl-vg65GYUd.mjs.map → impl-DysGumGV.mjs.map} +1 -1
  91. package/dist/{impl-lMY6fT6G.mjs → impl-HrUgz4tG.mjs} +2 -2
  92. package/dist/{impl-lMY6fT6G.mjs.map → impl-HrUgz4tG.mjs.map} +1 -1
  93. package/dist/{impl-CS4W0xxJ2.mjs → impl-L9xPwNwz2.mjs} +2 -2
  94. package/dist/{impl-CS4W0xxJ2.mjs.map → impl-L9xPwNwz2.mjs.map} +1 -1
  95. package/dist/{impl-BaJGA--D.mjs → impl-c0YrAaxs.mjs} +2 -2
  96. package/dist/{impl-BaJGA--D.mjs.map → impl-c0YrAaxs.mjs.map} +1 -1
  97. package/dist/{impl-BHZVyoUU.mjs → impl-h_KDIeo4.mjs} +2 -2
  98. package/dist/{impl-BHZVyoUU.mjs.map → impl-h_KDIeo4.mjs.map} +1 -1
  99. package/dist/{impl-4k456kRN.mjs → impl-jNQ05KT3.mjs} +2 -2
  100. package/dist/{impl-4k456kRN.mjs.map → impl-jNQ05KT3.mjs.map} +1 -1
  101. package/dist/{impl-Bjdv9HmT2.mjs → impl-lJzO6Szh2.mjs} +2 -2
  102. package/dist/{impl-Bjdv9HmT2.mjs.map → impl-lJzO6Szh2.mjs.map} +1 -1
  103. package/dist/{impl-qexLI_cv.mjs → impl-nePMEJkH.mjs} +2 -2
  104. package/dist/{impl-qexLI_cv.mjs.map → impl-nePMEJkH.mjs.map} +1 -1
  105. package/dist/{impl-DXmqDQqu2.mjs → impl-rbZRyuXb2.mjs} +2 -2
  106. package/dist/{impl-DXmqDQqu2.mjs.map → impl-rbZRyuXb2.mjs.map} +1 -1
  107. package/dist/{impl-BZMvZ-H5.mjs → impl-spb5yfh5.mjs} +2 -2
  108. package/dist/{impl-BZMvZ-H5.mjs.map → impl-spb5yfh5.mjs.map} +1 -1
  109. package/dist/{impl-459Az7fC2.mjs → impl-vUFXZXCy2.mjs} +2 -2
  110. package/dist/{impl-459Az7fC2.mjs.map → impl-vUFXZXCy2.mjs.map} +1 -1
  111. package/dist/index.d.mts +223 -17
  112. package/dist/index.d.mts.map +1 -1
  113. package/dist/index.mjs +3 -3
  114. package/dist/index.mjs.map +1 -1
  115. package/dist/{markRequestDataSiloIdsCompleted-aUZLQ4vH.mjs → markRequestDataSiloIdsCompleted-rPtNCOCl.mjs} +2 -2
  116. package/dist/{markRequestDataSiloIdsCompleted-aUZLQ4vH.mjs.map → markRequestDataSiloIdsCompleted-rPtNCOCl.mjs.map} +1 -1
  117. package/dist/{markSilentPrivacyRequests-DSymICv1.mjs → markSilentPrivacyRequests-L6fxUodG.mjs} +2 -2
  118. package/dist/{markSilentPrivacyRequests-DSymICv1.mjs.map → markSilentPrivacyRequests-L6fxUodG.mjs.map} +1 -1
  119. package/dist/{notifyPrivacyRequestsAdditionalTime-C9YqK6WF.mjs → notifyPrivacyRequestsAdditionalTime-DjzVbnND.mjs} +2 -2
  120. package/dist/{notifyPrivacyRequestsAdditionalTime-C9YqK6WF.mjs.map → notifyPrivacyRequestsAdditionalTime-DjzVbnND.mjs.map} +1 -1
  121. package/dist/parseVariablesFromString-CfXnITrG.mjs +3 -0
  122. package/dist/parseVariablesFromString-CfXnITrG.mjs.map +1 -0
  123. package/dist/{pullChunkedCustomSiloOutstandingIdentifiers-Ckh-dpAa.mjs → pullChunkedCustomSiloOutstandingIdentifiers-qZCnzDXQ.mjs} +2 -2
  124. package/dist/{pullChunkedCustomSiloOutstandingIdentifiers-Ckh-dpAa.mjs.map → pullChunkedCustomSiloOutstandingIdentifiers-qZCnzDXQ.mjs.map} +1 -1
  125. package/dist/{pullManualEnrichmentIdentifiersToCsv-gzP-wpef.mjs → pullManualEnrichmentIdentifiersToCsv-Bg1P8r4K.mjs} +2 -2
  126. package/dist/{pullManualEnrichmentIdentifiersToCsv-gzP-wpef.mjs.map → pullManualEnrichmentIdentifiersToCsv-Bg1P8r4K.mjs.map} +1 -1
  127. package/dist/pullTranscendConfiguration-BPkc-b3x.mjs +58 -0
  128. package/dist/pullTranscendConfiguration-BPkc-b3x.mjs.map +1 -0
  129. package/dist/{pushCronIdentifiersFromCsv-7M24AbQL.mjs → pushCronIdentifiersFromCsv-BJ_6eT7L.mjs} +2 -2
  130. package/dist/{pushCronIdentifiersFromCsv-7M24AbQL.mjs.map → pushCronIdentifiersFromCsv-BJ_6eT7L.mjs.map} +1 -1
  131. package/dist/{pushManualEnrichmentIdentifiersFromCsv-Bjr1td2N.mjs → pushManualEnrichmentIdentifiersFromCsv-raZJbDoH.mjs} +2 -2
  132. package/dist/{pushManualEnrichmentIdentifiersFromCsv-Bjr1td2N.mjs.map → pushManualEnrichmentIdentifiersFromCsv-raZJbDoH.mjs.map} +1 -1
  133. package/dist/{readTranscendYaml-BiOgzaYR.mjs → readTranscendYaml-B1FLjET0.mjs} +2 -2
  134. package/dist/{readTranscendYaml-BiOgzaYR.mjs.map → readTranscendYaml-B1FLjET0.mjs.map} +1 -1
  135. package/dist/{removeUnverifiedRequestIdentifiers-OZ7bu7Ru.mjs → removeUnverifiedRequestIdentifiers-D4BS0YLI.mjs} +2 -2
  136. package/dist/{removeUnverifiedRequestIdentifiers-OZ7bu7Ru.mjs.map → removeUnverifiedRequestIdentifiers-D4BS0YLI.mjs.map} +1 -1
  137. package/dist/{retryRequestDataSilos-CBQVt1KQ.mjs → retryRequestDataSilos-CBxZHU59.mjs} +2 -2
  138. package/dist/{retryRequestDataSilos-CBQVt1KQ.mjs.map → retryRequestDataSilos-CBxZHU59.mjs.map} +1 -1
  139. package/dist/{skipPreflightJobs-Bv4Aq4A8.mjs → skipPreflightJobs-mqhLTi0f.mjs} +2 -2
  140. package/dist/{skipPreflightJobs-Bv4Aq4A8.mjs.map → skipPreflightJobs-mqhLTi0f.mjs.map} +1 -1
  141. package/dist/{skipRequestDataSilos-ad1-O-VR.mjs → skipRequestDataSilos-8cK7x9K9.mjs} +2 -2
  142. package/dist/{skipRequestDataSilos-ad1-O-VR.mjs.map → skipRequestDataSilos-8cK7x9K9.mjs.map} +1 -1
  143. package/dist/{streamPrivacyRequestsToCsv-Dp2Zyy5x.mjs → streamPrivacyRequestsToCsv-CaueBxWE.mjs} +2 -2
  144. package/dist/{streamPrivacyRequestsToCsv-Dp2Zyy5x.mjs.map → streamPrivacyRequestsToCsv-CaueBxWE.mjs.map} +1 -1
  145. package/dist/{updateConsentManagerVersionToLatest-BplmLTDD.mjs → updateConsentManagerVersionToLatest-59LfKBYK.mjs} +2 -2
  146. package/dist/{updateConsentManagerVersionToLatest-BplmLTDD.mjs.map → updateConsentManagerVersionToLatest-59LfKBYK.mjs.map} +1 -1
  147. package/dist/{uploadConsents-zl9yaBjX.mjs → uploadConsents-CbPsjJ6G.mjs} +2 -2
  148. package/dist/{uploadConsents-zl9yaBjX.mjs.map → uploadConsents-CbPsjJ6G.mjs.map} +1 -1
  149. package/dist/{uploadCookiesFromCsv-B8Ast_0y.mjs → uploadCookiesFromCsv-DhDzLqvx.mjs} +2 -2
  150. package/dist/{uploadCookiesFromCsv-B8Ast_0y.mjs.map → uploadCookiesFromCsv-DhDzLqvx.mjs.map} +1 -1
  151. package/dist/{uploadDataFlowsFromCsv-DY_dmUdU.mjs → uploadDataFlowsFromCsv-Ca4JrvEd.mjs} +2 -2
  152. package/dist/{uploadDataFlowsFromCsv-DY_dmUdU.mjs.map → uploadDataFlowsFromCsv-Ca4JrvEd.mjs.map} +1 -1
  153. package/dist/{uploadPrivacyRequestsFromCsv-CzZCVwFV.mjs → uploadPrivacyRequestsFromCsv-CprxpH-W.mjs} +2 -2
  154. package/dist/{uploadPrivacyRequestsFromCsv-CzZCVwFV.mjs.map → uploadPrivacyRequestsFromCsv-CprxpH-W.mjs.map} +1 -1
  155. package/dist/{validateTranscendAuth-B_EFnL1A.mjs → validateTranscendAuth-D14jsB5C.mjs} +2 -2
  156. package/dist/{validateTranscendAuth-B_EFnL1A.mjs.map → validateTranscendAuth-D14jsB5C.mjs.map} +1 -1
  157. package/package.json +4 -4
  158. package/dist/codecs-CfHvcMSL.mjs +0 -2
  159. package/dist/codecs-CfHvcMSL.mjs.map +0 -1
  160. package/dist/constants-Cb9QI4yq.mjs +0 -2
  161. package/dist/constants-Cb9QI4yq.mjs.map +0 -1
  162. package/dist/enums-D53y231X.mjs.map +0 -1
  163. package/dist/parseVariablesFromString-C2SbrKX5.mjs +0 -3
  164. package/dist/parseVariablesFromString-C2SbrKX5.mjs.map +0 -1
  165. package/dist/pullTranscendConfiguration-B8mxJCi7.mjs +0 -58
  166. package/dist/pullTranscendConfiguration-B8mxJCi7.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseVariablesFromString-CfXnITrG.mjs","names":[],"sources":["../src/lib/preference-management/validatePreferenceManagementSlugs.ts","../src/lib/graphql/ensureAllDataSubjectsExist.ts","../src/lib/graphql/syncDataSilos.ts","../src/lib/graphql/syncConfigurationToTranscend.ts","../src/lib/mergeTranscendInputs.ts","../src/lib/helpers/parseVariablesFromString.ts"],"sourcesContent":["import type { TranscendInput } from '../../codecs.js';\n\n/** Slugs for preference topics and option values must be alphabetical letters only. */\nexport const PREFERENCE_SLUG_REGEX = /^[A-Za-z]+$/;\n\n/**\n * Validate preference topic and option value slugs before push.\n *\n * @param input - Parsed transcend.yml input\n * @returns List of validation error messages (empty when valid)\n */\nexport function validatePreferenceManagementSlugs(input: TranscendInput): string[] {\n const errors: string[] = [];\n\n const validateSlug = (slug: string, context: string): void => {\n if (!PREFERENCE_SLUG_REGEX.test(slug)) {\n errors.push(\n `${context}: slug \"${slug}\" is invalid — slugs must contain only alphabetical letters (A-Z, a-z). ` +\n 'Topic slugs are normalized to PascalCase server-side, so YAML slugs should already be PascalCase ' +\n 'or matching will break on subsequent pulls.',\n );\n }\n };\n\n for (const option of input['preference-options'] ?? []) {\n validateSlug(option.slug, 'preference-options');\n }\n\n for (const purpose of input.purposes ?? []) {\n for (const topic of purpose['preference-topics'] ?? []) {\n validateSlug(topic.slug, `purposes (topic \"${topic.title}\")`);\n for (const option of topic.options ?? []) {\n validateSlug(option.slug, `purposes (topic \"${topic.title}\" option \"${option.title}\")`);\n }\n }\n }\n\n return errors;\n}\n","import { createDataSubject, fetchAllDataSubjects, type DataSubject } from '@transcend-io/sdk';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\nimport { keyBy, flatten, uniq, difference } from 'lodash-es';\n\nimport { TranscendInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\n\n/**\n * Fetch all of the data subjects in the organization\n *\n * @param input - Input to fetch\n * @param client - GraphQL client\n * @param fetchAll - When true, always fetch all subjects\n * @returns The list of data subjects\n */\nexport async function ensureAllDataSubjectsExist(\n {\n 'data-silos': dataSilos = [],\n 'data-subjects': dataSubjects = [],\n 'processing-activities': processingActivities = [],\n enrichers = [],\n }: TranscendInput,\n client: GraphQLClient,\n fetchAll = false,\n): Promise<{ [type in string]: DataSubject }> {\n const expectedDataSubjects = uniq([\n ...flatten(dataSilos.map((silo) => silo['data-subjects'] || []) || []),\n ...flatten(processingActivities.map(({ dataSubjectTypes }) => dataSubjectTypes ?? []) ?? []),\n ...flatten(enrichers.map((enricher) => enricher['data-subjects'] || []) || []),\n ...dataSubjects.map((subject) => subject.type),\n ]);\n if (expectedDataSubjects.length === 0 && !fetchAll) {\n return {};\n }\n\n const internalSubjects = await fetchAllDataSubjects(client, { logger });\n const dataSubjectByName = keyBy(internalSubjects, 'type');\n\n const missingDataSubjects = difference(\n expectedDataSubjects,\n internalSubjects.map(({ type }) => type),\n );\n\n if (missingDataSubjects.length > 0) {\n logger.info(colors.magenta(`Creating ${missingDataSubjects.length} new data subjects...`));\n for (const dataSubjectType of missingDataSubjects) {\n logger.info(colors.magenta(`Creating data subject ${dataSubjectType}...`));\n const created = await createDataSubject(client, { input: dataSubjectType, logger });\n logger.info(colors.green(`Created data subject ${dataSubjectType}!`));\n dataSubjectByName[dataSubjectType] = created;\n }\n }\n\n return dataSubjectByName;\n}\n","import {\n makeGraphQLRequest,\n ApiKey,\n convertToDataSubjectBlockList,\n type DataSubject,\n fetchAllDataSilos,\n type DataSilo,\n CREATE_DATA_SILOS,\n UPDATE_DATA_SILOS,\n UPDATE_OR_CREATE_DATA_POINT,\n} from '@transcend-io/sdk';\nimport { apply } from '@transcend-io/type-utils';\nimport { mapSeries, map } from '@transcend-io/utils';\n/* eslint-disable max-lines */\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\nimport { chunk, keyBy } from 'lodash-es';\n\nimport { DataSiloInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\n\nconst BATCH_SILOS_LIMIT = 20;\n\n/**\n * Sync a data silo configuration\n *\n * @param dataSilos - Data silos to sync\n * @param client - GraphQL client\n * @param options - Options\n * @returns Data silo info\n */\nexport async function syncDataSilos(\n dataSilos: DataSiloInput[],\n client: GraphQLClient,\n {\n pageSize,\n dataSubjectsByName,\n apiKeysByTitle,\n }: {\n /** Page size */\n pageSize: number;\n /** The data subjects in the organization */\n dataSubjectsByName: { [type in string]: DataSubject };\n /** API key title to API key */\n apiKeysByTitle: { [title in string]: ApiKey };\n },\n): Promise<{\n /** Whether successfully updated */\n success: boolean;\n /** A mapping between data silo title to data silo ID */\n dataSiloTitleToId: { [k in string]: string };\n}> {\n let encounteredError = false;\n\n // Time duration\n const t0 = new Date().getTime();\n logger.info(colors.magenta(`Syncing \"${dataSilos.length}\" data silos...`));\n\n // Determine the set of data silos that already exist\n const existingDataSilos = await fetchAllDataSilos(client, {\n titles: dataSilos.map(({ title }) => title),\n pageSize,\n logger,\n });\n\n // Create a mapping of title -> existing silo, if it exists\n const existingDataSiloByTitle = keyBy<Pick<DataSilo, 'id' | 'title'>>(existingDataSilos, 'title');\n\n // Create new silos that do not exist\n const newDataSiloInputs = dataSilos.filter(({ title }) => !existingDataSiloByTitle[title]);\n if (newDataSiloInputs.length > 0) {\n logger.info(\n colors.magenta(`Creating \"${newDataSiloInputs.length}\" data silos that did not exist...`),\n );\n\n // Batch the creation\n const chunked = chunk(newDataSiloInputs, BATCH_SILOS_LIMIT);\n await mapSeries(chunked, async (dependencyUpdateChunk) => {\n const {\n createDataSilos: { dataSilos },\n } = await makeGraphQLRequest<{\n /** Mutation result */\n createDataSilos: {\n /** New data silos */\n dataSilos: Pick<DataSilo, 'id' | 'title'>[];\n };\n }>(client, CREATE_DATA_SILOS, {\n variables: {\n input: dependencyUpdateChunk.map((input) => ({\n name: input['outer-type'] || input.integrationName,\n title: input.title,\n country: input.country,\n countrySubDivision: input.countrySubDivision,\n sombraId: input['sombra-id'],\n })),\n },\n logger,\n });\n\n // save mapping of title and id\n dataSilos.forEach((silo) => {\n existingDataSiloByTitle[silo.title] = silo;\n });\n });\n\n logger.info(colors.green(`Successfully created \"${newDataSiloInputs.length}\" data silos!`));\n }\n\n // Batch the updates\n const chunkedUpdates = chunk(dataSilos, BATCH_SILOS_LIMIT);\n await mapSeries(chunkedUpdates, async (dataSiloUpdateChunk, ind) => {\n logger.info(\n colors.magenta(\n `[Batch ${ind + 1}/${chunkedUpdates.length}] Syncing \"${\n dataSiloUpdateChunk.length\n }\" data silos`,\n ),\n );\n await makeGraphQLRequest<{\n /** Mutation result */\n updateDataSilos: {\n /** New data silos */\n dataSilos: Pick<DataSilo, 'id' | 'title'>[];\n };\n }>(client, UPDATE_DATA_SILOS, {\n variables: {\n input: {\n dataSilos: dataSiloUpdateChunk.map((input) => ({\n id: existingDataSiloByTitle[input.title].id,\n country: input.country,\n countrySubDivision: input.countrySubDivision,\n url: input.url,\n headers: input.headers,\n description: input.description,\n identifiers: input['identity-keys'],\n isLive: !input.disabled,\n ownerEmails: input.owners,\n teamNames: input.teams,\n // clear out if not specified, otherwise the update needs to be applied after\n // all data silos are created\n dependedOnDataSiloTitles: input['deletion-dependencies'] ? undefined : [],\n apiKeyId: input['api-key-title']\n ? apiKeysByTitle[input['api-key-title']].id\n : undefined,\n dataSubjectBlockListIds: input['data-subjects']\n ? convertToDataSubjectBlockList(input['data-subjects'], dataSubjectsByName)\n : undefined,\n attributes: input.attributes,\n businessEntityTitles: input.businessEntityTitles,\n sombraId: input['sombra-id'],\n // AVC settings\n notifyEmailAddress: input['email-settings']?.['notify-email-address'],\n promptAVendorEmailSendFrequency: input['email-settings']?.['send-frequency'],\n promptAVendorEmailSendType: input['email-settings']?.['send-type'],\n promptAVendorEmailIncludeIdentifiersAttachment:\n input['email-settings']?.['include-identifiers-attachment'],\n promptAVendorEmailCompletionLinkType: input['email-settings']?.['completion-link-type'],\n manualWorkRetryFrequency: input['email-settings']?.['manual-work-retry-frequency'],\n })),\n },\n },\n logger,\n });\n logger.info(\n colors.green(\n `[Batch ${ind + 1}/${chunkedUpdates.length}] Synced \"${\n dataSiloUpdateChunk.length\n }\" data silos!`,\n ),\n );\n });\n\n // Sync datapoints\n\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n const dataSilosWithDataPoints = dataSilos.filter(({ datapoints = [] }) => datapoints.length > 0);\n const totalDataPoints = dataSilos\n .map(({ datapoints = [] }) => datapoints.length)\n .reduce((acc, count) => acc + count, 0);\n logger.info(\n colors.magenta(\n `Syncing \"${totalDataPoints}\" datapoints from \"${dataSilosWithDataPoints.length}\" data silos...`,\n ),\n );\n progressBar.start(totalDataPoints, 0);\n let total = 0;\n\n await map(\n dataSilosWithDataPoints,\n async ({ datapoints, title }) => {\n if (datapoints) {\n await mapSeries(datapoints, async (datapoint) => {\n const fields = datapoint.fields\n ? datapoint.fields.map(\n ({ key, description, categories, purposes, attributes, ...rest }) =>\n // TODO: Support setting title separately from the 'key/name'\n ({\n name: key,\n description,\n categories: !categories\n ? undefined\n : categories.map((category) => ({\n ...category,\n name: category.name || 'Other',\n })),\n purposes: !purposes\n ? undefined\n : purposes.map((purpose) => ({\n ...purpose,\n name: purpose.name || 'Other',\n })),\n attributes,\n accessRequestVisibilityEnabled: rest['access-request-visibility-enabled'],\n erasureRequestRedactionEnabled: rest['erasure-request-redaction-enabled'],\n }),\n )\n : undefined;\n\n const payload = {\n dataSiloId: existingDataSiloByTitle[title].id,\n path: datapoint.path,\n name: datapoint.key,\n title: datapoint.title,\n description: datapoint.description,\n ...(datapoint.owners\n ? {\n ownerEmails: datapoint.owners,\n }\n : {}),\n ...(datapoint.teams\n ? {\n teamNames: datapoint.teams,\n }\n : {}),\n ...(datapoint['data-collection-tag']\n ? { dataCollectionTag: datapoint['data-collection-tag'] }\n : {}),\n querySuggestions: !datapoint['privacy-action-queries']\n ? undefined\n : Object.entries(datapoint['privacy-action-queries']).map(([key, value]) => ({\n requestType: key,\n suggestedQuery: value,\n })),\n enabledActions: datapoint['privacy-actions'] || [], // clear out when not specified\n subDataPoints: fields,\n };\n\n // Ensure no duplicate sub-datapoints are provided\n const subDataPointsToUpdate = (payload.subDataPoints || []).map(({ name }) => name);\n const duplicateDataPoints = subDataPointsToUpdate.filter(\n (name, index) => subDataPointsToUpdate.indexOf(name) !== index,\n );\n if (duplicateDataPoints.length > 0) {\n logger.info(\n colors.red(\n `\\nCannot update datapoint \"${\n datapoint.key\n }\" as it has duplicate sub-datapoints with the same name: \\n${duplicateDataPoints.join(\n '\\n',\n )}`,\n ),\n );\n encounteredError = true;\n } else {\n try {\n await makeGraphQLRequest(client, UPDATE_OR_CREATE_DATA_POINT, {\n variables: payload,\n logger,\n });\n } catch (err) {\n logger.info(\n colors.red(\n `\\nFailed to update datapoint \"${datapoint.key}\" for data silo \"${title}\"! - \\n${err.message}`,\n ),\n );\n encounteredError = true;\n }\n }\n total += 1;\n progressBar.update(total);\n });\n }\n },\n {\n concurrency: 10,\n },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Synced \"${dataSilos.length}\" data silos and \"${totalDataPoints}\" datapoints in \"${\n totalTime / 1000\n }\" seconds!`,\n ),\n );\n return {\n success: !encounteredError,\n dataSiloTitleToId: apply(existingDataSiloByTitle, ({ id }) => id),\n };\n}\n/* eslint-enable max-lines */\n","import {\n fetchAllActions,\n fetchAllAttributes,\n fetchAllDataSubjects,\n fetchApiKeys,\n fetchIdentifiersAndCreateMissing,\n syncAction,\n syncActionItemCollections,\n syncActionItems,\n syncAgentFiles,\n syncAgentFunctions,\n syncAgents,\n syncAttribute,\n syncBusinessEntities,\n syncDataCategories,\n syncConsentManager,\n syncCookies,\n syncDataFlows,\n syncDataSubject,\n syncDataSiloDependencies,\n syncEnricher,\n syncIdentifier,\n syncIntlMessages,\n syncPartitions,\n syncPolicies,\n syncPrivacyCenter,\n syncProcessingActivities,\n syncProcessingPurposes,\n syncPromptGroups,\n syncPromptPartials,\n syncPrompts,\n syncConsentWorkflowTriggers,\n syncWorkflowConfigs,\n syncPreferenceOptionValues,\n syncPurposes,\n syncPreferenceTopics,\n syncTeams,\n syncTemplate,\n syncVendors,\n type Identifier,\n} from '@transcend-io/sdk';\nimport { map, type Logger, type SyncError, type SyncResult } from '@transcend-io/utils';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\n\n/* eslint-disable max-lines */\nimport { TranscendInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\nimport { validatePreferenceManagementSlugs } from '../preference-management/validatePreferenceManagementSlugs.js';\nimport { ensureAllDataSubjectsExist } from './ensureAllDataSubjectsExist.js';\nimport { syncDataSilos } from './syncDataSilos.js';\n\nconst CONCURRENCY = 10;\n\n/**\n * Sync the yaml input back to Transcend using the GraphQL APIs\n *\n * @param input - The yml input\n * @param client - GraphQL client\n * @param pageSize - Page size\n * @returns Structured sync result with per-resource errors\n */\nexport async function syncConfigurationToTranscend(\n input: TranscendInput,\n client: GraphQLClient,\n {\n pageSize = 50,\n // TODO: https://transcend.height.app/T-23779\n publishToPrivacyCenter = true,\n classifyService = false,\n deleteExtraAttributeValues = false,\n logger: syncLogger,\n warnings = [],\n }: {\n /** Page size */\n pageSize?: number;\n /** When true, skip publishing to privacy center */\n publishToPrivacyCenter?: boolean;\n /** When true, delete any attributes being synced up */\n deleteExtraAttributeValues?: boolean;\n /** classify data flow service if missing */\n classifyService?: boolean;\n /** Optional logger (e.g. collecting logger for MCP debug responses) */\n logger?: Logger;\n /** Non-fatal warnings to include in the result */\n warnings?: string[];\n },\n): Promise<SyncResult> {\n const activeLogger = syncLogger ?? logger;\n const errors: SyncError[] = [];\n let encounteredError = false;\n\n const recordError = (resource: string, message: string, item?: string): void => {\n errors.push({ resource, item, message });\n encounteredError = true;\n };\n\n activeLogger.info(colors.magenta(`Fetching data with page size ${pageSize}...`));\n\n const {\n templates,\n attributes,\n actions,\n identifiers,\n 'data-subjects': dataSubjects,\n 'business-entities': businessEntities,\n enrichers,\n cookies,\n 'consent-manager': consentManager,\n 'data-silos': dataSilos,\n 'data-flows': dataFlows,\n prompts,\n 'prompt-groups': promptGroups,\n 'prompt-partials': promptPartials,\n agents,\n 'agent-functions': agentFunctions,\n 'agent-files': agentFiles,\n vendors,\n 'data-categories': dataCategories,\n 'processing-activities': processingActivities,\n 'processing-purposes': processingPurposes,\n 'action-items': actionItems,\n 'action-item-collections': actionItemCollections,\n teams,\n 'privacy-center': privacyCenter,\n messages,\n policies,\n partitions,\n 'preference-workflow-configs': preferenceWorkflowConfigs,\n 'workflow-configs': workflowConfigs,\n } = input;\n\n const preferenceOptions = input['preference-options'];\n const purposes = input.purposes;\n\n const preferenceSlugErrors = validatePreferenceManagementSlugs(input);\n if (preferenceSlugErrors.length > 0) {\n for (const message of preferenceSlugErrors) {\n recordError('preference-slugs', message);\n }\n return {\n success: false,\n errors,\n warnings: warnings.length > 0 ? warnings : undefined,\n };\n }\n\n const [identifierByName, dataSubjectsByName, apiKeyTitleMap] = await Promise.all([\n // Ensure all identifiers are created and create a map from name -> identifier.id\n enrichers || identifiers\n ? fetchIdentifiersAndCreateMissing(client, {\n input,\n skipPublish: !publishToPrivacyCenter,\n logger,\n })\n : ({} as { [k in string]: Identifier }),\n // Grab all data subjects in the organization\n dataSilos || dataSubjects || enrichers || processingActivities\n ? ensureAllDataSubjectsExist(input, client)\n : {},\n // Grab API keys\n dataSilos &&\n dataSilos\n .map((dataSilo) => dataSilo['api-key-title'] || [])\n .reduce((acc, lst) => acc + lst.length, 0) > 0\n ? fetchApiKeys(client, { apiKeyInputs: input, logger })\n : {},\n ]);\n\n if (preferenceWorkflowConfigs?.length) {\n const preferenceWorkflowConfigsSuccess = await syncConsentWorkflowTriggers(\n client,\n preferenceWorkflowConfigs,\n {\n logger: activeLogger,\n pageSize,\n },\n );\n if (!preferenceWorkflowConfigsSuccess) {\n recordError('preference-workflow-configs', 'Failed to sync preference workflow configs');\n }\n }\n\n if (workflowConfigs?.length) {\n const workflowConfigsSuccess = await syncWorkflowConfigs(client, workflowConfigs, {\n logger: activeLogger,\n });\n if (!workflowConfigsSuccess) {\n recordError('workflow-configs', 'Failed to sync workflow configs');\n }\n }\n\n if (preferenceOptions?.length) {\n const preferenceOptionsSuccess = await syncPreferenceOptionValues(client, preferenceOptions, {\n logger: activeLogger,\n });\n if (!preferenceOptionsSuccess) {\n recordError('preference-options', 'Failed to sync preference option values');\n }\n }\n\n // Sync consent purposes and their nested preference topics.\n // Order matters: option values (above) exist first, then purposes, then topics\n // (which link to their purpose by ID and to option values by slug).\n if (purposes?.length) {\n const { success: purposesSuccess, purposeIdByTrackingType } = await syncPurposes(\n client,\n purposes,\n { logger: activeLogger },\n );\n if (!purposesSuccess) {\n recordError('purposes', 'Failed to sync one or more purposes');\n }\n\n const topics = purposes.flatMap((purpose) =>\n (purpose['preference-topics'] ?? []).map((topic) => ({\n ...topic,\n 'tracking-type': purpose.trackingType,\n })),\n );\n if (topics.length > 0) {\n const topicsSuccess = await syncPreferenceTopics(client, topics, {\n logger: activeLogger,\n purposeIdByTrackingType,\n });\n if (!topicsSuccess) {\n recordError('preference-topics', 'Failed to sync one or more preference topics');\n }\n }\n }\n\n // Sync consent manager\n if (consentManager) {\n activeLogger.info(colors.magenta('Syncing consent manager...'));\n try {\n await syncConsentManager(client, consentManager, { logger: activeLogger });\n activeLogger.info(colors.green('Successfully synced consent manager!'));\n } catch (err) {\n recordError('consent-manager', (err as Error).message);\n activeLogger.error(colors.red(`Failed to sync consent manager! - ${(err as Error).message}`));\n }\n }\n\n // Sync prompts\n if (prompts) {\n const promptsSuccess = await syncPrompts(client, prompts, { logger });\n encounteredError = encounteredError || !promptsSuccess;\n }\n if (promptPartials) {\n const promptsSuccess = await syncPromptPartials(client, promptPartials, { logger });\n encounteredError = encounteredError || !promptsSuccess;\n }\n if (promptGroups) {\n const promptsSuccess = await syncPromptGroups(client, promptGroups, { logger });\n encounteredError = encounteredError || !promptsSuccess;\n }\n\n if (teams) {\n const teamsSuccess = await syncTeams(client, teams, { logger });\n encounteredError = encounteredError || !teamsSuccess;\n }\n\n // Sync email templates\n if (templates) {\n logger.info(colors.magenta(`Syncing \"${templates.length}\" email templates...`));\n await map(\n templates,\n async (template) => {\n logger.info(colors.magenta(`Syncing template \"${template.title}\"...`));\n try {\n await syncTemplate(client, template, { logger });\n logger.info(colors.green(`Successfully synced template \"${template.title}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.error(colors.red(`Failed to sync template \"${template.title}\"! - ${err.message}`));\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${templates.length}\" email templates!`));\n }\n\n // Sync business entities\n if (businessEntities) {\n const businessEntitySuccess = await syncBusinessEntities(client, businessEntities, { logger });\n encounteredError = encounteredError || !businessEntitySuccess;\n }\n\n // Sync vendors\n if (vendors) {\n const vendorsSuccess = await syncVendors(client, vendors, { logger });\n encounteredError = encounteredError || !vendorsSuccess;\n }\n\n // Sync data categories\n if (dataCategories) {\n const dataCategoriesSuccess = await syncDataCategories(client, dataCategories, { logger });\n encounteredError = encounteredError || !dataCategoriesSuccess;\n }\n\n // Sync processing purposes\n if (processingPurposes) {\n const processingPurposesSuccess = await syncProcessingPurposes(client, processingPurposes, {\n logger,\n });\n encounteredError = encounteredError || !processingPurposesSuccess;\n }\n\n // Sync partitions\n if (partitions) {\n const partitionsSuccess = await syncPartitions(client, partitions, { logger });\n encounteredError = encounteredError || !partitionsSuccess;\n }\n\n // Sync agents\n if (agents) {\n const agentsSuccess = await syncAgents(client, agents, { logger });\n encounteredError = encounteredError || !agentsSuccess;\n }\n\n // Sync agent functions\n if (agentFunctions) {\n const agentFunctionsSuccess = await syncAgentFunctions(client, agentFunctions, { logger });\n encounteredError = encounteredError || !agentFunctionsSuccess;\n }\n\n // Sync agent files\n if (agentFiles) {\n const agentFilesSuccess = await syncAgentFiles(client, agentFiles, { logger });\n encounteredError = encounteredError || !agentFilesSuccess;\n }\n\n // Sync cookies\n if (cookies) {\n const cookiesSuccess = await syncCookies(client, cookies, { logger });\n encounteredError = encounteredError || !cookiesSuccess;\n }\n\n // Sync action item collections\n if (actionItemCollections) {\n const actionItemCollectionsSuccess = await syncActionItemCollections(\n client,\n actionItemCollections,\n { logger },\n );\n encounteredError = encounteredError || !actionItemCollectionsSuccess;\n }\n\n // Sync attributes\n if (attributes) {\n // Fetch existing\n logger.info(colors.magenta(`Syncing \"${attributes.length}\" attributes...`));\n const existingAttributes = await fetchAllAttributes(client, { logger });\n await map(\n attributes,\n async (attribute) => {\n const existing = existingAttributes.find((attr) => attr.name === attribute.name);\n\n logger.info(colors.magenta(`Syncing attribute \"${attribute.name}\"...`));\n try {\n await syncAttribute(client, attribute, {\n existingAttribute: existing,\n deleteExtraAttributeValues,\n logger,\n });\n logger.info(colors.green(`Successfully synced attribute \"${attribute.name}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.error(\n colors.red(`Failed to sync attribute \"${attribute.name}\"! - ${err.message}`),\n );\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${attributes.length}\" attributes!`));\n }\n\n // Sync action items\n if (actionItems) {\n const actionItemsSuccess = await syncActionItems(client, actionItems, { logger });\n encounteredError = encounteredError || !actionItemsSuccess;\n }\n\n // Sync enrichers\n if (enrichers) {\n logger.info(colors.magenta(`Syncing \"${enrichers.length}\" enrichers...`));\n await map(\n enrichers,\n async (enricher) => {\n logger.info(colors.magenta(`Syncing enricher \"${enricher.title}\"...`));\n try {\n await syncEnricher(client, {\n input: enricher,\n identifierByName,\n dataSubjectsByName,\n logger,\n });\n logger.info(colors.green(`Successfully synced enricher \"${enricher.title}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.error(colors.red(`Failed to sync enricher \"${enricher.title}\"! - ${err.message}`));\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${enrichers.length}\" enrichers!`));\n }\n\n // Sync identifiers\n if (identifiers) {\n // Fetch existing\n logger.info(colors.magenta(`Syncing \"${identifiers.length}\" identifiers...`));\n await map(\n identifiers,\n async (identifier) => {\n const existing = identifierByName[identifier.name];\n if (!existing) {\n throw new Error(\n `Failed to find identifier with name: ${identifier.type}. Should have been auto-created by cli.`,\n );\n }\n\n logger.info(colors.magenta(`Syncing identifier \"${identifier.type}\"...`));\n try {\n await syncIdentifier(client, {\n input: identifier,\n dataSubjectsByName,\n identifierId: existing.id,\n skipPublish: !publishToPrivacyCenter,\n logger,\n });\n logger.info(colors.green(`Successfully synced identifier \"${identifier.type}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.info(\n colors.red(`Failed to sync identifier \"${identifier.type}\"! - ${err.message}`),\n );\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${identifiers.length}\" identifiers!`));\n }\n\n // Sync actions\n if (actions) {\n // Fetch existing\n logger.info(colors.magenta(`Syncing \"${actions.length}\" actions...`));\n const existingActions = await fetchAllActions(client, { logger });\n await map(\n actions,\n async (action) => {\n const existing = existingActions.find((act) => act.type === action.type);\n if (!existing) {\n throw new Error(\n `Failed to find action with type: ${action.type}. Should have already existing in the organization.`,\n );\n }\n\n logger.info(colors.magenta(`Syncing action \"${action.type}\"...`));\n try {\n await syncAction(\n client,\n {\n action,\n actionId: existing.id,\n skipPublish: !publishToPrivacyCenter,\n },\n { logger },\n );\n logger.info(colors.green(`Successfully synced action \"${action.type}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.error(colors.red(`Failed to sync action \"${action.type}\"! - ${err.message}`));\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${actions.length}\" actions!`));\n }\n\n // Sync data subjects\n if (dataSubjects) {\n // Fetch existing\n logger.info(colors.magenta(`Syncing \"${dataSubjects.length}\" data subjects...`));\n const existingDataSubjects = await fetchAllDataSubjects(client, { logger });\n await map(\n dataSubjects,\n async (dataSubject) => {\n const existing = existingDataSubjects.find((subj) => subj.type === dataSubject.type);\n if (!existing) {\n throw new Error(\n `Failed to find data subject with type: ${dataSubject.type}. Should have already existing in the organization.`,\n );\n }\n\n logger.info(colors.magenta(`Syncing data subject \"${dataSubject.type}\"...`));\n try {\n await syncDataSubject(client, {\n input: dataSubject,\n dataSubjectId: existing.id,\n skipPublish: !publishToPrivacyCenter,\n logger,\n });\n logger.info(colors.green(`Successfully synced data subject \"${dataSubject.type}\"!`));\n } catch (err) {\n encounteredError = true;\n logger.info(\n colors.red(`Failed to sync data subject \"${dataSubject.type}\"! - ${err.message}`),\n );\n }\n },\n {\n concurrency: CONCURRENCY,\n },\n );\n logger.info(colors.green(`Synced \"${dataSubjects.length}\" data subjects!`));\n }\n\n // Sync data flows\n if (dataFlows) {\n const syncedDataFlows = await syncDataFlows(client, dataFlows, { classifyService, logger });\n encounteredError = encounteredError || !syncedDataFlows;\n }\n\n // Sync privacy center\n if (privacyCenter) {\n try {\n const privacyCenterSuccess = await syncPrivacyCenter(client, privacyCenter, {\n logger,\n skipPublish: !publishToPrivacyCenter,\n });\n if (!privacyCenterSuccess) {\n recordError('privacy-center', 'Failed to sync privacy center');\n }\n } catch (err) {\n recordError('privacy-center', (err as Error).message);\n }\n }\n\n // Sync messages\n if (messages) {\n const messagesSuccess = await syncIntlMessages(client, messages, { logger });\n encounteredError = encounteredError || !messagesSuccess;\n }\n\n // Sync policies\n if (policies) {\n const policiesSuccess = await syncPolicies(client, policies, { logger });\n encounteredError = encounteredError || !policiesSuccess;\n }\n\n // Store dependency updates\n const dependencyUpdates: [string, string[]][] = [];\n // Sync data silos\n if (dataSilos) {\n const { success, dataSiloTitleToId } = await syncDataSilos(dataSilos, client, {\n dataSubjectsByName,\n apiKeysByTitle: apiKeyTitleMap,\n pageSize,\n });\n dataSilos?.forEach((dataSilo) => {\n // Queue up dependency update\n if (dataSilo['deletion-dependencies']) {\n dependencyUpdates.push([\n dataSiloTitleToId[dataSilo.title],\n dataSilo['deletion-dependencies'],\n ]);\n }\n });\n encounteredError = encounteredError || !success;\n }\n\n // Dependencies updated at the end after all data silos are created\n if (dependencyUpdates.length > 0) {\n await syncDataSiloDependencies(client, { input: dependencyUpdates, logger });\n }\n\n // Update processing activities\n if (processingActivities) {\n const processingActivitySuccess = await syncProcessingActivities(client, processingActivities, {\n logger,\n });\n encounteredError = encounteredError || !processingActivitySuccess;\n }\n\n if (publishToPrivacyCenter) {\n // TODO: https://transcend.height.app/T-23779\n }\n\n return {\n success: !encounteredError,\n errors,\n warnings: warnings.length > 0 ? warnings : undefined,\n };\n}\n/* eslint-enable max-lines */\n","import { getEntries } from '@transcend-io/type-utils';\n\nimport { TranscendInput } from '../codecs.js';\n\n/**\n * Combine a set of TranscendInput yaml files into a single yaml\n *\n * @param base - Base input\n * @param inputs - The list of inputs\n * @returns Merged input\n */\nexport function mergeTranscendInputs(\n base: TranscendInput,\n ...inputs: TranscendInput[]\n): TranscendInput {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const cloned: any = JSON.parse(JSON.stringify(base));\n inputs.forEach((input) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getEntries(input).forEach(([key, value]: [any, any]) => {\n if (cloned[key] === undefined) {\n cloned[key] = value;\n } else if (Array.isArray(value)) {\n cloned[key] = [...cloned[key], ...value];\n } else {\n cloned[key] = value;\n }\n });\n });\n return cloned;\n}\n","/**\n * Parse variables from string\n *\n * @param variables - Variables as string\n * @returns Variables as object\n */\nexport function parseVariablesFromString(variables: string): {\n [k in string]: string;\n} {\n // Parse out the variables\n const splitVars = variables.split(',').filter((x) => !!x);\n const vars: { [k in string]: string } = {};\n splitVars.forEach((variable) => {\n const [k, v] = variable.split(':');\n if (!k || !v) {\n throw new Error(`Invalid variable: ${variable}. Expected format: key:value`);\n }\n vars[k] = v;\n });\n return vars;\n}\n"],"mappings":"03CAGA,MAAa,EAAwB,cAQrC,SAAgB,GAAkC,EAAiC,CACjF,IAAM,EAAmB,EAAE,CAErB,GAAgB,EAAc,IAA0B,CACvD,EAAsB,KAAK,EAAK,EACnC,EAAO,KACL,GAAG,EAAQ,UAAU,EAAK,sNAG3B,EAIL,IAAK,IAAM,KAAU,EAAM,uBAAyB,EAAE,CACpD,EAAa,EAAO,KAAM,qBAAqB,CAGjD,IAAK,IAAM,KAAW,EAAM,UAAY,EAAE,CACxC,IAAK,IAAM,KAAS,EAAQ,sBAAwB,EAAE,CAAE,CACtD,EAAa,EAAM,KAAM,oBAAoB,EAAM,MAAM,IAAI,CAC7D,IAAK,IAAM,KAAU,EAAM,SAAW,EAAE,CACtC,EAAa,EAAO,KAAM,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AAM,EAAc,KAAK,MAAM,KAAK,UAAU,EAAK,CAAC,CAapD,OAZA,EAAO,QAAS,GAAU,CAExB,EAAW,EAAM,CAAC,SAAS,CAAC,EAAK,KAAuB,CAClD,EAAO,KAAS,IAAA,GAClB,EAAO,GAAO,EACL,MAAM,QAAQ,EAAM,CAC7B,EAAO,GAAO,CAAC,GAAG,EAAO,GAAM,GAAG,EAAM,CAExC,EAAO,GAAO,GAEhB,EACF,CACK,ECvBT,SAAgB,EAAyB,EAEvC,CAEA,IAAM,EAAY,EAAU,MAAM,IAAI,CAAC,OAAQ,GAAM,CAAC,CAAC,EAAE,CACnD,EAAkC,EAAE,CAQ1C,OAPA,EAAU,QAAS,GAAa,CAC9B,GAAM,CAAC,EAAG,GAAK,EAAS,MAAM,IAAI,CAClC,GAAI,CAAC,GAAK,CAAC,EACT,MAAU,MAAM,qBAAqB,EAAS,8BAA8B,CAE9E,EAAK,GAAK,GACV,CACK"}
@@ -1,2 +1,2 @@
1
- import{a as e}from"./constants-Cb9QI4yq.mjs";import{t}from"./logger-B-LXIf3U.mjs";import{decodeCodec as n}from"@transcend-io/type-utils";import r from"colors";import*as i from"io-ts";import{REDUCED_REQUESTS_FOR_DATA_SILO_COUNT as a,buildTranscendGraphQLClient as o,createSombraGotInstance as s,makeGraphQLRequest as c,withTransientRetry as l}from"@transcend-io/sdk";import{mapSeries as u}from"@transcend-io/utils";import d from"cli-progress";async function f(e,{dataSiloId:n}){let{listReducedRequestsForDataSilo:{totalCount:r}}=await c(e,a,{variables:{input:{dataSiloId:n,isResolved:!1}},logger:t});return r}const p=i.type({id:i.string,name:i.string,partition:i.string}),m=i.intersection([i.type({identifier:i.string,type:i.string,coreIdentifier:i.string,dataSiloId:i.string,requestId:i.string,nonce:i.string,requestCreatedAt:i.string,daysUntilOverdue:i.number,attributes:i.array(i.type({key:i.string,values:i.array(i.string)}))}),i.partial({partition:i.union([p,i.null])})]);async function h(e,{dataSiloId:r,limit:a=100,offset:o=0,requestType:s}){try{let c=await l(`pullCronPageOfIdentifiers`,()=>e.get(`v1/data-silo/${r}/pending-requests/${s}`,{searchParams:{offset:o,limit:a}}).json(),{logger:t,maxAttempts:6,baseDelayMs:500}),{items:u}=n(i.type({items:i.array(m)}),c);return u}catch(e){throw Error(`Received an error from server: ${e?.response?.body||e?.message}`)}}async function g({dataSiloId:n,auth:i,sombraAuth:a,actions:c,apiPageSize:l=100,savePageSize:p=1e3,onSave:m,transcendUrl:g=e,skipRequestCount:_=!1}){if(p%l!==0)throw Error(`savePageSize must be a multiple of apiPageSize. savePageSize: ${p}, apiPageSize: ${l}`);let v=await s(g,i,{logger:t,sombraApiKey:a,sombraUrl:process.env.SOMBRA_URL}),y=o(g,i),b=0;_||(b=await f(y,{dataSiloId:n})),t.info(r.magenta(`Pulling ${_?`all`:b} outstanding request identifiers for data silo: "${n}" for requests of types "${c.join(`", "`)}"`));let x=new Date().getTime(),S=new d.SingleBar({},d.Presets.shades_classic),C=new Set,w=[],T=[];_||S.start(b,0),await u(c,async e=>{let i=0,a=!0;for(;a;){let o=await h(v,{dataSiloId:n,limit:l,offset:i,requestType:e}),s=o.map(t=>(C.add(t.requestId),{...t,action:e})),c=s.map(({attributes:e,partition:t,...n})=>({...n,...t?{partitionId:t.id,partitionName:t.name,partitionKey:t.partition}:{},...e.reduce((e,t)=>Object.assign(e,{[t.key]:t.values.join(`,`)}),{})}));w.push(...s),T.push(...c),T.length>=p&&(await m(T),T=[]),a=o.length===l,i+=l,_?t.info(r.magenta(`Pulled ${o.length} outstanding identifiers for ${C.size} requests`)):S.update(C.size)}}),T.length>0&&await m(T),_||S.stop();let E=new Date().getTime()-x;return t.info(r.green(`Successfully pulled ${w.length} outstanding identifiers from ${C.size} requests in "${E/1e3}" seconds!`)),{identifiers:w}}export{f as a,h as i,m as n,p as r,g as t};
2
- //# sourceMappingURL=pullChunkedCustomSiloOutstandingIdentifiers-Ckh-dpAa.mjs.map
1
+ import{a as e}from"./constants-CL4uZK_i.mjs";import{t}from"./logger-B-LXIf3U.mjs";import{decodeCodec as n}from"@transcend-io/type-utils";import r from"colors";import*as i from"io-ts";import{REDUCED_REQUESTS_FOR_DATA_SILO_COUNT as a,buildTranscendGraphQLClient as o,createSombraGotInstance as s,makeGraphQLRequest as c,withTransientRetry as l}from"@transcend-io/sdk";import{mapSeries as u}from"@transcend-io/utils";import d from"cli-progress";async function f(e,{dataSiloId:n}){let{listReducedRequestsForDataSilo:{totalCount:r}}=await c(e,a,{variables:{input:{dataSiloId:n,isResolved:!1}},logger:t});return r}const p=i.type({id:i.string,name:i.string,partition:i.string}),m=i.intersection([i.type({identifier:i.string,type:i.string,coreIdentifier:i.string,dataSiloId:i.string,requestId:i.string,nonce:i.string,requestCreatedAt:i.string,daysUntilOverdue:i.number,attributes:i.array(i.type({key:i.string,values:i.array(i.string)}))}),i.partial({partition:i.union([p,i.null])})]);async function h(e,{dataSiloId:r,limit:a=100,offset:o=0,requestType:s}){try{let c=await l(`pullCronPageOfIdentifiers`,()=>e.get(`v1/data-silo/${r}/pending-requests/${s}`,{searchParams:{offset:o,limit:a}}).json(),{logger:t,maxAttempts:6,baseDelayMs:500}),{items:u}=n(i.type({items:i.array(m)}),c);return u}catch(e){throw Error(`Received an error from server: ${e?.response?.body||e?.message}`)}}async function g({dataSiloId:n,auth:i,sombraAuth:a,actions:c,apiPageSize:l=100,savePageSize:p=1e3,onSave:m,transcendUrl:g=e,skipRequestCount:_=!1}){if(p%l!==0)throw Error(`savePageSize must be a multiple of apiPageSize. savePageSize: ${p}, apiPageSize: ${l}`);let v=await s(g,i,{logger:t,sombraApiKey:a,sombraUrl:process.env.SOMBRA_URL}),y=o(g,i),b=0;_||(b=await f(y,{dataSiloId:n})),t.info(r.magenta(`Pulling ${_?`all`:b} outstanding request identifiers for data silo: "${n}" for requests of types "${c.join(`", "`)}"`));let x=new Date().getTime(),S=new d.SingleBar({},d.Presets.shades_classic),C=new Set,w=[],T=[];_||S.start(b,0),await u(c,async e=>{let i=0,a=!0;for(;a;){let o=await h(v,{dataSiloId:n,limit:l,offset:i,requestType:e}),s=o.map(t=>(C.add(t.requestId),{...t,action:e})),c=s.map(({attributes:e,partition:t,...n})=>({...n,...t?{partitionId:t.id,partitionName:t.name,partitionKey:t.partition}:{},...e.reduce((e,t)=>Object.assign(e,{[t.key]:t.values.join(`,`)}),{})}));w.push(...s),T.push(...c),T.length>=p&&(await m(T),T=[]),a=o.length===l,i+=l,_?t.info(r.magenta(`Pulled ${o.length} outstanding identifiers for ${C.size} requests`)):S.update(C.size)}}),T.length>0&&await m(T),_||S.stop();let E=new Date().getTime()-x;return t.info(r.green(`Successfully pulled ${w.length} outstanding identifiers from ${C.size} requests in "${E/1e3}" seconds!`)),{identifiers:w}}export{f as a,h as i,m as n,p as r,g as t};
2
+ //# sourceMappingURL=pullChunkedCustomSiloOutstandingIdentifiers-qZCnzDXQ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"pullChunkedCustomSiloOutstandingIdentifiers-Ckh-dpAa.mjs","names":[],"sources":["../src/lib/graphql/fetchRequestDataSiloActiveCount.ts","../src/lib/cron/pullCronPageOfIdentifiers.ts","../src/lib/cron/pullChunkedCustomSiloOutstandingIdentifiers.ts"],"sourcesContent":["import { makeGraphQLRequest, REDUCED_REQUESTS_FOR_DATA_SILO_COUNT } from '@transcend-io/sdk';\nimport { GraphQLClient } from 'graphql-request';\n\nimport { logger } from '../../logger.js';\n\n/**\n * Get number of open requests for a data silo\n *\n * @param client - GraphQL client\n * @param options - Filter options\n * @returns List of request identifiers\n */\nexport async function fetchRequestDataSiloActiveCount(\n client: GraphQLClient,\n {\n dataSiloId,\n }: {\n /** Data silo ID */\n dataSiloId: string;\n },\n): Promise<number> {\n const {\n listReducedRequestsForDataSilo: { totalCount },\n } = await makeGraphQLRequest<{\n /** Requests */\n listReducedRequestsForDataSilo: {\n /** Total count */\n totalCount: number;\n };\n }>(client, REDUCED_REQUESTS_FOR_DATA_SILO_COUNT, {\n variables: {\n input: {\n dataSiloId,\n isResolved: false,\n },\n },\n logger,\n });\n\n return totalCount;\n}\n","import { RequestAction } from '@transcend-io/privacy-types';\nimport { withTransientRetry } from '@transcend-io/sdk';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport type { Got } from 'got';\nimport * as t from 'io-ts';\n\nimport { logger } from '../../logger.js';\n\n/** Consent partition metadata when a DSR is scoped to a partition */\nexport const CronPartition = t.type({\n /** ID of the partition */\n id: t.string,\n /** The human readable name of the partition */\n name: t.string,\n /** The unique identifying partition value */\n partition: t.string,\n});\n\n/** Type override */\nexport type CronPartition = t.TypeOf<typeof CronPartition>;\n\nexport const CronIdentifier = t.intersection([\n t.type({\n /** The identifier value */\n identifier: t.string,\n /** The type of identifier */\n type: t.string,\n /** The core identifier of the request */\n coreIdentifier: t.string,\n /** The ID of the underlying data silo */\n dataSiloId: t.string,\n /** The ID of the underlying request */\n requestId: t.string,\n /** The request nonce */\n nonce: t.string,\n /** The time the request was created */\n requestCreatedAt: t.string,\n /** The number of days until the request is overdue */\n daysUntilOverdue: t.number,\n /** Request attributes */\n attributes: t.array(\n t.type({\n key: t.string,\n values: t.array(t.string),\n }),\n ),\n }),\n t.partial({\n /** The consent partition that scopes this request, when applicable */\n partition: t.union([CronPartition, t.null]),\n }),\n]);\n\n/** Type override */\nexport type CronIdentifier = t.TypeOf<typeof CronIdentifier>;\n\n/**\n * Pull a offset of identifiers for a cron job\n *\n * @see https://docs.transcend.io/docs/api-reference/GET/v1/data-silo/(id)/pending-requests/(type)\n * @param sombra - Sombra instance configured to make requests\n * @param options - Additional options\n * @returns Successfully submitted request\n */\nexport async function pullCronPageOfIdentifiers(\n sombra: Got,\n {\n dataSiloId,\n limit = 100,\n offset = 0,\n requestType,\n }: {\n /** Data Silo ID */\n dataSiloId: string;\n /** Type of request */\n requestType: RequestAction;\n /** Number of identifiers to pull in */\n limit?: number;\n /** Page to pull in */\n offset?: number;\n },\n): Promise<CronIdentifier[]> {\n try {\n // `GET pending-requests` is a read and therefore safe to retry on transient\n // gateway / network errors. Customers running `transcend cron\n // pull-identifiers` against large silos would otherwise see the command\n // abort on a single 502 from the Sombra reverse tunnel.\n const response = await withTransientRetry(\n 'pullCronPageOfIdentifiers',\n () =>\n sombra\n .get(`v1/data-silo/${dataSiloId}/pending-requests/${requestType}`, {\n searchParams: {\n offset,\n limit,\n },\n })\n .json(),\n { logger, maxAttempts: 6, baseDelayMs: 500 },\n );\n\n const { items } = decodeCodec(\n t.type({\n items: t.array(CronIdentifier),\n }),\n response,\n );\n return items;\n } catch (err) {\n throw new Error(`Received an error from server: ${err?.response?.body || err?.message}`);\n }\n}\n","import { RequestAction } from '@transcend-io/privacy-types';\nimport { buildTranscendGraphQLClient, createSombraGotInstance } from '@transcend-io/sdk';\nimport { mapSeries } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { fetchRequestDataSiloActiveCount } from '../graphql/index.js';\nimport { pullCronPageOfIdentifiers, CronIdentifier } from './pullCronPageOfIdentifiers.js';\n\n/**\n * A CSV formatted identifier\n */\nexport type CsvFormattedIdentifier = {\n [k in string]: string | null | boolean | number;\n};\n\nexport interface CronIdentifierWithAction extends CronIdentifier {\n /** The request action that the identifier relates to */\n action: RequestAction;\n}\n\n/**\n * Pull the set of identifiers outstanding for a cron or AVC integration\n *\n * This function is designed to be used in a loop, and will call the onSave callback\n * with a chunk of identifiers when the savePageSize is reached.\n *\n * @param options - Options\n * @returns The identifiers and identifiers formatted for CSV\n */\nexport async function pullChunkedCustomSiloOutstandingIdentifiers({\n dataSiloId,\n auth,\n sombraAuth,\n actions,\n apiPageSize = 100,\n savePageSize = 1000,\n onSave,\n transcendUrl = DEFAULT_TRANSCEND_API,\n skipRequestCount = false,\n}: {\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** The request actions to fetch */\n actions: RequestAction[];\n /** How many identifiers to pull in a single call to the backend */\n apiPageSize: number;\n /** How many identifiers to save at a time (usually to a CSV file, should be a multiple of apiPageSize) */\n savePageSize: number;\n /** Callback function called when a chunk of identifiers is ready to be saved */\n onSave: (chunk: CsvFormattedIdentifier[]) => Promise<void>;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Skip request count */\n skipRequestCount?: boolean;\n}): Promise<{\n /** Raw Identifiers */\n identifiers: CronIdentifierWithAction[];\n}> {\n // Validate savePageSize\n if (savePageSize % apiPageSize !== 0) {\n throw new Error(\n `savePageSize must be a multiple of apiPageSize. savePageSize: ${savePageSize}, apiPageSize: ${apiPageSize}`,\n );\n }\n\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n // Create GraphQL client to connect to Transcend backend\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n let totalRequestCount = 0;\n if (!skipRequestCount) {\n totalRequestCount = await fetchRequestDataSiloActiveCount(client, {\n dataSiloId,\n });\n }\n\n logger.info(\n colors.magenta(\n `Pulling ${skipRequestCount ? 'all' : totalRequestCount} outstanding request identifiers ` +\n `for data silo: \"${dataSiloId}\" for requests of types \"${actions.join('\", \"')}\"`,\n ),\n );\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n const foundRequestIds = new Set<string>();\n\n // identifiers found in total\n const identifiers: CronIdentifierWithAction[] = [];\n // current chunk of identifiers to be saved\n let currentChunk: CsvFormattedIdentifier[] = [];\n\n // map over each action\n if (!skipRequestCount) {\n progressBar.start(totalRequestCount, 0);\n }\n await mapSeries(actions, async (action) => {\n let offset = 0;\n let shouldContinue = true;\n\n // Fetch a page of identifiers\n while (shouldContinue) {\n const pageIdentifiers = await pullCronPageOfIdentifiers(sombra, {\n dataSiloId,\n limit: apiPageSize,\n offset,\n requestType: action,\n });\n\n const identifiersWithAction: CronIdentifierWithAction[] = pageIdentifiers.map(\n (identifier) => {\n foundRequestIds.add(identifier.requestId);\n return {\n ...identifier,\n action,\n };\n },\n );\n\n const csvFormattedIdentifiers = identifiersWithAction.map(\n ({ attributes, partition, ...identifier }) => ({\n ...identifier,\n ...(partition\n ? {\n partitionId: partition.id,\n partitionName: partition.name,\n partitionKey: partition.partition,\n }\n : {}),\n ...attributes.reduce(\n (acc, val) =>\n Object.assign(acc, {\n [val.key]: val.values.join(','),\n }),\n {},\n ),\n }),\n );\n\n identifiers.push(...identifiersWithAction);\n currentChunk.push(...csvFormattedIdentifiers);\n\n // Check if we've reached the savePageSize and call the onSave callback\n if (currentChunk.length >= savePageSize) {\n await onSave(currentChunk);\n currentChunk = [];\n }\n\n shouldContinue = pageIdentifiers.length === apiPageSize;\n offset += apiPageSize;\n if (!skipRequestCount) {\n progressBar.update(foundRequestIds.size);\n } else {\n logger.info(\n colors.magenta(\n `Pulled ${pageIdentifiers.length} outstanding identifiers for ${foundRequestIds.size} requests`,\n ),\n );\n }\n }\n });\n\n // Save any remaining identifiers in the current chunk\n if (currentChunk.length > 0) {\n await onSave(currentChunk);\n }\n\n if (!skipRequestCount) {\n progressBar.stop();\n }\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully pulled ${identifiers.length} outstanding identifiers from ${\n foundRequestIds.size\n } requests in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n\n return { identifiers };\n}\n"],"mappings":"0bAYA,eAAsB,EACpB,EACA,CACE,cAKe,CACjB,GAAM,CACJ,+BAAgC,CAAE,eAChC,MAAM,EAMP,EAAQ,EAAsC,CAC/C,UAAW,CACT,MAAO,CACL,aACA,WAAY,GACb,CACF,CACD,SACD,CAAC,CAEF,OAAO,EC9BT,MAAa,EAAgB,EAAE,KAAK,CAElC,GAAI,EAAE,OAEN,KAAM,EAAE,OAER,UAAW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AAM,CAAC,SACF,CAAG,EAUvB,OARA,EAAO,KACL,EAAO,MACL,uBAAuB,EAAY,OAAO,gCACxC,EAAgB,KACjB,gBAAgB,EAAY,IAAK,YACnC,CACF,CAEM,CAAE,cAAa"}
1
+ {"version":3,"file":"pullChunkedCustomSiloOutstandingIdentifiers-qZCnzDXQ.mjs","names":[],"sources":["../src/lib/graphql/fetchRequestDataSiloActiveCount.ts","../src/lib/cron/pullCronPageOfIdentifiers.ts","../src/lib/cron/pullChunkedCustomSiloOutstandingIdentifiers.ts"],"sourcesContent":["import { makeGraphQLRequest, REDUCED_REQUESTS_FOR_DATA_SILO_COUNT } from '@transcend-io/sdk';\nimport { GraphQLClient } from 'graphql-request';\n\nimport { logger } from '../../logger.js';\n\n/**\n * Get number of open requests for a data silo\n *\n * @param client - GraphQL client\n * @param options - Filter options\n * @returns List of request identifiers\n */\nexport async function fetchRequestDataSiloActiveCount(\n client: GraphQLClient,\n {\n dataSiloId,\n }: {\n /** Data silo ID */\n dataSiloId: string;\n },\n): Promise<number> {\n const {\n listReducedRequestsForDataSilo: { totalCount },\n } = await makeGraphQLRequest<{\n /** Requests */\n listReducedRequestsForDataSilo: {\n /** Total count */\n totalCount: number;\n };\n }>(client, REDUCED_REQUESTS_FOR_DATA_SILO_COUNT, {\n variables: {\n input: {\n dataSiloId,\n isResolved: false,\n },\n },\n logger,\n });\n\n return totalCount;\n}\n","import { RequestAction } from '@transcend-io/privacy-types';\nimport { withTransientRetry } from '@transcend-io/sdk';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport type { Got } from 'got';\nimport * as t from 'io-ts';\n\nimport { logger } from '../../logger.js';\n\n/** Consent partition metadata when a DSR is scoped to a partition */\nexport const CronPartition = t.type({\n /** ID of the partition */\n id: t.string,\n /** The human readable name of the partition */\n name: t.string,\n /** The unique identifying partition value */\n partition: t.string,\n});\n\n/** Type override */\nexport type CronPartition = t.TypeOf<typeof CronPartition>;\n\nexport const CronIdentifier = t.intersection([\n t.type({\n /** The identifier value */\n identifier: t.string,\n /** The type of identifier */\n type: t.string,\n /** The core identifier of the request */\n coreIdentifier: t.string,\n /** The ID of the underlying data silo */\n dataSiloId: t.string,\n /** The ID of the underlying request */\n requestId: t.string,\n /** The request nonce */\n nonce: t.string,\n /** The time the request was created */\n requestCreatedAt: t.string,\n /** The number of days until the request is overdue */\n daysUntilOverdue: t.number,\n /** Request attributes */\n attributes: t.array(\n t.type({\n key: t.string,\n values: t.array(t.string),\n }),\n ),\n }),\n t.partial({\n /** The consent partition that scopes this request, when applicable */\n partition: t.union([CronPartition, t.null]),\n }),\n]);\n\n/** Type override */\nexport type CronIdentifier = t.TypeOf<typeof CronIdentifier>;\n\n/**\n * Pull a offset of identifiers for a cron job\n *\n * @see https://docs.transcend.io/docs/api-reference/GET/v1/data-silo/(id)/pending-requests/(type)\n * @param sombra - Sombra instance configured to make requests\n * @param options - Additional options\n * @returns Successfully submitted request\n */\nexport async function pullCronPageOfIdentifiers(\n sombra: Got,\n {\n dataSiloId,\n limit = 100,\n offset = 0,\n requestType,\n }: {\n /** Data Silo ID */\n dataSiloId: string;\n /** Type of request */\n requestType: RequestAction;\n /** Number of identifiers to pull in */\n limit?: number;\n /** Page to pull in */\n offset?: number;\n },\n): Promise<CronIdentifier[]> {\n try {\n // `GET pending-requests` is a read and therefore safe to retry on transient\n // gateway / network errors. Customers running `transcend cron\n // pull-identifiers` against large silos would otherwise see the command\n // abort on a single 502 from the Sombra reverse tunnel.\n const response = await withTransientRetry(\n 'pullCronPageOfIdentifiers',\n () =>\n sombra\n .get(`v1/data-silo/${dataSiloId}/pending-requests/${requestType}`, {\n searchParams: {\n offset,\n limit,\n },\n })\n .json(),\n { logger, maxAttempts: 6, baseDelayMs: 500 },\n );\n\n const { items } = decodeCodec(\n t.type({\n items: t.array(CronIdentifier),\n }),\n response,\n );\n return items;\n } catch (err) {\n throw new Error(`Received an error from server: ${err?.response?.body || err?.message}`);\n }\n}\n","import { RequestAction } from '@transcend-io/privacy-types';\nimport { buildTranscendGraphQLClient, createSombraGotInstance } from '@transcend-io/sdk';\nimport { mapSeries } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { fetchRequestDataSiloActiveCount } from '../graphql/index.js';\nimport { pullCronPageOfIdentifiers, CronIdentifier } from './pullCronPageOfIdentifiers.js';\n\n/**\n * A CSV formatted identifier\n */\nexport type CsvFormattedIdentifier = {\n [k in string]: string | null | boolean | number;\n};\n\nexport interface CronIdentifierWithAction extends CronIdentifier {\n /** The request action that the identifier relates to */\n action: RequestAction;\n}\n\n/**\n * Pull the set of identifiers outstanding for a cron or AVC integration\n *\n * This function is designed to be used in a loop, and will call the onSave callback\n * with a chunk of identifiers when the savePageSize is reached.\n *\n * @param options - Options\n * @returns The identifiers and identifiers formatted for CSV\n */\nexport async function pullChunkedCustomSiloOutstandingIdentifiers({\n dataSiloId,\n auth,\n sombraAuth,\n actions,\n apiPageSize = 100,\n savePageSize = 1000,\n onSave,\n transcendUrl = DEFAULT_TRANSCEND_API,\n skipRequestCount = false,\n}: {\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** The request actions to fetch */\n actions: RequestAction[];\n /** How many identifiers to pull in a single call to the backend */\n apiPageSize: number;\n /** How many identifiers to save at a time (usually to a CSV file, should be a multiple of apiPageSize) */\n savePageSize: number;\n /** Callback function called when a chunk of identifiers is ready to be saved */\n onSave: (chunk: CsvFormattedIdentifier[]) => Promise<void>;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Skip request count */\n skipRequestCount?: boolean;\n}): Promise<{\n /** Raw Identifiers */\n identifiers: CronIdentifierWithAction[];\n}> {\n // Validate savePageSize\n if (savePageSize % apiPageSize !== 0) {\n throw new Error(\n `savePageSize must be a multiple of apiPageSize. savePageSize: ${savePageSize}, apiPageSize: ${apiPageSize}`,\n );\n }\n\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n // Create GraphQL client to connect to Transcend backend\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n let totalRequestCount = 0;\n if (!skipRequestCount) {\n totalRequestCount = await fetchRequestDataSiloActiveCount(client, {\n dataSiloId,\n });\n }\n\n logger.info(\n colors.magenta(\n `Pulling ${skipRequestCount ? 'all' : totalRequestCount} outstanding request identifiers ` +\n `for data silo: \"${dataSiloId}\" for requests of types \"${actions.join('\", \"')}\"`,\n ),\n );\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n const foundRequestIds = new Set<string>();\n\n // identifiers found in total\n const identifiers: CronIdentifierWithAction[] = [];\n // current chunk of identifiers to be saved\n let currentChunk: CsvFormattedIdentifier[] = [];\n\n // map over each action\n if (!skipRequestCount) {\n progressBar.start(totalRequestCount, 0);\n }\n await mapSeries(actions, async (action) => {\n let offset = 0;\n let shouldContinue = true;\n\n // Fetch a page of identifiers\n while (shouldContinue) {\n const pageIdentifiers = await pullCronPageOfIdentifiers(sombra, {\n dataSiloId,\n limit: apiPageSize,\n offset,\n requestType: action,\n });\n\n const identifiersWithAction: CronIdentifierWithAction[] = pageIdentifiers.map(\n (identifier) => {\n foundRequestIds.add(identifier.requestId);\n return {\n ...identifier,\n action,\n };\n },\n );\n\n const csvFormattedIdentifiers = identifiersWithAction.map(\n ({ attributes, partition, ...identifier }) => ({\n ...identifier,\n ...(partition\n ? {\n partitionId: partition.id,\n partitionName: partition.name,\n partitionKey: partition.partition,\n }\n : {}),\n ...attributes.reduce(\n (acc, val) =>\n Object.assign(acc, {\n [val.key]: val.values.join(','),\n }),\n {},\n ),\n }),\n );\n\n identifiers.push(...identifiersWithAction);\n currentChunk.push(...csvFormattedIdentifiers);\n\n // Check if we've reached the savePageSize and call the onSave callback\n if (currentChunk.length >= savePageSize) {\n await onSave(currentChunk);\n currentChunk = [];\n }\n\n shouldContinue = pageIdentifiers.length === apiPageSize;\n offset += apiPageSize;\n if (!skipRequestCount) {\n progressBar.update(foundRequestIds.size);\n } else {\n logger.info(\n colors.magenta(\n `Pulled ${pageIdentifiers.length} outstanding identifiers for ${foundRequestIds.size} requests`,\n ),\n );\n }\n }\n });\n\n // Save any remaining identifiers in the current chunk\n if (currentChunk.length > 0) {\n await onSave(currentChunk);\n }\n\n if (!skipRequestCount) {\n progressBar.stop();\n }\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully pulled ${identifiers.length} outstanding identifiers from ${\n foundRequestIds.size\n } requests in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n\n return { identifiers };\n}\n"],"mappings":"0bAYA,eAAsB,EACpB,EACA,CACE,cAKe,CACjB,GAAM,CACJ,+BAAgC,CAAE,eAChC,MAAM,EAMP,EAAQ,EAAsC,CAC/C,UAAW,CACT,MAAO,CACL,aACA,WAAY,GACb,CACF,CACD,SACD,CAAC,CAEF,OAAO,EC9BT,MAAa,EAAgB,EAAE,KAAK,CAElC,GAAI,EAAE,OAEN,KAAM,EAAE,OAER,UAAW,EAAE,OACd,CAAC,CAKW,EAAiB,EAAE,aAAa,CAC3C,EAAE,KAAK,CAEL,WAAY,EAAE,OAEd,KAAM,EAAE,OAER,eAAgB,EAAE,OAElB,WAAY,EAAE,OAEd,UAAW,EAAE,OAEb,MAAO,EAAE,OAET,iBAAkB,EAAE,OAEpB,iBAAkB,EAAE,OAEpB,WAAY,EAAE,MACZ,EAAE,KAAK,CACL,IAAK,EAAE,OACP,OAAQ,EAAE,MAAM,EAAE,OAAO,CAC1B,CAAC,CACH,CACF,CAAC,CACF,EAAE,QAAQ,CAER,UAAW,EAAE,MAAM,CAAC,EAAe,EAAE,KAAK,CAAC,CAC5C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,MAAM,EAA0B,EAAQ,CAC9D,aACA,MAAO,EACP,SACA,YAAa,EACd,CAAC,CAEI,EAAoD,EAAgB,IACvE,IACC,EAAgB,IAAI,EAAW,UAAU,CAClC,CACL,GAAG,EACH,SACD,EAEJ,CAEK,EAA0B,EAAsB,KACnD,CAAE,aAAY,YAAW,GAAG,MAAkB,CAC7C,GAAG,EACH,GAAI,EACA,CACE,YAAa,EAAU,GACvB,cAAe,EAAU,KACzB,aAAc,EAAU,UACzB,CACD,EAAE,CACN,GAAG,EAAW,QACX,EAAK,IACJ,OAAO,OAAO,EAAK,EAChB,EAAI,KAAM,EAAI,OAAO,KAAK,IAAI,CAChC,CAAC,CACJ,EAAE,CACH,CACF,EACF,CAED,EAAY,KAAK,GAAG,EAAsB,CAC1C,EAAa,KAAK,GAAG,EAAwB,CAGzC,EAAa,QAAU,IACzB,MAAM,EAAO,EAAa,CAC1B,EAAe,EAAE,EAGnB,EAAiB,EAAgB,SAAW,EAC5C,GAAU,EACL,EAGH,EAAO,KACL,EAAO,QACL,UAAU,EAAgB,OAAO,+BAA+B,EAAgB,KAAK,WACtF,CACF,CAND,EAAY,OAAO,EAAgB,KAAK,GAS5C,CAGE,EAAa,OAAS,GACxB,MAAM,EAAO,EAAa,CAGvB,GACH,EAAY,MAAM,CAGpB,IAAM,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EAUvB,OARA,EAAO,KACL,EAAO,MACL,uBAAuB,EAAY,OAAO,gCACxC,EAAgB,KACjB,gBAAgB,EAAY,IAAK,YACnC,CACF,CAEM,CAAE,cAAa"}
@@ -1,2 +1,2 @@
1
- import{a as e}from"./constants-Cb9QI4yq.mjs";import{t}from"./logger-B-LXIf3U.mjs";import{r as n}from"./fetchAllRequests-BCHpCeFo.mjs";import{a as r}from"./writeCsv-DDKM_rAU.mjs";import{RequestStatus as i}from"@transcend-io/privacy-types";import{groupBy as a,uniq as o}from"lodash-es";import s from"colors";import{buildTranscendGraphQLClient as c,createSombraGotInstance as l,fetchAllRequestEnrichers as u,fetchAllRequestIdentifiers as d,validateSombraVersion as f}from"@transcend-io/sdk";import{map as p}from"@transcend-io/utils";async function m({file:m,auth:h,sombraAuth:g,requestActions:_=[],concurrency:v=100,transcendUrl:y=e}){let b=c(y,h),x=await l(y,h,{logger:t,sombraApiKey:g,sombraUrl:process.env.SOMBRA_URL});t.info(s.magenta(`Pulling manual enrichment requests, filtered for actions: ${_.join(`,`)}`));let S=await n(b,{actions:_,statuses:[i.Enriching]});await f(b,{logger:t});let C=[];await p(S,async e=>{let n=await u(b,{filterBy:{requestId:e.id},logger:t});if(n.filter(({status:e})=>e===`ACTION_REQUIRED`)){let r=await d(b,x,{filterBy:{requestId:e.id},skipSombraCheck:!0,logger:t});C.push({...e,requestIdentifiers:r,requestEnrichers:n})}},{concurrency:v});let w=C.map(({attributeValues:e,requestIdentifiers:t,requestEnrichers:n,...r})=>({...r,...Object.entries(a(t,`name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({value:e})=>e).join(`,`)}),{}),...Object.entries(a(e,`attributeKey.name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({name:e})=>e).join(`,`)}),{})}));return await r(m,w,o(w.map(e=>Object.keys(e)).flat())),t.info(s.green(`Successfully wrote ${C.length} requests to file "${m}"`)),C}export{m as t};
2
- //# sourceMappingURL=pullManualEnrichmentIdentifiersToCsv-gzP-wpef.mjs.map
1
+ import{a as e}from"./constants-CL4uZK_i.mjs";import{t}from"./logger-B-LXIf3U.mjs";import{r as n}from"./fetchAllRequests-BCHpCeFo.mjs";import{a as r}from"./writeCsv-DDKM_rAU.mjs";import{RequestStatus as i}from"@transcend-io/privacy-types";import{groupBy as a,uniq as o}from"lodash-es";import s from"colors";import{buildTranscendGraphQLClient as c,createSombraGotInstance as l,fetchAllRequestEnrichers as u,fetchAllRequestIdentifiers as d,validateSombraVersion as f}from"@transcend-io/sdk";import{map as p}from"@transcend-io/utils";async function m({file:m,auth:h,sombraAuth:g,requestActions:_=[],concurrency:v=100,transcendUrl:y=e}){let b=c(y,h),x=await l(y,h,{logger:t,sombraApiKey:g,sombraUrl:process.env.SOMBRA_URL});t.info(s.magenta(`Pulling manual enrichment requests, filtered for actions: ${_.join(`,`)}`));let S=await n(b,{actions:_,statuses:[i.Enriching]});await f(b,{logger:t});let C=[];await p(S,async e=>{let n=await u(b,{filterBy:{requestId:e.id},logger:t});if(n.filter(({status:e})=>e===`ACTION_REQUIRED`)){let r=await d(b,x,{filterBy:{requestId:e.id},skipSombraCheck:!0,logger:t});C.push({...e,requestIdentifiers:r,requestEnrichers:n})}},{concurrency:v});let w=C.map(({attributeValues:e,requestIdentifiers:t,requestEnrichers:n,...r})=>({...r,...Object.entries(a(t,`name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({value:e})=>e).join(`,`)}),{}),...Object.entries(a(e,`attributeKey.name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({name:e})=>e).join(`,`)}),{})}));return await r(m,w,o(w.map(e=>Object.keys(e)).flat())),t.info(s.green(`Successfully wrote ${C.length} requests to file "${m}"`)),C}export{m as t};
2
+ //# sourceMappingURL=pullManualEnrichmentIdentifiersToCsv-Bg1P8r4K.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"pullManualEnrichmentIdentifiersToCsv-gzP-wpef.mjs","names":[],"sources":["../src/lib/manual-enrichment/pullManualEnrichmentIdentifiersToCsv.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllRequestEnrichers,\n fetchAllRequestIdentifiers,\n validateSombraVersion,\n type RequestEnricher,\n type RequestIdentifier,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport colors from 'colors';\nimport { groupBy, uniq } from 'lodash-es';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { type PrivacyRequest, fetchAllRequests } from '../graphql/index.js';\nimport { writeCsv } from '../helpers/writeCsv.js';\n\nexport interface PrivacyRequestWithIdentifiers extends PrivacyRequest {\n /** Request Enrichers */\n requestEnrichers: RequestEnricher[];\n /** Request Identifiers */\n requestIdentifiers: RequestIdentifier[];\n}\n\n/**\n * Pull the set of manual enrichment jobs to CSV\n *\n * @param options - Options\n * @returns List of requests with identifiers\n */\nexport async function pullManualEnrichmentIdentifiersToCsv({\n file,\n auth,\n sombraAuth,\n requestActions = [],\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** CSV file path */\n file: string;\n /** Transcend API key authentication */\n auth: string;\n /** Sombra API key */\n sombraAuth?: string;\n /** Concurrency */\n concurrency?: number;\n /** The request actions to fetch */\n requestActions?: RequestAction[];\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<PrivacyRequestWithIdentifiers[]> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n logger.info(\n colors.magenta(\n `Pulling manual enrichment requests, filtered for actions: ${requestActions.join(',')}`,\n ),\n );\n\n // Pull all privacy requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses: [RequestStatus.Enriching],\n });\n\n await validateSombraVersion(client, { logger });\n\n // Requests to save\n const savedRequests: PrivacyRequestWithIdentifiers[] = [];\n\n // Filter down requests to what is needed\n await map(\n allRequests,\n async (request) => {\n // Fetch enrichers\n const requestEnrichers = await fetchAllRequestEnrichers(client, {\n filterBy: { requestId: request.id },\n logger,\n });\n\n // Check if manual enrichment exists for that request\n const hasManualEnrichment = requestEnrichers.filter(\n ({ status }) => status === 'ACTION_REQUIRED',\n );\n\n // Save request to queue\n if (hasManualEnrichment) {\n const requestIdentifiers = await fetchAllRequestIdentifiers(client, sombra, {\n filterBy: { requestId: request.id },\n skipSombraCheck: true,\n logger,\n });\n savedRequests.push({\n ...request,\n requestIdentifiers,\n requestEnrichers,\n });\n }\n },\n {\n concurrency,\n },\n );\n\n const data = savedRequests.map(\n ({\n attributeValues,\n requestIdentifiers,\n requestEnrichers, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...request\n }) => ({\n ...request,\n // flatten identifiers\n ...Object.entries(groupBy(requestIdentifiers, 'name')).reduce(\n (acc, [key, values]) =>\n Object.assign(acc, {\n [key]: values.map(({ value }) => value).join(','),\n }),\n {},\n ),\n // flatten attributes\n ...Object.entries(groupBy(attributeValues, 'attributeKey.name')).reduce(\n (acc, [key, values]) =>\n Object.assign(acc, {\n [key]: values.map(({ name }) => name).join(','),\n }),\n {},\n ),\n }),\n );\n\n // Write out to CSV\n const headers = uniq(data.map((d) => Object.keys(d)).flat());\n await writeCsv(file, data, headers);\n\n logger.info(\n colors.green(`Successfully wrote ${savedRequests.length} requests to file \"${file}\"`),\n );\n\n return savedRequests;\n}\n"],"mappings":"khBAgCA,eAAsB,EAAqC,CACzD,OACA,OACA,aACA,iBAAiB,EAAE,CACnB,cAAc,IACd,eAAe,GAc4B,CAE3C,IAAM,EAAS,EAA4B,EAAc,EAAK,CACxD,EAAS,MAAM,EAAwB,EAAc,EAAM,CAC/D,SACA,aAAc,EACd,UAAW,QAAQ,IAAI,WACxB,CAAC,CAEF,EAAO,KACL,EAAO,QACL,6DAA6D,EAAe,KAAK,IAAI,GACtF,CACF,CAGD,IAAM,EAAc,MAAM,EAAiB,EAAQ,CACjD,QAAS,EACT,SAAU,CAAC,EAAc,UAAU,CACpC,CAAC,CAEF,MAAM,EAAsB,EAAQ,CAAE,SAAQ,CAAC,CAG/C,IAAM,EAAiD,EAAE,CAGzD,MAAM,EACJ,EACA,KAAO,IAAY,CAEjB,IAAM,EAAmB,MAAM,EAAyB,EAAQ,CAC9D,SAAU,CAAE,UAAW,EAAQ,GAAI,CACnC,SACD,CAAC,CAQF,GAL4B,EAAiB,QAC1C,CAAE,YAAa,IAAW,kBAIN,CAAE,CACvB,IAAM,EAAqB,MAAM,EAA2B,EAAQ,EAAQ,CAC1E,SAAU,CAAE,UAAW,EAAQ,GAAI,CACnC,gBAAiB,GACjB,SACD,CAAC,CACF,EAAc,KAAK,CACjB,GAAG,EACH,qBACA,mBACD,CAAC,GAGN,CACE,cACD,CACF,CAED,IAAM,EAAO,EAAc,KACxB,CACC,kBACA,qBACA,mBACA,GAAG,MACE,CACL,GAAG,EAEH,GAAG,OAAO,QAAQ,EAAQ,EAAoB,OAAO,CAAC,CAAC,QACpD,EAAK,CAAC,EAAK,KACV,OAAO,OAAO,EAAK,EAChB,GAAM,EAAO,KAAK,CAAE,WAAY,EAAM,CAAC,KAAK,IAAI,CAClD,CAAC,CACJ,EAAE,CACH,CAED,GAAG,OAAO,QAAQ,EAAQ,EAAiB,oBAAoB,CAAC,CAAC,QAC9D,EAAK,CAAC,EAAK,KACV,OAAO,OAAO,EAAK,EAChB,GAAM,EAAO,KAAK,CAAE,UAAW,EAAK,CAAC,KAAK,IAAI,CAChD,CAAC,CACJ,EAAE,CACH,CACF,EACF,CAUD,OANA,MAAM,EAAS,EAAM,EADL,EAAK,EAAK,IAAK,GAAM,OAAO,KAAK,EAAE,CAAC,CAAC,MAAM,CACzB,CAAC,CAEnC,EAAO,KACL,EAAO,MAAM,sBAAsB,EAAc,OAAO,qBAAqB,EAAK,GAAG,CACtF,CAEM"}
1
+ {"version":3,"file":"pullManualEnrichmentIdentifiersToCsv-Bg1P8r4K.mjs","names":[],"sources":["../src/lib/manual-enrichment/pullManualEnrichmentIdentifiersToCsv.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllRequestEnrichers,\n fetchAllRequestIdentifiers,\n validateSombraVersion,\n type RequestEnricher,\n type RequestIdentifier,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport colors from 'colors';\nimport { groupBy, uniq } from 'lodash-es';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { type PrivacyRequest, fetchAllRequests } from '../graphql/index.js';\nimport { writeCsv } from '../helpers/writeCsv.js';\n\nexport interface PrivacyRequestWithIdentifiers extends PrivacyRequest {\n /** Request Enrichers */\n requestEnrichers: RequestEnricher[];\n /** Request Identifiers */\n requestIdentifiers: RequestIdentifier[];\n}\n\n/**\n * Pull the set of manual enrichment jobs to CSV\n *\n * @param options - Options\n * @returns List of requests with identifiers\n */\nexport async function pullManualEnrichmentIdentifiersToCsv({\n file,\n auth,\n sombraAuth,\n requestActions = [],\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** CSV file path */\n file: string;\n /** Transcend API key authentication */\n auth: string;\n /** Sombra API key */\n sombraAuth?: string;\n /** Concurrency */\n concurrency?: number;\n /** The request actions to fetch */\n requestActions?: RequestAction[];\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<PrivacyRequestWithIdentifiers[]> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n logger.info(\n colors.magenta(\n `Pulling manual enrichment requests, filtered for actions: ${requestActions.join(',')}`,\n ),\n );\n\n // Pull all privacy requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses: [RequestStatus.Enriching],\n });\n\n await validateSombraVersion(client, { logger });\n\n // Requests to save\n const savedRequests: PrivacyRequestWithIdentifiers[] = [];\n\n // Filter down requests to what is needed\n await map(\n allRequests,\n async (request) => {\n // Fetch enrichers\n const requestEnrichers = await fetchAllRequestEnrichers(client, {\n filterBy: { requestId: request.id },\n logger,\n });\n\n // Check if manual enrichment exists for that request\n const hasManualEnrichment = requestEnrichers.filter(\n ({ status }) => status === 'ACTION_REQUIRED',\n );\n\n // Save request to queue\n if (hasManualEnrichment) {\n const requestIdentifiers = await fetchAllRequestIdentifiers(client, sombra, {\n filterBy: { requestId: request.id },\n skipSombraCheck: true,\n logger,\n });\n savedRequests.push({\n ...request,\n requestIdentifiers,\n requestEnrichers,\n });\n }\n },\n {\n concurrency,\n },\n );\n\n const data = savedRequests.map(\n ({\n attributeValues,\n requestIdentifiers,\n requestEnrichers, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...request\n }) => ({\n ...request,\n // flatten identifiers\n ...Object.entries(groupBy(requestIdentifiers, 'name')).reduce(\n (acc, [key, values]) =>\n Object.assign(acc, {\n [key]: values.map(({ value }) => value).join(','),\n }),\n {},\n ),\n // flatten attributes\n ...Object.entries(groupBy(attributeValues, 'attributeKey.name')).reduce(\n (acc, [key, values]) =>\n Object.assign(acc, {\n [key]: values.map(({ name }) => name).join(','),\n }),\n {},\n ),\n }),\n );\n\n // Write out to CSV\n const headers = uniq(data.map((d) => Object.keys(d)).flat());\n await writeCsv(file, data, headers);\n\n logger.info(\n colors.green(`Successfully wrote ${savedRequests.length} requests to file \"${file}\"`),\n );\n\n return savedRequests;\n}\n"],"mappings":"khBAgCA,eAAsB,EAAqC,CACzD,OACA,OACA,aACA,iBAAiB,EAAE,CACnB,cAAc,IACd,eAAe,GAc4B,CAE3C,IAAM,EAAS,EAA4B,EAAc,EAAK,CACxD,EAAS,MAAM,EAAwB,EAAc,EAAM,CAC/D,SACA,aAAc,EACd,UAAW,QAAQ,IAAI,WACxB,CAAC,CAEF,EAAO,KACL,EAAO,QACL,6DAA6D,EAAe,KAAK,IAAI,GACtF,CACF,CAGD,IAAM,EAAc,MAAM,EAAiB,EAAQ,CACjD,QAAS,EACT,SAAU,CAAC,EAAc,UAAU,CACpC,CAAC,CAEF,MAAM,EAAsB,EAAQ,CAAE,SAAQ,CAAC,CAG/C,IAAM,EAAiD,EAAE,CAGzD,MAAM,EACJ,EACA,KAAO,IAAY,CAEjB,IAAM,EAAmB,MAAM,EAAyB,EAAQ,CAC9D,SAAU,CAAE,UAAW,EAAQ,GAAI,CACnC,SACD,CAAC,CAQF,GAL4B,EAAiB,QAC1C,CAAE,YAAa,IAAW,kBAIN,CAAE,CACvB,IAAM,EAAqB,MAAM,EAA2B,EAAQ,EAAQ,CAC1E,SAAU,CAAE,UAAW,EAAQ,GAAI,CACnC,gBAAiB,GACjB,SACD,CAAC,CACF,EAAc,KAAK,CACjB,GAAG,EACH,qBACA,mBACD,CAAC,GAGN,CACE,cACD,CACF,CAED,IAAM,EAAO,EAAc,KACxB,CACC,kBACA,qBACA,mBACA,GAAG,MACE,CACL,GAAG,EAEH,GAAG,OAAO,QAAQ,EAAQ,EAAoB,OAAO,CAAC,CAAC,QACpD,EAAK,CAAC,EAAK,KACV,OAAO,OAAO,EAAK,EAChB,GAAM,EAAO,KAAK,CAAE,WAAY,EAAM,CAAC,KAAK,IAAI,CAClD,CAAC,CACJ,EAAE,CACH,CAED,GAAG,OAAO,QAAQ,EAAQ,EAAiB,oBAAoB,CAAC,CAAC,QAC9D,EAAK,CAAC,EAAK,KACV,OAAO,OAAO,EAAK,EAChB,GAAM,EAAO,KAAK,CAAE,UAAW,EAAK,CAAC,KAAK,IAAI,CAChD,CAAC,CACJ,EAAE,CACH,CACF,EACF,CAUD,OANA,MAAM,EAAS,EAAM,EADL,EAAK,EAAK,IAAK,GAAM,OAAO,KAAK,EAAE,CAAC,CAAC,MAAM,CACzB,CAAC,CAEnC,EAAO,KACL,EAAO,MAAM,sBAAsB,EAAc,OAAO,qBAAqB,EAAK,GAAG,CACtF,CAEM"}
@@ -0,0 +1,58 @@
1
+ import"./enums-BymyVyqr.mjs";import{t as e}from"./logger-B-LXIf3U.mjs";import{ActionItemCode as t,ConsentTrackerStatus as n,PreferenceTopicType as r,RequestAction as i,RetentionType as a,WorkflowConfigType as o}from"@transcend-io/privacy-types";import{flatten as s,groupBy as c,keyBy as l,mapValues as u}from"lodash-es";import d from"colors";import{ASSESSMENT_SECTION_FIELDS as f,convertToDataSubjectAllowlist as p,fetchAllActionItemCollections as m,fetchAllActionItems as h,fetchAllActions as g,fetchAllAgentFiles as _,fetchAllAgentFunctions as v,fetchAllAgents as y,fetchAllAssessments as b,fetchAllAttributes as x,fetchAllBusinessEntities as S,fetchAllConsentWorkflowTriggers as C,fetchAllCookies as w,fetchAllDataCategories as T,fetchAllDataFlows as E,fetchAllDataSubjects as D,fetchAllEnrichers as O,fetchAllIdentifiers as k,fetchAllMessages as ee,fetchAllPolicies as te,fetchAllPreferenceOptionValues as ne,fetchAllPrivacyCenters as re,fetchAllProcessingActivities as ie,fetchAllProcessingPurposes as ae,fetchAllPromptGroups as oe,fetchAllPromptPartials as se,fetchAllPrompts as ce,fetchAllPurposesAndPreferences as le,fetchAllSiloDiscoveryResults as ue,fetchAllTeams as de,fetchAllTemplates as fe,fetchAllVendors as pe,fetchAllWorkflowConfigs as A,fetchApiKeys as me,fetchConsentManager as he,fetchConsentManagerExperiences as ge,fetchConsentManagerTheme as _e,fetchConsentThemes as ve,fetchConsentVariants as ye,fetchEnrichedDataSilos as be,fetchPartitions as xe,formatAttributeValues as j,formatRegions as M,makeGraphQLRequest as N,parseAssessmentDisplayLogic as P,parseAssessmentRiskLogic as F,parsePurposesFromTriggerCondition as Se,resolveWorkflowTitleFromId as Ce,workflowConfigMatchKey as we}from"@transcend-io/sdk";import{gql as I}from"graphql-request";const L=I`
2
+ query TranscendCliAssessmentTemplates(
3
+ $first: Int!
4
+ $offset: Int!
5
+ $filterBy: AssessmentFormTemplateFiltersInput
6
+ ) {
7
+ assessmentFormTemplates(
8
+ first: $first
9
+ offset: $offset
10
+ filterBy: $filterBy
11
+ ) {
12
+ nodes {
13
+ id
14
+ creator {
15
+ id
16
+ email
17
+ name
18
+ }
19
+ lastEditor {
20
+ id
21
+ email
22
+ name
23
+ }
24
+ title
25
+ description
26
+ status
27
+ source
28
+ parentId
29
+ isLocked
30
+ isArchived
31
+ createdAt
32
+ updatedAt
33
+ retentionSchedule {
34
+ id
35
+ type
36
+ durationDays
37
+ operation
38
+ createdAt
39
+ updatedAt
40
+ }
41
+ assessmentEmailSet {
42
+ id
43
+ title
44
+ description
45
+ isDefault
46
+ templates {
47
+ id
48
+ title
49
+ }
50
+ }
51
+ sections {
52
+ ${f}
53
+ }
54
+ }
55
+ }
56
+ }
57
+ `;async function R(t){let n=[],r=0,i=!1;do{let{assessmentFormTemplates:{nodes:a}}=await N(t,L,{variables:{first:20,offset:r},logger:e});n.push(...a),r+=20,i=a.length===20}while(i);return n.sort((e,t)=>e.title.localeCompare(t.title))}const z=[`dataSilos`,`enrichers`,`templates`,`apiKeys`];async function B(f,{dataSiloIds:N,integrationNames:I,debug:L,resources:B=z,pageSize:V,skipDatapoints:Te,includeGuessedCategories:H,skipSubDatapoints:Ee,trackerStatuses:U=Object.values(n)}){if(N.length>0&&I.length>0)throw Error(`Only 1 of integrationNames OR dataSiloIds can be provided`);e.info(d.magenta(`Fetching data with page size ${V}...`));let[W,De,G,K,Oe,ke,Ae,je,Me,Ne,Pe,Fe,q,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,J,et,tt,nt,Y,X,rt,it]=await Promise.all([B.includes(`dataSilos`)||B.includes(`dataSubjects`)?D(f,{logger:e}):[],B.includes(`apiKeys`)?me(f,{fetchAll:!0,logger:e}):[],B.includes(`dataSilos`)?be(f,{ids:N,integrationNames:I,pageSize:V,debug:L,includeGuessedCategories:H,skipDatapoints:Te,skipSubDatapoints:Ee,logger:e}):[],B.includes(`enrichers`)?O(f,{logger:e}):[],B.includes(`dataFlows`)?[...U.includes(n.Live)?await E(f,{logger:e,filterBy:{status:n.Live}}):[],...U.includes(n.NeedsReview)?await E(f,{logger:e,filterBy:{status:n.NeedsReview}}):[]]:[],B.includes(`cookies`)?[...U.includes(n.Live)?await w(f,{logger:e,filterBy:{status:n.Live}}):[],...U.includes(n.NeedsReview)?await w(f,{logger:e,filterBy:{status:n.NeedsReview}}):[]]:[],B.includes(`customFields`)?x(f,{logger:e}):[],B.includes(`templates`)?fe(f,{logger:e}):[],B.includes(`identifiers`)?k(f,{logger:e}):[],B.includes(`actions`)?g(f,{logger:e}):[],B.includes(`businessEntities`)?S(f,{logger:e}):[],B.includes(`processingActivities`)?ie(f,{logger:e}):[],B.includes(`consentManager`)?he(f,{logger:e}):void 0,B.includes(`consentManager`)?ge(f,{logger:e}):[],B.includes(`consentManager`)?ye(f,{logger:e}):[],B.includes(`consentManager`)?ve(f,{logger:e}):[],B.includes(`prompts`)?ce(f,{logger:e}):[],B.includes(`promptPartials`)?se(f,{logger:e}):[],B.includes(`promptGroups`)?oe(f,{logger:e}):[],B.includes(`agents`)?y(f,{logger:e}):[],B.includes(`agentFunctions`)?v(f,{logger:e}):[],B.includes(`agentFiles`)?_(f,{logger:e}):[],B.includes(`vendors`)?pe(f,{logger:e}):[],B.includes(`dataCategories`)?T(f,{logger:e}):[],B.includes(`processingPurposes`)?ae(f,{logger:e}):[],B.includes(`actionItems`)?h(f,{logger:e,filterBy:{type:[t.Onboarding]}}):[],B.includes(`actionItemCollections`)?m(f,{logger:e}):[],B.includes(`teams`)?de(f,{logger:e}):[],B.includes(`policies`)?te(f,{logger:e}):[],B.includes(`privacyCenters`)?re(f,{logger:e}):[],B.includes(`messages`)?ee(f,{logger:e}):[],B.includes(`partitions`)?xe(f,{logger:e}):[],B.includes(`assessments`)?b(f,{logger:e}):[],B.includes(`assessmentTemplates`)?R(f):[],B.includes(`purposes`)?le(f,{logger:e}):[],B.includes(`preferenceWorkflowConfigs`)?C(f,{logger:e}):[],B.includes(`workflowConfigs`)?A(f,{logger:e,workflowConfigType:o.DSR}):[],B.includes(`preferenceOptions`)?ne(f,{logger:e}):[],B.includes(`systemDiscovery`)?ue(f,{logger:e}):[]]),Z=B.includes(`consentManager`)&&q?await _e(f,{logger:e,filterBy:{airgapBundleId:q.id}}):void 0,Q={},at=s(G.map(([{apiKeys:e}])=>e.map(({title:e})=>e))),$=Object.values(De).filter(({title:e})=>B.includes(`apiKeys`)?!0:at.includes(e));if($.length>0&&B.includes(`apiKeys`)&&(Q[`api-keys`]=$.map(({title:e})=>({title:e}))),J.length>0&&B.includes(`partitions`)&&(Q.partitions=J.map(({name:e,partition:t})=>({name:e,partition:t}))),q&&B.includes(`consentManager`)&&(Q[`consent-manager`]={bundleUrls:{TEST:q.testBundleURL,PRODUCTION:q.bundleURL},domains:q.configuration.domains||void 0,partition:q.configuration.partition||void 0,consentPrecedence:q.configuration.consentPrecedence||void 0,unknownRequestPolicy:q.configuration.unknownRequestPolicy||void 0,unknownCookiePolicy:q.configuration.unknownCookiePolicy||void 0,syncEndpoint:q.configuration.syncEndpoint||void 0,telemetryPartitioning:q.configuration.telemetryPartitioning||void 0,signedIabAgreement:q.configuration.signedIabAgreement||void 0,syncGroups:q.configuration.syncGroups||void 0,theme:Z?{primaryColor:Z.primaryColor||void 0,fontColor:Z.fontColor||void 0,privacyPolicy:Z.privacyPolicy||void 0,prompt:Z.prompt}:void 0,experiences:Ie.map(e=>({name:e.name,displayName:e.displayName||void 0,regions:e.regions.map(e=>({countrySubDivision:e.countrySubDivision||void 0,country:e.country||void 0})),onConsentExpiry:e.onConsentExpiry,consentExpiry:e.consentExpiry,operator:e.operator,displayPriority:e.displayPriority,viewState:e.viewState,purposes:e.purposes.map(e=>({trackingType:e.trackingType})),optedOutPurposes:e.optedOutPurposes.map(e=>({trackingType:e.trackingType})),browserLanguages:e.browserLanguages,browserTimeZones:e.browserTimeZones,consentUiVariantSlug:e.consentUiVariant?.slug})),consentVariants:Le.map(e=>({id:e.id,name:e.name,slug:e.slug,description:e.description,configuration:JSON.stringify(e.configuration),locales:e.locales,status:e.status,userFlow:e.userFlow,themeSlug:e.theme?.slug})),consentThemes:Re.map(e=>({id:e.id,name:e.name,slug:e.slug,configuration:JSON.stringify(e.configuration)}))}),et.length>0&&B.includes(`assessments`)&&(Q.assessments=et.map(({title:e,assessmentGroup:t,sections:n,creator:r,description:i,status:a,assignees:o,externalAssignees:s,reviewers:c,isLocked:l,isArchived:u,isExternallyCreated:d,dueDate:f,createdAt:p,assignedAt:m,submittedAt:h,approvedAt:g,rejectedAt:_,titleIsInternal:v,retentionSchedule:y,attributeValues:b,resources:x,syncedRows:S})=>({title:e,group:t.title,sections:n.map(({title:e,status:t,questions:n,assignees:r,isReviewed:i,externalAssignees:a})=>({title:e,status:t,questions:n.map(({title:e,type:t,subType:n,placeholder:r,description:i,isRequired:a,referenceId:o,displayLogic:s,riskLogic:c,riskCategories:l,riskFramework:u,answerOptions:d,selectedAnswers:f,allowedMimeTypes:p,allowSelectOther:m,syncModel:h,syncColumn:g,attributeKey:_,requireRiskEvaluation:v,requireRiskMatrixEvaluation:y})=>{let b=s?P(s):void 0;return{title:e,type:t,"sub-type":n,placeholder:r,description:i,"is-required":a,"reference-id":o,"display-logic":b&&Object.keys(b).length>0?{action:b.action,rule:b.rule?{"depends-on-question-reference-id":b.rule.dependsOnQuestionReferenceId,"comparison-operator":b.rule.comparisonOperator,"comparison-operands":`comparisonOperands`in b.rule?b.rule.comparisonOperands:void 0}:void 0,"nested-rule":b.nestedRule?{"logic-operator":b.nestedRule.logicOperator,rules:(b.nestedRule.rules||[]).map(e=>({"depends-on-question-reference-id":e.dependsOnQuestionReferenceId,"comparison-operator":e.comparisonOperator,"comparison-operands":`comparisonOperands`in e?e.comparisonOperands:void 0}))}:void 0}:void 0,"risk-logic":c.map(e=>{let t=F(e);return{"risk-level":t.riskAssignment?.riskLevelId,"comparison-operands":t.comparisonOperands,"comparison-operator":t.comparisonOperator}}),"risk-categories":l.map(({title:e})=>e),"risk-framework":u?.title,"answer-options":d.map(({value:e})=>({value:e})),"selected-answers":f.map(({value:e})=>e),"allowed-mime-types":p,"allow-select-other":m,"sync-model":h||void 0,"sync-column":g||void 0,"attribute-key":_?.name,"require-risk-evaluation":v,"require-risk-matrix-evaluation":y}}),assignees:r.map(({email:e})=>e),"external-assignees":a.map(({email:e})=>e),"is-reviewed":i})),creator:r?.email,description:i,status:a,assignees:o.map(({email:e})=>e),"external-assignees":s.map(({email:e})=>e),reviewers:c.map(({email:e})=>e),locked:l,archived:u,external:d,"title-is-internal":v,"due-date":f||void 0,"created-at":p||void 0,"assigned-at":m||void 0,"submitted-at":h||void 0,"approved-at":g||void 0,"rejected-at":_||void 0,"retention-schedule":y?{type:y.type,"duration-days":y.durationDays,operand:y.operation}:void 0,attributes:b!==void 0&&b.length>0?j(b):void 0,resources:x.map(({resourceType:e,title:t,name:n,category:r,type:i,purpose:a})=>({type:e,title:r?`${r} - ${n}`:a?`${a} - ${n}`:t||n||i||``})),rows:S.map(({resourceType:e,title:t,name:n,category:r,type:i,purpose:a})=>({type:e,title:r?`${r} - ${n}`:a?`${a} - ${n}`:t||n||i||``}))}))),tt.length>0&&B.includes(`assessmentTemplates`)&&(Q[`assessment-templates`]=tt.map(({title:e,description:t,sections:n,status:r,source:i,creator:a,isLocked:o,isArchived:s,createdAt:c,retentionSchedule:l})=>({title:e,description:t,sections:n.map(({title:e,questions:t})=>({title:e,questions:t.map(({title:e,type:t,subType:n,placeholder:r,description:i,isRequired:a,referenceId:o,displayLogic:s,riskLogic:c,riskCategories:l,riskFramework:u,answerOptions:d,allowedMimeTypes:f,allowSelectOther:p,syncModel:m,syncColumn:h,attributeKey:g,requireRiskEvaluation:_,requireRiskMatrixEvaluation:v})=>{let y=s?P(s):void 0;return{title:e,type:t,"sub-type":n,placeholder:r,description:i,"is-required":a,"reference-id":o,"display-logic":y&&Object.keys(y).length>0?{action:y.action,rule:y.rule?{"depends-on-question-reference-id":y.rule.dependsOnQuestionReferenceId,"comparison-operator":y.rule.comparisonOperator,"comparison-operands":`comparisonOperands`in y.rule?y.rule.comparisonOperands:void 0}:void 0,"nested-rule":y.nestedRule?{"logic-operator":y.nestedRule.logicOperator,rules:(y.nestedRule.rules||[]).map(e=>({"depends-on-question-reference-id":e.dependsOnQuestionReferenceId,"comparison-operator":e.comparisonOperator,"comparison-operands":`comparisonOperands`in e?e.comparisonOperands:void 0}))}:void 0}:void 0,"risk-logic":c.map(e=>{let t=F(e);return{"risk-level":t.riskAssignment?.riskLevelId,"risk-matrix-row":t.riskAssignment?.riskMatrixRowId,"risk-matrix-column":t.riskAssignment?.riskMatrixColumnId,"comparison-operands":t.comparisonOperands,"comparison-operator":t.comparisonOperator}}),"risk-categories":l.map(({title:e})=>e),"risk-framework":u?.title,"answer-options":d.map(({value:e})=>({value:e})),"allowed-mime-types":f,"allow-select-other":p,"sync-model":m||void 0,"sync-column":h||void 0,"attribute-key":g?.name,"require-risk-evaluation":_,"require-risk-matrix-evaluation":v}})})),status:r,source:i,creator:a?.email,locked:o,archived:s,"created-at":c||void 0,"retention-schedule":l?{type:l.type,"duration-days":l.durationDays,operand:l.operation}:void 0}))),it.length>0&&B.includes(`systemDiscovery`)&&(Q[`system-discovery`]=it.map(({title:e,resourceId:t,suggestedCatalog:{title:n},plugin:{dataSilo:{title:r}},country:i,countrySubDivision:a,plaintextContext:o,containsSensitiveData:s,status:c})=>({title:e,resourceId:t,suggestedCatalog:n,plugin:r,country:i||void 0,countrySubDivision:a||void 0,plaintextContext:o,containsSensitiveData:s,status:c}))),ze.length>0&&B.includes(`prompts`)&&(Q.prompts=ze.map(({title:e,content:t})=>({title:e,content:t}))),Be.length>0&&B.includes(`promptPartials`)&&(Q[`prompt-partials`]=Be.map(({title:e,content:t})=>({title:e,content:t}))),Ve.length>0&&B.includes(`promptGroups`)&&(Q[`prompt-groups`]=Ve.map(({title:e,description:t,prompts:n})=>({title:e,description:t,prompts:n.map(({title:e})=>e)}))),Xe.length>0&&B.includes(`teams`)&&(Q.teams=Xe.map(({name:e,description:t,ssoDepartment:n,ssoGroup:r,ssoTitle:i,users:a,scopes:o,parentTeam:s})=>({name:e,description:t,"sso-department":n||void 0,"sso-group":r||void 0,"sso-title":i||void 0,"parent-team-name":s?.name,users:a.map(({email:e})=>e),scopes:o.map(({name:e})=>e)}))),W.length>0&&B.includes(`dataSubjects`)&&(Q[`data-subjects`]=W.map(({type:e,title:t,active:n,adminDashboardDefaultSilentMode:r,actions:i})=>({type:e,title:t?.defaultMessage,active:n,adminDashboardDefaultSilentMode:r,actions:i.map(({type:e})=>e)}))),Ze.length>0&&(Q.policies=Ze.map(({title:e,type:t,versions:n,disabledLocales:r})=>({title:e?.defaultMessage,type:t,content:n?.[0]?.content?.defaultMessage,disabledLocales:r}))),$e.length>0&&(Q.messages=$e.map(({id:e,defaultMessage:t,targetReactIntlId:n,description:r,translations:i})=>({id:e,defaultMessage:t,description:r,targetReactIntlId:n||void 0,translations:i.reduce((e,{locale:t,value:n})=>Object.assign(e,{[t]:n}),{})}))),Qe.length>0){let e=Qe[0];Q[`privacy-center`]={isDisabled:e.isDisabled,showPrivacyRequestButton:e.showPrivacyRequestButton,showPolicies:e.showPolicies,showTrackingTechnologies:e.showTrackingTechnologies,showCookies:e.showCookies,showDataFlows:e.showDataFlows,showConsentManager:e.showConsentManager,showManageYourPrivacy:e.showManageYourPrivacy,showMarketingPreferences:e.showMarketingPreferences,locales:e.locales,defaultLocale:e.defaultLocale,preferBrowserDefaultLocale:e.preferBrowserDefaultLocale,supportEmail:e.supportEmail||void 0,replyToEmail:e.replyToEmail||void 0,useNoReplyEmailAddress:e.useNoReplyEmailAddress,useCustomEmailDomain:e.useCustomEmailDomain,transformAccessReportJsonToCsv:e.transformAccessReportJsonToCsv,home:e.home||void 0,expandSideMenuByDefault:e.expandSideMenuByDefault,workflowsCustomFieldsRequired:e.workflowsCustomFieldsRequired,footerLayout:e.footerLayout,...e.childOrganizations.length>0?{displayedChildOrganizationUris:e.childOrganizations.map(e=>e.uri)}:{},...e.footerLinks.length>0?{footerLinks:[...e.footerLinks].sort((e,t)=>e.displayOrder-t.displayOrder).map(e=>({title:e.title.defaultMessage,...e.url?{url:e.url}:{},...e.iconOnly?{iconOnly:e.iconOnly}:{}}))}:{},theme:e.theme}}if(Pe.length>0&&B.includes(`businessEntities`)&&(Q[`business-entities`]=Pe.map(({title:e,description:t,address:n,headquarterCountry:r,headquarterSubDivision:i,dataProtectionOfficerName:a,dataProtectionOfficerEmail:o,attributeValues:s})=>({title:e,description:t||void 0,address:n||void 0,headquarterCountry:r||void 0,headquarterSubDivision:i||void 0,dataProtectionOfficerName:a||void 0,dataProtectionOfficerEmail:o||void 0,attributes:s!==void 0&&s.length>0?j(s):void 0}))),Fe.length>0&&B.includes(`processingActivities`)&&(Q[`processing-activities`]=Fe.map(({title:e,description:t,securityMeasureDetails:n,controllerships:r,storageRegions:i,transferRegions:o,retentionType:s,retentionPeriod:c,dataProtectionImpactAssessmentLink:l,dataProtectionImpactAssessmentStatus:u,attributeValues:d,dataSilos:f,dataSubjects:p,teams:m,owners:h,processingPurposeSubCategories:g,dataSubCategories:_,saaSCategories:v})=>({title:e,description:t,securityMeasureDetails:n??void 0,controllerships:r.length>0?r:void 0,storageRegions:i.length>0?M(i):void 0,transferRegions:o.length>0?M(o):void 0,retentionType:s,retentionPeriod:s===a.StatedPeriod?c:void 0,dataProtectionImpactAssessmentLink:l??void 0,dataProtectionImpactAssessmentStatus:u,attributes:d!==void 0&&d.length>0?j(d):void 0,dataSiloTitles:f.length>0?f.map(({title:e})=>e):void 0,dataSubjectTypes:p.length>0?p.map(({type:e})=>e):void 0,teamNames:m.length>0?m.map(({name:e})=>e):void 0,ownerEmails:h.length>0?h.map(({email:e})=>e):void 0,processingSubPurposes:g.length>0?g.map(({name:e,purpose:t})=>({purpose:t,...e?{name:e}:{}})):void 0,dataSubCategories:_.length>0?_.map(({name:e,category:t})=>({category:t,...e?{name:e}:{}})):void 0,saaSCategories:v.length>0?v.map(({title:e})=>e):void 0}))),Ne.length>0&&B.includes(`actions`)&&(Q.actions=Ne.map(({type:e,skipSecondaryIfNoFiles:t,skipDownloadableStep:n,requiresReview:r,regionList:a,regionDetectionMethod:o,waitingPeriod:s})=>({type:e,...e===i.Erasure?{skipSecondaryIfNoFiles:t,skipDownloadableStep:n}:{},requiresReview:r,waitingPeriod:s,regionDetectionMethod:o,regionList:a.length>0?a:void 0}))),Me.length>0&&B.includes(`identifiers`)&&(Q.identifiers=Me.map(({name:e,type:t,regex:n,selectOptions:r,privacyCenterVisibility:i,isRequiredInForm:a,placeholder:o,displayTitle:s,dataSubjects:c,displayDescription:l,displayOrder:u,isUniqueOnPreferenceStore:d})=>({name:e,type:t,regex:n,selectOptions:r.length>0?r:void 0,privacyCenterVisibility:i.length>0?i:void 0,isRequiredInForm:a,placeholder:o||void 0,dataSubjects:c.length>0?c.map(({type:e})=>e):void 0,displayTitle:s?.defaultMessage,displayDescription:l?.defaultMessage,displayOrder:u,isUniqueOnPreferenceStore:d}))),He.length>0&&B.includes(`agents`)&&(Q.agents=He.map(({name:e,agentId:t,description:n,instructions:r,codeInterpreterEnabled:i,retrievalEnabled:a,prompt:o,largeLanguageModel:s,teams:c,owners:l,agentFunctions:u,agentFiles:d})=>({name:e,agentId:t,description:n||void 0,instructions:r,codeInterpreterEnabled:i,retrievalEnabled:a,prompt:o?.title,"large-language-model":{name:s.name,client:s.client},teams:c&&c.length>0?c.map(({name:e})=>e):void 0,owners:l&&l.length>0?l.map(({email:e})=>e):void 0,"agent-functions":u&&u.length>0?u.map(({name:e})=>e):void 0,"agent-files":d&&d.length>0?d.map(({name:e})=>e):void 0}))),Je.length>0&&B.includes(`actionItems`)&&(Q[`action-items`]=Je.map(({teams:e,users:t,customerExperienceActionItemIds:[n],dueDate:r,priority:i,resolved:a,collections:o,notes:s,link:c,title:l,type:u,attributeValues:d})=>({teams:e.map(({name:e})=>e),users:t.map(({email:e})=>e),dueDate:r||void 0,title:l,notes:s,customerExperienceActionItemId:n,collections:o.map(({title:e})=>e),link:c,priority:i||void 0,resolved:a,type:u,attributes:d!==void 0&&d.length>0?j(d):void 0}))),Ye.length>0&&B.includes(`actionItemCollections`)&&(Q[`action-item-collections`]=Ye.map(({title:e,description:t,hidden:n,productLine:r})=>({title:e,description:t||void 0,hidden:n,productLine:r}))),Ue.length>0&&B.includes(`agentFunctions`)&&(Q[`agent-functions`]=Ue.map(({name:e,description:t,parameters:n})=>({name:e,description:t,parameters:JSON.stringify(n)}))),We.length>0&&B.includes(`agentFiles`)&&(Q[`agent-files`]=We.map(({name:e,description:t,fileId:n,size:r,purpose:i})=>({name:e,description:t,fileId:n,size:r,purpose:i}))),Ge.length>0&&B.includes(`vendors`)&&(Q.vendors=Ge.map(({title:e,description:t,dataProcessingAgreementLink:n,contactName:r,contactPhone:i,address:a,headquarterCountry:o,headquarterSubDivision:s,websiteUrl:c,businessEntity:l,teams:u,owners:d,attributeValues:f})=>({title:e,description:t||void 0,dataProcessingAgreementLink:n||void 0,contactName:r||void 0,contactPhone:i||void 0,address:a||void 0,headquarterCountry:o||void 0,headquarterSubDivision:s||void 0,websiteUrl:c||void 0,businessEntity:l?.title,teams:u&&u.length>0?u.map(({name:e})=>e):void 0,owners:d&&d.length>0?d.map(({email:e})=>e):void 0,attributes:f!==void 0&&f.length>0?j(f):void 0}))),Ke.length>0&&B.includes(`dataCategories`)&&(Q[`data-categories`]=Ke.map(({name:e,category:t,description:n,regex:r,owners:i,teams:a,attributeValues:o})=>({name:e,category:t,description:n||void 0,regex:r||void 0,owners:i&&i.length>0?i.map(({email:e})=>e):void 0,teams:a&&a.length>0?a.map(({name:e})=>e):void 0,attributes:o!==void 0&&o.length>0?j(o):void 0}))),qe.length>0&&B.includes(`processingPurposes`)&&(Q[`processing-purposes`]=qe.map(({name:e,purpose:t,description:n,owners:r,teams:i,attributeValues:a})=>({name:e,purpose:t,description:n||void 0,owners:r&&r.length>0?r.map(({email:e})=>e):void 0,teams:i&&i.length>0?i.map(({name:e})=>e):void 0,attributes:a!==void 0&&a.length>0?j(a):void 0}))),Oe.length>0&&B.includes(`dataFlows`)&&(Q[`data-flows`]=Oe.map(({value:e,type:t,description:n,trackingType:r,service:i,status:a,owners:o,teams:s,attributeValues:c})=>({value:e,type:t,description:n||void 0,trackingPurposes:r,status:a,service:i?.integrationName,owners:o.map(({email:e})=>e),teams:s.map(({name:e})=>e),attributes:c!==void 0&&c.length>0?j(c):void 0}))),ke.length>0&&B.includes(`cookies`)&&(Q.cookies=ke.map(({name:e,isRegex:t,description:n,trackingPurposes:r,service:i,status:a,owners:o,teams:s,attributeValues:c})=>({name:e,isRegex:t,description:n||void 0,trackingPurposes:r,status:a,service:i?.integrationName,owners:o.map(({email:e})=>e),teams:s.map(({name:e})=>e),attributes:c!==void 0&&c.length>0?j(c):void 0}))),Ae.length>0&&B.includes(`customFields`)&&(Q.attributes=Ae.map(({description:e,name:t,type:n,values:r,enabledOn:i=[]})=>({description:e||void 0,resources:i,name:t,type:n,values:r.map(({name:e,color:t,description:n})=>({name:e,color:t||void 0,description:n}))}))),nt.length>0&&(Q.purposes=nt.map(({name:e,description:t,trackingType:n,defaultConsent:i,configurable:a,showInConsentManager:o,isActive:s,displayOrder:c,optOutSignals:l,authLevel:u,topics:d,showInPrivacyCenter:f,title:p})=>({name:e,title:p,description:t||void 0,trackingType:n,"default-consent":i,configurable:a,"show-in-consent-manager":o,"show-in-privacy-center":f,"is-active":s,"display-order":c,"opt-out-signals":l.length>0?l:void 0,"auth-level":u||void 0,"preference-topics":d.map(({slug:e,title:t,type:n,color:i,displayDescription:a,defaultConfiguration:o,showInPrivacyCenter:s,preferenceOptionValues:c})=>({slug:e,title:t.defaultMessage,type:n,color:i,description:a.defaultMessage,"default-configuration":o,"show-in-privacy-center":s,options:n===r.Boolean?[]:c.map(({title:e,slug:t})=>({title:e.defaultMessage,slug:t}))}))}))),X.length>0&&B.includes(`workflowConfigs`)){let t=X.map(e=>({title:e.title.defaultMessage,"action-type":e.action.type,...e.internalName?{"internal-name":e.internalName}:{},...e.subtitle?{subtitle:e.subtitle.defaultMessage}:{},...e.description?{description:e.description.defaultMessage}:{},...e.subject?{"data-subject-type":e.subject.type}:{},visibility:e.workflowConfigVisibility,type:e.workflowConfigType,...e.collectDataSubjectRegions?{"collect-data-subject-regions":e.collectDataSubjectRegions}:{},...e.regionList.length>0?{"region-list":e.regionList}:{},...e.expiryTime&&e.expiryTime.length>0?{"expiry-time":e.expiryTime}:{},...e.WorkflowConfigAttributeKeys&&e.WorkflowConfigAttributeKeys.length>0?{"attribute-keys":e.WorkflowConfigAttributeKeys.map(({attributeKey:e})=>e.name)}:{}})),n=c(X,we);for(let t of Object.values(n))if(t.length>1){let n=t[0];e.warn(`Found "${t.length}" workflow configs with the same title, action-type, data-subject-type, and region-list for "${n.title.defaultMessage}" (${n.action.type}). Push will fail until they are disambiguated (for example with unique internal names).`)}t.length>0&&(Q[`workflow-configs`]=t)}if(Y.length>0&&B.includes(`preferenceWorkflowConfigs`)){let t=Y.some(e=>e.workflowConfigId)?await A(f,{logger:e,workflowConfigType:o.DSR}):[];Q[`preference-workflow-configs`]=Y.map(e=>{let n=Se(e.triggerCondition),r={name:e.name,"data-subject-type":e.subject.type,"is-silent":e.isSilent,"allow-unauthenticated":e.allowUnauthenticated,"is-active":e.isActive,purposes:n};if(e.workflowConfigId){let n=Ce(t,e.workflowConfigId);if(n)return{...r,"workflow-title":n}}return{...r,"action-type":e.action.type,"data-silo-titles":e.dataSilos.length>0?e.dataSilos.map(e=>e.title):void 0}})}if(rt.length>0&&B.includes(`preferenceOptions`)&&(Q[`preference-options`]=rt.map(({slug:e,title:t})=>({slug:e,title:t.defaultMessage}))),N.length===0&&je.length>0&&B.includes(`templates`)&&(Q.templates=je.map(({title:e})=>({title:e}))),K.length>0&&B.includes(`enrichers`)&&(Q.enrichers=K.map(({title:e,url:t,type:n,inputIdentifier:r,identifiers:a,actions:o,testRegex:s,dataSubjects:c,expirationDuration:l,lookerQueryTitle:u,transitionRequestStatus:d,phoneNumbers:f,regionList:p})=>({title:e,url:t||void 0,type:n,"input-identifier":r?.name,"output-identifiers":a.map(({name:e})=>e),"privacy-actions":Object.values(i).length===o.length?void 0:o,testRegex:s||void 0,lookerQueryTitle:u||void 0,expirationDuration:parseInt(l,10),transitionRequestStatus:d||void 0,phoneNumbers:f&&f.length>0?f:void 0,regionList:p&&p.length>0?p:void 0,"data-subjects":c.map(({type:e})=>e)}))),G.length>0&&B.includes(`dataSilos`)){let e=l(W,`type`);Q[`data-silos`]=G.map(([{title:t,description:n,url:r,type:i,outerType:a,apiKeys:o,notifyEmailAddress:s,identifiers:c,dependentDataSilos:d,owners:f,country:m,countrySubDivision:h,teams:g,subjectBlocklist:_,isLive:v,promptAVendorEmailSendFrequency:y,promptAVendorEmailSendType:b,promptAVendorEmailIncludeIdentifiersAttachment:x,promptAVendorEmailCompletionLinkType:S,manualWorkRetryFrequency:C,catalog:w,attributeValues:T,discoveredBy:E,businessEntities:D,sombra:O},k])=>({title:t,description:n,integrationName:i,"outer-type":a||void 0,url:r||void 0,"api-key-title":o[0]?.title,"sombra-id":O?.id||void 0,"identity-keys":c.filter(({isConnected:e})=>e).map(({name:e})=>e),...d.length>0?{"deletion-dependencies":d.map(({title:e})=>e)}:{},...f.length>0?{owners:f.map(({email:e})=>e)}:{},...g.length>0?{teams:g.map(({name:e})=>e)}:{},...E.length>0?{discoveredBy:E.map(({title:e})=>e)}:{},...D.length>0?{businessEntities:D.map(({title:e})=>e)}:{},country:m||void 0,countrySubDivision:h||void 0,disabled:!v,"data-subjects":_.length>0?p(_.map(({type:e})=>e),e):void 0,...w.hasAvcFunctionality?{"email-settings":{"notify-email-address":s||void 0,"send-frequency":y,"send-type":b,"include-identifiers-attachment":x,"completion-link-type":S,"manual-work-retry-frequency":C}}:{},attributes:T!==void 0&&T.length>0?j(T):void 0,datapoints:k.map(e=>({key:e.name,title:e.title?.defaultMessage,description:e.description?.defaultMessage,owners:e.owners.map(({email:e})=>e),teams:e.teams.map(({name:e})=>e),...e.path.length>0?{path:e.path}:{},...e.dataCollection?.title?{"data-collection-tag":e.dataCollection.title.defaultMessage}:{},...e.dbIntegrationQueries.length>0?{"privacy-action-queries":u(l(e.dbIntegrationQueries,`requestType`),e=>e.suggestedQuery||e.query||void 0)}:{},...e.subDataPoints.length>0?{fields:e.subDataPoints.map(e=>({key:e.name,description:e.description,purposes:e.purposes,categories:e.categories,...H&&e.pendingCategoryGuesses?{"guessed-categories":e.pendingCategoryGuesses.filter(e=>e.status===`PENDING`).map(e=>({category:{name:e.category.name,category:e.category.category},status:e.status,confidence:e.confidence,classifierVersion:e.classifierVersion||void 0}))}:{},"access-request-visibility-enabled":e.accessRequestVisibilityEnabled,"erasure-request-redaction-enabled":e.erasureRequestRedactionEnabled,attributes:e.attributeValues!==void 0&&e.attributeValues.length>0?j(e.attributeValues):void 0})).sort((e,t)=>e.key.localeCompare(t.key))}:{},"privacy-actions":e.actionSettings.filter(({active:e})=>e).map(({type:e})=>e)})).sort((e,t)=>[...e.path??[],e.key].join(`.`).localeCompare([...t.path??[],t.key].join(`.`)))}))}return Q}export{L as i,B as n,R as r,z as t};
58
+ //# sourceMappingURL=pullTranscendConfiguration-BPkc-b3x.mjs.map