@transcend-io/cli 8.1.2 → 8.1.6

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 (111) hide show
  1. package/dist/bin/bash-complete.cjs +1 -1
  2. package/dist/bin/cli.cjs +1 -1
  3. package/dist/bin/deprecated-command.cjs +2 -2
  4. package/dist/{chunk-FIPM3WX2.cjs → chunk-3BZWG5GJ.cjs} +2 -2
  5. package/dist/{chunk-FIPM3WX2.cjs.map → chunk-3BZWG5GJ.cjs.map} +1 -1
  6. package/dist/{chunk-E3HBS2DS.cjs → chunk-5CDEM565.cjs} +2 -2
  7. package/dist/{chunk-E3HBS2DS.cjs.map → chunk-5CDEM565.cjs.map} +1 -1
  8. package/dist/{chunk-DQ4R65RB.cjs → chunk-GVK66NZA.cjs} +2 -2
  9. package/dist/{chunk-DQ4R65RB.cjs.map → chunk-GVK66NZA.cjs.map} +1 -1
  10. package/dist/{chunk-CUTZDENX.cjs → chunk-J5D25IXA.cjs} +20 -20
  11. package/dist/{chunk-CUTZDENX.cjs.map → chunk-J5D25IXA.cjs.map} +1 -1
  12. package/dist/chunk-JEH3FW7J.cjs +2920 -0
  13. package/dist/{chunk-EMB64AC3.cjs.map → chunk-JEH3FW7J.cjs.map} +1 -1
  14. package/dist/{chunk-BZI5QRMD.cjs → chunk-OAG7DICW.cjs} +2 -2
  15. package/dist/{chunk-BZI5QRMD.cjs.map → chunk-OAG7DICW.cjs.map} +1 -1
  16. package/dist/{chunk-4U57O4PS.cjs → chunk-OFZ7ZSEV.cjs} +2 -2
  17. package/dist/{chunk-4U57O4PS.cjs.map → chunk-OFZ7ZSEV.cjs.map} +1 -1
  18. package/dist/{chunk-KUOWI5XE.cjs → chunk-SADDDAXF.cjs} +2 -2
  19. package/dist/{chunk-KUOWI5XE.cjs.map → chunk-SADDDAXF.cjs.map} +1 -1
  20. package/dist/{chunk-YYYG72XH.cjs → chunk-UW2YF6JM.cjs} +4 -4
  21. package/dist/{chunk-YYYG72XH.cjs.map → chunk-UW2YF6JM.cjs.map} +1 -1
  22. package/dist/{chunk-CVQWA6RN.cjs → chunk-VGTGGUCM.cjs} +2 -2
  23. package/dist/{chunk-CVQWA6RN.cjs.map → chunk-VGTGGUCM.cjs.map} +1 -1
  24. package/dist/{chunk-LOWUINKF.cjs → chunk-VKNIPZ42.cjs} +2 -2
  25. package/dist/{chunk-LOWUINKF.cjs.map → chunk-VKNIPZ42.cjs.map} +1 -1
  26. package/dist/{chunk-V4GIAIGU.cjs → chunk-VXJ3QION.cjs} +3 -3
  27. package/dist/{chunk-V4GIAIGU.cjs.map → chunk-VXJ3QION.cjs.map} +1 -1
  28. package/dist/{impl-CW4P3FBU.cjs → impl-3THXGCQP.cjs} +2 -2
  29. package/dist/{impl-CW4P3FBU.cjs.map → impl-3THXGCQP.cjs.map} +1 -1
  30. package/dist/{impl-L5IP2CI4.cjs → impl-43UGCXOQ.cjs} +2 -2
  31. package/dist/{impl-L5IP2CI4.cjs.map → impl-43UGCXOQ.cjs.map} +1 -1
  32. package/dist/{impl-FNQYLHQP.cjs → impl-4OHRVXEI.cjs} +2 -2
  33. package/dist/{impl-FNQYLHQP.cjs.map → impl-4OHRVXEI.cjs.map} +1 -1
  34. package/dist/{impl-VNONBZAR.cjs → impl-4TH3KKOU.cjs} +2 -2
  35. package/dist/{impl-VNONBZAR.cjs.map → impl-4TH3KKOU.cjs.map} +1 -1
  36. package/dist/impl-534MCRL5.cjs +2 -0
  37. package/dist/{impl-KFCSSBYU.cjs.map → impl-534MCRL5.cjs.map} +1 -1
  38. package/dist/{impl-3M5H66QQ.cjs → impl-67VIE5PB.cjs} +2 -2
  39. package/dist/{impl-3M5H66QQ.cjs.map → impl-67VIE5PB.cjs.map} +1 -1
  40. package/dist/{impl-A6YXWSI5.cjs → impl-6A3ARA2O.cjs} +6 -6
  41. package/dist/{impl-A6YXWSI5.cjs.map → impl-6A3ARA2O.cjs.map} +1 -1
  42. package/dist/{impl-ABCJ37Z7.cjs → impl-7RHWAGHN.cjs} +2 -2
  43. package/dist/{impl-ABCJ37Z7.cjs.map → impl-7RHWAGHN.cjs.map} +1 -1
  44. package/dist/{impl-2REOS3PC.cjs → impl-7RXJTTTG.cjs} +2 -2
  45. package/dist/{impl-2REOS3PC.cjs.map → impl-7RXJTTTG.cjs.map} +1 -1
  46. package/dist/{impl-Y6UD6TEX.cjs → impl-DRCKNEM2.cjs} +2 -2
  47. package/dist/{impl-Y6UD6TEX.cjs.map → impl-DRCKNEM2.cjs.map} +1 -1
  48. package/dist/{impl-M6QIFDQJ.cjs → impl-DSHX3YJG.cjs} +2 -2
  49. package/dist/{impl-M6QIFDQJ.cjs.map → impl-DSHX3YJG.cjs.map} +1 -1
  50. package/dist/{impl-ES6WNRK2.cjs → impl-DSNVVZRC.cjs} +2 -2
  51. package/dist/{impl-ES6WNRK2.cjs.map → impl-DSNVVZRC.cjs.map} +1 -1
  52. package/dist/{impl-KBO3FFYP.cjs → impl-E3URUIOG.cjs} +2 -2
  53. package/dist/{impl-KBO3FFYP.cjs.map → impl-E3URUIOG.cjs.map} +1 -1
  54. package/dist/{impl-GVGOIIHI.cjs → impl-FFNYFUNL.cjs} +2 -2
  55. package/dist/{impl-GVGOIIHI.cjs.map → impl-FFNYFUNL.cjs.map} +1 -1
  56. package/dist/{impl-ANMYZBXH.cjs → impl-FUTK5GS3.cjs} +2 -2
  57. package/dist/{impl-ANMYZBXH.cjs.map → impl-FUTK5GS3.cjs.map} +1 -1
  58. package/dist/{impl-PERSC7WX.cjs → impl-FXW73S5T.cjs} +2 -2
  59. package/dist/{impl-PERSC7WX.cjs.map → impl-FXW73S5T.cjs.map} +1 -1
  60. package/dist/{impl-KL5OOY5U.cjs → impl-H3AZBUG5.cjs} +2 -2
  61. package/dist/{impl-KL5OOY5U.cjs.map → impl-H3AZBUG5.cjs.map} +1 -1
  62. package/dist/{impl-QR72P4GY.cjs → impl-H7O5YVYG.cjs} +3 -3
  63. package/dist/{impl-QR72P4GY.cjs.map → impl-H7O5YVYG.cjs.map} +1 -1
  64. package/dist/{impl-U5EBZCIQ.cjs → impl-IASTUGV6.cjs} +4 -4
  65. package/dist/{impl-U5EBZCIQ.cjs.map → impl-IASTUGV6.cjs.map} +1 -1
  66. package/dist/{impl-LRWZARHM.cjs → impl-IJTQXS6O.cjs} +2 -2
  67. package/dist/{impl-LRWZARHM.cjs.map → impl-IJTQXS6O.cjs.map} +1 -1
  68. package/dist/{impl-6H2SEINI.cjs → impl-JQTEIK2F.cjs} +2 -2
  69. package/dist/{impl-6H2SEINI.cjs.map → impl-JQTEIK2F.cjs.map} +1 -1
  70. package/dist/{impl-ABEIAAXG.cjs → impl-KULLM3ES.cjs} +5 -5
  71. package/dist/{impl-ABEIAAXG.cjs.map → impl-KULLM3ES.cjs.map} +1 -1
  72. package/dist/{impl-VQHQ7BUI.cjs → impl-N3T5JJN3.cjs} +2 -2
  73. package/dist/{impl-VQHQ7BUI.cjs.map → impl-N3T5JJN3.cjs.map} +1 -1
  74. package/dist/{impl-2FDYPU4D.cjs → impl-N7G3LUCY.cjs} +2 -2
  75. package/dist/{impl-2FDYPU4D.cjs.map → impl-N7G3LUCY.cjs.map} +1 -1
  76. package/dist/{impl-E2HT5BNA.cjs → impl-P4SXH5YA.cjs} +2 -2
  77. package/dist/{impl-E2HT5BNA.cjs.map → impl-P4SXH5YA.cjs.map} +1 -1
  78. package/dist/{impl-GXF6DOD3.cjs → impl-PPDM46JD.cjs} +2 -2
  79. package/dist/{impl-GXF6DOD3.cjs.map → impl-PPDM46JD.cjs.map} +1 -1
  80. package/dist/{impl-DN2UQJ3S.cjs → impl-Q3KJJPJO.cjs} +2 -2
  81. package/dist/{impl-DN2UQJ3S.cjs.map → impl-Q3KJJPJO.cjs.map} +1 -1
  82. package/dist/{impl-DUTLZXI4.cjs → impl-S5RVN46S.cjs} +5 -5
  83. package/dist/{impl-DUTLZXI4.cjs.map → impl-S5RVN46S.cjs.map} +1 -1
  84. package/dist/{impl-IFO7BHTL.cjs → impl-TDSXUSMZ.cjs} +2 -2
  85. package/dist/{impl-IFO7BHTL.cjs.map → impl-TDSXUSMZ.cjs.map} +1 -1
  86. package/dist/{impl-5MZPCJWM.cjs → impl-TP5ZB4AS.cjs} +2 -2
  87. package/dist/{impl-5MZPCJWM.cjs.map → impl-TP5ZB4AS.cjs.map} +1 -1
  88. package/dist/{impl-QS3G7FDW.cjs → impl-UANPW425.cjs} +2 -2
  89. package/dist/{impl-QS3G7FDW.cjs.map → impl-UANPW425.cjs.map} +1 -1
  90. package/dist/{impl-WP4DZVLN.cjs → impl-UOHFNQMH.cjs} +2 -2
  91. package/dist/{impl-WP4DZVLN.cjs.map → impl-UOHFNQMH.cjs.map} +1 -1
  92. package/dist/{impl-3VIMVUBA.cjs → impl-V5BNNVFJ.cjs} +2 -2
  93. package/dist/{impl-3VIMVUBA.cjs.map → impl-V5BNNVFJ.cjs.map} +1 -1
  94. package/dist/{impl-Q2YWAZ5V.cjs → impl-WDHTHO7S.cjs} +3 -3
  95. package/dist/{impl-Q2YWAZ5V.cjs.map → impl-WDHTHO7S.cjs.map} +1 -1
  96. package/dist/{impl-DOQM27FH.cjs → impl-WQY2NAQM.cjs} +2 -2
  97. package/dist/{impl-DOQM27FH.cjs.map → impl-WQY2NAQM.cjs.map} +1 -1
  98. package/dist/{impl-OKUMBOKA.cjs → impl-Y2QTEYJ5.cjs} +2 -2
  99. package/dist/{impl-OKUMBOKA.cjs.map → impl-Y2QTEYJ5.cjs.map} +1 -1
  100. package/dist/{impl-UVWK5LEC.cjs → impl-YENS4XKY.cjs} +2 -2
  101. package/dist/{impl-UVWK5LEC.cjs.map → impl-YENS4XKY.cjs.map} +1 -1
  102. package/dist/{impl-JDTKIRQY.cjs → impl-YLZABO2C.cjs} +2 -2
  103. package/dist/{impl-JDTKIRQY.cjs.map → impl-YLZABO2C.cjs.map} +1 -1
  104. package/dist/{impl-PF2UNMEM.cjs → impl-Z3VKOYUT.cjs} +2 -2
  105. package/dist/{impl-PF2UNMEM.cjs.map → impl-Z3VKOYUT.cjs.map} +1 -1
  106. package/dist/index.cjs +3 -3
  107. package/dist/index.cjs.map +1 -1
  108. package/dist/index.d.cts +53 -27
  109. package/package.json +1 -1
  110. package/dist/chunk-EMB64AC3.cjs +0 -2920
  111. package/dist/impl-KFCSSBYU.cjs +0 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/cli/cli/dist/impl-QR72P4GY.cjs","../src/commands/inventory/push/impl.ts"],"names":["syncConfiguration","transcendUrl","auth","pageSize","publishToPrivacyCenter","contents","deleteExtraAttributeValues","classifyService","client","buildTranscendGraphQLClient","syncConfigurationToTranscend","err","logger","colors"],"mappings":"AAAA,quBAAwC,wDAAyC,wDAAgD,gCAA6B,wDAAyC,wDAA0D,gCAA6B,wDAAyC,wDAAyC,gCAA6B,oCCGnX,wBACY,4BACjB,gFAEF,MAmBnB,SAAeA,CAAAA,CAAkB,CAC/B,YAAA,CAAAC,CAAAA,CACA,IAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CACA,sBAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CACA,0BAAA,CAAAC,CAAAA,CAA6B,CAAA,CAAA,CAC7B,eAAA,CAAAC,CAAAA,CAAkB,CAAA,CACpB,CAAA,CAeqB,CACnB,IAAMC,CAAAA,CAASC,kCAAAA,CAA4BR,CAAcC,CAAI,CAAA,CAG7D,GAAI,CAWF,MAAO,CAVkB,MAAMQ,kCAAAA,CAC7BL,CACAG,CAAAA,CACA,CACE,QAAA,CAAAL,CAAAA,CACA,sBAAA,CAAAC,CAAAA,CACA,eAAA,CAAAG,CAAAA,CACA,0BAAA,CAAAD,CACF,CACF,CAEF,CAAA,KAAA,CAASK,CAAAA,CAAK,CACZ,OAAAC,mBAAAA,CAAO,KAAA,CACLC,gBAAAA,CAAO,GAAA,CACL,CAAA,iDAAA,EAAoDF,CAAAA,CAAI,OAAO,CAAA,CAAA;AAsI7D;AAAgB;AAAA;AA8D1B,GAAA","file":"/home/runner/work/cli/cli/dist/impl-QR72P4GY.cjs","sourcesContent":[null,"import type { LocalContext } from '../../../context';\n\nimport { logger } from '../../../logger';\nimport { mapSeries } from 'bluebird';\nimport { existsSync, lstatSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { readTranscendYaml } from '../../../lib/readTranscendYaml';\nimport colors from 'colors';\nimport {\n buildTranscendGraphQLClient,\n syncConfigurationToTranscend,\n} from '../../../lib/graphql';\n\nimport { ADMIN_DASH_INTEGRATIONS } from '../../../constants';\nimport { TranscendInput } from '../../../codecs';\nimport { validateTranscendAuth, listFiles } from '../../../lib/api-keys';\nimport { mergeTranscendInputs } from '../../../lib/mergeTranscendInputs';\nimport { parseVariablesFromString } from '../../../lib/helpers/parseVariablesFromString';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation';\n\n/**\n * Sync configuration to Transcend\n *\n * @param options - Options\n * @returns True if synced successfully, false if error occurs\n */\nasync function syncConfiguration({\n transcendUrl,\n auth,\n pageSize,\n publishToPrivacyCenter,\n contents,\n deleteExtraAttributeValues = false,\n classifyService = false,\n}: {\n /** Transcend YAML */\n contents: TranscendInput;\n /** Transcend URL */\n transcendUrl: string;\n /** API key */\n auth: string;\n /** Page size */\n pageSize: number;\n /** Skip privacy center publish step */\n publishToPrivacyCenter: boolean;\n /** classify data flow service if missing */\n classifyService?: boolean;\n /** Delete attributes when syncing */\n deleteExtraAttributeValues?: boolean;\n}): Promise<boolean> {\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Sync to Transcend\n try {\n const encounteredError = await syncConfigurationToTranscend(\n contents,\n client,\n {\n pageSize,\n publishToPrivacyCenter,\n classifyService,\n deleteExtraAttributeValues,\n },\n );\n return !encounteredError;\n } catch (err) {\n logger.error(\n colors.red(\n `An unexpected error occurred syncing the schema: ${err.message}`,\n ),\n );\n return false;\n }\n}\n\nexport interface PushCommandFlags {\n auth: string;\n file: string;\n transcendUrl: string;\n pageSize: number;\n variables: string;\n publishToPrivacyCenter: boolean;\n classifyService: boolean;\n deleteExtraAttributeValues: boolean;\n}\n\nexport async function push(\n this: LocalContext,\n {\n file = './transcend.yml',\n transcendUrl,\n auth,\n variables,\n pageSize,\n publishToPrivacyCenter,\n classifyService,\n deleteExtraAttributeValues,\n }: PushCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n // Parse authentication as API key or path to list of API keys\n const apiKeyOrList = await validateTranscendAuth(auth);\n\n // Parse out the variables\n const vars = parseVariablesFromString(variables);\n\n // check if we are being passed a list of API keys and a list of files\n let fileList: string[];\n if (Array.isArray(apiKeyOrList) && lstatSync(file).isDirectory()) {\n fileList = listFiles(file).map((filePath) => join(file, filePath));\n } else {\n fileList = file.split(',');\n }\n\n // Ensure at least one file is parsed\n if (fileList.length < 1) {\n throw new Error('No file specified!');\n }\n\n // eslint-disable-next-line array-callback-return,consistent-return\n const transcendInputs = fileList.map((filePath) => {\n // Ensure yaml file exists on disk\n if (!existsSync(filePath)) {\n logger.error(\n colors.red(\n `The file path does not exist on disk: ${filePath}. You can specify the filepath using --file=./examples/transcend.yml`,\n ),\n );\n this.process.exit(1);\n } else {\n logger.info(colors.magenta(`Reading file \"${filePath}\"...`));\n }\n\n try {\n // Read in the yaml file and validate it's shape\n const newContents = readTranscendYaml(filePath, vars);\n logger.info(colors.green(`Successfully read in \"${filePath}\"`));\n return {\n content: newContents,\n name: filePath.split('/').pop()!.replace('.yml', ''),\n };\n } catch (err) {\n logger.error(\n colors.red(\n `The shape of your yaml file is invalid with the following errors: ${err.message}`,\n ),\n );\n this.process.exit(1);\n }\n });\n\n // process a single API key\n if (typeof apiKeyOrList === 'string') {\n // if passed multiple inputs, merge them together\n const [base, ...rest] = transcendInputs.map(({ content }) => content);\n const contents = mergeTranscendInputs(base, ...rest);\n\n // sync the configuration\n const success = await syncConfiguration({\n transcendUrl,\n auth: apiKeyOrList,\n contents,\n publishToPrivacyCenter,\n deleteExtraAttributeValues,\n pageSize,\n classifyService: !!classifyService,\n });\n\n // exist with error code\n if (!success) {\n logger.info(\n colors.red(\n `Sync encountered errors. View output above for more information, or check out ${ADMIN_DASH_INTEGRATIONS}`,\n ),\n );\n\n this.process.exit(1);\n }\n } else {\n // if passed multiple inputs, expect them to be one per instance\n if (\n transcendInputs.length !== 1 &&\n transcendInputs.length !== apiKeyOrList.length\n ) {\n throw new Error(\n 'Expected list of yml files to be equal to the list of API keys.' +\n `Got ${transcendInputs.length} YML file${\n transcendInputs.length === 1 ? '' : 's'\n } and ${apiKeyOrList.length} API key${\n apiKeyOrList.length === 1 ? '' : 's'\n }`,\n );\n }\n\n const encounteredErrors: string[] = [];\n await mapSeries(apiKeyOrList, async (apiKey, ind) => {\n const prefix = `[${ind + 1}/${apiKeyOrList.length}][${\n apiKey.organizationName\n }] `;\n logger.info(\n colors.magenta(\n `~~~\\n\\n${prefix}Attempting to push configuration...\\n\\n~~~`,\n ),\n );\n\n // use the merged contents if 1 yml passed, else use the contents that map to that organization\n const useContents =\n transcendInputs.length === 1\n ? transcendInputs[0].content\n : transcendInputs.find(\n (input) => input.name === apiKey.organizationName,\n )?.content;\n\n // Throw error if cannot find a yml file matching that organization name\n if (!useContents) {\n logger.error(\n colors.red(\n `${prefix}Failed to find transcend.yml file for organization: \"${apiKey.organizationName}\".`,\n ),\n );\n encounteredErrors.push(apiKey.organizationName);\n return;\n }\n\n const success = await syncConfiguration({\n transcendUrl,\n auth: apiKey.apiKey,\n contents: useContents,\n pageSize,\n publishToPrivacyCenter,\n deleteExtraAttributeValues,\n classifyService,\n });\n\n if (success) {\n logger.info(\n colors.green(`${prefix}Successfully pushed configuration!`),\n );\n } else {\n logger.error(colors.red(`${prefix}Failed to sync configuration.`));\n encounteredErrors.push(apiKey.organizationName);\n }\n });\n\n if (encounteredErrors.length > 0) {\n logger.info(\n colors.red(\n `Sync encountered errors for \"${encounteredErrors.join(\n ',',\n )}\". View output above for more information, or check out ${ADMIN_DASH_INTEGRATIONS}`,\n ),\n );\n\n this.process.exit(1);\n }\n }\n\n // Indicate success\n logger.info(\n colors.green(\n `Successfully synced yaml file to Transcend! View at ${ADMIN_DASH_INTEGRATIONS}`,\n ),\n );\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/cli/cli/dist/impl-H7O5YVYG.cjs","../src/commands/inventory/push/impl.ts"],"names":["syncConfiguration","transcendUrl","auth","pageSize","publishToPrivacyCenter","contents","deleteExtraAttributeValues","classifyService","client","buildTranscendGraphQLClient","syncConfigurationToTranscend","err","logger","colors"],"mappings":"AAAA,quBAAwC,wDAAyC,wDAAgD,gCAA6B,wDAAyC,wDAA0D,gCAA6B,wDAAyC,wDAAyC,gCAA6B,oCCGnX,wBACY,4BACjB,gFAEF,MAmBnB,SAAeA,CAAAA,CAAkB,CAC/B,YAAA,CAAAC,CAAAA,CACA,IAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CACA,sBAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CACA,0BAAA,CAAAC,CAAAA,CAA6B,CAAA,CAAA,CAC7B,eAAA,CAAAC,CAAAA,CAAkB,CAAA,CACpB,CAAA,CAeqB,CACnB,IAAMC,CAAAA,CAASC,kCAAAA,CAA4BR,CAAcC,CAAI,CAAA,CAG7D,GAAI,CAWF,MAAO,CAVkB,MAAMQ,kCAAAA,CAC7BL,CACAG,CAAAA,CACA,CACE,QAAA,CAAAL,CAAAA,CACA,sBAAA,CAAAC,CAAAA,CACA,eAAA,CAAAG,CAAAA,CACA,0BAAA,CAAAD,CACF,CACF,CAEF,CAAA,KAAA,CAASK,CAAAA,CAAK,CACZ,OAAAC,mBAAAA,CAAO,KAAA,CACLC,gBAAAA,CAAO,GAAA,CACL,CAAA,iDAAA,EAAoDF,CAAAA,CAAI,OAAO,CAAA,CAAA;AAsI7D;AAAgB;AAAA;AA8D1B,GAAA","file":"/home/runner/work/cli/cli/dist/impl-H7O5YVYG.cjs","sourcesContent":[null,"import type { LocalContext } from '../../../context';\n\nimport { logger } from '../../../logger';\nimport { mapSeries } from 'bluebird';\nimport { existsSync, lstatSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { readTranscendYaml } from '../../../lib/readTranscendYaml';\nimport colors from 'colors';\nimport {\n buildTranscendGraphQLClient,\n syncConfigurationToTranscend,\n} from '../../../lib/graphql';\n\nimport { ADMIN_DASH_INTEGRATIONS } from '../../../constants';\nimport { TranscendInput } from '../../../codecs';\nimport { validateTranscendAuth, listFiles } from '../../../lib/api-keys';\nimport { mergeTranscendInputs } from '../../../lib/mergeTranscendInputs';\nimport { parseVariablesFromString } from '../../../lib/helpers/parseVariablesFromString';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation';\n\n/**\n * Sync configuration to Transcend\n *\n * @param options - Options\n * @returns True if synced successfully, false if error occurs\n */\nasync function syncConfiguration({\n transcendUrl,\n auth,\n pageSize,\n publishToPrivacyCenter,\n contents,\n deleteExtraAttributeValues = false,\n classifyService = false,\n}: {\n /** Transcend YAML */\n contents: TranscendInput;\n /** Transcend URL */\n transcendUrl: string;\n /** API key */\n auth: string;\n /** Page size */\n pageSize: number;\n /** Skip privacy center publish step */\n publishToPrivacyCenter: boolean;\n /** classify data flow service if missing */\n classifyService?: boolean;\n /** Delete attributes when syncing */\n deleteExtraAttributeValues?: boolean;\n}): Promise<boolean> {\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Sync to Transcend\n try {\n const encounteredError = await syncConfigurationToTranscend(\n contents,\n client,\n {\n pageSize,\n publishToPrivacyCenter,\n classifyService,\n deleteExtraAttributeValues,\n },\n );\n return !encounteredError;\n } catch (err) {\n logger.error(\n colors.red(\n `An unexpected error occurred syncing the schema: ${err.message}`,\n ),\n );\n return false;\n }\n}\n\nexport interface PushCommandFlags {\n auth: string;\n file: string;\n transcendUrl: string;\n pageSize: number;\n variables: string;\n publishToPrivacyCenter: boolean;\n classifyService: boolean;\n deleteExtraAttributeValues: boolean;\n}\n\nexport async function push(\n this: LocalContext,\n {\n file = './transcend.yml',\n transcendUrl,\n auth,\n variables,\n pageSize,\n publishToPrivacyCenter,\n classifyService,\n deleteExtraAttributeValues,\n }: PushCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n // Parse authentication as API key or path to list of API keys\n const apiKeyOrList = await validateTranscendAuth(auth);\n\n // Parse out the variables\n const vars = parseVariablesFromString(variables);\n\n // check if we are being passed a list of API keys and a list of files\n let fileList: string[];\n if (Array.isArray(apiKeyOrList) && lstatSync(file).isDirectory()) {\n fileList = listFiles(file).map((filePath) => join(file, filePath));\n } else {\n fileList = file.split(',');\n }\n\n // Ensure at least one file is parsed\n if (fileList.length < 1) {\n throw new Error('No file specified!');\n }\n\n // eslint-disable-next-line array-callback-return,consistent-return\n const transcendInputs = fileList.map((filePath) => {\n // Ensure yaml file exists on disk\n if (!existsSync(filePath)) {\n logger.error(\n colors.red(\n `The file path does not exist on disk: ${filePath}. You can specify the filepath using --file=./examples/transcend.yml`,\n ),\n );\n this.process.exit(1);\n } else {\n logger.info(colors.magenta(`Reading file \"${filePath}\"...`));\n }\n\n try {\n // Read in the yaml file and validate it's shape\n const newContents = readTranscendYaml(filePath, vars);\n logger.info(colors.green(`Successfully read in \"${filePath}\"`));\n return {\n content: newContents,\n name: filePath.split('/').pop()!.replace('.yml', ''),\n };\n } catch (err) {\n logger.error(\n colors.red(\n `The shape of your yaml file is invalid with the following errors: ${err.message}`,\n ),\n );\n this.process.exit(1);\n }\n });\n\n // process a single API key\n if (typeof apiKeyOrList === 'string') {\n // if passed multiple inputs, merge them together\n const [base, ...rest] = transcendInputs.map(({ content }) => content);\n const contents = mergeTranscendInputs(base, ...rest);\n\n // sync the configuration\n const success = await syncConfiguration({\n transcendUrl,\n auth: apiKeyOrList,\n contents,\n publishToPrivacyCenter,\n deleteExtraAttributeValues,\n pageSize,\n classifyService: !!classifyService,\n });\n\n // exist with error code\n if (!success) {\n logger.info(\n colors.red(\n `Sync encountered errors. View output above for more information, or check out ${ADMIN_DASH_INTEGRATIONS}`,\n ),\n );\n\n this.process.exit(1);\n }\n } else {\n // if passed multiple inputs, expect them to be one per instance\n if (\n transcendInputs.length !== 1 &&\n transcendInputs.length !== apiKeyOrList.length\n ) {\n throw new Error(\n 'Expected list of yml files to be equal to the list of API keys.' +\n `Got ${transcendInputs.length} YML file${\n transcendInputs.length === 1 ? '' : 's'\n } and ${apiKeyOrList.length} API key${\n apiKeyOrList.length === 1 ? '' : 's'\n }`,\n );\n }\n\n const encounteredErrors: string[] = [];\n await mapSeries(apiKeyOrList, async (apiKey, ind) => {\n const prefix = `[${ind + 1}/${apiKeyOrList.length}][${\n apiKey.organizationName\n }] `;\n logger.info(\n colors.magenta(\n `~~~\\n\\n${prefix}Attempting to push configuration...\\n\\n~~~`,\n ),\n );\n\n // use the merged contents if 1 yml passed, else use the contents that map to that organization\n const useContents =\n transcendInputs.length === 1\n ? transcendInputs[0].content\n : transcendInputs.find(\n (input) => input.name === apiKey.organizationName,\n )?.content;\n\n // Throw error if cannot find a yml file matching that organization name\n if (!useContents) {\n logger.error(\n colors.red(\n `${prefix}Failed to find transcend.yml file for organization: \"${apiKey.organizationName}\".`,\n ),\n );\n encounteredErrors.push(apiKey.organizationName);\n return;\n }\n\n const success = await syncConfiguration({\n transcendUrl,\n auth: apiKey.apiKey,\n contents: useContents,\n pageSize,\n publishToPrivacyCenter,\n deleteExtraAttributeValues,\n classifyService,\n });\n\n if (success) {\n logger.info(\n colors.green(`${prefix}Successfully pushed configuration!`),\n );\n } else {\n logger.error(colors.red(`${prefix}Failed to sync configuration.`));\n encounteredErrors.push(apiKey.organizationName);\n }\n });\n\n if (encounteredErrors.length > 0) {\n logger.info(\n colors.red(\n `Sync encountered errors for \"${encounteredErrors.join(\n ',',\n )}\". View output above for more information, or check out ${ADMIN_DASH_INTEGRATIONS}`,\n ),\n );\n\n this.process.exit(1);\n }\n }\n\n // Indicate success\n logger.info(\n colors.green(\n `Successfully synced yaml file to Transcend! View at ${ADMIN_DASH_INTEGRATIONS}`,\n ),\n );\n}\n"]}
@@ -1,7 +1,7 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkWKCTKYN4cjs = require('./chunk-WKCTKYN4.cjs');var _chunkEMB64AC3cjs = require('./chunk-EMB64AC3.cjs');require('./chunk-LCDYXJN6.cjs');var _chunkZUNVPK23cjs = require('./chunk-ZUNVPK23.cjs');var _chunk4U57O4PScjs = require('./chunk-4U57O4PS.cjs');var _chunkQ7I37FJVcjs = require('./chunk-Q7I37FJV.cjs');var _colors = require('colors'); var _colors2 = _interopRequireDefault(_colors);var _got = require('got'); var _got2 = _interopRequireDefault(_got);var j=({hostname:t,auth:e})=>_got2.default.extend({prefixUrl:`https://${t}`,headers:{accept:"application/json","content-type":"application/json",authorization:`Bearer ${e}`}});var _yargsparser = require('yargs-parser'); var _yargsparser2 = _interopRequireDefault(_yargsparser);var ve=Object.values(_chunkQ7I37FJVcjs.b);var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);var R=({assessment:t,index:e,total:s,wrap:r=!0})=>{let n="";(e===0||r)&&(n=`[
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkWKCTKYN4cjs = require('./chunk-WKCTKYN4.cjs');var _chunkJEH3FW7Jcjs = require('./chunk-JEH3FW7J.cjs');require('./chunk-LCDYXJN6.cjs');var _chunkZUNVPK23cjs = require('./chunk-ZUNVPK23.cjs');var _chunkOFZ7ZSEVcjs = require('./chunk-OFZ7ZSEV.cjs');var _chunkQ7I37FJVcjs = require('./chunk-Q7I37FJV.cjs');var _colors = require('colors'); var _colors2 = _interopRequireDefault(_colors);var _got = require('got'); var _got2 = _interopRequireDefault(_got);var j=({hostname:t,auth:e})=>_got2.default.extend({prefixUrl:`https://${t}`,headers:{accept:"application/json","content-type":"application/json",authorization:`Bearer ${e}`}});var _yargsparser = require('yargs-parser'); var _yargsparser2 = _interopRequireDefault(_yargsparser);var ve=Object.values(_chunkQ7I37FJVcjs.b);var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);var R=({assessment:t,index:e,total:s,wrap:r=!0})=>{let n="";(e===0||r)&&(n=`[
2
2
  `);let m=JSON.stringify(t),o=s&&e<s-1&&!r?",":"";return n=`${n+m+o}
3
3
  `,(s&&e===s-1||r)&&(n+=`
4
- ]`),n};var q=({file:t,assessment:e,index:s,total:r})=>{_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Writing enriched assessment ${s+1} of ${r} to file "${t}"...`)),s===0?_fs2.default.writeFileSync(t,R({assessment:e,index:s,total:r,wrap:!1})):_fs2.default.appendFileSync(t,R({assessment:e,index:s,total:r,wrap:!1}))};var _typeutils = require('@transcend-io/type-utils');var _privacytypes = require('@transcend-io/privacy-types');var J=async({oneTrust:t})=>{let e=0,s=1,r=0,n=[];for(;e<s;){let{body:m}=await t.get(`api/assessment/v2/assessments?page=${e}&size=2000`),{page:o,content:u}=_typeutils.decodeCodec.call(void 0, _privacytypes.OneTrustGetListOfAssessmentsResponse,m);n.push(..._nullishCoalesce(u, () => ([]))),e===0&&(s=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _2 => _2.totalPages]), () => (0)),r=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _3 => _3.totalElements]), () => (0))),e+=1,_chunkZUNVPK23cjs.a.info(`Fetched ${n.length} of ${r} assessments.`)}return n};var K=async({oneTrust:t,assessmentId:e})=>{let{body:s}=await t.get(`api/assessment/v2/assessments/${e}/export?ExcludeSkippedQuestions=false`);return _typeutils.decodeCodec.call(void 0, _privacytypes.OneTrustGetAssessmentResponse,s)};var W=async({oneTrust:t,riskId:e})=>{let{body:s}=await t.get(`api/risk/v2/risks/${e}`);return _typeutils.decodeCodec.call(void 0, _privacytypes.OneTrustGetRiskResponse,s)};var b=async({oneTrust:t,userId:e})=>{let{body:s}=await t.get(`api/scim/v2/Users/${e}`);return _typeutils.decodeCodec.call(void 0, _privacytypes.OneTrustGetUserResponse,s)};var _bluebird = require('bluebird');var H=({assessment:t,assessmentDetails:e,riskDetails:s,creatorDetails:r,approversDetails:n,respondentsDetails:m})=>{let o=_chunk4U57O4PScjs.e.call(void 0, s,"id"),{sections:u,createdBy:h,...g}=e,O=u.map(i=>{let{questions:A,...$}=i,w=A.map(x=>{let{risks:U,...E}=x,G=(_nullishCoalesce(U, () => ([]))).map(y=>{let v=o[y.riskId];return{...y,...v,level:y.level,impactLevel:_nullishCoalesce(y.impactLevel, () => (0))}});return{...E,risks:G}});return{...$,questions:w}}),p={...h,active:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _4 => _4.active]), () => (!1)),userType:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _5 => _5.userType]), () => ("Internal")),emails:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _6 => _6.emails]), () => ([])),title:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _7 => _7.title]), () => (null)),givenName:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _8 => _8.name, 'access', _9 => _9.givenName]), () => (null)),familyName:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _10 => _10.name, 'access', _11 => _11.familyName]), () => (null))},d=_chunk4U57O4PScjs.e.call(void 0, n,"id"),l=e.approvers.flatMap(i=>d[i.id]?[{...i,approver:{...i.approver,active:d[i.id].active,userType:d[i.id].userType,emails:d[i.id].emails,title:d[i.id].title,givenName:_nullishCoalesce(d[i.id].name.givenName, () => (null)),familyName:_nullishCoalesce(d[i.id].name.familyName, () => (null))}}]:[]),T=_chunk4U57O4PScjs.e.call(void 0, m,"id"),C=e.respondents.filter(i=>!i.name.includes("@")).flatMap(i=>T[i.id]?[{...i,active:T[i.id].active,userType:T[i.id].userType,emails:T[i.id].emails,title:T[i.id].title,givenName:_nullishCoalesce(T[i.id].name.givenName, () => (null)),familyName:_nullishCoalesce(T[i.id].name.familyName, () => (null))}]:[]);return{...t,...g,approvers:l,respondents:C,createdBy:p,sections:O}};var k=async({transcend:t,assessment:e,total:s,index:r})=>{_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Writing enriched assessment ${r+1} ${s?`of ${s} `:" "}to Transcend...`));let m={json:R({assessment:e,index:r,total:s})};try{await _chunkEMB64AC3cjs.Xf.call(void 0, t,_chunkEMB64AC3cjs.fa,{input:m})}catch (e2){_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Failed to sync assessment ${r+1} ${s?`of ${s} `:" "}to Transcend.
4
+ ]`),n};var q=({file:t,assessment:e,index:s,total:r})=>{_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Writing enriched assessment ${s+1} of ${r} to file "${t}"...`)),s===0?_fs2.default.writeFileSync(t,R({assessment:e,index:s,total:r,wrap:!1})):_fs2.default.appendFileSync(t,R({assessment:e,index:s,total:r,wrap:!1}))};var _typeutils = require('@transcend-io/type-utils');var _privacytypes = require('@transcend-io/privacy-types');var J=async({oneTrust:t})=>{let e=0,s=1,r=0,n=[];for(;e<s;){let{body:m}=await t.get(`api/assessment/v2/assessments?page=${e}&size=2000`),{page:o,content:u}=_typeutils.decodeCodec.call(void 0, _privacytypes.OneTrustGetListOfAssessmentsResponse,m);n.push(..._nullishCoalesce(u, () => ([]))),e===0&&(s=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _2 => _2.totalPages]), () => (0)),r=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _3 => _3.totalElements]), () => (0))),e+=1,_chunkZUNVPK23cjs.a.info(`Fetched ${n.length} of ${r} assessments.`)}return n};var K=async({oneTrust:t,assessmentId:e})=>{let{body:s}=await t.get(`api/assessment/v2/assessments/${e}/export?ExcludeSkippedQuestions=false`);return _typeutils.decodeCodec.call(void 0, _privacytypes.OneTrustGetAssessmentResponse,s)};var W=async({oneTrust:t,riskId:e})=>{let{body:s}=await t.get(`api/risk/v2/risks/${e}`);return _typeutils.decodeCodec.call(void 0, _privacytypes.OneTrustGetRiskResponse,s)};var b=async({oneTrust:t,userId:e})=>{let{body:s}=await t.get(`api/scim/v2/Users/${e}`);return _typeutils.decodeCodec.call(void 0, _privacytypes.OneTrustGetUserResponse,s)};var _bluebird = require('bluebird');var H=({assessment:t,assessmentDetails:e,riskDetails:s,creatorDetails:r,approversDetails:n,respondentsDetails:m})=>{let o=_chunkOFZ7ZSEVcjs.e.call(void 0, s,"id"),{sections:u,createdBy:h,...g}=e,O=u.map(i=>{let{questions:A,...$}=i,w=A.map(x=>{let{risks:U,...E}=x,G=(_nullishCoalesce(U, () => ([]))).map(y=>{let v=o[y.riskId];return{...y,...v,level:y.level,impactLevel:_nullishCoalesce(y.impactLevel, () => (0))}});return{...E,risks:G}});return{...$,questions:w}}),p={...h,active:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _4 => _4.active]), () => (!1)),userType:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _5 => _5.userType]), () => ("Internal")),emails:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _6 => _6.emails]), () => ([])),title:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _7 => _7.title]), () => (null)),givenName:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _8 => _8.name, 'access', _9 => _9.givenName]), () => (null)),familyName:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _10 => _10.name, 'access', _11 => _11.familyName]), () => (null))},d=_chunkOFZ7ZSEVcjs.e.call(void 0, n,"id"),l=e.approvers.flatMap(i=>d[i.id]?[{...i,approver:{...i.approver,active:d[i.id].active,userType:d[i.id].userType,emails:d[i.id].emails,title:d[i.id].title,givenName:_nullishCoalesce(d[i.id].name.givenName, () => (null)),familyName:_nullishCoalesce(d[i.id].name.familyName, () => (null))}}]:[]),T=_chunkOFZ7ZSEVcjs.e.call(void 0, m,"id"),C=e.respondents.filter(i=>!i.name.includes("@")).flatMap(i=>T[i.id]?[{...i,active:T[i.id].active,userType:T[i.id].userType,emails:T[i.id].emails,title:T[i.id].title,givenName:_nullishCoalesce(T[i.id].name.givenName, () => (null)),familyName:_nullishCoalesce(T[i.id].name.familyName, () => (null))}]:[]);return{...t,...g,approvers:l,respondents:C,createdBy:p,sections:O}};var k=async({transcend:t,assessment:e,total:s,index:r})=>{_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Writing enriched assessment ${r+1} ${s?`of ${s} `:" "}to Transcend...`));let m={json:R({assessment:e,index:r,total:s})};try{await _chunkJEH3FW7Jcjs._f.call(void 0, t,_chunkJEH3FW7Jcjs.fa,{input:m})}catch (e2){_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Failed to sync assessment ${r+1} ${s?`of ${s} `:" "}to Transcend.
5
5
  Assessment Title: ${e.name}. Template Title: ${e.template.name}
6
- `))}};var Y=async({oneTrust:t,file:e,dryRun:s,transcend:r})=>{_chunkZUNVPK23cjs.a.info("Getting list of all assessments from OneTrust...");let n=await J({oneTrust:t}),m={},o=5,u=Array.from({length:Math.ceil(n.length/o)},(h,g)=>n.slice(g*o,(g+1)*o));await _bluebird.mapSeries.call(void 0, u,async(h,g)=>{let O=[];await _bluebird.map.call(void 0, h,async(p,d)=>{let l=o*g+d+1;_chunkZUNVPK23cjs.a.info(`[assessment ${l} of ${n.length}]: fetching details...`);let{templateName:T,assessmentId:C}=p,i=await K({oneTrust:t,assessmentId:C}),A=i.createdBy.id,$=m[A];if(!$){_chunkZUNVPK23cjs.a.info(`[assessment ${l} of ${n.length}]: fetching creator...`);try{$=await b({oneTrust:t,userId:A}),m[A]=$}catch (e3){_chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(`[assessment ${l} of ${n.length}]: failed to fetch form creator. creatorId: ${A}. Assessment Title: ${p.name}. Template Title: ${T}`))}}let{approvers:w}=i,x=[];w.length>0&&(_chunkZUNVPK23cjs.a.info(`[assessment ${l} of ${n.length}]: fetching approvers...`),x=await _bluebird.map.call(void 0, w.map(({id:c})=>c),async c=>{try{let f=m[c];return f||(f=await b({oneTrust:t,userId:c}),m[c]=f),[f]}catch (e4){return _chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(`[assessment ${l} of ${n.length}]: failed to fetch a form approver. approverId: ${c}. Assessment Title: ${p.name}. Template Title: ${T}`)),[]}},{concurrency:5}));let{respondents:U}=i,E=U.filter(c=>!c.name.includes("@")),G=[];E.length>0&&(_chunkZUNVPK23cjs.a.info(`[assessment ${l} of ${n.length}]: fetching respondents...`),G=await _bluebird.map.call(void 0, E.map(({id:c})=>c),async c=>{try{let f=m[c];return f||(f=await b({oneTrust:t,userId:c}),m[c]=f),[f]}catch (e5){return _chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(`[assessment ${l} of ${n.length}]: failed to fetch a respondent. respondentId: ${c}. Assessment Title: ${p.name}. Template Title: ${T}`)),[]}},{concurrency:5}));let y=[],v=_chunk4U57O4PScjs.j.call(void 0, i.sections.flatMap(c=>c.questions.flatMap(f=>(_nullishCoalesce(f.risks, () => ([]))).flatMap(ee=>ee.riskId))));v.length>0&&(_chunkZUNVPK23cjs.a.info(`[assessment ${l} of ${n.length}]: fetching risks...`),y=await _bluebird.map.call(void 0, v,c=>W({oneTrust:t,riskId:c}),{concurrency:5}));let X=H({assessment:p,assessmentDetails:i,riskDetails:y,creatorDetails:$,approversDetails:x.flat(),respondentsDetails:G.flat()});O.push(X)},{concurrency:o}),await _bluebird.mapSeries.call(void 0, O,async(p,d)=>{let l=g*o+d;s&&e?q({assessment:p,index:l,total:n.length,file:e}):r&&await k({assessment:p,transcend:r,total:n.length,index:l})})})};var _JSONStream = require('JSONStream'); var _JSONStream2 = _interopRequireDefault(_JSONStream);var Z=({transcend:t,file:e})=>(_chunkZUNVPK23cjs.a.info(`Getting list of all assessments from file ${e}...`),new Promise((s,r)=>{let n=_fs.createReadStream.call(void 0, e,{encoding:"utf-8",highWaterMark:65536}),m=_JSONStream2.default.parse("*"),o=0;n.pipe(m),m.on("data",async u=>{try{m.pause();let h=_typeutils.decodeCodec.call(void 0, _privacytypes.OneTrustEnrichedAssessment,u);await k({assessment:h,transcend:t,index:o}),o+=1,m.resume()}catch(h){_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Failed to parse the assessment ${o} from file '${e}': ${h.message}.`))}}),m.on("end",()=>{_chunkZUNVPK23cjs.a.info(`Finished processing ${o} assessments from file ${e}`),s()}),m.on("error",u=>{_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Error parsing file '${e}': ${u.message}`)),r(u)}),n.on("error",u=>{_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Error reading file '${e}': ${u.message}`)),r(u)})}));async function Ds({hostname:t,oneTrustAuth:e,source:s,transcendAuth:r,transcendUrl:n,resource:m,file:o,dryRun:u,debug:h}){if(!u&&!r)throw new Error('Must specify a "transcendAuth" parameter to sync resources to Transcend. e.g. --transcendAuth=${TRANSCEND_API_KEY}');if(u&&!o)throw new Error('Must set a "file" parameter when "dryRun" is "true". e.g. --file=./oneTrustAssessments.json');if(o){let p=o.split(".");if(p.length<2)throw new Error('The "file" parameter has an invalid format. Expected a path with extensions. e.g. --file=./pathToFile.json.');if(p.at(-1)!=="json")throw new Error(`Expected the format of the "file" parameters '${o}' to be 'json', but got '${p.at(-1)}'.`)}if(s==="oneTrust"){if(!t)throw new Error('Missing required parameter "hostname". e.g. --hostname=customer.my.onetrust.com');if(!e)throw new Error('Missing required parameter "oneTrustAuth". e.g. --oneTrustAuth=$ONE_TRUST_AUTH_TOKEN')}else{if(!o)throw new Error('Must specify a "file" parameter to read the OneTrust assessments from. e.g. --source=./oneTrustAssessments.json');if(u)throw new Error('Cannot read and write to a file simultaneously. Emit the "source" parameter or set it to oneTrust if "dryRun" is enabled.')}_chunkWKCTKYN4cjs.a.call(void 0, this.process.exit);let g=t&&e?j({hostname:t,auth:e}):void 0,O=n&&r?_chunkEMB64AC3cjs.vc.call(void 0, n,r):void 0;try{m==="assessments"&&(s==="oneTrust"&&g?await Y({oneTrust:g,file:o,dryRun:u,...O&&{transcend:O}}):s==="file"&&o&&O&&await Z({file:o,transcend:O}))}catch(p){throw new Error(`An error occurred syncing the resource ${m} from OneTrust: ${h?p.stack:p.message}`)}_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully synced OneTrust ${m} to ${u?`disk at "${o}"`:"Transcend"}!`))}exports.syncOt = Ds;
7
- //# sourceMappingURL=impl-U5EBZCIQ.cjs.map
6
+ `))}};var Y=async({oneTrust:t,file:e,dryRun:s,transcend:r})=>{_chunkZUNVPK23cjs.a.info("Getting list of all assessments from OneTrust...");let n=await J({oneTrust:t}),m={},o=5,u=Array.from({length:Math.ceil(n.length/o)},(h,g)=>n.slice(g*o,(g+1)*o));await _bluebird.mapSeries.call(void 0, u,async(h,g)=>{let O=[];await _bluebird.map.call(void 0, h,async(p,d)=>{let l=o*g+d+1;_chunkZUNVPK23cjs.a.info(`[assessment ${l} of ${n.length}]: fetching details...`);let{templateName:T,assessmentId:C}=p,i=await K({oneTrust:t,assessmentId:C}),A=i.createdBy.id,$=m[A];if(!$){_chunkZUNVPK23cjs.a.info(`[assessment ${l} of ${n.length}]: fetching creator...`);try{$=await b({oneTrust:t,userId:A}),m[A]=$}catch (e3){_chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(`[assessment ${l} of ${n.length}]: failed to fetch form creator. creatorId: ${A}. Assessment Title: ${p.name}. Template Title: ${T}`))}}let{approvers:w}=i,x=[];w.length>0&&(_chunkZUNVPK23cjs.a.info(`[assessment ${l} of ${n.length}]: fetching approvers...`),x=await _bluebird.map.call(void 0, w.map(({id:c})=>c),async c=>{try{let f=m[c];return f||(f=await b({oneTrust:t,userId:c}),m[c]=f),[f]}catch (e4){return _chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(`[assessment ${l} of ${n.length}]: failed to fetch a form approver. approverId: ${c}. Assessment Title: ${p.name}. Template Title: ${T}`)),[]}},{concurrency:5}));let{respondents:U}=i,E=U.filter(c=>!c.name.includes("@")),G=[];E.length>0&&(_chunkZUNVPK23cjs.a.info(`[assessment ${l} of ${n.length}]: fetching respondents...`),G=await _bluebird.map.call(void 0, E.map(({id:c})=>c),async c=>{try{let f=m[c];return f||(f=await b({oneTrust:t,userId:c}),m[c]=f),[f]}catch (e5){return _chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(`[assessment ${l} of ${n.length}]: failed to fetch a respondent. respondentId: ${c}. Assessment Title: ${p.name}. Template Title: ${T}`)),[]}},{concurrency:5}));let y=[],v=_chunkOFZ7ZSEVcjs.j.call(void 0, i.sections.flatMap(c=>c.questions.flatMap(f=>(_nullishCoalesce(f.risks, () => ([]))).flatMap(ee=>ee.riskId))));v.length>0&&(_chunkZUNVPK23cjs.a.info(`[assessment ${l} of ${n.length}]: fetching risks...`),y=await _bluebird.map.call(void 0, v,c=>W({oneTrust:t,riskId:c}),{concurrency:5}));let X=H({assessment:p,assessmentDetails:i,riskDetails:y,creatorDetails:$,approversDetails:x.flat(),respondentsDetails:G.flat()});O.push(X)},{concurrency:o}),await _bluebird.mapSeries.call(void 0, O,async(p,d)=>{let l=g*o+d;s&&e?q({assessment:p,index:l,total:n.length,file:e}):r&&await k({assessment:p,transcend:r,total:n.length,index:l})})})};var _JSONStream = require('JSONStream'); var _JSONStream2 = _interopRequireDefault(_JSONStream);var Z=({transcend:t,file:e})=>(_chunkZUNVPK23cjs.a.info(`Getting list of all assessments from file ${e}...`),new Promise((s,r)=>{let n=_fs.createReadStream.call(void 0, e,{encoding:"utf-8",highWaterMark:65536}),m=_JSONStream2.default.parse("*"),o=0;n.pipe(m),m.on("data",async u=>{try{m.pause();let h=_typeutils.decodeCodec.call(void 0, _privacytypes.OneTrustEnrichedAssessment,u);await k({assessment:h,transcend:t,index:o}),o+=1,m.resume()}catch(h){_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Failed to parse the assessment ${o} from file '${e}': ${h.message}.`))}}),m.on("end",()=>{_chunkZUNVPK23cjs.a.info(`Finished processing ${o} assessments from file ${e}`),s()}),m.on("error",u=>{_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Error parsing file '${e}': ${u.message}`)),r(u)}),n.on("error",u=>{_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Error reading file '${e}': ${u.message}`)),r(u)})}));async function Ds({hostname:t,oneTrustAuth:e,source:s,transcendAuth:r,transcendUrl:n,resource:m,file:o,dryRun:u,debug:h}){if(!u&&!r)throw new Error('Must specify a "transcendAuth" parameter to sync resources to Transcend. e.g. --transcendAuth=${TRANSCEND_API_KEY}');if(u&&!o)throw new Error('Must set a "file" parameter when "dryRun" is "true". e.g. --file=./oneTrustAssessments.json');if(o){let p=o.split(".");if(p.length<2)throw new Error('The "file" parameter has an invalid format. Expected a path with extensions. e.g. --file=./pathToFile.json.');if(p.at(-1)!=="json")throw new Error(`Expected the format of the "file" parameters '${o}' to be 'json', but got '${p.at(-1)}'.`)}if(s==="oneTrust"){if(!t)throw new Error('Missing required parameter "hostname". e.g. --hostname=customer.my.onetrust.com');if(!e)throw new Error('Missing required parameter "oneTrustAuth". e.g. --oneTrustAuth=$ONE_TRUST_AUTH_TOKEN')}else{if(!o)throw new Error('Must specify a "file" parameter to read the OneTrust assessments from. e.g. --source=./oneTrustAssessments.json');if(u)throw new Error('Cannot read and write to a file simultaneously. Emit the "source" parameter or set it to oneTrust if "dryRun" is enabled.')}_chunkWKCTKYN4cjs.a.call(void 0, this.process.exit);let g=t&&e?j({hostname:t,auth:e}):void 0,O=n&&r?_chunkJEH3FW7Jcjs.vc.call(void 0, n,r):void 0;try{m==="assessments"&&(s==="oneTrust"&&g?await Y({oneTrust:g,file:o,dryRun:u,...O&&{transcend:O}}):s==="file"&&o&&O&&await Z({file:o,transcend:O}))}catch(p){throw new Error(`An error occurred syncing the resource ${m} from OneTrust: ${h?p.stack:p.message}`)}_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully synced OneTrust ${m} to ${u?`disk at "${o}"`:"Transcend"}!`))}exports.syncOt = Ds;
7
+ //# sourceMappingURL=impl-IASTUGV6.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/cli/cli/dist/impl-U5EBZCIQ.cjs","../src/commands/migration/sync-ot/impl.ts","../src/lib/oneTrust/createOneTrustGotInstance.ts","../src/lib/oneTrust/helpers/oneTrustAssessmentToJson.ts","../src/lib/oneTrust/endpoints/getListOfOneTrustAssessments.ts","../src/lib/oneTrust/helpers/syncOneTrustAssessmentToTranscend.ts","../src/lib/oneTrust/helpers/syncOneTrustAssessmentsFromOneTrust.ts"],"names":["createOneTrustGotInstance","hostname","auth","got"],"mappings":"AAAA,y0BAAwC,wDAA0D,gCAA6B,wDAAoC,wDAAgD,wDAAyC,gFCEzO,oECFM,IAQZA,CAAAA,CAA4B,CAAC,CACxC,QAAA,CAAAC,CAAAA,CACA,IAAA,CAAAC,CACF,CAAA,CAAA,EAMEC,aAAAA,CAAI,MAAA,CAAO,CACT,SAAA,CAAW,CAAA,QAAA,EAAWF,CAAQ,CAAA,CAAA;ACiBwB;AAIzC;AClCf,CAAA;ACsE2F,mBAAA;ACC3B","file":"/home/runner/work/cli/cli/dist/impl-U5EBZCIQ.cjs","sourcesContent":[null,"import type { LocalContext } from '../../../context';\nimport { logger } from '../../../logger';\nimport colors from 'colors';\nimport { createOneTrustGotInstance } from '../../../lib/oneTrust';\nimport {\n OneTrustFileFormat,\n OneTrustPullResource,\n OneTrustPullSource,\n} from '../../../enums';\nimport { buildTranscendGraphQLClient } from '../../../lib/graphql';\nimport {\n syncOneTrustAssessmentsFromFile,\n syncOneTrustAssessmentsFromOneTrust,\n} from '../../../lib/oneTrust/helpers';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation';\n\n// Command flag interface\nexport interface SyncOtCommandFlags {\n hostname?: string;\n oneTrustAuth?: string;\n source: OneTrustPullSource;\n transcendAuth?: string;\n transcendUrl: string;\n file?: string;\n resource: OneTrustPullResource;\n dryRun: boolean;\n debug: boolean;\n}\n\n// Command implementation\nexport async function syncOt(\n this: LocalContext,\n {\n hostname,\n oneTrustAuth,\n source,\n transcendAuth,\n transcendUrl,\n resource,\n file,\n dryRun,\n debug,\n }: SyncOtCommandFlags,\n): Promise<void> {\n // Must be able to authenticate to transcend to sync resources to it\n if (!dryRun && !transcendAuth) {\n throw new Error(\n // eslint-disable-next-line no-template-curly-in-string\n 'Must specify a \"transcendAuth\" parameter to sync resources to Transcend. e.g. --transcendAuth=${TRANSCEND_API_KEY}',\n );\n }\n\n // If trying to sync to disk, must specify a file path\n if (dryRun && !file) {\n throw new Error(\n 'Must set a \"file\" parameter when \"dryRun\" is \"true\". e.g. --file=./oneTrustAssessments.json',\n );\n }\n\n if (file) {\n const splitFile = file.split('.');\n if (splitFile.length < 2) {\n throw new Error(\n 'The \"file\" parameter has an invalid format. Expected a path with extensions. e.g. --file=./pathToFile.json.',\n );\n }\n if (splitFile.at(-1) !== OneTrustFileFormat.Json) {\n throw new Error(\n `Expected the format of the \"file\" parameters '${file}' to be '${\n OneTrustFileFormat.Json\n }', but got '${splitFile.at(-1)}'.`,\n );\n }\n }\n\n // if reading assessments from a OneTrust\n if (source === OneTrustPullSource.OneTrust) {\n // must specify the OneTrust hostname\n if (!hostname) {\n throw new Error(\n 'Missing required parameter \"hostname\". e.g. --hostname=customer.my.onetrust.com',\n );\n }\n // must specify the OneTrust auth\n if (!oneTrustAuth) {\n throw new Error(\n 'Missing required parameter \"oneTrustAuth\". e.g. --oneTrustAuth=$ONE_TRUST_AUTH_TOKEN',\n );\n }\n } else {\n // if reading the assessments from a file, must specify a file to read from\n if (!file) {\n throw new Error(\n 'Must specify a \"file\" parameter to read the OneTrust assessments from. e.g. --source=./oneTrustAssessments.json',\n );\n }\n\n // Cannot try reading from file and save assessments to a file simultaneously\n if (dryRun) {\n throw new Error(\n 'Cannot read and write to a file simultaneously.' +\n ` Emit the \"source\" parameter or set it to ${OneTrustPullSource.OneTrust} if \"dryRun\" is enabled.`,\n );\n }\n }\n\n doneInputValidation(this.process.exit);\n\n // instantiate a client to talk to OneTrust\n const oneTrust =\n hostname && oneTrustAuth\n ? createOneTrustGotInstance({\n hostname,\n auth: oneTrustAuth,\n })\n : undefined;\n\n // instantiate a client to talk to Transcend\n const transcend =\n transcendUrl && transcendAuth\n ? buildTranscendGraphQLClient(transcendUrl, transcendAuth)\n : undefined;\n\n try {\n if (resource === OneTrustPullResource.Assessments) {\n if (source === OneTrustPullSource.OneTrust && oneTrust) {\n await syncOneTrustAssessmentsFromOneTrust({\n oneTrust,\n file,\n dryRun,\n ...(transcend && { transcend }),\n });\n } else if (source === OneTrustPullSource.File && file && transcend) {\n await syncOneTrustAssessmentsFromFile({ file, transcend });\n }\n }\n } catch (err) {\n throw new Error(\n `An error occurred syncing the resource ${resource} from OneTrust: ${\n debug ? err.stack : err.message\n }`,\n );\n }\n\n // Indicate success\n logger.info(\n colors.green(\n `Successfully synced OneTrust ${resource} to ${\n dryRun ? `disk at \"${file}\"` : 'Transcend'\n }!`,\n ),\n );\n}\n","import got, { Got } from 'got';\n\n/**\n * Instantiate an instance of got that is capable of making requests to OneTrust\n *\n * @param param - information about the OneTrust URL\n * @returns The instance of got that is capable of making requests to the customer ingress\n */\nexport const createOneTrustGotInstance = ({\n hostname,\n auth,\n}: {\n /** Hostname of the OneTrust API */\n hostname: string;\n /** The OAuth access token */\n auth: string;\n}): Got =>\n got.extend({\n prefixUrl: `https://${hostname}`,\n headers: {\n accept: 'application/json',\n 'content-type': 'application/json',\n authorization: `Bearer ${auth}`,\n },\n });\n","import { OneTrustEnrichedAssessment } from '@transcend-io/privacy-types';\n\n/**\n * Converts the assessment into a json entry.\n *\n * @param param - information about the assessment and amount of entries\n * @returns a stringified json entry ready to be appended to a file\n */\nexport const oneTrustAssessmentToJson = ({\n assessment,\n index,\n total,\n wrap = true,\n}: {\n /** The assessment to convert */\n assessment: OneTrustEnrichedAssessment;\n /** The position of the assessment in the final Json object */\n index: number;\n /** The total amount of the assessments in the final Json object */\n total?: number;\n /** Whether to wrap every entry in brackets */\n wrap?: boolean;\n}): string => {\n let jsonEntry = '';\n // start with an opening bracket\n if (index === 0 || wrap) {\n jsonEntry = '[\\n';\n }\n\n const stringifiedAssessment = JSON.stringify(assessment);\n\n // Add comma for all items except the last one\n const comma = total && index < total - 1 && !wrap ? ',' : '';\n\n // write to file\n jsonEntry = `${jsonEntry + stringifiedAssessment + comma}\\n`;\n\n // end with closing bracket\n if ((total && index === total - 1) || wrap) {\n jsonEntry += '\\n]';\n }\n\n return jsonEntry;\n};\n","import { Got } from 'got';\nimport { logger } from '../../../logger';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport {\n OneTrustAssessment,\n OneTrustGetListOfAssessmentsResponse,\n} from '@transcend-io/privacy-types';\n\n/**\n * Fetch a list of all assessments from the OneTrust client.\n * ref: https://developer.onetrust.com/onetrust/reference/getallassessmentbasicdetailsusingget\n *\n * @param param - the information about the OneTrust client\n * @returns a list of OneTrustAssessment\n */\nexport const getListOfOneTrustAssessments = async ({\n oneTrust,\n}: {\n /** The OneTrust client instance */\n oneTrust: Got;\n}): Promise<OneTrustAssessment[]> => {\n let currentPage = 0;\n let totalPages = 1;\n let totalElements = 0;\n\n const allAssessments: OneTrustAssessment[] = [];\n\n while (currentPage < totalPages) {\n const { body } = await oneTrust.get(\n `api/assessment/v2/assessments?page=${currentPage}&size=2000`,\n );\n\n const { page, content } = decodeCodec(\n OneTrustGetListOfAssessmentsResponse,\n body,\n );\n allAssessments.push(...(content ?? []));\n if (currentPage === 0) {\n totalPages = page?.totalPages ?? 0;\n totalElements = page?.totalElements ?? 0;\n }\n currentPage += 1;\n\n // log progress\n logger.info(\n `Fetched ${allAssessments.length} of ${totalElements} assessments.`,\n );\n }\n\n return allAssessments;\n};\n","import { logger } from '../../../logger';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\nimport {\n IMPORT_ONE_TRUST_ASSESSMENT_FORMS,\n makeGraphQLRequest,\n} from '../../graphql';\nimport { ImportOnetrustAssessmentsInput } from '../../../codecs';\nimport { OneTrustEnrichedAssessment } from '@transcend-io/privacy-types';\nimport { oneTrustAssessmentToJson } from './oneTrustAssessmentToJson';\n\nexport interface AssessmentForm {\n /** ID of Assessment Form */\n id: string;\n /** Title of Assessment Form */\n name: string;\n}\n\n/**\n * Write the assessment to a Transcend instance.\n *\n *\n * @param param - information about the assessment and Transcend instance to write to\n */\nexport const syncOneTrustAssessmentToTranscend = async ({\n transcend,\n assessment,\n total,\n index,\n}: {\n /** the Transcend client instance */\n transcend: GraphQLClient;\n /** the assessment to sync to Transcend */\n assessment: OneTrustEnrichedAssessment;\n /** The index of the assessment being written to the file */\n index: number;\n /** The total amount of assessments that we will write */\n total?: number;\n}): Promise<void> => {\n logger.info(\n colors.magenta(\n `Writing enriched assessment ${index + 1} ${\n total ? `of ${total} ` : ' '\n }to Transcend...`,\n ),\n );\n\n // convert the OneTrust assessment object into a json record\n const json = oneTrustAssessmentToJson({\n assessment,\n index,\n total,\n });\n\n // transform the json record into a valid input to the mutation\n const input: ImportOnetrustAssessmentsInput = {\n json,\n };\n\n try {\n await makeGraphQLRequest<{\n /** the importOneTrustAssessmentForms mutation */\n importOneTrustAssessmentForms: {\n /** Created Assessment Forms */\n assessmentForms: AssessmentForm[];\n };\n }>(transcend, IMPORT_ONE_TRUST_ASSESSMENT_FORMS, {\n input,\n });\n } catch (e) {\n logger.error(\n colors.red(\n `Failed to sync assessment ${index + 1} ${\n total ? `of ${total} ` : ' '\n }to Transcend.\\n` +\n `\\tAssessment Title: ${assessment.name}. Template Title: ${assessment.template.name}\\n`,\n ),\n );\n }\n};\n","import type { Got } from 'got';\nimport colors from 'colors';\nimport {\n getListOfOneTrustAssessments,\n getOneTrustAssessment,\n getOneTrustRisk,\n getOneTrustUser,\n} from '../endpoints';\nimport { mapSeries, map } from 'bluebird';\nimport { logger } from '../../../logger';\nimport {\n OneTrustAssessmentQuestion,\n OneTrustAssessmentSection,\n OneTrustEnrichedAssessment,\n OneTrustGetRiskResponse,\n OneTrustGetUserResponse,\n} from '@transcend-io/privacy-types';\nimport { uniq } from 'lodash-es';\nimport { enrichOneTrustAssessment } from './enrichOneTrustAssessment';\nimport { syncOneTrustAssessmentToDisk } from './syncOneTrustAssessmentToDisk';\nimport { GraphQLClient } from 'graphql-request';\nimport { syncOneTrustAssessmentToTranscend } from './syncOneTrustAssessmentToTranscend';\n\nexport interface AssessmentForm {\n /** ID of Assessment Form */\n id: string;\n /** Title of Assessment Form */\n name: string;\n}\n\n/**\n * Reads all the assessments from a OneTrust instance and syncs them to Transcend or to Disk.\n *\n * @param param - the information about the assessment, its OneTrust source, and destination (disk or Transcend)\n */\nexport const syncOneTrustAssessmentsFromOneTrust = async ({\n oneTrust,\n file,\n dryRun,\n transcend,\n}: {\n /** the OneTrust client instance */\n oneTrust: Got;\n /** the Transcend client instance */\n transcend?: GraphQLClient;\n /** Whether to write to file instead of syncing to Transcend */\n dryRun: boolean;\n /** the path to the file in case dryRun is true */\n file?: string;\n}): Promise<void> => {\n // fetch the list of all assessments in the OneTrust organization\n logger.info('Getting list of all assessments from OneTrust...');\n const assessments = await getListOfOneTrustAssessments({ oneTrust });\n\n // a cache of OneTrust users so we avoid requesting already fetched users\n const oneTrustCachedUsers: Record<string, OneTrustGetUserResponse> = {};\n\n // split all assessments in batches, so we can process some of steps in parallel\n const BATCH_SIZE = 5;\n const assessmentBatches = Array.from(\n {\n length: Math.ceil(assessments.length / BATCH_SIZE),\n },\n (_, i) => assessments.slice(i * BATCH_SIZE, (i + 1) * BATCH_SIZE),\n );\n\n // process each batch and sync the batch right away so it's garbage collected and we don't run out of memory\n await mapSeries(assessmentBatches, async (assessmentBatch, batch) => {\n const batchEnrichedAssessments: OneTrustEnrichedAssessment[] = [];\n\n // fetch assessment details from OneTrust in parallel\n await map(\n assessmentBatch,\n async (assessment, index) => {\n const assessmentNumber = BATCH_SIZE * batch + index + 1;\n logger.info(\n `[assessment ${assessmentNumber} of ${assessments.length}]: fetching details...`,\n );\n const { templateName, assessmentId } = assessment;\n const assessmentDetails = await getOneTrustAssessment({\n oneTrust,\n assessmentId,\n });\n // fetch assessment's creator information\n const creatorId = assessmentDetails.createdBy.id;\n let creator = oneTrustCachedUsers[creatorId];\n if (!creator) {\n logger.info(\n `[assessment ${assessmentNumber} of ${assessments.length}]: fetching creator...`,\n );\n try {\n creator = await getOneTrustUser({\n oneTrust,\n userId: creatorId,\n });\n oneTrustCachedUsers[creatorId] = creator;\n } catch (e) {\n logger.warn(\n colors.yellow(\n `[assessment ${assessmentNumber} of ${assessments.length}]: failed to fetch form creator.` +\n `\\tcreatorId: ${creatorId}. Assessment Title: ${assessment.name}. Template Title: ${templateName}`,\n ),\n );\n }\n }\n\n // fetch assessment approvers information\n const { approvers } = assessmentDetails;\n let approversDetails: OneTrustGetUserResponse[][] = [];\n if (approvers.length > 0) {\n logger.info(\n `[assessment ${assessmentNumber} of ${assessments.length}]: fetching approvers...`,\n );\n approversDetails = await map(\n approvers.map(({ id }) => id),\n async (userId) => {\n try {\n let approver = oneTrustCachedUsers[userId];\n if (!approver) {\n approver = await getOneTrustUser({ oneTrust, userId });\n oneTrustCachedUsers[userId] = approver;\n }\n return [approver];\n } catch (e) {\n logger.warn(\n colors.yellow(\n `[assessment ${assessmentNumber} of ${assessments.length}]: failed to fetch a form approver.` +\n `\\tapproverId: ${userId}. Assessment Title: ${assessment.name}. Template Title: ${templateName}`,\n ),\n );\n return [];\n }\n },\n { concurrency: 5 },\n );\n }\n\n // fetch assessment internal respondents information\n const { respondents } = assessmentDetails;\n // if a user is an internal respondents, their 'name' field can't be an email.\n const internalRespondents = respondents.filter(\n (r) => !r.name.includes('@'),\n );\n let respondentsDetails: OneTrustGetUserResponse[][] = [];\n if (internalRespondents.length > 0) {\n logger.info(\n `[assessment ${assessmentNumber} of ${assessments.length}]: fetching respondents...`,\n );\n respondentsDetails = await map(\n internalRespondents.map(({ id }) => id),\n async (userId) => {\n try {\n let respondent = oneTrustCachedUsers[userId];\n if (!respondent) {\n respondent = await getOneTrustUser({ oneTrust, userId });\n oneTrustCachedUsers[userId] = respondent;\n }\n return [respondent];\n } catch (e) {\n logger.warn(\n colors.yellow(\n `[assessment ${assessmentNumber} of ${assessments.length}]: failed to fetch a respondent.` +\n `\\trespondentId: ${userId}. Assessment Title: ${assessment.name}. Template Title: ${templateName}`,\n ),\n );\n return [];\n }\n },\n { concurrency: 5 },\n );\n }\n\n // fetch assessment risk information\n let riskDetails: OneTrustGetRiskResponse[] = [];\n const riskIds = uniq(\n assessmentDetails.sections.flatMap((s: OneTrustAssessmentSection) =>\n s.questions.flatMap((q: OneTrustAssessmentQuestion) =>\n (q.risks ?? []).flatMap((r) => r.riskId),\n ),\n ),\n );\n if (riskIds.length > 0) {\n logger.info(\n `[assessment ${assessmentNumber} of ${assessments.length}]: fetching risks...`,\n );\n riskDetails = await map(\n riskIds,\n (riskId) => getOneTrustRisk({ oneTrust, riskId: riskId as string }),\n {\n concurrency: 5,\n },\n );\n }\n\n // enrich the assessments with user and risk details\n const enrichedAssessment = enrichOneTrustAssessment({\n assessment,\n assessmentDetails,\n riskDetails,\n creatorDetails: creator,\n approversDetails: approversDetails.flat(),\n respondentsDetails: respondentsDetails.flat(),\n });\n\n batchEnrichedAssessments.push(enrichedAssessment);\n },\n { concurrency: BATCH_SIZE },\n );\n\n // sync assessments in series to avoid concurrency bugs\n await mapSeries(\n batchEnrichedAssessments,\n async (enrichedAssessment, index) => {\n // the assessment's global index takes its batch into consideration\n const globalIndex = batch * BATCH_SIZE + index;\n\n if (dryRun && file) {\n // sync to file\n syncOneTrustAssessmentToDisk({\n assessment: enrichedAssessment,\n index: globalIndex,\n total: assessments.length,\n file,\n });\n } else if (transcend) {\n // sync to transcend\n await syncOneTrustAssessmentToTranscend({\n assessment: enrichedAssessment,\n transcend,\n total: assessments.length,\n index: globalIndex,\n });\n }\n },\n );\n });\n};\n"]}
1
+ {"version":3,"sources":["/home/runner/work/cli/cli/dist/impl-IASTUGV6.cjs","../src/commands/migration/sync-ot/impl.ts","../src/lib/oneTrust/createOneTrustGotInstance.ts","../src/lib/oneTrust/helpers/oneTrustAssessmentToJson.ts","../src/lib/oneTrust/endpoints/getListOfOneTrustAssessments.ts","../src/lib/oneTrust/helpers/syncOneTrustAssessmentToTranscend.ts","../src/lib/oneTrust/helpers/syncOneTrustAssessmentsFromOneTrust.ts"],"names":["createOneTrustGotInstance","hostname","auth","got"],"mappings":"AAAA,y0BAAwC,wDAA0D,gCAA6B,wDAAoC,wDAAgD,wDAAyC,gFCEzO,oECFM,IAQZA,CAAAA,CAA4B,CAAC,CACxC,QAAA,CAAAC,CAAAA,CACA,IAAA,CAAAC,CACF,CAAA,CAAA,EAMEC,aAAAA,CAAI,MAAA,CAAO,CACT,SAAA,CAAW,CAAA,QAAA,EAAWF,CAAQ,CAAA,CAAA;ACiBwB;AAIzC;AClCf,CAAA;ACsE2F,mBAAA;ACC3B","file":"/home/runner/work/cli/cli/dist/impl-IASTUGV6.cjs","sourcesContent":[null,"import type { LocalContext } from '../../../context';\nimport { logger } from '../../../logger';\nimport colors from 'colors';\nimport { createOneTrustGotInstance } from '../../../lib/oneTrust';\nimport {\n OneTrustFileFormat,\n OneTrustPullResource,\n OneTrustPullSource,\n} from '../../../enums';\nimport { buildTranscendGraphQLClient } from '../../../lib/graphql';\nimport {\n syncOneTrustAssessmentsFromFile,\n syncOneTrustAssessmentsFromOneTrust,\n} from '../../../lib/oneTrust/helpers';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation';\n\n// Command flag interface\nexport interface SyncOtCommandFlags {\n hostname?: string;\n oneTrustAuth?: string;\n source: OneTrustPullSource;\n transcendAuth?: string;\n transcendUrl: string;\n file?: string;\n resource: OneTrustPullResource;\n dryRun: boolean;\n debug: boolean;\n}\n\n// Command implementation\nexport async function syncOt(\n this: LocalContext,\n {\n hostname,\n oneTrustAuth,\n source,\n transcendAuth,\n transcendUrl,\n resource,\n file,\n dryRun,\n debug,\n }: SyncOtCommandFlags,\n): Promise<void> {\n // Must be able to authenticate to transcend to sync resources to it\n if (!dryRun && !transcendAuth) {\n throw new Error(\n // eslint-disable-next-line no-template-curly-in-string\n 'Must specify a \"transcendAuth\" parameter to sync resources to Transcend. e.g. --transcendAuth=${TRANSCEND_API_KEY}',\n );\n }\n\n // If trying to sync to disk, must specify a file path\n if (dryRun && !file) {\n throw new Error(\n 'Must set a \"file\" parameter when \"dryRun\" is \"true\". e.g. --file=./oneTrustAssessments.json',\n );\n }\n\n if (file) {\n const splitFile = file.split('.');\n if (splitFile.length < 2) {\n throw new Error(\n 'The \"file\" parameter has an invalid format. Expected a path with extensions. e.g. --file=./pathToFile.json.',\n );\n }\n if (splitFile.at(-1) !== OneTrustFileFormat.Json) {\n throw new Error(\n `Expected the format of the \"file\" parameters '${file}' to be '${\n OneTrustFileFormat.Json\n }', but got '${splitFile.at(-1)}'.`,\n );\n }\n }\n\n // if reading assessments from a OneTrust\n if (source === OneTrustPullSource.OneTrust) {\n // must specify the OneTrust hostname\n if (!hostname) {\n throw new Error(\n 'Missing required parameter \"hostname\". e.g. --hostname=customer.my.onetrust.com',\n );\n }\n // must specify the OneTrust auth\n if (!oneTrustAuth) {\n throw new Error(\n 'Missing required parameter \"oneTrustAuth\". e.g. --oneTrustAuth=$ONE_TRUST_AUTH_TOKEN',\n );\n }\n } else {\n // if reading the assessments from a file, must specify a file to read from\n if (!file) {\n throw new Error(\n 'Must specify a \"file\" parameter to read the OneTrust assessments from. e.g. --source=./oneTrustAssessments.json',\n );\n }\n\n // Cannot try reading from file and save assessments to a file simultaneously\n if (dryRun) {\n throw new Error(\n 'Cannot read and write to a file simultaneously.' +\n ` Emit the \"source\" parameter or set it to ${OneTrustPullSource.OneTrust} if \"dryRun\" is enabled.`,\n );\n }\n }\n\n doneInputValidation(this.process.exit);\n\n // instantiate a client to talk to OneTrust\n const oneTrust =\n hostname && oneTrustAuth\n ? createOneTrustGotInstance({\n hostname,\n auth: oneTrustAuth,\n })\n : undefined;\n\n // instantiate a client to talk to Transcend\n const transcend =\n transcendUrl && transcendAuth\n ? buildTranscendGraphQLClient(transcendUrl, transcendAuth)\n : undefined;\n\n try {\n if (resource === OneTrustPullResource.Assessments) {\n if (source === OneTrustPullSource.OneTrust && oneTrust) {\n await syncOneTrustAssessmentsFromOneTrust({\n oneTrust,\n file,\n dryRun,\n ...(transcend && { transcend }),\n });\n } else if (source === OneTrustPullSource.File && file && transcend) {\n await syncOneTrustAssessmentsFromFile({ file, transcend });\n }\n }\n } catch (err) {\n throw new Error(\n `An error occurred syncing the resource ${resource} from OneTrust: ${\n debug ? err.stack : err.message\n }`,\n );\n }\n\n // Indicate success\n logger.info(\n colors.green(\n `Successfully synced OneTrust ${resource} to ${\n dryRun ? `disk at \"${file}\"` : 'Transcend'\n }!`,\n ),\n );\n}\n","import got, { Got } from 'got';\n\n/**\n * Instantiate an instance of got that is capable of making requests to OneTrust\n *\n * @param param - information about the OneTrust URL\n * @returns The instance of got that is capable of making requests to the customer ingress\n */\nexport const createOneTrustGotInstance = ({\n hostname,\n auth,\n}: {\n /** Hostname of the OneTrust API */\n hostname: string;\n /** The OAuth access token */\n auth: string;\n}): Got =>\n got.extend({\n prefixUrl: `https://${hostname}`,\n headers: {\n accept: 'application/json',\n 'content-type': 'application/json',\n authorization: `Bearer ${auth}`,\n },\n });\n","import { OneTrustEnrichedAssessment } from '@transcend-io/privacy-types';\n\n/**\n * Converts the assessment into a json entry.\n *\n * @param param - information about the assessment and amount of entries\n * @returns a stringified json entry ready to be appended to a file\n */\nexport const oneTrustAssessmentToJson = ({\n assessment,\n index,\n total,\n wrap = true,\n}: {\n /** The assessment to convert */\n assessment: OneTrustEnrichedAssessment;\n /** The position of the assessment in the final Json object */\n index: number;\n /** The total amount of the assessments in the final Json object */\n total?: number;\n /** Whether to wrap every entry in brackets */\n wrap?: boolean;\n}): string => {\n let jsonEntry = '';\n // start with an opening bracket\n if (index === 0 || wrap) {\n jsonEntry = '[\\n';\n }\n\n const stringifiedAssessment = JSON.stringify(assessment);\n\n // Add comma for all items except the last one\n const comma = total && index < total - 1 && !wrap ? ',' : '';\n\n // write to file\n jsonEntry = `${jsonEntry + stringifiedAssessment + comma}\\n`;\n\n // end with closing bracket\n if ((total && index === total - 1) || wrap) {\n jsonEntry += '\\n]';\n }\n\n return jsonEntry;\n};\n","import { Got } from 'got';\nimport { logger } from '../../../logger';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport {\n OneTrustAssessment,\n OneTrustGetListOfAssessmentsResponse,\n} from '@transcend-io/privacy-types';\n\n/**\n * Fetch a list of all assessments from the OneTrust client.\n * ref: https://developer.onetrust.com/onetrust/reference/getallassessmentbasicdetailsusingget\n *\n * @param param - the information about the OneTrust client\n * @returns a list of OneTrustAssessment\n */\nexport const getListOfOneTrustAssessments = async ({\n oneTrust,\n}: {\n /** The OneTrust client instance */\n oneTrust: Got;\n}): Promise<OneTrustAssessment[]> => {\n let currentPage = 0;\n let totalPages = 1;\n let totalElements = 0;\n\n const allAssessments: OneTrustAssessment[] = [];\n\n while (currentPage < totalPages) {\n const { body } = await oneTrust.get(\n `api/assessment/v2/assessments?page=${currentPage}&size=2000`,\n );\n\n const { page, content } = decodeCodec(\n OneTrustGetListOfAssessmentsResponse,\n body,\n );\n allAssessments.push(...(content ?? []));\n if (currentPage === 0) {\n totalPages = page?.totalPages ?? 0;\n totalElements = page?.totalElements ?? 0;\n }\n currentPage += 1;\n\n // log progress\n logger.info(\n `Fetched ${allAssessments.length} of ${totalElements} assessments.`,\n );\n }\n\n return allAssessments;\n};\n","import { logger } from '../../../logger';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\nimport {\n IMPORT_ONE_TRUST_ASSESSMENT_FORMS,\n makeGraphQLRequest,\n} from '../../graphql';\nimport { ImportOnetrustAssessmentsInput } from '../../../codecs';\nimport { OneTrustEnrichedAssessment } from '@transcend-io/privacy-types';\nimport { oneTrustAssessmentToJson } from './oneTrustAssessmentToJson';\n\nexport interface AssessmentForm {\n /** ID of Assessment Form */\n id: string;\n /** Title of Assessment Form */\n name: string;\n}\n\n/**\n * Write the assessment to a Transcend instance.\n *\n *\n * @param param - information about the assessment and Transcend instance to write to\n */\nexport const syncOneTrustAssessmentToTranscend = async ({\n transcend,\n assessment,\n total,\n index,\n}: {\n /** the Transcend client instance */\n transcend: GraphQLClient;\n /** the assessment to sync to Transcend */\n assessment: OneTrustEnrichedAssessment;\n /** The index of the assessment being written to the file */\n index: number;\n /** The total amount of assessments that we will write */\n total?: number;\n}): Promise<void> => {\n logger.info(\n colors.magenta(\n `Writing enriched assessment ${index + 1} ${\n total ? `of ${total} ` : ' '\n }to Transcend...`,\n ),\n );\n\n // convert the OneTrust assessment object into a json record\n const json = oneTrustAssessmentToJson({\n assessment,\n index,\n total,\n });\n\n // transform the json record into a valid input to the mutation\n const input: ImportOnetrustAssessmentsInput = {\n json,\n };\n\n try {\n await makeGraphQLRequest<{\n /** the importOneTrustAssessmentForms mutation */\n importOneTrustAssessmentForms: {\n /** Created Assessment Forms */\n assessmentForms: AssessmentForm[];\n };\n }>(transcend, IMPORT_ONE_TRUST_ASSESSMENT_FORMS, {\n input,\n });\n } catch (e) {\n logger.error(\n colors.red(\n `Failed to sync assessment ${index + 1} ${\n total ? `of ${total} ` : ' '\n }to Transcend.\\n` +\n `\\tAssessment Title: ${assessment.name}. Template Title: ${assessment.template.name}\\n`,\n ),\n );\n }\n};\n","import type { Got } from 'got';\nimport colors from 'colors';\nimport {\n getListOfOneTrustAssessments,\n getOneTrustAssessment,\n getOneTrustRisk,\n getOneTrustUser,\n} from '../endpoints';\nimport { mapSeries, map } from 'bluebird';\nimport { logger } from '../../../logger';\nimport {\n OneTrustAssessmentQuestion,\n OneTrustAssessmentSection,\n OneTrustEnrichedAssessment,\n OneTrustGetRiskResponse,\n OneTrustGetUserResponse,\n} from '@transcend-io/privacy-types';\nimport { uniq } from 'lodash-es';\nimport { enrichOneTrustAssessment } from './enrichOneTrustAssessment';\nimport { syncOneTrustAssessmentToDisk } from './syncOneTrustAssessmentToDisk';\nimport { GraphQLClient } from 'graphql-request';\nimport { syncOneTrustAssessmentToTranscend } from './syncOneTrustAssessmentToTranscend';\n\nexport interface AssessmentForm {\n /** ID of Assessment Form */\n id: string;\n /** Title of Assessment Form */\n name: string;\n}\n\n/**\n * Reads all the assessments from a OneTrust instance and syncs them to Transcend or to Disk.\n *\n * @param param - the information about the assessment, its OneTrust source, and destination (disk or Transcend)\n */\nexport const syncOneTrustAssessmentsFromOneTrust = async ({\n oneTrust,\n file,\n dryRun,\n transcend,\n}: {\n /** the OneTrust client instance */\n oneTrust: Got;\n /** the Transcend client instance */\n transcend?: GraphQLClient;\n /** Whether to write to file instead of syncing to Transcend */\n dryRun: boolean;\n /** the path to the file in case dryRun is true */\n file?: string;\n}): Promise<void> => {\n // fetch the list of all assessments in the OneTrust organization\n logger.info('Getting list of all assessments from OneTrust...');\n const assessments = await getListOfOneTrustAssessments({ oneTrust });\n\n // a cache of OneTrust users so we avoid requesting already fetched users\n const oneTrustCachedUsers: Record<string, OneTrustGetUserResponse> = {};\n\n // split all assessments in batches, so we can process some of steps in parallel\n const BATCH_SIZE = 5;\n const assessmentBatches = Array.from(\n {\n length: Math.ceil(assessments.length / BATCH_SIZE),\n },\n (_, i) => assessments.slice(i * BATCH_SIZE, (i + 1) * BATCH_SIZE),\n );\n\n // process each batch and sync the batch right away so it's garbage collected and we don't run out of memory\n await mapSeries(assessmentBatches, async (assessmentBatch, batch) => {\n const batchEnrichedAssessments: OneTrustEnrichedAssessment[] = [];\n\n // fetch assessment details from OneTrust in parallel\n await map(\n assessmentBatch,\n async (assessment, index) => {\n const assessmentNumber = BATCH_SIZE * batch + index + 1;\n logger.info(\n `[assessment ${assessmentNumber} of ${assessments.length}]: fetching details...`,\n );\n const { templateName, assessmentId } = assessment;\n const assessmentDetails = await getOneTrustAssessment({\n oneTrust,\n assessmentId,\n });\n // fetch assessment's creator information\n const creatorId = assessmentDetails.createdBy.id;\n let creator = oneTrustCachedUsers[creatorId];\n if (!creator) {\n logger.info(\n `[assessment ${assessmentNumber} of ${assessments.length}]: fetching creator...`,\n );\n try {\n creator = await getOneTrustUser({\n oneTrust,\n userId: creatorId,\n });\n oneTrustCachedUsers[creatorId] = creator;\n } catch (e) {\n logger.warn(\n colors.yellow(\n `[assessment ${assessmentNumber} of ${assessments.length}]: failed to fetch form creator.` +\n `\\tcreatorId: ${creatorId}. Assessment Title: ${assessment.name}. Template Title: ${templateName}`,\n ),\n );\n }\n }\n\n // fetch assessment approvers information\n const { approvers } = assessmentDetails;\n let approversDetails: OneTrustGetUserResponse[][] = [];\n if (approvers.length > 0) {\n logger.info(\n `[assessment ${assessmentNumber} of ${assessments.length}]: fetching approvers...`,\n );\n approversDetails = await map(\n approvers.map(({ id }) => id),\n async (userId) => {\n try {\n let approver = oneTrustCachedUsers[userId];\n if (!approver) {\n approver = await getOneTrustUser({ oneTrust, userId });\n oneTrustCachedUsers[userId] = approver;\n }\n return [approver];\n } catch (e) {\n logger.warn(\n colors.yellow(\n `[assessment ${assessmentNumber} of ${assessments.length}]: failed to fetch a form approver.` +\n `\\tapproverId: ${userId}. Assessment Title: ${assessment.name}. Template Title: ${templateName}`,\n ),\n );\n return [];\n }\n },\n { concurrency: 5 },\n );\n }\n\n // fetch assessment internal respondents information\n const { respondents } = assessmentDetails;\n // if a user is an internal respondents, their 'name' field can't be an email.\n const internalRespondents = respondents.filter(\n (r) => !r.name.includes('@'),\n );\n let respondentsDetails: OneTrustGetUserResponse[][] = [];\n if (internalRespondents.length > 0) {\n logger.info(\n `[assessment ${assessmentNumber} of ${assessments.length}]: fetching respondents...`,\n );\n respondentsDetails = await map(\n internalRespondents.map(({ id }) => id),\n async (userId) => {\n try {\n let respondent = oneTrustCachedUsers[userId];\n if (!respondent) {\n respondent = await getOneTrustUser({ oneTrust, userId });\n oneTrustCachedUsers[userId] = respondent;\n }\n return [respondent];\n } catch (e) {\n logger.warn(\n colors.yellow(\n `[assessment ${assessmentNumber} of ${assessments.length}]: failed to fetch a respondent.` +\n `\\trespondentId: ${userId}. Assessment Title: ${assessment.name}. Template Title: ${templateName}`,\n ),\n );\n return [];\n }\n },\n { concurrency: 5 },\n );\n }\n\n // fetch assessment risk information\n let riskDetails: OneTrustGetRiskResponse[] = [];\n const riskIds = uniq(\n assessmentDetails.sections.flatMap((s: OneTrustAssessmentSection) =>\n s.questions.flatMap((q: OneTrustAssessmentQuestion) =>\n (q.risks ?? []).flatMap((r) => r.riskId),\n ),\n ),\n );\n if (riskIds.length > 0) {\n logger.info(\n `[assessment ${assessmentNumber} of ${assessments.length}]: fetching risks...`,\n );\n riskDetails = await map(\n riskIds,\n (riskId) => getOneTrustRisk({ oneTrust, riskId: riskId as string }),\n {\n concurrency: 5,\n },\n );\n }\n\n // enrich the assessments with user and risk details\n const enrichedAssessment = enrichOneTrustAssessment({\n assessment,\n assessmentDetails,\n riskDetails,\n creatorDetails: creator,\n approversDetails: approversDetails.flat(),\n respondentsDetails: respondentsDetails.flat(),\n });\n\n batchEnrichedAssessments.push(enrichedAssessment);\n },\n { concurrency: BATCH_SIZE },\n );\n\n // sync assessments in series to avoid concurrency bugs\n await mapSeries(\n batchEnrichedAssessments,\n async (enrichedAssessment, index) => {\n // the assessment's global index takes its batch into consideration\n const globalIndex = batch * BATCH_SIZE + index;\n\n if (dryRun && file) {\n // sync to file\n syncOneTrustAssessmentToDisk({\n assessment: enrichedAssessment,\n index: globalIndex,\n total: assessments.length,\n file,\n });\n } else if (transcend) {\n // sync to transcend\n await syncOneTrustAssessmentToTranscend({\n assessment: enrichedAssessment,\n transcend,\n total: assessments.length,\n index: globalIndex,\n });\n }\n },\n );\n });\n};\n"]}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkSW5CIF5Dcjs = require('./chunk-SW5CIF5D.cjs');var _chunkV4GIAIGUcjs = require('./chunk-V4GIAIGU.cjs');require('./chunk-BZI5QRMD.cjs');var _chunkDQ4R65RBcjs = require('./chunk-DQ4R65RB.cjs');require('./chunk-QEM6S2W7.cjs');var _chunkWKCTKYN4cjs = require('./chunk-WKCTKYN4.cjs');require('./chunk-EMB64AC3.cjs');require('./chunk-LCDYXJN6.cjs');var _chunkZUNVPK23cjs = require('./chunk-ZUNVPK23.cjs');require('./chunk-4U57O4PS.cjs');require('./chunk-Q7I37FJV.cjs');var _path = require('path');var _colors = require('colors'); var _colors2 = _interopRequireDefault(_colors);var _fs = require('fs');function M({consentManagerYmlFolder:s,output:n}){_chunkWKCTKYN4cjs.a.call(void 0, this.process.exit),(!_fs.existsSync.call(void 0, s)||!_fs.lstatSync.call(void 0, s).isDirectory())&&(_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Folder does not exist: "${s}"`)),this.process.exit(1));let f=_chunkDQ4R65RBcjs.c.call(void 0, s).map(i=>{let{"consent-manager":u}=_chunkSW5CIF5Dcjs.d.call(void 0, _path.join.call(void 0, s,i));return{name:i,input:u}}),e=_chunkV4GIAIGUcjs.h.call(void 0, f);_chunkSW5CIF5Dcjs.e.call(void 0, n,{"business-entities":e}),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully wrote ${e.length} business entities to file "${n}"`))}exports.consentManagersToBusinessEntities = M;
2
- //# sourceMappingURL=impl-LRWZARHM.cjs.map
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkSW5CIF5Dcjs = require('./chunk-SW5CIF5D.cjs');var _chunkVXJ3QIONcjs = require('./chunk-VXJ3QION.cjs');require('./chunk-OAG7DICW.cjs');var _chunkGVK66NZAcjs = require('./chunk-GVK66NZA.cjs');require('./chunk-QEM6S2W7.cjs');var _chunkWKCTKYN4cjs = require('./chunk-WKCTKYN4.cjs');require('./chunk-JEH3FW7J.cjs');require('./chunk-LCDYXJN6.cjs');var _chunkZUNVPK23cjs = require('./chunk-ZUNVPK23.cjs');require('./chunk-OFZ7ZSEV.cjs');require('./chunk-Q7I37FJV.cjs');var _path = require('path');var _colors = require('colors'); var _colors2 = _interopRequireDefault(_colors);var _fs = require('fs');function M({consentManagerYmlFolder:s,output:n}){_chunkWKCTKYN4cjs.a.call(void 0, this.process.exit),(!_fs.existsSync.call(void 0, s)||!_fs.lstatSync.call(void 0, s).isDirectory())&&(_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Folder does not exist: "${s}"`)),this.process.exit(1));let f=_chunkGVK66NZAcjs.c.call(void 0, s).map(i=>{let{"consent-manager":u}=_chunkSW5CIF5Dcjs.d.call(void 0, _path.join.call(void 0, s,i));return{name:i,input:u}}),e=_chunkVXJ3QIONcjs.h.call(void 0, f);_chunkSW5CIF5Dcjs.e.call(void 0, n,{"business-entities":e}),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully wrote ${e.length} business entities to file "${n}"`))}exports.consentManagersToBusinessEntities = M;
2
+ //# sourceMappingURL=impl-IJTQXS6O.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/cli/cli/dist/impl-LRWZARHM.cjs","../src/commands/inventory/consent-managers-to-business-entities/impl.ts"],"names":["consentManagersToBusinessEntities","consentManagerYmlFolder","output","doneInputValidation","existsSync","lstatSync","logger","colors","inputs","listFiles","directory","consentManager","readTranscendYaml","join","businessEntities","writeTranscendYaml"],"mappings":"AAAA,iOAA+C,wDAAyC,gCAA6B,wDAAyC,gCAA6B,wDAAyC,gCAA6B,gCAA6B,wDAAyC,gCAA6B,gCAA6B,4BCO5W,gFAEF,wBAEmB,SAQtBA,CAAAA,CAEd,CACE,uBAAA,CAAAC,CAAAA,CACA,MAAA,CAAAC,CACF,CAAA,CACM,CACNC,iCAAAA,IAAoB,CAAK,OAAA,CAAQ,IAAI,CAAA,CAAA,CAInC,CAACC,4BAAAA,CAAkC,CAAA,EACnC,CAACC,2BAAAA,CAAiC,CAAA,CAAE,WAAA,CAAY,CAAA,CAAA,EAAA,CAEhDC,mBAAAA,CAAO,KAAA,CACLC,gBAAAA,CAAO,GAAA,CAAI,CAAA,wBAAA,EAA2BN,CAAuB,CAAA,CAAA,CAAG,CAClE,CAAA,CACA,IAAA,CAAK,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CAAA,CAIrB,IAAMO,CAAAA,CAASC,iCAAAA,CAAiC,CAAA,CAAE,GAAA,CAAKC,CAAAA,EAAc,CACnE,GAAM,CAAE,iBAAA,CAAmBC,CAAe,CAAA,CAAIC,iCAAAA,wBAC5CC,CAAKZ,CAAyBS,CAAS,CACzC,CAAA,CACA,MAAO,CAAE,IAAA,CAAMA,CAAAA,CAAW,KAAA,CAAOC,CAAe,CAClD,CAAC,CAAA,CAGKG,CAAAA,CAAmBd,iCAAAA,CAA8C,CAAA,CAGvEe,iCAAAA,CAAmBb,CAAQ,CACzB,mBAAA,CAAqBY,CACvB,CAAC,CAAA,CAEDR,mBAAAA,CAAO,IAAA,CACLC,gBAAAA,CAAO,KAAA,CACL,CAAA,mBAAA,EAAsBO,CAAAA,CAAiB,MAAM,CAAA,4BAAA,EAA+BZ,CAAM,CAAA,CAAA,CACpF,CACF,CACF,CAAA,8CAAA","file":"/home/runner/work/cli/cli/dist/impl-LRWZARHM.cjs","sourcesContent":[null,"import type { LocalContext } from '../../../context';\nimport { listFiles } from '../../../lib/api-keys';\nimport { consentManagersToBusinessEntities as consentManagersToBusinessEntitiesHelper } from '../../../lib/consent-manager';\nimport {\n readTranscendYaml,\n writeTranscendYaml,\n} from '../../../lib/readTranscendYaml';\nimport { join } from 'node:path';\n\nimport colors from 'colors';\nimport { logger } from '../../../logger';\nimport { existsSync, lstatSync } from 'node:fs';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation';\n\nexport interface ConsentManagersToBusinessEntitiesCommandFlags {\n consentManagerYmlFolder: string;\n output: string;\n}\n\nexport function consentManagersToBusinessEntities(\n this: LocalContext,\n {\n consentManagerYmlFolder,\n output,\n }: ConsentManagersToBusinessEntitiesCommandFlags,\n): void {\n doneInputValidation(this.process.exit);\n\n // Ensure folder is passed\n if (\n !existsSync(consentManagerYmlFolder) ||\n !lstatSync(consentManagerYmlFolder).isDirectory()\n ) {\n logger.error(\n colors.red(`Folder does not exist: \"${consentManagerYmlFolder}\"`),\n );\n this.process.exit(1);\n }\n\n // Read in each consent manager configuration\n const inputs = listFiles(consentManagerYmlFolder).map((directory) => {\n const { 'consent-manager': consentManager } = readTranscendYaml(\n join(consentManagerYmlFolder, directory),\n );\n return { name: directory, input: consentManager };\n });\n\n // Convert to business entities\n const businessEntities = consentManagersToBusinessEntitiesHelper(inputs);\n\n // write to disk\n writeTranscendYaml(output, {\n 'business-entities': businessEntities,\n });\n\n logger.info(\n colors.green(\n `Successfully wrote ${businessEntities.length} business entities to file \"${output}\"`,\n ),\n );\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/cli/cli/dist/impl-IJTQXS6O.cjs","../src/commands/inventory/consent-managers-to-business-entities/impl.ts"],"names":["consentManagersToBusinessEntities","consentManagerYmlFolder","output","doneInputValidation","existsSync","lstatSync","logger","colors","inputs","listFiles","directory","consentManager","readTranscendYaml","join","businessEntities","writeTranscendYaml"],"mappings":"AAAA,iOAA+C,wDAAyC,gCAA6B,wDAAyC,gCAA6B,wDAAyC,gCAA6B,gCAA6B,wDAAyC,gCAA6B,gCAA6B,4BCO5W,gFAEF,wBAEmB,SAQtBA,CAAAA,CAEd,CACE,uBAAA,CAAAC,CAAAA,CACA,MAAA,CAAAC,CACF,CAAA,CACM,CACNC,iCAAAA,IAAoB,CAAK,OAAA,CAAQ,IAAI,CAAA,CAAA,CAInC,CAACC,4BAAAA,CAAkC,CAAA,EACnC,CAACC,2BAAAA,CAAiC,CAAA,CAAE,WAAA,CAAY,CAAA,CAAA,EAAA,CAEhDC,mBAAAA,CAAO,KAAA,CACLC,gBAAAA,CAAO,GAAA,CAAI,CAAA,wBAAA,EAA2BN,CAAuB,CAAA,CAAA,CAAG,CAClE,CAAA,CACA,IAAA,CAAK,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CAAA,CAIrB,IAAMO,CAAAA,CAASC,iCAAAA,CAAiC,CAAA,CAAE,GAAA,CAAKC,CAAAA,EAAc,CACnE,GAAM,CAAE,iBAAA,CAAmBC,CAAe,CAAA,CAAIC,iCAAAA,wBAC5CC,CAAKZ,CAAyBS,CAAS,CACzC,CAAA,CACA,MAAO,CAAE,IAAA,CAAMA,CAAAA,CAAW,KAAA,CAAOC,CAAe,CAClD,CAAC,CAAA,CAGKG,CAAAA,CAAmBd,iCAAAA,CAA8C,CAAA,CAGvEe,iCAAAA,CAAmBb,CAAQ,CACzB,mBAAA,CAAqBY,CACvB,CAAC,CAAA,CAEDR,mBAAAA,CAAO,IAAA,CACLC,gBAAAA,CAAO,KAAA,CACL,CAAA,mBAAA,EAAsBO,CAAAA,CAAiB,MAAM,CAAA,4BAAA,EAA+BZ,CAAM,CAAA,CAAA,CACpF,CACF,CACF,CAAA,8CAAA","file":"/home/runner/work/cli/cli/dist/impl-IJTQXS6O.cjs","sourcesContent":[null,"import type { LocalContext } from '../../../context';\nimport { listFiles } from '../../../lib/api-keys';\nimport { consentManagersToBusinessEntities as consentManagersToBusinessEntitiesHelper } from '../../../lib/consent-manager';\nimport {\n readTranscendYaml,\n writeTranscendYaml,\n} from '../../../lib/readTranscendYaml';\nimport { join } from 'node:path';\n\nimport colors from 'colors';\nimport { logger } from '../../../logger';\nimport { existsSync, lstatSync } from 'node:fs';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation';\n\nexport interface ConsentManagersToBusinessEntitiesCommandFlags {\n consentManagerYmlFolder: string;\n output: string;\n}\n\nexport function consentManagersToBusinessEntities(\n this: LocalContext,\n {\n consentManagerYmlFolder,\n output,\n }: ConsentManagersToBusinessEntitiesCommandFlags,\n): void {\n doneInputValidation(this.process.exit);\n\n // Ensure folder is passed\n if (\n !existsSync(consentManagerYmlFolder) ||\n !lstatSync(consentManagerYmlFolder).isDirectory()\n ) {\n logger.error(\n colors.red(`Folder does not exist: \"${consentManagerYmlFolder}\"`),\n );\n this.process.exit(1);\n }\n\n // Read in each consent manager configuration\n const inputs = listFiles(consentManagerYmlFolder).map((directory) => {\n const { 'consent-manager': consentManager } = readTranscendYaml(\n join(consentManagerYmlFolder, directory),\n );\n return { name: directory, input: consentManager };\n });\n\n // Convert to business entities\n const businessEntities = consentManagersToBusinessEntitiesHelper(inputs);\n\n // write to disk\n writeTranscendYaml(output, {\n 'business-entities': businessEntities,\n });\n\n logger.info(\n colors.green(\n `Successfully wrote ${businessEntities.length} business entities to file \"${output}\"`,\n ),\n );\n}\n"]}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkE3HBS2DScjs = require('./chunk-E3HBS2DS.cjs');require('./chunk-LR3CPNDM.cjs');var _chunkWKCTKYN4cjs = require('./chunk-WKCTKYN4.cjs');require('./chunk-EMB64AC3.cjs');require('./chunk-LCDYXJN6.cjs');require('./chunk-ZUNVPK23.cjs');require('./chunk-4U57O4PS.cjs');require('./chunk-Q7I37FJV.cjs');async function d({file:i,transcendUrl:o,auth:r,sombraAuth:n,dataSiloId:s}){_chunkWKCTKYN4cjs.a.call(void 0, this.process.exit),await _chunkE3HBS2DScjs.e.call(void 0, {file:i,transcendUrl:o,auth:r,sombraAuth:n,dataSiloId:s})}exports.markIdentifiersCompleted = d;
2
- //# sourceMappingURL=impl-6H2SEINI.cjs.map
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5CDEM565cjs = require('./chunk-5CDEM565.cjs');require('./chunk-LR3CPNDM.cjs');var _chunkWKCTKYN4cjs = require('./chunk-WKCTKYN4.cjs');require('./chunk-JEH3FW7J.cjs');require('./chunk-LCDYXJN6.cjs');require('./chunk-ZUNVPK23.cjs');require('./chunk-OFZ7ZSEV.cjs');require('./chunk-Q7I37FJV.cjs');async function d({file:i,transcendUrl:o,auth:r,sombraAuth:n,dataSiloId:s}){_chunkWKCTKYN4cjs.a.call(void 0, this.process.exit),await _chunk5CDEM565cjs.e.call(void 0, {file:i,transcendUrl:o,auth:r,sombraAuth:n,dataSiloId:s})}exports.markIdentifiersCompleted = d;
2
+ //# sourceMappingURL=impl-JQTEIK2F.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/cli/cli/dist/impl-6H2SEINI.cjs","../src/commands/request/cron/mark-identifiers-completed/impl.ts"],"names":["markIdentifiersCompleted","file","transcendUrl","auth","sombraAuth","dataSiloId","doneInputValidation","pushCronIdentifiersFromCsv"],"mappings":"AAAA,iIAAwC,gCAA6B,wDAAyC,gCAA6B,gCAA6B,gCAA6B,gCAA6B,gCAA6B,MCY/P,SAAsBA,CAAAA,CAEpB,CACE,IAAA,CAAAC,CAAAA,CACA,YAAA,CAAAC,CAAAA,CACA,IAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CACF,CAAA,CACe,CACfC,iCAAAA,IAAoB,CAAK,OAAA,CAAQ,IAAI,CAAA,CAErC,MAAMC,iCAAAA,CACJ,IAAA,CAAAN,CAAAA,CACA,YAAA,CAAAC,CAAAA,CACA,IAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CACF,CAAC,CACH,CAAA,qCAAA","file":"/home/runner/work/cli/cli/dist/impl-6H2SEINI.cjs","sourcesContent":[null,"import type { LocalContext } from '../../../../context';\nimport { pushCronIdentifiersFromCsv } from '../../../../lib/cron';\nimport { doneInputValidation } from '../../../../lib/cli/done-input-validation';\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 {\n file,\n transcendUrl,\n auth,\n sombraAuth,\n dataSiloId,\n }: MarkIdentifiersCompletedCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n await pushCronIdentifiersFromCsv({\n file,\n transcendUrl,\n auth,\n sombraAuth,\n dataSiloId,\n });\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/cli/cli/dist/impl-JQTEIK2F.cjs","../src/commands/request/cron/mark-identifiers-completed/impl.ts"],"names":["markIdentifiersCompleted","file","transcendUrl","auth","sombraAuth","dataSiloId","doneInputValidation","pushCronIdentifiersFromCsv"],"mappings":"AAAA,iIAAwC,gCAA6B,wDAAyC,gCAA6B,gCAA6B,gCAA6B,gCAA6B,gCAA6B,MCY/P,SAAsBA,CAAAA,CAEpB,CACE,IAAA,CAAAC,CAAAA,CACA,YAAA,CAAAC,CAAAA,CACA,IAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CACF,CAAA,CACe,CACfC,iCAAAA,IAAoB,CAAK,OAAA,CAAQ,IAAI,CAAA,CAErC,MAAMC,iCAAAA,CACJ,IAAA,CAAAN,CAAAA,CACA,YAAA,CAAAC,CAAAA,CACA,IAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CACF,CAAC,CACH,CAAA,qCAAA","file":"/home/runner/work/cli/cli/dist/impl-JQTEIK2F.cjs","sourcesContent":[null,"import type { LocalContext } from '../../../../context';\nimport { pushCronIdentifiersFromCsv } from '../../../../lib/cron';\nimport { doneInputValidation } from '../../../../lib/cli/done-input-validation';\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 {\n file,\n transcendUrl,\n auth,\n sombraAuth,\n dataSiloId,\n }: MarkIdentifiersCompletedCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n await pushCronIdentifiersFromCsv({\n file,\n transcendUrl,\n auth,\n sombraAuth,\n dataSiloId,\n });\n}\n"]}
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkWKCTKYN4cjs = require('./chunk-WKCTKYN4.cjs');var _chunkEMB64AC3cjs = require('./chunk-EMB64AC3.cjs');require('./chunk-LCDYXJN6.cjs');var _chunkZUNVPK23cjs = require('./chunk-ZUNVPK23.cjs');var _chunk4U57O4PScjs = require('./chunk-4U57O4PS.cjs');require('./chunk-Q7I37FJV.cjs');var _colors = require('colors'); var _colors2 = _interopRequireDefault(_colors);var _path = require('path');var _fs = require('fs');function lt(e,t){e||(_chunkZUNVPK23cjs.a.error(_colors2.default.red("A --directory must be provided.")),t.process.exit(1));let r=[];try{r=_fs.readdirSync.call(void 0, e).filter(n=>n.endsWith(".csv")).map(n=>_path.join.call(void 0, e,n)).filter(n=>{try{return _fs.statSync.call(void 0, n).isFile()}catch (e2){return!1}})}catch(o){_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Failed to read directory: ${e}`)),_chunkZUNVPK23cjs.a.error(_colors2.default.red(o.message)),t.process.exit(1)}return r.length===0&&(_chunkZUNVPK23cjs.a.error(_colors2.default.red(`No CSV files found in directory: ${e}`)),t.process.exit(1)),r}var _os = require('os');function ct(e,t){let r=Math.max(1,_nullishCoalesce(_optionalChain([_os.availableParallelism, 'optionalCall', _2 => _2()]), () => (1)));return{poolSize:typeof e=="number"&&e>0?Math.min(e,t):Math.min(r,t),cpuCount:r}}var _child_process = require('child_process');function ut(e){return`'${String(e).replace(/'/g,"'\\''")}'`}function pt(e,t,r=!1){if(r)return;let o=_os.platform.call(void 0, );try{if(o==="darwin"){let c=e.map(ut).join(" -f "),i=`
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkWKCTKYN4cjs = require('./chunk-WKCTKYN4.cjs');var _chunkJEH3FW7Jcjs = require('./chunk-JEH3FW7J.cjs');require('./chunk-LCDYXJN6.cjs');var _chunkZUNVPK23cjs = require('./chunk-ZUNVPK23.cjs');var _chunkOFZ7ZSEVcjs = require('./chunk-OFZ7ZSEV.cjs');require('./chunk-Q7I37FJV.cjs');var _colors = require('colors'); var _colors2 = _interopRequireDefault(_colors);var _path = require('path');var _fs = require('fs');function lt(e,t){e||(_chunkZUNVPK23cjs.a.error(_colors2.default.red("A --directory must be provided.")),t.process.exit(1));let r=[];try{r=_fs.readdirSync.call(void 0, e).filter(n=>n.endsWith(".csv")).map(n=>_path.join.call(void 0, e,n)).filter(n=>{try{return _fs.statSync.call(void 0, n).isFile()}catch (e2){return!1}})}catch(o){_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Failed to read directory: ${e}`)),_chunkZUNVPK23cjs.a.error(_colors2.default.red(o.message)),t.process.exit(1)}return r.length===0&&(_chunkZUNVPK23cjs.a.error(_colors2.default.red(`No CSV files found in directory: ${e}`)),t.process.exit(1)),r}var _os = require('os');function ct(e,t){let r=Math.max(1,_nullishCoalesce(_optionalChain([_os.availableParallelism, 'optionalCall', _2 => _2()]), () => (1)));return{poolSize:typeof e=="number"&&e>0?Math.min(e,t):Math.min(r,t),cpuCount:r}}var _child_process = require('child_process');function ut(e){return`'${String(e).replace(/'/g,"'\\''")}'`}function pt(e,t,r=!1){if(r)return;let o=_os.platform.call(void 0, );try{if(o==="darwin"){let c=e.map(ut).join(" -f "),i=`
2
2
  tell application "Terminal"
3
3
  activate
4
4
  do script "printf '\\e]0;${t}\\a'; tail -n +1 -f ${c}"
@@ -14,7 +14,7 @@
14
14
  `)}
15
15
  `),process.stdout.write(`
16
16
  Press Esc/Ctrl+] to return to dashboard.
17
- `)}var _readline = require('readline'); var Tt = _interopRequireWildcard(_readline); var X = _interopRequireWildcard(_readline);async function wt(e,t,r){await new Promise(o=>{try{let n=_fs.statSync.call(void 0, e),c=Math.max(0,n.size-t),i=_fs.createReadStream.call(void 0, e,{start:c,encoding:"utf8"});i.on("data",a=>r(a)),i.on("end",o),i.on("error",o)}catch (e9){o(void 0)}})}function bt(e,t,r){if(t.ctrl&&t.name==="c")return{type:"CTRL_C"};if(r==="dashboard")return t.name&&/^[0-9]$/.test(t.name)?{type:"ATTACH",id:Number(t.name)}:t.name==="tab"&&!t.shift?{type:"CYCLE",delta:1}:t.name==="tab"&&t.shift?{type:"CYCLE",delta:-1}:t.name==="q"?{type:"QUIT"}:null;if(t.name==="escape"||t.ctrl&&t.name==="]")return{type:"DETACH"};if(t.ctrl&&t.name==="d")return{type:"CTRL_D"};let o=_nullishCoalesce(_nullishCoalesce(t.sequence, () => (e)), () => (""));return o?{type:"FORWARD",sequence:o}:null}function xt(e){return[...e.keys()].sort((t,r)=>t-r)}function St(e,t,r){if(!e.length)return null;let o=_nullishCoalesce(t, () => (e[0])),n=e.indexOf(o);return n===-1&&(n=0),n=(n+r+e.length)%e.length,e[n]}function Pt(e){let{workers:t,onAttach:r,onDetach:o,onCtrlC:n,getLogPaths:c,replayBytes:i=200*1024,replayWhich:a=["out","err"],onEnterAttachScreen:p,ports:h}=e,m=_nullishCoalesce(_optionalChain([h, 'optionalAccess', _23 => _23.stdin]), () => (process.stdin)),d=_nullishCoalesce(_optionalChain([h, 'optionalAccess', _24 => _24.stdout]), () => (process.stdout)),l=_nullishCoalesce(_optionalChain([h, 'optionalAccess', _25 => _25.stderr]), () => (process.stderr)),s=(...x)=>{if(_chunk4U57O4PScjs.z)try{(_nullishCoalesce(_optionalChain([h, 'optionalAccess', _26 => _26.stderr]), () => (process.stderr))).write(`[keys] ${x.map(String).join(" ")}
17
+ `)}var _readline = require('readline'); var Tt = _interopRequireWildcard(_readline); var X = _interopRequireWildcard(_readline);async function wt(e,t,r){await new Promise(o=>{try{let n=_fs.statSync.call(void 0, e),c=Math.max(0,n.size-t),i=_fs.createReadStream.call(void 0, e,{start:c,encoding:"utf8"});i.on("data",a=>r(a)),i.on("end",o),i.on("error",o)}catch (e9){o(void 0)}})}function bt(e,t,r){if(t.ctrl&&t.name==="c")return{type:"CTRL_C"};if(r==="dashboard")return t.name&&/^[0-9]$/.test(t.name)?{type:"ATTACH",id:Number(t.name)}:t.name==="tab"&&!t.shift?{type:"CYCLE",delta:1}:t.name==="tab"&&t.shift?{type:"CYCLE",delta:-1}:t.name==="q"?{type:"QUIT"}:null;if(t.name==="escape"||t.ctrl&&t.name==="]")return{type:"DETACH"};if(t.ctrl&&t.name==="d")return{type:"CTRL_D"};let o=_nullishCoalesce(_nullishCoalesce(t.sequence, () => (e)), () => (""));return o?{type:"FORWARD",sequence:o}:null}function xt(e){return[...e.keys()].sort((t,r)=>t-r)}function St(e,t,r){if(!e.length)return null;let o=_nullishCoalesce(t, () => (e[0])),n=e.indexOf(o);return n===-1&&(n=0),n=(n+r+e.length)%e.length,e[n]}function Pt(e){let{workers:t,onAttach:r,onDetach:o,onCtrlC:n,getLogPaths:c,replayBytes:i=200*1024,replayWhich:a=["out","err"],onEnterAttachScreen:p,ports:h}=e,m=_nullishCoalesce(_optionalChain([h, 'optionalAccess', _23 => _23.stdin]), () => (process.stdin)),d=_nullishCoalesce(_optionalChain([h, 'optionalAccess', _24 => _24.stdout]), () => (process.stdout)),l=_nullishCoalesce(_optionalChain([h, 'optionalAccess', _25 => _25.stderr]), () => (process.stderr)),s=(...x)=>{if(_chunkOFZ7ZSEVcjs.z)try{(_nullishCoalesce(_optionalChain([h, 'optionalAccess', _26 => _26.stderr]), () => (process.stderr))).write(`[keys] ${x.map(String).join(" ")}
18
18
  `)}catch (e10){}};if(!m.isTTY)return()=>{};Tt.emitKeypressEvents(m),_optionalChain([m, 'access', _27 => _27.setRawMode, 'optionalCall', _28 => _28(!0)]);let u="dashboard",g=null,T=null,C=null;async function E(x){if(!c)return;let f=c(x);if(!f)return;let y=[];for(let b of a)b==="out"&&y.push(f.outPath),b==="err"&&y.push(f.errPath),b==="structured"&&y.push(f.structuredPath);if(y.length){d.write(`
19
19
  ------------ replay ------------
20
20
  `);for(let b of y)d.write(`
@@ -24,7 +24,7 @@ Press Esc/Ctrl+] to return to dashboard.
24
24
 
25
25
  `)}}let R=async x=>{s("attach()",`id=${x}`);let f=t.get(x);if(!f)return;u==="attached"&&P(),u="attached",g=x,_optionalChain([p, 'optionalCall', _29 => _29(x)]),_optionalChain([r, 'optionalCall', _30 => _30(x)]),await E(x),T=b=>d.write(b),C=b=>l.write(b),_optionalChain([f, 'access', _31 => _31.stdout, 'optionalAccess', _32 => _32.on, 'call', _33 => _33("data",T)]),_optionalChain([f, 'access', _34 => _34.stderr, 'optionalAccess', _35 => _35.on, 'call', _36 => _36("data",C)]);let y=()=>{g===x&&P()};f.once("exit",y)},P=()=>{if(s("detach()",`id=${g}`),g==null)return;let x=g,f=t.get(x);f&&(T&&_optionalChain([f, 'access', _37 => _37.stdout, 'optionalAccess', _38 => _38.off, 'call', _39 => _39("data",T)]),C&&_optionalChain([f, 'access', _40 => _40.stderr, 'optionalAccess', _41 => _41.off, 'call', _42 => _42("data",C)])),T=null,C=null,g=null,u="dashboard",_optionalChain([o, 'optionalCall', _43 => _43()])},S=(x,f)=>{s("keypress",JSON.stringify({str:x,name:f.name,seq:f.sequence,ctrl:f.ctrl,meta:f.meta,shift:f.shift,mode:u}));let y=bt(x,f,u);if(s("mapped",JSON.stringify(y)),!!y)switch(y.type){case"CTRL_C":{if(s("CTRL_C"),u==="attached"&&g!=null){let b=t.get(g);try{_optionalChain([b, 'optionalAccess', _44 => _44.kill, 'call', _45 => _45("SIGINT")])}catch (e11){}P();return}_optionalChain([n, 'optionalCall', _46 => _46()]);return}case"ATTACH":{if(s("ATTACH",`id=${y.id}`,`has=${t.has(y.id)}`),u!=="dashboard")return;t.has(y.id)&&R(y.id);return}case"CYCLE":{if(s("CYCLE",`delta=${y.delta}`),u!=="dashboard")return;let b=St(xt(t),g,y.delta);b!=null&&R(b);return}case"QUIT":{if(u!=="dashboard")return;_optionalChain([n, 'optionalCall', _47 => _47()]);return}case"DETACH":{s("DETACH"),u==="attached"&&P();return}case"CTRL_D":{if(u==="attached"&&g!=null){let b=t.get(g);try{_optionalChain([b, 'optionalAccess', _48 => _48.stdin, 'optionalAccess', _49 => _49.end, 'call', _50 => _50()])}catch (e12){}}return}case"FORWARD":if(u==="attached"&&g!=null){let b=t.get(g);try{_optionalChain([b, 'optionalAccess', _51 => _51.stdin, 'optionalAccess', _52 => _52.write, 'call', _53 => _53(y.sequence)])}catch (e13){}}}},M=x=>{if(u==="attached"&&g!=null){let f=t.get(g);try{_optionalChain([f, 'optionalAccess', _54 => _54.stdin, 'optionalAccess', _55 => _55.write, 'call', _56 => _56(x)])}catch (e14){}}},A=()=>{m.off("keypress",S),m.off("data",M),_optionalChain([m, 'access', _57 => _57.setRawMode, 'optionalCall', _58 => _58(!1)]),d.write("\x1B[?25h")};return m.on("keypress",S),m.on("data",M),A}var _events = require('events');var _url = require('url');var Ct="",ie=(e,t)=>{let r=Math.min(e-1,9),o=e<=1?"0":`0-${r}`,n=e>10?" (Tab/Shift+Tab for \u226510)":"";return t?_colors2.default.dim("Run complete \u2014 digits to view logs \u2022 Tab/Shift+Tab cycle \u2022 Esc/Ctrl+] detach \u2022 q to quit"):_colors2.default.dim(`Hotkeys: [${o}] attach${n} \u2022 e=errors \u2022 w=warnings \u2022 i=info \u2022 l=logs \u2022 Tab/Shift+Tab \u2022 Esc/Ctrl+] detach \u2022 Ctrl+C exit`)};function vt(e,t,r=!1){let o=[...t.renderHeader(e),"",...t.renderWorkers(e),...r?[]:["",ie(e.poolSize,e.final)],...t.renderExtras?[""].concat(t.renderExtras(e)):[]].join(`
26
26
  `);!e.final&&o===Ct||(Ct=o,e.final?process.stdout.write("\x1B[?25h"):(process.stdout.write("\x1B[?25l"),X.cursorTo(process.stdout,0,0),X.clearScreenDown(process.stdout)),process.stdout.write(`${o}
27
- `))}function Z(e,t,r){let o=t.get(e);if(F(o))try{let n=V(o);if(n!=null)return n}catch (e15){}return r.get(e)}function I(e){return typeof e=="number"?e.toLocaleString():"0"}function Lt(e,t=40){let r=Math.max(0,Math.min(100,Math.floor(e))),o=Math.floor(r/100*t);return"\u2588".repeat(o)+"\u2591".repeat(t-o)}function le(e){let t=[...e.workerState.values()].filter(n=>n.busy).length,r=e.filesCompleted+e.filesFailed,o=e.filesTotal===0?100:Math.floor(r/Math.max(1,e.filesTotal)*100);return{done:r,inProgress:t,pct:o}}function $t(e,t=[]){let{title:r,poolSize:o,cpuCount:n,filesTotal:c,filesCompleted:i,filesFailed:a,throughput:p}=e,{inProgress:h,pct:m}=le(e),d=[`${_colors2.default.bold(r)} \u2014 ${o} workers ${_colors2.default.dim(`(CPU avail: ${n})`)}`,`${_colors2.default.dim("Files")} ${I(c)} ${_colors2.default.dim("Completed")} ${I(i)} ${_colors2.default.dim("Failed")} ${a?_colors2.default.red(I(a)):I(a)} ${_colors2.default.dim("In-flight")} ${I(h)}`,`[${Lt(m)}] ${m}%`];if(p){let l=Math.round(p.r10s*3600).toLocaleString(),s=Math.round(p.r60s*3600).toLocaleString(),u=_optionalChain([e, 'access', _59 => _59.throughput, 'optionalAccess', _60 => _60.successSoFar])!=null?` Newly uploaded: ${I(e.throughput.successSoFar)}`:"";d.push(_colors2.default.cyan(`Throughput: ${l}/hr (1h: ${s}/hr)${u}`))}return t.length?d.concat(t):d}function Rt(e,t=r=>r?_path.basename.call(void 0, r):"-"){return[...e.workerState.entries()].map(([o,n])=>{let c=n.lastLevel==="error"?_colors2.default.red("ERROR "):n.lastLevel==="warn"?_colors2.default.yellow("WARN "):n.busy?_colors2.default.green("WORKING"):_colors2.default.dim("IDLE "),i=t(n.file),a=n.startedAt?`${Math.floor((Date.now()-n.startedAt)/1e3)}s`:"-",p=_nullishCoalesce(_optionalChain([n, 'access', _61 => _61.progress, 'optionalAccess', _62 => _62.processed]), () => (0)),h=_nullishCoalesce(_optionalChain([n, 'access', _63 => _63.progress, 'optionalAccess', _64 => _64.total]), () => (0)),m=h>0?Math.floor(p/h*100):0,d=h>0?Lt(m,18):" ".repeat(18),l=h>0?`${p.toLocaleString()}/${h.toLocaleString()} (${m}%)`:_colors2.default.dim("\u2014");return` [w${o}] ${c} | ${i} | ${a} | [${d}] ${l}`})}async function Et(e){let{title:t,baseDir:r,poolSize:o,cpuCount:n,render:c,childModulePath:i,hooks:a,filesTotal:p,childFlag:h,viewerMode:m=!1}=e,d=_nullishCoalesce(e.openLogWindows, () => (!m)),l=_nullishCoalesce(e.isSilent, () => (!0)),s=Date.now(),u=mt(r),g=new Map,T=new Map,C=new Map,E=new _chunkEMB64AC3cjs.Vf,P=_nullishCoalesce(_optionalChain([a, 'access', _65 => _65.initTotals, 'optionalCall', _66 => _66()]), () => ({})),S=0,M=0,A=0,x=null,f=!1,y=!1,b=null,L=(w=!1)=>{y||c({title:t,poolSize:o,cpuCount:n,filesTotal:p,filesCompleted:M,filesFailed:A,workerState:T,totals:P,final:w,exportStatus:_optionalChain([a, 'access', _67 => _67.exportStatus, 'optionalCall', _68 => _68()]),throughput:{successSoFar:M,r10s:E.rate(1e4),r60s:E.rate(6e4)}})},B=w=>{let $=a.nextTask();if(!$)return!1;let _=g.get(w),v=a.taskLabel($),O=_optionalChain([a, 'access', _69 => _69.initSlotProgress, 'optionalCall', _70 => _70($)]);return T.set(w,{busy:!0,file:v,startedAt:Date.now(),lastLevel:"ok",progress:O}),Q(_,{type:"task",payload:$}),L(),!0};for(let w=0;w<o;w+=1){let $=gt({id:w,modulePath:i,logDir:u,openLogWindows:d,isSilent:l,childFlag:h});g.set(w,$),T.set(w,{busy:!1,file:null,startedAt:null,lastLevel:"ok"}),C.set(w,V($)),S+=1;let _=N(v=>{let O=U(v);if(!O)return;let G=T.get(w);G.lastLevel!==O&&(T.set(w,{...G,lastLevel:O}),L())});_optionalChain([$, 'access', _71 => _71.stderr, 'optionalAccess', _72 => _72.on, 'call', _73 => _73("data",_)]),$.on("message",v=>{if(!(!v||typeof v!="object")){if(v.type==="ready"){f||(f=!0,x=setInterval(()=>L(!1),350)),B(w);return}if(v.type==="progress"){P=a.onProgress(P,v.payload);let O=T.get(w);T.set(w,{...O,progress:v.payload}),L();return}if(v.type==="result"){let O=T.get(w),{totals:G,ok:ot}=a.onResult(P,v.payload);P=G,ot?(M+=1,E.add(1)):A+=1,T.set(w,{...O,busy:!1,file:null,progress:void 0,lastLevel:ot?"ok":"error"}),!B(w)&&F($)&&Q($,{type:"shutdown"}),L()}}}),$.on("exit",()=>{S-=1,S===0&&(x&&clearInterval(x),L(!0))})}let H=()=>{},K=()=>{try{_optionalChain([process, 'access', _74 => _74.stdin, 'access', _75 => _75.setRawMode, 'optionalCall', _76 => _76(!1)])}catch (e16){}try{process.stdin.pause()}catch (e17){}},et=()=>{if(x&&clearInterval(x),_optionalChain([H, 'optionalCall', _77 => _77()]),b)try{process.stdin.off("data",b)}catch (e18){}K(),process.stdout.write(`
27
+ `))}function Z(e,t,r){let o=t.get(e);if(F(o))try{let n=V(o);if(n!=null)return n}catch (e15){}return r.get(e)}function I(e){return typeof e=="number"?e.toLocaleString():"0"}function Lt(e,t=40){let r=Math.max(0,Math.min(100,Math.floor(e))),o=Math.floor(r/100*t);return"\u2588".repeat(o)+"\u2591".repeat(t-o)}function le(e){let t=[...e.workerState.values()].filter(n=>n.busy).length,r=e.filesCompleted+e.filesFailed,o=e.filesTotal===0?100:Math.floor(r/Math.max(1,e.filesTotal)*100);return{done:r,inProgress:t,pct:o}}function $t(e,t=[]){let{title:r,poolSize:o,cpuCount:n,filesTotal:c,filesCompleted:i,filesFailed:a,throughput:p}=e,{inProgress:h,pct:m}=le(e),d=[`${_colors2.default.bold(r)} \u2014 ${o} workers ${_colors2.default.dim(`(CPU avail: ${n})`)}`,`${_colors2.default.dim("Files")} ${I(c)} ${_colors2.default.dim("Completed")} ${I(i)} ${_colors2.default.dim("Failed")} ${a?_colors2.default.red(I(a)):I(a)} ${_colors2.default.dim("In-flight")} ${I(h)}`,`[${Lt(m)}] ${m}%`];if(p){let l=Math.round(p.r10s*3600).toLocaleString(),s=Math.round(p.r60s*3600).toLocaleString(),u=_optionalChain([e, 'access', _59 => _59.throughput, 'optionalAccess', _60 => _60.successSoFar])!=null?` Newly uploaded: ${I(e.throughput.successSoFar)}`:"";d.push(_colors2.default.cyan(`Throughput: ${l}/hr (1h: ${s}/hr)${u}`))}return t.length?d.concat(t):d}function Rt(e,t=r=>r?_path.basename.call(void 0, r):"-"){return[...e.workerState.entries()].map(([o,n])=>{let c=n.lastLevel==="error"?_colors2.default.red("ERROR "):n.lastLevel==="warn"?_colors2.default.yellow("WARN "):n.busy?_colors2.default.green("WORKING"):_colors2.default.dim("IDLE "),i=t(n.file),a=n.startedAt?`${Math.floor((Date.now()-n.startedAt)/1e3)}s`:"-",p=_nullishCoalesce(_optionalChain([n, 'access', _61 => _61.progress, 'optionalAccess', _62 => _62.processed]), () => (0)),h=_nullishCoalesce(_optionalChain([n, 'access', _63 => _63.progress, 'optionalAccess', _64 => _64.total]), () => (0)),m=h>0?Math.floor(p/h*100):0,d=h>0?Lt(m,18):" ".repeat(18),l=h>0?`${p.toLocaleString()}/${h.toLocaleString()} (${m}%)`:_colors2.default.dim("\u2014");return` [w${o}] ${c} | ${i} | ${a} | [${d}] ${l}`})}async function Et(e){let{title:t,baseDir:r,poolSize:o,cpuCount:n,render:c,childModulePath:i,hooks:a,filesTotal:p,childFlag:h,viewerMode:m=!1}=e,d=_nullishCoalesce(e.openLogWindows, () => (!m)),l=_nullishCoalesce(e.isSilent, () => (!0)),s=Date.now(),u=mt(r),g=new Map,T=new Map,C=new Map,E=new _chunkJEH3FW7Jcjs.Yf,P=_nullishCoalesce(_optionalChain([a, 'access', _65 => _65.initTotals, 'optionalCall', _66 => _66()]), () => ({})),S=0,M=0,A=0,x=null,f=!1,y=!1,b=null,L=(w=!1)=>{y||c({title:t,poolSize:o,cpuCount:n,filesTotal:p,filesCompleted:M,filesFailed:A,workerState:T,totals:P,final:w,exportStatus:_optionalChain([a, 'access', _67 => _67.exportStatus, 'optionalCall', _68 => _68()]),throughput:{successSoFar:M,r10s:E.rate(1e4),r60s:E.rate(6e4)}})},B=w=>{let $=a.nextTask();if(!$)return!1;let _=g.get(w),v=a.taskLabel($),O=_optionalChain([a, 'access', _69 => _69.initSlotProgress, 'optionalCall', _70 => _70($)]);return T.set(w,{busy:!0,file:v,startedAt:Date.now(),lastLevel:"ok",progress:O}),Q(_,{type:"task",payload:$}),L(),!0};for(let w=0;w<o;w+=1){let $=gt({id:w,modulePath:i,logDir:u,openLogWindows:d,isSilent:l,childFlag:h});g.set(w,$),T.set(w,{busy:!1,file:null,startedAt:null,lastLevel:"ok"}),C.set(w,V($)),S+=1;let _=N(v=>{let O=U(v);if(!O)return;let G=T.get(w);G.lastLevel!==O&&(T.set(w,{...G,lastLevel:O}),L())});_optionalChain([$, 'access', _71 => _71.stderr, 'optionalAccess', _72 => _72.on, 'call', _73 => _73("data",_)]),$.on("message",v=>{if(!(!v||typeof v!="object")){if(v.type==="ready"){f||(f=!0,x=setInterval(()=>L(!1),350)),B(w);return}if(v.type==="progress"){P=a.onProgress(P,v.payload);let O=T.get(w);T.set(w,{...O,progress:v.payload}),L();return}if(v.type==="result"){let O=T.get(w),{totals:G,ok:ot}=a.onResult(P,v.payload);P=G,ot?(M+=1,E.add(1)):A+=1,T.set(w,{...O,busy:!1,file:null,progress:void 0,lastLevel:ot?"ok":"error"}),!B(w)&&F($)&&Q($,{type:"shutdown"}),L()}}}),$.on("exit",()=>{S-=1,S===0&&(x&&clearInterval(x),L(!0))})}let H=()=>{},K=()=>{try{_optionalChain([process, 'access', _74 => _74.stdin, 'access', _75 => _75.setRawMode, 'optionalCall', _76 => _76(!1)])}catch (e16){}try{process.stdin.pause()}catch (e17){}},et=()=>{if(x&&clearInterval(x),_optionalChain([H, 'optionalCall', _77 => _77()]),b)try{process.stdin.off("data",b)}catch (e18){}K(),process.stdout.write(`
28
28
  Stopping workers...
29
29
  `);for(let[,w]of g){F(w)&&Q(w,{type:"shutdown"});try{_optionalChain([w, 'optionalAccess', _78 => _78.kill, 'call', _79 => _79("SIGTERM")])}catch (e19){}}process.exit(130)},rt=w=>{y=!0,process.stdout.write("\x1B[2J\x1B[H"),process.stdout.write(`Attached to worker ${w}. (Esc/Ctrl+] detach \u2022 Ctrl+D EOF \u2022 Ctrl+C SIGINT)
30
30
  `)},jt=()=>{y=!1,L()};if(process.once("SIGINT",et),!m){if(process.stdin.isTTY){try{process.stdin.setRawMode(!0)}catch (e20){process.stdout.write(_colors2.default.yellow(`Warning: Unable to enable raw mode for interactive key handling.
@@ -34,5 +34,5 @@ Stopping workers...
34
34
 
35
35
  `),(async()=>{try{await yt(t,l,s)}catch (e22){h=!1,o(!1),r()}})())},d=(l,s)=>{if(n)try{let u=n.exportCombinedLogs(t,l);a(`
36
36
  Wrote combined ${s} logs to: ${u}`),p(l,u)}catch (e23){a(`
37
- Failed to write combined ${s} logs`)}};return l=>{let s=l.toString("utf8");if(s==="e"){m(["err"],"error");return}if(s==="w"){m(["warn","err"],"warn");return}if(s==="i"){m(["info"],"all");return}if(s==="l"){m(["out","err","structured"],"all");return}if(s==="E"){d("error","error");return}if(s==="W"){d("warn","warn");return}if(s==="I"){d("info","info");return}if(s==="A"){d("all","ALL");return}let u=_optionalChain([i, 'optionalAccess', _84 => _84[s]]);if(u){u({noteExport:p,say:a});return}(s==="\x1B"||s==="")&&(h=!1,o(!1),r())}}var _promises = require('fs/promises');var _promises3 = require('stream/promises');var _stream = require('stream');var _csvparse = require('csv-parse');var _fastcsv = require('fast-csv'); var Bt = _interopRequireWildcard(_fastcsv);function tt(e,t){let r=_fs.createWriteStream.call(void 0, e),o=Bt.format({headers:t,writeHeaders:!0,objectMode:!0});return o.pipe(r),{async write(n){o.write(n)||await _events.once.call(void 0, o,"drain")},async end(){let n=Promise.all([_events.once.call(void 0, r,"finish")]);o.end(),await n}}}function xe(e){return String(e).padStart(4,"0")}function Se(e){return Buffer.byteLength(Object.values(e).map(t=>t==null?"":String(t)).join(","),"utf8")}async function Dt(e){let{filePath:t,outputDir:r,clearOutputDir:o,chunkSizeMB:n,onProgress:c,reportEveryMs:i=500}=e,{size:a}=await _promises.stat.call(void 0, t),p=0;_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Chunking ${t} into ~${n}MB files...`));let h=Math.floor(n*1024*1024),m=_path.basename.call(void 0, t,".csv"),d=r||_path.dirname.call(void 0, t);if(_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Output directory: ${d}`)),await _promises.mkdir.call(void 0, d,{recursive:!0}),o){_chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(`Clearing output directory: ${d}`));let f=await _promises.readdir.call(void 0, d);await Promise.all(f.filter(y=>y.startsWith(`${m}_chunk_`)&&y.endsWith(".csv")).map(y=>_promises.unlink.call(void 0, _path.join.call(void 0, d,y))))}let l=null,s=null,u=0,g=1,T=0,C=new (0, _csvparse.Parser)({columns:!1,skip_empty_lines:!0}),E=0,R=0,P=()=>{let f=R>0?E/R:0,y=f>0?Math.max(u,Math.ceil(a/f)):void 0;c(u,y),p=Date.now()};P();let S=null,M=()=>_path.join.call(void 0, d,`${m}_chunk_${xe(g)}.csv`),A=new (0, _stream.Transform)({objectMode:!0,async transform(f,y,b){try{if(!l){l=f.slice(0),s=l.length,S=tt(M(),l),b();return}s!==null&&f.length!==s&&_chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(`Row has ${f.length} cols; expected ${s}`)),u+=1,u%25e4===0&&c(u);let L=Object.fromEntries(l.map((H,K)=>[H,f[K]])),B=Se(L);E+=B,R+=1,Date.now()-p>=i&&P(),S&&T>0&&T+B>h&&(await S.end(),g+=1,T=0,_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Rolling to chunk ${g} after ${u.toLocaleString()} rows.`)),S=tt(M(),l)),S||(S=tt(M(),l)),await S.write(L),T+=B,b()}catch(L){b(L)}},async flush(f){try{S&&(await S.end(),S=null),P(),f()}catch(y){f(y)}}}),x=_fs.createReadStream.call(void 0, t);await _promises3.pipeline.call(void 0, x,C,A),c(u),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Chunked ${t} into ${g} file(s); processed ${u.toLocaleString()} rows.`))}async function Ft(){let e=Number(process.env.WORKER_ID||"0");_chunkZUNVPK23cjs.a.info(`[w${e}] ready pid=${process.pid}`),_optionalChain([process, 'access', _85 => _85.send, 'optionalCall', _86 => _86({type:"ready"})]),process.on("message",async t=>{if(!t||typeof t!="object"||(t.type==="shutdown"&&process.exit(0),t.type!=="task"))return;let{filePath:r,options:o}=t.payload,{outputDir:n,clearOutputDir:c,chunkSizeMB:i}=o;try{await Dt({filePath:r,outputDir:n,clearOutputDir:c,chunkSizeMB:i,onProgress:(a,p)=>_optionalChain([process, 'access', _87 => _87.send, 'optionalCall', _88 => _88({type:"progress",payload:{filePath:r,processed:a,total:p}})])}),_optionalChain([process, 'access', _89 => _89.send, 'optionalCall', _90 => _90({type:"result",payload:{ok:!0,filePath:r}})])}catch(a){let p=_chunkEMB64AC3cjs.Qf.call(void 0, a);_chunkZUNVPK23cjs.a.error(`[w${e}] ERROR ${r}: ${p}`),_optionalChain([process, 'access', _91 => _91.send, 'optionalCall', _92 => _92({type:"result",payload:{ok:!1,filePath:r,error:p}})])}}),await new Promise(()=>{})}function Te(e){return $t(e)}function Pe(e){return Rt(e)}var It={renderHeader:Te,renderWorkers:Pe};function Ce(){return typeof __filename<"u"?__filename:process.argv[1]}async function Do(e){_chunkWKCTKYN4cjs.a.call(void 0, this.process.exit);let{directory:t,outputDir:r,clearOutputDir:o,chunkSizeMB:n,concurrency:c,viewerMode:i}=e,a=lt(t,this),{poolSize:p,cpuCount:h}=ct(c,a.length);_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Chunking ${a.length} CSV file(s) with pool size ${p} (CPU=${h})`));let m=a.map(l=>({filePath:l,options:{outputDir:r,clearOutputDir:o,chunkSizeMB:n}})),d={nextTask:()=>m.shift(),taskLabel:l=>l.filePath,initTotals:()=>({}),initSlotProgress:()=>{},onProgress:l=>l,onResult:(l,s)=>({totals:l,ok:!!s.ok}),postProcess:async()=>{}};await Et({title:"Chunk CSV",baseDir:t||r||process.cwd(),childFlag:Y,childModulePath:Ce(),poolSize:p,cpuCount:h,filesTotal:a.length,hooks:d,viewerMode:i,render:l=>vt(l,It,i),extraKeyHandler:({logsBySlot:l,repaint:s,setPaused:u})=>Mt({logsBySlot:l,repaint:s,setPaused:u})})}process.argv.includes(Y)&&Ft().catch(e=>{_chunkZUNVPK23cjs.a.error(e),process.exit(1)});exports.chunkCsv = Do;
38
- //# sourceMappingURL=impl-ABEIAAXG.cjs.map
37
+ Failed to write combined ${s} logs`)}};return l=>{let s=l.toString("utf8");if(s==="e"){m(["err"],"error");return}if(s==="w"){m(["warn","err"],"warn");return}if(s==="i"){m(["info"],"all");return}if(s==="l"){m(["out","err","structured"],"all");return}if(s==="E"){d("error","error");return}if(s==="W"){d("warn","warn");return}if(s==="I"){d("info","info");return}if(s==="A"){d("all","ALL");return}let u=_optionalChain([i, 'optionalAccess', _84 => _84[s]]);if(u){u({noteExport:p,say:a});return}(s==="\x1B"||s==="")&&(h=!1,o(!1),r())}}var _promises = require('fs/promises');var _promises3 = require('stream/promises');var _stream = require('stream');var _csvparse = require('csv-parse');var _fastcsv = require('fast-csv'); var Bt = _interopRequireWildcard(_fastcsv);function tt(e,t){let r=_fs.createWriteStream.call(void 0, e),o=Bt.format({headers:t,writeHeaders:!0,objectMode:!0});return o.pipe(r),{async write(n){o.write(n)||await _events.once.call(void 0, o,"drain")},async end(){let n=Promise.all([_events.once.call(void 0, r,"finish")]);o.end(),await n}}}function xe(e){return String(e).padStart(4,"0")}function Se(e){return Buffer.byteLength(Object.values(e).map(t=>t==null?"":String(t)).join(","),"utf8")}async function Dt(e){let{filePath:t,outputDir:r,clearOutputDir:o,chunkSizeMB:n,onProgress:c,reportEveryMs:i=500}=e,{size:a}=await _promises.stat.call(void 0, t),p=0;_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Chunking ${t} into ~${n}MB files...`));let h=Math.floor(n*1024*1024),m=_path.basename.call(void 0, t,".csv"),d=r||_path.dirname.call(void 0, t);if(_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Output directory: ${d}`)),await _promises.mkdir.call(void 0, d,{recursive:!0}),o){_chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(`Clearing output directory: ${d}`));let f=await _promises.readdir.call(void 0, d);await Promise.all(f.filter(y=>y.startsWith(`${m}_chunk_`)&&y.endsWith(".csv")).map(y=>_promises.unlink.call(void 0, _path.join.call(void 0, d,y))))}let l=null,s=null,u=0,g=1,T=0,C=new (0, _csvparse.Parser)({columns:!1,skip_empty_lines:!0}),E=0,R=0,P=()=>{let f=R>0?E/R:0,y=f>0?Math.max(u,Math.ceil(a/f)):void 0;c(u,y),p=Date.now()};P();let S=null,M=()=>_path.join.call(void 0, d,`${m}_chunk_${xe(g)}.csv`),A=new (0, _stream.Transform)({objectMode:!0,async transform(f,y,b){try{if(!l){l=f.slice(0),s=l.length,S=tt(M(),l),b();return}s!==null&&f.length!==s&&_chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(`Row has ${f.length} cols; expected ${s}`)),u+=1,u%25e4===0&&c(u);let L=Object.fromEntries(l.map((H,K)=>[H,f[K]])),B=Se(L);E+=B,R+=1,Date.now()-p>=i&&P(),S&&T>0&&T+B>h&&(await S.end(),g+=1,T=0,_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Rolling to chunk ${g} after ${u.toLocaleString()} rows.`)),S=tt(M(),l)),S||(S=tt(M(),l)),await S.write(L),T+=B,b()}catch(L){b(L)}},async flush(f){try{S&&(await S.end(),S=null),P(),f()}catch(y){f(y)}}}),x=_fs.createReadStream.call(void 0, t);await _promises3.pipeline.call(void 0, x,C,A),c(u),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Chunked ${t} into ${g} file(s); processed ${u.toLocaleString()} rows.`))}async function Ft(){let e=Number(process.env.WORKER_ID||"0");_chunkZUNVPK23cjs.a.info(`[w${e}] ready pid=${process.pid}`),_optionalChain([process, 'access', _85 => _85.send, 'optionalCall', _86 => _86({type:"ready"})]),process.on("message",async t=>{if(!t||typeof t!="object"||(t.type==="shutdown"&&process.exit(0),t.type!=="task"))return;let{filePath:r,options:o}=t.payload,{outputDir:n,clearOutputDir:c,chunkSizeMB:i}=o;try{await Dt({filePath:r,outputDir:n,clearOutputDir:c,chunkSizeMB:i,onProgress:(a,p)=>_optionalChain([process, 'access', _87 => _87.send, 'optionalCall', _88 => _88({type:"progress",payload:{filePath:r,processed:a,total:p}})])}),_optionalChain([process, 'access', _89 => _89.send, 'optionalCall', _90 => _90({type:"result",payload:{ok:!0,filePath:r}})])}catch(a){let p=_chunkJEH3FW7Jcjs.Tf.call(void 0, a);_chunkZUNVPK23cjs.a.error(`[w${e}] ERROR ${r}: ${p}`),_optionalChain([process, 'access', _91 => _91.send, 'optionalCall', _92 => _92({type:"result",payload:{ok:!1,filePath:r,error:p}})])}}),await new Promise(()=>{})}function Te(e){return $t(e)}function Pe(e){return Rt(e)}var It={renderHeader:Te,renderWorkers:Pe};function Ce(){return typeof __filename<"u"?__filename:process.argv[1]}async function Do(e){_chunkWKCTKYN4cjs.a.call(void 0, this.process.exit);let{directory:t,outputDir:r,clearOutputDir:o,chunkSizeMB:n,concurrency:c,viewerMode:i}=e,a=lt(t,this),{poolSize:p,cpuCount:h}=ct(c,a.length);_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Chunking ${a.length} CSV file(s) with pool size ${p} (CPU=${h})`));let m=a.map(l=>({filePath:l,options:{outputDir:r,clearOutputDir:o,chunkSizeMB:n}})),d={nextTask:()=>m.shift(),taskLabel:l=>l.filePath,initTotals:()=>({}),initSlotProgress:()=>{},onProgress:l=>l,onResult:(l,s)=>({totals:l,ok:!!s.ok}),postProcess:async()=>{}};await Et({title:"Chunk CSV",baseDir:t||r||process.cwd(),childFlag:Y,childModulePath:Ce(),poolSize:p,cpuCount:h,filesTotal:a.length,hooks:d,viewerMode:i,render:l=>vt(l,It,i),extraKeyHandler:({logsBySlot:l,repaint:s,setPaused:u})=>Mt({logsBySlot:l,repaint:s,setPaused:u})})}process.argv.includes(Y)&&Ft().catch(e=>{_chunkZUNVPK23cjs.a.error(e),process.exit(1)});exports.chunkCsv = Do;
38
+ //# sourceMappingURL=impl-KULLM3ES.cjs.map