@transcend-io/cli 8.26.3 → 8.28.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 +6 -0
- 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-IXJG6NAC.cjs → chunk-4PQ4RHUG.cjs} +4 -4
- package/dist/{chunk-IXJG6NAC.cjs.map → chunk-4PQ4RHUG.cjs.map} +1 -1
- package/dist/{chunk-PZLVJBQM.cjs → chunk-7PF5VVAF.cjs} +2 -2
- package/dist/{chunk-PZLVJBQM.cjs.map → chunk-7PF5VVAF.cjs.map} +1 -1
- package/dist/{chunk-4LHXA6MV.cjs → chunk-AEL3DOYI.cjs} +2 -2
- package/dist/{chunk-4LHXA6MV.cjs.map → chunk-AEL3DOYI.cjs.map} +1 -1
- package/dist/{chunk-YPUEGXPW.cjs → chunk-CQT5QQ3U.cjs} +2 -2
- package/dist/{chunk-YPUEGXPW.cjs.map → chunk-CQT5QQ3U.cjs.map} +1 -1
- package/dist/{chunk-5UBGZNDC.cjs → chunk-ECGHWDVP.cjs} +2 -2
- package/dist/chunk-ECGHWDVP.cjs.map +1 -0
- package/dist/{chunk-MGIVF74Z.cjs → chunk-EYOQLGDV.cjs} +2 -2
- package/dist/{chunk-MGIVF74Z.cjs.map → chunk-EYOQLGDV.cjs.map} +1 -1
- package/dist/{chunk-HPU3KPV4.cjs → chunk-FER7XKVN.cjs} +2 -2
- package/dist/{chunk-HPU3KPV4.cjs.map → chunk-FER7XKVN.cjs.map} +1 -1
- package/dist/{chunk-SBCX6SDE.cjs → chunk-I7PFP5VB.cjs} +2 -2
- package/dist/{chunk-SBCX6SDE.cjs.map → chunk-I7PFP5VB.cjs.map} +1 -1
- package/dist/{chunk-RE5YALEO.cjs → chunk-JFZPP4VV.cjs} +3 -3
- package/dist/{chunk-RE5YALEO.cjs.map → chunk-JFZPP4VV.cjs.map} +1 -1
- package/dist/{chunk-UAO3IAO3.cjs → chunk-K4TIJ3VM.cjs} +2 -2
- package/dist/{chunk-UAO3IAO3.cjs.map → chunk-K4TIJ3VM.cjs.map} +1 -1
- package/dist/{chunk-X6CJEYOA.cjs → chunk-KUBXRT3V.cjs} +5 -4
- package/dist/chunk-KUBXRT3V.cjs.map +1 -0
- package/dist/{chunk-ZOVKGQJQ.cjs → chunk-L7Z4PFRC.cjs} +2 -2
- package/dist/{chunk-ZOVKGQJQ.cjs.map → chunk-L7Z4PFRC.cjs.map} +1 -1
- package/dist/{chunk-PP4YLOQE.cjs → chunk-RNZ72QMS.cjs} +2 -2
- package/dist/{chunk-PP4YLOQE.cjs.map → chunk-RNZ72QMS.cjs.map} +1 -1
- package/dist/{chunk-LMUWS7HI.cjs → chunk-THOOR2KA.cjs} +4 -4
- package/dist/{chunk-LMUWS7HI.cjs.map → chunk-THOOR2KA.cjs.map} +1 -1
- package/dist/{chunk-S5MX7XJL.cjs → chunk-Y35YHYXP.cjs} +21 -21
- package/dist/{chunk-S5MX7XJL.cjs.map → chunk-Y35YHYXP.cjs.map} +1 -1
- package/dist/{chunk-EBEILTRR.cjs → chunk-YKGS253B.cjs} +6 -6
- package/dist/{chunk-EBEILTRR.cjs.map → chunk-YKGS253B.cjs.map} +1 -1
- package/dist/{impl-XW4UTUBW.cjs → impl-3YAJ7ZV3.cjs} +2 -2
- package/dist/{impl-XW4UTUBW.cjs.map → impl-3YAJ7ZV3.cjs.map} +1 -1
- package/dist/{impl-UHCILICE.cjs → impl-55NL4KOI.cjs} +2 -2
- package/dist/{impl-UHCILICE.cjs.map → impl-55NL4KOI.cjs.map} +1 -1
- package/dist/{impl-NAITRZS5.cjs → impl-7B7QDZZJ.cjs} +2 -2
- package/dist/{impl-NAITRZS5.cjs.map → impl-7B7QDZZJ.cjs.map} +1 -1
- package/dist/{impl-ZAKD7OF2.cjs → impl-A6W2KTYL.cjs} +2 -2
- package/dist/{impl-ZAKD7OF2.cjs.map → impl-A6W2KTYL.cjs.map} +1 -1
- package/dist/{impl-MNMSXIYH.cjs → impl-ALROZNDJ.cjs} +2 -2
- package/dist/{impl-MNMSXIYH.cjs.map → impl-ALROZNDJ.cjs.map} +1 -1
- package/dist/{impl-65UAYE4Y.cjs → impl-ANXIZT7S.cjs} +2 -2
- package/dist/{impl-65UAYE4Y.cjs.map → impl-ANXIZT7S.cjs.map} +1 -1
- package/dist/{impl-RIR5ANXH.cjs → impl-AP2ZTYJK.cjs} +2 -2
- package/dist/{impl-RIR5ANXH.cjs.map → impl-AP2ZTYJK.cjs.map} +1 -1
- package/dist/{impl-HNW6B2DU.cjs → impl-AZYBYV3X.cjs} +2 -2
- package/dist/{impl-HNW6B2DU.cjs.map → impl-AZYBYV3X.cjs.map} +1 -1
- package/dist/impl-B7ODYIUX.cjs +2 -0
- package/dist/{impl-6DHYOTA2.cjs.map → impl-B7ODYIUX.cjs.map} +1 -1
- package/dist/{impl-TNSZ6LTO.cjs → impl-BDPD5CCN.cjs} +2 -2
- package/dist/{impl-TNSZ6LTO.cjs.map → impl-BDPD5CCN.cjs.map} +1 -1
- package/dist/{impl-3BHV7STJ.cjs → impl-BL4XQEFX.cjs} +2 -2
- package/dist/{impl-3BHV7STJ.cjs.map → impl-BL4XQEFX.cjs.map} +1 -1
- package/dist/{impl-JBFNOZXK.cjs → impl-D7R3HZEC.cjs} +5 -5
- package/dist/{impl-JBFNOZXK.cjs.map → impl-D7R3HZEC.cjs.map} +1 -1
- package/dist/{impl-WTLPP6WJ.cjs → impl-DDQQGOQ3.cjs} +2 -2
- package/dist/{impl-WTLPP6WJ.cjs.map → impl-DDQQGOQ3.cjs.map} +1 -1
- package/dist/{impl-5FLGACAD.cjs → impl-DT5KLE2G.cjs} +3 -3
- package/dist/{impl-5FLGACAD.cjs.map → impl-DT5KLE2G.cjs.map} +1 -1
- package/dist/{impl-PBEQHLIJ.cjs → impl-DVE332P5.cjs} +2 -2
- package/dist/{impl-PBEQHLIJ.cjs.map → impl-DVE332P5.cjs.map} +1 -1
- package/dist/{impl-Z5MFXC4Y.cjs → impl-DXAKJNLZ.cjs} +2 -2
- package/dist/{impl-Z5MFXC4Y.cjs.map → impl-DXAKJNLZ.cjs.map} +1 -1
- package/dist/{impl-BFSDPXDV.cjs → impl-H2BRV4GP.cjs} +2 -2
- package/dist/{impl-BFSDPXDV.cjs.map → impl-H2BRV4GP.cjs.map} +1 -1
- package/dist/{impl-CSTT5HQH.cjs → impl-IFDUZGZM.cjs} +2 -2
- package/dist/{impl-CSTT5HQH.cjs.map → impl-IFDUZGZM.cjs.map} +1 -1
- package/dist/{impl-KAWZ42M5.cjs → impl-IIIT5MSV.cjs} +2 -2
- package/dist/{impl-KAWZ42M5.cjs.map → impl-IIIT5MSV.cjs.map} +1 -1
- package/dist/{impl-5K2UCOJJ.cjs → impl-JPVEFSJB.cjs} +2 -2
- package/dist/{impl-5K2UCOJJ.cjs.map → impl-JPVEFSJB.cjs.map} +1 -1
- package/dist/{impl-LVHX32GS.cjs → impl-LDOILOAQ.cjs} +2 -2
- package/dist/{impl-LVHX32GS.cjs.map → impl-LDOILOAQ.cjs.map} +1 -1
- package/dist/{impl-6YB36EZH.cjs → impl-LKJFVX7E.cjs} +2 -2
- package/dist/{impl-6YB36EZH.cjs.map → impl-LKJFVX7E.cjs.map} +1 -1
- package/dist/{impl-3DHFXZRO.cjs → impl-LQEYNOZS.cjs} +2 -2
- package/dist/{impl-3DHFXZRO.cjs.map → impl-LQEYNOZS.cjs.map} +1 -1
- package/dist/{impl-WP2EKZ6C.cjs → impl-M5QGTDLF.cjs} +2 -2
- package/dist/{impl-WP2EKZ6C.cjs.map → impl-M5QGTDLF.cjs.map} +1 -1
- package/dist/{impl-BJRSLU3V.cjs → impl-MBEVWSPX.cjs} +2 -2
- package/dist/{impl-BJRSLU3V.cjs.map → impl-MBEVWSPX.cjs.map} +1 -1
- package/dist/{impl-F4B6PYAE.cjs → impl-NCUMPL6B.cjs} +4 -4
- package/dist/{impl-F4B6PYAE.cjs.map → impl-NCUMPL6B.cjs.map} +1 -1
- package/dist/{impl-DHAB5PO6.cjs → impl-NISL4HZY.cjs} +2 -2
- package/dist/{impl-DHAB5PO6.cjs.map → impl-NISL4HZY.cjs.map} +1 -1
- package/dist/{impl-KWAOGILY.cjs → impl-OFRMKTX5.cjs} +2 -2
- package/dist/{impl-KWAOGILY.cjs.map → impl-OFRMKTX5.cjs.map} +1 -1
- package/dist/impl-PE52QYSI.cjs +2 -0
- package/dist/{impl-5G2I4YXV.cjs.map → impl-PE52QYSI.cjs.map} +1 -1
- package/dist/{impl-ZJFIQ3WO.cjs → impl-PXT7QNSR.cjs} +2 -2
- package/dist/{impl-ZJFIQ3WO.cjs.map → impl-PXT7QNSR.cjs.map} +1 -1
- package/dist/{impl-N7KXTUQ5.cjs → impl-SDQ6LUZD.cjs} +2 -2
- package/dist/{impl-N7KXTUQ5.cjs.map → impl-SDQ6LUZD.cjs.map} +1 -1
- package/dist/{impl-HFNH2244.cjs → impl-SVEK74IU.cjs} +2 -2
- package/dist/{impl-HFNH2244.cjs.map → impl-SVEK74IU.cjs.map} +1 -1
- package/dist/{impl-3WNATSXH.cjs → impl-SVPD3IHV.cjs} +2 -2
- package/dist/{impl-3WNATSXH.cjs.map → impl-SVPD3IHV.cjs.map} +1 -1
- package/dist/{impl-AH7B2B24.cjs → impl-UC5CCT6E.cjs} +3 -3
- package/dist/{impl-AH7B2B24.cjs.map → impl-UC5CCT6E.cjs.map} +1 -1
- package/dist/{impl-ZBPQU55V.cjs → impl-UZPP5VK5.cjs} +2 -2
- package/dist/{impl-ZBPQU55V.cjs.map → impl-UZPP5VK5.cjs.map} +1 -1
- package/dist/{impl-72IBK3I6.cjs → impl-VZ6NJDAV.cjs} +2 -2
- package/dist/{impl-72IBK3I6.cjs.map → impl-VZ6NJDAV.cjs.map} +1 -1
- package/dist/{impl-IG2OR2JL.cjs → impl-W35DMTQV.cjs} +2 -2
- package/dist/{impl-IG2OR2JL.cjs.map → impl-W35DMTQV.cjs.map} +1 -1
- package/dist/{impl-QUYKNAFP.cjs → impl-XHO6WQ2I.cjs} +2 -2
- package/dist/{impl-QUYKNAFP.cjs.map → impl-XHO6WQ2I.cjs.map} +1 -1
- package/dist/{impl-V2RBWUPL.cjs → impl-YHBNKYSL.cjs} +2 -2
- package/dist/{impl-V2RBWUPL.cjs.map → impl-YHBNKYSL.cjs.map} +1 -1
- package/dist/{impl-O7I2KRJ7.cjs → impl-YJ6UUT4D.cjs} +2 -2
- package/dist/{impl-O7I2KRJ7.cjs.map → impl-YJ6UUT4D.cjs.map} +1 -1
- package/dist/{impl-TXK727IK.cjs → impl-YWJCIRTP.cjs} +2 -2
- package/dist/{impl-TXK727IK.cjs.map → impl-YWJCIRTP.cjs.map} +1 -1
- package/dist/{impl-K6XHDMZZ.cjs → impl-ZTZHVQYY.cjs} +2 -2
- package/dist/{impl-K6XHDMZZ.cjs.map → impl-ZTZHVQYY.cjs.map} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +18 -1
- package/package.json +3 -3
- package/dist/chunk-5UBGZNDC.cjs.map +0 -1
- package/dist/chunk-X6CJEYOA.cjs.map +0 -1
- package/dist/impl-5G2I4YXV.cjs +0 -2
- package/dist/impl-6DHYOTA2.cjs +0 -2
|
@@ -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 }; }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 }; }var _chunkEYOQLGDVcjs = require('./chunk-EYOQLGDV.cjs');var _chunkQ7I37FJVcjs = require('./chunk-Q7I37FJV.cjs');var _core = require('@stricli/core');var _privacytypes = require('@transcend-io/privacy-types');var _ms = require('ms'); var _ms2 = _interopRequireDefault(_ms);function S(e){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e))throw new Error(`Invalid UUID format: ${e}`);return e}function n(e){try{return new URL(e).toString().replace(/\/$/,"")}catch (e2){throw new Error(`Invalid URL format: ${e}`)}}function T(e){return e.split(",").map(r=>r.trim()).filter(r=>r.length>0)}function y(e){let r=new Date(e);if(Number.isNaN(r.getTime()))throw new TypeError(`Invalid date: ${e}. Try using the ISO 8601 format (YYYY-MM-DDTHH:MM:SS.SSSZ)`);return r}function k(e){if(typeof e=="number"&&Number.isFinite(e))return Math.round(e*1e3);if(typeof e=="string"){let r=e.trim();if(r==="")throw new Error('Invalid duration. Examples: "45", "2d", "1h", "90 minutes", "10s".');let t=Number(r);if(r!==""&&Number.isFinite(t))return Math.round(t*1e3);let a;try{a=_ms2.default.call(void 0, r)}catch (e3){throw new Error('Invalid duration. Examples: "45", "2d", "1h", "90 minutes", "10s".')}if(typeof a=="number"&&Number.isFinite(a))return a}throw new Error('Invalid duration. Examples: "45", "2d", "1h", "90 minutes", "10s".')}var d=({scopes:e,requiresSiloScope:r=!1})=>{let t={kind:"parsed",parse:String,brief:"The Transcend API key."};return r&&(t.brief+=" This key must be associated with the data silo(s) being operated on."),e==="Varies"?{...t,brief:`${t.brief} The scopes required will vary depending on the operation performed. If in doubt, the ${_privacytypes.TRANSCEND_SCOPES[_privacytypes.ScopeName.FullAdmin].title} scope will always work.`}:e.length===0?{...t,brief:`${t.brief} No scopes are required for this command.`}:{...t,brief:`${t.brief} Requires scopes: ${e.map(a=>`"${_privacytypes.TRANSCEND_SCOPES[a].title}"`).join(", ")}`}},u= exports.f =(e=_chunkEYOQLGDVcjs.r)=>({kind:"parsed",parse:n,brief:"URL of the Transcend backend. Use https://api.us.transcend.io for US hosting",default:e}),x= exports.g =(e=_chunkEYOQLGDVcjs.s)=>({kind:"parsed",parse:n,brief:"URL of the Transcend consent backend. Use https://consent.us.transcend.io for US hosting",default:e}),A= exports.h =()=>({kind:"parsed",parse:String,brief:"The Sombra internal key, use for additional authentication when self-hosting Sombra",optional:!0});var g=["dataSilos","enrichers","templates","apiKeys"],I= exports.j =Object.values(_privacytypes.ConsentTrackerStatus),R= exports.k =_core.buildCommand.call(void 0, {loader:async()=>{let{pull:e}=await Promise.resolve().then(() => _interopRequireWildcard(require("./impl-DT5KLE2G.cjs")));return e},parameters:{flags:{auth:d({scopes:"Varies"}),resources:{kind:"enum",values:["all",...Object.values(_chunkQ7I37FJVcjs.d)],brief:`The different resource types to pull in. Defaults to ${g.join(",")}.`,variadic:",",optional:!0},file:{kind:"parsed",parse:String,brief:"Path to the YAML file to pull into",default:"./transcend.yml"},transcendUrl:u(),dataSiloIds:{kind:"parsed",parse:String,variadic:",",brief:"The UUIDs of the data silos that should be pulled into the YAML file",optional:!0},integrationNames:{kind:"parsed",parse:String,variadic:",",brief:"The types of integrations to pull down",optional:!0},trackerStatuses:{kind:"enum",values:Object.values(_privacytypes.ConsentTrackerStatus),variadic:",",brief:"The statuses of consent manager trackers to pull down. Defaults to all statuses.",optional:!0},pageSize:{kind:"parsed",parse:_core.numberParser,brief:"The page size to use when paginating over the API",default:"50"},skipDatapoints:{kind:"boolean",brief:"When true, skip pulling in datapoints alongside data silo resource",default:!1},skipSubDatapoints:{kind:"boolean",brief:"When true, skip pulling in subDatapoints alongside data silo resource",default:!1},includeGuessedCategories:{kind:"boolean",brief:"When true, included guessed data categories that came from the content classifier",default:!1},debug:{kind:"boolean",brief:"Set to true to include debug logs while pulling the configuration",default:!1}}},docs:{brief:"Pull metadata from Transcend into transcend.yml",fullDescription:`Generates a transcend.yml by pulling the configuration from your Transcend instance.
|
|
2
2
|
|
|
3
3
|
The API key needs various scopes depending on the resources being pulled (see the CLI's README for more details).
|
|
4
4
|
|
|
@@ -6,4 +6,4 @@ This command can be helpful if you are looking to:
|
|
|
6
6
|
|
|
7
7
|
- Copy your data into another instance
|
|
8
8
|
- Generate a transcend.yml file as a starting point to maintain parts of your data inventory in code.`}});exports.a = S; exports.b = T; exports.c = y; exports.d = k; exports.e = d; exports.f = u; exports.g = x; exports.h = A; exports.i = g; exports.j = I; exports.k = R;
|
|
9
|
-
//# sourceMappingURL=chunk-
|
|
9
|
+
//# sourceMappingURL=chunk-FER7XKVN.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-FER7XKVN.cjs","../src/commands/inventory/pull/command.ts","../src/lib/cli/parsers.ts"],"names":["uuidParser","input"],"mappings":"AAAA,mfAA0C,wDAAyC,qCCAxC,2DACN,gECDiB,SAStCA,CAAAA,CAAWC,CAAAA,CAAuB,CAGhD,EAAA,CAAI,CADF,4EAAA,CACa,IAAA,CAAKA,CAAK,CAAA,CACvB,MAAM,IAAI,KAAA,CAAM,CAAA,qBAAA,EAAwBA,CAAK,CAAA,CAAA;ADwF5B;AAAA;AAAA;AAAA;AAAA;AAAA;AASpB,qGAAA","file":"/home/runner/work/cli/cli/dist/chunk-FER7XKVN.cjs","sourcesContent":[null,"import { buildCommand, numberParser } from '@stricli/core';\nimport { ConsentTrackerStatus } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\nimport { TranscendPullResource } from '../../../enums';\n\nexport const DEFAULT_TRANSCEND_PULL_RESOURCES = [\n TranscendPullResource.DataSilos,\n TranscendPullResource.Enrichers,\n TranscendPullResource.Templates,\n TranscendPullResource.ApiKeys,\n];\n\nexport const DEFAULT_CONSENT_TRACKER_STATUSES =\n Object.values(ConsentTrackerStatus);\n\nexport const pullCommand = buildCommand({\n loader: async () => {\n const { pull } = await import('./impl');\n return pull;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: 'Varies',\n }),\n resources: {\n kind: 'enum',\n values: ['all', ...Object.values(TranscendPullResource)],\n brief: `The different resource types to pull in. Defaults to ${DEFAULT_TRANSCEND_PULL_RESOURCES.join(\n ',',\n )}.`,\n variadic: ',',\n optional: true,\n },\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the YAML file to pull into',\n default: './transcend.yml',\n },\n transcendUrl: createTranscendUrlParameter(),\n dataSiloIds: {\n kind: 'parsed',\n parse: String,\n variadic: ',',\n brief:\n 'The UUIDs of the data silos that should be pulled into the YAML file',\n optional: true,\n },\n integrationNames: {\n kind: 'parsed',\n parse: String,\n variadic: ',',\n brief: 'The types of integrations to pull down',\n optional: true,\n },\n trackerStatuses: {\n kind: 'enum',\n values: Object.values(ConsentTrackerStatus),\n variadic: ',',\n brief:\n 'The statuses of consent manager trackers to pull down. Defaults to all statuses.',\n optional: true,\n },\n pageSize: {\n kind: 'parsed',\n parse: numberParser,\n brief: 'The page size to use when paginating over the API',\n default: '50',\n },\n skipDatapoints: {\n kind: 'boolean',\n brief:\n 'When true, skip pulling in datapoints alongside data silo resource',\n default: false,\n },\n skipSubDatapoints: {\n kind: 'boolean',\n brief:\n 'When true, skip pulling in subDatapoints alongside data silo resource',\n default: false,\n },\n includeGuessedCategories: {\n kind: 'boolean',\n brief:\n 'When true, included guessed data categories that came from the content classifier',\n default: false,\n },\n debug: {\n kind: 'boolean',\n brief:\n 'Set to true to include debug logs while pulling the configuration',\n default: false,\n },\n },\n },\n docs: {\n brief: 'Pull metadata from Transcend into transcend.yml',\n fullDescription: `Generates a transcend.yml by pulling the configuration from your Transcend instance.\n\nThe API key needs various scopes depending on the resources being pulled (see the CLI's README for more details).\n\nThis command can be helpful if you are looking to:\n\n- Copy your data into another instance\n- Generate a transcend.yml file as a starting point to maintain parts of your data inventory in code.`,\n },\n});\n","import ms, { type StringValue as MsStringValue } from 'ms';\n\n/**\n * Validates and returns a UUID string.\n *\n * @param input - The input string to validate as UUID\n * @returns The validated UUID string\n * @throws Error if input is not a valid UUID\n */\nexport function uuidParser(input: string): string {\n const uuidRegex =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n if (!uuidRegex.test(input)) {\n throw new Error(`Invalid UUID format: ${input}`);\n }\n return input;\n}\n\n/**\n * Validates and returns a URL string.\n *\n * @param input - The input string to validate as URL\n * @returns The validated URL string\n * @throws Error if input is not a valid URL\n */\nexport function urlParser(input: string): string {\n try {\n const url = new URL(input);\n return url.toString().replace(/\\/$/, '');\n } catch {\n throw new Error(`Invalid URL format: ${input}`);\n }\n}\n\n/**\n * Parse a comma-separated string to array.\n * NOTE: Prefer using `variadic` for list arguments instead of this function. This should only be used for arguments which have a default value.\n *\n * @param input - The comma-separated string to parse\n * @returns Array of trimmed, non-empty strings\n */\nexport function arrayParser(input: string): string[] {\n return input\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n}\n\n/**\n * Parse a date string to a Date object.\n *\n * @param input - The date string to parse\n * @returns The parsed Date object\n * @throws TypeError if input is not a valid date\n */\nexport function dateParser(input: string): Date {\n const date = new Date(input);\n if (Number.isNaN(date.getTime())) {\n throw new TypeError(\n `Invalid date: ${input}. Try using the ISO 8601 format (YYYY-MM-DDTHH:MM:SS.SSSZ)`,\n );\n }\n return date;\n}\n\n/**\n * Parse a duration string to milliseconds.\n * Accepts concise/natural-ish strings (powered by `ms`) and returns milliseconds.\n * Examples: \"3600\", \"2d\", \"1h\", \"90 minutes\", \"10s\".\n *\n * @param input - The duration to parse\n * @returns The parsed duration in milliseconds\n * @throws Error if input is not a valid duration\n */\nexport function parseDurationToMs(input: unknown): number {\n if (typeof input === 'number' && Number.isFinite(input)) {\n // backward-compat: numbers => seconds\n return Math.round(input * 1000);\n }\n\n if (typeof input === 'string') {\n const trimmed = input.trim();\n // empty string → our standardized error (avoid ms throwing its own)\n if (trimmed === '') {\n throw new Error(\n 'Invalid duration. Examples: \"45\", \"2d\", \"1h\", \"90 minutes\", \"10s\".',\n );\n }\n\n // bare numeric string => seconds (backward-compat)\n const asNumber = Number(trimmed);\n if (trimmed !== '' && Number.isFinite(asNumber)) {\n return Math.round(asNumber * 1000);\n }\n\n // let ms parse human strings\n let parsed: number | undefined;\n try {\n parsed = ms(trimmed as MsStringValue);\n } catch {\n // normalize ms' error to ours\n throw new Error(\n 'Invalid duration. Examples: \"45\", \"2d\", \"1h\", \"90 minutes\", \"10s\".',\n );\n }\n if (typeof parsed === 'number' && Number.isFinite(parsed)) {\n return parsed;\n }\n }\n\n throw new Error(\n 'Invalid duration. Examples: \"45\", \"2d\", \"1h\", \"90 minutes\", \"10s\".',\n );\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
|
|
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 _chunkKUBXRT3Vcjs = require('./chunk-KUBXRT3V.cjs');var _chunkZUNVPK23cjs = require('./chunk-ZUNVPK23.cjs');var _chunkEYOQLGDVcjs = require('./chunk-EYOQLGDV.cjs');var _iots = require('io-ts'); var e = _interopRequireWildcard(_iots); var P = _interopRequireWildcard(_iots);var _typeutils = require('@transcend-io/type-utils');var X=e.type({identifier:e.string,type:e.string,coreIdentifier:e.string,dataSiloId:e.string,requestId:e.string,nonce:e.string,requestCreatedAt:e.string,daysUntilOverdue:e.number,attributes:e.array(e.type({key:e.string,values:e.array(e.string)}))});async function U(r,{dataSiloId:s,limit:c=100,offset:n=0,requestType:a}){try{let i=await r.get(`v1/data-silo/${s}/pending-requests/${a}`,{searchParams:{offset:n,limit:c}}).json(),{items:f}=_typeutils.decodeCodec.call(void 0, e.type({items:e.array(X)}),i);return f}catch(i){throw new Error(`Received an error from server: ${_optionalChain([i, 'optionalAccess', _2 => _2.response, 'optionalAccess', _3 => _3.body])||_optionalChain([i, 'optionalAccess', _4 => _4.message])}`)}}var L=P.type({nonce:P.string,identifier:P.string});async function B(r,{nonce:s,identifier:c}){try{return await r.put("v1/data-silo",{headers:{"x-transcend-nonce":s},json:{profiles:[{profileId:c}]}}),!0}catch(n){if(_optionalChain([n, 'access', _5 => _5.response, 'optionalAccess', _6 => _6.statusCode])===409)return!1;throw new Error(`Received an error from server: ${_optionalChain([n, 'optionalAccess', _7 => _7.response, 'optionalAccess', _8 => _8.body])||_optionalChain([n, 'optionalAccess', _9 => _9.message])}`)}}var _bluebird = require('bluebird');var _colors = require('colors'); var _colors2 = _interopRequireDefault(_colors);var _cliprogress = require('cli-progress'); var _cliprogress2 = _interopRequireDefault(_cliprogress);async function ge({file:r,dataSiloId:s,auth:c,sombraAuth:n,concurrency:a=100,transcendUrl:i=_chunkEYOQLGDVcjs.r,sleepSeconds:f=10}){let y=await _chunkKUBXRT3Vcjs.xc.call(void 0, i,c,n);_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Reading "${r}" from disk`));let o=_chunkKUBXRT3Vcjs.rc.call(void 0, r,L);_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Notifying Transcend for data silo "${s}" marking "${o.length}" identifiers as completed.`));let C=new Date().getTime(),w=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),d=0,u=0,l=0;w.start(o.length,0);let m=_chunkEYOQLGDVcjs.b.call(void 0, o,a),I=m.length;await _bluebird.mapSeries.call(void 0, m,async($,S)=>{_chunkZUNVPK23cjs.a.info(_colors2.default.blue(`Processing chunk ${S+1}/${I} (${_chunkEYOQLGDVcjs.b.length} items)`)),await _bluebird.map.call(void 0, $,async h=>{try{await B(y,h)?d+=1:u+=1}catch(b){_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Error notifying Transcend for identifier "${h.identifier}" - ${_optionalChain([b, 'optionalAccess', _10 => _10.message])}`)),l+=1}w.update(d+u)}),f>0&&S<I-1&&(_chunkZUNVPK23cjs.a.info(_colors2.default.yellow(`Sleeping for ${f}s before next chunk...`)),await new Promise(h=>{setTimeout(h,f*1e3)}))}),w.stop();let D=new Date().getTime()-C;if(_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully notified Transcend for ${d} identifiers in "${D/1e3}" seconds!`)),u&&_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`There were ${u} identifiers that were not in a state to be updated.They likely have already been resolved.`)),l)throw _chunkZUNVPK23cjs.a.error(_colors2.default.red(`There were ${l} identifiers that failed to be updated. Please review the logs for more information.`)),new Error("Failed to update all identifiers");return o.length}var _privacytypes = require('@transcend-io/privacy-types');async function Pe({requestIds:r,dataSiloId:s,auth:c,concurrency:n=100,status:a=_privacytypes.RequestDataSiloStatus.Resolved,transcendUrl:i=_chunkEYOQLGDVcjs.r}){let f=_chunkKUBXRT3Vcjs.wc.call(void 0, i,c),y=new Date().getTime(),o=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic);_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Notifying Transcend for data silo "${s}" marking "${r.length}" requests as completed.`));let C=0;o.start(r.length,0),await _bluebird.map.call(void 0, r,async u=>{let l=await _chunkKUBXRT3Vcjs.Gd.call(void 0, f,{requestId:u,dataSiloId:s});try{await _chunkKUBXRT3Vcjs.sg.call(void 0, f,_chunkKUBXRT3Vcjs.va,{requestDataSiloId:l.id,status:a})}catch(m){if(!m.message.includes("Client error: Request must be active:")&&!m.message.includes("Failed to find RequestDataSilo"))throw m}C+=1,o.update(C)},{concurrency:n}),o.stop();let d=new Date().getTime()-y;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully notified Transcend in "${d/1e3}" seconds!`)),r.length}async function _e({dataSiloId:r,auth:s,sombraAuth:c,actions:n,apiPageSize:a=100,savePageSize:i=1e3,onSave:f,transcendUrl:y=_chunkEYOQLGDVcjs.r,skipRequestCount:o=!1}){if(i%a!==0)throw new Error(`savePageSize must be a multiple of apiPageSize. savePageSize: ${i}, apiPageSize: ${a}`);let C=await _chunkKUBXRT3Vcjs.xc.call(void 0, y,s,c),w=_chunkKUBXRT3Vcjs.wc.call(void 0, y,s),d=0;o||(d=await _chunkKUBXRT3Vcjs.Hd.call(void 0, w,{dataSiloId:r})),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Pulling ${o?"all":d} outstanding request identifiers for data silo: "${r}" for requests of types "${n.join('", "')}"`));let u=new Date().getTime(),l=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),m=new Set,I=[],g=[];o||l.start(d,0),await _bluebird.mapSeries.call(void 0, n,async $=>{let S=0,h=!0;for(;h;){let b=await U(C,{dataSiloId:r,limit:a,offset:S,requestType:$}),k=b.map(A=>(m.add(A.requestId),{...A,action:$})),J=k.map(({attributes:A,...K})=>({...K,...A.reduce((M,E)=>Object.assign(M,{[E.key]:E.values.join(",")}),{})}));I.push(...k),g.push(...J),g.length>=i&&(await f(g),g=[]),h=b.length===a,S+=a,o?_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Pulled ${b.length} outstanding identifiers for ${m.size} requests`)):l.update(m.size)}}),g.length>0&&await f(g),o||l.stop();let D=new Date().getTime()-u;return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully pulled ${I.length} outstanding identifiers from ${m.size} requests in "${D/1e3}" seconds!`)),{identifiers:I}}exports.a = X; exports.b = U; exports.c = L; exports.d = B; exports.e = ge; exports.f = Pe; exports.g = _e;
|
|
2
|
+
//# sourceMappingURL=chunk-I7PFP5VB.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-I7PFP5VB.cjs","../src/lib/cron/pullCronPageOfIdentifiers.ts"],"names":["CronIdentifier","pullCronPageOfIdentifiers","sombra","dataSiloId","limit","offset","requestType","response"],"mappings":"AAAA,u/BAAyF,wDAAyC,wDAAgD,6GCA/J,qDACS,IAIfA,CAAAA,CAAmB,CAAA,CAAA,IAAA,CAAK,CAEnC,UAAA,CAAc,CAAA,CAAA,MAAA,CAEd,IAAA,CAAQ,CAAA,CAAA,MAAA,CAER,cAAA,CAAkB,CAAA,CAAA,MAAA,CAElB,UAAA,CAAc,CAAA,CAAA,MAAA,CAEd,SAAA,CAAa,CAAA,CAAA,MAAA,CAEb,KAAA,CAAS,CAAA,CAAA,MAAA,CAET,gBAAA,CAAoB,CAAA,CAAA,MAAA,CAEpB,gBAAA,CAAoB,CAAA,CAAA,MAAA,CAEpB,UAAA,CAAc,CAAA,CAAA,KAAA,CACV,CAAA,CAAA,IAAA,CAAK,CACL,GAAA,CAAO,CAAA,CAAA,MAAA,CACP,MAAA,CAAU,CAAA,CAAA,KAAA,CAAQ,CAAA,CAAA,MAAM,CAC1B,CAAC,CACH,CACF,CAAC,CAAA,CAaD,MAAA,SAAsBC,CAAAA,CACpBC,CAAAA,CACA,CACE,UAAA,CAAAC,CAAAA,CACA,KAAA,CAAAC,CAAAA,CAAQ,GAAA,CACR,MAAA,CAAAC,CAAAA,CAAS,CAAA,CACT,WAAA,CAAAC,CACF,CAAA,CAU2B,CAC3B,GAAI,CAEF,IAAMC,CAAAA,CAAW,MAAML,CAAAA,CACpB,GAAA,CAAI,CAAA,aAAA,EAAgBC,CAAU,CAAA,kBAAA,EAAqBG,CAAW,CAAA,CAAA","file":"/home/runner/work/cli/cli/dist/chunk-I7PFP5VB.cjs","sourcesContent":[null,"import * as t from 'io-ts';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport { RequestAction } from '@transcend-io/privacy-types';\nimport type { Got } from 'got';\n\nexport const CronIdentifier = t.type({\n /** The identifier value */\n identifier: t.string,\n /** The type of identifier */\n type: t.string,\n /** The core identifier of the request */\n coreIdentifier: t.string,\n /** The ID of the underlying data silo */\n dataSiloId: t.string,\n /** The ID of the underlying request */\n requestId: t.string,\n /** The request nonce */\n nonce: t.string,\n /** The time the request was created */\n requestCreatedAt: t.string,\n /** The number of days until the request is overdue */\n daysUntilOverdue: t.number,\n /** Request attributes */\n attributes: t.array(\n t.type({\n key: t.string,\n values: t.array(t.string),\n }),\n ),\n});\n\n/** Type override */\nexport type CronIdentifier = t.TypeOf<typeof CronIdentifier>;\n\n/**\n * Pull a offset of identifiers for a cron job\n *\n * @see https://docs.transcend.io/docs/api-reference/GET/v1/data-silo/(id)/pending-requests/(type)\n * @param sombra - Sombra instance configured to make requests\n * @param options - Additional options\n * @returns Successfully submitted request\n */\nexport async function pullCronPageOfIdentifiers(\n sombra: Got,\n {\n dataSiloId,\n limit = 100,\n offset = 0,\n requestType,\n }: {\n /** Data Silo ID */\n dataSiloId: string;\n /** Type of request */\n requestType: RequestAction;\n /** Number of identifiers to pull in */\n limit?: number;\n /** Page to pull in */\n offset?: number;\n },\n): Promise<CronIdentifier[]> {\n try {\n // Make the GraphQL request\n const response = await sombra\n .get(`v1/data-silo/${dataSiloId}/pending-requests/${requestType}`, {\n searchParams: {\n offset,\n limit,\n },\n })\n .json();\n\n const { items } = decodeCodec(\n t.type({\n items: t.array(CronIdentifier),\n }),\n response,\n );\n return items;\n } catch (err) {\n throw new Error(\n `Received an error from server: ${err?.response?.body || err?.message}`,\n );\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkECGHWDVPcjs = require('./chunk-ECGHWDVP.cjs');var _typeutils = require('@transcend-io/type-utils');var _jsyaml = require('js-yaml'); var _jsyaml2 = _interopRequireDefault(_jsyaml);var _fs = require('fs');var s=/<<parameters\.(.+?)>>/,i= exports.b ="parameters";function u(e,t,a=""){let r=e;if(Object.entries(t).forEach(([n,p])=>{r=r.split(`<<${i}.${n}>>`).join(p)}),s.test(r)){let[,n]=s.exec(r)||[];throw new Error(`Found variable that was not set: ${n}.
|
|
2
2
|
Make sure you are passing all parameters through the --${i}=${n}:value-for-param flag.
|
|
3
|
-
${a}`)}return r}function b(e,t={}){let a=_fs.readFileSync.call(void 0, e,"utf-8"),r=u(a,t,`Also check that there are no extra variables defined in your yaml: ${e}`);return _typeutils.decodeCodec.call(void 0,
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
${a}`)}return r}function b(e,t={}){let a=_fs.readFileSync.call(void 0, e,"utf-8"),r=u(a,t,`Also check that there are no extra variables defined in your yaml: ${e}`);return _typeutils.decodeCodec.call(void 0, _chunkECGHWDVPcjs.ga,_jsyaml2.default.load(r))}function h(e,t){_fs.writeFileSync.call(void 0, e,_jsyaml2.default.dump(_typeutils.decodeCodec.call(void 0, _chunkECGHWDVPcjs.ga,t)))}exports.a = s; exports.b = i; exports.c = u; exports.d = b; exports.e = h;
|
|
4
|
+
//# sourceMappingURL=chunk-JFZPP4VV.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-JFZPP4VV.cjs","../src/lib/readTranscendYaml.ts"],"names":["VARIABLE_PARAMETERS_REGEXP","VARIABLE_PARAMETERS_NAME","replaceVariablesInYaml","input","variables","extraErrorMessage","contents","name","value"],"mappings":"AAAA,iOAAyC,qDCAA,iFACxB,wBAC2B,IAG/BA,CAAAA,CAA6B,uBAAA,CAC7BC,CAAAA,aAA2B,YAAA,CAWjC,SAASC,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAAoB,EAAA,CACZ,CACR,IAAIC,CAAAA,CAAWH,CAAAA,CASf,EAAA,CAPA,MAAA,CAAO,OAAA,CAAQC,CAAS,CAAA,CAAE,OAAA,CAAQ,CAAC,CAACG,CAAAA,CAAMC,CAAK,CAAA,CAAA,EAAM,CACnDF,CAAAA,CAAWA,CAAAA,CACR,KAAA,CAAM,CAAA,EAAA,EAAKL,CAAwB,CAAA,CAAA,EAAIM,CAAI,CAAA,EAAA,CAAI,CAAA,CAC/C,IAAA,CAAKC,CAAK,CACf,CAAC,CAAA,CAGGR,CAAAA,CAA2B,IAAA,CAAKM,CAAQ,CAAA,CAAG,CAC7C,GAAM,CAAC,CAAEC,CAAI,CAAA,CAAIP,CAAAA,CAA2B,IAAA,CAAKM,CAAQ,CAAA,EAAK,CAAC,CAAA,CAC/D,MAAM,IAAI,KAAA,CACR,CAAA,iCAAA,EAAoCC,CAAI,CAAA;AAAA,uDAAA,EACWN,CAAwB,CAAA,CAAA,EAAIM,CAAI,CAAA;AAAA,EACvFF,CAAiB,CAAA,CAAA","file":"/home/runner/work/cli/cli/dist/chunk-JFZPP4VV.cjs","sourcesContent":[null,"import { decodeCodec, ObjByString } from '@transcend-io/type-utils';\nimport yaml from 'js-yaml';\nimport { readFileSync, writeFileSync } from 'node:fs';\nimport { TranscendInput } from '../codecs';\n\nexport const VARIABLE_PARAMETERS_REGEXP = /<<parameters\\.(.+?)>>/;\nexport const VARIABLE_PARAMETERS_NAME = 'parameters';\n\n/**\n * Function that replaces variables in a text file.\n * Throws error if there are variables that have not been replaced\n *\n * @param input - Input text\n * @param variables - Variables to replace\n * @param extraErrorMessage - Additional error message text\n * @returns Output text\n */\nexport function replaceVariablesInYaml(\n input: string,\n variables: ObjByString,\n extraErrorMessage = '',\n): string {\n let contents = input;\n // Replace variables\n Object.entries(variables).forEach(([name, value]) => {\n contents = contents\n .split(`<<${VARIABLE_PARAMETERS_NAME}.${name}>>`)\n .join(value);\n });\n\n // Throw error if unfilled variables\n if (VARIABLE_PARAMETERS_REGEXP.test(contents)) {\n const [, name] = VARIABLE_PARAMETERS_REGEXP.exec(contents) || [];\n throw new Error(\n `Found variable that was not set: ${name}.\nMake sure you are passing all parameters through the --${VARIABLE_PARAMETERS_NAME}=${name}:value-for-param flag.\n${extraErrorMessage}`,\n );\n }\n\n return contents;\n}\n\n/**\n * Read in the contents of a yaml file and validate that the shape\n * of the yaml file matches the codec API\n *\n * @param filePath - Path to yaml file\n * @param variables - Variables to fill in\n * @returns The contents of the yaml file, type-checked\n */\nexport function readTranscendYaml(\n filePath: string,\n variables: ObjByString = {},\n): TranscendInput {\n // Read in contents\n const fileContents = readFileSync(filePath, 'utf-8');\n\n // Replace variables\n const replacedVariables = replaceVariablesInYaml(\n fileContents,\n variables,\n `Also check that there are no extra variables defined in your yaml: ${filePath}`,\n );\n\n // Validate shape\n return decodeCodec(TranscendInput, yaml.load(replacedVariables));\n}\n\n/**\n * Write a Transcend configuration to disk\n *\n * @param filePath - Path to yaml file\n * @param input - The input to write out\n */\nexport function writeTranscendYaml(\n filePath: string,\n input: TranscendInput,\n): void {\n writeFileSync(filePath, yaml.dump(decodeCodec(TranscendInput, input)));\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 }; }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; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkECGHWDVPcjs = require('./chunk-ECGHWDVP.cjs');var _chunkKUBXRT3Vcjs = require('./chunk-KUBXRT3V.cjs');var _chunkZUNVPK23cjs = require('./chunk-ZUNVPK23.cjs');var _chunkEYOQLGDVcjs = require('./chunk-EYOQLGDV.cjs');var _bluebird = require('bluebird');var _colors = require('colors'); var _colors2 = _interopRequireDefault(_colors);async function H({email:r,password:a,scopes:f,apiKeyTitle:t,parentOrganizationId:o,deleteExistingApiKey:l=!0,createNewApiKey:I=!0,transcendUrl:x=_chunkEYOQLGDVcjs.r}){let s=await _chunkKUBXRT3Vcjs.vc.call(void 0, x,{});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Logging in using email and password."));let{roles:d,loginCookie:k}=await _chunkKUBXRT3Vcjs.Jd.call(void 0, s,{email:r,password:a});_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully logged in and found ${d.length} role${d.length===1?"":"s"}!`));let P=o?d.filter(e=>e.organization.id===o||e.organization.parentOrganizationId===o):d;s.setHeaders({Cookie:k});let m=[],c=[];return _chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Generating API keys with title: ${t}, scopes: ${f.join(",")}.`)),await _bluebird.mapSeries.call(void 0, P,async e=>{try{await _chunkKUBXRT3Vcjs.Kd.call(void 0, s,{roleId:e.id,email:r}),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Checking if API key already exists in organization "${e.organization.name}" with title: "${t}".`));let[g]=await _chunkKUBXRT3Vcjs.rd.call(void 0, s,[t]);if(g&&l)_chunkZUNVPK23cjs.a.info(_colors2.default.yellow(`Deleting existing API key in "${e.organization.name}" with title: "${t}".`)),await _chunkKUBXRT3Vcjs.Md.call(void 0, s,g.id),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully deleted API key in "${e.organization.name}" with title: "${t}".`));else if(g)throw new Error(`API key already exists with title: "${t}"`);if(I){_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Creating API key in "${e.organization.name}" with title: "${t}".`));let{apiKey:K}=await _chunkKUBXRT3Vcjs.Ld.call(void 0, s,{title:t,scopes:f});m.push({organizationName:e.organization.name,organizationId:e.organization.id,apiKey:K}),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully created API key in "${e.organization.name}" with title: "${t}".`))}else m.push({organizationName:e.organization.name,organizationId:e.organization.id,apiKey:""})}catch(g){_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Failed to create API key in organization "${e.organization.name}"! - ${g.message}`)),c.push({organizationName:e.organization.name,organizationId:e.organization.id,error:g.message})}}),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully created ${m.length} API key${m.length===1?"":"s"}`)),c.length>0&&_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Failed to create ${c.length} API key${c.length===1?"":"s"}!`)),{errors:c,apiKeys:m}}var _typeutils = require('@transcend-io/type-utils');var _iots = require('io-ts'); var S = _interopRequireWildcard(_iots);var _fs = require('fs');function T(r){return r||(_chunkZUNVPK23cjs.a.error(_colors2.default.red("A Transcend API key must be provided. You can specify using --auth=$TRANSCEND_API_KEY")),process.exit(1)),_fs.existsSync.call(void 0, r)?_typeutils.decodeCodec.call(void 0, S.array(_chunkECGHWDVPcjs.ha),_fs.readFileSync.call(void 0, r,"utf-8")):r}function Z(r,a,f=!1){if(!_fs.existsSync.call(void 0, r))return[];let t=_fs.readdirSync.call(void 0, r).filter(o=>a?a.filter(l=>o.endsWith(l)).length:!0).filter(o=>o.indexOf(".")>0);return f?t.map(o=>o.replace(/\.[^/.]+$/,"")):t}var _path = require('path');function te(r){return _fs.readdirSync.call(void 0, r).filter(a=>_fs.statSync.call(void 0, _path.join.call(void 0, r,a)).isDirectory())}exports.a = H; exports.b = T; exports.c = Z; exports.d = te;
|
|
2
|
+
//# sourceMappingURL=chunk-K4TIJ3VM.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-K4TIJ3VM.cjs","../src/lib/api-keys/generateCrossAccountApiKeys.ts"],"names":["generateCrossAccountApiKeys","email","password","scopes","apiKeyTitle","parentOrganizationId","deleteExistingApiKey","createNewApiKey","transcendUrl","DEFAULT_TRANSCEND_API","client","buildTranscendGraphQLClientGeneric","logger","colors","roles","loginCookie","loginUser","filteredRoles","role","results","errors","mapSeries","assumeRole","apiKeyWithTitle","fetchAllApiKeys","deleteApiKey","apiKey","createApiKey","err"],"mappings":"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","file":"/home/runner/work/cli/cli/dist/chunk-K4TIJ3VM.cjs","sourcesContent":[null,"import { mapSeries } from 'bluebird';\nimport {\n buildTranscendGraphQLClientGeneric,\n loginUser,\n createApiKey,\n fetchAllApiKeys,\n deleteApiKey,\n assumeRole,\n} from '../graphql';\nimport { ScopeName } from '@transcend-io/privacy-types';\nimport colors from 'colors';\nimport { StoredApiKey } from '../../codecs';\nimport { logger } from '../../logger';\nimport { DEFAULT_TRANSCEND_API } from '../../constants';\n\nexport interface ApiKeyGenerateError {\n /** Name of instance */\n organizationName: string;\n /** Error */\n error: string;\n /** Organization ID API key is for */\n organizationId: string;\n}\n\n/**\n * Generate API keys across multiple transcend accounts\n *\n * @param options - Options\n * @returns Number of API keys created\n */\nexport async function generateCrossAccountApiKeys({\n email,\n password,\n scopes,\n apiKeyTitle,\n parentOrganizationId,\n deleteExistingApiKey = true,\n createNewApiKey = true,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** Email address of user generating API keys */\n email: string;\n /** Password of user generating API keys */\n password: string;\n /** Filter for organizations that match this parent organization ID */\n parentOrganizationId?: string;\n /** Title of the API create to create */\n apiKeyTitle: string;\n /** Title of the API create to create */\n scopes: ScopeName[];\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** When true delete existing API keys with that title, if set to false an API key exists with that title, an error is thrown */\n deleteExistingApiKey?: boolean;\n /** When true, generate new API keys, otherwise only will delete past API keys */\n createNewApiKey?: boolean;\n}): Promise<{\n /** Successfully generated */\n apiKeys: StoredApiKey[];\n /** Error results */\n errors: ApiKeyGenerateError[];\n}> {\n // Create GraphQL client\n const client = await buildTranscendGraphQLClientGeneric(transcendUrl, {});\n\n // Login the user\n logger.info(colors.magenta('Logging in using email and password.'));\n const { roles, loginCookie } = await loginUser(client, { email, password });\n logger.info(\n colors.green(\n `Successfully logged in and found ${roles.length} role${\n roles.length === 1 ? '' : 's'\n }!`,\n ),\n );\n\n // Filter down by parentOrganizationId\n const filteredRoles = parentOrganizationId\n ? roles.filter(\n (role) =>\n role.organization.id === parentOrganizationId ||\n role.organization.parentOrganizationId === parentOrganizationId,\n )\n : roles;\n\n // Save cookie to call route subsequent times\n client.setHeaders({\n Cookie: loginCookie,\n });\n\n // Save the resulting API keys\n const results: StoredApiKey[] = [];\n const errors: ApiKeyGenerateError[] = [];\n\n // Generate API keys\n logger.info(\n colors.magenta(\n `Generating API keys with title: ${apiKeyTitle}, scopes: ${scopes.join(\n ',',\n )}.`,\n ),\n );\n\n // Map over each role\n await mapSeries(filteredRoles, async (role) => {\n try {\n // Log into the other instance\n await assumeRole(client, { roleId: role.id, email });\n\n // Grab API keys with that title\n logger.info(\n colors.magenta(\n `Checking if API key already exists in organization \"${role.organization.name}\" with title: \"${apiKeyTitle}\".`,\n ),\n );\n\n // Delete existing API key\n const [apiKeyWithTitle] = await fetchAllApiKeys(client, [apiKeyTitle]);\n if (apiKeyWithTitle && deleteExistingApiKey) {\n logger.info(\n colors.yellow(\n `Deleting existing API key in \"${role.organization.name}\" with title: \"${apiKeyTitle}\".`,\n ),\n );\n await deleteApiKey(client, apiKeyWithTitle.id);\n logger.info(\n colors.green(\n `Successfully deleted API key in \"${role.organization.name}\" with title: \"${apiKeyTitle}\".`,\n ),\n );\n } else if (apiKeyWithTitle) {\n // throw error if one exists but not configured to delete\n throw new Error(`API key already exists with title: \"${apiKeyTitle}\"`);\n }\n\n // Create the API key\n if (createNewApiKey) {\n logger.info(\n colors.magenta(\n `Creating API key in \"${role.organization.name}\" with title: \"${apiKeyTitle}\".`,\n ),\n );\n const { apiKey } = await createApiKey(client, {\n title: apiKeyTitle,\n scopes,\n });\n results.push({\n organizationName: role.organization.name,\n organizationId: role.organization.id,\n apiKey,\n });\n logger.info(\n colors.green(\n `Successfully created API key in \"${role.organization.name}\" with title: \"${apiKeyTitle}\".`,\n ),\n );\n } else {\n // Delete only\n results.push({\n organizationName: role.organization.name,\n organizationId: role.organization.id,\n apiKey: '',\n });\n }\n } catch (err) {\n logger.error(\n colors.red(\n `Failed to create API key in organization \"${role.organization.name}\"! - ${err.message}`,\n ),\n );\n errors.push({\n organizationName: role.organization.name,\n organizationId: role.organization.id,\n error: err.message,\n });\n }\n });\n logger.info(\n colors.green(\n `Successfully created ${results.length} API key${\n results.length === 1 ? '' : 's'\n }`,\n ),\n );\n\n if (errors.length > 0) {\n logger.error(\n colors.red(\n `Failed to create ${errors.length} API key${\n errors.length === 1 ? '' : 's'\n }!`,\n ),\n );\n }\n\n return { errors, apiKeys: results };\n}\n"]}
|