sandforge 0.0.0-stage → 1.80.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 (221) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +54 -2
  3. package/THIRD-PARTY-NOTICES.md +1624 -0
  4. package/bin/sandforge-autopilot.mjs +12 -0
  5. package/bin/sandforge-backup.mjs +12 -0
  6. package/bin/sandforge-checkpoint.mjs +12 -0
  7. package/bin/sandforge-cleanup.mjs +12 -0
  8. package/bin/sandforge-clone.mjs +12 -0
  9. package/bin/sandforge-compare.mjs +12 -0
  10. package/bin/sandforge-dataops.mjs +12 -0
  11. package/bin/sandforge-empty.mjs +12 -0
  12. package/bin/sandforge-env.mjs +12 -0
  13. package/bin/sandforge-frozen.mjs +12 -0
  14. package/bin/sandforge-mcp.mjs +12 -0
  15. package/bin/sandforge-monitor.mjs +12 -0
  16. package/bin/sandforge-seed.mjs +12 -0
  17. package/bin/sandforge-sync.mjs +12 -0
  18. package/bin/sandforge.mjs +12 -0
  19. package/lib/catalogue.en.json +1 -0
  20. package/lib/chunk-2BA2XKAY.mjs +7 -0
  21. package/lib/chunk-2CNCDM56.mjs +7 -0
  22. package/lib/chunk-2GTBABKU.mjs +7 -0
  23. package/lib/chunk-2NBYT7GR.mjs +7 -0
  24. package/lib/chunk-2UZPIMUC.mjs +7 -0
  25. package/lib/chunk-2YIV2OB2.mjs +7 -0
  26. package/lib/chunk-3F6Q5E7I.mjs +14 -0
  27. package/lib/chunk-3RZQZHEB.mjs +7 -0
  28. package/lib/chunk-3TJON4F3.mjs +7 -0
  29. package/lib/chunk-4HW535YJ.mjs +7 -0
  30. package/lib/chunk-4TLYUZD5.mjs +7 -0
  31. package/lib/chunk-4VS2V6WU.mjs +25 -0
  32. package/lib/chunk-5K5VLULK.mjs +7 -0
  33. package/lib/chunk-5LFSFYFJ.mjs +7 -0
  34. package/lib/chunk-5P4PHJRL.mjs +9 -0
  35. package/lib/chunk-5TC3QB4U.mjs +10 -0
  36. package/lib/chunk-66NMFCWX.mjs +7 -0
  37. package/lib/chunk-6XYKJSGX.mjs +7 -0
  38. package/lib/chunk-74Q6DORA.mjs +7 -0
  39. package/lib/chunk-7ABODJ4G.mjs +7 -0
  40. package/lib/chunk-7EANH5PY.mjs +68 -0
  41. package/lib/chunk-7EGQP6S4.mjs +7 -0
  42. package/lib/chunk-7F54PZUS.mjs +7 -0
  43. package/lib/chunk-7FFGJWHN.mjs +7 -0
  44. package/lib/chunk-7YDNUBO5.mjs +7 -0
  45. package/lib/chunk-A527W53V.mjs +7 -0
  46. package/lib/chunk-ADOAS63R.mjs +7 -0
  47. package/lib/chunk-AEKONPF4.mjs +7 -0
  48. package/lib/chunk-AV5SWEHP.mjs +9 -0
  49. package/lib/chunk-B5QQJ4SI.mjs +7 -0
  50. package/lib/chunk-BGUEWRK2.mjs +7 -0
  51. package/lib/chunk-BKDV4ENO.mjs +7 -0
  52. package/lib/chunk-BOGNK4LV.mjs +7 -0
  53. package/lib/chunk-BTWDMNN3.mjs +7 -0
  54. package/lib/chunk-BV6VTP3J.mjs +7 -0
  55. package/lib/chunk-BXU6WFMH.mjs +7 -0
  56. package/lib/chunk-BY2HJFFG.mjs +7 -0
  57. package/lib/chunk-BZ24IAP5.mjs +7 -0
  58. package/lib/chunk-CA5NAXSU.mjs +7 -0
  59. package/lib/chunk-CE6ZDGBB.mjs +7 -0
  60. package/lib/chunk-CEX3NEZL.mjs +7 -0
  61. package/lib/chunk-CHCHAE4B.mjs +7 -0
  62. package/lib/chunk-CHYDMRSV.mjs +7 -0
  63. package/lib/chunk-CION3VMZ.mjs +7 -0
  64. package/lib/chunk-COFG7Q6R.mjs +7 -0
  65. package/lib/chunk-CSBS5U5I.mjs +7 -0
  66. package/lib/chunk-CU2INBND.mjs +7 -0
  67. package/lib/chunk-DB7RBE5D.mjs +7 -0
  68. package/lib/chunk-DBB3EMIN.mjs +7 -0
  69. package/lib/chunk-DBFJB2B6.mjs +7 -0
  70. package/lib/chunk-DYFALGRT.mjs +7 -0
  71. package/lib/chunk-E5AHXLS6.mjs +7 -0
  72. package/lib/chunk-E5ZB3LU5.mjs +7 -0
  73. package/lib/chunk-EADHKH3A.mjs +7 -0
  74. package/lib/chunk-EFR2Y7E4.mjs +7 -0
  75. package/lib/chunk-EHQ3FX6X.mjs +7 -0
  76. package/lib/chunk-ELFXJHU7.mjs +7 -0
  77. package/lib/chunk-EMNC6YI4.mjs +7 -0
  78. package/lib/chunk-EQNW3UC2.mjs +7 -0
  79. package/lib/chunk-F2424IKX.mjs +7 -0
  80. package/lib/chunk-F43REJDZ.mjs +10 -0
  81. package/lib/chunk-F6GUDTOB.mjs +7 -0
  82. package/lib/chunk-FGRG7ANU.mjs +7 -0
  83. package/lib/chunk-FKG7Q3WH.mjs +7 -0
  84. package/lib/chunk-FPKYYFM7.mjs +7 -0
  85. package/lib/chunk-FQGHL7GR.mjs +259 -0
  86. package/lib/chunk-FXXLX4O6.mjs +7 -0
  87. package/lib/chunk-G35N4P7D.mjs +7 -0
  88. package/lib/chunk-GCOB7K5N.mjs +7 -0
  89. package/lib/chunk-GGD7ON3M.mjs +7 -0
  90. package/lib/chunk-GMY5427L.mjs +7 -0
  91. package/lib/chunk-GSG7WZHM.mjs +7 -0
  92. package/lib/chunk-GSKCGQIP.mjs +7 -0
  93. package/lib/chunk-HEKAZJRH.mjs +7 -0
  94. package/lib/chunk-HF6LAK3G.mjs +7 -0
  95. package/lib/chunk-HLWMJF6Y.mjs +7 -0
  96. package/lib/chunk-HOJYWTP7.mjs +20 -0
  97. package/lib/chunk-HS4YRX4J.mjs +7 -0
  98. package/lib/chunk-HXS7ORUF.mjs +11 -0
  99. package/lib/chunk-I7O6C2B5.mjs +8 -0
  100. package/lib/chunk-IC2C2GOF.mjs +8 -0
  101. package/lib/chunk-IFETCRWE.mjs +10 -0
  102. package/lib/chunk-IG2MTQRP.mjs +8 -0
  103. package/lib/chunk-IGYH7GMA.mjs +7 -0
  104. package/lib/chunk-INIQ23K6.mjs +7 -0
  105. package/lib/chunk-INIT2UKJ.mjs +7 -0
  106. package/lib/chunk-IOIWJ3DJ.mjs +7 -0
  107. package/lib/chunk-IQXHJEYB.mjs +7 -0
  108. package/lib/chunk-IWDREM66.mjs +7 -0
  109. package/lib/chunk-IZQZ6ZUF.mjs +7 -0
  110. package/lib/chunk-J525F5KI.mjs +7 -0
  111. package/lib/chunk-JEERQRLW.mjs +7 -0
  112. package/lib/chunk-JPUR2CFX.mjs +10 -0
  113. package/lib/chunk-JWTSEDIQ.mjs +7 -0
  114. package/lib/chunk-K2FBZIXY.mjs +7 -0
  115. package/lib/chunk-K327QKMD.mjs +7 -0
  116. package/lib/chunk-KBJ5VERV.mjs +7 -0
  117. package/lib/chunk-KDGMAGQR.mjs +7 -0
  118. package/lib/chunk-KRCA6IPH.mjs +8 -0
  119. package/lib/chunk-KYEDBS54.mjs +7 -0
  120. package/lib/chunk-L5FGY6YA.mjs +7 -0
  121. package/lib/chunk-L77FJZEP.mjs +10 -0
  122. package/lib/chunk-LKQ5RKIV.mjs +9 -0
  123. package/lib/chunk-LPBMBW3O.mjs +13 -0
  124. package/lib/chunk-LWW4U276.mjs +7 -0
  125. package/lib/chunk-M3ROUWDX.mjs +7 -0
  126. package/lib/chunk-M6P5ZZLE.mjs +7 -0
  127. package/lib/chunk-MFG4MUIO.mjs +9 -0
  128. package/lib/chunk-MHMH6MTP.mjs +7 -0
  129. package/lib/chunk-MILU7WFN.mjs +7 -0
  130. package/lib/chunk-MJU2PGZQ.mjs +15 -0
  131. package/lib/chunk-MJVTDA5Q.mjs +7 -0
  132. package/lib/chunk-MS4FJDFD.mjs +101 -0
  133. package/lib/chunk-MTMH6H2A.mjs +8 -0
  134. package/lib/chunk-MYW5QNGI.mjs +7 -0
  135. package/lib/chunk-N652NMZ4.mjs +441 -0
  136. package/lib/chunk-NTFIRZP6.mjs +7 -0
  137. package/lib/chunk-NTOVCTRS.mjs +7 -0
  138. package/lib/chunk-NZC67CGR.mjs +9 -0
  139. package/lib/chunk-O2HDYYUV.mjs +8 -0
  140. package/lib/chunk-OAZRPP4I.mjs +7 -0
  141. package/lib/chunk-OHWNPXWW.mjs +7 -0
  142. package/lib/chunk-OLSGVAIL.mjs +341 -0
  143. package/lib/chunk-OO6CLPEH.mjs +7 -0
  144. package/lib/chunk-OPXCV2KL.mjs +7 -0
  145. package/lib/chunk-P33PSCXK.mjs +7 -0
  146. package/lib/chunk-PJ5I73CK.mjs +7 -0
  147. package/lib/chunk-PTTHSSQO.mjs +7 -0
  148. package/lib/chunk-PZPJKATS.mjs +19 -0
  149. package/lib/chunk-Q3DM32KF.mjs +11 -0
  150. package/lib/chunk-QR3WELJQ.mjs +7 -0
  151. package/lib/chunk-QROPNEGY.mjs +14 -0
  152. package/lib/chunk-QSRAEUGZ.mjs +7 -0
  153. package/lib/chunk-QWT2C74M.mjs +7 -0
  154. package/lib/chunk-R3X3LV64.mjs +14 -0
  155. package/lib/chunk-RMBPOTD7.mjs +7 -0
  156. package/lib/chunk-RPI7LRTW.mjs +7 -0
  157. package/lib/chunk-RSWDYIHY.mjs +37 -0
  158. package/lib/chunk-SAR5622P.mjs +7 -0
  159. package/lib/chunk-SCKUIE3R.mjs +7 -0
  160. package/lib/chunk-SE4QEZUG.mjs +7 -0
  161. package/lib/chunk-SIHORWVK.mjs +7 -0
  162. package/lib/chunk-SOGQW4IG.mjs +7 -0
  163. package/lib/chunk-SOU4FRYN.mjs +7 -0
  164. package/lib/chunk-SRPWW4A2.mjs +10 -0
  165. package/lib/chunk-SU65Z2BA.mjs +7 -0
  166. package/lib/chunk-T62WNR54.mjs +7 -0
  167. package/lib/chunk-T63U4OZJ.mjs +7 -0
  168. package/lib/chunk-TLH7AD35.mjs +7 -0
  169. package/lib/chunk-TSLJUSLW.mjs +13 -0
  170. package/lib/chunk-TTFDUKUS.mjs +47 -0
  171. package/lib/chunk-TTKXMDBN.mjs +10 -0
  172. package/lib/chunk-TUACWKIH.mjs +7 -0
  173. package/lib/chunk-TW3N6W5Z.mjs +7 -0
  174. package/lib/chunk-TYYOBZMU.mjs +10 -0
  175. package/lib/chunk-TZE3Y7IQ.mjs +7 -0
  176. package/lib/chunk-UCD54V2M.mjs +7 -0
  177. package/lib/chunk-UNDIBZWG.mjs +7 -0
  178. package/lib/chunk-UNJA4J37.mjs +11 -0
  179. package/lib/chunk-VE6XKGGD.mjs +7 -0
  180. package/lib/chunk-VGW4MXXZ.mjs +7 -0
  181. package/lib/chunk-VS7ZXUII.mjs +824 -0
  182. package/lib/chunk-VXQLDM4R.mjs +7 -0
  183. package/lib/chunk-VYXMVJL5.mjs +7 -0
  184. package/lib/chunk-W622GUAW.mjs +8 -0
  185. package/lib/chunk-W7U5E5ZL.mjs +9 -0
  186. package/lib/chunk-WA7EYLAQ.mjs +7 -0
  187. package/lib/chunk-WIO4XO4F.mjs +7 -0
  188. package/lib/chunk-WR2GIKWE.mjs +7 -0
  189. package/lib/chunk-WR4Q363I.mjs +11 -0
  190. package/lib/chunk-WU3GLFZO.mjs +7 -0
  191. package/lib/chunk-WXAQ7FK3.mjs +115 -0
  192. package/lib/chunk-X5JYBPXP.mjs +7 -0
  193. package/lib/chunk-XAMBCQPU.mjs +7 -0
  194. package/lib/chunk-XCA5AONB.mjs +7 -0
  195. package/lib/chunk-XLXIPIEW.mjs +9 -0
  196. package/lib/chunk-XUWL6ZPC.mjs +7 -0
  197. package/lib/chunk-YAZO75G2.mjs +8 -0
  198. package/lib/chunk-YKKRIEH4.mjs +7 -0
  199. package/lib/chunk-YRQGKDHM.mjs +7 -0
  200. package/lib/chunk-YS4G22C2.mjs +7 -0
  201. package/lib/chunk-YYZL7UGV.mjs +7 -0
  202. package/lib/chunk-ZHJP7L3K.mjs +7 -0
  203. package/lib/chunk-ZM6OJGIG.mjs +7 -0
  204. package/lib/chunk-ZUTYVST5.mjs +7 -0
  205. package/lib/chunk-ZVAED4QV.mjs +7 -0
  206. package/lib/sandforge-autopilot.mjs +162 -0
  207. package/lib/sandforge-backup.mjs +103 -0
  208. package/lib/sandforge-checkpoint.mjs +354 -0
  209. package/lib/sandforge-cleanup.mjs +60 -0
  210. package/lib/sandforge-clone.mjs +7 -0
  211. package/lib/sandforge-compare.mjs +55 -0
  212. package/lib/sandforge-dataops.mjs +7 -0
  213. package/lib/sandforge-empty.mjs +140 -0
  214. package/lib/sandforge-env.mjs +355 -0
  215. package/lib/sandforge-frozen.mjs +272 -0
  216. package/lib/sandforge-mcp.mjs +40 -0
  217. package/lib/sandforge-monitor.mjs +43 -0
  218. package/lib/sandforge-seed.mjs +7 -0
  219. package/lib/sandforge-sync.mjs +7 -0
  220. package/lib/sandforge.mjs +28 -0
  221. package/package.json +52 -4
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-XLXIPIEW.mjs";import"./chunk-TTKXMDBN.mjs";import"./chunk-5TC3QB4U.mjs";import"./chunk-2BA2XKAY.mjs";import"./chunk-JEERQRLW.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-SIHORWVK.mjs";import"./chunk-NZC67CGR.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-JPUR2CFX.mjs";import"./chunk-LPBMBW3O.mjs";import"./chunk-IFETCRWE.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{h as REWIND_MUTING_STEP_WORDS,g as REWIND_STEP_WORDS,i as acceptanceRefusal,j as boundsRefusal,k as boundsRefusals,e as firedCount,m as notConfirmedRefusal,a as objectsWrittenBy,b as previewTotals,f as remakeUnasked,d as rewindStepsOf,c as selectionDiff,l as undeletableUnattendedRefusal};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{ib as o,ic as c}from"./chunk-TTFDUKUS.mjs";var u=new Set(["picklist","multipicklist"]);function d(s){return(s.picklistValues??[]).filter(n=>n.active!==!1&&typeof n.value=="string"&&n.value!=="").map(n=>n.value)}function b(s){let n=new Map,r=t=>{let i=n.get(t);return i||(i=s(t),n.set(t,i)),i};return{async createable(t){let{fields:i}=await r(t);return new Set(i.filter(e=>e.createable===!0).map(e=>e.name))},async visible(t){let{fields:i}=await r(t);return new Set(i.map(e=>e.name))},async computed(t){let{fields:i}=await r(t);return new Set(i.filter(e=>e.calculated===!0||e.autoNumber===!0).map(e=>e.name))},async picklistValues(t){let{fields:i}=await r(t),e=new Map;for(let a of i){if(!u.has(a.type??""))continue;let l=d(a);l.length>0&&e.set(a.name,l)}return e},async keyPrefix(t){let{keyPrefix:i}=await r(t);return typeof i=="string"&&i.length===3?i:void 0},async lengths(t){let{fields:i}=await r(t);return new Map(i.flatMap(e=>typeof e.length=="number"&&e.length>0?[[e.name,e.length]]:[]))},async required(t){let{fields:i}=await r(t);return i.filter(e=>e.createable===!0&&e.nillable===!1&&e.defaultedOnCreate!==!0&&(e.referenceTo??[]).length===0).map(e=>({fieldApiName:e.name,type:e.type??"string",picklistValues:d(e),referenceTo:[],length:e.length??0,integerDigits:o({...e,type:e.type??"string"}),objectApiName:t,required:!0}))}}}function m(s,n){return async r=>(await s.required(r)).filter(t=>!c(r,t.fieldApiName,n.includes(r)?"person":"business"))}export{b as a,m as b};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{h as M,i as T}from"./chunk-6XYKJSGX.mjs";import{o as b}from"./chunk-ZUTYVST5.mjs";import{Hb as _,Ib as h,Jb as p,Kb as R,Ob as C,Pb as S,Sb as k}from"./chunk-TTFDUKUS.mjs";async function Y(r,e){try{let[c,i]=await Promise.all([r(R),e(R)]),d=c[0]?.Id,a=i[0]?.Id;return typeof d=="string"&&typeof a=="string"?{source:d,target:a}:void 0}catch{return}}function v(r,e){return r===h||e.some(c=>typeof c[p]=="string")}var K=[p,C,S];function A(r,e,c,i,d=()=>!1){let a={...e,standsFor:new Map,standardFirst:0,standardMatched:!1,prices:[],leftIn:new Map};if(!c)return a;let o=e.records.map((t,s)=>s),m=t=>({records:t.map(s=>e.records[s]),sources:t.map(s=>e.sources[s]),sourceIds:t.map(s=>e.sourceIds[s])});if(r===h){let t=o.filter(s=>e.sourceIds[s]!==c.source);return t.length===o.length?a:{...m(t),standsFor:new Map,standardFirst:0,standardMatched:!0,prices:[],leftIn:new Map}}if(r!==_)return a;let l=o,I=new Map,P=new Map,O=[];if(i){let{target:t}=i,s=e.sources.filter(n=>!K.some(f=>{let u=n[f];return typeof u=="string"&&u!==""&&d(u)})),E=n=>t.active.has(n)?n:b(void 0,t)?.to,g=M({prices:s,standardBookId:c.source,sellingModels:s.some(n=>typeof n[S]=="string"),writtenIn:E,active:t.active},[]),B=new Set(g.standsFor.keys());l=o.filter(n=>{let f=e.sourceIds[n];return f===void 0||!B.has(f)});let D=new Map(s.map(n=>[n.Id,n[k]]));for(let[n,f]of g.standsFor){I.set(n,f);let u=D.get(n),w=typeof u=="string"?E(u):void 0;typeof u=="string"&&w!==void 0&&P.set(n,{from:u,to:w})}O=T(g.said)}let y=t=>e.sources[t][p]===c.source,F=[...l.filter(y),...l.filter(t=>!y(t))];return{...m(F),standsFor:I,standardFirst:l.filter(y).length,standardMatched:!1,prices:O,leftIn:P}}function Q(r,e){let c=r.prices.map(i=>({...i}));for(let i of e){let d=r.leftIn.get(i),a=d&&(c.find(o=>o.from===d.from&&o.to===d.to&&o.how==="replaced"&&!o.forLines)??c.find(o=>o.from===d.from&&o.to===d.to&&o.how==="replaced"));a&&a.prices--}return c.filter(i=>i.prices>0)}function q(r,e){return e===1?`1 ${r} record held back, not sent: read in a currency the target org does not hold active, it stands for the source's own price of its product and price book in the currency written, which this run did not write.`:`${e} ${r} records held back, not sent: read in a currency the target org does not hold active, they stand for the source's own prices of their product and price book in the currency written, which this run did not write.`}var H="The standard price book is matched to the target org's, never written.";function $(r,e){return e.prices.length===0&&!e.standardMatched?r:{...r,...e.prices.length>0?{pricesSettled:[...e.prices]}:{},...e.standardMatched?{standardPricebookMatched:!0}:{}}}export{Y as a,v as b,A as c,Q as d,q as e,H as f,$ as g};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import"./chunk-NTOVCTRS.mjs";var u=class{generateId;grappeSize;constructor(r,t){this.generateId=r,this.grappeSize=t??2e3}partition(r){let t=g(r.objects),e=[],n=new Map;for(let o of t){let a=f(o.recordCount,this.grappeSize,this.generateId),s=b(o,n),d=[],p=e.length;for(let c of a){let l={...c,index:p,totalPartitions:0,dependencies:s,status:"pending",progress:{processedRecords:0,totalRecords:c.recordCount,successCount:0,failureCount:0,percentage:0,recordsPerSecond:0},retryCount:0};e.push(l),d.push(c.id),p++}n.set(o.objectApiName,d)}for(let o of e)o.totalPartitions=e.length;return e}aggregateResults(r){let t=0,e=0,n=0,o=0,a=0;for(let s of r)t+=s.successCount,e+=s.failureCount,n=Math.max(n,s.duration),s.status==="success"?o++:s.status==="failure"?a++:o++;return{operationId:this.generateId(),totalPartitions:r.length,completedPartitions:o,failedPartitions:a,totalRecords:t+e,successRecords:t,failedRecords:e,duration:n,partitionResults:r}}};function g(i){return[...i].sort((r,t)=>r.insertOrder-t.insertOrder)}function f(i,r,t){let e=[],n=i;for(;n>0;){let o=Math.min(n,r);e.push({id:t(),recordCount:o}),n-=o}return e}function b(i,r){let t=[];for(let e of i.fieldRules)if(e.ruleType==="reference"&&e.config.referenceObject){let n=r.get(e.config.referenceObject);n&&t.push(...n)}return[...new Set(t)]}export{u as SeedGrappeAdapter};
@@ -0,0 +1,19 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a as le}from"./chunk-TUACWKIH.mjs";import{Aa as de,ta as ce,zc as ue}from"./chunk-TTFDUKUS.mjs";import{b as k,e as I,k as b,l as p,r as ae,s as oe,u as G,v as E}from"./chunk-7EANH5PY.mjs";import{appendFile as Be,mkdir as Te,readFile as Je,readdir as $e,rename as Ue,rm as We,stat as He,writeFile as Ze}from"node:fs/promises";import*as M from"node:path";import{appendFile as ke,mkdir as Re,readFile as je,readdir as xe,rename as Oe,rm as Ie,stat as Ae,writeFile as Fe}from"node:fs/promises";import*as $ from"node:path";var Ne="sync-links",Me=2e5,_e=16*1024*1024,J=k().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/),Y=k().min(1).max(200),Ee=p({s:Y,t:Y,o:k().regex(/^[A-Za-z][A-Za-z0-9_]{0,79}$/),p:b(ae([J,J])).max(5e4),l:E(!0).optional()}),De=p({s:Y,t:Y,f:b(J).max(1e6)});function T(s){return s.slice(0,15)}function Ke(s){return s.replace(/[^A-Za-z0-9_-]/g,"_")}function Ce(s){try{return JSON.parse(s)}catch{return}}function Le(s){let e=new Map;for(let t of s.split(`
8
+ `)){if(t.trim()==="")continue;let n=Ce(t),r=Ee.safeParse(n);if(r.success){let{s:y,t:R,o:C,p:P,l:D}=r.data;for(let[_,K]of P){let c=`${y}|${R}|${T(_)}`;e.delete(c),e.set(c,{s:y,t:R,o:C,source:_,target:K,...D===!0?{linked:!0}:{}})}continue}let i=De.safeParse(n);if(!i.success)continue;let{s:o,t:f,f:a}=i.data,g=new Set(a.map(T));for(let[y,R]of e)R.s===o&&R.t===f&&g.has(T(R.target))&&e.delete(y)}return e}function ht(s){return new H({storagePath:s,readFile:e=>je(e,"utf8"),writeFile:(e,t)=>Fe(e,t,"utf8"),appendFile:(e,t)=>ke(e,t,"utf8"),rename:(e,t)=>Oe(e,t),mkdir:async e=>{await Re(e,{recursive:!0})},rm:e=>Ie(e,{force:!0}),listFiles:async e=>{let t;try{t=await xe(e)}catch(r){if(r.code==="ENOENT")return[];throw r}let n=[];for(let r of t){let i=await Ae($.join(e,r)).catch(()=>{});i?.isFile()&&n.push({name:r,size:i.size})}return n}})}var H=class{constructor(e){this.deps=e;this.dir=$.join(e.storagePath,Ne),this.maxPairs=e.maxPairs??Me,this.compactBytes=e.compactBytes??_e}deps;dir;maxPairs;compactBytes;queue=Promise.resolve();fileOf(e){return $.join(this.dir,`${Ke(e)}.ndjson`)}inTurn(e){let t=this.queue.then(e);return this.queue=t.catch(()=>{}),t}async read(e){let t;try{t=await this.deps.readFile(this.fileOf(e))}catch(n){if(n?.code==="ENOENT")return new Map;throw n}return Le(t)}async load(e,t){await this.queue;let n=new Map;for(let r of(await this.read(e)).values())r.s===t.sourceOrgId&&r.t===t.targetOrgId&&n.set(T(r.source),r.target);return n}async linked(e,t){await this.queue;let n=new Set;for(let r of(await this.read(e)).values())r.linked&&r.s===t.sourceOrgId&&r.t===t.targetOrgId&&n.add(T(r.source));return n}record(e,t,n,r,i=!1){let o=r.filter(([f,a])=>J.safeParse(f).success&&J.safeParse(a).success);return o.length===0?Promise.resolve():this.inTurn(async()=>{await this.deps.mkdir(this.dir);let f=this.fileOf(e);for(let a=0;a<o.length;a+=5e4){let g={s:t.sourceOrgId,t:t.targetOrgId,o:n,p:o.slice(a,a+5e4),...i?{l:!0}:{}};await this.deps.appendFile(f,`${JSON.stringify(g)}
9
+ `)}await this.keepWithinBounds(e)})}forget(e,t,n){let r=new Set(n.filter(i=>J.safeParse(i).success).map(T));return r.size===0?Promise.resolve(0):this.inTurn(async()=>{let i=0,o=[];for(let a of(await this.read(e)).values())a.s!==t.sourceOrgId||a.t!==t.targetOrgId||r.has(T(a.target))&&(i++,o.push(a.target));if(i===0)return 0;let f={s:t.sourceOrgId,t:t.targetOrgId,f:[...new Set(o)]};return await this.deps.appendFile(this.fileOf(e),`${JSON.stringify(f)}
10
+ `),await this.keepWithinBounds(e),i})}delete(e){return this.inTurn(()=>this.deps.rm(this.fileOf(e)))}async keepWithinBounds(e){let t=this.fileOf(e),n=$.basename(t);if(((await this.deps.listFiles(this.dir)).find(a=>a.name===n)?.size??0)<=this.compactBytes)return;let i=[...(await this.read(e)).values()].slice(-this.maxPairs),o=[];for(let a of i){let g=o[o.length-1];if(g?.s===a.s&&g.t===a.t&&g.o===a.o&&g.l===a.linked&&g.p.length<5e4){g.p.push([a.source,a.target]);continue}o.push({s:a.s,t:a.t,o:a.o,p:[[a.source,a.target]],...a.linked?{l:!0}:{}})}let f=`${t}.${process.pid}.tmp`;await this.deps.writeFile(f,o.map(a=>`${JSON.stringify(a)}
11
+ `).join("")),await this.deps.rename(f,t)}};function yt(s,e){return{load:async(t,n)=>e(t)?s.load(t,n):null,record:async(t,n,r,i,o)=>{e(t)&&await s.record(t,n,r,i,o)},linked:async(t,n)=>e(t)&&s.linked?s.linked(t,n):new Set,forget:async(t,n,r)=>e(t)&&s.forget?s.forget(t,n,r):0}}var qe="sync-runs",Ye=4*1024*1024,Xe=64*1024*1024,ge=["ContentDocument","Attachment"],Ge=".scenario.json";function kt(s,e,t){return new te({storagePath:s,...e!==void 0?{runsDir:e}:{},...t?{onDropped:t}:{},readFile:n=>Je(n,"utf8"),writeFile:(n,r)=>Ze(n,r,"utf8"),appendFile:(n,r)=>Be(n,r,"utf8"),rename:(n,r)=>Ue(n,r),mkdir:async n=>{await Te(n,{recursive:!0})},rm:n=>We(n,{force:!0}),listFiles:async n=>{let r;try{r=await $e(n)}catch(o){if(o.code==="ENOENT")return[];throw o}let i=[];for(let o of r){let f=await He(M.join(n,o)).catch(()=>{});f?.isFile()&&i.push({name:o,size:f.size})}return i}})}var j=5e4,h=k().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/),S=k().regex(/^[A-Za-z][A-Za-z0-9_]{0,79}$/),w=k().min(1).max(40),Ve=500,Qe=p({run:p({runId:k().min(1).max(200),configId:k().min(1).max(200),configName:k().max(500),sourceOrgId:k().min(1).max(200),targetOrgId:k().min(1).max(200),targetAlias:k().min(1).max(200).optional(),startedAt:w,origin:G(["csv","clone"]).optional(),pipeline:p({name:k().max(Ve)}).optional(),realtime:E(!0).optional(),targetOrganizationId:h.optional(),answersNameJobs:E(!0).optional(),writer:p({pid:I().int().positive(),hostStartedAt:w}).optional(),runUserId:h.optional()})}),et=p({object:S,created:b(h).max(j),at:w.optional(),job:h.optional()}),tt=p({sending:p({object:S,rows:I().int().positive(),at:w,job:h.optional(),upsert:E(!0).optional()})}),nt=p({writing:p({object:S,rows:I().int().positive(),at:w})}),rt=p({touched:p({object:S,rows:I().int().positive(),at:w})}),Se=k().regex(/^[A-Za-z0-9_-]{1,200}$/).refine(s=>!s.includes("__")),it=p({overwriting:p({object:S,backup:Se,ids:b(h).min(1).max(j),held:b(p({id:h,at:w,by:h.optional()})).max(j).optional(),at:w})}),st=p({overwrote:p({object:S,notWritten:b(h).max(j),at:w})}),at=p({unkept:p({object:S,fields:b(S).min(1).max(800),why:E("encrypted"),at:w})}),ot=p({deleted:p({object:S,ids:b(h).min(1).max(j),at:w})}),ct=p({runUser:h}),V=1e3,pe=p({objectApiName:S,reason:k().max(4e3),...de}),we=p({checkpoint:p({state:E("taken"),checkpointId:ce,name:k().min(1).max(500),takenAt:w,expiresAt:w.nullable(),objects:b(S).max(V),records:I().int().nonnegative(),bytes:I().int().nonnegative(),requests:I().int().nonnegative(),added:b(pe).max(V),notHeld:b(pe).max(V)})}),dt=p({end:p({at:w,status:G(["success","partial","failure"]),cancelled:E(!0).optional()})}),me=100,ut=p({version:E(1),undo:p({removedAt:w,deleted:I().int().nonnegative(),alreadyGone:I().int().nonnegative(),kept:I().int().nonnegative(),refused:I().int().nonnegative(),notReached:I().int().nonnegative().optional(),notVisible:I().int().nonnegative().optional()}).optional(),removalStamps:oe(h,w).optional(),removalSpans:b(p({first:w,last:w,userId:h})).optional(),removalLeft:b(h).optional(),restoreLeft:b(h).optional(),restoredAt:w.optional(),undeleteLeft:b(h).optional(),undeletedAt:w.optional(),madeEarlier:b(h).max(1e4*me).optional().catch(void 0),lateEarlier:b(h).max(1e4*me).optional().catch(void 0)});function lt(s){let e=ut.safeParse(s);if(!e.success)return;let{undo:t,removalStamps:n,removalSpans:r,removalLeft:i,restoreLeft:o,restoredAt:f,undeleteLeft:a,undeletedAt:g,madeEarlier:y,lateEarlier:R}=e.data;return{...t?{undo:t}:{},...n?{removalStamps:n}:{},...r?{removalSpans:r}:{},...i?{removalLeft:i}:{},...o?{restoreLeft:o}:{},...f!==void 0?{restoredAt:f}:{},...a?{undeleteLeft:a}:{},...g!==void 0?{undeletedAt:g}:{},...y?{madeEarlier:y}:{},...R?{lateEarlier:R}:{}}}function Q(s){return s.replace(/[^A-Za-z0-9_-]/g,"_")}function ft(s){try{return JSON.parse(s)}catch{return}}function he(s){let e,t,n,r,i,o,f,a=(d,u=!0)=>{d===void 0||!Number.isFinite(Date.parse(d))||(u&&(o===void 0||Date.parse(d)<Date.parse(o))&&(o=d),(f===void 0||Date.parse(d)>Date.parse(f))&&(f=d))},g,y=new Map,R=new Map,C=new Set,P=new X,D=new Map,_=new Map,K=new Map;for(let d of s.split(`
12
+ `)){if(d.trim()==="")continue;let u=ft(d);if(!e){let v=Qe.safeParse(u);v.success&&(e=v.data.run);continue}let m=it.safeParse(u);if(m.success){let{object:v,backup:A,ids:x,at:O,held:N}=m.data.overwriting;a(O),P.candidates(v,A,x);for(let B of N??[]){let se=B.id.slice(0,15);K.has(se)||K.set(se,{at:B.at,...B.by!==void 0?{by:B.by}:{}})}continue}let L=st.safeParse(u);if(L.success){let{object:v,notWritten:A,at:x}=L.data.overwrote;a(x,!1),P.answer(v,A);continue}let Z=nt.safeParse(u);if(Z.success){a(Z.data.writing.at);continue}let z=at.safeParse(u);if(z.success){let{object:v,fields:A}=z.data.unkept,x=_.get(v)??new Set;for(let O of A)x.add(O);_.set(v,x);continue}let U=ot.safeParse(u);if(U.success){let{object:v,ids:A,at:x}=U.data.deleted;a(x);let O=D.get(v)??new Map;for(let N of A)O.has(N.slice(0,15))||O.set(N.slice(0,15),N);D.set(v,O);continue}let W=tt.safeParse(u);if(W.success){let{object:v,rows:A,at:x,job:O,upsert:N}=W.data.sending;a(x),g={objectApiName:v,rows:A,at:x,...O!==void 0?{job:O}:{},...N?{upsert:N}:{}},O!==void 0&&y.set(O,g);continue}let q=rt.safeParse(u);if(q.success){let{at:v}=q.data.touched;a(v),(i===void 0||Date.parse(v)>Date.parse(i))&&(i=v);continue}let F=et.safeParse(u);if(F.success){let{object:v,job:A}=F.data;A!==void 0?(y.delete(A),g?.job===A&&(g=void 0)):g?.objectApiName===v&&(e.answersNameJobs!==!0&&g.job!==void 0&&y.delete(g.job),g=void 0);let x=F.data.at;a(x,F.data.created.length>0),x!==void 0&&F.data.created.length>0&&(i===void 0||Date.parse(x)>Date.parse(i))&&(i=x);let O=R.get(F.data.object)??[];for(let N of F.data.created){let B=N.slice(0,15);C.has(B)||(C.add(B),O.push(N))}R.set(F.data.object,O);continue}let ne=we.safeParse(u);if(ne.success){n=ne.data.checkpoint;continue}let re=ct.safeParse(u);if(re.success){r=re.data.runUser;continue}let ie=dt.safeParse(u);ie.success&&(t=ie.data.end)}if(!e)return;let c={...e};delete c.answersNameJobs;let l=P.read();return{...c,...c.runUserId===void 0&&r!==void 0?{runUserId:r}:{},...t?{end:t}:{},...i!==void 0?{lastWrittenAt:i}:{},...o!==void 0?{firstWrittenAt:o}:{},...f!==void 0?{lastWriteAt:f}:{},...!t&&g?{inFlight:g}:{},...y.size>0?{jobs:[...y.values()]}:{},created:[...R].flatMap(([d,u])=>u.length>0?[{objectApiName:d,ids:u}]:[]),...l.length>0?{overwritten:l}:{},...K.size>0?{heldBefore:Object.fromEntries(K)}:{},..._.size>0?{unkept:[..._].map(([d,u])=>({objectApiName:d,fields:[...u]}))}:{},...D.size>0?{deleted:[...D].map(([d,u])=>({objectApiName:d,ids:[...u.values()]}))}:{},...n?{checkpoint:n}:{}}}var X=class{byObject=new Map;pending=new Map;written=new Set;candidates(e,t,n){let r=this.byObject.get(e)??{backup:t,ids:new Map};this.byObject.set(e,r);let i=this.pending.get(e);if(!i||i.answered){for(let o of i?.ids??[])this.written.add(o);i={ids:new Set,answered:!1},this.pending.set(e,i)}for(let o of n){let f=o.slice(0,15);r.ids.has(f)||r.ids.set(f,o),i.ids.add(f)}}answer(e,t){let n=this.pending.get(e);if(!n)return;n.answered=!0;let r=this.byObject.get(e);for(let i of t){let o=i.slice(0,15);n.ids.has(o)&&(n.ids.delete(o),this.written.has(o)||r?.ids.delete(o))}}read(){return[...this.byObject].flatMap(([e,{backup:t,ids:n}])=>n.size>0?[{objectApiName:e,backup:t,ids:[...n.values()]}]:[])}get count(){let e=0;for(let{ids:t}of this.byObject.values())e+=t.size;return e}};function ve(s,e=!1){let t=ge.flatMap(i=>s.created.filter(o=>o.objectApiName===i)),n=s.created.filter(i=>!ge.includes(i.objectApiName)),r=[...t,...[...n].reverse()].map(({objectApiName:i,ids:o})=>({objectApiName:i,ids:[...o].reverse()}));return e?r.filter(({ids:i})=>i.length>0):ue({objects:r,undo:s.removal?.undo,removalLeft:s.removal?.removalLeft})}function Rt(s){return s.created.reduce((e,t)=>e+t.ids.length,0)}function jt(s){return(s.overwritten??[]).reduce((e,t)=>e+t.ids.length,0)}function be(s){let e=s.removal?.restoreLeft,t=e?new Set(e.map(n=>n.slice(0,15))):void 0;return(s.overwritten??[]).flatMap(n=>{let r=t?n.ids.filter(i=>t.has(i.slice(0,15))):[...n.ids];return r.length>0?[{...n,ids:r}]:[]})}function xt(s){return(s.deleted??[]).reduce((e,t)=>e+t.ids.length,0)}function gt(s){let e=s.removal?.undeleteLeft,t=e?new Set(e.map(n=>n.slice(0,15))):void 0;return(s.deleted??[]).flatMap(n=>{let r=t?n.ids.filter(i=>t.has(i.slice(0,15))):[...n.ids];return r.length>0?[{objectApiName:n.objectApiName,ids:r}]:[]})}function ee(s){return ve(s).length>0||be(s).length>0||gt(s).length>0?!1:s.removal?.undo!==void 0||s.removal?.restoredAt!==void 0||s.removal?.undeletedAt!==void 0}function ye(s){return new Set([...ve(s),...be(s)].flatMap(({ids:e})=>e.map(t=>t.slice(0,15))))}function Ot(s){return s.targetAlias??s.targetOrgId}function Pe(s,e){return e.filter(t=>t.runId!==s.runId&&pt(s,t)&&!ee(t))}function pt(s,e){return s.targetOrganizationId!==void 0&&e.targetOrganizationId!==void 0?s.targetOrganizationId.slice(0,15)===e.targetOrganizationId.slice(0,15):s.targetOrgId===e.targetOrgId}function It(s,e){let t=Date.parse(s.startedAt);return Pe(s,e).filter(n=>Date.parse(n.startedAt)<t)}function At(s,e){let t=ye(s);if(t.size===0)return[];let n=Date.parse(s.startedAt);return Pe(s,e).filter(r=>Date.parse(r.startedAt)>n).flatMap(r=>{let i=0;for(let o of ye(r))t.has(o)&&i++;return i>0?[{runId:r.runId,configName:r.configName,startedAt:r.startedAt,records:i,...r.realtime?{realtime:!0}:{}}]:[]}).sort((r,i)=>Date.parse(i.startedAt)-Date.parse(r.startedAt)||0)}var te=class{constructor(e){this.deps=e;this.dir=M.join(e.storagePath,e.runsDir??qe),this.maxBytes=e.maxBytes??Ye,this.hardMaxBytes=Math.max(this.maxBytes,e.hardMaxBytes??Xe)}deps;dir;maxBytes;hardMaxBytes;queue=Promise.resolve();links;runPath(e){return M.join(this.dir,`${Q(e)}.ndjson`)}pathOf(e){return this.runPath(e)}removalPath(e){return M.join(this.dir,`${Q(e)}.removal.json`)}scenarioPath(e){return M.join(this.dir,`${Q(e)}${Ge}`)}get storagePath(){return this.deps.storagePath}recorder(e){let t=this.runPath(e.runId),n=this.deps.host??le,r={...e,startedAt:e.startedAt??new Date().toISOString(),answersNameJobs:!0,writer:{pid:n.pid,hostStartedAt:n.startedAt}},i=new Map,o=new X,f=!1,a=Promise.resolve(),g,y=!1,R,C,P=c=>{y=!0;let l=R;R=void 0;let d=C;C=void 0,a=a.then(async()=>{if(g===void 0)try{f||(f=!0,await this.deps.mkdir(this.dir),await this.keepWithinBounds(e.runId).catch(()=>{}),await this.deps.appendFile(t,`${JSON.stringify({run:r})}
13
+ `)),d!==void 0&&await this.deps.appendFile(t,`${JSON.stringify(d)}
14
+ `),l!==void 0&&await this.deps.appendFile(t,`${JSON.stringify(l)}
15
+ `),await this.deps.appendFile(t,`${JSON.stringify(c)}
16
+ `)}catch(u){g=u instanceof Error?u.message:String(u)}})},D=new Set,_=(c,l,d,u=0)=>{for(let m=u;m<l.length;m+=j)P({object:c,created:l.slice(m,m+j),at:d})},K=(c,l,d)=>{let u=l.filter(m=>h.safeParse(m).success);u.length===0||!S.safeParse(c).success||_(c,u,d??new Date().toISOString())};return{runId:e.runId,note:K,noteUnanswered:(c,l)=>K(c,l.filter(d=>!D.delete(d.slice(0,15)))),sending:(c,l,d)=>{if(l<=0||!S.safeParse(c).success)return;let u=d?.job!==void 0&&h.safeParse(d.job).success?d.job:"";u!==""?i.set(c,u):i.delete(c),P({sending:{object:c,rows:l,at:new Date().toISOString(),...u!==""?{job:u}:{},...d?.upsert?{upsert:!0}:{}}})},answered:(c,l)=>{if(!S.safeParse(c).success)return;let d=l.filter(L=>h.safeParse(L).success),u=i.get(c);i.delete(c);for(let L of d)D.add(L.slice(0,15));let m=new Date().toISOString();P({object:c,created:d.slice(0,j),at:m,...u!==void 0?{job:u}:{}}),_(c,d,m,j)},writing:(c,l)=>{if(l<=0||!S.safeParse(c).success)return;let d={writing:{object:c,rows:l,at:new Date().toISOString()}};y?P(d):R??=d},touched:(c,l)=>{l<=0||!S.safeParse(c).success||P({touched:{object:c,rows:l,at:new Date().toISOString()}})},overwriting:(c,l,d,u)=>{if(!S.safeParse(c).success||!Se.safeParse(l).success)return;let m=d.filter(z=>h.safeParse(z).success);if(m.length===0)return;o.candidates(c,l,m);let L=new Date().toISOString(),Z=new Map((u??[]).flatMap(z=>h.safeParse(z.id).success&&w.safeParse(z.at).success?[[z.id.slice(0,15),{id:z.id,at:z.at,...z.by!==void 0&&h.safeParse(z.by).success?{by:z.by}:{}}]]:[]));for(let z=0;z<m.length;z+=j){let U=m.slice(z,z+j),W=U.flatMap(q=>{let F=Z.get(q.slice(0,15));return F?[F]:[]});P({overwriting:{object:c,backup:l,ids:U,...W.length>0?{held:W}:{},at:L}})}},overwrote:(c,l)=>{if(!S.safeParse(c).success)return;let d=l.filter(m=>h.safeParse(m).success);o.answer(c,d);let u=new Date().toISOString();for(let m=0;m===0||m<d.length;m+=j)P({overwrote:{object:c,notWritten:d.slice(m,m+j),at:u}})},deleted:(c,l)=>{if(!S.safeParse(c).success)return;let d=l.filter(m=>h.safeParse(m).success),u=new Date().toISOString();for(let m=0;m<d.length;m+=j)P({deleted:{object:c,ids:d.slice(m,m+j),at:u}})},unkept:(c,l)=>{if(!S.safeParse(c).success)return;let d=l.filter(u=>S.safeParse(u).success);d.length!==0&&P({unkept:{object:c,fields:d.slice(0,800),why:"encrypted",at:new Date().toISOString()}})},checkpoint:c=>{let l=we.safeParse({checkpoint:c});l.success&&(y?P(l.data):C=l.data)},runUser:c=>{h.safeParse(c).success&&(y?P({runUser:c}):r.runUserId=c)},overwrittenCount:()=>o.count,flush:async()=>(await a,g),end:async c=>{await a,!(!f||g!==void 0)&&(P({end:{at:c.at??new Date().toISOString(),status:c.status,...c.cancelled?{cancelled:!0}:{}}}),await a)}}}idMap(){return this.links??=new H(this.deps),this.links}async get(e){let t;try{t=await this.deps.readFile(this.runPath(e))}catch{return}let n=he(t);if(!n||n.runId!==e)return;let r=await this.readRemoval(e);return r?{...n,removal:r}:n}async list(){let e=[];for(let t of await this.deps.listFiles(this.dir)){if(!t.name.endsWith(".ndjson"))continue;let n;try{n=await this.deps.readFile(M.join(this.dir,t.name))}catch{continue}let r=he(n);if(!r)continue;let i=await this.readRemoval(r.runId);e.push(i?{...r,removal:i}:r)}return e.sort((t,n)=>Date.parse(n.startedAt)-Date.parse(t.startedAt)||0)}updateRemoval(e,t){let n=this.queue.then(async()=>{let r=t(await this.readRemoval(e)??{}),i=this.removalPath(e),o=`${i}.${process.pid}.tmp`;await this.deps.mkdir(this.dir),await this.deps.writeFile(o,JSON.stringify({version:1,...r})),await this.deps.rename(o,i)});return this.queue=n.catch(()=>{}),n}async answerInFlight(e,t,n,r,i){if(!S.safeParse(t).success)return!1;let o=this.runPath(e);try{await this.deps.readFile(o)}catch{return!1}let f=n.filter(y=>h.safeParse(y).success),a=i!==void 0&&h.safeParse(i).success?{job:i}:{},g=[];for(let y=0;y===0||y<f.length;y+=j)g.push(JSON.stringify({object:t,created:f.slice(y,y+j),at:r,...a}));return await this.deps.appendFile(o,`
17
+ ${g.join(`
18
+ `)}
19
+ `),!0}async forget(e){await this.deps.rm(this.runPath(e)),await this.deps.rm(this.removalPath(e)),await this.deps.rm(this.scenarioPath(e))}async readRemoval(e){let t;try{t=JSON.parse(await this.deps.readFile(this.removalPath(e)))}catch{return}return lt(t)}async keepWithinBounds(e){let t=await this.deps.listFiles(this.dir),n=t.reduce((a,g)=>a+g.size,0);if(n<=this.maxBytes)return;let r=new Map(t.map(a=>[a.name,a.size])),i=(await this.list()).filter(a=>a.runId!==e).reverse(),o=a=>(r.get(M.basename(this.runPath(a.runId)))??0)+(r.get(M.basename(this.removalPath(a.runId)))??0)+(r.get(M.basename(this.scenarioPath(a.runId)))??0),f=async a=>{await this.forget(a.runId),n-=o(a)};for(let a of i){if(n<=this.maxBytes)return;ee(a)&&await f(a)}for(let a of i){if(n<=this.hardMaxBytes)return;if(!ee(a)){await f(a);try{this.deps.onDropped?.(a)}catch{}}}}};export{ht as a,yt as b,qe as c,Ye as d,Xe as e,ge as f,Ge as g,kt as h,j as i,Ve as j,Se as k,lt as l,he as m,X as n,ve as o,Rt as p,jt as q,be as r,xt as s,gt as t,ee as u,Ot as v,It as w,At as x,te as y};
@@ -0,0 +1,11 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{u as Q,w as q}from"./chunk-LPBMBW3O.mjs";import{F as W,H as Z,d as K,k as I,r as b,s as L,t as F,u as J,x as D,z as U}from"./chunk-IFETCRWE.mjs";import{Ca as Y,Da as G,Ea as N}from"./chunk-TTFDUKUS.mjs";import{b as H,e as _,m as $,v as X}from"./chunk-7EANH5PY.mjs";import{createCipheriv as be,createDecipheriv as Be,createHash as y,hkdfSync as Ae,randomBytes as S,timingSafeEqual as Ee}from"node:crypto";import{createReadStream as Oe}from"node:fs";import{lstat as ee,open as T,rename as xe,rm as Ie,statfs as Se}from"node:fs/promises";import{basename as ie,dirname as oe,join as ve}from"node:path";import{Readable as ae}from"node:stream";import{pipeline as se}from"node:stream/promises";import{createGunzip as Re,createGzip as Ce}from"node:zlib";var ct=".sfcheckpoint",Te=1024*1024,Pe=new Set([1]),He=new Set([1]),P=32,A=16,_e=4096,$e=1024,Ne=64*1024*1024,ce=2**32,he="sandforge-checkpoint/1 block key",fe="sandforge-checkpoint/1 key check",M="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",Ke=Math.ceil(P*8/5),w="Nothing was imported.";function ht(){return S(P)}function ft(n){if(n.length!==P)throw new RangeError("Not a key of a checkpoint file");let e="",t=0,r=0;for(let i of n)for(t=(t<<8|i)&65535,r+=8;r>=5;)e+=M[t>>>r-5&31],r-=5;return r>0&&(e+=M[t<<5-r&31]),(e.match(/.{1,4}/g)??[]).join("-")}function dt(n){let e=n.replace(/[\s-]/g,"").toUpperCase();if(e.length!==Ke||!/^[A-Z2-7]+$/.test(e))return;let t=Buffer.alloc(P),r=0,i=0,o=0;for(let a of e)r=(r<<5|M.indexOf(a))&65535,i+=5,i>=8&&(t[o++]=r>>>i-8&255,i-=8);if((r&(1<<i)-1)===0)return t}function v(n,e,t,r){return Buffer.from(Ae("sha256",n,e,t,r))}function de(n,e){let t=Buffer.alloc(12);return n.copy(t,0),t.writeUInt32BE(e,8),t}function le(n,e,t){let r=Buffer.alloc(37);return n.copy(r,0),r.writeUInt32BE(e,32),r[36]=t?1:0,r}function Fe(n,e,t,r){let i=be("aes-256-gcm",n.blockKey,de(n.prefix,e),{authTagLength:A});return i.setAAD(le(n.headerHash,e,t)),Buffer.concat([i.update(r),i.final(),i.getAuthTag()])}function De(n,e,t,r){let i=Be("aes-256-gcm",n.blockKey,de(n.prefix,e),{authTagLength:A});i.setAAD(le(n.headerHash,e,t)),i.setAuthTag(r.subarray(r.length-A));try{let o=i.update(r.subarray(0,r.length-A));return Buffer.concat([o,i.final()])}catch{return}}var R=class extends Error{constructor(t){super(t.message);this.refusal=t;this.name="ImportRefused"}refusal};function f(n){return new R({code:"IMPORT_DAMAGED",message:`This checkpoint file ${n}: it was changed or damaged after it was exported. ${w}`})}var E=class extends Error{constructor(t,r){super(r);this.code=t;this.name="CheckpointExportError"}code};function Me(n){return{...C(n,ue),org:C(n.org,pe)}}var ue=["lastRewind","takenOn","expiresAt","bytes","importedFrom"],pe=["alias"];function C(n,e){return Object.fromEntries(Object.entries(n).filter(([t])=>!e.includes(t)))}async function*ye(n,e){if(e===0)return;let t=0;for await(let r of Oe(n,{start:0,end:e-1})){let i=r;t+=i.length,yield i}if(t!==e)throw new E("EXPORT_CHANGED",`${ie(n)} of the checkpoint shrank while it was exported: export it again.`)}async function me(n,e){let t=y("sha256");for await(let r of ye(n,e))t.update(r);return t.digest("hex")}async function lt(n){let{folder:e,checkpoint:t,out:r,key:i}=n,o=n.chunkBytes??Te;if(await ee(r).catch(()=>{}))throw new E("EXPORT_EXISTS",`${r} is there already: name another file, or move that one away first.`);let a=Buffer.from(`${JSON.stringify(Me(t))}
8
+ `,"utf8"),s=[{path:b,bytes:a.length,sha256:y("sha256").update(a).digest("hex"),content:a}];for(let l of await F(e))l.path!==b&&s.push({...l,sha256:await me(l.file,l.bytes)});let h=S(32),c=S(8),d={format:"sandforge-checkpoint",formatVersion:1,checkpointFormat:1,sandforgeVersion:n.sandforgeVersion,organizationId:I(t.org.organizationId),orgTier:t.org.tier,checkpointId:t.checkpointId,takenAt:t.takenAt,records:we(t),objects:t.objects.length,files:s.length,bytes:s.reduce((l,p)=>l+p.bytes,0),cipher:"aes-256-gcm",kdf:"hkdf-sha256",salt:h.toString("hex"),noncePrefix:c.toString("hex"),keyCheck:v(i,h,fe,16).toString("hex"),chunkBytes:o},u=Buffer.from(`${JSON.stringify(N.parse(d))}
9
+ `),m={blockKey:v(i,h,he,32),prefix:c,headerHash:y("sha256").update(u).digest()},k=ve(oe(r),`.${ie(r)}.${process.pid}-${S(4).toString("hex")}.tmp`),O=y("sha256"),g=0,x=await T(k,"wx",K);try{try{let l=async p=>{O.update(p),g+=p.length,await ge(x,p)};await l(u),await se(ae.from(ze(s)),Ce({level:6}),async p=>{await je(p,o,m,l)}),await x.sync()}finally{await x.close()}if(await ee(r).catch(()=>{}))throw new E("EXPORT_EXISTS",`${r} appeared while the checkpoint was exported: name another file.`);await xe(k,r)}catch(l){throw await Ie(k,{force:!0}),l}return{header:d,bytes:g,sha256:O.digest("hex")}}async function ge(n,e){for(let t=0;t<e.length;){let{bytesWritten:r}=await n.write(e,t,e.length-t);t+=r}}function we(n){return n.objects.reduce((e,t)=>e+t.records,0)}async function*ze(n){for(let e of n){let{path:t,bytes:r,sha256:i}=e;if(yield Buffer.from(`${JSON.stringify({path:t,bytes:r,sha256:i})}
10
+ `,"utf8"),e.content!==void 0){yield e.content;continue}let o=y("sha256");for await(let a of ye(e.file??"",r))o.update(a),yield a;if(o.digest("hex")!==i)throw new E("EXPORT_CHANGED",`${t} of the checkpoint changed while it was exported: export it again.`)}yield Buffer.from(`${JSON.stringify({end:!0,files:n.length})}
11
+ `,"utf8")}async function je(n,e,t,r){let i=0,o,a=[],s=0,h=async c=>{if(o!==void 0){if(i>=ce)throw new RangeError("The checkpoint is too large for one file");await r(Fe(t,i,c,o)),i++,o=void 0}};for await(let c of n)for(a.push(c),s+=c.length;s>=e;){let d=Buffer.concat(a);await h(!1),o=d.subarray(0,e),a=[d.subarray(e)],s=d.length-e}s>0&&(await h(!1),o=Buffer.concat(a)),await h(!0)}async function z(n,e,t){let r=Buffer.alloc(t),i=0;for(;i<t;){let{bytesRead:o}=await n.read(r,i,t-i,e+i);if(o===0)break;i+=o}return i===t?r:r.subarray(0,i)}function B(n){return{refusal:{code:"IMPORT_NOT_ARCHIVE",message:`This is not a checkpoint file SandForge exported: ${n}. ${w}`}}}async function Ve(n){let e;try{e=await T(n,"r")}catch(t){let r=t.code;return B(r==="ENOENT"?"there is no such file":"it cannot be read")}try{let t=await e.stat();if(!t.isFile())return B("it is not a file");let r=await z(e,0,Math.min(t.size,_e)),i=r.indexOf(10);if(i<0)return B("it does not start with a checkpoint file\u2019s header");let o=r.subarray(0,i+1),a;try{a=JSON.parse(o.toString("utf8"))}catch{return B("it does not start with a checkpoint file\u2019s header")}let s=G.safeParse(a);if(!s.success)return B("it does not start with a checkpoint file\u2019s header");let{formatVersion:h,checkpointFormat:c,sandforgeVersion:d}=s.data;if(!He.has(h)||!Pe.has(c))return{refusal:{code:"IMPORT_VERSION",message:`This file was made by SandForge ${d}, with checkpoint format ${c} in file format ${h}, which this SandForge does not read: update SandForge, then import it. ${w}`}};let u=N.safeParse(a);return u.success?{read:{header:u.data,headerBytes:o.length,headerHash:y("sha256").update(o).digest(),size:t.size}}:B("its header does not read")}finally{await e.close()}}async function Xe(n){try{let e=await Se(n);return Number(e.bavail)*Number(e.bsize)}catch{return}}async function ut(n){try{return await Ye(n)}catch(e){if(e instanceof R)return{imported:!1,refusal:e.refusal};if(e instanceof W&&e.code==="damaged")return{imported:!1,refusal:{code:"IMPORT_DAMAGED",message:`${e.message} ${w}`}};throw e}}async function Ye(n){let{store:e,file:t,key:r}=n,i=n.now??new Date,o=await Ve(t);if("refusal"in o)return{imported:!1,refusal:o.refusal};if(!o.read.headerHash.equals(n.read.headerHash))throw f("changed since its header was read");let a=o.read,{header:s}=a,h=Buffer.from(s.salt,"hex");if(!Ee(v(r,h,fe,16),Buffer.from(s.keyCheck,"hex")))return{imported:!1,refusal:{code:"IMPORT_KEY",message:`This key is not the one the file was exported with. ${w}`}};let c={blockKey:v(r,h,he,32),prefix:Buffer.from(s.noncePrefix,"hex"),headerHash:a.headerHash},d=await e.read(s.checkpointId);if(d!==void 0)return ne(d,t,a,c);let u=await(n.freeBytes??Xe)(e.root),m=s.bytes+Q(s.records,2)+s.objects*8;if(u!==void 0&&u<m)return{imported:!1,refusal:{code:"IMPORT_DISK",message:`The checkpoint takes about ${te(m)} on this machine, and its disk has ${te(u)} free: make room, then import it. ${w}`}};let k=await e.importInto(s.organizationId,s.checkpointId,async g=>{let x=await ke(t,a,c,g.dir),l=We(x,a,{...n.alias!==void 0?{alias:n.alias}:{},keepDays:n.keepDays,takenOn:n.takenOn,now:i});await D(g.indexDir);for(let p of l.objects){let V=await q(g,l.snapshotId,p.objectApiName);if(V.rows!==p.records)throw f(`holds ${V.rows} records of ${p.objectApiName} where its checkpoint counts ${p.records}`)}return await Z(g,l.objects),l});if(k.outcome==="imported")return{imported:!0,outcome:"imported",checkpoint:k.checkpoint};let O=await e.read(s.checkpointId);if(O===void 0)throw f("could not be kept");return ne(O,t,a,c)}function te(n){return`${(n/(1024*1024)).toFixed(1)} MB`}async function ne(n,e,t,r){let i=c=>({imported:!1,refusal:{code:"IMPORT_KEPT_OTHER",message:`A checkpoint ${t.header.checkpointId} is kept on this machine already, ${c}: delete it first to import this file. ${w}`}});if(n.folder.organizationId!==I(t.header.organizationId))return i("of another org");if(n.checkpoint===void 0)return i("damaged");let o=i("and differs from this one"),a=await ke(e,t,r),s=new Map(a.hashes.filter(([c])=>c!==b).map(([c,d])=>[c,d])),h=(await F(n.folder)).filter(c=>c.path!==b);if(h.length!==s.size)return o;for(let c of h)if(s.get(c.path)!==await me(c.file,c.bytes))return o;return{imported:!0,outcome:"alreadyKept",checkpoint:n.checkpoint}}var Ge=$({path:H().min(1).max(300),bytes:_().int().nonnegative(),sha256:H().regex(/^[0-9a-f]{64}$/)}),Le=$({end:X(!0),files:_().int().positive()});async function ke(n,e,t,r){let i=await T(n,"r"),o=y("sha256");try{let a=new j(e.header,r);try{await se(ae.from(Je(i,e,t,o)),Re(),async h=>{for await(let c of h)await a.take(c)})}catch(h){throw String(h.code??"").startsWith("Z_")?f("does not inflate"):h}finally{await a.close()}return{...a.ended(),sha256:o.digest("hex")}}finally{await i.close()}}async function*Je(n,e,t,r){r.update(await z(n,0,e.headerBytes));let i=e.header.chunkBytes+A,o=e.size-e.headerBytes;if(o<=0)throw f("holds nothing after its header");let a=Math.ceil(o/i),s=o-(a-1)*i;if(s<=A)throw f("ends inside a block");if(a>ce)throw f("holds more blocks than a file can");for(let h=0;h<a;h++){let c=h===a-1,d=c?s:i,u=await z(n,e.headerBytes+h*i,d);if(u.length<d)throw f("is cut short");r.update(u);let m=De(t,h,c,u);if(m===void 0)throw f(`holds a block, the ${Ue(h+1)} of ${a}, that does not decrypt`);yield m}}function Ue(n){let e=n%100,t=e>=11&&e<=13?"th":["th","st","nd","rd"][n%10]??"th";return`${n}${t}`}var j=class{constructor(e,t){this.header=e;this.into=t}header;into;line=[];lineBytes=0;current;seen=new Set;hashes=[];portable;bytes=0;end=!1;async take(e){let t=0;for(;t<e.length;){if(this.end)throw f("holds bytes after its last entry");let r=this.current;if(r!==void 0){let s=e.subarray(t,t+Math.min(r.left,e.length-t));t+=s.length,r.left-=s.length,r.hash.update(s),r.handle!==void 0&&await ge(r.handle,s),r.held?.push(Buffer.from(s)),r.left===0&&await this.endEntry();continue}let i=e.indexOf(10,t),o=i<0?e.length:i;if(this.lineBytes+=o-t,this.lineBytes>$e)throw f("holds a line too long for an entry");if(this.line.push(e.subarray(t,o)),t=o,i<0)continue;t++;let a=Buffer.concat(this.line).toString("utf8");this.line=[],this.lineBytes=0,await this.startEntry(a)}}async startEntry(e){let t;try{t=JSON.parse(e)}catch{throw f("holds an entry that does not read")}let r=Le.safeParse(t);if(r.success){if(r.data.files!==this.hashes.length||r.data.files!==this.header.files)throw f("counts other files than it holds");this.end=!0;return}let i=Ge.safeParse(t);if(!i.success)throw f("holds an entry that does not read");let{path:o,bytes:a,sha256:s}=i.data;if(!L(o))throw f(`names a file no checkpoint holds, ${JSON.stringify(o)}`);if(this.seen.has(o))throw f(`holds ${o} twice`);if(this.seen.add(o),this.bytes+=a,this.bytes>this.header.bytes||this.seen.size>this.header.files)throw f("holds more than its header says");let h=o===b;if(h&&a>Ne)throw f("holds a checkpoint.json larger than any checkpoint\u2019s");let c;if(!h&&this.into!==void 0){let d=J(this.into,o);await D(oe(d)),c=await T(d,"wx",K)}this.current={path:o,left:a,sha256:s,hash:y("sha256"),...c!==void 0?{handle:c}:{},...h?{held:[]}:{}},a===0&&await this.endEntry()}async endEntry(){let e=this.current;if(e!==void 0){if(this.current=void 0,e.handle!==void 0)try{await e.handle.sync()}finally{await e.handle.close()}if(e.hash.digest("hex")!==e.sha256)throw f(`holds ${e.path} with other bytes than its sha256 says`);e.held!==void 0&&(this.portable=Buffer.concat(e.held)),this.hashes.push([e.path,e.sha256])}}async close(){await this.current?.handle?.close().catch(()=>{})}ended(){if(!this.end||this.current!==void 0)throw f("is cut short");if(this.bytes!==this.header.bytes)throw f("holds other bytes than its header says");if(this.portable===void 0)throw f("holds no checkpoint.json");return{portable:this.portable,hashes:this.hashes}}};function We(n,e,t){let r;try{r=JSON.parse(n.portable.toString("utf8"))}catch{throw f("holds a checkpoint.json that does not read")}if(!re(r)||!re(r.org))throw f("holds a checkpoint.json that does not read");let i=Y.safeParse({...C(r,ue),org:{...C(r.org,pe),...t.alias!==void 0?{alias:t.alias}:{}},takenOn:t.takenOn,expiresAt:U(t.now,t.keepDays),bytes:0,importedFrom:{at:t.now.toISOString(),sandforgeVersion:e.header.sandforgeVersion,sha256:n.sha256}});if(!i.success)throw f("holds a checkpoint.json that does not parse");let o=i.data,{header:a}=e;if(o.checkpointId!==a.checkpointId||I(o.org.organizationId)!==I(a.organizationId)||o.takenAt!==a.takenAt||o.status!=="ready"||we(o)!==a.records||o.objects.length!==a.objects)throw f("holds another checkpoint than its header says");return o}function re(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}export{ct as a,Te as b,ht as c,ft as d,dt as e,E as f,Me as g,lt as h,Ve as i,ut as j};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a,b,c}from"./chunk-WA7EYLAQ.mjs";import"./chunk-LKQ5RKIV.mjs";import"./chunk-XAMBCQPU.mjs";import"./chunk-IG2MTQRP.mjs";import"./chunk-WR4Q363I.mjs";import"./chunk-O2HDYYUV.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-E5AHXLS6.mjs";import"./chunk-PZPJKATS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{a as DX_PROJECT_FILE,b as scenarioProjectOf,c as writeRunTestFile};
@@ -0,0 +1,14 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ var m=()=>({input:process.stdin,output:process.stderr});function p(t,o,r){let{input:e,output:i}=o;return e.isTTY!==!0&&(i.write(`${t}
8
+ no terminal to answer: give --yes to go ahead without the question.
9
+ `),process.exit(2)),r?.aborted===!0?Promise.resolve(void 0):(i.write(`${t} `),new Promise(c=>{let n=s=>{e.off("data",a),e.off("end",u),r?.removeEventListener("abort",f),e.pause(),c(s)},a=s=>n(String(s).trim()),u=()=>n(void 0),f=()=>{i.write(`
10
+ `),n(void 0)};e.on("data",a),e.on("end",u),r?.addEventListener("abort",f,{once:!0}),e.resume()}))}async function T(t,o=m(),r){let e=await p(`${t} [y/N]`,o,r);return e!==void 0&&/^y(es)?$/i.test(e)}async function E(t,o=m()){return await p(t,o)??""}var w=new Set(["\r",`
11
+ `]),g=new Set(["\x7F","\b"]),l="",S="";function v(t,o,r=m()){let{input:e,output:i}=r;return e.isTTY!==!0&&(i.write(`${t}
12
+ no terminal to type it on: ${o}.
13
+ `),process.exit(2)),i.write(`${t} `),e.setRawMode?.(!0),new Promise(c=>{let n="",a=s=>{e.off("data",u),e.off("end",f),e.setRawMode?.(!1),e.pause(),i.write(`
14
+ `),c(s)},u=s=>{for(let d of String(s)){if(w.has(d))return a(n);if(d===l||d===S&&n==="")return a(void 0);g.has(d)?n=n.slice(0,-1):d>=" "&&(n+=d)}},f=()=>a(void 0);e.on("data",u),e.on("end",f),e.resume()})}export{T as a,E as b,v as c};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ function b(n,s,o=[]){let d=new Set([...o].map(a=>a.slice(0,15))),u=new Map,m=[];for(let a of[...n??[],...s]){let S=a.slice(0,15);if(!/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(a)||d.has(S))continue;let e=S.slice(0,3),t=u.get(e)??0;t>=1e4||(d.add(S),u.set(e,t+1),m.push(a))}return m}var p={made:3,madeOver:2,late:1};function w(n,s,o){return n<s?n-s:n>o?n-o:0}function g(n,s,o){let d=Number.isFinite(s.from)&&Number.isFinite(s.to),u=d?s.from:o.runSpan.from,m=d?s.to:o.runSpan.to,a=w(n.created,u,m);if(a>=-2e3&&!(a>9e5))return n.automatedProcess||a>6e4?{class:"late",sameSave:!1}:s.kind==="overwritten"?{class:"madeOver",sameSave:!1}:{class:"made",sameSave:Math.abs(a)<=2e3}}function E(n){let s=new Map(n.candidates.map(e=>[e.key,e])),o=new Map,d=(e,t,r)=>{let c=o.get(e)??new Map,f=c.get(t);return f!==void 0&&f<=r?!1:(c.set(t,r),o.set(e,c),!0)};for(let e of n.candidates)for(let t of e.references)n.anchors.has(t.key)&&d(e.key,t.key,1);for(let e of n.pointers)n.anchors.has(e.from)&&s.has(e.to)&&d(e.to,e.from,1);for(let e=2;e<=3;e++){let t=!1;for(let r of n.candidates)for(let c of r.references)for(let[f,l]of o.get(c.key)??[])c.key===r.key||l+1>3||d(r.key,f,l+1)&&(t=!0);if(!t)break}let u=new Map,m=(e,t,r)=>{let c=t===1?u.get(e):void 0;if(c!==void 0)return c;let f=s.get(e);if(!f||t>3||r.has(e))return!1;r.add(e);let l=f.references.some(i=>i.cascade&&(n.anchors.get(i.key)?.kind==="created"||m(i.key,t+1,r)));return r.delete(e),t===1&&u.set(e,l),l},a=new Set(n.pointers.filter(e=>e.restricted&&n.anchors.has(e.from)).map(e=>e.to)),S=new Map;for(let e of n.candidates){if(!(e.created<n.removalBegan))continue;let t;for(let f of o.get(e.key)?.keys()??[]){let l=n.anchors.get(f);if(!l)continue;let i=g(e,l,n);i&&(!t||p[i.class]>p[t.class]||i.class===t.class&&i.sameSave)&&(t=i)}!t&&n.madeEarlier?.has(e.key)&&!e.automatedProcess&&(t={class:"made",sameSave:!1}),!t&&n.lateEarlier?.has(e.key)&&(t={class:"late",sameSave:!1});let r=a.has(e.key)?"after":m(e.key,1,new Set)?"with":"before";if(t){S.set(e.key,{...t,turn:r});continue}let c=e.created>=n.window.from&&e.created<=n.window.to;!e.automatedProcess&&c&&S.set(e.key,{class:"untied",sameSave:!1,turn:r})}return S}export{b as a,E as b};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"./chunk-ZUTYVST5.mjs";import"./chunk-NTOVCTRS.mjs";export{a as CURRENCY_FIELD,q as CURRENCY_FOLLOWS,c as CURRENCY_SETTINGS_SOQL,b as CURRENCY_TYPES_SOQL,u as CurrencyReplacementTally,d as DATED_RATES_ON_SOQL,e as DATED_RATES_SOQL,j as DATED_RATE_FIELDS,l as conversionFactor,n as currencyFieldsOf,w as currencyReplacementsNote,k as datedRateOf,g as datedRatesOf,v as describeCurrencyReplaced,t as followParentCurrency,r as followsItsParentsCurrency,f as orgCurrenciesOf,s as parentCurrencyChange,h as readOrgCurrencies,i as readRunCurrencies,p as replaceRowCurrency,o as replacementCurrency,m as roundToScale};
@@ -0,0 +1,14 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{f as ce}from"./chunk-A527W53V.mjs";import{wc as de}from"./chunk-TTFDUKUS.mjs";import{b as u,e as f,i as ie,k as w,l as m,r as se,s as N,u as ae,v as D}from"./chunk-7EANH5PY.mjs";import{createHash as fe}from"node:crypto";import*as C from"node:fs/promises";import*as M from"node:path";import*as I from"node:fs/promises";import*as O from"node:path";import*as U from"node:fs";import*as b from"node:path";function Oe(t){let e=b.resolve(t);for(;;){if(U.existsSync(b.join(e,".git"))||U.existsSync(b.join(e,"pnpm-workspace.yaml")))return e;let r=b.dirname(e);if(r===e)throw new Error(`No repository root found above ${t}`);e=r}}function le(t){let e=b.resolve(t);return process.platform==="win32"?e.toLowerCase():e}function _(t){if(!/^[A-Za-z0-9_-]{1,128}$/.test(t))throw new Error(`Not an org id a file of the sas can be named after: "${t}"`);return t}var q=class extends Error{constructor(r,n){super(`Refusing output path inside the repository: ${r} (repo root: ${n}). Frozen-dataset exports, retained-ID lists and working manifests must live in a sas directory OUTSIDE the repo \u2014 versioning them would create a real\u2194anonymized correspondence table.`);this.resolvedPath=r;this.repoRoot=n;this.name="InsideRepoPathError"}resolvedPath;repoRoot},k=class{repoRoot;constructor(e){this.repoRoot=e?b.resolve(e):Oe(process.cwd())}isInsideRepo(e){let r=le(this.repoRoot),n=le(e);if(n===r)return!0;let i=b.relative(r,n);return i!==""&&!i.startsWith("..")&&!b.isAbsolute(i)}assertOutsideRepo(e){if(this.isInsideRepo(e))throw new q(b.resolve(e),this.repoRoot);return b.resolve(e)}};function ot(t){return t.map(({objectApiName:e,why:r,count:n})=>({objectApiName:e,count:n,note:ce(n,r)}))}var ue=/^\d+\.\d+\.\d+$/,Se=/^[0-9a-f]{12}$/,P=class extends Error{constructor(e){super(e),this.name="ManifestError"}};function it(t){let e=(t.now?.()??new Date).toISOString(),r={version:t.version,status:"frozen",frozenAt:e,source:t.source,saltFingerprint:t.saltFingerprint,rulesVersion:t.rulesVersion,volumetry:t.volumetry,controls:{nonReidentification:t.nonReidentification,dryRunLoad:null,author:t.author,date:e},...t.coverage?{coverage:t.coverage}:{}};return W(r),r}function W(t){if(!ue.test(t.version))throw new P(`version must be semver, got ${JSON.stringify(t.version)}`);if(t.status!=="frozen")throw new P(`status must be "frozen", got ${JSON.stringify(t.status)}`);if(!t.frozenAt)throw new P("frozenAt is required");if(!t.source?.orgId||!t.source.decisionDate)throw new P("source.orgId and source.decisionDate are required");if(!Se.test(t.saltFingerprint))throw new P("saltFingerprint must be 12 lowercase hex chars of the salt SHA-256");if(!ue.test(t.rulesVersion))throw new P(`rulesVersion must be semver, got ${JSON.stringify(t.rulesVersion)}`);if(typeof t.volumetry?.budgetMax!="number"||!t.volumetry.measured)throw new P("volumetry.budgetMax and volumetry.measured are required");if(!t.controls?.nonReidentification)throw new P("controls.nonReidentification is required");if(!t.controls.author||!t.controls.date)throw new P("controls.author and controls.date are required");let e=t.coverage;if(e!==void 0&&(typeof e.objects!="number"||typeof e.truncated!="boolean"||typeof e.maxNodes!="number"||!Array.isArray(e.unboundedObjects)||!Array.isArray(e.filesLeftOut)||e.leftToThePlatform!==void 0&&!Array.isArray(e.leftToThePlatform)||e.exclusionCosts!==void 0&&!Array.isArray(e.exclusionCosts)||e.requiredLeftEmpty!==void 0&&!Array.isArray(e.requiredLeftEmpty)||e.keptWithoutARule!==void 0&&!Array.isArray(e.keptWithoutARule)||e.encryptedNotKept!==void 0&&!Array.isArray(e.encryptedNotKept)))throw new P("coverage, when present, needs objects, truncated, maxNodes, unboundedObjects and filesLeftOut, and a list of what it left to the platform, of what its exclusions cost, of the required fields the rules leave empty, of the fields kept without a rule, or of the encrypted fields not kept, if it names any")}function pe(t){return W(t),`${JSON.stringify(t,null,2)}
8
+ `}function st(t){if(typeof t!="object"||t===null||Array.isArray(t))throw new P("Manifest must be a JSON object");let e=t;return W(e),e}var V="platform-records.json",G=class extends Error{constructor(e){let r=e.checks.filter(n=>!n.passed).map(n=>`${n.name} (${n.violations.length} violation(s))`).join(", ");super(`Refusing to write the frozen dataset: non-reidentification control FAILED [${r}]. A FAIL means nothing is written or versioned.`),this.name="ControlNotPassedError"}},ge=class{guard;constructor(e){this.guard=e??new k}async write(e,r,n,i){if(!i.passed)throw new G(i);let o=this.guard.assertOutsideRepo(e),s=this.guard.assertOutsideRepo(O.join(o,"data"));await I.mkdir(s,{recursive:!0});for(let l of await I.readdir(s))l.endsWith(".json")&&await I.rm(this.guard.assertOutsideRepo(O.join(s,l)));let a=[],d=async(l,p)=>{let g=this.guard.assertOutsideRepo(l);await I.writeFile(g,`${JSON.stringify(p)}
9
+ `,"utf8"),a.push(g)},c=this.guard.assertOutsideRepo(O.join(o,"manifest.json"));await I.writeFile(c,pe(n),"utf8"),a.push(c);for(let l of r.objects)await d(O.join(s,`${l.objectApiName}.json`),{objectApiName:l.objectApiName,records:l.records});return await d(O.join(o,"record-types.json"),r.recordTypes),await d(O.join(o,"personcontact-sidecar.json"),r.personContactSidecar),await d(O.join(o,V),{...r.standardPricebook?{standardPricebook:r.standardPricebook}:{}}),{dir:o,files:a}}};var K="manifest.json",Fe=["record-types.json","personcontact-sidecar.json",V],Z="data",Ee="sha256:";async function gt(t){let e=await H(M.join(t,K));if(e===void 0)throw new Error(`No frozen dataset at ${t}: it holds no ${K}.`);let r=[{name:K,content:ke(e)}];for(let i of Fe){let o=await H(M.join(t,i));o!==void 0&&r.push({name:i,content:o})}for(let i of await xe(M.join(t,Z))){let o=await H(M.join(t,Z,i));o!==void 0&&r.push({name:`${Z}/${i}`,content:o})}let n=fe("sha256");for(let{name:i,content:o}of r.sort((s,a)=>me(s.name,a.name)))n.update(`${i}\0${fe("sha256").update(o).digest("hex")}
10
+ `);return`${Ee}${n.digest("hex")}`}async function xe(t){let e;try{e=await C.readdir(t)}catch(r){if(r.code==="ENOENT")return[];throw r}return e.filter(r=>r.endsWith(".json"))}async function H(t){try{return await C.readFile(t)}catch(e){if(e.code==="ENOENT")return;throw e}}function ke(t){let e;try{e=JSON.parse(t.toString("utf8"))}catch{return t}if(Y(e)&&Y(e.controls)){let r={...e.controls};delete r.dryRunLoad,e={...e,controls:r}}return Buffer.from(X(e),"utf8")}function X(t){return Array.isArray(t)?`[${t.map(X).join(",")}]`:Y(t)?`{${Object.keys(t).sort(me).map(r=>`${JSON.stringify(r)}:${X(t[r])}`).join(",")}}`:JSON.stringify(t)??"null"}function Y(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function me(t,e){return t===e?0:t<e?-1:1}import*as h from"node:fs/promises";import*as z from"node:path";var yt=4*1024*1024,wt=64*1024*1024;var he=1e4,L=u().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/),S=u().min(1).max(40),bt=m({forgeId:u().min(1).max(200),targetOrgId:u().min(1).max(128),timestamp:S,duration:f().nonnegative(),status:ae(["success","partial","failure"]),cancelled:D(!0).optional(),writtenBetween:m({first:S,last:S}).optional(),retryOf:u().min(1).max(200).optional(),objects:w(m({objectApiName:u().regex(/^[A-Za-z][A-Za-z0-9_]*$/),ids:w(L)})),linked:f().int().nonnegative(),mayHaveBeenWritten:f().int().nonnegative().optional(),undo:m({removedAt:S,deleted:f().int().nonnegative(),alreadyGone:f().int().nonnegative(),kept:f().int().nonnegative(),refused:f().int().nonnegative(),notReached:f().int().nonnegative().optional(),notVisible:f().int().nonnegative().optional()}).optional(),removalStamps:N(L,S).optional(),removalSpans:w(m({first:S,last:S,userId:L})).optional(),removalLeft:w(L).optional(),sweep:m({sweptAt:S,deleted:f().int().nonnegative(),keptChanged:f().int().nonnegative(),refused:f().int().nonnegative()}).optional(),inJournal:m({journalId:u().min(1).max(200),part:f().int().nonnegative(),left:w(m({objectApiName:u().regex(/^[A-Za-z][A-Za-z0-9_]*$/),count:f().int().nonnegative()}))}).optional()}),Rt=m({version:D(1),plans:w(ie())}),Pt=m({version:D(1),runs:w(m({forgeId:u().min(1).max(300),ids:w(L),late:w(L).optional()}))});var J="referenceid-mapping.json",Ne=/^referenceid-mapping\.([A-Za-z0-9_-]{1,128})\.json$/,Me=/^referenceid-mapping\.([A-Za-z0-9_-]{1,128})\.load-\d{1,16}\.ndjson$/,T=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,Q=new Set;function De(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var _e=m({at:u().min(1).max(40),object:u().regex(/^[A-Za-z][A-Za-z0-9_]{0,79}$/),created:w(se([u().min(1).max(400),u().regex(T)])).max(1e4)}),Ce=m({journal:m({startedAt:u().min(1).max(40),pid:f().int().positive(),runUserId:u().regex(T).optional()})});function Be(t){let e,r={},n=new Map,i;for(let o of t.split(`
11
+ `)){if(o.trim()==="")continue;let s;try{s=JSON.parse(o)}catch{continue}if(!e){let c=Ce.safeParse(s);c.success&&(e=c.data.journal);continue}let a=_e.safeParse(s);if(!a.success)continue;let d=n.get(a.data.object)??[];for(let[c,l]of a.data.created)Object.prototype.hasOwnProperty.call(r,c)||d.push(c),r[c]=l;n.set(a.data.object,d),i=a.data.at}if(!(!e||i===void 0||Object.keys(r).length===0))return{startedAt:e.startedAt,pid:e.pid,load:{updatedAt:i,mapping:r,created:[...n].filter(([,o])=>o.length>0).map(([o,s])=>({objectApiName:o,referenceIds:s})),load:{startedAt:e.startedAt,endedAt:i},...e.runUserId?{runUserId:e.runUserId}:{}}}}function Je(t){return`referenceid-mapping.${_(t)}.json`}async function B(t){let e;try{e=await h.readFile(t,"utf8")}catch(r){if(r.code==="ENOENT")return;throw r}return JSON.parse(e)}async function At(t,e){let r=e.assertOutsideRepo(t),n;try{n=await h.readdir(r)}catch(o){if(o.code==="ENOENT")return[];throw o}let i=new Set(n.flatMap(o=>Ne.exec(o)?.[1]??Me.exec(o)?.[1]??[]));if(n.includes(J)){let s=(await B(e.assertOutsideRepo(z.join(r,J))))?.orgId;typeof s=="string"&&$e(s)&&i.add(s)}return[...i].sort()}function $e(t){try{return _(t),!0}catch{return!1}}var Ue=w(m({objectApiName:u(),referenceIds:w(u())})),qe=m({startedAt:u(),endedAt:u()}),We=m({first:u(),last:u()}),Ge=m({removedAt:u(),deleted:f(),alreadyGone:f(),kept:f(),refused:f(),notReached:f().optional()}),Ve=N(u(),u()),Ke=w(m({first:u(),last:u(),userId:u()})),ye=N(u(),u()),ee=u().regex(T);function v(t,e){let r=t.safeParse(e);return r.success?r.data:void 0}function A(t){if(typeof t!="object"||t===null)return;let e=t,r=typeof e.mapping=="object"&&e.mapping!==null?Object.fromEntries(Object.entries(e.mapping).filter(y=>typeof y[1]=="string")):{},n=v(Ue,e.created),i=v(qe,e.load),o=v(We,e.writtenBetween),s=v(Ge,e.removal),a=v(Ve,e.removalStamps),d=v(Ke,e.removalSpans),c=v(ye,e.personContacts),l=v(ye,e.withTheirRecord),p=v(ee,e.runUserId),g=v(w(ee),e.madeEarlier),R=v(w(ee),e.lateEarlier);return{updatedAt:typeof e.updatedAt=="string"?e.updatedAt:"",mapping:r,...n?{created:n}:{},...i?{load:i}:{},...o?{writtenBetween:o}:{},...s?{removal:s}:{},...a?{removalStamps:a}:{},...d?{removalSpans:d}:{},...c?{personContacts:c}:{},...l?{withTheirRecord:l}:{},...p?{runUserId:p}:{},...g?{madeEarlier:g}:{},...R?{lateEarlier:R}:{}}}function F(t){return Array.isArray(t.earlier)?t.earlier.flatMap(e=>A(e)??[]):[]}function E(t){return t.load?.endedAt??t.updatedAt}function Ze(t,e){return t.slice(0,15)===e.slice(0,15)}function j(t){return t.slice(0,15)}function we(t,e){let r={};for(let[n,i]of Object.entries(t??{}))Object.prototype.hasOwnProperty.call(e,i)?Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=i):delete e[n];return r}function be(t,e){if(e.size===0)return t;let r=Object.fromEntries(Object.entries(t.mapping).filter(([,d])=>!e.has(j(d)))),n=we(t.personContacts,r),i=we(t.withTheirRecord,r),o=t.created?.map(({objectApiName:d,referenceIds:c})=>({objectApiName:d,referenceIds:c.filter(l=>Object.prototype.hasOwnProperty.call(r,l))})).filter(d=>d.referenceIds.length>0),s=Object.fromEntries(Object.entries(t.removalStamps??{}).filter(([d])=>!e.has(j(d)))),a={...t,mapping:r};return delete a.removalStamps,delete a.personContacts,delete a.withTheirRecord,{...a,...o?{created:o}:{},...Object.keys(s).length>0?{removalStamps:s}:{},...Object.keys(n).length>0?{personContacts:n}:{},...Object.keys(i).length>0?{withTheirRecord:i}:{}}}function Re(t){return t.created?t.created.some(e=>e.referenceIds.length>0):Object.keys(t.mapping).length>0}var Pe=class{constructor(e,r){this.sasDir=e;this.guard=r?.guard??new k,this.orgId=r?.orgId??"";let n=r?.organizationId;this.askOrganizationId=typeof n=="function"?n:async()=>n,this.now=r?.now??(()=>new Date)}sasDir;guard;orgId;askOrganizationId;organizationId;now;get filePath(){return this.guard.assertOutsideRepo(z.join(this.sasDir,this.orgId===""?J:Je(this.orgId)))}get singleFilePath(){return this.orgId===""?void 0:this.guard.assertOutsideRepo(z.join(this.sasDir,J))}get journalStem(){return this.orgId===""?"referenceid-mapping":`referenceid-mapping.${_(this.orgId)}`}journalPath(e){let r=typeof e=="string"?Date.parse(e):e.getTime();return this.guard.assertOutsideRepo(z.join(this.sasDir,`${this.journalStem}.load-${Math.max(0,Math.trunc(r))}.ndjson`))}retiring=new Map;journal(e){let r=this.journalPath(e),n=!1,i=!1,o=!1,s,a=Promise.resolve(),d;Q.add(r);let c=p=>{a=a.then(async()=>{if(!(d!==void 0||i))try{if(!n){n=!0,await h.mkdir(z.dirname(r),{recursive:!0});let g={journal:{startedAt:e.toISOString(),pid:process.pid,...s?{runUserId:s}:{}}};await h.appendFile(r,`${JSON.stringify(g)}
12
+ `,"utf8")}await h.appendFile(r,`${JSON.stringify(p)}
13
+ `,"utf8")}catch(g){d=g instanceof Error?g.message:String(g)}})},l=async()=>{await a,i=!0,await h.rm(r,{force:!0})};return this.retiring.set(r,l),{writtenAs:p=>{T.test(p)&&(s=p)},created:(p,g)=>{let R=g.filter(([y,x])=>y!==""&&T.test(x));if(R.length!==0){o=!0;for(let y=0;y<R.length;y+=1e4)c({at:this.now().toISOString(),object:p,created:R.slice(y,y+1e4)})}},flush:async()=>(await a,d),close:async()=>{await a,this.retiring.delete(r),(i||!o)&&await h.rm(r,{force:!0}),i=!0,Q.delete(r)}}}async stoppedLoads(e){let r;try{r=await h.readdir(this.guard.assertOutsideRepo(this.sasDir))}catch(s){if(s.code==="ENOENT")return[];throw s}let n=`${this.journalStem}.load-`,i=new Set(e.flatMap(s=>s.load?[s.load.startedAt]:[])),o=[];for(let s of r){if(!s.startsWith(n)||!/^\d{1,16}\.ndjson$/.test(s.slice(n.length)))continue;let a=this.guard.assertOutsideRepo(z.join(this.sasDir,s));if(Q.has(a))continue;let d;try{d=await h.readFile(a,"utf8")}catch{continue}let c=Be(d);!c||i.has(c.startedAt)||c.pid!==process.pid&&De(c.pid)||o.push({file:a,load:c.load})}return o}async load(){let e=await this.read();return e===void 0||await this.writtenToAnotherOrg(e)?new Map:new Map(Object.entries(e.mapping??{}))}async previousLoads(){let e=await this.read();if(e===void 0||await this.writtenToAnotherOrg(e))return[];let r=A(e);return[...r?[r]:[],...F(e)].map(n=>({mapping:new Map(Object.entries(n.mapping)),...n.created?{created:n.created}:{},...n.writtenBetween?{writtenBetween:n.writtenBetween}:{},endedAt:E(n),...n.removalStamps?{removalStamps:n.removalStamps}:{}}))}async recorded(){return(await this.recordedLoads())[0]}async recordedLoads(){let e=await this.read();if(e===void 0)return[];let r=typeof e.orgId=="string"?e.orgId:"",n=A(e);return[...n?[this.recordedOf(n,r)]:[],...F(e).map(i=>({...this.recordedOf(i,r),earlier:!0}))]}recordedOf(e,r){return{orgId:r,mapping:new Map(Object.entries(e.mapping)),...e.created?{created:e.created}:{},...e.load?{startedAt:e.load.startedAt}:{},endedAt:E(e),...e.writtenBetween?{writtenBetween:e.writtenBetween}:{},...e.removal?{removal:e.removal}:{},removalStamps:e.removalStamps??{},removalSpans:e.removalSpans??[],...e.personContacts?{personContacts:e.personContacts}:{},...e.withTheirRecord?{withTheirRecord:e.withTheirRecord}:{},...e.runUserId?{runUserId:e.runUserId}:{},...e.madeEarlier?{madeEarlier:e.madeEarlier}:{},...e.lateEarlier?{lateEarlier:e.lateEarlier}:{}}}async isStale(){let e=await this.read();return e!==void 0&&await this.writtenToAnotherOrg(e)}async writtenToAnotherOrg(e){let r=e.organizationId;if(r===void 0)return!1;let n=await this.currentOrganizationId();return n!==void 0&&!Ze(r,n)}currentOrganizationId(){return this.organizationId??=this.askOrganizationId(),this.organizationId}async read(){return(await this.readWithJournals()).payload}async readFile(){let e=await B(this.filePath);if(e!==void 0)return e;let r=this.singleFilePath;if(r===void 0)return;let n=await B(r);return n?.orgId===this.orgId?n:void 0}async readWithJournals(){let e=await this.readFile(),r=e?[A(e),...F(e)]:[],n=await this.stoppedLoads(r.filter(a=>a!==void 0));if(n.length===0)return{payload:e,journals:[]};let i=[...r.filter(a=>a!==void 0),...n.map(({load:a})=>a)].sort((a,d)=>Date.parse(E(d))-Date.parse(E(a))),[o,...s]=i;return{payload:{version:1,orgId:typeof e?.orgId=="string"?e.orgId:this.orgId,...e?.organizationId!==void 0?{organizationId:e.organizationId}:{},...o,...s.length>0?{earlier:s}:{}},journals:n.map(({file:a})=>a)}}async dropJournals(e){for(let r of e)await h.rm(r,{force:!0}).catch(()=>{})}async write(e){let r=this.filePath;await h.mkdir(z.dirname(r),{recursive:!0}),await h.writeFile(r,`${JSON.stringify(e,null,2)}
14
+ `,"utf8");let n=this.singleFilePath;if(n!==void 0)try{(await B(n))?.orgId===this.orgId&&await h.rm(n)}catch{}}async keptLoads(e,r,n=[]){if(e===void 0||e.orgId!==this.orgId)return[];if(await this.writtenToAnotherOrg(e))return[];let i=new Set(r.map(j)),o=new Set(n),s=A(e);return[...s?[s]:[],...F(e)].map(a=>be(a,i)).filter(a=>Re(a)||o.has(E(a)))}async persist(e,r){let{payload:n,journals:i}=await this.readWithJournals(),o=r?.earlier?await this.keptLoads(n,r.earlier.settled,r.earlier.stillToSweep):[],s=await this.currentOrganizationId(),a=this.now().toISOString(),d=p=>Object.fromEntries(Object.entries(p??{}).filter(([g,R])=>e.has(g)&&e.has(R))),c=d(r?.personContacts),l=d(r?.withTheirRecord);if(await this.write({version:1,orgId:this.orgId,...s!==void 0?{organizationId:s}:{},updatedAt:a,mapping:Object.fromEntries([...e.entries()].sort(([p],[g])=>p.localeCompare(g))),...r?{created:r.created.map(({objectApiName:p,referenceIds:g})=>({objectApiName:p,referenceIds:g.filter(R=>e.has(R))})).filter(p=>p.referenceIds.length>0),load:{startedAt:r.startedAt.toISOString(),endedAt:a},...r.writtenBetween?{writtenBetween:{...r.writtenBetween}}:{},...Object.keys(c).length>0?{personContacts:c}:{},...Object.keys(l).length>0?{withTheirRecord:l}:{},...r.runUserId?{runUserId:r.runUserId}:{}}:{},...o.length>0?{earlier:o}:{}}),r?.earlier&&await this.dropJournals(i),r){let p=this.journalPath(r.startedAt),g=this.retiring.get(p);g?await g():await h.rm(p,{force:!0}).catch(()=>{})}}async recordRemoval(e,r){let{payload:n,journals:i}=await this.readWithJournals(),o=A(n);if(n===void 0||o===void 0)return!1;let s=[o,...F(n)],a=s.findIndex(p=>E(p)===e);if(a<0)return!1;let d=new Set(r.gone.map(j)),[c,...l]=s.map((p,g)=>be(g===a?Xe(p,r):p,d));return await this.write({version:1,orgId:typeof n.orgId=="string"?n.orgId:"",...n.organizationId!==void 0?{organizationId:n.organizationId}:{},...c,updatedAt:this.now().toISOString(),...l.length>0?{earlier:l}:{}}),await this.dropJournals(i),!0}async recordMade(e,r,n=[],i=[]){let{payload:o,journals:s}=await this.readWithJournals(),a=A(o);if(o===void 0||a===void 0)return!1;let d=[a,...F(o)],c=d.findIndex(y=>E(y)===e);if(c<0)return!1;let l=[...i],p=y=>{let x=ve(y.madeEarlier,r,l),oe=ve(y.lateEarlier,n,l),$={...y};return delete $.madeEarlier,delete $.lateEarlier,{...$,...x.length>0?{madeEarlier:x}:{},...oe.length>0?{lateEarlier:oe}:{}}},[g,...R]=d.map((y,x)=>x===c?p(y):y);return await this.write({version:1,orgId:typeof o.orgId=="string"?o.orgId:"",...o.organizationId!==void 0?{organizationId:o.organizationId}:{},...g,...R.length>0?{earlier:R}:{}}),await this.dropJournals(s),!0}async letSweptGo(e){if(e.length===0)return!1;let{payload:r,journals:n}=await this.readWithJournals(),i=A(r);if(r===void 0||i===void 0)return!1;let o=new Set(e),s=F(r),a=s.filter(d=>Re(d)||!o.has(E(d)));return a.length===s.length?!1:(await this.write({version:1,orgId:typeof r.orgId=="string"?r.orgId:"",...r.organizationId!==void 0?{organizationId:r.organizationId}:{},...i,...a.length>0?{earlier:a}:{}}),await this.dropJournals(n),!0)}async recordStamps(e){let{payload:r,journals:n}=await this.readWithJournals(),i=A(r);if(r===void 0||i===void 0)return!1;let o=[i,...F(r)],s=o.map(c=>He(c,e));if(s.every((c,l)=>c===o[l]))return!1;let[a,...d]=s;return await this.write({version:1,orgId:typeof r.orgId=="string"?r.orgId:"",...r.organizationId!==void 0?{organizationId:r.organizationId}:{},...a,...d.length>0?{earlier:d}:{}}),await this.dropJournals(n),!0}};function ve(t,e,r=[]){let n=new Map,i=new Set(r.map(j)),o=[];for(let s of[...t??[],...e]){let a=j(s),d=a.slice(0,3),c=n.get(d)??0;!T.test(s)||i.has(a)||c>=he||(i.add(a),n.set(d,c+1),o.push(s))}return o}function He(t,e){let r=new Set(Object.values(t.mapping).map(j)),n=Object.entries(e).filter(([o])=>r.has(j(o)));if(n.length===0)return t;let i=new Set(n.map(([o])=>j(o)));return{...t,removalStamps:{...Object.fromEntries(Object.entries(t.removalStamps??{}).filter(([o])=>!i.has(j(o)))),...Object.fromEntries(n)}}}function Xe(t,e){let r={...t.removalStamps,...e.stamps},n=[...t.removalSpans??[],...e.span?[e.span]:[]],i=e.mark??t.removal;return{...t,...i?{removal:i}:{},...Object.keys(r).length>0?{removalStamps:r}:{},...n.length>0?{removalSpans:n}:{}}}var je={BusinessHours:["Name"]},Ot=["DUPLICATE_VALUE","DUPLICATES_DETECTED","duplicate value found"];var Ye=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,Qe=/^[A-Za-z][A-Za-z0-9_]*$/;function te(t){return t.slice(0,15)}function re(t,e){let r=t.mapping.get(e);return typeof r=="string"&&Ye.test(r)?r:void 0}function Ie(t){let e=new Set((t.created??[]).flatMap(n=>n.referenceIds)),r=new Set;for(let n of t.mapping.keys()){if(e.has(n))continue;let i=re(t,n);i&&r.add(te(i))}return r}function et(t){let e=new Set((t.created??[]).flatMap(i=>i.referenceIds)),r=[...Object.entries(t.personContacts??{}),...Object.entries(t.withTheirRecord??{})];for(let i=!0;i;){i=!1;for(let[o,s]of r)e.has(o)||!e.has(s)||(e.add(o),i=!0)}let n=new Set;for(let[i]of r){let o=e.has(i)?re(t,i):void 0;o&&n.add(te(o))}return n}function Ae(t){let e=Ie(t),r=new Map;for(let{objectApiName:o,referenceIds:s}of t.created??[])Qe.test(o)&&r.set(o,[...r.get(o)??[],...s]);let n=new Set,i=[];for(let[o,s]of[...r].reverse()){let a=[];for(let d of[...s].reverse()){let c=re(t,d);if(!c)continue;let l=te(c);e.has(l)||n.has(l)||(n.add(l),a.push(c))}a.length>0&&i.push({objectApiName:o,ids:a})}return i}function ne(t){return de(t.removal)?[]:Ae(t).filter(e=>!ze(e.objectApiName))}function ze(t){return Object.prototype.hasOwnProperty.call(je,t)}function tt(t){return Ae(t).filter(e=>ze(e.objectApiName)).map(({objectApiName:e,ids:r})=>({objectApiName:e,count:r.length}))}function xt(t){return t.find(e=>ne(e).length>0)??t[0]}function kt(t,e){return t.filter(r=>r.endedAt!==e.endedAt&&r.created!==void 0&&ne(r).length===0)}function Lt(t){let e=t.created!==void 0,r=et(t),n=[...Ie(t)].filter(o=>!r.has(o)),i=tt(t);return{orgId:t.orgId,loadedAt:t.endedAt,created:ne(t).map(({objectApiName:o,ids:s})=>({objectApiName:o,count:s.length})),linked:e?n.length:0,recorded:e,...t.removal?{removed:t.removal}:{},...t.earlier?{earlier:!0}:{},...i.length>0?{keptByThePlatform:i}:{}}}export{Oe as a,_ as b,q as c,k as d,ot as e,it as f,pe as g,st as h,V as i,ge as j,gt as k,je as l,Ot as m,Je as n,At as o,Pe as p,Ae as q,ne as r,tt as s,xt as t,kt as u,Lt as v};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r}from"./chunk-NZC67CGR.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{p as actDeliverability,o as actEmailsGate,n as actSendersOf,q as afterLeaseEmailsRefusal,l as checkpointEmails,j as checkpointEmailsUncounted,c as draftedByDiff,d as draftedByPlan,a as emailsOfLimit,m as emailsRefusal,k as emailsUncountedWords,r as pageEmailsRefusal,e as statusBackByDiff,f as statusBackByPlan,b as updatedByDiff,g as writtenByDiff,h as writtenByPlan,i as writtenByUndo};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{Bd as c}from"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";var y=[{type:"seed",label:"Seed Data",description:"Seed an org with a template saved on the Seed page or shipped with SandForge, never a production org; its records are taken back from Seed\u2019s Recent runs",category:"data",icon:"database",configSchema:{orgId:{type:"string"},templateId:{type:"string"}}},{type:"sync",label:"Sync Data",description:"Run a Sync configuration saved on the Sync page; a target Production Guard asks about, a production org or a sandbox marked Staging, needs an Approval step before it",category:"data",icon:"sync",configSchema:{configId:{type:"string"}}},{type:"backup",label:"Backup",description:"Take a DataOps snapshot of the listed objects into local storage",category:"data",icon:"archive",configSchema:{orgId:{type:"string"},objects:{type:"array"}}},{type:"restore",label:"Restore",description:"Restore data from a previous backup snapshot",category:"data",icon:"history",configSchema:{backupId:{type:"string"}}},{type:"anonymize",label:"Anonymize",description:"Mask an org with a DataOps template, after a snapshot of the values it writes over, never a production org",category:"data",icon:"shield",configSchema:{orgId:{type:"string"},templateId:{type:"string"},object:{type:"string",optional:!0},where:{type:"string",optional:!0},acceptAutomation:{type:"boolean",default:!1},acceptEmails:{type:"boolean",default:!1},muteAutomation:{type:"boolean",default:!1}}},{type:"delete",label:"Delete",description:"Delete records matching specified criteria",category:"data",icon:"trash",configSchema:{objectName:{type:"string"},where:{type:"string"}}},{type:"checkpoint",label:"Checkpoint",description:"Take a checkpoint of a sandbox, a scratch org or a Developer Edition org, kept on this machine",category:"data",icon:"bookmark",configSchema:{orgId:{type:"string"},mode:{type:"string",default:"everything"},objects:{type:"array",optional:!0},excluded:{type:"array",optional:!0},name:{type:"string",optional:!0},keepDays:{type:"number",default:c},maxTotal:{type:"number",optional:!0},ignoredFields:{type:"array",optional:!0}}},{type:"rewind",label:"Rewind",description:"Put an org back to a checkpoint kept on this machine, once confirmed by typing the org\u2019s alias, at most maxRecords records",category:"data",icon:"history",configSchema:{orgId:{type:"string"},checkpointId:{type:"string"},objects:{type:"array",optional:!0},acceptAutomation:{type:"boolean",default:!1},acceptEmails:{type:"boolean",default:!1},muteAutomation:{type:"boolean",default:!1},acceptNoUndo:{type:"boolean",default:!1},acceptRecreate:{type:"boolean",default:!1},acceptOutside:{type:"boolean",default:!1},acceptUnseen:{type:"boolean",default:!1},maxRecords:{type:"number",required:!0},refuseWhenActive:{type:"boolean",default:!0}}},{type:"compare",label:"Compare Orgs",description:"Compare the metadata of two orgs, as the Compare page does",category:"quality",icon:"git-compare",configSchema:{sourceOrgId:{type:"string"},targetOrgId:{type:"string"},types:{type:"array"}}},{type:"precheck",label:"Pre-check",description:"Read an org\u2019s API usage, storage, error logs or failed jobs as the Monitor does; the run stops on a critical reading",category:"quality",icon:"check-circle",configSchema:{orgId:{type:"string"},checks:{type:"array"}}},{type:"condition",label:"Condition",description:"Branch pipeline execution based on conditions",category:"control",icon:"git-branch",configSchema:{field:{type:"string"},operator:{type:"string"},value:{type:"string"}}},{type:"delay",label:"Delay",description:"Wait for a specified duration before continuing",category:"control",icon:"clock",configSchema:{durationMs:{type:"number"}}},{type:"approval",label:"Approval",description:"Pauses the run until someone approves it in VS Code; a rejection, or no answer in time, stops it",category:"control",icon:"user-check",configSchema:{message:{type:"string"},timeoutMinutes:{type:"number"}}},{type:"notification",label:"Notification",description:"Shows its message as a VS Code notification",category:"notification",icon:"bell",configSchema:{message:{type:"string"}}}],p=class{registry;constructor(){this.registry=new Map(y.map(e=>[e.type,e]))}getStepTypes(){return[...this.registry.values()]}getStepType(e){return this.registry.get(e)}getDefaultConfig(e){let r=this.registry.get(e);if(!r)return{};let o={};for(let[t,a]of Object.entries(r.configSchema)){let n=a;if(!(n.optional===!0||n.required===!0)){if("default"in n){o[t]=n.default;continue}switch(n.type){case"string":o[t]="";break;case"number":o[t]=0;break;case"array":o[t]=[];break;case"boolean":o[t]=!1;break;default:o[t]=null}}}return o}validateStepConfig(e,r){let o=this.registry.get(e);if(!o)return[`Unknown step type: ${e}`];let t=[];for(let[a,n]of Object.entries(o.configSchema)){let l=n,i=r[a],s=l.type;i!=null&&(s==="array"&&!Array.isArray(i)?t.push(`Field "${a}" must be an array`):s==="string"&&typeof i!="string"?t.push(`Field "${a}" must be a string`):s==="number"&&typeof i!="number"?t.push(`Field "${a}" must be a number`):s==="boolean"&&typeof i!="boolean"&&t.push(`Field "${a}" must be a boolean`))}return t}getStepCategories(){let e=new Set;for(let r of this.registry.values())e.add(r.category);return[...e]}};export{p as StepLibrary};
@@ -0,0 +1,37 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{d as s}from"./chunk-AV5SWEHP.mjs";var i=["--accept-automation","--accept-emails","--mute-automation"];function n(t){return{...t.includes("--accept-automation")?{acceptAutomation:!0}:{},...t.includes("--accept-emails")?{acceptEmails:!0}:{},...t.includes("--mute-automation")?{muteAutomation:!0}:{}}}function r(t,e){let a=e?`exit 1; with ${e}, says what
8
+ would be muted and assigns nothing`:"exit 1";return` --accept-automation write although the org runs flows, Apex triggers,
9
+ processes or workflow rules as the records are
10
+ ${t}, or could not say what it runs:
11
+ AUTOMATION_NOT_ACCEPTED, exit 1, nothing written,
12
+ without it. What fires is said first, object by object.
13
+ An org the network did not reach as what it runs was
14
+ read refuses whatever is accepted:
15
+ ORG_TEMPORARILY_UNREACHABLE, exit 1, to be tried again
16
+ --accept-emails write although the org delivers every email of what
17
+ still runs as the records are ${t}, or would
18
+ not say whether it does: EMAILS_NOT_ACCEPTED, exit 1,
19
+ without it; --accept-automation never stands for it.
20
+ Asked only when what still runs sends one. Whether the
21
+ org delivers them is read with one line of anonymous
22
+ Apex that sends nothing
23
+ (Messaging.reserveSingleEmailCapacity(1)), never in a
24
+ production org; what an Apex trigger sends is read
25
+ nowhere. The emails are counted against what the org
26
+ has left today: past it, EMAILS_EXCEEDED, exit 1,
27
+ whatever is accepted
28
+ --mute-automation mute the org's automation for the run through its own
29
+ bypass: assign the user it writes as, for the run
30
+ alone, the permission sets holding the custom
31
+ permissions its flows, processes and workflow rules
32
+ test to stay quiet, and take them back as it ends.
33
+ What no bypass keeps quiet still runs, is named, and
34
+ still needs --accept-automation. Refused on a
35
+ production org and for a user who cannot assign
36
+ permission sets, ${a}
37
+ `}function u(t){return t.refusals.map(e=>` ${s(e)}`)}export{i as a,n as b,r as c,u as d};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{b as W}from"./chunk-CA5NAXSU.mjs";import{b as I,e as z,l as F,u as U}from"./chunk-7EANH5PY.mjs";function p(n){return`${n.op}\0${n.objectApiName}`}var j=class{entries=new Map;keys=new Map;of(t){let e=this.entries.get(p(t));return!e||e.spent?200:e.size}wasRefused(t){return this.entries.has(p(t))}wasCut(t){let e=this.entries.get(p(t));return e!==void 0&&e.size<200}firstRefusal(t,e,r){if(this.entries.has(p(t)))return;let o=this.entry(t,e);o.limit=r?.limit,o.automation=r?.automation,o.event=r?.event}refusedAt(t,e,r){this.firstRefusal(t,e,r);let o=this.entry(t,e);return o.size=Math.min(o.size,Math.max(1,Math.ceil(e/2))),this.of(t)}probes(t){return this.entries.get(p(t))?.probes??0}probed(t){let e=this.entries.get(p(t));e&&e.probes++}keepWhole(t){let e=this.entries.get(p(t));e&&(e.wholeAlone=!0)}isKeptWhole(t){return this.entries.get(p(t))?.wholeAlone===!0}spend(t){let e=this.entries.get(p(t));e&&(e.spent=!0)}isSpent(t){return this.entries.get(p(t))?.spent===!0}countExtraCalls(t,e){let r=this.entries.get(p(t));r&&e>0&&(r.extraCalls+=e)}countSmallCallRows(t,e){let r=this.entries.get(p(t));r&&e>0&&(r.rows+=e)}countNoted(t,e,r=1){let o=this.entries.get(p(t));!o||r<=0||(e===T?o.alone+=r:e===L?o.notSplit+=r:o.keptWhole+=r)}report(t){let e=this.entries.get(p(t));if(e)return{objectApiName:t.objectApiName,op:t.op,from:e.from,to:e.size,rows:e.rows,extraCalls:e.extraCalls,...e.limit!==void 0?{limit:e.limit}:{},...e.automation!==void 0?{automation:e.automation}:{},...e.event!==void 0?{event:e.event}:{},alone:e.alone,notSplit:e.notSplit,keptWhole:e.keptWhole,wholeAlone:e.wholeAlone,spent:e.spent}}reports(t){let e=[];for(let r of this.keys.values()){if(t!==void 0&&r.op!==t)continue;let o=this.report(r);o&&e.push(o)}return e}entry(t,e){let r=p(t),o=this.entries.get(r);return o||(o={size:200,from:e,spent:!1,wholeAlone:!1,probes:0,rows:0,extraCalls:0,alone:0,notSplit:0,keptWhole:0},this.entries.set(r,o),this.keys.set(r,{objectApiName:t.objectApiName,op:t.op})),o}};function E(n){return Math.max(0,Math.floor(Number.isFinite(n)?n:0))}var J=class{grantedCalls;perObject;takenInAll=0;byObject=new Map;constructor(t=2e3,e=500){this.grantedCalls=E(t),this.perObject=E(e)}get granted(){return this.grantedCalls}limitTo(t){this.grantedCalls=Math.min(this.grantedCalls,E(t))}left(t){let e=this.byObject.get(t.objectApiName)??0;return Math.max(0,Math.min(this.grantedCalls-this.takenInAll,this.perObject-e))}take(t,e){let r=Math.max(0,Math.min(Math.floor(e),this.left(t)));return r>0&&(this.takenInAll+=r,this.byObject.set(t.objectApiName,(this.byObject.get(t.objectApiName)??0)+r)),r}get spent(){return this.takenInAll}taken(t){return this.byObject.get(t.objectApiName)??0}};function se(n=2e3){return{sizes:new j,allowance:new J(n)}}function D(n,t){let e=Math.floor((n-t)/2);return Number.isFinite(e)?Math.min(2e3,Math.max(0,e)):0}function oe(n){return n.remaining===void 0?{}:{splitAllowance:D(n.remaining,n.estimate)}}function N(n,t,e,r){if(r<=0||n.isSpent(e))return 0;let o=t.take(e,r);return n.countExtraCalls(e,o),o<r&&n.spend(e),o}var T="alone",L="notSplit",v="keptWhole",Q="Sent on its own, the record still made the target's automation hit a Salesforce limit: the automation does too much for this record alone \u2014 fix it, or have it honour the bypass Forge's automation mute sets.",V="Not sent in smaller calls: records of the same object sent on their own were refused for a Salesforce limit too, so a smaller call would not take it \u2014 fix the target's automation, or have it honour the bypass Forge's automation mute sets.";function B(n,t){return n>0?`the ${t} had spent the ${n} smaller calls it allows itself`:`what the org has left today allowed the ${t} none`}function q(n,t="run"){return`Not sent in smaller calls: ${B(n,t)}.`}function ie(n,t,e="run"){return n===T?Q:n===v?V:q(t,e)}function M(n){return`${n} ${n===1?"call":"calls"} more`}function X(n){return`${n} ${n===1?"record":"records"}`}function Y(n){return n.automation===void 0?"The target's automation":n.event===void 0?n.automation:`${n.automation} (${n.event})`}function ae(n){let t=`${Y(n)} hit ${n.limit??"a Salesforce limit"} on a call of ${n.from}`;return n.wholeAlone?`${t}, and ${X(n.alone)} sent on ${n.alone===1?"its":"their"} own were refused too: not sent in smaller calls, ${M(n.extraCalls)}.`:n.to<200&&n.rows>0?`${t}: sent ${n.to} at a time, ${M(n.extraCalls)}.`:n.extraCalls>0?`${t}: ${M(n.extraCalls)}.`:`${t}.`}function le(n,t,e="run"){return`${n} not sent in smaller calls: ${B(t,e)}.`}function ue(n,t){let e=n.perObject-n.taken(t),r=n.granted-n.spent;return e<r?n.perObject:n.granted}function ee(n,t,e=200){return n<=t?!1:Math.ceil(n/e)===Math.ceil((n-t)/e)}var te=new Set;async function ce(n,t){let{key:e,sizes:r,allowance:o}=t,c=Math.min(t.maxSize??200,200),h=[],m,f=0,S=()=>[...h.flatMap(s=>s.items),...m?.items??[],...n.slice(f)],K=()=>{let s=Math.min(c,r.of(e)),l=s<c,g=t.pricedAs==="job"||ee(n.length-f,s,c);l&&g&&(t.paid&&t.paid.calls>0?t.paid.calls--:N(r,o,e,1)===0&&(s=c,l=!1));let i=n.slice(f,f+s);return f+=i.length,{items:i,reduced:l}},A=async s=>{let l=m;if(m=void 0,!l||l.items.length===0)return;r.countNoted(e,s,l.items.length);let g=new Map(l.items.map((i,d)=>[d,s]));try{await t.settle(l.items,l.answers,te,g,!0)}catch(i){throw t.onThrow?.(S(),i),i}},k=async()=>{let s=m;if(!s)return;if(s.items.length===0){m=void 0;return}let l=r.refusedAt(e,s.from,s.cause),g=N(r,o,e,Math.ceil(s.items.length/l)),i=Math.min(s.items.length,g*l),d=[];for(let b=0;b<i;b+=l)d.push({items:s.items.slice(b,Math.min(i,b+l)),reduced:!0});h.unshift(...d),m={...s,items:s.items.slice(i),answers:s.answers.slice(i)},await A(L)},_=async()=>{let s=m;if(!s||s.items.length===0){m=void 0;return}if(N(r,o,e,1)===0){await A(L);return}r.probed(e),h.unshift({items:[s.items[0]],reduced:!0,probe:!0}),m={...s,items:s.items.slice(1),answers:s.answers.slice(1)}},P=!0,w=t.refusedIn;if(w&&n.length>0){if(f=n.length,P=!1,!r.wasRefused(e)){r.firstRefusal(e,w.from,w.cause);let s=r.report(e);s&&t.onFirstRefusal?.(s)}m={items:[...n],answers:[...w.answers],from:w.from,...w.cause?{cause:w.cause}:{}},r.isSpent(e)?await A(L):r.isKeptWhole(e)?await A(v):!r.wasCut(e)&&r.probes(e)<2?await _():await k()}for(;;){let s;if(P){if(n.length===0)return{};s=K()}else{if(s=h.shift()??(f<n.length?K():void 0),!s)return{};try{if(await t.beforeEachSend?.()==="stop")return{stopped:{part:s.items,rest:S(),sent:!1}}}catch(u){throw t.onThrow?.([...s.items,...S()],u),u}}P=!1;let l;try{l=await t.send(s.items)}catch(u){throw t.onThrow?.([...s.items,...S()],u),u}if(l==="stop")return{stopped:{part:s.items,rest:S(),sent:!0}};let{answers:g}=l,i=s.items,d=[],b;for(let u=0;u<i.length;u++){let a=t.limited(g[u],i[u]);a&&(d.push(u),b??=a)}let R=new Set,C=new Map,x;if(s.probe)d.length>0?(C.set(0,T),x=r.probes(e)<2&&(m?.items.length??0)>0?_:async()=>{r.probes(e)>=2&&r.keepWhole(e),await A(v)}):x=k;else if(d.length>0){if(!r.wasRefused(e)){r.firstRefusal(e,i.length,b);let a=r.report(e);a&&t.onFirstRefusal?.(a)}let u=!r.wasCut(e)&&!r.isKeptWhole(e)&&r.probes(e)<2;if(i.length===1)C.set(0,T),u&&!r.isSpent(e)&&(r.probed(e),r.probes(e)>=2&&r.keepWhole(e));else if(r.isSpent(e))for(let a of d)C.set(a,L);else if(r.isKeptWhole(e))for(let a of d)C.set(a,v);else if(u){for(let a of d)R.add(a);m={items:d.map(a=>i[a]),answers:d.map(a=>g[a]),from:i.length,...b?{cause:b}:{}},x=_}else{let a=r.refusedAt(e,i.length,b),Z=N(r,o,e,Math.ceil(d.length/a)),O=d.slice(0,Z*a);for(let y of O)R.add(y);for(let y of d.slice(O.length))C.set(y,L);let $=[];for(let y=0;y<O.length;y+=a)$.push({items:O.slice(y,y+a).map(H=>i[H]),reduced:!0});h.unshift(...$)}}for(let u of C.values())r.countNoted(e,u);s.reduced&&r.countSmallCallRows(e,i.length-R.size);try{await t.settle(i,g,R,C)}catch(u){throw t.onThrow?.(S(),u),u}await x?.()}}var ne=60*6e4,re=F({state:U(["Open","UploadComplete","InProgress","JobComplete","Failed","Aborted"]),numberRecordsProcessed:z().int().nonnegative().optional(),errorMessage:I().nullish(),systemModstamp:I().optional(),createdDate:I().optional()});function G(n,t){let e=re.safeParse(t);if(e.success)return e.data;let r=typeof t=="object"&&t!==null&&"state"in t?String(JSON.stringify(t.state)):"none";throw new Error(`The org's answer about Bulk API job ${n||"(no id)"} is not an ingest job's state (state: ${r})`)}async function fe(n,t,e={}){let r=e.now??(()=>Date.now());try{let o=n.bulk2.job("ingest",{id:t}),c=G(t,await o.check());if(c.state==="Open"){let h=Date.parse(c.createdDate??""),m=e.openGraceMs??ne,f=m-(r()-h);if(Number.isFinite(h)&&f>0)return{state:"running",info:c,openUntil:new Date(h+m).toISOString(),graceLeftMs:f};if(!await o.abort().then(()=>!1,()=>!0)&&m>0)return{state:"never-closed"};if(c=G(t,await o.check()),c.state==="Open"||c.state==="Aborted"&&c.numberRecordsProcessed===0)return{state:"never-closed"}}if(c.state==="UploadComplete"||c.state==="InProgress")return{state:"running",info:c};if(e.successfulOnly)return{state:"ended",info:c,results:{successfulResults:[...await o.getSuccessfulResults()]}};if(o.getAllResults===void 0)throw new Error(`Bulk API job ${t}: this connection reads no failed or unprocessed rows`);return{state:"ended",info:c,results:await o.getAllResults()}}catch(o){return{state:"unread",reason:W(o)}}}export{se as a,D as b,oe as c,Q as d,V as e,ie as f,ae as g,le as h,ue as i,ce as j,G as k,fe as l};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ function r(n){return`npx sandforge ${n}`}function o(n){return n.replace(/^sandforge-(?=[a-z]+$)/,"sandforge ")}export{r as a,o as b};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a,b,c,d,e,f,g,h}from"./chunk-SOGQW4IG.mjs";import"./chunk-WR4Q363I.mjs";import"./chunk-O2HDYYUV.mjs";import"./chunk-M3ROUWDX.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{d as ARTICLE_OBJECT,b as CASE_STATUS_BY_LABEL_SOQL,a as CASE_STATUS_SOQL,g as prepareScenario,c as readScenarioCaseStatus,f as scenarioCasePicklists,e as scenarioKnowledge,h as toolingQueryAll};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{J as H}from"./chunk-JPUR2CFX.mjs";import{b as k,c as ie,d as $}from"./chunk-GSKCGQIP.mjs";import{i as oe}from"./chunk-INIT2UKJ.mjs";import{h as Y}from"./chunk-TZE3Y7IQ.mjs";import{b as S}from"./chunk-CA5NAXSU.mjs";var ye=5,pe=100;function y(t){return t.slice(0,15)}function L(t){return t==null||t===""}var ae=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;function he(t,n){if(L(t)||L(n))return L(t)&&L(n);if(typeof t=="number"||typeof n=="number")return Number(t)===Number(n);if(typeof t=="string"&&typeof n=="string"){if(t===n)return!0;if(ae.test(t)&&ae.test(n)){let a=Date.parse(t);return Number.isFinite(a)&&a===Date.parse(n)}return!1}return JSON.stringify(t)===JSON.stringify(n)}function me(t){let n;return()=>(n??=(async()=>{try{let a=await t.userId?.();return typeof a=="string"&&a!==""?y(a):void 0}catch{return}})(),n)}async function de(t){let n=Date.now();try{let a=Date.parse(await t.serverTime());return Number.isFinite(a)?a-(n+Date.now())/2:0}catch{return 0}}async function Ie(t,n){let a=Date.parse(n??"");return Number.isFinite(a)?a+await de(t)+H:Number.NEGATIVE_INFINITY}var be=1e3;function Re(t){let n=Date.parse(t);return Number.isFinite(n)?n-be:Number.NEGATIVE_INFINITY}function ke(t,n){let a=Object.hasOwn(t,n)?t[n]:[];return new Map(a.filter(c=>c.toLowerCase()!=="id").map(c=>[c.toLowerCase(),c]))}var Ae={INACTIVE_OWNER_OR_USER:"OwnerId"};function Oe(t,n){let a=new Set;for(let s of t.errors??[]){if(typeof s=="string")continue;if(Array.isArray(s.fields))for(let p of s.fields)typeof p=="string"&&a.add(p);let f=s.statusCode!==void 0?Ae[s.statusCode]:void 0;f!==void 0&&(!Array.isArray(s.fields)||s.fields.length===0)&&a.add(f)}let c=new Map(Object.keys(n).map(s=>[s.toLowerCase(),s]));return[...a].flatMap(s=>{let f=c.get(s.toLowerCase());return f!==void 0&&f!=="Id"?[f]:[]})}function ve(t,n){let a=Array.isArray(t)?t:[t];return Array.from({length:n},(c,s)=>a[s]??{success:!1})}function J(t){let n=t.errors?.[0];if(n===void 0)return{words:"The org gave no reason."};if(typeof n=="string")return{words:n};let a=n.statusCode,c=n.message??"";return{...a?{code:a}:{},words:a&&c?`${a}: ${c}`:a||c}}function P(t,{fields:n,why:a}){return`${n.map(c=>`${t}.${c}`).join(", ")}: the value from before is no longer taken (${a}) \u2014 left as the run wrote it`}async function je(t,n,a){let c=new Set;try{for(let s of $(a)){let f=await t.query(`SELECT Id FROM ${n} WHERE Id IN (${s})`);for(let p of f.records)typeof p.Id=="string"&&c.add(y(p.Id))}}catch(s){return{unread:S(s)}}return{live:c}}var Q=class{result;said=new Set;constructor(n,a){this.result={objectApiName:n,planned:a,restored:0,keptChanged:0,alreadyGone:0,refused:0,notKept:0,reasons:[]}}without(){this.result.restoredWithout=(this.result.restoredWithout??0)+1}reason(n){this.said.has(n)||this.said.size>=ye||(this.said.add(n),this.result.reasons.push(n))}};async function De(t){let{org:n,plan:a}=t,c=[],s=[],f={},p=!1,I=!1;if(a.length===0)return{objects:c,left:s,wrote:p,cancelled:I,stamps:f};let M=t.changedAfter!==void 0?Re(t.changedAfter):await Ie(n,t.lastWriteAt),R=new Map(Object.entries(t.stamps??{}).map(([h,_])=>[y(h),Date.parse(_)])),F=t.ownWriters&&t.ownWriters.length>0?new Set(t.ownWriters.map(y)):void 0,W=t.stampsFor,ce=me(n);for(let{objectApiName:h,backup:_,ids:C}of a){let u=new Q(h,C.length);c.push(u.result);let B=t.unkept?.find(e=>e.objectApiName===h);if(B&&B.fields.length>0&&u.reason(`${B.fields.map(e=>`${h}.${e}`).join(", ")}: not kept, encrypted \u2014 the run's user cannot view encrypted data, and read their values from before masked; left as the run wrote them`),I||t.signal?.aborted){I=!0,u.result.notReached=C.length,s.push(...C);continue}let x=Y(h),m=new Map(C.map(e=>[y(e),e])),U=t.fields?ke(t.fields,h):void 0,O=new Map,G=new Set;try{let e=await t.backups.batches(_,h,k);for await(let r of e??[])for(let o of r){if(typeof o.Id!="string"||!m.has(y(o.Id)))continue;let i=O.get(y(o.Id))??{};for(let[l,d]of Object.entries(o)){if(l==="Id")continue;let g=U?U.get(l.toLowerCase()):l;g!==void 0&&!(g in i)&&(i[g]=d)}if(U&&Object.keys(i).length===0){G.add(y(o.Id));continue}O.set(y(o.Id),i)}}catch(e){u.reason(`The values from before the run could not be read: ${S(e)}`),O.clear(),G.clear()}let X=[...G].filter(e=>!O.has(e)).length;X>0&&u.reason(`${X} ${h} record(s) hold no value of a field that may be written back now: left as they are`);for(let e of[...m.keys()])O.has(e)||(u.result.notKept++,m.delete(e));if(m.size===0)continue;let Z=new Set;for(let e of O.values())for(let r of Object.keys(e))Z.add(Y(r));let ee=["Id","LastModifiedDate",...F?["LastModifiedById"]:[],...Z],ue=ee.length>pe?k/4:k,q=new Map,fe=async e=>{if(t.signal?.aborted)throw new T;return(await n.query(e)).records};try{for(let e of $([...m.values()],ue)){let r=await oe(`SELECT ${ee.join(", ")} FROM ${x} WHERE Id IN (${e})`,fe,{stamp:"LastModifiedDate"});for(let o of r)typeof o.Id=="string"&&q.set(y(o.Id),o)}}catch(e){if(e instanceof T){I=!0,u.result.notReached=m.size,s.push(...m.values());continue}u.result.refused+=m.size,u.reason(S(e)),s.push(...m.values());continue}let D=[],te=new Set,le=W?Date.now()+await de(n)-H:0;for(let[e,r]of m){let o=q.get(e);if(!o){u.result.alreadyGone++,t.counted?.(r,"alreadyGone");continue}let i=Date.parse(String(o.LastModifiedDate??"")),l=o.LastModifiedById,d=i<=M||i<=(R.get(e)??Number.NaN)||F!==void 0&&typeof l=="string"&&F.has(y(l));if(!d&&!t.includeChanged){u.result.keptChanged++,s.push(r);continue}let g=O.get(e)??{},w={Id:o.Id};for(let[b,A]of Object.entries(g))he(A,o[b])||(w[b]=L(A)?null:A);if(Object.keys(w).length===1){u.result.restored++,t.counted?.(r,"restored"),d&&W?.(r)&&typeof o.LastModifiedDate=="string"&&(f[o.Id]=o.LastModifiedDate);continue}D.push(w),d&&W?.(r)&&te.add(r)}let j=[],v=[],E=(e,r)=>{u.result.refused++,u.reason(r),s.push(m.get(y(e.Id))??e.Id)},z=e=>{u.result.restored++,t.counted?.(m.get(y(e.Id))??e.Id,"restored")},ge=e=>{u.result.alreadyGone++,t.counted?.(m.get(y(e.Id))??e.Id,"alreadyGone")},ne=e=>{I=!0,u.result.notReached=(u.result.notReached??0)+e.length,s.push(...e.map(r=>m.get(y(r.Id))??r.Id))},re=(e,r,o,i)=>{let l=Object.keys(e).filter(w=>w!=="Id"&&!r.includes(w));if(l.length>0){let w={Id:e.Id};for(let b of l)w[b]=e[b];j.push({record:w,leftOut:o});return}if(o.length===0){z(e);return}let[d,...g]=o;i?(u.without(),u.reason(P(h,d))):E(e,P(h,d));for(let w of g)u.reason(P(h,w))},K=async e=>{try{return p=!0,ve(await n.update(h,[...e]),e.length)}catch(r){let o=S(r);return e.map(()=>({success:!1,errors:[o]}))}},we=async e=>{let r=t.keep;if(!r)return!0;let o=e.map(i=>{let l=q.get(y(i.Id))??{},d={Id:i.Id};for(let g of Object.keys(i))g!=="Id"&&(d[g]=l[g]??null);return d});try{return await r(h,o),!0}catch(i){let l=`What these ${e.length} ${h} record(s) hold now could not be kept before they were written (${S(i)}), so none of them was written: nothing is written over that cannot be put back.`;for(let d of e)E(d,l);return!1}};for(let e=0;e<D.length;e+=k){let r=D.slice(e,e+k);if(t.signal?.aborted){I=!0;let i=D.slice(e);u.result.notReached=(u.result.notReached??0)+i.length,s.push(...i.map(l=>m.get(y(l.Id))??l.Id));break}if(!await we(r))continue;(await K(r)).forEach((i,l)=>{let d=r[l];if(i.success===!0){z(d);return}let g=J(i),w=Oe(i,d);if(g.code==="ENTITY_IS_DELETED"&&w.length===0){v.push({record:d,why:g.words});return}let b=Object.keys(d).filter(A=>A!=="Id"&&!w.includes(A));if(w.length>0&&b.length>0){let A={Id:d.Id};for(let se of b)A[se]=d[se];j.push({record:A,leftOut:[{fields:w,why:g.words}]});return}E(d,g.words)})}let N=[];if(v.length>0&&t.signal?.aborted)ne(v.map(({record:e})=>e));else if(v.length>0){let e=await je(n,x,v.map(({record:r})=>r.Id));e.unread!==void 0&&u.reason(`Whether ${v.length} ${h} record(s) refused as deleted are still in the org could not be read (${e.unread}): left to be given back again`);for(let{record:r,why:o}of v){if(e.unread!==void 0){E(r,o);continue}if(!e.live.has(y(r.Id))){ge(r);continue}let i=Object.keys(r).filter(l=>l!=="Id"&&ie(r[l]));i.length===0?E(r,o):i.length===1?re(r,i,[{fields:i,why:o}],!1):N.push({record:r,lookups:i,given:[],refusedAlone:[]})}}let V=N.length>0;for(let e=0;V&&N.some(({lookups:r})=>r.length>e);e++){let r=N.filter(({lookups:o})=>o.length>e);for(let o=0;o<r.length;o+=k){if(t.signal?.aborted){ne(N.map(({record:d})=>d)),V=!1;break}let i=r.slice(o,o+k);(await K(i.map(({record:d,lookups:g})=>({Id:d.Id,[g[e]]:d[g[e]]})))).forEach((d,g)=>{let w=i[g],b=w.lookups[e];d.success===!0?w.given.push(b):w.refusedAlone.push({field:b,why:J(d).words})})}}for(let e of V?N:[]){let r=new Map;for(let{field:o,why:i}of e.refusedAlone)r.set(i,[...r.get(i)??[],o]);re(e.record,e.lookups,[...r].map(([o,i])=>({fields:i,why:o})),e.given.length>0)}for(let e=0;e<j.length;e+=k){let r=j.slice(e,e+k);if(t.signal?.aborted){I=!0,u.result.notReached=(u.result.notReached??0)+j.length-e,s.push(...j.slice(e).map(({record:i})=>m.get(y(i.Id))??i.Id));break}(await K(r.map(({record:i})=>i))).forEach((i,l)=>{let{record:d,leftOut:g}=r[l];if(i.success===!0){if(g.length===0){z(d);return}u.without();for(let w of g)u.reason(P(h,w));return}E(d,J(i).words)})}Object.assign(f,await Ee(n,x,[...te],le,ce))}return{objects:c,left:s,wrote:p,cancelled:I,stamps:f}}async function Ee(t,n,a,c,s){let f={};if(a.length===0)return f;let p=await s();if(p===void 0)return f;for(let I of $(a)){let M;try{M=(await t.query(`SELECT Id, LastModifiedDate, LastModifiedById FROM ${n} WHERE Id IN (${I})`)).records}catch{continue}for(let R of M)typeof R.Id=="string"&&typeof R.LastModifiedDate=="string"&&typeof R.LastModifiedById=="string"&&y(R.LastModifiedById)===p&&Date.parse(R.LastModifiedDate)>=c&&(f[R.Id]=R.LastModifiedDate)}return f}var T=class extends Error{};function $e(t,n,a=[]){let c=t.map(s=>({...s}));for(let s of a){if(s.undeleted+s.refused===0)continue;let f=c.find(p=>p.objectApiName===s.objectApiName);f?(f.created+=s.undeleted,f.failed+=s.refused):c.push({objectApiName:s.objectApiName,created:s.undeleted,updated:0,deleted:0,failed:s.refused})}for(let s of n){let f=s.restored+(s.restoredWithout??0);if(f+s.refused===0)continue;let p=c.find(I=>I.objectApiName===s.objectApiName);p?(p.updated+=f,p.failed+=s.refused):c.push({objectApiName:s.objectApiName,created:0,updated:f,deleted:0,failed:s.refused})}return c}export{he as a,me as b,de as c,Ie as d,De as e,Ee as f,$e as g};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a as y,b as g}from"./chunk-WR4Q363I.mjs";import{a as S,b as f,c as p}from"./chunk-M3ROUWDX.mjs";import{b as u}from"./chunk-CA5NAXSU.mjs";import{ja as d}from"./chunk-TTFDUKUS.mjs";var h="SELECT ApiName, MasterLabel, IsClosed, IsDefault, SortOrder FROM CaseStatus ORDER BY SortOrder",w="SELECT MasterLabel, IsClosed, IsDefault, SortOrder FROM CaseStatus ORDER BY SortOrder",A="Closed";async function k(a){let e;try{e=await a(h)}catch{try{e=await a(w)}catch(t){return m(`the org would not read its case statuses: ${u(t)}`)}}let r=e.flatMap(t=>{let n=b(t.ApiName)??b(t.MasterLabel);return n===void 0?[]:[{value:n,closed:t.IsClosed===!0,isDefault:t.IsDefault===!0}]}),o=r.filter(t=>!t.closed),i=r.filter(t=>t.closed);return o.length===0||i.length===0?m(o.length===0?"the org has no case status that leaves a case open":"the org has no case status that closes a case"):{open:(o.find(t=>t.isDefault)??o[0]).value,closed:(i.find(t=>t.value===A)??i[0]).value,from:"org"}}function m(a){return{...d.caseStatus,from:"default",reason:a}}function b(a){return typeof a=="string"&&a.trim()!==""?a:void 0}var c=S;async function E(a,e){let r;try{r=await a(c)}catch{r={access:"createable"}}if(r.access==="absent")return{available:!1,reason:r.reason??`the org has no ${c}`};if(r.access==="readOnly")return{available:!1,reason:r.reason??`the user this seed runs as may read ${c} and not create it`};try{return{available:!0,bodyFields:f(await e(c))}}catch{return{available:!0,bodyFields:[]}}}var P=["Status","Origin","Priority","Type"];async function T(a){let e;try{e=(await a("Case")).fields}catch{return}let r={};for(let o of P){let t=(e.find(n=>n.name===o)?.picklistValues??[]).filter(n=>n.active!==!1).map(n=>n.value);t.length>0&&(r[o]=t)}return r}function v(a,e){let r=e.knowledge.available?e.knowledge.bodyFields:[],o=r.map(s=>s.name),i=e.articleBodyField===void 0?r[0]:r.find(s=>s.name===e.articleBodyField);if(e.articleBodyField!==void 0&&i===void 0)return{issues:[`options.articleBodyField: ${e.articleBodyField} is not a field of ${c} this org lets a body be written to`+(o.length>0?` (${o.join(", ")})`:"")]};let t=e.knowledge.available?{available:!0,bodyFields:o}:e.knowledge,n={seed:e.seed??d.seed,caseStatus:{open:e.caseStatus.open,closed:e.caseStatus.closed},...i!==void 0?p(i):{}},l;try{l=g(a,n)}catch(s){if(s instanceof y)return{issues:s.issues};throw s}return{preparation:{options:n,objects:[...l.template.objects].sort((s,C)=>s.insertOrder-C.insertOrder).map(s=>({objectApiName:s.objectApiName,recordCount:s.recordCount,...s.optional===!0?{optional:!0}:{}})),tests:l.tests.length,caseStatusFrom:e.caseStatus.from==="org"?{from:"org"}:{from:"default",reason:e.caseStatus.reason},knowledge:t}}}function D(a){return async e=>{let r=await a.query(e),o=[...r.records];for(;!r.done&&r.nextRecordsUrl;)r=await a.queryMore(r.nextRecordsUrl),o.push(...r.records);return o}}export{h as a,w as b,k as c,c as d,E as e,T as f,v as g,D as h};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a as T,b as F,d as B,k as R}from"./chunk-7FFGJWHN.mjs";import{b as j,l as x,o as N}from"./chunk-G35N4P7D.mjs";import{a as L,f as C,i as $,j as _}from"./chunk-SAR5622P.mjs";import{a as I}from"./chunk-4TLYUZD5.mjs";import{b as P}from"./chunk-CA5NAXSU.mjs";import{qc as A}from"./chunk-TTFDUKUS.mjs";var w=class{byObject=new Map;add(e){let t=this.byObject.get(e.objectApiName);t||(t=new Map,this.byObject.set(e.objectApiName,t));let s=t.get(e.recordId),r=s?.[e.fieldName];if(r!==void 0&&r!==e.value)return{taken:!1,kept:r};let n=s??{Id:e.recordId};return n[e.fieldName]=e.value,t.set(e.recordId,n),{taken:!0}}updates(){return[...this.byObject].map(([e,t])=>[e,[...t.values()]])}};var J="DUPLICATES_DETECTED",X=3,Y=2e3;function Z(i){return new Promise(e=>setTimeout(e,i))}function z(i){let e=i.errorDetails??[];return N(i.errors,e.length===i.errors.length?e:void 0)}function q(i){let e=i.errorDetails;return e?.length!==1||e[0].statusCode===J||z(i)}function Q(i){let e=Object.keys(i).find(s=>s!=="Id"),t=e===void 0?void 0:i[e];return typeof t=="string"?t:""}function U(i){return{objectApiName:i,op:"update"}}function V(i){let e=i.automation??"the target's automation";I.warn(`[forge] ${i.objectApiName}: ${e} hit ${i.limit??"a Salesforce limit"} on an update of ${i.from} records \u2014 sending a record on its own, then smaller calls.`)}function y(i){return Object.keys(i).filter(e=>e!=="Id").length}async function fe(i){if(!i.enabled||!i.updateRecords||i.pendingFkUpdates.length===0)return null;let e=new E(i);return await e.patch(i.pendingFkUpdates),e.finish()}var ee=1024,te=.6;function K(i){let e=2166136261;for(let t=0;t<i.length;t++)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0}function M(i){let e=2538058380;for(let t=0;t<i.length;t++)e=Math.imul(e^i.charCodeAt(t),1540483477),e^=e>>>15;return e>>>0}var H=class{capacity=ee;used=0;h1=new Uint32Array(this.capacity);h2=new Uint32Array(this.capacity);firstPart=new Float64Array(this.capacity);several=new Uint8Array(this.capacity);note(e,t){let s=K(t),r=M(t),n=this.find(s,r);if(n>=0){this.firstPart[n]!==e+1&&(this.several[n]=1);return}this.used+1>this.capacity*te&&this.grow();let o=this.freeSlotFor(r);this.h1[o]=s,this.h2[o]=r,this.firstPart[o]=e+1,this.used++}spans(e){let t=this.find(K(e),M(e));return t>=0&&this.several[t]===1}find(e,t){let s=this.capacity-1;for(let r=t&s;;r=r+1&s){if(this.firstPart[r]===0)return-1;if(this.h1[r]===e&&this.h2[r]===t)return r}}freeSlotFor(e){let t=this.capacity-1,s=e&t;for(;this.firstPart[s]!==0;)s=s+1&t;return s}grow(){let{h1:e,h2:t,firstPart:s,several:r}=this;this.capacity*=2,this.h1=new Uint32Array(this.capacity),this.h2=new Uint32Array(this.capacity),this.firstPart=new Float64Array(this.capacity),this.several=new Uint8Array(this.capacity);for(let n=0;n<s.length;n++){if(s[n]===0)continue;let o=this.freeSlotFor(t[n]);this.h1[o]=e[n],this.h2[o]=t[n],this.firstPart[o]=s[n],this.several[o]=r[n]}}},E=class{constructor(e){this.input=e;this.splits=e.splitting!==void 0,this.splitting=e.splitting??L(0),this.bulkUnsupported=e.bulkUnsupported??new Set}input;resolvedCount=0;unresolvedCount=0;insertOnlyLost=0;unresolved=[];pass2Failed=0;pass2Samples=[];notSent=0;notSentObjects=new Set;cancelled=!1;handed=0;held=new w;splitting;splits;bulkUnsupported;backoff=new x({initialDelay:Y});limitOf(e){return this.splits&&e&&!e.success?A(e.errors):void 0}async patch(e,t){let{input:s}=this;if(!s.enabled||!s.updateRecords||e.length===0)return;this.handed+=e.length;let r=new w;for(let n of e)this.take(n,t?.(n)===!0?this.held:r);await this.send(r)}async sendHeld(){await this.send(this.held)}take(e,t){let{input:s}=this,{remapper:r}=s,n=r.get(e.sourceRefId);if(!n){if(s.deferUnresolved){s.stillPending?.push(e);return}if(s.outsideTheSample?.(e)){s.onLeftOutsideTheSample?.(e.objectApiName,e.fieldName);return}this.unresolvedCount++,this.unresolved.length<3&&this.unresolved.push({recordSummary:`${e.objectApiName} source=${e.sourceId??"?"} target=${e.newId} ${e.fieldName}=<source ${e.sourceRefId}>`,messages:[`Cycle FK '${e.fieldName}' could not be resolved \u2014 referenced parent (source ${e.sourceRefId}) was not cloned`]});return}if(e.insertOnly){this.insertOnlyLost++,this.unresolved.length<3&&this.unresolved.push({recordSummary:`${e.objectApiName} source=${e.sourceId??"?"} target=${e.newId} ${e.fieldName}`,messages:[`Lookup '${e.fieldName}' left empty: only an insert sets it, and the record it names (source ${e.sourceRefId}) was written after this one`]});return}let o=t.add({objectApiName:e.objectApiName,recordId:e.newId,fieldName:e.fieldName,value:n});if(!o.taken){this.unresolvedCount++,this.unresolved.length<3&&this.unresolved.push({recordSummary:`${e.objectApiName} source=${e.sourceId??"?"} target=${e.newId} ${e.fieldName}`,messages:[`Conflicting cycle FK update for ${e.fieldName}: ${String(o.kept)} vs ${n}`]});return}this.resolvedCount++}async send(e){for(let[t,s]of e.updates()){if(this.jobsFor(t,s.length)){await this.sendAsJobs(t,s);continue}await this.sendObject(t,s)}}jobsFor(e,t){let{input:s}=this;return s.bulkUpdate!==void 0&&t>=2e3&&s.restOnly?.has(e)!==!0&&!this.bulkUnsupported.has(e)}leaveNotSent(e,t){for(let s of t)this.notSent+=y(s);t.length>0&&this.notSentObjects.add(e)}async sendObject(e,t,s,r){let{input:n}=this,{targetOrgId:o}=n,d=n.updateRecords;if(!d||t.length===0)return;let c=()=>(this.cancelled||(this.cancelled=n.stopped?.()===!0),this.cancelled);if(c()){this.leaveNotSent(e,t);return}let l,a=await _(t,{key:U(e),sizes:this.splitting.sizes,allowance:this.splitting.allowance,maxSize:B.rest,...r,beforeEachSend:()=>c()?"stop":void 0,send:async p=>{try{return{answers:await d(o,e,[...p])}}catch(h){return l={error:h},{answers:[]}}},limited:p=>this.limitOf(p),settle:(p,h,k,S)=>{let v=l;l=void 0,v?this.callThrew(e,p,v.error):this.settleAnswers(e,p,h,k,S,s),n.onAnswered?.()},onFirstRefusal:V});a.stopped&&this.leaveNotSent(e,[...a.stopped.part,...a.stopped.rest])}settleAnswers(e,t,s,r,n,o){let{input:d}=this;for(let c=0;c<t.length;c++){if(r.has(c))continue;let l=s[c];l?l.success?d.onPatched?.(e,t[c]):o&&z(l)?o.push(t[c]):this.refused(e,t[c],l,n.get(c)):(this.pass2Failed+=y(t[c]),this.pass2Samples.length<3&&this.pass2Samples.push({recordSummary:R(t[c]),messages:[`No result returned for record (API truncated batch: ${s.length}/${t.length})`]}))}}refused(e,t,s,r){this.tellRefusedByFilter(e,t,s),this.pass2Failed+=y(t),this.pass2Samples.length<3&&this.pass2Samples.push({recordSummary:R(t),messages:r===void 0?s.errors:[...s.errors,C(r,$(this.splitting.allowance,U(e)),"run")]})}callThrew(e,t,s){for(let r of t)this.pass2Failed+=y(r);this.pass2Samples.length<3&&this.pass2Samples.push({recordSummary:`${e} batch failed`,messages:[P(s)]})}async sendAsJobs(e,t){let{input:s}=this,r=s.bulkUpdate;if(!r)return;let n=t.map((l,a)=>({record:l,at:a,value:Q(l)})).sort((l,a)=>l.value===a.value?l.at-a.at:l.value<a.value?-1:1).map(({record:l})=>l),o=U(e),{sizes:d,allowance:c}=this.splitting;for(let l=0;l<n.length;l+=F){let a=n.slice(l,l+F);if(this.cancelled||(this.cancelled=s.stopped?.()===!0),this.cancelled){this.leaveNotSent(e,a);continue}let p=d.of(o);if(p<200){let u=Math.ceil(a.length/p),f=c.take(o,u);d.countExtraCalls(o,f);let m=a.slice(0,f*p);try{await this.sendObject(e,m,void 0,{pricedAs:"job",paid:{calls:f}})}finally{f<u&&d.spend(o)}if(f===u)continue;if(a=a.slice(m.length),this.cancelled){this.leaveNotSent(e,a);continue}if(a.length<2e3){await this.sendObject(e,a);continue}}let h;try{h=await r(e,a)}catch(u){if(!(u instanceof T)){await this.sendObject(e,a);continue}for(let f of a)this.pass2Failed+=y(f);this.pass2Samples.length<3&&this.pass2Samples.push({recordSummary:`${e}: a Bulk API job of ${a.length} updates was lost`,messages:[P(u),"The target may hold any of these lookups: they are counted as left empty."]}),s.onAnswered?.();continue}if(h.aborted){this.cancelled=!0,this.leaveNotSent(e,a);continue}if(h.untouched){h.untouched.unsupported&&this.bulkUnsupported.add(e),await this.sendObject(e,a);continue}let k=[],S=[],v=[],b;a.forEach((u,f)=>{let m=h.rows[f]??"unprocessed",g=h.answers[f],O=m==="answered"?this.limitOf(g):void 0;O&&g?(b??=O,S.push(u),v.push(g)):m==="answered"&&g?.success?s.onPatched?.(e,u):m==="may-have-written"?(this.pass2Failed+=y(u),this.pass2Samples.length<3&&this.pass2Samples.push({recordSummary:R(u),messages:["The Bulk API job may have written this update without saying so."]})):m!=="answered"||!g||q(g)?k.push(u):this.refused(e,u,g)}),s.onAnswered?.(),await this.sendAgainByRest(e,k),await this.sendObject(e,S,void 0,{refusedIn:{from:200,answers:v,...b?{cause:b}:{}}})}}async sendAgainByRest(e,t){let s=t;for(let r=0;s.length>0;r++){r>0&&await(this.input.wait??Z)(this.backoff.calculateDelay(r-1));let n=[];await this.sendObject(e,s,r<X-1?n:void 0),s=n}}tellRefusedByFilter(e,t,s){let r=this.input.onRefusedByFilter,n=t.Id;if(!r||typeof n!="string")return;let o=new Set((s.errorDetails??[]).filter(d=>d.statusCode===j).flatMap(d=>d.fields));for(let d of Object.keys(t))d!=="Id"&&o.has(d)&&r(e,d,n)}finish(){let{resolvedCount:e,unresolvedCount:t,insertOnlyLost:s,pass2Failed:r,notSent:n}=this;if(this.handed===0)return null;let o=e+t+s;if(this.input.deferUnresolved&&e===0&&r===0&&s===0)return null;let d=r+t+s+n;if(this.input.onProgress({objectName:"__pass2__",status:d>0?"error":"done",progress:100,message:`Pass 2 (cycle FK update): ${e-r-n}/${o} resolved`+(n>0?`; cancelled with ${n} not sent`:"")}),d>0){let c=n>0?[{recordSummary:`${[...this.notSentObjects].join(", ")}: ${n} lookup${n===1?"":"s"} not sent`,messages:["The run was cancelled before they were filled in: they stay empty."]}]:[];return{objectApiName:"__pass2__",stage:"insert",failedCount:d,attemptedCount:o,samples:[...c,...this.pass2Samples,...this.unresolved].slice(0,3)}}return null}};export{w as a,fe as b,H as c,E as d};
@@ -0,0 +1,10 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a as C}from"./chunk-4TLYUZD5.mjs";import{createHash as v}from"node:crypto";var I=new Set(["unmanaged","beta","released"]);function _(c){let{namespacePrefix:a,manageableState:n}=c;return typeof a!="string"||a===""?!1:typeof n!="string"||!I.has(n)}function S(c){let a;try{a=JSON.parse(c)}catch{return!1}return typeof a!="object"||a===null?!1:_(a)}function x(c,a){let n=new Set;for(let t of[c,a])for(let[o,i]of t)S(i)&&n.add(o);let s=t=>new Map([...t].filter(([o])=>!n.has(o)));return{source:s(c),target:s(a),leftOut:n.size}}var N={components:500,seconds:90},k=4,B=3,D=30,w=240,b=class{fetchMetadata;diffEngine;reader;budget;now;constructor(a,n,s,t={}){this.fetchMetadata=a,this.diffEngine=n,this.reader=s,this.budget=t.budget??N,this.now=t.now??Date.now}async compare(a,n,s,t={includeManaged:!0},o){let i=[],d=0;for(let e of s){o?.throwIfAborted();let[p,r]=await Promise.all([this.fetchMetadata(a,e),this.fetchMetadata(n,e)]);if(t.includeManaged){i.push({componentType:e,source:p,target:r});continue}let{source:f,target:g,leftOut:h}=x(p,r);d+=h,i.push({componentType:e,source:f,target:g})}let l=O(i,e=>this.reader.batchSize(e),this.budget.components),m=await this.readPlanned(a,n,l.toRead,o);o?.throwIfAborted();let u=[];for(let{componentType:e,source:p,target:r}of i)u.push(...this.judge(e,p,r,l.toRead.get(e)??[],l.notCompared.get(e)??new Map,m.get(e)));return{items:u,managedLeftOut:d}}async readPlanned(a,n,s,t){let i=this.now()+this.budget.seconds*1e3,d=new Map,l=[];for(let[e,p]of s){let r={source:new Map,target:new Map,unread:new Set};d.set(e,r);let f=this.reader.batchSize(e)??p.length;for(let g=0;g<p.length;g+=f){let h=p.slice(g,g+f);l.push(async()=>{if(t?.throwIfAborted(),this.now()>=i){for(let M of h)r.unread.add(M);return}let[P,A]=await Promise.all([this.readOne(a,e,h,t),this.readOne(n,e,h,t)]);for(let[M,y]of P)r.source.set(M,y);for(let[M,y]of A)r.target.set(M,y)})}}let m=0,u=async()=>{for(;m<l.length;){let e=l[m];m+=1,await e()}};return await Promise.all(Array.from({length:Math.min(k,l.length)},u)),d}async readOne(a,n,s,t){try{return await this.reader.read(a,n,s)}catch(o){return t?.throwIfAborted(),C.warn(`[compare] reading ${s.length} ${n} failed: ${o instanceof Error?o.message:String(o)}`),new Map}}judge(a,n,s,t,o,i){let d=new Map(n),l=new Map(s),m=new Map,u=new Map(o);for(let e of t){let p=i?.source.get(e),r=i?.target.get(e);i?.unread.has(e)?u.set(e,"over_budget"):p===null||r===null?u.set(e,"unreadable"):p===void 0||r===void 0?u.set(e,"read_failed"):(d.set(e,T(p)),l.set(e,T(r)),m.set(e,{source:p,target:r}))}return this.diffEngine.diff(d,l,a,u).map(e=>{let p=[n,s].some(f=>{let g=f.get(e.fullName);return g!==void 0&&S(g)}),r=p?{...e,managed:p}:e;if(r.status==="modified"){let f=m.get(r.fullName),g=f?F(f.source,f.target):void 0;return{...r,sourceValue:g?.source,targetValue:g?.target}}return r.status==="unchanged"?{...r,sourceValue:void 0,targetValue:void 0}:r})}};function O(c,a,n){let s=new Map,t=new Map,o=[],i=[];for(let{componentType:u,source:e,target:p}of c){let r=[...e.keys()].filter(g=>p.has(g)).sort(),f=new Map;if(t.set(u,f),a(u)===void 0){for(let g of r)f.set(g,"unreadable");o.push([]),i.push([]);continue}o.push(r.filter(g=>e.get(g)!==p.get(g))),i.push(r.filter(g=>e.get(g)===p.get(g)))}let d=R(o.map(u=>u.length),n),l=d.reduce((u,e)=>u+e,0),m=R(i.map(u=>u.length),n-l);return c.forEach(({componentType:u},e)=>{let p=t.get(u)??new Map,r=[...o[e].slice(0,d[e]),...i[e].slice(0,m[e])];for(let f of o[e].slice(d[e]))p.set(f,"over_budget");for(let f of i[e].slice(m[e]))p.set(f,"over_budget");r.length>0&&s.set(u,r)}),{toRead:s,notCompared:t}}function R(c,a){let n=c.map(()=>0),s=c.map((i,d)=>d).sort((i,d)=>c[i]-c[d]),t=Math.max(0,a),o=s.length;for(let i of s){let d=Math.min(c[i],Math.floor(t/o));n[i]=d,t-=d,o-=1}return n}function T(c){return v("sha256").update(c).digest("hex")}function F(c,a){let n=c.split(`
8
+ `),s=a.split(`
9
+ `),t=0;for(;t<n.length&&t<s.length&&n[t]===s[t];)t+=1;let o=Math.max(0,t-B);return{source:E(n,o),target:E(s,o)}}function E(c,a){let n=Math.min(c.length,a+D),s=String(n).length,t=c.slice(a,n).map((o,i)=>{let d=o.length>w?`${o.slice(0,w)}\u2026`:o;return`${String(a+i+1).padStart(s)}\u2502 ${d}`});return a>0&&t.unshift("\u2026"),n<c.length&&t.push("\u2026"),t.join(`
10
+ `)}export{_ as a,S as b,N as c,b as d,O as e,F as f};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{b as i}from"./chunk-CA5NAXSU.mjs";var o=["ENOTFOUND","ECONNREFUSED","ETIMEDOUT","ECONNRESET","EAI_AGAIN","ENETUNREACH","EHOSTUNREACH"];function s(n){if(typeof n=="object"&&n!==null){let{code:t,name:u,cause:r}=n;if(typeof t=="string"&&o.includes(t)||u==="TimeoutError"||r!==void 0&&s(r))return!0}let e=i(n);return o.some(t=>e.includes(t))||e.includes("fetch failed")?!0:/\btimed out\b/i.test(e)}function c(n){let{code:e}=typeof n=="object"&&n!==null?n:{};if(typeof e=="string"&&o.includes(e))return e;let t=i(n),u=o.find(r=>t.includes(r));if(u!==void 0)return u;if(/socket hang up/i.test(t))return"socket hang up";if(s(n))return/\btimed out\b/i.test(t)?"timed out":"no connection"}function f(n){return typeof n.unread=="string"?c(n.unread):n.unread.find(e=>e.unreachable!==void 0)?.unreachable}export{s as a,c as b,f as c};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a as b}from"./chunk-74Q6DORA.mjs";import"./chunk-UNJA4J37.mjs";import{a}from"./chunk-XLXIPIEW.mjs";import"./chunk-TTKXMDBN.mjs";import"./chunk-TSLJUSLW.mjs";import"./chunk-KRCA6IPH.mjs";import"./chunk-5TC3QB4U.mjs";import"./chunk-2BA2XKAY.mjs";import"./chunk-OAZRPP4I.mjs";import"./chunk-JEERQRLW.mjs";import"./chunk-MHMH6MTP.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-MJU2PGZQ.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LWW4U276.mjs";import"./chunk-MJVTDA5Q.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-2CNCDM56.mjs";import"./chunk-SIHORWVK.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-B5QQJ4SI.mjs";import"./chunk-NZC67CGR.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-F43REJDZ.mjs";import"./chunk-JPUR2CFX.mjs";import"./chunk-LPBMBW3O.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-IFETCRWE.mjs";import"./chunk-PZPJKATS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-MFG4MUIO.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-HS4YRX4J.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{a as objectsWrittenBy,b as previewCheckpoint};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ function r(...a){return new RegExp(`(?<![a-z\xE0-\xFF])(?:${a.join("|")})(?![a-z\xE0-\xFF])`)}var p=[{regex:r("sexual orientation","sexual preference","orientation sexuelle"),classification:"Confidential",confidence:.85,label:"sexual_orientation",words:!0},{regex:r("gender identity","gender","sexe?","pronouns?","pronoms?","identit[e\xE9] de genre"),classification:"PII",confidence:.85,label:"gender",words:!0},{regex:r("salutations?","civility","honorifics?","civilit[e\xE9]s?"),classification:"PII",confidence:.8,label:"salutation",words:!0},{regex:r("marital status","marital","situation familiale","situation matrimoniale"),classification:"PII",confidence:.85,label:"marital_status",words:!0},{regex:r("nationality","nationalities","citizenship","nationalit[e\xE9]s?","citoyennet[e\xE9]"),classification:"PII",confidence:.85,label:"nationality",words:!0},{regex:r("ethnicity","ethnic","race","racial","ethnie","ethnique"),classification:"Confidential",confidence:.85,label:"ethnic_origin",words:!0},{regex:r("religion","religions","religious","religieux","religieuse"),classification:"Confidential",confidence:.85,label:"religion",words:!0},{regex:r("political (?:opinion|affiliation|party|view)s?","opinions? politiques?","parti politique"),classification:"Confidential",confidence:.85,label:"political_opinion",words:!0},{regex:r("trade union","labou?r union","union member(?:ship)?","syndicat","syndicale?"),classification:"Confidential",confidence:.85,label:"union_membership",words:!0},{regex:r("disability","disabilities","handicaps?"),classification:"PHI",confidence:.85,label:"disability",words:!0}],d=/(?<![a-z])(?:(?:first|last|middle|maiden)[\s_]?name(?:local)?|surname|suppliedname)(?![a-z])/,g=new Set(["string","textarea","encryptedstring"]);function C(a){return d.test(a.toLowerCase().replace(/__c$/i,""))}var u=new Set(["string","textarea","encryptedstring"]),I=new Set(["email","emails","mail","mails","courriel","courriels"]),m=new Set(["ToAddress","CcAddress","BccAddress"]),P=new Set(["phone","phones","telephone","tel","mobile","cell","fax","sms","gsm","whatsapp","portable"]);function f(a){return a.replace(/__[a-z]+$/i,"").replace(/^[a-z0-9]+__/i,"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/([A-Za-z])(\d)/g,"$1 $2").replace(/(\d)([A-Za-z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(i=>i!=="").map(i=>i.toLowerCase())}function h(a,i){let n=i.toLowerCase();if(n==="email")return"email";if(n==="phone")return"phone";if(!u.has(n))return;if(m.has(a))return"email";let e;for(let t of f(a))I.has(t)||t.endsWith("email")?e="email":(P.has(t)||t.endsWith("phone"))&&(e="phone");return e}function N(a,i){let n=new Set(a.detectPII("unknown",i.map(e=>({apiName:e.name,label:e.name,type:e.type}))).piiFields.map(e=>e.fieldApiName));return i.filter(e=>n.has(e.name)||h(e.name,e.type)!==void 0).map(e=>e.name)}var l=class{namePatterns;contentPatterns;constructor(){this.namePatterns=x(),this.contentPatterns=_()}detectPII(i,n,e){let t=new Map;for(let s of n)this.detectByName(s,t),this.detectByType(s,t);if(e&&e.length>0)for(let s of n)this.detectByContent(s,e,t);let c=Array.from(t.values());return{objectName:i,totalFields:n.length,piiFields:c,riskLevel:w(c.length)}}getPatterns(){let i={};for(let n of this.contentPatterns)i[n.label]=n.regex;return i}detectByName(i,n){let e=i.apiName.toLowerCase().replace(/__c$/i,""),t=f(i.apiName).join(" "),c=i.label.toLowerCase(),s=i.type.toLowerCase();for(let o of this.namePatterns){if(o.types&&!o.types.has(s))continue;let b=o.words?t:e;if(o.regex.test(b)||o.regex.test(c)){this.addDetection(n,i,{classification:o.classification,detectionMethod:"name_pattern",confidence:o.confidence,pattern:o.label});return}}}detectByType(i,n){if(n.has(i.apiName))return;let e=i.type.toLowerCase();e==="email"?this.addDetection(n,i,{classification:"PII",detectionMethod:"type_analysis",confidence:.95,pattern:"email_type"}):e==="phone"&&this.addDetection(n,i,{classification:"PII",detectionMethod:"type_analysis",confidence:.9,pattern:"phone_type"})}detectByContent(i,n,e){if(!e.has(i.apiName))for(let t of this.contentPatterns){let c=y(i.apiName,n,t.regex);if(c>0){let s=c/n.length,o=t.confidence*Math.min(s*2,1);this.addDetection(e,i,{classification:t.classification,detectionMethod:"content_pattern",confidence:o,pattern:t.label});return}}}addDetection(i,n,e){let t=i.get(n.apiName);t&&t.confidence>=e.confidence||i.set(n.apiName,{fieldApiName:n.apiName,fieldLabel:n.label,classification:e.classification,detectionMethod:e.detectionMethod,confidence:e.confidence,pattern:e.pattern})}};function x(){return[{regex:/\bemail\b/i,classification:"PII",confidence:.95,label:"email"},{regex:/\bphone\b/i,classification:"PII",confidence:.9,label:"phone"},{regex:/\bmobilephone\b/i,classification:"PII",confidence:.9,label:"mobile_phone"},{regex:/\bpersonemail\b/i,classification:"PII",confidence:.95,label:"person_email"},{regex:/\bmailingstreet\b/i,classification:"PII",confidence:.85,label:"mailing_street"},{regex:/\bbillingstreet\b/i,classification:"PII",confidence:.85,label:"billing_street"},{regex:/\bssn\b/i,classification:"PII",confidence:.99,label:"ssn"},{regex:/\bsocialsecuritynumber\b/i,classification:"PII",confidence:.99,label:"social_security_number"},{regex:/\bsocial_security\b/i,classification:"PII",confidence:.99,label:"social_security"},{regex:/\bbirthdate\b/i,classification:"PII",confidence:.9,label:"birthdate"},{regex:/\bdateofbirth\b/i,classification:"PII",confidence:.9,label:"date_of_birth"},{regex:/\bdate_of_birth\b/i,classification:"PII",confidence:.9,label:"date_of_birth_underscore"},{regex:/\bnationalid\b/i,classification:"PII",confidence:.95,label:"national_id"},{regex:/\bnational_id\b/i,classification:"PII",confidence:.95,label:"national_id_underscore"},{regex:/\bcreditcardnumber\b/i,classification:"PCI",confidence:.99,label:"credit_card_number"},{regex:/\bcreditcard\b/i,classification:"PCI",confidence:.95,label:"credit_card"},{regex:/\bcredit_card\b/i,classification:"PCI",confidence:.95,label:"credit_card_underscore"},{regex:/\biban\b/i,classification:"PCI",confidence:.95,label:"iban"},{regex:/\bbankaccount\b/i,classification:"PCI",confidence:.95,label:"bank_account"},{regex:/\bbank_account\b/i,classification:"PCI",confidence:.95,label:"bank_account_underscore"},{regex:/\bmedical\b/i,classification:"PHI",confidence:.85,label:"medical"},{regex:/\bdiagnos/i,classification:"PHI",confidence:.9,label:"diagnosis"},{regex:/\bhealth\b/i,classification:"PHI",confidence:.8,label:"health"},{regex:/\bpatient\b/i,classification:"PHI",confidence:.8,label:"patient"},{regex:/\bpassport\b/i,classification:"PII",confidence:.95,label:"passport"},{regex:/\bdriver.?licen/i,classification:"PII",confidence:.95,label:"driver_license"},{regex:/\baddress\b/i,classification:"PII",confidence:.8,label:"address"},{regex:d,classification:"PII",confidence:.85,label:"person_name",types:g},...p]}function _(){return[{regex:/[\w.-]+@[\w.-]+\.\w{2,}/,classification:"PII",confidence:.9,label:"email_content"},{regex:/\d{3}-\d{2}-\d{4}/,classification:"PII",confidence:.95,label:"ssn_content"},{regex:/\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}/,classification:"PCI",confidence:.95,label:"credit_card_content"},{regex:/[A-Z]{2}\d{2}[A-Z0-9]{4,}/,classification:"PCI",confidence:.85,label:"iban_content"},{regex:/\+?\d[\d\s-]{7,}/,classification:"PII",confidence:.7,label:"phone_content"}]}function y(a,i,n){let e=0;for(let t of i){let c=t[a];typeof c=="string"&&n.test(c)&&e++}return e}function w(a){return a===0?"none":a<=2?"low":a<=5?"medium":a<=10?"high":"critical"}export{C as a,h as b,N as c,l as d};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a,b}from"./chunk-VGW4MXXZ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-NTOVCTRS.mjs";export{b as AnonymizationEngine,a as MissingHashSaltError};