@transcend-io/cli 10.3.7 → 10.4.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 (153) hide show
  1. package/dist/{app-DC4zcY_g.mjs → app-knv-qziw.mjs} +17 -17
  2. package/dist/{app-DC4zcY_g.mjs.map → app-knv-qziw.mjs.map} +1 -1
  3. package/dist/{approvePrivacyRequests-BR5mcuSb.mjs → approvePrivacyRequests-DchF0x4j.mjs} +2 -2
  4. package/dist/{approvePrivacyRequests-BR5mcuSb.mjs.map → approvePrivacyRequests-DchF0x4j.mjs.map} +1 -1
  5. package/dist/bin/bash-complete.mjs +1 -1
  6. package/dist/bin/cli.mjs +1 -1
  7. package/dist/bin/deprecated-command.mjs +1 -1
  8. package/dist/{buildXdiSyncEndpoint-CJRPTf_i.mjs → buildXdiSyncEndpoint-BoV3Zaen.mjs} +2 -2
  9. package/dist/{buildXdiSyncEndpoint-CJRPTf_i.mjs.map → buildXdiSyncEndpoint-BoV3Zaen.mjs.map} +1 -1
  10. package/dist/{bulkRestartRequests-BJkf409e.mjs → bulkRestartRequests-B_T71-zF.mjs} +2 -2
  11. package/dist/{bulkRestartRequests-BJkf409e.mjs.map → bulkRestartRequests-B_T71-zF.mjs.map} +1 -1
  12. package/dist/{bulkRetryEnrichers-BBb-zG0P.mjs → bulkRetryEnrichers-C0PFRtA4.mjs} +2 -2
  13. package/dist/{bulkRetryEnrichers-BBb-zG0P.mjs.map → bulkRetryEnrichers-C0PFRtA4.mjs.map} +1 -1
  14. package/dist/{cancelPrivacyRequests-Db7Fo9NS.mjs → cancelPrivacyRequests-BWa-CsAX.mjs} +2 -2
  15. package/dist/{cancelPrivacyRequests-Db7Fo9NS.mjs.map → cancelPrivacyRequests-BWa-CsAX.mjs.map} +1 -1
  16. package/dist/codecs-B2mV72Wn.mjs +2 -0
  17. package/dist/codecs-B2mV72Wn.mjs.map +1 -0
  18. package/dist/{command-Cn-VTtF3.mjs → command-gTick4qw.mjs} +2 -2
  19. package/dist/{command-Cn-VTtF3.mjs.map → command-gTick4qw.mjs.map} +1 -1
  20. package/dist/{constants-BwO3d-v4.mjs → constants-BdUSsxl7.mjs} +2 -2
  21. package/dist/{constants-BwO3d-v4.mjs.map → constants-BdUSsxl7.mjs.map} +1 -1
  22. package/dist/{createExtraKeyHandler-Dij3MUwV.mjs → createExtraKeyHandler-z_vOVjvJ.mjs} +2 -2
  23. package/dist/{createExtraKeyHandler-Dij3MUwV.mjs.map → createExtraKeyHandler-z_vOVjvJ.mjs.map} +1 -1
  24. package/dist/{downloadPrivacyRequestFiles-CefkB8a5.mjs → downloadPrivacyRequestFiles-3IOspTTF.mjs} +2 -2
  25. package/dist/{downloadPrivacyRequestFiles-CefkB8a5.mjs.map → downloadPrivacyRequestFiles-3IOspTTF.mjs.map} +1 -1
  26. package/dist/{generateCrossAccountApiKeys-DagMZcM2.mjs → generateCrossAccountApiKeys-C1Ur0dUu.mjs} +2 -2
  27. package/dist/{generateCrossAccountApiKeys-DagMZcM2.mjs.map → generateCrossAccountApiKeys-C1Ur0dUu.mjs.map} +1 -1
  28. package/dist/{impl-DiKox85s.mjs → impl-B-8JVXdv.mjs} +2 -2
  29. package/dist/{impl-DiKox85s.mjs.map → impl-B-8JVXdv.mjs.map} +1 -1
  30. package/dist/{impl-BcfULoIK.mjs → impl-B-zQ-FUr.mjs} +2 -2
  31. package/dist/{impl-BcfULoIK.mjs.map → impl-B-zQ-FUr.mjs.map} +1 -1
  32. package/dist/{impl-DYpUCEVK.mjs → impl-B3gYrxa2.mjs} +2 -2
  33. package/dist/{impl-DYpUCEVK.mjs.map → impl-B3gYrxa2.mjs.map} +1 -1
  34. package/dist/{impl-4Kqq4OG_.mjs → impl-BM99XtUo.mjs} +2 -2
  35. package/dist/{impl-4Kqq4OG_.mjs.map → impl-BM99XtUo.mjs.map} +1 -1
  36. package/dist/{impl-3VLH9aat.mjs → impl-BW3HCdPO.mjs} +2 -2
  37. package/dist/{impl-3VLH9aat.mjs.map → impl-BW3HCdPO.mjs.map} +1 -1
  38. package/dist/{impl-BVFZzEl0.mjs → impl-Bc2SVjkt.mjs} +2 -2
  39. package/dist/{impl-BVFZzEl0.mjs.map → impl-Bc2SVjkt.mjs.map} +1 -1
  40. package/dist/{impl-Dw6kpn3N.mjs → impl-BfE1HnL0.mjs} +2 -2
  41. package/dist/{impl-Dw6kpn3N.mjs.map → impl-BfE1HnL0.mjs.map} +1 -1
  42. package/dist/{impl-AYA5nkrH.mjs → impl-BfuCzBwc.mjs} +2 -2
  43. package/dist/{impl-AYA5nkrH.mjs.map → impl-BfuCzBwc.mjs.map} +1 -1
  44. package/dist/{impl-EZjeJf1t.mjs → impl-Bgplt-MN.mjs} +2 -2
  45. package/dist/{impl-EZjeJf1t.mjs.map → impl-Bgplt-MN.mjs.map} +1 -1
  46. package/dist/{impl-BOlPPm1_.mjs → impl-BjCRJ_Ro.mjs} +2 -2
  47. package/dist/{impl-BOlPPm1_.mjs.map → impl-BjCRJ_Ro.mjs.map} +1 -1
  48. package/dist/{impl-6mCOBlSD.mjs → impl-BuxT4Cx2.mjs} +2 -2
  49. package/dist/{impl-6mCOBlSD.mjs.map → impl-BuxT4Cx2.mjs.map} +1 -1
  50. package/dist/{impl-B4tnfMOy.mjs → impl-CEE-oyAh.mjs} +2 -2
  51. package/dist/{impl-B4tnfMOy.mjs.map → impl-CEE-oyAh.mjs.map} +1 -1
  52. package/dist/{impl-yMumZUUX.mjs → impl-CFYxHmDT.mjs} +2 -2
  53. package/dist/{impl-yMumZUUX.mjs.map → impl-CFYxHmDT.mjs.map} +1 -1
  54. package/dist/{impl-BT24mDbc.mjs → impl-CMHKXlyi.mjs} +2 -2
  55. package/dist/{impl-BT24mDbc.mjs.map → impl-CMHKXlyi.mjs.map} +1 -1
  56. package/dist/{impl-FHDP6V7y.mjs → impl-CMLnr_dJ.mjs} +2 -2
  57. package/dist/{impl-FHDP6V7y.mjs.map → impl-CMLnr_dJ.mjs.map} +1 -1
  58. package/dist/{impl-CLY8393N.mjs → impl-CU2KBTzQ.mjs} +2 -2
  59. package/dist/{impl-CLY8393N.mjs.map → impl-CU2KBTzQ.mjs.map} +1 -1
  60. package/dist/{impl-CBkjBv2h.mjs → impl-C_SmP_1D.mjs} +2 -2
  61. package/dist/{impl-CBkjBv2h.mjs.map → impl-C_SmP_1D.mjs.map} +1 -1
  62. package/dist/{impl-PRTbuj2u.mjs → impl-Caf4LkhO.mjs} +2 -2
  63. package/dist/{impl-PRTbuj2u.mjs.map → impl-Caf4LkhO.mjs.map} +1 -1
  64. package/dist/{impl-DPcCMYIP.mjs → impl-Cb6Ll7As.mjs} +2 -2
  65. package/dist/{impl-DPcCMYIP.mjs.map → impl-Cb6Ll7As.mjs.map} +1 -1
  66. package/dist/{impl-CbiBteol.mjs → impl-D-AC7eVN.mjs} +2 -2
  67. package/dist/{impl-CbiBteol.mjs.map → impl-D-AC7eVN.mjs.map} +1 -1
  68. package/dist/{impl-CR7fxnKR.mjs → impl-D2uNMQti.mjs} +2 -2
  69. package/dist/{impl-CR7fxnKR.mjs.map → impl-D2uNMQti.mjs.map} +1 -1
  70. package/dist/{impl-BsGGcGT_.mjs → impl-D6eEb_ZD.mjs} +2 -2
  71. package/dist/{impl-BsGGcGT_.mjs.map → impl-D6eEb_ZD.mjs.map} +1 -1
  72. package/dist/{impl-CS2JaSVh.mjs → impl-DBn8mI6Y.mjs} +2 -2
  73. package/dist/{impl-CS2JaSVh.mjs.map → impl-DBn8mI6Y.mjs.map} +1 -1
  74. package/dist/{impl-CzvCA0Ev.mjs → impl-DCC9QQh4.mjs} +2 -2
  75. package/dist/{impl-CzvCA0Ev.mjs.map → impl-DCC9QQh4.mjs.map} +1 -1
  76. package/dist/{impl-CsmJAEgl.mjs → impl-Da91eO6c.mjs} +2 -2
  77. package/dist/{impl-CsmJAEgl.mjs.map → impl-Da91eO6c.mjs.map} +1 -1
  78. package/dist/{impl-D7PCRhwW.mjs → impl-Dd9PNmnj.mjs} +2 -2
  79. package/dist/{impl-D7PCRhwW.mjs.map → impl-Dd9PNmnj.mjs.map} +1 -1
  80. package/dist/{impl-BHjKTJGy.mjs → impl-FGgtoSGh.mjs} +2 -2
  81. package/dist/{impl-BHjKTJGy.mjs.map → impl-FGgtoSGh.mjs.map} +1 -1
  82. package/dist/{impl-CfrSm_z0.mjs → impl-FaO5m2ZA.mjs} +2 -2
  83. package/dist/{impl-CfrSm_z0.mjs.map → impl-FaO5m2ZA.mjs.map} +1 -1
  84. package/dist/{impl-D2YsAVUe.mjs → impl-QhHyvRrI.mjs} +2 -2
  85. package/dist/{impl-D2YsAVUe.mjs.map → impl-QhHyvRrI.mjs.map} +1 -1
  86. package/dist/{impl-DE2SWsi9.mjs → impl-SC3Sd_WY.mjs} +2 -2
  87. package/dist/{impl-DE2SWsi9.mjs.map → impl-SC3Sd_WY.mjs.map} +1 -1
  88. package/dist/{impl-DtSjX73X.mjs → impl-XUHSnqZ5.mjs} +2 -2
  89. package/dist/{impl-DtSjX73X.mjs.map → impl-XUHSnqZ5.mjs.map} +1 -1
  90. package/dist/{impl-COFkWKPV.mjs → impl-Xt0ep5VB.mjs} +2 -2
  91. package/dist/{impl-COFkWKPV.mjs.map → impl-Xt0ep5VB.mjs.map} +1 -1
  92. package/dist/{impl-COK4NOqq.mjs → impl-kTBV35kE.mjs} +2 -2
  93. package/dist/{impl-COK4NOqq.mjs.map → impl-kTBV35kE.mjs.map} +1 -1
  94. package/dist/{impl-CW2qSrFu.mjs → impl-lfiVeiMu.mjs} +2 -2
  95. package/dist/{impl-CW2qSrFu.mjs.map → impl-lfiVeiMu.mjs.map} +1 -1
  96. package/dist/{impl-DhVBzuLn.mjs → impl-luWxLWgr.mjs} +2 -2
  97. package/dist/{impl-DhVBzuLn.mjs.map → impl-luWxLWgr.mjs.map} +1 -1
  98. package/dist/{impl-CmrM1-3B.mjs → impl-rDNt9Mpe.mjs} +2 -2
  99. package/dist/{impl-CmrM1-3B.mjs.map → impl-rDNt9Mpe.mjs.map} +1 -1
  100. package/dist/{impl-BvOxkh7J.mjs → impl-yxfzym_k.mjs} +2 -2
  101. package/dist/{impl-BvOxkh7J.mjs.map → impl-yxfzym_k.mjs.map} +1 -1
  102. package/dist/index.d.mts +21 -5
  103. package/dist/index.d.mts.map +1 -1
  104. package/dist/index.mjs +3 -3
  105. package/dist/index.mjs.map +1 -1
  106. package/dist/{markRequestDataSiloIdsCompleted-URGUyr71.mjs → markRequestDataSiloIdsCompleted-nKo6RUOH.mjs} +2 -2
  107. package/dist/{markRequestDataSiloIdsCompleted-URGUyr71.mjs.map → markRequestDataSiloIdsCompleted-nKo6RUOH.mjs.map} +1 -1
  108. package/dist/{markSilentPrivacyRequests-DDKRgQdo.mjs → markSilentPrivacyRequests-DCrw92hR.mjs} +2 -2
  109. package/dist/{markSilentPrivacyRequests-DDKRgQdo.mjs.map → markSilentPrivacyRequests-DCrw92hR.mjs.map} +1 -1
  110. package/dist/{notifyPrivacyRequestsAdditionalTime-BFkab0tk.mjs → notifyPrivacyRequestsAdditionalTime-Dl6QYo_s.mjs} +2 -2
  111. package/dist/{notifyPrivacyRequestsAdditionalTime-BFkab0tk.mjs.map → notifyPrivacyRequestsAdditionalTime-Dl6QYo_s.mjs.map} +1 -1
  112. package/dist/pullChunkedCustomSiloOutstandingIdentifiers-C0uKFWhl.mjs +2 -0
  113. package/dist/pullChunkedCustomSiloOutstandingIdentifiers-C0uKFWhl.mjs.map +1 -0
  114. package/dist/{pullManualEnrichmentIdentifiersToCsv-DIQYZwZX.mjs → pullManualEnrichmentIdentifiersToCsv-CJJ_a_U6.mjs} +2 -2
  115. package/dist/{pullManualEnrichmentIdentifiersToCsv-DIQYZwZX.mjs.map → pullManualEnrichmentIdentifiersToCsv-CJJ_a_U6.mjs.map} +1 -1
  116. package/dist/{pullTranscendConfiguration-DjOELnPo.mjs → pullTranscendConfiguration-CofsMdIn.mjs} +2 -2
  117. package/dist/pullTranscendConfiguration-CofsMdIn.mjs.map +1 -0
  118. package/dist/{pushCronIdentifiersFromCsv-XwHKe623.mjs → pushCronIdentifiersFromCsv-Q5r4KNyE.mjs} +2 -2
  119. package/dist/{pushCronIdentifiersFromCsv-XwHKe623.mjs.map → pushCronIdentifiersFromCsv-Q5r4KNyE.mjs.map} +1 -1
  120. package/dist/{pushManualEnrichmentIdentifiersFromCsv-C5QN586O.mjs → pushManualEnrichmentIdentifiersFromCsv-BKtLAoqI.mjs} +2 -2
  121. package/dist/{pushManualEnrichmentIdentifiersFromCsv-C5QN586O.mjs.map → pushManualEnrichmentIdentifiersFromCsv-BKtLAoqI.mjs.map} +1 -1
  122. package/dist/{readTranscendYaml-DVkQL2SC.mjs → readTranscendYaml-BbnEGgVD.mjs} +2 -2
  123. package/dist/{readTranscendYaml-DVkQL2SC.mjs.map → readTranscendYaml-BbnEGgVD.mjs.map} +1 -1
  124. package/dist/{removeUnverifiedRequestIdentifiers-we9LWcF7.mjs → removeUnverifiedRequestIdentifiers-2ONNTCBT.mjs} +2 -2
  125. package/dist/{removeUnverifiedRequestIdentifiers-we9LWcF7.mjs.map → removeUnverifiedRequestIdentifiers-2ONNTCBT.mjs.map} +1 -1
  126. package/dist/{retryRequestDataSilos-BDOgvAdo.mjs → retryRequestDataSilos-C3lrYsJt.mjs} +2 -2
  127. package/dist/{retryRequestDataSilos-BDOgvAdo.mjs.map → retryRequestDataSilos-C3lrYsJt.mjs.map} +1 -1
  128. package/dist/{skipPreflightJobs-DdDHTAdy.mjs → skipPreflightJobs-BVW8pJNW.mjs} +2 -2
  129. package/dist/{skipPreflightJobs-DdDHTAdy.mjs.map → skipPreflightJobs-BVW8pJNW.mjs.map} +1 -1
  130. package/dist/{skipRequestDataSilos-Du5DBheH.mjs → skipRequestDataSilos-rMT0Nou7.mjs} +2 -2
  131. package/dist/{skipRequestDataSilos-Du5DBheH.mjs.map → skipRequestDataSilos-rMT0Nou7.mjs.map} +1 -1
  132. package/dist/{streamPrivacyRequestsToCsv-C-mu3l9p.mjs → streamPrivacyRequestsToCsv-BaZKrjn-.mjs} +2 -2
  133. package/dist/{streamPrivacyRequestsToCsv-C-mu3l9p.mjs.map → streamPrivacyRequestsToCsv-BaZKrjn-.mjs.map} +1 -1
  134. package/dist/{updateConsentManagerVersionToLatest-BxE5VOqU.mjs → updateConsentManagerVersionToLatest-Di0JWUY5.mjs} +2 -2
  135. package/dist/{updateConsentManagerVersionToLatest-BxE5VOqU.mjs.map → updateConsentManagerVersionToLatest-Di0JWUY5.mjs.map} +1 -1
  136. package/dist/uploadConsents-CQOPzizv.mjs +2 -0
  137. package/dist/uploadConsents-CQOPzizv.mjs.map +1 -0
  138. package/dist/{uploadCookiesFromCsv-DEBd330a.mjs → uploadCookiesFromCsv-BvyfDsJQ.mjs} +2 -2
  139. package/dist/{uploadCookiesFromCsv-DEBd330a.mjs.map → uploadCookiesFromCsv-BvyfDsJQ.mjs.map} +1 -1
  140. package/dist/{uploadDataFlowsFromCsv-nAEg26Sb.mjs → uploadDataFlowsFromCsv-DbLfSBwL.mjs} +2 -2
  141. package/dist/{uploadDataFlowsFromCsv-nAEg26Sb.mjs.map → uploadDataFlowsFromCsv-DbLfSBwL.mjs.map} +1 -1
  142. package/dist/{uploadPrivacyRequestsFromCsv-bUQKEJWa.mjs → uploadPrivacyRequestsFromCsv-CXpI6D7r.mjs} +2 -2
  143. package/dist/{uploadPrivacyRequestsFromCsv-bUQKEJWa.mjs.map → uploadPrivacyRequestsFromCsv-CXpI6D7r.mjs.map} +1 -1
  144. package/dist/{validateTranscendAuth-Cuh2Qfdl.mjs → validateTranscendAuth-BHw0WQu1.mjs} +2 -2
  145. package/dist/{validateTranscendAuth-Cuh2Qfdl.mjs.map → validateTranscendAuth-BHw0WQu1.mjs.map} +1 -1
  146. package/package.json +4 -4
  147. package/dist/codecs-CeDPaLYa.mjs +0 -2
  148. package/dist/codecs-CeDPaLYa.mjs.map +0 -1
  149. package/dist/pullChunkedCustomSiloOutstandingIdentifiers-bTV3ivr9.mjs +0 -2
  150. package/dist/pullChunkedCustomSiloOutstandingIdentifiers-bTV3ivr9.mjs.map +0 -1
  151. package/dist/pullTranscendConfiguration-DjOELnPo.mjs.map +0 -1
  152. package/dist/uploadConsents-BgB4l-nb.mjs +0 -2
  153. package/dist/uploadConsents-BgB4l-nb.mjs.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import{a as e,i as t,n,o as r,r as i,t as a}from"./enums-CyFTrzXY.mjs";import{a as o,c as s,d as c,f as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b}from"./constants-BwO3d-v4.mjs";import{t as x}from"./logger-Bj782ZYD.mjs";import{$ as S,A as ee,B as te,C as ne,D as re,E as ie,F as ae,G as oe,H as se,I as ce,J as le,K as ue,L as de,M as fe,N as pe,O as me,P as he,Q as ge,R as _e,S as ve,T as ye,U as be,V as C,W as w,X as T,Y as E,Z as D,_ as O,_t as k,a as A,at as j,b as M,bt as N,c as xe,ct as Se,d as Ce,dt as we,et as Te,f as Ee,ft as De,g as Oe,gt as ke,h as Ae,ht as je,i as Me,it as Ne,j as Pe,k as Fe,l as Ie,lt as Le,m as Re,mt as ze,n as Be,nt as Ve,o as He,ot as Ue,p as We,pt as Ge,q as Ke,r as qe,rt as Je,s as Ye,st as Xe,t as Ze,tt as Qe,u as $e,ut as et,v as tt,vt as nt,w as rt,x as it,xt as at,y as ot,yt as st,z as ct}from"./codecs-CeDPaLYa.mjs";import{a as lt,i as ut,n as dt,r as ft,t as pt}from"./readTranscendYaml-DVkQL2SC.mjs";import{a as mt,i as ht,n as gt,r as _t,t as vt}from"./parseVariablesFromString-BeKOGw5n.mjs";import{a as yt,c as bt,i as xt,l as St,n as Ct,o as wt,r as Tt,s as Et,t as Dt,u as Ot}from"./constants-ClkQQhJs.mjs";import{i as kt,n as At,r as jt,t as Mt}from"./parseAttributesFromString-D1Yl0xwT.mjs";import{a as Nt,c as Pt,d as Ft,f as It,i as Lt,l as Rt,n as zt,o as Bt,r as Vt,s as Ht,t as Ut,u as Wt}from"./uploadPrivacyRequestsFromCsv-bUQKEJWa.mjs";import{t as Gt}from"./readCsv-C4TyEs-r.mjs";import{n as Kt,t as qt}from"./pullUnstructuredSubDataPointRecommendations-D0z-vPgq.mjs";import{a as Jt,i as Yt,n as Xt,o as Zt,r as Qt,t as $t}from"./request-DfkRPQFr.mjs";import{i as en,n as tn,r as nn,t as rn}from"./pullTranscendConfiguration-DjOELnPo.mjs";import{i as an,n as on,r as P,t as sn}from"./fetchAllRequests-CHHdyb4Q.mjs";import{i as cn,n as ln,r as un,t as dn}from"./pullChunkedCustomSiloOutstandingIdentifiers-bTV3ivr9.mjs";import{n as fn,r as pn,t as mn}from"./syncCodePackages-CAk_Hjyl.mjs";import{t as hn}from"./markSilentPrivacyRequests-DDKRgQdo.mjs";import{a as gn,i as _n,n as vn,o as yn,r as bn,t as xn}from"./downloadPrivacyRequestFiles-CefkB8a5.mjs";import{n as Sn,r as Cn,t as wn}from"./extractClientError-i-Tw_az7.mjs";import{t as Tn}from"./approvePrivacyRequests-BR5mcuSb.mjs";import{t as En}from"./notifyPrivacyRequestsAdditionalTime-BFkab0tk.mjs";import{t as Dn}from"./cancelPrivacyRequests-Db7Fo9NS.mjs";import{n as On,t as kn}from"./bulkRestartRequests-BJkf409e.mjs";import{t as An}from"./skipPreflightJobs-DdDHTAdy.mjs";import{t as jn}from"./bulkRetryEnrichers-BBb-zG0P.mjs";import{t as Mn}from"./retryRequestDataSilos-BDOgvAdo.mjs";import{n as F,t as Nn}from"./streamPrivacyRequestsToCsv-C-mu3l9p.mjs";import{n as Pn,r as Fn,t as In}from"./inquirer-BqZXFEt1.mjs";import{t as Ln}from"./collectParquetFilesOrExit-BJiAyaQ5.mjs";import{t as Rn}from"./collectCsvFilesOrExit-CbtyKAzu.mjs";import{t as zn}from"./parquetToCsvOneFile-B84XXInh.mjs";import{a as Bn,i as Vn,n as Hn,o as Un,r as Wn,s as Gn,t as Kn}from"./writeCsv-C4pjXGsD.mjs";import{t as qn}from"./skipRequestDataSilos-Du5DBheH.mjs";import{t as Jn}from"./removeUnverifiedRequestIdentifiers-we9LWcF7.mjs";import{t as Yn}from"./updateConsentManagerVersionToLatest-BxE5VOqU.mjs";import{t as Xn}from"./uploadDataFlowsFromCsv-nAEg26Sb.mjs";import{t as Zn}from"./uploadCookiesFromCsv-DEBd330a.mjs";import{t as Qn}from"./pullConsentManagerMetrics-zKgjc3Ap.mjs";import{n as $n,r as er,t as tr}from"./buildXdiSyncEndpoint-CJRPTf_i.mjs";import{t as nr}from"./consentManagersToBusinessEntities-BdKDganK.mjs";import{i as rr,n as ir,r as ar,t as or}from"./uploadConsents-BgB4l-nb.mjs";import{n as sr,r as cr,t as lr}from"./pushCronIdentifiersFromCsv-XwHKe623.mjs";import{t as ur}from"./markRequestDataSiloIdsCompleted-URGUyr71.mjs";import{t as dr}from"./generateCrossAccountApiKeys-DagMZcM2.mjs";import{t as fr}from"./validateTranscendAuth-Cuh2Qfdl.mjs";import{t as pr}from"./listFiles-D2wMHnEr.mjs";import{t as mr}from"./pullAllDatapoints-Bbmky50p.mjs";import{t as hr}from"./pullManualEnrichmentIdentifiersToCsv-DIQYZwZX.mjs";import{n as gr,r as _r,t as vr}from"./pushManualEnrichmentIdentifiersFromCsv-C5QN586O.mjs";import{ChatCompletionRole as I,PromptRunProductArea as L,PromptStatus as R,QueueStatus as z}from"@transcend-io/privacy-types";import{chunk as B,difference as yr,groupBy as br,keyBy as V,uniq as xr}from"lodash-es";import{apply as Sr,decodeCodec as H,getValues as Cr}from"@transcend-io/type-utils";import{readFileSync as wr,readdirSync as Tr,statSync as Er}from"node:fs";import{join as Dr}from"node:path";import U from"colors";import{UPDATE_OR_CREATE_COOKIES as Or,buildTranscendGraphQLClient as W,createSombraGotInstance as kr,fetchAllAgentFiles as Ar,fetchAllAgents as G,fetchAllLargeLanguageModels as jr,fetchAllPromptThreads as Mr,fetchAllRequestIdentifiers as Nr,fetchConsentManagerId as Pr,fetchPromptsWithVariables as Fr,makeGraphQLRequest as Ir,reportPromptRun as K,validateSombraVersion as Lr}from"@transcend-io/sdk";import{map as q,mapSeries as J}from"@transcend-io/utils";import{createHandlebarsWithHelpers as Y}from"@transcend-io/handlebars-utils";import{execSync as X}from"child_process";import Rr from"fast-glob";async function Z(e,t){let n=await Pr(e,{logger:x});await J(B(t,100),async t=>{await Ir(e,Or,{variables:{airgapBundleId:n,cookies:t.map(e=>({name:e.name,trackingPurposes:e.trackingPurposes&&e.trackingPurposes.length>0?e.trackingPurposes:void 0,description:e.description,service:e.service,status:e.status,attributes:e.attributes,isRegex:e.isRegex}))},logger:x})})}async function zr(e,t){let n=!1;x.info(U.magenta(`Syncing "${t.length}" cookies...`));let r=t.filter(e=>t.filter(t=>e.name===t.name&&e.isRegex===t.isRegex).length>1);if(r.length>0)throw Error(`Failed to upload cookies as there were non-unique entries found: ${r.map(({name:e})=>e).join(`,`)}`);try{x.info(U.magenta(`Upserting "${t.length}" new cookies...`)),await Z(e,t),x.info(U.green(`Successfully synced ${t.length} cookies!`))}catch(e){n=!0,x.error(U.red(`Failed to create cookies! - ${e.message}`))}return!n}function Br(e,t,n){let r=e.getTime(),i=t.getTime(),a=(i-r)/n;return Array.from({length:n},(e,t)=>({createdAtAfter:new Date(r+a*t),createdAtBefore:new Date(t===n-1?i:r+a*(t+1))}))}async function Vr({auth:e,sombraAuth:t,actions:n=[],statuses:r=[],identifierSearch:i,pageLimit:a=100,concurrency:s=1,transcendUrl:c=o,createdAtBefore:l,skipRequestIdentifiers:u=!1,createdAtAfter:d,updatedAtBefore:f,updatedAtAfter:p,isTest:m}){let h=W(c,e),g=await kr(c,e,{logger:x,sombraApiKey:t,sombraUrl:process.env.SOMBRA_URL}),_=``;l&&(_+=` before ${l.toISOString()}`),d&&(_+=`${_?`, and`:``} after ${d.toISOString()}`),x.info(U.magenta(`${n.length>0?`Pulling requests of type "${n.join(`" , "`)}"`:`Pulling all requests`}${_}`));let v=s>1&&d&&l,y=v?Br(d,l,s):[{createdAtAfter:d,createdAtBefore:l}];v&&x.info(U.magenta(`Splitting date range into ${s} parallel chunks`));let b=(await q(y,e=>P(h,{actions:n,text:i,statuses:r,createdAtBefore:e.createdAtBefore,createdAtAfter:e.createdAtAfter,updatedAtBefore:f,updatedAtAfter:p,isTest:m}),{concurrency:v?s:1})).flat();u||await Lr(h,{logger:x});let S=u?b.map(e=>({...e,requestIdentifiers:[]})):await q(b,async e=>{let t=await Nr(h,g,{filterBy:{requestId:e.id},skipSombraCheck:!0,logger:x});return{...e,requestIdentifiers:t}},{concurrency:a});return x.info(U.magenta(`Pulled ${S.length} requests`)),{requestsWithRequestIdentifiers:S,requestsFormattedForCsv:S.map(F)}}function Hr(e){try{return e?wr(e,`utf8`):``}catch{return``}}function Ur(e){return Tr(e).filter(t=>Er(Dr(e,t)).isDirectory())}function Q(e){return RegExp(`<${e}>([\\s\\S]+?)<\\/${e}>`)}function Wr(e){return e}const $=e=>{try{return JSON.parse(e)}catch{return e}};var Gr=class{prompts;handlebarsOptions;promptContentMap;largeLanguageModels=[];agentsByName={};agentsByAgentId={};graphQLClient;defaultVariables;variables;handlebars;transcendApiKey;transcendUrl;requireApproval;cacheDuration;lastUpdatedAt;constructor({prompts:e,handlebarsOptions:t={},transcendUrl:n=o,transcendApiKey:r,requireApproval:i=!0,cacheDuration:a,defaultVariables:s={}}){this.prompts=e,this.transcendUrl=n,this.transcendApiKey=r,this.variables=s,this.defaultVariables=s,this.graphQLClient=W(n,typeof r==`object`?r.release():r),this.requireApproval=i,this.cacheDuration=a,this.handlebarsOptions=t,this.handlebars=Y(t)}async fetchPromptsAndMetadata(){let e=Cr(this.prompts),t=e.map(({id:e})=>e).filter(e=>!!e),n=e.map(({title:e})=>e).filter(e=>!!e),r=xr(e.map(({agentNames:e})=>e||[]).flat()),[i,a,o]=await Promise.all([Fr(this.graphQLClient,{logger:x,filterBy:{ids:t,titles:n}}),jr(this.graphQLClient,{logger:x}),G(this.graphQLClient,{logger:x,filterBy:{names:r}})]);this.agentsByName=V(o,`name`),this.agentsByAgentId=V(o,`agentId`),this.largeLanguageModels=a.filter(e=>e.isTranscendHosted===!1);let s=V(i.prompts,`title`),c=V(i.prompts,`id`);return this.variables={...i.calculatedVariables.reduce((e,t)=>Object.assign(e,{[t.name]:t.data?JSON.parse(t.data):t.data}),{}),...this.defaultVariables},this.handlebars=Y({...this.handlebarsOptions,templates:[...this.handlebarsOptions.templates||[],...i.promptPartials.map(e=>({name:e.slug,content:e.content}))]}),this.promptContentMap=Sr(this.prompts,({id:e,title:t})=>{let n=e?c[e]:t?s[t]:void 0;if(!n)throw Error(`Failed to find prompt with title: "${t}" and id: "${e}"`);return n}),this.lastUpdatedAt=new Date,i}async getAgentByName(e){let t=this.agentsByName[e];if(t)return t;let[n]=await G(this.graphQLClient,{logger:x,filterBy:{names:[e]}});if(n)return this.agentsByName[n.name]=n,this.agentsByAgentId[n.agentId]=n,n}async getPromptThreadBySlackTs(e){let[t]=await Mr(this.graphQLClient,{logger:x,filterBy:{slackMessageTs:[e]}});return t}async getAgentsByName(e){if(e.length<1)throw Error(`Expected at least one name to be provided`);let{hasCache:t=[],missingCache:n=[]}=br(e,e=>this.agentsByName[e]?`hasCache`:`missingCache`),r=t.map(e=>this.agentsByName[e]);if(n.length===0)return r;let i=B(n,50),a=[];return await J(i,async e=>{let t=await G(this.graphQLClient,{logger:x,filterBy:{names:e}});t.forEach(e=>{this.agentsByName[e.name]=e,this.agentsByAgentId[e.agentId]=e}),a.push(...t)}),[...r,...a]}getAgentFiles(e){return Ar(this.graphQLClient,{logger:x,filterBy:e})}getLargeLanguageModel(e){let t=this.largeLanguageModels.find(t=>typeof e==`string`?t.id===e:t.name===e.name&&t.client===e.client);if(!t)throw Error(`Failed to find model matching: ${typeof e==`string`?e:JSON.stringify(e)}`);return t}async getPromptDefinition(e){(!this.lastUpdatedAt||this.cacheDuration===0||this.cacheDuration&&Date.now()-this.lastUpdatedAt.getTime()>this.cacheDuration)&&await this.fetchPromptsAndMetadata();let{promptContentMap:t}=this;if(!t)throw Error(`Expected this.promptContentMap to be defined`);let n=t[e];if(!n)throw Error(`Expected this.promptContentMap[${e}] to be defined`);return n}async compilePrompt(e,t){let n=await this.getPromptDefinition(e),r=this.prompts[e];if(!r)throw Error(`Expected this.prompts[${e}] to be defined`);if(this.requireApproval&&n.status!==R.Approved)throw Error(`Assessment "${n.title}" cannot be used because its in status: "${n.status}"`);if(n.status===R.Rejected)throw Error(`Assessment "${n.title}" cannot be used because it's in status: "${n.status}"`);return H(r.paramCodec,t),this.handlebars.compile(n.content)({currentDate:new Date().toISOString(),...this.variables,...t})}parseAiResponse(e,t){let n=this.prompts[e];if(!n)throw Error(`Expected this.prompts[${e}] to be defined`);let r=n.extractFromTag&&(Q(n.extractFromTag).exec(t)||[])[1]||t;return H(n.outputCodec,$(r),!1)}async reportAndParsePromptRun(e,{largeLanguageModel:t,...n}){(!this.lastUpdatedAt||this.cacheDuration===0||this.cacheDuration&&Date.now()-this.lastUpdatedAt.getTime()>this.cacheDuration)&&await this.fetchPromptsAndMetadata();let r=n.name||`@transcend-io/cli-prompt-run-${new Date().toISOString()}`;if(!this.promptContentMap)throw Error(`Expected this.promptContentMap to be defined`);let i=this.promptContentMap[e];if(!i)throw Error(`Expected this.prompts[${e}] to be defined`);if(n.promptRunMessages.length===0)throw Error(`promptRunMessages is expected to have length > 0`);if(n.promptRunMessages[0].role!==I.System)throw Error(`promptRunMessages[0].role is expected to be = ${I.System}`);if(n.promptRunMessages[n.promptRunMessages.length-1].role!==I.Assistant)throw Error(`promptRunMessages[${n.promptRunMessages.length-1}].role is expected to be = ${I.Assistant}`);let a=n.promptRunMessages[n.promptRunMessages.length-1].content,o;try{o=this.parseAiResponse(e,a)}catch(e){throw await K(this.graphQLClient,{productArea:L.PromptManager,...n,name:r,error:e.message,status:z.Error,...typeof t==`string`?{largeLanguageModelId:t}:{largeLanguageModelName:t.name,largeLanguageModelClient:t.client},promptId:i.id,promptRunMessages:n.promptRunMessages.map((e,t)=>({...e,...t===0?{template:i.content}:{}}))},{logger:x}),e}let s=await K(this.graphQLClient,{productArea:L.PromptManager,...n,name:r,status:z.Resolved,...typeof t==`string`?{largeLanguageModelId:t}:{largeLanguageModelName:t.name,largeLanguageModelClient:t.client},promptId:i.id,promptRunMessages:n.promptRunMessages.map((e,t)=>({...e,...t===0?{template:i.content}:{}}))},{logger:x});return{result:o,promptRunId:s,promptRunUrl:`https://app.transcend.io/prompts/runs/${s}`}}async reportPromptRunError(e,{largeLanguageModel:t,...n}){(!this.lastUpdatedAt||this.cacheDuration===0||this.cacheDuration&&Date.now()-this.lastUpdatedAt.getTime()>this.cacheDuration)&&await this.fetchPromptsAndMetadata();let r=n.name||`@transcend-io/cli-prompt-run-${new Date().toISOString()}`;if(!this.promptContentMap)throw Error(`Expected this.promptContentMap to be defined`);let i=this.promptContentMap[e];if(!i)throw Error(`Expected this.prompts[${e}] to be defined`);if(n.promptRunMessages.length===0)throw Error(`promptRunMessages is expected to have length > 0`);if(n.promptRunMessages[0].role!==I.System)throw Error(`promptRunMessages[0].role is expected to be = ${I.System}`);let a=await K(this.graphQLClient,{productArea:L.PromptManager,...n,name:r,status:z.Error,...typeof t==`string`?{largeLanguageModelId:t}:{largeLanguageModelName:t.name,largeLanguageModelClient:t.client},promptId:i.id,promptRunMessages:n.promptRunMessages.map((e,t)=>({...e,...t===0?{template:i.content}:{}}))},{logger:x});return{promptRunId:a,promptRunUrl:`https://app.transcend.io/prompts/runs/${a}`}}};function Kr(e){return e.replace(/(https?:\/\/[^\s]+)/g,`<link-omitted>`)}function qr(e){return Object.entries(e).reduce((e,[t,n])=>n!=null&&n!==``&&!(Array.isArray(n)&&n.length===0)&&!(typeof n==`object`&&Object.keys(n).length===0)?Object.assign(e,{[t]:n}):e,{})}function Jr({baseBranch:e,rootDirectory:t,githubRepo:n,excludedGlob:r=[],fileBlockList:i=[]}){X(`git fetch origin ${e}`);let a=X(`git ls-remote ${n} "refs/heads/${e}" | cut -f 1`,{encoding:`utf-8`}).split(`
1
+ import{a as e,i as t,n,o as r,r as i,t as a}from"./enums-CyFTrzXY.mjs";import{a as o,c as s,d as c,f as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b}from"./constants-BdUSsxl7.mjs";import{t as x}from"./logger-Bj782ZYD.mjs";import{$ as S,A as ee,B as te,C as ne,D as re,E as ie,F as ae,G as oe,H as se,I as ce,J as le,K as ue,L as de,M as fe,N as pe,O as me,P as he,Q as ge,R as _e,S as ve,T as ye,U as be,V as C,W as w,X as T,Y as E,Z as D,_ as O,_t as k,a as A,at as j,b as M,bt as N,c as xe,ct as Se,d as Ce,dt as we,et as Te,f as Ee,ft as De,g as Oe,gt as ke,h as Ae,ht as je,i as Me,it as Ne,j as Pe,k as Fe,l as Ie,lt as Le,m as Re,mt as ze,n as Be,nt as Ve,o as He,ot as Ue,p as We,pt as Ge,q as Ke,r as qe,rt as Je,s as Ye,st as Xe,t as Ze,tt as Qe,u as $e,ut as et,v as tt,vt as nt,w as rt,x as it,xt as at,y as ot,yt as st,z as ct}from"./codecs-B2mV72Wn.mjs";import{a as lt,i as ut,n as dt,r as ft,t as pt}from"./readTranscendYaml-BbnEGgVD.mjs";import{a as mt,i as ht,n as gt,r as _t,t as vt}from"./parseVariablesFromString-BeKOGw5n.mjs";import{a as yt,c as bt,i as xt,l as St,n as Ct,o as wt,r as Tt,s as Et,t as Dt,u as Ot}from"./constants-ClkQQhJs.mjs";import{i as kt,n as At,r as jt,t as Mt}from"./parseAttributesFromString-D1Yl0xwT.mjs";import{a as Nt,c as Pt,d as Ft,f as It,i as Lt,l as Rt,n as zt,o as Bt,r as Vt,s as Ht,t as Ut,u as Wt}from"./uploadPrivacyRequestsFromCsv-CXpI6D7r.mjs";import{t as Gt}from"./readCsv-C4TyEs-r.mjs";import{n as Kt,t as qt}from"./pullUnstructuredSubDataPointRecommendations-D0z-vPgq.mjs";import{a as Jt,i as Yt,n as Xt,o as Zt,r as Qt,t as $t}from"./request-DfkRPQFr.mjs";import{i as en,n as tn,r as nn,t as rn}from"./pullTranscendConfiguration-CofsMdIn.mjs";import{i as an,n as on,r as P,t as sn}from"./fetchAllRequests-CHHdyb4Q.mjs";import{a as cn,i as ln,n as un,r as dn,t as fn}from"./pullChunkedCustomSiloOutstandingIdentifiers-C0uKFWhl.mjs";import{n as pn,r as mn,t as hn}from"./syncCodePackages-CAk_Hjyl.mjs";import{t as gn}from"./markSilentPrivacyRequests-DCrw92hR.mjs";import{a as _n,i as vn,n as yn,o as bn,r as xn,t as Sn}from"./downloadPrivacyRequestFiles-3IOspTTF.mjs";import{n as Cn,r as wn,t as Tn}from"./extractClientError-i-Tw_az7.mjs";import{t as En}from"./approvePrivacyRequests-DchF0x4j.mjs";import{t as Dn}from"./notifyPrivacyRequestsAdditionalTime-Dl6QYo_s.mjs";import{t as On}from"./cancelPrivacyRequests-BWa-CsAX.mjs";import{n as kn,t as An}from"./bulkRestartRequests-B_T71-zF.mjs";import{t as jn}from"./skipPreflightJobs-BVW8pJNW.mjs";import{t as Mn}from"./bulkRetryEnrichers-C0PFRtA4.mjs";import{t as Nn}from"./retryRequestDataSilos-C3lrYsJt.mjs";import{n as F,t as Pn}from"./streamPrivacyRequestsToCsv-BaZKrjn-.mjs";import{n as Fn,r as In,t as Ln}from"./inquirer-BqZXFEt1.mjs";import{t as Rn}from"./collectParquetFilesOrExit-BJiAyaQ5.mjs";import{t as zn}from"./collectCsvFilesOrExit-CbtyKAzu.mjs";import{t as Bn}from"./parquetToCsvOneFile-B84XXInh.mjs";import{a as Vn,i as Hn,n as Un,o as Wn,r as Gn,s as Kn,t as qn}from"./writeCsv-C4pjXGsD.mjs";import{t as Jn}from"./skipRequestDataSilos-rMT0Nou7.mjs";import{t as Yn}from"./removeUnverifiedRequestIdentifiers-2ONNTCBT.mjs";import{t as Xn}from"./updateConsentManagerVersionToLatest-Di0JWUY5.mjs";import{t as Zn}from"./uploadDataFlowsFromCsv-DbLfSBwL.mjs";import{t as Qn}from"./uploadCookiesFromCsv-BvyfDsJQ.mjs";import{t as $n}from"./pullConsentManagerMetrics-zKgjc3Ap.mjs";import{n as er,r as tr,t as nr}from"./buildXdiSyncEndpoint-BoV3Zaen.mjs";import{t as rr}from"./consentManagersToBusinessEntities-BdKDganK.mjs";import{i as ir,n as ar,r as or,t as sr}from"./uploadConsents-CQOPzizv.mjs";import{n as cr,r as lr,t as ur}from"./pushCronIdentifiersFromCsv-Q5r4KNyE.mjs";import{t as dr}from"./markRequestDataSiloIdsCompleted-nKo6RUOH.mjs";import{t as fr}from"./generateCrossAccountApiKeys-C1Ur0dUu.mjs";import{t as pr}from"./validateTranscendAuth-BHw0WQu1.mjs";import{t as mr}from"./listFiles-D2wMHnEr.mjs";import{t as hr}from"./pullAllDatapoints-Bbmky50p.mjs";import{t as gr}from"./pullManualEnrichmentIdentifiersToCsv-CJJ_a_U6.mjs";import{n as _r,r as vr,t as yr}from"./pushManualEnrichmentIdentifiersFromCsv-BKtLAoqI.mjs";import{ChatCompletionRole as I,PromptRunProductArea as L,PromptStatus as R,QueueStatus as z}from"@transcend-io/privacy-types";import{chunk as B,difference as br,groupBy as xr,keyBy as V,uniq as Sr}from"lodash-es";import{apply as Cr,decodeCodec as H,getValues as wr}from"@transcend-io/type-utils";import{readFileSync as Tr,readdirSync as Er,statSync as Dr}from"node:fs";import{join as Or}from"node:path";import U from"colors";import{UPDATE_OR_CREATE_COOKIES as kr,buildTranscendGraphQLClient as W,createSombraGotInstance as Ar,fetchAllAgentFiles as jr,fetchAllAgents as G,fetchAllLargeLanguageModels as Mr,fetchAllPromptThreads as Nr,fetchAllRequestIdentifiers as Pr,fetchConsentManagerId as Fr,fetchPromptsWithVariables as Ir,makeGraphQLRequest as Lr,reportPromptRun as K,validateSombraVersion as Rr}from"@transcend-io/sdk";import{map as q,mapSeries as J}from"@transcend-io/utils";import{createHandlebarsWithHelpers as Y}from"@transcend-io/handlebars-utils";import{execSync as X}from"child_process";import zr from"fast-glob";async function Z(e,t){let n=await Fr(e,{logger:x});await J(B(t,100),async t=>{await Lr(e,kr,{variables:{airgapBundleId:n,cookies:t.map(e=>({name:e.name,trackingPurposes:e.trackingPurposes&&e.trackingPurposes.length>0?e.trackingPurposes:void 0,description:e.description,service:e.service,status:e.status,attributes:e.attributes,isRegex:e.isRegex}))},logger:x})})}async function Br(e,t){let n=!1;x.info(U.magenta(`Syncing "${t.length}" cookies...`));let r=t.filter(e=>t.filter(t=>e.name===t.name&&e.isRegex===t.isRegex).length>1);if(r.length>0)throw Error(`Failed to upload cookies as there were non-unique entries found: ${r.map(({name:e})=>e).join(`,`)}`);try{x.info(U.magenta(`Upserting "${t.length}" new cookies...`)),await Z(e,t),x.info(U.green(`Successfully synced ${t.length} cookies!`))}catch(e){n=!0,x.error(U.red(`Failed to create cookies! - ${e.message}`))}return!n}function Vr(e,t,n){let r=e.getTime(),i=t.getTime(),a=(i-r)/n;return Array.from({length:n},(e,t)=>({createdAtAfter:new Date(r+a*t),createdAtBefore:new Date(t===n-1?i:r+a*(t+1))}))}async function Hr({auth:e,sombraAuth:t,actions:n=[],statuses:r=[],identifierSearch:i,pageLimit:a=100,concurrency:s=1,transcendUrl:c=o,createdAtBefore:l,skipRequestIdentifiers:u=!1,createdAtAfter:d,updatedAtBefore:f,updatedAtAfter:p,isTest:m}){let h=W(c,e),g=await Ar(c,e,{logger:x,sombraApiKey:t,sombraUrl:process.env.SOMBRA_URL}),_=``;l&&(_+=` before ${l.toISOString()}`),d&&(_+=`${_?`, and`:``} after ${d.toISOString()}`),x.info(U.magenta(`${n.length>0?`Pulling requests of type "${n.join(`" , "`)}"`:`Pulling all requests`}${_}`));let v=s>1&&d&&l,y=v?Vr(d,l,s):[{createdAtAfter:d,createdAtBefore:l}];v&&x.info(U.magenta(`Splitting date range into ${s} parallel chunks`));let b=(await q(y,e=>P(h,{actions:n,text:i,statuses:r,createdAtBefore:e.createdAtBefore,createdAtAfter:e.createdAtAfter,updatedAtBefore:f,updatedAtAfter:p,isTest:m}),{concurrency:v?s:1})).flat();u||await Rr(h,{logger:x});let S=u?b.map(e=>({...e,requestIdentifiers:[]})):await q(b,async e=>{let t=await Pr(h,g,{filterBy:{requestId:e.id},skipSombraCheck:!0,logger:x});return{...e,requestIdentifiers:t}},{concurrency:a});return x.info(U.magenta(`Pulled ${S.length} requests`)),{requestsWithRequestIdentifiers:S,requestsFormattedForCsv:S.map(F)}}function Ur(e){try{return e?Tr(e,`utf8`):``}catch{return``}}function Wr(e){return Er(e).filter(t=>Dr(Or(e,t)).isDirectory())}function Q(e){return RegExp(`<${e}>([\\s\\S]+?)<\\/${e}>`)}function $(e){return e}const Gr=e=>{try{return JSON.parse(e)}catch{return e}};var Kr=class{prompts;handlebarsOptions;promptContentMap;largeLanguageModels=[];agentsByName={};agentsByAgentId={};graphQLClient;defaultVariables;variables;handlebars;transcendApiKey;transcendUrl;requireApproval;cacheDuration;lastUpdatedAt;constructor({prompts:e,handlebarsOptions:t={},transcendUrl:n=o,transcendApiKey:r,requireApproval:i=!0,cacheDuration:a,defaultVariables:s={}}){this.prompts=e,this.transcendUrl=n,this.transcendApiKey=r,this.variables=s,this.defaultVariables=s,this.graphQLClient=W(n,typeof r==`object`?r.release():r),this.requireApproval=i,this.cacheDuration=a,this.handlebarsOptions=t,this.handlebars=Y(t)}async fetchPromptsAndMetadata(){let e=wr(this.prompts),t=e.map(({id:e})=>e).filter(e=>!!e),n=e.map(({title:e})=>e).filter(e=>!!e),r=Sr(e.map(({agentNames:e})=>e||[]).flat()),[i,a,o]=await Promise.all([Ir(this.graphQLClient,{logger:x,filterBy:{ids:t,titles:n}}),Mr(this.graphQLClient,{logger:x}),G(this.graphQLClient,{logger:x,filterBy:{names:r}})]);this.agentsByName=V(o,`name`),this.agentsByAgentId=V(o,`agentId`),this.largeLanguageModels=a.filter(e=>e.isTranscendHosted===!1);let s=V(i.prompts,`title`),c=V(i.prompts,`id`);return this.variables={...i.calculatedVariables.reduce((e,t)=>Object.assign(e,{[t.name]:t.data?JSON.parse(t.data):t.data}),{}),...this.defaultVariables},this.handlebars=Y({...this.handlebarsOptions,templates:[...this.handlebarsOptions.templates||[],...i.promptPartials.map(e=>({name:e.slug,content:e.content}))]}),this.promptContentMap=Cr(this.prompts,({id:e,title:t})=>{let n=e?c[e]:t?s[t]:void 0;if(!n)throw Error(`Failed to find prompt with title: "${t}" and id: "${e}"`);return n}),this.lastUpdatedAt=new Date,i}async getAgentByName(e){let t=this.agentsByName[e];if(t)return t;let[n]=await G(this.graphQLClient,{logger:x,filterBy:{names:[e]}});if(n)return this.agentsByName[n.name]=n,this.agentsByAgentId[n.agentId]=n,n}async getPromptThreadBySlackTs(e){let[t]=await Nr(this.graphQLClient,{logger:x,filterBy:{slackMessageTs:[e]}});return t}async getAgentsByName(e){if(e.length<1)throw Error(`Expected at least one name to be provided`);let{hasCache:t=[],missingCache:n=[]}=xr(e,e=>this.agentsByName[e]?`hasCache`:`missingCache`),r=t.map(e=>this.agentsByName[e]);if(n.length===0)return r;let i=B(n,50),a=[];return await J(i,async e=>{let t=await G(this.graphQLClient,{logger:x,filterBy:{names:e}});t.forEach(e=>{this.agentsByName[e.name]=e,this.agentsByAgentId[e.agentId]=e}),a.push(...t)}),[...r,...a]}getAgentFiles(e){return jr(this.graphQLClient,{logger:x,filterBy:e})}getLargeLanguageModel(e){let t=this.largeLanguageModels.find(t=>typeof e==`string`?t.id===e:t.name===e.name&&t.client===e.client);if(!t)throw Error(`Failed to find model matching: ${typeof e==`string`?e:JSON.stringify(e)}`);return t}async getPromptDefinition(e){(!this.lastUpdatedAt||this.cacheDuration===0||this.cacheDuration&&Date.now()-this.lastUpdatedAt.getTime()>this.cacheDuration)&&await this.fetchPromptsAndMetadata();let{promptContentMap:t}=this;if(!t)throw Error(`Expected this.promptContentMap to be defined`);let n=t[e];if(!n)throw Error(`Expected this.promptContentMap[${e}] to be defined`);return n}async compilePrompt(e,t){let n=await this.getPromptDefinition(e),r=this.prompts[e];if(!r)throw Error(`Expected this.prompts[${e}] to be defined`);if(this.requireApproval&&n.status!==R.Approved)throw Error(`Assessment "${n.title}" cannot be used because its in status: "${n.status}"`);if(n.status===R.Rejected)throw Error(`Assessment "${n.title}" cannot be used because it's in status: "${n.status}"`);return H(r.paramCodec,t),this.handlebars.compile(n.content)({currentDate:new Date().toISOString(),...this.variables,...t})}parseAiResponse(e,t){let n=this.prompts[e];if(!n)throw Error(`Expected this.prompts[${e}] to be defined`);let r=n.extractFromTag&&(Q(n.extractFromTag).exec(t)||[])[1]||t;return H(n.outputCodec,Gr(r),!1)}async reportAndParsePromptRun(e,{largeLanguageModel:t,...n}){(!this.lastUpdatedAt||this.cacheDuration===0||this.cacheDuration&&Date.now()-this.lastUpdatedAt.getTime()>this.cacheDuration)&&await this.fetchPromptsAndMetadata();let r=n.name||`@transcend-io/cli-prompt-run-${new Date().toISOString()}`;if(!this.promptContentMap)throw Error(`Expected this.promptContentMap to be defined`);let i=this.promptContentMap[e];if(!i)throw Error(`Expected this.prompts[${e}] to be defined`);if(n.promptRunMessages.length===0)throw Error(`promptRunMessages is expected to have length > 0`);if(n.promptRunMessages[0].role!==I.System)throw Error(`promptRunMessages[0].role is expected to be = ${I.System}`);if(n.promptRunMessages[n.promptRunMessages.length-1].role!==I.Assistant)throw Error(`promptRunMessages[${n.promptRunMessages.length-1}].role is expected to be = ${I.Assistant}`);let a=n.promptRunMessages[n.promptRunMessages.length-1].content,o;try{o=this.parseAiResponse(e,a)}catch(e){throw await K(this.graphQLClient,{productArea:L.PromptManager,...n,name:r,error:e.message,status:z.Error,...typeof t==`string`?{largeLanguageModelId:t}:{largeLanguageModelName:t.name,largeLanguageModelClient:t.client},promptId:i.id,promptRunMessages:n.promptRunMessages.map((e,t)=>({...e,...t===0?{template:i.content}:{}}))},{logger:x}),e}let s=await K(this.graphQLClient,{productArea:L.PromptManager,...n,name:r,status:z.Resolved,...typeof t==`string`?{largeLanguageModelId:t}:{largeLanguageModelName:t.name,largeLanguageModelClient:t.client},promptId:i.id,promptRunMessages:n.promptRunMessages.map((e,t)=>({...e,...t===0?{template:i.content}:{}}))},{logger:x});return{result:o,promptRunId:s,promptRunUrl:`https://app.transcend.io/prompts/runs/${s}`}}async reportPromptRunError(e,{largeLanguageModel:t,...n}){(!this.lastUpdatedAt||this.cacheDuration===0||this.cacheDuration&&Date.now()-this.lastUpdatedAt.getTime()>this.cacheDuration)&&await this.fetchPromptsAndMetadata();let r=n.name||`@transcend-io/cli-prompt-run-${new Date().toISOString()}`;if(!this.promptContentMap)throw Error(`Expected this.promptContentMap to be defined`);let i=this.promptContentMap[e];if(!i)throw Error(`Expected this.prompts[${e}] to be defined`);if(n.promptRunMessages.length===0)throw Error(`promptRunMessages is expected to have length > 0`);if(n.promptRunMessages[0].role!==I.System)throw Error(`promptRunMessages[0].role is expected to be = ${I.System}`);let a=await K(this.graphQLClient,{productArea:L.PromptManager,...n,name:r,status:z.Error,...typeof t==`string`?{largeLanguageModelId:t}:{largeLanguageModelName:t.name,largeLanguageModelClient:t.client},promptId:i.id,promptRunMessages:n.promptRunMessages.map((e,t)=>({...e,...t===0?{template:i.content}:{}}))},{logger:x});return{promptRunId:a,promptRunUrl:`https://app.transcend.io/prompts/runs/${a}`}}};function qr(e){return e.replace(/(https?:\/\/[^\s]+)/g,`<link-omitted>`)}function Jr(e){return Object.entries(e).reduce((e,[t,n])=>n!=null&&n!==``&&!(Array.isArray(n)&&n.length===0)&&!(typeof n==`object`&&Object.keys(n).length===0)?Object.assign(e,{[t]:n}):e,{})}function Yr({baseBranch:e,rootDirectory:t,githubRepo:n,excludedGlob:r=[],fileBlockList:i=[]}){X(`git fetch origin ${e}`);let a=X(`git ls-remote ${n} "refs/heads/${e}" | cut -f 1`,{encoding:`utf-8`}).split(`
2
2
  `)[0],o=X(`git rev-parse HEAD`,{encoding:`utf-8`}).split(`
3
- `)[0];if(!a||!o)throw Error(`FAILED TO FIND COMMIT RANGE`);let s=yr(X(`git fetch && git diff --name-only "${e||a}...${o}" -- ${t}`,{encoding:`utf-8`}).split(`
4
- `).filter(e=>e),i),c=r.length>0?Rr.sync(s,{ignore:r}):s,l={};return c.forEach(e=>{l[e]=X(`git show ${o}:${e}`,{encoding:`utf-8`})}),{changedFiles:s,fileDiffs:l,repoName:n.split(`/`).pop().split(`.`)[0],commit:o}}export{y as ADMIN_DASH,m as ADMIN_DASH_DATAPOINTS,_ as ADMIN_DASH_INTEGRATIONS,$t as APPROVE_PRIVACY_REQUEST,en as ASSESSMENT_TEMPLATES,Ze as ActionInput,Be as ActionItemCollectionInput,qe as ActionItemInput,Me as AgentFileInput,A as AgentFunctionInput,He as AgentInput,Ye as ApiKeyInput,xe as AssessmentAnswerOptionInput,Ie as AssessmentDisplayLogicInput,$e as AssessmentInput,Ce as AssessmentNestedRuleInput,Ee as AssessmentResourceInput,We as AssessmentRetentionScheduleInput,Re as AssessmentRuleInput,Ae as AssessmentSectionInput,Oe as AssessmentSectionQuestionInput,O as AssessmentTemplateInput,Lt as AttestedExtraIdentifiers,tt as AttributeInput,ot as AttributePreview,M as AttributeValueInput,Dt as BLANK,Ct as BULK_APPLY,it as BusinessEntityInput,Xt as CANCEL_PRIVACY_REQUEST,Tt as CAN_APPLY_IN_BULK,xt as CachedFileState,yt as CachedRequestState,ve as CodePackageInput,ne as CodePackageSdk,wt as ColumnName,rt as ConsentManageExperienceInput,ye as ConsentManagerInput,ie as ConsentManagerServiceMetadata,re as ConsentPreferenceTopic,me as ConsentPreferenceTopicOptionValue,Fe as ConsentPurpose,ee as CookieCsvInput,Pe as CookieInput,ln as CronIdentifier,sr as CronIdentifierPush,d as DEBUG,o as DEFAULT_TRANSCEND_API,h as DEFAULT_TRANSCEND_CONSENT_API,rn as DEFAULT_TRANSCEND_PULL_RESOURCES,fe as DataCategoryGuessInput,pe as DataCategoryInput,he as DataCategoryPreviewInput,ae as DataCategoryRecommendationInput,ce as DataFlowCsvInput,de as DataFlowInput,_e as DataSiloInput,ct as DataSubjectInput,te as DatapointInput,Kt as ENTRY_COUNT,gr as EnrichPrivacyRequest,C as EnricherInput,se as FieldInput,Et as IDENTIFIER_BLOCK_LIST,tr as IP_ADDRESS_REGEX,bt as IS_REQUIRED,be as IdentifierInput,w as ImportOnetrustAssessmentsInput,bn as IntlMessage,oe as IntlMessageInput,St as NONE,Qt as NOTIFY_ADDITIONAL_TIME,a as OneTrustFileFormat,n as OneTrustPullResource,i as OneTrustPullSource,ue as OpenAIEnabledRoute,Ke as OpenAIEnabledRoutes,le as OpenAIIntegration,t as OpenAIRouteName,Mt as ParsedAttributeInput,E as PartitionInput,T as PathfinderPolicy,e as PathfinderPolicyName,D as PathfinderPolicyNameC,ge as PathfinderPromptRunMetadata,S as PolicyInput,Te as PrivacyCenterInput,sn as PrivacyRequest,Nt as PrivacyRequestInput,Sn as PrivacyRequestResponse,Qe as ProcessingActivityInput,Ve as ProcessingPurposeInput,Je as ProcessingPurposePreviewInput,Ne as PromptAVendorEmailSettings,j as PromptGroupInput,Ue as PromptInput,Xe as PromptPartialInput,or as PurposeMap,Yt as REQUESTS,Jt as REQUESTS_COUNT,v as RETRYABLE_BATCH_STATUSES,Se as RegionInput,Le as RepositoryInput,_n as RequestFileMetadata,gn as RequestFileMetadataResponse,on as RequestPurposeTrigger,et as RiskAssignmentInput,we as RiskLogicInput,s as SCOPES_BY_TITLE,f as SCOPE_TITLES,De as SiloDiscoveryResultInput,Ge as SoftwareDevelopmentKitInput,ze as StoredApiKey,Ot as SuccessfulRequest,b as TR_PULL_RESOURCE_SCOPE_MAP,c as TR_PUSH_RESOURCE_SCOPE_MAP,l as TR_YML_RESOURCE_TO_FIELD_NAME,je as TeamInput,ke as TemplateInput,k as TranscendInput,Gr as TranscendPromptManager,r as TranscendPullResource,Zt as UPDATE_PRIVACY_REQUEST,ir as USP_STRING_REGEX,pt as VARIABLE_PARAMETERS_NAME,dt as VARIABLE_PARAMETERS_REGEXP,nt as VendorInput,st as WebhookHeader,Kn as appendCsvRowsOrdered,Hn as appendCsvSync,Tn as approvePrivacyRequests,at as buildAIIntegrationType,N as buildEnabledRouteType,$n as buildXdiSyncEndpoint,kn as bulkRestartRequests,jn as bulkRetryEnrichers,Dn as cancelPrivacyRequests,Rn as collectCsvFilesOrExit,Ln as collectParquetFilesOrExit,nr as consentManagersToBusinessEntities,mn as createCodePackage,rr as createConsentToken,Q as createRegexForTag,Wr as defineTranscendPrompts,p as description,er as domainToHost,xn as downloadPrivacyRequestFiles,_r as enrichPrivacyRequest,mt as ensureAllDataSubjectsExist,wn as extractClientError,nn as fetchAllAssessmentTemplates,P as fetchAllRequests,cn as fetchRequestDataSiloActiveCount,an as fetchRequestsTotalCount,qr as filterNullishValuesFromObject,Wt as filterRows,F as formatRequestForCsv,jt as fuzzyMatchColumns,kt as fuzzySearch,dr as generateCrossAccountApiKeys,yn as getFileMetadataForPrivacyRequests,Jr as getGitFilesThatChanged,Ft as getUniqueValuesForColumn,Wn as initCsvFile,In as inquirerAutoComplete,Pn as inquirerConfirmBoolean,Fn as inquirerConfirmText,Ur as listDirectories,pr as listFiles,zt as mapColumnsToAttributes,Vt as mapColumnsToIdentifiers,Rt as mapCsvColumnsToApi,Bt as mapCsvRowsToRequestInputs,It as mapEnumValues,Pt as mapRequestEnumValues,cr as markCronIdentifierCompleted,ur as markRequestDataSiloIdsCompleted,hn as markSilentPrivacyRequests,gt as mergeTranscendInputs,g as name,Ht as normalizeIdentifierValue,En as notifyPrivacyRequestsAdditionalTime,zn as parquetToCsvOneFile,At as parseAttributesFromString,Vn as parseFilePath,vt as parseVariablesFromString,mr as pullAllDatapoints,dn as pullChunkedCustomSiloOutstandingIdentifiers,Qn as pullConsentManagerMetrics,un as pullCronPageOfIdentifiers,hr as pullManualEnrichmentIdentifiersToCsv,Vr as pullPrivacyRequests,tn as pullTranscendConfiguration,qt as pullUnstructuredSubDataPointRecommendations,lr as pushCronIdentifiersFromCsv,vr as pushManualEnrichmentIdentifiersFromCsv,Gt as readCsv,Hr as readSafe,ft as readTranscendYaml,Kr as removeLinks,Jn as removeUnverifiedRequestIdentifiers,ut as replaceVariablesInYaml,On as restartPrivacyRequest,Mn as retryRequestDataSilos,An as skipPreflightJobs,qn as skipRequestDataSilos,vn as streamPrivacyRequestFiles,Nn as streamPrivacyRequestsToCsv,Cn as submitPrivacyRequest,fn as syncCodePackages,_t as syncConfigurationToTranscend,zr as syncCookies,ht as syncDataSilos,pn as updateCodePackages,Yn as updateConsentManagerVersionToLatest,Z as updateOrCreateCookies,ar as uploadConsents,Zn as uploadCookiesFromCsv,Xn as uploadDataFlowsFromCsv,Ut as uploadPrivacyRequestsFromCsv,fr as validateTranscendAuth,u as version,Bn as writeCsv,Un as writeCsvSync,Gn as writeLargeCsv,lt as writeTranscendYaml};
3
+ `)[0];if(!a||!o)throw Error(`FAILED TO FIND COMMIT RANGE`);let s=br(X(`git fetch && git diff --name-only "${e||a}...${o}" -- ${t}`,{encoding:`utf-8`}).split(`
4
+ `).filter(e=>e),i),c=r.length>0?zr.sync(s,{ignore:r}):s,l={};return c.forEach(e=>{l[e]=X(`git show ${o}:${e}`,{encoding:`utf-8`})}),{changedFiles:s,fileDiffs:l,repoName:n.split(`/`).pop().split(`.`)[0],commit:o}}export{y as ADMIN_DASH,m as ADMIN_DASH_DATAPOINTS,_ as ADMIN_DASH_INTEGRATIONS,$t as APPROVE_PRIVACY_REQUEST,en as ASSESSMENT_TEMPLATES,Ze as ActionInput,Be as ActionItemCollectionInput,qe as ActionItemInput,Me as AgentFileInput,A as AgentFunctionInput,He as AgentInput,Ye as ApiKeyInput,xe as AssessmentAnswerOptionInput,Ie as AssessmentDisplayLogicInput,$e as AssessmentInput,Ce as AssessmentNestedRuleInput,Ee as AssessmentResourceInput,We as AssessmentRetentionScheduleInput,Re as AssessmentRuleInput,Ae as AssessmentSectionInput,Oe as AssessmentSectionQuestionInput,O as AssessmentTemplateInput,Lt as AttestedExtraIdentifiers,tt as AttributeInput,ot as AttributePreview,M as AttributeValueInput,Dt as BLANK,Ct as BULK_APPLY,it as BusinessEntityInput,Xt as CANCEL_PRIVACY_REQUEST,Tt as CAN_APPLY_IN_BULK,xt as CachedFileState,yt as CachedRequestState,ve as CodePackageInput,ne as CodePackageSdk,wt as ColumnName,rt as ConsentManageExperienceInput,ye as ConsentManagerInput,ie as ConsentManagerServiceMetadata,re as ConsentPreferenceTopic,me as ConsentPreferenceTopicOptionValue,Fe as ConsentPurpose,ee as CookieCsvInput,Pe as CookieInput,un as CronIdentifier,cr as CronIdentifierPush,dn as CronPartition,d as DEBUG,o as DEFAULT_TRANSCEND_API,h as DEFAULT_TRANSCEND_CONSENT_API,rn as DEFAULT_TRANSCEND_PULL_RESOURCES,fe as DataCategoryGuessInput,pe as DataCategoryInput,he as DataCategoryPreviewInput,ae as DataCategoryRecommendationInput,ce as DataFlowCsvInput,de as DataFlowInput,_e as DataSiloInput,ct as DataSubjectInput,te as DatapointInput,Kt as ENTRY_COUNT,_r as EnrichPrivacyRequest,C as EnricherInput,se as FieldInput,Et as IDENTIFIER_BLOCK_LIST,nr as IP_ADDRESS_REGEX,bt as IS_REQUIRED,be as IdentifierInput,w as ImportOnetrustAssessmentsInput,xn as IntlMessage,oe as IntlMessageInput,St as NONE,Qt as NOTIFY_ADDITIONAL_TIME,a as OneTrustFileFormat,n as OneTrustPullResource,i as OneTrustPullSource,ue as OpenAIEnabledRoute,Ke as OpenAIEnabledRoutes,le as OpenAIIntegration,t as OpenAIRouteName,Mt as ParsedAttributeInput,E as PartitionInput,T as PathfinderPolicy,e as PathfinderPolicyName,D as PathfinderPolicyNameC,ge as PathfinderPromptRunMetadata,S as PolicyInput,Te as PrivacyCenterInput,sn as PrivacyRequest,Nt as PrivacyRequestInput,Cn as PrivacyRequestResponse,Qe as ProcessingActivityInput,Ve as ProcessingPurposeInput,Je as ProcessingPurposePreviewInput,Ne as PromptAVendorEmailSettings,j as PromptGroupInput,Ue as PromptInput,Xe as PromptPartialInput,sr as PurposeMap,Yt as REQUESTS,Jt as REQUESTS_COUNT,v as RETRYABLE_BATCH_STATUSES,Se as RegionInput,Le as RepositoryInput,vn as RequestFileMetadata,_n as RequestFileMetadataResponse,on as RequestPurposeTrigger,et as RiskAssignmentInput,we as RiskLogicInput,s as SCOPES_BY_TITLE,f as SCOPE_TITLES,De as SiloDiscoveryResultInput,Ge as SoftwareDevelopmentKitInput,ze as StoredApiKey,Ot as SuccessfulRequest,b as TR_PULL_RESOURCE_SCOPE_MAP,c as TR_PUSH_RESOURCE_SCOPE_MAP,l as TR_YML_RESOURCE_TO_FIELD_NAME,je as TeamInput,ke as TemplateInput,k as TranscendInput,Kr as TranscendPromptManager,r as TranscendPullResource,Zt as UPDATE_PRIVACY_REQUEST,ar as USP_STRING_REGEX,pt as VARIABLE_PARAMETERS_NAME,dt as VARIABLE_PARAMETERS_REGEXP,nt as VendorInput,st as WebhookHeader,qn as appendCsvRowsOrdered,Un as appendCsvSync,En as approvePrivacyRequests,at as buildAIIntegrationType,N as buildEnabledRouteType,er as buildXdiSyncEndpoint,An as bulkRestartRequests,Mn as bulkRetryEnrichers,On as cancelPrivacyRequests,zn as collectCsvFilesOrExit,Rn as collectParquetFilesOrExit,rr as consentManagersToBusinessEntities,hn as createCodePackage,ir as createConsentToken,Q as createRegexForTag,$ as defineTranscendPrompts,p as description,tr as domainToHost,Sn as downloadPrivacyRequestFiles,vr as enrichPrivacyRequest,mt as ensureAllDataSubjectsExist,Tn as extractClientError,nn as fetchAllAssessmentTemplates,P as fetchAllRequests,cn as fetchRequestDataSiloActiveCount,an as fetchRequestsTotalCount,Jr as filterNullishValuesFromObject,Wt as filterRows,F as formatRequestForCsv,jt as fuzzyMatchColumns,kt as fuzzySearch,fr as generateCrossAccountApiKeys,bn as getFileMetadataForPrivacyRequests,Yr as getGitFilesThatChanged,Ft as getUniqueValuesForColumn,Gn as initCsvFile,Ln as inquirerAutoComplete,Fn as inquirerConfirmBoolean,In as inquirerConfirmText,Wr as listDirectories,mr as listFiles,zt as mapColumnsToAttributes,Vt as mapColumnsToIdentifiers,Rt as mapCsvColumnsToApi,Bt as mapCsvRowsToRequestInputs,It as mapEnumValues,Pt as mapRequestEnumValues,lr as markCronIdentifierCompleted,dr as markRequestDataSiloIdsCompleted,gn as markSilentPrivacyRequests,gt as mergeTranscendInputs,g as name,Ht as normalizeIdentifierValue,Dn as notifyPrivacyRequestsAdditionalTime,Bn as parquetToCsvOneFile,At as parseAttributesFromString,Hn as parseFilePath,vt as parseVariablesFromString,hr as pullAllDatapoints,fn as pullChunkedCustomSiloOutstandingIdentifiers,$n as pullConsentManagerMetrics,ln as pullCronPageOfIdentifiers,gr as pullManualEnrichmentIdentifiersToCsv,Hr as pullPrivacyRequests,tn as pullTranscendConfiguration,qt as pullUnstructuredSubDataPointRecommendations,ur as pushCronIdentifiersFromCsv,yr as pushManualEnrichmentIdentifiersFromCsv,Gt as readCsv,Ur as readSafe,ft as readTranscendYaml,qr as removeLinks,Yn as removeUnverifiedRequestIdentifiers,ut as replaceVariablesInYaml,kn as restartPrivacyRequest,Nn as retryRequestDataSilos,jn as skipPreflightJobs,Jn as skipRequestDataSilos,yn as streamPrivacyRequestFiles,Pn as streamPrivacyRequestsToCsv,wn as submitPrivacyRequest,pn as syncCodePackages,_t as syncConfigurationToTranscend,Br as syncCookies,ht as syncDataSilos,mn as updateCodePackages,Xn as updateConsentManagerVersionToLatest,Z as updateOrCreateCookies,or as uploadConsents,Qn as uploadCookiesFromCsv,Zn as uploadDataFlowsFromCsv,Ut as uploadPrivacyRequestsFromCsv,pr as validateTranscendAuth,u as version,Vn as writeCsv,Wn as writeCsvSync,Kn as writeLargeCsv,lt as writeTranscendYaml};
5
5
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/lib/graphql/syncCookies.ts","../src/lib/requests/pullPrivacyRequests.ts","../src/lib/helpers/readSafe.ts","../src/lib/api-keys/listDirectories.ts","../src/lib/ai/TranscendPromptManager.ts","../src/lib/ai/removeLinks.ts","../src/lib/ai/filterNullishValuesFromObject.ts","../src/lib/ai/getGitFilesThatChanged.ts"],"sourcesContent":["// import { keyBy } from 'lodash-es';\nimport {\n fetchConsentManagerId,\n makeGraphQLRequest,\n UPDATE_OR_CREATE_COOKIES,\n} from '@transcend-io/sdk';\nimport { mapSeries } from '@transcend-io/utils';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\nimport { chunk } from 'lodash-es';\n\nimport { CookieInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\n\nconst MAX_PAGE_SIZE = 100;\n\n/**\n * Update or create cookies that already existed\n *\n * @param client - GraphQL client\n * @param cookieInputs - List of cookie input\n */\nexport async function updateOrCreateCookies(\n client: GraphQLClient,\n cookieInputs: CookieInput[],\n): Promise<void> {\n const airgapBundleId = await fetchConsentManagerId(client, { logger });\n\n // TODO: https://transcend.height.app/T-19841 - add with custom purposes\n // const purposes = await fetchAllPurposes(client);\n // const purposeNameToId = keyBy(purposes, 'name');\n\n await mapSeries(chunk(cookieInputs, MAX_PAGE_SIZE), async (page) => {\n await makeGraphQLRequest(client, UPDATE_OR_CREATE_COOKIES, {\n variables: {\n airgapBundleId,\n cookies: page.map((cookie) => ({\n name: cookie.name,\n trackingPurposes:\n cookie.trackingPurposes && cookie.trackingPurposes.length > 0\n ? cookie.trackingPurposes\n : undefined,\n // TODO: https://transcend.height.app/T-19841 - add with custom purposes\n // purposeIds: cookie.trackingPurposes\n // ? cookie.trackingPurposes\n // .filter((purpose) => purpose !== 'Unknown')\n // .map((purpose) => purposeNameToId[purpose].id)\n // : undefined,\n description: cookie.description,\n service: cookie.service,\n status: cookie.status,\n attributes: cookie.attributes,\n isRegex: cookie.isRegex,\n // TODO: https://transcend.height.app/T-23718\n // owners,\n // teams,\n })),\n },\n logger,\n });\n });\n}\n\n/**\n * Sync the set of cookies from the YML interface into the product\n *\n * @param client - GraphQL client\n * @param cookies - Cookies to sync\n * @returns True upon success, false upon failure\n */\nexport async function syncCookies(client: GraphQLClient, cookies: CookieInput[]): Promise<boolean> {\n let encounteredError = false;\n logger.info(colors.magenta(`Syncing \"${cookies.length}\" cookies...`));\n\n // Ensure no duplicates are being uploaded\n const notUnique = cookies.filter(\n (cookie) =>\n cookies.filter((cook) => cookie.name === cook.name && cookie.isRegex === cook.isRegex)\n .length > 1,\n );\n if (notUnique.length > 0) {\n throw new Error(\n `Failed to upload cookies as there were non-unique entries found: ${notUnique\n .map(({ name }) => name)\n .join(',')}`,\n );\n }\n\n try {\n logger.info(colors.magenta(`Upserting \"${cookies.length}\" new cookies...`));\n await updateOrCreateCookies(client, cookies);\n logger.info(colors.green(`Successfully synced ${cookies.length} cookies!`));\n } catch (err) {\n encounteredError = true;\n logger.error(colors.red(`Failed to create cookies! - ${err.message}`));\n }\n\n return !encounteredError;\n}\n","import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllRequestIdentifiers,\n validateSombraVersion,\n type RequestIdentifier,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { fetchAllRequests } from '../graphql/index.js';\nimport { formatRequestForCsv, CsvRow, ExportedPrivacyRequest } from './formatRequestForCsv.js';\n\n/**\n * Split a date range into N evenly-spaced chunks.\n *\n * @param after - Start of the date range\n * @param before - End of the date range\n * @param chunks - Number of chunks to split into\n * @returns Array of date range bounds\n */\nfunction splitDateRange(\n after: Date,\n before: Date,\n chunks: number,\n): {\n /** Chunk start */ createdAtAfter: Date;\n /** Chunk end */ createdAtBefore: Date;\n}[] {\n const /** Range start ms */ start = after.getTime();\n const /** Range end ms */ end = before.getTime();\n const /** Ms per chunk */ chunkSize = (end - start) / chunks;\n return Array.from({ length: chunks }, (_, i) => ({\n createdAtAfter: new Date(start + chunkSize * i),\n createdAtBefore: new Date(i === chunks - 1 ? end : start + chunkSize * (i + 1)),\n }));\n}\n\n/**\n * Pull down a list of privacy requests\n *\n * @param options - Options\n * @returns The requests with request identifiers and requests formatted for CSV\n */\nexport async function pullPrivacyRequests({\n auth,\n sombraAuth,\n actions = [],\n statuses = [],\n identifierSearch,\n pageLimit = 100,\n concurrency = 1,\n transcendUrl = DEFAULT_TRANSCEND_API,\n createdAtBefore,\n skipRequestIdentifiers = false,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isTest,\n}: {\n /** Transcend API key authentication */\n auth: string;\n /** Search for a specific identifier */\n identifierSearch?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Statuses to filter on */\n statuses?: RequestStatus[];\n /** The request action to fetch */\n actions?: RequestAction[];\n /** Page limit when fetching requests */\n pageLimit?: number;\n /** Number of parallel date-range chunks */\n concurrency?: number;\n /** Filter for requests created before this date */\n createdAtBefore?: Date;\n /** Filter for requests created after this date */\n createdAtAfter?: Date;\n /** Filter for requests updated before this date */\n updatedAtBefore?: Date;\n /** Filter for requests updated after this date */\n updatedAtAfter?: Date;\n /** Return test requests */\n isTest?: boolean;\n /** Skip fetching request identifier */\n skipRequestIdentifiers?: boolean;\n}): Promise<{\n /** All request information with attached identifiers */\n requestsWithRequestIdentifiers: ExportedPrivacyRequest[];\n /** Requests that are formatted for CSV */\n requestsFormattedForCsv: CsvRow[];\n}> {\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n // Log date range\n let dateRange = '';\n if (createdAtBefore) {\n dateRange += ` before ${createdAtBefore.toISOString()}`;\n }\n if (createdAtAfter) {\n dateRange += `${dateRange ? ', and' : ''} after ${createdAtAfter.toISOString()}`;\n }\n logger.info(\n colors.magenta(\n `${\n actions.length > 0\n ? `Pulling requests of type \"${actions.join('\" , \"')}\"`\n : 'Pulling all requests'\n }${dateRange}`,\n ),\n );\n\n // Split into parallel date-range chunks when possible\n const useChunks = concurrency > 1 && createdAtAfter && createdAtBefore;\n const chunks = useChunks\n ? splitDateRange(createdAtAfter, createdAtBefore, concurrency)\n : [{ createdAtAfter, createdAtBefore }];\n\n if (useChunks) {\n logger.info(colors.magenta(`Splitting date range into ${concurrency} parallel chunks`));\n }\n\n // Fetch requests across all chunks in parallel\n const chunkResults = await map(\n chunks,\n (chunk) =>\n fetchAllRequests(client, {\n actions,\n text: identifierSearch,\n statuses,\n createdAtBefore: chunk.createdAtBefore,\n createdAtAfter: chunk.createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isTest,\n }),\n { concurrency: useChunks ? concurrency : 1 },\n );\n const requests = chunkResults.flat();\n\n // Validate Sombra version once before bulk-fetching identifiers\n if (!skipRequestIdentifiers) {\n await validateSombraVersion(client, { logger });\n }\n\n // Fetch the request identifiers for those requests\n const requestsWithRequestIdentifiers = skipRequestIdentifiers\n ? requests.map((request) => ({\n ...request,\n requestIdentifiers: [] as RequestIdentifier[],\n }))\n : await map(\n requests,\n async (request) => {\n const requestIdentifiers = await fetchAllRequestIdentifiers(client, sombra, {\n filterBy: { requestId: request.id },\n skipSombraCheck: true,\n logger,\n });\n return {\n ...request,\n requestIdentifiers,\n };\n },\n {\n concurrency: pageLimit,\n },\n );\n\n logger.info(colors.magenta(`Pulled ${requestsWithRequestIdentifiers.length} requests`));\n\n const data = requestsWithRequestIdentifiers.map(formatRequestForCsv);\n\n return { requestsWithRequestIdentifiers, requestsFormattedForCsv: data };\n}\n","import { readFileSync } from 'node:fs';\n\n/**\n * Safely reads the contents of a file as a UTF-8 string.\n * Returns an empty string if the path is not provided or if reading fails.\n *\n * @param p - The path to the file to read.\n * @returns The file contents as a string, or an empty string on error.\n */\nexport function readSafe(p?: string): string {\n try {\n return p ? readFileSync(p, 'utf8') : '';\n } catch {\n return '';\n }\n}\n","import { readdirSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * List the folders in a directory\n *\n * @param startDir - The base directory to list from\n * @returns The list of folders in that directory\n */\nexport function listDirectories(startDir: string): string[] {\n return readdirSync(startDir).filter((entryName) =>\n statSync(join(startDir, entryName)).isDirectory(),\n );\n}\n","import {\n HandlebarsInput,\n createHandlebarsWithHelpers,\n type Handlebars,\n} from '@transcend-io/handlebars-utils';\nimport {\n PromptStatus,\n ChatCompletionRole,\n PromptRunProductArea,\n QueueStatus,\n LargeLanguageModelClient,\n} from '@transcend-io/privacy-types';\nimport {\n type Agent,\n type AgentFile,\n type AgentFileFilterBy,\n buildTranscendGraphQLClient,\n fetchAllAgentFiles,\n fetchAllAgents,\n fetchAllLargeLanguageModels,\n fetchAllPromptThreads,\n fetchPromptsWithVariables,\n type LargeLanguageModel,\n type PromptThread,\n reportPromptRun,\n type ReportPromptRunInput,\n type TranscendPromptTemplated,\n type TranscendPromptsAndVariables,\n} from '@transcend-io/sdk';\nimport { Secret } from '@transcend-io/secret-value';\n/* eslint-disable max-lines */\nimport { Optionalize, Requirize, apply, decodeCodec, getValues } from '@transcend-io/type-utils';\nimport { mapSeries } from '@transcend-io/utils';\nimport { GraphQLClient } from 'graphql-request';\nimport * as t from 'io-ts';\nimport { groupBy, keyBy, uniq, chunk } from 'lodash-es';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\n\n/**\n * An LLM Prompt definition\n */\nexport type TranscendPrompt<TInputParams extends t.Any, TOutputCodec extends t.Any> = (\n | {\n /** ID of the prompt */\n id: string;\n /** Title of the prompt */\n title?: string;\n }\n | {\n /** ID of the prompt */\n id?: string;\n /** Title of the prompt */\n title: string;\n }\n) & {\n /** The names of the agents that should be loaded along with the prompt */\n agentNames?: string[];\n /** Codec to validate runtime input shape */\n paramCodec: TInputParams;\n /** Codec to validate output response */\n outputCodec: TOutputCodec;\n /**\n * If the output that needs to be parsed is returned within a tag\n * e.g. <tag> or <json> - this is the name of the tag\n */\n extractFromTag?: string;\n};\n\nexport interface PromptRunResult {\n /** The ID of the prompt run created on Transcend */\n promptRunId: string;\n /** The URL of the prompt run on Transcend */\n promptRunUrl: string;\n}\n\n/**\n * Create a regex to extract data from a tag\n *\n * Input:\n * \"here is some data <tag>Data</tag>...\"\n *\n * @param tagName - Name of tag\n * @returns Data within the tag\n */\nexport function createRegexForTag(tagName: string): RegExp {\n return new RegExp(`<${tagName}>([\\\\s\\\\S]+?)<\\\\/${tagName}>`);\n}\n\n/**\n * Helper function to declare prompts\n *\n * @param prompts - Prompt config\n * @returns Prompts as identity function - but type enforced\n */\nexport function defineTranscendPrompts<\n TPromptNames extends string,\n TPrompts extends { [k in TPromptNames]: TranscendPrompt<t.Any, t.Any> },\n>(prompts: TPrompts): TPrompts {\n return prompts;\n}\n\n/**\n * Helper to get the type of the parameter for a given prompt\n */\nexport type GetPromptParamType<\n TPromptName extends keyof TPrompts,\n TPrompts extends { [k in TPromptName]: TranscendPrompt<t.Any, t.Any> },\n> = t.TypeOf<TPrompts[TPromptName]['paramCodec']>;\n\n/**\n * Helper to get the type of the parameter for a given prompt\n */\nexport type GetPromptResponseType<\n TPromptName extends keyof TPrompts,\n TPrompts extends { [k in TPromptName]: TranscendPrompt<t.Any, t.Any> },\n> = t.TypeOf<TPrompts[TPromptName]['outputCodec']>;\n\n/**\n * Input for reporting a prompt run\n */\nexport interface ReportPromptRunOptions extends Optionalize<\n Omit<ReportPromptRunInput, 'status' | 'promptId' | 'largeLanguageModelId'>,\n 'name' | 'productArea'\n> {\n /** The large language model being run. Either the ID of the LLM or the client/name pairing */\n largeLanguageModel:\n | string\n | {\n /** Name of client */\n client: LargeLanguageModelClient;\n /** Name of the model */\n name: string;\n };\n}\n\nconst jsonParseSafe = (obj: string): unknown => {\n try {\n return JSON.parse(obj);\n } catch {\n return obj;\n }\n};\n\n/**\n * A class that is capable of loading and insert variables into prompts from\n * Transcend's Prompt Manager\n */\nexport class TranscendPromptManager<\n TPromptNames extends string,\n TPrompts extends { [k in TPromptNames]: TranscendPrompt<t.Any, t.Any> },\n> {\n /** Prompt definitions */\n public prompts: TPrompts;\n\n /** Options for configuring handlebars */\n public handlebarsOptions!: HandlebarsInput;\n\n /** Prompt name -> content map, populated by call to Transcend API */\n public promptContentMap?: { [k in TPromptNames]: TranscendPromptTemplated };\n\n /** The large language models that are registered to this organization for reporting */\n public largeLanguageModels: LargeLanguageModel[] = [];\n\n /** The agent definitions registered to this organization */\n private agentsByName: { [name in string]: Agent } = {};\n\n /** The agent definitions registered to this organization */\n private agentsByAgentId: { [id in string]: Agent } = {};\n\n /** The GraphQL client that can be used to call Transcend */\n public graphQLClient: GraphQLClient;\n\n /** The set of variables to expose in handlebars context specified at class initiation */\n public defaultVariables: { [k in string]: unknown };\n\n /**\n * The set of variables to expose in handlebars context,\n * merges defaults with calculated variables from the inventory\n */\n public variables: { [k in string]: unknown };\n\n /** Handlebars compiler */\n public handlebars: typeof Handlebars;\n\n /** The Transcend API key */\n public transcendApiKey: string | Secret<string>;\n\n /** API of Transcend to call */\n public transcendUrl: string;\n\n /** When true, throw an error if the prompt is not approved */\n public requireApproval: boolean;\n\n /**\n * The cache duration in ms for how long prompts and associated metadata should be cached\n * When undefined - prompts are cached indefinitely unless explicitly re-requested\n * When 0, prompts and metadata are fetched every time (not recommended)\n * Setting this to be an hour is a good rate that optimizes for performance and keeping up to date\n */\n public cacheDuration?: number;\n\n /**\n * The last time the metadata was fetched\n */\n public lastUpdatedAt?: Date;\n\n /**\n * Constructor\n *\n * @param options - Options\n */\n constructor({\n prompts,\n handlebarsOptions = {},\n transcendUrl = DEFAULT_TRANSCEND_API,\n transcendApiKey,\n requireApproval = true,\n cacheDuration,\n defaultVariables = {},\n }: {\n /** Prompt definitions to load */\n prompts: TPrompts;\n /** Options for configuring handlebars */\n handlebarsOptions?: HandlebarsInput;\n /** The Transcend API key */\n transcendApiKey: string | Secret<string>;\n /** API of Transcend to call */\n transcendUrl?: string;\n /** When true, throw an error if the prompt is not approved */\n requireApproval?: boolean;\n /** The set of variables to expose in handlebars context specified at class initiation */\n defaultVariables?: { [k in string]: unknown };\n /**\n * The cache duration in ms for how long prompts and associated metadata should be cached\n * When undefined - prompts are cached indefinitely unless explicitly re-requested\n * When 0, prompts and metadata are fetched every time (not recommended)\n * Setting this to be an hour is a good rate that optimizes for performance and keeping up to date\n */\n cacheDuration?: number;\n }) {\n this.prompts = prompts;\n this.transcendUrl = transcendUrl;\n this.transcendApiKey = transcendApiKey;\n this.variables = defaultVariables;\n this.defaultVariables = defaultVariables;\n this.graphQLClient = buildTranscendGraphQLClient(\n transcendUrl,\n typeof transcendApiKey === 'object' ? transcendApiKey.release() : transcendApiKey,\n );\n this.requireApproval = requireApproval;\n this.cacheDuration = cacheDuration;\n this.handlebarsOptions = handlebarsOptions;\n this.handlebars = createHandlebarsWithHelpers(handlebarsOptions);\n }\n\n /**\n * Fetch prompt metadata from Transcend and cache to the class definition\n *\n * @returns A function that can be used to call the prompt\n */\n async fetchPromptsAndMetadata(): Promise<TranscendPromptsAndVariables> {\n // Determine what to fetch\n const promptDefinitions = getValues(this.prompts) as TranscendPrompt<t.Any, t.Any>[];\n const promptIds = promptDefinitions.map(({ id }) => id).filter((x): x is string => !!x);\n const promptTitles = promptDefinitions\n .map(({ title }) => title)\n .filter((x): x is string => !!x);\n const agentNames = uniq(promptDefinitions.map(({ agentNames }) => agentNames || []).flat());\n\n // Fetch prompts and data\n const [response, largeLanguageModels, agents] = await Promise.all([\n fetchPromptsWithVariables(this.graphQLClient, {\n logger,\n filterBy: { ids: promptIds, titles: promptTitles },\n }),\n fetchAllLargeLanguageModels(this.graphQLClient, { logger }),\n fetchAllAgents(this.graphQLClient, { logger, filterBy: { names: agentNames } }),\n ]);\n this.agentsByName = keyBy(agents, 'name');\n this.agentsByAgentId = keyBy(agents, 'agentId');\n this.largeLanguageModels = largeLanguageModels.filter(\n (model) => model.isTranscendHosted === false,\n );\n\n // Lookup prompts by id/title\n const promptByTitle = keyBy(response.prompts, 'title');\n const promptById = keyBy(response.prompts, 'id');\n\n // Update variables\n this.variables = {\n ...response.calculatedVariables.reduce(\n (acc, v) =>\n Object.assign(acc, {\n [v.name]: v.data ? JSON.parse(v.data) : v.data,\n }),\n {},\n ),\n ...this.defaultVariables,\n };\n\n // Update partials\n this.handlebars = createHandlebarsWithHelpers({\n ...this.handlebarsOptions,\n templates: [\n ...(this.handlebarsOptions.templates || []),\n ...response.promptPartials.map((partial) => ({\n name: partial.slug,\n content: partial.content,\n })),\n ],\n });\n\n // Create mapping from prompt to content\n this.promptContentMap = apply(this.prompts, ({ id, title }) => {\n const result = id ? promptById[id] : title ? promptByTitle[title] : undefined;\n if (!result) {\n throw new Error(`Failed to find prompt with title: \"${title}\" and id: \"${id}\"`);\n }\n return result;\n });\n\n // For cache\n this.lastUpdatedAt = new Date();\n\n return response;\n }\n\n /**\n * Get an agent definition by name\n *\n * @param name - Name of the agent to grab\n * @returns Large language model configuration\n */\n async getAgentByName(name: string): Promise<Agent | undefined> {\n const agent = this.agentsByName[name];\n if (agent) {\n return agent;\n }\n const [remoteAgent] = await fetchAllAgents(this.graphQLClient, {\n logger,\n filterBy: { names: [name] },\n });\n if (!remoteAgent) {\n return undefined;\n }\n this.agentsByName[remoteAgent.name] = remoteAgent;\n this.agentsByAgentId[remoteAgent.agentId] = remoteAgent;\n return remoteAgent;\n }\n\n /**\n * Get a prompt thread by ts\n *\n * @param ts - the slack message timestamp to look up thread for\n * @returns Large language model configuration\n */\n async getPromptThreadBySlackTs(ts: string): Promise<PromptThread | undefined> {\n const [thread] = await fetchAllPromptThreads(this.graphQLClient, {\n logger,\n filterBy: { slackMessageTs: [ts] },\n });\n return thread;\n }\n\n /**\n * Get a list of agent definitions by name.\n * Pulls from cache and may return less agents\n * than requested if some are not found\n *\n * @param names - Names of agents to fetch\n * @returns The agents that were found matching the names\n */\n async getAgentsByName(names: string[]): Promise<Agent[]> {\n if (names.length < 1) {\n throw new Error('Expected at least one name to be provided');\n }\n const { hasCache = [], missingCache = [] } = groupBy(names, (name) =>\n this.agentsByName[name] ? 'hasCache' : 'missingCache',\n );\n const cachedAgents = hasCache.map((name) => this.agentsByName[name]);\n if (missingCache.length === 0) {\n return cachedAgents;\n }\n const chunkedNames = chunk(missingCache, 50);\n const remoteAgents: Agent[] = [];\n await mapSeries(chunkedNames, async (chunkedName) => {\n const pageOfAgents = await fetchAllAgents(this.graphQLClient, {\n logger,\n filterBy: { names: chunkedName },\n });\n pageOfAgents.forEach((agent) => {\n this.agentsByName[agent.name] = agent;\n this.agentsByAgentId[agent.agentId] = agent;\n });\n remoteAgents.push(...pageOfAgents);\n });\n return [...cachedAgents, ...remoteAgents];\n }\n\n /**\n * Fetch metadata on agent files\n *\n * @param filterBy - Filter by parameters\n * @returns The files found matching the filter\n */\n getAgentFiles(filterBy: AgentFileFilterBy): Promise<AgentFile[]> {\n return fetchAllAgentFiles(this.graphQLClient, { logger, filterBy });\n }\n\n /**\n * Look up the large language model to report on\n *\n * @param largeLanguageModel - Input\n * @returns Large language model configuration\n */\n getLargeLanguageModel(\n largeLanguageModel: ReportPromptRunOptions['largeLanguageModel'],\n ): LargeLanguageModel {\n const matching = this.largeLanguageModels.find((model) =>\n typeof largeLanguageModel === 'string'\n ? model.id === largeLanguageModel\n : model.name === largeLanguageModel.name && model.client === largeLanguageModel.client,\n );\n if (!matching) {\n throw new Error(\n `Failed to find model matching: ${\n typeof largeLanguageModel === 'string'\n ? largeLanguageModel\n : JSON.stringify(largeLanguageModel)\n }`,\n );\n }\n return matching;\n }\n\n /**\n * Get a prompt definition by name\n *\n * @param promptName - Prompt to compile\n * @returns Parsed content\n */\n async getPromptDefinition<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n ): Promise<TranscendPromptTemplated> {\n // Determine if prompts need to be fetched\n if (\n // never been fetched\n !this.lastUpdatedAt ||\n // fetch every run\n this.cacheDuration === 0 ||\n // If cache duration met\n (this.cacheDuration && Date.now() - this.lastUpdatedAt.getTime() > this.cacheDuration)\n ) {\n await this.fetchPromptsAndMetadata();\n }\n\n // Lookup prompt\n const { promptContentMap } = this;\n if (!promptContentMap) {\n throw new Error('Expected this.promptContentMap to be defined');\n }\n const promptTemplate = promptContentMap[promptName];\n if (!promptTemplate) {\n throw new Error(`Expected this.promptContentMap[${promptName}] to be defined`);\n }\n return promptTemplate;\n }\n\n /**\n * Validate the shape of the response from AI\n *\n * @param promptName - Prompt to compile\n * @param params - Runtime parameters\n * @returns Parsed content\n */\n async compilePrompt<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n params: t.TypeOf<TPrompts[TPromptName]['paramCodec']>,\n ): Promise<string> {\n // Grab the prompt\n const promptTemplate = await this.getPromptDefinition(promptName);\n const promptInput = this.prompts[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Ensure prompt is approved\n if (this.requireApproval && promptTemplate.status !== PromptStatus.Approved) {\n throw new Error(\n `Assessment \"${promptTemplate.title}\" cannot be used because its in status: \"${promptTemplate.status}\"`,\n );\n }\n\n // If prompt is rejected, throw error\n if (promptTemplate.status === PromptStatus.Rejected) {\n throw new Error(\n `Assessment \"${promptTemplate.title}\" cannot be used because it's in status: \"${promptTemplate.status}\"`,\n );\n }\n\n // Validate params\n decodeCodec(promptInput.paramCodec, params);\n\n // Compile prompt and template\n return this.handlebars.compile(promptTemplate.content)({\n // template in currentDate by default\n currentDate: new Date().toISOString(),\n ...this.variables,\n ...params,\n });\n }\n\n /**\n * Validate the shape of the response from AI\n *\n * @param promptName - Prompt to parse\n * @param response - AI response as string\n * @returns Parsed content\n */\n parseAiResponse<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n response: string,\n ): t.TypeOf<TPrompts[TPromptName]['outputCodec']> {\n // Look up prompt info\n const promptInput = this.prompts[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Extract from tag if needed\n const extracted = promptInput.extractFromTag\n ? (createRegexForTag(promptInput.extractFromTag).exec(response) || [])[1] || response\n : response;\n\n // Parse via codec\n return decodeCodec(promptInput.outputCodec, jsonParseSafe(extracted), false);\n }\n\n /**\n * Parse the AI response and report back to Transcend\n *\n * @param promptName - Prompt to parse\n * @param options - Options for reporting\n * @returns Parsed content\n */\n async reportAndParsePromptRun<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n { largeLanguageModel, ...options }: ReportPromptRunOptions,\n ): Promise<\n PromptRunResult & {\n /** Resulting prompt run */\n result: t.TypeOf<TPrompts[TPromptName]['outputCodec']>;\n }\n > {\n // Determine if prompts need to be fetched\n if (\n // never been fetched\n !this.lastUpdatedAt ||\n // fetch every run\n this.cacheDuration === 0 ||\n // If cache duration met\n (this.cacheDuration && Date.now() - this.lastUpdatedAt.getTime() > this.cacheDuration)\n ) {\n await this.fetchPromptsAndMetadata();\n }\n\n const name = options.name || `@transcend-io/cli-prompt-run-${new Date().toISOString()}`;\n\n if (!this.promptContentMap) {\n throw new Error('Expected this.promptContentMap to be defined');\n }\n // Look up prompt info\n const promptInput = this.promptContentMap[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Ensure the first message in `promptRunMessages` is of type=system\n if (options.promptRunMessages.length === 0) {\n throw new Error('promptRunMessages is expected to have length > 0');\n }\n if (options.promptRunMessages[0].role !== ChatCompletionRole.System) {\n throw new Error(`promptRunMessages[0].role is expected to be = ${ChatCompletionRole.System}`);\n }\n if (\n options.promptRunMessages[options.promptRunMessages.length - 1].role !==\n ChatCompletionRole.Assistant\n ) {\n throw new Error(\n `promptRunMessages[${\n options.promptRunMessages.length - 1\n }].role is expected to be = ${ChatCompletionRole.Assistant}`,\n );\n }\n const response = options.promptRunMessages[options.promptRunMessages.length - 1].content;\n\n let parsed: t.TypeOf<TPrompts[TPromptName]['outputCodec']>;\n try {\n // Parse the response\n parsed = this.parseAiResponse(promptName, response);\n } catch (err) {\n await reportPromptRun(\n this.graphQLClient,\n {\n productArea: PromptRunProductArea.PromptManager,\n ...options,\n name,\n error: err.message,\n status: QueueStatus.Error,\n ...(typeof largeLanguageModel === 'string'\n ? { largeLanguageModelId: largeLanguageModel }\n : {\n largeLanguageModelName: largeLanguageModel.name,\n largeLanguageModelClient: largeLanguageModel.client,\n }),\n promptId: promptInput.id,\n promptRunMessages: options.promptRunMessages.map((message, ind) => ({\n ...message,\n ...(ind === 0 ? { template: promptInput.content } : {}),\n })),\n },\n { logger },\n );\n throw err;\n }\n\n // report successful run\n const promptRunId = await reportPromptRun(\n this.graphQLClient,\n {\n productArea: PromptRunProductArea.PromptManager,\n ...options,\n name,\n status: QueueStatus.Resolved,\n ...(typeof largeLanguageModel === 'string'\n ? { largeLanguageModelId: largeLanguageModel }\n : {\n largeLanguageModelName: largeLanguageModel.name,\n largeLanguageModelClient: largeLanguageModel.client,\n }),\n promptId: promptInput.id,\n promptRunMessages: options.promptRunMessages.map((message, ind) => ({\n ...message,\n ...(ind === 0 ? { template: promptInput.content } : {}),\n })),\n },\n { logger },\n );\n\n return {\n result: parsed,\n promptRunId,\n promptRunUrl: `https://app.transcend.io/prompts/runs/${promptRunId}`,\n };\n }\n\n /**\n * Report an error for a particular prompt\n *\n * @param promptName - Prompt to parse\n * @param options - Options for reporting\n * @returns Parsed content\n */\n async reportPromptRunError<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n { largeLanguageModel, ...options }: Requirize<ReportPromptRunOptions, 'error'>,\n ): Promise<PromptRunResult> {\n // Determine if prompts need to be fetched\n if (\n // never been fetched\n !this.lastUpdatedAt ||\n // fetch every run\n this.cacheDuration === 0 ||\n // If cache duration met\n (this.cacheDuration && Date.now() - this.lastUpdatedAt.getTime() > this.cacheDuration)\n ) {\n await this.fetchPromptsAndMetadata();\n }\n\n const name = options.name || `@transcend-io/cli-prompt-run-${new Date().toISOString()}`;\n\n if (!this.promptContentMap) {\n throw new Error('Expected this.promptContentMap to be defined');\n }\n // Look up prompt info\n const promptInput = this.promptContentMap[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Ensure the first message in `promptRunMessages` is of type=system\n if (options.promptRunMessages.length === 0) {\n throw new Error('promptRunMessages is expected to have length > 0');\n }\n if (options.promptRunMessages[0].role !== ChatCompletionRole.System) {\n throw new Error(`promptRunMessages[0].role is expected to be = ${ChatCompletionRole.System}`);\n }\n\n const promptRunId = await reportPromptRun(\n this.graphQLClient,\n {\n productArea: PromptRunProductArea.PromptManager,\n ...options,\n name,\n status: QueueStatus.Error,\n ...(typeof largeLanguageModel === 'string'\n ? { largeLanguageModelId: largeLanguageModel }\n : {\n largeLanguageModelName: largeLanguageModel.name,\n largeLanguageModelClient: largeLanguageModel.client,\n }),\n promptId: promptInput.id,\n promptRunMessages: options.promptRunMessages.map((message, ind) => ({\n ...message,\n ...(ind === 0 ? { template: promptInput.content } : {}),\n })),\n },\n { logger },\n );\n\n return {\n promptRunId,\n promptRunUrl: `https://app.transcend.io/prompts/runs/${promptRunId}`,\n };\n }\n}\n/* eslint-enable max-lines */\n","/**\n * Remove links from a string\n *\n * @param inputString - String\n * @returns String without links\n */\nexport function removeLinks(inputString: string): string {\n const regex = /(https?:\\/\\/[^\\s]+)/g;\n return inputString.replace(regex, '<link-omitted>');\n}\n","import { ObjByString } from '@transcend-io/type-utils';\n\n/**\n * Given an object, remove all keys that are null-ish\n *\n * @param obj - Object\n * @returns Object with null-ish values removed\n */\nexport function filterNullishValuesFromObject<T extends ObjByString>(obj: T): T {\n return Object.entries(obj).reduce(\n (acc, [k, v]) =>\n v !== null &&\n v !== undefined &&\n v !== '' &&\n !(Array.isArray(v) && v.length === 0) &&\n !(typeof v === 'object' && Object.keys(v).length === 0)\n ? Object.assign(acc, { [k]: v })\n : acc,\n {} as T,\n );\n}\n","import { execSync } from 'child_process';\n\nimport fastGlob from 'fast-glob';\nimport { difference } from 'lodash-es';\n\n/**\n * Function thats gets the git files that have changed\n * and returns the code\n *\n * @param options - Options\n * @returns Changes files and diffs\n */\nexport function getGitFilesThatChanged({\n baseBranch,\n rootDirectory,\n githubRepo,\n excludedGlob = [],\n fileBlockList = [],\n}: {\n /** Base branch */\n baseBranch: string;\n /** Github repo name */\n githubRepo: string;\n /** Root directory */\n rootDirectory: string;\n /** A glob that excludes files */\n excludedGlob?: string[];\n /** Block list of files to not process */\n fileBlockList?: string[];\n}): {\n /** The list of files that changed */\n changedFiles: string[];\n /** Github repo name */\n repoName: string;\n /** Current commit */\n commit: string;\n /** File diffs */\n fileDiffs: { [k in string]: string };\n} {\n // Pull base branch\n execSync(`git fetch origin ${baseBranch}`);\n\n // Latest commit on base branch. If we are on the base branch, we take the prior commit\n const latestBasedCommit = execSync(\n `git ls-remote ${githubRepo} \"refs/heads/${baseBranch}\" | cut -f 1`,\n { encoding: 'utf-8' },\n ).split('\\n')[0];\n\n // This commit\n const latestThisCommit = execSync('git rev-parse HEAD', {\n encoding: 'utf-8',\n }).split('\\n')[0];\n\n // Ensure commits are present\n if (!latestBasedCommit || !latestThisCommit) {\n throw new Error('FAILED TO FIND COMMIT RANGE');\n }\n\n // Get the diff between the given branch and base branch\n const diff = execSync(\n `git fetch && git diff --name-only \"${\n baseBranch || latestBasedCommit\n }...${latestThisCommit}\" -- ${rootDirectory}`,\n { encoding: 'utf-8' },\n );\n\n // Filter out block list\n const changedFiles = difference(\n diff.split('\\n').filter((f) => f),\n fileBlockList,\n );\n\n // Filter out globs\n const filteredChanges =\n excludedGlob.length > 0 ? fastGlob.sync(changedFiles, { ignore: excludedGlob }) : changedFiles;\n\n // Get the contents of only the changed files\n const fileDiffs: { [k in string]: string } = {};\n filteredChanges.forEach((file) => {\n const contents = execSync(`git show ${latestThisCommit}:${file}`, {\n encoding: 'utf-8',\n });\n fileDiffs[file] = contents;\n });\n\n // Pull the github repo name\n const repoName = githubRepo.split('/').pop()!.split('.')[0];\n\n return {\n changedFiles,\n fileDiffs,\n repoName,\n commit: latestThisCommit,\n };\n}\n"],"mappings":"glKAsBA,eAAsB,EACpB,EACA,EACe,CACf,IAAM,EAAiB,MAAM,GAAsB,EAAQ,CAAE,SAAQ,CAAC,CAMtE,MAAM,EAAU,EAAM,EAAc,IA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,OAVA,EAAgB,QAAS,GAAS,CAIhC,EAAU,GAHO,EAAS,YAAY,EAAiB,GAAG,IAAQ,CAChE,SAAU,QACX,CAAC,EAEF,CAKK,CACL,eACA,YACA,SALe,EAAW,MAAM,IAAI,CAAC,KAAK,CAAE,MAAM,IAAI,CAAC,GAMvD,OAAQ,EACT"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/lib/graphql/syncCookies.ts","../src/lib/requests/pullPrivacyRequests.ts","../src/lib/helpers/readSafe.ts","../src/lib/api-keys/listDirectories.ts","../src/lib/ai/TranscendPromptManager.ts","../src/lib/ai/removeLinks.ts","../src/lib/ai/filterNullishValuesFromObject.ts","../src/lib/ai/getGitFilesThatChanged.ts"],"sourcesContent":["// import { keyBy } from 'lodash-es';\nimport {\n fetchConsentManagerId,\n makeGraphQLRequest,\n UPDATE_OR_CREATE_COOKIES,\n} from '@transcend-io/sdk';\nimport { mapSeries } from '@transcend-io/utils';\nimport colors from 'colors';\nimport { GraphQLClient } from 'graphql-request';\nimport { chunk } from 'lodash-es';\n\nimport { CookieInput } from '../../codecs.js';\nimport { logger } from '../../logger.js';\n\nconst MAX_PAGE_SIZE = 100;\n\n/**\n * Update or create cookies that already existed\n *\n * @param client - GraphQL client\n * @param cookieInputs - List of cookie input\n */\nexport async function updateOrCreateCookies(\n client: GraphQLClient,\n cookieInputs: CookieInput[],\n): Promise<void> {\n const airgapBundleId = await fetchConsentManagerId(client, { logger });\n\n // TODO: https://transcend.height.app/T-19841 - add with custom purposes\n // const purposes = await fetchAllPurposes(client);\n // const purposeNameToId = keyBy(purposes, 'name');\n\n await mapSeries(chunk(cookieInputs, MAX_PAGE_SIZE), async (page) => {\n await makeGraphQLRequest(client, UPDATE_OR_CREATE_COOKIES, {\n variables: {\n airgapBundleId,\n cookies: page.map((cookie) => ({\n name: cookie.name,\n trackingPurposes:\n cookie.trackingPurposes && cookie.trackingPurposes.length > 0\n ? cookie.trackingPurposes\n : undefined,\n // TODO: https://transcend.height.app/T-19841 - add with custom purposes\n // purposeIds: cookie.trackingPurposes\n // ? cookie.trackingPurposes\n // .filter((purpose) => purpose !== 'Unknown')\n // .map((purpose) => purposeNameToId[purpose].id)\n // : undefined,\n description: cookie.description,\n service: cookie.service,\n status: cookie.status,\n attributes: cookie.attributes,\n isRegex: cookie.isRegex,\n // TODO: https://transcend.height.app/T-23718\n // owners,\n // teams,\n })),\n },\n logger,\n });\n });\n}\n\n/**\n * Sync the set of cookies from the YML interface into the product\n *\n * @param client - GraphQL client\n * @param cookies - Cookies to sync\n * @returns True upon success, false upon failure\n */\nexport async function syncCookies(client: GraphQLClient, cookies: CookieInput[]): Promise<boolean> {\n let encounteredError = false;\n logger.info(colors.magenta(`Syncing \"${cookies.length}\" cookies...`));\n\n // Ensure no duplicates are being uploaded\n const notUnique = cookies.filter(\n (cookie) =>\n cookies.filter((cook) => cookie.name === cook.name && cookie.isRegex === cook.isRegex)\n .length > 1,\n );\n if (notUnique.length > 0) {\n throw new Error(\n `Failed to upload cookies as there were non-unique entries found: ${notUnique\n .map(({ name }) => name)\n .join(',')}`,\n );\n }\n\n try {\n logger.info(colors.magenta(`Upserting \"${cookies.length}\" new cookies...`));\n await updateOrCreateCookies(client, cookies);\n logger.info(colors.green(`Successfully synced ${cookies.length} cookies!`));\n } catch (err) {\n encounteredError = true;\n logger.error(colors.red(`Failed to create cookies! - ${err.message}`));\n }\n\n return !encounteredError;\n}\n","import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllRequestIdentifiers,\n validateSombraVersion,\n type RequestIdentifier,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { fetchAllRequests } from '../graphql/index.js';\nimport { formatRequestForCsv, CsvRow, ExportedPrivacyRequest } from './formatRequestForCsv.js';\n\n/**\n * Split a date range into N evenly-spaced chunks.\n *\n * @param after - Start of the date range\n * @param before - End of the date range\n * @param chunks - Number of chunks to split into\n * @returns Array of date range bounds\n */\nfunction splitDateRange(\n after: Date,\n before: Date,\n chunks: number,\n): {\n /** Chunk start */ createdAtAfter: Date;\n /** Chunk end */ createdAtBefore: Date;\n}[] {\n const /** Range start ms */ start = after.getTime();\n const /** Range end ms */ end = before.getTime();\n const /** Ms per chunk */ chunkSize = (end - start) / chunks;\n return Array.from({ length: chunks }, (_, i) => ({\n createdAtAfter: new Date(start + chunkSize * i),\n createdAtBefore: new Date(i === chunks - 1 ? end : start + chunkSize * (i + 1)),\n }));\n}\n\n/**\n * Pull down a list of privacy requests\n *\n * @param options - Options\n * @returns The requests with request identifiers and requests formatted for CSV\n */\nexport async function pullPrivacyRequests({\n auth,\n sombraAuth,\n actions = [],\n statuses = [],\n identifierSearch,\n pageLimit = 100,\n concurrency = 1,\n transcendUrl = DEFAULT_TRANSCEND_API,\n createdAtBefore,\n skipRequestIdentifiers = false,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isTest,\n}: {\n /** Transcend API key authentication */\n auth: string;\n /** Search for a specific identifier */\n identifierSearch?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Statuses to filter on */\n statuses?: RequestStatus[];\n /** The request action to fetch */\n actions?: RequestAction[];\n /** Page limit when fetching requests */\n pageLimit?: number;\n /** Number of parallel date-range chunks */\n concurrency?: number;\n /** Filter for requests created before this date */\n createdAtBefore?: Date;\n /** Filter for requests created after this date */\n createdAtAfter?: Date;\n /** Filter for requests updated before this date */\n updatedAtBefore?: Date;\n /** Filter for requests updated after this date */\n updatedAtAfter?: Date;\n /** Return test requests */\n isTest?: boolean;\n /** Skip fetching request identifier */\n skipRequestIdentifiers?: boolean;\n}): Promise<{\n /** All request information with attached identifiers */\n requestsWithRequestIdentifiers: ExportedPrivacyRequest[];\n /** Requests that are formatted for CSV */\n requestsFormattedForCsv: CsvRow[];\n}> {\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n // Log date range\n let dateRange = '';\n if (createdAtBefore) {\n dateRange += ` before ${createdAtBefore.toISOString()}`;\n }\n if (createdAtAfter) {\n dateRange += `${dateRange ? ', and' : ''} after ${createdAtAfter.toISOString()}`;\n }\n logger.info(\n colors.magenta(\n `${\n actions.length > 0\n ? `Pulling requests of type \"${actions.join('\" , \"')}\"`\n : 'Pulling all requests'\n }${dateRange}`,\n ),\n );\n\n // Split into parallel date-range chunks when possible\n const useChunks = concurrency > 1 && createdAtAfter && createdAtBefore;\n const chunks = useChunks\n ? splitDateRange(createdAtAfter, createdAtBefore, concurrency)\n : [{ createdAtAfter, createdAtBefore }];\n\n if (useChunks) {\n logger.info(colors.magenta(`Splitting date range into ${concurrency} parallel chunks`));\n }\n\n // Fetch requests across all chunks in parallel\n const chunkResults = await map(\n chunks,\n (chunk) =>\n fetchAllRequests(client, {\n actions,\n text: identifierSearch,\n statuses,\n createdAtBefore: chunk.createdAtBefore,\n createdAtAfter: chunk.createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isTest,\n }),\n { concurrency: useChunks ? concurrency : 1 },\n );\n const requests = chunkResults.flat();\n\n // Validate Sombra version once before bulk-fetching identifiers\n if (!skipRequestIdentifiers) {\n await validateSombraVersion(client, { logger });\n }\n\n // Fetch the request identifiers for those requests\n const requestsWithRequestIdentifiers = skipRequestIdentifiers\n ? requests.map((request) => ({\n ...request,\n requestIdentifiers: [] as RequestIdentifier[],\n }))\n : await map(\n requests,\n async (request) => {\n const requestIdentifiers = await fetchAllRequestIdentifiers(client, sombra, {\n filterBy: { requestId: request.id },\n skipSombraCheck: true,\n logger,\n });\n return {\n ...request,\n requestIdentifiers,\n };\n },\n {\n concurrency: pageLimit,\n },\n );\n\n logger.info(colors.magenta(`Pulled ${requestsWithRequestIdentifiers.length} requests`));\n\n const data = requestsWithRequestIdentifiers.map(formatRequestForCsv);\n\n return { requestsWithRequestIdentifiers, requestsFormattedForCsv: data };\n}\n","import { readFileSync } from 'node:fs';\n\n/**\n * Safely reads the contents of a file as a UTF-8 string.\n * Returns an empty string if the path is not provided or if reading fails.\n *\n * @param p - The path to the file to read.\n * @returns The file contents as a string, or an empty string on error.\n */\nexport function readSafe(p?: string): string {\n try {\n return p ? readFileSync(p, 'utf8') : '';\n } catch {\n return '';\n }\n}\n","import { readdirSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * List the folders in a directory\n *\n * @param startDir - The base directory to list from\n * @returns The list of folders in that directory\n */\nexport function listDirectories(startDir: string): string[] {\n return readdirSync(startDir).filter((entryName) =>\n statSync(join(startDir, entryName)).isDirectory(),\n );\n}\n","import {\n HandlebarsInput,\n createHandlebarsWithHelpers,\n type Handlebars,\n} from '@transcend-io/handlebars-utils';\nimport {\n PromptStatus,\n ChatCompletionRole,\n PromptRunProductArea,\n QueueStatus,\n LargeLanguageModelClient,\n} from '@transcend-io/privacy-types';\nimport {\n type Agent,\n type AgentFile,\n type AgentFileFilterBy,\n buildTranscendGraphQLClient,\n fetchAllAgentFiles,\n fetchAllAgents,\n fetchAllLargeLanguageModels,\n fetchAllPromptThreads,\n fetchPromptsWithVariables,\n type LargeLanguageModel,\n type PromptThread,\n reportPromptRun,\n type ReportPromptRunInput,\n type TranscendPromptTemplated,\n type TranscendPromptsAndVariables,\n} from '@transcend-io/sdk';\nimport { Secret } from '@transcend-io/secret-value';\n/* eslint-disable max-lines */\nimport { Optionalize, Requirize, apply, decodeCodec, getValues } from '@transcend-io/type-utils';\nimport { mapSeries } from '@transcend-io/utils';\nimport { GraphQLClient } from 'graphql-request';\nimport * as t from 'io-ts';\nimport { groupBy, keyBy, uniq, chunk } from 'lodash-es';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\n\n/**\n * An LLM Prompt definition\n */\nexport type TranscendPrompt<TInputParams extends t.Any, TOutputCodec extends t.Any> = (\n | {\n /** ID of the prompt */\n id: string;\n /** Title of the prompt */\n title?: string;\n }\n | {\n /** ID of the prompt */\n id?: string;\n /** Title of the prompt */\n title: string;\n }\n) & {\n /** The names of the agents that should be loaded along with the prompt */\n agentNames?: string[];\n /** Codec to validate runtime input shape */\n paramCodec: TInputParams;\n /** Codec to validate output response */\n outputCodec: TOutputCodec;\n /**\n * If the output that needs to be parsed is returned within a tag\n * e.g. <tag> or <json> - this is the name of the tag\n */\n extractFromTag?: string;\n};\n\nexport interface PromptRunResult {\n /** The ID of the prompt run created on Transcend */\n promptRunId: string;\n /** The URL of the prompt run on Transcend */\n promptRunUrl: string;\n}\n\n/**\n * Create a regex to extract data from a tag\n *\n * Input:\n * \"here is some data <tag>Data</tag>...\"\n *\n * @param tagName - Name of tag\n * @returns Data within the tag\n */\nexport function createRegexForTag(tagName: string): RegExp {\n return new RegExp(`<${tagName}>([\\\\s\\\\S]+?)<\\\\/${tagName}>`);\n}\n\n/**\n * Helper function to declare prompts\n *\n * @param prompts - Prompt config\n * @returns Prompts as identity function - but type enforced\n */\nexport function defineTranscendPrompts<\n TPromptNames extends string,\n TPrompts extends { [k in TPromptNames]: TranscendPrompt<t.Any, t.Any> },\n>(prompts: TPrompts): TPrompts {\n return prompts;\n}\n\n/**\n * Helper to get the type of the parameter for a given prompt\n */\nexport type GetPromptParamType<\n TPromptName extends keyof TPrompts,\n TPrompts extends { [k in TPromptName]: TranscendPrompt<t.Any, t.Any> },\n> = t.TypeOf<TPrompts[TPromptName]['paramCodec']>;\n\n/**\n * Helper to get the type of the parameter for a given prompt\n */\nexport type GetPromptResponseType<\n TPromptName extends keyof TPrompts,\n TPrompts extends { [k in TPromptName]: TranscendPrompt<t.Any, t.Any> },\n> = t.TypeOf<TPrompts[TPromptName]['outputCodec']>;\n\n/**\n * Input for reporting a prompt run\n */\nexport interface ReportPromptRunOptions extends Optionalize<\n Omit<ReportPromptRunInput, 'status' | 'promptId' | 'largeLanguageModelId'>,\n 'name' | 'productArea'\n> {\n /** The large language model being run. Either the ID of the LLM or the client/name pairing */\n largeLanguageModel:\n | string\n | {\n /** Name of client */\n client: LargeLanguageModelClient;\n /** Name of the model */\n name: string;\n };\n}\n\nconst jsonParseSafe = (obj: string): unknown => {\n try {\n return JSON.parse(obj);\n } catch {\n return obj;\n }\n};\n\n/**\n * A class that is capable of loading and insert variables into prompts from\n * Transcend's Prompt Manager\n */\nexport class TranscendPromptManager<\n TPromptNames extends string,\n TPrompts extends { [k in TPromptNames]: TranscendPrompt<t.Any, t.Any> },\n> {\n /** Prompt definitions */\n public prompts: TPrompts;\n\n /** Options for configuring handlebars */\n public handlebarsOptions!: HandlebarsInput;\n\n /** Prompt name -> content map, populated by call to Transcend API */\n public promptContentMap?: { [k in TPromptNames]: TranscendPromptTemplated };\n\n /** The large language models that are registered to this organization for reporting */\n public largeLanguageModels: LargeLanguageModel[] = [];\n\n /** The agent definitions registered to this organization */\n private agentsByName: { [name in string]: Agent } = {};\n\n /** The agent definitions registered to this organization */\n private agentsByAgentId: { [id in string]: Agent } = {};\n\n /** The GraphQL client that can be used to call Transcend */\n public graphQLClient: GraphQLClient;\n\n /** The set of variables to expose in handlebars context specified at class initiation */\n public defaultVariables: { [k in string]: unknown };\n\n /**\n * The set of variables to expose in handlebars context,\n * merges defaults with calculated variables from the inventory\n */\n public variables: { [k in string]: unknown };\n\n /** Handlebars compiler */\n public handlebars: typeof Handlebars;\n\n /** The Transcend API key */\n public transcendApiKey: string | Secret<string>;\n\n /** API of Transcend to call */\n public transcendUrl: string;\n\n /** When true, throw an error if the prompt is not approved */\n public requireApproval: boolean;\n\n /**\n * The cache duration in ms for how long prompts and associated metadata should be cached\n * When undefined - prompts are cached indefinitely unless explicitly re-requested\n * When 0, prompts and metadata are fetched every time (not recommended)\n * Setting this to be an hour is a good rate that optimizes for performance and keeping up to date\n */\n public cacheDuration?: number;\n\n /**\n * The last time the metadata was fetched\n */\n public lastUpdatedAt?: Date;\n\n /**\n * Constructor\n *\n * @param options - Options\n */\n constructor({\n prompts,\n handlebarsOptions = {},\n transcendUrl = DEFAULT_TRANSCEND_API,\n transcendApiKey,\n requireApproval = true,\n cacheDuration,\n defaultVariables = {},\n }: {\n /** Prompt definitions to load */\n prompts: TPrompts;\n /** Options for configuring handlebars */\n handlebarsOptions?: HandlebarsInput;\n /** The Transcend API key */\n transcendApiKey: string | Secret<string>;\n /** API of Transcend to call */\n transcendUrl?: string;\n /** When true, throw an error if the prompt is not approved */\n requireApproval?: boolean;\n /** The set of variables to expose in handlebars context specified at class initiation */\n defaultVariables?: { [k in string]: unknown };\n /**\n * The cache duration in ms for how long prompts and associated metadata should be cached\n * When undefined - prompts are cached indefinitely unless explicitly re-requested\n * When 0, prompts and metadata are fetched every time (not recommended)\n * Setting this to be an hour is a good rate that optimizes for performance and keeping up to date\n */\n cacheDuration?: number;\n }) {\n this.prompts = prompts;\n this.transcendUrl = transcendUrl;\n this.transcendApiKey = transcendApiKey;\n this.variables = defaultVariables;\n this.defaultVariables = defaultVariables;\n this.graphQLClient = buildTranscendGraphQLClient(\n transcendUrl,\n typeof transcendApiKey === 'object' ? transcendApiKey.release() : transcendApiKey,\n );\n this.requireApproval = requireApproval;\n this.cacheDuration = cacheDuration;\n this.handlebarsOptions = handlebarsOptions;\n this.handlebars = createHandlebarsWithHelpers(handlebarsOptions);\n }\n\n /**\n * Fetch prompt metadata from Transcend and cache to the class definition\n *\n * @returns A function that can be used to call the prompt\n */\n async fetchPromptsAndMetadata(): Promise<TranscendPromptsAndVariables> {\n // Determine what to fetch\n const promptDefinitions = getValues(this.prompts) as TranscendPrompt<t.Any, t.Any>[];\n const promptIds = promptDefinitions.map(({ id }) => id).filter((x): x is string => !!x);\n const promptTitles = promptDefinitions\n .map(({ title }) => title)\n .filter((x): x is string => !!x);\n const agentNames = uniq(promptDefinitions.map(({ agentNames }) => agentNames || []).flat());\n\n // Fetch prompts and data\n const [response, largeLanguageModels, agents] = await Promise.all([\n fetchPromptsWithVariables(this.graphQLClient, {\n logger,\n filterBy: { ids: promptIds, titles: promptTitles },\n }),\n fetchAllLargeLanguageModels(this.graphQLClient, { logger }),\n fetchAllAgents(this.graphQLClient, { logger, filterBy: { names: agentNames } }),\n ]);\n this.agentsByName = keyBy(agents, 'name');\n this.agentsByAgentId = keyBy(agents, 'agentId');\n this.largeLanguageModels = largeLanguageModels.filter(\n (model) => model.isTranscendHosted === false,\n );\n\n // Lookup prompts by id/title\n const promptByTitle = keyBy(response.prompts, 'title');\n const promptById = keyBy(response.prompts, 'id');\n\n // Update variables\n this.variables = {\n ...response.calculatedVariables.reduce(\n (acc, v) =>\n Object.assign(acc, {\n [v.name]: v.data ? JSON.parse(v.data) : v.data,\n }),\n {},\n ),\n ...this.defaultVariables,\n };\n\n // Update partials\n this.handlebars = createHandlebarsWithHelpers({\n ...this.handlebarsOptions,\n templates: [\n ...(this.handlebarsOptions.templates || []),\n ...response.promptPartials.map((partial) => ({\n name: partial.slug,\n content: partial.content,\n })),\n ],\n });\n\n // Create mapping from prompt to content\n this.promptContentMap = apply(this.prompts, ({ id, title }) => {\n const result = id ? promptById[id] : title ? promptByTitle[title] : undefined;\n if (!result) {\n throw new Error(`Failed to find prompt with title: \"${title}\" and id: \"${id}\"`);\n }\n return result;\n });\n\n // For cache\n this.lastUpdatedAt = new Date();\n\n return response;\n }\n\n /**\n * Get an agent definition by name\n *\n * @param name - Name of the agent to grab\n * @returns Large language model configuration\n */\n async getAgentByName(name: string): Promise<Agent | undefined> {\n const agent = this.agentsByName[name];\n if (agent) {\n return agent;\n }\n const [remoteAgent] = await fetchAllAgents(this.graphQLClient, {\n logger,\n filterBy: { names: [name] },\n });\n if (!remoteAgent) {\n return undefined;\n }\n this.agentsByName[remoteAgent.name] = remoteAgent;\n this.agentsByAgentId[remoteAgent.agentId] = remoteAgent;\n return remoteAgent;\n }\n\n /**\n * Get a prompt thread by ts\n *\n * @param ts - the slack message timestamp to look up thread for\n * @returns Large language model configuration\n */\n async getPromptThreadBySlackTs(ts: string): Promise<PromptThread | undefined> {\n const [thread] = await fetchAllPromptThreads(this.graphQLClient, {\n logger,\n filterBy: { slackMessageTs: [ts] },\n });\n return thread;\n }\n\n /**\n * Get a list of agent definitions by name.\n * Pulls from cache and may return less agents\n * than requested if some are not found\n *\n * @param names - Names of agents to fetch\n * @returns The agents that were found matching the names\n */\n async getAgentsByName(names: string[]): Promise<Agent[]> {\n if (names.length < 1) {\n throw new Error('Expected at least one name to be provided');\n }\n const { hasCache = [], missingCache = [] } = groupBy(names, (name) =>\n this.agentsByName[name] ? 'hasCache' : 'missingCache',\n );\n const cachedAgents = hasCache.map((name) => this.agentsByName[name]);\n if (missingCache.length === 0) {\n return cachedAgents;\n }\n const chunkedNames = chunk(missingCache, 50);\n const remoteAgents: Agent[] = [];\n await mapSeries(chunkedNames, async (chunkedName) => {\n const pageOfAgents = await fetchAllAgents(this.graphQLClient, {\n logger,\n filterBy: { names: chunkedName },\n });\n pageOfAgents.forEach((agent) => {\n this.agentsByName[agent.name] = agent;\n this.agentsByAgentId[agent.agentId] = agent;\n });\n remoteAgents.push(...pageOfAgents);\n });\n return [...cachedAgents, ...remoteAgents];\n }\n\n /**\n * Fetch metadata on agent files\n *\n * @param filterBy - Filter by parameters\n * @returns The files found matching the filter\n */\n getAgentFiles(filterBy: AgentFileFilterBy): Promise<AgentFile[]> {\n return fetchAllAgentFiles(this.graphQLClient, { logger, filterBy });\n }\n\n /**\n * Look up the large language model to report on\n *\n * @param largeLanguageModel - Input\n * @returns Large language model configuration\n */\n getLargeLanguageModel(\n largeLanguageModel: ReportPromptRunOptions['largeLanguageModel'],\n ): LargeLanguageModel {\n const matching = this.largeLanguageModels.find((model) =>\n typeof largeLanguageModel === 'string'\n ? model.id === largeLanguageModel\n : model.name === largeLanguageModel.name && model.client === largeLanguageModel.client,\n );\n if (!matching) {\n throw new Error(\n `Failed to find model matching: ${\n typeof largeLanguageModel === 'string'\n ? largeLanguageModel\n : JSON.stringify(largeLanguageModel)\n }`,\n );\n }\n return matching;\n }\n\n /**\n * Get a prompt definition by name\n *\n * @param promptName - Prompt to compile\n * @returns Parsed content\n */\n async getPromptDefinition<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n ): Promise<TranscendPromptTemplated> {\n // Determine if prompts need to be fetched\n if (\n // never been fetched\n !this.lastUpdatedAt ||\n // fetch every run\n this.cacheDuration === 0 ||\n // If cache duration met\n (this.cacheDuration && Date.now() - this.lastUpdatedAt.getTime() > this.cacheDuration)\n ) {\n await this.fetchPromptsAndMetadata();\n }\n\n // Lookup prompt\n const { promptContentMap } = this;\n if (!promptContentMap) {\n throw new Error('Expected this.promptContentMap to be defined');\n }\n const promptTemplate = promptContentMap[promptName];\n if (!promptTemplate) {\n throw new Error(`Expected this.promptContentMap[${promptName}] to be defined`);\n }\n return promptTemplate;\n }\n\n /**\n * Validate the shape of the response from AI\n *\n * @param promptName - Prompt to compile\n * @param params - Runtime parameters\n * @returns Parsed content\n */\n async compilePrompt<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n params: t.TypeOf<TPrompts[TPromptName]['paramCodec']>,\n ): Promise<string> {\n // Grab the prompt\n const promptTemplate = await this.getPromptDefinition(promptName);\n const promptInput = this.prompts[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Ensure prompt is approved\n if (this.requireApproval && promptTemplate.status !== PromptStatus.Approved) {\n throw new Error(\n `Assessment \"${promptTemplate.title}\" cannot be used because its in status: \"${promptTemplate.status}\"`,\n );\n }\n\n // If prompt is rejected, throw error\n if (promptTemplate.status === PromptStatus.Rejected) {\n throw new Error(\n `Assessment \"${promptTemplate.title}\" cannot be used because it's in status: \"${promptTemplate.status}\"`,\n );\n }\n\n // Validate params\n decodeCodec(promptInput.paramCodec, params);\n\n // Compile prompt and template\n return this.handlebars.compile(promptTemplate.content)({\n // template in currentDate by default\n currentDate: new Date().toISOString(),\n ...this.variables,\n ...params,\n });\n }\n\n /**\n * Validate the shape of the response from AI\n *\n * @param promptName - Prompt to parse\n * @param response - AI response as string\n * @returns Parsed content\n */\n parseAiResponse<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n response: string,\n ): t.TypeOf<TPrompts[TPromptName]['outputCodec']> {\n // Look up prompt info\n const promptInput = this.prompts[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Extract from tag if needed\n const extracted = promptInput.extractFromTag\n ? (createRegexForTag(promptInput.extractFromTag).exec(response) || [])[1] || response\n : response;\n\n // Parse via codec\n return decodeCodec(promptInput.outputCodec, jsonParseSafe(extracted), false);\n }\n\n /**\n * Parse the AI response and report back to Transcend\n *\n * @param promptName - Prompt to parse\n * @param options - Options for reporting\n * @returns Parsed content\n */\n async reportAndParsePromptRun<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n { largeLanguageModel, ...options }: ReportPromptRunOptions,\n ): Promise<\n PromptRunResult & {\n /** Resulting prompt run */\n result: t.TypeOf<TPrompts[TPromptName]['outputCodec']>;\n }\n > {\n // Determine if prompts need to be fetched\n if (\n // never been fetched\n !this.lastUpdatedAt ||\n // fetch every run\n this.cacheDuration === 0 ||\n // If cache duration met\n (this.cacheDuration && Date.now() - this.lastUpdatedAt.getTime() > this.cacheDuration)\n ) {\n await this.fetchPromptsAndMetadata();\n }\n\n const name = options.name || `@transcend-io/cli-prompt-run-${new Date().toISOString()}`;\n\n if (!this.promptContentMap) {\n throw new Error('Expected this.promptContentMap to be defined');\n }\n // Look up prompt info\n const promptInput = this.promptContentMap[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Ensure the first message in `promptRunMessages` is of type=system\n if (options.promptRunMessages.length === 0) {\n throw new Error('promptRunMessages is expected to have length > 0');\n }\n if (options.promptRunMessages[0].role !== ChatCompletionRole.System) {\n throw new Error(`promptRunMessages[0].role is expected to be = ${ChatCompletionRole.System}`);\n }\n if (\n options.promptRunMessages[options.promptRunMessages.length - 1].role !==\n ChatCompletionRole.Assistant\n ) {\n throw new Error(\n `promptRunMessages[${\n options.promptRunMessages.length - 1\n }].role is expected to be = ${ChatCompletionRole.Assistant}`,\n );\n }\n const response = options.promptRunMessages[options.promptRunMessages.length - 1].content;\n\n let parsed: t.TypeOf<TPrompts[TPromptName]['outputCodec']>;\n try {\n // Parse the response\n parsed = this.parseAiResponse(promptName, response);\n } catch (err) {\n await reportPromptRun(\n this.graphQLClient,\n {\n productArea: PromptRunProductArea.PromptManager,\n ...options,\n name,\n error: err.message,\n status: QueueStatus.Error,\n ...(typeof largeLanguageModel === 'string'\n ? { largeLanguageModelId: largeLanguageModel }\n : {\n largeLanguageModelName: largeLanguageModel.name,\n largeLanguageModelClient: largeLanguageModel.client,\n }),\n promptId: promptInput.id,\n promptRunMessages: options.promptRunMessages.map((message, ind) => ({\n ...message,\n ...(ind === 0 ? { template: promptInput.content } : {}),\n })),\n },\n { logger },\n );\n throw err;\n }\n\n // report successful run\n const promptRunId = await reportPromptRun(\n this.graphQLClient,\n {\n productArea: PromptRunProductArea.PromptManager,\n ...options,\n name,\n status: QueueStatus.Resolved,\n ...(typeof largeLanguageModel === 'string'\n ? { largeLanguageModelId: largeLanguageModel }\n : {\n largeLanguageModelName: largeLanguageModel.name,\n largeLanguageModelClient: largeLanguageModel.client,\n }),\n promptId: promptInput.id,\n promptRunMessages: options.promptRunMessages.map((message, ind) => ({\n ...message,\n ...(ind === 0 ? { template: promptInput.content } : {}),\n })),\n },\n { logger },\n );\n\n return {\n result: parsed,\n promptRunId,\n promptRunUrl: `https://app.transcend.io/prompts/runs/${promptRunId}`,\n };\n }\n\n /**\n * Report an error for a particular prompt\n *\n * @param promptName - Prompt to parse\n * @param options - Options for reporting\n * @returns Parsed content\n */\n async reportPromptRunError<TPromptName extends TPromptNames>(\n promptName: TPromptName,\n { largeLanguageModel, ...options }: Requirize<ReportPromptRunOptions, 'error'>,\n ): Promise<PromptRunResult> {\n // Determine if prompts need to be fetched\n if (\n // never been fetched\n !this.lastUpdatedAt ||\n // fetch every run\n this.cacheDuration === 0 ||\n // If cache duration met\n (this.cacheDuration && Date.now() - this.lastUpdatedAt.getTime() > this.cacheDuration)\n ) {\n await this.fetchPromptsAndMetadata();\n }\n\n const name = options.name || `@transcend-io/cli-prompt-run-${new Date().toISOString()}`;\n\n if (!this.promptContentMap) {\n throw new Error('Expected this.promptContentMap to be defined');\n }\n // Look up prompt info\n const promptInput = this.promptContentMap[promptName];\n if (!promptInput) {\n throw new Error(`Expected this.prompts[${promptName}] to be defined`);\n }\n\n // Ensure the first message in `promptRunMessages` is of type=system\n if (options.promptRunMessages.length === 0) {\n throw new Error('promptRunMessages is expected to have length > 0');\n }\n if (options.promptRunMessages[0].role !== ChatCompletionRole.System) {\n throw new Error(`promptRunMessages[0].role is expected to be = ${ChatCompletionRole.System}`);\n }\n\n const promptRunId = await reportPromptRun(\n this.graphQLClient,\n {\n productArea: PromptRunProductArea.PromptManager,\n ...options,\n name,\n status: QueueStatus.Error,\n ...(typeof largeLanguageModel === 'string'\n ? { largeLanguageModelId: largeLanguageModel }\n : {\n largeLanguageModelName: largeLanguageModel.name,\n largeLanguageModelClient: largeLanguageModel.client,\n }),\n promptId: promptInput.id,\n promptRunMessages: options.promptRunMessages.map((message, ind) => ({\n ...message,\n ...(ind === 0 ? { template: promptInput.content } : {}),\n })),\n },\n { logger },\n );\n\n return {\n promptRunId,\n promptRunUrl: `https://app.transcend.io/prompts/runs/${promptRunId}`,\n };\n }\n}\n/* eslint-enable max-lines */\n","/**\n * Remove links from a string\n *\n * @param inputString - String\n * @returns String without links\n */\nexport function removeLinks(inputString: string): string {\n const regex = /(https?:\\/\\/[^\\s]+)/g;\n return inputString.replace(regex, '<link-omitted>');\n}\n","import { ObjByString } from '@transcend-io/type-utils';\n\n/**\n * Given an object, remove all keys that are null-ish\n *\n * @param obj - Object\n * @returns Object with null-ish values removed\n */\nexport function filterNullishValuesFromObject<T extends ObjByString>(obj: T): T {\n return Object.entries(obj).reduce(\n (acc, [k, v]) =>\n v !== null &&\n v !== undefined &&\n v !== '' &&\n !(Array.isArray(v) && v.length === 0) &&\n !(typeof v === 'object' && Object.keys(v).length === 0)\n ? Object.assign(acc, { [k]: v })\n : acc,\n {} as T,\n );\n}\n","import { execSync } from 'child_process';\n\nimport fastGlob from 'fast-glob';\nimport { difference } from 'lodash-es';\n\n/**\n * Function thats gets the git files that have changed\n * and returns the code\n *\n * @param options - Options\n * @returns Changes files and diffs\n */\nexport function getGitFilesThatChanged({\n baseBranch,\n rootDirectory,\n githubRepo,\n excludedGlob = [],\n fileBlockList = [],\n}: {\n /** Base branch */\n baseBranch: string;\n /** Github repo name */\n githubRepo: string;\n /** Root directory */\n rootDirectory: string;\n /** A glob that excludes files */\n excludedGlob?: string[];\n /** Block list of files to not process */\n fileBlockList?: string[];\n}): {\n /** The list of files that changed */\n changedFiles: string[];\n /** Github repo name */\n repoName: string;\n /** Current commit */\n commit: string;\n /** File diffs */\n fileDiffs: { [k in string]: string };\n} {\n // Pull base branch\n execSync(`git fetch origin ${baseBranch}`);\n\n // Latest commit on base branch. If we are on the base branch, we take the prior commit\n const latestBasedCommit = execSync(\n `git ls-remote ${githubRepo} \"refs/heads/${baseBranch}\" | cut -f 1`,\n { encoding: 'utf-8' },\n ).split('\\n')[0];\n\n // This commit\n const latestThisCommit = execSync('git rev-parse HEAD', {\n encoding: 'utf-8',\n }).split('\\n')[0];\n\n // Ensure commits are present\n if (!latestBasedCommit || !latestThisCommit) {\n throw new Error('FAILED TO FIND COMMIT RANGE');\n }\n\n // Get the diff between the given branch and base branch\n const diff = execSync(\n `git fetch && git diff --name-only \"${\n baseBranch || latestBasedCommit\n }...${latestThisCommit}\" -- ${rootDirectory}`,\n { encoding: 'utf-8' },\n );\n\n // Filter out block list\n const changedFiles = difference(\n diff.split('\\n').filter((f) => f),\n fileBlockList,\n );\n\n // Filter out globs\n const filteredChanges =\n excludedGlob.length > 0 ? fastGlob.sync(changedFiles, { ignore: excludedGlob }) : changedFiles;\n\n // Get the contents of only the changed files\n const fileDiffs: { [k in string]: string } = {};\n filteredChanges.forEach((file) => {\n const contents = execSync(`git show ${latestThisCommit}:${file}`, {\n encoding: 'utf-8',\n });\n fileDiffs[file] = contents;\n });\n\n // Pull the github repo name\n const repoName = githubRepo.split('/').pop()!.split('.')[0];\n\n return {\n changedFiles,\n fileDiffs,\n repoName,\n commit: latestThisCommit,\n };\n}\n"],"mappings":"wlKAsBA,eAAsB,EACpB,EACA,EACe,CACf,IAAM,EAAiB,MAAM,GAAsB,EAAQ,CAAE,SAAQ,CAAC,CAMtE,MAAM,EAAU,EAAM,EAAc,IAAc,CAAE,KAAO,IAAS,CAClE,MAAM,GAAmB,EAAQ,GAA0B,CACzD,UAAW,CACT,iBACA,QAAS,EAAK,IAAK,IAAY,CAC7B,KAAM,EAAO,KACb,iBACE,EAAO,kBAAoB,EAAO,iBAAiB,OAAS,EACxD,EAAO,iBACP,IAAA,GAON,YAAa,EAAO,YACpB,QAAS,EAAO,QAChB,OAAQ,EAAO,OACf,WAAY,EAAO,WACnB,QAAS,EAAO,QAIjB,EAAE,CACJ,CACD,SACD,CAAC,EACF,CAUJ,eAAsB,GAAY,EAAuB,EAA0C,CACjG,IAAI,EAAmB,GACvB,EAAO,KAAK,EAAO,QAAQ,YAAY,EAAQ,OAAO,cAAc,CAAC,CAGrE,IAAM,EAAY,EAAQ,OACvB,GACC,EAAQ,OAAQ,GAAS,EAAO,OAAS,EAAK,MAAQ,EAAO,UAAY,EAAK,QAAQ,CACnF,OAAS,EACf,CACD,GAAI,EAAU,OAAS,EACrB,MAAU,MACR,oEAAoE,EACjE,KAAK,CAAE,UAAW,EAAK,CACvB,KAAK,IAAI,GACb,CAGH,GAAI,CACF,EAAO,KAAK,EAAO,QAAQ,cAAc,EAAQ,OAAO,kBAAkB,CAAC,CAC3E,MAAM,EAAsB,EAAQ,EAAQ,CAC5C,EAAO,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W,cACtD,CAAE,SAAU,QAAS,CACtB,CAAC,MAAM;EAAK,CAAC,GAGR,EAAmB,EAAS,qBAAsB,CACtD,SAAU,QACX,CAAC,CAAC,MAAM;EAAK,CAAC,GAGf,GAAI,CAAC,GAAqB,CAAC,EACzB,MAAU,MAAM,8BAA8B,CAYhD,IAAM,EAAe,GARR,EACX,sCACE,GAAc,EACf,KAAK,EAAiB,OAAO,IAC9B,CAAE,SAAU,QAAS,CACtB,CAIM,MAAM;EAAK,CAAC,OAAQ,GAAM,EAAE,CACjC,EACD,CAGK,EACJ,EAAa,OAAS,EAAI,GAAS,KAAK,EAAc,CAAE,OAAQ,EAAc,CAAC,CAAG,EAG9E,EAAuC,EAAE,CAW/C,OAVA,EAAgB,QAAS,GAAS,CAIhC,EAAU,GAHO,EAAS,YAAY,EAAiB,GAAG,IAAQ,CAChE,SAAU,QACX,CAAC,EAEF,CAKK,CACL,eACA,YACA,SALe,EAAW,MAAM,IAAI,CAAC,KAAK,CAAE,MAAM,IAAI,CAAC,GAMvD,OAAQ,EACT"}
@@ -1,2 +1,2 @@
1
- import{a as e}from"./constants-BwO3d-v4.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{RequestDataSiloStatus as n}from"@transcend-io/privacy-types";import r from"colors";import{CHANGE_REQUEST_DATA_SILO_STATUS as i,buildTranscendGraphQLClient as a,fetchRequestDataSilo as o,makeGraphQLRequest as s}from"@transcend-io/sdk";import{map as c}from"@transcend-io/utils";import l from"cli-progress";async function u({requestIds:u,dataSiloId:d,auth:f,concurrency:p=100,status:m=n.Resolved,transcendUrl:h=e}){let g=a(h,f),_=new Date().getTime(),v=new l.SingleBar({},l.Presets.shades_classic);t.info(r.magenta(`Notifying Transcend for data silo "${d}" marking "${u.length}" requests as completed.`));let y=0;v.start(u.length,0),await c(u,async e=>{let n=await o(g,{logger:t,filterBy:{requestId:e,dataSiloId:d}});try{await s(g,i,{variables:{requestDataSiloId:n.id,status:m},logger:t})}catch(e){if(!e.message.includes(`Client error: Request must be active:`)&&!e.message.includes(`Failed to find RequestDataSilo`))throw e}y+=1,v.update(y)},{concurrency:p}),v.stop();let b=new Date().getTime()-_;return t.info(r.green(`Successfully notified Transcend in "${b/1e3}" seconds!`)),u.length}export{u as t};
2
- //# sourceMappingURL=markRequestDataSiloIdsCompleted-URGUyr71.mjs.map
1
+ import{a as e}from"./constants-BdUSsxl7.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{RequestDataSiloStatus as n}from"@transcend-io/privacy-types";import r from"colors";import{CHANGE_REQUEST_DATA_SILO_STATUS as i,buildTranscendGraphQLClient as a,fetchRequestDataSilo as o,makeGraphQLRequest as s}from"@transcend-io/sdk";import{map as c}from"@transcend-io/utils";import l from"cli-progress";async function u({requestIds:u,dataSiloId:d,auth:f,concurrency:p=100,status:m=n.Resolved,transcendUrl:h=e}){let g=a(h,f),_=new Date().getTime(),v=new l.SingleBar({},l.Presets.shades_classic);t.info(r.magenta(`Notifying Transcend for data silo "${d}" marking "${u.length}" requests as completed.`));let y=0;v.start(u.length,0),await c(u,async e=>{let n=await o(g,{logger:t,filterBy:{requestId:e,dataSiloId:d}});try{await s(g,i,{variables:{requestDataSiloId:n.id,status:m},logger:t})}catch(e){if(!e.message.includes(`Client error: Request must be active:`)&&!e.message.includes(`Failed to find RequestDataSilo`))throw e}y+=1,v.update(y)},{concurrency:p}),v.stop();let b=new Date().getTime()-_;return t.info(r.green(`Successfully notified Transcend in "${b/1e3}" seconds!`)),u.length}export{u as t};
2
+ //# sourceMappingURL=markRequestDataSiloIdsCompleted-nKo6RUOH.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"markRequestDataSiloIdsCompleted-URGUyr71.mjs","names":[],"sources":["../src/lib/cron/markRequestDataSiloIdsCompleted.ts"],"sourcesContent":["import { RequestDataSiloStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n makeGraphQLRequest,\n CHANGE_REQUEST_DATA_SILO_STATUS,\n fetchRequestDataSilo,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\n\n/**\n * Given a CSV of Request IDs, mark associated RequestDataSilos as completed\n *\n * @param options - Options\n * @returns Number of items marked as completed\n */\nexport async function markRequestDataSiloIdsCompleted({\n requestIds,\n dataSiloId,\n auth,\n concurrency = 100,\n status = RequestDataSiloStatus.Resolved,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The list of request ids to mark as completed */\n requestIds: string[];\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** Status to update requests to */\n status?: RequestDataSiloStatus;\n /** Upload concurrency */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Notify Transcend\n logger.info(\n colors.magenta(\n `Notifying Transcend for data silo \"${dataSiloId}\" marking \"${requestIds.length}\" requests as completed.`,\n ),\n );\n\n let total = 0;\n progressBar.start(requestIds.length, 0);\n await map(\n requestIds,\n async (requestId) => {\n const requestDataSilo = await fetchRequestDataSilo(client, {\n logger,\n filterBy: { requestId, dataSiloId },\n });\n\n try {\n await makeGraphQLRequest<{\n /** Whether we successfully uploaded the results */\n success: boolean;\n }>(client, CHANGE_REQUEST_DATA_SILO_STATUS, {\n variables: {\n requestDataSiloId: requestDataSilo.id,\n status,\n },\n logger,\n });\n } catch (err) {\n if (\n !err.message.includes('Client error: Request must be active:') &&\n !err.message.includes('Failed to find RequestDataSilo')\n ) {\n throw err;\n }\n }\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(colors.green(`Successfully notified Transcend in \"${totalTime / 1000}\" seconds!`));\n return requestIds.length;\n}\n"],"mappings":"yYAoBA,eAAsB,EAAgC,CACpD,aACA,aACA,OACA,cAAc,IACd,SAAS,EAAsB,SAC/B,eAAe,GAcG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAGrF,EAAO,KACL,EAAO,QACL,sCAAsC,EAAW,aAAa,EAAW,OAAO,0BACjF,CACF,CAED,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAW,OAAQ,EAAE,CACvC,MAAM,EACJ,EACA,KAAO,IAAc,CACnB,IAAM,EAAkB,MAAM,EAAqB,EAAQ,CACzD,SACA,SAAU,CAAE,YAAW,aAAY,CACpC,CAAC,CAEF,GAAI,CACF,MAAM,EAGH,EAAQ,EAAiC,CAC1C,UAAW,CACT,kBAAmB,EAAgB,GACnC,SACD,CACD,SACD,CAAC,OACK,EAAK,CACZ,GACE,CAAC,EAAI,QAAQ,SAAS,wCAAwC,EAC9D,CAAC,EAAI,QAAQ,SAAS,iCAAiC,CAEvD,MAAM,EAIV,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAGvB,OADA,EAAO,KAAK,EAAO,MAAM,uCAAuC,EAAY,IAAK,YAAY,CAAC,CACvF,EAAW"}
1
+ {"version":3,"file":"markRequestDataSiloIdsCompleted-nKo6RUOH.mjs","names":[],"sources":["../src/lib/cron/markRequestDataSiloIdsCompleted.ts"],"sourcesContent":["import { RequestDataSiloStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n makeGraphQLRequest,\n CHANGE_REQUEST_DATA_SILO_STATUS,\n fetchRequestDataSilo,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\n\n/**\n * Given a CSV of Request IDs, mark associated RequestDataSilos as completed\n *\n * @param options - Options\n * @returns Number of items marked as completed\n */\nexport async function markRequestDataSiloIdsCompleted({\n requestIds,\n dataSiloId,\n auth,\n concurrency = 100,\n status = RequestDataSiloStatus.Resolved,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The list of request ids to mark as completed */\n requestIds: string[];\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** Status to update requests to */\n status?: RequestDataSiloStatus;\n /** Upload concurrency */\n concurrency?: number;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Notify Transcend\n logger.info(\n colors.magenta(\n `Notifying Transcend for data silo \"${dataSiloId}\" marking \"${requestIds.length}\" requests as completed.`,\n ),\n );\n\n let total = 0;\n progressBar.start(requestIds.length, 0);\n await map(\n requestIds,\n async (requestId) => {\n const requestDataSilo = await fetchRequestDataSilo(client, {\n logger,\n filterBy: { requestId, dataSiloId },\n });\n\n try {\n await makeGraphQLRequest<{\n /** Whether we successfully uploaded the results */\n success: boolean;\n }>(client, CHANGE_REQUEST_DATA_SILO_STATUS, {\n variables: {\n requestDataSiloId: requestDataSilo.id,\n status,\n },\n logger,\n });\n } catch (err) {\n if (\n !err.message.includes('Client error: Request must be active:') &&\n !err.message.includes('Failed to find RequestDataSilo')\n ) {\n throw err;\n }\n }\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(colors.green(`Successfully notified Transcend in \"${totalTime / 1000}\" seconds!`));\n return requestIds.length;\n}\n"],"mappings":"yYAoBA,eAAsB,EAAgC,CACpD,aACA,aACA,OACA,cAAc,IACd,SAAS,EAAsB,SAC/B,eAAe,GAcG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAGrF,EAAO,KACL,EAAO,QACL,sCAAsC,EAAW,aAAa,EAAW,OAAO,0BACjF,CACF,CAED,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAW,OAAQ,EAAE,CACvC,MAAM,EACJ,EACA,KAAO,IAAc,CACnB,IAAM,EAAkB,MAAM,EAAqB,EAAQ,CACzD,SACA,SAAU,CAAE,YAAW,aAAY,CACpC,CAAC,CAEF,GAAI,CACF,MAAM,EAGH,EAAQ,EAAiC,CAC1C,UAAW,CACT,kBAAmB,EAAgB,GACnC,SACD,CACD,SACD,CAAC,OACK,EAAK,CACZ,GACE,CAAC,EAAI,QAAQ,SAAS,wCAAwC,EAC9D,CAAC,EAAI,QAAQ,SAAS,iCAAiC,CAEvD,MAAM,EAIV,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAGvB,OADA,EAAO,KAAK,EAAO,MAAM,uCAAuC,EAAY,IAAK,YAAY,CAAC,CACvF,EAAW"}
@@ -1,2 +1,2 @@
1
- import{a as e}from"./constants-BwO3d-v4.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{o as n}from"./request-DfkRPQFr.mjs";import{r}from"./fetchAllRequests-CHHdyb4Q.mjs";import{RequestStatus as i}from"@transcend-io/privacy-types";import a from"colors";import{buildTranscendGraphQLClient as o,makeGraphQLRequest as s}from"@transcend-io/sdk";import{map as c}from"@transcend-io/utils";import l from"cli-progress";async function u({requestActions:u,auth:d,requestIds:f,statuses:p=[i.Compiling,i.RequestMade,i.Delayed,i.Approving,i.Secondary,i.Enriching,i.Waiting,i.SecondaryApproving],createdAtAfter:m,createdAtBefore:h,updatedAtBefore:g,updatedAtAfter:_,concurrency:v=100,transcendUrl:y=e}){let b=o(y,d),x=new Date().getTime(),S=new l.SingleBar({},l.Presets.shades_classic),C=await r(b,{actions:u,statuses:p,createdAtBefore:h,createdAtAfter:m,updatedAtBefore:g,updatedAtAfter:_,isSilent:!1,requestIds:f});t.info(a.magenta(`Marking "${C.length}" as silent mode.`));let w=0;S.start(C.length,0),await c(C,async e=>{await s(b,n,{variables:{input:{id:e.id,isSilent:!0}},logger:t}),w+=1,S.update(w)},{concurrency:v}),S.stop();let T=new Date().getTime()-x;return t.info(a.green(`Successfully marked ${w} requests as silent mode in "${T/1e3}" seconds!`)),C.length}export{u as t};
2
- //# sourceMappingURL=markSilentPrivacyRequests-DDKRgQdo.mjs.map
1
+ import{a as e}from"./constants-BdUSsxl7.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{o as n}from"./request-DfkRPQFr.mjs";import{r}from"./fetchAllRequests-CHHdyb4Q.mjs";import{RequestStatus as i}from"@transcend-io/privacy-types";import a from"colors";import{buildTranscendGraphQLClient as o,makeGraphQLRequest as s}from"@transcend-io/sdk";import{map as c}from"@transcend-io/utils";import l from"cli-progress";async function u({requestActions:u,auth:d,requestIds:f,statuses:p=[i.Compiling,i.RequestMade,i.Delayed,i.Approving,i.Secondary,i.Enriching,i.Waiting,i.SecondaryApproving],createdAtAfter:m,createdAtBefore:h,updatedAtBefore:g,updatedAtAfter:_,concurrency:v=100,transcendUrl:y=e}){let b=o(y,d),x=new Date().getTime(),S=new l.SingleBar({},l.Presets.shades_classic),C=await r(b,{actions:u,statuses:p,createdAtBefore:h,createdAtAfter:m,updatedAtBefore:g,updatedAtAfter:_,isSilent:!1,requestIds:f});t.info(a.magenta(`Marking "${C.length}" as silent mode.`));let w=0;S.start(C.length,0),await c(C,async e=>{await s(b,n,{variables:{input:{id:e.id,isSilent:!0}},logger:t}),w+=1,S.update(w)},{concurrency:v}),S.stop();let T=new Date().getTime()-x;return t.info(a.green(`Successfully marked ${w} requests as silent mode in "${T/1e3}" seconds!`)),C.length}export{u as t};
2
+ //# sourceMappingURL=markSilentPrivacyRequests-DCrw92hR.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"markSilentPrivacyRequests-DDKRgQdo.mjs","names":[],"sources":["../src/lib/requests/markSilentPrivacyRequests.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport { buildTranscendGraphQLClient, makeGraphQLRequest } from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { UPDATE_PRIVACY_REQUEST, fetchAllRequests } from '../graphql/index.js';\n\n/**\n * Mark a set of privacy requests to be in silent mode\n *\n * @param options - Options\n * @returns The number of requests marked silent\n */\nexport async function markSilentPrivacyRequests({\n requestActions,\n auth,\n requestIds,\n statuses = [\n RequestStatus.Compiling,\n RequestStatus.RequestMade,\n RequestStatus.Delayed,\n RequestStatus.Approving,\n RequestStatus.Secondary,\n RequestStatus.Enriching,\n RequestStatus.Waiting,\n RequestStatus.SecondaryApproving,\n ],\n createdAtAfter,\n createdAtBefore,\n updatedAtBefore,\n updatedAtAfter,\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The request actions that should be restarted */\n requestActions: RequestAction[];\n /** Transcend API key authentication */\n auth: string;\n /** Concurrency limit for approving */\n concurrency?: number;\n /** The request statuses to mark silent */\n statuses?: RequestStatus[];\n /** The set of privacy requests to mark silent */\n requestIds?: string[];\n /** Filter for requests created before this date */\n createdAtBefore?: Date;\n /** Filter for requests created after this date */\n createdAtAfter?: Date;\n /** Filter for requests updated before this date */\n updatedAtBefore?: Date;\n /** Filter for requests updated after this date */\n updatedAtAfter?: Date;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Pull in the requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isSilent: false,\n requestIds,\n });\n\n // Notify Transcend\n logger.info(colors.magenta(`Marking \"${allRequests.length}\" as silent mode.`));\n\n let total = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToMarkSilent) => {\n await makeGraphQLRequest(client, UPDATE_PRIVACY_REQUEST, {\n variables: {\n input: {\n id: requestToMarkSilent.id,\n isSilent: true,\n },\n },\n logger,\n });\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully marked ${total} requests as silent mode in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n return allRequests.length;\n}\n"],"mappings":"4ZAgBA,eAAsB,EAA0B,CAC9C,iBACA,OACA,aACA,WAAW,CACT,EAAc,UACd,EAAc,YACd,EAAc,QACd,EAAc,UACd,EAAc,UACd,EAAc,UACd,EAAc,QACd,EAAc,mBACf,CACD,iBACA,kBACA,kBACA,iBACA,cAAc,IACd,eAAe,GAsBG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAG/E,EAAc,MAAM,EAAiB,EAAQ,CACjD,QAAS,EACT,WACA,kBACA,iBACA,kBACA,iBACA,SAAU,GACV,aACD,CAAC,CAGF,EAAO,KAAK,EAAO,QAAQ,YAAY,EAAY,OAAO,mBAAmB,CAAC,CAE9E,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAY,OAAQ,EAAE,CACxC,MAAM,EACJ,EACA,KAAO,IAAwB,CAC7B,MAAM,EAAmB,EAAQ,EAAwB,CACvD,UAAW,CACT,MAAO,CACL,GAAI,EAAoB,GACxB,SAAU,GACX,CACF,CACD,SACD,CAAC,CAEF,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAOvB,OALA,EAAO,KACL,EAAO,MACL,uBAAuB,EAAM,+BAA+B,EAAY,IAAK,YAC9E,CACF,CACM,EAAY"}
1
+ {"version":3,"file":"markSilentPrivacyRequests-DCrw92hR.mjs","names":[],"sources":["../src/lib/requests/markSilentPrivacyRequests.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport { buildTranscendGraphQLClient, makeGraphQLRequest } from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { UPDATE_PRIVACY_REQUEST, fetchAllRequests } from '../graphql/index.js';\n\n/**\n * Mark a set of privacy requests to be in silent mode\n *\n * @param options - Options\n * @returns The number of requests marked silent\n */\nexport async function markSilentPrivacyRequests({\n requestActions,\n auth,\n requestIds,\n statuses = [\n RequestStatus.Compiling,\n RequestStatus.RequestMade,\n RequestStatus.Delayed,\n RequestStatus.Approving,\n RequestStatus.Secondary,\n RequestStatus.Enriching,\n RequestStatus.Waiting,\n RequestStatus.SecondaryApproving,\n ],\n createdAtAfter,\n createdAtBefore,\n updatedAtBefore,\n updatedAtAfter,\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The request actions that should be restarted */\n requestActions: RequestAction[];\n /** Transcend API key authentication */\n auth: string;\n /** Concurrency limit for approving */\n concurrency?: number;\n /** The request statuses to mark silent */\n statuses?: RequestStatus[];\n /** The set of privacy requests to mark silent */\n requestIds?: string[];\n /** Filter for requests created before this date */\n createdAtBefore?: Date;\n /** Filter for requests created after this date */\n createdAtAfter?: Date;\n /** Filter for requests updated before this date */\n updatedAtBefore?: Date;\n /** Filter for requests updated after this date */\n updatedAtAfter?: Date;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Pull in the requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isSilent: false,\n requestIds,\n });\n\n // Notify Transcend\n logger.info(colors.magenta(`Marking \"${allRequests.length}\" as silent mode.`));\n\n let total = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToMarkSilent) => {\n await makeGraphQLRequest(client, UPDATE_PRIVACY_REQUEST, {\n variables: {\n input: {\n id: requestToMarkSilent.id,\n isSilent: true,\n },\n },\n logger,\n });\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully marked ${total} requests as silent mode in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n return allRequests.length;\n}\n"],"mappings":"4ZAgBA,eAAsB,EAA0B,CAC9C,iBACA,OACA,aACA,WAAW,CACT,EAAc,UACd,EAAc,YACd,EAAc,QACd,EAAc,UACd,EAAc,UACd,EAAc,UACd,EAAc,QACd,EAAc,mBACf,CACD,iBACA,kBACA,kBACA,iBACA,cAAc,IACd,eAAe,GAsBG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAG/E,EAAc,MAAM,EAAiB,EAAQ,CACjD,QAAS,EACT,WACA,kBACA,iBACA,kBACA,iBACA,SAAU,GACV,aACD,CAAC,CAGF,EAAO,KAAK,EAAO,QAAQ,YAAY,EAAY,OAAO,mBAAmB,CAAC,CAE9E,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAY,OAAQ,EAAE,CACxC,MAAM,EACJ,EACA,KAAO,IAAwB,CAC7B,MAAM,EAAmB,EAAQ,EAAwB,CACvD,UAAW,CACT,MAAO,CACL,GAAI,EAAoB,GACxB,SAAU,GACX,CACF,CACD,SACD,CAAC,CAEF,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAOvB,OALA,EAAO,KACL,EAAO,MACL,uBAAuB,EAAM,+BAA+B,EAAY,IAAK,YAC9E,CACF,CACM,EAAY"}
@@ -1,2 +1,2 @@
1
- import{a as e}from"./constants-BwO3d-v4.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{r as n}from"./request-DfkRPQFr.mjs";import{r}from"./fetchAllRequests-CHHdyb4Q.mjs";import{RequestAction as i}from"@transcend-io/privacy-types";import a from"colors";import{buildTranscendGraphQLClient as o,fetchAllTemplates as s,makeGraphQLRequest as c}from"@transcend-io/sdk";import{map as l}from"@transcend-io/utils";import u from"cli-progress";async function d({requestActions:d=Object.values(i),auth:f,requestIds:p,createdAtBefore:m,days:h=45,daysLeft:g=10,createdAtAfter:_,updatedAtBefore:v,updatedAtAfter:y,emailTemplate:b=`Additional Time Needed`,concurrency:x=100,transcendUrl:S=e}){let C=o(S,f),w=new Date().getTime(),T=new u.SingleBar({},u.Presets.shades_classic),E=(await s(C,{logger:t,filterBy:{title:b}})).find(e=>e.title===b);if(!E)throw Error(`Failed to find a template with title: "${b}"`);let D=await r(C,{actions:d,createdAtBefore:m,createdAtAfter:_,updatedAtBefore:v,updatedAtAfter:y,isSilent:!1,isClosed:!1,requestIds:p});D=D.filter(e=>typeof e.daysRemaining==`number`&&e.daysRemaining<g),t.info(a.magenta(`Notifying "${D.length}" that more time is needed.`));let O=0;T.start(D.length,0),await l(D,async e=>{await c(C,n,{variables:{input:{requestId:e.id,template:E.template.defaultMessage,subject:E.subject.defaultMessage,additionalTime:h}},logger:t}),O+=1,T.update(O)},{concurrency:x}),T.stop();let k=new Date().getTime()-w;return t.info(a.green(`Successfully marked ${O} requests as silent mode in "${k/1e3}" seconds!`)),D.length}export{d as t};
2
- //# sourceMappingURL=notifyPrivacyRequestsAdditionalTime-BFkab0tk.mjs.map
1
+ import{a as e}from"./constants-BdUSsxl7.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{r as n}from"./request-DfkRPQFr.mjs";import{r}from"./fetchAllRequests-CHHdyb4Q.mjs";import{RequestAction as i}from"@transcend-io/privacy-types";import a from"colors";import{buildTranscendGraphQLClient as o,fetchAllTemplates as s,makeGraphQLRequest as c}from"@transcend-io/sdk";import{map as l}from"@transcend-io/utils";import u from"cli-progress";async function d({requestActions:d=Object.values(i),auth:f,requestIds:p,createdAtBefore:m,days:h=45,daysLeft:g=10,createdAtAfter:_,updatedAtBefore:v,updatedAtAfter:y,emailTemplate:b=`Additional Time Needed`,concurrency:x=100,transcendUrl:S=e}){let C=o(S,f),w=new Date().getTime(),T=new u.SingleBar({},u.Presets.shades_classic),E=(await s(C,{logger:t,filterBy:{title:b}})).find(e=>e.title===b);if(!E)throw Error(`Failed to find a template with title: "${b}"`);let D=await r(C,{actions:d,createdAtBefore:m,createdAtAfter:_,updatedAtBefore:v,updatedAtAfter:y,isSilent:!1,isClosed:!1,requestIds:p});D=D.filter(e=>typeof e.daysRemaining==`number`&&e.daysRemaining<g),t.info(a.magenta(`Notifying "${D.length}" that more time is needed.`));let O=0;T.start(D.length,0),await l(D,async e=>{await c(C,n,{variables:{input:{requestId:e.id,template:E.template.defaultMessage,subject:E.subject.defaultMessage,additionalTime:h}},logger:t}),O+=1,T.update(O)},{concurrency:x}),T.stop();let k=new Date().getTime()-w;return t.info(a.green(`Successfully marked ${O} requests as silent mode in "${k/1e3}" seconds!`)),D.length}export{d as t};
2
+ //# sourceMappingURL=notifyPrivacyRequestsAdditionalTime-Dl6QYo_s.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"notifyPrivacyRequestsAdditionalTime-BFkab0tk.mjs","names":[],"sources":["../src/lib/requests/notifyPrivacyRequestsAdditionalTime.ts"],"sourcesContent":["import { RequestAction } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n fetchAllTemplates,\n makeGraphQLRequest,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { NOTIFY_ADDITIONAL_TIME, fetchAllRequests } from '../graphql/index.js';\n\n/**\n * Mark a set of privacy requests to be in silent mode.\n * Note requests in silent mode are ignored\n *\n * @param options - Options\n * @returns The number of requests marked silent\n */\nexport async function notifyPrivacyRequestsAdditionalTime({\n requestActions = Object.values(RequestAction),\n auth,\n requestIds,\n createdAtBefore,\n days = 45,\n daysLeft = 10,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n emailTemplate = 'Additional Time Needed',\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The request actions that should be restarted */\n requestActions?: RequestAction[];\n /** Filter for requests created before this date */\n createdAtBefore: Date;\n /** Filter for requests created after this date */\n createdAtAfter?: Date;\n /** Filter for requests updated before this date */\n updatedAtBefore?: Date;\n /** Filter for requests updated after this date */\n updatedAtAfter?: Date;\n /** Email template */\n emailTemplate?: string;\n /** Transcend API key authentication */\n auth: string;\n /** Number of days to extend request by */\n days?: number;\n /**\n * Only notify requests that have less than this number of days until they are considered expired.\n * This allows for re-running the command without notifying the same users multiple times\n */\n daysLeft?: number;\n /** Concurrency limit for approving */\n concurrency?: number;\n /** The set of privacy requests to notify */\n requestIds?: string[];\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Grab the template with that title\n const matchingTemplates = await fetchAllTemplates(client, {\n logger,\n filterBy: { title: emailTemplate },\n });\n const exactTemplateMatch = matchingTemplates.find((template) => template.title === emailTemplate);\n if (!exactTemplateMatch) {\n throw new Error(`Failed to find a template with title: \"${emailTemplate}\"`);\n }\n\n // Pull in the requests\n let allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isSilent: false,\n isClosed: false,\n requestIds,\n });\n\n // Filter requests by daysLeft\n allRequests = allRequests.filter(\n (request) => typeof request.daysRemaining === 'number' && request.daysRemaining < daysLeft,\n );\n\n // Notify Transcend\n logger.info(colors.magenta(`Notifying \"${allRequests.length}\" that more time is needed.`));\n\n let total = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToNotify) => {\n await makeGraphQLRequest(client, NOTIFY_ADDITIONAL_TIME, {\n variables: {\n input: {\n requestId: requestToNotify.id,\n template: exactTemplateMatch.template.defaultMessage,\n subject: exactTemplateMatch.subject.defaultMessage,\n additionalTime: days,\n },\n },\n logger,\n });\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully marked ${total} requests as silent mode in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n return allRequests.length;\n}\n"],"mappings":"mbAqBA,eAAsB,EAAoC,CACxD,iBAAiB,OAAO,OAAO,EAAc,CAC7C,OACA,aACA,kBACA,OAAO,GACP,WAAW,GACX,iBACA,kBACA,iBACA,gBAAgB,yBAChB,cAAc,IACd,eAAe,GA6BG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAO/E,GAJoB,MAAM,EAAkB,EAAQ,CACxD,SACA,SAAU,CAAE,MAAO,EAAe,CACnC,CAAC,EAC2C,KAAM,GAAa,EAAS,QAAU,EAAc,CACjG,GAAI,CAAC,EACH,MAAU,MAAM,0CAA0C,EAAc,GAAG,CAI7E,IAAI,EAAc,MAAM,EAAiB,EAAQ,CAC/C,QAAS,EACT,kBACA,iBACA,kBACA,iBACA,SAAU,GACV,SAAU,GACV,aACD,CAAC,CAGF,EAAc,EAAY,OACvB,GAAY,OAAO,EAAQ,eAAkB,UAAY,EAAQ,cAAgB,EACnF,CAGD,EAAO,KAAK,EAAO,QAAQ,cAAc,EAAY,OAAO,6BAA6B,CAAC,CAE1F,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAY,OAAQ,EAAE,CACxC,MAAM,EACJ,EACA,KAAO,IAAoB,CACzB,MAAM,EAAmB,EAAQ,EAAwB,CACvD,UAAW,CACT,MAAO,CACL,UAAW,EAAgB,GAC3B,SAAU,EAAmB,SAAS,eACtC,QAAS,EAAmB,QAAQ,eACpC,eAAgB,EACjB,CACF,CACD,SACD,CAAC,CAEF,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAOvB,OALA,EAAO,KACL,EAAO,MACL,uBAAuB,EAAM,+BAA+B,EAAY,IAAK,YAC9E,CACF,CACM,EAAY"}
1
+ {"version":3,"file":"notifyPrivacyRequestsAdditionalTime-Dl6QYo_s.mjs","names":[],"sources":["../src/lib/requests/notifyPrivacyRequestsAdditionalTime.ts"],"sourcesContent":["import { RequestAction } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n fetchAllTemplates,\n makeGraphQLRequest,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { NOTIFY_ADDITIONAL_TIME, fetchAllRequests } from '../graphql/index.js';\n\n/**\n * Mark a set of privacy requests to be in silent mode.\n * Note requests in silent mode are ignored\n *\n * @param options - Options\n * @returns The number of requests marked silent\n */\nexport async function notifyPrivacyRequestsAdditionalTime({\n requestActions = Object.values(RequestAction),\n auth,\n requestIds,\n createdAtBefore,\n days = 45,\n daysLeft = 10,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n emailTemplate = 'Additional Time Needed',\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** The request actions that should be restarted */\n requestActions?: RequestAction[];\n /** Filter for requests created before this date */\n createdAtBefore: Date;\n /** Filter for requests created after this date */\n createdAtAfter?: Date;\n /** Filter for requests updated before this date */\n updatedAtBefore?: Date;\n /** Filter for requests updated after this date */\n updatedAtAfter?: Date;\n /** Email template */\n emailTemplate?: string;\n /** Transcend API key authentication */\n auth: string;\n /** Number of days to extend request by */\n days?: number;\n /**\n * Only notify requests that have less than this number of days until they are considered expired.\n * This allows for re-running the command without notifying the same users multiple times\n */\n daysLeft?: number;\n /** Concurrency limit for approving */\n concurrency?: number;\n /** The set of privacy requests to notify */\n requestIds?: string[];\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<number> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n\n // Grab the template with that title\n const matchingTemplates = await fetchAllTemplates(client, {\n logger,\n filterBy: { title: emailTemplate },\n });\n const exactTemplateMatch = matchingTemplates.find((template) => template.title === emailTemplate);\n if (!exactTemplateMatch) {\n throw new Error(`Failed to find a template with title: \"${emailTemplate}\"`);\n }\n\n // Pull in the requests\n let allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isSilent: false,\n isClosed: false,\n requestIds,\n });\n\n // Filter requests by daysLeft\n allRequests = allRequests.filter(\n (request) => typeof request.daysRemaining === 'number' && request.daysRemaining < daysLeft,\n );\n\n // Notify Transcend\n logger.info(colors.magenta(`Notifying \"${allRequests.length}\" that more time is needed.`));\n\n let total = 0;\n progressBar.start(allRequests.length, 0);\n await map(\n allRequests,\n async (requestToNotify) => {\n await makeGraphQLRequest(client, NOTIFY_ADDITIONAL_TIME, {\n variables: {\n input: {\n requestId: requestToNotify.id,\n template: exactTemplateMatch.template.defaultMessage,\n subject: exactTemplateMatch.subject.defaultMessage,\n additionalTime: days,\n },\n },\n logger,\n });\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully marked ${total} requests as silent mode in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n return allRequests.length;\n}\n"],"mappings":"mbAqBA,eAAsB,EAAoC,CACxD,iBAAiB,OAAO,OAAO,EAAc,CAC7C,OACA,aACA,kBACA,OAAO,GACP,WAAW,GACX,iBACA,kBACA,iBACA,gBAAgB,yBAChB,cAAc,IACd,eAAe,GA6BG,CAElB,IAAM,EAAS,EAA4B,EAAc,EAAK,CAGxD,EAAK,IAAI,MAAM,CAAC,SAAS,CAEzB,EAAc,IAAI,EAAY,UAAU,EAAE,CAAE,EAAY,QAAQ,eAAe,CAO/E,GAJoB,MAAM,EAAkB,EAAQ,CACxD,SACA,SAAU,CAAE,MAAO,EAAe,CACnC,CAAC,EAC2C,KAAM,GAAa,EAAS,QAAU,EAAc,CACjG,GAAI,CAAC,EACH,MAAU,MAAM,0CAA0C,EAAc,GAAG,CAI7E,IAAI,EAAc,MAAM,EAAiB,EAAQ,CAC/C,QAAS,EACT,kBACA,iBACA,kBACA,iBACA,SAAU,GACV,SAAU,GACV,aACD,CAAC,CAGF,EAAc,EAAY,OACvB,GAAY,OAAO,EAAQ,eAAkB,UAAY,EAAQ,cAAgB,EACnF,CAGD,EAAO,KAAK,EAAO,QAAQ,cAAc,EAAY,OAAO,6BAA6B,CAAC,CAE1F,IAAI,EAAQ,EACZ,EAAY,MAAM,EAAY,OAAQ,EAAE,CACxC,MAAM,EACJ,EACA,KAAO,IAAoB,CACzB,MAAM,EAAmB,EAAQ,EAAwB,CACvD,UAAW,CACT,MAAO,CACL,UAAW,EAAgB,GAC3B,SAAU,EAAmB,SAAS,eACtC,QAAS,EAAmB,QAAQ,eACpC,eAAgB,EACjB,CACF,CACD,SACD,CAAC,CAEF,GAAS,EACT,EAAY,OAAO,EAAM,EAE3B,CAAE,cAAa,CAChB,CAED,EAAY,MAAM,CAElB,IAAM,EADK,IAAI,MAAM,CAAC,SAAS,CACR,EAOvB,OALA,EAAO,KACL,EAAO,MACL,uBAAuB,EAAM,+BAA+B,EAAY,IAAK,YAC9E,CACF,CACM,EAAY"}
@@ -0,0 +1,2 @@
1
+ import{a as e}from"./constants-BdUSsxl7.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{decodeCodec as n}from"@transcend-io/type-utils";import r from"colors";import*as i from"io-ts";import{REDUCED_REQUESTS_FOR_DATA_SILO_COUNT as a,buildTranscendGraphQLClient as o,createSombraGotInstance as s,makeGraphQLRequest as c,withTransientRetry as l}from"@transcend-io/sdk";import{mapSeries as u}from"@transcend-io/utils";import d from"cli-progress";async function f(e,{dataSiloId:n}){let{listReducedRequestsForDataSilo:{totalCount:r}}=await c(e,a,{variables:{input:{dataSiloId:n,isResolved:!1}},logger:t});return r}const p=i.type({id:i.string,name:i.string,partition:i.string}),m=i.intersection([i.type({identifier:i.string,type:i.string,coreIdentifier:i.string,dataSiloId:i.string,requestId:i.string,nonce:i.string,requestCreatedAt:i.string,daysUntilOverdue:i.number,attributes:i.array(i.type({key:i.string,values:i.array(i.string)}))}),i.partial({partition:i.union([p,i.null])})]);async function h(e,{dataSiloId:r,limit:a=100,offset:o=0,requestType:s}){try{let c=await l(`pullCronPageOfIdentifiers`,()=>e.get(`v1/data-silo/${r}/pending-requests/${s}`,{searchParams:{offset:o,limit:a}}).json(),{logger:t,maxAttempts:6,baseDelayMs:500}),{items:u}=n(i.type({items:i.array(m)}),c);return u}catch(e){throw Error(`Received an error from server: ${e?.response?.body||e?.message}`)}}async function g({dataSiloId:n,auth:i,sombraAuth:a,actions:c,apiPageSize:l=100,savePageSize:p=1e3,onSave:m,transcendUrl:g=e,skipRequestCount:_=!1}){if(p%l!==0)throw Error(`savePageSize must be a multiple of apiPageSize. savePageSize: ${p}, apiPageSize: ${l}`);let v=await s(g,i,{logger:t,sombraApiKey:a,sombraUrl:process.env.SOMBRA_URL}),y=o(g,i),b=0;_||(b=await f(y,{dataSiloId:n})),t.info(r.magenta(`Pulling ${_?`all`:b} outstanding request identifiers for data silo: "${n}" for requests of types "${c.join(`", "`)}"`));let x=new Date().getTime(),S=new d.SingleBar({},d.Presets.shades_classic),C=new Set,w=[],T=[];_||S.start(b,0),await u(c,async e=>{let i=0,a=!0;for(;a;){let o=await h(v,{dataSiloId:n,limit:l,offset:i,requestType:e}),s=o.map(t=>(C.add(t.requestId),{...t,action:e})),c=s.map(({attributes:e,partition:t,...n})=>({...n,...t?{partitionId:t.id,partitionName:t.name,partitionKey:t.partition}:{},...e.reduce((e,t)=>Object.assign(e,{[t.key]:t.values.join(`,`)}),{})}));w.push(...s),T.push(...c),T.length>=p&&(await m(T),T=[]),a=o.length===l,i+=l,_?t.info(r.magenta(`Pulled ${o.length} outstanding identifiers for ${C.size} requests`)):S.update(C.size)}}),T.length>0&&await m(T),_||S.stop();let E=new Date().getTime()-x;return t.info(r.green(`Successfully pulled ${w.length} outstanding identifiers from ${C.size} requests in "${E/1e3}" seconds!`)),{identifiers:w}}export{f as a,h as i,m as n,p as r,g as t};
2
+ //# sourceMappingURL=pullChunkedCustomSiloOutstandingIdentifiers-C0uKFWhl.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pullChunkedCustomSiloOutstandingIdentifiers-C0uKFWhl.mjs","names":[],"sources":["../src/lib/graphql/fetchRequestDataSiloActiveCount.ts","../src/lib/cron/pullCronPageOfIdentifiers.ts","../src/lib/cron/pullChunkedCustomSiloOutstandingIdentifiers.ts"],"sourcesContent":["import { makeGraphQLRequest, REDUCED_REQUESTS_FOR_DATA_SILO_COUNT } from '@transcend-io/sdk';\nimport { GraphQLClient } from 'graphql-request';\n\nimport { logger } from '../../logger.js';\n\n/**\n * Get number of open requests for a data silo\n *\n * @param client - GraphQL client\n * @param options - Filter options\n * @returns List of request identifiers\n */\nexport async function fetchRequestDataSiloActiveCount(\n client: GraphQLClient,\n {\n dataSiloId,\n }: {\n /** Data silo ID */\n dataSiloId: string;\n },\n): Promise<number> {\n const {\n listReducedRequestsForDataSilo: { totalCount },\n } = await makeGraphQLRequest<{\n /** Requests */\n listReducedRequestsForDataSilo: {\n /** Total count */\n totalCount: number;\n };\n }>(client, REDUCED_REQUESTS_FOR_DATA_SILO_COUNT, {\n variables: {\n input: {\n dataSiloId,\n isResolved: false,\n },\n },\n logger,\n });\n\n return totalCount;\n}\n","import { RequestAction } from '@transcend-io/privacy-types';\nimport { withTransientRetry } from '@transcend-io/sdk';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport type { Got } from 'got';\nimport * as t from 'io-ts';\n\nimport { logger } from '../../logger.js';\n\n/** Consent partition metadata when a DSR is scoped to a partition */\nexport const CronPartition = t.type({\n /** ID of the partition */\n id: t.string,\n /** The human readable name of the partition */\n name: t.string,\n /** The unique identifying partition value */\n partition: t.string,\n});\n\n/** Type override */\nexport type CronPartition = t.TypeOf<typeof CronPartition>;\n\nexport const CronIdentifier = t.intersection([\n t.type({\n /** The identifier value */\n identifier: t.string,\n /** The type of identifier */\n type: t.string,\n /** The core identifier of the request */\n coreIdentifier: t.string,\n /** The ID of the underlying data silo */\n dataSiloId: t.string,\n /** The ID of the underlying request */\n requestId: t.string,\n /** The request nonce */\n nonce: t.string,\n /** The time the request was created */\n requestCreatedAt: t.string,\n /** The number of days until the request is overdue */\n daysUntilOverdue: t.number,\n /** Request attributes */\n attributes: t.array(\n t.type({\n key: t.string,\n values: t.array(t.string),\n }),\n ),\n }),\n t.partial({\n /** The consent partition that scopes this request, when applicable */\n partition: t.union([CronPartition, t.null]),\n }),\n]);\n\n/** Type override */\nexport type CronIdentifier = t.TypeOf<typeof CronIdentifier>;\n\n/**\n * Pull a offset of identifiers for a cron job\n *\n * @see https://docs.transcend.io/docs/api-reference/GET/v1/data-silo/(id)/pending-requests/(type)\n * @param sombra - Sombra instance configured to make requests\n * @param options - Additional options\n * @returns Successfully submitted request\n */\nexport async function pullCronPageOfIdentifiers(\n sombra: Got,\n {\n dataSiloId,\n limit = 100,\n offset = 0,\n requestType,\n }: {\n /** Data Silo ID */\n dataSiloId: string;\n /** Type of request */\n requestType: RequestAction;\n /** Number of identifiers to pull in */\n limit?: number;\n /** Page to pull in */\n offset?: number;\n },\n): Promise<CronIdentifier[]> {\n try {\n // `GET pending-requests` is a read and therefore safe to retry on transient\n // gateway / network errors. Customers running `transcend cron\n // pull-identifiers` against large silos would otherwise see the command\n // abort on a single 502 from the Sombra reverse tunnel.\n const response = await withTransientRetry(\n 'pullCronPageOfIdentifiers',\n () =>\n sombra\n .get(`v1/data-silo/${dataSiloId}/pending-requests/${requestType}`, {\n searchParams: {\n offset,\n limit,\n },\n })\n .json(),\n { logger, maxAttempts: 6, baseDelayMs: 500 },\n );\n\n const { items } = decodeCodec(\n t.type({\n items: t.array(CronIdentifier),\n }),\n response,\n );\n return items;\n } catch (err) {\n throw new Error(`Received an error from server: ${err?.response?.body || err?.message}`);\n }\n}\n","import { RequestAction } from '@transcend-io/privacy-types';\nimport { buildTranscendGraphQLClient, createSombraGotInstance } from '@transcend-io/sdk';\nimport { mapSeries } from '@transcend-io/utils';\nimport cliProgress from 'cli-progress';\nimport colors from 'colors';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { fetchRequestDataSiloActiveCount } from '../graphql/index.js';\nimport { pullCronPageOfIdentifiers, CronIdentifier } from './pullCronPageOfIdentifiers.js';\n\n/**\n * A CSV formatted identifier\n */\nexport type CsvFormattedIdentifier = {\n [k in string]: string | null | boolean | number;\n};\n\nexport interface CronIdentifierWithAction extends CronIdentifier {\n /** The request action that the identifier relates to */\n action: RequestAction;\n}\n\n/**\n * Pull the set of identifiers outstanding for a cron or AVC integration\n *\n * This function is designed to be used in a loop, and will call the onSave callback\n * with a chunk of identifiers when the savePageSize is reached.\n *\n * @param options - Options\n * @returns The identifiers and identifiers formatted for CSV\n */\nexport async function pullChunkedCustomSiloOutstandingIdentifiers({\n dataSiloId,\n auth,\n sombraAuth,\n actions,\n apiPageSize = 100,\n savePageSize = 1000,\n onSave,\n transcendUrl = DEFAULT_TRANSCEND_API,\n skipRequestCount = false,\n}: {\n /** Transcend API key authentication */\n auth: string;\n /** Data Silo ID to pull down jobs for */\n dataSiloId: string;\n /** The request actions to fetch */\n actions: RequestAction[];\n /** How many identifiers to pull in a single call to the backend */\n apiPageSize: number;\n /** How many identifiers to save at a time (usually to a CSV file, should be a multiple of apiPageSize) */\n savePageSize: number;\n /** Callback function called when a chunk of identifiers is ready to be saved */\n onSave: (chunk: CsvFormattedIdentifier[]) => Promise<void>;\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Sombra API key authentication */\n sombraAuth?: string;\n /** Skip request count */\n skipRequestCount?: boolean;\n}): Promise<{\n /** Raw Identifiers */\n identifiers: CronIdentifierWithAction[];\n}> {\n // Validate savePageSize\n if (savePageSize % apiPageSize !== 0) {\n throw new Error(\n `savePageSize must be a multiple of apiPageSize. savePageSize: ${savePageSize}, apiPageSize: ${apiPageSize}`,\n );\n }\n\n // Create sombra instance to communicate with\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n // Create GraphQL client to connect to Transcend backend\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n\n let totalRequestCount = 0;\n if (!skipRequestCount) {\n totalRequestCount = await fetchRequestDataSiloActiveCount(client, {\n dataSiloId,\n });\n }\n\n logger.info(\n colors.magenta(\n `Pulling ${skipRequestCount ? 'all' : totalRequestCount} outstanding request identifiers ` +\n `for data silo: \"${dataSiloId}\" for requests of types \"${actions.join('\", \"')}\"`,\n ),\n );\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);\n const foundRequestIds = new Set<string>();\n\n // identifiers found in total\n const identifiers: CronIdentifierWithAction[] = [];\n // current chunk of identifiers to be saved\n let currentChunk: CsvFormattedIdentifier[] = [];\n\n // map over each action\n if (!skipRequestCount) {\n progressBar.start(totalRequestCount, 0);\n }\n await mapSeries(actions, async (action) => {\n let offset = 0;\n let shouldContinue = true;\n\n // Fetch a page of identifiers\n while (shouldContinue) {\n const pageIdentifiers = await pullCronPageOfIdentifiers(sombra, {\n dataSiloId,\n limit: apiPageSize,\n offset,\n requestType: action,\n });\n\n const identifiersWithAction: CronIdentifierWithAction[] = pageIdentifiers.map(\n (identifier) => {\n foundRequestIds.add(identifier.requestId);\n return {\n ...identifier,\n action,\n };\n },\n );\n\n const csvFormattedIdentifiers = identifiersWithAction.map(\n ({ attributes, partition, ...identifier }) => ({\n ...identifier,\n ...(partition\n ? {\n partitionId: partition.id,\n partitionName: partition.name,\n partitionKey: partition.partition,\n }\n : {}),\n ...attributes.reduce(\n (acc, val) =>\n Object.assign(acc, {\n [val.key]: val.values.join(','),\n }),\n {},\n ),\n }),\n );\n\n identifiers.push(...identifiersWithAction);\n currentChunk.push(...csvFormattedIdentifiers);\n\n // Check if we've reached the savePageSize and call the onSave callback\n if (currentChunk.length >= savePageSize) {\n await onSave(currentChunk);\n currentChunk = [];\n }\n\n shouldContinue = pageIdentifiers.length === apiPageSize;\n offset += apiPageSize;\n if (!skipRequestCount) {\n progressBar.update(foundRequestIds.size);\n } else {\n logger.info(\n colors.magenta(\n `Pulled ${pageIdentifiers.length} outstanding identifiers for ${foundRequestIds.size} requests`,\n ),\n );\n }\n }\n });\n\n // Save any remaining identifiers in the current chunk\n if (currentChunk.length > 0) {\n await onSave(currentChunk);\n }\n\n if (!skipRequestCount) {\n progressBar.stop();\n }\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully pulled ${identifiers.length} outstanding identifiers from ${\n foundRequestIds.size\n } requests in \"${totalTime / 1000}\" seconds!`,\n ),\n );\n\n return { identifiers };\n}\n"],"mappings":"0bAYA,eAAsB,EACpB,EACA,CACE,cAKe,CACjB,GAAM,CACJ,+BAAgC,CAAE,eAChC,MAAM,EAMP,EAAQ,EAAsC,CAC/C,UAAW,CACT,MAAO,CACL,aACA,WAAY,GACb,CACF,CACD,SACD,CAAC,CAEF,OAAO,EC9BT,MAAa,EAAgB,EAAE,KAAK,CAElC,GAAI,EAAE,OAEN,KAAM,EAAE,OAER,UAAW,EAAE,OACd,CAAC,CAKW,EAAiB,EAAE,aAAa,CAC3C,EAAE,KAAK,CAEL,WAAY,EAAE,OAEd,KAAM,EAAE,OAER,eAAgB,EAAE,OAElB,WA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F,CAEM,CAAE,cAAa"}
@@ -1,2 +1,2 @@
1
- import{a as e}from"./constants-BwO3d-v4.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{r as n}from"./fetchAllRequests-CHHdyb4Q.mjs";import{a as r}from"./writeCsv-C4pjXGsD.mjs";import{RequestStatus as i}from"@transcend-io/privacy-types";import{groupBy as a,uniq as o}from"lodash-es";import s from"colors";import{buildTranscendGraphQLClient as c,createSombraGotInstance as l,fetchAllRequestEnrichers as u,fetchAllRequestIdentifiers as d,validateSombraVersion as f}from"@transcend-io/sdk";import{map as p}from"@transcend-io/utils";async function m({file:m,auth:h,sombraAuth:g,requestActions:_=[],concurrency:v=100,transcendUrl:y=e}){let b=c(y,h),x=await l(y,h,{logger:t,sombraApiKey:g,sombraUrl:process.env.SOMBRA_URL});t.info(s.magenta(`Pulling manual enrichment requests, filtered for actions: ${_.join(`,`)}`));let S=await n(b,{actions:_,statuses:[i.Enriching]});await f(b,{logger:t});let C=[];await p(S,async e=>{let n=await u(b,{filterBy:{requestId:e.id},logger:t});if(n.filter(({status:e})=>e===`ACTION_REQUIRED`)){let r=await d(b,x,{filterBy:{requestId:e.id},skipSombraCheck:!0,logger:t});C.push({...e,requestIdentifiers:r,requestEnrichers:n})}},{concurrency:v});let w=C.map(({attributeValues:e,requestIdentifiers:t,requestEnrichers:n,...r})=>({...r,...Object.entries(a(t,`name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({value:e})=>e).join(`,`)}),{}),...Object.entries(a(e,`attributeKey.name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({name:e})=>e).join(`,`)}),{})}));return await r(m,w,o(w.map(e=>Object.keys(e)).flat())),t.info(s.green(`Successfully wrote ${C.length} requests to file "${m}"`)),C}export{m as t};
2
- //# sourceMappingURL=pullManualEnrichmentIdentifiersToCsv-DIQYZwZX.mjs.map
1
+ import{a as e}from"./constants-BdUSsxl7.mjs";import{t}from"./logger-Bj782ZYD.mjs";import{r as n}from"./fetchAllRequests-CHHdyb4Q.mjs";import{a as r}from"./writeCsv-C4pjXGsD.mjs";import{RequestStatus as i}from"@transcend-io/privacy-types";import{groupBy as a,uniq as o}from"lodash-es";import s from"colors";import{buildTranscendGraphQLClient as c,createSombraGotInstance as l,fetchAllRequestEnrichers as u,fetchAllRequestIdentifiers as d,validateSombraVersion as f}from"@transcend-io/sdk";import{map as p}from"@transcend-io/utils";async function m({file:m,auth:h,sombraAuth:g,requestActions:_=[],concurrency:v=100,transcendUrl:y=e}){let b=c(y,h),x=await l(y,h,{logger:t,sombraApiKey:g,sombraUrl:process.env.SOMBRA_URL});t.info(s.magenta(`Pulling manual enrichment requests, filtered for actions: ${_.join(`,`)}`));let S=await n(b,{actions:_,statuses:[i.Enriching]});await f(b,{logger:t});let C=[];await p(S,async e=>{let n=await u(b,{filterBy:{requestId:e.id},logger:t});if(n.filter(({status:e})=>e===`ACTION_REQUIRED`)){let r=await d(b,x,{filterBy:{requestId:e.id},skipSombraCheck:!0,logger:t});C.push({...e,requestIdentifiers:r,requestEnrichers:n})}},{concurrency:v});let w=C.map(({attributeValues:e,requestIdentifiers:t,requestEnrichers:n,...r})=>({...r,...Object.entries(a(t,`name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({value:e})=>e).join(`,`)}),{}),...Object.entries(a(e,`attributeKey.name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({name:e})=>e).join(`,`)}),{})}));return await r(m,w,o(w.map(e=>Object.keys(e)).flat())),t.info(s.green(`Successfully wrote ${C.length} requests to file "${m}"`)),C}export{m as t};
2
+ //# sourceMappingURL=pullManualEnrichmentIdentifiersToCsv-CJJ_a_U6.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"pullManualEnrichmentIdentifiersToCsv-DIQYZwZX.mjs","names":[],"sources":["../src/lib/manual-enrichment/pullManualEnrichmentIdentifiersToCsv.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllRequestEnrichers,\n fetchAllRequestIdentifiers,\n validateSombraVersion,\n type RequestEnricher,\n type RequestIdentifier,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport colors from 'colors';\nimport { groupBy, uniq } from 'lodash-es';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { type PrivacyRequest, fetchAllRequests } from '../graphql/index.js';\nimport { writeCsv } from '../helpers/writeCsv.js';\n\nexport interface PrivacyRequestWithIdentifiers extends PrivacyRequest {\n /** Request Enrichers */\n requestEnrichers: RequestEnricher[];\n /** Request Identifiers */\n requestIdentifiers: RequestIdentifier[];\n}\n\n/**\n * Pull the set of manual enrichment jobs to CSV\n *\n * @param options - Options\n * @returns List of requests with identifiers\n */\nexport async function pullManualEnrichmentIdentifiersToCsv({\n file,\n auth,\n sombraAuth,\n requestActions = [],\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** CSV file path */\n file: string;\n /** Transcend API key authentication */\n auth: string;\n /** Sombra API key */\n sombraAuth?: string;\n /** Concurrency */\n concurrency?: number;\n /** The request actions to fetch */\n requestActions?: RequestAction[];\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<PrivacyRequestWithIdentifiers[]> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n logger.info(\n colors.magenta(\n `Pulling manual enrichment requests, filtered for actions: ${requestActions.join(',')}`,\n ),\n );\n\n // Pull all privacy requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses: [RequestStatus.Enriching],\n });\n\n await validateSombraVersion(client, { logger });\n\n // Requests to save\n const savedRequests: PrivacyRequestWithIdentifiers[] = [];\n\n // Filter down requests to what is needed\n await map(\n allRequests,\n async (request) => {\n // Fetch enrichers\n const requestEnrichers = await fetchAllRequestEnrichers(client, {\n filterBy: { requestId: request.id },\n logger,\n });\n\n // Check if manual enrichment exists for that request\n const hasManualEnrichment = requestEnrichers.filter(\n ({ status }) => status === 'ACTION_REQUIRED',\n );\n\n // Save request to queue\n if (hasManualEnrichment) {\n const requestIdentifiers = await fetchAllRequestIdentifiers(client, sombra, {\n filterBy: { requestId: request.id },\n skipSombraCheck: true,\n logger,\n });\n savedRequests.push({\n ...request,\n requestIdentifiers,\n requestEnrichers,\n });\n }\n },\n {\n concurrency,\n },\n );\n\n const data = savedRequests.map(\n ({\n attributeValues,\n requestIdentifiers,\n requestEnrichers, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...request\n }) => ({\n ...request,\n // flatten identifiers\n ...Object.entries(groupBy(requestIdentifiers, 'name')).reduce(\n (acc, [key, values]) =>\n Object.assign(acc, {\n [key]: values.map(({ value }) => value).join(','),\n }),\n {},\n ),\n // flatten attributes\n ...Object.entries(groupBy(attributeValues, 'attributeKey.name')).reduce(\n (acc, [key, values]) =>\n Object.assign(acc, {\n [key]: values.map(({ name }) => name).join(','),\n }),\n {},\n ),\n }),\n );\n\n // Write out to CSV\n const headers = uniq(data.map((d) => Object.keys(d)).flat());\n await writeCsv(file, data, headers);\n\n logger.info(\n colors.green(`Successfully wrote ${savedRequests.length} requests to file \"${file}\"`),\n );\n\n return savedRequests;\n}\n"],"mappings":"khBAgCA,eAAsB,EAAqC,CACzD,OACA,OACA,aACA,iBAAiB,EAAE,CACnB,cAAc,IACd,eAAe,GAc4B,CAE3C,IAAM,EAAS,EAA4B,EAAc,EAAK,CACxD,EAAS,MAAM,EAAwB,EAAc,EAAM,CAC/D,SACA,aAAc,EACd,UAAW,QAAQ,IAAI,WACxB,CAAC,CAEF,EAAO,KACL,EAAO,QACL,6DAA6D,EAAe,KAAK,IAAI,GACtF,CACF,CAGD,IAAM,EAAc,MAAM,EAAiB,EAAQ,CACjD,QAAS,EACT,S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ual-enrichment/pullManualEnrichmentIdentifiersToCsv.ts"],"sourcesContent":["import { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport {\n buildTranscendGraphQLClient,\n createSombraGotInstance,\n fetchAllRequestEnrichers,\n fetchAllRequestIdentifiers,\n validateSombraVersion,\n type RequestEnricher,\n type RequestIdentifier,\n} from '@transcend-io/sdk';\nimport { map } from '@transcend-io/utils';\nimport colors from 'colors';\nimport { groupBy, uniq } from 'lodash-es';\n\nimport { DEFAULT_TRANSCEND_API } from '../../constants.js';\nimport { logger } from '../../logger.js';\nimport { type PrivacyRequest, fetchAllRequests } from '../graphql/index.js';\nimport { writeCsv } from '../helpers/writeCsv.js';\n\nexport interface PrivacyRequestWithIdentifiers extends PrivacyRequest {\n /** Request Enrichers */\n requestEnrichers: RequestEnricher[];\n /** Request Identifiers */\n requestIdentifiers: RequestIdentifier[];\n}\n\n/**\n * Pull the set of manual enrichment jobs to CSV\n *\n * @param options - Options\n * @returns List of requests with identifiers\n */\nexport async function pullManualEnrichmentIdentifiersToCsv({\n file,\n auth,\n sombraAuth,\n requestActions = [],\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_API,\n}: {\n /** CSV file path */\n file: string;\n /** Transcend API key authentication */\n auth: string;\n /** Sombra API key */\n sombraAuth?: string;\n /** Concurrency */\n concurrency?: number;\n /** The request actions to fetch */\n requestActions?: RequestAction[];\n /** API URL for Transcend backend */\n transcendUrl?: string;\n}): Promise<PrivacyRequestWithIdentifiers[]> {\n // Find all requests made before createdAt that are in a removing data state\n const client = buildTranscendGraphQLClient(transcendUrl, auth);\n const sombra = await createSombraGotInstance(transcendUrl, auth, {\n logger,\n sombraApiKey: sombraAuth,\n sombraUrl: process.env.SOMBRA_URL,\n });\n\n logger.info(\n colors.magenta(\n `Pulling manual enrichment requests, filtered for actions: ${requestActions.join(',')}`,\n ),\n );\n\n // Pull all privacy requests\n const allRequests = await fetchAllRequests(client, {\n actions: requestActions,\n statuses: [RequestStatus.Enriching],\n });\n\n await validateSombraVersion(client, { logger });\n\n // Requests to save\n const savedRequests: PrivacyRequestWithIdentifiers[] = [];\n\n // Filter down requests to what is needed\n await map(\n allRequests,\n async (request) => {\n // Fetch enrichers\n const requestEnrichers = await fetchAllRequestEnrichers(client, {\n filterBy: { requestId: request.id },\n logger,\n });\n\n // Check if manual enrichment exists for that request\n const hasManualEnrichment = requestEnrichers.filter(\n ({ status }) => status === 'ACTION_REQUIRED',\n );\n\n // Save request to queue\n if (hasManualEnrichment) {\n const requestIdentifiers = await fetchAllRequestIdentifiers(client, sombra, {\n filterBy: { requestId: request.id },\n skipSombraCheck: true,\n logger,\n });\n savedRequests.push({\n ...request,\n requestIdentifiers,\n requestEnrichers,\n });\n }\n },\n {\n concurrency,\n },\n );\n\n const data = savedRequests.map(\n ({\n attributeValues,\n requestIdentifiers,\n requestEnrichers, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...request\n }) => ({\n ...request,\n // flatten identifiers\n ...Object.entries(groupBy(requestIdentifiers, 'name')).reduce(\n (acc, [key, values]) =>\n Object.assign(acc, {\n [key]: values.map(({ value }) => value).join(','),\n }),\n {},\n ),\n // flatten attributes\n ...Object.entries(groupBy(attributeValues, 'attributeKey.name')).reduce(\n (acc, [key, values]) =>\n Object.assign(acc, {\n [key]: values.map(({ name }) => name).join(','),\n }),\n {},\n ),\n }),\n );\n\n // Write out to CSV\n const headers = uniq(data.map((d) => Object.keys(d)).flat());\n await writeCsv(file, data, headers);\n\n logger.info(\n colors.green(`Successfully wrote ${savedRequests.length} requests to file \"${file}\"`),\n );\n\n return savedRequests;\n}\n"],"mappings":"khBAgCA,eAAsB,EAAqC,CACzD,OACA,OACA,aACA,iBAAiB,EAAE,CACnB,cAAc,IACd,eAAe,GAc4B,CAE3C,IAAM,EAAS,EAA4B,EAAc,EAAK,CACxD,EAAS,MAAM,EAAwB,EAAc,EAAM,CAC/D,SACA,aAAc,EACd,UAAW,QAAQ,IAAI,WACxB,CAAC,CAEF,EAAO,KAC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