@transcend-io/cli 7.0.0-alpha.3 → 7.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/bash-complete.js +1 -1
- package/dist/bin/cli.js +1 -1
- package/dist/bin/deprecated-command.js +1 -1
- package/dist/{chunk-4ZW3XBZV.js → chunk-2U7DMWVM.js} +1 -1
- package/dist/{chunk-CMG5ZYLE.js → chunk-36OYCQAH.js} +1 -1
- package/dist/{chunk-NMRI6QFR.js → chunk-BHDQRYCC.js} +1 -1
- package/dist/{chunk-FV7557JH.js → chunk-DDYFIYCC.js} +1 -1
- package/dist/{chunk-LVQ3VJ2W.js → chunk-IX57OTFV.js} +1 -1
- package/dist/{chunk-3GMPEWZU.js → chunk-J2A7ZQZK.js} +1 -1
- package/dist/{chunk-WUZVHBZ6.js → chunk-LB26GOGN.js} +1 -1
- package/dist/{chunk-7NWTOLV6.js → chunk-PC5LFPCL.js} +1 -1
- package/dist/{chunk-YAW3NWII.js → chunk-QPPYCG3K.js} +1 -1
- package/dist/{chunk-ZSQRC7CE.js → chunk-RIVSSQAD.js} +1 -1
- package/dist/{chunk-LYA6JDF3.js → chunk-SNE53JL2.js} +1 -1
- package/dist/{chunk-GCT6ASWD.js → chunk-UJC7455L.js} +9 -9
- package/dist/{chunk-VOSDKHIQ.js → chunk-VH4PAOVV.js} +1 -1
- package/dist/{impl-QEJPFCJI.js → impl-23A44LMH.js} +1 -1
- package/dist/{impl-WNH7YI6Z.js → impl-3O7U2A5Z.js} +1 -1
- package/dist/{impl-PY6QMFDF.js → impl-57MM7K6S.js} +1 -1
- package/dist/{impl-D7BMJMXZ.js → impl-5JQWZE22.js} +1 -1
- package/dist/{impl-JMTECOZS.js → impl-6TW2ZJGW.js} +1 -1
- package/dist/{impl-7MUJH6P5.js → impl-BT4YFJXD.js} +1 -1
- package/dist/{impl-OFNYLVXQ.js → impl-BUGOJ622.js} +1 -1
- package/dist/{impl-GCOOAYPD.js → impl-CQWNM6M6.js} +1 -1
- package/dist/{impl-EB7RIOVE.js → impl-FQ4JY3PM.js} +1 -1
- package/dist/{impl-34GPMXPL.js → impl-FTOWS4LT.js} +1 -1
- package/dist/{impl-PC6DNGTZ.js → impl-GTNPTYRN.js} +1 -1
- package/dist/{impl-LDFZSLYD.js → impl-GURN665S.js} +1 -1
- package/dist/{impl-YDRXS46V.js → impl-HI7GPKJS.js} +1 -1
- package/dist/{impl-SJQV2OMC.js → impl-IIR7UIYH.js} +1 -1
- package/dist/{impl-XGATOXTC.js → impl-IRPIOI7A.js} +1 -1
- package/dist/{impl-52WERFAD.js → impl-JD3GTCZX.js} +1 -1
- package/dist/{impl-4PM5ANUA.js → impl-JMDCSKFW.js} +1 -1
- package/dist/{impl-FLM53BCK.js → impl-L7FPB5XK.js} +1 -1
- package/dist/{impl-A2USYIKE.js → impl-LEORLG3G.js} +1 -1
- package/dist/{impl-OUM2TMCA.js → impl-LQ4FGFCT.js} +1 -1
- package/dist/{impl-ZEOQDQGJ.js → impl-LR3KH6HF.js} +1 -1
- package/dist/{impl-NZAJVL4T.js → impl-MSPLKNAC.js} +1 -1
- package/dist/{impl-V6VQDET2.js → impl-NCQGE4HN.js} +1 -1
- package/dist/{impl-GBFIC5HA.js → impl-P36LWMYL.js} +1 -1
- package/dist/{impl-U5UP4IPY.js → impl-PIVVUTJ5.js} +1 -1
- package/dist/{impl-DPXDEQNI.js → impl-R4TN5WE6.js} +1 -1
- package/dist/{impl-ZW2R7XBD.js → impl-SE4W22MX.js} +1 -1
- package/dist/{impl-WW7Y6LSR.js → impl-TOCVOZ7D.js} +1 -1
- package/dist/{impl-VJE75UCF.js → impl-TWDD35U4.js} +1 -1
- package/dist/{impl-6YBT2TVS.js → impl-UAO73YJW.js} +1 -1
- package/dist/{impl-E47RFIQN.js → impl-UAP5BU4W.js} +1 -1
- package/dist/{impl-D5B5PHQ3.js → impl-V2POCVEM.js} +1 -1
- package/dist/{impl-W3HV7NRK.js → impl-VSIEMKCJ.js} +1 -1
- package/dist/{impl-MYQ2JZZW.js → impl-WWUVCY2C.js} +1 -1
- package/dist/{impl-5BJNBSJM.js → impl-YUZJV3RL.js} +1 -1
- package/dist/{impl-ZNK4HGCU.js → impl-Z4MBWRSS.js} +1 -1
- package/dist/{impl-2FMVZQC3.js → impl-ZZTFBASI.js} +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as s}from"../chunk-XMGVDVM2.js";import{a as o}from"../chunk-
|
|
2
|
+
import{a as s}from"../chunk-XMGVDVM2.js";import{a as o}from"../chunk-UJC7455L.js";import"../chunk-RIVSSQAD.js";import"../chunk-APA5PR4U.js";import"../chunk-BHDQRYCC.js";import"../chunk-EZCJGIOS.js";import{proposeCompletions as r}from"@stricli/core";var t=process.argv.slice(3);process.env.COMP_LINE?.endsWith(" ")&&t.push("");await r(o,t,s(process));try{for(let{completion:p}of await r(o,t,s(process)))process.stdout.write(`${p}
|
|
3
3
|
`)}catch{}
|
package/dist/bin/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as o}from"../chunk-XMGVDVM2.js";import{a as r}from"../chunk-
|
|
2
|
+
import{a as o}from"../chunk-XMGVDVM2.js";import{a as r}from"../chunk-UJC7455L.js";import"../chunk-RIVSSQAD.js";import"../chunk-APA5PR4U.js";import"../chunk-BHDQRYCC.js";import"../chunk-EZCJGIOS.js";import{run as i}from"@stricli/core";await i(r,process.argv.slice(2),o(process));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as r}from"../chunk-
|
|
2
|
+
import{a as r}from"../chunk-UJC7455L.js";import"../chunk-RIVSSQAD.js";import"../chunk-APA5PR4U.js";import"../chunk-BHDQRYCC.js";import"../chunk-EZCJGIOS.js";import{generateHelpTextForAllCommands as d}from"@stricli/core";var s={"tr-build-xdi-sync-endpoint":["consent","build-xdi-sync-endpoint"],"tr-consent-manager-service-json-to-yml":["consent","consent-manager-service-json-to-yml"],"tr-consent-managers-to-business-entities":["consent","consent-managers-to-business-entities"],"tr-cron-mark-identifiers-completed":["request","cron","mark-identifiers-completed"],"tr-cron-pull-identifiers":["request","cron","pull-identifiers"],"tr-derive-data-silos-from-data-flows":["inventory","derive-data-silos-from-data-flows"],"tr-derive-data-silos-from-data-flows-cross-instance":["inventory","derive-data-silos-from-data-flows-cross-instance"],"tr-discover-silos":["inventory","discover-silos"],"tr-generate-api-keys":["admin","generate-api-keys"],"tr-manual-enrichment-pull-identifiers":["request","preflight","pull-identifiers"],"tr-manual-enrichment-push-identifiers":["request","preflight","push-identifiers"],"tr-mark-request-data-silos-completed":["request","system","mark-request-data-silos-completed"],"tr-pull":["inventory","pull"],"tr-pull-consent-metrics":["consent","pull-consent-metrics"],"tr-pull-consent-preferences":["consent","pull-consent-preferences"],"tr-pull-datapoints":["inventory","pull-datapoints"],"tr-pull-pull-unstructured-discovery-files":["inventory","pull-unstructured-discovery-files"],"tr-push":["inventory","push"],"tr-request-approve":["request","approve"],"tr-request-cancel":["request","cancel"],"tr-request-download-files":["request","download-files"],"tr-request-enricher-restart":["request","enricher-restart"],"tr-request-export":["request","export"],"tr-request-mark-silent":["request","mark-silent"],"tr-request-notify-additional-time":["request","notify-additional-time"],"tr-request-reject-unverified-identifiers":["request","reject-unverified-identifiers"],"tr-request-restart":["request","restart"],"tr-request-upload":["request","upload"],"tr-retry-request-data-silos":["request","system","retry-request-data-silos"],"tr-scan-packages":["inventory","scan-packages"],"tr-skip-preflight-jobs":["request","skip-preflight-jobs"],"tr-skip-request-data-silos":["request","system","skip-request-data-silos"],"tr-sync-ot":["migration","sync-ot"],"tr-update-consent-manager":["consent","update-consent-manager"],"tr-upload-consent-preferences":["consent","upload-consent-preferences"],"tr-upload-cookies-from-csv":["consent","upload-cookies-from-csv"],"tr-upload-data-flows-from-csv":["consent","upload-data-flows-from-csv"],"tr-upload-preferences":["consent","upload-preferences"]};function c(t){return d(r).find(n=>n[0]===`${r.config.name} ${t.join(" ")}`)?.[1]}function o(t){console.log("[DEPRECATION NOTICE]");let e=s[t];if(!e){let i=Object.entries(s).map(([a,l])=>`\`${a}\` -> \`${r.config.name} ${l.join(" ")}\``).join(`
|
|
3
3
|
`);console.log(`This command is deprecated as of v7.0.0. Here is a list of new commands, mapped to their legacy command names:
|
|
4
4
|
${i}`);return}console.log(`\`${t}\` is deprecated as of v7.0.0.
|
|
5
5
|
Use \`${r.config.name} ${e.join(" ")}\` instead.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as x}from"./chunk-
|
|
1
|
+
import{c as x}from"./chunk-QPPYCG3K.js";import{n as u,q as D}from"./chunk-PC5LFPCL.js";import{Le as O,Me as U,a as R,b as P,bd as b,pc as L,pe as S,qc as M,tc as N,wc as k}from"./chunk-SNE53JL2.js";import{e as C}from"./chunk-APA5PR4U.js";import{ga as w,ha as _}from"./chunk-HMF46LB7.js";import{a as c}from"./chunk-OERYFLN2.js";import{ConsentBundleType as H}from"@transcend-io/privacy-types";import A from"colors";async function at({auth:e,deploy:i=!1,transcendUrl:o=C,bundleTypes:t=Object.values(H)}){let r=S(o,e),n=await M(r);await R(t,async a=>{c.info(A.magenta(`Update Consent Manager bundle with ID "${n}" and type "${a}" to latest version...`)),await U(r,{id:n,bundleType:a}),c.info(A.green(`Updated Consent Manager bundle with ID "${n}" and type "${a}" to latest version!`))}),i&&await R(t,async a=>{c.info(A.magenta(`Deploying Consent Manager bundle with ID "${n}" and type "${a}"...`)),await O(r,{id:n,bundleType:a}),c.info(A.green(`Deployed Consent Manager bundle with ID "${n}" and type "${a}"!`))})}import G from"colors";var K=["ID","Activity","Encounters","Last Seen At","Has Native Do Not Sell/Share Support","IAB USP API Support","Service Description","Website URL","Categories of Recipients"];async function Ct({auth:e,trackerStatus:i,file:o,classifyService:t=!1,transcendUrl:r=C}){let n=S(r,e);c.info(G.magenta(`Reading "${o}" from disk`));let l=D(o,w).map(({Type:d,Notes:m,Service:f,Purpose:E,Status:g,Owners:I,Teams:T,"Connections Made To":v,...y})=>({value:v,type:d,description:m,trackingPurposes:u(E),status:g||i,owners:I?u(I):void 0,teams:T?u(T):void 0,attributes:Object.entries(y).filter(([h])=>!K.includes(h)).map(([h,B])=>({key:h,values:u(B)}))}));await b(n,l,t)||(c.error(G.red("Encountered error(s) syncing data flows from CSV, see logs above for more info. ")),process.exit(1))}import F from"colors";var j=["ID","Activity","Encounters","Last Seen At","Has Native Do Not Sell/Share Support","IAB USP API Support","Service Description","Website URL","Categories of Recipients"];async function vt({auth:e,trackerStatus:i,file:o,transcendUrl:t=C}){let r=S(t,e);c.info(F.magenta(`Reading "${o}" from disk`));let a=D(o,_).map(({"Is Regex?":s,Notes:d,Service:m,Purpose:f,Status:E,Owners:g,Teams:I,Name:T,...v})=>({...typeof s=="string"?{isRegex:s.toLowerCase()==="true"}:{},name:T,description:d,trackingPurposes:u(f),status:E||i,owners:g?u(g):void 0,teams:I?u(I):void 0,attributes:Object.entries(v).filter(([y])=>!j.includes(y)).map(([y,h])=>({key:y,values:u(h)}))}));await k(r,a)||(c.error(F.red("Encountered error(s) syncing cookies from CSV, see logs above for more info. ")),process.exit(1))}var Y=1e3,Q=60*Y,V=60*Q,X=24*V,z=7*X;async function Lt(e,{bin:i,start:o,end:t=new Date}){let r=await M(e),n=Math.floor(o.getTime()/1e3),a=Math.floor(t.getTime()/1e3);if(n>a)throw new Error('Received "end" date that happened before "start" date');if(i==="1h"&&t.getTime()-o.getTime()>z*2)throw new Error("When using bin=1h, start and end time can be no more than 2 weeks apart");let l=o.toISOString(),s=t.toISOString(),[d,m,f]=await Promise.all([N(e,{dataSource:"PRIVACY_SIGNAL_TIMESERIES",startDate:l,endDate:s,forceRefetch:!0,airgapBundleId:r,binInterval:i,smoothTimeseries:!1}),N(e,{dataSource:"CONSENT_CHANGES_TIMESERIES",startDate:l,endDate:s,forceRefetch:!0,airgapBundleId:r,binInterval:i,smoothTimeseries:!1}),N(e,{dataSource:"CONSENT_SESSIONS_BY_REGIME",startDate:l,endDate:s,forceRefetch:!0,airgapBundleId:r,binInterval:i,smoothTimeseries:!1})]);return{PRIVACY_SIGNAL_TIMESERIES:d,CONSENT_CHANGES_TIMESERIES:m,CONSENT_SESSIONS_BY_REGIME:f}}var $=e=>new URL(`https://${e}`).hostname.split(".").slice(-2).join(".");import W from"colors";import{difference as q}from"lodash-es";var J=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;async function Ht(e,{xdiLocation:i,transcendUrl:o=C,removeIpAddresses:t=!0,domainBlockList:r=["localhost"],xdiAllowedCommands:n="ConsentManager:Sync"}){let a=Array.isArray(e)?e:[{apiKey:e,organizationId:"",organizationName:""}],l=await P(a,async m=>{c.info(W.magenta(`Pulling consent metadata for organization - ${m.organizationName}`));let f=S(o,m.apiKey);return await L(f)},{concurrency:5}),s={};return l.forEach(m=>{let f=m.partition?.partition||m.bundleURL.split("/").reverse()[1];s[f]||(s[f]=[]);let E=q(m.configuration.domains.filter(g=>!t||!J.test(g)).map(g=>$(g)),r);s[f]=[...new Set([...s[f]||[],...E])]}),{html:`
|
|
2
2
|
<!DOCTYPE html>
|
|
3
3
|
<script
|
|
4
4
|
src="${i}"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as i}from"./chunk-
|
|
1
|
+
import{k as i}from"./chunk-PC5LFPCL.js";import o from"inquirer";import m from"inquirer-autocomplete-prompt";async function c({message:e}){let{response:r}=await o.prompt([{name:"response",message:e,type:"confirm"}]);return r}async function l({message:e}){let{response:r}=await o.prompt([{name:"response",message:e,type:"text",validate:t=>t.trim().length>0}]);return r}async function y({defaultValue:e,values:r,message:t}){o.registerPrompt("autocomplete",m);let{response:p}=await o.prompt([{name:"response",message:t,type:"autocomplete",default:e,source:(a,n)=>n?r.filter(s=>typeof s=="string"&&i(n,s)):r}]);return p}export{c as a,l as b,y as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var s="A command line interface for programmatic operations across Transcend.",n="7.0.0-alpha.
|
|
1
|
+
var s="A command line interface for programmatic operations across Transcend.",n="7.0.0-alpha.4";export{s as a,n as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_b as S,a as w,f as $,i as B,j as T,l as R}from"./chunk-
|
|
1
|
+
import{_b as S,a as w,f as $,i as B,j as T,l as R}from"./chunk-SNE53JL2.js";import{a as i}from"./chunk-OERYFLN2.js";import{keyBy as O,uniq as A,chunk as U,sortBy as G}from"lodash-es";import{SubDataPointDataSubCategoryGuessStatus as _}from"@transcend-io/privacy-types";import h from"cli-progress";import{gql as L}from"graphql-request";import f from"colors";async function q(u,{dataSiloIds:e=[],includeGuessedCategories:l,includeAttributes:a,parentCategories:c=[],subCategories:t=[],pageSize:p=1e3}={}){let n=[],m=new Date().getTime(),d=new h.SingleBar({},h.Presets.shades_classic),s={...c.length>0?{category:c}:{},...t.length>0?{subCategoryIds:t}:{},...c.length+t.length>0&&!l?{status:_.Approved}:{},...e.length>0?{dataSilos:e}:{}},{subDataPoints:{totalCount:o}}=await S(u,$,{filterBy:s});i.info(f.magenta("[Step 1/3] Pulling in all subdatapoints")),d.start(o,0);let y=0,D=!1,r,b=0;do try{let{subDataPoints:{nodes:P}}=await S(u,L`
|
|
2
2
|
query TranscendCliSubDataPointCsvExport(
|
|
3
3
|
$filterBy: SubDataPointFiltersInput
|
|
4
4
|
$first: Int!
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as _}from"./chunk-4AH7KIGL.js";import{n as A,q as x}from"./chunk-
|
|
1
|
+
import{c as _}from"./chunk-4AH7KIGL.js";import{n as A,q as x}from"./chunk-PC5LFPCL.js";import{Ae as O,Be as D,_ as T,_b as j,b as R,pe as y,qe as E,ye as L}from"./chunk-SNE53JL2.js";import{e as b}from"./chunk-APA5PR4U.js";import{a as r}from"./chunk-OERYFLN2.js";import{RequestStatus as U}from"@transcend-io/privacy-types";import k from"colors";import{groupBy as G,uniq as Q}from"lodash-es";async function te({file:u,auth:s,sombraAuth:g,requestActions:f=[],concurrency:p=100,transcendUrl:n=b}){let o=y(n,s),e=await E(n,s,g);r.info(k.magenta(`Pulling manual enrichment requests, filtered for actions: ${f.join(",")}`));let d=await L(o,{actions:f,statuses:[U.Enriching]}),i=[];await R(d,async t=>{let c=await D(o,{requestId:t.id});if(c.filter(({status:m})=>m==="ACTION_REQUIRED")){let m=await O(o,e,{requestId:t.id});i.push({...t,requestIdentifiers:m,requestEnrichers:c})}},{concurrency:p});let l=i.map(({attributeValues:t,requestIdentifiers:c,requestEnrichers:I,...m})=>({...m,...Object.entries(G(c,"name")).reduce((w,[P,$])=>Object.assign(w,{[P]:$.map(({value:C})=>C).join(",")}),{}),...Object.entries(G(t,"attributeKey.name")).reduce((w,[P,$])=>Object.assign(w,{[P]:$.map(({name:C})=>C).join(",")}),{})})),a=Q(l.map(t=>Object.keys(t)).flat());return _(u,l,a),r.info(k.green(`Successfully wrote ${i.length} requests to file "${u}"`)),i}import*as q from"io-ts";import{uniq as F}from"lodash-es";import v from"colors";var S="https://app.transcend.io/privacy-requests/incoming-requests/",M=q.record(q.string,q.string);async function N(u,{id:s,...g},f,p){if(!s){let e=`Request ID must be provided to enricher request.${p?` Found error in row: ${p}`:""}`;throw r.error(v.red(e)),new Error(e)}let n=s.toLowerCase(),o=Object.entries(g).reduce((e,[d,i])=>F(A(i)).length===0?e:Object.assign(e,{[d]:F(A(i)).map(a=>({value:d==="email"?a.toLowerCase():a}))}),{});try{return await u.post("v1/enrich-identifiers",{headers:{"x-transcend-request-id":n,"x-transcend-enricher-id":f},json:{enrichedIdentifiers:o}}).json(),r.error(v.green(`Successfully enriched request: ${S}${n}`)),!0}catch(e){if(typeof e.response.body=="string"&&e.response.body.includes("Cannot update a resolved RequestEnricher"))return r.warn(v.magenta(`Skipped enrichment for request: ${S}${n}, request is no longer in the enriching phase.`)),!1;throw r.error(v.red(`Failed to enricher identifiers for request with id: ${S}${n} - ${e.message} - ${e.response.body}`)),e}}import h from"colors";async function ge({file:u,auth:s,sombraAuth:g,enricherId:f,markSilent:p,concurrency:n=100,transcendUrl:o=b}){let e=await E(o,s,g),d=y(o,s);r.info(h.magenta(`Reading "${u}" from disk`));let i=x(u,M);r.info(h.magenta(`Enriching "${i.length}" privacy requests.`));let l=0,a=0,t=0;if(await R(i,async(c,I)=>{try{p&&(await j(d,T,{input:{id:c.id,isSilent:!0}}),r.info(h.magenta(`Mark request as silent mode - ${c.id}`))),await N(e,c,f,I)?l+=1:a+=1}catch{t+=1}},{concurrency:n}),r.info(h.green(`Successfully notified Transcend!
|
|
2
2
|
Success count: ${l}.`)),a>0&&r.info(h.magenta(`Skipped count: ${a}.`)),t>0)throw r.info(h.red(`Error Count: ${t}.`)),new Error(`Failed to enrich: ${t} requests.`);return i.length}export{te as a,M as b,N as c,ge as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{q as G}from"./chunk-
|
|
1
|
+
import{q as G}from"./chunk-PC5LFPCL.js";import{De as N,_b as _,a as x,b as $,pe as q,qe as D,ve as F,wa as E}from"./chunk-SNE53JL2.js";import{e as y}from"./chunk-APA5PR4U.js";import{a as r}from"./chunk-OERYFLN2.js";import*as e from"io-ts";import{decodeCodec as z}from"@transcend-io/type-utils";var W=e.type({identifier:e.string,type:e.string,coreIdentifier:e.string,dataSiloId:e.string,requestId:e.string,nonce:e.string,requestCreatedAt:e.string,daysUntilOverdue:e.number,attributes:e.array(e.type({key:e.string,values:e.array(e.string)}))});async function k(t,{dataSiloId:i,limit:c=100,offset:o=0,requestType:d}){try{let s=await t.get(`v1/data-silo/${i}/pending-requests/${d}`,{searchParams:{offset:o,limit:c}}).json(),{items:n}=z(e.type({items:e.array(W)}),s);return n}catch(s){throw new Error(`Received an error from server: ${s?.response?.body||s?.message}`)}}import R from"colors";import O from"cli-progress";async function oe({dataSiloId:t,auth:i,sombraAuth:c,actions:o,pageLimit:d=100,transcendUrl:s=y,skipRequestCount:n=!1}){let l=await D(s,i,c),u=q(s,i),a=0;n||(a=await F(u,{dataSiloId:t})),r.info(R.magenta(`Pulling ${n?"all":a} outstanding request identifiers for data silo: "${t}" for requests of types "${o.join('", "')}"`));let g=new Date().getTime(),f=new O.SingleBar({},O.Presets.shades_classic),m=new Set,p=[];n||f.start(a,0),await x(o,async S=>{let A=0,P=!0;for(;P;){let h=await k(l,{dataSiloId:t,limit:d,offset:A,requestType:S});p.push(...h.map(v=>(m.add(v.requestId),{...v,action:S}))),P=h.length===d,A+=d,n?r.info(R.magenta(`Pulled ${h.length} outstanding identifiers for ${m.size} requests`)):f.update(m.size)}}),n||f.stop();let T=new Date().getTime()-g;r.info(R.green(`Successfully pulled ${p.length} outstanding identifiers from ${m.size} requests in "${T/1e3}" seconds!`));let b=p.map(({attributes:S,...A})=>({...A,...S.reduce((P,h)=>Object.assign(P,{[h.key]:h.values.join(",")}),{})}));return{identifiers:p,identifiersFormattedForCsv:b}}import*as I from"io-ts";var U=I.type({nonce:I.string,identifier:I.string});async function B(t,{nonce:i,identifier:c}){try{return await t.put("v1/data-silo",{headers:{"x-transcend-nonce":i},json:{profiles:[{profileId:c}]}}),!0}catch(o){if(o.response?.statusCode===409)return!1;throw new Error(`Received an error from server: ${o?.response?.body||o?.message}`)}}import C from"colors";import L from"cli-progress";async function pe({file:t,dataSiloId:i,auth:c,sombraAuth:o,concurrency:d=100,transcendUrl:s=y}){let n=await D(s,c,o);r.info(C.magenta(`Reading "${t}" from disk`));let l=G(t,U);r.info(C.magenta(`Notifying Transcend for data silo "${i}" marking "${l.length}" identifiers as completed.`));let u=new Date().getTime(),a=new L.SingleBar({},L.Presets.shades_classic),g=0,f=0,m=0;a.start(l.length,0),await $(l,async T=>{try{await B(n,T)?g+=1:f+=1}catch(b){r.error(C.red(`Error notifying Transcend for identifier "${T.identifier}" - ${b.message}`)),m+=1}a.update(g+f)},{concurrency:d}),a.stop();let w=new Date().getTime()-u;if(r.info(C.green(`Successfully notified Transcend for ${g} identifiers in "${w/1e3}" seconds!`)),f&&r.info(C.magenta(`There were ${f} identifiers that were not in a state to be updated.They likely have already been resolved.`)),m)throw r.error(C.red(`There were ${m} identifiers that failed to be updated. Please review the logs for more information.`)),new Error("Failed to update all identifiers");return l.length}import j from"colors";import Q from"cli-progress";import{RequestDataSiloStatus as H}from"@transcend-io/privacy-types";async function Se({requestIds:t,dataSiloId:i,auth:c,concurrency:o=100,status:d=H.Resolved,transcendUrl:s=y}){let n=q(s,c),l=new Date().getTime(),u=new Q.SingleBar({},Q.Presets.shades_classic);r.info(j.magenta(`Notifying Transcend for data silo "${i}" marking "${t.length}" requests as completed.`));let a=0;u.start(t.length,0),await $(t,async m=>{let p=await N(n,{requestId:m,dataSiloId:i});try{await _(n,E,{requestDataSiloId:p.id,status:d})}catch(w){if(!w.message.includes("Client error: Request must be active:"))throw w}a+=1,u.update(a)},{concurrency:o}),u.stop();let f=new Date().getTime()-l;return r.info(j.green(`Successfully notified Transcend in "${f/1e3}" seconds!`)),t.length}export{W as a,k as b,oe as c,U as d,B as e,pe as f,Se as g};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{c as u}from"./chunk-
|
|
1
|
+
import{c as u}from"./chunk-VH4PAOVV.js";import{a as E}from"./chunk-OERYFLN2.js";import{readFileSync as b}from"fs";import{findAllWithRegex as F}from"@transcend-io/type-utils";import{CodePackageType as w}from"@transcend-io/privacy-types";var N=/target ('|")(.*?)('|")/,O=/pod ('|")(.*?)('|")(, ('|")~> (.+?)('|")|)/,y={supportedFiles:["Podfile"],ignoreDirs:["Pods"],scanFunction:e=>{let n=b(e,"utf-8"),o=F({value:new RegExp(N,"g"),matches:["quote1","name","quote2"]},n),c=F({value:new RegExp(O,"g"),matches:["quote1","name","quote2","extra","quote3","version","quote4"]},n);return o.map((t,p)=>({name:t.name,type:w.CocoaPods,softwareDevelopmentKits:c.filter(r=>r.matchIndex>t.matchIndex&&(!o[p+1]||r.matchIndex<o[p+1].matchIndex)).map(r=>({name:r.name,version:r.version}))}))}};import{readFileSync as T}from"fs";import{findAllWithRegex as l}from"@transcend-io/type-utils";import{dirname as h}from"path";var K=/implementation( *)('|")(.+?):(.+?):(.+?|)('|")/,M=/apply plugin: *('|")(.+?)(:(.+?)|)('|")/,j=/implementation group:( *)('|")(.+?)('|"),( *)name:( *)('|")(.+?)('|"),( *)version:( *)('|")(.+?)('|")/,L=/applicationId( *)"(.+?)"/,S={supportedFiles:["build.gradle**"],ignoreDirs:["gradle-app.setting","gradle-wrapper.jar","gradle-wrapper.properties"],scanFunction:e=>{let n=T(e,"utf-8"),o=h(e),c=l({value:new RegExp(K,"g"),matches:["space","quote1","name","path","version","quote2"]},n),a=l({value:new RegExp(M,"g"),matches:["quote1","name","group","version","quote2"]},n),t=l({value:new RegExp(j,"g"),matches:["space1","quote1","group","quote2","space2","space3","quote3","name","quote4","space4","space5","quote5","version","quote6"]},n),p=l({value:new RegExp(L,"g"),matches:["space","name"]},n);if(p.length>1)throw new Error(`Expected only one applicationId per file: ${e}`);return[{name:p[0]?.name||o.split("/").pop(),softwareDevelopmentKits:[...c,...t,...a].map(r=>({name:r.name,version:r.version||void 0}))}]}};import{readFileSync as $}from"fs";import{dirname as J}from"path";var x={supportedFiles:["package.json"],ignoreDirs:["node_modules","serverless-build","lambda-build"],scanFunction:e=>{let n=$(e,"utf-8"),o=J(e),c=JSON.parse(n),{name:a,description:t,dependencies:p={},devDependencies:r={},optionalDependencies:i={}}=c;return[{name:a||o.split("/").pop(),description:t,softwareDevelopmentKits:[...Object.entries(p).map(([s,m])=>({name:s,version:typeof m=="string"?m:void 0})),...Object.entries(r).map(([s,m])=>({name:s,version:typeof m=="string"?m:void 0,isDevDependency:!0})),...Object.entries(i).map(([s,m])=>({name:s,version:typeof m=="string"?m:void 0}))]}]}};import{readFileSync as R}from"fs";import{findAllWithRegex as X}from"@transcend-io/type-utils";import{dirname as U,join as W}from"path";import{CodePackageType as Y}from"@transcend-io/privacy-types";var V=/(.+?)(=+)(.+)/,H=/name *= *('|")(.+?)('|")/,Q=/description *= *('|")(.+?)('|")/,P={supportedFiles:["requirements.txt"],ignoreDirs:["build","lib","lib64"],scanFunction:e=>{let n=R(e,"utf-8"),o=U(e),a=u(o).find(s=>s==="setup.py"),t=a?R(W(o,a),"utf-8"):void 0,p=t?(H.exec(t)||[])[2]:void 0,r=t?(Q.exec(t)||[])[2]:void 0,i=X({value:new RegExp(V,"g"),matches:["name","equals","version"]},n);return[{name:p||o.split("/").pop(),description:r||void 0,type:Y.RequirementsTxt,softwareDevelopmentKits:i.map(s=>({name:s.name,version:s.version}))}]}};import{readFileSync as G}from"fs";import{findAllWithRegex as z}from"@transcend-io/type-utils";import{dirname as B}from"path";import{CodePackageType as Z}from"@transcend-io/privacy-types";var ee=/gem *('|")(.+?)('|")(, *('|")(.+?)('|")|)/,ne=/spec\.name *= *('|")(.+?)('|")/,oe=/spec\.description *= *('|")(.+?)('|")/,te=/spec\.summary *= *('|")(.+?)('|")/,k={supportedFiles:["Gemfile"],ignoreDirs:["bin"],scanFunction:e=>{let n=G(e,"utf-8"),o=B(e),a=u(o).find(s=>s===".gemspec"),t=a?G(a,"utf-8"):void 0,p=t?(ne.exec(t)||[])[2]:void 0,r=t?(oe.exec(t)||te.exec(t)||[])[1]:void 0,i=z({value:new RegExp(ee,"g"),matches:["quote1","name","quote2","hasVersion","quote3","version","quote4"]},n);return[{name:p||o.split("/").pop(),description:r||void 0,type:Z.RequirementsTxt,softwareDevelopmentKits:i.map(s=>({name:s.name,version:s.version}))}]}};import{readFileSync as re}from"fs";import{CodePackageType as ie}from"@transcend-io/privacy-types";import se from"js-yaml";import{dirname as ae}from"path";function pe(e){return e.split(`
|
|
2
2
|
`).map(n=>{let o=n.indexOf("#");return o>-1&&!n.substring(0,o).includes('"')&&!n.substring(0,o).includes("'")?n.substring(0,o).trim():n}).filter(n=>n.length>0).join(`
|
|
3
3
|
`)}var v={supportedFiles:["pubspec.yml"],ignoreDirs:["build"],scanFunction:e=>{let n=ae(e),o=re(e,"utf-8"),{name:c,description:a,dev_dependencies:t={},dependencies:p={}}=se.load(pe(o));return[{name:c||n.split("/").pop(),description:a,type:ie.RequirementsTxt,softwareDevelopmentKits:[...Object.entries(p).map(([r,i])=>({name:r,version:typeof i=="string"?i:typeof i=="number"?i.toString():i?.sdk})),...Object.entries(t).map(([r,i])=>({name:r,version:typeof i=="string"?i:typeof i=="number"?i.toString():i?.sdk,isDevDependency:!0}))]}]}};import{readFileSync as ce}from"fs";import{dirname as me}from"path";var I={supportedFiles:["composer.json"],ignoreDirs:["vendor","node_modules","cache","build","dist"],scanFunction:e=>{let n=ce(e,"utf-8"),o=me(e),c=JSON.parse(n),{name:a,description:t,require:p={},"require-dev":r={}}=c;return[{name:a||o.split("/").pop(),description:t,softwareDevelopmentKits:[...Object.entries(p).map(([i,s])=>({name:i,version:typeof s=="string"?s:void 0})),...Object.entries(r).map(([i,s])=>({name:i,version:typeof s=="string"?s:void 0,isDevDependency:!0}))]}]}};import{readFileSync as de}from"fs";import{CodePackageType as ge}from"@transcend-io/privacy-types";import{decodeCodec as fe}from"@transcend-io/type-utils";import*as d from"io-ts";import{dirname as ue}from"path";var le=d.type({pins:d.array(d.type({identity:d.string,kind:d.string,location:d.string,state:d.type({revision:d.string,version:d.string})})),version:d.number}),D={supportedFiles:["Package.resolved"],ignoreDirs:[],scanFunction:e=>{let n=de(e,"utf-8"),o=fe(le,n);return[{name:ue(e).split("/").pop()||"",type:ge.CocoaPods,softwareDevelopmentKits:o.pins.map(c=>({name:c.identity,version:c.state.version}))}]}};import{CodePackageType as f}from"@transcend-io/privacy-types";var gn={cocoaPods:y,gradle:S,javascriptPackageJson:x,pythonRequirementsTxt:P,gemfile:k,pubspec:v,swift:D},_={[f.CocoaPods]:y,[f.Gradle]:S,[f.PackageJson]:x,[f.RequirementsTxt]:P,[f.Gemfile]:k,[f.Pubspec]:v,[f.ComposerJson]:I,[f.Swift]:D};import Ce from"fast-glob";import A from"colors";import{getEntries as Ee}from"@transcend-io/type-utils";async function Sn({scanPath:e,ignoreDirs:n=[],repositoryName:o}){return(await Promise.all(Ee(_).map(async([a,t])=>{let{ignoreDirs:p,supportedFiles:r,scanFunction:i}=t,s=[...n,...p].filter(m=>m.length>0);try{let m=await Ce(`${e}/**/${r.join("|")}`,{ignore:s.map(g=>`${e}/**/${g}`),unique:!0,onlyFiles:!0});E.info(A.magenta(`Scanning: ${m.length} files of type ${a}`));let C=m.map(g=>i(g).map(q=>({...q,relativePath:g.replace(`${e}/`,"")}))).flat();return E.info(A.green(`Found: ${C.length} packages and ${C.map(({softwareDevelopmentKits:g=[]})=>g).flat().length} sdks`)),C.map(g=>({...g,type:a,repositoryName:o}))}catch(m){throw new Error(`Error scanning globs ${r} with error: ${m}`)}}))).flat()}export{gn as a,Sn as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as Ve,Ae as ye,Be as qe,Ca as Qe,Ce as Ye,De as We,Y as de,Z as ke,_ as oe,_b as P,a as je,b,dd as ge,ea as Me,pe as w,q as Fe,qe as W,se as Ge,ue as Ke,wa as Be,we as ze,xa as Ue,y as _e,ye as E}from"./chunk-LYA6JDF3.js";import{e as C}from"./chunk-APA5PR4U.js";import{a as u}from"./chunk-OERYFLN2.js";import{applyEnum as Jt,valuesOf as le}from"@transcend-io/type-utils";import{LanguageKey as Zt}from"@transcend-io/internationalization";import{CompletedRequestStatus as Ht,RequestAction as Xt,IsoCountryCode as er,IsoCountrySubdivisionCode as tr}from"@transcend-io/privacy-types";import*as R from"io-ts";var A="[NONE]",ce="[APPLY VALUE TO ALL ROWS]",Ce="<blank>",Re=["email","coreIdentifier"],ie=(c=>(c.Email="email",c.CoreIdentifier="coreIdentifier",c.RequestType="requestType",c.SubjectType="subjectType",c.Locale="locale",c.Country="country",c.CountrySubDivision="countrySubDivision",c.RequestStatus="requestStatus",c.CreatedAt="createdAt",c.DataSiloIds="dataSiloIds",c))(ie||{}),Je={email:!1,coreIdentifier:!0,requestType:!0,subjectType:!0,requestStatus:!1,createdAt:!1,dataSiloIds:!1,locale:!1,country:!1,countrySubDivision:!1},Ze={requestType:!0,subjectType:!0},He=R.type({columnNames:R.partial(Jt(ie,()=>R.string)),identifierNames:R.record(R.string,R.string),attributeNames:R.record(R.string,R.string),requestTypeToRequestAction:R.record(R.string,le(Xt)),subjectTypeToSubjectName:R.record(R.string,R.string),languageToLocale:R.record(R.string,le(Zt)),regionToCountry:R.record(R.string,le({...er,[A]:A})),regionToCountrySubDivision:R.record(R.string,le({...tr,[A]:A})),statusToRequestStatus:R.record(R.string,le({...Ht,[A]:A}))}),he=R.type({id:R.string,link:R.string,rowIndex:R.number,coreIdentifier:R.string,attemptedAt:R.string}),Xe=R.type({failingRequests:R.array(R.record(R.string,R.any)),successfulRequests:R.array(he),duplicateRequests:R.array(R.type({rowIndex:R.number,coreIdentifier:R.string,attemptedAt:R.string}))});import rr from"inquirer";import et from"fuzzysearch";function Se(n,e){return et(n.toLowerCase(),e.toLowerCase())||et(e.toLowerCase(),n.toLowerCase())}function ne(n,e,s,l){let a=n.filter(o=>Se(e.toLowerCase(),o.toLowerCase()));return[...a,new rr.Separator,...s?[]:[A],...l?[ce]:[],...n.filter(o=>!a.includes(o))]}import tt from"inquirer";import sr from"inquirer-autocomplete-prompt";import{apply as or}from"@transcend-io/type-utils";async function ee(n,e,s){tt.registerPrompt("autocomplete",sr);let l=n.map(o=>o||"<blank>").filter(o=>!s[o]);if(l.length===0)return s;let a=await tt.prompt(l.map(o=>({name:o,message:`Map value of: ${o}`,type:"autocomplete",default:e.find(i=>Se(o,i)),source:(i,r)=>r?e.filter(t=>typeof t=="string"&&Se(r,t)):e})));return{...s,...or(a,o=>typeof o=="string"?o:Object.values(o)[0])}}function Ie(n){return n.split(",").map(e=>e.trim()).filter(e=>e)}import rt from"colors";import*as te from"io-ts";var st=te.type({key:te.string,values:te.array(te.string)});function ot(n){let e=n.map(s=>{let[l,a]=s.trim().split(":");if(!a)throw new Error("Expected attributes in key:value1;value2,key2:value3;value4");let o=a.split(";");return{key:l,values:o}});return u.info(rt.magenta("Attributes to apply to all requests:")),u.info(rt.magenta(JSON.stringify(e,null,2))),e}import ir from"csv-parse/lib/sync";import{readFileSync as nr}from"fs";import*as it from"io-ts";import{decodeCodec as ar}from"@transcend-io/type-utils";function nt(n,e,s={columns:!0}){let l=ir(nr(n,"utf-8"),s);return ar(it.array(e),l).map(i=>Object.entries(i).reduce((r,[t,y])=>Object.assign(r,{[t.replace(/[^a-z_.+\-A-Z -~]/g,"")]:y}),{}))}import{uniq as ur}from"lodash-es";function G(n,e){return ur(n.map(s=>s[e]||"").flat())}import at from"inquirer";import lr from"colors";import{uniq as cr}from"lodash-es";async function ut(n){let e=cr(n.map(a=>Object.keys(a)).flat()),s=n,l=!0;for(;l;){let{filterColumnName:a}=await at.prompt([{name:"filterColumnName",message:`If you need to filter the list of requests to import, choose the column to filter on. Currently ${s.length} rows.`,type:"list",default:e,choices:[A,...e]}]);if(l=A!==a,l){let o=G(s,a),{valuesToKeep:i}=await at.prompt([{name:"valuesToKeep",message:"Keep rows matching this value",type:"checkbox",default:e,choices:o}]);s=s.filter(r=>i.includes(r[a]))}}return u.info(lr.magenta(`Importing ${s.length} requests`)),s}import lt from"colors";import{RequestStatus as J}from"@transcend-io/privacy-types";import ct from"cli-progress";async function Ys({requestActions:n,auth:e,requestIds:s,statuses:l=[J.Compiling,J.RequestMade,J.Delayed,J.Approving,J.Secondary,J.Enriching,J.Waiting,J.SecondaryApproving],createdAtAfter:a,createdAtBefore:o,concurrency:i=100,transcendUrl:r=C}){let t=w(r,e),y=new Date().getTime(),c=new ct.SingleBar({},ct.Presets.shades_classic),g=await E(t,{actions:n,statuses:l,createdAtBefore:o,createdAtAfter:a,isSilent:!1,requestIds:s});u.info(lt.magenta(`Marking "${g.length}" as silent mode.`));let m=0;c.start(g.length,0),await b(g,async f=>{await P(t,oe,{input:{id:f.id,isSilent:!0}}),m+=1,c.update(m)},{concurrency:i}),c.stop();let p=new Date().getTime()-y;return u.info(lt.green(`Successfully marked ${m} requests as silent mode in "${p/1e3}" seconds!`)),g.length}import{getValues as mr,getEntries as pr}from"@transcend-io/type-utils";import fr from"inquirer";import{startCase as dr}from"lodash-es";async function mt(n,e){let s=mr(ie).filter(a=>!e.getValue("columnNames",a)),l=s.length===0?{}:await fr.prompt(s.map(a=>{let o=dr(a.replace("ColumnName","")),i=ne(n,o,Je[a],!!Ze[a]);return{name:a,message:`Choose the column that will be used to map in the field: ${o}`,type:"list",default:i[0],choices:i}}));return await Promise.all(pr(l).map(([a,o])=>e.setValue(o,"columnNames",a))),l}import re from"colors";import{CompletedRequestStatus as gr,RequestAction as yr,IsoCountryCode as qr,IsoCountrySubdivisionCode as Rr}from"@transcend-io/privacy-types";import{LanguageKey as hr}from"@transcend-io/internationalization";async function pt(n,e,{state:s,columnNameMap:l}){let a=f=>s.getValue("columnNames",f)||l[f],{internalSubjects:o}=await P(n,_e);u.info(re.magenta("Determining mapping of columns for request action"));let i=await ee(G(e,a("requestType")),Object.values(yr),s.getValue("requestTypeToRequestAction"));await s.setValue(i,"requestTypeToRequestAction"),u.info(re.magenta("Determining mapping of columns for subject"));let r=await ee(G(e,a("subjectType")),o.map(({type:f})=>f),s.getValue("subjectTypeToSubjectName"));await s.setValue(r,"subjectTypeToSubjectName"),u.info(re.magenta("Determining mapping of columns for locale"));let t=await ee(G(e,a("locale")),Object.values(hr),s.getValue("languageToLocale"));await s.setValue(t,"languageToLocale"),u.info(re.magenta("Determining mapping of columns for request status")),u.info(re.magenta("Determining mapping of columns for request status"));let y=a("requestStatus"),c=y===A?{}:await ee(G(e,y),[...Object.values(gr),A],s.getValue("statusToRequestStatus"));await s.setValue(c,"statusToRequestStatus"),u.info(re.magenta("Determining mapping of columns for country"));let g=a("country"),m=g===A?{}:await ee(G(e,g),[...Object.values(qr),A],s.getValue("regionToCountry"));await s.setValue(m,"regionToCountry"),u.info(re.magenta("Determining mapping of columns for country sub division"));let d=a("countrySubDivision"),p=d===A?{}:await ee(G(e,d),[...Object.values(Rr),A],s.getValue("regionToCountrySubDivision"));await s.setValue(p,"regionToCountrySubDivision")}import{LanguageKey as Sr}from"@transcend-io/internationalization";import{DateFromISOString as br}from"io-ts-types/lib/DateFromISOString";import*as D from"io-ts";import{NORMALIZE_PHONE_NUMBER as Tr,CompletedRequestStatus as Ar,RequestAction as wr,IdentifierType as be,IsoCountryCode as Cr,IsoCountrySubdivisionCode as Ir}from"@transcend-io/privacy-types";import{valuesOf as me}from"@transcend-io/type-utils";var Pr=D.record(D.string,D.array(D.intersection([D.type({value:D.string}),D.partial({name:D.string})]))),wo=D.intersection([D.type({email:D.string,attestedExtraIdentifiers:Pr,coreIdentifier:D.string,requestType:me(wr),subjectType:D.string}),D.partial({country:me(Cr),countrySubDivision:me(Ir),attributes:D.array(st),status:me(Ar),createdAt:br,dataSiloIds:D.array(D.string),locale:me(Sr)})]);function Dr(n,e,s){if(e===be.Email)return n.toLowerCase();if(e===be.Phone){let l=n.replace(Tr,"").replace(/[()]/g,"").replace(/[–]/g,"").replace(/[:]/g,"").replace(/[]/g,"").replace(/[A-Za-z]/g,"");return l?l.startsWith("+")?l:`+${s}${l}`:""}return n}function ft(n,e,{columnNameMap:s,identifierNameMap:l,attributeNameMap:a,requestAttributeKeys:o,defaultPhoneCountryCode:i="1"}){let r=t=>e.getValue("columnNames",t)||s[t];return n.map(t=>{let y={};Object.entries(l).filter(([,d])=>d!==A).forEach(([d,p])=>{let f=Object.values(be).includes(d)?d:be.Custom,h=t[p];if(h){let S=Dr(h,f,i);S&&(y[f]||(y[f]=[]),y[f].push({value:S,name:d}))}});let c=[];Object.entries(a).filter(([,d])=>d!==A).forEach(([d,p])=>{let f=t[p];if(f){let h=o.find(S=>S.name===d)?.type==="MULTI_SELECT";c.push({values:h?Ie(f):f,key:d})}});let g=r("requestType"),m=r("subjectType");return[t,{email:t[r("email")],attestedExtraIdentifiers:y,attributes:c,coreIdentifier:t[r("coreIdentifier")],requestType:g===ce?e.getValue("requestTypeToRequestAction",Ce):e.getValue("requestTypeToRequestAction",t[g]),subjectType:m===ce?e.getValue("subjectTypeToSubjectName",Ce):e.getValue("subjectTypeToSubjectName",t[m]),...r("locale")!==A&&t[r("locale")]?{locale:e.getValue("languageToLocale",t[r("locale")])}:{},...r("country")!==A&&t[r("country")]?{country:e.getValue("regionToCountry",t[r("country")])}:{},...r("countrySubDivision")!==A&&t[r("countrySubDivision")]?{countrySubDivision:e.getValue("regionToCountrySubDivision",t[r("countrySubDivision")])}:{},...r("requestStatus")!==A&&e.getValue("statusToRequestStatus",t[r("requestStatus")])!==A&&t[r("requestStatus")]?{status:e.getValue("statusToRequestStatus",t[r("requestStatus")])}:{},...r("createdAt")!==A&&t[r("createdAt")]?{createdAt:new Date(t[r("createdAt")])}:{},...r("dataSiloIds")!==A&&t[r("dataSiloIds")]?{dataSiloIds:Ie(t[r("dataSiloIds")])}:{}}]})}import dt from"colors";import gt from"cli-progress";import*as q from"io-ts";import{decodeCodec as Er,valuesOf as vr}from"@transcend-io/type-utils";import{TableEncryptionType as Nr}from"@transcend-io/privacy-types";var yt=q.type({defaultMessage:q.string,id:q.string}),xr=q.type({downloadKey:q.string,error:q.union([q.null,q.string]),mimetype:q.string,size:q.string,fileName:q.string,dataPoint:q.type({id:q.string,title:q.union([yt,q.null]),description:q.union([yt,q.null]),name:q.string,slug:q.string,encryption:q.union([vr(Nr),q.null]),dataSilo:q.type({id:q.string,title:q.string,description:q.string,type:q.string,outerType:q.union([q.string,q.null])}),path:q.array(q.string)})}),Lr=q.type({nodes:q.array(xr),totalCount:q.number,_links:q.partial({next:q.union([q.string,q.null]),previous:q.union([q.string,q.null])})});async function qt(n,{sombra:e,concurrency:s=5,limit:l=100}){u.info(dt.magenta(`Pulling file metadata for ${n.length} requests`));let a=new Date().getTime(),o=new gt.SingleBar({},gt.Presets.shades_classic),i=0;o.start(n.length,0);let r=await b(n,async c=>{let g=[],m=!0,d=0;for(;m;){let p;try{let f=await e.get(`v1/data-subject-request/${c.id}/download-keys`,{searchParams:{limit:l,offset:d}}).json();p=Er(Lr,f),g.push(...p.nodes),d+=l,m=!!p._links.next&&p.nodes.length===l}catch(f){throw new Error(`Received an error from server: ${f?.response?.body||f?.message}`)}}return i+=1,o.update(i),[c,g]},{concurrency:s});o.stop();let y=new Date().getTime()-a;return u.info(dt.green(`Successfully downloaded file metadata ${n.length} requests in "${y/1e3}" seconds!`)),r}import $r from"colors";async function Rt(n,{requestId:e,sombra:s,onFileDownloaded:l,concurrency:a=20}){await b(n,async o=>{try{await s.get("v1/files",{searchParams:{downloadKey:o.downloadKey}}).buffer().then(i=>l(o,i))}catch(i){if(i?.response?.body?.includes("fileMetadata#verify")){u.error($r.red(`Failed to pull file for: ${o.fileName} (request:${e}) - JWT expired. This likely means that the file is no longer available. Try restarting the request from scratch in Transcend Admin Dashboard. Skipping the download of this file.`));return}throw new Error(`Received an error from server: ${i?.response?.body||i?.message}`)}},{concurrency:a})}import{existsSync as Pe,mkdirSync as De,writeFileSync as Or}from"fs";import{dirname as jr,join as ht}from"path";import St from"colors";import{RequestAction as Fr,RequestStatus as Ee}from"@transcend-io/privacy-types";import bt from"cli-progress";async function Yo({auth:n,folderPath:e,requestIds:s,createdAtBefore:l,sombraAuth:a,createdAtAfter:o,statuses:i=[Ee.Approving,Ee.Downloadable],concurrency:r=5,transcendUrl:t=C,approveAfterDownload:y=!1}){let c=w(t,n),g=await W(t,n,a);Pe(e)||De(e);let m=await E(c,{actions:[Fr.Access],createdAtBefore:l,createdAtAfter:o,statuses:i,requestIds:s}),d=await qt(m,{sombra:g,concurrency:r}),p=new Date().getTime(),f=new bt.SingleBar({},bt.Presets.shades_classic),h=0,S=0;f.start(m.length,0),await b(d,async([v,x])=>{let K=ht(e,v.id);Pe(K)||De(K),await Rt(x,{sombra:g,requestId:v.id,onFileDownloaded:($,_)=>{let z=ht(K,$.fileName),j=jr(z);Pe(j)||De(j,{recursive:!0}),Or(z,_)}}),y&&v.status===Ee.Approving&&(await P(c,de,{input:{requestId:v.id}}),S+=1),h+=1,f.update(h)},{concurrency:r}),f.stop();let T=new Date().getTime()-p;return u.info(St.green(`Successfully downloaded ${h} requests in "${T/1e3}" seconds!`)),S>0&&u.info(St.green(`Approved ${S} requests in Transcend.`)),m.length}import*as I from"io-ts";import{uniq as _r}from"lodash-es";import{valuesOf as Te,decodeCodec as kr}from"@transcend-io/type-utils";import{IsoCountryCode as Vr,IsoCountrySubdivisionCode as Mr,RequestAction as Br,RequestStatus as Ur}from"@transcend-io/privacy-types";var ve=I.type({id:I.string,link:I.string,status:Te(Ur),type:Te(Br),subjectType:I.string,email:I.union([I.null,I.string]),coreIdentifier:I.string,isSilent:I.boolean,isTest:I.boolean,country:I.union([I.null,Te(Vr)]),countrySubDivision:I.union([I.null,Te(Mr)]),attributeValues:I.array(I.type({attributeKey:I.type({name:I.string}),name:I.string}))});async function Tt(n,e,{details:s="",isTest:l=!1,emailIsVerified:a=!0,skipSendingReceipt:o=!1,isSilent:i=!0,additionalAttributes:r=[]}={}){let t=[...r];(e.attributes||[]).forEach(g=>{let m=t.find(d=>d.key===g.key);m?(m.values.push(...g.values),m.values=_r(m.values)):t.push(g)});let y;try{y=await n.post("v1/data-subject-request",{json:{type:e.requestType,subject:{coreIdentifier:e.coreIdentifier,email:e.email,emailIsVerified:a,attestedExtraIdentifiers:e.attestedExtraIdentifiers},subjectType:e.subjectType,isSilent:i,isTest:l,skipSendingReceipt:o,...e.locale?{locale:e.locale}:{},details:s,attributes:t,...e.country||e.countrySubDivision?{region:{...e.country?{country:e.country}:e.countrySubDivision?{country:e.countrySubDivision.split("-")[0]}:{},...e.countrySubDivision?{countrySubDivision:e.countrySubDivision}:{}}}:{},...e.createdAt?{createdAt:e.createdAt}:{},...e.dataSiloIds?{dataSiloIds:e.dataSiloIds}:{},...e.status?{completedRequestStatus:e.status}:{}}}).json()}catch(g){throw new Error(`Received an error from server: ${g?.response?.body||g?.message}`)}let{request:c}=kr(I.type({request:ve}),y);return c}import Ne from"colors";import{RequestStatus as Qr}from"@transcend-io/privacy-types";import At from"cli-progress";async function li({requestActions:n,requestOrigins:e,auth:s,silentModeBefore:l,createdAtAfter:a,createdAtBefore:o,concurrency:i=50,transcendUrl:r=C}){let t=w(r,s),y=new Date().getTime(),c=new At.SingleBar({},At.Presets.shades_classic),g=await E(t,{actions:n,statuses:[Qr.Approving],createdAtAfter:a,origins:e,createdAtBefore:o});u.info(Ne.magenta(`Approving "${g.length}" requests.`));let m=0,d=0;c.start(g.length,0),await b(g,async h=>{l&&new Date(l)>new Date(h.createdAt)&&await P(t,oe,{input:{id:h.id,isSilent:!0}});try{await P(t,de,{input:{requestId:h.id}})}catch(S){S.message.includes("Request must be in an approving state,")&&(d+=1)}m+=1,c.update(m)},{concurrency:i}),c.stop();let f=new Date().getTime()-y;return d>0&&u.info(Ne.yellow(`${d} requests were skipped.`)),u.info(Ne.green(`Successfully approved ${m} requests in "${f/1e3}" seconds!`)),g.length}import wt from"colors";import{RequestAction as Gr}from"@transcend-io/privacy-types";import Ct from"cli-progress";async function Ri({requestActions:n=Object.values(Gr),auth:e,requestIds:s,createdAtBefore:l,days:a=45,daysLeft:o=10,createdAtAfter:i,emailTemplate:r="Additional Time Needed",concurrency:t=100,transcendUrl:y=C}){let c=w(y,e),g=new Date().getTime(),m=new Ct.SingleBar({},Ct.Presets.shades_classic),p=(await ge(c,r)).find(T=>T.title===r);if(!p)throw new Error(`Failed to find a template with title: "${r}"`);let f=await E(c,{actions:n,createdAtBefore:l,createdAtAfter:i,isSilent:!1,isClosed:!1,requestIds:s});f=f.filter(T=>typeof T.daysRemaining=="number"&&T.daysRemaining<o),u.info(wt.magenta(`Notifying "${f.length}" that more time is needed.`));let h=0;m.start(f.length,0),await b(f,async T=>{await P(c,Ve,{input:{requestId:T.id,template:p.template.defaultMessage,subject:p.subject.defaultMessage,additionalTime:a}}),h+=1,m.update(h)},{concurrency:t}),m.stop();let N=new Date().getTime()-g;return u.info(wt.green(`Successfully marked ${h} requests as silent mode in "${N/1e3}" seconds!`)),f.length}import Kr from"inquirer";async function It(n,e,s){let{initializer:l}=await P(n,Fe),a=l.identifiers.filter(({name:i})=>!s.getValue("identifierNames",i)&&!Re.includes(i)),o=a.length===0?{}:await Kr.prompt(a.map(({name:i})=>{let r=ne(e,i,!1);return{name:i,message:`Choose the column that will be used to map in the identifier: ${i}`,type:"list",default:r[0],choices:r}}));return await Promise.all(Object.entries(o).map(([i,r])=>s.setValue(r,"identifierNames",i))),{...s.getValue("identifierNames"),...o}}import Pt from"colors";import{RequestStatus as Z}from"@transcend-io/privacy-types";import Dt from"cli-progress";async function ji({requestActions:n,cancellationTitle:e,auth:s,requestIds:l,silentModeBefore:a,createdAtBefore:o,createdAtAfter:i,statuses:r=[Z.Compiling,Z.RequestMade,Z.Delayed,Z.Approving,Z.Secondary,Z.Enriching,Z.Waiting,Z.SecondaryApproving],concurrency:t=50,transcendUrl:y=C}){let c=w(y,s),g=new Date().getTime(),m=new Dt.SingleBar({},Dt.Presets.shades_classic),d;if(e){let T=(await ge(c,e)).find(v=>v.title===e);if(!T)throw new Error(`Failed to find a template with title: "${e}"`);d=T}let p=await E(c,{actions:n,createdAtBefore:o,createdAtAfter:i,statuses:r,requestIds:l});u.info(Pt.magenta(`Canceling "${p.length}" requests${d?` Using template: ${d.title}`:""}.`));let f=0;m.start(p.length,0),await b(p,async N=>{a&&new Date(a)>new Date(N.createdAt)&&await P(c,oe,{input:{id:N.id,isSilent:!0}}),await P(c,ke,{input:{requestId:N.id,...d?{subject:`Re: ${d.subject.defaultMessage}`,template:d.template.defaultMessage}:{}}}),f+=1,m.update(f)},{concurrency:t}),m.stop();let S=new Date().getTime()-g;return u.info(Pt.green(`Successfully canceled ${f} requests in "${S/1e3}" seconds!`)),p.length}import zr from"inquirer";async function Et(n,e,s,l){let a=l.filter(({name:i})=>!s.getValue("attributeNames",i)),o=a.length===0?{}:await zr.prompt(a.map(({name:i})=>{let r=ne(e,i,!1);return{name:i,message:`Choose the column that will be used to map in the attribute: ${i}`,type:"list",default:r[0],choices:r}}));return await Promise.all(Object.entries(o).map(([i,r])=>s.setValue(r,"attributeNames",i))),{...s.getValue("attributeNames"),...o}}var vt=/{\\"message\\":\\"(.+?)\\",/;function Ae(n){return vt.test(n)?vt.exec(n)[1]:null}import F from"colors";import*as pe from"io-ts";import{uniq as Yr}from"lodash-es";import Nt from"cli-progress";import{join as Wr}from"path";import{PersistedState as xt}from"@transcend-io/persisted-state";async function ln({cacheFilepath:n,requestReceiptFolder:e,file:s,auth:l,sombraAuth:a,concurrency:o=100,defaultPhoneCountryCode:i="1",transcendUrl:r=C,attributes:t=[],emailIsVerified:y=!0,skipFilterStep:c=!1,skipSendingReceipt:g=!0,isTest:m=!1,isSilent:d=!0,debug:p=!1,dryRun:f=!1}){let h=new Date().getTime(),S=new Nt.SingleBar({},Nt.Presets.shades_classic),N=ot(t),T=new xt(n,He,{columnNames:{},requestTypeToRequestAction:{},subjectTypeToSubjectName:{},languageToLocale:{},statusToRequestStatus:{},identifierNames:{},attributeNames:{},regionToCountrySubDivision:{},regionToCountry:{}}),v=Wr(e,`tr-request-upload-${new Date().toISOString()}-${s.split("/").pop()}`.replace(".csv",".json")),x=new xt(v,Xe,{successfulRequests:[],duplicateRequests:[],failingRequests:[]}),K=await W(r,l,a),$=nt(s,pe.record(pe.string,pe.string)),_=Yr($.map(U=>Object.keys(U)).flat());if($.length===0)throw new Error("No Requests found in list! Ensure the first row of the CSV is a header and the rest are requests.");if(p){let U=$[0];u.info(F.magenta(`First request: ${JSON.stringify(U,null,2)}`))}let z=c?$:await ut($),j=w(r,l),L=await ze(j),B=await mt(_,T),Y=await It(j,_,T),k=await Et(j,_,T,L);await pt(j,z,{state:T,columnNameMap:B});let O=ft(z,T,{defaultPhoneCountryCode:i,columnNameMap:B,identifierNameMap:Y,attributeNameMap:k,requestAttributeKeys:L});p||S.start(O.length,0);let H=0;await b(O,async([U,V],Q)=>{let Oe=p?`email:${V.email} | coreIdentifier:${V.coreIdentifier}`:`row:${Q.toString()}`;if(p&&u.info(F.magenta(`[${Q+1}/${O.length}] Importing: ${JSON.stringify(V,null,2)}`)),f){u.info(F.magenta("Bailing out on dry run because dryRun is set"));return}try{let X=await Tt(K,V,{details:`Uploaded by Transcend Cli: "tr-request-upload" : ${JSON.stringify(U,null,2)}`,isTest:m,emailIsVerified:y,skipSendingReceipt:g,isSilent:d,additionalAttributes:N});p&&(u.info(F.green(`[${Q+1}/${O.length}] Successfully submitted the test data subject request: "${Oe}"`)),u.info(F.green(`[${Q+1}/${O.length}] View it at: "${X.link}"`)));let se=x.getValue("successfulRequests");se.push({id:X.id,link:X.link,rowIndex:Q,coreIdentifier:X.coreIdentifier,attemptedAt:new Date().toISOString()}),await x.setValue(se,"successfulRequests")}catch(X){let se=`${X.message} - ${JSON.stringify(X.response?.body,null,2)}`,we=Ae(se);if(we==="Client error: You have already made this request."){p&&u.info(F.yellow(`[${Q+1}/${O.length}] Skipping request as it is a duplicate`));let ue=x.getValue("duplicateRequests");ue.push({coreIdentifier:V.coreIdentifier,rowIndex:Q,attemptedAt:new Date().toISOString()}),await x.setValue(ue,"duplicateRequests")}else{let ue=x.getValue("failingRequests");ue.push({...V,rowIndex:Q,error:we||se,attemptedAt:new Date().toISOString()}),await x.setValue(ue,"failingRequests"),p&&(u.error(F.red(we||se)),u.error(F.red(`[${Q+1}/${O.length}] Failed to submit request for: "${Oe}"`)))}}H+=1,p||S.update(H)},{concurrency:o}),S.stop();let ae=new Date().getTime()-h;u.info(F.green(`Completed upload in "${ae/1e3}" seconds.`)),x.getValue("duplicateRequests").length>0&&u.info(F.yellow(`Encountered "${x.getValue("duplicateRequests").length}" duplicate requests. See "${v}" to review the core identifiers for these requests.`)),x.getValue("failingRequests").length>0&&(u.error(F.red(`Encountered "${x.getValue("failingRequests").length}" errors. See "${v}" to review the error messages and inputs.`)),process.exit(1))}import*as Lt from"io-ts";import{groupBy as Jr}from"lodash-es";import{apply as Zr,decodeCodec as Hr}from"@transcend-io/type-utils";import{IdentifierType as xe}from"@transcend-io/privacy-types";async function $t(n,e,{sendEmailReceipt:s=!1,skipWaitingPeriod:l=!1,emailIsVerified:a=!0,requestIdentifiers:o=[]}={}){let i=await n.post("v1/data-subject-request",{json:{type:e.type,subject:{coreIdentifier:e.coreIdentifier,email:e.email,emailIsVerified:a,...o.length>0?{attestedExtraIdentifiers:Zr(Jr(o.filter(t=>!(t.name==="email"&&t.value===e.email)&&!Re.includes(t.name)).map(t=>({...t,type:Object.values(xe).includes(t.name)?t.name:xe.Custom})),"type"),(t,y)=>t.map(({name:c,value:g})=>({...y===xe.Custom?{name:c}:{},value:g})))}:{}},requestId:e.id,subjectType:e.subjectType,isSilent:e.isSilent,isTest:e.isTest,locale:e.locale,skipWaitingPeriod:l,createdAt:e.createdAt,details:`Restarted by Transcend cli: "tr-request-restart" - ${e.details}`,skipSendingReceipt:!s}}).json(),{request:r}=Hr(Lt.type({request:ve}),i);return r}import{PersistedState as Xr}from"@transcend-io/persisted-state";import Ot from"cli-progress";import Le from"colors";import*as M from"io-ts";import{difference as es}from"lodash-es";import{join as ts}from"path";var rs=M.intersection([he,M.type({error:M.string})]),ss=M.type({restartedRequests:M.array(he),failingRequests:M.array(rs)});async function En({requestReceiptFolder:n,auth:e,sombraAuth:s,requestActions:l,requestStatuses:a,createdAtBefore:o,createdAtAfter:i,transcendUrl:r=C,requestIds:t=[],createdAt:y=new Date,silentModeBefore:c,sendEmailReceipt:g=!1,emailIsVerified:m=!0,copyIdentifiers:d=!1,skipWaitingPeriod:p=!1,concurrency:f=20}){let h=new Date().getTime(),S=new Ot.SingleBar({},Ot.Presets.shades_classic),N=ts(n,`tr-request-restart-${new Date().toISOString()}`),T=new Xr(N,ss,{restartedRequests:[],failingRequests:[]}),v=await W(r,e,s),x=w(r,e),$=(await E(x,{actions:l,statuses:a,createdAtBefore:o,createdAtAfter:i})).filter(L=>new Date(L.createdAt)<y);if(u.info(`Found ${$.length} requests to process`),d&&u.info("copyIdentifiers detected - All Identifiers will be copied."),g&&u.info("sendEmailReceipt detected - Email receipts will be sent."),p&&u.info("skipWaitingPeriod detected - Waiting period will be skipped."),t.length>0&&t.length!==$.length){let L=es(t,$.map(({id:B})=>B));L.length>0&&(u.error(Le.red(`Failed to find the following requests by ID: ${L.join(",")}.`)),process.exit(1))}let _=0;S.start($.length,0),await b($,async(L,B)=>{try{let Y=d?await ye(x,v,{requestId:L.id}):[],k=await $t(v,{...L,isSilent:c&&new Date(L.createdAt)<c?!0:L.isSilent},{requestIdentifiers:Y,skipWaitingPeriod:p,sendEmailReceipt:g,emailIsVerified:m}),O=T.getValue("restartedRequests");O.push({id:k.id,link:k.link,rowIndex:B,coreIdentifier:k.coreIdentifier,attemptedAt:new Date().toISOString()}),await T.setValue(O,"restartedRequests")}catch(Y){let k=`${Y.message} - ${JSON.stringify(Y.response?.body,null,2)}`,O=Ae(k),H=T.getValue("failingRequests");H.push({id:L.id,link:L.link,rowIndex:B,coreIdentifier:L.coreIdentifier,attemptedAt:new Date().toISOString(),error:O||k}),await T.setValue(H,"failingRequests")}_+=1,S.update(_)},{concurrency:f}),S.stop();let j=new Date().getTime()-h;u.info(Le.green(`Completed restarting of requests in "${j/1e3}" seconds.`)),T.getValue("failingRequests").length>0&&(u.error(Le.red(`Encountered "${T.getValue("failingRequests").length}" errors. See "${N}" to review the error messages and inputs.`)),process.exit(1))}import jt from"colors";import Ft from"cli-progress";import{RequestEnricherStatus as _t,RequestStatus as os}from"@transcend-io/privacy-types";async function _n({enricherIds:n,auth:e,concurrency:s=100,transcendUrl:l=C}){let a=w(l,e),o=new Date().getTime(),i=await E(a,{statuses:[os.Enriching]});u.info(jt.magenta(`Processing enricher: "${n.join(",")}" fetched "${i.length}" in enriching status.`));let r=new Ft.SingleBar({},Ft.Presets.shades_classic),t=0;r.start(i.length,0);let y=0;await b(i,async m=>{let p=(await qe(a,{requestId:m.id})).filter(f=>n.includes(f.enricher.id)&&![_t.Resolved,_t.Skipped].includes(f.status));p.length>0&&await je(p,async f=>{try{await P(a,Me,{requestEnricherId:f.id}),y+=1}catch(h){if(!h.message.includes("Client error: Cannot skip Request enricher because it has already completed"))throw h}}),t+=1,r.update(t)},{concurrency:s}),r.stop();let g=new Date().getTime()-o;return u.info(jt.green(`Successfully skipped "${y}" for "${i.length}" requests in "${g/1e3}" seconds!`)),i.length}import{RequestEnricherStatus as is,RequestStatus as ns}from"@transcend-io/privacy-types";import kt from"cli-progress";import $e from"colors";import{difference as as}from"lodash-es";async function Wn({auth:n,requestActions:e=[],createdAtBefore:s,createdAtAfter:l,transcendUrl:a=C,requestEnricherStatuses:o=Object.values(is),requestIds:i=[],enricherId:r,concurrency:t=20}){let y=new Date().getTime(),c=new kt.SingleBar({},kt.Presets.shades_classic),g=w(a,n);u.info($e.magenta("Fetching requests to restart..."));let m=await E(g,{actions:e,statuses:[ns.Enriching],createdAtBefore:s,createdAtAfter:l,requestIds:i}),d=0;if(i.length>0&&i.length!==m.length){let S=as(i,m.map(({id:N})=>N));S.length>0&&(u.error($e.red(`Failed to find the following requests by ID: ${S.join(",")}.`)),process.exit(1))}let p=0;c.start(m.length,0),await b(m,async S=>{let T=(await qe(g,{requestId:S.id})).filter(v=>v.enricher.id===r&&o.includes(v.status));await b(T,async v=>{await Ge(g,v.id),d+=1}),p+=1,c.update(p)},{concurrency:t}),c.stop();let h=new Date().getTime()-y;u.info($e.green(`Completed restarting of ${m.length} requests and ${d} enrichers in "${h/1e3}" seconds.`))}import Vt from"colors";import{RequestStatus as Mt}from"@transcend-io/privacy-types";import Bt from"cli-progress";async function ia({requestActions:n,dataSiloId:e,auth:s,concurrency:l=20,transcendUrl:a=C}){let o=w(a,s),i=new Date().getTime(),r=new Bt.SingleBar({},Bt.Presets.shades_classic),t=await E(o,{actions:n,statuses:[Mt.Compiling,Mt.Approving]});u.info(Vt.magenta(`Retrying requests for Data Silo: "${e}", restarting "${t.length}" requests.`));let y=0,c=0;r.start(t.length,0),await b(t,async d=>{try{let p=await We(o,{requestId:d.id,dataSiloId:e});await P(o,Ue,{requestDataSiloId:p.id})}catch(p){if(!p.message.includes("Failed to find RequestDataSilo"))throw p;c+=1}y+=1,r.update(y)},{concurrency:l}),r.stop();let m=new Date().getTime()-i;return u.info(Vt.green(`Successfully notified Transcend in "${m/1e3}" seconds for ${y} requests, ${c} requests were skipped because data silo was not attached to the request!`)),t.length}import Ut from"colors";import{groupBy as Qt}from"lodash-es";async function ga({auth:n,sombraAuth:e,actions:s=[],statuses:l=[],identifierSearch:a,pageLimit:o=100,transcendUrl:i=C,createdAtBefore:r,createdAtAfter:t,isTest:y}){let c=w(i,n),g=await W(i,n,e),m="";r&&(m+=` before ${r.toISOString()}`),t&&(m+=`${m?", and":""} after ${t.toISOString()}`),u.info(Ut.magenta(`${s.length>0?`Pulling requests of type "${s.join('" , "')}"`:"Pulling all requests"}${m}`));let d=await E(c,{actions:s,text:a,statuses:l,createdAtBefore:r,createdAtAfter:t,isTest:y}),p=await b(d,async h=>{let S=await ye(c,g,{requestId:h.id});return{...h,requestIdentifiers:S}},{concurrency:o});u.info(Ut.magenta(`Pulled ${p.length} requests`));let f=p.map(({attributeValues:h,requestIdentifiers:S,id:N,email:T,type:v,status:x,subjectType:K,details:$,createdAt:_,country:z,locale:j,origin:L,countrySubDivision:B,isSilent:Y,isTest:k,coreIdentifier:O,...H})=>({"Request ID":N,"Created At":_,Email:T,"Core Identifier":O,"Request Type":v,"Data Subject Type":K,Status:x,Country:z,"Country Sub Division":B,Details:$,Origin:L,"Silent Mode":Y,"Is Test Request":k,Language:j,...H,...Object.entries(Qt(h,"attributeKey.name")).reduce((fe,[ae,U])=>Object.assign(fe,{[ae]:U.map(({name:V})=>V).join(",")}),{}),...Object.entries(Qt(S,"name")).reduce((fe,[ae,U])=>Object.assign(fe,{[ae]:U.map(({value:V})=>V).join(",")}),{})}));return{requestsWithRequestIdentifiers:p,requestsFormattedForCsv:f}}import Gt from"colors";import Kt from"cli-progress";import{RequestStatus as zt}from"@transcend-io/privacy-types";async function wa({dataSiloId:n,auth:e,concurrency:s=100,status:l="SKIPPED",transcendUrl:a=C,requestStatuses:o=[zt.Compiling,zt.Secondary]}){let i=w(a,e),r=new Date().getTime(),t=await Ye(i,{dataSiloId:n,requestStatuses:o});u.info(Gt.magenta(`Processing data silo: "${n}" marking "${t.length}" requests as skipped.`));let y=new Kt.SingleBar({},Kt.Presets.shades_classic),c=0;y.start(t.length,0),await b(t,async d=>{try{await P(i,Be,{requestDataSiloId:d.id,status:l})}catch(p){if(!p.message.includes("Client error: Request must be active:"))throw p}c+=1,y.update(c)},{concurrency:s}),y.stop();let m=new Date().getTime()-r;return u.info(Gt.green(`Successfully skipped "${t.length}" requests in "${m/1e3}" seconds!`)),t.length}import Yt from"colors";import{RequestStatus as us}from"@transcend-io/privacy-types";import Wt from"cli-progress";async function $a({requestActions:n,identifierNames:e,auth:s,concurrency:l=20,transcendUrl:a=C}){let o=w(a,s),i=new Date().getTime(),r=new Wt.SingleBar({},Wt.Presets.shades_classic),t=await E(o,{actions:n,statuses:[us.Enriching]});u.info(Yt.magenta("Fetched requests in preflight/enriching state."));let y=0,c=0;r.start(t.length,0),await b(t,async d=>{let f=(await Ke(o,{requestId:d.id})).filter(({isVerifiedAtLeastOnce:h,name:S})=>h===!1&&e.includes(S)).map(({id:h})=>h);f.length>0&&(await P(o,Qe,{input:{requestId:d.id,requestIdentifierIds:f}}),c+=f.length),y+=1,r.update(y)},{concurrency:l}),r.stop();let m=new Date().getTime()-i;return u.info(Yt.green(`Successfully cleared out unverified identifiers "${m/1e3}" seconds for ${y} requests, ${c} identifiers were cleared out!`)),t.length}export{A as a,ce as b,Ce as c,Re as d,ie as e,Je as f,Ze as g,He as h,he as i,Xe as j,Se as k,ne as l,ee as m,Ie as n,st as o,ot as p,nt as q,G as r,ut as s,Ys as t,mt as u,pt as v,Pr as w,wo as x,Dr as y,ft as z,yt as A,xr as B,Lr as C,qt as D,Rt as E,Yo as F,ve as G,Tt as H,li as I,Ri as J,It as K,ji as L,Et as M,Ae as N,ln as O,$t as P,En as Q,_n as R,Wn as S,ia as T,ga as U,wa as V,$a as W};
|
|
1
|
+
import{$ as Ve,Ae as ye,Be as qe,Ca as Qe,Ce as Ye,De as We,Y as de,Z as ke,_ as oe,_b as P,a as je,b,dd as ge,ea as Me,pe as w,q as Fe,qe as W,se as Ge,ue as Ke,wa as Be,we as ze,xa as Ue,y as _e,ye as E}from"./chunk-SNE53JL2.js";import{e as C}from"./chunk-APA5PR4U.js";import{a as u}from"./chunk-OERYFLN2.js";import{applyEnum as Jt,valuesOf as le}from"@transcend-io/type-utils";import{LanguageKey as Zt}from"@transcend-io/internationalization";import{CompletedRequestStatus as Ht,RequestAction as Xt,IsoCountryCode as er,IsoCountrySubdivisionCode as tr}from"@transcend-io/privacy-types";import*as R from"io-ts";var A="[NONE]",ce="[APPLY VALUE TO ALL ROWS]",Ce="<blank>",Re=["email","coreIdentifier"],ie=(c=>(c.Email="email",c.CoreIdentifier="coreIdentifier",c.RequestType="requestType",c.SubjectType="subjectType",c.Locale="locale",c.Country="country",c.CountrySubDivision="countrySubDivision",c.RequestStatus="requestStatus",c.CreatedAt="createdAt",c.DataSiloIds="dataSiloIds",c))(ie||{}),Je={email:!1,coreIdentifier:!0,requestType:!0,subjectType:!0,requestStatus:!1,createdAt:!1,dataSiloIds:!1,locale:!1,country:!1,countrySubDivision:!1},Ze={requestType:!0,subjectType:!0},He=R.type({columnNames:R.partial(Jt(ie,()=>R.string)),identifierNames:R.record(R.string,R.string),attributeNames:R.record(R.string,R.string),requestTypeToRequestAction:R.record(R.string,le(Xt)),subjectTypeToSubjectName:R.record(R.string,R.string),languageToLocale:R.record(R.string,le(Zt)),regionToCountry:R.record(R.string,le({...er,[A]:A})),regionToCountrySubDivision:R.record(R.string,le({...tr,[A]:A})),statusToRequestStatus:R.record(R.string,le({...Ht,[A]:A}))}),he=R.type({id:R.string,link:R.string,rowIndex:R.number,coreIdentifier:R.string,attemptedAt:R.string}),Xe=R.type({failingRequests:R.array(R.record(R.string,R.any)),successfulRequests:R.array(he),duplicateRequests:R.array(R.type({rowIndex:R.number,coreIdentifier:R.string,attemptedAt:R.string}))});import rr from"inquirer";import et from"fuzzysearch";function Se(n,e){return et(n.toLowerCase(),e.toLowerCase())||et(e.toLowerCase(),n.toLowerCase())}function ne(n,e,s,l){let a=n.filter(o=>Se(e.toLowerCase(),o.toLowerCase()));return[...a,new rr.Separator,...s?[]:[A],...l?[ce]:[],...n.filter(o=>!a.includes(o))]}import tt from"inquirer";import sr from"inquirer-autocomplete-prompt";import{apply as or}from"@transcend-io/type-utils";async function ee(n,e,s){tt.registerPrompt("autocomplete",sr);let l=n.map(o=>o||"<blank>").filter(o=>!s[o]);if(l.length===0)return s;let a=await tt.prompt(l.map(o=>({name:o,message:`Map value of: ${o}`,type:"autocomplete",default:e.find(i=>Se(o,i)),source:(i,r)=>r?e.filter(t=>typeof t=="string"&&Se(r,t)):e})));return{...s,...or(a,o=>typeof o=="string"?o:Object.values(o)[0])}}function Ie(n){return n.split(",").map(e=>e.trim()).filter(e=>e)}import rt from"colors";import*as te from"io-ts";var st=te.type({key:te.string,values:te.array(te.string)});function ot(n){let e=n.map(s=>{let[l,a]=s.trim().split(":");if(!a)throw new Error("Expected attributes in key:value1;value2,key2:value3;value4");let o=a.split(";");return{key:l,values:o}});return u.info(rt.magenta("Attributes to apply to all requests:")),u.info(rt.magenta(JSON.stringify(e,null,2))),e}import ir from"csv-parse/lib/sync";import{readFileSync as nr}from"fs";import*as it from"io-ts";import{decodeCodec as ar}from"@transcend-io/type-utils";function nt(n,e,s={columns:!0}){let l=ir(nr(n,"utf-8"),s);return ar(it.array(e),l).map(i=>Object.entries(i).reduce((r,[t,y])=>Object.assign(r,{[t.replace(/[^a-z_.+\-A-Z -~]/g,"")]:y}),{}))}import{uniq as ur}from"lodash-es";function G(n,e){return ur(n.map(s=>s[e]||"").flat())}import at from"inquirer";import lr from"colors";import{uniq as cr}from"lodash-es";async function ut(n){let e=cr(n.map(a=>Object.keys(a)).flat()),s=n,l=!0;for(;l;){let{filterColumnName:a}=await at.prompt([{name:"filterColumnName",message:`If you need to filter the list of requests to import, choose the column to filter on. Currently ${s.length} rows.`,type:"list",default:e,choices:[A,...e]}]);if(l=A!==a,l){let o=G(s,a),{valuesToKeep:i}=await at.prompt([{name:"valuesToKeep",message:"Keep rows matching this value",type:"checkbox",default:e,choices:o}]);s=s.filter(r=>i.includes(r[a]))}}return u.info(lr.magenta(`Importing ${s.length} requests`)),s}import lt from"colors";import{RequestStatus as J}from"@transcend-io/privacy-types";import ct from"cli-progress";async function Ys({requestActions:n,auth:e,requestIds:s,statuses:l=[J.Compiling,J.RequestMade,J.Delayed,J.Approving,J.Secondary,J.Enriching,J.Waiting,J.SecondaryApproving],createdAtAfter:a,createdAtBefore:o,concurrency:i=100,transcendUrl:r=C}){let t=w(r,e),y=new Date().getTime(),c=new ct.SingleBar({},ct.Presets.shades_classic),g=await E(t,{actions:n,statuses:l,createdAtBefore:o,createdAtAfter:a,isSilent:!1,requestIds:s});u.info(lt.magenta(`Marking "${g.length}" as silent mode.`));let m=0;c.start(g.length,0),await b(g,async f=>{await P(t,oe,{input:{id:f.id,isSilent:!0}}),m+=1,c.update(m)},{concurrency:i}),c.stop();let p=new Date().getTime()-y;return u.info(lt.green(`Successfully marked ${m} requests as silent mode in "${p/1e3}" seconds!`)),g.length}import{getValues as mr,getEntries as pr}from"@transcend-io/type-utils";import fr from"inquirer";import{startCase as dr}from"lodash-es";async function mt(n,e){let s=mr(ie).filter(a=>!e.getValue("columnNames",a)),l=s.length===0?{}:await fr.prompt(s.map(a=>{let o=dr(a.replace("ColumnName","")),i=ne(n,o,Je[a],!!Ze[a]);return{name:a,message:`Choose the column that will be used to map in the field: ${o}`,type:"list",default:i[0],choices:i}}));return await Promise.all(pr(l).map(([a,o])=>e.setValue(o,"columnNames",a))),l}import re from"colors";import{CompletedRequestStatus as gr,RequestAction as yr,IsoCountryCode as qr,IsoCountrySubdivisionCode as Rr}from"@transcend-io/privacy-types";import{LanguageKey as hr}from"@transcend-io/internationalization";async function pt(n,e,{state:s,columnNameMap:l}){let a=f=>s.getValue("columnNames",f)||l[f],{internalSubjects:o}=await P(n,_e);u.info(re.magenta("Determining mapping of columns for request action"));let i=await ee(G(e,a("requestType")),Object.values(yr),s.getValue("requestTypeToRequestAction"));await s.setValue(i,"requestTypeToRequestAction"),u.info(re.magenta("Determining mapping of columns for subject"));let r=await ee(G(e,a("subjectType")),o.map(({type:f})=>f),s.getValue("subjectTypeToSubjectName"));await s.setValue(r,"subjectTypeToSubjectName"),u.info(re.magenta("Determining mapping of columns for locale"));let t=await ee(G(e,a("locale")),Object.values(hr),s.getValue("languageToLocale"));await s.setValue(t,"languageToLocale"),u.info(re.magenta("Determining mapping of columns for request status")),u.info(re.magenta("Determining mapping of columns for request status"));let y=a("requestStatus"),c=y===A?{}:await ee(G(e,y),[...Object.values(gr),A],s.getValue("statusToRequestStatus"));await s.setValue(c,"statusToRequestStatus"),u.info(re.magenta("Determining mapping of columns for country"));let g=a("country"),m=g===A?{}:await ee(G(e,g),[...Object.values(qr),A],s.getValue("regionToCountry"));await s.setValue(m,"regionToCountry"),u.info(re.magenta("Determining mapping of columns for country sub division"));let d=a("countrySubDivision"),p=d===A?{}:await ee(G(e,d),[...Object.values(Rr),A],s.getValue("regionToCountrySubDivision"));await s.setValue(p,"regionToCountrySubDivision")}import{LanguageKey as Sr}from"@transcend-io/internationalization";import{DateFromISOString as br}from"io-ts-types/lib/DateFromISOString";import*as D from"io-ts";import{NORMALIZE_PHONE_NUMBER as Tr,CompletedRequestStatus as Ar,RequestAction as wr,IdentifierType as be,IsoCountryCode as Cr,IsoCountrySubdivisionCode as Ir}from"@transcend-io/privacy-types";import{valuesOf as me}from"@transcend-io/type-utils";var Pr=D.record(D.string,D.array(D.intersection([D.type({value:D.string}),D.partial({name:D.string})]))),wo=D.intersection([D.type({email:D.string,attestedExtraIdentifiers:Pr,coreIdentifier:D.string,requestType:me(wr),subjectType:D.string}),D.partial({country:me(Cr),countrySubDivision:me(Ir),attributes:D.array(st),status:me(Ar),createdAt:br,dataSiloIds:D.array(D.string),locale:me(Sr)})]);function Dr(n,e,s){if(e===be.Email)return n.toLowerCase();if(e===be.Phone){let l=n.replace(Tr,"").replace(/[()]/g,"").replace(/[–]/g,"").replace(/[:]/g,"").replace(/[]/g,"").replace(/[A-Za-z]/g,"");return l?l.startsWith("+")?l:`+${s}${l}`:""}return n}function ft(n,e,{columnNameMap:s,identifierNameMap:l,attributeNameMap:a,requestAttributeKeys:o,defaultPhoneCountryCode:i="1"}){let r=t=>e.getValue("columnNames",t)||s[t];return n.map(t=>{let y={};Object.entries(l).filter(([,d])=>d!==A).forEach(([d,p])=>{let f=Object.values(be).includes(d)?d:be.Custom,h=t[p];if(h){let S=Dr(h,f,i);S&&(y[f]||(y[f]=[]),y[f].push({value:S,name:d}))}});let c=[];Object.entries(a).filter(([,d])=>d!==A).forEach(([d,p])=>{let f=t[p];if(f){let h=o.find(S=>S.name===d)?.type==="MULTI_SELECT";c.push({values:h?Ie(f):f,key:d})}});let g=r("requestType"),m=r("subjectType");return[t,{email:t[r("email")],attestedExtraIdentifiers:y,attributes:c,coreIdentifier:t[r("coreIdentifier")],requestType:g===ce?e.getValue("requestTypeToRequestAction",Ce):e.getValue("requestTypeToRequestAction",t[g]),subjectType:m===ce?e.getValue("subjectTypeToSubjectName",Ce):e.getValue("subjectTypeToSubjectName",t[m]),...r("locale")!==A&&t[r("locale")]?{locale:e.getValue("languageToLocale",t[r("locale")])}:{},...r("country")!==A&&t[r("country")]?{country:e.getValue("regionToCountry",t[r("country")])}:{},...r("countrySubDivision")!==A&&t[r("countrySubDivision")]?{countrySubDivision:e.getValue("regionToCountrySubDivision",t[r("countrySubDivision")])}:{},...r("requestStatus")!==A&&e.getValue("statusToRequestStatus",t[r("requestStatus")])!==A&&t[r("requestStatus")]?{status:e.getValue("statusToRequestStatus",t[r("requestStatus")])}:{},...r("createdAt")!==A&&t[r("createdAt")]?{createdAt:new Date(t[r("createdAt")])}:{},...r("dataSiloIds")!==A&&t[r("dataSiloIds")]?{dataSiloIds:Ie(t[r("dataSiloIds")])}:{}}]})}import dt from"colors";import gt from"cli-progress";import*as q from"io-ts";import{decodeCodec as Er,valuesOf as vr}from"@transcend-io/type-utils";import{TableEncryptionType as Nr}from"@transcend-io/privacy-types";var yt=q.type({defaultMessage:q.string,id:q.string}),xr=q.type({downloadKey:q.string,error:q.union([q.null,q.string]),mimetype:q.string,size:q.string,fileName:q.string,dataPoint:q.type({id:q.string,title:q.union([yt,q.null]),description:q.union([yt,q.null]),name:q.string,slug:q.string,encryption:q.union([vr(Nr),q.null]),dataSilo:q.type({id:q.string,title:q.string,description:q.string,type:q.string,outerType:q.union([q.string,q.null])}),path:q.array(q.string)})}),Lr=q.type({nodes:q.array(xr),totalCount:q.number,_links:q.partial({next:q.union([q.string,q.null]),previous:q.union([q.string,q.null])})});async function qt(n,{sombra:e,concurrency:s=5,limit:l=100}){u.info(dt.magenta(`Pulling file metadata for ${n.length} requests`));let a=new Date().getTime(),o=new gt.SingleBar({},gt.Presets.shades_classic),i=0;o.start(n.length,0);let r=await b(n,async c=>{let g=[],m=!0,d=0;for(;m;){let p;try{let f=await e.get(`v1/data-subject-request/${c.id}/download-keys`,{searchParams:{limit:l,offset:d}}).json();p=Er(Lr,f),g.push(...p.nodes),d+=l,m=!!p._links.next&&p.nodes.length===l}catch(f){throw new Error(`Received an error from server: ${f?.response?.body||f?.message}`)}}return i+=1,o.update(i),[c,g]},{concurrency:s});o.stop();let y=new Date().getTime()-a;return u.info(dt.green(`Successfully downloaded file metadata ${n.length} requests in "${y/1e3}" seconds!`)),r}import $r from"colors";async function Rt(n,{requestId:e,sombra:s,onFileDownloaded:l,concurrency:a=20}){await b(n,async o=>{try{await s.get("v1/files",{searchParams:{downloadKey:o.downloadKey}}).buffer().then(i=>l(o,i))}catch(i){if(i?.response?.body?.includes("fileMetadata#verify")){u.error($r.red(`Failed to pull file for: ${o.fileName} (request:${e}) - JWT expired. This likely means that the file is no longer available. Try restarting the request from scratch in Transcend Admin Dashboard. Skipping the download of this file.`));return}throw new Error(`Received an error from server: ${i?.response?.body||i?.message}`)}},{concurrency:a})}import{existsSync as Pe,mkdirSync as De,writeFileSync as Or}from"fs";import{dirname as jr,join as ht}from"path";import St from"colors";import{RequestAction as Fr,RequestStatus as Ee}from"@transcend-io/privacy-types";import bt from"cli-progress";async function Yo({auth:n,folderPath:e,requestIds:s,createdAtBefore:l,sombraAuth:a,createdAtAfter:o,statuses:i=[Ee.Approving,Ee.Downloadable],concurrency:r=5,transcendUrl:t=C,approveAfterDownload:y=!1}){let c=w(t,n),g=await W(t,n,a);Pe(e)||De(e);let m=await E(c,{actions:[Fr.Access],createdAtBefore:l,createdAtAfter:o,statuses:i,requestIds:s}),d=await qt(m,{sombra:g,concurrency:r}),p=new Date().getTime(),f=new bt.SingleBar({},bt.Presets.shades_classic),h=0,S=0;f.start(m.length,0),await b(d,async([v,x])=>{let K=ht(e,v.id);Pe(K)||De(K),await Rt(x,{sombra:g,requestId:v.id,onFileDownloaded:($,_)=>{let z=ht(K,$.fileName),j=jr(z);Pe(j)||De(j,{recursive:!0}),Or(z,_)}}),y&&v.status===Ee.Approving&&(await P(c,de,{input:{requestId:v.id}}),S+=1),h+=1,f.update(h)},{concurrency:r}),f.stop();let T=new Date().getTime()-p;return u.info(St.green(`Successfully downloaded ${h} requests in "${T/1e3}" seconds!`)),S>0&&u.info(St.green(`Approved ${S} requests in Transcend.`)),m.length}import*as I from"io-ts";import{uniq as _r}from"lodash-es";import{valuesOf as Te,decodeCodec as kr}from"@transcend-io/type-utils";import{IsoCountryCode as Vr,IsoCountrySubdivisionCode as Mr,RequestAction as Br,RequestStatus as Ur}from"@transcend-io/privacy-types";var ve=I.type({id:I.string,link:I.string,status:Te(Ur),type:Te(Br),subjectType:I.string,email:I.union([I.null,I.string]),coreIdentifier:I.string,isSilent:I.boolean,isTest:I.boolean,country:I.union([I.null,Te(Vr)]),countrySubDivision:I.union([I.null,Te(Mr)]),attributeValues:I.array(I.type({attributeKey:I.type({name:I.string}),name:I.string}))});async function Tt(n,e,{details:s="",isTest:l=!1,emailIsVerified:a=!0,skipSendingReceipt:o=!1,isSilent:i=!0,additionalAttributes:r=[]}={}){let t=[...r];(e.attributes||[]).forEach(g=>{let m=t.find(d=>d.key===g.key);m?(m.values.push(...g.values),m.values=_r(m.values)):t.push(g)});let y;try{y=await n.post("v1/data-subject-request",{json:{type:e.requestType,subject:{coreIdentifier:e.coreIdentifier,email:e.email,emailIsVerified:a,attestedExtraIdentifiers:e.attestedExtraIdentifiers},subjectType:e.subjectType,isSilent:i,isTest:l,skipSendingReceipt:o,...e.locale?{locale:e.locale}:{},details:s,attributes:t,...e.country||e.countrySubDivision?{region:{...e.country?{country:e.country}:e.countrySubDivision?{country:e.countrySubDivision.split("-")[0]}:{},...e.countrySubDivision?{countrySubDivision:e.countrySubDivision}:{}}}:{},...e.createdAt?{createdAt:e.createdAt}:{},...e.dataSiloIds?{dataSiloIds:e.dataSiloIds}:{},...e.status?{completedRequestStatus:e.status}:{}}}).json()}catch(g){throw new Error(`Received an error from server: ${g?.response?.body||g?.message}`)}let{request:c}=kr(I.type({request:ve}),y);return c}import Ne from"colors";import{RequestStatus as Qr}from"@transcend-io/privacy-types";import At from"cli-progress";async function li({requestActions:n,requestOrigins:e,auth:s,silentModeBefore:l,createdAtAfter:a,createdAtBefore:o,concurrency:i=50,transcendUrl:r=C}){let t=w(r,s),y=new Date().getTime(),c=new At.SingleBar({},At.Presets.shades_classic),g=await E(t,{actions:n,statuses:[Qr.Approving],createdAtAfter:a,origins:e,createdAtBefore:o});u.info(Ne.magenta(`Approving "${g.length}" requests.`));let m=0,d=0;c.start(g.length,0),await b(g,async h=>{l&&new Date(l)>new Date(h.createdAt)&&await P(t,oe,{input:{id:h.id,isSilent:!0}});try{await P(t,de,{input:{requestId:h.id}})}catch(S){S.message.includes("Request must be in an approving state,")&&(d+=1)}m+=1,c.update(m)},{concurrency:i}),c.stop();let f=new Date().getTime()-y;return d>0&&u.info(Ne.yellow(`${d} requests were skipped.`)),u.info(Ne.green(`Successfully approved ${m} requests in "${f/1e3}" seconds!`)),g.length}import wt from"colors";import{RequestAction as Gr}from"@transcend-io/privacy-types";import Ct from"cli-progress";async function Ri({requestActions:n=Object.values(Gr),auth:e,requestIds:s,createdAtBefore:l,days:a=45,daysLeft:o=10,createdAtAfter:i,emailTemplate:r="Additional Time Needed",concurrency:t=100,transcendUrl:y=C}){let c=w(y,e),g=new Date().getTime(),m=new Ct.SingleBar({},Ct.Presets.shades_classic),p=(await ge(c,r)).find(T=>T.title===r);if(!p)throw new Error(`Failed to find a template with title: "${r}"`);let f=await E(c,{actions:n,createdAtBefore:l,createdAtAfter:i,isSilent:!1,isClosed:!1,requestIds:s});f=f.filter(T=>typeof T.daysRemaining=="number"&&T.daysRemaining<o),u.info(wt.magenta(`Notifying "${f.length}" that more time is needed.`));let h=0;m.start(f.length,0),await b(f,async T=>{await P(c,Ve,{input:{requestId:T.id,template:p.template.defaultMessage,subject:p.subject.defaultMessage,additionalTime:a}}),h+=1,m.update(h)},{concurrency:t}),m.stop();let N=new Date().getTime()-g;return u.info(wt.green(`Successfully marked ${h} requests as silent mode in "${N/1e3}" seconds!`)),f.length}import Kr from"inquirer";async function It(n,e,s){let{initializer:l}=await P(n,Fe),a=l.identifiers.filter(({name:i})=>!s.getValue("identifierNames",i)&&!Re.includes(i)),o=a.length===0?{}:await Kr.prompt(a.map(({name:i})=>{let r=ne(e,i,!1);return{name:i,message:`Choose the column that will be used to map in the identifier: ${i}`,type:"list",default:r[0],choices:r}}));return await Promise.all(Object.entries(o).map(([i,r])=>s.setValue(r,"identifierNames",i))),{...s.getValue("identifierNames"),...o}}import Pt from"colors";import{RequestStatus as Z}from"@transcend-io/privacy-types";import Dt from"cli-progress";async function ji({requestActions:n,cancellationTitle:e,auth:s,requestIds:l,silentModeBefore:a,createdAtBefore:o,createdAtAfter:i,statuses:r=[Z.Compiling,Z.RequestMade,Z.Delayed,Z.Approving,Z.Secondary,Z.Enriching,Z.Waiting,Z.SecondaryApproving],concurrency:t=50,transcendUrl:y=C}){let c=w(y,s),g=new Date().getTime(),m=new Dt.SingleBar({},Dt.Presets.shades_classic),d;if(e){let T=(await ge(c,e)).find(v=>v.title===e);if(!T)throw new Error(`Failed to find a template with title: "${e}"`);d=T}let p=await E(c,{actions:n,createdAtBefore:o,createdAtAfter:i,statuses:r,requestIds:l});u.info(Pt.magenta(`Canceling "${p.length}" requests${d?` Using template: ${d.title}`:""}.`));let f=0;m.start(p.length,0),await b(p,async N=>{a&&new Date(a)>new Date(N.createdAt)&&await P(c,oe,{input:{id:N.id,isSilent:!0}}),await P(c,ke,{input:{requestId:N.id,...d?{subject:`Re: ${d.subject.defaultMessage}`,template:d.template.defaultMessage}:{}}}),f+=1,m.update(f)},{concurrency:t}),m.stop();let S=new Date().getTime()-g;return u.info(Pt.green(`Successfully canceled ${f} requests in "${S/1e3}" seconds!`)),p.length}import zr from"inquirer";async function Et(n,e,s,l){let a=l.filter(({name:i})=>!s.getValue("attributeNames",i)),o=a.length===0?{}:await zr.prompt(a.map(({name:i})=>{let r=ne(e,i,!1);return{name:i,message:`Choose the column that will be used to map in the attribute: ${i}`,type:"list",default:r[0],choices:r}}));return await Promise.all(Object.entries(o).map(([i,r])=>s.setValue(r,"attributeNames",i))),{...s.getValue("attributeNames"),...o}}var vt=/{\\"message\\":\\"(.+?)\\",/;function Ae(n){return vt.test(n)?vt.exec(n)[1]:null}import F from"colors";import*as pe from"io-ts";import{uniq as Yr}from"lodash-es";import Nt from"cli-progress";import{join as Wr}from"path";import{PersistedState as xt}from"@transcend-io/persisted-state";async function ln({cacheFilepath:n,requestReceiptFolder:e,file:s,auth:l,sombraAuth:a,concurrency:o=100,defaultPhoneCountryCode:i="1",transcendUrl:r=C,attributes:t=[],emailIsVerified:y=!0,skipFilterStep:c=!1,skipSendingReceipt:g=!0,isTest:m=!1,isSilent:d=!0,debug:p=!1,dryRun:f=!1}){let h=new Date().getTime(),S=new Nt.SingleBar({},Nt.Presets.shades_classic),N=ot(t),T=new xt(n,He,{columnNames:{},requestTypeToRequestAction:{},subjectTypeToSubjectName:{},languageToLocale:{},statusToRequestStatus:{},identifierNames:{},attributeNames:{},regionToCountrySubDivision:{},regionToCountry:{}}),v=Wr(e,`tr-request-upload-${new Date().toISOString()}-${s.split("/").pop()}`.replace(".csv",".json")),x=new xt(v,Xe,{successfulRequests:[],duplicateRequests:[],failingRequests:[]}),K=await W(r,l,a),$=nt(s,pe.record(pe.string,pe.string)),_=Yr($.map(U=>Object.keys(U)).flat());if($.length===0)throw new Error("No Requests found in list! Ensure the first row of the CSV is a header and the rest are requests.");if(p){let U=$[0];u.info(F.magenta(`First request: ${JSON.stringify(U,null,2)}`))}let z=c?$:await ut($),j=w(r,l),L=await ze(j),B=await mt(_,T),Y=await It(j,_,T),k=await Et(j,_,T,L);await pt(j,z,{state:T,columnNameMap:B});let O=ft(z,T,{defaultPhoneCountryCode:i,columnNameMap:B,identifierNameMap:Y,attributeNameMap:k,requestAttributeKeys:L});p||S.start(O.length,0);let H=0;await b(O,async([U,V],Q)=>{let Oe=p?`email:${V.email} | coreIdentifier:${V.coreIdentifier}`:`row:${Q.toString()}`;if(p&&u.info(F.magenta(`[${Q+1}/${O.length}] Importing: ${JSON.stringify(V,null,2)}`)),f){u.info(F.magenta("Bailing out on dry run because dryRun is set"));return}try{let X=await Tt(K,V,{details:`Uploaded by Transcend Cli: "tr-request-upload" : ${JSON.stringify(U,null,2)}`,isTest:m,emailIsVerified:y,skipSendingReceipt:g,isSilent:d,additionalAttributes:N});p&&(u.info(F.green(`[${Q+1}/${O.length}] Successfully submitted the test data subject request: "${Oe}"`)),u.info(F.green(`[${Q+1}/${O.length}] View it at: "${X.link}"`)));let se=x.getValue("successfulRequests");se.push({id:X.id,link:X.link,rowIndex:Q,coreIdentifier:X.coreIdentifier,attemptedAt:new Date().toISOString()}),await x.setValue(se,"successfulRequests")}catch(X){let se=`${X.message} - ${JSON.stringify(X.response?.body,null,2)}`,we=Ae(se);if(we==="Client error: You have already made this request."){p&&u.info(F.yellow(`[${Q+1}/${O.length}] Skipping request as it is a duplicate`));let ue=x.getValue("duplicateRequests");ue.push({coreIdentifier:V.coreIdentifier,rowIndex:Q,attemptedAt:new Date().toISOString()}),await x.setValue(ue,"duplicateRequests")}else{let ue=x.getValue("failingRequests");ue.push({...V,rowIndex:Q,error:we||se,attemptedAt:new Date().toISOString()}),await x.setValue(ue,"failingRequests"),p&&(u.error(F.red(we||se)),u.error(F.red(`[${Q+1}/${O.length}] Failed to submit request for: "${Oe}"`)))}}H+=1,p||S.update(H)},{concurrency:o}),S.stop();let ae=new Date().getTime()-h;u.info(F.green(`Completed upload in "${ae/1e3}" seconds.`)),x.getValue("duplicateRequests").length>0&&u.info(F.yellow(`Encountered "${x.getValue("duplicateRequests").length}" duplicate requests. See "${v}" to review the core identifiers for these requests.`)),x.getValue("failingRequests").length>0&&(u.error(F.red(`Encountered "${x.getValue("failingRequests").length}" errors. See "${v}" to review the error messages and inputs.`)),process.exit(1))}import*as Lt from"io-ts";import{groupBy as Jr}from"lodash-es";import{apply as Zr,decodeCodec as Hr}from"@transcend-io/type-utils";import{IdentifierType as xe}from"@transcend-io/privacy-types";async function $t(n,e,{sendEmailReceipt:s=!1,skipWaitingPeriod:l=!1,emailIsVerified:a=!0,requestIdentifiers:o=[]}={}){let i=await n.post("v1/data-subject-request",{json:{type:e.type,subject:{coreIdentifier:e.coreIdentifier,email:e.email,emailIsVerified:a,...o.length>0?{attestedExtraIdentifiers:Zr(Jr(o.filter(t=>!(t.name==="email"&&t.value===e.email)&&!Re.includes(t.name)).map(t=>({...t,type:Object.values(xe).includes(t.name)?t.name:xe.Custom})),"type"),(t,y)=>t.map(({name:c,value:g})=>({...y===xe.Custom?{name:c}:{},value:g})))}:{}},requestId:e.id,subjectType:e.subjectType,isSilent:e.isSilent,isTest:e.isTest,locale:e.locale,skipWaitingPeriod:l,createdAt:e.createdAt,details:`Restarted by Transcend cli: "tr-request-restart" - ${e.details}`,skipSendingReceipt:!s}}).json(),{request:r}=Hr(Lt.type({request:ve}),i);return r}import{PersistedState as Xr}from"@transcend-io/persisted-state";import Ot from"cli-progress";import Le from"colors";import*as M from"io-ts";import{difference as es}from"lodash-es";import{join as ts}from"path";var rs=M.intersection([he,M.type({error:M.string})]),ss=M.type({restartedRequests:M.array(he),failingRequests:M.array(rs)});async function En({requestReceiptFolder:n,auth:e,sombraAuth:s,requestActions:l,requestStatuses:a,createdAtBefore:o,createdAtAfter:i,transcendUrl:r=C,requestIds:t=[],createdAt:y=new Date,silentModeBefore:c,sendEmailReceipt:g=!1,emailIsVerified:m=!0,copyIdentifiers:d=!1,skipWaitingPeriod:p=!1,concurrency:f=20}){let h=new Date().getTime(),S=new Ot.SingleBar({},Ot.Presets.shades_classic),N=ts(n,`tr-request-restart-${new Date().toISOString()}`),T=new Xr(N,ss,{restartedRequests:[],failingRequests:[]}),v=await W(r,e,s),x=w(r,e),$=(await E(x,{actions:l,statuses:a,createdAtBefore:o,createdAtAfter:i})).filter(L=>new Date(L.createdAt)<y);if(u.info(`Found ${$.length} requests to process`),d&&u.info("copyIdentifiers detected - All Identifiers will be copied."),g&&u.info("sendEmailReceipt detected - Email receipts will be sent."),p&&u.info("skipWaitingPeriod detected - Waiting period will be skipped."),t.length>0&&t.length!==$.length){let L=es(t,$.map(({id:B})=>B));L.length>0&&(u.error(Le.red(`Failed to find the following requests by ID: ${L.join(",")}.`)),process.exit(1))}let _=0;S.start($.length,0),await b($,async(L,B)=>{try{let Y=d?await ye(x,v,{requestId:L.id}):[],k=await $t(v,{...L,isSilent:c&&new Date(L.createdAt)<c?!0:L.isSilent},{requestIdentifiers:Y,skipWaitingPeriod:p,sendEmailReceipt:g,emailIsVerified:m}),O=T.getValue("restartedRequests");O.push({id:k.id,link:k.link,rowIndex:B,coreIdentifier:k.coreIdentifier,attemptedAt:new Date().toISOString()}),await T.setValue(O,"restartedRequests")}catch(Y){let k=`${Y.message} - ${JSON.stringify(Y.response?.body,null,2)}`,O=Ae(k),H=T.getValue("failingRequests");H.push({id:L.id,link:L.link,rowIndex:B,coreIdentifier:L.coreIdentifier,attemptedAt:new Date().toISOString(),error:O||k}),await T.setValue(H,"failingRequests")}_+=1,S.update(_)},{concurrency:f}),S.stop();let j=new Date().getTime()-h;u.info(Le.green(`Completed restarting of requests in "${j/1e3}" seconds.`)),T.getValue("failingRequests").length>0&&(u.error(Le.red(`Encountered "${T.getValue("failingRequests").length}" errors. See "${N}" to review the error messages and inputs.`)),process.exit(1))}import jt from"colors";import Ft from"cli-progress";import{RequestEnricherStatus as _t,RequestStatus as os}from"@transcend-io/privacy-types";async function _n({enricherIds:n,auth:e,concurrency:s=100,transcendUrl:l=C}){let a=w(l,e),o=new Date().getTime(),i=await E(a,{statuses:[os.Enriching]});u.info(jt.magenta(`Processing enricher: "${n.join(",")}" fetched "${i.length}" in enriching status.`));let r=new Ft.SingleBar({},Ft.Presets.shades_classic),t=0;r.start(i.length,0);let y=0;await b(i,async m=>{let p=(await qe(a,{requestId:m.id})).filter(f=>n.includes(f.enricher.id)&&![_t.Resolved,_t.Skipped].includes(f.status));p.length>0&&await je(p,async f=>{try{await P(a,Me,{requestEnricherId:f.id}),y+=1}catch(h){if(!h.message.includes("Client error: Cannot skip Request enricher because it has already completed"))throw h}}),t+=1,r.update(t)},{concurrency:s}),r.stop();let g=new Date().getTime()-o;return u.info(jt.green(`Successfully skipped "${y}" for "${i.length}" requests in "${g/1e3}" seconds!`)),i.length}import{RequestEnricherStatus as is,RequestStatus as ns}from"@transcend-io/privacy-types";import kt from"cli-progress";import $e from"colors";import{difference as as}from"lodash-es";async function Wn({auth:n,requestActions:e=[],createdAtBefore:s,createdAtAfter:l,transcendUrl:a=C,requestEnricherStatuses:o=Object.values(is),requestIds:i=[],enricherId:r,concurrency:t=20}){let y=new Date().getTime(),c=new kt.SingleBar({},kt.Presets.shades_classic),g=w(a,n);u.info($e.magenta("Fetching requests to restart..."));let m=await E(g,{actions:e,statuses:[ns.Enriching],createdAtBefore:s,createdAtAfter:l,requestIds:i}),d=0;if(i.length>0&&i.length!==m.length){let S=as(i,m.map(({id:N})=>N));S.length>0&&(u.error($e.red(`Failed to find the following requests by ID: ${S.join(",")}.`)),process.exit(1))}let p=0;c.start(m.length,0),await b(m,async S=>{let T=(await qe(g,{requestId:S.id})).filter(v=>v.enricher.id===r&&o.includes(v.status));await b(T,async v=>{await Ge(g,v.id),d+=1}),p+=1,c.update(p)},{concurrency:t}),c.stop();let h=new Date().getTime()-y;u.info($e.green(`Completed restarting of ${m.length} requests and ${d} enrichers in "${h/1e3}" seconds.`))}import Vt from"colors";import{RequestStatus as Mt}from"@transcend-io/privacy-types";import Bt from"cli-progress";async function ia({requestActions:n,dataSiloId:e,auth:s,concurrency:l=20,transcendUrl:a=C}){let o=w(a,s),i=new Date().getTime(),r=new Bt.SingleBar({},Bt.Presets.shades_classic),t=await E(o,{actions:n,statuses:[Mt.Compiling,Mt.Approving]});u.info(Vt.magenta(`Retrying requests for Data Silo: "${e}", restarting "${t.length}" requests.`));let y=0,c=0;r.start(t.length,0),await b(t,async d=>{try{let p=await We(o,{requestId:d.id,dataSiloId:e});await P(o,Ue,{requestDataSiloId:p.id})}catch(p){if(!p.message.includes("Failed to find RequestDataSilo"))throw p;c+=1}y+=1,r.update(y)},{concurrency:l}),r.stop();let m=new Date().getTime()-i;return u.info(Vt.green(`Successfully notified Transcend in "${m/1e3}" seconds for ${y} requests, ${c} requests were skipped because data silo was not attached to the request!`)),t.length}import Ut from"colors";import{groupBy as Qt}from"lodash-es";async function ga({auth:n,sombraAuth:e,actions:s=[],statuses:l=[],identifierSearch:a,pageLimit:o=100,transcendUrl:i=C,createdAtBefore:r,createdAtAfter:t,isTest:y}){let c=w(i,n),g=await W(i,n,e),m="";r&&(m+=` before ${r.toISOString()}`),t&&(m+=`${m?", and":""} after ${t.toISOString()}`),u.info(Ut.magenta(`${s.length>0?`Pulling requests of type "${s.join('" , "')}"`:"Pulling all requests"}${m}`));let d=await E(c,{actions:s,text:a,statuses:l,createdAtBefore:r,createdAtAfter:t,isTest:y}),p=await b(d,async h=>{let S=await ye(c,g,{requestId:h.id});return{...h,requestIdentifiers:S}},{concurrency:o});u.info(Ut.magenta(`Pulled ${p.length} requests`));let f=p.map(({attributeValues:h,requestIdentifiers:S,id:N,email:T,type:v,status:x,subjectType:K,details:$,createdAt:_,country:z,locale:j,origin:L,countrySubDivision:B,isSilent:Y,isTest:k,coreIdentifier:O,...H})=>({"Request ID":N,"Created At":_,Email:T,"Core Identifier":O,"Request Type":v,"Data Subject Type":K,Status:x,Country:z,"Country Sub Division":B,Details:$,Origin:L,"Silent Mode":Y,"Is Test Request":k,Language:j,...H,...Object.entries(Qt(h,"attributeKey.name")).reduce((fe,[ae,U])=>Object.assign(fe,{[ae]:U.map(({name:V})=>V).join(",")}),{}),...Object.entries(Qt(S,"name")).reduce((fe,[ae,U])=>Object.assign(fe,{[ae]:U.map(({value:V})=>V).join(",")}),{})}));return{requestsWithRequestIdentifiers:p,requestsFormattedForCsv:f}}import Gt from"colors";import Kt from"cli-progress";import{RequestStatus as zt}from"@transcend-io/privacy-types";async function wa({dataSiloId:n,auth:e,concurrency:s=100,status:l="SKIPPED",transcendUrl:a=C,requestStatuses:o=[zt.Compiling,zt.Secondary]}){let i=w(a,e),r=new Date().getTime(),t=await Ye(i,{dataSiloId:n,requestStatuses:o});u.info(Gt.magenta(`Processing data silo: "${n}" marking "${t.length}" requests as skipped.`));let y=new Kt.SingleBar({},Kt.Presets.shades_classic),c=0;y.start(t.length,0),await b(t,async d=>{try{await P(i,Be,{requestDataSiloId:d.id,status:l})}catch(p){if(!p.message.includes("Client error: Request must be active:"))throw p}c+=1,y.update(c)},{concurrency:s}),y.stop();let m=new Date().getTime()-r;return u.info(Gt.green(`Successfully skipped "${t.length}" requests in "${m/1e3}" seconds!`)),t.length}import Yt from"colors";import{RequestStatus as us}from"@transcend-io/privacy-types";import Wt from"cli-progress";async function $a({requestActions:n,identifierNames:e,auth:s,concurrency:l=20,transcendUrl:a=C}){let o=w(a,s),i=new Date().getTime(),r=new Wt.SingleBar({},Wt.Presets.shades_classic),t=await E(o,{actions:n,statuses:[us.Enriching]});u.info(Yt.magenta("Fetched requests in preflight/enriching state."));let y=0,c=0;r.start(t.length,0),await b(t,async d=>{let f=(await Ke(o,{requestId:d.id})).filter(({isVerifiedAtLeastOnce:h,name:S})=>h===!1&&e.includes(S)).map(({id:h})=>h);f.length>0&&(await P(o,Qe,{input:{requestId:d.id,requestIdentifierIds:f}}),c+=f.length),y+=1,r.update(y)},{concurrency:l}),r.stop();let m=new Date().getTime()-i;return u.info(Yt.green(`Successfully cleared out unverified identifiers "${m/1e3}" seconds for ${y} requests, ${c} identifiers were cleared out!`)),t.length}export{A as a,ce as b,Ce as c,Re as d,ie as e,Je as f,Ze as g,He as h,he as i,Xe as j,Se as k,ne as l,ee as m,Ie as n,st as o,ot as p,nt as q,G as r,ut as s,Ys as t,mt as u,pt as v,Pr as w,wo as x,Dr as y,ft as z,yt as A,xr as B,Lr as C,qt as D,Rt as E,Yo as F,ve as G,Tt as H,li as I,Ri as J,It as K,ji as L,Et as M,Ae as N,ln as O,$t as P,En as Q,_n as R,Wn as S,ia as T,ga as U,wa as V,$a as W};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ee as N,b}from"./chunk-
|
|
1
|
+
import{Ee as N,b}from"./chunk-SNE53JL2.js";import{f as U}from"./chunk-APA5PR4U.js";import{a}from"./chunk-OERYFLN2.js";import*as E from"crypto";import*as $ from"jsonwebtoken";function B(c,l,n){let o=Buffer.from(n,"base64"),f=Buffer.from(l,"base64"),u="id-aes256-wrap-pad",d=Buffer.from("A65959A6","hex"),s=E.createCipheriv(u,f,d),i={encryptedIdentifier:Buffer.concat([s.update(c),s.final()]).toString("base64")};return $.sign(i,o,{algorithm:"HS384"})}import*as e from"io-ts";var O=e.intersection([e.type({userId:e.string,timestamp:e.string}),e.partial({confirmed:e.union([e.literal("true"),e.literal("false")]),updated:e.union([e.literal("true"),e.literal("false")]),prompted:e.union([e.literal("true"),e.literal("false")]),metadata:e.string,usp:e.union([e.string,e.null]),gpp:e.union([e.string,e.null])})]),Y=e.intersection([O,e.partial({purposes:e.string})]),G=e.intersection([O,e.type({partition:e.string}),e.partial({tcf:e.union([e.string,e.null]),purposes:e.record(e.string,e.union([e.boolean,e.string]))})]);import P from"colors";import*as r from"io-ts";import A from"cli-progress";import{decodeCodec as I}from"@transcend-io/type-utils";var R=/^[0-9][Y|N]([Y|N])[Y|N]$/,_=r.record(r.string,r.union([r.boolean,r.literal("Auto")]));async function Z({base64EncryptionKey:c,base64SigningKey:l,preferences:n,partition:o,concurrency:f=100,transcendUrl:u=U}){let d=N(u),s=n.filter(t=>t.usp&&!R.test(t.usp));if(s.length>0)throw new Error(`Received invalid usp strings: ${JSON.stringify(s,null,2)}`);let m=n.map((t,y)=>[t,y]).filter(([t])=>{if(!t.purposes)return!1;try{return I(_,t.purposes),!1}catch{return!0}});if(m.length>0)throw new Error(`Received invalid purpose maps: ${JSON.stringify(m,null,2)}`);let i=n.filter(t=>!t.usp&&!t.purposes);if(i.length>0)throw new Error(`Received invalid inputs, expected either purposes or usp to be defined: ${JSON.stringify(i,null,2)}`);a.info(P.magenta(`Uploading ${n.length} user preferences to partition ${o}`));let w=new Date().getTime(),g=new A.SingleBar({},A.Presets.shades_classic),S=0;g.start(n.length,0),await b(n,async({userId:t,confirmed:y="true",updated:T,prompted:v,purposes:x,...p})=>{let k=B(t,c,l),[,D]=p.usp?R.exec(p.usp)||[]:[],F={token:k,partition:o,consent:{confirmed:y==="true",purposes:x?I(_,x):p.usp?{SaleOfInfo:D==="Y"}:{},...T?{updated:T==="true"}:{},...v?{prompted:v==="true"}:{},...p}};try{await d.post("sync",{json:F}).json()}catch(h){try{let C=JSON.parse(h?.response?.body||"{}");C.error&&a.error(P.red(`Error: ${C.error}`))}catch{}throw new Error(`Received an error from server: ${h?.response?.body||h?.message}`)}S+=1,g.update(S)},{concurrency:f}),g.stop();let j=new Date().getTime()-w;a.info(P.green(`Successfully uploaded ${n.length} user preferences to partition ${o} in "${j/1e3}" seconds!`))}export{B as a,Y as b,G as c,R as d,_ as e,Z as f};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{d as a}from"./chunk-EZCJGIOS.js";import{buildCommand as c,numberParser as f}from"@stricli/core";import{ConsentTrackerStatus as l}from"@transcend-io/privacy-types";import{ScopeName as d,TRANSCEND_SCOPES as n}from"@transcend-io/privacy-types";function m(e){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e))throw new Error(`Invalid UUID format: ${e}`);return e}function i(e){try{return new URL(e).toString()}catch{throw new Error(`Invalid URL format: ${e}`)}}function h(e){return e.split(",").map(r=>r.trim()).filter(r=>r.length>0)}function g(e){let r=new Date(e);if(Number.isNaN(r.getTime()))throw new TypeError(`Invalid date: ${e}. Try using the ISO 8601 format (YYYY-MM-DDTHH:MM:SS.SSSZ)`);return r}var o=({scopes:e,requiresSiloScope:r=!1})=>{let t={kind:"parsed",parse:String,brief:"The Transcend API key."};return r&&(t.brief+=" This key must be associated with the data silo(s) being operated on."),e==="Varies"?{...t,brief:`${t.brief} The scopes required will vary depending on the operation performed. If in doubt, the ${n[d.FullAdmin].title} scope will always work.`}:e.length===0?{...t,brief:`${t.brief} No scopes are required for this command.`}:{...t,brief:`${t.brief} Requires scopes: ${e.map(u=>`"${n[u].title}"`).join(", ")}`}},s=(e="https://api.transcend.io")=>({kind:"parsed",parse:i,brief:"URL of the Transcend backend. Use https://api.us.transcend.io for US hosting",default:e}),k=()=>({kind:"parsed",parse:String,brief:"The Sombra internal key, use for additional authentication when self-hosting Sombra",optional:!0});var p=["dataSilos","enrichers","templates","apiKeys"],U=Object.values(l),A=c({loader:async()=>{let{pull:e}=await import("./impl-
|
|
1
|
+
import{d as a}from"./chunk-EZCJGIOS.js";import{buildCommand as c,numberParser as f}from"@stricli/core";import{ConsentTrackerStatus as l}from"@transcend-io/privacy-types";import{ScopeName as d,TRANSCEND_SCOPES as n}from"@transcend-io/privacy-types";function m(e){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e))throw new Error(`Invalid UUID format: ${e}`);return e}function i(e){try{return new URL(e).toString()}catch{throw new Error(`Invalid URL format: ${e}`)}}function h(e){return e.split(",").map(r=>r.trim()).filter(r=>r.length>0)}function g(e){let r=new Date(e);if(Number.isNaN(r.getTime()))throw new TypeError(`Invalid date: ${e}. Try using the ISO 8601 format (YYYY-MM-DDTHH:MM:SS.SSSZ)`);return r}var o=({scopes:e,requiresSiloScope:r=!1})=>{let t={kind:"parsed",parse:String,brief:"The Transcend API key."};return r&&(t.brief+=" This key must be associated with the data silo(s) being operated on."),e==="Varies"?{...t,brief:`${t.brief} The scopes required will vary depending on the operation performed. If in doubt, the ${n[d.FullAdmin].title} scope will always work.`}:e.length===0?{...t,brief:`${t.brief} No scopes are required for this command.`}:{...t,brief:`${t.brief} Requires scopes: ${e.map(u=>`"${n[u].title}"`).join(", ")}`}},s=(e="https://api.transcend.io")=>({kind:"parsed",parse:i,brief:"URL of the Transcend backend. Use https://api.us.transcend.io for US hosting",default:e}),k=()=>({kind:"parsed",parse:String,brief:"The Sombra internal key, use for additional authentication when self-hosting Sombra",optional:!0});var p=["dataSilos","enrichers","templates","apiKeys"],U=Object.values(l),A=c({loader:async()=>{let{pull:e}=await import("./impl-YUZJV3RL.js");return e},parameters:{flags:{auth:o({scopes:"Varies"}),resources:{kind:"enum",values:Object.values(a),brief:`The different resource types to pull in. Defaults to ${p.join(",")}.`,variadic:",",optional:!0},file:{kind:"parsed",parse:String,brief:"Path to the YAML file to pull into",default:"./transcend.yml"},transcendUrl:s(),dataSiloIds:{kind:"parsed",parse:String,variadic:",",brief:"The UUIDs of the data silos that should be pulled into the YAML file",optional:!0},integrationNames:{kind:"parsed",parse:String,variadic:",",brief:"The types of integrations to pull down",optional:!0},trackerStatuses:{kind:"enum",values:Object.values(l),variadic:",",brief:"The statuses of consent manager trackers to pull down. Defaults to all statuses.",optional:!0},pageSize:{kind:"parsed",parse:f,brief:"The page size to use when paginating over the API",default:"50"},skipDatapoints:{kind:"boolean",brief:"When true, skip pulling in datapoints alongside data silo resource",default:!1},skipSubDatapoints:{kind:"boolean",brief:"When true, skip pulling in subDatapoints alongside data silo resource",default:!1},includeGuessedCategories:{kind:"boolean",brief:"When true, included guessed data categories that came from the content classifier",default:!1},debug:{kind:"boolean",brief:"Set to true to include debug logs while pulling the configuration",default:!1}}},docs:{brief:"Pull configuration from Transcend",fullDescription:`Generate's a transcend.yml by pulling the configuration from your connected services view.
|
|
2
2
|
|
|
3
3
|
The API key needs various scopes depending on the resources being pulled.`}});export{m as a,i as b,h as c,g as d,o as e,s as f,k as g,p as h,U as i,A as j};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as ui}from"./chunk-
|
|
1
|
+
import{b as ui}from"./chunk-BHDQRYCC.js";import{a}from"./chunk-OERYFLN2.js";async function T(t,e){let n=[];for(let r=0;r<t.length;r+=1)n.push(await e(t[r],r,t.length));return n}async function M(t,e,n={}){let{concurrency:r=1/0}=n,i=new Array(t.length),s=[],o=0,l=async()=>{if(o>=t.length)return;let d=o;o+=1;let m=e(t[d],d,t.length).then(h=>{i[d]=h});s.push(m),await m;let g=s.indexOf(m);g>-1&&s.splice(g,1)},u=Math.min(r,t.length),c=[];for(let d=0;d<u;d+=1)c.push(l());for(await Promise.all(c);o<t.length;)s.length<r?await l():await Promise.race(s);return await Promise.all(s),i}import{gql as Me}from"graphql-request";var di=Me`
|
|
2
2
|
query TranscendCliDataPoints(
|
|
3
3
|
$filterBy: DataPointFiltersInput
|
|
4
4
|
$first: Int!
|