@transcend-io/cli 7.0.5 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -4
- package/dist/bin/bash-complete.cjs +1 -1
- package/dist/bin/cli.cjs +1 -1
- package/dist/bin/deprecated-command.cjs +2 -2
- package/dist/{chunk-L7NHDBBN.cjs → chunk-2FBBA65B.cjs} +3 -3
- package/dist/{chunk-L7NHDBBN.cjs.map → chunk-2FBBA65B.cjs.map} +1 -1
- package/dist/{chunk-K4QC24DY.cjs → chunk-327HQXYV.cjs} +2 -2
- package/dist/{chunk-K4QC24DY.cjs.map → chunk-327HQXYV.cjs.map} +1 -1
- package/dist/{chunk-XWMFHJGK.cjs → chunk-3G77IGKQ.cjs} +2 -2
- package/dist/{chunk-XWMFHJGK.cjs.map → chunk-3G77IGKQ.cjs.map} +1 -1
- package/dist/{chunk-EUDUZQOO.cjs → chunk-5JXP3N7U.cjs} +4 -4
- package/dist/{chunk-EUDUZQOO.cjs.map → chunk-5JXP3N7U.cjs.map} +1 -1
- package/dist/{chunk-XXVZA7HN.cjs → chunk-74OAET6D.cjs} +2 -2
- package/dist/{chunk-XXVZA7HN.cjs.map → chunk-74OAET6D.cjs.map} +1 -1
- package/dist/{chunk-RQWXNYMW.cjs → chunk-AFYBKLWT.cjs} +2 -2
- package/dist/{chunk-RQWXNYMW.cjs.map → chunk-AFYBKLWT.cjs.map} +1 -1
- package/dist/{chunk-QBBOYJ3O.cjs → chunk-EAJZX4TX.cjs} +2 -2
- package/dist/{chunk-QBBOYJ3O.cjs.map → chunk-EAJZX4TX.cjs.map} +1 -1
- package/dist/{chunk-UTG3LZO7.cjs → chunk-I4XVTF53.cjs} +2 -2
- package/dist/{chunk-UTG3LZO7.cjs.map → chunk-I4XVTF53.cjs.map} +1 -1
- package/dist/{chunk-SAEKBZGF.cjs → chunk-LCDYXJN6.cjs} +2 -2
- package/dist/{chunk-SAEKBZGF.cjs.map → chunk-LCDYXJN6.cjs.map} +1 -1
- package/dist/{chunk-YGAK4NBT.cjs → chunk-NNMCZMFJ.cjs} +2 -2
- package/dist/{chunk-YGAK4NBT.cjs.map → chunk-NNMCZMFJ.cjs.map} +1 -1
- package/dist/{chunk-NSKHXTBW.cjs → chunk-NW3O6OPS.cjs} +2 -2
- package/dist/{chunk-NSKHXTBW.cjs.map → chunk-NW3O6OPS.cjs.map} +1 -1
- package/dist/{chunk-6W7CSPHF.cjs → chunk-PIJPXUK5.cjs} +3 -3
- package/dist/{chunk-6W7CSPHF.cjs.map → chunk-PIJPXUK5.cjs.map} +1 -1
- package/dist/chunk-Q7I37FJV.cjs +2 -0
- package/dist/chunk-Q7I37FJV.cjs.map +1 -0
- package/dist/chunk-R77JR6OQ.cjs +2919 -0
- package/dist/chunk-R77JR6OQ.cjs.map +1 -0
- package/dist/chunk-UWUR56CO.cjs +2 -0
- package/dist/chunk-UWUR56CO.cjs.map +1 -0
- package/dist/chunk-VIPFYWRR.cjs +2 -0
- package/dist/chunk-VIPFYWRR.cjs.map +1 -0
- package/dist/{chunk-X37NM7FZ.cjs → chunk-VMGXBH6E.cjs} +19 -19
- package/dist/{chunk-X37NM7FZ.cjs.map → chunk-VMGXBH6E.cjs.map} +1 -1
- package/dist/{chunk-N27TJLBG.cjs → chunk-YK5YCHD6.cjs} +2 -2
- package/dist/{chunk-N27TJLBG.cjs.map → chunk-YK5YCHD6.cjs.map} +1 -1
- package/dist/{chunk-TET6I2QK.cjs → chunk-Z2PA2QDO.cjs} +2 -2
- package/dist/{chunk-TET6I2QK.cjs.map → chunk-Z2PA2QDO.cjs.map} +1 -1
- package/dist/{impl-O2M7RVTK.cjs → impl-275S73PA.cjs} +2 -2
- package/dist/{impl-O2M7RVTK.cjs.map → impl-275S73PA.cjs.map} +1 -1
- package/dist/{impl-JG5TMU6H.cjs → impl-2ZHRCHKL.cjs} +2 -2
- package/dist/{impl-JG5TMU6H.cjs.map → impl-2ZHRCHKL.cjs.map} +1 -1
- package/dist/impl-3HQ63RRZ.cjs +2 -0
- package/dist/{impl-YL6NFYNB.cjs.map → impl-3HQ63RRZ.cjs.map} +1 -1
- package/dist/impl-3ON47TMW.cjs +2 -0
- package/dist/{impl-LDTQPPG4.cjs.map → impl-3ON47TMW.cjs.map} +1 -1
- package/dist/{impl-CL6KPZLE.cjs → impl-42EGVNC4.cjs} +3 -3
- package/dist/{impl-CL6KPZLE.cjs.map → impl-42EGVNC4.cjs.map} +1 -1
- package/dist/{impl-ZVQSMGTX.cjs → impl-57FO3PX7.cjs} +5 -5
- package/dist/{impl-ZVQSMGTX.cjs.map → impl-57FO3PX7.cjs.map} +1 -1
- package/dist/{impl-LZV3EW2T.cjs → impl-5RAQCIIT.cjs} +2 -2
- package/dist/{impl-LZV3EW2T.cjs.map → impl-5RAQCIIT.cjs.map} +1 -1
- package/dist/{impl-D5TZDNRA.cjs → impl-6ALA6KXM.cjs} +2 -2
- package/dist/{impl-D5TZDNRA.cjs.map → impl-6ALA6KXM.cjs.map} +1 -1
- package/dist/{impl-OCCJLM7J.cjs → impl-6FMDP53G.cjs} +2 -2
- package/dist/{impl-OCCJLM7J.cjs.map → impl-6FMDP53G.cjs.map} +1 -1
- package/dist/{impl-U2RBVO73.cjs → impl-7L5YW5CG.cjs} +2 -2
- package/dist/{impl-U2RBVO73.cjs.map → impl-7L5YW5CG.cjs.map} +1 -1
- package/dist/{impl-2JBFAO77.cjs → impl-B5GIP2VU.cjs} +2 -2
- package/dist/{impl-2JBFAO77.cjs.map → impl-B5GIP2VU.cjs.map} +1 -1
- package/dist/{impl-QQKQBRMF.cjs → impl-BSJJNNCI.cjs} +2 -2
- package/dist/{impl-QQKQBRMF.cjs.map → impl-BSJJNNCI.cjs.map} +1 -1
- package/dist/{impl-TGEXS5L4.cjs → impl-C7VBO6EQ.cjs} +2 -2
- package/dist/{impl-TGEXS5L4.cjs.map → impl-C7VBO6EQ.cjs.map} +1 -1
- package/dist/impl-CNNTC625.cjs +2 -0
- package/dist/{impl-6KCSMCD6.cjs.map → impl-CNNTC625.cjs.map} +1 -1
- package/dist/{impl-RKBK7S5H.cjs → impl-CSVPLCDE.cjs} +2 -2
- package/dist/{impl-RKBK7S5H.cjs.map → impl-CSVPLCDE.cjs.map} +1 -1
- package/dist/{impl-5VEW37CW.cjs → impl-EKGVCWVS.cjs} +4 -4
- package/dist/{impl-5VEW37CW.cjs.map → impl-EKGVCWVS.cjs.map} +1 -1
- package/dist/impl-EZEGBKX7.cjs +2 -0
- package/dist/{impl-7Q5BF5OS.cjs.map → impl-EZEGBKX7.cjs.map} +1 -1
- package/dist/{impl-6FXWJOHN.cjs → impl-FPDL23FO.cjs} +2 -2
- package/dist/{impl-6FXWJOHN.cjs.map → impl-FPDL23FO.cjs.map} +1 -1
- package/dist/{impl-2ETA24UG.cjs → impl-HI3ZAAZJ.cjs} +6 -6
- package/dist/{impl-2ETA24UG.cjs.map → impl-HI3ZAAZJ.cjs.map} +1 -1
- package/dist/{impl-CD3OZA7N.cjs → impl-HKEYENUI.cjs} +2 -2
- package/dist/{impl-CD3OZA7N.cjs.map → impl-HKEYENUI.cjs.map} +1 -1
- package/dist/impl-IZ6KZF27.cjs +2 -0
- package/dist/{impl-6O3K3VET.cjs.map → impl-IZ6KZF27.cjs.map} +1 -1
- package/dist/{impl-CVJ7ESYK.cjs → impl-JDJ4CQXV.cjs} +2 -2
- package/dist/{impl-CVJ7ESYK.cjs.map → impl-JDJ4CQXV.cjs.map} +1 -1
- package/dist/{impl-6FE4QJ4J.cjs → impl-JKSZNCWA.cjs} +2 -2
- package/dist/{impl-6FE4QJ4J.cjs.map → impl-JKSZNCWA.cjs.map} +1 -1
- package/dist/{impl-XK5I264J.cjs → impl-MEK2DTKK.cjs} +2 -2
- package/dist/{impl-XK5I264J.cjs.map → impl-MEK2DTKK.cjs.map} +1 -1
- package/dist/{impl-KE2PQIWC.cjs → impl-NL7N7YF4.cjs} +2 -2
- package/dist/{impl-KE2PQIWC.cjs.map → impl-NL7N7YF4.cjs.map} +1 -1
- package/dist/{impl-DQN5SZPW.cjs → impl-OBAYFQ23.cjs} +2 -2
- package/dist/{impl-DQN5SZPW.cjs.map → impl-OBAYFQ23.cjs.map} +1 -1
- package/dist/impl-OJ5LZMML.cjs +2 -0
- package/dist/{impl-SPMWIV5D.cjs.map → impl-OJ5LZMML.cjs.map} +1 -1
- package/dist/impl-OKB3HF7H.cjs +2 -0
- package/dist/{impl-7HFUP3UR.cjs.map → impl-OKB3HF7H.cjs.map} +1 -1
- package/dist/{impl-5TMNTUZT.cjs → impl-OOKYV6NI.cjs} +3 -3
- package/dist/{impl-5TMNTUZT.cjs.map → impl-OOKYV6NI.cjs.map} +1 -1
- package/dist/{impl-BMAMFZHY.cjs → impl-P77UGVDU.cjs} +2 -2
- package/dist/{impl-BMAMFZHY.cjs.map → impl-P77UGVDU.cjs.map} +1 -1
- package/dist/impl-PJF6PVKZ.cjs +2 -0
- package/dist/{impl-DDY5QERH.cjs.map → impl-PJF6PVKZ.cjs.map} +1 -1
- package/dist/impl-RTDKCEU3.cjs +2 -0
- package/dist/{impl-IGRDFRB5.cjs.map → impl-RTDKCEU3.cjs.map} +1 -1
- package/dist/impl-S7SJFITO.cjs +2 -0
- package/dist/{impl-KEOLBOR2.cjs.map → impl-S7SJFITO.cjs.map} +1 -1
- package/dist/{impl-24MFRX5R.cjs → impl-U64CK4IR.cjs} +2 -2
- package/dist/{impl-24MFRX5R.cjs.map → impl-U64CK4IR.cjs.map} +1 -1
- package/dist/{impl-IXNKHZFW.cjs → impl-V3TJ5WS2.cjs} +2 -2
- package/dist/{impl-IXNKHZFW.cjs.map → impl-V3TJ5WS2.cjs.map} +1 -1
- package/dist/{impl-3AJDNF67.cjs → impl-VOTMQS3M.cjs} +2 -2
- package/dist/{impl-3AJDNF67.cjs.map → impl-VOTMQS3M.cjs.map} +1 -1
- package/dist/impl-WMJ7ZSI2.cjs +2 -0
- package/dist/{impl-4L4ETIBX.cjs.map → impl-WMJ7ZSI2.cjs.map} +1 -1
- package/dist/impl-Y2UFIDZG.cjs +2 -0
- package/dist/{impl-GNUG6ZDE.cjs.map → impl-Y2UFIDZG.cjs.map} +1 -1
- package/dist/impl-ZP5ZWANC.cjs +2 -0
- package/dist/{impl-QGSF3JGN.cjs.map → impl-ZP5ZWANC.cjs.map} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33442 -6116
- package/package.json +4 -3
- package/dist/chunk-35HDA5WV.cjs +0 -2
- package/dist/chunk-35HDA5WV.cjs.map +0 -1
- package/dist/chunk-AWMP5TQB.cjs +0 -2847
- package/dist/chunk-AWMP5TQB.cjs.map +0 -1
- package/dist/chunk-BY7W4UQF.cjs +0 -2
- package/dist/chunk-BY7W4UQF.cjs.map +0 -1
- package/dist/chunk-ZD2HOHJI.cjs +0 -2
- package/dist/chunk-ZD2HOHJI.cjs.map +0 -1
- package/dist/impl-4L4ETIBX.cjs +0 -2
- package/dist/impl-6KCSMCD6.cjs +0 -2
- package/dist/impl-6O3K3VET.cjs +0 -2
- package/dist/impl-7HFUP3UR.cjs +0 -2
- package/dist/impl-7Q5BF5OS.cjs +0 -2
- package/dist/impl-DDY5QERH.cjs +0 -2
- package/dist/impl-GNUG6ZDE.cjs +0 -2
- package/dist/impl-IGRDFRB5.cjs +0 -2
- package/dist/impl-KEOLBOR2.cjs +0 -2
- package/dist/impl-LDTQPPG4.cjs +0 -2
- package/dist/impl-QGSF3JGN.cjs +0 -2
- package/dist/impl-SPMWIV5D.cjs +0 -2
- package/dist/impl-YL6NFYNB.cjs +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkNW3O6OPScjs = require('./chunk-NW3O6OPS.cjs');var _inquirer = require('inquirer'); var _inquirer2 = _interopRequireDefault(_inquirer);var _inquirerautocompleteprompt = require('inquirer-autocomplete-prompt'); var _inquirerautocompleteprompt2 = _interopRequireDefault(_inquirerautocompleteprompt);async function c({message:e}){let{response:r}=await _inquirer2.default.prompt([{name:"response",message:e,type:"confirm"}]);return r}async function l({message:e}){let{response:r}=await _inquirer2.default.prompt([{name:"response",message:e,type:"text",validate:t=>t.trim().length>0}]);return r}async function y({defaultValue:e,values:r,message:t}){_inquirer2.default.registerPrompt("autocomplete",_inquirerautocompleteprompt2.default);let{response:p}=await _inquirer2.default.prompt([{name:"response",message:t,type:"autocomplete",default:e,source:(a,n)=>n?r.filter(s=>typeof s=="string"&&_chunkNW3O6OPScjs.k.call(void 0, n,s)):r}]);return p}exports.a = c; exports.b = l; exports.c = y;
|
|
2
|
+
//# sourceMappingURL=chunk-I4XVTF53.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/cli/cli/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/cli/cli/dist/chunk-I4XVTF53.cjs","../src/lib/helpers/inquirer.ts"],"names":["inquirerConfirmBoolean","message","response","inquirer","inquirerConfirmText","x","inquirerAutoComplete","defaultValue","values","autoCompletePrompt","answersSoFar","input","fuzzySearch"],"mappings":"AAAA,iOAAwC,wFCAnB,kKACU,MAU/B,SAAsBA,CAAAA,CAAuB,CAC3C,OAAA,CAAAC,CACF,CAAA,CAGqB,CACnB,GAAM,CAAE,QAAA,CAAAC,CAAS,CAAA,CAAI,MAAMC,kBAAAA,CAAS,MAAA,CAGjC,CACD,CACE,IAAA,CAAM,UAAA,CACN,OAAA,CAAAF,CAAAA,CACA,IAAA,CAAM,SACR,CACF,CAAC,CAAA,CACD,OAAOC,CACT,CAQA,MAAA,SAAsBE,CAAAA,CAAoB,CACxC,OAAA,CAAAH,CACF,CAAA,CAGoB,CAClB,GAAM,CAAE,QAAA,CAAAC,CAAS,CAAA,CAAI,MAAMC,kBAAAA,CAAS,MAAA,CAGjC,CACD,CACE,IAAA,CAAM,UAAA,CACN,OAAA,CAAAF,CAAAA,CACA,IAAA,CAAM,MAAA,CACN,QAAA,CAAWI,CAAAA,EAAMA,CAAAA,CAAE,IAAA,CAAK,CAAA,CAAE,MAAA,CAAS,CACrC,CACF,CAAC,CAAA,CACD,OAAOH,CACT,CAQA,MAAA,SAAsBI,CAAAA,CAAqB,CACzC,YAAA,CAAAC,CAAAA,CACA,MAAA,CAAAC,CAAAA,CACA,OAAA,CAAAP,CACF,CAAA,CAOoB,CAClBE,kBAAAA,CAAS,cAAA,CAAe,cAAA,CAAgBM,oCAAkB,CAAA,CAC1D,GAAM,CAAE,QAAA,CAAAP,CAAS,CAAA,CAAI,MAAMC,kBAAAA,CAAS,MAAA,CAGjC,CACD,CACE,IAAA,CAAM,UAAA,CACN,OAAA,CAAAF,CAAAA,CACA,IAAA,CAAM,cAAA,CACN,OAAA,CAASM,CAAAA,CACT,MAAA,CAAQ,CAACG,CAAAA,CAA2BC,CAAAA,CAAAA,EACjCA,CAAAA,CAEGH,CAAAA,CAAO,MAAA,CACJH,CAAAA,EAAM,OAAOA,CAAAA,EAAM,QAAA,EAAYO,iCAAAA,CAAYD,CAAON,CAAC,CACtD,CAAA,CAHAG,CAIR,CACF,CAAC,CAAA,CACD,OAAON,CACT,CAAA,4CAAA","file":"/home/runner/work/cli/cli/dist/chunk-I4XVTF53.cjs","sourcesContent":[null,"import inquirer from 'inquirer';\nimport autoCompletePrompt from 'inquirer-autocomplete-prompt';\nimport { fuzzySearch } from '../requests';\nimport { ObjByString } from '@transcend-io/type-utils';\n\n/**\n * Inquirer confirm text\n *\n * @param options - Options\n * @returns The response\n */\nexport async function inquirerConfirmBoolean({\n message,\n}: {\n /** Message */\n message: string;\n}): Promise<boolean> {\n const { response } = await inquirer.prompt<{\n /** confirmation */\n response: boolean;\n }>([\n {\n name: 'response',\n message,\n type: 'confirm',\n },\n ]);\n return response;\n}\n\n/**\n * Inquirer confirm text\n *\n * @param options - Options\n * @returns The response\n */\nexport async function inquirerConfirmText({\n message,\n}: {\n /** Message */\n message: string;\n}): Promise<string> {\n const { response } = await inquirer.prompt<{\n /** confirmation */\n response: string;\n }>([\n {\n name: 'response',\n message,\n type: 'text',\n validate: (x) => x.trim().length > 0,\n },\n ]);\n return response;\n}\n\n/**\n * Inquirer auto complete\n *\n * @param options - Options\n * @returns The response\n */\nexport async function inquirerAutoComplete({\n defaultValue,\n values,\n message,\n}: {\n /** Default value */\n defaultValue?: string;\n /** Message */\n message: string;\n /** Values to select */\n values: string[];\n}): Promise<string> {\n inquirer.registerPrompt('autocomplete', autoCompletePrompt);\n const { response } = await inquirer.prompt<{\n /** confirmation */\n response: string;\n }>([\n {\n name: 'response',\n message,\n type: 'autocomplete',\n default: defaultValue,\n source: (answersSoFar: ObjByString, input: string) =>\n !input\n ? values\n : values.filter(\n (x) => typeof x === 'string' && fuzzySearch(input, x),\n ),\n },\n ]);\n return response;\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
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; } }var
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
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; } }var _chunkQ7I37FJVcjs = require('./chunk-Q7I37FJV.cjs');var _iots = require('io-ts'); var e = _interopRequireWildcard(_iots); var r = _interopRequireWildcard(_iots);var _typeutils = require('@transcend-io/type-utils');var d=({TRouteName:t})=>e.type({routeName:t,enabledPolicies:e.array(_typeutils.valuesOf.call(void 0, _chunkQ7I37FJVcjs.e))});var l=({TEnabledRoutes:t})=>r.type({enabledRoutes:t});exports.a = d; exports.b = l;
|
|
2
|
+
//# sourceMappingURL=chunk-LCDYXJN6.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/cli/cli/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/cli/cli/dist/chunk-LCDYXJN6.cjs","../src/lib/helpers/buildEnabledRouteType.ts","../src/lib/helpers/buildAIIntegrationType.ts"],"names":["buildEnabledRouteType","TRouteName","valuesOf","buildAIIntegrationType","TEnabledRoutes"],"mappings":"AAAA,mZAAwC,6GCArB,qDAEM,IASZA,CAAAA,CAAwB,CAAoB,CACvD,UAAA,CAAAC,CACF,CAAA,CAAA,EAII,CAAA,CAAA,IAAA,CAAK,CACL,SAAA,CAAWA,CAAAA,CACX,eAAA,CAAmB,CAAA,CAAA,KAAA,CAAMC,iCAAAA,mBAA6B,CAAC,CACzD,CAAC,CAAA,CCpBH,IASaC,CAAAA,CAAyB,CAGpC,CACA,cAAA,CAAAC,CACF,CAAA,CAAA,EAII,CAAA,CAAA,IAAA,CAAK,CACL,aAAA,CAAeA,CACjB,CAAC,CAAA,CAAA,6BAAA","file":"/home/runner/work/cli/cli/dist/chunk-LCDYXJN6.cjs","sourcesContent":[null,"import * as t from 'io-ts';\nimport { EnabledRouteC } from '../../codecs';\nimport { valuesOf } from '@transcend-io/type-utils';\nimport { PathfinderPolicyName } from '../../enums';\n\n/**\n * Builds a custom io-ts type that represents a route allowed by the proxy\n *\n * @param TRouteName - the string with the name of the allowed route\n * @returns custom io-ts AllowedRoute type\n */\nexport const buildEnabledRouteType = <T extends t.Mixed>({\n TRouteName,\n}: {\n /** the type of the routeName property */\n TRouteName: T;\n}): EnabledRouteC<T> =>\n t.type({\n routeName: TRouteName,\n enabledPolicies: t.array(valuesOf(PathfinderPolicyName)),\n });\n","import * as t from 'io-ts';\nimport { AIIntegrationC, EnabledRouteC } from '../../codecs';\n\n/**\n * Helper to build a custom io-ts type representing an AIIntegration\n *\n * @param TEnabledRoutes - the type of the enabledRoutes for the AIIntegration type\n * @returns an AIIntegration type\n */\nexport const buildAIIntegrationType = <\n T extends t.Mixed,\n P extends t.ArrayC<EnabledRouteC<T>>,\n>({\n TEnabledRoutes,\n}: {\n /** the type of the enabledRoutes property */\n TEnabledRoutes: P;\n}): AIIntegrationC<T> =>\n t.type({\n enabledRoutes: TEnabledRoutes,\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 _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
|
|
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 _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 _chunkYK5YCHD6cjs = require('./chunk-YK5YCHD6.cjs');var _chunkZUNVPK23cjs = require('./chunk-ZUNVPK23.cjs');var _fs = require('fs');var _typeutils = require('@transcend-io/type-utils');var _privacytypes = require('@transcend-io/privacy-types');var N=/target ('|")(.*?)('|")/,O=/pod ('|")(.*?)('|")(, ('|")~> (.+?)('|")|)/,y={supportedFiles:["Podfile"],ignoreDirs:["Pods"],scanFunction:e=>{let n=_fs.readFileSync.call(void 0, e,"utf-8"),o=_typeutils.findAllWithRegex.call(void 0, {value:new RegExp(N,"g"),matches:["quote1","name","quote2"]},n),c=_typeutils.findAllWithRegex.call(void 0, {value:new RegExp(O,"g"),matches:["quote1","name","quote2","extra","quote3","version","quote4"]},n);return o.map((t,p)=>({name:t.name,type:_privacytypes.CodePackageType.CocoaPods,softwareDevelopmentKits:c.filter(r=>r.matchIndex>t.matchIndex&&(!o[p+1]||r.matchIndex<o[p+1].matchIndex)).map(r=>({name:r.name,version:r.version}))}))}};var _path = require('path');var K=/implementation( *)('|")(.+?):(.+?):(.+?|)('|")/,M=/apply plugin: *('|")(.+?)(:(.+?)|)('|")/,j=/implementation group:( *)('|")(.+?)('|"),( *)name:( *)('|")(.+?)('|"),( *)version:( *)('|")(.+?)('|")/,L=/applicationId( *)"(.+?)"/,S={supportedFiles:["build.gradle**"],ignoreDirs:["gradle-app.setting","gradle-wrapper.jar","gradle-wrapper.properties"],scanFunction:e=>{let n=_fs.readFileSync.call(void 0, e,"utf-8"),o=_path.dirname.call(void 0, e),c=_typeutils.findAllWithRegex.call(void 0, {value:new RegExp(K,"g"),matches:["space","quote1","name","path","version","quote2"]},n),a=_typeutils.findAllWithRegex.call(void 0, {value:new RegExp(M,"g"),matches:["quote1","name","group","version","quote2"]},n),t=_typeutils.findAllWithRegex.call(void 0, {value:new RegExp(j,"g"),matches:["space1","quote1","group","quote2","space2","space3","quote3","name","quote4","space4","space5","quote5","version","quote6"]},n),p=_typeutils.findAllWithRegex.call(void 0, {value:new RegExp(L,"g"),matches:["space","name"]},n);if(p.length>1)throw new Error(`Expected only one applicationId per file: ${e}`);return[{name:_optionalChain([p, 'access', _2 => _2[0], 'optionalAccess', _3 => _3.name])||o.split("/").pop(),softwareDevelopmentKits:[...c,...t,...a].map(r=>({name:r.name,version:r.version||void 0}))}]}};var x={supportedFiles:["package.json"],ignoreDirs:["node_modules","serverless-build","lambda-build"],scanFunction:e=>{let n=_fs.readFileSync.call(void 0, e,"utf-8"),o=_path.dirname.call(void 0, e),c=JSON.parse(n),{name:a,description:t,dependencies:p={},devDependencies:r={},optionalDependencies:i={}}=c;return[{name:a||o.split("/").pop(),description:t,softwareDevelopmentKits:[...Object.entries(p).map(([s,m])=>({name:s,version:typeof m=="string"?m:void 0})),...Object.entries(r).map(([s,m])=>({name:s,version:typeof m=="string"?m:void 0,isDevDependency:!0})),...Object.entries(i).map(([s,m])=>({name:s,version:typeof m=="string"?m:void 0}))]}]}};var V=/(.+?)(=+)(.+)/,H=/name *= *('|")(.+?)('|")/,Q=/description *= *('|")(.+?)('|")/,P={supportedFiles:["requirements.txt"],ignoreDirs:["build","lib","lib64"],scanFunction:e=>{let n=_fs.readFileSync.call(void 0, e,"utf-8"),o=_path.dirname.call(void 0, e),a=_chunkYK5YCHD6cjs.c.call(void 0, o).find(s=>s==="setup.py"),t=a?_fs.readFileSync.call(void 0, _path.join.call(void 0, o,a),"utf-8"):void 0,p=t?(H.exec(t)||[])[2]:void 0,r=t?(Q.exec(t)||[])[2]:void 0,i=_typeutils.findAllWithRegex.call(void 0, {value:new RegExp(V,"g"),matches:["name","equals","version"]},n);return[{name:p||o.split("/").pop(),description:r||void 0,type:_privacytypes.CodePackageType.RequirementsTxt,softwareDevelopmentKits:i.map(s=>({name:s.name,version:s.version}))}]}};var ee=/gem *('|")(.+?)('|")(, *('|")(.+?)('|")|)/,ne=/spec\.name *= *('|")(.+?)('|")/,oe=/spec\.description *= *('|")(.+?)('|")/,te=/spec\.summary *= *('|")(.+?)('|")/,k={supportedFiles:["Gemfile"],ignoreDirs:["bin"],scanFunction:e=>{let n=_fs.readFileSync.call(void 0, e,"utf-8"),o=_path.dirname.call(void 0, e),a=_chunkYK5YCHD6cjs.c.call(void 0, o).find(s=>s===".gemspec"),t=a?_fs.readFileSync.call(void 0, a,"utf-8"):void 0,p=t?(ne.exec(t)||[])[2]:void 0,r=t?(oe.exec(t)||te.exec(t)||[])[1]:void 0,i=_typeutils.findAllWithRegex.call(void 0, {value:new RegExp(ee,"g"),matches:["quote1","name","quote2","hasVersion","quote3","version","quote4"]},n);return[{name:p||o.split("/").pop(),description:r||void 0,type:_privacytypes.CodePackageType.RequirementsTxt,softwareDevelopmentKits:i.map(s=>({name:s.name,version:s.version}))}]}};var _jsyaml = require('js-yaml'); var _jsyaml2 = _interopRequireDefault(_jsyaml);function pe(e){return e.split(`
|
|
2
2
|
`).map(n=>{let o=n.indexOf("#");return o>-1&&!n.substring(0,o).includes('"')&&!n.substring(0,o).includes("'")?n.substring(0,o).trim():n}).filter(n=>n.length>0).join(`
|
|
3
3
|
`)}var v={supportedFiles:["pubspec.yml"],ignoreDirs:["build"],scanFunction:e=>{let n=_path.dirname.call(void 0, e),o=_fs.readFileSync.call(void 0, e,"utf-8"),{name:c,description:a,dev_dependencies:t={},dependencies:p={}}=_jsyaml2.default.load(pe(o));return[{name:c||n.split("/").pop(),description:a,type:_privacytypes.CodePackageType.RequirementsTxt,softwareDevelopmentKits:[...Object.entries(p).map(([r,i])=>({name:r,version:typeof i=="string"?i:typeof i=="number"?i.toString():_optionalChain([i, 'optionalAccess', _4 => _4.sdk])})),...Object.entries(t).map(([r,i])=>({name:r,version:typeof i=="string"?i:typeof i=="number"?i.toString():_optionalChain([i, 'optionalAccess', _5 => _5.sdk]),isDevDependency:!0}))]}]}};var I={supportedFiles:["composer.json"],ignoreDirs:["vendor","node_modules","cache","build","dist"],scanFunction:e=>{let n=_fs.readFileSync.call(void 0, e,"utf-8"),o=_path.dirname.call(void 0, e),c=JSON.parse(n),{name:a,description:t,require:p={},"require-dev":r={}}=c;return[{name:a||o.split("/").pop(),description:t,softwareDevelopmentKits:[...Object.entries(p).map(([i,s])=>({name:i,version:typeof s=="string"?s:void 0})),...Object.entries(r).map(([i,s])=>({name:i,version:typeof s=="string"?s:void 0,isDevDependency:!0}))]}]}};var _iots = require('io-ts'); var d = _interopRequireWildcard(_iots);var le=d.type({pins:d.array(d.type({identity:d.string,kind:d.string,location:d.string,state:d.type({revision:d.string,version:d.string})})),version:d.number}),D={supportedFiles:["Package.resolved"],ignoreDirs:[],scanFunction:e=>{let n=_fs.readFileSync.call(void 0, e,"utf-8"),o=_typeutils.decodeCodec.call(void 0, le,n);return[{name:_path.dirname.call(void 0, e).split("/").pop()||"",type:_privacytypes.CodePackageType.CocoaPods,softwareDevelopmentKits:o.pins.map(c=>({name:c.identity,version:c.state.version}))}]}};var gn={cocoaPods:y,gradle:S,javascriptPackageJson:x,pythonRequirementsTxt:P,gemfile:k,pubspec:v,swift:D},_={[_privacytypes.CodePackageType.CocoaPods]:y,[_privacytypes.CodePackageType.Gradle]:S,[_privacytypes.CodePackageType.PackageJson]:x,[_privacytypes.CodePackageType.RequirementsTxt]:P,[_privacytypes.CodePackageType.Gemfile]:k,[_privacytypes.CodePackageType.Pubspec]:v,[_privacytypes.CodePackageType.ComposerJson]:I,[_privacytypes.CodePackageType.Swift]:D};var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_fastglob);var _colors = require('colors'); var _colors2 = _interopRequireDefault(_colors);async function Sn({scanPath:e,ignoreDirs:n=[],repositoryName:o}){return(await Promise.all(_typeutils.getEntries.call(void 0, _).map(async([a,t])=>{let{ignoreDirs:p,supportedFiles:r,scanFunction:i}=t,s=[...n,...p].filter(m=>m.length>0);try{let m=await _fastglob2.default.call(void 0, `${e}/**/${r.join("|")}`,{ignore:s.map(g=>`${e}/**/${g}`),unique:!0,onlyFiles:!0});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Scanning: ${m.length} files of type ${a}`));let C=m.map(g=>i(g).map(q=>({...q,relativePath:g.replace(`${e}/`,"")}))).flat();return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Found: ${C.length} packages and ${C.map(({softwareDevelopmentKits:g=[]})=>g).flat().length} sdks`)),C.map(g=>({...g,type:a,repositoryName:o}))}catch(m){throw new Error(`Error scanning globs ${r} with error: ${m}`)}}))).flat()}exports.a = gn; exports.b = Sn;
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-NNMCZMFJ.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/cli/cli/dist/chunk-YGAK4NBT.cjs","../src/lib/code-scanning/integrations/cocoaPods.ts","../src/lib/code-scanning/integrations/gradle.ts","../src/lib/code-scanning/integrations/pubspec.ts","../src/lib/code-scanning/constants.ts"],"names":["POD_TARGET_REGEX","POD_PACKAGE_REGEX","cocoaPods","filePath","fileContents","readFileSync","targets","findAllWithRegex","packages","target","ind","CodePackageType","pkg","GRADLE_IMPLEMENTATION_REGEX","GRADLE_PLUGIN_REGEX","GRADLE_IMPLEMENTATION_GROUP_REGEX","GRADLE_APPLICATION_NAME_REGEX","gradle","directory","dirname","targetPlugins","targetGroups","applications"],"mappings":"AAAA,u/BAAwC,wDAAyC,wBCApD,qDAGI,2DACD,IAE1BA,CAAAA,CAAmB,wBAAA,CACnBC,CAAAA,CAAoB,4CAAA,CAEbC,CAAAA,CAAgC,CAC3C,cAAA,CAAgB,CAAC,SAAS,CAAA,CAC1B,UAAA,CAAY,CAAC,MAAM,CAAA,CACnB,YAAA,CAAeC,CAAAA,EAAa,CAC1B,IAAMC,CAAAA,CAAe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T.cjs","sourcesContent":[null,"import { readFileSync } from 'fs';\nimport { CodeScanningConfig } from '../types';\nimport { CodePackageSdk } from '../../../codecs';\nimport { findAllWithRegex } from '@transcend-io/type-utils';\nimport { CodePackageType } from '@transcend-io/privacy-types';\n\nconst POD_TARGET_REGEX = /target ('|\")(.*?)('|\")/;\nconst POD_PACKAGE_REGEX = /pod ('|\")(.*?)('|\")(, ('|\")~> (.+?)('|\")|)/;\n\nexport const cocoaPods: CodeScanningConfig = {\n supportedFiles: ['Podfile'],\n ignoreDirs: ['Pods'],\n scanFunction: (filePath) => {\n const fileContents = readFileSync(filePath, 'utf-8');\n\n const targets = findAllWithRegex(\n {\n value: new RegExp(POD_TARGET_REGEX, 'g'),\n matches: ['quote1', 'name', 'quote2'],\n },\n fileContents,\n );\n const packages = findAllWithRegex(\n {\n value: new RegExp(POD_PACKAGE_REGEX, 'g'),\n matches: [\n 'quote1',\n 'name',\n 'quote2',\n 'extra',\n 'quote3',\n 'version',\n 'quote4',\n ],\n },\n fileContents,\n );\n\n const deps: CodePackageSdk[] = targets.map((target, ind) => ({\n name: target.name,\n type: CodePackageType.CocoaPods,\n softwareDevelopmentKits: packages\n .filter(\n (pkg) =>\n pkg.matchIndex > target.matchIndex &&\n (!targets[ind + 1] || pkg.matchIndex < targets[ind + 1].matchIndex),\n )\n .map((pkg) => ({\n name: pkg.name,\n version: pkg.version,\n })),\n }));\n\n return deps;\n },\n};\n","import { readFileSync } from 'fs';\nimport { CodeScanningConfig } from '../types';\nimport { findAllWithRegex } from '@transcend-io/type-utils';\nimport { dirname } from 'path';\n\nconst GRADLE_IMPLEMENTATION_REGEX =\n /implementation( *)('|\")(.+?):(.+?):(.+?|)('|\")/;\nconst GRADLE_PLUGIN_REGEX = /apply plugin: *('|\")(.+?)(:(.+?)|)('|\")/;\nconst GRADLE_IMPLEMENTATION_GROUP_REGEX =\n /implementation group:( *)('|\")(.+?)('|\"),( *)name:( *)('|\")(.+?)('|\"),( *)version:( *)('|\")(.+?)('|\")/;\nconst GRADLE_APPLICATION_NAME_REGEX = /applicationId( *)\"(.+?)\"/;\n\n/**\n * So far, there are three ways of defining dependencies that is supported\n * implementation group: 'org.eclipse.jdt', name: 'org.eclipse.jdt.core', version: '3.28.0'\n * or\n * implementation 'com.google.firebase:firebase-analytics:18.0.0'\n * or\n * apply plugin: 'com.google.gms.google-services'\n *\n * single and double quotes are both recognized\n */\nexport const gradle: CodeScanningConfig = {\n supportedFiles: ['build.gradle**'],\n ignoreDirs: [\n 'gradle-app.setting',\n 'gradle-wrapper.jar',\n 'gradle-wrapper.properties',\n ],\n scanFunction: (filePath) => {\n const fileContents = readFileSync(filePath, 'utf-8');\n const directory = dirname(filePath);\n\n const targets = findAllWithRegex(\n {\n value: new RegExp(GRADLE_IMPLEMENTATION_REGEX, 'g'),\n matches: ['space', 'quote1', 'name', 'path', 'version', 'quote2'],\n },\n fileContents,\n );\n const targetPlugins = findAllWithRegex(\n {\n value: new RegExp(GRADLE_PLUGIN_REGEX, 'g'),\n matches: ['quote1', 'name', 'group', 'version', 'quote2'],\n },\n fileContents,\n );\n const targetGroups = findAllWithRegex(\n {\n value: new RegExp(GRADLE_IMPLEMENTATION_GROUP_REGEX, 'g'),\n matches: [\n 'space1',\n 'quote1',\n 'group',\n 'quote2',\n 'space2',\n 'space3',\n 'quote3',\n 'name',\n 'quote4',\n 'space4',\n 'space5',\n 'quote5',\n 'version',\n 'quote6',\n ],\n },\n fileContents,\n );\n const applications = findAllWithRegex(\n {\n value: new RegExp(GRADLE_APPLICATION_NAME_REGEX, 'g'),\n matches: ['space', 'name'],\n },\n fileContents,\n );\n if (applications.length > 1) {\n throw new Error(`Expected only one applicationId per file: ${filePath}`);\n }\n\n return [\n {\n name: applications[0]?.name || directory.split('/').pop()!,\n softwareDevelopmentKits: [\n ...targets,\n ...targetGroups,\n ...targetPlugins,\n ].map((target) => ({\n name: target.name,\n version: target.version || undefined,\n })),\n },\n ];\n },\n};\n","import { readFileSync } from 'fs';\nimport { CodeScanningConfig } from '../types';\nimport { CodePackageType } from '@transcend-io/privacy-types';\nimport yaml from 'js-yaml';\nimport { dirname } from 'path';\n\n/**\n * Remove YAML comments from a string\n *\n * @param yamlString - YAML string\n * @returns String without comments\n */\nfunction removeYAMLComments(yamlString: string): string {\n return yamlString\n .split('\\n')\n .map((line) => {\n // Remove inline comments\n const commentIndex = line.indexOf('#');\n if (commentIndex > -1) {\n // Check if '#' is not inside a string\n if (\n !line.substring(0, commentIndex).includes('\"') &&\n !line.substring(0, commentIndex).includes(\"'\")\n ) {\n return line.substring(0, commentIndex).trim();\n }\n }\n return line;\n })\n .filter((line) => line.length > 0)\n .join('\\n');\n}\n\nexport const pubspec: CodeScanningConfig = {\n supportedFiles: ['pubspec.yml'],\n ignoreDirs: ['build'],\n scanFunction: (filePath) => {\n const directory = dirname(filePath);\n const fileContents = readFileSync(filePath, 'utf-8');\n const {\n name,\n description,\n dev_dependencies = {},\n dependencies = {},\n } = yaml.load(removeYAMLComments(fileContents)) as {\n /** Name */\n name?: string;\n /** Description */\n description?: string;\n /** Dev dependencies */\n dev_dependencies?: { [k in string]: number | Record<string, string> };\n /** Dependencies */\n dependencies?: { [k in string]: number | Record<string, string> };\n };\n return [\n {\n name: name || directory.split('/').pop()!,\n description,\n type: CodePackageType.RequirementsTxt,\n softwareDevelopmentKits: [\n ...Object.entries(dependencies).map(([name, version]) => ({\n name,\n version:\n typeof version === 'string'\n ? version\n : typeof version === 'number'\n ? version.toString()\n : version?.sdk,\n })),\n ...Object.entries(dev_dependencies).map(([name, version]) => ({\n name,\n version:\n typeof version === 'string'\n ? version\n : typeof version === 'number'\n ? version.toString()\n : version?.sdk,\n isDevDependency: true,\n })),\n ],\n },\n ];\n },\n};\n","import { CodeScanningConfig } from './types';\nimport {\n cocoaPods,\n gradle,\n javascriptPackageJson,\n gemfile,\n composerJson,\n pubspec,\n swift,\n pythonRequirementsTxt,\n} from './integrations';\nimport { CodePackageType } from '@transcend-io/privacy-types';\n\n/**\n * @deprecated TODO: https://transcend.height.app/T-32325 - use code scanning instead\n */\nexport const SILO_DISCOVERY_CONFIGS: {\n [k in string]: CodeScanningConfig;\n} = {\n cocoaPods,\n gradle,\n javascriptPackageJson,\n pythonRequirementsTxt,\n gemfile,\n pubspec,\n swift,\n};\n\nexport const CODE_SCANNING_CONFIGS: {\n [k in CodePackageType]: CodeScanningConfig;\n} = {\n [CodePackageType.CocoaPods]: cocoaPods,\n [CodePackageType.Gradle]: gradle,\n [CodePackageType.PackageJson]: javascriptPackageJson,\n [CodePackageType.RequirementsTxt]: pythonRequirementsTxt,\n [CodePackageType.Gemfile]: gemfile,\n [CodePackageType.Pubspec]: pubspec,\n [CodePackageType.ComposerJson]: composerJson,\n [CodePackageType.Swift]: swift,\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/cli/cli/dist/chunk-NNMCZMFJ.cjs","../src/lib/code-scanning/integrations/cocoaPods.ts","../src/lib/code-scanning/integrations/gradle.ts","../src/lib/code-scanning/integrations/pubspec.ts","../src/lib/code-scanning/constants.ts"],"names":["POD_TARGET_REGEX","POD_PACKAGE_REGEX","cocoaPods","filePath","fileContents","readFileSync","targets","findAllWithRegex","packages","target","ind","CodePackageType","pkg","GRADLE_IMPLEMENTATION_REGEX","GRADLE_PLUGIN_REGEX","GRADLE_IMPLEMENTATION_GROUP_REGEX","GRADLE_APPLICATION_NAME_REGEX","gradle","directory","dirname","targetPlugins","targetGroups","applications"],"mappings":"AAAA,u/BAAwC,wDAAyC,wBCApD,qDAGI,2DACD,IAE1BA,CAAAA,CAAmB,wBAAA,CACnBC,CAAAA,CAAoB,4CAAA,CAEbC,CAAAA,CAAgC,CAC3C,cAAA,CAAgB,CAAC,SAAS,CAAA,CAC1B,UAAA,CAAY,CAAC,MAAM,CAAA,CACnB,YAAA,CAAeC,CAAAA,EAAa,CAC1B,IAAMC,CAAAA,CAAeC,8BAAAA,CAAaF,CAAU,OAAO,CAAA,CAE7CG,CAAAA,CAAUC,yCAAAA,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1B,IAAMC,CAAAA,CAAeC,8BAAAA,CAAaF,CAAU,OAAO,CAAA,CAC7Ce,CAAAA,CAAYC,2BAAAA,CAAgB,CAAA,CAE5Bb,CAAAA,CAAUC,yCAAAA,CAEZ,KAAA,CAAO,IAAI,MAAA,CAAOM,CAAAA,CAA6B,GAAG,CAAA,CAClD,OAAA,CAAS,CAAC,OAAA,CAAS,QAAA,CAAU,MAAA,CAAQ,MAAA,CAAQ,SAAA,CAAW,QAAQ,CAClE,CAAA,CACAT,CACF,CAAA,CACMgB,CAAAA,CAAgBb,yCAAAA,CAElB,KAAA,CAAO,IAAI,MAAA,CAAOO,CAAAA,CAAqB,GAAG,CAAA,CAC1C,OAAA,CAAS,CAAC,QAAA,CAAU,MAAA,CAAQ,OAAA,CAAS,SAAA,CAAW,QAAQ,CAC1D,CAAA,CACAV,CACF,CAAA,CACMiB,CAAAA,CAAed,yCAAAA,CAEjB,KAAA,CAAO,IAAI,MAAA,CAAOQ,CAAAA,CAAmC,GAAG,CAAA,CACxD,OAAA,CAAS,CACP,QAAA,CACA,QAAA,CACA,OAAA,CACA,QAAA,CACA,QAAA,CACA,QAAA,CACA,QAAA,CACA,MAAA,CACA,QAAA,CACA,QAAA,CACA,QAAA,CACA,QAAA,CACA,SAAA,CACA,QACF,CACF,CAAA,CACAX,CACF,CAAA,CACMkB,CAAAA,CAAef,yCAAAA,CAEjB,KAAA,CAAO,IAAI,MAAA,CAAOS,CAAAA,CAA+B,GAAG,CAAA,CACpD,OAAA,CAAS,CAAC,OAAA,CAAS,MAAM,CAC3B,CAAA,CACAZ,CACF,CAAA,CACA,EAAA,CAAIkB,CAAAA,CAAa,MAAA,CAAS,CAAA,CACxB,MAAM,IAAI,KAAA,CAAM,CAAA,0CAAA,EAA6CnB,CAAQ,CAAA,CAAA;AC/CjE;ACVR","file":"/home/runner/work/cli/cli/dist/chunk-NNMCZMFJ.cjs","sourcesContent":[null,"import { readFileSync } from 'fs';\nimport { CodeScanningConfig } from '../types';\nimport { CodePackageSdk } from '../../../codecs';\nimport { findAllWithRegex } from '@transcend-io/type-utils';\nimport { CodePackageType } from '@transcend-io/privacy-types';\n\nconst POD_TARGET_REGEX = /target ('|\")(.*?)('|\")/;\nconst POD_PACKAGE_REGEX = /pod ('|\")(.*?)('|\")(, ('|\")~> (.+?)('|\")|)/;\n\nexport const cocoaPods: CodeScanningConfig = {\n supportedFiles: ['Podfile'],\n ignoreDirs: ['Pods'],\n scanFunction: (filePath) => {\n const fileContents = readFileSync(filePath, 'utf-8');\n\n const targets = findAllWithRegex(\n {\n value: new RegExp(POD_TARGET_REGEX, 'g'),\n matches: ['quote1', 'name', 'quote2'],\n },\n fileContents,\n );\n const packages = findAllWithRegex(\n {\n value: new RegExp(POD_PACKAGE_REGEX, 'g'),\n matches: [\n 'quote1',\n 'name',\n 'quote2',\n 'extra',\n 'quote3',\n 'version',\n 'quote4',\n ],\n },\n fileContents,\n );\n\n const deps: CodePackageSdk[] = targets.map((target, ind) => ({\n name: target.name,\n type: CodePackageType.CocoaPods,\n softwareDevelopmentKits: packages\n .filter(\n (pkg) =>\n pkg.matchIndex > target.matchIndex &&\n (!targets[ind + 1] || pkg.matchIndex < targets[ind + 1].matchIndex),\n )\n .map((pkg) => ({\n name: pkg.name,\n version: pkg.version,\n })),\n }));\n\n return deps;\n },\n};\n","import { readFileSync } from 'fs';\nimport { CodeScanningConfig } from '../types';\nimport { findAllWithRegex } from '@transcend-io/type-utils';\nimport { dirname } from 'path';\n\nconst GRADLE_IMPLEMENTATION_REGEX =\n /implementation( *)('|\")(.+?):(.+?):(.+?|)('|\")/;\nconst GRADLE_PLUGIN_REGEX = /apply plugin: *('|\")(.+?)(:(.+?)|)('|\")/;\nconst GRADLE_IMPLEMENTATION_GROUP_REGEX =\n /implementation group:( *)('|\")(.+?)('|\"),( *)name:( *)('|\")(.+?)('|\"),( *)version:( *)('|\")(.+?)('|\")/;\nconst GRADLE_APPLICATION_NAME_REGEX = /applicationId( *)\"(.+?)\"/;\n\n/**\n * So far, there are three ways of defining dependencies that is supported\n * implementation group: 'org.eclipse.jdt', name: 'org.eclipse.jdt.core', version: '3.28.0'\n * or\n * implementation 'com.google.firebase:firebase-analytics:18.0.0'\n * or\n * apply plugin: 'com.google.gms.google-services'\n *\n * single and double quotes are both recognized\n */\nexport const gradle: CodeScanningConfig = {\n supportedFiles: ['build.gradle**'],\n ignoreDirs: [\n 'gradle-app.setting',\n 'gradle-wrapper.jar',\n 'gradle-wrapper.properties',\n ],\n scanFunction: (filePath) => {\n const fileContents = readFileSync(filePath, 'utf-8');\n const directory = dirname(filePath);\n\n const targets = findAllWithRegex(\n {\n value: new RegExp(GRADLE_IMPLEMENTATION_REGEX, 'g'),\n matches: ['space', 'quote1', 'name', 'path', 'version', 'quote2'],\n },\n fileContents,\n );\n const targetPlugins = findAllWithRegex(\n {\n value: new RegExp(GRADLE_PLUGIN_REGEX, 'g'),\n matches: ['quote1', 'name', 'group', 'version', 'quote2'],\n },\n fileContents,\n );\n const targetGroups = findAllWithRegex(\n {\n value: new RegExp(GRADLE_IMPLEMENTATION_GROUP_REGEX, 'g'),\n matches: [\n 'space1',\n 'quote1',\n 'group',\n 'quote2',\n 'space2',\n 'space3',\n 'quote3',\n 'name',\n 'quote4',\n 'space4',\n 'space5',\n 'quote5',\n 'version',\n 'quote6',\n ],\n },\n fileContents,\n );\n const applications = findAllWithRegex(\n {\n value: new RegExp(GRADLE_APPLICATION_NAME_REGEX, 'g'),\n matches: ['space', 'name'],\n },\n fileContents,\n );\n if (applications.length > 1) {\n throw new Error(`Expected only one applicationId per file: ${filePath}`);\n }\n\n return [\n {\n name: applications[0]?.name || directory.split('/').pop()!,\n softwareDevelopmentKits: [\n ...targets,\n ...targetGroups,\n ...targetPlugins,\n ].map((target) => ({\n name: target.name,\n version: target.version || undefined,\n })),\n },\n ];\n },\n};\n","import { readFileSync } from 'fs';\nimport { CodeScanningConfig } from '../types';\nimport { CodePackageType } from '@transcend-io/privacy-types';\nimport yaml from 'js-yaml';\nimport { dirname } from 'path';\n\n/**\n * Remove YAML comments from a string\n *\n * @param yamlString - YAML string\n * @returns String without comments\n */\nfunction removeYAMLComments(yamlString: string): string {\n return yamlString\n .split('\\n')\n .map((line) => {\n // Remove inline comments\n const commentIndex = line.indexOf('#');\n if (commentIndex > -1) {\n // Check if '#' is not inside a string\n if (\n !line.substring(0, commentIndex).includes('\"') &&\n !line.substring(0, commentIndex).includes(\"'\")\n ) {\n return line.substring(0, commentIndex).trim();\n }\n }\n return line;\n })\n .filter((line) => line.length > 0)\n .join('\\n');\n}\n\nexport const pubspec: CodeScanningConfig = {\n supportedFiles: ['pubspec.yml'],\n ignoreDirs: ['build'],\n scanFunction: (filePath) => {\n const directory = dirname(filePath);\n const fileContents = readFileSync(filePath, 'utf-8');\n const {\n name,\n description,\n dev_dependencies = {},\n dependencies = {},\n } = yaml.load(removeYAMLComments(fileContents)) as {\n /** Name */\n name?: string;\n /** Description */\n description?: string;\n /** Dev dependencies */\n dev_dependencies?: { [k in string]: number | Record<string, string> };\n /** Dependencies */\n dependencies?: { [k in string]: number | Record<string, string> };\n };\n return [\n {\n name: name || directory.split('/').pop()!,\n description,\n type: CodePackageType.RequirementsTxt,\n softwareDevelopmentKits: [\n ...Object.entries(dependencies).map(([name, version]) => ({\n name,\n version:\n typeof version === 'string'\n ? version\n : typeof version === 'number'\n ? version.toString()\n : version?.sdk,\n })),\n ...Object.entries(dev_dependencies).map(([name, version]) => ({\n name,\n version:\n typeof version === 'string'\n ? version\n : typeof version === 'number'\n ? version.toString()\n : version?.sdk,\n isDevDependency: true,\n })),\n ],\n },\n ];\n },\n};\n","import { CodeScanningConfig } from './types';\nimport {\n cocoaPods,\n gradle,\n javascriptPackageJson,\n gemfile,\n composerJson,\n pubspec,\n swift,\n pythonRequirementsTxt,\n} from './integrations';\nimport { CodePackageType } from '@transcend-io/privacy-types';\n\n/**\n * @deprecated TODO: https://transcend.height.app/T-32325 - use code scanning instead\n */\nexport const SILO_DISCOVERY_CONFIGS: {\n [k in string]: CodeScanningConfig;\n} = {\n cocoaPods,\n gradle,\n javascriptPackageJson,\n pythonRequirementsTxt,\n gemfile,\n pubspec,\n swift,\n};\n\nexport const CODE_SCANNING_CONFIGS: {\n [k in CodePackageType]: CodeScanningConfig;\n} = {\n [CodePackageType.CocoaPods]: cocoaPods,\n [CodePackageType.Gradle]: gradle,\n [CodePackageType.PackageJson]: javascriptPackageJson,\n [CodePackageType.RequirementsTxt]: pythonRequirementsTxt,\n [CodePackageType.Gemfile]: gemfile,\n [CodePackageType.Pubspec]: pubspec,\n [CodePackageType.ComposerJson]: composerJson,\n [CodePackageType.Swift]: swift,\n};\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
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 _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 _chunkAWMP5TQBcjs = require('./chunk-AWMP5TQB.cjs');var _chunkZUNVPK23cjs = require('./chunk-ZUNVPK23.cjs');var _chunk35HDA5WVcjs = require('./chunk-35HDA5WV.cjs');var _chunkQBBOYJ3Ocjs = require('./chunk-QBBOYJ3O.cjs');var _typeutils = require('@transcend-io/type-utils');var _internationalization = require('@transcend-io/internationalization');var _privacytypes = require('@transcend-io/privacy-types');var _iots = require('io-ts'); var R = _interopRequireWildcard(_iots); var re = _interopRequireWildcard(_iots); var lt = _interopRequireWildcard(_iots); var D = _interopRequireWildcard(_iots); var q = _interopRequireWildcard(_iots); var I = _interopRequireWildcard(_iots); var de = _interopRequireWildcard(_iots); var Ft = _interopRequireWildcard(_iots); var M = _interopRequireWildcard(_iots);var A="[NONE]",pe= exports.b ="[APPLY VALUE TO ALL ROWS]",De= exports.c ="<blank>",be= exports.d =["email","coreIdentifier"],ne= exports.e =(c=>(c.Email="email",c.CoreIdentifier="coreIdentifier",c.RequestType="requestType",c.SubjectType="subjectType",c.Locale="locale",c.Country="country",c.CountrySubDivision="countrySubDivision",c.RequestStatus="requestStatus",c.CreatedAt="createdAt",c.DataSiloIds="dataSiloIds",c))(ne||{}),et= exports.f ={email:!1,coreIdentifier:!0,requestType:!0,subjectType:!0,requestStatus:!1,createdAt:!1,dataSiloIds:!1,locale:!1,country:!1,countrySubDivision:!1},tt= exports.g ={requestType:!0,subjectType:!0},rt= exports.h =R.type({columnNames:R.partial(_typeutils.applyEnum.call(void 0, ne,()=>R.string)),identifierNames:R.record(R.string,R.string),attributeNames:R.record(R.string,R.string),requestTypeToRequestAction:R.record(R.string,_typeutils.valuesOf.call(void 0, _privacytypes.RequestAction)),subjectTypeToSubjectName:R.record(R.string,R.string),languageToLocale:R.record(R.string,_typeutils.valuesOf.call(void 0, _internationalization.LanguageKey)),regionToCountry:R.record(R.string,_typeutils.valuesOf.call(void 0, {..._privacytypes.IsoCountryCode,[A]:A})),regionToCountrySubDivision:R.record(R.string,_typeutils.valuesOf.call(void 0, {..._privacytypes.IsoCountrySubdivisionCode,[A]:A})),statusToRequestStatus:R.record(R.string,_typeutils.valuesOf.call(void 0, {..._privacytypes.CompletedRequestStatus,[A]:A}))}),Te= exports.i =R.type({id:R.string,link:R.string,rowIndex:R.number,coreIdentifier:R.string,attemptedAt:R.string}),st= exports.j =R.type({failingRequests:R.array(R.record(R.string,R.any)),successfulRequests:R.array(Te),duplicateRequests:R.array(R.type({rowIndex:R.number,coreIdentifier:R.string,attemptedAt:R.string}))});var _inquirer = require('inquirer'); var _inquirer2 = _interopRequireDefault(_inquirer);var _fuzzysearch = require('fuzzysearch'); var _fuzzysearch2 = _interopRequireDefault(_fuzzysearch);function Ae(n,e){return _fuzzysearch2.default.call(void 0, n.toLowerCase(),e.toLowerCase())||_fuzzysearch2.default.call(void 0, e.toLowerCase(),n.toLowerCase())}function ae(n,e,s,l){let a=n.filter(o=>Ae(e.toLowerCase(),o.toLowerCase()));return[...a,new _inquirer2.default.Separator,...s?[]:[A],...l?[pe]:[],...n.filter(o=>!a.includes(o))]}var _inquirerautocompleteprompt = require('inquirer-autocomplete-prompt'); var _inquirerautocompleteprompt2 = _interopRequireDefault(_inquirerautocompleteprompt);async function te(n,e,s){_inquirer2.default.registerPrompt("autocomplete",_inquirerautocompleteprompt2.default);let l=n.map(o=>o||"<blank>").filter(o=>!s[o]);if(l.length===0)return s;let a=await _inquirer2.default.prompt(l.map(o=>({name:o,message:`Map value of: ${o}`,type:"autocomplete",default:e.find(i=>Ae(o,i)),source:(i,r)=>r?e.filter(t=>typeof t=="string"&&Ae(r,t)):e})));return{...s,..._typeutils.apply.call(void 0, a,o=>typeof o=="string"?o:Object.values(o)[0])}}function Ee(n){return n.split(",").map(e=>e.trim()).filter(e=>e)}var _colors = require('colors'); var _colors2 = _interopRequireDefault(_colors);var at=re.type({key:re.string,values:re.array(re.string)});function ut(n){let e=n.map(s=>{let[l,a]=s.trim().split(":");if(!a)throw new Error("Expected attributes in key:value1;value2,key2:value3;value4");let o=a.split(";");return{key:l,values:o}});return _chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Attributes to apply to all requests:")),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(JSON.stringify(e,null,2))),e}var _sync = require('csv-parse/sync');var _fs = require('fs');function ct(n,e,s={columns:!0}){let l=_sync.parse.call(void 0, _fs.readFileSync.call(void 0, n,"utf-8"),s);return _typeutils.decodeCodec.call(void 0, lt.array(e),l).map(i=>Object.entries(i).reduce((r,[t,y])=>Object.assign(r,{[t.replace(/[^a-z_.+\-A-Z -~]/g,"")]:y}),{}))}function G(n,e){return _chunkQBBOYJ3Ocjs.j.call(void 0, n.map(s=>s[e]||"").flat())}async function pt(n){let e=_chunkQBBOYJ3Ocjs.j.call(void 0, n.map(a=>Object.keys(a)).flat()),s=n,l=!0;for(;l;){let{filterColumnName:a}=await _inquirer2.default.prompt([{name:"filterColumnName",message:`If you need to filter the list of requests to import, choose the column to filter on. Currently ${s.length} rows.`,type:"list",default:e,choices:[A,...e]}]);if(l=A!==a,l){let o=G(s,a),{valuesToKeep:i}=await _inquirer2.default.prompt([{name:"valuesToKeep",message:"Keep rows matching this value",type:"checkbox",default:e,choices:o}]);s=s.filter(r=>i.includes(r[a]))}}return _chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Importing ${s.length} requests`)),s}var _cliprogress = require('cli-progress'); var _cliprogress2 = _interopRequireDefault(_cliprogress);async function Us({requestActions:n,auth:e,requestIds:s,statuses:l=[_privacytypes.RequestStatus.Compiling,_privacytypes.RequestStatus.RequestMade,_privacytypes.RequestStatus.Delayed,_privacytypes.RequestStatus.Approving,_privacytypes.RequestStatus.Secondary,_privacytypes.RequestStatus.Enriching,_privacytypes.RequestStatus.Waiting,_privacytypes.RequestStatus.SecondaryApproving],createdAtAfter:a,createdAtBefore:o,concurrency:i=100,transcendUrl:r=_chunk35HDA5WVcjs.e}){let t=_chunkAWMP5TQBcjs.qe.call(void 0, r,e),y=new Date().getTime(),c=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),g=await _chunkAWMP5TQBcjs.ze.call(void 0, t,{actions:n,statuses:l,createdAtBefore:o,createdAtAfter:a,isSilent:!1,requestIds:s});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Marking "${g.length}" as silent mode.`));let m=0;c.start(g.length,0),await _chunkAWMP5TQBcjs.b.call(void 0, g,async f=>{await _chunkAWMP5TQBcjs.$b.call(void 0, t,_chunkAWMP5TQBcjs._,{input:{id:f.id,isSilent:!0}}),m+=1,c.update(m)},{concurrency:i}),c.stop();let p=new Date().getTime()-y;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully marked ${m} requests as silent mode in "${p/1e3}" seconds!`)),g.length}async function gt(n,e){let s=_typeutils.getValues.call(void 0, ne).filter(a=>!e.getValue("columnNames",a)),l=s.length===0?{}:await _inquirer2.default.prompt(s.map(a=>{let o=_chunkQBBOYJ3Ocjs.h.call(void 0, a.replace("ColumnName","")),i=ae(n,o,et[a],!!tt[a]);return{name:a,message:`Choose the column that will be used to map in the field: ${o}`,type:"list",default:i[0],choices:i}}));return await Promise.all(_typeutils.getEntries.call(void 0, l).map(([a,o])=>e.setValue(o,"columnNames",a))),l}async function yt(n,e,{state:s,columnNameMap:l}){let a=f=>s.getValue("columnNames",f)||l[f],{internalSubjects:o}=await _chunkAWMP5TQBcjs.$b.call(void 0, n,_chunkAWMP5TQBcjs.y);_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Determining mapping of columns for request action"));let i=await te(G(e,a("requestType")),Object.values(_privacytypes.RequestAction),s.getValue("requestTypeToRequestAction"));await s.setValue(i,"requestTypeToRequestAction"),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Determining mapping of columns for subject"));let r=await te(G(e,a("subjectType")),o.map(({type:f})=>f),s.getValue("subjectTypeToSubjectName"));await s.setValue(r,"subjectTypeToSubjectName"),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Determining mapping of columns for locale"));let t=await te(G(e,a("locale")),Object.values(_internationalization.LanguageKey),s.getValue("languageToLocale"));await s.setValue(t,"languageToLocale"),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Determining mapping of columns for request status")),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Determining mapping of columns for request status"));let y=a("requestStatus"),c=y===A?{}:await te(G(e,y),[...Object.values(_privacytypes.CompletedRequestStatus),A],s.getValue("statusToRequestStatus"));await s.setValue(c,"statusToRequestStatus"),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Determining mapping of columns for country"));let g=a("country"),m=g===A?{}:await te(G(e,g),[...Object.values(_privacytypes.IsoCountryCode),A],s.getValue("regionToCountry"));await s.setValue(m,"regionToCountry"),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Determining mapping of columns for country sub division"));let d=a("countrySubDivision"),p=d===A?{}:await te(G(e,d),[...Object.values(_privacytypes.IsoCountrySubdivisionCode),A],s.getValue("regionToCountrySubDivision"));await s.setValue(p,"regionToCountrySubDivision")}var _iotstypes = require('io-ts-types');var Pr=D.record(D.string,D.array(D.intersection([D.type({value:D.string}),D.partial({name:D.string})]))),ho= exports.x =D.intersection([D.type({email:D.string,attestedExtraIdentifiers:Pr,coreIdentifier:D.string,requestType:_typeutils.valuesOf.call(void 0, _privacytypes.RequestAction),subjectType:D.string}),D.partial({country:_typeutils.valuesOf.call(void 0, _privacytypes.IsoCountryCode),countrySubDivision:_typeutils.valuesOf.call(void 0, _privacytypes.IsoCountrySubdivisionCode),attributes:D.array(at),status:_typeutils.valuesOf.call(void 0, _privacytypes.CompletedRequestStatus),createdAt:_iotstypes.DateFromISOString,dataSiloIds:D.array(D.string),locale:_typeutils.valuesOf.call(void 0, _internationalization.LanguageKey)})]);function Dr(n,e,s){if(e===_privacytypes.IdentifierType.Email)return n.toLowerCase();if(e===_privacytypes.IdentifierType.Phone){let l=n.replace(_privacytypes.NORMALIZE_PHONE_NUMBER,"").replace(/[()]/g,"").replace(/[–]/g,"").replace(/[:]/g,"").replace(/[]/g,"").replace(/[A-Za-z]/g,"");return l?l.startsWith("+")?l:`+${s}${l}`:""}return n}function qt(n,e,{columnNameMap:s,identifierNameMap:l,attributeNameMap:a,requestAttributeKeys:o,defaultPhoneCountryCode:i="1"}){let r=t=>e.getValue("columnNames",t)||s[t];return n.map(t=>{let y={};Object.entries(l).filter(([,d])=>d!==A).forEach(([d,p])=>{let f=Object.values(_privacytypes.IdentifierType).includes(d)?d:_privacytypes.IdentifierType.Custom,h=t[p];if(h){let S=Dr(h,f,i);S&&(y[f]||(y[f]=[]),y[f].push({value:S,name:d}))}});let c=[];Object.entries(a).filter(([,d])=>d!==A).forEach(([d,p])=>{let f=t[p];if(f){let h=_optionalChain([o, 'access', _2 => _2.find, 'call', _3 => _3(S=>S.name===d), 'optionalAccess', _4 => _4.type])==="MULTI_SELECT";c.push({values:h?Ee(f):f,key:d})}});let g=r("requestType"),m=r("subjectType");return[t,{email:t[r("email")],attestedExtraIdentifiers:y,attributes:c,coreIdentifier:t[r("coreIdentifier")],requestType:g===pe?e.getValue("requestTypeToRequestAction",De):e.getValue("requestTypeToRequestAction",t[g]),subjectType:m===pe?e.getValue("subjectTypeToSubjectName",De):e.getValue("subjectTypeToSubjectName",t[m]),...r("locale")!==A&&t[r("locale")]?{locale:e.getValue("languageToLocale",t[r("locale")])}:{},...r("country")!==A&&t[r("country")]?{country:e.getValue("regionToCountry",t[r("country")])}:{},...r("countrySubDivision")!==A&&t[r("countrySubDivision")]?{countrySubDivision:e.getValue("regionToCountrySubDivision",t[r("countrySubDivision")])}:{},...r("requestStatus")!==A&&e.getValue("statusToRequestStatus",t[r("requestStatus")])!==A&&t[r("requestStatus")]?{status:e.getValue("statusToRequestStatus",t[r("requestStatus")])}:{},...r("createdAt")!==A&&t[r("createdAt")]?{createdAt:new Date(t[r("createdAt")])}:{},...r("dataSiloIds")!==A&&t[r("dataSiloIds")]?{dataSiloIds:Ee(t[r("dataSiloIds")])}:{}}]})}var St=q.type({defaultMessage:q.string,id:q.string}),xr= exports.B =q.type({downloadKey:q.string,error:q.union([q.null,q.string]),mimetype:q.string,size:q.string,fileName:q.string,dataPoint:q.type({id:q.string,title:q.union([St,q.null]),description:q.union([St,q.null]),name:q.string,slug:q.string,encryption:q.union([_typeutils.valuesOf.call(void 0, _privacytypes.TableEncryptionType),q.null]),dataSilo:q.type({id:q.string,title:q.string,description:q.string,type:q.string,outerType:q.union([q.string,q.null])}),path:q.array(q.string)})}),Lr= exports.C =q.type({nodes:q.array(xr),totalCount:q.number,_links:q.partial({next:q.union([q.string,q.null]),previous:q.union([q.string,q.null])})});async function bt(n,{sombra:e,concurrency:s=5,limit:l=100}){_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Pulling file metadata for ${n.length} requests`));let a=new Date().getTime(),o=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),i=0;o.start(n.length,0);let r=await _chunkAWMP5TQBcjs.b.call(void 0, n,async c=>{let g=[],m=!0,d=0;for(;m;){let p;try{let f=await e.get(`v1/data-subject-request/${c.id}/download-keys`,{searchParams:{limit:l,offset:d}}).json();p=_typeutils.decodeCodec.call(void 0, Lr,f),g.push(...p.nodes),d+=l,m=!!p._links.next&&p.nodes.length===l}catch(f){throw new Error(`Received an error from server: ${_optionalChain([f, 'optionalAccess', _5 => _5.response, 'optionalAccess', _6 => _6.body])||_optionalChain([f, 'optionalAccess', _7 => _7.message])}`)}}return i+=1,o.update(i),[c,g]},{concurrency:s});o.stop();let y=new Date().getTime()-a;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully downloaded file metadata ${n.length} requests in "${y/1e3}" seconds!`)),r}async function Tt(n,{requestId:e,sombra:s,onFileDownloaded:l,concurrency:a=20}){await _chunkAWMP5TQBcjs.b.call(void 0, n,async o=>{try{await s.get("v1/files",{searchParams:{downloadKey:o.downloadKey}}).buffer().then(i=>l(o,i))}catch(i){if(_optionalChain([i, 'optionalAccess', _8 => _8.response, 'optionalAccess', _9 => _9.body, 'optionalAccess', _10 => _10.includes, 'call', _11 => _11("fileMetadata#verify")])){_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Failed to pull file for: ${o.fileName} (request:${e}) - JWT expired. This likely means that the file is no longer available. Try restarting the request from scratch in Transcend Admin Dashboard. Skipping the download of this file.`));return}throw new Error(`Received an error from server: ${_optionalChain([i, 'optionalAccess', _12 => _12.response, 'optionalAccess', _13 => _13.body])||_optionalChain([i, 'optionalAccess', _14 => _14.message])}`)}},{concurrency:a})}var _path = require('path');async function Uo({auth:n,folderPath:e,requestIds:s,createdAtBefore:l,sombraAuth:a,createdAtAfter:o,statuses:i=[_privacytypes.RequestStatus.Approving,_privacytypes.RequestStatus.Downloadable],concurrency:r=5,transcendUrl:t=_chunk35HDA5WVcjs.e,approveAfterDownload:y=!1}){let c=_chunkAWMP5TQBcjs.qe.call(void 0, t,n),g=await _chunkAWMP5TQBcjs.re.call(void 0, t,n,a);_fs.existsSync.call(void 0, e)||_fs.mkdirSync.call(void 0, e);let m=await _chunkAWMP5TQBcjs.ze.call(void 0, c,{actions:[_privacytypes.RequestAction.Access],createdAtBefore:l,createdAtAfter:o,statuses:i,requestIds:s}),d=await bt(m,{sombra:g,concurrency:r}),p=new Date().getTime(),f=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),h=0,S=0;f.start(m.length,0),await _chunkAWMP5TQBcjs.b.call(void 0, d,async([v,x])=>{let K=_path.join.call(void 0, e,v.id);_fs.existsSync.call(void 0, K)||_fs.mkdirSync.call(void 0, K),await Tt(x,{sombra:g,requestId:v.id,onFileDownloaded:($,_)=>{let z=_path.join.call(void 0, K,$.fileName),j=_path.dirname.call(void 0, z);_fs.existsSync.call(void 0, j)||_fs.mkdirSync.call(void 0, j,{recursive:!0}),_fs.writeFileSync.call(void 0, z,_)}}),y&&v.status===_privacytypes.RequestStatus.Approving&&(await _chunkAWMP5TQBcjs.$b.call(void 0, c,_chunkAWMP5TQBcjs.Y,{input:{requestId:v.id}}),S+=1),h+=1,f.update(h)},{concurrency:r}),f.stop();let T=new Date().getTime()-p;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully downloaded ${h} requests in "${T/1e3}" seconds!`)),S>0&&_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Approved ${S} requests in Transcend.`)),m.length}var Le=I.type({id:I.string,link:I.string,status:_typeutils.valuesOf.call(void 0, _privacytypes.RequestStatus),type:_typeutils.valuesOf.call(void 0, _privacytypes.RequestAction),subjectType:I.string,email:I.union([I.null,I.string]),coreIdentifier:I.string,isSilent:I.boolean,isTest:I.boolean,country:I.union([I.null,_typeutils.valuesOf.call(void 0, _privacytypes.IsoCountryCode)]),countrySubDivision:I.union([I.null,_typeutils.valuesOf.call(void 0, _privacytypes.IsoCountrySubdivisionCode)]),attributeValues:I.array(I.type({attributeKey:I.type({name:I.string}),name:I.string}))});async function It(n,e,{details:s="",isTest:l=!1,emailIsVerified:a=!0,skipSendingReceipt:o=!1,isSilent:i=!0,additionalAttributes:r=[]}={}){let t=[...r];(e.attributes||[]).forEach(g=>{let m=t.find(d=>d.key===g.key);m?(m.values.push(...g.values),m.values=_chunkQBBOYJ3Ocjs.j.call(void 0, m.values)):t.push(g)});let y;try{y=await n.post("v1/data-subject-request",{json:{type:e.requestType,subject:{coreIdentifier:e.coreIdentifier,email:e.email,emailIsVerified:a,attestedExtraIdentifiers:e.attestedExtraIdentifiers},subjectType:e.subjectType,isSilent:i,isTest:l,skipSendingReceipt:o,...e.locale?{locale:e.locale}:{},details:s,attributes:t,...e.country||e.countrySubDivision?{region:{...e.country?{country:e.country}:e.countrySubDivision?{country:e.countrySubDivision.split("-")[0]}:{},...e.countrySubDivision?{countrySubDivision:e.countrySubDivision}:{}}}:{},...e.createdAt?{createdAt:e.createdAt}:{},...e.dataSiloIds?{dataSiloIds:e.dataSiloIds}:{},...e.status?{completedRequestStatus:e.status}:{}}}).json()}catch(g){throw new Error(`Received an error from server: ${_optionalChain([g, 'optionalAccess', _15 => _15.response, 'optionalAccess', _16 => _16.body])||_optionalChain([g, 'optionalAccess', _17 => _17.message])}`)}let{request:c}=_typeutils.decodeCodec.call(void 0, I.type({request:Le}),y);return c}async function oi({requestActions:n,requestOrigins:e,auth:s,silentModeBefore:l,createdAtAfter:a,createdAtBefore:o,concurrency:i=50,transcendUrl:r=_chunk35HDA5WVcjs.e}){let t=_chunkAWMP5TQBcjs.qe.call(void 0, r,s),y=new Date().getTime(),c=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),g=await _chunkAWMP5TQBcjs.ze.call(void 0, t,{actions:n,statuses:[_privacytypes.RequestStatus.Approving],createdAtAfter:a,origins:e,createdAtBefore:o});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Approving "${g.length}" requests.`));let m=0,d=0;c.start(g.length,0),await _chunkAWMP5TQBcjs.b.call(void 0, g,async h=>{l&&new Date(l)>new Date(h.createdAt)&&await _chunkAWMP5TQBcjs.$b.call(void 0, t,_chunkAWMP5TQBcjs._,{input:{id:h.id,isSilent:!0}});try{await _chunkAWMP5TQBcjs.$b.call(void 0, t,_chunkAWMP5TQBcjs.Y,{input:{requestId:h.id}})}catch(S){S.message.includes("Request must be in an approving state,")&&(d+=1)}m+=1,c.update(m)},{concurrency:i}),c.stop();let f=new Date().getTime()-y;return d>0&&_chunkZUNVPK23cjs.a.info(_colors2.default.yellow(`${d} requests were skipped.`)),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully approved ${m} requests in "${f/1e3}" seconds!`)),g.length}async function fi({requestActions:n=Object.values(_privacytypes.RequestAction),auth:e,requestIds:s,createdAtBefore:l,days:a=45,daysLeft:o=10,createdAtAfter:i,emailTemplate:r="Additional Time Needed",concurrency:t=100,transcendUrl:y=_chunk35HDA5WVcjs.e}){let c=_chunkAWMP5TQBcjs.qe.call(void 0, y,e),g=new Date().getTime(),m=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),p=(await _chunkAWMP5TQBcjs.ed.call(void 0, c,r)).find(T=>T.title===r);if(!p)throw new Error(`Failed to find a template with title: "${r}"`);let f=await _chunkAWMP5TQBcjs.ze.call(void 0, c,{actions:n,createdAtBefore:l,createdAtAfter:i,isSilent:!1,isClosed:!1,requestIds:s});f=f.filter(T=>typeof T.daysRemaining=="number"&&T.daysRemaining<o),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Notifying "${f.length}" that more time is needed.`));let h=0;m.start(f.length,0),await _chunkAWMP5TQBcjs.b.call(void 0, f,async T=>{await _chunkAWMP5TQBcjs.$b.call(void 0, c,_chunkAWMP5TQBcjs.$,{input:{requestId:T.id,template:p.template.defaultMessage,subject:p.subject.defaultMessage,additionalTime:a}}),h+=1,m.update(h)},{concurrency:t}),m.stop();let N=new Date().getTime()-g;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully marked ${h} requests as silent mode in "${N/1e3}" seconds!`)),f.length}async function vt(n,e,s){let{initializer:l}=await _chunkAWMP5TQBcjs.$b.call(void 0, n,_chunkAWMP5TQBcjs.q),a=l.identifiers.filter(({name:i})=>!s.getValue("identifierNames",i)&&!be.includes(i)),o=a.length===0?{}:await _inquirer2.default.prompt(a.map(({name:i})=>{let r=ae(e,i,!1);return{name:i,message:`Choose the column that will be used to map in the identifier: ${i}`,type:"list",default:r[0],choices:r}}));return await Promise.all(Object.entries(o).map(([i,r])=>s.setValue(r,"identifierNames",i))),{...s.getValue("identifierNames"),...o}}async function Ni({requestActions:n,cancellationTitle:e,auth:s,requestIds:l,silentModeBefore:a,createdAtBefore:o,createdAtAfter:i,statuses:r=[_privacytypes.RequestStatus.Compiling,_privacytypes.RequestStatus.RequestMade,_privacytypes.RequestStatus.Delayed,_privacytypes.RequestStatus.Approving,_privacytypes.RequestStatus.Secondary,_privacytypes.RequestStatus.Enriching,_privacytypes.RequestStatus.Waiting,_privacytypes.RequestStatus.SecondaryApproving],concurrency:t=50,transcendUrl:y=_chunk35HDA5WVcjs.e}){let c=_chunkAWMP5TQBcjs.qe.call(void 0, y,s),g=new Date().getTime(),m=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),d;if(e){let T=(await _chunkAWMP5TQBcjs.ed.call(void 0, c,e)).find(v=>v.title===e);if(!T)throw new Error(`Failed to find a template with title: "${e}"`);d=T}let p=await _chunkAWMP5TQBcjs.ze.call(void 0, c,{actions:n,createdAtBefore:o,createdAtAfter:i,statuses:r,requestIds:l});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Canceling "${p.length}" requests${d?` Using template: ${d.title}`:""}.`));let f=0;m.start(p.length,0),await _chunkAWMP5TQBcjs.b.call(void 0, p,async N=>{a&&new Date(a)>new Date(N.createdAt)&&await _chunkAWMP5TQBcjs.$b.call(void 0, c,_chunkAWMP5TQBcjs._,{input:{id:N.id,isSilent:!0}}),await _chunkAWMP5TQBcjs.$b.call(void 0, c,_chunkAWMP5TQBcjs.Z,{input:{requestId:N.id,...d?{subject:`Re: ${d.subject.defaultMessage}`,template:d.template.defaultMessage}:{}}}),f+=1,m.update(f)},{concurrency:t}),m.stop();let S=new Date().getTime()-g;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully canceled ${f} requests in "${S/1e3}" seconds!`)),p.length}async function Lt(n,e,s,l){let a=l.filter(({name:i})=>!s.getValue("attributeNames",i)),o=a.length===0?{}:await _inquirer2.default.prompt(a.map(({name:i})=>{let r=ae(e,i,!1);return{name:i,message:`Choose the column that will be used to map in the attribute: ${i}`,type:"list",default:r[0],choices:r}}));return await Promise.all(Object.entries(o).map(([i,r])=>s.setValue(r,"attributeNames",i))),{...s.getValue("attributeNames"),...o}}var $t=/{\\"message\\":\\"(.+?)\\",/;function Ie(n){return $t.test(n)?$t.exec(n)[1]:null}var _persistedstate = require('@transcend-io/persisted-state');async function sn({cacheFilepath:n,requestReceiptFolder:e,file:s,auth:l,sombraAuth:a,concurrency:o=100,defaultPhoneCountryCode:i="1",transcendUrl:r=_chunk35HDA5WVcjs.e,attributes:t=[],emailIsVerified:y=!0,skipFilterStep:c=!1,skipSendingReceipt:g=!0,isTest:m=!1,isSilent:d=!0,debug:p=!1,dryRun:f=!1}){let h=new Date().getTime(),S=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),N=ut(t),T=new (0, _persistedstate.PersistedState)(n,rt,{columnNames:{},requestTypeToRequestAction:{},subjectTypeToSubjectName:{},languageToLocale:{},statusToRequestStatus:{},identifierNames:{},attributeNames:{},regionToCountrySubDivision:{},regionToCountry:{}}),v=_path.join.call(void 0, e,`tr-request-upload-${new Date().toISOString()}-${s.split("/").pop()}`.replace(".csv",".json")),x=new (0, _persistedstate.PersistedState)(v,st,{successfulRequests:[],duplicateRequests:[],failingRequests:[]}),K=await _chunkAWMP5TQBcjs.re.call(void 0, r,l,a),$=ct(s,de.record(de.string,de.string)),_=_chunkQBBOYJ3Ocjs.j.call(void 0, $.map(U=>Object.keys(U)).flat());if($.length===0)throw new Error("No Requests found in list! Ensure the first row of the CSV is a header and the rest are requests.");if(p){let U=$[0];_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`First request: ${JSON.stringify(U,null,2)}`))}let z=c?$:await pt($),j=_chunkAWMP5TQBcjs.qe.call(void 0, r,l),L=await _chunkAWMP5TQBcjs.xe.call(void 0, j),B=await gt(_,T),Y=await vt(j,_,T),k=await Lt(j,_,T,L);await yt(j,z,{state:T,columnNameMap:B});let O=qt(z,T,{defaultPhoneCountryCode:i,columnNameMap:B,identifierNameMap:Y,attributeNameMap:k,requestAttributeKeys:L});p||S.start(O.length,0);let X=0;await _chunkAWMP5TQBcjs.b.call(void 0, O,async([U,V],Q)=>{let _e=p?`email:${V.email} | coreIdentifier:${V.coreIdentifier}`:`row:${Q.toString()}`;if(p&&_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`[${Q+1}/${O.length}] Importing: ${JSON.stringify(V,null,2)}`)),f){_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Bailing out on dry run because dryRun is set"));return}try{let ee=await It(K,V,{details:`Uploaded by Transcend Cli: "tr-request-upload" : ${JSON.stringify(U,null,2)}`,isTest:m,emailIsVerified:y,skipSendingReceipt:g,isSilent:d,additionalAttributes:N});p&&(_chunkZUNVPK23cjs.a.info(_colors2.default.green(`[${Q+1}/${O.length}] Successfully submitted the test data subject request: "${_e}"`)),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`[${Q+1}/${O.length}] View it at: "${ee.link}"`)));let oe=x.getValue("successfulRequests");oe.push({id:ee.id,link:ee.link,rowIndex:Q,coreIdentifier:ee.coreIdentifier,attemptedAt:new Date().toISOString()}),await x.setValue(oe,"successfulRequests")}catch(ee){let oe=`${ee.message} - ${JSON.stringify(_optionalChain([ee, 'access', _18 => _18.response, 'optionalAccess', _19 => _19.body]),null,2)}`,Pe=Ie(oe);if(Pe==="Client error: You have already made this request."){p&&_chunkZUNVPK23cjs.a.info(_colors2.default.yellow(`[${Q+1}/${O.length}] Skipping request as it is a duplicate`));let le=x.getValue("duplicateRequests");le.push({coreIdentifier:V.coreIdentifier,rowIndex:Q,attemptedAt:new Date().toISOString()}),await x.setValue(le,"duplicateRequests")}else{let le=x.getValue("failingRequests");le.push({...V,rowIndex:Q,error:Pe||oe,attemptedAt:new Date().toISOString()}),await x.setValue(le,"failingRequests"),p&&(_chunkZUNVPK23cjs.a.error(_colors2.default.red(Pe||oe)),_chunkZUNVPK23cjs.a.error(_colors2.default.red(`[${Q+1}/${O.length}] Failed to submit request for: "${_e}"`)))}}X+=1,p||S.update(X)},{concurrency:o}),S.stop();let ue=new Date().getTime()-h;_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Completed upload in "${ue/1e3}" seconds.`)),x.getValue("duplicateRequests").length>0&&_chunkZUNVPK23cjs.a.info(_colors2.default.yellow(`Encountered "${x.getValue("duplicateRequests").length}" duplicate requests. See "${v}" to review the core identifiers for these requests.`)),x.getValue("failingRequests").length>0&&(_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Encountered "${x.getValue("failingRequests").length}" errors. See "${v}" to review the error messages and inputs.`)),process.exit(1))}async function _t(n,e,{sendEmailReceipt:s=!1,skipWaitingPeriod:l=!1,emailIsVerified:a=!0,requestIdentifiers:o=[]}={}){let i=await n.post("v1/data-subject-request",{json:{type:e.type,subject:{coreIdentifier:e.coreIdentifier,email:e.email,emailIsVerified:a,...o.length>0?{attestedExtraIdentifiers:_typeutils.apply.call(void 0, _chunkQBBOYJ3Ocjs.d.call(void 0, o.filter(t=>!(t.name==="email"&&t.value===e.email)&&!be.includes(t.name)).map(t=>({...t,type:Object.values(_privacytypes.IdentifierType).includes(t.name)?t.name:_privacytypes.IdentifierType.Custom})),"type"),(t,y)=>t.map(({name:c,value:g})=>({...y===_privacytypes.IdentifierType.Custom?{name:c}:{},value:g})))}:{}},requestId:e.id,subjectType:e.subjectType,isSilent:e.isSilent,isTest:e.isTest,locale:e.locale,skipWaitingPeriod:l,createdAt:e.createdAt,details:`Restarted by Transcend cli: "tr-request-restart" - ${e.details}`,skipSendingReceipt:!s}}).json(),{request:r}=_typeutils.decodeCodec.call(void 0, Ft.type({request:Le}),i);return r}var Hr=M.intersection([Te,M.type({error:M.string})]),Xr=M.type({restartedRequests:M.array(Te),failingRequests:M.array(Hr)});async function wn({requestReceiptFolder:n,auth:e,sombraAuth:s,requestActions:l,requestStatuses:a,createdAtBefore:o,createdAtAfter:i,transcendUrl:r=_chunk35HDA5WVcjs.e,requestIds:t=[],createdAt:y=new Date,silentModeBefore:c,sendEmailReceipt:g=!1,emailIsVerified:m=!0,copyIdentifiers:d=!1,skipWaitingPeriod:p=!1,concurrency:f=20}){let h=new Date().getTime(),S=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),N=_path.join.call(void 0, n,`tr-request-restart-${new Date().toISOString()}`),T=new (0, _persistedstate.PersistedState)(N,Xr,{restartedRequests:[],failingRequests:[]}),v=await _chunkAWMP5TQBcjs.re.call(void 0, r,e,s),x=_chunkAWMP5TQBcjs.qe.call(void 0, r,e),$=(await _chunkAWMP5TQBcjs.ze.call(void 0, x,{actions:l,statuses:a,createdAtBefore:o,createdAtAfter:i})).filter(L=>new Date(L.createdAt)<y);if(_chunkZUNVPK23cjs.a.info(`Found ${$.length} requests to process`),d&&_chunkZUNVPK23cjs.a.info("copyIdentifiers detected - All Identifiers will be copied."),g&&_chunkZUNVPK23cjs.a.info("sendEmailReceipt detected - Email receipts will be sent."),p&&_chunkZUNVPK23cjs.a.info("skipWaitingPeriod detected - Waiting period will be skipped."),t.length>0&&t.length!==$.length){let L=_chunkQBBOYJ3Ocjs.c.call(void 0, t,$.map(({id:B})=>B));L.length>0&&(_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Failed to find the following requests by ID: ${L.join(",")}.`)),process.exit(1))}let _=0;S.start($.length,0),await _chunkAWMP5TQBcjs.b.call(void 0, $,async(L,B)=>{try{let Y=d?await _chunkAWMP5TQBcjs.Be.call(void 0, x,v,{requestId:L.id}):[],k=await _t(v,{...L,isSilent:c&&new Date(L.createdAt)<c?!0:L.isSilent},{requestIdentifiers:Y,skipWaitingPeriod:p,sendEmailReceipt:g,emailIsVerified:m}),O=T.getValue("restartedRequests");O.push({id:k.id,link:k.link,rowIndex:B,coreIdentifier:k.coreIdentifier,attemptedAt:new Date().toISOString()}),await T.setValue(O,"restartedRequests")}catch(Y){let k=`${Y.message} - ${JSON.stringify(_optionalChain([Y, 'access', _20 => _20.response, 'optionalAccess', _21 => _21.body]),null,2)}`,O=Ie(k),X=T.getValue("failingRequests");X.push({id:L.id,link:L.link,rowIndex:B,coreIdentifier:L.coreIdentifier,attemptedAt:new Date().toISOString(),error:O||k}),await T.setValue(X,"failingRequests")}_+=1,S.update(_)},{concurrency:f}),S.stop();let j=new Date().getTime()-h;_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Completed restarting of requests in "${j/1e3}" seconds.`)),T.getValue("failingRequests").length>0&&(_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Encountered "${T.getValue("failingRequests").length}" errors. See "${N}" to review the error messages and inputs.`)),process.exit(1))}async function Ln({enricherIds:n,auth:e,concurrency:s=100,transcendUrl:l=_chunk35HDA5WVcjs.e}){let a=_chunkAWMP5TQBcjs.qe.call(void 0, l,e),o=new Date().getTime(),i=await _chunkAWMP5TQBcjs.ze.call(void 0, a,{statuses:[_privacytypes.RequestStatus.Enriching]});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Processing enricher: "${n.join(",")}" fetched "${i.length}" in enriching status.`));let r=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),t=0;r.start(i.length,0);let y=0;await _chunkAWMP5TQBcjs.b.call(void 0, i,async m=>{let p=(await _chunkAWMP5TQBcjs.Ce.call(void 0, a,{requestId:m.id})).filter(f=>n.includes(f.enricher.id)&&![_privacytypes.RequestEnricherStatus.Resolved,_privacytypes.RequestEnricherStatus.Skipped].includes(f.status));p.length>0&&await _chunkAWMP5TQBcjs.a.call(void 0, p,async f=>{try{await _chunkAWMP5TQBcjs.$b.call(void 0, a,_chunkAWMP5TQBcjs.ea,{requestEnricherId:f.id}),y+=1}catch(h){if(!h.message.includes("Client error: Cannot skip Request enricher because it has already completed"))throw h}}),t+=1,r.update(t)},{concurrency:s}),r.stop();let g=new Date().getTime()-o;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully skipped "${y}" for "${i.length}" requests in "${g/1e3}" seconds!`)),i.length}async function Qn({auth:n,requestActions:e=[],createdAtBefore:s,createdAtAfter:l,transcendUrl:a=_chunk35HDA5WVcjs.e,requestEnricherStatuses:o=Object.values(_privacytypes.RequestEnricherStatus),requestIds:i=[],enricherId:r,concurrency:t=20}){let y=new Date().getTime(),c=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),g=_chunkAWMP5TQBcjs.qe.call(void 0, a,n);_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Fetching requests to restart..."));let m=await _chunkAWMP5TQBcjs.ze.call(void 0, g,{actions:e,statuses:[_privacytypes.RequestStatus.Enriching],createdAtBefore:s,createdAtAfter:l,requestIds:i}),d=0;if(i.length>0&&i.length!==m.length){let S=_chunkQBBOYJ3Ocjs.c.call(void 0, i,m.map(({id:N})=>N));S.length>0&&(_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Failed to find the following requests by ID: ${S.join(",")}.`)),process.exit(1))}let p=0;c.start(m.length,0),await _chunkAWMP5TQBcjs.b.call(void 0, m,async S=>{let T=(await _chunkAWMP5TQBcjs.Ce.call(void 0, g,{requestId:S.id})).filter(v=>v.enricher.id===r&&o.includes(v.status));await _chunkAWMP5TQBcjs.b.call(void 0, T,async v=>{await _chunkAWMP5TQBcjs.te.call(void 0, g,v.id),d+=1}),p+=1,c.update(p)},{concurrency:t}),c.stop();let h=new Date().getTime()-y;_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Completed restarting of ${m.length} requests and ${d} enrichers in "${h/1e3}" seconds.`))}async function ea({requestActions:n,dataSiloId:e,auth:s,concurrency:l=20,transcendUrl:a=_chunk35HDA5WVcjs.e}){let o=_chunkAWMP5TQBcjs.qe.call(void 0, a,s),i=new Date().getTime(),r=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),t=await _chunkAWMP5TQBcjs.ze.call(void 0, o,{actions:n,statuses:[_privacytypes.RequestStatus.Compiling,_privacytypes.RequestStatus.Approving]});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Retrying requests for Data Silo: "${e}", restarting "${t.length}" requests.`));let y=0,c=0;r.start(t.length,0),await _chunkAWMP5TQBcjs.b.call(void 0, t,async d=>{try{let p=await _chunkAWMP5TQBcjs.Ee.call(void 0, o,{requestId:d.id,dataSiloId:e});await _chunkAWMP5TQBcjs.$b.call(void 0, o,_chunkAWMP5TQBcjs.xa,{requestDataSiloId:p.id})}catch(p){if(!p.message.includes("Failed to find RequestDataSilo"))throw p;c+=1}y+=1,r.update(y)},{concurrency:l}),r.stop();let m=new Date().getTime()-i;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully notified Transcend in "${m/1e3}" seconds for ${y} requests, ${c} requests were skipped because data silo was not attached to the request!`)),t.length}async function ca({auth:n,sombraAuth:e,actions:s=[],statuses:l=[],identifierSearch:a,pageLimit:o=100,transcendUrl:i=_chunk35HDA5WVcjs.e,createdAtBefore:r,createdAtAfter:t,isTest:y}){let c=_chunkAWMP5TQBcjs.qe.call(void 0, i,n),g=await _chunkAWMP5TQBcjs.re.call(void 0, i,n,e),m="";r&&(m+=` before ${r.toISOString()}`),t&&(m+=`${m?", and":""} after ${t.toISOString()}`),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`${s.length>0?`Pulling requests of type "${s.join('" , "')}"`:"Pulling all requests"}${m}`));let d=await _chunkAWMP5TQBcjs.ze.call(void 0, c,{actions:s,text:a,statuses:l,createdAtBefore:r,createdAtAfter:t,isTest:y}),p=await _chunkAWMP5TQBcjs.b.call(void 0, d,async h=>{let S=await _chunkAWMP5TQBcjs.Be.call(void 0, c,g,{requestId:h.id});return{...h,requestIdentifiers:S}},{concurrency:o});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Pulled ${p.length} requests`));let f=p.map(({attributeValues:h,requestIdentifiers:S,id:N,email:T,type:v,status:x,subjectType:K,details:$,createdAt:_,country:z,locale:j,origin:L,countrySubDivision:B,isSilent:Y,isTest:k,coreIdentifier:O,...X})=>({"Request ID":N,"Created At":_,Email:T,"Core Identifier":O,"Request Type":v,"Data Subject Type":K,Status:x,Country:z,"Country Sub Division":B,Details:$,Origin:L,"Silent Mode":Y,"Is Test Request":k,Language:j,...X,...Object.entries(_chunkQBBOYJ3Ocjs.d.call(void 0, h,"attributeKey.name")).reduce((ge,[ue,U])=>Object.assign(ge,{[ue]:U.map(({name:V})=>V).join(",")}),{}),...Object.entries(_chunkQBBOYJ3Ocjs.d.call(void 0, S,"name")).reduce((ge,[ue,U])=>Object.assign(ge,{[ue]:U.map(({value:V})=>V).join(",")}),{})}));return{requestsWithRequestIdentifiers:p,requestsFormattedForCsv:f}}async function ha({dataSiloId:n,auth:e,concurrency:s=100,status:l="SKIPPED",transcendUrl:a=_chunk35HDA5WVcjs.e,requestStatuses:o=[_privacytypes.RequestStatus.Compiling,_privacytypes.RequestStatus.Secondary]}){let i=_chunkAWMP5TQBcjs.qe.call(void 0, a,e),r=new Date().getTime(),t=await _chunkAWMP5TQBcjs.De.call(void 0, i,{dataSiloId:n,requestStatuses:o});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Processing data silo: "${n}" marking "${t.length}" requests as skipped.`));let y=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),c=0;y.start(t.length,0),await _chunkAWMP5TQBcjs.b.call(void 0, t,async d=>{try{await _chunkAWMP5TQBcjs.$b.call(void 0, i,_chunkAWMP5TQBcjs.wa,{requestDataSiloId:d.id,status:l})}catch(p){if(!p.message.includes("Client error: Request must be active:"))throw p}c+=1,y.update(c)},{concurrency:s}),y.stop();let m=new Date().getTime()-r;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully skipped "${t.length}" requests in "${m/1e3}" seconds!`)),t.length}async function Ea({requestActions:n,identifierNames:e,auth:s,concurrency:l=20,transcendUrl:a=_chunk35HDA5WVcjs.e}){let o=_chunkAWMP5TQBcjs.qe.call(void 0, a,s),i=new Date().getTime(),r=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),t=await _chunkAWMP5TQBcjs.ze.call(void 0, o,{actions:n,statuses:[_privacytypes.RequestStatus.Enriching]});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Fetched requests in preflight/enriching state."));let y=0,c=0;r.start(t.length,0),await _chunkAWMP5TQBcjs.b.call(void 0, t,async d=>{let f=(await _chunkAWMP5TQBcjs.ve.call(void 0, o,{requestId:d.id})).filter(({isVerifiedAtLeastOnce:h,name:S})=>h===!1&&e.includes(S)).map(({id:h})=>h);f.length>0&&(await _chunkAWMP5TQBcjs.$b.call(void 0, o,_chunkAWMP5TQBcjs.Ca,{input:{requestId:d.id,requestIdentifierIds:f}}),c+=f.length),y+=1,r.update(y)},{concurrency:l}),r.stop();let m=new Date().getTime()-i;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully cleared out unverified identifiers "${m/1e3}" seconds for ${y} requests, ${c} identifiers were cleared out!`)),t.length}exports.a = A; exports.b = pe; exports.c = De; exports.d = be; exports.e = ne; exports.f = et; exports.g = tt; exports.h = rt; exports.i = Te; exports.j = st; exports.k = Ae; exports.l = ae; exports.m = te; exports.n = Ee; exports.o = at; exports.p = ut; exports.q = ct; exports.r = G; exports.s = pt; exports.t = Us; exports.u = gt; exports.v = yt; exports.w = Pr; exports.x = ho; exports.y = Dr; exports.z = qt; exports.A = St; exports.B = xr; exports.C = Lr; exports.D = bt; exports.E = Tt; exports.F = Uo; exports.G = Le; exports.H = It; exports.I = oi; exports.J = fi; exports.K = vt; exports.L = Ni; exports.M = Lt; exports.N = Ie; exports.O = sn; exports.P = _t; exports.Q = wn; exports.R = Ln; exports.S = Qn; exports.T = ea; exports.U = ca; exports.V = ha; exports.W = Ea;
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
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 _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 _chunkR77JR6OQcjs = require('./chunk-R77JR6OQ.cjs');var _chunkZUNVPK23cjs = require('./chunk-ZUNVPK23.cjs');var _chunkVIPFYWRRcjs = require('./chunk-VIPFYWRR.cjs');var _chunkEAJZX4TXcjs = require('./chunk-EAJZX4TX.cjs');var _typeutils = require('@transcend-io/type-utils');var _internationalization = require('@transcend-io/internationalization');var _privacytypes = require('@transcend-io/privacy-types');var _iots = require('io-ts'); var R = _interopRequireWildcard(_iots); var re = _interopRequireWildcard(_iots); var lt = _interopRequireWildcard(_iots); var D = _interopRequireWildcard(_iots); var q = _interopRequireWildcard(_iots); var I = _interopRequireWildcard(_iots); var de = _interopRequireWildcard(_iots); var Ft = _interopRequireWildcard(_iots); var M = _interopRequireWildcard(_iots);var A="[NONE]",pe= exports.b ="[APPLY VALUE TO ALL ROWS]",De= exports.c ="<blank>",be= exports.d =["email","coreIdentifier"],ne= exports.e =(c=>(c.Email="email",c.CoreIdentifier="coreIdentifier",c.RequestType="requestType",c.SubjectType="subjectType",c.Locale="locale",c.Country="country",c.CountrySubDivision="countrySubDivision",c.RequestStatus="requestStatus",c.CreatedAt="createdAt",c.DataSiloIds="dataSiloIds",c))(ne||{}),et= exports.f ={email:!1,coreIdentifier:!0,requestType:!0,subjectType:!0,requestStatus:!1,createdAt:!1,dataSiloIds:!1,locale:!1,country:!1,countrySubDivision:!1},tt= exports.g ={requestType:!0,subjectType:!0},rt= exports.h =R.type({columnNames:R.partial(_typeutils.applyEnum.call(void 0, ne,()=>R.string)),identifierNames:R.record(R.string,R.string),attributeNames:R.record(R.string,R.string),requestTypeToRequestAction:R.record(R.string,_typeutils.valuesOf.call(void 0, _privacytypes.RequestAction)),subjectTypeToSubjectName:R.record(R.string,R.string),languageToLocale:R.record(R.string,_typeutils.valuesOf.call(void 0, _internationalization.LanguageKey)),regionToCountry:R.record(R.string,_typeutils.valuesOf.call(void 0, {..._privacytypes.IsoCountryCode,[A]:A})),regionToCountrySubDivision:R.record(R.string,_typeutils.valuesOf.call(void 0, {..._privacytypes.IsoCountrySubdivisionCode,[A]:A})),statusToRequestStatus:R.record(R.string,_typeutils.valuesOf.call(void 0, {..._privacytypes.CompletedRequestStatus,[A]:A}))}),Te= exports.i =R.type({id:R.string,link:R.string,rowIndex:R.number,coreIdentifier:R.string,attemptedAt:R.string}),st= exports.j =R.type({failingRequests:R.array(R.record(R.string,R.any)),successfulRequests:R.array(Te),duplicateRequests:R.array(R.type({rowIndex:R.number,coreIdentifier:R.string,attemptedAt:R.string}))});var _inquirer = require('inquirer'); var _inquirer2 = _interopRequireDefault(_inquirer);var _fuzzysearch = require('fuzzysearch'); var _fuzzysearch2 = _interopRequireDefault(_fuzzysearch);function Ae(n,e){return _fuzzysearch2.default.call(void 0, n.toLowerCase(),e.toLowerCase())||_fuzzysearch2.default.call(void 0, e.toLowerCase(),n.toLowerCase())}function ae(n,e,s,l){let a=n.filter(o=>Ae(e.toLowerCase(),o.toLowerCase()));return[...a,new _inquirer2.default.Separator,...s?[]:[A],...l?[pe]:[],...n.filter(o=>!a.includes(o))]}var _inquirerautocompleteprompt = require('inquirer-autocomplete-prompt'); var _inquirerautocompleteprompt2 = _interopRequireDefault(_inquirerautocompleteprompt);async function te(n,e,s){_inquirer2.default.registerPrompt("autocomplete",_inquirerautocompleteprompt2.default);let l=n.map(o=>o||"<blank>").filter(o=>!s[o]);if(l.length===0)return s;let a=await _inquirer2.default.prompt(l.map(o=>({name:o,message:`Map value of: ${o}`,type:"autocomplete",default:e.find(i=>Ae(o,i)),source:(i,r)=>r?e.filter(t=>typeof t=="string"&&Ae(r,t)):e})));return{...s,..._typeutils.apply.call(void 0, a,o=>typeof o=="string"?o:Object.values(o)[0])}}function Ee(n){return n.split(",").map(e=>e.trim()).filter(e=>e)}var _colors = require('colors'); var _colors2 = _interopRequireDefault(_colors);var at=re.type({key:re.string,values:re.array(re.string)});function ut(n){let e=n.map(s=>{let[l,a]=s.trim().split(":");if(!a)throw new Error("Expected attributes in key:value1;value2,key2:value3;value4");let o=a.split(";");return{key:l,values:o}});return _chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Attributes to apply to all requests:")),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(JSON.stringify(e,null,2))),e}var _sync = require('csv-parse/sync');var _fs = require('fs');function ct(n,e,s={columns:!0}){let l=_sync.parse.call(void 0, _fs.readFileSync.call(void 0, n,"utf-8"),s);return _typeutils.decodeCodec.call(void 0, lt.array(e),l).map(i=>Object.entries(i).reduce((r,[t,y])=>Object.assign(r,{[t.replace(/[^a-z_.+\-A-Z -~]/g,"")]:y}),{}))}function G(n,e){return _chunkEAJZX4TXcjs.j.call(void 0, n.map(s=>s[e]||"").flat())}async function pt(n){let e=_chunkEAJZX4TXcjs.j.call(void 0, n.map(a=>Object.keys(a)).flat()),s=n,l=!0;for(;l;){let{filterColumnName:a}=await _inquirer2.default.prompt([{name:"filterColumnName",message:`If you need to filter the list of requests to import, choose the column to filter on. Currently ${s.length} rows.`,type:"list",default:e,choices:[A,...e]}]);if(l=A!==a,l){let o=G(s,a),{valuesToKeep:i}=await _inquirer2.default.prompt([{name:"valuesToKeep",message:"Keep rows matching this value",type:"checkbox",default:e,choices:o}]);s=s.filter(r=>i.includes(r[a]))}}return _chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Importing ${s.length} requests`)),s}var _cliprogress = require('cli-progress'); var _cliprogress2 = _interopRequireDefault(_cliprogress);async function Us({requestActions:n,auth:e,requestIds:s,statuses:l=[_privacytypes.RequestStatus.Compiling,_privacytypes.RequestStatus.RequestMade,_privacytypes.RequestStatus.Delayed,_privacytypes.RequestStatus.Approving,_privacytypes.RequestStatus.Secondary,_privacytypes.RequestStatus.Enriching,_privacytypes.RequestStatus.Waiting,_privacytypes.RequestStatus.SecondaryApproving],createdAtAfter:a,createdAtBefore:o,concurrency:i=100,transcendUrl:r=_chunkVIPFYWRRcjs.e}){let t=_chunkR77JR6OQcjs.Wd.call(void 0, r,e),y=new Date().getTime(),c=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),g=await _chunkR77JR6OQcjs.ne.call(void 0, t,{actions:n,statuses:l,createdAtBefore:o,createdAtAfter:a,isSilent:!1,requestIds:s});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Marking "${g.length}" as silent mode.`));let m=0;c.start(g.length,0),await _chunkR77JR6OQcjs.b.call(void 0, g,async f=>{await _chunkR77JR6OQcjs.cc.call(void 0, t,_chunkR77JR6OQcjs._,{input:{id:f.id,isSilent:!0}}),m+=1,c.update(m)},{concurrency:i}),c.stop();let p=new Date().getTime()-y;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully marked ${m} requests as silent mode in "${p/1e3}" seconds!`)),g.length}async function gt(n,e){let s=_typeutils.getValues.call(void 0, ne).filter(a=>!e.getValue("columnNames",a)),l=s.length===0?{}:await _inquirer2.default.prompt(s.map(a=>{let o=_chunkEAJZX4TXcjs.h.call(void 0, a.replace("ColumnName","")),i=ae(n,o,et[a],!!tt[a]);return{name:a,message:`Choose the column that will be used to map in the field: ${o}`,type:"list",default:i[0],choices:i}}));return await Promise.all(_typeutils.getEntries.call(void 0, l).map(([a,o])=>e.setValue(o,"columnNames",a))),l}async function yt(n,e,{state:s,columnNameMap:l}){let a=f=>s.getValue("columnNames",f)||l[f],{internalSubjects:o}=await _chunkR77JR6OQcjs.cc.call(void 0, n,_chunkR77JR6OQcjs.y);_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Determining mapping of columns for request action"));let i=await te(G(e,a("requestType")),Object.values(_privacytypes.RequestAction),s.getValue("requestTypeToRequestAction"));await s.setValue(i,"requestTypeToRequestAction"),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Determining mapping of columns for subject"));let r=await te(G(e,a("subjectType")),o.map(({type:f})=>f),s.getValue("subjectTypeToSubjectName"));await s.setValue(r,"subjectTypeToSubjectName"),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Determining mapping of columns for locale"));let t=await te(G(e,a("locale")),Object.values(_internationalization.LanguageKey),s.getValue("languageToLocale"));await s.setValue(t,"languageToLocale"),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Determining mapping of columns for request status")),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Determining mapping of columns for request status"));let y=a("requestStatus"),c=y===A?{}:await te(G(e,y),[...Object.values(_privacytypes.CompletedRequestStatus),A],s.getValue("statusToRequestStatus"));await s.setValue(c,"statusToRequestStatus"),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Determining mapping of columns for country"));let g=a("country"),m=g===A?{}:await te(G(e,g),[...Object.values(_privacytypes.IsoCountryCode),A],s.getValue("regionToCountry"));await s.setValue(m,"regionToCountry"),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Determining mapping of columns for country sub division"));let d=a("countrySubDivision"),p=d===A?{}:await te(G(e,d),[...Object.values(_privacytypes.IsoCountrySubdivisionCode),A],s.getValue("regionToCountrySubDivision"));await s.setValue(p,"regionToCountrySubDivision")}var _iotstypes = require('io-ts-types');var Pr=D.record(D.string,D.array(D.intersection([D.type({value:D.string}),D.partial({name:D.string})]))),ho= exports.x =D.intersection([D.type({email:D.string,attestedExtraIdentifiers:Pr,coreIdentifier:D.string,requestType:_typeutils.valuesOf.call(void 0, _privacytypes.RequestAction),subjectType:D.string}),D.partial({country:_typeutils.valuesOf.call(void 0, _privacytypes.IsoCountryCode),countrySubDivision:_typeutils.valuesOf.call(void 0, _privacytypes.IsoCountrySubdivisionCode),attributes:D.array(at),status:_typeutils.valuesOf.call(void 0, _privacytypes.CompletedRequestStatus),createdAt:_iotstypes.DateFromISOString,dataSiloIds:D.array(D.string),locale:_typeutils.valuesOf.call(void 0, _internationalization.LanguageKey)})]);function Dr(n,e,s){if(e===_privacytypes.IdentifierType.Email)return n.toLowerCase();if(e===_privacytypes.IdentifierType.Phone){let l=n.replace(_privacytypes.NORMALIZE_PHONE_NUMBER,"").replace(/[()]/g,"").replace(/[–]/g,"").replace(/[:]/g,"").replace(/[]/g,"").replace(/[A-Za-z]/g,"");return l?l.startsWith("+")?l:`+${s}${l}`:""}return n}function qt(n,e,{columnNameMap:s,identifierNameMap:l,attributeNameMap:a,requestAttributeKeys:o,defaultPhoneCountryCode:i="1"}){let r=t=>e.getValue("columnNames",t)||s[t];return n.map(t=>{let y={};Object.entries(l).filter(([,d])=>d!==A).forEach(([d,p])=>{let f=Object.values(_privacytypes.IdentifierType).includes(d)?d:_privacytypes.IdentifierType.Custom,h=t[p];if(h){let S=Dr(h,f,i);S&&(y[f]||(y[f]=[]),y[f].push({value:S,name:d}))}});let c=[];Object.entries(a).filter(([,d])=>d!==A).forEach(([d,p])=>{let f=t[p];if(f){let h=_optionalChain([o, 'access', _2 => _2.find, 'call', _3 => _3(S=>S.name===d), 'optionalAccess', _4 => _4.type])==="MULTI_SELECT";c.push({values:h?Ee(f):f,key:d})}});let g=r("requestType"),m=r("subjectType");return[t,{email:t[r("email")],attestedExtraIdentifiers:y,attributes:c,coreIdentifier:t[r("coreIdentifier")],requestType:g===pe?e.getValue("requestTypeToRequestAction",De):e.getValue("requestTypeToRequestAction",t[g]),subjectType:m===pe?e.getValue("subjectTypeToSubjectName",De):e.getValue("subjectTypeToSubjectName",t[m]),...r("locale")!==A&&t[r("locale")]?{locale:e.getValue("languageToLocale",t[r("locale")])}:{},...r("country")!==A&&t[r("country")]?{country:e.getValue("regionToCountry",t[r("country")])}:{},...r("countrySubDivision")!==A&&t[r("countrySubDivision")]?{countrySubDivision:e.getValue("regionToCountrySubDivision",t[r("countrySubDivision")])}:{},...r("requestStatus")!==A&&e.getValue("statusToRequestStatus",t[r("requestStatus")])!==A&&t[r("requestStatus")]?{status:e.getValue("statusToRequestStatus",t[r("requestStatus")])}:{},...r("createdAt")!==A&&t[r("createdAt")]?{createdAt:new Date(t[r("createdAt")])}:{},...r("dataSiloIds")!==A&&t[r("dataSiloIds")]?{dataSiloIds:Ee(t[r("dataSiloIds")])}:{}}]})}var St=q.type({defaultMessage:q.string,id:q.string}),xr= exports.B =q.type({downloadKey:q.string,error:q.union([q.null,q.string]),mimetype:q.string,size:q.string,fileName:q.string,dataPoint:q.type({id:q.string,title:q.union([St,q.null]),description:q.union([St,q.null]),name:q.string,slug:q.string,encryption:q.union([_typeutils.valuesOf.call(void 0, _privacytypes.TableEncryptionType),q.null]),dataSilo:q.type({id:q.string,title:q.string,description:q.string,type:q.string,outerType:q.union([q.string,q.null])}),path:q.array(q.string)})}),Lr= exports.C =q.type({nodes:q.array(xr),totalCount:q.number,_links:q.partial({next:q.union([q.string,q.null]),previous:q.union([q.string,q.null])})});async function bt(n,{sombra:e,concurrency:s=5,limit:l=100}){_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Pulling file metadata for ${n.length} requests`));let a=new Date().getTime(),o=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),i=0;o.start(n.length,0);let r=await _chunkR77JR6OQcjs.b.call(void 0, n,async c=>{let g=[],m=!0,d=0;for(;m;){let p;try{let f=await e.get(`v1/data-subject-request/${c.id}/download-keys`,{searchParams:{limit:l,offset:d}}).json();p=_typeutils.decodeCodec.call(void 0, Lr,f),g.push(...p.nodes),d+=l,m=!!p._links.next&&p.nodes.length===l}catch(f){throw new Error(`Received an error from server: ${_optionalChain([f, 'optionalAccess', _5 => _5.response, 'optionalAccess', _6 => _6.body])||_optionalChain([f, 'optionalAccess', _7 => _7.message])}`)}}return i+=1,o.update(i),[c,g]},{concurrency:s});o.stop();let y=new Date().getTime()-a;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully downloaded file metadata ${n.length} requests in "${y/1e3}" seconds!`)),r}async function Tt(n,{requestId:e,sombra:s,onFileDownloaded:l,concurrency:a=20}){await _chunkR77JR6OQcjs.b.call(void 0, n,async o=>{try{await s.get("v1/files",{searchParams:{downloadKey:o.downloadKey}}).buffer().then(i=>l(o,i))}catch(i){if(_optionalChain([i, 'optionalAccess', _8 => _8.response, 'optionalAccess', _9 => _9.body, 'optionalAccess', _10 => _10.includes, 'call', _11 => _11("fileMetadata#verify")])){_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Failed to pull file for: ${o.fileName} (request:${e}) - JWT expired. This likely means that the file is no longer available. Try restarting the request from scratch in Transcend Admin Dashboard. Skipping the download of this file.`));return}throw new Error(`Received an error from server: ${_optionalChain([i, 'optionalAccess', _12 => _12.response, 'optionalAccess', _13 => _13.body])||_optionalChain([i, 'optionalAccess', _14 => _14.message])}`)}},{concurrency:a})}var _path = require('path');async function Uo({auth:n,folderPath:e,requestIds:s,createdAtBefore:l,sombraAuth:a,createdAtAfter:o,statuses:i=[_privacytypes.RequestStatus.Approving,_privacytypes.RequestStatus.Downloadable],concurrency:r=5,transcendUrl:t=_chunkVIPFYWRRcjs.e,approveAfterDownload:y=!1}){let c=_chunkR77JR6OQcjs.Wd.call(void 0, t,n),g=await _chunkR77JR6OQcjs.Xd.call(void 0, t,n,a);_fs.existsSync.call(void 0, e)||_fs.mkdirSync.call(void 0, e);let m=await _chunkR77JR6OQcjs.ne.call(void 0, c,{actions:[_privacytypes.RequestAction.Access],createdAtBefore:l,createdAtAfter:o,statuses:i,requestIds:s}),d=await bt(m,{sombra:g,concurrency:r}),p=new Date().getTime(),f=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),h=0,S=0;f.start(m.length,0),await _chunkR77JR6OQcjs.b.call(void 0, d,async([v,x])=>{let K=_path.join.call(void 0, e,v.id);_fs.existsSync.call(void 0, K)||_fs.mkdirSync.call(void 0, K),await Tt(x,{sombra:g,requestId:v.id,onFileDownloaded:($,_)=>{let z=_path.join.call(void 0, K,$.fileName),j=_path.dirname.call(void 0, z);_fs.existsSync.call(void 0, j)||_fs.mkdirSync.call(void 0, j,{recursive:!0}),_fs.writeFileSync.call(void 0, z,_)}}),y&&v.status===_privacytypes.RequestStatus.Approving&&(await _chunkR77JR6OQcjs.cc.call(void 0, c,_chunkR77JR6OQcjs.Y,{input:{requestId:v.id}}),S+=1),h+=1,f.update(h)},{concurrency:r}),f.stop();let T=new Date().getTime()-p;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully downloaded ${h} requests in "${T/1e3}" seconds!`)),S>0&&_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Approved ${S} requests in Transcend.`)),m.length}var Le=I.type({id:I.string,link:I.string,status:_typeutils.valuesOf.call(void 0, _privacytypes.RequestStatus),type:_typeutils.valuesOf.call(void 0, _privacytypes.RequestAction),subjectType:I.string,email:I.union([I.null,I.string]),coreIdentifier:I.string,isSilent:I.boolean,isTest:I.boolean,country:I.union([I.null,_typeutils.valuesOf.call(void 0, _privacytypes.IsoCountryCode)]),countrySubDivision:I.union([I.null,_typeutils.valuesOf.call(void 0, _privacytypes.IsoCountrySubdivisionCode)]),attributeValues:I.array(I.type({attributeKey:I.type({name:I.string}),name:I.string}))});async function It(n,e,{details:s="",isTest:l=!1,emailIsVerified:a=!0,skipSendingReceipt:o=!1,isSilent:i=!0,additionalAttributes:r=[]}={}){let t=[...r];(e.attributes||[]).forEach(g=>{let m=t.find(d=>d.key===g.key);m?(m.values.push(...g.values),m.values=_chunkEAJZX4TXcjs.j.call(void 0, m.values)):t.push(g)});let y;try{y=await n.post("v1/data-subject-request",{json:{type:e.requestType,subject:{coreIdentifier:e.coreIdentifier,email:e.email,emailIsVerified:a,attestedExtraIdentifiers:e.attestedExtraIdentifiers},subjectType:e.subjectType,isSilent:i,isTest:l,skipSendingReceipt:o,...e.locale?{locale:e.locale}:{},details:s,attributes:t,...e.country||e.countrySubDivision?{region:{...e.country?{country:e.country}:e.countrySubDivision?{country:e.countrySubDivision.split("-")[0]}:{},...e.countrySubDivision?{countrySubDivision:e.countrySubDivision}:{}}}:{},...e.createdAt?{createdAt:e.createdAt}:{},...e.dataSiloIds?{dataSiloIds:e.dataSiloIds}:{},...e.status?{completedRequestStatus:e.status}:{}}}).json()}catch(g){throw new Error(`Received an error from server: ${_optionalChain([g, 'optionalAccess', _15 => _15.response, 'optionalAccess', _16 => _16.body])||_optionalChain([g, 'optionalAccess', _17 => _17.message])}`)}let{request:c}=_typeutils.decodeCodec.call(void 0, I.type({request:Le}),y);return c}async function oi({requestActions:n,requestOrigins:e,auth:s,silentModeBefore:l,createdAtAfter:a,createdAtBefore:o,concurrency:i=50,transcendUrl:r=_chunkVIPFYWRRcjs.e}){let t=_chunkR77JR6OQcjs.Wd.call(void 0, r,s),y=new Date().getTime(),c=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),g=await _chunkR77JR6OQcjs.ne.call(void 0, t,{actions:n,statuses:[_privacytypes.RequestStatus.Approving],createdAtAfter:a,origins:e,createdAtBefore:o});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Approving "${g.length}" requests.`));let m=0,d=0;c.start(g.length,0),await _chunkR77JR6OQcjs.b.call(void 0, g,async h=>{l&&new Date(l)>new Date(h.createdAt)&&await _chunkR77JR6OQcjs.cc.call(void 0, t,_chunkR77JR6OQcjs._,{input:{id:h.id,isSilent:!0}});try{await _chunkR77JR6OQcjs.cc.call(void 0, t,_chunkR77JR6OQcjs.Y,{input:{requestId:h.id}})}catch(S){S.message.includes("Request must be in an approving state,")&&(d+=1)}m+=1,c.update(m)},{concurrency:i}),c.stop();let f=new Date().getTime()-y;return d>0&&_chunkZUNVPK23cjs.a.info(_colors2.default.yellow(`${d} requests were skipped.`)),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully approved ${m} requests in "${f/1e3}" seconds!`)),g.length}async function fi({requestActions:n=Object.values(_privacytypes.RequestAction),auth:e,requestIds:s,createdAtBefore:l,days:a=45,daysLeft:o=10,createdAtAfter:i,emailTemplate:r="Additional Time Needed",concurrency:t=100,transcendUrl:y=_chunkVIPFYWRRcjs.e}){let c=_chunkR77JR6OQcjs.Wd.call(void 0, y,e),g=new Date().getTime(),m=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),p=(await _chunkR77JR6OQcjs.hd.call(void 0, c,r)).find(T=>T.title===r);if(!p)throw new Error(`Failed to find a template with title: "${r}"`);let f=await _chunkR77JR6OQcjs.ne.call(void 0, c,{actions:n,createdAtBefore:l,createdAtAfter:i,isSilent:!1,isClosed:!1,requestIds:s});f=f.filter(T=>typeof T.daysRemaining=="number"&&T.daysRemaining<o),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Notifying "${f.length}" that more time is needed.`));let h=0;m.start(f.length,0),await _chunkR77JR6OQcjs.b.call(void 0, f,async T=>{await _chunkR77JR6OQcjs.cc.call(void 0, c,_chunkR77JR6OQcjs.$,{input:{requestId:T.id,template:p.template.defaultMessage,subject:p.subject.defaultMessage,additionalTime:a}}),h+=1,m.update(h)},{concurrency:t}),m.stop();let N=new Date().getTime()-g;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully marked ${h} requests as silent mode in "${N/1e3}" seconds!`)),f.length}async function vt(n,e,s){let{initializer:l}=await _chunkR77JR6OQcjs.cc.call(void 0, n,_chunkR77JR6OQcjs.q),a=l.identifiers.filter(({name:i})=>!s.getValue("identifierNames",i)&&!be.includes(i)),o=a.length===0?{}:await _inquirer2.default.prompt(a.map(({name:i})=>{let r=ae(e,i,!1);return{name:i,message:`Choose the column that will be used to map in the identifier: ${i}`,type:"list",default:r[0],choices:r}}));return await Promise.all(Object.entries(o).map(([i,r])=>s.setValue(r,"identifierNames",i))),{...s.getValue("identifierNames"),...o}}async function Ni({requestActions:n,cancellationTitle:e,auth:s,requestIds:l,silentModeBefore:a,createdAtBefore:o,createdAtAfter:i,statuses:r=[_privacytypes.RequestStatus.Compiling,_privacytypes.RequestStatus.RequestMade,_privacytypes.RequestStatus.Delayed,_privacytypes.RequestStatus.Approving,_privacytypes.RequestStatus.Secondary,_privacytypes.RequestStatus.Enriching,_privacytypes.RequestStatus.Waiting,_privacytypes.RequestStatus.SecondaryApproving],concurrency:t=50,transcendUrl:y=_chunkVIPFYWRRcjs.e}){let c=_chunkR77JR6OQcjs.Wd.call(void 0, y,s),g=new Date().getTime(),m=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),d;if(e){let T=(await _chunkR77JR6OQcjs.hd.call(void 0, c,e)).find(v=>v.title===e);if(!T)throw new Error(`Failed to find a template with title: "${e}"`);d=T}let p=await _chunkR77JR6OQcjs.ne.call(void 0, c,{actions:n,createdAtBefore:o,createdAtAfter:i,statuses:r,requestIds:l});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Canceling "${p.length}" requests${d?` Using template: ${d.title}`:""}.`));let f=0;m.start(p.length,0),await _chunkR77JR6OQcjs.b.call(void 0, p,async N=>{a&&new Date(a)>new Date(N.createdAt)&&await _chunkR77JR6OQcjs.cc.call(void 0, c,_chunkR77JR6OQcjs._,{input:{id:N.id,isSilent:!0}}),await _chunkR77JR6OQcjs.cc.call(void 0, c,_chunkR77JR6OQcjs.Z,{input:{requestId:N.id,...d?{subject:`Re: ${d.subject.defaultMessage}`,template:d.template.defaultMessage}:{}}}),f+=1,m.update(f)},{concurrency:t}),m.stop();let S=new Date().getTime()-g;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully canceled ${f} requests in "${S/1e3}" seconds!`)),p.length}async function Lt(n,e,s,l){let a=l.filter(({name:i})=>!s.getValue("attributeNames",i)),o=a.length===0?{}:await _inquirer2.default.prompt(a.map(({name:i})=>{let r=ae(e,i,!1);return{name:i,message:`Choose the column that will be used to map in the attribute: ${i}`,type:"list",default:r[0],choices:r}}));return await Promise.all(Object.entries(o).map(([i,r])=>s.setValue(r,"attributeNames",i))),{...s.getValue("attributeNames"),...o}}var $t=/{\\"message\\":\\"(.+?)\\",/;function Ie(n){return $t.test(n)?$t.exec(n)[1]:null}var _persistedstate = require('@transcend-io/persisted-state');async function sn({cacheFilepath:n,requestReceiptFolder:e,file:s,auth:l,sombraAuth:a,concurrency:o=100,defaultPhoneCountryCode:i="1",transcendUrl:r=_chunkVIPFYWRRcjs.e,attributes:t=[],emailIsVerified:y=!0,skipFilterStep:c=!1,skipSendingReceipt:g=!0,isTest:m=!1,isSilent:d=!0,debug:p=!1,dryRun:f=!1}){let h=new Date().getTime(),S=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),N=ut(t),T=new (0, _persistedstate.PersistedState)(n,rt,{columnNames:{},requestTypeToRequestAction:{},subjectTypeToSubjectName:{},languageToLocale:{},statusToRequestStatus:{},identifierNames:{},attributeNames:{},regionToCountrySubDivision:{},regionToCountry:{}}),v=_path.join.call(void 0, e,`tr-request-upload-${new Date().toISOString()}-${s.split("/").pop()}`.replace(".csv",".json")),x=new (0, _persistedstate.PersistedState)(v,st,{successfulRequests:[],duplicateRequests:[],failingRequests:[]}),K=await _chunkR77JR6OQcjs.Xd.call(void 0, r,l,a),$=ct(s,de.record(de.string,de.string)),_=_chunkEAJZX4TXcjs.j.call(void 0, $.map(U=>Object.keys(U)).flat());if($.length===0)throw new Error("No Requests found in list! Ensure the first row of the CSV is a header and the rest are requests.");if(p){let U=$[0];_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`First request: ${JSON.stringify(U,null,2)}`))}let z=c?$:await pt($),j=_chunkR77JR6OQcjs.Wd.call(void 0, r,l),L=await _chunkR77JR6OQcjs.ce.call(void 0, j),B=await gt(_,T),Y=await vt(j,_,T),k=await Lt(j,_,T,L);await yt(j,z,{state:T,columnNameMap:B});let O=qt(z,T,{defaultPhoneCountryCode:i,columnNameMap:B,identifierNameMap:Y,attributeNameMap:k,requestAttributeKeys:L});p||S.start(O.length,0);let X=0;await _chunkR77JR6OQcjs.b.call(void 0, O,async([U,V],Q)=>{let _e=p?`email:${V.email} | coreIdentifier:${V.coreIdentifier}`:`row:${Q.toString()}`;if(p&&_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`[${Q+1}/${O.length}] Importing: ${JSON.stringify(V,null,2)}`)),f){_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Bailing out on dry run because dryRun is set"));return}try{let ee=await It(K,V,{details:`Uploaded by Transcend Cli: "tr-request-upload" : ${JSON.stringify(U,null,2)}`,isTest:m,emailIsVerified:y,skipSendingReceipt:g,isSilent:d,additionalAttributes:N});p&&(_chunkZUNVPK23cjs.a.info(_colors2.default.green(`[${Q+1}/${O.length}] Successfully submitted the test data subject request: "${_e}"`)),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`[${Q+1}/${O.length}] View it at: "${ee.link}"`)));let oe=x.getValue("successfulRequests");oe.push({id:ee.id,link:ee.link,rowIndex:Q,coreIdentifier:ee.coreIdentifier,attemptedAt:new Date().toISOString()}),await x.setValue(oe,"successfulRequests")}catch(ee){let oe=`${ee.message} - ${JSON.stringify(_optionalChain([ee, 'access', _18 => _18.response, 'optionalAccess', _19 => _19.body]),null,2)}`,Pe=Ie(oe);if(Pe==="Client error: You have already made this request."){p&&_chunkZUNVPK23cjs.a.info(_colors2.default.yellow(`[${Q+1}/${O.length}] Skipping request as it is a duplicate`));let le=x.getValue("duplicateRequests");le.push({coreIdentifier:V.coreIdentifier,rowIndex:Q,attemptedAt:new Date().toISOString()}),await x.setValue(le,"duplicateRequests")}else{let le=x.getValue("failingRequests");le.push({...V,rowIndex:Q,error:Pe||oe,attemptedAt:new Date().toISOString()}),await x.setValue(le,"failingRequests"),p&&(_chunkZUNVPK23cjs.a.error(_colors2.default.red(Pe||oe)),_chunkZUNVPK23cjs.a.error(_colors2.default.red(`[${Q+1}/${O.length}] Failed to submit request for: "${_e}"`)))}}X+=1,p||S.update(X)},{concurrency:o}),S.stop();let ue=new Date().getTime()-h;_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Completed upload in "${ue/1e3}" seconds.`)),x.getValue("duplicateRequests").length>0&&_chunkZUNVPK23cjs.a.info(_colors2.default.yellow(`Encountered "${x.getValue("duplicateRequests").length}" duplicate requests. See "${v}" to review the core identifiers for these requests.`)),x.getValue("failingRequests").length>0&&(_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Encountered "${x.getValue("failingRequests").length}" errors. See "${v}" to review the error messages and inputs.`)),process.exit(1))}async function _t(n,e,{sendEmailReceipt:s=!1,skipWaitingPeriod:l=!1,emailIsVerified:a=!0,requestIdentifiers:o=[]}={}){let i=await n.post("v1/data-subject-request",{json:{type:e.type,subject:{coreIdentifier:e.coreIdentifier,email:e.email,emailIsVerified:a,...o.length>0?{attestedExtraIdentifiers:_typeutils.apply.call(void 0, _chunkEAJZX4TXcjs.d.call(void 0, o.filter(t=>!(t.name==="email"&&t.value===e.email)&&!be.includes(t.name)).map(t=>({...t,type:Object.values(_privacytypes.IdentifierType).includes(t.name)?t.name:_privacytypes.IdentifierType.Custom})),"type"),(t,y)=>t.map(({name:c,value:g})=>({...y===_privacytypes.IdentifierType.Custom?{name:c}:{},value:g})))}:{}},requestId:e.id,subjectType:e.subjectType,isSilent:e.isSilent,isTest:e.isTest,locale:e.locale,skipWaitingPeriod:l,createdAt:e.createdAt,details:`Restarted by Transcend cli: "tr-request-restart" - ${e.details}`,skipSendingReceipt:!s}}).json(),{request:r}=_typeutils.decodeCodec.call(void 0, Ft.type({request:Le}),i);return r}var Hr=M.intersection([Te,M.type({error:M.string})]),Xr=M.type({restartedRequests:M.array(Te),failingRequests:M.array(Hr)});async function wn({requestReceiptFolder:n,auth:e,sombraAuth:s,requestActions:l,requestStatuses:a,createdAtBefore:o,createdAtAfter:i,transcendUrl:r=_chunkVIPFYWRRcjs.e,requestIds:t=[],createdAt:y=new Date,silentModeBefore:c,sendEmailReceipt:g=!1,emailIsVerified:m=!0,copyIdentifiers:d=!1,skipWaitingPeriod:p=!1,concurrency:f=20}){let h=new Date().getTime(),S=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),N=_path.join.call(void 0, n,`tr-request-restart-${new Date().toISOString()}`),T=new (0, _persistedstate.PersistedState)(N,Xr,{restartedRequests:[],failingRequests:[]}),v=await _chunkR77JR6OQcjs.Xd.call(void 0, r,e,s),x=_chunkR77JR6OQcjs.Wd.call(void 0, r,e),$=(await _chunkR77JR6OQcjs.ne.call(void 0, x,{actions:l,statuses:a,createdAtBefore:o,createdAtAfter:i})).filter(L=>new Date(L.createdAt)<y);if(_chunkZUNVPK23cjs.a.info(`Found ${$.length} requests to process`),d&&_chunkZUNVPK23cjs.a.info("copyIdentifiers detected - All Identifiers will be copied."),g&&_chunkZUNVPK23cjs.a.info("sendEmailReceipt detected - Email receipts will be sent."),p&&_chunkZUNVPK23cjs.a.info("skipWaitingPeriod detected - Waiting period will be skipped."),t.length>0&&t.length!==$.length){let L=_chunkEAJZX4TXcjs.c.call(void 0, t,$.map(({id:B})=>B));L.length>0&&(_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Failed to find the following requests by ID: ${L.join(",")}.`)),process.exit(1))}let _=0;S.start($.length,0),await _chunkR77JR6OQcjs.b.call(void 0, $,async(L,B)=>{try{let Y=d?await _chunkR77JR6OQcjs.le.call(void 0, x,v,{requestId:L.id}):[],k=await _t(v,{...L,isSilent:c&&new Date(L.createdAt)<c?!0:L.isSilent},{requestIdentifiers:Y,skipWaitingPeriod:p,sendEmailReceipt:g,emailIsVerified:m}),O=T.getValue("restartedRequests");O.push({id:k.id,link:k.link,rowIndex:B,coreIdentifier:k.coreIdentifier,attemptedAt:new Date().toISOString()}),await T.setValue(O,"restartedRequests")}catch(Y){let k=`${Y.message} - ${JSON.stringify(_optionalChain([Y, 'access', _20 => _20.response, 'optionalAccess', _21 => _21.body]),null,2)}`,O=Ie(k),X=T.getValue("failingRequests");X.push({id:L.id,link:L.link,rowIndex:B,coreIdentifier:L.coreIdentifier,attemptedAt:new Date().toISOString(),error:O||k}),await T.setValue(X,"failingRequests")}_+=1,S.update(_)},{concurrency:f}),S.stop();let j=new Date().getTime()-h;_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Completed restarting of requests in "${j/1e3}" seconds.`)),T.getValue("failingRequests").length>0&&(_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Encountered "${T.getValue("failingRequests").length}" errors. See "${N}" to review the error messages and inputs.`)),process.exit(1))}async function Ln({enricherIds:n,auth:e,concurrency:s=100,transcendUrl:l=_chunkVIPFYWRRcjs.e}){let a=_chunkR77JR6OQcjs.Wd.call(void 0, l,e),o=new Date().getTime(),i=await _chunkR77JR6OQcjs.ne.call(void 0, a,{statuses:[_privacytypes.RequestStatus.Enriching]});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Processing enricher: "${n.join(",")}" fetched "${i.length}" in enriching status.`));let r=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),t=0;r.start(i.length,0);let y=0;await _chunkR77JR6OQcjs.b.call(void 0, i,async m=>{let p=(await _chunkR77JR6OQcjs.ie.call(void 0, a,{requestId:m.id})).filter(f=>n.includes(f.enricher.id)&&![_privacytypes.RequestEnricherStatus.Resolved,_privacytypes.RequestEnricherStatus.Skipped].includes(f.status));p.length>0&&await _chunkR77JR6OQcjs.a.call(void 0, p,async f=>{try{await _chunkR77JR6OQcjs.cc.call(void 0, a,_chunkR77JR6OQcjs.ea,{requestEnricherId:f.id}),y+=1}catch(h){if(!h.message.includes("Client error: Cannot skip Request enricher because it has already completed"))throw h}}),t+=1,r.update(t)},{concurrency:s}),r.stop();let g=new Date().getTime()-o;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully skipped "${y}" for "${i.length}" requests in "${g/1e3}" seconds!`)),i.length}async function Qn({auth:n,requestActions:e=[],createdAtBefore:s,createdAtAfter:l,transcendUrl:a=_chunkVIPFYWRRcjs.e,requestEnricherStatuses:o=Object.values(_privacytypes.RequestEnricherStatus),requestIds:i=[],enricherId:r,concurrency:t=20}){let y=new Date().getTime(),c=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),g=_chunkR77JR6OQcjs.Wd.call(void 0, a,n);_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Fetching requests to restart..."));let m=await _chunkR77JR6OQcjs.ne.call(void 0, g,{actions:e,statuses:[_privacytypes.RequestStatus.Enriching],createdAtBefore:s,createdAtAfter:l,requestIds:i}),d=0;if(i.length>0&&i.length!==m.length){let S=_chunkEAJZX4TXcjs.c.call(void 0, i,m.map(({id:N})=>N));S.length>0&&(_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Failed to find the following requests by ID: ${S.join(",")}.`)),process.exit(1))}let p=0;c.start(m.length,0),await _chunkR77JR6OQcjs.b.call(void 0, m,async S=>{let T=(await _chunkR77JR6OQcjs.ie.call(void 0, g,{requestId:S.id})).filter(v=>v.enricher.id===r&&o.includes(v.status));await _chunkR77JR6OQcjs.b.call(void 0, T,async v=>{await _chunkR77JR6OQcjs.Je.call(void 0, g,v.id),d+=1}),p+=1,c.update(p)},{concurrency:t}),c.stop();let h=new Date().getTime()-y;_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Completed restarting of ${m.length} requests and ${d} enrichers in "${h/1e3}" seconds.`))}async function ea({requestActions:n,dataSiloId:e,auth:s,concurrency:l=20,transcendUrl:a=_chunkVIPFYWRRcjs.e}){let o=_chunkR77JR6OQcjs.Wd.call(void 0, a,s),i=new Date().getTime(),r=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),t=await _chunkR77JR6OQcjs.ne.call(void 0, o,{actions:n,statuses:[_privacytypes.RequestStatus.Compiling,_privacytypes.RequestStatus.Approving]});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Retrying requests for Data Silo: "${e}", restarting "${t.length}" requests.`));let y=0,c=0;r.start(t.length,0),await _chunkR77JR6OQcjs.b.call(void 0, t,async d=>{try{let p=await _chunkR77JR6OQcjs.te.call(void 0, o,{requestId:d.id,dataSiloId:e});await _chunkR77JR6OQcjs.cc.call(void 0, o,_chunkR77JR6OQcjs.xa,{requestDataSiloId:p.id})}catch(p){if(!p.message.includes("Failed to find RequestDataSilo"))throw p;c+=1}y+=1,r.update(y)},{concurrency:l}),r.stop();let m=new Date().getTime()-i;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully notified Transcend in "${m/1e3}" seconds for ${y} requests, ${c} requests were skipped because data silo was not attached to the request!`)),t.length}async function ca({auth:n,sombraAuth:e,actions:s=[],statuses:l=[],identifierSearch:a,pageLimit:o=100,transcendUrl:i=_chunkVIPFYWRRcjs.e,createdAtBefore:r,createdAtAfter:t,isTest:y}){let c=_chunkR77JR6OQcjs.Wd.call(void 0, i,n),g=await _chunkR77JR6OQcjs.Xd.call(void 0, i,n,e),m="";r&&(m+=` before ${r.toISOString()}`),t&&(m+=`${m?", and":""} after ${t.toISOString()}`),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`${s.length>0?`Pulling requests of type "${s.join('" , "')}"`:"Pulling all requests"}${m}`));let d=await _chunkR77JR6OQcjs.ne.call(void 0, c,{actions:s,text:a,statuses:l,createdAtBefore:r,createdAtAfter:t,isTest:y}),p=await _chunkR77JR6OQcjs.b.call(void 0, d,async h=>{let S=await _chunkR77JR6OQcjs.le.call(void 0, c,g,{requestId:h.id});return{...h,requestIdentifiers:S}},{concurrency:o});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Pulled ${p.length} requests`));let f=p.map(({attributeValues:h,requestIdentifiers:S,id:N,email:T,type:v,status:x,subjectType:K,details:$,createdAt:_,country:z,locale:j,origin:L,countrySubDivision:B,isSilent:Y,isTest:k,coreIdentifier:O,...X})=>({"Request ID":N,"Created At":_,Email:T,"Core Identifier":O,"Request Type":v,"Data Subject Type":K,Status:x,Country:z,"Country Sub Division":B,Details:$,Origin:L,"Silent Mode":Y,"Is Test Request":k,Language:j,...X,...Object.entries(_chunkEAJZX4TXcjs.d.call(void 0, h,"attributeKey.name")).reduce((ge,[ue,U])=>Object.assign(ge,{[ue]:U.map(({name:V})=>V).join(",")}),{}),...Object.entries(_chunkEAJZX4TXcjs.d.call(void 0, S,"name")).reduce((ge,[ue,U])=>Object.assign(ge,{[ue]:U.map(({value:V})=>V).join(",")}),{})}));return{requestsWithRequestIdentifiers:p,requestsFormattedForCsv:f}}async function ha({dataSiloId:n,auth:e,concurrency:s=100,status:l="SKIPPED",transcendUrl:a=_chunkVIPFYWRRcjs.e,requestStatuses:o=[_privacytypes.RequestStatus.Compiling,_privacytypes.RequestStatus.Secondary]}){let i=_chunkR77JR6OQcjs.Wd.call(void 0, a,e),r=new Date().getTime(),t=await _chunkR77JR6OQcjs.se.call(void 0, i,{dataSiloId:n,requestStatuses:o});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Processing data silo: "${n}" marking "${t.length}" requests as skipped.`));let y=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),c=0;y.start(t.length,0),await _chunkR77JR6OQcjs.b.call(void 0, t,async d=>{try{await _chunkR77JR6OQcjs.cc.call(void 0, i,_chunkR77JR6OQcjs.wa,{requestDataSiloId:d.id,status:l})}catch(p){if(!p.message.includes("Client error: Request must be active:"))throw p}c+=1,y.update(c)},{concurrency:s}),y.stop();let m=new Date().getTime()-r;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully skipped "${t.length}" requests in "${m/1e3}" seconds!`)),t.length}async function Ea({requestActions:n,identifierNames:e,auth:s,concurrency:l=20,transcendUrl:a=_chunkVIPFYWRRcjs.e}){let o=_chunkR77JR6OQcjs.Wd.call(void 0, a,s),i=new Date().getTime(),r=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),t=await _chunkR77JR6OQcjs.ne.call(void 0, o,{actions:n,statuses:[_privacytypes.RequestStatus.Enriching]});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Fetched requests in preflight/enriching state."));let y=0,c=0;r.start(t.length,0),await _chunkR77JR6OQcjs.b.call(void 0, t,async d=>{let f=(await _chunkR77JR6OQcjs.je.call(void 0, o,{requestId:d.id})).filter(({isVerifiedAtLeastOnce:h,name:S})=>h===!1&&e.includes(S)).map(({id:h})=>h);f.length>0&&(await _chunkR77JR6OQcjs.cc.call(void 0, o,_chunkR77JR6OQcjs.Ca,{input:{requestId:d.id,requestIdentifierIds:f}}),c+=f.length),y+=1,r.update(y)},{concurrency:l}),r.stop();let m=new Date().getTime()-i;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully cleared out unverified identifiers "${m/1e3}" seconds for ${y} requests, ${c} identifiers were cleared out!`)),t.length}exports.a = A; exports.b = pe; exports.c = De; exports.d = be; exports.e = ne; exports.f = et; exports.g = tt; exports.h = rt; exports.i = Te; exports.j = st; exports.k = Ae; exports.l = ae; exports.m = te; exports.n = Ee; exports.o = at; exports.p = ut; exports.q = ct; exports.r = G; exports.s = pt; exports.t = Us; exports.u = gt; exports.v = yt; exports.w = Pr; exports.x = ho; exports.y = Dr; exports.z = qt; exports.A = St; exports.B = xr; exports.C = Lr; exports.D = bt; exports.E = Tt; exports.F = Uo; exports.G = Le; exports.H = It; exports.I = oi; exports.J = fi; exports.K = vt; exports.L = Ni; exports.M = Lt; exports.N = Ie; exports.O = sn; exports.P = _t; exports.Q = wn; exports.R = Ln; exports.S = Qn; exports.T = ea; exports.U = ca; exports.V = ha; exports.W = Ea;
|
|
2
|
+
//# sourceMappingURL=chunk-NW3O6OPS.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/cli/cli/dist/chunk-NSKHXTBW.cjs","../src/lib/requests/constants.ts","../src/lib/requests/fuzzyMatchColumns.ts","../src/lib/requests/mapEnumValues.ts"],"names":["NONE","BULK_APPLY","BLANK","IDENTIFIER_BLOCK_LIST","ColumnName","IS_REQUIRED","CAN_APPLY_IN_BULK","CachedFileState","applyEnum","valuesOf","IsoCountryCode","IsoCountrySubdivisionCode","CompletedRequestStatus","SuccessfulRequest","CachedRequestState","fuzzySearch","word1","word2","fuzzysearch","fuzzyMatchColumns","allColumnNames","fuzzyMapName","isRequired","canApplyAll","matchingColumnNames","x","inquirer","mapEnumValues","csvInputs","expectedOutputs","cache","autoCompletePrompt","inputs","item","value","result"],"mappings":"AAAA,u/BAAuO,wDAAyC,wDAAyC,wDAAiE,qDCAtV,0EACR,2DAMrB,yYACY,IAENA,CAAAA,CAAO,QAAA,CACPC,EAAAA,aAAa,2BAAA,CACbC,EAAAA,aAAQ,SAAA,CAGRC,EAAAA,aAAwB,CAAC,OAAA,CAAS,gBAAgB,CAAA,CAKnDC,EAAAA,aAAAA,CAAAA,CAAAA,EAAAA,CAEVA,CAAAA,CAAA,KAAA,CAAQ,OAAA,CAERA,CAAAA,CAAA,cAAA,CAAiB,gBAAA,CAEjBA,CAAAA,CAAA,WAAA,CAAc,aAAA,CAEdA,CAAAA,CAAA,WAAA,CAAc,aAAA,CAEdA,CAAAA,CAAA,MAAA,CAAS,QAAA,CAETA,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CAAAA,CAAS,MAAMT,kBAAAA,CAAS,MAAA,CAC5BM,CAAAA,CAAO,GAAA,CAAKE,CAAAA,EAAAA,CAAW,CACrB,IAAA,CAAMA,CAAAA,CACN,OAAA,CAAS,CAAA,cAAA,EAAiBA,CAAK,CAAA,CAAA","file":"/home/runner/work/cli/cli/dist/chunk-NSKHXTBW.cjs","sourcesContent":[null,"import { applyEnum, valuesOf } from '@transcend-io/type-utils';\nimport { LanguageKey } from '@transcend-io/internationalization';\nimport {\n CompletedRequestStatus,\n RequestAction,\n IsoCountryCode,\n IsoCountrySubdivisionCode,\n} from '@transcend-io/privacy-types';\nimport * as t from 'io-ts';\n\nexport const NONE = '[NONE]' as const;\nexport const BULK_APPLY = '[APPLY VALUE TO ALL ROWS]' as const;\nexport const BLANK = '<blank>' as const;\n\n/** These are uploaded at the top level of the request */\nexport const IDENTIFIER_BLOCK_LIST = ['email', 'coreIdentifier'];\n\n/**\n * Column names to map\n */\nexport enum ColumnName {\n /** The title of the email column */\n Email = 'email',\n /** The title of the core identifier column */\n CoreIdentifier = 'coreIdentifier',\n /** The title of the requestType column */\n RequestType = 'requestType',\n /** The title of the subjectType column */\n SubjectType = 'subjectType',\n /** The title of the locale column */\n Locale = 'locale',\n /** The country */\n Country = 'country',\n /** The country sub division */\n CountrySubDivision = 'countrySubDivision',\n /** The title of the requestStatus column */\n RequestStatus = 'requestStatus',\n /** The title of the createdAt column */\n CreatedAt = 'createdAt',\n /** The title of the dataSiloIds column */\n DataSiloIds = 'dataSiloIds',\n}\n\n/** These parameters are required in the Transcend DSR API */\nexport const IS_REQUIRED: { [k in ColumnName]: boolean } = {\n [ColumnName.Email]: false,\n [ColumnName.CoreIdentifier]: true,\n [ColumnName.RequestType]: true,\n [ColumnName.SubjectType]: true,\n [ColumnName.RequestStatus]: false,\n [ColumnName.CreatedAt]: false,\n [ColumnName.DataSiloIds]: false,\n [ColumnName.Locale]: false,\n [ColumnName.Country]: false,\n [ColumnName.CountrySubDivision]: false,\n};\n\n/** These parameters can be specified for the entire CSV set if needed */\nexport const CAN_APPLY_IN_BULK: { [k in ColumnName]?: boolean } = {\n [ColumnName.RequestType]: true,\n [ColumnName.SubjectType]: true,\n};\n\n// Cache state\nexport const CachedFileState = t.type({\n /** Mapping between the default request input column names and the CSV column name for that input */\n columnNames: t.partial(applyEnum(ColumnName, () => t.string)),\n /** Mapping between the identifier names and the CSV column name for that input */\n identifierNames: t.record(t.string, t.string),\n /** Mapping between the request attribute inputs and the CSV column name for that input */\n attributeNames: t.record(t.string, t.string),\n /** Mapping between CSV request type and Transcend Request Action */\n requestTypeToRequestAction: t.record(t.string, valuesOf(RequestAction)),\n /** Mapping between CSV data subject type and the name of the data subject in Transcend */\n subjectTypeToSubjectName: t.record(t.string, t.string),\n /** Mapping between language imported and Transcend locale code */\n languageToLocale: t.record(t.string, valuesOf(LanguageKey)),\n /** Mapping between region and country code */\n regionToCountry: t.record(\n t.string,\n valuesOf({ ...IsoCountryCode, [NONE]: NONE }),\n ),\n /** Mapping between region and country sub division code */\n regionToCountrySubDivision: t.record(\n t.string,\n valuesOf({ ...IsoCountrySubdivisionCode, [NONE]: NONE }),\n ),\n /** Mapping between request status in import to Transcend request status */\n statusToRequestStatus: t.record(\n t.string,\n valuesOf({ ...CompletedRequestStatus, [NONE]: NONE }),\n ),\n});\n\n/** Type override */\nexport type CachedFileState = t.TypeOf<typeof CachedFileState>;\n\n/**\n * Successfully processed request\n */\nexport const SuccessfulRequest = t.type({\n id: t.string,\n link: t.string,\n rowIndex: t.number,\n coreIdentifier: t.string,\n attemptedAt: t.string,\n});\n\n/** Type override */\nexport type SuccessfulRequest = t.TypeOf<typeof SuccessfulRequest>;\n\n// Cache state\nexport const CachedRequestState = t.type({\n /** Set of privacy requests that failed to upload */\n failingRequests: t.array(t.record(t.string, t.any)),\n /** Successfully uploaded requests */\n successfulRequests: t.array(SuccessfulRequest),\n /** Duplicate requests */\n duplicateRequests: t.array(\n t.type({\n rowIndex: t.number,\n coreIdentifier: t.string,\n attemptedAt: t.string,\n }),\n ),\n});\n\n/** Type override */\nexport type CachedRequestState = t.TypeOf<typeof CachedRequestState>;\n","import inquirer from 'inquirer';\nimport { NONE, BULK_APPLY } from './constants';\n\nimport fuzzysearch from 'fuzzysearch';\n\n/**\n * Check if word1 and word2 are a fuzzy match of each other.\n * Returns true if word1 is fuzzy match of word2 or vice versa.\n *\n * @param word1 - First word\n * @param word2 - Second word\n * @returns True if words are fuzzy match\n */\nexport function fuzzySearch(word1: string, word2: string): boolean {\n return (\n fuzzysearch(word1.toLowerCase(), word2.toLowerCase()) ||\n fuzzysearch(word2.toLowerCase(), word1.toLowerCase())\n );\n}\n\n/**\n * Fuzzy match column names for a particular field\n *\n * @param allColumnNames - List of all column names\n * @param fuzzyMapName - The name of field being mapped to\n * @param isRequired - When true, don't include \"NONE\" as an option\n * @param canApplyAll - When true, include an option to specify the value in bulk\n * @returns The list of suggestions for inquirer\n */\nexport function fuzzyMatchColumns(\n allColumnNames: string[],\n fuzzyMapName: string,\n isRequired: boolean,\n canApplyAll?: boolean,\n): (string | InstanceType<typeof inquirer.Separator>)[] {\n const matchingColumnNames = allColumnNames.filter((x) =>\n fuzzySearch(fuzzyMapName.toLowerCase(), x.toLowerCase()),\n );\n return [\n ...matchingColumnNames,\n new inquirer.Separator(),\n ...(isRequired ? [] : [NONE]),\n ...(canApplyAll ? [BULK_APPLY] : []),\n ...allColumnNames.filter((x) => !matchingColumnNames.includes(x)),\n ];\n}\n","import inquirer from 'inquirer';\nimport autoCompletePrompt from 'inquirer-autocomplete-prompt';\nimport { apply, ObjByString } from '@transcend-io/type-utils';\nimport { fuzzySearch } from './fuzzyMatchColumns';\n\n/**\n * Map a set of inputs to a set of outputs\n *\n * @param csvInputs - Input list\n * @param expectedOutputs - Output list\n * @param cache - Cache\n * @returns Mapping from row to enum value\n */\nexport async function mapEnumValues<TValue extends string>(\n csvInputs: string[],\n expectedOutputs: TValue[],\n cache: { [k in string]: TValue },\n): Promise<{ [k in string]: TValue }> {\n inquirer.registerPrompt('autocomplete', autoCompletePrompt);\n\n const inputs = csvInputs\n .map((item) => item || '<blank>')\n .filter((value) => !cache[value]);\n if (inputs.length === 0) {\n return cache;\n }\n const result = await inquirer.prompt<{ [k in string]: TValue }>(\n inputs.map((value) => ({\n name: value,\n message: `Map value of: ${value}`,\n type: 'autocomplete',\n default: expectedOutputs.find((x) => fuzzySearch(value, x)),\n source: (answersSoFar: ObjByString, input: string) =>\n !input\n ? expectedOutputs\n : expectedOutputs.filter(\n (x) => typeof x === 'string' && fuzzySearch(input, x),\n ),\n })),\n );\n return {\n ...cache,\n ...apply(result, (r) =>\n typeof r === 'string' ? (r as TValue) : (Object.values(r)[0] as TValue),\n ),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/cli/cli/dist/chunk-NW3O6OPS.cjs","../src/lib/requests/constants.ts","../src/lib/requests/fuzzyMatchColumns.ts","../src/lib/requests/mapEnumValues.ts"],"names":["NONE","BULK_APPLY","BLANK","IDENTIFIER_BLOCK_LIST","ColumnName","IS_REQUIRED","CAN_APPLY_IN_BULK","CachedFileState","applyEnum","valuesOf","IsoCountryCode","IsoCountrySubdivisionCode","CompletedRequestStatus","SuccessfulRequest","CachedRequestState","fuzzySearch","word1","word2","fuzzysearch","fuzzyMatchColumns","allColumnNames","fuzzyMapName","isRequired","canApplyAll","matchingColumnNames","x","inquirer","mapEnumValues","csvInputs","expectedOutputs","cache","autoCompletePrompt","inputs","item","value","result"],"mappings":"AAAA,u/BAAuO,wDAAyC,wDAAyC,wDAAiE,qDCAtV,0EACR,2DAMrB,yYACY,IAENA,CAAAA,CAAO,QAAA,CACPC,EAAAA,aAAa,2BAAA,CACbC,EAAAA,aAAQ,SAAA,CAGRC,EAAAA,aAAwB,CAAC,OAAA,CAAS,gBAAgB,CAAA,CAKnDC,EAAAA,aAAAA,CAAAA,CAAAA,EAAAA,CAEVA,CAAAA,CAAA,KAAA,CAAQ,OAAA,CAERA,CAAAA,CA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AA,CAAQC,CAAAA,EAAU,CAACJ,CAAAA,CAAMI,CAAK,CAAC,CAAA,CAClC,EAAA,CAAIF,CAAAA,CAAO,MAAA,GAAW,CAAA,CACpB,OAAOF,CAAAA,CAET,IAAMK,CAAAA,CAAS,MAAMT,kBAAAA,CAAS,MAAA,CAC5BM,CAAAA,CAAO,GAAA,CAAKE,CAAAA,EAAAA,CAAW,CACrB,IAAA,CAAMA,CAAAA,CACN,OAAA,CAAS,CAAA,cAAA,EAAiBA,CAAK,CAAA,CAAA","file":"/home/runner/work/cli/cli/dist/chunk-NW3O6OPS.cjs","sourcesContent":[null,"import { applyEnum, valuesOf } from '@transcend-io/type-utils';\nimport { LanguageKey } from '@transcend-io/internationalization';\nimport {\n CompletedRequestStatus,\n RequestAction,\n IsoCountryCode,\n IsoCountrySubdivisionCode,\n} from '@transcend-io/privacy-types';\nimport * as t from 'io-ts';\n\nexport const NONE = '[NONE]' as const;\nexport const BULK_APPLY = '[APPLY VALUE TO ALL ROWS]' as const;\nexport const BLANK = '<blank>' as const;\n\n/** These are uploaded at the top level of the request */\nexport const IDENTIFIER_BLOCK_LIST = ['email', 'coreIdentifier'];\n\n/**\n * Column names to map\n */\nexport enum ColumnName {\n /** The title of the email column */\n Email = 'email',\n /** The title of the core identifier column */\n CoreIdentifier = 'coreIdentifier',\n /** The title of the requestType column */\n RequestType = 'requestType',\n /** The title of the subjectType column */\n SubjectType = 'subjectType',\n /** The title of the locale column */\n Locale = 'locale',\n /** The country */\n Country = 'country',\n /** The country sub division */\n CountrySubDivision = 'countrySubDivision',\n /** The title of the requestStatus column */\n RequestStatus = 'requestStatus',\n /** The title of the createdAt column */\n CreatedAt = 'createdAt',\n /** The title of the dataSiloIds column */\n DataSiloIds = 'dataSiloIds',\n}\n\n/** These parameters are required in the Transcend DSR API */\nexport const IS_REQUIRED: { [k in ColumnName]: boolean } = {\n [ColumnName.Email]: false,\n [ColumnName.CoreIdentifier]: true,\n [ColumnName.RequestType]: true,\n [ColumnName.SubjectType]: true,\n [ColumnName.RequestStatus]: false,\n [ColumnName.CreatedAt]: false,\n [ColumnName.DataSiloIds]: false,\n [ColumnName.Locale]: false,\n [ColumnName.Country]: false,\n [ColumnName.CountrySubDivision]: false,\n};\n\n/** These parameters can be specified for the entire CSV set if needed */\nexport const CAN_APPLY_IN_BULK: { [k in ColumnName]?: boolean } = {\n [ColumnName.RequestType]: true,\n [ColumnName.SubjectType]: true,\n};\n\n// Cache state\nexport const CachedFileState = t.type({\n /** Mapping between the default request input column names and the CSV column name for that input */\n columnNames: t.partial(applyEnum(ColumnName, () => t.string)),\n /** Mapping between the identifier names and the CSV column name for that input */\n identifierNames: t.record(t.string, t.string),\n /** Mapping between the request attribute inputs and the CSV column name for that input */\n attributeNames: t.record(t.string, t.string),\n /** Mapping between CSV request type and Transcend Request Action */\n requestTypeToRequestAction: t.record(t.string, valuesOf(RequestAction)),\n /** Mapping between CSV data subject type and the name of the data subject in Transcend */\n subjectTypeToSubjectName: t.record(t.string, t.string),\n /** Mapping between language imported and Transcend locale code */\n languageToLocale: t.record(t.string, valuesOf(LanguageKey)),\n /** Mapping between region and country code */\n regionToCountry: t.record(\n t.string,\n valuesOf({ ...IsoCountryCode, [NONE]: NONE }),\n ),\n /** Mapping between region and country sub division code */\n regionToCountrySubDivision: t.record(\n t.string,\n valuesOf({ ...IsoCountrySubdivisionCode, [NONE]: NONE }),\n ),\n /** Mapping between request status in import to Transcend request status */\n statusToRequestStatus: t.record(\n t.string,\n valuesOf({ ...CompletedRequestStatus, [NONE]: NONE }),\n ),\n});\n\n/** Type override */\nexport type CachedFileState = t.TypeOf<typeof CachedFileState>;\n\n/**\n * Successfully processed request\n */\nexport const SuccessfulRequest = t.type({\n id: t.string,\n link: t.string,\n rowIndex: t.number,\n coreIdentifier: t.string,\n attemptedAt: t.string,\n});\n\n/** Type override */\nexport type SuccessfulRequest = t.TypeOf<typeof SuccessfulRequest>;\n\n// Cache state\nexport const CachedRequestState = t.type({\n /** Set of privacy requests that failed to upload */\n failingRequests: t.array(t.record(t.string, t.any)),\n /** Successfully uploaded requests */\n successfulRequests: t.array(SuccessfulRequest),\n /** Duplicate requests */\n duplicateRequests: t.array(\n t.type({\n rowIndex: t.number,\n coreIdentifier: t.string,\n attemptedAt: t.string,\n }),\n ),\n});\n\n/** Type override */\nexport type CachedRequestState = t.TypeOf<typeof CachedRequestState>;\n","import inquirer from 'inquirer';\nimport { NONE, BULK_APPLY } from './constants';\n\nimport fuzzysearch from 'fuzzysearch';\n\n/**\n * Check if word1 and word2 are a fuzzy match of each other.\n * Returns true if word1 is fuzzy match of word2 or vice versa.\n *\n * @param word1 - First word\n * @param word2 - Second word\n * @returns True if words are fuzzy match\n */\nexport function fuzzySearch(word1: string, word2: string): boolean {\n return (\n fuzzysearch(word1.toLowerCase(), word2.toLowerCase()) ||\n fuzzysearch(word2.toLowerCase(), word1.toLowerCase())\n );\n}\n\n/**\n * Fuzzy match column names for a particular field\n *\n * @param allColumnNames - List of all column names\n * @param fuzzyMapName - The name of field being mapped to\n * @param isRequired - When true, don't include \"NONE\" as an option\n * @param canApplyAll - When true, include an option to specify the value in bulk\n * @returns The list of suggestions for inquirer\n */\nexport function fuzzyMatchColumns(\n allColumnNames: string[],\n fuzzyMapName: string,\n isRequired: boolean,\n canApplyAll?: boolean,\n): (string | InstanceType<typeof inquirer.Separator>)[] {\n const matchingColumnNames = allColumnNames.filter((x) =>\n fuzzySearch(fuzzyMapName.toLowerCase(), x.toLowerCase()),\n );\n return [\n ...matchingColumnNames,\n new inquirer.Separator(),\n ...(isRequired ? [] : [NONE]),\n ...(canApplyAll ? [BULK_APPLY] : []),\n ...allColumnNames.filter((x) => !matchingColumnNames.includes(x)),\n ];\n}\n","import inquirer from 'inquirer';\nimport autoCompletePrompt from 'inquirer-autocomplete-prompt';\nimport { apply, ObjByString } from '@transcend-io/type-utils';\nimport { fuzzySearch } from './fuzzyMatchColumns';\n\n/**\n * Map a set of inputs to a set of outputs\n *\n * @param csvInputs - Input list\n * @param expectedOutputs - Output list\n * @param cache - Cache\n * @returns Mapping from row to enum value\n */\nexport async function mapEnumValues<TValue extends string>(\n csvInputs: string[],\n expectedOutputs: TValue[],\n cache: { [k in string]: TValue },\n): Promise<{ [k in string]: TValue }> {\n inquirer.registerPrompt('autocomplete', autoCompletePrompt);\n\n const inputs = csvInputs\n .map((item) => item || '<blank>')\n .filter((value) => !cache[value]);\n if (inputs.length === 0) {\n return cache;\n }\n const result = await inquirer.prompt<{ [k in string]: TValue }>(\n inputs.map((value) => ({\n name: value,\n message: `Map value of: ${value}`,\n type: 'autocomplete',\n default: expectedOutputs.find((x) => fuzzySearch(value, x)),\n source: (answersSoFar: ObjByString, input: string) =>\n !input\n ? expectedOutputs\n : expectedOutputs.filter(\n (x) => typeof x === 'string' && fuzzySearch(input, x),\n ),\n })),\n );\n return {\n ...cache,\n ...apply(result, (r) =>\n typeof r === 'string' ? (r as TValue) : (Object.values(r)[0] as TValue),\n ),\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 _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
|
|
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 _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 _chunk74OAET6Dcjs = require('./chunk-74OAET6D.cjs');var _chunkNW3O6OPScjs = require('./chunk-NW3O6OPS.cjs');var _chunkUWUR56COcjs = require('./chunk-UWUR56CO.cjs');var _chunkR77JR6OQcjs = require('./chunk-R77JR6OQ.cjs');var _chunkZUNVPK23cjs = require('./chunk-ZUNVPK23.cjs');var _chunkVIPFYWRRcjs = require('./chunk-VIPFYWRR.cjs');var _chunkEAJZX4TXcjs = require('./chunk-EAJZX4TX.cjs');var _privacytypes = require('@transcend-io/privacy-types');var _colors = require('colors'); var _colors2 = _interopRequireDefault(_colors);async function at({auth:e,deploy:i=!1,transcendUrl:o=_chunkVIPFYWRRcjs.e,bundleTypes:t=Object.values(_privacytypes.ConsentBundleType)}){let r=_chunkR77JR6OQcjs.Wd.call(void 0, o,e),n=await _chunkR77JR6OQcjs.uc.call(void 0, r);await _chunkR77JR6OQcjs.a.call(void 0, t,async a=>{_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Update Consent Manager bundle with ID "${n}" and type "${a}" to latest version...`)),await _chunkR77JR6OQcjs._d.call(void 0, r,{id:n,bundleType:a}),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Updated Consent Manager bundle with ID "${n}" and type "${a}" to latest version!`))}),i&&await _chunkR77JR6OQcjs.a.call(void 0, t,async a=>{_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Deploying Consent Manager bundle with ID "${n}" and type "${a}"...`)),await _chunkR77JR6OQcjs.Zd.call(void 0, r,{id:n,bundleType:a}),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Deployed Consent Manager bundle with ID "${n}" and type "${a}"!`))})}var j=["ID","Activity","Encounters","Last Seen At","Has Native Do Not Sell/Share Support","IAB USP API Support","Service Description","Website URL","Categories of Recipients"];async function Ct({auth:e,trackerStatus:i,file:o,classifyService:t=!1,transcendUrl:r=_chunkVIPFYWRRcjs.e}){let n=_chunkR77JR6OQcjs.Wd.call(void 0, r,e);_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Reading "${o}" from disk`));let l=_chunkNW3O6OPScjs.q.call(void 0, o,_chunkUWUR56COcjs.ia).map(({Type:d,Notes:m,Service:f,Purpose:E,Status:g,Owners:I,Teams:T,"Connections Made To":v,...y})=>({value:v,type:d,description:m,trackingPurposes:_chunkNW3O6OPScjs.n.call(void 0, E),status:g||i,owners:I?_chunkNW3O6OPScjs.n.call(void 0, I):void 0,teams:T?_chunkNW3O6OPScjs.n.call(void 0, T):void 0,attributes:Object.entries(y).filter(([h])=>!j.includes(h)).map(([h,H])=>({key:h,values:_chunkNW3O6OPScjs.n.call(void 0, H)}))}));await _chunkR77JR6OQcjs.fd.call(void 0, n,l,t)||(_chunkZUNVPK23cjs.a.error(_colors2.default.red("Encountered error(s) syncing data flows from CSV, see logs above for more info. ")),process.exit(1))}var Y=["ID","Activity","Encounters","Last Seen At","Has Native Do Not Sell/Share Support","IAB USP API Support","Service Description","Website URL","Categories of Recipients"];async function vt({auth:e,trackerStatus:i,file:o,transcendUrl:t=_chunkVIPFYWRRcjs.e}){let r=_chunkR77JR6OQcjs.Wd.call(void 0, t,e);_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Reading "${o}" from disk`));let a=_chunkNW3O6OPScjs.q.call(void 0, o,_chunkUWUR56COcjs.ja).map(({"Is Regex?":s,Notes:d,Service:m,Purpose:f,Status:E,Owners:g,Teams:I,Name:T,...v})=>({...typeof s=="string"?{isRegex:s.toLowerCase()==="true"}:{},name:T,description:d,trackingPurposes:_chunkNW3O6OPScjs.n.call(void 0, f),status:E||i,owners:g?_chunkNW3O6OPScjs.n.call(void 0, g):void 0,teams:I?_chunkNW3O6OPScjs.n.call(void 0, I):void 0,attributes:Object.entries(v).filter(([y])=>!Y.includes(y)).map(([y,h])=>({key:y,values:_chunkNW3O6OPScjs.n.call(void 0, h)}))}));await _chunkR77JR6OQcjs.Ac.call(void 0, r,a)||(_chunkZUNVPK23cjs.a.error(_colors2.default.red("Encountered error(s) syncing cookies from CSV, see logs above for more info. ")),process.exit(1))}var Q=1e3,V=60*Q,X=60*V,z=24*X,W=7*z;async function Lt(e,{bin:i,start:o,end:t=new Date}){let r=await _chunkR77JR6OQcjs.uc.call(void 0, e),n=Math.floor(o.getTime()/1e3),a=Math.floor(t.getTime()/1e3);if(n>a)throw new Error('Received "end" date that happened before "start" date');if(i==="1h"&&t.getTime()-o.getTime()>W*2)throw new Error("When using bin=1h, start and end time can be no more than 2 weeks apart");let l=o.toISOString(),s=t.toISOString(),[d,m,f]=await Promise.all([_chunkR77JR6OQcjs.xc.call(void 0, e,{dataSource:"PRIVACY_SIGNAL_TIMESERIES",startDate:l,endDate:s,forceRefetch:!0,airgapBundleId:r,binInterval:i,smoothTimeseries:!1}),_chunkR77JR6OQcjs.xc.call(void 0, e,{dataSource:"CONSENT_CHANGES_TIMESERIES",startDate:l,endDate:s,forceRefetch:!0,airgapBundleId:r,binInterval:i,smoothTimeseries:!1}),_chunkR77JR6OQcjs.xc.call(void 0, e,{dataSource:"CONSENT_SESSIONS_BY_REGIME",startDate:l,endDate:s,forceRefetch:!0,airgapBundleId:r,binInterval:i,smoothTimeseries:!1})]);return{PRIVACY_SIGNAL_TIMESERIES:d,CONSENT_CHANGES_TIMESERIES:m,CONSENT_SESSIONS_BY_REGIME:f}}var B=e=>new URL(`https://${e}`).hostname.split(".").slice(-2).join(".");var J=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;async function Ht(e,{xdiLocation:i,transcendUrl:o=_chunkVIPFYWRRcjs.e,removeIpAddresses:t=!0,domainBlockList:r=["localhost"],xdiAllowedCommands:n="ConsentManager:Sync"}){let a=Array.isArray(e)?e:[{apiKey:e,organizationId:"",organizationName:""}],l=await _chunkR77JR6OQcjs.b.call(void 0, a,async m=>{_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Pulling consent metadata for organization - ${m.organizationName}`));let f=_chunkR77JR6OQcjs.Wd.call(void 0, o,m.apiKey);return await _chunkR77JR6OQcjs.tc.call(void 0, f)},{concurrency:5}),s={};return l.forEach(m=>{let f=_optionalChain([m, 'access', _2 => _2.partition, 'optionalAccess', _3 => _3.partition])||m.bundleURL.split("/").reverse()[1];s[f]||(s[f]=[]);let E=_chunkEAJZX4TXcjs.c.call(void 0, m.configuration.domains.filter(g=>!t||!J.test(g)).map(g=>B(g)),r);s[f]=[...new Set([...s[f]||[],...E])]}),{html:`
|
|
2
2
|
<!DOCTYPE html>
|
|
3
3
|
<script
|
|
4
4
|
src="${i}"
|
|
@@ -8,5 +8,5 @@ data-xdi-commands="${n}"
|
|
|
8
8
|
`,syncGroups:s}}function Yt(e){let i=e.map(({name:o,input:t})=>({title:o.replace(".yml",""),attributes:[..._optionalChain([t, 'optionalAccess', _4 => _4.domains])?[{key:"Transcend Domain List",values:[...new Set(t.domains)]}]:[],..._optionalChain([t, 'optionalAccess', _5 => _5.bundleUrls])?[{key:"Airgap Production URL",values:[t.bundleUrls.PRODUCTION]},{key:"Airgap Test URL",values:[t.bundleUrls.TEST]},{key:"Airgap XDI URL",values:[t.bundleUrls.PRODUCTION.replace("airgap.js","xdi.js")]}]:[],..._optionalChain([t, 'optionalAccess', _6 => _6.partition])?[{key:"Consent Partition Key",values:[t.partition]}]:[]]}));return _chunkZUNVPK23cjs.a.info(`
|
|
9
9
|
|
|
10
10
|
~~~~~~~~~~~
|
|
11
|
-
Airgap scripts to host:`),i.forEach(({attributes:o,title:t},r)=>{_optionalChain([o, 'optionalAccess', _7 => _7.find, 'call', _8 => _8(n=>n.key==="Airgap Production URL"), 'optionalAccess', _9 => _9.values, 'optionalAccess', _10 => _10.forEach, 'call', _11 => _11(n=>{_chunkZUNVPK23cjs.a.info(`${r}) ${t} - ${n}`)})])}),i}var _iots = require('io-ts'); var p = _interopRequireWildcard(_iots);var _typeutils = require('@transcend-io/type-utils');var tt=p.intersection([p.type({nodes:p.array(
|
|
12
|
-
//# sourceMappingURL=chunk-
|
|
11
|
+
Airgap scripts to host:`),i.forEach(({attributes:o,title:t},r)=>{_optionalChain([o, 'optionalAccess', _7 => _7.find, 'call', _8 => _8(n=>n.key==="Airgap Production URL"), 'optionalAccess', _9 => _9.values, 'optionalAccess', _10 => _10.forEach, 'call', _11 => _11(n=>{_chunkZUNVPK23cjs.a.info(`${r}) ${t} - ${n}`)})])}),i}var _iots = require('io-ts'); var p = _interopRequireWildcard(_iots);var _typeutils = require('@transcend-io/type-utils');var tt=p.intersection([p.type({nodes:p.array(_chunk74OAET6Dcjs.c)}),p.partial({lastKey:p.partial({userId:p.string,partition:p.string,timestamp:p.string})})]);async function zt(e,{partition:i,filterBy:o={},limit:t=50}){let r,n=[],a=!0;for(;a;){let l=await e.post("v1/consent-preferences",{json:{partition:i,...o,startKey:r||void 0,limit:t}}).json(),{nodes:s,lastKey:d}=_typeutils.decodeCodec.call(void 0, tt,l);if(!s||s.length===0)break;n.push(...s),r=d,a=!!d&&Object.keys(d).length>0}return n}exports.a = at; exports.b = Ct; exports.c = vt; exports.d = Lt; exports.e = B; exports.f = J; exports.g = Ht; exports.h = Yt; exports.i = tt; exports.j = zt;
|
|
12
|
+
//# sourceMappingURL=chunk-PIJPXUK5.cjs.map
|