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.
- package/LICENSE +21 -0
- package/README.md +54 -2
- package/THIRD-PARTY-NOTICES.md +1624 -0
- package/bin/sandforge-autopilot.mjs +12 -0
- package/bin/sandforge-backup.mjs +12 -0
- package/bin/sandforge-checkpoint.mjs +12 -0
- package/bin/sandforge-cleanup.mjs +12 -0
- package/bin/sandforge-clone.mjs +12 -0
- package/bin/sandforge-compare.mjs +12 -0
- package/bin/sandforge-dataops.mjs +12 -0
- package/bin/sandforge-empty.mjs +12 -0
- package/bin/sandforge-env.mjs +12 -0
- package/bin/sandforge-frozen.mjs +12 -0
- package/bin/sandforge-mcp.mjs +12 -0
- package/bin/sandforge-monitor.mjs +12 -0
- package/bin/sandforge-seed.mjs +12 -0
- package/bin/sandforge-sync.mjs +12 -0
- package/bin/sandforge.mjs +12 -0
- package/lib/catalogue.en.json +1 -0
- package/lib/chunk-2BVTCNWA.mjs +7 -0
- package/lib/chunk-2S5OMIIA.mjs +7 -0
- package/lib/chunk-2YIV2OB2.mjs +7 -0
- package/lib/chunk-342FN7AO.mjs +9 -0
- package/lib/chunk-36U7IQ6Y.mjs +25 -0
- package/lib/chunk-3CA767QB.mjs +7 -0
- package/lib/chunk-3DCUADVK.mjs +7 -0
- package/lib/chunk-3F5YMM2F.mjs +7 -0
- package/lib/chunk-3OHPD72J.mjs +9 -0
- package/lib/chunk-3RYLICRX.mjs +7 -0
- package/lib/chunk-3SRXFZSD.mjs +7 -0
- package/lib/chunk-42RER7V4.mjs +14 -0
- package/lib/chunk-4GL773D5.mjs +7 -0
- package/lib/chunk-4HFRHFGQ.mjs +7 -0
- package/lib/chunk-4HW535YJ.mjs +7 -0
- package/lib/chunk-4NAHW2D3.mjs +7 -0
- package/lib/chunk-4SNDMJP2.mjs +7 -0
- package/lib/chunk-4TLYUZD5.mjs +7 -0
- package/lib/chunk-4U6NXJNL.mjs +7 -0
- package/lib/chunk-4XZ5YT5O.mjs +7 -0
- package/lib/chunk-55HEMHEG.mjs +7 -0
- package/lib/chunk-57VHUYNG.mjs +10 -0
- package/lib/chunk-5AJRHRXA.mjs +20 -0
- package/lib/chunk-5CD257T7.mjs +7 -0
- package/lib/chunk-5HMAPZBV.mjs +7 -0
- package/lib/chunk-5LFSFYFJ.mjs +7 -0
- package/lib/chunk-5MMXFWPD.mjs +7 -0
- package/lib/chunk-5O6JOMHS.mjs +13 -0
- package/lib/chunk-5P4PHJRL.mjs +9 -0
- package/lib/chunk-5QKTYCWE.mjs +11 -0
- package/lib/chunk-66NMFCWX.mjs +7 -0
- package/lib/chunk-6EBMEGZB.mjs +7 -0
- package/lib/chunk-6LAXTAVN.mjs +7 -0
- package/lib/chunk-6MUEPV7M.mjs +9 -0
- package/lib/chunk-6QSM2WIH.mjs +10 -0
- package/lib/chunk-75ADZS6B.mjs +7 -0
- package/lib/chunk-7EANH5PY.mjs +68 -0
- package/lib/chunk-7F54PZUS.mjs +7 -0
- package/lib/chunk-7UQD6V6F.mjs +7 -0
- package/lib/chunk-AAVJ5XVX.mjs +7 -0
- package/lib/chunk-ALJVEUUS.mjs +7 -0
- package/lib/chunk-ALUFROGA.mjs +7 -0
- package/lib/chunk-AR7BE5O2.mjs +7 -0
- package/lib/chunk-AUTM6H6Z.mjs +7 -0
- package/lib/chunk-AV5SWEHP.mjs +9 -0
- package/lib/chunk-B45CNPUX.mjs +47 -0
- package/lib/chunk-BILZ3SSR.mjs +7 -0
- package/lib/chunk-BN7A4GRQ.mjs +7 -0
- package/lib/chunk-BOGNK4LV.mjs +7 -0
- package/lib/chunk-BS5T3MOQ.mjs +7 -0
- package/lib/chunk-BZ24IAP5.mjs +7 -0
- package/lib/chunk-CA5NAXSU.mjs +7 -0
- package/lib/chunk-CE6ZDGBB.mjs +7 -0
- package/lib/chunk-CGWXQX75.mjs +7 -0
- package/lib/chunk-CHCHAE4B.mjs +7 -0
- package/lib/chunk-D3QRXG63.mjs +787 -0
- package/lib/chunk-DBFJB2B6.mjs +7 -0
- package/lib/chunk-DLDX6RRC.mjs +7 -0
- package/lib/chunk-EADHKH3A.mjs +7 -0
- package/lib/chunk-EEVVGGM6.mjs +7 -0
- package/lib/chunk-ENLBYECD.mjs +7 -0
- package/lib/chunk-EQF2IJS2.mjs +11 -0
- package/lib/chunk-EQOQASDQ.mjs +7 -0
- package/lib/chunk-F2424IKX.mjs +7 -0
- package/lib/chunk-F74IHMGL.mjs +7 -0
- package/lib/chunk-FOVVHGEP.mjs +7 -0
- package/lib/chunk-FQBRBBY4.mjs +7 -0
- package/lib/chunk-FQGHL7GR.mjs +259 -0
- package/lib/chunk-GAM726CK.mjs +7 -0
- package/lib/chunk-GCOB7K5N.mjs +7 -0
- package/lib/chunk-GMY5427L.mjs +7 -0
- package/lib/chunk-GNC27UEU.mjs +7 -0
- package/lib/chunk-H2PJNIYJ.mjs +7 -0
- package/lib/chunk-H45UXY6G.mjs +7 -0
- package/lib/chunk-HCIDVIOW.mjs +7 -0
- package/lib/chunk-HF6LAK3G.mjs +7 -0
- package/lib/chunk-HJC7AIBK.mjs +7 -0
- package/lib/chunk-HJKM3E56.mjs +7 -0
- package/lib/chunk-HTJ5OGP5.mjs +7 -0
- package/lib/chunk-HUMEKZT5.mjs +8 -0
- package/lib/chunk-HV2MXMGI.mjs +7 -0
- package/lib/chunk-HXS7ORUF.mjs +11 -0
- package/lib/chunk-I3JKJTLO.mjs +110 -0
- package/lib/chunk-I7O6C2B5.mjs +8 -0
- package/lib/chunk-IAZB4WIL.mjs +7 -0
- package/lib/chunk-IC2C2GOF.mjs +8 -0
- package/lib/chunk-IEYG5ATY.mjs +7 -0
- package/lib/chunk-INIQ23K6.mjs +7 -0
- package/lib/chunk-INIT2UKJ.mjs +7 -0
- package/lib/chunk-J7HVXMSW.mjs +7 -0
- package/lib/chunk-JVL444U5.mjs +7 -0
- package/lib/chunk-K22PA4XL.mjs +7 -0
- package/lib/chunk-K2FBZIXY.mjs +7 -0
- package/lib/chunk-KLX67VPL.mjs +7 -0
- package/lib/chunk-L776PUMV.mjs +7 -0
- package/lib/chunk-LQ4DRFUH.mjs +9 -0
- package/lib/chunk-LRFAIUN7.mjs +7 -0
- package/lib/chunk-LV6G4XTK.mjs +7 -0
- package/lib/chunk-M6P5ZZLE.mjs +7 -0
- package/lib/chunk-MTMH6H2A.mjs +8 -0
- package/lib/chunk-MYTIL2JD.mjs +10 -0
- package/lib/chunk-NEVXIGR6.mjs +10 -0
- package/lib/chunk-NGSMZZDA.mjs +7 -0
- package/lib/chunk-NHWE66K5.mjs +7 -0
- package/lib/chunk-NM4MDLK4.mjs +7 -0
- package/lib/chunk-NTDN2JQZ.mjs +19 -0
- package/lib/chunk-NTOVCTRS.mjs +7 -0
- package/lib/chunk-NZ5ZZLKS.mjs +7 -0
- package/lib/chunk-OQOZAPCI.mjs +7 -0
- package/lib/chunk-OTWRDD6L.mjs +7 -0
- package/lib/chunk-P2PJYWGQ.mjs +7 -0
- package/lib/chunk-P42X3B4D.mjs +7 -0
- package/lib/chunk-P7GSGFJO.mjs +7 -0
- package/lib/chunk-PA3MKJVH.mjs +7 -0
- package/lib/chunk-PBI4BYWW.mjs +7 -0
- package/lib/chunk-PNCONNFJ.mjs +10 -0
- package/lib/chunk-PTTHSSQO.mjs +7 -0
- package/lib/chunk-PUOX4NBJ.mjs +8 -0
- package/lib/chunk-PZTSVQSF.mjs +7 -0
- package/lib/chunk-QPF6C5MX.mjs +7 -0
- package/lib/chunk-QQZZMKU3.mjs +7 -0
- package/lib/chunk-QROPNEGY.mjs +14 -0
- package/lib/chunk-QRV2OSIS.mjs +7 -0
- package/lib/chunk-QSRAEUGZ.mjs +7 -0
- package/lib/chunk-QWT2C74M.mjs +7 -0
- package/lib/chunk-RAAANPPG.mjs +7 -0
- package/lib/chunk-RACDTRZA.mjs +7 -0
- package/lib/chunk-RFEO2KAN.mjs +7 -0
- package/lib/chunk-RH3N2H7P.mjs +7 -0
- package/lib/chunk-RSWDYIHY.mjs +37 -0
- package/lib/chunk-RSYICMZG.mjs +8 -0
- package/lib/chunk-SAR5622P.mjs +7 -0
- package/lib/chunk-SBIMVCXT.mjs +101 -0
- package/lib/chunk-SCKUIE3R.mjs +7 -0
- package/lib/chunk-SFURUNJM.mjs +7 -0
- package/lib/chunk-SIOZXPFG.mjs +7 -0
- package/lib/chunk-SRPWW4A2.mjs +10 -0
- package/lib/chunk-SRQDABQ2.mjs +15 -0
- package/lib/chunk-SVS6UMDU.mjs +323 -0
- package/lib/chunk-T63U4OZJ.mjs +7 -0
- package/lib/chunk-TBZMC2VV.mjs +11 -0
- package/lib/chunk-TEOLMRDO.mjs +7 -0
- package/lib/chunk-TLH7AD35.mjs +7 -0
- package/lib/chunk-TNXUU6W7.mjs +14 -0
- package/lib/chunk-TQX3PURV.mjs +7 -0
- package/lib/chunk-TUACWKIH.mjs +7 -0
- package/lib/chunk-TW3N6W5Z.mjs +7 -0
- package/lib/chunk-TYYOBZMU.mjs +10 -0
- package/lib/chunk-TZE3Y7IQ.mjs +7 -0
- package/lib/chunk-UNDIBZWG.mjs +7 -0
- package/lib/chunk-VGW4MXXZ.mjs +7 -0
- package/lib/chunk-VHI54FBK.mjs +441 -0
- package/lib/chunk-VXHDBYMI.mjs +7 -0
- package/lib/chunk-W7KFAY55.mjs +7 -0
- package/lib/chunk-WFEB5X4U.mjs +8 -0
- package/lib/chunk-WIO4XO4F.mjs +7 -0
- package/lib/chunk-WJY54JO7.mjs +13 -0
- package/lib/chunk-WR2GIKWE.mjs +7 -0
- package/lib/chunk-WRU5FJFC.mjs +7 -0
- package/lib/chunk-X2PY6MWZ.mjs +7 -0
- package/lib/chunk-X65MT4W3.mjs +7 -0
- package/lib/chunk-XBG5SP6Q.mjs +7 -0
- package/lib/chunk-XCA5AONB.mjs +7 -0
- package/lib/chunk-XEFDB2R4.mjs +7 -0
- package/lib/chunk-XETCPL7E.mjs +7 -0
- package/lib/chunk-Y5CGXLUB.mjs +7 -0
- package/lib/chunk-Y6J6QFI2.mjs +7 -0
- package/lib/chunk-YAZO75G2.mjs +8 -0
- package/lib/chunk-YBU4Z4QV.mjs +7 -0
- package/lib/chunk-YMJVMFPY.mjs +7 -0
- package/lib/chunk-YPSRZRIT.mjs +7 -0
- package/lib/chunk-YS4G22C2.mjs +7 -0
- package/lib/chunk-YW2SBL4Z.mjs +7 -0
- package/lib/chunk-YYZL7UGV.mjs +7 -0
- package/lib/chunk-Z7X534S4.mjs +10 -0
- package/lib/chunk-ZE6HKRR4.mjs +9 -0
- package/lib/chunk-ZHJP7L3K.mjs +7 -0
- package/lib/chunk-ZJKCWBRJ.mjs +7 -0
- package/lib/chunk-ZLZRU6MO.mjs +7 -0
- package/lib/chunk-ZOVSMN5C.mjs +7 -0
- package/lib/chunk-ZPYJPGDK.mjs +7 -0
- package/lib/chunk-ZQOZ4EFW.mjs +7 -0
- package/lib/chunk-ZUTYVST5.mjs +7 -0
- package/lib/chunk-ZXH4MBWP.mjs +7 -0
- package/lib/chunk-ZYEE34WO.mjs +7 -0
- package/lib/sandforge-autopilot.mjs +157 -0
- package/lib/sandforge-backup.mjs +99 -0
- package/lib/sandforge-checkpoint.mjs +353 -0
- package/lib/sandforge-cleanup.mjs +56 -0
- package/lib/sandforge-clone.mjs +7 -0
- package/lib/sandforge-compare.mjs +54 -0
- package/lib/sandforge-dataops.mjs +7 -0
- package/lib/sandforge-empty.mjs +140 -0
- package/lib/sandforge-env.mjs +355 -0
- package/lib/sandforge-frozen.mjs +263 -0
- package/lib/sandforge-mcp.mjs +40 -0
- package/lib/sandforge-monitor.mjs +43 -0
- package/lib/sandforge-seed.mjs +7 -0
- package/lib/sandforge-sync.mjs +7 -0
- package/lib/sandforge.mjs +28 -0
- package/package.json +52 -4
|
@@ -0,0 +1,353 @@
|
|
|
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"./chunk-RFEO2KAN.mjs";import{b as tt}from"./chunk-ALUFROGA.mjs";import{b as Qe,n as et}from"./chunk-TBZMC2VV.mjs";import{e as ne}from"./chunk-5QKTYCWE.mjs";import{a as Ke,b as J,c as Ye,d as V,f as Xe,i as Ze,k as re}from"./chunk-LQ4DRFUH.mjs";import{f as ze}from"./chunk-57VHUYNG.mjs";import"./chunk-5O6JOMHS.mjs";import{a as We,b as qe}from"./chunk-HUMEKZT5.mjs";import"./chunk-MYTIL2JD.mjs";import{e as nt}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 ot}from"./chunk-TW3N6W5Z.mjs";import"./chunk-5P4PHJRL.mjs";import{a as Ge,b as ae,c as Je}from"./chunk-QROPNEGY.mjs";import{b as Q,e as Ie}from"./chunk-BZ24IAP5.mjs";import{c as ee}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{hb as Pe}from"./chunk-YMJVMFPY.mjs";import"./chunk-ALJVEUUS.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-4HFRHFGQ.mjs";import{a as Be,n as Fe,o as Ue}from"./chunk-342FN7AO.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-36U7IQ6Y.mjs";import"./chunk-XETCPL7E.mjs";import"./chunk-K2FBZIXY.mjs";import"./chunk-Z7X534S4.mjs";import{C as Le}from"./chunk-6QSM2WIH.mjs";import"./chunk-WJY54JO7.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import{H as Me,e as G,i as _e}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 Ne}from"./chunk-L776PUMV.mjs";import{A as te,q as Oe,u as Te}from"./chunk-6MUEPV7M.mjs";import"./chunk-HJC7AIBK.mjs";import"./chunk-OTWRDD6L.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-RH3N2H7P.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-55HEMHEG.mjs";import"./chunk-P42X3B4D.mjs";import"./chunk-TUACWKIH.mjs";import{Ia as He}from"./chunk-VXHDBYMI.mjs";import"./chunk-ENLBYECD.mjs";import{k as De}from"./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{ca as Ee}from"./chunk-CGWXQX75.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-SIOZXPFG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import{a as xe,e as B,g as Ve}from"./chunk-MTMH6H2A.mjs";import{Sc as se,Vc as Se,cc as Ce,ra as je,va as Re}from"./chunk-B45CNPUX.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-SBIMVCXT.mjs";import"./chunk-NTOVCTRS.mjs";import{mkdtempSync as Jt,readFileSync as Vt,rmSync as zt}from"node:fs";import{tmpdir as Kt}from"node:os";import{join as ct,resolve as de}from"node:path";var Yt=`sandforge checkpoint \u2014 take a checkpoint of an org's data, and rewind the org to it, without the editor.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
npx sandforge checkpoint <command> --org <alias> [options]
|
|
11
|
+
|
|
12
|
+
Commands:
|
|
13
|
+
take read the org's records and keep them as a checkpoint on this machine
|
|
14
|
+
list name the checkpoints kept, newest first, with what a rewind and an undo can still reach
|
|
15
|
+
preview say what a rewind would delete, give back and bring back, who last changed it, and what
|
|
16
|
+
it and an undo cannot take back; writes nothing
|
|
17
|
+
rewind return the org to a checkpoint: bring back from the recycle bin the records deleted
|
|
18
|
+
since, give the records changed since their values back, delete the records created
|
|
19
|
+
since, and put the files attached to its records back as they were \u2014 whoever made the
|
|
20
|
+
changes; keep what it changes so it can be undone; then read the org again
|
|
21
|
+
undo take back the org's last rewind: bring back what it deleted, give back what it wrote
|
|
22
|
+
over, send back to the bin what it brought back; what anyone changed since the rewind
|
|
23
|
+
stays, and is said
|
|
24
|
+
delete delete a checkpoint from this machine; the org is not touched
|
|
25
|
+
export write a checkpoint to a .sfcheckpoint file, encrypted, for a teammate who rewinds the
|
|
26
|
+
same org from another machine; the org is not contacted
|
|
27
|
+
import keep a .sfcheckpoint file a teammate exported as a checkpoint of the org on this
|
|
28
|
+
machine, once the org answers that it is the file's, and its user sees all data
|
|
29
|
+
|
|
30
|
+
Required:
|
|
31
|
+
--org <alias> sf CLI alias of the org (list: every org of the store without it)
|
|
32
|
+
|
|
33
|
+
take:
|
|
34
|
+
--name <text> what it is called (default: the date and time)
|
|
35
|
+
--object <ApiName> an object to keep; repeat for more (default: every object people
|
|
36
|
+
work in, empty ones included, setup and log objects left out)
|
|
37
|
+
--exclude-object <ApiName> leave an object out; repeat for more
|
|
38
|
+
--custom-setting <ApiName|all> keep a custom setting, or all of them, which a checkpoint leaves
|
|
39
|
+
out unless named: a rewind sets their rows back, an integration's
|
|
40
|
+
endpoint or an admin's switch among them; repeat for more; needs
|
|
41
|
+
Customize Application
|
|
42
|
+
--ignore-field <Object.Field> do not compare a field, nor write it back (one your automation sets
|
|
43
|
+
on every save); repeat for more
|
|
44
|
+
--max-total <n> refuse, before reading, more than <n> records (default: ${We})
|
|
45
|
+
--keep-days <n> when it expires (default: ${G}; 0 keeps it until deleted)
|
|
46
|
+
--estimate say the records, API requests, time and disk it would take, then stop
|
|
47
|
+
preview, rewind, undo, delete, export:
|
|
48
|
+
--checkpoint <id|name|latest> which one (default: latest, for undo the one the last rewind went
|
|
49
|
+
back to; rewind and undo with --yes need it named, by id or name)
|
|
50
|
+
preview, rewind:
|
|
51
|
+
--object <ApiName> limit the rewind to an object of the checkpoint; repeat for more
|
|
52
|
+
(default: every object). It writes the others only to delete again
|
|
53
|
+
the records made since that come back with a record it brings
|
|
54
|
+
back, and never adds what the objects named depend on: what it
|
|
55
|
+
leaves of them for that is said, with the --object to add
|
|
56
|
+
preview:
|
|
57
|
+
--fail-on-change exit 3 when the org differs from the checkpoint
|
|
58
|
+
rewind:
|
|
59
|
+
--dry-run the preview, then stop
|
|
60
|
+
--accept-automation rewind even when the org runs flows, Apex triggers, processes or
|
|
61
|
+
workflow rules as records are updated, deleted or brought back;
|
|
62
|
+
without it such a rewind writes nothing, exit 1
|
|
63
|
+
--accept-emails rewind even when the org delivers every email its automation
|
|
64
|
+
sends (Setup > Deliverability: All email), or would not say
|
|
65
|
+
whether it does, and what still runs as it writes sends some:
|
|
66
|
+
they go to the addresses the records and the alerts name, and to
|
|
67
|
+
the records' owners. Without it such a rewind writes nothing,
|
|
68
|
+
exit 1. --accept-automation never stands for it. Read with one
|
|
69
|
+
line of anonymous Apex that sends nothing, only when something
|
|
70
|
+
that still runs sends an email; what Apex triggers send is not
|
|
71
|
+
read
|
|
72
|
+
--mute-automation mute the org's automation for the rewind through its own bypass:
|
|
73
|
+
assign the user it writes as, for the rewind alone, the permission
|
|
74
|
+
sets holding the custom permissions its flows, processes and
|
|
75
|
+
workflow rules test to stay quiet, and take them back as it ends;
|
|
76
|
+
what no bypass keeps quiet still runs, and still needs
|
|
77
|
+
--accept-automation. Refused on a production org and for a user
|
|
78
|
+
who cannot assign permission sets, exit 1; with --dry-run, says
|
|
79
|
+
what would be muted, or why it would be refused, and assigns
|
|
80
|
+
nothing
|
|
81
|
+
--accept-no-undo rewind even when undo could not bring back some records it deletes
|
|
82
|
+
(objects Salesforce undeletes only with their parent, such as
|
|
83
|
+
OpportunityLineItem); without it such a rewind writes nothing, exit 1
|
|
84
|
+
--accept-recreate make again, with new Ids, the records deleted since that the
|
|
85
|
+
recycle bin no longer gives back: what outside Salesforce names
|
|
86
|
+
their old Ids no longer finds them; without it a rewind that
|
|
87
|
+
counts such records writes nothing, exit 1, and one Salesforce
|
|
88
|
+
answers is no longer in the bin as it brings it back is left,
|
|
89
|
+
named
|
|
90
|
+
--accept-outside (a checkpoint of picked objects) also delete the records outside it
|
|
91
|
+
created under records it deletes, and the files it deletes that are
|
|
92
|
+
attached outside it too; without it those parents stay, and those
|
|
93
|
+
files are only removed from its records
|
|
94
|
+
--accept-unseen (a user without View All Data and Modify All Data) delete records
|
|
95
|
+
whose delete takes along records of objects the user is not
|
|
96
|
+
proven to see whole \u2014 tasks and events always: the preview names
|
|
97
|
+
those objects, and no count holds what goes with them; without it
|
|
98
|
+
such a rewind writes nothing, exit 1
|
|
99
|
+
--max-records <n> refuse, before it writes, a rewind that would delete, give back,
|
|
100
|
+
bring back and make again more than <n> records together, exit 1:
|
|
101
|
+
with --yes in a cron job or a CI step, what stands in for reading
|
|
102
|
+
the preview
|
|
103
|
+
--refuse-when-active refuse, before it writes, a rewind of an org where anyone but the
|
|
104
|
+
user it writes as and the org's Automated Process changed records
|
|
105
|
+
of the checkpoint's objects in the hour before it read the org,
|
|
106
|
+
whose work it would take back, exit 1; the refusal says how many
|
|
107
|
+
people. Where people sign in as the user SandForge connects as,
|
|
108
|
+
their changes are that user's, and are not told apart
|
|
109
|
+
--ignore-field <Object.Field> stop comparing a field from now on; kept in the checkpoint
|
|
110
|
+
--yes do not ask before writing; without it and with no terminal \u2014 a CI
|
|
111
|
+
step \u2014 it stops at its question, exit 2, having written nothing
|
|
112
|
+
undo:
|
|
113
|
+
--accept-automation as for rewind
|
|
114
|
+
--accept-emails as for rewind
|
|
115
|
+
--mute-automation as for rewind
|
|
116
|
+
--yes as for rewind
|
|
117
|
+
delete:
|
|
118
|
+
--all every checkpoint of the org
|
|
119
|
+
--yes do not ask
|
|
120
|
+
export:
|
|
121
|
+
--out <file> the file to write; refused when one is there already
|
|
122
|
+
--key-env <VAR> encrypt under the key this environment variable holds, one an
|
|
123
|
+
export showed (a CI step's secret); without it a new key is
|
|
124
|
+
drawn and shown once, on stderr
|
|
125
|
+
import:
|
|
126
|
+
--file <file> the .sfcheckpoint file
|
|
127
|
+
--key-env <VAR> read the key from this environment variable; without it the key
|
|
128
|
+
is asked on the terminal, not echoed, and with no terminal it
|
|
129
|
+
stops, exit 2, having imported nothing
|
|
130
|
+
--keep-days <n> when it expires on this machine (default: ${G}; 0 keeps it until
|
|
131
|
+
deleted)
|
|
132
|
+
Options:
|
|
133
|
+
--store <dir> where checkpoints live (default: ~/.sandforge/checkpoints, or
|
|
134
|
+
checkpoints/ in the folder SANDFORGE_JOURNAL_DIR names)
|
|
135
|
+
--json the answer alone on stdout, every other line on stderr
|
|
136
|
+
--help this text
|
|
137
|
+
|
|
138
|
+
A production org is refused before anything is read or written, exit 1. No flag lifts it.
|
|
139
|
+
With View All Data and Modify All Data, the user the alias connects as sees every record and
|
|
140
|
+
rewinds whoever changed it; import needs both. Without them, take holds only the objects the
|
|
141
|
+
user has View All and Modify All on, or, for an object with no permissions of its own, on every
|
|
142
|
+
record it hangs from \u2014 never tasks and events, products and price books, files or custom
|
|
143
|
+
settings \u2014 and preview, rewind and undo read those permissions again: an object no longer held
|
|
144
|
+
is not read, and is left as it is; what another user deleted since stays in the recycle bin,
|
|
145
|
+
named; undo takes back the user's own rewind alone. A checkpoint that keeps custom settings
|
|
146
|
+
needs Customize Application too: View All Custom Settings reads them, never writes them.
|
|
147
|
+
A checkpoint holds the records' values as the org held them, personal data among them,
|
|
148
|
+
unencrypted, in files only you can read (on Windows: in your user profile). Expired checkpoints
|
|
149
|
+
are deleted as any command starts, each named.
|
|
150
|
+
list and delete read this machine alone and never contact the org. An org's checkpoints are the
|
|
151
|
+
ones taken under its alias or username, and the others kept of the same Organization Id.
|
|
152
|
+
export never writes a checkpoint unencrypted: AES-256-GCM, under a key of 52 letters and digits
|
|
153
|
+
shown once and kept nowhere. Anyone who has the file and its key reads every record it holds:
|
|
154
|
+
send the key another way than the file, and only to people who already see all data in the org.
|
|
155
|
+
The file does not expire: delete it once it has served. It carries neither the journals of
|
|
156
|
+
rewinds nor their undo, which stay on this machine.
|
|
157
|
+
import reads the file's header, then asks the org: another org, a production org, a user without
|
|
158
|
+
View All Data and Modify All Data, a file a newer SandForge made, are each refused before the key
|
|
159
|
+
is asked. A wrong key, or a file changed since it was exported, is refused before anything is
|
|
160
|
+
kept. A checkpoint kept already the same is left as it is, exit 0; another of its id is refused.
|
|
161
|
+
The lock against two rewinds at once is per machine: agree on who rewinds the org.
|
|
162
|
+
rewind shows its preview and asks you to type the org's alias exactly as --org gives it before it
|
|
163
|
+
writes, then rewinds from that preview as it read the org: a record someone changes after it read
|
|
164
|
+
is left as they made it, and said. undo says what it takes back and asks the same before it
|
|
165
|
+
writes. A take, a rewind or an undo of the org under way on this machine, in the editor or in
|
|
166
|
+
another command line, refuses a rewind and an undo; other runs writing to the org are not seen
|
|
167
|
+
here, and what one of them changes after the preview read the org is left and said the same way.
|
|
168
|
+
Ctrl-C stops a take between two reads, and nothing of it is kept; a second Ctrl-C ends it at once,
|
|
169
|
+
and leaves a checkpoint listed as never taken, which delete removes. Ctrl-C stops a rewind or an
|
|
170
|
+
undo before its next call to the org, and leaves its journal: rewind again takes up from what still
|
|
171
|
+
differs, and undo still returns the org to how it was before the rewind. A rewind stopped before
|
|
172
|
+
it sent anything leaves none, and the undo of the rewind before it stays offered.
|
|
173
|
+
|
|
174
|
+
A record deleted since that the recycle bin no longer gives back is made again from the
|
|
175
|
+
checkpoint, with a new Id, once --accept-recreate says so: the lookups the checkpoint holds that
|
|
176
|
+
named it name the new Id, and undo deletes it again. Salesforce still lists a record emptied from
|
|
177
|
+
the bin as deleted, for minutes to hours, and says the bin no longer holds it only as the rewind
|
|
178
|
+
asks it back: such a record, with what was to come back with it, is made again then, or left
|
|
179
|
+
and named without --accept-recreate.
|
|
180
|
+
A record the checkpoint does not hold that took records of it along when it was deleted since is
|
|
181
|
+
brought back for a moment with them, then deleted again with what came back with it.
|
|
182
|
+
A custom setting is kept only when --custom-setting names it. A rewind brings a row of one back
|
|
183
|
+
only once no other row holds its owner (a hierarchy: the org's default, a profile, a user) or
|
|
184
|
+
its name (a list): it deletes the row made since first, then brings the row back with its Id.
|
|
185
|
+
A checkpoint holds the files attached to its records, Salesforce Files and classic attachments:
|
|
186
|
+
which records each is attached to, its latest version and its size, never its content. A rewind
|
|
187
|
+
deletes the files attached to them since, brings back those deleted since with their links,
|
|
188
|
+
removes the links added since and puts back those removed since, under new Ids; a file
|
|
189
|
+
attached to no record of the checkpoint, a user's own or a library's, is left and counted.
|
|
190
|
+
Bringing files back from the recycle bin takes file storage again: a rewind or an undo that would
|
|
191
|
+
take more than the org has left is refused before it writes. Without Query All Files, other
|
|
192
|
+
users' files that no record of the checkpoint is attached to are not seen.
|
|
193
|
+
What a rewind cannot undo: a file deleted since and no longer in the recycle bin, whose body the
|
|
194
|
+
checkpoint does not hold, a file given a new version since, which keeps it, a lead converted
|
|
195
|
+
since, a contract activated since, a record deleted with a parent created since that Salesforce
|
|
196
|
+
does not undelete on its own, or with its parent of an object the checkpoint does not hold
|
|
197
|
+
(preview counts them); without View All Data and Modify All Data, a record another user deleted
|
|
198
|
+
since, and a record of an object held through what it hangs from that the recycle bin does not
|
|
199
|
+
show the user (preview counts them too); a field added since, deleted since, or hidden since from
|
|
200
|
+
the user by field-level security, which the preview tells apart and names in an object something
|
|
201
|
+
changed in since \u2014 in an object nothing changed in, which a rewind writes nothing to, the fields
|
|
202
|
+
are not checked, and the preview counts those objects; the values the org computes or keeps
|
|
203
|
+
itself (formulas, roll-ups, auto-numbers, created and modified dates); what left the org
|
|
204
|
+
(emails, callouts, outbound messages, platform events); metadata; the files of a checkpoint taken
|
|
205
|
+
before SandForge 1.70, which holds none. A record the org refuses to put back, or to make again,
|
|
206
|
+
is named by rewind, with its words.
|
|
207
|
+
|
|
208
|
+
JSON (--json), one value on stdout:
|
|
209
|
+
list [{id, name, org, organizationId, takenAt, records, bytes, expiresAt,
|
|
210
|
+
expiresSoon, binReachSince, lastRewind?, valid, why?, refreshedAt?}]
|
|
211
|
+
(name, org, takenAt, records and bytes are null for a damaged checkpoint;
|
|
212
|
+
expiresAt is null for one kept until deleted)
|
|
213
|
+
take {checkpoint, requests?, estimate}: the checkpoint as kept (its
|
|
214
|
+
checkpoint.json; files?, {documents, links, anchored, readByIds?}, for one
|
|
215
|
+
that holds files); requests, {total, byPhase}, the API requests the take sent
|
|
216
|
+
the org, SOAP calls among them; estimate, what it said before reading a record
|
|
217
|
+
take --estimate {mode, objects, leftOut, estimate, refusal?, files?, customSettings?}:
|
|
218
|
+
estimate.requestsByPhase splits the requests over a take's phases as
|
|
219
|
+
requests.byPhase does: guard, scope, start, counts, bin, snapshot, stability;
|
|
220
|
+
files, {held, queryAllFiles, addedToPicked}; customSettings, every custom
|
|
221
|
+
setting of the org, kept or not, [{objectApiName, label, kind?, records?}],
|
|
222
|
+
kind hierarchy or list, and objects[].customSetting for one kept; {mode,
|
|
223
|
+
refusal} for a take refused before its scope is read (a production org, a
|
|
224
|
+
user without the permissions)
|
|
225
|
+
preview {checkpoint: {id, name, takenAt, org}, toDelete, toGiveBack, toBringBack,
|
|
226
|
+
toRecreate, carriers, differs, diff, estimate, automation?, emails?,
|
|
227
|
+
emailsUncounted?, deliverability?, refusal?}: carriers, the records
|
|
228
|
+
brought back for a moment and deleted again, in none of the other numbers;
|
|
229
|
+
diff, estimate
|
|
230
|
+
and automation as the extension answers them; refusal, the first a rewind
|
|
231
|
+
given no flag would meet now, of those its lines name with what lifts
|
|
232
|
+
each, as rewind --dry-run lists them: the extension's own (the org's lock,
|
|
233
|
+
a run writing, the day's API requests or emails, file storage), then an
|
|
234
|
+
acceptance it needs (NO_UNDO, RECREATE, UNSEEN, AUTOMATION,
|
|
235
|
+
EMAILS_DELIVERED, in that order); emails, one per daily limit its writes send
|
|
236
|
+
against: {limit, emails, verdict, remaining?, max?, alertsCounted?,
|
|
237
|
+
objects: [{objectApiName, write, records, perRecord, sentBy}]};
|
|
238
|
+
emailsUncounted, what sends emails as it writes that could not be read \u2014 a
|
|
239
|
+
flow whose definition was refused, a package's, which no user reads \u2014 its
|
|
240
|
+
emails not counted, which --accept-automation covers; deliverability,
|
|
241
|
+
when something that still runs may send an email: {reading: {level: all
|
|
242
|
+
or withheld} or {unread}, senders: [{objectApiName, kind, name, why}]},
|
|
243
|
+
which --accept-emails answers for all and unread;
|
|
244
|
+
diff.objects[].schemaDrift, of an object whose fields changed since:
|
|
245
|
+
{removed, added, changed, hidden?, uncertain?: {fields, reason?}}, removed
|
|
246
|
+
the custom fields deleted since, hidden those field-level security hides
|
|
247
|
+
from the user, uncertain those the org would not say which of;
|
|
248
|
+
diff.described, {first, later}, the objects it described again, asked
|
|
249
|
+
whether their fields changed since the take: first those something moved
|
|
250
|
+
in, later those nothing moved in that hold fewer records than the
|
|
251
|
+
checkpoint; diff.fieldsNotChecked, the objects nothing changed in whose
|
|
252
|
+
fields it did not describe: a rewind writes nothing there, and a field
|
|
253
|
+
deleted or hidden since in one of them is not known; diff.files,
|
|
254
|
+
for a checkpoint that holds files: {unlink, relink, updateLinks,
|
|
255
|
+
outsideAdded, outsideDeleted, storage: {bringBack, remaining?, undo},
|
|
256
|
+
blindSpot?}, the links to remove, put back and give their sharing back, the
|
|
257
|
+
files left, and file storage in bytes; diff.access, {kind, requests?}, org
|
|
258
|
+
for a user with View All Data and Modify All Data, perObject for one read
|
|
259
|
+
object by object, with the API requests that read; diff.unseen, read
|
|
260
|
+
object by object: [{objectApiName, children, records}], of the records to
|
|
261
|
+
delete of an object, the objects whose records their delete takes along
|
|
262
|
+
out of the user's sight; with --object, objects, the objects named, and
|
|
263
|
+
selection, {objects, acts: [{objectApiName, picked, toDelete, toGiveBack,
|
|
264
|
+
toBringBack, toRecreate}], left: [{objectApiName, reason, count}], needs:
|
|
265
|
+
[{objectApiName, records}], undoCannot}, what a rewind of them alone would
|
|
266
|
+
do and leave \u2014 reason needsUnpickedParent, heldByUnpicked,
|
|
267
|
+
outsideNotAccepted, holdsLeft or keyTaken \u2014 and the objects to add; the
|
|
268
|
+
numbers, differs and estimate are then the rewind's of those objects,
|
|
269
|
+
diff the whole diff; of a checkpoint of picked objects whose records
|
|
270
|
+
outside it were made since under records a rewind would delete, kept:
|
|
271
|
+
[{objectApiName, reason, count}], what a rewind without --accept-outside
|
|
272
|
+
keeps for them \u2014 reason outsideNotAccepted or holdsLeft \u2014, the numbers
|
|
273
|
+
then those of what it writes, differs the whole diff's (preview previews
|
|
274
|
+
that rewind)
|
|
275
|
+
rewind --dry-run as preview, with wouldBeRefused: ["refused (CODE): message"] and
|
|
276
|
+
wouldBeRefusedCodes: ["CODE"], one for each refusal a rewind with these
|
|
277
|
+
flags would meet, in order; asked to mute, emails and deliverability are
|
|
278
|
+
of what still runs, with mutedAutomation and mutePlan
|
|
279
|
+
rewind {checkpoint: {id, name, takenAt, org}, rewindId, status, deleted, givenBack,
|
|
280
|
+
broughtBack, recreated (each {planned, done, left}), cannotUndo: [{object,
|
|
281
|
+
reason, count}], carriers?: [{object, count}], draftsLeft?: [{object,
|
|
282
|
+
count, ids}], undo?: {until, cannot: [{object, count, reason?}]}, verify:
|
|
283
|
+
{differences, stable, passes, notCompared}, residual: [{object, reason,
|
|
284
|
+
by?, count, message?}], unread: [{object, reason}], objects: [{object,
|
|
285
|
+
deleted, givenBack, broughtBack, refused}], apiRequests: {used,
|
|
286
|
+
leftToday}, result}:
|
|
287
|
+
status success, partial, unstable, failure or cancelled; result as the
|
|
288
|
+
extension answers it; undo.cannot's reason deletedBeforeParent: deleted
|
|
289
|
+
before a record they point at, which the rewind deleted next; carriers, of
|
|
290
|
+
what it brought back and deleted, the records brought back for a moment;
|
|
291
|
+
draftsLeft, of a rewind stopped part way, the orders and contracts it made
|
|
292
|
+
again as drafts and had not given their status back yet, by their new Ids;
|
|
293
|
+
files?: {unlinked, relinked, linksUpdated, linksRefused}, the links between
|
|
294
|
+
files and records it wrote, when it wrote one; with --object, limitedTo,
|
|
295
|
+
the objects named, and notRewound, {objects, records}, the objects not
|
|
296
|
+
named that still differ and their records that do, which the status
|
|
297
|
+
does not count
|
|
298
|
+
undo as rewind, without recreated, cannotUndo, carriers, draftsLeft and undo,
|
|
299
|
+
with carriedAlone?: [{object, count}], the records sent back to the
|
|
300
|
+
recycle bin on their own that had gone there with a record the rewind
|
|
301
|
+
brought back for a moment
|
|
302
|
+
delete {deleted: [id], kept: [id]}
|
|
303
|
+
export {checkpoint: {id, name, takenAt, org}, file, bytes, sha256, records, objects,
|
|
304
|
+
keyShown}: keyShown, whether a new key was drawn and shown on stderr; never
|
|
305
|
+
the key itself
|
|
306
|
+
import {outcome, checkpoint: {id, name, takenAt, org}, records, objects, expiresAt,
|
|
307
|
+
warnings}: outcome imported, or alreadyKept for the same checkpoint kept here
|
|
308
|
+
already
|
|
309
|
+
refused or failed {refusal: {code, message}}; a rewind or an undo refused before it wrote
|
|
310
|
+
for more than one reason adds wouldBeRefused and wouldBeRefusedCodes, as
|
|
311
|
+
rewind --dry-run gives them: every refusal, the first among them, each other
|
|
312
|
+
also on a line of its own, refused (CODE): message
|
|
313
|
+
A bad command line (exit 2) prints nothing on stdout.
|
|
314
|
+
|
|
315
|
+
Exit codes: 0 done (take: every record of its objects is kept; rewind and undo: read again, the
|
|
316
|
+
org matches among the objects and fields compared \u2014 with --object, among the objects named,
|
|
317
|
+
whatever still differs in the others; preview, rewind --dry-run and list answered;
|
|
318
|
+
delete: every checkpoint named is deleted; export: the file is written; import: the checkpoint is
|
|
319
|
+
kept, or was already); 1 refused before it read or wrote (a production org,
|
|
320
|
+
missing permissions, automation without --accept-automation, emails the org delivers or would not
|
|
321
|
+
say it withholds without --accept-emails (refusal code EMAILS_DELIVERED), deletions undo could not
|
|
322
|
+
bring back without --accept-no-undo, records to make again with new Ids without --accept-recreate,
|
|
323
|
+
deletions taking along records the user is not proven to see without --accept-unseen, more than
|
|
324
|
+
--max-total records, more records to rewind than --max-records, people working in the org in the
|
|
325
|
+
hour before with --refuse-when-active, more API requests or emails than the org
|
|
326
|
+
has left today, files to bring back taking more file storage than it has left, a checkpoint of
|
|
327
|
+
the org before a refresh or of an expired scratch org, a SandForge run writing to it; an import
|
|
328
|
+
of another org's file, with the wrong key, of a file changed since its export), or nothing
|
|
329
|
+
done; 2 a bad command line, a --checkpoint name several checkpoints
|
|
330
|
+
have, an --object the checkpoint does not hold,
|
|
331
|
+
rewind or undo with --yes and no checkpoint named, or a question with no terminal (give
|
|
332
|
+
--yes; import's key: --key-env); 3 partial (rewind and undo: records still differ, each said
|
|
333
|
+
with why; with
|
|
334
|
+
--fail-on-change, the org differs: records to delete, give back, bring back or make again,
|
|
335
|
+
links between files and records to remove, put back or give their sharing back, records the
|
|
336
|
+
rewind cannot take back or the checkpoint does not hold although they are dated before it, files
|
|
337
|
+
added or deleted since that no record of it is attached to, a field it compares deleted or
|
|
338
|
+
hidden since in an object something moved in, an object that could not be read; delete: some
|
|
339
|
+
were kept, each said with why); 4 unstable (someone else changed
|
|
340
|
+
records during the rewind or the undo: left as they made them); 130, 143, 129 Ctrl-C, SIGTERM or
|
|
341
|
+
SIGHUP stopped it \u2014 run rewind again: it takes up from what still differs, and undo still reaches
|
|
342
|
+
the state before it.
|
|
343
|
+
`,Xt=["take","list","preview","rewind","undo","delete","export","import"],Zt=e=>Xt.includes(e),x={switches:["--json"],values:["--org","--store"]},Qt={take:{words:1,switches:[...x.switches,"--estimate"],values:[...x.values,"--name","--object","--exclude-object","--custom-setting","--ignore-field","--max-total","--keep-days"]},list:{words:1,...x},preview:{words:1,switches:[...x.switches,"--fail-on-change"],values:[...x.values,"--checkpoint","--object"]},rewind:{words:1,switches:[...x.switches,"--dry-run","--accept-automation","--accept-emails","--mute-automation","--accept-no-undo","--accept-recreate","--accept-outside","--accept-unseen","--refuse-when-active","--yes"],values:[...x.values,"--checkpoint","--ignore-field","--object","--max-records"]},undo:{words:1,switches:[...x.switches,"--accept-automation","--accept-emails","--mute-automation","--yes"],values:[...x.values,"--checkpoint"]},delete:{words:1,switches:[...x.switches,"--all","--yes"],values:[...x.values,"--checkpoint"]},export:{words:1,switches:x.switches,values:[...x.values,"--checkpoint","--out","--key-env"]},import:{words:1,switches:x.switches,values:[...x.values,"--file","--key-env","--keep-days"]}},en={name:"--name",objects:"--object",excluded:"--exclude-object",customSettings:"--custom-setting",ignoredFields:"--ignore-field",maxTotal:"--max-total",keepDays:"--keep-days"},tn=/^[A-Za-z][A-Za-z0-9_]{0,79}$/;function O(e){process.stderr.write(`${e}
|
|
344
|
+
`),process.exit(2)}function nn(e){let n=e.toISOString();return`${n.slice(0,10)} ${n.slice(11,16)} UTC`}function on(e,n=new Date){let t=e.slice(2);(t.includes("--help")||t.includes("-h"))&&(process.stdout.write(Yt),process.exit(0));let o=t[0];if(o===void 0||o.startsWith("-"))return O("Name the command first: take, list, preview, rewind, undo, delete, export or import. Run with --help.");if(!Zt(o))return O(`"${o}" is not a command of sandforge checkpoint: take, list, preview, rewind, undo, delete, export or import. Nothing was run. Run with --help.`);xe(t,Qt[o]);let i=h=>{let l=[];for(let m=1;m<t.length;m++){if(t[m]!==h)continue;let g=t[m+1];if(g===void 0||g.startsWith("--"))return O(`${h} wants a value.`);l.push(g),m++}return l},a=h=>{let l=i(h);return l.length>1&&O(`${h} is given ${l.length} times: give it once.`),l[0]},c=h=>{let l=a(h);if(l!==void 0)return/^\d{1,15}$/.test(l)||O(`${h} takes a whole number, not "${l}".`),Number(l)},s=a("--store"),r={storeRoot:s!==void 0?de(s):_e(),json:t.includes("--json")},p=a("--org"),w=()=>p??O(`${o} needs --org. Run with --help.`),k=h=>{t.includes("--yes")&&(h===void 0&&O(`${o} --yes needs --checkpoint <id|name>: one that does not ask is told which checkpoint it acts on. Nothing was run.`),h==="latest"&&O(`${o} --yes needs the checkpoint named by its id or its name, not latest: a checkpoint taken since would be the one it acts on. Nothing was run.`))},$=()=>{let h=i("--object"),l=h.find(m=>!tn.test(m));return l!==void 0&&O(`--object takes an object's API name, not "${l}".`),h.filter((m,g)=>h.findIndex(A=>A.toLowerCase()===m.toLowerCase())===g)};switch(o){case"list":return{...r,command:o,...p!==void 0?{org:p}:{}};case"take":{let h=w(),l=i("--object"),m=i("--exclude-object"),g=i("--custom-setting"),A=g.includes("all")?"all":g,d=i("--ignore-field"),f=c("--max-total"),j={name:a("--name")??nn(n),mode:l.length>0?"picked":"everything",...l.length>0?{objects:l}:{},...m.length>0?{excluded:m}:{},...A.length>0?{customSettings:A}:{},...d.length>0?{ignoredFields:d}:{},...f!==void 0?{maxTotal:f}:{},keepDays:c("--keep-days")??G},C=Pe.safeParse({...j,orgId:"command-line"});if(!C.success){let S=C.error.issues[0],_=String(S?.path[0]??"");return O(`${en[_]??_}: ${S?.message??"not read"}. Nothing was run.`)}return{...r,command:o,org:h,take:{...j,name:C.data.name},estimate:t.includes("--estimate")}}case"preview":return{...r,command:o,org:w(),checkpoint:a("--checkpoint")??"latest",failOnChange:t.includes("--fail-on-change"),objects:$()};case"rewind":{let h=w(),l=a("--checkpoint");k(l);let m=i("--ignore-field"),g=Re.safeParse(m);if(!g.success)return O(`--ignore-field: ${g.error.issues[0]?.message??"not read"}. Nothing was run.`);let A=c("--max-records");return A===0&&O('--max-records takes a whole number of 1 or more, not "0". Nothing was run.'),{...r,command:o,org:h,checkpoint:l??"latest",objects:$(),dryRun:t.includes("--dry-run"),acceptAutomation:t.includes("--accept-automation"),acceptEmails:t.includes("--accept-emails"),muteAutomation:t.includes("--mute-automation"),acceptNoUndo:t.includes("--accept-no-undo"),acceptRecreate:t.includes("--accept-recreate"),acceptOutside:t.includes("--accept-outside"),acceptUnseen:t.includes("--accept-unseen"),...A!==void 0?{maxRecords:A}:{},refuseWhenActive:t.includes("--refuse-when-active"),ignoreFields:m,yes:t.includes("--yes")}}case"undo":{let h=w(),l=a("--checkpoint");return k(l),{...r,command:o,org:h,...l!==void 0?{checkpoint:l}:{},acceptAutomation:t.includes("--accept-automation"),acceptEmails:t.includes("--accept-emails"),muteAutomation:t.includes("--mute-automation"),yes:t.includes("--yes")}}case"delete":{let h=w(),l=a("--checkpoint"),m=t.includes("--all");return m&&l!==void 0&&O("Give --checkpoint or --all, not both."),{...r,command:o,org:h,...m?{}:{checkpoint:l??"latest"},all:m,yes:t.includes("--yes")}}case"export":{let h=w(),l=a("--out")??O("export needs --out <file>. Run with --help."),m=it(a("--key-env"));return{...r,command:o,org:h,checkpoint:a("--checkpoint")??"latest",out:de(l),...m!==void 0?{keyEnv:m}:{}}}case"import":{let h=w(),l=a("--file")??O("import needs --file <file>. Run with --help."),m=it(a("--key-env"));return{...r,command:o,org:h,file:de(l),...m!==void 0?{keyEnv:m}:{},keepDays:c("--keep-days")??G}}}}function it(e){if(e!==void 0)return!/^[A-Za-z_][A-Za-z0-9_]{0,127}$/.test(e)||ne(e)!==void 0?O("--key-env takes the name of an environment variable that holds the key, never the key: a key on the command line stays in the shell\u2019s history and the list of processes. Nothing was run."):e}function ht(e,n){return e!==void 0&&n!==void 0&&e.length>=15&&e.slice(0,15)===n.slice(0,15)}function M(e,n,t){let o=t!==void 0?[t]:[];for(let i of e){let a=i.checkpoint?.org;a!==void 0&&(a.alias===n||a.username.toLowerCase()===n.toLowerCase())&&o.push(i.organizationId)}return e.filter(i=>o.some(a=>ht(a,i.organizationId)))}function X(e,n,t,o){if(je.safeParse(t).success){let a=e.find(c=>c.checkpointId===t);return a?{entry:a}:{none:`No checkpoint ${t} is kept on this machine.`}}if(t==="latest"){let a=n[0];return a?{entry:a}:{none:`No checkpoint of ${o} is kept on this machine.`}}let i=n.filter(a=>a.checkpoint?.name===t);return i.length===1?{entry:i[0]}:i.length===0?{none:`No checkpoint of ${o} named '${t}' is kept on this machine.`}:{ambiguous:`${i.length} checkpoints of ${o} are named '${t}': give the id of the one you mean with --checkpoint (${i.map(a=>a.checkpointId).join(", ")}).`}}function fe(e){if(e.valid)return;let n=e.checkpoint?`'${e.checkpoint.name}'`:e.checkpointId;switch(e.why){case"damaged":return{code:"DAMAGED",message:`The file of checkpoint ${e.checkpointId} cannot be read: it can only be deleted.`};case"taking":return{code:"TAKING",message:`The checkpoint ${n} is being taken, or its take never ended: it can be previewed once taken, or deleted.`};case"failed":return{code:"FAILED",message:`The take of checkpoint ${n} failed: it can only be deleted.`};case"refreshed":return{code:"OTHER_ORG",message:`This sandbox was refreshed${e.refreshedAt?` on ${e.refreshedAt.slice(0,10)}`:""}: it is another org now, and the checkpoint ${n} is of the org before it. It can only be deleted.`};case"scratchExpired":return{code:"SCRATCH_EXPIRED",message:`The scratch org of checkpoint ${n} has expired: its checkpoints can only be deleted.`};default:return{code:"INVALID",message:`The checkpoint ${n} cannot be previewed.`}}}var u=e=>e.toLocaleString("en-US");function N(e){let n=new Date(Date.parse(e)).toISOString();return`${n.slice(0,10)} ${n.slice(11,16)} UTC`}function ce(e){let n=new Date(Date.parse(e)).toISOString();return`${n.slice(0,10)} ${n.slice(11,19)} UTC`}var F=e=>`${He(e/(1024*1024))} MB`;function y(e,n=8){if(e.length===0)return"\u2014";let t=e.slice(0,n).join(", ");return e.length>n?`${t} \u2026 (+${e.length-n})`:t}function K(e){return e.objects.reduce((n,t)=>n+t.records,0)}function pe(e){return e===null?"kept until you delete it":`kept until ${N(e)}`}function q(e){return e.org.alias??e.org.username}var sn=/^Left out(?::\s*|\s+(?=as asked\b))/;function lt(e){let n=new Map;for(let{objectApiName:t,reason:o}of e)n.set(o,[...n.get(o)??[],t]);return[...n].map(([t,o])=>` left out: ${y(o)} \u2014 ${t.replace(sn,"")}`)}var an={fls:"hidden from the user SandForge connects as by field-level security: Rewind won\u2019t put them back",encrypted:"encrypted, and the user SandForge connects as can\u2019t view encrypted data: Rewind won\u2019t touch them",base64:"the content of files and other binary values, which a checkpoint doesn\u2019t hold",compound:"compound fields, kept through the fields they are made of"};function ut(e){let n=new Map;for(let t of e)for(let{field:o,reason:i}of t.leftOutFields)n.set(i,[...n.get(i)??[],`${t.objectApiName}.${o}`]);return[...n].map(([t,o])=>` fields left out (${o.length}): ${y(o)} \u2014 ${an[t]??t}`)}function ft(e){let n=e.filter(t=>!t.undeletable).map(t=>t.objectApiName);return n.length===0?[]:[` deleted ${y(n)} records come back from the recycle bin only with their parent`]}function pt(e){return` about ${u(e.seconds)} s \xB7 about ${u(e.apiRequests)} API requests of the ${u(e.apiRequestsLeft)} left today`+(e.bytes>0?` \xB7 about ${F(e.bytes)} on this machine`:"")}var st={damaged:"its file cannot be read: it can only be deleted",taking:"being taken, or its take never ended: it can only be deleted unless it ends",failed:"its take failed: it can only be deleted",refreshed:"of the org before its refresh: it can only be deleted",scratchExpired:"its scratch org has expired: it can only be deleted"};function rn(e,n){if(e.length===0)return[`No checkpoint is kept in ${n}.`];let t=[];for(let o of e){let i=o.checkpoint;if(!i){t.push(`${o.checkpointId} ${st.damaged}`);continue}if(t.push(`${o.checkpointId} '${i.name}' ${q(i)} taken ${N(i.takenAt)} ${u(K(i))} records in ${i.objects.length} objects ${F(i.bytes)} `+pe(i.expiresAt)),!o.valid){let a=o.why==="refreshed"&&o.refreshedAt?`refreshed on ${o.refreshedAt.slice(0,10)}: `:"";t.push(` ${a}${st[o.why??""]??"it cannot be previewed"}`)}o.expiresSoon&&i.expiresAt!==null&&t.push(` expires on ${N(i.expiresAt)}: take a new one, or keep this one in the editor`),o.binReachSince&&t.push(` records deleted before ${o.binReachSince.slice(0,10)} can't come back with their Id (recycle bin), sooner if the bin fills: a rewind makes them again, with new Ids`),o.undo&&t.push(` rewound: the rewind can be undone until ${N(o.undo.until)}`)}return t}function dn(e){let n=e.checkpoint;return{id:e.checkpointId,name:n?.name??null,org:n?q(n):null,organizationId:e.organizationId,takenAt:n?.takenAt??null,records:n?K(n):null,bytes:n?.bytes??null,expiresAt:n?n.expiresAt:null,expiresSoon:e.expiresSoon===!0,binReachSince:e.binReachSince??null,...n?.lastRewind?{lastRewind:{...n.lastRewind,undoable:e.undo!==void 0}}:{},valid:e.valid,...e.why!==void 0?{why:e.why}:{},...e.refreshedAt!==void 0?{refreshedAt:e.refreshedAt}:{}}}function mt(e){return e.refusal!==void 0&&e.objects.length===0&&e.leftOut.length===0}function cn(e){return mt(e)?{mode:e.mode,refusal:e.refusal}:{...e}}function hn(e,n){if(mt(n))return[`refused: ${n.refusal.message}`];let t=n.objects.filter(i=>i.records>0).length,o=new Map;for(let{namespace:i}of n.objects)i!==void 0&&o.set(i,(o.get(i)??0)+1);return[`a checkpoint of ${e} would keep ${n.objects.length} objects (${t} hold records; ${n.objects.length-t} are empty \u2014 what is created there later is caught too), about ${u(n.estimate.records)} records`,...[...o].map(([i,a])=>` includes ${a} objects of the ${i} package`),pt(n.estimate),...lt(n.leftOut),...ut(n.objects),...ft(n.objects),...n.files?un(n.files):[],...ln(n),...n.refusal?[`refused: ${n.refusal.message}`]:[]]}function wt(e){let n=e.records===void 0?void 0:`${u(e.records)} ${e.records===1?"row":"rows"}`,t=[e.kind,n].filter(o=>o!==void 0);return t.length>0?`${e.objectApiName} (${t.join(", ")})`:e.objectApiName}function gt(e){return wt({objectApiName:e.objectApiName,...e.customSetting!==void 0?{kind:e.customSetting}:{},records:e.records})}function ln(e){let n=e.objects.filter(i=>i.customSetting!==void 0),t=new Set(n.map(i=>i.objectApiName)),o=(e.customSettings??[]).filter(i=>!t.has(i.objectApiName));return[...n.length>0?[` custom settings kept: ${y(n.map(gt))} \u2014 a rewind sets their rows back as the checkpoint holds them, whoever changed them since`]:[],...o.length>0?[` custom settings not kept: ${y(o.map(wt))} \u2014 --custom-setting <ApiName|all> keeps them`]:[]]}function un(e){return e.held?[" files: it keeps which files are attached to its records (Salesforce Files, classic attachments) and each file's latest version, not its content; a rewind deletes the files attached to them since and brings back those deleted since. A file attached to no record it holds, a user's own or a library's, is left as it is",...kt(e.addedToPicked),...e.queryAllFiles?[]:[me]]:[" files: not kept \u2014 a rewind leaves the files attached since as they are"]}function kt(e){return e.length>0?[` added to the objects picked: ${e.join(", ")} \u2014 without them a rewind would leave the files attached since as they are`]:[]}var me=" the user the alias connects as doesn't have Query All Files: other users' files that no record of the checkpoint is attached to (in a library the user is not a member of, say) are not seen, nor counted among the files left; files attached to its records are seen";function fn(e,n,t=[]){let o=e.movedWhileTaken,i=o.changed+o.deleted+o.created;return[`taken '${e.name}' (${e.checkpointId}) of ${q(e)}: ${u(K(e))} records in ${e.objects.length} objects, ${F(e.bytes)} on this machine, ${pe(e.expiresAt)}`,` of ${ce(e.readFrom)}, read until ${ce(e.takenAt)} on the org's clock`,...i>0?[` ${u(i)} records changed while it was taken (${o.changed} changed, ${o.deleted} deleted, ${o.created} created): it holds them as they were read, and a rewind treats them as changed since. Take checkpoints when nobody works in the org.`]:[],...lt(e.scope.leftOut),...ut(e.objects),...e.ignoredFields.length>0?[` not compared, nor written back (you chose): ${e.ignoredFields.join(", ")}`]:[],...ft(e.objects),...pn(e.objects),...e.files?mn(e,e.files,t):[],` it holds the records' values unencrypted, in files only you can read: ${n}`]}function pn(e){let n=e.filter(t=>t.customSetting!==void 0);return n.length===0?[]:[` custom settings kept: ${y(n.map(gt))} \u2014 a rewind sets their rows back as the checkpoint holds them`]}function mn(e,n,t){let o=n.readByIds??[],i=new Set(t.map(s=>s.toLowerCase())),a=new Set(e.objects.map(({objectApiName:s})=>s.toLowerCase())),c=e.scope.mode==="picked"?De.filter(s=>a.has(s.toLowerCase())&&!i.has(s.toLowerCase())):[];return[` files: ${u(n.anchored)} attached to its records by ${u(n.links)} link(s): a rewind takes back what is attached to them since`,...kt(c),...o.length>0?[` the links of ${y(o)} were read by lists of record Ids: ${q(e)} refused one query, or answered too late`]:[],...e.takenBy.queryAllFiles===!1?[me]:[]]}function wn(e,n){let t=Object.entries(e.byPhase).map(([i,a])=>{let c=n?.requestsByPhase?.[i];return c===void 0||c===a?`${i} ${a}`:`${i} ${a} (${c})`}),o=n?`, about ${u(n.apiRequests)} estimated`:"";return` sent ${u(e.total)} API requests to the org${o}: ${t.join(", ")}`}var at=e=>e.toDelete.createdSince+e.toDelete.broughtBackSince+e.toDelete.comesBackWithParent,H=e=>e.toBringBack.inBin+e.toBringBack.withParent+e.toBringBack.deletedWhileTaken,he=e=>e.cannotUndo.reduce((n,t)=>n+t.count,0),z=e=>e.toRecreate??0,oe=e=>e.toBringBack.carriers??0;function bt(e){let n=e.files;return n===void 0?0:n.unlink+n.relink+n.updateLinks}function gn(e){let n=e.files;return n===void 0?0:n.outsideAdded+n.outsideDeleted}function kn(e){let n=e.schemaDrift;return n===void 0?0:n.removed.length+(n.hidden?.length??0)+(n.uncertain?.fields.length??0)}function we(e){let n=J(e);return n.toDelete+n.toGiveBack+n.toBringBack+n.toRecreate>0||bt(e)+gn(e)>0||e.objects.some(t=>he(t)>0||t.unexplained>0||kn(t)>0)||e.unread.length>0}var bn={goneForGood:"deleted since and no longer in the recycle bin, and not made again \u2014 a file, whose body the checkpoint does not hold, or a record deleted while it was taken: they can\u2019t come back",convertedLead:"leads converted since: Salesforce can\u2019t unconvert a lead",activatedContract:"contracts activated since: Salesforce won\u2019t set them back to Draft",deletedWithCreatedParent:"deleted with a parent created since that Salesforce does not undelete on its own: they come back with that parent only",deletedWithParentOutside:"deleted with their parent, a record of an object the checkpoint does not hold: they come back with that parent only, which a checkpoint that holds its object brings back",newFileVersion:"files given a new version since: Salesforce deletes no version and won\u2019t make an older one the latest again, so they keep their new content; the content each had is still in its version history, and their titles are given back",deletedByOther:"deleted since by another user: only View All Data and Modify All Data restore those; they stay in the recycle bin, never made again",outOfReach:"out of reach: without View All Data and Modify All Data, nothing shows what others deleted of an object held through the records it hangs from; they may be in the recycle bin out of sight, and are never made again"},yn=[{reason:"onlyWithParent",preview:"Salesforce undeletes them only with their parent, and their parent stays",result:"Salesforce undeletes them only with their parent"},{reason:"deletedBeforeParent",preview:"deleted before a record they point at, which the rewind deletes next: Salesforce cannot bring them back after that",result:"deleted before a record they point at, which the rewind deleted next: Salesforce cannot bring them back after that"}];function yt(e){return yn.flatMap(n=>{let t=e.filter(o=>(o.reason??"onlyWithParent")===n.reason);return t.length>0?[{words:n,of:t}]:[]})}function $n(e,n){let{automation:t,deliverability:o}=n;if(!t||!o)return[];let i=V(n.diff),{line:a}=Ue({act:"rewind",orgName:e,automation:t,steps:i,accepted:!0,mayMute:!1,...Fe({automation:t,steps:i}),reading:o.reading}).gate;return a!==void 0?[` ${a}`]:[]}function vn(e,n){return n.map(t=>{let o=[...new Set(t.objects.flatMap(a=>a.sentBy))],i=` emails: ${e}'s automation sends about ${Be(t.emails,t.limit)} as the rewind writes (${y(o,4)})`+(t.alertsCounted?`, its email alerts among them: ${e} counts them against its single emails, as a Developer Edition does`:"");return t.verdict==="unread"?`${i}; what it has left today could not be read (${t.unread??""})`:t.verdict==="fits"?`${i}; ${t.remaining??0} of ${t.max??0} left today`:`${i}, more than the ${t.remaining??0} of ${t.max??0} left today: a rewind is refused`})}function An(e,n){if(!e||n.length===0)return"";let t=se(e,{giveBack:n}).map(o=>`${o.objectApiName}: '${o.name}'`);return t.length>0?`, on which runs ${y(t,4)}`:""}function jn(e,n,t=[]){let o=e.objects.filter(s=>Ee[s.objectApiName]!==void 0),i=o.filter(s=>z(s)>0),a=o.filter(s=>H(s)>0&&!t.includes(s.objectApiName)),c=[];return i.length>0&&c.push(` made as drafts first: ${y(i.map(s=>`${s.objectApiName} ${u(z(s))}`))} \u2014 Salesforce refuses an order or a contract made past Draft, and an order takes its products only as a draft: one past Draft at the checkpoint is made at the org's Draft status, the records under it next, then given its status back, an update`+An(n,i.map(s=>s.objectApiName))),a.length>0&&c.push(` if Salesforce answers that an order or a contract to bring back is no longer in the recycle bin, --accept-recreate makes it again as a draft, then gives it its status back, an update: ${y(a.map(s=>`${s.objectApiName} ${u(H(s))}`))}`),c}function Rn(e,n,t=!1){if(!n)return{objects:[],fired:[]};let o=V(e),i=[],a=new Set;for(let c of e.objects){if(H(c)===0)continue;let s=Xe(n,o,[c.objectApiName],t);if(!(s.fired.length===0&&!s.blind)){i.push(c.objectApiName);for(let r of s.fired)a.add(`${r.objectApiName}: '${r.name}'`)}}return{objects:i,fired:[...a]}}function Cn(e,n,t){let o=se(n,t),i=[];for(let c of n.objects){let s=o.filter(k=>k.objectApiName===c.objectApiName),r=[...new Set(s.filter(k=>k.kind!=="trigger").map(k=>`'${k.name}'`))],p=[...new Set(s.filter(k=>k.kind==="trigger").map(k=>k.name))],w=[...r.length>0?[`${r.length} flow(s) or rule(s): ${y(r,4)}`]:[],...p.length>0?[`${p.length} Apex trigger(s): ${y(p,4)}`]:[]];w.length>0&&i.push(` ${c.objectApiName}: ${w.join("; ")}`)}return[...i.length>0?[` what ${e} runs as a rewind writes (updates, deletes, records brought back):`]:[],...i,...n.unread.map(c=>` not read of its automation: ${c.part} \u2014 ${c.reason}`)]}function $t(e,n,t,o="the user SandForge connects as",i=!1){let{diff:a}=t,c=J(a),s=[`Rewind ${e} to '${n.name}' (${N(n.takenAt)}), read at ${ce(a.readAt)}:`,` ${u(c.toDelete)} to delete \xB7 ${u(c.toGiveBack)} to give back \xB7 ${u(c.toBringBack)} to bring back`+(c.toRecreate>0?` \xB7 ${u(c.toRecreate)} to make again`:"")];!we(a)&&!a.objects.some(d=>d.outside.length>0)&&s.push(` ${e} is as it was at '${n.name}' among the objects and fields it holds: nothing to rewind.`);let r=a.objects.filter(d=>at(d)+d.toGiveBack.records+H(d)+z(d)+he(d)>0);if(r.length>0){let d=Math.max(6,...r.map(f=>f.objectApiName.length));s.push(` ${"Object".padEnd(d)} ${"Delete".padStart(8)} ${"Give back".padStart(9)} ${"Bring back".padStart(10)} ${"Can't undo".padStart(10)}`);for(let f of r)s.push(` ${f.objectApiName.padEnd(d)} ${u(at(f)).padStart(8)} ${u(f.toGiveBack.records).padStart(9)} ${u(H(f)).padStart(10)} ${u(he(f)).padStart(10)}`)}let p=new Map;for(let d of a.objects)for(let[f,j]of Object.entries(d.lastChangedBy))p.set(f,(p.get(f)??0)+j);p.size>0&&s.push(` last changed by: ${[...p].sort((d,f)=>f[1]-d[1]).map(([d,f])=>`${a.userNames[d]??d} ${u(f)}`).join(" \xB7 ")}`),a.activeLastHour.length>0&&s.push(` people working in ${e} in the last hour: ${a.activeLastHour.map(d=>a.userNames[d]??d).join(", ")}`);let w=a.objects.filter(d=>d.touched>0);w.length>0&&s.push(` touched since but holding their checkpoint values: ${y(w.map(d=>`${d.objectApiName} ${u(d.touched)}`))}`);let k=a.objects.filter(d=>oe(d)>0);k.length>0&&s.push(` brought back for a moment: ${y(k.map(d=>`${d.objectApiName} ${u(oe(d))}`))} \u2014 records the checkpoint does not hold that took records of it along when deleted since: Salesforce gives those back with them only, so they come back, then go back to the recycle bin with what came back with them; what the org runs on them runs twice`);let $=new Map;for(let d of a.objects)for(let f of d.cannotUndo)f.count!==0&&$.set(f.reason,[...$.get(f.reason)??[],`${d.objectApiName} ${u(f.count)}`]);for(let[d,f]of $)s.push(` can't be taken back: ${y(f)} \u2014 ${bn[d]??d}`);let h=a.objects.filter(d=>z(d)>0);h.length>0&&s.push(` to make again, with new Ids: ${y(h.map(d=>`${d.objectApiName} ${u(z(d))}`))} \u2014 deleted since and no longer in the recycle bin: made again from the checkpoint, the lookups it holds that named them naming the new Ids; anything outside Salesforce that names their old Ids no longer finds them`);let l=c.toBringBack>0?Rn(a,t.automation,i):void 0;if(l){let d=l.fired.length>0?`making them again runs ${y(l.fired,4)}`:"what runs as they are made again could not all be read";s.push(" if Salesforce answers that a record to bring back is no longer in the recycle bin \u2014 it still lists one emptied from it as deleted \u2014, --accept-recreate makes it again with a new Id, with what was to come back with it; without it, the rewind leaves them and names them"+(l.objects.length>0?`; ${y(l.objects)} records it leaves all the same, with what was to come back with them, and names them: ${d}, which this rewind does not ask about \u2014 a rewind after it counts them to make again, and asks`:""))}s.push(...jn(a,t.automation,l?.objects));let m=a.objects.filter(d=>d.unexplained>0);m.length>0&&s.push(` left as they are: ${y(m.map(d=>`${d.objectApiName} ${u(d.unexplained)}`))} \u2014 records the checkpoint doesn't hold although they're dated before it (a load with back-dated creation dates?); a rewind deletes nothing it cannot prove was created since`);for(let{words:d,of:f}of yt(a.undoCannot))s.push(` undo couldn't bring back: ${y(f.map(j=>`${j.objectApiName} ${u(j.count)}`))} \u2014 ${d.preview}`);for(let{objectApiName:d,children:f,records:j}of a.unseen??[])s.push(` also deleted with them, out of sight: deleting ${u(j)} ${d} also deletes what ${o} can't see under them in ${y(f)}; Rewind can't count those, and deletes them only with --accept-unseen`);for(let d of a.objects)for(let f of d.outside)s.push(d.objectApiName===vt&&f.objectApiName===Sn?` also attached outside the checkpoint: ${u(f.parents)} file(s) it deletes, by ${u(f.count)} link(s) to a library, a group or a record of another object \u2014 deleting them removes them from there as well`:` also deleted with them, outside the checkpoint: ${u(f.count)} ${f.objectApiName} created under ${u(f.parents)} ${d.objectApiName}`);s.push(...On(e,a));let g=a.objects.flatMap(d=>{let f=d.schemaDrift,j=new Set([...f?.removed??[],...f?.hidden??[],...f?.uncertain?.fields??[]]);return d.notCompared.filter(C=>!j.has(C)).map(C=>`${d.objectApiName}.${C}`)});g.length>0&&s.push(` not compared (you chose): ${y(g)}`);for(let d of a.objects){let f=d.schemaDrift;if(!f)continue;let j=C=>C.map(S=>`${d.objectApiName}.${S}`);f.removed.length>0&&s.push(` fields deleted since: ${y(j(f.removed))} \u2014 restore them from Deleted Fields, then rewind`),(f.hidden??[]).length>0&&s.push(` fields hidden from ${o} by field-level security since: ${y(j(f.hidden??[]))} \u2014 rewind does not put them back; give ${o} read and edit access to them, then rewind again`),f.uncertain!==void 0&&f.uncertain.fields.length>0&&s.push(` fields gone from what ${e} shows ${o}: ${y(j(f.uncertain.fields))} \u2014 deleted since (restore them from Deleted Fields within 15 days), or hidden by field-level security (give ${o} read and edit access); rewind does not put them back`+(f.uncertain.reason!==void 0?` (which, ${e} would not say: ${f.uncertain.reason})`:"")),f.added.length>0&&s.push(` fields added since, their values left alone: ${y(j(f.added))}`),f.changed.length>0&&s.push(` fields changed since, tried one by one: ${y(j(f.changed))}`)}let A=a.fieldsNotChecked??0;A>0&&s.push(` fields not checked for changes in ${u(A)} objects nothing changed in: a rewind writes nothing there`);for(let d of a.unread)s.push(` could not be read: ${d.objectApiName} \u2014 ${d.reason} (never taken for unchanged)`);return t.automation&&s.push(...Cn(e,t.automation,V(a))),t.emails&&s.push(...vn(e,t.emails)),t.emailsUncounted!==void 0&&s.push(` emails: not counted, ${t.emailsUncounted} could not be read \u2014 what they send as the rewind writes is not known; --accept-automation covers it`),s.push(...$n(e,t)),s.push(pt(t.estimate)),t.refusal&&s.push(` a rewind now would be refused (${t.refusal.code}): ${t.refusal.message}`),s}var vt="ContentDocument",Sn="ContentDocumentLink";function On(e,n){let t=n.files;if(t===void 0)return[];let o=[];t.unlink>0&&o.push(` links to remove: ${u(t.unlink)} added since between a file and a record that both stay \u2014 the file stays, no longer attached to that record`),t.relink>0&&o.push(` links to put back: ${u(t.relink)} removed since between a file and a record that both stay, each under a new Id: Salesforce keeps no removed link in the recycle bin`),t.updateLinks>0&&o.push(` links to give their sharing back: ${u(t.updateLinks)} \u2014 who sees the file from the record, and with what access; a link to an account keeps its access, which Salesforce doesn't let change`),t.outsideAdded>0&&o.push(` kept: ${u(t.outsideAdded)} file(s) added since, as no record of this checkpoint links to them (a user's own, a library's)`),t.outsideDeleted>0&&o.push(` left in the recycle bin: ${u(t.outsideDeleted)} file(s) deleted since, as no record of this checkpoint linked to them`);let i=n.objects.find(s=>s.objectApiName===vt),a=i===void 0?0:H(i),{storage:c}=t;return a>0&&c.bringBack>0&&o.push(` file storage: bringing back ${u(a)} file(s) takes ${F(c.bringBack)} again; `+(c.remaining===void 0?`${e} did not say how much it has left`:`${e} has ${F(c.remaining)} left`)),c.undo>0&&o.push(` undo would bring back the files this rewind deletes: ${F(c.undo)} of file storage again`),t.blindSpot&&o.push(me),o}function At(e,n,t,o,i){let a=o?.diff??i?.diff??t.diff;return{checkpoint:{id:n.checkpointId,name:n.name,takenAt:n.takenAt,org:e},...o?{objects:[...o.plan.objects]}:{},...J(a),carriers:a.objects.reduce((c,s)=>c+oe(s),0),differs:we(o?.diff??t.diff),...o?{selection:o.plan}:{},...i?{kept:i.plan.left}:{},diff:t.diff,estimate:t.estimate,...t.automation?{automation:t.automation}:{},...t.emails?{emails:t.emails}:{},...t.emailsUncounted!==void 0?{emailsUncounted:t.emailsUncounted}:{},...t.deliverability?{deliverability:t.deliverability}:{},...t.refusal?{refusal:t.refusal}:{}}}function xn(e,n){return n&&we(e)?3:0}var jt={needsUnpickedParent:"they come back only with a parent this rewind leaves deleted, or look up a record it leaves deleted, which Salesforce refuses: those lookups are left, the rest written",heldByUnpicked:"records of an object not named made since hang from them and hold some of their values in place: given back but for those",outsideNotAccepted:"records of an object not named made since hang from them, which their deletion would take along: kept, unless --accept-outside",holdsLeft:"records this rewind leaves as they are hang from them, which their deletion would take along: kept",keyTaken:"rows of a custom setting whose owner or name a row made since holds: brought back once it is gone"};function Rt(e){let n=[` limited to ${e.objects.join(", ")}: the other objects are left as they are, and what still differs in them is counted apart`],t=e.acts.filter(o=>!o.picked&&o.toDelete>0);t.length>0&&n.push(` also deletes again ${y(t.map(o=>`${o.objectApiName} ${u(o.toDelete)}`))} \u2014 made since, they come back with a record it brings back: leaving them would make a state that never existed`);for(let o of e.left)n.push(` left: ${u(o.count)} ${o.objectApiName} record(s) \u2014 ${jt[o.reason]}`);return e.needs.length>0&&n.push(` to rewind those too, add ${e.needs.map(o=>`--object ${o.objectApiName} (${u(o.records)} record(s) need it)`).join(", ")}`),e.acts.some(o=>o.picked&&o.toDelete>0)&&n.push(" a record of an object not named that looks up a record it deletes has that lookup emptied by Salesforce, and is dated that second"),n}function Ct(e,n,t){return!t&&e.scope.mode==="picked"&&n.objects.some(o=>o.outside.length>0)}function St(e){return e.left.map(n=>` kept: ${u(n.count)} ${n.objectApiName} record(s) \u2014 `+(n.reason==="outsideNotAccepted"?"records outside the checkpoint made since hang from them, which their deletion would take along: kept, unless --accept-outside":jt[n.reason]))}async function Ot(e,n,t,o){if(!Ct(n,t,o))return;let i=n.objects.map(({objectApiName:a})=>a);return ge(e,t,i,!1)}function xt(e,n){let t=new Map(e.objects.map(({objectApiName:i})=>[i.toLowerCase(),i])),o=n.filter(i=>!t.has(i.toLowerCase()));if(o.length>0)throw new b({code:"NOT_HELD",message:`--object: '${e.name}' holds no ${o.join(", ")}. It holds ${y(e.objects.map(i=>i.objectApiName))}. Nothing was run.`},2);return n.flatMap(i=>t.get(i.toLowerCase())??[])}async function ge(e,n,t,o){let i=await e.request({type:"checkpoint:plan-selection",payload:{checkpointId:n.checkpointId,previewId:n.previewId,objects:[...t],acceptOutside:o},timeoutMs:ie});if(i.outcome!=="answered")throw new b(P(i,"The plan of the objects named"));let a=D(i).plan;return{plan:a,diff:Ye(n,a)}}var Y={limit:e=>`--max-records ${e}`,mutes:!0,lift:{acceptAutomation:"give --accept-automation to rewind all the same",acceptEmails:"add --accept-emails to rewind all the same",acceptNoUndo:"give --accept-no-undo to rewind all the same",acceptRecreate:"give --accept-recreate to rewind all the same",acceptUnseen:"give --accept-unseen to rewind all the same",maxRecords:"read its preview (--dry-run), then give a --max-records that holds it",refuseWhenActive:"rewind once they are done, or without --refuse-when-active"}};function Nn(e){return e.code==="AUTOMATION"?{...e,message:e.message.replace(et,Y.lift.acceptAutomation)}:e}function In(e){return e.code==="AUTOMATION"?{...e,message:e.message.replace(tt,"give --accept-automation to undo the rewind all the same")}:e}function Io(e,n,t,o="the user SandForge connects as"){return Ze(e,n,t,Y.lift,o,Y.mutes)}var En={acceptAutomation:!1,acceptNoUndo:!1,acceptRecreate:!1};function Nt(e,n){return[...e?[e]:[],...n.filter(t=>t.code!==e?.code)]}function Dn(e,n,t,o){let i=o!==void 0&&o.length>0?`${o.join(", ")} of ${e}`:e,a=J(t),c=a.toRecreate>0?`, and makes ${u(a.toRecreate)} record(s) the recycle bin no longer holds again, with new Ids`:"",s=t.objects.reduce((k,$)=>k+oe($),0),r=s>0?`, with ${u(s)} record(s) brought back for a moment that had taken records of the checkpoint along, then deleted again`:"",p=bt(t),w=p>0?`, and puts ${u(p)} link(s) between files and records back as they were`:"";return`Rewind ${i} to '${n.name}': it deletes the ${u(a.toDelete)} record(s) created since ${N(n.takenAt)}, gives ${u(a.toGiveBack)} record(s) their values from then back, and brings back ${u(a.toBringBack)} record(s) from the recycle bin${r}${c}${w} \u2014 whoever made these changes. What it changes is kept, so it can be undone. Type ${e} to rewind it:`}var R=(e,n)=>e.reduce((t,o)=>t+n(o),0);function ke(e){let n=R(e.deleted,s=>s.deleted),t=R(e.deleted,s=>s.planned),o=R(e.restored,s=>s.restored+(s.restoredWithout??0)),i=R(e.restored,s=>s.planned),a=R(e.undeleted,s=>s.undeleted+s.alreadyBack),c=R(e.undeleted,s=>s.planned);return{deleted:{planned:t,done:n,left:Math.max(0,t-n-R(e.deleted,s=>s.alreadyGone))},givenBack:{planned:i,done:o,left:Math.max(0,i-o-R(e.restored,s=>s.alreadyGone))},broughtBack:{planned:c,done:a,left:Math.max(0,c-a)}}}function It(e){let n=e.recreated??[],t=R(n,i=>i.planned),o=R(n,i=>i.created);return{planned:t,done:o,left:Math.max(0,t-o)}}function Pn(e){return(e.remade??[]).reduce((n,t)=>{let o=R(e.deleted.filter(i=>i.objectApiName===t.objectApiName),i=>i.deleted);return n+Math.min(o,t.count)},0)}function Et(e,n){return e===void 0?"another user":n[e]??e}function Ln(e,n,t){switch(n.reason){case"automation":return e==="rewind"?"kept by your automation, which sets them again on save: rewind --ignore-field <Object.Field> stops comparing such a field":"set again on save by your automation, since the undo gave them back their values";case"changedDuringRewind":return`changed during the ${e} by ${Et(n.by,t)}: left as they made them`;case"changedSincePreview":return"changed since the preview: rewind again to take them";case"refused":return`refused: ${n.message??"the org gave no reason"}`;case"notInBin":return"no longer in the recycle bin \u2014 emptied from it, or kept there for good \u2014: Salesforce still lists them as deleted but will not bring them back; --accept-recreate makes them again with new Ids";case"goneForGood":return"deleted since and no longer in the recycle bin, and not made again (a file, whose body the checkpoint does not hold, or a record deleted while it was taken): they can't come back";case"kept":return n.message??"kept as they are"}}function Dt(e,n){return`Stopped before it wrote anything: ${e} is as it was before this rewind. Rewind again to rewind it to '${n}'.`}function Tn(e,n,t,o={}){let i=R(t.residual,h=>h.count),a=t.residual.filter(h=>h.reason==="changedDuringRewind"),c={success:`${e} is back at '${n.name}': read again, nothing differs among the objects and fields it holds.`,partial:`${e} is back at '${n.name}' but for ${u(i)} record(s) that still differ, each said with why:`,unstable:`Someone kept writing to ${e} during the rewind: ${[...new Set(a.map(h=>Et(h.by,o)))].join(", ")} changed ${u(R(a,h=>h.count))} record(s), left as they made them. Rewind again once they have stopped.`,failure:`Nothing of the rewind of ${e} to '${n.name}' went through: what still differs is said with why:`,cancelled:t.undo===void 0?Dt(e,n.name):`Stopped part way: ${e} is between '${n.name}' and now. Rewind again to finish: it takes up from what still differs, and undo still returns ${e} to how it was before the rewind.`},s=t.scope;s!==void 0&&t.status==="success"&&(c.success=`${s.objects.join(", ")} of ${e} ${s.objects.length>1?"are":"is"} back at '${n.name}': read again, nothing differs among them.`);let r=ke(t),p=R(t.undeleted,h=>h.alreadyBack),w=[c[t.status]];if(s!==void 0){let{objects:h,records:l}=s.notRewound;w.push(l>0?` not rewound: ${u(l)} record(s) of ${y(h)} still differ, left as they are \u2014 the rewind was limited to the objects named; add them with --object`:" the objects not named match the checkpoint too")}r.deleted.done>0&&w.push(` deleted ${u(r.deleted.done)} record(s) added since the checkpoint \u2014 created, or brought back from the recycle bin they were in when it was taken \u2014 (in the recycle bin for up to 15 days)`),r.givenBack.done>0&&w.push(` gave ${u(r.givenBack.done)} record(s) back their checkpoint values`),r.broughtBack.done>0&&w.push(` brought back ${u(r.broughtBack.done-p)} record(s) deleted since the checkpoint, with their original Ids`+(p>0?`, and ${u(p)} that came back with them`:""));let k=t.status==="failure"?[]:t.carriers??[];if(k.length>0){let h=y(k.map(l=>`${l.objectApiName} ${u(l.count)}`));w.push(t.status==="cancelled"?` of them, brought back for a moment: ${h} \u2014 records the checkpoint does not hold that had taken records of it along; stopped before it was through, those it had not deleted again yet are still in the org: rewind again deletes them, with what came back with them`:` of them, brought back for a moment and deleted again: ${h} \u2014 records the checkpoint does not hold that had taken records of it along, back in the recycle bin with what came back with them`)}let $=It(t);$.done>0&&w.push(` made again ${u($.done)} record(s) the recycle bin no longer held, with new Ids`);for(let h of t.draftsLeft??[])w.push(` left as drafts: ${h.objectApiName} ${u(h.count)} (${y(h.ids,3)}) \u2014 made again as drafts, the rewind stopped before it gave them back the status the checkpoint holds: rewind again gives it back to them, an update`);if(w.push(...Lt("rewind",e,t)),w.push(...Tt("rewind",t,o)),t.undo){w.push(` undo it until ${N(t.undo.until)}, sooner if the recycle bin fills: undo --org ${e} --checkpoint ${n.checkpointId}`);for(let{words:h,of:l}of yt(t.undo.cannot))w.push(` undo couldn't bring back: ${y(l.map(m=>`${m.objectApiName} ${u(m.count)}`))} \u2014 ${h.result}`)}for(let h of t.removedJournals??[])w.push(` removed the journal of rewind ${h.rewindId} of '${h.name}': undo reaches the last rewind of the org alone`);return w.push(Bt(t)),w}function Pt(e){return`Stopped before it wrote anything: ${e} is as the rewind left it, and the rewind can still be undone.`}function Bn(e,n,t){let o=R(t.restored,l=>l.keptChanged)+R(t.deleted,l=>l.keptChanged),i=R([...t.deleted,...t.restored,...t.undeleted],l=>l.refused),a=R(t.residual,l=>l.count)+i,c=`${e} is back as it was before its rewind to '${n.name}'`,s={success:`${c}.`,partial:o>0&&a===0?`${c}, except ${u(o)} record(s) changed since the rewind, left as they are now.`:`${c}, except ${u(a+o)} record(s), each said with why:`,unstable:`Someone changed records of ${e} during the undo: left as they made them, each said below.`,failure:`Nothing of the undo of ${e}'s rewind went through: its reasons are said below.`,cancelled:Ce(t)?Pt(e):`Stopped part way: ${e} is between the rewind and how it was before it. Undo again to finish: it takes up what this one left.`},r=ke(t),p=[s[t.status]],w=Pn(t),k=R(t.wentAlong??[],l=>l.count),$=r.deleted.done-w-k;$>0&&p.push(` sent back to the recycle bin ${u($)} record(s) the rewind brought back`+(k>0?", with what came back with them":"")),w>0&&p.push(` deleted again ${u(w)} record(s) the rewind made again, with what went with them`);let h=t.carriedAlone??[];return h.length>0&&p.push(` of them, back in the recycle bin on their own: ${y(h.map(l=>`${l.objectApiName} ${u(l.count)}`))} \u2014 they had gone there with a record the rewind brought back for a moment, which stays there; they come back alone, under the parent the checkpoint gave them`),r.broughtBack.done>0&&p.push(` brought back ${u(r.broughtBack.done)} record(s) the rewind deleted`),r.givenBack.done>0&&p.push(` gave ${u(r.givenBack.done)} record(s) back the values they had before the rewind`),o>0&&p.push(` kept ${u(o)} record(s) changed since the rewind: undo leaves them as they are now`),p.push(...Lt("undo",e,t)),p.push(...Tt("undo",t,{})),p.push(Bt(t)),p}function Lt(e,n,t){let o=t.files;if(o===void 0)return[];let i=e==="rewind"?{unlinked:"removed {n} link(s) added since between files and records: the files stay",relinked:"put back {n} link(s) removed since between files and records, under new Ids",linksUpdated:"gave {n} link(s) between files and records their sharing back"}:{unlinked:"removed again {n} link(s) between files and records the rewind put back",relinked:"put back {n} link(s) between files and records the rewind removed, under new Ids",linksUpdated:"gave {n} link(s) between files and records back the sharing they had before the rewind"},a=["unlinked","relinked","linksUpdated"].filter(c=>o[c]>0).map(c=>` ${i[c].replace("{n}",u(o[c]))}`);return o.linksRefused>0&&a.push(` ${n} refused to write ${u(o.linksRefused)} link(s) between files and records`),a}function Tt(e,n,t){let o=n.residual.map(i=>` ${i.objectApiName} ${u(i.count)} \u2014 ${Ln(e,i,t)}`);if(e==="undo")for(let i of[...n.deleted,...n.restored,...n.undeleted])i.refused!==0&&o.push(` ${i.objectApiName} ${u(i.refused)} \u2014 refused: ${i.reasons[0]??"the org gave no reason"}`);for(let i of n.unread??[])o.push(` could not be read again: ${i.objectApiName} \u2014 ${i.reason} (never taken for unchanged)`);return o}function Bt(e){return` sent ${u(e.apiRequests.used)} API requests to the org; ${u(e.apiRequests.leftToday)} left today`}function Ft(e,n,t,o,i){let a=new Map,c=r=>{let p=a.get(r);return p||(p={object:r,deleted:0,givenBack:0,broughtBack:0,refused:0},a.set(r,p)),p};for(let r of o.deleted)c(r.objectApiName).deleted+=r.deleted,c(r.objectApiName).refused+=r.refused;for(let r of o.restored)c(r.objectApiName).givenBack+=r.restored+(r.restoredWithout??0),c(r.objectApiName).refused+=r.refused;for(let r of o.undeleted)c(r.objectApiName).broughtBack+=r.undeleted+r.alreadyBack,c(r.objectApiName).refused+=r.refused;for(let r of o.recreated??[])c(r.objectApiName).refused+=r.refused;let s=(o.unread??[]).map(r=>({object:r.objectApiName,reason:r.reason}));return{checkpoint:{id:t.checkpointId,name:t.name,takenAt:t.takenAt,org:n},rewindId:o.rewindId,status:o.status,...o.scope?{limitedTo:[...o.scope.objects],notRewound:{...o.scope.notRewound}}:{},...ke(o),...e==="rewind"?{recreated:It(o),cannotUndo:(i?.objects??[]).flatMap(r=>r.cannotUndo.filter(p=>p.count>0).map(p=>({object:r.objectApiName,reason:p.reason,count:p.count})))}:{},...e==="rewind"&&(o.carriers??[]).length>0?{carriers:(o.carriers??[]).map(r=>({object:r.objectApiName,count:r.count}))}:{},...e==="rewind"&&(o.draftsLeft??[]).length>0?{draftsLeft:(o.draftsLeft??[]).map(r=>({object:r.objectApiName,count:r.count,ids:[...r.ids]}))}:{},...e==="undo"&&(o.carriedAlone??[]).length>0?{carriedAlone:(o.carriedAlone??[]).map(r=>({object:r.objectApiName,count:r.count}))}:{},...o.files?{files:{...o.files}}:{},...o.undo?{undo:{until:o.undo.until,cannot:o.undo.cannot.map(r=>({object:r.objectApiName,count:r.count,...r.reason!==void 0?{reason:r.reason}:{}}))}}:{},verify:{differences:R(o.residual,r=>r.count)+s.length,stable:o.status!=="unstable",passes:o.passes,notCompared:[...t.ignoredFields]},residual:o.residual.map(r=>({object:r.objectApiName,reason:r.reason,...r.by!==void 0?{by:r.by}:{},count:r.count,...r.message!==void 0?{message:r.message}:{}})),unread:s,objects:[...a.values()],apiRequests:o.apiRequests,result:o}}function Ut(e,n){switch(e){case"success":return 0;case"partial":return 3;case"unstable":return 4;case"failure":return 1;case"cancelled":return n!==void 0?Q(n):1}}var Fn=10*6e4,Un=720*6e4,_t=60*6e4,ie=5*6e4,rt=200,b=class extends Error{constructor(t,o=1,i=[]){super(t.message);this.refusal=t;this.code=o;this.also=i;this.name="Stop"}refusal;code;also};function _n(e){let n=[e.refusal,...e.also];return{refusal:e.refusal,...e.also.length>0?{wouldBeRefused:n.map(t=>ee(t)),wouldBeRefusedCodes:n.map(t=>t.code)}:{}}}function D(e){return e.message?.payload??{}}function P(e,n){let t=D(e);if(e.outcome==="unanswered")return{code:"UNANSWERED",message:`${n}: no answer came in time.`};let o=typeof t.message=="string"?t.message:JSON.stringify(t);return{code:typeof t.code=="string"?t.code:e.outcome.toUpperCase(),message:o}}function Mn(e){let n=D(e).alsoRefused;return e.outcome!=="failed"||!Array.isArray(n)?[]:n.flatMap(t=>{let{code:o,message:i}=t??{};return typeof o=="string"&&typeof i=="string"?[{code:o,message:i}]:[]})}async function Wn(e=process.argv,n={}){let t=on(e),o=l=>{process[t.json?"stderr":"stdout"].write(`${l}
|
|
345
|
+
`)},i=l=>{t.json&&process.stdout.write(`${JSON.stringify(l,null,2)}
|
|
346
|
+
`)},a=Me({root:t.storeRoot,...n.locksDir!==void 0?{locksDir:n.locksDir}:{}});if("refusal"in a){let{reason:l,path:m}=a.refusal,g=l==="otherOwner"?`The checkpoints cannot be kept in ${m}: another user of this machine owns it, and could read and replace the checkpoints in it. Name a folder of your own with --store.`:l==="notAFolder"?`The checkpoints cannot be kept in ${m}: it is a file, not a folder.`:`The checkpoints cannot be kept in ${m}: it could not be made${a.refusal.detail?` (${a.refusal.detail})`:""}.`;process.stderr.write(`${g}
|
|
347
|
+
`),i({refusal:{code:"STORE_REFUSED",message:g}}),B(1);return}let c=a.store,s=Jt(ct(Kt(),"sandforge-checkpoint-")),r=new ot,p=!1,w,k=()=>Promise.resolve(),$,h;try{let l=(n.createHost??nt)({storeDir:s,log:d=>{p&&d.startsWith("[INFO] ")?o(d.slice(7)):d.startsWith("[WARN] ")&&o(`warning: ${d.slice(7)}`)},compose:d=>{d.handlers.setCheckpointStore(c),d.handlers.rewindCheckpointsFromPreviewsAnswered(),d.handlers.setInfraServices({backgroundRegistry:r}),k=()=>d.handlers.sweepCheckpoints(),$=d.handlers,h=d},onPost:d=>{if(d.type!=="operation:progress")return;let f=d.payload?.currentStep;typeof f!="string"||f===w||(w=f,o(` ${f}`))}});p=!0;try{await k()}finally{p=!1}let m=async()=>{let d=await l.request({type:"checkpoint:list",timeoutMs:ie});if(d.outcome!=="answered")throw new b(P(d,"The list of checkpoints"));return D(d).checkpoints??[]},g=async d=>{try{return await l.connect(d)}catch(f){throw new b({code:"NOT_CONNECTED",message:f instanceof Ne?f.message:`${d} could not be reached: ${f instanceof Error?f.message:String(f)}`})}},A=async d=>{if(h===void 0)throw new Error("The host composed no handlers.");return qe(await Oe(d.id,h.orgRegistry,h.orgManager)).userId()};switch(t.command){case"list":{let d=await m(),f=t.org!==void 0?M(d,t.org):d;for(let j of rn(f,c.root))o(j);i(f.map(dn));return}case"take":await Vn(t,l,await g(t.org),c,r,o,i);return;case"preview":{let d=await m(),f=Z(X(d,M(d,t.org),t.checkpoint,t.org)),j=fe(f);if(j)throw new b(j);let C=f.checkpoint,S=t.objects.length>0?xt(C,t.objects):void 0,_=await g(t.org);be(_,f,C,t.org,"preview");let W=await l.request({type:"checkpoint:preview",payload:{checkpointId:f.checkpointId,...S?{objects:S}:{},acceptOutside:!1},timeoutMs:_t});if(W.outcome!=="answered")throw new b(P(W,"The preview"));let I=D(W),L=S?await ge(l,I.diff,S,!1):void 0,E=S?void 0:await Ot(l,C,I.diff,!1),v=L??E,$e=v?{...I,diff:v.diff}:I,ve=Nt(I.refusal,await re({orgName:t.org,preview:$e,bounds:{refuseWhenActive:!1},accepted:En,writers:()=>Promise.resolve([]),words:Y,user:_.username})),[Ae]=ve;for(let T of $t(t.org,C,$e,_.username))o(T);for(let T of L?Rt(L.plan):[])o(T);for(let T of E?St(E.plan):[])o(T);for(let T of ve.slice(I.refusal?1:0))o(` a rewind now would be refused (${T.code}): ${T.message}`);i(At(t.org,C,{...I,...Ae?{refusal:Ae}:{}},L,E)),B(xn(L?.diff??I.diff,t.failOnChange));return}case"rewind":case"undo":{let d={host:l,registry:r,store:c,listAll:m,connect:g,userIdOf:A,say:o,answerJson:i};t.command==="rewind"?await Kn(t,d):await Zn(t,d);return}case"delete":await zn(t,l,m,o,i);return;case"export":await Hn(t,{transfers:dt($),listAll:m,say:o,answerJson:i});return;case"import":await Gn(t,{transfers:dt($),connect:g,say:o,answerJson:i});return}}catch(l){let m=l instanceof b?l:new b({code:"FAILED",message:l instanceof Error?l.message:String(l)});process.stderr.write(`${m.message}
|
|
348
|
+
`);for(let g of m.also)process.stderr.write(`${ee(g)}
|
|
349
|
+
`);m.code!==2&&i(_n(m)),B(m.code)}finally{r.dispose(),zt(s,{recursive:!0,force:!0})}}function dt(e){if(e===void 0)throw new Error("The host composed no handlers.");return e}function qn(){try{let e=JSON.parse(Vt(ct(__dirname,"..","package.json"),"utf8"));return typeof e.version=="string"?e.version:"0.0.0"}catch{return"0.0.0"}}function Mt(e){let n=process.env[e];if(n===void 0||n.trim()==="")throw new b({code:"NO_KEY",message:`${e} is not set: it holds no key. Nothing was run.`},2);let t=ne(n);if(t===void 0)throw new b({code:"NO_KEY",message:`${e} holds no key SandForge reads: 52 letters and digits, in groups of four as an export shows one. Nothing was run.`},2);return t}function Wt(e,n){return{id:e.checkpointId,name:e.name,takenAt:e.takenAt,org:n}}async function Hn(e,n){let{say:t,answerJson:o}=n,i=e.keyEnv!==void 0?Mt(e.keyEnv):void 0,a=await n.listAll(),c=Z(X(a,M(a,e.org),e.checkpoint,e.org)),s=await n.transfers.exportCheckpoint({checkpointId:c.checkpointId,out:e.out,...i!==void 0?{key:i}:{},sandforgeVersion:qn()});if(!s.exported)throw new b(s.refusal);let{checkpoint:r,header:p}=s;t(`exported '${r.name}' (${r.checkpointId}) of ${e.org}, taken ${N(r.takenAt)}: ${u(p.records)} record(s) of ${u(p.objects)} object(s), ${F(s.bytes)}, to ${e.out}`),t(` sha256 ${s.sha256}`),s.key!==void 0&&process.stderr.write(` key, shown this once and kept nowhere: ${s.key}
|
|
350
|
+
`),t(` Anyone who has this file and its key can read the ${u(p.records)} records it holds of ${e.org}, personal data among them. Send the key another way than the file, and only to people who already see all data in ${e.org}.`),t(" The file does not expire: delete it once it has served."),o({checkpoint:Wt(r,e.org),file:e.out,bytes:s.bytes,sha256:s.sha256,records:p.records,objects:p.objects,keyShown:s.key!==void 0})}async function Gn(e,n){let{say:t,answerJson:o}=n,i=e.keyEnv!==void 0?Mt(e.keyEnv):void 0,a=await n.connect(e.org),c=await n.transfers.readCheckpointImport({orgId:a.id,file:e.file});if(c.header!==void 0){let{header:w}=c;t(`the file holds checkpoint ${w.checkpointId}, taken ${N(w.takenAt)}: ${u(w.records)} record(s) of ${u(w.objects)} object(s), ${F(w.bytes)}, exported by SandForge ${w.sandforgeVersion}`)}if(!c.allowed)throw new b(c.refusal);let s=i??await Jn(),r=await n.transfers.importCheckpoint({orgId:a.id,file:e.file,key:s,keepDays:e.keepDays});if(!r.imported)throw new b(r.refusal);let{checkpoint:p}=r;t(r.outcome==="imported"?`imported '${p.name}' (${p.checkpointId}) of ${e.org}: ${u(K(p))} record(s) of ${u(p.objects.length)} object(s), ${pe(p.expiresAt)}`:`'${p.name}' (${p.checkpointId}) is kept on this machine already, the same: left as it is`);for(let w of r.warnings)t(` ${w}`);o({outcome:r.outcome,checkpoint:Wt(p,e.org),records:K(p),objects:p.objects.length,expiresAt:p.expiresAt,warnings:r.warnings})}async function Jn(){let e=await Je("Key of the file (not shown as you type it):","give --key-env VAR, the name of an environment variable that holds the key");if(e===void 0||e.trim()==="")throw new b({code:"DECLINED",message:"No key was typed. Nothing was imported."});let n=ne(e);if(n===void 0)throw new b({code:"IMPORT_KEY",message:"That is not a key SandForge draws: 52 letters and digits, in groups of four as the export showed it. Nothing was imported."});return n}function Z(e){if("entry"in e)return e.entry;throw"ambiguous"in e?new b({code:"AMBIGUOUS",message:e.ambiguous},2):new b({code:"NOT_FOUND",message:e.none})}async function Vn(e,n,t,o,i,a,c){let{take:s}=e;if(e.estimate){let m={orgId:t.id,mode:s.mode,...s.objects?{objects:s.objects}:{},...s.excluded?{excluded:s.excluded}:{},...s.customSettings?{customSettings:s.customSettings}:{},...s.maxTotal!==void 0?{maxTotal:s.maxTotal}:{}},g=await n.request({type:"checkpoint:scope",payload:m,timeoutMs:Fn});if(g.outcome!=="answered")throw new b(P(g,"The estimate"));let A=D(g),d={mode:A.mode,objects:A.objects,leftOut:A.leftOut,estimate:A.estimate,...A.refusal?{refusal:A.refusal}:{},...A.files?{files:A.files}:{},...A.customSettings?{customSettings:A.customSettings}:{}};for(let f of hn(e.org,d))a(f);c(cn(d)),B(d.refusal?1:0);return}a(`taking a checkpoint of ${e.org}: it reads every record of its objects (Ctrl-C stops it, and nothing of it is kept)`);let{answer:r,stoppedBy:p}=await ye(i,"the take stops after the read under way, and keeps nothing",()=>n.request({type:"checkpoint:take",payload:{orgId:t.id,...s},timeoutMs:Un}));if(r.outcome!=="answered"){let m=P(r,"The take");throw p!==void 0&&m.code==="CANCELLED"?new b(m,Q(p)):new b(m)}let w=D(r),k=w.checkpoint,$=w.requests,h=w.estimate,l=o.folderOf(k.org.organizationId,k.checkpointId).dir;for(let m of fn(k,l,s.objects??[]))a(m);$&&a(wn($,h)),c({checkpoint:k,...$?{requests:$}:{},...h?{estimate:h}:{}})}async function zn(e,n,t,o,i){let a=await t(),c=M(a,e.org),s=e.checkpoint===void 0?c:[Z(X(a,c,e.checkpoint,e.org))];if(s.length===0)throw new b({code:"NOT_FOUND",message:`No checkpoint of ${e.org} is kept on this machine. Nothing was deleted.`});let r=h=>h.checkpoint?`'${h.checkpoint.name}' (${h.checkpointId})`:h.checkpointId;if(!e.yes){let h=s.filter(g=>g.undo!==void 0),m=`${s.length===1?`Delete ${r(s[0])}${s[0].checkpoint?`, taken ${N(s[0].checkpoint.takenAt)},`:""} from this machine? ${e.org} can no longer be rewound to it`:`Delete the ${s.length} checkpoints of ${e.org} from this machine (${y(s.map(r),4)})? ${e.org} can no longer be rewound to them`}${h.length>0?", and its last rewind can no longer be undone":""}. The org is not touched.`;if(!await Ge(m))throw new b({code:"DECLINED",message:"Nothing was deleted."})}let p=s.map(h=>h.checkpointId);for(let h=0;h<p.length;h+=rt){let l=await n.request({type:"checkpoint:delete",payload:{checkpointIds:p.slice(h,h+rt)},timeoutMs:ie});if(l.outcome!=="answered"){let m=P(l,"The delete");if(h===0)throw new b(m);o(`refused: ${m.message}`);break}}let w=new Set((await t()).map(h=>h.checkpointId)),k=s.filter(h=>!w.has(h.checkpointId)),$=s.filter(h=>w.has(h.checkpointId));for(let h of k)o(`deleted ${r(h)}`);for(let h of $)o(`kept ${r(h)}: a take, a rewind or an undo of its org is running; delete it once it has ended`);i({deleted:k.map(h=>h.checkpointId),kept:$.map(h=>h.checkpointId)}),$.length>0&&B(k.length>0?3:1)}function be(e,n,t,o,i){if(ht(e.orgId,n.organizationId))return;let a=M([n],o).length>0,c=i==="preview"?"preview it":i==="rewind"?"rewind to it":"undo it";throw new b({code:"OTHER_ORG",message:a?`${o} answers as another org than the one '${t.name}' was taken of: a sandbox refreshed since is another org, and this checkpoint can only be deleted. No record was read.`:`'${t.name}' is a checkpoint of ${q(t)}, not of ${o}: ${c} with --org ${q(t)}. No record was read.`})}async function ye(e,n,t){let o,i=e.onEvent((c,s,r)=>{o!==void 0&&s==="started"&&r.module==="checkpoint"&&e.abort(c)}),a=Ie(c=>{o=c,process.stderr.write(`
|
|
351
|
+
interrupted: ${n} (Ctrl-C again ends it at once)
|
|
352
|
+
`);for(let s of e.getRunning())s.module==="checkpoint"&&e.abort(s.operationId)});try{let c=await t();return o!==void 0?{answer:c,stoppedBy:o}:{answer:c}}finally{a(),i()}}var qt=720*6e4;function Ht(e,n,t=o=>o){let{answer:o,stoppedBy:i}=e;if(o.outcome!=="answered"){let a=t(P(o,n));throw i!==void 0&&a.code==="CANCELLED"?new b(a,Q(i)):new b(a,1,Mn(o).map(t))}return D(o).result}async function Kn(e,n){let{host:t,say:o,answerJson:i}=n,a=await n.listAll(),c=Z(X(a,M(a,e.org),e.checkpoint,e.org)),s=fe(c);if(s)throw new b(s);let r=c.checkpoint,p=e.ignoreFields.filter(v=>!r.ignoredFields.includes(v));if(p.length>0){let v=await t.request({type:"checkpoint:ignore-fields",payload:{checkpointId:c.checkpointId,fields:[...r.ignoredFields,...p]},timeoutMs:ie});if(v.outcome!=="answered")throw new b(P(v,"The fields not to compare"));r=D(v).checkpoint,o(`not compared from now on, nor written back: ${p.join(", ")} (kept in '${r.name}')`)}let w=e.objects.length>0?xt(r,e.objects):void 0,k=await n.connect(e.org);be(k,c,r,e.org,"rewind");let $=await t.request({type:"checkpoint:preview",payload:{checkpointId:c.checkpointId,...w?{objects:w}:{},...e.muteAutomation?{muteAutomation:!0}:{},acceptOutside:e.acceptOutside},timeoutMs:_t});if($.outcome!=="answered")throw new b(P($,"The preview"));let h=D($),l=w?await ge(t,h.diff,w,e.acceptOutside):void 0,m=w?void 0:await Ot(t,r,h.diff,e.acceptOutside),g=l??m,A=g?{...h,diff:g.diff}:h,d=e.muteAutomation&&A.automation?Te(A.automation,Se(V(A.diff))):void 0,f=d?{...A,automation:d.automation}:A;for(let v of $t(e.org,r,f,k.username,e.acceptAutomation))o(v);for(let v of l?Rt(l.plan):[])o(v);for(let v of m?St(m.plan):[])o(v);for(let v of d?te(d.planned,e.org):[])o(` ${v}`);let j=Ke(f.diff).length>0,C=await re({orgName:e.org,preview:f,bounds:{...e.maxRecords!==void 0?{maxRecords:e.maxRecords}:{},refuseWhenActive:e.refuseWhenActive},accepted:e,writers:async()=>ze(r.takenBy,await n.userIdOf(k)),words:Y,user:k.username}),S=Nt(f.refusal,C);if(Ct(r,f.diff,e.acceptOutside)&&o(" without --accept-outside, the records they hang from stay, and so do they: each is said once the rewind is through"),e.dryRun){for(let v of S.slice(f.refusal?1:0))o(` a rewind now would be refused (${v.code}): ${v.message}`);i({...At(e.org,r,h,l,m),...d?{mutedAutomation:d.planned,mutePlan:d.plan}:{},...S.length>0?{wouldBeRefused:S.map(v=>ee(v)),wouldBeRefusedCodes:S.map(v=>v.code)}:{}});return}let[W,...I]=S;if(W)throw new b(W,1,I);if(j&&!e.yes&&await ae(Dn(e.org,r,f.diff,w))!==e.org)throw new b({code:"DECLINED",message:"Nothing was written."});let L=await ye(n.registry,"the rewind stops before its next call to the org, and leaves its journal: rewind again takes up from what still differs",()=>t.request({type:"checkpoint:rewind",payload:{checkpointId:c.checkpointId,previewId:f.diff.previewId,...w?{objects:w}:{},acceptAutomation:e.acceptAutomation,...e.acceptEmails?{acceptEmails:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{},acceptNoUndo:e.acceptNoUndo,acceptRecreate:e.acceptRecreate,acceptOutside:e.acceptOutside,acceptUnseen:e.acceptUnseen},timeoutMs:qt})),E=Ht(L,"The rewind",v=>v.code==="CANCELLED"?{...v,message:Dt(e.org,r.name)}:Nn(v));for(let v of Tn(e.org,r,E,f.diff.userNames))o(v);for(let v of E.mutedAutomation?te(E.mutedAutomation,e.org):[])o(v);i(Ft("rewind",e.org,r,E,f.diff)),B(Ut(E.status,L.stoppedBy))}function Yn(e,n,t,o,i){return`undo the rewind ${t} of ${e} to '${n.name}' (open until ${N(o)}, sooner if the recycle bin fills)`+(i?`: it brings back ${u(i.bringBack)} record(s) the rewind deleted, gives ${u(i.giveBack)} record(s) back the values they had before it, and sends ${u(i.remove-i.remade)} record(s) it brought back to the recycle bin`+(i.along>0?", with what came back with them":"")+(i.remade>0?`, deleting again the ${u(i.remade)} record(s) it made again`:"")+(i.drafted>0?` \u2014 of them, ${u(i.drafted)} order(s) set back to Draft first if past it, the one way Salesforce deletes one: an update, which what runs on an order's update fires on`:"")+"; what anyone changed since the rewind stays":"")}async function Xn(e,n,t,o){try{let i=e.folderOf(n.organizationId,n.checkpointId),a=await Qe(i,o,t.objects);try{return{bringBack:a.bringBack.count,giveBack:a.giveBack.count,remove:a.remove.spool.count,along:a.goesWithParent.count,remade:a.remade.keys.size,drafted:a.remade.objects.filter(({objectApiName:c})=>Le([c]).length>0).reduce((c,{count:s})=>c+s,0)}}finally{await a.dispose()}}catch{return}}async function Zn(e,n){let{host:t,say:o,answerJson:i}=n,a=await n.listAll(),c=M(a,e.org),s=e.checkpoint===void 0?c.find(g=>g.undo!==void 0):Z(X(a,c,e.checkpoint,e.org));if(!s)throw new b({code:"NOT_FOUND",message:`No rewind of ${e.org} can be undone from this machine: Undo is offered for the last rewind of an org, for 15 days after it, until it is undone. Nothing was written.`});let r=fe(s);if(r)throw new b(r);let p=s.checkpoint;if(!s.undo)throw new b({code:"UNDO_CLOSED",message:`'${p.name}' has no rewind that can be undone: Undo is offered for the last rewind of an org only, for 15 days after it, until it is undone. Nothing was written.`});let{rewindId:w,until:k}=s.undo,$=await Xn(n.store,s,p,w);o(Yn(e.org,p,w,k,$));let h=await n.connect(e.org);if(be(h,s,p,e.org,"undo"),!e.yes&&await ae(`Type ${e.org} to undo its rewind:`)!==e.org)throw new b({code:"DECLINED",message:"Nothing was written."});let l=await ye(n.registry,"the undo stops before its next call to the org: undo again takes up what it left",()=>t.request({type:"checkpoint:undo",payload:{checkpointId:s.checkpointId,rewindId:w,acceptAutomation:e.acceptAutomation,...e.acceptEmails?{acceptEmails:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{}},timeoutMs:qt})),m=Ht(l,"The undo",g=>g.code==="CANCELLED"?{...g,message:Pt(e.org)}:In(g));for(let g of Bn(e.org,p,m))o(g);for(let g of m.mutedAutomation?te(m.mutedAutomation,e.org):[])o(g);i(Ft("undo",e.org,p,m)),B(Ut(m.status,l.stoppedBy))}process.argv[1]?.includes("sandforge-checkpoint")&&(Ve(),Wn().then(()=>process.exit(process.exitCode??0)).catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
|
|
353
|
+
`),process.exit(1)}));export{Io as acceptanceRefusal,M as checkpointsOf,nn as defaultName,xt as heldObjectsOrStop,fe as invalidRefusal,Ct as keepsOutside,St as keptLines,bt as linkWritesOf,dn as listEntryJson,rn as listLines,Wn as main,we as orgDiffers,on as parseArgs,xn as previewExitCode,At as previewJson,$t as previewLines,J as previewTotals,wn as requestsLine,X as resolveCheckpoint,Ut as resultExitCode,Ft as resultJson,Tn as rewindLines,Dn as rewindQuestion,V as rewindStepsOf,cn as scopeJson,hn as scopeLines,Ye as selectionDiff,Rt as selectionLines,fn as takeLines,Yn as undoLine,Bn as undoLines};
|
|
@@ -0,0 +1,56 @@
|
|
|
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 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
|
|
8
|
+
--since window, whether or not a clone wrote them. Preview with --dry-run and
|
|
9
|
+
narrow with --objects before deleting.
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
npx sandforge cleanup --target <alias> [options]
|
|
13
|
+
|
|
14
|
+
Required:
|
|
15
|
+
--target <alias> sf CLI alias of the target sandbox, or Developer
|
|
16
|
+
Edition org. A production org is refused.
|
|
17
|
+
|
|
18
|
+
Options:
|
|
19
|
+
--since <when> the records created from the start of: today
|
|
20
|
+
(default), yesterday, last_week, this_week,
|
|
21
|
+
last_n_days:N (N days ago), or an ISO date
|
|
22
|
+
YYYY-MM-DD (midnight UTC), up to now.
|
|
23
|
+
--objects <a,b,c> Comma-separated object API names. Defaults to a
|
|
24
|
+
whitelist of common Forge targets.
|
|
25
|
+
--max <n> Max records to delete per object (default: 200).
|
|
26
|
+
--dry-run Print counts and what the target runs as they would
|
|
27
|
+
go, don't delete.
|
|
28
|
+
${Q("deleted","--dry-run")} --json print per object the records found, deleted and
|
|
29
|
+
refused as JSON on stdout, every other line on stderr
|
|
30
|
+
-h, --help Show this help.
|
|
31
|
+
|
|
32
|
+
Before it deletes, the cleanup says what the target runs as the records go:
|
|
33
|
+
its record-triggered flows, Apex triggers, processes and workflow rules on
|
|
34
|
+
delete, before and after, the emails that sends against what the target has
|
|
35
|
+
left today, and whether it delivers them (with --json, under automation).
|
|
36
|
+
What the target deletes along with the records (a contact's tasks, an
|
|
37
|
+
account's contacts) goes too, uncounted, and runs none of its delete
|
|
38
|
+
automation: Salesforce runs none on a record deleted with its parent, so it
|
|
39
|
+
is not read.
|
|
40
|
+
|
|
41
|
+
Exit codes: 0 every record found was deleted (or counted, with --dry-run);
|
|
42
|
+
1 the cleanup could not start, the target is a production org, an object
|
|
43
|
+
could not be read or deleted (one the target does not have is passed over),
|
|
44
|
+
or the cleanup was refused for what the target runs as it deletes, without
|
|
45
|
+
--accept-automation (AUTOMATION_NOT_ACCEPTED), emails it delivers, without
|
|
46
|
+
--accept-emails (EMAILS_NOT_ACCEPTED), more emails than it has left today
|
|
47
|
+
(EMAILS_EXCEEDED), or a mute refused \u2014 a --dry-run that saw a real run would be
|
|
48
|
+
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};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{$ as I,$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};
|