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{a as P}from"./chunk-ZE6HKRR4.mjs";import{a as X,b as Z,c as Q,d as K}from"./chunk-RSWDYIHY.mjs";import{c as R,e as Y}from"./chunk-AV5SWEHP.mjs";import{g as W,h as U,i as H}from"./chunk-4HFRHFGQ.mjs";import"./chunk-342FN7AO.mjs";import"./chunk-BOGNK4LV.mjs";import{b as M,c as L}from"./chunk-L776PUMV.mjs";import{A as F}from"./chunk-6MUEPV7M.mjs";import"./chunk-HJC7AIBK.mjs";import"./chunk-OTWRDD6L.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import{a as T,b as x}from"./chunk-RH3N2H7P.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-55HEMHEG.mjs";import"./chunk-P42X3B4D.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VXHDBYMI.mjs";import"./chunk-ENLBYECD.mjs";import"./chunk-PA3MKJVH.mjs";import"./chunk-4TLYUZD5.mjs";import{ha as B,ya as z}from"./chunk-ZLZRU6MO.mjs";import"./chunk-WIO4XO4F.mjs";import{a as k}from"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-PNCONNFJ.mjs";import"./chunk-CGWXQX75.mjs";import{a as C,h as S}from"./chunk-TZE3Y7IQ.mjs";import"./chunk-SIOZXPFG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import{a as v,b as N,e as q,g as J}from"./chunk-MTMH6H2A.mjs";import"./chunk-B45CNPUX.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-SBIMVCXT.mjs";import"./chunk-NTOVCTRS.mjs";var ee=/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/,te=/^\d{4}-\d{2}-\d{2}$/,re=["CaseComment","EmailMessage","Asset","Contract","Case","Contact","Account"],se=`sandforge cleanup \u2014 Bulk delete records you created on a sandbox in the
7
+ import{b as k}from"./chunk-W7U5E5ZL.mjs";import{a as Z,b as Q,c as K,d as V}from"./chunk-RSWDYIHY.mjs";import{c as I,e as Y}from"./chunk-AV5SWEHP.mjs";import{g as U,h as H,i as B}from"./chunk-B5QQJ4SI.mjs";import"./chunk-NZC67CGR.mjs";import"./chunk-BOGNK4LV.mjs";import{b as L,c as P}from"./chunk-KDGMAGQR.mjs";import{B as W}from"./chunk-MFG4MUIO.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import{b as D,c as M}from"./chunk-HS4YRX4J.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import{fa as z,wa as J}from"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import{a as F}from"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import{a as j,h as R}from"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import{a as v,b as N,e as q,g as X}from"./chunk-MTMH6H2A.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-NTOVCTRS.mjs";var te=/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/,re=/^\d{4}-\d{2}-\d{2}$/,se=["CaseComment","EmailMessage","Asset","Contract","Case","Contact","Account"],ne=`sandforge cleanup \u2014 Bulk delete records you created on a sandbox in the
8
8
  --since window, whether or not a clone wrote them. Preview with --dry-run and
9
9
  narrow with --objects before deleting.
10
10
 
@@ -23,9 +23,11 @@ Options:
23
23
  --objects <a,b,c> Comma-separated object API names. Defaults to a
24
24
  whitelist of common Forge targets.
25
25
  --max <n> Max records to delete per object (default: 200).
26
+ Past it, the rest is left, named per object, and the
27
+ cleanup exits 3: run it again, or give a higher --max.
26
28
  --dry-run Print counts and what the target runs as they would
27
29
  go, don't delete.
28
- ${Q("deleted","--dry-run")} --json print per object the records found, deleted and
30
+ ${K("deleted","--dry-run")} --json print per object the records found, deleted and
29
31
  refused as JSON on stdout, every other line on stderr
30
32
  -h, --help Show this help.
31
33
 
@@ -46,11 +48,13 @@ or the cleanup was refused for what the target runs as it deletes, without
46
48
  --accept-emails (EMAILS_NOT_ACCEPTED), more emails than it has left today
47
49
  (EMAILS_EXCEEDED), or a mute refused \u2014 a --dry-run that saw a real run would be
48
50
  refused among them; 2 a bad command line; 3 the target refused to delete some
49
- of the records found.
50
- `,ne={switches:["--dry-run","--json",...X],values:["--target","--since","--objects","--max"]},E=1,oe=3;function ae(s){return` what ${s} deletes along with them (a contact's tasks, an account's contacts) goes too, uncounted, and runs none of its delete automation: Salesforce runs none on a record deleted with its parent`}function h(s){process.stderr.write(`${s}
51
- `),process.exit(2)}function ie(s){let n=s.slice(2);(n.includes("-h")||n.includes("--help"))&&(process.stdout.write(se),process.exit(0)),v(n,ne);let e=(d,A)=>{let c=n.indexOf(d);return c>=0&&c+1<n.length?n[c+1]:A},r=d=>n.includes(d),f=e("--target");f||h("Missing --target. Run with --help."),N.test(f)||h(`Invalid --target alias: ${f}. An sf alias or a username: letters, digits, _ . @ + and -, not starting with . @ + or -.`);let u=e("--objects"),w=u?u.split(",").map(d=>d.trim()).filter(Boolean):re;for(let d of w)try{S(d)}catch{h(`Invalid object name in --objects: ${d}`)}let y=e("--since","today")??"today",p="";try{p=de(y)}catch(d){h(d instanceof Error?d.message:`Invalid --since: ${y}`)}let g=e("--max","200")??"200",m=Number(g);return(!Number.isInteger(m)||m<=0)&&h(`Invalid --max: ${g}. Expected a whole number above 0.`),{target:f,since:y,sinceSoql:p,objects:w,max:m,dryRun:r("--dry-run"),json:r("--json"),accord:Z(n)}}function de(s){let n=s.toLowerCase();if(n==="today")return"TODAY";if(n==="yesterday")return"YESTERDAY";if(n==="this_week")return"THIS_WEEK";if(n==="last_week")return"LAST_WEEK";if(n.startsWith("last_n_days:")){let e=n.slice(12),r=Number(e);if(!/^\d+$/.test(e)||!Number.isInteger(r)||r<=0)throw new Error(`Invalid --since: ${s}`);return`LAST_N_DAYS:${r}`}if(te.test(s)){let e=new Date(`${s}T00:00:00Z`);if(!Number.isNaN(e.getTime())&&e.toISOString().startsWith(s))return`${s}T00:00:00Z`}throw new Error(`Invalid --since: ${s}. Allowed: today, yesterday, this_week, last_week, last_n_days:N, YYYY-MM-DD.`)}function ce(s,n,e,r){return`SELECT Id FROM ${S(s)} WHERE CreatedDate >= ${n} AND CreatedById = '${C(e)}' LIMIT ${r}`}var le=3;function ue(s){let n=new Set;for(let e of s)if(!e.success)for(let r of e.errors??[])n.add(typeof r=="string"?r:r.message??"refused");return[...n].slice(0,le)}function fe(s){return s.some(n=>n.error!==void 0)?E:s.some(n=>n.failed>0)?oe:0}async function ge(s=process.argv){let n=Date.now(),e=ie(s),r=t=>e.json?console.error(t):console.log(t);r(`sandforge cleanup target=${e.target} since=${e.since} ${e.dryRun?"DRY-RUN":"REAL"}`);let f=await M(e.target),u=L(f),w=e.dryRun?await T(u).then(x,()=>!0):!await P(u,e.target,{tool:"sandforge cleanup",action:"delete",readOnly:"--dry-run"}),p=(await u.query(`SELECT Id FROM User WHERE Username = '${C(f.username)}' LIMIT 1`)).records[0]?.Id??"";p||(console.error(`Could not resolve userId for ${f.username} on ${f.alias}.`),process.exit(1)),ee.test(p)||(console.error(`Invalid userId returned by org: ${p}`),process.exit(1)),r(`user: ${f.username} (${p})
52
- `);let g=[],m=new Map;for(let t of e.objects){let o={objectApiName:t,found:0,deleted:0,failed:0};g.push(o);try{let{records:i}=await k({query:async l=>u.query(l),queryMore:async l=>u.queryMore(l)},ce(t,e.sinceSoql,p,e.max)),a=i.map(l=>l.Id);o.found=a.length,a.length===0?r(` ${t.padEnd(40)} 0`):e.dryRun&&r(` ${t.padEnd(40)} ${a.length} [dry-run]`),a.length>0&&m.set(t,a)}catch(i){let a=i instanceof Error?i.message:String(i);if(a.includes("INVALID_TYPE")||a.includes("sObject type '")){o.notPresent=!0,r(` ${t.padEnd(40)} - (object not present on target)`);continue}o.error=a,r(` ${t.padEnd(40)} ERROR: ${a.slice(0,200)}`)}}let d=new z(B(async()=>u)),A=await H({act:"cleanup",target:e.target,objects:[...m].map(([t,o])=>({objectApiName:t,records:o.length})),org:W(u,t=>d.read(e.target,t),w),accord:e.accord,mayMute:!0}),c=A.answer;r("");for(let t of c.lines)r(t);m.size>0&&r(ae(e.target));let b;if(e.dryRun){for(let t of K(c))r(t);c.refusals.length>0&&(process.exitCode=E)}else if(c.refusals.length>0){for(let t of c.refusals)process.stderr.write(`${R(t)}
53
- `);m.clear(),process.exitCode=E}else{let t=await U(A,`sandforge-cleanup-${Date.now()}`,e.accord.acceptEmails===!0);"refused"in t?(process.stderr.write(`${R(t.refused)}
54
- `),m.clear(),process.exitCode=E):b=t.held}try{for(let t of g){let o=t.objectApiName,i=m.get(o);if(!(e.dryRun||!i))try{await V(o,i,t)}catch(a){let l=a instanceof Error?a.message:String(a);t.error=l,r(` ${o.padEnd(40)} ERROR: ${l.slice(0,200)}`)}}}finally{if(b){let t=await b.release();for(let o of F(t,e.target))r(` ${o}`)}}async function V(t,o,i){let a=await u.sobject(t).destroy(o,{allowRecursive:!0}),l=Array.isArray(a)?a:[a];i.deleted=l.filter(O=>O.success).length,i.failed=l.length-i.deleted;let I=ue(l);I.length>0&&(i.reasons=I);let G=i.failed>0?` \x1B[31m(${i.failed} failed)\x1B[0m`:"";r(` ${t.padEnd(40)} ${o.length} deleted ${i.deleted}${G}`);for(let O of I)r(` ${O.slice(0,200)}`)}let j=g.reduce((t,o)=>t+o.found,0),_=g.reduce((t,o)=>t+o.deleted,0),$=g.reduce((t,o)=>t+o.failed,0),D=Date.now()-n;if(q(fe(g)),e.json){process.stdout.write(`${JSON.stringify({tool:"sandforge-cleanup",target:e.target,since:e.since,condition:`CreatedDate >= ${e.sinceSoql}`,dryRun:e.dryRun,objects:g,automation:c,...e.dryRun?Y(c.refusals):{},...!e.dryRun&&c.refusals[0]?{refused:c.refusals[0]}:{},found:j,deleted:_,failed:$,elapsedMs:D},null,2)}
55
- `);return}console.log(`
56
- ${e.dryRun?"would delete":"deleted"} ${e.dryRun?j:_} record(s)${$>0?`, ${$} refused`:""} in ${D}ms`)}/sandforge-cleanup\.[cm]?[jt]s$/.test(process.argv[1]??"")&&(J(),ge().then(()=>process.exit(process.exitCode??0)).catch(s=>{console.error("FATAL:",s instanceof Error?s.stack:s),process.exit(1)}));export{ae as alongLine,fe as cleanupExitCode,ce as cleanupSoql,ge as main,de as sinceClause};
51
+ of the records found, or an object holds more than --max of them, the rest
52
+ left (with --dry-run too).
53
+ `,oe={switches:["--dry-run","--json",...Z],values:["--target","--since","--objects","--max"]},w=1,ae=3;function ie(n){return` what ${n} deletes along with them (a contact's tasks, an account's contacts) goes too, uncounted, and runs none of its delete automation: Salesforce runs none on a record deleted with its parent`}function h(n){process.stderr.write(`${n}
54
+ `),process.exit(2)}function de(n){let s=n.slice(2);(s.includes("-h")||s.includes("--help"))&&(process.stdout.write(ne),process.exit(0)),v(s,oe);let t=(c,b)=>{let l=s.indexOf(c);return l>=0&&l+1<s.length?s[l+1]:b},r=c=>s.includes(c),f=t("--target");f||h("Missing --target. Run with --help."),N.test(f)||h(`Invalid --target alias: ${f}. An sf alias or a username: letters, digits, _ . @ + and -, not starting with . @ + or -.`);let g=t("--objects"),y=g?g.split(",").map(c=>c.trim()).filter(Boolean):se;for(let c of y)try{R(c)}catch{h(`Invalid object name in --objects: ${c}`)}let A=t("--since","today")??"today",p="";try{p=ce(A)}catch(c){h(c instanceof Error?c.message:`Invalid --since: ${A}`)}let d=t("--max","200")??"200",m=Number(d);return(!Number.isInteger(m)||m<=0)&&h(`Invalid --max: ${d}. Expected a whole number above 0.`),{target:f,since:A,sinceSoql:p,objects:y,max:m,dryRun:r("--dry-run"),json:r("--json"),accord:Q(s)}}function ce(n){let s=n.toLowerCase();if(s==="today")return"TODAY";if(s==="yesterday")return"YESTERDAY";if(s==="this_week")return"THIS_WEEK";if(s==="last_week")return"LAST_WEEK";if(s.startsWith("last_n_days:")){let t=s.slice(12),r=Number(t);if(!/^\d+$/.test(t)||!Number.isInteger(r)||r<=0)throw new Error(`Invalid --since: ${n}`);return`LAST_N_DAYS:${r}`}if(re.test(n)){let t=new Date(`${n}T00:00:00Z`);if(!Number.isNaN(t.getTime())&&t.toISOString().startsWith(n))return`${n}T00:00:00Z`}throw new Error(`Invalid --since: ${n}. Allowed: today, yesterday, this_week, last_week, last_n_days:N, YYYY-MM-DD.`)}function le(n,s,t,r){return`SELECT Id FROM ${R(n)} WHERE CreatedDate >= ${s} AND CreatedById = '${j(t)}' LIMIT ${r}`}var ue=3;function fe(n){let s=new Set;for(let t of n)if(!t.success)for(let r of t.errors??[])s.add(typeof r=="string"?r:r.message??"refused");return[...s].slice(0,ue)}function ge(n){return n.some(s=>s.error!==void 0)?w:n.some(s=>s.failed>0||s.pastMax===!0)?ae:0}async function me(n=process.argv){let s=Date.now(),t=de(n),r=e=>t.json?console.error(e):console.log(e);r(`sandforge cleanup target=${t.target} since=${t.since} ${t.dryRun?"DRY-RUN":"REAL"}`);let f;try{f=await L(t.target)}catch(e){process.stderr.write(`${e instanceof Error?e.message:String(e)}
55
+ `),process.exit(w)}let g=P(f),y=t.dryRun?await D(g).then(M,()=>!0):!await k(g,t.target,{tool:"sandforge cleanup",action:"delete",readOnly:"--dry-run"}),p=(await g.query(`SELECT Id FROM User WHERE Username = '${j(f.username)}' LIMIT 1`)).records[0]?.Id??"";p||(console.error(`Could not resolve userId for ${f.username} on ${f.alias}.`),process.exit(1)),te.test(p)||(console.error(`Invalid userId returned by org: ${p}`),process.exit(1)),r(`user: ${f.username} (${p})
56
+ `);let d=[],m=new Map;for(let e of t.objects){let o={objectApiName:e,found:0,deleted:0,failed:0};d.push(o);try{let{records:i}=await F({query:async u=>g.query(u),queryMore:async u=>g.queryMore(u)},le(e,t.sinceSoql,p,t.max+1)),a=i.slice(0,t.max).map(u=>u.Id);i.length>t.max&&(o.pastMax=!0),o.found=a.length,a.length===0?r(` ${e.padEnd(40)} 0`):t.dryRun&&r(` ${e.padEnd(40)} ${a.length} [dry-run]`),a.length>0&&m.set(e,a),o.pastMax&&r(` ${e.padEnd(40)} more past --max ${t.max} left: run it again, or give a higher --max`)}catch(i){let a=i instanceof Error?i.message:String(i);if(a.includes("INVALID_TYPE")||a.includes("sObject type '")){o.notPresent=!0,r(` ${e.padEnd(40)} - (object not present on target)`);continue}o.error=a,r(` ${e.padEnd(40)} ERROR: ${a.slice(0,200)}`)}}let c=new J(z(async()=>g)),b=await B({act:"cleanup",target:t.target,objects:[...m].map(([e,o])=>({objectApiName:e,records:o.length})),org:U(g,e=>c.read(t.target,e),y),accord:t.accord,mayMute:!0}),l=b.answer;r("");for(let e of l.lines)r(e);m.size>0&&r(ie(t.target));let E;if(t.dryRun){for(let e of V(l))r(e);l.refusals.length>0&&(process.exitCode=w)}else if(l.refusals.length>0){for(let e of l.refusals)process.stderr.write(`${I(e)}
57
+ `);m.clear(),process.exitCode=w}else{let e=await H(b,`sandforge-cleanup-${Date.now()}`,t.accord.acceptEmails===!0);"refused"in e?(process.stderr.write(`${I(e.refused)}
58
+ `),m.clear(),process.exitCode=w):E=e.held}try{for(let e of d){let o=e.objectApiName,i=m.get(o);if(!(t.dryRun||!i))try{await G(o,i,e)}catch(a){let u=a instanceof Error?a.message:String(a);e.error=u,r(` ${o.padEnd(40)} ERROR: ${u.slice(0,200)}`)}}}finally{if(E){let e=await E.release();for(let o of W(e,t.target))r(` ${o}`)}}async function G(e,o,i){let a=await g.sobject(e).destroy(o,{allowRecursive:!0}),u=Array.isArray(a)?a:[a];i.deleted=u.filter(O=>O.success).length,i.failed=u.length-i.deleted;let x=fe(u);x.length>0&&(i.reasons=x);let ee=i.failed>0?` \x1B[31m(${i.failed} failed)\x1B[0m`:"";r(` ${e.padEnd(40)} ${o.length} deleted ${i.deleted}${ee}`);for(let O of x)r(` ${O.slice(0,200)}`)}let C=d.reduce((e,o)=>e+o.found,0),S=d.reduce((e,o)=>e+o.deleted,0),$=d.reduce((e,o)=>e+o.failed,0),T=Date.now()-s;if(q(ge(d)),t.json){process.stdout.write(`${JSON.stringify({tool:"sandforge-cleanup",target:t.target,since:t.since,condition:`CreatedDate >= ${t.sinceSoql}`,dryRun:t.dryRun,objects:d,automation:l,...t.dryRun?Y(l.refusals):{},...!t.dryRun&&l.refusals[0]?{refused:l.refusals[0]}:{},found:C,deleted:S,failed:$,...d.some(e=>e.pastMax===!0)?{pastMax:d.filter(e=>e.pastMax===!0).map(e=>e.objectApiName)}:{},elapsedMs:T},null,2)}
59
+ `);return}let _=d.filter(e=>e.pastMax===!0).length;console.log(`
60
+ ${t.dryRun?"would delete":"deleted"} ${t.dryRun?C:S} record(s)${$>0?`, ${$} refused`:""}${_>0?`; ${_} object(s) hold more past --max ${t.max}`:""} in ${T}ms`)}/sandforge-cleanup\.[cm]?[jt]s$/.test(process.argv[1]??"")&&(X(),me().then(()=>process.exit(process.exitCode??0)).catch(n=>{console.error("FATAL:",n instanceof Error?n.stack:n),process.exit(1)}));export{ie as alongLine,ge as cleanupExitCode,le as cleanupSoql,me as main,ce as sinceClause};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{$ as I,$a as Ia,A as h,Aa as ha,Ab as hb,B as i,Ba as ia,Bb as ib,C as j,Ca as ja,Cb as jb,D as k,Da as ka,Db as kb,E as l,Ea as la,Eb as lb,F as m,Fa as ma,Fb as mb,G as n,Ga as na,Gb as nb,H as o,Ha as oa,Hb as ob,I as p,Ia as pa,Ib as pb,J as q,Ja as qa,K as r,Ka as ra,L as s,La as sa,M as t,Ma as ta,N as u,Na as ua,O as v,Oa as va,P as w,Pa as wa,Q as x,Qa as xa,R as y,Ra as ya,S as z,Sa as za,T as A,Ta as Aa,U as B,Ua as Ba,V as C,Va as Ca,W as D,Wa as Da,X as E,Xa as Ea,Y as F,Ya as Fa,Z as G,Za as Ga,_ as H,_a as Ha,aa as J,ab as Ja,ba as K,bb as Ka,ca as L,cb as La,da as M,db as Ma,ea as N,eb as Na,fa as O,fb as Oa,ga as P,gb as Pa,ha as Q,hb as Qa,ia as R,ib as Ra,ja as S,jb as Sa,ka as T,kb as Ta,la as U,lb as Ua,ma as V,mb as Va,na as W,nb as Wa,oa as X,ob as Xa,pa as Y,pb as Ya,qa as Z,qb as Za,ra as _,rb as _a,sa as $,sb as $a,t as a,ta as aa,tb as ab,u as b,ua as ba,ub as bb,v as c,va as ca,vb as cb,w as d,wa as da,wb as db,x as e,xa as ea,xb as eb,y as f,ya as fa,yb as fb,z as g,za as ga,zb as gb}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"./chunk-SCKUIE3R.mjs";import"./chunk-QROPNEGY.mjs";import"./chunk-BZ24IAP5.mjs";import"./chunk-AV5SWEHP.mjs";import"./chunk-36U7IQ6Y.mjs";import"./chunk-XETCPL7E.mjs";import"./chunk-K2FBZIXY.mjs";import"./chunk-Z7X534S4.mjs";import"./chunk-6QSM2WIH.mjs";import"./chunk-WJY54JO7.mjs";import"./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"./chunk-L776PUMV.mjs";import"./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"./chunk-VXHDBYMI.mjs";import"./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"./chunk-CGWXQX75.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-SIOZXPFG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-MTMH6H2A.mjs";import"./chunk-B45CNPUX.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-SBIMVCXT.mjs";import"./chunk-NTOVCTRS.mjs";export{cb as CLONE_PREVIEW_UNREAD,lb as ROOT_NEVER_CREATED,Ja as SWEEP_CLASS_FLAGS,x as adaptDescribe,a as apiRequestsLine,v as auditDepsOf,Ea as automationHeldLines,G as choicesLines,t as cliRunSetup,Ia as cliSweepInput,T as cloneApiRequestsJson,i as cloneInputLine,h as cloneInputOf,db as clonePreviewJson,eb as clonePreviewLines,j as cloneSubjectOf,Qa as commandSweepTies,I as contactPointLines,fb as datedFromItsJournal,H as decisionLines,A as describeObjectInfo,z as describeOnce,S as discoveryRequestsLine,L as dryRunAdminChanges,$a as earlierOfTheRun,fa as executeOptions,B as failedOutright,w as fieldInfosOf,D as fileLines,da as graphCounts,P as graphLine,jb as interruptedLine,r as journalDirOf,Xa as journalPartsOf,M as jsonResult,ea as listedObjects,y as loadRecordTypes,ob as lostJobsBeforeTheMute,pb as main,Aa as maxTotalRefusal,J as neutralizedUpsertKeys,N as objectOutcomeLine,O as objectOutcomePrinter,Ga as otherPartIdsOf,Ya as otherPartsOf,Ha as otherPartsSweepLines,Pa as otherRunsOf,p as parseArgs,oa as parseRemoveArgs,sa as parseRunSummary,gb as parseVerifyArgs,Wa as partsLeft,va as partsLeftLines,xa as platformCopiesWords,la as productionRefusal,b as queryRootOf,wa as quoteCopiesLines,n as readChoicesFile,Ta as readEarlierRemovals,C as recordTypeGivenLines,na as rehearsalLines,ma as rehearsalPlanLines,za as removalLines,ta as removalPlan,ua as removalPlanLines,Ua as removalsAfter,_a as removalsOfParts,Ra as removalsPath,bb as removeMain,u as resumeRefusal,s as resumedJournalPath,mb as rootNeverCreatedRefusal,Va as runInPartsOf,Sa as runKey,pa as runMuteSchema,Za as runRemovalsAfter,ra as runSummaryOfFile,qa as runUserIdOf,o as sampleArgsOf,X as sampleBudgetOf,Z as sampleJson,Y as sampleLines,aa as sampleReadsLine,ca as sampleRefusalExit,_ as sampleResultJson,$ as sampleResultLines,ba as samplingProgressPrinter,F as simulationGapLines,E as summaryLines,Ka as sweepClassArgsOf,La as sweepClassOptions,Fa as sweepLines,Ca as sweepListingLines,Ba as sweepOptionWords,Na as sweepOrgOf,Ma as sweepPartsOptions,Da as sweepUnsaid,Oa as syncRunSpanOf,g as tablesExecuteOptions,d as tablesLeftOut,e as tablesNotReached,c as tablesQueryOf,f as tablesRunConfig,ia as targetAutomationReader,ja as targetGapReader,ya as tookAlongLines,ka as typeOrg,q as uncertainRefusal,K as upsertKeyLines,hb as verificationLines,ib as verifyMain,R as wholeOrgGateLines,Q as wholeOrgGraphLine,m as wholeOrgGraphOf,W as wholeOrgMaxTotalRefusal,l as wholeOrgOptions,U as wholeOrgQuestionWords,V as wholeOrgRefusalWords,k as wholeOrgRunConfig,kb as wholeOrgSweepLine,nb as wholeOrgWriteDeps,ha as withTemplateFields,ga as withTheJournal,ab as writeWhole};
7
+ import{$ as I,$a as Ia,A as h,Aa as ha,Ab as hb,B as i,Ba as ia,Bb as ib,C as j,Ca as ja,Cb as jb,D as k,Da as ka,Db as kb,E as l,Ea as la,Eb as lb,F as m,Fa as ma,Fb as mb,G as n,Ga as na,Gb as nb,H as o,Ha as oa,Hb as ob,I as p,Ia as pa,Ib as pb,J as q,Ja as qa,Jb as qb,K as r,Ka as ra,Kb as rb,L as s,La as sa,Lb as sb,M as t,Ma as ta,Mb as tb,N as u,Na as ua,Nb as ub,O as v,Oa as va,Ob as vb,P as w,Pa as wa,Pb as wb,Q as x,Qa as xa,Qb as xb,R as y,Ra as ya,Rb as yb,S as z,Sa as za,Sb as zb,T as A,Ta as Aa,Tb as Ab,U as B,Ua as Ba,Ub as Bb,V as C,Va as Ca,Vb as Cb,W as D,Wa as Da,Wb as Db,X as E,Xa as Ea,Xb as Eb,Y as F,Ya as Fa,Yb as Fb,Z as G,Za as Ga,_ as H,_a as Ha,aa as J,ab as Ja,ba as K,bb as Ka,ca as L,cb as La,da as M,db as Ma,ea as N,eb as Na,fa as O,fb as Oa,ga as P,gb as Pa,ha as Q,hb as Qa,ia as R,ib as Ra,ja as S,jb as Sa,ka as T,kb as Ta,la as U,lb as Ua,ma as V,mb as Va,na as W,nb as Wa,oa as X,ob as Xa,pa as Y,pb as Ya,qa as Z,qb as Za,ra as _,rb as _a,sa as $,sb as $a,t as a,ta as aa,tb as ab,u as b,ua as ba,ub as bb,v as c,va as ca,vb as cb,w as d,wa as da,wb as db,x as e,xa as ea,xb as eb,y as f,ya as fa,yb as fb,z as g,za as ga,zb as gb}from"./chunk-VS7ZXUII.mjs";import"./chunk-SOU4FRYN.mjs";import"./chunk-E5AHXLS6.mjs";import"./chunk-OO6CLPEH.mjs";import"./chunk-YS4G22C2.mjs";import"./chunk-QROPNEGY.mjs";import"./chunk-BZ24IAP5.mjs";import"./chunk-SCKUIE3R.mjs";import"./chunk-AV5SWEHP.mjs";import"./chunk-4VS2V6WU.mjs";import"./chunk-KYEDBS54.mjs";import"./chunk-6XYKJSGX.mjs";import"./chunk-K2FBZIXY.mjs";import"./chunk-F43REJDZ.mjs";import"./chunk-JPUR2CFX.mjs";import"./chunk-LPBMBW3O.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-IFETCRWE.mjs";import"./chunk-PZPJKATS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-DYFALGRT.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-7FFGJWHN.mjs";import"./chunk-G35N4P7D.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-KDGMAGQR.mjs";import"./chunk-MFG4MUIO.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-HS4YRX4J.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-MTMH6H2A.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-NTOVCTRS.mjs";export{qb as CLONE_PREVIEW_UNREAD,J as FIELD_EXCLUSION_UNMATCHED,zb as ROOT_NEVER_CREATED,Xa as SWEEP_CLASS_FLAGS,Ab as TABLE_NEVER_CLONED,C as adaptDescribe,a as apiRequestsLine,A as auditDepsOf,Sa as automationHeldLines,R as choicesLines,x as cliRunSetup,Wa as cliSweepInput,ca as cloneApiRequestsJson,m as cloneInputLine,l as cloneInputOf,rb as clonePreviewJson,sb as clonePreviewLines,n as cloneSubjectOf,cb as commandSweepTies,T as contactPointLines,tb as datedFromItsJournal,S as decisionLines,F as describeObjectInfo,E as describeOnce,ba as discoveryRequestsLine,W as dryRunAdminChanges,nb as earlierOfTheRun,Fb as endOfAThrow,ra as executeOptions,G as failedOutright,K as fieldExclusionUnmatchedWords,L as fieldExclusionsUnmatchedLines,N as fieldExclusionsUnmatchedOf,M as fieldExclusionsUnmatchedRefusal,B as fieldInfosOf,I as fileLines,oa as graphCounts,_ as graphLine,xb as interruptedLine,v as journalDirOf,Fa as journalGoneWords,jb as journalPartsOf,X as jsonResult,qa as listedObjects,D as loadRecordTypes,Db as lostJobsBeforeTheMute,Eb as main,Oa as maxTotalRefusal,i as missingFlagsWords,U as neutralizedUpsertKeys,f as neverClonedTableRefusal,pa as notCountedObjectsOf,Y as objectOutcomeLine,Z as objectOutcomePrinter,O as orphanParentsCappedLine,Ua as otherPartIdsOf,kb as otherPartsOf,Va as otherPartsSweepLines,bb as otherRunsOf,t as parseArgs,Aa as parseRemoveArgs,Ga as parseRunSummary,ub as parseVerifyArgs,ib as partsLeft,Ja as partsLeftLines,La as platformCopiesWords,xa as productionRefusal,b as queryRootOf,Ka as quoteCopiesLines,r as readChoicesFile,fb as readEarlierRemovals,H as recordTypeGivenLines,za as rehearsalLines,ya as rehearsalPlanLines,Na as removalLines,Ha as removalPlan,Ia as removalPlanLines,gb as removalsAfter,mb as removalsOfParts,db as removalsPath,pb as removeMain,z as resumeChangedWords,y as resumeRefusal,w as resumedJournalPath,Bb as rootNeverCreatedRefusal,hb as runInPartsOf,eb as runKey,Ca as runMuteSchema,lb as runRemovalsAfter,Ea as runSummaryOfFile,Da as runUserIdOf,s as sampleArgsOf,ga as sampleBudgetOf,ia as sampleJson,ha as sampleLines,la as sampleReadsLine,na as sampleRefusalExit,ja as sampleResultJson,ka as sampleResultLines,ma as samplingProgressPrinter,Q as simulationGapLines,P as summaryLines,Ya as sweepClassArgsOf,Za as sweepClassOptions,Ta as sweepLines,Qa as sweepListingLines,Pa as sweepOptionWords,$a as sweepOrgOf,_a as sweepPartsOptions,Ra as sweepUnsaid,Ba as sweepUserHint,ab as syncRunSpanOf,k as tablesExecuteOptions,d as tablesLeftOut,e as tablesNotReached,g as tablesNotReachedWords,c as tablesQueryOf,j as tablesRunConfig,ua as targetAutomationReader,va as targetGapReader,h as templateWithoutInputWords,Ma as tookAlongLines,wa as typeOrg,u as uncertainRefusal,V as upsertKeyLines,vb as verificationLines,wb as verifyMain,aa as wholeOrgGateLines,$ as wholeOrgGraphLine,q as wholeOrgGraphOf,fa as wholeOrgMaxTotalRefusal,p as wholeOrgOptions,da as wholeOrgQuestionWords,ea as wholeOrgRefusalWords,o as wholeOrgRunConfig,yb as wholeOrgSweepLine,Cb as wholeOrgWriteDeps,ta as withTemplateFields,sa as withTheJournal,ob as writeWhole};
@@ -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{e as x}from"./chunk-TNXUU6W7.mjs";import"./chunk-IC2C2GOF.mjs";import"./chunk-VGW4MXXZ.mjs";import"./chunk-JVL444U5.mjs";import"./chunk-KLX67VPL.mjs";import"./chunk-5CD257T7.mjs";import"./chunk-5AJRHRXA.mjs";import"./chunk-42RER7V4.mjs";import"./chunk-LRFAIUN7.mjs";import"./chunk-OQOZAPCI.mjs";import"./chunk-RSYICMZG.mjs";import"./chunk-IAZB4WIL.mjs";import"./chunk-FQGHL7GR.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{b,c as E}from"./chunk-I7O6C2B5.mjs";import"./chunk-4GL773D5.mjs";import"./chunk-SRQDABQ2.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LV6G4XTK.mjs";import"./chunk-HJKM3E56.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-YMJVMFPY.mjs";import"./chunk-ALJVEUUS.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-4HFRHFGQ.mjs";import"./chunk-342FN7AO.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-36U7IQ6Y.mjs";import"./chunk-XETCPL7E.mjs";import"./chunk-K2FBZIXY.mjs";import"./chunk-Z7X534S4.mjs";import"./chunk-6QSM2WIH.mjs";import"./chunk-WJY54JO7.mjs";import"./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"./chunk-L776PUMV.mjs";import"./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"./chunk-VXHDBYMI.mjs";import"./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"./chunk-CGWXQX75.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-SIOZXPFG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import{a as T,e as O,g as R}from"./chunk-MTMH6H2A.mjs";import{hb as h,ib as $,jb as v,kb as w}from"./chunk-B45CNPUX.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-SBIMVCXT.mjs";import"./chunk-NTOVCTRS.mjs";var L=`sandforge compare \u2014 compare two orgs the way the Compare page does, without the editor.
7
+ import{f as A}from"./chunk-3F6Q5E7I.mjs";import"./chunk-IC2C2GOF.mjs";import"./chunk-VGW4MXXZ.mjs";import"./chunk-2BA2XKAY.mjs";import"./chunk-OAZRPP4I.mjs";import"./chunk-JEERQRLW.mjs";import"./chunk-HOJYWTP7.mjs";import"./chunk-R3X3LV64.mjs";import"./chunk-E5ZB3LU5.mjs";import"./chunk-EFR2Y7E4.mjs";import"./chunk-O2HDYYUV.mjs";import"./chunk-M3ROUWDX.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-ZM6OJGIG.mjs";import"./chunk-MHMH6MTP.mjs";import"./chunk-COFG7Q6R.mjs";import"./chunk-GMY5427L.mjs";import"./chunk-PJ5I73CK.mjs";import"./chunk-BKDV4ENO.mjs";import"./chunk-X5JYBPXP.mjs";import{b as C,c as E}from"./chunk-I7O6C2B5.mjs";import"./chunk-YRQGKDHM.mjs";import"./chunk-MJU2PGZQ.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LWW4U276.mjs";import"./chunk-MJVTDA5Q.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-2CNCDM56.mjs";import"./chunk-SIHORWVK.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-B5QQJ4SI.mjs";import"./chunk-NZC67CGR.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-4VS2V6WU.mjs";import"./chunk-KYEDBS54.mjs";import"./chunk-6XYKJSGX.mjs";import"./chunk-K2FBZIXY.mjs";import"./chunk-F43REJDZ.mjs";import"./chunk-JPUR2CFX.mjs";import"./chunk-LPBMBW3O.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-IFETCRWE.mjs";import"./chunk-PZPJKATS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-DYFALGRT.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-7FFGJWHN.mjs";import"./chunk-G35N4P7D.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-KDGMAGQR.mjs";import"./chunk-MFG4MUIO.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-HS4YRX4J.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import{a as O,e as R,g as b}from"./chunk-MTMH6H2A.mjs";import{kb as h,lb as $,mb as T,nb as v}from"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-NTOVCTRS.mjs";var L=`sandforge compare \u2014 compare two orgs the way the Compare page does, without the editor.
8
8
 
9
9
  Usage:
10
10
  npx sandforge compare --source <alias> --target <alias> [options]
@@ -39,16 +39,17 @@ Options:
39
39
 
40
40
  Nothing is written to either org. A validation deploys check-only: the
41
41
  target compiles the components and runs the tests, keeps none of them, and
42
- lists the validation in Setup \u203A Deployment Status. This tool never deploys.
42
+ lists the validation in Setup \u203A Deployment Status. This tool never deploys:
43
+ the Deploy tab of the Compare page does, in VS Code.
43
44
 
44
45
  Exit codes: 0 every request was answered, and every validation succeeded (a
45
46
  diff is read, whatever it found, unless --fail-on-drift); 1 it could not
46
47
  start, or a request failed, was refused or was not answered in time; 2 a bad
47
48
  command line; 3 a validation came back with no success, a component error or
48
49
  a failed test, or --fail-on-drift and a diff found differences.
49
- `,C=["execute","permissions","snapshots","drift","validate-deployment"],_=["execute","permissions","snapshots","drift"],S=["CustomObject","CustomField","RecordType","ApexClass","ApexTrigger","LightningComponentBundle","Flow","WorkflowRule","ValidationRule","Profile","PermissionSet","Layout","CustomLabel","CustomMetadata","StaticResource","EmailTemplate","Report","Dashboard"],k=5*6e4,I=(2*$.retrieve+$.deploy+1)*6e4,j={switches:["--all-types","--exclude-managed","--json","--fail-on-drift"],values:["--source","--target","--op","--type","--validate","--tests","--run-test","--store","--wait"]};function V(t){let e=t.slice(2);(e.includes("--help")||e.includes("-h"))&&(process.stdout.write(L),process.exit(0)),T(e,j);let n=(l,g)=>{let p=e.indexOf(l);return p>=0&&p+1<e.length?e[p+1]:g},s=l=>{let g=[];for(let p=0;p<e.length;p++)e[p]===l&&p+1<e.length&&g.push(e[p+1]);return g},r=l=>{process.stderr.write(`${l}
50
- `),process.exit(2)},o=n("--source"),d=n("--target");(!o||!d)&&r("Missing --source or --target. Run with --help."),o===d&&r("--source and --target name the same org.");let a=s("--op");for(let l of a)C.includes(l)||r(`Not an operation: "${l}". One of: ${C.join(", ")}.`);let i=F(s,n,r),c=a.length>0?[...new Set(a)]:i.components.length>0?["validate-deployment"]:[..._];c.includes("validate-deployment")&&i.components.length===0&&r("validate-deployment needs a component: give --validate Type:Name.");let u=s("--type");for(let l of u)S.includes(l)||r(`Not a category the page offers: "${l}".`);let m=e.includes("--all-types")?[...S]:[...new Set(u)];c.includes("execute")&&m.length===0&&r("execute needs a category: give --type or --all-types, or leave execute out with --op.");let P=n("--wait","300")??"300",y=Number(P);return(!Number.isInteger(y)||y<1)&&r("--wait takes a whole number of seconds."),{source:o,target:d,operations:c,types:m,includeManaged:!e.includes("--exclude-managed"),validation:i,storeDir:n("--store")??b("compare"),waitMs:y*1e3,json:e.includes("--json"),failOnDrift:e.includes("--fail-on-drift")}}function F(t,e,n){let s=[];for(let a of t("--validate")){let i=a.indexOf(":"),c=a.slice(0,i),u=a.slice(i+1);(i<1||u==="")&&n(`--validate takes Type:Name, got "${a}".`),w.includes(c)||n(`Not a type a deployment carries: "${c}".`),s.push({componentType:c,fullName:u})}let r=e("--tests","NoTestRun")??"NoTestRun";h.includes(r)||n(`Not a test level: "${r}". One of: ${h.join(", ")}.`);let o=r,d=t("--run-test");for(let a of d)v.test(a)||n(`Not an Apex class name: "${a}".`);return o==="RunSpecifiedTests"&&d.length===0&&n("RunSpecifiedTests needs a test class: give --run-test."),o!=="RunSpecifiedTests"&&d.length>0&&n("--run-test names the tests of --tests RunSpecifiedTests only."),{components:s,testLevel:o,runTests:d}}function B(t){let{counts:e}=t,n=[` ${t.checkOnly?"validation":"deployment"} ${t.deployId??"(none sent)"}: ${t.status}, ${t.success?"success":"no success"}`+(t.errorMessage?` \u2014 ${t.errorMessage}`:""),` components: ${e.componentsDeployed} of ${e.componentsTotal} without an error, ${e.componentErrors} with one; tests (${t.testLevel}${t.runTests.length>0?`: ${t.runTests.join(", ")}`:""}): ${e.testsCompleted} of ${e.testsTotal} passed, ${e.testErrors} failed`];for(let s of t.components){let r=s.line!==void 0?` (line ${s.line}${s.column!==void 0?`, column ${s.column}`:""})`:"",o=s.problem?` \u2014 ${s.problem}${r}`:"";n.push(` ${s.outcome.padEnd(13)} ${s.componentType} ${s.fullName}${o}`)}for(let s of t.testFailures){let r=s.methodName?`${s.className}.${s.methodName}`:s.className,o=s.line!==void 0?` (line ${s.line})`:"";n.push(` test failed ${r}${o} \u2014 ${s.message}`)}for(let s of t.coverageWarnings)n.push(` coverage ${s}`);for(let s of t.retrieveProblems??[])n.push(` source said ${s}`);return n}function U(t){let e=new Map;for(let n of t){if(n.status!=="modified")continue;let s=e.get(n.componentType)??[];s.push(n.fullName),e.set(n.componentType,s)}return e}function q(t){let{content:e,summary:n}=t,s=n.modified+n.unchanged+n.notCompared,{over_budget:r,unreadable:o,read_failed:d}=e.notCompared,a=e.managedLeftOut?`; left out, as asked: ${e.managedLeftOut} installed by a managed package`:"";return` content compared for ${e.compared} of ${s} in both orgs; not compared: ${r} over the budget (${e.budget.components} per org, ${e.budget.seconds} s), ${o} unreadable, ${d} read failed${a}`}function W(t){let{summary:e}=t,n=[` mode ${t.mode}, ${e.totalItems} item(s): +${e.added} added -${e.removed} removed ~${e.modified} modified =${e.unchanged} unchanged ?${e.notCompared} not compared`],s=new Map;for(let r of t.diffs){let o=s.get(r.componentType)??{};o[r.status]=(o[r.status]??0)+1,s.set(r.componentType,o)}for(let[r,o]of s){let d=(o.modified??0)+(o.unchanged??0)+(o.not_compared??0),a=(o.removed??0)+d,i=(o.added??0)+d;n.push(` ${r.padEnd(26)} source ${String(a).padStart(5)} target ${String(i).padStart(5)} +${o.added??0} -${o.removed??0} ~${o.modified??0} =${o.unchanged??0} ?${o.not_compared??0}`)}n.push(q(t));for(let[r,o]of U(t.diffs))n.push(` modified ${r}: ${f(o)}`);return n}function f(t,e=8){if(t.length===0)return"\u2014";let n=t.slice(0,e).join(", ");return t.length>e?`${n} \u2026 (+${t.length-e})`:n}function N(t,e){let n=(e.sourceOnly??[]).map(r=>r.name),s=(e.targetOnly??[]).map(r=>r.name);return[` ${t}: ${n.length} source only, ${s.length} target only, ${(e.shared??[]).length} in both`,` source only: ${f(n)}`,` target only: ${f(s)}`]}function Y(t,e){let n=`${(e.elapsedMs/1e3).toFixed(1)}s`,s=`compare:${t} ${e.outcome} in ${n}`,r=[e.late?`${s} \u2014 past the page's timeout: the page dropped it`:s],o=e.message?.payload??{};if(e.outcome!=="answered")return e.message&&r.push(` ${String(o.message??JSON.stringify(o))}`),r;if(t==="execute")return[...r,...W(o)];if(t==="validate-deployment"){let a=o.report;return a?[...r,...B(a)]:[...r," (no report)"]}if(t==="permissions"){let a=o.permissions??{};return[...r,...N("permission sets",a.permissionSets??{}),...N("profiles",a.profiles??{})]}if(t==="snapshots"){let a=o.snapshot??{},i=c=>c?`${c.totalObjects} objects (${c.customObjects} custom, ${c.standardObjects} standard, ${c.queryableObjects} queryable)`:"\u2014";return[...r,` source: ${i(a.source)}`,` target: ${i(a.target)}`,` ${a.diff?.sharedCount??0} in both; source only: ${f(a.diff?.sourceOnly??[])}`,` target only: ${f(a.diff?.targetOnly??[])}`]}let d=o.drift??{};return[...r,...(d.items??[]).map(a=>` ${a.status.padEnd(14)} ${a.setting}: ${a.sourceValue} | ${a.targetValue}`)]}function G(t,e=!1){if(t.some(({answer:o})=>o.outcome!=="answered"))return 1;let n=o=>o.message?.payload??{};if(t.some(({op:o,answer:d})=>{if(o!=="validate-deployment")return!1;let a=n(d).report;return a===void 0||!a.success||a.counts.componentErrors>0||a.counts.testErrors>0}))return 3;let r=t.some(({op:o,answer:d})=>{if(o!=="execute")return!1;let a=n(d).summary;return a!==void 0&&a.added+a.removed+a.modified>0});return e&&r?3:0}async function X(t=process.argv){let e=V(t),n=i=>{process[e.json?"stderr":"stdout"].write(`${i}
51
- `)},s=E(e.storeDir);if(s!==void 0){process.stderr.write(`${s}
52
- `),process.exitCode=1;return}let r=x({storeDir:e.storeDir,log:i=>{/^\s*!|\[(ERR|WARN)\]/.test(i)&&n(i)},waitMs:e.waitMs}),o=await r.connect(e.source),d=await r.connect(e.target);n(`sandforge compare ${e.source} (${o.orgType}) -> ${e.target} (${d.orgType})`);let a=[];for(let i of e.operations){let c={sourceOrgId:o.id,targetOrgId:d.id};i==="execute"&&(c.types=e.types,c.includeManaged=e.includeManaged),i==="validate-deployment"&&(c.components=e.validation.components,c.testLevel=e.validation.testLevel,e.validation.testLevel==="RunSpecifiedTests"&&(c.runTests=e.validation.runTests));let u=await r.request({type:`compare:${i}`,payload:c,...i==="execute"?{timeoutMs:k}:{},...i==="validate-deployment"?{timeoutMs:I}:{}});a.push({op:i,answer:u});for(let m of Y(i,u))n(m)}e.json&&process.stdout.write(`${JSON.stringify({tool:"sandforge-compare",results:a,posted:r.posted},null,2)}
53
- `),O(G(a,e.failOnDrift))}process.argv[1]?.includes("sandforge-compare")&&(R(),X().then(()=>process.exit(process.exitCode??0)).catch(t=>{process.stderr.write(`${t instanceof Error?t.message:String(t)}
54
- `),process.exit(1)}));export{S as PAGE_COMPONENT_TYPES,G as compareExitCode,Y as describeAnswer,q as describeCoverage,B as describeDeployment,X as main,U as modifiedByType,V as parseArgs};
50
+ `,N=["execute","permissions","snapshots","drift","validate-deployment"],_=["execute","permissions","snapshots","drift"],w=["CustomObject","CustomField","RecordType","ApexClass","ApexTrigger","LightningComponentBundle","Flow","WorkflowRule","ValidationRule","Profile","PermissionSet","Layout","CustomLabel","CustomMetadata","StaticResource","EmailTemplate","Report","Dashboard"],j=5*6e4,I=(2*$.retrieve+$.deploy+1)*6e4,V={switches:["--all-types","--exclude-managed","--json","--fail-on-drift"],values:["--source","--target","--op","--type","--validate","--tests","--run-test","--store","--wait"]};function F(t){let e=t.slice(2);(e.includes("--help")||e.includes("-h"))&&(process.stdout.write(L),process.exit(0)),O(e,V);let a=(l,g)=>{let p=e.indexOf(l);return p>=0&&p+1<e.length?e[p+1]:g},r=l=>{let g=[];for(let p=0;p<e.length;p++)e[p]===l&&p+1<e.length&&g.push(e[p+1]);return g},n=l=>{process.stderr.write(`${l}
51
+ `),process.exit(2)},o=a("--source"),d=a("--target");(!o||!d)&&n("Missing --source or --target. Run with --help."),o===d&&n("--source and --target name the same org.");let s=r("--op");for(let l of s)l==="deploy"&&n("This tool never deploys: once a validation succeeds (--validate), the Deploy tab of the Compare page deploys it, in VS Code."),N.includes(l)||n(`Not an operation: "${l}". One of: ${N.join(", ")}.`);let i=B(r,a,n),c=s.length>0?[...new Set(s)]:i.components.length>0?["validate-deployment"]:[..._];c.includes("validate-deployment")&&i.components.length===0&&n("validate-deployment needs a component: give --validate Type:Name.");let u=r("--type");for(let l of u)w.includes(l)||n(`Not a category the page offers: "${l}". One of: ${w.join(", ")}.`);let f=e.includes("--all-types")?[...w]:[...new Set(u)];c.includes("execute")&&f.length===0&&n("execute needs a category: give --type or --all-types, or leave execute out with --op.");let P=a("--wait","300")??"300",y=Number(P);return(!Number.isInteger(y)||y<1)&&n("--wait takes a whole number of seconds."),{source:o,target:d,operations:c,types:f,includeManaged:!e.includes("--exclude-managed"),validation:i,storeDir:a("--store")??C("compare"),waitMs:y*1e3,json:e.includes("--json"),failOnDrift:e.includes("--fail-on-drift")}}function B(t,e,a){let r=[];for(let s of t("--validate")){let i=s.indexOf(":"),c=s.slice(0,i),u=s.slice(i+1);(i<1||u==="")&&a(`--validate takes Type:Name, got "${s}".`),v.includes(c)||a(`Not a type a deployment carries: "${c}". One of: ${v.join(", ")}.`),r.push({componentType:c,fullName:u})}let n=e("--tests","NoTestRun")??"NoTestRun";h.includes(n)||a(`Not a test level: "${n}". One of: ${h.join(", ")}.`);let o=n,d=t("--run-test");for(let s of d)T.test(s)||a(`Not an Apex class name: "${s}".`);return o==="RunSpecifiedTests"&&d.length===0&&a("RunSpecifiedTests needs a test class: give --run-test."),o!=="RunSpecifiedTests"&&d.length>0&&a("--run-test names the tests of --tests RunSpecifiedTests only."),{components:r,testLevel:o,runTests:d}}function U(t){let{counts:e}=t,a=[` ${t.checkOnly?"validation":"deployment"} ${t.deployId??"(none sent)"}: ${t.status}, ${t.success?"success":"no success"}`+(t.errorMessage?` \u2014 ${t.errorMessage}`:""),` components: ${e.componentsDeployed} of ${e.componentsTotal} without an error, ${e.componentErrors} with one; tests (${t.testLevel}${t.runTests.length>0?`: ${t.runTests.join(", ")}`:""}): ${e.testsCompleted} of ${e.testsTotal} passed, ${e.testErrors} failed`];for(let r of t.components){let n=r.line!==void 0?` (line ${r.line}${r.column!==void 0?`, column ${r.column}`:""})`:"",o=r.problem?` \u2014 ${r.problem}${n}`:"";a.push(` ${r.outcome.padEnd(13)} ${r.componentType} ${r.fullName}${o}`)}for(let r of t.testFailures){let n=r.methodName?`${r.className}.${r.methodName}`:r.className,o=r.line!==void 0?` (line ${r.line})`:"";a.push(` test failed ${n}${o} \u2014 ${r.message}`)}for(let r of t.coverageWarnings)a.push(` coverage ${r}`);for(let r of t.retrieveProblems??[])a.push(` source said ${r}`);return a}function q(t){let e=new Map;for(let a of t){if(a.status!=="modified")continue;let r=e.get(a.componentType)??[];r.push(a.fullName),e.set(a.componentType,r)}return e}function G(t){let{content:e,summary:a}=t,r=a.modified+a.unchanged+a.notCompared,{over_budget:n,unreadable:o,read_failed:d}=e.notCompared,s=e.managedLeftOut?`; left out, as asked: ${e.managedLeftOut} installed by a managed package`:"";return` content compared for ${e.compared} of ${r} in both orgs; not compared: ${n} over the budget (${e.budget.components} per org, ${e.budget.seconds} s), ${o} unreadable, ${d} read failed${s}`}function W(t){let{summary:e}=t,a=[` mode ${t.mode}, ${e.totalItems} item(s): +${e.added} added -${e.removed} removed ~${e.modified} modified =${e.unchanged} unchanged ?${e.notCompared} not compared`],r=new Map;for(let n of t.diffs){let o=r.get(n.componentType)??{};o[n.status]=(o[n.status]??0)+1,r.set(n.componentType,o)}for(let[n,o]of r){let d=(o.modified??0)+(o.unchanged??0)+(o.not_compared??0),s=(o.removed??0)+d,i=(o.added??0)+d;a.push(` ${n.padEnd(26)} source ${String(s).padStart(5)} target ${String(i).padStart(5)} +${o.added??0} -${o.removed??0} ~${o.modified??0} =${o.unchanged??0} ?${o.not_compared??0}`)}a.push(G(t));for(let[n,o]of q(t.diffs))a.push(` modified ${n}: ${m(o)}`);return a}function m(t,e=8){if(t.length===0)return"\u2014";let a=t.slice(0,e).join(", ");return t.length>e?`${a} \u2026 (+${t.length-e})`:a}function S(t,e){let a=(e.sourceOnly??[]).map(n=>n.name),r=(e.targetOnly??[]).map(n=>n.name);return[` ${t}: ${a.length} source only, ${r.length} target only, ${(e.shared??[]).length} in both`,` source only: ${m(a)}`,` target only: ${m(r)}`]}function Y(t){return t.code!=="MANAGED"||!Array.isArray(t.managed)?[]:t.managed.filter(e=>typeof e=="object"&&e!==null&&typeof e.componentType=="string"&&typeof e.fullName=="string")}function M(t){return t.success&&t.counts.componentErrors===0&&t.counts.testErrors===0}function X(t,e){let a=`${(e.elapsedMs/1e3).toFixed(1)}s`,r=`compare:${t} ${e.outcome} in ${a}`,n=[e.late?`${r} \u2014 past the page's timeout: the page dropped it`:r],o=e.message?.payload??{};if(e.outcome!=="answered"){let s=Y(o);return s.length>0?(n.push(` a managed package installed ${s.map(i=>`${i.componentType} ${i.fullName}`).join(", ")} in the source, and it owns them: drop `+s.map(i=>`--validate ${i.componentType}:${i.fullName}`).join(" ")+" from the line and run it again. Nothing was sent to the target."),n):(e.message&&n.push(` ${String(o.message??JSON.stringify(o))}`),e.outcome==="unanswered"&&n.push(` nothing came back in ${Math.round(e.elapsedMs/1e3)} s: give a longer --wait`+(t==="execute"?", or fewer --type":"")),n)}if(t==="execute")return[...n,...W(o)];if(t==="validate-deployment"){let s=o.report;return s?[...n,...U(s),...M(s)?[" this tool never deploys: the Deploy tab of the Compare page deploys it, in VS Code"]:[]]:[...n," (no report)"]}if(t==="permissions"){let s=o.permissions??{};return[...n,...S("permission sets",s.permissionSets??{}),...S("profiles",s.profiles??{})]}if(t==="snapshots"){let s=o.snapshot??{},i=c=>c?`${c.totalObjects} objects (${c.customObjects} custom, ${c.standardObjects} standard, ${c.queryableObjects} queryable)`:"\u2014";return[...n,` source: ${i(s.source)}`,` target: ${i(s.target)}`,` ${s.diff?.sharedCount??0} in both; source only: ${m(s.diff?.sourceOnly??[])}`,` target only: ${m(s.diff?.targetOnly??[])}`]}let d=o.drift??{};return[...n,...(d.items??[]).map(s=>` ${s.status.padEnd(14)} ${s.setting}: ${s.sourceValue} | ${s.targetValue}`)]}function H(t,e=!1){if(t.some(({answer:o})=>o.outcome!=="answered"))return 1;let a=o=>o.message?.payload??{};if(t.some(({op:o,answer:d})=>{if(o!=="validate-deployment")return!1;let s=a(d).report;return s===void 0||!M(s)}))return 3;let n=t.some(({op:o,answer:d})=>{if(o!=="execute")return!1;let s=a(d).summary;return s!==void 0&&s.added+s.removed+s.modified>0});return e&&n?3:0}async function J(t=process.argv){let e=F(t),a=i=>{process[e.json?"stderr":"stdout"].write(`${i}
52
+ `)},r=E(e.storeDir);if(r!==void 0){process.stderr.write(`${r}
53
+ `),process.exitCode=1;return}let n=A({storeDir:e.storeDir,log:i=>{/^\s*!|\[(ERR|WARN)\]/.test(i)&&a(i)},waitMs:e.waitMs}),o=await n.connect(e.source),d=await n.connect(e.target);a(`sandforge compare ${e.source} (${o.orgType}) -> ${e.target} (${d.orgType})`);let s=[];for(let i of e.operations){let c={sourceOrgId:o.id,targetOrgId:d.id};i==="execute"&&(c.types=e.types,c.includeManaged=e.includeManaged),i==="validate-deployment"&&(c.components=e.validation.components,c.testLevel=e.validation.testLevel,e.validation.testLevel==="RunSpecifiedTests"&&(c.runTests=e.validation.runTests));let u=await n.request({type:`compare:${i}`,payload:c,...i==="execute"?{timeoutMs:j}:{},...i==="validate-deployment"?{timeoutMs:I}:{}});s.push({op:i,answer:u});for(let f of X(i,u))a(f)}e.json&&process.stdout.write(`${JSON.stringify({tool:"sandforge-compare",results:s,posted:n.posted},null,2)}
54
+ `),R(H(s,e.failOnDrift))}process.argv[1]?.includes("sandforge-compare")&&(b(),J().then(()=>process.exit(process.exitCode??0)).catch(t=>{process.stderr.write(`${t instanceof Error?t.message:String(t)}
55
+ `),process.exit(1)}));export{w as PAGE_COMPONENT_TYPES,H as compareExitCode,X as describeAnswer,G as describeCoverage,U as describeDeployment,J as main,q as modifiedByType,F as parseArgs};
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a,b,c,d,e,f,g,h,i,j}from"./chunk-I3JKJTLO.mjs";import"./chunk-TW3N6W5Z.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-RSWDYIHY.mjs";import"./chunk-D3QRXG63.mjs";import"./chunk-NM4MDLK4.mjs";import"./chunk-BS5T3MOQ.mjs";import"./chunk-TEOLMRDO.mjs";import"./chunk-FQBRBBY4.mjs";import"./chunk-YS4G22C2.mjs";import"./chunk-SCKUIE3R.mjs";import"./chunk-QROPNEGY.mjs";import"./chunk-BZ24IAP5.mjs";import"./chunk-AV5SWEHP.mjs";import"./chunk-I7O6C2B5.mjs";import"./chunk-4GL773D5.mjs";import"./chunk-SRQDABQ2.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LV6G4XTK.mjs";import"./chunk-HJKM3E56.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-YMJVMFPY.mjs";import"./chunk-ALJVEUUS.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-4HFRHFGQ.mjs";import"./chunk-342FN7AO.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-36U7IQ6Y.mjs";import"./chunk-XETCPL7E.mjs";import"./chunk-K2FBZIXY.mjs";import"./chunk-Z7X534S4.mjs";import"./chunk-6QSM2WIH.mjs";import"./chunk-WJY54JO7.mjs";import"./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"./chunk-L776PUMV.mjs";import"./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"./chunk-VXHDBYMI.mjs";import"./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"./chunk-CGWXQX75.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-SIOZXPFG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-MTMH6H2A.mjs";import"./chunk-B45CNPUX.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-SBIMVCXT.mjs";import"./chunk-NTOVCTRS.mjs";export{g as dryRunLines,j as main,i as maskingInterruptedLine,b as masksObject,d as missingFieldLine,e as notWritableLine,a as parseArgs,h as restoreInterruptedLine,c as resultLines,f as runWouldBeRefused};
7
+ import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-WXAQ7FK3.mjs";import"./chunk-TW3N6W5Z.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-RSWDYIHY.mjs";import"./chunk-VS7ZXUII.mjs";import"./chunk-SOU4FRYN.mjs";import"./chunk-E5AHXLS6.mjs";import"./chunk-OO6CLPEH.mjs";import"./chunk-YS4G22C2.mjs";import"./chunk-QROPNEGY.mjs";import"./chunk-BZ24IAP5.mjs";import"./chunk-SCKUIE3R.mjs";import"./chunk-AV5SWEHP.mjs";import"./chunk-I7O6C2B5.mjs";import"./chunk-YRQGKDHM.mjs";import"./chunk-MJU2PGZQ.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LWW4U276.mjs";import"./chunk-MJVTDA5Q.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-2CNCDM56.mjs";import"./chunk-SIHORWVK.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-B5QQJ4SI.mjs";import"./chunk-NZC67CGR.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-4VS2V6WU.mjs";import"./chunk-KYEDBS54.mjs";import"./chunk-6XYKJSGX.mjs";import"./chunk-K2FBZIXY.mjs";import"./chunk-F43REJDZ.mjs";import"./chunk-JPUR2CFX.mjs";import"./chunk-LPBMBW3O.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-IFETCRWE.mjs";import"./chunk-PZPJKATS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-DYFALGRT.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-7FFGJWHN.mjs";import"./chunk-G35N4P7D.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-KDGMAGQR.mjs";import"./chunk-MFG4MUIO.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-HS4YRX4J.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-MTMH6H2A.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-NTOVCTRS.mjs";export{h as dryRunLines,k as main,j as maskingInterruptedLine,b as masksObject,d as missingFieldLine,e as notWritableLine,a as parseArgs,i as restoreInterruptedLine,c as resultLines,f as runWouldBeRefused,g as snapshotTooSmallLines};
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
4
4
  const require = __sandforgeRequire(import.meta.url);
5
5
  const __filename = __sandforgePath(import.meta.url);
6
6
  const __dirname = __sandforgeDirname(__filename);
7
- import{a as pe}from"./chunk-PBI4BYWW.mjs";import{a as le,b as he,c as fe,d as ge,e as me}from"./chunk-TNXUU6W7.mjs";import"./chunk-IC2C2GOF.mjs";import"./chunk-VGW4MXXZ.mjs";import"./chunk-JVL444U5.mjs";import"./chunk-KLX67VPL.mjs";import"./chunk-5CD257T7.mjs";import"./chunk-5AJRHRXA.mjs";import"./chunk-42RER7V4.mjs";import"./chunk-LRFAIUN7.mjs";import"./chunk-OQOZAPCI.mjs";import"./chunk-RSYICMZG.mjs";import"./chunk-IAZB4WIL.mjs";import"./chunk-FQGHL7GR.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 ye}from"./chunk-TW3N6W5Z.mjs";import{a as de,b as ce,c as ue}from"./chunk-RSWDYIHY.mjs";import{a as B,b as M}from"./chunk-SCKUIE3R.mjs";import{b as H,e as oe}from"./chunk-BZ24IAP5.mjs";import{c as P,d as ne}from"./chunk-AV5SWEHP.mjs";import"./chunk-4GL773D5.mjs";import"./chunk-SRQDABQ2.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LV6G4XTK.mjs";import"./chunk-HJKM3E56.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-YMJVMFPY.mjs";import"./chunk-ALJVEUUS.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-4HFRHFGQ.mjs";import"./chunk-342FN7AO.mjs";import"./chunk-BOGNK4LV.mjs";import{x as ae}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"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import{H as re,i as se}from"./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{a as te}from"./chunk-L776PUMV.mjs";import{q as Z}from"./chunk-6MUEPV7M.mjs";import"./chunk-HJC7AIBK.mjs";import"./chunk-OTWRDD6L.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import{c as K}from"./chunk-RH3N2H7P.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-55HEMHEG.mjs";import"./chunk-P42X3B4D.mjs";import"./chunk-TUACWKIH.mjs";import{b as G}from"./chunk-VXHDBYMI.mjs";import"./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"./chunk-CGWXQX75.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-SIOZXPFG.mjs";import"./chunk-UNDIBZWG.mjs";import{b as Y}from"./chunk-CA5NAXSU.mjs";import{a as Q,b as ee,e as S,g as ie}from"./chunk-MTMH6H2A.mjs";import"./chunk-B45CNPUX.mjs";import{e as z,l as W}from"./chunk-7EANH5PY.mjs";import"./chunk-SBIMVCXT.mjs";import"./chunk-NTOVCTRS.mjs";import{mkdtempSync as Ce,rmSync as Ne}from"node:fs";import{tmpdir as Le}from"node:os";import{basename as Te,join as _e}from"node:path";var be=1024,we="COPY_SANDBOX",Pe=W({DataStorageMB:W({Max:z()}).loose()}).loose();async function ke(o){if(o.orgType!=="Sandbox")return;let t="Empty it whole from DataOps Cleanup in the panel, which knows whether it is marked Staging, or pick the objects to empty with --objects, which Production Guard asks about. "+le,e;try{e=Pe.parse(await o.limits()).DataStorageMB.Max}catch(n){return{code:we,message:`${o.target} is a sandbox whose data storage could not be read (${Y(n)}): this command cannot tell a Partial Copy or Full sandbox, which may hold real data, from a developer's. ${t}`}}if(!(e<=be))return{code:we,message:`${o.target} is a Partial Copy or Full sandbox, by its data storage (${e.toLocaleString("en-US")} MB, past the ${be.toLocaleString("en-US")} MB of a Developer Pro): it may hold real data, and this command cannot see whether it is marked Staging in the extension, where such a sandbox is never emptied whole. ${t}`}}var T="sandforge-empty",Be=`sandforge empty \u2014 empty objects of a sandbox, or the whole of it, without the editor:
7
+ import{a as he}from"./chunk-3RZQZHEB.mjs";import{b as fe,c as ge,d as me,e as ye,f as be}from"./chunk-3F6Q5E7I.mjs";import"./chunk-IC2C2GOF.mjs";import"./chunk-VGW4MXXZ.mjs";import"./chunk-2BA2XKAY.mjs";import"./chunk-OAZRPP4I.mjs";import"./chunk-JEERQRLW.mjs";import"./chunk-HOJYWTP7.mjs";import"./chunk-R3X3LV64.mjs";import"./chunk-E5ZB3LU5.mjs";import"./chunk-EFR2Y7E4.mjs";import"./chunk-O2HDYYUV.mjs";import"./chunk-M3ROUWDX.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-ZM6OJGIG.mjs";import"./chunk-MHMH6MTP.mjs";import"./chunk-COFG7Q6R.mjs";import"./chunk-GMY5427L.mjs";import"./chunk-PJ5I73CK.mjs";import"./chunk-BKDV4ENO.mjs";import"./chunk-X5JYBPXP.mjs";import{a as we}from"./chunk-TW3N6W5Z.mjs";import{a as ue,b as pe,c as le}from"./chunk-RSWDYIHY.mjs";import{b as G,e as ne}from"./chunk-BZ24IAP5.mjs";import{a as B,b as M}from"./chunk-SCKUIE3R.mjs";import{c as P,d as se}from"./chunk-AV5SWEHP.mjs";import"./chunk-YRQGKDHM.mjs";import"./chunk-MJU2PGZQ.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LWW4U276.mjs";import"./chunk-MJVTDA5Q.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-2CNCDM56.mjs";import"./chunk-SIHORWVK.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-B5QQJ4SI.mjs";import"./chunk-NZC67CGR.mjs";import"./chunk-BOGNK4LV.mjs";import{y as de}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"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import{G as ae,J as ie,i as re}from"./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{a as oe}from"./chunk-KDGMAGQR.mjs";import{r as Q}from"./chunk-MFG4MUIO.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import{g as Z}from"./chunk-HS4YRX4J.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import{b as J}from"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import{b as K}from"./chunk-CA5NAXSU.mjs";import{a as ee,b as te,e as D,g as ce}from"./chunk-MTMH6H2A.mjs";import"./chunk-TTFDUKUS.mjs";import{e as Y,l as H}from"./chunk-7EANH5PY.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-NTOVCTRS.mjs";import{mkdtempSync as Te,rmSync as _e}from"node:fs";import{tmpdir as Be}from"node:os";import{basename as Me,join as Ue}from"node:path";var ke=1024,$e="COPY_SANDBOX",Ne=H({DataStorageMB:H({Max:Y()}).loose()}).loose();async function Re(o){if(o.orgType!=="Sandbox")return;let t="Empty it whole from DataOps Cleanup in the panel, which knows whether it is marked Staging, or pick the objects to empty with --objects, which Production Guard asks about. "+fe,e;try{e=Ne.parse(await o.limits()).DataStorageMB.Max}catch(n){return{code:$e,message:`${o.target} is a sandbox whose data storage could not be read (${K(n)}): this command cannot tell a Partial Copy or Full sandbox, which may hold real data, from a developer's. ${t}`}}if(!(e<=ke))return{code:$e,message:`${o.target} is a Partial Copy or Full sandbox, by its data storage (${e.toLocaleString("en-US")} MB, past the ${ke.toLocaleString("en-US")} MB of a Developer Pro): it may hold real data, and this command cannot see whether it is marked Staging in the extension, where such a sandbox is never emptied whole. ${t}`}}var _="sandforge-empty",qe=`sandforge empty \u2014 empty objects of a sandbox, or the whole of it, without the editor:
8
8
  a dry run first, then the deletes, to the recycle bin with an undo, or for good.
9
9
 
10
10
  Usage:
@@ -70,7 +70,7 @@ Options:
70
70
  first delete, to rewind to (sandforge checkpoint);
71
71
  refused past 500,000 records or the disk's room, and
72
72
  then nothing is deleted
73
- ${ue("deleted","--dry-run")} --audit <file> add the run's entry, or the undo's, to the audit trail
73
+ ${le("deleted","--dry-run")} --audit <file> add the run's entry, or the undo's, to the audit trail
74
74
  kept in <file>: the entry the panel keeps in Reports ->
75
75
  Audit trail, counts only. Not with --dry-run,
76
76
  which adds none
@@ -124,17 +124,17 @@ Exit codes:
124
124
  3 partial: records the org refused, each said with why
125
125
  130, 143, 129 a Ctrl-C, a SIGTERM or a SIGHUP stopped it before its next
126
126
  call or job: --resume takes it up, --undo brings back what it deleted
127
- `,Me={switches:["--org","--custom-settings","--files","--managed-packages","--unrestorable","--hard-delete","--dry-run","--yes","--json","--accept-no-undo","--accept-people-active","--checkpoint-first",...de],values:["--target","--objects","--exclude-object","--undo","--resume","--audit"]},Ue=/^[A-Za-z][A-Za-z0-9_]{0,79}$/;function k(o){process.stderr.write(`${o} Run with --help.
128
- `),process.exit(2)}function $e(o,t){let e=[];for(let n=0;n<o.length;n++)o[n]===t&&o[n+1]!==void 0&&e.push(o[n+1]);return e}function qe(o){let t=o.replace(/[\\/]+$/,""),e=Te(t);return he(e)?e:void 0}function Fe(o){let t=o.slice(2);(t.includes("--help")||t.includes("-h"))&&(process.stdout.write(Be),process.exit(0)),Q(t,Me);let e=c=>t.includes(c),n=c=>{let b=$e(t,c);return b.length>1&&k(`${c} is given ${b.length} times: give it once.`),b[0]},r=n("--target");r===void 0&&k("--target <alias> names the org to empty."),ee.test(r)||k(`--target ${r} is not an sf CLI alias.`);let l=e("--json"),a=ce(t),h=n("--audit"),f={target:r,json:l,accord:a,...h!==void 0?{audit:h}:{},...e("--accept-people-active")?{acceptPeopleActive:!0}:{}},s=n("--undo"),i=n("--resume"),u=n("--objects"),g=$e(t,"--exclude-object"),y=e("--org"),O=["--custom-settings","--files","--managed-packages","--unrestorable"].filter(e);if(s!==void 0||i!==void 0){let c=s!==void 0?"--undo":"--resume";s!==void 0&&i!==void 0&&k("--undo and --resume go apart."),s!==void 0&&e("--accept-people-active")&&k("--undo deletes nothing, and does not go with --accept-people-active.");let b=[...u!==void 0?["--objects"]:[],...y?["--org"]:[],...g.length>0?["--exclude-object"]:[],...O,...["--hard-delete","--accept-no-undo","--checkpoint-first","--dry-run"].filter(e)];b.length>0&&k(`${c} acts on what its run's journal holds, and does not go with ${b.join(", ")}.`);let j=s??i,I=qe(j);return I===void 0&&k(`${c} ${j} names no emptying: give its id (em-...) or its journal's folder.`),e("--yes")||Re(f,s!==void 0?"undo":"resume"),{act:s!==void 0?"undo":"resume",runId:I,...f}}if(u!==void 0&&y&&k("--objects and --org go apart: give one."),u===void 0&&!y&&k("Name the objects to empty with --objects <A,B>, or the whole org with --org."),!y){let c=[...g.length>0?["--exclude-object"]:[],...O];c.length>0&&k(`${c.join(", ")} goes with --org alone.`)}let v=u===void 0?void 0:u.split(",").map(c=>c.trim()).filter(c=>c!=="");v!==void 0&&v.length===0&&k("--objects names no object.");for(let c of[...v??[],...g])Ue.test(c)||k(`${c} is not an object API name.`);let $=e("--dry-run"),E=e("--yes");return $&&E&&k("--dry-run and --yes go apart: a dry run deletes nothing."),!$&&!E&&Re(f,"empty"),$&&h!==void 0&&k("--audit records a run: a dry run adds no entry."),{act:"empty",request:y?{mode:"org",...g.length>0?{excluded:[...new Set(g)]}:{},...e("--custom-settings")?{customSettings:!0}:{},...e("--files")?{files:!0}:{},...e("--managed-packages")?{managedPackages:!0}:{},...e("--unrestorable")?{unrestorable:!0}:{}}:{mode:"objects",objects:[...new Set(v??[])]},hard:e("--hard-delete"),dryRun:$,acceptNoUndo:e("--accept-no-undo"),checkpointFirst:e("--checkpoint-first"),...f}}function Re(o,t){let e={code:"NOT_CONFIRMED",message:t==="empty"?`${M(T)} asks no question: add --dry-run to read what it would delete, or --yes to empty once the dry run said it. Nothing was read or deleted.`:`${M(T)} asks no question: add --yes to ${t==="undo"?"undo":"take up"} the emptying. Nothing was read or written.`};process.stderr.write(`${P(e)}
129
- `),o.json&&process.stdout.write(`${JSON.stringify({tool:T,target:o.target,action:t,refused:e},null,2)}
130
- `),process.exit(1)}var p=o=>o.toLocaleString("en-US");function R(o){if(o.records===void 0)return`not counted (${o.unread??"no count"})`;if(o.atMost&&o.atLeast)return`about ${p(o.records)}`;let t=o.atMost?" at most":o.atLeast?" at least":"";return`${p(o.records)}${t}`}var ve={configuration:"configuration: flows, orchestrations, settings, definitions",notRestorable:"cannot come back from the recycle bin (--unrestorable empties them)",excludedByUser:"left out as asked",notFound:"the org has no such object",chatter:"Chatter",history:"field history",sharing:"sharing",changeEvent:"change events",unsupportedKind:"big, external or platform event object",customSetting:"a custom setting (--custom-settings empties them)",files:"files (--files empties them)",managedPackage:"a managed package (--managed-packages empties them)",documents:"documents",heldWithFiles:"goes with the files",setup:"setup",platformCreated:"made by the platform",metadata:"metadata",notDeletable:"the user may not delete its records",notDescribed:"the org would not describe it",noRecycleBin:"its records never go to the recycle bin",notForGood:"its records are never deleted for good"},We={activatedOrder:"activated order(s): set back to Draft first, as Salesforce deletes none activated",activatedOrderLeft:"activated order(s) left as they are: what blocks keeps too many records to tell those under them apart, so none is set back to Draft, and what each hangs from is refused",standardPriceBook:"the standard price book: kept, never deleted",directContactRelation:"direct relation(s) of a contact to its account: they go with the contact",personAccountContact:"person account contact(s): left, as each goes only with its account"};function N(o,...t){let e=t.every(n=>n!==void 0)?t.reduce((n,r)=>n+(r??0),0):void 0;return o===void 0&&e===void 0?{}:{apiRequests:{...o!==void 0?{estimate:o}:{},...e!==void 0?{sent:e}:{}}}}var He={NO_UNDO:"--accept-no-undo",PEOPLE_ACTIVE:"--accept-people-active"};function X(o){let t=He[o.code];return t&&!o.message.includes(t)?{...o,message:`${o.message} (${t} accepts it)`}:o}function Ie(o){return o.reason==="notRestorable"?`${o.objectApiName} sent by its own pass: Salesforce does not bring them back`:`${o.objectApiName} before ${o.parent??"its parent"}${o.field!==void 0?` (${o.field})`:""}: they go before a record they name`}function Ge(o,t){let{preview:e}=t,n=[],r=e.mode==="org"?"every object people work in":`${e.passes.length} object(s) picked`;n.push(`${M(T)} target=${o} ${r} ${e.deleteMode==="hard"?"FOR GOOD":"to the recycle bin"}`),n.push(`read at ${t.readAt} on the org's clock: records made after it are left`),n.push(`${e.total.atLeast?"at least ":""}${p(e.total.records)} record(s) of ${p(e.total.objects)} object(s)`+(e.total.uncounted.length>0?`, and ${e.total.uncounted.join(", ")} not counted`:""));let l=e.passes.filter(s=>s.records.records===void 0||s.records.records>0);if(e.passes.length>0){n.push("","Emptied, in the order the run takes them:");for(let i of l){let u=i.sent.records!==i.records.records?`, ${R(i.sent)} sent by its own pass`:"",g=i.archived?.records?`, ${R(i.archived)} archived`:"",y=i.kept?.records?`, ${R(i.kept)} kept`:"",O=i.blocked?`, ${R(i.blocked)} kept by what blocks them, which stay`:"";n.push(` ${i.objectApiName.padEnd(40)} ${R(i.records)}${u}${g}${y}${O}`)}let s=e.passes.length-l.length;s>0&&n.push(` and ${p(s)} object(s) holding no record (--json lists them)`)}if(e.along.length>0){n.push("","Going along, deleted by the org with a record emptied:");for(let s of e.along){let i=[...new Set(s.via.map(y=>`${y.field} \u2192 ${y.parent}`))].join(", "),u=s.blocking?`; ${R(s.blocking)} more block the delete and stay`:"",g=s.routesNotRead?.length?`; routes through ${s.routesNotRead.join(", ")} not read, there may be more`:"";n.push(` ${s.objectApiName.padEnd(40)} ${R(s.records)}${i?` (${i})`:""}${u}${g}`)}}let a=e.refusals.filter(s=>s.records.records!==0);if(a.length>0){n.push("","Likely refused by the org, or done first so that it is not:");for(let s of a)n.push(` ${s.objectApiName}: ${R(s.records)} \u2014 ${We[s.code]}`)}let h=e.blockers.filter(s=>s.records.records!==0);if(h.length>0){n.push("","Blocking: records of objects not emptied whose lookup refuses the delete; they stay, and so do the records they name, with what hangs from those:");for(let s of h){let i=s.keeps&&s.keeps.records!==0?`, keeping ${R(s.keeps)} ${s.parent}`:"";n.push(` ${s.objectApiName}.${s.field} \u2192 ${s.parent}: ${R(s.records)}${i}`)}}let f=e.undoLost.filter(s=>s.records.records!==0);if(e.deleteMode==="recycle"&&f.length>0){n.push("","Undo cannot bring back:");for(let s of f)n.push(` ${Ie(s)}: ${R(s.records)}`)}if(e.leftOut.length>0){let s=u=>e.mode==="objects"||u==="excludedByUser"||u==="notFound",i=new Map;n.push("",`Left out: ${p(e.leftOut.length)} object(s)`);for(let u of e.leftOut)s(u.reason)?n.push(` ${u.objectApiName}: ${ve[u.reason]}`):i.set(u.reason,(i.get(u.reason)??0)+1);for(let[u,g]of i)n.push(` ${p(g)} object(s): ${ve[u]}`)}if(n.push("",...Je(t)),n.push(...Ve(t)),t.checkpoint){let{estimate:s,objects:i,refusal:u}=t.checkpoint;n.push(u?`checkpoint first: refused (${u.code}): ${u.message}`:`checkpoint first: ${p(i.length)} object(s), about ${p(s.records)} record(s) and ${p(s.apiRequests)} API request(s), taken before the first delete`)}return t.openRun&&n.push(`the last emptying of ${o}, ${t.openRun.runId}, stopped part way: --resume ${t.openRun.runId} takes it up, --undo ${t.openRun.runId} brings back what it deleted`),t.automation.lines.length>0&&n.push("",...t.automation.lines),n}function Je(o){let{cost:t}=o.preview,e=r=>r.verdict==="unread"?` (what the org has left today could not be read: ${r.unread})`:` of ${p(r.remaining)} left today${r.verdict==="exceeds"?": too many":""}`,n=[`about ${p(t.api.estimate)} API request(s), the dry run's reads and the run's together${e(t.api)}, ${p(t.bulkBatches)} Bulk API batch(es)`+(t.batches?e(t.batches):"")+`, about ${p(Math.ceil(t.seconds))} s`];return o.preview.deleteMode==="recycle"?n.push(`${p(t.binRecords)} record(s) to the recycle bin`+(t.bin?.past?`: past the ${p(t.bin.documentedCapacity)} the bin is documented to hold, it empties its oldest first, colleagues\u2019 deletions among them, and Undo may not bring all back`:"")):n.push("deleted for good, with what goes along: no undo brings anything back"),n}function Ve(o){let t=[];if(o.access.kind==="org")t.push("the user sees every record: View All Data and Modify All Data");else{t.push("the user holds "+(o.access.viewAllData?"View All Data":"no View All Data")+" and "+(o.access.modifyAllData?"Modify All Data":"no Modify All Data")+": the records of an object it is not proven to see whole are neither counted nor deleted, but those a deleted parent takes along are");for(let e of o.access.unseen)t.push(` not proven to see ${e.objectApiName} whole: ${e.reason}`)}if(o.preview.deleteMode==="hard"&&t.push(o.hardDelete.permitted?"the user holds Bulk API Hard Delete":`the user does not hold Bulk API Hard Delete${o.hardDelete.unread?` (${o.hardDelete.unread})`:""}`),o.peopleActive.people>0){t.push(`${o.peopleActive.atLeast?"at least ":""}${p(o.peopleActive.people)} other person(s) changed records of these objects in the hour before the read: their work goes with the emptying, which --accept-people-active accepts`);for(let e of o.peopleActive.who??[])t.push(` user ${e.userId}: ${p(e.records)} record(s), the last changed at ${e.lastChangedAt||"an unread time"}`)}return t}function Ae(o,t){if(t.runId==="")return t.notes;let e=[`${t.resumed?"took up":"emptied"} ${o}: ${t.runId}, ${t.status}`+(t.hard?", for good":"")],n=t.passes.filter(a=>a.deleted+a.gone+a.refused+(a.notReached??0)+(a.madeSince??0)>0||a.reasons.length>0);for(let a of n){let h=[`deleted ${p(a.deleted)}`,...a.gone>0?[`gone before ${p(a.gone)}`]:[],...a.refused>0?[`refused ${p(a.refused)}`]:[],...(a.notReached??0)>0?[`not reached ${p(a.notReached??0)}`]:[],...(a.madeSince??0)>0?[`made since and left ${p(a.madeSince??0)}`]:[]];e.push(` ${a.objectApiName.padEnd(40)} ${h.join(", ")}`);for(let f of a.reasons)e.push(` ${f}`)}let r=t.passes.length-n.length;r>0&&e.push(` and ${p(r)} object(s) whose pass found nothing to delete (--json lists them)`);let{totals:l}=t;e.push(`deleted ${p(l.deleted)} record(s), ${p(l.gone)} gone before their delete, ${p(l.refused)} refused, ${p(l.notReached)} not reached`),t.hardRefused&&e.push(`the org refused to delete for good: ${t.hardRefused}`),t.checkpoint?.state==="taken"?e.push(`checkpoint taken first: ${t.checkpoint.name} (${t.checkpoint.checkpointId}); ${B("checkpoint")} rewind --org ${o} --checkpoint ${t.checkpoint.checkpointId} returns the objects it holds to it`):t.checkpoint?.state==="deleted"&&e.push("the checkpoint taken first was deleted again: the run deleted nothing");for(let a of t.notes)e.push(a);return t.status==="cancelled"||t.status==="failure"?e.push(`${B("empty")} --target ${o} --resume ${t.runId} --yes takes it up; --undo ${t.runId} --yes brings back what it deleted`):t.undo.offered?e.push(`${B("empty")} --target ${o} --undo ${t.runId} --yes brings them back while the recycle bin holds them, as long as no other emptying of the org follows`):t.undo.why==="hard"&&e.push("no undo: it deleted for good"),e}function Xe(o,t){let e=[`undid the emptying ${t.runId} of ${o}: ${t.status}`];for(let r of t.objects){let l=[`brought back ${p(r.undeleted)}`,...r.alreadyBack>0?[`already back ${p(r.alreadyBack)}`]:[],...r.notInBin>0?[`no longer in the recycle bin ${p(r.notInBin)}`]:[],...r.othersDeletion>0?[`deleted by another user, Modify All Data needed ${p(r.othersDeletion)}`]:[],...r.refused>0?[`refused ${p(r.refused)}`]:[],...(r.notReached??0)>0?[`not reached ${p(r.notReached??0)}`]:[]];e.push(` ${r.objectApiName.padEnd(40)} ${l.join(", ")}`);for(let a of r.reasons)e.push(` ${a}`)}let n=t.previewedLost??[];if(n.length>0){e.push("not brought back, as the preview said Undo could not:");for(let r of n)e.push(` ${Ie(r)}: ${R(r.records)}`)}for(let r of t.notes)e.push(r);return e}function J(o,t){return o==="success"?0:o==="partial"?3:o==="cancelled"?t!==void 0?H(t):1:1}var ze=60*6e4,Oe=720*6e4,Ee="dataops",A=class extends Error{constructor(e,n=1,r=[]){super(e.message);this.refusal=e;this.code=n;this.also=r;this.name="Stop"}refusal;code;also};function L(o){return o.message?.payload??{}}function V(o,t,e){if(o.outcome==="unanswered")return new A({code:"UNANSWERED",message:`${t}: no answer came in time.`});let n=L(o),r=typeof n.message=="string"?n.message:JSON.stringify(n),l=typeof n.code=="string"?n.code:o.outcome.toUpperCase(),a=Array.isArray(n.alsoRefused)?n.alsoRefused.flatMap(h=>{let f=h??{};return typeof f.code=="string"&&typeof f.message=="string"?[{code:f.code,message:f.message}]:[]}):[];return e!==void 0&&l==="CANCELLED"?new A({code:l,message:r},H(e)):new A(X({code:l,message:r}),1,a.map(X))}async function Se(o,t,e){let n,r=o.onEvent((a,h,f)=>{n!==void 0&&h==="started"&&f.module===Ee&&o.abort(a)}),l=oe(a=>{n=a,process.stderr.write(`
127
+ `,Fe={switches:["--org","--custom-settings","--files","--managed-packages","--unrestorable","--hard-delete","--dry-run","--yes","--json","--accept-no-undo","--accept-people-active","--checkpoint-first",...ue],values:["--target","--objects","--exclude-object","--undo","--resume","--audit"]},We=/^[A-Za-z][A-Za-z0-9_]{0,79}$/;function k(o){process.stderr.write(`${o} Run with --help.
128
+ `),process.exit(2)}function Oe(o,t){let e=[];for(let n=0;n<o.length;n++)o[n]===t&&o[n+1]!==void 0&&e.push(o[n+1]);return e}function He(o){let t=o.replace(/[\\/]+$/,""),e=Me(t);return ge(e)?e:void 0}function Ge(o){let t=o.slice(2);(t.includes("--help")||t.includes("-h"))&&(process.stdout.write(qe),process.exit(0)),ee(t,Fe);let e=h=>t.includes(h),n=h=>{let p=Oe(t,h);return p.length>1&&k(`${h} is given ${p.length} times: give it once.`),p[0]},r=n("--target");r===void 0&&k("--target <alias> names the org to empty."),te.test(r)||k(`--target ${r} is not an sf CLI alias.`);let f=e("--json"),i=pe(t),l=n("--audit"),g={target:r,json:f,accord:i,...l!==void 0?{audit:l}:{},...e("--accept-people-active")?{acceptPeopleActive:!0}:{}},s=n("--undo"),d=n("--resume"),c=n("--objects"),y=Oe(t,"--exclude-object"),b=e("--org"),O=["--custom-settings","--files","--managed-packages","--unrestorable"].filter(e);if(s!==void 0||d!==void 0){let h=s!==void 0?"--undo":"--resume";s!==void 0&&d!==void 0&&k("--undo and --resume go apart."),s!==void 0&&e("--accept-people-active")&&k("--undo deletes nothing, and does not go with --accept-people-active.");let p=[...c!==void 0?["--objects"]:[],...b?["--org"]:[],...y.length>0?["--exclude-object"]:[],...O,...["--hard-delete","--accept-no-undo","--checkpoint-first","--dry-run"].filter(e)];p.length>0&&k(`${h} acts on what its run's journal holds, and does not go with ${p.join(", ")}.`);let E=s??d,I=He(E);return I===void 0&&k(`${h} ${E} names no emptying: give its id (em-...) or its journal's folder.`),e("--yes")||Ae(g,s!==void 0?"undo":"resume"),{act:s!==void 0?"undo":"resume",runId:I,...g}}if(c!==void 0&&b&&k("--objects and --org go apart: give one."),c===void 0&&!b&&k("Name the objects to empty with --objects <A,B>, or the whole org with --org."),!b){let h=[...y.length>0?["--exclude-object"]:[],...O];h.length>0&&k(`${h.join(", ")} goes with --org alone.`)}let S=c===void 0?void 0:c.split(",").map(h=>h.trim()).filter(h=>h!=="");S!==void 0&&S.length===0&&k("--objects names no object.");for(let h of[...S??[],...y])We.test(h)||k(`${h} is not an object API name.`);let A=e("--dry-run"),R=e("--yes");return A&&R&&k("--dry-run and --yes go apart: a dry run deletes nothing."),!A&&!R&&Ae(g,"empty"),A&&l!==void 0&&k("--audit records a run: a dry run adds no entry."),{act:"empty",request:b?{mode:"org",...y.length>0?{excluded:[...new Set(y)]}:{},...e("--custom-settings")?{customSettings:!0}:{},...e("--files")?{files:!0}:{},...e("--managed-packages")?{managedPackages:!0}:{},...e("--unrestorable")?{unrestorable:!0}:{}}:{mode:"objects",objects:[...new Set(S??[])]},hard:e("--hard-delete"),dryRun:A,acceptNoUndo:e("--accept-no-undo"),checkpointFirst:e("--checkpoint-first"),...g}}function Ae(o,t){let e={code:"NOT_CONFIRMED",message:t==="empty"?`${M(_)} asks no question: add --dry-run to read what it would delete, or --yes to empty once the dry run said it. Nothing was read or deleted.`:`${M(_)} asks no question: add --yes to ${t==="undo"?"undo":"take up"} the emptying. Nothing was read or written.`};process.stderr.write(`${P(e)}
129
+ `),o.json&&process.stdout.write(`${JSON.stringify({tool:_,target:o.target,action:t,refused:e},null,2)}
130
+ `),process.exit(1)}var u=o=>o.toLocaleString("en-US");function $(o){if(o.records===void 0)return`not counted (${o.unread??"no count"})`;if(o.atMost&&o.atLeast)return`about ${u(o.records)}`;let t=o.atMost?" at most":o.atLeast?" at least":"";return`${u(o.records)}${t}`}var Ee={configuration:"configuration: flows, orchestrations, settings, definitions",notRestorable:"cannot come back from the recycle bin (--unrestorable empties them)",excludedByUser:"left out as asked",notFound:"the org has no such object",chatter:"Chatter",history:"field history",sharing:"sharing",changeEvent:"change events",unsupportedKind:"big, external or platform event object",customSetting:"a custom setting (--custom-settings empties them)",files:"files (--files empties them)",managedPackage:"a managed package (--managed-packages empties them)",documents:"documents",heldWithFiles:"goes with the files",setup:"setup",platformCreated:"made by the platform",metadata:"metadata",notDeletable:"the user may not delete its records",notDescribed:"the org would not describe it",noRecycleBin:"its records never go to the recycle bin",notForGood:"its records are never deleted for good"},Je={activatedOrder:"activated order(s): set back to Draft first, as Salesforce deletes none activated",activatedOrderLeft:"activated order(s) left as they are: what blocks keeps too many records to tell those under them apart, so none is set back to Draft, and what each hangs from is refused",standardPriceBook:"the standard price book: kept, never deleted",directContactRelation:"direct relation(s) of a contact to its account: they go with the contact",personAccountContact:"person account contact(s): left, as each goes only with its account"};function L(o,...t){let e=t.every(n=>n!==void 0)?t.reduce((n,r)=>n+(r??0),0):void 0;return o===void 0&&e===void 0?{}:{apiRequests:{...o!==void 0?{estimate:o}:{},...e!==void 0?{sent:e}:{}}}}var Ve={NO_UNDO:"--accept-no-undo",PEOPLE_ACTIVE:"--accept-people-active"},Xe=new Set(["TOO_MANY_RECORDS","NOTHING_HELD"]);function z(o,t){if(Xe.has(o.code)||t!==void 0&&t.code===o.code&&t.message===o.message)return{...o,message:xe(o.message)};let n=Ve[o.code];return n&&!o.message.includes(n)?{...o,message:`${o.message} (${n} accepts it)`}:o}function xe(o){let t=o.replace(/\s*No record was read( or written)?\.$/,"").replace(/: pick fewer objects\.$/,".").replace(/\.$/,"");return`The checkpoint first was refused: ${t.charAt(0).toLowerCase()}${t.slice(1)}. Empty fewer objects (--objects, or --exclude-object with --org), or leave out --checkpoint-first to empty without one.`}function Ce(o){return o.reason==="notRestorable"?`${o.objectApiName} sent by its own pass: Salesforce does not bring them back`:`${o.objectApiName} before ${o.parent??"its parent"}${o.field!==void 0?` (${o.field})`:""}: they go before a record they name`}function ze(o,t){let{preview:e}=t,n=[],r=e.mode==="org"?"every object people work in":`${e.passes.length} object(s) picked`;n.push(`${M(_)} target=${o} ${r} ${e.deleteMode==="hard"?"FOR GOOD":"to the recycle bin"}`),n.push(`read at ${t.readAt} on the org's clock: records made after it are left`),n.push(`${e.total.atLeast?"at least ":""}${u(e.total.records)} record(s) of ${u(e.total.objects)} object(s)`+(e.total.uncounted.length>0?`, and ${e.total.uncounted.join(", ")} not counted`:""));let f=e.passes.filter(s=>s.records.records===void 0||s.records.records>0);if(e.passes.length>0){n.push("","Emptied, in the order the run takes them:");for(let d of f){let c=d.sent.records!==d.records.records?`, ${$(d.sent)} sent by its own pass`:"",y=d.archived?.records?`, ${$(d.archived)} archived`:"",b=d.kept?.records?`, ${$(d.kept)} kept`:"",O=d.blocked?`, ${$(d.blocked)} kept by what blocks them, which stay`:"";n.push(` ${d.objectApiName.padEnd(40)} ${$(d.records)}${c}${y}${b}${O}`)}let s=e.passes.length-f.length;s>0&&n.push(` and ${u(s)} object(s) holding no record (--json lists them)`)}if(e.along.length>0){n.push("","Going along, deleted by the org with a record emptied:");for(let s of e.along){let d=[...new Set(s.via.map(b=>`${b.field} \u2192 ${b.parent}`))].join(", "),c=s.blocking?`; ${$(s.blocking)} more block the delete and stay`:"",y=s.routesNotRead?.length?`; routes through ${s.routesNotRead.join(", ")} not read, there may be more`:"";n.push(` ${s.objectApiName.padEnd(40)} ${$(s.records)}${d?` (${d})`:""}${c}${y}`)}}let i=e.refusals.filter(s=>s.records.records!==0);if(i.length>0){n.push("","Likely refused by the org, or done first so that it is not:");for(let s of i)n.push(` ${s.objectApiName}: ${$(s.records)} \u2014 ${Je[s.code]}`)}let l=e.blockers.filter(s=>s.records.records!==0);if(l.length>0){n.push("","Blocking: records of objects not emptied whose lookup refuses the delete; they stay, and so do the records they name, with what hangs from those:");for(let s of l){let d=s.keeps&&s.keeps.records!==0?`, keeping ${$(s.keeps)} ${s.parent}`:"";n.push(` ${s.objectApiName}.${s.field} \u2192 ${s.parent}: ${$(s.records)}${d}`)}}let g=e.undoLost.filter(s=>s.records.records!==0);if(e.deleteMode==="recycle"&&g.length>0){n.push("","Undo cannot bring back:");for(let s of g)n.push(` ${Ce(s)}: ${$(s.records)}`)}if(e.leftOut.length>0){let s=c=>e.mode==="objects"||c==="excludedByUser"||c==="notFound",d=new Map;n.push("",`Left out: ${u(e.leftOut.length)} object(s)`);for(let c of e.leftOut)s(c.reason)?n.push(` ${c.objectApiName}: ${Ee[c.reason]}`):d.set(c.reason,(d.get(c.reason)??0)+1);for(let[c,y]of d)n.push(` ${u(y)} object(s): ${Ee[c]}`)}if(n.push("",...Ye(t)),n.push(...Ke(t)),t.checkpoint){let{estimate:s,objects:d,refusal:c}=t.checkpoint;n.push(c?`checkpoint first: refused (${c.code}): ${xe(c.message)}`:`checkpoint first: ${u(d.length)} object(s), about ${u(s.records)} record(s) and ${u(s.apiRequests)} API request(s), taken before the first delete`)}return t.openRun&&n.push(`the last emptying of ${o}, ${t.openRun.runId}, stopped part way: --resume ${t.openRun.runId} takes it up, --undo ${t.openRun.runId} brings back what it deleted`),t.automation.lines.length>0&&n.push("",...t.automation.lines),n}function Ye(o){let{cost:t}=o.preview,e=r=>r.verdict==="unread"?` (what the org has left today could not be read: ${r.unread})`:` of ${u(r.remaining)} left today${r.verdict==="exceeds"?": too many":""}`,n=[`about ${u(t.api.estimate)} API request(s), the dry run's reads and the run's together${e(t.api)}, ${u(t.bulkBatches)} Bulk API batch(es)`+(t.batches?e(t.batches):"")+`, about ${u(Math.ceil(t.seconds))} s`];return o.preview.deleteMode==="recycle"?n.push(`${u(t.binRecords)} record(s) to the recycle bin`+(t.bin?.past?`: past the ${u(t.bin.documentedCapacity)} the bin is documented to hold, it empties its oldest first, colleagues\u2019 deletions among them, and Undo may not bring all back`:"")):n.push("deleted for good, with what goes along: no undo brings anything back"),n}function Ke(o){let t=[];if(o.access.kind==="org")t.push("the user sees every record: View All Data and Modify All Data");else{t.push("the user holds "+(o.access.viewAllData?"View All Data":"no View All Data")+" and "+(o.access.modifyAllData?"Modify All Data":"no Modify All Data")+": the records of an object it is not proven to see whole are neither counted nor deleted, but those a deleted parent takes along are");for(let e of o.access.unseen)t.push(` not proven to see ${e.objectApiName} whole: ${e.reason}`)}if(o.preview.deleteMode==="hard"&&t.push(o.hardDelete.permitted?"the user holds Bulk API Hard Delete":`the user does not hold Bulk API Hard Delete${o.hardDelete.unread?` (${o.hardDelete.unread})`:""}`),o.peopleActive.people>0){t.push(`${o.peopleActive.atLeast?"at least ":""}${u(o.peopleActive.people)} other person(s) changed records of these objects in the hour before the read: their work goes with the emptying, which --accept-people-active accepts`);for(let e of o.peopleActive.who??[])t.push(` user ${e.userId}: ${u(e.records)} record(s), the last changed at ${e.lastChangedAt||"an unread time"}`)}return t}function ve(o,t){if(t.runId==="")return t.notes;let e=[`${t.resumed?"took up":"emptied"} ${o}: ${t.runId}, ${t.status}`+(t.hard?", for good":"")],n=t.passes.filter(i=>i.deleted+i.gone+i.refused+(i.notReached??0)+(i.madeSince??0)>0||i.reasons.length>0);for(let i of n){let l=[`deleted ${u(i.deleted)}`,...i.gone>0?[`gone before ${u(i.gone)}`]:[],...i.refused>0?[`refused ${u(i.refused)}`]:[],...(i.notReached??0)>0?[`not reached ${u(i.notReached??0)}`]:[],...(i.madeSince??0)>0?[`made since and left ${u(i.madeSince??0)}`]:[]];e.push(` ${i.objectApiName.padEnd(40)} ${l.join(", ")}`);for(let g of i.reasons)e.push(` ${g}`)}let r=t.passes.length-n.length;r>0&&e.push(` and ${u(r)} object(s) whose pass found nothing to delete (--json lists them)`);let{totals:f}=t;e.push(`deleted ${u(f.deleted)} record(s), ${u(f.gone)} gone before their delete, ${u(f.refused)} refused, ${u(f.notReached)} not reached`),t.hardRefused&&e.push(`the org refused to delete for good: ${t.hardRefused}`),t.checkpoint?.state==="taken"?e.push(`checkpoint taken first: ${t.checkpoint.name} (${t.checkpoint.checkpointId}); ${B("checkpoint")} rewind --org ${o} --checkpoint ${t.checkpoint.checkpointId} returns the objects it holds to it`):t.checkpoint?.state==="deleted"&&e.push("the checkpoint taken first was deleted again: the run deleted nothing");for(let i of t.notes)e.push(i);return t.status==="cancelled"||t.status==="failure"?e.push(`${B("empty")} --target ${o} --resume ${t.runId} --yes takes it up; --undo ${t.runId} --yes brings back what it deleted`):t.undo.offered?e.push(`${B("empty")} --target ${o} --undo ${t.runId} --yes brings them back while the recycle bin holds them, as long as no other emptying of the org follows`):t.undo.why==="hard"&&e.push("no undo: it deleted for good"),e}function Ze(o,t){let e=[`undid the emptying ${t.runId} of ${o}: ${t.status}`];for(let r of t.objects){let f=[`brought back ${u(r.undeleted)}`,...r.alreadyBack>0?[`already back ${u(r.alreadyBack)}`]:[],...r.notInBin>0?[`no longer in the recycle bin ${u(r.notInBin)}`]:[],...r.othersDeletion>0?[`deleted by another user, Modify All Data needed ${u(r.othersDeletion)}`]:[],...r.refused>0?[`refused ${u(r.refused)}`]:[],...(r.notReached??0)>0?[`not reached ${u(r.notReached??0)}`]:[]];e.push(` ${r.objectApiName.padEnd(40)} ${f.join(", ")}`);for(let i of r.reasons)e.push(` ${i}`)}let n=t.previewedLost??[];if(n.length>0){e.push("not brought back, as the preview said Undo could not:");for(let r of n)e.push(` ${Ce(r)}: ${$(r.records)}`)}for(let r of t.notes)e.push(r);return e}function V(o,t){return o==="success"?0:o==="partial"?3:o==="cancelled"?t!==void 0?G(t):1:1}var Qe=60*6e4,Se=720*6e4,De="dataops",v=class extends Error{constructor(e,n=1,r=[]){super(e.message);this.refusal=e;this.code=n;this.also=r;this.name="Stop"}refusal;code;also};function T(o){return o.message?.payload??{}}function X(o,t,e){if(o.outcome==="unanswered")return new v({code:"UNANSWERED",message:`${t}: no answer came in time.`});let n=T(o),r=typeof n.message=="string"?n.message:JSON.stringify(n),f=typeof n.code=="string"?n.code:o.outcome.toUpperCase(),i=Array.isArray(n.alsoRefused)?n.alsoRefused.flatMap(l=>{let g=l??{};return typeof g.code=="string"&&typeof g.message=="string"?[{code:g.code,message:g.message}]:[]}):[];return e!==void 0&&f==="CANCELLED"?new v({code:f,message:r},G(e)):new v(z({code:f,message:r}),1,i.map(l=>z(l)))}async function je(o,t,e){let n,r=o.onEvent((i,l,g)=>{n!==void 0&&l==="started"&&g.module===De&&o.abort(i)}),f=ne(i=>{n=i,process.stderr.write(`
131
131
  interrupted: ${t} (Ctrl-C again ends it at once)
132
- `);for(let h of o.getRunning())h.module===Ee&&o.abort(h.operationId)});try{let a=await e();return n!==void 0?{answer:a,stoppedBy:n}:{answer:a}}finally{l(),r()}}async function Ye(o,t,e){if(o.act==="empty")return o.request.mode==="org";if(o.act!=="resume")return!1;try{return(await t.open(e.orgId,o.runId)).head.mode==="org"}catch{return!1}}async function Ke(o=process.argv,t={}){let e=Fe(o),n=i=>{process[e.json?"stderr":"stdout"].write(`${i}
133
- `)},r=i=>{e.json&&process.stdout.write(`${JSON.stringify({tool:T,target:e.target,action:e.act,...i},null,2)}
134
- `)},l=Ce(_e(Le(),"sandforge-empty-")),a=new ye,h,f,s;try{let i=re({root:t.checkpointRoot??se(),...t.locksDir!==void 0?{locksDir:t.locksDir}:{}});if("refusal"in i)throw new A({code:"STORE_REFUSED",message:`The org's lock and a checkpoint taken first cannot be kept in ${i.refusal.path} (${i.refusal.reason}). Nothing was read or deleted.`});let u=i.store,g=new ge(t.journalRoot??fe()),y=(t.createHost??me)({storeDir:l,log:d=>{d.startsWith("[WARN] ")&&n(`warning: ${d.slice(7)}`)},compose:d=>{h=d.configStore,f=d,d.handlers.setCheckpointStore(u),d.handlers.setEmptyStores({journals:g,lock:m=>u.lock(m,"empty")}),d.handlers.setInfraServices({backgroundRegistry:a,productionGuard:pe(n,e.target)})},onPost:d=>{if(d.type!=="operation:progress")return;let m=d.payload?.currentStep;typeof m!="string"||m===s||(s=m,n(` ${m}`))}}),O=()=>0,v=()=>(y.connectingRequests?.()??0)+O(),$;try{$=await y.connect(e.target)}catch(d){throw new A({code:"NOT_CONNECTED",message:d instanceof te?`${d.reason} Nothing was read or deleted.`:`${e.target} could not be reached: ${d instanceof Error?d.message:String(d)}. Nothing was read or deleted.`})}let E={...e.accord};if(await Ye(e,g,$)){let d=f,m=await ke({target:e.target,orgType:$.orgType,limits:async()=>{if(!d)throw new Error("the host built no registry");let w=await Z($.id,d.orgRegistry,d.orgManager);return O=K(w),w.request({method:"GET",url:"/limits"})}});if(m)throw new A(m)}if(e.act!=="empty"){let d=e.act==="undo";n(d?`undo the emptying ${e.runId} of ${e.target}: bring back what it deleted, parents first`:`take up the emptying ${e.runId} of ${e.target} where it stopped`);let m=await Se(a,d?"the undo stops before its next call to the org: --undo again takes up what it left":"the run stops before its next call or job, and keeps its journal: --resume takes it up",()=>y.request({type:d?"dataops:empty:undo":"dataops:empty:run",payload:d?{orgId:$.id,runId:e.runId,...E}:{orgId:$.id,resumeRunId:e.runId,...E,...e.acceptPeopleActive?{acceptPeopleActive:!0}:{}},timeoutMs:Oe}));if(De(h,e.audit),m.answer.outcome!=="answered")throw V(m.answer,d?"The undo":"The run",m.stoppedBy);if(d){let w=L(m.answer).result;for(let F of Xe(e.target,w))n(F);r({runId:e.runId,result:w,...N(w.requestsEstimate,v(),w.requestsSent)}),S(J(w.status,m.stoppedBy))}else{let w=L(m.answer).result;for(let F of Ae(e.target,w))n(F);r({runId:e.runId,result:w,...N(w.requestsEstimate,v(),w.requestsSent)}),S(J(w.status,m.stoppedBy))}return}let _=await y.request({type:"dataops:empty:preview",payload:{orgId:$.id,request:e.request,deleteMode:e.hard?"hard":"recycle",...e.acceptNoUndo?{acceptNoUndo:!0}:{},...e.acceptPeopleActive?{acceptPeopleActive:!0}:{},...e.checkpointFirst?{checkpointFirst:!0}:{},...E},timeoutMs:ze});if(_.outcome!=="answered")throw V(_,"The dry run");let c=L(_);for(let d of Ge(e.target,c))n(d);let b=c.refusals.map(X),j={dryRun:e.dryRun,previewId:c.previewId,readAt:c.readAt,tier:c.tier,preview:c.preview,access:c.access,hardDelete:c.hardDelete,peopleActive:c.peopleActive,...c.checkpoint?{checkpoint:c.checkpoint}:{},...c.openRun?{openRun:c.openRun}:{},automation:c.automation},I=c.preview.cost.api.estimate;if(e.dryRun){for(let d of b)n(` ${ne(d)}`);b.length===0&&n(" a real run would not be refused"),r({...j,...N(I,v(),c.requestsSent),...b.length>0?{wouldBeRefused:b.map(d=>d.message),wouldBeRefusedCodes:b.map(d=>d.code)}:{}}),S(b.length>0?1:0);return}let[U,...q]=b;if(U){process.stderr.write(`${P(U)}
135
- `);for(let d of q)process.stderr.write(`${P(d)}
136
- `);r({...j,...N(I,v(),c.requestsSent),refused:U,...q.length>0?{alsoRefused:q}:{}}),S(1);return}let x=await Se(a,"the run stops before its next call or job, and keeps its journal: --resume takes it up, --undo brings back what it deleted",()=>y.request({type:"dataops:empty:run",payload:{orgId:$.id,previewId:c.previewId,...e.acceptNoUndo?{acceptNoUndo:!0}:{},...e.acceptPeopleActive?{acceptPeopleActive:!0}:{},...e.checkpointFirst?{checkpointFirst:!0}:{},...E},timeoutMs:Oe}));if(De(h,e.audit),x.answer.outcome!=="answered")throw V(x.answer,"The run",x.stoppedBy);let C=L(x.answer).result;for(let d of Ae(e.target,C))n(d);C.runId!==""&&n(`journal: ${g.root}`),r({...j,...N(I,v(),c.requestsSent,C.requestsSent),result:C}),S(J(C.status,x.stoppedBy))}catch(i){let u=i instanceof A?i:new A({code:"FAILED",message:i instanceof Error?i.message:String(i)});process.stderr.write(`${P(u.refusal)}
137
- `);for(let g of u.also)process.stderr.write(`${P(g)}
138
- `);r({refused:u.refusal,...u.also.length>0?{alsoRefused:[...u.also]}:{}}),S(u.code)}finally{a.dispose(),Ne(l,{recursive:!0,force:!0})}}function De(o,t){if(!(t===void 0||o===void 0))try{let e=new G(ae(t)),n=new G(o).list({limit:1e3}).entries;for(let r of[...n].reverse())e.append(r)}catch(e){process.stderr.write(`The entry could not be added to the audit trail in ${t} (${e instanceof Error?e.message:String(e)}).
139
- `)}}process.argv[1]?.includes("sandforge-empty")&&(ie(),Ke().then(()=>process.exit(process.exitCode??0)).catch(o=>{process.stderr.write(`${o instanceof Error?o.message:String(o)}
140
- `),process.exit(1)}));export{N as apiRequestsJson,J as emptyExitCode,Ke as main,Fe as parseArgs,Ge as previewLines,X as refusalWords,qe as runIdOf,Ae as runLines,Xe as undoLines};
132
+ `);for(let l of o.getRunning())l.module===De&&o.abort(l.operationId)});try{let i=await e();return n!==void 0?{answer:i,stoppedBy:n}:{answer:i}}finally{f(),r()}}async function et(o,t,e){if(o.act==="empty")return o.request.mode==="org";if(o.act!=="resume")return!1;try{return(await t.open(e.orgId,o.runId)).head.mode==="org"}catch{return!1}}async function tt(o=process.argv,t={}){let e=Ge(o),n=d=>{process[e.json?"stderr":"stdout"].write(`${d}
133
+ `)},r=d=>{e.json&&process.stdout.write(`${JSON.stringify({tool:_,target:e.target,action:e.act,...d},null,2)}
134
+ `)},f=Te(Ue(Be(),"sandforge-empty-")),i=new we,l,g,s;try{let d=t.checkpointRoot??re(),c=ie({root:d,...t.locksDir!==void 0?{locksDir:t.locksDir}:{}});if("refusal"in c)throw new v({code:"STORE_REFUSED",message:`The org's lock and a checkpoint taken first cannot be kept in ${c.refusal.path}: ${ae(c.refusal,d,"SANDFORGE_JOURNAL_DIR=<folder>")} Nothing was read or deleted.`});let y=c.store,b=new ye(t.journalRoot??me()),O=(t.createHost??be)({storeDir:f,log:a=>{a.startsWith("[WARN] ")&&n(`warning: ${a.slice(7)}`)},compose:a=>{l=a.configStore,g=a,a.handlers.setCheckpointStore(y),a.handlers.setEmptyStores({journals:b,lock:m=>y.lock(m,"empty")}),a.handlers.setInfraServices({backgroundRegistry:i,productionGuard:he(n,e.target)})},onPost:a=>{if(a.type!=="operation:progress")return;let m=a.payload?.currentStep;typeof m!="string"||m===s||(s=m,n(` ${m}`))}}),S=()=>0,A=()=>(O.connectingRequests?.()??0)+S(),R;try{R=await O.connect(e.target)}catch(a){throw new v({code:"NOT_CONNECTED",message:a instanceof oe?`${a.reason} Nothing was read or deleted.`:`${e.target} could not be reached: ${a instanceof Error?a.message:String(a)}. Nothing was read or deleted.`})}let x={...e.accord};if(await et(e,b,R)){let a=g,m=await Re({target:e.target,orgType:R.orgType,limits:async()=>{if(!a)throw new Error("the host built no registry");let w=await Q(R.id,a.orgRegistry,a.orgManager);return S=Z(w),w.request({method:"GET",url:"/limits"})}});if(m)throw new v(m)}if(e.act!=="empty"){let a=e.act==="undo";n(a?`undo the emptying ${e.runId} of ${e.target}: bring back what it deleted, parents first`:`take up the emptying ${e.runId} of ${e.target} where it stopped`);let m=await je(i,a?"the undo stops before its next call to the org: --undo again takes up what it left":"the run stops before its next call or job, and keeps its journal: --resume takes it up",()=>O.request({type:a?"dataops:empty:undo":"dataops:empty:run",payload:a?{orgId:R.id,runId:e.runId,...x}:{orgId:R.id,resumeRunId:e.runId,...x,...e.acceptPeopleActive?{acceptPeopleActive:!0}:{}},timeoutMs:Se}));if(Ie(l,e.audit),m.answer.outcome!=="answered")throw X(m.answer,a?"The undo":"The run",m.stoppedBy);if(a){let w=T(m.answer).result;for(let W of Ze(e.target,w))n(W);r({runId:e.runId,result:w,...L(w.requestsEstimate,A(),w.requestsSent)}),D(V(w.status,m.stoppedBy))}else{let w=T(m.answer).result;for(let W of ve(e.target,w))n(W);r({runId:e.runId,result:w,...L(w.requestsEstimate,A(),w.requestsSent)}),D(V(w.status,m.stoppedBy))}return}let h=await O.request({type:"dataops:empty:preview",payload:{orgId:R.id,request:e.request,deleteMode:e.hard?"hard":"recycle",...e.acceptNoUndo?{acceptNoUndo:!0}:{},...e.acceptPeopleActive?{acceptPeopleActive:!0}:{},...e.checkpointFirst?{checkpointFirst:!0}:{},...x},timeoutMs:Qe});if(h.outcome!=="answered")throw X(h,"The dry run");let p=T(h);for(let a of ze(e.target,p))n(a);let E=p.refusals.map(a=>z(a,p.checkpoint?.refusal)),I={dryRun:e.dryRun,previewId:p.previewId,readAt:p.readAt,tier:p.tier,preview:p.preview,access:p.access,hardDelete:p.hardDelete,peopleActive:p.peopleActive,...p.checkpoint?{checkpoint:p.checkpoint}:{},...p.openRun?{openRun:p.openRun}:{},automation:p.automation},U=p.preview.cost.api.estimate;if(e.dryRun){for(let a of E)n(` ${se(a)}`);E.length===0&&n(" a real run would not be refused"),r({...I,...L(U,A(),p.requestsSent),...E.length>0?{wouldBeRefused:E.map(a=>a.message),wouldBeRefusedCodes:E.map(a=>a.code)}:{}}),D(E.length>0?1:0);return}let[q,...F]=E;if(q){process.stderr.write(`${P(q)}
135
+ `);for(let a of F)process.stderr.write(`${P(a)}
136
+ `);r({...I,...L(U,A(),p.requestsSent),refused:q,...F.length>0?{alsoRefused:F}:{}}),D(1);return}let C=await je(i,"the run stops before its next call or job, and keeps its journal: --resume takes it up, --undo brings back what it deleted",()=>O.request({type:"dataops:empty:run",payload:{orgId:R.id,previewId:p.previewId,...e.acceptNoUndo?{acceptNoUndo:!0}:{},...e.acceptPeopleActive?{acceptPeopleActive:!0}:{},...e.checkpointFirst?{checkpointFirst:!0}:{},...x},timeoutMs:Se}));if(Ie(l,e.audit),C.answer.outcome!=="answered")throw X(C.answer,"The run",C.stoppedBy);let N=T(C.answer).result;for(let a of ve(e.target,N))n(a);N.runId!==""&&n(`journal: ${b.root}`),r({...I,...L(U,A(),p.requestsSent,N.requestsSent),result:N}),D(V(N.status,C.stoppedBy))}catch(d){let c=d instanceof v?d:new v({code:"FAILED",message:d instanceof Error?d.message:String(d)});process.stderr.write(`${P(c.refusal)}
137
+ `);for(let y of c.also)process.stderr.write(`${P(y)}
138
+ `);r({refused:c.refusal,...c.also.length>0?{alsoRefused:[...c.also]}:{}}),D(c.code)}finally{i.dispose(),_e(f,{recursive:!0,force:!0})}}function Ie(o,t){if(!(t===void 0||o===void 0))try{let e=new J(de(t)),n=new J(o).list({limit:1e3}).entries;for(let r of[...n].reverse())e.append(r)}catch(e){process.stderr.write(`The entry could not be added to the audit trail in ${t} (${e instanceof Error?e.message:String(e)}).
139
+ `)}}process.argv[1]?.includes("sandforge-empty")&&(ce(),tt().then(()=>process.exit(process.exitCode??0)).catch(o=>{process.stderr.write(`${o instanceof Error?o.message:String(o)}
140
+ `),process.exit(1)}));export{L as apiRequestsJson,V as emptyExitCode,tt as main,Ge as parseArgs,ze as previewLines,z as refusalWords,He as runIdOf,ve as runLines,Ze as undoLines};