@transcend-io/cli 7.0.0-alpha.8 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/README.md +10 -6
  2. package/dist/bin/bash-complete.cjs +4 -0
  3. package/dist/bin/bash-complete.cjs.map +1 -0
  4. package/dist/bin/bash-complete.d.cts +1 -0
  5. package/dist/bin/cli.cjs +3 -0
  6. package/dist/bin/cli.cjs.map +1 -0
  7. package/dist/bin/cli.d.cts +1 -0
  8. package/dist/bin/deprecated-command.cjs +7 -0
  9. package/dist/bin/deprecated-command.cjs.map +1 -0
  10. package/dist/bin/deprecated-command.d.cts +1 -0
  11. package/dist/chunk-ANCIGXE5.cjs +4 -0
  12. package/dist/chunk-ANCIGXE5.cjs.map +1 -0
  13. package/dist/chunk-AW6I4V4F.cjs +3 -0
  14. package/dist/chunk-AW6I4V4F.cjs.map +1 -0
  15. package/dist/chunk-BY7W4UQF.cjs +2 -0
  16. package/dist/chunk-BY7W4UQF.cjs.map +1 -0
  17. package/dist/chunk-CHTWXNEA.cjs +2 -0
  18. package/dist/chunk-CHTWXNEA.cjs.map +1 -0
  19. package/dist/chunk-DS6VH676.cjs +2 -0
  20. package/dist/chunk-DS6VH676.cjs.map +1 -0
  21. package/dist/chunk-EG4L6YAJ.cjs +2 -0
  22. package/dist/chunk-EG4L6YAJ.cjs.map +1 -0
  23. package/dist/chunk-ETNRSKUM.cjs +2 -0
  24. package/dist/chunk-ETNRSKUM.cjs.map +1 -0
  25. package/dist/chunk-GM2EDRKN.cjs +12 -0
  26. package/dist/chunk-GM2EDRKN.cjs.map +1 -0
  27. package/dist/chunk-IBTP5OXE.cjs +2 -0
  28. package/dist/chunk-IBTP5OXE.cjs.map +1 -0
  29. package/dist/chunk-KOV2SQO2.cjs +4 -0
  30. package/dist/chunk-KOV2SQO2.cjs.map +1 -0
  31. package/dist/chunk-LBDIZJ23.cjs +2844 -0
  32. package/dist/chunk-LBDIZJ23.cjs.map +1 -0
  33. package/dist/chunk-LZYEIVWM.cjs +94 -0
  34. package/dist/chunk-LZYEIVWM.cjs.map +1 -0
  35. package/dist/chunk-MPJABCSW.cjs +75 -0
  36. package/dist/chunk-MPJABCSW.cjs.map +1 -0
  37. package/dist/chunk-R5N2S5UU.cjs +2 -0
  38. package/dist/chunk-R5N2S5UU.cjs.map +1 -0
  39. package/dist/chunk-RW5GSSAA.cjs +2 -0
  40. package/dist/chunk-RW5GSSAA.cjs.map +1 -0
  41. package/dist/chunk-RZWMOCW3.cjs +2 -0
  42. package/dist/chunk-RZWMOCW3.cjs.map +1 -0
  43. package/dist/chunk-SAEKBZGF.cjs +2 -0
  44. package/dist/chunk-SAEKBZGF.cjs.map +1 -0
  45. package/dist/chunk-T462ONFX.cjs +2 -0
  46. package/dist/chunk-T462ONFX.cjs.map +1 -0
  47. package/dist/chunk-TD7ADMVO.cjs +2 -0
  48. package/dist/chunk-TD7ADMVO.cjs.map +1 -0
  49. package/dist/chunk-UBUNHRCG.cjs +2 -0
  50. package/dist/chunk-UBUNHRCG.cjs.map +1 -0
  51. package/dist/chunk-UEGX6GZ2.cjs +2 -0
  52. package/dist/chunk-UEGX6GZ2.cjs.map +1 -0
  53. package/dist/chunk-VCWGXJ2H.cjs +9 -0
  54. package/dist/chunk-VCWGXJ2H.cjs.map +1 -0
  55. package/dist/chunk-ZUNVPK23.cjs +2 -0
  56. package/dist/chunk-ZUNVPK23.cjs.map +1 -0
  57. package/dist/chunk-ZVK4HIDF.cjs +6 -0
  58. package/dist/chunk-ZVK4HIDF.cjs.map +1 -0
  59. package/dist/impl-2GU6CYMY.cjs +2 -0
  60. package/dist/impl-2GU6CYMY.cjs.map +1 -0
  61. package/dist/impl-2OEHQTIR.cjs +2 -0
  62. package/dist/impl-2OEHQTIR.cjs.map +1 -0
  63. package/dist/impl-2QXJ3WST.cjs +9 -0
  64. package/dist/impl-2QXJ3WST.cjs.map +1 -0
  65. package/dist/impl-442H4ODN.cjs +7 -0
  66. package/dist/impl-442H4ODN.cjs.map +1 -0
  67. package/dist/impl-44QRPPUX.cjs +6 -0
  68. package/dist/impl-44QRPPUX.cjs.map +1 -0
  69. package/dist/impl-4DOGSDPC.cjs +2 -0
  70. package/dist/impl-4DOGSDPC.cjs.map +1 -0
  71. package/dist/impl-5J3MG42D.cjs +2 -0
  72. package/dist/impl-5J3MG42D.cjs.map +1 -0
  73. package/dist/impl-5YMSNFJU.cjs +2 -0
  74. package/dist/impl-5YMSNFJU.cjs.map +1 -0
  75. package/dist/impl-6TBKGA4Y.cjs +2 -0
  76. package/dist/impl-6TBKGA4Y.cjs.map +1 -0
  77. package/dist/impl-7VYQSZVO.cjs +2 -0
  78. package/dist/impl-7VYQSZVO.cjs.map +1 -0
  79. package/dist/impl-BB24LU3N.cjs +2 -0
  80. package/dist/impl-BB24LU3N.cjs.map +1 -0
  81. package/dist/impl-CWZ26FTN.cjs +2 -0
  82. package/dist/impl-CWZ26FTN.cjs.map +1 -0
  83. package/dist/impl-EFTKRWUA.cjs +2 -0
  84. package/dist/impl-EFTKRWUA.cjs.map +1 -0
  85. package/dist/impl-EJT3AX73.cjs +2 -0
  86. package/dist/impl-EJT3AX73.cjs.map +1 -0
  87. package/dist/impl-EKQ6ZNN3.cjs +2 -0
  88. package/dist/impl-EKQ6ZNN3.cjs.map +1 -0
  89. package/dist/impl-EV6T5UOK.cjs +6 -0
  90. package/dist/impl-EV6T5UOK.cjs.map +1 -0
  91. package/dist/impl-FPFUAY4Q.cjs +2 -0
  92. package/dist/impl-FPFUAY4Q.cjs.map +1 -0
  93. package/dist/impl-GDKUHX2J.cjs +2 -0
  94. package/dist/impl-GDKUHX2J.cjs.map +1 -0
  95. package/dist/impl-GXDABG5X.cjs +2 -0
  96. package/dist/impl-GXDABG5X.cjs.map +1 -0
  97. package/dist/impl-IG7QEF6D.cjs +2 -0
  98. package/dist/impl-IG7QEF6D.cjs.map +1 -0
  99. package/dist/impl-JQLYJA5L.cjs +2 -0
  100. package/dist/impl-JQLYJA5L.cjs.map +1 -0
  101. package/dist/impl-LPI3M7L3.cjs +6 -0
  102. package/dist/impl-LPI3M7L3.cjs.map +1 -0
  103. package/dist/impl-M7WMSIK4.cjs +4 -0
  104. package/dist/impl-M7WMSIK4.cjs.map +1 -0
  105. package/dist/impl-MRGZ5OLO.cjs +2 -0
  106. package/dist/impl-MRGZ5OLO.cjs.map +1 -0
  107. package/dist/impl-OI4UWRAU.cjs +12 -0
  108. package/dist/impl-OI4UWRAU.cjs.map +1 -0
  109. package/dist/impl-OX24YDRR.cjs +2 -0
  110. package/dist/impl-OX24YDRR.cjs.map +1 -0
  111. package/dist/impl-PFQKPCUL.cjs +2 -0
  112. package/dist/impl-PFQKPCUL.cjs.map +1 -0
  113. package/dist/impl-PXJZK6BV.cjs +2 -0
  114. package/dist/impl-PXJZK6BV.cjs.map +1 -0
  115. package/dist/impl-QOGUUIE6.cjs +2 -0
  116. package/dist/impl-QOGUUIE6.cjs.map +1 -0
  117. package/dist/impl-QR3LLBZL.cjs +2 -0
  118. package/dist/impl-QR3LLBZL.cjs.map +1 -0
  119. package/dist/impl-RODUB22E.cjs +2 -0
  120. package/dist/impl-RODUB22E.cjs.map +1 -0
  121. package/dist/impl-S56PHXGG.cjs +2 -0
  122. package/dist/impl-S56PHXGG.cjs.map +1 -0
  123. package/dist/impl-SDGCTSWN.cjs +2 -0
  124. package/dist/impl-SDGCTSWN.cjs.map +1 -0
  125. package/dist/impl-VEMQEG27.cjs +2 -0
  126. package/dist/impl-VEMQEG27.cjs.map +1 -0
  127. package/dist/impl-VFWBSWT5.cjs +2 -0
  128. package/dist/impl-VFWBSWT5.cjs.map +1 -0
  129. package/dist/impl-XRRNIJUK.cjs +2 -0
  130. package/dist/impl-XRRNIJUK.cjs.map +1 -0
  131. package/dist/impl-YA7HWMYB.cjs +2 -0
  132. package/dist/impl-YA7HWMYB.cjs.map +1 -0
  133. package/dist/impl-YOWRUVYG.cjs +2 -0
  134. package/dist/impl-YOWRUVYG.cjs.map +1 -0
  135. package/dist/impl-ZHZOMOST.cjs +2 -0
  136. package/dist/impl-ZHZOMOST.cjs.map +1 -0
  137. package/dist/index.cjs +5 -0
  138. package/dist/index.cjs.map +1 -0
  139. package/dist/index.d.cts +117658 -0
  140. package/package.json +67 -62
  141. package/dist/bin/bash-complete.js +0 -3
  142. package/dist/bin/cli.js +0 -2
  143. package/dist/bin/deprecated-command.js +0 -6
  144. package/dist/chunk-3KYYR6WM.js +0 -74
  145. package/dist/chunk-4W2NF2OS.js +0 -1
  146. package/dist/chunk-5SI3ACV3.js +0 -8
  147. package/dist/chunk-64RBCV3H.js +0 -93
  148. package/dist/chunk-AHYJJKNA.js +0 -1
  149. package/dist/chunk-APA5PR4U.js +0 -1
  150. package/dist/chunk-EZCJGIOS.js +0 -1
  151. package/dist/chunk-FXYTXR6R.js +0 -2
  152. package/dist/chunk-HMF46LB7.js +0 -1
  153. package/dist/chunk-HXMONGHM.js +0 -1
  154. package/dist/chunk-HXYCZ5UY.js +0 -3
  155. package/dist/chunk-MBAKYLJ3.js +0 -2830
  156. package/dist/chunk-OERYFLN2.js +0 -1
  157. package/dist/chunk-QQRMUEM7.js +0 -3
  158. package/dist/chunk-RBOBI6B6.js +0 -5
  159. package/dist/chunk-SVDDU4R6.js +0 -1
  160. package/dist/chunk-T2PLXAEM.js +0 -1
  161. package/dist/chunk-TD5AG6IF.js +0 -1
  162. package/dist/chunk-UPHD5UAO.js +0 -1
  163. package/dist/chunk-UVJSNZM5.js +0 -1
  164. package/dist/chunk-W6GUOMVP.js +0 -1
  165. package/dist/chunk-XMGVDVM2.js +0 -1
  166. package/dist/chunk-XQTNSPJ3.js +0 -11
  167. package/dist/chunk-ZB5DNAF3.js +0 -1
  168. package/dist/impl-2AQG2DEN.js +0 -1
  169. package/dist/impl-2CT4WQB5.js +0 -1
  170. package/dist/impl-4KGHP2BC.js +0 -1
  171. package/dist/impl-75Y3OM5Z.js +0 -1
  172. package/dist/impl-AKN4Q3ON.js +0 -1
  173. package/dist/impl-B45RAXAK.js +0 -1
  174. package/dist/impl-C4HUZZJO.js +0 -5
  175. package/dist/impl-DHTPY5AB.js +0 -1
  176. package/dist/impl-FCRKJBOS.js +0 -11
  177. package/dist/impl-GUEUJOOC.js +0 -1
  178. package/dist/impl-H57BW5MO.js +0 -1
  179. package/dist/impl-HCNN3NZK.js +0 -1
  180. package/dist/impl-IME3ONWF.js +0 -1
  181. package/dist/impl-L3UJQJZ6.js +0 -1
  182. package/dist/impl-LC3UNIDE.js +0 -1
  183. package/dist/impl-LEZFRF7Y.js +0 -1
  184. package/dist/impl-LJLXQ3QL.js +0 -1
  185. package/dist/impl-MZ6D4BQ3.js +0 -1
  186. package/dist/impl-NKKIQKJ6.js +0 -1
  187. package/dist/impl-NYB4YSNU.js +0 -1
  188. package/dist/impl-OQFT2DYM.js +0 -1
  189. package/dist/impl-OQUKAZLQ.js +0 -6
  190. package/dist/impl-P63ATAHR.js +0 -1
  191. package/dist/impl-PATZGQVZ.js +0 -1
  192. package/dist/impl-PWZF46AT.js +0 -8
  193. package/dist/impl-QD62F5PJ.js +0 -1
  194. package/dist/impl-S5PLONJN.js +0 -1
  195. package/dist/impl-SBN3KA7O.js +0 -5
  196. package/dist/impl-T4ODLBML.js +0 -1
  197. package/dist/impl-TG65PIBJ.js +0 -3
  198. package/dist/impl-UQR3O4M3.js +0 -1
  199. package/dist/impl-V5KJW35Z.js +0 -1
  200. package/dist/impl-WLQF5X2U.js +0 -5
  201. package/dist/impl-X6FJHMP5.js +0 -1
  202. package/dist/impl-XRYV4FW7.js +0 -1
  203. package/dist/impl-YFDEKBXT.js +0 -1
  204. package/dist/impl-YQW4KNXL.js +0 -1
  205. package/dist/impl-YWNLYZI4.js +0 -1
  206. package/dist/impl-ZBLHGXKD.js +0 -1
  207. package/dist/index.js +0 -4
@@ -1 +0,0 @@
1
- import r from"colors";import{bootstrap as t}from"global-agent";import{ProxyAgent as e,setGlobalDispatcher as s}from"undici";import p from"yargs-parser";var i=console,{httpProxy:o=process.env.http_proxy}=p(process.argv.slice(2));o&&(i.info(r.green(`Initializing proxy: ${o}`)),process.env.GLOBAL_AGENT_HTTP_PROXY=o,t(),s(new e(o)));export{i as a};
@@ -1,3 +0,0 @@
1
- import{ea as o}from"./chunk-HMF46LB7.js";import{decodeCodec as c}from"@transcend-io/type-utils";import l from"js-yaml";import{readFileSync as m,writeFileSync as d}from"fs";var s=/<<parameters\.(.+?)>>/,i="parameters";function u(e,t,a=""){let r=e;if(Object.entries(t).forEach(([n,p])=>{r=r.split(`<<${i}.${n}>>`).join(p)}),s.test(r)){let[,n]=s.exec(r)||[];throw new Error(`Found variable that was not set: ${n}.
2
- Make sure you are passing all parameters through the --${i}=${n}:value-for-param flag.
3
- ${a}`)}return r}function b(e,t={}){let a=m(e,"utf-8"),r=u(a,t,`Also check that there are no extra variables defined in your yaml: ${e}`);return c(o,l.load(r))}function h(e,t){d(e,l.dump(c(o,t)))}export{s as a,i as b,u as c,b as d,h as e};
@@ -1,5 +0,0 @@
1
- import*as u from"fast-csv";import{createWriteStream as f,writeFileSync as j,appendFileSync as v}from"fs";function m(n){return n.includes('"')||n.includes(",")||n.includes(`
2
- `)?`"${n.replace(/"/g,'""')}"`:n}function d(n,t,i){let r=[];r.push(i),r.push(...t.map(e=>Object.values(e)));let s=r.map(e=>e.map(m).join(",")).join(`
3
- `);j(n,s)}function C(n,t){let r=t.map(s=>Object.values(s)).map(s=>s.map(m).join(",")).join(`
4
- `);v(n,`
5
- ${r}`)}async function p(n,t,i=!0){let r=f(n);await new Promise((s,e)=>{try{u.write(t,{headers:i,objectMode:!0}).pipe(r).on("error",e).on("end",()=>s(!0))}catch(c){e(c)}})}function x(n){let t=n.lastIndexOf(".");return{baseName:t!==-1?n.substring(0,t):n,extension:t!==-1?n.substring(t):".csv"}}async function O(n,t,i=!0,r=1e5){if(t.length<=r)return await p(n,t,i),[n];let s=[],e=Math.ceil(t.length/r),{baseName:c,extension:b}=x(n);for(let o=0;o<e;o+=1){let a=o*r,l=Math.min(a+r,t.length),w=t.slice(a,l),y=String(o+1).padStart(String(e).length,"0"),g=`${c}_part${y}_of_${e}${b}`;await p(g,w,i),s.push(g)}return s}export{d as a,C as b,p as c,x as d,O as e};
@@ -1 +0,0 @@
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-MBAKYLJ3.js";import{a as u}from"./chunk-OERYFLN2.js";import{e as C}from"./chunk-APA5PR4U.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{parse as ir}from"csv-parse/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";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 +0,0 @@
1
- function o(s){let e=s.split(",").filter(r=>!!r),t={};return e.forEach(r=>{let[i,n]=r.split(":");if(!i||!n)throw new Error(`Invalid variable: ${r}. Expected format: key:value`);t[i]=n}),t}export{o as a};
@@ -1 +0,0 @@
1
- import{fa as p}from"./chunk-HMF46LB7.js";import{Fe as h,Ge as z,Ie as $,Je as w,a as y,oe as u,zc as A}from"./chunk-MBAKYLJ3.js";import{a as i}from"./chunk-OERYFLN2.js";import{e as S}from"./chunk-APA5PR4U.js";import n from"colors";async function H({email:r,password:a,scopes:f,apiKeyTitle:t,parentOrganizationId:o,deleteExistingApiKey:l=!0,createNewApiKey:x=!0,transcendUrl:k=S}){let s=await u(k,{});i.info(n.magenta("Logging in using email and password."));let{roles:d,loginCookie:P}=await h(s,{email:r,password:a});i.info(n.green(`Successfully logged in and found ${d.length} role${d.length===1?"":"s"}!`));let K=o?d.filter(e=>e.organization.id===o||e.organization.parentOrganizationId===o):d;s.setHeaders({Cookie:P});let m=[],c=[];return i.info(n.magenta(`Generating API keys with title: ${t}, scopes: ${f.join(",")}.`)),await y(K,async e=>{try{await z(s,{roleId:e.id,email:r}),i.info(n.magenta(`Checking if API key already exists in organization "${e.organization.name}" with title: "${t}".`));let[g]=await A(s,[t]);if(g&&l)i.info(n.yellow(`Deleting existing API key in "${e.organization.name}" with title: "${t}".`)),await w(s,g.id),i.info(n.green(`Successfully deleted API key in "${e.organization.name}" with title: "${t}".`));else if(g)throw new Error(`API key already exists with title: "${t}"`);if(x){i.info(n.magenta(`Creating API key in "${e.organization.name}" with title: "${t}".`));let{apiKey:N}=await $(s,{title:t,scopes:f});m.push({organizationName:e.organization.name,organizationId:e.organization.id,apiKey:N}),i.info(n.green(`Successfully created API key in "${e.organization.name}" with title: "${t}".`))}else m.push({organizationName:e.organization.name,organizationId:e.organization.id,apiKey:""})}catch(g){i.error(n.red(`Failed to create API key in organization "${e.organization.name}"! - ${g.message}`)),c.push({organizationName:e.organization.name,organizationId:e.organization.id,error:g.message})}}),i.info(n.green(`Successfully created ${m.length} API key${m.length===1?"":"s"}`)),c.length>0&&i.error(n.red(`Failed to create ${c.length} API key${c.length===1?"":"s"}!`)),{errors:c,apiKeys:m}}import{decodeCodec as C}from"@transcend-io/type-utils";import E from"colors";import*as I from"io-ts";import{existsSync as G,readFileSync as D}from"fs";function T(r){return r||(i.error(E.red("A Transcend API key must be provided. You can specify using --auth=$TRANSCEND_API_KEY")),process.exit(1)),G(r)?C(I.array(p),D(r,"utf-8")):r}import{existsSync as F,readdirSync as b}from"fs";function Z(r,a,f=!1){if(!F(r))return[];let t=b(r).filter(o=>a?a.filter(l=>o.endsWith(l)).length:!0).filter(o=>o.indexOf(".")>0);return f?t.map(o=>o.replace(/\.[^/.]+$/,"")):t}import{readdirSync as R,statSync as _}from"fs";import{join as L}from"path";function te(r){return R(r).filter(a=>_(L(r,a)).isDirectory())}export{H as a,T as b,Z as c,te as d};
@@ -1 +0,0 @@
1
- import{Ee as N,b}from"./chunk-MBAKYLJ3.js";import{a}from"./chunk-OERYFLN2.js";import{f as U}from"./chunk-APA5PR4U.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 +0,0 @@
1
- import{k as i}from"./chunk-SVDDU4R6.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 +0,0 @@
1
- import{e as o}from"./chunk-EZCJGIOS.js";import*as e from"io-ts";import{valuesOf as a}from"@transcend-io/type-utils";var d=({TRouteName:t})=>e.type({routeName:t,enabledPolicies:e.array(a(o))});import*as r from"io-ts";var l=({TEnabledRoutes:t})=>r.type({enabledRoutes:t});export{d as a,l as b};
@@ -1 +0,0 @@
1
- import t from"fs";import e from"os";import r from"path";function p(o){return{process:o,os:e,fs:t,path:r}}export{p as a};
@@ -1,11 +0,0 @@
1
- import{c as x}from"./chunk-UPHD5UAO.js";import{n as u,q as D}from"./chunk-SVDDU4R6.js";import{ga as w,ha as _}from"./chunk-HMF46LB7.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-MBAKYLJ3.js";import{a as c}from"./chunk-OERYFLN2.js";import{e as C}from"./chunk-APA5PR4U.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
- <!DOCTYPE html>
3
- <script
4
- src="${i}"
5
- data-sync-groups='${JSON.stringify(s,null,2)}'
6
- data-xdi-commands="${n}"
7
- ></script>
8
- `,syncGroups:s}}function Yt(e){let i=e.map(({name:o,input:t})=>({title:o.replace(".yml",""),attributes:[...t?.domains?[{key:"Transcend Domain List",values:[...new Set(t.domains)]}]:[],...t?.bundleUrls?[{key:"Airgap Production URL",values:[t.bundleUrls.PRODUCTION]},{key:"Airgap Test URL",values:[t.bundleUrls.TEST]},{key:"Airgap XDI URL",values:[t.bundleUrls.PRODUCTION.replace("airgap.js","xdi.js")]}]:[],...t?.partition?[{key:"Consent Partition Key",values:[t.partition]}]:[]]}));return c.info(`
9
-
10
- ~~~~~~~~~~~
11
- Airgap scripts to host:`),i.forEach(({attributes:o,title:t},r)=>{o?.find(n=>n.key==="Airgap Production URL")?.values?.forEach(n=>{c.info(`${r}) ${t} - ${n}`)})}),i}import*as p from"io-ts";import{decodeCodec as Z}from"@transcend-io/type-utils";var tt=p.intersection([p.type({nodes:p.array(x)}),p.partial({lastKey:p.partial({userId:p.string,partition:p.string,timestamp:p.string})})]);async function zt(e,{partition:i,filterBy:o={},limit:t=50}){let r,n=[],a=!0;for(;a;){let l=await e.post("v1/consent-preferences",{json:{partition:i,...o,startKey:r||void 0,limit:t}}).json(),{nodes:s,lastKey:d}=Z(tt,l);if(!s||s.length===0)break;n.push(...s),r=d,a=!!d&&Object.keys(d).length>0}return n}export{at as a,Ct as b,vt as c,Lt as d,$ as e,J as f,Ht as g,Yt as h,tt as i,zt as j};
@@ -1 +0,0 @@
1
- import{union as c}from"lodash-es";function f(l,{adTechPurposes:p=["SaleOfInfo"],serviceToTitle:s,serviceToSupportedIntegration:r}){let e=[],i=[],n={};l.forEach(t=>{let{service:a,attributes:h=[]}=t;if(!a||a==="internalService")return;let u=h.find(o=>o.key==="Found on Domain");u&&(n[a]||(n[a]=[]),n[a].push(...u.values.map(o=>o.replace("https://","").replace("http://",""))),n[a]=[...new Set(n[a])]),c(t.trackingPurposes,p).length>0?(i.push(a),e.includes(a)&&(e=e.filter(o=>o!==a))):i.includes(a)||e.push(a)});let m=[...new Set(i)].map(t=>({title:s[t],...r[t]?{integrationName:t}:{integrationName:"promptAPerson","outer-type":t},attributes:[{key:"Tech Type",values:["Ad Tech"]},{key:"Found On Domain",values:n[t]||[]}]}));return{siteTechDataSilos:[...new Set(e)].map(t=>({title:s[t],...r[t]?{integrationName:t}:{integrationName:"promptAPerson",outerType:t},attributes:[{key:"Tech Type",values:["Site Tech"]},{key:"Found On Domain",values:n[t]||[]}]})),adTechDataSilos:m}}export{f as a};
@@ -1 +0,0 @@
1
- import{S as r}from"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function m({auth:n,enricherId:s,actions:i,requestEnricherStatuses:a,requestIds:c,createdAtBefore:e,createdAtAfter:t,concurrency:o,transcendUrl:u}){await r({auth:n,enricherId:s,requestActions:i,requestEnricherStatuses:a,requestIds:c,createdAtBefore:e?new Date(e):void 0,createdAtAfter:t?new Date(t):void 0,concurrency:o,transcendUrl:u})}export{m as enricherRestart};
@@ -1 +0,0 @@
1
- import{L as a}from"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function m({auth:s,actions:o,statuses:r=[],requestIds:c,silentModeBefore:e,createdAtBefore:t,createdAtAfter:n,cancellationTitle:i,transcendUrl:u,concurrency:d}){await a({transcendUrl:u,requestActions:o,auth:s,cancellationTitle:i,requestIds:c,statuses:r,concurrency:d,silentModeBefore:e?new Date(e):void 0,createdAtBefore:t?new Date(t):void 0,createdAtAfter:n?new Date(n):void 0})}export{m as cancel};
@@ -1 +0,0 @@
1
- import{b as m}from"./chunk-TD5AG6IF.js";import{a as t}from"./chunk-XQTNSPJ3.js";import"./chunk-UPHD5UAO.js";import"./chunk-SVDDU4R6.js";import"./chunk-HMF46LB7.js";import"./chunk-W6GUOMVP.js";import{a as g}from"./chunk-MBAKYLJ3.js";import{a as n}from"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import a from"colors";import{ConsentBundleType as p}from"@transcend-io/privacy-types";async function M({auth:f,bundleTypes:r=[p.Production,p.Test],deploy:i,transcendUrl:s}){let e=await m(f);typeof e=="string"?(await t({deploy:i,transcendUrl:s,auth:e,bundleTypes:r}),n.info(a.green("Successfully updated Consent Manager!"))):(await g(e,async o=>{n.info(a.magenta(`Updating Consent Manager for organization "${o.organizationName}"...`)),await t({deploy:i,transcendUrl:s,auth:o.apiKey,bundleTypes:r}),n.info(a.green(`Successfully updated Consent Manager for organization "${o.organizationName}"!`))}),n.info(a.green("Successfully updated Consent Managers!")))}export{M as updateConsentManager};
@@ -1 +0,0 @@
1
- import{t}from"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function u({auth:e,transcendUrl:r,actions:a,statuses:n,requestIds:s,createdAtBefore:o,createdAtAfter:i,concurrency:c}){await t({transcendUrl:r,requestActions:a,auth:e,requestIds:s,statuses:n,concurrency:c,createdAtBefore:o,createdAtAfter:i})}export{u as markSilent};
@@ -1 +0,0 @@
1
- import{b as r}from"./chunk-TD5AG6IF.js";import{g as t}from"./chunk-XQTNSPJ3.js";import"./chunk-UPHD5UAO.js";import"./chunk-SVDDU4R6.js";import"./chunk-HMF46LB7.js";import"./chunk-W6GUOMVP.js";import"./chunk-MBAKYLJ3.js";import{a as n}from"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import e from"colors";import{writeFileSync as g}from"fs";async function C({auth:d,xdiLocation:s,file:i,removeIpAddresses:c,domainBlockList:o,xdiAllowedCommands:l,transcendUrl:a}){let m=await r(d),{syncGroups:p,html:f}=await t(m,{xdiLocation:s,transcendUrl:a,removeIpAddresses:c,domainBlockList:o.length>0?o:void 0,xdiAllowedCommands:l});n.info(e.green(`Successfully constructed sync endpoint for sync groups: ${JSON.stringify(p,null,2)}`)),g(i,f),n.info(e.green(`Wrote configuration to file "${i}"!`))}export{C as buildXdiSyncEndpoint};
@@ -1 +0,0 @@
1
- import{a as p}from"./chunk-ZB5DNAF3.js";import{d as c,e as l}from"./chunk-QQRMUEM7.js";import{c as d}from"./chunk-TD5AG6IF.js";import"./chunk-HMF46LB7.js";import"./chunk-W6GUOMVP.js";import{ne as m,pe as g}from"./chunk-MBAKYLJ3.js";import{a as o}from"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import{join as f}from"path";import e from"colors";import{existsSync as D,lstatSync as h}from"fs";async function M({auth:x,dataFlowsYmlFolder:r,dataSilosYmlFolder:t,ignoreYmls:S=[],transcendUrl:T}){r||(o.error(e.red("Missing required arg: --dataFlowsYmlFolder=./working/data-flows/")),process.exit(1)),(!D(r)||!h(r).isDirectory())&&(o.error(e.red(`Folder does not exist: "${r}"`)),process.exit(1)),t||(o.error(e.red("Missing required arg: --dataSilosYmlFolder=./working/data-silos/")),process.exit(1)),(!D(t)||!h(t).isDirectory())&&(o.error(e.red(`Folder does not exist: "${t}"`)),process.exit(1));let w=g(T,x),{serviceToTitle:u,serviceToSupportedIntegration:v}=await m(w);d(r).forEach(i=>{let{"data-flows":F=[]}=c(f(r,i)),{adTechDataSilos:s,siteTechDataSilos:a}=p(F,{serviceToSupportedIntegration:v,serviceToTitle:u}),n=[...s,...a];o.log(`Total Services: ${n.length}`),o.log(`Ad Tech Services: ${s.length}`),o.log(`Site Tech Services: ${a.length}`),l(f(t,i),{"data-silos":S.includes(i)?[]:n})})}export{M as deriveDataSilosFromDataFlows};
@@ -1,5 +0,0 @@
1
- import{a as S}from"./chunk-AHYJJKNA.js";import{a as A}from"./chunk-T2PLXAEM.js";import{d as b}from"./chunk-QQRMUEM7.js";import{b as v,c as C}from"./chunk-TD5AG6IF.js";import"./chunk-HMF46LB7.js";import"./chunk-W6GUOMVP.js";import{Nd as x,a as w,pe as T}from"./chunk-MBAKYLJ3.js";import{a as n}from"./chunk-OERYFLN2.js";import{c as d}from"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import{existsSync as z,lstatSync as F}from"fs";import{join as L}from"path";import o from"colors";async function I({transcendUrl:i,auth:c,pageSize:h,publishToPrivacyCenter:y,contents:l,deleteExtraAttributeValues:m=!1,classifyService:f=!1}){let u=T(i,c);try{return!await x(l,u,{pageSize:h,publishToPrivacyCenter:y,classifyService:f,deleteExtraAttributeValues:m})}catch(t){return n.error(o.red(`An unexpected error occurred syncing the schema: ${t.message}`)),!1}}async function H({file:i="./transcend.yml",transcendUrl:c,auth:h,variables:y,pageSize:l,publishToPrivacyCenter:m,classifyService:f,deleteExtraAttributeValues:u}){let t=await v(h),N=A(y),p;if(Array.isArray(t)&&F(i).isDirectory()?p=C(i).map(e=>L(i,e)):p=i.split(","),p.length<1)throw new Error("No file specified!");let s=p.map(e=>{z(e)?n.info(o.magenta(`Reading file "${e}"...`)):(n.error(o.red(`The file path does not exist on disk: ${e}. You can specify the filepath using --file=./examples/transcend.yml`)),process.exit(1));try{let r=b(e,N);return n.info(o.green(`Successfully read in "${e}"`)),{content:r,name:e.split("/").pop().replace(".yml","")}}catch(r){n.error(o.red(`The shape of your yaml file is invalid with the following errors: ${r.message}`)),process.exit(1)}});if(typeof t=="string"){let[e,...r]=s.map(({content:g})=>g),$=S(e,...r);await I({transcendUrl:c,auth:t,contents:$,publishToPrivacyCenter:m,deleteExtraAttributeValues:u,pageSize:l,classifyService:!!f})||(n.info(o.red(`Sync encountered errors. View output above for more information, or check out ${d}`)),process.exit(1))}else{if(s.length!==1&&s.length!==t.length)throw new Error(`Expected list of yml files to be equal to the list of API keys.Got ${s.length} YML file${s.length===1?"":"s"} and ${t.length} API key${t.length===1?"":"s"}`);let e=[];await w(t,async(r,$)=>{let a=`[${$+1}/${t.length}][${r.organizationName}] `;n.info(o.magenta(`~~~
2
-
3
- ${a}Attempting to push configuration...
4
-
5
- ~~~`));let g=s.length===1?s[0].content:s.find(E=>E.name===r.organizationName)?.content;if(!g){n.error(o.red(`${a}Failed to find transcend.yml file for organization: "${r.organizationName}".`)),e.push(r.organizationName);return}await I({transcendUrl:c,auth:r.apiKey,contents:g,pageSize:l,publishToPrivacyCenter:m,deleteExtraAttributeValues:u,classifyService:f})?n.info(o.green(`${a}Successfully pushed configuration!`)):(n.error(o.red(`${a}Failed to sync configuration.`)),e.push(r.organizationName))}),e.length>0&&(n.info(o.red(`Sync encountered errors for "${e.join(",")}". View output above for more information, or check out ${d}`)),process.exit(1))}n.info(o.green(`Successfully synced yaml file to Transcend! View at ${d}`))}export{H as push};
@@ -1 +0,0 @@
1
- import{W as e}from"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function s({auth:t,transcendUrl:i,identifierNames:n,actions:r=[]}){await e({requestActions:r,transcendUrl:i,auth:t,identifierNames:n})}export{s as rejectUnverifiedIdentifiers};
@@ -1,11 +0,0 @@
1
- import{a as Q}from"./chunk-UVJSNZM5.js";import"./chunk-T2PLXAEM.js";import{n as F,p as X,q as Z}from"./chunk-SVDDU4R6.js";import"./chunk-W6GUOMVP.js";import{Qc as H,_d as ee,a as A,b as V,pe as te,qe as re}from"./chunk-MBAKYLJ3.js";import{a as l}from"./chunk-OERYFLN2.js";import{f as oe}from"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import v from"colors";import k from"colors";import{chunk as Qe}from"lodash-es";import ye from"cli-progress";import{PersistedState as Ge}from"@transcend-io/persisted-state";import{keyBy as De}from"lodash-es";import*as x from"io-ts";import de from"colors";import{PreferenceQueryResponseItem as Ue}from"@transcend-io/privacy-types";import ne from"colors";import se from"cli-progress";import{chunk as ke}from"lodash-es";import{decodeCodec as Re}from"@transcend-io/type-utils";import*as T from"io-ts";var Me=T.intersection([T.type({nodes:T.array(Ue)}),T.partial({cursor:T.string})]),Ve=["ENOTFOUND","ETIMEDOUT","504 Gateway Time-out","Task timed out after"];async function ie(m,{identifiers:n,partitionKey:h,skipLogging:d=!1}){let s=[],u=ke(n,100),i=new Date().getTime(),t=new se.SingleBar({},se.Presets.shades_classic);d||t.start(n.length,0);let c=0;await V(u,async e=>{let a=0,g=3;for(;a<g;)try{let p=await m.post(`v1/preferences/${h}/query`,{json:{filter:{identifiers:e},limit:e.length}}).json(),w=Re(Me,p);s.push(...w.nodes),c+=e.length,t.update(c);break}catch(p){a+=1;let w=p?.response?.body||p?.message||"";if(a>=g||!Ve.some(P=>w.includes(P)))throw new Error(`Received an error from server after ${a} attempts: ${w}`);l.warn(ne.yellow(`[RETRYING FAILED REQUEST - Attempt ${a}] Failed to fetch ${e.length} user preferences from partition ${h}: ${w}`))}},{concurrency:40}),t.stop();let r=new Date().getTime()-i;return d||l.info(ne.green(`Completed download in "${r/1e3}" seconds.`)),s}import{PreferenceTopicType as G}from"@transcend-io/privacy-types";import{apply as Fe}from"@transcend-io/type-utils";function D({row:m,columnToPurposeName:n,purposeSlugs:h,preferenceTopics:d}){let s={};return Object.entries(n).forEach(([u,{purpose:i,preference:t,valueMapping:c}])=>{if(!h.includes(i))throw new Error(`Invalid purpose slug: ${i}, expected: ${h.join(", ")}`);if(t){let f=d.find(g=>g.slug===t&&g.purpose.trackingType===i);if(!f){let g=d.filter(p=>p.purpose.trackingType===i).map(p=>p.slug);throw new Error(`Invalid preference slug: ${t} for purpose: ${i}. Allowed preference slugs for purpose are: ${g.join(",")}`)}s[i]||(s[i]={preferences:[]}),s[i].preferences||(s[i].preferences=[]);let r=m[u],e=c[r],a=typeof e=="string"&&e.trim()||null;switch(f.type){case G.Boolean:if(typeof e!="boolean")throw new Error(`Invalid value for boolean preference: ${t}, expected boolean, got: ${r}`);s[i].preferences.push({topic:t,choice:{booleanValue:e}});break;case G.Select:if(typeof e!="string"&&e!==null)throw new Error(`Invalid value for select preference: ${t}, expected string or null, got: ${r}`);if(a&&!f.preferenceOptionValues.map(({slug:g})=>g).includes(a))throw new Error(`Invalid value for select preference: ${t}, expected one of: ${f.preferenceOptionValues.map(({slug:g})=>g).join(", ")}, got: ${r}`);s[i].preferences.push({topic:t,choice:{selectValue:a}});break;case G.MultiSelect:if(typeof r!="string")throw new Error(`Invalid value for multi select preference: ${t}, expected string, got: ${r}`);s[i].preferences.push({topic:t,choice:{selectValues:F(r).map(g=>{let p=c[g];if(typeof p!="string")throw new Error(`Invalid value for multi select preference: ${t}, expected one of: ${f.preferenceOptionValues.map(({slug:w})=>w).join(", ")}, got: ${g}`);return p}).sort((g,p)=>g.localeCompare(p))}});break;default:throw new Error(`Unknown preference type: ${f.type}`)}}else s[i]?s[i].enabled=c[m[u]]===!0:s[i]={enabled:c[m[u]]===!0}}),Fe(s,(u,i)=>{if(typeof u.enabled!="boolean")throw new Error(`No mapping provided for purpose.enabled=true/false value: ${i}`);return{...u,enabled:u.enabled}})}import{uniq as Se,difference as Ee}from"lodash-es";import ae from"colors";import Ie from"inquirer";var q="[NONE]";async function pe(m,n){let h=Se(m.map(s=>Object.keys(s)).flat()),d=Ee(h,[...n.identifierColumn?[n.identifierColumn]:[],...Object.keys(n.columnToPurposeName)]);if(!n.timestampColum){let{timestampName:s}=await Ie.prompt([{name:"timestampName",message:"Choose the column that will be used as the timestamp of last preference update",type:"list",default:d.find(u=>u.toLowerCase().includes("date"))||d.find(u=>u.toLowerCase().includes("time"))||d[0],choices:[...d,q]}]);n.timestampColum=s}if(l.info(ae.magenta(`Using timestamp column "${n.timestampColum}"`)),n.timestampColum!==q){let s=m.map((u,i)=>u[n.timestampColum]?null:[i]).filter(u=>!!u).flat();if(s.length>0)throw new Error(`The timestamp column "${n.timestampColum}" is missing a value for the following rows: ${s.join(`
2
- `)}`);l.info(ae.magenta(`The timestamp column "${n.timestampColum}" is present for all row`))}return n}import{uniq as Ne,groupBy as Oe,difference as xe}from"lodash-es";import N from"colors";import je from"inquirer";async function le(m,n){let h=Ne(m.map(t=>Object.keys(t)).flat()),d=xe(h,[...n.identifierColumn?[n.identifierColumn]:[],...Object.keys(n.columnToPurposeName)]);if(!n.identifierColumn){let{identifierName:t}=await je.prompt([{name:"identifierName",message:"Choose the column that will be used as the identifier to upload consent preferences by",type:"list",default:d.find(c=>c.toLowerCase().includes("email"))||d[0],choices:d}]);n.identifierColumn=t}l.info(N.magenta(`Using identifier column "${n.identifierColumn}"`));let s=m.map((t,c)=>t[n.identifierColumn]?null:[c]).filter(t=>!!t).flat();if(s.length>0){let t=`The identifier column "${n.identifierColumn}" is missing a value for the following rows: ${s.join(", ")}`;if(l.warn(N.yellow(t)),!await Q({message:"Would you like to skip rows missing an identifier?"}))throw new Error(t);let f=m.length;m=m.filter(r=>r[n.identifierColumn]),l.info(N.yellow(`Skipped ${f-m.length} rows missing an identifier`))}l.info(N.magenta(`The identifier column "${n.identifierColumn}" is present for all rows`));let u=Oe(m,n.identifierColumn),i=Object.entries(u).filter(([,t])=>t.length>1);if(i.length>0){let t=`The identifier column "${n.identifierColumn}" has duplicate values for the following rows: ${i.slice(0,10).map(([f,r])=>`${f} (${r.length})`).join(`
3
- `)}`;if(l.warn(N.yellow(t)),!await Q({message:"Would you like to automatically take the latest update?"}))throw new Error(t);m=Object.entries(u).map(([,f])=>f.sort((e,a)=>new Date(a[n.timestampColum]).getTime()-new Date(e[n.timestampColum]).getTime())[0]).filter(f=>f)}return{currentState:n,preferences:m}}import{uniq as ce,difference as Ae}from"lodash-es";import W from"colors";import O from"inquirer";import{PreferenceTopicType as _}from"@transcend-io/privacy-types";async function fe(m,n,{purposeSlugs:h,preferenceTopics:d,forceTriggerWorkflows:s}){let u=ce(m.map(c=>Object.keys(c)).flat()),i=Ae(u,[...n.identifierColumn?[n.identifierColumn]:[],...n.timestampColum?[n.timestampColum]:[]]);if(i.length===0){if(s)return n;throw new Error("No other columns to process")}let t=[...h,...d.map(c=>`${c.purpose.trackingType}->${c.slug}`)];return await A(i,async c=>{let f=ce(m.map(e=>e[c])),r=n.columnToPurposeName[c];if(r)l.info(W.magenta(`Column "${c}" is associated with purpose "${r.purpose}"`));else{let{purposeName:e}=await O.prompt([{name:"purposeName",message:`Choose the purpose that column ${c} is associated with`,type:"list",default:t.find(p=>p.startsWith(h[0])),choices:t}]),[a,g]=e.split("->");r={purpose:a,preference:g||null,valueMapping:{}}}await A(f,async e=>{if(r.valueMapping[e]!==void 0){l.info(W.magenta(`Value "${e}" is associated with purpose value "${r.valueMapping[e]}"`));return}if(r.preference===null){let{purposeValue:a}=await O.prompt([{name:"purposeValue",message:`Choose the purpose value for value "${e}" associated with purpose "${r.purpose}"`,type:"confirm",default:e!=="false"}]);r.valueMapping[e]=a}if(r.preference!==null){let a=d.find(p=>p.slug===r.preference);if(!a){l.error(W.red(`Preference topic "${r.preference}" not found`));return}let g=a.preferenceOptionValues.map(({slug:p})=>p);if(a.type===_.Boolean){let{preferenceValue:p}=await O.prompt([{name:"preferenceValue",message:`Choose the preference value for "${a.slug}" value "${e}" associated with purpose "${r.purpose}"`,type:"confirm",default:e!=="false"}]);r.valueMapping[e]=p;return}if(a.type===_.Select){let{preferenceValue:p}=await O.prompt([{name:"preferenceValue",message:`Choose the preference value for "${a.slug}" value "${e}" associated with purpose "${r.purpose}"`,type:"list",choices:g,default:g.find(w=>w===e)}]);r.valueMapping[e]=p;return}if(a.type===_.MultiSelect){let p=F(e);await A(p,async w=>{if(r.valueMapping[w]!==void 0)return;let{preferenceValue:P}=await O.prompt([{name:"preferenceValue",message:`Choose the preference value for "${a.slug}" value "${w}" associated with purpose "${r.purpose}"`,type:"list",choices:g,default:g.find(y=>y===w)}]);r.valueMapping[w]=P});return}throw new Error(`Unknown preference topic type: ${a.type}`)}}),n.columnToPurposeName[c]=r}),n}import{PreferenceTopicType as K}from"@transcend-io/privacy-types";function me({currentConsentRecord:m,pendingUpdates:n,preferenceTopics:h}){return Object.entries(n).every(([d,{preferences:s=[],enabled:u}])=>{let i=m.purposes.find(c=>c.purpose===d);return!!i&&i.enabled===u?s.every(({topic:c,choice:f})=>i.preferences&&i.preferences.find(r=>{if(r.topic!==c)return!1;let e=h.find(a=>a.slug===c&&a.purpose.trackingType===d);if(!e)throw new Error(`Could not find preference topic for ${c}`);switch(e.type){case K.Boolean:return r.choice.booleanValue===f.booleanValue;case K.Select:return r.choice.selectValue===f.selectValue;case K.MultiSelect:let a=(r.choice.selectValues||[]).sort(),g=(f.selectValues||[]).sort();return a.length===g.length&&a.every((p,w)=>p===g[w]);default:throw new Error(`Unknown preference topic type: ${e.type}`)}})):!1})}import{PreferenceTopicType as Y}from"@transcend-io/privacy-types";function ue({currentConsentRecord:m,pendingUpdates:n,preferenceTopics:h}){return!!Object.entries(n).find(([d,{preferences:s=[],enabled:u}])=>{let i=m.purposes.find(t=>t.purpose===d);return i?i.enabled!==u?!0:!!s.find(({topic:t,choice:c})=>{let f=(i.preferences||[]).find(e=>e.topic===t);if(!f)return!1;let r=h.find(e=>e.slug===t&&e.purpose.trackingType===d);if(!r)throw new Error(`Could not find preference topic for ${t}`);switch(r.type){case Y.Boolean:return f.choice.booleanValue!==c.booleanValue;case Y.Select:return f.choice.selectValue!==c.selectValue;case Y.MultiSelect:let e=(f.choice.selectValues||[]).sort(),a=(c.selectValues||[]).sort();return e.length!==a.length||!e.every((g,p)=>g===a[p]);default:throw new Error(`Unknown preference topic type: ${r.type}`)}}):!1})}async function ge({file:m,sombra:n,purposeSlugs:h,preferenceTopics:d,partitionKey:s,skipExistingRecordCheck:u,forceTriggerWorkflows:i},t){let c=new Date().getTime(),f=t.getValue("fileMetadata");l.info(de.magenta(`Reading in file: "${m}"`));let r=Z(m,x.record(x.string,x.string)),e={columnToPurposeName:{},pendingSafeUpdates:{},pendingConflictUpdates:{},skippedUpdates:{},...f[m]||{},lastFetchedAt:new Date().toISOString()};e=await pe(r,e),f[m]=e,await t.setValue(f,"fileMetadata");let a=await le(r,e);e=a.currentState,r=a.preferences,f[m]=e,await t.setValue(f,"fileMetadata"),e=await fe(r,e,{preferenceTopics:d,purposeSlugs:h,forceTriggerWorkflows:i}),f[m]=e,await t.setValue(f,"fileMetadata");let g=r.map(y=>y[e.identifierColumn]),p=u?[]:await ie(n,{identifiers:g.map(y=>({value:y})),partitionKey:s}),w=De(p,"userId");e.pendingConflictUpdates={},e.pendingSafeUpdates={},e.skippedUpdates={},r.forEach(y=>{let C=y[e.identifierColumn],S=D({row:y,columnToPurposeName:e.columnToPurposeName,preferenceTopics:d,purposeSlugs:h}),U=w[C];if(i&&!U)throw new Error(`No existing consent record found for user with id: ${C}.
4
- When 'forceTriggerWorkflows' is set all the user identifiers should contain a consent record`);if(U&&me({currentConsentRecord:U,pendingUpdates:S,preferenceTopics:d})&&!i){e.skippedUpdates[C]=y;return}if(U&&ue({currentConsentRecord:U,pendingUpdates:S,preferenceTopics:d})){e.pendingConflictUpdates[C]={row:y,record:U};return}e.pendingSafeUpdates[C]=y}),f[m]=e,await t.setValue(f,"fileMetadata");let P=new Date().getTime();l.info(de.green(`Successfully pre-processed file: "${m}" in ${(P-c)/1e3}s`))}import{PreferenceQueryResponseItem as qe,PreferenceUpdateItem as we}from"@transcend-io/privacy-types";import*as o from"io-ts";var Be=o.type({purpose:o.string,preference:o.union([o.string,o.null]),valueMapping:o.record(o.string,o.union([o.string,o.boolean,o.null]))}),Le=o.intersection([o.type({columnToPurposeName:o.record(o.string,Be),lastFetchedAt:o.string,pendingSafeUpdates:o.record(o.string,o.record(o.string,o.string)),pendingConflictUpdates:o.record(o.string,o.type({record:qe,row:o.record(o.string,o.string)})),skippedUpdates:o.record(o.string,o.record(o.string,o.string))}),o.partial({identifierColumn:o.string,timestampColum:o.string})]),he=o.type({fileMetadata:o.record(o.string,Le),failingUpdates:o.record(o.string,o.type({uploadedAt:o.string,error:o.string,update:we})),pendingUpdates:o.record(o.string,we)});import{apply as We}from"@transcend-io/type-utils";async function Pe({auth:m,sombraAuth:n,receiptFilepath:h,file:d,partition:s,isSilent:u=!0,dryRun:i=!1,skipWorkflowTriggers:t=!1,skipConflictUpdates:c=!1,skipExistingRecordCheck:f=!1,attributes:r=[],transcendUrl:e=oe,forceTriggerWorkflows:a=!1}){let g=X(r),p=new Ge(h,he,{fileMetadata:{},failingUpdates:{},pendingUpdates:{}}),w=p.getValue("failingUpdates"),P=p.getValue("pendingUpdates"),y=p.getValue("fileMetadata");l.info(k.magenta(`Restored cache, there are:
5
- ${Object.values(w).length} failing requests to be retried
6
- ${Object.values(P).length} pending requests to be processed
7
- The following files are stored in cache and will be used:
8
- ${Object.keys(y).map(b=>b).join(`
9
- `)}
10
- The following file will be processed: ${d}
11
- `));let C=te(e,m),[S,U,J]=await Promise.all([re(e,m,n),a?Promise.resolve([]):H(C),a?Promise.resolve([]):ee(C)]);await ge({file:d,purposeSlugs:U.map(b=>b.trackingType),preferenceTopics:J,sombra:S,partitionKey:s,skipExistingRecordCheck:f,forceTriggerWorkflows:a},p);let E={};y=p.getValue("fileMetadata");let R=y[d];if(l.info(k.magenta(`Found ${Object.entries(R.pendingSafeUpdates).length} safe updates in ${d}`)),l.info(k.magenta(`Found ${Object.entries(R.pendingConflictUpdates).length} conflict updates in ${d}`)),l.info(k.magenta(`Found ${Object.entries(R.skippedUpdates).length} skipped updates in ${d}`)),Object.entries({...R.pendingSafeUpdates,...c?{}:We(R.pendingConflictUpdates,({row:b})=>b)}).forEach(([b,$])=>{let j=R.timestampColum===q?new Date:new Date($[R.timestampColum]),M=D({row:$,columnToPurposeName:R.columnToPurposeName,preferenceTopics:J,purposeSlugs:U.map(I=>I.trackingType)});E[b]={userId:b,partition:s,timestamp:j.toISOString(),purposes:Object.entries(M).map(([I,ve])=>({...ve,purpose:I,workflowSettings:{attributes:g,isSilent:u,skipWorkflowTrigger:t}}))}}),await p.setValue(E,"pendingUpdates"),await p.setValue({},"failingUpdates"),i){l.info(k.green(`Dry run complete, exiting. ${Object.values(E).length} pending updates. Check file: ${h}`));return}l.info(k.magenta(`Uploading ${Object.values(E).length} preferences to partition: ${s}`));let Ce=new Date().getTime(),B=new ye.SingleBar({},ye.Presets.shades_classic),z=0,L=Object.entries(E),$e=Qe(L,t?100:10);B.start(L.length,0),await V($e,async b=>{try{await S.put("v1/preferences",{json:{records:b.map(([,$])=>$),skipWorkflowTriggers:t,forceTriggerWorkflows:a}}).json()}catch($){try{let M=JSON.parse($?.response?.body||"{}");M.error&&l.error(k.red(`Error: ${M.error}`))}catch{}l.error(k.red(`Failed to upload ${b.length} user preferences to partition ${s}: ${$?.response?.body||$?.message}`));let j=p.getValue("failingUpdates");b.forEach(([M,I])=>{j[M]={uploadedAt:new Date().toISOString(),update:I,error:$?.response?.body||$?.message||"Unknown error"}}),await p.setValue(j,"failingUpdates")}z+=b.length,B.update(z)},{concurrency:40}),B.stop();let Te=new Date().getTime()-Ce;l.info(k.green(`Successfully uploaded ${L.length} user preferences to partition ${s} in "${Te/1e3}" seconds!`))}import{readdirSync as _e}from"fs";import{basename as Ke,join as be}from"path";async function Sr({auth:m,partition:n,sombraAuth:h,consentUrl:d,file:s="",directory:u,dryRun:i,skipExistingRecordCheck:t,receiptFileDir:c,skipWorkflowTriggers:f,forceTriggerWorkflows:r,skipConflictUpdates:e,isSilent:a,attributes:g,concurrency:p}){u&&s&&(l.error(v.red("Cannot provide both a directory and a file. Please provide only one.")),process.exit(1)),!s&&!u&&(l.error(v.red("A file or directory must be provided. Please provide one using --file=./preferences.csv or --directory=./preferences")),process.exit(1));let w=[];if(u)try{let y=_e(u).filter(C=>C.endsWith(".csv"));y.length===0&&(l.error(v.red(`No CSV files found in directory: ${u}`)),process.exit(1)),w.push(...y.map(C=>be(u,C)))}catch(P){l.error(v.red(`Failed to read directory: ${u}`)),l.error(v.red(P.message)),process.exit(1)}else try{s.endsWith(".csv")||(l.error(v.red("File must be a CSV file")),process.exit(1)),w.push(s)}catch(P){l.error(v.red(`Failed to access file: ${s}`)),l.error(v.red(P.message)),process.exit(1)}l.info(v.green(`Processing ${w.length} consent preferences files for partition: ${n}`)),l.debug(`Files to process: ${w.join(", ")}`),t&&l.info(v.bgYellow(`Skipping existing record check: ${t}`)),await V(w,async P=>{let y=Ke(P).replace(".csv","");await Pe({receiptFilepath:be(c,`${y}-receipts.json`),auth:m,sombraAuth:h,file:P,partition:n,transcendUrl:d,skipConflictUpdates:e,skipWorkflowTriggers:f,skipExistingRecordCheck:t,isSilent:a,dryRun:i,attributes:F(g),forceTriggerWorkflows:r})},{concurrency:p})}export{Sr as uploadPreferences};
@@ -1 +0,0 @@
1
- import"./chunk-HXMONGHM.js";import{c as i}from"./chunk-RBOBI6B6.js";import{j as s}from"./chunk-XQTNSPJ3.js";import"./chunk-UPHD5UAO.js";import"./chunk-SVDDU4R6.js";import"./chunk-HMF46LB7.js";import"./chunk-W6GUOMVP.js";import{qe as o}from"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function h({auth:a,partition:m,sombraAuth:c,file:p,transcendUrl:f,timestampBefore:e,timestampAfter:r,identifiers:n=[],concurrency:l}){let g=await o(f,a,c),u=await s(g,{partition:m,filterBy:{...e?{timestampBefore:e.toISOString()}:{},...r?{timestampAfter:r.toISOString()}:{},...n.length>0?{identifiers:n}:{}},limit:l});i(p,u.map(t=>({...t,purposes:JSON.stringify(t.purposes),...t.purposes})))}export{h as pullConsentPreferences};
@@ -1 +0,0 @@
1
- import{f as s}from"./chunk-HXMONGHM.js";import"./chunk-RBOBI6B6.js";import{q as a}from"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import{a as o}from"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import l from"colors";import*as t from"io-ts";var p=t.type({"Request Id":t.string});async function R({auth:r,dataSiloId:i,file:e,transcendUrl:m}){o.info(l.magenta(`Reading "${e}" from disk`));let n=a(e,p);await s({requestIds:n.map(d=>d["Request Id"]),transcendUrl:m,auth:r,dataSiloId:i})}export{R as markRequestDataSilosCompleted};
@@ -1 +0,0 @@
1
- import{b as p}from"./chunk-HXYCZ5UY.js";import"./chunk-TD5AG6IF.js";import"./chunk-HMF46LB7.js";import"./chunk-W6GUOMVP.js";import{ke as c,pe as m}from"./chunk-MBAKYLJ3.js";import{a as r}from"./chunk-OERYFLN2.js";import{b as g}from"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import n from"colors";import{execSync as k}from"child_process";var l='A repository name must be provided. You can specify using --repositoryName=$REPO_NAME or by ensuring the command "git config --get remote.origin.url" returns the name of the repository';async function S({auth:d,scanPath:o,ignoreDirs:f,repositoryName:u,transcendUrl:y}){let e=u;if(!e)try{let t=k(`cd ${o} && git config --get remote.origin.url`).toString("utf-8").trim();[e]=t.includes("https:")?t.split("/").slice(3).join("/").split("."):(t.split(":").pop()||"").split("."),e||(r.error(n.red(l)),process.exit(1))}catch(a){r.error(n.red(`${l} - Got error: ${a.message}`)),process.exit(1)}let h=m(y,d),i=await p({scanPath:o,ignoreDirs:f,repositoryName:e});await c(h,i);let s=new URL(g);s.pathname="/code-scanning/code-packages",r.info(n.green(`Scan found ${i.length} packages at ${o}! View results at '${s.href}'`))}export{S as scanPackages};
@@ -1 +0,0 @@
1
- import{F as t}from"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import{RequestStatus as e}from"@transcend-io/privacy-types";async function f({auth:o,transcendUrl:a,folderPath:r,requestIds:n,statuses:s=[e.Approving,e.Downloadable],concurrency:i,createdAtBefore:l,createdAtAfter:d,approveAfterDownload:c}){await t({transcendUrl:a,auth:o,folderPath:r,requestIds:n,statuses:s,concurrency:i,createdAtBefore:l,createdAtAfter:d,approveAfterDownload:c})}export{f as downloadFiles};
@@ -1 +0,0 @@
1
- import"./chunk-HXMONGHM.js";import{c as s}from"./chunk-RBOBI6B6.js";import{U as r}from"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import{a as o}from"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import y from"colors";import{uniq as q}from"lodash-es";async function v({auth:n,transcendUrl:a,file:e,pageLimit:i,actions:m,sombraAuth:c,statuses:u,createdAtBefore:p,createdAtAfter:f,showTests:l}){let{requestsFormattedForCsv:t}=await r({transcendUrl:a,pageLimit:i,actions:m,statuses:u,auth:n,sombraAuth:c,createdAtBefore:p,createdAtAfter:f,isTest:l}),g=q(t.map(d=>Object.keys(d)).flat());s(e,t,g),o.info(y.green(`Successfully wrote ${t.length} requests to file "${e}"`))}export{v as _export};
@@ -1 +0,0 @@
1
- import{O as t,n as e}from"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function y({auth:o,file:i,transcendUrl:n,cacheFilepath:a,requestReceiptFolder:r,sombraAuth:s,concurrency:l,attributes:c,isTest:d,isSilent:p,skipSendingReceipt:u,emailIsVerified:m,skipFilterStep:b,dryRun:g,debug:C,defaultPhoneCountryCode:f}){await t({cacheFilepath:a,requestReceiptFolder:r,file:i,auth:o,sombraAuth:s,concurrency:l,transcendUrl:n,defaultPhoneCountryCode:f,attributes:e(c),debug:C,skipFilterStep:b,isSilent:p,skipSendingReceipt:u,emailIsVerified:m,isTest:d,dryRun:g})}export{y as upload};
@@ -1 +0,0 @@
1
- import{g as f}from"./chunk-HXMONGHM.js";import{c as l,d as m}from"./chunk-RBOBI6B6.js";import"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import{a as t}from"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import o from"colors";import{uniq as P}from"lodash-es";async function N({file:d,transcendUrl:u,auth:p,sombraAuth:g,dataSiloId:c,actions:v,pageLimit:r,skipRequestCount:n,chunkSize:e}){n&&t.info(o.yellow("Skipping request count as requested. This may help speed up the call.")),(Number.isNaN(e)||e<=0||e%r!==0)&&(t.error(o.red(`Invalid chunk size: "${e}". Must be a positive integer that is a multiple of ${r}.`)),process.exit(1));let{baseName:b,extension:C}=m(d),a=0;await f({transcendUrl:u,apiPageSize:r,savePageSize:e,onSave:i=>{let s=`${b}-${a}${C}`;t.info(o.blue(`Saving ${i.length} identifiers to file "${s}"`));let $=P(i.map(I=>Object.keys(I)).flat());return l(s,i,$),t.info(o.green(`Successfully wrote ${i.length} identifiers to file "${s}"`)),a+=1,Promise.resolve()},actions:v,auth:p,sombraAuth:g,dataSiloId:c,skipRequestCount:n})}export{N as pullIdentifiers};
@@ -1 +0,0 @@
1
- import{g as w}from"./chunk-HXMONGHM.js";import{c as d,d as c}from"./chunk-RBOBI6B6.js";import"./chunk-SVDDU4R6.js";import{Ke as v,b as h,pe as q}from"./chunk-MBAKYLJ3.js";import{a as t}from"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import i from"colors";import{uniq as u}from"lodash-es";async function W({file:n,fileTarget:a,transcendUrl:m,auth:p,sombraAuth:P,cronDataSiloId:S,targetDataSiloId:F,actions:x,skipRequestCount:g,pageLimit:l,chunkSize:s}){g&&t.info(i.yellow("Skipping request count as requested. This may help speed up the call.")),(Number.isNaN(s)||s<=0||s%l!==0)&&(t.error(i.red(`Invalid chunk size: "${s}". Must be a positive integer that is a multiple of ${l}.`)),process.exit(1));let N=q(m,p),{baseName:R,extension:T}=c(n),{baseName:j,extension:O}=c(a),$=0,b=0,f=0;await w({dataSiloId:S,auth:p,sombraAuth:P,actions:x,apiPageSize:l,savePageSize:s,onSave:async o=>{$+=o.length;let A=o.map(e=>e.requestId),D=u(A),y=await h(D,async e=>(await v(N,{requestId:e,dataSiloId:F})).map(({fileName:C,remoteId:I})=>{if(!I)throw new Error(`Failed to find remoteId for ${C} request: ${e}`);return{RecordId:I,Object:C.replace(".json","").split("/").pop()?.replace(" Information",""),Comment:"Customer data deletion request submitted via transcend.io"}}),{concurrency:10});b+=y.flat().length;let L=u(o.map(e=>Object.keys(e)).flat()),E=`${R}-${f}${T}`,G=`${j}-${f}${O}`;d(E,o,L),t.info(i.green(`Successfully wrote ${o.length} identifiers to file "${n}"`));let r=y.flat(),M=u(r.map(e=>Object.keys(e)).flat());d(G,r,M),t.info(i.green(`Successfully wrote ${r.length} identifiers to file "${a}"`)),t.info(i.blue(`Processed chunk of ${o.length} identifiers, found ${r.length} target identifiers`)),f+=1},transcendUrl:m,skipRequestCount:g}),t.info(i.green(`Successfully wrote ${$} identifiers to file "${n}"`)),t.info(i.green(`Successfully wrote ${b} identifiers to file "${a}"`))}export{W as pullProfiles};
@@ -1 +0,0 @@
1
- import{R as t}from"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function e({auth:i,transcendUrl:o,enricherIds:r}){await t({transcendUrl:o,auth:i,enricherIds:r})}export{e as skipPreflightJobs};
@@ -1 +0,0 @@
1
- import{J as t}from"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function f({auth:e,transcendUrl:i,createdAtBefore:n,createdAtAfter:o,actions:r,daysLeft:a,days:s,requestIds:m,emailTemplate:c,concurrency:d}){await t({transcendUrl:i,requestActions:r,auth:e,emailTemplate:c,days:s,daysLeft:a,requestIds:m,concurrency:d,createdAtBefore:n,createdAtAfter:o})}export{f as notifyAdditionalTime};
@@ -1 +0,0 @@
1
- import{e as c}from"./chunk-QQRMUEM7.js";import{ia as i}from"./chunk-HMF46LB7.js";import"./chunk-W6GUOMVP.js";import{a}from"./chunk-OERYFLN2.js";import"./chunk-EZCJGIOS.js";import*as p from"io-ts";import m from"colors";import{existsSync as u,readFileSync as g}from"fs";import{decodeCodec as d}from"@transcend-io/type-utils";import{ConsentTrackerStatus as l,DataFlowScope as C}from"@transcend-io/privacy-types";function P({file:e,output:n}){u(e)||(a.error(m.red(`File does not exist: --file="${e}"`)),process.exit(1));let f=d(p.array(i),g(e,"utf-8")),t=[],r=[];f.forEach(s=>{s.dataFlows.filter(({type:o})=>o!==C.CSP).forEach(o=>{t.push({value:o.value,type:o.type,status:l.Live,trackingPurposes:o.trackingPurposes})}),s.cookies.forEach(o=>{r.push({name:o.name,status:l.Live,trackingPurposes:o.trackingPurposes})})}),c(n,{"data-flows":t,cookies:r}),a.info(m.green(`Successfully wrote ${t.length} data flows and ${r.length} cookies to file "${n}"`))}export{P as consentManagerServiceJsonToYml};
@@ -1 +0,0 @@
1
- import{b as a}from"./chunk-XQTNSPJ3.js";import"./chunk-UPHD5UAO.js";import"./chunk-SVDDU4R6.js";import"./chunk-HMF46LB7.js";import"./chunk-W6GUOMVP.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function n({auth:o,trackerStatus:t,file:r,classifyService:s,transcendUrl:e}){await a({auth:o,trackerStatus:t,file:r,classifyService:s,transcendUrl:e})}export{n as uploadDataFlowsFromCsv};
@@ -1,6 +0,0 @@
1
- import{_b as L,a as N,b as R,ha as _,pe as D}from"./chunk-MBAKYLJ3.js";import{a}from"./chunk-OERYFLN2.js";import"./chunk-4W2NF2OS.js";import{b as U}from"./chunk-EZCJGIOS.js";import ge from"colors";import X from"got";var Q=({hostname:t,auth:e})=>X.extend({prefixUrl:`https://${t}`,headers:{accept:"application/json","content-type":"application/json",authorization:`Bearer ${e}`}});import Re from"colors";import xe from"yargs-parser";var Ge=Object.values(U);import te from"colors";import j from"fs";var w=({assessment:t,index:e,total:s,wrap:r=!0})=>{let n="";(e===0||r)&&(n=`[
2
- `);let m=JSON.stringify(t),o=s&&e<s-1&&!r?",":"";return n=`${n+m+o}
3
- `,(s&&e===s-1||r)&&(n+=`
4
- ]`),n};var B=({file:t,assessment:e,index:s,total:r})=>{a.info(te.magenta(`Writing enriched assessment ${s+1} of ${r} to file "${t}"...`)),s===0?j.writeFileSync(t,w({assessment:e,index:s,total:r,wrap:!1})):j.appendFileSync(t,w({assessment:e,index:s,total:r,wrap:!1}))};import P from"colors";import{decodeCodec as re}from"@transcend-io/type-utils";import{OneTrustGetListOfAssessmentsResponse as ne}from"@transcend-io/privacy-types";var q=async({oneTrust:t})=>{let e=0,s=1,r=0,n=[];for(;e<s;){let{body:m}=await t.get(`api/assessment/v2/assessments?page=${e}&size=2000`),{page:o,content:u}=re(ne,m);n.push(...u??[]),e===0&&(s=o?.totalPages??0,r=o?.totalElements??0),e+=1,a.info(`Fetched ${n.length} of ${r} assessments.`)}return n};import{decodeCodec as oe}from"@transcend-io/type-utils";import{OneTrustGetAssessmentResponse as ie}from"@transcend-io/privacy-types";var J=async({oneTrust:t,assessmentId:e})=>{let{body:s}=await t.get(`api/assessment/v2/assessments/${e}/export?ExcludeSkippedQuestions=false`);return oe(ie,s)};import{decodeCodec as ae}from"@transcend-io/type-utils";import{OneTrustGetRiskResponse as me}from"@transcend-io/privacy-types";var K=async({oneTrust:t,riskId:e})=>{let{body:s}=await t.get(`api/risk/v2/risks/${e}`);return ae(me,s)};import{decodeCodec as ce}from"@transcend-io/type-utils";import{OneTrustGetUserResponse as ue}from"@transcend-io/privacy-types";var b=async({oneTrust:t,userId:e})=>{let{body:s}=await t.get(`api/scim/v2/Users/${e}`);return ce(ue,s)};import{uniq as pe}from"lodash-es";import{keyBy as I}from"lodash-es";var W=({assessment:t,assessmentDetails:e,riskDetails:s,creatorDetails:r,approversDetails:n,respondentsDetails:m})=>{let o=I(s,"id"),{sections:u,createdBy:g,...h}=e,O=u.map(i=>{let{questions:A,...$}=i,x=A.map(E=>{let{risks:C,...G}=E,v=(C??[]).map(y=>{let S=o[y.riskId];return{...y,...S,level:y.level,impactLevel:y.impactLevel??0}});return{...G,risks:v}});return{...$,questions:x}}),p={...g,active:r?.active??!1,userType:r?.userType??"Internal",emails:r?.emails??[],title:r?.title??null,givenName:r?.name.givenName??null,familyName:r?.name.familyName??null},d=I(n,"id"),l=e.approvers.flatMap(i=>d[i.id]?[{...i,approver:{...i.approver,active:d[i.id].active,userType:d[i.id].userType,emails:d[i.id].emails,title:d[i.id].title,givenName:d[i.id].name.givenName??null,familyName:d[i.id].name.familyName??null}}]:[]),T=I(m,"id"),F=e.respondents.filter(i=>!i.name.includes("@")).flatMap(i=>T[i.id]?[{...i,active:T[i.id].active,userType:T[i.id].userType,emails:T[i.id].emails,title:T[i.id].title,givenName:T[i.id].name.givenName??null,familyName:T[i.id].name.familyName??null}]:[]);return{...t,...h,approvers:l,respondents:F,createdBy:p,sections:O}};import H from"colors";var k=async({transcend:t,assessment:e,total:s,index:r})=>{a.info(H.magenta(`Writing enriched assessment ${r+1} ${s?`of ${s} `:" "}to Transcend...`));let m={json:w({assessment:e,index:r,total:s})};try{await L(t,_,{input:m})}catch{a.error(H.red(`Failed to sync assessment ${r+1} ${s?`of ${s} `:" "}to Transcend.
5
- Assessment Title: ${e.name}. Template Title: ${e.template.name}
6
- `))}};var z=async({oneTrust:t,file:e,dryRun:s,transcend:r})=>{a.info("Getting list of all assessments from OneTrust...");let n=await q({oneTrust:t}),m={},o=5,u=Array.from({length:Math.ceil(n.length/o)},(g,h)=>n.slice(h*o,(h+1)*o));await N(u,async(g,h)=>{let O=[];await R(g,async(p,d)=>{let l=o*h+d+1;a.info(`[assessment ${l} of ${n.length}]: fetching details...`);let{templateName:T,assessmentId:F}=p,i=await J({oneTrust:t,assessmentId:F}),A=i.createdBy.id,$=m[A];if(!$){a.info(`[assessment ${l} of ${n.length}]: fetching creator...`);try{$=await b({oneTrust:t,userId:A}),m[A]=$}catch{a.warn(P.yellow(`[assessment ${l} of ${n.length}]: failed to fetch form creator. creatorId: ${A}. Assessment Title: ${p.name}. Template Title: ${T}`))}}let{approvers:x}=i,E=[];x.length>0&&(a.info(`[assessment ${l} of ${n.length}]: fetching approvers...`),E=await R(x.map(({id:c})=>c),async c=>{try{let f=m[c];return f||(f=await b({oneTrust:t,userId:c}),m[c]=f),[f]}catch{return a.warn(P.yellow(`[assessment ${l} of ${n.length}]: failed to fetch a form approver. approverId: ${c}. Assessment Title: ${p.name}. Template Title: ${T}`)),[]}},{concurrency:5}));let{respondents:C}=i,G=C.filter(c=>!c.name.includes("@")),v=[];G.length>0&&(a.info(`[assessment ${l} of ${n.length}]: fetching respondents...`),v=await R(G.map(({id:c})=>c),async c=>{try{let f=m[c];return f||(f=await b({oneTrust:t,userId:c}),m[c]=f),[f]}catch{return a.warn(P.yellow(`[assessment ${l} of ${n.length}]: failed to fetch a respondent. respondentId: ${c}. Assessment Title: ${p.name}. Template Title: ${T}`)),[]}},{concurrency:5}));let y=[],S=pe(i.sections.flatMap(c=>c.questions.flatMap(f=>(f.risks??[]).flatMap(Z=>Z.riskId))));S.length>0&&(a.info(`[assessment ${l} of ${n.length}]: fetching risks...`),y=await R(S,c=>K({oneTrust:t,riskId:c}),{concurrency:5}));let V=W({assessment:p,assessmentDetails:i,riskDetails:y,creatorDetails:$,approversDetails:E.flat(),respondentsDetails:v.flat()});O.push(V)},{concurrency:o}),await N(O,async(p,d)=>{let l=h*o+d;s&&e?B({assessment:p,index:l,total:n.length,file:e}):r&&await k({assessment:p,transcend:r,total:n.length,index:l})})})};import{decodeCodec as le}from"@transcend-io/type-utils";import M from"colors";import fe from"JSONStream";import{createReadStream as de}from"fs";import{OneTrustEnrichedAssessment as Te}from"@transcend-io/privacy-types";var Y=({transcend:t,file:e})=>(a.info(`Getting list of all assessments from file ${e}...`),new Promise((s,r)=>{let n=de(e,{encoding:"utf-8",highWaterMark:65536}),m=fe.parse("*"),o=0;n.pipe(m),m.on("data",async u=>{try{m.pause();let g=le(Te,u);await k({assessment:g,transcend:t,index:o}),o+=1,m.resume()}catch(g){a.error(M.red(`Failed to parse the assessment ${o} from file '${e}': ${g.message}.`))}}),m.on("end",()=>{a.info(`Finished processing ${o} assessments from file ${e}`),s()}),m.on("error",u=>{a.error(M.red(`Error parsing file '${e}': ${u.message}`)),r(u)}),n.on("error",u=>{a.error(M.red(`Error reading file '${e}': ${u.message}`)),r(u)})}));async function _s({hostname:t,oneTrustAuth:e,source:s,transcendAuth:r,transcendUrl:n,resource:m,file:o,dryRun:u,debug:g}){if(!u&&!r)throw new Error('Must specify a "transcendAuth" parameter to sync resources to Transcend. e.g. --transcendAuth=${TRANSCEND_API_KEY}');if(u&&!o)throw new Error('Must set a "file" parameter when "dryRun" is "true". e.g. --file=./oneTrustAssessments.json');if(o){let p=o.split(".");if(p.length<2)throw new Error('The "file" parameter has an invalid format. Expected a path with extensions. e.g. --file=./pathToFile.json.');if(p.at(-1)!=="json")throw new Error(`Expected the format of the "file" parameters '${o}' to be 'json', but got '${p.at(-1)}'.`)}if(s==="oneTrust"){if(!t)throw new Error('Missing required parameter "hostname". e.g. --hostname=customer.my.onetrust.com');if(!e)throw new Error('Missing required parameter "oneTrustAuth". e.g. --oneTrustAuth=$ONE_TRUST_AUTH_TOKEN')}else{if(!o)throw new Error('Must specify a "file" parameter to read the OneTrust assessments from. e.g. --source=./oneTrustAssessments.json');if(u)throw new Error('Cannot read and write to a file simultaneously. Emit the "source" parameter or set it to oneTrust if "dryRun" is enabled.')}let h=t&&e?Q({hostname:t,auth:e}):void 0,O=n&&r?D(n,r):void 0;try{m==="assessments"&&(s==="oneTrust"&&h?await z({oneTrust:h,file:o,dryRun:u,...O&&{transcend:O}}):s==="file"&&o&&O&&await Y({file:o,transcend:O}))}catch(p){throw new Error(`An error occurred syncing the resource ${m} from OneTrust: ${g?p.stack:p.message}`)}a.info(ge.green(`Successfully synced OneTrust ${m} to ${u?`disk at "${o}"`:"Transcend"}!`))}export{_s as syncOt};
@@ -1 +0,0 @@
1
- import{V as t}from"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function n({auth:s,dataSiloId:a,status:e,statuses:i,transcendUrl:o}){await t({transcendUrl:o,auth:s,status:e,dataSiloId:a,requestStatuses:i})}export{n as skipRequestDataSilos};
@@ -1 +0,0 @@
1
- import{I as e}from"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function m({auth:t,actions:r,origins:o,silentModeBefore:i,createdAtBefore:n,createdAtAfter:a,transcendUrl:s,concurrency:c}){await e({transcendUrl:s,requestActions:r,auth:t,requestOrigins:o,concurrency:c,silentModeBefore:i,createdAtBefore:n,createdAtAfter:a})}export{m as approve};
@@ -1,8 +0,0 @@
1
- import{b as O}from"./chunk-TD5AG6IF.js";import"./chunk-HXMONGHM.js";import{c as w}from"./chunk-RBOBI6B6.js";import{d as v}from"./chunk-XQTNSPJ3.js";import"./chunk-UPHD5UAO.js";import"./chunk-SVDDU4R6.js";import"./chunk-HMF46LB7.js";import"./chunk-W6GUOMVP.js";import{a as M,pe as y,sc as x}from"./chunk-MBAKYLJ3.js";import{a as t}from"./chunk-OERYFLN2.js";import{c as b}from"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import e from"colors";import{join as C}from"path";import E,{existsSync as j,mkdirSync as T}from"fs";async function q({auth:A,start:N,end:f,folder:r,bin:l,transcendUrl:g}){let c=await O(A);E.existsSync(r)&&!E.lstatSync(r).isDirectory()&&(t.error(e.red('The provided argument "folder" was passed a file. expected: folder="./consent-metrics/"')),process.exit(1));let p=l;Object.values(x).includes(p)||(t.error(e.red(`Failed to parse argument "bin" with value "${l}"
2
- Expected one of:
3
- ${Object.values(x).join(`
4
- `)}`)),process.exit(1));let i=new Date(N),o=f?new Date(f):new Date;if(Number.isNaN(i.getTime())&&(t.error(e.red(`Start date provided is invalid date. Got --start="${N}" expected --start="01/01/2023"`)),process.exit(1)),Number.isNaN(o.getTime())&&(t.error(e.red(`End date provided is invalid date. Got --end="${f}" expected --end="01/01/2023"`)),process.exit(1)),i>o&&(t.error(e.red(`Got a start date "${i.toISOString()}" that was larger than the end date "${o.toISOString()}". Start date must be before end date.`)),process.exit(1)),j(r)||T(r),t.info(e.magenta(`Pulling consent metrics from start=${i.toString()} to end=${o.toISOString()} with bin size "${l}"`)),console.log("apiKeyOrList",c,g),typeof c=="string"){try{let n=y(g,c),s=await v(n,{bin:p,start:i,end:o});Object.entries(s).forEach(([u,m])=>{m.forEach(({points:$,name:d})=>{let a=C(r,`${u}_${d}.csv`);t.info(e.magenta(`Writing configuration to file "${a}"...`)),w(a,$.map(({key:h,value:S})=>({timestamp:h,value:S})))})})}catch(n){t.error(e.red(`An error occurred syncing the schema: ${n.message}`)),process.exit(1)}t.info(e.green(`Successfully synced consent metrics to disk in folder "${r}"! View at ${b}`))}else{let n=[];await M(c,async(s,u)=>{let m=`[${u+1}/${c.length}][${s.organizationName}] `;t.info(e.magenta(`~~~
5
-
6
- ${m}Attempting to pull consent metrics...
7
-
8
- ~~~`));let $=y(g,s.apiKey);try{let d=await v($,{bin:p,start:i,end:o}),a=C(r,s.organizationName);j(a)||T(a),Object.entries(d).forEach(([h,S])=>{S.forEach(({points:I,name:F})=>{let D=C(a,`${h}_${F}.csv`);t.info(e.magenta(`Writing configuration to file "${D}"...`)),w(D,I.map(({key:G,value:L})=>({timestamp:G,value:L})))})}),t.info(e.green(`${m}Successfully pulled configuration!`))}catch{t.error(e.red(`${m}Failed to sync configuration.`)),n.push(s.organizationName)}}),n.length>0&&(t.info(e.red(`Sync encountered errors for "${n.join(",")}". View output above for more information, or check out ${b}`)),process.exit(1))}}export{q as pullConsentMetrics};
@@ -1 +0,0 @@
1
- import{T as t}from"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function i({auth:e,dataSiloId:a,actions:o,transcendUrl:s}){await t({requestActions:o,transcendUrl:s,auth:e,dataSiloId:a})}export{i as retryRequestDataSilos};
@@ -1 +0,0 @@
1
- import{a as t}from"./chunk-FXYTXR6R.js";import"./chunk-RBOBI6B6.js";import"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function c({auth:n,transcendUrl:e,file:i,concurrency:r,actions:o,sombraAuth:s}){await t({file:i,transcendUrl:e,concurrency:r,requestActions:o,auth:n,sombraAuth:s})}export{c as pullIdentifiers};
@@ -1,5 +0,0 @@
1
- import{e as l}from"./chunk-QQRMUEM7.js";import{h as R,i as b}from"./chunk-5SI3ACV3.js";import{b as N}from"./chunk-TD5AG6IF.js";import"./chunk-HMF46LB7.js";import"./chunk-W6GUOMVP.js";import{a as P,be as m,pe as u}from"./chunk-MBAKYLJ3.js";import{a as o}from"./chunk-OERYFLN2.js";import{c as f}from"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import{d as E}from"./chunk-EZCJGIOS.js";import n from"colors";import{join as k}from"path";import D from"fs";async function M({auth:x,resources:g=R,file:t,transcendUrl:p,dataSiloIds:d=[],integrationNames:T=[],trackerStatuses:y=b,pageSize:S,skipDatapoints:h,skipSubDatapoints:$,includeGuessedCategories:A,debug:a}){let i=await N(x),C=g.includes("all")?Object.values(E):g;if(typeof i=="string"){try{let r=u(p,i),e=await m(r,{dataSiloIds:d,integrationNames:T,resources:C,pageSize:S,debug:a,skipDatapoints:h,skipSubDatapoints:$,includeGuessedCategories:A,trackerStatuses:y});o.info(n.magenta(`Writing configuration to file "${t}"...`)),l(t,e)}catch(r){o.error(n.red(`An error occurred syncing the schema: ${a?r.stack:r.message}`)),process.exit(1)}o.info(n.green(`Successfully synced yaml file to disk at ${t}! View at ${f}`))}else{if(!D.lstatSync(t).isDirectory())throw new Error("File is expected to be a folder when passing in a list of API keys to pull from. e.g. --file=./working/");let r=[];await P(i,async(e,L)=>{let s=`[${L+1}/${i.length}][${e.organizationName}] `;o.info(n.magenta(`~~~
2
-
3
- ${s}Attempting to pull configuration...
4
-
5
- ~~~`));let _=u(p,e.apiKey);try{let c=await m(_,{dataSiloIds:d,integrationNames:T,resources:C,pageSize:S,debug:a,skipDatapoints:h,skipSubDatapoints:$,includeGuessedCategories:A,trackerStatuses:y}),w=k(t,`${e.organizationName}.yml`);o.info(n.magenta(`Writing configuration to file "${w}"...`)),l(w,c),o.info(n.green(`${s}Successfully pulled configuration!`))}catch(c){o.error(n.red(`${s}Failed to sync configuration. - ${c.message}`)),r.push(e.organizationName)}}),r.length>0&&(o.info(n.red(`Sync encountered errors for "${r.join(",")}". View output above for more information, or check out ${f}`)),process.exit(1))}}export{M as pull};
@@ -1 +0,0 @@
1
- import{Q as e}from"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function A({auth:t,requestReceiptFolder:s,sombraAuth:r,actions:a,statuses:o,requestIds:i,createdAt:n,emailIsVerified:c,silentModeBefore:u,sendEmailReceipt:d,copyIdentifiers:m,skipWaitingPeriod:l,createdAtBefore:p,createdAtAfter:f,concurrency:R,transcendUrl:q}){await e({requestReceiptFolder:s,auth:t,sombraAuth:r,requestActions:a,requestStatuses:o,requestIds:i,createdAt:n,emailIsVerified:c,silentModeBefore:u,sendEmailReceipt:d,copyIdentifiers:m,skipWaitingPeriod:l,createdAtBefore:p,createdAtAfter:f,concurrency:R,transcendUrl:q})}export{A as restart};
@@ -1,3 +0,0 @@
1
- import{a as D}from"./chunk-HXYCZ5UY.js";import"./chunk-TD5AG6IF.js";import"./chunk-HMF46LB7.js";import"./chunk-W6GUOMVP.js";import{Od as u,le as S,pe as y}from"./chunk-MBAKYLJ3.js";import{a as r}from"./chunk-OERYFLN2.js";import{b as h}from"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import{stringify as C}from"query-string";import w from"colors";import v from"fast-glob";async function m({scanPath:t,fileGlobs:e,ignoreDirs:g,config:p}){let{ignoreDirs:f,supportedFiles:s,scanFunction:a}=p,n=e===""?s:s.concat(e.split(",")),l=[...g.split(","),...f].filter(o=>o.length>0);try{let o=await v(`${t}/**/${n.join("|")}`,{ignore:l.map(i=>`${t}/**/${i}`),unique:!0,onlyFiles:!0});r.info(`Scanning: ${o.length} files`);let $=o.map(i=>a(i)).flat().map(i=>i.softwareDevelopmentKits||[]).flat(),d=[...new Set($.map(i=>i.name))];return r.info(`Found: ${d.length} unique dependencies`),d.map(i=>({name:i,resourceId:`${t}/**/${i}`,useStrictClassifier:!0}))}catch(o){throw new Error(`Error scanning globs ${m} with error: ${o}`)}}async function k({scanPath:t,dataSiloId:e,auth:g,fileGlobs:p,ignoreDirs:f,transcendUrl:s}){let a=y(s,g),n=await u(a,e),l=D[n.dataSilo.type];l||(r.error(w.red(`This plugin "${n.dataSilo.type}" is not supported for offline silo discovery.`)),process.exit(1));let o=await m({scanPath:t,fileGlobs:p,ignoreDirs:f,config:l});await S(a,n.id,o);let c=new URL(h);c.pathname="/data-map/data-inventory/silo-discovery/triage",c.search=C({filters:JSON.stringify({pluginIds:[n.id]})}),r.info(w.green(`Scan found ${o.length} potential data silos at ${t}! View at '${c.href}'
2
-
3
- NOTE: it may take 2-3 minutes for scan results to appear in the UI.`))}export{k as discoverSilos};
@@ -1 +0,0 @@
1
- import{b as n,f as r}from"./chunk-UPHD5UAO.js";import{q as e}from"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function d({base64EncryptionKey:o,base64SigningKey:t,partition:s,file:i,consentUrl:a,concurrency:c}){let m=e(i,n);await r({base64EncryptionKey:o,base64SigningKey:t,preferences:m,partition:s,concurrency:c,transcendUrl:a})}export{d as uploadConsentPreferences};
@@ -1 +0,0 @@
1
- import{c as o}from"./chunk-XQTNSPJ3.js";import"./chunk-UPHD5UAO.js";import"./chunk-SVDDU4R6.js";import"./chunk-HMF46LB7.js";import"./chunk-W6GUOMVP.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function i({auth:t,trackerStatus:r,file:s,transcendUrl:a}){await o({auth:t,trackerStatus:r,file:s,transcendUrl:a})}export{i as uploadCookiesFromCsv};
@@ -1,5 +0,0 @@
1
- import{a}from"./chunk-TD5AG6IF.js";import"./chunk-HMF46LB7.js";import"./chunk-W6GUOMVP.js";import"./chunk-MBAKYLJ3.js";import{a as n}from"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import x from"colors";import{writeFileSync as A}from"fs";import{TRANSCEND_SCOPES as E}from"@transcend-io/privacy-types";import{keyBy as K}from"lodash-es";var i=K(Object.entries(E).map(([t,o])=>({...o,name:t})),"title"),N=Object.keys(i);async function P({email:t,password:o,apiKeyTitle:p,file:c,scopes:m,deleteExistingApiKey:l,createNewApiKey:g,parentOrganizationId:f,transcendUrl:y}){let r=m.map(e=>e.trim()),s=r.filter(e=>!i[e]);s.length>0&&(n.error(x.red(`Failed to parse scopes:"${s.join(",")}".
2
- Expected one of:
3
- ${N.join(`
4
- `)}`)),process.exit(1));let S=r.map(e=>i[e].name),{errors:d,apiKeys:C}=await a({transcendUrl:y,password:o,email:t,parentOrganizationId:f,deleteExistingApiKey:l,createNewApiKey:g,apiKeyTitle:p,scopes:S});A(c,`${JSON.stringify(C,null,2)}
5
- `),d.length>0&&process.exit(1)}export{P as generateApiKeys};
@@ -1 +0,0 @@
1
- import{d as n}from"./chunk-FXYTXR6R.js";import"./chunk-RBOBI6B6.js";import"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function c({auth:t,transcendUrl:r,file:e,enricherId:i,concurrency:s,markSilent:o,sombraAuth:a}){await n({file:e,transcendUrl:r,enricherId:i,concurrency:s,markSilent:o,auth:t,sombraAuth:a})}export{c as pushIdentifiers};
@@ -1 +0,0 @@
1
- import{d as o,e as r}from"./chunk-QQRMUEM7.js";import{c as m}from"./chunk-TD5AG6IF.js";import{h as a}from"./chunk-XQTNSPJ3.js";import"./chunk-UPHD5UAO.js";import"./chunk-SVDDU4R6.js";import"./chunk-HMF46LB7.js";import"./chunk-W6GUOMVP.js";import"./chunk-MBAKYLJ3.js";import{a as t}from"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import{join as u}from"path";import c from"colors";import{existsSync as g,lstatSync as l}from"fs";function b({consentManagerYmlFolder:s,output:n}){(!g(s)||!l(s).isDirectory())&&(t.error(c.red(`Folder does not exist: "${s}"`)),process.exit(1));let p=m(s).map(i=>{let{"consent-manager":f}=o(u(s,i));return{name:i,input:f}}),e=a(p);r(n,{"business-entities":e}),t.info(c.green(`Successfully wrote ${e.length} business entities to file "${n}"`))}export{b as consentManagersToBusinessEntities};
@@ -1 +0,0 @@
1
- import{a as l}from"./chunk-3KYYR6WM.js";import"./chunk-HXMONGHM.js";import{c as m}from"./chunk-RBOBI6B6.js";import"./chunk-SVDDU4R6.js";import{pe as c}from"./chunk-MBAKYLJ3.js";import{a as r}from"./chunk-OERYFLN2.js";import{d as g}from"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import{uniq as A,groupBy as G}from"lodash-es";import n from"colors";async function k({auth:p,file:a,transcendUrl:d,dataSiloIds:u,includeAttributes:y,includeGuessedCategories:C,parentCategories:f,subCategories:D=[]}){try{let o=c(d,p),P=await l(o,{dataSiloIds:u,includeGuessedCategories:C,parentCategories:f,includeAttributes:y,subCategories:D});r.info(n.magenta(`Writing datapoints to file "${a}"...`));let s=[],b=P.map(e=>{let i={"Property ID":e.id,"Data Silo":e.dataSilo.title,Object:e.dataPoint.name,"Object Path":e.dataPoint.path.join("."),Property:e.name,"Property Description":e.description,"Data Categories":e.categories.map(t=>`${t.category}:${t.name}`).join(", "),"Guessed Category":e.pendingCategoryGuesses?.[0]?`${e.pendingCategoryGuesses[0].category.category}:${e.pendingCategoryGuesses[0].category.name}`:"","Processing Purposes":e.purposes.map(t=>`${t.purpose}:${t.name}`).join(", "),...Object.entries(G(e.attributeValues||[],({attributeKey:t})=>t.name)).reduce((t,[$,h])=>(t[$]=h.map(j=>j.name).join(","),t),{})};return s=A([...s,...Object.keys(i)]),i});m(a,b,s)}catch(o){r.error(n.red(`An error occurred syncing the datapoints: ${o.message}`)),process.exit(1)}r.info(n.green(`Successfully synced datapoints to disk at ${a}! View at ${g}`))}export{k as pullDatapoints};
@@ -1 +0,0 @@
1
- import{a as w}from"./chunk-ZB5DNAF3.js";import{d as D,e as h}from"./chunk-QQRMUEM7.js";import{c as y}from"./chunk-TD5AG6IF.js";import"./chunk-HMF46LB7.js";import"./chunk-W6GUOMVP.js";import{ne as S,pe as T}from"./chunk-MBAKYLJ3.js";import{a as c}from"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import{join as O}from"path";import{difference as v}from"lodash-es";import I from"colors";import{existsSync as $,lstatSync as b}from"fs";async function Q({auth:F,dataFlowsYmlFolder:a,output:x,ignoreYmls:C=[],transcendUrl:k}){a||(c.error(I.red("Missing required arg: --dataFlowsYmlFolder=./working/data-flows/")),process.exit(1)),(!$(a)||!b(a).isDirectory())&&(c.error(I.red(`Folder does not exist: "${a}"`)),process.exit(1));let N=C.map(t=>t.split(".")[0]),l=y(a).map(t=>{let{"data-flows":o=[]}=D(O(a,t)),{adTechDataSilos:m,siteTechDataSilos:r}=w(o,{serviceToSupportedIntegration:u,serviceToTitle:f});return{adTechDataSilos:m,siteTechDataSilos:r,organizationName:t.split(".")[0]}}),s={};l.forEach(({adTechDataSilos:t,siteTechDataSilos:o,organizationName:m})=>{[...t,...o].forEach(e=>{let n=e["outer-type"]||e.integrationName;s[n]||(s[n]=[]),s[n].push(m),s[n]=[...new Set(s[n])]})});let p=[...new Set(l.map(({adTechDataSilos:t})=>t.map(o=>o["outer-type"]||o.integrationName)).flat())],g=v([...new Set(l.map(({siteTechDataSilos:t})=>t.map(o=>o["outer-type"]||o.integrationName)).flat())],p),i={};l.forEach(({adTechDataSilos:t,siteTechDataSilos:o})=>{[...t,...o].forEach(r=>{let e=r["outer-type"]||r.integrationName,n=r.attributes?.find(E=>E.key==="Found On Domain");i[e]||(i[e]=[]),i[e].push(...n?.values||[]),i[e]=[...new Set(i[e])]})});let A=T(k,F),{serviceToTitle:f,serviceToSupportedIntegration:u}=await S(A),d=[...p,...g].map(t=>({title:f[t],...u[t]?{integrationName:t}:{integrationName:"promptAPerson","outer-type":t},attributes:[{key:"Tech Type",values:["Ad Tech"]},{key:"Business Units",values:v(s[t]||[],N)},{key:"Found On Domain",values:i[t]||[]}]}));c.log(`Total Services: ${d.length}`),c.log(`Ad Tech Services: ${p.length}`),c.log(`Site Tech Services: ${g.length}`),h(x,{"data-silos":d})}export{Q as deriveDataSilosFromDataFlowsCrossInstance};
@@ -1 +0,0 @@
1
- import{b as d}from"./chunk-3KYYR6WM.js";import"./chunk-HXMONGHM.js";import{c as u}from"./chunk-RBOBI6B6.js";import"./chunk-SVDDU4R6.js";import{pe as c}from"./chunk-MBAKYLJ3.js";import{a as e}from"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";import i from"colors";import{uniq as b}from"lodash-es";async function x({auth:l,file:s,transcendUrl:m,dataSiloIds:f,subCategories:p,status:g,includeEncryptedSnippets:a}){try{let o=c(m,l),C=await d(o,{dataSiloIds:f,subCategories:p,status:g,includeEncryptedSnippets:a});e.info(i.magenta(`Writing unstructured discovery files to file "${s}"...`));let r=[],S=C.map(t=>{let n={"Entry ID":t.id,"Data Silo ID":t.dataSiloId,"Object Path ID":t.scannedObjectPathId,"Object ID":t.scannedObjectId,...a?{Entry:t.name,"Context Snippet":t.contextSnippet}:{},"Data Category":`${t.dataSubCategory.category}:${t.dataSubCategory.name}`,"Classification Status":t.status,"Confidence Score":t.confidence,"Classification Method":t.classificationMethod,"Classifier Version":t.classifierVersion};return r=b([...r,...Object.keys(n)]),n});u(s,S,r)}catch(o){e.error(i.red(`An error occurred syncing the unstructured discovery files: ${o.message}`)),process.exit(1)}e.info(i.green(`Successfully synced unstructured discovery files to disk at ${s}!`))}export{x as pullUnstructuredDiscoveryFiles};
@@ -1 +0,0 @@
1
- import{e as t}from"./chunk-HXMONGHM.js";import"./chunk-RBOBI6B6.js";import"./chunk-SVDDU4R6.js";import"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import"./chunk-APA5PR4U.js";import"./chunk-4W2NF2OS.js";import"./chunk-EZCJGIOS.js";async function s({file:e,transcendUrl:r,auth:i,sombraAuth:o,dataSiloId:n}){await t({file:e,transcendUrl:r,auth:i,sombraAuth:o,dataSiloId:n})}export{s as markIdentifiersCompleted};
package/dist/index.js DELETED
@@ -1,4 +0,0 @@
1
- import{a as Ui,b as ji,c as Hi,d as Vi}from"./chunk-FXYTXR6R.js";import{a as Qi,b as Gi}from"./chunk-3KYYR6WM.js";import{a as ta}from"./chunk-AHYJJKNA.js";import{a as Ti,b as Ai,c as yi}from"./chunk-UVJSNZM5.js";import{a as xi}from"./chunk-T2PLXAEM.js";import{a as ue,b as he,c as fe,d as Pe,e as Te}from"./chunk-QQRMUEM7.js";import{a as Si,b as ki,c as Bi,d as Fi}from"./chunk-TD5AG6IF.js";import{a as bi,b as wi,c as Ei,d as Ii,e as Oi,f as Di,g as $i}from"./chunk-HXMONGHM.js";import{a as Ri,b as Ci,c as Mi,d as Li,e as Ni}from"./chunk-RBOBI6B6.js";import{a as si,b as oi,c as ai,d as pi,e as ii,f as mi,g as ci,h as gi,i as li,j as ui}from"./chunk-XQTNSPJ3.js";import{a as di,d as hi,e as fi,f as Pi}from"./chunk-UPHD5UAO.js";import{A as kp,B as Bp,C as Fp,D as Qp,E as Gp,F as Up,G as jp,H as Hp,I as Vp,J as qp,K as vp,L as _p,M as zp,N as Jp,O as Wp,P as Zp,Q as Kp,R as Xp,S as Yp,T as ti,U as ei,V as ri,W as ni,a as ea,b as ra,c as na,d as sa,e as oa,f as aa,g as pa,h as ia,i as ma,j as ca,k as ga,l as da,m as la,n as ua,o as ha,p as fa,q as Pa,r as Ta,s as Aa,t as Np,u as Ep,v as Ip,w as Op,x as Dp,y as $p,z as Sp}from"./chunk-SVDDU4R6.js";import{$ as Kt,A as Rt,B as Ct,C as Mt,D as Lt,E as Nt,F as Et,G as It,H as Ot,I as Dt,J as $t,K as St,L as kt,M as Bt,N as Ft,O as Qt,P as Gt,Q as Ut,R as jt,S as Ht,T as Vt,U as qt,V as vt,W as _t,X as zt,Y as Jt,Z as Wt,_ as Zt,a as X,aa as Xt,b as Y,ba as Yt,c as tt,ca as te,d as et,da as ee,e as rt,ea as re,f as nt,fa as ne,g as st,ga as se,h as ot,ha as oe,i as at,ia as ae,j as pt,ja as pe,k as it,ka as ie,l as mt,la as me,m as ct,ma as ce,n as gt,na as ge,o as dt,oa as de,p as lt,pa as le,q as ut,r as ht,s as ft,t as Pt,u as Tt,v as At,w as yt,x as xt,y as bt,z as wt}from"./chunk-HMF46LB7.js";import{a as Z,b as K}from"./chunk-W6GUOMVP.js";import{$ as fr,$a as Pn,$b as hs,$c as ho,$d as $a,A as Ve,Aa as Vr,Ab as qn,Ac as Hs,Ad as Uo,Ae as ap,B as qe,Ba as qr,Bb as vn,Bc as Vs,Bd as jo,Be as pp,C as ve,Ca as vr,Cb as _n,Cc as R,Cd as Ho,Ce as ip,D as _e,Da as _r,Db as zn,Dc as qs,Dd as Vo,De as mp,E as ze,Ea as zr,Eb as Jn,Ec as vs,Ed as qo,Ee as cp,F as Je,Fa as Jr,Fb as Wn,Fc as _s,Fd as vo,Fe as gp,G as We,Ga as Wr,Gb as b,Gc as zs,Gd as _o,Ge as dp,H as Ze,Ha as Zr,Hb as Zn,Hc as Js,Hd as zo,He as lp,I as Ke,Ia as Kr,Ib as Kn,Ic as Ws,Id as Jo,Ie as up,J as Xe,Ja as Xr,Jb as Xn,Jc as Zs,Jd as Wo,Je as hp,K as Ye,Ka as Yr,Kb as Yn,Kc as Ks,Kd as Zo,Ke as fp,L as tr,La as tn,Lb as ts,Lc as Xs,Ld as Ko,Le as Pp,M as er,Ma as en,Mb as es,Mc as Ys,Md as Xo,Me as Tp,N as rr,Na as rn,Nb as rs,Nc as to,Nd as Yo,Ne as f,O as nr,Oa as nn,Ob as ns,Oc as eo,Od as ya,Oe as Ap,P as sr,Pa as sn,Pb as ss,Pc as ro,Pd as xa,Q as or,Qa as on,Qb as os,Qc as no,Qd as ba,R as ar,Ra as an,Rb as as,Rc as so,Rd as wa,S as pr,Sa as pn,Sb as ps,Sc as oo,Sd as Ra,T as ir,Ta as mn,Tb as is,Tc as ao,Td as Ca,U as mr,Ua as cn,Ub as ms,Uc as po,Ud as Ma,V as cr,Va as gn,Vb as cs,Vc as io,Vd as La,W as gr,Wa as dn,Wb as gs,Wc as mo,Wd as Na,X as dr,Xa as ln,Xb as ds,Xc as co,Xd as Ea,Y as lr,Ya as un,Yb as ls,Yc as go,Yd as Ia,Z as ur,Za as hn,Zb as us,Zc as lo,Zd as Oa,_ as hr,_a as fn,_b as w,_c as uo,_d as Da,a as x,aa as Pr,ab as Tn,ac as fs,ad as fo,ae as Sa,ba as Tr,bb as An,bc as Ps,bd as Po,be as ka,c as Ae,ca as Ar,cb as yn,cc as Ts,cd as To,ce as Ba,d as ye,da as yr,db as xn,dc as As,dd as Ao,de as Fa,e as xe,ea as xr,eb as bn,ec as ys,ed as yo,ee as Qa,f as be,fa as br,fb as wn,fc as xs,fd as xo,fe as Ga,g as we,ga as wr,gb as Rn,gc as bs,gd as bo,ge as Ua,h as Re,ha as Rr,hb as Cn,hc as ws,hd as wo,he as ja,i as Ce,ia as Cr,ib as Mn,ic as Rs,id as h,ie as Ha,j as Me,ja as Mr,jb as Ln,jc as Cs,jd as Ro,je as Va,k as Le,ka as Lr,kb as Nn,kc as Ms,kd as Co,ke as qa,l as Ne,la as Nr,lb as En,lc as Ls,ld as Mo,le as va,m as Ee,ma as Er,mb as In,mc as Ns,md as Lo,me as _a,n as Ie,na as Ir,nb as On,nc as Es,nd as No,ne as za,o as Oe,oa as Or,ob as Dn,oc as Is,od as Eo,oe as Za,p as De,pa as Dr,pb as $n,pc as Os,pd as Io,pe as M,q as $e,qa as $r,qb as Sn,qc as Ds,qd as Oo,qe as Ka,r as Se,ra as Sr,rb as kn,rc as $s,rd as Do,re as Xa,s as ke,sa as kr,sb as Bn,sc as Ss,sd as $o,se as Ya,t as Be,ta as Br,tb as Fn,tc as ks,td as So,te as L,u as Fe,ua as Fr,ub as Qn,uc as Bs,ud as ko,ue as tp,v as Qe,va as Qr,vb as Gn,vc as Fs,vd as Bo,ve as ep,w as Ge,wa as Gr,wb as Un,wc as Qs,wd as Fo,we as rp,x as Ue,xa as Ur,xb as jn,xc as Gs,xd as C,xe as np,y as je,ya as jr,yb as Hn,yc as Us,yd as Qo,ye as sp,z as He,za as Hr,zb as Vn,zc as js,zd as Go,ze as op}from"./chunk-MBAKYLJ3.js";import"./chunk-OERYFLN2.js";import{a as yp,b as xp,c as bp,d as wp,e as N,f as Rp,g as Cp,h as Mp,i as Lp}from"./chunk-APA5PR4U.js";import{a as Ja,b as Wa}from"./chunk-4W2NF2OS.js";import{a as q,b as v,c as _,d as z,e as J,f as W}from"./chunk-EZCJGIOS.js";import{apply as k,decodeCodec as I,getValues as B}from"@transcend-io/type-utils";import{createHandlebarsWithHelpers as O}from"@transcend-io/handlebars-utils";import{PromptStatus as D,ChatCompletionRole as l,PromptRunProductArea as A,QueueStatus as y}from"@transcend-io/privacy-types";var T=20;async function E(a){let e=[],r=0,t=!1;do{let{largeLanguageModels:{nodes:s}}=await w(a,b,{first:T,offset:r});e.push(...s),r+=T,t=s.length===T}while(t);return e.sort((s,o)=>s.name.localeCompare(o.name))}import{groupBy as F,keyBy as P,uniq as Q,chunk as G}from"lodash-es";function U(a){return new RegExp(`<${a}>([\\s\\S]+?)<\\/${a}>`)}function hm(a){return a}var j=a=>{try{return JSON.parse(a)}catch{return a}},$=class{prompts;handlebarsOptions;promptContentMap;largeLanguageModels=[];agentsByName={};agentsByAgentId={};graphQLClient;defaultVariables;variables;handlebars;transcendApiKey;transcendUrl;requireApproval;cacheDuration;lastUpdatedAt;constructor({prompts:e,handlebarsOptions:r={},transcendUrl:t=N,transcendApiKey:s,requireApproval:o=!0,cacheDuration:i,defaultVariables:p={}}){this.prompts=e,this.transcendUrl=t,this.transcendApiKey=s,this.variables=p,this.defaultVariables=p,this.graphQLClient=M(t,typeof s=="object"?s.release():s),this.requireApproval=o,this.cacheDuration=i,this.handlebarsOptions=r,this.handlebars=O(r)}async fetchPromptsAndMetadata(){let e=B(this.prompts),r=e.map(({id:n})=>n).filter(n=>!!n),t=e.map(({title:n})=>n).filter(n=>!!n),s=Q(e.map(({agentNames:n})=>n||[]).flat()),[o,i,p]=await Promise.all([R(this.graphQLClient,{promptIds:r,promptTitles:t}),E(this.graphQLClient),h(this.graphQLClient,{names:s})]);this.agentsByName=P(p,"name"),this.agentsByAgentId=P(p,"agentId"),this.largeLanguageModels=i.filter(n=>n.isTranscendHosted===!1);let m=P(o.prompts,"title"),c=P(o.prompts,"id");return this.variables={...o.calculatedVariables.reduce((n,g)=>Object.assign(n,{[g.name]:g.data?JSON.parse(g.data):g.data}),{}),...this.defaultVariables},this.handlebars=O({...this.handlebarsOptions,templates:[...this.handlebarsOptions.templates||[],...o.promptPartials.map(n=>({name:n.slug,content:n.content}))]}),this.promptContentMap=k(this.prompts,({id:n,title:g})=>{let d=n?c[n]:g?m[g]:void 0;if(!d)throw new Error(`Failed to find prompt with title: "${g}" and id: "${n}"`);return d}),this.lastUpdatedAt=new Date,o}async getAgentByName(e){let r=this.agentsByName[e];if(r)return r;let[t]=await h(this.graphQLClient,{names:[e]});if(t)return this.agentsByName[t.name]=t,this.agentsByAgentId[t.agentId]=t,t}async getPromptThreadBySlackTs(e){let[r]=await L(this.graphQLClient,{slackMessageTs:[e]});return r}async getAgentsByName(e){if(e.length<1)throw new Error("Expected at least one name to be provided");let{hasCache:r=[],missingCache:t=[]}=F(e,p=>this.agentsByName[p]?"hasCache":"missingCache"),s=r.map(p=>this.agentsByName[p]);if(t.length===0)return s;let o=G(t,50),i=[];return await x(o,async p=>{let m=await h(this.graphQLClient,{names:p});m.forEach(c=>{this.agentsByName[c.name]=c,this.agentsByAgentId[c.agentId]=c}),i.push(...m)}),[...s,...i]}getAgentFiles(e){return C(this.graphQLClient,e)}getLargeLanguageModel(e){let r=this.largeLanguageModels.find(t=>typeof e=="string"?t.id===e:t.name===e.name&&t.client===e.client);if(!r)throw new Error(`Failed to find model matching: ${typeof e=="string"?e:JSON.stringify(e)}`);return r}async getPromptDefinition(e){(!this.lastUpdatedAt||this.cacheDuration===0||this.cacheDuration&&Date.now()-this.lastUpdatedAt.getTime()>this.cacheDuration)&&await this.fetchPromptsAndMetadata();let{promptContentMap:r}=this;if(!r)throw new Error("Expected this.promptContentMap to be defined");let t=r[e];if(!t)throw new Error(`Expected this.promptContentMap[${e}] to be defined`);return t}async compilePrompt(e,r){let t=await this.getPromptDefinition(e),s=this.prompts[e];if(!s)throw new Error(`Expected this.prompts[${e}] to be defined`);if(this.requireApproval&&t.status!==D.Approved)throw new Error(`Assessment "${t.title}" cannot be used because its in status: "${t.status}"`);if(t.status===D.Rejected)throw new Error(`Assessment "${t.title}" cannot be used because it's in status: "${t.status}"`);return I(s.paramCodec,r),this.handlebars.compile(t.content)({currentDate:new Date().toISOString(),...this.variables,...r})}parseAiResponse(e,r){let t=this.prompts[e];if(!t)throw new Error(`Expected this.prompts[${e}] to be defined`);let s=t.extractFromTag&&(U(t.extractFromTag).exec(r)||[])[1]||r;return I(t.outputCodec,j(s),!1)}async reportAndParsePromptRun(e,{largeLanguageModel:r,...t}){(!this.lastUpdatedAt||this.cacheDuration===0||this.cacheDuration&&Date.now()-this.lastUpdatedAt.getTime()>this.cacheDuration)&&await this.fetchPromptsAndMetadata();let s=t.name||`@transcend-io/cli-prompt-run-${new Date().toISOString()}`;if(!this.promptContentMap)throw new Error("Expected this.promptContentMap to be defined");let o=this.promptContentMap[e];if(!o)throw new Error(`Expected this.prompts[${e}] to be defined`);if(t.promptRunMessages.length===0)throw new Error("promptRunMessages is expected to have length > 0");if(t.promptRunMessages[0].role!==l.System)throw new Error(`promptRunMessages[0].role is expected to be = ${l.System}`);if(t.promptRunMessages[t.promptRunMessages.length-1].role!==l.Assistant)throw new Error(`promptRunMessages[${t.promptRunMessages.length-1}].role is expected to be = ${l.Assistant}`);let i=t.promptRunMessages[t.promptRunMessages.length-1].content,p;try{p=this.parseAiResponse(e,i)}catch(c){throw await f(this.graphQLClient,{productArea:A.PromptManager,...t,name:s,error:c.message,status:y.Error,...typeof r=="string"?{largeLanguageModelId:r}:{largeLanguageModelName:r.name,largeLanguageModelClient:r.client},promptId:o.id,promptRunMessages:t.promptRunMessages.map((n,g)=>({...n,...g===0?{template:o.content}:{}}))}),c}let m=await f(this.graphQLClient,{productArea:A.PromptManager,...t,name:s,status:y.Resolved,...typeof r=="string"?{largeLanguageModelId:r}:{largeLanguageModelName:r.name,largeLanguageModelClient:r.client},promptId:o.id,promptRunMessages:t.promptRunMessages.map((c,n)=>({...c,...n===0?{template:o.content}:{}}))});return{result:p,promptRunId:m,promptRunUrl:`https://app.transcend.io/prompts/runs/${m}`}}async reportPromptRunError(e,{largeLanguageModel:r,...t}){(!this.lastUpdatedAt||this.cacheDuration===0||this.cacheDuration&&Date.now()-this.lastUpdatedAt.getTime()>this.cacheDuration)&&await this.fetchPromptsAndMetadata();let s=t.name||`@transcend-io/cli-prompt-run-${new Date().toISOString()}`;if(!this.promptContentMap)throw new Error("Expected this.promptContentMap to be defined");let o=this.promptContentMap[e];if(!o)throw new Error(`Expected this.prompts[${e}] to be defined`);if(t.promptRunMessages.length===0)throw new Error("promptRunMessages is expected to have length > 0");if(t.promptRunMessages[0].role!==l.System)throw new Error(`promptRunMessages[0].role is expected to be = ${l.System}`);let i=await f(this.graphQLClient,{productArea:A.PromptManager,...t,name:s,status:y.Error,...typeof r=="string"?{largeLanguageModelId:r}:{largeLanguageModelName:r.name,largeLanguageModelClient:r.client},promptId:o.id,promptRunMessages:t.promptRunMessages.map((p,m)=>({...p,...m===0?{template:o.content}:{}}))});return{promptRunId:i,promptRunUrl:`https://app.transcend.io/prompts/runs/${i}`}}};function Pm(a){let e=/(https?:\/\/[^\s]+)/g;return a.replace(e,"<link-omitted>")}function Am(a){return Object.entries(a).reduce((e,[r,t])=>t!=null&&t!==""&&!(Array.isArray(t)&&t.length===0)&&!(typeof t=="object"&&Object.keys(t).length===0)?Object.assign(e,{[r]:t}):e,{})}import{difference as H}from"lodash-es";import V from"fast-glob";import{execSync as u}from"child_process";function Rm({baseBranch:a,rootDirectory:e,githubRepo:r,excludedGlob:t=[],fileBlockList:s=[]}){u(`git fetch origin ${a}`);let o=u(`git ls-remote ${r} "refs/heads/${a}" | cut -f 1`,{encoding:"utf-8"}).split(`
2
- `)[0],i=u("git rev-parse HEAD",{encoding:"utf-8"}).split(`
3
- `)[0];if(!o||!i)throw new Error("FAILED TO FIND COMMIT RANGE");let p=u(`git fetch && git diff --name-only "${a||o}...${i}" -- ${e}`,{encoding:"utf-8"}),m=H(p.split(`
4
- `).filter(d=>d),s),c=t.length>0?V.sync(m,{ignore:t}):m,n={};c.forEach(d=>{let S=u(`git show ${i}:${d}`,{encoding:"utf-8"});n[d]=S});let g=r.split("/").pop().split(".")[0];return{changedFiles:m,fileDiffs:n,repoName:g,commit:i}}export{Qn as ACTIONS,Zr as ADD_MESSAGES_TO_PROMPT_RUN,Ke as ADD_SILO_DISCOVERY_RESULTS,xp as ADMIN_DASH,wp as ADMIN_DASH_DATAPOINTS,bp as ADMIN_DASH_INTEGRATIONS,Zn as AGENTS,Yn as AGENT_FILES,rs as AGENT_FUNCTIONS,Je as API_KEYS,lr as APPROVE_PRIVACY_REQUEST,wr as ASSESSMENTS,br as ASSESSMENT_SECTION_FIELDS,Lr as ASSESSMENT_TEMPLATES,Wn as ASSUME_ROLE,tn as ATTRIBUTES,rr as ATTRIBUTE_KEYS_REQUESTS,sn as ATTRIBUTE_VALUES,Nt as ActionInput,Gt as ActionItemCollectionInput,Ut as ActionItemInput,dt as AgentFileInput,gt as AgentFunctionInput,ct as AgentInput,tt as ApiKeyInput,Na as AssessmentAction,_t as AssessmentAnswerOptionInput,Vt as AssessmentDisplayLogicInput,Xt as AssessmentInput,La as AssessmentNestedRule,Ht as AssessmentNestedRuleInput,Kt as AssessmentResourceInput,Wt as AssessmentRetentionScheduleInput,Ia as AssessmentRiskLogic,Ma as AssessmentRule,jt as AssessmentRuleInput,Jt as AssessmentSectionInput,zt as AssessmentSectionQuestionInput,Zt as AssessmentTemplateInput,Op as AttestedExtraIdentifiers,it as AttributeInput,mt as AttributePreview,pt as AttributeValueInput,na as BLANK,ra as BULK_APPLY,kn as BUSINESS_ENTITIES,bt as BusinessEntityInput,ur as CANCEL_PRIVACY_REQUEST,pa as CAN_APPLY_IN_BULK,Be as CATALOGS,Gr as CHANGE_REQUEST_DATA_SILO_STATUS,ar as CODE_PACKAGES,Sn as CONSENT_MANAGER_ANALYTICS_DATA,cn as CONSENT_PARTITIONS,hn as COOKIES,Hn as CREATE_ACTION_ITEMS,Xr as CREATE_ACTION_ITEM_COLLECTION,Kn as CREATE_AGENT,ts as CREATE_AGENT_FILE,ns as CREATE_AGENT_FUNCTION,We as CREATE_API_KEY,on as CREATE_ATTRIBUTE,en as CREATE_ATTRIBUTE_VALUES,Bn as CREATE_BUSINESS_ENTITY,ir as CREATE_CODE_PACKAGE,Dn as CREATE_CONSENT_EXPERIENCE,An as CREATE_CONSENT_MANAGER,$n as CREATE_CONSENT_PARTITION,gn as CREATE_DATA_FLOWS,Oe as CREATE_DATA_SILOS,He as CREATE_DATA_SUBJECT,ms as CREATE_DATA_SUB_CATEGORY,Se as CREATE_ENRICHER,Ge as CREATE_IDENTIFIER,ds as CREATE_PROCESSING_PURPOSE_SUB_CATEGORY,$r as CREATE_PROMPT,Fr as CREATE_PROMPT_GROUP,kr as CREATE_PROMPT_PARTIAL,ze as CREATE_REPOSITORY,or as CREATE_SOFTWARE_DEVELOPMENT_KIT,Vr as CREATE_TEAM,tr as CREATE_TEMPLATE,as as CREATE_VENDOR,ia as CachedFileState,ca as CachedRequestState,Ct as CodePackageInput,Rt as CodePackageSdk,oa as ColumnName,Dt as ConsentManageExperienceInput,St as ConsentManagerInput,Ss as ConsentManagerMetricBin,ae as ConsentManagerServiceMetadata,li as ConsentPreferenceResponse,te as ConsentPreferenceTopic,Yt as ConsentPreferenceTopicOptionValue,ee as ConsentPurpose,oe as CookieCsvInput,Ot as CookieInput,bi as CronIdentifier,Ei as CronIdentifierPush,Ce as DATAPOINT_EXPORT,un as DATA_FLOWS,Ae as DATA_POINTS,ye as DATA_POINT_COUNT,Le as DATA_SILOS,Ee as DATA_SILOS_ENRICHED,Ne as DATA_SILO_EXPORT,je as DATA_SUBJECTS,is as DATA_SUB_CATEGORIES,N as DEFAULT_TRANSCEND_API,Rp as DEFAULT_TRANSCEND_CONSENT_API,Sa as DEFAULT_TRANSCEND_PULL_RESOURCES,Ze as DELETE_API_KEY,nn as DELETE_ATTRIBUTE_VALUE,qn as DEPLOYED_PRIVACY_CENTER_URL,bn as DEPLOY_CONSENT_MANAGER,zn as DETERMINE_LOGIN_METHOD,ot as DataCategoryGuessInput,ut as DataCategoryInput,st as DataCategoryPreviewInput,at as DataCategoryRecommendationInput,se as DataFlowCsvInput,It as DataFlowInput,Qt as DataSiloInput,Lt as DataSubjectInput,yt as DatapointInput,Xe as ENABLED_PLUGINS,De as ENRICHERS,Me as ENTRY_COUNT,mn as EXPERIENCES,ji as EnrichPrivacyRequest,rt as EnricherInput,Pn as FETCH_CONSENT_MANAGER,fn as FETCH_CONSENT_MANAGER_ID,Tn as FETCH_CONSENT_MANAGER_THEME,Vn as FETCH_PRIVACY_CENTER_ID,At as FieldInput,Un as GLOBAL_ACTION_ITEMS,Kr as GLOBAL_ACTION_ITEM_COLLECTIONS,Fe as IDENTIFIERS,sa as IDENTIFIER_BLOCK_LIST,Rr as IMPORT_ONE_TRUST_ASSESSMENT_FORMS,$e as INITIALIZER,mi as IP_ADDRESS_REGEX,aa as IS_REQUIRED,Et as IdentifierInput,le as ImportOnetrustAssessmentsInput,kp as IntlMessage,Ft as IntlMessageInput,b as LARGE_LANGUAGE_MODELS,Jn as LOGIN,Pr as MESSAGES,Qe as NEW_IDENTIFIER_TYPES,ea as NONE,fr as NOTIFY_ADDITIONAL_TIME,er as ORGANIZATION,q as OneTrustFileFormat,v as OneTrustPullResource,_ as OneTrustPullSource,ie as OpenAIEnabledRoute,me as OpenAIEnabledRoutes,ce as OpenAIIntegration,W as OpenAIRouteName,cr as POLICIES,Mr as PREFERENCE_TOPICS,vn as PRIVACY_CENTER,gs as PROCESSING_PURPOSE_SUB_CATEGORIES,Nr as PROMPTS,Or as PROMPTS_WITH_VARIABLES,Ir as PROMPT_GROUPS,Er as PROMPT_PARTIALS,mr as PROMPT_THREADS,Cr as PURPOSES,ha as ParsedAttributeInput,$t as PartitionInput,ge as PathfinderPolicy,J as PathfinderPolicyName,pe as PathfinderPolicyNameC,de as PathfinderPromptRunMetadata,Bt as PolicyInput,kt as PrivacyCenterInput,np as PrivacyRequest,Dp as PrivacyRequestInput,jp as PrivacyRequestResponse,ht as ProcessingPurposeInput,nt as ProcessingPurposePreviewInput,xt as PromptAVendorEmailSettings,Tt as PromptGroupInput,ft as PromptInput,Pt as PromptPartialInput,fi as PurposeMap,jr as REDUCED_REQUESTS_FOR_DATA_SILO_COUNT,vr as REMOVE_REQUEST_IDENTIFIERS,Wr as REPORT_PROMPT_RUN,ve as REPOSITORIES,dr as REQUESTS,Qr as REQUEST_DATA_SILOS,Ar as REQUEST_ENRICHERS,Jr as REQUEST_FILES,_r as REQUEST_IDENTIFIERS,Ur as RETRY_REQUEST_DATA_SILO,yr as RETRY_REQUEST_ENRICHER,Mt as RepositoryInput,Bp as RequestFileMetadata,Fp as RequestFileMetadataResponse,op as RequestIdentifiersResponse,qt as RiskAssignmentInput,vt as RiskLogicInput,pn as SET_RESOURCE_ATTRIBUTES,xr as SKIP_REQUEST_ENRICHER,nr as SOFTWARE_DEVELOPMENT_KITS,us as SOMBRA_VERSION,xe as SUB_DATA_POINTS,be as SUB_DATA_POINTS_COUNT,we as SUB_DATA_POINTS_WITH_GUESSES,po as SYNC_ATTRIBUTE_TYPES,wt as SoftwareDevelopmentKitInput,ne as StoredApiKey,ma as SuccessfulRequest,Hr as TEAMS,Ye as TEMPLATES,En as TOGGLE_CONSENT_PRECEDENCE,qe as TOGGLE_DATA_SUBJECT,Nn as TOGGLE_TELEMETRY_PARTITION_STRATEGY,Ln as TOGGLE_UNKNOWN_COOKIE_POLICY,Mn as TOGGLE_UNKNOWN_REQUEST_POLICY,Mp as TR_PULL_RESOURCE_SCOPE_MAP,Cp as TR_PUSH_RESOURCE_SCOPE_MAP,Lp as TR_YML_RESOURCE_TO_FIELD_NAME,et as TeamInput,X as TemplateInput,re as TranscendInput,$ as TranscendPromptManager,z as TranscendPullResource,Gn as UPDATE_ACTION,jn as UPDATE_ACTION_ITEMS,Yr as UPDATE_ACTION_ITEM_COLLECTION,Xn as UPDATE_AGENTS,es as UPDATE_AGENT_FILES,ss as UPDATE_AGENT_FUNCTIONS,an as UPDATE_ATTRIBUTE,rn as UPDATE_ATTRIBUTE_VALUES,Fn as UPDATE_BUSINESS_ENTITIES,pr as UPDATE_CODE_PACKAGES,On as UPDATE_CONSENT_EXPERIENCE,wn as UPDATE_CONSENT_MANAGER_DOMAINS,Rn as UPDATE_CONSENT_MANAGER_PARTITION,In as UPDATE_CONSENT_MANAGER_THEME,xn as UPDATE_CONSENT_MANAGER_TO_LATEST,yn as UPDATE_CONSENT_MANAGER_VERSION,dn as UPDATE_DATA_FLOWS,Ie as UPDATE_DATA_SILOS,Ve as UPDATE_DATA_SUBJECT,cs as UPDATE_DATA_SUB_CATEGORIES,ke as UPDATE_ENRICHER,Ue as UPDATE_IDENTIFIER,Tr as UPDATE_INTL_MESSAGES,ln as UPDATE_OR_CREATE_COOKIES,Re as UPDATE_OR_CREATE_DATA_POINT,gr as UPDATE_POLICIES,_n as UPDATE_PRIVACY_CENTER,hr as UPDATE_PRIVACY_REQUEST,ls as UPDATE_PROCESSING_PURPOSE_SUB_CATEGORIES,Dr as UPDATE_PROMPTS,Br as UPDATE_PROMPT_GROUPS,Sr as UPDATE_PROMPT_PARTIALS,_e as UPDATE_REPOSITORIES,sr as UPDATE_SOFTWARE_DEVELOPMENT_KITS,qr as UPDATE_TEAM,Cn as UPDATE_TOGGLE_USP_API,ps as UPDATE_VENDORS,zr as USERS,hi as USP_STRING_REGEX,he as VARIABLE_PARAMETERS_NAME,ue as VARIABLE_PARAMETERS_REGEXP,os as VENDORS,lt as VendorInput,Y as WebhookHeader,Ap as addMessagesToPromptRun,Ci as appendCsvSync,Vp as approvePrivacyRequests,dp as assumeRole,K as buildAIIntegrationType,Z as buildEnabledRouteType,M as buildTranscendGraphQLClient,Za as buildTranscendGraphQLClientGeneric,ci as buildXdiSyncEndpoint,Kp as bulkRestartRequests,Yp as bulkRetryEnrichers,_p as cancelPrivacyRequests,gi as consentManagersToBusinessEntities,Rs as convertToDataSubjectAllowlist,ws as convertToDataSubjectBlockList,Lo as createActionItemCollection,Oo as createActionItems,Ro as createAgent,Qo as createAgentFile,ko as createAgentFunction,up as createApiKey,co as createBusinessEntity,Ha as createCodePackage,di as createConsentToken,_o as createDataCategory,fo as createDataFlows,Zo as createProcessingPurpose,qs as createPrompt,U as createRegexForTag,Ga as createRepository,Ba as createSoftwareDevelopmentKit,Ka as createSombraGotInstance,cp as createTranscendConsentGotInstance,Ho as createVendor,hm as defineTranscendPrompts,hp as deleteApiKey,Pp as deployConsentManager,Ja as description,ii as domainToHost,Up as downloadPrivacyRequestFiles,Hi as enrichPrivacyRequest,bs as ensureAllDataSubjectsExist,Jp as extractClientError,ya as fetchActiveSiloDiscoPlugin,Io as fetchAllActionItems,xo as fetchAllActions,C as fetchAllAgentFiles,So as fetchAllAgentFunctions,h as fetchAllAgents,js as fetchAllApiKeys,Ca as fetchAllAssessmentTemplates,Ra as fetchAllAssessments,ao as fetchAllAttributeValues,io as fetchAllAttributes,mo as fetchAllBusinessEntities,_a as fetchAllCatalogs,wa as fetchAllCookies,vo as fetchAllDataCategories,uo as fetchAllDataFlows,Ls as fetchAllDataPoints,Cs as fetchAllDataSilos,xs as fetchAllDataSubjects,Ts as fetchAllEnrichers,hs as fetchAllIdentifiers,ba as fetchAllMessages,Ws as fetchAllPolicies,Da as fetchAllPreferenceTopics,xa as fetchAllPrivacyCenters,Wo as fetchAllProcessingPurposes,wo as fetchAllPromptGroups,bo as fetchAllPromptPartials,L as fetchAllPromptThreads,Vs as fetchAllPrompts,no as fetchAllPurposes,$a as fetchAllPurposesAndPreferences,rp as fetchAllRequestAttributeKeys,pp as fetchAllRequestEnrichers,tp as fetchAllRequestIdentifierMetadata,ap as fetchAllRequestIdentifiers,sp as fetchAllRequests,Ms as fetchAllSubDataPoints,Gs as fetchAllTeams,Ao as fetchAllTemplates,lp as fetchAllUsers,jo as fetchAllVendors,za as fetchAndIndexCatalogs,Hs as fetchApiKeys,Os as fetchConsentManager,ks as fetchConsentManagerAnalyticsData,$s as fetchConsentManagerExperiences,Ds as fetchConsentManagerId,Bs as fetchConsentManagerTheme,ui as fetchConsentPreferences,Ns as fetchEnrichedDataSilos,fs as fetchIdentifiersAndCreateMissing,eo as fetchPartitions,Js as fetchPrivacyCenterId,zs as fetchPrivacyCenterUrl,R as fetchPromptsWithVariables,mp as fetchRequestDataSilo,ep as fetchRequestDataSiloActiveCount,ip as fetchRequestDataSilos,fp as fetchRequestFilesForRequest,Am as filterNullishValuesFromObject,Aa as filterRows,da as fuzzyMatchColumns,ga as fuzzySearch,Si as generateCrossAccountApiKeys,Qp as getFileMetadataForPrivacyRequests,Rm as getGitFilesThatChanged,Ta as getUniqueValuesForColumn,yi as inquirerAutoComplete,Ti as inquirerConfirmBoolean,Ai as inquirerConfirmText,Fi as listDirectories,Bi as listFiles,gp as loginUser,w as makeGraphQLRequest,zp as mapColumnsToAttributes,vp as mapColumnsToIdentifiers,Ep as mapCsvColumnsToApi,Sp as mapCsvRowsToRequestInputs,la as mapEnumValues,Ip as mapRequestEnumValues,Ii as markCronIdentifierCompleted,Di as markRequestDataSiloIdsCompleted,Np as markSilentPrivacyRequests,ta as mergeTranscendInputs,yp as name,$p as normalizeIdentifierValue,qp as notifyPrivacyRequestsAdditionalTime,Ea as parseAssessmentDisplayLogic,Oa as parseAssessmentRiskLogic,fa as parseAttributesFromString,Li as parseFilePath,xi as parseVariablesFromString,Qi as pullAllDatapoints,$i as pullChunkedCustomSiloOutstandingIdentifiers,pi as pullConsentManagerMetrics,wi as pullCronPageOfIdentifiers,Ui as pullManualEnrichmentIdentifiersToCsv,ei as pullPrivacyRequests,ka as pullTranscendConfiguration,Gi as pullUnstructuredSubDataPointRecommendations,Oi as pushCronIdentifiersFromCsv,Vi as pushManualEnrichmentIdentifiersFromCsv,Pa as readCsv,Pe as readTranscendYaml,Pm as removeLinks,ni as removeUnverifiedRequestIdentifiers,fe as replaceVariablesInYaml,f as reportPromptRun,Zp as restartPrivacyRequest,ti as retryRequestDataSilos,Ya as retryRequestEnricher,Xa as setResourceAttributes,Xp as skipPreflightJobs,ri as skipRequestDataSilos,ua as splitCsvToList,Gp as streamPrivacyRequestFiles,Hp as submitPrivacyRequest,To as syncAction,Eo as syncActionItemCollections,$o as syncActionItems,Uo as syncAgentFiles,Fo as syncAgentFunctions,Mo as syncAgents,ys as syncAttribute,lo as syncBusinessEntities,qa as syncCodePackages,Yo as syncConfigurationToTranscend,oo as syncConsentManager,so as syncConsentManagerExperiences,Qs as syncCookies,Jo as syncDataCategories,Po as syncDataFlows,Is as syncDataSiloDependencies,Es as syncDataSilos,Us as syncDataSubject,As as syncEnricher,Ps as syncIdentifier,Ys as syncIntlMessages,ro as syncPartitions,Ks as syncPolicies,to as syncPrivacyCenter,Xo as syncProcessingPurposes,_s as syncPrompts,ja as syncRepositories,Qa as syncSoftwareDevelopmentKits,yo as syncTemplate,qo as syncVendors,Do as updateActionItem,No as updateActionItemCollection,Go as updateAgentFiles,Bo as updateAgentFunctions,Co as updateAgents,go as updateBusinessEntities,Va as updateCodePackages,Tp as updateConsentManagerToLatest,si as updateConsentManagerVersionToLatest,zo as updateDataCategories,ho as updateDataFlows,Xs as updateIntlMessages,Fs as updateOrCreateCookies,Zs as updatePolicies,Ko as updateProcessingPurposes,vs as updatePrompts,Ua as updateRepositories,Fa as updateSoftwareDevelopmentKits,Vo as updateVendors,Pi as uploadConsents,ai as uploadCookiesFromCsv,oi as uploadDataFlowsFromCsv,Wp as uploadPrivacyRequestsFromCsv,va as uploadSiloDiscoveryResults,ki as validateTranscendAuth,Wa as version,Mi as writeCsv,Ri as writeCsvSync,Ni as writeLargeCsv,Te as writeTranscendYaml};