sandforge 1.80.0 → 1.82.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/README.md +48 -0
  2. package/bin/sandforge-pipeline.mjs +12 -0
  3. package/bin/sandforge-users.mjs +12 -0
  4. package/lib/{chunk-J525F5KI.mjs → chunk-27Z76O2O.mjs} +1 -1
  5. package/lib/chunk-2JZGCCPG.mjs +9 -0
  6. package/lib/{chunk-ELFXJHU7.mjs → chunk-2UU42PTD.mjs} +1 -1
  7. package/lib/{chunk-N652NMZ4.mjs → chunk-32EUNQT6.mjs} +52 -52
  8. package/lib/chunk-3C2ZZIFN.mjs +7 -0
  9. package/lib/chunk-3CX7GPCR.mjs +7 -0
  10. package/lib/chunk-3HEMJTAP.mjs +925 -0
  11. package/lib/{chunk-BY2HJFFG.mjs → chunk-3HROD5RE.mjs} +1 -1
  12. package/lib/{chunk-OHWNPXWW.mjs → chunk-3MGMNK3Q.mjs} +1 -1
  13. package/lib/{chunk-PZPJKATS.mjs → chunk-3SKLBRPL.mjs} +8 -8
  14. package/lib/chunk-3XG25GTF.mjs +7 -0
  15. package/lib/chunk-42BFLWHR.mjs +7 -0
  16. package/lib/chunk-466F37VD.mjs +7 -0
  17. package/lib/chunk-47UHTN3Q.mjs +7 -0
  18. package/lib/chunk-4JKR4PTZ.mjs +8 -0
  19. package/lib/{chunk-COFG7Q6R.mjs → chunk-52EXDVPN.mjs} +1 -1
  20. package/lib/{chunk-SAR5622P.mjs → chunk-54HYHHVL.mjs} +1 -1
  21. package/lib/{chunk-RSWDYIHY.mjs → chunk-5GBO4KD5.mjs} +1 -1
  22. package/lib/chunk-5K2I2DMP.mjs +11 -0
  23. package/lib/{chunk-AV5SWEHP.mjs → chunk-6FARZYMJ.mjs} +1 -1
  24. package/lib/{chunk-BV6VTP3J.mjs → chunk-6GQUZ4IP.mjs} +1 -1
  25. package/lib/chunk-6KP6WETK.mjs +9 -0
  26. package/lib/{chunk-MJVTDA5Q.mjs → chunk-6VSZNZHH.mjs} +1 -1
  27. package/lib/{chunk-XUWL6ZPC.mjs → chunk-7CVDVBEE.mjs} +1 -1
  28. package/lib/{chunk-UCD54V2M.mjs → chunk-7EYQYZJP.mjs} +1 -1
  29. package/lib/{chunk-5K5VLULK.mjs → chunk-7LKI7OAS.mjs} +1 -1
  30. package/lib/chunk-7PY3VQP3.mjs +7 -0
  31. package/lib/chunk-7SDZR6SR.mjs +7 -0
  32. package/lib/chunk-7WSLT5VX.mjs +8 -0
  33. package/lib/chunk-A32ISQ6M.mjs +28 -0
  34. package/lib/{chunk-M3ROUWDX.mjs → chunk-A65ADTCR.mjs} +1 -1
  35. package/lib/chunk-A7JJWOLT.mjs +7 -0
  36. package/lib/chunk-AUS6NFLZ.mjs +8 -0
  37. package/lib/chunk-BMTNTBBM.mjs +7 -0
  38. package/lib/{chunk-SOU4FRYN.mjs → chunk-BN33LVPQ.mjs} +1 -1
  39. package/lib/chunk-BNKT3R3F.mjs +7 -0
  40. package/lib/{chunk-K2FBZIXY.mjs → chunk-BWWQXU2B.mjs} +1 -1
  41. package/lib/{chunk-IC2C2GOF.mjs → chunk-BXZ73A5M.mjs} +1 -1
  42. package/lib/{chunk-WA7EYLAQ.mjs → chunk-C2N2TNEU.mjs} +1 -1
  43. package/lib/{chunk-BKDV4ENO.mjs → chunk-C3LNYAVJ.mjs} +1 -1
  44. package/lib/{chunk-XLXIPIEW.mjs → chunk-CBL42DUU.mjs} +1 -1
  45. package/lib/chunk-CCEH7L53.mjs +7 -0
  46. package/lib/chunk-CELEBWEZ.mjs +7 -0
  47. package/lib/chunk-CV47FDQW.mjs +7 -0
  48. package/lib/{chunk-2UZPIMUC.mjs → chunk-CZLJZQCS.mjs} +1 -1
  49. package/lib/chunk-DBBPDSFN.mjs +7 -0
  50. package/lib/chunk-DIL62SUN.mjs +7 -0
  51. package/lib/chunk-DIS254AN.mjs +7 -0
  52. package/lib/{chunk-BTWDMNN3.mjs → chunk-DJCGURW7.mjs} +1 -1
  53. package/lib/{chunk-F6GUDTOB.mjs → chunk-DT3T7FRD.mjs} +1 -1
  54. package/lib/{chunk-IGYH7GMA.mjs → chunk-DWMRIWV5.mjs} +1 -1
  55. package/lib/{chunk-YRQGKDHM.mjs → chunk-EEFUE2ES.mjs} +1 -1
  56. package/lib/{chunk-FGRG7ANU.mjs → chunk-EOFO3PHS.mjs} +1 -1
  57. package/lib/{chunk-KBJ5VERV.mjs → chunk-FA4ZKDCU.mjs} +1 -1
  58. package/lib/{chunk-WU3GLFZO.mjs → chunk-FKK5YBGZ.mjs} +1 -1
  59. package/lib/chunk-FOIWWK7G.mjs +156 -0
  60. package/lib/chunk-FZF23M6R.mjs +7 -0
  61. package/lib/chunk-G2JR3F63.mjs +7 -0
  62. package/lib/{chunk-JEERQRLW.mjs → chunk-GBGHJTPC.mjs} +1 -1
  63. package/lib/{chunk-3RZQZHEB.mjs → chunk-GCGHHN4K.mjs} +1 -1
  64. package/lib/{chunk-RPI7LRTW.mjs → chunk-GGNUACTY.mjs} +1 -1
  65. package/lib/{chunk-EMNC6YI4.mjs → chunk-GGUOIDWP.mjs} +1 -1
  66. package/lib/chunk-GHPR5UVV.mjs +7 -0
  67. package/lib/{chunk-X5JYBPXP.mjs → chunk-GJ6SZVHT.mjs} +1 -1
  68. package/lib/{chunk-W622GUAW.mjs → chunk-H4JUYUSL.mjs} +1 -1
  69. package/lib/{chunk-XAMBCQPU.mjs → chunk-H4OBZIX3.mjs} +1 -1
  70. package/lib/{chunk-WIO4XO4F.mjs → chunk-HFSBDM7B.mjs} +1 -1
  71. package/lib/{chunk-L77FJZEP.mjs → chunk-HFUDCNU5.mjs} +1 -1
  72. package/lib/chunk-HIHCYMSL.mjs +7 -0
  73. package/lib/chunk-HKUWHVI7.mjs +9 -0
  74. package/lib/chunk-HQQVANWQ.mjs +20 -0
  75. package/lib/chunk-ICIYL45C.mjs +7 -0
  76. package/lib/chunk-IRZJU2PG.mjs +22 -0
  77. package/lib/chunk-ISSP2FZ5.mjs +7 -0
  78. package/lib/chunk-IVZJSDJD.mjs +7 -0
  79. package/lib/chunk-J24TIGSI.mjs +10 -0
  80. package/lib/{chunk-UNJA4J37.mjs → chunk-JESRFE2Z.mjs} +4 -4
  81. package/lib/chunk-JFNLKHY6.mjs +8 -0
  82. package/lib/chunk-JH27IKCO.mjs +9 -0
  83. package/lib/chunk-JJITOWZK.mjs +7 -0
  84. package/lib/{chunk-E5AHXLS6.mjs → chunk-JKT5YAQ2.mjs} +1 -1
  85. package/lib/{chunk-IWDREM66.mjs → chunk-JLZRZL5E.mjs} +1 -1
  86. package/lib/{chunk-FPKYYFM7.mjs → chunk-JPEVIXNH.mjs} +1 -1
  87. package/lib/chunk-JQZTMFO7.mjs +7 -0
  88. package/lib/chunk-KIMQQ6JQ.mjs +7 -0
  89. package/lib/{chunk-MILU7WFN.mjs → chunk-KJYEQHYP.mjs} +1 -1
  90. package/lib/chunk-KKOA62S4.mjs +474 -0
  91. package/lib/chunk-KP5G6FUC.mjs +7 -0
  92. package/lib/{chunk-JWTSEDIQ.mjs → chunk-L4INJ5TZ.mjs} +1 -1
  93. package/lib/{chunk-OLSGVAIL.mjs → chunk-LAUOSXMN.mjs} +53 -53
  94. package/lib/{chunk-MTMH6H2A.mjs → chunk-LCDPCUXS.mjs} +1 -1
  95. package/lib/{chunk-KDGMAGQR.mjs → chunk-LHU6CPGE.mjs} +1 -1
  96. package/lib/{chunk-YAZO75G2.mjs → chunk-LNXBCE7E.mjs} +1 -1
  97. package/lib/chunk-LXDSRP2W.mjs +7 -0
  98. package/lib/{chunk-2YIV2OB2.mjs → chunk-MIDBQ7SD.mjs} +1 -1
  99. package/lib/{chunk-TTKXMDBN.mjs → chunk-MKTXJCXN.mjs} +4 -4
  100. package/lib/chunk-MUEQRIK7.mjs +9 -0
  101. package/lib/{chunk-IOIWJ3DJ.mjs → chunk-NLB3RGIY.mjs} +1 -1
  102. package/lib/{chunk-O2HDYYUV.mjs → chunk-NWOI25WY.mjs} +1 -1
  103. package/lib/chunk-O2PUGRNW.mjs +10 -0
  104. package/lib/chunk-O4BROUGM.mjs +7 -0
  105. package/lib/chunk-OETEC3P7.mjs +7 -0
  106. package/lib/{chunk-GCOB7K5N.mjs → chunk-OHEOJISY.mjs} +1 -1
  107. package/lib/chunk-P55MKIZX.mjs +37 -0
  108. package/lib/chunk-P63WJMXQ.mjs +7 -0
  109. package/lib/chunk-PBE44M2Y.mjs +7 -0
  110. package/lib/{chunk-TYYOBZMU.mjs → chunk-PC247GKX.mjs} +1 -1
  111. package/lib/chunk-PE435FVH.mjs +15 -0
  112. package/lib/chunk-PPGDAUEQ.mjs +7 -0
  113. package/lib/{chunk-SE4QEZUG.mjs → chunk-PPHVWUFY.mjs} +1 -1
  114. package/lib/{chunk-CU2INBND.mjs → chunk-PR74GYVI.mjs} +1 -1
  115. package/lib/chunk-PWVDNN2C.mjs +7 -0
  116. package/lib/{chunk-6XYKJSGX.mjs → chunk-PYRZFUVU.mjs} +1 -1
  117. package/lib/{chunk-TLH7AD35.mjs → chunk-PZBZ7MNC.mjs} +1 -1
  118. package/lib/{chunk-DYFALGRT.mjs → chunk-Q3DY7TO2.mjs} +1 -1
  119. package/lib/{chunk-BGUEWRK2.mjs → chunk-Q6SXNKV2.mjs} +1 -1
  120. package/lib/chunk-QAPVKPEC.mjs +7 -0
  121. package/lib/{chunk-DBFJB2B6.mjs → chunk-QIRO4HTE.mjs} +1 -1
  122. package/lib/{chunk-TSLJUSLW.mjs → chunk-RCYEBY42.mjs} +1 -1
  123. package/lib/chunk-RLWB7F26.mjs +7 -0
  124. package/lib/{chunk-FXXLX4O6.mjs → chunk-RTWYLOCA.mjs} +1 -1
  125. package/lib/chunk-RYRMUPMY.mjs +7 -0
  126. package/lib/chunk-SAMWHL22.mjs +13 -0
  127. package/lib/{chunk-IZQZ6ZUF.mjs → chunk-SFGZFB4F.mjs} +1 -1
  128. package/lib/{chunk-FKG7Q3WH.mjs → chunk-SNEOKYV7.mjs} +1 -1
  129. package/lib/{chunk-3TJON4F3.mjs → chunk-STRMWSIQ.mjs} +1 -1
  130. package/lib/chunk-SZGGFST2.mjs +272 -0
  131. package/lib/{chunk-SOGQW4IG.mjs → chunk-T7WREYA5.mjs} +1 -1
  132. package/lib/{chunk-NTFIRZP6.mjs → chunk-TCBAE65A.mjs} +1 -1
  133. package/lib/{chunk-KYEDBS54.mjs → chunk-TEIBWMJM.mjs} +1 -1
  134. package/lib/{chunk-YKKRIEH4.mjs → chunk-TMA34QMA.mjs} +1 -1
  135. package/lib/chunk-TQ2TQHTT.mjs +9 -0
  136. package/lib/{chunk-HEKAZJRH.mjs → chunk-TWV4A5RK.mjs} +1 -1
  137. package/lib/{chunk-CEX3NEZL.mjs → chunk-UHFLKP26.mjs} +1 -1
  138. package/lib/chunk-UV74P4H2.mjs +7 -0
  139. package/lib/{chunk-WR4Q363I.mjs → chunk-V3R45ZWT.mjs} +1 -1
  140. package/lib/{chunk-GSKCGQIP.mjs → chunk-VPDEJGPS.mjs} +1 -1
  141. package/lib/{chunk-HLWMJF6Y.mjs → chunk-VQJMP3DC.mjs} +1 -1
  142. package/lib/chunk-VV3B6IC3.mjs +7 -0
  143. package/lib/{chunk-PJ5I73CK.mjs → chunk-VYOYXTCU.mjs} +1 -1
  144. package/lib/{chunk-NZC67CGR.mjs → chunk-VZT4E2OJ.mjs} +1 -1
  145. package/lib/{chunk-AEKONPF4.mjs → chunk-VZVICK7Q.mjs} +1 -1
  146. package/lib/{chunk-WR2GIKWE.mjs → chunk-WB2RIVO3.mjs} +1 -1
  147. package/lib/chunk-WEMLDUQA.mjs +7 -0
  148. package/lib/{chunk-MYW5QNGI.mjs → chunk-WOOUISSO.mjs} +1 -1
  149. package/lib/{chunk-G35N4P7D.mjs → chunk-WSUKC2U3.mjs} +1 -1
  150. package/lib/{chunk-ZVAED4QV.mjs → chunk-WT3SCUHS.mjs} +1 -1
  151. package/lib/{chunk-7EANH5PY.mjs → chunk-WZQEK4WT.mjs} +1 -1
  152. package/lib/{chunk-DBB3EMIN.mjs → chunk-XFU3HRUV.mjs} +1 -1
  153. package/lib/chunk-XK5W7BVE.mjs +7 -0
  154. package/lib/{chunk-2GTBABKU.mjs → chunk-XO5FBOQF.mjs} +1 -1
  155. package/lib/{chunk-CHYDMRSV.mjs → chunk-XSKPYGMT.mjs} +1 -1
  156. package/lib/chunk-XU25YA46.mjs +9 -0
  157. package/lib/chunk-XZISAZA6.mjs +7 -0
  158. package/lib/chunk-Y4TDVDP2.mjs +13 -0
  159. package/lib/chunk-YAIIRFKJ.mjs +8 -0
  160. package/lib/{chunk-LKQ5RKIV.mjs → chunk-YAJQS3OL.mjs} +1 -1
  161. package/lib/{chunk-74Q6DORA.mjs → chunk-YGJF55VJ.mjs} +1 -1
  162. package/lib/chunk-YH4DYI6D.mjs +7 -0
  163. package/lib/chunk-YMDFF657.mjs +10 -0
  164. package/lib/{chunk-2BA2XKAY.mjs → chunk-YT22LMF7.mjs} +1 -1
  165. package/lib/{chunk-IG2MTQRP.mjs → chunk-Z42PHCVZ.mjs} +1 -1
  166. package/lib/{chunk-2NBYT7GR.mjs → chunk-ZHIZY3ZC.mjs} +1 -1
  167. package/lib/chunk-ZQO5PDX5.mjs +48 -0
  168. package/lib/chunk-ZRUDYB7O.mjs +7 -0
  169. package/lib/{chunk-BXU6WFMH.mjs → chunk-ZUBBEP75.mjs} +1 -1
  170. package/lib/chunk-ZUOPC4W2.mjs +7 -0
  171. package/lib/{chunk-GGD7ON3M.mjs → chunk-ZUTUYBNW.mjs} +1 -1
  172. package/lib/{chunk-MHMH6MTP.mjs → chunk-ZXFL2MSN.mjs} +1 -1
  173. package/lib/sandforge-autopilot.mjs +11 -11
  174. package/lib/sandforge-backup.mjs +63 -32
  175. package/lib/sandforge-checkpoint.mjs +1 -348
  176. package/lib/sandforge-cleanup.mjs +1 -1
  177. package/lib/sandforge-clone.mjs +1 -1
  178. package/lib/sandforge-compare.mjs +1 -1
  179. package/lib/sandforge-dataops.mjs +1 -1
  180. package/lib/sandforge-empty.mjs +11 -11
  181. package/lib/sandforge-env.mjs +186 -140
  182. package/lib/sandforge-frozen.mjs +1 -266
  183. package/lib/sandforge-mcp.mjs +33 -14
  184. package/lib/sandforge-monitor.mjs +1 -1
  185. package/lib/sandforge-pipeline.mjs +88 -0
  186. package/lib/sandforge-seed.mjs +1 -1
  187. package/lib/sandforge-sync.mjs +1 -1
  188. package/lib/sandforge-users.mjs +157 -0
  189. package/lib/sandforge.mjs +1 -22
  190. package/lib/sf/sandforge/autopilot.mjs +20 -0
  191. package/lib/sf/sandforge/backup.mjs +20 -0
  192. package/lib/sf/sandforge/checkpoint.mjs +20 -0
  193. package/lib/sf/sandforge/cleanup.mjs +20 -0
  194. package/lib/sf/sandforge/clone.mjs +20 -0
  195. package/lib/sf/sandforge/compare.mjs +20 -0
  196. package/lib/sf/sandforge/dataops.mjs +20 -0
  197. package/lib/sf/sandforge/empty.mjs +20 -0
  198. package/lib/sf/sandforge/env.mjs +20 -0
  199. package/lib/sf/sandforge/frozen.mjs +20 -0
  200. package/lib/sf/sandforge/hardis-commands.mjs +20 -0
  201. package/lib/sf/sandforge/index.mjs +20 -0
  202. package/lib/sf/sandforge/mcp.mjs +20 -0
  203. package/lib/sf/sandforge/monitor.mjs +20 -0
  204. package/lib/sf/sandforge/pipeline.mjs +20 -0
  205. package/lib/sf/sandforge/seed.mjs +20 -0
  206. package/lib/sf/sandforge/sync.mjs +20 -0
  207. package/lib/sf/sandforge/users.mjs +20 -0
  208. package/lib/sfHelpHook.mjs +7 -0
  209. package/lib/sfPlugin.mjs +11 -0
  210. package/oclif.manifest.json +1 -0
  211. package/package.json +18 -3
  212. package/lib/chunk-2CNCDM56.mjs +0 -7
  213. package/lib/chunk-3F6Q5E7I.mjs +0 -14
  214. package/lib/chunk-4VS2V6WU.mjs +0 -25
  215. package/lib/chunk-5P4PHJRL.mjs +0 -9
  216. package/lib/chunk-5TC3QB4U.mjs +0 -10
  217. package/lib/chunk-7ABODJ4G.mjs +0 -7
  218. package/lib/chunk-7EGQP6S4.mjs +0 -7
  219. package/lib/chunk-7FFGJWHN.mjs +0 -7
  220. package/lib/chunk-7YDNUBO5.mjs +0 -7
  221. package/lib/chunk-A527W53V.mjs +0 -7
  222. package/lib/chunk-ADOAS63R.mjs +0 -7
  223. package/lib/chunk-B5QQJ4SI.mjs +0 -7
  224. package/lib/chunk-CION3VMZ.mjs +0 -7
  225. package/lib/chunk-CSBS5U5I.mjs +0 -7
  226. package/lib/chunk-DB7RBE5D.mjs +0 -7
  227. package/lib/chunk-E5ZB3LU5.mjs +0 -7
  228. package/lib/chunk-EFR2Y7E4.mjs +0 -7
  229. package/lib/chunk-EHQ3FX6X.mjs +0 -7
  230. package/lib/chunk-EQNW3UC2.mjs +0 -7
  231. package/lib/chunk-F43REJDZ.mjs +0 -10
  232. package/lib/chunk-GSG7WZHM.mjs +0 -7
  233. package/lib/chunk-HOJYWTP7.mjs +0 -20
  234. package/lib/chunk-HS4YRX4J.mjs +0 -7
  235. package/lib/chunk-I7O6C2B5.mjs +0 -8
  236. package/lib/chunk-IFETCRWE.mjs +0 -10
  237. package/lib/chunk-IQXHJEYB.mjs +0 -7
  238. package/lib/chunk-JPUR2CFX.mjs +0 -10
  239. package/lib/chunk-K327QKMD.mjs +0 -7
  240. package/lib/chunk-KRCA6IPH.mjs +0 -8
  241. package/lib/chunk-LPBMBW3O.mjs +0 -13
  242. package/lib/chunk-LWW4U276.mjs +0 -7
  243. package/lib/chunk-MFG4MUIO.mjs +0 -9
  244. package/lib/chunk-MJU2PGZQ.mjs +0 -15
  245. package/lib/chunk-OAZRPP4I.mjs +0 -7
  246. package/lib/chunk-OO6CLPEH.mjs +0 -7
  247. package/lib/chunk-OPXCV2KL.mjs +0 -7
  248. package/lib/chunk-P33PSCXK.mjs +0 -7
  249. package/lib/chunk-Q3DM32KF.mjs +0 -11
  250. package/lib/chunk-QR3WELJQ.mjs +0 -7
  251. package/lib/chunk-QWT2C74M.mjs +0 -7
  252. package/lib/chunk-R3X3LV64.mjs +0 -14
  253. package/lib/chunk-RMBPOTD7.mjs +0 -7
  254. package/lib/chunk-SIHORWVK.mjs +0 -7
  255. package/lib/chunk-T62WNR54.mjs +0 -7
  256. package/lib/chunk-TTFDUKUS.mjs +0 -47
  257. package/lib/chunk-VE6XKGGD.mjs +0 -7
  258. package/lib/chunk-VGW4MXXZ.mjs +0 -7
  259. package/lib/chunk-VS7ZXUII.mjs +0 -824
  260. package/lib/chunk-VXQLDM4R.mjs +0 -7
  261. package/lib/chunk-VYXMVJL5.mjs +0 -7
  262. package/lib/chunk-W7U5E5ZL.mjs +0 -9
  263. package/lib/chunk-WXAQ7FK3.mjs +0 -115
  264. package/lib/chunk-YS4G22C2.mjs +0 -7
  265. package/lib/chunk-ZM6OJGIG.mjs +0 -7
  266. package/lib/chunk-ZUTYVST5.mjs +0 -7
@@ -0,0 +1,88 @@
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{p as De}from"./chunk-KKOA62S4.mjs";import"./chunk-YGJF55VJ.mjs";import"./chunk-HIHCYMSL.mjs";import"./chunk-JESRFE2Z.mjs";import"./chunk-CBL42DUU.mjs";import"./chunk-MKTXJCXN.mjs";import"./chunk-RCYEBY42.mjs";import"./chunk-AUS6NFLZ.mjs";import"./chunk-YH4DYI6D.mjs";import"./chunk-SZGGFST2.mjs";import"./chunk-LAUOSXMN.mjs";import"./chunk-INIQ23K6.mjs";import"./chunk-2UU42PTD.mjs";import"./chunk-GCGHHN4K.mjs";import"./chunk-2JZGCCPG.mjs";import{a as W,c as Oe,g as Ie,h as Y,i as Te,j as be,k as q,l as Ee,m as Ne,n as xe,o as Ae,p as _e,q as Ce}from"./chunk-HQQVANWQ.mjs";import"./chunk-BXZ73A5M.mjs";import"./chunk-DBBPDSFN.mjs";import"./chunk-GBGHJTPC.mjs";import"./chunk-ZRUDYB7O.mjs";import"./chunk-IRZJU2PG.mjs";import"./chunk-Y4TDVDP2.mjs";import"./chunk-JJITOWZK.mjs";import"./chunk-YMDFF657.mjs";import"./chunk-UV74P4H2.mjs";import"./chunk-5K2I2DMP.mjs";import"./chunk-7WSLT5VX.mjs";import"./chunk-YT22LMF7.mjs";import"./chunk-G2JR3F63.mjs";import"./chunk-3CX7GPCR.mjs";import"./chunk-A65ADTCR.mjs";import"./chunk-NWOI25WY.mjs";import"./chunk-FQGHL7GR.mjs";import{h as Pe}from"./chunk-A7JJWOLT.mjs";import"./chunk-ZXFL2MSN.mjs";import"./chunk-VYOYXTCU.mjs";import"./chunk-C3LNYAVJ.mjs";import"./chunk-GJ6SZVHT.mjs";import"./chunk-52EXDVPN.mjs";import"./chunk-GMY5427L.mjs";import{a as Fe}from"./chunk-TW3N6W5Z.mjs";import"./chunk-3HEMJTAP.mjs";import"./chunk-BN33LVPQ.mjs";import{d as ve}from"./chunk-JKT5YAQ2.mjs";import"./chunk-QAPVKPEC.mjs";import{a as he}from"./chunk-BNKT3R3F.mjs";import{a as we,b as ke}from"./chunk-QROPNEGY.mjs";import{b as K,e as de}from"./chunk-BZ24IAP5.mjs";import{a as N}from"./chunk-SCKUIE3R.mjs";import"./chunk-6FARZYMJ.mjs";import"./chunk-EEFUE2ES.mjs";import{e as ce}from"./chunk-PE435FVH.mjs";import"./chunk-PWVDNN2C.mjs";import"./chunk-6VSZNZHH.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-WB2RIVO3.mjs";import{a as Re,c as Se}from"./chunk-MUEQRIK7.mjs";import"./chunk-ISSP2FZ5.mjs";import{h as ge,i as me}from"./chunk-XU25YA46.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-IVZJSDJD.mjs";import"./chunk-VZT4E2OJ.mjs";import"./chunk-BOGNK4LV.mjs";import{m as ye}from"./chunk-P55MKIZX.mjs";import"./chunk-PYRZFUVU.mjs";import{l as fe}from"./chunk-O2PUGRNW.mjs";import"./chunk-7SDZR6SR.mjs";import"./chunk-TEIBWMJM.mjs";import"./chunk-BWWQXU2B.mjs";import{d as le}from"./chunk-T63U4OZJ.mjs";import"./chunk-YAIIRFKJ.mjs";import"./chunk-Q3DY7TO2.mjs";import"./chunk-3XG25GTF.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-WSUKC2U3.mjs";import"./chunk-QIRO4HTE.mjs";import{h as pe,m as ue}from"./chunk-3SKLBRPL.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-JH27IKCO.mjs";import"./chunk-SAMWHL22.mjs";import"./chunk-6KP6WETK.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-J24TIGSI.mjs";import"./chunk-HKUWHVI7.mjs";import"./chunk-VPDEJGPS.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-LHU6CPGE.mjs";import"./chunk-PBE44M2Y.mjs";import"./chunk-ZUOPC4W2.mjs";import"./chunk-JQZTMFO7.mjs";import"./chunk-JFNLKHY6.mjs";import"./chunk-VZVICK7Q.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-7PY3VQP3.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-HFUDCNU5.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-XZISAZA6.mjs";import{a as oe,c as ae,f as T,h as $e}from"./chunk-LCDPCUXS.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-L4INJ5TZ.mjs";import"./chunk-KIMQQ6JQ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-PR74GYVI.mjs";import"./chunk-TMA34QMA.mjs";import"./chunk-TUACWKIH.mjs";import{Kc as te,te as ie,ve as re,xe as se}from"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";import{copyFileSync as fn,existsSync as Je,mkdtempSync as gn,readFileSync as Xe,rmSync as mn,rmdirSync as hn}from"node:fs";import{tmpdir as yn}from"node:os";import{join as j,resolve as wn}from"node:path";import{randomUUID as kn}from"node:crypto";import{mkdirSync as sn}from"node:fs";import{join as on}from"node:path";var an=/^\[(WARN|ERR)\]|^\[INFO\] (?:The run lock|the confirmation)/;function je(e,t){return t==="production"?`${e??"the org"} is taken for a production org, and a pipeline from the command line writes to none`:void 0}function J(e){let t=e.journalDir??he(),n=e.backupDir??Re(),s=Se(n);if(s!==void 0)throw new Error(s);sn(e.storeDir,{recursive:!0,mode:448});let i=new Fe,r,o=Ce({storeDir:e.storeDir,log:a=>{an.test(a.trim())&&e.log(a.trim())},waitMs:0,typeScratchOrgs:!0,...e.onPost?{onPost:e.onPost}:{},services:{getSandforgeSetting:e.setting,showNotification:e.notify,...e.askApproval?{askApproval:e.askApproval}:{}},compose:a=>{let d=u=>a.orgManager.getOrg(u)?.alias,c=new fe({orgNameOf:d,requestConfirmation:(u,y)=>{let w=je(void 0,y);return w===void 0?Promise.resolve(!0):(e.log(`refused: ${w} (${u})`),Promise.resolve(!1))},declinesWithoutAsking:u=>je(void 0,u)});a.handlers.setInfraServices({productionGuard:c,backgroundRegistry:i,piiDetector:new le,checkpointFiles:{sandforgeVersion:e.sandforgeVersion,pickExportFile:()=>Promise.reject(new Error("sandforge checkpoint export saves a checkpoint to a file.")),pickImportFile:()=>Promise.reject(new Error("sandforge checkpoint import reads a checkpoint file."))}}),a.handlers.setBackgroundRegistry(i),a.handlers.setBackupRecordStore(new me(ge(n))),a.handlers.setSyncRunCreations(pe(t)),a.handlers.setSeedRunCreations(ve(t)),r={configStore:a.configStore,orgRegistry:a.orgRegistry}}});if(r===void 0)throw new Error("The host composed no handlers.");return{host:o,configStore:r.configStore,orgRegistry:r.orgRegistry,backupDir:n,dispose:()=>i.dispose()}}function X(e){switch(te(e.orgType,e.metadata?.edition)){case"Sandbox":return"sandbox";case"Scratch":return"scratch";case"Developer":return"developer";default:return"production"}}function Me(e,t){return e.length>=15&&t.length>=15&&e.slice(0,15)===t.slice(0,15)}var Le=new Set(["scratch","developer"]),ze={sandbox:"a sandbox",scratch:"a scratch org",developer:"a Developer Edition org",production:"a production org"};function dn(e,t){return e!==t?`another org, of another kind: ${ze[t]} here, ${ze[e]} in the file`:e==="sandbox"?"a sandbox refreshed since is another org, holding production\u2019s data again":"another org than the one the pipeline was exported for"}function Ge(e,t,n,s,i,r=e){return Me(n.organizationId,s.organizationId)?{ok:!0}:i!==void 0&&Me(i,s.organizationId)?{ok:!0,note:`${t} answers as org ${s.organizationId}, not the ${n.organizationId} the file names: taken, as --accept-org ${r}=${i} says.`}:Le.has(n.kind)&&Le.has(s.kind)?{ok:!0,note:`${t} answers as org ${s.organizationId}, not the ${n.organizationId} the file names: a ${s.kind==="scratch"?"scratch org":"Developer Edition org"} is made again under its alias, and is not pinned to its Id.`}:{ok:!1,code:"ORG_MOVED",message:`${t} answers as org ${s.organizationId}, and the file names ${n.organizationId}: ${dn(n.kind,s.kind)}. Nothing was run.`,wayOut:`check that ${t} is the org the pipeline is for, then run again with --accept-org ${t}=${s.organizationId}; or export the pipeline again from the Automation page.`}}function Be(e,t,n,s){if(!n.staging)return{org:t};let i=X(t);if(i!=="sandbox")return{org:t,note:`${s} is marked Staging in the file, and is a ${i} org here: the mark is read of a sandbox alone, and not set.`};let r={...t,staging:!0};return e.updateOrgMetadata(r),{org:r}}function L(e){return JSON.parse(JSON.stringify(e))}function He(e,t){let n=L(e.pipeline),s=L(e.syncConfigs);for(let i of se(e)){let r=t(i.key);if(r!==void 0){if(i.stepId!==void 0){let o=n.steps.find(a=>a.id===i.stepId);o&&(o.config[i.field]=r)}else if(i.syncConfigId!==void 0){let o=s[i.syncConfigId];o&&(o[i.field]=r)}}}return{pipeline:{...n,variables:n.variables.map(i=>i.required&&i.defaultValue===void 0?{...i,required:!1}:i),version:1,triggers:[],createdAt:e.exportedAt,updatedAt:e.exportedAt},syncConfigs:Object.values(s)}}var pn="prebuilt-",un="tpl-";function Ve(e,t,n){let s=new Pe(e);for(let o of n.syncConfigs)s.save(o);let i=new Oe(e);for(let o of Object.values(t.seedTemplates))o.id.startsWith(pn)||i.save(L(o));let r=new ce(e);for(let o of Object.values(t.maskingTemplates))o.id.startsWith(un)||r.save(L(o))}var Ue="backup:";function Ke(e,t,n,s=()=>{}){let i=e.getKeysByPrefix(Ue).filter(o=>!n.has(o));if(i.length===0)return 0;let r=ye(on(t,"snapshots.json"));for(let o of i)r.set(o,cn(e.get(o),s),"backups");return i.length}function cn(e,t){if(typeof e!="object"||e===null||Array.isArray(e))return e;let n=e;if(typeof n.orgId!="string")return e;let s=t(n.orgId);return s===void 0?e:{...n,orgId:s,organizationId:typeof n.organizationId=="string"?n.organizationId:n.orgId}}function We(e){return new Set(e.getKeysByPrefix(Ue))}var vn=`sandforge pipeline \u2014 run an Automation pipeline exported from VS Code, without the editor.
8
+
9
+ Usage:
10
+ npx sandforge pipeline plan --file <file> [options]
11
+ npx sandforge pipeline run --file <file> [options]
12
+ npx sandforge pipeline confirm --file <file> [--org <key>=<alias>]\u2026 [--store <dir>]
13
+ npx sandforge pipeline history --file <file> [--json]
14
+
15
+ Commands:
16
+ plan connect each org, type it, and say what a run would do and refuse; writes nothing
17
+ run run the pipeline as the Automation page runs it; with --dry-run, the steps that
18
+ write say what they would do, and the steps that read run
19
+ confirm confirm its Rewind steps at the terminal, as the page's confirmation does: the
20
+ alias of each Rewind step's org is typed, and the confirmation kept in the store
21
+ history the runs of the pipeline the command line made on this machine, newest first
22
+
23
+ The file is the one the Automation page's Export\u2026 writes (<name>.sandforge-pipeline.json).
24
+
25
+ Options (plan, run):
26
+ --file <file> the pipeline file
27
+ --org <key>=<alias> the sf alias an org of the file is reached by here, by its key in
28
+ the file's "orgs"; repeat for more (default: the alias the file names)
29
+ --accept-org <alias>=<id> take the org an alias reaches for the file's though its Organization
30
+ Id differs \u2014 a sandbox refreshed since \u2014 once you checked it is the
31
+ one: the org by its alias, or by its key in the file's "orgs", and
32
+ the Id it answers with; repeat for more
33
+ --var <name>=<value> a variable of the pipeline; repeat for more
34
+ --var-env <name>=<VAR> a variable read from an environment variable: a secret, which the
35
+ file never holds; repeat for more
36
+ --approve <step> answer the Approval step of that name ahead, yes, for a run with no
37
+ one at a terminal; repeat for more. Never one that stands before a
38
+ write to a sandbox marked Staging: a person answers it at a terminal
39
+ --confirm-rewind <alias> confirm the Rewind steps of the org of that alias, as typing it on
40
+ the page does; repeat for more
41
+ --store <dir> where the run keeps its state between runs: the Sync watermarks a
42
+ delta Sync reads on from, the Rewind confirmations, the audit
43
+ (default: the pipeline's folder under the folder
44
+ SANDFORGE_JOURNAL_DIR names, ~/.sandforge by default). A CI job
45
+ caches it between its runs
46
+ --json the plan, or the run, as JSON on stdout; every other line on stderr
47
+ --help this text
48
+
49
+ Options (run):
50
+ --dry-run the steps that write say what they would do: a Sync simulates, an
51
+ Anonymize previews, a Rewind previews, a Checkpoint estimates, a
52
+ Seed meets its gates \u2014 the data storage and the API requests its
53
+ org has left \u2014 and says what it would seed; Compare and Pre-check
54
+ run, and the Conditions read what they found; no Delay waits, no
55
+ Approval is asked; nothing is kept in the history, the audit or
56
+ the store
57
+ --timeout <ms> the run's time budget, sandforge.pipeline.timeout, from 30000 to
58
+ 3600000 (default: the file's, or 300000); an Approval's wait, a
59
+ Delay and the steps that write have their own
60
+ --triggered-by <how> manual | schedule: what the history says started it (default: manual)
61
+ --fail-on-partial exit 3 when the run ended with warnings: a step past which it went on
62
+
63
+ Nothing is written to any org by plan, nor by run --dry-run. A run takes the pipeline's lock
64
+ on this machine, which a run in VS Code takes too: one run of a pipeline at a time. Each org
65
+ is named by its sf CLI alias: the Salesforce CLI (sf) must be installed and logged in to it.
66
+
67
+ Exit codes:
68
+ 0 the plan refuses nothing; the run completed (with warnings, unless --fail-on-partial)
69
+ 1 the run failed, or could not start
70
+ 2 a bad command line, a file that does not read, or a run refused before its first step,
71
+ every cause said with what lifts it: nothing ran
72
+ 3 --fail-on-partial, and the run completed with warnings
73
+ 129, 130, 143 a SIGHUP, a Ctrl-C or a SIGTERM stopped it: the step under way is stopped, and
74
+ the run ends cancelled
75
+ `,Q=["plan","run","confirm","history"],$n={plan:{words:1,switches:["--json"],values:["--file","--org","--accept-org","--var","--var-env","--approve","--confirm-rewind","--store"]},run:{words:1,switches:["--json","--dry-run","--fail-on-partial"],values:["--file","--org","--accept-org","--var","--var-env","--approve","--confirm-rewind","--store","--timeout","--triggered-by"]},confirm:{words:1,switches:[],values:["--file","--org","--accept-org","--store"]},history:{words:1,switches:["--json"],values:["--file"]}},E=2,z=ie["pipeline.timeout"],Pn=2147483647,ee=6e4,H=5*6e4,I=class extends Error{};function G(e,t){let n=t.indexOf("=");if(n<=0||n===t.length-1)throw new I(`${e} takes <key>=<value>, got "${t}". Nothing was run.`);return[t.slice(0,n),t.slice(n+1)]}function Rn(e,t=process.env){let n=e.slice(2),s=n[0];if(s===void 0||s.startsWith("-"))throw new I(`Name the command: ${Q.join(", ")}. Nothing was run.`);if(!Q.includes(s))throw new I(`"${s}" is not a command of sandforge pipeline: ${Q.join(", ")}. Nothing was run.`);let i=$n[s],r=oe(n,i);if(r!==void 0)throw new I(r);let o=v=>{let m=[];for(let p=1;p<n.length;p++)n[p]===v&&p+1<n.length?m.push(n[++p]):i.values.includes(n[p])&&p++;return m},a=v=>{let m=o(v);if(m.length>1)throw new I(`${v} is given ${m.length} times. Nothing was run.`);return m[0]},d=a("--file");if(d===void 0)throw new I("--file names the pipeline file. Nothing was run.");let c=new Map;for(let v of o("--org")){let[m,p]=G("--org",v);if(!ae.test(p))throw new I(`--org ${m}=${p}: "${p}" is not an sf alias. Nothing was run.`);if(c.has(m))throw new I(`--org names ${m} twice. Nothing was run.`);c.set(m,p)}let u=new Map;for(let v of o("--accept-org")){let[m,p]=G("--accept-org",v);if(!/^00D[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/.test(p))throw new I(`--accept-org ${m}=${p}: "${p}" is no Organization Id (00D\u2026). Nothing was run.`);u.set(m,p)}let y=new Map;for(let v of o("--var")){let[m,p]=G("--var",v);if(y.has(m))throw new I(`${m} is given twice. Nothing was run.`);y.set(m,{value:p})}for(let v of o("--var-env")){let[m,p]=G("--var-env",v);if(y.has(m))throw new I(`${m} is given twice. Nothing was run.`);let k=t[p];y.set(m,{env:p,...k!==void 0&&k!==""?{value:k}:{}})}let w,h=a("--timeout");if(h!==void 0&&(w=Number(h),!Number.isInteger(w)||w<(z.minimum??0)||w>(z.maximum??1/0)))throw new I(`--timeout takes milliseconds from ${z.minimum} to ${z.maximum}, got "${h}". Nothing was run.`);let $=a("--triggered-by")??"manual";if($!=="manual"&&$!=="schedule")throw new I(`--triggered-by takes manual or schedule, got "${$}". Nothing was run.`);let P=a("--store");return{verb:s,file:d,orgs:c,accepted:u,vars:y,approve:o("--approve"),confirmRewind:o("--confirm-rewind"),...P!==void 0?{store:wn(P)}:{},json:n.includes("--json"),dryRun:n.includes("--dry-run"),...w!==void 0?{timeoutMs:w}:{},triggeredBy:$,failOnPartial:n.includes("--fail-on-partial")}}function Ye(){try{let e=JSON.parse(Xe(j(__dirname,"..","package.json"),"utf8"));return typeof e.version=="string"?e.version:"0.0.0"}catch{return"0.0.0"}}function Sn(e,t,n){return e.code==="PIPELINE_FILE_NEWER"&&e.exporterVersion!==void 0?[{code:e.code,message:e.message,wayOut:`npx -y sandforge@${e.exporterVersion} pipeline ${t} --file ${n}`}]:e.issues.length===0?[{code:e.code,message:e.message}]:[{code:e.code,message:e.message},...e.issues.map(s=>({code:e.code,message:`${s.path}: ${s.message}`}))]}function Qe(e,t){let n=[],s=[];for(let i of t.keys())Object.prototype.hasOwnProperty.call(e.orgs,i)||s.push({code:"ORG_UNKNOWN_KEY",org:i,message:`--org names "${i}", and the file has no org of that key.`,wayOut:`name one of ${Object.keys(e.orgs).join(", ")||"none"}.`});for(let[i,r]of Object.entries(e.orgs)){let o=t.get(i)??r.alias;if(o===void 0){s.push({code:"ORG_NO_ALIAS",org:i,message:`The org "${r.name??i}" (${r.organizationId}) has no alias in the file.`,wayOut:`give the sf alias it is reached by here: --org ${i}=<alias> (sf alias set <alias>=<username> names one).`});continue}n.push({key:i,alias:o,file:r})}return{orgs:n,refusals:s}}function On(e,t){let n={},s=[],i=new Map(e.pipeline.variables.map(r=>[r.name,r]));for(let[r,o]of t)i.has(r)?o.value!==void 0?n[r]=o.value:o.env!==void 0&&s.push({code:"VARIABLE_MISSING",message:`Variable "${r}" is to be read from ${o.env}, which is not set, or empty.`,wayOut:`set ${o.env} in the environment the run starts in.`}):s.push({code:"VARIABLE_UNKNOWN",message:`The pipeline declares no variable "${r}".`,wayOut:`name one of ${[...i.keys()].join(", ")||"none"}, or leave it out.`});for(let r of e.pipeline.variables)Object.prototype.hasOwnProperty.call(n,r.name)||t.has(r.name)||(r.defaultValue!==void 0?n[r.name]=r.defaultValue:r.required&&s.push({code:"VARIABLE_MISSING",message:`Variable "${r.name}" is required, and the file gives it no value${r.type==="secret"?": a secret never travels in it":""}.`,wayOut:r.type==="secret"?`--var-env ${r.name}=<environment variable that holds it>`:`--var ${r.name}=<value>, or --var-env ${r.name}=<environment variable>`}));return{values:n,refusals:s}}function In(e,t){return e.pipeline.steps.filter(n=>n.type===t).map(n=>n.name)}function Tn(e,t,n){let s=[],i=In(e,"approval");for(let o of t.approve)i.includes(o)||s.push({code:"APPROVE_UNKNOWN_STEP",message:`--approve "${o}" names no Approval step of the pipeline.`,wayOut:i.length>0?`name one of ${i.map(a=>`"${a}"`).join(", ")}.`:"leave it out: the pipeline has no Approval step."});let r=new Set(e.pipeline.steps.filter(o=>o.type==="rewind").map(o=>n.find(a=>a.key===o.config.orgId)?.alias).filter(o=>o!==void 0));for(let o of t.confirmRewind)r.has(o)||s.push({code:"CONFIRM_UNKNOWN_ORG",message:`--confirm-rewind ${o} names no org a Rewind step of the pipeline rewinds.`,wayOut:r.size>0?`name ${[...r].join(", ")}.`:"leave it out: the pipeline has no Rewind step."});return s}function bn(e,t){let n=e.pipeline.steps.find(s=>s.id===t);if(!n)return[];if(n.type==="sync"){let s=e.syncConfigs[String(n.config.configId??"")]?.targetOrgId;return typeof s=="string"?[s]:[]}if(["seed","anonymize","rewind","restore","delete"].includes(n.type)){let s=n.config.orgId;return typeof s=="string"?[s]:[]}return[]}function En(e,t,n,s){let i=[],r=new Set,o=d=>n.find(c=>c.key===d)?.kind,a=d=>n.find(c=>c.key===d)?.alias??d;for(let d of t.steps){let c=bn(e,d.stepId).find(y=>o(y)==="production");if(c!==void 0){let y=`Step "${d.name}" writes to ${a(c)}, a production org: a pipeline from the command line never writes to a production org, whatever an Approval answers.`;i.push({code:"PRODUCTION_TARGET",step:d.name,org:c,message:y,wayOut:`point the step at a sandbox, a scratch org or a Developer Edition org, and export again; or map ${c} to one with --org.`}),r.add(d.refusal??y);continue}let u=Nn(e,d,n,s.confirmLine);if(u!==void 0){i.push(u),r.add(d.refusal??u.message);continue}if(d.fate==="refused"&&d.refusal!==void 0){i.push({code:"STEP_REFUSED",step:d.name,message:d.refusal}),r.add(d.refusal);continue}d.type==="approval"&&i.push(...An(d,s))}for(let d of t.problems)r.has(d)||[...r].some(c=>d.includes(c))||i.push({code:"PIPELINE_REFUSED",message:d});return i}function Nn(e,t,n,s=`${N("pipeline")} confirm --file <file>`){if(t.type!=="rewind"||t.fate!=="refused"||t.refusal===void 0)return;let i=t.refusal===W(t.name,"changed");if(!i&&t.refusal!==W(t.name,"never"))return;let r=e.pipeline.steps.find(a=>a.id===t.stepId)?.config.orgId,o=n.find(a=>a.key===r)?.alias??"<alias>";return{code:"REWIND_NOT_CONFIRMED",step:t.name,message:`Rewind step "${t.name}" has `+(i?"not been confirmed since it was changed":"never been confirmed on this machine")+`: it rewinds ${o} only once ${o}'s alias is confirmed for it.`,wayOut:`run it with --confirm-rewind ${o}; or confirm it once, at a terminal, with ${s}, typing ${o}: the runs of that store then rewind it without the flag.`}}function xn(e){let t=[...e.orgs].map(([s,i])=>` --org ${s}=${i}`).join(""),n=[...e.accepted].map(([s,i])=>` --accept-org ${s}=${i}`).join("");return`${N("pipeline")} confirm --file ${e.file}${t}${n}`+(e.store!==void 0?` --store ${e.store}`:"")}function An(e,t){let n=`Approval step "${e.name}"`,s=t.approve.includes(e.name);return e.notes.includes("STAGING_NEEDS_PERSON")?s?[{code:"STAGING_NEEDS_PERSON",step:e.name,message:`${n} stands before a write to a sandbox marked Staging: only a person at a terminal answers it, never --approve.`,wayOut:`leave --approve "${e.name}" out and run it in a terminal; or take the Staging mark off the sandbox on the Organizations page, and export again.`}]:t.isTTY?[]:[{code:"STAGING_NEEDS_PERSON",step:e.name,message:`${n} stands before a write to a sandbox marked Staging, and this run has no terminal: only a person at a terminal answers it.`,wayOut:"run it in a terminal; or take the Staging mark off the sandbox on the Organizations page, and export again."}]:!s&&!t.isTTY?[{code:"APPROVAL_NO_TERMINAL",step:e.name,message:`${n} has no one to ask: this run has no terminal.`,wayOut:`run it in a terminal, or add --approve "${e.name}".`}]:[]}function Ze(e,t){return(n,s)=>{if(n==="pipeline.timeout"&&t!==void 0)return t;let i=e.settings;if(Object.prototype.hasOwnProperty.call(i,n))return i[n];let r=_e;return Object.prototype.hasOwnProperty.call(r,n)?r[n]:s}}function _n(e,t,n,s){let i=e.output??{};if(i.dryRun===!0)return;let r=a=>typeof a=="string"&&a!==""?a:void 0,o=r(i.orgId)!==void 0?t(String(i.orgId)):void 0;switch(e.stepType){case"seed":{let a=r(i.runId);return a===void 0||o===void 0||Number(i.totalRecordsCreated??0)===0?void 0:`${N("seed")} --remove ${a} --target ${o}`}case"sync":{let a=r(i.operationId),d=s(String(i.configId??""));return a===void 0||d===void 0||Number(i.totalSuccess??0)===0?void 0:`${N("sync")} --remove ${ue(a)} --target ${d} --store ${n}`}case"anonymize":{let a=i.snapshot??{},d=r(a.operationId);return d===void 0||o===void 0?void 0:`${N("dataops")} anonymize --org ${o} --restore ${d}`}case"rewind":{let a=r(i.checkpointId);return a===void 0||o===void 0||i.undoUntil===void 0?void 0:`${N("checkpoint")} undo --org ${o} --checkpoint ${a}`}case"checkpoint":{let a=r(i.checkpointId);return a===void 0||o===void 0?void 0:`${N("checkpoint")} delete --org ${o} --checkpoint ${a}`}default:return}}function Cn(e,t,n,s){let i=e.map(a=>_n(a,t,n,s)),r=a=>{let d=a.output?.orgId;return typeof d=="string"?t(d):void 0},o=(a,d)=>{let c=a.output?.objects;return new Set((Array.isArray(c)?c:[]).filter(u=>Number(u[d]??0)>0).map(u=>String(u.objectApiName)))};return i.map((a,d)=>{let c=e[d];if(a===void 0||c===void 0)return a;let u,y;if(c.stepType==="seed")u=r(c),y=o(c,"recordsCreated");else if(c.stepType==="sync")u=s(String(c.output?.configId??"")),y=o(c,"success");else return a;return e.some((h,$)=>$<=d||i[$]===void 0||r(h)!==u?!1:h.stepType==="rewind"?Number(h.output?.deleted??0)>0:h.stepType!=="anonymize"?!1:[...o(h,"processed")].some(P=>y.has(P)))?`${a} --include-changed`:a})}function Fn(e,t){return e.flatMap(n=>{if(n.stepType!=="anonymize"||n.output?.dryRun===!0)return[];let s=n.output?.snapshot??{},i=n.output?.orgId,r=typeof i=="string"?t(i):void 0;return typeof s.operationId!="string"||r===void 0?[]:[`The snapshot of "${n.stepName}" keeps the values it masked in clear on this machine: once they are back, or no longer wanted, ${N("backup")} --delete ${s.operationId} --org ${r} deletes it.`]})}function Dn(e,t,n){switch(e.status){case"completed":return 0;case"completed_with_warnings":return t?3:0;case"cancelled":return n!==void 0?K(n):1;default:return 1}}function jn(e,t=e.triggeredBy){return{runId:e.id,pipelineId:e.pipelineId,pipelineName:e.pipelineName,status:e.status,triggeredBy:t,startTime:e.startTime,duration:e.duration??0,stepCount:e.stepResults.filter(n=>n.status!=="skipped").length,errorCount:e.stepResults.filter(n=>n.status==="failed").length,steps:e.stepResults.map(n=>({stepName:n.stepName,stepType:n.stepType,status:n.status,...n.duration!==void 0?{duration:n.duration}:{},...n.summary!==void 0?{summary:n.summary}:{},...n.error!==void 0?{error:n.error}:{},...n.approval!==void 0?{approval:n.approval}:{}})),ranFrom:"commandLine"}}function Mn(e,t){return j(Y(e,t),"store")}function A(e){return e.message?.payload??{}}function F(e,t){if(e.outcome==="unanswered")return`${t} was not answered in time.`;let n=A(e);return`${t} failed: ${String(n.message??n.error??e.outcome)}`}var Ln=new Set(["ORG_NO_ALIAS","ORG_UNKNOWN_KEY","ORG_NOT_CONNECTED"]);async function en(e,t,n,s,i){let{host:r,orgRegistry:o,configStore:a}=e,d=[...i.refusals],c=[...i.notes],u=[];for(let p of i.orgs){let k;try{k=await r.connect(p.alias)}catch(g){d.push({code:"ORG_NOT_CONNECTED",org:p.key,message:`${p.alias} could not be reached: ${g instanceof Error?g.message:String(g)}`,wayOut:`"sf org display --target-org ${p.alias}" says what sf holds for it; sign in to it under that alias.`}),u.push(p);continue}let R=X(k),O=[p.key,p.alias].find(g=>n.accepted.has(g)),S=Ge(p.key,p.alias,p.file,{organizationId:k.orgId??k.id,kind:R},O!==void 0?n.accepted.get(O):void 0,O);S.ok?S.note!==void 0&&c.push(S.note):d.push({code:S.code,org:p.key,message:S.message,wayOut:S.wayOut});let D=Be(o,k,p.file,p.alias);D.note!==void 0&&c.push(D.note),u.push({...p,org:D.org,kind:R})}if(d.some(p=>Ln.has(p.code)))return c.push("The steps are checked once every org of the file is reached."),{file:t,digestMatches:!0,orgs:u,values:i.values,refusals:d,notes:c};let w=He(t,p=>u.find(k=>k.key===p)?.org?.id);Ve(a,t,w);let h=await r.request({type:"pipeline:save",payload:{id:w.pipeline.id,config:w.pipeline},timeoutMs:ee});if(h.outcome!=="answered")return d.push({code:"PIPELINE_REFUSED",message:F(h,"Saving the pipeline in the store")}),{file:t,digestMatches:!0,orgs:u,values:i.values,refusals:d,notes:c};for(let p of n.confirmRewind)for(let k of t.pipeline.steps){if(k.type!=="rewind"||u.find(S=>S.key===k.config.orgId)?.alias!==p)continue;let R=await r.request({type:"pipeline:rewind-grant",payload:{pipelineId:w.pipeline.id,stepId:k.id,typed:p},timeoutMs:H}),O=A(R);(R.outcome!=="answered"||O.granted!==!0)&&d.push({code:"REWIND_NOT_CONFIRMED",step:k.name,message:R.outcome!=="answered"?F(R,`The confirmation of Rewind step "${k.name}"`):`Rewind step "${k.name}" was not confirmed for ${p}: ${String(O.code??"refused")}${O.why?` (${String(O.why)})`:""}.`,wayOut:"take the checkpoint it names on this machine, or import it (sandforge checkpoint import)."})}let $=await r.request({type:"pipeline:export",payload:{pipelineId:w.pipeline.id},timeoutMs:H}),P=A($);if($.outcome!=="answered"||P.exported!==!0)return d.push({code:"PIPELINE_REFUSED",message:$.outcome!=="answered"?F($,"The check of the pipeline"):`The check of the pipeline did not run: ${P.exported===!1?P.message:""}`}),{file:t,digestMatches:!0,orgs:u,values:i.values,refusals:d,notes:c};let v=En(t,P,u,{approve:n.approve,isTTY:s.isTTY,confirmLine:xn(n)});d.push(...v);let m={...P,steps:P.steps.map(p=>{let k=v.find(R=>R.code==="REWIND_NOT_CONFIRMED"&&R.step===p.name);return k!==void 0?{...p,refusal:k.message}:p})};return{file:t,digestMatches:!0,orgs:u,values:i.values,check:m,refusals:d,notes:c}}function zn(e){let{file:t}=e,n=[`Pipeline "${t.pipeline.name}" (${t.pipeline.steps.length} ${t.pipeline.steps.length===1?"step":"steps"}), exported from ${t.exportedBy} on ${t.exportedAt.slice(0,10)}.`];e.digestMatches||n.push(" The file was edited since it was exported: its digest no longer matches what it holds.");let s=new Map((e.check?.orgs??[]).map(r=>[r.alias??"",r])),i=e.orgs.map(r=>{let o=r.kind??r.file.kind,a={sandbox:"sandbox",scratch:"scratch org",developer:"Developer Edition org",production:"production org"}[o],d=r.org?.orgId??r.file.organizationId,c=s.get(r.alias),u=c===void 0?"":c.writtenBy.length>0?` (written: ${c.writtenBy.join(", ")})`:" (read)";return`${r.alias} ${a}${r.org?.staging===!0?" marked Staging":""} ${d}${u}`});i.length>0&&n.push(`Orgs: ${i.join("; ")}`);for(let[r,o]of(e.check?.steps??[]).entries()){let a=o.fate==="refused"?"refused":o.fate==="asks"?"asks":"runs";n.push(` ${r+1} ${o.type} "${o.name}": ${a}`)}for(let r of e.notes)n.push(` ${r}`);if(e.refusals.length>0){n.push(`Refused before the first step, nothing run (exit ${E}):`);for(let r of e.refusals)n.push(` - ${r.message}${r.wayOut?` ${Z(r.wayOut)}`:""}`)}return n}function Z(e){return e.charAt(0).toUpperCase()+e.slice(1)}function qe(e){return e.map(t=>({key:t.key,alias:t.alias,organizationId:t.org?.orgId??t.file.organizationId,kind:t.kind??t.file.kind,staging:t.org?.staging===!0}))}function Gn(e){let t=gn(j(yn(),"sandforge-pipeline-plan-")),n=j(e,"configStore.json");return Je(n)&&fn(n,j(t,"configStore.json")),t}function Bn(e,t,n,s){return async i=>e.includes(i.stepName)?{decision:"approve",via:"commandLine"}:t?{decision:await we(`Approval step "${i.stepName}"${i.pipelineName?` of pipeline "${i.pipelineName}"`:""}${i.message?`: ${i.message}`:""} \u2014 approve? (it waits until ${i.expiresAt})`,n,s)?"approve":"reject",via:"terminal"}:void 0}function Hn(e){let t;try{t=Xe(e,"utf8")}catch(n){return{ok:!1,refusal:{code:"PIPELINE_FILE_NOT_JSON",message:`${e} could not be read: ${n instanceof Error?n.message:String(n)}`,issues:[]}}}return re(t)}async function Vn(e=process.argv,t={}){let n=t.env??process.env;if(e.slice(2).includes("--help")||e.slice(2).includes("-h")){process.stdout.write(vn);return}let s;try{s=Rn(e,n)}catch(u){if(!(u instanceof I))throw u;process.stderr.write(`${u.message} Run with --help.
76
+ `),T(E);return}let i={line:u=>process[s.json?"stderr":"stdout"].write(`${u}
77
+ `),json:u=>{s.json&&process.stdout.write(`${JSON.stringify(u,null,2)}
78
+ `)}},r=t.pipelinesRoot??Ie(n),o=Hn(s.file);if(!o.ok){let u=Sn(o.refusal,s.verb,s.file);for(let y of u)process.stderr.write(`${y.message}${y.wayOut?` Run it with: ${y.wayOut}`:""}
79
+ `);i.json({tool:"sandforge-pipeline",refusals:u,exit:E}),T(E);return}let{file:a}=o;if(s.verb==="history"){Yn(a,r,i);return}let d=t.isTTY??process.stdin.isTTY===!0,c=s.store??Mn(r,a.pipeline.id);if(s.verb==="confirm"){await qn(a,s,c,{...t,isTTY:d,version:t.version??Ye()},i);return}await Un(a,o.digestMatches,s,c,r,{isTTY:d,terminal:t.terminal,version:t.version??Ye()},i)}async function Un(e,t,n,s,i,r,o){let a=n.verb==="run",d=Qe(e,n.orgs),c=On(e,n.vars),u=Tn(e,n,d.orgs),y={orgs:d.orgs,values:c.values,refusals:[...d.refusals,...c.refusals,...u],notes:[]},w,h=Y(i,e.pipeline.id),$=Je(h);if(a){let g=Te(i,e.pipeline.id,{pipelineName:e.pipeline.name,ranFrom:"commandLine",triggeredBy:n.triggeredBy,...n.dryRun?{dryRun:!0}:{}});if("busy"in g){let x={code:"PIPELINE_RUNNING",message:q(g.busy,e.pipeline.name)};process.stderr.write(`${x.message}
80
+ `),o.json({tool:"sandforge-pipeline",refusals:[x],exit:E}),T(E);return}w=g.lock,g.tookOver&&y.notes.push(Ee(g.tookOver))}else{let g=be(i,e.pipeline.id);g!==void 0&&y.notes.push(q(g,e.pipeline.name))}let P=new AbortController,v,m,p,k=de(g=>{v=g,P.abort(),o.line(`Stopping (${g}): the step under way is stopped, and the run ends cancelled.`),m!==void 0&&p!==void 0&&p.host.request({type:"execution:abort",payload:{operationId:m},timeoutMs:ee})}),R=a&&!n.dryRun?s:Gn(s),O=[],S=new Set,D=new Map(e.pipeline.steps.map((g,x)=>[g.id,x]));try{try{p=J({storeDir:R,log:l=>o.line(` ${l}`),setting:Ze(e,n.timeoutMs),notify:l=>o.line(` notification: ${l}`),sandforgeVersion:r.version,askApproval:Bn(n.approve,r.isTTY,r.terminal,P.signal),onPost:l=>{if(l.type!=="pipeline:step")return;let f=l.payload??{};f.status!=="running"&&f.stepId!==void 0&&S.add(f.stepId),Wn(l,e,D,o)}})}catch(l){process.stderr.write(`${l instanceof Error?l.message:String(l)}
81
+ `),T(1);return}let g=await en(p,e,n,r,y);if(g.digestMatches=t,v!==void 0){T(K(v));return}for(let l of zn(g))o.line(l);let x={id:e.pipeline.id,name:e.pipeline.name,file:n.file,digest:e.digest,digestMatches:t};if(g.refusals.length>0||!a){let l=g.refusals.length>0?E:0;o.json({tool:"sandforge-pipeline",pipeline:x,plan:!a,...a?{dryRun:n.dryRun}:{},orgs:qe(g.orgs),steps:(g.check?.steps??[]).map(f=>({name:f.name,type:f.type,fate:f.fate,...f.refusal!==void 0?{refusal:f.refusal}:{}})),refusals:g.refusals,notes:g.notes,exit:l}),T(l);return}w?.release(),w=void 0;let nn=We(p.configStore);m=`cli-${kn()}`,o.line(n.dryRun?"Dry run: the steps that write say what they would do.":"Run:");let M=await p.host.request({id:m,type:"pipeline:execute",responseType:"pipeline:run:response",payload:{pipeline:{...p.configStore.get(`pipeline:saved:${e.pipeline.id}`)??{}},variables:g.values,...n.dryRun?{dryRun:!0}:{}},timeoutMs:Pn});if(M.outcome!=="answered"){let l=A(M),f=l.code==="PIPELINE_RUNNING",_=F(M,"The run");process.stderr.write(`${_}
82
+ `),o.json({tool:"sandforge-pipeline",pipeline:x,dryRun:n.dryRun,refusals:[{code:String(l.code??"RUN_FAILED"),message:_}],exit:f?E:1}),T(f?E:1);return}let b=A(M),V=l=>g.orgs.find(f=>f.org?.id===l)?.alias,tn=l=>{let f=e.syncConfigs[l]?.targetOrgId;return g.orgs.find(_=>_.key===f)?.alias},rn=Cn(b.stepResults,V,s,tn);for(let[l,f]of b.stepResults.entries()){let _=rn[l];O.push({name:f.stepName,type:f.stepType,status:f.status,...f.summary!==void 0?{summary:f.summary}:{},...f.error!==void 0?{error:f.error}:{},...f.output!==void 0?{output:f.output}:{},..._!==void 0?{takeBack:_}:{}})}let U=Dn(b,n.failOnPartial,v);o.line(`${n.dryRun?"Dry run":"Run"} ${b.status}${b.error?`: ${b.error}`:""} (exit ${U}).`);for(let[l,f]of O.entries())S.has(b.stepResults[l]?.stepId??"")||o.line(` ${f.type} "${f.name}": ${f.status}${f.summary?` \u2014 ${f.summary}`:""}${f.error?` \u2014 ${f.error}`:""}`);let ne=O.filter(l=>l.takeBack!==void 0).reverse();if(ne.length>0){o.line("To take this run back, in this order:");for(let l of ne)o.line(` ${l.takeBack}`)}if(!n.dryRun){let l=Ke(p.configStore,p.backupDir,nn,V);l>0&&o.line(` ${l} snapshot${l===1?"":"s"} listed in ${p.backupDir}, where sandforge dataops restores from.`);for(let f of Fn(b.stepResults,V))o.line(` ${f}`);try{Ae(i,e.pipeline.id,jn(b,n.triggeredBy))}catch(f){o.line(` warning: the run was not kept in the history: ${f instanceof Error?f.message:String(f)}`)}}o.json({tool:"sandforge-pipeline",pipeline:x,dryRun:n.dryRun,status:b.status,startedAt:b.startTime,endedAt:b.endTime,triggeredBy:n.triggeredBy,orgs:qe(g.orgs),steps:O,approvals:b.stepResults.filter(l=>l.approval!==void 0).map(l=>({step:l.stepName,...l.approval})),notes:g.notes,exit:U}),T(U)}finally{k(),w?.release(),p?.dispose(),R!==s&&mn(R,{recursive:!0,force:!0}),n.dryRun&&!$&&Kn(h)}}function Kn(e){try{hn(e)}catch{}}function Wn(e,t,n,s){let i=e.payload??{},r=n.get(i.stepId??"");if(r===void 0)return;let o=t.pipeline.steps[r];if(o===void 0)return;let a=` ${r+1} ${o.type} "${o.name}"`;if(i.status==="running"){s.line(i.approval?`${a}: waits for its answer until ${i.approval.expiresAt??"?"}`:`${a}: running`);return}s.line(`${a}: ${i.status??"?"}${i.summary?` \u2014 ${i.summary}`:""}${i.error?` \u2014 ${i.error}`:""}`)}function Yn(e,t,n){let s=[],i=xe(t,r=>s.push(r)).read().filter(r=>r.pipelineId===e.pipeline.id);for(let r of s)process.stderr.write(`${r}
83
+ `);n.line(`Pipeline "${e.pipeline.name}": ${i.length} ${i.length===1?"run":"runs"} from the command line on this machine (${Ne(t,e.pipeline.id)}).`);for(let r of i)n.line(` ${r.startTime} ${r.status} ${r.triggeredBy} ${r.stepCount} ${r.stepCount===1?"step":"steps"}${r.errorCount>0?`, ${r.errorCount} failed`:""}`);n.json({tool:"sandforge-pipeline",pipeline:{id:e.pipeline.id,name:e.pipeline.name},runs:i})}async function qn(e,t,n,s,i){let r=e.pipeline.steps.filter(d=>d.type==="rewind");if(r.length===0){i.line(`Pipeline "${e.pipeline.name}" has no Rewind step: nothing to confirm.`);return}if(!s.isTTY){process.stderr.write(`confirm asks for each Rewind step's alias to be typed at a terminal: there is none. Give --confirm-rewind <alias> to run instead. Nothing was confirmed.
84
+ `),T(E);return}let o=Qe(e,t.orgs);if(o.refusals.length>0){for(let d of o.refusals)process.stderr.write(`${d.message} ${Z(d.wayOut??"")}
85
+ `);T(E);return}let a;try{a=J({storeDir:n,log:d=>i.line(` ${d}`),setting:Ze(e,void 0),notify:()=>{},sandforgeVersion:s.version})}catch(d){process.stderr.write(`${d instanceof Error?d.message:String(d)}
86
+ `),T(1);return}try{let d=new Set(r.map(h=>String(h.config.orgId??""))),c={orgs:o.orgs.filter(h=>d.has(h.key)),values:{},refusals:[],notes:[]},u=await en(a,e,{...t,approve:[],confirmRewind:[]},{isTTY:!0},c),y=u.refusals.filter(h=>["ORG_NOT_CONNECTED","ORG_MOVED"].includes(h.code));if(y.length>0){for(let h of y)process.stderr.write(`${h.message} ${Z(h.wayOut??"")}
87
+ `);T(E);return}let w=0;for(let h of r){let $=u.orgs.find(S=>S.key===h.config.orgId);if($?.org===void 0)continue;let P=String(h.config.checkpointId??"");i.line(`Rewind step "${h.name}" rewinds ${$.alias} to checkpoint ${P}.`);let v=await a.host.request({type:"checkpoint:preview",payload:{checkpointId:P},timeoutMs:H});if(v.outcome!=="answered"){i.line(` ${F(v,"Its preview")} It is not confirmed.`),w+=1;continue}let m=await a.host.request({type:"checkpoint:list",timeoutMs:ee}),p=(A(m).checkpoints??[]).find(S=>S.checkpointId===P)?.checkpoint;for(let S of De($.alias,{name:p?.name??P,takenAt:p?.takenAt??""},A(v),$.org.username))i.line(` ${S}`);let k=await ke(`Type ${$.alias} to confirm this step's rewind:`,s.terminal);if(k!==$.alias){i.line(" Not confirmed: what was typed is not the alias."),w+=1;continue}let R=await a.host.request({type:"pipeline:rewind-grant",payload:{pipelineId:e.pipeline.id,stepId:h.id,typed:k},timeoutMs:H}),O=A(R);R.outcome==="answered"&&O.granted===!0?i.line(` Confirmed, kept in ${n}: the runs of this store rewind it without --confirm-rewind.`):(i.line(` Not confirmed: ${R.outcome==="answered"?String(O.code):F(R,"The confirmation")}.`),w+=1)}T(w>0?1:0)}finally{a.dispose()}}process.argv[1]?.includes("sandforge-pipeline")&&($e(),Vn().then(()=>process.exit(process.exitCode??0)).catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
88
+ `),process.exit(1)}));export{E as REFUSED_EXIT,Qe as aliasesOf,En as checkRefusals,xn as confirmLineOf,Mn as defaultStoreOf,Sn as fileRefusals,jn as historyEntryOf,Vn as main,Fn as maskedSnapshotLines,Tn as namedStepRefusals,Rn as parseArgs,zn as planLines,Dn as runExit,Ze as settingOf,_n as takeBackOf,Cn as takeBacksOf,Nn as unconfirmedRewind,On as variablesOf};
@@ -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,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-N652NMZ4.mjs";import"./chunk-SOGQW4IG.mjs";import"./chunk-W622GUAW.mjs";import"./chunk-WA7EYLAQ.mjs";import"./chunk-LKQ5RKIV.mjs";import"./chunk-XAMBCQPU.mjs";import"./chunk-IG2MTQRP.mjs";import"./chunk-WR4Q363I.mjs";import"./chunk-CHYDMRSV.mjs";import"./chunk-F6GUDTOB.mjs";import"./chunk-BXU6WFMH.mjs";import"./chunk-2GTBABKU.mjs";import"./chunk-P33PSCXK.mjs";import"./chunk-UCD54V2M.mjs";import"./chunk-BV6VTP3J.mjs";import"./chunk-OLSGVAIL.mjs";import"./chunk-INIQ23K6.mjs";import"./chunk-ELFXJHU7.mjs";import"./chunk-W7U5E5ZL.mjs";import"./chunk-EFR2Y7E4.mjs";import"./chunk-O2HDYYUV.mjs";import"./chunk-M3ROUWDX.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-ZM6OJGIG.mjs";import"./chunk-MHMH6MTP.mjs";import"./chunk-COFG7Q6R.mjs";import"./chunk-GMY5427L.mjs";import"./chunk-PJ5I73CK.mjs";import"./chunk-BKDV4ENO.mjs";import"./chunk-X5JYBPXP.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-VS7ZXUII.mjs";import"./chunk-SOU4FRYN.mjs";import"./chunk-E5AHXLS6.mjs";import"./chunk-OO6CLPEH.mjs";import"./chunk-YS4G22C2.mjs";import"./chunk-QROPNEGY.mjs";import"./chunk-BZ24IAP5.mjs";import"./chunk-SCKUIE3R.mjs";import"./chunk-AV5SWEHP.mjs";import"./chunk-I7O6C2B5.mjs";import"./chunk-2CNCDM56.mjs";import"./chunk-SIHORWVK.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-4VS2V6WU.mjs";import"./chunk-KYEDBS54.mjs";import"./chunk-6XYKJSGX.mjs";import"./chunk-K2FBZIXY.mjs";import"./chunk-F43REJDZ.mjs";import"./chunk-JPUR2CFX.mjs";import"./chunk-LPBMBW3O.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-IFETCRWE.mjs";import"./chunk-PZPJKATS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-DYFALGRT.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-7FFGJWHN.mjs";import"./chunk-G35N4P7D.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-KDGMAGQR.mjs";import"./chunk-MFG4MUIO.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-HS4YRX4J.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-MTMH6H2A.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-NTOVCTRS.mjs";export{a as ENV_RUN_ID_RE,G as PREVIEW_UNREAD,l as accountKindOfRecordTypes,v as apiRequestsJson,p as describeDistribution,u as dryRunGatesJson,x as fitJson,c as fitOfArgs,y as main,d as parseArgs,C as parseRemoveArgs,m as personAccountLine,k as personRecordTypeNames,i as prebuiltTemplate,D as readRunSummary,f as readTemplateFile,o as recordTypeChoiceLine,n as recordTypeRule,A as refusalLines,H as removalPreviewJson,I as removalPreviewLines,F as removeMain,j as rulesFromDescribe,g as runIdRefusal,E as runOfSummary,z as scenarioKeptLines,t as seedAutomationCheck,w as seedFitLines,B as seedInterruptedLine,q as seedOrchestrator,r as seedWritePathOf,b as seededRandom,s as storageLine,e as templateDisplayName,h as templateRecordTypesRefusal};
7
+ import{A,B,C,D,E,F,G,H,I,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-32EUNQT6.mjs";import"./chunk-T7WREYA5.mjs";import"./chunk-H4JUYUSL.mjs";import"./chunk-C2N2TNEU.mjs";import"./chunk-YAJQS3OL.mjs";import"./chunk-Z42PHCVZ.mjs";import"./chunk-DT3T7FRD.mjs";import"./chunk-ZUBBEP75.mjs";import"./chunk-XO5FBOQF.mjs";import"./chunk-KP5G6FUC.mjs";import"./chunk-7EYQYZJP.mjs";import"./chunk-H4OBZIX3.mjs";import"./chunk-V3R45ZWT.mjs";import"./chunk-XSKPYGMT.mjs";import"./chunk-6GQUZ4IP.mjs";import"./chunk-LAUOSXMN.mjs";import"./chunk-INIQ23K6.mjs";import"./chunk-2UU42PTD.mjs";import"./chunk-2JZGCCPG.mjs";import"./chunk-3CX7GPCR.mjs";import"./chunk-A65ADTCR.mjs";import"./chunk-NWOI25WY.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-A7JJWOLT.mjs";import"./chunk-ZXFL2MSN.mjs";import"./chunk-VYOYXTCU.mjs";import"./chunk-C3LNYAVJ.mjs";import"./chunk-GJ6SZVHT.mjs";import"./chunk-52EXDVPN.mjs";import"./chunk-GMY5427L.mjs";import"./chunk-3HEMJTAP.mjs";import"./chunk-BN33LVPQ.mjs";import"./chunk-JKT5YAQ2.mjs";import"./chunk-QAPVKPEC.mjs";import"./chunk-BNKT3R3F.mjs";import"./chunk-QROPNEGY.mjs";import"./chunk-BZ24IAP5.mjs";import"./chunk-SCKUIE3R.mjs";import"./chunk-6FARZYMJ.mjs";import"./chunk-MUEQRIK7.mjs";import"./chunk-ISSP2FZ5.mjs";import"./chunk-XU25YA46.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-P55MKIZX.mjs";import"./chunk-PYRZFUVU.mjs";import"./chunk-O2PUGRNW.mjs";import"./chunk-7SDZR6SR.mjs";import"./chunk-TEIBWMJM.mjs";import"./chunk-BWWQXU2B.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YAIIRFKJ.mjs";import"./chunk-Q3DY7TO2.mjs";import"./chunk-3XG25GTF.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-WSUKC2U3.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-3SKLBRPL.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-JH27IKCO.mjs";import"./chunk-SAMWHL22.mjs";import"./chunk-6KP6WETK.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-J24TIGSI.mjs";import"./chunk-HKUWHVI7.mjs";import"./chunk-VPDEJGPS.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-LHU6CPGE.mjs";import"./chunk-PBE44M2Y.mjs";import"./chunk-ZUOPC4W2.mjs";import"./chunk-JQZTMFO7.mjs";import"./chunk-JFNLKHY6.mjs";import"./chunk-VZVICK7Q.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-7PY3VQP3.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-HFUDCNU5.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-XZISAZA6.mjs";import"./chunk-LCDPCUXS.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-L4INJ5TZ.mjs";import"./chunk-KIMQQ6JQ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-PR74GYVI.mjs";import"./chunk-TMA34QMA.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as ENV_RUN_ID_RE,G as PREVIEW_UNREAD,l as accountKindOfRecordTypes,v as apiRequestsJson,p as describeDistribution,u as dryRunGatesJson,x as fitJson,c as fitOfArgs,y as main,d as parseArgs,C as parseRemoveArgs,m as personAccountLine,k as personRecordTypeNames,i as prebuiltTemplate,D as readRunSummary,f as readTemplateFile,o as recordTypeChoiceLine,n as recordTypeRule,A as refusalLines,H as removalPreviewJson,I as removalPreviewLines,F as removeMain,j as rulesFromDescribe,g as runIdRefusal,E as runOfSummary,z as scenarioKeptLines,t as seedAutomationCheck,w as seedFitLines,B as seedInterruptedLine,q as seedOrchestrator,r as seedWritePathOf,b as seededRandom,s as storageLine,e as templateDisplayName,h as templateRecordTypesRefusal};
@@ -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,N,O,P,Q,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-OLSGVAIL.mjs";import"./chunk-INIQ23K6.mjs";import"./chunk-ELFXJHU7.mjs";import"./chunk-W7U5E5ZL.mjs";import"./chunk-ZM6OJGIG.mjs";import"./chunk-MHMH6MTP.mjs";import"./chunk-COFG7Q6R.mjs";import"./chunk-GMY5427L.mjs";import"./chunk-PJ5I73CK.mjs";import"./chunk-BKDV4ENO.mjs";import"./chunk-X5JYBPXP.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-VS7ZXUII.mjs";import"./chunk-SOU4FRYN.mjs";import"./chunk-E5AHXLS6.mjs";import"./chunk-OO6CLPEH.mjs";import"./chunk-YS4G22C2.mjs";import"./chunk-QROPNEGY.mjs";import"./chunk-BZ24IAP5.mjs";import"./chunk-SCKUIE3R.mjs";import"./chunk-AV5SWEHP.mjs";import"./chunk-I7O6C2B5.mjs";import"./chunk-2CNCDM56.mjs";import"./chunk-SIHORWVK.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-4VS2V6WU.mjs";import"./chunk-KYEDBS54.mjs";import"./chunk-6XYKJSGX.mjs";import"./chunk-K2FBZIXY.mjs";import"./chunk-F43REJDZ.mjs";import"./chunk-JPUR2CFX.mjs";import"./chunk-LPBMBW3O.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-IFETCRWE.mjs";import"./chunk-PZPJKATS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-DYFALGRT.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-7FFGJWHN.mjs";import"./chunk-G35N4P7D.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-KDGMAGQR.mjs";import"./chunk-MFG4MUIO.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-HS4YRX4J.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-MTMH6H2A.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-NTOVCTRS.mjs";var export_jsforce=a.default;export{D as LINE_RUN,r as alreadyLinkedWords,C as bothRecorders,c as buildConfig,h as buildQueryFn,g as cliAllowsDeletes,k as cliCountFn,f as cliFileDeps,l as cliPersonAccountsFn,m as cliSourceIdsFn,N as configurationToldLines,x as contactPointLines,A as deltaLine,w as encryptedLeftOutLine,n as inTheCommandsWords,P as jobLines,export_jsforce as jsforce,E as main,B as memoryCreations,u as objectCountsLine,y as objectCurrencyLines,t as objectErrorLines,z as objectPriceLines,v as objectWrittenLines,b as parseArgs,F as parseRemoveArgs,i as readCutLines,G as readRunSummary,d as readSavedConfig,q as recordTypeGivenOfObjectsLines,J as removalRefusal,K as removalSummaryLines,H as removalsPathOf,Q as removeMain,L as restoredLines,O as runFileOf,I as runOfSummary,e as savedConfigStore,s as simulationLines,j as statusWithReadCuts,o as syncApiRequestsJson,M as undeletedLines,p as writeCheckLines};
7
+ import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-LAUOSXMN.mjs";import"./chunk-INIQ23K6.mjs";import"./chunk-2UU42PTD.mjs";import"./chunk-2JZGCCPG.mjs";import"./chunk-A7JJWOLT.mjs";import"./chunk-ZXFL2MSN.mjs";import"./chunk-VYOYXTCU.mjs";import"./chunk-C3LNYAVJ.mjs";import"./chunk-GJ6SZVHT.mjs";import"./chunk-52EXDVPN.mjs";import"./chunk-GMY5427L.mjs";import"./chunk-3HEMJTAP.mjs";import"./chunk-BN33LVPQ.mjs";import"./chunk-JKT5YAQ2.mjs";import"./chunk-QAPVKPEC.mjs";import"./chunk-BNKT3R3F.mjs";import"./chunk-QROPNEGY.mjs";import"./chunk-BZ24IAP5.mjs";import"./chunk-SCKUIE3R.mjs";import"./chunk-6FARZYMJ.mjs";import"./chunk-MUEQRIK7.mjs";import"./chunk-ISSP2FZ5.mjs";import"./chunk-XU25YA46.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-P55MKIZX.mjs";import"./chunk-PYRZFUVU.mjs";import"./chunk-O2PUGRNW.mjs";import"./chunk-7SDZR6SR.mjs";import"./chunk-TEIBWMJM.mjs";import"./chunk-BWWQXU2B.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YAIIRFKJ.mjs";import"./chunk-Q3DY7TO2.mjs";import"./chunk-3XG25GTF.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-WSUKC2U3.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-3SKLBRPL.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-JH27IKCO.mjs";import"./chunk-SAMWHL22.mjs";import"./chunk-6KP6WETK.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-J24TIGSI.mjs";import"./chunk-HKUWHVI7.mjs";import"./chunk-VPDEJGPS.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-LHU6CPGE.mjs";import"./chunk-PBE44M2Y.mjs";import"./chunk-ZUOPC4W2.mjs";import"./chunk-JQZTMFO7.mjs";import"./chunk-JFNLKHY6.mjs";import"./chunk-VZVICK7Q.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-7PY3VQP3.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-HFUDCNU5.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-XZISAZA6.mjs";import"./chunk-LCDPCUXS.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-L4INJ5TZ.mjs";import"./chunk-KIMQQ6JQ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-PR74GYVI.mjs";import"./chunk-TMA34QMA.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";var export_jsforce=a.default;export{D as LINE_RUN,r as alreadyLinkedWords,C as bothRecorders,c as buildConfig,h as buildQueryFn,g as cliAllowsDeletes,k as cliCountFn,f as cliFileDeps,l as cliPersonAccountsFn,m as cliSourceIdsFn,N as configurationToldLines,x as contactPointLines,A as deltaLine,w as encryptedLeftOutLine,n as inTheCommandsWords,P as jobLines,export_jsforce as jsforce,E as main,B as memoryCreations,u as objectCountsLine,y as objectCurrencyLines,t as objectErrorLines,z as objectPriceLines,v as objectWrittenLines,b as parseArgs,F as parseRemoveArgs,i as readCutLines,G as readRunSummary,d as readSavedConfig,q as recordTypeGivenOfObjectsLines,J as removalRefusal,K as removalSummaryLines,H as removalsPathOf,Q as removeMain,L as restoredLines,O as runFileOf,I as runOfSummary,e as savedConfigStore,s as simulationLines,j as statusWithReadCuts,o as syncApiRequestsJson,M as undeletedLines,p as writeCheckLines};
@@ -0,0 +1,157 @@
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 fs}from"./chunk-2JZGCCPG.mjs";import{d as Is}from"./chunk-UV74P4H2.mjs";import{a as Ne}from"./chunk-QROPNEGY.mjs";import{b as ps,e as ms}from"./chunk-BZ24IAP5.mjs";import{a as Ze,b as ce}from"./chunk-SCKUIE3R.mjs";import{c as se,d as gs}from"./chunk-6FARZYMJ.mjs";import{d as $e,k as Pe,z as ws}from"./chunk-J24TIGSI.mjs";import{b as cs,c as ls}from"./chunk-LHU6CPGE.mjs";import"./chunk-PBE44M2Y.mjs";import{a as os,b as as}from"./chunk-ZUOPC4W2.mjs";import{c as hs}from"./chunk-JQZTMFO7.mjs";import{Ga as Ss,oa as Us,uc as ke}from"./chunk-JFNLKHY6.mjs";import"./chunk-VZVICK7Q.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-7PY3VQP3.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-HFUDCNU5.mjs";import"./chunk-MS4FJDFD.mjs";import{a as ds,c as us,f as V,h as ys}from"./chunk-LCDPCUXS.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-L4INJ5TZ.mjs";import"./chunk-KIMQQ6JQ.mjs";import{a as Oe}from"./chunk-TZE3Y7IQ.mjs";import{b as X}from"./chunk-CA5NAXSU.mjs";import"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import{Bd as is,Ua as ss,ib as fe,ic as Ee,jb as pe,kb as me,lb as ge,mb as j,nb as ns,ob as rs,qb as ts}from"./chunk-ZQO5PDX5.mjs";import{b as re,e as be,f as le,k as te,m as ee,u as ie,v as Ye,z as es}from"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";import{readFileSync as Ln}from"node:fs";var _e=200;function q(e,s){let n=[];for(let r=0;r<e.length;r+=s)n.push(e.slice(r,r+s));return n}function xe(e){return`'${Oe(e)}'`}function M(e){return`(${e.map(xe).join(", ")})`}function Rs(e){return`'${Oe(e).replace(/[%_]/g,n=>`\\${n}`)}.%'`}function he(e,s){let n=new Set(s.map(r=>r.toLowerCase()));return e.replace(/[^\s@<>()[\]"',;:]+@[^\s@<>()[\]"',;:]+/g,r=>n.has(r.toLowerCase())?r:"<address>")}function nn(e){let s=e;return typeof s?.errorCode=="string"&&s.errorCode!==""?s.errorCode:typeof s?.name=="string"&&/^[A-Z][A-Z_]+$/.test(s.name)?s.name:"REQUEST_FAILED"}function rn(e,s){let n={code:nn(e),message:X(e),fields:[]};return Array.from({length:s},()=>({success:!1,errors:[n]}))}function tn(e){let s=e;if(s==null)return{success:!1,errors:[{code:"NO_ANSWER",message:"the org answered nothing for it",fields:[]}]};let n=(s.errors??[]).map(t=>({code:typeof t.statusCode=="string"?t.statusCode:typeof t.errorCode=="string"?t.errorCode:"UNKNOWN_ERROR",message:typeof t.message=="string"?t.message:"the org gave no words",fields:Array.isArray(t.fields)?t.fields.filter(o=>typeof o=="string"):[]})),r=s.success===!0;return{...typeof s.id=="string"?{id:s.id}:{},success:r,errors:r||n.length>0?n:[{code:"UNKNOWN_ERROR",message:"the org refused it",fields:[]}]}}function on(e,s){let n=Array.isArray(e)?e:[e];return Array.from({length:s},(r,t)=>tn(n[t]))}function As(e){let s=0,n=async(r,t)=>{let o=[];for(let i of q(r,_e)){s+=1;try{o.push(...on(await t(i),i.length))}catch(g){o.push(...rn(g,i.length))}}return o};return{identity:async()=>{s+=1;let r=await e.identity();return{userId:r.user_id,organizationId:r.organization_id,username:r.username}},query:async r=>{s+=1;let t=await e.query(r),o=[...t.records];for(;!t.done&&t.nextRecordsUrl;)s+=1,t=await e.queryMore(t.nextRecordsUrl),o.push(...t.records);return o},update:(r,t)=>n(t,o=>e.sobject(r).update(o,{allOrNone:!1,headers:Ee()})),create:(r,t)=>n(t,o=>e.sobject(r).create(o,{allOrNone:!1,headers:Ee()})),destroy:(r,t)=>n(t,o=>e.sobject(r).destroy(o,{allOrNone:!1})),requests:()=>s}}var we=72,an=50,dn=20,un=200,cn=100,vs=".invalid";function ne(e){let s=e.length-vs.length;if(!(s<=0||e.slice(s).toLowerCase()!==vs))return e.slice(0,s)}function U(e){return e.slice(0,15)}function G(e){return typeof e=="string"&&e!==""?e:void 0}var Ce="Id, Username, Email, IsActive, ProfileId, Profile.Name, Profile.UserLicenseId";function Le(e){let s=e.Profile??void 0,n=G(s?.UserLicenseId);return{id:String(e.Id),username:String(e.Username),isActive:e.IsActive===!0,profileId:String(e.ProfileId),profileName:G(s?.Name)??String(e.ProfileId),...n?{licenseId:n}:{},email:G(e.Email)??""}}function bs(e){let s=e.indexOf("__");return s>0&&!e.slice(s+2).includes("__")?{namespace:e.slice(0,s),own:e.slice(s+2)}:{own:e}}function Z(e,s){return s?`${s}__${e}`:e}async function ln(e,s){let n=new Map,r=[...new Map(s.map(i=>[j(i),i])).values()];for(let i of q(r,an)){let g=await e.query(`SELECT ${Ce} FROM User WHERE Username IN ${M(i)}`);for(let c of g){let d=Le(c);n.set(j(d.username),d)}}let t=r.filter(i=>!n.has(j(i))),o=new Map;for(let i of q(t,dn)){let g=i.map(d=>`Username LIKE ${Rs(d)}`).join(" OR "),c=(await e.query(`SELECT ${Ce} FROM User WHERE ${g}`)).map(Le);for(let d of i){let w=`${j(d)}.`,h=[...new Map(c.filter(S=>j(S.username).startsWith(w)).map(S=>[S.id,S])).values()];o.set(j(d),h)}}return s.map(i=>{let g=n.get(j(i));if(g)return{given:i,kind:"found",user:g};let c=o.get(j(i))??[];return c.length===1?{given:i,kind:"found",user:c[0]}:c.length===0?{given:i,kind:"none"}:{given:i,kind:"two",usernames:c.map(d=>d.username).sort((d,w)=>d<w?-1:d>w?1:0)}})}async function oe(e,s,n,r,t,o=""){let i=[];for(let g of q([...new Set(t)],un))i.push(...await e.query(`SELECT ${s} FROM ${n} WHERE ${r} IN ${M(g)}${o}`));return i}async function ze(e,s,n,r,t,o=""){let i=[];for(let g of q([...new Set(t)],cn))i.push(...await e.query(`SELECT ${s} FROM ${n} WHERE ${r} IN ${M(g)}${o}`));return i}async function Fe(e){try{let[s]=await e.query("SELECT PermissionsManageUsers FROM UserPermissionAccess"),n=s?.PermissionsManageUsers;return typeof n=="boolean"?n:void 0}catch{return}}function Te(e,s){let n=new Set(s.map(r=>r.toLowerCase()));return e.filter(r=>!n.has(r.toLowerCase()))}async function fn(e,s,n){if(s.length===0)return[];let r=new Date(n.getTime()-we*36e5).toISOString().replace(/\.\d{3}Z$/,"Z"),t;try{t=await e.query(`SELECT Display, CreatedDate FROM SetupAuditTrail WHERE Action = ${xe("useremailchangesent")} AND CreatedDate >= ${r}`)}catch{return[]}let o=t.map(i=>(G(i.Display)??"").trim().toLowerCase());return s.filter(i=>{let g=ne(i.email)?.toLowerCase();if(g===void 0)return!1;let c=`[${U(i.id).toLowerCase()}]`;return o.some(d=>d.includes(c)&&d.endsWith(` ${g}`))}).map(i=>U(i.id))}async function Ue(e,s,n){let r=e.requests(),t=await e.identity(),o=await Fe(e),i=await ln(e,s.map(p=>p.username)),g=i.flatMap(p=>p.kind==="found"?[p.user]:[]),c=new Set(g.map(p=>U(p.id))),d=n.previous?.users??[],w=d.map(p=>p.applied.userId).filter(p=>!c.has(U(p))),h=(await oe(e,Ce,"User","Id",w)).map(Le),S=[...g,...h].map(p=>p.id),O=p=>[...new Map(s.flatMap(u=>p(u)??[]).map(u=>[u.toLowerCase(),u])).values()],k=O(p=>p.permissionSets),L=O(p=>p.permissionSetGroups),F=O(p=>p.groups),x=d.length>0,W=s.some(p=>p.frozen!==void 0)||x?(await oe(e,"Id, UserId, IsFrozen","UserLogin","UserId",S)).map(p=>({id:String(p.Id),userId:String(p.UserId),isFrozen:p.IsFrozen===!0})):[],l=s.some(p=>p.profile!==void 0)||x?(await e.query("SELECT Id, Name, UserLicenseId FROM Profile")).map(p=>{let u=G(p.UserLicenseId);return{id:String(p.Id),name:String(p.Name),...u?{licenseId:u}:{}}}):void 0,A={},E=[];if(k.length>0){let p=await ze(e,"Id, Name, NamespacePrefix, LicenseId","PermissionSet","Name",k.map(a=>bs(a).own)," AND IsOwnedByProfile = false");for(let a of p){let I=G(a.NamespacePrefix),R=G(a.LicenseId);E.push({id:String(a.Id),name:String(a.Name),...I?{namespace:I}:{},...R?{licenseId:R}:{}})}let u=E.map(a=>Z(a.name,a.namespace));Te(k,u).length>0&&(A.permissionSets=(await e.query("SELECT Name, NamespacePrefix FROM PermissionSet WHERE IsOwnedByProfile = false")).map(a=>Z(String(a.Name),G(a.NamespacePrefix))))}let v=[];if(L.length>0){let p=await ze(e,"Id, DeveloperName, NamespacePrefix","PermissionSetGroup","DeveloperName",L.map(a=>bs(a).own));for(let a of p){let I=G(a.NamespacePrefix);v.push({id:String(a.Id),name:String(a.DeveloperName),...I?{namespace:I}:{}})}let u=v.map(a=>Z(a.name,a.namespace));Te(L,u).length>0&&(A.permissionSetGroups=(await e.query("SELECT DeveloperName, NamespacePrefix FROM PermissionSetGroup")).map(a=>Z(String(a.DeveloperName),G(a.NamespacePrefix))))}let N=[];if(F.length>0){let p=await ze(e,"Id, DeveloperName, Type","Group","DeveloperName",F,` AND Type IN ${M(["Regular","Queue"])}`);for(let u of p){let a=u.Type;a!=="Regular"&&a!=="Queue"||N.push({id:String(u.Id),name:String(u.DeveloperName),type:a})}Te(F,N.map(u=>u.name)).length>0&&(A.groups=(await e.query(`SELECT DeveloperName FROM Group WHERE Type IN ${M(["Regular","Queue"])}`)).map(u=>String(u.DeveloperName)))}let f=s.some(p=>p.active===!0||p.profile!==void 0)||x||E.some(p=>p.licenseId?.startsWith("100"))?(await e.query("SELECT Id, Name, TotalLicenses, UsedLicenses FROM UserLicense")).map(p=>({id:String(p.Id),name:String(p.Name),total:Number(p.TotalLicenses??0),used:Number(p.UsedLicenses??0)})):[],m=k.length>0||L.length>0||x?(await oe(e,"Id, AssigneeId, PermissionSetId, PermissionSetGroupId","PermissionSetAssignment","AssigneeId",S)).map(p=>{let u=G(p.PermissionSetId),a=G(p.PermissionSetGroupId);return{id:String(p.Id),assigneeId:String(p.AssigneeId),...u?{permissionSetId:u}:{},...a?{permissionSetGroupId:a}:{}}}):[],y=F.length>0||x?(await oe(e,"Id, GroupId, UserOrGroupId","GroupMember","UserOrGroupId",S)).map(p=>({id:String(p.Id),groupId:String(p.GroupId),userId:String(p.UserOrGroupId)})):[],P=E.some(p=>p.licenseId?.startsWith("0PL"))?(await oe(e,"AssigneeId, PermissionSetLicenseId","PermissionSetLicenseAssign","AssigneeId",S)).map(p=>({assigneeId:String(p.AssigneeId),permissionSetLicenseId:String(p.PermissionSetLicenseId)})):[],$=i.flatMap((p,u)=>p.kind==="found"&&s[u]?.email==="restore"&&ne(p.user.email)!==void 0?[p.user]:[]),b=await fn(e,$,n.now);return{connected:t,manageUsers:o,resolutions:i,held:h,logins:W,...l?{profiles:l}:{},licenses:f,permissionSets:E,permissionSetGroups:v,groups:N,knownNames:A,assignments:m,memberships:y,licenseAssignments:P,addressesAsked:b,requests:e.requests()-r}}function Es(e){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function $s(e){return[...new Set(e)].sort((s,n)=>s<n?-1:s>n?1:0)}function pn(e,s,n){if(Math.abs(e.length-s.length)>n)return n+1;let r=Array.from({length:s.length+1},(t,o)=>o);for(let t=1;t<=e.length;t+=1){let o=[t];for(let i=1;i<=s.length;i+=1)o[i]=Math.min(r[i]+1,o[i-1]+1,r[i-1]+(e[t-1]===s[i-1]?0:1));r=o}return r[s.length]}function Os(e){return e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(s=>s.length>=3)}function Me(e,s){let n=e.toLowerCase(),r=new Set(Os(e));return $s(s.filter(t=>{let o=t.toLowerCase();return o.includes(n)||n.includes(o)||Os(t).some(i=>r.has(i))||pn(o,n,2)<=2}))}function qe(e){let s=e.slice(0,20).join(", ");return e.length>20?`${s}, and ${e.length-20} more`:s}var De={profile:"change its profile",active:"deactivate it",frozen:"freeze it"};function je(e,s){return{code:"USERS_NO_RIGHT",message:(s===!1?`${e} cannot manage users here (Manage Users)`:`the org would not say whether ${e} may manage users (Manage Users)`)+": give it Manage Users, or connect as a user who has it"}}function C(e,s){return e!==void 0&&s!==void 0&&U(e)===U(s)}function We(e){return e.what==="group"?{what:"group",name:e.name,type:e.type??"Regular",to:"removed"}:{what:e.what,name:e.name,to:"removed"}}function Se(){return{assign:[],unassign:[],join:[],leave:[]}}function ae(e,s,n={}){let r=[],t=e.connected;e.manageUsers!==!0&&r.push(je(t.username,e.manageUsers));let o=n.previous?.users??[],i=l=>o.find(A=>C(A.applied.userId,l)),g=l=>e.profiles?.find(A=>C(A.id,l)),c=l=>e.logins.find(A=>C(A.userId,l)),d=l=>e.assignments.some(A=>C(A.id,l)),w=l=>e.memberships.some(A=>C(A.id,l)),h=(l,A,E,v)=>{let N={isActive:l.isActive,isFrozen:c(l.id)?.isFrozen??!1,profileId:l.profileId},f=A?.applied.before??N;v.current=N,v.before=f,l.licenseId!==void 0&&(v.licenseId=l.licenseId);let m=b=>{if(E[b]!==void 0)return E[b];if(A&&A.after[b]!==A.applied.before[b]&&N[b]===A.after[b])return f[b]},y=m("profileId");y!==void 0&&(v.target.profileId=y,C(y,N.profileId)||(v.writes.profileId=y,v.changes.push({what:"profile",from:l.profileName,to:g(y)?.name??y})));let P=m("isActive");P!==void 0&&(v.target.isActive=P,P!==N.isActive&&(v.writes.isActive=P,v.changes.push({what:"active",from:N.isActive,to:P})));let $=m("isFrozen");if($!==void 0&&(v.target.isFrozen=$,$!==N.isFrozen)){let b=c(l.id);v.writes.isFrozen=$,b&&(v.writes.loginId=b.id),v.changes.push({what:"frozen",from:N.isFrozen,to:$})}},S=(l,A)=>{for(let E of l)E.what==="group"?w(E.id)&&A.writes.leave.push(E):d(E.id)&&A.writes.unassign.push(E)},O=[],k=new Map;s.forEach((l,A)=>{let E=e.resolutions[A];if(E===void 0||E.kind!=="found"){O.push({given:l.username,username:l.username,inFile:!0,changes:[],emailsToPeople:0,target:{},writes:Se(),found:{permissionSetAssignments:[],groupMembers:[]},carried:[]}),E?.kind==="two"?r.push({code:"USERS_TWO_USERS",username:l.username,message:`${l.username} names ${E.usernames.length} users: write the sandbox\u2019s username in full: ${E.usernames.join(" or ")}`}):r.push({code:"USERS_NO_USER",username:l.username,message:`${l.username}: no user has this username, nor this username followed by .<sandbox>: check the username, as Setup > Users gives it, or take it out of the file`});return}let v=E.user,N=k.get(U(v.id));if(N!==void 0){O.push({given:l.username,username:v.username,inFile:!0,changes:[],emailsToPeople:0,target:{},writes:Se(),found:{permissionSetAssignments:[],groupMembers:[]},carried:[]}),r.push({code:"USERS_SAME_USER",username:l.username,message:`${l.username} and ${N} name one user, ${v.username}: one entry per user`});return}k.set(U(v.id),l.username);let f=i(v.id),m={given:l.username,username:v.username,userId:v.id,inFile:!0,changes:[],emailsToPeople:0,target:{},writes:Se(),found:{permissionSetAssignments:[],groupMembers:[]},carried:[]},y;if(l.profile!==void 0){let a=(e.profiles??[]).filter(I=>I.name===l.profile);if(a.length===1)y=a[0].id;else{let I=(e.profiles??[]).map(z=>z.name),R=Me(l.profile,I);r.push({code:"USERS_PROFILE_UNKNOWN",username:l.username,message:`profile ${l.profile}: `+(a.length===0?"no profile has this name":`${a.length} profiles have this name`)+": profiles are named as Setup > Profiles names them, in the org\u2019s language: "+qe(R.length>0?R:$s(I))})}}h(v,f,{...y!==void 0?{profileId:y}:{},...l.active!==void 0?{isActive:l.active}:{},...l.frozen!==void 0?{isFrozen:l.frozen}:{}},m);let P=(m.target.profileId!==void 0?g(m.target.profileId)?.licenseId:void 0)??v.licenseId,$=f?.accesses??[],b=(a,I)=>$.find(R=>R.what===a&&R.name.toLowerCase()===I.toLowerCase()),p=(a,I)=>{for(let R of I??[]){let _=(a==="permissionSet"?e.permissionSets.map(T=>({...T,apiName:Z(T.name,T.namespace)})):e.permissionSetGroups.map(T=>({...T,licenseId:void 0,apiName:Z(T.name,T.namespace)}))).find(T=>T.apiName.toLowerCase()===R.toLowerCase());if(!_){let T=(a==="permissionSet"?e.knownNames.permissionSets:e.knownNames.permissionSetGroups)??[],ue=Me(R,T);r.push({code:"USERS_PERMISSION_SET_UNKNOWN",username:l.username,message:(a==="permissionSet"?`permission set ${R}: no permission set has this API name: names are API names (Setup > Permission Sets > API Name)`:`permission set group ${R}: no permission set group has this API name: names are API names (Setup > Permission Set Groups > API Name)`)+(ue.length>0?`; close: ${qe(ue)}`:"")});continue}let Q=e.assignments.find(T=>C(T.assigneeId,v.id)&&C(a==="permissionSet"?T.permissionSetId:T.permissionSetGroupId,_.id)),B=b(a,R);if(Q){B&&C(B.id,Q.id)?m.carried.push(B):m.found.permissionSetAssignments.push(Q.id);continue}let J=_.licenseId;if(J?.startsWith("100")&&!C(J,P)){let T=e.licenses.find(ue=>C(ue.id,J))?.name??J;r.push({code:"USERS_PERMISSION_SET_LICENSE",username:l.username,message:`${v.username}: permission set ${R} needs the license ${T}, which this user will not have: assign the permission set license first, in Setup, or take the set out`});continue}if(J?.startsWith("0PL")&&!e.licenseAssignments.some(T=>C(T.assigneeId,v.id)&&C(T.permissionSetLicenseId,J))){r.push({code:"USERS_PERMISSION_SET_LICENSE",username:l.username,message:`${v.username}: permission set ${R} needs a permission set license this user does not hold: assign the permission set license first, in Setup, or take the set out`});continue}m.writes.assign.push({what:a,name:R,setId:_.id})}};p("permissionSet",l.permissionSets),p("permissionSetGroup",l.permissionSetGroups);for(let a of l.groups??[]){let I=e.groups.find(_=>_.name.toLowerCase()===a.toLowerCase());if(!I){let _=Me(a,e.knownNames.groups??[]);r.push({code:"USERS_GROUP_UNKNOWN",username:l.username,message:`group ${a}: no public group or queue has this API name (DeveloperName)`+(_.length>0?`; close: ${qe(_)}`:"")});continue}let R=e.memberships.find(_=>C(_.userId,v.id)&&C(_.groupId,I.id)),z=b("group",a);if(R){z&&C(z.id,R.id)?m.carried.push(z):m.found.groupMembers.push(R.id);continue}m.writes.join.push({name:a,type:I.type,groupId:I.id})}let u=a=>((a.what==="permissionSet"?l.permissionSets:a.what==="permissionSetGroup"?l.permissionSetGroups:l.groups)??[]).some(R=>R.toLowerCase()===a.name.toLowerCase());S($.filter(a=>!u(a)),m);for(let a of m.writes.assign)m.changes.push({what:a.what,name:a.name,to:"added"});for(let a of m.writes.unassign)m.changes.push(We(a));for(let a of m.writes.join)m.changes.push({what:"group",name:a.name,type:a.type,to:"added"});for(let a of m.writes.leave)m.changes.push(We(a));if(l.email==="keep"&&(m.address="kept"),l.email==="restore"){let a=ne(v.email);a===void 0?m.address="restored":e.addressesAsked.includes(U(v.id))?m.address="awaiting":(m.address="invalid",m.writes.email=a,m.emailsToPeople=1,m.changes.push({what:"email",to:"awaiting"}))}O.push(m)});let L=new Set(O.flatMap(l=>l.userId?[U(l.userId)]:[]));for(let l of o){if(L.has(U(l.applied.userId)))continue;let A=e.held.find(v=>C(v.id,l.applied.userId));if(!A)continue;let E={username:A.username,userId:A.id,inFile:!1,changes:[],emailsToPeople:0,target:{},writes:Se(),found:{permissionSetAssignments:[],groupMembers:[]},carried:[]};h(A,l,{},E),S(l.accesses,E);for(let v of[...E.writes.unassign,...E.writes.leave])E.changes.push(We(v));O.push(E)}for(let l of O)l.writes.isFrozen===void 0||l.writes.loginId!==void 0||r.push({code:"USERS_NO_LOGIN",...l.given!==void 0?{username:l.given}:{},message:`${l.username}: the org keeps no login of this user (UserLogin), which a freeze writes`+(l.inFile?`: take frozen off ${l.username}`:"")});for(let l of O){if(!C(l.userId,t.userId))continue;let A=[...l.writes.profileId!==void 0?[De.profile]:[],...l.writes.isActive===!1?[De.active]:[],...l.writes.isFrozen===!0?[De.frozen]:[]];A.length!==0&&r.push({code:"USERS_SELF",...l.given!==void 0?{username:l.given}:{},message:l.inFile?`${l.username} is the user connected, and the file would ${Es(A)}: SandForge would lock itself out: take ${l.username} out of the file, or connect as another`:`${l.username} is the user connected, and putting it back as it was would ${Es(A)}: SandForge would lock itself out: connect as another`})}let F=mn(e,O,r),x=O.reduce((l,A)=>l+A.emailsToPeople,0);x>0&&n.acceptUserEmails!==!0&&r.push({code:"USERS_EMAILS_NOT_ACCEPTED",message:`Salesforce would email ${x} ${x===1?"person":"people"}: the confirmation of each address asked back, a system email, which only the line accepts: --accept-user-emails, once those people may receive them`});let W=n.deliverability==="open"||n.deliverability==="unread";return x>0&&W&&n.acceptEmails!==!0&&r.push({code:"USERS_EMAILS_OPEN",message:(n.deliverability==="unread"?"the org's deliverability could not be read, so it may deliver all email, and ":"the org delivers all email, and ")+`${x} ${x===1?"address":"addresses"} would be asked back before the masking is done: set Setup > Deliverability to System email only until the masking is done, or accept with --accept-emails that what runs there emails these people`}),{users:O,licenses:F,emailsToPeople:x,refusals:r}}function mn(e,s,n){let r=new Map,t=c=>{let d=U(c),w=r.get(d);return w||(w={takesFirst:0,freesFirst:0,takesThen:0,freesThen:0,takers:new Map},r.set(d,w)),w},o=c=>e.profiles?.find(d=>U(d.id)===U(c))?.licenseId,i=(c,d,w)=>{let h=t(c).takers;h.set(d,[...h.get(d)??[],w])};for(let c of s){let d=c.current;if(!d)continue;let w=o(d.profileId)??c.licenseId,h=c.writes.profileId??d.profileId,S=o(h)??w;if(c.writes.profileId!==void 0&&d.isActive&&S!==void 0&&(w===void 0||U(w)!==U(S))){t(S).takesFirst+=1;let O=c.changes.find(k=>k.what==="profile");i(S,`profile: ${O?.what==="profile"?O.to:h}`,c.username),w!==void 0&&(t(w).freesFirst+=1)}S!==void 0&&(c.writes.isActive===!0&&(t(S).takesThen+=1,i(S,"active: true",c.username)),c.writes.isActive===!1&&(t(S).freesThen+=1))}let g=[];for(let c of e.licenses){let d=r.get(U(c.id)),w=d?d.takesFirst+d.takesThen:0;if(!d||w===0)continue;let h=Math.max(0,w-d.freesFirst-d.freesThen),S=c.total-c.used,O=d.takesFirst>S||d.takesThen>S-d.takesFirst+d.freesFirst+d.freesThen;if(g.push({name:c.name,total:c.total,used:c.used,toUse:h}),O){let k=[...d.takers].map(([L,F])=>`${L} off ${F.join(" or ")}`);n.push({code:"USERS_LICENSE",message:`${c.name}: ${c.used} of ${c.total} used, and the file takes ${h} more: deactivate a user who no longer needs it, or take ${k.join(", or ")}`})}}return g}function H(e){return Math.ceil(e/_e)}function gn(e){let s=i=>e.users.filter(i).length,n=i=>e.users.reduce((g,c)=>g+i(c),0),r=s(i=>i.writes.join.length>0),t=s(i=>i.writes.isFrozen!==void 0),o=s(i=>i.writes.profileId!==void 0||i.writes.isActive!==void 0||i.writes.isFrozen!==void 0||i.writes.email!==void 0);return H(s(i=>i.writes.profileId!==void 0))+H(s(i=>i.writes.isActive===!1))+H(s(i=>i.writes.isActive===!0))+H(t)+H(n(i=>i.writes.assign.length))+H(n(i=>i.writes.unassign.length))+H(r)+H(n(i=>i.writes.join.length))+H(n(i=>i.writes.leave.length))+H(s(i=>i.writes.email!==void 0))+H(o)+H(t)}function ye(e,s,n){return{org:s,users:e.users.map(r=>({username:r.username,...r.given!==void 0&&j(r.given)!==j(r.username)?{given:r.given}:{},...r.userId!==void 0?{userId:r.userId}:{},...r.address!==void 0?{address:r.address}:{},changes:r.changes,...r.emailsToPeople>0?{emailsToPeople:r.emailsToPeople}:{}})),...e.licenses.length>0?{licenses:e.licenses}:{},emailsToPeople:e.emailsToPeople,apiRequests:n+gn(e),...e.refusals.length>0?{refusals:e.refusals}:{}}}async function hn(e){let s=e.now??(()=>new Date),n=await Ue(e.org,e.users,{now:s(),...e.previous?{previous:e.previous}:{}}),r=ae(n,e.users,{...e.previous?{previous:e.previous}:{},...e.acceptUserEmails!==void 0?{acceptUserEmails:e.acceptUserEmails}:{},...e.deliverability!==void 0?{deliverability:e.deliverability}:{},...e.acceptEmails!==void 0?{acceptEmails:e.acceptEmails}:{}});return{state:n,plan:r,answer:ye(r,e.organization,n.requests)}}function Ie(e,s){let n=e.changes.find(s);if(!n)throw new Error(`No change of ${e.username} for this write`);return n}function Re(e,s){let n=e?.errors[0];return{code:n?.code??"NO_ANSWER",message:he(n?.message??"the org answered nothing for it",s)}}var wn=new Set(["ENTITY_IS_DELETED","NOT_FOUND","INVALID_CROSS_REFERENCE_KEY"]);function ks(e){let{target:s}=e.planned;return{isActive:s.isActive!==void 0?e.standing.isActive:e.before.isActive,isFrozen:s.isFrozen!==void 0?e.standing.isFrozen:e.before.isFrozen,profileId:s.profileId!==void 0?e.standing.profileId:e.before.profileId}}function Un(e){let s=ks(e);return e.accesses.length>0||s.isActive!==e.before.isActive||s.isFrozen!==e.before.isFrozen||U(s.profileId)!==U(e.before.profileId)}function Ps(e){let s=e.found.permissionSetAssignments.length>0||e.found.groupMembers.length>0?{found:e.found}:{};return{username:e.planned.username,userId:e.userId,before:e.before,done:e.done,created:{permissionSetAssignments:e.accesses.filter(n=>n.what!=="group").map(n=>n.id),groupMembers:e.accesses.filter(n=>n.what==="group").map(n=>n.id)},...s,...e.address!==void 0?{address:e.address}:{},...e.refused.length>0?{refused:e.refused}:{}}}async function Ns(e){let{org:s,store:n,signal:r}=e,t=e.now??(()=>new Date),o=s.requests(),{state:i,plan:g,answer:c}=await hn(e);if(g.refusals.length>0)return{kind:"refused",plan:c};if(U(i.connected.organizationId)!==U(e.organization.organizationId))throw new Error(`The connection is to ${i.connected.organizationId}, not to ${e.organization.organizationId}: nothing was written`);let d=g.users.flatMap(f=>f.userId!==void 0&&f.current!==void 0&&f.before!==void 0?[{planned:f,userId:f.userId,before:f.before,standing:{...f.current},done:[],refused:[],accesses:[...f.carried,...f.writes.unassign,...f.writes.leave],found:{permissionSetAssignments:[...f.found.permissionSetAssignments],groupMembers:[...f.found.groupMembers]},...f.address!==void 0?{address:f.address}:{}}]:[]),w=d.map(f=>f.planned.username),h=0,S=t().toISOString(),O=(f,m)=>({...e.previous?{replaces:e.previous.run}:{},status:f,startedAt:S,...m?{endedAt:t().toISOString()}:{},emailsToPeople:h,users:d.filter(y=>y.planned.inFile||Un(y)).map(y=>({applied:Ps(y),after:ks(y),accesses:y.accesses,inFile:y.planned.inFile}))}),k=(f,m,y)=>({version:1,organizationId:i.connected.organizationId,run:f,...O(m,y)}),F=(await n.begin(i.connected.organizationId,O("running",!1))).run,x=new Set,W=async(f,m,y,P,$)=>{if(f.length===0)return;let b=await s.update(P,f.map(m));f.forEach((p,u)=>{let a=Ie(p.planned,y);b[u]?.success===!0?($(p),p.done.push(a)):p.refused.push({change:a,...Re(b[u],w)})})},l=[()=>W(d.filter(f=>f.planned.writes.profileId!==void 0),f=>({Id:f.userId,ProfileId:f.planned.writes.profileId}),f=>f.what==="profile","User",f=>{f.standing.profileId=f.planned.writes.profileId??f.standing.profileId}),async()=>{for(let f of[!1,!0])await W(d.filter(m=>m.planned.writes.isActive===f),m=>({Id:m.userId,IsActive:f}),m=>m.what==="active","User",m=>{m.standing.isActive=f})},()=>W(d.filter(f=>f.planned.writes.isFrozen!==void 0),f=>({Id:f.planned.writes.loginId??"",IsFrozen:f.planned.writes.isFrozen}),f=>f.what==="frozen","UserLogin",f=>{f.standing.isFrozen=f.planned.writes.isFrozen??f.standing.isFrozen}),async()=>{let f=d.flatMap(m=>m.planned.writes.assign.map(y=>({one:m,assign:y})));if(f.length>0){let m=await s.create("PermissionSetAssignment",f.map(({one:y,assign:P})=>P.what==="permissionSet"?{AssigneeId:y.userId,PermissionSetId:P.setId}:{AssigneeId:y.userId,PermissionSetGroupId:P.setId}));f.forEach(({one:y,assign:P},$)=>{let b=m[$],p=Ie(y.planned,u=>u.what===P.what&&u.name===P.name&&u.to==="added");b?.success===!0&&b.id!==void 0?(y.accesses.push({id:b.id,what:P.what,name:P.name}),y.done.push(p)):b?.errors[0]?.code==="DUPLICATE_VALUE"?x.add(y):y.refused.push({change:p,...Re(b,w)})})}await A("PermissionSetAssignment",m=>m.planned.writes.unassign)},async()=>{let f=d.filter(m=>m.planned.writes.join.length>0);if(f.length>0){let m=new Map;for(let P of q(f.map($=>$.userId),200)){let $=await s.query(`SELECT Id, GroupId, UserOrGroupId FROM GroupMember WHERE UserOrGroupId IN ${M(P)}`);for(let b of $)m.set(`${U(String(b.UserOrGroupId))}:${U(String(b.GroupId))}`,String(b.Id))}let y=f.flatMap(P=>P.planned.writes.join.flatMap($=>{let b=m.get(`${U(P.userId)}:${U($.groupId)}`);return b!==void 0?(P.found.groupMembers.push(b),[]):[{one:P,join:$}]}));if(y.length>0){let P=new Set([...m.values()].map(U)),$=await s.create("GroupMember",y.map(({one:b,join:p})=>({GroupId:p.groupId,UserOrGroupId:b.userId})));y.forEach(({one:b,join:p},u)=>{let a=$[u],I=Ie(b.planned,R=>R.what==="group"&&R.name===p.name&&R.to==="added");if(a?.success===!0&&a.id!==void 0){if(P.has(U(a.id))){b.found.groupMembers.push(a.id);return}b.accesses.push({id:a.id,what:"group",name:p.name,type:p.type}),b.done.push(I)}else b.refused.push({change:I,...Re(a,w)})})}}await A("GroupMember",m=>m.planned.writes.leave)},()=>W(d.filter(f=>f.planned.writes.email!==void 0),f=>({Id:f.userId,Email:f.planned.writes.email}),f=>f.what==="email","User",f=>{h+=1,f.address="awaiting"})];async function A(f,m){let y=d.flatMap($=>m($).map(b=>({one:$,access:b})));if(y.length===0)return;let P=await s.destroy(f,y.map(({access:$})=>$.id));y.forEach(({one:$,access:b},p)=>{let u=P[p],a=Ie($.planned,R=>R.what===b.what&&"name"in R&&R.name===b.name&&R.to==="removed"),I=u?.errors.some(R=>wn.has(R.code))===!0;u?.success===!0||I?($.accesses=$.accesses.filter(R=>R.id!==b.id),u?.success===!0&&$.done.push(a)):$.refused.push({change:a,...Re(u,w)})})}let E="success";for(let f of l){if(r?.aborted){E="cancelled";break}await f(),await n.write(k(F,"running",!1))}E!=="cancelled"&&await Sn(s,d,x),E!=="cancelled"&&d.some(f=>f.refused.length>0)&&(E="partial");let v=k(F,E,!0);return await n.write(v),{kind:"applied",answer:{org:e.organization,run:F,status:E,users:d.map(Ps),emailsToPeople:h,apiRequests:s.requests()-o},record:v}}async function Sn(e,s,n){let r=s.filter(c=>c.planned.writes.profileId!==void 0||c.planned.writes.isActive!==void 0||c.planned.writes.isFrozen!==void 0||c.planned.writes.email!==void 0),t=new Map(s.map(c=>[U(c.userId),c])),o=(c,d)=>{let w=c.done.findIndex(S=>S.what===d);if(w<0)return;let[h]=c.done.splice(w,1);c.refused.push({change:h,code:"NOT_HELD",message:"the org answered success, and its read after the run holds the user otherwise"})};for(let c of q(r.map(d=>d.userId),200)){let d=await e.query(`SELECT Id, Email, IsActive, ProfileId FROM User WHERE Id IN ${M(c)}`);for(let w of d){let h=t.get(U(String(w.Id)));if(!h)continue;let S=w.IsActive===!0,O=String(w.ProfileId);h.planned.writes.isActive!==void 0&&S!==h.standing.isActive&&o(h,"active"),h.planned.writes.profileId!==void 0&&U(O)!==U(h.standing.profileId)&&o(h,"profile"),h.standing.isActive=S,h.standing.profileId=O,h.address==="awaiting"&&typeof w.Email=="string"&&ne(w.Email)===void 0&&(h.address="restored")}}let i=r.filter(c=>c.planned.writes.isFrozen!==void 0);for(let c of q(i.map(d=>d.userId),200)){let d=await e.query(`SELECT Id, UserId, IsFrozen FROM UserLogin WHERE UserId IN ${M(c)}`);for(let w of d){let h=t.get(U(String(w.UserId)));if(!h)continue;let S=w.IsFrozen===!0;S!==h.standing.isFrozen&&o(h,"frozen"),h.standing.isFrozen=S}}if(n.size===0)return;let g=await e.query(`SELECT Id, AssigneeId, PermissionSetId, PermissionSetGroupId FROM PermissionSetAssignment WHERE AssigneeId IN ${M([...n].map(c=>c.userId))}`);for(let c of n)for(let d of c.planned.writes.assign){let w=g.find(S=>U(String(S.AssigneeId))===U(c.userId)&&U(String((d.what==="permissionSet"?S.PermissionSetId:S.PermissionSetGroupId)??""))===U(d.setId)),h=w?String(w.Id):void 0;h!==void 0&&!c.accesses.some(S=>U(S.id)===U(h))&&!c.found.permissionSetAssignments.includes(h)&&c.found.permissionSetAssignments.push(h)}}function yn(e,s,n){let{before:r}=e.applied,{after:t}=e,o=s.standing,i=U(e.applied.userId)===U(n.connected.userId),g=`${n.connected.username} is the user connected: SandForge would lock itself out; connect as another to put it back`,c={leave:e.accesses.filter(d=>d.what==="group"&&s.present.has(U(d.id))),unassign:e.accesses.filter(d=>d.what!=="group"&&s.present.has(U(d.id))),kept:[]};if(t.isFrozen!==r.isFrozen&&o.isFrozen===t.isFrozen){let d={what:"frozen",from:t.isFrozen,to:r.isFrozen};i&&r.isFrozen?c.kept.push({change:d,why:g}):s.loginId===void 0?c.kept.push({change:d,why:"the org keeps no login of this user (UserLogin) to write"}):c.isFrozen={to:r.isFrozen,loginId:s.loginId,change:d}}if(t.isActive!==r.isActive&&o.isActive===t.isActive){let d={what:"active",from:t.isActive,to:r.isActive};i&&!r.isActive?c.kept.push({change:d,why:g}):c.isActive={to:r.isActive,change:d}}if(U(t.profileId)!==U(r.profileId)&&U(o.profileId)!==U(r.profileId)){let d=S=>s.profileNames.get(U(S))??S,w={what:"profile",from:d(o.profileId),to:d(r.profileId)},h=U(o.profileId)!==U(t.profileId);i?c.kept.push({change:w,why:g}):h&&!n.includeChanged?c.kept.push({change:w,why:`its profile was changed since the run, to ${d(o.profileId)}: --include-changed puts ${d(r.profileId)} back`}):c.profileId={to:r.profileId,change:w}}return c}function _s(e){return e.what==="group"?{what:"group",name:e.name,type:e.type??"Regular",to:"removed"}:{what:e.what,name:e.name,to:"removed"}}function Ge(e,s,n,r){return{org:e.organization,run:e.run,status:"failure",users:[],apiRequests:r,refusals:[{code:s,message:n}]}}async function xs(e){let{org:s,store:n,run:r}=e,t=e.now??(()=>new Date),o=s.requests(),i=()=>s.requests()-o,g=await s.identity(),c=await n.read(g.organizationId,r);if(!c)return Ge(e,"USERS_RUN_NOT_FOUND",`run ${r}: this machine keeps no run of that number for this org, whose Organization Id is ${g.organizationId}: a sandbox refreshed since answers another, and its runs went with the copy they set up`,i());let d=(await n.list(g.organizationId)).find(u=>u.replaces===r);if(d)return Ge(e,"USERS_RUN_REPLACED",`run ${r} was replaced by run ${d.run}, which holds what it set up: remove run ${d.run}`,i());let w=await Fe(s);if(w!==!0){let u=je(g.username,w);return Ge(e,u.code,u.message,i())}let h=c.users,S=h.map(u=>u.applied.userId),O=new Map;for(let u of q(S,200))for(let a of await s.query(`SELECT Id, IsActive, ProfileId FROM User WHERE Id IN ${M(u)}`))O.set(U(String(a.Id)),{isActive:a.IsActive===!0,isFrozen:!1,profileId:String(a.ProfileId)});let k=new Map,L=h.filter(u=>u.after.isFrozen!==u.applied.before.isFrozen);for(let u of q(L.map(a=>a.applied.userId),200))for(let a of await s.query(`SELECT Id, UserId, IsFrozen FROM UserLogin WHERE UserId IN ${M(u)}`)){let I=U(String(a.UserId));k.set(I,String(a.Id));let R=O.get(I);R&&(R.isFrozen=a.IsFrozen===!0)}let F=new Set,x=u=>h.flatMap(a=>a.accesses.filter(I=>u==="memberships"==(I.what==="group")).map(I=>I.id));for(let[u,a]of[["PermissionSetAssignment",x("assignments")],["GroupMember",x("memberships")]])for(let I of q(a,200))for(let R of await s.query(`SELECT Id FROM ${u} WHERE Id IN ${M(I)}`))F.add(U(String(R.Id)));let W=h.flatMap(u=>U(u.after.profileId)!==U(u.applied.before.profileId)?[u.applied.before.profileId,u.after.profileId,O.get(U(u.applied.userId))?.profileId??""]:[]).filter(u=>u!==""),l=new Map;for(let u of q([...new Set(W)],200))for(let a of await s.query(`SELECT Id, Name FROM Profile WHERE Id IN ${M(u)}`))l.set(U(String(a.Id)),String(a.Name));let A=h.map(u=>u.applied.username),E=h.flatMap(u=>{let a=O.get(U(u.applied.userId));if(!a)return[];let I=k.get(U(u.applied.userId));return[{user:u,undo:yn(u,{standing:a,...I?{loginId:I}:{},profileNames:l,present:F},{includeChanged:e.includeChanged===!0,connected:g}),undone:[],refused:[]}]}),v=(u,a,I)=>{let R=I?.code??"NO_ANSWER";u.refused.push({change:a,code:R,why:`the org refused it: ${R} ${he(I?.message??"the org answered nothing for it",A)}`})},N=async(u,a)=>{let I=E.flatMap(z=>a(z).map(_=>({one:z,access:_})));if(I.length===0)return;let R=await s.destroy(u,I.map(({access:z})=>z.id));I.forEach(({one:z,access:_},Q)=>{let B=R[Q];B?.success===!0?z.undone.push(_s(_)):B?.errors.some(J=>J.code==="ENTITY_IS_DELETED")||v(z,_s(_),B?.errors[0])})},f=async(u,a)=>{let I=E.flatMap(z=>{let _=a(z);return _?[{one:z,..._}]:[]});if(I.length===0)return;let R=await s.update(u,I.map(({row:z})=>z));I.forEach(({one:z,change:_},Q)=>{let B=R[Q];B?.success===!0?z.undone.push(_):v(z,_,B?.errors[0])})},m=[()=>N("GroupMember",u=>u.undo.leave),()=>N("PermissionSetAssignment",u=>u.undo.unassign),()=>f("UserLogin",u=>u.undo.isFrozen?{row:{Id:u.undo.isFrozen.loginId,IsFrozen:u.undo.isFrozen.to},change:u.undo.isFrozen.change}:void 0),async()=>{for(let u of[!1,!0])await f("User",a=>a.undo.isActive?.to===u?{row:{Id:a.user.applied.userId,IsActive:u},change:a.undo.isActive.change}:void 0)},()=>f("User",u=>u.undo.profileId?{row:{Id:u.user.applied.userId,ProfileId:u.undo.profileId.to},change:u.undo.profileId.change}:void 0)],y=!1;for(let u of m)if(await u(),e.signal?.aborted){y=!0;break}let P=E.map(u=>{let a=[...u.undo.kept,...u.refused.map(({change:I,why:R})=>({change:I,why:R}))];return{username:u.user.applied.username,userId:u.user.applied.userId,undone:u.undone,...a.length>0?{kept:a}:{}}}),$=P.reduce((u,a)=>u+(a.kept?.length??0),0),b=y?"cancelled":$>0?"partial":"success",p={...c,removals:[...c.removals??[],{at:t().toISOString(),status:b,undone:P.reduce((u,a)=>u+a.undone.length,0),kept:$,codes:[...new Set(E.flatMap(u=>u.refused.map(a=>a.code)))].slice(0,50)}]};return await n.write(p),{org:e.organization,run:r,status:b,users:P,apiRequests:i()}}import{randomBytes as In}from"node:crypto";import{open as Ts,readFile as Rn,readdir as An,rename as vn,rm as bn}from"node:fs/promises";import{homedir as En}from"node:os";import{join as Ae,resolve as On}from"node:path";var $n="users";function Cs(e=process.env){let s=e.SANDFORGE_JOURNAL_DIR,n=s!==void 0&&s.trim()!==""?On(s):Ae(En(),".sandforge");return Ae(n,$n)}var Ke=es.datetime({offset:!0}),Be=be().int().nonnegative(),Je=be().int().positive().max(999999),Pn=ee({isActive:le(),isFrozen:le(),profileId:re().regex(/^00e[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/)}),kn=ee({id:re().regex(/^(?:0Pa|011)[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/),what:ie(["permissionSet","permissionSetGroup","group"]),name:re().regex(/^[A-Za-z][A-Za-z0-9_]*$/).max(80),type:ie(["Regular","Queue"]).optional()}),Nn=ee({applied:ts,after:Pn,accesses:te(kn).max(pe+me+ge),inFile:le()}),_n=ee({at:Ke,status:ie(["success","partial","failure","cancelled"]),undone:Be,kept:Be,codes:te(re().regex(/^[A-Z][A-Z_]{1,63}$/)).max(50)}),He=ee({version:Ye(1),organizationId:ss,run:Je,replaces:Je.optional(),status:ie(["running","success","partial","failure","cancelled"]),startedAt:Ke,endedAt:Ke.optional(),emailsToPeople:Be,users:te(Nn).max(2*fe),removals:te(_n).max(1e3).optional()});function xn(e){return`refused with ${e}; the org\u2019s words are not kept, as they may name the person`}function zs(e){return{...e,users:e.users.map(s=>s.applied.refused===void 0?s:{...s,applied:{...s.applied,refused:s.applied.refused.map(n=>({...n,message:xn(n.code)}))}})}}var zn=/^run-([1-9]\d{0,5})\.json$/,ve=class{root;guard;constructor(s){this.guard=s.guard??new Is,this.root=this.guard.assertOutsideRepo(s.root)}folderOf(s){return this.guard.assertOutsideRepo(Ae(this.root,Pe(s)))}fileOf(s,n){return Ae(this.folderOf(s),`run-${Je.parse(n)}.json`)}async begin(s,n){let r=this.folderOf(s);await ws(r);for(let t=await this.highest(s)+1;;t+=1){let o=He.parse(zs({...n,version:1,organizationId:Pe(s),run:t})),i;try{i=await Ts(this.fileOf(s,t),"wx",$e)}catch(g){if(g.code==="EEXIST")continue;throw g}try{await i.writeFile(`${JSON.stringify(o,null,2)}
8
+ `,"utf8"),await i.sync()}finally{await i.close()}return o}}async write(s){let n=He.parse(zs(s));await Tn(this.fileOf(n.organizationId,n.run),`${JSON.stringify(n,null,2)}
9
+ `)}async read(s,n){let r;try{r=await Rn(this.fileOf(s,n),"utf8")}catch(t){if(t.code==="ENOENT")return;throw t}try{let t=He.safeParse(JSON.parse(r));return t.success&&t.data.run===n?t.data:void 0}catch{return}}async list(s){let n=[];for(let r of(await this.numbers(s)).sort((t,o)=>o-t)){let t=await this.read(s,r);t&&n.push(t)}return n}async numbers(s){let n;try{n=await An(this.folderOf(s))}catch(r){if(r.code==="ENOENT")return[];throw r}return n.flatMap(r=>{let t=zn.exec(r);return t?[Number(t[1])]:[]})}async highest(s){return Math.max(0,...await this.numbers(s))}};async function Tn(e,s){let n=`${e}.${process.pid}-${In(4).toString("hex")}.tmp`,r=await Ts(n,"wx",$e);try{try{await r.writeFile(s,"utf8"),await r.sync()}finally{await r.close()}await vn(n,e)}catch(t){throw await bn(n,{force:!0}),t}}var Ve="sandforge-users",Ls="AUTOMATION_NOT_ACCEPTED",Fn="USERS_RUN_NOT_FOUND",Mn="USERS_RUN_REPLACED",qn=`sandforge users \u2014 set up the users of a sandbox handed back to its testers, a scratch org
10
+ or a Developer Edition org: an address the copy put under .invalid asked back, a user activated,
11
+ frozen or unfrozen, a profile, permission sets, permission set groups, groups and queues given;
12
+ and take a run back.
13
+
14
+ It is what sandforge env runs for a users resource of sandforge.yaml, which it applies before
15
+ every other resource and takes back after them all; it runs alone as well.
16
+
17
+ Usage:
18
+ npx sandforge users plan --org <alias> --config <file.json> [options]
19
+ npx sandforge users apply --org <alias> --config <file.json> (--dry-run | --yes) [options]
20
+ npx sandforge users remove --org <alias> --run <n> [--yes] [options]
21
+
22
+ Verbs:
23
+ plan read the org and say, user by user, what a run would change; the
24
+ licenses it takes, the emails Salesforce would send to people, what
25
+ the org runs as users are written, the requests an apply sends, and
26
+ each refusal a run would meet. Nothing is written. Exit 1 when a
27
+ run would be refused
28
+ apply the plan, then, when nothing refuses it, the writes in this order:
29
+ profiles; deactivations, then activations; freezes and unfreezes;
30
+ permission sets and their groups; groups and queues; the addresses
31
+ last, so that a run stopped before has mailed nobody; then a read
32
+ of what it wrote. The run is kept on this machine as run <n> before
33
+ its first write, and again after each step
34
+ remove take run <n> back: the memberships and assignments it created,
35
+ each by its id, then each freeze, activation and profile put back
36
+ as it was before the run, where the org still holds what the run
37
+ left. An assignment or a membership the user held before is never
38
+ touched
39
+
40
+ Required:
41
+ --org <alias> sf CLI alias of the sandbox, scratch org or Developer
42
+ Edition org. A production org is refused before
43
+ anything of it is read, whatever the verb, and nothing
44
+ lifts it
45
+ --config <file.json> (plan, apply) the users to set up, as a users resource
46
+ of sandforge.yaml lists them (below)
47
+ --run <n> (remove) the run to take back, as apply named it
48
+
49
+ Options:
50
+ --dry-run (apply) the plan, nothing written: what the run would
51
+ change and the requests it would send
52
+ --yes (apply, remove) do not ask; without it and with no
53
+ terminal, stop at the question, exit 2
54
+ --replaces <n> (plan, apply) the run this one replaces, which
55
+ sandforge env names: converge from what it held \u2014 add
56
+ what is missing, take back what it added that the
57
+ config no longer names, put a user it no longer lists
58
+ back as it was. Never all taken back then done again
59
+ --accept-user-emails (plan, apply) let Salesforce email the people whose
60
+ address is asked back: the confirmation link, a system
61
+ email, which leaves under System email only too.
62
+ USERS_EMAILS_NOT_ACCEPTED, exit 1, without it, as soon
63
+ as one address is asked
64
+ --accept-emails (plan, apply) ask addresses back in an org that
65
+ delivers all email (Setup > Deliverability, read with
66
+ one line of anonymous Apex that sends nothing), where
67
+ what runs there emails these people from then on.
68
+ USERS_EMAILS_OPEN, exit 1, without it; set the org to
69
+ System email only until the masking is done instead
70
+ --accept-automation (plan, apply, remove) write although the org runs
71
+ flows, Apex triggers, processes or workflow rules as a
72
+ user or a login is written, or could not say what it
73
+ runs: AUTOMATION_NOT_ACCEPTED, exit 1, nothing
74
+ written, without it. sandforge env gives it for a
75
+ resource that says accept: { automation: true }
76
+ --include-changed (remove) put back a profile someone changed since the
77
+ run all the same
78
+ --json print the answer as JSON on stdout, every other line on
79
+ stderr
80
+ -h, --help show this help and exit
81
+
82
+ The config, JSON:
83
+ {"defaults": {"email": "restore", "frozen": false},
84
+ "users": [{"username": "jane.qa@acme.com", "permissionSets": ["QA_Tools"], "groups": ["QA_Team"]},
85
+ {"username": "paul.qa@acme.com", "active": true, "profile": "QA Tester"}]}
86
+
87
+ users 1 to ${fe}, each username once, whatever its case
88
+ username production's (jane.qa@acme.com) or the sandbox's whole
89
+ (jane.qa@acme.com.uat): read as given, then as given
90
+ followed by .<sandbox>, which must name exactly one user
91
+ email restore asks back the address the copy put under
92
+ .invalid; keep (the default) leaves it
93
+ active, frozen true or false; absent, left as they are
94
+ profile Profile.Name, exact, in the org's language for a
95
+ standard profile
96
+ permissionSets API names, ${pe} at most
97
+ permissionSetGroups API names, ${me} at most
98
+ groups DeveloperName of a public group or a queue, ${ge} at most
99
+ defaults the same keys but username; a key a user gives
100
+ replaces the default's whole, a list included
101
+
102
+ What it never does: take away an assignment, a membership or a permission set
103
+ the config does not name; delete a user, which Salesforce does not do; reset a
104
+ password \u2014 once an address is restored, its owner asks for one with
105
+ "Forgot your password?" on the sandbox's login page; or put an address back
106
+ under .invalid. An address asked back is not restored at once: Salesforce
107
+ mails a link to it and keeps the old one until the link is clicked
108
+ (${we} h). The run says it awaits its owner; a later plan reads it restored.
109
+
110
+ Refused before its first write, exit 1, nothing written: a production org, or
111
+ one that will not say what it is; USERS_NO_USER, a username no user has;
112
+ USERS_TWO_USERS, one two users have; USERS_NO_RIGHT, a connection without
113
+ Manage Users; USERS_SELF, the user connected frozen, deactivated or given
114
+ another profile; USERS_LICENSE, more activations or profiles than the licenses
115
+ have free, counted on the whole plan; USERS_PROFILE_UNKNOWN,
116
+ USERS_PERMISSION_SET_UNKNOWN, USERS_GROUP_UNKNOWN, a name the org does not
117
+ hold, its close names listed; USERS_PERMISSION_SET_LICENSE, a permission set
118
+ whose license the user lacks; USERS_EMAILS_NOT_ACCEPTED, USERS_EMAILS_OPEN and
119
+ AUTOMATION_NOT_ACCEPTED, above; USERS_RUN_NOT_FOUND, a run this machine does
120
+ not keep for the org (a refreshed sandbox answers another Organization Id);
121
+ USERS_RUN_REPLACED, a run to replace that another run replaced already.
122
+
123
+ Each run is kept in <SANDFORGE_JOURNAL_DIR, or ~/.sandforge>/users/<Organization
124
+ Id>/run-<n>.json, its owner's alone and never inside a repository: ids,
125
+ usernames, booleans and the names of profiles, permission sets and groups;
126
+ never an address, never a person's name.
127
+
128
+ Exit codes:
129
+ 0 plan: a run would go; apply: every user set up, an address awaiting its
130
+ owner included, said; remove: everything put back
131
+ 1 refused before its first write, every refusal said (the plan, the dry run
132
+ and the apply alike), or the org could not be reached
133
+ 2 a bad command line or config, or a question with no terminal to answer it
134
+ (give --yes)
135
+ 3 partial: the org refused a write the plan took for possible \u2014 a license
136
+ taken since, a deactivation it will not do \u2014, the user named in the org's
137
+ code and words, the others set up; or a removal kept something, said why
138
+ 130 Ctrl-C (143 SIGTERM, 129 SIGHUP): the run ends after the step under
139
+ way, its file saying what it holds, for remove to take back
140
+ `,Dn=["plan","apply","remove"],Fs={words:1,switches:["--dry-run","--yes","--json","--accept-user-emails","--accept-emails","--accept-automation","--include-changed"],values:["--org","--config","--run","--replaces"]},Ms=["--org","--config","--replaces","--accept-user-emails","--accept-emails","--accept-automation","--json"],qs={plan:Ms,apply:[...Ms,"--dry-run","--yes"],remove:["--org","--run","--include-changed","--accept-automation","--yes","--json"]};function D(e){process.stderr.write(`${e} Nothing was run. Run with --help.
141
+ `),process.exit(2)}function Ds(e,s){return/^[1-9]\d{0,5}$/.test(s)||D(`${e} takes a run's number, as apply named it: "${s}" is not one.`),Number(s)}function Wn(e){let[s]=e;s===void 0&&D("Name the verb: plan, apply or remove."),Dn.includes(s)||D(s.startsWith("-")?`"${s}" comes before the verb: name plan, apply or remove first.`:`"${s}" is not a verb of ${ce(Ve)}: plan, apply or remove.`);let n=s,r=ds(e,Fs);r!==void 0&&D(r.replace(/ Nothing was run\.$/,""));let t=new Map,o=new Set;for(let w=1;w<e.length;w++){let h=e[w];Fs.values.includes(h)?(t.has(h)&&D(`${h} is given twice.`),t.set(h,e[w+1]),w++):o.add(h)}for(let w of[...t.keys(),...o])qs[n].includes(w)||D(`${w} is not read by ${n}: it reads ${qs[n].join(", ")}.`);let i=t.get("--org");i===void 0&&D(`${n} needs --org <alias>.`),us.test(i)||D(`--org takes an sf alias or a username: "${i}" is neither (letters, digits, _ . @ + and -, not first . @ + or -).`);let g=t.get("--config");n!=="remove"&&g===void 0&&D(`${n} needs --config <file.json>.`);let c=t.get("--run");n==="remove"&&c===void 0&&D("remove needs --run <n>.");let d=t.get("--replaces");return n==="apply"&&o.has("--dry-run")&&o.has("--yes")&&D("--dry-run writes nothing and --yes writes: give one of them."),{verb:n,org:i,...g!==void 0?{config:g}:{},...c!==void 0?{run:Ds("--run",c)}:{},...d!==void 0?{replaces:Ds("--replaces",d)}:{},dryRun:o.has("--dry-run"),yes:o.has("--yes"),json:o.has("--json"),acceptUserEmails:o.has("--accept-user-emails"),acceptEmails:o.has("--accept-emails"),acceptAutomation:o.has("--accept-automation"),includeChanged:o.has("--include-changed")}}function jn(e){let s;try{s=Ln(e,"utf8")}catch(t){D(`--config ${e} could not be read (${X(t)}).`)}let n;try{n=JSON.parse(s)}catch(t){D(`--config ${e} is not JSON (${X(t)}).`)}let r=ns.safeParse(n);if(!r.success){let t=r.error.issues.map(o=>{let i=o.path.map((g,c)=>typeof g=="number"?`[${g}]`:`${c===0?"":"."}${String(g)}`).join("");return i===""?o.message:`${i}: ${o.message}`});D(`--config ${e}: ${t.join("; ")}.`)}return rs(r.data)}var Gn={scratch:"scratch org",developer:"Developer Edition org",sandbox:"sandbox"};function de(e){let s=n=>n==="added"?"added":"taken back";switch(e.what){case"email":return"address asked back";case"active":return e.to?"activated":"deactivated";case"frozen":return e.to?"frozen":"unfrozen";case"profile":return`profile ${e.to} in place of ${e.from}`;case"permissionSet":return`permission set ${e.name} ${s(e.to)}`;case"permissionSetGroup":return`permission set group ${e.name} ${s(e.to)}`;case"group":return`${e.type==="Queue"?"queue":"group"} ${e.name} ${s(e.to)}`}}var Hn=`address awaiting its owner's confirmation \u2014 Salesforce sent the link to it; until it is clicked (${we} h), the address stays .invalid`;function Qe(e){return`${e.alias??e.organizationId} (${Gn[e.kind]}, ${e.organizationId})`}function Kn(e){return e.map(s=>gs(s,"a run now"))}function Bn(e,s){let n=s.edition?`IsSandbox false, edition ${s.edition}`:"IsSandbox false, and no edition";return`${e} is a production org (its Organization record says ${n}): ${ce(Ve)} sets up the users of a sandbox, a scratch org or a Developer Edition org, and reads nothing of a production org. Nothing was read or written.`}async function Gs(e){let s;try{s=await cs(e)}catch(g){process.stderr.write(`${X(g)}
142
+ `),process.exit(1)}let n=ls(s),r=0,t;try{t=await os({query:(g=>(r+=1,n.query(g)))})}catch(g){process.stderr.write(`${fs(e,g,{tool:ce(Ve),action:"write",readOnly:"plan"})}
143
+ `),process.exit(1)}as(t)&&(process.stderr.write(`${Bn(e,t)}
144
+ `),process.exit(1));let o=As(n),i=await o.identity();return U(i.organizationId)!==U(t.id)&&(process.stderr.write(`The session sf gave for ${e} is of ${i.organizationId}, and its Organization record says ${t.id}: nothing was read or written. Sign in to ${e} again with sf.
145
+ `),process.exit(1)),{conn:n,org:o,organization:{organizationId:t.id,kind:s.scratch===!0?"scratch":t.sandbox?"sandbox":"developer",alias:e,username:i.username},typingRequests:r}}function Hs(){try{return new ve({root:Cs()})}catch(e){process.stderr.write(`${X(e)} Nothing was read or written.
146
+ `),process.exit(1)}}var Ks={before:"before save",after:"after save",beforeAndAfter:"before and after save"},Bs={flows:"the flows",triggers:"the Apex triggers",processes:"the Process Builder processes",workflowRules:"the workflow rules"};function Js(e,s){return e==="flow"?`flow "${s}"`:e==="process"?`process "${s}"`:e==="workflowRule"?`workflow rule "${s}"`:`Apex trigger ${s}`}async function Xs(e,s,n){if(n.length===0)return{kind:"none"};try{return{kind:"read",automation:await new Ss(Us(async()=>e)).read(s,n)}}catch(r){return{kind:"unread",reason:X(r)}}}function Vs(e){return e.kind==="read"?is(e.automation,"update"):[]}function Qs(e,s,n){if(e.kind==="none")return["automation: none read: this run writes no user and no login"];if(e.kind==="unread")return[`automation: what ${s} runs as ${n} could not be read (${e.reason})`];let r=Vs(e),t=ke(e.automation);return r.length===0&&t.length===0?[`automation: ${s} runs nothing as ${n}`]:[...r.length>0?[`automation: ${s} runs as ${n}:`]:[],...r.map(o=>` ${o.objectApiName}: ${Js(o.kind,o.name)} (${Ks[o.when]})`),...t.map(({part:o,reason:i})=>` ${Bs[o]??o} of ${s} could not be read: ${i}`)]}function Zs(e,s,n,r){if(r||e.kind==="none")return;let t=`Nothing was written. Add --accept-automation to write all the same (accept: { automation: true } on the users resource of sandforge.yaml), or turn that automation off in ${s} first.`;if(e.kind==="unread")return{code:Ls,message:`What ${s} runs as ${n} could not be read (${e.reason}), so what fires is not known. ${t}`};let o=Vs(e),i=ke(e.automation);if(o.length===0&&i.length===0)return;let g=[];if(o.length>0){let c=o.map(d=>`${d.objectApiName}: ${Js(d.kind,d.name)} (${Ks[d.when]})`);g.push(`${s} runs automation as ${n}: ${c.join("; ")}.`)}for(let{part:c,reason:d}of i)g.push(`${Bs[c]??c} of ${s} could not be read (${d}), so what fires as ${n} is not known.`);return g.push(t),{code:Ls,message:g.join(" ")}}function Xe(e){return e.kind==="read"?e.automation.requests:0}function Jn(e){let s=e.users.some(r=>r.writes.profileId!==void 0||r.writes.isActive!==void 0||r.writes.email!==void 0),n=e.users.some(r=>r.writes.isFrozen!==void 0);return[...s?["User"]:[],...n?["UserLogin"]:[]]}function Xn(e){let s=e.users.some(r=>r.after.isActive!==r.applied.before.isActive||U(r.after.profileId)!==U(r.applied.before.profileId)),n=e.users.some(r=>r.after.isFrozen!==r.applied.before.isFrozen);return[...s?["User"]:[],...n?["UserLogin"]:[]]}function Ws(e){let{reading:s}=e;return"unread"in s?"unread":s.level==="all"?"open":"closed"}function Vn(e,s){let{reading:n}=e;return"unread"in n?`deliverability: not read (${n.unread})`:n.level==="all"?`deliverability: All email \u2014 what runs in ${s} emails the addresses its records hold`:"deliverability: closed \u2014 System email only or No access: what runs there emails nobody. Which of the two, no API says."}function Ys(e){return s=>(e?process.stderr:process.stdout).write(`${s}
147
+ `)}function Y(e){process.stdout.write(`${JSON.stringify(e,null,2)}
148
+ `)}function Qn(e,s,n){return{org:e,users:[],emailsToPeople:0,apiRequests:n,refusals:[s]}}async function Zn(e,s,n){let r=await e.read(s,n);if(!r)return{refusal:{code:Fn,message:`--replaces ${n}: this machine keeps no run of that number for this org, whose Organization Id is ${s}: a sandbox refreshed since answers another, and its runs went with the copy they set up. Plan without --replaces to set the users up anew`}};let t=(await e.list(s)).find(o=>o.replaces===n);return t?{refusal:{code:Mn,message:`run ${n} was replaced by run ${t.run}, which holds what it set up: --replaces ${t.run}`}}:{record:r}}function Yn(e,s,n){let r=n.org,t=[`plan of the users of ${Qe(e.org)}`];for(let o of e.users){let i=o.given!==void 0?`${o.username} (${o.given} in the config)`:o.username,g;o.userId===void 0?g="no single user has this username (below)":o.changes.length>0?g=o.changes.map(de).join(", "):o.address==="awaiting"?g="its address asked back by an earlier run, awaiting its owner's click":g="as the config says already: nothing to do",t.push(` ${i}: ${g}`)}return e.licenses!==void 0&&t.push(`licenses: ${e.licenses.map(o=>`${o.name} ${o.used} of ${o.total} used, ${o.toUse} more`).join("; ")}`),e.emailsToPeople>0&&t.push(`emails to people: ${e.emailsToPeople}, the confirmation of each address asked back, a system email, which leaves under System email only too`+(n.acceptUserEmails?"; accepted (--accept-user-emails)":"")),s.deliverability!==void 0&&t.push(Vn(s.deliverability,r)),t.push(...Qs(s.automation,r,"users are written")),t.push(`API requests: ${s.sent} sent by this plan; an apply sends about ${e.apiRequests}`),t.push(...Kn(e.refusals??[])),t}function er(e,s){let n=[`run ${e.run} of the users of ${Qe(e.org)}: ${e.status}`];for(let r of e.users){let t=r.done.filter(o=>o.what!=="email");t.length>0&&n.push(` ${r.username}: ${t.map(de).join(", ")}`),r.address==="awaiting"&&r.done.some(o=>o.what==="email")&&n.push(` ${r.username}: ${Hn}`),r.address==="restored"&&r.done.some(o=>o.what==="email")&&n.push(` ${r.username}: address restored`);for(let o of r.refused??[])n.push(` ${r.username}: refused ${de(o.change)}: ${o.code} ${o.message}`);r.done.length===0&&(r.refused??[]).length===0&&n.push(` ${r.username}: nothing to do`)}return n.push(`taken back by: ${Ze("users")} remove --org ${s} --run ${e.run} --yes`),n.push(`API requests: ${e.apiRequests}`),n}function sr(e,s){let n=[`removal of run ${e.run} of the users of ${s}: ${e.status}`];for(let r of e.users){n.push(` ${r.username}: ${r.undone.length>0?r.undone.map(de).join(", "):"nothing put back"}`);for(let t of r.kept??[])n.push(` ${r.username}: kept ${de(t.change)}: ${t.why}`)}for(let r of e.refusals??[])n.push(se(r));return n.push(`API requests: ${e.apiRequests}`),n}function en(e,s){return e==="cancelled"?ps(s??"SIGINT"):e==="partial"?3:e==="failure"?1:0}function sn(){let e=new AbortController,s,n=ms(r=>{s=r,process.stderr.write(`
149
+ interrupted: the run ends after the step under way, its file saying what it holds (Ctrl-C again ends it at once)
150
+ `),e.abort()});return{signal:e.signal,stopped:()=>s,release:n}}async function nr(e,s){let n=Ys(e.json),r=await Gs(e.org),{conn:t,org:o,organization:i}=r,g=Hs(),c=m=>r.typingRequests+o.requests()+m,d;if(e.replaces!==void 0){let m=await Zn(g,i.organizationId,e.replaces);if("refusal"in m){let y=Qn(i,m.refusal,c(0));n(`plan of the users of ${Qe(i)}`),process.stderr.write(`${se(m.refusal)}
151
+ `),e.json&&Y(y),V(1);return}d=m.record}let w=await Ue(o,s,{now:new Date,...d?{previous:d}:{}}),h={...d?{previous:d}:{},acceptUserEmails:e.acceptUserEmails,acceptEmails:e.acceptEmails},S=ae(w,s,h),O;S.emailsToPeople>0&&(O=await hs(t),S=ae(w,s,{...h,deliverability:Ws(O)}));let k=await Xs(t,e.org,Jn(S)),L=Zs(k,e.org,"users are written",e.acceptAutomation),F=()=>(O?.requests??0)+Xe(k),x=c(F()),W=ye(S,i,x+w.requests),l=[...W.refusals??[],...L?[L]:[]],A={...W,...l.length>0?{refusals:l}:{}};for(let m of Yn(A,{...O?{deliverability:O}:{},automation:k,sent:x},e))n(m);if(e.verb==="plan"||e.dryRun){e.dryRun&&n("a dry run: nothing was written"),e.json&&Y(A),V(l.length>0?1:0);return}if(l.length>0){for(let m of l)process.stderr.write(`${se(m)}
152
+ `);process.stderr.write(`Nothing was written.
153
+ `),e.json&&Y(A),V(1);return}let E=A.users.filter(m=>m.changes.length>0).length;if(!e.yes){let m=`Set up ${E} user${E===1?"":"s"} of ${e.org} as above`+(A.emailsToPeople>0?`, Salesforce emailing ${A.emailsToPeople} ${A.emailsToPeople===1?"person":"people"}?`:"?");if(!await Ne(m)){n("Nothing was written.");return}}let v=sn(),N;try{N=await Ns({org:o,organization:i,users:s,store:g,signal:v.signal,...h,...O?{deliverability:Ws(O)}:{}})}finally{v.release()}if(N.kind==="refused"){let m=N.plan;for(let y of m.refusals??[])process.stderr.write(`${se(y)}
154
+ `);process.stderr.write(`The org changed since the plan read it. Nothing was written.
155
+ `),e.json&&Y(m),V(1);return}let f={...N.answer,apiRequests:c(F())};for(let m of er(f,e.org))n(m);e.json&&Y(f),V(en(f.status,v.stopped()))}async function rr(e){let s=Ys(e.json),n=e.run??0,r=await Gs(e.org),{conn:t,org:o,organization:i}=r,g=Hs(),c={kind:"none"},d=await g.read(i.organizationId,n),w=d!==void 0&&(await g.list(i.organizationId)).some(k=>k.replaces===n);if(d!==void 0&&!w){c=await Xs(t,e.org,Xn(d));let k=Zs(c,e.org,"users are put back",e.acceptAutomation);if(c.kind!=="none")for(let L of Qs(c,e.org,"users are put back"))s(L);if(k!==void 0){let L={org:i,run:n,status:"failure",users:[],apiRequests:r.typingRequests+o.requests()+Xe(c),refusals:[k]};process.stderr.write(`${se(k)}
156
+ `),e.json&&Y(L),V(1);return}if(!e.yes&&!await Ne(`Take back run ${n} of the users of ${e.org}?`)){s("Nothing was written.");return}}let h=sn(),S;try{S=await xs({org:o,organization:i,store:g,run:n,includeChanged:e.includeChanged,signal:h.signal})}finally{h.release()}let O={...S,apiRequests:r.typingRequests+o.requests()+Xe(c)};for(let k of sr(O,e.org))s(k);e.json&&Y(O),V(en(O.status,h.stopped()))}async function tr(e=process.argv){let s=e.slice(2);if(s.includes("--help")||s.includes("-h")){process.stdout.write(qn);return}let n=Wn(s);if(n.verb==="remove"){await rr(n);return}await nr(n,jn(n.config??""))}/sandforge-users\.[cm]?[jt]s$/.test(process.argv[1]??"")&&(ys(),tr().then(()=>process.exit(process.exitCode??0)).catch(e=>{process.stderr.write(`${e instanceof Error?e.stack??e.message:String(e)}
157
+ `),process.exit(1)}));export{Ls as AUTOMATION_NOT_ACCEPTED,qn as HELP,Fs as USERS_FLAGS,Fn as USERS_RUN_NOT_FOUND,Mn as USERS_RUN_REPLACED,de as changeWords,tr as main,Wn as parseArgs,jn as readConfig,Bn as usersProductionRefusal};
package/lib/sandforge.mjs CHANGED
@@ -4,25 +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 s}from"./chunk-SCKUIE3R.mjs";import"./chunk-NTOVCTRS.mjs";import{readFileSync as d}from"node:fs";import{extname as c,join as i}from"node:path";import{pathToFileURL as p}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",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",seed:"fill an org from a seed template",sync:"run a Sync between two orgs"},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 l(){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, sandforge.yaml environments, and
9
- 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 f(o,e=__dirname,n=__filename){return i(e,`sandforge-${o}${c(n)}`)}function g(o=__dirname){let e=JSON.parse(d(i(o,"..","package.json"),"utf8"));return typeof e.version=="string"?e.version:"0.0.0"}var h=o=>import(p(o).href);async function u(o=process.argv,e=h){let n=m(o.slice(2));switch(n.kind){case"help":process.stdout.write(l());return;case"version":process.stdout.write(`${g()}
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=f(n.tool);process.argv=[o[0]??process.execPath,t,...n.args],await e(t);return}}}/(?:^|[\\/])sandforge\.[cm]?[jt]s$/.test(process.argv[1]??"")&&u().catch(o=>{process.stderr.write(`${o instanceof Error?o.message:String(o)}
28
- `),process.exit(1)});export{r as TOOLS,m as dispatchOf,l as helpText,u as main,f as toolFile,g as versionOf};
7
+ import{a,b,c,d,e,f}from"./chunk-A32ISQ6M.mjs";import"./chunk-SCKUIE3R.mjs";import"./chunk-NTOVCTRS.mjs";export{a as TOOLS,b as dispatchOf,c as helpText,f as main,d as toolFile,e as versionOf};
@@ -0,0 +1,20 @@
1
+ export default class SandforgeCommand {
2
+ static summary = "run an Autopilot copy between two orgs";
3
+ static description = "sandforge autopilot — run an Autopilot copy between two orgs, without the editor.\n\nThe whole help, its options and its exit codes: sf sandforge autopilot --help.";
4
+ static hidden = false;
5
+ static strict = false;
6
+ static flags = {};
7
+ static args = {"argv":{"name":"argv","description":"the words npx sandforge autopilot takes"}};
8
+ static async run(argv) {
9
+ const [major, minor] = process.versions.node.split('.').map(Number);
10
+ if (major < 20 || (major === 20 && minor < 19)) {
11
+ process.stderr.write(
12
+ 'sandforge needs Node.js 20.19 or later, and this is ' + process.versions.node + '. Nothing was run.\n',
13
+ );
14
+ process.exitCode = 1;
15
+ return;
16
+ }
17
+ const { runTool } = await import('../../sfPlugin.mjs');
18
+ await runTool("autopilot", argv);
19
+ }
20
+ }
@@ -0,0 +1,20 @@
1
+ export default class SandforgeCommand {
2
+ static summary = "take and restore DataOps snapshots";
3
+ static description = "sandforge backup — take and restore DataOps snapshots, without the editor.\n\nThe whole help, its options and its exit codes: sf sandforge backup --help.";
4
+ static hidden = false;
5
+ static strict = false;
6
+ static flags = {};
7
+ static args = {"argv":{"name":"argv","description":"the words npx sandforge backup takes"}};
8
+ static async run(argv) {
9
+ const [major, minor] = process.versions.node.split('.').map(Number);
10
+ if (major < 20 || (major === 20 && minor < 19)) {
11
+ process.stderr.write(
12
+ 'sandforge needs Node.js 20.19 or later, and this is ' + process.versions.node + '. Nothing was run.\n',
13
+ );
14
+ process.exitCode = 1;
15
+ return;
16
+ }
17
+ const { runTool } = await import('../../sfPlugin.mjs');
18
+ await runTool("backup", argv);
19
+ }
20
+ }