sandforge 0.0.0-stage → 1.79.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 (220) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +54 -2
  3. package/THIRD-PARTY-NOTICES.md +1624 -0
  4. package/bin/sandforge-autopilot.mjs +12 -0
  5. package/bin/sandforge-backup.mjs +12 -0
  6. package/bin/sandforge-checkpoint.mjs +12 -0
  7. package/bin/sandforge-cleanup.mjs +12 -0
  8. package/bin/sandforge-clone.mjs +12 -0
  9. package/bin/sandforge-compare.mjs +12 -0
  10. package/bin/sandforge-dataops.mjs +12 -0
  11. package/bin/sandforge-empty.mjs +12 -0
  12. package/bin/sandforge-env.mjs +12 -0
  13. package/bin/sandforge-frozen.mjs +12 -0
  14. package/bin/sandforge-mcp.mjs +12 -0
  15. package/bin/sandforge-monitor.mjs +12 -0
  16. package/bin/sandforge-seed.mjs +12 -0
  17. package/bin/sandforge-sync.mjs +12 -0
  18. package/bin/sandforge.mjs +12 -0
  19. package/lib/catalogue.en.json +1 -0
  20. package/lib/chunk-2BVTCNWA.mjs +7 -0
  21. package/lib/chunk-2S5OMIIA.mjs +7 -0
  22. package/lib/chunk-2YIV2OB2.mjs +7 -0
  23. package/lib/chunk-342FN7AO.mjs +9 -0
  24. package/lib/chunk-36U7IQ6Y.mjs +25 -0
  25. package/lib/chunk-3CA767QB.mjs +7 -0
  26. package/lib/chunk-3DCUADVK.mjs +7 -0
  27. package/lib/chunk-3F5YMM2F.mjs +7 -0
  28. package/lib/chunk-3OHPD72J.mjs +9 -0
  29. package/lib/chunk-3RYLICRX.mjs +7 -0
  30. package/lib/chunk-3SRXFZSD.mjs +7 -0
  31. package/lib/chunk-42RER7V4.mjs +14 -0
  32. package/lib/chunk-4GL773D5.mjs +7 -0
  33. package/lib/chunk-4HFRHFGQ.mjs +7 -0
  34. package/lib/chunk-4HW535YJ.mjs +7 -0
  35. package/lib/chunk-4NAHW2D3.mjs +7 -0
  36. package/lib/chunk-4SNDMJP2.mjs +7 -0
  37. package/lib/chunk-4TLYUZD5.mjs +7 -0
  38. package/lib/chunk-4U6NXJNL.mjs +7 -0
  39. package/lib/chunk-4XZ5YT5O.mjs +7 -0
  40. package/lib/chunk-55HEMHEG.mjs +7 -0
  41. package/lib/chunk-57VHUYNG.mjs +10 -0
  42. package/lib/chunk-5AJRHRXA.mjs +20 -0
  43. package/lib/chunk-5CD257T7.mjs +7 -0
  44. package/lib/chunk-5HMAPZBV.mjs +7 -0
  45. package/lib/chunk-5LFSFYFJ.mjs +7 -0
  46. package/lib/chunk-5MMXFWPD.mjs +7 -0
  47. package/lib/chunk-5O6JOMHS.mjs +13 -0
  48. package/lib/chunk-5P4PHJRL.mjs +9 -0
  49. package/lib/chunk-5QKTYCWE.mjs +11 -0
  50. package/lib/chunk-66NMFCWX.mjs +7 -0
  51. package/lib/chunk-6EBMEGZB.mjs +7 -0
  52. package/lib/chunk-6LAXTAVN.mjs +7 -0
  53. package/lib/chunk-6MUEPV7M.mjs +9 -0
  54. package/lib/chunk-6QSM2WIH.mjs +10 -0
  55. package/lib/chunk-75ADZS6B.mjs +7 -0
  56. package/lib/chunk-7EANH5PY.mjs +68 -0
  57. package/lib/chunk-7F54PZUS.mjs +7 -0
  58. package/lib/chunk-7UQD6V6F.mjs +7 -0
  59. package/lib/chunk-AAVJ5XVX.mjs +7 -0
  60. package/lib/chunk-ALJVEUUS.mjs +7 -0
  61. package/lib/chunk-ALUFROGA.mjs +7 -0
  62. package/lib/chunk-AR7BE5O2.mjs +7 -0
  63. package/lib/chunk-AUTM6H6Z.mjs +7 -0
  64. package/lib/chunk-AV5SWEHP.mjs +9 -0
  65. package/lib/chunk-B45CNPUX.mjs +47 -0
  66. package/lib/chunk-BILZ3SSR.mjs +7 -0
  67. package/lib/chunk-BN7A4GRQ.mjs +7 -0
  68. package/lib/chunk-BOGNK4LV.mjs +7 -0
  69. package/lib/chunk-BS5T3MOQ.mjs +7 -0
  70. package/lib/chunk-BZ24IAP5.mjs +7 -0
  71. package/lib/chunk-CA5NAXSU.mjs +7 -0
  72. package/lib/chunk-CE6ZDGBB.mjs +7 -0
  73. package/lib/chunk-CGWXQX75.mjs +7 -0
  74. package/lib/chunk-CHCHAE4B.mjs +7 -0
  75. package/lib/chunk-D3QRXG63.mjs +787 -0
  76. package/lib/chunk-DBFJB2B6.mjs +7 -0
  77. package/lib/chunk-DLDX6RRC.mjs +7 -0
  78. package/lib/chunk-EADHKH3A.mjs +7 -0
  79. package/lib/chunk-EEVVGGM6.mjs +7 -0
  80. package/lib/chunk-ENLBYECD.mjs +7 -0
  81. package/lib/chunk-EQF2IJS2.mjs +11 -0
  82. package/lib/chunk-EQOQASDQ.mjs +7 -0
  83. package/lib/chunk-F2424IKX.mjs +7 -0
  84. package/lib/chunk-F74IHMGL.mjs +7 -0
  85. package/lib/chunk-FOVVHGEP.mjs +7 -0
  86. package/lib/chunk-FQBRBBY4.mjs +7 -0
  87. package/lib/chunk-FQGHL7GR.mjs +259 -0
  88. package/lib/chunk-GAM726CK.mjs +7 -0
  89. package/lib/chunk-GCOB7K5N.mjs +7 -0
  90. package/lib/chunk-GMY5427L.mjs +7 -0
  91. package/lib/chunk-GNC27UEU.mjs +7 -0
  92. package/lib/chunk-H2PJNIYJ.mjs +7 -0
  93. package/lib/chunk-H45UXY6G.mjs +7 -0
  94. package/lib/chunk-HCIDVIOW.mjs +7 -0
  95. package/lib/chunk-HF6LAK3G.mjs +7 -0
  96. package/lib/chunk-HJC7AIBK.mjs +7 -0
  97. package/lib/chunk-HJKM3E56.mjs +7 -0
  98. package/lib/chunk-HTJ5OGP5.mjs +7 -0
  99. package/lib/chunk-HUMEKZT5.mjs +8 -0
  100. package/lib/chunk-HV2MXMGI.mjs +7 -0
  101. package/lib/chunk-HXS7ORUF.mjs +11 -0
  102. package/lib/chunk-I3JKJTLO.mjs +110 -0
  103. package/lib/chunk-I7O6C2B5.mjs +8 -0
  104. package/lib/chunk-IAZB4WIL.mjs +7 -0
  105. package/lib/chunk-IC2C2GOF.mjs +8 -0
  106. package/lib/chunk-IEYG5ATY.mjs +7 -0
  107. package/lib/chunk-INIQ23K6.mjs +7 -0
  108. package/lib/chunk-INIT2UKJ.mjs +7 -0
  109. package/lib/chunk-J7HVXMSW.mjs +7 -0
  110. package/lib/chunk-JVL444U5.mjs +7 -0
  111. package/lib/chunk-K22PA4XL.mjs +7 -0
  112. package/lib/chunk-K2FBZIXY.mjs +7 -0
  113. package/lib/chunk-KLX67VPL.mjs +7 -0
  114. package/lib/chunk-L776PUMV.mjs +7 -0
  115. package/lib/chunk-LQ4DRFUH.mjs +9 -0
  116. package/lib/chunk-LRFAIUN7.mjs +7 -0
  117. package/lib/chunk-LV6G4XTK.mjs +7 -0
  118. package/lib/chunk-M6P5ZZLE.mjs +7 -0
  119. package/lib/chunk-MTMH6H2A.mjs +8 -0
  120. package/lib/chunk-MYTIL2JD.mjs +10 -0
  121. package/lib/chunk-NEVXIGR6.mjs +10 -0
  122. package/lib/chunk-NGSMZZDA.mjs +7 -0
  123. package/lib/chunk-NHWE66K5.mjs +7 -0
  124. package/lib/chunk-NM4MDLK4.mjs +7 -0
  125. package/lib/chunk-NTDN2JQZ.mjs +19 -0
  126. package/lib/chunk-NTOVCTRS.mjs +7 -0
  127. package/lib/chunk-NZ5ZZLKS.mjs +7 -0
  128. package/lib/chunk-OQOZAPCI.mjs +7 -0
  129. package/lib/chunk-OTWRDD6L.mjs +7 -0
  130. package/lib/chunk-P2PJYWGQ.mjs +7 -0
  131. package/lib/chunk-P42X3B4D.mjs +7 -0
  132. package/lib/chunk-P7GSGFJO.mjs +7 -0
  133. package/lib/chunk-PA3MKJVH.mjs +7 -0
  134. package/lib/chunk-PBI4BYWW.mjs +7 -0
  135. package/lib/chunk-PNCONNFJ.mjs +10 -0
  136. package/lib/chunk-PTTHSSQO.mjs +7 -0
  137. package/lib/chunk-PUOX4NBJ.mjs +8 -0
  138. package/lib/chunk-PZTSVQSF.mjs +7 -0
  139. package/lib/chunk-QPF6C5MX.mjs +7 -0
  140. package/lib/chunk-QQZZMKU3.mjs +7 -0
  141. package/lib/chunk-QROPNEGY.mjs +14 -0
  142. package/lib/chunk-QRV2OSIS.mjs +7 -0
  143. package/lib/chunk-QSRAEUGZ.mjs +7 -0
  144. package/lib/chunk-QWT2C74M.mjs +7 -0
  145. package/lib/chunk-RAAANPPG.mjs +7 -0
  146. package/lib/chunk-RACDTRZA.mjs +7 -0
  147. package/lib/chunk-RFEO2KAN.mjs +7 -0
  148. package/lib/chunk-RH3N2H7P.mjs +7 -0
  149. package/lib/chunk-RSWDYIHY.mjs +37 -0
  150. package/lib/chunk-RSYICMZG.mjs +8 -0
  151. package/lib/chunk-SAR5622P.mjs +7 -0
  152. package/lib/chunk-SBIMVCXT.mjs +101 -0
  153. package/lib/chunk-SCKUIE3R.mjs +7 -0
  154. package/lib/chunk-SFURUNJM.mjs +7 -0
  155. package/lib/chunk-SIOZXPFG.mjs +7 -0
  156. package/lib/chunk-SRPWW4A2.mjs +10 -0
  157. package/lib/chunk-SRQDABQ2.mjs +15 -0
  158. package/lib/chunk-SVS6UMDU.mjs +323 -0
  159. package/lib/chunk-T63U4OZJ.mjs +7 -0
  160. package/lib/chunk-TBZMC2VV.mjs +11 -0
  161. package/lib/chunk-TEOLMRDO.mjs +7 -0
  162. package/lib/chunk-TLH7AD35.mjs +7 -0
  163. package/lib/chunk-TNXUU6W7.mjs +14 -0
  164. package/lib/chunk-TQX3PURV.mjs +7 -0
  165. package/lib/chunk-TUACWKIH.mjs +7 -0
  166. package/lib/chunk-TW3N6W5Z.mjs +7 -0
  167. package/lib/chunk-TYYOBZMU.mjs +10 -0
  168. package/lib/chunk-TZE3Y7IQ.mjs +7 -0
  169. package/lib/chunk-UNDIBZWG.mjs +7 -0
  170. package/lib/chunk-VGW4MXXZ.mjs +7 -0
  171. package/lib/chunk-VHI54FBK.mjs +441 -0
  172. package/lib/chunk-VXHDBYMI.mjs +7 -0
  173. package/lib/chunk-W7KFAY55.mjs +7 -0
  174. package/lib/chunk-WFEB5X4U.mjs +8 -0
  175. package/lib/chunk-WIO4XO4F.mjs +7 -0
  176. package/lib/chunk-WJY54JO7.mjs +13 -0
  177. package/lib/chunk-WR2GIKWE.mjs +7 -0
  178. package/lib/chunk-WRU5FJFC.mjs +7 -0
  179. package/lib/chunk-X2PY6MWZ.mjs +7 -0
  180. package/lib/chunk-X65MT4W3.mjs +7 -0
  181. package/lib/chunk-XBG5SP6Q.mjs +7 -0
  182. package/lib/chunk-XCA5AONB.mjs +7 -0
  183. package/lib/chunk-XEFDB2R4.mjs +7 -0
  184. package/lib/chunk-XETCPL7E.mjs +7 -0
  185. package/lib/chunk-Y5CGXLUB.mjs +7 -0
  186. package/lib/chunk-Y6J6QFI2.mjs +7 -0
  187. package/lib/chunk-YAZO75G2.mjs +8 -0
  188. package/lib/chunk-YBU4Z4QV.mjs +7 -0
  189. package/lib/chunk-YMJVMFPY.mjs +7 -0
  190. package/lib/chunk-YPSRZRIT.mjs +7 -0
  191. package/lib/chunk-YS4G22C2.mjs +7 -0
  192. package/lib/chunk-YW2SBL4Z.mjs +7 -0
  193. package/lib/chunk-YYZL7UGV.mjs +7 -0
  194. package/lib/chunk-Z7X534S4.mjs +10 -0
  195. package/lib/chunk-ZE6HKRR4.mjs +9 -0
  196. package/lib/chunk-ZHJP7L3K.mjs +7 -0
  197. package/lib/chunk-ZJKCWBRJ.mjs +7 -0
  198. package/lib/chunk-ZLZRU6MO.mjs +7 -0
  199. package/lib/chunk-ZOVSMN5C.mjs +7 -0
  200. package/lib/chunk-ZPYJPGDK.mjs +7 -0
  201. package/lib/chunk-ZQOZ4EFW.mjs +7 -0
  202. package/lib/chunk-ZUTYVST5.mjs +7 -0
  203. package/lib/chunk-ZXH4MBWP.mjs +7 -0
  204. package/lib/chunk-ZYEE34WO.mjs +7 -0
  205. package/lib/sandforge-autopilot.mjs +157 -0
  206. package/lib/sandforge-backup.mjs +99 -0
  207. package/lib/sandforge-checkpoint.mjs +353 -0
  208. package/lib/sandforge-cleanup.mjs +56 -0
  209. package/lib/sandforge-clone.mjs +7 -0
  210. package/lib/sandforge-compare.mjs +54 -0
  211. package/lib/sandforge-dataops.mjs +7 -0
  212. package/lib/sandforge-empty.mjs +140 -0
  213. package/lib/sandforge-env.mjs +355 -0
  214. package/lib/sandforge-frozen.mjs +263 -0
  215. package/lib/sandforge-mcp.mjs +40 -0
  216. package/lib/sandforge-monitor.mjs +43 -0
  217. package/lib/sandforge-seed.mjs +7 -0
  218. package/lib/sandforge-sync.mjs +7 -0
  219. package/lib/sandforge.mjs +28 -0
  220. package/package.json +52 -4
@@ -0,0 +1,54 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{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.
8
+
9
+ Usage:
10
+ npx sandforge compare --source <alias> --target <alias> [options]
11
+
12
+ Required:
13
+ --source <alias> sf CLI alias of the source org
14
+ --target <alias> sf CLI alias of the target org
15
+
16
+ Options:
17
+ --op <name> execute | permissions | snapshots | drift |
18
+ validate-deployment; repeat for more
19
+ (default: the first four, or validate-deployment
20
+ alone when --validate is given)
21
+ --type <Type> a metadata category to diff (execute); repeat for more
22
+ --all-types every category the page offers, as "Select all" does
23
+ --exclude-managed leave out what a managed package installed (execute),
24
+ as the page does with its box unticked
25
+ --validate <Type:Name> a component to validate a deployment of, from the
26
+ source to the target; repeat for more
27
+ --tests <level> the Apex tests the validation runs: NoTestRun |
28
+ RunLocalTests | RunSpecifiedTests (default: NoTestRun)
29
+ --run-test <Class> a test class RunSpecifiedTests runs; repeat for more
30
+ --store <dir> where the host keeps its config store, a folder of your
31
+ own (default: ~/.sandforge/compare, under the folder
32
+ SANDFORGE_JOURNAL_DIR names when it is set)
33
+ --wait <seconds> how long to keep waiting for an answer (default: 300)
34
+ --fail-on-drift exit 3 when a diff (execute) finds a component added,
35
+ removed or modified (default: off)
36
+ --json emit what the page would receive, every other line on
37
+ stderr
38
+ --help this text
39
+
40
+ Nothing is written to either org. A validation deploys check-only: the
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.
43
+
44
+ Exit codes: 0 every request was answered, and every validation succeeded (a
45
+ diff is read, whatever it found, unless --fail-on-drift); 1 it could not
46
+ start, or a request failed, was refused or was not answered in time; 2 a bad
47
+ command line; 3 a validation came back with no success, a component error or
48
+ 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};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{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};
@@ -0,0 +1,140 @@
1
+ import { createRequire as __sandforgeRequire } from 'node:module';
2
+ import { fileURLToPath as __sandforgePath } from 'node:url';
3
+ import { dirname as __sandforgeDirname } from 'node:path';
4
+ const require = __sandforgeRequire(import.meta.url);
5
+ const __filename = __sandforgePath(import.meta.url);
6
+ const __dirname = __sandforgeDirname(__filename);
7
+ import{a as 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:
8
+ a dry run first, then the deletes, to the recycle bin with an undo, or for good.
9
+
10
+ Usage:
11
+ npx sandforge empty --target <alias> (--objects <A,B> | --org [--exclude-object <ApiName>]...) (--dry-run | --yes) [options]
12
+ npx sandforge empty --target <alias> --undo <run> --yes [options]
13
+ npx sandforge empty --target <alias> --resume <run> --yes [options]
14
+
15
+ Required:
16
+ --target <alias> sf CLI alias of the sandbox, scratch org or Developer
17
+ Edition org to empty. A production org is refused
18
+ before anything is read, and nothing lifts it.
19
+ --objects <A,B> empty these objects, by API name, comma-separated:
20
+ every record of each, and what the org deletes along
21
+ with them
22
+ --org empty every object people work in, as checkpoints
23
+ read them: never users, profiles, setup, Chatter,
24
+ history, sharing, the org's flows, settings and
25
+ definitions, or the standard price book. Refused on
26
+ a Partial Copy or Full sandbox (COPY_SANDBOX, below)
27
+ --dry-run read the org and say everything a run would do and
28
+ meet, deleting nothing; exit 1 when a run would be
29
+ refused, its refusals listed
30
+ --yes empty: the dry run is read and said first, and the
31
+ run goes only when nothing refuses it. Without
32
+ --dry-run or --yes, refused, exit 1: this command
33
+ asks no question
34
+
35
+ Options of --org:
36
+ --exclude-object <ApiName>
37
+ leave this object out, named in the dry run;
38
+ repeat it for several
39
+ --custom-settings empty the custom settings too (left out unless given)
40
+ --files empty the files and attachments too (left out unless
41
+ given)
42
+ --managed-packages empty the objects of managed packages too (left out
43
+ unless given)
44
+ --unrestorable empty too, by passes of their own, the objects whose
45
+ records Salesforce does not bring back from the
46
+ recycle bin on their own (left out unless given;
47
+ what they hold under a record emptied goes along
48
+ with it all the same). What their passes send is
49
+ said beyond Undo: NO_UNDO, exit 1, without
50
+ --accept-no-undo
51
+
52
+ Options:
53
+ --hard-delete delete for good, with what goes along: nothing goes
54
+ to the recycle bin and no undo brings anything back.
55
+ Needs the user's Bulk API Hard Delete permission,
56
+ read before anything is deleted:
57
+ HARD_DELETE_NOT_PERMITTED, exit 1, without it
58
+ --accept-no-undo empty although some records go before a record they
59
+ name, as Salesforce requires, so that once both have
60
+ gone Undo cannot bring them back: NO_UNDO, exit 1,
61
+ without it
62
+ --accept-people-active empty although people other than the user changed
63
+ records of these objects in the hour before the
64
+ read, their work going with it: the dry run says how
65
+ many, each by user Id with their last change.
66
+ PEOPLE_ACTIVE, exit 1, without it. It covers the
67
+ people the dry run named: anyone at work since
68
+ refuses the run all the same
69
+ --checkpoint-first take a checkpoint of the objects emptied before the
70
+ first delete, to rewind to (sandforge checkpoint);
71
+ refused past 500,000 records or the disk's room, and
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
74
+ kept in <file>: the entry the panel keeps in Reports ->
75
+ Audit trail, counts only. Not with --dry-run,
76
+ which adds none
77
+ --json print the answer as JSON on stdout, every other line on
78
+ stderr
79
+ -h, --help show this help and exit
80
+
81
+ Undo and resume:
82
+ --undo <run> bring back from the recycle bin what the org's last
83
+ emptying deleted, parents first, while the bin holds
84
+ them; refused for a run that deleted for good. <run>
85
+ is its id (em-...), or the folder of its journal
86
+ --resume <run> take up the org's last emptying where it stopped, on
87
+ what its journal confirmed: records already gone count
88
+ as deleted
89
+ Both need --yes, and take --accept-automation, --accept-emails,
90
+ --mute-automation and --audit; --resume takes --accept-people-active too.
91
+
92
+ Before it deletes, it says per object the records it deletes and what goes
93
+ along, in the order it takes them; what will likely refuse, and what it does
94
+ first so that it does not (an activated order set back to Draft); the records
95
+ of objects left that block a delete; what no undo would bring back; what is
96
+ left out and why; the API requests, Bulk API batches and time it takes against
97
+ what the org has left today, and the recycle bin's load; what the user is not
98
+ proven to see; and what the org runs as the records go, and its emails.
99
+
100
+ It is refused, exit 1, before anything is deleted, every refusal said: a
101
+ production org; another act of this machine writing to the org; the org's last
102
+ emptying stopped part way (resume or undo it first); someone else changing
103
+ records of these objects in the last hour, unless --accept-people-active
104
+ lets their work go; more requests or batches than the
105
+ org has left today; the automation, emails and mute, as every DataOps act asks
106
+ them; a checkpoint refused; and the org changed since the dry run beyond what
107
+ it showed. A sandbox marked Staging in the extension, whose whole the panel
108
+ never empties, is not known here: the command registers the org afresh, from
109
+ what it says it is. So the whole of a Partial Copy or Full sandbox, read from
110
+ its data storage \u2014 past the 1 GB of a Developer Pro sandbox \u2014 is refused,
111
+ --org and a --resume of such a run alike (COPY_SANDBOX), before anything is
112
+ read: empty it whole from DataOps Cleanup in the panel, which knows the mark,
113
+ or pick its objects with --objects, which Production Guard asks about. A
114
+ scratch org and a Developer or Developer Pro sandbox are emptied whole.
115
+
116
+ Journals are kept in empty/ under the folder SANDFORGE_JOURNAL_DIR names
117
+ (~/.sandforge by default), shared with the panel. Undo reaches the org's last
118
+ emptying alone.
119
+
120
+ Exit codes:
121
+ 0 emptied, or a dry run nothing would refuse
122
+ 1 refused before anything was deleted, or nothing went through
123
+ 2 a bad command line
124
+ 3 partial: records the org refused, each said with why
125
+ 130, 143, 129 a Ctrl-C, a SIGTERM or a SIGHUP stopped it before its next
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(`
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};