sandforge 1.83.0 → 1.84.1

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 (254) hide show
  1. package/README.md +1 -1
  2. package/lib/chunk-23SEDORH.mjs +11 -0
  3. package/lib/{chunk-I5C4O3VA.mjs → chunk-24RFOFYT.mjs} +1 -1
  4. package/lib/chunk-26POJDIT.mjs +7 -0
  5. package/lib/{chunk-WJAZ5LHL.mjs → chunk-2AZQHBEF.mjs} +1 -1
  6. package/lib/{chunk-IHGYJZZ2.mjs → chunk-2HVOZUM4.mjs} +1 -1
  7. package/lib/{chunk-3V4YH5KO.mjs → chunk-2JDAOWUW.mjs} +1 -1
  8. package/lib/{chunk-BNKT3R3F.mjs → chunk-2METQHGG.mjs} +1 -1
  9. package/lib/chunk-2WFIVO4F.mjs +13 -0
  10. package/lib/chunk-2YHZBUZE.mjs +7 -0
  11. package/lib/{chunk-7DPHZWA4.mjs → chunk-326AJTIU.mjs} +14 -14
  12. package/lib/{chunk-UIR77ZJD.mjs → chunk-36JOHEJL.mjs} +1 -1
  13. package/lib/chunk-3PVRGTVK.mjs +7 -0
  14. package/lib/{chunk-2WMKJVD2.mjs → chunk-3Q353S2R.mjs} +1 -1
  15. package/lib/chunk-3TZSBHEY.mjs +7 -0
  16. package/lib/{chunk-T36DZJPH.mjs → chunk-43TOMFV4.mjs} +1 -1
  17. package/lib/{chunk-XAMMIPZ4.mjs → chunk-4CVUUVGJ.mjs} +1 -1
  18. package/lib/{chunk-6YC2ELCU.mjs → chunk-4EOHEDFP.mjs} +1 -1
  19. package/lib/{chunk-ZB5E7NHU.mjs → chunk-4JE4BYXK.mjs} +1 -1
  20. package/lib/{chunk-JREKJO3D.mjs → chunk-54WZUS7J.mjs} +1 -1
  21. package/lib/{chunk-CGZGL6VT.mjs → chunk-5CRLRHOJ.mjs} +1 -1
  22. package/lib/{chunk-UOHZW2L4.mjs → chunk-5IZTFMJM.mjs} +1 -1
  23. package/lib/{chunk-6VOQFISN.mjs → chunk-5M5FQ7RP.mjs} +1 -1
  24. package/lib/{chunk-U4YFYSF3.mjs → chunk-5SMWFNE7.mjs} +1 -1
  25. package/lib/{chunk-HQZUQXDC.mjs → chunk-5XTUSN72.mjs} +1 -1
  26. package/lib/chunk-6I6TWNV5.mjs +7 -0
  27. package/lib/{chunk-QLRWU3MB.mjs → chunk-6JWWSDM6.mjs} +1 -1
  28. package/lib/chunk-6O222PW6.mjs +7 -0
  29. package/lib/{chunk-J3TIHLWG.mjs → chunk-6PD6K7LP.mjs} +1 -1
  30. package/lib/{chunk-ISAUCWYK.mjs → chunk-6QE6R6RL.mjs} +1 -1
  31. package/lib/{chunk-2KTGDYUH.mjs → chunk-6WX5ZU7Q.mjs} +1 -1
  32. package/lib/{chunk-XAUQXYPW.mjs → chunk-6YL7BNYD.mjs} +1 -1
  33. package/lib/chunk-6ZLKIT3H.mjs +7 -0
  34. package/lib/{chunk-XKFHTBAB.mjs → chunk-7QYHEHMA.mjs} +1 -1
  35. package/lib/chunk-7SQSWVAU.mjs +9 -0
  36. package/lib/{chunk-NNV7IGM7.mjs → chunk-7UVKIWKV.mjs} +1 -1
  37. package/lib/{chunk-RZKJQOOC.mjs → chunk-7WATA4SB.mjs} +1 -1
  38. package/lib/{chunk-DMT5SCO3.mjs → chunk-7YNM6KFZ.mjs} +1 -1
  39. package/lib/{chunk-TMIESDE5.mjs → chunk-A3MYSOOC.mjs} +1 -1
  40. package/lib/chunk-AL4C3GFT.mjs +7 -0
  41. package/lib/chunk-B3FBHVNN.mjs +21 -0
  42. package/lib/{chunk-CDWZGQAJ.mjs → chunk-B63POIPQ.mjs} +1 -1
  43. package/lib/{chunk-YEVB7LVK.mjs → chunk-BAWCOKRW.mjs} +1 -1
  44. package/lib/{chunk-FVLFO2S6.mjs → chunk-BBRWFKS5.mjs} +1 -1
  45. package/lib/chunk-BEA27DLS.mjs +7 -0
  46. package/lib/chunk-BRY3PLIZ.mjs +7 -0
  47. package/lib/chunk-CBH3TOWK.mjs +341 -0
  48. package/lib/{chunk-7V2UYZ6S.mjs → chunk-CPQIZGG5.mjs} +1 -1
  49. package/lib/chunk-CVHNXJH3.mjs +7 -0
  50. package/lib/{chunk-ZOSESZ22.mjs → chunk-D4GF4FAB.mjs} +1 -1
  51. package/lib/chunk-DGDRQRCW.mjs +7 -0
  52. package/lib/{chunk-2N73W63D.mjs → chunk-DPMRIMUC.mjs} +1 -1
  53. package/lib/chunk-DUN2EPRC.mjs +7 -0
  54. package/lib/chunk-E3A3LOCY.mjs +7 -0
  55. package/lib/{chunk-KWAVSZ2B.mjs → chunk-EAC5QCE3.mjs} +1 -1
  56. package/lib/{chunk-JUOQUG7U.mjs → chunk-EC72TIEG.mjs} +1 -1
  57. package/lib/chunk-EPFCERGL.mjs +7 -0
  58. package/lib/{chunk-6KOUYHEY.mjs → chunk-ETDCBLGU.mjs} +1 -1
  59. package/lib/{chunk-2R6GFNKF.mjs → chunk-F3AQW6IU.mjs} +1 -1
  60. package/lib/{chunk-AHUGG3WU.mjs → chunk-FITPY3L4.mjs} +1 -1
  61. package/lib/chunk-FNJ4SGWO.mjs +7 -0
  62. package/lib/{chunk-EOQON3E5.mjs → chunk-FP7CYB2F.mjs} +1 -1
  63. package/lib/{chunk-262TP6UU.mjs → chunk-GKY2JMHY.mjs} +1 -1
  64. package/lib/{chunk-JBWJ6UEZ.mjs → chunk-GMIGWR6U.mjs} +1 -1
  65. package/lib/{chunk-OS5GE52G.mjs → chunk-GNRSF65U.mjs} +1 -1
  66. package/lib/chunk-GOOVPVWX.mjs +7 -0
  67. package/lib/{chunk-DB5RVDC5.mjs → chunk-GWZRR3MM.mjs} +1 -1
  68. package/lib/{chunk-SX6QWYCQ.mjs → chunk-H2BHESDA.mjs} +2 -2
  69. package/lib/chunk-H4CGM6YO.mjs +7 -0
  70. package/lib/{chunk-NFEBX75O.mjs → chunk-HCGXK7G7.mjs} +1 -1
  71. package/lib/{chunk-4X5D3MSV.mjs → chunk-HIDW7FNV.mjs} +1 -1
  72. package/lib/chunk-HSBXRQTI.mjs +7 -0
  73. package/lib/chunk-HUZPBE47.mjs +7 -0
  74. package/lib/{chunk-F5SBGJWW.mjs → chunk-HV7VPEXP.mjs} +1 -1
  75. package/lib/chunk-I6E6T6YY.mjs +7 -0
  76. package/lib/chunk-IUM4NFKI.mjs +10 -0
  77. package/lib/chunk-IVFVNNGB.mjs +37 -0
  78. package/lib/{chunk-L4MSL4U7.mjs → chunk-IZGCEOYO.mjs} +1 -1
  79. package/lib/{chunk-E3RQ575Y.mjs → chunk-J3DND3BC.mjs} +1 -1
  80. package/lib/{chunk-MJD6CPZZ.mjs → chunk-JAEDM4SI.mjs} +1 -1
  81. package/lib/chunk-JCFBFF4Y.mjs +7 -0
  82. package/lib/{chunk-U2CTKIPE.mjs → chunk-JE6SCT6R.mjs} +1 -1
  83. package/lib/{chunk-XJICAOAQ.mjs → chunk-JGZPD4IM.mjs} +1 -1
  84. package/lib/{chunk-XCJUNX63.mjs → chunk-JKJ74BX5.mjs} +1 -1
  85. package/lib/{chunk-WAYQLQAD.mjs → chunk-JLSIWO4Z.mjs} +1 -1
  86. package/lib/{chunk-D7XUNWWU.mjs → chunk-JSAJS3MY.mjs} +1 -1
  87. package/lib/chunk-JTJK2D36.mjs +7 -0
  88. package/lib/{chunk-OTJH6AEA.mjs → chunk-KAZS5Z6W.mjs} +1 -1
  89. package/lib/chunk-KB4ZHM4Q.mjs +10 -0
  90. package/lib/{chunk-N2HYG3BL.mjs → chunk-KGU4SVIT.mjs} +1 -1
  91. package/lib/{chunk-FKCIGJOI.mjs → chunk-KJWFYBMU.mjs} +2 -2
  92. package/lib/{chunk-KXUOHACP.mjs → chunk-KZTZDC7H.mjs} +1 -1
  93. package/lib/{chunk-S4PRKKGC.mjs → chunk-L2E5WBGD.mjs} +1 -1
  94. package/lib/{chunk-X2XZQ434.mjs → chunk-L53JWJ3S.mjs} +1 -1
  95. package/lib/{chunk-CQAFVEKP.mjs → chunk-LA4KIATH.mjs} +6 -6
  96. package/lib/chunk-LC3NDW4N.mjs +7 -0
  97. package/lib/{chunk-4V3QO7HF.mjs → chunk-LKTNQEBS.mjs} +1 -1
  98. package/lib/chunk-M2ABR4JM.mjs +7 -0
  99. package/lib/{chunk-3CM7LAPE.mjs → chunk-M4BLK6HJ.mjs} +1 -1
  100. package/lib/{chunk-Z3MGN42K.mjs → chunk-M6K34KGF.mjs} +1 -1
  101. package/lib/{chunk-TUPZY2QJ.mjs → chunk-MDMPJEV3.mjs} +1 -1
  102. package/lib/{chunk-BVZ5H3N4.mjs → chunk-MJZU3U5O.mjs} +68 -63
  103. package/lib/{chunk-OUU47Y7A.mjs → chunk-MSIEU5MR.mjs} +1 -1
  104. package/lib/{chunk-QQDZQCO2.mjs → chunk-N4WPCWJO.mjs} +1 -1
  105. package/lib/{chunk-MTM4KG3T.mjs → chunk-NCZKWSC7.mjs} +1 -1
  106. package/lib/{chunk-Y7YUNRKK.mjs → chunk-NED4MBIM.mjs} +1 -1
  107. package/lib/{chunk-QKJXIY6L.mjs → chunk-NOBQTEQD.mjs} +1 -1
  108. package/lib/{chunk-WBELLGNE.mjs → chunk-NSQWI7ZY.mjs} +1 -1
  109. package/lib/{chunk-BPHTA6KP.mjs → chunk-O677VOGO.mjs} +1 -1
  110. package/lib/chunk-OFTT7J2M.mjs +7 -0
  111. package/lib/{chunk-JH4ZTVQN.mjs → chunk-OLCVHL7I.mjs} +1 -1
  112. package/lib/chunk-OM5NORJG.mjs +7 -0
  113. package/lib/{chunk-QP3JLFIO.mjs → chunk-OMNMLKDT.mjs} +1 -1
  114. package/lib/{chunk-WABXKL4N.mjs → chunk-OPMO6I45.mjs} +1 -1
  115. package/lib/{chunk-7ZBDACVG.mjs → chunk-OUZQPYT3.mjs} +1 -1
  116. package/lib/chunk-OVNMB6Q2.mjs +7 -0
  117. package/lib/{chunk-DKDKCGXV.mjs → chunk-PAXNWTYK.mjs} +1 -1
  118. package/lib/{chunk-GLN4PI5P.mjs → chunk-PBY2O6OF.mjs} +1 -1
  119. package/lib/chunk-PEDQPM2P.mjs +926 -0
  120. package/lib/chunk-PH7SP4YK.mjs +21 -0
  121. package/lib/{chunk-BT43WSOS.mjs → chunk-PMN4PAC3.mjs} +1 -1
  122. package/lib/chunk-PMWAFDUB.mjs +48 -0
  123. package/lib/chunk-PPLVFX6N.mjs +7 -0
  124. package/lib/{chunk-L3I6DAHX.mjs → chunk-PR3XCSPO.mjs} +1 -1
  125. package/lib/{chunk-WZN36ACK.mjs → chunk-PR42EZSR.mjs} +1 -1
  126. package/lib/{chunk-NDFFIJL5.mjs → chunk-PWRJRL5U.mjs} +1 -1
  127. package/lib/{chunk-NS6ONPWL.mjs → chunk-Q7GIJBCD.mjs} +1 -1
  128. package/lib/chunk-Q7TLC3I2.mjs +7 -0
  129. package/lib/{chunk-ALBY5SOH.mjs → chunk-QAFPQ3YB.mjs} +1 -1
  130. package/lib/{chunk-KKS2KFBT.mjs → chunk-QKEKG2LD.mjs} +1 -1
  131. package/lib/{chunk-OOIDCHBQ.mjs → chunk-QO53K5W2.mjs} +2 -2
  132. package/lib/{chunk-HVX2AFYW.mjs → chunk-QTG6LUZT.mjs} +1 -1
  133. package/lib/{chunk-K7G3W7XH.mjs → chunk-RE7RYF3B.mjs} +1 -1
  134. package/lib/{chunk-JIPT5FUD.mjs → chunk-RGBGUCJA.mjs} +1 -1
  135. package/lib/{chunk-GT5ZKU6V.mjs → chunk-RGUQOSBU.mjs} +1 -1
  136. package/lib/{chunk-VXZ5PTOM.mjs → chunk-RHNTHGNU.mjs} +1 -1
  137. package/lib/chunk-RKTFFCNS.mjs +7 -0
  138. package/lib/chunk-RMFU4BAL.mjs +28 -0
  139. package/lib/{chunk-DNQKVCUV.mjs → chunk-ROV3QXEF.mjs} +11 -11
  140. package/lib/chunk-RT47RKLY.mjs +7 -0
  141. package/lib/{chunk-ISOSTAJR.mjs → chunk-S42RBRH2.mjs} +1 -1
  142. package/lib/{chunk-27BBEGUD.mjs → chunk-SI267LYR.mjs} +1 -1
  143. package/lib/chunk-T3G6VZNS.mjs +7 -0
  144. package/lib/chunk-TNT27RBG.mjs +7 -0
  145. package/lib/chunk-UBIKR5VO.mjs +7 -0
  146. package/lib/chunk-UI3JQVRU.mjs +8 -0
  147. package/lib/{chunk-RVCPQVKM.mjs → chunk-UIOMAX56.mjs} +1 -1
  148. package/lib/chunk-UX3BVH2Y.mjs +7 -0
  149. package/lib/{chunk-L4RJX7DG.mjs → chunk-VCUXCK36.mjs} +1 -1
  150. package/lib/chunk-VINGECAJ.mjs +10 -0
  151. package/lib/chunk-VOXJHJIE.mjs +7 -0
  152. package/lib/chunk-W6PN6TJG.mjs +7 -0
  153. package/lib/{chunk-D6JT4PAB.mjs → chunk-WAPSSYMT.mjs} +1 -1
  154. package/lib/{chunk-7BQMBXKX.mjs → chunk-WUUKFE2U.mjs} +1 -1
  155. package/lib/chunk-WWTCWWZI.mjs +7 -0
  156. package/lib/chunk-WXDLQT2O.mjs +10 -0
  157. package/lib/{chunk-TCEXCHXR.mjs → chunk-WY5V5PR3.mjs} +1 -1
  158. package/lib/chunk-X4BXESMQ.mjs +7 -0
  159. package/lib/chunk-XBQGZGWR.mjs +7 -0
  160. package/lib/{chunk-AXFD2OH6.mjs → chunk-XGGOUNPP.mjs} +1 -1
  161. package/lib/chunk-XKWW3GKF.mjs +7 -0
  162. package/lib/{chunk-PDRXM5WN.mjs → chunk-Y2DRK37K.mjs} +1 -1
  163. package/lib/{chunk-ZXOUWHYE.mjs → chunk-YA6ATMTB.mjs} +1 -1
  164. package/lib/{chunk-54HYHHVL.mjs → chunk-YDXMTWAT.mjs} +1 -1
  165. package/lib/chunk-YHR4WQPR.mjs +7 -0
  166. package/lib/{chunk-LWES2KZE.mjs → chunk-YTLUYSMF.mjs} +1 -1
  167. package/lib/{chunk-2K5BYZQM.mjs → chunk-YWEQQL3C.mjs} +1 -1
  168. package/lib/{chunk-C6RKM4BB.mjs → chunk-Z4LKKOFY.mjs} +1 -1
  169. package/lib/chunk-ZBAWJUG2.mjs +7 -0
  170. package/lib/{chunk-446GBKAC.mjs → chunk-ZJW6YOMV.mjs} +1 -1
  171. package/lib/chunk-ZQQXSCVI.mjs +7 -0
  172. package/lib/{chunk-L6CLN664.mjs → chunk-ZQWIVYVM.mjs} +1 -1
  173. package/lib/{chunk-CXKZ6TYV.mjs → chunk-ZV7ZFQQC.mjs} +1 -1
  174. package/lib/sandforge-autopilot.mjs +25 -25
  175. package/lib/sandforge-backup.mjs +1 -1
  176. package/lib/sandforge-checkpoint.mjs +1 -1
  177. package/lib/sandforge-cleanup.mjs +1 -1
  178. package/lib/sandforge-clone.mjs +1 -1
  179. package/lib/sandforge-compare.mjs +52 -21
  180. package/lib/sandforge-dataops.mjs +1 -1
  181. package/lib/sandforge-empty.mjs +1 -1
  182. package/lib/sandforge-env.mjs +95 -95
  183. package/lib/sandforge-frozen.mjs +1 -1
  184. package/lib/sandforge-mcp.mjs +12 -12
  185. package/lib/sandforge-monitor.mjs +1 -1
  186. package/lib/sandforge-pipeline.mjs +1 -1
  187. package/lib/sandforge-seed.mjs +1 -1
  188. package/lib/sandforge-sync.mjs +1 -1
  189. package/lib/sandforge-users.mjs +1 -1
  190. package/lib/sandforge.mjs +1 -1
  191. package/lib/sf/sandforge/compare.mjs +2 -2
  192. package/lib/sfPlugin.mjs +1 -1
  193. package/oclif.manifest.json +1 -1
  194. package/package.json +1 -1
  195. package/lib/chunk-2ADSD5WK.mjs +0 -7
  196. package/lib/chunk-2GSMHGIV.mjs +0 -7
  197. package/lib/chunk-36Y225OM.mjs +0 -7
  198. package/lib/chunk-3OVTKRS4.mjs +0 -7
  199. package/lib/chunk-4GCYGQXD.mjs +0 -7
  200. package/lib/chunk-4JKR4PTZ.mjs +0 -8
  201. package/lib/chunk-5OGNK3JP.mjs +0 -37
  202. package/lib/chunk-6QSHWIZI.mjs +0 -48
  203. package/lib/chunk-77IVKH7R.mjs +0 -7
  204. package/lib/chunk-77MZRBWX.mjs +0 -7
  205. package/lib/chunk-7WSQ65WG.mjs +0 -9
  206. package/lib/chunk-A32ISQ6M.mjs +0 -28
  207. package/lib/chunk-AG24QMSY.mjs +0 -7
  208. package/lib/chunk-BH76USTQ.mjs +0 -11
  209. package/lib/chunk-BZ24IAP5.mjs +0 -7
  210. package/lib/chunk-CN5HGFG4.mjs +0 -7
  211. package/lib/chunk-CTPLYUXA.mjs +0 -7
  212. package/lib/chunk-DIGUC7S4.mjs +0 -341
  213. package/lib/chunk-DSR2MSBH.mjs +0 -7
  214. package/lib/chunk-ETNQHIDI.mjs +0 -9
  215. package/lib/chunk-FBXH4VRQ.mjs +0 -7
  216. package/lib/chunk-FYWNSMOZ.mjs +0 -10
  217. package/lib/chunk-GEEWPTV5.mjs +0 -7
  218. package/lib/chunk-GTRU5AV5.mjs +0 -7
  219. package/lib/chunk-I3ZO76LL.mjs +0 -21
  220. package/lib/chunk-ISA2NYJV.mjs +0 -7
  221. package/lib/chunk-IXIY6Q4M.mjs +0 -7
  222. package/lib/chunk-JAV6F6OA.mjs +0 -7
  223. package/lib/chunk-JYUMD357.mjs +0 -7
  224. package/lib/chunk-L47JCNP3.mjs +0 -7
  225. package/lib/chunk-LI2XNV7F.mjs +0 -7
  226. package/lib/chunk-LP2D3JJP.mjs +0 -7
  227. package/lib/chunk-LYOGCIYD.mjs +0 -925
  228. package/lib/chunk-N5UIE4IR.mjs +0 -7
  229. package/lib/chunk-O7GCCRPW.mjs +0 -7
  230. package/lib/chunk-OO24ZYYJ.mjs +0 -7
  231. package/lib/chunk-OS6HFJ7L.mjs +0 -7
  232. package/lib/chunk-P6WRYJN3.mjs +0 -7
  233. package/lib/chunk-PGRY365W.mjs +0 -7
  234. package/lib/chunk-PPGDAUEQ.mjs +0 -7
  235. package/lib/chunk-Q4PPI3KG.mjs +0 -7
  236. package/lib/chunk-QFTF2PGS.mjs +0 -21
  237. package/lib/chunk-QO4MPHZD.mjs +0 -7
  238. package/lib/chunk-QXB6U3ZP.mjs +0 -7
  239. package/lib/chunk-R3OM3X4L.mjs +0 -8
  240. package/lib/chunk-R7GKMAT4.mjs +0 -7
  241. package/lib/chunk-SCKUIE3R.mjs +0 -7
  242. package/lib/chunk-SU65Z2BA.mjs +0 -7
  243. package/lib/chunk-T7DDS4UQ.mjs +0 -7
  244. package/lib/chunk-TQJ5NPRC.mjs +0 -7
  245. package/lib/chunk-VZLJZEV2.mjs +0 -7
  246. package/lib/chunk-W3BQGMTR.mjs +0 -7
  247. package/lib/chunk-WXU6ZJIV.mjs +0 -7
  248. package/lib/chunk-X4HZD5U2.mjs +0 -7
  249. package/lib/chunk-X6XNTOGO.mjs +0 -7
  250. package/lib/chunk-XMQ5R6TC.mjs +0 -10
  251. package/lib/chunk-XPXEQKLR.mjs +0 -7
  252. package/lib/chunk-YBZIDW6W.mjs +0 -7
  253. package/lib/chunk-ZCOSME6P.mjs +0 -7
  254. package/lib/chunk-ZTHC42X6.mjs +0 -7
@@ -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 a,k as b,l as c,m as d,n as e,o as f,p as g,q as h,r as i,s as j,t as k,u as l,v as m,w as n}from"./chunk-2WFIVO4F.mjs";import"./chunk-7QYHEHMA.mjs";import"./chunk-WXDLQT2O.mjs";import"./chunk-NSQWI7ZY.mjs";import"./chunk-GNRSF65U.mjs";import"./chunk-O677VOGO.mjs";import"./chunk-JE6SCT6R.mjs";import"./chunk-PWRJRL5U.mjs";import"./chunk-24RFOFYT.mjs";import"./chunk-UIOMAX56.mjs";import"./chunk-QAFPQ3YB.mjs";import"./chunk-KJWFYBMU.mjs";import"./chunk-Z4LKKOFY.mjs";import"./chunk-2HVOZUM4.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-WB2RIVO3.mjs";import"./chunk-XGGOUNPP.mjs";import"./chunk-L53JWJ3S.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-OFTT7J2M.mjs";import"./chunk-HIDW7FNV.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-VINGECAJ.mjs";import"./chunk-H4CGM6YO.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-YDXMTWAT.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-PMN4PAC3.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-FP7CYB2F.mjs";import"./chunk-NED4MBIM.mjs";import"./chunk-UI3JQVRU.mjs";import"./chunk-KGU4SVIT.mjs";import"./chunk-JAEDM4SI.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-MSIEU5MR.mjs";import"./chunk-LC3NDW4N.mjs";import"./chunk-KB4ZHM4Q.mjs";import"./chunk-23SEDORH.mjs";import"./chunk-W6PN6TJG.mjs";import"./chunk-3Q353S2R.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-RHNTHGNU.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-Q7TLC3I2.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-D4GF4FAB.mjs";import"./chunk-CVHNXJH3.mjs";import"./chunk-YA6ATMTB.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-M6K34KGF.mjs";import"./chunk-TNT27RBG.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-S42RBRH2.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-WUUKFE2U.mjs";import"./chunk-EAC5QCE3.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{d as NOT_REMADE_WORDS,b as OTHERS_DELETION_WORDS,c as OUT_OF_REACH_WORDS,j as REWIND_AUTOMATION_LIFTED_BY,a as REWIND_RESIDUAL_IDS,i as RewindStopped,k as automationUnread,m as counted,h as heldWhile,l as inRewindWords,g as muteOfSteps,e as notAskedWords,n as rewindOrg,f as rewindOrgOf};
@@ -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,c,d,e}from"./chunk-7BQMBXKX.mjs";import"./chunk-KWAVSZ2B.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as FieldMappingService,b as MOVES_ITS_SOURCE,e as mapFields,c as mappedTargets,d as notSentAsRead};
7
+ import{a,b,c,d,e}from"./chunk-WUUKFE2U.mjs";import"./chunk-EAC5QCE3.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as FieldMappingService,b as MOVES_ITS_SOURCE,e as mapFields,c as mappedTargets,d as notSentAsRead};
@@ -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 as R}from"./chunk-CE6ZDGBB.mjs";import{F as g,G as u,K as w,N as m,O as I,P as k}from"./chunk-2GSMHGIV.mjs";import{b as h}from"./chunk-CA5NAXSU.mjs";import{g as T}from"./chunk-ISOSTAJR.mjs";import{vc as y}from"./chunk-6QSHWIZI.mjs";var b="Opportunity",v=new Set(["Id","OpportunityId",u,"IsPrimary"]),O=200,l=s=>s.slice(0,15);function S(s){return`The contact roles the platform wrote with the run's opportunities were not looked up, so written as generated: an opportunity may hold the role of its contact twice. ${s}`}var P=class{constructor(e){this.deps=e}deps;sentWith=new Map;untold;linkedIds=[];said;unread;alike=0;opportunitiesWritten(e,d){let r=t=>{let n=t?.[u];return typeof n=="string"&&n!==""?n:void 0},o=d.rows&&(d.rows.length===e.length||d.stopped)?d.rows:void 0;if(!o){d.successIds.length>0&&e.some(t=>r(t))&&(this.untold??="The opportunities' insert did not say which record each id it answered is.");return}o.forEach((t,n)=>{let a=r(e[n]);if(!(!t.id||a===void 0)){if(t.unmatched){this.untold??="The opportunities' insert did not say which record each id it answered is.";return}this.sentWith.set(l(t.id),a)}})}async link(e){if(e.length>0&&this.untold!==void 0&&(this.unread??=this.untold),this.sentWith.size===0||e.length===0)return new Map;let d=e.map(i=>({OpportunityId:i.OpportunityId,[u]:i[u],IsPrimary:i.IsPrimary})),r=i=>this.sentWith.get(l(i)),o=this.deps.readTarget;if(!o)return W(d,r)&&(this.unread??="This run cannot read the target."),new Map;let t;try{t=await k(o,d,r,A(e))}catch(i){return this.unread??=h(i),new Map}let{found:n,alike:a}=t;this.alike+=a.length;for(let i of[...n.keys(),...a])this.sentWith.delete(l(String(e[i].OpportunityId)));return n.size>0&&await this.give(e,n),n}async give(e,d){let r=this.said??={records:0,given:0},o=[];for(let[n,a]of d){let i=String(a.Id);this.linkedIds.push(i),r.records++;let p=Object.entries(e[n]??{}).filter(([f,c])=>!v.has(f)&&c!==null&&c!==void 0&&String(a[f]??"")!==String(c));p.length>0&&o.push({Id:i,...Object.fromEntries(p)})}if(o.length===0)return;let t=n=>{r.refusal??=n};if(!this.deps.update)return t("This run cannot update the target.");for(let n=0;n<o.length;n+=O){if(this.deps.stopped())return t("The run was stopped before they were given them.");let a=o.slice(n,n+O),i;try{i=await this.deps.update(this.deps.orgId,g,a)}catch(p){t(h(p));continue}a.forEach((p,f)=>{let c=i[f];c?.success?r.given++:t(c?.error??"The org gave no answer for it.")})}}resultOf(e){return e!==g?{linkedIds:[],notes:[]}:{linkedIds:this.linkedIds,...this.said?{writtenByThePlatform:{...this.said}}:{},notes:[...this.unread!==void 0?[S(this.unread)]:[],...this.alike>0?[m(this.alike,"generated")]:[]]}}};function A(s){return[...new Set(s.flatMap(e=>Object.keys(e)))].filter(e=>!v.has(e))}function W(s,e){return s.some(d=>{let r=d.OpportunityId,o=d[u];if(typeof r!="string"||typeof o!="string")return!1;let t=e(r);return t!==void 0&&l(t)===l(o)})}function j(){let s=new Map,e=0;return{inserted(d,r,o){d===b&&r.forEach((t,n)=>{let a=t[u],i=o[n];i!==void 0&&typeof a=="string"&&a!==""&&s.set(i,a)})},readTarget:async d=>{let r=w(d);if(!r)throw new Error("A dry run reads nothing else of the target here.");let o=new Date().toISOString();return r.opportunities.flatMap(t=>{let n=s.get(t);return n===void 0?[]:[I({...Object.fromEntries(r.fields.map(a=>[a,null])),Id:`dry-role-${e++}`,OpportunityId:t,[u]:n,...r.fields.includes("IsPrimary")?{IsPrimary:!0}:{}},o)]})},update:async(d,r,o)=>o.map(()=>({success:!0}))}}function _(s){if(s)return`${s.records} record(s) linked to the contact role the platform wrote with their opportunity, for its contact, not written; ${s.given} given the fields the seed generated for ${s.given===1?"it":"them"}`+(s.refusal!==void 0?`, the others left as the platform wrote them (${s.refusal}).`:".")}function B(s){return{readTarget:e=>R(s,e),update:async(e,d,r)=>{let o=await s.sobject(d).update(r,{allOrNone:!1,headers:y()}),t=Array.isArray(o)?o:[o];return r.map((n,a)=>{let i=t[a];return i?.success===!0?{success:!0}:{success:!1,error:(i?.errors??[]).length>0?T(i?.errors):"The org gave no answer for it."}})}}}export{b as a,S as b,P as c,j as d,_ as e,B as f};
7
+ import{a as R}from"./chunk-CE6ZDGBB.mjs";import{F as g,G as u,K as w,N as m,O as I,P as k}from"./chunk-TNT27RBG.mjs";import{b as h}from"./chunk-CA5NAXSU.mjs";import{g as T}from"./chunk-S42RBRH2.mjs";import{vc as y}from"./chunk-PMWAFDUB.mjs";var b="Opportunity",v=new Set(["Id","OpportunityId",u,"IsPrimary"]),O=200,l=s=>s.slice(0,15);function S(s){return`The contact roles the platform wrote with the run's opportunities were not looked up, so written as generated: an opportunity may hold the role of its contact twice. ${s}`}var P=class{constructor(e){this.deps=e}deps;sentWith=new Map;untold;linkedIds=[];said;unread;alike=0;opportunitiesWritten(e,d){let r=t=>{let n=t?.[u];return typeof n=="string"&&n!==""?n:void 0},o=d.rows&&(d.rows.length===e.length||d.stopped)?d.rows:void 0;if(!o){d.successIds.length>0&&e.some(t=>r(t))&&(this.untold??="The opportunities' insert did not say which record each id it answered is.");return}o.forEach((t,n)=>{let a=r(e[n]);if(!(!t.id||a===void 0)){if(t.unmatched){this.untold??="The opportunities' insert did not say which record each id it answered is.";return}this.sentWith.set(l(t.id),a)}})}async link(e){if(e.length>0&&this.untold!==void 0&&(this.unread??=this.untold),this.sentWith.size===0||e.length===0)return new Map;let d=e.map(i=>({OpportunityId:i.OpportunityId,[u]:i[u],IsPrimary:i.IsPrimary})),r=i=>this.sentWith.get(l(i)),o=this.deps.readTarget;if(!o)return W(d,r)&&(this.unread??="This run cannot read the target."),new Map;let t;try{t=await k(o,d,r,A(e))}catch(i){return this.unread??=h(i),new Map}let{found:n,alike:a}=t;this.alike+=a.length;for(let i of[...n.keys(),...a])this.sentWith.delete(l(String(e[i].OpportunityId)));return n.size>0&&await this.give(e,n),n}async give(e,d){let r=this.said??={records:0,given:0},o=[];for(let[n,a]of d){let i=String(a.Id);this.linkedIds.push(i),r.records++;let p=Object.entries(e[n]??{}).filter(([f,c])=>!v.has(f)&&c!==null&&c!==void 0&&String(a[f]??"")!==String(c));p.length>0&&o.push({Id:i,...Object.fromEntries(p)})}if(o.length===0)return;let t=n=>{r.refusal??=n};if(!this.deps.update)return t("This run cannot update the target.");for(let n=0;n<o.length;n+=O){if(this.deps.stopped())return t("The run was stopped before they were given them.");let a=o.slice(n,n+O),i;try{i=await this.deps.update(this.deps.orgId,g,a)}catch(p){t(h(p));continue}a.forEach((p,f)=>{let c=i[f];c?.success?r.given++:t(c?.error??"The org gave no answer for it.")})}}resultOf(e){return e!==g?{linkedIds:[],notes:[]}:{linkedIds:this.linkedIds,...this.said?{writtenByThePlatform:{...this.said}}:{},notes:[...this.unread!==void 0?[S(this.unread)]:[],...this.alike>0?[m(this.alike,"generated")]:[]]}}};function A(s){return[...new Set(s.flatMap(e=>Object.keys(e)))].filter(e=>!v.has(e))}function W(s,e){return s.some(d=>{let r=d.OpportunityId,o=d[u];if(typeof r!="string"||typeof o!="string")return!1;let t=e(r);return t!==void 0&&l(t)===l(o)})}function j(){let s=new Map,e=0;return{inserted(d,r,o){d===b&&r.forEach((t,n)=>{let a=t[u],i=o[n];i!==void 0&&typeof a=="string"&&a!==""&&s.set(i,a)})},readTarget:async d=>{let r=w(d);if(!r)throw new Error("A dry run reads nothing else of the target here.");let o=new Date().toISOString();return r.opportunities.flatMap(t=>{let n=s.get(t);return n===void 0?[]:[I({...Object.fromEntries(r.fields.map(a=>[a,null])),Id:`dry-role-${e++}`,OpportunityId:t,[u]:n,...r.fields.includes("IsPrimary")?{IsPrimary:!0}:{}},o)]})},update:async(d,r,o)=>o.map(()=>({success:!0}))}}function _(s){if(s)return`${s.records} record(s) linked to the contact role the platform wrote with their opportunity, for its contact, not written; ${s.given} given the fields the seed generated for ${s.given===1?"it":"them"}`+(s.refusal!==void 0?`, the others left as the platform wrote them (${s.refusal}).`:".")}function B(s){return{readTarget:e=>R(s,e),update:async(e,d,r)=>{let o=await s.sobject(d).update(r,{allOrNone:!1,headers:y()}),t=Array.isArray(o)?o:[o];return r.map((n,a)=>{let i=t[a];return i?.success===!0?{success:!0}:{success:!1,error:(i?.errors??[]).length>0?T(i?.errors):"The org gave no answer for it."}})}}}export{b as a,S as b,P as c,j as d,_ as e,B as f};
@@ -4,7 +4,7 @@ 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{h as O}from"./chunk-X2XZQ434.mjs";import{A as R,B as _,e as X,k as S,r as P}from"./chunk-EOQON3E5.mjs";import{H as E,c as Y,p as A,q as z}from"./chunk-N2HYG3BL.mjs";import{g as w,h as y}from"./chunk-Z3MGN42K.mjs";import{Uc as u}from"./chunk-6QSHWIZI.mjs";import{b as D,e as W,f as Q,l as L}from"./chunk-WZQEK4WT.mjs";import{mkdir as se,rm as M}from"node:fs/promises";import{join as I}from"node:path";var ee=200,ne=X*10,B=2e3,te=["Id","ContentDocumentId","LinkedEntityId","ShareType","Visibility"],ae=["Id","LatestPublishedVersionId","ContentSize"],de="taking",h=D().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,"Not a record id"),T=D().regex(/^[A-Za-z]{1,40}$/,"Not a sharing value"),V=L({Id:h,ContentDocumentId:h,LinkedEntityId:h,ShareType:T,Visibility:T}),J=L({Id:h,LatestPublishedVersionId:h.nullable(),ContentSize:W().int().nonnegative().nullable(),anchored:Q()});function Re(e,n){return I(e,`${y}.${n}.ndjson`)}var Ce=V.extend({now:L({ShareType:T,Visibility:T})});function Fe(e,n){let t=new Set(n.map(r=>r.toLowerCase())),i=new Map;for(let r of e){let a=r.keyPrefix;t.has(r.name.toLowerCase())&&typeof a=="string"&&a.length===3&&i.set(a,r.name)}return i}function Te(e,n){let t=e.LinkedEntityId;return typeof t=="string"&&t.length>=15?n.get(t.slice(0,3)):void 0}function oe(e){return e.map(n=>{if(!h.safeParse(n).success)throw new Error(`Not a record id: ${n}`);return`'${n}'`}).join(", ")}function ce(e){let n=u(e);return{objectApiName:n,soql:`SELECT ${te.join(", ")} FROM ${y} WHERE LinkedEntityId IN (SELECT Id FROM ${n})`,scanAll:!1}}function be(e){let n=u(e);return{objectApiName:n,soql:`SELECT COUNT() FROM ${y} WHERE LinkedEntityId IN (SELECT Id FROM ${n})`,scanAll:!1}}function le(e,n){return{objectApiName:u(e),soql:`SELECT ${te.join(", ")} FROM ${y} WHERE LinkedEntityId IN (${oe(n)})`,scanAll:!1}}function fe(e){return{objectApiName:w,soql:`SELECT ${ae.join(", ")} FROM ${w} WHERE Id IN (${oe(e)})`,scanAll:!1}}async function*v(e,n){let t=[];for await(let i of e)t.push(i),t.length>=n&&(yield t,t=[]);t.length>0&&(yield t)}function*C(e,n){let t=[];for(let i of e)t.push(i),t.length>=n&&(yield t,t=[]);t.length>0&&(yield t)}function G(e,n,t){let i=e.safeParse(n);if(!i.success)throw new Error(`The org answered a ${t} that does not read as one: ${i.error.message}`);return i.data}function F(e){return e.slice(0,15)}async function xe(e){let{reader:n,folder:t,signal:i}=e,r=e.files??S(O(t.dir)),a=I(t.filesDir,de);await se(a,{recursive:!0,mode:Y});let m=z(t),b=A(t);await r.writeFile(m,""),await r.writeFile(b,"");try{let x=new Map,q=0,H=async d=>{for await(let c of v(_(d),B)){let s=c.map(o=>G(V,o,"link"));for(let o of s)x.has(F(o.ContentDocumentId))||x.set(F(o.ContentDocumentId),o.ContentDocumentId);q+=s.length,await r.appendFile(m,s.map(o=>`${JSON.stringify(o)}
7
+ import{h as O}from"./chunk-L53JWJ3S.mjs";import{A as R,B as _,e as X,k as S,r as P}from"./chunk-FP7CYB2F.mjs";import{H as E,c as Y,p as A,q as z}from"./chunk-KGU4SVIT.mjs";import{g as w,h as y}from"./chunk-M6K34KGF.mjs";import{Uc as u}from"./chunk-PMWAFDUB.mjs";import{b as D,e as W,f as Q,l as L}from"./chunk-WZQEK4WT.mjs";import{mkdir as se,rm as M}from"node:fs/promises";import{join as I}from"node:path";var ee=200,ne=X*10,B=2e3,te=["Id","ContentDocumentId","LinkedEntityId","ShareType","Visibility"],ae=["Id","LatestPublishedVersionId","ContentSize"],de="taking",h=D().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,"Not a record id"),T=D().regex(/^[A-Za-z]{1,40}$/,"Not a sharing value"),V=L({Id:h,ContentDocumentId:h,LinkedEntityId:h,ShareType:T,Visibility:T}),J=L({Id:h,LatestPublishedVersionId:h.nullable(),ContentSize:W().int().nonnegative().nullable(),anchored:Q()});function Re(e,n){return I(e,`${y}.${n}.ndjson`)}var Ce=V.extend({now:L({ShareType:T,Visibility:T})});function Fe(e,n){let t=new Set(n.map(r=>r.toLowerCase())),i=new Map;for(let r of e){let a=r.keyPrefix;t.has(r.name.toLowerCase())&&typeof a=="string"&&a.length===3&&i.set(a,r.name)}return i}function Te(e,n){let t=e.LinkedEntityId;return typeof t=="string"&&t.length>=15?n.get(t.slice(0,3)):void 0}function oe(e){return e.map(n=>{if(!h.safeParse(n).success)throw new Error(`Not a record id: ${n}`);return`'${n}'`}).join(", ")}function ce(e){let n=u(e);return{objectApiName:n,soql:`SELECT ${te.join(", ")} FROM ${y} WHERE LinkedEntityId IN (SELECT Id FROM ${n})`,scanAll:!1}}function be(e){let n=u(e);return{objectApiName:n,soql:`SELECT COUNT() FROM ${y} WHERE LinkedEntityId IN (SELECT Id FROM ${n})`,scanAll:!1}}function le(e,n){return{objectApiName:u(e),soql:`SELECT ${te.join(", ")} FROM ${y} WHERE LinkedEntityId IN (${oe(n)})`,scanAll:!1}}function fe(e){return{objectApiName:w,soql:`SELECT ${ae.join(", ")} FROM ${w} WHERE Id IN (${oe(e)})`,scanAll:!1}}async function*v(e,n){let t=[];for await(let i of e)t.push(i),t.length>=n&&(yield t,t=[]);t.length>0&&(yield t)}function*C(e,n){let t=[];for(let i of e)t.push(i),t.length>=n&&(yield t,t=[]);t.length>0&&(yield t)}function G(e,n,t){let i=e.safeParse(n);if(!i.success)throw new Error(`The org answered a ${t} that does not read as one: ${i.error.message}`);return i.data}function F(e){return e.slice(0,15)}async function xe(e){let{reader:n,folder:t,signal:i}=e,r=e.files??S(O(t.dir)),a=I(t.filesDir,de);await se(a,{recursive:!0,mode:Y});let m=z(t),b=A(t);await r.writeFile(m,""),await r.writeFile(b,"");try{let x=new Map,q=0,H=async d=>{for await(let c of v(_(d),B)){let s=c.map(o=>G(V,o,"link"));for(let o of s)x.has(F(o.ContentDocumentId))||x.set(F(o.ContentDocumentId),o.ContentDocumentId);q+=s.length,await r.appendFile(m,s.map(o=>`${JSON.stringify(o)}
8
8
  `).join(""))}await M(d,{force:!0})},K=e.linked.map(d=>({...ce(d),file:I(a,`${u(d)}.links.ndjson`)})),re=await R(n,K,i),$=[];for(let[d,c]of re.entries()){if(c.read){await H(K[d].file);continue}let s=e.linked[d];$.push(s);let o=await P.read(t,e.snapshotId,s),l=0;for(let g of C(C(pe(o),ee),ne)){let f=g.map(k=>({...le(s,k),file:I(a,`${u(s)}.links.${l++}.ndjson`)})),N=(await R(n,f,i)).find(k=>!k.read);if(N&&!N.read)throw new Error(`The links of the files of ${s} could not be read whole: ${c.reason}; read by the ids of its records, ${N.reason}`);for(let k of f)await H(k.file)}}let j=0,U=0,Z=new Set;for(let d of C(C(x.values(),ee),ne)){let c=d.map((l,g)=>({...fe(l),file:I(a,`documents.${g}.ndjson`)})),o=(await R(n,c,i)).find(l=>!l.read);if(o&&!o.read)throw new Error(`The files the links name could not be read by their ids: ${o.reason}`);for(let l of c){for await(let g of v(_(l.file),B)){let f=g.map(p=>({...G(J.omit({anchored:!0}),p,"file"),anchored:!0}));for(let p of f)Z.add(F(p.Id));j+=f.length,U+=f.length,await r.appendFile(b,f.map(p=>`${JSON.stringify(p)}
9
9
  `).join(""))}await M(l.file,{force:!0})}}if(e.documentsInSnapshot){let d=await P.read(t,e.snapshotId,w);for await(let c of v(d.records(),B)){let s=c.filter(o=>typeof o.Id=="string"&&!Z.has(F(o.Id))).map(o=>({...G(J.omit({anchored:!0}),ue(o),"file"),anchored:!1}));j+=s.length,s.length>0&&await r.appendFile(b,s.map(o=>`${JSON.stringify(o)}
10
10
  `).join(""))}}return{documents:j,links:q,anchored:U,...$.length>0?{readByIds:$}:{}}}finally{await M(a,{recursive:!0,force:!0})}}function*pe(e){for(let n=0;n<e.size;n++)yield e.idAt(n)}function ue(e){return{Id:e.Id,LatestPublishedVersionId:e.LatestPublishedVersionId??null,ContentSize:e.ContentSize??null}}async function*ie(e,n,t,i){if(!await e.exists(n))throw new E("damaged",`The checkpoint\u2019s ${i} are not there`);for await(let r of e.readLines(n)){if(r==="")continue;let a;try{a=JSON.parse(r)}catch{throw new E("damaged",`The checkpoint\u2019s ${i} hold a line that is not JSON`)}let m=t.safeParse(a);if(!m.success)throw new E("damaged",`The checkpoint\u2019s ${i} hold a line that does not parse`);yield m.data}}function $e(e,n=S(O(e.dir))){return ie(n,z(e),V,"file links")}function je(e,n=S(O(e.dir))){return ie(n,A(e),J,"files")}export{ee as a,te as b,V as c,Re as d,Ce as e,Fe as f,Te as g,ce as h,be as i,le as j,xe as k,$e as l,je as m};
@@ -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{e as $}from"./chunk-DSR2MSBH.mjs";import{m as F,o as A}from"./chunk-VXZ5PTOM.mjs";import{c as M}from"./chunk-HF6LAK3G.mjs";var k=class{avgSecondsPerApiCall;batchStrategy;constructor(u){this.avgSecondsPerApiCall=u?.avgSecondsPerApiCall??.5,this.batchStrategy=new M}generate(u){let a=u.nodes.filter(o=>o.included);if(a.length===0)return{waves:[],totalRecords:0,totalApiCalls:0,estimatedDurationSeconds:0,cycleResolutions:[]};let{edges:c,components:t}=G(u),i=this.computeTopoLevels(c,t),l=new Map;for(let o of a){let e=i.get(o.objectApiName)??o.level,h=l.get(e);h?h.push(o.objectApiName):l.set(e,[o.objectApiName])}let n=[...l.keys()].sort((o,e)=>o-e),s=new Map(a.map(o=>[o.objectApiName,o])),g=n.map((o,e)=>{let h=l.get(o)??[],v=0,b=0,w=0;for(let N of h){let j=s.get(N);if(!j)continue;v+=j.recordCount;let x=this.batchStrategy.resolve(j.batchStrategy,j.recordCount),C=$(x,j.recordCount).batchCount;b+=C;let O=C*this.avgSecondsPerApiCall;O>w&&(w=O)}return{order:e,objectApiNames:h,totalRecords:v,estimatedDurationSeconds:w,estimatedApiCalls:b}}),r=this.detectCycles(u,c,t),p=g.reduce((o,e)=>o+e.totalRecords,0),f=g.reduce((o,e)=>o+e.estimatedApiCalls,0),m=g.reduce((o,e)=>o+e.estimatedDurationSeconds,0);return{waves:g,totalRecords:p,totalApiCalls:f,estimatedDurationSeconds:m,cycleResolutions:r}}computeTopoLevels(u,a){let c=new Map;a.forEach((n,s)=>{for(let g of n)c.set(g,s)});let t=new Map;for(let n of u){let s=c.get(n.sourceObject),g=c.get(n.targetObject);if(s===void 0||g===void 0||s===g)continue;let r=t.get(s);r?r.push(g):t.set(s,[g])}let i=a.map(()=>0);for(let n=a.length-1;n>=0;n--)for(let s of t.get(n)??[])i[s]=Math.max(i[s],i[n]+1);let l=new Map;for(let[n,s]of c)l.set(n,i[s]);return l}detectCycles(u,a,c){let t=c.filter(n=>n.length>1);if(t.length===0)return[];let i=new Map(A(u).map((n,s)=>[n.objectApiName,s])),l=n=>i.get(n)??0;return t.map(n=>{let s=new Set(n),g=[...n].sort((e,h)=>l(e)-l(h)),r=a.filter(e=>s.has(e.sourceObject)&&s.has(e.targetObject)&&l(e.targetObject)<l(e.sourceObject)),p=r.filter(e=>e.required===!0);if(p.length>0){let e=[...new Set(p.map(b=>b.targetObject))],h=[...new Set(p.map(b=>b.sourceObject))],v=e.length===1;return{objects:g,strategy:"unbreakable",description:`The run cannot break this cycle: ${y(p.map(S))} may not be left empty, and no order writes ${y(h)} first. ${y(e)} ${v?"is":"are"} refused, and what cannot be written without ${v?"it":"them"} is skipped.`}}let f=r.filter(e=>e.insertOnly!==!0),m=r.filter(e=>e.insertOnly===!0),o=[...f.length>0?[`${y(f.map(S))} left empty at insert and filled in by the second pass`]:[],...m.length>0?[`${y(m.map(S))} left empty for good: only an insert sets ${m.length===1?"it":"them"}, and no order writes ${y([...new Set(m.map(e=>e.sourceObject))])} first`]:[]];return{objects:g,strategy:"nullable_lookup",description:`Written in this order, with ${o.join(", and ")}.`}})}};function G(d){let u=d.nodes.filter(t=>t.included).map(t=>t.objectApiName),a=new Set(u),c=d.edges.filter(t=>t.sourceObject!==t.targetObject&&a.has(t.sourceObject)&&a.has(t.targetObject)&&F(t));return{edges:c,components:R(u,c)}}function R(d,u){let a=new Map;for(let r of d)a.set(r,[]);for(let r of u)a.get(r.sourceObject)?.push(r.targetObject);let c=0,t=new Map,i=new Map,l=new Set,n=[],s=[],g=r=>{let p=[];for(t.set(r,c),i.set(r,c),c++,n.push(r),l.add(r),p.push({v:r,neighbors:a.get(r)??[],i:0});p.length>0;){let f=p[p.length-1];if(f.i<f.neighbors.length){let e=f.neighbors[f.i++];t.has(e)?l.has(e)&&i.set(f.v,Math.min(i.get(f.v),t.get(e))):(t.set(e,c),i.set(e,c),c++,n.push(e),l.add(e),p.push({v:e,neighbors:a.get(e)??[],i:0}));continue}let m=f.v;p.pop();let o=p[p.length-1];if(o&&i.set(o.v,Math.min(i.get(o.v),i.get(m))),i.get(m)===t.get(m)){let e=[],h;do h=n.pop(),l.delete(h),e.push(h);while(h!==m);s.push(e)}}};for(let r of d)t.has(r)||g(r);return s}function S(d){return`${d.targetObject}'s lookup to ${d.sourceObject}`}function y(d){return d.length<=1?d.join(""):`${d.slice(0,-1).join(", ")} and ${d[d.length-1]}`}export{k as a,R as b};
7
+ import{e as $}from"./chunk-YHR4WQPR.mjs";import{m as F,o as A}from"./chunk-RHNTHGNU.mjs";import{c as M}from"./chunk-HF6LAK3G.mjs";var k=class{avgSecondsPerApiCall;batchStrategy;constructor(u){this.avgSecondsPerApiCall=u?.avgSecondsPerApiCall??.5,this.batchStrategy=new M}generate(u){let a=u.nodes.filter(o=>o.included);if(a.length===0)return{waves:[],totalRecords:0,totalApiCalls:0,estimatedDurationSeconds:0,cycleResolutions:[]};let{edges:c,components:t}=G(u),i=this.computeTopoLevels(c,t),l=new Map;for(let o of a){let e=i.get(o.objectApiName)??o.level,h=l.get(e);h?h.push(o.objectApiName):l.set(e,[o.objectApiName])}let n=[...l.keys()].sort((o,e)=>o-e),s=new Map(a.map(o=>[o.objectApiName,o])),g=n.map((o,e)=>{let h=l.get(o)??[],v=0,b=0,w=0;for(let N of h){let j=s.get(N);if(!j)continue;v+=j.recordCount;let x=this.batchStrategy.resolve(j.batchStrategy,j.recordCount),C=$(x,j.recordCount).batchCount;b+=C;let O=C*this.avgSecondsPerApiCall;O>w&&(w=O)}return{order:e,objectApiNames:h,totalRecords:v,estimatedDurationSeconds:w,estimatedApiCalls:b}}),r=this.detectCycles(u,c,t),p=g.reduce((o,e)=>o+e.totalRecords,0),f=g.reduce((o,e)=>o+e.estimatedApiCalls,0),m=g.reduce((o,e)=>o+e.estimatedDurationSeconds,0);return{waves:g,totalRecords:p,totalApiCalls:f,estimatedDurationSeconds:m,cycleResolutions:r}}computeTopoLevels(u,a){let c=new Map;a.forEach((n,s)=>{for(let g of n)c.set(g,s)});let t=new Map;for(let n of u){let s=c.get(n.sourceObject),g=c.get(n.targetObject);if(s===void 0||g===void 0||s===g)continue;let r=t.get(s);r?r.push(g):t.set(s,[g])}let i=a.map(()=>0);for(let n=a.length-1;n>=0;n--)for(let s of t.get(n)??[])i[s]=Math.max(i[s],i[n]+1);let l=new Map;for(let[n,s]of c)l.set(n,i[s]);return l}detectCycles(u,a,c){let t=c.filter(n=>n.length>1);if(t.length===0)return[];let i=new Map(A(u).map((n,s)=>[n.objectApiName,s])),l=n=>i.get(n)??0;return t.map(n=>{let s=new Set(n),g=[...n].sort((e,h)=>l(e)-l(h)),r=a.filter(e=>s.has(e.sourceObject)&&s.has(e.targetObject)&&l(e.targetObject)<l(e.sourceObject)),p=r.filter(e=>e.required===!0);if(p.length>0){let e=[...new Set(p.map(b=>b.targetObject))],h=[...new Set(p.map(b=>b.sourceObject))],v=e.length===1;return{objects:g,strategy:"unbreakable",description:`The run cannot break this cycle: ${y(p.map(S))} may not be left empty, and no order writes ${y(h)} first. ${y(e)} ${v?"is":"are"} refused, and what cannot be written without ${v?"it":"them"} is skipped.`}}let f=r.filter(e=>e.insertOnly!==!0),m=r.filter(e=>e.insertOnly===!0),o=[...f.length>0?[`${y(f.map(S))} left empty at insert and filled in by the second pass`]:[],...m.length>0?[`${y(m.map(S))} left empty for good: only an insert sets ${m.length===1?"it":"them"}, and no order writes ${y([...new Set(m.map(e=>e.sourceObject))])} first`]:[]];return{objects:g,strategy:"nullable_lookup",description:`Written in this order, with ${o.join(", and ")}.`}})}};function G(d){let u=d.nodes.filter(t=>t.included).map(t=>t.objectApiName),a=new Set(u),c=d.edges.filter(t=>t.sourceObject!==t.targetObject&&a.has(t.sourceObject)&&a.has(t.targetObject)&&F(t));return{edges:c,components:R(u,c)}}function R(d,u){let a=new Map;for(let r of d)a.set(r,[]);for(let r of u)a.get(r.sourceObject)?.push(r.targetObject);let c=0,t=new Map,i=new Map,l=new Set,n=[],s=[],g=r=>{let p=[];for(t.set(r,c),i.set(r,c),c++,n.push(r),l.add(r),p.push({v:r,neighbors:a.get(r)??[],i:0});p.length>0;){let f=p[p.length-1];if(f.i<f.neighbors.length){let e=f.neighbors[f.i++];t.has(e)?l.has(e)&&i.set(f.v,Math.min(i.get(f.v),t.get(e))):(t.set(e,c),i.set(e,c),c++,n.push(e),l.add(e),p.push({v:e,neighbors:a.get(e)??[],i:0}));continue}let m=f.v;p.pop();let o=p[p.length-1];if(o&&i.set(o.v,Math.min(i.get(o.v),i.get(m))),i.get(m)===t.get(m)){let e=[],h;do h=n.pop(),l.delete(h),e.push(h);while(h!==m);s.push(e)}}};for(let r of d)t.has(r)||g(r);return s}function S(d){return`${d.targetObject}'s lookup to ${d.sourceObject}`}function y(d){return d.length<=1?d.join(""):`${d.slice(0,-1).join(", ")} and ${d[d.length-1]}`}export{k as a,R as b};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{b as u}from"./chunk-CA5NAXSU.mjs";var s=["INVALID_SESSION_ID","INVALID_AUTH_HEADER","SESSION_EXPIRED"];function a(n){if(typeof n=="object"&&n!==null){let{errorCode:t,statusCode:r}=n;if(typeof t=="string"&&s.includes(t)||r===401)return!0}let e=u(n);return s.some(t=>e.includes(t))||e.includes("Session expired")?!0:/\b401\b/.test(e)&&/unauthorized/i.test(e)}var i=["ENOTFOUND","ECONNREFUSED","ETIMEDOUT","ECONNRESET","EAI_AGAIN","ENETUNREACH","EHOSTUNREACH"];function d(n){if(typeof n=="object"&&n!==null){let{code:t,name:r,cause:o}=n;if(typeof t=="string"&&i.includes(t)||r==="TimeoutError"||o!==void 0&&d(o))return!0}let e=u(n);return i.some(t=>e.includes(t))||e.includes("fetch failed")?!0:/\btimed out\b/i.test(e)}function c(n){let{code:e}=typeof n=="object"&&n!==null?n:{};if(typeof e=="string"&&i.includes(e))return e;let t=u(n),r=i.find(o=>t.includes(o));if(r!==void 0)return r;if(/socket hang up/i.test(t))return"socket hang up";if(d(n))return/\btimed out\b/i.test(t)?"timed out":"no connection"}function g(n){return typeof n.unread=="string"?c(n.unread):n.unread.find(e=>e.unreachable!==void 0)?.unreachable}export{a,d as b,c,g as d};
@@ -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 as N}from"./chunk-EOQON3E5.mjs";import{a as j,h as D}from"./chunk-TZE3Y7IQ.mjs";import{b as J}from"./chunk-CA5NAXSU.mjs";function se(e){return`sync-before-${e.replace(/[^A-Za-z0-9-]+/g,"-")}`.slice(0,200)}var oe=1e3;function he(e){let o=se(e.runId),d=new Map,a=e.everyMs??oe,g=()=>(e.now?.()??new Date).getTime(),S,I=Number.NEGATIVE_INFINITY,k,E=!1,R=h=>{if(S===void 0)return;let t=[...d].map(([l,c])=>({objectApiName:l,recordCount:c,truncated:!1}));e.meta.set(`backup:${o}`,{operationId:o,orgId:e.orgId,...e.organizationId!==void 0?{organizationId:e.organizationId}:{},objects:t,partial:h,timestamp:S,totalRecords:t.reduce((l,c)=>l+c.recordCount,0),origin:"sync",runId:e.runId},"backups")},z=()=>{if(E)return;let h=I+a-g();if(h<=0){k!==void 0&&clearTimeout(k),k=void 0,I=g(),R(!0);return}k??=setTimeout(()=>{if(k=void 0,!E){I=g();try{R(!0)}catch{}}},h),k.unref?.()};return{id:o,keep:async(h,t)=>{t.length!==0&&(d.has(h)||(S??=(e.now?.()??new Date).toISOString(),d.set(h,0),R(!0),await e.files.begin(o,h)),await e.files.append(o,h,t),d.set(h,(d.get(h)??0)+t.length),z())},close:()=>{E=!0,k!==void 0&&clearTimeout(k),k=void 0,R(!1)}}}var F=200,de=["LastModifiedDate","LastModifiedById"],ee=100,te=4e3,ae=20,ne=255;function ce(e=ne){return 2*Math.max(0,e)+2}function ke(e,o){let d=o===void 0||o.creatable.size+4>ee;if(e.toLowerCase()==="id")return{characters:ae,wide:d};let a=o?.fields?.find(g=>g.name.toLowerCase()===e.toLowerCase());return a&&["double","int","long","currency","percent"].includes(a.type??"")?{characters:(a.precision??a.digits??18)+2,wide:d}:{characters:ce(a?.length??ne),wide:d}}function fe(e){let o=e.wide?F/4:F,d=Math.floor((te+2)/(Math.max(1,e.characters)+2));return Math.max(1,Math.min(o,d))}function me(e,o){let d=fe(o),a=e.reduce((g,S)=>g+Math.ceil(Math.max(0,S)/d),0);return a>0?a+1:0}function u(e){return e.slice(0,15)}function U(e,o){if(typeof e=="number"&&Number.isFinite(e))return`#${e}`;if(!(typeof e!="string"||e===""))return o?u(e):e.toLowerCase()}function ue(e){return typeof e=="number"?String(e):`'${j(String(e))}'`}function ge(e,o){let d=[],a=[],g=0;for(let S of e){let I=ue(S);a.length>0&&(a.length>=o||g+I.length>te)&&(d.push(a),a=[],g=0),a.push(I),g+=I.length+2}return a.length>0&&d.push(a),d}function le(e,o,d){return`What these ${o} ${e} record(s) would write over in the target could not be read and kept first (${J(d)}), so none of them was written: a run writes over nothing it cannot put back.`}function Se(e){let o=new Map,d=new Map,a=new Set,g=new Map,S=new Map,I=new Map,k=new Map,E=new Map,R=new Map,z=t=>{let l=e.describe,c=e.viewsEncrypted;if(!l||!c)return Promise.resolve(new Set);let y=I.get(t);return y||(y=l(t).then(async f=>{let m=(f.fields??[]).filter(M=>M.type===N).map(M=>M.name);return m.length>0&&!await c()?new Set(m):new Set},()=>new Set),I.set(t,y)),y},h=t=>{let l=e.describe;if(!l)return Promise.resolve(new Set);let c=S.get(t);return c||(c=l(t).then(y=>new Set((y.fields??[]).filter(f=>f.type==="base64"||f.queryable===!1).map(f=>f.name)),()=>new Set),S.set(t,c)),c};return{before:async(t,l,c,y)=>{if(g.delete(t),l!=="update"&&l!=="upsert"||c.length===0)return;let f=l==="update"?"Id":y??"Id",m=f==="Id";try{D(t),D(f);let M=await h(t),p=await z(t),v=new Set,O=new Set,T=new Map;for(let n of c){let i=U(n[f],m);i!==void 0&&!T.has(i)&&T.set(i,n[f]);for(let[r,s]of Object.entries(n))if(!(r==="Id"||r===f||r==="attributes")&&!M.has(r)&&!(typeof s=="object"&&s!==null)){if(p.has(r)){O.add(r);continue}v.add(D(r))}}if(T.size===0||v.size===0&&O.size===0)return;let x=["Id",...m?[]:[f],...v],V=[...x,...de.filter(n=>!x.includes(n))],re=V.length>ee?F/4:F,$=new Map,P=R.get(t)===!1?x:V;for(let n of ge([...T.values()],re)){let i=s=>`SELECT ${s.join(", ")} FROM ${t} WHERE ${f} IN (${n.join(", ")})`,r;try{r=await e.query(i(P))}catch(s){if(P===x)throw s;P=x,R.set(t,!1),r=await e.query(i(P))}for(let s of r){let w=U(m?s.Id:s[f],m);w===void 0||typeof s.Id!="string"||$.set(w,[...$.get(w)??[],s])}}let K=o.get(t)??new Map,_=[],B=new Map,C=new Map,G=new Map;for(let n of c){let i=U(n[f],m),r=i===void 0?void 0:$.get(i),s=r?.length===1?r[0]:void 0,w=s?.Id;if(_.push(w),!s||w===void 0||a.has(u(w)))continue;typeof s.LastModifiedDate=="string"&&G.set(u(w),{id:w,at:s.LastModifiedDate,...typeof s.LastModifiedById=="string"?{by:s.LastModifiedById}:{}});let ie=K.get(u(w)),q=B.get(u(w))??{Id:w},Q=C.get(u(w))??new Set;for(let b of Object.keys(n))!v.has(b)||ie?.has(b)||b in q||(q[b]=s[b]??null,Q.add(b));Q.size!==0&&(B.set(u(w),q),C.set(u(w),Q))}if(O.size>0&&_.some(n=>n!==void 0&&!a.has(u(n)))){let n=k.get(t)??new Set,i=[...O].filter(r=>!n.has(r));if(i.length>0){for(let r of i)n.add(r);k.set(t,n),e.recorder.unkept?.(t,i)}}if(B.size===0){g.set(t,{reaches:_,named:[],added:new Map});return}let X=[...B.values()],L=d.get(t)??new Map,Y=X.flatMap(n=>{let i=L.get(u(n.Id)),r=Object.entries(n).filter(([s])=>s==="Id"||!i?.has(s));return r.length>1?[Object.fromEntries(r)]:[]});Y.length>0&&await e.backup.keep(t,Y);for(let n of Y){let i=L.get(u(n.Id))??new Set;for(let r of Object.keys(n))r!=="Id"&&i.add(r);L.set(u(n.Id),i)}d.set(t,L);let A=X.map(n=>n.Id),W=E.get(t)??new Set,H=[];for(let n of A){let i=u(n);if(W.has(i))continue;W.add(i);let r=G.get(i);r&&H.push(r)}E.set(t,W),H.length>0?e.recorder.overwriting?.(t,e.backup.id,A,H):e.recorder.overwriting?.(t,e.backup.id,A);let Z=await e.recorder.flush();if(Z!==void 0)throw new Error(`the run's file could not be written: ${Z}`);for(let[n,i]of C){let r=K.get(n)??new Set;for(let s of i)r.add(s);K.set(n,r)}o.set(t,K),g.set(t,{reaches:_,named:A,added:C});return}catch(M){return le(t,c.length,M)}},answered:(t,l,c)=>{if(l==="insert"||l==="upsert")for(let p of c)p.success&&typeof p.id=="string"&&p.id!==""&&(l==="insert"||p.created===!0)&&a.add(u(p.id));let y=g.get(t);if(g.delete(t),!y||y.named.length===0)return;let f=new Set;c.forEach((p,v)=>{let O=y.reaches[v];O!==void 0&&p.success&&p.created!==!0&&f.add(u(O))});let m=y.named.filter(p=>!f.has(u(p))),M=o.get(t);for(let p of m){let v=M?.get(u(p));for(let O of y.added.get(u(p))??[])v?.delete(O)}e.recorder.overwrote?.(t,m)}}}export{se as a,he as b,ae as c,ce as d,ke as e,me as f,Se as g};
7
+ import{a as N}from"./chunk-FP7CYB2F.mjs";import{a as j,h as D}from"./chunk-TZE3Y7IQ.mjs";import{b as J}from"./chunk-CA5NAXSU.mjs";function se(e){return`sync-before-${e.replace(/[^A-Za-z0-9-]+/g,"-")}`.slice(0,200)}var oe=1e3;function he(e){let o=se(e.runId),d=new Map,a=e.everyMs??oe,g=()=>(e.now?.()??new Date).getTime(),S,I=Number.NEGATIVE_INFINITY,k,E=!1,R=h=>{if(S===void 0)return;let t=[...d].map(([l,c])=>({objectApiName:l,recordCount:c,truncated:!1}));e.meta.set(`backup:${o}`,{operationId:o,orgId:e.orgId,...e.organizationId!==void 0?{organizationId:e.organizationId}:{},objects:t,partial:h,timestamp:S,totalRecords:t.reduce((l,c)=>l+c.recordCount,0),origin:"sync",runId:e.runId},"backups")},z=()=>{if(E)return;let h=I+a-g();if(h<=0){k!==void 0&&clearTimeout(k),k=void 0,I=g(),R(!0);return}k??=setTimeout(()=>{if(k=void 0,!E){I=g();try{R(!0)}catch{}}},h),k.unref?.()};return{id:o,keep:async(h,t)=>{t.length!==0&&(d.has(h)||(S??=(e.now?.()??new Date).toISOString(),d.set(h,0),R(!0),await e.files.begin(o,h)),await e.files.append(o,h,t),d.set(h,(d.get(h)??0)+t.length),z())},close:()=>{E=!0,k!==void 0&&clearTimeout(k),k=void 0,R(!1)}}}var F=200,de=["LastModifiedDate","LastModifiedById"],ee=100,te=4e3,ae=20,ne=255;function ce(e=ne){return 2*Math.max(0,e)+2}function ke(e,o){let d=o===void 0||o.creatable.size+4>ee;if(e.toLowerCase()==="id")return{characters:ae,wide:d};let a=o?.fields?.find(g=>g.name.toLowerCase()===e.toLowerCase());return a&&["double","int","long","currency","percent"].includes(a.type??"")?{characters:(a.precision??a.digits??18)+2,wide:d}:{characters:ce(a?.length??ne),wide:d}}function fe(e){let o=e.wide?F/4:F,d=Math.floor((te+2)/(Math.max(1,e.characters)+2));return Math.max(1,Math.min(o,d))}function me(e,o){let d=fe(o),a=e.reduce((g,S)=>g+Math.ceil(Math.max(0,S)/d),0);return a>0?a+1:0}function u(e){return e.slice(0,15)}function U(e,o){if(typeof e=="number"&&Number.isFinite(e))return`#${e}`;if(!(typeof e!="string"||e===""))return o?u(e):e.toLowerCase()}function ue(e){return typeof e=="number"?String(e):`'${j(String(e))}'`}function ge(e,o){let d=[],a=[],g=0;for(let S of e){let I=ue(S);a.length>0&&(a.length>=o||g+I.length>te)&&(d.push(a),a=[],g=0),a.push(I),g+=I.length+2}return a.length>0&&d.push(a),d}function le(e,o,d){return`What these ${o} ${e} record(s) would write over in the target could not be read and kept first (${J(d)}), so none of them was written: a run writes over nothing it cannot put back.`}function Se(e){let o=new Map,d=new Map,a=new Set,g=new Map,S=new Map,I=new Map,k=new Map,E=new Map,R=new Map,z=t=>{let l=e.describe,c=e.viewsEncrypted;if(!l||!c)return Promise.resolve(new Set);let y=I.get(t);return y||(y=l(t).then(async f=>{let m=(f.fields??[]).filter(M=>M.type===N).map(M=>M.name);return m.length>0&&!await c()?new Set(m):new Set},()=>new Set),I.set(t,y)),y},h=t=>{let l=e.describe;if(!l)return Promise.resolve(new Set);let c=S.get(t);return c||(c=l(t).then(y=>new Set((y.fields??[]).filter(f=>f.type==="base64"||f.queryable===!1).map(f=>f.name)),()=>new Set),S.set(t,c)),c};return{before:async(t,l,c,y)=>{if(g.delete(t),l!=="update"&&l!=="upsert"||c.length===0)return;let f=l==="update"?"Id":y??"Id",m=f==="Id";try{D(t),D(f);let M=await h(t),p=await z(t),v=new Set,O=new Set,T=new Map;for(let n of c){let i=U(n[f],m);i!==void 0&&!T.has(i)&&T.set(i,n[f]);for(let[r,s]of Object.entries(n))if(!(r==="Id"||r===f||r==="attributes")&&!M.has(r)&&!(typeof s=="object"&&s!==null)){if(p.has(r)){O.add(r);continue}v.add(D(r))}}if(T.size===0||v.size===0&&O.size===0)return;let x=["Id",...m?[]:[f],...v],V=[...x,...de.filter(n=>!x.includes(n))],re=V.length>ee?F/4:F,$=new Map,P=R.get(t)===!1?x:V;for(let n of ge([...T.values()],re)){let i=s=>`SELECT ${s.join(", ")} FROM ${t} WHERE ${f} IN (${n.join(", ")})`,r;try{r=await e.query(i(P))}catch(s){if(P===x)throw s;P=x,R.set(t,!1),r=await e.query(i(P))}for(let s of r){let w=U(m?s.Id:s[f],m);w===void 0||typeof s.Id!="string"||$.set(w,[...$.get(w)??[],s])}}let K=o.get(t)??new Map,_=[],B=new Map,C=new Map,G=new Map;for(let n of c){let i=U(n[f],m),r=i===void 0?void 0:$.get(i),s=r?.length===1?r[0]:void 0,w=s?.Id;if(_.push(w),!s||w===void 0||a.has(u(w)))continue;typeof s.LastModifiedDate=="string"&&G.set(u(w),{id:w,at:s.LastModifiedDate,...typeof s.LastModifiedById=="string"?{by:s.LastModifiedById}:{}});let ie=K.get(u(w)),q=B.get(u(w))??{Id:w},Q=C.get(u(w))??new Set;for(let b of Object.keys(n))!v.has(b)||ie?.has(b)||b in q||(q[b]=s[b]??null,Q.add(b));Q.size!==0&&(B.set(u(w),q),C.set(u(w),Q))}if(O.size>0&&_.some(n=>n!==void 0&&!a.has(u(n)))){let n=k.get(t)??new Set,i=[...O].filter(r=>!n.has(r));if(i.length>0){for(let r of i)n.add(r);k.set(t,n),e.recorder.unkept?.(t,i)}}if(B.size===0){g.set(t,{reaches:_,named:[],added:new Map});return}let X=[...B.values()],L=d.get(t)??new Map,Y=X.flatMap(n=>{let i=L.get(u(n.Id)),r=Object.entries(n).filter(([s])=>s==="Id"||!i?.has(s));return r.length>1?[Object.fromEntries(r)]:[]});Y.length>0&&await e.backup.keep(t,Y);for(let n of Y){let i=L.get(u(n.Id))??new Set;for(let r of Object.keys(n))r!=="Id"&&i.add(r);L.set(u(n.Id),i)}d.set(t,L);let A=X.map(n=>n.Id),W=E.get(t)??new Set,H=[];for(let n of A){let i=u(n);if(W.has(i))continue;W.add(i);let r=G.get(i);r&&H.push(r)}E.set(t,W),H.length>0?e.recorder.overwriting?.(t,e.backup.id,A,H):e.recorder.overwriting?.(t,e.backup.id,A);let Z=await e.recorder.flush();if(Z!==void 0)throw new Error(`the run's file could not be written: ${Z}`);for(let[n,i]of C){let r=K.get(n)??new Set;for(let s of i)r.add(s);K.set(n,r)}o.set(t,K),g.set(t,{reaches:_,named:A,added:C});return}catch(M){return le(t,c.length,M)}},answered:(t,l,c)=>{if(l==="insert"||l==="upsert")for(let p of c)p.success&&typeof p.id=="string"&&p.id!==""&&(l==="insert"||p.created===!0)&&a.add(u(p.id));let y=g.get(t);if(g.delete(t),!y||y.named.length===0)return;let f=new Set;c.forEach((p,v)=>{let O=y.reaches[v];O!==void 0&&p.success&&p.created!==!0&&f.add(u(O))});let m=y.named.filter(p=>!f.has(u(p))),M=o.get(t);for(let p of m){let v=M?.get(u(p));for(let O of y.added.get(u(p))??[])v?.delete(O)}e.recorder.overwrote?.(t,m)}}}export{se as a,he as b,ae as c,ce as d,ke as e,me as f,Se as g};
@@ -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 as y,b as g}from"./chunk-OTJH6AEA.mjs";import{a as S,b as f,c as p}from"./chunk-AHUGG3WU.mjs";import{b as u}from"./chunk-CA5NAXSU.mjs";import{Ha as d}from"./chunk-6QSHWIZI.mjs";var h="SELECT ApiName, MasterLabel, IsClosed, IsDefault, SortOrder FROM CaseStatus ORDER BY SortOrder",w="SELECT MasterLabel, IsClosed, IsDefault, SortOrder FROM CaseStatus ORDER BY SortOrder",A="Closed";async function k(a){let e;try{e=await a(h)}catch{try{e=await a(w)}catch(t){return m(`the org would not read its case statuses: ${u(t)}`)}}let r=e.flatMap(t=>{let n=b(t.ApiName)??b(t.MasterLabel);return n===void 0?[]:[{value:n,closed:t.IsClosed===!0,isDefault:t.IsDefault===!0}]}),o=r.filter(t=>!t.closed),i=r.filter(t=>t.closed);return o.length===0||i.length===0?m(o.length===0?"the org has no case status that leaves a case open":"the org has no case status that closes a case"):{open:(o.find(t=>t.isDefault)??o[0]).value,closed:(i.find(t=>t.value===A)??i[0]).value,from:"org"}}function m(a){return{...d.caseStatus,from:"default",reason:a}}function b(a){return typeof a=="string"&&a.trim()!==""?a:void 0}var c=S;async function E(a,e){let r;try{r=await a(c)}catch{r={access:"createable"}}if(r.access==="absent")return{available:!1,reason:r.reason??`the org has no ${c}`};if(r.access==="readOnly")return{available:!1,reason:r.reason??`the user this seed runs as may read ${c} and not create it`};try{return{available:!0,bodyFields:f(await e(c))}}catch{return{available:!0,bodyFields:[]}}}var P=["Status","Origin","Priority","Type"];async function T(a){let e;try{e=(await a("Case")).fields}catch{return}let r={};for(let o of P){let t=(e.find(n=>n.name===o)?.picklistValues??[]).filter(n=>n.active!==!1).map(n=>n.value);t.length>0&&(r[o]=t)}return r}function v(a,e){let r=e.knowledge.available?e.knowledge.bodyFields:[],o=r.map(s=>s.name),i=e.articleBodyField===void 0?r[0]:r.find(s=>s.name===e.articleBodyField);if(e.articleBodyField!==void 0&&i===void 0)return{issues:[`options.articleBodyField: ${e.articleBodyField} is not a field of ${c} this org lets a body be written to`+(o.length>0?` (${o.join(", ")})`:"")]};let t=e.knowledge.available?{available:!0,bodyFields:o}:e.knowledge,n={seed:e.seed??d.seed,caseStatus:{open:e.caseStatus.open,closed:e.caseStatus.closed},...i!==void 0?p(i):{}},l;try{l=g(a,n)}catch(s){if(s instanceof y)return{issues:s.issues};throw s}return{preparation:{options:n,objects:[...l.template.objects].sort((s,C)=>s.insertOrder-C.insertOrder).map(s=>({objectApiName:s.objectApiName,recordCount:s.recordCount,...s.optional===!0?{optional:!0}:{}})),tests:l.tests.length,caseStatusFrom:e.caseStatus.from==="org"?{from:"org"}:{from:"default",reason:e.caseStatus.reason},knowledge:t}}}function D(a){return async e=>{let r=await a.query(e),o=[...r.records];for(;!r.done&&r.nextRecordsUrl;)r=await a.queryMore(r.nextRecordsUrl),o.push(...r.records);return o}}export{h as a,w as b,k as c,c as d,E as e,T as f,v as g,D as h};
7
+ import{a as y,b as g}from"./chunk-KAZS5Z6W.mjs";import{a as S,b as f,c as p}from"./chunk-FITPY3L4.mjs";import{b as u}from"./chunk-CA5NAXSU.mjs";import{Ha as d}from"./chunk-PMWAFDUB.mjs";var h="SELECT ApiName, MasterLabel, IsClosed, IsDefault, SortOrder FROM CaseStatus ORDER BY SortOrder",w="SELECT MasterLabel, IsClosed, IsDefault, SortOrder FROM CaseStatus ORDER BY SortOrder",A="Closed";async function k(a){let e;try{e=await a(h)}catch{try{e=await a(w)}catch(t){return m(`the org would not read its case statuses: ${u(t)}`)}}let r=e.flatMap(t=>{let n=b(t.ApiName)??b(t.MasterLabel);return n===void 0?[]:[{value:n,closed:t.IsClosed===!0,isDefault:t.IsDefault===!0}]}),o=r.filter(t=>!t.closed),i=r.filter(t=>t.closed);return o.length===0||i.length===0?m(o.length===0?"the org has no case status that leaves a case open":"the org has no case status that closes a case"):{open:(o.find(t=>t.isDefault)??o[0]).value,closed:(i.find(t=>t.value===A)??i[0]).value,from:"org"}}function m(a){return{...d.caseStatus,from:"default",reason:a}}function b(a){return typeof a=="string"&&a.trim()!==""?a:void 0}var c=S;async function E(a,e){let r;try{r=await a(c)}catch{r={access:"createable"}}if(r.access==="absent")return{available:!1,reason:r.reason??`the org has no ${c}`};if(r.access==="readOnly")return{available:!1,reason:r.reason??`the user this seed runs as may read ${c} and not create it`};try{return{available:!0,bodyFields:f(await e(c))}}catch{return{available:!0,bodyFields:[]}}}var P=["Status","Origin","Priority","Type"];async function T(a){let e;try{e=(await a("Case")).fields}catch{return}let r={};for(let o of P){let t=(e.find(n=>n.name===o)?.picklistValues??[]).filter(n=>n.active!==!1).map(n=>n.value);t.length>0&&(r[o]=t)}return r}function v(a,e){let r=e.knowledge.available?e.knowledge.bodyFields:[],o=r.map(s=>s.name),i=e.articleBodyField===void 0?r[0]:r.find(s=>s.name===e.articleBodyField);if(e.articleBodyField!==void 0&&i===void 0)return{issues:[`options.articleBodyField: ${e.articleBodyField} is not a field of ${c} this org lets a body be written to`+(o.length>0?` (${o.join(", ")})`:"")]};let t=e.knowledge.available?{available:!0,bodyFields:o}:e.knowledge,n={seed:e.seed??d.seed,caseStatus:{open:e.caseStatus.open,closed:e.caseStatus.closed},...i!==void 0?p(i):{}},l;try{l=g(a,n)}catch(s){if(s instanceof y)return{issues:s.issues};throw s}return{preparation:{options:n,objects:[...l.template.objects].sort((s,C)=>s.insertOrder-C.insertOrder).map(s=>({objectApiName:s.objectApiName,recordCount:s.recordCount,...s.optional===!0?{optional:!0}:{}})),tests:l.tests.length,caseStatusFrom:e.caseStatus.from==="org"?{from:"org"}:{from:"default",reason:e.caseStatus.reason},knowledge:t}}}function D(a){return async e=>{let r=await a.query(e),o=[...r.records];for(;!r.done&&r.nextRecordsUrl;)r=await a.queryMore(r.nextRecordsUrl),o.push(...r.records);return o}}export{h as a,w as b,k as c,c as d,E as e,T as f,v as g,D as h};
@@ -4,6 +4,6 @@ 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 u,b as a,c as h,d as g,e as l,f as m}from"./chunk-DMT5SCO3.mjs";import{k as p}from"./chunk-N2HYG3BL.mjs";import{randomBytes as k}from"node:crypto";import{mkdir as v,open as O,readdir as w,rename as S,rm as $}from"node:fs/promises";import{homedir as b}from"node:os";import{dirname as x,join as f,resolve as y}from"node:path";var E=448,D=384,A="_recovery",I="Back into service",T=/^(\d{8}T\d{9}Z)-(00D[A-Za-z0-9]{15})\.md$/;function J(e=process.env){let t=e.SANDFORGE_JOURNAL_DIR;return t!==void 0&&t.trim()!==""?y(t):f(b(),".sandforge")}function R(e){return f(y(e),"handoff",A)}function M(e,t){let n=new Date(t.at).toISOString().replace(/[-:.]/g,"");return f(R(e),`${n}-${p(t.organizationId)}.md`)}function _(e){return`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}T${e.slice(9,11)}:${e.slice(11,13)}:${e.slice(13,15)}.${e.slice(15,18)}Z`}async function F(e,t){let n=p(t),o=R(e),i;try{i=await w(o)}catch(r){let s=r?.code;if(s==="ENOENT"||s==="ENOTDIR")return;throw r}let c=i.flatMap(r=>{let s=T.exec(r);return s?.[1]!==void 0&&s[2]===n?[{stamp:s[1],name:r}]:[]}).sort((r,s)=>r.stamp<s.stamp?-1:1).at(-1);return c!==void 0?{at:_(c.stamp),path:f(o,c.name)}:void 0}async function W(e,t){return(await F(e,t))?.at}var H={refresh:"Refresh noticed",users:"Users",masking:"Masking of the data copied from production",replay:"Replay of the checkpoint of before",frozen:"Frozen dataset loaded",testersCheckpoint:"Testers' starting checkpoint",deliverability:"Email deliverability",scheduledJobs:"Scheduled jobs",endpoints:"Endpoints that still name production",handoff:"Handoff note"},N={refreshDetected:"noticed",ranAfterRefresh:"ran on the sandbox since its refresh",markedDone:"checked and marked done",ready:"kept",toDo:"to do",skipped:"skipped",noRefreshDetected:"no refresh was noticed",nothingCopied:"nothing of production was copied into this sandbox",noCheckpointBefore:"no checkpoint of the sandbox was taken before its refresh",noManifest:"no frozen dataset is kept on this machine",noInventoryBefore:"no inventory of its jobs was kept before the refresh",noUserToBringBack:"no user is under .invalid, frozen or inactive",stagingSandbox:"the sandbox is marked Staging"},B={todo:"to do",done:"done",skipped:"skipped",notApplicable:"not applicable",refused:"refused"};function z(e,t,n){let o=[B[e.status]];return e.status!=="todo"&&e.status!=="skipped"&&o.push(N[e.reason]),e.at!==void 0&&o.push(a(e.at)),e.id==="users"&&n.lastUsersRun!==void 0&&o.push(`last run ${n.lastUsersRun.run}, ${n.lastUsersRun.status}`),e.id==="replay"&&n.checkpointBefore!==void 0&&o.push(`checkpoint ${u(n.checkpointBefore.name)} of ${a(n.checkpointBefore.takenAt)}`),`${t+1}. ${H[e.id]}: ${o.join(", ")}.`}function Y(e){let{status:t,org:n}=e,o=t.refresh,i=o!==void 0?`- Refresh: noticed ${a(o.detectedAt)}`+(o.previousOrganizationId!==void 0?`; the sandbox was ${u(o.previousOrganizationId)} before.`:"."):"- Refresh: none was noticed; the steps are of the org the sandbox is.",d=t.steps.find(r=>r.id==="testersCheckpoint");return`${[h(I,n),"","## Sandbox","",g(n),i,`- Written: ${a(e.at)}`+(e.sandforgeVersion!==void 0?`, by SandForge ${e.sandforgeVersion}`:"")+`; ${t.done} of ${t.total} steps done.`,"","## Steps","",...t.steps.map((r,s)=>z(r,s,t)),"","## Testers' starting point","",d?.status==="done"&&d.at!==void 0?`- A checkpoint of the sandbox taken ${a(d.at)}: what the testers start from, and what a rewind takes it back to.`:"- No checkpoint of the sandbox was taken since its refresh: take one before the testers start, to rewind to.","",...l(e.audits,{endpoints:"step 9 of Back into service lists those that still name production.",schedules:"step 8 of Back into service compares them with their inventory."}),"",...m()].join(`
7
+ import{a as u,b as a,c as h,d as g,e as l,f as m}from"./chunk-7YNM6KFZ.mjs";import{k as p}from"./chunk-KGU4SVIT.mjs";import{randomBytes as R}from"node:crypto";import{mkdir as v,open as O,readdir as w,rename as S,rm as $}from"node:fs/promises";import{homedir as b}from"node:os";import{dirname as x,join as f,resolve as k}from"node:path";var E=448,D=384,A="_recovery",I="Back into service",T=/^(\d{8}T\d{9}Z)-(00D[A-Za-z0-9]{15})\.md$/;function J(e=process.env){let t=e.SANDFORGE_JOURNAL_DIR;return t!==void 0&&t.trim()!==""?k(t):f(b(),".sandforge")}function y(e){return f(k(e),"handoff",A)}function M(e,t){let n=new Date(t.at).toISOString().replace(/[-:.]/g,"");return f(y(e),`${n}-${p(t.organizationId)}.md`)}function _(e){return`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}T${e.slice(9,11)}:${e.slice(11,13)}:${e.slice(13,15)}.${e.slice(15,18)}Z`}async function F(e,t){let n=p(t),o=y(e),i;try{i=await w(o)}catch(r){let s=r?.code;if(s==="ENOENT"||s==="ENOTDIR")return;throw r}let c=i.flatMap(r=>{let s=T.exec(r);return s?.[1]!==void 0&&s[2]===n?[{stamp:s[1],name:r}]:[]}).sort((r,s)=>r.stamp<s.stamp?-1:1).at(-1);return c!==void 0?{at:_(c.stamp),path:f(o,c.name)}:void 0}async function W(e,t){return(await F(e,t))?.at}var H={refresh:"Refresh noticed",users:"Users",masking:"Masking of the data copied from production",replay:"Replay of the checkpoint of before",frozen:"Frozen dataset loaded",testersCheckpoint:"Testers' starting checkpoint",deliverability:"Email deliverability",scheduledJobs:"Scheduled jobs",endpoints:"Endpoints that still name production",handoff:"Handoff note"},N={refreshDetected:"noticed",ranAfterRefresh:"ran on the sandbox since its refresh",markedDone:"checked and marked done",ready:"kept",toDo:"to do",skipped:"skipped",noRefreshDetected:"no refresh was noticed",nothingCopied:"nothing of production was copied into this sandbox",noCheckpointBefore:"no checkpoint of the sandbox was taken before its refresh",noManifest:"no frozen dataset is kept on this machine",noInventoryBefore:"no inventory of its jobs was kept before the refresh",noUserToBringBack:"no user is under .invalid, frozen or inactive",stagingSandbox:"the sandbox is marked Staging"},B={todo:"to do",done:"done",skipped:"skipped",notApplicable:"not applicable",refused:"refused"};function z(e,t,n){let o=[B[e.status]];return e.status!=="todo"&&e.status!=="skipped"&&o.push(N[e.reason]),e.at!==void 0&&o.push(a(e.at)),e.id==="users"&&n.lastUsersRun!==void 0&&o.push(`last run ${n.lastUsersRun.run}, ${n.lastUsersRun.status}`+(n.lastUsersRun.takenBack===!0?", taken back by its removal":"")),e.id==="replay"&&n.checkpointBefore!==void 0&&o.push(`checkpoint ${u(n.checkpointBefore.name)} of ${a(n.checkpointBefore.takenAt)}`),`${t+1}. ${H[e.id]}: ${o.join(", ")}.`}function Y(e){let{status:t,org:n}=e,o=t.refresh,i=o!==void 0?`- Refresh: noticed ${a(o.detectedAt)}`+(o.previousOrganizationId!==void 0?`; the sandbox was ${u(o.previousOrganizationId)} before.`:"."):"- Refresh: none was noticed; the steps are of the org the sandbox is.",d=t.steps.find(r=>r.id==="testersCheckpoint");return`${[h(I,n),"","## Sandbox","",g(n),i,`- Written: ${a(e.at)}`+(e.sandforgeVersion!==void 0?`, by SandForge ${e.sandforgeVersion}`:"")+`; ${t.done} of ${t.total} steps done.`,"","## Steps","",...t.steps.map((r,s)=>z(r,s,t)),"","## Testers' starting point","",d?.status==="done"&&d.at!==void 0?`- A checkpoint of the sandbox taken ${a(d.at)}: what the testers start from, and what a rewind takes it back to.`:"- No checkpoint of the sandbox was taken since its refresh: take one before the testers start, to rewind to.","",...l(e.audits,{endpoints:"step 9 of Back into service lists those that still name production.",schedules:"step 8 of Back into service compares them with their inventory."}),"",...m()].join(`
8
8
  `)}
9
- `}async function Z(e,t){await v(x(e),{recursive:!0,mode:E});let n=`${e}.${process.pid}-${k(4).toString("hex")}.tmp`,o=await O(n,"wx",D);try{try{await o.writeFile(t,"utf8"),await o.sync()}finally{await o.close()}await S(n,e)}catch(i){throw await $(n,{force:!0}),i}}export{E as a,D as b,A as c,J as d,R as e,M as f,F as g,W as h,Y as i,Z as j};
9
+ `}async function Z(e,t){await v(x(e),{recursive:!0,mode:E});let n=`${e}.${process.pid}-${R(4).toString("hex")}.tmp`,o=await O(n,"wx",D);try{try{await o.writeFile(t,"utf8"),await o.sync()}finally{await o.close()}await S(n,e)}catch(i){throw await $(n,{force:!0}),i}}export{E as a,D as b,A as c,J as d,y as e,M as f,F as g,W as h,Y as i,Z as j};
@@ -4,6 +4,6 @@ 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{Ic as m,Nc as l,Qc as p}from"./chunk-AXFD2OH6.mjs";import{mkdirSync as $,statSync as A}from"node:fs";import{homedir as k}from"node:os";import{join as g,resolve as x}from"node:path";var y=448;function D(e=process.env){return S("backups",e)}function S(e,r=process.env){let t=r.SANDFORGE_JOURNAL_DIR,n=t!==void 0&&t.trim()!==""?x(t):g(k(),".sandforge");return g(n,e)}var w={mkdir:(e,r)=>{$(e,r)},stat:e=>A(e),...typeof process.getuid=="function"?{uid:()=>process.getuid?.()??-1}:{}};function I(e,r=w){try{r.mkdir(e,{recursive:!0,mode:y});let t=r.stat(e);if(!t.isDirectory())return`The store ${e} is not a folder.`;let n=r.uid?.();return n!==void 0&&t.uid!==n?`The store ${e} belongs to another user, who can read its snapshots and change them: name a folder of your own with --store.`:void 0}catch(t){return`The store ${e} could not be made: ${t instanceof Error?t.message:String(t)}`}}function B(e){if(e!==void 0)return/^\d{1,5}$/.test(e)||(process.stderr.write(`Not a number of days: "${e}"
7
+ import{Ic as m,Nc as l,Qc as p}from"./chunk-XGGOUNPP.mjs";import{mkdirSync as $,statSync as A}from"node:fs";import{homedir as k}from"node:os";import{join as g,resolve as x}from"node:path";var y=448;function D(e=process.env){return S("backups",e)}function S(e,r=process.env){let t=r.SANDFORGE_JOURNAL_DIR,n=t!==void 0&&t.trim()!==""?x(t):g(k(),".sandforge");return g(n,e)}var w={mkdir:(e,r)=>{$(e,r)},stat:e=>A(e),...typeof process.getuid=="function"?{uid:()=>process.getuid?.()??-1}:{}};function I(e,r=w){try{r.mkdir(e,{recursive:!0,mode:y});let t=r.stat(e);if(!t.isDirectory())return`The store ${e} is not a folder.`;let n=r.uid?.();return n!==void 0&&t.uid!==n?`The store ${e} belongs to another user, who can read its snapshots and change them: name a folder of your own with --store.`:void 0}catch(t){return`The store ${e} could not be made: ${t instanceof Error?t.message:String(t)}`}}function B(e){if(e!==void 0)return/^\d{1,5}$/.test(e)||(process.stderr.write(`Not a number of days: "${e}"
8
8
  `),process.exit(2)),Number(e)}function E(e,r){return e.flatMap((t,n)=>t===r&&n+1<e.length?[e[n+1]??""]:[])}function F(e){let r=[];for(let t of e){/^[1-9]\d{0,5}(,[1-9]\d{0,5})*$/.test(t)||(process.stderr.write(`Not a slice's number: "${t}". Give --slice 2, or --slice 1,3.
9
9
  `),process.exit(2));for(let n of t.split(",").map(Number))r.includes(n)||r.push(n)}return r.sort((t,n)=>t-n)}function C(e){return(r,t)=>r==="backup.maxRecordsPerObject"&&e.maxRecords!==void 0?e.maxRecords:r==="backup.maxAgeDays"&&e.maxAgeDays!==void 0?e.maxAgeDays:t}function M(e){let r=`removed snapshot ${e.operationId}${e.takenAt!==void 0?`, taken ${e.takenAt}`:""}: past the retention of ${e.days} day(s) (--max-age-days, 0 keeps them all)`;return e.syncRunId!==void 0?`${r}. It held what the Sync run ${e.syncRunId||"(unknown)"} wrote over: removing that run with sandforge sync --remove no longer puts those values back`:r}var j=1440*6e4;function _(e,r,t={}){let n=e.get(`backup:${r}`);if(n){let o=(n.objects??[]).map(s=>({objectApiName:s.objectApiName,records:s.recordCount??0}));return{words:n.origin==="slice"&&n.setId!==void 0?`slice ${n.slice?.index??"?"} of set ${n.setId}`:`snapshot ${r}`,objects:o,totalRecords:n.totalRecords??o.reduce((s,f)=>s+f.records,0)}}let a=new p(e).get(r);if(!a)return;let c=a.objects.flatMap(o=>o.slices.filter(s=>s.state!=="pending").map(s=>({objectApiName:o.objectApiName,slice:s}))),i=t.slices,d=i?c.filter(o=>i.includes(o.slice.index)):t.rewriteAll===!0?c:c.filter(o=>o.slice.restoredAt===void 0),u=[];for(let{objectApiName:o,slice:s}of d){let f=u.find(h=>h.objectApiName===o);f?f.records+=s.rows:u.push({objectApiName:o,records:s.rows})}let b=i?`slice(s) ${i.join(", ")}`:t.rewriteAll===!0?"every slice":`the ${d.length} slice(s) not put back yet`;return{words:`set ${r} (${b}, of ${c.length})`,objects:u,totalRecords:u.reduce((o,s)=>o+s.records,0)}}function L(e){let r=e.slices;return Array.isArray(r)?r.map(t=>t.skipped===!0?` slice ${t.index} ${t.objectApiName} put back before, not read again (--slice or --rewrite-all puts it back again)`:` slice ${t.index} ${t.objectApiName} put back ${t.restored} refused ${t.failed} unchanged ${t.unchanged}`):[]}function P(e){return new p(e).list()}function N(e,r){let t=Date.parse(e.lastActivityAt);if(!(r<=0||!Number.isFinite(t)))return new Date(t+r*j).toISOString().slice(0,10)}function J(e,r){let t=m(e),n=t.reduce((i,d)=>i+d.rows,0),a=e.objects.map(i=>`${i.objectApiName}${i.where!==void 0?` (where ${i.where})`:""}`).join(", "),c=N(e,r);return`${e.setId} ${e.startedAt} ${e.orgId} ${a} ${t.length} slice(s) of up to ${e.size} ${n} record(s) ${e.kind}, ${l(e)} `+(c!==void 0?`expires ${c}`:"kept (--max-age-days 0)")}export{D as a,S as b,I as c,B as d,E as e,F as f,C as g,M as h,_ as i,L as j,P as k,N as l,J as m};
@@ -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{fc as o,id as d}from"./chunk-6QSHWIZI.mjs";var u=new Set(["picklist","multipicklist"]);function c(a){return(a.picklistValues??[]).filter(s=>s.active!==!1&&typeof s.value=="string"&&s.value!=="").map(s=>s.value)}function m(a){let s=new Map,r=i=>{let t=s.get(i);return t||(t=a(i),s.set(i,t)),t};return{async createable(i){let{fields:t}=await r(i);return new Set(t.filter(e=>e.createable===!0).map(e=>e.name))},async visible(i){let{fields:t}=await r(i);return new Set(t.map(e=>e.name))},async computed(i){let{fields:t}=await r(i);return new Set(t.filter(e=>e.calculated===!0||e.autoNumber===!0).map(e=>e.name))},async picklistValues(i){let{fields:t}=await r(i),e=new Map;for(let n of t){if(!u.has(n.type??""))continue;let l=c(n);l.length>0&&e.set(n.name,l)}return e},async keyPrefix(i){let{keyPrefix:t}=await r(i);return typeof t=="string"&&t.length===3?t:void 0},async lengths(i){let{fields:t}=await r(i);return new Map(t.flatMap(e=>typeof e.length=="number"&&e.length>0?[[e.name,e.length]]:[]))},async unset(i){let{fields:t}=await r(i),e=n=>n.type==="reference"||(n.referenceTo??[]).length>0;return{empty:new Set(t.filter(n=>e(n)&&n.nillable===!0&&n.defaultedOnCreate!==!0).map(n=>n.name)),filled:new Set(t.filter(n=>n.nillable===!1||n.defaultedOnCreate===!0).map(n=>n.name))}},async required(i){let{fields:t}=await r(i);return t.filter(e=>e.createable===!0&&e.nillable===!1&&e.defaultedOnCreate!==!0&&(e.referenceTo??[]).length===0).map(e=>({fieldApiName:e.name,type:e.type??"string",picklistValues:c(e),referenceTo:[],length:e.length??0,integerDigits:o({...e,type:e.type??"string"}),objectApiName:i,required:!0}))}}}function p(a,s){return async r=>(await a.required(r)).filter(i=>!d(r,i.fieldApiName,s.includes(r)?"person":"business"))}export{m as a,p as b};
7
+ import{fc as o,id as d}from"./chunk-PMWAFDUB.mjs";var u=new Set(["picklist","multipicklist"]);function c(a){return(a.picklistValues??[]).filter(s=>s.active!==!1&&typeof s.value=="string"&&s.value!=="").map(s=>s.value)}function m(a){let s=new Map,r=i=>{let t=s.get(i);return t||(t=a(i),s.set(i,t)),t};return{async createable(i){let{fields:t}=await r(i);return new Set(t.filter(e=>e.createable===!0).map(e=>e.name))},async visible(i){let{fields:t}=await r(i);return new Set(t.map(e=>e.name))},async computed(i){let{fields:t}=await r(i);return new Set(t.filter(e=>e.calculated===!0||e.autoNumber===!0).map(e=>e.name))},async picklistValues(i){let{fields:t}=await r(i),e=new Map;for(let n of t){if(!u.has(n.type??""))continue;let l=c(n);l.length>0&&e.set(n.name,l)}return e},async keyPrefix(i){let{keyPrefix:t}=await r(i);return typeof t=="string"&&t.length===3?t:void 0},async lengths(i){let{fields:t}=await r(i);return new Map(t.flatMap(e=>typeof e.length=="number"&&e.length>0?[[e.name,e.length]]:[]))},async unset(i){let{fields:t}=await r(i),e=n=>n.type==="reference"||(n.referenceTo??[]).length>0;return{empty:new Set(t.filter(n=>e(n)&&n.nillable===!0&&n.defaultedOnCreate!==!0).map(n=>n.name)),filled:new Set(t.filter(n=>n.nillable===!1||n.defaultedOnCreate===!0).map(n=>n.name))}},async required(i){let{fields:t}=await r(i);return t.filter(e=>e.createable===!0&&e.nillable===!1&&e.defaultedOnCreate!==!0&&(e.referenceTo??[]).length===0).map(e=>({fieldApiName:e.name,type:e.type??"string",picklistValues:c(e),referenceTo:[],length:e.length??0,integerDigits:o({...e,type:e.type??"string"}),objectApiName:i,required:!0}))}}}function p(a,s){return async r=>(await a.required(r)).filter(i=>!d(r,i.fieldApiName,s.includes(r)?"person":"business"))}export{m as a,p as b};
@@ -4,7 +4,7 @@ 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 _e}from"./chunk-TW3N6W5Z.mjs";import{a as Le,b as Ee,c as Te,d as De}from"./chunk-5GBO4KD5.mjs";import{a as ye,j as $e}from"./chunk-BNKT3R3F.mjs";import{a as M}from"./chunk-QROPNEGY.mjs";import{b as G,e as H}from"./chunk-BZ24IAP5.mjs";import{a as U}from"./chunk-SCKUIE3R.mjs";import{c as J}from"./chunk-6FARZYMJ.mjs";import{a as Me}from"./chunk-WAYQLQAD.mjs";import{f as pe,j as Q,k as T,m as ge,n as _,o as D,p as we}from"./chunk-FKCIGJOI.mjs";import{a as Se,c as je,d as xe,e as Re,f as Ce,g as Oe,h as Ie,i as Pe,j as Ne}from"./chunk-HVX2AFYW.mjs";import{Qc as fe,za as le}from"./chunk-AXFD2OH6.mjs";import{h as be,i as ke}from"./chunk-X2XZQ434.mjs";import{m as ve}from"./chunk-5OGNK3JP.mjs";import{l as me}from"./chunk-XMQ5R6TC.mjs";import{h as he}from"./chunk-BT43WSOS.mjs";import{b as oe}from"./chunk-7ZBDACVG.mjs";import{b as ne,c as re,e as ae,f as ie,h as Ae}from"./chunk-LCDPCUXS.mjs";import{q as ue}from"./chunk-2GSMHGIV.mjs";import{e as de,g as ce}from"./chunk-TZE3Y7IQ.mjs";import{Wc as te,gd as se,y as W}from"./chunk-6QSHWIZI.mjs";import{readFileSync as Xe}from"node:fs";import{basename as Ke,join as Ve}from"node:path";var Ze=`sandforge dataops \u2014 mask an org's records, and put them back, without the editor.
7
+ import{a as _e}from"./chunk-TW3N6W5Z.mjs";import{a as Le,b as Ee,c as Te,d as De}from"./chunk-5GBO4KD5.mjs";import{a as ye,j as $e}from"./chunk-2METQHGG.mjs";import{b as G,e as H}from"./chunk-RKTFFCNS.mjs";import{c as J}from"./chunk-6FARZYMJ.mjs";import{a as Me}from"./chunk-JLSIWO4Z.mjs";import{f as pe,j as Q,k as T,m as ge,n as _,o as D,p as we}from"./chunk-KJWFYBMU.mjs";import{a as Se,c as je,d as xe,e as Re,f as Ce,g as Oe,h as Ie,i as Pe,j as Ne}from"./chunk-QTG6LUZT.mjs";import{Qc as fe,za as le}from"./chunk-XGGOUNPP.mjs";import{h as be,i as ke}from"./chunk-L53JWJ3S.mjs";import{a as M}from"./chunk-QROPNEGY.mjs";import{n as ve}from"./chunk-IVFVNNGB.mjs";import{m as me}from"./chunk-VINGECAJ.mjs";import{h as he}from"./chunk-PMN4PAC3.mjs";import{a as U}from"./chunk-AL4C3GFT.mjs";import{b as oe}from"./chunk-OUZQPYT3.mjs";import{b as ne,c as re,e as ae,f as ie,h as Ae}from"./chunk-LCDPCUXS.mjs";import{q as ue}from"./chunk-TNT27RBG.mjs";import{e as de,g as ce}from"./chunk-TZE3Y7IQ.mjs";import{Wc as te,gd as se,y as W}from"./chunk-PMWAFDUB.mjs";import{readFileSync as Xe}from"node:fs";import{basename as Ke,join as Ve}from"node:path";var Ze=`sandforge dataops \u2014 mask an org's records, and put them back, without the editor.
8
8
 
9
9
  Usage:
10
10
  npx sandforge dataops anonymize \\
@@ -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,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-WBELLGNE.mjs";import"./chunk-N2HYG3BL.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ISOSTAJR.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{c as LEDGER_KEPT_LINES,b as LEDGER_MAX_LINES,i as OrgClockWatch,a as REWIND_LEDGER_FILE,f as appendToRewindLedger,l as noteRewindEnded,m as noteRewindUndone,g as readRewindLedger,h as readRewindLedgers,k as rewindEndedRecord,e as rewindLedgerBeside,d as rewindLedgerFileOf,j as rewindTotalsOf};
7
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-NSQWI7ZY.mjs";import"./chunk-KGU4SVIT.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-S42RBRH2.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{c as LEDGER_KEPT_LINES,b as LEDGER_MAX_LINES,i as OrgClockWatch,a as REWIND_LEDGER_FILE,f as appendToRewindLedger,l as noteRewindEnded,m as noteRewindUndone,g as readRewindLedger,h as readRewindLedgers,k as rewindEndedRecord,e as rewindLedgerBeside,d as rewindLedgerFileOf,j as rewindTotalsOf};
@@ -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 as j,c as M}from"./chunk-INIT2UKJ.mjs";import{d as K}from"./chunk-2GSMHGIV.mjs";import{a as T,h as N}from"./chunk-TZE3Y7IQ.mjs";import{Ac as J,Bc as Q,Ec as C,Fc as v,Mc as H,Nc as $,Oc as F,zc as z}from"./chunk-6QSHWIZI.mjs";var ee="Id = NULL",B="no parent in cache and not the root",Y=class{build(t){let n=this.buildMeasured(t);return{...n,statements:_(n.statements,t.node.objectApiName,t.selectFields)}}buildMeasured(t){let n=N(t.node.objectApiName),o=k(M(t.selectFields)),r=t.extraWhere?` AND (${t.extraWhere})`:"",i=t.extraWhere?" + extra filter":"",l=`SELECT ${o} FROM ${n} WHERE `,u=t.node.objectApiName===t.rootObjectApiName&&!t.under;if(u&&!(t.rootReadAgain&&t.cache.has(t.node.objectApiName))){if(t.rootRecordIds!==void 0)return{statements:L({prefix:l,suffix:r,wrap:!1,objectApiName:t.node.objectApiName},[{field:"Id",ids:t.rootRecordIds}]),scoped:t.rootRecordIds.size>0,scope:"root",reason:`${t.rootRecordIds.size} root records${i}`,parentObjectsUsed:[t.rootObjectApiName],scopeIdCount:t.rootRecordIds.size,byIdCount:0};let b=T(t.rootRecordId??"");return{statements:[`${l}Id = '${b}'${r}`],scoped:!0,scope:"root",reason:`root record${i}`,parentObjectsUsed:[t.rootObjectApiName],scopeIdCount:1,byIdCount:0}}let d=t.under?void 0:t.cache.get(t.node.objectApiName),s=d?.size??0,a=d&&s>0?L({prefix:l,suffix:r,wrap:!1,objectApiName:t.node.objectApiName},[{field:"Id",ids:d}]):[],h=`${s} ID(s) cached from earlier wave`,f={statements:a,scoped:!0,scope:"self-cached",reason:`${h}${i}`,parentObjectsUsed:[],scopeIdCount:s,byIdCount:a.length};if(s>0&&(!t.everyEdge||u))return f;let g=[],I=[],y=0;for(let b of t.edges){if(b.targetObject!==t.node.objectApiName||t.under&&!t.under.has(b.sourceObject)||b.sourceObject===b.targetObject)continue;let O=t.fromAboveOnly||t.catalog?.has(b.sourceObject)?t.cache.reachedOf(b.sourceObject):t.cache.scopeOf(b.sourceObject);if(!O||O.size===0)continue;let S=t.fields.filter(c=>c.type==="reference"&&c.referenceTo.includes(b.sourceObject));if(S.length!==0){for(let c of S)g.push({field:N(c.name),ids:O});I.includes(b.sourceObject)||(I.push(b.sourceObject),y+=O.size)}}let R=[];for(let b of t.fields){if(b.type!=="reference"||b.nillable!==!1)continue;let O=new Set;for(let S of b.referenceTo){if(!t.readObjects?.has(S))continue;let c=t.catalog?.has(S)===!0;if(c&&!t.cache.isRead(S))continue;let m=c?t.cache.scopeOf(S):t.cache.get(S);if(m)for(let p of m)O.add(p)}O.size!==0&&R.push({field:N(b.name),ids:O})}let x=R.length>0?" + required parents in scope":"";if(g.length===0)return s>0?f:{statements:[`${l}${ee}`],scoped:!1,scope:"unscoped",reason:B,parentObjectsUsed:[],scopeIdCount:0,byIdCount:1};let w=Z({prefix:l,extraSuffix:r,objectApiName:t.node.objectApiName},g,R),A=`via ${I.join(", ")}${i}${x}`;return s===0?{statements:w,scoped:!0,scope:"parent-fk",reason:A,parentObjectsUsed:I,scopeIdCount:y,byIdCount:0}:{statements:[...a,...w],scoped:!0,scope:"self-and-parent-fk",reason:`${h}, and ${A}`,parentObjectsUsed:I,scopeIdCount:s+y,byIdCount:a.length}}buildJoining(t){let n=N(t.objectApiName),r=`SELECT ${k(M(t.selectFields))} FROM ${n} WHERE `,i=t.extraWhere?` AND (${t.extraWhere})`:"";return _(Z({prefix:r,extraSuffix:i,objectApiName:t.objectApiName},[{field:N(t.split.field),ids:t.split.ids}],[{field:N(t.whole.field),ids:t.whole.ids}]),t.objectApiName,t.selectFields)}buildById(t){let n=N(t.objectApiName);return _(L({prefix:`SELECT ${k(M(t.selectFields))} FROM ${n} WHERE `,suffix:t.extraWhere?` AND (${t.extraWhere})`:"",wrap:!1,objectApiName:t.objectApiName},[{field:"Id",ids:t.ids}]),t.objectApiName,t.selectFields)}};function k(e){return e.length===0?"Id":e.map(t=>N(t)).join(", ")}function _(e,t,n){let o=N(t),r=`SELECT ${k(M(n))} FROM ${o} `,i=`SELECT ${k(n)} FROM ${o} `;return r===i?[...e]:e.map(l=>l.startsWith(r)?i+l.slice(r.length):l)}var te=500;function W(e,t){let n=[...t].map(o=>`'${T(o)}'`).join(", ");return` AND (${e.field} IN (${n}))`}function ne(e,t){if(e.field!==t.field)return!1;for(let n of e.ids)if(!t.ids.has(n))return!1;return!0}function oe(e,t,n){let o=j(W(e,[])),r=j(", "),i=[],l=[],u=o;for(let d of e.ids){let s=j(`'${T(d)}'`);if(l.length>0&&u+r+s>t&&(i.push(l),l=[],u=o),l.length===0&&o+s>t)throw X(n);u+=(l.length>0?r:0)+s,l.push(d)}return l.length>0&&i.push(l),i}function re(e,t,n){let o=[""];for(let r of e){let i=oe(r,t/e.length,n);o=o.flatMap(l=>i.map(u=>l+W(r,u)))}return o}function Z(e,t,n){let o=(d,s)=>L({prefix:e.prefix,suffix:d,wrap:d!=="",objectApiName:e.objectApiName},s),r=n.map(d=>W(d,d.ids)).join(""),i=14e3-j(`${e.prefix}()${e.extraSuffix}`);if(j(r)<=i/2)return o(`${r}${e.extraSuffix}`,t);let l=new Map;for(let d of t){let s=n.filter(f=>!ne(d,f)),a=s.map(f=>f.field).join("|"),h=l.get(a)??{needed:s,clauses:[]};h.clauses.push(d),l.set(a,h)}let u=[];for(let d of l.values())for(let s of re(d.needed,i/2,e.objectApiName))u.push(...o(`${s}${e.extraSuffix}`,d.clauses));return u}function X(e){return new Error(`Scoped clone for ${e}: its filter leaves a Salesforce query URI no room for a single record Id. Shorten the filter on this object and run it again.`)}function L(e,t){let n=e.wrap?"(":"",o=e.wrap?")":"",r=j(e.prefix+n+o+e.suffix),i=j(", "),l=j(" OR "),u=[],d=[],s=r,a=0,h=()=>{let f=d.map(g=>`${g.field} IN (${g.values.join(", ")})`).join(" OR ");u.push(`${e.prefix}${n}${f}${o}${e.suffix}`),d=[],s=r,a=0};for(let f of t){let g=j(`${f.field} IN ()`),I=!1;for(let y of f.ids){let R=`'${T(y)}'`,x=j(R),w=I?i+x:(d.length>0?l:0)+g+x,A=s+w>14e3||a>=te;if(d.length>0&&A&&(h(),I=!1,w=g+x),d.length===0&&s+w>14e3)throw X(e.objectApiName);I?d[d.length-1].values.push(R):(d.push({field:f.field,values:[R]}),I=!0),s+=w,a++}}return d.length>0&&h(),u}var G="Product2",U=[C,G,$,F,v,"ProductCategory","ProductCatalog"],Ne=new Set(U);function je(e,t){return z(e,t.name,t.nillable)||e===C&&t.name===H}function xe(e,t=new Set){let n=new Set(e.nodes.map(o=>o.objectApiName));return new Set(U.filter(o=>!n.has(o)&&!t.has(o)))}function we(e,t){return e.nodes.some(n=>n.included&&t.has(n.objectApiName))?{...e,nodes:e.nodes.map(n=>n.included&&t.has(n.objectApiName)?{...n,included:!1}:n)}:e}function se(e,t,n){if(t.length<2)return t;let o=e.slice(0,3),r=t.find(i=>n.get(i)===o);return r!==void 0?[r]:t.filter(i=>!n.has(i))}function Ae(e,t){let n=q(e);return t?he(n,t):n}function Ee(e,t,n){let o=U.flatMap(f=>t.filter(({node:g})=>g.objectApiName===f)),r=new Set(o.flatMap(({fieldInfos:f})=>f.flatMap(g=>g.isReference?g.referenceTo??[]:[]))),i=new Map,l=new Map,u=(f,g,I)=>{let y=f.get(g);y?y.push(I):f.set(g,[I])};for(let{sourceObject:f,targetObject:g}of n)u(i,g,f),u(l,f,g);let d=[],s=new Set,a=[...e],h=a.filter(f=>r.has(f.objectApiName));for(;h.length>0;){for(let f of h)s.add(f.objectApiName),d.push(f);a=a.filter(f=>!s.has(f.objectApiName)),h=a.filter(({objectApiName:f})=>(i.get(f)??[]).some(g=>s.has(g))||(l.get(f)??[]).some(g=>s.has(g)))}return[...a,...o.map(({node:f})=>f),...d]}function V(e){return e.settable!==!1}function Ce(e,t){let n=!1,o=e.edges.map(r=>{let i=(t.get(r.targetObject)??[]).filter(s=>s.isReference&&(s.referenceTo??[]).includes(r.sourceObject));if(i.length===0)return r;let l=i.some(s=>J(s)),u=i.some(s=>Q(s));if(l===V(r)&&u===(r.insertOnly===!0))return r;n=!0;let d={...r};return l?delete d.settable:d.settable=!1,u?d.insertOnly=!0:delete d.insertOnly,d});return n?{...e,edges:o}:e}function Fe(e,t=[]){let n=e.edges.filter(V),o=[...n.filter(c=>c.required===!0),...t],r=n.filter(c=>c.insertOnly===!0&&c.required!==!0);if(o.length===0&&r.length===0)return q(e,n);let i=new Set(e.nodes.map(c=>c.objectApiName)),l=q(e,n),u=new Map(l.map((c,m)=>[c.objectApiName,m])),d=new Map,s=new Map,a=new Map,h=(c,m,p)=>{let E=c.get(m)??new Set;E.add(p),c.set(m,E)};for(let c of o){let{sourceObject:m,targetObject:p}=c;m===p||!i.has(m)||!i.has(p)||(h(d,p,m),h(s,m,p))}for(let c of n){let{sourceObject:m,targetObject:p}=c;m===p||!i.has(m)||!i.has(p)||d.get(p)?.has(m)||h(a,p,m)}let f=new Map;for(let[c,m]of a)for(let p of m)h(f,p,c);let g=new Map,I=new Map;for(let{sourceObject:c,targetObject:m}of r)c===m||!i.has(c)||!i.has(m)||d.get(m)?.has(c)||(h(g,m,c),h(I,c,m));let y=new Map,R=new Map,x=new Map;for(let c of i)y.set(c,d.get(c)?.size??0),R.set(c,g.get(c)?.size??0),x.set(c,a.get(c)?.size??0);let w=(c,m)=>{for(let p of[R,x,u]){let E=p.get(c)??0,D=p.get(m)??0;if(E!==D)return E<D}return!1},A=new Set([...i].filter(c=>y.get(c)===0)),b=new Map(e.nodes.map(c=>[c.objectApiName,c])),O=[],S=new Set;for(;A.size>0;){let c;for(let p of A)(c===void 0||w(p,c))&&(c=p);if(c===void 0)break;A.delete(c),S.add(c);let m=b.get(c);m&&O.push(m);for(let p of s.get(c)??[]){let E=(y.get(p)??1)-1;y.set(p,E),E===0&&!S.has(p)&&A.add(p)}for(let p of I.get(c)??[])R.set(p,(R.get(p)??1)-1);for(let p of f.get(c)??[])x.set(p,(x.get(p)??1)-1)}for(let c of e.nodes)S.has(c.objectApiName)||O.push(c);return O}function $e(e,t){return[[G,F],[$,F],[G,C],[$,C],[F,C],[v,C],...t.map(o=>[C,o])].filter(([o,r])=>o!==r&&e.has(o)&&e.has(r)).map(([o,r])=>({sourceObject:o,targetObject:r,relationshipName:`${o}Before${r}`,type:"lookup",required:!0}))}var ie=new Set(["Id","Name","CurrencyIsoCode","IsPersonAccount","IsActive","Status","IsWhat","IsInvitee","Response","RespondedDate",...Object.values(K).flat()]);function de(e,t){let n=new Set(t??[]);return e.filter(o=>o.queryable&&(!n.has(o.name)||o.isReference||ie.has(o.name))).map(o=>o.name)}var ce=2;function ae(e,t){let n=Array.from({length:t.length+1},(o,r)=>r);for(let o=1;o<=e.length;o++){let r=[o];for(let i=1;i<=t.length;i++)r[i]=Math.min(n[i]+1,r[i-1]+1,n[i-1]+(e[o-1]===t[i-1]?0:1));n=r}return n[t.length]}function le(e,t){let n=e.toLowerCase(),o;for(let r of t){let i=ae(n,r.toLowerCase());i<=ce&&i<n.length&&(!o||i<o.edits)&&(o={name:r,edits:i})}return o?.name}function Te(e,t,n){let o={},r=[];for(let[i,l]of Object.entries(e)){let u=t.find(a=>a.toLowerCase()===i.toLowerCase())??i,d=n(u),s=o[u]??=[];for(let a of l){let h=d?.find(g=>g.toLowerCase()===a.toLowerCase());if(h===void 0&&d!==null){let g=d===void 0?void 0:le(a,d);r.push({objectApiName:u,field:a,missing:d===void 0?"object":"field",...g!==void 0?{nearest:g}:{}})}let f=h??a;s.includes(f)||s.push(f)}}return{exclusions:o,unmatched:r}}function Me(e){let t=de(e.fieldInfos,e.fieldsLeftOut);t.length===0&&t.push("Id");let n,o=0,r=[],i=!1,l=!!e.rootRecordId||e.rootRecordIds!==void 0;if(e.scopedBuilder&&e.scopeCache&&e.rootObjectApiName&&l&&e.node.objectApiName===F&&e.node.objectApiName!==e.rootObjectApiName&&e.catalog?.has(F)){let d=ge(e.scopedBuilder,e.scopeCache,t,e.extraWhere);if(!d)return{kind:"skip",reason:B};n=d,o=n.length}else if(e.scopedBuilder&&e.scopeCache&&e.rootObjectApiName&&l){let d=e.fieldInfos.filter(a=>a.isReference).map(a=>({name:a.name,type:"reference",referenceTo:a.referenceTo??[],nillable:a.nillable})),s=e.scopedBuilder.build({node:e.node,fields:d,selectFields:t,edges:e.edges,cache:e.scopeCache,rootObjectApiName:e.rootObjectApiName,...e.rootRecordIds!==void 0?{rootRecordIds:e.rootRecordIds}:{rootRecordId:e.rootRecordId},extraWhere:e.extraWhere,everyEdge:!0,readObjects:e.readObjects,catalog:e.catalog,rootReadAgain:e.rootReadAgain,under:e.under});if(!s.scoped)return{kind:"skip",reason:s.reason};n=s.statements,o=s.byIdCount,i=s.scope==="root"&&e.rootRecordIds!==void 0,e.rootRecordIds!==void 0&&(s.scope==="parent-fk"||s.scope==="self-and-parent-fk")&&(r=s.parentObjectsUsed)}else{let d=[...e.extraWhere?[`(${e.extraWhere})`]:[],...e.inIdOrder?.afterId!==void 0?[`Id > ${ue(e.inIdOrder.afterId)}`]:[]],s=d.length>0?` WHERE ${d.join(" AND ")}`:"",a=e.inIdOrder?" ORDER BY Id":"";n=[`SELECT ${t.join(", ")} FROM ${N(e.node.objectApiName)}${s}${a}`]}let u={...o>0?{byIdCount:o}:{},...r.length>0?{readUnder:[...r]}:{}};if(!i&&e.maxRecordsPerObject&&e.maxRecordsPerObject>0){let d=Math.floor(e.maxRecordsPerObject);if(d>0)return fe(n,d,u)}return{kind:"query",statements:n,...u}}function fe(e,t,n={}){return{kind:"query",statements:e.map(o=>`${o} LIMIT ${t+1}`),limit:t,...n}}function ue(e){if(!/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(e))throw new Error(`Not a record id to resume after: ${JSON.stringify(e.slice(0,40))}`);return`'${e}'`}function ge(e,t,n,o){let r=t.scopeOf(G),i=t.scopeOf($);if(!(!r||r.size===0||!i||i.size===0))return e.buildJoining({objectApiName:F,selectFields:n,split:{field:"Product2Id",ids:r},whole:{field:"ProductSellingModelId",ids:i},extraWhere:o})}function ke(e){return(e.byIdCount??0)<e.statements.length}async function Le(e,t,n,o){let r=e.byIdCount??0,i=e.limit,l=s=>{if(i===void 0||s.length<=i)return s;for(let a of s.slice(i))typeof a.Id=="string"&&n?.delete(a.Id);return o?.(),s.slice(0,i)};if(e.statements.length===1){let s=await t(e.statements[0]);if(n&&r===0)for(let a of s)typeof a.Id=="string"&&n.add(a.Id);return l(s)}let u=[],d=new Set;for(let[s,a]of e.statements.entries())for(let h of await t(a)){let f=h.Id;if(typeof f=="string"){if(n&&s>=r&&n.add(f),d.has(f))continue;d.add(f)}if(u.push(h),i!==void 0&&u.length>i)return l(u)}return u}function pe(e,t,n,{settle:o=!0}={}){let r=[];for(let i of n){let l=i.Id;typeof l=="string"&&l&&r.push(l)}o?e.addRead(t,r):e.add(t,r)}function Ge(e,t,n,o,r={}){pe(e,t,n,r);let i=r.keyPrefixes??new Map,l=o.filter(u=>u.isReference&&u.referenceTo&&u.referenceTo.length>0);for(let u of l){let d=u.referenceTo??[];for(let s of n){let a=s[u.name];if(!(typeof a!="string"||!a))for(let h of se(a,d,i))e.add(h,[a])}}}function he(e,t){let n=e.findIndex(l=>l.objectApiName===t);if(n<0)throw new Error(`Cannot run scoped clone with root "${t}" missing from the graph. The root node was excluded or filtered out \u2014 re-include it before executing.`);let o=e[n];if(!o.included)throw o.status==="error"?new Error(`Cannot run scoped clone: root "${t}" could not be measured during discovery (${o.errors[0]??"unknown discovery error"}), and nothing was read or written. Run discovery again once the org answers for it; if it refuses again, the user the clone reads as may not read ${t}: start from a record the user can read.`):new Error(`Cannot run scoped clone with root "${t}" excluded: the clone starts from its record, and the records that point at it would be written without it. Include it again, or clone from a query instead of a record.`);if(n===0)return e;let r=[...e],[i]=r.splice(n,1);return r.unshift(i),r}function q(e,t){let n=t??e.edges,o=new Map;for(let s of e.nodes)o.set(s.objectApiName,s);let r=new Map,i=new Map;for(let s of e.nodes)r.set(s.objectApiName,0);for(let s of n){r.has(s.targetObject)&&r.set(s.targetObject,(r.get(s.targetObject)??0)+1);let a=i.get(s.sourceObject);a?a.push(s.targetObject):i.set(s.sourceObject,[s.targetObject])}let l=[];for(let[s,a]of r)a===0&&l.push(s);let u=[],d=new Set;for(;l.length>0;){let s=l.shift();if(d.has(s))continue;d.add(s);let a=o.get(s);a&&u.push(a);let h=i.get(s);if(h){for(let f of h)if(r.has(f)){let g=(r.get(f)??1)-1;r.set(f,g),g===0&&!d.has(f)&&l.push(f)}}}for(let s of e.nodes)d.has(s.objectApiName)||u.push(s);return u}export{B as a,Y as b,te as c,G as d,U as e,Ne as f,je as g,xe as h,we as i,se as j,Ae as k,Ee as l,V as m,Ce as n,Fe as o,$e as p,de as q,Te as r,Me as s,fe as t,ke as u,Le as v,pe as w,Ge as x};
7
+ import{a as j,c as M}from"./chunk-INIT2UKJ.mjs";import{d as K}from"./chunk-TNT27RBG.mjs";import{a as T,h as N}from"./chunk-TZE3Y7IQ.mjs";import{Ac as J,Bc as Q,Ec as C,Fc as v,Mc as H,Nc as $,Oc as F,zc as z}from"./chunk-PMWAFDUB.mjs";var ee="Id = NULL",B="no parent in cache and not the root",Y=class{build(t){let n=this.buildMeasured(t);return{...n,statements:_(n.statements,t.node.objectApiName,t.selectFields)}}buildMeasured(t){let n=N(t.node.objectApiName),o=k(M(t.selectFields)),r=t.extraWhere?` AND (${t.extraWhere})`:"",i=t.extraWhere?" + extra filter":"",l=`SELECT ${o} FROM ${n} WHERE `,u=t.node.objectApiName===t.rootObjectApiName&&!t.under;if(u&&!(t.rootReadAgain&&t.cache.has(t.node.objectApiName))){if(t.rootRecordIds!==void 0)return{statements:L({prefix:l,suffix:r,wrap:!1,objectApiName:t.node.objectApiName},[{field:"Id",ids:t.rootRecordIds}]),scoped:t.rootRecordIds.size>0,scope:"root",reason:`${t.rootRecordIds.size} root records${i}`,parentObjectsUsed:[t.rootObjectApiName],scopeIdCount:t.rootRecordIds.size,byIdCount:0};let b=T(t.rootRecordId??"");return{statements:[`${l}Id = '${b}'${r}`],scoped:!0,scope:"root",reason:`root record${i}`,parentObjectsUsed:[t.rootObjectApiName],scopeIdCount:1,byIdCount:0}}let d=t.under?void 0:t.cache.get(t.node.objectApiName),s=d?.size??0,a=d&&s>0?L({prefix:l,suffix:r,wrap:!1,objectApiName:t.node.objectApiName},[{field:"Id",ids:d}]):[],h=`${s} ID(s) cached from earlier wave`,f={statements:a,scoped:!0,scope:"self-cached",reason:`${h}${i}`,parentObjectsUsed:[],scopeIdCount:s,byIdCount:a.length};if(s>0&&(!t.everyEdge||u))return f;let g=[],I=[],y=0;for(let b of t.edges){if(b.targetObject!==t.node.objectApiName||t.under&&!t.under.has(b.sourceObject)||b.sourceObject===b.targetObject)continue;let O=t.fromAboveOnly||t.catalog?.has(b.sourceObject)?t.cache.reachedOf(b.sourceObject):t.cache.scopeOf(b.sourceObject);if(!O||O.size===0)continue;let S=t.fields.filter(c=>c.type==="reference"&&c.referenceTo.includes(b.sourceObject));if(S.length!==0){for(let c of S)g.push({field:N(c.name),ids:O});I.includes(b.sourceObject)||(I.push(b.sourceObject),y+=O.size)}}let R=[];for(let b of t.fields){if(b.type!=="reference"||b.nillable!==!1)continue;let O=new Set;for(let S of b.referenceTo){if(!t.readObjects?.has(S))continue;let c=t.catalog?.has(S)===!0;if(c&&!t.cache.isRead(S))continue;let m=c?t.cache.scopeOf(S):t.cache.get(S);if(m)for(let p of m)O.add(p)}O.size!==0&&R.push({field:N(b.name),ids:O})}let x=R.length>0?" + required parents in scope":"";if(g.length===0)return s>0?f:{statements:[`${l}${ee}`],scoped:!1,scope:"unscoped",reason:B,parentObjectsUsed:[],scopeIdCount:0,byIdCount:1};let w=Z({prefix:l,extraSuffix:r,objectApiName:t.node.objectApiName},g,R),A=`via ${I.join(", ")}${i}${x}`;return s===0?{statements:w,scoped:!0,scope:"parent-fk",reason:A,parentObjectsUsed:I,scopeIdCount:y,byIdCount:0}:{statements:[...a,...w],scoped:!0,scope:"self-and-parent-fk",reason:`${h}, and ${A}`,parentObjectsUsed:I,scopeIdCount:s+y,byIdCount:a.length}}buildJoining(t){let n=N(t.objectApiName),r=`SELECT ${k(M(t.selectFields))} FROM ${n} WHERE `,i=t.extraWhere?` AND (${t.extraWhere})`:"";return _(Z({prefix:r,extraSuffix:i,objectApiName:t.objectApiName},[{field:N(t.split.field),ids:t.split.ids}],[{field:N(t.whole.field),ids:t.whole.ids}]),t.objectApiName,t.selectFields)}buildById(t){let n=N(t.objectApiName);return _(L({prefix:`SELECT ${k(M(t.selectFields))} FROM ${n} WHERE `,suffix:t.extraWhere?` AND (${t.extraWhere})`:"",wrap:!1,objectApiName:t.objectApiName},[{field:"Id",ids:t.ids}]),t.objectApiName,t.selectFields)}};function k(e){return e.length===0?"Id":e.map(t=>N(t)).join(", ")}function _(e,t,n){let o=N(t),r=`SELECT ${k(M(n))} FROM ${o} `,i=`SELECT ${k(n)} FROM ${o} `;return r===i?[...e]:e.map(l=>l.startsWith(r)?i+l.slice(r.length):l)}var te=500;function W(e,t){let n=[...t].map(o=>`'${T(o)}'`).join(", ");return` AND (${e.field} IN (${n}))`}function ne(e,t){if(e.field!==t.field)return!1;for(let n of e.ids)if(!t.ids.has(n))return!1;return!0}function oe(e,t,n){let o=j(W(e,[])),r=j(", "),i=[],l=[],u=o;for(let d of e.ids){let s=j(`'${T(d)}'`);if(l.length>0&&u+r+s>t&&(i.push(l),l=[],u=o),l.length===0&&o+s>t)throw X(n);u+=(l.length>0?r:0)+s,l.push(d)}return l.length>0&&i.push(l),i}function re(e,t,n){let o=[""];for(let r of e){let i=oe(r,t/e.length,n);o=o.flatMap(l=>i.map(u=>l+W(r,u)))}return o}function Z(e,t,n){let o=(d,s)=>L({prefix:e.prefix,suffix:d,wrap:d!=="",objectApiName:e.objectApiName},s),r=n.map(d=>W(d,d.ids)).join(""),i=14e3-j(`${e.prefix}()${e.extraSuffix}`);if(j(r)<=i/2)return o(`${r}${e.extraSuffix}`,t);let l=new Map;for(let d of t){let s=n.filter(f=>!ne(d,f)),a=s.map(f=>f.field).join("|"),h=l.get(a)??{needed:s,clauses:[]};h.clauses.push(d),l.set(a,h)}let u=[];for(let d of l.values())for(let s of re(d.needed,i/2,e.objectApiName))u.push(...o(`${s}${e.extraSuffix}`,d.clauses));return u}function X(e){return new Error(`Scoped clone for ${e}: its filter leaves a Salesforce query URI no room for a single record Id. Shorten the filter on this object and run it again.`)}function L(e,t){let n=e.wrap?"(":"",o=e.wrap?")":"",r=j(e.prefix+n+o+e.suffix),i=j(", "),l=j(" OR "),u=[],d=[],s=r,a=0,h=()=>{let f=d.map(g=>`${g.field} IN (${g.values.join(", ")})`).join(" OR ");u.push(`${e.prefix}${n}${f}${o}${e.suffix}`),d=[],s=r,a=0};for(let f of t){let g=j(`${f.field} IN ()`),I=!1;for(let y of f.ids){let R=`'${T(y)}'`,x=j(R),w=I?i+x:(d.length>0?l:0)+g+x,A=s+w>14e3||a>=te;if(d.length>0&&A&&(h(),I=!1,w=g+x),d.length===0&&s+w>14e3)throw X(e.objectApiName);I?d[d.length-1].values.push(R):(d.push({field:f.field,values:[R]}),I=!0),s+=w,a++}}return d.length>0&&h(),u}var G="Product2",U=[C,G,$,F,v,"ProductCategory","ProductCatalog"],Ne=new Set(U);function je(e,t){return z(e,t.name,t.nillable)||e===C&&t.name===H}function xe(e,t=new Set){let n=new Set(e.nodes.map(o=>o.objectApiName));return new Set(U.filter(o=>!n.has(o)&&!t.has(o)))}function we(e,t){return e.nodes.some(n=>n.included&&t.has(n.objectApiName))?{...e,nodes:e.nodes.map(n=>n.included&&t.has(n.objectApiName)?{...n,included:!1}:n)}:e}function se(e,t,n){if(t.length<2)return t;let o=e.slice(0,3),r=t.find(i=>n.get(i)===o);return r!==void 0?[r]:t.filter(i=>!n.has(i))}function Ae(e,t){let n=q(e);return t?he(n,t):n}function Ee(e,t,n){let o=U.flatMap(f=>t.filter(({node:g})=>g.objectApiName===f)),r=new Set(o.flatMap(({fieldInfos:f})=>f.flatMap(g=>g.isReference?g.referenceTo??[]:[]))),i=new Map,l=new Map,u=(f,g,I)=>{let y=f.get(g);y?y.push(I):f.set(g,[I])};for(let{sourceObject:f,targetObject:g}of n)u(i,g,f),u(l,f,g);let d=[],s=new Set,a=[...e],h=a.filter(f=>r.has(f.objectApiName));for(;h.length>0;){for(let f of h)s.add(f.objectApiName),d.push(f);a=a.filter(f=>!s.has(f.objectApiName)),h=a.filter(({objectApiName:f})=>(i.get(f)??[]).some(g=>s.has(g))||(l.get(f)??[]).some(g=>s.has(g)))}return[...a,...o.map(({node:f})=>f),...d]}function V(e){return e.settable!==!1}function Ce(e,t){let n=!1,o=e.edges.map(r=>{let i=(t.get(r.targetObject)??[]).filter(s=>s.isReference&&(s.referenceTo??[]).includes(r.sourceObject));if(i.length===0)return r;let l=i.some(s=>J(s)),u=i.some(s=>Q(s));if(l===V(r)&&u===(r.insertOnly===!0))return r;n=!0;let d={...r};return l?delete d.settable:d.settable=!1,u?d.insertOnly=!0:delete d.insertOnly,d});return n?{...e,edges:o}:e}function Fe(e,t=[]){let n=e.edges.filter(V),o=[...n.filter(c=>c.required===!0),...t],r=n.filter(c=>c.insertOnly===!0&&c.required!==!0);if(o.length===0&&r.length===0)return q(e,n);let i=new Set(e.nodes.map(c=>c.objectApiName)),l=q(e,n),u=new Map(l.map((c,m)=>[c.objectApiName,m])),d=new Map,s=new Map,a=new Map,h=(c,m,p)=>{let E=c.get(m)??new Set;E.add(p),c.set(m,E)};for(let c of o){let{sourceObject:m,targetObject:p}=c;m===p||!i.has(m)||!i.has(p)||(h(d,p,m),h(s,m,p))}for(let c of n){let{sourceObject:m,targetObject:p}=c;m===p||!i.has(m)||!i.has(p)||d.get(p)?.has(m)||h(a,p,m)}let f=new Map;for(let[c,m]of a)for(let p of m)h(f,p,c);let g=new Map,I=new Map;for(let{sourceObject:c,targetObject:m}of r)c===m||!i.has(c)||!i.has(m)||d.get(m)?.has(c)||(h(g,m,c),h(I,c,m));let y=new Map,R=new Map,x=new Map;for(let c of i)y.set(c,d.get(c)?.size??0),R.set(c,g.get(c)?.size??0),x.set(c,a.get(c)?.size??0);let w=(c,m)=>{for(let p of[R,x,u]){let E=p.get(c)??0,D=p.get(m)??0;if(E!==D)return E<D}return!1},A=new Set([...i].filter(c=>y.get(c)===0)),b=new Map(e.nodes.map(c=>[c.objectApiName,c])),O=[],S=new Set;for(;A.size>0;){let c;for(let p of A)(c===void 0||w(p,c))&&(c=p);if(c===void 0)break;A.delete(c),S.add(c);let m=b.get(c);m&&O.push(m);for(let p of s.get(c)??[]){let E=(y.get(p)??1)-1;y.set(p,E),E===0&&!S.has(p)&&A.add(p)}for(let p of I.get(c)??[])R.set(p,(R.get(p)??1)-1);for(let p of f.get(c)??[])x.set(p,(x.get(p)??1)-1)}for(let c of e.nodes)S.has(c.objectApiName)||O.push(c);return O}function $e(e,t){return[[G,F],[$,F],[G,C],[$,C],[F,C],[v,C],...t.map(o=>[C,o])].filter(([o,r])=>o!==r&&e.has(o)&&e.has(r)).map(([o,r])=>({sourceObject:o,targetObject:r,relationshipName:`${o}Before${r}`,type:"lookup",required:!0}))}var ie=new Set(["Id","Name","CurrencyIsoCode","IsPersonAccount","IsActive","Status","IsWhat","IsInvitee","Response","RespondedDate",...Object.values(K).flat()]);function de(e,t){let n=new Set(t??[]);return e.filter(o=>o.queryable&&(!n.has(o.name)||o.isReference||ie.has(o.name))).map(o=>o.name)}var ce=2;function ae(e,t){let n=Array.from({length:t.length+1},(o,r)=>r);for(let o=1;o<=e.length;o++){let r=[o];for(let i=1;i<=t.length;i++)r[i]=Math.min(n[i]+1,r[i-1]+1,n[i-1]+(e[o-1]===t[i-1]?0:1));n=r}return n[t.length]}function le(e,t){let n=e.toLowerCase(),o;for(let r of t){let i=ae(n,r.toLowerCase());i<=ce&&i<n.length&&(!o||i<o.edits)&&(o={name:r,edits:i})}return o?.name}function Te(e,t,n){let o={},r=[];for(let[i,l]of Object.entries(e)){let u=t.find(a=>a.toLowerCase()===i.toLowerCase())??i,d=n(u),s=o[u]??=[];for(let a of l){let h=d?.find(g=>g.toLowerCase()===a.toLowerCase());if(h===void 0&&d!==null){let g=d===void 0?void 0:le(a,d);r.push({objectApiName:u,field:a,missing:d===void 0?"object":"field",...g!==void 0?{nearest:g}:{}})}let f=h??a;s.includes(f)||s.push(f)}}return{exclusions:o,unmatched:r}}function Me(e){let t=de(e.fieldInfos,e.fieldsLeftOut);t.length===0&&t.push("Id");let n,o=0,r=[],i=!1,l=!!e.rootRecordId||e.rootRecordIds!==void 0;if(e.scopedBuilder&&e.scopeCache&&e.rootObjectApiName&&l&&e.node.objectApiName===F&&e.node.objectApiName!==e.rootObjectApiName&&e.catalog?.has(F)){let d=ge(e.scopedBuilder,e.scopeCache,t,e.extraWhere);if(!d)return{kind:"skip",reason:B};n=d,o=n.length}else if(e.scopedBuilder&&e.scopeCache&&e.rootObjectApiName&&l){let d=e.fieldInfos.filter(a=>a.isReference).map(a=>({name:a.name,type:"reference",referenceTo:a.referenceTo??[],nillable:a.nillable})),s=e.scopedBuilder.build({node:e.node,fields:d,selectFields:t,edges:e.edges,cache:e.scopeCache,rootObjectApiName:e.rootObjectApiName,...e.rootRecordIds!==void 0?{rootRecordIds:e.rootRecordIds}:{rootRecordId:e.rootRecordId},extraWhere:e.extraWhere,everyEdge:!0,readObjects:e.readObjects,catalog:e.catalog,rootReadAgain:e.rootReadAgain,under:e.under});if(!s.scoped)return{kind:"skip",reason:s.reason};n=s.statements,o=s.byIdCount,i=s.scope==="root"&&e.rootRecordIds!==void 0,e.rootRecordIds!==void 0&&(s.scope==="parent-fk"||s.scope==="self-and-parent-fk")&&(r=s.parentObjectsUsed)}else{let d=[...e.extraWhere?[`(${e.extraWhere})`]:[],...e.inIdOrder?.afterId!==void 0?[`Id > ${ue(e.inIdOrder.afterId)}`]:[]],s=d.length>0?` WHERE ${d.join(" AND ")}`:"",a=e.inIdOrder?" ORDER BY Id":"";n=[`SELECT ${t.join(", ")} FROM ${N(e.node.objectApiName)}${s}${a}`]}let u={...o>0?{byIdCount:o}:{},...r.length>0?{readUnder:[...r]}:{}};if(!i&&e.maxRecordsPerObject&&e.maxRecordsPerObject>0){let d=Math.floor(e.maxRecordsPerObject);if(d>0)return fe(n,d,u)}return{kind:"query",statements:n,...u}}function fe(e,t,n={}){return{kind:"query",statements:e.map(o=>`${o} LIMIT ${t+1}`),limit:t,...n}}function ue(e){if(!/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(e))throw new Error(`Not a record id to resume after: ${JSON.stringify(e.slice(0,40))}`);return`'${e}'`}function ge(e,t,n,o){let r=t.scopeOf(G),i=t.scopeOf($);if(!(!r||r.size===0||!i||i.size===0))return e.buildJoining({objectApiName:F,selectFields:n,split:{field:"Product2Id",ids:r},whole:{field:"ProductSellingModelId",ids:i},extraWhere:o})}function ke(e){return(e.byIdCount??0)<e.statements.length}async function Le(e,t,n,o){let r=e.byIdCount??0,i=e.limit,l=s=>{if(i===void 0||s.length<=i)return s;for(let a of s.slice(i))typeof a.Id=="string"&&n?.delete(a.Id);return o?.(),s.slice(0,i)};if(e.statements.length===1){let s=await t(e.statements[0]);if(n&&r===0)for(let a of s)typeof a.Id=="string"&&n.add(a.Id);return l(s)}let u=[],d=new Set;for(let[s,a]of e.statements.entries())for(let h of await t(a)){let f=h.Id;if(typeof f=="string"){if(n&&s>=r&&n.add(f),d.has(f))continue;d.add(f)}if(u.push(h),i!==void 0&&u.length>i)return l(u)}return u}function pe(e,t,n,{settle:o=!0}={}){let r=[];for(let i of n){let l=i.Id;typeof l=="string"&&l&&r.push(l)}o?e.addRead(t,r):e.add(t,r)}function Ge(e,t,n,o,r={}){pe(e,t,n,r);let i=r.keyPrefixes??new Map,l=o.filter(u=>u.isReference&&u.referenceTo&&u.referenceTo.length>0);for(let u of l){let d=u.referenceTo??[];for(let s of n){let a=s[u.name];if(!(typeof a!="string"||!a))for(let h of se(a,d,i))e.add(h,[a])}}}function he(e,t){let n=e.findIndex(l=>l.objectApiName===t);if(n<0)throw new Error(`Cannot run scoped clone with root "${t}" missing from the graph. The root node was excluded or filtered out \u2014 re-include it before executing.`);let o=e[n];if(!o.included)throw o.status==="error"?new Error(`Cannot run scoped clone: root "${t}" could not be measured during discovery (${o.errors[0]??"unknown discovery error"}), and nothing was read or written. Run discovery again once the org answers for it; if it refuses again, the user the clone reads as may not read ${t}: start from a record the user can read.`):new Error(`Cannot run scoped clone with root "${t}" excluded: the clone starts from its record, and the records that point at it would be written without it. Include it again, or clone from a query instead of a record.`);if(n===0)return e;let r=[...e],[i]=r.splice(n,1);return r.unshift(i),r}function q(e,t){let n=t??e.edges,o=new Map;for(let s of e.nodes)o.set(s.objectApiName,s);let r=new Map,i=new Map;for(let s of e.nodes)r.set(s.objectApiName,0);for(let s of n){r.has(s.targetObject)&&r.set(s.targetObject,(r.get(s.targetObject)??0)+1);let a=i.get(s.sourceObject);a?a.push(s.targetObject):i.set(s.sourceObject,[s.targetObject])}let l=[];for(let[s,a]of r)a===0&&l.push(s);let u=[],d=new Set;for(;l.length>0;){let s=l.shift();if(d.has(s))continue;d.add(s);let a=o.get(s);a&&u.push(a);let h=i.get(s);if(h){for(let f of h)if(r.has(f)){let g=(r.get(f)??1)-1;r.set(f,g),g===0&&!d.has(f)&&l.push(f)}}}for(let s of e.nodes)d.has(s.objectApiName)||u.push(s);return u}export{B as a,Y as b,te as c,G as d,U as e,Ne as f,je as g,xe as h,we as i,se as j,Ae as k,Ee as l,V as m,Ce as n,Fe as o,$e as p,de as q,Te as r,Me as s,fe as t,ke as u,Le as v,pe as w,Ge as x};
@@ -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
+ var p=["SIGINT","SIGTERM","SIGHUP"],g={SIGHUP:129,SIGINT:130,SIGTERM:143};function T(s){return g[s]}var I="sandforge:stop",N="SANDFORGE_STOP_CHANNEL";function G(s){let r=new Map,S=new Map,t,n,i=o=>{let e=S.get(o);e&&process.off(o,e),S.delete(o),n?.signal===o&&(clearTimeout(n.timer),n=void 0)},l=()=>{for(let[o,e]of r)process.off(o,e);r.clear(),t&&process.off("message",t),t=void 0},d=()=>{l();for(let o of p)i(o)};for(let o of p){let e=()=>{n?.signal===o&&i(o)};S.set(o,e),process.on(o,e);let a=()=>{l();for(let u of p)u!==o&&i(u);let f={signal:o};n=f;let c=setTimeout(()=>i(o),1e3);typeof c=="object"&&c.unref(),n===f&&(f.timer=c),s(o)};r.set(o,a),process.once(o,a)}return process.env[N]==="ipc"&&typeof process.send=="function"&&(t=o=>{o===I&&(d(),s("SIGINT"))},process.on("message",t),process.channel?.unref()),d}export{p as a,T as b,I as c,N as d,G as e};
@@ -0,0 +1,28 @@
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 s}from"./chunk-AL4C3GFT.mjs";import{readFileSync as d}from"node:fs";import{extname as p,join as i}from"node:path";import{pathToFileURL as c}from"node:url";var r={autopilot:"run an Autopilot copy between two orgs",backup:"take and restore DataOps snapshots",checkpoint:"take a checkpoint of an org's data, and rewind the org to it",cleanup:"Bulk delete records you created on a sandbox in a time window",clone:"clone a record, or whole tables, from one org to a sandbox, or remove a run",compare:"compare two orgs the way the Compare page does, and deploy what differs",dataops:"mask an org's records, and put them back",empty:"empty objects of a sandbox, or the whole of it",env:"apply a sandforge.yaml to an org, and take it back",frozen:"build and replay a Frozen Dataset",mcp:"the MCP server: these scripts as tools for an AI agent, on stdio",monitor:"read an org the way the Monitor page does",pipeline:"plan and run an Automation pipeline exported from VS Code",seed:"fill an org from a seed template",sync:"run a Sync between two orgs",users:"set up the users of a sandbox after its refresh, and take them back"},a=o=>Object.prototype.hasOwnProperty.call(r,o);function m(o){let[e,...n]=o;if(e===void 0)return{kind:"refused",reason:"Name the command to run."};if(e==="--help"||e==="-h"||e==="help")return{kind:"help"};if(e==="--version"||e==="-v")return{kind:"version"};if(a(e))return{kind:"run",tool:e,args:n};let t=e.replace(/^sandforge-/,"");return t!==e&&a(t)?{kind:"refused",reason:`"${e}" is named ${t} here: ${s(t)} \u2026.`}:{kind:"refused",reason:e.startsWith("-")?`"${e}" is not a flag sandforge reads: name a command first.`:`"${e}" is not a command of sandforge.`}}function f(){let o=Math.max(...Object.keys(r).map(n=>n.length));return`sandforge \u2014 SandForge's command lines, without the editor: Seed, Forge's clone, Sync,
8
+ Checkpoints, DataOps, Frozen Dataset, the emptying of a sandbox, the users of a sandbox,
9
+ sandforge.yaml environments, Automation pipelines, and the MCP server.
10
+
11
+ Usage:
12
+ sandforge <command> [options]
13
+ sandforge <command> --help what the command does, its options and its exit codes
14
+
15
+ Commands:
16
+ ${Object.entries(r).map(([n,t])=>` ${n.padEnd(o)} ${t}`).join(`
17
+ `)}
18
+
19
+ Each org is named by its sf CLI alias: the Salesforce CLI (sf) must be installed and logged in
20
+ to it. In Claude Code:
21
+ claude mcp add sandforge -- npx -y sandforge mcp
22
+
23
+ --version the version of SandForge these scripts belong to
24
+ --help this text
25
+ `}function l(o,e=__dirname,n=__filename){return i(e,`sandforge-${o}${p(n)}`)}function h(o=__dirname){let e=JSON.parse(d(i(o,"..","package.json"),"utf8"));return typeof e.version=="string"?e.version:"0.0.0"}var u=o=>import(c(o).href);async function g(o=process.argv,e=u){let n=m(o.slice(2));switch(n.kind){case"help":process.stdout.write(f());return;case"version":process.stdout.write(`${h()}
26
+ `);return;case"refused":process.stderr.write(`${n.reason} Nothing was run. The commands: ${Object.keys(r).join(", ")}. Run with --help.
27
+ `),process.exitCode=2;return;case"run":{let t=l(n.tool);process.argv=[o[0]??process.execPath,t,...n.args],await e(t);return}}}/(?:^|[\\/])sandforge\.[cm]?[jt]s$/.test(process.argv[1]??"")&&g().catch(o=>{process.stderr.write(`${o instanceof Error?o.message:String(o)}
28
+ `),process.exit(1)});export{r as a,m as b,f as c,l as d,h as e,g as f};