@transcend-io/cli 10.29.0 → 10.29.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/dist/{app-C5baDSA2.mjs → app-DxjIt23c.mjs} +16 -16
  2. package/dist/{app-C5baDSA2.mjs.map → app-DxjIt23c.mjs.map} +1 -1
  3. package/dist/{approvePrivacyRequests-B8x7oxTn.mjs → approvePrivacyRequests-CFKObXCt.mjs} +2 -2
  4. package/dist/{approvePrivacyRequests-B8x7oxTn.mjs.map → approvePrivacyRequests-CFKObXCt.mjs.map} +1 -1
  5. package/dist/bin/bash-complete.mjs +1 -1
  6. package/dist/bin/cli.mjs +1 -1
  7. package/dist/bin/deprecated-command.mjs +1 -1
  8. package/dist/{buildExamples-7KXBjl-b.mjs → buildExamples-DTMKJ2pF.mjs} +2 -2
  9. package/dist/{buildExamples-7KXBjl-b.mjs.map → buildExamples-DTMKJ2pF.mjs.map} +1 -1
  10. package/dist/{buildXdiSyncEndpoint-DcrkZ2Gu.mjs → buildXdiSyncEndpoint-D8YJpLZd.mjs} +2 -2
  11. package/dist/{buildXdiSyncEndpoint-DcrkZ2Gu.mjs.map → buildXdiSyncEndpoint-D8YJpLZd.mjs.map} +1 -1
  12. package/dist/{bulkRestartRequests-CysUfl98.mjs → bulkRestartRequests-CMdTpO-W.mjs} +2 -2
  13. package/dist/{bulkRestartRequests-CysUfl98.mjs.map → bulkRestartRequests-CMdTpO-W.mjs.map} +1 -1
  14. package/dist/{bulkRetryEnrichers-DaLE67Ht.mjs → bulkRetryEnrichers-DeLVA0zH.mjs} +2 -2
  15. package/dist/{bulkRetryEnrichers-DaLE67Ht.mjs.map → bulkRetryEnrichers-DeLVA0zH.mjs.map} +1 -1
  16. package/dist/{cancelPrivacyRequests-D0zNUNdS.mjs → cancelPrivacyRequests-DvRHEAjF.mjs} +2 -2
  17. package/dist/{cancelPrivacyRequests-D0zNUNdS.mjs.map → cancelPrivacyRequests-DvRHEAjF.mjs.map} +1 -1
  18. package/dist/{command-CIv9yk86.mjs → command-jo1QPpAq.mjs} +2 -2
  19. package/dist/{command-CIv9yk86.mjs.map → command-jo1QPpAq.mjs.map} +1 -1
  20. package/dist/{constants-jjHIzHGm.mjs → constants-BnIMwfNb.mjs} +2 -2
  21. package/dist/{constants-jjHIzHGm.mjs.map → constants-BnIMwfNb.mjs.map} +1 -1
  22. package/dist/{createPoolingCommandUi-uiDjLlqf.mjs → createPoolingCommandUi-CE6fvB2v.mjs} +2 -2
  23. package/dist/{createPoolingCommandUi-uiDjLlqf.mjs.map → createPoolingCommandUi-CE6fvB2v.mjs.map} +1 -1
  24. package/dist/{downloadPrivacyRequestFiles-B_BVxW5Z.mjs → downloadPrivacyRequestFiles-DUFTfiZL.mjs} +2 -2
  25. package/dist/{downloadPrivacyRequestFiles-B_BVxW5Z.mjs.map → downloadPrivacyRequestFiles-DUFTfiZL.mjs.map} +1 -1
  26. package/dist/{generateCrossAccountApiKeys-Bnqgmj-H.mjs → generateCrossAccountApiKeys-BNze2Fyn.mjs} +2 -2
  27. package/dist/{generateCrossAccountApiKeys-Bnqgmj-H.mjs.map → generateCrossAccountApiKeys-BNze2Fyn.mjs.map} +1 -1
  28. package/dist/{impl-xq89cSSz2.mjs → impl-B-nmILxQ2.mjs} +2 -2
  29. package/dist/{impl-xq89cSSz2.mjs.map → impl-B-nmILxQ2.mjs.map} +1 -1
  30. package/dist/{impl-DNe-gRXe2.mjs → impl-BA0u3f6F2.mjs} +2 -2
  31. package/dist/{impl-DNe-gRXe2.mjs.map → impl-BA0u3f6F2.mjs.map} +1 -1
  32. package/dist/{impl-BH_A5rgL.mjs → impl-BQjsGfVz.mjs} +2 -2
  33. package/dist/{impl-BH_A5rgL.mjs.map → impl-BQjsGfVz.mjs.map} +1 -1
  34. package/dist/{impl-BqWQh9Ss.mjs → impl-BUVf0UQ0.mjs} +2 -2
  35. package/dist/{impl-BqWQh9Ss.mjs.map → impl-BUVf0UQ0.mjs.map} +1 -1
  36. package/dist/{impl-CXTBcYo6.mjs → impl-BUbupZLV.mjs} +2 -2
  37. package/dist/{impl-CXTBcYo6.mjs.map → impl-BUbupZLV.mjs.map} +1 -1
  38. package/dist/{impl-XrTL-TDl.mjs → impl-Bq0lE7N5.mjs} +2 -2
  39. package/dist/{impl-XrTL-TDl.mjs.map → impl-Bq0lE7N5.mjs.map} +1 -1
  40. package/dist/{impl-BOawPhYE.mjs → impl-C3EjC8hF.mjs} +2 -2
  41. package/dist/{impl-BOawPhYE.mjs.map → impl-C3EjC8hF.mjs.map} +1 -1
  42. package/dist/{impl-Bc6p8A1l2.mjs → impl-CMDIQiHg2.mjs} +2 -2
  43. package/dist/{impl-Bc6p8A1l2.mjs.map → impl-CMDIQiHg2.mjs.map} +1 -1
  44. package/dist/{impl-DuZjI6p0.mjs → impl-CMFrsj8b.mjs} +2 -2
  45. package/dist/{impl-DuZjI6p0.mjs.map → impl-CMFrsj8b.mjs.map} +1 -1
  46. package/dist/{impl-CQVy2k3o.mjs → impl-Cav9IgWW.mjs} +2 -2
  47. package/dist/{impl-CQVy2k3o.mjs.map → impl-Cav9IgWW.mjs.map} +1 -1
  48. package/dist/{impl-INhq_CiK.mjs → impl-CdSGCsQD.mjs} +2 -2
  49. package/dist/{impl-INhq_CiK.mjs.map → impl-CdSGCsQD.mjs.map} +1 -1
  50. package/dist/{impl-2iVTxNn4.mjs → impl-Cgy6VLCF.mjs} +2 -2
  51. package/dist/{impl-2iVTxNn4.mjs.map → impl-Cgy6VLCF.mjs.map} +1 -1
  52. package/dist/{impl-BXUYpR27.mjs → impl-CnoGZZoX.mjs} +2 -2
  53. package/dist/{impl-BXUYpR27.mjs.map → impl-CnoGZZoX.mjs.map} +1 -1
  54. package/dist/{impl-RPG-BTmX.mjs → impl-CoNyUtMT.mjs} +2 -2
  55. package/dist/{impl-RPG-BTmX.mjs.map → impl-CoNyUtMT.mjs.map} +1 -1
  56. package/dist/{impl-CwXp3Tbr.mjs → impl-CrdDX-vS.mjs} +2 -2
  57. package/dist/{impl-CwXp3Tbr.mjs.map → impl-CrdDX-vS.mjs.map} +1 -1
  58. package/dist/{impl-DMe_OqJx.mjs → impl-D9ae4SOp.mjs} +2 -2
  59. package/dist/{impl-DMe_OqJx.mjs.map → impl-D9ae4SOp.mjs.map} +1 -1
  60. package/dist/{impl-KmCNH-yw.mjs → impl-DM0nXs11.mjs} +2 -2
  61. package/dist/{impl-KmCNH-yw.mjs.map → impl-DM0nXs11.mjs.map} +1 -1
  62. package/dist/{impl-CwKYKBYb.mjs → impl-DMaHiR8F.mjs} +2 -2
  63. package/dist/{impl-CwKYKBYb.mjs.map → impl-DMaHiR8F.mjs.map} +1 -1
  64. package/dist/{impl-CvLI_Jig.mjs → impl-DRGgLGNU.mjs} +2 -2
  65. package/dist/{impl-CvLI_Jig.mjs.map → impl-DRGgLGNU.mjs.map} +1 -1
  66. package/dist/{impl-DVQmuZQY.mjs → impl-DRvnUtsd.mjs} +2 -2
  67. package/dist/{impl-DVQmuZQY.mjs.map → impl-DRvnUtsd.mjs.map} +1 -1
  68. package/dist/{impl-Dw8NYkzw.mjs → impl-DayplqEn.mjs} +2 -2
  69. package/dist/{impl-Dw8NYkzw.mjs.map → impl-DayplqEn.mjs.map} +1 -1
  70. package/dist/{impl-BDrvzlpf2.mjs → impl-DdHPAFYq2.mjs} +2 -2
  71. package/dist/{impl-BDrvzlpf2.mjs.map → impl-DdHPAFYq2.mjs.map} +1 -1
  72. package/dist/{impl-DK7nSMle2.mjs → impl-Dn_PyB5_2.mjs} +2 -2
  73. package/dist/{impl-DK7nSMle2.mjs.map → impl-Dn_PyB5_2.mjs.map} +1 -1
  74. package/dist/{impl-DLG0Egy6.mjs → impl-Dzqr61LA.mjs} +2 -2
  75. package/dist/{impl-DLG0Egy6.mjs.map → impl-Dzqr61LA.mjs.map} +1 -1
  76. package/dist/{impl-DNzkRayg.mjs → impl-RgoaYjMi.mjs} +2 -2
  77. package/dist/{impl-DNzkRayg.mjs.map → impl-RgoaYjMi.mjs.map} +1 -1
  78. package/dist/{impl-DypttZd6.mjs → impl-RuQc4nQ6.mjs} +2 -2
  79. package/dist/{impl-DypttZd6.mjs.map → impl-RuQc4nQ6.mjs.map} +1 -1
  80. package/dist/{impl-DEhw1iNn.mjs → impl-Yb5jtD4V.mjs} +2 -2
  81. package/dist/{impl-DEhw1iNn.mjs.map → impl-Yb5jtD4V.mjs.map} +1 -1
  82. package/dist/{impl-CL29fOWM.mjs → impl-_bJkh9UY.mjs} +2 -2
  83. package/dist/{impl-CL29fOWM.mjs.map → impl-_bJkh9UY.mjs.map} +1 -1
  84. package/dist/{impl-Dx_TfvW1.mjs → impl-cA3shutB.mjs} +2 -2
  85. package/dist/{impl-Dx_TfvW1.mjs.map → impl-cA3shutB.mjs.map} +1 -1
  86. package/dist/{impl-DEJpYLPB.mjs → impl-cjVcQvnQ.mjs} +2 -2
  87. package/dist/{impl-DEJpYLPB.mjs.map → impl-cjVcQvnQ.mjs.map} +1 -1
  88. package/dist/{impl-CyQRmuM72.mjs → impl-ehFICcp72.mjs} +2 -2
  89. package/dist/{impl-CyQRmuM72.mjs.map → impl-ehFICcp72.mjs.map} +1 -1
  90. package/dist/{impl-CuDs6SsI.mjs → impl-oGSoHT2a.mjs} +2 -2
  91. package/dist/{impl-CuDs6SsI.mjs.map → impl-oGSoHT2a.mjs.map} +1 -1
  92. package/dist/{impl-hwpT9u5o2.mjs → impl-x9HLXhsK2.mjs} +2 -2
  93. package/dist/{impl-hwpT9u5o2.mjs.map → impl-x9HLXhsK2.mjs.map} +1 -1
  94. package/dist/{impl-B-j5ACi02.mjs → impl-zVgfQ0im2.mjs} +2 -2
  95. package/dist/{impl-B-j5ACi02.mjs.map → impl-zVgfQ0im2.mjs.map} +1 -1
  96. package/dist/index.mjs +1 -1
  97. package/dist/{markRequestDataSiloIdsCompleted-B5N-cQWr.mjs → markRequestDataSiloIdsCompleted-DX7d2Itu.mjs} +2 -2
  98. package/dist/{markRequestDataSiloIdsCompleted-B5N-cQWr.mjs.map → markRequestDataSiloIdsCompleted-DX7d2Itu.mjs.map} +1 -1
  99. package/dist/{markSilentPrivacyRequests-BiaButWF.mjs → markSilentPrivacyRequests-3t9IZPpS.mjs} +2 -2
  100. package/dist/{markSilentPrivacyRequests-BiaButWF.mjs.map → markSilentPrivacyRequests-3t9IZPpS.mjs.map} +1 -1
  101. package/dist/{notifyPrivacyRequestsAdditionalTime-D3Vtvg5G.mjs → notifyPrivacyRequestsAdditionalTime-Ce_GPf6U.mjs} +2 -2
  102. package/dist/{notifyPrivacyRequestsAdditionalTime-D3Vtvg5G.mjs.map → notifyPrivacyRequestsAdditionalTime-Ce_GPf6U.mjs.map} +1 -1
  103. package/dist/{pullChunkedCustomSiloOutstandingIdentifiers-D85P1W_8.mjs → pullChunkedCustomSiloOutstandingIdentifiers-3OvSjU15.mjs} +2 -2
  104. package/dist/{pullChunkedCustomSiloOutstandingIdentifiers-D85P1W_8.mjs.map → pullChunkedCustomSiloOutstandingIdentifiers-3OvSjU15.mjs.map} +1 -1
  105. package/dist/{pullManualEnrichmentIdentifiersToCsv-DbNSrKEk.mjs → pullManualEnrichmentIdentifiersToCsv-B9AfaSwT.mjs} +2 -2
  106. package/dist/{pullManualEnrichmentIdentifiersToCsv-DbNSrKEk.mjs.map → pullManualEnrichmentIdentifiersToCsv-B9AfaSwT.mjs.map} +1 -1
  107. package/dist/{pushCronIdentifiersFromCsv-5ruUKHtL.mjs → pushCronIdentifiersFromCsv-ByCv8bd4.mjs} +2 -2
  108. package/dist/{pushCronIdentifiersFromCsv-5ruUKHtL.mjs.map → pushCronIdentifiersFromCsv-ByCv8bd4.mjs.map} +1 -1
  109. package/dist/{pushManualEnrichmentIdentifiersFromCsv-B0i2239u.mjs → pushManualEnrichmentIdentifiersFromCsv-BQYjiA9G.mjs} +2 -2
  110. package/dist/{pushManualEnrichmentIdentifiersFromCsv-B0i2239u.mjs.map → pushManualEnrichmentIdentifiersFromCsv-BQYjiA9G.mjs.map} +1 -1
  111. package/dist/{removeUnverifiedRequestIdentifiers-QmeqrmxM.mjs → removeUnverifiedRequestIdentifiers-DOYx5k0N.mjs} +2 -2
  112. package/dist/{removeUnverifiedRequestIdentifiers-QmeqrmxM.mjs.map → removeUnverifiedRequestIdentifiers-DOYx5k0N.mjs.map} +1 -1
  113. package/dist/{retryRequestDataSilos-BfckLjOJ.mjs → retryRequestDataSilos-CUAhRnGs.mjs} +2 -2
  114. package/dist/{retryRequestDataSilos-BfckLjOJ.mjs.map → retryRequestDataSilos-CUAhRnGs.mjs.map} +1 -1
  115. package/dist/{skipPreflightJobs-Do_kwu3m.mjs → skipPreflightJobs-CpJMKv7V.mjs} +2 -2
  116. package/dist/{skipPreflightJobs-Do_kwu3m.mjs.map → skipPreflightJobs-CpJMKv7V.mjs.map} +1 -1
  117. package/dist/{skipRequestDataSilos-BNDhdllD.mjs → skipRequestDataSilos-BkVAyIwG.mjs} +2 -2
  118. package/dist/{skipRequestDataSilos-BNDhdllD.mjs.map → skipRequestDataSilos-BkVAyIwG.mjs.map} +1 -1
  119. package/dist/{streamPrivacyRequestsToCsv-CbJfhV6A.mjs → streamPrivacyRequestsToCsv-CkIiJexX.mjs} +2 -2
  120. package/dist/{streamPrivacyRequestsToCsv-CbJfhV6A.mjs.map → streamPrivacyRequestsToCsv-CkIiJexX.mjs.map} +1 -1
  121. package/dist/{updateConsentManagerVersionToLatest-DEFwH4Se.mjs → updateConsentManagerVersionToLatest-BR_UWjal.mjs} +2 -2
  122. package/dist/{updateConsentManagerVersionToLatest-DEFwH4Se.mjs.map → updateConsentManagerVersionToLatest-BR_UWjal.mjs.map} +1 -1
  123. package/dist/{uploadConsents-ChmFIw_j.mjs → uploadConsents-DeNdLfPd.mjs} +2 -2
  124. package/dist/{uploadConsents-ChmFIw_j.mjs.map → uploadConsents-DeNdLfPd.mjs.map} +1 -1
  125. package/dist/{uploadPrivacyRequestsFromCsv-D3KSb1qH.mjs → uploadPrivacyRequestsFromCsv-CxtOU5CQ.mjs} +2 -2
  126. package/dist/{uploadPrivacyRequestsFromCsv-D3KSb1qH.mjs.map → uploadPrivacyRequestsFromCsv-CxtOU5CQ.mjs.map} +1 -1
  127. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"impl-DEhw1iNn.mjs","names":["CLI_VERSION"],"sources":["../src/commands/custom-functions/init/impl.ts"],"sourcesContent":["import { CUSTOM_FUNCTION_TYPES_VERSION } from '@transcend-io/custom-function-types';\nimport colors from 'colors';\n\nimport { version as CLI_VERSION } from '../../../constants.js';\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { runCapturedProcess } from '../../../lib/cli/run-captured-process.js';\nimport { buildInitAiHandoff } from '../../../lib/custom-functions/ai-handoff.js';\nimport {\n DENO_INSTALL_URL,\n getDenoRuntimeCompatibility,\n SUPPORTED_DENO_MAJOR_VERSION,\n} from '../../../lib/custom-functions/deno-runtime.js';\nimport { discoverCustomFunctionProject } from '../../../lib/custom-functions/project-discovery.js';\nimport {\n CustomFunctionSetupFeature,\n type CustomFunctionSetupFeature as CustomFunctionSetupFeatureType,\n} from '../../../lib/custom-functions/scaffold-model.js';\nimport { buildPlanResult } from '../../../lib/custom-functions/scaffold-output.js';\nimport {\n buildInitPlan,\n getInitPlanningCandidatePaths,\n} from '../../../lib/custom-functions/scaffold-planning.js';\nimport { collectPlanningSnapshots } from '../../../lib/scaffolding/project-discovery.js';\nimport { applyProjectPlan } from '../../../lib/scaffolding/project-plan-apply.js';\nimport {\n displayProjectPath,\n renderProjectPlan,\n} from '../../../lib/scaffolding/project-plan-output.js';\nimport {\n PromptCancelledError,\n type PromptChoice,\n ScaffoldPrompts,\n} from '../../../lib/scaffolding/prompts.js';\n\n/** Flags for `custom-functions init`. */\nexport interface CustomFunctionInitFlags {\n /** Explicit manifest path. */\n manifest?: string;\n /** Install Deno configuration. */\n deno?: boolean;\n /** Install editor recommendations. */\n editor?: boolean;\n /** Install the coding-agent skill. */\n skill?: boolean;\n /** Install GitHub Actions validation. */\n ci?: boolean;\n /** Disable prompts. */\n noInteractive: boolean;\n /** Render but do not apply. */\n dryRun: boolean;\n /** Approve the final displayed plan. */\n yes: boolean;\n /** Emit one stable JSON result on stdout. */\n json: boolean;\n}\n\n/** User-facing setup labels. */\nconst SETUP_LABELS: Readonly<Record<CustomFunctionSetupFeatureType, string>> = {\n [CustomFunctionSetupFeature.Deno]: 'Deno configuration',\n [CustomFunctionSetupFeature.Editor]: 'VS Code settings',\n [CustomFunctionSetupFeature.Skill]: 'Agent skill',\n [CustomFunctionSetupFeature.Ci]: 'GitHub Actions',\n};\n\n/** All optional setup features in stable prompt order. */\nconst ALL_SETUP_FEATURES = Object.values(CustomFunctionSetupFeature);\n\n/**\n * Whether this invocation can ask questions.\n *\n * @param context - CLI context\n * @param flags - Interaction flags\n * @returns Whether prompts are enabled\n */\nfunction isInteractiveInvocation(\n flags: Pick<CustomFunctionInitFlags, 'json' | 'noInteractive'>,\n stdinIsTTY: boolean | undefined,\n stderrIsTTY: boolean | undefined,\n): boolean {\n return !flags.json && !flags.noInteractive && Boolean(stdinIsTTY && stderrIsTTY);\n}\n\n/**\n * Resolve setup directly from individual flags or one checkbox prompt.\n *\n * @param context - CLI context\n * @param prompts - Prompt adapters\n * @param flags - Setup flags\n * @param options - Interaction state\n * @returns Selected setup features\n */\nasync function resolveFeatures(\n prompts: ScaffoldPrompts,\n flags: CustomFunctionInitFlags,\n options: {\n /** Whether prompts are available. */\n interactive: boolean;\n },\n): Promise<CustomFunctionSetupFeatureType[]> {\n const enabled: Readonly<Record<CustomFunctionSetupFeatureType, boolean | undefined>> = {\n [CustomFunctionSetupFeature.Deno]: flags.deno,\n [CustomFunctionSetupFeature.Editor]: flags.editor,\n [CustomFunctionSetupFeature.Skill]: flags.skill,\n [CustomFunctionSetupFeature.Ci]: flags.ci,\n };\n if (!options.interactive) {\n return ALL_SETUP_FEATURES.filter((feature) => enabled[feature] === true);\n }\n const choices: PromptChoice<CustomFunctionSetupFeatureType>[] = ALL_SETUP_FEATURES.map(\n (feature) => ({\n name: SETUP_LABELS[feature],\n value: feature,\n checked: enabled[feature] !== false,\n }),\n );\n return prompts.checkbox('Choose repository setup:', choices);\n}\n\n/**\n * Initialize a credential-free local Custom Function project.\n *\n * @param this - CLI context\n * @param flags - Scaffold and interaction flags\n * @param directory - Optional target directory\n */\nexport async function init(\n this: LocalContext,\n flags: CustomFunctionInitFlags,\n directory?: string,\n): Promise<void> {\n doneInputValidation(this.process);\n try {\n const state = discoverCustomFunctionProject(this, {\n ...(directory ? { directory } : {}),\n ...(flags.manifest ? { manifest: flags.manifest } : {}),\n });\n const prompts = new ScaffoldPrompts(this);\n const interactive = isInteractiveInvocation(\n flags,\n this.process.stdin.isTTY,\n this.process.stderr.isTTY,\n );\n const features = await resolveFeatures(prompts, flags, { interactive });\n const snapshots = collectPlanningSnapshots(\n this,\n state.projectRoot,\n getInitPlanningCandidatePaths(state, { features }),\n );\n const plan = buildInitPlan(\n {\n state,\n snapshots,\n contractVersion: CUSTOM_FUNCTION_TYPES_VERSION,\n cliVersion: CLI_VERSION,\n },\n { features },\n );\n if (features.includes(CustomFunctionSetupFeature.Deno)) {\n const denoVersion = await runCapturedProcess(\n 'deno',\n ['--version'],\n { cwd: this.process.cwd() },\n this,\n );\n if (denoVersion.error?.code === 'ENOENT') {\n plan.warnings.push(\n `Deno ${SUPPORTED_DENO_MAJOR_VERSION}.x is not installed. Install it from ${DENO_INSTALL_URL}`,\n );\n } else if (denoVersion.code !== 0) {\n plan.warnings.push(\n `Deno was found, but its version could not be determined. Deno ${SUPPORTED_DENO_MAJOR_VERSION}.x is required. See ${DENO_INSTALL_URL}`,\n );\n } else {\n const compatibility = getDenoRuntimeCompatibility(denoVersion.stdout);\n if (compatibility.level !== 'compatible') {\n plan.warnings.push(compatibility.message);\n }\n }\n }\n if (!flags.json) {\n this.logger.info(\n renderProjectPlan(plan, {\n cwd: this.process.cwd(),\n title: 'Custom Function plan',\n details: [\n { label: 'Target', path: plan.targetDirectory },\n { label: 'Manifest', path: plan.manifestPath },\n ],\n }),\n );\n }\n\n let approved = plan.changes.length === 0 || flags.dryRun;\n if (plan.changes.length > 0 && !flags.dryRun) {\n if (flags.yes) {\n approved = true;\n } else if (interactive) {\n approved = await prompts.confirm('Apply this complete plan?', true);\n } else {\n throw new Error(\n 'The plan requires approval in a non-interactive invocation. Review with --dryRun, then pass --yes.',\n );\n }\n }\n\n if (approved && !flags.dryRun && plan.changes.length > 0) {\n await applyProjectPlan(this, plan);\n }\n const applied = approved && !flags.dryRun && plan.changes.length > 0;\n const setupAvailable = approved && !flags.dryRun;\n const aiHandoff = buildInitAiHandoff({\n targetDirectory: displayProjectPath(this.process.cwd(), state.targetDirectory),\n manifestPath: displayProjectPath(this.process.cwd(), state.manifestPath),\n cliVersion: CLI_VERSION,\n hasSkill: setupAvailable && features.includes(CustomFunctionSetupFeature.Skill),\n hasGithubWorkflow:\n setupAvailable &&\n features.includes(CustomFunctionSetupFeature.Ci) &&\n Boolean(state.repositoryRoot && state.usesGithub),\n });\n const result = buildPlanResult(plan, {\n applied,\n dryRun: flags.dryRun,\n cwd: this.process.cwd(),\n aiHandoff,\n });\n if (flags.json) {\n this.process.stdout.write(`${JSON.stringify(result)}\\n`);\n return;\n }\n if (flags.dryRun) {\n this.logger.info(colors.yellow('Dry run complete. No changes were written.'));\n return;\n }\n if (!approved) {\n this.logger.info(colors.yellow('No changes applied.'));\n return;\n }\n if (plan.changes.length === 0) {\n this.logger.info(colors.green('Custom Function project is already initialized.'));\n return;\n }\n this.logger.info(colors.green('Custom Function project initialized.'));\n if (plan.nextSteps.length > 0) {\n this.logger.info(`\\n${colors.bold('Next steps')}`);\n plan.nextSteps.forEach((step) => this.logger.info(step));\n }\n this.logger.info(`\\n${colors.bold('AI handoff — paste into your coding agent')}`);\n this.logger.info(aiHandoff);\n } catch (error) {\n if (error instanceof PromptCancelledError) {\n this.process.exit(130);\n }\n throw error;\n }\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"impl-Yb5jtD4V.mjs","names":["CLI_VERSION"],"sources":["../src/commands/custom-functions/init/impl.ts"],"sourcesContent":["import { CUSTOM_FUNCTION_TYPES_VERSION } from '@transcend-io/custom-function-types';\nimport colors from 'colors';\n\nimport { version as CLI_VERSION } from '../../../constants.js';\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { runCapturedProcess } from '../../../lib/cli/run-captured-process.js';\nimport { buildInitAiHandoff } from '../../../lib/custom-functions/ai-handoff.js';\nimport {\n DENO_INSTALL_URL,\n getDenoRuntimeCompatibility,\n SUPPORTED_DENO_MAJOR_VERSION,\n} from '../../../lib/custom-functions/deno-runtime.js';\nimport { discoverCustomFunctionProject } from '../../../lib/custom-functions/project-discovery.js';\nimport {\n CustomFunctionSetupFeature,\n type CustomFunctionSetupFeature as CustomFunctionSetupFeatureType,\n} from '../../../lib/custom-functions/scaffold-model.js';\nimport { buildPlanResult } from '../../../lib/custom-functions/scaffold-output.js';\nimport {\n buildInitPlan,\n getInitPlanningCandidatePaths,\n} from '../../../lib/custom-functions/scaffold-planning.js';\nimport { collectPlanningSnapshots } from '../../../lib/scaffolding/project-discovery.js';\nimport { applyProjectPlan } from '../../../lib/scaffolding/project-plan-apply.js';\nimport {\n displayProjectPath,\n renderProjectPlan,\n} from '../../../lib/scaffolding/project-plan-output.js';\nimport {\n PromptCancelledError,\n type PromptChoice,\n ScaffoldPrompts,\n} from '../../../lib/scaffolding/prompts.js';\n\n/** Flags for `custom-functions init`. */\nexport interface CustomFunctionInitFlags {\n /** Explicit manifest path. */\n manifest?: string;\n /** Install Deno configuration. */\n deno?: boolean;\n /** Install editor recommendations. */\n editor?: boolean;\n /** Install the coding-agent skill. */\n skill?: boolean;\n /** Install GitHub Actions validation. */\n ci?: boolean;\n /** Disable prompts. */\n noInteractive: boolean;\n /** Render but do not apply. */\n dryRun: boolean;\n /** Approve the final displayed plan. */\n yes: boolean;\n /** Emit one stable JSON result on stdout. */\n json: boolean;\n}\n\n/** User-facing setup labels. */\nconst SETUP_LABELS: Readonly<Record<CustomFunctionSetupFeatureType, string>> = {\n [CustomFunctionSetupFeature.Deno]: 'Deno configuration',\n [CustomFunctionSetupFeature.Editor]: 'VS Code settings',\n [CustomFunctionSetupFeature.Skill]: 'Agent skill',\n [CustomFunctionSetupFeature.Ci]: 'GitHub Actions',\n};\n\n/** All optional setup features in stable prompt order. */\nconst ALL_SETUP_FEATURES = Object.values(CustomFunctionSetupFeature);\n\n/**\n * Whether this invocation can ask questions.\n *\n * @param context - CLI context\n * @param flags - Interaction flags\n * @returns Whether prompts are enabled\n */\nfunction isInteractiveInvocation(\n flags: Pick<CustomFunctionInitFlags, 'json' | 'noInteractive'>,\n stdinIsTTY: boolean | undefined,\n stderrIsTTY: boolean | undefined,\n): boolean {\n return !flags.json && !flags.noInteractive && Boolean(stdinIsTTY && stderrIsTTY);\n}\n\n/**\n * Resolve setup directly from individual flags or one checkbox prompt.\n *\n * @param context - CLI context\n * @param prompts - Prompt adapters\n * @param flags - Setup flags\n * @param options - Interaction state\n * @returns Selected setup features\n */\nasync function resolveFeatures(\n prompts: ScaffoldPrompts,\n flags: CustomFunctionInitFlags,\n options: {\n /** Whether prompts are available. */\n interactive: boolean;\n },\n): Promise<CustomFunctionSetupFeatureType[]> {\n const enabled: Readonly<Record<CustomFunctionSetupFeatureType, boolean | undefined>> = {\n [CustomFunctionSetupFeature.Deno]: flags.deno,\n [CustomFunctionSetupFeature.Editor]: flags.editor,\n [CustomFunctionSetupFeature.Skill]: flags.skill,\n [CustomFunctionSetupFeature.Ci]: flags.ci,\n };\n if (!options.interactive) {\n return ALL_SETUP_FEATURES.filter((feature) => enabled[feature] === true);\n }\n const choices: PromptChoice<CustomFunctionSetupFeatureType>[] = ALL_SETUP_FEATURES.map(\n (feature) => ({\n name: SETUP_LABELS[feature],\n value: feature,\n checked: enabled[feature] !== false,\n }),\n );\n return prompts.checkbox('Choose repository setup:', choices);\n}\n\n/**\n * Initialize a credential-free local Custom Function project.\n *\n * @param this - CLI context\n * @param flags - Scaffold and interaction flags\n * @param directory - Optional target directory\n */\nexport async function init(\n this: LocalContext,\n flags: CustomFunctionInitFlags,\n directory?: string,\n): Promise<void> {\n doneInputValidation(this.process);\n try {\n const state = discoverCustomFunctionProject(this, {\n ...(directory ? { directory } : {}),\n ...(flags.manifest ? { manifest: flags.manifest } : {}),\n });\n const prompts = new ScaffoldPrompts(this);\n const interactive = isInteractiveInvocation(\n flags,\n this.process.stdin.isTTY,\n this.process.stderr.isTTY,\n );\n const features = await resolveFeatures(prompts, flags, { interactive });\n const snapshots = collectPlanningSnapshots(\n this,\n state.projectRoot,\n getInitPlanningCandidatePaths(state, { features }),\n );\n const plan = buildInitPlan(\n {\n state,\n snapshots,\n contractVersion: CUSTOM_FUNCTION_TYPES_VERSION,\n cliVersion: CLI_VERSION,\n },\n { features },\n );\n if (features.includes(CustomFunctionSetupFeature.Deno)) {\n const denoVersion = await runCapturedProcess(\n 'deno',\n ['--version'],\n { cwd: this.process.cwd() },\n this,\n );\n if (denoVersion.error?.code === 'ENOENT') {\n plan.warnings.push(\n `Deno ${SUPPORTED_DENO_MAJOR_VERSION}.x is not installed. Install it from ${DENO_INSTALL_URL}`,\n );\n } else if (denoVersion.code !== 0) {\n plan.warnings.push(\n `Deno was found, but its version could not be determined. Deno ${SUPPORTED_DENO_MAJOR_VERSION}.x is required. See ${DENO_INSTALL_URL}`,\n );\n } else {\n const compatibility = getDenoRuntimeCompatibility(denoVersion.stdout);\n if (compatibility.level !== 'compatible') {\n plan.warnings.push(compatibility.message);\n }\n }\n }\n if (!flags.json) {\n this.logger.info(\n renderProjectPlan(plan, {\n cwd: this.process.cwd(),\n title: 'Custom Function plan',\n details: [\n { label: 'Target', path: plan.targetDirectory },\n { label: 'Manifest', path: plan.manifestPath },\n ],\n }),\n );\n }\n\n let approved = plan.changes.length === 0 || flags.dryRun;\n if (plan.changes.length > 0 && !flags.dryRun) {\n if (flags.yes) {\n approved = true;\n } else if (interactive) {\n approved = await prompts.confirm('Apply this complete plan?', true);\n } else {\n throw new Error(\n 'The plan requires approval in a non-interactive invocation. Review with --dryRun, then pass --yes.',\n );\n }\n }\n\n if (approved && !flags.dryRun && plan.changes.length > 0) {\n await applyProjectPlan(this, plan);\n }\n const applied = approved && !flags.dryRun && plan.changes.length > 0;\n const setupAvailable = approved && !flags.dryRun;\n const aiHandoff = buildInitAiHandoff({\n targetDirectory: displayProjectPath(this.process.cwd(), state.targetDirectory),\n manifestPath: displayProjectPath(this.process.cwd(), state.manifestPath),\n cliVersion: CLI_VERSION,\n hasSkill: setupAvailable && features.includes(CustomFunctionSetupFeature.Skill),\n hasGithubWorkflow:\n setupAvailable &&\n features.includes(CustomFunctionSetupFeature.Ci) &&\n Boolean(state.repositoryRoot && state.usesGithub),\n });\n const result = buildPlanResult(plan, {\n applied,\n dryRun: flags.dryRun,\n cwd: this.process.cwd(),\n aiHandoff,\n });\n if (flags.json) {\n this.process.stdout.write(`${JSON.stringify(result)}\\n`);\n return;\n }\n if (flags.dryRun) {\n this.logger.info(colors.yellow('Dry run complete. No changes were written.'));\n return;\n }\n if (!approved) {\n this.logger.info(colors.yellow('No changes applied.'));\n return;\n }\n if (plan.changes.length === 0) {\n this.logger.info(colors.green('Custom Function project is already initialized.'));\n return;\n }\n this.logger.info(colors.green('Custom Function project initialized.'));\n if (plan.nextSteps.length > 0) {\n this.logger.info(`\\n${colors.bold('Next steps')}`);\n plan.nextSteps.forEach((step) => this.logger.info(step));\n }\n this.logger.info(`\\n${colors.bold('AI handoff — paste into your coding agent')}`);\n this.logger.info(aiHandoff);\n } catch (error) {\n if (error instanceof PromptCancelledError) {\n this.process.exit(130);\n }\n throw error;\n }\n}\n"],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- import{t as e}from"./collectCsvFilesOrExit-B1VOVGWN.mjs";import{t}from"./done-input-validation-BUz-aVC5.mjs";import{n,r,t as i}from"./createPoolingCommandUi-uiDjLlqf.mjs";import a from"colors";import{CHILD_FLAG as o,PoolCancelledError as s,computePoolSize as c,resolveWorkerPath as l,runPool as u}from"@transcend-io/utils";function d(e){return n(e)}function f(e){return r(e)}const p={renderHeader:d,renderWorkers:f};async function m(n){t(this.process);let{directory:r,outputDir:d,clearOutputDir:f,chunkSizeMB:m,concurrency:h,viewerMode:g}=n,_=i(this,p,g),v=e(r,this),{poolSize:y,cpuCount:b}=c(h,v.length);this.logger.info(a.green(`Chunking ${v.length} CSV file(s) with pool size ${y} (CPU=${b})`));let x=v.map(e=>({filePath:e,options:{outputDir:d,clearOutputDir:f,chunkSizeMB:m}}));await u({title:`Chunk CSV - ${r}`,baseDir:r||d||this.process.cwd(),childFlag:o,childModulePath:l(import.meta.url,`commands/admin/chunk-csv/worker.mjs`),poolSize:y,cpuCount:b,filesTotal:v.length,hooks:{nextTask:()=>x.shift(),taskLabel:e=>e.filePath,initTotals:()=>({}),initSlotProgress:()=>void 0,onProgress:e=>e,onResult:(e,t)=>({totals:e,ok:!!t.ok}),postProcess:async()=>{}},viewerMode:g,..._}).catch(e=>{throw e instanceof s&&this.process.exit(130),e})}export{m as chunkCsv};
2
- //# sourceMappingURL=impl-CL29fOWM.mjs.map
1
+ import{t as e}from"./collectCsvFilesOrExit-B1VOVGWN.mjs";import{t}from"./done-input-validation-BUz-aVC5.mjs";import{n,r,t as i}from"./createPoolingCommandUi-CE6fvB2v.mjs";import a from"colors";import{CHILD_FLAG as o,PoolCancelledError as s,computePoolSize as c,resolveWorkerPath as l,runPool as u}from"@transcend-io/utils";function d(e){return n(e)}function f(e){return r(e)}const p={renderHeader:d,renderWorkers:f};async function m(n){t(this.process);let{directory:r,outputDir:d,clearOutputDir:f,chunkSizeMB:m,concurrency:h,viewerMode:g}=n,_=i(this,p,g),v=e(r,this),{poolSize:y,cpuCount:b}=c(h,v.length);this.logger.info(a.green(`Chunking ${v.length} CSV file(s) with pool size ${y} (CPU=${b})`));let x=v.map(e=>({filePath:e,options:{outputDir:d,clearOutputDir:f,chunkSizeMB:m}}));await u({title:`Chunk CSV - ${r}`,baseDir:r||d||this.process.cwd(),childFlag:o,childModulePath:l(import.meta.url,`commands/admin/chunk-csv/worker.mjs`),poolSize:y,cpuCount:b,filesTotal:v.length,hooks:{nextTask:()=>x.shift(),taskLabel:e=>e.filePath,initTotals:()=>({}),initSlotProgress:()=>void 0,onProgress:e=>e,onResult:(e,t)=>({totals:e,ok:!!t.ok}),postProcess:async()=>{}},viewerMode:g,..._}).catch(e=>{throw e instanceof s&&this.process.exit(130),e})}export{m as chunkCsv};
2
+ //# sourceMappingURL=impl-_bJkh9UY.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"impl-CL29fOWM.mjs","names":[],"sources":["../src/commands/admin/chunk-csv/ui/plugin.ts","../src/commands/admin/chunk-csv/impl.ts"],"sourcesContent":["import {\n makeHeader,\n makeWorkerRows,\n type ChunkSlotProgress,\n type CommonCtx,\n type DashboardPlugin,\n} from '../../../../lib/pooling/index.js';\n\n/**\n * Header for chunk-csv (no extra totals block).\n *\n * @param ctx - Dashboard context.\n * @returns Header lines.\n */\nfunction renderHeader<TTotals>(ctx: CommonCtx<TTotals, ChunkSlotProgress>): string[] {\n // no extra lines — reuse the shared header as-is\n return makeHeader(ctx);\n}\n\n/**\n * Worker rows for chunk-csv — share the generic row renderer.\n *\n * @param ctx - Dashboard context.\n * @returns Array of strings, each representing one worker row.\n */\nfunction renderWorkers<TTotals>(ctx: CommonCtx<TTotals, ChunkSlotProgress>): string[] {\n return makeWorkerRows(ctx);\n}\n\nexport const chunkCsvPlugin: DashboardPlugin<unknown, ChunkSlotProgress> = {\n renderHeader,\n renderWorkers,\n // no extras\n};\n","import {\n CHILD_FLAG,\n type PoolHooks,\n runPool,\n computePoolSize,\n PoolCancelledError,\n resolveWorkerPath,\n} from '@transcend-io/utils';\nimport colors from 'colors';\n\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { collectCsvFilesOrExit } from '../../../lib/helpers/collectCsvFilesOrExit.js';\nimport { createPoolingCommandUi } from '../../../lib/pooling/index.js';\nimport { chunkCsvPlugin } from './ui/index.js';\nimport type { ChunkProgress, ChunkResult, ChunkTask } from './worker.js';\n\n/**\n * Totals aggregate for this command.\n * We don’t need custom counters since the runner already tracks\n * completed/failed counts in its header — so we just use an empty record.\n */\ntype Totals = Record<string, never>;\n\n/**\n * CLI flags accepted by the `chunk-csv` command.\n *\n * These are passed down from the CLI parser into the parent process.\n */\nexport type ChunkCsvCommandFlags = {\n directory: string;\n outputDir?: string;\n clearOutputDir: boolean;\n chunkSizeMB: number;\n concurrency?: number;\n viewerMode: boolean;\n};\n\n/**\n * Parent entrypoint for chunking many CSVs in parallel using the worker pool runner.\n *\n * Lifecycle:\n * 1) Discover CSV inputs (exit if none).\n * 2) Compute pool size (CPU-count heuristic or --concurrency).\n * 3) Build a FIFO queue of `ChunkTask`s.\n * 4) Define pool hooks to drive task assignment, progress, and result handling.\n * 5) Launch the pool with `runPool`, rendering via the `chunkCsvPlugin`.\n *\n * @param this - Bound CLI context (provides process exit + logging).\n * @param flags - CLI options for the run.\n */\nexport async function chunkCsv(this: LocalContext, flags: ChunkCsvCommandFlags): Promise<void> {\n doneInputValidation(this.process);\n\n const { directory, outputDir, clearOutputDir, chunkSizeMB, concurrency, viewerMode } = flags;\n const poolingUi = createPoolingCommandUi(this, chunkCsvPlugin, viewerMode);\n\n /* 1) Discover CSV inputs */\n const files = collectCsvFilesOrExit(directory, this);\n\n /* 2) Size the pool */\n const { poolSize, cpuCount } = computePoolSize(concurrency, files.length);\n\n this.logger.info(\n colors.green(\n `Chunking ${files.length} CSV file(s) with pool size ${poolSize} (CPU=${cpuCount})`,\n ),\n );\n\n /* 3) Prepare a simple FIFO queue of tasks (one per file). */\n const queue = files.map<ChunkTask>((filePath) => ({\n filePath,\n options: { outputDir, clearOutputDir, chunkSizeMB },\n }));\n\n /* 4) Define pool hooks to adapt runner to this command. */\n const hooks: PoolHooks<ChunkTask, ChunkProgress, ChunkResult, Totals> = {\n nextTask: () => queue.shift(),\n taskLabel: (t) => t.filePath,\n initTotals: () => ({}) as Totals,\n initSlotProgress: () => undefined,\n onProgress: (totals) => totals,\n onResult: (totals, res) => ({ totals, ok: !!res.ok }),\n // postProcess receives log context when viewerMode=true — we don’t need it here.\n postProcess: async () => {\n // nothing extra for chunk-csv\n },\n };\n\n /* 5) Launch the pool runner with our hooks and custom dashboard plugin. */\n await runPool({\n title: `Chunk CSV - ${directory}`,\n baseDir: directory || outputDir || this.process.cwd(),\n childFlag: CHILD_FLAG,\n childModulePath: resolveWorkerPath(import.meta.url, 'commands/admin/chunk-csv/worker.mjs'),\n poolSize,\n cpuCount,\n filesTotal: files.length,\n hooks,\n viewerMode,\n ...poolingUi,\n }).catch((err) => {\n if (err instanceof PoolCancelledError) {\n this.process.exit(130);\n }\n throw err;\n });\n}\n"],"mappings":"mUAcA,SAAS,EAAsB,EAAsD,CAEnF,OAAO,EAAW,EAAI,CASxB,SAAS,EAAuB,EAAsD,CACpF,OAAO,EAAe,EAAI,CAG5B,MAAa,EAA8D,CACzE,eACA,gBAED,CCkBD,eAAsB,EAA6B,EAA4C,CAC7F,EAAoB,KAAK,QAAQ,CAEjC,GAAM,CAAE,YAAW,YAAW,iBAAgB,cAAa,cAAa,cAAe,EACjF,EAAY,EAAuB,KAAM,EAAgB,EAAW,CAGpE,EAAQ,EAAsB,EAAW,KAAK,CAG9C,CAAE,WAAU,YAAa,EAAgB,EAAa,EAAM,OAAO,CAEzE,KAAK,OAAO,KACV,EAAO,MACL,YAAY,EAAM,OAAO,8BAA8B,EAAS,QAAQ,EAAS,GAClF,CACF,CAGD,IAAM,EAAQ,EAAM,IAAgB,IAAc,CAChD,WACA,QAAS,CAAE,YAAW,iBAAgB,cAAa,CACpD,EAAE,CAiBH,MAAM,EAAQ,CACZ,MAAO,eAAe,IACtB,QAAS,GAAa,GAAa,KAAK,QAAQ,KAAK,CACrD,UAAW,EACX,gBAAiB,EAAkB,OAAO,KAAK,IAAK,sCAAsC,CAC1F,WACA,WACA,WAAY,EAAM,OAClB,MAAA,CArBA,aAAgB,EAAM,OAAO,CAC7B,UAAY,GAAM,EAAE,SACpB,gBAAmB,EAAE,EACrB,qBAAwB,IAAA,GACxB,WAAa,GAAW,EACxB,UAAW,EAAQ,KAAS,CAAE,SAAQ,GAAI,CAAC,CAAC,EAAI,GAAI,EAEpD,YAAa,SAAY,GAcpB,CACL,aACA,GAAG,EACJ,CAAC,CAAC,MAAO,GAAQ,CAIhB,MAHI,aAAe,GACjB,KAAK,QAAQ,KAAK,IAAI,CAElB,GACN"}
1
+ {"version":3,"file":"impl-_bJkh9UY.mjs","names":[],"sources":["../src/commands/admin/chunk-csv/ui/plugin.ts","../src/commands/admin/chunk-csv/impl.ts"],"sourcesContent":["import {\n makeHeader,\n makeWorkerRows,\n type ChunkSlotProgress,\n type CommonCtx,\n type DashboardPlugin,\n} from '../../../../lib/pooling/index.js';\n\n/**\n * Header for chunk-csv (no extra totals block).\n *\n * @param ctx - Dashboard context.\n * @returns Header lines.\n */\nfunction renderHeader<TTotals>(ctx: CommonCtx<TTotals, ChunkSlotProgress>): string[] {\n // no extra lines — reuse the shared header as-is\n return makeHeader(ctx);\n}\n\n/**\n * Worker rows for chunk-csv — share the generic row renderer.\n *\n * @param ctx - Dashboard context.\n * @returns Array of strings, each representing one worker row.\n */\nfunction renderWorkers<TTotals>(ctx: CommonCtx<TTotals, ChunkSlotProgress>): string[] {\n return makeWorkerRows(ctx);\n}\n\nexport const chunkCsvPlugin: DashboardPlugin<unknown, ChunkSlotProgress> = {\n renderHeader,\n renderWorkers,\n // no extras\n};\n","import {\n CHILD_FLAG,\n type PoolHooks,\n runPool,\n computePoolSize,\n PoolCancelledError,\n resolveWorkerPath,\n} from '@transcend-io/utils';\nimport colors from 'colors';\n\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { collectCsvFilesOrExit } from '../../../lib/helpers/collectCsvFilesOrExit.js';\nimport { createPoolingCommandUi } from '../../../lib/pooling/index.js';\nimport { chunkCsvPlugin } from './ui/index.js';\nimport type { ChunkProgress, ChunkResult, ChunkTask } from './worker.js';\n\n/**\n * Totals aggregate for this command.\n * We don’t need custom counters since the runner already tracks\n * completed/failed counts in its header — so we just use an empty record.\n */\ntype Totals = Record<string, never>;\n\n/**\n * CLI flags accepted by the `chunk-csv` command.\n *\n * These are passed down from the CLI parser into the parent process.\n */\nexport type ChunkCsvCommandFlags = {\n directory: string;\n outputDir?: string;\n clearOutputDir: boolean;\n chunkSizeMB: number;\n concurrency?: number;\n viewerMode: boolean;\n};\n\n/**\n * Parent entrypoint for chunking many CSVs in parallel using the worker pool runner.\n *\n * Lifecycle:\n * 1) Discover CSV inputs (exit if none).\n * 2) Compute pool size (CPU-count heuristic or --concurrency).\n * 3) Build a FIFO queue of `ChunkTask`s.\n * 4) Define pool hooks to drive task assignment, progress, and result handling.\n * 5) Launch the pool with `runPool`, rendering via the `chunkCsvPlugin`.\n *\n * @param this - Bound CLI context (provides process exit + logging).\n * @param flags - CLI options for the run.\n */\nexport async function chunkCsv(this: LocalContext, flags: ChunkCsvCommandFlags): Promise<void> {\n doneInputValidation(this.process);\n\n const { directory, outputDir, clearOutputDir, chunkSizeMB, concurrency, viewerMode } = flags;\n const poolingUi = createPoolingCommandUi(this, chunkCsvPlugin, viewerMode);\n\n /* 1) Discover CSV inputs */\n const files = collectCsvFilesOrExit(directory, this);\n\n /* 2) Size the pool */\n const { poolSize, cpuCount } = computePoolSize(concurrency, files.length);\n\n this.logger.info(\n colors.green(\n `Chunking ${files.length} CSV file(s) with pool size ${poolSize} (CPU=${cpuCount})`,\n ),\n );\n\n /* 3) Prepare a simple FIFO queue of tasks (one per file). */\n const queue = files.map<ChunkTask>((filePath) => ({\n filePath,\n options: { outputDir, clearOutputDir, chunkSizeMB },\n }));\n\n /* 4) Define pool hooks to adapt runner to this command. */\n const hooks: PoolHooks<ChunkTask, ChunkProgress, ChunkResult, Totals> = {\n nextTask: () => queue.shift(),\n taskLabel: (t) => t.filePath,\n initTotals: () => ({}) as Totals,\n initSlotProgress: () => undefined,\n onProgress: (totals) => totals,\n onResult: (totals, res) => ({ totals, ok: !!res.ok }),\n // postProcess receives log context when viewerMode=true — we don’t need it here.\n postProcess: async () => {\n // nothing extra for chunk-csv\n },\n };\n\n /* 5) Launch the pool runner with our hooks and custom dashboard plugin. */\n await runPool({\n title: `Chunk CSV - ${directory}`,\n baseDir: directory || outputDir || this.process.cwd(),\n childFlag: CHILD_FLAG,\n childModulePath: resolveWorkerPath(import.meta.url, 'commands/admin/chunk-csv/worker.mjs'),\n poolSize,\n cpuCount,\n filesTotal: files.length,\n hooks,\n viewerMode,\n ...poolingUi,\n }).catch((err) => {\n if (err instanceof PoolCancelledError) {\n this.process.exit(130);\n }\n throw err;\n });\n}\n"],"mappings":"mUAcA,SAAS,EAAsB,EAAsD,CAEnF,OAAO,EAAW,EAAI,CASxB,SAAS,EAAuB,EAAsD,CACpF,OAAO,EAAe,EAAI,CAG5B,MAAa,EAA8D,CACzE,eACA,gBAED,CCkBD,eAAsB,EAA6B,EAA4C,CAC7F,EAAoB,KAAK,QAAQ,CAEjC,GAAM,CAAE,YAAW,YAAW,iBAAgB,cAAa,cAAa,cAAe,EACjF,EAAY,EAAuB,KAAM,EAAgB,EAAW,CAGpE,EAAQ,EAAsB,EAAW,KAAK,CAG9C,CAAE,WAAU,YAAa,EAAgB,EAAa,EAAM,OAAO,CAEzE,KAAK,OAAO,KACV,EAAO,MACL,YAAY,EAAM,OAAO,8BAA8B,EAAS,QAAQ,EAAS,GAClF,CACF,CAGD,IAAM,EAAQ,EAAM,IAAgB,IAAc,CAChD,WACA,QAAS,CAAE,YAAW,iBAAgB,cAAa,CACpD,EAAE,CAiBH,MAAM,EAAQ,CACZ,MAAO,eAAe,IACtB,QAAS,GAAa,GAAa,KAAK,QAAQ,KAAK,CACrD,UAAW,EACX,gBAAiB,EAAkB,OAAO,KAAK,IAAK,sCAAsC,CAC1F,WACA,WACA,WAAY,EAAM,OAClB,MAAA,CArBA,aAAgB,EAAM,OAAO,CAC7B,UAAY,GAAM,EAAE,SACpB,gBAAmB,EAAE,EACrB,qBAAwB,IAAA,GACxB,WAAa,GAAW,EACxB,UAAW,EAAQ,KAAS,CAAE,SAAQ,GAAI,CAAC,CAAC,EAAI,GAAI,EAEpD,YAAa,SAAY,GAcpB,CACL,aACA,GAAG,EACJ,CAAC,CAAC,MAAO,GAAQ,CAIhB,MAHI,aAAe,GACjB,KAAK,QAAQ,KAAK,IAAI,CAElB,GACN"}
@@ -1,2 +1,2 @@
1
- import{t as e}from"./retryRequestDataSilos-BfckLjOJ.mjs";import{t}from"./done-input-validation-BUz-aVC5.mjs";async function n({auth:n,dataSiloId:r,actions:i,transcendUrl:a}){t(this.process),await e({requestActions:i,transcendUrl:a,auth:n,dataSiloId:r})}export{n as retryRequestDataSilos};
2
- //# sourceMappingURL=impl-Dx_TfvW1.mjs.map
1
+ import{t as e}from"./retryRequestDataSilos-CUAhRnGs.mjs";import{t}from"./done-input-validation-BUz-aVC5.mjs";async function n({auth:n,dataSiloId:r,actions:i,transcendUrl:a}){t(this.process),await e({requestActions:i,transcendUrl:a,auth:n,dataSiloId:r})}export{n as retryRequestDataSilos};
2
+ //# sourceMappingURL=impl-cA3shutB.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"impl-Dx_TfvW1.mjs","names":["retryRequestDataSilosHelper"],"sources":["../src/commands/request/system/retry-request-data-silos/impl.ts"],"sourcesContent":["import type { RequestAction } from '@transcend-io/privacy-types';\n\nimport type { LocalContext } from '../../../../context.js';\nimport { doneInputValidation } from '../../../../lib/cli/done-input-validation.js';\nimport { retryRequestDataSilos as retryRequestDataSilosHelper } from '../../../../lib/requests/index.js';\n\nexport interface RetryRequestDataSilosCommandFlags {\n auth: string;\n dataSiloId: string;\n actions: RequestAction[];\n transcendUrl: string;\n}\n\nexport async function retryRequestDataSilos(\n this: LocalContext,\n { auth, dataSiloId, actions, transcendUrl }: RetryRequestDataSilosCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process);\n\n await retryRequestDataSilosHelper({\n requestActions: actions,\n transcendUrl,\n auth,\n dataSiloId,\n });\n}\n"],"mappings":"6GAaA,eAAsB,EAEpB,CAAE,OAAM,aAAY,UAAS,gBACd,CACf,EAAoB,KAAK,QAAQ,CAEjC,MAAMA,EAA4B,CAChC,eAAgB,EAChB,eACA,OACA,aACD,CAAC"}
1
+ {"version":3,"file":"impl-cA3shutB.mjs","names":["retryRequestDataSilosHelper"],"sources":["../src/commands/request/system/retry-request-data-silos/impl.ts"],"sourcesContent":["import type { RequestAction } from '@transcend-io/privacy-types';\n\nimport type { LocalContext } from '../../../../context.js';\nimport { doneInputValidation } from '../../../../lib/cli/done-input-validation.js';\nimport { retryRequestDataSilos as retryRequestDataSilosHelper } from '../../../../lib/requests/index.js';\n\nexport interface RetryRequestDataSilosCommandFlags {\n auth: string;\n dataSiloId: string;\n actions: RequestAction[];\n transcendUrl: string;\n}\n\nexport async function retryRequestDataSilos(\n this: LocalContext,\n { auth, dataSiloId, actions, transcendUrl }: RetryRequestDataSilosCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process);\n\n await retryRequestDataSilosHelper({\n requestActions: actions,\n transcendUrl,\n auth,\n dataSiloId,\n });\n}\n"],"mappings":"6GAaA,eAAsB,EAEpB,CAAE,OAAM,aAAY,UAAS,gBACd,CACf,EAAoB,KAAK,QAAQ,CAEjC,MAAMA,EAA4B,CAChC,eAAgB,EAChB,eACA,OACA,aACD,CAAC"}
@@ -1,2 +1,2 @@
1
- import{t as e}from"./buildExamples-7KXBjl-b.mjs";import{r as t}from"./policyEngineCliError-DY8V-qkK.mjs";import{r as n,t as r}from"./runOpa-CswzJxIs.mjs";import{t as i}from"./policy-bundle-manifest-D6dkbjNi.mjs";import{a,i as o,n as s,o as c,t as l}from"./printResult-CHe3nRN4.mjs";import{t as u}from"./formatPolicyBundleVersionSummary-CJmMCLtJ.mjs";import{n as d}from"./resolveBundleIdByName-qXZBrUz_.mjs";import{n as f}from"./inquirer-BeaBetMO.mjs";import{t as p}from"./done-input-validation-BUz-aVC5.mjs";import{spawnSync as m}from"node:child_process";import h from"node:fs";import g from"node:os";import _ from"node:path";import{gunzipSync as v}from"node:zlib";import y from"fast-glob";import b from"colors";function x(e){let t=y.sync(`**/*.rego`,{cwd:e,onlyFiles:!0,dot:!1}).sort(),n=_.join(e,`manifest.json`),{publishableRegoPaths:r}=i(h.existsSync(n)?h.readFileSync(n,`utf8`):void 0,t.map(t=>({path:t,contents:h.readFileSync(_.join(e,t),`utf8`)})));return{entries:[`manifest.json`,...r]}}async function S(e){let t=_.join(g.tmpdir(),`transcend-policy-bundle-build-${Date.now()}-${Math.random().toString(36).slice(2)}.tar.gz`);try{let{code:n,stderr:i}=await r([`build`,`--v0-compatible`,`--ignore`,`*_test.rego`,`-o`,t,`.`],{cwd:e});if(n!==0)throw Error(i.trim()||`opa build failed with exit code ${n}`)}finally{h.existsSync(t)&&h.unlinkSync(t)}}function C(e){if(e<1024)return`${e} B`;let t=e/1024;if(t<1024)return`${t%1==0?t.toFixed(0):t.toFixed(1)} KiB`;let n=t/1024;return`${n%1==0?n.toFixed(0):n.toFixed(1)} MiB`}async function w(e){n();let t=_.resolve(e);if(!h.existsSync(t)||!h.statSync(t).isDirectory())throw Error(`Policy directory does not exist or is not a directory: ${t}`);let{entries:i}=x(t),{code:o,stderr:s}=await r([`check`,`--strict`,`--v0-compatible`,t]);if(o!==0)throw Error(s.trim()||`opa check failed with exit code ${o}`);await S(t);let l=_.join(g.tmpdir(),`transcend-policy-bundle-${Date.now()}-${Math.random().toString(36).slice(2)}.tar.gz`),u=m(`tar`,[`-czf`,l,`-C`,t,...i],{env:{...process.env,COPYFILE_DISABLE:`1`},encoding:`utf8`});if(u.status!==0)throw Error(`Failed to create policy bundle archive: ${u.stderr.trim()||`tar failed`}`);let d=h.readFileSync(l);if(d.byteLength>5120)throw h.unlinkSync(l),Error(`Policy bundle exceeds the ${C(a)} compressed upload limit (bundle is ${C(d.byteLength)}). The server also rejects decompressed bundles larger than ${C(c)}.`);let f=v(d);if(f.byteLength>51200)throw h.unlinkSync(l),Error(`Policy bundle exceeds the ${C(c)} decompressed upload limit (bundle is ${C(f.byteLength)} decompressed).`);return l}function T(e){let t=h.readFileSync(e.bundlePath),n=new FormData;return n.append(`bundle`,new Blob([t],{type:`application/gzip`}),_.basename(e.bundlePath)),n.append(`version`,e.version),e.description&&n.append(`description`,e.description),e.bundleName&&n.append(`bundleName`,e.bundleName),n}function E(e){return e.toISOString().slice(0,19).replace(/[T:]/g,`-`)}function D(e,t=new Date){return`${e}-${E(t)}`}async function O({dir:n,"bundle-name":r,auth:i,"transcend-url":a,version:c,description:m,json:h,yes:g,debug:v=!1}){p(this.process),t(v);let y=_.resolve(n),x=c??D(r),S=o(a,i),C;try{this.logger.info(b.green(`Building policy bundle from ${y}...`)),C=await w(y);let t=await d(S,r),n;if(t){this.logger.info(b.green(`Uploading new version for bundle "${r}"...`));let e=T({bundlePath:C,version:x,description:m});n=await s(S.post(`v1/policy-engine/policy-bundles/${t}/versions`,{body:e}).json())}else{if(!this.process.stdin.isTTY&&!g){this.logger.error(b.red(`Cannot create a new bundle in a non-interactive environment; pass --yes to confirm.`)),this.process.exit(1);return}if(!g&&(this.logger.warn(b.yellow(`No policy bundle named "${r}" exists for this organization.`)),!await f({message:`No policy bundle named "${r}" exists. Create a new bundle and upload its first version?`}))){this.logger.info(b.yellow(`Publish cancelled.`));return}this.logger.info(b.green(`Creating bundle "${r}" and uploading first version...`));let e=T({bundlePath:C,version:x,description:m,bundleName:r});n=await s(S.post(`v1/policy-engine/policy-bundles`,{body:e}).json())}l(this.process.stdout,{json:h,data:n,renderTable:()=>u(n.version)}),this.logger.info(b.green(`Policy bundle version uploaded successfully.`));let i=e([`policy`,`activate`],{version:n.version.version,"bundle-name":r});this.logger.info(b.yellow(`Publishing a policy does not activate it. To activate this version, run:\n ${i}`))}finally{C&&this.fs.existsSync(C)&&this.fs.unlinkSync(C)}}export{O as publish};
2
- //# sourceMappingURL=impl-DEJpYLPB.mjs.map
1
+ import{t as e}from"./buildExamples-DTMKJ2pF.mjs";import{r as t}from"./policyEngineCliError-DY8V-qkK.mjs";import{r as n,t as r}from"./runOpa-CswzJxIs.mjs";import{t as i}from"./policy-bundle-manifest-D6dkbjNi.mjs";import{a,i as o,n as s,o as c,t as l}from"./printResult-CHe3nRN4.mjs";import{t as u}from"./formatPolicyBundleVersionSummary-CJmMCLtJ.mjs";import{n as d}from"./resolveBundleIdByName-qXZBrUz_.mjs";import{n as f}from"./inquirer-BeaBetMO.mjs";import{t as p}from"./done-input-validation-BUz-aVC5.mjs";import{spawnSync as m}from"node:child_process";import h from"node:fs";import g from"node:os";import _ from"node:path";import{gunzipSync as v}from"node:zlib";import y from"fast-glob";import b from"colors";function x(e){let t=y.sync(`**/*.rego`,{cwd:e,onlyFiles:!0,dot:!1}).sort(),n=_.join(e,`manifest.json`),{publishableRegoPaths:r}=i(h.existsSync(n)?h.readFileSync(n,`utf8`):void 0,t.map(t=>({path:t,contents:h.readFileSync(_.join(e,t),`utf8`)})));return{entries:[`manifest.json`,...r]}}async function S(e){let t=_.join(g.tmpdir(),`transcend-policy-bundle-build-${Date.now()}-${Math.random().toString(36).slice(2)}.tar.gz`);try{let{code:n,stderr:i}=await r([`build`,`--v0-compatible`,`--ignore`,`*_test.rego`,`-o`,t,`.`],{cwd:e});if(n!==0)throw Error(i.trim()||`opa build failed with exit code ${n}`)}finally{h.existsSync(t)&&h.unlinkSync(t)}}function C(e){if(e<1024)return`${e} B`;let t=e/1024;if(t<1024)return`${t%1==0?t.toFixed(0):t.toFixed(1)} KiB`;let n=t/1024;return`${n%1==0?n.toFixed(0):n.toFixed(1)} MiB`}async function w(e){n();let t=_.resolve(e);if(!h.existsSync(t)||!h.statSync(t).isDirectory())throw Error(`Policy directory does not exist or is not a directory: ${t}`);let{entries:i}=x(t),{code:o,stderr:s}=await r([`check`,`--strict`,`--v0-compatible`,t]);if(o!==0)throw Error(s.trim()||`opa check failed with exit code ${o}`);await S(t);let l=_.join(g.tmpdir(),`transcend-policy-bundle-${Date.now()}-${Math.random().toString(36).slice(2)}.tar.gz`),u=m(`tar`,[`-czf`,l,`-C`,t,...i],{env:{...process.env,COPYFILE_DISABLE:`1`},encoding:`utf8`});if(u.status!==0)throw Error(`Failed to create policy bundle archive: ${u.stderr.trim()||`tar failed`}`);let d=h.readFileSync(l);if(d.byteLength>5120)throw h.unlinkSync(l),Error(`Policy bundle exceeds the ${C(a)} compressed upload limit (bundle is ${C(d.byteLength)}). The server also rejects decompressed bundles larger than ${C(c)}.`);let f=v(d);if(f.byteLength>51200)throw h.unlinkSync(l),Error(`Policy bundle exceeds the ${C(c)} decompressed upload limit (bundle is ${C(f.byteLength)} decompressed).`);return l}function T(e){let t=h.readFileSync(e.bundlePath),n=new FormData;return n.append(`bundle`,new Blob([t],{type:`application/gzip`}),_.basename(e.bundlePath)),n.append(`version`,e.version),e.description&&n.append(`description`,e.description),e.bundleName&&n.append(`bundleName`,e.bundleName),n}function E(e){return e.toISOString().slice(0,19).replace(/[T:]/g,`-`)}function D(e,t=new Date){return`${e}-${E(t)}`}async function O({dir:n,"bundle-name":r,auth:i,"transcend-url":a,version:c,description:m,json:h,yes:g,debug:v=!1}){p(this.process),t(v);let y=_.resolve(n),x=c??D(r),S=o(a,i),C;try{this.logger.info(b.green(`Building policy bundle from ${y}...`)),C=await w(y);let t=await d(S,r),n;if(t){this.logger.info(b.green(`Uploading new version for bundle "${r}"...`));let e=T({bundlePath:C,version:x,description:m});n=await s(S.post(`v1/policy-engine/policy-bundles/${t}/versions`,{body:e}).json())}else{if(!this.process.stdin.isTTY&&!g){this.logger.error(b.red(`Cannot create a new bundle in a non-interactive environment; pass --yes to confirm.`)),this.process.exit(1);return}if(!g&&(this.logger.warn(b.yellow(`No policy bundle named "${r}" exists for this organization.`)),!await f({message:`No policy bundle named "${r}" exists. Create a new bundle and upload its first version?`}))){this.logger.info(b.yellow(`Publish cancelled.`));return}this.logger.info(b.green(`Creating bundle "${r}" and uploading first version...`));let e=T({bundlePath:C,version:x,description:m,bundleName:r});n=await s(S.post(`v1/policy-engine/policy-bundles`,{body:e}).json())}l(this.process.stdout,{json:h,data:n,renderTable:()=>u(n.version)}),this.logger.info(b.green(`Policy bundle version uploaded successfully.`));let i=e([`policy`,`activate`],{version:n.version.version,"bundle-name":r});this.logger.info(b.yellow(`Publishing a policy does not activate it. To activate this version, run:\n ${i}`))}finally{C&&this.fs.existsSync(C)&&this.fs.unlinkSync(C)}}export{O as publish};
2
+ //# sourceMappingURL=impl-cjVcQvnQ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"impl-DEJpYLPB.mjs","names":["fg"],"sources":["../src/commands/policy/helpers/buildOpaBundleTarball.ts","../src/commands/policy/helpers/buildPolicyBundleFormData.ts","../src/commands/policy/helpers/defaultPolicyVersionLabel.ts","../src/commands/policy/publish/impl.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { gunzipSync } from 'node:zlib';\n\nimport fg from 'fast-glob';\n\nimport { validatePolicyBundleContents } from '../../../lib/policy/policy-bundle-manifest.js';\nimport { MAX_BUNDLE_COMPRESSED_BYTES, MAX_BUNDLE_DECOMPRESSED_BYTES } from '../constants.js';\nimport { assertOpaInstalled } from './assertOpaInstalled.js';\nimport { runOPACapture } from './runOpa.js';\n\n/** Result of collecting publishable entries from a policy bundle directory. */\ninterface PolicyBundleArchiveContents {\n /** Relative paths to include in the upload tarball (manifest first, then rego) */\n entries: string[];\n}\n\n/**\n * Collects `manifest.json` and publishable `.rego` files from a policy directory.\n *\n * @param dir - Absolute path to the policy bundle directory\n * @returns Validated archive entries\n */\nfunction collectPolicyBundleArchiveEntries(dir: string): PolicyBundleArchiveContents {\n const regoFiles = fg\n .sync('**/*.rego', {\n cwd: dir,\n onlyFiles: true,\n dot: false,\n })\n .sort();\n const manifestPath = path.join(dir, 'manifest.json');\n const { publishableRegoPaths } = validatePolicyBundleContents(\n fs.existsSync(manifestPath) ? fs.readFileSync(manifestPath, 'utf8') : undefined,\n regoFiles.map((relativePath) => ({\n path: relativePath,\n contents: fs.readFileSync(path.join(dir, relativePath), 'utf8'),\n })),\n );\n\n return {\n entries: ['manifest.json', ...publishableRegoPaths],\n };\n}\n\n/**\n * Verifies that a policy directory compiles end-to-end with `opa build`.\n *\n * The compiled output is discarded — the server receives the `manifest.json` +\n * `.rego` archive produced by {@link buildOpaBundleTarball}, not the OPA bundle\n * — but a successful build guarantees the policies compile and link, surfacing\n * errors (syntax, missing imports, undefined references, etc.) before upload.\n *\n * @param dir - Absolute path to the policy bundle directory\n */\nasync function assertBundleCompiles(dir: string): Promise<void> {\n const buildOutputPath = path.join(\n os.tmpdir(),\n `transcend-policy-bundle-build-${Date.now()}-${Math.random().toString(36).slice(2)}.tar.gz`,\n );\n try {\n // Run with `cwd` set to the bundle directory and pass `.` so `opa build`\n // resolves the bundle root correctly. `*_test.rego` files are local-only.\n const { code, stderr } = await runOPACapture(\n ['build', '--v0-compatible', '--ignore', '*_test.rego', '-o', buildOutputPath, '.'],\n { cwd: dir },\n );\n if (code !== 0) {\n throw new Error(stderr.trim() || `opa build failed with exit code ${code}`);\n }\n } finally {\n if (fs.existsSync(buildOutputPath)) {\n fs.unlinkSync(buildOutputPath);\n }\n }\n}\n\n/**\n * Formats a byte count as a human-readable size with binary units.\n *\n * @param bytes - Number of bytes\n * @returns Human-readable size, e.g. `14 MiB` or `4 KiB`\n */\nfunction formatBytes(bytes: number): string {\n if (bytes < 1024) {\n return `${bytes} B`;\n }\n const kib = bytes / 1024;\n if (kib < 1024) {\n return `${kib % 1 === 0 ? kib.toFixed(0) : kib.toFixed(1)} KiB`;\n }\n const mib = kib / 1024;\n return `${mib % 1 === 0 ? mib.toFixed(0) : mib.toFixed(1)} MiB`;\n}\n\n/**\n * Builds a gzip-compressed policy bundle tarball for upload to Transcend.\n *\n * The Policy Engine API expects a plain archive containing `manifest.json` and\n * one or more `.rego` files. This differs from `opa build` output, which embeds\n * `.manifest`, `data.json`, and other OPA bundle metadata that the server\n * rejects. Before packaging, the manifest is validated (shape + root coverage)\n * and the bundle is validated with `opa check` (strict Rego linting) and\n * `opa build` (full compilation) so failures surface client-side rather than\n * after upload.\n *\n * @param dir - Directory containing `manifest.json` and `.rego` policy files\n * @returns Absolute path to the generated `.tar.gz` bundle\n */\nexport async function buildOpaBundleTarball(dir: string): Promise<string> {\n assertOpaInstalled();\n\n const resolvedDir = path.resolve(dir);\n if (!fs.existsSync(resolvedDir) || !fs.statSync(resolvedDir).isDirectory()) {\n throw new Error(`Policy directory does not exist or is not a directory: ${resolvedDir}`);\n }\n\n // Validate the manifest shape and that roots cover every Rego package before\n // invoking OPA, so invalid manifests surface a clear error instead of an\n // opaque `opa build failed with exit code 1`.\n const { entries: archiveEntries } = collectPolicyBundleArchiveEntries(resolvedDir);\n\n // Match the Rego v1 validation the Policy Engine API runs on upload.\n const { code: checkCode, stderr: checkStderr } = await runOPACapture([\n 'check',\n '--strict',\n '--v0-compatible',\n resolvedDir,\n ]);\n if (checkCode !== 0) {\n throw new Error(checkStderr.trim() || `opa check failed with exit code ${checkCode}`);\n }\n\n // Ensure the bundle compiles end-to-end before packaging for upload.\n await assertBundleCompiles(resolvedDir);\n\n const outputPath = path.join(\n os.tmpdir(),\n `transcend-policy-bundle-${Date.now()}-${Math.random().toString(36).slice(2)}.tar.gz`,\n );\n\n const tarResult = spawnSync('tar', ['-czf', outputPath, '-C', resolvedDir, ...archiveEntries], {\n env: { ...process.env, COPYFILE_DISABLE: '1' },\n encoding: 'utf8',\n });\n if (tarResult.status !== 0) {\n throw new Error(\n `Failed to create policy bundle archive: ${tarResult.stderr.trim() || 'tar failed'}`,\n );\n }\n\n const compressedBytes = fs.readFileSync(outputPath);\n if (compressedBytes.byteLength > MAX_BUNDLE_COMPRESSED_BYTES) {\n fs.unlinkSync(outputPath);\n throw new Error(\n `Policy bundle exceeds the ${formatBytes(MAX_BUNDLE_COMPRESSED_BYTES)} compressed upload limit ` +\n `(bundle is ${formatBytes(compressedBytes.byteLength)}). ` +\n `The server also rejects decompressed bundles larger than ${formatBytes(MAX_BUNDLE_DECOMPRESSED_BYTES)}.`,\n );\n }\n\n const decompressedBytes = gunzipSync(compressedBytes);\n if (decompressedBytes.byteLength > MAX_BUNDLE_DECOMPRESSED_BYTES) {\n fs.unlinkSync(outputPath);\n throw new Error(\n `Policy bundle exceeds the ${formatBytes(MAX_BUNDLE_DECOMPRESSED_BYTES)} decompressed upload limit ` +\n `(bundle is ${formatBytes(decompressedBytes.byteLength)} decompressed).`,\n );\n }\n\n return outputPath;\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\n/** Fields for building a policy bundle upload form. */\nexport interface BuildPolicyBundleFormDataOptions {\n /** Absolute path to the bundle tarball */\n bundlePath: string;\n /** Version label */\n version: string;\n /** Optional description */\n description?: string;\n /** Bundle name (only for create) */\n bundleName?: string;\n}\n\n/**\n * Builds multipart form data for a policy bundle upload.\n *\n * @param options - Upload fields\n * @returns FormData ready for POST\n */\nexport function buildPolicyBundleFormData(options: BuildPolicyBundleFormDataOptions): FormData {\n const bundleBytes = fs.readFileSync(options.bundlePath);\n const form = new FormData();\n form.append(\n 'bundle',\n new Blob([bundleBytes], { type: 'application/gzip' }),\n path.basename(options.bundlePath),\n );\n form.append('version', options.version);\n if (options.description) {\n form.append('description', options.description);\n }\n if (options.bundleName) {\n form.append('bundleName', options.bundleName);\n }\n return form;\n}\n","/**\n * Formats a date as `yyyy-mm-dd-hh-mm-ss` in UTC.\n *\n * @param date - Date to format\n * @returns Timestamp label\n */\nfunction formatPolicyVersionTimestamp(date: Date): string {\n return date.toISOString().slice(0, 19).replace(/[T:]/g, '-');\n}\n\n/**\n * Returns a default version label from the bundle name and current UTC timestamp.\n *\n * @param bundleName - Tenant-unique policy bundle name\n * @param now - Current time (for testing)\n * @returns Version label in `{bundleName}-yyyy-mm-dd-hh-mm-ss` form\n */\nexport function defaultPolicyVersionLabel(bundleName: string, now: Date = new Date()): string {\n return `${bundleName}-${formatPolicyVersionTimestamp(now)}`;\n}\n","import path from 'node:path';\n\nimport colors from 'colors';\n\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { buildExampleCommand } from '../../../lib/docgen/buildExamples.js';\nimport { inquirerConfirmBoolean } from '../../../lib/helpers/inquirer.js';\nimport type { ActivateCommandFlags } from '../activate/impl.js';\nimport {\n buildPolicyBundleFormData,\n buildPolicyEngineClient,\n buildOpaBundleTarball,\n defaultPolicyVersionLabel,\n formatPolicyBundleVersionSummary,\n policyEngineRequest,\n printResult,\n resolveBundleIdByName,\n setPolicyEngineCliDebug,\n} from '../helpers/index.js';\nimport type { CreatePolicyBundleResponse, CreatePolicyBundleVersionResponse } from '../types.js';\n\n/** CLI flags for `transcend policy publish`. */\nexport interface PublishCommandFlags {\n /** Directory containing Rego policy files */\n dir: string;\n /** Tenant-unique bundle name */\n 'bundle-name': string;\n /** Transcend API key */\n auth: string;\n /** Transcend API URL */\n 'transcend-url': string;\n /** Version label (defaults to `{bundleName}-yyyy-mm-dd-hh-mm-ss`) */\n version?: string;\n /** Optional version description */\n description?: string;\n /** Print raw JSON response */\n json: boolean;\n /** Skip the \"create new bundle\" confirmation */\n yes: boolean;\n /** Include technical error details when a command fails */\n debug?: boolean;\n}\n\n/**\n * Build and upload a new immutable policy bundle version.\n *\n * @param this - CLI context\n * @param flags - Command flags\n */\nexport async function publish(\n this: LocalContext,\n {\n dir,\n 'bundle-name': bundleName,\n auth,\n 'transcend-url': transcendUrl,\n version,\n description,\n json,\n yes,\n debug = false,\n }: PublishCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process);\n setPolicyEngineCliDebug(debug);\n\n const resolvedDir = path.resolve(dir);\n const versionLabel = version ?? defaultPolicyVersionLabel(bundleName);\n const client = buildPolicyEngineClient(transcendUrl, auth);\n\n let bundlePath: string | undefined;\n try {\n this.logger.info(colors.green(`Building policy bundle from ${resolvedDir}...`));\n bundlePath = await buildOpaBundleTarball(resolvedDir);\n\n const existingBundleId = await resolveBundleIdByName(client, bundleName);\n\n let responseBody: CreatePolicyBundleResponse | CreatePolicyBundleVersionResponse;\n\n if (existingBundleId) {\n this.logger.info(colors.green(`Uploading new version for bundle \"${bundleName}\"...`));\n const form = buildPolicyBundleFormData({\n bundlePath,\n version: versionLabel,\n description,\n });\n responseBody = await policyEngineRequest(\n client\n .post(`v1/policy-engine/policy-bundles/${existingBundleId}/versions`, { body: form })\n .json<CreatePolicyBundleVersionResponse>(),\n );\n } else {\n if (!this.process.stdin.isTTY && !yes) {\n this.logger.error(\n colors.red(\n 'Cannot create a new bundle in a non-interactive environment; pass --yes to confirm.',\n ),\n );\n this.process.exit(1);\n return;\n }\n\n if (!yes) {\n this.logger.warn(\n colors.yellow(`No policy bundle named \"${bundleName}\" exists for this organization.`),\n );\n const shouldCreate = await inquirerConfirmBoolean({\n message: `No policy bundle named \"${bundleName}\" exists. Create a new bundle and upload its first version?`,\n });\n if (!shouldCreate) {\n this.logger.info(colors.yellow('Publish cancelled.'));\n return;\n }\n }\n\n this.logger.info(\n colors.green(`Creating bundle \"${bundleName}\" and uploading first version...`),\n );\n const createForm = buildPolicyBundleFormData({\n bundlePath,\n version: versionLabel,\n description,\n bundleName,\n });\n responseBody = await policyEngineRequest(\n client\n .post('v1/policy-engine/policy-bundles', {\n body: createForm,\n })\n .json<CreatePolicyBundleResponse>(),\n );\n }\n\n printResult(this.process.stdout, {\n json,\n data: responseBody,\n renderTable: () => formatPolicyBundleVersionSummary(responseBody.version),\n });\n\n this.logger.info(colors.green('Policy bundle version uploaded successfully.'));\n\n const activateCommand = buildExampleCommand<ActivateCommandFlags>(['policy', 'activate'], {\n version: responseBody.version.version,\n 'bundle-name': bundleName,\n });\n this.logger.info(\n colors.yellow(\n `Publishing a policy does not activate it. To activate this version, run:\\n ${activateCommand}`,\n ),\n );\n } finally {\n if (bundlePath && this.fs.existsSync(bundlePath)) {\n this.fs.unlinkSync(bundlePath);\n }\n }\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"impl-cjVcQvnQ.mjs","names":["fg"],"sources":["../src/commands/policy/helpers/buildOpaBundleTarball.ts","../src/commands/policy/helpers/buildPolicyBundleFormData.ts","../src/commands/policy/helpers/defaultPolicyVersionLabel.ts","../src/commands/policy/publish/impl.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { gunzipSync } from 'node:zlib';\n\nimport fg from 'fast-glob';\n\nimport { validatePolicyBundleContents } from '../../../lib/policy/policy-bundle-manifest.js';\nimport { MAX_BUNDLE_COMPRESSED_BYTES, MAX_BUNDLE_DECOMPRESSED_BYTES } from '../constants.js';\nimport { assertOpaInstalled } from './assertOpaInstalled.js';\nimport { runOPACapture } from './runOpa.js';\n\n/** Result of collecting publishable entries from a policy bundle directory. */\ninterface PolicyBundleArchiveContents {\n /** Relative paths to include in the upload tarball (manifest first, then rego) */\n entries: string[];\n}\n\n/**\n * Collects `manifest.json` and publishable `.rego` files from a policy directory.\n *\n * @param dir - Absolute path to the policy bundle directory\n * @returns Validated archive entries\n */\nfunction collectPolicyBundleArchiveEntries(dir: string): PolicyBundleArchiveContents {\n const regoFiles = fg\n .sync('**/*.rego', {\n cwd: dir,\n onlyFiles: true,\n dot: false,\n })\n .sort();\n const manifestPath = path.join(dir, 'manifest.json');\n const { publishableRegoPaths } = validatePolicyBundleContents(\n fs.existsSync(manifestPath) ? fs.readFileSync(manifestPath, 'utf8') : undefined,\n regoFiles.map((relativePath) => ({\n path: relativePath,\n contents: fs.readFileSync(path.join(dir, relativePath), 'utf8'),\n })),\n );\n\n return {\n entries: ['manifest.json', ...publishableRegoPaths],\n };\n}\n\n/**\n * Verifies that a policy directory compiles end-to-end with `opa build`.\n *\n * The compiled output is discarded — the server receives the `manifest.json` +\n * `.rego` archive produced by {@link buildOpaBundleTarball}, not the OPA bundle\n * — but a successful build guarantees the policies compile and link, surfacing\n * errors (syntax, missing imports, undefined references, etc.) before upload.\n *\n * @param dir - Absolute path to the policy bundle directory\n */\nasync function assertBundleCompiles(dir: string): Promise<void> {\n const buildOutputPath = path.join(\n os.tmpdir(),\n `transcend-policy-bundle-build-${Date.now()}-${Math.random().toString(36).slice(2)}.tar.gz`,\n );\n try {\n // Run with `cwd` set to the bundle directory and pass `.` so `opa build`\n // resolves the bundle root correctly. `*_test.rego` files are local-only.\n const { code, stderr } = await runOPACapture(\n ['build', '--v0-compatible', '--ignore', '*_test.rego', '-o', buildOutputPath, '.'],\n { cwd: dir },\n );\n if (code !== 0) {\n throw new Error(stderr.trim() || `opa build failed with exit code ${code}`);\n }\n } finally {\n if (fs.existsSync(buildOutputPath)) {\n fs.unlinkSync(buildOutputPath);\n }\n }\n}\n\n/**\n * Formats a byte count as a human-readable size with binary units.\n *\n * @param bytes - Number of bytes\n * @returns Human-readable size, e.g. `14 MiB` or `4 KiB`\n */\nfunction formatBytes(bytes: number): string {\n if (bytes < 1024) {\n return `${bytes} B`;\n }\n const kib = bytes / 1024;\n if (kib < 1024) {\n return `${kib % 1 === 0 ? kib.toFixed(0) : kib.toFixed(1)} KiB`;\n }\n const mib = kib / 1024;\n return `${mib % 1 === 0 ? mib.toFixed(0) : mib.toFixed(1)} MiB`;\n}\n\n/**\n * Builds a gzip-compressed policy bundle tarball for upload to Transcend.\n *\n * The Policy Engine API expects a plain archive containing `manifest.json` and\n * one or more `.rego` files. This differs from `opa build` output, which embeds\n * `.manifest`, `data.json`, and other OPA bundle metadata that the server\n * rejects. Before packaging, the manifest is validated (shape + root coverage)\n * and the bundle is validated with `opa check` (strict Rego linting) and\n * `opa build` (full compilation) so failures surface client-side rather than\n * after upload.\n *\n * @param dir - Directory containing `manifest.json` and `.rego` policy files\n * @returns Absolute path to the generated `.tar.gz` bundle\n */\nexport async function buildOpaBundleTarball(dir: string): Promise<string> {\n assertOpaInstalled();\n\n const resolvedDir = path.resolve(dir);\n if (!fs.existsSync(resolvedDir) || !fs.statSync(resolvedDir).isDirectory()) {\n throw new Error(`Policy directory does not exist or is not a directory: ${resolvedDir}`);\n }\n\n // Validate the manifest shape and that roots cover every Rego package before\n // invoking OPA, so invalid manifests surface a clear error instead of an\n // opaque `opa build failed with exit code 1`.\n const { entries: archiveEntries } = collectPolicyBundleArchiveEntries(resolvedDir);\n\n // Match the Rego v1 validation the Policy Engine API runs on upload.\n const { code: checkCode, stderr: checkStderr } = await runOPACapture([\n 'check',\n '--strict',\n '--v0-compatible',\n resolvedDir,\n ]);\n if (checkCode !== 0) {\n throw new Error(checkStderr.trim() || `opa check failed with exit code ${checkCode}`);\n }\n\n // Ensure the bundle compiles end-to-end before packaging for upload.\n await assertBundleCompiles(resolvedDir);\n\n const outputPath = path.join(\n os.tmpdir(),\n `transcend-policy-bundle-${Date.now()}-${Math.random().toString(36).slice(2)}.tar.gz`,\n );\n\n const tarResult = spawnSync('tar', ['-czf', outputPath, '-C', resolvedDir, ...archiveEntries], {\n env: { ...process.env, COPYFILE_DISABLE: '1' },\n encoding: 'utf8',\n });\n if (tarResult.status !== 0) {\n throw new Error(\n `Failed to create policy bundle archive: ${tarResult.stderr.trim() || 'tar failed'}`,\n );\n }\n\n const compressedBytes = fs.readFileSync(outputPath);\n if (compressedBytes.byteLength > MAX_BUNDLE_COMPRESSED_BYTES) {\n fs.unlinkSync(outputPath);\n throw new Error(\n `Policy bundle exceeds the ${formatBytes(MAX_BUNDLE_COMPRESSED_BYTES)} compressed upload limit ` +\n `(bundle is ${formatBytes(compressedBytes.byteLength)}). ` +\n `The server also rejects decompressed bundles larger than ${formatBytes(MAX_BUNDLE_DECOMPRESSED_BYTES)}.`,\n );\n }\n\n const decompressedBytes = gunzipSync(compressedBytes);\n if (decompressedBytes.byteLength > MAX_BUNDLE_DECOMPRESSED_BYTES) {\n fs.unlinkSync(outputPath);\n throw new Error(\n `Policy bundle exceeds the ${formatBytes(MAX_BUNDLE_DECOMPRESSED_BYTES)} decompressed upload limit ` +\n `(bundle is ${formatBytes(decompressedBytes.byteLength)} decompressed).`,\n );\n }\n\n return outputPath;\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\n/** Fields for building a policy bundle upload form. */\nexport interface BuildPolicyBundleFormDataOptions {\n /** Absolute path to the bundle tarball */\n bundlePath: string;\n /** Version label */\n version: string;\n /** Optional description */\n description?: string;\n /** Bundle name (only for create) */\n bundleName?: string;\n}\n\n/**\n * Builds multipart form data for a policy bundle upload.\n *\n * @param options - Upload fields\n * @returns FormData ready for POST\n */\nexport function buildPolicyBundleFormData(options: BuildPolicyBundleFormDataOptions): FormData {\n const bundleBytes = fs.readFileSync(options.bundlePath);\n const form = new FormData();\n form.append(\n 'bundle',\n new Blob([bundleBytes], { type: 'application/gzip' }),\n path.basename(options.bundlePath),\n );\n form.append('version', options.version);\n if (options.description) {\n form.append('description', options.description);\n }\n if (options.bundleName) {\n form.append('bundleName', options.bundleName);\n }\n return form;\n}\n","/**\n * Formats a date as `yyyy-mm-dd-hh-mm-ss` in UTC.\n *\n * @param date - Date to format\n * @returns Timestamp label\n */\nfunction formatPolicyVersionTimestamp(date: Date): string {\n return date.toISOString().slice(0, 19).replace(/[T:]/g, '-');\n}\n\n/**\n * Returns a default version label from the bundle name and current UTC timestamp.\n *\n * @param bundleName - Tenant-unique policy bundle name\n * @param now - Current time (for testing)\n * @returns Version label in `{bundleName}-yyyy-mm-dd-hh-mm-ss` form\n */\nexport function defaultPolicyVersionLabel(bundleName: string, now: Date = new Date()): string {\n return `${bundleName}-${formatPolicyVersionTimestamp(now)}`;\n}\n","import path from 'node:path';\n\nimport colors from 'colors';\n\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { buildExampleCommand } from '../../../lib/docgen/buildExamples.js';\nimport { inquirerConfirmBoolean } from '../../../lib/helpers/inquirer.js';\nimport type { ActivateCommandFlags } from '../activate/impl.js';\nimport {\n buildPolicyBundleFormData,\n buildPolicyEngineClient,\n buildOpaBundleTarball,\n defaultPolicyVersionLabel,\n formatPolicyBundleVersionSummary,\n policyEngineRequest,\n printResult,\n resolveBundleIdByName,\n setPolicyEngineCliDebug,\n} from '../helpers/index.js';\nimport type { CreatePolicyBundleResponse, CreatePolicyBundleVersionResponse } from '../types.js';\n\n/** CLI flags for `transcend policy publish`. */\nexport interface PublishCommandFlags {\n /** Directory containing Rego policy files */\n dir: string;\n /** Tenant-unique bundle name */\n 'bundle-name': string;\n /** Transcend API key */\n auth: string;\n /** Transcend API URL */\n 'transcend-url': string;\n /** Version label (defaults to `{bundleName}-yyyy-mm-dd-hh-mm-ss`) */\n version?: string;\n /** Optional version description */\n description?: string;\n /** Print raw JSON response */\n json: boolean;\n /** Skip the \"create new bundle\" confirmation */\n yes: boolean;\n /** Include technical error details when a command fails */\n debug?: boolean;\n}\n\n/**\n * Build and upload a new immutable policy bundle version.\n *\n * @param this - CLI context\n * @param flags - Command flags\n */\nexport async function publish(\n this: LocalContext,\n {\n dir,\n 'bundle-name': bundleName,\n auth,\n 'transcend-url': transcendUrl,\n version,\n description,\n json,\n yes,\n debug = false,\n }: PublishCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process);\n setPolicyEngineCliDebug(debug);\n\n const resolvedDir = path.resolve(dir);\n const versionLabel = version ?? defaultPolicyVersionLabel(bundleName);\n const client = buildPolicyEngineClient(transcendUrl, auth);\n\n let bundlePath: string | undefined;\n try {\n this.logger.info(colors.green(`Building policy bundle from ${resolvedDir}...`));\n bundlePath = await buildOpaBundleTarball(resolvedDir);\n\n const existingBundleId = await resolveBundleIdByName(client, bundleName);\n\n let responseBody: CreatePolicyBundleResponse | CreatePolicyBundleVersionResponse;\n\n if (existingBundleId) {\n this.logger.info(colors.green(`Uploading new version for bundle \"${bundleName}\"...`));\n const form = buildPolicyBundleFormData({\n bundlePath,\n version: versionLabel,\n description,\n });\n responseBody = await policyEngineRequest(\n client\n .post(`v1/policy-engine/policy-bundles/${existingBundleId}/versions`, { body: form })\n .json<CreatePolicyBundleVersionResponse>(),\n );\n } else {\n if (!this.process.stdin.isTTY && !yes) {\n this.logger.error(\n colors.red(\n 'Cannot create a new bundle in a non-interactive environment; pass --yes to confirm.',\n ),\n );\n this.process.exit(1);\n return;\n }\n\n if (!yes) {\n this.logger.warn(\n colors.yellow(`No policy bundle named \"${bundleName}\" exists for this organization.`),\n );\n const shouldCreate = await inquirerConfirmBoolean({\n message: `No policy bundle named \"${bundleName}\" exists. Create a new bundle and upload its first version?`,\n });\n if (!shouldCreate) {\n this.logger.info(colors.yellow('Publish cancelled.'));\n return;\n }\n }\n\n this.logger.info(\n colors.green(`Creating bundle \"${bundleName}\" and uploading first version...`),\n );\n const createForm = buildPolicyBundleFormData({\n bundlePath,\n version: versionLabel,\n description,\n bundleName,\n });\n responseBody = await policyEngineRequest(\n client\n .post('v1/policy-engine/policy-bundles', {\n body: createForm,\n })\n .json<CreatePolicyBundleResponse>(),\n );\n }\n\n printResult(this.process.stdout, {\n json,\n data: responseBody,\n renderTable: () => formatPolicyBundleVersionSummary(responseBody.version),\n });\n\n this.logger.info(colors.green('Policy bundle version uploaded successfully.'));\n\n const activateCommand = buildExampleCommand<ActivateCommandFlags>(['policy', 'activate'], {\n version: responseBody.version.version,\n 'bundle-name': bundleName,\n });\n this.logger.info(\n colors.yellow(\n `Publishing a policy does not activate it. To activate this version, run:\\n ${activateCommand}`,\n ),\n );\n } finally {\n if (bundlePath && this.fs.existsSync(bundlePath)) {\n this.fs.unlinkSync(bundlePath);\n }\n }\n}\n"],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- import{t as e}from"./cancelPrivacyRequests-D0zNUNdS.mjs";import{t}from"./done-input-validation-BUz-aVC5.mjs";async function n({auth:n,actions:r,statuses:i=[],requestIds:a,silentModeBefore:o,createdAtBefore:s,createdAtAfter:c,updatedAtBefore:l,updatedAtAfter:u,cancellationTitle:d,transcendUrl:f,concurrency:p}){t(this.process),await e({transcendUrl:f,requestActions:r,auth:n,cancellationTitle:d,requestIds:a,statuses:i,concurrency:p,silentModeBefore:o?new Date(o):void 0,createdAtBefore:s?new Date(s):void 0,createdAtAfter:c?new Date(c):void 0,updatedAtBefore:l?new Date(l):void 0,updatedAtAfter:u?new Date(u):void 0})}export{n as cancel};
2
- //# sourceMappingURL=impl-CyQRmuM72.mjs.map
1
+ import{t as e}from"./cancelPrivacyRequests-DvRHEAjF.mjs";import{t}from"./done-input-validation-BUz-aVC5.mjs";async function n({auth:n,actions:r,statuses:i=[],requestIds:a,silentModeBefore:o,createdAtBefore:s,createdAtAfter:c,updatedAtBefore:l,updatedAtAfter:u,cancellationTitle:d,transcendUrl:f,concurrency:p}){t(this.process),await e({transcendUrl:f,requestActions:r,auth:n,cancellationTitle:d,requestIds:a,statuses:i,concurrency:p,silentModeBefore:o?new Date(o):void 0,createdAtBefore:s?new Date(s):void 0,createdAtAfter:c?new Date(c):void 0,updatedAtBefore:l?new Date(l):void 0,updatedAtAfter:u?new Date(u):void 0})}export{n as cancel};
2
+ //# sourceMappingURL=impl-ehFICcp72.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"impl-CyQRmuM72.mjs","names":[],"sources":["../src/commands/request/cancel/impl.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\n\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { cancelPrivacyRequests } from '../../../lib/requests/index.js';\n\nexport interface CancelCommandFlags {\n auth: string;\n actions: RequestAction[];\n statuses?: RequestStatus[];\n requestIds?: string[];\n silentModeBefore?: Date;\n createdAtBefore?: Date;\n createdAtAfter?: Date;\n updatedAtBefore?: Date;\n updatedAtAfter?: Date;\n cancellationTitle: string;\n transcendUrl: string;\n concurrency: number;\n}\n\nexport async function cancel(\n this: LocalContext,\n {\n auth,\n actions,\n statuses = [],\n requestIds,\n silentModeBefore,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n cancellationTitle,\n transcendUrl,\n concurrency,\n }: CancelCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process);\n\n await cancelPrivacyRequests({\n transcendUrl,\n requestActions: actions,\n auth,\n cancellationTitle,\n requestIds,\n statuses,\n concurrency,\n silentModeBefore: silentModeBefore ? new Date(silentModeBefore) : undefined,\n createdAtBefore: createdAtBefore ? new Date(createdAtBefore) : undefined,\n createdAtAfter: createdAtAfter ? new Date(createdAtAfter) : undefined,\n updatedAtBefore: updatedAtBefore ? new Date(updatedAtBefore) : undefined,\n updatedAtAfter: updatedAtAfter ? new Date(updatedAtAfter) : undefined,\n });\n}\n"],"mappings":"6GAqBA,eAAsB,EAEpB,CACE,OACA,UACA,WAAW,EAAE,CACb,aACA,mBACA,kBACA,iBACA,kBACA,iBACA,oBACA,eACA,eAEa,CACf,EAAoB,KAAK,QAAQ,CAEjC,MAAM,EAAsB,CAC1B,eACA,eAAgB,EAChB,OACA,oBACA,aACA,WACA,cACA,iBAAkB,EAAmB,IAAI,KAAK,EAAiB,CAAG,IAAA,GAClE,gBAAiB,EAAkB,IAAI,KAAK,EAAgB,CAAG,IAAA,GAC/D,eAAgB,EAAiB,IAAI,KAAK,EAAe,CAAG,IAAA,GAC5D,gBAAiB,EAAkB,IAAI,KAAK,EAAgB,CAAG,IAAA,GAC/D,eAAgB,EAAiB,IAAI,KAAK,EAAe,CAAG,IAAA,GAC7D,CAAC"}
1
+ {"version":3,"file":"impl-ehFICcp72.mjs","names":[],"sources":["../src/commands/request/cancel/impl.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\n\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { cancelPrivacyRequests } from '../../../lib/requests/index.js';\n\nexport interface CancelCommandFlags {\n auth: string;\n actions: RequestAction[];\n statuses?: RequestStatus[];\n requestIds?: string[];\n silentModeBefore?: Date;\n createdAtBefore?: Date;\n createdAtAfter?: Date;\n updatedAtBefore?: Date;\n updatedAtAfter?: Date;\n cancellationTitle: string;\n transcendUrl: string;\n concurrency: number;\n}\n\nexport async function cancel(\n this: LocalContext,\n {\n auth,\n actions,\n statuses = [],\n requestIds,\n silentModeBefore,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n cancellationTitle,\n transcendUrl,\n concurrency,\n }: CancelCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process);\n\n await cancelPrivacyRequests({\n transcendUrl,\n requestActions: actions,\n auth,\n cancellationTitle,\n requestIds,\n statuses,\n concurrency,\n silentModeBefore: silentModeBefore ? new Date(silentModeBefore) : undefined,\n createdAtBefore: createdAtBefore ? new Date(createdAtBefore) : undefined,\n createdAtAfter: createdAtAfter ? new Date(createdAtAfter) : undefined,\n updatedAtBefore: updatedAtBefore ? new Date(updatedAtBefore) : undefined,\n updatedAtAfter: updatedAtAfter ? new Date(updatedAtAfter) : undefined,\n });\n}\n"],"mappings":"6GAqBA,eAAsB,EAEpB,CACE,OACA,UACA,WAAW,EAAE,CACb,aACA,mBACA,kBACA,iBACA,kBACA,iBACA,oBACA,eACA,eAEa,CACf,EAAoB,KAAK,QAAQ,CAEjC,MAAM,EAAsB,CAC1B,eACA,eAAgB,EAChB,OACA,oBACA,aACA,WACA,cACA,iBAAkB,EAAmB,IAAI,KAAK,EAAiB,CAAG,IAAA,GAClE,gBAAiB,EAAkB,IAAI,KAAK,EAAgB,CAAG,IAAA,GAC/D,eAAgB,EAAiB,IAAI,KAAK,EAAe,CAAG,IAAA,GAC5D,gBAAiB,EAAkB,IAAI,KAAK,EAAgB,CAAG,IAAA,GAC/D,eAAgB,EAAiB,IAAI,KAAK,EAAe,CAAG,IAAA,GAC7D,CAAC"}
@@ -1,2 +1,2 @@
1
- import{t as e}from"./updateConsentManagerVersionToLatest-DEFwH4Se.mjs";import{t}from"./validateTranscendAuth-D6Wr1cxY.mjs";import{t as n}from"./done-input-validation-BUz-aVC5.mjs";import{ConsentBundleType as r}from"@transcend-io/privacy-types";import i from"colors";import{mapSeries as a}from"@transcend-io/utils";async function o({auth:o,bundleTypes:s=[r.Production,r.Test],deploy:c,transcendUrl:l}){n(this.process);let u=await t(o,this);typeof u==`string`?(await e({deploy:c,transcendUrl:l,auth:u,bundleTypes:s}),this.logger.info(i.green(`Successfully updated Consent Manager!`))):(await a(u,async t=>{this.logger.info(i.magenta(`Updating Consent Manager for organization "${t.organizationName}"...`)),await e({deploy:c,transcendUrl:l,auth:t.apiKey,bundleTypes:s}),this.logger.info(i.green(`Successfully updated Consent Manager for organization "${t.organizationName}"!`))}),this.logger.info(i.green(`Successfully updated Consent Managers!`)))}export{o as updateConsentManager};
2
- //# sourceMappingURL=impl-CuDs6SsI.mjs.map
1
+ import{t as e}from"./updateConsentManagerVersionToLatest-BR_UWjal.mjs";import{t}from"./validateTranscendAuth-D6Wr1cxY.mjs";import{t as n}from"./done-input-validation-BUz-aVC5.mjs";import{ConsentBundleType as r}from"@transcend-io/privacy-types";import i from"colors";import{mapSeries as a}from"@transcend-io/utils";async function o({auth:o,bundleTypes:s=[r.Production,r.Test],deploy:c,transcendUrl:l}){n(this.process);let u=await t(o,this);typeof u==`string`?(await e({deploy:c,transcendUrl:l,auth:u,bundleTypes:s}),this.logger.info(i.green(`Successfully updated Consent Manager!`))):(await a(u,async t=>{this.logger.info(i.magenta(`Updating Consent Manager for organization "${t.organizationName}"...`)),await e({deploy:c,transcendUrl:l,auth:t.apiKey,bundleTypes:s}),this.logger.info(i.green(`Successfully updated Consent Manager for organization "${t.organizationName}"!`))}),this.logger.info(i.green(`Successfully updated Consent Managers!`)))}export{o as updateConsentManager};
2
+ //# sourceMappingURL=impl-oGSoHT2a.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"impl-CuDs6SsI.mjs","names":[],"sources":["../src/commands/consent/update-consent-manager/impl.ts"],"sourcesContent":["import { ConsentBundleType } from '@transcend-io/privacy-types';\nimport { mapSeries } from '@transcend-io/utils';\nimport colors from 'colors';\n\nimport type { LocalContext } from '../../../context.js';\nimport { validateTranscendAuth } from '../../../lib/api-keys/index.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { updateConsentManagerVersionToLatest } from '../../../lib/consent-manager/index.js';\n\nexport interface UpdateConsentManagerCommandFlags {\n auth: string;\n bundleTypes: ConsentBundleType[];\n deploy: boolean;\n transcendUrl: string;\n}\n\nexport async function updateConsentManager(\n this: LocalContext,\n {\n auth,\n bundleTypes = [ConsentBundleType.Production, ConsentBundleType.Test],\n deploy,\n transcendUrl,\n }: UpdateConsentManagerCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process);\n\n // Parse authentication as API key or path to list of API keys\n const apiKeyOrList = await validateTranscendAuth(auth, this);\n\n // Handle single update\n if (typeof apiKeyOrList === 'string') {\n // Update consent manager\n await updateConsentManagerVersionToLatest({\n deploy,\n transcendUrl,\n auth: apiKeyOrList,\n bundleTypes,\n });\n this.logger.info(colors.green('Successfully updated Consent Manager!'));\n } else {\n await mapSeries(apiKeyOrList, async (apiKey) => {\n this.logger.info(\n colors.magenta(`Updating Consent Manager for organization \"${apiKey.organizationName}\"...`),\n );\n\n await updateConsentManagerVersionToLatest({\n deploy,\n transcendUrl,\n auth: apiKey.apiKey,\n bundleTypes,\n });\n\n this.logger.info(\n colors.green(\n `Successfully updated Consent Manager for organization \"${apiKey.organizationName}\"!`,\n ),\n );\n });\n this.logger.info(colors.green('Successfully updated Consent Managers!'));\n }\n}\n"],"mappings":"0TAgBA,eAAsB,EAEpB,CACE,OACA,cAAc,CAAC,EAAkB,WAAY,EAAkB,KAAK,CACpE,SACA,gBAEa,CACf,EAAoB,KAAK,QAAQ,CAGjC,IAAM,EAAe,MAAM,EAAsB,EAAM,KAAK,CAGxD,OAAO,GAAiB,UAE1B,MAAM,EAAoC,CACxC,SACA,eACA,KAAM,EACN,cACD,CAAC,CACF,KAAK,OAAO,KAAK,EAAO,MAAM,wCAAwC,CAAC,GAEvE,MAAM,EAAU,EAAc,KAAO,IAAW,CAC9C,KAAK,OAAO,KACV,EAAO,QAAQ,8CAA8C,EAAO,iBAAiB,MAAM,CAC5F,CAED,MAAM,EAAoC,CACxC,SACA,eACA,KAAM,EAAO,OACb,cACD,CAAC,CAEF,KAAK,OAAO,KACV,EAAO,MACL,0DAA0D,EAAO,iBAAiB,IACnF,CACF,EACD,CACF,KAAK,OAAO,KAAK,EAAO,MAAM,yCAAyC,CAAC"}
1
+ {"version":3,"file":"impl-oGSoHT2a.mjs","names":[],"sources":["../src/commands/consent/update-consent-manager/impl.ts"],"sourcesContent":["import { ConsentBundleType } from '@transcend-io/privacy-types';\nimport { mapSeries } from '@transcend-io/utils';\nimport colors from 'colors';\n\nimport type { LocalContext } from '../../../context.js';\nimport { validateTranscendAuth } from '../../../lib/api-keys/index.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { updateConsentManagerVersionToLatest } from '../../../lib/consent-manager/index.js';\n\nexport interface UpdateConsentManagerCommandFlags {\n auth: string;\n bundleTypes: ConsentBundleType[];\n deploy: boolean;\n transcendUrl: string;\n}\n\nexport async function updateConsentManager(\n this: LocalContext,\n {\n auth,\n bundleTypes = [ConsentBundleType.Production, ConsentBundleType.Test],\n deploy,\n transcendUrl,\n }: UpdateConsentManagerCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process);\n\n // Parse authentication as API key or path to list of API keys\n const apiKeyOrList = await validateTranscendAuth(auth, this);\n\n // Handle single update\n if (typeof apiKeyOrList === 'string') {\n // Update consent manager\n await updateConsentManagerVersionToLatest({\n deploy,\n transcendUrl,\n auth: apiKeyOrList,\n bundleTypes,\n });\n this.logger.info(colors.green('Successfully updated Consent Manager!'));\n } else {\n await mapSeries(apiKeyOrList, async (apiKey) => {\n this.logger.info(\n colors.magenta(`Updating Consent Manager for organization \"${apiKey.organizationName}\"...`),\n );\n\n await updateConsentManagerVersionToLatest({\n deploy,\n transcendUrl,\n auth: apiKey.apiKey,\n bundleTypes,\n });\n\n this.logger.info(\n colors.green(\n `Successfully updated Consent Manager for organization \"${apiKey.organizationName}\"!`,\n ),\n );\n });\n this.logger.info(colors.green('Successfully updated Consent Managers!'));\n }\n}\n"],"mappings":"0TAgBA,eAAsB,EAEpB,CACE,OACA,cAAc,CAAC,EAAkB,WAAY,EAAkB,KAAK,CACpE,SACA,gBAEa,CACf,EAAoB,KAAK,QAAQ,CAGjC,IAAM,EAAe,MAAM,EAAsB,EAAM,KAAK,CAGxD,OAAO,GAAiB,UAE1B,MAAM,EAAoC,CACxC,SACA,eACA,KAAM,EACN,cACD,CAAC,CACF,KAAK,OAAO,KAAK,EAAO,MAAM,wCAAwC,CAAC,GAEvE,MAAM,EAAU,EAAc,KAAO,IAAW,CAC9C,KAAK,OAAO,KACV,EAAO,QAAQ,8CAA8C,EAAO,iBAAiB,MAAM,CAC5F,CAED,MAAM,EAAoC,CACxC,SACA,eACA,KAAM,EAAO,OACb,cACD,CAAC,CAEF,KAAK,OAAO,KACV,EAAO,MACL,0DAA0D,EAAO,iBAAiB,IACnF,CACF,EACD,CACF,KAAK,OAAO,KAAK,EAAO,MAAM,yCAAyC,CAAC"}
@@ -1,2 +1,2 @@
1
- import{n as e}from"./constants-jjHIzHGm.mjs";import{s as t}from"./writeCsv-D-2siSwE.mjs";import{t as n}from"./pullAllDatapoints-uk5ggk6O.mjs";import{t as r}from"./done-input-validation-BUz-aVC5.mjs";import{groupBy as i,uniq as a}from"lodash-es";import o from"colors";import{buildTranscendGraphQLClient as s}from"@transcend-io/sdk";async function c({auth:c,file:l,transcendUrl:u,dataSiloIds:d,includeAttributes:f,includeGuessedCategories:p,parentCategories:m,subCategories:h=[]}){r(this.process);try{let e=await n(s(u,c),{dataSiloIds:d,includeGuessedCategories:p,parentCategories:m,includeAttributes:f,subCategories:h});this.logger.info(o.magenta(`Writing datapoints to file "${l}"...`));let r=[];await t(l,e.map(e=>{let t={"Property ID":e.id,"Data Silo":e.dataSilo.title,Object:e.dataPoint.name,"Object Path":e.dataPoint.path.join(`.`),Property:e.name,"Property Description":e.description,"Data Categories":e.categories.map(e=>`${e.category}:${e.name}`).join(`, `),"Guessed Category":e.pendingCategoryGuesses?.[0]?`${e.pendingCategoryGuesses[0].category.category}:${e.pendingCategoryGuesses[0].category.name}`:``,"Processing Purposes":e.purposes.map(e=>`${e.purpose}:${e.name}`).join(`, `),...Object.entries(i(e.attributeValues||[],({attributeKey:e})=>e.name)).reduce((e,[t,n])=>(e[t]=n.map(e=>e.name).join(`,`),e),{})};return r=a([...r,...Object.keys(t)]),t}),r)}catch(e){this.logger.error(o.red(`An error occurred syncing the datapoints: ${e.message}`)),this.process.exit(1)}this.logger.info(o.green(`Successfully synced datapoints to disk at ${l}! View at ${e}`))}export{c as pullDatapoints};
2
- //# sourceMappingURL=impl-hwpT9u5o2.mjs.map
1
+ import{n as e}from"./constants-BnIMwfNb.mjs";import{s as t}from"./writeCsv-D-2siSwE.mjs";import{t as n}from"./pullAllDatapoints-uk5ggk6O.mjs";import{t as r}from"./done-input-validation-BUz-aVC5.mjs";import{groupBy as i,uniq as a}from"lodash-es";import o from"colors";import{buildTranscendGraphQLClient as s}from"@transcend-io/sdk";async function c({auth:c,file:l,transcendUrl:u,dataSiloIds:d,includeAttributes:f,includeGuessedCategories:p,parentCategories:m,subCategories:h=[]}){r(this.process);try{let e=await n(s(u,c),{dataSiloIds:d,includeGuessedCategories:p,parentCategories:m,includeAttributes:f,subCategories:h});this.logger.info(o.magenta(`Writing datapoints to file "${l}"...`));let r=[];await t(l,e.map(e=>{let t={"Property ID":e.id,"Data Silo":e.dataSilo.title,Object:e.dataPoint.name,"Object Path":e.dataPoint.path.join(`.`),Property:e.name,"Property Description":e.description,"Data Categories":e.categories.map(e=>`${e.category}:${e.name}`).join(`, `),"Guessed Category":e.pendingCategoryGuesses?.[0]?`${e.pendingCategoryGuesses[0].category.category}:${e.pendingCategoryGuesses[0].category.name}`:``,"Processing Purposes":e.purposes.map(e=>`${e.purpose}:${e.name}`).join(`, `),...Object.entries(i(e.attributeValues||[],({attributeKey:e})=>e.name)).reduce((e,[t,n])=>(e[t]=n.map(e=>e.name).join(`,`),e),{})};return r=a([...r,...Object.keys(t)]),t}),r)}catch(e){this.logger.error(o.red(`An error occurred syncing the datapoints: ${e.message}`)),this.process.exit(1)}this.logger.info(o.green(`Successfully synced datapoints to disk at ${l}! View at ${e}`))}export{c as pullDatapoints};
2
+ //# sourceMappingURL=impl-x9HLXhsK2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"impl-hwpT9u5o2.mjs","names":[],"sources":["../src/commands/inventory/pull-datapoints/impl.ts"],"sourcesContent":["import { DataCategoryType } from '@transcend-io/privacy-types';\nimport { buildTranscendGraphQLClient } from '@transcend-io/sdk';\nimport colors from 'colors';\nimport { uniq, groupBy } from 'lodash-es';\n\nimport { ADMIN_DASH_DATAPOINTS } from '../../../constants.js';\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { pullAllDatapoints } from '../../../lib/data-inventory/index.js';\nimport { writeLargeCsv } from '../../../lib/helpers/index.js';\n\nexport interface PullDatapointsCommandFlags {\n auth: string;\n file: string;\n transcendUrl: string;\n dataSiloIds?: string[];\n includeAttributes: boolean;\n includeGuessedCategories: boolean;\n parentCategories?: DataCategoryType[];\n subCategories?: string[];\n}\n\nexport async function pullDatapoints(\n this: LocalContext,\n {\n auth,\n file,\n transcendUrl,\n dataSiloIds,\n includeAttributes,\n includeGuessedCategories,\n parentCategories,\n subCategories = [],\n }: PullDatapointsCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process);\n\n try {\n // Create a GraphQL client\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n const dataPoints = await pullAllDatapoints(client, {\n dataSiloIds,\n includeGuessedCategories,\n parentCategories,\n includeAttributes,\n subCategories, // TODO: https://transcend.height.app/T-40482 - do by name not ID\n });\n\n this.logger.info(colors.magenta(`Writing datapoints to file \"${file}\"...`));\n let headers: string[] = [];\n const inputs = dataPoints.map((point) => {\n const result = {\n 'Property ID': point.id,\n 'Data Silo': point.dataSilo.title,\n Object: point.dataPoint.name,\n 'Object Path': point.dataPoint.path.join('.'),\n Property: point.name,\n 'Property Description': point.description,\n 'Data Categories': point.categories\n .map((category) => `${category.category}:${category.name}`)\n .join(', '),\n 'Guessed Category': point.pendingCategoryGuesses?.[0]\n ? `${point.pendingCategoryGuesses![0]!.category.category}:${\n point.pendingCategoryGuesses![0]!.category.name\n }`\n : '',\n 'Processing Purposes': point.purposes\n .map((purpose) => `${purpose.purpose}:${purpose.name}`)\n .join(', '),\n ...Object.entries(\n groupBy(point.attributeValues || [], ({ attributeKey }) => attributeKey.name),\n ).reduce(\n (acc, [key, values]) => {\n acc[key] = values.map((value) => value.name).join(',');\n return acc;\n },\n {} as Record<string, string>,\n ),\n };\n headers = uniq([...headers, ...Object.keys(result)]);\n return result;\n });\n await writeLargeCsv(file, inputs, headers);\n } catch (err) {\n this.logger.error(colors.red(`An error occurred syncing the datapoints: ${err.message}`));\n this.process.exit(1);\n }\n\n // Indicate success\n this.logger.info(\n colors.green(\n `Successfully synced datapoints to disk at ${file}! View at ${ADMIN_DASH_DATAPOINTS}`,\n ),\n );\n}\n"],"mappings":"2UAsBA,eAAsB,EAEpB,CACE,OACA,OACA,eACA,cACA,oBACA,2BACA,mBACA,gBAAgB,EAAE,EAEL,CACf,EAAoB,KAAK,QAAQ,CAEjC,GAAI,CAIF,IAAM,EAAa,MAAM,EAFV,EAA4B,EAAc,EAER,CAAE,CACjD,cACA,2BACA,mBACA,oBACA,gBACD,CAAC,CAEF,KAAK,OAAO,KAAK,EAAO,QAAQ,+BAA+B,EAAK,MAAM,CAAC,CAC3E,IAAI,EAAoB,EAAE,CAiC1B,MAAM,EAAc,EAhCL,EAAW,IAAK,GAAU,CACvC,IAAM,EAAS,CACb,cAAe,EAAM,GACrB,YAAa,EAAM,SAAS,MAC5B,OAAQ,EAAM,UAAU,KACxB,cAAe,EAAM,UAAU,KAAK,KAAK,IAAI,CAC7C,SAAU,EAAM,KAChB,uBAAwB,EAAM,YAC9B,kBAAmB,EAAM,WACtB,IAAK,GAAa,GAAG,EAAS,SAAS,GAAG,EAAS,OAAO,CAC1D,KAAK,KAAK,CACb,mBAAoB,EAAM,yBAAyB,GAC/C,GAAG,EAAM,uBAAwB,GAAI,SAAS,SAAS,GACrD,EAAM,uBAAwB,GAAI,SAAS,OAE7C,GACJ,sBAAuB,EAAM,SAC1B,IAAK,GAAY,GAAG,EAAQ,QAAQ,GAAG,EAAQ,OAAO,CACtD,KAAK,KAAK,CACb,GAAG,OAAO,QACR,EAAQ,EAAM,iBAAmB,EAAE,EAAG,CAAE,kBAAmB,EAAa,KAAK,CAC9E,CAAC,QACC,EAAK,CAAC,EAAK,MACV,EAAI,GAAO,EAAO,IAAK,GAAU,EAAM,KAAK,CAAC,KAAK,IAAI,CAC/C,GAET,EAAE,CACH,CACF,CAED,MADA,GAAU,EAAK,CAAC,GAAG,EAAS,GAAG,OAAO,KAAK,EAAO,CAAC,CAAC,CAC7C,GAEuB,CAAE,EAAQ,OACnC,EAAK,CACZ,KAAK,OAAO,MAAM,EAAO,IAAI,6CAA6C,EAAI,UAAU,CAAC,CACzF,KAAK,QAAQ,KAAK,EAAE,CAItB,KAAK,OAAO,KACV,EAAO,MACL,6CAA6C,EAAK,YAAY,IAC/D,CACF"}
1
+ {"version":3,"file":"impl-x9HLXhsK2.mjs","names":[],"sources":["../src/commands/inventory/pull-datapoints/impl.ts"],"sourcesContent":["import { DataCategoryType } from '@transcend-io/privacy-types';\nimport { buildTranscendGraphQLClient } from '@transcend-io/sdk';\nimport colors from 'colors';\nimport { uniq, groupBy } from 'lodash-es';\n\nimport { ADMIN_DASH_DATAPOINTS } from '../../../constants.js';\nimport type { LocalContext } from '../../../context.js';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation.js';\nimport { pullAllDatapoints } from '../../../lib/data-inventory/index.js';\nimport { writeLargeCsv } from '../../../lib/helpers/index.js';\n\nexport interface PullDatapointsCommandFlags {\n auth: string;\n file: string;\n transcendUrl: string;\n dataSiloIds?: string[];\n includeAttributes: boolean;\n includeGuessedCategories: boolean;\n parentCategories?: DataCategoryType[];\n subCategories?: string[];\n}\n\nexport async function pullDatapoints(\n this: LocalContext,\n {\n auth,\n file,\n transcendUrl,\n dataSiloIds,\n includeAttributes,\n includeGuessedCategories,\n parentCategories,\n subCategories = [],\n }: PullDatapointsCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process);\n\n try {\n // Create a GraphQL client\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n const dataPoints = await pullAllDatapoints(client, {\n dataSiloIds,\n includeGuessedCategories,\n parentCategories,\n includeAttributes,\n subCategories, // TODO: https://transcend.height.app/T-40482 - do by name not ID\n });\n\n this.logger.info(colors.magenta(`Writing datapoints to file \"${file}\"...`));\n let headers: string[] = [];\n const inputs = dataPoints.map((point) => {\n const result = {\n 'Property ID': point.id,\n 'Data Silo': point.dataSilo.title,\n Object: point.dataPoint.name,\n 'Object Path': point.dataPoint.path.join('.'),\n Property: point.name,\n 'Property Description': point.description,\n 'Data Categories': point.categories\n .map((category) => `${category.category}:${category.name}`)\n .join(', '),\n 'Guessed Category': point.pendingCategoryGuesses?.[0]\n ? `${point.pendingCategoryGuesses![0]!.category.category}:${\n point.pendingCategoryGuesses![0]!.category.name\n }`\n : '',\n 'Processing Purposes': point.purposes\n .map((purpose) => `${purpose.purpose}:${purpose.name}`)\n .join(', '),\n ...Object.entries(\n groupBy(point.attributeValues || [], ({ attributeKey }) => attributeKey.name),\n ).reduce(\n (acc, [key, values]) => {\n acc[key] = values.map((value) => value.name).join(',');\n return acc;\n },\n {} as Record<string, string>,\n ),\n };\n headers = uniq([...headers, ...Object.keys(result)]);\n return result;\n });\n await writeLargeCsv(file, inputs, headers);\n } catch (err) {\n this.logger.error(colors.red(`An error occurred syncing the datapoints: ${err.message}`));\n this.process.exit(1);\n }\n\n // Indicate success\n this.logger.info(\n colors.green(\n `Successfully synced datapoints to disk at ${file}! View at ${ADMIN_DASH_DATAPOINTS}`,\n ),\n );\n}\n"],"mappings":"2UAsBA,eAAsB,EAEpB,CACE,OACA,OACA,eACA,cACA,oBACA,2BACA,mBACA,gBAAgB,EAAE,EAEL,CACf,EAAoB,KAAK,QAAQ,CAEjC,GAAI,CAIF,IAAM,EAAa,MAAM,EAFV,EAA4B,EAAc,EAER,CAAE,CACjD,cACA,2BACA,mBACA,oBACA,gBACD,CAAC,CAEF,KAAK,OAAO,KAAK,EAAO,QAAQ,+BAA+B,EAAK,MAAM,CAAC,CAC3E,IAAI,EAAoB,EAAE,CAiC1B,MAAM,EAAc,EAhCL,EAAW,IAAK,GAAU,CACvC,IAAM,EAAS,CACb,cAAe,EAAM,GACrB,YAAa,EAAM,SAAS,MAC5B,OAAQ,EAAM,UAAU,KACxB,cAAe,EAAM,UAAU,KAAK,KAAK,IAAI,CAC7C,SAAU,EAAM,KAChB,uBAAwB,EAAM,YAC9B,kBAAmB,EAAM,WACtB,IAAK,GAAa,GAAG,EAAS,SAAS,GAAG,EAAS,OAAO,CAC1D,KAAK,KAAK,CACb,mBAAoB,EAAM,yBAAyB,GAC/C,GAAG,EAAM,uBAAwB,GAAI,SAAS,SAAS,GACrD,EAAM,uBAAwB,GAAI,SAAS,OAE7C,GACJ,sBAAuB,EAAM,SAC1B,IAAK,GAAY,GAAG,EAAQ,QAAQ,GAAG,EAAQ,OAAO,CACtD,KAAK,KAAK,CACb,GAAG,OAAO,QACR,EAAQ,EAAM,iBAAmB,EAAE,EAAG,CAAE,kBAAmB,EAAa,KAAK,CAC9E,CAAC,QACC,EAAK,CAAC,EAAK,MACV,EAAI,GAAO,EAAO,IAAK,GAAU,EAAM,KAAK,CAAC,KAAK,IAAI,CAC/C,GAET,EAAE,CACH,CACF,CAED,MADA,GAAU,EAAK,CAAC,GAAG,EAAS,GAAG,OAAO,KAAK,EAAO,CAAC,CAAC,CAC7C,GAEuB,CAAE,EAAQ,OACnC,EAAK,CACZ,KAAK,OAAO,MAAM,EAAO,IAAI,6CAA6C,EAAI,UAAU,CAAC,CACzF,KAAK,QAAQ,KAAK,EAAE,CAItB,KAAK,OAAO,KACV,EAAO,MACL,6CAA6C,EAAK,YAAY,IAC/D,CACF"}
@@ -1,2 +1,2 @@
1
- import{t as e}from"./pushCronIdentifiersFromCsv-5ruUKHtL.mjs";import{t}from"./done-input-validation-BUz-aVC5.mjs";async function n({file:n,transcendUrl:r,auth:i,sombraAuth:a,dataSiloId:o}){t(this.process),await e({file:n,transcendUrl:r,auth:i,sombraAuth:a,dataSiloId:o})}export{n as markIdentifiersCompleted};
2
- //# sourceMappingURL=impl-B-j5ACi02.mjs.map
1
+ import{t as e}from"./pushCronIdentifiersFromCsv-ByCv8bd4.mjs";import{t}from"./done-input-validation-BUz-aVC5.mjs";async function n({file:n,transcendUrl:r,auth:i,sombraAuth:a,dataSiloId:o}){t(this.process),await e({file:n,transcendUrl:r,auth:i,sombraAuth:a,dataSiloId:o})}export{n as markIdentifiersCompleted};
2
+ //# sourceMappingURL=impl-zVgfQ0im2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"impl-B-j5ACi02.mjs","names":[],"sources":["../src/commands/request/cron/mark-identifiers-completed/impl.ts"],"sourcesContent":["import type { LocalContext } from '../../../../context.js';\nimport { doneInputValidation } from '../../../../lib/cli/done-input-validation.js';\nimport { pushCronIdentifiersFromCsv } from '../../../../lib/cron/index.js';\n\nexport interface MarkIdentifiersCompletedCommandFlags {\n file: string;\n transcendUrl: string;\n auth: string;\n sombraAuth?: string;\n dataSiloId: string;\n}\n\nexport async function markIdentifiersCompleted(\n this: LocalContext,\n { file, transcendUrl, auth, sombraAuth, dataSiloId }: MarkIdentifiersCompletedCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process);\n\n await pushCronIdentifiersFromCsv({\n file,\n transcendUrl,\n auth,\n sombraAuth,\n dataSiloId,\n });\n}\n"],"mappings":"kHAYA,eAAsB,EAEpB,CAAE,OAAM,eAAc,OAAM,aAAY,cACzB,CACf,EAAoB,KAAK,QAAQ,CAEjC,MAAM,EAA2B,CAC/B,OACA,eACA,OACA,aACA,aACD,CAAC"}
1
+ {"version":3,"file":"impl-zVgfQ0im2.mjs","names":[],"sources":["../src/commands/request/cron/mark-identifiers-completed/impl.ts"],"sourcesContent":["import type { LocalContext } from '../../../../context.js';\nimport { doneInputValidation } from '../../../../lib/cli/done-input-validation.js';\nimport { pushCronIdentifiersFromCsv } from '../../../../lib/cron/index.js';\n\nexport interface MarkIdentifiersCompletedCommandFlags {\n file: string;\n transcendUrl: string;\n auth: string;\n sombraAuth?: string;\n dataSiloId: string;\n}\n\nexport async function markIdentifiersCompleted(\n this: LocalContext,\n { file, transcendUrl, auth, sombraAuth, dataSiloId }: MarkIdentifiersCompletedCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process);\n\n await pushCronIdentifiersFromCsv({\n file,\n transcendUrl,\n auth,\n sombraAuth,\n dataSiloId,\n });\n}\n"],"mappings":"kHAYA,eAAsB,EAEpB,CAAE,OAAM,eAAc,OAAM,aAAY,cACzB,CACf,EAAoB,KAAK,QAAQ,CAEjC,MAAM,EAA2B,CAC/B,OACA,eACA,OACA,aACA,aACD,CAAC"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{i as e,n as t,r as n,t as r}from"./enums-OiLcZ26O.mjs";import{a as i,c as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,u as y}from"./constants-jjHIzHGm.mjs";import{t as b}from"./logger-zplFSeXU.mjs";import{$ as x,A as S,B as ee,C as te,D as C,E as ne,F as re,G as ie,H as ae,I as oe,J as se,K as ce,L as le,M as ue,N as w,O as de,P as fe,Q as T,R as E,S as D,T as O,U as k,V as A,W as j,X as M,Y as N,Z as P,_ as F,a as I,at as L,b as R,c as z,ct as B,d as V,dt as pe,et as me,f as he,ft as ge,g as _e,gt as ve,h as ye,ht as be,i as xe,it as Se,j as Ce,k as we,l as Te,lt as Ee,m as De,mt as Oe,n as ke,nt as Ae,o as je,ot as Me,p as Ne,pt as Pe,q as Fe,r as Ie,rt as Le,s as Re,st as ze,t as Be,tt as Ve,u as He,ut as Ue,v as We,w as Ge,x as Ke,y as qe,z as Je}from"./codecs-CTxFjCg4.mjs";import{a as Ye,i as Xe,n as Ze,o as Qe,r as $e,s as et,t as tt}from"./readTranscendYaml-BNn6-Ofi.mjs";import{i as nt,n as rt,r as it,t as at}from"./mergeTranscendInputs-DFQcbh8b.mjs";import{a as ot,c as st,i as ct,l as lt,n as ut,o as dt,r as ft,s as pt,t as mt,u as ht}from"./constants-D_HVDaOy.mjs";import{n as gt,t as _t}from"./fuzzyMatchColumns-CQCzpjWC.mjs";import{a as vt,c as yt,d as bt,f as xt,i as St,l as Ct,n as wt,o as Tt,r as Et,s as Dt,t as Ot,u as kt}from"./uploadPrivacyRequestsFromCsv-D3KSb1qH.mjs";import{n as At,t as jt}from"./parseAttributesFromString-CO16oAlx.mjs";import{n as H,t as Mt}from"./readCsv-DLg8pwjd.mjs";import{n as Nt,t as Pt}from"./pullUnstructuredSubDataPointRecommendations-YTBzfkRZ.mjs";import{a as Ft,i as It,n as Lt,o as Rt,r as zt,t as Bt}from"./request-BiPv6jmP.mjs";import{i as Vt,n as Ht,r as Ut,t as Wt}from"./pullTranscendConfiguration-B63M3ild.mjs";import{i as Gt,n as Kt,r as U,t as qt}from"./fetchAllRequests-2TZr-LfT.mjs";import{a as Jt,i as Yt,n as Xt,r as Zt,t as Qt}from"./pullChunkedCustomSiloOutstandingIdentifiers-D85P1W_8.mjs";import{n as $t,r as en,t as tn}from"./syncCodePackages-BHE2Tn1Q.mjs";import{t as nn}from"./markSilentPrivacyRequests-BiaButWF.mjs";import{a as rn,i as an,n as on,o as sn,r as cn,t as ln}from"./downloadPrivacyRequestFiles-B_BVxW5Z.mjs";import{n as un,r as dn,t as fn}from"./extractClientError-HZ2U7yqV.mjs";import{t as pn}from"./approvePrivacyRequests-B8x7oxTn.mjs";import{t as mn}from"./notifyPrivacyRequestsAdditionalTime-D3Vtvg5G.mjs";import{t as hn}from"./cancelPrivacyRequests-D0zNUNdS.mjs";import{n as gn,t as _n}from"./bulkRestartRequests-CysUfl98.mjs";import{t as vn}from"./skipPreflightJobs-Do_kwu3m.mjs";import{t as yn}from"./bulkRetryEnrichers-DaLE67Ht.mjs";import{t as bn}from"./retryRequestDataSilos-BfckLjOJ.mjs";import{n as W,r as G,t as xn}from"./streamPrivacyRequestsToCsv-CbJfhV6A.mjs";import{n as Sn,r as Cn,t as wn}from"./inquirer-BeaBetMO.mjs";import{t as Tn}from"./parseVariablesFromString-BOSfQ4QF.mjs";import{t as En}from"./collectParquetFilesOrExit-DVlv5ctt.mjs";import{t as Dn}from"./collectCsvFilesOrExit-B1VOVGWN.mjs";import{t as On}from"./parquetToCsvOneFile-ChmPC6dL.mjs";import{a as kn,i as An,n as jn,o as Mn,r as Nn,s as Pn,t as Fn}from"./writeCsv-D-2siSwE.mjs";import{t as In}from"./skipRequestDataSilos-BNDhdllD.mjs";import{t as Ln}from"./removeUnverifiedRequestIdentifiers-QmeqrmxM.mjs";import{t as Rn}from"./updateConsentManagerVersionToLatest-DEFwH4Se.mjs";import{n as K,t as q}from"./mapConsentCsvRowsToInputs-Dqb6WL4r.mjs";import{t as zn}from"./pullConsentManagerMetrics-Dv5n1ZGp.mjs";import{n as Bn,r as Vn,t as Hn}from"./buildXdiSyncEndpoint-DcrkZ2Gu.mjs";import{t as Un}from"./consentManagersToBusinessEntities-CBJ81aGO.mjs";import{i as Wn,n as Gn,r as Kn,t as qn}from"./uploadConsents-ChmFIw_j.mjs";import{n as Jn,r as Yn,t as Xn}from"./pushCronIdentifiersFromCsv-5ruUKHtL.mjs";import{t as Zn}from"./markRequestDataSiloIdsCompleted-B5N-cQWr.mjs";import{t as Qn}from"./generateCrossAccountApiKeys-Bnqgmj-H.mjs";import{t as $n}from"./validateTranscendAuth-D6Wr1cxY.mjs";import{n as er,t as tr}from"./listFiles-BdFUbX5x.mjs";import{t as nr}from"./pullAllDatapoints-uk5ggk6O.mjs";import{t as rr}from"./pullManualEnrichmentIdentifiersToCsv-DbNSrKEk.mjs";import{n as ir,r as ar,t as or}from"./pushManualEnrichmentIdentifiersFromCsv-B0i2239u.mjs";import{chunk as sr,difference as cr}from"lodash-es";import{readFileSync as lr,readdirSync as ur,statSync as dr}from"node:fs";import{join as fr}from"node:path";import J from"fast-glob";import Y from"colors";import{UPDATE_OR_CREATE_COOKIES as pr,buildTranscendGraphQLClient as X,createSombraGotInstance as mr,fetchAllRequestIdentifiers as hr,fetchConsentManagerId as gr,makeGraphQLRequest as _r,syncCookies as vr,syncDataFlows as yr,validateSombraVersion as br}from"@transcend-io/sdk";import{map as Z,mapSeries as xr}from"@transcend-io/utils";import{execSync as Q}from"child_process";async function $(e,t){let n=await gr(e,{logger:b});await xr(sr(t,100),async t=>{await _r(e,pr,{variables:{airgapBundleId:n,cookies:t.map(e=>({name:e.name,trackingPurposes:e.trackingPurposes&&e.trackingPurposes.length>0?e.trackingPurposes:void 0,description:e.description,service:e.service,status:e.status,attributes:e.attributes,isRegex:e.isRegex}))},logger:b})})}async function Sr(e,t){let n=!1;b.info(Y.magenta(`Syncing "${t.length}" cookies...`));let r=t.filter(e=>t.filter(t=>e.name===t.name&&e.isRegex===t.isRegex).length>1);if(r.length>0)throw Error(`Failed to upload cookies as there were non-unique entries found: ${r.map(({name:e})=>e).join(`,`)}`);try{b.info(Y.magenta(`Upserting "${t.length}" new cookies...`)),await $(e,t),b.info(Y.green(`Successfully synced ${t.length} cookies!`))}catch(e){n=!0,b.error(Y.red(`Failed to create cookies! - ${e.message}`))}return!n}async function Cr({auth:e,sombraAuth:t,actions:n=[],statuses:r=[],identifierSearch:a,pageLimit:o=100,concurrency:s=1,transcendUrl:c=i,createdAtBefore:l,skipRequestIdentifiers:u=!1,createdAtAfter:d,updatedAtBefore:f,updatedAtAfter:p,isTest:m}){let h=X(c,e),g=await mr(c,e,{logger:b,sombraApiKey:t,sombraUrl:process.env.SOMBRA_URL}),_=``;l&&(_+=` before ${l.toISOString()}`),d&&(_+=`${_?`, and`:``} after ${d.toISOString()}`),b.info(Y.magenta(`${n.length>0?`Pulling requests of type "${n.join(`" , "`)}"`:`Pulling all requests`}${_}`));let v=s>1&&d&&l,y=v?W(d,l,s):[{createdAtAfter:d,createdAtBefore:l}];v&&b.info(Y.magenta(`Splitting date range into ${s} parallel chunks`));let x=(await Z(y,e=>U(h,{actions:n,text:a,statuses:r,createdAtBefore:e.createdAtBefore,createdAtAfter:e.createdAtAfter,updatedAtBefore:f,updatedAtAfter:p,isTest:m}),{concurrency:v?s:1})).flat();u||await br(h,{logger:b});let S=u?x.map(e=>({...e,requestIdentifiers:[]})):await Z(x,async e=>{let t=await hr(h,g,{filterBy:{requestId:e.id},skipSombraCheck:!0,logger:b});return{...e,requestIdentifiers:t}},{concurrency:o});return b.info(Y.magenta(`Pulled ${S.length} requests`)),{requestsWithRequestIdentifiers:S,requestsFormattedForCsv:S.map(G)}}function wr(e,t=lr){try{return e?t(e,`utf8`):``}catch{return``}}async function Tr({auth:e,trackerStatus:t,file:n,classifyService:r=!1,transcendUrl:a=i}){let o=X(a,e);b.info(Y.magenta(`Reading "${n}" from disk`)),await yr(o,K(H(n,w),t),{classifyService:r,logger:b})||(b.error(Y.red(`Encountered error(s) syncing data flows from CSV, see logs above for more info. `)),process.exit(1))}async function Er({auth:e,trackerStatus:t,file:n,transcendUrl:r=i}){let a=X(r,e);b.info(Y.magenta(`Reading "${n}" from disk`)),await vr(a,q(H(n,C),t),{logger:b})||(b.error(Y.red(`Encountered error(s) syncing cookies from CSV, see logs above for more info. `)),process.exit(1))}function Dr(e){return ur(e).filter(t=>dr(fr(e,t)).isDirectory())}function Or(e){return e.replace(/(https?:\/\/[^\s]+)/g,`<link-omitted>`)}function kr(e){return Object.entries(e).reduce((e,[t,n])=>n!=null&&n!==``&&!(Array.isArray(n)&&n.length===0)&&!(typeof n==`object`&&Object.keys(n).length===0)?Object.assign(e,{[t]:n}):e,{})}function Ar({baseBranch:e,rootDirectory:t,githubRepo:n,excludedGlob:r=[],fileBlockList:i=[]}){Q(`git fetch origin ${e}`);let a=Q(`git ls-remote ${n} "refs/heads/${e}" | cut -f 1`,{encoding:`utf-8`}).split(`
1
+ import{i as e,n as t,r as n,t as r}from"./enums-OiLcZ26O.mjs";import{a as i,c as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,u as y}from"./constants-BnIMwfNb.mjs";import{t as b}from"./logger-zplFSeXU.mjs";import{$ as x,A as S,B as ee,C as te,D as C,E as ne,F as re,G as ie,H as ae,I as oe,J as se,K as ce,L as le,M as ue,N as w,O as de,P as fe,Q as T,R as E,S as D,T as O,U as k,V as A,W as j,X as M,Y as N,Z as P,_ as F,a as I,at as L,b as R,c as z,ct as B,d as V,dt as pe,et as me,f as he,ft as ge,g as _e,gt as ve,h as ye,ht as be,i as xe,it as Se,j as Ce,k as we,l as Te,lt as Ee,m as De,mt as Oe,n as ke,nt as Ae,o as je,ot as Me,p as Ne,pt as Pe,q as Fe,r as Ie,rt as Le,s as Re,st as ze,t as Be,tt as Ve,u as He,ut as Ue,v as We,w as Ge,x as Ke,y as qe,z as Je}from"./codecs-CTxFjCg4.mjs";import{a as Ye,i as Xe,n as Ze,o as Qe,r as $e,s as et,t as tt}from"./readTranscendYaml-BNn6-Ofi.mjs";import{i as nt,n as rt,r as it,t as at}from"./mergeTranscendInputs-DFQcbh8b.mjs";import{a as ot,c as st,i as ct,l as lt,n as ut,o as dt,r as ft,s as pt,t as mt,u as ht}from"./constants-D_HVDaOy.mjs";import{n as gt,t as _t}from"./fuzzyMatchColumns-CQCzpjWC.mjs";import{a as vt,c as yt,d as bt,f as xt,i as St,l as Ct,n as wt,o as Tt,r as Et,s as Dt,t as Ot,u as kt}from"./uploadPrivacyRequestsFromCsv-CxtOU5CQ.mjs";import{n as At,t as jt}from"./parseAttributesFromString-CO16oAlx.mjs";import{n as H,t as Mt}from"./readCsv-DLg8pwjd.mjs";import{n as Nt,t as Pt}from"./pullUnstructuredSubDataPointRecommendations-YTBzfkRZ.mjs";import{a as Ft,i as It,n as Lt,o as Rt,r as zt,t as Bt}from"./request-BiPv6jmP.mjs";import{i as Vt,n as Ht,r as Ut,t as Wt}from"./pullTranscendConfiguration-B63M3ild.mjs";import{i as Gt,n as Kt,r as U,t as qt}from"./fetchAllRequests-2TZr-LfT.mjs";import{a as Jt,i as Yt,n as Xt,r as Zt,t as Qt}from"./pullChunkedCustomSiloOutstandingIdentifiers-3OvSjU15.mjs";import{n as $t,r as en,t as tn}from"./syncCodePackages-BHE2Tn1Q.mjs";import{t as nn}from"./markSilentPrivacyRequests-3t9IZPpS.mjs";import{a as rn,i as an,n as on,o as sn,r as cn,t as ln}from"./downloadPrivacyRequestFiles-DUFTfiZL.mjs";import{n as un,r as dn,t as fn}from"./extractClientError-HZ2U7yqV.mjs";import{t as pn}from"./approvePrivacyRequests-CFKObXCt.mjs";import{t as mn}from"./notifyPrivacyRequestsAdditionalTime-Ce_GPf6U.mjs";import{t as hn}from"./cancelPrivacyRequests-DvRHEAjF.mjs";import{n as gn,t as _n}from"./bulkRestartRequests-CMdTpO-W.mjs";import{t as vn}from"./skipPreflightJobs-CpJMKv7V.mjs";import{t as yn}from"./bulkRetryEnrichers-DeLVA0zH.mjs";import{t as bn}from"./retryRequestDataSilos-CUAhRnGs.mjs";import{n as W,r as G,t as xn}from"./streamPrivacyRequestsToCsv-CkIiJexX.mjs";import{n as Sn,r as Cn,t as wn}from"./inquirer-BeaBetMO.mjs";import{t as Tn}from"./parseVariablesFromString-BOSfQ4QF.mjs";import{t as En}from"./collectParquetFilesOrExit-DVlv5ctt.mjs";import{t as Dn}from"./collectCsvFilesOrExit-B1VOVGWN.mjs";import{t as On}from"./parquetToCsvOneFile-ChmPC6dL.mjs";import{a as kn,i as An,n as jn,o as Mn,r as Nn,s as Pn,t as Fn}from"./writeCsv-D-2siSwE.mjs";import{t as In}from"./skipRequestDataSilos-BkVAyIwG.mjs";import{t as Ln}from"./removeUnverifiedRequestIdentifiers-DOYx5k0N.mjs";import{t as Rn}from"./updateConsentManagerVersionToLatest-BR_UWjal.mjs";import{n as K,t as q}from"./mapConsentCsvRowsToInputs-Dqb6WL4r.mjs";import{t as zn}from"./pullConsentManagerMetrics-Dv5n1ZGp.mjs";import{n as Bn,r as Vn,t as Hn}from"./buildXdiSyncEndpoint-D8YJpLZd.mjs";import{t as Un}from"./consentManagersToBusinessEntities-CBJ81aGO.mjs";import{i as Wn,n as Gn,r as Kn,t as qn}from"./uploadConsents-DeNdLfPd.mjs";import{n as Jn,r as Yn,t as Xn}from"./pushCronIdentifiersFromCsv-ByCv8bd4.mjs";import{t as Zn}from"./markRequestDataSiloIdsCompleted-DX7d2Itu.mjs";import{t as Qn}from"./generateCrossAccountApiKeys-BNze2Fyn.mjs";import{t as $n}from"./validateTranscendAuth-D6Wr1cxY.mjs";import{n as er,t as tr}from"./listFiles-BdFUbX5x.mjs";import{t as nr}from"./pullAllDatapoints-uk5ggk6O.mjs";import{t as rr}from"./pullManualEnrichmentIdentifiersToCsv-B9AfaSwT.mjs";import{n as ir,r as ar,t as or}from"./pushManualEnrichmentIdentifiersFromCsv-BQYjiA9G.mjs";import{chunk as sr,difference as cr}from"lodash-es";import{readFileSync as lr,readdirSync as ur,statSync as dr}from"node:fs";import{join as fr}from"node:path";import J from"fast-glob";import Y from"colors";import{UPDATE_OR_CREATE_COOKIES as pr,buildTranscendGraphQLClient as X,createSombraGotInstance as mr,fetchAllRequestIdentifiers as hr,fetchConsentManagerId as gr,makeGraphQLRequest as _r,syncCookies as vr,syncDataFlows as yr,validateSombraVersion as br}from"@transcend-io/sdk";import{map as Z,mapSeries as xr}from"@transcend-io/utils";import{execSync as Q}from"child_process";async function $(e,t){let n=await gr(e,{logger:b});await xr(sr(t,100),async t=>{await _r(e,pr,{variables:{airgapBundleId:n,cookies:t.map(e=>({name:e.name,trackingPurposes:e.trackingPurposes&&e.trackingPurposes.length>0?e.trackingPurposes:void 0,description:e.description,service:e.service,status:e.status,attributes:e.attributes,isRegex:e.isRegex}))},logger:b})})}async function Sr(e,t){let n=!1;b.info(Y.magenta(`Syncing "${t.length}" cookies...`));let r=t.filter(e=>t.filter(t=>e.name===t.name&&e.isRegex===t.isRegex).length>1);if(r.length>0)throw Error(`Failed to upload cookies as there were non-unique entries found: ${r.map(({name:e})=>e).join(`,`)}`);try{b.info(Y.magenta(`Upserting "${t.length}" new cookies...`)),await $(e,t),b.info(Y.green(`Successfully synced ${t.length} cookies!`))}catch(e){n=!0,b.error(Y.red(`Failed to create cookies! - ${e.message}`))}return!n}async function Cr({auth:e,sombraAuth:t,actions:n=[],statuses:r=[],identifierSearch:a,pageLimit:o=100,concurrency:s=1,transcendUrl:c=i,createdAtBefore:l,skipRequestIdentifiers:u=!1,createdAtAfter:d,updatedAtBefore:f,updatedAtAfter:p,isTest:m}){let h=X(c,e),g=await mr(c,e,{logger:b,sombraApiKey:t,sombraUrl:process.env.SOMBRA_URL}),_=``;l&&(_+=` before ${l.toISOString()}`),d&&(_+=`${_?`, and`:``} after ${d.toISOString()}`),b.info(Y.magenta(`${n.length>0?`Pulling requests of type "${n.join(`" , "`)}"`:`Pulling all requests`}${_}`));let v=s>1&&d&&l,y=v?W(d,l,s):[{createdAtAfter:d,createdAtBefore:l}];v&&b.info(Y.magenta(`Splitting date range into ${s} parallel chunks`));let x=(await Z(y,e=>U(h,{actions:n,text:a,statuses:r,createdAtBefore:e.createdAtBefore,createdAtAfter:e.createdAtAfter,updatedAtBefore:f,updatedAtAfter:p,isTest:m}),{concurrency:v?s:1})).flat();u||await br(h,{logger:b});let S=u?x.map(e=>({...e,requestIdentifiers:[]})):await Z(x,async e=>{let t=await hr(h,g,{filterBy:{requestId:e.id},skipSombraCheck:!0,logger:b});return{...e,requestIdentifiers:t}},{concurrency:o});return b.info(Y.magenta(`Pulled ${S.length} requests`)),{requestsWithRequestIdentifiers:S,requestsFormattedForCsv:S.map(G)}}function wr(e,t=lr){try{return e?t(e,`utf8`):``}catch{return``}}async function Tr({auth:e,trackerStatus:t,file:n,classifyService:r=!1,transcendUrl:a=i}){let o=X(a,e);b.info(Y.magenta(`Reading "${n}" from disk`)),await yr(o,K(H(n,w),t),{classifyService:r,logger:b})||(b.error(Y.red(`Encountered error(s) syncing data flows from CSV, see logs above for more info. `)),process.exit(1))}async function Er({auth:e,trackerStatus:t,file:n,transcendUrl:r=i}){let a=X(r,e);b.info(Y.magenta(`Reading "${n}" from disk`)),await vr(a,q(H(n,C),t),{logger:b})||(b.error(Y.red(`Encountered error(s) syncing cookies from CSV, see logs above for more info. `)),process.exit(1))}function Dr(e){return ur(e).filter(t=>dr(fr(e,t)).isDirectory())}function Or(e){return e.replace(/(https?:\/\/[^\s]+)/g,`<link-omitted>`)}function kr(e){return Object.entries(e).reduce((e,[t,n])=>n!=null&&n!==``&&!(Array.isArray(n)&&n.length===0)&&!(typeof n==`object`&&Object.keys(n).length===0)?Object.assign(e,{[t]:n}):e,{})}function Ar({baseBranch:e,rootDirectory:t,githubRepo:n,excludedGlob:r=[],fileBlockList:i=[]}){Q(`git fetch origin ${e}`);let a=Q(`git ls-remote ${n} "refs/heads/${e}" | cut -f 1`,{encoding:`utf-8`}).split(`
2
2
  `)[0],o=Q(`git rev-parse HEAD`,{encoding:`utf-8`}).split(`
3
3
  `)[0];if(!a||!o)throw Error(`FAILED TO FIND COMMIT RANGE`);let s=cr(Q(`git fetch && git diff --name-only "${e||a}...${o}" -- ${t}`,{encoding:`utf-8`}).split(`
4
4
  `).filter(e=>e),i),c=r.length>0?J.sync(s,{ignore:r}):s,l={};return c.forEach(e=>{l[e]=Q(`git show ${o}:${e}`,{encoding:`utf-8`})}),{changedFiles:s,fileDiffs:l,repoName:n.split(`/`).pop().split(`.`)[0],commit:o}}export{v as ADMIN_DASH,p as ADMIN_DASH_DATAPOINTS,g as ADMIN_DASH_INTEGRATIONS,Bt as APPROVE_PRIVACY_REQUEST,Vt as ASSESSMENT_TEMPLATES,Be as ActionInput,ke as ActionItemCollectionInput,Ie as ActionItemInput,xe as ApiKeyInput,I as AssessmentAnswerOptionInput,je as AssessmentDisplayLogicInput,Re as AssessmentInput,z as AssessmentNestedRuleInput,Te as AssessmentResourceInput,He as AssessmentRetentionScheduleInput,V as AssessmentRuleInput,he as AssessmentSectionInput,Ne as AssessmentSectionQuestionInput,De as AssessmentTemplateInput,St as AttestedExtraIdentifiers,ye as AttributeInput,_e as AttributePreview,F as AttributeValueInput,mt as BLANK,ut as BULK_APPLY,We as BusinessEntityInput,Lt as CANCEL_PRIVACY_REQUEST,ft as CAN_APPLY_IN_BULK,ct as CachedFileState,ot as CachedRequestState,qe as CodePackageInput,R as CodePackageSdk,dt as ColumnName,Ke as ConsentManageExperienceInput,D as ConsentManagerInput,te as ConsentManagerServiceMetadata,Ge as ConsentPreferenceTopic,O as ConsentPreferenceTopicOptionValue,ne as ConsentPurpose,C as CookieCsvInput,de as CookieInput,Xt as CronIdentifier,Jn as CronIdentifierPush,Zt as CronPartition,u as DEBUG,i as DEFAULT_TRANSCEND_API,m as DEFAULT_TRANSCEND_API_KEY,_ as DEFAULT_TRANSCEND_CONSENT_API,Wt as DEFAULT_TRANSCEND_PULL_RESOURCES,we as DataCategoryGuessInput,S as DataCategoryInput,Ce as DataCategoryPreviewInput,ue as DataCategoryRecommendationInput,w as DataFlowCsvInput,fe as DataFlowInput,re as DataSiloInput,oe as DataSubjectInput,le as DatapointInput,E as DeletionDependencies,Je as DeletionDependency,ee as DeletionDependencyInput,A as DeletionDependencyReset,Nt as ENTRY_COUNT,ir as EnrichPrivacyRequest,ae as EnricherInput,k as FieldInput,pt as IDENTIFIER_BLOCK_LIST,Hn as IP_ADDRESS_REGEX,st as IS_REQUIRED,j as IdentifierInput,ie as ImportOnetrustAssessmentsInput,cn as IntlMessage,ce as IntlMessageInput,lt as NONE,zt as NOTIFY_ADDITIONAL_TIME,r as OneTrustFileFormat,t as OneTrustPullResource,n as OneTrustPullSource,jt as ParsedAttributeInput,Fe as PartitionInput,se as PolicyInput,N as PreferenceWorkflowConfigInput,M as PreferenceWorkflowConfigPurposeInput,P as PreflightInput,T as PrivacyCenterInput,qt as PrivacyRequest,vt as PrivacyRequestInput,un as PrivacyRequestResponse,x as ProcessingActivityInput,me as ProcessingPurposeInput,Ve as ProcessingPurposePreviewInput,Ae as PromptAVendorEmailSettings,qn as PurposeMap,It as REQUESTS,Ft as REQUESTS_COUNT,a as RETRYABLE_BATCH_STATUSES,Le as RegionInput,Se as RepositoryInput,an as RequestFileMetadata,rn as RequestFileMetadataResponse,Kt as RequestPurposeTrigger,L as RiskAssignmentInput,Me as RiskLogicInput,d as SCOPES_BY_TITLE,y as SCOPE_TITLES,ze as SiloDiscoveryResultInput,B as SoftwareDevelopmentKitInput,Ee as StoredApiKey,ht as SuccessfulRequest,o as TR_PULL_RESOURCE_SCOPE_MAP,s as TR_PUSH_RESOURCE_SCOPE_MAP,h as TR_YML_RESOURCE_TO_FIELD_NAME,Ue as TeamInput,pe as TemplateInput,ge as TranscendInput,e as TranscendPullResource,Rt as UPDATE_PRIVACY_REQUEST,Gn as USP_STRING_REGEX,tt as VARIABLE_PARAMETERS_NAME,Ze as VARIABLE_PARAMETERS_REGEXP,Pe as VendorInput,Oe as WebhookHeader,be as WorkflowConfigInput,Fn as appendCsvRowsOrdered,jn as appendCsvSync,pn as approvePrivacyRequests,Bn as buildXdiSyncEndpoint,_n as bulkRestartRequests,yn as bulkRetryEnrichers,hn as cancelPrivacyRequests,Dn as collectCsvFilesOrExit,En as collectParquetFilesOrExit,Un as consentManagersToBusinessEntities,tn as createCodePackage,Wn as createConsentToken,l as description,Vn as domainToHost,ln as downloadPrivacyRequestFiles,ar as enrichPrivacyRequest,nt as ensureAllDataSubjectsExist,fn as extractClientError,Ut as fetchAllAssessmentTemplates,U as fetchAllRequests,Jt as fetchRequestDataSiloActiveCount,Gt as fetchRequestsTotalCount,tr as filterFileNames,kr as filterNullishValuesFromObject,kt as filterRows,G as formatRequestForCsv,_t as fuzzyMatchColumns,gt as fuzzySearch,Qn as generateCrossAccountApiKeys,sn as getFileMetadataForPrivacyRequests,Ar as getGitFilesThatChanged,bt as getUniqueValuesForColumn,Nn as initCsvFile,wn as inquirerAutoComplete,Sn as inquirerConfirmBoolean,Cn as inquirerConfirmText,Dr as listDirectories,er as listFiles,wt as mapColumnsToAttributes,Et as mapColumnsToIdentifiers,q as mapCookieCsvRowsToInputs,Ct as mapCsvColumnsToApi,Tt as mapCsvRowsToRequestInputs,K as mapDataFlowCsvRowsToInputs,xt as mapEnumValues,yt as mapRequestEnumValues,Yn as markCronIdentifierCompleted,Zn as markRequestDataSiloIdsCompleted,nn as markSilentPrivacyRequests,at as mergeTranscendInputs,f as name,Dt as normalizeIdentifierValue,ve as normalizeTranscendInput,mn as notifyPrivacyRequestsAdditionalTime,On as parquetToCsvOneFile,At as parseAttributesFromString,Mt as parseCsv,An as parseFilePath,$e as parseTranscendYaml,Tn as parseVariablesFromString,nr as pullAllDatapoints,Qt as pullChunkedCustomSiloOutstandingIdentifiers,zn as pullConsentManagerMetrics,Yt as pullCronPageOfIdentifiers,rr as pullManualEnrichmentIdentifiersToCsv,Cr as pullPrivacyRequests,Ht as pullTranscendConfiguration,Pt as pullUnstructuredSubDataPointRecommendations,Xn as pushCronIdentifiersFromCsv,or as pushManualEnrichmentIdentifiersFromCsv,H as readCsv,wr as readSafe,Xe as readTranscendYaml,Or as removeLinks,Ln as removeUnverifiedRequestIdentifiers,Ye as replaceVariablesInYaml,gn as restartPrivacyRequest,bn as retryRequestDataSilos,Qe as serializeTranscendYaml,vn as skipPreflightJobs,In as skipRequestDataSilos,W as splitDateRange,on as streamPrivacyRequestFiles,xn as streamPrivacyRequestsToCsv,dn as submitPrivacyRequest,$t as syncCodePackages,rt as syncConfigurationToTranscend,Sr as syncCookies,it as syncDataSilos,en as updateCodePackages,Rn as updateConsentManagerVersionToLatest,$ as updateOrCreateCookies,Kn as uploadConsents,Er as uploadCookiesFromCsv,Tr as uploadDataFlowsFromCsv,Ot as uploadPrivacyRequestsFromCsv,$n as validateTranscendAuth,c as version,kn as writeCsv,Mn as writeCsvSync,Pn as writeLargeCsv,et as writeTranscendYaml};
@@ -1,2 +1,2 @@
1
- import{a as e}from"./constants-jjHIzHGm.mjs";import{t}from"./logger-zplFSeXU.mjs";import{RequestDataSiloStatus as n}from"@transcend-io/privacy-types";import r from"colors";import{CHANGE_REQUEST_DATA_SILO_STATUS as i,buildTranscendGraphQLClient as a,fetchRequestDataSilo as o,makeGraphQLRequest as s}from"@transcend-io/sdk";import{map as c}from"@transcend-io/utils";import l from"cli-progress";async function u({requestIds:u,dataSiloId:d,auth:f,concurrency:p=100,status:m=n.Resolved,transcendUrl:h=e}){let g=a(h,f),_=new Date().getTime(),v=new l.SingleBar({},l.Presets.shades_classic);t.info(r.magenta(`Notifying Transcend for data silo "${d}" marking "${u.length}" requests as completed.`));let y=0;v.start(u.length,0),await c(u,async e=>{let n=await o(g,{logger:t,filterBy:{requestId:e,dataSiloId:d}});try{await s(g,i,{variables:{requestDataSiloId:n.id,status:m},logger:t})}catch(e){if(!e.message.includes(`Client error: Request must be active:`)&&!e.message.includes(`Failed to find RequestDataSilo`))throw e}y+=1,v.update(y)},{concurrency:p}),v.stop();let b=new Date().getTime()-_;return t.info(r.green(`Successfully notified Transcend in "${b/1e3}" seconds!`)),u.length}export{u as t};
2
- //# sourceMappingURL=markRequestDataSiloIdsCompleted-B5N-cQWr.mjs.map
1
+ import{a as e}from"./constants-BnIMwfNb.mjs";import{t}from"./logger-zplFSeXU.mjs";import{RequestDataSiloStatus as n}from"@transcend-io/privacy-types";import r from"colors";import{CHANGE_REQUEST_DATA_SILO_STATUS as i,buildTranscendGraphQLClient as a,fetchRequestDataSilo as o,makeGraphQLRequest as s}from"@transcend-io/sdk";import{map as c}from"@transcend-io/utils";import l from"cli-progress";async function u({requestIds:u,dataSiloId:d,auth:f,concurrency:p=100,status:m=n.Resolved,transcendUrl:h=e}){let g=a(h,f),_=new Date().getTime(),v=new l.SingleBar({},l.Presets.shades_classic);t.info(r.magenta(`Notifying Transcend for data silo "${d}" marking "${u.length}" requests as completed.`));let y=0;v.start(u.length,0),await c(u,async e=>{let n=await o(g,{logger:t,filterBy:{requestId:e,dataSiloId:d}});try{await s(g,i,{variables:{requestDataSiloId:n.id,status:m},logger:t})}catch(e){if(!e.message.includes(`Client error: Request must be active:`)&&!e.message.includes(`Failed to find RequestDataSilo`))throw e}y+=1,v.update(y)},{concurrency:p}),v.stop();let b=new Date().getTime()-_;return t.info(r.green(`Successfully notified Transcend in "${b/1e3}" seconds!`)),u.length}export{u as t};
2
+ //# sourceMappingURL=markRequestDataSiloIdsCompleted-DX7d2Itu.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"markRequestDataSiloIdsCompleted-B5N-cQWr.mjs","names":[],"sources":["../src/lib/cron/markRequestDataSiloIdsCompleted.ts"],"sourcesContent":["import { RequestDataSiloStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n makeGraphQLRequest,\n CHANGE_REQUEST_DATA_SILO_STATUS,\n fetchRequestDataSilo,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\n\n/**\n * Given a CSV of Request IDs, mark associated RequestDataSilos as completed\n *\n * @param options - Options\n * @returns Number of items marked as completed\n */\nexport async function markRequestDataSiloIdsCompleted({\n requestIds,\n dataSiloId,\n auth,\n concurrency = 100,\n status = RequestDataSiloStatus.Resolved,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The list of request ids to mark as completed */\n requestIds: string[];\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** Status to update requests to */\n status?: RequestDataSiloStatus;\n /** Upload concurrency */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Notify Transcend\n logger.info(\n colors.magenta(\n `Notifying Transcend for data silo \"${dataSiloId}\" marking \"${requestIds.length}\" requests as completed.`,\n ),\n );\n\n let total = 0;\n progressBar.start(requestIds.length, 0);\n await map(\n requestIds,\n async (requestId) => {\n const requestDataSilo = await fetchRequestDataSilo(client, {\n logger,\n filterBy: { requestId, dataSiloId },\n });\n\n try {\n await makeGraphQLRequest<{\n /** Whether we successfully uploaded the results */\n success: boolean;\n }>(client, CHANGE_REQUEST_DATA_SILO_STATUS, {\n variables: {\n requestDataSiloId: requestDataSilo.id,\n status,\n },\n logger,\n });\n } catch (err) {\n if (\n !err.message.includes('Client error: Request must be active:') &&\n !err.message.includes('Failed to find RequestDataSilo')\n ) {\n throw err;\n }\n }\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(colors.green(`Successfully notified Transcend in \"${totalTime / 1000}\" seconds!`));\n return requestIds.length;\n}\n"],"mappings":"yYAoBA,eAAsB,EAAgC,CACpD,aACA,aACA,OACA,cAAc,IACd,SAAS,EAAsB,SAC/B,eAAe,GAcG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAGrF,EAAO,KACL,EAAO,QACL,sCAAsC,EAAW,aAAa,EAAW,OAAO,0BACjF,CACF,CAED,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAW,OAAQ,EAAE,CACvC,MAAM,EACJ,EACA,KAAO,IAAc,CACnB,IAAM,EAAkB,MAAM,EAAqB,EAAQ,CACzD,SACA,SAAU,CAAE,YAAW,aAAY,CACpC,CAAC,CAEF,GAAI,CACF,MAAM,EAGH,EAAQ,EAAiC,CAC1C,UAAW,CACT,kBAAmB,EAAgB,GACnC,SACD,CACD,SACD,CAAC,OACK,EAAK,CACZ,GACE,CAAC,EAAI,QAAQ,SAAS,wCAAwC,EAC9D,CAAC,EAAI,QAAQ,SAAS,iCAAiC,CAEvD,MAAM,EAIV,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EAGvB,OADA,EAAO,KAAK,EAAO,MAAM,uCAAuC,EAAY,IAAK,YAAY,CAAC,CACvF,EAAW"}
1
+ {"version":3,"file":"markRequestDataSiloIdsCompleted-DX7d2Itu.mjs","names":[],"sources":["../src/lib/cron/markRequestDataSiloIdsCompleted.ts"],"sourcesContent":["import { RequestDataSiloStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n makeGraphQLRequest,\n CHANGE_REQUEST_DATA_SILO_STATUS,\n fetchRequestDataSilo,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\n\n/**\n * Given a CSV of Request IDs, mark associated RequestDataSilos as completed\n *\n * @param options - Options\n * @returns Number of items marked as completed\n */\nexport async function markRequestDataSiloIdsCompleted({\n requestIds,\n dataSiloId,\n auth,\n concurrency = 100,\n status = RequestDataSiloStatus.Resolved,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The list of request ids to mark as completed */\n requestIds: string[];\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** Status to update requests to */\n status?: RequestDataSiloStatus;\n /** Upload concurrency */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Notify Transcend\n logger.info(\n colors.magenta(\n `Notifying Transcend for data silo \"${dataSiloId}\" marking \"${requestIds.length}\" requests as completed.`,\n ),\n );\n\n let total = 0;\n progressBar.start(requestIds.length, 0);\n await map(\n requestIds,\n async (requestId) => {\n const requestDataSilo = await fetchRequestDataSilo(client, {\n logger,\n filterBy: { requestId, dataSiloId },\n });\n\n try {\n await makeGraphQLRequest<{\n /** Whether we successfully uploaded the results */\n success: boolean;\n }>(client, CHANGE_REQUEST_DATA_SILO_STATUS, {\n variables: {\n requestDataSiloId: requestDataSilo.id,\n status,\n },\n logger,\n });\n } catch (err) {\n if (\n !err.message.includes('Client error: Request must be active:') &&\n !err.message.includes('Failed to find RequestDataSilo')\n ) {\n throw err;\n }\n }\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(colors.green(`Successfully notified Transcend in \"${totalTime / 1000}\" seconds!`));\n return requestIds.length;\n}\n"],"mappings":"yYAoBA,eAAsB,EAAgC,CACpD,aACA,aACA,OACA,cAAc,IACd,SAAS,EAAsB,SAC/B,eAAe,GAcG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAGrF,EAAO,KACL,EAAO,QACL,sCAAsC,EAAW,aAAa,EAAW,OAAO,0BACjF,CACF,CAED,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAW,OAAQ,EAAE,CACvC,MAAM,EACJ,EACA,KAAO,IAAc,CACnB,IAAM,EAAkB,MAAM,EAAqB,EAAQ,CACzD,SACA,SAAU,CAAE,YAAW,aAAY,CACpC,CAAC,CAEF,GAAI,CACF,MAAM,EAGH,EAAQ,EAAiC,CAC1C,UAAW,CACT,kBAAmB,EAAgB,GACnC,SACD,CACD,SACD,CAAC,OACK,EAAK,CACZ,GACE,CAAC,EAAI,QAAQ,SAAS,wCAAwC,EAC9D,CAAC,EAAI,QAAQ,SAAS,iCAAiC,CAEvD,MAAM,EAIV,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EAGvB,OADA,EAAO,KAAK,EAAO,MAAM,uCAAuC,EAAY,IAAK,YAAY,CAAC,CACvF,EAAW"}
@@ -1,2 +1,2 @@
1
- import{a as e}from"./constants-jjHIzHGm.mjs";import{t}from"./logger-zplFSeXU.mjs";import{o as n}from"./request-BiPv6jmP.mjs";import{r}from"./fetchAllRequests-2TZr-LfT.mjs";import{RequestStatus as i}from"@transcend-io/privacy-types";import a from"colors";import{buildTranscendGraphQLClient as o,makeGraphQLRequest as s}from"@transcend-io/sdk";import{map as c}from"@transcend-io/utils";import l from"cli-progress";async function u({requestActions:u,auth:d,requestIds:f,statuses:p=[i.Compiling,i.RequestMade,i.Delayed,i.Approving,i.Secondary,i.Enriching,i.Waiting,i.SecondaryApproving],createdAtAfter:m,createdAtBefore:h,updatedAtBefore:g,updatedAtAfter:_,concurrency:v=100,transcendUrl:y=e}){let b=o(y,d),x=new Date().getTime(),S=new l.SingleBar({},l.Presets.shades_classic),C=await r(b,{actions:u,statuses:p,createdAtBefore:h,createdAtAfter:m,updatedAtBefore:g,updatedAtAfter:_,isSilent:!1,requestIds:f});t.info(a.magenta(`Marking "${C.length}" as silent mode.`));let w=0;S.start(C.length,0),await c(C,async e=>{await s(b,n,{variables:{input:{id:e.id,isSilent:!0}},logger:t}),w+=1,S.update(w)},{concurrency:v}),S.stop();let T=new Date().getTime()-x;return t.info(a.green(`Successfully marked ${w} requests as silent mode in "${T/1e3}" seconds!`)),C.length}export{u as t};
2
- //# sourceMappingURL=markSilentPrivacyRequests-BiaButWF.mjs.map
1
+ import{a as e}from"./constants-BnIMwfNb.mjs";import{t}from"./logger-zplFSeXU.mjs";import{o as n}from"./request-BiPv6jmP.mjs";import{r}from"./fetchAllRequests-2TZr-LfT.mjs";import{RequestStatus as i}from"@transcend-io/privacy-types";import a from"colors";import{buildTranscendGraphQLClient as o,makeGraphQLRequest as s}from"@transcend-io/sdk";import{map as c}from"@transcend-io/utils";import l from"cli-progress";async function u({requestActions:u,auth:d,requestIds:f,statuses:p=[i.Compiling,i.RequestMade,i.Delayed,i.Approving,i.Secondary,i.Enriching,i.Waiting,i.SecondaryApproving],createdAtAfter:m,createdAtBefore:h,updatedAtBefore:g,updatedAtAfter:_,concurrency:v=100,transcendUrl:y=e}){let b=o(y,d),x=new Date().getTime(),S=new l.SingleBar({},l.Presets.shades_classic),C=await r(b,{actions:u,statuses:p,createdAtBefore:h,createdAtAfter:m,updatedAtBefore:g,updatedAtAfter:_,isSilent:!1,requestIds:f});t.info(a.magenta(`Marking "${C.length}" as silent mode.`));let w=0;S.start(C.length,0),await c(C,async e=>{await s(b,n,{variables:{input:{id:e.id,isSilent:!0}},logger:t}),w+=1,S.update(w)},{concurrency:v}),S.stop();let T=new Date().getTime()-x;return t.info(a.green(`Successfully marked ${w} requests as silent mode in "${T/1e3}" seconds!`)),C.length}export{u as t};
2
+ //# sourceMappingURL=markSilentPrivacyRequests-3t9IZPpS.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"markSilentPrivacyRequests-BiaButWF.mjs","names":[],"sources":["../src/lib/requests/markSilentPrivacyRequests.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport { buildTranscendGraphQLClient, makeGraphQLRequest } from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { UPDATE_PRIVACY_REQUEST, fetchAllRequests } from '../graphql/index.js';\n\n/**\n * Mark a set of privacy requests to be in silent mode\n *\n * @param options - Options\n * @returns The number of requests marked silent\n */\nexport async function markSilentPrivacyRequests({\n requestActions,\n auth,\n requestIds,\n statuses = [\n RequestStatus.Compiling,\n RequestStatus.RequestMade,\n RequestStatus.Delayed,\n RequestStatus.Approving,\n RequestStatus.Secondary,\n RequestStatus.Enriching,\n RequestStatus.Waiting,\n RequestStatus.SecondaryApproving,\n ],\n createdAtAfter,\n createdAtBefore,\n updatedAtBefore,\n updatedAtAfter,\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The request actions that should be restarted */\n requestActions: RequestAction[];\n /** Transcend API key authentication */\n auth: string;\n /** Concurrency limit for approving */\n concurrency?: number;\n /** The request statuses to mark silent */\n statuses?: RequestStatus[];\n /** The set of privacy requests to mark silent */\n requestIds?: string[];\n /** Filter for requests created before this date */\n createdAtBefore?: Date;\n /** Filter for requests created after this date */\n createdAtAfter?: Date;\n /** Filter for requests updated before this date */\n updatedAtBefore?: Date;\n /** Filter for requests updated after this date */\n updatedAtAfter?: Date;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Pull in the requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isSilent: false,\n requestIds,\n });\n\n // Notify Transcend\n logger.info(colors.magenta(`Marking \"${allRequests.length}\" as silent mode.`));\n\n let total = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToMarkSilent) => {\n await makeGraphQLRequest(client, UPDATE_PRIVACY_REQUEST, {\n variables: {\n input: {\n id: requestToMarkSilent.id,\n isSilent: true,\n },\n },\n logger,\n });\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully marked ${total} requests as silent mode in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n return allRequests.length;\n}\n"],"mappings":"4ZAgBA,eAAsB,EAA0B,CAC9C,iBACA,OACA,aACA,WAAW,CACT,EAAc,UACd,EAAc,YACd,EAAc,QACd,EAAc,UACd,EAAc,UACd,EAAc,UACd,EAAc,QACd,EAAc,mBACf,CACD,iBACA,kBACA,kBACA,iBACA,cAAc,IACd,eAAe,GAsBG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAG/E,EAAc,MAAM,EAAiB,EAAQ,CACjD,QAAS,EACT,WACA,kBACA,iBACA,kBACA,iBACA,SAAU,GACV,aACD,CAAC,CAGF,EAAO,KAAK,EAAO,QAAQ,YAAY,EAAY,OAAO,mBAAmB,CAAC,CAE9E,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAY,OAAQ,EAAE,CACxC,MAAM,EACJ,EACA,KAAO,IAAwB,CAC7B,MAAM,EAAmB,EAAQ,EAAwB,CACvD,UAAW,CACT,MAAO,CACL,GAAI,EAAoB,GACxB,SAAU,GACX,CACF,CACD,SACD,CAAC,CAEF,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EAOvB,OALA,EAAO,KACL,EAAO,MACL,uBAAuB,EAAM,+BAA+B,EAAY,IAAK,YAC9E,CACF,CACM,EAAY"}
1
+ {"version":3,"file":"markSilentPrivacyRequests-3t9IZPpS.mjs","names":[],"sources":["../src/lib/requests/markSilentPrivacyRequests.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport { buildTranscendGraphQLClient, makeGraphQLRequest } from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { UPDATE_PRIVACY_REQUEST, fetchAllRequests } from '../graphql/index.js';\n\n/**\n * Mark a set of privacy requests to be in silent mode\n *\n * @param options - Options\n * @returns The number of requests marked silent\n */\nexport async function markSilentPrivacyRequests({\n requestActions,\n auth,\n requestIds,\n statuses = [\n RequestStatus.Compiling,\n RequestStatus.RequestMade,\n RequestStatus.Delayed,\n RequestStatus.Approving,\n RequestStatus.Secondary,\n RequestStatus.Enriching,\n RequestStatus.Waiting,\n RequestStatus.SecondaryApproving,\n ],\n createdAtAfter,\n createdAtBefore,\n updatedAtBefore,\n updatedAtAfter,\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The request actions that should be restarted */\n requestActions: RequestAction[];\n /** Transcend API key authentication */\n auth: string;\n /** Concurrency limit for approving */\n concurrency?: number;\n /** The request statuses to mark silent */\n statuses?: RequestStatus[];\n /** The set of privacy requests to mark silent */\n requestIds?: string[];\n /** Filter for requests created before this date */\n createdAtBefore?: Date;\n /** Filter for requests created after this date */\n createdAtAfter?: Date;\n /** Filter for requests updated before this date */\n updatedAtBefore?: Date;\n /** Filter for requests updated after this date */\n updatedAtAfter?: Date;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Pull in the requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isSilent: false,\n requestIds,\n });\n\n // Notify Transcend\n logger.info(colors.magenta(`Marking \"${allRequests.length}\" as silent mode.`));\n\n let total = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToMarkSilent) => {\n await makeGraphQLRequest(client, UPDATE_PRIVACY_REQUEST, {\n variables: {\n input: {\n id: requestToMarkSilent.id,\n isSilent: true,\n },\n },\n logger,\n });\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully marked ${total} requests as silent mode in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n return allRequests.length;\n}\n"],"mappings":"4ZAgBA,eAAsB,EAA0B,CAC9C,iBACA,OACA,aACA,WAAW,CACT,EAAc,UACd,EAAc,YACd,EAAc,QACd,EAAc,UACd,EAAc,UACd,EAAc,UACd,EAAc,QACd,EAAc,mBACf,CACD,iBACA,kBACA,kBACA,iBACA,cAAc,IACd,eAAe,GAsBG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAG/E,EAAc,MAAM,EAAiB,EAAQ,CACjD,QAAS,EACT,WACA,kBACA,iBACA,kBACA,iBACA,SAAU,GACV,aACD,CAAC,CAGF,EAAO,KAAK,EAAO,QAAQ,YAAY,EAAY,OAAO,mBAAmB,CAAC,CAE9E,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAY,OAAQ,EAAE,CACxC,MAAM,EACJ,EACA,KAAO,IAAwB,CAC7B,MAAM,EAAmB,EAAQ,EAAwB,CACvD,UAAW,CACT,MAAO,CACL,GAAI,EAAoB,GACxB,SAAU,GACX,CACF,CACD,SACD,CAAC,CAEF,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EAOvB,OALA,EAAO,KACL,EAAO,MACL,uBAAuB,EAAM,+BAA+B,EAAY,IAAK,YAC9E,CACF,CACM,EAAY"}
@@ -1,2 +1,2 @@
1
- import{a as e}from"./constants-jjHIzHGm.mjs";import{t}from"./logger-zplFSeXU.mjs";import{r as n}from"./request-BiPv6jmP.mjs";import{r}from"./fetchAllRequests-2TZr-LfT.mjs";import{RequestAction as i}from"@transcend-io/privacy-types";import a from"colors";import{buildTranscendGraphQLClient as o,fetchAllTemplates as s,makeGraphQLRequest as c}from"@transcend-io/sdk";import{map as l}from"@transcend-io/utils";import u from"cli-progress";async function d({requestActions:d=Object.values(i),auth:f,requestIds:p,createdAtBefore:m,days:h=45,daysLeft:g=10,createdAtAfter:_,updatedAtBefore:v,updatedAtAfter:y,emailTemplate:b=`Additional Time Needed`,concurrency:x=100,transcendUrl:S=e}){let C=o(S,f),w=new Date().getTime(),T=new u.SingleBar({},u.Presets.shades_classic),E=(await s(C,{logger:t,filterBy:{title:b}})).find(e=>e.title===b);if(!E)throw Error(`Failed to find a template with title: "${b}"`);let D=await r(C,{actions:d,createdAtBefore:m,createdAtAfter:_,updatedAtBefore:v,updatedAtAfter:y,isSilent:!1,isClosed:!1,requestIds:p});D=D.filter(e=>typeof e.daysRemaining==`number`&&e.daysRemaining<g),t.info(a.magenta(`Notifying "${D.length}" that more time is needed.`));let O=0;T.start(D.length,0),await l(D,async e=>{await c(C,n,{variables:{input:{requestId:e.id,template:E.template.defaultMessage,subject:E.subject.defaultMessage,additionalTime:h}},logger:t}),O+=1,T.update(O)},{concurrency:x}),T.stop();let k=new Date().getTime()-w;return t.info(a.green(`Successfully marked ${O} requests as silent mode in "${k/1e3}" seconds!`)),D.length}export{d as t};
2
- //# sourceMappingURL=notifyPrivacyRequestsAdditionalTime-D3Vtvg5G.mjs.map
1
+ import{a as e}from"./constants-BnIMwfNb.mjs";import{t}from"./logger-zplFSeXU.mjs";import{r as n}from"./request-BiPv6jmP.mjs";import{r}from"./fetchAllRequests-2TZr-LfT.mjs";import{RequestAction as i}from"@transcend-io/privacy-types";import a from"colors";import{buildTranscendGraphQLClient as o,fetchAllTemplates as s,makeGraphQLRequest as c}from"@transcend-io/sdk";import{map as l}from"@transcend-io/utils";import u from"cli-progress";async function d({requestActions:d=Object.values(i),auth:f,requestIds:p,createdAtBefore:m,days:h=45,daysLeft:g=10,createdAtAfter:_,updatedAtBefore:v,updatedAtAfter:y,emailTemplate:b=`Additional Time Needed`,concurrency:x=100,transcendUrl:S=e}){let C=o(S,f),w=new Date().getTime(),T=new u.SingleBar({},u.Presets.shades_classic),E=(await s(C,{logger:t,filterBy:{title:b}})).find(e=>e.title===b);if(!E)throw Error(`Failed to find a template with title: "${b}"`);let D=await r(C,{actions:d,createdAtBefore:m,createdAtAfter:_,updatedAtBefore:v,updatedAtAfter:y,isSilent:!1,isClosed:!1,requestIds:p});D=D.filter(e=>typeof e.daysRemaining==`number`&&e.daysRemaining<g),t.info(a.magenta(`Notifying "${D.length}" that more time is needed.`));let O=0;T.start(D.length,0),await l(D,async e=>{await c(C,n,{variables:{input:{requestId:e.id,template:E.template.defaultMessage,subject:E.subject.defaultMessage,additionalTime:h}},logger:t}),O+=1,T.update(O)},{concurrency:x}),T.stop();let k=new Date().getTime()-w;return t.info(a.green(`Successfully marked ${O} requests as silent mode in "${k/1e3}" seconds!`)),D.length}export{d as t};
2
+ //# sourceMappingURL=notifyPrivacyRequestsAdditionalTime-Ce_GPf6U.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"notifyPrivacyRequestsAdditionalTime-D3Vtvg5G.mjs","names":[],"sources":["../src/lib/requests/notifyPrivacyRequestsAdditionalTime.ts"],"sourcesContent":["import { RequestAction } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n fetchAllTemplates,\n makeGraphQLRequest,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { NOTIFY_ADDITIONAL_TIME, fetchAllRequests } from '../graphql/index.js';\n\n/**\n * Mark a set of privacy requests to be in silent mode.\n * Note requests in silent mode are ignored\n *\n * @param options - Options\n * @returns The number of requests marked silent\n */\nexport async function notifyPrivacyRequestsAdditionalTime({\n requestActions = Object.values(RequestAction),\n auth,\n requestIds,\n createdAtBefore,\n days = 45,\n daysLeft = 10,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n emailTemplate = 'Additional Time Needed',\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The request actions that should be restarted */\n requestActions?: RequestAction[];\n /** Filter for requests created before this date */\n createdAtBefore: Date;\n /** Filter for requests created after this date */\n createdAtAfter?: Date;\n /** Filter for requests updated before this date */\n updatedAtBefore?: Date;\n /** Filter for requests updated after this date */\n updatedAtAfter?: Date;\n /** Email template */\n emailTemplate?: string;\n /** Transcend API key authentication */\n auth: string;\n /** Number of days to extend request by */\n days?: number;\n /**\n * Only notify requests that have less than this number of days until they are considered expired.\n * This allows for re-running the command without notifying the same users multiple times\n */\n daysLeft?: number;\n /** Concurrency limit for approving */\n concurrency?: number;\n /** The set of privacy requests to notify */\n requestIds?: string[];\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Grab the template with that title\n const matchingTemplates = await fetchAllTemplates(client, {\n logger,\n filterBy: { title: emailTemplate },\n });\n const exactTemplateMatch = matchingTemplates.find((template) => template.title === emailTemplate);\n if (!exactTemplateMatch) {\n throw new Error(`Failed to find a template with title: \"${emailTemplate}\"`);\n }\n\n // Pull in the requests\n let allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isSilent: false,\n isClosed: false,\n requestIds,\n });\n\n // Filter requests by daysLeft\n allRequests = allRequests.filter(\n (request) => typeof request.daysRemaining === 'number' && request.daysRemaining < daysLeft,\n );\n\n // Notify Transcend\n logger.info(colors.magenta(`Notifying \"${allRequests.length}\" that more time is needed.`));\n\n let total = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToNotify) => {\n await makeGraphQLRequest(client, NOTIFY_ADDITIONAL_TIME, {\n variables: {\n input: {\n requestId: requestToNotify.id,\n template: exactTemplateMatch.template.defaultMessage,\n subject: exactTemplateMatch.subject.defaultMessage,\n additionalTime: days,\n },\n },\n logger,\n });\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully marked ${total} requests as silent mode in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n return allRequests.length;\n}\n"],"mappings":"mbAqBA,eAAsB,EAAoC,CACxD,iBAAiB,OAAO,OAAO,EAAc,CAC7C,OACA,aACA,kBACA,OAAO,GACP,WAAW,GACX,iBACA,kBACA,iBACA,gBAAgB,yBAChB,cAAc,IACd,eAAe,GA6BG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAO/E,GAAqB,MAJK,EAAkB,EAAQ,CACxD,SACA,SAAU,CAAE,MAAO,EAAe,CACnC,CAAC,EAC2C,KAAM,GAAa,EAAS,QAAU,EAAc,CACjG,GAAI,CAAC,EACH,MAAU,MAAM,0CAA0C,EAAc,GAAG,CAI7E,IAAI,EAAc,MAAM,EAAiB,EAAQ,CAC/C,QAAS,EACT,kBACA,iBACA,kBACA,iBACA,SAAU,GACV,SAAU,GACV,aACD,CAAC,CAGF,EAAc,EAAY,OACvB,GAAY,OAAO,EAAQ,eAAkB,UAAY,EAAQ,cAAgB,EACnF,CAGD,EAAO,KAAK,EAAO,QAAQ,cAAc,EAAY,OAAO,6BAA6B,CAAC,CAE1F,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAY,OAAQ,EAAE,CACxC,MAAM,EACJ,EACA,KAAO,IAAoB,CACzB,MAAM,EAAmB,EAAQ,EAAwB,CACvD,UAAW,CACT,MAAO,CACL,UAAW,EAAgB,GAC3B,SAAU,EAAmB,SAAS,eACtC,QAAS,EAAmB,QAAQ,eACpC,eAAgB,EACjB,CACF,CACD,SACD,CAAC,CAEF,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EAOvB,OALA,EAAO,KACL,EAAO,MACL,uBAAuB,EAAM,+BAA+B,EAAY,IAAK,YAC9E,CACF,CACM,EAAY"}
1
+ {"version":3,"file":"notifyPrivacyRequestsAdditionalTime-Ce_GPf6U.mjs","names":[],"sources":["../src/lib/requests/notifyPrivacyRequestsAdditionalTime.ts"],"sourcesContent":["import { RequestAction } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n fetchAllTemplates,\n makeGraphQLRequest,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { NOTIFY_ADDITIONAL_TIME, fetchAllRequests } from '../graphql/index.js';\n\n/**\n * Mark a set of privacy requests to be in silent mode.\n * Note requests in silent mode are ignored\n *\n * @param options - Options\n * @returns The number of requests marked silent\n */\nexport async function notifyPrivacyRequestsAdditionalTime({\n requestActions = Object.values(RequestAction),\n auth,\n requestIds,\n createdAtBefore,\n days = 45,\n daysLeft = 10,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n emailTemplate = 'Additional Time Needed',\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The request actions that should be restarted */\n requestActions?: RequestAction[];\n /** Filter for requests created before this date */\n createdAtBefore: Date;\n /** Filter for requests created after this date */\n createdAtAfter?: Date;\n /** Filter for requests updated before this date */\n updatedAtBefore?: Date;\n /** Filter for requests updated after this date */\n updatedAtAfter?: Date;\n /** Email template */\n emailTemplate?: string;\n /** Transcend API key authentication */\n auth: string;\n /** Number of days to extend request by */\n days?: number;\n /**\n * Only notify requests that have less than this number of days until they are considered expired.\n * This allows for re-running the command without notifying the same users multiple times\n */\n daysLeft?: number;\n /** Concurrency limit for approving */\n concurrency?: number;\n /** The set of privacy requests to notify */\n requestIds?: string[];\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Grab the template with that title\n const matchingTemplates = await fetchAllTemplates(client, {\n logger,\n filterBy: { title: emailTemplate },\n });\n const exactTemplateMatch = matchingTemplates.find((template) => template.title === emailTemplate);\n if (!exactTemplateMatch) {\n throw new Error(`Failed to find a template with title: \"${emailTemplate}\"`);\n }\n\n // Pull in the requests\n let allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isSilent: false,\n isClosed: false,\n requestIds,\n });\n\n // Filter requests by daysLeft\n allRequests = allRequests.filter(\n (request) => typeof request.daysRemaining === 'number' && request.daysRemaining < daysLeft,\n );\n\n // Notify Transcend\n logger.info(colors.magenta(`Notifying \"${allRequests.length}\" that more time is needed.`));\n\n let total = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToNotify) => {\n await makeGraphQLRequest(client, NOTIFY_ADDITIONAL_TIME, {\n variables: {\n input: {\n requestId: requestToNotify.id,\n template: exactTemplateMatch.template.defaultMessage,\n subject: exactTemplateMatch.subject.defaultMessage,\n additionalTime: days,\n },\n },\n logger,\n });\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully marked ${total} requests as silent mode in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n return allRequests.length;\n}\n"],"mappings":"mbAqBA,eAAsB,EAAoC,CACxD,iBAAiB,OAAO,OAAO,EAAc,CAC7C,OACA,aACA,kBACA,OAAO,GACP,WAAW,GACX,iBACA,kBACA,iBACA,gBAAgB,yBAChB,cAAc,IACd,eAAe,GA6BG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAO/E,GAAqB,MAJK,EAAkB,EAAQ,CACxD,SACA,SAAU,CAAE,MAAO,EAAe,CACnC,CAAC,EAC2C,KAAM,GAAa,EAAS,QAAU,EAAc,CACjG,GAAI,CAAC,EACH,MAAU,MAAM,0CAA0C,EAAc,GAAG,CAI7E,IAAI,EAAc,MAAM,EAAiB,EAAQ,CAC/C,QAAS,EACT,kBACA,iBACA,kBACA,iBACA,SAAU,GACV,SAAU,GACV,aACD,CAAC,CAGF,EAAc,EAAY,OACvB,GAAY,OAAO,EAAQ,eAAkB,UAAY,EAAQ,cAAgB,EACnF,CAGD,EAAO,KAAK,EAAO,QAAQ,cAAc,EAAY,OAAO,6BAA6B,CAAC,CAE1F,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAY,OAAQ,EAAE,CACxC,MAAM,EACJ,EACA,KAAO,IAAoB,CACzB,MAAM,EAAmB,EAAQ,EAAwB,CACvD,UAAW,CACT,MAAO,CACL,UAAW,EAAgB,GAC3B,SAAU,EAAmB,SAAS,eACtC,QAAS,EAAmB,QAAQ,eACpC,eAAgB,EACjB,CACF,CACD,SACD,CAAC,CAEF,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SACF,CAAG,EAOvB,OALA,EAAO,KACL,EAAO,MACL,uBAAuB,EAAM,+BAA+B,EAAY,IAAK,YAC9E,CACF,CACM,EAAY"}
@@ -1,2 +1,2 @@
1
- import{a as e}from"./constants-jjHIzHGm.mjs";import{t}from"./logger-zplFSeXU.mjs";import n from"colors";import{decodeCodec as r}from"@transcend-io/type-utils";import*as i from"io-ts";import{REDUCED_REQUESTS_FOR_DATA_SILO_COUNT as a,buildTranscendGraphQLClient as o,createSombraGotInstance as s,makeGraphQLRequest as c,withTransientRetry as l}from"@transcend-io/sdk";import{mapSeries as u}from"@transcend-io/utils";import d from"cli-progress";async function f(e,{dataSiloId:n}){let{listReducedRequestsForDataSilo:{totalCount:r}}=await c(e,a,{variables:{input:{dataSiloId:n,isResolved:!1}},logger:t});return r}const p=i.type({id:i.string,name:i.string,partition:i.string}),m=i.intersection([i.type({identifier:i.string,type:i.string,coreIdentifier:i.string,dataSiloId:i.string,requestId:i.string,nonce:i.string,requestCreatedAt:i.string,daysUntilOverdue:i.number,attributes:i.array(i.type({key:i.string,values:i.array(i.string)}))}),i.partial({partition:i.union([p,i.null])})]);async function h(e,{dataSiloId:n,limit:a=100,offset:o=0,requestType:s}){try{let c=await l(`pullCronPageOfIdentifiers`,()=>e.get(`v1/data-silo/${n}/pending-requests/${s}`,{searchParams:{offset:o,limit:a}}).json(),{logger:t,maxAttempts:6,baseDelayMs:500}),{items:u}=r(i.type({items:i.array(m)}),c);return u}catch(e){throw Error(`Received an error from server: ${e?.response?.body||e?.message}`)}}async function g({dataSiloId:r,auth:i,sombraAuth:a,actions:c,apiPageSize:l=100,savePageSize:p=1e3,onSave:m,transcendUrl:g=e,skipRequestCount:_=!1}){if(p%l!==0)throw Error(`savePageSize must be a multiple of apiPageSize. savePageSize: ${p}, apiPageSize: ${l}`);let v=await s(g,i,{logger:t,sombraApiKey:a,sombraUrl:process.env.SOMBRA_URL}),y=o(g,i),b=0;_||(b=await f(y,{dataSiloId:r})),t.info(n.magenta(`Pulling ${_?`all`:b} outstanding request identifiers for data silo: "${r}" for requests of types "${c.join(`", "`)}"`));let x=new Date().getTime(),S=new d.SingleBar({},d.Presets.shades_classic),C=new Set,w=[],T=[];_||S.start(b,0),await u(c,async e=>{let i=0,a=!0;for(;a;){let o=await h(v,{dataSiloId:r,limit:l,offset:i,requestType:e}),s=o.map(t=>(C.add(t.requestId),{...t,action:e})),c=s.map(({attributes:e,partition:t,...n})=>({...n,...t?{partitionId:t.id,partitionName:t.name,partitionKey:t.partition}:{},...e.reduce((e,t)=>Object.assign(e,{[t.key]:t.values.join(`,`)}),{})}));w.push(...s),T.push(...c),T.length>=p&&(await m(T),T=[]),a=o.length===l,i+=l,_?t.info(n.magenta(`Pulled ${o.length} outstanding identifiers for ${C.size} requests`)):S.update(C.size)}}),T.length>0&&await m(T),_||S.stop();let E=new Date().getTime()-x;return t.info(n.green(`Successfully pulled ${w.length} outstanding identifiers from ${C.size} requests in "${E/1e3}" seconds!`)),{identifiers:w}}export{f as a,h as i,m as n,p as r,g as t};
2
- //# sourceMappingURL=pullChunkedCustomSiloOutstandingIdentifiers-D85P1W_8.mjs.map
1
+ import{a as e}from"./constants-BnIMwfNb.mjs";import{t}from"./logger-zplFSeXU.mjs";import n from"colors";import{decodeCodec as r}from"@transcend-io/type-utils";import*as i from"io-ts";import{REDUCED_REQUESTS_FOR_DATA_SILO_COUNT as a,buildTranscendGraphQLClient as o,createSombraGotInstance as s,makeGraphQLRequest as c,withTransientRetry as l}from"@transcend-io/sdk";import{mapSeries as u}from"@transcend-io/utils";import d from"cli-progress";async function f(e,{dataSiloId:n}){let{listReducedRequestsForDataSilo:{totalCount:r}}=await c(e,a,{variables:{input:{dataSiloId:n,isResolved:!1}},logger:t});return r}const p=i.type({id:i.string,name:i.string,partition:i.string}),m=i.intersection([i.type({identifier:i.string,type:i.string,coreIdentifier:i.string,dataSiloId:i.string,requestId:i.string,nonce:i.string,requestCreatedAt:i.string,daysUntilOverdue:i.number,attributes:i.array(i.type({key:i.string,values:i.array(i.string)}))}),i.partial({partition:i.union([p,i.null])})]);async function h(e,{dataSiloId:n,limit:a=100,offset:o=0,requestType:s}){try{let c=await l(`pullCronPageOfIdentifiers`,()=>e.get(`v1/data-silo/${n}/pending-requests/${s}`,{searchParams:{offset:o,limit:a}}).json(),{logger:t,maxAttempts:6,baseDelayMs:500}),{items:u}=r(i.type({items:i.array(m)}),c);return u}catch(e){throw Error(`Received an error from server: ${e?.response?.body||e?.message}`)}}async function g({dataSiloId:r,auth:i,sombraAuth:a,actions:c,apiPageSize:l=100,savePageSize:p=1e3,onSave:m,transcendUrl:g=e,skipRequestCount:_=!1}){if(p%l!==0)throw Error(`savePageSize must be a multiple of apiPageSize. savePageSize: ${p}, apiPageSize: ${l}`);let v=await s(g,i,{logger:t,sombraApiKey:a,sombraUrl:process.env.SOMBRA_URL}),y=o(g,i),b=0;_||(b=await f(y,{dataSiloId:r})),t.info(n.magenta(`Pulling ${_?`all`:b} outstanding request identifiers for data silo: "${r}" for requests of types "${c.join(`", "`)}"`));let x=new Date().getTime(),S=new d.SingleBar({},d.Presets.shades_classic),C=new Set,w=[],T=[];_||S.start(b,0),await u(c,async e=>{let i=0,a=!0;for(;a;){let o=await h(v,{dataSiloId:r,limit:l,offset:i,requestType:e}),s=o.map(t=>(C.add(t.requestId),{...t,action:e})),c=s.map(({attributes:e,partition:t,...n})=>({...n,...t?{partitionId:t.id,partitionName:t.name,partitionKey:t.partition}:{},...e.reduce((e,t)=>Object.assign(e,{[t.key]:t.values.join(`,`)}),{})}));w.push(...s),T.push(...c),T.length>=p&&(await m(T),T=[]),a=o.length===l,i+=l,_?t.info(n.magenta(`Pulled ${o.length} outstanding identifiers for ${C.size} requests`)):S.update(C.size)}}),T.length>0&&await m(T),_||S.stop();let E=new Date().getTime()-x;return t.info(n.green(`Successfully pulled ${w.length} outstanding identifiers from ${C.size} requests in "${E/1e3}" seconds!`)),{identifiers:w}}export{f as a,h as i,m as n,p as r,g as t};
2
+ //# sourceMappingURL=pullChunkedCustomSiloOutstandingIdentifiers-3OvSjU15.mjs.map