sandforge 1.80.0 → 1.81.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 (239) hide show
  1. package/bin/sandforge-pipeline.mjs +12 -0
  2. package/lib/{chunk-EMNC6YI4.mjs → chunk-2IB7I3IQ.mjs} +1 -1
  3. package/lib/{chunk-3RZQZHEB.mjs → chunk-2NAIUKVL.mjs} +1 -1
  4. package/lib/{chunk-AEKONPF4.mjs → chunk-2OIRJEYE.mjs} +1 -1
  5. package/lib/{chunk-BV6VTP3J.mjs → chunk-2OZG6GRW.mjs} +1 -1
  6. package/lib/{chunk-JEERQRLW.mjs → chunk-2Z54GB6X.mjs} +1 -1
  7. package/lib/chunk-2ZMGVBLW.mjs +7 -0
  8. package/lib/{chunk-FKG7Q3WH.mjs → chunk-33ZX3A56.mjs} +1 -1
  9. package/lib/{chunk-HLWMJF6Y.mjs → chunk-3AOKLIVE.mjs} +1 -1
  10. package/lib/{chunk-GGD7ON3M.mjs → chunk-3B5H24ZG.mjs} +1 -1
  11. package/lib/chunk-43K2C6H2.mjs +7 -0
  12. package/lib/chunk-4JKR4PTZ.mjs +8 -0
  13. package/lib/chunk-4L7FBOJS.mjs +8 -0
  14. package/lib/chunk-5344TZBT.mjs +11 -0
  15. package/lib/{chunk-SAR5622P.mjs → chunk-54HYHHVL.mjs} +1 -1
  16. package/lib/chunk-55LQD3Y3.mjs +7 -0
  17. package/lib/chunk-56MPPWLA.mjs +7 -0
  18. package/lib/chunk-5C5XEVZN.mjs +11 -0
  19. package/lib/chunk-5CKWGZX4.mjs +9 -0
  20. package/lib/{chunk-RSWDYIHY.mjs → chunk-5GBO4KD5.mjs} +1 -1
  21. package/lib/{chunk-BKDV4ENO.mjs → chunk-5UT2ZBGF.mjs} +1 -1
  22. package/lib/chunk-5VQNKDFU.mjs +7 -0
  23. package/lib/{chunk-XAMBCQPU.mjs → chunk-5WGA5CZB.mjs} +1 -1
  24. package/lib/chunk-5ZKCLBTN.mjs +474 -0
  25. package/lib/{chunk-UCD54V2M.mjs → chunk-67CC7RAE.mjs} +1 -1
  26. package/lib/{chunk-TSLJUSLW.mjs → chunk-6CDIIFNX.mjs} +1 -1
  27. package/lib/{chunk-AV5SWEHP.mjs → chunk-6FARZYMJ.mjs} +1 -1
  28. package/lib/{chunk-FPKYYFM7.mjs → chunk-6FMLW7PH.mjs} +1 -1
  29. package/lib/chunk-6IGEASOF.mjs +7 -0
  30. package/lib/{chunk-XUWL6ZPC.mjs → chunk-6NADW3OI.mjs} +1 -1
  31. package/lib/chunk-6SEDOIO3.mjs +10 -0
  32. package/lib/{chunk-PJ5I73CK.mjs → chunk-742SSN7I.mjs} +1 -1
  33. package/lib/chunk-7DALDJMO.mjs +7 -0
  34. package/lib/chunk-7PK5QDQI.mjs +7 -0
  35. package/lib/chunk-AELFEK3G.mjs +7 -0
  36. package/lib/chunk-AITNZWLB.mjs +9 -0
  37. package/lib/{chunk-2UZPIMUC.mjs → chunk-AJPSGVMD.mjs} +1 -1
  38. package/lib/{chunk-GSKCGQIP.mjs → chunk-BNO5GIJ6.mjs} +1 -1
  39. package/lib/{chunk-K2FBZIXY.mjs → chunk-BWWQXU2B.mjs} +1 -1
  40. package/lib/{chunk-IC2C2GOF.mjs → chunk-BXZ73A5M.mjs} +1 -1
  41. package/lib/chunk-BZFIOZS3.mjs +156 -0
  42. package/lib/{chunk-J525F5KI.mjs → chunk-C4YGSK6W.mjs} +1 -1
  43. package/lib/chunk-CAFUNR6D.mjs +7 -0
  44. package/lib/chunk-CULAOP3U.mjs +7 -0
  45. package/lib/chunk-D62KWDDT.mjs +7 -0
  46. package/lib/{chunk-OHWNPXWW.mjs → chunk-D7P7DTWL.mjs} +1 -1
  47. package/lib/{chunk-COFG7Q6R.mjs → chunk-DHGPDSXS.mjs} +1 -1
  48. package/lib/{chunk-WU3GLFZO.mjs → chunk-DHIW4IO5.mjs} +1 -1
  49. package/lib/{chunk-6XYKJSGX.mjs → chunk-DMBR24CK.mjs} +1 -1
  50. package/lib/chunk-DPYTG6DM.mjs +48 -0
  51. package/lib/{chunk-BY2HJFFG.mjs → chunk-DQR5NDMI.mjs} +1 -1
  52. package/lib/chunk-DXOXLUZA.mjs +7 -0
  53. package/lib/{chunk-YRQGKDHM.mjs → chunk-E2OBAWSH.mjs} +1 -1
  54. package/lib/chunk-E2YJVSX6.mjs +10 -0
  55. package/lib/{chunk-JWTSEDIQ.mjs → chunk-EAFLDSQ2.mjs} +1 -1
  56. package/lib/{chunk-MILU7WFN.mjs → chunk-EH5YUA5W.mjs} +1 -1
  57. package/lib/{chunk-BGUEWRK2.mjs → chunk-EOSEMFPU.mjs} +1 -1
  58. package/lib/chunk-ETT5GP4P.mjs +13 -0
  59. package/lib/{chunk-MYW5QNGI.mjs → chunk-FDGFUEK3.mjs} +1 -1
  60. package/lib/{chunk-NTFIRZP6.mjs → chunk-FLNLG43R.mjs} +1 -1
  61. package/lib/{chunk-CHYDMRSV.mjs → chunk-FSDO4DJA.mjs} +1 -1
  62. package/lib/{chunk-MJVTDA5Q.mjs → chunk-FSZTXLNW.mjs} +1 -1
  63. package/lib/{chunk-SOU4FRYN.mjs → chunk-FTA5LOVX.mjs} +1 -1
  64. package/lib/chunk-G4VXPS3A.mjs +7 -0
  65. package/lib/chunk-GF247DA7.mjs +7 -0
  66. package/lib/{chunk-BTWDMNN3.mjs → chunk-GK7VEYFM.mjs} +1 -1
  67. package/lib/{chunk-SE4QEZUG.mjs → chunk-GR3NGDVM.mjs} +1 -1
  68. package/lib/{chunk-3TJON4F3.mjs → chunk-GTIXJCGS.mjs} +1 -1
  69. package/lib/{chunk-NZC67CGR.mjs → chunk-GWRKS3AL.mjs} +1 -1
  70. package/lib/{chunk-XLXIPIEW.mjs → chunk-GYKNCYES.mjs} +1 -1
  71. package/lib/{chunk-WIO4XO4F.mjs → chunk-HFSBDM7B.mjs} +1 -1
  72. package/lib/{chunk-KDGMAGQR.mjs → chunk-HVC5CYIB.mjs} +1 -1
  73. package/lib/{chunk-WR4Q363I.mjs → chunk-HYBH5PFM.mjs} +1 -1
  74. package/lib/chunk-HYOOJVR6.mjs +7 -0
  75. package/lib/{chunk-5K5VLULK.mjs → chunk-IBURU7T7.mjs} +1 -1
  76. package/lib/chunk-ICIYL45C.mjs +7 -0
  77. package/lib/{chunk-QR3WELJQ.mjs → chunk-IKGHRYCN.mjs} +1 -1
  78. package/lib/chunk-IM2XA6JI.mjs +7 -0
  79. package/lib/{chunk-IWDREM66.mjs → chunk-J6G23RUI.mjs} +1 -1
  80. package/lib/{chunk-2BA2XKAY.mjs → chunk-JU2XEKEO.mjs} +1 -1
  81. package/lib/{chunk-MHMH6MTP.mjs → chunk-K55LH4ZQ.mjs} +1 -1
  82. package/lib/chunk-K5HV4YRO.mjs +7 -0
  83. package/lib/{chunk-M3ROUWDX.mjs → chunk-K77NR3UK.mjs} +1 -1
  84. package/lib/chunk-KE2PGD6C.mjs +7 -0
  85. package/lib/chunk-KGYXLSQ5.mjs +37 -0
  86. package/lib/{chunk-E5AHXLS6.mjs → chunk-KNIRA333.mjs} +1 -1
  87. package/lib/chunk-KOQV4WXC.mjs +8 -0
  88. package/lib/{chunk-L77FJZEP.mjs → chunk-KRNFVAGC.mjs} +1 -1
  89. package/lib/{chunk-MTMH6H2A.mjs → chunk-LCDPCUXS.mjs} +1 -1
  90. package/lib/{chunk-YAZO75G2.mjs → chunk-LNXBCE7E.mjs} +1 -1
  91. package/lib/{chunk-IZQZ6ZUF.mjs → chunk-LO527YLT.mjs} +1 -1
  92. package/lib/chunk-MAHZMPMZ.mjs +7 -0
  93. package/lib/{chunk-F6GUDTOB.mjs → chunk-MHW6DV6T.mjs} +1 -1
  94. package/lib/{chunk-2YIV2OB2.mjs → chunk-MIDBQ7SD.mjs} +1 -1
  95. package/lib/{chunk-FGRG7ANU.mjs → chunk-MKNAZPOT.mjs} +1 -1
  96. package/lib/{chunk-PZPJKATS.mjs → chunk-MNITSYI2.mjs} +8 -8
  97. package/lib/{chunk-OLSGVAIL.mjs → chunk-MO3N5XVV.mjs} +53 -53
  98. package/lib/chunk-MWLFFVQV.mjs +8 -0
  99. package/lib/chunk-N6HHNR6J.mjs +7 -0
  100. package/lib/chunk-N7J6NJQ6.mjs +7 -0
  101. package/lib/chunk-NJ3EOEHS.mjs +9 -0
  102. package/lib/chunk-NWPQF5XR.mjs +7 -0
  103. package/lib/{chunk-IG2MTQRP.mjs → chunk-NWVVCZUK.mjs} +1 -1
  104. package/lib/{chunk-2NBYT7GR.mjs → chunk-O6ADMP36.mjs} +1 -1
  105. package/lib/chunk-O7DAFE6M.mjs +14 -0
  106. package/lib/chunk-OEHVAJAB.mjs +7 -0
  107. package/lib/chunk-OETEC3P7.mjs +7 -0
  108. package/lib/{chunk-GCOB7K5N.mjs → chunk-OHEOJISY.mjs} +1 -1
  109. package/lib/chunk-OIIL4NVI.mjs +7 -0
  110. package/lib/chunk-OMZJ37JI.mjs +15 -0
  111. package/lib/{chunk-CEX3NEZL.mjs → chunk-ONMBSACW.mjs} +1 -1
  112. package/lib/chunk-OQQHNYR7.mjs +272 -0
  113. package/lib/{chunk-SOGQW4IG.mjs → chunk-OU5W7SCB.mjs} +1 -1
  114. package/lib/{chunk-O2HDYYUV.mjs → chunk-OVOLG3AL.mjs} +1 -1
  115. package/lib/{chunk-DYFALGRT.mjs → chunk-OXKZ4Y3B.mjs} +1 -1
  116. package/lib/{chunk-2GTBABKU.mjs → chunk-OZNLOV4U.mjs} +1 -1
  117. package/lib/{chunk-TYYOBZMU.mjs → chunk-PC247GKX.mjs} +1 -1
  118. package/lib/chunk-PPGDAUEQ.mjs +7 -0
  119. package/lib/{chunk-IGYH7GMA.mjs → chunk-PYUEHBA6.mjs} +1 -1
  120. package/lib/{chunk-TLH7AD35.mjs → chunk-PZBZ7MNC.mjs} +1 -1
  121. package/lib/{chunk-DBFJB2B6.mjs → chunk-QIRO4HTE.mjs} +1 -1
  122. package/lib/{chunk-BXU6WFMH.mjs → chunk-QXLZINZB.mjs} +1 -1
  123. package/lib/chunk-R2BJWO5N.mjs +20 -0
  124. package/lib/chunk-R6TF26V4.mjs +10 -0
  125. package/lib/{chunk-YKKRIEH4.mjs → chunk-RKALOKAU.mjs} +1 -1
  126. package/lib/chunk-SQGP46QS.mjs +7 -0
  127. package/lib/chunk-SW2NUKQL.mjs +9 -0
  128. package/lib/{chunk-MFG4MUIO.mjs → chunk-T26C576X.mjs} +1 -1
  129. package/lib/{chunk-LKQ5RKIV.mjs → chunk-T3PLRQ2T.mjs} +1 -1
  130. package/lib/chunk-T5VAULLQ.mjs +7 -0
  131. package/lib/{chunk-KYEDBS54.mjs → chunk-TEIBWMJM.mjs} +1 -1
  132. package/lib/chunk-TKQQVB2D.mjs +9 -0
  133. package/lib/{chunk-ELFXJHU7.mjs → chunk-TPHXRHOA.mjs} +1 -1
  134. package/lib/chunk-TQ2TQHTT.mjs +9 -0
  135. package/lib/{chunk-RPI7LRTW.mjs → chunk-TQM2XJ27.mjs} +1 -1
  136. package/lib/{chunk-IOIWJ3DJ.mjs → chunk-UCHAZ4ZU.mjs} +1 -1
  137. package/lib/{chunk-G35N4P7D.mjs → chunk-UIUPPEFB.mjs} +1 -1
  138. package/lib/{chunk-DBB3EMIN.mjs → chunk-UT27HXE7.mjs} +1 -1
  139. package/lib/{chunk-KBJ5VERV.mjs → chunk-UUSLTW5V.mjs} +1 -1
  140. package/lib/chunk-V2QO6KOE.mjs +19 -0
  141. package/lib/chunk-V473C7LY.mjs +7 -0
  142. package/lib/chunk-V4RKM4QZ.mjs +8 -0
  143. package/lib/chunk-VSU74RQ3.mjs +9 -0
  144. package/lib/chunk-VV3B6IC3.mjs +7 -0
  145. package/lib/chunk-W2AAGIZF.mjs +7 -0
  146. package/lib/{chunk-WR2GIKWE.mjs → chunk-WB2RIVO3.mjs} +1 -1
  147. package/lib/chunk-WD47PGUS.mjs +10 -0
  148. package/lib/{chunk-HEKAZJRH.mjs → chunk-WEZLXE34.mjs} +1 -1
  149. package/lib/{chunk-W622GUAW.mjs → chunk-WI4HYWV6.mjs} +1 -1
  150. package/lib/{chunk-WA7EYLAQ.mjs → chunk-WM5JI4JI.mjs} +1 -1
  151. package/lib/chunk-WWTXRWNZ.mjs +7 -0
  152. package/lib/{chunk-7EANH5PY.mjs → chunk-WZQEK4WT.mjs} +1 -1
  153. package/lib/{chunk-FXXLX4O6.mjs → chunk-X2ZVSQ54.mjs} +1 -1
  154. package/lib/{chunk-ZVAED4QV.mjs → chunk-XC2QKQT5.mjs} +1 -1
  155. package/lib/chunk-XC54KKKC.mjs +7 -0
  156. package/lib/chunk-XEB6HZ34.mjs +7 -0
  157. package/lib/chunk-XGKSSCW7.mjs +7 -0
  158. package/lib/chunk-XIZ5LMQM.mjs +7 -0
  159. package/lib/{chunk-74Q6DORA.mjs → chunk-Y5ZCPY36.mjs} +1 -1
  160. package/lib/{chunk-UNJA4J37.mjs → chunk-YCSFP6ER.mjs} +4 -4
  161. package/lib/{chunk-X5JYBPXP.mjs → chunk-YHIOS2PU.mjs} +1 -1
  162. package/lib/chunk-YIGFYZQY.mjs +7 -0
  163. package/lib/chunk-YJEXE6HZ.mjs +925 -0
  164. package/lib/{chunk-TTKXMDBN.mjs → chunk-YOGMP72T.mjs} +4 -4
  165. package/lib/chunk-ZRUDYB7O.mjs +7 -0
  166. package/lib/{chunk-CU2INBND.mjs → chunk-ZUA5BNAO.mjs} +1 -1
  167. package/lib/chunk-ZWCRWF7E.mjs +7 -0
  168. package/lib/{chunk-N652NMZ4.mjs → chunk-ZWZXQTAK.mjs} +52 -52
  169. package/lib/sandforge-autopilot.mjs +11 -11
  170. package/lib/sandforge-backup.mjs +63 -32
  171. package/lib/sandforge-checkpoint.mjs +1 -348
  172. package/lib/sandforge-cleanup.mjs +1 -1
  173. package/lib/sandforge-clone.mjs +1 -1
  174. package/lib/sandforge-compare.mjs +1 -1
  175. package/lib/sandforge-dataops.mjs +1 -1
  176. package/lib/sandforge-empty.mjs +11 -11
  177. package/lib/sandforge-env.mjs +104 -104
  178. package/lib/sandforge-frozen.mjs +1 -266
  179. package/lib/sandforge-mcp.mjs +33 -14
  180. package/lib/sandforge-monitor.mjs +1 -1
  181. package/lib/sandforge-pipeline.mjs +88 -0
  182. package/lib/sandforge-seed.mjs +1 -1
  183. package/lib/sandforge-sync.mjs +1 -1
  184. package/lib/sandforge.mjs +6 -6
  185. package/package.json +2 -1
  186. package/lib/chunk-2CNCDM56.mjs +0 -7
  187. package/lib/chunk-3F6Q5E7I.mjs +0 -14
  188. package/lib/chunk-4VS2V6WU.mjs +0 -25
  189. package/lib/chunk-5P4PHJRL.mjs +0 -9
  190. package/lib/chunk-5TC3QB4U.mjs +0 -10
  191. package/lib/chunk-7ABODJ4G.mjs +0 -7
  192. package/lib/chunk-7EGQP6S4.mjs +0 -7
  193. package/lib/chunk-7FFGJWHN.mjs +0 -7
  194. package/lib/chunk-7YDNUBO5.mjs +0 -7
  195. package/lib/chunk-A527W53V.mjs +0 -7
  196. package/lib/chunk-ADOAS63R.mjs +0 -7
  197. package/lib/chunk-B5QQJ4SI.mjs +0 -7
  198. package/lib/chunk-CION3VMZ.mjs +0 -7
  199. package/lib/chunk-CSBS5U5I.mjs +0 -7
  200. package/lib/chunk-DB7RBE5D.mjs +0 -7
  201. package/lib/chunk-E5ZB3LU5.mjs +0 -7
  202. package/lib/chunk-EFR2Y7E4.mjs +0 -7
  203. package/lib/chunk-EHQ3FX6X.mjs +0 -7
  204. package/lib/chunk-EQNW3UC2.mjs +0 -7
  205. package/lib/chunk-F43REJDZ.mjs +0 -10
  206. package/lib/chunk-GSG7WZHM.mjs +0 -7
  207. package/lib/chunk-HOJYWTP7.mjs +0 -20
  208. package/lib/chunk-HS4YRX4J.mjs +0 -7
  209. package/lib/chunk-I7O6C2B5.mjs +0 -8
  210. package/lib/chunk-IFETCRWE.mjs +0 -10
  211. package/lib/chunk-IQXHJEYB.mjs +0 -7
  212. package/lib/chunk-JPUR2CFX.mjs +0 -10
  213. package/lib/chunk-K327QKMD.mjs +0 -7
  214. package/lib/chunk-KRCA6IPH.mjs +0 -8
  215. package/lib/chunk-LPBMBW3O.mjs +0 -13
  216. package/lib/chunk-LWW4U276.mjs +0 -7
  217. package/lib/chunk-MJU2PGZQ.mjs +0 -15
  218. package/lib/chunk-OAZRPP4I.mjs +0 -7
  219. package/lib/chunk-OO6CLPEH.mjs +0 -7
  220. package/lib/chunk-OPXCV2KL.mjs +0 -7
  221. package/lib/chunk-P33PSCXK.mjs +0 -7
  222. package/lib/chunk-Q3DM32KF.mjs +0 -11
  223. package/lib/chunk-QROPNEGY.mjs +0 -14
  224. package/lib/chunk-QWT2C74M.mjs +0 -7
  225. package/lib/chunk-R3X3LV64.mjs +0 -14
  226. package/lib/chunk-RMBPOTD7.mjs +0 -7
  227. package/lib/chunk-SIHORWVK.mjs +0 -7
  228. package/lib/chunk-T62WNR54.mjs +0 -7
  229. package/lib/chunk-TTFDUKUS.mjs +0 -47
  230. package/lib/chunk-VE6XKGGD.mjs +0 -7
  231. package/lib/chunk-VGW4MXXZ.mjs +0 -7
  232. package/lib/chunk-VS7ZXUII.mjs +0 -824
  233. package/lib/chunk-VXQLDM4R.mjs +0 -7
  234. package/lib/chunk-VYXMVJL5.mjs +0 -7
  235. package/lib/chunk-W7U5E5ZL.mjs +0 -9
  236. package/lib/chunk-WXAQ7FK3.mjs +0 -115
  237. package/lib/chunk-YS4G22C2.mjs +0 -7
  238. package/lib/chunk-ZM6OJGIG.mjs +0 -7
  239. package/lib/chunk-ZUTYVST5.mjs +0 -7
@@ -0,0 +1,8 @@
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 te}from"./chunk-YIGFYZQY.mjs";import{c as nt,d as ot}from"./chunk-2Z54GB6X.mjs";import{i as et,k as tt}from"./chunk-R6TF26V4.mjs";import{a as st,b as it,c as rt,d as at,e as ct,f as dt,h as lt}from"./chunk-V4RKM4QZ.mjs";import{d as He,j as Ke}from"./chunk-JU2XEKEO.mjs";import{c as Oe,d as Ce,p as Ge}from"./chunk-OMZJ37JI.mjs";import{a as Te}from"./chunk-43K2C6H2.mjs";import{h as ze,i as Ve}from"./chunk-AITNZWLB.mjs";import{A as _e,C as Ue,t as Be,u as We,z as q}from"./chunk-6SEDOIO3.mjs";import{A as qe,B as x,D as ee,G as Ze,b as je,f as Re,h as Ne,i as Q,j as X,k as Fe,n as Le,o as Ie,r as xe,t as Z,u as Je,v as Qe,w as Xe,z as Ye}from"./chunk-ETT5GP4P.mjs";import{A as ve,B as I,H as Ee,K as $e,a as De,e as Me,o as Y,z as Pe}from"./chunk-E2YJVSX6.mjs";import{f as H}from"./chunk-SQGP46QS.mjs";import{E as Se}from"./chunk-XEB6HZ34.mjs";import{f as be,g as ke,h as L,m as we,n as ye,o as K,t as Ae,u as J}from"./chunk-EAFLDSQ2.mjs";import{b as v}from"./chunk-CA5NAXSU.mjs";import{$d as he,Va as me,Wa as $,Za as ge,vc as F}from"./chunk-DPYTG6DM.mjs";import{b as pe,k as fe,l as V}from"./chunk-WZQEK4WT.mjs";import{readdir as It,rm as gt,stat as ht}from"node:fs/promises";import{existsSync as xt,readFileSync as Bt,writeFileSync as Wt}from"node:fs";import{hostname as _t}from"node:os";import{join as oe}from"node:path";var Gt=5e5,B=1e6,Ut=100,zt="taking",ut=500;function Xn(e){let t=Ne(e),n=[H(e)];return{get version(){return e.version},request:o=>t.request(o),query:(o,s)=>t.query(o,s),queryMore:o=>t.queryMore(o),describeGlobal:async()=>await e.describeGlobal(),toolingObjects:async()=>{try{return(await e.tooling.describeGlobal()).sobjects.map(s=>s.name)}catch{return[]}},serverTime:async()=>(await e.soap.getServerTimestamp()).timestamp,userId:async()=>(await e.soap.getUserInfo()).userId,requestsSent:()=>n.reduce((o,s)=>o+s(),0),countAlso:o=>{n.push(H(o))}}}function Vt(e){return Fe(ze(e))}var D=class extends Error{constructor(){super("The checkpoint was stopped before it was taken: nothing of it was kept."),this.name="CheckpointTakeStopped"}},W="No record was read.",Ht={excludedByUser:"Left out as asked.",notFound:"The org has no object of this name.",chatter:"Chatter posts, comments and feeds are left out: Salesforce brings a post back only with what it was posted on.",history:"History is left out: it is the org's own trace of changes.",sharing:"Sharing is left out: the org keeps it itself.",changeEvent:"Change events are left out.",unsupportedKind:"Left out: neither the recycle bin nor an update reaches this kind of object as it reaches a record.",customSetting:"Custom settings are left out unless you pick them as custom settings: they are configuration, which a rewind sets back.",notCustomSetting:"Picked as a custom setting: the org has no custom setting of this name.",files:"Documents of the Documents tab are left out: they are shared content kept in folders, as setup is.",heldWithFiles:"Held with its file (ContentDocument): Salesforce neither deletes nor brings back a file's version on its own, and reads the links of a file through the records they tie it to.",setup:"Users, permissions and setup are left out, and so are the org's own logs and jobs.",platformCreated:"Left out: Salesforce alone creates its records, such as approvals, Einstein insights, Data.com clean info and invoices, and no permission lets a user create one.",metadata:"Left out: it is metadata, which a checkpoint doesn't hold.",notWritable:"Left out: the user SandForge connects as may not create, edit and delete its records.",notDescribed:"Left out: the org would not describe it.",noSystemModstamp:"Left out: it has no SystemModstamp, so nothing would tell a record changed since.",noRecycleBin:"Left out: the org deletes its records for good, with no recycle bin, so nothing would tell one deleted since, nor bring it back.",unreadable:"Left out: the org refuses to read it whole.",noViewAll:"Without View All Data and Modify All Data, an object is held only with View All and Modify All on it, and the user SandForge connects as has neither on this one: a record they cannot see would read as deleted since.",noModifyAll:"Without View All Data and Modify All Data, an object is held only with View All and Modify All on it, and the user SandForge connects as has View All on this one, not Modify All: a rewind could not put back what others changed.",activities:"Without View All Data and Modify All Data, tasks and events are left out: Salesforce has no View All for activities, and a private one linked to no record stays out of sight.",catalog:"Without View All Data and Modify All Data, products and price books are left out: Salesforce has no View All or Modify All for them.",filesNotProven:"Without View All Data and Modify All Data, files are left out: nothing proves the user sees every file.",settingNotProven:"Without View All Data and Modify All Data, custom settings are left out: no permission on an object proves the user sees and writes every row.",parentNotSeen:"Without View All Data and Modify All Data, an object with no permissions of its own is held only when the user has View All and Modify All on every record it hangs from, which is not proven here."};function bt(e){let t=Ht[e.reason],n=e.detail===void 0?t:`${t.replace(/\.$/,"")} (${e.detail}).`;return{objectApiName:e.objectApiName,code:e.reason,reason:pt(n),...e.detail===void 0?{}:{detail:pt(e.detail)}}}function Kt(e,t,n){return{objectApiName:e,code:"pastTheLimit",records:t,limit:n,reason:t>B?`${e} has ${t} records, more than any checkpoint holds of one object (${B}): left out of the checkpoint, and a rewind to it does not touch ${e}. Data Export, in Setup, or a Bulk API query keeps a copy of it.`:`${e} has ${t} records, past the checkpoint's limit of ${n} for one object: left out of the checkpoint, as part of it would be taken for all of it.`}}function Jt(e,t){let n=t;for(;;){let o=e.filter(s=>s<=Math.min(n,B)).reduce((s,r)=>s+r,0);if(o<=n)return n;n=o}}function pt(e){return e.length<=ut?e:`${e.slice(0,ut-1)}\u2026`}function kt(e,t){return{code:"RUN_WRITING",message:`${t.operation==="take"?`A checkpoint of ${e} is being taken`:t.operation==="rewind"?`A rewind is writing to ${e}`:t.operation==="undo"?`An undo is writing to ${e}`:t.operation==="empty"?`An emptying of its objects is writing to ${e}`:`SandForge is deleting checkpoints of ${e}`} (process ${t.pid} on ${t.host}): take the checkpoint once it has ended. ${W}`}}function wt(e){return typeof e!="object"||e===null?void 0:typeof e.errorCode=="string"?v(e):void 0}function _(e,t){return e instanceof Q||e instanceof Te||e instanceof D||t?.aborted===!0}var Qt=V({sobjects:fe(be)}).loose();function M(e){return e.toLowerCase()===ke.toLowerCase()}function Xt(e,t,n){if(e===void 0)return{why:`the org lists no ${L}`};let o=t.get(e);if(o===void 0)return{why:n.get(e)??"it was not described"};let r=o.fields.find(d=>d.name.toLowerCase()==="linkedentityid")?.referenceTo??[];return r.length===0?{why:"its describe names no record a link ties a file to"}:{linkable:new Set(r.map(d=>d.toLowerCase()))}}async function se(e,t,n){let o=new Map,s=new Map,r=0,d=await Promise.allSettled(n.map(p=>t.describe(p)));for(let[p,i]of d.entries()){let c=n[p],l;if(i.status==="fulfilled"&&"body"in i.value)l=i.value.body;else{if(i.status==="rejected"&&i.reason instanceof Q)throw i.reason;r++;try{l=await e.request({method:"GET",url:`/services/data/v${e.version}/sobjects/${F(c)}/describe`})}catch(h){let a=wt(h);if(a===void 0)throw new Error(`The org did not answer the describe of ${c}: ${v(h)}`);s.set(c,a);continue}}let u=He.safeParse(l);u.success?o.set(c,u.data):s.set(c,"its describe does not read as one")}return{describes:o,errors:s,alone:r}}async function yt(e,t,n){let o=Qt.parse(await e.describeGlobal()),s=await e.toolingObjects?.()??[],r=ye(o.sobjects,{mode:n.mode,...n.objects?{objects:n.objects}:{},...n.excluded?{excluded:n.excluded}:{},...n.customSettings?{customSettings:n.customSettings}:{}},s),d=r.candidates.some(M),p=d?o.sobjects.find(m=>m.name.toLowerCase()===L.toLowerCase())?.name:void 0,i=p===void 0?r.candidates:[...r.candidates,p],{describes:c,errors:l,alone:u}=await se(e,t,i),h,a;if(d){let m=Xt(p,c,l);"linkable"in m?h=m.linkable:a=m.why,p!==void 0&&c.delete(p)}let g=Ae(r,c,l);if(a!==void 0){let m=g.objects.find(({objectApiName:C})=>M(C));m!==void 0&&(g=J(g,new Map([[m.objectApiName,`its links to records, ${L}, could not be described: ${a}`]])))}let w=await je(async m=>(await e.query(m)).records),A=new Map(o.sobjects.map(m=>[m.name,ft(m)])),S=o.sobjects.filter(we),f=new Set(S.map(m=>m.name)),k=[...c.values()],y=[];for(let m of g.objects){let C=c.get(m.objectApiName);C&&y.push({scoped:m,label:A.get(m.objectApiName)??m.objectApiName,describe:C,capture:await Ke(C,k,{viewsEncryptedData:w}),...f.has(m.objectApiName)?{customSetting:K(C)}:{}})}return{described:i.length,describedAlone:u,objects:y,leftOut:g.leftOut,addedToPicked:r.addedToPicked,...h!==void 0&&y.some(({scoped:m})=>M(m.objectApiName))?{linkable:h}:{},settings:S.map(m=>({objectApiName:m.name,label:ft(m)}))}}function ft(e){let t=e.label;return typeof t=="string"&&t!==""?t:e.name}async function Yt(e,t,n,o){let s=await ee(t,n.map(({capture:i})=>({objectApiName:i.objectApiName,readMode:i.readMode})),o),r=new Map,d=new Map,p=0;for(let[i,c]of s.entries()){let{objectApiName:l,readMode:u}=n[i].capture;if("count"in c){r.set(l,c.count);continue}p++;let h=Qe(l,u);try{let a=await e.query(h.soql,{scanAll:h.scanAll});if(typeof a.totalSize!="number")throw new Error("The org gave no count of its records.");r.set(l,a.totalSize)}catch(a){let g=wt(a);if(g===void 0)throw new Error(`The org did not count the records of ${l}: ${v(a)}`);d.set(l,g)}}return{counts:r,refused:d,alone:p}}function At(e,t){return t?.has(e.toLowerCase())===!0&&!M(e)}async function qt(e,t,n,o,s){let r=[];for(let{objectApiName:i,records:c}of t){let l=F(i);r.push({objectApiName:l,soql:`SELECT COUNT() FROM ${l} WHERE IsDeleted = true AND SystemModstamp < ${Z(o)}`,scanAll:!0,counts:"inBin"}),c!==0&&(r.push({objectApiName:l,soql:`SELECT COUNT() FROM ${l} WHERE SystemModstamp >= ${Je(o)}`,scanAll:!0,counts:"stampedSince"}),At(l,n)&&r.push({...et(l),counts:"links"}))}let d=await Ye(e,r,()=>{},s),p=new Map;return d.forEach((i,c)=>{let{objectApiName:l,counts:u}=r[c],h=i.read?i.totalSize:void 0,a=p.get(l)??{};u==="links"?a.links=h??null:h!==void 0&&(a[u]=h),p.set(l,a)}),{asked:r.length,of:p}}function St({scoped:e,capture:t,customSetting:n,access:o},s,r,d){return{objectApiName:e.objectApiName,records:s,inBin:r,readOrder:e.readOrder,readMode:t.readMode,undeletable:t.undeletable,cascadeParents:t.cascadeParents,restrictParents:t.restrictParents,fingerprint:d,fields:t.fields,leftOutFields:t.leftOutFields,...n!==void 0?{customSetting:n}:{},...o!==void 0?{access:o}:{}}}function Ot(e){return{personAccounts:rt(e.map(({describe:t})=>t)),catalog:at(e.map(({scoped:t})=>t.objectApiName))}}function Zt(e){let t=e?.orgType==="Sandbox"||e?.orgType==="Scratch";return Oe(Ce(t)).defaultQueryLimit}async function Ct(e,t,n,o,s,r,d,p=Tt){let i=n.maxTotal??Gt;if(!Number.isInteger(i)||i<1)throw new RangeError(`Not a number of records: ${i}`);let c=Math.min(i,B),{counts:l,refused:u,alone:h}=await Yt(e,t,o.objects,d),a=J({mode:n.mode,objects:o.objects.map(({scoped:b})=>b),leftOut:o.leftOut,packages:[]},u),g=new Map(o.objects.map(b=>[b.scoped.objectApiName,b])),w=a.leftOut.map(bt),A=[];for(let b of a.objects){let O=g.get(b.objectApiName),P=l.get(b.objectApiName);if(!(O===void 0||P===void 0)){if(P>c){w.push(Kt(b.objectApiName,P,c));continue}A.push({...O,scoped:{...b,readOrder:A.length},records:P,otherGroups:Be(b.objectApiName,O.capture.fields,O.capture.readMode),recount:{}})}}let S=A.some(({scoped:b})=>M(b.objectApiName))?o.linkable:void 0,f=await qt(t,A.map(({scoped:b,records:O})=>({objectApiName:b.objectApiName,records:O})),S,r,d);for(let b of A)b.recount=f.of.get(b.scoped.objectApiName)??{};w.sort((b,O)=>b.objectApiName<O.objectApiName?-1:b.objectApiName>O.objectApiName?1:0);let k={};for(let{scoped:b,describe:O}of A)k[b.objectApiName]=De(O.fields);let y=en(p,We({described:o.described,describedAlone:o.describedAlone,counted:o.objects.length,countedAlone:h,recounted:f.asked,objects:A.map(b=>({records:b.records,otherGroups:b.otherGroups,...b.recount,entry:St(b,b.records,0,k[b.scoped.objectApiName].digest)})),pageRows:Zt(n.registered),leftOut:w,printsBytes:(await $e(k)).length,annexCalls:ct(Ot(A))})),m={...y,apiRequestsLeft:s.remaining},C={objects:A,leftOut:w,estimate:m,objectLimit:c,prints:k,...S!==void 0?{linkable:S}:{}};if(y.records>i){let b=[...A.map(O=>O.records),...w.flatMap(O=>O.code==="pastTheLimit"?[O.records??0]:[])];return{...C,refusal:{code:"TOO_MANY_RECORDS",message:`The objects this checkpoint would keep hold ${y.records} records in ${n.orgName}, past its limit of ${i}: pick fewer objects. ${W}`,holdingLimit:Jt(b,y.records)}}}let R=_e("take",y.apiRequests,s,n.orgName);return R===void 0?C:{...C,refusal:R}}function jt(e){return{query:t=>e.query(t),queryMore:t=>e.queryMore(t)}}var Tt={guard:0,scope:0};function en(e,t){if(e.guard+e.scope===0)return t;let n=t.requestsByPhase;return{...t,apiRequests:t.apiRequests+e.guard+e.scope,...n!==void 0?{requestsByPhase:{...n,guard:n.guard+e.guard,scope:n.scope+e.scope}}:{}}}function tn(e){let t=[...e.mode==="picked"?e.objects??[]:[],...Array.isArray(e.customSettings)?e.customSettings:[]];return new Set(t.map(n=>n.toLowerCase()))}function nn(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}async function Rt(e,t,n,o,s,r){if(s.kind==="org")return{scope:{...o,objects:o.objects.map(f=>({...f,access:"org"}))},reads:Tt};let d=o.objects.map(({scoped:f})=>f.objectApiName),p={grants:s.objects,describes:o.objects.map(({describe:f})=>f),customSettings:o.objects.filter(({customSetting:f})=>f!==void 0).map(({scoped:f})=>f.objectApiName)},i=nt(d,p),c=[],l=0;if(i.length>0)try{let f=await se(e,t,i);c=[...f.describes.values()],l=Math.ceil(i.length/Re)+f.alone}catch(f){if(_(f,r))throw f}let u=ot(d,{...p,describes:[...p.describes,...c]}),h=tn(n),a=[],g=[...o.leftOut],w=[];for(let f of o.objects){let k=f.scoped.objectApiName,y=u.get(k);if(y!==void 0&&"access"in y){a.push({...f,access:y.access});continue}let m={objectApiName:k,reason:y?.reason??"noViewAll",...y?.detail!==void 0?{detail:y.detail}:{}};g.push(m),h.has(k.toLowerCase())&&n.unprovenLeftOut!==!0&&w.push(m)}let A=new Set(a.map(({scoped:f})=>f.objectApiName)),S={scope:{...o,objects:a,leftOut:g,addedToPicked:o.addedToPicked.filter(f=>A.has(f))},reads:{guard:s.requests,scope:l}};if(w.length>0){let f=w.length===1;return{...S,refusal:{code:"PERMISSIONS",message:`${n.username} doesn't have View All Data and Modify All Data, and the checkpoint can't hold ${nn(w.map(k=>k.objectApiName))}, asked for by name. ${w.map(k=>`${k.objectApiName}: ${bt(k).reason}`).join(" ")} Leave ${f?"it":"them"} out, or give the user View All Data and Modify All Data. ${W}`}}}return a.length===0&&o.objects.length>0?{...S,refusal:{code:"PERMISSIONS",message:`${n.username} doesn't have View All Data and Modify All Data, nor View All and Modify All on any object this checkpoint would hold: without them, a checkpoint holds only the objects its user sees and puts back whole. Give the user View All and Modify All on the objects to hold, or View All Data and Modify All Data. `+W}}:S}function on(e){return e.objects.map(({scoped:t,label:n,capture:o,records:s,customSetting:r,access:d})=>({objectApiName:t.objectApiName,label:n,...t.namespace!==void 0?{namespace:t.namespace}:{},records:s,undeletable:o.undeletable,leftOutFields:o.leftOutFields,...r!==void 0?{customSetting:r}:{},...d!==void 0?{access:d}:{}}))}function Nt(e){let t=e.customSettings;return t!==void 0&&(t==="all"||t.length>0)}async function sn(e,t,n,o,s){let r=new Map(o.objects.map(u=>[u.scoped.objectApiName,u])),d=n.settings.filter(({objectApiName:u})=>!r.has(u)),p=new Map;if(d.length>0)try{({describes:p}=await se(e,t,d.map(({objectApiName:u})=>u)))}catch(u){if(_(u,s))throw u}let i=d.filter(({objectApiName:u})=>p.has(u)),c=await ee(t,i.map(({objectApiName:u})=>({objectApiName:u,readMode:"query"})),s),l=new Map;return c.forEach((u,h)=>{"count"in u&&l.set(i[h].objectApiName,u.count)}),n.settings.map(({objectApiName:u,label:h})=>{let a=r.get(u);if(a?.customSetting!==void 0)return{objectApiName:u,label:h,kind:a.customSetting,records:a.records};let g=p.get(u),w=l.get(u);return{objectApiName:u,label:h,...g!==void 0?{kind:K(g)}:{},...w!==void 0?{records:w}:{}}})}var rn={records:0,apiRequests:0,apiRequestsLeft:0,seconds:0,bytes:0};async function Yn(e,t){let n={mode:t.mode,objects:[],leftOut:[],estimate:rn},o=await te(jt(e.org),{act:"take",orgName:t.orgName,registered:t.registered,username:t.username,customSettings:Nt(t)},{userId:()=>e.org.userId()});if(!o.allowed)return{...n,refusal:o.refusal};let s=e.store.heldBy(o.org.id),r=s===void 0?await e.runWriting?.(o.org.id):void 0,d=X(e.org,e.signal);try{let p=await q(e.org,t.orgName),i=await Rt(e.org,d,t,await yt(e.org,d,t),o.grants,e.signal),{scope:c}=i,l=await e.org.serverTime(),u=await Ct(e.org,d,t,c,p,l,e.signal,i.reads),h={mode:t.mode,objects:on(u),leftOut:u.leftOut,estimate:u.estimate,files:{held:u.objects.some(({scoped:g})=>M(g.objectApiName)),queryAllFiles:o.queryAllFiles,addedToPicked:c.addedToPicked},customSettings:await sn(e.org,d,c,u,e.signal)},a=s!==void 0?kt(t.orgName,s):r!==void 0?{code:"RUN_WRITING",message:r}:i.refusal??u.refusal;return a===void 0?h:{...h,refusal:a}}catch(p){throw _(p,e.signal)?new D:p}}function an(e){let t=e.requestsSent?()=>e.requestsSent?.()??0:void 0,n={guard:0,scope:0,start:0,counts:0,bin:0,snapshot:0,stability:0},o="guard",s=t?.()??0,r=()=>{if(!t)return;let d=t();n[o]+=d-s,s=d};return{enter(d){r(),o=d},requests(){return t?(r(),{total:Object.values(n).reduce((p,i)=>p+i,0),byPhase:{...n}}):void 0}}}async function cn(e,t){if(t.edition!==void 0)return t.edition;let o=(await e.query("SELECT OrganizationType FROM Organization LIMIT 1")).records[0]?.OrganizationType;if(typeof o!="string"||o==="")throw new Error("The org did not say its edition (Organization.OrganizationType).");return o}var dn="Automated Process";async function ln(e){let n=(await e.query("SELECT Id, Name FROM User WHERE UserType = 'AutomatedProcess'")).records.filter(s=>typeof s.Id=="string"),o=n.find(s=>s.Name===dn);return o!==void 0?o.Id:n.length===1?n[0].Id:void 0}function Dt(e){let t=new Date(Date.parse(e)).toISOString();return`${t.slice(0,10)} ${t.slice(11,16)} UTC`}function mt(e,t){return e.split(he).join(Dt(t))}function ne(e){let t=Se(e);return t===null?Number.NaN:Date.parse(t)}function Mt(e){return typeof e=="string"&&e.length>=15?e.slice(0,15):void 0}async function un(e,t){let n=new Set;for await(let o of x(Y(e,t))){let s=Mt(o.Id);s!==void 0&&n.add(s)}return n}async function pn(e,t,n,o,s,r){let d={changed:0,deleted:0,created:0};if(!o.live&&!o.deleted)return d;let p=await xe.read(e,t,n);if(o.live)for await(let i of x(o.live.file)){let c=ne(i.SystemModstamp);if(!(c<=r))continue;let l=p.stampOf(i.Id);l===void 0?d.created++:l!==c&&d.changed++}if(o.deleted){let i;for await(let c of x(o.deleted.file)){if(!(ne(c.SystemModstamp)<=r))continue;if(p.has(c.Id)){d.deleted++;continue}if(!(ne(c.CreatedDate)<s))continue;i??=await un(e,n);let l=Mt(c.Id);l!==void 0&&!i.has(l)&&d.deleted++}}return d}async function Pt(e){let t=0;for(let n of await It(e,{withFileTypes:!0})){let o=oe(e,n.name);n.isDirectory()?t+=await Pt(o):n.isFile()&&(t+=(await ht(o)).size)}return t}async function fn(e,t){let n=await Pt(e.dir)-(await ht(e.checkpointFile)).size,o=r=>Buffer.byteLength(`${JSON.stringify({...t,bytes:r},null,2)}
8
+ `,"utf8"),s=n+o(n);return s=n+o(s),s}function mn(e){let t=e.snapshotsFile,n=new Ue({getData:()=>xt(t)?JSON.parse(Bt(t,"utf8")):{},setData:o=>Wt(t,JSON.stringify(o,null,2),{encoding:"utf8",mode:384})});return n.initialize(),n}var gn=V({organizationId:pe().optional()}).loose();async function hn(e,t,n,o,s){let r=mn(e),d=0,p={log:n.handler.log,orgManager:n.handler.orgManager,orgRegistry:n.handler.orgRegistry,configStore:r,broker:{postToWebview:c=>{if(c.type!=="operation:progress")return;let l=c.payload;typeof l.percentage=="number"&&typeof l.currentStep=="string"&&s(l.percentage,l.currentStep)}},services:{getSandforgeSetting:(c,l)=>c==="backup.maxRecordsPerObject"?o:l},nextId:()=>`${e.checkpointId}-${++d}`},i=new Ge(p);return i.setBackupRecordStore(new Ve(t)),await i.swept(),{handler:i,config:r}}function bn(e,t){return e.slice(0,15)===t.slice(0,15)}async function qn(e,t){let{org:n,store:o,signal:s}=e,r=e.now??(()=>new Date),d=me.parse([...t.ignoredFields??[]]),p=t.name===void 0?void 0:$.parse(t.name),i=t.nameWithDate;i!==void 0&&$.parse(mt(i,r().toISOString()));let c=t.customSettings==="all"?[]:t.customSettings??[];for(let y of[...t.objects??[],...t.excluded??[],...c])F(y);let l=t.beforeRun===void 0?void 0:ge.parse(t.beforeRun),u=t.keepDays??Me;I(r(),u);let h=(y,m,C=0,R=0)=>e.onProgress?.({percentage:Math.round(y),processedObjects:C,totalObjects:R,step:m});h(0,`Checking ${t.orgName}`);let a=an(n),g=await te(jt(n),{act:"take",orgName:t.orgName,registered:t.registered,username:t.username,customSettings:Nt(t)},{userId:()=>n.userId()});if(!g.allowed)return{taken:!1,refusal:g.refusal};let w=g.org.id,A=ve("ck",r()),S=o.lock(w,"take",A);if("busy"in S)return{taken:!1,refusal:kt(t.orgName,S.busy)};let f,k;try{let y=await e.runWriting?.(w);if(y!==void 0)return{taken:!1,refusal:{code:"RUN_WRITING",message:y}};let m=X(n,s),C=await cn(n,g.org),R=await q(n,t.orgName);h(2,`Reading the objects of ${t.orgName}`),a.enter("scope");let b=await Rt(n,m,t,await yt(n,m,t),g.grants,s);if(b.refusal!==void 0)return{taken:!1,refusal:b.refusal};let{scope:O}=b;a.enter("start");let P=await n.userId(),ie=await ln(n),N=await n.serverTime();h(8,`Counting the records of ${O.objects.length} objects`),a.enter("counts");let T=await Ct(n,m,t,O,R,N,s,b.reads);if(T.refusal!==void 0)return{taken:!1,refusal:T.refusal};if(T.objects.length===0)throw new Error(`None of the objects asked for can be kept in a checkpoint of ${t.orgName}: ${T.leftOut.map(j=>`${j.objectApiName}: ${j.reason}`).join(" ")||"there are none."}`);if(s?.aborted)throw new D;f=await o.create(w,A);let E=`snapshot-${A}`;k={version:1,checkpointId:A,name:p??(i!==void 0?$.parse(mt(i,N)):Dt(N)),org:{organizationId:w,...t.alias!==void 0?{alias:t.alias}:{},username:t.username,instanceUrl:t.instanceUrl,isSandbox:g.org.sandbox,organizationType:C,tier:g.tier,...t.scratchExpiresAt!==void 0?{scratchExpiresAt:t.scratchExpiresAt}:{},...R.dataStorageMaxMB!==void 0?{dataStorageMaxMB:R.dataStorageMaxMB}:{},...t.registered?.staging===!0&&g.org.sandbox?{staging:!0}:{}},takenBy:{userId:P,...ie!==void 0?{automatedProcessUserId:ie}:{},viewAllData:g.grants.kind==="org"||g.grants.viewAllData,modifyAllData:g.grants.kind==="org"||g.grants.modifyAllData,queryAllFiles:g.queryAllFiles},readFrom:N,takenAt:N,scope:{mode:t.mode,leftOut:T.leftOut},objects:[],ignoredFields:d,snapshotId:E,movedWhileTaken:{changed:0,deleted:0,created:0},bytes:0,expiresAt:I(r(),u),status:"taking",takenOn:{host:_t(),pid:process.pid},...l!==void 0?{beforeRun:l}:{}},await o.write(k),h(12,"Reading the recycle bin as it was at the checkpoint"),a.enter("bin");let vt=await qe(m,T.objects.map(({scoped:j})=>({...Xe(j.objectApiName,N),file:Y(f,j.objectApiName)})),s),re=new Map;for(let j of vt){if(!j.read)throw new Error(`The recycle bin of ${j.objectApiName} could not be read whole: ${j.reason}`);re.set(j.objectApiName,j.rows)}a.enter("snapshot");let{records:Et,files:ae}=await kn(f,E,T,t,e,w,m,h);h(88,`Reading the record types, users and queues ${t.orgName} names`);let $t=await wn(f,E,T,m,w,s);h(89,"Reading the time on the org"),a.enter("stability");let ce=await n.serverTime();h(90,`Checking what changed in ${t.orgName} while it was read`);let{movedWhileTaken:Ft,notChecked:Lt}=await yn(f,E,T,m,N,ce,s),{prints:de}=T;await o.writeFingerprints(f,de);let G=T.objects.map(j=>{let z=j.scoped.objectApiName;return St(j,Et.get(z)??0,re.get(z)??0,de[z].digest)});if(s?.aborted)throw new D;let le={...k,takenAt:ce,objects:G,movedWhileTaken:Ft,bytes:0,expiresAt:I(r(),u),status:"ready",...ae!==void 0?{files:ae}:{},replayAnnex:$t},U={...le,bytes:await fn(f,le)};await o.write(U),h(100,`Checkpoint '${U.name}' taken`,G.length,G.length);let ue=a.requests();return{taken:!0,checkpoint:U,notChecked:Lt,...ue!==void 0?{requests:ue}:{},estimate:T.estimate}}catch(y){throw f!==void 0&&await An(o,f,k,e),_(y,s)?new D:y}finally{S.lock.release()}}async function kn(e,t,n,o,s,r,d,p){let i=n.objects.filter(a=>a.records>0),c=new Map,l=(s.snapshotFiles??Vt)(e.dir);if(i.length>0){let a=Math.max(Ut,n.objectLimit),{handler:g,config:w}=await hn(e,l,s,a,(k,y)=>p(15+k*.65,y)),A=await g.backupForPipeline({operationId:t,orgId:o.orgId,objects:i.map(({scoped:k})=>k.objectApiName),fields:new Map(i.map(({scoped:k,capture:y})=>[k.objectApiName,y.fields])),scanAll:i.filter(({capture:k})=>k.readMode==="scanAllLive").map(({scoped:k})=>k.objectApiName),origin:"checkpoint",failWhenTruncated:!0,onConnection:k=>s.org.countAlso?.(k)},s.signal),S=gn.safeParse(w.get(`backup:${t}`)),f=S.success?S.data.organizationId:void 0;if(f===void 0||!bn(f,r))throw new Error(`The snapshot was read from ${f===void 0?"an org that did not say which it is":`another org (${f})`}, not from ${o.orgName}: it is not kept.`);for(let k of A.objects)c.set(k.objectApiName,k.recordCount)}p(82,"Indexing the snapshot",0,n.objects.length);for(let[a,{scoped:g}]of n.objects.entries()){let w=g.objectApiName,A=c.get(w)??0;c.has(w)||(await Pe(oe(e.dir,"backups")),await l.writeFile(Le(e,t,w),""),c.set(w,0));let S=await Ie(e,t,w);if(S.rows!==A)throw new Ee("damaged",`The snapshot of ${w} holds ${S.rows} records where its read kept ${A}: it is not kept.`);p(82+6*(a+1)/n.objects.length,`Indexed ${w}`,a+1,n.objects.length)}let u=n.objects.find(({scoped:a})=>M(a.objectApiName));if(u===void 0||n.linkable===void 0)return{records:c};p(88,"Reading the links of files to the records read");let h=await tt({reader:d,folder:e,snapshotId:t,linked:n.objects.map(({scoped:a})=>a.objectApiName).filter(a=>(c.get(a)??0)>0&&At(a,n.linkable)),documentsInSnapshot:(c.get(u.scoped.objectApiName)??0)>0,...s.signal!==void 0?{signal:s.signal}:{}});return{records:c,files:h}}async function wn(e,t,n,o,s,r){let d=await it(e,t,n.objects.map(({scoped:i,describe:c,capture:l})=>({objectApiName:i.objectApiName,userLookups:st(c,l.fields)}))),p=await dt({reader:o,organizationId:s,users:d,...Ot(n.objects),...r!==void 0?{signal:r}:{}});return lt(e,p)}async function yn(e,t,n,o,s,r,d){let p=oe(e.dir,zt),i={changed:0,deleted:0,created:0},c=[];try{let l=await Ze(o,n.objects.map(({capture:a})=>({objectApiName:a.objectApiName,readMode:a.readMode,held:!1})),s,p,d),u=Date.parse(Z(s)),h=Date.parse(r);for(let a of l){if("unread"in a){c.push({objectApiName:a.objectApiName,reason:a.unread});continue}if(!a.moved)continue;let g=await pn(e,t,a.objectApiName,a,u,h);i.changed+=g.changed,i.deleted+=g.deleted,i.created+=g.created}}finally{await gt(p,{recursive:!0,force:!0})}return{movedWhileTaken:i,notChecked:c}}async function An(e,t,n,o){try{n!==void 0&&await e.write({...n,status:"failed"})}catch(s){o.handler.log(`[WARN] checkpoint ${t.checkpointId}: not marked failed: ${v(s)}`)}try{await gt(t.dir,{recursive:!0,force:!0})}catch(s){o.handler.log(`[WARN] checkpoint ${t.checkpointId}: what its take wrote was not removed: ${v(s)}`)}}export{Gt as a,B as b,Xn as c,D as d,Kt as e,Jt as f,Yn as g,qn 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,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-5344TZBT.mjs";import"./chunk-V4RKM4QZ.mjs";import"./chunk-JU2XEKEO.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-ETT5GP4P.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-E2YJVSX6.mjs";import"./chunk-XEB6HZ34.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-ZUA5BNAO.mjs";import"./chunk-RKALOKAU.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-55LQD3Y3.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-3B5H24ZG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-EAFLDSQ2.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as ARCHIVE_CHUNK_BYTES,a as ARCHIVE_EXTENSION,f as CheckpointExportError,d as archiveKeyText,h as exportCheckpointArchive,j as importCheckpointArchive,l as importReceivedArchive,c as newArchiveKey,e as parseArchiveKey,g as portableCheckpointOf,i as readArchiveHeader,k as receivedStoreRootOf};
@@ -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-7DALDJMO.mjs";import"./chunk-OXKZ4Y3B.mjs";import"./chunk-MAHZMPMZ.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-UIUPPEFB.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-KOQV4WXC.mjs";import"./chunk-CULAOP3U.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-KRNFVAGC.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-2OIRJEYE.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-55LQD3Y3.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-3B5H24ZG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-EAFLDSQ2.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{h as ACTIVE_DUPLICATE_RULES_SOQL,a as FORMULAS_BOUND,c as FORMULAS_IN_COMPOSITES_BOUND,b as FORMULA_REQUESTS_BOUND,o as TargetGapReader,i as bypassesOf,j as callsEstimateOf,f as fieldLabelsSoql,p as gapAnsweredBy,d as gapFieldOf,r as gapLines,q as gapsWithAnswers,l as readActiveValidationRules,m as readValidationRuleBypasses,k as toolingQueriesOver,n as toolingValidationRules,g as validationFormulaSoql,e as validationRulesSoql};
@@ -0,0 +1,9 @@
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{c as N,e as C,f as F}from"./chunk-SW2NUKQL.mjs";import{d as I,z as P}from"./chunk-E2YJVSX6.mjs";import{b as O}from"./chunk-TQ2TQHTT.mjs";import{ma as $,ta as _}from"./chunk-DPYTG6DM.mjs";import{b as u,e as m,f as M,h as R,k as l,l as i,o as A,s as k,u as z,v as S,z as E}from"./chunk-WZQEK4WT.mjs";import{createHash as K,randomBytes as q}from"node:crypto";import{createReadStream as re}from"node:fs";import{chmod as ne,copyFile as oe,open as ae,readFile as G,readdir as H,rename as j,rm as w,stat as U}from"node:fs/promises";import{join as h}from"node:path";var X=1440*6e4,se="forge-samples",Q="forge-runs",B="sample.json",W="the run of this sample",ie=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,V=/^[A-Za-z0-9_-]{1,128}$/,f=class extends Error{constructor(e,r){super(r);this.refusal=e;this.name="SamplePlanError"}refusal};function x(n){return h(n,se)}function ce(n,t){if(!V.test(t))throw new f("otherSetup","Not the fingerprint of a setup of a run.");return h(x(n),t)}function v(n,t){return h(n,Q,`${t.replace(/[^A-Za-z0-9_-]/g,"_")}.sample`)}var p=u().regex(/^[A-Za-z][A-Za-z0-9_]*$/),s=m().int().nonnegative(),le=i({window:i({field:z(["CreatedDate","LastModifiedDate"]),from:u().optional(),to:u().optional(),lastDays:m().int().positive().optional()}).optional(),notWindowed:l(p).optional(),where:l(i({objectApiName:p,where:u()})).optional(),strata:l(i({objectApiName:p,field:u(),values:l(i({value:A([u(),M(),R()]),label:u().optional(),roots:s,kept:s})),more:s.optional()})).optional()}),pe=i({seed:m().int().min(0),draw:$,floor:s,parents:_,children:A([S("all"),m().int().min(1)]),share:m().min(0).max(1),budget:i({bytes:m().nonnegative(),remainingMB:m().optional(),maxMB:m().optional(),share:m().optional(),roundingMB:m().optional(),automationMB:m().optional(),withinMB:m().optional(),maxTotal:m().optional(),limitedBy:z(["storage","within","maxTotal","targetRequests","bulkBatches","sourceRequests","heavyRoots","whole","draw"])}),rows:s,storageBytes:m().nonnegative(),objects:l(i({objectApiName:p,sourceRows:s,kept:s,roots:s,below:s,asParents:s,whole:S(!0).optional(),childrenCut:l(i({field:u(),rows:s})).optional(),rootsInTheSource:s.optional(),rootsInTheDraw:s.optional()})),whole:l(i({objectApiName:p,why:z(["referenceData","catalog","smallParent","asked"])})),heavyRoots:l(i({objectApiName:p,id:u().regex(ie),rows:s,relation:i({objectApiName:p,field:u()})})),dropped:l(i({objectApiName:p,rows:s,reason:z(["noParentInSource","outsideFilter","excludedObject","withoutParent","heldBack","recordTypeNotInTarget"])})),leftEmpty:l(i({objectApiName:p,field:u(),rows:s})),noRecordDrawn:l(i({objectApiName:p,sourceRows:s,noRootInTheDraw:S(!0).optional()})),roots:le.optional(),partialMasters:l(i({objectApiName:p,details:p,field:u(),kept:s.optional(),sourceRows:s.optional(),asParents:s.optional()})).optional(),planRequests:i({source:s}),newestByIds:l(p).optional(),oldestByIds:l(p).optional()}),ue=i({personAccounts:k(p,s),byThePlatform:l(i({objectApiName:p,inPlan:s,beyond:s}))}),T=i({version:S(1),sourceOrgId:u().min(1),fingerprint:u().regex(V),drawnAt:E.datetime(),drawnBy:z(["run","dryRun"]),sha256:u().regex(/^[0-9a-f]{64}$/),objects:l(i({objectApiName:p,count:m().int().positive(),sha256:u().regex(/^[0-9a-f]{64}$/)})),sample:pe,newestByIds:l(p).optional(),oldestByIds:l(p).optional(),counts:ue.optional()});async function Z(n){let t=K("sha256");for await(let e of re(n))t.update(e);return t.digest("hex")}function L(n){let t=K("sha256"),e=[...n].sort((r,o)=>r.objectApiName<o.objectApiName?-1:r.objectApiName>o.objectApiName?1:0);for(let{objectApiName:r,count:o,sha256:a}of e)t.update(`${r} ${o} ${a}
8
+ `);return t.digest("hex")}async function me(n,t){let e=await ae(n,"wx",I);try{await e.writeFile(t,"utf8"),await e.sync()}finally{await e.close()}}function D(n){let t=n?.code;return t==="ENOENT"||t==="ENOTDIR"}var y=class n{constructor(t,e,r){this.dir=t;this.manifest=e;this.spool=r}dir;manifest;spool;get sha256(){return this.manifest.sha256}get count(){return this.spool.count}countOf(t){return this.manifest.objects.find(e=>e.objectApiName===t)?.count??0}ageMs(t){return t.getTime()-Date.parse(this.manifest.drawnAt)}get place(){return{path:this.dir,sha256:this.manifest.sha256,drawnAt:this.manifest.drawnAt,drawnBy:this.manifest.drawnBy}}async*ids(t,e={}){let r=Math.max(1,Math.floor(e.size??2e3)),o=e.after,a=[];for await(let c of this.spool.pages(t,r))for(let d of c)o!==void 0&&O(d,o)<=0||(a.push(d),a.length>=r&&(yield a,a=[]));a.length>0&&(yield a)}static async open(t,e={}){let r;try{r=JSON.parse(await G(h(t,B),"utf8"))}catch(d){throw D(d)?new f("gone","The plan of this sample is no longer on this machine."):new f("changed","The plan of this sample does not read as one.")}let o=T.safeParse(r);if(!o.success)throw new f("changed","The plan of this sample does not read as one.");let a=o.data,c;try{c=await F.open(t,W)}catch{throw new f("changed","The ids of this sample are not as they were written.")}if(await n.holdToManifest(t,a,c),e.sourceOrgId!==void 0&&e.sourceOrgId!==a.sourceOrgId)throw new f("otherOrg","This plan was drawn of another org.");if(e.fingerprint!==void 0&&e.fingerprint!==a.fingerprint)throw new f("otherSetup","This plan was drawn for another setup of the run.");if(e.sha256!==void 0&&e.sha256!==a.sha256)throw new f("otherSha","This is not the plan the run was drawn with.");return new n(t,a,c)}static async holdToManifest(t,e,r){let o=()=>new f("changed","The ids of this sample are not as they were written."),a=r.objects.filter(c=>c.count>0);if(a.length!==e.objects.length)throw o();for(let c of e.objects){let d=a.find(b=>b.objectApiName===c.objectApiName);if(!d||d.count!==c.count)throw o();let g;try{g=await Z(N(t,c.objectApiName))}catch{throw o()}if(g!==c.sha256)throw o()}if(L(e.objects)!==e.sha256)throw o()}static async keep(t,e){let r=`${t}.${process.pid}-${q(4).toString("hex")}.tmp`;try{await P(r);let o=new C(r,W);for(let{objectApiName:g,ids:b}of e.ids){let ee=[...b].sort(O);for(let te of ee)await o.add(g,te)}let a=await o.finish(),c=[];for(let{objectApiName:g,count:b}of a.objects)b!==0&&c.push({objectApiName:g,count:b,sha256:await Z(N(r,g))});let d={version:1,sourceOrgId:e.sourceOrgId,fingerprint:e.fingerprint,drawnAt:e.drawnAt.toISOString(),drawnBy:e.drawnBy,sha256:L(c),objects:c,sample:e.sample,...e.newestByIds!==void 0&&e.newestByIds.length>0?{newestByIds:[...e.newestByIds]}:{},...e.oldestByIds!==void 0&&e.oldestByIds.length>0?{oldestByIds:[...e.oldestByIds]}:{},...e.counts?{counts:e.counts}:{}};T.parse(d),await me(h(r,B),`${JSON.stringify(d)}
9
+ `),await w(t,{recursive:!0,force:!0}),await j(r,t)}catch(o){throw await w(r,{recursive:!0,force:!0}),o}return n.open(t)}};function Pe(n,t){return y.keep(n,t)}async function je(n,t,e){let r;try{r=await y.open(ce(n,t),{fingerprint:t})}catch(o){if(o instanceof f)return;throw o}return r.ageMs(e)>=X?"tooOld":r}async function Ae(n,t,e){let r=v(t,e);return await P(h(t,Q)),await w(r,{recursive:!0,force:!0}),await j(n.dir,r),y.open(r,{sha256:n.sha256})}async function Ie(n,t,e){let r=v(n,t);return!await J(r)||await J(e)?!1:(await P(x(n)),await j(r,e),!0)}async function Ne(n,t,e){let r=v(t,e);return await Y(n.dir,r),y.open(r,{sha256:n.sha256})}async function Oe(n,t,e){let r=await y.open(n,{sha256:e});await Y(r.dir,t);try{return await y.open(t,{sha256:e})}catch(o){throw await w(t,{recursive:!0,force:!0}),o}}async function Y(n,t){let e=`${t}.${process.pid}-${q(4).toString("hex")}.tmp`;try{await P(e);for(let r of await H(n))await oe(h(n,r),h(e,r)),await ne(h(e,r),I);await w(t,{recursive:!0,force:!0}),await j(e,t)}catch(r){throw await w(e,{recursive:!0,force:!0}),r}}async function J(n){try{return await U(n),!0}catch(t){if(D(t))return!1;throw t}}async function Be(n){await w(n,{recursive:!0,force:!0})}async function Te(n,t){let e=x(n),r;try{r=await H(e)}catch(a){if(D(a))return 0;throw a}let o=0;for(let a of r){let c=h(e,a),d;try{let g=T.parse(JSON.parse(await G(h(c,B),"utf8")));d=Date.parse(g.drawnAt)}catch{d=(await U(c)).mtimeMs}t.getTime()-d<X||(await w(c,{recursive:!0,force:!0}),o++)}return o}export{X as a,f as b,ce as c,v as d,y as e,Pe as f,je as g,Ae as h,Ie as i,Ne as j,Oe as k,Be as l,Te as m};
@@ -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-GWRKS3AL.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-6IGEASOF.mjs";import"./chunk-KOQV4WXC.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-CULAOP3U.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-KRNFVAGC.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-2OIRJEYE.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-55LQD3Y3.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-3B5H24ZG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-EAFLDSQ2.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.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};
@@ -4,5 +4,5 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a as w,b as x}from"./chunk-WR4Q363I.mjs";import{b as R}from"./chunk-E5AHXLS6.mjs";import{g as k}from"./chunk-PZPJKATS.mjs";import{Va as h,ka as g,na as l}from"./chunk-TTFDUKUS.mjs";import{b as d,m as S,s as u,v as f}from"./chunk-7EANH5PY.mjs";import{createHash as $}from"node:crypto";import{mkdir as y,readFile as C,rename as P,writeFile as O}from"node:fs/promises";import*as a from"node:path";var A=k,N=d().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,"A record id"),p=S({version:f(1),runId:d().min(1).max(200),packId:g,packFingerprint:d().regex(/^[0-9a-f]{64}$/,"A sha256, in lower-case hexadecimal"),compile:l.refine(e=>e.seed!==void 0,{message:"The seed the pack was compiled with is kept",path:["seed"]}),openCases:u(d().min(1).max(255),N),agent:h.optional()});function F(e){return $("sha256").update(m(e)).digest("hex")}function v(e){let r={};for(let i of e.compiled.tests){let n=i.openCase?.caseKey;if(n===void 0)continue;let t=e.caseIds[n];t!==void 0&&(r[n]=t)}return p.parse({version:1,runId:e.runId,packId:e.pack.id,packFingerprint:F(e.pack),compile:{...e.options,seed:e.compiled.seed},openCases:r})}function D(e,r){return p.parse({...e,agent:r})}function U(e,r){if(r.id!==e.packId)return{ok:!1,message:`The run was seeded from the scenario ${e.packId}, not ${r.id}`};if(F(r)!==e.packFingerprint)return{ok:!1,message:`The scenario ${r.id} has changed since the run: its tests would be about subjects and addresses no record of the run holds`};try{return{ok:!0,compiled:x(r,e.compile)}}catch(i){if(i instanceof w)return{ok:!1,message:i.message};throw i}}function Z(){return{readFile:e=>C(e,"utf8"),writeFile:(e,r)=>O(e,r,"utf8"),rename:(e,r)=>P(e,r),mkdir:async e=>{await y(e,{recursive:!0})}}}function I(e,r){return a.join(e,R,`${r.replace(/[^A-Za-z0-9_-]/g,"_")}${A}`)}async function K(e,r,i){let n=p.parse(i),t=I(r,n.runId),o=`${t}.${process.pid}.tmp`;return await e.mkdir(a.dirname(t)),await e.writeFile(o,`${JSON.stringify(n,null,2)}
7
+ import{a as w,b as x}from"./chunk-HYBH5PFM.mjs";import{b as R}from"./chunk-KNIRA333.mjs";import{g as k}from"./chunk-MNITSYI2.mjs";import{Ia as g,La as l,tb as h}from"./chunk-DPYTG6DM.mjs";import{b as d,m as S,s as u,v as f}from"./chunk-WZQEK4WT.mjs";import{createHash as $}from"node:crypto";import{mkdir as y,readFile as C,rename as P,writeFile as O}from"node:fs/promises";import*as a from"node:path";var A=k,N=d().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,"A record id"),p=S({version:f(1),runId:d().min(1).max(200),packId:g,packFingerprint:d().regex(/^[0-9a-f]{64}$/,"A sha256, in lower-case hexadecimal"),compile:l.refine(e=>e.seed!==void 0,{message:"The seed the pack was compiled with is kept",path:["seed"]}),openCases:u(d().min(1).max(255),N),agent:h.optional()});function F(e){return $("sha256").update(m(e)).digest("hex")}function v(e){let r={};for(let i of e.compiled.tests){let n=i.openCase?.caseKey;if(n===void 0)continue;let t=e.caseIds[n];t!==void 0&&(r[n]=t)}return p.parse({version:1,runId:e.runId,packId:e.pack.id,packFingerprint:F(e.pack),compile:{...e.options,seed:e.compiled.seed},openCases:r})}function D(e,r){return p.parse({...e,agent:r})}function U(e,r){if(r.id!==e.packId)return{ok:!1,message:`The run was seeded from the scenario ${e.packId}, not ${r.id}`};if(F(r)!==e.packFingerprint)return{ok:!1,message:`The scenario ${r.id} has changed since the run: its tests would be about subjects and addresses no record of the run holds`};try{return{ok:!0,compiled:x(r,e.compile)}}catch(i){if(i instanceof w)return{ok:!1,message:i.message};throw i}}function Z(){return{readFile:e=>C(e,"utf8"),writeFile:(e,r)=>O(e,r,"utf8"),rename:(e,r)=>P(e,r),mkdir:async e=>{await y(e,{recursive:!0})}}}function I(e,r){return a.join(e,R,`${r.replace(/[^A-Za-z0-9_-]/g,"_")}${A}`)}async function K(e,r,i){let n=p.parse(i),t=I(r,n.runId),o=`${t}.${process.pid}.tmp`;return await e.mkdir(a.dirname(t)),await e.writeFile(o,`${JSON.stringify(n,null,2)}
8
8
  `),await e.rename(o,t),t}async function X(e,r,i){let n=I(r,i),t;try{t=await e.readFile(n)}catch(c){if(c.code==="ENOENT")return{kind:"absent"};throw c}let o;try{o=JSON.parse(t)}catch{return{kind:"invalid",message:`${a.basename(n)} is not JSON`}}let s=p.safeParse(o);if(!s.success){let c=s.error.issues[0];return{kind:"invalid",message:`${a.basename(n)}: ${c.path.join(".")||"the file"}: ${c.message}`}}return s.data.runId!==i?{kind:"invalid",message:`${a.basename(n)} is the companion of the run ${s.data.runId}, not ${i}`}:{kind:"read",sidecar:s.data}}function m(e){return Array.isArray(e)?`[${e.map(r=>m(r??null)).join(",")}]`:e!==null&&typeof e=="object"?`{${Object.entries(e).filter(([,i])=>i!==void 0).sort(([i],[n])=>i<n?-1:i>n?1:0).map(([i,n])=>`${JSON.stringify(i)}:${m(n)}`).join(",")}}`:JSON.stringify(e??null)}export{A as a,p as b,F as c,v as d,D as e,U as f,Z as g,I as h,K as i,X as j};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a,b}from"./chunk-F6GUDTOB.mjs";import"./chunk-O2HDYYUV.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{a as FieldMapper,b as generateValue};
7
+ import{a,b}from"./chunk-MHW6DV6T.mjs";import"./chunk-OVOLG3AL.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as FieldMapper,b as generateValue};
@@ -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{a as x,b as A,c as b,d as L}from"./chunk-BZ24IAP5.mjs";import{homedir as B}from"node:os";import{join as O,resolve as I}from"node:path";var C="SANDFORGE_JOURNAL_DIR";function U(e=process.env){let n=e[C];return n!==void 0&&n.trim()!==""?I(n):O(B(),".sandforge")}import{spawn as Y}from"node:child_process";import{join as $}from"node:path";import{StringDecoder as M}from"node:string_decoder";function G(){return process.execArgv.filter(e=>!/^--inspect/.test(e))}function J(e){return $(__dirname,`${e}.mjs`)}var g="SANDFORGE_RELAYED_BY";function re(e={}){let n=(e.platform??process.platform)==="win32",s=e.scriptPath??J;return(t,d,c,o={})=>new Promise((f,p)=>{let u=o.relayedBy??e.relayedBy,a={...process.env,...u!==void 0?{[g]:u}:{},...n?{[L]:"ipc"}:{}},r=Y(process.execPath,[...G(),s(t),...d],{stdio:n?["ignore","pipe","pipe","ipc"]:["ignore","pipe","pipe"],env:a,detached:!n,windowsHide:!0}),E=[],R=[],y=o.onStderr!==void 0?new M("utf8"):void 0;r.stdout?.on("data",i=>E.push(i)),r.stderr?.on("data",i=>{R.push(i),process.stderr.write(i);let m=y?.write(i);m&&o.onStderr?.(m)});let l=()=>{if(!n||!r.connected){r.kill("SIGINT");return}r.send(b,i=>{i&&r.kill("SIGINT")})};c.aborted?l():c.addEventListener("abort",l,{once:!0}),r.on("error",i=>{c.removeEventListener("abort",l),p(i)}),r.on("close",(i,m)=>{c.removeEventListener("abort",l);let _=y?.end();_&&o.onStderr?.(_);let v=x.find(T=>T===m);f({code:i??(v!==void 0?A(v):1),stdout:Buffer.concat(E).toString("utf8"),stderr:Buffer.concat(R).toString("utf8")})})})}function S(){let e=process.env[g]?.trim();return e===void 0||e===""?void 0:e}function h(){return S()?.startsWith("sandforge env")===!0}function se(e,n){return h()?n:e}var j="sandforge mcp clone_org_plan",N="sandforge mcp clone_org",F=new Map([["sandforge env",["--sweep","--include-changed"]],["sandforge env, relayed by sandforge mcp",["--include-changed"]],["sandforge mcp",["--mute-automation","--leave-undeletable","--store","--include-changed","--preview"]],[j,["--max-total","--exclude-object","--exclude","--filter","--fit","--fit-within","--fit-seed","--fit-draw","--fit-parents","--fit-children","--fit-whole","--fit-floor","--anonymize","--accept-automation","--accept-emails","--mute-automation","--checkpoint-first"]],[N,[]]]);function de(){return h()||S()===N}function k(e){let n=S();return n===void 0||F.get(n)?.includes(e)===!0}function ae(e,n){return k(e)?e:n===void 0?`this script's own ${e}`:`this script's own ${n} with ${e}`}var w=()=>({input:process.stdin,output:process.stderr});function P(e,n,s){let{input:t,output:d}=n;return t.isTTY!==!0&&(d.write(`${e}
8
+ no terminal to answer: give --yes to go ahead without the question.
9
+ `),process.exit(2)),s?.aborted===!0?Promise.resolve(void 0):(d.write(`${e} `),new Promise(c=>{let o=a=>{t.off("data",f),t.off("end",p),s?.removeEventListener("abort",u),t.pause(),c(a)},f=a=>o(String(a).trim()),p=()=>o(void 0),u=()=>{d.write(`
10
+ `),o(void 0)};t.on("data",f),t.on("end",p),s?.addEventListener("abort",u,{once:!0}),t.resume()}))}async function fe(e,n=w(),s){let t=await P(`${e} [y/N]`,n,s);return t!==void 0&&/^y(es)?$/i.test(t)}async function ue(e,n=w()){return await P(e,n)??""}var H=new Set(["\r",`
11
+ `]),V=new Set(["\x7F","\b"]),W="",X="";function pe(e,n,s=w()){let{input:t,output:d}=s;return t.isTTY!==!0&&(d.write(`${e}
12
+ no terminal to type it on: ${n}.
13
+ `),process.exit(2)),d.write(`${e} `),t.setRawMode?.(!0),new Promise(c=>{let o="",f=a=>{t.off("data",p),t.off("end",u),t.setRawMode?.(!1),t.pause(),d.write(`
14
+ `),c(a)},p=a=>{for(let r of String(a)){if(H.has(r))return f(o);if(r===W||r===X&&o==="")return f(void 0);V.has(r)?o=o.slice(0,-1):r>=" "&&(o+=r)}},u=()=>f(void 0);t.on("data",p),t.on("end",u),t.resume()})}export{U as a,g as b,re as c,S as d,h as e,se as f,j as g,N as h,de as i,k as j,ae as k,fe as l,ue as m,pe as n};
@@ -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 Z,l as T}from"./chunk-GWRKS3AL.mjs";import{B as Q,s as Y,t as M,v as K,z as J}from"./chunk-T26C576X.mjs";import{d as G}from"./chunk-BNO5GIJ6.mjs";import{b as V,c as X,g as z}from"./chunk-6IGEASOF.mjs";import{$b as te,Ec as re,Pb as ee,tc as se,uc as N}from"./chunk-KOQV4WXC.mjs";import{b as U,c as B}from"./chunk-SU65Z2BA.mjs";import{B as H}from"./chunk-XEB6HZ34.mjs";import{b as $}from"./chunk-CA5NAXSU.mjs";import{Ad as q,nd as I,rd as C,wd as S,zd as F}from"./chunk-DPYTG6DM.mjs";var _e=5e3,x=2e3,le=1e3,me={masking:{during:"during the masking",records:"records it masked"},restore:{during:"during the restore",records:"records it put back"},erasure:{during:"during the erasure",records:"records it overwrote"}};function ne(e,t){let r=new Set(t.map(s=>s.toLowerCase()));return(e?.objects??[]).filter(s=>r.has(s.objectApiName.toLowerCase())).filter(s=>(s.duplicateRules??[]).length>0).map(s=>({objectApiName:s.objectApiName,rules:(s.duplicateRules??[]).map(n=>n.name)}))}function ae(e){return typeof e=="string"?e.slice(0,15):""}async function pe(e,t){let{rules:r}=t,s=0,n=a=>(s++,e.query(a));try{let a=H(new Date(Date.parse(t.since)-le).toISOString()),i=new Set([...t.masked].map(ae)),c=await n(`SELECT Id, DuplicateRecordSetId, RecordId FROM DuplicateRecordItem WHERE CreatedDate >= ${a} LIMIT ${x+1}`),u=c.done===!1||c.records.length>x,d=c.records.slice(0,x),p=new Set(d.filter(o=>i.has(ae(o.RecordId))).map(o=>String(o.DuplicateRecordSetId??"")).filter(o=>o!=="")),l=d.filter(o=>p.has(String(o.DuplicateRecordSetId??""))).length,m=0;for(let o of G([...p])){let f=await n(`SELECT Id FROM DuplicateRecordSet WHERE CreatedDate >= ${a} AND Id IN (${o})`);m+=f.records.length}return{rules:r,sets:m,items:l,...u?{atLeast:!0}:{},requests:s}}catch(a){return{rules:r,sets:0,items:0,unread:$(a),requests:s}}}function Ie(e,t,r){let s=r.now??Date.now,n=r.sleep??(l=>new Promise(m=>setTimeout(m,l))),a=new Set(t.map(l=>l.objectApiName.toLowerCase())),i=l=>a.has(l.toLowerCase()),c,u=0,d=new Set,p=0;return{covers:i,beforeWrite:l=>{i(l)&&c===void 0&&(u=s())},wrote:(l,m)=>{if(!i(l))return;let o=!1;for(let h of m)typeof h!="string"||h===""||(d.add(h),o=!0);if(!o)return;p=s();let f=u;c??=e.serverTime().then(h=>{let b=Date.parse(h);return Number.isNaN(b)?{unread:`it answered "${h}"`}:{at:new Date(b-Math.max(0,s()-f)).toISOString()}},h=>({unread:$(h)}))},held:()=>d.size,read:async()=>{if(d.size===0)return;let l=c?await c:void 0;if(!l||"unread"in l)return{rules:t,sets:0,items:0,unread:l?`the org's clock: ${l.unread}`:"the org's clock was not read",requests:l?1:0};let m=Math.max(0,p+r.settleMs-s());m>0&&await n(m);let o=await pe(e,{rules:t,since:l.at,masked:d});return{...o,requests:(o.requests??0)+1,waitedMs:m}}}}function Ce(e,t){if(!e)return t;if(!t)return e;let r=[e.unread,t.unread].filter(s=>s!==void 0);return{rules:t.rules.length>=e.rules.length?t.rules:e.rules,sets:e.sets+t.sets,items:e.items+t.items,...e.atLeast||t.atLeast?{atLeast:!0}:{},...r.length>0?{unread:r.join("; ")}:{},requests:(e.requests??0)+(t.requests??0),waitedMs:(e.waitedMs??0)+(t.waitedMs??0)}}function Fe(e){return e!==void 0&&(e.sets>0||e.items>0||e.unread!==void 0)}function ge(e){return e.map(t=>`"${t}"`).join(", ")}function fe(e){return e<=0?"without waiting":e<1e3?"after waiting less than 1 s":`after waiting ${Math.round(e/1e3)} s`}function qe(e,t,r="masking"){if(!e||e.rules.length===0)return"";let s=me[r],n=e.rules.map(c=>`${c.objectApiName} (${ge(c.rules)})`).join(", ");if(e.unread!==void 0)return`What the duplicate rules of ${t} on ${n} wrote ${s.during} could not be read (${e.unread}): a duplicate record set they wrote stays.`;let a=e.requests!==void 0?` Read in ${e.requests} request(s), ${fe(e.waitedMs??0)}.`:"";if(e.sets===0&&e.items===0)return`The duplicate rules of ${t} on ${n} wrote nothing for the ${s.records}.`+a;let i=e.atLeast===!0?"at least ":"";return`The duplicate rules of ${t} on ${n} wrote ${i}${e.sets} duplicate record set(s) and ${i}${e.items} item(s) ${s.during}, for ${s.records}: kept, as they name records that stay.${a}`}var he="AUTOMATION_NOT_ACCEPTED",we="EMAILS_EXCEEDED",Oe="ORG_TEMPORARILY_UNREACHABLE";function Ae(e,t){return e==="cleanup"||e==="empty"?{delete:[...t]}:e==="restore"?{bringBack:[...t],giveBack:[...t]}:e==="emptyUndo"?{bringBack:[...t]}:{giveBack:[...t]}}function be(e,t){let r=e==="cleanup"||e==="empty"?"delete":"update";return t.filter(s=>s.records>0).map(s=>({objectApiName:s.objectApiName,write:r,records:s.records}))}var E={masking:{heading:"masking automation: what {org} runs as the masking writes over the records",the:"the masking",this:"this masking",writes:"writes over",verb:"mask",nothing:"Nothing was written.",flag:"to mask all the same"},restore:{heading:"restore automation: what {org} runs as the restore puts the backup's values back",the:"the restore",this:"this restore",writes:"puts back",verb:"restore",nothing:"Nothing was written.",flag:"to restore all the same"},cleanup:{heading:"cleanup automation: what {org} runs as the cleanup deletes the records",the:"the cleanup",this:"this cleanup",writes:"deletes",verb:"delete",nothing:"Nothing was deleted.",flag:"to delete all the same"},empty:{heading:"emptying automation: what {org} runs as the emptying deletes the records",the:"the emptying",this:"this emptying",writes:"deletes",verb:"empty",nothing:"Nothing was deleted.",flag:"to empty all the same"},emptyUndo:{heading:"undo automation: what {org} runs as the undo brings the records back",the:"the undo",this:"this undo",writes:"brings back",verb:"undo",nothing:"Nothing was written.",flag:"to undo all the same"}},$e={masking:"masking",restore:"restore",cleanup:"cleanup",empty:"empty",emptyUndo:"undo"};function Je(e){return e.erasure===!0?"erasure":e.fromPage===!0?"page":void 0}var ye={"accept-automation":"acceptAutomation","accept-emails":"acceptEmails","mute-automation":"muteAutomation"},De={"accept-emails":"the confirmation's box that lets the org send these emails","mute-automation":"the confirmation's box that mutes the target's automation"},Re={mask:"masking",restore:"restore",delete:"cleanup",erase:"erasure",empty:"emptying",undo:"undo"};function oe(e){let t=r=>De[r]??`--${r}`;return e.replace(/\bAdd --accept-automation to (mask|restore|delete|erase|empty|undo) all the same\b/g,(r,s)=>`Confirm the ${Re[s]??s} from its confirmation, which lists what fires, to ${s} all the same`).replace(/\bWith --mute-automation,/g,`With ${t("mute-automation")} ticked,`).replace(/\bAdd --(accept-emails|mute-automation)\b/g,(r,s)=>`Tick ${t(s)}`).replace(/(^|[.:;] )--(accept-emails|mute-automation)\b/g,(r,s,n)=>`${s}${W(t(n))}`).replace(/--(accept-emails|mute-automation)\b/g,(r,s)=>t(s))}function L(e,t="flags"){return t==="step"?e.replace(/--(accept-automation|accept-emails|mute-automation)\b/g,(r,s)=>`${ye[s]??s} in the step`).replace(/\bAdd (acceptAutomation|acceptEmails|muteAutomation) in the step\b/g,"Turn on $1 in the step"):t==="erasure"?oe(e.replace(/\b(this|the|This|The) (masking|cleanup)\b/g,"$1 erasure").replace(/\bto (mask|delete) all the same\b/g,"to erase all the same").replace(/\b(mask|delete) fewer records\b/g,"erase fewer records")):t==="page"?oe(e):e}var ke={before:"before save",after:"after save",beforeAndAfter:"before and after save"},Ee={before:"before delete",after:"after delete",beforeAndAfter:"before and after delete"},ue={flows:"the flows",triggers:"the Apex triggers",processes:"the Process Builder processes",workflowRules:"the workflow rules",automation:"the automation"};function de({kind:e,name:t}){return e==="flow"?`flow "${t}"`:e==="process"?`process "${t}"`:e==="workflowRule"?`workflow rule "${t}"`:`Apex trigger ${t}`}function ce(e,t){return t.step==="delete"?Ee[t.when]:t.step==="bringBack"?"as it comes back from the recycle bin":`${e==="restore"?"as its values are put back":"as it is masked"}, ${ke[t.when]}`}function W(e){return`${e[0]?.toUpperCase()??""}${e.slice(1)}`}function ve(e,t,r,s){let n=E[r],a=[n.heading.replace("{org}",t)];if(typeof e.unread=="string")return a.push(` what ${t} runs could not be read: ${e.unread}`),a;let i=e;for(let d of S(i,s))a.push(` ${d.objectApiName}: ${ce(r,d)}: ${de(d)}`);let c=N(i);if(a.length===1&&c.length===0){let d=new Set(Object.values(s).flat()).size;a.push(` nothing fires on the ${d} object(s) it ${n.writes} records of`)}for(let d of ne(i,s.giveBack??[]))a.push(` ${d.objectApiName}: duplicate rules ${d.rules.map(p=>`"${p}"`).join(", ")}: ${n.the} saves a record a rule only alerts on, a rule that blocks still refuses it, and what a rule that reports writes (a duplicate record set and its items) stays`);let u=I(i);u.length>0&&a.push(` bypass held: the user ${n.the} writes as holds ${u.join(", ")}, and what names it stays quiet`);for(let{part:d,reason:p}of c)a.push(` ${ue[d]??d} could not be read: ${p}`);return a}function Se(e,t,r){let s=E[r.act],n=`${s.nothing} Add --accept-automation ${s.flag}, or turn that automation off in ${t} first.`;if(typeof e.unread=="string")return`What ${t} runs as ${s.this} ${s.writes} its records could not be read (${e.unread}), so what fires is not known. ${n}`;let a=e,i=S(a,r.steps),c=N(a);if(i.length===0&&c.length===0)return;let u=[];if(i.length>0){let l=i.map(m=>`${m.objectApiName}: ${de(m)} (${ce(r.act,m)})`);u.push(`${t} runs automation as ${s.this} ${s.writes} its records: ${l.join("; ")}.`)}for(let{part:l,reason:m}of c)u.push(`${W(ue[l]??l)} of ${t} could not be read (${m}), so what fires as ${s.the} ${s.writes} its records is not known.`);let d=r.assign??[];u.push(...re(d,t,s.the));let p=[...new Set(d.flatMap(l=>l.permissionSet??[]))];return r.mayMute===!0&&p.length>0&&u.push(`With --mute-automation, ${s.the} assigns ${p.join(", ")} to the user it writes as for ${s.the} alone, under a lease, and what ${p.length===1?"it keeps":"they keep"} quiet does not fire.`),u.push(n),u.join(" ")}function k(e){let t=e.objects.map(r=>`${r.perRecord} per ${r.objectApiName}`).join(", ");return`about ${te(e.emails,e.limit)} (${t}`+(e.alertsCounted?"; its email alerts among them, as a Developer Edition counts them":"")+")"}function Me(e,t,r){let s=e.map(n=>{if(n.verdict==="unread")return` emails: ${k(n)}; what ${t} has left today could not be read (${n.unread??"not said"})`;let a=`${n.remaining??0} of ${n.max??0} left today`;return n.verdict==="exceeds"?` emails: ${k(n)}, past the ${a}`:` emails: ${k(n)}, ${a}`});return r!==void 0&&s.push(` emails not counted: what sends them was not read (${r})`),s}function Te(e,t,r,s){let n=t.filter(u=>u.verdict==="exceeds");if(n.length===0)return;let a=E[e],i=n.map(u=>`${k(u)}, ${u.remaining??0} of ${u.max??0} left today`).join("; "),c=s?.kind==="enough"?`Turn off what sends them, give the user it writes as the bypass that keeps them quiet (--mute-automation assigns ${s.sets.join(", ")} for ${a.the} alone, and what still sends then fits what is left today), or ${a.verb} fewer records.`:`Turn off what sends them, or ${a.verb} fewer records.`+(s?.kind==="muting"?" What sends them still runs under the mute.":s?.kind==="notEnough"?" --mute-automation would not keep enough of them quiet.":"");return`${W(a.this)} would make ${r} send ${i}: past them, each record whose flow fails in the save is refused (CANNOT_EXECUTE_FLOW_TRIGGER), and the org's own emails stop for the rest of the day. ${c} ${a.nothing}`}function Qe(e,t,r){return{readAutomation:t,readLimits:()=>ee(e),readDeliverability:()=>r?Promise.resolve(V):X(e),muteOrg:async()=>Y(e),...r?{production:r}:{}}}async function Ze(e,t,r,s){let n=e?.mute?.prepared;if(!e||!n)return{};let a;try{a=await n.acquire(t)}catch(c){if(!M(c))throw c;return{refused:{code:c.code,message:L(c.message,s)}}}let i=e.emails.afterLease(a.outcome,r);return i?(await a.release(),{refused:{code:i.code,message:L(i.message,s)}}):{held:a}}var Ne={objectsRead:[],objects:[],unread:[],conditionsNotRead:0,conditionsBound:0,requests:0};async function et(e){let{act:t,target:r,accord:s}=e,n=e.objects.filter(g=>g.records>0),a=n.map(g=>g.objectApiName),i=e.writes?.steps??Ae(t,a),c=F(i),u=a.length===0?Ne:await e.org.readAutomation(a).catch(g=>{let A=U(g);return{unread:A===void 0?$(g):`the org could not be reached (${A})`}}),d=typeof u.unread=="string"?void 0:u,p=B(u),l=E[t],m=[],o;if(s.muteAutomation===!0&&p===void 0)try{o=await J(e.org.muteOrg,u,{...e.muteLeases,writes:c})}catch(g){if(!M(g))throw g;m.push({code:g.code,message:g.message})}let f=o?.automation??d,h=e.mayMute&&s.muteAutomation!==!0&&e.org.production!==!0,b=[...ve(d??u,r,t,i),...o?Q(o.muted,r).map(g=>` ${g}`):[]],j=Se(f??u,r,{act:t,steps:i,...f?{assign:se(f,q(f,i),e.assignTo)}:{},mayMute:h});j!==void 0&&s.acceptAutomation!==!0&&m.push({code:he,message:j});let D=e.writes?e.writes.written.filter(g=>g.records>0):be(t,n),y=[],R,P;if(f&&p===void 0){if(D.some(A=>C(f,A.write).some(w=>w.objectApiName===A.objectApiName))){let A=await e.org.readLimits().catch(w=>({unread:$(w)}));if(y=T(D,f,A),y.some(w=>w.verdict==="exceeds")){let w=!o&&h&&d?K(d,c):void 0;P=o?{kind:"muting"}:w&&w.plan.assign.length>0?T(D,w.automation,A).some(v=>v.verdict==="exceeds")?{kind:"notEnough"}:{kind:"enough",sets:w.plan.assign.map(v=>v.permissionSet)}:void 0}}R=Z(D,f)}b.push(...Me(y,r,R));let _=Te(t,y,r,P);_!==void 0&&m.push({code:we,message:_});let O=await z({read:u,...o?.plan?{plan:o.plan}:{},writes:c,readDeliverability:p===void 0?e.org.readDeliverability:async()=>({reading:{unread:`${r} could not be reached`},requests:0}),accepted:s.acceptEmails===!0,target:r,run:$e[t],keepsAddresses:!0,mayMute:h});return O.gate.line!==void 0&&b.push(` ${O.gate.line}`),O.gate.stop&&m.push({...O.gate.stop}),p!==void 0&&m.splice(0,m.length,{code:Oe,message:`${r} could not be reached as what it runs was read (${p}), so ${l.the} was not started. ${l.nothing} Check the network, then try again.`}),{answer:{act:t,objects:n,steps:i,...d?{automation:d}:{automationUnread:String(u.unread)},lines:b,emails:y,...R!==void 0?{emailsUncounted:R}:{},...O.gate.deliverability?{deliverability:O.gate.deliverability}:{},emailsAsk:O.gate.verdict==="asks",refusals:m.map(g=>({...g,message:L(g.message,e.voice)})),...o?{mutedAutomation:o.muted}:{},...o?.plan?{mutePlan:o.plan}:{}},...o?{mute:o}:{},emails:O}}var xe=/\bnothing (?:was )?(?:written|deleted)\b/i,ie=/\s*\bNothing was (?:written|deleted)\./g;function tt(e){let[t,...r]=e.refusals;if(!t)return;let s=!1,n=e.refusals.map(a=>s?a.message.replace(ie,"").trim():(s=xe.test(a.message),a.message)).join(" ");return{code:t.code,message:n,alsoRefused:r.map(a=>({code:a.code,message:a.message.replace(ie,"").trim()}))}}function st(e){return e.alsoRefused.length>0?{extraPayload:{alsoRefused:[...e.alsoRefused]}}:{}}export{_e as a,ne as b,Ie as c,Ce as d,Fe as e,qe as f,Je as g,Qe as h,Ze as i,et as j,tt as k,st 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
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x}from"./chunk-ICIYL45C.mjs";import"./chunk-NTOVCTRS.mjs";export{a as CURRENCY_FIELD,r as CURRENCY_FOLLOWS,c as CURRENCY_SETTINGS_SOQL,b as CURRENCY_TYPES_SOQL,v as CurrencyReplacementTally,d as DATED_RATES_ON_SOQL,e as DATED_RATES_SOQL,k as DATED_RATE_FIELDS,m as conversionFactor,o as currencyFieldsOf,x as currencyReplacementsNote,l as datedRateOf,g as datedRatesOf,w as describeCurrencyReplaced,u as followParentCurrency,s as followsItsParentsCurrency,f as orgCurrenciesOf,i as orgCurrencyOf,t as parentCurrencyChange,h as readOrgCurrencies,j as readRunCurrencies,q as replaceRowCurrency,p as replacementCurrency,n as roundToScale};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{b as c,l as p}from"./chunk-7EANH5PY.mjs";var T="SELECT Id, SobjectType, DeveloperName, NamespacePrefix FROM RecordType",d=p({Id:c().min(15),DeveloperName:c().min(1),NamespacePrefix:c().nullable().optional(),SobjectType:c().min(1).optional()}).loose();function y(e){return Array.isArray(e)?e.flatMap(r=>{let a=d.safeParse(r);if(!a.success)return[];let{Id:n,DeveloperName:t,NamespacePrefix:o,SobjectType:i}=a.data;return[{id:n,developerName:t,namespacePrefix:o||null,...i?{sobjectType:i}:{}}]}):[]}function s(e,r){return e?`${e}__${r}`:r}function N(e){return s(e.namespacePrefix,e.developerName)}function g(e){return{namespacePrefix:e.namespacePrefix??null,developerName:e.developerName}}function x(e){return`${e.sobjectType??""}::${e.namespacePrefix??""}::${e.developerName}`}function m(e){let r=e.indexOf("__");return r>0&&r<e.length-2?{namespacePrefix:e.slice(0,r),developerName:e.slice(r+2)}:{namespacePrefix:void 0,developerName:e}}function P(e,r,a){let n=u(m(e),r,a);if(!("ambiguous"in n))return n;let t=n.ambiguous.filter(o=>a(o).namespacePrefix===null);return t.length===1?{found:t[0]}:n}function u(e,r,a){let n=r.filter(t=>{let o=a(t);return o.developerName!==e.developerName?!1:e.namespacePrefix===void 0||o.namespacePrefix===e.namespacePrefix});return n.length===1?{found:n[0]}:n.length>1?{ambiguous:n}:{none:!0}}function f(e){let r=s(e.namespacePrefix,e.developerName);return e.namespacePrefix?`${r}, of package ${e.namespacePrefix}`:e.namespacePrefix===null?`${r}, the org's own`:r}function R(e,r,a,n){return`${r} names ${n.length} ${e} record types in ${a}: `+n.map(f).join(" and ")}export{T as a,y as b,s as c,N as d,g as e,x as f,m as g,P as h,u as i,R as j};
7
+ import{b as c,l as p}from"./chunk-WZQEK4WT.mjs";var T="SELECT Id, SobjectType, DeveloperName, NamespacePrefix FROM RecordType",d=p({Id:c().min(15),DeveloperName:c().min(1),NamespacePrefix:c().nullable().optional(),SobjectType:c().min(1).optional()}).loose();function y(e){return Array.isArray(e)?e.flatMap(r=>{let a=d.safeParse(r);if(!a.success)return[];let{Id:n,DeveloperName:t,NamespacePrefix:o,SobjectType:i}=a.data;return[{id:n,developerName:t,namespacePrefix:o||null,...i?{sobjectType:i}:{}}]}):[]}function s(e,r){return e?`${e}__${r}`:r}function N(e){return s(e.namespacePrefix,e.developerName)}function g(e){return{namespacePrefix:e.namespacePrefix??null,developerName:e.developerName}}function x(e){return`${e.sobjectType??""}::${e.namespacePrefix??""}::${e.developerName}`}function m(e){let r=e.indexOf("__");return r>0&&r<e.length-2?{namespacePrefix:e.slice(0,r),developerName:e.slice(r+2)}:{namespacePrefix:void 0,developerName:e}}function P(e,r,a){let n=u(m(e),r,a);if(!("ambiguous"in n))return n;let t=n.ambiguous.filter(o=>a(o).namespacePrefix===null);return t.length===1?{found:t[0]}:n}function u(e,r,a){let n=r.filter(t=>{let o=a(t);return o.developerName!==e.developerName?!1:e.namespacePrefix===void 0||o.namespacePrefix===e.namespacePrefix});return n.length===1?{found:n[0]}:n.length>1?{ambiguous:n}:{none:!0}}function f(e){let r=s(e.namespacePrefix,e.developerName);return e.namespacePrefix?`${r}, of package ${e.namespacePrefix}`:e.namespacePrefix===null?`${r}, the org's own`:r}function R(e,r,a,n){return`${r} names ${n.length} ${e} record types in ${a}: `+n.map(f).join(" and ")}export{T as a,y as b,s as c,N as d,g as e,x as f,m as g,P as h,u as i,R 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 as je,b as Ne,c as Pe,d as Fe,k as We,l as xe,o as Le,q as _e}from"./chunk-YCSFP6ER.mjs";import{e as Me}from"./chunk-GYKNCYES.mjs";import{b as De,f as Te}from"./chunk-YOGMP72T.mjs";import{m as Be}from"./chunk-6CDIIFNX.mjs";import{b as ve}from"./chunk-YIGFYZQY.mjs";import{i as he,j as we,k as ke,l as ye,m as be,p as Re,q as Ae}from"./chunk-GWRKS3AL.mjs";import{A as Ie,B as $e,y as Se,z as Ue}from"./chunk-6SEDOIO3.mjs";import{C as ge}from"./chunk-ZWCRWF7E.mjs";import{a as le,b as fe}from"./chunk-54HYHHVL.mjs";import{i as Oe,j as Ce}from"./chunk-ETT5GP4P.mjs";import{t as pe}from"./chunk-T26C576X.mjs";import{b as ue,d as ce}from"./chunk-BNO5GIJ6.mjs";import{c as me}from"./chunk-6IGEASOF.mjs";import{fc as Ee}from"./chunk-KOQV4WXC.mjs";import{g as L,h as _,q as de}from"./chunk-EAFLDSQ2.mjs";import{b as x}from"./chunk-CA5NAXSU.mjs";import{od as se,wd as W}from"./chunk-DPYTG6DM.mjs";var C=class extends Error{constructor(){super("The undo was stopped before it wrote anything to the org."),this.name="UndoStopped"}},z="No record was written.",Je="accept that it runs to undo the rewind all the same";function ze(e){return e.slice(0,15)}function Ke(e){return{query:n=>e.query(n),queryMore:n=>e.queryMore(n)}}function Ye(e,n,t){if(e.kind==="org")return;let a=e.userKey;if(n.users.some(i=>i.slice(0,15)!==a))return{code:"PERMISSIONS",message:`This rewind was made as another user than ${t}: what it deleted is that user's deletion in the recycle bin, which Salesforce brings back only for a user with View All Data and Modify All Data. Undo it as the user it was made as, or as a user with View All Data and Modify All Data. ${z}`};let r=n.objects.flatMap(i=>{let l=e.notHeld.get(i);return l===void 0?[]:[`${i}: ${l}`]});if(r.length!==0)return{code:"PERMISSIONS",message:`Undo takes back what the rewind did to objects ${t} no longer holds whole (${r.join("; ")}), and does not stop part way: an undo left part way could not be offered again. Undo it once the user has View All and Modify All on them again, or as a user with View All Data and Modify All Data. ${z}`}}function Qe(e,n){return{undone:!1,refusal:{code:e,message:n}}}function Xe(e,n){return{code:"RUN_WRITING",message:`${n.operation==="take"?`A checkpoint of ${e} is being taken`:n.operation==="rewind"?`A rewind is writing to ${e}`:n.operation==="undo"?`An undo is writing to ${e}`:`SandForge is deleting checkpoints of ${e}`} (process ${n.pid} on ${n.host}): undo the rewind once it has ended. No record was read or written.`}}function Ze(e,n,t,a){let r=W(n,t),i=[...new Set(r.map(b=>b.objectApiName))],l=(t.setToDraft??[]).length>0?", sets an order back to Draft":"",h=r.length>0?`${Me(r)} flow(s), trigger(s) or rule(s) of ${i.join(", ")} run as the undo brings records back, gives them their values back${l} or sends them back to the recycle bin`:"what runs as the undo writes could not all be read, so automation may run";return{code:"AUTOMATION",message:`${e}: ${h}. ${ke("undo",a)}Undo refused; ${Je}. ${z}`}}async function et(e,n){let t=0,a=0;for await(let r of n.bringBack.pages(L)){t+=r.length;for(let i of ce(r,ue)){let l=await e.queryDeleted(`SELECT Id, ContentSize FROM ${L} WHERE Id IN (${i}) AND IsDeleted = true`);for(let h of l.records)typeof h.ContentSize=="number"&&(a+=h.ContentSize)}}return{files:t,bytes:a}}function tt(e,n){return e.status==="cancelled"||e.status==="failure"?e.status:n.some(t=>t.reason==="changedDuringRewind")?"unstable":e.status}function nt(e,n){return e.map(t=>{let a=Object.keys(t.by).filter(i=>!n.has(ze(i)));if(a.length===0)return{objectApiName:t.objectApiName,reason:"automation",count:t.count,ids:[...t.ids]};let r=a.length===1&&a[0]!=="unknown"?a[0]:void 0;return{objectApiName:t.objectApiName,reason:"changedDuringRewind",...r!==void 0?{by:r}:{},count:t.count,ids:[...t.ids]}})}async function Ot(e,n){let{checkpoint:t,folder:a,orgName:r,rewindId:i}=n,l=e.signal,h=()=>l?.aborted===!0,b=(U,k)=>e.onProgress?.({percentage:U,step:k}),c=_e(e.org,e.undelete),T,S=await ve(Ke(c.org),{act:"undo",orgName:r,registered:n.registered,username:n.username,organizationId:t.org.organizationId,customSettings:de(t)},{userId:async()=>T=await c.org.userId()});if(!S.allowed)return{undone:!1,refusal:S.refusal};let R=e.store.lock(t.org.organizationId,"undo",t.checkpointId);if("busy"in R)return{undone:!1,refusal:Xe(r,R.busy)};try{let U=await e.runWriting?.(S.org.id);if(U!==void 0)return Qe("RUN_WRITING",U);let k=await Ue(c.org,r);if(h())throw new C;b(5,"Reading what the rewind did");let g=await Ne(a,i,t.objects),G=Pe(g),M=g.goesWithParent.objects,Ge=g.remade.keys.size>0?"Sending back to the recycle bin what the rewind brought back, and deleting again what it made again":"Sending back to the recycle bin what the rewind brought back",A=o=>o.filter(u=>u.count>0).map(u=>u.objectApiName),j=g.links,q=o=>o>0?[_]:[],N=g.remade.objects.filter(({objectApiName:o,count:u})=>u>0&&ge([o]).length>0),m={bringBack:A(g.bringBack.objects),giveBack:[...A(g.giveBack.objects),...q(j?.share.count??0)],...N.length>0?{setToDraft:A(N)}:{},delete:[...new Set([...A(M),...A(g.remove.objects),...q(j?.remove.count??0)])],...(j?.reinsert.count??0)>0?{recreate:[_]}:{}},H;try{H=await et(c.org,g)}finally{await g.dispose()}let V=$e("undo",H,k.fileStorage?.remaining,r);if(V)return{undone:!1,refusal:V};let w=[...new Set([...m.bringBack??[],...m.giveBack??[],...m.setToDraft??[],...m.delete??[],...m.recreate??[]])],P;try{P=await De({grants:S.grants,...T!==void 0?{userId:T}:{},username:n.username,checkpoint:t,reader:Ce(c.org,l)})}catch(o){throw o instanceof Oe||h()?new C:o}if(P.kind==="perObject"){let o=await je(a,i),u=Ye(P,{users:o.passes.map(f=>f.userId),objects:w},n.username);if(u)return{undone:!1,refusal:u}}let d;if(w.length>0&&e.readAutomation){try{d=await e.readAutomation(w)}catch(o){d=Le(w,x(o))}c.add(d.requests)}let I=d,y=w.length>0?await We(e.mute,d,m):{},$="refusal"in y?y:void 0,J="refusal"in y?void 0:y.mute;y.automation&&(d=y.automation);let v=$?$.plan:J?.plan,K=n.acceptEmails===!0,p=w.length>0&&I?await Re({act:"undo",orgName:r,automation:I,steps:m,...v?{plan:v}:{},accepted:K,mayMute:e.mute===void 0&&n.canMute===!0,read:()=>me(c.org)}):void 0,Y=he(G,M,N),Q=d?we(Y,d):void 0,O=$?[$.refusal]:[];d&&!n.acceptAutomation&&(W(d,m).length>0||se(d.unread)||Q!==void 0)&&O.push(Ze(r,d,m,Q));let X=Se({objects:t.objects,rewound:G,along:M,automationRequests:0}),Z=Ee(p?.ofRun),ee=Ie("undo",{run:c.used()-(Z.deliverability??0)+X.apiRequests,...Z},k,r);w.length>0&&ee&&O.push(ee);let te=d?be("undo",ye(Y,d,k.emails),r):void 0;w.length>0&&te&&O.push(te),p?.refusal&&O.push(p.refusal);let[ne,...oe]=O;if(ne)return{undone:!1,refusal:ne,...oe.length>0?{alsoRefused:oe}:{}};if(h())throw new C;let qe=await c.org.userId(),He=new Set(Te(t.takenBy,qe).map(ze));b(20,"Bringing back what the rewind deleted and giving back what it wrote over");let B,E;try{E=await xe(J,`undo ${t.checkpointId} ${i}`,o=>{let u=o&&v&&I&&p?Ae({act:"undo",orgName:r,automation:I,steps:m,plan:v,held:o.outcome,planned:p.ofRun.senders,...p.ofRun.read?{reading:p.ofRun.read.reading}:{},accepted:K}):void 0;return u?Promise.resolve({relit:u}):Fe({folder:a,rewindId:i,lock:R.lock,objects:t.objects,org:c.org,undelete:c.undelete,splitting:le(fe(k.remaining,c.used()+X.apiRequests)),...l?{signal:l}:{},...e.onUndeletable?{onUndeletable:e.onUndeletable}:{},onProgress:(f,ae,Ve)=>b(20+Math.round(70*f/Math.max(ae,1)),`${Ge}: ${Ve} ${f} / ${ae}`)})},o=>{B=o})}catch(o){if(!pe(o))throw o;return{undone:!1,refusal:{code:"MUTE",message:`${o.message} No record was written.`}}}if("relit"in E)return{undone:!1,refusal:E.relit};let s=E,re=nt(s.residual,He),D=tt(s,re),F=[...s.notes];if(D!=="cancelled"&&D!=="failure"){let o=(e.now??(()=>new Date))().toISOString();try{await e.store.update(t.checkpointId,f=>f.lastRewind?.rewindId===i?{...f,lastRewind:{...f.lastRewind,undoneAt:o}}:f)}catch(f){F.push(`The checkpoint could not be told the rewind was undone (${x(f)}): its list may still offer to undo it.`)}let u=await Be({folder:a,lock:R.lock,checkpoint:t,rewindId:i,status:D,undoneAt:o});u!==void 0&&F.push(u)}let ie=c.used();return{undone:!0,result:{checkpointId:t.checkpointId,rewindId:i,status:D,deleted:s.deleted,...s.remade?{remade:s.remade}:{},...s.carriedAlone?{carriedAlone:s.carriedAlone}:{},...s.wentAlong?{wentAlong:s.wentAlong}:{},restored:s.restored,undeleted:s.undeleted,...s.files?{files:s.files}:{},residual:re,passes:1,apiRequests:{used:ie,leftToday:Math.max(0,k.remaining-ie)},finishedAt:s.finishedAt,...B?{mutedAutomation:B}:{}},notes:F,...p?.gate.audit!==void 0?{deliverability:p.gate.audit}:{}}}finally{R.lock.release()}}export{C as a,Je as b,Ot as c};