@transcend-io/cli 8.37.2 → 8.38.1
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 +24 -8
- package/dist/{api-keys-Bvt2HbSv.cjs → api-keys-y8Txn6tT.cjs} +2 -2
- package/dist/{api-keys-Bvt2HbSv.cjs.map → api-keys-y8Txn6tT.cjs.map} +1 -1
- package/dist/{app-CdWFyBYu.cjs → app-_ZoYl64o.cjs} +18 -18
- package/dist/{app-CdWFyBYu.cjs.map → app-_ZoYl64o.cjs.map} +1 -1
- package/dist/bin/bash-complete.cjs +1 -1
- package/dist/bin/cli.cjs +1 -1
- package/dist/bin/deprecated-command.cjs +1 -1
- package/dist/{code-scanning-BZzwKEfY.cjs → code-scanning-ByZQgqip.cjs} +2 -2
- package/dist/{code-scanning-BZzwKEfY.cjs.map → code-scanning-ByZQgqip.cjs.map} +1 -1
- package/dist/{command-DNcjQs8y.cjs → command-CLULRNcd.cjs} +2 -2
- package/dist/{command-DNcjQs8y.cjs.map → command-CLULRNcd.cjs.map} +1 -1
- package/dist/{consent-manager-oip5m3XC.cjs → consent-manager-CJZ5GTmv.cjs} +2 -2
- package/dist/{consent-manager-oip5m3XC.cjs.map → consent-manager-CJZ5GTmv.cjs.map} +1 -1
- package/dist/{constants-K6pQQtc7.cjs → constants-CzmvL6Mw.cjs} +2 -2
- package/dist/{constants-K6pQQtc7.cjs.map → constants-CzmvL6Mw.cjs.map} +1 -1
- package/dist/{cron-lijiEqFA.cjs → cron-Ts7kHP6_.cjs} +2 -2
- package/dist/{cron-lijiEqFA.cjs.map → cron-Ts7kHP6_.cjs.map} +1 -1
- package/dist/{data-inventory-BKAQGjFN.cjs → data-inventory-D0Tt_vAm.cjs} +4 -4
- package/dist/{data-inventory-BKAQGjFN.cjs.map → data-inventory-D0Tt_vAm.cjs.map} +1 -1
- package/dist/{dataFlowsToDataSilos-CnvG2jqy.cjs → dataFlowsToDataSilos-B7nTxawV.cjs} +2 -2
- package/dist/{dataFlowsToDataSilos-CnvG2jqy.cjs.map → dataFlowsToDataSilos-B7nTxawV.cjs.map} +1 -1
- package/dist/{impl-B4OVz7FC.cjs → impl-1qwMfsU4.cjs} +2 -2
- package/dist/{impl-B4OVz7FC.cjs.map → impl-1qwMfsU4.cjs.map} +1 -1
- package/dist/{impl-LMp29vxd.cjs → impl-8HXqFDdD.cjs} +2 -2
- package/dist/{impl-LMp29vxd.cjs.map → impl-8HXqFDdD.cjs.map} +1 -1
- package/dist/{impl-57HOh2c3.cjs → impl-AZPWCkCp.cjs} +2 -2
- package/dist/{impl-57HOh2c3.cjs.map → impl-AZPWCkCp.cjs.map} +1 -1
- package/dist/{impl-DhnCAbU-.cjs → impl-B61wd2KQ.cjs} +2 -2
- package/dist/{impl-DhnCAbU-.cjs.map → impl-B61wd2KQ.cjs.map} +1 -1
- package/dist/{impl-XwC7A99P.cjs → impl-B8rg6CMv.cjs} +2 -2
- package/dist/{impl-XwC7A99P.cjs.map → impl-B8rg6CMv.cjs.map} +1 -1
- package/dist/{impl-Dj2fTDNO.cjs → impl-BIjDq-3S.cjs} +2 -2
- package/dist/{impl-Dj2fTDNO.cjs.map → impl-BIjDq-3S.cjs.map} +1 -1
- package/dist/{impl-DbxzDk8h.cjs → impl-BPxZw3LN.cjs} +2 -2
- package/dist/{impl-DbxzDk8h.cjs.map → impl-BPxZw3LN.cjs.map} +1 -1
- package/dist/{impl-oYFKp06U.cjs → impl-BczOEWXK.cjs} +2 -2
- package/dist/{impl-oYFKp06U.cjs.map → impl-BczOEWXK.cjs.map} +1 -1
- package/dist/{impl-BtuKKdl3.cjs → impl-BeUsmMIp.cjs} +2 -2
- package/dist/{impl-BtuKKdl3.cjs.map → impl-BeUsmMIp.cjs.map} +1 -1
- package/dist/{impl-DL2j8g1C.cjs → impl-Bhv353rp.cjs} +2 -2
- package/dist/{impl-DL2j8g1C.cjs.map → impl-Bhv353rp.cjs.map} +1 -1
- package/dist/{impl-W6jE_UV0.cjs → impl-BiPKUZQ2.cjs} +2 -2
- package/dist/{impl-W6jE_UV0.cjs.map → impl-BiPKUZQ2.cjs.map} +1 -1
- package/dist/{impl-D-IWtHQi.cjs → impl-BvrbCovf.cjs} +2 -2
- package/dist/{impl-D-IWtHQi.cjs.map → impl-BvrbCovf.cjs.map} +1 -1
- package/dist/{impl-DSNgFKP_.cjs → impl-BxKSXO7j.cjs} +2 -2
- package/dist/{impl-DSNgFKP_.cjs.map → impl-BxKSXO7j.cjs.map} +1 -1
- package/dist/{impl-CCdxbRmg.cjs → impl-ByavdlGX.cjs} +2 -2
- package/dist/{impl-CCdxbRmg.cjs.map → impl-ByavdlGX.cjs.map} +1 -1
- package/dist/{impl-C2e4xVvX.cjs → impl-C6Vv_fyU.cjs} +2 -2
- package/dist/{impl-C2e4xVvX.cjs.map → impl-C6Vv_fyU.cjs.map} +1 -1
- package/dist/{impl-ebVxRYAc.cjs → impl-CGSBsFc7.cjs} +2 -2
- package/dist/{impl-ebVxRYAc.cjs.map → impl-CGSBsFc7.cjs.map} +1 -1
- package/dist/{impl-Bf_hLViY.cjs → impl-ChHjX-p0.cjs} +2 -2
- package/dist/{impl-Bf_hLViY.cjs.map → impl-ChHjX-p0.cjs.map} +1 -1
- package/dist/{impl-CdfA8kxo.cjs → impl-ChqwjO34.cjs} +2 -2
- package/dist/{impl-CdfA8kxo.cjs.map → impl-ChqwjO34.cjs.map} +1 -1
- package/dist/{impl-Bmln6D88.cjs → impl-CrieEyzk.cjs} +2 -2
- package/dist/{impl-Bmln6D88.cjs.map → impl-CrieEyzk.cjs.map} +1 -1
- package/dist/{impl-DV5f54rm.cjs → impl-CujcX7vE.cjs} +2 -2
- package/dist/{impl-DV5f54rm.cjs.map → impl-CujcX7vE.cjs.map} +1 -1
- package/dist/{impl-BszlCtcR.cjs → impl-D9OOb2JE.cjs} +2 -2
- package/dist/{impl-BszlCtcR.cjs.map → impl-D9OOb2JE.cjs.map} +1 -1
- package/dist/{impl-C65nk0G8.cjs → impl-DCKUxoWY.cjs} +2 -2
- package/dist/{impl-C65nk0G8.cjs.map → impl-DCKUxoWY.cjs.map} +1 -1
- package/dist/{impl-CMwmo2vR.cjs → impl-DG_MFWMU.cjs} +2 -2
- package/dist/{impl-CMwmo2vR.cjs.map → impl-DG_MFWMU.cjs.map} +1 -1
- package/dist/{impl-BVmw0mE4.cjs → impl-DHIiB7cV.cjs} +2 -2
- package/dist/{impl-BVmw0mE4.cjs.map → impl-DHIiB7cV.cjs.map} +1 -1
- package/dist/{impl-58WnFNmn.cjs → impl-DYHQz-Wu.cjs} +2 -2
- package/dist/{impl-58WnFNmn.cjs.map → impl-DYHQz-Wu.cjs.map} +1 -1
- package/dist/{impl-BqIqzp40.cjs → impl-D_4LdDL9.cjs} +2 -2
- package/dist/{impl-BqIqzp40.cjs.map → impl-D_4LdDL9.cjs.map} +1 -1
- package/dist/{impl-k61p_VQY.cjs → impl-D_tCWU8I.cjs} +2 -2
- package/dist/{impl-k61p_VQY.cjs.map → impl-D_tCWU8I.cjs.map} +1 -1
- package/dist/{impl-CkfOZzpI.cjs → impl-DhKyE3ja.cjs} +2 -2
- package/dist/{impl-CkfOZzpI.cjs.map → impl-DhKyE3ja.cjs.map} +1 -1
- package/dist/impl-DkyT66jZ.cjs +2 -0
- package/dist/impl-DkyT66jZ.cjs.map +1 -0
- package/dist/{impl-BkEg-Nm6.cjs → impl-DpkTAuVd.cjs} +2 -2
- package/dist/{impl-BkEg-Nm6.cjs.map → impl-DpkTAuVd.cjs.map} +1 -1
- package/dist/{impl-D9-ZQmJB.cjs → impl-DvFcMtV7.cjs} +2 -2
- package/dist/{impl-D9-ZQmJB.cjs.map → impl-DvFcMtV7.cjs.map} +1 -1
- package/dist/{impl-BSS_avMv.cjs → impl-Dzi2-R-5.cjs} +3 -3
- package/dist/{impl-BSS_avMv.cjs.map → impl-Dzi2-R-5.cjs.map} +1 -1
- package/dist/{impl-kMebV10f.cjs → impl-Dzyo_6if.cjs} +2 -2
- package/dist/{impl-kMebV10f.cjs.map → impl-Dzyo_6if.cjs.map} +1 -1
- package/dist/{impl-ClujxTb8.cjs → impl-HogBsNBk.cjs} +2 -2
- package/dist/{impl-ClujxTb8.cjs.map → impl-HogBsNBk.cjs.map} +1 -1
- package/dist/{impl-BFRrE04X.cjs → impl-JgMjiEBD.cjs} +2 -2
- package/dist/{impl-BFRrE04X.cjs.map → impl-JgMjiEBD.cjs.map} +1 -1
- package/dist/{impl-1-1sg4WF.cjs → impl-JkHt--m4.cjs} +3 -3
- package/dist/{impl-1-1sg4WF.cjs.map → impl-JkHt--m4.cjs.map} +1 -1
- package/dist/{impl-MrsSr72p.cjs → impl-_wktLwfn.cjs} +2 -2
- package/dist/{impl-MrsSr72p.cjs.map → impl-_wktLwfn.cjs.map} +1 -1
- package/dist/{impl-DU85U1jO.cjs → impl-afJ-fKK4.cjs} +2 -2
- package/dist/{impl-DU85U1jO.cjs.map → impl-afJ-fKK4.cjs.map} +1 -1
- package/dist/{impl-KAorCmlT.cjs → impl-brt-L_kS.cjs} +2 -2
- package/dist/{impl-KAorCmlT.cjs.map → impl-brt-L_kS.cjs.map} +1 -1
- package/dist/{impl-SZp3iTUp.cjs → impl-iuvcsdad.cjs} +2 -2
- package/dist/{impl-SZp3iTUp.cjs.map → impl-iuvcsdad.cjs.map} +1 -1
- package/dist/{impl-Cb64HwGx.cjs → impl-kmDIC1No.cjs} +2 -2
- package/dist/{impl-Cb64HwGx.cjs.map → impl-kmDIC1No.cjs.map} +1 -1
- package/dist/{impl-DGel0ZLe.cjs → impl-zSp6Nypz.cjs} +2 -2
- package/dist/{impl-DGel0ZLe.cjs.map → impl-zSp6Nypz.cjs.map} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +187 -62
- package/dist/manual-enrichment-CW8iihdb.cjs +2 -0
- package/dist/{manual-enrichment-C6h9gjY1.cjs.map → manual-enrichment-CW8iihdb.cjs.map} +1 -1
- package/dist/{pooling-DLEGcLtt.cjs → pooling-Dw0a42I_.cjs} +2 -2
- package/dist/{pooling-DLEGcLtt.cjs.map → pooling-Dw0a42I_.cjs.map} +1 -1
- package/dist/{preference-management-B36PQuMK.cjs → preference-management-CkmW6Z91.cjs} +6 -6
- package/dist/preference-management-CkmW6Z91.cjs.map +1 -0
- package/dist/{syncConfigurationToTranscend-DKliAJhK.cjs → syncConfigurationToTranscend-DkeLrq-I.cjs} +138 -129
- package/dist/syncConfigurationToTranscend-DkeLrq-I.cjs.map +1 -0
- package/dist/{uploadConsents-MtgCk8B0.cjs → uploadConsents-zr1Hg-JE.cjs} +2 -2
- package/dist/{uploadConsents-MtgCk8B0.cjs.map → uploadConsents-zr1Hg-JE.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/impl-DXKJH0AZ.cjs +0 -2
- package/dist/impl-DXKJH0AZ.cjs.map +0 -1
- package/dist/manual-enrichment-C6h9gjY1.cjs +0 -2
- package/dist/preference-management-B36PQuMK.cjs.map +0 -1
- package/dist/syncConfigurationToTranscend-DKliAJhK.cjs.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./constants-
|
|
2
|
-
//# sourceMappingURL=cron-
|
|
1
|
+
const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./constants-CzmvL6Mw.cjs`),n=require(`./syncConfigurationToTranscend-DkeLrq-I.cjs`),r=require(`./logger-DQwEYtSS.cjs`);let i=require(`@transcend-io/privacy-types`),a=require(`@transcend-io/type-utils`),o=require(`colors`);o=e.t(o);let s=require(`io-ts`);s=e.t(s);let c=require(`cli-progress`);c=e.t(c);const l=s.type({identifier:s.string,type:s.string,coreIdentifier:s.string,dataSiloId:s.string,requestId:s.string,nonce:s.string,requestCreatedAt:s.string,daysUntilOverdue:s.number,attributes:s.array(s.type({key:s.string,values:s.array(s.string)}))});async function u(e,{dataSiloId:t,limit:n=100,offset:r=0,requestType:i}){try{let o=await e.get(`v1/data-silo/${t}/pending-requests/${i}`,{searchParams:{offset:r,limit:n}}).json(),{items:c}=(0,a.decodeCodec)(s.type({items:s.array(l)}),o);return c}catch(e){throw Error(`Received an error from server: ${e?.response?.body||e?.message}`)}}const d=s.type({nonce:s.string,identifier:s.string});async function f(e,{nonce:t,identifier:n}){try{return await e.put(`v1/data-silo`,{headers:{"x-transcend-nonce":t},json:{profiles:[{profileId:n}]}}),!0}catch(e){if(e.response?.statusCode===409)return!1;throw Error(`Received an error from server: ${e?.response?.body||e?.message}`)}}async function p({file:e,dataSiloId:i,auth:a,sombraAuth:s,concurrency:l=100,transcendUrl:u=t.a,sleepSeconds:p=10}){let m=await n.ii(u,a,s);r.t.info(o.default.magenta(`Reading "${e}" from disk`));let h=n.ui(e,d);r.t.info(o.default.magenta(`Notifying Transcend for data silo "${i}" marking "${h.length}" identifiers as completed.`));let g=new Date().getTime(),_=new c.default.SingleBar({},c.default.Presets.shades_classic),v=0,y=0,b=0;_.start(h.length,0);let x=n.Rs(h,l),S=x.length;await n.js(x,async(e,t)=>{r.t.info(o.default.blue(`Processing chunk ${t+1}/${S} (${n.Rs.length} items)`)),await n.As(e,async e=>{try{await f(m,e)?v+=1:y+=1}catch(t){r.t.error(o.default.red(`Error notifying Transcend for identifier "${e.identifier}" - ${t?.message}`)),b+=1}_.update(v+y)}),p>0&&t<S-1&&(r.t.info(o.default.yellow(`Sleeping for ${p}s before next chunk...`)),await new Promise(e=>{setTimeout(e,p*1e3)}))}),_.stop();let C=new Date().getTime()-g;if(r.t.info(o.default.green(`Successfully notified Transcend for ${v} identifiers in "${C/1e3}" seconds!`)),y&&r.t.info(o.default.magenta(`There were ${y} identifiers that were not in a state to be updated.They likely have already been resolved.`)),b)throw r.t.error(o.default.red(`There were ${b} identifiers that failed to be updated. Please review the logs for more information.`)),Error(`Failed to update all identifiers`);return h.length}async function m({requestIds:e,dataSiloId:a,auth:s,concurrency:l=100,status:u=i.RequestDataSiloStatus.Resolved,transcendUrl:d=t.a}){let f=n.ai(d,s),p=new Date().getTime(),m=new c.default.SingleBar({},c.default.Presets.shades_classic);r.t.info(o.default.magenta(`Notifying Transcend for data silo "${a}" marking "${e.length}" requests as completed.`));let h=0;m.start(e.length,0),await n.As(e,async e=>{let t=await n.qn(f,{requestId:e,dataSiloId:a});try{await n.i(f,n.ao,{requestDataSiloId:t.id,status:u})}catch(e){if(!e.message.includes(`Client error: Request must be active:`)&&!e.message.includes(`Failed to find RequestDataSilo`))throw e}h+=1,m.update(h)},{concurrency:l}),m.stop();let g=new Date().getTime()-p;return r.t.info(o.default.green(`Successfully notified Transcend in "${g/1e3}" seconds!`)),e.length}async function h({dataSiloId:e,auth:i,sombraAuth:a,actions:s,apiPageSize:l=100,savePageSize:d=1e3,onSave:f,transcendUrl:p=t.a,skipRequestCount:m=!1}){if(d%l!==0)throw Error(`savePageSize must be a multiple of apiPageSize. savePageSize: ${d}, apiPageSize: ${l}`);let h=await n.ii(p,i,a),g=n.ai(p,i),_=0;m||(_=await n.Kn(g,{dataSiloId:e})),r.t.info(o.default.magenta(`Pulling ${m?`all`:_} outstanding request identifiers for data silo: "${e}" for requests of types "${s.join(`", "`)}"`));let v=new Date().getTime(),y=new c.default.SingleBar({},c.default.Presets.shades_classic),b=new Set,x=[],S=[];m||y.start(_,0),await n.js(s,async t=>{let n=0,i=!0;for(;i;){let a=await u(h,{dataSiloId:e,limit:l,offset:n,requestType:t}),s=a.map(e=>(b.add(e.requestId),{...e,action:t})),c=s.map(({attributes:e,...t})=>({...t,...e.reduce((e,t)=>Object.assign(e,{[t.key]:t.values.join(`,`)}),{})}));x.push(...s),S.push(...c),S.length>=d&&(await f(S),S=[]),i=a.length===l,n+=l,m?r.t.info(o.default.magenta(`Pulled ${a.length} outstanding identifiers for ${b.size} requests`)):y.update(b.size)}}),S.length>0&&await f(S),m||y.stop();let C=new Date().getTime()-v;return r.t.info(o.default.green(`Successfully pulled ${x.length} outstanding identifiers from ${b.size} requests in "${C/1e3}" seconds!`)),{identifiers:x}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return h}});
|
|
2
|
+
//# sourceMappingURL=cron-Ts7kHP6_.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cron-lijiEqFA.cjs","names":["t","t","DEFAULT_TRANSCEND_API","createSombraGotInstance","readCsv","cliProgress","chunk","map","mapSeries","RequestDataSiloStatus","DEFAULT_TRANSCEND_API","buildTranscendGraphQLClient","cliProgress","map","fetchRequestDataSilo","makeGraphQLRequest","CHANGE_REQUEST_DATA_SILO_STATUS","DEFAULT_TRANSCEND_API","createSombraGotInstance","buildTranscendGraphQLClient","fetchRequestDataSiloActiveCount","cliProgress","mapSeries"],"sources":["../src/lib/cron/pullCronPageOfIdentifiers.ts","../src/lib/cron/markCronIdentifierCompleted.ts","../src/lib/cron/pushCronIdentifiersFromCsv.ts","../src/lib/cron/markRequestDataSiloIdsCompleted.ts","../src/lib/cron/pullChunkedCustomSiloOutstandingIdentifiers.ts"],"sourcesContent":["import * as t from 'io-ts';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport { RequestAction } from '@transcend-io/privacy-types';\nimport type { Got } from 'got';\n\nexport const CronIdentifier = t.type({\n /** The identifier value */\n identifier: t.string,\n /** The type of identifier */\n type: t.string,\n /** The core identifier of the request */\n coreIdentifier: t.string,\n /** The ID of the underlying data silo */\n dataSiloId: t.string,\n /** The ID of the underlying request */\n requestId: t.string,\n /** The request nonce */\n nonce: t.string,\n /** The time the request was created */\n requestCreatedAt: t.string,\n /** The number of days until the request is overdue */\n daysUntilOverdue: t.number,\n /** Request attributes */\n attributes: t.array(\n t.type({\n key: t.string,\n values: t.array(t.string),\n }),\n ),\n});\n\n/** Type override */\nexport type CronIdentifier = t.TypeOf<typeof CronIdentifier>;\n\n/**\n * Pull a offset of identifiers for a cron job\n *\n * @see https://docs.transcend.io/docs/api-reference/GET/v1/data-silo/(id)/pending-requests/(type)\n * @param sombra - Sombra instance configured to make requests\n * @param options - Additional options\n * @returns Successfully submitted request\n */\nexport async function pullCronPageOfIdentifiers(\n sombra: Got,\n {\n dataSiloId,\n limit = 100,\n offset = 0,\n requestType,\n }: {\n /** Data Silo ID */\n dataSiloId: string;\n /** Type of request */\n requestType: RequestAction;\n /** Number of identifiers to pull in */\n limit?: number;\n /** Page to pull in */\n offset?: number;\n },\n): Promise<CronIdentifier[]> {\n try {\n // Make the GraphQL request\n const response = await sombra\n .get(`v1/data-silo/${dataSiloId}/pending-requests/${requestType}`, {\n searchParams: {\n offset,\n limit,\n },\n })\n .json();\n\n const { items } = decodeCodec(\n t.type({\n items: t.array(CronIdentifier),\n }),\n response,\n );\n return items;\n } catch (err) {\n throw new Error(\n `Received an error from server: ${err?.response?.body || err?.message}`,\n );\n }\n}\n","import type { Got } from 'got';\nimport * as t from 'io-ts';\n\n/**\n * Minimal set required to mark as completed\n */\nexport const CronIdentifierPush = t.type({\n nonce: t.string,\n identifier: t.string,\n});\n\n/** Type override */\nexport type CronIdentifierPush = t.TypeOf<typeof CronIdentifierPush>;\n\n/**\n * Mark an identifier output by the cron job as completed.\n *\n * @see https://docs.transcend.io/docs/api-reference/PUT/v1/data-silo\n * @param sombra - Sombra instance configured to make requests\n * @param options - Additional options\n * @returns Successfully submitted request, false if not in a state to update\n */\nexport async function markCronIdentifierCompleted(\n sombra: Got,\n { nonce, identifier }: CronIdentifierPush,\n): Promise<boolean> {\n try {\n // Make the GraphQL request\n await sombra.put('v1/data-silo', {\n headers: {\n 'x-transcend-nonce': nonce,\n },\n json: {\n profiles: [\n {\n profileId: identifier,\n },\n ],\n },\n });\n return true;\n } catch (err) {\n // handle gracefully\n if (err.response?.statusCode === 409) {\n return false;\n }\n throw new Error(\n `Received an error from server: ${err?.response?.body || err?.message}`,\n );\n }\n}\n","import { map, mapSeries } from '../bluebird';\nimport { chunk } from 'lodash-es';\nimport { createSombraGotInstance } from '../graphql';\nimport colors from 'colors';\nimport {\n markCronIdentifierCompleted,\n CronIdentifierPush,\n} from './markCronIdentifierCompleted';\nimport cliProgress from 'cli-progress';\nimport { logger } from '../../logger';\nimport { readCsv } from '../requests';\nimport { DEFAULT_TRANSCEND_API } from '../../constants';\n\n/**\n * Given a CSV of cron job outputs, mark all requests as completed in Transcend\n *\n * @param options - Options\n * @returns Number of items marked as completed\n */\nexport async function pushCronIdentifiersFromCsv({\n file,\n dataSiloId,\n auth,\n sombraAuth,\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n sleepSeconds = 10,\n}: {\n /** CSV file path */\n file: string;\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** Upload concurrency */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Sleep time in seconds between chunks of concurrent calls */\n sleepSeconds?: number;\n}): Promise<number> {\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, sombraAuth);\n\n // Read from CSV\n logger.info(colors.magenta(`Reading \"${file}\" from disk`));\n const activeResults = readCsv(file, CronIdentifierPush);\n\n // Notify Transcend\n logger.info(\n colors.magenta(\n `Notifying Transcend for data silo \"${dataSiloId}\" marking \"${activeResults.length}\" identifiers as completed.`,\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 let successCount = 0;\n let failureCount = 0;\n let errorCount = 0;\n progressBar.start(activeResults.length, 0);\n\n // Process in chunks with sleep intervals\n const chunks = chunk(activeResults, concurrency);\n const totalChunks = chunks.length;\n const processChunk = async (\n items: CronIdentifierPush[],\n chunkIndex: number,\n ): Promise<void> => {\n logger.info(\n colors.blue(\n `Processing chunk ${chunkIndex + 1}/${totalChunks} (${\n chunk.length\n } items)`,\n ),\n );\n\n // Process the items of the chunk concurrently\n await map(items, async (identifier) => {\n try {\n const success = await markCronIdentifierCompleted(sombra, identifier);\n if (success) {\n successCount += 1;\n } else {\n failureCount += 1;\n }\n } catch (e) {\n logger.error(\n colors.red(\n `Error notifying Transcend for identifier \"${identifier.identifier}\" - ${e?.message}`,\n ),\n );\n errorCount += 1;\n }\n progressBar.update(successCount + failureCount);\n });\n\n // Sleep between chunks (except for the last chunk)\n if (sleepSeconds > 0 && chunkIndex < totalChunks - 1) {\n logger.info(\n colors.yellow(`Sleeping for ${sleepSeconds}s before next chunk...`),\n );\n\n await new Promise((resolve) => {\n setTimeout(resolve, sleepSeconds * 1000);\n });\n }\n };\n\n // Process all chunks sequentially\n await mapSeries(chunks, processChunk);\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully notified Transcend for ${successCount} identifiers in \"${\n totalTime / 1000\n }\" seconds!`,\n ),\n );\n if (failureCount) {\n logger.info(\n colors.magenta(\n `There were ${failureCount} identifiers that were not in a state to be updated.` +\n 'They likely have already been resolved.',\n ),\n );\n }\n if (errorCount) {\n logger.error(\n colors.red(\n `There were ${errorCount} identifiers that failed to be updated. Please review the logs for more information.`,\n ),\n );\n throw new Error('Failed to update all identifiers');\n }\n return activeResults.length;\n}\n","import { map } from '../bluebird';\nimport colors from 'colors';\nimport { logger } from '../../logger';\nimport {\n CHANGE_REQUEST_DATA_SILO_STATUS,\n fetchRequestDataSilo,\n makeGraphQLRequest,\n buildTranscendGraphQLClient,\n} from '../graphql';\nimport cliProgress from 'cli-progress';\nimport { DEFAULT_TRANSCEND_API } from '../../constants';\nimport { RequestDataSiloStatus } from '@transcend-io/privacy-types';\n\n/**\n * Given a CSV of Request IDs, mark associated RequestDataSilos as completed\n *\n * @param options - Options\n * @returns Number of items marked as completed\n */\nexport async function markRequestDataSiloIdsCompleted({\n requestIds,\n dataSiloId,\n auth,\n concurrency = 100,\n status = RequestDataSiloStatus.Resolved,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The list of request ids to mark as completed */\n requestIds: string[];\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** Status to update requests to */\n status?: RequestDataSiloStatus;\n /** Upload concurrency */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar(\n {},\n cliProgress.Presets.shades_classic,\n );\n\n // Notify Transcend\n logger.info(\n colors.magenta(\n `Notifying Transcend for data silo \"${dataSiloId}\" marking \"${requestIds.length}\" requests as completed.`,\n ),\n );\n\n let total = 0;\n progressBar.start(requestIds.length, 0);\n await map(\n requestIds,\n async (requestId) => {\n const requestDataSilo = await fetchRequestDataSilo(client, {\n requestId,\n dataSiloId,\n });\n\n try {\n await makeGraphQLRequest<{\n /** Whether we successfully uploaded the results */\n success: boolean;\n }>(client, CHANGE_REQUEST_DATA_SILO_STATUS, {\n requestDataSiloId: requestDataSilo.id,\n status,\n });\n } catch (err) {\n if (\n !err.message.includes('Client error: Request must be active:') &&\n !err.message.includes('Failed to find RequestDataSilo')\n ) {\n throw err;\n }\n }\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully notified Transcend in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n return requestIds.length;\n}\n","import {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchRequestDataSiloActiveCount,\n} from '../graphql';\nimport colors from 'colors';\nimport cliProgress from 'cli-progress';\nimport {\n pullCronPageOfIdentifiers,\n CronIdentifier,\n} from './pullCronPageOfIdentifiers';\nimport { RequestAction } from '@transcend-io/privacy-types';\n\nimport { logger } from '../../logger';\nimport { DEFAULT_TRANSCEND_API } from '../../constants';\nimport { mapSeries } from '../bluebird';\n\n/**\n * A CSV formatted identifier\n */\nexport type CsvFormattedIdentifier = {\n [k in string]: string | null | boolean | number;\n};\n\nexport interface CronIdentifierWithAction extends CronIdentifier {\n /** The request action that the identifier relates to */\n action: RequestAction;\n}\n\n/**\n * Pull the set of identifiers outstanding for a cron or AVC integration\n *\n * This function is designed to be used in a loop, and will call the onSave callback\n * with a chunk of identifiers when the savePageSize is reached.\n *\n * @param options - Options\n * @returns The identifiers and identifiers formatted for CSV\n */\nexport async function pullChunkedCustomSiloOutstandingIdentifiers({\n dataSiloId,\n auth,\n sombraAuth,\n actions,\n apiPageSize = 100,\n savePageSize = 1000,\n onSave,\n transcendUrl = DEFAULT_TRANSCEND_API,\n skipRequestCount = false,\n}: {\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** The request actions to fetch */\n actions: RequestAction[];\n /** How many identifiers to pull in a single call to the backend */\n apiPageSize: number;\n /** How many identifiers to save at a time (usually to a CSV file, should be a multiple of apiPageSize) */\n savePageSize: number;\n /** Callback function called when a chunk of identifiers is ready to be saved */\n onSave: (chunk: CsvFormattedIdentifier[]) => Promise<void>;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Skip request count */\n skipRequestCount?: boolean;\n}): Promise<{\n /** Raw Identifiers */\n identifiers: CronIdentifierWithAction[];\n}> {\n // Validate savePageSize\n if (savePageSize % apiPageSize !== 0) {\n throw new Error(\n `savePageSize must be a multiple of apiPageSize. savePageSize: ${savePageSize}, apiPageSize: ${apiPageSize}`,\n );\n }\n\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, sombraAuth);\n\n // Create GraphQL client to connect to Transcend backend\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n let totalRequestCount = 0;\n if (!skipRequestCount) {\n totalRequestCount = await fetchRequestDataSiloActiveCount(client, {\n dataSiloId,\n });\n }\n\n logger.info(\n colors.magenta(\n `Pulling ${\n skipRequestCount ? 'all' : totalRequestCount\n } outstanding request identifiers ` +\n `for data silo: \"${dataSiloId}\" for requests of types \"${actions.join(\n '\", \"',\n )}\"`,\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 const foundRequestIds = new Set<string>();\n\n // identifiers found in total\n const identifiers: CronIdentifierWithAction[] = [];\n // current chunk of identifiers to be saved\n let currentChunk: CsvFormattedIdentifier[] = [];\n\n // map over each action\n if (!skipRequestCount) {\n progressBar.start(totalRequestCount, 0);\n }\n await mapSeries(actions, async (action) => {\n let offset = 0;\n let shouldContinue = true;\n\n // Fetch a page of identifiers\n while (shouldContinue) {\n const pageIdentifiers = await pullCronPageOfIdentifiers(sombra, {\n dataSiloId,\n limit: apiPageSize,\n offset,\n requestType: action,\n });\n\n const identifiersWithAction: CronIdentifierWithAction[] =\n pageIdentifiers.map((identifier) => {\n foundRequestIds.add(identifier.requestId);\n return {\n ...identifier,\n action,\n };\n });\n\n const csvFormattedIdentifiers = identifiersWithAction.map(\n ({ attributes, ...identifier }) => ({\n ...identifier,\n ...attributes.reduce(\n (acc, val) =>\n Object.assign(acc, {\n [val.key]: val.values.join(','),\n }),\n {},\n ),\n }),\n );\n\n identifiers.push(...identifiersWithAction);\n currentChunk.push(...csvFormattedIdentifiers);\n\n // Check if we've reached the savePageSize and call the onSave callback\n if (currentChunk.length >= savePageSize) {\n await onSave(currentChunk);\n currentChunk = [];\n }\n\n shouldContinue = pageIdentifiers.length === apiPageSize;\n offset += apiPageSize;\n if (!skipRequestCount) {\n progressBar.update(foundRequestIds.size);\n } else {\n logger.info(\n colors.magenta(\n `Pulled ${pageIdentifiers.length} outstanding identifiers for ${foundRequestIds.size} requests`,\n ),\n );\n }\n }\n });\n\n // Save any remaining identifiers in the current chunk\n if (currentChunk.length > 0) {\n await onSave(currentChunk);\n }\n\n if (!skipRequestCount) {\n progressBar.stop();\n }\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully pulled ${identifiers.length} outstanding identifiers from ${\n foundRequestIds.size\n } requests in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n\n return { identifiers };\n}\n"],"mappings":"iWAKA,MAAa,EAAiBA,EAAE,KAAK,CAEnC,WAAYA,EAAE,OAEd,KAAMA,EAAE,OAER,eAAgBA,EAAE,OAElB,WAAYA,EAAE,OAEd,UAAWA,EAAE,OAEb,MAAOA,EAAE,OAET,iBAAkBA,EAAE,OAEpB,iBAAkBA,EAAE,OAEpB,WAAYA,EAAE,MACZA,EAAE,KAAK,CACL,IAAKA,EAAE,OACP,OAAQA,EAAE,MAAMA,EAAE,OAAO,CAC1B,CAAC,CACH,CACF,CAAC,CAaF,eAAsB,EACpB,EACA,CACE,aACA,QAAQ,IACR,SAAS,EACT,eAWyB,CAC3B,GAAI,CAEF,IAAM,EAAW,MAAM,EACpB,IAAI,gBAAgB,EAAW,oBAAoB,IAAe,CACjE,aAAc,CACZ,SACA,QACD,CACF,CAAC,CACD,MAAM,CAEH,CAAE,UAAA,EAAA,EAAA,aACNA,EAAE,KAAK,CACL,MAAOA,EAAE,MAAM,EAAe,CAC/B,CAAC,CACF,EACD,CACD,OAAO,QACA,EAAK,CACZ,MAAU,MACR,kCAAkC,GAAK,UAAU,MAAQ,GAAK,UAC/D,EC3EL,MAAa,EAAqBC,EAAE,KAAK,CACvC,MAAOA,EAAE,OACT,WAAYA,EAAE,OACf,CAAC,CAaF,eAAsB,EACpB,EACA,CAAE,QAAO,cACS,CAClB,GAAI,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0B,EAAsB,KACnD,CAAE,aAAY,GAAG,MAAkB,CAClC,GAAG,EACH,GAAG,EAAW,QACX,EAAK,IACJ,OAAO,OAAO,EAAK,EAChB,EAAI,KAAM,EAAI,OAAO,KAAK,IAAI,CAChC,CAAC,CACJ,EAAE,CACH,CACF,EACF,CAED,EAAY,KAAK,GAAG,EAAsB,CAC1C,EAAa,KAAK,GAAG,EAAwB,CAGzC,EAAa,QAAU,IACzB,MAAM,EAAO,EAAa,CAC1B,EAAe,EAAE,EAGnB,EAAiB,EAAgB,SAAW,EAC5C,GAAU,EACL,EAGH,EAAA,EAAO,KACL,EAAA,QAAO,QACL,UAAU,EAAgB,OAAO,+BAA+B,EAAgB,KAAK,WACtF,CACF,CAND,EAAY,OAAO,EAAgB,KAAK,GAS5C,CAGE,EAAa,OAAS,GACxB,MAAM,EAAO,EAAa,CAGvB,GACH,EAAY,MAAM,CAGpB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAUvB,OARA,EAAA,EAAO,KACL,EAAA,QAAO,MACL,uBAAuB,EAAY,OAAO,gCACxC,EAAgB,KACjB,gBAAgB,EAAY,IAAK,YACnC,CACF,CAEM,CAAE,cAAa"}
|
|
1
|
+
{"version":3,"file":"cron-Ts7kHP6_.cjs","names":["t","t","DEFAULT_TRANSCEND_API","createSombraGotInstance","readCsv","cliProgress","chunk","map","mapSeries","RequestDataSiloStatus","DEFAULT_TRANSCEND_API","buildTranscendGraphQLClient","cliProgress","map","fetchRequestDataSilo","makeGraphQLRequest","CHANGE_REQUEST_DATA_SILO_STATUS","DEFAULT_TRANSCEND_API","createSombraGotInstance","buildTranscendGraphQLClient","fetchRequestDataSiloActiveCount","cliProgress","mapSeries"],"sources":["../src/lib/cron/pullCronPageOfIdentifiers.ts","../src/lib/cron/markCronIdentifierCompleted.ts","../src/lib/cron/pushCronIdentifiersFromCsv.ts","../src/lib/cron/markRequestDataSiloIdsCompleted.ts","../src/lib/cron/pullChunkedCustomSiloOutstandingIdentifiers.ts"],"sourcesContent":["import * as t from 'io-ts';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport { RequestAction } from '@transcend-io/privacy-types';\nimport type { Got } from 'got';\n\nexport const CronIdentifier = t.type({\n /** The identifier value */\n identifier: t.string,\n /** The type of identifier */\n type: t.string,\n /** The core identifier of the request */\n coreIdentifier: t.string,\n /** The ID of the underlying data silo */\n dataSiloId: t.string,\n /** The ID of the underlying request */\n requestId: t.string,\n /** The request nonce */\n nonce: t.string,\n /** The time the request was created */\n requestCreatedAt: t.string,\n /** The number of days until the request is overdue */\n daysUntilOverdue: t.number,\n /** Request attributes */\n attributes: t.array(\n t.type({\n key: t.string,\n values: t.array(t.string),\n }),\n ),\n});\n\n/** Type override */\nexport type CronIdentifier = t.TypeOf<typeof CronIdentifier>;\n\n/**\n * Pull a offset of identifiers for a cron job\n *\n * @see https://docs.transcend.io/docs/api-reference/GET/v1/data-silo/(id)/pending-requests/(type)\n * @param sombra - Sombra instance configured to make requests\n * @param options - Additional options\n * @returns Successfully submitted request\n */\nexport async function pullCronPageOfIdentifiers(\n sombra: Got,\n {\n dataSiloId,\n limit = 100,\n offset = 0,\n requestType,\n }: {\n /** Data Silo ID */\n dataSiloId: string;\n /** Type of request */\n requestType: RequestAction;\n /** Number of identifiers to pull in */\n limit?: number;\n /** Page to pull in */\n offset?: number;\n },\n): Promise<CronIdentifier[]> {\n try {\n // Make the GraphQL request\n const response = await sombra\n .get(`v1/data-silo/${dataSiloId}/pending-requests/${requestType}`, {\n searchParams: {\n offset,\n limit,\n },\n })\n .json();\n\n const { items } = decodeCodec(\n t.type({\n items: t.array(CronIdentifier),\n }),\n response,\n );\n return items;\n } catch (err) {\n throw new Error(\n `Received an error from server: ${err?.response?.body || err?.message}`,\n );\n }\n}\n","import type { Got } from 'got';\nimport * as t from 'io-ts';\n\n/**\n * Minimal set required to mark as completed\n */\nexport const CronIdentifierPush = t.type({\n nonce: t.string,\n identifier: t.string,\n});\n\n/** Type override */\nexport type CronIdentifierPush = t.TypeOf<typeof CronIdentifierPush>;\n\n/**\n * Mark an identifier output by the cron job as completed.\n *\n * @see https://docs.transcend.io/docs/api-reference/PUT/v1/data-silo\n * @param sombra - Sombra instance configured to make requests\n * @param options - Additional options\n * @returns Successfully submitted request, false if not in a state to update\n */\nexport async function markCronIdentifierCompleted(\n sombra: Got,\n { nonce, identifier }: CronIdentifierPush,\n): Promise<boolean> {\n try {\n // Make the GraphQL request\n await sombra.put('v1/data-silo', {\n headers: {\n 'x-transcend-nonce': nonce,\n },\n json: {\n profiles: [\n {\n profileId: identifier,\n },\n ],\n },\n });\n return true;\n } catch (err) {\n // handle gracefully\n if (err.response?.statusCode === 409) {\n return false;\n }\n throw new Error(\n `Received an error from server: ${err?.response?.body || err?.message}`,\n );\n }\n}\n","import { map, mapSeries } from '../bluebird';\nimport { chunk } from 'lodash-es';\nimport { createSombraGotInstance } from '../graphql';\nimport colors from 'colors';\nimport {\n markCronIdentifierCompleted,\n CronIdentifierPush,\n} from './markCronIdentifierCompleted';\nimport cliProgress from 'cli-progress';\nimport { logger } from '../../logger';\nimport { readCsv } from '../requests';\nimport { DEFAULT_TRANSCEND_API } from '../../constants';\n\n/**\n * Given a CSV of cron job outputs, mark all requests as completed in Transcend\n *\n * @param options - Options\n * @returns Number of items marked as completed\n */\nexport async function pushCronIdentifiersFromCsv({\n file,\n dataSiloId,\n auth,\n sombraAuth,\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n sleepSeconds = 10,\n}: {\n /** CSV file path */\n file: string;\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** Upload concurrency */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Sleep time in seconds between chunks of concurrent calls */\n sleepSeconds?: number;\n}): Promise<number> {\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, sombraAuth);\n\n // Read from CSV\n logger.info(colors.magenta(`Reading \"${file}\" from disk`));\n const activeResults = readCsv(file, CronIdentifierPush);\n\n // Notify Transcend\n logger.info(\n colors.magenta(\n `Notifying Transcend for data silo \"${dataSiloId}\" marking \"${activeResults.length}\" identifiers as completed.`,\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 let successCount = 0;\n let failureCount = 0;\n let errorCount = 0;\n progressBar.start(activeResults.length, 0);\n\n // Process in chunks with sleep intervals\n const chunks = chunk(activeResults, concurrency);\n const totalChunks = chunks.length;\n const processChunk = async (\n items: CronIdentifierPush[],\n chunkIndex: number,\n ): Promise<void> => {\n logger.info(\n colors.blue(\n `Processing chunk ${chunkIndex + 1}/${totalChunks} (${\n chunk.length\n } items)`,\n ),\n );\n\n // Process the items of the chunk concurrently\n await map(items, async (identifier) => {\n try {\n const success = await markCronIdentifierCompleted(sombra, identifier);\n if (success) {\n successCount += 1;\n } else {\n failureCount += 1;\n }\n } catch (e) {\n logger.error(\n colors.red(\n `Error notifying Transcend for identifier \"${identifier.identifier}\" - ${e?.message}`,\n ),\n );\n errorCount += 1;\n }\n progressBar.update(successCount + failureCount);\n });\n\n // Sleep between chunks (except for the last chunk)\n if (sleepSeconds > 0 && chunkIndex < totalChunks - 1) {\n logger.info(\n colors.yellow(`Sleeping for ${sleepSeconds}s before next chunk...`),\n );\n\n await new Promise((resolve) => {\n setTimeout(resolve, sleepSeconds * 1000);\n });\n }\n };\n\n // Process all chunks sequentially\n await mapSeries(chunks, processChunk);\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully notified Transcend for ${successCount} identifiers in \"${\n totalTime / 1000\n }\" seconds!`,\n ),\n );\n if (failureCount) {\n logger.info(\n colors.magenta(\n `There were ${failureCount} identifiers that were not in a state to be updated.` +\n 'They likely have already been resolved.',\n ),\n );\n }\n if (errorCount) {\n logger.error(\n colors.red(\n `There were ${errorCount} identifiers that failed to be updated. Please review the logs for more information.`,\n ),\n );\n throw new Error('Failed to update all identifiers');\n }\n return activeResults.length;\n}\n","import { map } from '../bluebird';\nimport colors from 'colors';\nimport { logger } from '../../logger';\nimport {\n CHANGE_REQUEST_DATA_SILO_STATUS,\n fetchRequestDataSilo,\n makeGraphQLRequest,\n buildTranscendGraphQLClient,\n} from '../graphql';\nimport cliProgress from 'cli-progress';\nimport { DEFAULT_TRANSCEND_API } from '../../constants';\nimport { RequestDataSiloStatus } from '@transcend-io/privacy-types';\n\n/**\n * Given a CSV of Request IDs, mark associated RequestDataSilos as completed\n *\n * @param options - Options\n * @returns Number of items marked as completed\n */\nexport async function markRequestDataSiloIdsCompleted({\n requestIds,\n dataSiloId,\n auth,\n concurrency = 100,\n status = RequestDataSiloStatus.Resolved,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The list of request ids to mark as completed */\n requestIds: string[];\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** Status to update requests to */\n status?: RequestDataSiloStatus;\n /** Upload concurrency */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar(\n {},\n cliProgress.Presets.shades_classic,\n );\n\n // Notify Transcend\n logger.info(\n colors.magenta(\n `Notifying Transcend for data silo \"${dataSiloId}\" marking \"${requestIds.length}\" requests as completed.`,\n ),\n );\n\n let total = 0;\n progressBar.start(requestIds.length, 0);\n await map(\n requestIds,\n async (requestId) => {\n const requestDataSilo = await fetchRequestDataSilo(client, {\n requestId,\n dataSiloId,\n });\n\n try {\n await makeGraphQLRequest<{\n /** Whether we successfully uploaded the results */\n success: boolean;\n }>(client, CHANGE_REQUEST_DATA_SILO_STATUS, {\n requestDataSiloId: requestDataSilo.id,\n status,\n });\n } catch (err) {\n if (\n !err.message.includes('Client error: Request must be active:') &&\n !err.message.includes('Failed to find RequestDataSilo')\n ) {\n throw err;\n }\n }\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully notified Transcend in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n return requestIds.length;\n}\n","import {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchRequestDataSiloActiveCount,\n} from '../graphql';\nimport colors from 'colors';\nimport cliProgress from 'cli-progress';\nimport {\n pullCronPageOfIdentifiers,\n CronIdentifier,\n} from './pullCronPageOfIdentifiers';\nimport { RequestAction } from '@transcend-io/privacy-types';\n\nimport { logger } from '../../logger';\nimport { DEFAULT_TRANSCEND_API } from '../../constants';\nimport { mapSeries } from '../bluebird';\n\n/**\n * A CSV formatted identifier\n */\nexport type CsvFormattedIdentifier = {\n [k in string]: string | null | boolean | number;\n};\n\nexport interface CronIdentifierWithAction extends CronIdentifier {\n /** The request action that the identifier relates to */\n action: RequestAction;\n}\n\n/**\n * Pull the set of identifiers outstanding for a cron or AVC integration\n *\n * This function is designed to be used in a loop, and will call the onSave callback\n * with a chunk of identifiers when the savePageSize is reached.\n *\n * @param options - Options\n * @returns The identifiers and identifiers formatted for CSV\n */\nexport async function pullChunkedCustomSiloOutstandingIdentifiers({\n dataSiloId,\n auth,\n sombraAuth,\n actions,\n apiPageSize = 100,\n savePageSize = 1000,\n onSave,\n transcendUrl = DEFAULT_TRANSCEND_API,\n skipRequestCount = false,\n}: {\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** The request actions to fetch */\n actions: RequestAction[];\n /** How many identifiers to pull in a single call to the backend */\n apiPageSize: number;\n /** How many identifiers to save at a time (usually to a CSV file, should be a multiple of apiPageSize) */\n savePageSize: number;\n /** Callback function called when a chunk of identifiers is ready to be saved */\n onSave: (chunk: CsvFormattedIdentifier[]) => Promise<void>;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Skip request count */\n skipRequestCount?: boolean;\n}): Promise<{\n /** Raw Identifiers */\n identifiers: CronIdentifierWithAction[];\n}> {\n // Validate savePageSize\n if (savePageSize % apiPageSize !== 0) {\n throw new Error(\n `savePageSize must be a multiple of apiPageSize. savePageSize: ${savePageSize}, apiPageSize: ${apiPageSize}`,\n );\n }\n\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, sombraAuth);\n\n // Create GraphQL client to connect to Transcend backend\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n let totalRequestCount = 0;\n if (!skipRequestCount) {\n totalRequestCount = await fetchRequestDataSiloActiveCount(client, {\n dataSiloId,\n });\n }\n\n logger.info(\n colors.magenta(\n `Pulling ${\n skipRequestCount ? 'all' : totalRequestCount\n } outstanding request identifiers ` +\n `for data silo: \"${dataSiloId}\" for requests of types \"${actions.join(\n '\", \"',\n )}\"`,\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 const foundRequestIds = new Set<string>();\n\n // identifiers found in total\n const identifiers: CronIdentifierWithAction[] = [];\n // current chunk of identifiers to be saved\n let currentChunk: CsvFormattedIdentifier[] = [];\n\n // map over each action\n if (!skipRequestCount) {\n progressBar.start(totalRequestCount, 0);\n }\n await mapSeries(actions, async (action) => {\n let offset = 0;\n let shouldContinue = true;\n\n // Fetch a page of identifiers\n while (shouldContinue) {\n const pageIdentifiers = await pullCronPageOfIdentifiers(sombra, {\n dataSiloId,\n limit: apiPageSize,\n offset,\n requestType: action,\n });\n\n const identifiersWithAction: CronIdentifierWithAction[] =\n pageIdentifiers.map((identifier) => {\n foundRequestIds.add(identifier.requestId);\n return {\n ...identifier,\n action,\n };\n });\n\n const csvFormattedIdentifiers = identifiersWithAction.map(\n ({ attributes, ...identifier }) => ({\n ...identifier,\n ...attributes.reduce(\n (acc, val) =>\n Object.assign(acc, {\n [val.key]: val.values.join(','),\n }),\n {},\n ),\n }),\n );\n\n identifiers.push(...identifiersWithAction);\n currentChunk.push(...csvFormattedIdentifiers);\n\n // Check if we've reached the savePageSize and call the onSave callback\n if (currentChunk.length >= savePageSize) {\n await onSave(currentChunk);\n currentChunk = [];\n }\n\n shouldContinue = pageIdentifiers.length === apiPageSize;\n offset += apiPageSize;\n if (!skipRequestCount) {\n progressBar.update(foundRequestIds.size);\n } else {\n logger.info(\n colors.magenta(\n `Pulled ${pageIdentifiers.length} outstanding identifiers for ${foundRequestIds.size} requests`,\n ),\n );\n }\n }\n });\n\n // Save any remaining identifiers in the current chunk\n if (currentChunk.length > 0) {\n await onSave(currentChunk);\n }\n\n if (!skipRequestCount) {\n progressBar.stop();\n }\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully pulled ${identifiers.length} outstanding identifiers from ${\n foundRequestIds.size\n } requests in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n\n return { identifiers };\n}\n"],"mappings":"iWAKA,MAAa,EAAiBA,EAAE,KAAK,CAEnC,WAAYA,EAAE,OAEd,KAAMA,EAAE,OAER,eAAgBA,EAAE,OAElB,WAAYA,EAAE,OAEd,UAAWA,EAAE,OAEb,MAAOA,EAAE,OAET,iBAAkBA,EAAE,OAEpB,iBAAkBA,EAAE,OAEpB,WAAYA,EAAE,MACZA,EAAE,KAAK,CACL,IAAKA,EAAE,OACP,OAAQA,EAAE,MAAMA,EAAE,OAAO,CAC1B,CAAC,CACH,CACF,CAAC,CAaF,eAAsB,EACpB,EACA,CACE,aACA,QAAQ,IACR,SAAS,EACT,eAWyB,CAC3B,GAAI,CAEF,IAAM,EAAW,MAAM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
|
+
const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./constants-CzmvL6Mw.cjs`),n=require(`./syncConfigurationToTranscend-DkeLrq-I.cjs`),r=require(`./logger-DQwEYtSS.cjs`);let i=require(`@transcend-io/privacy-types`),a=require(`colors`);a=e.t(a);let o=require(`graphql-request`),s=require(`cli-progress`);s=e.t(s);async function c(e,{dataSiloIds:t=[],includeGuessedCategories:c,includeAttributes:l,parentCategories:u=[],subCategories:d=[],pageSize:f=1e3}={}){let p=[],m=new Date().getTime(),h=new s.default.SingleBar({},s.default.Presets.shades_classic),g={...u.length>0?{category:u}:{},...d.length>0?{subCategoryIds:d}:{},...u.length+d.length>0&&!c?{status:i.SubDataPointDataSubCategoryGuessStatus.Approved}:{},...t.length>0?{dataSilos:t}:{}},{subDataPoints:{totalCount:_}}=await n.i(e,n.Ds,{filterBy:g});r.t.info(a.default.magenta(`[Step 1/3] Pulling in all subdatapoints`)),h.start(_,0);let v=0,y=!1,b,x=0;do try{let{subDataPoints:{nodes:t}}=await n.i(e,o.gql`
|
|
2
2
|
query TranscendCliSubDataPointCsvExport(
|
|
3
3
|
$filterBy: SubDataPointFiltersInput
|
|
4
4
|
$first: Int!
|
|
@@ -41,7 +41,7 @@ const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./constants-K6pQQtc7.cjs`),n=
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
`,{first:f,offset:x,filterBy:{...g}});b=t[t.length-1]?.id,p.push(...t),y=t.length===f,v+=t.length,x+=t.length,h.update(v)}catch(e){throw r.t.error(a.default.red(`An error fetching subdatapoints for cursor ${b} and offset ${x}`)),e}while(y);h.stop();let S=new Date().getTime()-m,C=n.
|
|
44
|
+
`,{first:f,offset:x,filterBy:{...g}});b=t[t.length-1]?.id,p.push(...t),y=t.length===f,v+=t.length,x+=t.length,h.update(v)}catch(e){throw r.t.error(a.default.red(`An error fetching subdatapoints for cursor ${b} and offset ${x}`)),e}while(y);h.stop();let S=new Date().getTime()-m,C=n.Ps(p,`name`);return r.t.info(a.default.green(`Successfully pulled in ${C.length} subdatapoints in ${S/1e3} seconds!`)),C}async function l(e,{dataPointIds:t=[],pageSize:i=100}){let o=[],c=new Date().getTime(),l=new s.default.SingleBar({},s.default.Presets.shades_classic);r.t.info(a.default.magenta(`[Step 2/3] Fetching metadata for ${t.length} datapoints`));let u=n.Rs(t,i);l.start(t.length,0);let d=0;await n.js(u,async t=>{try{let{dataPoints:{nodes:r}}=await n.i(e,n.Cs,{first:i,filterBy:{ids:t}});o.push(...r),d+=t.length,l.update(d)}catch(e){throw r.t.error(a.default.red(`An error fetching subdatapoints for IDs ${t.join(`, `)}`)),e}}),l.stop();let f=new Date().getTime()-c;return r.t.info(a.default.green(`Successfully pulled in ${o.length} dataPoints in ${f/1e3} seconds!`)),o}async function u(e,{dataSiloIds:t=[],pageSize:i=100}){let o=[],c=new Date().getTime(),l=new s.default.SingleBar({},s.default.Presets.shades_classic);r.t.info(a.default.magenta(`[Step 3/3] Fetching metadata for ${t.length} data silos`));let u=n.Rs(t,i);l.start(t.length,0);let d=0;await n.js(u,async t=>{try{let{dataSilos:{nodes:r}}=await n.i(e,n.bs,{first:i,filterBy:{ids:t}});o.push(...r),d+=t.length,l.update(d)}catch(e){throw r.t.error(a.default.red(`An error fetching data silos for IDs ${t.join(`, `)}`)),e}}),l.stop();let f=new Date().getTime()-c;return r.t.info(a.default.green(`Successfully pulled in ${o.length} data silos in ${f/1e3} seconds!`)),o}async function d(e,{dataSiloIds:r=[],includeGuessedCategories:i,includeAttributes:a,parentCategories:o=[],subCategories:s=[],pageSize:d=1e3}={}){let f=await c(e,{dataSiloIds:r,includeGuessedCategories:i,includeAttributes:a,parentCategories:o,subCategories:s,pageSize:d}),p=t.g(await l(e,{dataPointIds:n.Ms(f.map(e=>e.dataPointId))}),`id`),m=t.g(await u(e,{dataSiloIds:n.Ms(f.map(e=>e.dataSiloId))}),`id`);return f.map(e=>({...e,dataPoint:p[e.dataPointId],dataSilo:m[e.dataSiloId]}))}async function f(e,{dataSiloIds:t=[],status:i,subCategories:c=[],includeEncryptedSnippets:l,pageSize:u=100}={}){let d=[],f=new Date().getTime(),p=new s.default.SingleBar({},s.default.Presets.shades_classic),m={...c.length>0?{subCategoryIds:c}:{},...i?{status:i}:{},...t.length>0?{dataSilos:t}:{}},{unstructuredSubDataPointRecommendations:{totalCount:h}}=await n.i(e,n.Ss,{filterBy:m});r.t.info(a.default.magenta(`[Step 1/3] Pulling in all subdatapoints`)),p.start(h,0);let g=0,_=!1,v,y=0;do try{let{unstructuredSubDataPointRecommendations:{nodes:t}}=await n.i(e,o.gql`
|
|
45
45
|
query TranscendCliUnstructuredSubDataPointRecommendationCsvExport(
|
|
46
46
|
$filterBy: UnstructuredSubDataPointRecommendationsFilterInput
|
|
47
47
|
$first: Int!
|
|
@@ -71,5 +71,5 @@ const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./constants-K6pQQtc7.cjs`),n=
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
`,{first:u,offset:y,filterBy:{...m}});v=t[t.length-1]?.id,d.push(...t),_=t.length===u,g+=t.length,y+=t.length,p.update(g)}catch(e){throw r.t.error(a.default.red(`An error fetching subdatapoints for cursor ${v} and offset ${y}`)),e}while(_);p.stop();let b=new Date().getTime()-f,x=n.
|
|
75
|
-
//# sourceMappingURL=data-inventory-
|
|
74
|
+
`,{first:u,offset:y,filterBy:{...m}});v=t[t.length-1]?.id,d.push(...t),_=t.length===u,g+=t.length,y+=t.length,p.update(g)}catch(e){throw r.t.error(a.default.red(`An error fetching subdatapoints for cursor ${v} and offset ${y}`)),e}while(_);p.stop();let b=new Date().getTime()-f,x=n.Ps(d,`name`);return r.t.info(a.default.green(`Successfully pulled in ${x.length} subdatapoints in ${b/1e3} seconds!`)),x}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return f}});
|
|
75
|
+
//# sourceMappingURL=data-inventory-D0Tt_vAm.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-inventory-BKAQGjFN.cjs","names":["cliProgress","SubDataPointDataSubCategoryGuessStatus","makeGraphQLRequest","SUB_DATA_POINTS_COUNT","sortBy","chunk","mapSeries","DATAPOINT_EXPORT","DATA_SILO_EXPORT","keyBy","uniq","cliProgress","makeGraphQLRequest","ENTRY_COUNT","sortBy"],"sources":["../src/lib/data-inventory/pullAllDatapoints.ts","../src/lib/data-inventory/pullUnstructuredSubDataPointRecommendations.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport { keyBy, uniq, chunk, sortBy } from 'lodash-es';\nimport {\n type DataCategoryType,\n SubDataPointDataSubCategoryGuessStatus,\n} from '@transcend-io/privacy-types';\nimport cliProgress from 'cli-progress';\nimport { gql } from 'graphql-request';\nimport colors from 'colors';\nimport type { GraphQLClient } from 'graphql-request';\nimport {\n DATAPOINT_EXPORT,\n DATA_SILO_EXPORT,\n type DataSiloAttributeValue,\n SUB_DATA_POINTS_COUNT,\n makeGraphQLRequest,\n} from '../graphql';\nimport { logger } from '../../logger';\nimport type { DataCategoryInput, ProcessingPurposeInput } from '../../codecs';\nimport { mapSeries } from '../bluebird';\n\nexport interface DataSiloCsvPreview {\n /** ID of dataSilo */\n id: string;\n /** Name of dataSilo */\n title: string;\n}\n\nexport interface DataPointCsvPreview {\n /** ID of dataPoint */\n id: string;\n /** The path to this data point */\n path: string[];\n /** Description */\n description: {\n /** Default message */\n defaultMessage: string;\n };\n /** Name */\n name: string;\n}\n\nexport interface SubDataPointCsvPreview {\n /** ID of subDatapoint */\n id: string;\n /** Name (or key) of the subdatapoint */\n name: string;\n /** The description */\n description?: string;\n /** Personal data category */\n categories: DataCategoryInput[];\n /** Data point ID */\n dataPointId: string;\n /** The data silo ID */\n dataSiloId: string;\n /** The processing purpose for this sub datapoint */\n purposes: ProcessingPurposeInput[];\n /** Attribute attached to subdatapoint */\n attributeValues?: DataSiloAttributeValue[];\n /** Data category guesses that are output by the classifier */\n pendingCategoryGuesses?: {\n /** Data category being guessed */\n category: DataCategoryInput;\n /** Status of guess */\n status: SubDataPointDataSubCategoryGuessStatus;\n /** classifier version that produced the guess */\n classifierVersion: number;\n }[];\n}\n\nexport interface DatapointFilterOptions {\n /** IDs of data silos to filter down */\n dataSiloIds?: string[];\n /** Whether to include guessed categories, defaults to only approved categories */\n includeGuessedCategories?: boolean;\n /** Whether or not to include attributes */\n includeAttributes?: boolean;\n /** Parent categories to filter down for */\n parentCategories?: DataCategoryType[];\n /** Sub categories to filter down for */\n subCategories?: string[]; // TODO: https://transcend.height.app/T-40482 - do by name not ID\n}\n\n/**\n * Pull subdatapoint information\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @returns The subdatapoints\n */\nasync function pullSubDatapoints(\n client: GraphQLClient,\n {\n dataSiloIds = [],\n includeGuessedCategories,\n includeAttributes,\n parentCategories = [],\n subCategories = [],\n pageSize = 1000,\n }: DatapointFilterOptions & {\n /** Page size to pull in */\n pageSize?: number;\n } = {},\n): Promise<SubDataPointCsvPreview[]> {\n const subDataPoints: SubDataPointCsvPreview[] = [];\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 // Filters\n const filterBy = {\n ...(parentCategories.length > 0 ? { category: parentCategories } : {}),\n ...(subCategories.length > 0 ? { subCategoryIds: subCategories } : {}),\n // if parentCategories or subCategories and not includeGuessedCategories\n ...(parentCategories.length + subCategories.length > 0 &&\n !includeGuessedCategories\n ? // then only show data points with approved data categories\n { status: SubDataPointDataSubCategoryGuessStatus.Approved }\n : {}),\n ...(dataSiloIds.length > 0 ? { dataSilos: dataSiloIds } : {}),\n };\n\n // Build a GraphQL client\n const {\n subDataPoints: { totalCount },\n } = await makeGraphQLRequest<{\n /** Query response */\n subDataPoints: {\n /** Count */\n totalCount: number;\n };\n }>(client, SUB_DATA_POINTS_COUNT, {\n filterBy,\n });\n\n logger.info(colors.magenta('[Step 1/3] Pulling in all subdatapoints'));\n\n progressBar.start(totalCount, 0);\n let total = 0;\n let shouldContinue = false;\n let cursor: string | undefined;\n let offset = 0;\n do {\n try {\n const {\n subDataPoints: { nodes },\n } = await makeGraphQLRequest<{\n /** Query response */\n subDataPoints: {\n /** List of matches */\n nodes: SubDataPointCsvPreview[];\n };\n }>(\n client,\n gql`\n query TranscendCliSubDataPointCsvExport(\n $filterBy: SubDataPointFiltersInput\n $first: Int!\n $offset: Int!\n ) {\n subDataPoints(\n filterBy: $filterBy\n first: $first\n offset: $offset\n useMaster: false\n ) {\n nodes {\n id\n name\n description\n dataPointId\n dataSiloId\n purposes {\n name\n purpose\n }\n categories {\n name\n category\n }\n ${\n includeGuessedCategories\n ? `pendingCategoryGuesses {\n category {\n name\n category\n }\n status\n classifierVersion\n }`\n : ''\n }\n ${\n includeAttributes\n ? `attributeValues {\n attributeKey {\n name\n }\n name\n }`\n : ''\n }\n }\n }\n }\n `,\n {\n first: pageSize,\n offset,\n filterBy: {\n ...filterBy,\n // TODO: https://transcend.height.app/T-40484 - add cursor support\n // ...(cursor ? { cursor: { id: cursor } } : {}),\n },\n },\n );\n\n cursor = nodes[nodes.length - 1]?.id as string;\n subDataPoints.push(...nodes);\n shouldContinue = nodes.length === pageSize;\n total += nodes.length;\n offset += nodes.length;\n progressBar.update(total);\n } catch (err) {\n logger.error(\n colors.red(\n `An error fetching subdatapoints for cursor ${cursor} and offset ${offset}`,\n ),\n );\n throw err;\n }\n } while (shouldContinue);\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n const sorted = sortBy(subDataPoints, 'name');\n\n logger.info(\n colors.green(\n `Successfully pulled in ${sorted.length} subdatapoints in ${\n totalTime / 1000\n } seconds!`,\n ),\n );\n return sorted;\n}\n\n/**\n * Pull datapoint information\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @returns The datapoints\n */\nasync function pullDatapoints(\n client: GraphQLClient,\n {\n dataPointIds = [],\n pageSize = 100,\n }: {\n /** IDs of data points to filter down */\n dataPointIds: string[];\n /** Page size to pull in */\n pageSize?: number;\n },\n): Promise<DataPointCsvPreview[]> {\n const dataPoints: DataPointCsvPreview[] = [];\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 logger.info(\n colors.magenta(\n `[Step 2/3] Fetching metadata for ${dataPointIds.length} datapoints`,\n ),\n );\n\n // Group by 100\n const dataPointsGrouped = chunk(dataPointIds, pageSize);\n\n progressBar.start(dataPointIds.length, 0);\n let total = 0;\n await mapSeries(dataPointsGrouped, async (dataPointIdsGroup) => {\n try {\n const {\n dataPoints: { nodes },\n } = await makeGraphQLRequest<{\n /** Query response */\n dataPoints: {\n /** List of matches */\n nodes: DataPointCsvPreview[];\n };\n }>(client, DATAPOINT_EXPORT, {\n first: pageSize,\n filterBy: {\n ids: dataPointIdsGroup,\n },\n });\n\n dataPoints.push(...nodes);\n total += dataPointIdsGroup.length;\n progressBar.update(total);\n } catch (err) {\n logger.error(\n colors.red(\n `An error fetching subdatapoints for IDs ${dataPointIdsGroup.join(\n ', ',\n )}`,\n ),\n );\n throw err;\n }\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 pulled in ${dataPoints.length} dataPoints in ${\n totalTime / 1000\n } seconds!`,\n ),\n );\n return dataPoints;\n}\n\n/**\n * Pull data silo information\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @returns The data silos\n */\nasync function pullDataSilos(\n client: GraphQLClient,\n {\n dataSiloIds = [],\n pageSize = 100,\n }: {\n /** IDs of data silos to filter down */\n dataSiloIds: string[];\n /** Page size to pull in */\n pageSize?: number;\n },\n): Promise<DataSiloCsvPreview[]> {\n const dataSilos: DataSiloCsvPreview[] = [];\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 logger.info(\n colors.magenta(\n `[Step 3/3] Fetching metadata for ${dataSiloIds.length} data silos`,\n ),\n );\n\n // Group by 100\n const dataSilosGrouped = chunk(dataSiloIds, pageSize);\n\n progressBar.start(dataSiloIds.length, 0);\n let total = 0;\n await mapSeries(dataSilosGrouped, async (dataSiloIdsGroup) => {\n try {\n const {\n dataSilos: { nodes },\n } = await makeGraphQLRequest<{\n /** Query response */\n dataSilos: {\n /** List of matches */\n nodes: DataSiloCsvPreview[];\n };\n }>(client, DATA_SILO_EXPORT, {\n first: pageSize,\n filterBy: {\n ids: dataSiloIdsGroup,\n },\n });\n\n dataSilos.push(...nodes);\n total += dataSiloIdsGroup.length;\n progressBar.update(total);\n } catch (err) {\n logger.error(\n colors.red(\n `An error fetching data silos for IDs ${dataSiloIdsGroup.join(', ')}`,\n ),\n );\n throw err;\n }\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 pulled in ${dataSilos.length} data silos in ${\n totalTime / 1000\n } seconds!`,\n ),\n );\n return dataSilos;\n}\n\n/**\n * Pull all datapoints from the data inventory.\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @returns The datapoints and data silos\n */\nexport async function pullAllDatapoints(\n client: GraphQLClient,\n {\n dataSiloIds = [],\n includeGuessedCategories,\n includeAttributes,\n parentCategories = [],\n subCategories = [],\n pageSize = 1000,\n }: DatapointFilterOptions & {\n /** Page size to pull in */\n pageSize?: number;\n } = {},\n): Promise<\n (SubDataPointCsvPreview & {\n /** Data point information */\n dataPoint: DataPointCsvPreview;\n /** Data silo information */\n dataSilo: DataSiloCsvPreview;\n })[]\n> {\n // Subdatapoint information\n const subDatapoints = await pullSubDatapoints(client, {\n dataSiloIds,\n includeGuessedCategories,\n includeAttributes,\n parentCategories,\n subCategories,\n pageSize,\n });\n\n // The datapoint ids to grab\n const dataPointIds = uniq(subDatapoints.map((point) => point.dataPointId));\n const dataPoints = await pullDatapoints(client, {\n dataPointIds,\n });\n const dataPointById = keyBy(dataPoints, 'id');\n\n // The data silo IDs to grab\n const allDataSiloIds = uniq(subDatapoints.map((point) => point.dataSiloId));\n const dataSilos = await pullDataSilos(client, {\n dataSiloIds: allDataSiloIds,\n });\n const dataSiloById = keyBy(dataSilos, 'id');\n\n return subDatapoints.map((subDataPoint) => ({\n ...subDataPoint,\n dataPoint: dataPointById[subDataPoint.dataPointId],\n dataSilo: dataSiloById[subDataPoint.dataSiloId],\n }));\n}\n/* eslint-enable max-lines */\n","import type { UnstructuredSubDataPointRecommendationStatus } from '@transcend-io/privacy-types';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport { gql, type GraphQLClient } from 'graphql-request';\nimport { sortBy } from 'lodash-es';\nimport type { DataCategoryInput } from '../../codecs';\nimport { ENTRY_COUNT, makeGraphQLRequest } from '../graphql';\nimport { logger } from '../../logger';\n\ninterface UnstructuredSubDataPointRecommendationCsvPreview {\n /** ID of subDatapoint */\n id: string;\n /** Entry or Named Entity recognized by the classifier */\n name: string;\n /** Context snippet including entry */\n contextSnippet: string;\n /** Scanned object ID */\n scannedObjectId: string;\n /** Scanned object path ID */\n scannedObjectPathId: string;\n /** The data silo ID */\n dataSiloId: string;\n /** Personal data category */\n dataSubCategory: DataCategoryInput;\n /** Classification Status */\n status: UnstructuredSubDataPointRecommendationStatus;\n /** Confidence */\n confidence: number;\n /** Classification method */\n classificationMethod: string;\n /** Classifier version */\n classifierVersion: string;\n}\n\ninterface EntryFilterOptions {\n /** IDs of data silos to filter down */\n dataSiloIds?: string[];\n /** Parent categories to filter down for */\n status?: UnstructuredSubDataPointRecommendationStatus[];\n /** Sub categories to filter down for */\n subCategories?: string[]; // TODO: https://transcend.height.app/T-40482 - do by name not ID\n /** Include entry and snippet */\n includeEncryptedSnippets?: boolean;\n /** Include encryptedSamplesS3Key */\n includeEncryptedSamplesS3Key?: boolean;\n}\n/**\n * Pull unstructured subdatapoint information\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @param options.dataSiloIds - IDs of data silos to filter down\n * @param options.status - Parent categories to filter down for\n * @param options.subCategories - Sub categories to filter down for\n * @param options.includeEncryptedSnippets - Include entry and snippet\n * @param options.includeEncryptedSamplesS3Key - Include encryptedSamplesS3Key\n * @param options.pageSize - Page size to pull in\n * @returns A promise that resolves to an array of unstructured subdatapoint recommendations\n */\nexport async function pullUnstructuredSubDataPointRecommendations(\n client: GraphQLClient,\n {\n dataSiloIds = [],\n status,\n subCategories = [],\n includeEncryptedSnippets,\n pageSize = 100,\n }: EntryFilterOptions & {\n /** Page size to pull in */\n pageSize?: number;\n } = {},\n): Promise<UnstructuredSubDataPointRecommendationCsvPreview[]> {\n const unstructuredSubDataPointRecommendations: UnstructuredSubDataPointRecommendationCsvPreview[] =\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 // Filters\n const filterBy = {\n ...(subCategories.length > 0 ? { subCategoryIds: subCategories } : {}),\n ...(status ? { status } : {}),\n ...(dataSiloIds.length > 0 ? { dataSilos: dataSiloIds } : {}),\n };\n\n // Build a GraphQL client\n const {\n unstructuredSubDataPointRecommendations: { totalCount },\n } = await makeGraphQLRequest<{\n /** Query response */\n unstructuredSubDataPointRecommendations: {\n /** Count */\n totalCount: number;\n };\n }>(client, ENTRY_COUNT, {\n filterBy,\n });\n\n logger.info(colors.magenta('[Step 1/3] Pulling in all subdatapoints'));\n\n progressBar.start(totalCount, 0);\n let total = 0;\n let shouldContinue = false;\n let cursor: string | undefined;\n let offset = 0;\n do {\n try {\n const {\n unstructuredSubDataPointRecommendations: { nodes },\n } = await makeGraphQLRequest<{\n /** Query response */\n unstructuredSubDataPointRecommendations: {\n /** List of matches */\n nodes: UnstructuredSubDataPointRecommendationCsvPreview[];\n };\n }>(\n client,\n gql`\n query TranscendCliUnstructuredSubDataPointRecommendationCsvExport(\n $filterBy: UnstructuredSubDataPointRecommendationsFilterInput\n $first: Int!\n $offset: Int!\n ) {\n unstructuredSubDataPointRecommendations(\n filterBy: $filterBy\n first: $first\n offset: $offset\n useMaster: false\n ) {\n nodes {\n id\n dataSiloId\n scannedObjectPathId\n scannedObjectId\n ${includeEncryptedSnippets ? 'name' : ''}\n ${includeEncryptedSnippets ? 'contextSnippet' : ''}\n dataSubCategory {\n name\n category\n }\n status\n confidence\n classificationMethod\n classifierVersion\n }\n }\n }\n `,\n {\n first: pageSize,\n offset,\n filterBy: {\n ...filterBy,\n },\n },\n );\n\n cursor = nodes[nodes.length - 1]?.id as string;\n unstructuredSubDataPointRecommendations.push(...nodes);\n shouldContinue = nodes.length === pageSize;\n total += nodes.length;\n offset += nodes.length;\n progressBar.update(total);\n } catch (err) {\n logger.error(\n colors.red(\n `An error fetching subdatapoints for cursor ${cursor} and offset ${offset}`,\n ),\n );\n throw err;\n }\n } while (shouldContinue);\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n const sorted = sortBy(unstructuredSubDataPointRecommendations, 'name');\n\n logger.info(\n colors.green(\n `Successfully pulled in ${sorted.length} subdatapoints in ${\n totalTime / 1000\n } seconds!`,\n ),\n );\n return sorted;\n}\n"],"mappings":"wTA0FA,eAAe,EACb,EACA,CACE,cAAc,EAAE,CAChB,2BACA,oBACA,mBAAmB,EAAE,CACrB,gBAAgB,EAAE,CAClB,WAAW,KAIT,EAAE,CAC6B,CACnC,IAAM,EAA0C,EAAE,CAG5C,EAAK,IAAI,MAAM,CAAC,SAAS,CAGzB,EAAc,IAAIA,EAAAA,QAAY,UAClC,EAAE,CACFA,EAAAA,QAAY,QAAQ,eACrB,CAGK,EAAW,CACf,GAAI,EAAiB,OAAS,EAAI,CAAE,SAAU,EAAkB,C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inventory-D0Tt_vAm.cjs","names":["cliProgress","SubDataPointDataSubCategoryGuessStatus","makeGraphQLRequest","SUB_DATA_POINTS_COUNT","sortBy","chunk","mapSeries","DATAPOINT_EXPORT","DATA_SILO_EXPORT","keyBy","uniq","cliProgress","makeGraphQLRequest","ENTRY_COUNT","sortBy"],"sources":["../src/lib/data-inventory/pullAllDatapoints.ts","../src/lib/data-inventory/pullUnstructuredSubDataPointRecommendations.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport { keyBy, uniq, chunk, sortBy } from 'lodash-es';\nimport {\n type DataCategoryType,\n SubDataPointDataSubCategoryGuessStatus,\n} from '@transcend-io/privacy-types';\nimport cliProgress from 'cli-progress';\nimport { gql } from 'graphql-request';\nimport colors from 'colors';\nimport type { GraphQLClient } from 'graphql-request';\nimport {\n DATAPOINT_EXPORT,\n DATA_SILO_EXPORT,\n type DataSiloAttributeValue,\n SUB_DATA_POINTS_COUNT,\n makeGraphQLRequest,\n} from '../graphql';\nimport { logger } from '../../logger';\nimport type { DataCategoryInput, ProcessingPurposeInput } from '../../codecs';\nimport { mapSeries } from '../bluebird';\n\nexport interface DataSiloCsvPreview {\n /** ID of dataSilo */\n id: string;\n /** Name of dataSilo */\n title: string;\n}\n\nexport interface DataPointCsvPreview {\n /** ID of dataPoint */\n id: string;\n /** The path to this data point */\n path: string[];\n /** Description */\n description: {\n /** Default message */\n defaultMessage: string;\n };\n /** Name */\n name: string;\n}\n\nexport interface SubDataPointCsvPreview {\n /** ID of subDatapoint */\n id: string;\n /** Name (or key) of the subdatapoint */\n name: string;\n /** The description */\n description?: string;\n /** Personal data category */\n categories: DataCategoryInput[];\n /** Data point ID */\n dataPointId: string;\n /** The data silo ID */\n dataSiloId: string;\n /** The processing purpose for this sub datapoint */\n purposes: ProcessingPurposeInput[];\n /** Attribute attached to subdatapoint */\n attributeValues?: DataSiloAttributeValue[];\n /** Data category guesses that are output by the classifier */\n pendingCategoryGuesses?: {\n /** Data category being guessed */\n category: DataCategoryInput;\n /** Status of guess */\n status: SubDataPointDataSubCategoryGuessStatus;\n /** classifier version that produced the guess */\n classifierVersion: number;\n }[];\n}\n\nexport interface DatapointFilterOptions {\n /** IDs of data silos to filter down */\n dataSiloIds?: string[];\n /** Whether to include guessed categories, defaults to only approved categories */\n includeGuessedCategories?: boolean;\n /** Whether or not to include attributes */\n includeAttributes?: boolean;\n /** Parent categories to filter down for */\n parentCategories?: DataCategoryType[];\n /** Sub categories to filter down for */\n subCategories?: string[]; // TODO: https://transcend.height.app/T-40482 - do by name not ID\n}\n\n/**\n * Pull subdatapoint information\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @returns The subdatapoints\n */\nasync function pullSubDatapoints(\n client: GraphQLClient,\n {\n dataSiloIds = [],\n includeGuessedCategories,\n includeAttributes,\n parentCategories = [],\n subCategories = [],\n pageSize = 1000,\n }: DatapointFilterOptions & {\n /** Page size to pull in */\n pageSize?: number;\n } = {},\n): Promise<SubDataPointCsvPreview[]> {\n const subDataPoints: SubDataPointCsvPreview[] = [];\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 // Filters\n const filterBy = {\n ...(parentCategories.length > 0 ? { category: parentCategories } : {}),\n ...(subCategories.length > 0 ? { subCategoryIds: subCategories } : {}),\n // if parentCategories or subCategories and not includeGuessedCategories\n ...(parentCategories.length + subCategories.length > 0 &&\n !includeGuessedCategories\n ? // then only show data points with approved data categories\n { status: SubDataPointDataSubCategoryGuessStatus.Approved }\n : {}),\n ...(dataSiloIds.length > 0 ? { dataSilos: dataSiloIds } : {}),\n };\n\n // Build a GraphQL client\n const {\n subDataPoints: { totalCount },\n } = await makeGraphQLRequest<{\n /** Query response */\n subDataPoints: {\n /** Count */\n totalCount: number;\n };\n }>(client, SUB_DATA_POINTS_COUNT, {\n filterBy,\n });\n\n logger.info(colors.magenta('[Step 1/3] Pulling in all subdatapoints'));\n\n progressBar.start(totalCount, 0);\n let total = 0;\n let shouldContinue = false;\n let cursor: string | undefined;\n let offset = 0;\n do {\n try {\n const {\n subDataPoints: { nodes },\n } = await makeGraphQLRequest<{\n /** Query response */\n subDataPoints: {\n /** List of matches */\n nodes: SubDataPointCsvPreview[];\n };\n }>(\n client,\n gql`\n query TranscendCliSubDataPointCsvExport(\n $filterBy: SubDataPointFiltersInput\n $first: Int!\n $offset: Int!\n ) {\n subDataPoints(\n filterBy: $filterBy\n first: $first\n offset: $offset\n useMaster: false\n ) {\n nodes {\n id\n name\n description\n dataPointId\n dataSiloId\n purposes {\n name\n purpose\n }\n categories {\n name\n category\n }\n ${\n includeGuessedCategories\n ? `pendingCategoryGuesses {\n category {\n name\n category\n }\n status\n classifierVersion\n }`\n : ''\n }\n ${\n includeAttributes\n ? `attributeValues {\n attributeKey {\n name\n }\n name\n }`\n : ''\n }\n }\n }\n }\n `,\n {\n first: pageSize,\n offset,\n filterBy: {\n ...filterBy,\n // TODO: https://transcend.height.app/T-40484 - add cursor support\n // ...(cursor ? { cursor: { id: cursor } } : {}),\n },\n },\n );\n\n cursor = nodes[nodes.length - 1]?.id as string;\n subDataPoints.push(...nodes);\n shouldContinue = nodes.length === pageSize;\n total += nodes.length;\n offset += nodes.length;\n progressBar.update(total);\n } catch (err) {\n logger.error(\n colors.red(\n `An error fetching subdatapoints for cursor ${cursor} and offset ${offset}`,\n ),\n );\n throw err;\n }\n } while (shouldContinue);\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n const sorted = sortBy(subDataPoints, 'name');\n\n logger.info(\n colors.green(\n `Successfully pulled in ${sorted.length} subdatapoints in ${\n totalTime / 1000\n } seconds!`,\n ),\n );\n return sorted;\n}\n\n/**\n * Pull datapoint information\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @returns The datapoints\n */\nasync function pullDatapoints(\n client: GraphQLClient,\n {\n dataPointIds = [],\n pageSize = 100,\n }: {\n /** IDs of data points to filter down */\n dataPointIds: string[];\n /** Page size to pull in */\n pageSize?: number;\n },\n): Promise<DataPointCsvPreview[]> {\n const dataPoints: DataPointCsvPreview[] = [];\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 logger.info(\n colors.magenta(\n `[Step 2/3] Fetching metadata for ${dataPointIds.length} datapoints`,\n ),\n );\n\n // Group by 100\n const dataPointsGrouped = chunk(dataPointIds, pageSize);\n\n progressBar.start(dataPointIds.length, 0);\n let total = 0;\n await mapSeries(dataPointsGrouped, async (dataPointIdsGroup) => {\n try {\n const {\n dataPoints: { nodes },\n } = await makeGraphQLRequest<{\n /** Query response */\n dataPoints: {\n /** List of matches */\n nodes: DataPointCsvPreview[];\n };\n }>(client, DATAPOINT_EXPORT, {\n first: pageSize,\n filterBy: {\n ids: dataPointIdsGroup,\n },\n });\n\n dataPoints.push(...nodes);\n total += dataPointIdsGroup.length;\n progressBar.update(total);\n } catch (err) {\n logger.error(\n colors.red(\n `An error fetching subdatapoints for IDs ${dataPointIdsGroup.join(\n ', ',\n )}`,\n ),\n );\n throw err;\n }\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 pulled in ${dataPoints.length} dataPoints in ${\n totalTime / 1000\n } seconds!`,\n ),\n );\n return dataPoints;\n}\n\n/**\n * Pull data silo information\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @returns The data silos\n */\nasync function pullDataSilos(\n client: GraphQLClient,\n {\n dataSiloIds = [],\n pageSize = 100,\n }: {\n /** IDs of data silos to filter down */\n dataSiloIds: string[];\n /** Page size to pull in */\n pageSize?: number;\n },\n): Promise<DataSiloCsvPreview[]> {\n const dataSilos: DataSiloCsvPreview[] = [];\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 logger.info(\n colors.magenta(\n `[Step 3/3] Fetching metadata for ${dataSiloIds.length} data silos`,\n ),\n );\n\n // Group by 100\n const dataSilosGrouped = chunk(dataSiloIds, pageSize);\n\n progressBar.start(dataSiloIds.length, 0);\n let total = 0;\n await mapSeries(dataSilosGrouped, async (dataSiloIdsGroup) => {\n try {\n const {\n dataSilos: { nodes },\n } = await makeGraphQLRequest<{\n /** Query response */\n dataSilos: {\n /** List of matches */\n nodes: DataSiloCsvPreview[];\n };\n }>(client, DATA_SILO_EXPORT, {\n first: pageSize,\n filterBy: {\n ids: dataSiloIdsGroup,\n },\n });\n\n dataSilos.push(...nodes);\n total += dataSiloIdsGroup.length;\n progressBar.update(total);\n } catch (err) {\n logger.error(\n colors.red(\n `An error fetching data silos for IDs ${dataSiloIdsGroup.join(', ')}`,\n ),\n );\n throw err;\n }\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 pulled in ${dataSilos.length} data silos in ${\n totalTime / 1000\n } seconds!`,\n ),\n );\n return dataSilos;\n}\n\n/**\n * Pull all datapoints from the data inventory.\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @returns The datapoints and data silos\n */\nexport async function pullAllDatapoints(\n client: GraphQLClient,\n {\n dataSiloIds = [],\n includeGuessedCategories,\n includeAttributes,\n parentCategories = [],\n subCategories = [],\n pageSize = 1000,\n }: DatapointFilterOptions & {\n /** Page size to pull in */\n pageSize?: number;\n } = {},\n): Promise<\n (SubDataPointCsvPreview & {\n /** Data point information */\n dataPoint: DataPointCsvPreview;\n /** Data silo information */\n dataSilo: DataSiloCsvPreview;\n })[]\n> {\n // Subdatapoint information\n const subDatapoints = await pullSubDatapoints(client, {\n dataSiloIds,\n includeGuessedCategories,\n includeAttributes,\n parentCategories,\n subCategories,\n pageSize,\n });\n\n // The datapoint ids to grab\n const dataPointIds = uniq(subDatapoints.map((point) => point.dataPointId));\n const dataPoints = await pullDatapoints(client, {\n dataPointIds,\n });\n const dataPointById = keyBy(dataPoints, 'id');\n\n // The data silo IDs to grab\n const allDataSiloIds = uniq(subDatapoints.map((point) => point.dataSiloId));\n const dataSilos = await pullDataSilos(client, {\n dataSiloIds: allDataSiloIds,\n });\n const dataSiloById = keyBy(dataSilos, 'id');\n\n return subDatapoints.map((subDataPoint) => ({\n ...subDataPoint,\n dataPoint: dataPointById[subDataPoint.dataPointId],\n dataSilo: dataSiloById[subDataPoint.dataSiloId],\n }));\n}\n/* eslint-enable max-lines */\n","import type { UnstructuredSubDataPointRecommendationStatus } from '@transcend-io/privacy-types';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\nimport { gql, type GraphQLClient } from 'graphql-request';\nimport { sortBy } from 'lodash-es';\nimport type { DataCategoryInput } from '../../codecs';\nimport { ENTRY_COUNT, makeGraphQLRequest } from '../graphql';\nimport { logger } from '../../logger';\n\ninterface UnstructuredSubDataPointRecommendationCsvPreview {\n /** ID of subDatapoint */\n id: string;\n /** Entry or Named Entity recognized by the classifier */\n name: string;\n /** Context snippet including entry */\n contextSnippet: string;\n /** Scanned object ID */\n scannedObjectId: string;\n /** Scanned object path ID */\n scannedObjectPathId: string;\n /** The data silo ID */\n dataSiloId: string;\n /** Personal data category */\n dataSubCategory: DataCategoryInput;\n /** Classification Status */\n status: UnstructuredSubDataPointRecommendationStatus;\n /** Confidence */\n confidence: number;\n /** Classification method */\n classificationMethod: string;\n /** Classifier version */\n classifierVersion: string;\n}\n\ninterface EntryFilterOptions {\n /** IDs of data silos to filter down */\n dataSiloIds?: string[];\n /** Parent categories to filter down for */\n status?: UnstructuredSubDataPointRecommendationStatus[];\n /** Sub categories to filter down for */\n subCategories?: string[]; // TODO: https://transcend.height.app/T-40482 - do by name not ID\n /** Include entry and snippet */\n includeEncryptedSnippets?: boolean;\n /** Include encryptedSamplesS3Key */\n includeEncryptedSamplesS3Key?: boolean;\n}\n/**\n * Pull unstructured subdatapoint information\n *\n * @param client - Client to use for the request\n * @param options - Options\n * @param options.dataSiloIds - IDs of data silos to filter down\n * @param options.status - Parent categories to filter down for\n * @param options.subCategories - Sub categories to filter down for\n * @param options.includeEncryptedSnippets - Include entry and snippet\n * @param options.includeEncryptedSamplesS3Key - Include encryptedSamplesS3Key\n * @param options.pageSize - Page size to pull in\n * @returns A promise that resolves to an array of unstructured subdatapoint recommendations\n */\nexport async function pullUnstructuredSubDataPointRecommendations(\n client: GraphQLClient,\n {\n dataSiloIds = [],\n status,\n subCategories = [],\n includeEncryptedSnippets,\n pageSize = 100,\n }: EntryFilterOptions & {\n /** Page size to pull in */\n pageSize?: number;\n } = {},\n): Promise<UnstructuredSubDataPointRecommendationCsvPreview[]> {\n const unstructuredSubDataPointRecommendations: UnstructuredSubDataPointRecommendationCsvPreview[] =\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 // Filters\n const filterBy = {\n ...(subCategories.length > 0 ? { subCategoryIds: subCategories } : {}),\n ...(status ? { status } : {}),\n ...(dataSiloIds.length > 0 ? { dataSilos: dataSiloIds } : {}),\n };\n\n // Build a GraphQL client\n const {\n unstructuredSubDataPointRecommendations: { totalCount },\n } = await makeGraphQLRequest<{\n /** Query response */\n unstructuredSubDataPointRecommendations: {\n /** Count */\n totalCount: number;\n };\n }>(client, ENTRY_COUNT, {\n filterBy,\n });\n\n logger.info(colors.magenta('[Step 1/3] Pulling in all subdatapoints'));\n\n progressBar.start(totalCount, 0);\n let total = 0;\n let shouldContinue = false;\n let cursor: string | undefined;\n let offset = 0;\n do {\n try {\n const {\n unstructuredSubDataPointRecommendations: { nodes },\n } = await makeGraphQLRequest<{\n /** Query response */\n unstructuredSubDataPointRecommendations: {\n /** List of matches */\n nodes: UnstructuredSubDataPointRecommendationCsvPreview[];\n };\n }>(\n client,\n gql`\n query TranscendCliUnstructuredSubDataPointRecommendationCsvExport(\n $filterBy: UnstructuredSubDataPointRecommendationsFilterInput\n $first: Int!\n $offset: Int!\n ) {\n unstructuredSubDataPointRecommendations(\n filterBy: $filterBy\n first: $first\n offset: $offset\n useMaster: false\n ) {\n nodes {\n id\n dataSiloId\n scannedObjectPathId\n scannedObjectId\n ${includeEncryptedSnippets ? 'name' : ''}\n ${includeEncryptedSnippets ? 'contextSnippet' : ''}\n dataSubCategory {\n name\n category\n }\n status\n confidence\n classificationMethod\n classifierVersion\n }\n }\n }\n `,\n {\n first: pageSize,\n offset,\n filterBy: {\n ...filterBy,\n },\n },\n );\n\n cursor = nodes[nodes.length - 1]?.id as string;\n unstructuredSubDataPointRecommendations.push(...nodes);\n shouldContinue = nodes.length === pageSize;\n total += nodes.length;\n offset += nodes.length;\n progressBar.update(total);\n } catch (err) {\n logger.error(\n colors.red(\n `An error fetching subdatapoints for cursor ${cursor} and offset ${offset}`,\n ),\n );\n throw err;\n }\n } while (shouldContinue);\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n const sorted = sortBy(unstructuredSubDataPointRecommendations, 'name');\n\n logger.info(\n colors.green(\n `Successfully pulled in ${sorted.length} subdatapoints in ${\n totalTime / 1000\n } seconds!`,\n ),\n );\n return sorted;\n}\n"],"mappings":"wTA0FA,eAAe,EACb,EACA,CACE,cAAc,EAAE,CAChB,2BACA,oBACA,mBAAmB,EAAE,CACrB,gBAAgB,EAAE,CAClB,WAAW,KAIT,EAAE,CAC6B,CACnC,IAAM,EAA0C,EAAE,CAG5C,EAAK,IAAI,MAAM,CAAC,SAAS,CAGzB,EAAc,IAAIA,EAAAA,QAAY,UAClC,EAAE,CACFA,EAAAA,QAAY,QAAQ,eACrB,CAGK,EAAW,CACf,GAAI,EAAiB,OAAS,EAAI,CAAE,SAAU,EAAkB,CAAG,EAAE,CACrE,GAAI,EAAc,OAAS,EAAI,CAAE,eAAgB,EAAe,CAAG,EAAE,CAErE,GAAI,EAAiB,OAAS,EAAc,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AGK,EAAW,CACf,GAAI,EAAc,OAAS,EAAI,CAAE,eAAgB,EAAe,CAAG,EAAE,CACrE,GAAI,EAAS,CAAE,SAAQ,CAAG,EAAE,CAC5B,GAAI,EAAY,OAAS,EAAI,CAAE,UAAW,EAAa,CAAG,EAAE,CAC7D,CAGK,CACJ,wCAAyC,CAAE,eACzC,MAAMC,EAAAA,EAMP,EAAQC,EAAAA,GAAa,CACtB,WACD,CAAC,CAEF,EAAA,EAAO,KAAK,EAAA,QAAO,QAAQ,0CAA0C,CAAC,CAEtE,EAAY,MAAM,EAAY,EAAE,CAChC,IAAI,EAAQ,EACR,EAAiB,GACjB,EACA,EAAS,EACb,EACE,IAAI,CACF,GAAM,CACJ,wCAAyC,CAAE,UACzC,MAAMD,EAAAA,EAOR,EACA,EAAA,GAAG;;;;;;;;;;;;;;;;;kBAiBO,EAA2B,OAAS,GAAG;kBACvC,EAA2B,iBAAmB,GAAG;;;;;;;;;;;;UAa3D,CACE,MAAO,EACP,SACA,SAAU,CACR,GAAG,EACJ,CACF,CACF,CAED,EAAS,EAAM,EAAM,OAAS,IAAI,GAClC,EAAwC,KAAK,GAAG,EAAM,CACtD,EAAiB,EAAM,SAAW,EAClC,GAAS,EAAM,OACf,GAAU,EAAM,OAChB,EAAY,OAAO,EAAM,OAClB,EAAK,CAMZ,MALA,EAAA,EAAO,MACL,EAAA,QAAO,IACL,8CAA8C,EAAO,cAAc,IACpE,CACF,CACK,QAED,GAET,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAEjB,EAASE,EAAAA,GAAO,EAAyC,OAAO,CAStE,OAPA,EAAA,EAAO,KACL,EAAA,QAAO,MACL,0BAA0B,EAAO,OAAO,oBACtC,EAAY,IACb,WACF,CACF,CACM"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`./syncConfigurationToTranscend-
|
|
2
|
-
//# sourceMappingURL=dataFlowsToDataSilos-
|
|
1
|
+
const e=require(`./syncConfigurationToTranscend-DkeLrq-I.cjs`);var t=e.Bs(function(t){return e.Ns(e.zs(t,1,e.Ls,!0))}),n=t;function r(e,{adTechPurposes:t=[`SaleOfInfo`],serviceToTitle:r,serviceToSupportedIntegration:i}){let a=[],o=[],s={};e.forEach(e=>{let{service:r,attributes:i=[]}=e;if(!r||r===`internalService`)return;let c=i.find(e=>e.key===`Found on Domain`);c&&(s[r]||(s[r]=[]),s[r].push(...c.values.map(e=>e.replace(`https://`,``).replace(`http://`,``))),s[r]=[...new Set(s[r])]),n(e.trackingPurposes,t).length>0?(o.push(r),a.includes(r)&&(a=a.filter(e=>e!==r))):o.includes(r)||a.push(r)});let c=[...new Set(o)].map(e=>({title:r[e],...i[e]?{integrationName:e}:{integrationName:`promptAPerson`,"outer-type":e},attributes:[{key:`Tech Type`,values:[`Ad Tech`]},{key:`Found On Domain`,values:s[e]||[]}]}));return{siteTechDataSilos:[...new Set(a)].map(e=>({title:r[e],...i[e]?{integrationName:e}:{integrationName:`promptAPerson`,outerType:e},attributes:[{key:`Tech Type`,values:[`Site Tech`]},{key:`Found On Domain`,values:s[e]||[]}]})),adTechDataSilos:c}}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}});
|
|
2
|
+
//# sourceMappingURL=dataFlowsToDataSilos-B7nTxawV.cjs.map
|
package/dist/{dataFlowsToDataSilos-CnvG2jqy.cjs.map → dataFlowsToDataSilos-B7nTxawV.cjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataFlowsToDataSilos-
|
|
1
|
+
{"version":3,"file":"dataFlowsToDataSilos-B7nTxawV.cjs","names":["baseRest","baseUniq","baseFlatten","isArrayLikeObject","union"],"sources":["../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/union.js","../src/lib/consent-manager/dataFlowsToDataSilos.ts"],"sourcesContent":["import baseFlatten from './_baseFlatten.js';\nimport baseRest from './_baseRest.js';\nimport baseUniq from './_baseUniq.js';\nimport isArrayLikeObject from './isArrayLikeObject.js';\n\n/**\n * Creates an array of unique values, in order, from all given arrays using\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @returns {Array} Returns the new array of combined values.\n * @example\n *\n * _.union([2], [1, 2]);\n * // => [2, 1]\n */\nvar union = baseRest(function(arrays) {\n return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));\n});\n\nexport default union;\n","import { DataFlowInput, DataSiloInput } from '../../codecs';\nimport { union } from 'lodash-es';\nimport { IndexedCatalogs } from '../graphql';\n\n/**\n * Convert data flow configurations into a set of data silo configurations\n *\n * @param inputs - Data flow input to convert to data silos\n * @param options - Additional options\n * @returns Business entity configuration input\n */\nexport function dataFlowsToDataSilos(\n inputs: DataFlowInput[],\n {\n adTechPurposes = ['SaleOfInfo'],\n serviceToTitle,\n serviceToSupportedIntegration,\n }: IndexedCatalogs & {\n /** List of purposes that are considered \"Ad Tech\" */\n adTechPurposes?: string[];\n },\n): {\n /** List of data silo configurations for site-tech services */\n siteTechDataSilos: DataSiloInput[];\n /** List of data silo configurations for ad-tech services */\n adTechDataSilos: DataSiloInput[];\n} {\n // List of site tech integrations\n let siteTechIntegrations: string[] = [];\n\n // List of ad tech integrations\n const adTechIntegrations: string[] = [];\n\n // Mapping from service name to list of\n const serviceToFoundOnDomain: { [k in string]: string[] } = {};\n\n // iterate over each flow\n inputs.forEach((flow) => {\n // process data flows with services\n const { service, attributes = [] } = flow;\n if (!service || service === 'internalService') {\n return;\n }\n\n // create mapping to found on domain\n const foundOnDomain = attributes.find(\n (attr) => attr.key === 'Found on Domain',\n );\n\n // Create a list of all domains where the data flow was found\n if (foundOnDomain) {\n if (!serviceToFoundOnDomain[service]) {\n serviceToFoundOnDomain[service] = [];\n }\n serviceToFoundOnDomain[service]!.push(\n ...foundOnDomain.values.map((v) =>\n v.replace('https://', '').replace('http://', ''),\n ),\n );\n serviceToFoundOnDomain[service] = [\n ...new Set(serviceToFoundOnDomain[service]),\n ];\n }\n\n // Keep track of ad tech\n if (union(flow.trackingPurposes, adTechPurposes).length > 0) {\n // add service to ad tech list\n adTechIntegrations.push(service);\n\n // remove from site tech list\n if (siteTechIntegrations.includes(service)) {\n siteTechIntegrations = siteTechIntegrations.filter(\n (s) => s !== service,\n );\n }\n } else if (!adTechIntegrations.includes(service)) {\n // add to site tech list\n siteTechIntegrations.push(service);\n }\n });\n\n // create the list of ad tech integrations\n const adTechDataSilos = [...new Set(adTechIntegrations)].map((service) => ({\n title: serviceToTitle[service],\n ...(serviceToSupportedIntegration[service]\n ? { integrationName: service }\n : { integrationName: 'promptAPerson', 'outer-type': service }),\n attributes: [\n {\n key: 'Tech Type',\n values: ['Ad Tech'],\n },\n {\n key: 'Found On Domain',\n values: serviceToFoundOnDomain[service] || [],\n },\n ],\n }));\n\n // create the list of site tech integrations\n const siteTechDataSilos = [...new Set(siteTechIntegrations)].map(\n (service) => ({\n title: serviceToTitle[service],\n ...(serviceToSupportedIntegration[service]\n ? { integrationName: service }\n : { integrationName: 'promptAPerson', outerType: service }),\n attributes: [\n {\n key: 'Tech Type',\n values: ['Site Tech'],\n },\n {\n key: 'Found On Domain',\n values: serviceToFoundOnDomain[service] || [],\n },\n ],\n }),\n );\n\n return {\n siteTechDataSilos,\n adTechDataSilos,\n };\n}\n"],"x_google_ignoreList":[0],"mappings":"+DAqBA,IAAI,EAAQA,EAAAA,GAAS,SAAS,EAAQ,CACpC,OAAOC,EAAAA,GAASC,EAAAA,GAAY,EAAQ,EAAGC,EAAAA,GAAmB,GAAK,CAAC,EAChE,CAEF,EAAe,ECdf,SAAgB,EACd,EACA,CACE,iBAAiB,CAAC,aAAa,CAC/B,iBACA,iCAUF,CAEA,IAAI,EAAiC,EAAE,CAGjC,EAA+B,EAAE,CAGjC,EAAsD,EAAE,CAG9D,EAAO,QAAS,GAAS,CAEvB,GAAM,CAAE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|
-
require(`./constants-
|
|
2
|
-
//# sourceMappingURL=impl-
|
|
1
|
+
require(`./constants-CzmvL6Mw.cjs`);const e=require(`./syncConfigurationToTranscend-DkeLrq-I.cjs`);require(`./enums-BZulhPFa.cjs`),require(`./logger-DQwEYtSS.cjs`),require(`./buildAIIntegrationType-BwuCYR-o.cjs`);const t=require(`./done-input-validation-DGckEJ5a.cjs`);async function n({auth:n,actions:r,statuses:i=[],requestIds:a,silentModeBefore:o,createdAtBefore:s,createdAtAfter:c,updatedAtBefore:l,updatedAtAfter:u,cancellationTitle:d,transcendUrl:f,concurrency:p}){t.t(this.process.exit),await e.q({transcendUrl:f,requestActions:r,auth:n,cancellationTitle:d,requestIds:a,statuses:i,concurrency:p,silentModeBefore:o?new Date(o):void 0,createdAtBefore:s?new Date(s):void 0,createdAtAfter:c?new Date(c):void 0,updatedAtBefore:l?new Date(l):void 0,updatedAtAfter:u?new Date(u):void 0})}exports.cancel=n;
|
|
2
|
+
//# sourceMappingURL=impl-1qwMfsU4.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"impl-
|
|
1
|
+
{"version":3,"file":"impl-1qwMfsU4.cjs","names":["cancelPrivacyRequests"],"sources":["../src/commands/request/cancel/impl.ts"],"sourcesContent":["import type { LocalContext } from '../../../context';\nimport { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport { cancelPrivacyRequests } from '../../../lib/requests';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation';\n\nexport interface CancelCommandFlags {\n auth: string;\n actions: RequestAction[];\n statuses?: RequestStatus[];\n requestIds?: string[];\n silentModeBefore?: Date;\n createdAtBefore?: Date;\n createdAtAfter?: Date;\n updatedAtBefore?: Date;\n updatedAtAfter?: Date;\n cancellationTitle: string;\n transcendUrl: string;\n concurrency: number;\n}\n\nexport async function cancel(\n this: LocalContext,\n {\n auth,\n actions,\n statuses = [],\n requestIds,\n silentModeBefore,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n cancellationTitle,\n transcendUrl,\n concurrency,\n }: CancelCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n await cancelPrivacyRequests({\n transcendUrl,\n requestActions: actions,\n auth,\n cancellationTitle,\n requestIds,\n statuses,\n concurrency,\n silentModeBefore: silentModeBefore ? new Date(silentModeBefore) : undefined,\n createdAtBefore: createdAtBefore ? new Date(createdAtBefore) : undefined,\n createdAtAfter: createdAtAfter ? new Date(createdAtAfter) : undefined,\n updatedAtBefore: updatedAtBefore ? new Date(updatedAtBefore) : undefined,\n updatedAtAfter: updatedAtAfter ? new Date(updatedAtAfter) : undefined,\n });\n}\n"],"mappings":"6QAoBA,eAAsB,EAEpB,CACE,OACA,UACA,WAAW,EAAE,CACb,aACA,mBACA,kBACA,iBACA,kBACA,iBACA,oBACA,eACA,eAEa,CACf,EAAA,EAAoB,KAAK,QAAQ,KAAK,CAEtC,MAAMA,EAAAA,EAAsB,CAC1B,eACA,eAAgB,EAChB,OACA,oBACA,aACA,WACA,cACA,iBAAkB,EAAmB,IAAI,KAAK,EAAiB,CAAG,IAAA,GAClE,gBAAiB,EAAkB,IAAI,KAAK,EAAgB,CAAG,IAAA,GAC/D,eAAgB,EAAiB,IAAI,KAAK,EAAe,CAAG,IAAA,GAC5D,gBAAiB,EAAkB,IAAI,KAAK,EAAgB,CAAG,IAAA,GAC/D,eAAgB,EAAiB,IAAI,KAAK,EAAe,CAAG,IAAA,GAC7D,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`./chunk-Bmb41Sf3.cjs`);require(`./constants-
|
|
2
|
-
//# sourceMappingURL=impl-
|
|
1
|
+
const e=require(`./chunk-Bmb41Sf3.cjs`);require(`./constants-CzmvL6Mw.cjs`);const t=require(`./syncConfigurationToTranscend-DkeLrq-I.cjs`);require(`./enums-BZulhPFa.cjs`);const n=require(`./logger-DQwEYtSS.cjs`);require(`./buildAIIntegrationType-BwuCYR-o.cjs`),require(`./codecs-Bvmb8o9R.cjs`);const r=require(`./consent-manager-CJZ5GTmv.cjs`);require(`./uploadConsents-zr1Hg-JE.cjs`);const i=require(`./api-keys-y8Txn6tT.cjs`),a=require(`./done-input-validation-DGckEJ5a.cjs`);let o=require(`@transcend-io/privacy-types`),s=require(`colors`);s=e.t(s);async function c({auth:e,bundleTypes:c=[o.ConsentBundleType.Production,o.ConsentBundleType.Test],deploy:l,transcendUrl:u}){a.t(this.process.exit);let d=await i.r(e);typeof d==`string`?(await r.c({deploy:l,transcendUrl:u,auth:d,bundleTypes:c}),n.t.info(s.default.green(`Successfully updated Consent Manager!`))):(await t.js(d,async e=>{n.t.info(s.default.magenta(`Updating Consent Manager for organization "${e.organizationName}"...`)),await r.c({deploy:l,transcendUrl:u,auth:e.apiKey,bundleTypes:c}),n.t.info(s.default.green(`Successfully updated Consent Manager for organization "${e.organizationName}"!`))}),n.t.info(s.default.green(`Successfully updated Consent Managers!`)))}exports.updateConsentManager=c;
|
|
2
|
+
//# sourceMappingURL=impl-8HXqFDdD.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"impl-
|
|
1
|
+
{"version":3,"file":"impl-8HXqFDdD.cjs","names":["ConsentBundleType","validateTranscendAuth","updateConsentManagerVersionToLatest","mapSeries"],"sources":["../src/commands/consent/update-consent-manager/impl.ts"],"sourcesContent":["import type { LocalContext } from '../../../context';\nimport colors from 'colors';\nimport { ConsentBundleType } from '@transcend-io/privacy-types';\nimport { mapSeries } from '../../../lib/bluebird';\n\nimport { logger } from '../../../logger';\nimport { updateConsentManagerVersionToLatest } from '../../../lib/consent-manager';\nimport { validateTranscendAuth } from '../../../lib/api-keys';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation';\n\nexport interface UpdateConsentManagerCommandFlags {\n auth: string;\n bundleTypes: ConsentBundleType[];\n deploy: boolean;\n transcendUrl: string;\n}\n\nexport async function updateConsentManager(\n this: LocalContext,\n {\n auth,\n bundleTypes = [ConsentBundleType.Production, ConsentBundleType.Test],\n deploy,\n transcendUrl,\n }: UpdateConsentManagerCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n // Parse authentication as API key or path to list of API keys\n const apiKeyOrList = await validateTranscendAuth(auth);\n\n // Handle single update\n if (typeof apiKeyOrList === 'string') {\n // Update consent manager\n await updateConsentManagerVersionToLatest({\n deploy,\n transcendUrl,\n auth: apiKeyOrList,\n bundleTypes,\n });\n logger.info(colors.green('Successfully updated Consent Manager!'));\n } else {\n await mapSeries(apiKeyOrList, async (apiKey) => {\n logger.info(\n colors.magenta(\n `Updating Consent Manager for organization \"${apiKey.organizationName}\"...`,\n ),\n );\n\n await updateConsentManagerVersionToLatest({\n deploy,\n transcendUrl,\n auth: apiKey.apiKey,\n bundleTypes,\n });\n\n logger.info(\n colors.green(\n `Successfully updated Consent Manager for organization \"${apiKey.organizationName}\"!`,\n ),\n );\n });\n logger.info(colors.green('Successfully updated Consent Managers!'));\n }\n}\n"],"mappings":"wiBAiBA,eAAsB,EAEpB,CACE,OACA,cAAc,CAACA,EAAAA,kBAAkB,WAAYA,EAAAA,kBAAkB,KAAK,CACpE,SACA,gBAEa,CACf,EAAA,EAAoB,KAAK,QAAQ,KAAK,CAGtC,IAAM,EAAe,MAAMC,EAAAA,EAAsB,EAAK,CAGlD,OAAO,GAAiB,UAE1B,MAAMC,EAAAA,EAAoC,CACxC,SACA,eACA,KAAM,EACN,cACD,CAAC,CACF,EAAA,EAAO,KAAK,EAAA,QAAO,MAAM,wCAAwC,CAAC,GAElE,MAAMC,EAAAA,GAAU,EAAc,KAAO,IAAW,CAC9C,EAAA,EAAO,KACL,EAAA,QAAO,QACL,8CAA8C,EAAO,iBAAiB,MACvE,CACF,CAED,MAAMD,EAAAA,EAAoC,CACxC,SACA,eACA,KAAM,EAAO,OACb,cACD,CAAC,CAEF,EAAA,EAAO,KACL,EAAA,QAAO,MACL,0DAA0D,EAAO,iBAAiB,IACnF,CACF,EACD,CACF,EAAA,EAAO,KAAK,EAAA,QAAO,MAAM,yCAAyC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`./chunk-Bmb41Sf3.cjs`);require(`./constants-
|
|
2
|
-
//# sourceMappingURL=impl-
|
|
1
|
+
const e=require(`./chunk-Bmb41Sf3.cjs`);require(`./constants-CzmvL6Mw.cjs`);const t=require(`./syncConfigurationToTranscend-DkeLrq-I.cjs`);require(`./enums-BZulhPFa.cjs`);const n=require(`./logger-DQwEYtSS.cjs`);require(`./buildAIIntegrationType-BwuCYR-o.cjs`);const r=require(`./cron-Ts7kHP6_.cjs`),i=require(`./done-input-validation-DGckEJ5a.cjs`);let a=require(`colors`);a=e.t(a);async function o({file:e,fileTarget:o,transcendUrl:s,auth:c,sombraAuth:l,cronDataSiloId:u,targetDataSiloId:d,actions:f,skipRequestCount:p,pageLimit:m,chunkSize:h}){p&&n.t.info(a.default.yellow(`Skipping request count as requested. This may help speed up the call.`)),(Number.isNaN(h)||h<=0||h%m!==0)&&(n.t.error(a.default.red(`Invalid chunk size: "${h}". Must be a positive integer that is a multiple of ${m}.`)),this.process.exit(1)),i.t(this.process.exit);let g=t.ai(s,c),{baseName:_,extension:v}=t.c(e),{baseName:y,extension:b}=t.c(o),x=0,S=0,C=0;await r.t({dataSiloId:u,auth:c,sombraAuth:l,actions:f,apiPageSize:m,savePageSize:h,onSave:async r=>{x+=r.length;let i=await t.As(t.Rs(t.Ms(r.map(e=>e.requestId)),m),async e=>(n.t.info(a.default.magenta(`Fetching target identifiers for ${e.length} requests`)),(await t.Gn(g,m*2,{requestIds:e,dataSiloIds:[d]})).map(({fileName:e,remoteId:t})=>{if(!t)throw Error(`Failed to find remoteId for ${e}`);return{RecordId:t,Object:e.replace(`.json`,``).split(`/`).pop()?.replace(` Information`,``),Comment:`Customer data deletion request submitted via transcend.io`}})),{concurrency:1});S+=i.flat().length;let s=t.Ms(r.map(e=>Object.keys(e)).flat()),c=`${_}-${C}${v}`,l=`${y}-${C}${b}`;await t.d(c,r,s),n.t.info(a.default.green(`Successfully wrote ${r.length} identifiers to file "${e}"`));let u=i.flat();await t.d(l,u,t.Ms(u.map(e=>Object.keys(e)).flat())),n.t.info(a.default.green(`Successfully wrote ${u.length} identifiers to file "${o}"`)),n.t.info(a.default.blue(`Processed chunk of ${t.Rs.length} identifiers, found ${u.length} target identifiers`)),C+=1},transcendUrl:s,skipRequestCount:p}),n.t.info(a.default.green(`Successfully wrote ${x} identifiers to file "${e}"`)),n.t.info(a.default.green(`Successfully wrote ${S} identifiers to file "${o}"`))}exports.pullProfiles=o;
|
|
2
|
+
//# sourceMappingURL=impl-AZPWCkCp.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"impl-
|
|
1
|
+
{"version":3,"file":"impl-AZPWCkCp.cjs","names":["buildTranscendGraphQLClient","parseFilePath","map","chunk","uniq","fetchRequestFilesForRequest","writeLargeCsv","pullChunkedCustomSiloOutstandingIdentifiers"],"sources":["../src/commands/request/cron/pull-profiles/impl.ts"],"sourcesContent":["import type { RequestAction } from '@transcend-io/privacy-types';\nimport { logger } from '../../../../logger';\nimport colors from 'colors';\nimport { uniq, chunk } from 'lodash-es';\nimport { map } from '../../../../lib/bluebird';\nimport {\n buildTranscendGraphQLClient,\n fetchRequestFilesForRequest,\n} from '../../../../lib/graphql';\nimport type { LocalContext } from '../../../../context';\nimport {\n pullChunkedCustomSiloOutstandingIdentifiers,\n type CsvFormattedIdentifier,\n} from '../../../../lib/cron';\nimport { doneInputValidation } from '../../../../lib/cli/done-input-validation';\nimport { parseFilePath, writeLargeCsv } from '../../../../lib/helpers';\n\nexport interface PullProfilesCommandFlags {\n file: string;\n fileTarget: string;\n transcendUrl: string;\n auth: string;\n sombraAuth?: string;\n cronDataSiloId: string;\n targetDataSiloId: string;\n actions: RequestAction[];\n skipRequestCount: boolean;\n pageLimit: number;\n chunkSize: number;\n}\n\nexport async function pullProfiles(\n this: LocalContext,\n {\n file,\n fileTarget,\n transcendUrl,\n auth,\n sombraAuth,\n cronDataSiloId,\n targetDataSiloId,\n actions,\n skipRequestCount,\n pageLimit,\n chunkSize,\n }: PullProfilesCommandFlags,\n): Promise<void> {\n if (skipRequestCount) {\n logger.info(\n colors.yellow(\n 'Skipping request count as requested. This may help speed up the call.',\n ),\n );\n }\n\n if (\n Number.isNaN(chunkSize) ||\n chunkSize <= 0 ||\n chunkSize % pageLimit !== 0\n ) {\n logger.error(\n colors.red(\n `Invalid chunk size: \"${chunkSize}\". Must be a positive integer that is a multiple of ${pageLimit}.`,\n ),\n );\n this.process.exit(1);\n }\n\n doneInputValidation(this.process.exit);\n\n // Create GraphQL client to connect to Transcend backend\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n const { baseName, extension } = parseFilePath(file);\n const { baseName: baseNameTarget, extension: extensionTarget } =\n parseFilePath(fileTarget);\n\n let allIdentifiersCount = 0;\n let allTargetIdentifiersCount = 0;\n let fileCount = 0;\n // Create onSave callback to handle chunked processing\n const onSave = async (\n chunkToSave: CsvFormattedIdentifier[],\n ): Promise<void> => {\n // Add to all identifiers\n allIdentifiersCount += chunkToSave.length;\n\n // Get unique request IDs from this chunk\n const requestIds = chunkToSave.map((d) => d.requestId as string);\n const uniqueRequestIds = uniq(requestIds);\n\n // Pull down target identifiers for this chunk\n const chunkedRequestIds = chunk(uniqueRequestIds, pageLimit);\n const results = await map(\n chunkedRequestIds,\n async (requestIds) => {\n logger.info(\n colors.magenta(\n `Fetching target identifiers for ${requestIds.length} requests`,\n ),\n );\n const results = await fetchRequestFilesForRequest(\n client,\n pageLimit * 2,\n {\n requestIds,\n dataSiloIds: [targetDataSiloId],\n },\n );\n return results.map(({ fileName, remoteId }) => {\n if (!remoteId) {\n throw new Error(`Failed to find remoteId for ${fileName}`);\n }\n return {\n RecordId: remoteId,\n Object: fileName\n .replace('.json', '')\n .split('/')\n .pop()\n ?.replace(' Information', ''),\n Comment:\n 'Customer data deletion request submitted via transcend.io',\n };\n });\n },\n // We are grabbing all the request files for the 'pageLimit' # of requests at a time\n {\n concurrency: 1,\n },\n );\n\n allTargetIdentifiersCount += results.flat().length;\n\n // Write the identifiers and target identifiers to CSV\n const headers = uniq(chunkToSave.map((d) => Object.keys(d)).flat());\n const numberedFileName = `${baseName}-${fileCount}${extension}`;\n const numberedFileNameTarget = `${baseNameTarget}-${fileCount}${extensionTarget}`;\n await writeLargeCsv(numberedFileName, chunkToSave, headers);\n logger.info(\n colors.green(\n `Successfully wrote ${chunkToSave.length} identifiers to file \"${file}\"`,\n ),\n );\n\n const targetIdentifiers = results.flat();\n const headers2 = uniq(targetIdentifiers.map((d) => Object.keys(d)).flat());\n await writeLargeCsv(numberedFileNameTarget, targetIdentifiers, headers2);\n logger.info(\n colors.green(\n `Successfully wrote ${targetIdentifiers.length} identifiers to file \"${fileTarget}\"`,\n ),\n );\n\n logger.info(\n colors.blue(\n `Processed chunk of ${chunk.length} identifiers, found ${targetIdentifiers.length} target identifiers`,\n ),\n );\n fileCount += 1;\n };\n\n // Pull down outstanding identifiers using the new chunked function\n await pullChunkedCustomSiloOutstandingIdentifiers({\n dataSiloId: cronDataSiloId,\n auth,\n sombraAuth,\n actions,\n apiPageSize: pageLimit,\n savePageSize: chunkSize,\n onSave,\n transcendUrl,\n skipRequestCount,\n });\n\n logger.info(\n colors.green(\n `Successfully wrote ${allIdentifiersCount} identifiers to file \"${file}\"`,\n ),\n );\n logger.info(\n colors.green(\n `Successfully wrote ${allTargetIdentifiersCount} identifiers to file \"${fileTarget}\"`,\n ),\n );\n}\n"],"mappings":"+XA+BA,eAAsB,EAEpB,CACE,OACA,aACA,eACA,OACA,aACA,iBACA,mBACA,UACA,mBACA,YACA,aAEa,CACX,GACF,EAAA,EAAO,KACL,EAAA,QAAO,OACL,wEACD,CACF,EAID,OAAO,MAAM,EAAU,EACvB,GAAa,GACb,EAAY,IAAc,KAE1B,EAAA,EAAO,MACL,EAAA,QAAO,IACL,wBAAwB,EAAU,sDAAsD,EAAU,GACnG,CACF,CACD,KAAK,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AED,IAAM,EAAoB,EAAQ,MAAM,CAExC,MAAMA,EAAAA,EAAc,EAAwB,EAD3BF,EAAAA,GAAK,EAAkB,IAAK,GAAM,OAAO,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CACF,CACxE,EAAA,EAAO,KACL,EAAA,QAAO,MACL,sBAAsB,EAAkB,OAAO,wBAAwB,EAAW,GACnF,CACF,CAED,EAAA,EAAO,KACL,EAAA,QAAO,KACL,sBAAsBD,EAAAA,GAAM,OAAO,sBAAsB,EAAkB,OAAO,qBACnF,CACF,CACD,GAAa,GAYb,eACA,mBACD,CAAC,CAEF,EAAA,EAAO,KACL,EAAA,QAAO,MACL,sBAAsB,EAAoB,wBAAwB,EAAK,GACxE,CACF,CACD,EAAA,EAAO,KACL,EAAA,QAAO,MACL,sBAAsB,EAA0B,wBAAwB,EAAW,GACpF,CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`./chunk-Bmb41Sf3.cjs`);require(`./constants-
|
|
2
|
-
//# sourceMappingURL=impl-
|
|
1
|
+
const e=require(`./chunk-Bmb41Sf3.cjs`);require(`./constants-CzmvL6Mw.cjs`),require(`./syncConfigurationToTranscend-DkeLrq-I.cjs`),require(`./enums-BZulhPFa.cjs`);const t=require(`./logger-DQwEYtSS.cjs`);require(`./buildAIIntegrationType-BwuCYR-o.cjs`),require(`./codecs-Bvmb8o9R.cjs`);const n=require(`./readTranscendYaml-Cycz6RxW.cjs`),r=require(`./consent-manager-CJZ5GTmv.cjs`);require(`./uploadConsents-zr1Hg-JE.cjs`);const i=require(`./api-keys-y8Txn6tT.cjs`),a=require(`./done-input-validation-DGckEJ5a.cjs`);let o=require(`node:fs`),s=require(`node:path`),c=require(`colors`);c=e.t(c);function l({consentManagerYmlFolder:e,output:l}){a.t(this.process.exit),(!(0,o.existsSync)(e)||!(0,o.lstatSync)(e).isDirectory())&&(t.t.error(c.default.red(`Folder does not exist: "${e}"`)),this.process.exit(1));let u=r.t(i.n(e).map(t=>{let{"consent-manager":r}=n.r((0,s.join)(e,t));return{name:t,input:r}}));n.a(l,{"business-entities":u}),t.t.info(c.default.green(`Successfully wrote ${u.length} business entities to file "${l}"`))}exports.consentManagersToBusinessEntities=l;
|
|
2
|
+
//# sourceMappingURL=impl-B61wd2KQ.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"impl-
|
|
1
|
+
{"version":3,"file":"impl-B61wd2KQ.cjs","names":["consentManagersToBusinessEntitiesHelper","listFiles","readTranscendYaml"],"sources":["../src/commands/inventory/consent-managers-to-business-entities/impl.ts"],"sourcesContent":["import type { LocalContext } from '../../../context';\nimport { listFiles } from '../../../lib/api-keys';\nimport { consentManagersToBusinessEntities as consentManagersToBusinessEntitiesHelper } from '../../../lib/consent-manager';\nimport {\n readTranscendYaml,\n writeTranscendYaml,\n} from '../../../lib/readTranscendYaml';\nimport { join } from 'node:path';\n\nimport colors from 'colors';\nimport { logger } from '../../../logger';\nimport { existsSync, lstatSync } from 'node:fs';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation';\n\nexport interface ConsentManagersToBusinessEntitiesCommandFlags {\n consentManagerYmlFolder: string;\n output: string;\n}\n\nexport function consentManagersToBusinessEntities(\n this: LocalContext,\n {\n consentManagerYmlFolder,\n output,\n }: ConsentManagersToBusinessEntitiesCommandFlags,\n): void {\n doneInputValidation(this.process.exit);\n\n // Ensure folder is passed\n if (\n !existsSync(consentManagerYmlFolder) ||\n !lstatSync(consentManagerYmlFolder).isDirectory()\n ) {\n logger.error(\n colors.red(`Folder does not exist: \"${consentManagerYmlFolder}\"`),\n );\n this.process.exit(1);\n }\n\n // Read in each consent manager configuration\n const inputs = listFiles(consentManagerYmlFolder).map((directory) => {\n const { 'consent-manager': consentManager } = readTranscendYaml(\n join(consentManagerYmlFolder, directory),\n );\n return { name: directory, input: consentManager };\n });\n\n // Convert to business entities\n const businessEntities = consentManagersToBusinessEntitiesHelper(inputs);\n\n // write to disk\n writeTranscendYaml(output, {\n 'business-entities': businessEntities,\n });\n\n logger.info(\n colors.green(\n `Successfully wrote ${businessEntities.length} business entities to file \"${output}\"`,\n ),\n );\n}\n"],"mappings":"ilBAmBA,SAAgB,EAEd,CACE,0BACA,UAEI,CACN,EAAA,EAAoB,KAAK,QAAQ,KAAK,EAIpC,EAAA,EAAA,EAAA,YAAY,EAAwB,EACpC,EAAA,EAAA,EAAA,WAAW,EAAwB,CAAC,aAAa,IAEjD,EAAA,EAAO,MACL,EAAA,QAAO,IAAI,2BAA2B,EAAwB,GAAG,CAClE,CACD,KAAK,QAAQ,KAAK,EAAE,EAYtB,IAAM,EAAmBA,EAAAA,EARVC,EAAAA,EAAU,EAAwB,CAAC,IAAK,GAAc,CACnE,GAAM,CAAE,kBAAmB,GAAmBC,EAAAA,GAAAA,EAAAA,EAAAA,MACvC,EAAyB,EAAU,CACzC,CACD,MAAO,CAAE,KAAM,EAAW,MAAO,EAAgB,EACjD,CAGsE,CAGxE,EAAA,EAAmB,EAAQ,CACzB,oBAAqB,EACtB,CAAC,CAEF,EAAA,EAAO,KACL,EAAA,QAAO,MACL,sBAAsB,EAAiB,OAAO,8BAA8B,EAAO,GACpF,CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require(`./constants-
|
|
2
|
-
//# sourceMappingURL=impl-
|
|
1
|
+
require(`./constants-CzmvL6Mw.cjs`);const e=require(`./syncConfigurationToTranscend-DkeLrq-I.cjs`);require(`./enums-BZulhPFa.cjs`),require(`./logger-DQwEYtSS.cjs`),require(`./buildAIIntegrationType-BwuCYR-o.cjs`);const t=require(`./done-input-validation-DGckEJ5a.cjs`);async function n({auth:n,dataSiloId:r,status:i,statuses:a,transcendUrl:o}){t.t(this.process.exit),await e.F({transcendUrl:o,auth:n,status:i,dataSiloId:r,requestStatuses:a})}exports.skipRequestDataSilos=n;
|
|
2
|
+
//# sourceMappingURL=impl-B8rg6CMv.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"impl-
|
|
1
|
+
{"version":3,"file":"impl-B8rg6CMv.cjs","names":["skipRequestDataSilosHelper"],"sources":["../src/commands/request/system/skip-request-data-silos/impl.ts"],"sourcesContent":["import type { LocalContext } from '../../../../context';\nimport type {\n RequestDataSiloStatus,\n RequestStatus,\n} from '@transcend-io/privacy-types';\nimport { skipRequestDataSilos as skipRequestDataSilosHelper } from '../../../../lib/requests';\nimport { doneInputValidation } from '../../../../lib/cli/done-input-validation';\n\nexport interface SkipRequestDataSilosCommandFlags {\n auth: string;\n dataSiloId: string;\n transcendUrl: string;\n statuses: RequestStatus[];\n status:\n | (typeof RequestDataSiloStatus)['Skipped']\n | (typeof RequestDataSiloStatus)['Resolved'];\n}\n\nexport async function skipRequestDataSilos(\n this: LocalContext,\n {\n auth,\n dataSiloId,\n status,\n statuses,\n transcendUrl,\n }: SkipRequestDataSilosCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n await skipRequestDataSilosHelper({\n transcendUrl,\n auth,\n status,\n dataSiloId,\n requestStatuses: statuses,\n });\n}\n"],"mappings":"6QAkBA,eAAsB,EAEpB,CACE,OACA,aACA,SACA,WACA,gBAEa,CACf,EAAA,EAAoB,KAAK,QAAQ,KAAK,CAEtC,MAAMA,EAAAA,EAA2B,CAC/B,eACA,OACA,SACA,aACA,gBAAiB,EAClB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require(`./constants-
|
|
2
|
-
//# sourceMappingURL=impl-
|
|
1
|
+
require(`./constants-CzmvL6Mw.cjs`),require(`./syncConfigurationToTranscend-DkeLrq-I.cjs`),require(`./enums-BZulhPFa.cjs`),require(`./logger-DQwEYtSS.cjs`),require(`./buildAIIntegrationType-BwuCYR-o.cjs`),require(`./codecs-Bvmb8o9R.cjs`);const e=require(`./consent-manager-CJZ5GTmv.cjs`);require(`./uploadConsents-zr1Hg-JE.cjs`);const t=require(`./done-input-validation-DGckEJ5a.cjs`);async function n({auth:n,trackerStatus:r,file:i,classifyService:a,transcendUrl:o}){t.t(this.process.exit),await e.s({auth:n,trackerStatus:r,file:i,classifyService:a,transcendUrl:o})}exports.uploadDataFlowsFromCsv=n;
|
|
2
|
+
//# sourceMappingURL=impl-BIjDq-3S.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"impl-
|
|
1
|
+
{"version":3,"file":"impl-BIjDq-3S.cjs","names":["uploadDataFlowsFromCsvHelper"],"sources":["../src/commands/consent/upload-data-flows-from-csv/impl.ts"],"sourcesContent":["import type { LocalContext } from '../../../context';\nimport { uploadDataFlowsFromCsv as uploadDataFlowsFromCsvHelper } from '../../../lib/consent-manager';\nimport { ConsentTrackerStatus } from '@transcend-io/privacy-types';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation';\n\nexport interface UploadDataFlowsFromCsvCommandFlags {\n auth: string;\n trackerStatus: ConsentTrackerStatus;\n file: string;\n classifyService: boolean;\n transcendUrl: string;\n}\n\nexport async function uploadDataFlowsFromCsv(\n this: LocalContext,\n {\n auth,\n trackerStatus,\n file,\n classifyService,\n transcendUrl,\n }: UploadDataFlowsFromCsvCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n await uploadDataFlowsFromCsvHelper({\n auth,\n trackerStatus,\n file,\n classifyService,\n transcendUrl,\n });\n}\n"],"mappings":"iYAaA,eAAsB,EAEpB,CACE,OACA,gBACA,OACA,kBACA,gBAEa,CACf,EAAA,EAAoB,KAAK,QAAQ,KAAK,CAEtC,MAAMA,EAAAA,EAA6B,CACjC,OACA,gBACA,OACA,kBACA,eACD,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`./chunk-Bmb41Sf3.cjs`);require(`./constants-
|
|
2
|
-
//# sourceMappingURL=impl-
|
|
1
|
+
const e=require(`./chunk-Bmb41Sf3.cjs`);require(`./constants-CzmvL6Mw.cjs`);const t=require(`./syncConfigurationToTranscend-DkeLrq-I.cjs`);require(`./enums-BZulhPFa.cjs`);const n=require(`./logger-DQwEYtSS.cjs`);require(`./buildAIIntegrationType-BwuCYR-o.cjs`);const r=require(`./pooling-Dw0a42I_.cjs`),i=require(`./done-input-validation-DGckEJ5a.cjs`);let a=require(`colors`);a=e.t(a);async function o(){let e=Number(process.env.WORKER_ID||`0`);n.t.info(`[w${e}] ready pid=${process.pid}`),process.send?.({type:`ready`}),process.on(`message`,async r=>{if(!r||typeof r!=`object`||(r.type===`shutdown`&&process.exit(0),r.type!==`task`))return;let{filePath:i,options:a}=r.payload,{outputDir:o,clearOutputDir:s}=a;try{n.t.info(`[w${e}] processing ${i}`);let{DuckDBInstance:r}=await import(`@duckdb/node-api`);await t.b({filePath:i,outputDir:o,clearOutputDir:s,onProgress:(e,t)=>process.send?.({type:`progress`,payload:{filePath:i,processed:e,total:t}})},r),process.send?.({type:`result`,payload:{ok:!0,filePath:i}})}catch(r){let a=t.O(r);n.t.error(`[w${e}] ERROR ${i}: ${r.stack||a}`),process.send?.({type:`result`,payload:{ok:!1,filePath:i,error:a}})}}),await new Promise(()=>{})}function s(e){return r.r(e)}function c(e){return r.i(e)}const l={renderHeader:s,renderWorkers:c};function u(){return typeof __filename<`u`?__filename:process.argv[1]}async function d(e){i.t(this.process.exit);let{directory:o,outputDir:s,clearOutputDir:c,concurrency:d,viewerMode:f}=e,p=t.x(o,this),{poolSize:m,cpuCount:h}=r.s(d,p.length);n.t.info(a.default.green(`Converting ${p.length} Parquet file(s) → CSV with pool size ${m} (CPU=${h})`));let g=p.map(e=>({filePath:e,options:{outputDir:s,clearOutputDir:c}}));await r.n({title:`Parquet → CSV - ${o}`,baseDir:o||s||process.cwd(),childFlag:r.o,childModulePath:u(),poolSize:m,cpuCount:h,filesTotal:p.length,hooks:{nextTask:()=>g.shift(),taskLabel:e=>e.filePath,initTotals:()=>({}),initSlotProgress:()=>void 0,onProgress:e=>e,onResult:(e,t)=>({totals:e,ok:!!t.ok}),postProcess:async()=>{}},viewerMode:f,render:e=>r.a(e,l,f),extraKeyHandler:({logsBySlot:e,repaint:t,setPaused:n})=>r.t({logsBySlot:e,repaint:t,setPaused:n})})}process.argv.includes(r.o)&&o().catch(e=>{n.t.error(e),process.exit(1)}),exports.parquetToCsv=d;
|
|
2
|
+
//# sourceMappingURL=impl-BPxZw3LN.cjs.map
|