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,272 @@
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{q as Nt}from"./chunk-LAUOSXMN.mjs";import{a as It}from"./chunk-GCGHHN4K.mjs";import{i as _t,j as pe,k as Bt,m as Ut,n as Pe,o as Wt,p as Gt,q as qt,r as Vt,s as he,t as me,y as Kt}from"./chunk-IRZJU2PG.mjs";import{e as xt,g as Mt}from"./chunk-Y4TDVDP2.mjs";import{f as Dt,h as Pt}from"./chunk-JJITOWZK.mjs";import{a as Ht}from"./chunk-TW3N6W5Z.mjs";import{Db as Lt,Wa as oe,c as je,d as Le,e as bt,f as At,h as $t,i as Ne,j as kt,k as Rt,l as St,lb as Ie,m as Ot,mb as Tt,pb as De,q as Ft,qb as fe,sb as zt,tb as ne,xb as Ct,yb as jt}from"./chunk-3HEMJTAP.mjs";import{a as te,d as gt,j as Ce}from"./chunk-BNKT3R3F.mjs";import{a as yt,b as vt}from"./chunk-QROPNEGY.mjs";import{b as de,e as at}from"./chunk-BZ24IAP5.mjs";import{a as ke}from"./chunk-SCKUIE3R.mjs";import{c as ee,d as ue}from"./chunk-6FARZYMJ.mjs";import{b as le}from"./chunk-ISSP2FZ5.mjs";import{m as wt}from"./chunk-P55MKIZX.mjs";import{d as ut}from"./chunk-T63U4OZJ.mjs";import{a as Ee,c as Fe,d as Te,j as Z}from"./chunk-HKUWHVI7.mjs";import{b as st,c as Se}from"./chunk-LHU6CPGE.mjs";import{Ic as ht,Jc as mt,eb as ze,hb as ce,kb as ct,lb as ft,mc as J,tc as pt}from"./chunk-JFNLKHY6.mjs";import{q as lt}from"./chunk-VZVICK7Q.mjs";import{b as rt,f as it,g as dt,h as Et}from"./chunk-LCDPCUXS.mjs";import{E as Oe}from"./chunk-KIMQQ6JQ.mjs";import{Jc as et,Jd as tt,Kd as Re,Ld as ie,Md as ot,Td as nt}from"./chunk-ZQO5PDX5.mjs";import{existsSync as _e,mkdirSync as mo,readdirSync as go,readFileSync as ve}from"node:fs";import{dirname as wo,join as G}from"node:path";import{homedir as yo}from"node:os";var vo=`sandforge frozen \u2014 build and replay a Frozen Dataset, without the editor.
8
+
9
+ Usage:
10
+ npx sandforge frozen <step> --config <file> [options]
11
+
12
+ Steps:
13
+ select pick one root per combination of the coverage matrix (needs --source)
14
+ extract read, pseudonymize, check and freeze those roots (needs --source)
15
+ load replay the frozen dataset into a sandbox or a Developer Edition
16
+ \u2014 WRITES (needs --target);
17
+ what the target runs as it inserts and updates is named first, and takes
18
+ --accept-automation or --mute-automation
19
+ verify check the last load against the dataset (needs --target)
20
+ remove delete the records a load created, the last first \u2014 DELETES (needs --target);
21
+ what the target runs as they go is named first, and takes --accept-automation
22
+ or --mute-automation; with --preview, say what it would delete, and delete
23
+ nothing
24
+ status what the store knows so far
25
+
26
+ Required:
27
+ --config <file> the project configuration, as the panel saves it (JSON)
28
+
29
+ Options:
30
+ --source <alias> sf CLI alias of the org the dataset is read from
31
+ --target <alias> sf CLI alias of the sandbox, or Developer Edition org, it is
32
+ loaded into
33
+ --author <name> who froze the dataset, for the manifest (default: sandforge)
34
+ --salt-file <file> the file holding the pseudonymization salt, when
35
+ SANDFORGE_FROZEN_SALT is not set
36
+ --store <file> where the run keeps its state (default: <sasDir>/cli-store.json)
37
+ --pilot load one root folder only
38
+ --reload replace the loads before: purge what earlier loads created,
39
+ then load again. Refused before anything is written when a
40
+ removal of those loads would leave records in the org \u2014
41
+ records changed since, kept for records that stay under them
42
+ (a contact made by hand since under one of their accounts,
43
+ which the org would delete along), of an object the user may
44
+ not delete, out of the user's sight or unread: take the load
45
+ back with remove first (--include-changed takes what changed
46
+ since, and what was added under them since). Refused as well
47
+ when one of them was recorded before loads kept what they
48
+ created, which no removal takes: refresh the sandbox, or find
49
+ what your user created that day with
50
+ ${ke("cleanup")}, its dry run
51
+ first, then delete it. Refused
52
+ the same way when the purge would have the org delete along a
53
+ record the reload finds again by its keys \u2014 a quote under the
54
+ opportunity an earlier load wrote: give that parent identity
55
+ keys too, or take the load back first. What the target's
56
+ automation likely made for a load holds nothing with --sweep,
57
+ which takes it first. What the target runs as the purge
58
+ deletes is read and named first, and nothing is written
59
+ while something fires unless --accept-automation or
60
+ --mute-automation answers it. The purge takes what those
61
+ loads created, not what the target's automation made for
62
+ them: --sweep takes that too. With --pilot, a reload purges
63
+ nothing, and is not asked
64
+ --gone-first <file> with load --reload --dry-run: the records taken back before
65
+ the reload runs, a JSON array of their ids \u2014 hanging from the
66
+ loads' records, they hold nothing. sandforge env gives it what
67
+ its apply takes back first; a reload that runs reads what is
68
+ still there
69
+ --max-total <n> with load: the most records it may insert \u2014 the count its dry
70
+ run gave. A load, or a reload, that would insert more is
71
+ refused before anything is written, the purge included; a dry
72
+ run says it would be, exit 1
73
+ --dry-run with load: say what the load would do \u2014 per object, what it
74
+ would insert, link, drop, rewrite and purge \u2014 and write nothing
75
+ --write-encrypted with load: write the fields the target encrypts as the dataset
76
+ holds them, though its manifest does not say its extraction
77
+ left out what it read masked \u2014 they may hold masks such as
78
+ ****1234 (left out otherwise, each named)
79
+ --mute-automation with load or remove: mute the target's automation for that
80
+ step through its own bypass \u2014 assign the user it writes as,
81
+ for the step alone, the permission sets holding the custom
82
+ permissions its flows, processes and workflow rules test to
83
+ stay quiet, those of what --sweep deletes included, and take
84
+ them back as it ends; what no bypass keeps quiet still runs,
85
+ and is named, and a load or a removal then needs
86
+ --accept-automation.
87
+ Refused on a production org and for a user who cannot assign
88
+ permission sets, exit 1; with --dry-run or --preview, says
89
+ what would be muted and assigns nothing
90
+ --accept-automation with load: write although the target runs flows, Apex
91
+ triggers, processes or workflow rules as the load inserts
92
+ its records and updates them \u2014 what --mute-automation
93
+ keeps quiet and a bypass the user holds aside \u2014 or could
94
+ not say what it runs; with remove, or load --reload:
95
+ delete although it runs them as the records go, those
96
+ --sweep deletes included \u2014 before or after a delete, or
97
+ as an activated order is set back to Draft for its
98
+ delete. Each is named before anything is written or
99
+ deleted; without the flag the load or the reload writes
100
+ nothing (AUTOMATION_NOT_ACCEPTED), the removal deletes
101
+ nothing, exit 1; --dry-run says so
102
+ --accept-emails with load: write although the target delivers every email
103
+ what still runs sends as the records go in, a reload's
104
+ purge and sweep included (Setup > Deliverability: All
105
+ email), or would not say whether it does: without it
106
+ such a load is refused, exit 1 (EMAILS_NOT_ACCEPTED),
107
+ nothing written. Read only when something that still
108
+ runs sends one, with one line of anonymous Apex that
109
+ sends nothing; on System email only or No access it is
110
+ not needed. The emails are counted too, on the records
111
+ of the dataset, at most, against what the target has
112
+ left today: past it, the load is refused whatever the
113
+ flag, exit 1 (FROZEN_EMAILS_EXCEEDED). --mute-automation
114
+ keeps quiet what tests the org's bypass; what an Apex
115
+ trigger sends is read nowhere. --dry-run says it all,
116
+ and what a load would be refused for
117
+ ${bt({run:"the load",simulation:"--dry-run",step:"with load: ",note:["Taken by this command once the load may write, before","the load's lease; deleted when the load is refused before","it writes or reports it wrote nothing, and kept when it","stops or fails part way: what it wrote then is not told","here."]})}
118
+ --include-changed remove also the records changed since the load, and what
119
+ was added to them since (kept otherwise); with load
120
+ --reload --sweep, the sweep of each load replaced takes
121
+ too what it finds changed since that load, which it
122
+ keeps and names otherwise, the load kept recorded for
123
+ a later sweep, and the reload no partial for them
124
+ --sweep with remove: before the load's records go, delete too what
125
+ the target's automation made for the load, that the
126
+ load's mapping does not hold: what the load's user
127
+ created under the load's records, what they point at,
128
+ or what hangs from those, three links at most, at most
129
+ a minute after the record it is tied to \u2014 in the
130
+ objects the load wrote and their children, tasks,
131
+ events, feed, email messages, notes, case comments, and
132
+ the objects the target's flows create; the window is
133
+ the load's writes, from a second before the first to a
134
+ minute after the last. What a record of the load points
135
+ at by a lookup the org refuses the delete for goes once
136
+ that record is gone. Listed and kept: what is tied to
137
+ the load but came later, up to 15 minutes, or as the
138
+ org's Automated Process user; and what the load's user
139
+ created in the window tied to nothing of it. Such
140
+ records then keep none of the load's records as records
141
+ that stay. A sweep refused, or that did not take all it was
142
+ asked to, exits 3, and ends partial a removal that took
143
+ every record of the load; one that left records of its own
144
+ keeps its own status. Once the load's records went already,
145
+ the sweep runs alone, the way to take what such a sweep
146
+ left (off otherwise: a removal that took the load's
147
+ records then reads what a sweep would take now, read
148
+ only, and names what stays and the option that takes
149
+ it, "notSwept" with --json). It sweeps too, each in its
150
+ own window, every other load recorded whose records
151
+ went \u2014 a load a reload replaced, kept for what its
152
+ sweep left \u2014, and lets it go once that sweep took all
153
+ it found. With load --reload: the sweep of each load
154
+ the reload replaces, as its removal sweeps it, around
155
+ the purge; what the target runs as it deletes is named
156
+ once it has read what it takes, before the first
157
+ delete, and answered as the purge's; with --dry-run, it
158
+ lists what it would take. One refused, or that did not
159
+ take all it was asked to, exits 3
160
+ --sweep-late with --sweep: take too what it lists as made late; with
161
+ --sweep-list, say what it would take
162
+ --sweep-untied with --sweep: take too what it lists as tied to nothing of
163
+ the load; with --sweep-list, say what it would take;
164
+ refused when another run wrote to the target
165
+ in the window \u2014 a load swept with it is none, a load
166
+ this command ran from another sas into the org is one
167
+ \u2014, or when that user created records in the window on
168
+ objects neither the load nor the automation reaches
169
+ (hand work, likely)
170
+ --sweep-list with remove: list what --sweep would delete, per object
171
+ with a few names and how many it ties to the load, and
172
+ for each other load it sweeps with it, and delete nothing;
173
+ exit 3 when it says a sweep is refused, as --sweep would
174
+ --preview with remove: say what the removal would do, per object \u2014 the
175
+ records it would delete, those it would keep as changed since
176
+ the load and who changed them, those gone already, those it
177
+ cannot see, and those it would leave because the user may not
178
+ delete them \u2014 what the target runs as they go, and what it
179
+ would be refused for, that automation without
180
+ --accept-automation included. It deletes nothing, writes
181
+ nothing to the sas and asks nothing; it exits 0 once it has
182
+ said it. It cannot know what hangs from the records, which a
183
+ removal reads at each object's turn. With --sweep, it lists
184
+ what the sweep would take, and reads what fires on it with
185
+ the load's own. Not with --sweep-list
186
+ --yes do not ask before a load writes or a removal deletes: a
187
+ removal asks last, once what it deletes and what the
188
+ target runs as they go are said. Without it, a step
189
+ with no terminal to answer the question \u2014 a CI step \u2014
190
+ stops there, exit 2, and writes nothing
191
+ --json emit what the panel would receive, every other line on
192
+ stderr; a step that ends before its request, refused or
193
+ with nothing to do, says "ended": true. Beside it, "step";
194
+ "dataset" \u2014 its folder, its digest (sha256 of the files a load
195
+ reads, the manifest less the verdict a verification writes
196
+ into it) and its version \u2014 for extract, load and verify;
197
+ "mapping", the file in the sas naming the records the loads
198
+ into the target created, for load, verify and remove; per
199
+ object, what the step counted ("objects"); how a load or a
200
+ removal ended ("status"); verify's verdict, and a load's, per
201
+ object ("verdict"); what a dry run or a
202
+ removal's preview would be refused for ("refusals"), with the
203
+ code of each ("refusalCodes"), as its line names it: a load
204
+ would be refused (CODE): ..., a removal would be refused
205
+ (CODE): ...; and what refused a load before it wrote \u2014 what
206
+ runs as it writes, its purge, its checkpoint, its emails or
207
+ its mute \u2014 or a removal
208
+ before its first delete \u2014 what fires as it deletes, its mute
209
+ or Production Guard \u2014 ("refused": {"code", "message"}), as
210
+ its line names it: refused (CODE): ...
211
+ --help this text
212
+
213
+ The salt that makes pseudonyms repeatable is read from SANDFORGE_FROZEN_SALT,
214
+ or else from --salt-file, and never made up here: an extraction without one is
215
+ refused. The editor keeps its own in VS Code's secret storage; copy it from there
216
+ with "SandForge: Copy Frozen Dataset Salt" to extract the same pseudonyms.
217
+
218
+ The graph a selection or an extraction discovers is kept in the sas
219
+ (discovery.json) and reused by the next one while the source's schema has not
220
+ changed and a day has not gone by: each says "graph reused from <step>" or
221
+ "rediscovered: <why>".
222
+
223
+ Ctrl-C stops a step after the call under way, a load recorded in the sas with
224
+ what it wrote, which remove takes back; a SIGTERM \u2014 a CI job cancelled or timed
225
+ out \u2014 or a SIGHUP stops it the same way. Ctrl-C again ends it at once.
226
+
227
+ Exit codes: 0 the step finished \u2014 a removal with nothing to take included, and a
228
+ removal's preview once said, its refusals included \u2014, and verify's verdict is
229
+ PASSED; 1 it failed or could not start, verify's verdict is FAILED, a dry run says
230
+ the load would be refused, a load was refused before it wrote for what the target
231
+ runs as it writes (AUTOMATION_NOT_ACCEPTED without --accept-automation), for its
232
+ emails (EMAILS_NOT_ACCEPTED without --accept-emails, FROZEN_EMAILS_EXCEEDED) or for
233
+ the data storage its records take past what the target has left
234
+ (FROZEN_STORAGE_EXCEEDED: --pilot, or a smaller dataset), or a removal
235
+ stopped before its first delete at what the target runs, without
236
+ --accept-automation; 2 a bad command line, or a question with
237
+ no terminal to answer it (give --yes); 3 verify's verdict is PARTIAL, a load
238
+ completed with errors, the verification it runs after it was FAILED or PARTIAL, or
239
+ the sweep of a reload did not take all it was asked to, or a removal left records
240
+ of the load or its sweep did not take all it was asked to; 4 verify's verdict is
241
+ UNSTABLE: no two readings agreed; 130 Ctrl-C stopped the step, 143 a SIGTERM, 129 a
242
+ SIGHUP. A load is judged by its own report, which ends partial on a verification
243
+ FAILED or PARTIAL; one UNSTABLE is said, and the verify step gives it a code.
244
+ `,Xt=["select","extract","load","verify","remove","status"],bo={words:1,switches:["--pilot","--reload","--dry-run","--write-encrypted","--mute-automation","--accept-automation","--include-changed","--accept-emails","--sweep","--sweep-list",...Ct,"--preview","--yes","--json",...Le.switches],values:["--config","--source","--target","--author","--salt-file","--store","--max-total","--gone-first",...Le.values]},Zt=1e6;function Ao(e){let t;try{t=JSON.parse(ve(e,"utf8"))}catch(o){process.stderr.write(`--gone-first: ${e} does not read: ${String(o)}
245
+ `),process.exit(2)}return(!Array.isArray(t)||!t.every(o=>typeof o=="string"&&/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(o)))&&(process.stderr.write(`--gone-first: ${e} holds no JSON array of record ids.
246
+ `),process.exit(2)),t}function $o(e){let t=e.slice(2);(t.includes("--help")||t.includes("-h")||t.length===0)&&(process.stdout.write(vo),process.exit(0));let o=p=>{let g=t.indexOf(p);return g>=0&&g+1<t.length?t[g+1]:void 0},n=t[0];Xt.includes(n)||(process.stderr.write(`The first word is the step: ${Xt.join(", ")} \u2014 not "${t[0]}".
247
+ `),process.exit(2)),rt(t,bo);let s=o("--config");s||(process.stderr.write(`Missing --config. Run with --help.
248
+ `),process.exit(2));let i=o("--source"),m=o("--target");(n==="select"||n==="extract")&&!i&&(process.stderr.write(`${n} reads the source org: give --source.
249
+ `),process.exit(2)),(n==="load"||n==="verify"||n==="remove")&&!m&&(process.stderr.write(`${n} works on the target org: give --target.
250
+ `),process.exit(2)),t.includes("--sweep")&&t.includes("--sweep-list")&&(process.stderr.write(`--sweep deletes and --sweep-list only lists: give one of them. Run with --help.
251
+ `),process.exit(2)),t.includes("--sweep-list")&&n!=="remove"&&(process.stderr.write(`--sweep-list goes with remove${n==="load"?"; a reload lists what its sweep would take with --dry-run --sweep":""}. Run with --help.
252
+ `),process.exit(2)),t.includes("--sweep")&&n!=="remove"&&!(n==="load"&&t.includes("--reload")&&!t.includes("--pilot"))&&(process.stderr.write(`--sweep goes with remove or load --reload${n==="load"&&t.includes("--pilot")?", and a pilot purges nothing":""}. Run with --help.
253
+ `),process.exit(2)),t.includes("--include-changed")&&n!=="remove"&&!(n==="load"&&t.includes("--reload")&&t.includes("--sweep"))&&(process.stderr.write(`--include-changed goes with remove, or with load --reload --sweep, whose sweep then takes what changed since the loads it replaces. Run with --help.
254
+ `),process.exit(2)),t.includes("--gone-first")&&!(n==="load"&&t.includes("--reload")&&t.includes("--dry-run"))&&(process.stderr.write(`--gone-first goes with load --reload --dry-run. Run with --help.
255
+ `),process.exit(2));let r=o("--gone-first");t.includes("--gone-first")&&r===void 0&&(process.stderr.write(`--gone-first takes the file of the ids taken back first.
256
+ `),process.exit(2)),t.includes("--write-encrypted")&&n!=="load"&&(process.stderr.write(`--write-encrypted goes with load. Run with --help.
257
+ `),process.exit(2)),t.includes("--accept-emails")&&n!=="load"&&(process.stderr.write(`--accept-emails goes with load. Run with --help.
258
+ `),process.exit(2)),t.includes("--mute-automation")&&n!=="load"&&n!=="remove"&&(process.stderr.write(`--mute-automation goes with load or remove. Run with --help.
259
+ `),process.exit(2)),t.includes("--accept-automation")&&n!=="remove"&&n!=="load"&&(process.stderr.write(`--accept-automation goes with load or remove. Run with --help.
260
+ `),process.exit(2)),t.includes(je)&&n!=="load"&&(process.stderr.write(`${je} goes with load. Run with --help.
261
+ `),process.exit(2));let d=At(t);t.includes("--preview")&&n!=="remove"&&(process.stderr.write(`--preview goes with remove${n==="load"?"; a load says what it would do with --dry-run":""}. Run with --help.
262
+ `),process.exit(2)),t.includes("--preview")&&t.includes("--sweep-list")&&(process.stderr.write(`--preview deletes nothing, and --sweep-list lists what a sweep would take: give --preview without it, or with --sweep. Run with --help.
263
+ `),process.exit(2));let a=jt(t);"refusal"in a&&(process.stderr.write(`${a.refusal} Run with --help.
264
+ `),process.exit(2));let l;if(t.includes("--max-total")){let p=o("--max-total");l=Number(p),n!=="load"&&(process.stderr.write(`--max-total goes with load. Run with --help.
265
+ `),process.exit(2)),(p===void 0||!/^\d+$/.test(p)||l<1||l>Zt)&&(process.stderr.write(`--max-total takes a whole number from 1 to ${Zt}, not "${p??""}".
266
+ `),process.exit(2))}return{step:n,configPath:s,source:i,target:m,author:o("--author"),storePath:o("--store"),saltFile:o("--salt-file"),pilot:t.includes("--pilot"),reload:t.includes("--reload"),dryRun:t.includes("--dry-run"),writeEncrypted:t.includes("--write-encrypted"),muteAutomation:t.includes("--mute-automation"),acceptAutomation:t.includes("--accept-automation"),...d!==void 0?{checkpointFirst:d}:{},includeChanged:t.includes("--include-changed"),acceptEmails:t.includes("--accept-emails"),sweep:t.includes("--sweep"),sweepList:t.includes("--sweep-list"),...a,preview:t.includes("--preview"),...l!==void 0?{maxTotal:l}:{},...r!==void 0?{goneFirst:r}:{},yes:t.includes("--yes"),json:t.includes("--json")}}async function ko(e){let o=(await e.query("SELECT Id, IsSandbox FROM Organization LIMIT 1")).records[0];if(!o)throw new Error("The org gave no Organization record.");if(o.IsSandbox)return{id:o.Id,orgType:"Sandbox"};try{let s=(await e.query("SELECT OrganizationType FROM Organization LIMIT 1")).records[0]?.OrganizationType;return typeof s=="string"&&s!==""?{id:o.Id,orgType:et({isSandbox:!1,edition:s}),edition:s}:{id:o.Id,orgType:"Production"}}catch{return{id:o.Id,orgType:"Production"}}}async function Jt(e,t,o,n){let s=await st(e),i=Se(s),m;try{m=await ko(i)}catch(r){let d=r instanceof Error?r.message:String(r);throw new Error(`Could not read the Organization record of '${e}': ${d}`)}return t.set(m.id,{org:{id:m.id,alias:e,orgType:m.orgType,metadata:{apiVersion:"66.0",...m.edition?{edition:m.edition}:{}},username:s.username,instanceUrl:s.instanceUrl},credentials:{accessToken:s.accessToken,instanceUrl:s.instanceUrl}}),o?.set(m.id,i),n?.set(m.id,{session:s,typed:m}),m.id}var x={run:"load",done:"loaded",source:"the frozen dataset",recordedIn:"in this sas",remove:"`remove`",module:"frozen",again:"reload",againSubject:{purge:"reload",sweep:"reloadSweep"},maybeMasks:"the dataset's manifest does not say its extraction left out what it read masked, so they may hold masks such as ****1234; --write-encrypted writes them as the dataset holds them"};function We(e){return!e||e.length===0?[]:[`kept: the platform does not delete them \u2014 ${e.map(({objectApiName:o,count:n})=>`${o} (${n})`).join(", ")}`]}function Qt(e,t,o=x){let n=(e??[]).filter(i=>i.reason==="may-hold-masks");if(n.length===0)return[];let s=n.map(({objectApiName:i,field:m,affectedRecords:r})=>`${i}.${m} (${r})`).join(", ");return[`${t} out, encrypted in the target: ${s} \u2014 ${o.maybeMasks}`]}function Ro(e,t){let o=e==="token"?"each record its own, from the token the value carries":`each record its own, its rank appended: the field is ${e==="unique"?"unique in the target":"the record name"}`;return t===void 0?o:`${o} (first: "${t}")`}function Ge(e){return e.created.reduce((t,o)=>t+o.count,0)}function So(e){return{...e.includeChanged?{includeChanged:!0}:{},...e.sweep?{sweep:!0}:{},...e.sweepLate?{sweepLate:!0}:{},...e.sweepUntied?{sweepUntied:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{}}}var Oo={removal:{heading:"removal",writer:"this removal",verb:"remove"},reload:{heading:"reload",writer:"this reload's purge",verb:"reload"},reloadSweep:{heading:"reload",writer:"this reload's sweep",verb:"reload"},replayAgain:{heading:"replay",writer:"this replay's purge",verb:"replay again"},replayAgainSweep:{heading:"replay",writer:"this replay's sweep",verb:"replay again"}};function xe({read:e,steps:t,mute:o},n,s="removal",i){let m=o?Z(o.muted,n).map(l=>` ${l}`):[];if(!("objects"in e)){let l=Oo[s],p=s==="reload"||s==="replayAgain",g=`${l.writer}${p&&i?" and its sweep":""}`;return{lines:[`${l.heading} automation: what ${n} runs could not be read: ${e.unread}`,...m],refusal:`What ${n} runs as ${g} writes could not be read (${e.unread}), so what fires as the records go is not known. Nothing was written or deleted. Add --accept-automation to ${l.verb} all the same, or turn that automation off in ${n} first.`}}let r=o?.automation??e,d=i?tt(t,i.delete??[]):t,a=mt(r,n,{steps:t,...i?{sweep:i}:{},assign:pt(r,ot(r,d)),mayMute:o===void 0&&Ce("--mute-automation"),subject:s});return{lines:[...ht(e,n,t,s,i),...m],...a!==void 0?{refusal:a}:{}}}function Eo(e,t,o=x){let n=Ge(e),s=e.earlier?`a ${o.run} before the last one, whose records the ${o.run}s after it left in place,`:`the last ${o.run}`,i=`a removal deletes the ${n} record(s) it created, children first:`;return e.removed&&n===0?i=`its records were removed on ${e.removed.removedAt}, and none is left to remove`:n===0&&(e.keptByThePlatform?.length??0)>0?i="it created no record a removal takes":e.removed&&(i=`the removal of ${e.removed.removedAt} left ${n} of the records it created, and a removal deletes those, children first:`),[`${s} wrote to ${t} at ${e.loadedAt}; ${i}`,...e.created.map(m=>` ${m.objectApiName}: ${m.count}`),`${e.linked} record(s) it linked to or reused stay`,...We(e.keptByThePlatform)]}function Fo(e,t){return e.recorded&&(Ge(e)>0||(t?.delete??[]).length>0)}function To(e){return[e.deleted>0?`${e.deleted} deleted`:"",e.alreadyGone>0?`${e.alreadyGone} already gone`:"",e.keptChanged>0?`${e.keptChanged} kept, changed since the load`:"",e.keptDependents>0?`${e.keptDependents} kept for records that stay`+(e.heldBy.length>0?` (${e.heldBy.join(", ")})`:""):"",e.refused>0?`${e.refused} refused`:"",(e.notReached??0)>0?`${e.notReached} not reached`:""].filter(Boolean).join(", ")}function zo(e,t=x){let o=e.count>e.names.length?", \u2026":"";return`${e.count} file(s) attached to them stay in the org, as the ${t.run} did not create them: ${e.names.join(", ")}${o}`}function Yt(e){return`graph: ${e.objects} object(s) at a cap of ${e.maxNodes}`+(e.objects>e.maxNodes?" (raised for the parents their records cannot be written without)":"")+(e.truncated?" \u2014 TRUNCATED: objects further out were not read":"")}function eo(e){return"reusedFrom"in e?`graph reused from ${e.reusedFrom} (discovered ${e.discoveredAt}): the source's schema has not changed since`:`rediscovered: ${e.rediscovered}`}function Co(e){switch(e.phase){case"discovery":return` discovery: ${e.objects??0} object(s) reached`;case"axis":return` listing the values of axis ${e.axis??"?"}\u2026`;case"combination":return` combination ${e.index??"?"}/${e.of??"?"}: ${e.combinationKey??"?"}`;case"candidate":return` candidate ${e.candidate??"?"}/${e.candidates??"?"} of ${e.combinationKey??"?"}: measuring its own records\u2026`;case"measure":return` measuring the ${e.roots??0} root(s) kept, together\u2026`}}function jo(e){let t=e.reason==="timeout"?"its time ran out":"it was cancelled",o=e.during==="axes"?"while it listed the axis values":e.during==="measure"?"while it measured the roots it kept":`while it probed ${e.combinationKey??"?"}`+(e.candidate!==void 0?`, candidate ${e.candidate} of ${e.candidates??"?"}`:"");return[`STOPPED: ${t} ${o}; the combinations decided before are kept`,...e.notProbed.length>0?[` never probed: ${e.notProbed.join(", ")}`]:[]]}var Lo=new Set(["NO_LOAD","ALREADY_REMOVED","NOTHING_TO_REMOVE"]),uo="REMOVAL_DECLINED",to=["MUTE_PRODUCTION","MUTE_NO_RIGHT","MUTE_FAILED"],No=new Map([["frozen:load:error",new Set(["EMAILS_NOT_ACCEPTED","FROZEN_EMAILS_EXCEEDED",ze,"FROZEN_STORAGE_EXCEEDED","AUTOMATION_NOT_ACCEPTED",le.code,...to])],["frozen:remove:error",new Set(["AUTOMATION_NOT_ACCEPTED","GUARD_BLOCKED","GUARD_DECLINED",le.code,...to])]]);function Be(e){let t=e.payload?.code,o=No.get(String(e.type??""));if(!(typeof t!="string"||o?.has(t)!==!0))return{code:t,message:String(e.payload?.message??"")}}function Ue(e){let t=String(e.type??"");if(!t.endsWith(":error")||t==="frozen:remove:automation:error")return!1;let o=String(e.payload?.code);return t==="frozen:remove:error"&&o===uo?!1:!((t==="frozen:remove:error"||t==="frozen:remove:preview:error")&&Lo.has(o))}var oo={passed:0,partial:3,unstable:4,failed:1};function Io(e,t,o){return async(n,s)=>{let i=Date.parse(s?.first??""),m=Math.max(i,Date.parse(s?.last??""));return!Number.isFinite(i)||!Number.isFinite(m)?[]:[...(await Lt({organizationId:n,alias:e,span:{from:i,to:m},own:{ids:[]},...t!==void 0?{journalDir:t}:{}})).map(({ids:d})=>({ids:d,from:i,to:m})),...Gt(Vt(t??te(),n),{sasMark:o,own:[]})]}}function Do(e,t){return dt(t.map(o=>{let n=o.payload??{};if(e==="verify"&&o.type==="frozen:verify:result"){let s=String(n.verdict?.status??"");return Object.prototype.hasOwnProperty.call(oo,s)?oo[s]:1}if(e==="load"&&o.type==="frozen:load:response"){let s=n.report,i=n.replay?.summary.records.refusedBeforeWrite;return s?.status==="completed"&&(s.sweeps??[]).every(m=>m.result.status==="success")&&(i??0)===0?0:3}return e==="remove"&&o.type==="frozen:remove:response"?n.result?.status==="success"?0:3:0}))}function Po(e,t){return` data storage: about ${J(e.estimateMB)} MB`+(e.automationMB!==void 0&&e.automationMB>0?`, about ${J(e.automationMB)} MB of it for what the target's automation creates under them,`:"")+` of the ${J(e.remainingMB)} MB ${t} has left of ${J(e.maxMB)} MB`+(e.freedMB!==void 0?`, and the reload's purge frees about ${J(e.freedMB)} MB first`:"")}function no(e,t){return Ft(e.verdict==="unread"?{verdict:"unread",estimate:e.estimate,unread:e.unread??"not said"}:{verdict:e.verdict,estimate:e.estimate,remaining:e.remaining??0,max:e.max??0},t)}function xo(e){return(e.filter(o=>o.type==="frozen:remove:response").at(-1)?.payload?.result?.objects??[]).some(o=>o.deleted+o.alreadyGone>0)}function ge(e,t){if(gt()!==void 0)return De(e);let o=t.remove.replace(/`/g,"");return e==="--sweep"||e==="--sweep-list"?`${o} ${e}`:`${o} --sweep ${e}`}function Mo(e,t=x){if(!e||e.found.length===0)return[];let o=e.found.reduce((l,p)=>l+p.count,0),n=e.found.some(l=>l.overBound)?" or more":"",s=l=>e.found.reduce((p,g)=>p+(g.classes?l(g.classes):0),0),i=s(l=>l.made+l.madeOver),m=s(l=>l.late),r=s(l=>l.untied),d=e.found.filter(l=>l.overBound).map(l=>l.objectApiName),a=[...i>0?[`${ge("--sweep",t)} takes the ${i} tied to the ${t.run}`]:[],...m>0?[`${ge("--sweep-late",t)} takes the ${m} made late`]:[],...r>0?[e.untied?.refusal!==void 0?`the ${r} tied to nothing of the ${t.run} now stay: --sweep-untied is refused (${e.untied.refusal})`:`${ge("--sweep-untied",t)} takes the ${r} tied to nothing of the ${t.run} now`]:[],...d.length>0?[`no sweep takes those of ${d.join(", ")}, past its bound`]:[]];return[`not swept: ${o}${n} record(s) the ${t.run}'s user created in its window stay, what the target's automation made for the ${t.run} likely: `+e.found.map(l=>`${l.objectApiName}: ${l.count}`).join(", "),...a.map(l=>` ${l}`),` ${ge("--sweep-list",t)} names them first: a record made by hand as that user in the ${t.run}'s window reads as the automation's, so check the names before a sweep`]}function _o(e,t={},o=x){let n=String(e.type??""),s=e.payload??{},i=n.replace(/^frozen:/,`${o.module}:`),m=o===x?"load":"run";if((n==="frozen:remove:error"||n==="frozen:remove:preview:error")&&!Ue(e))return[`nothing to remove: ${String(s.message??"")}`];if(n==="frozen:remove:error"&&!Ue(e))return[String(s.message??"")];if(n==="frozen:remove:automation:error")return[];if(n.endsWith(":error")){let r=n==="frozen:load:error"?s.sweeps??[]:[],d=n==="frozen:load:error"?s.emails:void 0,a=n==="frozen:load:error"?s.automation:void 0,l=n==="frozen:load:error"?s.mutedAutomation:void 0,p=Be(e);return[...p?[]:[`! ${i}: ${String(s.message??"")}${s.code?` [${String(s.code)}]`:""}`],...a?me(a,"the target"):[],...d?he(d,"the target"):[],...l?Z(l,"the target"):[],...r.length>0?[`before the ${o.run} ended, its sweep had already done this:`]:[],...r.flatMap(({loadedAt:g,result:y})=>[`sweep of the ${o.run} of ${g}:`,...ne(y)]),...p?[ee(p)]:[]]}switch(n){case"frozen:select:progress":return[Co(s)];case"frozen:select:response":{let r=s.selection;return[`selected ${r.combinations.length} root(s): ${r.combinations.map(d=>d.combinationKey).join(", ")}`,...r.uncovered.map(d=>` uncovered ${d.combinationKey}: ${d.reason}`),...r.stopped?jo(r.stopped):[],...r.discovery?[eo(r.discovery)]:[],...r.graph?[Yt(r.graph)]:[],`volumetry ${r.volumetry.total} / ${r.volumetry.budgetMax} record(s)`+(r.volumetry.summed?" \u2014 each kept root's own records added up: they were not measured together":""),...Object.entries(r.volumetry.measured).filter(([,d])=>d>0).map(([d,a])=>` ${d}: ${a}`)]}case"frozen:control:result":{let r=s.report;return[`non-reidentification control: ${r.passed?"PASSED":"FAILED"}`,...r.checks.map(d=>` ${d.passed?"ok ":"FAIL"} ${d.name}`+(d.violations.length>0?` (${d.violations.length} violation(s))`:""))]}case"frozen:extract:response":{let r=s.manifest,d=s.discovery;return[`frozen ${String(s.recordCount)} record(s) as version ${r.version} in ${String(s.datasetDir)}`,...d?[eo(d)]:[],...r.coverage?[Yt(r.coverage)]:[],...r.coverage&&r.coverage.unboundedObjects.length>0?[`read without the time bound: ${r.coverage.unboundedObjects.join(", ")}`]:[],...(r.coverage?.leftToThePlatform??[]).map(a=>`${a.objectApiName}: ${a.note}`),...(r.coverage?.exclusionCosts??[]).map(a=>`${a.objectApiName}: ${a.note}`),...(r.coverage?.requiredLeftEmpty??[]).length>0?[`required in the source and left empty by the rules \u2014 a load will ask a value for each: ${(r.coverage?.requiredLeftEmpty??[]).join(", ")}`]:[],...(r.coverage?.keptWithoutARule??[]).length>0?["kept without a rule, the platform's own words: "+(r.coverage?.keptWithoutARule??[]).join(", ")]:[],...(r.coverage?.encryptedNotKept??[]).length>0?["not kept, encrypted and read masked: the user the source is read as lacks View Encrypted Data, and the masks are not copied: "+(r.coverage?.encryptedNotKept??[]).join(", ")]:[],...Object.entries(r.volumetry.measured).filter(([,a])=>a>0).map(([a,l])=>` ${a}: ${l}`)]}case"frozen:load:response":{let r=s.report,d=[`${o.run}: ${r.status} in ${r.durationMs}ms \u2014 ${r.alignment.excludedObjects.length} object(s) excluded, ${r.alignment.removals.length} field removal(s), ${r.alignment.recordTypeIssues.length} record type issue(s), ${r.placeholders.length} placeholder(s)`];for(let f of r.alignment.excludedObjects)d.push(` ${f.objectApiName}: not ${o.done} \u2014 ${f.reason}`);d.push(...Qt(r.alignment.removals,"left",o));for(let f of r.perObject){let S=f.writtenByThePlatform??0;d.push(` ${f.objectApiName}: ${f.inserted} inserted, ${f.reused} reused`+(S>0?` (${S} written by the platform with ${Oe(f.objectApiName)})`:"")+`, ${f.skippedDuplicates.length} duplicate(s), ${f.failed.length} failed of ${f.fromFiles}`);let P=f.failed[0];P&&d.push(` first refusal: ${P.errors?.[0]??P.error??"?"}`)}for(let f of[...r.leftToThePlatform??[],...r.untypedFeedItems??[],...r.heldForExcludedParents??[],...r.quotesLeftUnsynced??[],...r.keysLeftEmpty??[]])d.push(` ${f.objectApiName}: ${f.note}`);let a=r.perObject.filter(f=>(f.writtenWithoutFields?.fields.length??0)>0);if(a.length>0){d.push(`written again without a field a validation rule or a restricted picklist refused (${a.length} object(s)):`);for(let{objectApiName:f,writtenWithoutFields:S}of a)for(let{field:P,refusedBy:q,reason:V,rows:Ve,replacedWith:se}of S?.fields??[]){let Q=q==="restricted-picklist"?"a restricted picklist refused its value":"a validation rule refused it",j=se===void 0?"":` \u2014 written with "${se}", as its picklist rule declares`;d.push(` ${f}.${P} ${Ve} record(s) \u2014 ${Q}${j} \u2014 ${V}`)}}d.push(`pass 2: ${r.pass2.resolved} resolved, ${r.pass2.unresolved.length} unresolved`);for(let f of r.pass2.unresolved.slice(0,5))d.push(` ${f.objectApiName}.${f.field}: ${f.detail}`);let l=r.personContact,p=l?.sent??[];if(l&&l.restored+p.length+l.unresolved.length>0){d.push(`person contacts: ${l.restored} linked, ${p.length} sent as contacts of their own, ${l.unresolved.length} not linked`);for(let f of p.slice(0,5))d.push(` ${f.contactReferenceId} sent: ${f.detail}`);for(let f of l.unresolved.slice(0,5))d.push(` ${f.contactReferenceId}: ${f.detail}`)}if(r.statuses&&r.statuses.restored+r.statuses.refused.length>0){d.push(`statuses applied after insert: ${r.statuses.restored}, refused ${r.statuses.refused.length}`);for(let f of r.statuses.refused.slice(0,5))d.push(` ${f.objectApiName} \u2192 ${f.status}: ${f.detail}`)}let g=f=>Object.values(f).reduce((S,P)=>S+P,0),y=g(r.purge.deleted),z=g(r.purge.deactivated??{});if(y+z+r.purge.failures.length>0){d.push(`purge of earlier ${o.run}s: ${y} deleted, ${z} deactivated, ${r.purge.failures.length} failed`);for(let f of r.purge.failures.slice(0,5))d.push(` ${f.objectApiName}: ${f.errors[0]??"?"}`)}for(let[f,S]of Object.entries(r.purge.cameAlong??{}))d.push(` ${f}: took along ${S.count} record(s) the ${o.run}s did not write that came with their records, made as they wrote: ${S.objects.join(", ")}`);let M=Object.entries(r.purge.leftUnrecorded??{});if(M.length>0){d.push("left in place, of a load recorded before loads kept what they created \u2014 it may have linked them:");for(let[f,S]of M)d.push(` ${f}: ${S}`)}let C=Object.entries(r.purge.keptByThePlatform??{});if(C.length>0){d.push("kept by the purge, the platform does not delete them:");for(let[f,S]of C)d.push(` ${f}: ${S}`)}for(let f of s.report.sweeps??[]){d.push(`sweep of the ${o.run} of ${f.loadedAt}:`,...ne(f.result));let S=f.result.objects.reduce((P,q)=>P+q.keptChanged,0);S>0&&d.push(` ${S} record(s) kept, changed since that ${o.run}: `+(o===x?"load --reload --sweep --include-changed, or remove --sweep --include-changed, ":`${o.remove} --sweep --include-changed `)+"takes them")}let F=s.report.mutedAutomation;F&&d.push(...Z(F,"the target"));let D=s.report.automation;D&&d.push(...me(D,"the target"));let u=s.report.emails;u&&d.push(...he(u,"the target"));let $=s.report.apiRequests;return $&&d.push(no($,"the target")),d.push(...lo(s.report.recordTypesGiven,!1)),d}case"frozen:load:preview:response":{let r=s.plan,d=u=>r.perObject.reduce(($,f)=>$+u(f),0),a=[`dry run${r.mode.pilot?" (pilot)":""}${r.mode.reload?` (${o.again})`:""}: ${d(u=>u.toInsert)} record(s) to insert, ${d(u=>u.reusedByKeys+u.reusedFromCatalog+(u.writtenByThePlatform??0))} to link, ${d(u=>u.notSent)} not sent`+(r.mode.reload?`, ${d(u=>u.toPurge)} to purge and ${d(u=>u.toDeactivate)} to deactivate of ${r.earlierLoads} earlier ${o.run}(s)`:"")+" \u2014 nothing written"];for(let u of r.perObject){let $=[`${u.toInsert} to insert`,u.reusedByKeys>0?`${u.reusedByKeys} found by identity keys`:"",u.reusedFromCatalog>0?`${u.reusedFromCatalog} found in the catalog`:"",(u.writtenByThePlatform??0)>0?`${u.writtenByThePlatform} to link (written by the platform with ${Oe(u.objectApiName)})`:"",u.fieldsDropped>0?`${u.fieldsDropped} field(s) dropped`:"",u.picklistsRewritten>0?`${u.picklistsRewritten} picklist value(s) rewritten`:"",u.notSent>0?`${u.notSent} not sent`:"",u.toPurge>0?`${u.toPurge} to purge`:"",u.toDeactivate>0?`${u.toDeactivate} to deactivate`:""].filter(Boolean);a.push(` ${u.objectApiName}: ${$.join(", ")} of ${u.fromFiles}`)}for(let u of r.excludedObjects)a.push(` ${u.objectApiName}: not ${o.done} \u2014 ${u.reason}`);a.push(...Qt(r.removals,"would leave",o));for(let u of[...r.heldForExcludedParents??[],...r.quotesLeftUnsynced??[],...r.keysLeftEmpty??[]])a.push(` ${u.objectApiName}: ${u.note}`);for(let u of r.placeholders)a.push(`placeholder for ${u.objectApiName}.${u.field}: ${u.affectedRecords} record(s)`);for(let u of r.requiredDefaults)a.push(`default for ${u.objectApiName}.${u.field}: ${u.affectedRecords} record(s)`+(u.perRecord?`, ${Ro(u.perRecord,u.example)}`:""));r.personContacts>0&&a.push(`${r.personContacts} person account contact(s) go in with their account, not counted above`);let l=Object.entries(r.leftUnrecorded??{});if(l.length>0){a.push("left in place, of a load recorded before loads kept what they created \u2014 it may have linked them:");for(let[u,$]of l)a.push(` ${u}: ${$}`)}let p=Object.entries(r.keptByThePlatform??{});if(p.length>0){a.push("left in place by the purge, the platform does not delete them:");for(let[u,$]of p)a.push(` ${u}: ${$}`)}let g=u=>` ${u.name}${u.field?` (${u.field})`:""}${u.message?` \u2014 ${u.message}`:""}`,y=r.perObject.filter(u=>(u.validationRules?.length??0)>0);for(let u of y){a.push(`${u.objectApiName}: ${u.validationRules?.length??0} active validation rule(s) of the target, which a preview cannot evaluate \u2014 a record one of them refuses is counted to insert:`);for(let $ of u.validationRules??[])a.push(g($))}for(let u of r.perObject){let $=u.lookupFilters??[];$.length!==0&&a.push(`${u.objectApiName}: ${$.length} lookup filter(s) of the target, which a preview cannot check \u2014 a record whose lookup it refuses is refused, and what hangs from it: `+$.map(f=>`${f.field} (${f.referenceTo.join(" or ")}, ${f.records} record(s))`).join(", "))}for(let u of r.perObject){let $=u.validationRulesOnChange??[];$.length!==0&&a.push(`${u.objectApiName}: ${$.length} rule(s) left out \u2014 their formula holds only on a change of a record (ISCHANGED, PRIORVALUE, NOT(ISNEW())), which an insert never is: `+$.join(", "))}let z=new Map(r.placeholders.filter(u=>(u.validationRules?.length??0)>0).map(u=>[u.placeholderObjectApiName,u.validationRules??[]]));for(let[u,$]of z){a.push(`placeholder of ${u}: ${$.length} active validation rule(s) of the target, which a preview cannot evaluate \u2014 a placeholder one of them refuses stops the load:`);for(let f of $)a.push(g(f))}r.validationRulesUnread&&a.push(`the target's validation rules could not be listed (${r.validationRulesUnread}): any of them may refuse a record counted to insert`);let M=s.plan.automation;M&&a.push(...me(M,"the target"));let C=s.plan.emails;C&&a.push(...he(C,"the target"));let F=s.plan.apiRequests;F&&a.push(no(F,"the target"));let D=s.plan.storage;return D&&a.push(Po(D,"the target")),a}case"frozen:verify:result":{let r=s.verdict;return[`verification: ${r.status.toUpperCase()}`,...r.checks.map(d=>{let a=Vo(d,o);return` ${d.passed?"ok ":"FAIL"} ${a.name}: ${a.detail}`})]}case"frozen:remove:response":{let r=s.result,d=[...new Set(r.objects.flatMap(l=>l.unchecked))],a=r.sweep!==void 0&&r.objects.length===0;return[...r.sweep?ne(r.sweep):[],...(r.otherLoadSweeps??[]).flatMap(({loadedAt:l,result:p})=>[`sweep of the ${o.run} of ${l}:`,...ne(p)]),...a?[]:[`removal: ${r.status.toUpperCase()}`+(r.leftBy?` \u2014 of what the removal of ${r.leftBy} left`:"")],...r.objects.flatMap(l=>[` ${l.objectApiName}: ${To(l)||"nothing"} of ${l.planned}${Ie(l)}`,...Tt(l,m),...l.reasons.map(p=>` ${p}`),...l.filesLeft&&l.filesLeft.count>0?[` ${zo(l.filesLeft,o)}`]:[]]),...d.length>0?[`not checked, deleted with their parent: ${d.join(", ")}`]:[],...We(r.keptByThePlatform),...zt(r.objects,{sweep:r.sweep!==void 0}),...r.mutedAutomation?Z(r.mutedAutomation,"the target"):[]]}case"frozen:remove:sweep:response":{let r=s.loads;if(r)return r.flatMap(({loadedAt:a,listing:l})=>[`sweep of the ${o.run} of ${a}:`,...fe(l,"the target org",t,!0)]);let d=s.otherLoads??[];return d.length>0?[{loadedAt:String(s.loadedAt),listing:s.listing},...d].flatMap(({loadedAt:a,listing:l})=>[`sweep of the ${o.run} of ${a}:`,...fe(l,"the target org",t,!0)]):fe(s.listing,"the target org",t,!0)}case"frozen:remove:preview:response":return Uo(s.preview,o);case"frozen:status:response":return[JSON.stringify(s.status,null,2)];default:return[]}}var Bo="not read by a preview: what hangs from the records, which a removal reads at each object's turn \u2014 a record kept for records that stay is counted with those to delete \u2014 nor what the target's automation does as they go";function Uo(e,t=x){let o=i=>e.userNames[i]??i,n=["preview: what a removal would do; nothing was deleted"+(e.leftBy?` \u2014 of what the removal of ${e.leftBy} left`:"")];for(let i of e.objects){let m=[i.toDelete>0?`${i.toDelete} to delete`:"",e.includeChanged&&i.changedSince>0?`${i.changedSince} of them changed since the ${t.run}`:"",i.alreadyGone>0?`${i.alreadyGone} gone already`:"",i.notVisible>0?`${i.notVisible} not visible`:"",i.keptChanged>0?`${i.keptChanged} kept, changed since the ${t.run}`:"",i.undeletable>0?`${i.undeletable} left, the user may not delete them`:"",i.unread>0?`${i.unread} left, not read`:""].filter(Boolean);n.push(` ${i.objectApiName}: ${m.join(", ")||"nothing"} of ${i.planned}${Ie(i)}`);let r=Object.entries(i.changedBy).sort((d,a)=>a[1]-d[1]);r.length>0&&n.push(` last changed by: ${r.map(([d,a])=>`${o(d)} ${a}`).join(" \xB7 ")}`);for(let d of i.reasons)n.push(` ${d}`)}n.push(...We(e.keptByThePlatform));let s=e.refusalCodes;return e.refusals.forEach((i,m)=>{n.push(s?.length===e.refusals.length?ue({code:s[m],message:i},"a removal"):`a removal would be refused: ${i}`)}),n.push(Bo),n}async function Wo(e){let t=G(e,"manifest.json");if(_e(t))try{let o=await _t(e),{version:n}=JSON.parse(ve(t,"utf8"));return{dir:e,digest:o,...typeof n=="string"?{version:n}:{}}}catch{return}}function Go(e,t){let o=G(e,xt(t)),n=G(e,"referenceid-mapping.json");return!_e(o)&&_e(n)?n:o}function ro(e){return{status:e.status.toUpperCase(),objects:(e.objects??[]).map(({status:t,...o})=>({...o,verdict:t==="passed"?"PASSED":"FAILED"}))}}async function qo(e,t,o){let n=a=>t.filter(l=>l.type===a).at(-1)?.payload,s=o.targetOrgId?Go(o.sasDir,o.targetOrgId):void 0,i={tool:"sandforge-frozen",step:e,posted:t},m=[],r=[],d=async a=>{if(a===void 0)return;let l=await Wo(a);l&&(i.dataset=l)};switch(e){case"extract":{let a=n("frozen:extract:response");if(!a)break;await d(typeof a.datasetDir=="string"?a.datasetDir:o.datasetDir);let l=a.manifest?.volumetry?.measured??{};i.objects=Object.entries(l).filter(([,p])=>p>0).map(([p,g])=>({objectApiName:p,records:g}));break}case"load":{await d(o.datasetDir);let a=n("frozen:load:response")?.report,l=n("frozen:load:preview:response")?.plan,p=a?a.recordTypesGiven:l?.recordTypesGiven;p&&(i.recordTypesGiven=p),a?(i.mapping=a.mappingPath,i.objects=a.perObject.map(y=>({objectApiName:y.objectApiName,fromFiles:y.fromFiles,inserted:y.inserted,reused:y.reused,duplicates:y.skippedDuplicates.length,failed:y.failed.length}))):l&&(s&&(i.mapping=s),i.objects=l.perObject.map(y=>({objectApiName:y.objectApiName,fromFiles:y.fromFiles,toInsert:y.toInsert,toLink:y.reusedByKeys+y.reusedFromCatalog+(y.writtenByThePlatform??0),notSent:y.notSent,toPurge:y.toPurge,toDeactivate:y.toDeactivate}))),a&&(i.status=a.status),!a&&n("frozen:load:error")?.code==="LOAD_CANCELLED"&&(i.status="cancelled",s&&(i.mapping=s));let g=n("frozen:verify:result")?.verdict;g&&(i.verdict=ro(g));break}case"verify":{let a=n("frozen:verify:result")?.verdict;await d(a?.manifestPath?wo(a.manifestPath):o.datasetDir),s&&(i.mapping=s),a&&(i.verdict=ro(a));break}case"remove":{s&&(i.mapping=s);let a=n("frozen:remove:response")?.result,l=n("frozen:remove:preview:response")?.preview;a?(i.status=a.status,a.mutedAutomation&&(i.mutedAutomation=a.mutedAutomation),i.objects=a.objects.map(p=>({objectApiName:p.objectApiName,planned:p.planned,deleted:p.deleted,alreadyGone:p.alreadyGone,keptChanged:p.keptChanged,keptDependents:p.keptDependents,refused:p.refused,notReached:p.notReached??0,notVisible:p.notVisible??0,...p.tookAlong?{tookAlong:p.tookAlong}:{},...p.cameAlong?{cameAlong:p.cameAlong}:{}})),i.includeChanged=a.includeChanged):l&&(i.preview=!0,i.includeChanged=l.includeChanged,i.objects=l.objects.map(p=>({objectApiName:p.objectApiName,planned:p.planned,toDelete:p.toDelete,alreadyGone:p.alreadyGone,changedSince:p.changedSince,keptChanged:p.keptChanged,undeletable:p.undeletable,notVisible:p.notVisible,unread:p.unread})),m.push(...l.refusals),l.refusalCodes?.length===l.refusals.length&&r.push(...l.refusalCodes));break}}return m.push(...o.refusals??[]),o.refusalCodes?.length===(o.refusals??[]).length&&r.push(...o.refusalCodes??[]),m.length>0&&(i.refusals=m),m.length>0&&r.length===m.length&&(i.refusalCodes=r),o.mute&&Object.assign(i,o.mute),o.checkpoint&&(i.checkpoint=o.checkpoint),i}function Vo(e,t){return t===x?e:{name:e.name==="load"?t.run:e.name,detail:e.detail.replace(/\bThe load\b/g,`The ${t.run}`).replace(/\bthe load\b/g,`the ${t.run}`).replace(/\bnot loaded\b/g,`not ${t.done}`).replace(/\bnot loadable\b/g,`not ${t.run}able`)}}async function Ko(e=process.argv){await Ho($o(e))}async function Ho(e,t){let o=Date.now(),n=c=>{process[e.json?"stderr":"stdout"].write(`${c}
267
+ `)},s=t?.words??x,i=t?{}:JSON.parse(ve(e.configPath??"","utf8")),m=t?t.folder.dir:typeof i.sasDir=="string"?i.sasDir:G(yo(),".sandforge-sas");t||mo(m,{recursive:!0});let r=wt(t?t.auditStore:e.storePath??G(m,"cli-store.json")),d=new Map,a=new Map,l=new Map,p=e.source?await Jt(e.source,d):void 0,g=e.target?await Jt(e.target,d,a,l):void 0,y=[],z=!1,M=!1,C=new Kt({log:()=>{},broker:{postToWebview:c=>{if(c.type==="frozen:load:progress")return;if(t&&String(c.type).endsWith(":error")&&c.payload){let w=c.payload.code;c.payload.message=t.reword(typeof w=="string"?w:void 0,String(c.payload.message??""),c.payload)}y.push(c),Ue(c)&&(z=!0);let h=t?.refusalOf(c);if(h&&(E??=h,j.push(h)),M)return;let v=h?[ee(h)]:_o(c,e,s);for(let w of t?t.lines(c,v):v)n(w)}},orgManager:{getOrg:c=>d.get(c)?.org},orgRegistry:{getCredentials:async c=>d.get(c)?.credentials},configStore:r,infraServices:{productionGuard:It(n,e.target??e.source??"the org"),piiDetector:new ut},nextId:()=>`cli-${Date.now()}-${Math.random().toString(36).slice(2,8)}`});t&&C.setReplayStores(t.stores);let F=g?a.get(g):void 0,D=g?l.get(g):void 0,u=e.checkpointFirst&&D?$t({module:t?"replay":"frozen",operationId:`sandforge-frozen-load-${o}`,request:e.checkpointFirst,session:D.session,org:{id:D.typed.id,orgType:D.typed.orgType,...D.typed.edition!==void 0?{edition:D.typed.edition}:{}},connect:Se,journalDir:te(),say:n}):void 0;F&&C.setTargetAutomation(oe(F)),C.setMuteOffered(Ce("--mute-automation")),C.setSaltKeeper(Ut(process.env,e.saltFile)),e.target&&C.setOtherModuleRuns(Io(e.target,void 0,Pe(m)));let $=new Ht;C.setRegistry($);let f,S,P=!1,q=!1,V,se=at(c=>{if(V=c,process.stderr.write(`
268
+ interrupted: the ${e.step==="load"?s.run:e.step} stops after the call under way, and says what it wrote (Ctrl-C again ends it at once)
269
+ `),S){S.abort();return}for(let h of $.getRunning())$.abort(h.operationId);f&&$.cancelBeforeStart(f),(!f||q)&&process.exit(de(c))}),Q=t?void 0:typeof i.datasetDir=="string"?i.datasetDir:G(m,"dataset"),j=[],U=c=>{let h=t?{code:c.code,message:t.reword(c.code,c.message)}:c;j.push(h),n(ue(h,`a ${s.run}`))},B=c=>{if(!t)return{};let{organizationId:h,checkpointId:v,config:w}=t.request;return c==="load"?{replay:t.request}:c==="verify"?{replay:{organizationId:h,checkpointId:v,...w?{config:w}:{}}}:{replay:{organizationId:h,checkpointId:v}}},be=[],E,Ke=!1,K,H,X,Ae=async(c,h=Number(process.exitCode??0))=>{if(!e.json)return;let v=[...j,...be],w=await qo(e.step,y,{...Q!==void 0?{datasetDir:Q}:{},sasDir:m,...g?{targetOrgId:g}:{},...v.length>0?{refusals:v.map(({message:A})=>A),refusalCodes:v.map(({code:A})=>A)}:{},...K?{mute:K}:{},...H?{checkpoint:H}:{}}),b=t?{...t.answer(w,{exit:h,...c?{ended:c}:{},...E?{refused:E}:{},...g?{targetOrgId:g}:{}}),...X?{notSwept:X}:{}}:{...w,...X?{notSwept:X}:{},...E?{refused:E}:{},...c?{ended:c}:{}};process.stdout.write(`${JSON.stringify(b,null,2)}
270
+ `)},L=async(c,h)=>{let v=`cli-${c}-${Date.now()}`;f=v;try{return await C.handle({id:v,type:c,payload:h})}finally{f=void 0}},He;try{He=await po()}finally{se()}if(He==="ended"&&!V){z&&(process.exitCode=1),await Ae(!0);return}if(V){await Ae(void 0,de(V)),process.stderr.write(`${P?ct:Qo(e.preview?"preview":e.step,e.step!=="load"||e.dryRun||Me(y),s)}
271
+ `),process.exitCode=de(V);return}if(it(z||j.length>0?1:Ke?3:Do(e.step,y)),e.json){await Ae();return}n(`done in ${Date.now()-o}ms`);async function Xe(c){await L("frozen:remove:automation",{...c,...B("removal")});let h=T=>y.find(W=>W.type===T)?.payload,v=h("frozen:remove:automation:response"),w=Array.isArray(c.sweptObjects)?c.sweptObjects:[],b=v?.purge&&w.length>0?v.purge:void 0,A=v&&e.muteAutomation?F&&(e.preview||e.dryRun)?await Fe(Ee(F),v.automation,{writes:ie(v.steps)}):Te(v.automation,ie(v.steps)):void 0,N=A&&!("refused"in A)?A:void 0,{lines:k,refusal:O}=xe({read:v?.automation??{unread:String(h("frozen:remove:automation:error")?.message)},steps:b??v?.steps??{},...N?{mute:{automation:N.automation,muted:N.planned}}:{}},e.target??"",c.reload===!0?s.againSubject.purge:"removal",b?{delete:w}:void 0);for(let T of k)n(T);let _=A&&"refused"in A?A.refused:O!==void 0&&!e.acceptAutomation?{code:"AUTOMATION_NOT_ACCEPTED",message:O}:void 0;return{...v?{steps:v.steps}:{},...N?{planned:N}:{},..._?{refusal:_.message,code:_.code}:{}}}function Ze(c){E={code:ce,message:c},j.push(E),n(ee(E)),z=!0}async function $e(){if(t){if(g===void 0)return;let h=Dt(await t.stores.replays.mappingStoreOf(t.folder,g).recordedLoads());return h?{...Pt(h),orgId:g}:void 0}return M=!0,await L("frozen:status",{}),M=!1,y.filter(h=>h.type==="frozen:status:response").at(-1)?.payload?.status?.loadRecords?.find(h=>h.orgId===g)}async function Je(c=[]){if(!e.reload||e.pilot)return;let h=await $e();if(!(!h||h.created.length===0&&c.length===0))return Xe({targetOrgId:g,loadedAt:h.loadedAt,reload:!0,...c.length>0?{sweptObjects:c}:{}})}async function Qe(){let c=await $e();if(!c)return[];n(`reading what a sweep of ${e.target} would take for the loads a reload replaces\u2026`);let h=y.length;await L("frozen:remove:sweep",{targetOrgId:g,loadedAt:c.loadedAt,reload:!0,...B("removal")});let v=y.slice(h);if(v.some(b=>b.type==="frozen:remove:sweep:error"))return;let w=v.filter(b=>b.type==="frozen:remove:sweep:response").at(-1)?.payload?.loads;return[...new Set((w??[]).flatMap(({listing:b})=>Re(b,e)))]}async function co(c){n(`reading what a sweep of ${e.target} would take\u2026`);let h=y.length;await L("frozen:remove:sweep",{targetOrgId:g,loadedAt:c,...B("removal")});let v=y.slice(h);if(v.some(A=>A.type==="frozen:remove:sweep:error"))return;let w=v.filter(A=>A.type==="frozen:remove:sweep:response").at(-1)?.payload,b=[...w?.listing?[w.listing]:[],...(w?.otherLoads??[]).map(({listing:A})=>A)];return[...new Set(b.flatMap(A=>Re(A,e)))]}async function Ye(c){n(`reading what ${t?`a replay of ${s.source}`:"a load"} into ${e.target}${e.pilot?" (pilot)":""} would do\u2026`),await L("frozen:load:preview",{targetOrgId:g,...B("load"),...e.pilot?{pilot:!0}:{},...e.reload?{reload:!0}:{},...e.goneFirst!==void 0?{goneFirst:Ao(e.goneFirst)}:{},...e.writeEncrypted?{writeEncrypted:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{},...e.acceptEmails?{acceptEmails:!0}:{},...e.acceptAutomation?{acceptAutomation:!0}:{}});let h=y.find(R=>R.type==="frozen:load:preview:response")?.payload?.plan,v=y.find(R=>R.type==="frozen:load:preview:error"&&R.payload?.code==="LOAD_CONFIG")?.payload;if(h===void 0&&v!==void 0){j.push({code:"LOAD_CONFIG",message:String(v.message??"")});let R=Array.isArray(v.refusedBeside)?v.refusedBeside:[];for(let{code:I,message:Y}of R)U({code:I,message:Y})}let w=h?Bt(pe(h),e.maxTotal):void 0;w&&U({code:"MAX_RECORDS",message:w});let b=h?.automation?.refused;b&&U(b);let A=h?.emails?.refused;A&&U(A);let k=y.find(R=>R.type==="frozen:load:preview:response")?.payload?.replay?.storage?.refusal??h?.storage?.refusal;k&&U(k);let O=h?.apiRequests?.refused;O&&U(O);let _=(h&&e.sweep?await Qe():[])??[],T=h?await Je(_):void 0;T?.refusal!==void 0&&U({code:T.code??"AUTOMATION_NOT_ACCEPTED",message:T.refusal});let W;if(e.muteAutomation&&h&&F){W=await oe(F).read(g,[...new Set([...h.perObject.map(I=>I.objectApiName),...T?.steps?.delete??[]])]);let R=await Fe(Ee(F),W,{writes:Xo(T?.steps)});if("refused"in R)j.some(({message:I})=>I===R.refused.message)||U(R.refused);else{for(let I of Z(R.planned,e.target??"the target"))n(I);K={mutedAutomation:R.planned,mutePlan:R.plan}}}for(let R of lo(h?.recordTypesGiven,!0,(K?.mutePlan.assign.length??0)>0))n(R);let ae=h?ao(h):[];if(c&&u&&h&&F&&ae.length>0){W??=await oe(F).read(g,h.perObject.map(Y=>Y.objectApiName)).catch(()=>{});let{estimate:R,refused:I}=await io(u,{written:ae,running:so(W,K?.mutePlan)});if(R){H=R;for(let Y of Ne(R))n(Y)}I!==void 0&&U({code:ce,message:I})}return h}async function fo(c){let h=y.length,v=z;M=!0;try{await L("frozen:remove:sweep",{targetOrgId:g,loadedAt:c,...B("removal")})}finally{M=!1}let w=y.splice(h);z=v;let b=w.find(A=>A.type==="frozen:remove:sweep:response")?.payload?.listing;return b&&b.refusal===void 0&&b.found.length>0?b:void 0}async function po(){if(t||await L("frozen:config:save",{config:i}),z)return"ended";switch(e.step){case"select":n(`selecting from ${e.source}\u2026`),await L("frozen:select",{sourceOrgId:p});break;case"extract":n(`extracting from ${e.source}\u2026`),await L("frozen:extract",{sourceOrgId:p,...e.author?{author:e.author}:{}});break;case"load":{if(e.dryRun){if(await Ye(!0),t&&!z)for(let k of t.dryRunEnd(j))n(k);break}let c;if(t){if(c=await Ye(!1),K=void 0,c===void 0||z||j.length>0)return E??=j[0],z=!0,n("Nothing written."),"ended";if(pe(c)===0)return n(`Nothing to create in ${e.target??"the target"}: nothing written.`),"ended"}let h=e.reload&&!e.pilot&&e.sweep?await Qe():[];if(h===void 0)return n("Nothing written."),"ended";let v=e.reload&&!e.pilot?await Je(h):void 0;if(v?.refusal!==void 0)return E={code:v.code??"AUTOMATION_NOT_ACCEPTED",message:v.refusal},j.push(E),n(ee(E)),z=!0,"ended";if(e.sweep&&(n(`around the purge, a sweep deletes what the target's automation made for each ${s.run} it replaces, as the ${s.run}'s user, tied to its records \u2014 run with --dry-run to see what`),C.setRemovalAsker(async k=>{let{lines:O,refusal:_}=xe(k,e.target??"",s.againSubject.sweep);for(let T of O)n(T);if(!(_===void 0||e.acceptAutomation))return E={code:"AUTOMATION_NOT_ACCEPTED",message:_},j.push(E),E})),!e.yes&&!await yt(t&&c?t.question(c):`Load the frozen dataset into ${e.target}${e.reload?`, purging first what earlier loads created${e.sweep?" and what the target's automation made for them":""}`:""}?`))return n("Nothing written."),"ended";let w;if(u&&F){let k=c?ao(c):Zo(Q??""),O=await oe(F).read(g,k).catch(()=>{}),_={written:k,running:so(O,e.muteAutomation&&O?Te(O,qe).plan:void 0)},{estimate:T,refused:W}=await io(u,_);if(T){H=T;for(let I of Ne(T))n(I)}if(W!==void 0||T===void 0)return Ze(`${W??""} Nothing was written.`.trim()),"ended";S=new AbortController;let ae=S.signal,R=await ft(()=>u.take(_,T,{signal:ae})).finally(()=>{S=void 0});if("stop"in R)return R.stop.code!==ce?(P=!0,"ended"):(Ze(Rt(R.stop)),"ended");w=R.checkpoint,H=w;for(let I of St(w,e.target??"the target",e.muteAutomation))n(I)}n(t?`replaying ${s.source} into ${e.target}\u2026`:`loading into ${e.target}${e.pilot?" (pilot)":""}\u2026`);let b=new Date().toISOString(),A=e.maxTotal??(c?pe(c):void 0);await L("frozen:load",{targetOrgId:g,...B("load"),...e.pilot?{pilot:!0}:{},...e.reload?{reload:!0}:{},...e.writeEncrypted?{writeEncrypted:!0}:{},...A!==void 0?{maxRecords:A}:{},...e.muteAutomation?{muteAutomation:!0}:{},...e.sweep?{sweep:!0}:{},...e.sweepLate?{sweepLate:!0}:{},...e.sweepUntied?{sweepUntied:!0}:{},...e.sweep&&e.includeChanged?{includeChanged:!0}:{},...e.acceptEmails?{acceptEmails:!0}:{},...e.acceptAutomation?{acceptAutomation:!0}:{}});let N=y.filter(k=>k.type==="frozen:load:error").map(Be).find(k=>k!==void 0);if(N&&!E&&(E=N,j.push(E)),g&&Me(y)){let k=Wt(await new Mt(m,{orgId:g}).recorded().catch(()=>{}),b);try{qt(te(),{organizationId:g,sas:Pe(m),startedAt:b,endedAt:new Date().toISOString(),...k?{lastWriteAt:k}:{}})}catch(O){n(`warning: this load could not be added to ${te()}: another sas's sweep of ${e.target??""} will not see it (${O instanceof Error?O.message:String(O)})`)}}if(u&&w){let k=w;H=await u.settle(k,Me(y)).catch(O=>(n(`warning: the checkpoint '${k.name}' taken before the load could not be deleted (${O instanceof Error?O.message:String(O)}): delete it with ${ke("checkpoint")} delete --org ${e.target??""} --checkpoint `+k.checkpointId),k));for(let O of Ot(H))n(O)}break}case"verify":n(t?`verifying the replay of ${s.source} into ${e.target}\u2026`:`verifying ${e.target}\u2026`),await L("frozen:verify",{targetOrgId:g,...B("verify")});break;case"remove":{let c=await $e();if(!c)return n(`No ${s.run} into ${e.target} is recorded ${s.recordedIn}: nothing to remove.`),"ended";if(e.preview){if(n(`reading what a removal from ${e.target} would do\u2026`),await L("frozen:remove:preview",{targetOrgId:g,loadedAt:c.loadedAt,...e.includeChanged?{includeChanged:!0}:{},...B("removal")}),y.some(w=>w.type==="frozen:remove:preview:response")){let w=e.sweep?await co(c.loadedAt):[];if(w===void 0)break;let{planned:b,refusal:A,code:N}=await Xe({targetOrgId:g,loadedAt:c.loadedAt,...w.length>0?{sweptObjects:w}:{}});if(b&&(K={mutedAutomation:b.planned,mutePlan:b.plan}),A!==void 0){let k={code:N??"AUTOMATION_NOT_ACCEPTED",message:A};be.push(k),n(ue(k,"a removal"))}}break}if(e.sweepList){n(`reading what a sweep of ${e.target} would take\u2026`),await L("frozen:remove:sweep",{targetOrgId:g,loadedAt:c.loadedAt,...B("removal")});let w=y.filter(b=>b.type==="frozen:remove:sweep:response").at(-1)?.payload;Ke=[w?.listing,...(w?.otherLoads??[]).map(({listing:b})=>b)].some(b=>b?.refusal!==void 0);break}for(let w of Eo(c,e.target??"",s))n(w);e.sweep&&n(`${Ge(c)>0?"before them, a sweep deletes":"a sweep alone deletes"} what the target's automation made for the ${s.run}, as the ${s.run}'s user, tied to its records \u2014 run ${De("--sweep-list")} to see what`);let h=!1;if(C.setRemovalAsker(async w=>{let{lines:b,refusal:A}=xe(w,e.target??"");for(let N of b)n(N);if(A!==void 0&&!e.acceptAutomation)return{message:A,code:"AUTOMATION_NOT_ACCEPTED"};if(!e.yes&&Fo(c,w.steps)){q=!0;let N=await vt(`Type ${e.target} to delete them:`);if(q=!1,N!==e.target)return h=!0,{message:"Nothing deleted.",code:uo}}n(`removing from ${e.target}\u2026`)}),await L("frozen:remove",{targetOrgId:g,loadedAt:c.loadedAt,...So(e),...B("removal")}),h)return"ended";let v=y.filter(w=>w.type==="frozen:remove:error").map(Be).find(w=>w!==void 0);if(v&&(E=v,be.push(v)),!e.sweep&&!E&&xo(y)){X=await fo(c.loadedAt);for(let w of Mo(X,s))n(w)}break}case"status":await L("frozen:status",{});break}return"through"}}var qe=(e,t)=>t==="insert"||t==="update";function Xo(e){let t=e?ie(e):void 0;return(o,n)=>qe(o,n)||t?.(o,n)===!0}function lo(e,t,o=!1){return Nt((e??[]).map(n=>({recordTypeGiven:n})),t,o)}function so(e,t){return{firing:e?nt(e,t,qe).firing:[]}}function ao(e){let t=[...e.perObject.filter(o=>o.toInsert>0||o.toPurge>0||o.toDeactivate>0).map(o=>o.objectApiName),...(e.placeholders??[]).map(o=>o.placeholderObjectApiName)];return[...new Set(t)]}function Zo(e){try{let t=JSON.parse(ve(G(e,"manifest.json"),"utf8")),o=Object.entries(t.volumetry?.measured??{}).filter(([,n])=>typeof n=="number"&&n>0).map(([n])=>n);if(o.length>0)return o}catch{}try{return go(G(e,"data")).filter(t=>t.endsWith(".json")).map(t=>t.slice(0,-5)).sort()}catch{return[]}}var Jo=new Set(["INVALID_PAYLOAD","CONFIG_MISSING",le.code,"REPLACE_LEAVES_RECORDS","MUTE_PRODUCTION","MUTE_NO_RIGHT","MUTE_FAILED","EMAILS_NOT_ACCEPTED","FROZEN_EMAILS_EXCEEDED","AUTOMATION_NOT_ACCEPTED",ze,"FROZEN_STORAGE_EXCEEDED"]);function Me(e){let t=i=>e.filter(m=>m.type===i).at(-1)?.payload,o=t("frozen:load:response")?.report;if(o){let i=m=>Object.values(m??{}).reduce((r,d)=>r+d,0);return o.perObject.some(m=>m.inserted>0)||(o.placeholders??[]).length>0||i(o.purge?.deleted)>0||i(o.purge?.deactivated)>0}let n=t("frozen:load:error"),s=n?.code;return typeof s=="string"&&Jo.has(s)?!1:n?.written!==0}async function io(e,t){try{let o=await e.scope(t);return{estimate:o,...o.refusal!==void 0?{refused:kt(o.refusal)}:{}}}catch(o){return{refused:lt(o).replace(/ Nothing was written\.$/,"")}}}function Qo(e,t=!0,o=x){let n=o===x?"the sas":"the folder of its replays";return e==="load"&&!t?`interrupted: the ${o.run} stopped before it created or purged a record: ${n} is as it was, and ${o.remove} has nothing of this ${o.run} to take back`:e==="load"?`interrupted: the ${o.run} stopped before it was through; what it wrote is recorded in ${n} and the audit trail, and ${o.remove} takes it back`:e==="remove"?`interrupted: the removal stopped before it was through; what it deleted is recorded, and ${o.remove} again takes what it left`:e==="preview"?"interrupted: the preview stopped before it was through, and deleted nothing":`interrupted: the ${e} stopped before it was through`}process.argv[1]?.includes("sandforge-frozen")&&(Et(),Ko().then(()=>process.exit(process.exitCode??0)).catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
272
+ `),process.exit(1)}));export{Ao as a,$o as b,ko as c,x as d,So as e,xe as f,Eo as g,Fo as h,eo as i,Co as j,Be as k,Ue as l,Io as m,Do as n,Po as o,no as p,xo as q,Mo as r,_o as s,Bo as t,Uo as u,qo as v,Vo as w,Ko as x,Ho as y,lo as z,ao as A,Zo as B,Me as C,Qo as D};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a as y,b as g}from"./chunk-WR4Q363I.mjs";import{a as S,b as f,c as p}from"./chunk-M3ROUWDX.mjs";import{b as u}from"./chunk-CA5NAXSU.mjs";import{ja as d}from"./chunk-TTFDUKUS.mjs";var h="SELECT ApiName, MasterLabel, IsClosed, IsDefault, SortOrder FROM CaseStatus ORDER BY SortOrder",w="SELECT MasterLabel, IsClosed, IsDefault, SortOrder FROM CaseStatus ORDER BY SortOrder",A="Closed";async function k(a){let e;try{e=await a(h)}catch{try{e=await a(w)}catch(t){return m(`the org would not read its case statuses: ${u(t)}`)}}let r=e.flatMap(t=>{let n=b(t.ApiName)??b(t.MasterLabel);return n===void 0?[]:[{value:n,closed:t.IsClosed===!0,isDefault:t.IsDefault===!0}]}),o=r.filter(t=>!t.closed),i=r.filter(t=>t.closed);return o.length===0||i.length===0?m(o.length===0?"the org has no case status that leaves a case open":"the org has no case status that closes a case"):{open:(o.find(t=>t.isDefault)??o[0]).value,closed:(i.find(t=>t.value===A)??i[0]).value,from:"org"}}function m(a){return{...d.caseStatus,from:"default",reason:a}}function b(a){return typeof a=="string"&&a.trim()!==""?a:void 0}var c=S;async function E(a,e){let r;try{r=await a(c)}catch{r={access:"createable"}}if(r.access==="absent")return{available:!1,reason:r.reason??`the org has no ${c}`};if(r.access==="readOnly")return{available:!1,reason:r.reason??`the user this seed runs as may read ${c} and not create it`};try{return{available:!0,bodyFields:f(await e(c))}}catch{return{available:!0,bodyFields:[]}}}var P=["Status","Origin","Priority","Type"];async function T(a){let e;try{e=(await a("Case")).fields}catch{return}let r={};for(let o of P){let t=(e.find(n=>n.name===o)?.picklistValues??[]).filter(n=>n.active!==!1).map(n=>n.value);t.length>0&&(r[o]=t)}return r}function v(a,e){let r=e.knowledge.available?e.knowledge.bodyFields:[],o=r.map(s=>s.name),i=e.articleBodyField===void 0?r[0]:r.find(s=>s.name===e.articleBodyField);if(e.articleBodyField!==void 0&&i===void 0)return{issues:[`options.articleBodyField: ${e.articleBodyField} is not a field of ${c} this org lets a body be written to`+(o.length>0?` (${o.join(", ")})`:"")]};let t=e.knowledge.available?{available:!0,bodyFields:o}:e.knowledge,n={seed:e.seed??d.seed,caseStatus:{open:e.caseStatus.open,closed:e.caseStatus.closed},...i!==void 0?p(i):{}},l;try{l=g(a,n)}catch(s){if(s instanceof y)return{issues:s.issues};throw s}return{preparation:{options:n,objects:[...l.template.objects].sort((s,C)=>s.insertOrder-C.insertOrder).map(s=>({objectApiName:s.objectApiName,recordCount:s.recordCount,...s.optional===!0?{optional:!0}:{}})),tests:l.tests.length,caseStatusFrom:e.caseStatus.from==="org"?{from:"org"}:{from:"default",reason:e.caseStatus.reason},knowledge:t}}}function D(a){return async e=>{let r=await a.query(e),o=[...r.records];for(;!r.done&&r.nextRecordsUrl;)r=await a.queryMore(r.nextRecordsUrl),o.push(...r.records);return o}}export{h as a,w as b,k as c,c as d,E as e,T as f,v as g,D as h};
7
+ import{a as y,b as g}from"./chunk-V3R45ZWT.mjs";import{a as S,b as f,c as p}from"./chunk-A65ADTCR.mjs";import{b as u}from"./chunk-CA5NAXSU.mjs";import{Ha as d}from"./chunk-ZQO5PDX5.mjs";var h="SELECT ApiName, MasterLabel, IsClosed, IsDefault, SortOrder FROM CaseStatus ORDER BY SortOrder",w="SELECT MasterLabel, IsClosed, IsDefault, SortOrder FROM CaseStatus ORDER BY SortOrder",A="Closed";async function k(a){let e;try{e=await a(h)}catch{try{e=await a(w)}catch(t){return m(`the org would not read its case statuses: ${u(t)}`)}}let r=e.flatMap(t=>{let n=b(t.ApiName)??b(t.MasterLabel);return n===void 0?[]:[{value:n,closed:t.IsClosed===!0,isDefault:t.IsDefault===!0}]}),o=r.filter(t=>!t.closed),i=r.filter(t=>t.closed);return o.length===0||i.length===0?m(o.length===0?"the org has no case status that leaves a case open":"the org has no case status that closes a case"):{open:(o.find(t=>t.isDefault)??o[0]).value,closed:(i.find(t=>t.value===A)??i[0]).value,from:"org"}}function m(a){return{...d.caseStatus,from:"default",reason:a}}function b(a){return typeof a=="string"&&a.trim()!==""?a:void 0}var c=S;async function E(a,e){let r;try{r=await a(c)}catch{r={access:"createable"}}if(r.access==="absent")return{available:!1,reason:r.reason??`the org has no ${c}`};if(r.access==="readOnly")return{available:!1,reason:r.reason??`the user this seed runs as may read ${c} and not create it`};try{return{available:!0,bodyFields:f(await e(c))}}catch{return{available:!0,bodyFields:[]}}}var P=["Status","Origin","Priority","Type"];async function T(a){let e;try{e=(await a("Case")).fields}catch{return}let r={};for(let o of P){let t=(e.find(n=>n.name===o)?.picklistValues??[]).filter(n=>n.active!==!1).map(n=>n.value);t.length>0&&(r[o]=t)}return r}function v(a,e){let r=e.knowledge.available?e.knowledge.bodyFields:[],o=r.map(s=>s.name),i=e.articleBodyField===void 0?r[0]:r.find(s=>s.name===e.articleBodyField);if(e.articleBodyField!==void 0&&i===void 0)return{issues:[`options.articleBodyField: ${e.articleBodyField} is not a field of ${c} this org lets a body be written to`+(o.length>0?` (${o.join(", ")})`:"")]};let t=e.knowledge.available?{available:!0,bodyFields:o}:e.knowledge,n={seed:e.seed??d.seed,caseStatus:{open:e.caseStatus.open,closed:e.caseStatus.closed},...i!==void 0?p(i):{}},l;try{l=g(a,n)}catch(s){if(s instanceof y)return{issues:s.issues};throw s}return{preparation:{options:n,objects:[...l.template.objects].sort((s,C)=>s.insertOrder-C.insertOrder).map(s=>({objectApiName:s.objectApiName,recordCount:s.recordCount,...s.optional===!0?{optional:!0}:{}})),tests:l.tests.length,caseStatusFrom:e.caseStatus.from==="org"?{from:"org"}:{from:"default",reason:e.caseStatus.reason},knowledge:t}}}function D(a){return async e=>{let r=await a.query(e),o=[...r.records];for(;!r.done&&r.nextRecordsUrl;)r=await a.queryMore(r.nextRecordsUrl),o.push(...r.records);return o}}export{h as a,w as b,k as c,c as d,E as e,T as f,v as g,D as h};
@@ -4,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}from"./chunk-LKQ5RKIV.mjs";import"./chunk-XAMBCQPU.mjs";import"./chunk-IG2MTQRP.mjs";import"./chunk-WR4Q363I.mjs";import"./chunk-O2HDYYUV.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-E5AHXLS6.mjs";import"./chunk-PZPJKATS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{b as AGENT_TEST_RUN_WAIT_MINUTES,a as AGENT_TEST_SPECS_DIR,e as agentTestApiName,f as agentTestCommands,d as agentTestSpecFileName,c as agentTestSpecYaml,g as nodeAgentTestSpecFiles,h as writeAgentTestSpec,i as writeScenarioTestSpec,j as yamlOf};
7
+ import{a,b,c,d,e,f,g,h,i,j}from"./chunk-YAJQS3OL.mjs";import"./chunk-Z42PHCVZ.mjs";import"./chunk-H4OBZIX3.mjs";import"./chunk-V3R45ZWT.mjs";import"./chunk-NWOI25WY.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-JKT5YAQ2.mjs";import"./chunk-3SKLBRPL.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as AGENT_TEST_RUN_WAIT_MINUTES,a as AGENT_TEST_SPECS_DIR,e as agentTestApiName,f as agentTestCommands,d as agentTestSpecFileName,c as agentTestSpecYaml,g as nodeAgentTestSpecFiles,h as writeAgentTestSpec,i as writeScenarioTestSpec,j as yamlOf};
@@ -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{c as E}from"./chunk-K2FBZIXY.mjs";import{b as S}from"./chunk-T63U4OZJ.mjs";import{h as N}from"./chunk-TZE3Y7IQ.mjs";import{b as h,e as m,k as y,l as b}from"./chunk-7EANH5PY.mjs";var z={kind:"master"};function w(i){return i.available&&i.active&&!i.master}function B(i){let t=i.find(n=>n.defaultRecordTypeMapping);if(t&&w(t))return{kind:"given",info:t,basis:"userDefault"};let e=i.filter(w);return e.length===1?{kind:"given",info:e[0],basis:"onlyOneOpen"}:z}function ie(i){if(i.kind!=="master")return{developerName:i.info.developerName,label:i.info.name,basis:i.basis}}var L=200,j=/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/;function se(i,t){let e=t.filter(n=>j.test(n)).slice(0,L).map(n=>`'${n}'`);return`SELECT RecordTypeId, COUNT(Id) n FROM ${N(i)} WHERE Id IN (${e.join(", ")}) GROUP BY RecordTypeId`}var U=b({RecordTypeId:h().nullish(),n:m().int().nonnegative()});function oe(i,t){let e=y(U).safeParse(i);if(!e.success)return{read:0,types:[],unread:"the org answered rows that name no record type count"};let n=new Map;for(let{RecordTypeId:s,n:o}of e.data){let a=K(s??null,t),d=n.get(a.developerName);d?d.rows+=o:n.set(a.developerName,{...a,rows:o})}let r=[...n.values()].sort((s,o)=>o.rows-s.rows);return{read:r.reduce((s,o)=>s+o.rows,0),types:r}}function K(i,t){if(i===null||E(i)){let n=t.find(r=>r.master);return{developerName:n?.developerName??"Master",label:n?.name??"Master"}}let e=t.find(n=>n.recordTypeId.slice(0,15)===i.slice(0,15));return e?{developerName:e.developerName,label:e.name}:{developerName:i,label:i}}function ae(i){if(!i)return;let t=B(i);return t.kind==="given"?t.info.recordTypeId:i.find(e=>e.master)?.recordTypeId}function fe(i){if(typeof i!="object"||i===null)return!1;let{errorCode:t,name:e}=i;return t==="NOT_FOUND"||e==="NOT_FOUND"}import{createHash as R,createHmac as T}from"node:crypto";var p="SANDFORGE_FROZEN_SALT",me=["keep","clear","firstName","lastName","companyName","phoneE164","email","registrationSIV","contractNumber","postalCodeGeneralize","dateMonthStart","dateShift","geoRound1","kmRound10"],f=class extends Error{constructor(){super(`No pseudonymization salt. In VS Code, the first extraction makes one and keeps it in the editor's secret storage, which could not keep it here. On the command line, give it with --salt-file <file>, or set ${p} (bash or zsh: export ${p}="<salt>"; PowerShell: $env:${p} = "<salt>") and start VS Code from that shell. Use the salt the dataset was built with: another one gives the same records other pseudonyms.`),this.name="MissingSaltError"}},V=["Alix","Camille","Dominique","\xC9loi","Faustine","Gabin","H\xE9lo\xEFse","Ibrahim","Jasmine","Kylian","L\xE9a","Mathis","Nour","Oc\xE9ane","Paul","Quitterie","Rayan","Salom\xE9","Th\xE9o","Ursule","Victor","Wendy","Xavier","Yasmine","Zacharie","Ambre","Bastien","Chlo\xE9","Dorian","Emma","Fabien","Gabrielle","Hugo","In\xE8s","Jules","Klara","Louis","Manon","No\xE9","Oph\xE9lie"],H=["Arnaud","Berthelot","Chevallier","Deschamps","Etcheverry","Fontaine","Guibert","Hamonic","Imbert","Jacquin","Kermarrec","Lefebvre","Mignard","Noirot","Ollivier","Perrin","Quentin","Rochefort","Seguin","Thibault","Uberti","Vasseur","Wagner","Xuereb","Yverneau","Zimmermann","Aubry","Barbier","Charpentier","Delattre","Esnault","Fournier","Gosselin","Hervieux","Leloup","Marchand","Navarro","Pasquier","Renard","Sauvage"],v=["Aster","Boreal","C\xE9drat","Delta","Ellipse","Fulmen","Granit","Halcyon","Isatis","Jaspe","Kelvin","Lumen","M\xE9ridien","Noroit","Obsidienne","Pulsar"],k=["Conseil","Services","Industries","Solutions","Groupe","SAS","Partenaires","Logistique"],$="ABCDEFGHJKLMNPRSTUVWXYZ",x=/^(\d{4})-(\d{2})-(\d{2})$/,A=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d{1,3})?(Z|[+-]\d{2}:?\d{2})$/;function Z(i){return Date.parse(i.replace(/([+-]\d{2})(\d{2})$/,"$1:$2"))}var D=864e5,u=class{salt;constructor(t){if(!t)throw new f;this.salt=t}get saltFingerprint(){return R("sha256").update(this.salt).digest("hex").slice(0,12)}get dateShiftDays(){return 200+R("sha256").update(`${this.salt}|dateShift-offset`).digest().readUInt32BE(0)%201}pseudonymize(t,e){if(e==null)return e;switch(t){case"keep":return e;case"clear":return"";case"firstName":return this.pick(t,String(e),V);case"lastName":return this.pick(t,String(e),H);case"companyName":return this.companyName(String(e));case"phoneE164":return this.phoneE164(String(e));case"email":return this.email(String(e));case"registrationSIV":return this.registrationSIV(String(e));case"contractNumber":return this.contractNumber(String(e));case"postalCodeGeneralize":return this.postalCodeGeneralize(String(e));case"dateMonthStart":return this.dateMonthStart(String(e));case"dateShift":return this.dateShift(e);case"geoRound1":return this.roundNumber(e,1);case"kmRound10":return this.roundTo(e,10)}}digest(t,e){return T("sha256",this.salt).update(`${t}|${e}`).digest()}*bytes(t,e){let n=this.digest(t,e),r=0;for(;;){for(let s of n)yield s;r+=1,n=T("sha256",this.salt).update(`${t}|${e}|#${r}`).digest()}}pick(t,e,n){let r=this.digest(t,e);return n[r.readUInt32BE(0)%n.length]}companyName(t){let e=this.digest("companyName",t),n=v[e.readUInt32BE(0)%v.length],r=k[e.readUInt32BE(4)%k.length];return`${n} ${r}`}phoneE164(t){let e=this.bytes("phoneE164",t),n="";for(let r=0;r<4;r++)n+=String(e.next().value%10);return`+3363998${n}`}email(t){return`user-${this.digest("email",t).subarray(0,4).toString("hex")}@example.invalid`}registrationSIV(t){let e=this.bytes("registrationSIV",t),n=()=>$[e.next().value%$.length],r=()=>String(e.next().value%10);return`${n()}${n()}-${r()}${r()}${r()}-${n()}${n()}`}contractNumber(t){let e=this.bytes("contractNumber",t),n="";for(let r of t)r>="0"&&r<="9"?n+=String(e.next().value%10):r>="A"&&r<="Z"?n+=String.fromCharCode(65+e.next().value%26):r>="a"&&r<="z"?n+=String.fromCharCode(97+e.next().value%26):n+=r;return n}postalCodeGeneralize(t){let e=t.trim();if(e.length<=2)return e;if(/^\d+$/.test(e))return e.slice(0,2)+"0".repeat(e.length-2);let n=e.slice(0,2);for(let r of e.slice(2))r>="0"&&r<="9"?n+="0":r>="A"&&r<="Z"||r>="a"&&r<="z"?n+="X":n+=r;return n}dateMonthStart(t){let e=x.exec(t)??A.exec(t);return e?`${e[1]}-${e[2]}-01`:""}dateShift(t){if(typeof t=="string"&&x.test(t))return new Date(Date.parse(`${t}T00:00:00Z`)-this.dateShiftDays*D).toISOString().slice(0,10);if(typeof t=="string"&&A.test(t)){let e=Z(t);if(Number.isFinite(e))return new Date(e-this.dateShiftDays*D).toISOString()}return""}roundNumber(t,e){let n=typeof t=="number"?t:Number(String(t).trim());if(!Number.isFinite(n))return"";let r=10**e,s=Math.round(n*r)/r;return typeof t=="number"?s:String(s)}roundTo(t,e){let n=typeof t=="number"?t:Number(String(t).trim());if(!Number.isFinite(n))return"";let r=Math.round(n/e)*e;return typeof t=="number"?r:String(r)}};import{createHash as Y,randomBytes as X}from"node:crypto";var G=80,W=40,F=1e4,q=64,I=".invalid",g=/\.invalid$/i,C=/[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+/g,J=/\+?(?<!\d)\d(?:[\s.()/-]{0,2}\d){6,}/g;function M(i){return/^(?:(?:00)?330?|0)63998\d{4}$/.test(i.replace(/\D/g,""))}function O(i){return`+3363998${i.replace(/\D/g,"").slice(-4)}`}var Q=/^[\d\s.()/+-]+$/;function _(i,t){if(!Q.test(i))return null;let e=t.slice(3),n=/^[\s(]*\+/.test(i)?[`33${e}`,`330${e}`]:[`0${e}`,`33${e}`,`330${e}`,`0033${e}`,`00330${e}`],r=i.replace(/\D/g,"").length,s=n.find(a=>a.length===r);if(s===void 0)return null;let o=0;return i.replace(/\d/g,()=>s[o++])}function ee(i,t={}){let e=[];for(let n of i){let r=(n.type??"").toLowerCase(),s=S(n.name,r);if(!s)continue;let o=r==="email"||r==="phone",a=r==="email"?G:r==="phone"?W:0,d=n.length!==void 0&&n.length>0?n.length:a;e.push({name:t[n.name]??n.name,kind:s,typed:o,...d>0?{maxLength:d}:{},...n.externalId===!0?{key:!0}:{}})}return e}var P=class{pseudonymizer;upsertKeys;drawnFor=new Map;taken=new Set;exhausted=0;counted=new Map;constructor(t=X(32).toString("hex"),e={}){this.pseudonymizer=new u(t),this.upsertKeys=e.upsertKeys===!0}forObject(t,e,n={}){let r=ee(e,n);if(r.length!==0)return s=>{for(let o of r){let a=s[o.name];if(typeof a!="string")continue;let d=this.neutralize(o,a);d!==a&&(d===null?delete s[o.name]:s[o.name]=d,this.count(t,o))}}}email(t,e=G,n=!1){let r=t.trim();if(r===""||g.test(r))return t;let s=`${r}${I}`;if(s.length<=e)return s;let o=this.shortAddress(r,n);return o.length<=e?o:null}phone(t,e){return/\d/.test(t)?M(t)?(this.taken.add(O(t)),t):this.fictional(t,e):t}report(){let t=[],e=0;for(let[n,r]of this.counted)for(let[s,{kind:o,values:a}]of r)t.push({objectApiName:n,field:s,kind:o,values:a}),e+=a;return{neutralized:!0,fields:t,values:e,...this.exhausted>0?{numbersExhausted:this.exhausted}:{}}}neutralize(t,e){let n=this.upsertKeys&&t.key===!0;return t.typed?t.kind==="email"?this.email(e,t.maxLength,n):this.phone(e,t.maxLength):t.kind==="email"?this.addressesIn(e,t.maxLength,n):this.numbersIn(e,t.maxLength)}addressesIn(t,e,n=!1){let r=a=>e===void 0||a.length<=e,s=t.replace(C,a=>g.test(a)?a:`${a}${I}`);if(s===t||r(s))return s;let o=t.replace(C,a=>g.test(a)?a:this.shortAddress(a,n));return r(o)?o:null}numbersIn(t,e){let n=d=>e===void 0||d.length<=e,r=!1,s=d=>t.replace(J,c=>{if(M(c))return this.taken.add(O(c)),c;let l=this.drawnNumber(c);return l===null?(r=!0,c):_(c,l)??(d?`0${l.slice(3)}`:l)}),o=s(!1);if(r)return null;if(o===t||n(o))return o;let a=s(!0);return n(a)?a:null}fictional(t,e){let n=this.drawnNumber(t);if(n===null)return null;let r=_(t,n);if(r!==null&&(e===void 0||r.length<=e))return r;if(e===void 0||n.length<=e)return n;let s=`0${n.slice(3)}`;return s.length<=e?s:null}drawnNumber(t){let e=t.replace(/[^\d+]/g,""),n=this.drawnFor.get(e);if(n!==void 0)return n;if(this.taken.size>=F)return this.exhausted+=1,null;let r=o=>String(this.pseudonymizer.pseudonymize("phoneE164",o)),s=r(e);for(let o=1;this.taken.has(s)&&o<=q;o+=1)s=r(`${e}#${o}`);for(let o=Number(s.slice(-4));this.taken.has(s);)o=(o+1)%F,s=`+3363998${String(o).padStart(4,"0")}`;return this.drawnFor.set(e,s),this.taken.add(s),s}shortAddress(t,e=!1){let n=t.toLowerCase();return e?`user-${Y("sha256").update(n).digest("hex").slice(0,16)}@example.invalid`:String(this.pseudonymizer.pseudonymize("email",n))}count(t,e){let n=this.counted.get(t)??new Map,r=n.get(e.name)??{kind:e.kind,values:0};r.values+=1,n.set(e.name,r),this.counted.set(t,n)}};export{p as a,me as b,f as c,u as d,G as e,F as f,ee as g,P as h,B as i,ie as j,L as k,se as l,oe as m,ae as n,fe as o};
7
+ import{c as E}from"./chunk-BWWQXU2B.mjs";import{b as S}from"./chunk-T63U4OZJ.mjs";import{h as N}from"./chunk-TZE3Y7IQ.mjs";import{b as h,e as m,k as y,l as b}from"./chunk-WZQEK4WT.mjs";var z={kind:"master"};function w(i){return i.available&&i.active&&!i.master}function B(i){let t=i.find(n=>n.defaultRecordTypeMapping);if(t&&w(t))return{kind:"given",info:t,basis:"userDefault"};let e=i.filter(w);return e.length===1?{kind:"given",info:e[0],basis:"onlyOneOpen"}:z}function ie(i){if(i.kind!=="master")return{developerName:i.info.developerName,label:i.info.name,basis:i.basis}}var L=200,j=/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/;function se(i,t){let e=t.filter(n=>j.test(n)).slice(0,L).map(n=>`'${n}'`);return`SELECT RecordTypeId, COUNT(Id) n FROM ${N(i)} WHERE Id IN (${e.join(", ")}) GROUP BY RecordTypeId`}var U=b({RecordTypeId:h().nullish(),n:m().int().nonnegative()});function oe(i,t){let e=y(U).safeParse(i);if(!e.success)return{read:0,types:[],unread:"the org answered rows that name no record type count"};let n=new Map;for(let{RecordTypeId:s,n:o}of e.data){let a=K(s??null,t),d=n.get(a.developerName);d?d.rows+=o:n.set(a.developerName,{...a,rows:o})}let r=[...n.values()].sort((s,o)=>o.rows-s.rows);return{read:r.reduce((s,o)=>s+o.rows,0),types:r}}function K(i,t){if(i===null||E(i)){let n=t.find(r=>r.master);return{developerName:n?.developerName??"Master",label:n?.name??"Master"}}let e=t.find(n=>n.recordTypeId.slice(0,15)===i.slice(0,15));return e?{developerName:e.developerName,label:e.name}:{developerName:i,label:i}}function ae(i){if(!i)return;let t=B(i);return t.kind==="given"?t.info.recordTypeId:i.find(e=>e.master)?.recordTypeId}function fe(i){if(typeof i!="object"||i===null)return!1;let{errorCode:t,name:e}=i;return t==="NOT_FOUND"||e==="NOT_FOUND"}import{createHash as R,createHmac as T}from"node:crypto";var p="SANDFORGE_FROZEN_SALT",me=["keep","clear","firstName","lastName","companyName","phoneE164","email","registrationSIV","contractNumber","postalCodeGeneralize","dateMonthStart","dateShift","geoRound1","kmRound10"],f=class extends Error{constructor(){super(`No pseudonymization salt. In VS Code, the first extraction makes one and keeps it in the editor's secret storage, which could not keep it here. On the command line, give it with --salt-file <file>, or set ${p} (bash or zsh: export ${p}="<salt>"; PowerShell: $env:${p} = "<salt>") and start VS Code from that shell. Use the salt the dataset was built with: another one gives the same records other pseudonyms.`),this.name="MissingSaltError"}},V=["Alix","Camille","Dominique","\xC9loi","Faustine","Gabin","H\xE9lo\xEFse","Ibrahim","Jasmine","Kylian","L\xE9a","Mathis","Nour","Oc\xE9ane","Paul","Quitterie","Rayan","Salom\xE9","Th\xE9o","Ursule","Victor","Wendy","Xavier","Yasmine","Zacharie","Ambre","Bastien","Chlo\xE9","Dorian","Emma","Fabien","Gabrielle","Hugo","In\xE8s","Jules","Klara","Louis","Manon","No\xE9","Oph\xE9lie"],H=["Arnaud","Berthelot","Chevallier","Deschamps","Etcheverry","Fontaine","Guibert","Hamonic","Imbert","Jacquin","Kermarrec","Lefebvre","Mignard","Noirot","Ollivier","Perrin","Quentin","Rochefort","Seguin","Thibault","Uberti","Vasseur","Wagner","Xuereb","Yverneau","Zimmermann","Aubry","Barbier","Charpentier","Delattre","Esnault","Fournier","Gosselin","Hervieux","Leloup","Marchand","Navarro","Pasquier","Renard","Sauvage"],v=["Aster","Boreal","C\xE9drat","Delta","Ellipse","Fulmen","Granit","Halcyon","Isatis","Jaspe","Kelvin","Lumen","M\xE9ridien","Noroit","Obsidienne","Pulsar"],k=["Conseil","Services","Industries","Solutions","Groupe","SAS","Partenaires","Logistique"],$="ABCDEFGHJKLMNPRSTUVWXYZ",x=/^(\d{4})-(\d{2})-(\d{2})$/,A=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d{1,3})?(Z|[+-]\d{2}:?\d{2})$/;function Z(i){return Date.parse(i.replace(/([+-]\d{2})(\d{2})$/,"$1:$2"))}var D=864e5,u=class{salt;constructor(t){if(!t)throw new f;this.salt=t}get saltFingerprint(){return R("sha256").update(this.salt).digest("hex").slice(0,12)}get dateShiftDays(){return 200+R("sha256").update(`${this.salt}|dateShift-offset`).digest().readUInt32BE(0)%201}pseudonymize(t,e){if(e==null)return e;switch(t){case"keep":return e;case"clear":return"";case"firstName":return this.pick(t,String(e),V);case"lastName":return this.pick(t,String(e),H);case"companyName":return this.companyName(String(e));case"phoneE164":return this.phoneE164(String(e));case"email":return this.email(String(e));case"registrationSIV":return this.registrationSIV(String(e));case"contractNumber":return this.contractNumber(String(e));case"postalCodeGeneralize":return this.postalCodeGeneralize(String(e));case"dateMonthStart":return this.dateMonthStart(String(e));case"dateShift":return this.dateShift(e);case"geoRound1":return this.roundNumber(e,1);case"kmRound10":return this.roundTo(e,10)}}digest(t,e){return T("sha256",this.salt).update(`${t}|${e}`).digest()}*bytes(t,e){let n=this.digest(t,e),r=0;for(;;){for(let s of n)yield s;r+=1,n=T("sha256",this.salt).update(`${t}|${e}|#${r}`).digest()}}pick(t,e,n){let r=this.digest(t,e);return n[r.readUInt32BE(0)%n.length]}companyName(t){let e=this.digest("companyName",t),n=v[e.readUInt32BE(0)%v.length],r=k[e.readUInt32BE(4)%k.length];return`${n} ${r}`}phoneE164(t){let e=this.bytes("phoneE164",t),n="";for(let r=0;r<4;r++)n+=String(e.next().value%10);return`+3363998${n}`}email(t){return`user-${this.digest("email",t).subarray(0,4).toString("hex")}@example.invalid`}registrationSIV(t){let e=this.bytes("registrationSIV",t),n=()=>$[e.next().value%$.length],r=()=>String(e.next().value%10);return`${n()}${n()}-${r()}${r()}${r()}-${n()}${n()}`}contractNumber(t){let e=this.bytes("contractNumber",t),n="";for(let r of t)r>="0"&&r<="9"?n+=String(e.next().value%10):r>="A"&&r<="Z"?n+=String.fromCharCode(65+e.next().value%26):r>="a"&&r<="z"?n+=String.fromCharCode(97+e.next().value%26):n+=r;return n}postalCodeGeneralize(t){let e=t.trim();if(e.length<=2)return e;if(/^\d+$/.test(e))return e.slice(0,2)+"0".repeat(e.length-2);let n=e.slice(0,2);for(let r of e.slice(2))r>="0"&&r<="9"?n+="0":r>="A"&&r<="Z"||r>="a"&&r<="z"?n+="X":n+=r;return n}dateMonthStart(t){let e=x.exec(t)??A.exec(t);return e?`${e[1]}-${e[2]}-01`:""}dateShift(t){if(typeof t=="string"&&x.test(t))return new Date(Date.parse(`${t}T00:00:00Z`)-this.dateShiftDays*D).toISOString().slice(0,10);if(typeof t=="string"&&A.test(t)){let e=Z(t);if(Number.isFinite(e))return new Date(e-this.dateShiftDays*D).toISOString()}return""}roundNumber(t,e){let n=typeof t=="number"?t:Number(String(t).trim());if(!Number.isFinite(n))return"";let r=10**e,s=Math.round(n*r)/r;return typeof t=="number"?s:String(s)}roundTo(t,e){let n=typeof t=="number"?t:Number(String(t).trim());if(!Number.isFinite(n))return"";let r=Math.round(n/e)*e;return typeof t=="number"?r:String(r)}};import{createHash as Y,randomBytes as X}from"node:crypto";var G=80,W=40,F=1e4,q=64,I=".invalid",g=/\.invalid$/i,C=/[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+/g,J=/\+?(?<!\d)\d(?:[\s.()/-]{0,2}\d){6,}/g;function M(i){return/^(?:(?:00)?330?|0)63998\d{4}$/.test(i.replace(/\D/g,""))}function O(i){return`+3363998${i.replace(/\D/g,"").slice(-4)}`}var Q=/^[\d\s.()/+-]+$/;function _(i,t){if(!Q.test(i))return null;let e=t.slice(3),n=/^[\s(]*\+/.test(i)?[`33${e}`,`330${e}`]:[`0${e}`,`33${e}`,`330${e}`,`0033${e}`,`00330${e}`],r=i.replace(/\D/g,"").length,s=n.find(a=>a.length===r);if(s===void 0)return null;let o=0;return i.replace(/\d/g,()=>s[o++])}function ee(i,t={}){let e=[];for(let n of i){let r=(n.type??"").toLowerCase(),s=S(n.name,r);if(!s)continue;let o=r==="email"||r==="phone",a=r==="email"?G:r==="phone"?W:0,d=n.length!==void 0&&n.length>0?n.length:a;e.push({name:t[n.name]??n.name,kind:s,typed:o,...d>0?{maxLength:d}:{},...n.externalId===!0?{key:!0}:{}})}return e}var P=class{pseudonymizer;upsertKeys;drawnFor=new Map;taken=new Set;exhausted=0;counted=new Map;constructor(t=X(32).toString("hex"),e={}){this.pseudonymizer=new u(t),this.upsertKeys=e.upsertKeys===!0}forObject(t,e,n={}){let r=ee(e,n);if(r.length!==0)return s=>{for(let o of r){let a=s[o.name];if(typeof a!="string")continue;let d=this.neutralize(o,a);d!==a&&(d===null?delete s[o.name]:s[o.name]=d,this.count(t,o))}}}email(t,e=G,n=!1){let r=t.trim();if(r===""||g.test(r))return t;let s=`${r}${I}`;if(s.length<=e)return s;let o=this.shortAddress(r,n);return o.length<=e?o:null}phone(t,e){return/\d/.test(t)?M(t)?(this.taken.add(O(t)),t):this.fictional(t,e):t}report(){let t=[],e=0;for(let[n,r]of this.counted)for(let[s,{kind:o,values:a}]of r)t.push({objectApiName:n,field:s,kind:o,values:a}),e+=a;return{neutralized:!0,fields:t,values:e,...this.exhausted>0?{numbersExhausted:this.exhausted}:{}}}neutralize(t,e){let n=this.upsertKeys&&t.key===!0;return t.typed?t.kind==="email"?this.email(e,t.maxLength,n):this.phone(e,t.maxLength):t.kind==="email"?this.addressesIn(e,t.maxLength,n):this.numbersIn(e,t.maxLength)}addressesIn(t,e,n=!1){let r=a=>e===void 0||a.length<=e,s=t.replace(C,a=>g.test(a)?a:`${a}${I}`);if(s===t||r(s))return s;let o=t.replace(C,a=>g.test(a)?a:this.shortAddress(a,n));return r(o)?o:null}numbersIn(t,e){let n=d=>e===void 0||d.length<=e,r=!1,s=d=>t.replace(J,c=>{if(M(c))return this.taken.add(O(c)),c;let l=this.drawnNumber(c);return l===null?(r=!0,c):_(c,l)??(d?`0${l.slice(3)}`:l)}),o=s(!1);if(r)return null;if(o===t||n(o))return o;let a=s(!0);return n(a)?a:null}fictional(t,e){let n=this.drawnNumber(t);if(n===null)return null;let r=_(t,n);if(r!==null&&(e===void 0||r.length<=e))return r;if(e===void 0||n.length<=e)return n;let s=`0${n.slice(3)}`;return s.length<=e?s:null}drawnNumber(t){let e=t.replace(/[^\d+]/g,""),n=this.drawnFor.get(e);if(n!==void 0)return n;if(this.taken.size>=F)return this.exhausted+=1,null;let r=o=>String(this.pseudonymizer.pseudonymize("phoneE164",o)),s=r(e);for(let o=1;this.taken.has(s)&&o<=q;o+=1)s=r(`${e}#${o}`);for(let o=Number(s.slice(-4));this.taken.has(s);)o=(o+1)%F,s=`+3363998${String(o).padStart(4,"0")}`;return this.drawnFor.set(e,s),this.taken.add(s),s}shortAddress(t,e=!1){let n=t.toLowerCase();return e?`user-${Y("sha256").update(n).digest("hex").slice(0,16)}@example.invalid`:String(this.pseudonymizer.pseudonymize("email",n))}count(t,e){let n=this.counted.get(t)??new Map,r=n.get(e.name)??{kind:e.kind,values:0};r.values+=1,n.set(e.name,r),this.counted.set(t,n)}};export{p as a,me as b,f as c,u as d,G as e,F as f,ee as g,P as h,B as i,ie as j,L as k,se as l,oe as m,ae as n,fe as o};
@@ -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{lc as c,mc as l,oc as d,pc as m}from"./chunk-TTFDUKUS.mjs";var g=class{transform(n,r){let t=n;for(let o of r)t=p(t,o.type,o.config);return t}transformRecord(n,r){let t=d([{objectApiName:r.objectApiName,transformRules:r.transformRules}]);if(t.length>0)throw new Error(m(t));let o={...n},s=(r.externalIdField??"Id").toLowerCase(),R=a=>{let i=a.toLowerCase();return i!==s&&i!=="id"};for(let a of r.transformRules){let i=a.field?.trim();if(!i)throw new Error(l(c([r])));for(let f of h(o,i))R(f)&&(o[f]=p(o[f],a.type,a.config))}return o}};function h(e,n){let r=n.toLowerCase();return Object.keys(e).filter(t=>t.toLowerCase()===r)}function u(e){return(n,r)=>typeof n=="string"?e(n,r):n}function w(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string"||e.trim()==="")return;let n=Number(e);return Number.isNaN(n)?void 0:n}var b={uppercase:u(e=>e.toUpperCase()),lowercase:u(e=>e.toLowerCase()),trim:u(e=>e.trim()),truncate:u((e,n)=>e.slice(0,n.length??e.length)),prefix:u((e,n)=>`${n.prefix??""}${e}`),suffix:u((e,n)=>`${e}${n.suffix??""}`),replace:u((e,n)=>n.search?e.split(n.search).join(n.replace??""):e),regex_replace:u((e,n)=>n.regex?e.replace(y(n.regex),n.replace??""):e),map_value:(e,n)=>{let r=String(e??""),t=n.valueMap??{};return r in t?t[r]:e},default_value:(e,n)=>e==null||e===""?n.defaultValue??"":e,format_date:u((e,n)=>T(e,n.dateFormat??"YYYY-MM-DD")),format_number:(e,n)=>{let r=w(e);if(r===void 0)return e;let t=n.numberFormat??"0";return k(r,t)},custom_formula:(e,n)=>{let r=n.formula??"";return x(e,r)}};function y(e){try{return new RegExp(e,"g")}catch(n){throw new Error(`The pattern "${e}" of a Regex replace rule is no regular expression: `+(n instanceof Error?n.message:String(n)))}}function p(e,n,r){let t=b[n];return t(e,r)}function T(e,n){let r=new Date(e);if(isNaN(r.getTime()))return e;let t=r.getUTCFullYear().toString(),o=(r.getUTCMonth()+1).toString().padStart(2,"0"),s=r.getUTCDate().toString().padStart(2,"0");return n.replace("YYYY",t).replace("MM",o).replace("DD",s)}function k(e,n){let r=n.indexOf(".");if(r===-1)return Math.round(e).toString();let t=n.length-r-1;return e.toFixed(t)}function x(e,n){if(n.includes("VALUE")){let r=w(e);if(r!==void 0){let t=n.replace(/VALUE/g,r.toString());return N(t)??e}}return e}function N(e){let n=e.replace(/\s/g,""),r=/^(-?\d+(?:\.\d+)?)([-+*/])(-?\d+(?:\.\d+)?)$/.exec(n);if(!r)return;let t=Number(r[1]),o=r[2],s=Number(r[3]);switch(o){case"+":return t+s;case"-":return t-s;case"*":return t*s;case"/":return s===0?void 0:t/s;default:return}}export{g as a};
7
+ import{$c as l,_c as c,bd as d,cd as m}from"./chunk-ZQO5PDX5.mjs";var g=class{transform(n,r){let t=n;for(let o of r)t=p(t,o.type,o.config);return t}transformRecord(n,r){let t=d([{objectApiName:r.objectApiName,transformRules:r.transformRules}]);if(t.length>0)throw new Error(m(t));let o={...n},s=(r.externalIdField??"Id").toLowerCase(),R=a=>{let i=a.toLowerCase();return i!==s&&i!=="id"};for(let a of r.transformRules){let i=a.field?.trim();if(!i)throw new Error(l(c([r])));for(let f of h(o,i))R(f)&&(o[f]=p(o[f],a.type,a.config))}return o}};function h(e,n){let r=n.toLowerCase();return Object.keys(e).filter(t=>t.toLowerCase()===r)}function u(e){return(n,r)=>typeof n=="string"?e(n,r):n}function w(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string"||e.trim()==="")return;let n=Number(e);return Number.isNaN(n)?void 0:n}var b={uppercase:u(e=>e.toUpperCase()),lowercase:u(e=>e.toLowerCase()),trim:u(e=>e.trim()),truncate:u((e,n)=>e.slice(0,n.length??e.length)),prefix:u((e,n)=>`${n.prefix??""}${e}`),suffix:u((e,n)=>`${e}${n.suffix??""}`),replace:u((e,n)=>n.search?e.split(n.search).join(n.replace??""):e),regex_replace:u((e,n)=>n.regex?e.replace(y(n.regex),n.replace??""):e),map_value:(e,n)=>{let r=String(e??""),t=n.valueMap??{};return r in t?t[r]:e},default_value:(e,n)=>e==null||e===""?n.defaultValue??"":e,format_date:u((e,n)=>T(e,n.dateFormat??"YYYY-MM-DD")),format_number:(e,n)=>{let r=w(e);if(r===void 0)return e;let t=n.numberFormat??"0";return k(r,t)},custom_formula:(e,n)=>{let r=n.formula??"";return x(e,r)}};function y(e){try{return new RegExp(e,"g")}catch(n){throw new Error(`The pattern "${e}" of a Regex replace rule is no regular expression: `+(n instanceof Error?n.message:String(n)))}}function p(e,n,r){let t=b[n];return t(e,r)}function T(e,n){let r=new Date(e);if(isNaN(r.getTime()))return e;let t=r.getUTCFullYear().toString(),o=(r.getUTCMonth()+1).toString().padStart(2,"0"),s=r.getUTCDate().toString().padStart(2,"0");return n.replace("YYYY",t).replace("MM",o).replace("DD",s)}function k(e,n){let r=n.indexOf(".");if(r===-1)return Math.round(e).toString();let t=n.length-r-1;return e.toFixed(t)}function x(e,n){if(n.includes("VALUE")){let r=w(e);if(r!==void 0){let t=n.replace(/VALUE/g,r.toString());return N(t)??e}}return e}function N(e){let n=e.replace(/\s/g,""),r=/^(-?\d+(?:\.\d+)?)([-+*/])(-?\d+(?:\.\d+)?)$/.exec(n);if(!r)return;let t=Number(r[1]),o=r[2],s=Number(r[3]);switch(o){case"+":return t+s;case"-":return t-s;case"*":return t*s;case"/":return s===0?void 0:t/s;default:return}}export{g as a};
@@ -0,0 +1,9 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{createHash as g}from"node:crypto";function h(n){return n.slice(0,15)}function b(n,t){let e=h(n),r=h(t);return e<r?-1:e>r?1:0}var k=2**21,w=2**53;function v(n,t){let e=g("sha256").update(`${n}:${h(t)}`).digest(),r=e.readUInt32BE(0),s=e.readUInt32BE(4)>>>11;return(r*k+s)/w}function x(n,t){return n/Math.max(t,n+1)}var y=1024;function D(n,t){let e=Math.floor(Math.max(0,n)/y);return Math.max(1,Math.min(e,t??1/0))}function l(n,t){return n.rank!==t.rank?n.rank<t.rank?-1:1:n.objectApiName!==t.objectApiName?n.objectApiName<t.objectApiName?-1:1:b(n.id,t.id)}var p=class{items=[];get size(){return this.items.length}peek(){return this.items[0]}push(t){let e=this.items;e.push(t);let r=e.length-1;for(;r>0;){let s=r-1>>1;if(l(e[r],e[s])<=0)break;[e[r],e[s]]=[e[s],e[r]],r=s}}pop(){let t=this.items,e=t[0],r=t.pop();if(t.length===0||r===void 0)return e;t[0]=r;let s=0;for(;;){let i=2*s+1,u=i+1,o=s;if(i<t.length&&l(t[i],t[o])>0&&(o=i),u<t.length&&l(t[u],t[o])>0&&(o=u),o===s)break;[t[s],t[o]]=[t[o],t[s]],s=o}return e}values(){return this.items}};function f(n){return`${n.objectApiName}
8
+ ${h(n.id)}`}function d(n,t){return t===void 0?n:`${n}
9
+ ${t}`}var m=class{constructor(t,e){this.most=t;this.floor=e}most;floor;kept=new p;floors=new Map;inKept=new Set;inFloor=new Set;letGo=1/0;offer(t,e,r,s){let i={objectApiName:t,id:e,rank:r},u=[];if(this.floor>0){let o=d(t,s),a=this.floors.get(o);if(a||(a=new p,this.floors.set(o,a)),a.push(i),this.inFloor.add(f(i)),a.size>this.floor){let c=a.pop();c&&(this.inFloor.delete(f(c)),u.push(c))}}if(this.most>0){if(this.kept.push(i),this.inKept.add(f(i)),this.kept.size>this.most){let o=this.kept.pop();o&&(this.inKept.delete(f(o)),u.push(o))}}else u.push(i);for(let o of u){let a=f(o);!this.inKept.has(a)&&!this.inFloor.has(a)&&(this.letGo=Math.min(this.letGo,o.rank))}}keeps(t,e,r){let s=this.floors.get(d(t,r));if(this.floor>0&&(s?.size??0)<this.floor||this.kept.size<this.most)return!0;let i=this.kept.peek();return i!==void 0&&e<i.rank}leftUnread(t){this.letGo=Math.min(this.letGo,t)}get beyond(){return this.letGo}drawn(){let t=new Map;for(let e of this.kept.values())t.set(f(e),e);for(let e of this.floors.values())for(let r of e.values())t.set(f(r),{...r,rank:0});return[...t.values()].sort(l)}};export{h as a,b,v as c,x as d,y as e,D as f,l as g,p as h,m as i};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a,b}from"./chunk-WR4Q363I.mjs";import"./chunk-O2HDYYUV.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{a as ScenarioCompileError,b as compileScenario};
7
+ import{a,b}from"./chunk-V3R45ZWT.mjs";import"./chunk-NWOI25WY.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as ScenarioCompileError,b as compileScenario};
@@ -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}from"./chunk-BXU6WFMH.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{a as ReferenceLinker};
7
+ import{a}from"./chunk-ZUBBEP75.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as ReferenceLinker};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import*as i from"node:fs";import*as t from"node:path";function c(e){let r=t.resolve(e);for(;;){if(i.existsSync(t.join(r,".git"))||i.existsSync(t.join(r,"pnpm-workspace.yaml")))return r;let o=t.dirname(r);if(o===r)throw new Error(`No repository root found above ${e}`);r=o}}function p(e){let r=t.resolve(e);return process.platform==="win32"?r.toLowerCase():r}function h(e){if(!/^[A-Za-z0-9_-]{1,128}$/.test(e))throw new Error(`Not an org id a file of the sas can be named after: "${e}"`);return e}var a=class extends Error{constructor(o,s){super(`Refusing output path inside the repository: ${o} (repo root: ${s}). Frozen-dataset exports, retained-ID lists and working manifests must live in a sas directory OUTSIDE the repo \u2014 versioning them would create a real\u2194anonymized correspondence table.`);this.resolvedPath=o;this.repoRoot=s;this.name="InsideRepoPathError"}resolvedPath;repoRoot},l=class{repoRoot;constructor(r){this.repoRoot=r?t.resolve(r):c(process.cwd())}isInsideRepo(r){let o=p(this.repoRoot),s=p(r);if(s===o)return!0;let n=t.relative(o,s);return n!==""&&!n.startsWith("..")&&!t.isAbsolute(n)}assertOutsideRepo(r){if(this.isInsideRepo(r))throw new a(t.resolve(r),this.repoRoot);return t.resolve(r)}};export{c as a,h as b,a as c,l as d};
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{b as X,e as Y}from"./chunk-O2HDYYUV.mjs";import{a as G,b as q,e as J,f as Q,j as L}from"./chunk-FQGHL7GR.mjs";import{ja as A,la as N,ma as Z,na as W}from"./chunk-TTFDUKUS.mjs";var O=class extends Error{constructor(t){super(`The scenario cannot be compiled: ${t.join("; ")}`);this.issues=t;this.name="ScenarioCompileError"}issues},ee="2026-10-28T00:00:00.000Z",x={subject:255,description:32e3,commentBody:4e3,articleTitle:255,articleSummary:1e3},ie=new Set(["Phone"]);function $e(e,n={}){let t=Z.safeParse(e),a=W.safeParse(n);if(!t.success||!a.success)throw new O([...t.error?.issues.map(i=>te(["pack",...i.path],i))??[],...a.error?.issues.map(i=>te(["options",...i.path],i))??[]]);let r=n.customers??e.customers.count;if(r<e.topics.length)throw new O([`options.customers: ${r} customer(s) for ${e.topics.length} topics: each topic's utterances are said about a customer's open case on it`]);let s=n.seed??A.seed,u=n.historyPerCustomer??A.historyPerCustomer,l=n.caseStatus??A.caseStatus,c=ge(e.language),o=ce(),p=e.id,m=e.topics,f=fe(p,r,c,s),S=f.map((i,d)=>({key:i.key,values:o.row({Name:i.company,Industry:e.customers.industry,Type:"Customer - Direct",Phone:L(c,2*d),Website:`https://www.${se(i.company)}`})})),$=f.map((i,d)=>({key:i.key,parentKey:i.key,values:o.row({FirstName:i.firstName,LastName:i.lastName,Email:i.email,Phone:L(c,2*d+1)})})),T=m.map(()=>0),k=[],M=[],D=[],z=[],F=i=>`${p}-article-${m[i].key}`;for(let[i,d]of f.entries()){let I=[...Array.from({length:u},(g,h)=>({topicIndex:(i+1+h)%m.length,key:`${d.key}-h${h+1}`,open:!1})),{topicIndex:i%m.length,key:`${d.key}-open`,open:!0}];for(let{topicIndex:g,key:h,open:j}of I){let U=m[g].caseTemplates,w=U[T[g]++%U.length],v=o.text(P(w.subject,d),x.subject),V={...d,caseSubject:v};k.push({key:h,parentKey:d.key,values:o.row({Subject:v,Description:o.text(P(w.description,V),x.description),Status:j?l.open:l.closed,Priority:w.priority,Origin:w.origin})}),M.push(...le(h,w,j,V,o)),j?D.push({key:h,subject:v,topicIndex:g,customer:d}):z.push({caseKey:h,articleKey:F(g)})}}let y=ue(n),_=[],oe=m.map((i,d)=>{if(!y)return;let I=i.article.facts.map(h=>o.text(h)),g=me(o.text(i.article.body),I,y);if(typeof g=="string")return g;_.push(`pack.topics[${d}].article.facts[${g.unfit}]: the fact "${i.article.facts[g.unfit]}" does not fit, with the facts before it, in the ${y.max} characters of ${y.name}, the field the article's body goes to in this org: shorten the facts, or give Knowledge a longer field for the body`)});if(_.length>0)throw new O(_);let H=[...m.map((i,d)=>({key:F(d),values:ne(i.article,`${p}-${i.key}-${s}`,e,o,y&&{name:y.name,text:oe[d]??""})})),{key:`${p}-decoy-article`,values:ne(e.decoy,`${p}-${s}-decoy`,e,o,y&&{name:y.name,text:de(o.text(e.decoy.body),o.text(e.decoy.summary),y)})}],ae={id:`scenario-${p}`,name:o.text(e.name),description:o.text(e.businessContext),version:1,strategy:"template",objects:[R("Account",0,S),R("Contact",1,$),R("Case",2,k),R("CaseComment",3,M),{...R("Knowledge__kav",4,H),optional:!0}],relations:[B("Contact","AccountId","Account"),B("Case","ContactId","Contact"),B("CaseComment","ParentId","Case")],tags:["scenario",p],createdAt:ee,updatedAt:ee};return{packId:p,seed:s,template:ae,tests:pe(e,D,F,H,o),closedCaseArticles:z}}function te(e,n){return`${e.reduce((a,r)=>typeof r=="number"?`${a}[${r}]`:`${a}.${String(r)}`,"").replace(/^\./,"")}: ${n.message}`}function ce(){let e=X(),n=new Map,t=r=>{let s=n.get(r);if(s!==void 0)return s;let u=e(r);return n.set(r,u),u},a=(r,s)=>Y(r,s,t);return{text(r,s){let u=a({text:r},new Set).text;return E(typeof u=="string"?u:r,s)},row(r){return a(r,ie)}}}function E(e,n){if(n===void 0||e.length<=n)return e;let t=e.slice(0,n);if(/\s/.test(e.charAt(n)))return t.trimEnd();let a=t.search(/\s\S*$/);return a>0?t.slice(0,a).trimEnd():t}function P(e,n){return e.replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g,(t,a)=>n[a]??t)}function le(e,n,t,a,r){return(t?[n.followUp]:n.resolution).map((u,l)=>({key:`${e}-${l+1}`,parentKey:e,values:{CommentBody:r.text(P(u,a),x.commentBody),IsPublished:!1}}))}function ne(e,n,t,a,r){let s={Title:a.text(e.title,x.articleTitle),UrlName:n,Summary:a.text(e.summary,x.articleSummary),Language:t.language,IsVisibleInPkb:!1,IsVisibleInCsp:!1,IsVisibleInPrm:!1};return r&&(s[r.name]=r.text),s}function ue(e){let n=e.articleBodyField;if(n===void 0)return;let t=e.articleBodyLength??(n==="Summary"?x.articleSummary:void 0);return{name:n,...t!==void 0?{max:t}:{},html:e.articleBodyHtml===!0}}function K(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function C(e,n){return n.html?e.map(t=>`<p>${re(t)}</p>`).join(""):e.join(`
7
+ import{b as X,e as Y}from"./chunk-NWOI25WY.mjs";import{a as G,b as q,e as J,f as Q,j as L}from"./chunk-FQGHL7GR.mjs";import{Ha as A,Ja as N,Ka as Z,La as W}from"./chunk-ZQO5PDX5.mjs";var O=class extends Error{constructor(t){super(`The scenario cannot be compiled: ${t.join("; ")}`);this.issues=t;this.name="ScenarioCompileError"}issues},ee="2026-10-28T00:00:00.000Z",x={subject:255,description:32e3,commentBody:4e3,articleTitle:255,articleSummary:1e3},ie=new Set(["Phone"]);function $e(e,n={}){let t=Z.safeParse(e),a=W.safeParse(n);if(!t.success||!a.success)throw new O([...t.error?.issues.map(i=>te(["pack",...i.path],i))??[],...a.error?.issues.map(i=>te(["options",...i.path],i))??[]]);let r=n.customers??e.customers.count;if(r<e.topics.length)throw new O([`options.customers: ${r} customer(s) for ${e.topics.length} topics: each topic's utterances are said about a customer's open case on it`]);let s=n.seed??A.seed,u=n.historyPerCustomer??A.historyPerCustomer,l=n.caseStatus??A.caseStatus,c=ge(e.language),o=ce(),p=e.id,m=e.topics,f=fe(p,r,c,s),S=f.map((i,d)=>({key:i.key,values:o.row({Name:i.company,Industry:e.customers.industry,Type:"Customer - Direct",Phone:L(c,2*d),Website:`https://www.${se(i.company)}`})})),$=f.map((i,d)=>({key:i.key,parentKey:i.key,values:o.row({FirstName:i.firstName,LastName:i.lastName,Email:i.email,Phone:L(c,2*d+1)})})),T=m.map(()=>0),k=[],M=[],D=[],z=[],F=i=>`${p}-article-${m[i].key}`;for(let[i,d]of f.entries()){let I=[...Array.from({length:u},(g,h)=>({topicIndex:(i+1+h)%m.length,key:`${d.key}-h${h+1}`,open:!1})),{topicIndex:i%m.length,key:`${d.key}-open`,open:!0}];for(let{topicIndex:g,key:h,open:j}of I){let U=m[g].caseTemplates,w=U[T[g]++%U.length],v=o.text(P(w.subject,d),x.subject),V={...d,caseSubject:v};k.push({key:h,parentKey:d.key,values:o.row({Subject:v,Description:o.text(P(w.description,V),x.description),Status:j?l.open:l.closed,Priority:w.priority,Origin:w.origin})}),M.push(...le(h,w,j,V,o)),j?D.push({key:h,subject:v,topicIndex:g,customer:d}):z.push({caseKey:h,articleKey:F(g)})}}let y=ue(n),_=[],oe=m.map((i,d)=>{if(!y)return;let I=i.article.facts.map(h=>o.text(h)),g=me(o.text(i.article.body),I,y);if(typeof g=="string")return g;_.push(`pack.topics[${d}].article.facts[${g.unfit}]: the fact "${i.article.facts[g.unfit]}" does not fit, with the facts before it, in the ${y.max} characters of ${y.name}, the field the article's body goes to in this org: shorten the facts, or give Knowledge a longer field for the body`)});if(_.length>0)throw new O(_);let H=[...m.map((i,d)=>({key:F(d),values:ne(i.article,`${p}-${i.key}-${s}`,e,o,y&&{name:y.name,text:oe[d]??""})})),{key:`${p}-decoy-article`,values:ne(e.decoy,`${p}-${s}-decoy`,e,o,y&&{name:y.name,text:de(o.text(e.decoy.body),o.text(e.decoy.summary),y)})}],ae={id:`scenario-${p}`,name:o.text(e.name),description:o.text(e.businessContext),version:1,strategy:"template",objects:[R("Account",0,S),R("Contact",1,$),R("Case",2,k),R("CaseComment",3,M),{...R("Knowledge__kav",4,H),optional:!0}],relations:[B("Contact","AccountId","Account"),B("Case","ContactId","Contact"),B("CaseComment","ParentId","Case")],tags:["scenario",p],createdAt:ee,updatedAt:ee};return{packId:p,seed:s,template:ae,tests:pe(e,D,F,H,o),closedCaseArticles:z}}function te(e,n){return`${e.reduce((a,r)=>typeof r=="number"?`${a}[${r}]`:`${a}.${String(r)}`,"").replace(/^\./,"")}: ${n.message}`}function ce(){let e=X(),n=new Map,t=r=>{let s=n.get(r);if(s!==void 0)return s;let u=e(r);return n.set(r,u),u},a=(r,s)=>Y(r,s,t);return{text(r,s){let u=a({text:r},new Set).text;return E(typeof u=="string"?u:r,s)},row(r){return a(r,ie)}}}function E(e,n){if(n===void 0||e.length<=n)return e;let t=e.slice(0,n);if(/\s/.test(e.charAt(n)))return t.trimEnd();let a=t.search(/\s\S*$/);return a>0?t.slice(0,a).trimEnd():t}function P(e,n){return e.replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g,(t,a)=>n[a]??t)}function le(e,n,t,a,r){return(t?[n.followUp]:n.resolution).map((u,l)=>({key:`${e}-${l+1}`,parentKey:e,values:{CommentBody:r.text(P(u,a),x.commentBody),IsPublished:!1}}))}function ne(e,n,t,a,r){let s={Title:a.text(e.title,x.articleTitle),UrlName:n,Summary:a.text(e.summary,x.articleSummary),Language:t.language,IsVisibleInPkb:!1,IsVisibleInCsp:!1,IsVisibleInPrm:!1};return r&&(s[r.name]=r.text),s}function ue(e){let n=e.articleBodyField;if(n===void 0)return;let t=e.articleBodyLength??(n==="Summary"?x.articleSummary:void 0);return{name:n,...t!==void 0?{max:t}:{},html:e.articleBodyHtml===!0}}function K(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function C(e,n){return n.html?e.map(t=>`<p>${re(t)}</p>`).join(""):e.join(`
8
8
 
9
9
  `)}function re(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function b(e,n){return n.max===void 0||e.length<=n.max}function me(e,n,t){let a=K(e),r=t.html?C(a,t):e;if(b(r,t))return r;let s=a.filter(c=>n.some(o=>N(c,o)));if(n.every(c=>N(s.join(`
10
10