sandforge 1.79.0 → 1.80.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/lib/{chunk-JVL444U5.mjs → chunk-2BA2XKAY.mjs} +1 -1
  2. package/lib/chunk-2CNCDM56.mjs +7 -0
  3. package/lib/{chunk-W7KFAY55.mjs → chunk-2GTBABKU.mjs} +1 -1
  4. package/lib/{chunk-DLDX6RRC.mjs → chunk-2NBYT7GR.mjs} +1 -1
  5. package/lib/{chunk-HV2MXMGI.mjs → chunk-2UZPIMUC.mjs} +1 -1
  6. package/lib/chunk-3F6Q5E7I.mjs +14 -0
  7. package/lib/{chunk-PBI4BYWW.mjs → chunk-3RZQZHEB.mjs} +1 -1
  8. package/lib/{chunk-P7GSGFJO.mjs → chunk-3TJON4F3.mjs} +1 -1
  9. package/lib/chunk-4VS2V6WU.mjs +25 -0
  10. package/lib/{chunk-TQX3PURV.mjs → chunk-5K5VLULK.mjs} +1 -1
  11. package/lib/{chunk-MYTIL2JD.mjs → chunk-5TC3QB4U.mjs} +1 -1
  12. package/lib/{chunk-NM4MDLK4.mjs → chunk-6XYKJSGX.mjs} +1 -1
  13. package/lib/{chunk-RFEO2KAN.mjs → chunk-74Q6DORA.mjs} +1 -1
  14. package/lib/chunk-7ABODJ4G.mjs +7 -0
  15. package/lib/{chunk-ZPYJPGDK.mjs → chunk-7EGQP6S4.mjs} +1 -1
  16. package/lib/chunk-7FFGJWHN.mjs +7 -0
  17. package/lib/chunk-7YDNUBO5.mjs +7 -0
  18. package/lib/{chunk-CGWXQX75.mjs → chunk-A527W53V.mjs} +1 -1
  19. package/lib/chunk-ADOAS63R.mjs +7 -0
  20. package/lib/chunk-AEKONPF4.mjs +7 -0
  21. package/lib/{chunk-4HFRHFGQ.mjs → chunk-B5QQJ4SI.mjs} +1 -1
  22. package/lib/{chunk-2BVTCNWA.mjs → chunk-BGUEWRK2.mjs} +1 -1
  23. package/lib/{chunk-GNC27UEU.mjs → chunk-BKDV4ENO.mjs} +1 -1
  24. package/lib/{chunk-QRV2OSIS.mjs → chunk-BTWDMNN3.mjs} +1 -1
  25. package/lib/{chunk-FOVVHGEP.mjs → chunk-BV6VTP3J.mjs} +1 -1
  26. package/lib/{chunk-PZTSVQSF.mjs → chunk-BXU6WFMH.mjs} +1 -1
  27. package/lib/{chunk-ZQOZ4EFW.mjs → chunk-BY2HJFFG.mjs} +1 -1
  28. package/lib/{chunk-NZ5ZZLKS.mjs → chunk-CEX3NEZL.mjs} +1 -1
  29. package/lib/{chunk-HTJ5OGP5.mjs → chunk-CHYDMRSV.mjs} +1 -1
  30. package/lib/chunk-CION3VMZ.mjs +7 -0
  31. package/lib/chunk-COFG7Q6R.mjs +7 -0
  32. package/lib/chunk-CSBS5U5I.mjs +7 -0
  33. package/lib/{chunk-55HEMHEG.mjs → chunk-CU2INBND.mjs} +1 -1
  34. package/lib/chunk-DB7RBE5D.mjs +7 -0
  35. package/lib/{chunk-QPF6C5MX.mjs → chunk-DBB3EMIN.mjs} +1 -1
  36. package/lib/{chunk-F74IHMGL.mjs → chunk-DYFALGRT.mjs} +1 -1
  37. package/lib/{chunk-TEOLMRDO.mjs → chunk-E5AHXLS6.mjs} +1 -1
  38. package/lib/{chunk-LRFAIUN7.mjs → chunk-E5ZB3LU5.mjs} +1 -1
  39. package/lib/chunk-EFR2Y7E4.mjs +7 -0
  40. package/lib/chunk-EHQ3FX6X.mjs +7 -0
  41. package/lib/{chunk-RAAANPPG.mjs → chunk-ELFXJHU7.mjs} +1 -1
  42. package/lib/{chunk-BN7A4GRQ.mjs → chunk-EMNC6YI4.mjs} +1 -1
  43. package/lib/{chunk-HJC7AIBK.mjs → chunk-EQNW3UC2.mjs} +1 -1
  44. package/lib/{chunk-Z7X534S4.mjs → chunk-F43REJDZ.mjs} +2 -2
  45. package/lib/{chunk-QQZZMKU3.mjs → chunk-F6GUDTOB.mjs} +1 -1
  46. package/lib/{chunk-6EBMEGZB.mjs → chunk-FGRG7ANU.mjs} +1 -1
  47. package/lib/{chunk-4NAHW2D3.mjs → chunk-FKG7Q3WH.mjs} +1 -1
  48. package/lib/{chunk-7UQD6V6F.mjs → chunk-FPKYYFM7.mjs} +1 -1
  49. package/lib/{chunk-ZJKCWBRJ.mjs → chunk-FXXLX4O6.mjs} +1 -1
  50. package/lib/chunk-G35N4P7D.mjs +7 -0
  51. package/lib/{chunk-SIOZXPFG.mjs → chunk-GGD7ON3M.mjs} +1 -1
  52. package/lib/chunk-GSG7WZHM.mjs +7 -0
  53. package/lib/{chunk-OTWRDD6L.mjs → chunk-GSKCGQIP.mjs} +1 -1
  54. package/lib/{chunk-3CA767QB.mjs → chunk-HEKAZJRH.mjs} +1 -1
  55. package/lib/{chunk-4SNDMJP2.mjs → chunk-HLWMJF6Y.mjs} +1 -1
  56. package/lib/chunk-HOJYWTP7.mjs +20 -0
  57. package/lib/chunk-HS4YRX4J.mjs +7 -0
  58. package/lib/chunk-IFETCRWE.mjs +10 -0
  59. package/lib/{chunk-PUOX4NBJ.mjs → chunk-IG2MTQRP.mjs} +1 -1
  60. package/lib/{chunk-RACDTRZA.mjs → chunk-IGYH7GMA.mjs} +1 -1
  61. package/lib/{chunk-X65MT4W3.mjs → chunk-IOIWJ3DJ.mjs} +1 -1
  62. package/lib/{chunk-4U6NXJNL.mjs → chunk-IQXHJEYB.mjs} +1 -1
  63. package/lib/{chunk-P2PJYWGQ.mjs → chunk-IWDREM66.mjs} +1 -1
  64. package/lib/{chunk-ZOVSMN5C.mjs → chunk-IZQZ6ZUF.mjs} +1 -1
  65. package/lib/{chunk-XBG5SP6Q.mjs → chunk-J525F5KI.mjs} +1 -1
  66. package/lib/{chunk-5CD257T7.mjs → chunk-JEERQRLW.mjs} +1 -1
  67. package/lib/{chunk-6QSM2WIH.mjs → chunk-JPUR2CFX.mjs} +1 -1
  68. package/lib/chunk-JWTSEDIQ.mjs +7 -0
  69. package/lib/chunk-K327QKMD.mjs +7 -0
  70. package/lib/{chunk-J7HVXMSW.mjs → chunk-KBJ5VERV.mjs} +1 -1
  71. package/lib/chunk-KDGMAGQR.mjs +7 -0
  72. package/lib/chunk-KRCA6IPH.mjs +8 -0
  73. package/lib/chunk-KYEDBS54.mjs +7 -0
  74. package/lib/chunk-L5FGY6YA.mjs +7 -0
  75. package/lib/{chunk-PNCONNFJ.mjs → chunk-L77FJZEP.mjs} +1 -1
  76. package/lib/{chunk-3OHPD72J.mjs → chunk-LKQ5RKIV.mjs} +1 -1
  77. package/lib/{chunk-WJY54JO7.mjs → chunk-LPBMBW3O.mjs} +1 -1
  78. package/lib/{chunk-LV6G4XTK.mjs → chunk-LWW4U276.mjs} +1 -1
  79. package/lib/{chunk-IAZB4WIL.mjs → chunk-M3ROUWDX.mjs} +1 -1
  80. package/lib/chunk-MFG4MUIO.mjs +9 -0
  81. package/lib/{chunk-H45UXY6G.mjs → chunk-MHMH6MTP.mjs} +1 -1
  82. package/lib/{chunk-HCIDVIOW.mjs → chunk-MILU7WFN.mjs} +1 -1
  83. package/lib/chunk-MJU2PGZQ.mjs +15 -0
  84. package/lib/{chunk-HJKM3E56.mjs → chunk-MJVTDA5Q.mjs} +1 -1
  85. package/lib/{chunk-SBIMVCXT.mjs → chunk-MS4FJDFD.mjs} +9 -9
  86. package/lib/{chunk-3SRXFZSD.mjs → chunk-MYW5QNGI.mjs} +1 -1
  87. package/lib/{chunk-VHI54FBK.mjs → chunk-N652NMZ4.mjs} +26 -26
  88. package/lib/{chunk-3DCUADVK.mjs → chunk-NTFIRZP6.mjs} +1 -1
  89. package/lib/{chunk-342FN7AO.mjs → chunk-NZC67CGR.mjs} +1 -1
  90. package/lib/{chunk-RSYICMZG.mjs → chunk-O2HDYYUV.mjs} +1 -1
  91. package/lib/chunk-OAZRPP4I.mjs +7 -0
  92. package/lib/{chunk-BILZ3SSR.mjs → chunk-OHWNPXWW.mjs} +1 -1
  93. package/lib/chunk-OLSGVAIL.mjs +341 -0
  94. package/lib/chunk-OO6CLPEH.mjs +7 -0
  95. package/lib/chunk-OPXCV2KL.mjs +7 -0
  96. package/lib/chunk-P33PSCXK.mjs +7 -0
  97. package/lib/{chunk-AUTM6H6Z.mjs → chunk-PJ5I73CK.mjs} +1 -1
  98. package/lib/{chunk-NTDN2JQZ.mjs → chunk-PZPJKATS.mjs} +1 -1
  99. package/lib/{chunk-5QKTYCWE.mjs → chunk-Q3DM32KF.mjs} +1 -1
  100. package/lib/{chunk-K22PA4XL.mjs → chunk-QR3WELJQ.mjs} +1 -1
  101. package/lib/{chunk-42RER7V4.mjs → chunk-R3X3LV64.mjs} +1 -1
  102. package/lib/chunk-RMBPOTD7.mjs +7 -0
  103. package/lib/{chunk-IEYG5ATY.mjs → chunk-RPI7LRTW.mjs} +1 -1
  104. package/lib/{chunk-5MMXFWPD.mjs → chunk-SE4QEZUG.mjs} +1 -1
  105. package/lib/{chunk-ALJVEUUS.mjs → chunk-SIHORWVK.mjs} +1 -1
  106. package/lib/{chunk-AAVJ5XVX.mjs → chunk-SOGQW4IG.mjs} +1 -1
  107. package/lib/chunk-SOU4FRYN.mjs +7 -0
  108. package/lib/chunk-SU65Z2BA.mjs +7 -0
  109. package/lib/chunk-T62WNR54.mjs +7 -0
  110. package/lib/{chunk-5O6JOMHS.mjs → chunk-TSLJUSLW.mjs} +1 -1
  111. package/lib/chunk-TTFDUKUS.mjs +47 -0
  112. package/lib/{chunk-57VHUYNG.mjs → chunk-TTKXMDBN.mjs} +1 -1
  113. package/lib/chunk-UCD54V2M.mjs +7 -0
  114. package/lib/{chunk-TBZMC2VV.mjs → chunk-UNJA4J37.mjs} +1 -1
  115. package/lib/{chunk-NGSMZZDA.mjs → chunk-VE6XKGGD.mjs} +1 -1
  116. package/lib/chunk-VS7ZXUII.mjs +824 -0
  117. package/lib/{chunk-ALUFROGA.mjs → chunk-VXQLDM4R.mjs} +1 -1
  118. package/lib/chunk-VYXMVJL5.mjs +7 -0
  119. package/lib/{chunk-WFEB5X4U.mjs → chunk-W622GUAW.mjs} +1 -1
  120. package/lib/chunk-W7U5E5ZL.mjs +9 -0
  121. package/lib/{chunk-AR7BE5O2.mjs → chunk-WA7EYLAQ.mjs} +1 -1
  122. package/lib/{chunk-EQF2IJS2.mjs → chunk-WR4Q363I.mjs} +1 -1
  123. package/lib/{chunk-ZXH4MBWP.mjs → chunk-WU3GLFZO.mjs} +1 -1
  124. package/lib/chunk-WXAQ7FK3.mjs +115 -0
  125. package/lib/{chunk-YBU4Z4QV.mjs → chunk-X5JYBPXP.mjs} +1 -1
  126. package/lib/chunk-XAMBCQPU.mjs +7 -0
  127. package/lib/{chunk-LQ4DRFUH.mjs → chunk-XLXIPIEW.mjs} +1 -1
  128. package/lib/{chunk-H2PJNIYJ.mjs → chunk-XUWL6ZPC.mjs} +1 -1
  129. package/lib/{chunk-P42X3B4D.mjs → chunk-YKKRIEH4.mjs} +1 -1
  130. package/lib/chunk-YRQGKDHM.mjs +7 -0
  131. package/lib/chunk-ZM6OJGIG.mjs +7 -0
  132. package/lib/{chunk-SFURUNJM.mjs → chunk-ZVAED4QV.mjs} +1 -1
  133. package/lib/sandforge-autopilot.mjs +29 -24
  134. package/lib/sandforge-backup.mjs +25 -21
  135. package/lib/sandforge-checkpoint.mjs +15 -14
  136. package/lib/sandforge-cleanup.mjs +14 -10
  137. package/lib/sandforge-clone.mjs +1 -1
  138. package/lib/sandforge-compare.mjs +9 -8
  139. package/lib/sandforge-dataops.mjs +1 -1
  140. package/lib/sandforge-empty.mjs +15 -15
  141. package/lib/sandforge-env.mjs +88 -88
  142. package/lib/sandforge-frozen.mjs +43 -34
  143. package/lib/sandforge-mcp.mjs +12 -12
  144. package/lib/sandforge-monitor.mjs +7 -7
  145. package/lib/sandforge-seed.mjs +1 -1
  146. package/lib/sandforge-sync.mjs +1 -1
  147. package/lib/sandforge.mjs +4 -4
  148. package/package.json +1 -1
  149. package/lib/chunk-2S5OMIIA.mjs +0 -7
  150. package/lib/chunk-36U7IQ6Y.mjs +0 -25
  151. package/lib/chunk-3F5YMM2F.mjs +0 -7
  152. package/lib/chunk-3RYLICRX.mjs +0 -7
  153. package/lib/chunk-4GL773D5.mjs +0 -7
  154. package/lib/chunk-4XZ5YT5O.mjs +0 -7
  155. package/lib/chunk-5AJRHRXA.mjs +0 -20
  156. package/lib/chunk-5HMAPZBV.mjs +0 -7
  157. package/lib/chunk-6LAXTAVN.mjs +0 -7
  158. package/lib/chunk-6MUEPV7M.mjs +0 -9
  159. package/lib/chunk-75ADZS6B.mjs +0 -7
  160. package/lib/chunk-B45CNPUX.mjs +0 -47
  161. package/lib/chunk-BS5T3MOQ.mjs +0 -7
  162. package/lib/chunk-D3QRXG63.mjs +0 -787
  163. package/lib/chunk-EEVVGGM6.mjs +0 -7
  164. package/lib/chunk-ENLBYECD.mjs +0 -7
  165. package/lib/chunk-EQOQASDQ.mjs +0 -7
  166. package/lib/chunk-FQBRBBY4.mjs +0 -7
  167. package/lib/chunk-GAM726CK.mjs +0 -7
  168. package/lib/chunk-HUMEKZT5.mjs +0 -8
  169. package/lib/chunk-I3JKJTLO.mjs +0 -110
  170. package/lib/chunk-KLX67VPL.mjs +0 -7
  171. package/lib/chunk-L776PUMV.mjs +0 -7
  172. package/lib/chunk-NEVXIGR6.mjs +0 -10
  173. package/lib/chunk-NHWE66K5.mjs +0 -7
  174. package/lib/chunk-OQOZAPCI.mjs +0 -7
  175. package/lib/chunk-PA3MKJVH.mjs +0 -7
  176. package/lib/chunk-RH3N2H7P.mjs +0 -7
  177. package/lib/chunk-SRQDABQ2.mjs +0 -15
  178. package/lib/chunk-SVS6UMDU.mjs +0 -323
  179. package/lib/chunk-TNXUU6W7.mjs +0 -14
  180. package/lib/chunk-VXHDBYMI.mjs +0 -7
  181. package/lib/chunk-WRU5FJFC.mjs +0 -7
  182. package/lib/chunk-X2PY6MWZ.mjs +0 -7
  183. package/lib/chunk-XEFDB2R4.mjs +0 -7
  184. package/lib/chunk-XETCPL7E.mjs +0 -7
  185. package/lib/chunk-Y5CGXLUB.mjs +0 -7
  186. package/lib/chunk-Y6J6QFI2.mjs +0 -7
  187. package/lib/chunk-YMJVMFPY.mjs +0 -7
  188. package/lib/chunk-YPSRZRIT.mjs +0 -7
  189. package/lib/chunk-YW2SBL4Z.mjs +0 -7
  190. package/lib/chunk-ZE6HKRR4.mjs +0 -9
  191. package/lib/chunk-ZLZRU6MO.mjs +0 -7
  192. package/lib/chunk-ZYEE34WO.mjs +0 -7
@@ -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{o as St}from"./chunk-SVS6UMDU.mjs";import"./chunk-AUTM6H6Z.mjs";import"./chunk-INIQ23K6.mjs";import"./chunk-RAAANPPG.mjs";import{a as Et}from"./chunk-PBI4BYWW.mjs";import"./chunk-ZE6HKRR4.mjs";import{a as Ft,b as Lt,d as Nt,e as Se,f as zt,g as Dt,h as Pt,i as It,j as re,k as ne,l as xt}from"./chunk-5AJRHRXA.mjs";import{k as Tt,n as Ct,p as jt}from"./chunk-42RER7V4.mjs";import"./chunk-XEFDB2R4.mjs";import"./chunk-H45UXY6G.mjs";import"./chunk-WRU5FJFC.mjs";import"./chunk-GMY5427L.mjs";import"./chunk-GNC27UEU.mjs";import"./chunk-YBU4Z4QV.mjs";import{a as _t}from"./chunk-TW3N6W5Z.mjs";import"./chunk-5P4PHJRL.mjs";import{Ba as H,K,Qa as Oe,Ra as vt,Ua as At,Va as oe,Xa as kt,Ya as X,ab as $t,bb as Rt,c as Ae,f as ke,g as $e,gb as Ot,h as ct,i as pt,k as ft,l as Re,m as ht,n as mt,o as gt,p as wt,t as bt}from"./chunk-D3QRXG63.mjs";import"./chunk-NM4MDLK4.mjs";import"./chunk-BS5T3MOQ.mjs";import"./chunk-TEOLMRDO.mjs";import"./chunk-FQBRBBY4.mjs";import"./chunk-YS4G22C2.mjs";import{a as ut}from"./chunk-SCKUIE3R.mjs";import{a as dt,b as lt}from"./chunk-QROPNEGY.mjs";import{b as me,e as Ze}from"./chunk-BZ24IAP5.mjs";import{c as Q,d as Y}from"./chunk-AV5SWEHP.mjs";import"./chunk-I7O6C2B5.mjs";import"./chunk-XCA5AONB.mjs";import{b as ee}from"./chunk-YMJVMFPY.mjs";import"./chunk-ALJVEUUS.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-BOGNK4LV.mjs";import{x as it}from"./chunk-36U7IQ6Y.mjs";import"./chunk-XETCPL7E.mjs";import"./chunk-K2FBZIXY.mjs";import"./chunk-Z7X534S4.mjs";import"./chunk-6QSM2WIH.mjs";import"./chunk-WJY54JO7.mjs";import{d as et}from"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-NEVXIGR6.mjs";import"./chunk-NTDN2JQZ.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-F74IHMGL.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-Y5CGXLUB.mjs";import"./chunk-3F5YMM2F.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import{b as Je,c as he}from"./chunk-L776PUMV.mjs";import{A as q,r as we,t as ye,u as be}from"./chunk-6MUEPV7M.mjs";import"./chunk-HJC7AIBK.mjs";import"./chunk-OTWRDD6L.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-RH3N2H7P.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-55HEMHEG.mjs";import"./chunk-P42X3B4D.mjs";import"./chunk-TUACWKIH.mjs";import{P as ve,Pa as nt,S as te,V as ot,W as rt,bb as st,cb as at}from"./chunk-VXHDBYMI.mjs";import{q as tt}from"./chunk-ENLBYECD.mjs";import"./chunk-PA3MKJVH.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-ZLZRU6MO.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-PNCONNFJ.mjs";import{D as ge}from"./chunk-CGWXQX75.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-SIOZXPFG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import{a as Xe,e as Qe,f as Ye,g as yt}from"./chunk-MTMH6H2A.mjs";import{Tc as Ve,Uc as fe,Vb as qe,Vc as Z,Wc as Ke,bd as He}from"./chunk-B45CNPUX.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-SBIMVCXT.mjs";import"./chunk-NTOVCTRS.mjs";import{existsSync as Ce,mkdirSync as ro,readdirSync as no,readFileSync as de}from"node:fs";import{dirname as so,join as _}from"node:path";import{homedir as ao}from"node:os";var io=`sandforge frozen \u2014 build and replay a Frozen Dataset, without the editor.
7
+ import{q as jt}from"./chunk-OLSGVAIL.mjs";import"./chunk-INIQ23K6.mjs";import"./chunk-ELFXJHU7.mjs";import{a as Lt}from"./chunk-3RZQZHEB.mjs";import"./chunk-W7U5E5ZL.mjs";import{a as Pt,b as It,d as xt,e as Le,f as _t,g as Mt,h as Bt,i as Ut,j as ae,k as ie,l as Gt}from"./chunk-HOJYWTP7.mjs";import{k as Nt,n as zt,p as Dt}from"./chunk-R3X3LV64.mjs";import"./chunk-ZM6OJGIG.mjs";import"./chunk-MHMH6MTP.mjs";import"./chunk-COFG7Q6R.mjs";import"./chunk-GMY5427L.mjs";import"./chunk-PJ5I73CK.mjs";import"./chunk-BKDV4ENO.mjs";import"./chunk-X5JYBPXP.mjs";import{a as Wt}from"./chunk-TW3N6W5Z.mjs";import"./chunk-5P4PHJRL.mjs";import{Na as X,O as H,b as ft,c as Ee,cb as Fe,db as Et,f as Oe,g as Te,gb as je,h as wt,hb as se,i as yt,jb as Ot,k as vt,kb as Z,l as Ce,m as bt,n as At,o as kt,ob as Tt,p as $t,pb as Ct,t as St,ub as Ft}from"./chunk-VS7ZXUII.mjs";import"./chunk-SOU4FRYN.mjs";import"./chunk-E5AHXLS6.mjs";import"./chunk-OO6CLPEH.mjs";import"./chunk-YS4G22C2.mjs";import{a as mt,b as gt}from"./chunk-QROPNEGY.mjs";import{b as be,e as rt}from"./chunk-BZ24IAP5.mjs";import{a as we}from"./chunk-SCKUIE3R.mjs";import{c as te,d as oe}from"./chunk-AV5SWEHP.mjs";import"./chunk-I7O6C2B5.mjs";import"./chunk-XCA5AONB.mjs";import{b as re}from"./chunk-2CNCDM56.mjs";import"./chunk-SIHORWVK.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-BOGNK4LV.mjs";import{y as ht}from"./chunk-4VS2V6WU.mjs";import"./chunk-KYEDBS54.mjs";import"./chunk-6XYKJSGX.mjs";import"./chunk-K2FBZIXY.mjs";import"./chunk-F43REJDZ.mjs";import"./chunk-JPUR2CFX.mjs";import"./chunk-LPBMBW3O.mjs";import{d as at}from"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-IFETCRWE.mjs";import"./chunk-PZPJKATS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-DYFALGRT.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-7FFGJWHN.mjs";import"./chunk-G35N4P7D.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import{b as ot,c as ve}from"./chunk-KDGMAGQR.mjs";import{B as q,s as ke,u as $e,v as Re}from"./chunk-MFG4MUIO.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-HS4YRX4J.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import{Ia as K,P as Se,Pa as ut,S as ne,V as dt,W as lt,bb as ct,cb as pt}from"./chunk-VYXMVJL5.mjs";import{q as it}from"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import{D as Ae}from"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import{a as tt,e as nt,f as st,g as Rt}from"./chunk-MTMH6H2A.mjs";import{Wc as Qe,Xc as ye,Yb as Je,Yc as ee,Zc as Ye,ed as et}from"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-NTOVCTRS.mjs";import{existsSync as De,mkdirSync as uo,readdirSync as co,readFileSync as pe}from"node:fs";import{dirname as po,join as B}from"node:path";import{homedir as fo}from"node:os";var ho=`sandforge frozen \u2014 build and replay a Frozen Dataset, without the editor.
8
8
 
9
9
  Usage:
10
10
  npx sandforge frozen <step> --config <file> [options]
@@ -41,10 +41,14 @@ Options:
41
41
  records changed since, kept for records that stay under them
42
42
  (a contact made by hand since under one of their accounts,
43
43
  which the org would delete along), of an object the user may
44
- not delete, out of the user's sight or unread \u2014 or when one
45
- of them was recorded before loads kept what they created: take
46
- the load back with remove first (--include-changed takes what
47
- changed since, and what was added under them since). Refused
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
+ ${we("cleanup")}, its dry run
51
+ first, then delete it. Refused
48
52
  the same way when the purge would have the org delete along a
49
53
  record the reload finds again by its keys \u2014 a quote under the
50
54
  opportunity an earlier load wrote: give that parent identity
@@ -110,7 +114,7 @@ Options:
110
114
  keeps quiet what tests the org's bypass; what an Apex
111
115
  trigger sends is read nowhere. --dry-run says it all,
112
116
  and what a load would be refused for
113
- ${ct({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."]})}
117
+ ${wt({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."]})}
114
118
  --include-changed remove also the records changed since the load, and what
115
119
  was added to them since (kept otherwise); with load
116
120
  --reload --sweep, the sweep of each load replaced takes
@@ -139,17 +143,20 @@ ${ct({run:"the load",simulation:"--dry-run",step:"with load: ",note:["Taken by t
139
143
  every record of the load; one that left records of its own
140
144
  keeps its own status. Once the load's records went already,
141
145
  the sweep runs alone, the way to take what such a sweep
142
- left (off otherwise). It sweeps too, each in its own
143
- window, every other load recorded whose records went \u2014 a
144
- load a reload replaced, kept for what its sweep left \u2014,
145
- and lets it go once that sweep took all it found. With
146
- load --reload: the sweep of each load the reload
147
- replaces, as its removal sweeps it, around the purge;
148
- what the target runs as it deletes is named once it has
149
- read what it takes, before the first delete, and
150
- answered as the purge's; with --dry-run, it lists what
151
- it would take. One refused, or that did not take all it
152
- was asked to, exits 3
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
153
160
  --sweep-late with --sweep: take too what it lists as made late; with
154
161
  --sweep-list, say what it would take
155
162
  --sweep-untied with --sweep: take too what it lists as tied to nothing of
@@ -221,8 +228,10 @@ Exit codes: 0 the step finished \u2014 a removal with nothing to take included,
221
228
  removal's preview once said, its refusals included \u2014, and verify's verdict is
222
229
  PASSED; 1 it failed or could not start, verify's verdict is FAILED, a dry run says
223
230
  the load would be refused, a load was refused before it wrote for what the target
224
- runs as it writes (AUTOMATION_NOT_ACCEPTED without --accept-automation) or for its
225
- emails (EMAILS_NOT_ACCEPTED without --accept-emails, FROZEN_EMAILS_EXCEEDED), or a removal
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
226
235
  stopped before its first delete at what the target runs, without
227
236
  --accept-automation; 2 a bad command line, or a question with
228
237
  no terminal to answer it (give --yes); 3 verify's verdict is PARTIAL, a load
@@ -232,10 +241,10 @@ of the load or its sweep did not take all it was asked to; 4 verify's verdict is
232
241
  UNSTABLE: no two readings agreed; 130 Ctrl-C stopped the step, 143 a SIGTERM, 129 a
233
242
  SIGHUP. A load is judged by its own report, which ends partial on a verification
234
243
  FAILED or PARTIAL; one UNSTABLE is said, and the verify step gives it a code.
235
- `,Mt=["select","extract","load","verify","remove","status"],lo={words:1,switches:["--pilot","--reload","--dry-run","--write-encrypted","--mute-automation","--accept-automation","--include-changed","--accept-emails","--sweep","--sweep-list",...$t,"--preview","--yes","--json",...$e.switches],values:["--config","--source","--target","--author","--salt-file","--store","--max-total","--gone-first",...$e.values]},Ut=1e6;function uo(o){let n;try{n=JSON.parse(de(o,"utf8"))}catch(e){process.stderr.write(`--gone-first: ${o} does not read: ${String(e)}
236
- `),process.exit(2)}return(!Array.isArray(n)||!n.every(e=>typeof e=="string"&&/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(e)))&&(process.stderr.write(`--gone-first: ${o} holds no JSON array of record ids.
237
- `),process.exit(2)),n}function co(o){let n=o.slice(2);(n.includes("--help")||n.includes("-h")||n.length===0)&&(process.stdout.write(io),process.exit(0));let e=d=>{let b=n.indexOf(d);return b>=0&&b+1<n.length?n[b+1]:void 0},r=n[0];Mt.includes(r)||(process.stderr.write(`The first word is the step: ${Mt.join(", ")} \u2014 not "${n[0]}".
238
- `),process.exit(2)),Xe(n,lo);let t=e("--config");t||(process.stderr.write(`Missing --config. Run with --help.
244
+ `,qt=["select","extract","load","verify","remove","status"],mo={words:1,switches:["--pilot","--reload","--dry-run","--write-encrypted","--mute-automation","--accept-automation","--include-changed","--accept-emails","--sweep","--sweep-list",...Tt,"--preview","--yes","--json",...Te.switches],values:["--config","--source","--target","--author","--salt-file","--store","--max-total","--gone-first",...Te.values]},Vt=1e6;function go(t){let n;try{n=JSON.parse(pe(t,"utf8"))}catch(e){process.stderr.write(`--gone-first: ${t} does not read: ${String(e)}
245
+ `),process.exit(2)}return(!Array.isArray(n)||!n.every(e=>typeof e=="string"&&/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(e)))&&(process.stderr.write(`--gone-first: ${t} holds no JSON array of record ids.
246
+ `),process.exit(2)),n}function wo(t){let n=t.slice(2);(n.includes("--help")||n.includes("-h")||n.length===0)&&(process.stdout.write(ho),process.exit(0));let e=d=>{let y=n.indexOf(d);return y>=0&&y+1<n.length?n[y+1]:void 0},r=n[0];qt.includes(r)||(process.stderr.write(`The first word is the step: ${qt.join(", ")} \u2014 not "${n[0]}".
247
+ `),process.exit(2)),tt(n,mo);let o=e("--config");o||(process.stderr.write(`Missing --config. Run with --help.
239
248
  `),process.exit(2));let s=e("--source"),i=e("--target");(r==="select"||r==="extract")&&!s&&(process.stderr.write(`${r} reads the source org: give --source.
240
249
  `),process.exit(2)),(r==="load"||r==="verify"||r==="remove")&&!i&&(process.stderr.write(`${r} works on the target org: give --target.
241
250
  `),process.exit(2)),n.includes("--sweep")&&n.includes("--sweep-list")&&(process.stderr.write(`--sweep deletes and --sweep-list only lists: give one of them. Run with --help.
@@ -243,21 +252,21 @@ FAILED or PARTIAL; one UNSTABLE is said, and the verify step gives it a code.
243
252
  `),process.exit(2)),n.includes("--sweep")&&r!=="remove"&&!(r==="load"&&n.includes("--reload")&&!n.includes("--pilot"))&&(process.stderr.write(`--sweep goes with remove or load --reload${r==="load"&&n.includes("--pilot")?", and a pilot purges nothing":""}. Run with --help.
244
253
  `),process.exit(2)),n.includes("--include-changed")&&r!=="remove"&&!(r==="load"&&n.includes("--reload")&&n.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.
245
254
  `),process.exit(2)),n.includes("--gone-first")&&!(r==="load"&&n.includes("--reload")&&n.includes("--dry-run"))&&(process.stderr.write(`--gone-first goes with load --reload --dry-run. Run with --help.
246
- `),process.exit(2));let l=e("--gone-first");n.includes("--gone-first")&&l===void 0&&(process.stderr.write(`--gone-first takes the file of the ids taken back first.
255
+ `),process.exit(2));let u=e("--gone-first");n.includes("--gone-first")&&u===void 0&&(process.stderr.write(`--gone-first takes the file of the ids taken back first.
247
256
  `),process.exit(2)),n.includes("--write-encrypted")&&r!=="load"&&(process.stderr.write(`--write-encrypted goes with load. Run with --help.
248
257
  `),process.exit(2)),n.includes("--accept-emails")&&r!=="load"&&(process.stderr.write(`--accept-emails goes with load. Run with --help.
249
258
  `),process.exit(2)),n.includes("--mute-automation")&&r!=="load"&&r!=="remove"&&(process.stderr.write(`--mute-automation goes with load or remove. Run with --help.
250
259
  `),process.exit(2)),n.includes("--accept-automation")&&r!=="remove"&&r!=="load"&&(process.stderr.write(`--accept-automation goes with load or remove. Run with --help.
251
- `),process.exit(2)),n.includes(ke)&&r!=="load"&&(process.stderr.write(`${ke} goes with load. Run with --help.
252
- `),process.exit(2));let w=pt(n);n.includes("--preview")&&r!=="remove"&&(process.stderr.write(`--preview goes with remove${r==="load"?"; a load says what it would do with --dry-run":""}. Run with --help.
260
+ `),process.exit(2)),n.includes(Oe)&&r!=="load"&&(process.stderr.write(`${Oe} goes with load. Run with --help.
261
+ `),process.exit(2));let w=yt(n);n.includes("--preview")&&r!=="remove"&&(process.stderr.write(`--preview goes with remove${r==="load"?"; a load says what it would do with --dry-run":""}. Run with --help.
253
262
  `),process.exit(2)),n.includes("--preview")&&n.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.
254
- `),process.exit(2));let p=Rt(n);"refusal"in p&&(process.stderr.write(`${p.refusal} Run with --help.
263
+ `),process.exit(2));let l=Ct(n);"refusal"in l&&(process.stderr.write(`${l.refusal} Run with --help.
255
264
  `),process.exit(2));let h;if(n.includes("--max-total")){let d=e("--max-total");h=Number(d),r!=="load"&&(process.stderr.write(`--max-total goes with load. Run with --help.
256
- `),process.exit(2)),(d===void 0||!/^\d+$/.test(d)||h<1||h>Ut)&&(process.stderr.write(`--max-total takes a whole number from 1 to ${Ut}, not "${d??""}".
257
- `),process.exit(2))}return{step:r,configPath:t,source:s,target:i,author:e("--author"),storePath:e("--store"),saltFile:e("--salt-file"),pilot:n.includes("--pilot"),reload:n.includes("--reload"),dryRun:n.includes("--dry-run"),writeEncrypted:n.includes("--write-encrypted"),muteAutomation:n.includes("--mute-automation"),acceptAutomation:n.includes("--accept-automation"),...w!==void 0?{checkpointFirst:w}:{},includeChanged:n.includes("--include-changed"),acceptEmails:n.includes("--accept-emails"),sweep:n.includes("--sweep"),sweepList:n.includes("--sweep-list"),...p,preview:n.includes("--preview"),...h!==void 0?{maxTotal:h}:{},...l!==void 0?{goneFirst:l}:{},yes:n.includes("--yes"),json:n.includes("--json")}}async function po(o){let e=(await o.query("SELECT Id, IsSandbox FROM Organization LIMIT 1")).records[0];if(!e)throw new Error("The org gave no Organization record.");if(e.IsSandbox)return{id:e.Id,orgType:"Sandbox"};try{let t=(await o.query("SELECT OrganizationType FROM Organization LIMIT 1")).records[0]?.OrganizationType;return typeof t=="string"&&t!==""?{id:e.Id,orgType:qe({isSandbox:!1,edition:t}),edition:t}:{id:e.Id,orgType:"Production"}}catch{return{id:e.Id,orgType:"Production"}}}async function Bt(o,n,e,r){let t=await Je(o),s=he(t),i;try{i=await po(s)}catch(l){let w=l instanceof Error?l.message:String(l);throw new Error(`Could not read the Organization record of '${o}': ${w}`)}return n.set(i.id,{org:{id:i.id,alias:o,orgType:i.orgType,metadata:{apiVersion:"66.0",...i.edition?{edition:i.edition}:{}}},credentials:{accessToken:t.accessToken,instanceUrl:t.instanceUrl}}),e?.set(i.id,s),r?.set(i.id,{session:t,typed:i}),i.id}function Le(o){return!o||o.length===0?[]:[`kept: the platform does not delete them \u2014 ${o.map(({objectApiName:e,count:r})=>`${e} (${r})`).join(", ")}`]}function Gt(o,n){let e=(o??[]).filter(t=>t.reason==="may-hold-masks");if(e.length===0)return[];let r=e.map(({objectApiName:t,field:s,affectedRecords:i})=>`${t}.${s} (${i})`).join(", ");return[`${n} out, encrypted in the target: ${r} \u2014 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 fo(o,n){let e=o==="token"?"each record its own, from the token the value carries":`each record its own, its rank appended: the field is ${o==="unique"?"unique in the target":"the record name"}`;return n===void 0?e:`${e} (first: "${n}")`}function Ne(o){return o.created.reduce((n,e)=>n+e.count,0)}function ho(o){return{...o.includeChanged?{includeChanged:!0}:{},...o.sweep?{sweep:!0}:{},...o.sweepLate?{sweepLate:!0}:{},...o.sweepUntied?{sweepUntied:!0}:{},...o.muteAutomation?{muteAutomation:!0}:{}}}function Ee({read:o,steps:n,mute:e},r,t="removal",s){let i=e?q(e.muted,r).map(h=>` ${h}`):[];if(!("objects"in o)){let h=t!=="removal",d=t==="reloadSweep"?"this reload's sweep":h?`this reload's purge${s?" and its sweep":""}`:"this removal";return{lines:[`${h?"reload":"removal"} automation: what ${r} runs could not be read: ${o.unread}`,...i],refusal:`What ${r} runs as ${d} writes could not be read (${o.unread}), so what fires as the records go is not known. Nothing was written or deleted. Add --accept-automation to ${h?"reload":"remove"} all the same, or turn that automation off in ${r} first.`}}let l=e?.automation??o,w=s?Ve(n,s.delete??[]):n,p=at(l,r,{steps:n,...s?{sweep:s}:{},assign:nt(l,Ke(l,w)),mayMute:e===void 0&&Ae("--mute-automation"),subject:t});return{lines:[...st(o,r,n,t,s),...i],...p!==void 0?{refusal:p}:{}}}function mo(o,n){let e=Ne(o),r=o.earlier?"a load before the last one, whose records the loads after it left in place,":"the last load",t=`a removal deletes the ${e} record(s) it created, children first:`;return o.removed&&e===0?t=`its records were removed on ${o.removed.removedAt}, and none is left to remove`:e===0&&(o.keptByThePlatform?.length??0)>0?t="it created no record a removal takes":o.removed&&(t=`the removal of ${o.removed.removedAt} left ${e} of the records it created, and a removal deletes those, children first:`),[`${r} wrote to ${n} at ${o.loadedAt}; ${t}`,...o.created.map(s=>` ${s.objectApiName}: ${s.count}`),`${o.linked} record(s) it linked to or reused stay`,...Le(o.keptByThePlatform)]}function go(o,n){return o.recorded&&(Ne(o)>0||(n?.delete??[]).length>0)}function wo(o){return[o.deleted>0?`${o.deleted} deleted`:"",o.alreadyGone>0?`${o.alreadyGone} already gone`:"",o.keptChanged>0?`${o.keptChanged} kept, changed since the load`:"",o.keptDependents>0?`${o.keptDependents} kept for records that stay`+(o.heldBy.length>0?` (${o.heldBy.join(", ")})`:""):"",o.refused>0?`${o.refused} refused`:"",(o.notReached??0)>0?`${o.notReached} not reached`:""].filter(Boolean).join(", ")}function yo(o){let n=o.count>o.names.length?", \u2026":"";return`${o.count} file(s) attached to them stay in the org, as the load did not create them: ${o.names.join(", ")}${n}`}function Wt(o){return`graph: ${o.objects} object(s) at a cap of ${o.maxNodes}`+(o.objects>o.maxNodes?" (raised for the parents their records cannot be written without)":"")+(o.truncated?" \u2014 TRUNCATED: objects further out were not read":"")}function qt(o){return"reusedFrom"in o?`graph reused from ${o.reusedFrom} (discovered ${o.discoveredAt}): the source's schema has not changed since`:`rediscovered: ${o.rediscovered}`}function bo(o){switch(o.phase){case"discovery":return` discovery: ${o.objects??0} object(s) reached`;case"axis":return` listing the values of axis ${o.axis??"?"}\u2026`;case"combination":return` combination ${o.index??"?"}/${o.of??"?"}: ${o.combinationKey??"?"}`;case"candidate":return` candidate ${o.candidate??"?"}/${o.candidates??"?"} of ${o.combinationKey??"?"}: measuring its own records\u2026`;case"measure":return` measuring the ${o.roots??0} root(s) kept, together\u2026`}}function vo(o){let n=o.reason==="timeout"?"its time ran out":"it was cancelled",e=o.during==="axes"?"while it listed the axis values":o.during==="measure"?"while it measured the roots it kept":`while it probed ${o.combinationKey??"?"}`+(o.candidate!==void 0?`, candidate ${o.candidate} of ${o.candidates??"?"}`:"");return[`STOPPED: ${n} ${e}; the combinations decided before are kept`,...o.notProbed.length>0?[` never probed: ${o.notProbed.join(", ")}`]:[]]}var Ao=new Set(["NO_LOAD","ALREADY_REMOVED","NOTHING_TO_REMOVE"]),Qt="REMOVAL_DECLINED",Vt=["MUTE_PRODUCTION","MUTE_NO_RIGHT","MUTE_FAILED"],ko=new Map([["frozen:load:error",new Set(["EMAILS_NOT_ACCEPTED","FROZEN_EMAILS_EXCEEDED",ve,"AUTOMATION_NOT_ACCEPTED",ee.code,...Vt])],["frozen:remove:error",new Set(["AUTOMATION_NOT_ACCEPTED","GUARD_BLOCKED","GUARD_DECLINED",ee.code,...Vt])]]);function je(o){let n=o.payload?.code,e=ko.get(String(o.type??""));if(!(typeof n!="string"||e?.has(n)!==!0))return{code:n,message:String(o.payload?.message??"")}}function Fe(o){let n=String(o.type??"");if(!n.endsWith(":error")||n==="frozen:remove:automation:error")return!1;let e=String(o.payload?.code);return n==="frozen:remove:error"&&e===Qt?!1:!((n==="frozen:remove:error"||n==="frozen:remove:preview:error")&&Ao.has(e))}var Kt={passed:0,partial:3,unstable:4,failed:1};function $o(o,n,e){return async(r,t)=>{let s=Date.parse(t?.first??""),i=Math.max(s,Date.parse(t?.last??""));return!Number.isFinite(s)||!Number.isFinite(i)?[]:[...(await Ot({organizationId:r,alias:o,span:{from:s,to:i},own:{ids:[]},...n!==void 0?{journalDir:n}:{}})).map(({ids:w})=>({ids:w,from:s,to:i})),...Dt(It(n??K(),r),{sasMark:e,own:[]})]}}function Ro(o,n){return Ye(n.map(e=>{let r=e.payload??{};if(o==="verify"&&e.type==="frozen:verify:result"){let t=String(r.verdict?.status??"");return Object.prototype.hasOwnProperty.call(Kt,t)?Kt[t]:1}if(o==="load"&&e.type==="frozen:load:response"){let t=r.report;return t?.status==="completed"&&(t.sweeps??[]).every(s=>s.result.status==="success")?0:3}return o==="remove"&&e.type==="frozen:remove:response"?r.result?.status==="success"?0:3:0}))}function Ht(o,n){return bt(o.verdict==="unread"?{verdict:"unread",estimate:o.estimate,unread:o.unread??"not said"}:{verdict:o.verdict,estimate:o.estimate,remaining:o.remaining??0,max:o.max??0},n)}function Oo(o,n={}){let e=String(o.type??""),r=o.payload??{};if((e==="frozen:remove:error"||e==="frozen:remove:preview:error")&&!Fe(o))return[`nothing to remove: ${String(r.message??"")}`];if(e==="frozen:remove:error"&&!Fe(o))return[String(r.message??"")];if(e==="frozen:remove:automation:error")return[];if(e.endsWith(":error")){let t=e==="frozen:load:error"?r.sweeps??[]:[],s=e==="frozen:load:error"?r.emails:void 0,i=e==="frozen:load:error"?r.automation:void 0,l=e==="frozen:load:error"?r.mutedAutomation:void 0,w=je(o);return[...w?[]:[`! ${e}: ${String(r.message??"")}${r.code?` [${String(r.code)}]`:""}`],...i?ne(i,"the target"):[],...s?re(s,"the target"):[],...l?q(l,"the target"):[],...t.length>0?["before the load ended, its sweep had already done this:"]:[],...t.flatMap(({loadedAt:p,result:h})=>[`sweep of the load of ${p}:`,...X(h)]),...w?[Q(w)]:[]]}switch(e){case"frozen:select:progress":return[bo(r)];case"frozen:select:response":{let t=r.selection;return[`selected ${t.combinations.length} root(s): ${t.combinations.map(s=>s.combinationKey).join(", ")}`,...t.uncovered.map(s=>` uncovered ${s.combinationKey}: ${s.reason}`),...t.stopped?vo(t.stopped):[],...t.discovery?[qt(t.discovery)]:[],...t.graph?[Wt(t.graph)]:[],`volumetry ${t.volumetry.total} / ${t.volumetry.budgetMax} record(s)`+(t.volumetry.summed?" \u2014 each kept root's own records added up: they were not measured together":""),...Object.entries(t.volumetry.measured).filter(([,s])=>s>0).map(([s,i])=>` ${s}: ${i}`)]}case"frozen:control:result":{let t=r.report;return[`non-reidentification control: ${t.passed?"PASSED":"FAILED"}`,...t.checks.map(s=>` ${s.passed?"ok ":"FAIL"} ${s.name}`+(s.violations.length>0?` (${s.violations.length} violation(s))`:""))]}case"frozen:extract:response":{let t=r.manifest,s=r.discovery;return[`frozen ${String(r.recordCount)} record(s) as version ${t.version} in ${String(r.datasetDir)}`,...s?[qt(s)]:[],...t.coverage?[Wt(t.coverage)]:[],...t.coverage&&t.coverage.unboundedObjects.length>0?[`read without the time bound: ${t.coverage.unboundedObjects.join(", ")}`]:[],...(t.coverage?.leftToThePlatform??[]).map(i=>`${i.objectApiName}: ${i.note}`),...(t.coverage?.exclusionCosts??[]).map(i=>`${i.objectApiName}: ${i.note}`),...(t.coverage?.requiredLeftEmpty??[]).length>0?[`required in the source and left empty by the rules \u2014 a load will ask a value for each: ${(t.coverage?.requiredLeftEmpty??[]).join(", ")}`]:[],...(t.coverage?.keptWithoutARule??[]).length>0?["kept without a rule, the platform's own words: "+(t.coverage?.keptWithoutARule??[]).join(", ")]:[],...(t.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: "+(t.coverage?.encryptedNotKept??[]).join(", ")]:[],...Object.entries(t.volumetry.measured).filter(([,i])=>i>0).map(([i,l])=>` ${i}: ${l}`)]}case"frozen:load:response":{let t=r.report,s=[`load: ${t.status} in ${t.durationMs}ms \u2014 ${t.alignment.excludedObjects.length} object(s) excluded, ${t.alignment.removals.length} field removal(s), ${t.alignment.recordTypeIssues.length} record type issue(s), ${t.placeholders.length} placeholder(s)`];for(let u of t.alignment.excludedObjects)s.push(` ${u.objectApiName}: not loaded \u2014 ${u.reason}`);s.push(...Gt(t.alignment.removals,"left"));for(let u of t.perObject){let R=u.writtenByThePlatform??0;s.push(` ${u.objectApiName}: ${u.inserted} inserted, ${u.reused} reused`+(R>0?` (${R} written by the platform with ${ge(u.objectApiName)})`:"")+`, ${u.skippedDuplicates.length} duplicate(s), ${u.failed.length} failed of ${u.fromFiles}`);let E=u.failed[0];E&&s.push(` first refusal: ${E.errors?.[0]??E.error??"?"}`)}for(let u of[...t.leftToThePlatform??[],...t.untypedFeedItems??[],...t.heldForExcludedParents??[],...t.quotesLeftUnsynced??[],...t.keysLeftEmpty??[]])s.push(` ${u.objectApiName}: ${u.note}`);let i=t.perObject.filter(u=>(u.writtenWithoutFields?.fields.length??0)>0);if(i.length>0){s.push(`written again without a field a validation rule or a restricted picklist refused (${i.length} object(s)):`);for(let{objectApiName:u,writtenWithoutFields:R}of i)for(let{field:E,refusedBy:z,reason:J,rows:V,replacedWith:M}of R?.fields??[]){let De=z==="restricted-picklist"?"a restricted picklist refused its value":"a validation rule refused it",le=M===void 0?"":` \u2014 written with "${M}", as its picklist rule declares`;s.push(` ${u}.${E} ${V} record(s) \u2014 ${De}${le} \u2014 ${J}`)}}s.push(`pass 2: ${t.pass2.resolved} resolved, ${t.pass2.unresolved.length} unresolved`);for(let u of t.pass2.unresolved.slice(0,5))s.push(` ${u.objectApiName}.${u.field}: ${u.detail}`);let l=t.personContact,w=l?.sent??[];if(l&&l.restored+w.length+l.unresolved.length>0){s.push(`person contacts: ${l.restored} linked, ${w.length} sent as contacts of their own, ${l.unresolved.length} not linked`);for(let u of w.slice(0,5))s.push(` ${u.contactReferenceId} sent: ${u.detail}`);for(let u of l.unresolved.slice(0,5))s.push(` ${u.contactReferenceId}: ${u.detail}`)}if(t.statuses&&t.statuses.restored+t.statuses.refused.length>0){s.push(`statuses applied after insert: ${t.statuses.restored}, refused ${t.statuses.refused.length}`);for(let u of t.statuses.refused.slice(0,5))s.push(` ${u.objectApiName} \u2192 ${u.status}: ${u.detail}`)}let p=u=>Object.values(u).reduce((R,E)=>R+E,0),h=p(t.purge.deleted),d=p(t.purge.deactivated??{});if(h+d+t.purge.failures.length>0){s.push(`purge of earlier loads: ${h} deleted, ${d} deactivated, ${t.purge.failures.length} failed`);for(let u of t.purge.failures.slice(0,5))s.push(` ${u.objectApiName}: ${u.errors[0]??"?"}`)}for(let[u,R]of Object.entries(t.purge.cameAlong??{}))s.push(` ${u}: took along ${R.count} record(s) the loads did not write that came with their records, made as they wrote: ${R.objects.join(", ")}`);let b=Object.entries(t.purge.leftUnrecorded??{});if(b.length>0){s.push("left in place, of a load recorded before loads kept what they created \u2014 it may have linked them:");for(let[u,R]of b)s.push(` ${u}: ${R}`)}let k=Object.entries(t.purge.keptByThePlatform??{});if(k.length>0){s.push("kept by the purge, the platform does not delete them:");for(let[u,R]of k)s.push(` ${u}: ${R}`)}for(let u of r.report.sweeps??[]){s.push(`sweep of the load of ${u.loadedAt}:`,...X(u.result));let R=u.result.objects.reduce((E,z)=>E+z.keptChanged,0);R>0&&s.push(` ${R} record(s) kept, changed since that load: load --reload --sweep --include-changed, or remove --sweep --include-changed, takes them`)}let N=r.report.mutedAutomation;N&&s.push(...q(N,"the target"));let a=r.report.automation;a&&s.push(...ne(a,"the target"));let y=r.report.emails;y&&s.push(...re(y,"the target"));let O=r.report.apiRequests;return O&&s.push(Ht(O,"the target")),s.push(...Yt(r.report.recordTypesGiven,!1)),s}case"frozen:load:preview:response":{let t=r.plan,s=a=>t.perObject.reduce((y,O)=>y+a(O),0),i=[`dry run${t.mode.pilot?" (pilot)":""}${t.mode.reload?" (reload)":""}: ${s(a=>a.toInsert)} record(s) to insert, ${s(a=>a.reusedByKeys+a.reusedFromCatalog+(a.writtenByThePlatform??0))} to link, ${s(a=>a.notSent)} not sent`+(t.mode.reload?`, ${s(a=>a.toPurge)} to purge and ${s(a=>a.toDeactivate)} to deactivate of ${t.earlierLoads} earlier load(s)`:"")+" \u2014 nothing written"];for(let a of t.perObject){let y=[`${a.toInsert} to insert`,a.reusedByKeys>0?`${a.reusedByKeys} found by identity keys`:"",a.reusedFromCatalog>0?`${a.reusedFromCatalog} found in the catalog`:"",(a.writtenByThePlatform??0)>0?`${a.writtenByThePlatform} to link (written by the platform with ${ge(a.objectApiName)})`:"",a.fieldsDropped>0?`${a.fieldsDropped} field(s) dropped`:"",a.picklistsRewritten>0?`${a.picklistsRewritten} picklist value(s) rewritten`:"",a.notSent>0?`${a.notSent} not sent`:"",a.toPurge>0?`${a.toPurge} to purge`:"",a.toDeactivate>0?`${a.toDeactivate} to deactivate`:""].filter(Boolean);i.push(` ${a.objectApiName}: ${y.join(", ")} of ${a.fromFiles}`)}for(let a of t.excludedObjects)i.push(` ${a.objectApiName}: not loaded \u2014 ${a.reason}`);i.push(...Gt(t.removals,"would leave"));for(let a of[...t.heldForExcludedParents??[],...t.quotesLeftUnsynced??[],...t.keysLeftEmpty??[]])i.push(` ${a.objectApiName}: ${a.note}`);for(let a of t.placeholders)i.push(`placeholder for ${a.objectApiName}.${a.field}: ${a.affectedRecords} record(s)`);for(let a of t.requiredDefaults)i.push(`default for ${a.objectApiName}.${a.field}: ${a.affectedRecords} record(s)`+(a.perRecord?`, ${fo(a.perRecord,a.example)}`:""));t.personContacts>0&&i.push(`${t.personContacts} person account contact(s) go in with their account, not counted above`);let l=Object.entries(t.leftUnrecorded??{});if(l.length>0){i.push("left in place, of a load recorded before loads kept what they created \u2014 it may have linked them:");for(let[a,y]of l)i.push(` ${a}: ${y}`)}let w=Object.entries(t.keptByThePlatform??{});if(w.length>0){i.push("left in place by the purge, the platform does not delete them:");for(let[a,y]of w)i.push(` ${a}: ${y}`)}let p=a=>` ${a.name}${a.field?` (${a.field})`:""}${a.message?` \u2014 ${a.message}`:""}`,h=t.perObject.filter(a=>(a.validationRules?.length??0)>0);for(let a of h){i.push(`${a.objectApiName}: ${a.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 y of a.validationRules??[])i.push(p(y))}for(let a of t.perObject){let y=a.lookupFilters??[];y.length!==0&&i.push(`${a.objectApiName}: ${y.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: `+y.map(O=>`${O.field} (${O.referenceTo.join(" or ")}, ${O.records} record(s))`).join(", "))}for(let a of t.perObject){let y=a.validationRulesOnChange??[];y.length!==0&&i.push(`${a.objectApiName}: ${y.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: `+y.join(", "))}let d=new Map(t.placeholders.filter(a=>(a.validationRules?.length??0)>0).map(a=>[a.placeholderObjectApiName,a.validationRules??[]]));for(let[a,y]of d){i.push(`placeholder of ${a}: ${y.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 O of y)i.push(p(O))}t.validationRulesUnread&&i.push(`the target's validation rules could not be listed (${t.validationRulesUnread}): any of them may refuse a record counted to insert`);let b=r.plan.automation;b&&i.push(...ne(b,"the target"));let k=r.plan.emails;k&&i.push(...re(k,"the target"));let N=r.plan.apiRequests;return N&&i.push(Ht(N,"the target")),i}case"frozen:verify:result":{let t=r.verdict;return[`verification: ${t.status.toUpperCase()}`,...t.checks.map(s=>` ${s.passed?"ok ":"FAIL"} ${s.name}: ${s.detail}`)]}case"frozen:remove:response":{let t=r.result,s=[...new Set(t.objects.flatMap(l=>l.unchecked))],i=t.sweep!==void 0&&t.objects.length===0;return[...t.sweep?X(t.sweep):[],...(t.otherLoadSweeps??[]).flatMap(({loadedAt:l,result:w})=>[`sweep of the load of ${l}:`,...X(w)]),...i?[]:[`removal: ${t.status.toUpperCase()}`+(t.leftBy?` \u2014 of what the removal of ${t.leftBy} left`:"")],...t.objects.flatMap(l=>[` ${l.objectApiName}: ${wo(l)||"nothing"} of ${l.planned}${Oe(l)}`,...vt(l,"load"),...l.reasons.map(w=>` ${w}`),...l.filesLeft&&l.filesLeft.count>0?[` ${yo(l.filesLeft)}`]:[]]),...s.length>0?[`not checked, deleted with their parent: ${s.join(", ")}`]:[],...Le(t.keptByThePlatform),...kt(t.objects,{sweep:t.sweep!==void 0}),...t.mutedAutomation?q(t.mutedAutomation,"the target"):[]]}case"frozen:remove:sweep:response":{let t=r.loads;if(t)return t.flatMap(({loadedAt:i,listing:l})=>[`sweep of the load of ${i}:`,...oe(l,"the target org",n,!0)]);let s=r.otherLoads??[];return s.length>0?[{loadedAt:String(r.loadedAt),listing:r.listing},...s].flatMap(({loadedAt:i,listing:l})=>[`sweep of the load of ${i}:`,...oe(l,"the target org",n,!0)]):oe(r.listing,"the target org",n,!0)}case"frozen:remove:preview:response":return Eo(r.preview);case"frozen:status:response":return[JSON.stringify(r.status,null,2)];default:return[]}}var So="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 Eo(o){let n=t=>o.userNames[t]??t,e=["preview: what a removal would do; nothing was deleted"+(o.leftBy?` \u2014 of what the removal of ${o.leftBy} left`:"")];for(let t of o.objects){let s=[t.toDelete>0?`${t.toDelete} to delete`:"",o.includeChanged&&t.changedSince>0?`${t.changedSince} of them changed since the load`:"",t.alreadyGone>0?`${t.alreadyGone} gone already`:"",t.notVisible>0?`${t.notVisible} not visible`:"",t.keptChanged>0?`${t.keptChanged} kept, changed since the load`:"",t.undeletable>0?`${t.undeletable} left, the user may not delete them`:"",t.unread>0?`${t.unread} left, not read`:""].filter(Boolean);e.push(` ${t.objectApiName}: ${s.join(", ")||"nothing"} of ${t.planned}${Oe(t)}`);let i=Object.entries(t.changedBy).sort((l,w)=>w[1]-l[1]);i.length>0&&e.push(` last changed by: ${i.map(([l,w])=>`${n(l)} ${w}`).join(" \xB7 ")}`);for(let l of t.reasons)e.push(` ${l}`)}e.push(...Le(o.keptByThePlatform));let r=o.refusalCodes;return o.refusals.forEach((t,s)=>{e.push(r?.length===o.refusals.length?Y({code:r[s],message:t},"a removal"):`a removal would be refused: ${t}`)}),e.push(So),e}async function To(o){let n=_(o,"manifest.json");if(Ce(n))try{let e=await Tt(o),{version:r}=JSON.parse(de(n,"utf8"));return{dir:o,digest:e,...typeof r=="string"?{version:r}:{}}}catch{return}}function Co(o,n){let e=_(o,Ct(n)),r=_(o,"referenceid-mapping.json");return!Ce(e)&&Ce(r)?r:e}function Xt(o){return{status:o.status.toUpperCase(),objects:(o.objects??[]).map(({status:n,...e})=>({...e,verdict:n==="passed"?"PASSED":"FAILED"}))}}async function jo(o,n,e){let r=p=>n.filter(h=>h.type===p).at(-1)?.payload,t=e.targetOrgId?Co(e.sasDir,e.targetOrgId):void 0,s={tool:"sandforge-frozen",step:o,posted:n},i=[],l=[],w=async p=>{let h=await To(p);h&&(s.dataset=h)};switch(o){case"extract":{let p=r("frozen:extract:response");if(!p)break;await w(typeof p.datasetDir=="string"?p.datasetDir:e.datasetDir);let h=p.manifest?.volumetry?.measured??{};s.objects=Object.entries(h).filter(([,d])=>d>0).map(([d,b])=>({objectApiName:d,records:b}));break}case"load":{await w(e.datasetDir);let p=r("frozen:load:response")?.report,h=r("frozen:load:preview:response")?.plan,d=p?p.recordTypesGiven:h?.recordTypesGiven;d&&(s.recordTypesGiven=d),p?(s.mapping=p.mappingPath,s.objects=p.perObject.map(k=>({objectApiName:k.objectApiName,fromFiles:k.fromFiles,inserted:k.inserted,reused:k.reused,duplicates:k.skippedDuplicates.length,failed:k.failed.length}))):h&&(t&&(s.mapping=t),s.objects=h.perObject.map(k=>({objectApiName:k.objectApiName,fromFiles:k.fromFiles,toInsert:k.toInsert,toLink:k.reusedByKeys+k.reusedFromCatalog+(k.writtenByThePlatform??0),notSent:k.notSent,toPurge:k.toPurge,toDeactivate:k.toDeactivate}))),p&&(s.status=p.status),!p&&r("frozen:load:error")?.code==="LOAD_CANCELLED"&&(s.status="cancelled",t&&(s.mapping=t));let b=r("frozen:verify:result")?.verdict;b&&(s.verdict=Xt(b));break}case"verify":{let p=r("frozen:verify:result")?.verdict;await w(p?.manifestPath?so(p.manifestPath):e.datasetDir),t&&(s.mapping=t),p&&(s.verdict=Xt(p));break}case"remove":{t&&(s.mapping=t);let p=r("frozen:remove:response")?.result,h=r("frozen:remove:preview:response")?.preview;p?(s.status=p.status,p.mutedAutomation&&(s.mutedAutomation=p.mutedAutomation),s.objects=p.objects.map(d=>({objectApiName:d.objectApiName,planned:d.planned,deleted:d.deleted,alreadyGone:d.alreadyGone,keptChanged:d.keptChanged,keptDependents:d.keptDependents,refused:d.refused,notReached:d.notReached??0,notVisible:d.notVisible??0,...d.tookAlong?{tookAlong:d.tookAlong}:{},...d.cameAlong?{cameAlong:d.cameAlong}:{}})),s.includeChanged=p.includeChanged):h&&(s.preview=!0,s.includeChanged=h.includeChanged,s.objects=h.objects.map(d=>({objectApiName:d.objectApiName,planned:d.planned,toDelete:d.toDelete,alreadyGone:d.alreadyGone,changedSince:d.changedSince,keptChanged:d.keptChanged,undeletable:d.undeletable,notVisible:d.notVisible,unread:d.unread})),i.push(...h.refusals),h.refusalCodes?.length===h.refusals.length&&l.push(...h.refusalCodes));break}}return i.push(...e.refusals??[]),e.refusalCodes?.length===(e.refusals??[]).length&&l.push(...e.refusalCodes??[]),i.length>0&&(s.refusals=i),i.length>0&&l.length===i.length&&(s.refusalCodes=l),e.mute&&Object.assign(s,e.mute),e.checkpoint&&(s.checkpoint=e.checkpoint),s}async function Fo(o=process.argv){let n=Date.now(),e=co(o),r=f=>{process[e.json?"stderr":"stdout"].write(`${f}
258
- `)},t=JSON.parse(de(e.configPath,"utf8")),s=typeof t.sasDir=="string"?t.sasDir:_(ao(),".sandforge-sas");ro(s,{recursive:!0});let i=it(e.storePath??_(s,"cli-store.json")),l=new Map,w=new Map,p=new Map,h=e.source?await Bt(e.source,l):void 0,d=e.target?await Bt(e.target,l,w,p):void 0,b=[],k=!1,N=!1,a=new xt({log:()=>{},broker:{postToWebview:f=>{if(f.type!=="frozen:load:progress"&&(b.push(f),Fe(f)&&(k=!0),!N))for(let m of Oo(f,e))r(m)}},orgManager:{getOrg:f=>l.get(f)?.org},orgRegistry:{getCredentials:async f=>l.get(f)?.credentials},configStore:i,infraServices:{productionGuard:Et(r,e.target??e.source??"the org"),piiDetector:new et},nextId:()=>`cli-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}),y=d?w.get(d):void 0,O=d?p.get(d):void 0,u=e.checkpointFirst&&O?ft({module:"frozen",operationId:`sandforge-frozen-load-${n}`,request:e.checkpointFirst,session:O.session,org:{id:O.typed.id,orgType:O.typed.orgType,...O.typed.edition!==void 0?{edition:O.typed.edition}:{}},connect:he,journalDir:K(),say:r}):void 0;y&&a.setTargetAutomation(H(y)),a.setMuteOffered(Ae("--mute-automation")),a.setSaltKeeper(Nt(process.env,e.saltFile)),e.target&&a.setOtherModuleRuns($o(e.target,void 0,Se(s)));let R=new _t;a.setRegistry(R);let E,z,J=!1,V=!1,M,le=Ze(f=>{if(M=f,process.stderr.write(`
265
+ `),process.exit(2)),(d===void 0||!/^\d+$/.test(d)||h<1||h>Vt)&&(process.stderr.write(`--max-total takes a whole number from 1 to ${Vt}, not "${d??""}".
266
+ `),process.exit(2))}return{step:r,configPath:o,source:s,target:i,author:e("--author"),storePath:e("--store"),saltFile:e("--salt-file"),pilot:n.includes("--pilot"),reload:n.includes("--reload"),dryRun:n.includes("--dry-run"),writeEncrypted:n.includes("--write-encrypted"),muteAutomation:n.includes("--mute-automation"),acceptAutomation:n.includes("--accept-automation"),...w!==void 0?{checkpointFirst:w}:{},includeChanged:n.includes("--include-changed"),acceptEmails:n.includes("--accept-emails"),sweep:n.includes("--sweep"),sweepList:n.includes("--sweep-list"),...l,preview:n.includes("--preview"),...h!==void 0?{maxTotal:h}:{},...u!==void 0?{goneFirst:u}:{},yes:n.includes("--yes"),json:n.includes("--json")}}async function yo(t){let e=(await t.query("SELECT Id, IsSandbox FROM Organization LIMIT 1")).records[0];if(!e)throw new Error("The org gave no Organization record.");if(e.IsSandbox)return{id:e.Id,orgType:"Sandbox"};try{let o=(await t.query("SELECT OrganizationType FROM Organization LIMIT 1")).records[0]?.OrganizationType;return typeof o=="string"&&o!==""?{id:e.Id,orgType:Je({isSandbox:!1,edition:o}),edition:o}:{id:e.Id,orgType:"Production"}}catch{return{id:e.Id,orgType:"Production"}}}async function Kt(t,n,e,r){let o=await ot(t),s=ve(o),i;try{i=await yo(s)}catch(u){let w=u instanceof Error?u.message:String(u);throw new Error(`Could not read the Organization record of '${t}': ${w}`)}return n.set(i.id,{org:{id:i.id,alias:t,orgType:i.orgType,metadata:{apiVersion:"66.0",...i.edition?{edition:i.edition}:{}}},credentials:{accessToken:o.accessToken,instanceUrl:o.instanceUrl}}),e?.set(i.id,s),r?.set(i.id,{session:o,typed:i}),i.id}function xe(t){return!t||t.length===0?[]:[`kept: the platform does not delete them \u2014 ${t.map(({objectApiName:e,count:r})=>`${e} (${r})`).join(", ")}`]}function Ht(t,n){let e=(t??[]).filter(o=>o.reason==="may-hold-masks");if(e.length===0)return[];let r=e.map(({objectApiName:o,field:s,affectedRecords:i})=>`${o}.${s} (${i})`).join(", ");return[`${n} out, encrypted in the target: ${r} \u2014 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 vo(t,n){let e=t==="token"?"each record its own, from the token the value carries":`each record its own, its rank appended: the field is ${t==="unique"?"unique in the target":"the record name"}`;return n===void 0?e:`${e} (first: "${n}")`}function _e(t){return t.created.reduce((n,e)=>n+e.count,0)}function bo(t){return{...t.includeChanged?{includeChanged:!0}:{},...t.sweep?{sweep:!0}:{},...t.sweepLate?{sweepLate:!0}:{},...t.sweepUntied?{sweepUntied:!0}:{},...t.muteAutomation?{muteAutomation:!0}:{}}}function Ne({read:t,steps:n,mute:e},r,o="removal",s){let i=e?q(e.muted,r).map(h=>` ${h}`):[];if(!("objects"in t)){let h=o!=="removal",d=o==="reloadSweep"?"this reload's sweep":h?`this reload's purge${s?" and its sweep":""}`:"this removal";return{lines:[`${h?"reload":"removal"} automation: what ${r} runs could not be read: ${t.unread}`,...i],refusal:`What ${r} runs as ${d} writes could not be read (${t.unread}), so what fires as the records go is not known. Nothing was written or deleted. Add --accept-automation to ${h?"reload":"remove"} all the same, or turn that automation off in ${r} first.`}}let u=e?.automation??t,w=s?Qe(n,s.delete??[]):n,l=pt(u,r,{steps:n,...s?{sweep:s}:{},assign:ut(u,Ye(u,w)),mayMute:e===void 0&&Ee("--mute-automation"),subject:o});return{lines:[...ct(t,r,n,o,s),...i],...l!==void 0?{refusal:l}:{}}}function Ao(t,n){let e=_e(t),r=t.earlier?"a load before the last one, whose records the loads after it left in place,":"the last load",o=`a removal deletes the ${e} record(s) it created, children first:`;return t.removed&&e===0?o=`its records were removed on ${t.removed.removedAt}, and none is left to remove`:e===0&&(t.keptByThePlatform?.length??0)>0?o="it created no record a removal takes":t.removed&&(o=`the removal of ${t.removed.removedAt} left ${e} of the records it created, and a removal deletes those, children first:`),[`${r} wrote to ${n} at ${t.loadedAt}; ${o}`,...t.created.map(s=>` ${s.objectApiName}: ${s.count}`),`${t.linked} record(s) it linked to or reused stay`,...xe(t.keptByThePlatform)]}function ko(t,n){return t.recorded&&(_e(t)>0||(n?.delete??[]).length>0)}function $o(t){return[t.deleted>0?`${t.deleted} deleted`:"",t.alreadyGone>0?`${t.alreadyGone} already gone`:"",t.keptChanged>0?`${t.keptChanged} kept, changed since the load`:"",t.keptDependents>0?`${t.keptDependents} kept for records that stay`+(t.heldBy.length>0?` (${t.heldBy.join(", ")})`:""):"",t.refused>0?`${t.refused} refused`:"",(t.notReached??0)>0?`${t.notReached} not reached`:""].filter(Boolean).join(", ")}function Ro(t){let n=t.count>t.names.length?", \u2026":"";return`${t.count} file(s) attached to them stay in the org, as the load did not create them: ${t.names.join(", ")}${n}`}function Xt(t){return`graph: ${t.objects} object(s) at a cap of ${t.maxNodes}`+(t.objects>t.maxNodes?" (raised for the parents their records cannot be written without)":"")+(t.truncated?" \u2014 TRUNCATED: objects further out were not read":"")}function Zt(t){return"reusedFrom"in t?`graph reused from ${t.reusedFrom} (discovered ${t.discoveredAt}): the source's schema has not changed since`:`rediscovered: ${t.rediscovered}`}function So(t){switch(t.phase){case"discovery":return` discovery: ${t.objects??0} object(s) reached`;case"axis":return` listing the values of axis ${t.axis??"?"}\u2026`;case"combination":return` combination ${t.index??"?"}/${t.of??"?"}: ${t.combinationKey??"?"}`;case"candidate":return` candidate ${t.candidate??"?"}/${t.candidates??"?"} of ${t.combinationKey??"?"}: measuring its own records\u2026`;case"measure":return` measuring the ${t.roots??0} root(s) kept, together\u2026`}}function Eo(t){let n=t.reason==="timeout"?"its time ran out":"it was cancelled",e=t.during==="axes"?"while it listed the axis values":t.during==="measure"?"while it measured the roots it kept":`while it probed ${t.combinationKey??"?"}`+(t.candidate!==void 0?`, candidate ${t.candidate} of ${t.candidates??"?"}`:"");return[`STOPPED: ${n} ${e}; the combinations decided before are kept`,...t.notProbed.length>0?[` never probed: ${t.notProbed.join(", ")}`]:[]]}var Oo=new Set(["NO_LOAD","ALREADY_REMOVED","NOTHING_TO_REMOVE"]),ro="REMOVAL_DECLINED",Jt=["MUTE_PRODUCTION","MUTE_NO_RIGHT","MUTE_FAILED"],To=new Map([["frozen:load:error",new Set(["EMAILS_NOT_ACCEPTED","FROZEN_EMAILS_EXCEEDED",Se,"FROZEN_STORAGE_EXCEEDED","AUTOMATION_NOT_ACCEPTED",re.code,...Jt])],["frozen:remove:error",new Set(["AUTOMATION_NOT_ACCEPTED","GUARD_BLOCKED","GUARD_DECLINED",re.code,...Jt])]]);function Pe(t){let n=t.payload?.code,e=To.get(String(t.type??""));if(!(typeof n!="string"||e?.has(n)!==!0))return{code:n,message:String(t.payload?.message??"")}}function Ie(t){let n=String(t.type??"");if(!n.endsWith(":error")||n==="frozen:remove:automation:error")return!1;let e=String(t.payload?.code);return n==="frozen:remove:error"&&e===ro?!1:!((n==="frozen:remove:error"||n==="frozen:remove:preview:error")&&Oo.has(e))}var Qt={passed:0,partial:3,unstable:4,failed:1};function Co(t,n,e){return async(r,o)=>{let s=Date.parse(o?.first??""),i=Math.max(s,Date.parse(o?.last??""));return!Number.isFinite(s)||!Number.isFinite(i)?[]:[...(await Ft({organizationId:r,alias:t,span:{from:s,to:i},own:{ids:[]},...n!==void 0?{journalDir:n}:{}})).map(({ids:w})=>({ids:w,from:s,to:i})),...Mt(Ut(n??H(),r),{sasMark:e,own:[]})]}}function Fo(t,n){return st(n.map(e=>{let r=e.payload??{};if(t==="verify"&&e.type==="frozen:verify:result"){let o=String(r.verdict?.status??"");return Object.prototype.hasOwnProperty.call(Qt,o)?Qt[o]:1}if(t==="load"&&e.type==="frozen:load:response"){let o=r.report;return o?.status==="completed"&&(o.sweeps??[]).every(s=>s.result.status==="success")?0:3}return t==="remove"&&e.type==="frozen:remove:response"?r.result?.status==="success"?0:3:0}))}function Yt(t,n){return St(t.verdict==="unread"?{verdict:"unread",estimate:t.estimate,unread:t.unread??"not said"}:{verdict:t.verdict,estimate:t.estimate,remaining:t.remaining??0,max:t.max??0},n)}function jo(t){return(t.filter(e=>e.type==="frozen:remove:response").at(-1)?.payload?.result?.objects??[]).some(e=>e.deleted+e.alreadyGone>0)}function de(t){return ft()!==void 0?je(t):t==="--sweep"||t==="--sweep-list"?`remove ${t}`:`remove --sweep ${t}`}function Lo(t){if(!t||t.found.length===0)return[];let n=t.found.reduce((l,h)=>l+h.count,0),e=t.found.some(l=>l.overBound)?" or more":"",r=l=>t.found.reduce((h,d)=>h+(d.classes?l(d.classes):0),0),o=r(l=>l.made+l.madeOver),s=r(l=>l.late),i=r(l=>l.untied),u=t.found.filter(l=>l.overBound).map(l=>l.objectApiName),w=[...o>0?[`${de("--sweep")} takes the ${o} tied to the load`]:[],...s>0?[`${de("--sweep-late")} takes the ${s} made late`]:[],...i>0?[t.untied?.refusal!==void 0?`the ${i} tied to nothing of the load now stay: --sweep-untied is refused (${t.untied.refusal})`:`${de("--sweep-untied")} takes the ${i} tied to nothing of the load now`]:[],...u.length>0?[`no sweep takes those of ${u.join(", ")}, past its bound`]:[]];return[`not swept: ${n}${e} record(s) the load's user created in its window stay, what the target's automation made for the load likely: `+t.found.map(l=>`${l.objectApiName}: ${l.count}`).join(", "),...w.map(l=>` ${l}`),` ${de("--sweep-list")} names them first: a record made by hand as that user in the load's window reads as the automation's, so check the names before a sweep`]}function No(t,n){return` data storage: about ${K(t.estimateMB)} MB, of the ${K(t.remainingMB)} MB ${n} has left of ${K(t.maxMB)} MB`+(t.freedMB!==void 0?`, with about ${K(t.freedMB)} MB the reload's purge frees first`:"")+(t.refusal!==void 0?": more than it has left":"")}function zo(t,n={}){let e=String(t.type??""),r=t.payload??{};if((e==="frozen:remove:error"||e==="frozen:remove:preview:error")&&!Ie(t))return[`nothing to remove: ${String(r.message??"")}`];if(e==="frozen:remove:error"&&!Ie(t))return[String(r.message??"")];if(e==="frozen:remove:automation:error")return[];if(e.endsWith(":error")){let o=e==="frozen:load:error"?r.sweeps??[]:[],s=e==="frozen:load:error"?r.emails:void 0,i=e==="frozen:load:error"?r.automation:void 0,u=e==="frozen:load:error"?r.mutedAutomation:void 0,w=Pe(t);return[...w?[]:[`! ${e}: ${String(r.message??"")}${r.code?` [${String(r.code)}]`:""}`],...i?ie(i,"the target"):[],...s?ae(s,"the target"):[],...u?q(u,"the target"):[],...o.length>0?["before the load ended, its sweep had already done this:"]:[],...o.flatMap(({loadedAt:l,result:h})=>[`sweep of the load of ${l}:`,...Z(h)]),...w?[te(w)]:[]]}switch(e){case"frozen:select:progress":return[So(r)];case"frozen:select:response":{let o=r.selection;return[`selected ${o.combinations.length} root(s): ${o.combinations.map(s=>s.combinationKey).join(", ")}`,...o.uncovered.map(s=>` uncovered ${s.combinationKey}: ${s.reason}`),...o.stopped?Eo(o.stopped):[],...o.discovery?[Zt(o.discovery)]:[],...o.graph?[Xt(o.graph)]:[],`volumetry ${o.volumetry.total} / ${o.volumetry.budgetMax} record(s)`+(o.volumetry.summed?" \u2014 each kept root's own records added up: they were not measured together":""),...Object.entries(o.volumetry.measured).filter(([,s])=>s>0).map(([s,i])=>` ${s}: ${i}`)]}case"frozen:control:result":{let o=r.report;return[`non-reidentification control: ${o.passed?"PASSED":"FAILED"}`,...o.checks.map(s=>` ${s.passed?"ok ":"FAIL"} ${s.name}`+(s.violations.length>0?` (${s.violations.length} violation(s))`:""))]}case"frozen:extract:response":{let o=r.manifest,s=r.discovery;return[`frozen ${String(r.recordCount)} record(s) as version ${o.version} in ${String(r.datasetDir)}`,...s?[Zt(s)]:[],...o.coverage?[Xt(o.coverage)]:[],...o.coverage&&o.coverage.unboundedObjects.length>0?[`read without the time bound: ${o.coverage.unboundedObjects.join(", ")}`]:[],...(o.coverage?.leftToThePlatform??[]).map(i=>`${i.objectApiName}: ${i.note}`),...(o.coverage?.exclusionCosts??[]).map(i=>`${i.objectApiName}: ${i.note}`),...(o.coverage?.requiredLeftEmpty??[]).length>0?[`required in the source and left empty by the rules \u2014 a load will ask a value for each: ${(o.coverage?.requiredLeftEmpty??[]).join(", ")}`]:[],...(o.coverage?.keptWithoutARule??[]).length>0?["kept without a rule, the platform's own words: "+(o.coverage?.keptWithoutARule??[]).join(", ")]:[],...(o.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: "+(o.coverage?.encryptedNotKept??[]).join(", ")]:[],...Object.entries(o.volumetry.measured).filter(([,i])=>i>0).map(([i,u])=>` ${i}: ${u}`)]}case"frozen:load:response":{let o=r.report,s=[`load: ${o.status} in ${o.durationMs}ms \u2014 ${o.alignment.excludedObjects.length} object(s) excluded, ${o.alignment.removals.length} field removal(s), ${o.alignment.recordTypeIssues.length} record type issue(s), ${o.placeholders.length} placeholder(s)`];for(let c of o.alignment.excludedObjects)s.push(` ${c.objectApiName}: not loaded \u2014 ${c.reason}`);s.push(...Ht(o.alignment.removals,"left"));for(let c of o.perObject){let R=c.writtenByThePlatform??0;s.push(` ${c.objectApiName}: ${c.inserted} inserted, ${c.reused} reused`+(R>0?` (${R} written by the platform with ${Ae(c.objectApiName)})`:"")+`, ${c.skippedDuplicates.length} duplicate(s), ${c.failed.length} failed of ${c.fromFiles}`);let O=c.failed[0];O&&s.push(` first refusal: ${O.errors?.[0]??O.error??"?"}`)}for(let c of[...o.leftToThePlatform??[],...o.untypedFeedItems??[],...o.heldForExcludedParents??[],...o.quotesLeftUnsynced??[],...o.keysLeftEmpty??[]])s.push(` ${c.objectApiName}: ${c.note}`);let i=o.perObject.filter(c=>(c.writtenWithoutFields?.fields.length??0)>0);if(i.length>0){s.push(`written again without a field a validation rule or a restricted picklist refused (${i.length} object(s)):`);for(let{objectApiName:c,writtenWithoutFields:R}of i)for(let{field:O,refusedBy:N,reason:J,rows:V,replacedWith:U}of R?.fields??[]){let Be=N==="restricted-picklist"?"a restricted picklist refused its value":"a validation rule refused it",fe=U===void 0?"":` \u2014 written with "${U}", as its picklist rule declares`;s.push(` ${c}.${O} ${V} record(s) \u2014 ${Be}${fe} \u2014 ${J}`)}}s.push(`pass 2: ${o.pass2.resolved} resolved, ${o.pass2.unresolved.length} unresolved`);for(let c of o.pass2.unresolved.slice(0,5))s.push(` ${c.objectApiName}.${c.field}: ${c.detail}`);let u=o.personContact,w=u?.sent??[];if(u&&u.restored+w.length+u.unresolved.length>0){s.push(`person contacts: ${u.restored} linked, ${w.length} sent as contacts of their own, ${u.unresolved.length} not linked`);for(let c of w.slice(0,5))s.push(` ${c.contactReferenceId} sent: ${c.detail}`);for(let c of u.unresolved.slice(0,5))s.push(` ${c.contactReferenceId}: ${c.detail}`)}if(o.statuses&&o.statuses.restored+o.statuses.refused.length>0){s.push(`statuses applied after insert: ${o.statuses.restored}, refused ${o.statuses.refused.length}`);for(let c of o.statuses.refused.slice(0,5))s.push(` ${c.objectApiName} \u2192 ${c.status}: ${c.detail}`)}let l=c=>Object.values(c).reduce((R,O)=>R+O,0),h=l(o.purge.deleted),d=l(o.purge.deactivated??{});if(h+d+o.purge.failures.length>0){s.push(`purge of earlier loads: ${h} deleted, ${d} deactivated, ${o.purge.failures.length} failed`);for(let c of o.purge.failures.slice(0,5))s.push(` ${c.objectApiName}: ${c.errors[0]??"?"}`)}for(let[c,R]of Object.entries(o.purge.cameAlong??{}))s.push(` ${c}: took along ${R.count} record(s) the loads did not write that came with their records, made as they wrote: ${R.objects.join(", ")}`);let y=Object.entries(o.purge.leftUnrecorded??{});if(y.length>0){s.push("left in place, of a load recorded before loads kept what they created \u2014 it may have linked them:");for(let[c,R]of y)s.push(` ${c}: ${R}`)}let b=Object.entries(o.purge.keptByThePlatform??{});if(b.length>0){s.push("kept by the purge, the platform does not delete them:");for(let[c,R]of b)s.push(` ${c}: ${R}`)}for(let c of r.report.sweeps??[]){s.push(`sweep of the load of ${c.loadedAt}:`,...Z(c.result));let R=c.result.objects.reduce((O,N)=>O+N.keptChanged,0);R>0&&s.push(` ${R} record(s) kept, changed since that load: load --reload --sweep --include-changed, or remove --sweep --include-changed, takes them`)}let F=r.report.mutedAutomation;F&&s.push(...q(F,"the target"));let T=r.report.automation;T&&s.push(...ie(T,"the target"));let a=r.report.emails;a&&s.push(...ae(a,"the target"));let A=r.report.apiRequests;return A&&s.push(Yt(A,"the target")),s.push(...no(r.report.recordTypesGiven,!1)),s}case"frozen:load:preview:response":{let o=r.plan,s=a=>o.perObject.reduce((A,c)=>A+a(c),0),i=[`dry run${o.mode.pilot?" (pilot)":""}${o.mode.reload?" (reload)":""}: ${s(a=>a.toInsert)} record(s) to insert, ${s(a=>a.reusedByKeys+a.reusedFromCatalog+(a.writtenByThePlatform??0))} to link, ${s(a=>a.notSent)} not sent`+(o.mode.reload?`, ${s(a=>a.toPurge)} to purge and ${s(a=>a.toDeactivate)} to deactivate of ${o.earlierLoads} earlier load(s)`:"")+" \u2014 nothing written"];for(let a of o.perObject){let A=[`${a.toInsert} to insert`,a.reusedByKeys>0?`${a.reusedByKeys} found by identity keys`:"",a.reusedFromCatalog>0?`${a.reusedFromCatalog} found in the catalog`:"",(a.writtenByThePlatform??0)>0?`${a.writtenByThePlatform} to link (written by the platform with ${Ae(a.objectApiName)})`:"",a.fieldsDropped>0?`${a.fieldsDropped} field(s) dropped`:"",a.picklistsRewritten>0?`${a.picklistsRewritten} picklist value(s) rewritten`:"",a.notSent>0?`${a.notSent} not sent`:"",a.toPurge>0?`${a.toPurge} to purge`:"",a.toDeactivate>0?`${a.toDeactivate} to deactivate`:""].filter(Boolean);i.push(` ${a.objectApiName}: ${A.join(", ")} of ${a.fromFiles}`)}for(let a of o.excludedObjects)i.push(` ${a.objectApiName}: not loaded \u2014 ${a.reason}`);i.push(...Ht(o.removals,"would leave"));for(let a of[...o.heldForExcludedParents??[],...o.quotesLeftUnsynced??[],...o.keysLeftEmpty??[]])i.push(` ${a.objectApiName}: ${a.note}`);for(let a of o.placeholders)i.push(`placeholder for ${a.objectApiName}.${a.field}: ${a.affectedRecords} record(s)`);for(let a of o.requiredDefaults)i.push(`default for ${a.objectApiName}.${a.field}: ${a.affectedRecords} record(s)`+(a.perRecord?`, ${vo(a.perRecord,a.example)}`:""));o.personContacts>0&&i.push(`${o.personContacts} person account contact(s) go in with their account, not counted above`);let u=Object.entries(o.leftUnrecorded??{});if(u.length>0){i.push("left in place, of a load recorded before loads kept what they created \u2014 it may have linked them:");for(let[a,A]of u)i.push(` ${a}: ${A}`)}let w=Object.entries(o.keptByThePlatform??{});if(w.length>0){i.push("left in place by the purge, the platform does not delete them:");for(let[a,A]of w)i.push(` ${a}: ${A}`)}let l=a=>` ${a.name}${a.field?` (${a.field})`:""}${a.message?` \u2014 ${a.message}`:""}`,h=o.perObject.filter(a=>(a.validationRules?.length??0)>0);for(let a of h){i.push(`${a.objectApiName}: ${a.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 A of a.validationRules??[])i.push(l(A))}for(let a of o.perObject){let A=a.lookupFilters??[];A.length!==0&&i.push(`${a.objectApiName}: ${A.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: `+A.map(c=>`${c.field} (${c.referenceTo.join(" or ")}, ${c.records} record(s))`).join(", "))}for(let a of o.perObject){let A=a.validationRulesOnChange??[];A.length!==0&&i.push(`${a.objectApiName}: ${A.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: `+A.join(", "))}let d=new Map(o.placeholders.filter(a=>(a.validationRules?.length??0)>0).map(a=>[a.placeholderObjectApiName,a.validationRules??[]]));for(let[a,A]of d){i.push(`placeholder of ${a}: ${A.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 c of A)i.push(l(c))}o.validationRulesUnread&&i.push(`the target's validation rules could not be listed (${o.validationRulesUnread}): any of them may refuse a record counted to insert`);let y=r.plan.automation;y&&i.push(...ie(y,"the target"));let b=r.plan.emails;b&&i.push(...ae(b,"the target"));let F=r.plan.apiRequests;F&&i.push(Yt(F,"the target"));let T=r.plan.storage;return T&&i.push(No(T,"the target")),i}case"frozen:verify:result":{let o=r.verdict;return[`verification: ${o.status.toUpperCase()}`,...o.checks.map(s=>` ${s.passed?"ok ":"FAIL"} ${s.name}: ${s.detail}`)]}case"frozen:remove:response":{let o=r.result,s=[...new Set(o.objects.flatMap(u=>u.unchecked))],i=o.sweep!==void 0&&o.objects.length===0;return[...o.sweep?Z(o.sweep):[],...(o.otherLoadSweeps??[]).flatMap(({loadedAt:u,result:w})=>[`sweep of the load of ${u}:`,...Z(w)]),...i?[]:[`removal: ${o.status.toUpperCase()}`+(o.leftBy?` \u2014 of what the removal of ${o.leftBy} left`:"")],...o.objects.flatMap(u=>[` ${u.objectApiName}: ${$o(u)||"nothing"} of ${u.planned}${Fe(u)}`,...Et(u,"load"),...u.reasons.map(w=>` ${w}`),...u.filesLeft&&u.filesLeft.count>0?[` ${Ro(u.filesLeft)}`]:[]]),...s.length>0?[`not checked, deleted with their parent: ${s.join(", ")}`]:[],...xe(o.keptByThePlatform),...Ot(o.objects,{sweep:o.sweep!==void 0}),...o.mutedAutomation?q(o.mutedAutomation,"the target"):[]]}case"frozen:remove:sweep:response":{let o=r.loads;if(o)return o.flatMap(({loadedAt:i,listing:u})=>[`sweep of the load of ${i}:`,...se(u,"the target org",n,!0)]);let s=r.otherLoads??[];return s.length>0?[{loadedAt:String(r.loadedAt),listing:r.listing},...s].flatMap(({loadedAt:i,listing:u})=>[`sweep of the load of ${i}:`,...se(u,"the target org",n,!0)]):se(r.listing,"the target org",n,!0)}case"frozen:remove:preview:response":return Po(r.preview);case"frozen:status:response":return[JSON.stringify(r.status,null,2)];default:return[]}}var Do="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 Po(t){let n=o=>t.userNames[o]??o,e=["preview: what a removal would do; nothing was deleted"+(t.leftBy?` \u2014 of what the removal of ${t.leftBy} left`:"")];for(let o of t.objects){let s=[o.toDelete>0?`${o.toDelete} to delete`:"",t.includeChanged&&o.changedSince>0?`${o.changedSince} of them changed since the load`:"",o.alreadyGone>0?`${o.alreadyGone} gone already`:"",o.notVisible>0?`${o.notVisible} not visible`:"",o.keptChanged>0?`${o.keptChanged} kept, changed since the load`:"",o.undeletable>0?`${o.undeletable} left, the user may not delete them`:"",o.unread>0?`${o.unread} left, not read`:""].filter(Boolean);e.push(` ${o.objectApiName}: ${s.join(", ")||"nothing"} of ${o.planned}${Fe(o)}`);let i=Object.entries(o.changedBy).sort((u,w)=>w[1]-u[1]);i.length>0&&e.push(` last changed by: ${i.map(([u,w])=>`${n(u)} ${w}`).join(" \xB7 ")}`);for(let u of o.reasons)e.push(` ${u}`)}e.push(...xe(t.keptByThePlatform));let r=t.refusalCodes;return t.refusals.forEach((o,s)=>{e.push(r?.length===t.refusals.length?oe({code:r[s],message:o},"a removal"):`a removal would be refused: ${o}`)}),e.push(Do),e}async function Io(t){let n=B(t,"manifest.json");if(De(n))try{let e=await Nt(t),{version:r}=JSON.parse(pe(n,"utf8"));return{dir:t,digest:e,...typeof r=="string"?{version:r}:{}}}catch{return}}function xo(t,n){let e=B(t,zt(n)),r=B(t,"referenceid-mapping.json");return!De(e)&&De(r)?r:e}function eo(t){return{status:t.status.toUpperCase(),objects:(t.objects??[]).map(({status:n,...e})=>({...e,verdict:n==="passed"?"PASSED":"FAILED"}))}}async function _o(t,n,e){let r=l=>n.filter(h=>h.type===l).at(-1)?.payload,o=e.targetOrgId?xo(e.sasDir,e.targetOrgId):void 0,s={tool:"sandforge-frozen",step:t,posted:n},i=[],u=[],w=async l=>{let h=await Io(l);h&&(s.dataset=h)};switch(t){case"extract":{let l=r("frozen:extract:response");if(!l)break;await w(typeof l.datasetDir=="string"?l.datasetDir:e.datasetDir);let h=l.manifest?.volumetry?.measured??{};s.objects=Object.entries(h).filter(([,d])=>d>0).map(([d,y])=>({objectApiName:d,records:y}));break}case"load":{await w(e.datasetDir);let l=r("frozen:load:response")?.report,h=r("frozen:load:preview:response")?.plan,d=l?l.recordTypesGiven:h?.recordTypesGiven;d&&(s.recordTypesGiven=d),l?(s.mapping=l.mappingPath,s.objects=l.perObject.map(b=>({objectApiName:b.objectApiName,fromFiles:b.fromFiles,inserted:b.inserted,reused:b.reused,duplicates:b.skippedDuplicates.length,failed:b.failed.length}))):h&&(o&&(s.mapping=o),s.objects=h.perObject.map(b=>({objectApiName:b.objectApiName,fromFiles:b.fromFiles,toInsert:b.toInsert,toLink:b.reusedByKeys+b.reusedFromCatalog+(b.writtenByThePlatform??0),notSent:b.notSent,toPurge:b.toPurge,toDeactivate:b.toDeactivate}))),l&&(s.status=l.status),!l&&r("frozen:load:error")?.code==="LOAD_CANCELLED"&&(s.status="cancelled",o&&(s.mapping=o));let y=r("frozen:verify:result")?.verdict;y&&(s.verdict=eo(y));break}case"verify":{let l=r("frozen:verify:result")?.verdict;await w(l?.manifestPath?po(l.manifestPath):e.datasetDir),o&&(s.mapping=o),l&&(s.verdict=eo(l));break}case"remove":{o&&(s.mapping=o);let l=r("frozen:remove:response")?.result,h=r("frozen:remove:preview:response")?.preview;l?(s.status=l.status,l.mutedAutomation&&(s.mutedAutomation=l.mutedAutomation),s.objects=l.objects.map(d=>({objectApiName:d.objectApiName,planned:d.planned,deleted:d.deleted,alreadyGone:d.alreadyGone,keptChanged:d.keptChanged,keptDependents:d.keptDependents,refused:d.refused,notReached:d.notReached??0,notVisible:d.notVisible??0,...d.tookAlong?{tookAlong:d.tookAlong}:{},...d.cameAlong?{cameAlong:d.cameAlong}:{}})),s.includeChanged=l.includeChanged):h&&(s.preview=!0,s.includeChanged=h.includeChanged,s.objects=h.objects.map(d=>({objectApiName:d.objectApiName,planned:d.planned,toDelete:d.toDelete,alreadyGone:d.alreadyGone,changedSince:d.changedSince,keptChanged:d.keptChanged,undeletable:d.undeletable,notVisible:d.notVisible,unread:d.unread})),i.push(...h.refusals),h.refusalCodes?.length===h.refusals.length&&u.push(...h.refusalCodes));break}}return i.push(...e.refusals??[]),e.refusalCodes?.length===(e.refusals??[]).length&&u.push(...e.refusalCodes??[]),i.length>0&&(s.refusals=i),i.length>0&&u.length===i.length&&(s.refusalCodes=u),e.mute&&Object.assign(s,e.mute),e.checkpoint&&(s.checkpoint=e.checkpoint),s}async function Mo(t=process.argv){let n=Date.now(),e=wo(t),r=f=>{process[e.json?"stderr":"stdout"].write(`${f}
267
+ `)},o=JSON.parse(pe(e.configPath,"utf8")),s=typeof o.sasDir=="string"?o.sasDir:B(fo(),".sandforge-sas");uo(s,{recursive:!0});let i=ht(e.storePath??B(s,"cli-store.json")),u=new Map,w=new Map,l=new Map,h=e.source?await Kt(e.source,u):void 0,d=e.target?await Kt(e.target,u,w,l):void 0,y=[],b=!1,F=!1,T=new Gt({log:()=>{},broker:{postToWebview:f=>{if(f.type!=="frozen:load:progress"&&(y.push(f),Ie(f)&&(b=!0),!F))for(let m of zo(f,e))r(m)}},orgManager:{getOrg:f=>u.get(f)?.org},orgRegistry:{getCredentials:async f=>u.get(f)?.credentials},configStore:i,infraServices:{productionGuard:Lt(r,e.target??e.source??"the org"),piiDetector:new at},nextId:()=>`cli-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}),a=d?w.get(d):void 0,A=d?l.get(d):void 0,c=e.checkpointFirst&&A?vt({module:"frozen",operationId:`sandforge-frozen-load-${n}`,request:e.checkpointFirst,session:A.session,org:{id:A.typed.id,orgType:A.typed.orgType,...A.typed.edition!==void 0?{edition:A.typed.edition}:{}},connect:ve,journalDir:H(),say:r}):void 0;a&&T.setTargetAutomation(X(a)),T.setMuteOffered(Ee("--mute-automation")),T.setSaltKeeper(xt(process.env,e.saltFile)),e.target&&T.setOtherModuleRuns(Co(e.target,void 0,Le(s)));let R=new Wt;T.setRegistry(R);let O,N,J=!1,V=!1,U,fe=rt(f=>{if(U=f,process.stderr.write(`
259
268
  interrupted: the ${e.step} stops after the call under way, and says what it wrote (Ctrl-C again ends it at once)
260
- `),z){z.abort();return}for(let m of R.getRunning())R.abort(m.operationId);E&&R.cancelBeforeStart(E),(!E||V)&&process.exit(me(f))}),Pe=typeof t.datasetDir=="string"?t.datasetDir:_(s,"dataset"),P=[],U=f=>{P.push(f),r(Y(f,"a load"))},ue=[],S,Ie=!1,W,B,ce=async f=>{if(!e.json)return;let m=[...P,...ue],v=await jo(e.step,b,{datasetDir:Pe,sasDir:s,...d?{targetOrgId:d}:{},...m.length>0?{refusals:m.map(({message:g})=>g),refusalCodes:m.map(({code:g})=>g)}:{},...W?{mute:W}:{},...B?{checkpoint:B}:{}});process.stdout.write(`${JSON.stringify({...v,...S?{refused:S}:{},...f?{ended:f}:{}},null,2)}
261
- `)},T=async(f,m)=>{let v=`cli-${f}-${Date.now()}`;E=v;try{return await a.handle({id:v,type:f,payload:m})}finally{E=void 0}},xe;try{xe=await to()}finally{le()}if(xe==="ended"&&!M){k&&(process.exitCode=1),await ce(!0);return}if(M){await ce(),process.stderr.write(`${J?ot:Po(e.preview?"preview":e.step,e.step!=="load"||e.dryRun||Te(b))}
262
- `),process.exitCode=me(M);return}if(Qe(k||P.length>0?1:Ie?3:Ro(e.step,b)),e.json){await ce();return}r(`done in ${Date.now()-n}ms`);async function _e(f){await T("frozen:remove:automation",f);let m=G=>b.find(L=>L.type===G)?.payload,v=m("frozen:remove:automation:response"),g=Array.isArray(f.sweptObjects)?f.sweptObjects:[],$=v?.purge&&g.length>0?v.purge:void 0,c=v&&e.muteAutomation?y&&(e.preview||e.dryRun)?await ye(we(y),v.automation,{writes:Z(v.steps)}):be(v.automation,Z(v.steps)):void 0,A=c&&!("refused"in c)?c:void 0,{lines:j,refusal:F}=Ee({read:v?.automation??{unread:String(m("frozen:remove:automation:error")?.message)},steps:$??v?.steps??{},...A?{mute:{automation:A.automation,muted:A.planned}}:{}},e.target??"",f.reload===!0?"reload":"removal",$?{delete:g}:void 0);for(let G of j)r(G);let D=c&&"refused"in c?c.refused:F!==void 0&&!e.acceptAutomation?{code:"AUTOMATION_NOT_ACCEPTED",message:F}:void 0;return{...v?{steps:v.steps}:{},...A?{planned:A}:{},...D?{refusal:D.message,code:D.code}:{}}}function Me(f){S={code:te,message:f},P.push(S),r(Q(S)),k=!0}async function Ue(){return N=!0,await T("frozen:status",{}),N=!1,b.filter(m=>m.type==="frozen:status:response").at(-1)?.payload?.status?.loadRecords?.find(m=>m.orgId===d)}async function Be(f=[]){if(!e.reload||e.pilot)return;let m=await Ue();if(!(!m||m.created.length===0&&f.length===0))return _e({targetOrgId:d,loadedAt:m.loadedAt,reload:!0,...f.length>0?{sweptObjects:f}:{}})}async function Ge(){let f=await Ue();if(!f)return[];r(`reading what a sweep of ${e.target} would take for the loads a reload replaces\u2026`);let m=b.length;await T("frozen:remove:sweep",{targetOrgId:d,loadedAt:f.loadedAt,reload:!0});let v=b.slice(m);if(v.some($=>$.type==="frozen:remove:sweep:error"))return;let g=v.filter($=>$.type==="frozen:remove:sweep:response").at(-1)?.payload?.loads;return[...new Set((g??[]).flatMap(({listing:$})=>fe($,e)))]}async function eo(f){r(`reading what a sweep of ${e.target} would take\u2026`);let m=b.length;await T("frozen:remove:sweep",{targetOrgId:d,loadedAt:f});let v=b.slice(m);if(v.some(c=>c.type==="frozen:remove:sweep:error"))return;let g=v.filter(c=>c.type==="frozen:remove:sweep:response").at(-1)?.payload,$=[...g?.listing?[g.listing]:[],...(g?.otherLoads??[]).map(({listing:c})=>c)];return[...new Set($.flatMap(c=>fe(c,e)))]}async function to(){if(await T("frozen:config:save",{config:t}),k)return"ended";switch(e.step){case"select":r(`selecting from ${e.source}\u2026`),await T("frozen:select",{sourceOrgId:h});break;case"extract":r(`extracting from ${e.source}\u2026`),await T("frozen:extract",{sourceOrgId:h,...e.author?{author:e.author}:{}});break;case"load":{if(e.dryRun){r(`reading what a load into ${e.target}${e.pilot?" (pilot)":""} would do\u2026`),await T("frozen:load:preview",{targetOrgId:d,...e.pilot?{pilot:!0}:{},...e.reload?{reload:!0}:{},...e.goneFirst!==void 0?{goneFirst:uo(e.goneFirst)}:{},...e.writeEncrypted?{writeEncrypted:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{},...e.acceptEmails?{acceptEmails:!0}:{},...e.acceptAutomation?{acceptAutomation:!0}:{}});let c=b.find(C=>C.type==="frozen:load:preview:response")?.payload?.plan,A=c?Lt(Ft(c),e.maxTotal):void 0;A&&U({code:"MAX_RECORDS",message:A});let j=c?.automation?.refused;j&&U(j);let F=c?.emails?.refused;F&&U(F);let D=c?.apiRequests?.refused;D&&U(D);let G=(c&&e.sweep?await Ge():[])??[],L=c?await Be(G):void 0;L?.refusal!==void 0&&U({code:L.code??"AUTOMATION_NOT_ACCEPTED",message:L.refusal});let I;if(e.muteAutomation&&c&&y){I=await H(y).read(d,[...new Set([...c.perObject.map(x=>x.objectApiName),...L?.steps?.delete??[]])]);let C=await ye(we(y),I,{writes:Lo(L?.steps)});if("refused"in C)P.some(({message:x})=>x===C.refused.message)||U(C.refused);else{for(let x of q(C.planned,e.target??"the target"))r(x);W={mutedAutomation:C.planned,mutePlan:C.plan}}}for(let C of Yt(c?.recordTypesGiven,!0,(W?.mutePlan.assign.length??0)>0))r(C);let We=c?No(c):[];if(u&&c&&y&&We.length>0){I??=await H(y).read(d,c.perObject.map(pe=>pe.objectApiName)).catch(()=>{});let{estimate:C,refused:x}=await Zt(u,{written:We,running:Jt(I,W?.mutePlan)});if(C){B=C;for(let pe of Re(C))r(pe)}x!==void 0&&U({code:te,message:x})}break}let f=e.reload&&!e.pilot&&e.sweep?await Ge():[];if(f===void 0)return r("Nothing written."),"ended";let m=e.reload&&!e.pilot?await Be(f):void 0;if(m?.refusal!==void 0)return S={code:m.code??"AUTOMATION_NOT_ACCEPTED",message:m.refusal},P.push(S),r(Q(S)),k=!0,"ended";if(e.sweep&&(r("around the purge, a sweep deletes what the target's automation made for each load it replaces, as the load's user, tied to its records \u2014 run with --dry-run to see what"),a.setRemovalAsker(async c=>{let{lines:A,refusal:j}=Ee(c,e.target??"","reloadSweep");for(let F of A)r(F);if(!(j===void 0||e.acceptAutomation))return S={code:"AUTOMATION_NOT_ACCEPTED",message:j},P.push(S),S})),!e.yes&&!await dt(`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 r("Nothing written."),"ended";let v;if(u&&y){let c=zo(Pe),A=await H(y).read(d,c).catch(()=>{}),j={written:c,running:Jt(A,e.muteAutomation&&A?be(A,ze).plan:void 0)},{estimate:F,refused:D}=await Zt(u,j);if(F){B=F;for(let I of Re(F))r(I)}if(D!==void 0||F===void 0)return Me(`${D??""} Nothing was written.`.trim()),"ended";z=new AbortController;let G=z.signal,L=await rt(()=>u.take(j,F,{signal:G})).finally(()=>{z=void 0});if("stop"in L)return L.stop.code!==te?(J=!0,"ended"):(Me(mt(L.stop)),"ended");v=L.checkpoint,B=v;for(let I of gt(v,e.target??"the target",e.muteAutomation))r(I)}r(`loading into ${e.target}${e.pilot?" (pilot)":""}\u2026`);let g=new Date().toISOString();await T("frozen:load",{targetOrgId:d,...e.pilot?{pilot:!0}:{},...e.reload?{reload:!0}:{},...e.writeEncrypted?{writeEncrypted:!0}:{},...e.maxTotal!==void 0?{maxRecords:e.maxTotal}:{},...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 $=b.filter(c=>c.type==="frozen:load:error").map(je).find(c=>c!==void 0);if($&&!S&&(S=$,P.push(S)),d&&Te(b)){let c=zt(await new jt(s,{orgId:d}).recorded().catch(()=>{}),g);try{Pt(K(),{organizationId:d,sas:Se(s),startedAt:g,endedAt:new Date().toISOString(),...c?{lastWriteAt:c}:{}})}catch(A){r(`warning: this load could not be added to ${K()}: another sas's sweep of ${e.target??""} will not see it (${A instanceof Error?A.message:String(A)})`)}}if(u&&v){let c=v;B=await u.settle(c,Te(b)).catch(A=>(r(`warning: the checkpoint '${c.name}' taken before the load could not be deleted (${A instanceof Error?A.message:String(A)}): delete it with ${ut("checkpoint")} delete --org ${e.target??""} --checkpoint `+c.checkpointId),c));for(let A of wt(B))r(A)}break}case"verify":r(`verifying ${e.target}\u2026`),await T("frozen:verify",{targetOrgId:d});break;case"remove":{N=!0,await T("frozen:status",{}),N=!1;let m=b.filter(g=>g.type==="frozen:status:response").at(-1)?.payload?.status?.loadRecords?.find(g=>g.orgId===d);if(!m)return r(`No load into ${e.target} is recorded in this sas: nothing to remove.`),"ended";if(e.preview){if(r(`reading what a removal from ${e.target} would do\u2026`),await T("frozen:remove:preview",{targetOrgId:d,loadedAt:m.loadedAt,...e.includeChanged?{includeChanged:!0}:{}}),b.some(g=>g.type==="frozen:remove:preview:response")){let g=e.sweep?await eo(m.loadedAt):[];if(g===void 0)break;let{planned:$,refusal:c,code:A}=await _e({targetOrgId:d,loadedAt:m.loadedAt,...g.length>0?{sweptObjects:g}:{}});if($&&(W={mutedAutomation:$.planned,mutePlan:$.plan}),c!==void 0){let j={code:A??"AUTOMATION_NOT_ACCEPTED",message:c};ue.push(j),r(Y(j,"a removal"))}}break}if(e.sweepList){r(`reading what a sweep of ${e.target} would take\u2026`),await T("frozen:remove:sweep",{targetOrgId:d,loadedAt:m.loadedAt});let g=b.filter($=>$.type==="frozen:remove:sweep:response").at(-1)?.payload;Ie=[g?.listing,...(g?.otherLoads??[]).map(({listing:$})=>$)].some($=>$?.refusal!==void 0);break}for(let g of mo(m,e.target??""))r(g);e.sweep&&r(`${Ne(m)>0?"before them, a sweep deletes":"a sweep alone deletes"} what the target's automation made for the load, as the load's user, tied to its records \u2014 run ${At("--sweep-list")} to see what`);let v=!1;if(a.setRemovalAsker(async g=>{let{lines:$,refusal:c}=Ee(g,e.target??"");for(let A of $)r(A);if(c!==void 0&&!e.acceptAutomation)return{message:c,code:"AUTOMATION_NOT_ACCEPTED"};if(!e.yes&&go(m,g.steps)){V=!0;let A=await lt(`Type ${e.target} to delete them:`);if(V=!1,A!==e.target)return v=!0,{message:"Nothing deleted.",code:Qt}}r(`removing from ${e.target}\u2026`)}),await T("frozen:remove",{targetOrgId:d,loadedAt:m.loadedAt,...ho(e)}),v)return"ended";S=b.filter(g=>g.type==="frozen:remove:error").map(je).find(g=>g!==void 0),S&&ue.push(S);break}case"status":await T("frozen:status",{});break}return"through"}}var ze=(o,n)=>n==="insert"||n==="update";function Lo(o){let n=o?Z(o):void 0;return(e,r)=>ze(e,r)||n?.(e,r)===!0}function Yt(o,n,e=!1){return St((o??[]).map(r=>({recordTypeGiven:r})),n,e)}function Jt(o,n){return{firing:o?He(o,n,ze).firing:[]}}function No(o){let n=[...o.perObject.filter(e=>e.toInsert>0||e.toPurge>0||e.toDeactivate>0).map(e=>e.objectApiName),...(o.placeholders??[]).map(e=>e.placeholderObjectApiName)];return[...new Set(n)]}function zo(o){try{let n=JSON.parse(de(_(o,"manifest.json"),"utf8")),e=Object.entries(n.volumetry?.measured??{}).filter(([,r])=>typeof r=="number"&&r>0).map(([r])=>r);if(e.length>0)return e}catch{}try{return no(_(o,"data")).filter(n=>n.endsWith(".json")).map(n=>n.slice(0,-5)).sort()}catch{return[]}}var Do=new Set(["INVALID_PAYLOAD","CONFIG_MISSING",ee.code,"REPLACE_LEAVES_RECORDS","MUTE_PRODUCTION","MUTE_NO_RIGHT","MUTE_FAILED","EMAILS_NOT_ACCEPTED","FROZEN_EMAILS_EXCEEDED","AUTOMATION_NOT_ACCEPTED",ve]);function Te(o){let n=s=>o.filter(i=>i.type===s).at(-1)?.payload,e=n("frozen:load:response")?.report;if(e){let s=i=>Object.values(i??{}).reduce((l,w)=>l+w,0);return e.perObject.some(i=>i.inserted>0)||(e.placeholders??[]).length>0||s(e.purge?.deleted)>0||s(e.purge?.deactivated)>0}let r=n("frozen:load:error"),t=r?.code;return typeof t=="string"&&Do.has(t)?!1:r?.written!==0}async function Zt(o,n){try{let e=await o.scope(n);return{estimate:e,...e.refusal!==void 0?{refused:ht(e.refusal)}:{}}}catch(e){return{refused:tt(e).replace(/ Nothing was written\.$/,"")}}}function Po(o,n=!0){return o==="load"&&!n?"interrupted: the load stopped before it created or purged a record: the sas is as it was, and `remove` has nothing of this load to take back":o==="load"?"interrupted: the load stopped before it was through; what it wrote is recorded in the sas and the audit trail, and `remove` takes it back":o==="remove"?"interrupted: the removal stopped before it was through; what it deleted is recorded, and `remove` again takes what it left":o==="preview"?"interrupted: the preview stopped before it was through, and deleted nothing":`interrupted: the ${o} stopped before it was through`}process.argv[1]?.includes("sandforge-frozen")&&(yt(),Fo().then(()=>process.exit(process.exitCode??0)).catch(o=>{process.stderr.write(`${o instanceof Error?o.message:String(o)}
263
- `),process.exit(1)}));export{So as FROZEN_PREVIEW_UNREAD,$o as commandLineOtherRuns,zo as datasetObjectsOf,qt as discoveryLine,Fe as failsTheStep,jo as frozenAnswer,Po as frozenInterruptedLine,Te as frozenLoadWrote,Yt as frozenRecordTypeLines,Ro as frozenStepExit,uo as goneFirstIdsOf,Ht as loadApiRequestsLine,No as loadPlanWrites,Fo as main,Oo as messageLines,co as parseArgs,je as refusedFirstOf,ho as removalAsked,go as removalAsks,Ee as removalAutomation,mo as removalPlanLines,Eo as removalPreviewLines,bo as selectStepLine,po as typeOrg};
269
+ `),N){N.abort();return}for(let m of R.getRunning())R.abort(m.operationId);O&&R.cancelBeforeStart(O),(!O||V)&&process.exit(be(f))}),Ue=typeof o.datasetDir=="string"?o.datasetDir:B(s,"dataset"),P=[],I=f=>{P.push(f),r(oe(f,"a load"))},he=[],S,Ge=!1,W,G,Q,me=async f=>{if(!e.json)return;let m=[...P,...he],v=await _o(e.step,y,{datasetDir:Ue,sasDir:s,...d?{targetOrgId:d}:{},...m.length>0?{refusals:m.map(({message:g})=>g),refusalCodes:m.map(({code:g})=>g)}:{},...W?{mute:W}:{},...G?{checkpoint:G}:{}});process.stdout.write(`${JSON.stringify({...v,...Q?{notSwept:Q}:{},...S?{refused:S}:{},...f?{ended:f}:{}},null,2)}
270
+ `)},E=async(f,m)=>{let v=`cli-${f}-${Date.now()}`;O=v;try{return await T.handle({id:v,type:f,payload:m})}finally{O=void 0}},We;try{We=await io()}finally{fe()}if(We==="ended"&&!U){b&&(process.exitCode=1),await me(!0);return}if(U){await me(),process.stderr.write(`${J?dt:qo(e.preview?"preview":e.step,e.step!=="load"||e.dryRun||ze(y))}
271
+ `),process.exitCode=be(U);return}if(nt(b||P.length>0?1:Ge?3:Fo(e.step,y)),e.json){await me();return}r(`done in ${Date.now()-n}ms`);async function qe(f){await E("frozen:remove:automation",f);let m=x=>y.find(_=>_.type===x)?.payload,v=m("frozen:remove:automation:response"),g=Array.isArray(f.sweptObjects)?f.sweptObjects:[],k=v?.purge&&g.length>0?v.purge:void 0,p=v&&e.muteAutomation?a&&(e.preview||e.dryRun)?await $e(ke(a),v.automation,{writes:ee(v.steps)}):Re(v.automation,ee(v.steps)):void 0,$=p&&!("refused"in p)?p:void 0,{lines:j,refusal:L}=Ne({read:v?.automation??{unread:String(m("frozen:remove:automation:error")?.message)},steps:k??v?.steps??{},...$?{mute:{automation:$.automation,muted:$.planned}}:{}},e.target??"",f.reload===!0?"reload":"removal",k?{delete:g}:void 0);for(let x of j)r(x);let z=p&&"refused"in p?p.refused:L!==void 0&&!e.acceptAutomation?{code:"AUTOMATION_NOT_ACCEPTED",message:L}:void 0;return{...v?{steps:v.steps}:{},...$?{planned:$}:{},...z?{refusal:z.message,code:z.code}:{}}}function Ve(f){S={code:ne,message:f},P.push(S),r(te(S)),b=!0}async function Ke(){return F=!0,await E("frozen:status",{}),F=!1,y.filter(m=>m.type==="frozen:status:response").at(-1)?.payload?.status?.loadRecords?.find(m=>m.orgId===d)}async function He(f=[]){if(!e.reload||e.pilot)return;let m=await Ke();if(!(!m||m.created.length===0&&f.length===0))return qe({targetOrgId:d,loadedAt:m.loadedAt,reload:!0,...f.length>0?{sweptObjects:f}:{}})}async function Xe(){let f=await Ke();if(!f)return[];r(`reading what a sweep of ${e.target} would take for the loads a reload replaces\u2026`);let m=y.length;await E("frozen:remove:sweep",{targetOrgId:d,loadedAt:f.loadedAt,reload:!0});let v=y.slice(m);if(v.some(k=>k.type==="frozen:remove:sweep:error"))return;let g=v.filter(k=>k.type==="frozen:remove:sweep:response").at(-1)?.payload?.loads;return[...new Set((g??[]).flatMap(({listing:k})=>ye(k,e)))]}async function so(f){r(`reading what a sweep of ${e.target} would take\u2026`);let m=y.length;await E("frozen:remove:sweep",{targetOrgId:d,loadedAt:f});let v=y.slice(m);if(v.some(p=>p.type==="frozen:remove:sweep:error"))return;let g=v.filter(p=>p.type==="frozen:remove:sweep:response").at(-1)?.payload,k=[...g?.listing?[g.listing]:[],...(g?.otherLoads??[]).map(({listing:p})=>p)];return[...new Set(k.flatMap(p=>ye(p,e)))]}async function ao(f){let m=y.length,v=b;F=!0;try{await E("frozen:remove:sweep",{targetOrgId:d,loadedAt:f})}finally{F=!1}let g=y.splice(m);b=v;let k=g.find(p=>p.type==="frozen:remove:sweep:response")?.payload?.listing;return k&&k.refusal===void 0&&k.found.length>0?k:void 0}async function io(){if(await E("frozen:config:save",{config:o}),b)return"ended";switch(e.step){case"select":r(`selecting from ${e.source}\u2026`),await E("frozen:select",{sourceOrgId:h});break;case"extract":r(`extracting from ${e.source}\u2026`),await E("frozen:extract",{sourceOrgId:h,...e.author?{author:e.author}:{}});break;case"load":{if(e.dryRun){r(`reading what a load into ${e.target}${e.pilot?" (pilot)":""} would do\u2026`),await E("frozen:load:preview",{targetOrgId:d,...e.pilot?{pilot:!0}:{},...e.reload?{reload:!0}:{},...e.goneFirst!==void 0?{goneFirst:go(e.goneFirst)}:{},...e.writeEncrypted?{writeEncrypted:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{},...e.acceptEmails?{acceptEmails:!0}:{},...e.acceptAutomation?{acceptAutomation:!0}:{}});let p=y.find(C=>C.type==="frozen:load:preview:response")?.payload?.plan,$=p?It(Pt(p),e.maxTotal):void 0;$&&I({code:"MAX_RECORDS",message:$});let j=p?.automation?.refused;j&&I(j);let L=p?.emails?.refused;L&&I(L);let z=p?.storage?.refusal;z&&I(z);let x=p?.apiRequests?.refused;x&&I(x);let _=(p&&e.sweep?await Xe():[])??[],D=p?await He(_):void 0;D?.refusal!==void 0&&I({code:D.code??"AUTOMATION_NOT_ACCEPTED",message:D.refusal});let Y;if(e.muteAutomation&&p&&a){Y=await X(a).read(d,[...new Set([...p.perObject.map(M=>M.objectApiName),...D?.steps?.delete??[]])]);let C=await $e(ke(a),Y,{writes:Bo(D?.steps)});if("refused"in C)P.some(({message:M})=>M===C.refused.message)||I(C.refused);else{for(let M of q(C.planned,e.target??"the target"))r(M);W={mutedAutomation:C.planned,mutePlan:C.plan}}}for(let C of no(p?.recordTypesGiven,!0,(W?.mutePlan.assign.length??0)>0))r(C);let Ze=p?Uo(p):[];if(c&&p&&a&&Ze.length>0){Y??=await X(a).read(d,p.perObject.map(ge=>ge.objectApiName)).catch(()=>{});let{estimate:C,refused:M}=await oo(c,{written:Ze,running:to(Y,W?.mutePlan)});if(C){G=C;for(let ge of Ce(C))r(ge)}M!==void 0&&I({code:ne,message:M})}break}let f=e.reload&&!e.pilot&&e.sweep?await Xe():[];if(f===void 0)return r("Nothing written."),"ended";let m=e.reload&&!e.pilot?await He(f):void 0;if(m?.refusal!==void 0)return S={code:m.code??"AUTOMATION_NOT_ACCEPTED",message:m.refusal},P.push(S),r(te(S)),b=!0,"ended";if(e.sweep&&(r("around the purge, a sweep deletes what the target's automation made for each load it replaces, as the load's user, tied to its records \u2014 run with --dry-run to see what"),T.setRemovalAsker(async p=>{let{lines:$,refusal:j}=Ne(p,e.target??"","reloadSweep");for(let L of $)r(L);if(!(j===void 0||e.acceptAutomation))return S={code:"AUTOMATION_NOT_ACCEPTED",message:j},P.push(S),S})),!e.yes&&!await mt(`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 r("Nothing written."),"ended";let v;if(c&&a){let p=Go(Ue),$=await X(a).read(d,p).catch(()=>{}),j={written:p,running:to($,e.muteAutomation&&$?Re($,Me).plan:void 0)},{estimate:L,refused:z}=await oo(c,j);if(L){G=L;for(let D of Ce(L))r(D)}if(z!==void 0||L===void 0)return Ve(`${z??""} Nothing was written.`.trim()),"ended";N=new AbortController;let x=N.signal,_=await lt(()=>c.take(j,L,{signal:x})).finally(()=>{N=void 0});if("stop"in _)return _.stop.code!==ne?(J=!0,"ended"):(Ve(At(_.stop)),"ended");v=_.checkpoint,G=v;for(let D of kt(v,e.target??"the target",e.muteAutomation))r(D)}r(`loading into ${e.target}${e.pilot?" (pilot)":""}\u2026`);let g=new Date().toISOString();await E("frozen:load",{targetOrgId:d,...e.pilot?{pilot:!0}:{},...e.reload?{reload:!0}:{},...e.writeEncrypted?{writeEncrypted:!0}:{},...e.maxTotal!==void 0?{maxRecords:e.maxTotal}:{},...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 k=y.filter(p=>p.type==="frozen:load:error").map(Pe).find(p=>p!==void 0);if(k&&!S&&(S=k,P.push(S)),d&&ze(y)){let p=_t(await new Dt(s,{orgId:d}).recorded().catch(()=>{}),g);try{Bt(H(),{organizationId:d,sas:Le(s),startedAt:g,endedAt:new Date().toISOString(),...p?{lastWriteAt:p}:{}})}catch($){r(`warning: this load could not be added to ${H()}: another sas's sweep of ${e.target??""} will not see it (${$ instanceof Error?$.message:String($)})`)}}if(c&&v){let p=v;G=await c.settle(p,ze(y)).catch($=>(r(`warning: the checkpoint '${p.name}' taken before the load could not be deleted (${$ instanceof Error?$.message:String($)}): delete it with ${we("checkpoint")} delete --org ${e.target??""} --checkpoint `+p.checkpointId),p));for(let $ of $t(G))r($)}break}case"verify":r(`verifying ${e.target}\u2026`),await E("frozen:verify",{targetOrgId:d});break;case"remove":{F=!0,await E("frozen:status",{}),F=!1;let m=y.filter(g=>g.type==="frozen:status:response").at(-1)?.payload?.status?.loadRecords?.find(g=>g.orgId===d);if(!m)return r(`No load into ${e.target} is recorded in this sas: nothing to remove.`),"ended";if(e.preview){if(r(`reading what a removal from ${e.target} would do\u2026`),await E("frozen:remove:preview",{targetOrgId:d,loadedAt:m.loadedAt,...e.includeChanged?{includeChanged:!0}:{}}),y.some(g=>g.type==="frozen:remove:preview:response")){let g=e.sweep?await so(m.loadedAt):[];if(g===void 0)break;let{planned:k,refusal:p,code:$}=await qe({targetOrgId:d,loadedAt:m.loadedAt,...g.length>0?{sweptObjects:g}:{}});if(k&&(W={mutedAutomation:k.planned,mutePlan:k.plan}),p!==void 0){let j={code:$??"AUTOMATION_NOT_ACCEPTED",message:p};he.push(j),r(oe(j,"a removal"))}}break}if(e.sweepList){r(`reading what a sweep of ${e.target} would take\u2026`),await E("frozen:remove:sweep",{targetOrgId:d,loadedAt:m.loadedAt});let g=y.filter(k=>k.type==="frozen:remove:sweep:response").at(-1)?.payload;Ge=[g?.listing,...(g?.otherLoads??[]).map(({listing:k})=>k)].some(k=>k?.refusal!==void 0);break}for(let g of Ao(m,e.target??""))r(g);e.sweep&&r(`${_e(m)>0?"before them, a sweep deletes":"a sweep alone deletes"} what the target's automation made for the load, as the load's user, tied to its records \u2014 run ${je("--sweep-list")} to see what`);let v=!1;if(T.setRemovalAsker(async g=>{let{lines:k,refusal:p}=Ne(g,e.target??"");for(let $ of k)r($);if(p!==void 0&&!e.acceptAutomation)return{message:p,code:"AUTOMATION_NOT_ACCEPTED"};if(!e.yes&&ko(m,g.steps)){V=!0;let $=await gt(`Type ${e.target} to delete them:`);if(V=!1,$!==e.target)return v=!0,{message:"Nothing deleted.",code:ro}}r(`removing from ${e.target}\u2026`)}),await E("frozen:remove",{targetOrgId:d,loadedAt:m.loadedAt,...bo(e)}),v)return"ended";if(S=y.filter(g=>g.type==="frozen:remove:error").map(Pe).find(g=>g!==void 0),S&&he.push(S),!e.sweep&&!S&&jo(y)){Q=await ao(m.loadedAt);for(let g of Lo(Q))r(g)}break}case"status":await E("frozen:status",{});break}return"through"}}var Me=(t,n)=>n==="insert"||n==="update";function Bo(t){let n=t?ee(t):void 0;return(e,r)=>Me(e,r)||n?.(e,r)===!0}function no(t,n,e=!1){return jt((t??[]).map(r=>({recordTypeGiven:r})),n,e)}function to(t,n){return{firing:t?et(t,n,Me).firing:[]}}function Uo(t){let n=[...t.perObject.filter(e=>e.toInsert>0||e.toPurge>0||e.toDeactivate>0).map(e=>e.objectApiName),...(t.placeholders??[]).map(e=>e.placeholderObjectApiName)];return[...new Set(n)]}function Go(t){try{let n=JSON.parse(pe(B(t,"manifest.json"),"utf8")),e=Object.entries(n.volumetry?.measured??{}).filter(([,r])=>typeof r=="number"&&r>0).map(([r])=>r);if(e.length>0)return e}catch{}try{return co(B(t,"data")).filter(n=>n.endsWith(".json")).map(n=>n.slice(0,-5)).sort()}catch{return[]}}var Wo=new Set(["INVALID_PAYLOAD","CONFIG_MISSING",re.code,"REPLACE_LEAVES_RECORDS","MUTE_PRODUCTION","MUTE_NO_RIGHT","MUTE_FAILED","EMAILS_NOT_ACCEPTED","FROZEN_EMAILS_EXCEEDED","AUTOMATION_NOT_ACCEPTED",Se,"FROZEN_STORAGE_EXCEEDED"]);function ze(t){let n=s=>t.filter(i=>i.type===s).at(-1)?.payload,e=n("frozen:load:response")?.report;if(e){let s=i=>Object.values(i??{}).reduce((u,w)=>u+w,0);return e.perObject.some(i=>i.inserted>0)||(e.placeholders??[]).length>0||s(e.purge?.deleted)>0||s(e.purge?.deactivated)>0}let r=n("frozen:load:error"),o=r?.code;return typeof o=="string"&&Wo.has(o)?!1:r?.written!==0}async function oo(t,n){try{let e=await t.scope(n);return{estimate:e,...e.refusal!==void 0?{refused:bt(e.refusal)}:{}}}catch(e){return{refused:it(e).replace(/ Nothing was written\.$/,"")}}}function qo(t,n=!0){return t==="load"&&!n?"interrupted: the load stopped before it created or purged a record: the sas is as it was, and `remove` has nothing of this load to take back":t==="load"?"interrupted: the load stopped before it was through; what it wrote is recorded in the sas and the audit trail, and `remove` takes it back":t==="remove"?"interrupted: the removal stopped before it was through; what it deleted is recorded, and `remove` again takes what it left":t==="preview"?"interrupted: the preview stopped before it was through, and deleted nothing":`interrupted: the ${t} stopped before it was through`}process.argv[1]?.includes("sandforge-frozen")&&(Rt(),Mo().then(()=>process.exit(process.exitCode??0)).catch(t=>{process.stderr.write(`${t instanceof Error?t.message:String(t)}
272
+ `),process.exit(1)}));export{Do as FROZEN_PREVIEW_UNREAD,Co as commandLineOtherRuns,Go as datasetObjectsOf,Zt as discoveryLine,Ie as failsTheStep,_o as frozenAnswer,qo as frozenInterruptedLine,ze as frozenLoadWrote,no as frozenRecordTypeLines,Fo as frozenStepExit,go as goneFirstIdsOf,Yt as loadApiRequestsLine,Uo as loadPlanWrites,No as loadStorageLine,Mo as main,zo as messageLines,Lo as notSweptLines,wo as parseArgs,Pe as refusedFirstOf,bo as removalAsked,ko as removalAsks,Ne as removalAutomation,Ao as removalPlanLines,Po as removalPreviewLines,jo as removalTookRecords,So as selectStepLine,yo as typeOrg};