sandforge 1.80.0 → 1.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/bin/sandforge-pipeline.mjs +12 -0
- package/bin/sandforge-users.mjs +12 -0
- package/lib/{chunk-J525F5KI.mjs → chunk-27Z76O2O.mjs} +1 -1
- package/lib/chunk-2JZGCCPG.mjs +9 -0
- package/lib/{chunk-ELFXJHU7.mjs → chunk-2UU42PTD.mjs} +1 -1
- package/lib/{chunk-N652NMZ4.mjs → chunk-32EUNQT6.mjs} +52 -52
- package/lib/chunk-3C2ZZIFN.mjs +7 -0
- package/lib/chunk-3CX7GPCR.mjs +7 -0
- package/lib/chunk-3HEMJTAP.mjs +925 -0
- package/lib/{chunk-BY2HJFFG.mjs → chunk-3HROD5RE.mjs} +1 -1
- package/lib/{chunk-OHWNPXWW.mjs → chunk-3MGMNK3Q.mjs} +1 -1
- package/lib/{chunk-PZPJKATS.mjs → chunk-3SKLBRPL.mjs} +8 -8
- package/lib/chunk-3XG25GTF.mjs +7 -0
- package/lib/chunk-42BFLWHR.mjs +7 -0
- package/lib/chunk-466F37VD.mjs +7 -0
- package/lib/chunk-47UHTN3Q.mjs +7 -0
- package/lib/chunk-4JKR4PTZ.mjs +8 -0
- package/lib/{chunk-COFG7Q6R.mjs → chunk-52EXDVPN.mjs} +1 -1
- package/lib/{chunk-SAR5622P.mjs → chunk-54HYHHVL.mjs} +1 -1
- package/lib/{chunk-RSWDYIHY.mjs → chunk-5GBO4KD5.mjs} +1 -1
- package/lib/chunk-5K2I2DMP.mjs +11 -0
- package/lib/{chunk-AV5SWEHP.mjs → chunk-6FARZYMJ.mjs} +1 -1
- package/lib/{chunk-BV6VTP3J.mjs → chunk-6GQUZ4IP.mjs} +1 -1
- package/lib/chunk-6KP6WETK.mjs +9 -0
- package/lib/{chunk-MJVTDA5Q.mjs → chunk-6VSZNZHH.mjs} +1 -1
- package/lib/{chunk-XUWL6ZPC.mjs → chunk-7CVDVBEE.mjs} +1 -1
- package/lib/{chunk-UCD54V2M.mjs → chunk-7EYQYZJP.mjs} +1 -1
- package/lib/{chunk-5K5VLULK.mjs → chunk-7LKI7OAS.mjs} +1 -1
- package/lib/chunk-7PY3VQP3.mjs +7 -0
- package/lib/chunk-7SDZR6SR.mjs +7 -0
- package/lib/chunk-7WSLT5VX.mjs +8 -0
- package/lib/chunk-A32ISQ6M.mjs +28 -0
- package/lib/{chunk-M3ROUWDX.mjs → chunk-A65ADTCR.mjs} +1 -1
- package/lib/chunk-A7JJWOLT.mjs +7 -0
- package/lib/chunk-AUS6NFLZ.mjs +8 -0
- package/lib/chunk-BMTNTBBM.mjs +7 -0
- package/lib/{chunk-SOU4FRYN.mjs → chunk-BN33LVPQ.mjs} +1 -1
- package/lib/chunk-BNKT3R3F.mjs +7 -0
- package/lib/{chunk-K2FBZIXY.mjs → chunk-BWWQXU2B.mjs} +1 -1
- package/lib/{chunk-IC2C2GOF.mjs → chunk-BXZ73A5M.mjs} +1 -1
- package/lib/{chunk-WA7EYLAQ.mjs → chunk-C2N2TNEU.mjs} +1 -1
- package/lib/{chunk-BKDV4ENO.mjs → chunk-C3LNYAVJ.mjs} +1 -1
- package/lib/{chunk-XLXIPIEW.mjs → chunk-CBL42DUU.mjs} +1 -1
- package/lib/chunk-CCEH7L53.mjs +7 -0
- package/lib/chunk-CELEBWEZ.mjs +7 -0
- package/lib/chunk-CV47FDQW.mjs +7 -0
- package/lib/{chunk-2UZPIMUC.mjs → chunk-CZLJZQCS.mjs} +1 -1
- package/lib/chunk-DBBPDSFN.mjs +7 -0
- package/lib/chunk-DIL62SUN.mjs +7 -0
- package/lib/chunk-DIS254AN.mjs +7 -0
- package/lib/{chunk-BTWDMNN3.mjs → chunk-DJCGURW7.mjs} +1 -1
- package/lib/{chunk-F6GUDTOB.mjs → chunk-DT3T7FRD.mjs} +1 -1
- package/lib/{chunk-IGYH7GMA.mjs → chunk-DWMRIWV5.mjs} +1 -1
- package/lib/{chunk-YRQGKDHM.mjs → chunk-EEFUE2ES.mjs} +1 -1
- package/lib/{chunk-FGRG7ANU.mjs → chunk-EOFO3PHS.mjs} +1 -1
- package/lib/{chunk-KBJ5VERV.mjs → chunk-FA4ZKDCU.mjs} +1 -1
- package/lib/{chunk-WU3GLFZO.mjs → chunk-FKK5YBGZ.mjs} +1 -1
- package/lib/chunk-FOIWWK7G.mjs +156 -0
- package/lib/chunk-FZF23M6R.mjs +7 -0
- package/lib/chunk-G2JR3F63.mjs +7 -0
- package/lib/{chunk-JEERQRLW.mjs → chunk-GBGHJTPC.mjs} +1 -1
- package/lib/{chunk-3RZQZHEB.mjs → chunk-GCGHHN4K.mjs} +1 -1
- package/lib/{chunk-RPI7LRTW.mjs → chunk-GGNUACTY.mjs} +1 -1
- package/lib/{chunk-EMNC6YI4.mjs → chunk-GGUOIDWP.mjs} +1 -1
- package/lib/chunk-GHPR5UVV.mjs +7 -0
- package/lib/{chunk-X5JYBPXP.mjs → chunk-GJ6SZVHT.mjs} +1 -1
- package/lib/{chunk-W622GUAW.mjs → chunk-H4JUYUSL.mjs} +1 -1
- package/lib/{chunk-XAMBCQPU.mjs → chunk-H4OBZIX3.mjs} +1 -1
- package/lib/{chunk-WIO4XO4F.mjs → chunk-HFSBDM7B.mjs} +1 -1
- package/lib/{chunk-L77FJZEP.mjs → chunk-HFUDCNU5.mjs} +1 -1
- package/lib/chunk-HIHCYMSL.mjs +7 -0
- package/lib/chunk-HKUWHVI7.mjs +9 -0
- package/lib/chunk-HQQVANWQ.mjs +20 -0
- package/lib/chunk-ICIYL45C.mjs +7 -0
- package/lib/chunk-IRZJU2PG.mjs +22 -0
- package/lib/chunk-ISSP2FZ5.mjs +7 -0
- package/lib/chunk-IVZJSDJD.mjs +7 -0
- package/lib/chunk-J24TIGSI.mjs +10 -0
- package/lib/{chunk-UNJA4J37.mjs → chunk-JESRFE2Z.mjs} +4 -4
- package/lib/chunk-JFNLKHY6.mjs +8 -0
- package/lib/chunk-JH27IKCO.mjs +9 -0
- package/lib/chunk-JJITOWZK.mjs +7 -0
- package/lib/{chunk-E5AHXLS6.mjs → chunk-JKT5YAQ2.mjs} +1 -1
- package/lib/{chunk-IWDREM66.mjs → chunk-JLZRZL5E.mjs} +1 -1
- package/lib/{chunk-FPKYYFM7.mjs → chunk-JPEVIXNH.mjs} +1 -1
- package/lib/chunk-JQZTMFO7.mjs +7 -0
- package/lib/chunk-KIMQQ6JQ.mjs +7 -0
- package/lib/{chunk-MILU7WFN.mjs → chunk-KJYEQHYP.mjs} +1 -1
- package/lib/chunk-KKOA62S4.mjs +474 -0
- package/lib/chunk-KP5G6FUC.mjs +7 -0
- package/lib/{chunk-JWTSEDIQ.mjs → chunk-L4INJ5TZ.mjs} +1 -1
- package/lib/{chunk-OLSGVAIL.mjs → chunk-LAUOSXMN.mjs} +53 -53
- package/lib/{chunk-MTMH6H2A.mjs → chunk-LCDPCUXS.mjs} +1 -1
- package/lib/{chunk-KDGMAGQR.mjs → chunk-LHU6CPGE.mjs} +1 -1
- package/lib/{chunk-YAZO75G2.mjs → chunk-LNXBCE7E.mjs} +1 -1
- package/lib/chunk-LXDSRP2W.mjs +7 -0
- package/lib/{chunk-2YIV2OB2.mjs → chunk-MIDBQ7SD.mjs} +1 -1
- package/lib/{chunk-TTKXMDBN.mjs → chunk-MKTXJCXN.mjs} +4 -4
- package/lib/chunk-MUEQRIK7.mjs +9 -0
- package/lib/{chunk-IOIWJ3DJ.mjs → chunk-NLB3RGIY.mjs} +1 -1
- package/lib/{chunk-O2HDYYUV.mjs → chunk-NWOI25WY.mjs} +1 -1
- package/lib/chunk-O2PUGRNW.mjs +10 -0
- package/lib/chunk-O4BROUGM.mjs +7 -0
- package/lib/chunk-OETEC3P7.mjs +7 -0
- package/lib/{chunk-GCOB7K5N.mjs → chunk-OHEOJISY.mjs} +1 -1
- package/lib/chunk-P55MKIZX.mjs +37 -0
- package/lib/chunk-P63WJMXQ.mjs +7 -0
- package/lib/chunk-PBE44M2Y.mjs +7 -0
- package/lib/{chunk-TYYOBZMU.mjs → chunk-PC247GKX.mjs} +1 -1
- package/lib/chunk-PE435FVH.mjs +15 -0
- package/lib/chunk-PPGDAUEQ.mjs +7 -0
- package/lib/{chunk-SE4QEZUG.mjs → chunk-PPHVWUFY.mjs} +1 -1
- package/lib/{chunk-CU2INBND.mjs → chunk-PR74GYVI.mjs} +1 -1
- package/lib/chunk-PWVDNN2C.mjs +7 -0
- package/lib/{chunk-6XYKJSGX.mjs → chunk-PYRZFUVU.mjs} +1 -1
- package/lib/{chunk-TLH7AD35.mjs → chunk-PZBZ7MNC.mjs} +1 -1
- package/lib/{chunk-DYFALGRT.mjs → chunk-Q3DY7TO2.mjs} +1 -1
- package/lib/{chunk-BGUEWRK2.mjs → chunk-Q6SXNKV2.mjs} +1 -1
- package/lib/chunk-QAPVKPEC.mjs +7 -0
- package/lib/{chunk-DBFJB2B6.mjs → chunk-QIRO4HTE.mjs} +1 -1
- package/lib/{chunk-TSLJUSLW.mjs → chunk-RCYEBY42.mjs} +1 -1
- package/lib/chunk-RLWB7F26.mjs +7 -0
- package/lib/{chunk-FXXLX4O6.mjs → chunk-RTWYLOCA.mjs} +1 -1
- package/lib/chunk-RYRMUPMY.mjs +7 -0
- package/lib/chunk-SAMWHL22.mjs +13 -0
- package/lib/{chunk-IZQZ6ZUF.mjs → chunk-SFGZFB4F.mjs} +1 -1
- package/lib/{chunk-FKG7Q3WH.mjs → chunk-SNEOKYV7.mjs} +1 -1
- package/lib/{chunk-3TJON4F3.mjs → chunk-STRMWSIQ.mjs} +1 -1
- package/lib/chunk-SZGGFST2.mjs +272 -0
- package/lib/{chunk-SOGQW4IG.mjs → chunk-T7WREYA5.mjs} +1 -1
- package/lib/{chunk-NTFIRZP6.mjs → chunk-TCBAE65A.mjs} +1 -1
- package/lib/{chunk-KYEDBS54.mjs → chunk-TEIBWMJM.mjs} +1 -1
- package/lib/{chunk-YKKRIEH4.mjs → chunk-TMA34QMA.mjs} +1 -1
- package/lib/chunk-TQ2TQHTT.mjs +9 -0
- package/lib/{chunk-HEKAZJRH.mjs → chunk-TWV4A5RK.mjs} +1 -1
- package/lib/{chunk-CEX3NEZL.mjs → chunk-UHFLKP26.mjs} +1 -1
- package/lib/chunk-UV74P4H2.mjs +7 -0
- package/lib/{chunk-WR4Q363I.mjs → chunk-V3R45ZWT.mjs} +1 -1
- package/lib/{chunk-GSKCGQIP.mjs → chunk-VPDEJGPS.mjs} +1 -1
- package/lib/{chunk-HLWMJF6Y.mjs → chunk-VQJMP3DC.mjs} +1 -1
- package/lib/chunk-VV3B6IC3.mjs +7 -0
- package/lib/{chunk-PJ5I73CK.mjs → chunk-VYOYXTCU.mjs} +1 -1
- package/lib/{chunk-NZC67CGR.mjs → chunk-VZT4E2OJ.mjs} +1 -1
- package/lib/{chunk-AEKONPF4.mjs → chunk-VZVICK7Q.mjs} +1 -1
- package/lib/{chunk-WR2GIKWE.mjs → chunk-WB2RIVO3.mjs} +1 -1
- package/lib/chunk-WEMLDUQA.mjs +7 -0
- package/lib/{chunk-MYW5QNGI.mjs → chunk-WOOUISSO.mjs} +1 -1
- package/lib/{chunk-G35N4P7D.mjs → chunk-WSUKC2U3.mjs} +1 -1
- package/lib/{chunk-ZVAED4QV.mjs → chunk-WT3SCUHS.mjs} +1 -1
- package/lib/{chunk-7EANH5PY.mjs → chunk-WZQEK4WT.mjs} +1 -1
- package/lib/{chunk-DBB3EMIN.mjs → chunk-XFU3HRUV.mjs} +1 -1
- package/lib/chunk-XK5W7BVE.mjs +7 -0
- package/lib/{chunk-2GTBABKU.mjs → chunk-XO5FBOQF.mjs} +1 -1
- package/lib/{chunk-CHYDMRSV.mjs → chunk-XSKPYGMT.mjs} +1 -1
- package/lib/chunk-XU25YA46.mjs +9 -0
- package/lib/chunk-XZISAZA6.mjs +7 -0
- package/lib/chunk-Y4TDVDP2.mjs +13 -0
- package/lib/chunk-YAIIRFKJ.mjs +8 -0
- package/lib/{chunk-LKQ5RKIV.mjs → chunk-YAJQS3OL.mjs} +1 -1
- package/lib/{chunk-74Q6DORA.mjs → chunk-YGJF55VJ.mjs} +1 -1
- package/lib/chunk-YH4DYI6D.mjs +7 -0
- package/lib/chunk-YMDFF657.mjs +10 -0
- package/lib/{chunk-2BA2XKAY.mjs → chunk-YT22LMF7.mjs} +1 -1
- package/lib/{chunk-IG2MTQRP.mjs → chunk-Z42PHCVZ.mjs} +1 -1
- package/lib/{chunk-2NBYT7GR.mjs → chunk-ZHIZY3ZC.mjs} +1 -1
- package/lib/chunk-ZQO5PDX5.mjs +48 -0
- package/lib/chunk-ZRUDYB7O.mjs +7 -0
- package/lib/{chunk-BXU6WFMH.mjs → chunk-ZUBBEP75.mjs} +1 -1
- package/lib/chunk-ZUOPC4W2.mjs +7 -0
- package/lib/{chunk-GGD7ON3M.mjs → chunk-ZUTUYBNW.mjs} +1 -1
- package/lib/{chunk-MHMH6MTP.mjs → chunk-ZXFL2MSN.mjs} +1 -1
- package/lib/sandforge-autopilot.mjs +11 -11
- package/lib/sandforge-backup.mjs +63 -32
- package/lib/sandforge-checkpoint.mjs +1 -348
- package/lib/sandforge-cleanup.mjs +1 -1
- package/lib/sandforge-clone.mjs +1 -1
- package/lib/sandforge-compare.mjs +1 -1
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +11 -11
- package/lib/sandforge-env.mjs +186 -140
- package/lib/sandforge-frozen.mjs +1 -266
- package/lib/sandforge-mcp.mjs +33 -14
- package/lib/sandforge-monitor.mjs +1 -1
- package/lib/sandforge-pipeline.mjs +88 -0
- package/lib/sandforge-seed.mjs +1 -1
- package/lib/sandforge-sync.mjs +1 -1
- package/lib/sandforge-users.mjs +157 -0
- package/lib/sandforge.mjs +1 -22
- package/lib/sf/sandforge/autopilot.mjs +20 -0
- package/lib/sf/sandforge/backup.mjs +20 -0
- package/lib/sf/sandforge/checkpoint.mjs +20 -0
- package/lib/sf/sandforge/cleanup.mjs +20 -0
- package/lib/sf/sandforge/clone.mjs +20 -0
- package/lib/sf/sandforge/compare.mjs +20 -0
- package/lib/sf/sandforge/dataops.mjs +20 -0
- package/lib/sf/sandforge/empty.mjs +20 -0
- package/lib/sf/sandforge/env.mjs +20 -0
- package/lib/sf/sandforge/frozen.mjs +20 -0
- package/lib/sf/sandforge/hardis-commands.mjs +20 -0
- package/lib/sf/sandforge/index.mjs +20 -0
- package/lib/sf/sandforge/mcp.mjs +20 -0
- package/lib/sf/sandforge/monitor.mjs +20 -0
- package/lib/sf/sandforge/pipeline.mjs +20 -0
- package/lib/sf/sandforge/seed.mjs +20 -0
- package/lib/sf/sandforge/sync.mjs +20 -0
- package/lib/sf/sandforge/users.mjs +20 -0
- package/lib/sfHelpHook.mjs +7 -0
- package/lib/sfPlugin.mjs +11 -0
- package/oclif.manifest.json +1 -0
- package/package.json +18 -3
- package/lib/chunk-2CNCDM56.mjs +0 -7
- package/lib/chunk-3F6Q5E7I.mjs +0 -14
- package/lib/chunk-4VS2V6WU.mjs +0 -25
- package/lib/chunk-5P4PHJRL.mjs +0 -9
- package/lib/chunk-5TC3QB4U.mjs +0 -10
- package/lib/chunk-7ABODJ4G.mjs +0 -7
- package/lib/chunk-7EGQP6S4.mjs +0 -7
- package/lib/chunk-7FFGJWHN.mjs +0 -7
- package/lib/chunk-7YDNUBO5.mjs +0 -7
- package/lib/chunk-A527W53V.mjs +0 -7
- package/lib/chunk-ADOAS63R.mjs +0 -7
- package/lib/chunk-B5QQJ4SI.mjs +0 -7
- package/lib/chunk-CION3VMZ.mjs +0 -7
- package/lib/chunk-CSBS5U5I.mjs +0 -7
- package/lib/chunk-DB7RBE5D.mjs +0 -7
- package/lib/chunk-E5ZB3LU5.mjs +0 -7
- package/lib/chunk-EFR2Y7E4.mjs +0 -7
- package/lib/chunk-EHQ3FX6X.mjs +0 -7
- package/lib/chunk-EQNW3UC2.mjs +0 -7
- package/lib/chunk-F43REJDZ.mjs +0 -10
- package/lib/chunk-GSG7WZHM.mjs +0 -7
- package/lib/chunk-HOJYWTP7.mjs +0 -20
- package/lib/chunk-HS4YRX4J.mjs +0 -7
- package/lib/chunk-I7O6C2B5.mjs +0 -8
- package/lib/chunk-IFETCRWE.mjs +0 -10
- package/lib/chunk-IQXHJEYB.mjs +0 -7
- package/lib/chunk-JPUR2CFX.mjs +0 -10
- package/lib/chunk-K327QKMD.mjs +0 -7
- package/lib/chunk-KRCA6IPH.mjs +0 -8
- package/lib/chunk-LPBMBW3O.mjs +0 -13
- package/lib/chunk-LWW4U276.mjs +0 -7
- package/lib/chunk-MFG4MUIO.mjs +0 -9
- package/lib/chunk-MJU2PGZQ.mjs +0 -15
- package/lib/chunk-OAZRPP4I.mjs +0 -7
- package/lib/chunk-OO6CLPEH.mjs +0 -7
- package/lib/chunk-OPXCV2KL.mjs +0 -7
- package/lib/chunk-P33PSCXK.mjs +0 -7
- package/lib/chunk-Q3DM32KF.mjs +0 -11
- package/lib/chunk-QR3WELJQ.mjs +0 -7
- package/lib/chunk-QWT2C74M.mjs +0 -7
- package/lib/chunk-R3X3LV64.mjs +0 -14
- package/lib/chunk-RMBPOTD7.mjs +0 -7
- package/lib/chunk-SIHORWVK.mjs +0 -7
- package/lib/chunk-T62WNR54.mjs +0 -7
- package/lib/chunk-TTFDUKUS.mjs +0 -47
- package/lib/chunk-VE6XKGGD.mjs +0 -7
- package/lib/chunk-VGW4MXXZ.mjs +0 -7
- package/lib/chunk-VS7ZXUII.mjs +0 -824
- package/lib/chunk-VXQLDM4R.mjs +0 -7
- package/lib/chunk-VYXMVJL5.mjs +0 -7
- package/lib/chunk-W7U5E5ZL.mjs +0 -9
- package/lib/chunk-WXAQ7FK3.mjs +0 -115
- package/lib/chunk-YS4G22C2.mjs +0 -7
- package/lib/chunk-ZM6OJGIG.mjs +0 -7
- package/lib/chunk-ZUTYVST5.mjs +0 -7
|
@@ -0,0 +1,474 @@
|
|
|
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{b as ft}from"./chunk-HIHCYMSL.mjs";import{b as lt,n as ut}from"./chunk-JESRFE2Z.mjs";import{a as rt,b as K,c as dt,d as Y,f as ct,i as ht,k as me}from"./chunk-CBL42DUU.mjs";import{f as at}from"./chunk-MKTXJCXN.mjs";import{a as ue,b as F,c as et,f as tt}from"./chunk-AUS6NFLZ.mjs";import{a as wt,b as gt,c as we,d as kt,e as ge,g as bt,h as yt,i as vt,j as ke}from"./chunk-YH4DYI6D.mjs";import{q as pt}from"./chunk-HQQVANWQ.mjs";import{e as se}from"./chunk-5K2I2DMP.mjs";import{a as mt}from"./chunk-TW3N6W5Z.mjs";import{d as pe}from"./chunk-3HEMJTAP.mjs";import{a as ot,b as fe,c as it}from"./chunk-QROPNEGY.mjs";import{b as oe,e as qe}from"./chunk-BZ24IAP5.mjs";import{a as ne}from"./chunk-SCKUIE3R.mjs";import{c as V}from"./chunk-6FARZYMJ.mjs";import{hb as ze}from"./chunk-ISSP2FZ5.mjs";import{a as Ke,n as Ye,o as Xe}from"./chunk-VZT4E2OJ.mjs";import{C as Je}from"./chunk-7SDZR6SR.mjs";import{I as Ze,L as Qe,e as H,i as le}from"./chunk-J24TIGSI.mjs";import{d as Ve,j as ie}from"./chunk-HKUWHVI7.mjs";import{a as We}from"./chunk-LHU6CPGE.mjs";import{r as Ue}from"./chunk-PBE44M2Y.mjs";import{mc as nt}from"./chunk-JFNLKHY6.mjs";import{b as Me,f as B,h as st}from"./chunk-LCDPCUXS.mjs";import{k as Ge}from"./chunk-L4INJ5TZ.mjs";import{da as He}from"./chunk-KIMQQ6JQ.mjs";import{A as ce,Id as he,Ld as _e,Ra as Te,Tc as Fe,Va as Be}from"./chunk-ZQO5PDX5.mjs";import{mkdtempSync as pn,readFileSync as mn,rmSync as wn}from"node:fs";import{tmpdir as gn}from"node:os";import{join as Ot,resolve as be}from"node:path";var kn=`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
|
+
replay set a checkpoint's records up again in another org, with new Ids \u2014 the sandbox its
|
|
30
|
+
org became once refreshed, another sandbox, a scratch org \u2014, its own org never
|
|
31
|
+
reached: its dry run first, then a question; nothing the other org holds is changed
|
|
32
|
+
or deleted, and --remove takes it back
|
|
33
|
+
replays name the replays kept on this machine, and what each left in its org; no org is
|
|
34
|
+
contacted
|
|
35
|
+
|
|
36
|
+
Required:
|
|
37
|
+
--org <alias> sf CLI alias of the org (list: every org of the store without it;
|
|
38
|
+
replay names --target instead)
|
|
39
|
+
|
|
40
|
+
take:
|
|
41
|
+
--name <text> what it is called (default: the date and time)
|
|
42
|
+
--object <ApiName> an object to keep; repeat for more (default: every object people
|
|
43
|
+
work in, empty ones included, setup and log objects left out)
|
|
44
|
+
--exclude-object <ApiName> leave an object out; repeat for more
|
|
45
|
+
--custom-setting <ApiName|all> keep a custom setting, or all of them, which a checkpoint leaves
|
|
46
|
+
out unless named: a rewind sets their rows back, an integration's
|
|
47
|
+
endpoint or an admin's switch among them; repeat for more; needs
|
|
48
|
+
Customize Application
|
|
49
|
+
--ignore-field <Object.Field> do not compare a field, nor write it back (one your automation sets
|
|
50
|
+
on every save); repeat for more
|
|
51
|
+
--max-total <n> refuse, before reading, more than <n> records (default: ${ue},
|
|
52
|
+
${F} at most)
|
|
53
|
+
--keep-days <n> when it expires (default: ${H}; 0 keeps it until deleted)
|
|
54
|
+
--estimate say the records, API requests, time and disk it would take, then stop
|
|
55
|
+
preview, rewind, undo, delete, export:
|
|
56
|
+
--checkpoint <id|name|latest> which one (default: latest, for undo the one the last rewind went
|
|
57
|
+
back to; rewind and undo with --yes need it named, by id or name)
|
|
58
|
+
preview, rewind:
|
|
59
|
+
--object <ApiName> limit the rewind to an object of the checkpoint; repeat for more
|
|
60
|
+
(default: every object). It writes the others only to delete again
|
|
61
|
+
the records made since that come back with a record it brings
|
|
62
|
+
back, and never adds what the objects named depend on: what it
|
|
63
|
+
leaves of them for that is said, with the --object to add
|
|
64
|
+
preview:
|
|
65
|
+
--fail-on-change exit 3 when the org differs from the checkpoint
|
|
66
|
+
rewind:
|
|
67
|
+
--dry-run the preview, then stop
|
|
68
|
+
--accept-automation rewind even when the org runs flows, Apex triggers, processes or
|
|
69
|
+
workflow rules as records are updated, deleted or brought back;
|
|
70
|
+
without it such a rewind writes nothing, exit 1
|
|
71
|
+
--accept-emails rewind even when the org delivers every email its automation
|
|
72
|
+
sends (Setup > Deliverability: All email), or would not say
|
|
73
|
+
whether it does, and what still runs as it writes sends some:
|
|
74
|
+
they go to the addresses the records and the alerts name, and to
|
|
75
|
+
the records' owners. Without it such a rewind writes nothing,
|
|
76
|
+
exit 1. --accept-automation never stands for it. Read with one
|
|
77
|
+
line of anonymous Apex that sends nothing, only when something
|
|
78
|
+
that still runs sends an email; what Apex triggers send is not
|
|
79
|
+
read
|
|
80
|
+
--mute-automation mute the org's automation for the rewind through its own bypass:
|
|
81
|
+
assign the user it writes as, for the rewind alone, the permission
|
|
82
|
+
sets holding the custom permissions its flows, processes and
|
|
83
|
+
workflow rules test to stay quiet, and take them back as it ends;
|
|
84
|
+
what no bypass keeps quiet still runs, and still needs
|
|
85
|
+
--accept-automation. Refused on a production org and for a user
|
|
86
|
+
who cannot assign permission sets, exit 1; with --dry-run, says
|
|
87
|
+
what would be muted, or why it would be refused, and assigns
|
|
88
|
+
nothing
|
|
89
|
+
--accept-no-undo rewind even when undo could not bring back some records it deletes
|
|
90
|
+
(objects Salesforce undeletes only with their parent, such as
|
|
91
|
+
OpportunityLineItem); without it such a rewind writes nothing, exit 1
|
|
92
|
+
--accept-recreate make again, with new Ids, the records deleted since that the
|
|
93
|
+
recycle bin no longer gives back: what outside Salesforce names
|
|
94
|
+
their old Ids no longer finds them; without it a rewind that
|
|
95
|
+
counts such records writes nothing, exit 1, and one Salesforce
|
|
96
|
+
answers is no longer in the bin as it brings it back is left,
|
|
97
|
+
named
|
|
98
|
+
--accept-outside (a checkpoint of picked objects) also delete the records outside it
|
|
99
|
+
created under records it deletes, and the files it deletes that are
|
|
100
|
+
attached outside it too; without it those parents stay, and those
|
|
101
|
+
files are only removed from its records
|
|
102
|
+
--accept-unseen (a user without View All Data and Modify All Data) delete records
|
|
103
|
+
whose delete takes along records of objects the user is not
|
|
104
|
+
proven to see whole \u2014 tasks and events always: the preview names
|
|
105
|
+
those objects, and no count holds what goes with them; without it
|
|
106
|
+
such a rewind writes nothing, exit 1
|
|
107
|
+
--max-records <n> refuse, before it writes, a rewind that would delete, give back,
|
|
108
|
+
bring back and make again more than <n> records together, exit 1:
|
|
109
|
+
with --yes in a cron job or a CI step, what stands in for reading
|
|
110
|
+
the preview
|
|
111
|
+
--refuse-when-active refuse, before it writes, a rewind of an org where anyone but the
|
|
112
|
+
user it writes as and the org's Automated Process changed records
|
|
113
|
+
of the checkpoint's objects in the hour before it read the org,
|
|
114
|
+
whose work it would take back, exit 1; the refusal says how many
|
|
115
|
+
people. Where people sign in as the user SandForge connects as,
|
|
116
|
+
their changes are that user's, and are not told apart
|
|
117
|
+
--ignore-field <Object.Field> stop comparing a field from now on; kept in the checkpoint
|
|
118
|
+
--yes do not ask before writing; without it and with no terminal \u2014 a CI
|
|
119
|
+
step \u2014 it stops at its question, exit 2, having written nothing
|
|
120
|
+
undo:
|
|
121
|
+
--accept-automation as for rewind
|
|
122
|
+
--accept-emails as for rewind
|
|
123
|
+
--mute-automation as for rewind
|
|
124
|
+
--yes as for rewind
|
|
125
|
+
delete:
|
|
126
|
+
--all every checkpoint of the org
|
|
127
|
+
--yes do not ask
|
|
128
|
+
export:
|
|
129
|
+
--out <file> the file to write; refused when one is there already
|
|
130
|
+
--key-env <VAR> encrypt under the key this environment variable holds, one an
|
|
131
|
+
export showed (a CI step's secret); without it a new key is
|
|
132
|
+
drawn and shown once, on stderr
|
|
133
|
+
import:
|
|
134
|
+
--file <file> the .sfcheckpoint file
|
|
135
|
+
--key-env <VAR> read the key from this environment variable; without it the key
|
|
136
|
+
is asked on the terminal, not echoed, and with no terminal it
|
|
137
|
+
stops, exit 2, having imported nothing
|
|
138
|
+
--keep-days <n> when it expires on this machine (default: ${H}; 0 keeps it until
|
|
139
|
+
deleted)
|
|
140
|
+
replay:
|
|
141
|
+
--checkpoint <id|name|latest> which one: by its id, wherever it is kept (list names it); by its
|
|
142
|
+
name, or latest, with --from
|
|
143
|
+
--from <alias|username|00D\u2026> the org it was taken of, as list names it; refreshed or expired
|
|
144
|
+
since, it is not reached
|
|
145
|
+
--file <file> a .sfcheckpoint file a teammate sent, in place of --checkpoint:
|
|
146
|
+
replayed without its org, the key standing for the teammate's
|
|
147
|
+
consent; its checkpoint is kept on this machine apart from those
|
|
148
|
+
it rewinds. A file of a Partial Copy, a Full or a Staging sandbox
|
|
149
|
+
is refused unmasked before its key is read
|
|
150
|
+
--key-env <VAR> with --file: the environment variable that holds its key; without
|
|
151
|
+
it the key is asked on the terminal, not echoed, and with no
|
|
152
|
+
terminal it stops, exit 2
|
|
153
|
+
--keep-days <n> with --file: when its checkpoint expires here (default: ${H}; 0 keeps
|
|
154
|
+
it until deleted)
|
|
155
|
+
--target <alias> the org the records go into: a sandbox, a scratch org or a
|
|
156
|
+
Developer Edition org; never a production org, a sandbox marked
|
|
157
|
+
Staging, nor the checkpoint's own org, which rewind brings back
|
|
158
|
+
--dry-run say what it would create, link, leave and refuse, and write
|
|
159
|
+
nothing
|
|
160
|
+
--objects <A,B> replay these objects alone (default: every object it holds);
|
|
161
|
+
separate with commas, or repeat
|
|
162
|
+
--exclude-object <ApiName> leave an object out; repeat for more
|
|
163
|
+
--owners same|me same (default): a record keeps its owner where the other org has
|
|
164
|
+
that user active \u2014 by its Id, or by its username without a
|
|
165
|
+
sandbox's suffix \u2014, and goes to the user who replays otherwise;
|
|
166
|
+
me: every record to the user who replays
|
|
167
|
+
--owner-map <file.json> {"<user Id there>": "<user Id here>"}: who owns the records of
|
|
168
|
+
each user of the checkpoint's org, an active user of the other org
|
|
169
|
+
--link <Object=Field[,Field]> link to the records of an object the other org holds with the
|
|
170
|
+
same values of these fields, rather than create them; repeat
|
|
171
|
+
--custom-settings set up the custom settings the checkpoint holds too; a row the
|
|
172
|
+
other org has already is kept, never written over
|
|
173
|
+
--mask mask personal data, as Forge's anonymization does; required of a
|
|
174
|
+
checkpoint of a Partial Copy, a Full or a Staging sandbox, told by
|
|
175
|
+
its data storage and its mark; the free text it does not read is
|
|
176
|
+
named
|
|
177
|
+
--no-real-data declare that a sandbox's checkpoint taken before SandForge 1.81,
|
|
178
|
+
which does not say which sandbox, holds no real data: replayed
|
|
179
|
+
unmasked, the declaration kept in the audit trail
|
|
180
|
+
--keep-contact-points keep emails and phone numbers as they are (default: made
|
|
181
|
+
unreachable, addresses in .invalid and numbers that ring nobody)
|
|
182
|
+
--replay-config <file.json> the load's part of a Frozen project's configuration: required field
|
|
183
|
+
defaults, lookup placeholders, picklist rules, identity keys, \u2026
|
|
184
|
+
--again replay over what the replays before created there, which goes
|
|
185
|
+
first; what they linked stays
|
|
186
|
+
--max-records <n> the most records it may create (default: the count of the dry run
|
|
187
|
+
it reads first)
|
|
188
|
+
--mute-automation mute what the other org runs as the replay writes, or as --remove
|
|
189
|
+
deletes, through its own bypass, for that run alone, as a Frozen
|
|
190
|
+
load does; what no bypass keeps quiet still needs
|
|
191
|
+
--accept-automation
|
|
192
|
+
--accept-automation write, or delete, although the other org runs flows, Apex
|
|
193
|
+
triggers, processes or workflow rules as it does: named first,
|
|
194
|
+
and without it such a replay writes nothing, exit 1
|
|
195
|
+
--accept-emails write although the other org delivers the emails what still runs
|
|
196
|
+
sends, or would not say: without it such a replay writes nothing,
|
|
197
|
+
exit 1
|
|
198
|
+
--checkpoint-first take a checkpoint of what the replay writes in the other org
|
|
199
|
+
before its first write: a rewind to it takes the replay back, and
|
|
200
|
+
the work of anyone else on those objects since
|
|
201
|
+
--checkpoint-keep-days <n> the days that checkpoint is kept on this machine (default: 7)
|
|
202
|
+
--checkpoint-exclude-object <ApiName>
|
|
203
|
+
leave an object out of that checkpoint; repeat for more
|
|
204
|
+
--yes do not ask before it writes, nor before --remove deletes; without
|
|
205
|
+
it and with no terminal, it stops at its question, exit 2
|
|
206
|
+
--verify verify the last replay into the other org: what it created there,
|
|
207
|
+
counted against what it said it created
|
|
208
|
+
--remove delete from the other org what the replays created there, children
|
|
209
|
+
first, the checkpoint kept or not; --preview says what it would
|
|
210
|
+
delete; --sweep takes too what the other org's automation made for
|
|
211
|
+
them, and --sweep-list lists it and deletes nothing;
|
|
212
|
+
--include-changed takes too what was changed since
|
|
213
|
+
--sweep-late with --sweep: take too what it lists as made late; with
|
|
214
|
+
--sweep-list, say what it would take
|
|
215
|
+
--sweep-untied with --sweep: take too what it lists as tied to nothing of the
|
|
216
|
+
replay, refused when another run of this machine wrote to the
|
|
217
|
+
other org meanwhile; with --sweep-list, say what it would take
|
|
218
|
+
replays:
|
|
219
|
+
--target <alias|00D\u2026> the replays into this org alone
|
|
220
|
+
Options:
|
|
221
|
+
--store <dir> where checkpoints live (default: ~/.sandforge/checkpoints, or
|
|
222
|
+
checkpoints/ in the folder SANDFORGE_JOURNAL_DIR names); the
|
|
223
|
+
replays of its checkpoints are kept in it too, in .replays
|
|
224
|
+
--json the answer alone on stdout, every other line on stderr
|
|
225
|
+
--help this text
|
|
226
|
+
|
|
227
|
+
A production org is refused before anything is read or written, exit 1. No flag lifts it.
|
|
228
|
+
With View All Data and Modify All Data, the user the alias connects as sees every record and
|
|
229
|
+
rewinds whoever changed it; import needs both. Without them, take holds only the objects the
|
|
230
|
+
user has View All and Modify All on, or, for an object with no permissions of its own, on every
|
|
231
|
+
record it hangs from \u2014 never tasks and events, products and price books, files or custom
|
|
232
|
+
settings \u2014 and preview, rewind and undo read those permissions again: an object no longer held
|
|
233
|
+
is not read, and is left as it is; what another user deleted since stays in the recycle bin,
|
|
234
|
+
named; undo takes back the user's own rewind alone. A checkpoint that keeps custom settings
|
|
235
|
+
needs Customize Application too: View All Custom Settings reads them, never writes them.
|
|
236
|
+
A checkpoint holds the records' values as the org held them, personal data among them,
|
|
237
|
+
unencrypted, in files only you can read (on Windows: in your user profile). Expired checkpoints
|
|
238
|
+
are deleted as any command starts, each named.
|
|
239
|
+
list and delete read this machine alone and never contact the org. An org's checkpoints are the
|
|
240
|
+
ones taken under its alias or username, and the others kept of the same Organization Id.
|
|
241
|
+
export never writes a checkpoint unencrypted: AES-256-GCM, under a key of 52 letters and digits
|
|
242
|
+
shown once and kept nowhere. Anyone who has the file and its key reads every record it holds:
|
|
243
|
+
send the key another way than the file, and only to people who already see all data in the org.
|
|
244
|
+
The file does not expire: delete it once it has served. It carries neither the journals of
|
|
245
|
+
rewinds nor their undo, which stay on this machine.
|
|
246
|
+
import reads the file's header, then asks the org: another org, a production org, a user without
|
|
247
|
+
View All Data and Modify All Data, a file a newer SandForge made, are each refused before the key
|
|
248
|
+
is asked. A wrong key, or a file changed since it was exported, is refused before anything is
|
|
249
|
+
kept. A checkpoint kept already the same is left as it is, exit 0; another of its id is refused.
|
|
250
|
+
The lock against two rewinds at once is per machine: agree on who rewinds the org.
|
|
251
|
+
replay never reaches the checkpoint's own org. It reads the other org, then creates copies of
|
|
252
|
+
the checkpoint's records there, parents first, with new Ids, and changes or deletes nothing that
|
|
253
|
+
org holds. A checkpoint keeps no file's content: files, attachments and documents are never
|
|
254
|
+
replayed, each named. Owners, record types, currencies, person accounts and the standard price
|
|
255
|
+
book are read from the other org, and every record that does not go across as it was is said,
|
|
256
|
+
with why: a checkpoint taken before SandForge 1.81 keeps no record types, users or price book,
|
|
257
|
+
and its records get the other org's. Its created and modified dates and users are the replay's.
|
|
258
|
+
A replay runs its dry run first, asks, then creates no more than that dry run counted. What it
|
|
259
|
+
wrote is kept on this machine apart from the checkpoint (replays/ beside checkpoints/, or .replays
|
|
260
|
+
in the folder --store names), and --remove takes it back once the checkpoint is deleted. A
|
|
261
|
+
checkpoint of a Partial Copy, a Full or a Staging sandbox replays masked only, but into that
|
|
262
|
+
sandbox refreshed; delete names the replays a checkpoint leaves in place.
|
|
263
|
+
rewind shows its preview and asks you to type the org's alias exactly as --org gives it before it
|
|
264
|
+
writes, then rewinds from that preview as it read the org: a record someone changes after it read
|
|
265
|
+
is left as they made it, and said. undo says what it takes back and asks the same before it
|
|
266
|
+
writes. A take, a rewind or an undo of the org under way on this machine, in the editor or in
|
|
267
|
+
another command line, refuses a rewind and an undo; other runs writing to the org are not seen
|
|
268
|
+
here, and what one of them changes after the preview read the org is left and said the same way.
|
|
269
|
+
Ctrl-C stops a take between two reads, and nothing of it is kept; a second Ctrl-C ends it at once,
|
|
270
|
+
and leaves a checkpoint listed as never taken, which delete removes. Ctrl-C stops a rewind or an
|
|
271
|
+
undo before its next call to the org, and leaves its journal: rewind again takes up from what still
|
|
272
|
+
differs, and undo still returns the org to how it was before the rewind. A rewind stopped before
|
|
273
|
+
it sent anything leaves none, and the undo of the rewind before it stays offered.
|
|
274
|
+
|
|
275
|
+
A record deleted since that the recycle bin no longer gives back is made again from the
|
|
276
|
+
checkpoint, with a new Id, once --accept-recreate says so: the lookups the checkpoint holds that
|
|
277
|
+
named it name the new Id, and undo deletes it again. Salesforce still lists a record emptied from
|
|
278
|
+
the bin as deleted, for minutes to hours, and says the bin no longer holds it only as the rewind
|
|
279
|
+
asks it back: such a record, with what was to come back with it, is made again then, or left
|
|
280
|
+
and named without --accept-recreate.
|
|
281
|
+
A record the checkpoint does not hold that took records of it along when it was deleted since is
|
|
282
|
+
brought back for a moment with them, then deleted again with what came back with it.
|
|
283
|
+
A custom setting is kept only when --custom-setting names it. A rewind brings a row of one back
|
|
284
|
+
only once no other row holds its owner (a hierarchy: the org's default, a profile, a user) or
|
|
285
|
+
its name (a list): it deletes the row made since first, then brings the row back with its Id.
|
|
286
|
+
A checkpoint holds the files attached to its records, Salesforce Files and classic attachments:
|
|
287
|
+
which records each is attached to, its latest version and its size, never its content. A rewind
|
|
288
|
+
deletes the files attached to them since, brings back those deleted since with their links,
|
|
289
|
+
removes the links added since and puts back those removed since, under new Ids; a file
|
|
290
|
+
attached to no record of the checkpoint, a user's own or a library's, is left and counted.
|
|
291
|
+
Bringing files back from the recycle bin takes file storage again: a rewind or an undo that would
|
|
292
|
+
take more than the org has left is refused before it writes. Without Query All Files, other
|
|
293
|
+
users' files that no record of the checkpoint is attached to are not seen.
|
|
294
|
+
What a rewind cannot undo: a file deleted since and no longer in the recycle bin, whose body the
|
|
295
|
+
checkpoint does not hold, a file given a new version since, which keeps it, a lead converted
|
|
296
|
+
since, a contract activated since, a record deleted with a parent created since that Salesforce
|
|
297
|
+
does not undelete on its own, or with its parent of an object the checkpoint does not hold
|
|
298
|
+
(preview counts them); without View All Data and Modify All Data, a record another user deleted
|
|
299
|
+
since, and a record of an object held through what it hangs from that the recycle bin does not
|
|
300
|
+
show the user (preview counts them too); a field added since, deleted since, or hidden since from
|
|
301
|
+
the user by field-level security, which the preview tells apart and names in an object something
|
|
302
|
+
changed in since \u2014 in an object nothing changed in, which a rewind writes nothing to, the fields
|
|
303
|
+
are not checked, and the preview counts those objects; the values the org computes or keeps
|
|
304
|
+
itself (formulas, roll-ups, auto-numbers, created and modified dates); what left the org
|
|
305
|
+
(emails, callouts, outbound messages, platform events); metadata; the files of a checkpoint taken
|
|
306
|
+
before SandForge 1.70, which holds none. A record the org refuses to put back, or to make again,
|
|
307
|
+
is named by rewind, with its words.
|
|
308
|
+
|
|
309
|
+
JSON (--json), one value on stdout:
|
|
310
|
+
list [{id, name, org, organizationId, takenAt, records, bytes, expiresAt,
|
|
311
|
+
expiresSoon, binReachSince, lastRewind?, valid, why?, refreshedAt?,
|
|
312
|
+
replayWith?}]
|
|
313
|
+
(name, org, takenAt, records and bytes are null for a damaged checkpoint;
|
|
314
|
+
expiresAt is null for one kept until deleted; replayWith, of one that no
|
|
315
|
+
longer rewinds its org, the dry run of its replay)
|
|
316
|
+
take {checkpoint, requests?, estimate}: the checkpoint as kept (its
|
|
317
|
+
checkpoint.json; files?, {documents, links, anchored, readByIds?}, for one
|
|
318
|
+
that holds files); requests, {total, byPhase}, the API requests the take sent
|
|
319
|
+
the org, SOAP calls among them; estimate, what it said before reading a record
|
|
320
|
+
take --estimate {mode, objects, leftOut, estimate, refusal?, files?, customSettings?}:
|
|
321
|
+
estimate.requestsByPhase splits the requests over a take's phases as
|
|
322
|
+
requests.byPhase does: guard, scope, start, counts, bin, snapshot, stability;
|
|
323
|
+
files, {held, queryAllFiles, addedToPicked}; customSettings, every custom
|
|
324
|
+
setting of the org, kept or not, [{objectApiName, label, kind?, records?}],
|
|
325
|
+
kind hierarchy or list, and objects[].customSetting for one kept; {mode,
|
|
326
|
+
refusal} for a take refused before its scope is read (a production org, a
|
|
327
|
+
user without the permissions)
|
|
328
|
+
preview {checkpoint: {id, name, takenAt, org}, toDelete, toGiveBack, toBringBack,
|
|
329
|
+
toRecreate, carriers, differs, diff, estimate, automation?, emails?,
|
|
330
|
+
emailsUncounted?, deliverability?, refusal?}: carriers, the records
|
|
331
|
+
brought back for a moment and deleted again, in none of the other numbers;
|
|
332
|
+
diff, estimate
|
|
333
|
+
and automation as the extension answers them; refusal, the first a rewind
|
|
334
|
+
given no flag would meet now, of those its lines name with what lifts
|
|
335
|
+
each, as rewind --dry-run lists them: the extension's own (the org's lock,
|
|
336
|
+
a run writing, the day's API requests or emails, file storage), then an
|
|
337
|
+
acceptance it needs (NO_UNDO, RECREATE, UNSEEN, AUTOMATION,
|
|
338
|
+
EMAILS_DELIVERED, in that order); emails, one per daily limit its writes send
|
|
339
|
+
against: {limit, emails, verdict, remaining?, max?, alertsCounted?,
|
|
340
|
+
objects: [{objectApiName, write, records, perRecord, sentBy}]};
|
|
341
|
+
emailsUncounted, what sends emails as it writes that could not be read \u2014 a
|
|
342
|
+
flow whose definition was refused, a package's, which no user reads \u2014 its
|
|
343
|
+
emails not counted, which --accept-automation covers; deliverability,
|
|
344
|
+
when something that still runs may send an email: {reading: {level: all
|
|
345
|
+
or withheld} or {unread}, senders: [{objectApiName, kind, name, why}]},
|
|
346
|
+
which --accept-emails answers for all and unread;
|
|
347
|
+
diff.objects[].schemaDrift, of an object whose fields changed since:
|
|
348
|
+
{removed, added, changed, hidden?, uncertain?: {fields, reason?}}, removed
|
|
349
|
+
the custom fields deleted since, hidden those field-level security hides
|
|
350
|
+
from the user, uncertain those the org would not say which of;
|
|
351
|
+
diff.described, {first, later}, the objects it described again, asked
|
|
352
|
+
whether their fields changed since the take: first those something moved
|
|
353
|
+
in, later those nothing moved in that hold fewer records than the
|
|
354
|
+
checkpoint; diff.fieldsNotChecked, the objects nothing changed in whose
|
|
355
|
+
fields it did not describe: a rewind writes nothing there, and a field
|
|
356
|
+
deleted or hidden since in one of them is not known; diff.files,
|
|
357
|
+
for a checkpoint that holds files: {unlink, relink, updateLinks,
|
|
358
|
+
outsideAdded, outsideDeleted, storage: {bringBack, remaining?, undo},
|
|
359
|
+
blindSpot?}, the links to remove, put back and give their sharing back, the
|
|
360
|
+
files left, and file storage in bytes; diff.access, {kind, requests?}, org
|
|
361
|
+
for a user with View All Data and Modify All Data, perObject for one read
|
|
362
|
+
object by object, with the API requests that read; diff.unseen, read
|
|
363
|
+
object by object: [{objectApiName, children, records}], of the records to
|
|
364
|
+
delete of an object, the objects whose records their delete takes along
|
|
365
|
+
out of the user's sight; with --object, objects, the objects named, and
|
|
366
|
+
selection, {objects, acts: [{objectApiName, picked, toDelete, toGiveBack,
|
|
367
|
+
toBringBack, toRecreate}], left: [{objectApiName, reason, count}], needs:
|
|
368
|
+
[{objectApiName, records}], undoCannot}, what a rewind of them alone would
|
|
369
|
+
do and leave \u2014 reason needsUnpickedParent, heldByUnpicked,
|
|
370
|
+
outsideNotAccepted, holdsLeft or keyTaken \u2014 and the objects to add; the
|
|
371
|
+
numbers, differs and estimate are then the rewind's of those objects,
|
|
372
|
+
diff the whole diff; of a checkpoint of picked objects whose records
|
|
373
|
+
outside it were made since under records a rewind would delete, kept:
|
|
374
|
+
[{objectApiName, reason, count}], what a rewind without --accept-outside
|
|
375
|
+
keeps for them \u2014 reason outsideNotAccepted or holdsLeft \u2014, the numbers
|
|
376
|
+
then those of what it writes, differs the whole diff's (preview previews
|
|
377
|
+
that rewind)
|
|
378
|
+
rewind --dry-run as preview, with wouldBeRefused: ["refused (CODE): message"] and
|
|
379
|
+
wouldBeRefusedCodes: ["CODE"], one for each refusal a rewind with these
|
|
380
|
+
flags would meet, in order; asked to mute, emails and deliverability are
|
|
381
|
+
of what still runs, with mutedAutomation and mutePlan
|
|
382
|
+
rewind {checkpoint: {id, name, takenAt, org}, rewindId, status, deleted, givenBack,
|
|
383
|
+
broughtBack, recreated (each {planned, done, left}), cannotUndo: [{object,
|
|
384
|
+
reason, count}], carriers?: [{object, count}], draftsLeft?: [{object,
|
|
385
|
+
count, ids}], undo?: {until, cannot: [{object, count, reason?}]}, verify:
|
|
386
|
+
{differences, stable, passes, notCompared}, residual: [{object, reason,
|
|
387
|
+
by?, count, message?}], unread: [{object, reason}], objects: [{object,
|
|
388
|
+
deleted, givenBack, broughtBack, refused}], apiRequests: {used,
|
|
389
|
+
leftToday}, result}:
|
|
390
|
+
status success, partial, unstable, failure or cancelled; result as the
|
|
391
|
+
extension answers it; undo.cannot's reason deletedBeforeParent: deleted
|
|
392
|
+
before a record they point at, which the rewind deleted next; carriers, of
|
|
393
|
+
what it brought back and deleted, the records brought back for a moment;
|
|
394
|
+
draftsLeft, of a rewind stopped part way, the orders and contracts it made
|
|
395
|
+
again as drafts and had not given their status back yet, by their new Ids;
|
|
396
|
+
files?: {unlinked, relinked, linksUpdated, linksRefused}, the links between
|
|
397
|
+
files and records it wrote, when it wrote one; with --object, limitedTo,
|
|
398
|
+
the objects named, and notRewound, {objects, records}, the objects not
|
|
399
|
+
named that still differ and their records that do, which the status
|
|
400
|
+
does not count
|
|
401
|
+
undo as rewind, without recreated, cannotUndo, carriers, draftsLeft and undo,
|
|
402
|
+
with carriedAlone?: [{object, count}], the records sent back to the
|
|
403
|
+
recycle bin on their own that had gone there with a record the rewind
|
|
404
|
+
brought back for a moment
|
|
405
|
+
delete {deleted: [id], kept: [id], replaysInPlace?}: replaysInPlace, as replays
|
|
406
|
+
lists them, those of the checkpoints deleted that left records in their org
|
|
407
|
+
replay {command, action, dryRun, checkpoint: {id, name, organizationId, takenAt,
|
|
408
|
+
tier, annex}, target: {alias, organizationId}, choices?, file?, plan?,
|
|
409
|
+
replay?: {records, owners, recordTypes, notReplayed, filesLeft,
|
|
410
|
+
lookupsEmptied, refused, fieldsNotInTarget, customSettings?, currencies,
|
|
411
|
+
standardPricebook?, masked, contactPoints, archivedActivities?,
|
|
412
|
+
degraded, auditDates, storage?, requests}, result?, removal?, objects?,
|
|
413
|
+
status?, verdict?, mapping?, refusals?, refusalCodes?, refused?,
|
|
414
|
+
mutedAutomation?, mutePlan?, checkpointFirst?, removeWith, ended?, exit}:
|
|
415
|
+
plan, result and removal as a Frozen load and its removal answer them;
|
|
416
|
+
objects, status, verdict and refusals as a Frozen step gives them
|
|
417
|
+
replays [{checkpointId, checkpointName?, sourceOrganizationId, takenAt?, target:
|
|
418
|
+
{organizationId, name?}, choices?, replayedAt?, inPlace, inPlaceByObject,
|
|
419
|
+
removed?, removeWith}]
|
|
420
|
+
export {checkpoint: {id, name, takenAt, org}, file, bytes, sha256, records, objects,
|
|
421
|
+
keyShown}: keyShown, whether a new key was drawn and shown on stderr; never
|
|
422
|
+
the key itself
|
|
423
|
+
import {outcome, checkpoint: {id, name, takenAt, org}, records, objects, expiresAt,
|
|
424
|
+
warnings}: outcome imported, or alreadyKept for the same checkpoint kept here
|
|
425
|
+
already
|
|
426
|
+
refused or failed {refusal: {code, message}}; a rewind or an undo refused before it wrote
|
|
427
|
+
for more than one reason adds wouldBeRefused and wouldBeRefusedCodes, as
|
|
428
|
+
rewind --dry-run gives them: every refusal, the first among them, each other
|
|
429
|
+
also on a line of its own, refused (CODE): message
|
|
430
|
+
A bad command line (exit 2) prints nothing on stdout.
|
|
431
|
+
|
|
432
|
+
replay ends as a Frozen load ends: 0 its dry run said, or the replay done and verified; 1 refused
|
|
433
|
+
before it wrote (REPLAY_SAME_ORG, REPLAY_REAL_DATA, REPLAY_COPY_UNKNOWN, REPLAY_TOO_MANY,
|
|
434
|
+
REPLAY_NOTHING, a target refused, what it runs or sends unanswered) or failed; 2 a bad line or a
|
|
435
|
+
question with no terminal; 3 done with records refused or left, or its verification PARTIAL.
|
|
436
|
+
Exit codes: 0 done (take: every record of its objects is kept; rewind and undo: read again, the
|
|
437
|
+
org matches among the objects and fields compared \u2014 with --object, among the objects named,
|
|
438
|
+
whatever still differs in the others; preview, rewind --dry-run and list answered;
|
|
439
|
+
delete: every checkpoint named is deleted; export: the file is written; import: the checkpoint is
|
|
440
|
+
kept, or was already); 1 refused before it read or wrote (a production org,
|
|
441
|
+
missing permissions, automation without --accept-automation, emails the org delivers or would not
|
|
442
|
+
say it withholds without --accept-emails (refusal code EMAILS_DELIVERED), deletions undo could not
|
|
443
|
+
bring back without --accept-no-undo, records to make again with new Ids without --accept-recreate,
|
|
444
|
+
deletions taking along records the user is not proven to see without --accept-unseen, more than
|
|
445
|
+
--max-total records, more records to rewind than --max-records, people working in the org in the
|
|
446
|
+
hour before with --refuse-when-active, more API requests or emails than the org
|
|
447
|
+
has left today, files to bring back taking more file storage than it has left, a checkpoint of
|
|
448
|
+
the org before a refresh or of an expired scratch org, a SandForge run writing to it; an import
|
|
449
|
+
of another org's file, with the wrong key, of a file changed since its export), or nothing
|
|
450
|
+
done; 2 a bad command line, a --checkpoint name several checkpoints
|
|
451
|
+
have, an --object the checkpoint does not hold,
|
|
452
|
+
rewind or undo with --yes and no checkpoint named, or a question with no terminal (give
|
|
453
|
+
--yes; import's key: --key-env); 3 partial (rewind and undo: records still differ, each said
|
|
454
|
+
with why; with
|
|
455
|
+
--fail-on-change, the org differs: records to delete, give back, bring back or make again,
|
|
456
|
+
links between files and records to remove, put back or give their sharing back, records the
|
|
457
|
+
rewind cannot take back or the checkpoint does not hold although they are dated before it, files
|
|
458
|
+
added or deleted since that no record of it is attached to, a field it compares deleted or
|
|
459
|
+
hidden since in an object something moved in, an object that could not be read; delete: some
|
|
460
|
+
were kept, each said with why); 4 unstable (someone else changed
|
|
461
|
+
records during the rewind or the undo: left as they made them); 130, 143, 129 Ctrl-C, SIGTERM or
|
|
462
|
+
SIGHUP stopped it \u2014 run rewind again: it takes up from what still differs, and undo still reaches
|
|
463
|
+
the state before it.
|
|
464
|
+
`,bn=["take","list","preview","rewind","undo","delete","export","import","replay","replays"],yn=e=>bn.includes(e),x={switches:["--json"],values:["--org","--store"]},vn={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"]},replay:{words:1,switches:["--json","--dry-run","--verify","--remove","--preview","--sweep","--sweep-list","--sweep-late","--sweep-untied","--include-changed","--custom-settings","--mask","--keep-contact-points","--no-real-data","--again","--mute-automation","--accept-automation","--accept-emails","--yes",...pe.switches],values:["--store","--checkpoint","--from","--file","--key-env","--keep-days","--target","--objects","--exclude-object","--owners","--owner-map","--link","--replay-config","--max-records",...pe.values]},replays:{words:1,switches:["--json"],values:["--store","--target"]}},$n={name:"--name",objects:"--object",excluded:"--exclude-object",customSettings:"--custom-setting",ignoredFields:"--ignore-field",maxTotal:"--max-total",keepDays:"--keep-days"},An=/^[A-Za-z][A-Za-z0-9_]{0,79}$/;function S(e){process.stderr.write(`${e}
|
|
465
|
+
`),process.exit(2)}function jn(e){let n=e.toISOString();return`${n.slice(0,10)} ${n.slice(11,16)} UTC`}function Rn(e,n=new Date){let t=e.slice(2);(t.includes("--help")||t.includes("-h"))&&(process.stdout.write(kn),process.exit(0));let o=t[0];if(o===void 0||o.startsWith("-"))return S("Name the command first: take, list, preview, rewind, undo, delete, export, import, replay or replays. Run with --help.");if(!yn(o))return S(`"${o}" is not a command of sandforge checkpoint: take, list, preview, rewind, undo, delete, export, import, replay or replays. Nothing was run. Run with --help.`);Me(t,vn[o]);let i=w=>{let h=[];for(let l=1;l<t.length;l++){if(t[l]!==w)continue;let k=t[l+1];if(k===void 0||k.startsWith("--"))return S(`${w} wants a value.`);h.push(k),l++}return h},s=w=>{let h=i(w);return h.length>1&&S(`${w} is given ${h.length} times: give it once.`),h[0]},d=w=>{let h=s(w);if(h!==void 0)return/^\d{1,15}$/.test(h)||S(`${w} takes a whole number, not "${h}".`),Number(h)},a=s("--store"),r={storeRoot:a!==void 0?be(a):le(),...a!==void 0?{storeNamed:!0}:{},json:t.includes("--json")},p=s("--org"),m=()=>p??S(`${o} needs --org. Run with --help.`),g=w=>{t.includes("--yes")&&(w===void 0&&S(`${o} --yes needs --checkpoint <id|name>: one that does not ask is told which checkpoint it acts on. Nothing was run.`),w==="latest"&&S(`${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 w=i("--object"),h=w.find(l=>!An.test(l));return h!==void 0&&S(`--object takes an object's API name, not "${h}".`),w.filter((l,k)=>w.findIndex(y=>y.toLowerCase()===l.toLowerCase())===k)};switch(o){case"list":return{...r,command:o,...p!==void 0?{org:p}:{}};case"replay":return{...r,command:o,replay:wt(t,S)};case"replays":return{...r,command:o,...gt(t,S)};case"take":{let w=m(),h=i("--object"),l=i("--exclude-object"),k=i("--custom-setting"),y=k.includes("all")?"all":k,c=i("--ignore-field"),u=d("--max-total"),j={name:s("--name")??jn(n),mode:h.length>0?"picked":"everything",...h.length>0?{objects:h}:{},...l.length>0?{excluded:l}:{},...y.length>0?{customSettings:y}:{},...c.length>0?{ignoredFields:c}:{},...u!==void 0?{maxTotal:u}:{},keepDays:d("--keep-days")??H},C=ze.safeParse({...j,orgId:"command-line"});if(!C.success){let O=C.error.issues[0],W=String(O?.path[0]??"");return S(`${$n[W]??W}: ${O?.message??"not read"}. Nothing was run.`)}return{...r,command:o,org:w,take:{...j,name:C.data.name},estimate:t.includes("--estimate")}}case"preview":return{...r,command:o,org:m(),checkpoint:s("--checkpoint")??"latest",failOnChange:t.includes("--fail-on-change"),objects:$()};case"rewind":{let w=m(),h=s("--checkpoint");g(h);let l=i("--ignore-field"),k=Be.safeParse(l);if(!k.success)return S(`--ignore-field: ${k.error.issues[0]?.message??"not read"}. Nothing was run.`);let y=d("--max-records");return y===0&&S('--max-records takes a whole number of 1 or more, not "0". Nothing was run.'),{...r,command:o,org:w,checkpoint:h??"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"),...y!==void 0?{maxRecords:y}:{},refuseWhenActive:t.includes("--refuse-when-active"),ignoreFields:l,yes:t.includes("--yes")}}case"undo":{let w=m(),h=s("--checkpoint");return g(h),{...r,command:o,org:w,...h!==void 0?{checkpoint:h}:{},acceptAutomation:t.includes("--accept-automation"),acceptEmails:t.includes("--accept-emails"),muteAutomation:t.includes("--mute-automation"),yes:t.includes("--yes")}}case"delete":{let w=m(),h=s("--checkpoint"),l=t.includes("--all");return l&&h!==void 0&&S("Give --checkpoint or --all, not both."),{...r,command:o,org:w,...l?{}:{checkpoint:h??"latest"},all:l,yes:t.includes("--yes")}}case"export":{let w=m(),h=s("--out")??S("export needs --out <file>. Run with --help."),l=$t(s("--key-env"));return{...r,command:o,org:w,checkpoint:s("--checkpoint")??"latest",out:be(h),...l!==void 0?{keyEnv:l}:{}}}case"import":{let w=m(),h=s("--file")??S("import needs --file <file>. Run with --help."),l=$t(s("--key-env"));return{...r,command:o,org:w,file:be(h),...l!==void 0?{keyEnv:l}:{},keepDays:d("--keep-days")??H}}}}function $t(e){if(e!==void 0)return!/^[A-Za-z_][A-Za-z0-9_]{0,127}$/.test(e)||se(e)!==void 0?S("--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 xt(e,n){return e!==void 0&&n!==void 0&&e.length>=15&&e.slice(0,15)===n.slice(0,15)}function _(e,n,t){let o=t!==void 0?[t]:[];for(let i of e){let s=i.checkpoint?.org;s!==void 0&&(s.alias===n||s.username.toLowerCase()===n.toLowerCase())&&o.push(i.organizationId)}return e.filter(i=>o.some(s=>xt(s,i.organizationId)))}var Et="One kept in another folder is read with --store <folder>, or with SANDFORGE_JOURNAL_DIR set as when it was taken \u2014 in a CI job, a folder its cache restores; one taken on another machine comes here by export there, then import here.";function ae(e){return`"${ne("checkpoint")} list --org ${e}" names those it holds. ${Et}`}function G(e,n,t,o){if(Te.safeParse(t).success){let s=e.find(d=>d.checkpointId===t);return s?{entry:s}:{none:`No checkpoint ${t} is kept in the folder read. ${ae(o)}`}}if(t==="latest"){let s=n[0];return s?{entry:s}:{none:`No checkpoint of ${o} is kept in the folder read. ${ae(o)}`}}let i=n.filter(s=>s.checkpoint?.name===t);return i.length===1?{entry:i[0]}:i.length===0?{none:`No checkpoint of ${o} named '${t}' is kept in the folder read. `+ae(o)}:{ambiguous:`${i.length} checkpoints of ${o} are named '${t}': give the id of the one you mean with --checkpoint (${i.map(s=>s.checkpointId).join(", ")}).`}}function Re(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 no longer rewinds. ${At(e)}`};case"scratchExpired":return{code:"SCRATCH_EXPIRED",message:`The scratch org of checkpoint ${n} has expired: its checkpoints no longer rewind it. ${At(e)}`};default:return{code:"INVALID",message:`The checkpoint ${n} cannot be previewed.`}}}function Ce(e){let n=e.checkpoint?.org,t=e.why==="refreshed"&&n!==void 0?n.alias??n.username:"<alias>";return`${ge(e.checkpointId,t)} --dry-run`}function At(e){return`${ce.replace(/\.$/,"")}: ${Ce(e)}`}function It(e){return!e.valid&&(e.why==="refreshed"||e.why==="scratchExpired")}var f=e=>e.toLocaleString("en-US");function E(e){let n=new Date(Date.parse(e)).toISOString();return`${n.slice(0,10)} ${n.slice(11,16)} UTC`}function ye(e){let n=new Date(Date.parse(e)).toISOString();return`${n.slice(0,10)} ${n.slice(11,19)} UTC`}var U=e=>`${nt(e/(1024*1024))} MB`;function v(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 Z(e){return e.objects.reduce((n,t)=>n+t.records,0)}function Se(e){return e===null?"kept until you delete it":`kept until ${E(e)}`}function z(e){return e.org.alias??e.org.username}var Cn=/^Left out(?::\s*|\s+(?=as asked\b))/;function Nt(e,n){let t=[...n,...e.flatMap(({code:s,records:d})=>s==="pastTheLimit"&&d!==void 0?[d]:[])],o=t.filter(s=>s<=F).reduce((s,d)=>s+d,0),i=new Map;for(let{objectApiName:s,reason:d,code:a,records:r}of e){let p=d;if(a==="pastTheLimit"&&r!==void 0&&r<=F){let m=tt(t,r);p=m>F?`${d} With it, every object no larger is kept, more than ${F} records in all, past any --max-total: --exclude-object <ApiName> leaves some out.`:`${d} --max-total ${m}${m===o?" or more":""} holds it.`}i.set(p,[...i.get(p)??[],s])}return[...i].map(([s,d])=>` left out: ${v(d)} \u2014 ${s.replace(Cn,"")}`)}var Sn={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 Dt(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}): ${v(o)} \u2014 ${Sn[t]??t}`)}function Pt(e){let n=e.filter(t=>!t.undeletable).map(t=>t.objectApiName);return n.length===0?[]:[` deleted ${v(n)} records come back from the recycle bin only with their parent`]}function Lt(e){return` about ${f(e.seconds)} s \xB7 about ${f(e.apiRequests)} API requests of the ${f(e.apiRequestsLeft)} left today`+(e.bytes>0?` \xB7 about ${U(e.bytes)} on this machine`:"")}var jt={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 no longer rewinds, and replays into another org",scratchExpired:"its scratch org has expired: it no longer rewinds, and replays into another org"};function On(e,n,t){if(e.length===0&&t!==void 0){let i=t.kept===0?"":`, which keeps ${t.kept===1?"1 of another org":`${t.kept} of other orgs`}: "${ne("checkpoint")} list" names ${t.kept===1?"it":"them"}`;return[`No checkpoint of ${t.org} is kept in ${n}${i}. ${Et}`]}if(e.length===0)return[`No checkpoint is kept in ${n}.`];let o=[];for(let i of e){let s=i.checkpoint;if(!s){o.push(`${i.checkpointId} ${jt.damaged}`);continue}if(o.push(`${i.checkpointId} '${s.name}' ${z(s)} taken ${E(s.takenAt)} ${f(Z(s))} records in ${s.objects.length} objects ${U(s.bytes)} `+Se(s.expiresAt)),!i.valid){let d=i.why==="refreshed"&&i.refreshedAt?`refreshed on ${i.refreshedAt.slice(0,10)}: `:"";o.push(` ${d}${jt[i.why??""]??"it cannot be previewed"}`),It(i)&&(o.push(` replay it: ${Ce(i)}`),s.expiresAt!==null&&o.push(` deleted from this machine on ${E(s.expiresAt)}: to replay it after, Keep it in the editor, or export it and replay the file`))}i.scratchExpiresSoon&&s.org.scratchExpiresAt!==void 0&&o.push(` its scratch org expires on ${s.org.scratchExpiresAt.slice(0,10)}: its checkpoints then no longer rewind it, whatever --keep-days said, and still replay into another org`),i.expiresSoon&&s.expiresAt!==null&&o.push(` expires on ${E(s.expiresAt)}: take a new one, or keep this one in the editor`),i.binReachSince&&o.push(` records deleted before ${i.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`),i.undo&&o.push(` rewound: the rewind can be undone until ${E(i.undo.until)}`)}return o}function xn(e){let n=e.checkpoint;return{id:e.checkpointId,name:n?.name??null,org:n?z(n):null,organizationId:e.organizationId,takenAt:n?.takenAt??null,records:n?Z(n):null,bytes:n?.bytes??null,expiresAt:n?n.expiresAt:null,expiresSoon:e.expiresSoon===!0,scratchExpiresSoon:e.scratchExpiresSoon===!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}:{},...It(e)?{replayWith:Ce(e)}:{}}}function Tt(e){return e.refusal!==void 0&&e.objects.length===0&&e.leftOut.length===0}function En(e){return Tt(e)?{mode:e.mode,refusal:e.refusal}:{...e}}function ve(e){if(e.code!=="TOO_MANY_RECORDS")return e;let n="pick fewer objects (--exclude-object <ApiName> leaves one out)",t=`(${f(ue)} unless given)`,o=e.holdingLimit,i=o===void 0?`${n}, or raise the limit with --max-total <n> ${t}`:o>F?`${n}: no --max-total holds them all, ${f(F)} at most`:`${n}, or raise the limit with --max-total ${o} ${t}`;return{...e,message:e.message.replace(/: pick fewer objects\./,`: ${i}.`)}}function In(e,n){if(Tt(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 ${f(n.estimate.records)} records`,...[...o].map(([i,s])=>` includes ${s} objects of the ${i} package`),Lt(n.estimate),...Nt(n.leftOut,n.objects.map(i=>i.records)),...Dt(n.objects),...Pt(n.objects),...n.files?Dn(n.files):[],...Nn(n),...n.refusal?[`refused: ${ve(n.refusal).message}`]:[]]}function Bt(e){let n=e.records===void 0?void 0:`${f(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 Ft(e){return Bt({objectApiName:e.objectApiName,...e.customSetting!==void 0?{kind:e.customSetting}:{},records:e.records})}function Nn(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: ${v(n.map(Ft))} \u2014 a rewind sets their rows back as the checkpoint holds them, whoever changed them since`]:[],...o.length>0?[` custom settings not kept: ${v(o.map(Bt))} \u2014 --custom-setting <ApiName|all> keeps them`]:[]]}function Dn(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",..._t(e.addedToPicked),...e.queryAllFiles?[]:[Oe]]:[" files: not kept \u2014 a rewind leaves the files attached since as they are"]}function _t(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 Oe=" 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 Pn(e,n,t=[]){let o=e.movedWhileTaken,i=o.changed+o.deleted+o.created;return[`taken '${e.name}' (${e.checkpointId}) of ${z(e)}: ${f(Z(e))} records in ${e.objects.length} objects, ${U(e.bytes)} on this machine, ${Se(e.expiresAt)}`,` of ${ye(e.readFrom)}, read until ${ye(e.takenAt)} on the org's clock`,...i>0?[` ${f(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.`]:[],...Nt(e.scope.leftOut,e.objects.map(s=>s.records)),...Dt(e.objects),...e.ignoredFields.length>0?[` not compared, nor written back (you chose): ${e.ignoredFields.join(", ")}`]:[],...Pt(e.objects),...Ln(e.objects),...e.files?Tn(e,e.files,t):[],` it holds the records' values unencrypted, in files only you can read: ${n}`]}function Ln(e){let n=e.filter(t=>t.customSetting!==void 0);return n.length===0?[]:[` custom settings kept: ${v(n.map(Ft))} \u2014 a rewind sets their rows back as the checkpoint holds them`]}function Tn(e,n,t){let o=n.readByIds??[],i=new Set(t.map(a=>a.toLowerCase())),s=new Set(e.objects.map(({objectApiName:a})=>a.toLowerCase())),d=e.scope.mode==="picked"?Ge.filter(a=>s.has(a.toLowerCase())&&!i.has(a.toLowerCase())):[];return[` files: ${f(n.anchored)} attached to its records by ${f(n.links)} link(s): a rewind takes back what is attached to them since`,..._t(d),...o.length>0?[` the links of ${v(o)} were read by lists of record Ids: ${z(e)} refused one query, or answered too late`]:[],...e.takenBy.queryAllFiles===!1?[Oe]:[]]}function Bn(e,n){let t=Object.entries(e.byPhase).map(([i,s])=>{let d=n?.requestsByPhase?.[i];return d===void 0||d===s?`${i} ${s}`:`${i} ${s} (${d})`}),o=n?`, about ${f(n.apiRequests)} estimated`:"";return` sent ${f(e.total)} API requests to the org${o}: ${t.join(", ")}`}var Rt=e=>e.toDelete.createdSince+e.toDelete.broughtBackSince+e.toDelete.comesBackWithParent,J=e=>e.toBringBack.inBin+e.toBringBack.withParent+e.toBringBack.deletedWhileTaken,$e=e=>e.cannotUndo.reduce((n,t)=>n+t.count,0),X=e=>e.toRecreate??0,re=e=>e.toBringBack.carriers??0;function Ut(e){let n=e.files;return n===void 0?0:n.unlink+n.relink+n.updateLinks}function Fn(e){let n=e.files;return n===void 0?0:n.outsideAdded+n.outsideDeleted}function _n(e){let n=e.schemaDrift;return n===void 0?0:n.removed.length+(n.hidden?.length??0)+(n.uncertain?.fields.length??0)}function xe(e){let n=K(e);return n.toDelete+n.toGiveBack+n.toBringBack+n.toRecreate>0||Ut(e)+Fn(e)>0||e.objects.some(t=>$e(t)>0||t.unexplained>0||_n(t)>0)||e.unread.length>0}var Un={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"},Mn=[{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 Mt(e){return Mn.flatMap(n=>{let t=e.filter(o=>(o.reason??"onlyWithParent")===n.reason);return t.length>0?[{words:n,of:t}]:[]})}function Wn(e,n){let{automation:t,deliverability:o}=n;if(!t||!o)return[];let i=Y(n.diff),{line:s}=Xe({act:"rewind",orgName:e,automation:t,steps:i,accepted:!0,mayMute:!1,...Ye({automation:t,steps:i}),reading:o.reading}).gate;return s!==void 0?[` ${s}`]:[]}function qn(e,n){return n.map(t=>{let o=[...new Set(t.objects.flatMap(s=>s.sentBy))],i=` emails: ${e}'s automation sends about ${Ke(t.emails,t.limit)} as the rewind writes (${v(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 Hn(e,n){if(!e||n.length===0)return"";let t=he(e,{giveBack:n}).map(o=>`${o.objectApiName}: '${o.name}'`);return t.length>0?`, on which runs ${v(t,4)}`:""}function Gn(e,n,t=[]){let o=e.objects.filter(a=>He[a.objectApiName]!==void 0),i=o.filter(a=>X(a)>0),s=o.filter(a=>J(a)>0&&!t.includes(a.objectApiName)),d=[];return i.length>0&&d.push(` made as drafts first: ${v(i.map(a=>`${a.objectApiName} ${f(X(a))}`))} \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`+Hn(n,i.map(a=>a.objectApiName))),s.length>0&&d.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: ${v(s.map(a=>`${a.objectApiName} ${f(J(a))}`))}`),d}function zn(e,n,t=!1){if(!n)return{objects:[],fired:[]};let o=Y(e),i=[],s=new Set;for(let d of e.objects){if(J(d)===0)continue;let a=ct(n,o,[d.objectApiName],t);if(!(a.fired.length===0&&!a.blind)){i.push(d.objectApiName);for(let r of a.fired)s.add(`${r.objectApiName}: '${r.name}'`)}}return{objects:i,fired:[...s]}}function Jn(e,n,t){let o=he(n,t),i=[];for(let d of n.objects){let a=o.filter(g=>g.objectApiName===d.objectApiName),r=[...new Set(a.filter(g=>g.kind!=="trigger").map(g=>`'${g.name}'`))],p=[...new Set(a.filter(g=>g.kind==="trigger").map(g=>g.name))],m=[...r.length>0?[`${r.length} flow(s) or rule(s): ${v(r,4)}`]:[],...p.length>0?[`${p.length} Apex trigger(s): ${v(p,4)}`]:[]];m.length>0&&i.push(` ${d.objectApiName}: ${m.join("; ")}`)}return[...i.length>0?[` what ${e} runs as a rewind writes (updates, deletes, records brought back):`]:[],...i,...n.unread.map(d=>` not read of its automation: ${d.part} \u2014 ${d.reason}`)]}function Wt(e,n,t,o="the user SandForge connects as",i=!1){let{diff:s}=t,d=K(s),a=[`Rewind ${e} to '${n.name}' (${E(n.takenAt)}), read at ${ye(s.readAt)}:`,` ${f(d.toDelete)} to delete \xB7 ${f(d.toGiveBack)} to give back \xB7 ${f(d.toBringBack)} to bring back`+(d.toRecreate>0?` \xB7 ${f(d.toRecreate)} to make again`:"")];!xe(s)&&!s.objects.some(c=>c.outside.length>0)&&a.push(` ${e} is as it was at '${n.name}' among the objects and fields it holds: nothing to rewind.`);let r=s.objects.filter(c=>Rt(c)+c.toGiveBack.records+J(c)+X(c)+$e(c)>0);if(r.length>0){let c=Math.max(6,...r.map(u=>u.objectApiName.length));a.push(` ${"Object".padEnd(c)} ${"Delete".padStart(8)} ${"Give back".padStart(9)} ${"Bring back".padStart(10)} ${"Can't undo".padStart(10)}`);for(let u of r)a.push(` ${u.objectApiName.padEnd(c)} ${f(Rt(u)).padStart(8)} ${f(u.toGiveBack.records).padStart(9)} ${f(J(u)).padStart(10)} ${f($e(u)).padStart(10)}`)}let p=new Map;for(let c of s.objects)for(let[u,j]of Object.entries(c.lastChangedBy))p.set(u,(p.get(u)??0)+j);p.size>0&&a.push(` last changed by: ${[...p].sort((c,u)=>u[1]-c[1]).map(([c,u])=>`${s.userNames[c]??c} ${f(u)}`).join(" \xB7 ")}`),s.activeLastHour.length>0&&a.push(` people working in ${e} in the last hour: ${s.activeLastHour.map(c=>s.userNames[c]??c).join(", ")}`);let m=s.objects.filter(c=>c.touched>0);m.length>0&&a.push(` touched since but holding their checkpoint values: ${v(m.map(c=>`${c.objectApiName} ${f(c.touched)}`))}`);let g=s.objects.filter(c=>re(c)>0);g.length>0&&a.push(` brought back for a moment: ${v(g.map(c=>`${c.objectApiName} ${f(re(c))}`))} \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 c of s.objects)for(let u of c.cannotUndo)u.count!==0&&$.set(u.reason,[...$.get(u.reason)??[],`${c.objectApiName} ${f(u.count)}`]);for(let[c,u]of $)a.push(` can't be taken back: ${v(u)} \u2014 ${Un[c]??c}`);let w=s.objects.filter(c=>X(c)>0);w.length>0&&a.push(` to make again, with new Ids: ${v(w.map(c=>`${c.objectApiName} ${f(X(c))}`))} \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 h=d.toBringBack>0?zn(s,t.automation,i):void 0;if(h){let c=h.fired.length>0?`making them again runs ${v(h.fired,4)}`:"what runs as they are made again could not all be read";a.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"+(h.objects.length>0?`; ${v(h.objects)} records it leaves all the same, with what was to come back with them, and names them: ${c}, which this rewind does not ask about \u2014 a rewind after it counts them to make again, and asks`:""))}a.push(...Gn(s,t.automation,h?.objects));let l=s.objects.filter(c=>c.unexplained>0);l.length>0&&a.push(` left as they are: ${v(l.map(c=>`${c.objectApiName} ${f(c.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:c,of:u}of Mt(s.undoCannot))a.push(` undo couldn't bring back: ${v(u.map(j=>`${j.objectApiName} ${f(j.count)}`))} \u2014 ${c.preview}`);for(let{objectApiName:c,children:u,records:j}of s.unseen??[])a.push(` also deleted with them, out of sight: deleting ${f(j)} ${c} also deletes what ${o} can't see under them in ${v(u)}; Rewind can't count those, and deletes them only with --accept-unseen`);for(let c of s.objects)for(let u of c.outside)a.push(c.objectApiName===qt&&u.objectApiName===Vn?` also attached outside the checkpoint: ${f(u.parents)} file(s) it deletes, by ${f(u.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: ${f(u.count)} ${u.objectApiName} created under ${f(u.parents)} ${c.objectApiName}`);a.push(...Kn(e,s));let k=s.objects.flatMap(c=>{let u=c.schemaDrift,j=new Set([...u?.removed??[],...u?.hidden??[],...u?.uncertain?.fields??[]]);return c.notCompared.filter(C=>!j.has(C)).map(C=>`${c.objectApiName}.${C}`)});k.length>0&&a.push(` not compared (you chose): ${v(k)}`);for(let c of s.objects){let u=c.schemaDrift;if(!u)continue;let j=C=>C.map(O=>`${c.objectApiName}.${O}`);u.removed.length>0&&a.push(` fields deleted since: ${v(j(u.removed))} \u2014 restore them from Deleted Fields, then rewind`),(u.hidden??[]).length>0&&a.push(` fields hidden from ${o} by field-level security since: ${v(j(u.hidden??[]))} \u2014 rewind does not put them back; give ${o} read and edit access to them, then rewind again`),u.uncertain!==void 0&&u.uncertain.fields.length>0&&a.push(` fields gone from what ${e} shows ${o}: ${v(j(u.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`+(u.uncertain.reason!==void 0?` (which, ${e} would not say: ${u.uncertain.reason})`:"")),u.added.length>0&&a.push(` fields added since, their values left alone: ${v(j(u.added))}`),u.changed.length>0&&a.push(` fields changed since, tried one by one: ${v(j(u.changed))}`)}let y=s.fieldsNotChecked??0;y>0&&a.push(` fields not checked for changes in ${f(y)} objects nothing changed in: a rewind writes nothing there`);for(let c of s.unread)a.push(` could not be read: ${c.objectApiName} \u2014 ${c.reason} (never taken for unchanged)`);return t.automation&&a.push(...Jn(e,t.automation,Y(s))),t.emails&&a.push(...qn(e,t.emails)),t.emailsUncounted!==void 0&&a.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`),a.push(...Wn(e,t)),a.push(Lt(t.estimate)),t.refusal&&a.push(` a rewind now would be refused (${t.refusal.code}): ${t.refusal.message}`),a}var qt="ContentDocument",Vn="ContentDocumentLink";function Kn(e,n){let t=n.files;if(t===void 0)return[];let o=[];t.unlink>0&&o.push(` links to remove: ${f(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: ${f(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: ${f(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: ${f(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: ${f(t.outsideDeleted)} file(s) deleted since, as no record of this checkpoint linked to them`);let i=n.objects.find(a=>a.objectApiName===qt),s=i===void 0?0:J(i),{storage:d}=t;return s>0&&d.bringBack>0&&o.push(` file storage: bringing back ${f(s)} file(s) takes ${U(d.bringBack)} again; `+(d.remaining===void 0?`${e} did not say how much it has left`:`${e} has ${U(d.remaining)} left`)),d.undo>0&&o.push(` undo would bring back the files this rewind deletes: ${U(d.undo)} of file storage again`),t.blindSpot&&o.push(Oe),o}function Ht(e,n,t,o,i){let s=o?.diff??i?.diff??t.diff;return{checkpoint:{id:n.checkpointId,name:n.name,takenAt:n.takenAt,org:e},...o?{objects:[...o.plan.objects]}:{},...K(s),carriers:s.objects.reduce((d,a)=>d+re(a),0),differs:xe(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 Yn(e,n){return n&&xe(e)?3:0}var Gt={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 zt(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 ${v(t.map(o=>`${o.objectApiName} ${f(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: ${f(o.count)} ${o.objectApiName} record(s) \u2014 ${Gt[o.reason]}`);return e.needs.length>0&&n.push(` to rewind those too, add ${e.needs.map(o=>`--object ${o.objectApiName} (${f(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 Jt(e,n,t){return!t&&e.scope.mode==="picked"&&n.objects.some(o=>o.outside.length>0)}function Vt(e){return e.left.map(n=>` kept: ${f(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":Gt[n.reason]))}async function Kt(e,n,t,o){if(!Jt(n,t,o))return;let i=n.objects.map(({objectApiName:s})=>s);return Ee(e,t,i,!1)}function Yt(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 ${v(e.objects.map(i=>i.objectApiName))}. Nothing was run.`},2);return n.flatMap(i=>t.get(i.toLowerCase())??[])}async function Ee(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:de});if(i.outcome!=="answered")throw new b(P(i,"The plan of the objects named"));let s=D(i).plan;return{plan:s,diff:dt(n,s)}}var Q={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 Xn(e){return e.code==="AUTOMATION"?{...e,message:e.message.replace(ut,Q.lift.acceptAutomation)}:e}function Zn(e){return e.code==="AUTOMATION"?{...e,message:e.message.replace(ft,"give --accept-automation to undo the rewind all the same")}:e}function ti(e,n,t,o="the user SandForge connects as"){return ht(e,n,t,Q.lift,o,Q.mutes)}var Qn={acceptAutomation:!1,acceptNoUndo:!1,acceptRecreate:!1};function Xt(e,n){return[...e?[e]:[],...n.filter(t=>t.code!==e?.code)]}function eo(e,n,t,o){let i=o!==void 0&&o.length>0?`${o.join(", ")} of ${e}`:e,s=K(t),d=s.toRecreate>0?`, and makes ${f(s.toRecreate)} record(s) the recycle bin no longer holds again, with new Ids`:"",a=t.objects.reduce((g,$)=>g+re($),0),r=a>0?`, with ${f(a)} record(s) brought back for a moment that had taken records of the checkpoint along, then deleted again`:"",p=Ut(t),m=p>0?`, and puts ${f(p)} link(s) between files and records back as they were`:"";return`Rewind ${i} to '${n.name}': it deletes the ${f(s.toDelete)} record(s) created since ${E(n.takenAt)}, gives ${f(s.toGiveBack)} record(s) their values from then back, and brings back ${f(s.toBringBack)} record(s) from the recycle bin${r}${d}${m} \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 Ie(e){let n=R(e.deleted,a=>a.deleted),t=R(e.deleted,a=>a.planned),o=R(e.restored,a=>a.restored+(a.restoredWithout??0)),i=R(e.restored,a=>a.planned),s=R(e.undeleted,a=>a.undeleted+a.alreadyBack),d=R(e.undeleted,a=>a.planned);return{deleted:{planned:t,done:n,left:Math.max(0,t-n-R(e.deleted,a=>a.alreadyGone))},givenBack:{planned:i,done:o,left:Math.max(0,i-o-R(e.restored,a=>a.alreadyGone))},broughtBack:{planned:d,done:s,left:Math.max(0,d-s)}}}function Zt(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 to(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 Qt(e,n){return e===void 0?"another user":n[e]??e}function no(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 ${Qt(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 en(e,n){return`Stopped before it wrote anything: ${e} is as it was before this rewind. Rewind again to rewind it to '${n}'.`}function oo(e,n,t,o={},i){let s=R(t.residual,h=>h.count),d=t.residual.filter(h=>h.reason==="changedDuringRewind"),a={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 ${f(s)} record(s) that still differ, each said with why:`,unstable:`Someone kept writing to ${e} during the rewind: ${[...new Set(d.map(h=>Qt(h.by,o)))].join(", ")} changed ${f(R(d,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?en(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.`},r=t.scope;r!==void 0&&t.status==="success"&&(a.success=`${r.objects.join(", ")} of ${e} ${r.objects.length>1?"are":"is"} back at '${n.name}': read again, nothing differs among them.`);let p=Ie(t),m=R(t.undeleted,h=>h.alreadyBack),g=[a[t.status]];if(r!==void 0){let{objects:h,records:l}=r.notRewound;g.push(l>0?` not rewound: ${f(l)} record(s) of ${v(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")}p.deleted.done>0&&g.push(` deleted ${f(p.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)`),p.givenBack.done>0&&g.push(` gave ${f(p.givenBack.done)} record(s) back their checkpoint values`),p.broughtBack.done>0&&g.push(` brought back ${f(p.broughtBack.done-m)} record(s) deleted since the checkpoint, with their original Ids`+(m>0?`, and ${f(m)} that came back with them`:""));let $=t.status==="failure"?[]:t.carriers??[];if($.length>0){let h=v($.map(l=>`${l.objectApiName} ${f(l.count)}`));g.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 w=Zt(t);w.done>0&&g.push(` made again ${f(w.done)} record(s) the recycle bin no longer held, with new Ids`);for(let h of t.draftsLeft??[])g.push(` left as drafts: ${h.objectApiName} ${f(h.count)} (${v(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(g.push(...nn("rewind",e,t)),g.push(...on("rewind",t,o)),t.undo){g.push(` undo it until ${E(t.undo.until)}, sooner if the recycle bin fills: ${ne("checkpoint")} undo --org ${e} --checkpoint ${n.checkpointId}`+(i!==void 0?` --store ${i}`:""));for(let{words:h,of:l}of Mt(t.undo.cannot))g.push(` undo couldn't bring back: ${v(l.map(k=>`${k.objectApiName} ${f(k.count)}`))} \u2014 ${h.result}`)}for(let h of t.removedJournals??[])g.push(` removed the journal of rewind ${h.rewindId} of '${h.name}': undo reaches the last rewind of the org alone`);return g.push(sn(t)),g}function tn(e){return`Stopped before it wrote anything: ${e} is as the rewind left it, and the rewind can still be undone.`}function io(e,n,t){let o=R(t.restored,h=>h.keptChanged)+R(t.deleted,h=>h.keptChanged),i=R([...t.deleted,...t.restored,...t.undeleted],h=>h.refused),s=R(t.residual,h=>h.count)+i,d=`${e} is back as it was before its rewind to '${n.name}'`,a={success:`${d}.`,partial:o>0&&s===0?`${d}, except ${f(o)} record(s) changed since the rewind, left as they are now.`:`${d}, except ${f(s+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:Fe(t)?tn(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=Ie(t),p=[a[t.status]],m=to(t),g=R(t.wentAlong??[],h=>h.count),$=r.deleted.done-m-g;$>0&&p.push(` sent back to the recycle bin ${f($)} record(s) the rewind brought back`+(g>0?", with what came back with them":"")),m>0&&p.push(` deleted again ${f(m)} record(s) the rewind made again, with what went with them`);let w=t.carriedAlone??[];return w.length>0&&p.push(` of them, back in the recycle bin on their own: ${v(w.map(h=>`${h.objectApiName} ${f(h.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 ${f(r.broughtBack.done)} record(s) the rewind deleted`),r.givenBack.done>0&&p.push(` gave ${f(r.givenBack.done)} record(s) back the values they had before the rewind`),o>0&&p.push(` kept ${f(o)} record(s) changed since the rewind: undo leaves them as they are now`),p.push(...nn("undo",e,t)),p.push(...on("undo",t,{})),p.push(sn(t)),p}function nn(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"},s=["unlinked","relinked","linksUpdated"].filter(d=>o[d]>0).map(d=>` ${i[d].replace("{n}",f(o[d]))}`);return o.linksRefused>0&&s.push(` ${n} refused to write ${f(o.linksRefused)} link(s) between files and records`),s}function on(e,n,t){let o=n.residual.map(i=>` ${i.objectApiName} ${f(i.count)} \u2014 ${no(e,i,t)}`);if(e==="undo")for(let i of[...n.deleted,...n.restored,...n.undeleted])i.refused!==0&&o.push(` ${i.objectApiName} ${f(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 sn(e){return` sent ${f(e.apiRequests.used)} API requests to the org; ${f(e.apiRequests.leftToday)} left today`}function an(e,n,t,o,i){let s=new Map,d=r=>{let p=s.get(r);return p||(p={object:r,deleted:0,givenBack:0,broughtBack:0,refused:0},s.set(r,p)),p};for(let r of o.deleted)d(r.objectApiName).deleted+=r.deleted,d(r.objectApiName).refused+=r.refused;for(let r of o.restored)d(r.objectApiName).givenBack+=r.restored+(r.restoredWithout??0),d(r.objectApiName).refused+=r.refused;for(let r of o.undeleted)d(r.objectApiName).broughtBack+=r.undeleted+r.alreadyBack,d(r.objectApiName).refused+=r.refused;for(let r of o.recreated??[])d(r.objectApiName).refused+=r.refused;let a=(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}}:{},...Ie(o),...e==="rewind"?{recreated:Zt(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)+a.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:a,objects:[...s.values()],apiRequests:o.apiRequests,result:o}}function rn(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?oe(n):1}}var so=10*6e4,ao=720*6e4,dn=60*6e4,de=5*6e4,Ct=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 ro(e){let n=[e.refusal,...e.also];return{refusal:e.refusal,...e.also.length>0?{wouldBeRefused:n.map(t=>V(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),i=typeof t.code=="string"?t.code:e.outcome.toUpperCase(),{holdingLimit:s}=t;return{code:i,message:o,...typeof s=="number"?{holdingLimit:s}:{}}}function co(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 ho(e=process.argv,n={}){let t=Rn(e),o=h=>{process[t.json?"stderr":"stdout"].write(`${h}
|
|
466
|
+
`)},i=h=>{t.json&&process.stdout.write(`${JSON.stringify(h,null,2)}
|
|
467
|
+
`)},s=Qe({root:t.storeRoot,...n.locksDir!==void 0?{locksDir:n.locksDir}:{}});if("refusal"in s){let h=`The checkpoints cannot be kept in ${s.refusal.path}: `+Ze(s.refusal,t.storeRoot,"--store <folder>");process.stderr.write(`${h}
|
|
468
|
+
`),i({refusal:{code:"STORE_REFUSED",message:h}}),B(1);return}let d=s.store,a=pn(Ot(gn(),"sandforge-checkpoint-")),r=new mt,p=!1,m,g=()=>Promise.resolve(),$,w;try{let h=(n.createHost??pt)({storeDir:a,log:c=>{p&&c.startsWith("[INFO] ")?o(c.slice(7)):c.startsWith("[WARN] ")&&o(`warning: ${c.slice(7)}`)},compose:c=>{c.handlers.setCheckpointStore(d),c.handlers.rewindCheckpointsFromPreviewsAnswered(),c.handlers.setInfraServices({backgroundRegistry:r}),g=()=>c.handlers.sweepCheckpoints(),$=c.handlers,w=c},onPost:c=>{if(c.type!=="operation:progress")return;let u=c.payload?.currentStep;typeof u!="string"||u===m||(m=u,o(` ${u}`))}});p=!0;try{await g()}finally{p=!1}let l=async()=>{let c=await h.request({type:"checkpoint:list",timeoutMs:de});if(c.outcome!=="answered")throw new b(P(c,"The list of checkpoints"));return D(c).checkpoints??[]},k=async c=>{try{return await h.connect(c)}catch(u){throw new b({code:"NOT_CONNECTED",message:u instanceof We?u.message:`${c} could not be reached: ${u instanceof Error?u.message:String(u)}`})}},y=async c=>{if(w===void 0)throw new Error("The host composed no handlers.");return et(await Ue(c.id,w.orgRegistry,w.orgManager)).userId()};switch(t.command){case"list":{let c=await l(),u=t.org!==void 0?_(c,t.org):c,j=t.org!==void 0?{org:t.org,kept:c.length}:void 0;for(let C of On(u,d.root,j))o(C);i(u.map(xn));return}case"take":await mo(t,h,await k(t.org),d,r,o,i);return;case"preview":{let c=await l(),u=ee(G(c,_(c,t.org),t.checkpoint,t.org)),j=Re(u);if(j)throw new b(j);let C=u.checkpoint,O=t.objects.length>0?Yt(C,t.objects):void 0,W=await k(t.org);Ne(W,u,C,t.org,"preview");let q=await h.request({type:"checkpoint:preview",payload:{checkpointId:u.checkpointId,...O?{objects:O}:{},acceptOutside:!1},timeoutMs:dn});if(q.outcome!=="answered")throw new b(P(q,"The preview"));let I=D(q),L=O?await Ee(h,I.diff,O,!1):void 0,N=O?void 0:await Kt(h,C,I.diff,!1),te=L??N,A=te?{...I,diff:te.diff}:I,Pe=Xt(I.refusal,await me({orgName:t.org,preview:A,bounds:{refuseWhenActive:!1},accepted:Qn,writers:()=>Promise.resolve([]),words:Q,user:W.username})),[Le]=Pe;for(let T of Wt(t.org,C,A,W.username))o(T);for(let T of L?zt(L.plan):[])o(T);for(let T of N?Vt(N.plan):[])o(T);for(let T of Pe.slice(I.refusal?1:0))o(` a rewind now would be refused (${T.code}): ${T.message}`);i(Ht(t.org,C,{...I,...Le?{refusal:Le}:{}},L,N)),B(Yn(L?.diff??I.diff,t.failOnChange));return}case"rewind":case"undo":{let c={host:h,registry:r,store:d,listAll:l,connect:k,userIdOf:y,say:o,answerJson:i};t.command==="rewind"?await go(t,c):await yo(t,c);return}case"delete":await wo(t,h,l,o,i);return;case"export":await uo(t,{transfers:St($),listAll:l,say:o,answerJson:i});return;case"import":await fo(t,{transfers:St($),connect:k,say:o,answerJson:i});return;case"replay":await bt(t.replay,{storeRoot:t.storeRoot,storeNamed:t.storeNamed===!0,store:d,...n.locksDir!==void 0?{locksDir:n.locksDir}:{},listAll:l,checkpointsOf:_,resolve:G,say:o,json:t.json});return;case"replays":await vt(t.target,{storeRoot:t.storeRoot,storeNamed:t.storeNamed===!0,say:o,answerJson:i});return}}catch(h){let l=h instanceof b?h:h instanceof we?new b(h.refusal,h.code):new b({code:"FAILED",message:h instanceof Error?h.message:String(h)});process.stderr.write(`${h instanceof we?V(h.refusal):l.message}
|
|
469
|
+
`);for(let k of l.also)process.stderr.write(`${V(k)}
|
|
470
|
+
`);l.code!==2&&i(ro(l)),B(l.code)}finally{r.dispose(),wn(a,{recursive:!0,force:!0})}}function St(e){if(e===void 0)throw new Error("The host composed no handlers.");return e}function lo(){try{let e=JSON.parse(mn(Ot(__dirname,"..","package.json"),"utf8"));return typeof e.version=="string"?e.version:"0.0.0"}catch{return"0.0.0"}}function cn(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=se(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 hn(e,n){return{id:e.checkpointId,name:e.name,takenAt:e.takenAt,org:n}}async function uo(e,n){let{say:t,answerJson:o}=n,i=e.keyEnv!==void 0?cn(e.keyEnv):void 0,s=await n.listAll(),d=ee(G(s,_(s,e.org),e.checkpoint,e.org)),a=await n.transfers.exportCheckpoint({checkpointId:d.checkpointId,out:e.out,...i!==void 0?{key:i}:{},sandforgeVersion:lo()});if(!a.exported)throw new b(a.refusal);let{checkpoint:r,header:p}=a;t(`exported '${r.name}' (${r.checkpointId}) of ${e.org}, taken ${E(r.takenAt)}: ${f(p.records)} record(s) of ${f(p.objects)} object(s), ${U(a.bytes)}, to ${e.out}`),t(` sha256 ${a.sha256}`),a.key!==void 0&&process.stderr.write(` key, shown this once and kept nowhere: ${a.key}
|
|
471
|
+
`),t(` Anyone who has this file and its key can read the ${f(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:hn(r,e.org),file:e.out,bytes:a.bytes,sha256:a.sha256,records:p.records,objects:p.objects,keyShown:a.key!==void 0})}async function fo(e,n){let{say:t,answerJson:o}=n,i=e.keyEnv!==void 0?cn(e.keyEnv):void 0,s=await n.connect(e.org),d=await n.transfers.readCheckpointImport({orgId:s.id,file:e.file});if(d.header!==void 0){let{header:m}=d;t(`the file holds checkpoint ${m.checkpointId}, taken ${E(m.takenAt)}: ${f(m.records)} record(s) of ${f(m.objects)} object(s), ${U(m.bytes)}, exported by SandForge ${m.sandforgeVersion}`)}if(!d.allowed)throw new b(d.refusal.code==="OTHER_ORG"?{...d.refusal,message:`${d.refusal.message} Its replay into ${e.org}: ${kt(e.file,e.org)} --dry-run`}:d.refusal);let a=i??await po(),r=await n.transfers.importCheckpoint({orgId:s.id,file:e.file,key:a,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}: ${f(Z(p))} record(s) of ${f(p.objects.length)} object(s), ${Se(p.expiresAt)}`:`'${p.name}' (${p.checkpointId}) is kept on this machine already, the same: left as it is`);for(let m of r.warnings)t(` ${m}`);o({outcome:r.outcome,checkpoint:hn(p,e.org),records:Z(p),objects:p.objects.length,expiresAt:p.expiresAt,warnings:r.warnings})}async function po(){let e=await it("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=se(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 ee(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 mo(e,n,t,o,i,s,d){let{take:a}=e;if(e.estimate){let l={orgId:t.id,mode:a.mode,...a.objects?{objects:a.objects}:{},...a.excluded?{excluded:a.excluded}:{},...a.customSettings?{customSettings:a.customSettings}:{},...a.maxTotal!==void 0?{maxTotal:a.maxTotal}:{}},k=await n.request({type:"checkpoint:scope",payload:l,timeoutMs:so});if(k.outcome!=="answered")throw new b(P(k,"The estimate"));let y=D(k),c={mode:y.mode,objects:y.objects,leftOut:y.leftOut,estimate:y.estimate,...y.refusal?{refusal:ve(y.refusal)}:{},...y.files?{files:y.files}:{},...y.customSettings?{customSettings:y.customSettings}:{}};for(let u of In(e.org,c))s(u);d(En(c)),B(c.refusal?1:0);return}s(`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 De(i,"the take stops after the read under way, and keeps nothing",()=>n.request({type:"checkpoint:take",payload:{orgId:t.id,...a},timeoutMs:ao}));if(r.outcome!=="answered"){let l=ve(P(r,"The take"));throw p!==void 0&&l.code==="CANCELLED"?new b(l,oe(p)):new b(l)}let m=D(r),g=m.checkpoint,$=m.requests,w=m.estimate,h=o.folderOf(g.org.organizationId,g.checkpointId).dir;for(let l of Pn(g,h,a.objects??[]))s(l);$&&s(Bn($,w)),d({checkpoint:g,...$?{requests:$}:{},...w?{estimate:w}:{}})}async function wo(e,n,t,o,i){let s=await t(),d=_(s,e.org),a=e.checkpoint===void 0?d:[ee(G(s,d,e.checkpoint,e.org))];if(a.length===0)throw new b({code:"NOT_FOUND",message:`No checkpoint of ${e.org} is kept in the folder read. ${ae(e.org)} Nothing was deleted.`});let r=l=>l.checkpoint?`'${l.checkpoint.name}' (${l.checkpointId})`:l.checkpointId;if(!e.yes){let l=a.filter(u=>u.undo!==void 0),k=a.length===1?`Delete ${r(a[0])}${a[0].checkpoint?`, taken ${E(a[0].checkpoint.takenAt)},`:""} from this machine? ${e.org} can no longer be rewound to it`:`Delete the ${a.length} checkpoints of ${e.org} from this machine (${v(a.map(r),4)})? ${e.org} can no longer be rewound to them`,y=(await ke(a,{storeRoot:e.storeRoot,storeNamed:e.storeNamed===!0})).entries,c=`${k}${l.length>0?", and its last rewind can no longer be undone":""}. The org is not touched`+(y.length>0?`, nor the ${y.length===1?"org it was":"orgs they were"} replayed into (${v(y.map(u=>u.target.name??u.target.organizationId),4)}), each replay still taken back with --remove`:"")+".";if(!await ot(c))throw new b({code:"DECLINED",message:"Nothing was deleted."})}let p=a.map(l=>l.checkpointId);for(let l=0;l<p.length;l+=Ct){let k=await n.request({type:"checkpoint:delete",payload:{checkpointIds:p.slice(l,l+Ct)},timeoutMs:de});if(k.outcome!=="answered"){let y=P(k,"The delete");if(l===0)throw new b(y);o(`refused: ${y.message}`);break}}let m=new Set((await t()).map(l=>l.checkpointId)),g=a.filter(l=>!m.has(l.checkpointId)),$=a.filter(l=>m.has(l.checkpointId));for(let l of g)o(`deleted ${r(l)}`);for(let l of $)o(`kept ${r(l)}: a take, a rewind or an undo of its org is running; delete it once it has ended`);let w=await ke(g,{storeRoot:e.storeRoot,storeNamed:e.storeNamed===!0});for(let l of w.lines)o(l);let h=e.storeNamed?e.storeRoot:void 0;i({deleted:g.map(l=>l.checkpointId),kept:$.map(l=>l.checkpointId),...w.entries.length>0?{replaysInPlace:w.entries.map(l=>yt(l,h))}:{}}),$.length>0&&B(g.length>0?3:1)}function Ne(e,n,t,o,i){if(xt(e.orgId,n.organizationId))return;let s=_([n],o).length>0,d=i==="preview"?"preview it":i==="rewind"?"rewind to it":"undo it";throw new b({code:"OTHER_ORG",message:s?`${o} answers as another org than the one '${t.name}' was taken of: a sandbox refreshed since is another org, and this checkpoint no longer rewinds it. ${ce.replace(/\.$/,"")}: ${ge(n.checkpointId,o)} --dry-run. No record was read.`:`'${t.name}' is a checkpoint of ${z(t)}, not of ${o}: ${d} with --org ${z(t)}. No record was read.`})}async function De(e,n,t){let o,i=e.onEvent((d,a,r)=>{o!==void 0&&a==="started"&&r.module==="checkpoint"&&e.abort(d)}),s=qe(d=>{o=d,process.stderr.write(`
|
|
472
|
+
interrupted: ${n} (Ctrl-C again ends it at once)
|
|
473
|
+
`);for(let a of e.getRunning())a.module==="checkpoint"&&e.abort(a.operationId)});try{let d=await t();return o!==void 0?{answer:d,stoppedBy:o}:{answer:d}}finally{s(),i()}}var ln=720*6e4;function un(e,n,t=o=>o){let{answer:o,stoppedBy:i}=e;if(o.outcome!=="answered"){let s=t(P(o,n));throw i!==void 0&&s.code==="CANCELLED"?new b(s,oe(i)):new b(s,1,co(o).map(t))}return D(o).result}async function go(e,n){let{host:t,say:o,answerJson:i}=n,s=await n.listAll(),d=ee(G(s,_(s,e.org),e.checkpoint,e.org)),a=Re(d);if(a)throw new b(a);let r=d.checkpoint,p=e.ignoreFields.filter(A=>!r.ignoredFields.includes(A));if(p.length>0){let A=await t.request({type:"checkpoint:ignore-fields",payload:{checkpointId:d.checkpointId,fields:[...r.ignoredFields,...p]},timeoutMs:de});if(A.outcome!=="answered")throw new b(P(A,"The fields not to compare"));r=D(A).checkpoint,o(`not compared from now on, nor written back: ${p.join(", ")} (kept in '${r.name}')`)}let m=e.objects.length>0?Yt(r,e.objects):void 0,g=await n.connect(e.org);Ne(g,d,r,e.org,"rewind");let $=await t.request({type:"checkpoint:preview",payload:{checkpointId:d.checkpointId,...m?{objects:m}:{},...e.muteAutomation?{muteAutomation:!0}:{},acceptOutside:e.acceptOutside},timeoutMs:dn});if($.outcome!=="answered")throw new b(P($,"The preview"));let w=D($),h=m?await Ee(t,w.diff,m,e.acceptOutside):void 0,l=m?void 0:await Kt(t,r,w.diff,e.acceptOutside),k=h??l,y=k?{...w,diff:k.diff}:w,c=e.muteAutomation&&y.automation?Ve(y.automation,_e(Y(y.diff))):void 0,u=c?{...y,automation:c.automation}:y;for(let A of Wt(e.org,r,u,g.username,e.acceptAutomation))o(A);for(let A of h?zt(h.plan):[])o(A);for(let A of l?Vt(l.plan):[])o(A);for(let A of c?ie(c.planned,e.org):[])o(` ${A}`);let j=rt(u.diff).length>0,C=await me({orgName:e.org,preview:u,bounds:{...e.maxRecords!==void 0?{maxRecords:e.maxRecords}:{},refuseWhenActive:e.refuseWhenActive},accepted:e,writers:async()=>at(r.takenBy,await n.userIdOf(g)),words:Q,user:g.username}),O=Xt(u.refusal,C);if(Jt(r,u.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 A of O.slice(u.refusal?1:0))o(` a rewind now would be refused (${A.code}): ${A.message}`);i({...Ht(e.org,r,w,h,l),...c?{mutedAutomation:c.planned,mutePlan:c.plan}:{},...O.length>0?{wouldBeRefused:O.map(A=>V(A)),wouldBeRefusedCodes:O.map(A=>A.code)}:{}});return}let[q,...I]=O;if(q)throw new b(q,1,I);if(j&&!e.yes&&await fe(eo(e.org,r,u.diff,m))!==e.org)throw new b({code:"DECLINED",message:"Nothing was written."});let L=await De(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:d.checkpointId,previewId:u.diff.previewId,...m?{objects:m}:{},acceptAutomation:e.acceptAutomation,...e.acceptEmails?{acceptEmails:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{},acceptNoUndo:e.acceptNoUndo,acceptRecreate:e.acceptRecreate,acceptOutside:e.acceptOutside,acceptUnseen:e.acceptUnseen},timeoutMs:ln})),N=un(L,"The rewind",A=>A.code==="CANCELLED"?{...A,message:en(e.org,r.name)}:Xn(A)),te=e.storeRoot!==le()?e.storeRoot:void 0;for(let A of oo(e.org,r,N,u.diff.userNames,te))o(A);for(let A of N.mutedAutomation?ie(N.mutedAutomation,e.org):[])o(A);i(an("rewind",e.org,r,N,u.diff)),B(rn(N.status,L.stoppedBy))}function ko(e,n,t,o,i){return`undo the rewind ${t} of ${e} to '${n.name}' (open until ${E(o)}, sooner if the recycle bin fills)`+(i?`: it brings back ${f(i.bringBack)} record(s) the rewind deleted, gives ${f(i.giveBack)} record(s) back the values they had before it, and sends ${f(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 ${f(i.remade)} record(s) it made again`:"")+(i.drafted>0?` \u2014 of them, ${f(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 bo(e,n,t,o){try{let i=e.folderOf(n.organizationId,n.checkpointId),s=await lt(i,o,t.objects);try{return{bringBack:s.bringBack.count,giveBack:s.giveBack.count,remove:s.remove.spool.count,along:s.goesWithParent.count,remade:s.remade.keys.size,drafted:s.remade.objects.filter(({objectApiName:d})=>Je([d]).length>0).reduce((d,{count:a})=>d+a,0)}}finally{await s.dispose()}}catch{return}}async function yo(e,n){let{host:t,say:o,answerJson:i}=n,s=await n.listAll(),d=_(s,e.org),a=e.checkpoint===void 0?d.find(k=>k.undo!==void 0):ee(G(s,d,e.checkpoint,e.org));if(!a)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=Re(a);if(r)throw new b(r);let p=a.checkpoint;if(!a.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:m,until:g}=a.undo,$=await bo(n.store,a,p,m);o(ko(e.org,p,m,g,$));let w=await n.connect(e.org);if(Ne(w,a,p,e.org,"undo"),!e.yes&&await fe(`Type ${e.org} to undo its rewind:`)!==e.org)throw new b({code:"DECLINED",message:"Nothing was written."});let h=await De(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:a.checkpointId,rewindId:m,acceptAutomation:e.acceptAutomation,...e.acceptEmails?{acceptEmails:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{}},timeoutMs:ln})),l=un(h,"The undo",k=>k.code==="CANCELLED"?{...k,message:tn(e.org)}:Zn(k));for(let k of io(e.org,p,l))o(k);for(let k of l.mutedAutomation?ie(l.mutedAutomation,e.org):[])o(k);i(an("undo",e.org,p,l)),B(rn(l.status,h.stoppedBy))}process.argv[1]?.includes("sandforge-checkpoint")&&(st(),ho().then(()=>process.exit(process.exitCode??0)).catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
|
|
474
|
+
`),process.exit(1)}));export{jn as a,Rn as b,_ as c,G as d,Re as e,Ce as f,On as g,xn as h,En as i,ve as j,In as k,Pn as l,Bn as m,Ut as n,xe as o,Wt as p,Ht as q,Yn as r,zt as s,Jt as t,Vt as u,Yt as v,ti as w,eo as x,oo as y,io as z,an as A,rn as B,ho as C,ko as D};
|