@transcend-io/cli 8.31.1 → 8.32.4
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 +121 -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-M7OVJJGB.cjs → chunk-22KX2NM4.cjs} +4 -4
- package/dist/{chunk-M7OVJJGB.cjs.map → chunk-22KX2NM4.cjs.map} +1 -1
- package/dist/chunk-56QKBG2R.cjs +3001 -0
- package/dist/chunk-56QKBG2R.cjs.map +1 -0
- package/dist/chunk-6TKTYQIF.cjs +3 -0
- package/dist/chunk-6TKTYQIF.cjs.map +1 -0
- package/dist/{chunk-DIB7IOEX.cjs → chunk-BPOXNSPY.cjs} +2 -2
- package/dist/{chunk-DIB7IOEX.cjs.map → chunk-BPOXNSPY.cjs.map} +1 -1
- package/dist/chunk-CM7VJEOY.cjs +4 -0
- package/dist/{chunk-SKOTYI3A.cjs.map → chunk-CM7VJEOY.cjs.map} +1 -1
- package/dist/chunk-D3VRD5F5.cjs +2 -0
- package/dist/chunk-D3VRD5F5.cjs.map +1 -0
- package/dist/{chunk-XXFLFF7Q.cjs → chunk-DQCPGPXG.cjs} +2 -2
- package/dist/{chunk-XXFLFF7Q.cjs.map → chunk-DQCPGPXG.cjs.map} +1 -1
- package/dist/{chunk-MXT7N555.cjs → chunk-DYBVUGHH.cjs} +22 -22
- package/dist/chunk-DYBVUGHH.cjs.map +1 -0
- package/dist/chunk-IHUCIK5T.cjs +2 -0
- package/dist/{chunk-Q2RJZGYW.cjs.map → chunk-IHUCIK5T.cjs.map} +1 -1
- package/dist/{chunk-7H4ALAHC.cjs → chunk-LQUVB4MI.cjs} +4 -4
- package/dist/chunk-LQUVB4MI.cjs.map +1 -0
- package/dist/chunk-P5GD5LAK.cjs +2 -0
- package/dist/chunk-P5GD5LAK.cjs.map +1 -0
- package/dist/chunk-PGO2YKRX.cjs +12 -0
- package/dist/chunk-PGO2YKRX.cjs.map +1 -0
- package/dist/{chunk-ALOB5SWZ.cjs → chunk-VCPZG4FJ.cjs} +2 -2
- package/dist/{chunk-ALOB5SWZ.cjs.map → chunk-VCPZG4FJ.cjs.map} +1 -1
- package/dist/chunk-VUQAH7YK.cjs +12 -0
- package/dist/chunk-VUQAH7YK.cjs.map +1 -0
- package/dist/{impl-VXOHC45F.cjs → impl-2JA6BPE7.cjs} +2 -2
- package/dist/{impl-VXOHC45F.cjs.map → impl-2JA6BPE7.cjs.map} +1 -1
- package/dist/{impl-PKWSORXX.cjs → impl-4AI7T6RD.cjs} +2 -2
- package/dist/{impl-PKWSORXX.cjs.map → impl-4AI7T6RD.cjs.map} +1 -1
- package/dist/impl-4LAJNPQ4.cjs +16 -0
- package/dist/impl-4LAJNPQ4.cjs.map +1 -0
- package/dist/{impl-4CWCLU5Z.cjs → impl-4YFJOKCA.cjs} +2 -2
- package/dist/{impl-4CWCLU5Z.cjs.map → impl-4YFJOKCA.cjs.map} +1 -1
- package/dist/{impl-WMI46UXI.cjs → impl-5RX3NB6C.cjs} +2 -2
- package/dist/{impl-WMI46UXI.cjs.map → impl-5RX3NB6C.cjs.map} +1 -1
- package/dist/{impl-VUAC7AYF.cjs → impl-66CDS7IN.cjs} +2 -2
- package/dist/{impl-VUAC7AYF.cjs.map → impl-66CDS7IN.cjs.map} +1 -1
- package/dist/{impl-542SIWQ2.cjs → impl-ADPBEB3N.cjs} +2 -2
- package/dist/{impl-542SIWQ2.cjs.map → impl-ADPBEB3N.cjs.map} +1 -1
- package/dist/{impl-REKQO7ZI.cjs → impl-B6DTQRYV.cjs} +2 -2
- package/dist/{impl-REKQO7ZI.cjs.map → impl-B6DTQRYV.cjs.map} +1 -1
- package/dist/impl-BHA2L6BP.cjs +2 -0
- package/dist/{impl-V3MXFXZF.cjs.map → impl-BHA2L6BP.cjs.map} +1 -1
- package/dist/impl-BLGX7DMN.cjs +6 -0
- package/dist/impl-BLGX7DMN.cjs.map +1 -0
- package/dist/{impl-XJBUIDZP.cjs → impl-DA7AASRR.cjs} +2 -2
- package/dist/{impl-XJBUIDZP.cjs.map → impl-DA7AASRR.cjs.map} +1 -1
- package/dist/{impl-OQAP7YDW.cjs → impl-EXHOBCQW.cjs} +2 -2
- package/dist/{impl-OQAP7YDW.cjs.map → impl-EXHOBCQW.cjs.map} +1 -1
- package/dist/{impl-D2HENZNO.cjs → impl-FRWZLZ2V.cjs} +2 -2
- package/dist/{impl-D2HENZNO.cjs.map → impl-FRWZLZ2V.cjs.map} +1 -1
- package/dist/impl-GA6T4SCB.cjs +2 -0
- package/dist/impl-GA6T4SCB.cjs.map +1 -0
- package/dist/{impl-RD5UOJY6.cjs → impl-GG3S2VBT.cjs} +2 -2
- package/dist/{impl-RD5UOJY6.cjs.map → impl-GG3S2VBT.cjs.map} +1 -1
- package/dist/impl-GZNNNSYW.cjs +7 -0
- package/dist/{impl-BQNXMBQ4.cjs.map → impl-GZNNNSYW.cjs.map} +1 -1
- package/dist/{impl-5VMEZB7F.cjs → impl-IOS3QLTX.cjs} +2 -2
- package/dist/{impl-5VMEZB7F.cjs.map → impl-IOS3QLTX.cjs.map} +1 -1
- package/dist/{impl-PHBUSAGS.cjs → impl-IQGUF37H.cjs} +2 -2
- package/dist/{impl-PHBUSAGS.cjs.map → impl-IQGUF37H.cjs.map} +1 -1
- package/dist/impl-IZIXOMMN.cjs +2 -0
- package/dist/impl-IZIXOMMN.cjs.map +1 -0
- package/dist/{impl-VT3C6SP4.cjs → impl-J5PWNHKL.cjs} +2 -2
- package/dist/{impl-VT3C6SP4.cjs.map → impl-J5PWNHKL.cjs.map} +1 -1
- package/dist/impl-JI6COVDW.cjs +2 -0
- package/dist/{impl-SRI65ZIC.cjs.map → impl-JI6COVDW.cjs.map} +1 -1
- package/dist/{impl-XLL66FXK.cjs → impl-JY7YM3QH.cjs} +2 -2
- package/dist/{impl-XLL66FXK.cjs.map → impl-JY7YM3QH.cjs.map} +1 -1
- package/dist/{impl-YGVW4RTA.cjs → impl-LKX6OLE2.cjs} +2 -2
- package/dist/{impl-YGVW4RTA.cjs.map → impl-LKX6OLE2.cjs.map} +1 -1
- package/dist/impl-MRC5UI22.cjs +2 -0
- package/dist/impl-MRC5UI22.cjs.map +1 -0
- package/dist/{impl-KQYINEBI.cjs → impl-NW57RBBR.cjs} +2 -2
- package/dist/{impl-KQYINEBI.cjs.map → impl-NW57RBBR.cjs.map} +1 -1
- package/dist/impl-QOCEM2K5.cjs +2 -0
- package/dist/{impl-JSXYZHX4.cjs.map → impl-QOCEM2K5.cjs.map} +1 -1
- package/dist/{impl-K2D3GTZG.cjs → impl-QPLTL2SO.cjs} +2 -2
- package/dist/{impl-K2D3GTZG.cjs.map → impl-QPLTL2SO.cjs.map} +1 -1
- package/dist/impl-R35FW4U7.cjs +9 -0
- package/dist/impl-R35FW4U7.cjs.map +1 -0
- package/dist/{impl-6ANYWCOV.cjs → impl-RMPDHVAH.cjs} +2 -2
- package/dist/{impl-6ANYWCOV.cjs.map → impl-RMPDHVAH.cjs.map} +1 -1
- package/dist/{impl-JQVCW52V.cjs → impl-S64WVKSC.cjs} +2 -2
- package/dist/{impl-JQVCW52V.cjs.map → impl-S64WVKSC.cjs.map} +1 -1
- package/dist/{impl-55GTRVMZ.cjs → impl-SE32ARTN.cjs} +2 -2
- package/dist/{impl-55GTRVMZ.cjs.map → impl-SE32ARTN.cjs.map} +1 -1
- package/dist/{impl-PWYKAVK4.cjs → impl-SSBP4ONX.cjs} +2 -2
- package/dist/{impl-PWYKAVK4.cjs.map → impl-SSBP4ONX.cjs.map} +1 -1
- package/dist/{impl-T67PUM7X.cjs → impl-UA7V6YEM.cjs} +2 -2
- package/dist/{impl-T67PUM7X.cjs.map → impl-UA7V6YEM.cjs.map} +1 -1
- package/dist/{impl-NK42TN4C.cjs → impl-WTGAAEUZ.cjs} +2 -2
- package/dist/{impl-NK42TN4C.cjs.map → impl-WTGAAEUZ.cjs.map} +1 -1
- package/dist/{impl-Q3P6DGHG.cjs → impl-WVOFYJLG.cjs} +2 -2
- package/dist/{impl-Q3P6DGHG.cjs.map → impl-WVOFYJLG.cjs.map} +1 -1
- package/dist/{impl-TCR3Y3J2.cjs → impl-X23VUODX.cjs} +2 -2
- package/dist/{impl-TCR3Y3J2.cjs.map → impl-X23VUODX.cjs.map} +1 -1
- package/dist/{impl-KRJNBGJ6.cjs → impl-XU54KM62.cjs} +2 -2
- package/dist/{impl-KRJNBGJ6.cjs.map → impl-XU54KM62.cjs.map} +1 -1
- package/dist/{impl-A7XL5O4W.cjs → impl-XYHIS7X5.cjs} +2 -2
- package/dist/{impl-A7XL5O4W.cjs.map → impl-XYHIS7X5.cjs.map} +1 -1
- package/dist/{impl-VL3CJ2OT.cjs → impl-Y3MY5EKD.cjs} +2 -2
- package/dist/{impl-VL3CJ2OT.cjs.map → impl-Y3MY5EKD.cjs.map} +1 -1
- package/dist/impl-YIPC6MAR.cjs +6 -0
- package/dist/impl-YIPC6MAR.cjs.map +1 -0
- package/dist/{impl-JFYHXSOV.cjs → impl-Z54SB7SM.cjs} +2 -2
- package/dist/{impl-JFYHXSOV.cjs.map → impl-Z54SB7SM.cjs.map} +1 -1
- package/dist/{impl-GEEPG7OH.cjs → impl-ZTEP5CYM.cjs} +2 -2
- package/dist/{impl-GEEPG7OH.cjs.map → impl-ZTEP5CYM.cjs.map} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/package.json +2 -2
- package/dist/chunk-52MA7ZLS.cjs +0 -12
- package/dist/chunk-52MA7ZLS.cjs.map +0 -1
- package/dist/chunk-55B57ZAY.cjs +0 -3001
- package/dist/chunk-55B57ZAY.cjs.map +0 -1
- package/dist/chunk-7H4ALAHC.cjs.map +0 -1
- package/dist/chunk-G522ZIHS.cjs +0 -3
- package/dist/chunk-G522ZIHS.cjs.map +0 -1
- package/dist/chunk-HCEZRZHV.cjs +0 -12
- package/dist/chunk-HCEZRZHV.cjs.map +0 -1
- package/dist/chunk-M3Y6JH6I.cjs +0 -2
- package/dist/chunk-M3Y6JH6I.cjs.map +0 -1
- package/dist/chunk-MXT7N555.cjs.map +0 -1
- package/dist/chunk-NC6VWOMN.cjs +0 -2
- package/dist/chunk-NC6VWOMN.cjs.map +0 -1
- package/dist/chunk-Q2RJZGYW.cjs +0 -2
- package/dist/chunk-SKOTYI3A.cjs +0 -4
- package/dist/impl-BQNXMBQ4.cjs +0 -7
- package/dist/impl-CFYRFABZ.cjs +0 -9
- package/dist/impl-CFYRFABZ.cjs.map +0 -1
- package/dist/impl-JSXYZHX4.cjs +0 -2
- package/dist/impl-RI3WQFOE.cjs +0 -6
- package/dist/impl-RI3WQFOE.cjs.map +0 -1
- package/dist/impl-SRI65ZIC.cjs +0 -2
- package/dist/impl-U46BMUFL.cjs +0 -2
- package/dist/impl-U46BMUFL.cjs.map +0 -1
- package/dist/impl-UVQJ7HSK.cjs +0 -6
- package/dist/impl-UVQJ7HSK.cjs.map +0 -1
- package/dist/impl-V3MXFXZF.cjs +0 -2
- package/dist/impl-ZAKPYQ32.cjs +0 -2
- package/dist/impl-ZAKPYQ32.cjs.map +0 -1
- package/dist/impl-ZTYQ3IB5.cjs +0 -2
- package/dist/impl-ZTYQ3IB5.cjs.map +0 -1
package/dist/chunk-HCEZRZHV.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk55B57ZAYcjs = require('./chunk-55B57ZAY.cjs');var _chunkZUNVPK23cjs = require('./chunk-ZUNVPK23.cjs');var _chunkXXFLFF7Qcjs = require('./chunk-XXFLFF7Q.cjs');var _colors = require('colors'); var _colors2 = _interopRequireDefault(_colors);var _bluebird = require('bluebird');var _cliprogress = require('cli-progress'); var _cliprogress2 = _interopRequireDefault(_cliprogress);var _persistedstate = require('@transcend-io/persisted-state');var _iots = require('io-ts'); var G = _interopRequireWildcard(_iots); var I = _interopRequireWildcard(_iots); var n = _interopRequireWildcard(_iots);var _typeutils = require('@transcend-io/type-utils');var ze=["ENOTFOUND","ECONNRESET","ETIMEDOUT","502 Bad Gateway","504 Gateway Time-out","Task timed out after","unknown request error"].map(a=>a.toLowerCase());async function D(a,{maxAttempts:t=3,baseDelayMs:f=250,isRetryable:u=(d,p)=>ze.some(o=>p.toLowerCase().includes(o)),onRetry:c}={}){let d=0;for(;;){d+=1;try{return await a()}catch(p){let o=_nullishCoalesce((p&&(_optionalChain([p, 'access', _2 => _2.response, 'optionalAccess', _3 => _3.body])||p.message)), () => (String(_nullishCoalesce(p, () => ("Unknown error")))));if(!(d<t&&u(p,o)))throw new Error(`Preference query failed after ${d} attempt(s): ${o}`);_optionalChain([c, 'optionalCall', _4 => _4(d,p,o)]);let r=f*2**(d-1),s=Math.floor(Math.random()*f),e=r+s;_chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(`[retry] attempt ${d}/${t-1}; backing off ${e}ms: ${o}`)),await _chunk55B57ZAYcjs.Zf.call(void 0, e)}}}var _privacytypes = require('@transcend-io/privacy-types');var V=I.intersection([I.type({nodes:I.array(_privacytypes.PreferenceQueryResponseItem)}),I.partial({cursor:I.string})]);async function Se(a,{identifiers:t,partitionKey:f,skipLogging:u=!1,concurrency:c=40}){let d=[],p=_chunkXXFLFF7Qcjs.b.call(void 0, t,100),o=new Date().getTime(),i=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic);u||i.start(t.length,0);let r=0;await _bluebird.map.call(void 0, p,async l=>{let y=await D(()=>a.post(`v1/preferences/${f}/query`,{json:{filter:{identifiers:l},limit:l.length}}).json(),{onRetry:(h,C,w)=>{_chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(`[RETRY] group size=${l.length} partition=${f} attempt=${h}: ${w}`))}}),g=_typeutils.decodeCodec.call(void 0, V,y);d.push(...g.nodes),r+=l.length,i.update(r)},{concurrency:c}),i.stop();let e=new Date().getTime()-o;return u||_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Completed download in "${e/1e3}" seconds.`)),d}function J({row:a,columnToPurposeName:t,purposeSlugs:f,preferenceTopics:u}){let c={};return Object.entries(t).forEach(([d,{purpose:p,preference:o,valueMapping:i}])=>{if(!f.includes(p))throw new Error(`Invalid purpose slug: ${p}, expected: ${f.join(", ")}`);let r=a[d];if(o){let s=u.find(e=>e.slug===o&&e.purpose.trackingType===p);if(!s){let e=u.filter(l=>l.purpose.trackingType===p).map(l=>l.slug);throw new Error(`Invalid preference slug: ${o} for purpose: ${p}. Allowed preference slugs for purpose are: ${e.join(",")}`)}switch(c[p]||(c[p]={preferences:[]}),c[p].preferences||(c[p].preferences=[]),s.type){case _privacytypes.PreferenceTopicType.Boolean:{let e=i[r];if(e===void 0&&r!=="")throw new Error(`No preference mapping found for value "${r}" in column "${d}" (purpose=${p}, preference=${o})`);if(e==null)return;if(typeof e!="boolean")throw new Error(`Invalid value for boolean preference: ${o}, expected boolean, got: ${r}`);c[p].preferences.push({topic:o,choice:{booleanValue:e}});break}case _privacytypes.PreferenceTopicType.Select:{let e=i[r];if(e===void 0&&r!=="")throw new Error(`No preference mapping found for value "${r}" in column "${d}" (purpose=${p}, preference=${o})`);if(e==null)return;if(typeof e!="string")throw new Error(`Invalid value for select preference: ${o}, expected string, got: ${r}`);let l=e.trim()||null;if(l&&!s.preferenceOptionValues.map(({slug:y})=>y).includes(l))throw new Error(`Invalid value for select preference: ${o}, expected one of: ${s.preferenceOptionValues.map(({slug:y})=>y).join(", ")}, got: ${r}`);c[p].preferences.push({topic:o,choice:{selectValue:l}});break}case _privacytypes.PreferenceTopicType.MultiSelect:{if(typeof r!="string")throw new Error(`Invalid value for multi select preference: ${o}, expected string, got: ${r}`);let e=_chunk55B57ZAYcjs.pc.call(void 0, r).map(l=>{let y=i[l];if(y===void 0&&r!=="")throw new Error(`No preference mapping found for multi select token "${r}" in column "${d}" (purpose=${p}, preference=${o})`);if(y==null)return null;if(typeof y!="string")throw new Error(`Invalid value for multi select preference: ${o}, expected one of: ${s.preferenceOptionValues.map(({slug:g})=>g).join(", ")}, got: ${l}`);return y}).filter(l=>l!==null).sort((l,y)=>l.localeCompare(y));e.length>0&&c[p].preferences.push({topic:o,choice:{selectValues:e}});break}default:throw new Error(`Unknown preference type: ${s.type}`)}}else{let s=i[r];if(s===void 0&&r!=="")throw new Error(`No preference mapping found for value "${r}" in column "${d}" (purpose=${p}, preference=\u2205)`);if(s===null)return;c[p]?c[p].enabled=s===!0:c[p]={enabled:s===!0}}}),_typeutils.apply.call(void 0, c,(d,p)=>{if(typeof d.enabled!="boolean")throw new Error(`No mapping provided for purpose.enabled=true/false value: ${p}`);return{...d,enabled:d.enabled}})}var _inquirer = require('inquirer'); var _inquirer2 = _interopRequireDefault(_inquirer);var H="[NONE]";async function ke(a,t){let f=_chunkXXFLFF7Qcjs.j.call(void 0, a.map(c=>Object.keys(c)).flat()),u=_chunkXXFLFF7Qcjs.c.call(void 0, f,[...t.identifierColumn?[t.identifierColumn]:[],...Object.keys(t.columnToPurposeName)]);if(!t.timestampColum){let{timestampName:c}=await _inquirer2.default.prompt([{name:"timestampName",message:"Choose the column that will be used as the timestamp of last preference update",type:"list",default:u.find(d=>d.toLowerCase().includes("date"))||u.find(d=>d.toLowerCase().includes("time"))||u[0],choices:[...u,H]}]);t.timestampColum=c}if(_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Using timestamp column "${t.timestampColum}"`)),t.timestampColum!==H){let c=a.map((d,p)=>d[t.timestampColum]?null:[p]).filter(d=>!!d).flat();if(c.length>0)throw new Error(`The timestamp column "${t.timestampColum}" is missing a value for the following rows: ${c.join(`
|
|
2
|
-
`)}`);_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`The timestamp column "${t.timestampColum}" is present for all row`))}return t}async function Ie(a,t){let f=_chunkXXFLFF7Qcjs.j.call(void 0, a.map(o=>Object.keys(o)).flat()),u=_chunkXXFLFF7Qcjs.c.call(void 0, f,[...t.identifierColumn?[t.identifierColumn]:[],...Object.keys(t.columnToPurposeName)]);if(!t.identifierColumn){let{identifierName:o}=await _inquirer2.default.prompt([{name:"identifierName",message:"Choose the column that will be used as the identifier to upload consent preferences by",type:"list",default:u.find(i=>i.toLowerCase().includes("email"))||u[0],choices:u}]);t.identifierColumn=o}_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Using identifier column "${t.identifierColumn}"`));let c=a.map((o,i)=>o[t.identifierColumn]?null:[i]).filter(o=>!!o).flat();if(c.length>0){let o=`The identifier column "${t.identifierColumn}" is missing a value for the following rows: ${c.join(", ")}`;if(_chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(o)),!await _chunk55B57ZAYcjs.Tf.call(void 0, {message:"Would you like to skip rows missing an identifier?"}))throw new Error(o);let r=a.length;a=a.filter(s=>s[t.identifierColumn]),_chunkZUNVPK23cjs.a.info(_colors2.default.yellow(`Skipped ${r-a.length} rows missing an identifier`))}_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`The identifier column "${t.identifierColumn}" is present for all rows`));let d=_chunkXXFLFF7Qcjs.d.call(void 0, a,t.identifierColumn),p=Object.entries(d).filter(([,o])=>o.length>1);if(p.length>0){let o=`The identifier column "${t.identifierColumn}" has duplicate values for the following rows: ${p.slice(0,10).map(([r,s])=>`${r} (${s.length})`).join(`
|
|
3
|
-
`)}`;if(_chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(o)),!await _chunk55B57ZAYcjs.Tf.call(void 0, {message:"Would you like to automatically take the latest update?"}))throw new Error(o);a=Object.entries(d).map(([,r])=>r.sort((e,l)=>new Date(l[t.timestampColum]).getTime()-new Date(e[t.timestampColum]).getTime())[0]).filter(r=>r)}return{currentState:t,preferences:a}}async function xe(a,t,{purposeSlugs:f,preferenceTopics:u,forceTriggerWorkflows:c}){let d=_chunkXXFLFF7Qcjs.j.call(void 0, a.map(i=>Object.keys(i)).flat()),p=_chunkXXFLFF7Qcjs.c.call(void 0, d,[...t.identifierColumn?[t.identifierColumn]:[],...t.timestampColum?[t.timestampColum]:[]]);if(p.length===0){if(c)return t;throw new Error("No other columns to process")}let o=[...f,...u.map(i=>`${i.purpose.trackingType}->${i.slug}`)];return await _bluebird.mapSeries.call(void 0, p,async i=>{let r=_chunkXXFLFF7Qcjs.j.call(void 0, a.map(e=>e[i])),s=t.columnToPurposeName[i];if(s)_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Column "${i}" is associated with purpose "${s.purpose}"`));else{let{purposeName:e}=await _inquirer2.default.prompt([{name:"purposeName",message:`Choose the purpose that column ${i} is associated with`,type:"list",default:o.find(g=>g.startsWith(f[0])),choices:o}]),[l,y]=e.split("->");s={purpose:l,preference:y||null,valueMapping:{}}}await _bluebird.mapSeries.call(void 0, r,async e=>{if(s.valueMapping[e]!==void 0){_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Value "${e}" is associated with purpose value "${s.valueMapping[e]}"`));return}if(s.preference===null){let{purposeValue:l}=await _inquirer2.default.prompt([{name:"purposeValue",message:`Choose the purpose value for value "${e}" associated with purpose "${s.purpose}"`,type:"confirm",default:e!=="false"}]);s.valueMapping[e]=l}if(s.preference!==null){let l=u.find(g=>g.slug===s.preference);if(!l){_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Preference topic "${s.preference}" not found`));return}let y=l.preferenceOptionValues.map(({slug:g})=>g);if(l.type===_privacytypes.PreferenceTopicType.Boolean){let{preferenceValue:g}=await _inquirer2.default.prompt([{name:"preferenceValue",message:`Choose the preference value for "${l.slug}" value "${e}" associated with purpose "${s.purpose}"`,type:"confirm",default:e!=="false"}]);s.valueMapping[e]=g;return}if(l.type===_privacytypes.PreferenceTopicType.Select){let{preferenceValue:g}=await _inquirer2.default.prompt([{name:"preferenceValue",message:`Choose the preference value for "${l.slug}" value "${e}" associated with purpose "${s.purpose}"`,type:"list",choices:y,default:y.find(h=>h===e)}]);s.valueMapping[e]=g;return}if(l.type===_privacytypes.PreferenceTopicType.MultiSelect){let g=_chunk55B57ZAYcjs.pc.call(void 0, e);await _bluebird.mapSeries.call(void 0, g,async h=>{if(s.valueMapping[h]!==void 0)return;let{preferenceValue:C}=await _inquirer2.default.prompt([{name:"preferenceValue",message:`Choose the preference value for "${l.slug}" value "${h}" associated with purpose "${s.purpose}"`,type:"list",choices:y,default:y.find(w=>w===h)}]);s.valueMapping[h]=C});return}throw new Error(`Unknown preference topic type: ${l.type}`)}}),t.columnToPurposeName[i]=s}),t}function Re({currentConsentRecord:a,pendingUpdates:t,preferenceTopics:f}){return Object.entries(t).every(([u,{preferences:c=[],enabled:d}])=>{let p=a.purposes.find(i=>i.purpose===u);return!!p&&p.enabled===d?c.every(({topic:i,choice:r})=>p.preferences&&p.preferences.find(s=>{if(s.topic!==i)return!1;let e=f.find(l=>l.slug===i&&l.purpose.trackingType===u);if(!e)throw new Error(`Could not find preference topic for ${i}`);switch(e.type){case _privacytypes.PreferenceTopicType.Boolean:return s.choice.booleanValue===r.booleanValue;case _privacytypes.PreferenceTopicType.Select:return s.choice.selectValue===r.selectValue;case _privacytypes.PreferenceTopicType.MultiSelect:let l=(s.choice.selectValues||[]).sort(),y=(r.selectValues||[]).sort();return l.length===y.length&&l.every((g,h)=>g===y[h]);default:throw new Error(`Unknown preference topic type: ${e.type}`)}})):!1})}function Fe({currentConsentRecord:a,pendingUpdates:t,preferenceTopics:f,log:u}){return!!Object.entries(t).find(([c,{preferences:d=[],enabled:p}])=>{let o=a.purposes.find(i=>i.purpose===c);return o?o.enabled!==p?(u&&_chunkZUNVPK23cjs.a.warn(`Purpose ${c} enabled value conflict for user ${a.userId}. Pending Value: ${p}, Current Value: ${o.enabled}`),!0):!!d.find(({topic:i,choice:r})=>{let s=(o.preferences||[]).find(g=>g.topic===i);if(!s)return u&&_chunkZUNVPK23cjs.a.warn(`No existing preference found for topic ${i} in purpose ${c} for user ${a.userId}.`),!1;let e=f.find(g=>g.slug===i&&g.purpose.trackingType===c);if(!e)throw new Error(`Could not find preference topic for ${i}`);let l,y;switch(e.type){case _privacytypes.PreferenceTopicType.Boolean:return l=s.choice.booleanValue!==r.booleanValue,u&&_chunkZUNVPK23cjs.a.warn(`Preference topic ${i} boolean value conflict for user ${a.userId}. Expected: ${r.booleanValue}, Found: ${s.choice.booleanValue}`),l;case _privacytypes.PreferenceTopicType.Select:return y=s.choice.selectValue!==r.selectValue,u&&_chunkZUNVPK23cjs.a.warn(`Preference topic ${i} select value conflict for user ${a.userId}. Expected: ${r.selectValue}, Found: ${s.choice.selectValue}`),y;case _privacytypes.PreferenceTopicType.MultiSelect:let g=(s.choice.selectValues||[]).sort(),h=(r.selectValues||[]).sort();return y=g.length!==h.length||!g.every((C,w)=>C===h[w]),u&&_chunkZUNVPK23cjs.a.warn(`Preference topic ${i} multi-select value conflict for user ${a.userId}. Expected: ${h.join(", ")}, Found: ${g.join(", ")}`),y;default:throw new Error(`Unknown preference topic type: ${e.type}`)}}):(u&&_chunkZUNVPK23cjs.a.warn(`No existing purpose found for ${c} in consent record for ${a.userId}.`),!1)})}async function ve({file:a,sombra:t,purposeSlugs:f,preferenceTopics:u,partitionKey:c,skipExistingRecordCheck:d,forceTriggerWorkflows:p},o){let i=new Date().getTime(),r=o.getValue("fileMetadata");_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Reading in file: "${a}"`));let s=_chunk55B57ZAYcjs.sc.call(void 0, a,G.record(G.string,G.string)),e={columnToPurposeName:{},pendingSafeUpdates:{},pendingConflictUpdates:{},skippedUpdates:{},...r[a]||{},lastFetchedAt:new Date().toISOString()};e=await ke(s,e),r[a]=e,await o.setValue(r,"fileMetadata");let l=await Ie(s,e);e=l.currentState,s=l.preferences,r[a]=e,await o.setValue(r,"fileMetadata"),e=await xe(s,e,{preferenceTopics:u,purposeSlugs:f,forceTriggerWorkflows:p}),r[a]=e,await o.setValue(r,"fileMetadata");let y=s.map(w=>w[e.identifierColumn]),g=d?[]:await Se(t,{identifiers:y.map(w=>({value:w})),partitionKey:c}),h=_chunkXXFLFF7Qcjs.e.call(void 0, g,"userId");e.pendingConflictUpdates={},e.pendingSafeUpdates={},e.skippedUpdates={},s.forEach(w=>{let P=w[e.identifierColumn],b=J({row:w,columnToPurposeName:e.columnToPurposeName,preferenceTopics:u,purposeSlugs:f}),S=h[P];if(p&&!S)throw new Error(`No existing consent record found for user with id: ${P}.
|
|
4
|
-
When 'forceTriggerWorkflows' is set all the user identifiers should contain a consent record`);if(S&&Re({currentConsentRecord:S,pendingUpdates:b,preferenceTopics:u})&&!p){e.skippedUpdates[P]=w;return}if(S&&Fe({currentConsentRecord:S,pendingUpdates:b,preferenceTopics:u})){e.pendingConflictUpdates[P]={row:w,record:S};return}e.pendingSafeUpdates[P]=w}),r[a]=e,await o.setValue(r,"fileMetadata");let C=new Date().getTime();_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully pre-processed file: "${a}" in ${(C-i)/1e3}s`))}var De=n.type({purpose:n.string,preference:n.union([n.string,n.null]),valueMapping:n.record(n.string,n.union([n.string,n.boolean,n.null,n.undefined]))}),Pr=n.record(n.string,De),et=n.type({name:n.string,isUniqueOnPreferenceStore:n.boolean}),$r=n.record(n.string,et),tt=n.intersection([n.type({columnToPurposeName:n.record(n.string,De),lastFetchedAt:n.string,pendingSafeUpdates:n.record(n.string,n.record(n.string,n.string)),pendingConflictUpdates:n.record(n.string,n.type({record:_privacytypes.PreferenceQueryResponseItem,row:n.record(n.string,n.string)})),skippedUpdates:n.record(n.string,n.record(n.string,n.string))}),n.partial({identifierColumn:n.string,timestampColum:n.string})]),br=n.record(n.string,n.union([n.boolean,_privacytypes.PreferenceUpdateItem])),Cr=n.record(n.string,n.union([n.boolean,n.record(n.string,n.string)])),Tr=n.record(n.string,n.type({uploadedAt:n.string,error:n.string,update:_privacytypes.PreferenceUpdateItem})),Sr=n.record(n.string,n.type({record:_privacytypes.PreferenceQueryResponseItem,row:n.record(n.string,n.string)})),Mr=n.record(n.string,n.record(n.string,n.string)),Ve=n.type({fileMetadata:n.record(n.string,tt),failingUpdates:n.record(n.string,n.type({uploadedAt:n.string,error:n.string,update:_privacytypes.PreferenceUpdateItem})),pendingUpdates:n.record(n.string,_privacytypes.PreferenceUpdateItem)});async function Gr({auth:a,sombraAuth:t,receiptFilepath:f,file:u,partition:c,isSilent:d=!0,dryRun:p=!1,skipWorkflowTriggers:o=!1,skipConflictUpdates:i=!1,skipExistingRecordCheck:r=!1,attributes:s=[],transcendUrl:e,forceTriggerWorkflows:l=!1}){let y=_chunk55B57ZAYcjs.rc.call(void 0, s),g=new (0, _persistedstate.PersistedState)(f,Ve,{fileMetadata:{},failingUpdates:{},pendingUpdates:{}}),h=g.getValue("failingUpdates"),C=g.getValue("pendingUpdates"),w=g.getValue("fileMetadata");_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Restored cache, there are:
|
|
5
|
-
${Object.values(h).length} failing requests to be retried
|
|
6
|
-
${Object.values(C).length} pending requests to be processed
|
|
7
|
-
The following files are stored in cache and will be used:
|
|
8
|
-
${Object.keys(w).map(M=>M).join(`
|
|
9
|
-
`)}
|
|
10
|
-
The following file will be processed: ${u}
|
|
11
|
-
`));let P=_chunk55B57ZAYcjs.xc.call(void 0, e,a),[b,S,fe]=await Promise.all([_chunk55B57ZAYcjs.yc.call(void 0, e,a,t),l?Promise.resolve([]):_chunk55B57ZAYcjs.gd.call(void 0, P),l?Promise.resolve([]):_chunk55B57ZAYcjs.cd.call(void 0, P)]);await ve({file:u,purposeSlugs:S.map(M=>M.trackingType),preferenceTopics:fe,sombra:b,partitionKey:c,skipExistingRecordCheck:r,forceTriggerWorkflows:l},g);let Q={};w=g.getValue("fileMetadata");let F=w[u];if(_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Found ${Object.entries(F.pendingSafeUpdates).length} safe updates in ${u}`)),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Found ${Object.entries(F.pendingConflictUpdates).length} conflict updates in ${u}`)),_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Found ${Object.entries(F.skippedUpdates).length} skipped updates in ${u}`)),Object.entries({...F.pendingSafeUpdates,...i?{}:_typeutils.apply.call(void 0, F.pendingConflictUpdates,({row:M})=>M)}).forEach(([M,k])=>{let _=F.timestampColum===H?new Date:new Date(k[F.timestampColum]),O=J({row:k,columnToPurposeName:F.columnToPurposeName,preferenceTopics:fe,purposeSlugs:S.map(N=>N.trackingType)});Q[M]={userId:M,partition:c,timestamp:_.toISOString(),purposes:Object.entries(O).map(([N,_e])=>({..._e,purpose:N,workflowSettings:{attributes:y,isSilent:d,skipWorkflowTrigger:o}}))}}),await g.setValue(Q,"pendingUpdates"),await g.setValue({},"failingUpdates"),p){_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Dry run complete, exiting. ${Object.values(Q).length} pending updates. Check file: ${f}`));return}_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Uploading ${Object.values(Q).length} preferences to partition: ${c}`));let Ge=new Date().getTime(),ee=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),me=0,te=Object.entries(Q),qe=_chunkXXFLFF7Qcjs.b.call(void 0, te,o?100:10);ee.start(te.length,0),await _bluebird.map.call(void 0, qe,async M=>{try{await b.put("v1/preferences",{json:{records:M.map(([,k])=>k),skipWorkflowTriggers:o,forceTriggerWorkflows:l}}).json()}catch(k){try{let O=JSON.parse(_optionalChain([k, 'optionalAccess', _5 => _5.response, 'optionalAccess', _6 => _6.body])||"{}");O.error&&_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Error: ${O.error}`))}catch (e2){}_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Failed to upload ${M.length} user preferences to partition ${c}: ${_optionalChain([k, 'optionalAccess', _7 => _7.response, 'optionalAccess', _8 => _8.body])||_optionalChain([k, 'optionalAccess', _9 => _9.message])}`));let _=g.getValue("failingUpdates");M.forEach(([O,N])=>{_[O]={uploadedAt:new Date().toISOString(),update:N,error:_optionalChain([k, 'optionalAccess', _10 => _10.response, 'optionalAccess', _11 => _11.body])||_optionalChain([k, 'optionalAccess', _12 => _12.message])||"Unknown error"}}),await g.setValue(_,"failingUpdates")}me+=M.length,ee.update(me)},{concurrency:40}),ee.stop();let Le=new Date().getTime()-Ge;_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully uploaded ${te.length} user preferences to partition ${c} in "${Le/1e3}" seconds!`))}function Lr({identifiers:a=[],purposes:t=[],metadata:f=[],consentManagement:u={},system:c={decryptionStatus:"DECRYPTED"},...d}){let p={...d,...c,...u};if(Array.isArray(a)){let o=new Map;for(let{name:i,value:r}of a)o.has(i)||o.set(i,new Set),r&&o.get(i).add(r);for(let[i,r]of o.entries())p[i]=Array.from(r).join(",")}if(Array.isArray(f)&&(p.metadata=JSON.stringify(f.reduce((o,{key:i,value:r})=>(o[i]=r,o),{}))),Array.isArray(t)){for(let{purpose:o,preferences:i,enabled:r}of t)if(p[o]=!!r,Array.isArray(i))for(let{topic:s,choice:e}of i){let l=`${o}_${s}`,y=null;typeof e.booleanValue=="boolean"?y=e.booleanValue:e.selectValue?y=e.selectValue:Array.isArray(e.selectValues)?y=e.selectValues.filter(h=>h.length>0).join(","):y=null,p[l]=y}}return p}async function*X(a,t,f,u){let c;for(;;){let d={limit:u};f&&Object.keys(f).length&&(d.filter=f),c&&(d.cursor=c);let p=await D(()=>a.post(`v1/preferences/${t}/query`,{json:d}).json(),{onRetry:(r,s,e)=>{_chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(`Retry attempt ${r} for fetchConsentPreferences due to error: ${e}`))}}),{nodes:o,cursor:i}=_typeutils.decodeCodec.call(void 0, V,p);if(!_optionalChain([o, 'optionalAccess', _13 => _13.length])||(yield o,!i))break;c=i}}function Z(a){return!!a.timestampAfter||!!a.timestampBefore?"timestamp":"updated"}function E(a,t){return a==="timestamp"?new Date(t.timestamp):_optionalChain([t, 'access', _14 => _14.system, 'optionalAccess', _15 => _15.updatedAt])?new Date(t.system.updatedAt):new Date}function Ae(a,t){if(a==="timestamp")return{after:t.timestampAfter?new Date(t.timestampAfter):void 0,before:t.timestampBefore?new Date(t.timestampBefore):void 0};let f=_nullishCoalesce(t.system, () => ({}));return{after:f.updatedAfter?new Date(f.updatedAfter):void 0,before:f.updatedBefore?new Date(f.updatedBefore):void 0}}function q(a,t,f){return a==="timestamp"?{...t,timestampBefore:_nullishCoalesce(f, () => (t.timestampBefore))}:{...t,system:{...t.system||{},...f?{updatedBefore:f}:{}},timestampAfter:void 0,timestampBefore:void 0}}async function L(a,t,f){_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Single-record probe with filter: ${JSON.stringify(f)}`));let c=await X(a,t,f,1).next();if(c.done||!c.value||c.value.length===0)return _chunkZUNVPK23cjs.a.info(_colors2.default.yellow("Probe result: no record")),null;let d=c.value[0];return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Probe result: found record at ${E(Z(f),d).toISOString()}`)),d}async function Qe(a,t){let{partition:f,mode:u,baseFilter:c,maxLookbackDays:d=3650}=t,p=await L(a,f,q(u,c));if(!p)return _chunkZUNVPK23cjs.a.info(_colors2.default.yellow("No records found; defaulting earliest day to today.")),_chunk55B57ZAYcjs.jg.call(void 0, new Date);let o=E(u,p);_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Newest instant: ${o.toISOString()}`));let i=[1,7,30],r=0,s=i[0]*864e5,e=o,l=null;for(;;){let w=r<i.length?new Date(o.getTime()-i[r]*864e5):new Date(o.getTime()-s);if((_chunk55B57ZAYcjs.jg.call(void 0, new Date).getTime()-_chunk55B57ZAYcjs.jg.call(void 0, w).getTime())/864e5>d){_chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(`Exponential jump exceeded maxLookbackDays=${d}. Using current bounds.`)),l=w;break}_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Probing before=${w.toISOString()} (jump step ${r<i.length?`${i[r]}d`:`${Math.round(s/864e5)}d`})\u2026`));let b=await L(a,f,q(u,c,w.toISOString()));if(b){e=E(u,b),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Found older record at ${e.toISOString()} \u2014 continue jumping back.`)),r<i.length-1?(r+=1,s=i[r]*864e5):r===i.length-1?(r+=1,s=i[i.length-1]*2*864e5):s*=2;continue}l=w,_chunkZUNVPK23cjs.a.info(_colors2.default.green(`No record before ${w.toISOString()} \u2014 established empty lower bound.`));break}l||(l=new Date(e.getTime()-864e5));let y=l,g=e,h=Math.max(864e5,Math.floor((g.getTime()-y.getTime())/64));_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Exponential forward-from-empty start: empty=${y.toISOString()} found=${g.toISOString()} step=${Math.round(h/864e5)}d`));for(let w=0;w<8;w+=1){let P=new Date(y.getTime()+h);if(P.getTime()>=g.getTime())break;_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Forward gallop probe before=${P.toISOString()}\u2026`));let b=await L(a,f,q(u,c,P.toISOString()));if(b?(g=E(u,b),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Gallop hit at ${g.toISOString()} \u2014 tightening found bound. Next step halves.`)),h=Math.max(864e5,Math.floor(h/2))):(y.setTime(P.getTime()),_chunkZUNVPK23cjs.a.info(_colors2.default.yellow(`Gallop miss \u2014 advancing empty bound to ${y.toISOString()}. Next step doubles.`)),h=Math.min(g.getTime()-y.getTime(),h*2),h<864e5&&(h=864e5)),g.getTime()-y.getTime()<=864e5)break}for(;g.getTime()-y.getTime()>864e5;){let w=new Date(y.getTime()+Math.floor((g.getTime()-y.getTime())/2));_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Binary probe before=${w.toISOString()}\u2026`));let P=await L(a,f,q(u,c,w.toISOString()));if(P){let b=E(u,P);_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Binary probe found record at ${b.toISOString()}.`)),g=b}else _chunkZUNVPK23cjs.a.info(_colors2.default.yellow("Binary probe found no record.")),y=w}let C=_chunk55B57ZAYcjs.jg.call(void 0, g);return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Earliest day (UTC) resolved to ${C.toISOString()} (instant \u2248 ${g.toISOString()}).`)),C}async function Ne(a,t){let{partition:f,mode:u,baseFilter:c}=t;_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Latest-day discovery: probing newest record\u2026"));let d=await L(a,f,q(u,c));if(!d)return _chunkZUNVPK23cjs.a.info(_colors2.default.yellow("No records found at all; defaulting latest day to today.")),_chunk55B57ZAYcjs.jg.call(void 0, new Date);let p=E(u,d);_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Newest record instant is ${p.toISOString()}.`));let o=_chunk55B57ZAYcjs.jg.call(void 0, p);return _chunkZUNVPK23cjs.a.info(_colors2.default.green(`Latest day (UTC) resolved to ${o.toISOString()} from instant ${p.toISOString()}.`)),o}function je(a,t,f,u=5e3){let c=Math.max(0,f.getTime()-t.getTime());if(c===0)return[];let d=new Date(Math.floor(t.getTime()/3e5)*3e5),p=Math.ceil(c/Math.max(1,u)),o=Math.max(3e5,p),i=Math.ceil((f.getTime()-d.getTime())/o),r=[];for(let s=0;s<i;s+=1){let e=d.getTime()+s*o,y=Math.min(f.getTime(),e+o)-1,g=Math.max(e,y),h=new Date(e).toISOString(),C=new Date(g).toISOString();a==="timestamp"?r.push({timestampAfter:h,timestampBefore:C}):r.push({system:{updatedAfter:h,updatedBefore:C}})}return r}function pt(a,t,f){return a==="timestamp"?{...t,timestampAfter:_nullishCoalesce(f.timestampAfter, () => (t.timestampAfter)),timestampBefore:_nullishCoalesce(f.timestampBefore, () => (t.timestampBefore)),system:void 0}:{...t,system:{...t.system||{},..._optionalChain([f, 'access', _16 => _16.system, 'optionalAccess', _17 => _17.updatedAfter])?{updatedAfter:f.system.updatedAfter}:{},..._optionalChain([f, 'access', _18 => _18.system, 'optionalAccess', _19 => _19.updatedBefore])?{updatedBefore:f.system.updatedBefore}:{}},timestampAfter:void 0,timestampBefore:void 0}}async function $o(a,{partition:t,filterBy:f={},limit:u=50,windowConcurrency:c=25,maxChunks:d=5e3,maxLookbackDays:p=3650,onItems:o}){let i=Z(f);_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Fetching consent preferences in chunks by ${i==="timestamp"?"timestamp":"system.updatedAt"}...`));let{after:r,before:s}=Ae(i,f);if(_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Initial bounds: after=${_nullishCoalesce(_optionalChain([r, 'optionalAccess', _20 => _20.toISOString, 'call', _21 => _21()]), () => ("undefined"))} before=${_nullishCoalesce(_optionalChain([s, 'optionalAccess', _22 => _22.toISOString, 'call', _23 => _23()]), () => ("undefined"))}`)),(!r||!s)&&(r||(_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Discovering earliest day with data for partition ${t}...`)),r=await Qe(a,{partition:t,mode:i,baseFilter:f,maxLookbackDays:p}),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Discovered earliest day with data: ${r.toISOString()}`))),!s)){_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Discovering latest day with data for partition ${t}...`));let P=await Ne(a,{partition:t,mode:i,baseFilter:f,earliest:r});s=_chunk55B57ZAYcjs.mg.call(void 0, P,1),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Discovered latest day with data: ${P.toISOString()}`))}_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Final bounds (UTC): after=${r.toISOString()} before=${s.toISOString()}`));let e=je(i,r,s,d);_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Fetching consent preferences from partition ${t} in ${e.length} chunks...`));let l=new _cliprogress2.default.SingleBar({format:"Downloading [{bar}] {percentage}% | chunks {value}/{total} | fetched {fetched}"},_cliprogress2.default.Presets.shades_classic),y=0,g=0;l.start(e.length,0,{fetched:g});let h=Date.now(),C=_chunk55B57ZAYcjs.ig.call(void 0, u),w=[];return await _bluebird.map.call(void 0, e.map((P,b)=>({windowFilter:P,idx:b})),async({windowFilter:P})=>{let b=pt(i,f,P);for await(let S of X(a,t,b,C))g+=S.length,l.update(y,{fetched:g}),o?await o(S):w.push(...S);y+=1,l.update(y,{fetched:g})},{concurrency:Math.max(1,c)}),l.update(y,{fetched:g}),l.stop(),_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Fetched ${g} consent preference records from partition ${t} in ${(Date.now()-h)/1e3}s.`)),o?[]:w}async function xo(a,{partition:t,filterBy:f={},limit:u=50,onItems:c}){let d=[],p,o=f&&(Object.keys(f).length>0||f.system&&Object.keys(f.system).length>0),i=Math.max(1,Math.min(50,_nullishCoalesce(u, () => (50))));for(;;){let r={limit:i};o&&(r.filter=f),p&&(r.cursor=p);let s=await D(()=>a.post(`v1/preferences/${t}/query`,{json:r}).json(),{onRetry:(y,g,h)=>{_chunkZUNVPK23cjs.a.warn(_colors2.default.yellow(`Retry attempt ${y} for fetchConsentPreferences due to error: ${h}`))}}),{nodes:e,cursor:l}=_typeutils.decodeCodec.call(void 0, V,s);if(!e||e.length===0||(c?await c(e):d.push(...e),!l))break;p=l}return c?[]:d}exports.a = Gr; exports.b = Lr; exports.c = $o; exports.d = xo;
|
|
12
|
-
//# sourceMappingURL=chunk-HCEZRZHV.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/cli/cli/dist/chunk-HCEZRZHV.cjs","../src/lib/preference-management/uploadPreferenceManagementPreferencesInteractive.ts","../src/lib/preference-management/parsePreferenceManagementCsv.ts","../src/lib/preference-management/getPreferencesForIdentifiers.ts","../src/lib/preference-management/withPreferenceQueryRetry.ts","../src/lib/preference-management/parsePreferenceIdentifiersFromCsv.ts","../src/lib/preference-management/parsePreferenceAndPurposeValuesFromCsv.ts","../src/lib/preference-management/codecs.ts"],"names":["RETRY_PREFERENCE_MSGS","s","withPreferenceQueryRetry","fn","maxAttempts","baseDelayMs","isRetryable","_err","msg","m","onRetry","attempt","err"],"mappings":"AAAA,2lCAA2J,wDAAyC,wDAAuE,gFCQxP,oCACC,qGAGI,+DAEO,qJCXZ,qDCES,ICGfA,EAAAA,CAAkC,CAC7C,WAAA,CACA,YAAA,CACA,WAAA,CACA,iBAAA,CACA,sBAAA,CACA,sBAAA,CACA,uBACF,CAAA,CAAE,GAAA,CAAKC,CAAAA,EAAMA,CAAAA,CAAE,WAAA,CAAY,CAAC,CAAA,CAwB5B,MAAA,SAAsBC,CAAAA,CACpBC,CAAAA,CACA,CACE,WAAA,CAAAC,CAAAA,CAAc,CAAA,CACd,WAAA,CAAAC,CAAAA,CAAc,GAAA,CACd,WAAA,CAAAC,CAAAA,CAAc,CAACC,CAAAA,CAAMC,CAAAA,CAAAA,EACnBR,EAAAA,CAAsB,IAAA,CAAMS,CAAAA,EAAMD,CAAAA,CAAI,WAAA,CAAY,CAAA,CAAE,QAAA,CAASC,CAAC,CAAC,CAAA,CACjE,OAAA,CAAAC,CACF,CAAA,CAAkB,CAAC,CAAA,CACP,CACZ,IAAIC,CAAAA,CAAU,CAAA,CAEd,GAAA,CAAA,CAAA,CAAA,CAAa,CACXA,CAAAA,EAAW,CAAA,CACX,GAAI,CACF,OAAO,MAAMR,CAAAA,CAAG,CAElB,CAAA,KAAA,CAASS,CAAAA,CAAU,CACjB,IAAMJ,CAAAA,kBAAAA,CACHI,CAAAA,EAAAA,iBAAQA,CAAAA,qBAAI,QAAA,6BAAU,MAAA,EAAQA,CAAAA,CAAI,OAAA,CAAA,CAAA,SACnC,MAAA,kBAAOA,CAAAA,SAAO,iBAAe,GAAA,CAE/B,EAAA,CAAI,CAAA,CADcD,CAAAA,CAAUP,CAAAA,EAAeE,CAAAA,CAAYM,CAAAA,CAAKJ,CAAG,CAAA,CAAA,CAE7D,MAAM,IAAI,KAAA,CACR,CAAA,8BAAA,EAAiCG,CAAO,CAAA,aAAA,EAAgBH,CAAG,CAAA,CAAA;ACiC/D;ACnBU;ACyBD,oGAAA;ANbP;AAGA;AAAA;AAKQ;AAAK;AACgC,sCAAA;AA+FY","file":"/home/runner/work/cli/cli/dist/chunk-HCEZRZHV.cjs","sourcesContent":[null,"import {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllPurposes,\n fetchAllPreferenceTopics,\n PreferenceTopic,\n Purpose,\n} from '../graphql';\nimport colors from 'colors';\nimport { map } from 'bluebird';\nimport { chunk } from 'lodash-es';\nimport { logger } from '../../logger';\nimport cliProgress from 'cli-progress';\nimport { parseAttributesFromString } from '../requests';\nimport { PersistedState } from '@transcend-io/persisted-state';\nimport { parsePreferenceManagementCsvWithCache } from './parsePreferenceManagementCsv';\nimport { PreferenceState } from './codecs';\nimport { PreferenceUpdateItem } from '@transcend-io/privacy-types';\nimport { apply } from '@transcend-io/type-utils';\nimport { NONE_PREFERENCE_MAP } from './parsePreferenceTimestampsFromCsv';\nimport { getPreferenceUpdatesFromRow } from './getPreferenceUpdatesFromRow';\n\n/**\n * Upload a set of consent preferences\n *\n * @param options - Options\n */\nexport async function uploadPreferenceManagementPreferencesInteractive({\n auth,\n sombraAuth,\n receiptFilepath,\n file,\n partition,\n isSilent = true,\n dryRun = false,\n skipWorkflowTriggers = false,\n skipConflictUpdates = false,\n skipExistingRecordCheck = false,\n attributes = [],\n transcendUrl,\n forceTriggerWorkflows = false,\n}: {\n /** The Transcend API key */\n auth: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Partition key */\n partition: string;\n /** File where to store receipt and continue from where left off */\n receiptFilepath: string;\n /** The file to process */\n file: string;\n /** API URL for Transcend backend */\n transcendUrl: string;\n /** Whether to do a dry run */\n dryRun?: boolean;\n /** Whether to upload as isSilent */\n isSilent?: boolean;\n /** Attributes string pre-parse. In format Key:Value */\n attributes?: string[];\n /** Skip workflow triggers */\n skipWorkflowTriggers?: boolean;\n /**\n * When true, only update preferences that do not conflict with existing\n * preferences. When false, update all preferences in CSV based on timestamp.\n */\n skipConflictUpdates?: boolean;\n /** Whether to skip the check for existing records. SHOULD ONLY BE USED FOR INITIAL UPLOAD */\n skipExistingRecordCheck?: boolean;\n /** Whether to force trigger workflows */\n forceTriggerWorkflows?: boolean;\n}): Promise<void> {\n // Parse out the extra attributes to apply to all requests uploaded\n const parsedAttributes = parseAttributesFromString(attributes);\n\n // Create a new state file to store the requests from this run\n const preferenceState = new PersistedState(receiptFilepath, PreferenceState, {\n fileMetadata: {},\n failingUpdates: {},\n pendingUpdates: {},\n });\n const failingRequests = preferenceState.getValue('failingUpdates');\n const pendingRequests = preferenceState.getValue('pendingUpdates');\n let fileMetadata = preferenceState.getValue('fileMetadata');\n\n logger.info(\n colors.magenta(\n 'Restored cache, there are: \\n' +\n `${\n Object.values(failingRequests).length\n } failing requests to be retried\\n` +\n `${\n Object.values(pendingRequests).length\n } pending requests to be processed\\n` +\n `The following files are stored in cache and will be used:\\n${Object.keys(\n fileMetadata,\n )\n .map((x) => x)\n .join('\\n')}\\n` +\n `The following file will be processed: ${file}\\n`,\n ),\n );\n\n // Create GraphQL client to connect to Transcend backend\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n const [sombra, purposes, preferenceTopics] = await Promise.all([\n // Create sombra instance to communicate with\n createSombraGotInstance(transcendUrl, auth, sombraAuth),\n // get all purposes and topics\n forceTriggerWorkflows\n ? Promise.resolve([] as Purpose[])\n : fetchAllPurposes(client),\n forceTriggerWorkflows\n ? Promise.resolve([] as PreferenceTopic[])\n : fetchAllPreferenceTopics(client),\n ]);\n\n // Process the file\n await parsePreferenceManagementCsvWithCache(\n {\n file,\n purposeSlugs: purposes.map((x) => x.trackingType),\n preferenceTopics,\n sombra,\n partitionKey: partition,\n skipExistingRecordCheck,\n forceTriggerWorkflows,\n },\n preferenceState,\n );\n\n // Construct the pending updates\n const pendingUpdates: Record<string, PreferenceUpdateItem> = {};\n fileMetadata = preferenceState.getValue('fileMetadata');\n const metadata = fileMetadata[file];\n\n logger.info(\n colors.magenta(\n `Found ${\n Object.entries(metadata.pendingSafeUpdates).length\n } safe updates in ${file}`,\n ),\n );\n logger.info(\n colors.magenta(\n `Found ${\n Object.entries(metadata.pendingConflictUpdates).length\n } conflict updates in ${file}`,\n ),\n );\n logger.info(\n colors.magenta(\n `Found ${\n Object.entries(metadata.skippedUpdates).length\n } skipped updates in ${file}`,\n ),\n );\n\n // Update either safe updates only or safe + conflict\n Object.entries({\n ...metadata.pendingSafeUpdates,\n ...(skipConflictUpdates\n ? {}\n : apply(metadata.pendingConflictUpdates, ({ row }) => row)),\n }).forEach(([userId, update]) => {\n // Determine timestamp\n const timestamp =\n metadata.timestampColum === NONE_PREFERENCE_MAP\n ? new Date()\n : new Date(update[metadata.timestampColum!]);\n\n // Determine updates\n const updates = getPreferenceUpdatesFromRow({\n row: update,\n columnToPurposeName: metadata.columnToPurposeName,\n preferenceTopics,\n purposeSlugs: purposes.map((x) => x.trackingType),\n });\n pendingUpdates[userId] = {\n userId,\n partition,\n timestamp: timestamp.toISOString(),\n purposes: Object.entries(updates).map(([purpose, value]) => ({\n ...value,\n purpose,\n workflowSettings: {\n attributes: parsedAttributes,\n isSilent,\n skipWorkflowTrigger: skipWorkflowTriggers,\n },\n })),\n };\n });\n await preferenceState.setValue(pendingUpdates, 'pendingUpdates');\n await preferenceState.setValue({}, 'failingUpdates');\n\n // Exist early if dry run\n if (dryRun) {\n logger.info(\n colors.green(\n `Dry run complete, exiting. ${\n Object.values(pendingUpdates).length\n } pending updates. Check file: ${receiptFilepath}`,\n ),\n );\n return;\n }\n\n logger.info(\n colors.magenta(\n `Uploading ${\n Object.values(pendingUpdates).length\n } preferences to partition: ${partition}`,\n ),\n );\n\n // Time duration\n const t0 = new Date().getTime();\n\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar(\n {},\n cliProgress.Presets.shades_classic,\n );\n\n // Build a GraphQL client\n let total = 0;\n const updatesToRun = Object.entries(pendingUpdates);\n const chunkedUpdates = chunk(updatesToRun, skipWorkflowTriggers ? 100 : 10);\n progressBar.start(updatesToRun.length, 0);\n await map(\n chunkedUpdates,\n async (currentChunk) => {\n // Make the request\n try {\n await sombra\n .put('v1/preferences', {\n json: {\n records: currentChunk.map(([, update]) => update),\n skipWorkflowTriggers,\n forceTriggerWorkflows,\n },\n })\n .json();\n } catch (err) {\n try {\n const parsed = JSON.parse(err?.response?.body || '{}');\n if (parsed.error) {\n logger.error(colors.red(`Error: ${parsed.error}`));\n }\n } catch (e) {\n // continue\n }\n logger.error(\n colors.red(\n `Failed to upload ${\n currentChunk.length\n } user preferences to partition ${partition}: ${\n err?.response?.body || err?.message\n }`,\n ),\n );\n const failingUpdates = preferenceState.getValue('failingUpdates');\n currentChunk.forEach(([userId, update]) => {\n failingUpdates[userId] = {\n uploadedAt: new Date().toISOString(),\n update,\n error: err?.response?.body || err?.message || 'Unknown error',\n };\n });\n await preferenceState.setValue(failingUpdates, 'failingUpdates');\n }\n\n total += currentChunk.length;\n progressBar.update(total);\n },\n {\n concurrency: 40,\n },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n logger.info(\n colors.green(\n `Successfully uploaded ${\n updatesToRun.length\n } user preferences to partition ${partition} in \"${\n totalTime / 1000\n }\" seconds!`,\n ),\n );\n}\n","import { PersistedState } from '@transcend-io/persisted-state';\nimport type { Got } from 'got';\nimport { keyBy } from 'lodash-es';\nimport * as t from 'io-ts';\nimport colors from 'colors';\nimport { FileMetadataState, PreferenceState } from './codecs';\nimport { logger } from '../../logger';\nimport { readCsv } from '../requests';\nimport { getPreferencesForIdentifiers } from './getPreferencesForIdentifiers';\nimport { PreferenceTopic } from '../graphql';\nimport { getPreferenceUpdatesFromRow } from './getPreferenceUpdatesFromRow';\nimport { parsePreferenceTimestampsFromCsv } from './parsePreferenceTimestampsFromCsv';\nimport { parsePreferenceIdentifiersFromCsv } from './parsePreferenceIdentifiersFromCsv';\nimport { parsePreferenceAndPurposeValuesFromCsv } from './parsePreferenceAndPurposeValuesFromCsv';\nimport { checkIfPendingPreferenceUpdatesAreNoOp } from './checkIfPendingPreferenceUpdatesAreNoOp';\nimport { checkIfPendingPreferenceUpdatesCauseConflict } from './checkIfPendingPreferenceUpdatesCauseConflict';\n\n/**\n * Parse a file into the cache\n *\n *\n * @param options - Options\n * @param cache - The cache to store the parsed file in\n * @returns The cache with the parsed file\n */\nexport async function parsePreferenceManagementCsvWithCache(\n {\n file,\n sombra,\n purposeSlugs,\n preferenceTopics,\n partitionKey,\n skipExistingRecordCheck,\n forceTriggerWorkflows,\n }: {\n /** File to parse */\n file: string;\n /** The purpose slugs that are allowed to be updated */\n purposeSlugs: string[];\n /** The preference topics */\n preferenceTopics: PreferenceTopic[];\n /** Sombra got instance */\n sombra: Got;\n /** Partition key */\n partitionKey: string;\n /** Whether to skip the check for existing records. SHOULD ONLY BE USED FOR INITIAL UPLOAD */\n skipExistingRecordCheck: boolean;\n /** Wheather to force workflow triggers */\n forceTriggerWorkflows: boolean;\n },\n cache: PersistedState<typeof PreferenceState>,\n): Promise<void> {\n // Start the timer\n const t0 = new Date().getTime();\n\n // Get the current metadata\n const fileMetadata = cache.getValue('fileMetadata');\n\n // Read in the file\n logger.info(colors.magenta(`Reading in file: \"${file}\"`));\n let preferences = readCsv(file, t.record(t.string, t.string));\n\n // start building the cache, can use previous cache as well\n let currentState: FileMetadataState = {\n columnToPurposeName: {},\n pendingSafeUpdates: {},\n pendingConflictUpdates: {},\n skippedUpdates: {},\n // Load in the last fetched time\n ...((fileMetadata[file] || {}) as Partial<FileMetadataState>),\n lastFetchedAt: new Date().toISOString(),\n };\n\n // Validate that all timestamps are present in the file\n currentState = await parsePreferenceTimestampsFromCsv(\n preferences,\n currentState,\n );\n fileMetadata[file] = currentState;\n await cache.setValue(fileMetadata, 'fileMetadata');\n\n // Validate that all identifiers are present and unique\n const result = await parsePreferenceIdentifiersFromCsv(\n preferences,\n currentState,\n );\n currentState = result.currentState;\n preferences = result.preferences;\n fileMetadata[file] = currentState;\n await cache.setValue(fileMetadata, 'fileMetadata');\n\n // Ensure all other columns are mapped to purpose and preference\n // slug values\n currentState = await parsePreferenceAndPurposeValuesFromCsv(\n preferences,\n currentState,\n {\n preferenceTopics,\n purposeSlugs,\n forceTriggerWorkflows,\n },\n );\n fileMetadata[file] = currentState;\n await cache.setValue(fileMetadata, 'fileMetadata');\n\n // Grab existing preference store records\n const identifiers = preferences.map(\n (pref) => pref[currentState.identifierColumn!],\n );\n const existingConsentRecords = skipExistingRecordCheck\n ? []\n : await getPreferencesForIdentifiers(sombra, {\n identifiers: identifiers.map((x) => ({ value: x })),\n partitionKey,\n });\n const consentRecordByIdentifier = keyBy(existingConsentRecords, 'userId');\n\n // Clear out previous updates\n currentState.pendingConflictUpdates = {};\n currentState.pendingSafeUpdates = {};\n currentState.skippedUpdates = {};\n\n // Process each row\n preferences.forEach((pref) => {\n // Grab unique Id for the user\n const userId = pref[currentState.identifierColumn!];\n\n // determine updates for user\n const pendingUpdates = getPreferenceUpdatesFromRow({\n row: pref,\n columnToPurposeName: currentState.columnToPurposeName,\n preferenceTopics,\n purposeSlugs,\n });\n\n // Grab current state of the update\n const currentConsentRecord = consentRecordByIdentifier[userId];\n if (forceTriggerWorkflows && !currentConsentRecord) {\n throw new Error(\n `No existing consent record found for user with id: ${userId}. \n When 'forceTriggerWorkflows' is set all the user identifiers should contain a consent record`,\n );\n }\n // Check if the update can be skipped\n // this is the case if a record exists, and the purpose\n // and preference values are all in sync\n if (\n currentConsentRecord &&\n checkIfPendingPreferenceUpdatesAreNoOp({\n currentConsentRecord,\n pendingUpdates,\n preferenceTopics,\n }) &&\n !forceTriggerWorkflows\n ) {\n currentState.skippedUpdates[userId] = pref;\n return;\n }\n\n // Determine if there are any conflicts\n if (\n currentConsentRecord &&\n checkIfPendingPreferenceUpdatesCauseConflict({\n currentConsentRecord,\n pendingUpdates,\n preferenceTopics,\n })\n ) {\n currentState.pendingConflictUpdates[userId] = {\n row: pref,\n record: currentConsentRecord,\n };\n return;\n }\n\n // Add to pending updates\n currentState.pendingSafeUpdates[userId] = pref;\n });\n\n // Read in the file\n fileMetadata[file] = currentState;\n await cache.setValue(fileMetadata, 'fileMetadata');\n const t1 = new Date().getTime();\n logger.info(\n colors.green(\n `Successfully pre-processed file: \"${file}\" in ${(t1 - t0) / 1000}s`,\n ),\n );\n}\n","import { PreferenceQueryResponseItem } from '@transcend-io/privacy-types';\nimport type { Got } from 'got';\nimport colors from 'colors';\nimport cliProgress from 'cli-progress';\nimport { chunk } from 'lodash-es';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport { map } from 'bluebird';\nimport { logger } from '../../logger';\nimport { withPreferenceQueryRetry } from './withPreferenceQueryRetry';\nimport { ConsentPreferenceResponse } from './types';\n\n/**\n * Grab the current consent preference values for a list of identifiers\n *\n * @param sombra - Backend to make API call to\n * @param options - Options\n * @returns Plaintext context information\n */\nexport async function getPreferencesForIdentifiers(\n sombra: Got,\n {\n identifiers,\n partitionKey,\n skipLogging = false,\n concurrency = 40,\n }: {\n /** The list of identifiers to look up */\n identifiers: {\n /** The value of the identifier */\n value: string;\n }[];\n /** The partition key to look up */\n partitionKey: string;\n /** Whether to skip logging */\n skipLogging?: boolean;\n /** Concurrency for requests (default 40) */\n concurrency?: number;\n },\n): Promise<PreferenceQueryResponseItem[]> {\n const results: PreferenceQueryResponseItem[] = [];\n const groupedIdentifiers = chunk(identifiers, 100);\n\n // create a new progress bar instance and use shades_classic theme\n const t0 = new Date().getTime();\n const progressBar = new cliProgress.SingleBar(\n {},\n cliProgress.Presets.shades_classic,\n );\n if (!skipLogging) {\n progressBar.start(identifiers.length, 0);\n }\n\n let total = 0;\n await map(\n groupedIdentifiers,\n async (group) => {\n const rawResult = await withPreferenceQueryRetry(\n () =>\n sombra\n .post(`v1/preferences/${partitionKey}/query`, {\n json: {\n filter: { identifiers: group },\n limit: group.length,\n },\n })\n .json(),\n {\n onRetry: (attempt, _err, msg) => {\n logger.warn(\n colors.yellow(\n `[RETRY] group size=${group.length} partition=${partitionKey} attempt=${attempt}: ${msg}`,\n ),\n );\n },\n },\n );\n\n const result = decodeCodec(ConsentPreferenceResponse, rawResult);\n results.push(...result.nodes);\n total += group.length;\n progressBar.update(total);\n },\n {\n concurrency,\n },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n if (!skipLogging) {\n // Log completion time\n logger.info(\n colors.green(`Completed download in \"${totalTime / 1000}\" seconds.`),\n );\n }\n\n return results;\n}\n","import colors from 'colors';\nimport { logger } from '../../logger';\nimport { sleepPromise } from '../helpers';\n\n/**\n * Transient network / platform errors that merit a retry.\n * Keep this list short and specific to avoid masking real failures.\n */\nexport const RETRY_PREFERENCE_MSGS: string[] = [\n 'ENOTFOUND',\n 'ECONNRESET',\n 'ETIMEDOUT',\n '502 Bad Gateway',\n '504 Gateway Time-out',\n 'Task timed out after',\n 'unknown request error',\n].map((s) => s.toLowerCase());\n\n/**\n * Options for retrying preference queries.\n */\nexport type RetryOptions = {\n /** Max attempts including the first try (default 3) */\n maxAttempts?: number;\n /** Initial backoff in ms (default 250) */\n baseDelayMs?: number;\n /** Optional custom predicate to decide if an error is retryable */\n isRetryable?: (err: unknown, message: string) => boolean;\n /** Optional hook to log on each retry */\n onRetry?: (attempt: number, err: unknown, message: string) => void;\n};\n\n/**\n * Run an async function with standardized retry behavior for preference queries.\n * Exponential backoff with jitter; only retries on known-transient messages.\n *\n * @param fn - Function to run\n * @param options - Retry options\n * @returns Result of the function\n */\nexport async function withPreferenceQueryRetry<T>(\n fn: () => Promise<T>,\n {\n maxAttempts = 3,\n baseDelayMs = 250,\n isRetryable = (_err, msg) =>\n RETRY_PREFERENCE_MSGS.some((m) => msg.toLowerCase().includes(m)),\n onRetry,\n }: RetryOptions = {},\n): Promise<T> {\n let attempt = 0;\n // eslint-disable-next-line no-constant-condition\n while (true) {\n attempt += 1;\n try {\n return await fn();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (err: any) {\n const msg: string =\n (err && (err.response?.body || err.message)) ??\n String(err ?? 'Unknown error');\n const willRetry = attempt < maxAttempts && isRetryable(err, msg);\n if (!willRetry) {\n throw new Error(\n `Preference query failed after ${attempt} attempt(s): ${msg}`,\n );\n }\n onRetry?.(attempt, err, msg);\n\n const backoff = baseDelayMs * 2 ** (attempt - 1);\n const jitter = Math.floor(Math.random() * baseDelayMs);\n const delay = backoff + jitter;\n logger.warn(\n colors.yellow(\n `[retry] attempt ${attempt}/${\n maxAttempts - 1\n }; backing off ${delay}ms: ${msg}`,\n ),\n );\n await sleepPromise(delay);\n }\n }\n}\n","import { uniq, groupBy, difference } from 'lodash-es';\nimport colors from 'colors';\nimport inquirer from 'inquirer';\nimport { FileMetadataState } from './codecs';\nimport { logger } from '../../logger';\nimport { inquirerConfirmBoolean } from '../helpers';\n\n/* eslint-disable no-param-reassign */\n\n/**\n * Parse identifiers from a CSV list of preferences\n *\n * Ensures that all rows have a valid identifier\n * and that all identifiers are unique.\n *\n * @param preferences - List of preferences\n * @param currentState - The current file metadata state for parsing this list\n * @returns The updated file metadata state\n */\nexport async function parsePreferenceIdentifiersFromCsv(\n preferences: Record<string, string>[],\n currentState: FileMetadataState,\n): Promise<{\n /** The updated state */\n currentState: FileMetadataState;\n /** The updated preferences */\n preferences: Record<string, string>[];\n}> {\n // Determine columns to map\n const columnNames = uniq(preferences.map((x) => Object.keys(x)).flat());\n\n // Determine the columns that could potentially be used for identifier\n const remainingColumnsForIdentifier = difference(columnNames, [\n ...(currentState.identifierColumn ? [currentState.identifierColumn] : []),\n ...Object.keys(currentState.columnToPurposeName),\n ]);\n\n // Determine the identifier column to work off of\n if (!currentState.identifierColumn) {\n const { identifierName } = await inquirer.prompt<{\n /** Identifier name */\n identifierName: string;\n }>([\n {\n name: 'identifierName',\n message:\n 'Choose the column that will be used as the identifier to upload consent preferences by',\n type: 'list',\n default:\n remainingColumnsForIdentifier.find((col) =>\n col.toLowerCase().includes('email'),\n ) || remainingColumnsForIdentifier[0],\n choices: remainingColumnsForIdentifier,\n },\n ]);\n currentState.identifierColumn = identifierName;\n }\n logger.info(\n colors.magenta(\n `Using identifier column \"${currentState.identifierColumn}\"`,\n ),\n );\n\n // Validate that the identifier column is present for all rows and unique\n const identifierColumnsMissing = preferences\n .map((pref, ind) => (pref[currentState.identifierColumn!] ? null : [ind]))\n .filter((x): x is number[] => !!x)\n .flat();\n if (identifierColumnsMissing.length > 0) {\n const msg = `The identifier column \"${\n currentState.identifierColumn\n }\" is missing a value for the following rows: ${identifierColumnsMissing.join(\n ', ',\n )}`;\n logger.warn(colors.yellow(msg));\n\n // Ask user if they would like to skip rows missing an identifier\n const skip = await inquirerConfirmBoolean({\n message: 'Would you like to skip rows missing an identifier?',\n });\n if (!skip) {\n throw new Error(msg);\n }\n\n // Filter out rows missing an identifier\n const previous = preferences.length;\n preferences = preferences.filter(\n (pref) => pref[currentState.identifierColumn!],\n );\n logger.info(\n colors.yellow(\n `Skipped ${previous - preferences.length} rows missing an identifier`,\n ),\n );\n }\n logger.info(\n colors.magenta(\n `The identifier column \"${currentState.identifierColumn}\" is present for all rows`,\n ),\n );\n\n // Validate that all identifiers are unique\n const rowsByUserId = groupBy(preferences, currentState.identifierColumn);\n const duplicateIdentifiers = Object.entries(rowsByUserId).filter(\n ([, rows]) => rows.length > 1,\n );\n if (duplicateIdentifiers.length > 0) {\n const msg = `The identifier column \"${\n currentState.identifierColumn\n }\" has duplicate values for the following rows: ${duplicateIdentifiers\n .slice(0, 10)\n .map(([userId, rows]) => `${userId} (${rows.length})`)\n .join('\\n')}`;\n logger.warn(colors.yellow(msg));\n\n // Ask user if they would like to take the most recent update\n // for each duplicate identifier\n const skip = await inquirerConfirmBoolean({\n message: 'Would you like to automatically take the latest update?',\n });\n if (!skip) {\n throw new Error(msg);\n }\n preferences = Object.entries(rowsByUserId)\n .map(([, rows]) => {\n const sorted = rows.sort(\n (a, b) =>\n new Date(b[currentState.timestampColum!]).getTime() -\n new Date(a[currentState.timestampColum!]).getTime(),\n );\n return sorted[0];\n })\n .filter((x) => x);\n }\n\n return { currentState, preferences };\n}\n/* eslint-enable no-param-reassign */\n","import { uniq, difference } from 'lodash-es';\nimport colors from 'colors';\nimport inquirer from 'inquirer';\nimport { FileMetadataState } from './codecs';\nimport { logger } from '../../logger';\nimport { mapSeries } from 'bluebird';\nimport { PreferenceTopic } from '../graphql';\nimport { PreferenceTopicType } from '@transcend-io/privacy-types';\nimport { splitCsvToList } from '../requests';\n\n/* eslint-disable no-param-reassign */\n\n/**\n * Parse out the purpose.enabled and preference values from a CSV file\n *\n * @param preferences - List of preferences\n * @param currentState - The current file metadata state for parsing this list\n * @param options - Options\n * @returns The updated file metadata state\n */\nexport async function parsePreferenceAndPurposeValuesFromCsv(\n preferences: Record<string, string>[],\n currentState: FileMetadataState,\n {\n purposeSlugs,\n preferenceTopics,\n forceTriggerWorkflows,\n }: {\n /** The purpose slugs that are allowed to be updated */\n purposeSlugs: string[];\n /** The preference topics */\n preferenceTopics: PreferenceTopic[];\n /** Force workflow triggers */\n forceTriggerWorkflows: boolean;\n },\n): Promise<FileMetadataState> {\n // Determine columns to map\n const columnNames = uniq(preferences.map((x) => Object.keys(x)).flat());\n\n // Determine the columns that could potentially be used for identifier\n const otherColumns = difference(columnNames, [\n ...(currentState.identifierColumn ? [currentState.identifierColumn] : []),\n ...(currentState.timestampColum ? [currentState.timestampColum] : []),\n ]);\n if (otherColumns.length === 0) {\n if (forceTriggerWorkflows) {\n return currentState;\n }\n throw new Error('No other columns to process');\n }\n\n // The purpose and preferences to map to\n const purposeNames = [\n ...purposeSlugs,\n ...preferenceTopics.map((x) => `${x.purpose.trackingType}->${x.slug}`),\n ];\n\n // Ensure all columns are accounted for\n await mapSeries(otherColumns, async (col) => {\n // Determine the unique values to map in this column\n const uniqueValues = uniq(preferences.map((x) => x[col]));\n\n // Map the column to a purpose\n let purposeMapping = currentState.columnToPurposeName[col];\n if (purposeMapping) {\n logger.info(\n colors.magenta(\n `Column \"${col}\" is associated with purpose \"${purposeMapping.purpose}\"`,\n ),\n );\n } else {\n const { purposeName } = await inquirer.prompt<{\n /** purpose name */\n purposeName: string;\n }>([\n {\n name: 'purposeName',\n message: `Choose the purpose that column ${col} is associated with`,\n type: 'list',\n default: purposeNames.find((x) => x.startsWith(purposeSlugs[0])),\n choices: purposeNames,\n },\n ]);\n const [purposeSlug, preferenceSlug] = purposeName.split('->');\n purposeMapping = {\n purpose: purposeSlug,\n preference: preferenceSlug || null,\n valueMapping: {},\n };\n }\n\n // map each value to the purpose value\n await mapSeries(uniqueValues, async (value) => {\n if (purposeMapping.valueMapping[value] !== undefined) {\n logger.info(\n colors.magenta(\n `Value \"${value}\" is associated with purpose value \"${purposeMapping.valueMapping[value]}\"`,\n ),\n );\n return;\n }\n // if preference is null, this column is just for the purpose\n if (purposeMapping.preference === null) {\n const { purposeValue } = await inquirer.prompt<{\n /** purpose value */\n purposeValue: boolean;\n }>([\n {\n name: 'purposeValue',\n message: `Choose the purpose value for value \"${value}\" associated with purpose \"${purposeMapping.purpose}\"`,\n type: 'confirm',\n default: value !== 'false',\n },\n ]);\n purposeMapping.valueMapping[value] = purposeValue;\n }\n\n // if preference is not null, this column is for a specific preference\n if (purposeMapping.preference !== null) {\n const preferenceTopic = preferenceTopics.find(\n (x) => x.slug === purposeMapping.preference,\n );\n if (!preferenceTopic) {\n logger.error(\n colors.red(\n `Preference topic \"${purposeMapping.preference}\" not found`,\n ),\n );\n return;\n }\n const preferenceOptions = preferenceTopic.preferenceOptionValues.map(\n ({ slug }) => slug,\n );\n\n if (preferenceTopic.type === PreferenceTopicType.Boolean) {\n const { preferenceValue } = await inquirer.prompt<{\n /** purpose value */\n preferenceValue: boolean;\n }>([\n {\n name: 'preferenceValue',\n message:\n // eslint-disable-next-line max-len\n `Choose the preference value for \"${preferenceTopic.slug}\" value \"${value}\" associated with purpose \"${purposeMapping.purpose}\"`,\n type: 'confirm',\n default: value !== 'false',\n },\n ]);\n purposeMapping.valueMapping[value] = preferenceValue;\n return;\n }\n\n if (preferenceTopic.type === PreferenceTopicType.Select) {\n const { preferenceValue } = await inquirer.prompt<{\n /** purpose value */\n preferenceValue: boolean;\n }>([\n {\n name: 'preferenceValue',\n // eslint-disable-next-line max-len\n message: `Choose the preference value for \"${preferenceTopic.slug}\" value \"${value}\" associated with purpose \"${purposeMapping.purpose}\"`,\n type: 'list',\n choices: preferenceOptions,\n default: preferenceOptions.find((x) => x === value),\n },\n ]);\n purposeMapping.valueMapping[value] = preferenceValue;\n return;\n }\n\n if (preferenceTopic.type === PreferenceTopicType.MultiSelect) {\n const parsedValues = splitCsvToList(value);\n // need to do this serially\n await mapSeries(parsedValues, async (parsedValue) => {\n // if we already have a value, skip re-processing it again\n if (purposeMapping.valueMapping[parsedValue] !== undefined) {\n return;\n }\n const { preferenceValue } = await inquirer.prompt<{\n /** purpose value */\n preferenceValue: boolean;\n }>([\n {\n name: 'preferenceValue',\n // eslint-disable-next-line max-len\n message: `Choose the preference value for \"${preferenceTopic.slug}\" value \"${parsedValue}\" associated with purpose \"${purposeMapping.purpose}\"`,\n type: 'list',\n choices: preferenceOptions,\n default: preferenceOptions.find((x) => x === parsedValue),\n },\n ]);\n purposeMapping.valueMapping[parsedValue] = preferenceValue;\n });\n return;\n }\n\n throw new Error(\n `Unknown preference topic type: ${preferenceTopic.type}`,\n );\n }\n });\n\n currentState.columnToPurposeName[col] = purposeMapping;\n });\n\n return currentState;\n}\n/* eslint-enable no-param-reassign */\n","import {\n PreferenceQueryResponseItem,\n PreferenceUpdateItem,\n} from '@transcend-io/privacy-types';\nimport * as t from 'io-ts';\n\nexport const PurposeRowMapping = t.type({\n /**\n * The slug or trackingType of the purpose to map to\n *\n * e.g. `Marketing`\n */\n purpose: t.string,\n /**\n * If the column maps to a preference instead of a purpose\n * this is the slug of the purpose.\n *\n * null value indicates that this column maps to the true/false\n * value of the purpose\n */\n preference: t.union([t.string, t.null]),\n /**\n * The mapping between each row value and purpose/preference value.\n *\n * e.g. for a boolean preference or purpose\n * {\n * 'true': true,\n * 'false': false,\n * '': true,\n * }\n *\n * or for a single or multi select preference\n * {\n * '': true,\n * 'value1': 'Value1',\n * 'value2': 'Value2',\n * }\n */\n valueMapping: t.record(\n t.string,\n t.union([t.string, t.boolean, t.null, t.undefined]),\n ),\n});\n\n/** Override type */\nexport type PurposeRowMapping = t.TypeOf<typeof PurposeRowMapping>;\n\n/**\n * Mapping of column name to purpose row mapping.\n * This is used to map each column in the CSV to the relevant purpose and preference definitions in\n * transcend.\n */\nexport const ColumnPurposeMap = t.record(t.string, PurposeRowMapping);\n\n/** Override type */\nexport type ColumnPurposeMap = t.TypeOf<typeof ColumnPurposeMap>;\n\nexport const IdentifierMetadataForPreference = t.type({\n /** The identifier name */\n name: t.string,\n /** Is unique on preference store */\n isUniqueOnPreferenceStore: t.boolean,\n});\n\n/** Override type */\nexport type IdentifierMetadataForPreference = t.TypeOf<\n typeof IdentifierMetadataForPreference\n>;\n\n/**\n * Mapping of identifier name to the column name in the CSV file.\n * This is used to map each identifier name to the column in the CSV file.\n */\nexport const ColumnIdentifierMap = t.record(\n t.string,\n IdentifierMetadataForPreference,\n);\n\n/** Override type */\nexport type ColumnIdentifierMap = t.TypeOf<typeof ColumnIdentifierMap>;\n\nexport const FileMetadataState = t.intersection([\n t.type({\n /**\n * Definition of how to map each column in the CSV to\n * the relevant purpose and preference definitions in transcend\n */\n columnToPurposeName: t.record(t.string, PurposeRowMapping),\n /** Last time the file was last parsed at */\n lastFetchedAt: t.string,\n /**\n * Mapping of userId to the rows in the file that need to be uploaded\n * These uploads are overwriting non-existent preferences and are safe\n */\n pendingSafeUpdates: t.record(t.string, t.record(t.string, t.string)),\n /**\n * Mapping of userId to the rows in the file that need to be uploaded\n * these records have conflicts with existing consent preferences\n */\n pendingConflictUpdates: t.record(\n t.string,\n t.type({\n record: PreferenceQueryResponseItem,\n row: t.record(t.string, t.string),\n }),\n ),\n /**\n * Mapping of userId to the rows in the file that can be skipped because\n * their preferences are already in the store\n */\n skippedUpdates: t.record(t.string, t.record(t.string, t.string)),\n }),\n t.partial({\n /** Determine which column name in file maps to consent record identifier to upload on */\n identifierColumn: t.string,\n /** Determine which column name in file maps to the timestamp */\n timestampColum: t.string,\n }),\n]);\n\n/** Override type */\nexport type FileMetadataState = t.TypeOf<typeof FileMetadataState>;\n\n/**\n * This is the type of the receipts that are stored in the file\n * that is used to track the state of the upload process.\n * It is used to resume the upload process from where it left off.\n * It is used to persist the state of the upload process across multiple runs.\n */\nexport const PreferenceUpdateMap = t.record(\n t.string,\n // This can either be true to indicate the record is pending\n // or it can be an object showing the object\n // We only return a fixed number of results to avoid\n // making the JSON file too large\n t.union([t.boolean, PreferenceUpdateItem]),\n);\n\n/** Override type */\nexport type PreferenceUpdateMap = t.TypeOf<typeof PreferenceUpdateMap>;\n\n/**\n * This is the type of the pending updates that are safe to run without\n * conflicts with existing consent preferences.\n *\n * Key is primaryKey of the record in the file.\n * The value is the row in the file that is safe to upload.\n */\nexport const PendingSafePreferenceUpdates = t.record(\n t.string,\n // This can either be true to indicate the record is safe\n // or it can be an object showing the object\n // We only return a fixed number of results to avoid\n // making the JSON file too large\n t.union([t.boolean, t.record(t.string, t.string)]),\n);\n\n/** Override type */\nexport type PendingSafePreferenceUpdates = t.TypeOf<\n typeof PendingSafePreferenceUpdates\n>;\n\n/**\n * These are the updates that failed to be uploaded to the API.\n */\nexport const FailingPreferenceUpdates = t.record(\n t.string,\n t.type({\n /** Time upload ran at */\n uploadedAt: t.string,\n /** Attempts to upload that resulted in an error */\n error: t.string,\n /** The update body */\n update: PreferenceUpdateItem,\n }),\n);\n\n/** Override type */\nexport type FailingPreferenceUpdates = t.TypeOf<\n typeof FailingPreferenceUpdates\n>;\n\n/**\n * This is the type of the pending updates that are in conflict with existing consent preferences.\n *\n * Key is primaryKey of the record in the file.\n * The value is the row in the file that is pending upload.\n */\nexport const PendingWithConflictPreferenceUpdates = t.record(\n t.string,\n // We always return the conflicts for investigation\n t.type({\n /** Record to be inserted to transcend v1/preferences API */\n record: PreferenceQueryResponseItem,\n /** The row in the file that is pending upload */\n row: t.record(t.string, t.string),\n }),\n);\n\n/** Override type */\nexport type PendingWithConflictPreferenceUpdates = t.TypeOf<\n typeof PendingWithConflictPreferenceUpdates\n>;\n\n/**\n * The set of preference updates that are skipped\n * Key is primaryKey and value is the row in the CSV\n * that is skipped.\n *\n * This is usually because the preferences are already in the store\n * or there are duplicate rows in the CSV file that are identical.\n */\nexport const SkippedPreferenceUpdates = t.record(\n t.string,\n t.record(t.string, t.string),\n);\n\n/** Override type */\nexport type SkippedPreferenceUpdates = t.TypeOf<\n typeof SkippedPreferenceUpdates\n>;\n\n/** Persist this data between runs of the script */\nexport const PreferenceState = t.type({\n /**\n * Store a cache of previous files read in\n */\n fileMetadata: t.record(t.string, FileMetadataState),\n /**\n * The set of successful uploads to Transcend\n * Mapping from userId to the upload metadata\n */\n failingUpdates: t.record(\n t.string,\n t.type({\n /** Time upload ran at */\n uploadedAt: t.string,\n /** Attempts to upload that resulted in an error */\n error: t.string,\n /** The update body */\n update: PreferenceUpdateItem,\n }),\n ),\n /**\n * The set of pending uploads to Transcend\n * Mapping from userId to the upload metadata\n */\n pendingUpdates: t.record(t.string, PreferenceUpdateItem),\n});\n\n/** Override type */\nexport type PreferenceState = t.TypeOf<typeof PreferenceState>;\n"]}
|
package/dist/chunk-M3Y6JH6I.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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 _chunk55B57ZAYcjs = require('./chunk-55B57ZAY.cjs');var _chunkZUNVPK23cjs = require('./chunk-ZUNVPK23.cjs');var _chunkXXFLFF7Qcjs = require('./chunk-XXFLFF7Q.cjs');var _crypto = require('crypto'); var E = _interopRequireWildcard(_crypto);var _jsonwebtoken = require('jsonwebtoken'); var $ = _interopRequireWildcard(_jsonwebtoken);function A(c,p,t){let n=Buffer.from(t,"base64"),u=Buffer.from(p,"base64"),f="id-aes256-wrap-pad",l=Buffer.from("A65959A6","hex"),o=E.createCipheriv(f,u,l),s={encryptedIdentifier:Buffer.concat([o.update(c),o.final()]).toString("base64")};return $.sign(s,n,{algorithm:"HS384"})}var _colors = require('colors'); var _colors2 = _interopRequireDefault(_colors);var _iots = require('io-ts'); var r = _interopRequireWildcard(_iots);var _bluebird = require('bluebird');var _cliprogress = require('cli-progress'); var _cliprogress2 = _interopRequireDefault(_cliprogress);var _typeutils = require('@transcend-io/type-utils');var x=/^[0-9][Y|N]([Y|N])[Y|N]$/,I= exports.c =r.record(r.string,r.union([r.boolean,r.literal("Auto")]));async function q({base64EncryptionKey:c,base64SigningKey:p,preferences:t,partition:n,concurrency:u=100,transcendUrl:f=_chunkXXFLFF7Qcjs.s}){let l=_chunk55B57ZAYcjs.zc.call(void 0, f),o=t.filter(e=>e.usp&&!x.test(e.usp));if(o.length>0)throw new Error(`Received invalid usp strings: ${JSON.stringify(o,null,2)}`);let d=t.map((e,g)=>[e,g]).filter(([e])=>{if(!e.purposes)return!1;try{return _typeutils.decodeCodec.call(void 0, I,e.purposes),!1}catch (e2){return!0}});if(d.length>0)throw new Error(`Received invalid purpose maps: ${JSON.stringify(d,null,2)}`);let s=t.filter(e=>!e.usp&&!e.purposes);if(s.length>0)throw new Error(`Received invalid inputs, expected either purposes or usp to be defined: ${JSON.stringify(s,null,2)}`);_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Uploading ${t.length} user preferences to partition ${n}`));let S=new Date().getTime(),m=new _cliprogress2.default.SingleBar({},_cliprogress2.default.Presets.shades_classic),v=0;m.start(t.length,0),await _bluebird.map.call(void 0, t,async({userId:e,confirmed:g="true",updated:C,prompted:P,purposes:N,...i})=>{let O=A(e,c,p),[,_]=i.usp?x.exec(i.usp)||[]:[],j={token:O,partition:n,consent:{confirmed:g==="true",purposes:N?_typeutils.decodeCodec.call(void 0, I,N):i.usp?{SaleOfInfo:_==="Y"}:{},...C?{updated:C==="true"}:{},...P?{prompted:P==="true"}:{},...i}};try{await l.post("sync",{json:j}).json()}catch(y){try{let h=JSON.parse(_optionalChain([y, 'optionalAccess', _2 => _2.response, 'optionalAccess', _3 => _3.body])||"{}");h.error&&_chunkZUNVPK23cjs.a.error(_colors2.default.red(`Error: ${h.error}`))}catch (e3){}throw new Error(`Received an error from server: ${_optionalChain([y, 'optionalAccess', _4 => _4.response, 'optionalAccess', _5 => _5.body])||_optionalChain([y, 'optionalAccess', _6 => _6.message])}`)}v+=1,m.update(v)},{concurrency:u}),m.stop();let R=new Date().getTime()-S;_chunkZUNVPK23cjs.a.info(_colors2.default.green(`Successfully uploaded ${t.length} user preferences to partition ${n} in "${R/1e3}" seconds!`))}exports.a = A; exports.b = x; exports.c = I; exports.d = q;
|
|
2
|
-
//# sourceMappingURL=chunk-M3Y6JH6I.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/cli/cli/dist/chunk-M3Y6JH6I.cjs","../src/lib/consent-manager/createConsentToken.ts","../src/lib/consent-manager/uploadConsents.ts"],"names":["createConsentToken","userId","base64EncryptionKey","base64SigningKey","signingKey","encryptionKey","encryptionAlgorithm","iv","cipher","jwtPayload","USP_STRING_REGEX","PurposeMap","uploadConsents","preferences","partition","concurrency","transcendUrl","DEFAULT_TRANSCEND_CONSENT_API","transcendConsentApi","createTranscendConsentGotInstance","invalidUspStrings","pref"],"mappings":"AAAA,u/BAAyC,wDAAoC,wDAAyC,0ECA9F,4FACH,SAWLA,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACQ,CAER,IAAMC,CAAAA,CAAa,MAAA,CAAO,IAAA,CAAKD,CAAAA,CAAkB,QAAQ,CAAA,CACnDE,CAAAA,CAAgB,MAAA,CAAO,IAAA,CAAKH,CAAAA,CAAqB,QAAQ,CAAA,CAGzDI,CAAAA,CAAsB,oBAAA,CAEtBC,CAAAA,CAAK,MAAA,CAAO,IAAA,CAAK,UAAA,CAAY,KAAK,CAAA,CAElCC,CAAAA,CAAgB,CAAA,CAAA,cAAA,CAAeF,CAAAA,CAAqBD,CAAAA,CAAeE,CAAE,CAAA,CAYrEE,CAAAA,CAAa,CACjB,mBAAA,CAV0B,MAAA,CAAO,MAAA,CAAO,CACxCD,CAAAA,CAAO,MAAA,CAAOP,CAAM,CAAA,CACpBO,CAAAA,CAAO,KAAA,CAAM,CACf,CAAC,CAAA,CAAE,QAAA,CAAS,QAAQ,CAQpB,CAAA,CAOA,OAJyB,CAAA,CAAA,IAAA,CAAKC,CAAAA,CAAYL,CAAAA,CAAY,CACpD,SAAA,CAAW,OACb,CAAC,CAGH,CC/CA,gFAAmB,qEACA,oCAEC,qGAGI,qDACI,IAIfM,CAAAA,CAAmB,0BAAA,CAEnBC,CAAAA,aAAe,CAAA,CAAA,MAAA,CACxB,CAAA,CAAA,MAAA,CACA,CAAA,CAAA,KAAA,CAAM,CAAG,CAAA,CAAA,OAAA,CAAW,CAAA,CAAA,OAAA,CAAQ,MAAM,CAAC,CAAC,CACxC,CAAA,CAOA,MAAA,SAAsBC,CAAAA,CAAe,CACnC,mBAAA,CAAAV,CAAAA,CACA,gBAAA,CAAAC,CAAAA,CACA,WAAA,CAAAU,CAAAA,CACA,SAAA,CAAAC,CAAAA,CACA,WAAA,CAAAC,CAAAA,CAAc,GAAA,CACd,YAAA,CAAAC,CAAAA,CAAeC,mBACjB,CAAA,CAakB,CAEhB,IAAMC,CAAAA,CAAsBC,kCAAAA,CAA8C,CAAA,CAGpEC,CAAAA,CAAoBP,CAAAA,CAAY,MAAA,CACnCQ,CAAAA,EAASA,CAAAA,CAAK,GAAA,EAAO,CAACX,CAAAA,CAAiB,IAAA,CAAKW,CAAAA,CAAK,GAAG,CACvD,CAAA,CACA,EAAA,CAAID,CAAAA,CAAkB,MAAA,CAAS,CAAA,CAC7B,MAAM,IAAI,KAAA,CACR,CAAA,8BAAA,EAAiC,IAAA,CAAK,SAAA,CACpCA,CAAAA,CACA,IAAA,CACA,CACF,CAAC,CAAA,CAAA","file":"/home/runner/work/cli/cli/dist/chunk-M3Y6JH6I.cjs","sourcesContent":[null,"import * as crypto from 'crypto';\nimport * as jwt from 'jsonwebtoken';\n\n/**\n * Function to create a consent manager token\n *\n * @see https://docs.transcend.io/docs/consent/reference/managed-consent-database\n * @param userId - User ID\n * @param base64EncryptionKey - Encryption key\n * @param base64SigningKey - Signing key\n * @returns Token\n */\nexport function createConsentToken(\n userId: string,\n base64EncryptionKey: string,\n base64SigningKey: string,\n): string {\n // Read on for where to find these keys\n const signingKey = Buffer.from(base64SigningKey, 'base64');\n const encryptionKey = Buffer.from(base64EncryptionKey, 'base64');\n\n // NIST's AES-KWP implementation { aes 48 } - see https://tools.ietf.org/html/rfc5649\n const encryptionAlgorithm = 'id-aes256-wrap-pad';\n // Initial Value for AES-KWP integrity check - see https://tools.ietf.org/html/rfc5649#section-3\n const iv = Buffer.from('A65959A6', 'hex');\n // Set up encryption algorithm\n const cipher = crypto.createCipheriv(encryptionAlgorithm, encryptionKey, iv);\n\n // Encrypt the userId and base64-encode the result\n const encryptedIdentifier = Buffer.concat([\n cipher.update(userId),\n cipher.final(),\n ]).toString('base64');\n\n // Create the JWT content - jwt.sign will add a 'iat' (issued at) field to the payload\n // If you wanted to add something manually, consider\n // const issued: Date = new Date();\n // const isoDate = issued.toISOString();\n const jwtPayload = {\n encryptedIdentifier,\n };\n\n // Create a JSON web token and HMAC it with SHA-384\n const consentToken = jwt.sign(jwtPayload, signingKey, {\n algorithm: 'HS384',\n });\n\n return consentToken;\n}\n","import { createTranscendConsentGotInstance } from '../graphql';\nimport colors from 'colors';\nimport * as t from 'io-ts';\nimport { DEFAULT_TRANSCEND_CONSENT_API } from '../../constants';\nimport { map } from 'bluebird';\nimport { createConsentToken } from './createConsentToken';\nimport { logger } from '../../logger';\nimport cliProgress from 'cli-progress';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport type { ConsentPreferenceUpload } from './types';\nimport { ConsentPreferencesBody } from '@transcend-io/airgap.js-types';\n\nexport const USP_STRING_REGEX = /^[0-9][Y|N]([Y|N])[Y|N]$/;\n\nexport const PurposeMap = t.record(\n t.string,\n t.union([t.boolean, t.literal('Auto')]),\n);\n\n/**\n * Upload a set of consent preferences\n *\n * @param options - Options\n */\nexport async function uploadConsents({\n base64EncryptionKey,\n base64SigningKey,\n preferences,\n partition,\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_CONSENT_API,\n}: {\n /** base64 encryption key */\n base64EncryptionKey: string;\n /** base64 signing key */\n base64SigningKey: string;\n /** Partition key */\n partition: string;\n /** Sombra API key authentication */\n preferences: ConsentPreferenceUpload[];\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Concurrency limit for approving */\n concurrency?: number;\n}): Promise<void> {\n // Create connection to API\n const transcendConsentApi = createTranscendConsentGotInstance(transcendUrl);\n\n // Ensure usp strings are valid\n const invalidUspStrings = preferences.filter(\n (pref) => pref.usp && !USP_STRING_REGEX.test(pref.usp),\n );\n if (invalidUspStrings.length > 0) {\n throw new Error(\n `Received invalid usp strings: ${JSON.stringify(\n invalidUspStrings,\n null,\n 2,\n )}`,\n );\n }\n\n // Ensure purpose maps are valid\n const invalidPurposeMaps = preferences\n .map((pref, ind) => [pref, ind] as [ConsentPreferenceUpload, number])\n .filter(([pref]) => {\n if (!pref.purposes) {\n return false;\n }\n try {\n decodeCodec(PurposeMap, pref.purposes);\n return false;\n } catch {\n return true;\n }\n });\n if (invalidPurposeMaps.length > 0) {\n throw new Error(\n `Received invalid purpose maps: ${JSON.stringify(\n invalidPurposeMaps,\n null,\n 2,\n )}`,\n );\n }\n\n // Ensure usp or preferences are provided\n const invalidInputs = preferences.filter(\n (pref) => !pref.usp && !pref.purposes,\n );\n if (invalidInputs.length > 0) {\n throw new Error(\n `Received invalid inputs, expected either purposes or usp to be defined: ${JSON.stringify(\n invalidInputs,\n null,\n 2,\n )}`,\n );\n }\n\n logger.info(\n colors.magenta(\n `Uploading ${preferences.length} user preferences to partition ${partition}`,\n ),\n );\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar(\n {},\n cliProgress.Presets.shades_classic,\n );\n\n // Build a GraphQL client\n let total = 0;\n progressBar.start(preferences.length, 0);\n await map(\n preferences,\n async ({\n userId,\n confirmed = 'true',\n updated,\n prompted,\n purposes,\n ...consent\n }) => {\n const token = createConsentToken(\n userId,\n base64EncryptionKey,\n base64SigningKey,\n );\n\n // parse usp string\n const [, saleStatus] = consent.usp\n ? USP_STRING_REGEX.exec(consent.usp) || []\n : [];\n\n const input = {\n token,\n partition,\n consent: {\n confirmed: confirmed === 'true',\n purposes: purposes\n ? decodeCodec(PurposeMap, purposes)\n : consent.usp\n ? { SaleOfInfo: saleStatus === 'Y' }\n : {},\n ...(updated ? { updated: updated === 'true' } : {}),\n ...(prompted ? { prompted: prompted === 'true' } : {}),\n ...consent,\n },\n } as ConsentPreferencesBody;\n\n // Make the request\n try {\n await transcendConsentApi\n .post('sync', {\n json: input,\n })\n .json();\n } catch (err) {\n try {\n const parsed = JSON.parse(err?.response?.body || '{}');\n if (parsed.error) {\n logger.error(colors.red(`Error: ${parsed.error}`));\n }\n } catch (e) {\n // continue\n }\n throw new Error(\n `Received an error from server: ${\n err?.response?.body || err?.message\n }`,\n );\n }\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully uploaded ${\n preferences.length\n } user preferences to partition ${partition} in \"${\n totalTime / 1000\n }\" seconds!`,\n ),\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/cli/cli/dist/chunk-MXT7N555.cjs","../src/app.ts","../src/commands/admin/generate-api-keys/command.ts","../src/commands/admin/chunk-csv/command.ts","../src/commands/admin/parquet-to-csv/command.ts","../src/commands/admin/routes.ts","../src/commands/consent/routes.ts","../src/commands/consent/build-xdi-sync-endpoint/command.ts","../src/commands/consent/pull-consent-metrics/command.ts","../src/commands/consent/pull-consent-preferences/command.ts","../src/commands/consent/update-consent-manager/command.ts","../src/commands/consent/upload-consent-preferences/command.ts","../src/commands/consent/upload-cookies-from-csv/command.ts","../src/commands/consent/upload-data-flows-from-csv/command.ts","../src/commands/consent/upload-preferences/command.ts","../src/commands/consent/generate-access-tokens/command.ts","../src/commands/inventory/routes.ts","../src/commands/inventory/derive-data-silos-from-data-flows-cross-instance/command.ts","../src/commands/inventory/derive-data-silos-from-data-flows/command.ts","../src/commands/inventory/discover-silos/command.ts","../src/commands/inventory/pull-datapoints/command.ts","../src/commands/inventory/pull-unstructured-discovery-files/command.ts","../src/commands/inventory/push/command.ts","../src/commands/inventory/scan-packages/command.ts","../src/commands/inventory/consent-manager-service-json-to-yml/command.ts","../src/lib/docgen/buildExamples.ts","../src/commands/inventory/consent-managers-to-business-entities/command.ts","../src/commands/migration/sync-ot/command.ts","../src/commands/migration/routes.ts","../src/commands/request/cron/mark-identifiers-completed/command.ts","../src/commands/request/cron/pull-identifiers/command.ts","../src/commands/request/cron/pull-profiles/command.ts","../src/commands/request/cron/routes.ts","../src/commands/request/enricher-restart/command.ts","../src/commands/request/export/command.ts","../src/commands/request/preflight/pull-identifiers/command.ts","../src/commands/request/preflight/push-identifiers/command.ts","../src/commands/request/preflight/routes.ts","../src/commands/request/system/retry-request-data-silos/command.ts","../src/commands/request/upload/command.ts","../src/commands/request/routes.ts"],"names":["generateApiKeysCommand","buildCommand","generateApiKeys","SCOPE_TITLES","uuidParser","createTranscendUrlParameter","chunkCsvCommand","chunkCsv","v","n","parquetToCsvCommand","parquetToCsv","adminRoutes","buildRouteMap","buildXdiSyncEndpointCommand","buildXdiSyncEndpoint","createAuthParameter","ScopeName","arrayParser","pullConsentMetricsCommand","pullConsentMetrics","dateParser","pullConsentPreferencesCommand","pullConsentPreferences","createSombraAuthParameter","numberParser","updateConsentManagerCommand","updateConsentManager","ConsentBundleType","uploadConsentPreferencesCommand","uploadConsentPreferences","createConsentUrlParameter","uploadCookiesFromCsvCommand","uploadCookiesFromCsv","ConsentTrackerStatus","uploadDataFlowsFromCsvCommand","uploadDataFlowsFromCsv","uploadPreferencesCommand","uploadPreferences","generateAccessTokensCommand","generateAccessTokens","parseDurationToMs","consentRoutes","deriveDataSilosFromDataFlowsCrossInstanceCommand","deriveDataSilosFromDataFlowsCrossInstance","deriveDataSilosFromDataFlowsCommand","deriveDataSilosFromDataFlows","discoverSilosCommand","discoverSilos","pullDatapointsCommand","pullDatapoints","DataCategoryType","pullUnstructuredDiscoveryFilesCommand","pullUnstructuredDiscoveryFiles","UnstructuredSubDataPointRecommendationStatus","pushCommand","push","scanPackagesCommand","scanPackages","buildExampleCommand","commandPath","flags","options","command","flagList","getFlagList","forceSingleLine","argsIndent","RequestAction"],"mappings":"AAAA,ufAAgG,wDA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ACR,IAAMC,CAAAA,CAAUH,CAAAA,CAAY,IAAA,CAAK,GAAG,CAAA,CAC9BI,CAAAA,CAAWC,EAAAA,CAAYJ,CAAK,CAAA,CAC5B,CAAE,eAAA,CAAAK,EAAAA,CAAkB,CAAA,CAAA,CAAO,UAAA,CAAAC,CAAAA,CAAa,CAAE,CAAA,kBAAIL,CAAAA,SAAW,CAAC,GAAA,CAEhE,EAAA,CAAIE,CAAAA,CAAS,MAAA,GAAW,CAAA,CACtB,MAAO,CAAA,EAAA;AAQD;AAwBO;ADzDI;AAAA;AAAA;AAAA;AAAA;AAAA;AAcjB,GAAA;AAAA;AAAA;AAAA;AExCM,GAAA;ACqEW;AAAA;AAAA;AAAA;AAAA;AAAA;AC9DrB,kHAAA;ACiCK;AAAA;AAAA;AAAA;AAaE,GAAA;AACH;AAAA;AAAA;AAAA;AAAA;AAcA,GAAA;AAAA;AChE0B,8EAAA;AAuDT;AAAA;AAAA;ACvDS,8EAAA;AAkET;AAAA;AAAA;AC7DjB,8EAAA;AC2DiB;AAAA;AClEd,4BAAA;ACyCc;AAAA;AAAA;AAAA;AAAA;AAYjB,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACzDK,GAAA;AAoDY;AAAA;AAAA;AAAA;AAAA;AAYjB,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACvDO,GAAA;ACTFI,4GAAAA;AC0GY;AAAA;AAAA;ACrFjB,yGAAA","file":"/home/runner/work/cli/cli/dist/chunk-MXT7N555.cjs","sourcesContent":[null,"import {\n buildInstallCommand,\n buildUninstallCommand,\n} from '@stricli/auto-complete';\nimport { buildApplication, buildRouteMap } from '@stricli/core';\nimport { adminRoutes } from './commands/admin/routes';\nimport { consentRoutes } from './commands/consent/routes';\nimport { inventoryRoutes } from './commands/inventory/routes';\nimport { migrationRoutes } from './commands/migration/routes';\nimport { requestRoutes } from './commands/request/routes';\nimport { description, name, version } from './constants';\n\nconst routes = buildRouteMap({\n routes: {\n request: requestRoutes,\n consent: consentRoutes,\n inventory: inventoryRoutes,\n admin: adminRoutes,\n migration: migrationRoutes,\n install: buildInstallCommand('@transcend-io/transcend', {\n bash: '__@transcend-io/cli_bash_complete',\n }),\n uninstall: buildUninstallCommand('@transcend-io/transcend', { bash: true }),\n },\n docs: {\n brief: description,\n hideRoute: {\n install: true,\n uninstall: true,\n },\n },\n});\n\nexport const app = buildApplication(routes, {\n name,\n versionInfo: {\n currentVersion: version,\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport { createTranscendUrlParameter } from '../../../lib/cli/common-parameters';\nimport { uuidParser } from '../../../lib/cli/parsers';\nimport { SCOPE_TITLES } from '../../../constants';\n\nexport const generateApiKeysCommand = buildCommand({\n loader: async () => {\n const { generateApiKeys } = await import('./impl');\n return generateApiKeys;\n },\n parameters: {\n flags: {\n email: {\n kind: 'parsed',\n parse: String,\n brief: 'The email address that you use to log into Transcend',\n },\n password: {\n kind: 'parsed',\n parse: String,\n brief: 'The password for your account login',\n },\n apiKeyTitle: {\n kind: 'parsed',\n parse: String,\n brief: 'The title of the API key being generated or destroyed',\n },\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'The file where API keys should be written to',\n },\n scopes: {\n kind: 'enum',\n values: SCOPE_TITLES,\n variadic: ',',\n brief: 'The list of scopes that should be given to the API key',\n },\n deleteExistingApiKey: {\n kind: 'boolean',\n brief:\n 'When true, if an API key exists with the specified apiKeyTitle, the existing API key is deleted',\n default: true,\n },\n createNewApiKey: {\n kind: 'boolean',\n brief:\n 'When true, new API keys will be created. Set to false if you simply want to delete all API keys with a title',\n default: true,\n },\n parentOrganizationId: {\n kind: 'parsed',\n parse: uuidParser,\n brief:\n 'Filter for only a specific organization by ID, returning all child accounts associated with that organization',\n optional: true,\n },\n transcendUrl: createTranscendUrlParameter(),\n },\n },\n docs: {\n brief: 'Generate API keys',\n fullDescription: `This command allows for creating API keys across multiple Transcend instances. This is useful for customers that are managing many Transcend instances and need to regularly create, cycle or delete API keys across all of their instances.\n\nUnlike the other commands that rely on API key authentication, this command relies upon username/password authentication. This command will spit out the API keys into a JSON file, and that JSON file can be used in subsequent CLI commands.\n\nAuthentication requires your email and password for the Transcend account. This command will only generate API keys for Transcend instances where you have the permission to \"Manage API Keys\".`,\n },\n});\n","import { buildCommand } from '@stricli/core';\n\nexport const chunkCsvCommand = buildCommand({\n loader: async () => {\n const { chunkCsv } = await import('./impl');\n return chunkCsv;\n },\n parameters: {\n flags: {\n directory: {\n kind: 'parsed',\n parse: String,\n brief: 'Directory containing CSV files to split (required)',\n },\n outputDir: {\n kind: 'parsed',\n parse: String,\n brief:\n \"Directory to write chunk files (defaults to each input file's directory)\",\n optional: true,\n },\n clearOutputDir: {\n kind: 'boolean',\n brief: 'Clear the output directory before writing chunks',\n default: true,\n },\n chunkSizeMB: {\n kind: 'parsed',\n parse: (v: string) => {\n const n = Number(v);\n if (!Number.isFinite(n) || n <= 0) {\n throw new Error('chunkSizeMB must be a positive number');\n }\n return n;\n },\n brief:\n 'Approximate chunk size in megabytes. Keep well under JS string size limits',\n default: '10',\n },\n concurrency: {\n kind: 'parsed',\n parse: (v: string) => Math.max(1, Number(v) || 0),\n brief:\n 'Max number of worker processes (defaults based on CPU and file count)',\n optional: true,\n },\n viewerMode: {\n kind: 'boolean',\n brief:\n 'Run in non-interactive viewer mode (no attach UI, auto-artifacts)',\n default: false,\n },\n },\n },\n docs: {\n brief: 'Chunk all CSVs in a directory into smaller CSV files',\n fullDescription: `Streams every CSV in --directory and writes chunked files of approximately N MB each.\n- Runs files in parallel across worker processes (configurable via --concurrency).\n- Validates row-length consistency against the header row; logs periodic progress and memory usage.`,\n },\n});\n","import { buildCommand } from '@stricli/core';\n\nexport const parquetToCsvCommand = buildCommand({\n loader: async () => {\n const { parquetToCsv } = await import('./impl');\n return parquetToCsv;\n },\n parameters: {\n flags: {\n directory: {\n kind: 'parsed',\n parse: String,\n brief: 'Directory containing Parquet files to convert (required)',\n },\n outputDir: {\n kind: 'parsed',\n parse: String,\n brief:\n \"Directory to write CSV files (defaults to each input file's directory)\",\n optional: true,\n },\n clearOutputDir: {\n kind: 'boolean',\n brief: 'Clear the output directory before writing CSVs',\n default: true,\n },\n concurrency: {\n kind: 'parsed',\n parse: (v: string) => Math.max(1, Number(v) || 0),\n brief:\n 'Max number of worker processes (defaults based on CPU and file count)',\n optional: true,\n },\n viewerMode: {\n kind: 'boolean',\n brief:\n 'Run in non-interactive viewer mode (no attach UI, auto-artifacts)',\n default: false,\n },\n },\n },\n docs: {\n brief: 'Convert all Parquet files in a directory to CSV',\n fullDescription: `Streams every .parquet in --directory and writes CSV output files\n- Runs files in parallel across worker processes (configurable via --concurrency).\n- Validates row consistency; logs periodic progress and memory usage.\n\nThis is a useful administrative tool for converting Parquet exports to CSV for the purposes\nof uploading DSRs or Consent Preferences. e.g. transcend consent upload-preferences ...`,\n },\n});\n","import { buildRouteMap } from '@stricli/core';\nimport { generateApiKeysCommand } from './generate-api-keys/command';\nimport { chunkCsvCommand } from './chunk-csv/command';\nimport { parquetToCsvCommand } from './parquet-to-csv/command';\n\nexport const adminRoutes = buildRouteMap({\n routes: {\n 'generate-api-keys': generateApiKeysCommand,\n 'chunk-csv': chunkCsvCommand,\n 'parquet-to-csv': parquetToCsvCommand,\n },\n docs: {\n brief: 'Admin commands',\n },\n});\n","import { buildRouteMap } from '@stricli/core';\nimport { buildXdiSyncEndpointCommand } from './build-xdi-sync-endpoint/command';\nimport { pullConsentMetricsCommand } from './pull-consent-metrics/command';\nimport { pullConsentPreferencesCommand } from './pull-consent-preferences/command';\nimport { updateConsentManagerCommand } from './update-consent-manager/command';\nimport { uploadConsentPreferencesCommand } from './upload-consent-preferences/command';\nimport { uploadCookiesFromCsvCommand } from './upload-cookies-from-csv/command';\nimport { uploadDataFlowsFromCsvCommand } from './upload-data-flows-from-csv/command';\nimport { uploadPreferencesCommand } from './upload-preferences/command';\nimport { generateAccessTokensCommand } from './generate-access-tokens/command';\n\nexport const consentRoutes = buildRouteMap({\n routes: {\n 'build-xdi-sync-endpoint': buildXdiSyncEndpointCommand,\n 'generate-access-tokens': generateAccessTokensCommand,\n 'pull-consent-metrics': pullConsentMetricsCommand,\n 'pull-consent-preferences': pullConsentPreferencesCommand,\n 'update-consent-manager': updateConsentManagerCommand,\n 'upload-consent-preferences': uploadConsentPreferencesCommand,\n 'upload-cookies-from-csv': uploadCookiesFromCsvCommand,\n 'upload-data-flows-from-csv': uploadDataFlowsFromCsvCommand,\n 'upload-preferences': uploadPreferencesCommand,\n },\n docs: {\n brief: 'Consent commands',\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport { ScopeName } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\nimport { arrayParser } from '../../../lib/cli/parsers';\n\nexport const buildXdiSyncEndpointCommand = buildCommand({\n loader: async () => {\n const { buildXdiSyncEndpoint } = await import('./impl');\n return buildXdiSyncEndpoint;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [ScopeName.ViewConsentManager],\n }),\n xdiLocation: {\n kind: 'parsed',\n parse: String,\n brief:\n 'The location of the XDI that will be loaded by the generated sync endpoint',\n },\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'The HTML file path where the sync endpoint should be written',\n default: './sync-endpoint.html',\n },\n removeIpAddresses: {\n kind: 'boolean',\n brief: 'When true, remove IP addresses from the domain list',\n default: true,\n },\n domainBlockList: {\n kind: 'parsed',\n parse: arrayParser,\n brief:\n 'The set of domains that should be excluded from the sync endpoint. Comma-separated list.',\n default: 'localhost',\n },\n xdiAllowedCommands: {\n kind: 'parsed',\n parse: String,\n brief: 'The allowed set of XDI commands',\n default: 'ConsentManager:Sync',\n },\n transcendUrl: createTranscendUrlParameter(),\n },\n },\n docs: {\n brief: 'Build XDI sync endpoint',\n fullDescription:\n 'This command allows for building of the XDI Sync Endpoint across a set of Transcend accounts.',\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport { ScopeName } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\nimport { dateParser } from '../../../lib/cli/parsers';\n\nexport const pullConsentMetricsCommand = buildCommand({\n loader: async () => {\n const { pullConsentMetrics } = await import('./impl');\n return pullConsentMetrics;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [ScopeName.ViewConsentManager],\n }),\n start: {\n kind: 'parsed',\n parse: dateParser,\n brief: 'The start date to pull metrics from',\n },\n end: {\n kind: 'parsed',\n parse: dateParser,\n brief: 'The end date to pull metrics until',\n optional: true,\n },\n folder: {\n kind: 'parsed',\n parse: String,\n brief: 'The folder to save metrics to',\n default: './consent-metrics/',\n },\n bin: {\n kind: 'parsed',\n parse: String,\n brief: 'The bin metric when pulling data (1h or 1d)',\n default: '1d',\n },\n transcendUrl: createTranscendUrlParameter(),\n },\n },\n docs: {\n brief: 'Pull consent metrics',\n fullDescription: `This command allows for pulling consent manager metrics for a Transcend account, or a set of Transcend accounts.\n\nBy default, the consent metrics will be written to a folder named \\`consent-metrics\\` within the directory where you run the command. You can override the location that these CSVs are written to using the flag \\`--folder=./my-folder/\\`. This folder will contain a set of CSV files:\n\n- \\`CONSENT_CHANGES_TIMESERIES_optIn.csv\\` -> this is a feed containing the number of explicit opt in events that happen - these are calls to \\`airgap.setConsent(event, { SaleOfInfo: true });\\`\n- \\`CONSENT_CHANGES_TIMESERIES_optOut.csv\\` -> this is a feed containing the number of explicit opt out events that happen - these are calls to \\`airgap.setConsent(event, { SaleOfInfo: false });\\`\n- \\`CONSENT_SESSIONS_BY_REGIME_Default.csv\\` -> this contains the number of sessions detected for the bin period\n- \\`PRIVACY_SIGNAL_TIMESERIES_DNT.csv\\` -> the number of DNT signals detected.\n- \\`PRIVACY_SIGNAL_TIMESERIES_GPC.csv\\` -> the number of GPC signals detected.`,\n },\n});\n","import { buildCommand, numberParser } from '@stricli/core';\nimport { ScopeName } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createSombraAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\nimport { dateParser } from '../../../lib/cli/parsers';\n\nexport const pullConsentPreferencesCommand = buildCommand({\n loader: async () => {\n const { pullConsentPreferences } = await import('./impl');\n return pullConsentPreferences;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [\n ScopeName.ViewManagedConsentDatabaseAdminApi,\n ScopeName.ViewRequestIdentitySettings,\n ScopeName.ViewPreferenceStoreSettings,\n ],\n }),\n partition: {\n kind: 'parsed',\n parse: String,\n brief: 'Partition ID to query in the Preference Store',\n },\n sombraAuth: createSombraAuthParameter(),\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to CSV output file',\n default: './preferences.csv',\n },\n transcendUrl: createTranscendUrlParameter(),\n // \"timestamp*\" filters map to consent collection time\n timestampBefore: {\n kind: 'parsed',\n parse: dateParser,\n brief:\n 'Filter: preferences collected before this time (timestampBefore)',\n optional: true,\n },\n timestampAfter: {\n kind: 'parsed',\n parse: dateParser,\n brief: 'Filter: preferences collected after this time (timestampAfter)',\n optional: true,\n },\n // \"updated*\" filters map to system.updatedAt window\n updatedBefore: {\n kind: 'parsed',\n parse: dateParser,\n brief:\n 'Filter: preferences updated before this time (system.updatedAt)',\n optional: true,\n },\n updatedAfter: {\n kind: 'parsed',\n parse: dateParser,\n brief: 'Filter: preferences updated after this time (system.updatedAt)',\n optional: true,\n },\n identifiers: {\n kind: 'parsed',\n parse: String,\n variadic: ',',\n brief:\n 'Filter specific users by identifier(s) as \"name:value\". ' +\n 'If name is omitted, defaults to \"email\". Multiple values separated by commas.',\n optional: true,\n },\n concurrency: {\n kind: 'parsed',\n parse: numberParser,\n brief:\n 'Page size / concurrency used when downloading (1–50 per API). Higher = fewer pages.',\n default: '50',\n },\n shouldChunk: {\n kind: 'boolean',\n brief: 'Whether to download requests in timestamp window chunks.',\n default: true,\n },\n windowConcurrency: {\n kind: 'parsed',\n parse: numberParser,\n brief:\n 'When chunking, how many windows to download in parallel (higher = faster, but more load).',\n default: '100',\n },\n maxChunks: {\n kind: 'parsed',\n parse: numberParser,\n brief:\n 'Maximum number of chunks to download (higher = more data, but more load).',\n default: '5000',\n },\n maxLookbackDays: {\n kind: 'parsed',\n parse: numberParser,\n brief:\n 'Maximum lookback period in days for fetching consent preferences.',\n default: '3650',\n },\n },\n },\n docs: {\n brief: 'Pull consent preferences from the Managed Consent Database',\n fullDescription:\n 'Uses POST /v1/preferences/{partition}/query with cursor-based pagination. ' +\n 'Supports filtering by identifiers, collection timestamps, and system.updatedAt.',\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport { ConsentBundleType, ScopeName } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\n\nexport const updateConsentManagerCommand = buildCommand({\n loader: async () => {\n const { updateConsentManager } = await import('./impl');\n return updateConsentManager;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [ScopeName.ManageConsentManagerDeveloperSettings],\n }),\n bundleTypes: {\n kind: 'enum',\n values: Object.values(ConsentBundleType),\n brief: 'The bundle types to deploy. Defaults to PRODUCTION,TEST.',\n variadic: ',',\n },\n deploy: {\n kind: 'boolean',\n brief:\n 'When true, deploy the Consent Manager after updating the version',\n default: false,\n },\n transcendUrl: createTranscendUrlParameter(),\n },\n },\n docs: {\n brief: 'Update consent manager',\n fullDescription:\n 'This command allows for updating Consent Manager to latest version. The Consent Manager bundle can also be deployed using this command.',\n },\n});\n","import { buildCommand, numberParser } from '@stricli/core';\nimport { createConsentUrlParameter } from '../../../lib/cli/common-parameters';\n\nexport const uploadConsentPreferencesCommand = buildCommand({\n loader: async () => {\n const { uploadConsentPreferences } = await import('./impl');\n return uploadConsentPreferences;\n },\n parameters: {\n flags: {\n base64EncryptionKey: {\n kind: 'parsed',\n parse: String,\n brief: 'The encryption key used to encrypt the userId',\n },\n base64SigningKey: {\n kind: 'parsed',\n parse: String,\n brief:\n 'The signing key used to prove authentication of consent request',\n },\n partition: {\n kind: 'parsed',\n parse: String,\n brief: 'The partition key to download consent preferences to',\n },\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'The file to pull consent preferences from',\n default: './preferences.csv',\n },\n consentUrl: createConsentUrlParameter(),\n concurrency: {\n kind: 'parsed',\n parse: numberParser,\n brief: 'The concurrency to use when uploading requests in parallel',\n default: '100',\n },\n },\n },\n docs: {\n brief: 'Upload consent preferences to the Managed Consent Database',\n fullDescription:\n 'This command allows for updating of consent preferences to the Managed Consent Database.',\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport { ConsentTrackerStatus, ScopeName } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\n\nexport const uploadCookiesFromCsvCommand = buildCommand({\n loader: async () => {\n const { uploadCookiesFromCsv } = await import('./impl');\n return uploadCookiesFromCsv;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [ScopeName.ManageDataFlow],\n }),\n trackerStatus: {\n kind: 'enum',\n values: Object.values(ConsentTrackerStatus),\n brief: 'The status of the cookies you will upload.',\n },\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the CSV file to upload',\n default: './cookies.csv',\n },\n transcendUrl: createTranscendUrlParameter(),\n },\n },\n docs: {\n brief: 'Upload cookies from CSV',\n fullDescription: `Upload cookies from CSV. This command allows for uploading of cookies from CSV.\n\nStep 1) Download the CSV of cookies that you want to edit from the Admin Dashboard under [Consent Management -> Cookies](https://app.transcend.io/consent-manager/cookies). You can download cookies from both the \"Triage\" and \"Approved\" tabs.\n\nStep 2) You can edit the contents of the CSV file as needed. You may adjust the \"Purpose\" column, adjust the \"Notes\" column, add \"Owners\" and \"Teams\" or even add custom columns with additional metadata.\n\nStep 3) Upload the modified CSV file back into the dashboard with this command.`,\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport { ConsentTrackerStatus, ScopeName } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\n\nexport const uploadDataFlowsFromCsvCommand = buildCommand({\n loader: async () => {\n const { uploadDataFlowsFromCsv } = await import('./impl');\n return uploadDataFlowsFromCsv;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [ScopeName.ManageDataFlow],\n }),\n trackerStatus: {\n kind: 'enum',\n values: Object.values(ConsentTrackerStatus),\n brief: 'The status of the data flows you will upload.',\n },\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the CSV file to upload',\n default: './data-flows.csv',\n },\n classifyService: {\n kind: 'boolean',\n brief:\n 'When true, automatically assign the service for a data flow based on the domain that is specified',\n default: false,\n },\n transcendUrl: createTranscendUrlParameter(),\n },\n },\n docs: {\n brief: 'Upload data flows from CSV',\n fullDescription: `Upload data flows from CSV. This command allows for uploading of data flows from CSV.\n\nStep 1) Download the CSV of data flows that you want to edit from the Admin Dashboard under [Consent Management -> Data Flows](https://app.transcend.io/consent-manager/data-flows). You can download data flows from both the \"Triage\" and \"Approved\" tabs.\n\nStep 2) You can edit the contents of the CSV file as needed. You may adjust the \"Purpose\" column, adjust the \"Notes\" column, add \"Owners\" and \"Teams\" or even add custom columns with additional metadata.\n\nStep 3) Upload the modified CSV file back into the dashboard with this command.`,\n },\n});\n","import { buildCommand, numberParser } from '@stricli/core';\nimport { ScopeName } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createSombraAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\n\nexport const uploadPreferencesCommand = buildCommand({\n loader: async () => {\n const { uploadPreferences } = await import('./impl');\n return uploadPreferences;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [\n ScopeName.ManageStoredPreferences,\n ScopeName.ViewManagedConsentDatabaseAdminApi,\n ScopeName.ViewPreferenceStoreSettings,\n ],\n }),\n partition: {\n kind: 'parsed',\n parse: String,\n brief: 'The partition key to download consent preferences to',\n },\n sombraAuth: createSombraAuthParameter(),\n transcendUrl: createTranscendUrlParameter(),\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the CSV file to load preferences from',\n optional: true,\n },\n directory: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the directory of CSV files to load preferences from',\n optional: true,\n },\n dryRun: {\n kind: 'boolean',\n brief:\n 'Whether to do a dry run only - will write results to receiptFilepath without updating Transcend',\n default: false,\n },\n skipExistingRecordCheck: {\n kind: 'boolean',\n brief:\n 'Whether to skip the check for existing records. SHOULD ONLY BE USED FOR INITIAL UPLOAD',\n default: false,\n },\n receiptFileDir: {\n kind: 'parsed',\n parse: String,\n brief: 'Directory path where the response receipts should be saved',\n default: './receipts',\n },\n skipWorkflowTriggers: {\n kind: 'boolean',\n brief:\n 'Whether to skip workflow triggers when uploading to preference store',\n default: false,\n },\n forceTriggerWorkflows: {\n kind: 'boolean',\n brief:\n 'Whether to force trigger workflows for existing consent records',\n default: false,\n },\n skipConflictUpdates: {\n kind: 'boolean',\n brief:\n 'Whether to skip uploading of any records where the preference store and file have a hard conflict',\n default: false,\n },\n isSilent: {\n kind: 'boolean',\n brief: 'Whether to skip sending emails in workflows',\n default: true,\n },\n attributes: {\n kind: 'parsed',\n parse: String,\n brief:\n 'Attributes to add to any DSR request if created. Comma-separated list of key:value pairs.',\n default: 'Tags:transcend-cli,Source:transcend-cli',\n },\n receiptFilepath: {\n kind: 'parsed',\n parse: String,\n brief: 'Store resulting, continuing where left off',\n default: './preference-management-upload-receipts.json',\n },\n concurrency: {\n kind: 'parsed',\n parse: numberParser,\n brief: 'The concurrency to use when uploading in parallel',\n default: '10',\n },\n },\n },\n docs: {\n brief: 'Upload preference management data to your Preference Store',\n fullDescription: `Upload preference management data to your Preference Store.\n\nThis command prompts you to map the shape of the CSV to the shape of the Transcend API. There is no requirement for the shape of the incoming CSV, as the script will handle the mapping process.\n\nThe script will also produce a JSON cache file that allows for the mappings to be preserved between runs.`,\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport { ScopeName } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\nimport { parseDurationToMs } from '../../../lib/cli/parsers';\n\nexport const generateAccessTokensCommand = buildCommand({\n loader: async () => {\n const { generateAccessTokens } = await import('./impl');\n return generateAccessTokens;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [ScopeName.GeneratePreferenceAccessTokens],\n }),\n file: {\n kind: 'parsed',\n parse: String,\n brief:\n 'Path to the CSV file containing user identifiers to generate access tokens for',\n },\n subjectType: {\n kind: 'parsed',\n parse: String,\n brief:\n 'Slug for the data subject that the user will be logged in as on the Privacy Center. e.g. \"customer\" or \"employee\"',\n },\n emailColumnName: {\n kind: 'parsed',\n parse: String,\n brief:\n 'Name of the column in the CSV that contains user email addresses',\n default: 'email',\n },\n coreIdentifierColumnName: {\n kind: 'parsed',\n parse: String,\n optional: true,\n brief:\n 'Name of the column in the CSV that contains user core identifiers',\n },\n duration: {\n kind: 'parsed',\n parse: parseDurationToMs,\n brief:\n 'How long the access tokens should be valid. Accepts human-friendly values ' +\n 'like \"2 days\", \"10h\", \"90 minutes\". A bare number is interpreted as seconds ' +\n '(e.g., \"300\" = 5 minutes). Powered by the `ms` library: ' +\n 'https://github.com/vercel/ms',\n // Default of \"1y\" → parsed to 31_557_600_000 ms\n default: '1y',\n },\n transcendUrl: createTranscendUrlParameter(),\n },\n },\n docs: {\n brief: 'Generate access tokens',\n fullDescription:\n 'This command allows for the generation of access tokens for users specified in a CSV file.',\n },\n});\n","import { buildRouteMap } from '@stricli/core';\nimport { deriveDataSilosFromDataFlowsCrossInstanceCommand } from './derive-data-silos-from-data-flows-cross-instance/command';\nimport { deriveDataSilosFromDataFlowsCommand } from './derive-data-silos-from-data-flows/command';\nimport { discoverSilosCommand } from './discover-silos/command';\nimport { pullDatapointsCommand } from './pull-datapoints/command';\nimport { pullUnstructuredDiscoveryFilesCommand } from './pull-unstructured-discovery-files/command';\nimport { pullCommand } from './pull/command';\nimport { pushCommand } from './push/command';\nimport { scanPackagesCommand } from './scan-packages/command';\nimport { consentManagerServiceJsonToYmlCommand } from './consent-manager-service-json-to-yml/command';\nimport { consentManagersToBusinessEntitiesCommand } from './consent-managers-to-business-entities/command';\n\nexport const inventoryRoutes = buildRouteMap({\n routes: {\n pull: pullCommand,\n push: pushCommand,\n 'scan-packages': scanPackagesCommand,\n 'discover-silos': discoverSilosCommand,\n 'pull-datapoints': pullDatapointsCommand,\n 'pull-unstructured-discovery-files': pullUnstructuredDiscoveryFilesCommand,\n 'derive-data-silos-from-data-flows': deriveDataSilosFromDataFlowsCommand,\n 'derive-data-silos-from-data-flows-cross-instance':\n deriveDataSilosFromDataFlowsCrossInstanceCommand,\n 'consent-manager-service-json-to-yml':\n consentManagerServiceJsonToYmlCommand,\n 'consent-managers-to-business-entities':\n consentManagersToBusinessEntitiesCommand,\n },\n docs: {\n brief: 'Inventory commands',\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\n\nexport const deriveDataSilosFromDataFlowsCrossInstanceCommand = buildCommand({\n loader: async () => {\n const { deriveDataSilosFromDataFlowsCrossInstance } = await import(\n './impl'\n );\n return deriveDataSilosFromDataFlowsCrossInstance;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [],\n }),\n dataFlowsYmlFolder: {\n kind: 'parsed',\n parse: String,\n brief: 'The folder that contains data flow yml files',\n },\n output: {\n kind: 'parsed',\n parse: String,\n brief:\n 'The output transcend.yml file containing the data silo configurations',\n default: './transcend.yml',\n },\n ignoreYmls: {\n kind: 'parsed',\n parse: String,\n variadic: ',',\n brief: 'The set of yml files that should be skipped when uploading',\n optional: true,\n },\n transcendUrl: createTranscendUrlParameter(),\n },\n },\n docs: {\n brief: 'Derive data silos from data flows cross instance',\n fullDescription:\n 'Given a folder of data flow transcend.yml configurations, convert those configurations to a single transcend.yml configurations of all related data silos.',\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\n\nexport const deriveDataSilosFromDataFlowsCommand = buildCommand({\n loader: async () => {\n const { deriveDataSilosFromDataFlows } = await import('./impl');\n return deriveDataSilosFromDataFlows;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [],\n }),\n dataFlowsYmlFolder: {\n kind: 'parsed',\n parse: String,\n brief: 'The folder that contains data flow yml files',\n },\n dataSilosYmlFolder: {\n kind: 'parsed',\n parse: String,\n brief: 'The folder that contains data silo yml files',\n },\n ignoreYmls: {\n kind: 'parsed',\n parse: String,\n variadic: ',',\n brief: 'The set of yml files that should be skipped when uploading',\n optional: true,\n },\n transcendUrl: createTranscendUrlParameter(),\n },\n },\n docs: {\n brief: 'Derive data silos from data flows',\n fullDescription:\n 'Given a folder of data flow transcend.yml configurations, convert those configurations to set of data silo transcend.yml configurations.',\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport { ScopeName } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\nimport { uuidParser } from '../../../lib/cli/parsers';\n\nexport const discoverSilosCommand = buildCommand({\n loader: async () => {\n const { discoverSilos } = await import('./impl');\n return discoverSilos;\n },\n parameters: {\n flags: {\n scanPath: {\n kind: 'parsed',\n parse: String,\n brief: 'File path in the project to scan',\n },\n dataSiloId: {\n kind: 'parsed',\n parse: uuidParser,\n brief: 'The UUID of the corresponding data silo',\n },\n auth: createAuthParameter({\n scopes: [ScopeName.ManageAssignedDataInventory],\n requiresSiloScope: true,\n }),\n fileGlobs: {\n kind: 'parsed',\n parse: String,\n brief:\n 'You can pass a glob syntax pattern(s) to specify additional file paths to scan. Comma-separated list of globs.',\n default: '',\n },\n ignoreDirs: {\n kind: 'parsed',\n parse: String,\n brief: 'Comma-separated list of directories to ignore.',\n default: '',\n },\n transcendUrl: createTranscendUrlParameter(),\n },\n },\n docs: {\n brief: 'Scan dependency management files to discover new data silos.',\n fullDescription: `We support scanning for new data silos in JavaScript, Python, Gradle, and CocoaPods projects.\n\nTo get started, add a data silo for the corresponding project type with the \"silo discovery\" plugin enabled. For example, if you want to scan a JavaScript project, add a package.json data silo. Then, specify the data silo ID in the \"--dataSiloId\" parameter.`,\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport { DataCategoryType, ScopeName } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\n\nexport const pullDatapointsCommand = buildCommand({\n loader: async () => {\n const { pullDatapoints } = await import('./impl');\n return pullDatapoints;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [ScopeName.ViewDataInventory],\n }),\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'The file to save datapoints to',\n default: './datapoints.csv',\n },\n transcendUrl: createTranscendUrlParameter(),\n dataSiloIds: {\n kind: 'parsed',\n parse: String,\n variadic: ',',\n brief: 'List of data silo IDs to filter by',\n optional: true,\n },\n includeAttributes: {\n kind: 'boolean',\n brief: 'Whether to include attributes in the output',\n default: false,\n },\n includeGuessedCategories: {\n kind: 'boolean',\n brief: 'Whether to include guessed categories in the output',\n default: false,\n },\n parentCategories: {\n kind: 'enum',\n values: Object.values(DataCategoryType),\n brief: 'List of parent categories to filter by',\n variadic: ',',\n optional: true,\n },\n subCategories: {\n kind: 'parsed',\n parse: String,\n brief: 'List of subcategories to filter by',\n variadic: ',',\n optional: true,\n },\n },\n },\n docs: {\n brief: 'Export the datapoints from your Data Inventory into a CSV.',\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport {\n ScopeName,\n UnstructuredSubDataPointRecommendationStatus,\n} from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\n\nexport const pullUnstructuredDiscoveryFilesCommand = buildCommand({\n loader: async () => {\n const { pullUnstructuredDiscoveryFiles } = await import('./impl');\n return pullUnstructuredDiscoveryFiles;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [ScopeName.ViewDataInventory],\n }),\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'The file to save datapoints to',\n default: './unstructured-discovery-files.csv',\n },\n transcendUrl: createTranscendUrlParameter(),\n dataSiloIds: {\n kind: 'parsed',\n parse: String,\n brief: 'List of data silo IDs to filter by',\n variadic: ',',\n optional: true,\n },\n subCategories: {\n kind: 'parsed',\n parse: String,\n brief: 'List of data categories to filter by',\n variadic: ',',\n optional: true,\n },\n status: {\n kind: 'enum',\n values: Object.values(UnstructuredSubDataPointRecommendationStatus),\n brief: 'List of classification statuses to filter by',\n variadic: ',',\n optional: true,\n },\n includeEncryptedSnippets: {\n kind: 'boolean',\n brief:\n 'Whether to include encrypted snippets of the entries classified',\n default: false,\n },\n },\n },\n docs: {\n brief: 'Pull unstructured discovery files',\n fullDescription:\n 'This command allows for pulling Unstructured Discovery into a CSV.',\n },\n});\n","import { buildCommand, numberParser } from '@stricli/core';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\n\nexport const pushCommand = buildCommand({\n loader: async () => {\n const { push } = await import('./impl');\n return push;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: 'Varies',\n }),\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the YAML file to push from',\n default: './transcend.yml',\n },\n transcendUrl: createTranscendUrlParameter(),\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 variables: {\n kind: 'parsed',\n parse: String,\n brief:\n 'The variables to template into the YAML file when pushing configuration. Comma-separated list of key:value pairs.',\n default: '',\n },\n publishToPrivacyCenter: {\n kind: 'boolean',\n brief: 'When true, publish the configuration to the Privacy Center',\n default: false,\n },\n classifyService: {\n kind: 'boolean',\n brief:\n 'When true, automatically assign the service for a data flow based on the domain that is specified',\n default: false,\n },\n deleteExtraAttributeValues: {\n kind: 'boolean',\n brief:\n 'When true and syncing attributes, delete any extra attributes instead of just upserting',\n default: false,\n },\n },\n },\n docs: {\n brief: 'Push metadata from transcend.yml to Transcend',\n fullDescription:\n 'Given a transcend.yml file, sync the contents up to your Transcend instance.',\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport { ScopeName } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\n\nexport const scanPackagesCommand = buildCommand({\n loader: async () => {\n const { scanPackages } = await import('./impl');\n return scanPackages;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [ScopeName.ManageCodeScanning],\n }),\n scanPath: {\n kind: 'parsed',\n parse: String,\n brief: 'File path in the project to scan',\n default: './',\n },\n ignoreDirs: {\n kind: 'parsed',\n parse: String,\n variadic: ',',\n brief: 'List of directories to ignore in scan',\n optional: true,\n },\n repositoryName: {\n kind: 'parsed',\n parse: String,\n brief: 'Name of the git repository that the package should be tied to',\n optional: true,\n },\n transcendUrl: createTranscendUrlParameter(),\n },\n },\n docs: {\n brief: 'Scan dependency management files to inventory code dependencies.',\n fullDescription: `Transcend scans packages and dependencies for the following frameworks:\n\n- package.json\n- requirements.txt & setup.py\n- Podfile\n- Package.resolved\n- build.gradle\n- pubspec.yaml\n- Gemfile & .gemspec\n- composer.json\n\nThis command will scan the folder you point at to look for any of these files. Once found, the build file will be parsed in search of dependencies. Those code packages and dependencies will be uploaded to Transcend. The information uploaded to Transcend is:\n\n- repository name\n- package names\n- dependency names and versions\n- package descriptions`,\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport { buildExampleCommand } from '../../../lib/docgen/buildExamples';\nimport { ConsentManagerServiceJsonToYmlCommandFlags } from './impl';\nimport { PushCommandFlags } from '../push/impl';\n\nexport const consentManagerServiceJsonToYmlCommand = buildCommand({\n loader: async () => {\n const { consentManagerServiceJsonToYml } = await import('./impl');\n return consentManagerServiceJsonToYml;\n },\n parameters: {\n flags: {\n file: {\n kind: 'parsed',\n parse: String,\n brief:\n 'Path to the services.json file, output of await airgap.getMetadata()',\n default: './services.json',\n },\n output: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the output transcend.yml to write to',\n default: './transcend.yml',\n },\n },\n },\n docs: {\n brief: 'Convert consent manager services to transcend.yml',\n fullDescription: `Import the services from an airgap.js file into a Transcend instance.\n\n1. Run \\`await airgap.getMetadata()\\` on a site with airgap\n2. Right click on the printed object, and click \\`Copy object\\`\n3. Place output of file in a file named \\`services.json\\`\n4. Run:\n\n ${buildExampleCommand<ConsentManagerServiceJsonToYmlCommandFlags>(\n ['inventory', 'consent-manager-service-json-to-yml'],\n {\n file: './services.json',\n output: './transcend.yml',\n },\n { argsIndent: 5 },\n )}\n\n5. Run:\n\n ${buildExampleCommand<PushCommandFlags>(\n ['inventory', 'push'],\n {\n auth: '$TRANSCEND_API_KEY',\n file: './transcend.yml',\n classifyService: true,\n },\n { argsIndent: 5 },\n )}`,\n },\n});\n","import { name } from '../../constants';\n\nexport interface Example<Flags> {\n /** A description of the example */\n description: string;\n /** The flag arguments to the command */\n flags: Partial<Flags>;\n}\n\n/**\n * Builds a string of examples for the CLI\n *\n * @param commandPath - The path to the command to run, omitting the `transcend` command name, e.g., `['consent', 'upload-preferences']`\n * @param examples - The examples to build\n * @returns A string of examples for the CLI\n */\nexport function buildExamples<Flags = never>(\n commandPath: string[],\n examples: NoInfer<Example<Flags>>[],\n): string {\n return examples\n .map((example) => {\n const exampleCommand = buildExampleCommand<Flags>(\n commandPath,\n example.flags,\n );\n return `**${example.description}**\\n\\n\\`\\`\\`sh\\n${exampleCommand}\\n\\`\\`\\``;\n })\n .join('\\n\\n');\n}\n\n/**\n * Builds a command string for an example\n *\n * @param commandPath - The path to the command to run, omitting the `transcend` command name, e.g., `['consent', 'upload-preferences']`\n * @param flags - The flags to build the command with\n * @param options - The options for the command\n * @returns A command string for the example\n */\nexport function buildExampleCommand<Flags = never>(\n commandPath: string[],\n flags: NoInfer<Partial<Flags>>,\n options?: {\n /** If true, the command will be forced to a single line */\n forceSingleLine?: boolean;\n /** If true, the command will be indented */\n argsIndent?: number;\n },\n): string {\n const command = commandPath.join(' ');\n const flagList = getFlagList(flags);\n const { forceSingleLine = false, argsIndent = 2 } = options ?? {};\n\n if (flagList.length === 0) {\n return `${name} ${command}`;\n }\n\n // Break the command into multiple lines if it's too long\n const exampleCommand =\n `${name} ${command} ${flagList.join(' ')}`.length <= 117 && !forceSingleLine\n ? `${command} ${flagList.join(' ')}`\n : `${command} \\\\\\n${' '.repeat(argsIndent)}${flagList.join(\n ` \\\\\\n${' '.repeat(argsIndent)}`,\n )}`;\n\n // Add `transcend` before command name\n return `${name} ${exampleCommand}`;\n}\n\n/**\n * Formats a flag value to the bash string for an example command\n *\n * @param value - The value to format\n * @param depth - The depth of the recursion\n * @returns The formatted value\n */\nfunction formatFlagValue(value: unknown, depth = 0): string {\n if (typeof value === 'boolean') {\n return value ? 'true' : 'false';\n }\n\n if (typeof value === 'number') {\n return value.toString();\n }\n\n if (value instanceof Date) {\n return value.toISOString();\n }\n\n if (Array.isArray(value) && depth === 0) {\n const values = value.map((v) => formatFlagValue(v, depth + 1));\n if (values.every((x) => x.startsWith('$') || x.includes(' '))) {\n return `\"${values.join(',')}\"`;\n }\n return values.join(',');\n }\n\n if (typeof value === 'string') {\n // If we're operating on list elements\n if (depth === 1) {\n if (value.startsWith('$')) {\n return `$\\{${value.slice(1)}}`;\n }\n return value;\n }\n\n // Escape strings that start with $ or contain spaces or special characters\n return value.startsWith('$') || value.includes(' ') ? `\"${value}\"` : value;\n }\n\n throw new Error(`Unsupported value type: ${typeof value}`);\n}\n\n/**\n * Builds a list of flags formatted for an example command\n *\n * @param flags - The flags to build the command with\n * @param depth - The depth of the recursion\n * @returns A list of flags for the example command\n */\nexport function getFlagList<Flags = never>(\n flags: Partial<Flags>,\n depth = 0,\n): string[] {\n return Object.entries(flags).map(([flag, value]) => {\n if (typeof value === 'boolean' && value) {\n // For true booleans, just pass the flag alone\n return `--${flag}`;\n }\n\n const formattedValue = formatFlagValue(value, depth);\n\n return `--${flag}=${formattedValue}`;\n });\n}\n","import { buildCommand } from '@stricli/core';\n\nexport const consentManagersToBusinessEntitiesCommand = buildCommand({\n loader: async () => {\n const { consentManagersToBusinessEntities } = await import('./impl');\n return consentManagersToBusinessEntities;\n },\n parameters: {\n flags: {\n consentManagerYmlFolder: {\n kind: 'parsed',\n parse: String,\n brief:\n 'Path to the folder of Consent Manager transcend.yml files to combine',\n },\n output: {\n kind: 'parsed',\n parse: String,\n brief:\n 'Path to the output transcend.yml with business entity configuration',\n default: './combined-business-entities.yml',\n },\n },\n },\n docs: {\n brief: 'Convert consent managers to business entities',\n fullDescription:\n 'This command allows for converting a folder or Consent Manager transcend.yml files into a single transcend.yml file where each consent manager configuration is a Business Entity in the data inventory.',\n },\n});\n","import { buildCommand, type TypedFlagParameter } from '@stricli/core';\nimport { ScopeName } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\nimport { OneTrustPullResource, OneTrustPullSource } from '../../../enums';\nimport type { LocalContext } from '../../../context';\n\nexport const syncOtCommand = buildCommand({\n loader: async () => {\n const { syncOt } = await import('./impl');\n return syncOt;\n },\n parameters: {\n flags: {\n hostname: {\n kind: 'parsed',\n parse: String,\n brief:\n 'The domain of the OneTrust environment from which to pull the resource',\n optional: true,\n },\n oneTrustAuth: {\n kind: 'parsed',\n parse: String,\n brief:\n 'The OAuth access token with the scopes necessary to access the OneTrust Public APIs',\n optional: true,\n },\n source: {\n kind: 'enum',\n values: Object.values(OneTrustPullSource) as OneTrustPullSource[],\n brief: 'Whether to read the assessments from OneTrust or from a file',\n default: OneTrustPullSource.OneTrust,\n },\n transcendAuth: {\n ...createAuthParameter({\n scopes: [ScopeName.ManageAssessments],\n }),\n optional: true,\n } as TypedFlagParameter<string | undefined, LocalContext>,\n transcendUrl: createTranscendUrlParameter(),\n file: {\n kind: 'parsed',\n parse: String,\n brief:\n 'Path to the file to pull the resource into. Must be a json file!',\n optional: true,\n },\n resource: {\n kind: 'enum',\n values: Object.values(OneTrustPullResource) as OneTrustPullResource[],\n brief:\n 'The resource to pull from OneTrust. For now, only assessments is supported',\n default: OneTrustPullResource.Assessments,\n },\n dryRun: {\n kind: 'boolean',\n brief:\n 'Whether to export the resource to a file rather than sync to Transcend',\n default: false,\n },\n debug: {\n kind: 'boolean',\n brief: 'Whether to print detailed logs in case of error',\n default: false,\n },\n },\n },\n docs: {\n brief: 'Sync OneTrust data',\n fullDescription: `Pulls resources from a OneTrust and syncs them to a Transcend instance. For now, it only supports retrieving OneTrust Assessments.\n\nThis command can be helpful if you are looking to:\n- Pull resources from your OneTrust account.\n- Migrate your resources from your OneTrust account to Transcend.\n\nOneTrust authentication requires an OAuth Token with scope for accessing the assessment endpoints.\nIf syncing the resources to Transcend, you will also need to generate an API key on the Transcend Admin Dashboard.`,\n },\n});\n","import { buildRouteMap } from '@stricli/core';\nimport { syncOtCommand } from './sync-ot/command';\n\nexport const migrationRoutes = buildRouteMap({\n routes: {\n 'sync-ot': syncOtCommand,\n },\n docs: {\n brief: 'Migration commands',\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport {\n createAuthParameter,\n createSombraAuthParameter,\n createTranscendUrlParameter,\n} from '../../../../lib/cli/common-parameters';\nimport { uuidParser } from '../../../../lib/cli/parsers';\nimport type { PullIdentifiersCommandFlags } from '../pull-identifiers/impl';\nimport { buildExampleCommand } from '../../../../lib/docgen/buildExamples';\nimport type { MarkIdentifiersCompletedCommandFlags } from './impl';\nimport { RequestAction } from '@transcend-io/privacy-types';\n\nexport const markIdentifiersCompletedCommand = buildCommand({\n loader: async () => {\n const { markIdentifiersCompleted } = await import('./impl');\n return markIdentifiersCompleted;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [],\n requiresSiloScope: true,\n }),\n dataSiloId: {\n kind: 'parsed',\n parse: uuidParser,\n brief: 'The ID of the data silo to pull in',\n },\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the CSV file where identifiers will be written to',\n default: './cron-identifiers.csv',\n },\n transcendUrl: createTranscendUrlParameter(),\n sombraAuth: createSombraAuthParameter(),\n },\n },\n docs: {\n brief: 'Mark identifiers as completed after processing.',\n fullDescription: `This command takes the output of \"${buildExampleCommand<PullIdentifiersCommandFlags>(\n ['request', 'cron', 'pull-identifiers'],\n {},\n )}\" and notifies Transcend that all of the requests in the CSV have been processed.\nThis is used in the workflow like:\n\n1. Pull identifiers to CSV:\n\n ${buildExampleCommand<PullIdentifiersCommandFlags>(\n ['request', 'cron', 'pull-identifiers'],\n {\n auth: '$TRANSCEND_API_KEY',\n dataSiloId: '70810f2e-cf90-43f6-9776-901a5950599f',\n actions: [RequestAction.Erasure],\n file: './outstanding-requests.csv',\n },\n { argsIndent: 5 },\n )}\n\n2. Run your process to operate on that CSV of requests.\n\n3. Notify Transcend of completion\n\n ${buildExampleCommand<MarkIdentifiersCompletedCommandFlags>(\n ['request', 'cron', 'mark-identifiers-completed'],\n {\n auth: '$TRANSCEND_API_KEY',\n dataSiloId: '70810f2e-cf90-43f6-9776-901a5950599f',\n file: './outstanding-requests.csv',\n },\n { argsIndent: 5 },\n )}\n\nRead more at https://docs.transcend.io/docs/integrations/cron-job-integration.`,\n },\n});\n","import { buildCommand, numberParser } from '@stricli/core';\nimport {\n createAuthParameter,\n createSombraAuthParameter,\n createTranscendUrlParameter,\n} from '../../../../lib/cli/common-parameters';\nimport { uuidParser } from '../../../../lib/cli/parsers';\nimport { RequestAction } from '@transcend-io/privacy-types';\n\nexport const pullIdentifiersCommand = buildCommand({\n loader: async () => {\n const { pullIdentifiers } = await import('./impl');\n return pullIdentifiers;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [],\n requiresSiloScope: true,\n }),\n dataSiloId: {\n kind: 'parsed',\n parse: uuidParser,\n brief: 'The ID of the data silo to pull in',\n },\n actions: {\n kind: 'enum',\n values: Object.values(RequestAction),\n variadic: ',',\n brief: 'The request actions to restart',\n },\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the CSV file where identifiers will be written to',\n default: './cron-identifiers.csv',\n },\n transcendUrl: createTranscendUrlParameter(),\n sombraAuth: createSombraAuthParameter(),\n pageLimit: {\n kind: 'parsed',\n parse: numberParser,\n brief: 'The page limit to use when pulling in pages of identifiers',\n default: '100',\n },\n skipRequestCount: {\n kind: 'boolean',\n brief:\n 'Whether to skip the count of all outstanding requests. This is required to render the progress bar, but can take a long time to run if you have a large number of outstanding requests to process. In that case, we recommend setting skipRequestCount=true so that you can still proceed with fetching the identifiers',\n default: false,\n },\n chunkSize: {\n kind: 'parsed',\n parse: numberParser,\n brief:\n 'Maximum number of rows per CSV file. For large datasets, the output will be automatically split into multiple files to avoid file system size limits. Each file will contain at most this many rows',\n default: '10000',\n },\n },\n },\n docs: {\n brief: 'Pull identifiers of outstanding requests for a data silo to a CSV.',\n fullDescription: `If you are using the cron job integration, you can run this command to pull the outstanding identifiers for the data silo to a CSV.\n\nFor large datasets, the output will be automatically split into multiple CSV files to avoid file system size limits. Use the --chunkSize parameter to control the maximum number of rows per file.\n\nRead more at https://docs.transcend.io/docs/integrations/cron-job-integration.`,\n },\n});\n","import { buildCommand, numberParser } from '@stricli/core';\nimport {\n createAuthParameter,\n createSombraAuthParameter,\n createTranscendUrlParameter,\n} from '../../../../lib/cli/common-parameters';\nimport { uuidParser } from '../../../../lib/cli/parsers';\nimport { RequestAction } from '@transcend-io/privacy-types';\n\nexport const pullProfilesCommand = buildCommand({\n loader: async () => {\n const { pullProfiles } = await import('./impl');\n return pullProfiles;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [],\n requiresSiloScope: true,\n }),\n cronDataSiloId: {\n kind: 'parsed',\n parse: uuidParser,\n brief: 'The ID of the cron data silo to pull in',\n },\n targetDataSiloId: {\n kind: 'parsed',\n parse: uuidParser,\n brief: 'The ID of the target data silo to pull in',\n },\n actions: {\n kind: 'enum',\n values: Object.values(RequestAction),\n variadic: ',',\n brief: 'The request actions to restart',\n },\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the CSV file where identifiers will be written to',\n default: './cron-identifiers.csv',\n },\n fileTarget: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the CSV file where identifiers will be written to',\n default: './cron-identifiers-target.csv',\n },\n transcendUrl: createTranscendUrlParameter(),\n sombraAuth: createSombraAuthParameter(),\n pageLimit: {\n kind: 'parsed',\n parse: numberParser,\n brief: 'The page limit to use when pulling in pages of identifiers',\n default: '100',\n },\n skipRequestCount: {\n kind: 'boolean',\n brief:\n 'Whether to skip the count of all outstanding requests. This is required to render the progress bar, but can take a long time to run if you have a large number of outstanding requests to process. In that case, we recommend setting skipRequestCount=true so that you can still proceed with fetching the identifiers',\n default: false,\n },\n chunkSize: {\n kind: 'parsed',\n parse: numberParser,\n brief:\n 'Maximum number of rows per CSV file. For large datasets, the output will be automatically split into multiple files to avoid file system size limits. Each file will contain at most this many rows',\n default: '10000',\n },\n },\n },\n docs: {\n brief: 'Pull profiles of outstanding requests for a data silo to a CSV.',\n fullDescription: `If you are using the cron job integration, you can run this command to pull the outstanding profiles for the data silo to a CSV.\n\nFor large datasets, the output will be automatically split into multiple CSV files to avoid file system size limits. Use the --chunkSize parameter to control the maximum number of rows per file.\n\nRead more at https://docs.transcend.io/docs/integrations/cron-job-integration.`,\n },\n});\n","import { buildRouteMap } from '@stricli/core';\nimport { markIdentifiersCompletedCommand } from './mark-identifiers-completed/command';\nimport { pullIdentifiersCommand } from './pull-identifiers/command';\nimport { pullProfilesCommand } from './pull-profiles/command';\n\nexport const cronRoutes = buildRouteMap({\n routes: {\n 'pull-identifiers': pullIdentifiersCommand,\n 'pull-profiles': pullProfilesCommand,\n 'mark-identifiers-completed': markIdentifiersCompletedCommand,\n },\n docs: {\n brief: 'Cron commands',\n hideRoute: {\n 'pull-profiles': true,\n },\n },\n});\n","import { buildCommand, numberParser } from '@stricli/core';\nimport {\n RequestAction,\n RequestEnricherStatus,\n ScopeName,\n} from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\nimport { dateParser } from '../../../lib/cli/parsers';\n\nexport const enricherRestartCommand = buildCommand({\n loader: async () => {\n const { enricherRestart } = await import('./impl');\n return enricherRestart;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [ScopeName.ManageRequestCompilation],\n }),\n enricherId: {\n kind: 'parsed',\n parse: String,\n brief: 'The ID of the enricher to restart',\n },\n actions: {\n kind: 'enum',\n values: Object.values(RequestAction),\n variadic: ',',\n brief: 'The request action to restart',\n optional: true,\n },\n requestEnricherStatuses: {\n kind: 'enum',\n values: Object.values(RequestEnricherStatus),\n variadic: ',',\n brief: 'The request enricher statuses to restart',\n optional: true,\n },\n transcendUrl: createTranscendUrlParameter(),\n concurrency: {\n kind: 'parsed',\n parse: numberParser,\n brief: 'The concurrency to use when uploading requests in parallel',\n default: '15',\n },\n requestIds: {\n kind: 'parsed',\n parse: String,\n variadic: ',',\n brief: 'Specify the specific request IDs to restart',\n optional: true,\n },\n createdAtBefore: {\n kind: 'parsed',\n parse: dateParser,\n brief: 'Restart requests that were submitted before this time',\n optional: true,\n },\n createdAtAfter: {\n kind: 'parsed',\n parse: dateParser,\n brief: 'Restart requests that were submitted after this time',\n optional: true,\n },\n },\n },\n docs: {\n brief: 'Bulk restart a particular enricher across a series of DSRs',\n fullDescription: `Bulk restart a particular enricher across a series of DSRs.\n\nThe API key needs the following scopes:\n- Manage Request Compilation`,\n },\n});\n","import { buildCommand, numberParser } from '@stricli/core';\nimport {\n RequestAction,\n RequestStatus,\n ScopeName,\n} from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createSombraAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\nimport { dateParser } from '../../../lib/cli/parsers';\n\nexport const exportCommand = buildCommand({\n loader: async () => {\n const { _export } = await import('./impl');\n return _export;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [ScopeName.ViewRequests, ScopeName.ViewRequestCompilation],\n }),\n sombraAuth: createSombraAuthParameter(),\n actions: {\n kind: 'enum',\n values: Object.values(RequestAction),\n variadic: ',',\n brief: 'The request actions to export',\n optional: true,\n },\n statuses: {\n kind: 'enum',\n values: Object.values(RequestStatus),\n variadic: ',',\n brief: 'The request statuses to export',\n optional: true,\n },\n transcendUrl: createTranscendUrlParameter(),\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the CSV file where identifiers will be written to',\n default: './transcend-request-export.csv',\n },\n concurrency: {\n kind: 'parsed',\n parse: numberParser,\n brief: 'The concurrency to use when uploading requests in parallel',\n default: '50',\n },\n skipRequestIdentifiers: {\n kind: 'boolean',\n brief: 'Skip exporting request identifiers',\n optional: true,\n },\n createdAtBefore: {\n kind: 'parsed',\n parse: dateParser,\n brief: 'Pull requests that were submitted before this time',\n optional: true,\n },\n createdAtAfter: {\n kind: 'parsed',\n parse: dateParser,\n brief: 'Pull requests that were submitted after this time',\n optional: true,\n },\n showTests: {\n kind: 'boolean',\n brief:\n 'Filter for test requests or production requests - when not provided, pulls both',\n optional: true,\n },\n pageLimit: {\n kind: 'parsed',\n parse: numberParser,\n brief: 'The page limit to use when pulling in pages of requests',\n default: '100',\n },\n },\n },\n docs: {\n brief: 'Export privacy requests and request identifiers to a CSV file',\n fullDescription:\n 'Export privacy requests and request identifiers to a CSV file.',\n },\n});\n","import { buildCommand, numberParser } from '@stricli/core';\nimport { RequestAction, ScopeName } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createSombraAuthParameter,\n createTranscendUrlParameter,\n} from '../../../../lib/cli/common-parameters';\nimport { buildExampleCommand } from '../../../../lib/docgen/buildExamples';\nimport type { PullIdentifiersCommandFlags } from './impl';\nimport type { PushIdentifiersCommandFlags } from '../push-identifiers/impl';\n\nexport const pullIdentifiersCommand = buildCommand({\n loader: async () => {\n const { pullIdentifiers } = await import('./impl');\n return pullIdentifiers;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [ScopeName.ViewRequests, ScopeName.ViewRequestCompilation],\n }),\n sombraAuth: createSombraAuthParameter(),\n transcendUrl: createTranscendUrlParameter(),\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the CSV file where requests will be written to',\n default: './manual-enrichment-identifiers.csv',\n },\n actions: {\n kind: 'enum',\n values: Object.values(RequestAction),\n variadic: ',',\n brief: 'The request actions to pull for',\n optional: true,\n },\n concurrency: {\n kind: 'parsed',\n parse: numberParser,\n brief: 'The concurrency to use when uploading requests in parallel',\n default: '100',\n },\n },\n },\n docs: {\n brief: 'Pull identifiers for manual enrichment',\n fullDescription: `This command pulls down the set of privacy requests that are currently pending manual enrichment.\n\nThis is useful for the following workflow:\n\n1. Pull identifiers to CSV:\n\n ${buildExampleCommand<PullIdentifiersCommandFlags>(\n ['request', 'preflight', 'pull-identifiers'],\n {\n file: './enrichment-requests.csv',\n },\n { argsIndent: 5 },\n )}\n\n2. Fill out the CSV with additional identifiers\n\n3. Push updated back to Transcend:\n\n ${buildExampleCommand<PushIdentifiersCommandFlags>(\n ['request', 'preflight', 'push-identifiers'],\n {\n file: './enrichment-requests.csv',\n },\n { argsIndent: 5 },\n )}`,\n },\n});\n","import { buildCommand, numberParser } from '@stricli/core';\nimport { ScopeName } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createSombraAuthParameter,\n createTranscendUrlParameter,\n} from '../../../../lib/cli/common-parameters';\nimport { uuidParser } from '../../../../lib/cli/parsers';\nimport { buildExampleCommand } from '../../../../lib/docgen/buildExamples';\nimport type { PullIdentifiersCommandFlags } from '../pull-identifiers/impl';\nimport type { PushIdentifiersCommandFlags } from './impl';\n\nexport const pushIdentifiersCommand = buildCommand({\n loader: async () => {\n const { pushIdentifiers } = await import('./impl');\n return pushIdentifiers;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [\n ScopeName.ManageRequestIdentities,\n ScopeName.ManageRequestCompilation,\n ],\n }),\n enricherId: {\n kind: 'parsed',\n parse: uuidParser,\n brief: 'The ID of the Request Enricher to upload to',\n },\n sombraAuth: createSombraAuthParameter(),\n transcendUrl: createTranscendUrlParameter(),\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the CSV file where requests will be written to',\n default: './manual-enrichment-identifiers.csv',\n },\n markSilent: {\n kind: 'boolean',\n brief: 'When true, set requests into silent mode before enriching',\n default: false,\n },\n concurrency: {\n kind: 'parsed',\n parse: numberParser,\n brief: 'The concurrency to use when uploading requests in parallel',\n default: '100',\n },\n },\n },\n docs: {\n brief: 'Push identifiers for manual enrichment',\n fullDescription: `This command push up a set of identifiers for a set of requests pending manual enrichment.\n\nThis is useful for the following workflow:\n\n1. Pull identifiers to CSV:\n\n ${buildExampleCommand<PullIdentifiersCommandFlags>(\n ['request', 'preflight', 'pull-identifiers'],\n {\n file: './enrichment-requests.csv',\n },\n { argsIndent: 5 },\n )}\n\n2. Fill out the CSV with additional identifiers\n\n3. Push updated back to Transcend:\n\n ${buildExampleCommand<PushIdentifiersCommandFlags>(\n ['request', 'preflight', 'push-identifiers'],\n {\n file: './enrichment-requests.csv',\n },\n { argsIndent: 5 },\n )}`,\n },\n});\n","import { buildRouteMap } from '@stricli/core';\nimport { pullIdentifiersCommand } from './pull-identifiers/command';\nimport { pushIdentifiersCommand } from './push-identifiers/command';\n\nexport const preflightRoutes = buildRouteMap({\n routes: {\n 'pull-identifiers': pullIdentifiersCommand,\n 'push-identifiers': pushIdentifiersCommand,\n },\n docs: {\n brief: 'Preflight commands',\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport { RequestAction, ScopeName } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createTranscendUrlParameter,\n} from '../../../../lib/cli/common-parameters';\nimport { uuidParser } from '../../../../lib/cli/parsers';\n\nexport const retryRequestDataSilosCommand = buildCommand({\n loader: async () => {\n const { retryRequestDataSilos } = await import('./impl');\n return retryRequestDataSilos;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [ScopeName.ManageRequestCompilation],\n }),\n dataSiloId: {\n kind: 'parsed',\n parse: uuidParser,\n brief: 'The ID of the data silo to pull in',\n },\n actions: {\n kind: 'enum',\n values: Object.values(RequestAction),\n variadic: ',',\n brief: 'The request actions to restart',\n },\n transcendUrl: createTranscendUrlParameter(),\n },\n },\n docs: {\n brief: 'Retry request data silos',\n fullDescription:\n 'This command allows for bulk restarting a set of data silos jobs for open privacy requests. This is equivalent to clicking the \"Wipe and Retry\" button for a particular data silo across a set of privacy requests.',\n },\n});\n","import { buildCommand, numberParser } from '@stricli/core';\nimport { ScopeName } from '@transcend-io/privacy-types';\nimport {\n createAuthParameter,\n createSombraAuthParameter,\n createTranscendUrlParameter,\n} from '../../../lib/cli/common-parameters';\n\nexport const uploadCommand = buildCommand({\n loader: async () => {\n const { upload } = await import('./impl');\n return upload;\n },\n parameters: {\n flags: {\n auth: createAuthParameter({\n scopes: [\n ScopeName.MakeDataSubjectRequest,\n ScopeName.ViewRequestIdentitySettings,\n ScopeName.ViewGlobalAttributes,\n ],\n }),\n file: {\n kind: 'parsed',\n parse: String,\n brief: 'Path to the CSV file of requests to upload',\n default: './requests.csv',\n },\n transcendUrl: createTranscendUrlParameter(),\n cacheFilepath: {\n kind: 'parsed',\n parse: String,\n brief:\n 'The path to the JSON file encoding the metadata used to map the CSV shape to Transcend API',\n default: './transcend-privacy-requests-cache.json',\n },\n requestReceiptFolder: {\n kind: 'parsed',\n parse: String,\n brief:\n 'The path to the folder where receipts of each upload are stored',\n default: './privacy-request-upload-receipts',\n },\n sombraAuth: createSombraAuthParameter(),\n concurrency: {\n kind: 'parsed',\n parse: numberParser,\n brief: 'The concurrency to use when uploading requests in parallel',\n default: '50',\n },\n attributes: {\n kind: 'parsed',\n parse: String,\n brief:\n 'Tag all of the requests with the following attributes. Format: key1:value1;value2,key2:value3;value4',\n default: 'Tags:transcend-cli',\n },\n isTest: {\n kind: 'boolean',\n brief:\n 'Flag whether the requests being uploaded are test requests or regular requests',\n default: false,\n },\n isSilent: {\n kind: 'boolean',\n brief:\n 'Flag whether the requests being uploaded should be submitted in silent mode',\n default: true,\n },\n skipSendingReceipt: {\n kind: 'boolean',\n brief: 'Flag whether to skip sending of the receipt email',\n default: false,\n },\n emailIsVerified: {\n kind: 'boolean',\n brief:\n 'Indicate whether the email address being uploaded is pre-verified. Set to false to send a verification email',\n default: true,\n },\n skipFilterStep: {\n kind: 'boolean',\n brief: 'When true, skip the interactive step to filter down the CSV',\n default: false,\n },\n dryRun: {\n kind: 'boolean',\n brief:\n 'When true, perform a dry run of the upload instead of calling the API to submit the requests',\n default: false,\n },\n debug: {\n kind: 'boolean',\n brief: 'Debug logging',\n default: false,\n },\n defaultPhoneCountryCode: {\n kind: 'parsed',\n parse: String,\n brief:\n 'When uploading phone numbers, if the phone number is missing a country code, assume this country code',\n default: '1',\n },\n },\n },\n docs: {\n brief: 'Upload a set of requests from a CSV',\n fullDescription: `Upload a set of requests from a CSV.\n\nThis command prompts you to map the shape of the CSV to the shape of the Transcend API. There is no requirement for the shape of the incoming CSV, as the script will handle the mapping process.\n\nThe script will also produce a JSON cache file that allows for the mappings to be preserved between runs.`,\n },\n});\n","import { buildRouteMap } from '@stricli/core';\nimport { approveCommand } from './approve/command';\nimport { cancelCommand } from './cancel/command';\nimport { cronRoutes } from './cron/routes';\nimport { downloadFilesCommand } from './download-files/command';\nimport { enricherRestartCommand } from './enricher-restart/command';\nimport { exportCommand } from './export/command';\nimport { markSilentCommand } from './mark-silent/command';\nimport { notifyAdditionalTimeCommand } from './notify-additional-time/command';\nimport { preflightRoutes } from './preflight/routes';\nimport { rejectUnverifiedIdentifiersCommand } from './reject-unverified-identifiers/command';\nimport { restartCommand } from './restart/command';\nimport { skipPreflightJobsCommand } from './skip-preflight-jobs/command';\nimport { systemRoutes } from './system/routes';\nimport { uploadCommand } from './upload/command';\n\nexport const requestRoutes = buildRouteMap({\n routes: {\n approve: approveCommand,\n upload: uploadCommand,\n 'download-files': downloadFilesCommand,\n cancel: cancelCommand,\n restart: restartCommand,\n 'notify-additional-time': notifyAdditionalTimeCommand,\n 'mark-silent': markSilentCommand,\n 'enricher-restart': enricherRestartCommand,\n 'reject-unverified-identifiers': rejectUnverifiedIdentifiersCommand,\n export: exportCommand,\n 'skip-preflight-jobs': skipPreflightJobsCommand,\n system: systemRoutes,\n preflight: preflightRoutes,\n cron: cronRoutes,\n },\n docs: {\n brief: 'All commands related to DSR requests',\n },\n});\n"]}
|
package/dist/chunk-NC6VWOMN.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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 _chunkABKDAPPRcjs = require('./chunk-ABKDAPPR.cjs');var _chunk55B57ZAYcjs = require('./chunk-55B57ZAY.cjs');var _chunkZUNVPK23cjs = require('./chunk-ZUNVPK23.cjs');var _chunkXXFLFF7Qcjs = require('./chunk-XXFLFF7Q.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=_chunkXXFLFF7Qcjs.r}){let s=await _chunk55B57ZAYcjs.wc.call(void 0, x,{});_chunkZUNVPK23cjs.a.info(_colors2.default.magenta("Logging in using email and password."));let{roles:d,loginCookie:k}=await _chunk55B57ZAYcjs.Kd.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 _chunk55B57ZAYcjs.Ld.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 _chunk55B57ZAYcjs.sd.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 _chunk55B57ZAYcjs.Nd.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 _chunk55B57ZAYcjs.Md.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(_chunkABKDAPPRcjs.ia),_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-NC6VWOMN.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/cli/cli/dist/chunk-NC6VWOMN.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":"AAAA,mfAAyC,wDAAkF,wDAAyC,wDAAyC,oCCAnL,gFAUP,MAoBnB,SAAsBA,CAAAA,CAA4B,CAChD,KAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CACA,MAAA,CAAAC,CAAAA,CACA,WAAA,CAAAC,CAAAA,CACA,oBAAA,CAAAC,CAAAA,CACA,oBAAA,CAAAC,CAAAA,CAAuB,CAAA,CAAA,CACvB,eAAA,CAAAC,CAAAA,CAAkB,CAAA,CAAA,CAClB,YAAA,CAAAC,CAAAA,CAAeC,mBACjB,CA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AAkBD,CAAAA,CAAK,YAAA,CAAa,IAAA,CACpC,cAAA,CAAgBA,CAAAA,CAAK,YAAA,CAAa,EAAA,CAClC,MAAA,CAAAQ,CACF,CAAC,CAAA,CACDd,mBAAAA,CAAO,IAAA,CACLC,gBAAAA,CAAO,KAAA,CACL,CAAA,iCAAA,EAAoCK,CAAAA,CAAK,YAAA,CAAa,IAAI,CAAA,eAAA,EAAkBd,CAAW,CAAA,EAAA,CACzF,CACF,CACF,CAAA,KAEEe,CAAAA,CAAQ,IAAA,CAAK,CACX,gBAAA,CAAkBD,CAAAA,CAAK,YAAA,CAAa,IAAA,CACpC,cAAA,CAAgBA,CAAAA,CAAK,YAAA,CAAa,EAAA,CAClC,MAAA,CAAQ,EACV,CAAC,CAEL,CAAA,KAAA,CAASU,CAAAA,CAAK,CACZhB,mBAAAA,CAAO,KAAA,CACLC,gBAAAA,CAAO,GAAA,CACL,CAAA,0CAAA,EAA6CK,CAAAA,CAAK,YAAA,CAAa,IAAI,CAAA,KAAA,EAAQU,CAAAA,CAAI,OAAO,CAAA,CAAA","file":"/home/runner/work/cli/cli/dist/chunk-NC6VWOMN.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"]}
|
package/dist/chunk-Q2RJZGYW.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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 _chunk55B57ZAYcjs = require('./chunk-55B57ZAY.cjs');var _chunkZUNVPK23cjs = require('./chunk-ZUNVPK23.cjs');var _chunkXXFLFF7Qcjs = require('./chunk-XXFLFF7Q.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=_chunkXXFLFF7Qcjs.r,sleepSeconds:f=10}){let y=await _chunk55B57ZAYcjs.yc.call(void 0, i,c,n);_chunkZUNVPK23cjs.a.info(_colors2.default.magenta(`Reading "${r}" from disk`));let o=_chunk55B57ZAYcjs.sc.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=_chunkXXFLFF7Qcjs.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} (${_chunkXXFLFF7Qcjs.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=_chunkXXFLFF7Qcjs.r}){let f=_chunk55B57ZAYcjs.xc.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 _chunk55B57ZAYcjs.Hd.call(void 0, f,{requestId:u,dataSiloId:s});try{await _chunk55B57ZAYcjs.ug.call(void 0, f,_chunk55B57ZAYcjs.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=_chunkXXFLFF7Qcjs.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 _chunk55B57ZAYcjs.yc.call(void 0, y,s,c),w=_chunk55B57ZAYcjs.xc.call(void 0, y,s),d=0;o||(d=await _chunk55B57ZAYcjs.Id.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-Q2RJZGYW.cjs.map
|