sandforge 0.0.0-stage → 1.79.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +54 -2
- package/THIRD-PARTY-NOTICES.md +1624 -0
- package/bin/sandforge-autopilot.mjs +12 -0
- package/bin/sandforge-backup.mjs +12 -0
- package/bin/sandforge-checkpoint.mjs +12 -0
- package/bin/sandforge-cleanup.mjs +12 -0
- package/bin/sandforge-clone.mjs +12 -0
- package/bin/sandforge-compare.mjs +12 -0
- package/bin/sandforge-dataops.mjs +12 -0
- package/bin/sandforge-empty.mjs +12 -0
- package/bin/sandforge-env.mjs +12 -0
- package/bin/sandforge-frozen.mjs +12 -0
- package/bin/sandforge-mcp.mjs +12 -0
- package/bin/sandforge-monitor.mjs +12 -0
- package/bin/sandforge-seed.mjs +12 -0
- package/bin/sandforge-sync.mjs +12 -0
- package/bin/sandforge.mjs +12 -0
- package/lib/catalogue.en.json +1 -0
- package/lib/chunk-2BVTCNWA.mjs +7 -0
- package/lib/chunk-2S5OMIIA.mjs +7 -0
- package/lib/chunk-2YIV2OB2.mjs +7 -0
- package/lib/chunk-342FN7AO.mjs +9 -0
- package/lib/chunk-36U7IQ6Y.mjs +25 -0
- package/lib/chunk-3CA767QB.mjs +7 -0
- package/lib/chunk-3DCUADVK.mjs +7 -0
- package/lib/chunk-3F5YMM2F.mjs +7 -0
- package/lib/chunk-3OHPD72J.mjs +9 -0
- package/lib/chunk-3RYLICRX.mjs +7 -0
- package/lib/chunk-3SRXFZSD.mjs +7 -0
- package/lib/chunk-42RER7V4.mjs +14 -0
- package/lib/chunk-4GL773D5.mjs +7 -0
- package/lib/chunk-4HFRHFGQ.mjs +7 -0
- package/lib/chunk-4HW535YJ.mjs +7 -0
- package/lib/chunk-4NAHW2D3.mjs +7 -0
- package/lib/chunk-4SNDMJP2.mjs +7 -0
- package/lib/chunk-4TLYUZD5.mjs +7 -0
- package/lib/chunk-4U6NXJNL.mjs +7 -0
- package/lib/chunk-4XZ5YT5O.mjs +7 -0
- package/lib/chunk-55HEMHEG.mjs +7 -0
- package/lib/chunk-57VHUYNG.mjs +10 -0
- package/lib/chunk-5AJRHRXA.mjs +20 -0
- package/lib/chunk-5CD257T7.mjs +7 -0
- package/lib/chunk-5HMAPZBV.mjs +7 -0
- package/lib/chunk-5LFSFYFJ.mjs +7 -0
- package/lib/chunk-5MMXFWPD.mjs +7 -0
- package/lib/chunk-5O6JOMHS.mjs +13 -0
- package/lib/chunk-5P4PHJRL.mjs +9 -0
- package/lib/chunk-5QKTYCWE.mjs +11 -0
- package/lib/chunk-66NMFCWX.mjs +7 -0
- package/lib/chunk-6EBMEGZB.mjs +7 -0
- package/lib/chunk-6LAXTAVN.mjs +7 -0
- package/lib/chunk-6MUEPV7M.mjs +9 -0
- package/lib/chunk-6QSM2WIH.mjs +10 -0
- package/lib/chunk-75ADZS6B.mjs +7 -0
- package/lib/chunk-7EANH5PY.mjs +68 -0
- package/lib/chunk-7F54PZUS.mjs +7 -0
- package/lib/chunk-7UQD6V6F.mjs +7 -0
- package/lib/chunk-AAVJ5XVX.mjs +7 -0
- package/lib/chunk-ALJVEUUS.mjs +7 -0
- package/lib/chunk-ALUFROGA.mjs +7 -0
- package/lib/chunk-AR7BE5O2.mjs +7 -0
- package/lib/chunk-AUTM6H6Z.mjs +7 -0
- package/lib/chunk-AV5SWEHP.mjs +9 -0
- package/lib/chunk-B45CNPUX.mjs +47 -0
- package/lib/chunk-BILZ3SSR.mjs +7 -0
- package/lib/chunk-BN7A4GRQ.mjs +7 -0
- package/lib/chunk-BOGNK4LV.mjs +7 -0
- package/lib/chunk-BS5T3MOQ.mjs +7 -0
- package/lib/chunk-BZ24IAP5.mjs +7 -0
- package/lib/chunk-CA5NAXSU.mjs +7 -0
- package/lib/chunk-CE6ZDGBB.mjs +7 -0
- package/lib/chunk-CGWXQX75.mjs +7 -0
- package/lib/chunk-CHCHAE4B.mjs +7 -0
- package/lib/chunk-D3QRXG63.mjs +787 -0
- package/lib/chunk-DBFJB2B6.mjs +7 -0
- package/lib/chunk-DLDX6RRC.mjs +7 -0
- package/lib/chunk-EADHKH3A.mjs +7 -0
- package/lib/chunk-EEVVGGM6.mjs +7 -0
- package/lib/chunk-ENLBYECD.mjs +7 -0
- package/lib/chunk-EQF2IJS2.mjs +11 -0
- package/lib/chunk-EQOQASDQ.mjs +7 -0
- package/lib/chunk-F2424IKX.mjs +7 -0
- package/lib/chunk-F74IHMGL.mjs +7 -0
- package/lib/chunk-FOVVHGEP.mjs +7 -0
- package/lib/chunk-FQBRBBY4.mjs +7 -0
- package/lib/chunk-FQGHL7GR.mjs +259 -0
- package/lib/chunk-GAM726CK.mjs +7 -0
- package/lib/chunk-GCOB7K5N.mjs +7 -0
- package/lib/chunk-GMY5427L.mjs +7 -0
- package/lib/chunk-GNC27UEU.mjs +7 -0
- package/lib/chunk-H2PJNIYJ.mjs +7 -0
- package/lib/chunk-H45UXY6G.mjs +7 -0
- package/lib/chunk-HCIDVIOW.mjs +7 -0
- package/lib/chunk-HF6LAK3G.mjs +7 -0
- package/lib/chunk-HJC7AIBK.mjs +7 -0
- package/lib/chunk-HJKM3E56.mjs +7 -0
- package/lib/chunk-HTJ5OGP5.mjs +7 -0
- package/lib/chunk-HUMEKZT5.mjs +8 -0
- package/lib/chunk-HV2MXMGI.mjs +7 -0
- package/lib/chunk-HXS7ORUF.mjs +11 -0
- package/lib/chunk-I3JKJTLO.mjs +110 -0
- package/lib/chunk-I7O6C2B5.mjs +8 -0
- package/lib/chunk-IAZB4WIL.mjs +7 -0
- package/lib/chunk-IC2C2GOF.mjs +8 -0
- package/lib/chunk-IEYG5ATY.mjs +7 -0
- package/lib/chunk-INIQ23K6.mjs +7 -0
- package/lib/chunk-INIT2UKJ.mjs +7 -0
- package/lib/chunk-J7HVXMSW.mjs +7 -0
- package/lib/chunk-JVL444U5.mjs +7 -0
- package/lib/chunk-K22PA4XL.mjs +7 -0
- package/lib/chunk-K2FBZIXY.mjs +7 -0
- package/lib/chunk-KLX67VPL.mjs +7 -0
- package/lib/chunk-L776PUMV.mjs +7 -0
- package/lib/chunk-LQ4DRFUH.mjs +9 -0
- package/lib/chunk-LRFAIUN7.mjs +7 -0
- package/lib/chunk-LV6G4XTK.mjs +7 -0
- package/lib/chunk-M6P5ZZLE.mjs +7 -0
- package/lib/chunk-MTMH6H2A.mjs +8 -0
- package/lib/chunk-MYTIL2JD.mjs +10 -0
- package/lib/chunk-NEVXIGR6.mjs +10 -0
- package/lib/chunk-NGSMZZDA.mjs +7 -0
- package/lib/chunk-NHWE66K5.mjs +7 -0
- package/lib/chunk-NM4MDLK4.mjs +7 -0
- package/lib/chunk-NTDN2JQZ.mjs +19 -0
- package/lib/chunk-NTOVCTRS.mjs +7 -0
- package/lib/chunk-NZ5ZZLKS.mjs +7 -0
- package/lib/chunk-OQOZAPCI.mjs +7 -0
- package/lib/chunk-OTWRDD6L.mjs +7 -0
- package/lib/chunk-P2PJYWGQ.mjs +7 -0
- package/lib/chunk-P42X3B4D.mjs +7 -0
- package/lib/chunk-P7GSGFJO.mjs +7 -0
- package/lib/chunk-PA3MKJVH.mjs +7 -0
- package/lib/chunk-PBI4BYWW.mjs +7 -0
- package/lib/chunk-PNCONNFJ.mjs +10 -0
- package/lib/chunk-PTTHSSQO.mjs +7 -0
- package/lib/chunk-PUOX4NBJ.mjs +8 -0
- package/lib/chunk-PZTSVQSF.mjs +7 -0
- package/lib/chunk-QPF6C5MX.mjs +7 -0
- package/lib/chunk-QQZZMKU3.mjs +7 -0
- package/lib/chunk-QROPNEGY.mjs +14 -0
- package/lib/chunk-QRV2OSIS.mjs +7 -0
- package/lib/chunk-QSRAEUGZ.mjs +7 -0
- package/lib/chunk-QWT2C74M.mjs +7 -0
- package/lib/chunk-RAAANPPG.mjs +7 -0
- package/lib/chunk-RACDTRZA.mjs +7 -0
- package/lib/chunk-RFEO2KAN.mjs +7 -0
- package/lib/chunk-RH3N2H7P.mjs +7 -0
- package/lib/chunk-RSWDYIHY.mjs +37 -0
- package/lib/chunk-RSYICMZG.mjs +8 -0
- package/lib/chunk-SAR5622P.mjs +7 -0
- package/lib/chunk-SBIMVCXT.mjs +101 -0
- package/lib/chunk-SCKUIE3R.mjs +7 -0
- package/lib/chunk-SFURUNJM.mjs +7 -0
- package/lib/chunk-SIOZXPFG.mjs +7 -0
- package/lib/chunk-SRPWW4A2.mjs +10 -0
- package/lib/chunk-SRQDABQ2.mjs +15 -0
- package/lib/chunk-SVS6UMDU.mjs +323 -0
- package/lib/chunk-T63U4OZJ.mjs +7 -0
- package/lib/chunk-TBZMC2VV.mjs +11 -0
- package/lib/chunk-TEOLMRDO.mjs +7 -0
- package/lib/chunk-TLH7AD35.mjs +7 -0
- package/lib/chunk-TNXUU6W7.mjs +14 -0
- package/lib/chunk-TQX3PURV.mjs +7 -0
- package/lib/chunk-TUACWKIH.mjs +7 -0
- package/lib/chunk-TW3N6W5Z.mjs +7 -0
- package/lib/chunk-TYYOBZMU.mjs +10 -0
- package/lib/chunk-TZE3Y7IQ.mjs +7 -0
- package/lib/chunk-UNDIBZWG.mjs +7 -0
- package/lib/chunk-VGW4MXXZ.mjs +7 -0
- package/lib/chunk-VHI54FBK.mjs +441 -0
- package/lib/chunk-VXHDBYMI.mjs +7 -0
- package/lib/chunk-W7KFAY55.mjs +7 -0
- package/lib/chunk-WFEB5X4U.mjs +8 -0
- package/lib/chunk-WIO4XO4F.mjs +7 -0
- package/lib/chunk-WJY54JO7.mjs +13 -0
- package/lib/chunk-WR2GIKWE.mjs +7 -0
- package/lib/chunk-WRU5FJFC.mjs +7 -0
- package/lib/chunk-X2PY6MWZ.mjs +7 -0
- package/lib/chunk-X65MT4W3.mjs +7 -0
- package/lib/chunk-XBG5SP6Q.mjs +7 -0
- package/lib/chunk-XCA5AONB.mjs +7 -0
- package/lib/chunk-XEFDB2R4.mjs +7 -0
- package/lib/chunk-XETCPL7E.mjs +7 -0
- package/lib/chunk-Y5CGXLUB.mjs +7 -0
- package/lib/chunk-Y6J6QFI2.mjs +7 -0
- package/lib/chunk-YAZO75G2.mjs +8 -0
- package/lib/chunk-YBU4Z4QV.mjs +7 -0
- package/lib/chunk-YMJVMFPY.mjs +7 -0
- package/lib/chunk-YPSRZRIT.mjs +7 -0
- package/lib/chunk-YS4G22C2.mjs +7 -0
- package/lib/chunk-YW2SBL4Z.mjs +7 -0
- package/lib/chunk-YYZL7UGV.mjs +7 -0
- package/lib/chunk-Z7X534S4.mjs +10 -0
- package/lib/chunk-ZE6HKRR4.mjs +9 -0
- package/lib/chunk-ZHJP7L3K.mjs +7 -0
- package/lib/chunk-ZJKCWBRJ.mjs +7 -0
- package/lib/chunk-ZLZRU6MO.mjs +7 -0
- package/lib/chunk-ZOVSMN5C.mjs +7 -0
- package/lib/chunk-ZPYJPGDK.mjs +7 -0
- package/lib/chunk-ZQOZ4EFW.mjs +7 -0
- package/lib/chunk-ZUTYVST5.mjs +7 -0
- package/lib/chunk-ZXH4MBWP.mjs +7 -0
- package/lib/chunk-ZYEE34WO.mjs +7 -0
- package/lib/sandforge-autopilot.mjs +157 -0
- package/lib/sandforge-backup.mjs +99 -0
- package/lib/sandforge-checkpoint.mjs +353 -0
- package/lib/sandforge-cleanup.mjs +56 -0
- package/lib/sandforge-clone.mjs +7 -0
- package/lib/sandforge-compare.mjs +54 -0
- package/lib/sandforge-dataops.mjs +7 -0
- package/lib/sandforge-empty.mjs +140 -0
- package/lib/sandforge-env.mjs +355 -0
- package/lib/sandforge-frozen.mjs +263 -0
- package/lib/sandforge-mcp.mjs +40 -0
- package/lib/sandforge-monitor.mjs +43 -0
- package/lib/sandforge-seed.mjs +7 -0
- package/lib/sandforge-sync.mjs +7 -0
- package/lib/sandforge.mjs +28 -0
- package/package.json +52 -4
|
@@ -0,0 +1,263 @@
|
|
|
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{o as St}from"./chunk-SVS6UMDU.mjs";import"./chunk-AUTM6H6Z.mjs";import"./chunk-INIQ23K6.mjs";import"./chunk-RAAANPPG.mjs";import{a as Et}from"./chunk-PBI4BYWW.mjs";import"./chunk-ZE6HKRR4.mjs";import{a as Ft,b as Lt,d as Nt,e as Se,f as zt,g as Dt,h as Pt,i as It,j as re,k as ne,l as xt}from"./chunk-5AJRHRXA.mjs";import{k as Tt,n as Ct,p as jt}from"./chunk-42RER7V4.mjs";import"./chunk-XEFDB2R4.mjs";import"./chunk-H45UXY6G.mjs";import"./chunk-WRU5FJFC.mjs";import"./chunk-GMY5427L.mjs";import"./chunk-GNC27UEU.mjs";import"./chunk-YBU4Z4QV.mjs";import{a as _t}from"./chunk-TW3N6W5Z.mjs";import"./chunk-5P4PHJRL.mjs";import{Ba as H,K,Qa as Oe,Ra as vt,Ua as At,Va as oe,Xa as kt,Ya as X,ab as $t,bb as Rt,c as Ae,f as ke,g as $e,gb as Ot,h as ct,i as pt,k as ft,l as Re,m as ht,n as mt,o as gt,p as wt,t as bt}from"./chunk-D3QRXG63.mjs";import"./chunk-NM4MDLK4.mjs";import"./chunk-BS5T3MOQ.mjs";import"./chunk-TEOLMRDO.mjs";import"./chunk-FQBRBBY4.mjs";import"./chunk-YS4G22C2.mjs";import{a as ut}from"./chunk-SCKUIE3R.mjs";import{a as dt,b as lt}from"./chunk-QROPNEGY.mjs";import{b as me,e as Ze}from"./chunk-BZ24IAP5.mjs";import{c as Q,d as Y}from"./chunk-AV5SWEHP.mjs";import"./chunk-I7O6C2B5.mjs";import"./chunk-XCA5AONB.mjs";import{b as ee}from"./chunk-YMJVMFPY.mjs";import"./chunk-ALJVEUUS.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-BOGNK4LV.mjs";import{x as it}from"./chunk-36U7IQ6Y.mjs";import"./chunk-XETCPL7E.mjs";import"./chunk-K2FBZIXY.mjs";import"./chunk-Z7X534S4.mjs";import"./chunk-6QSM2WIH.mjs";import"./chunk-WJY54JO7.mjs";import{d as et}from"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-NEVXIGR6.mjs";import"./chunk-NTDN2JQZ.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-F74IHMGL.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-Y5CGXLUB.mjs";import"./chunk-3F5YMM2F.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import{b as Je,c as he}from"./chunk-L776PUMV.mjs";import{A as q,r as we,t as ye,u as be}from"./chunk-6MUEPV7M.mjs";import"./chunk-HJC7AIBK.mjs";import"./chunk-OTWRDD6L.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-RH3N2H7P.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-55HEMHEG.mjs";import"./chunk-P42X3B4D.mjs";import"./chunk-TUACWKIH.mjs";import{P as ve,Pa as nt,S as te,V as ot,W as rt,bb as st,cb as at}from"./chunk-VXHDBYMI.mjs";import{q as tt}from"./chunk-ENLBYECD.mjs";import"./chunk-PA3MKJVH.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-ZLZRU6MO.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-PNCONNFJ.mjs";import{D as ge}from"./chunk-CGWXQX75.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-SIOZXPFG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import{a as Xe,e as Qe,f as Ye,g as yt}from"./chunk-MTMH6H2A.mjs";import{Tc as Ve,Uc as fe,Vb as qe,Vc as Z,Wc as Ke,bd as He}from"./chunk-B45CNPUX.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-SBIMVCXT.mjs";import"./chunk-NTOVCTRS.mjs";import{existsSync as Ce,mkdirSync as ro,readdirSync as no,readFileSync as de}from"node:fs";import{dirname as so,join as _}from"node:path";import{homedir as ao}from"node:os";var io=`sandforge frozen \u2014 build and replay a Frozen Dataset, without the editor.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
npx sandforge frozen <step> --config <file> [options]
|
|
11
|
+
|
|
12
|
+
Steps:
|
|
13
|
+
select pick one root per combination of the coverage matrix (needs --source)
|
|
14
|
+
extract read, pseudonymize, check and freeze those roots (needs --source)
|
|
15
|
+
load replay the frozen dataset into a sandbox or a Developer Edition
|
|
16
|
+
\u2014 WRITES (needs --target);
|
|
17
|
+
what the target runs as it inserts and updates is named first, and takes
|
|
18
|
+
--accept-automation or --mute-automation
|
|
19
|
+
verify check the last load against the dataset (needs --target)
|
|
20
|
+
remove delete the records a load created, the last first \u2014 DELETES (needs --target);
|
|
21
|
+
what the target runs as they go is named first, and takes --accept-automation
|
|
22
|
+
or --mute-automation; with --preview, say what it would delete, and delete
|
|
23
|
+
nothing
|
|
24
|
+
status what the store knows so far
|
|
25
|
+
|
|
26
|
+
Required:
|
|
27
|
+
--config <file> the project configuration, as the panel saves it (JSON)
|
|
28
|
+
|
|
29
|
+
Options:
|
|
30
|
+
--source <alias> sf CLI alias of the org the dataset is read from
|
|
31
|
+
--target <alias> sf CLI alias of the sandbox, or Developer Edition org, it is
|
|
32
|
+
loaded into
|
|
33
|
+
--author <name> who froze the dataset, for the manifest (default: sandforge)
|
|
34
|
+
--salt-file <file> the file holding the pseudonymization salt, when
|
|
35
|
+
SANDFORGE_FROZEN_SALT is not set
|
|
36
|
+
--store <file> where the run keeps its state (default: <sasDir>/cli-store.json)
|
|
37
|
+
--pilot load one root folder only
|
|
38
|
+
--reload replace the loads before: purge what earlier loads created,
|
|
39
|
+
then load again. Refused before anything is written when a
|
|
40
|
+
removal of those loads would leave records in the org \u2014
|
|
41
|
+
records changed since, kept for records that stay under them
|
|
42
|
+
(a contact made by hand since under one of their accounts,
|
|
43
|
+
which the org would delete along), of an object the user may
|
|
44
|
+
not delete, out of the user's sight or unread \u2014 or when one
|
|
45
|
+
of them was recorded before loads kept what they created: take
|
|
46
|
+
the load back with remove first (--include-changed takes what
|
|
47
|
+
changed since, and what was added under them since). Refused
|
|
48
|
+
the same way when the purge would have the org delete along a
|
|
49
|
+
record the reload finds again by its keys \u2014 a quote under the
|
|
50
|
+
opportunity an earlier load wrote: give that parent identity
|
|
51
|
+
keys too, or take the load back first. What the target's
|
|
52
|
+
automation likely made for a load holds nothing with --sweep,
|
|
53
|
+
which takes it first. What the target runs as the purge
|
|
54
|
+
deletes is read and named first, and nothing is written
|
|
55
|
+
while something fires unless --accept-automation or
|
|
56
|
+
--mute-automation answers it. The purge takes what those
|
|
57
|
+
loads created, not what the target's automation made for
|
|
58
|
+
them: --sweep takes that too. With --pilot, a reload purges
|
|
59
|
+
nothing, and is not asked
|
|
60
|
+
--gone-first <file> with load --reload --dry-run: the records taken back before
|
|
61
|
+
the reload runs, a JSON array of their ids \u2014 hanging from the
|
|
62
|
+
loads' records, they hold nothing. sandforge env gives it what
|
|
63
|
+
its apply takes back first; a reload that runs reads what is
|
|
64
|
+
still there
|
|
65
|
+
--max-total <n> with load: the most records it may insert \u2014 the count its dry
|
|
66
|
+
run gave. A load, or a reload, that would insert more is
|
|
67
|
+
refused before anything is written, the purge included; a dry
|
|
68
|
+
run says it would be, exit 1
|
|
69
|
+
--dry-run with load: say what the load would do \u2014 per object, what it
|
|
70
|
+
would insert, link, drop, rewrite and purge \u2014 and write nothing
|
|
71
|
+
--write-encrypted with load: write the fields the target encrypts as the dataset
|
|
72
|
+
holds them, though its manifest does not say its extraction
|
|
73
|
+
left out what it read masked \u2014 they may hold masks such as
|
|
74
|
+
****1234 (left out otherwise, each named)
|
|
75
|
+
--mute-automation with load or remove: mute the target's automation for that
|
|
76
|
+
step through its own bypass \u2014 assign the user it writes as,
|
|
77
|
+
for the step alone, the permission sets holding the custom
|
|
78
|
+
permissions its flows, processes and workflow rules test to
|
|
79
|
+
stay quiet, those of what --sweep deletes included, and take
|
|
80
|
+
them back as it ends; what no bypass keeps quiet still runs,
|
|
81
|
+
and is named, and a load or a removal then needs
|
|
82
|
+
--accept-automation.
|
|
83
|
+
Refused on a production org and for a user who cannot assign
|
|
84
|
+
permission sets, exit 1; with --dry-run or --preview, says
|
|
85
|
+
what would be muted and assigns nothing
|
|
86
|
+
--accept-automation with load: write although the target runs flows, Apex
|
|
87
|
+
triggers, processes or workflow rules as the load inserts
|
|
88
|
+
its records and updates them \u2014 what --mute-automation
|
|
89
|
+
keeps quiet and a bypass the user holds aside \u2014 or could
|
|
90
|
+
not say what it runs; with remove, or load --reload:
|
|
91
|
+
delete although it runs them as the records go, those
|
|
92
|
+
--sweep deletes included \u2014 before or after a delete, or
|
|
93
|
+
as an activated order is set back to Draft for its
|
|
94
|
+
delete. Each is named before anything is written or
|
|
95
|
+
deleted; without the flag the load or the reload writes
|
|
96
|
+
nothing (AUTOMATION_NOT_ACCEPTED), the removal deletes
|
|
97
|
+
nothing, exit 1; --dry-run says so
|
|
98
|
+
--accept-emails with load: write although the target delivers every email
|
|
99
|
+
what still runs sends as the records go in, a reload's
|
|
100
|
+
purge and sweep included (Setup > Deliverability: All
|
|
101
|
+
email), or would not say whether it does: without it
|
|
102
|
+
such a load is refused, exit 1 (EMAILS_NOT_ACCEPTED),
|
|
103
|
+
nothing written. Read only when something that still
|
|
104
|
+
runs sends one, with one line of anonymous Apex that
|
|
105
|
+
sends nothing; on System email only or No access it is
|
|
106
|
+
not needed. The emails are counted too, on the records
|
|
107
|
+
of the dataset, at most, against what the target has
|
|
108
|
+
left today: past it, the load is refused whatever the
|
|
109
|
+
flag, exit 1 (FROZEN_EMAILS_EXCEEDED). --mute-automation
|
|
110
|
+
keeps quiet what tests the org's bypass; what an Apex
|
|
111
|
+
trigger sends is read nowhere. --dry-run says it all,
|
|
112
|
+
and what a load would be refused for
|
|
113
|
+
${ct({run:"the load",simulation:"--dry-run",step:"with load: ",note:["Taken by this command once the load may write, before","the load's lease; deleted when the load is refused before","it writes or reports it wrote nothing, and kept when it","stops or fails part way: what it wrote then is not told","here."]})}
|
|
114
|
+
--include-changed remove also the records changed since the load, and what
|
|
115
|
+
was added to them since (kept otherwise); with load
|
|
116
|
+
--reload --sweep, the sweep of each load replaced takes
|
|
117
|
+
too what it finds changed since that load, which it
|
|
118
|
+
keeps and names otherwise, the load kept recorded for
|
|
119
|
+
a later sweep, and the reload no partial for them
|
|
120
|
+
--sweep with remove: before the load's records go, delete too what
|
|
121
|
+
the target's automation made for the load, that the
|
|
122
|
+
load's mapping does not hold: what the load's user
|
|
123
|
+
created under the load's records, what they point at,
|
|
124
|
+
or what hangs from those, three links at most, at most
|
|
125
|
+
a minute after the record it is tied to \u2014 in the
|
|
126
|
+
objects the load wrote and their children, tasks,
|
|
127
|
+
events, feed, email messages, notes, case comments, and
|
|
128
|
+
the objects the target's flows create; the window is
|
|
129
|
+
the load's writes, from a second before the first to a
|
|
130
|
+
minute after the last. What a record of the load points
|
|
131
|
+
at by a lookup the org refuses the delete for goes once
|
|
132
|
+
that record is gone. Listed and kept: what is tied to
|
|
133
|
+
the load but came later, up to 15 minutes, or as the
|
|
134
|
+
org's Automated Process user; and what the load's user
|
|
135
|
+
created in the window tied to nothing of it. Such
|
|
136
|
+
records then keep none of the load's records as records
|
|
137
|
+
that stay. A sweep refused, or that did not take all it was
|
|
138
|
+
asked to, exits 3, and ends partial a removal that took
|
|
139
|
+
every record of the load; one that left records of its own
|
|
140
|
+
keeps its own status. Once the load's records went already,
|
|
141
|
+
the sweep runs alone, the way to take what such a sweep
|
|
142
|
+
left (off otherwise). It sweeps too, each in its own
|
|
143
|
+
window, every other load recorded whose records went \u2014 a
|
|
144
|
+
load a reload replaced, kept for what its sweep left \u2014,
|
|
145
|
+
and lets it go once that sweep took all it found. With
|
|
146
|
+
load --reload: the sweep of each load the reload
|
|
147
|
+
replaces, as its removal sweeps it, around the purge;
|
|
148
|
+
what the target runs as it deletes is named once it has
|
|
149
|
+
read what it takes, before the first delete, and
|
|
150
|
+
answered as the purge's; with --dry-run, it lists what
|
|
151
|
+
it would take. One refused, or that did not take all it
|
|
152
|
+
was asked to, exits 3
|
|
153
|
+
--sweep-late with --sweep: take too what it lists as made late; with
|
|
154
|
+
--sweep-list, say what it would take
|
|
155
|
+
--sweep-untied with --sweep: take too what it lists as tied to nothing of
|
|
156
|
+
the load; with --sweep-list, say what it would take;
|
|
157
|
+
refused when another run wrote to the target
|
|
158
|
+
in the window \u2014 a load swept with it is none, a load
|
|
159
|
+
this command ran from another sas into the org is one
|
|
160
|
+
\u2014, or when that user created records in the window on
|
|
161
|
+
objects neither the load nor the automation reaches
|
|
162
|
+
(hand work, likely)
|
|
163
|
+
--sweep-list with remove: list what --sweep would delete, per object
|
|
164
|
+
with a few names and how many it ties to the load, and
|
|
165
|
+
for each other load it sweeps with it, and delete nothing;
|
|
166
|
+
exit 3 when it says a sweep is refused, as --sweep would
|
|
167
|
+
--preview with remove: say what the removal would do, per object \u2014 the
|
|
168
|
+
records it would delete, those it would keep as changed since
|
|
169
|
+
the load and who changed them, those gone already, those it
|
|
170
|
+
cannot see, and those it would leave because the user may not
|
|
171
|
+
delete them \u2014 what the target runs as they go, and what it
|
|
172
|
+
would be refused for, that automation without
|
|
173
|
+
--accept-automation included. It deletes nothing, writes
|
|
174
|
+
nothing to the sas and asks nothing; it exits 0 once it has
|
|
175
|
+
said it. It cannot know what hangs from the records, which a
|
|
176
|
+
removal reads at each object's turn. With --sweep, it lists
|
|
177
|
+
what the sweep would take, and reads what fires on it with
|
|
178
|
+
the load's own. Not with --sweep-list
|
|
179
|
+
--yes do not ask before a load writes or a removal deletes: a
|
|
180
|
+
removal asks last, once what it deletes and what the
|
|
181
|
+
target runs as they go are said. Without it, a step
|
|
182
|
+
with no terminal to answer the question \u2014 a CI step \u2014
|
|
183
|
+
stops there, exit 2, and writes nothing
|
|
184
|
+
--json emit what the panel would receive, every other line on
|
|
185
|
+
stderr; a step that ends before its request, refused or
|
|
186
|
+
with nothing to do, says "ended": true. Beside it, "step";
|
|
187
|
+
"dataset" \u2014 its folder, its digest (sha256 of the files a load
|
|
188
|
+
reads, the manifest less the verdict a verification writes
|
|
189
|
+
into it) and its version \u2014 for extract, load and verify;
|
|
190
|
+
"mapping", the file in the sas naming the records the loads
|
|
191
|
+
into the target created, for load, verify and remove; per
|
|
192
|
+
object, what the step counted ("objects"); how a load or a
|
|
193
|
+
removal ended ("status"); verify's verdict, and a load's, per
|
|
194
|
+
object ("verdict"); what a dry run or a
|
|
195
|
+
removal's preview would be refused for ("refusals"), with the
|
|
196
|
+
code of each ("refusalCodes"), as its line names it: a load
|
|
197
|
+
would be refused (CODE): ..., a removal would be refused
|
|
198
|
+
(CODE): ...; and what refused a load before it wrote \u2014 what
|
|
199
|
+
runs as it writes, its purge, its checkpoint, its emails or
|
|
200
|
+
its mute \u2014 or a removal
|
|
201
|
+
before its first delete \u2014 what fires as it deletes, its mute
|
|
202
|
+
or Production Guard \u2014 ("refused": {"code", "message"}), as
|
|
203
|
+
its line names it: refused (CODE): ...
|
|
204
|
+
--help this text
|
|
205
|
+
|
|
206
|
+
The salt that makes pseudonyms repeatable is read from SANDFORGE_FROZEN_SALT,
|
|
207
|
+
or else from --salt-file, and never made up here: an extraction without one is
|
|
208
|
+
refused. The editor keeps its own in VS Code's secret storage; copy it from there
|
|
209
|
+
with "SandForge: Copy Frozen Dataset Salt" to extract the same pseudonyms.
|
|
210
|
+
|
|
211
|
+
The graph a selection or an extraction discovers is kept in the sas
|
|
212
|
+
(discovery.json) and reused by the next one while the source's schema has not
|
|
213
|
+
changed and a day has not gone by: each says "graph reused from <step>" or
|
|
214
|
+
"rediscovered: <why>".
|
|
215
|
+
|
|
216
|
+
Ctrl-C stops a step after the call under way, a load recorded in the sas with
|
|
217
|
+
what it wrote, which remove takes back; a SIGTERM \u2014 a CI job cancelled or timed
|
|
218
|
+
out \u2014 or a SIGHUP stops it the same way. Ctrl-C again ends it at once.
|
|
219
|
+
|
|
220
|
+
Exit codes: 0 the step finished \u2014 a removal with nothing to take included, and a
|
|
221
|
+
removal's preview once said, its refusals included \u2014, and verify's verdict is
|
|
222
|
+
PASSED; 1 it failed or could not start, verify's verdict is FAILED, a dry run says
|
|
223
|
+
the load would be refused, a load was refused before it wrote for what the target
|
|
224
|
+
runs as it writes (AUTOMATION_NOT_ACCEPTED without --accept-automation) or for its
|
|
225
|
+
emails (EMAILS_NOT_ACCEPTED without --accept-emails, FROZEN_EMAILS_EXCEEDED), or a removal
|
|
226
|
+
stopped before its first delete at what the target runs, without
|
|
227
|
+
--accept-automation; 2 a bad command line, or a question with
|
|
228
|
+
no terminal to answer it (give --yes); 3 verify's verdict is PARTIAL, a load
|
|
229
|
+
completed with errors, the verification it runs after it was FAILED or PARTIAL, or
|
|
230
|
+
the sweep of a reload did not take all it was asked to, or a removal left records
|
|
231
|
+
of the load or its sweep did not take all it was asked to; 4 verify's verdict is
|
|
232
|
+
UNSTABLE: no two readings agreed; 130 Ctrl-C stopped the step, 143 a SIGTERM, 129 a
|
|
233
|
+
SIGHUP. A load is judged by its own report, which ends partial on a verification
|
|
234
|
+
FAILED or PARTIAL; one UNSTABLE is said, and the verify step gives it a code.
|
|
235
|
+
`,Mt=["select","extract","load","verify","remove","status"],lo={words:1,switches:["--pilot","--reload","--dry-run","--write-encrypted","--mute-automation","--accept-automation","--include-changed","--accept-emails","--sweep","--sweep-list",...$t,"--preview","--yes","--json",...$e.switches],values:["--config","--source","--target","--author","--salt-file","--store","--max-total","--gone-first",...$e.values]},Ut=1e6;function uo(o){let n;try{n=JSON.parse(de(o,"utf8"))}catch(e){process.stderr.write(`--gone-first: ${o} does not read: ${String(e)}
|
|
236
|
+
`),process.exit(2)}return(!Array.isArray(n)||!n.every(e=>typeof e=="string"&&/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(e)))&&(process.stderr.write(`--gone-first: ${o} holds no JSON array of record ids.
|
|
237
|
+
`),process.exit(2)),n}function co(o){let n=o.slice(2);(n.includes("--help")||n.includes("-h")||n.length===0)&&(process.stdout.write(io),process.exit(0));let e=d=>{let b=n.indexOf(d);return b>=0&&b+1<n.length?n[b+1]:void 0},r=n[0];Mt.includes(r)||(process.stderr.write(`The first word is the step: ${Mt.join(", ")} \u2014 not "${n[0]}".
|
|
238
|
+
`),process.exit(2)),Xe(n,lo);let t=e("--config");t||(process.stderr.write(`Missing --config. Run with --help.
|
|
239
|
+
`),process.exit(2));let s=e("--source"),i=e("--target");(r==="select"||r==="extract")&&!s&&(process.stderr.write(`${r} reads the source org: give --source.
|
|
240
|
+
`),process.exit(2)),(r==="load"||r==="verify"||r==="remove")&&!i&&(process.stderr.write(`${r} works on the target org: give --target.
|
|
241
|
+
`),process.exit(2)),n.includes("--sweep")&&n.includes("--sweep-list")&&(process.stderr.write(`--sweep deletes and --sweep-list only lists: give one of them. Run with --help.
|
|
242
|
+
`),process.exit(2)),n.includes("--sweep-list")&&r!=="remove"&&(process.stderr.write(`--sweep-list goes with remove${r==="load"?"; a reload lists what its sweep would take with --dry-run --sweep":""}. Run with --help.
|
|
243
|
+
`),process.exit(2)),n.includes("--sweep")&&r!=="remove"&&!(r==="load"&&n.includes("--reload")&&!n.includes("--pilot"))&&(process.stderr.write(`--sweep goes with remove or load --reload${r==="load"&&n.includes("--pilot")?", and a pilot purges nothing":""}. Run with --help.
|
|
244
|
+
`),process.exit(2)),n.includes("--include-changed")&&r!=="remove"&&!(r==="load"&&n.includes("--reload")&&n.includes("--sweep"))&&(process.stderr.write(`--include-changed goes with remove, or with load --reload --sweep, whose sweep then takes what changed since the loads it replaces. Run with --help.
|
|
245
|
+
`),process.exit(2)),n.includes("--gone-first")&&!(r==="load"&&n.includes("--reload")&&n.includes("--dry-run"))&&(process.stderr.write(`--gone-first goes with load --reload --dry-run. Run with --help.
|
|
246
|
+
`),process.exit(2));let l=e("--gone-first");n.includes("--gone-first")&&l===void 0&&(process.stderr.write(`--gone-first takes the file of the ids taken back first.
|
|
247
|
+
`),process.exit(2)),n.includes("--write-encrypted")&&r!=="load"&&(process.stderr.write(`--write-encrypted goes with load. Run with --help.
|
|
248
|
+
`),process.exit(2)),n.includes("--accept-emails")&&r!=="load"&&(process.stderr.write(`--accept-emails goes with load. Run with --help.
|
|
249
|
+
`),process.exit(2)),n.includes("--mute-automation")&&r!=="load"&&r!=="remove"&&(process.stderr.write(`--mute-automation goes with load or remove. Run with --help.
|
|
250
|
+
`),process.exit(2)),n.includes("--accept-automation")&&r!=="remove"&&r!=="load"&&(process.stderr.write(`--accept-automation goes with load or remove. Run with --help.
|
|
251
|
+
`),process.exit(2)),n.includes(ke)&&r!=="load"&&(process.stderr.write(`${ke} goes with load. Run with --help.
|
|
252
|
+
`),process.exit(2));let w=pt(n);n.includes("--preview")&&r!=="remove"&&(process.stderr.write(`--preview goes with remove${r==="load"?"; a load says what it would do with --dry-run":""}. Run with --help.
|
|
253
|
+
`),process.exit(2)),n.includes("--preview")&&n.includes("--sweep-list")&&(process.stderr.write(`--preview deletes nothing, and --sweep-list lists what a sweep would take: give --preview without it, or with --sweep. Run with --help.
|
|
254
|
+
`),process.exit(2));let p=Rt(n);"refusal"in p&&(process.stderr.write(`${p.refusal} Run with --help.
|
|
255
|
+
`),process.exit(2));let h;if(n.includes("--max-total")){let d=e("--max-total");h=Number(d),r!=="load"&&(process.stderr.write(`--max-total goes with load. Run with --help.
|
|
256
|
+
`),process.exit(2)),(d===void 0||!/^\d+$/.test(d)||h<1||h>Ut)&&(process.stderr.write(`--max-total takes a whole number from 1 to ${Ut}, not "${d??""}".
|
|
257
|
+
`),process.exit(2))}return{step:r,configPath:t,source:s,target:i,author:e("--author"),storePath:e("--store"),saltFile:e("--salt-file"),pilot:n.includes("--pilot"),reload:n.includes("--reload"),dryRun:n.includes("--dry-run"),writeEncrypted:n.includes("--write-encrypted"),muteAutomation:n.includes("--mute-automation"),acceptAutomation:n.includes("--accept-automation"),...w!==void 0?{checkpointFirst:w}:{},includeChanged:n.includes("--include-changed"),acceptEmails:n.includes("--accept-emails"),sweep:n.includes("--sweep"),sweepList:n.includes("--sweep-list"),...p,preview:n.includes("--preview"),...h!==void 0?{maxTotal:h}:{},...l!==void 0?{goneFirst:l}:{},yes:n.includes("--yes"),json:n.includes("--json")}}async function po(o){let e=(await o.query("SELECT Id, IsSandbox FROM Organization LIMIT 1")).records[0];if(!e)throw new Error("The org gave no Organization record.");if(e.IsSandbox)return{id:e.Id,orgType:"Sandbox"};try{let t=(await o.query("SELECT OrganizationType FROM Organization LIMIT 1")).records[0]?.OrganizationType;return typeof t=="string"&&t!==""?{id:e.Id,orgType:qe({isSandbox:!1,edition:t}),edition:t}:{id:e.Id,orgType:"Production"}}catch{return{id:e.Id,orgType:"Production"}}}async function Bt(o,n,e,r){let t=await Je(o),s=he(t),i;try{i=await po(s)}catch(l){let w=l instanceof Error?l.message:String(l);throw new Error(`Could not read the Organization record of '${o}': ${w}`)}return n.set(i.id,{org:{id:i.id,alias:o,orgType:i.orgType,metadata:{apiVersion:"66.0",...i.edition?{edition:i.edition}:{}}},credentials:{accessToken:t.accessToken,instanceUrl:t.instanceUrl}}),e?.set(i.id,s),r?.set(i.id,{session:t,typed:i}),i.id}function Le(o){return!o||o.length===0?[]:[`kept: the platform does not delete them \u2014 ${o.map(({objectApiName:e,count:r})=>`${e} (${r})`).join(", ")}`]}function Gt(o,n){let e=(o??[]).filter(t=>t.reason==="may-hold-masks");if(e.length===0)return[];let r=e.map(({objectApiName:t,field:s,affectedRecords:i})=>`${t}.${s} (${i})`).join(", ");return[`${n} out, encrypted in the target: ${r} \u2014 the dataset's manifest does not say its extraction left out what it read masked, so they may hold masks such as ****1234; --write-encrypted writes them as the dataset holds them`]}function fo(o,n){let e=o==="token"?"each record its own, from the token the value carries":`each record its own, its rank appended: the field is ${o==="unique"?"unique in the target":"the record name"}`;return n===void 0?e:`${e} (first: "${n}")`}function Ne(o){return o.created.reduce((n,e)=>n+e.count,0)}function ho(o){return{...o.includeChanged?{includeChanged:!0}:{},...o.sweep?{sweep:!0}:{},...o.sweepLate?{sweepLate:!0}:{},...o.sweepUntied?{sweepUntied:!0}:{},...o.muteAutomation?{muteAutomation:!0}:{}}}function Ee({read:o,steps:n,mute:e},r,t="removal",s){let i=e?q(e.muted,r).map(h=>` ${h}`):[];if(!("objects"in o)){let h=t!=="removal",d=t==="reloadSweep"?"this reload's sweep":h?`this reload's purge${s?" and its sweep":""}`:"this removal";return{lines:[`${h?"reload":"removal"} automation: what ${r} runs could not be read: ${o.unread}`,...i],refusal:`What ${r} runs as ${d} writes could not be read (${o.unread}), so what fires as the records go is not known. Nothing was written or deleted. Add --accept-automation to ${h?"reload":"remove"} all the same, or turn that automation off in ${r} first.`}}let l=e?.automation??o,w=s?Ve(n,s.delete??[]):n,p=at(l,r,{steps:n,...s?{sweep:s}:{},assign:nt(l,Ke(l,w)),mayMute:e===void 0&&Ae("--mute-automation"),subject:t});return{lines:[...st(o,r,n,t,s),...i],...p!==void 0?{refusal:p}:{}}}function mo(o,n){let e=Ne(o),r=o.earlier?"a load before the last one, whose records the loads after it left in place,":"the last load",t=`a removal deletes the ${e} record(s) it created, children first:`;return o.removed&&e===0?t=`its records were removed on ${o.removed.removedAt}, and none is left to remove`:e===0&&(o.keptByThePlatform?.length??0)>0?t="it created no record a removal takes":o.removed&&(t=`the removal of ${o.removed.removedAt} left ${e} of the records it created, and a removal deletes those, children first:`),[`${r} wrote to ${n} at ${o.loadedAt}; ${t}`,...o.created.map(s=>` ${s.objectApiName}: ${s.count}`),`${o.linked} record(s) it linked to or reused stay`,...Le(o.keptByThePlatform)]}function go(o,n){return o.recorded&&(Ne(o)>0||(n?.delete??[]).length>0)}function wo(o){return[o.deleted>0?`${o.deleted} deleted`:"",o.alreadyGone>0?`${o.alreadyGone} already gone`:"",o.keptChanged>0?`${o.keptChanged} kept, changed since the load`:"",o.keptDependents>0?`${o.keptDependents} kept for records that stay`+(o.heldBy.length>0?` (${o.heldBy.join(", ")})`:""):"",o.refused>0?`${o.refused} refused`:"",(o.notReached??0)>0?`${o.notReached} not reached`:""].filter(Boolean).join(", ")}function yo(o){let n=o.count>o.names.length?", \u2026":"";return`${o.count} file(s) attached to them stay in the org, as the load did not create them: ${o.names.join(", ")}${n}`}function Wt(o){return`graph: ${o.objects} object(s) at a cap of ${o.maxNodes}`+(o.objects>o.maxNodes?" (raised for the parents their records cannot be written without)":"")+(o.truncated?" \u2014 TRUNCATED: objects further out were not read":"")}function qt(o){return"reusedFrom"in o?`graph reused from ${o.reusedFrom} (discovered ${o.discoveredAt}): the source's schema has not changed since`:`rediscovered: ${o.rediscovered}`}function bo(o){switch(o.phase){case"discovery":return` discovery: ${o.objects??0} object(s) reached`;case"axis":return` listing the values of axis ${o.axis??"?"}\u2026`;case"combination":return` combination ${o.index??"?"}/${o.of??"?"}: ${o.combinationKey??"?"}`;case"candidate":return` candidate ${o.candidate??"?"}/${o.candidates??"?"} of ${o.combinationKey??"?"}: measuring its own records\u2026`;case"measure":return` measuring the ${o.roots??0} root(s) kept, together\u2026`}}function vo(o){let n=o.reason==="timeout"?"its time ran out":"it was cancelled",e=o.during==="axes"?"while it listed the axis values":o.during==="measure"?"while it measured the roots it kept":`while it probed ${o.combinationKey??"?"}`+(o.candidate!==void 0?`, candidate ${o.candidate} of ${o.candidates??"?"}`:"");return[`STOPPED: ${n} ${e}; the combinations decided before are kept`,...o.notProbed.length>0?[` never probed: ${o.notProbed.join(", ")}`]:[]]}var Ao=new Set(["NO_LOAD","ALREADY_REMOVED","NOTHING_TO_REMOVE"]),Qt="REMOVAL_DECLINED",Vt=["MUTE_PRODUCTION","MUTE_NO_RIGHT","MUTE_FAILED"],ko=new Map([["frozen:load:error",new Set(["EMAILS_NOT_ACCEPTED","FROZEN_EMAILS_EXCEEDED",ve,"AUTOMATION_NOT_ACCEPTED",ee.code,...Vt])],["frozen:remove:error",new Set(["AUTOMATION_NOT_ACCEPTED","GUARD_BLOCKED","GUARD_DECLINED",ee.code,...Vt])]]);function je(o){let n=o.payload?.code,e=ko.get(String(o.type??""));if(!(typeof n!="string"||e?.has(n)!==!0))return{code:n,message:String(o.payload?.message??"")}}function Fe(o){let n=String(o.type??"");if(!n.endsWith(":error")||n==="frozen:remove:automation:error")return!1;let e=String(o.payload?.code);return n==="frozen:remove:error"&&e===Qt?!1:!((n==="frozen:remove:error"||n==="frozen:remove:preview:error")&&Ao.has(e))}var Kt={passed:0,partial:3,unstable:4,failed:1};function $o(o,n,e){return async(r,t)=>{let s=Date.parse(t?.first??""),i=Math.max(s,Date.parse(t?.last??""));return!Number.isFinite(s)||!Number.isFinite(i)?[]:[...(await Ot({organizationId:r,alias:o,span:{from:s,to:i},own:{ids:[]},...n!==void 0?{journalDir:n}:{}})).map(({ids:w})=>({ids:w,from:s,to:i})),...Dt(It(n??K(),r),{sasMark:e,own:[]})]}}function Ro(o,n){return Ye(n.map(e=>{let r=e.payload??{};if(o==="verify"&&e.type==="frozen:verify:result"){let t=String(r.verdict?.status??"");return Object.prototype.hasOwnProperty.call(Kt,t)?Kt[t]:1}if(o==="load"&&e.type==="frozen:load:response"){let t=r.report;return t?.status==="completed"&&(t.sweeps??[]).every(s=>s.result.status==="success")?0:3}return o==="remove"&&e.type==="frozen:remove:response"?r.result?.status==="success"?0:3:0}))}function Ht(o,n){return bt(o.verdict==="unread"?{verdict:"unread",estimate:o.estimate,unread:o.unread??"not said"}:{verdict:o.verdict,estimate:o.estimate,remaining:o.remaining??0,max:o.max??0},n)}function Oo(o,n={}){let e=String(o.type??""),r=o.payload??{};if((e==="frozen:remove:error"||e==="frozen:remove:preview:error")&&!Fe(o))return[`nothing to remove: ${String(r.message??"")}`];if(e==="frozen:remove:error"&&!Fe(o))return[String(r.message??"")];if(e==="frozen:remove:automation:error")return[];if(e.endsWith(":error")){let t=e==="frozen:load:error"?r.sweeps??[]:[],s=e==="frozen:load:error"?r.emails:void 0,i=e==="frozen:load:error"?r.automation:void 0,l=e==="frozen:load:error"?r.mutedAutomation:void 0,w=je(o);return[...w?[]:[`! ${e}: ${String(r.message??"")}${r.code?` [${String(r.code)}]`:""}`],...i?ne(i,"the target"):[],...s?re(s,"the target"):[],...l?q(l,"the target"):[],...t.length>0?["before the load ended, its sweep had already done this:"]:[],...t.flatMap(({loadedAt:p,result:h})=>[`sweep of the load of ${p}:`,...X(h)]),...w?[Q(w)]:[]]}switch(e){case"frozen:select:progress":return[bo(r)];case"frozen:select:response":{let t=r.selection;return[`selected ${t.combinations.length} root(s): ${t.combinations.map(s=>s.combinationKey).join(", ")}`,...t.uncovered.map(s=>` uncovered ${s.combinationKey}: ${s.reason}`),...t.stopped?vo(t.stopped):[],...t.discovery?[qt(t.discovery)]:[],...t.graph?[Wt(t.graph)]:[],`volumetry ${t.volumetry.total} / ${t.volumetry.budgetMax} record(s)`+(t.volumetry.summed?" \u2014 each kept root's own records added up: they were not measured together":""),...Object.entries(t.volumetry.measured).filter(([,s])=>s>0).map(([s,i])=>` ${s}: ${i}`)]}case"frozen:control:result":{let t=r.report;return[`non-reidentification control: ${t.passed?"PASSED":"FAILED"}`,...t.checks.map(s=>` ${s.passed?"ok ":"FAIL"} ${s.name}`+(s.violations.length>0?` (${s.violations.length} violation(s))`:""))]}case"frozen:extract:response":{let t=r.manifest,s=r.discovery;return[`frozen ${String(r.recordCount)} record(s) as version ${t.version} in ${String(r.datasetDir)}`,...s?[qt(s)]:[],...t.coverage?[Wt(t.coverage)]:[],...t.coverage&&t.coverage.unboundedObjects.length>0?[`read without the time bound: ${t.coverage.unboundedObjects.join(", ")}`]:[],...(t.coverage?.leftToThePlatform??[]).map(i=>`${i.objectApiName}: ${i.note}`),...(t.coverage?.exclusionCosts??[]).map(i=>`${i.objectApiName}: ${i.note}`),...(t.coverage?.requiredLeftEmpty??[]).length>0?[`required in the source and left empty by the rules \u2014 a load will ask a value for each: ${(t.coverage?.requiredLeftEmpty??[]).join(", ")}`]:[],...(t.coverage?.keptWithoutARule??[]).length>0?["kept without a rule, the platform's own words: "+(t.coverage?.keptWithoutARule??[]).join(", ")]:[],...(t.coverage?.encryptedNotKept??[]).length>0?["not kept, encrypted and read masked: the user the source is read as lacks View Encrypted Data, and the masks are not copied: "+(t.coverage?.encryptedNotKept??[]).join(", ")]:[],...Object.entries(t.volumetry.measured).filter(([,i])=>i>0).map(([i,l])=>` ${i}: ${l}`)]}case"frozen:load:response":{let t=r.report,s=[`load: ${t.status} in ${t.durationMs}ms \u2014 ${t.alignment.excludedObjects.length} object(s) excluded, ${t.alignment.removals.length} field removal(s), ${t.alignment.recordTypeIssues.length} record type issue(s), ${t.placeholders.length} placeholder(s)`];for(let u of t.alignment.excludedObjects)s.push(` ${u.objectApiName}: not loaded \u2014 ${u.reason}`);s.push(...Gt(t.alignment.removals,"left"));for(let u of t.perObject){let R=u.writtenByThePlatform??0;s.push(` ${u.objectApiName}: ${u.inserted} inserted, ${u.reused} reused`+(R>0?` (${R} written by the platform with ${ge(u.objectApiName)})`:"")+`, ${u.skippedDuplicates.length} duplicate(s), ${u.failed.length} failed of ${u.fromFiles}`);let E=u.failed[0];E&&s.push(` first refusal: ${E.errors?.[0]??E.error??"?"}`)}for(let u of[...t.leftToThePlatform??[],...t.untypedFeedItems??[],...t.heldForExcludedParents??[],...t.quotesLeftUnsynced??[],...t.keysLeftEmpty??[]])s.push(` ${u.objectApiName}: ${u.note}`);let i=t.perObject.filter(u=>(u.writtenWithoutFields?.fields.length??0)>0);if(i.length>0){s.push(`written again without a field a validation rule or a restricted picklist refused (${i.length} object(s)):`);for(let{objectApiName:u,writtenWithoutFields:R}of i)for(let{field:E,refusedBy:z,reason:J,rows:V,replacedWith:M}of R?.fields??[]){let De=z==="restricted-picklist"?"a restricted picklist refused its value":"a validation rule refused it",le=M===void 0?"":` \u2014 written with "${M}", as its picklist rule declares`;s.push(` ${u}.${E} ${V} record(s) \u2014 ${De}${le} \u2014 ${J}`)}}s.push(`pass 2: ${t.pass2.resolved} resolved, ${t.pass2.unresolved.length} unresolved`);for(let u of t.pass2.unresolved.slice(0,5))s.push(` ${u.objectApiName}.${u.field}: ${u.detail}`);let l=t.personContact,w=l?.sent??[];if(l&&l.restored+w.length+l.unresolved.length>0){s.push(`person contacts: ${l.restored} linked, ${w.length} sent as contacts of their own, ${l.unresolved.length} not linked`);for(let u of w.slice(0,5))s.push(` ${u.contactReferenceId} sent: ${u.detail}`);for(let u of l.unresolved.slice(0,5))s.push(` ${u.contactReferenceId}: ${u.detail}`)}if(t.statuses&&t.statuses.restored+t.statuses.refused.length>0){s.push(`statuses applied after insert: ${t.statuses.restored}, refused ${t.statuses.refused.length}`);for(let u of t.statuses.refused.slice(0,5))s.push(` ${u.objectApiName} \u2192 ${u.status}: ${u.detail}`)}let p=u=>Object.values(u).reduce((R,E)=>R+E,0),h=p(t.purge.deleted),d=p(t.purge.deactivated??{});if(h+d+t.purge.failures.length>0){s.push(`purge of earlier loads: ${h} deleted, ${d} deactivated, ${t.purge.failures.length} failed`);for(let u of t.purge.failures.slice(0,5))s.push(` ${u.objectApiName}: ${u.errors[0]??"?"}`)}for(let[u,R]of Object.entries(t.purge.cameAlong??{}))s.push(` ${u}: took along ${R.count} record(s) the loads did not write that came with their records, made as they wrote: ${R.objects.join(", ")}`);let b=Object.entries(t.purge.leftUnrecorded??{});if(b.length>0){s.push("left in place, of a load recorded before loads kept what they created \u2014 it may have linked them:");for(let[u,R]of b)s.push(` ${u}: ${R}`)}let k=Object.entries(t.purge.keptByThePlatform??{});if(k.length>0){s.push("kept by the purge, the platform does not delete them:");for(let[u,R]of k)s.push(` ${u}: ${R}`)}for(let u of r.report.sweeps??[]){s.push(`sweep of the load of ${u.loadedAt}:`,...X(u.result));let R=u.result.objects.reduce((E,z)=>E+z.keptChanged,0);R>0&&s.push(` ${R} record(s) kept, changed since that load: load --reload --sweep --include-changed, or remove --sweep --include-changed, takes them`)}let N=r.report.mutedAutomation;N&&s.push(...q(N,"the target"));let a=r.report.automation;a&&s.push(...ne(a,"the target"));let y=r.report.emails;y&&s.push(...re(y,"the target"));let O=r.report.apiRequests;return O&&s.push(Ht(O,"the target")),s.push(...Yt(r.report.recordTypesGiven,!1)),s}case"frozen:load:preview:response":{let t=r.plan,s=a=>t.perObject.reduce((y,O)=>y+a(O),0),i=[`dry run${t.mode.pilot?" (pilot)":""}${t.mode.reload?" (reload)":""}: ${s(a=>a.toInsert)} record(s) to insert, ${s(a=>a.reusedByKeys+a.reusedFromCatalog+(a.writtenByThePlatform??0))} to link, ${s(a=>a.notSent)} not sent`+(t.mode.reload?`, ${s(a=>a.toPurge)} to purge and ${s(a=>a.toDeactivate)} to deactivate of ${t.earlierLoads} earlier load(s)`:"")+" \u2014 nothing written"];for(let a of t.perObject){let y=[`${a.toInsert} to insert`,a.reusedByKeys>0?`${a.reusedByKeys} found by identity keys`:"",a.reusedFromCatalog>0?`${a.reusedFromCatalog} found in the catalog`:"",(a.writtenByThePlatform??0)>0?`${a.writtenByThePlatform} to link (written by the platform with ${ge(a.objectApiName)})`:"",a.fieldsDropped>0?`${a.fieldsDropped} field(s) dropped`:"",a.picklistsRewritten>0?`${a.picklistsRewritten} picklist value(s) rewritten`:"",a.notSent>0?`${a.notSent} not sent`:"",a.toPurge>0?`${a.toPurge} to purge`:"",a.toDeactivate>0?`${a.toDeactivate} to deactivate`:""].filter(Boolean);i.push(` ${a.objectApiName}: ${y.join(", ")} of ${a.fromFiles}`)}for(let a of t.excludedObjects)i.push(` ${a.objectApiName}: not loaded \u2014 ${a.reason}`);i.push(...Gt(t.removals,"would leave"));for(let a of[...t.heldForExcludedParents??[],...t.quotesLeftUnsynced??[],...t.keysLeftEmpty??[]])i.push(` ${a.objectApiName}: ${a.note}`);for(let a of t.placeholders)i.push(`placeholder for ${a.objectApiName}.${a.field}: ${a.affectedRecords} record(s)`);for(let a of t.requiredDefaults)i.push(`default for ${a.objectApiName}.${a.field}: ${a.affectedRecords} record(s)`+(a.perRecord?`, ${fo(a.perRecord,a.example)}`:""));t.personContacts>0&&i.push(`${t.personContacts} person account contact(s) go in with their account, not counted above`);let l=Object.entries(t.leftUnrecorded??{});if(l.length>0){i.push("left in place, of a load recorded before loads kept what they created \u2014 it may have linked them:");for(let[a,y]of l)i.push(` ${a}: ${y}`)}let w=Object.entries(t.keptByThePlatform??{});if(w.length>0){i.push("left in place by the purge, the platform does not delete them:");for(let[a,y]of w)i.push(` ${a}: ${y}`)}let p=a=>` ${a.name}${a.field?` (${a.field})`:""}${a.message?` \u2014 ${a.message}`:""}`,h=t.perObject.filter(a=>(a.validationRules?.length??0)>0);for(let a of h){i.push(`${a.objectApiName}: ${a.validationRules?.length??0} active validation rule(s) of the target, which a preview cannot evaluate \u2014 a record one of them refuses is counted to insert:`);for(let y of a.validationRules??[])i.push(p(y))}for(let a of t.perObject){let y=a.lookupFilters??[];y.length!==0&&i.push(`${a.objectApiName}: ${y.length} lookup filter(s) of the target, which a preview cannot check \u2014 a record whose lookup it refuses is refused, and what hangs from it: `+y.map(O=>`${O.field} (${O.referenceTo.join(" or ")}, ${O.records} record(s))`).join(", "))}for(let a of t.perObject){let y=a.validationRulesOnChange??[];y.length!==0&&i.push(`${a.objectApiName}: ${y.length} rule(s) left out \u2014 their formula holds only on a change of a record (ISCHANGED, PRIORVALUE, NOT(ISNEW())), which an insert never is: `+y.join(", "))}let d=new Map(t.placeholders.filter(a=>(a.validationRules?.length??0)>0).map(a=>[a.placeholderObjectApiName,a.validationRules??[]]));for(let[a,y]of d){i.push(`placeholder of ${a}: ${y.length} active validation rule(s) of the target, which a preview cannot evaluate \u2014 a placeholder one of them refuses stops the load:`);for(let O of y)i.push(p(O))}t.validationRulesUnread&&i.push(`the target's validation rules could not be listed (${t.validationRulesUnread}): any of them may refuse a record counted to insert`);let b=r.plan.automation;b&&i.push(...ne(b,"the target"));let k=r.plan.emails;k&&i.push(...re(k,"the target"));let N=r.plan.apiRequests;return N&&i.push(Ht(N,"the target")),i}case"frozen:verify:result":{let t=r.verdict;return[`verification: ${t.status.toUpperCase()}`,...t.checks.map(s=>` ${s.passed?"ok ":"FAIL"} ${s.name}: ${s.detail}`)]}case"frozen:remove:response":{let t=r.result,s=[...new Set(t.objects.flatMap(l=>l.unchecked))],i=t.sweep!==void 0&&t.objects.length===0;return[...t.sweep?X(t.sweep):[],...(t.otherLoadSweeps??[]).flatMap(({loadedAt:l,result:w})=>[`sweep of the load of ${l}:`,...X(w)]),...i?[]:[`removal: ${t.status.toUpperCase()}`+(t.leftBy?` \u2014 of what the removal of ${t.leftBy} left`:"")],...t.objects.flatMap(l=>[` ${l.objectApiName}: ${wo(l)||"nothing"} of ${l.planned}${Oe(l)}`,...vt(l,"load"),...l.reasons.map(w=>` ${w}`),...l.filesLeft&&l.filesLeft.count>0?[` ${yo(l.filesLeft)}`]:[]]),...s.length>0?[`not checked, deleted with their parent: ${s.join(", ")}`]:[],...Le(t.keptByThePlatform),...kt(t.objects,{sweep:t.sweep!==void 0}),...t.mutedAutomation?q(t.mutedAutomation,"the target"):[]]}case"frozen:remove:sweep:response":{let t=r.loads;if(t)return t.flatMap(({loadedAt:i,listing:l})=>[`sweep of the load of ${i}:`,...oe(l,"the target org",n,!0)]);let s=r.otherLoads??[];return s.length>0?[{loadedAt:String(r.loadedAt),listing:r.listing},...s].flatMap(({loadedAt:i,listing:l})=>[`sweep of the load of ${i}:`,...oe(l,"the target org",n,!0)]):oe(r.listing,"the target org",n,!0)}case"frozen:remove:preview:response":return Eo(r.preview);case"frozen:status:response":return[JSON.stringify(r.status,null,2)];default:return[]}}var So="not read by a preview: what hangs from the records, which a removal reads at each object's turn \u2014 a record kept for records that stay is counted with those to delete \u2014 nor what the target's automation does as they go";function Eo(o){let n=t=>o.userNames[t]??t,e=["preview: what a removal would do; nothing was deleted"+(o.leftBy?` \u2014 of what the removal of ${o.leftBy} left`:"")];for(let t of o.objects){let s=[t.toDelete>0?`${t.toDelete} to delete`:"",o.includeChanged&&t.changedSince>0?`${t.changedSince} of them changed since the load`:"",t.alreadyGone>0?`${t.alreadyGone} gone already`:"",t.notVisible>0?`${t.notVisible} not visible`:"",t.keptChanged>0?`${t.keptChanged} kept, changed since the load`:"",t.undeletable>0?`${t.undeletable} left, the user may not delete them`:"",t.unread>0?`${t.unread} left, not read`:""].filter(Boolean);e.push(` ${t.objectApiName}: ${s.join(", ")||"nothing"} of ${t.planned}${Oe(t)}`);let i=Object.entries(t.changedBy).sort((l,w)=>w[1]-l[1]);i.length>0&&e.push(` last changed by: ${i.map(([l,w])=>`${n(l)} ${w}`).join(" \xB7 ")}`);for(let l of t.reasons)e.push(` ${l}`)}e.push(...Le(o.keptByThePlatform));let r=o.refusalCodes;return o.refusals.forEach((t,s)=>{e.push(r?.length===o.refusals.length?Y({code:r[s],message:t},"a removal"):`a removal would be refused: ${t}`)}),e.push(So),e}async function To(o){let n=_(o,"manifest.json");if(Ce(n))try{let e=await Tt(o),{version:r}=JSON.parse(de(n,"utf8"));return{dir:o,digest:e,...typeof r=="string"?{version:r}:{}}}catch{return}}function Co(o,n){let e=_(o,Ct(n)),r=_(o,"referenceid-mapping.json");return!Ce(e)&&Ce(r)?r:e}function Xt(o){return{status:o.status.toUpperCase(),objects:(o.objects??[]).map(({status:n,...e})=>({...e,verdict:n==="passed"?"PASSED":"FAILED"}))}}async function jo(o,n,e){let r=p=>n.filter(h=>h.type===p).at(-1)?.payload,t=e.targetOrgId?Co(e.sasDir,e.targetOrgId):void 0,s={tool:"sandforge-frozen",step:o,posted:n},i=[],l=[],w=async p=>{let h=await To(p);h&&(s.dataset=h)};switch(o){case"extract":{let p=r("frozen:extract:response");if(!p)break;await w(typeof p.datasetDir=="string"?p.datasetDir:e.datasetDir);let h=p.manifest?.volumetry?.measured??{};s.objects=Object.entries(h).filter(([,d])=>d>0).map(([d,b])=>({objectApiName:d,records:b}));break}case"load":{await w(e.datasetDir);let p=r("frozen:load:response")?.report,h=r("frozen:load:preview:response")?.plan,d=p?p.recordTypesGiven:h?.recordTypesGiven;d&&(s.recordTypesGiven=d),p?(s.mapping=p.mappingPath,s.objects=p.perObject.map(k=>({objectApiName:k.objectApiName,fromFiles:k.fromFiles,inserted:k.inserted,reused:k.reused,duplicates:k.skippedDuplicates.length,failed:k.failed.length}))):h&&(t&&(s.mapping=t),s.objects=h.perObject.map(k=>({objectApiName:k.objectApiName,fromFiles:k.fromFiles,toInsert:k.toInsert,toLink:k.reusedByKeys+k.reusedFromCatalog+(k.writtenByThePlatform??0),notSent:k.notSent,toPurge:k.toPurge,toDeactivate:k.toDeactivate}))),p&&(s.status=p.status),!p&&r("frozen:load:error")?.code==="LOAD_CANCELLED"&&(s.status="cancelled",t&&(s.mapping=t));let b=r("frozen:verify:result")?.verdict;b&&(s.verdict=Xt(b));break}case"verify":{let p=r("frozen:verify:result")?.verdict;await w(p?.manifestPath?so(p.manifestPath):e.datasetDir),t&&(s.mapping=t),p&&(s.verdict=Xt(p));break}case"remove":{t&&(s.mapping=t);let p=r("frozen:remove:response")?.result,h=r("frozen:remove:preview:response")?.preview;p?(s.status=p.status,p.mutedAutomation&&(s.mutedAutomation=p.mutedAutomation),s.objects=p.objects.map(d=>({objectApiName:d.objectApiName,planned:d.planned,deleted:d.deleted,alreadyGone:d.alreadyGone,keptChanged:d.keptChanged,keptDependents:d.keptDependents,refused:d.refused,notReached:d.notReached??0,notVisible:d.notVisible??0,...d.tookAlong?{tookAlong:d.tookAlong}:{},...d.cameAlong?{cameAlong:d.cameAlong}:{}})),s.includeChanged=p.includeChanged):h&&(s.preview=!0,s.includeChanged=h.includeChanged,s.objects=h.objects.map(d=>({objectApiName:d.objectApiName,planned:d.planned,toDelete:d.toDelete,alreadyGone:d.alreadyGone,changedSince:d.changedSince,keptChanged:d.keptChanged,undeletable:d.undeletable,notVisible:d.notVisible,unread:d.unread})),i.push(...h.refusals),h.refusalCodes?.length===h.refusals.length&&l.push(...h.refusalCodes));break}}return i.push(...e.refusals??[]),e.refusalCodes?.length===(e.refusals??[]).length&&l.push(...e.refusalCodes??[]),i.length>0&&(s.refusals=i),i.length>0&&l.length===i.length&&(s.refusalCodes=l),e.mute&&Object.assign(s,e.mute),e.checkpoint&&(s.checkpoint=e.checkpoint),s}async function Fo(o=process.argv){let n=Date.now(),e=co(o),r=f=>{process[e.json?"stderr":"stdout"].write(`${f}
|
|
258
|
+
`)},t=JSON.parse(de(e.configPath,"utf8")),s=typeof t.sasDir=="string"?t.sasDir:_(ao(),".sandforge-sas");ro(s,{recursive:!0});let i=it(e.storePath??_(s,"cli-store.json")),l=new Map,w=new Map,p=new Map,h=e.source?await Bt(e.source,l):void 0,d=e.target?await Bt(e.target,l,w,p):void 0,b=[],k=!1,N=!1,a=new xt({log:()=>{},broker:{postToWebview:f=>{if(f.type!=="frozen:load:progress"&&(b.push(f),Fe(f)&&(k=!0),!N))for(let m of Oo(f,e))r(m)}},orgManager:{getOrg:f=>l.get(f)?.org},orgRegistry:{getCredentials:async f=>l.get(f)?.credentials},configStore:i,infraServices:{productionGuard:Et(r,e.target??e.source??"the org"),piiDetector:new et},nextId:()=>`cli-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}),y=d?w.get(d):void 0,O=d?p.get(d):void 0,u=e.checkpointFirst&&O?ft({module:"frozen",operationId:`sandforge-frozen-load-${n}`,request:e.checkpointFirst,session:O.session,org:{id:O.typed.id,orgType:O.typed.orgType,...O.typed.edition!==void 0?{edition:O.typed.edition}:{}},connect:he,journalDir:K(),say:r}):void 0;y&&a.setTargetAutomation(H(y)),a.setMuteOffered(Ae("--mute-automation")),a.setSaltKeeper(Nt(process.env,e.saltFile)),e.target&&a.setOtherModuleRuns($o(e.target,void 0,Se(s)));let R=new _t;a.setRegistry(R);let E,z,J=!1,V=!1,M,le=Ze(f=>{if(M=f,process.stderr.write(`
|
|
259
|
+
interrupted: the ${e.step} stops after the call under way, and says what it wrote (Ctrl-C again ends it at once)
|
|
260
|
+
`),z){z.abort();return}for(let m of R.getRunning())R.abort(m.operationId);E&&R.cancelBeforeStart(E),(!E||V)&&process.exit(me(f))}),Pe=typeof t.datasetDir=="string"?t.datasetDir:_(s,"dataset"),P=[],U=f=>{P.push(f),r(Y(f,"a load"))},ue=[],S,Ie=!1,W,B,ce=async f=>{if(!e.json)return;let m=[...P,...ue],v=await jo(e.step,b,{datasetDir:Pe,sasDir:s,...d?{targetOrgId:d}:{},...m.length>0?{refusals:m.map(({message:g})=>g),refusalCodes:m.map(({code:g})=>g)}:{},...W?{mute:W}:{},...B?{checkpoint:B}:{}});process.stdout.write(`${JSON.stringify({...v,...S?{refused:S}:{},...f?{ended:f}:{}},null,2)}
|
|
261
|
+
`)},T=async(f,m)=>{let v=`cli-${f}-${Date.now()}`;E=v;try{return await a.handle({id:v,type:f,payload:m})}finally{E=void 0}},xe;try{xe=await to()}finally{le()}if(xe==="ended"&&!M){k&&(process.exitCode=1),await ce(!0);return}if(M){await ce(),process.stderr.write(`${J?ot:Po(e.preview?"preview":e.step,e.step!=="load"||e.dryRun||Te(b))}
|
|
262
|
+
`),process.exitCode=me(M);return}if(Qe(k||P.length>0?1:Ie?3:Ro(e.step,b)),e.json){await ce();return}r(`done in ${Date.now()-n}ms`);async function _e(f){await T("frozen:remove:automation",f);let m=G=>b.find(L=>L.type===G)?.payload,v=m("frozen:remove:automation:response"),g=Array.isArray(f.sweptObjects)?f.sweptObjects:[],$=v?.purge&&g.length>0?v.purge:void 0,c=v&&e.muteAutomation?y&&(e.preview||e.dryRun)?await ye(we(y),v.automation,{writes:Z(v.steps)}):be(v.automation,Z(v.steps)):void 0,A=c&&!("refused"in c)?c:void 0,{lines:j,refusal:F}=Ee({read:v?.automation??{unread:String(m("frozen:remove:automation:error")?.message)},steps:$??v?.steps??{},...A?{mute:{automation:A.automation,muted:A.planned}}:{}},e.target??"",f.reload===!0?"reload":"removal",$?{delete:g}:void 0);for(let G of j)r(G);let D=c&&"refused"in c?c.refused:F!==void 0&&!e.acceptAutomation?{code:"AUTOMATION_NOT_ACCEPTED",message:F}:void 0;return{...v?{steps:v.steps}:{},...A?{planned:A}:{},...D?{refusal:D.message,code:D.code}:{}}}function Me(f){S={code:te,message:f},P.push(S),r(Q(S)),k=!0}async function Ue(){return N=!0,await T("frozen:status",{}),N=!1,b.filter(m=>m.type==="frozen:status:response").at(-1)?.payload?.status?.loadRecords?.find(m=>m.orgId===d)}async function Be(f=[]){if(!e.reload||e.pilot)return;let m=await Ue();if(!(!m||m.created.length===0&&f.length===0))return _e({targetOrgId:d,loadedAt:m.loadedAt,reload:!0,...f.length>0?{sweptObjects:f}:{}})}async function Ge(){let f=await Ue();if(!f)return[];r(`reading what a sweep of ${e.target} would take for the loads a reload replaces\u2026`);let m=b.length;await T("frozen:remove:sweep",{targetOrgId:d,loadedAt:f.loadedAt,reload:!0});let v=b.slice(m);if(v.some($=>$.type==="frozen:remove:sweep:error"))return;let g=v.filter($=>$.type==="frozen:remove:sweep:response").at(-1)?.payload?.loads;return[...new Set((g??[]).flatMap(({listing:$})=>fe($,e)))]}async function eo(f){r(`reading what a sweep of ${e.target} would take\u2026`);let m=b.length;await T("frozen:remove:sweep",{targetOrgId:d,loadedAt:f});let v=b.slice(m);if(v.some(c=>c.type==="frozen:remove:sweep:error"))return;let g=v.filter(c=>c.type==="frozen:remove:sweep:response").at(-1)?.payload,$=[...g?.listing?[g.listing]:[],...(g?.otherLoads??[]).map(({listing:c})=>c)];return[...new Set($.flatMap(c=>fe(c,e)))]}async function to(){if(await T("frozen:config:save",{config:t}),k)return"ended";switch(e.step){case"select":r(`selecting from ${e.source}\u2026`),await T("frozen:select",{sourceOrgId:h});break;case"extract":r(`extracting from ${e.source}\u2026`),await T("frozen:extract",{sourceOrgId:h,...e.author?{author:e.author}:{}});break;case"load":{if(e.dryRun){r(`reading what a load into ${e.target}${e.pilot?" (pilot)":""} would do\u2026`),await T("frozen:load:preview",{targetOrgId:d,...e.pilot?{pilot:!0}:{},...e.reload?{reload:!0}:{},...e.goneFirst!==void 0?{goneFirst:uo(e.goneFirst)}:{},...e.writeEncrypted?{writeEncrypted:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{},...e.acceptEmails?{acceptEmails:!0}:{},...e.acceptAutomation?{acceptAutomation:!0}:{}});let c=b.find(C=>C.type==="frozen:load:preview:response")?.payload?.plan,A=c?Lt(Ft(c),e.maxTotal):void 0;A&&U({code:"MAX_RECORDS",message:A});let j=c?.automation?.refused;j&&U(j);let F=c?.emails?.refused;F&&U(F);let D=c?.apiRequests?.refused;D&&U(D);let G=(c&&e.sweep?await Ge():[])??[],L=c?await Be(G):void 0;L?.refusal!==void 0&&U({code:L.code??"AUTOMATION_NOT_ACCEPTED",message:L.refusal});let I;if(e.muteAutomation&&c&&y){I=await H(y).read(d,[...new Set([...c.perObject.map(x=>x.objectApiName),...L?.steps?.delete??[]])]);let C=await ye(we(y),I,{writes:Lo(L?.steps)});if("refused"in C)P.some(({message:x})=>x===C.refused.message)||U(C.refused);else{for(let x of q(C.planned,e.target??"the target"))r(x);W={mutedAutomation:C.planned,mutePlan:C.plan}}}for(let C of Yt(c?.recordTypesGiven,!0,(W?.mutePlan.assign.length??0)>0))r(C);let We=c?No(c):[];if(u&&c&&y&&We.length>0){I??=await H(y).read(d,c.perObject.map(pe=>pe.objectApiName)).catch(()=>{});let{estimate:C,refused:x}=await Zt(u,{written:We,running:Jt(I,W?.mutePlan)});if(C){B=C;for(let pe of Re(C))r(pe)}x!==void 0&&U({code:te,message:x})}break}let f=e.reload&&!e.pilot&&e.sweep?await Ge():[];if(f===void 0)return r("Nothing written."),"ended";let m=e.reload&&!e.pilot?await Be(f):void 0;if(m?.refusal!==void 0)return S={code:m.code??"AUTOMATION_NOT_ACCEPTED",message:m.refusal},P.push(S),r(Q(S)),k=!0,"ended";if(e.sweep&&(r("around the purge, a sweep deletes what the target's automation made for each load it replaces, as the load's user, tied to its records \u2014 run with --dry-run to see what"),a.setRemovalAsker(async c=>{let{lines:A,refusal:j}=Ee(c,e.target??"","reloadSweep");for(let F of A)r(F);if(!(j===void 0||e.acceptAutomation))return S={code:"AUTOMATION_NOT_ACCEPTED",message:j},P.push(S),S})),!e.yes&&!await dt(`Load the frozen dataset into ${e.target}${e.reload?`, purging first what earlier loads created${e.sweep?" and what the target's automation made for them":""}`:""}?`))return r("Nothing written."),"ended";let v;if(u&&y){let c=zo(Pe),A=await H(y).read(d,c).catch(()=>{}),j={written:c,running:Jt(A,e.muteAutomation&&A?be(A,ze).plan:void 0)},{estimate:F,refused:D}=await Zt(u,j);if(F){B=F;for(let I of Re(F))r(I)}if(D!==void 0||F===void 0)return Me(`${D??""} Nothing was written.`.trim()),"ended";z=new AbortController;let G=z.signal,L=await rt(()=>u.take(j,F,{signal:G})).finally(()=>{z=void 0});if("stop"in L)return L.stop.code!==te?(J=!0,"ended"):(Me(mt(L.stop)),"ended");v=L.checkpoint,B=v;for(let I of gt(v,e.target??"the target",e.muteAutomation))r(I)}r(`loading into ${e.target}${e.pilot?" (pilot)":""}\u2026`);let g=new Date().toISOString();await T("frozen:load",{targetOrgId:d,...e.pilot?{pilot:!0}:{},...e.reload?{reload:!0}:{},...e.writeEncrypted?{writeEncrypted:!0}:{},...e.maxTotal!==void 0?{maxRecords:e.maxTotal}:{},...e.muteAutomation?{muteAutomation:!0}:{},...e.sweep?{sweep:!0}:{},...e.sweepLate?{sweepLate:!0}:{},...e.sweepUntied?{sweepUntied:!0}:{},...e.sweep&&e.includeChanged?{includeChanged:!0}:{},...e.acceptEmails?{acceptEmails:!0}:{},...e.acceptAutomation?{acceptAutomation:!0}:{}});let $=b.filter(c=>c.type==="frozen:load:error").map(je).find(c=>c!==void 0);if($&&!S&&(S=$,P.push(S)),d&&Te(b)){let c=zt(await new jt(s,{orgId:d}).recorded().catch(()=>{}),g);try{Pt(K(),{organizationId:d,sas:Se(s),startedAt:g,endedAt:new Date().toISOString(),...c?{lastWriteAt:c}:{}})}catch(A){r(`warning: this load could not be added to ${K()}: another sas's sweep of ${e.target??""} will not see it (${A instanceof Error?A.message:String(A)})`)}}if(u&&v){let c=v;B=await u.settle(c,Te(b)).catch(A=>(r(`warning: the checkpoint '${c.name}' taken before the load could not be deleted (${A instanceof Error?A.message:String(A)}): delete it with ${ut("checkpoint")} delete --org ${e.target??""} --checkpoint `+c.checkpointId),c));for(let A of wt(B))r(A)}break}case"verify":r(`verifying ${e.target}\u2026`),await T("frozen:verify",{targetOrgId:d});break;case"remove":{N=!0,await T("frozen:status",{}),N=!1;let m=b.filter(g=>g.type==="frozen:status:response").at(-1)?.payload?.status?.loadRecords?.find(g=>g.orgId===d);if(!m)return r(`No load into ${e.target} is recorded in this sas: nothing to remove.`),"ended";if(e.preview){if(r(`reading what a removal from ${e.target} would do\u2026`),await T("frozen:remove:preview",{targetOrgId:d,loadedAt:m.loadedAt,...e.includeChanged?{includeChanged:!0}:{}}),b.some(g=>g.type==="frozen:remove:preview:response")){let g=e.sweep?await eo(m.loadedAt):[];if(g===void 0)break;let{planned:$,refusal:c,code:A}=await _e({targetOrgId:d,loadedAt:m.loadedAt,...g.length>0?{sweptObjects:g}:{}});if($&&(W={mutedAutomation:$.planned,mutePlan:$.plan}),c!==void 0){let j={code:A??"AUTOMATION_NOT_ACCEPTED",message:c};ue.push(j),r(Y(j,"a removal"))}}break}if(e.sweepList){r(`reading what a sweep of ${e.target} would take\u2026`),await T("frozen:remove:sweep",{targetOrgId:d,loadedAt:m.loadedAt});let g=b.filter($=>$.type==="frozen:remove:sweep:response").at(-1)?.payload;Ie=[g?.listing,...(g?.otherLoads??[]).map(({listing:$})=>$)].some($=>$?.refusal!==void 0);break}for(let g of mo(m,e.target??""))r(g);e.sweep&&r(`${Ne(m)>0?"before them, a sweep deletes":"a sweep alone deletes"} what the target's automation made for the load, as the load's user, tied to its records \u2014 run ${At("--sweep-list")} to see what`);let v=!1;if(a.setRemovalAsker(async g=>{let{lines:$,refusal:c}=Ee(g,e.target??"");for(let A of $)r(A);if(c!==void 0&&!e.acceptAutomation)return{message:c,code:"AUTOMATION_NOT_ACCEPTED"};if(!e.yes&&go(m,g.steps)){V=!0;let A=await lt(`Type ${e.target} to delete them:`);if(V=!1,A!==e.target)return v=!0,{message:"Nothing deleted.",code:Qt}}r(`removing from ${e.target}\u2026`)}),await T("frozen:remove",{targetOrgId:d,loadedAt:m.loadedAt,...ho(e)}),v)return"ended";S=b.filter(g=>g.type==="frozen:remove:error").map(je).find(g=>g!==void 0),S&&ue.push(S);break}case"status":await T("frozen:status",{});break}return"through"}}var ze=(o,n)=>n==="insert"||n==="update";function Lo(o){let n=o?Z(o):void 0;return(e,r)=>ze(e,r)||n?.(e,r)===!0}function Yt(o,n,e=!1){return St((o??[]).map(r=>({recordTypeGiven:r})),n,e)}function Jt(o,n){return{firing:o?He(o,n,ze).firing:[]}}function No(o){let n=[...o.perObject.filter(e=>e.toInsert>0||e.toPurge>0||e.toDeactivate>0).map(e=>e.objectApiName),...(o.placeholders??[]).map(e=>e.placeholderObjectApiName)];return[...new Set(n)]}function zo(o){try{let n=JSON.parse(de(_(o,"manifest.json"),"utf8")),e=Object.entries(n.volumetry?.measured??{}).filter(([,r])=>typeof r=="number"&&r>0).map(([r])=>r);if(e.length>0)return e}catch{}try{return no(_(o,"data")).filter(n=>n.endsWith(".json")).map(n=>n.slice(0,-5)).sort()}catch{return[]}}var Do=new Set(["INVALID_PAYLOAD","CONFIG_MISSING",ee.code,"REPLACE_LEAVES_RECORDS","MUTE_PRODUCTION","MUTE_NO_RIGHT","MUTE_FAILED","EMAILS_NOT_ACCEPTED","FROZEN_EMAILS_EXCEEDED","AUTOMATION_NOT_ACCEPTED",ve]);function Te(o){let n=s=>o.filter(i=>i.type===s).at(-1)?.payload,e=n("frozen:load:response")?.report;if(e){let s=i=>Object.values(i??{}).reduce((l,w)=>l+w,0);return e.perObject.some(i=>i.inserted>0)||(e.placeholders??[]).length>0||s(e.purge?.deleted)>0||s(e.purge?.deactivated)>0}let r=n("frozen:load:error"),t=r?.code;return typeof t=="string"&&Do.has(t)?!1:r?.written!==0}async function Zt(o,n){try{let e=await o.scope(n);return{estimate:e,...e.refusal!==void 0?{refused:ht(e.refusal)}:{}}}catch(e){return{refused:tt(e).replace(/ Nothing was written\.$/,"")}}}function Po(o,n=!0){return o==="load"&&!n?"interrupted: the load stopped before it created or purged a record: the sas is as it was, and `remove` has nothing of this load to take back":o==="load"?"interrupted: the load stopped before it was through; what it wrote is recorded in the sas and the audit trail, and `remove` takes it back":o==="remove"?"interrupted: the removal stopped before it was through; what it deleted is recorded, and `remove` again takes what it left":o==="preview"?"interrupted: the preview stopped before it was through, and deleted nothing":`interrupted: the ${o} stopped before it was through`}process.argv[1]?.includes("sandforge-frozen")&&(yt(),Fo().then(()=>process.exit(process.exitCode??0)).catch(o=>{process.stderr.write(`${o instanceof Error?o.message:String(o)}
|
|
263
|
+
`),process.exit(1)}));export{So as FROZEN_PREVIEW_UNREAD,$o as commandLineOtherRuns,zo as datasetObjectsOf,qt as discoveryLine,Fe as failsTheStep,jo as frozenAnswer,Po as frozenInterruptedLine,Te as frozenLoadWrote,Yt as frozenRecordTypeLines,Ro as frozenStepExit,uo as goneFirstIdsOf,Ht as loadApiRequestsLine,No as loadPlanWrites,Fo as main,Oo as messageLines,co as parseArgs,je as refusedFirstOf,ho as removalAsked,go as removalAsks,Ee as removalAutomation,mo as removalPlanLines,Eo as removalPreviewLines,bo as selectStepLine,po as typeOrg};
|
|
@@ -0,0 +1,40 @@
|
|
|
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 Y}from"./chunk-YS4G22C2.mjs";import{b as X}from"./chunk-SCKUIE3R.mjs";import"./chunk-QROPNEGY.mjs";import{a as Z,b as q,e as K}from"./chunk-BZ24IAP5.mjs";import{a as V,b as G,g as Q}from"./chunk-MTMH6H2A.mjs";import{bb as J,w as L}from"./chunk-B45CNPUX.mjs";import{A as o}from"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";import{readFileSync as Te}from"node:fs";import{join as Ee}from"node:path";import{createInterface as _e}from"node:readline";var S="2026-07-28",_=["2025-11-25","2025-06-18","2025-03-26"],E={version:"io.modelcontextprotocol/protocolVersion",capabilities:"io.modelcontextprotocol/clientCapabilities",serverInfo:"io.modelcontextprotocol/serverInfo"},f={parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603,unsupportedVersion:-32022},ee=60*6e4,te={name:"sandforge",title:"SandForge",version:String(JSON.parse(Te(Ee(__dirname,"..","package.json"),"utf8")).version??"0.0.0")},oe="SandForge's Seed, Forge's clone of a record, the removal of a run, the emptying of objects or of a whole org, Checkpoints and the environments of a sandforge.yaml, run from the sandforge npm package. Every org is named by its sf CLI alias, as `sf alias list` shows them. A tool that writes to an org takes confirm, the alias of that org exactly: give it only once the person using you has agreed to that write, after a dry run, a preview or a plan has said what it would do. The acceptances (acceptAutomation and the others) are theirs to give too. A production org is refused by every tool that writes to an org. Each answer carries the script's own JSON, its exit code and its lines.";function Ie(e={}){return Y({...e,relayedBy:"sandforge mcp"})}var Ne=Ie();function $e(e){let t=o.toJSONSchema(e);return delete t.$schema,t}function u(e){return{definition:{name:e.name,title:e.title,description:e.description,inputSchema:$e(e.args),annotations:{title:e.title,readOnlyHint:e.readOnly,...e.readOnly?{}:{destructiveHint:e.destructive===!0}}},...e.writes!==void 0?{writes:e.writes}:{},...e.readFirst!==void 0?{readFirst:e.readFirst}:{},flags:e.flags??{},named:e.named??{},exits:e.exits??{},read:t=>{let n=e.args.safeParse(t);if(!n.success)return{refusal:n.error.issues.map(w=>`${w.path.join(".")||"arguments"}: ${w.message}`).join("; ")};let s=n.data,c=e.writesTo?.(s),m=s.confirm;return{call:{...c!==void 0?{writesTo:c}:{},...typeof m=="string"?{confirm:m}:{},run:e.run(s),after:w=>e.after?.(s,w)??[]}}}}}var x=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,Pe=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,Ce=/^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$/,I=/^[^-\r\n][^\r\n]*$/,Fe=/^[a-z][a-z0-9-]{0,62}$/,p=e=>o.string().regex(G,'an sf CLI alias, or the username it stands for, not starting with "-"').describe(e),k=e=>o.string().max(255).describe(`The alias of ${e} again, exactly as given: the person using you agrees to this write. Without it, the call is refused before anything is read.`),$=e=>o.string().min(1).max(200).regex(I,'one line, not starting with "-"').describe(e),r=e=>o.boolean().optional().describe(e),ne=e=>o.strictObject({keepDays:o.number().int().min(L.min).max(L.max).optional().describe("The days it is kept on this machine; 0 until it is deleted (default 7)."),excluded:o.array(o.string().regex(x,"an object API name")).min(1).max(500).optional().describe("Objects to leave out of it, by API name, named in the answer: a rewind leaves their records as they are.")}).optional().describe(`Before ${e}'s first write, take a checkpoint of each object it writes, and of each the target's flows that still run create as it writes them, held whole: {} takes it with the defaults. Its cost is that of the tables, not of the records written, and its values stay unencrypted on this machine: give it only once the person using you has seen, in a dry run with it, what it would hold and cost. Refused, ${e} writes nothing; deleted again when it writes nothing.`);function re(e){return e===void 0?[]:["--checkpoint-first",...e.keepDays!==void 0?["--checkpoint-keep-days",String(e.keepDays)]:[],...(e.excluded??[]).flatMap(t=>["--checkpoint-exclude-object",t])]}var se=e=>r(`Keep quiet what the org runs as ${e} writes, through its own bypass: the permission sets holding it are assigned to the user it writes as, for the run alone, under a lease, and taken back as it ends; what no bypass keeps quiet still runs. A dry run with it says what it would assign, and assigns nothing. Refused on a production org and for a user who cannot assign permission sets. Only once the person using you has agreed to it.`),C=e=>r(`Keep quiet what the org runs as ${e} writes, through its own bypass: the permission sets holding it are assigned to the user it writes as, for ${e} alone, under a lease, and taken back as it ends; what no bypass keeps quiet still needs acceptAutomation. Refused on a production org and for a user who cannot assign permission sets. Only once the person using you has agreed to it.`);function ie(e){return`is no parameter of ${e}: an environment's acceptance of automation is its file's. Write accept: { automation: true } on the resource whose run it names, in the file, once the person using you has accepted what fires, then call ${e} again.`}var je={"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation","--accept-no-undo":"acceptNoUndo","--accept-recreate":"acceptRecreate","--accept-outside":"acceptOutside","--accept-unseen":"acceptUnseen"},De=Object.fromEntries(Object.entries(je).map(([e,t])=>[e,`is checkpoint_rewind's ${t}: true, on the rewind this preview is of. Give it only once the person using you has accepted what it lets through.`])),ae=()=>o.array(o.string().regex(x,"an object API name")).min(1).max(500).optional().describe("Limit the rewind to these objects of the checkpoint, by API name (default: every object). What they depend on is never added: the answer names it."),ce=/^em-\d{8}-\d{6}-[a-z0-9]{4}$/,de={objects:o.array(o.string().regex(x,"an object API name")).min(1).max(500).optional().describe("Empty these objects, by API name: every record of each. Not with wholeOrg."),wholeOrg:o.literal(!0).optional().describe("Empty every object people work in, less users, setup, Chatter, history, sharing, the org's flows, settings and definitions, and the standard price book. Not with objects."),excluded:o.array(o.string().regex(x,"an object API name")).min(1).max(500).optional().describe("With wholeOrg: objects to leave out, by API name."),customSettings:r("With wholeOrg: empty the custom settings too."),files:r("With wholeOrg: empty the files and attachments too."),managedPackages:r("With wholeOrg: empty the objects of managed packages too."),unrestorable:r("With wholeOrg: empty too, by passes of their own, the objects whose records Salesforce does not bring back from the recycle bin on their own. Only once the person using you has accepted that Undo cannot bring those back."),hardDelete:r("Delete for good, with what goes along: nothing goes to the recycle bin and no undo brings anything back. Needs the Bulk API Hard Delete permission of the user. Only once the person using you has accepted that nothing can be brought back."),checkpointFirst:r("Take a checkpoint of the objects emptied before the first delete, to rewind to."),acceptAutomation:r("Empty although the org runs flows, Apex triggers, processes or workflow rules as the records are deleted, or would not say what it runs."),acceptEmails:r("Empty although the org delivers every email what still runs as the records go sends, or would not say whether it does. acceptAutomation never stands for it. Only once the person using you has accepted that these emails go out."),muteAutomation:C("the emptying"),acceptNoUndo:r("Empty although some records go before a record they name, as Salesforce requires, so that Undo cannot bring them back once both have gone."),acceptPeopleActive:r("Empty although people other than the user changed records of these objects in the hour before the read, their work going with it: empty_preview says how many and each one's last change. It covers those the preview named, and taking up a run, whoever. Only once the person using you has accepted that their work goes.")};function le(e){return[e.objects,e.wholeOrg,e.resume].filter(n=>n!==void 0).length===1}function he(e){return[...e.objects!==void 0?["--objects",e.objects.join(",")]:[],...e.wholeOrg===!0?["--org"]:[],...(e.excluded??[]).flatMap(t=>["--exclude-object",t]),...e.customSettings===!0?["--custom-settings"]:[],...e.files===!0?["--files"]:[],...e.managedPackages===!0?["--managed-packages"]:[],...e.unrestorable===!0?["--unrestorable"]:[],...e.hardDelete===!0?["--hard-delete"]:[],...e.checkpointFirst===!0?["--checkpoint-first"]:[],...e.acceptNoUndo===!0?["--accept-no-undo"]:[]]}function M(e){return[...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[]]}var Re={"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},ue={...Re,"--accept-no-undo":"acceptNoUndo","--accept-people-active":"acceptPeopleActive"},pe={"--undo":"is empty_undo, with the run the line names: it brings back what that run deleted.","--resume":"is empty_run's resume, with the run the line names: it takes that run up."};function Le(e){if(typeof e!="object"||e===null)return[];let{result:t}=e;return typeof t?.runId=="string"&&t.runId!==""&&t.undo?.offered===!0?[`empty_undo with run "${t.runId}" brings back what it deleted while the recycle bin holds it, as long as no other emptying of the org follows.`]:[]}var U=()=>o.string().min(1).max(4096).regex(I,'one line, not starting with "-"').describe("The sandforge.yaml, by its path; a relative path is read from where the server was started.");function qe(e,t,n){let s=n===void 0?"gives no confirm":`gives confirm "${n}", which is not "${t}", the alias of the org it writes to`;return`${e.definition.name} writes to ${t}: it ${e.writes??"writes to the org"}. This call ${s}. `+(e.readFirst!==void 0?`Before it, ${e.readFirst}. `:"")+`Give confirm: "${t}" once the person using you has agreed to this write. Refused: nothing was read or written.`}function me(e,t){if(typeof t!="object"||t===null)return[];let{runFile:n,journal:s}=t,c=e==="seed"?n:s;return typeof c=="string"?[`run_remove with module "${e}" and run "${c}" takes this run back.`]:[]}function ge(e){if(typeof e!="object"||e===null)return[];let{checkpoint:t}=e;return t?.state==="taken"&&typeof t.checkpointId=="string"?[`checkpoint_rewind with checkpoint "${t.checkpointId}" returns the org to how it was before this run, and takes back what anyone did since on the objects it holds: checkpoint_preview says what it would do first.`]:[]}var Me={seed:"sandforge-seed",forge:"sandforge-clone",sync:"sandforge-sync"},F=[u({name:"seed_templates",title:"Seed templates",description:"The built-in Seed templates, as the Seed page's gallery lists them: id, name, what it is for, and the records each object gets at most. The first is the one a new Developer Edition holds whole. seed_run takes the id. Reads no org.",readOnly:!0,args:o.strictObject({}),run:()=>({local:We})}),u({name:"seed_run",title:"Seed an org",description:`Fill an org with records, from a Seed template (template, an id seed_templates gives) or with generated rows (objects), as sandforge seed --json does. Run it with dryRun: true first: it reads the org and writes nothing, and says what a real run would meet \u2014 the data storage it takes, the emails the org's automation would send, what runs as the records are created. Past the storage the org has left, it says the counts that fit; fit: "share" seeds them, the largest share of every count that fits, and fitWithinMB holds the run to fewer MB still. checkpointFirst takes a checkpoint of what the run writes before its first write, and a dry run says what it would hold and cost. dryRun: false writes, a production org refused, and needs confirm. acceptEmails lets it write although the org delivers every email what still runs sends, or would not say whether it does; muteAutomation keeps the org's automation quiet for the run through its own bypass, and a dry run with it says what it would assign. The answer names the run file, which run_remove with module "seed" takes the run back from, and the checkpoint it took, which checkpoint_rewind returns the org to.`,readOnly:!1,destructive:!1,args:o.strictObject({org:p("The org to fill: its sf CLI alias."),template:o.string().regex(Ce,"a template id, as seed_templates gives them").optional().describe("A built-in template, by the id seed_templates gives; or give objects."),objects:o.array(o.strictObject({objectApiName:o.string().regex(x,"an object API name"),count:o.number().int().min(1).max(1e5)})).min(1).max(50).optional().describe("Objects and how many records each gets, in insert order, their fields drawn by the faker; or give template."),dryRun:o.boolean().describe("true: read the org and say what a run would do, writing nothing."),fit:o.enum(["share"]).optional().describe('"share": seed the largest share of every count that fits the data storage the org has left, each object about that share of its records, a child no more than its parents kept hold, room kept for what its flows still running create. The answer says the counts, object by object; give it to a write only once the person using you has seen them in a dry run.'),fitWithinMB:o.number().min(.01).max(1e6).optional().describe("With fit: take no more than this many MB, whatever the org has left."),checkpointFirst:ne("the seed"),acceptEmails:r("Write although the org delivers every email of what still runs as the records go in, or would not say whether it does: only once the person using you has accepted that these emails go out."),muteAutomation:se("the seed"),confirm:k("org").optional()}).refine(e=>e.fitWithinMB===void 0||e.fit!==void 0,{message:'fitWithinMB goes with fit: "share"',path:["fitWithinMB"]}),writesTo:e=>e.dryRun?void 0:e.org,writes:"creates the records of the seed in it",readFirst:"a dry run of the same seed says what it would write and meet",flags:{"--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},after:(e,t)=>e.dryRun?[]:[...me("seed",t),...ge(t)],run:e=>({script:"sandforge-seed",args:["--target",e.org,...e.template!==void 0?["--template",e.template]:[],...(e.objects??[]).flatMap(t=>["--object",`${t.objectApiName}:${t.count}`]),...e.dryRun?["--dry-run"]:[],...e.fit!==void 0?["--fit",e.fit]:[],...e.fitWithinMB!==void 0?["--fit-within",String(e.fitWithinMB)]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...re(e.checkpointFirst),"--json"]})}),u({name:"clone_record",title:"Clone a record (Forge)",description:`Clone one record from source into target with the records it needs and the ones that hang from it, as Forge's record clone and sandforge clone --record --json do. Run it with dryRun: true first: it reads both orgs, counts what it would write and says what would stop a real run \u2014 the target's automation, its data storage, the emails its flows send \u2014 and writes nothing. dryRun: false writes into target, a sandbox or a Developer Edition only, and needs confirm, the alias of target. acceptAutomation lets it write although the target runs automation as the records go in; acceptEmails, although the target delivers every email what still runs sends, or would not say whether it does, which acceptAutomation never stands for. muteAutomation keeps what the target runs quiet for the clone through the target's own bypass; what no bypass keeps quiet still needs acceptAutomation. checkpointFirst takes a checkpoint of what the clone writes before its first write, and a dry run says what it would hold and cost. The answer names the run journal, which run_remove with module "forge" takes the run back from, and the checkpoint it took, which checkpoint_rewind returns the org to.`,readOnly:!1,destructive:!1,args:o.strictObject({source:p("The org to read from: its sf CLI alias."),target:p("The org to write into: its sf CLI alias."),recordId:o.string().regex(Pe,"a 15- or 18-character Salesforce record id").describe("The record to clone, in source."),depth:o.union([o.enum(["direct","full"]),o.number().int().min(1).max(10)]).optional().describe('How far from the record discovery goes: "direct", "full", or a number of hops (default 5).'),maxNodes:o.number().int().min(10).max(500).optional().describe("How many objects discovery may reach (default 50)."),dryRun:o.boolean().describe("true: read both orgs and say what a clone would do, writing nothing."),confirm:k("target").optional(),acceptAutomation:r("Write although the target runs flows, Apex triggers, processes or workflow rules as the records go in, or would not say what it runs: only once the person using you has accepted what the dry run named."),acceptEmails:r("Write although the target delivers every email of what still runs as the records go in, or would not say whether it does. acceptAutomation never stands for it. Only once the person using you has accepted that these emails go out."),muteAutomation:se("the clone"),checkpointFirst:ne("the clone")}),writesTo:e=>e.dryRun?void 0:e.target,writes:"creates the records of the clone in it",readFirst:"a dry run of the same clone says what it would write and meet",flags:{"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},after:(e,t)=>e.dryRun?[]:[...me("forge",t),...ge(t)],run:e=>({script:"sandforge-clone",args:["--record",e.recordId,"--source",e.source,"--target",e.target,...e.depth===void 0?[]:typeof e.depth=="number"?["--depth","custom","--custom-depth",String(e.depth)]:["--depth",e.depth],...e.maxNodes!==void 0?["--max-nodes",String(e.maxNodes)]:[],...e.dryRun?["--dry-run"]:[],...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...re(e.checkpointFirst),"--json"]})}),u({name:"run_remove",title:"Remove a run's records",description:`Delete from org, into its recycle bin, what one run of Seed (module "seed"), Forge (module "forge") or Sync (module "sync") created, as that script's --remove --json does; a Sync run also gives the records it wrote over their values back. run is the summary file the run's --json was saved to, its run file or journal, or, for Seed and Sync, its run id. Records changed since the run are kept, unless includeChanged. A production org is refused. Needs confirm, the alias of org. acceptAutomation lets it delete although the org runs automation as the records go; muteAutomation keeps that automation quiet for the removal through the org's own bypass. Where its user may not delete the records of some objects of the run, it stops before its first delete, unless leaveUndeletable. store, for a Sync run of a saved configuration, is that configuration's store, which the removal tells what it took.`,readOnly:!1,destructive:!0,args:o.strictObject({module:o.enum(["seed","forge","sync"]).describe("Which module made the run."),org:p("The org the run wrote to: its sf CLI alias."),run:o.string().min(1).max(4096).regex(I,'one line, not starting with "-"').describe("The run's summary file, its run file or journal, or (Seed, Sync) its run id; a relative path is read from where the server was started."),confirm:k("org").optional(),includeChanged:r("Take also the records changed since the run, and what was added to them since: on a shared sandbox, others' work. Only once the person using you has accepted it."),acceptAutomation:r("Delete although the org runs flows, Apex triggers, processes or workflow rules as the records go, or would not say what it runs: only once the person using you has accepted it."),muteAutomation:r("Keep quiet what the org runs as the records go, through its own bypass: the removal assigns the permission sets holding it to the user it deletes as, for the removal alone, under a lease, and takes them back as it ends; what no bypass keeps quiet still needs acceptAutomation. Refused on a production org and for a user who cannot assign permission sets. Only once the person using you has agreed to it."),leaveUndeletable:r("Where the user the alias connects as may not delete the records of some objects of the run, remove the rest and leave those, with the records they hang from; without it the removal stops before its first delete and names them. Only once the person using you has accepted it."),store:o.string().min(1).max(4096).regex(I,'one line, not starting with "-"').optional().describe(`module "sync" only: the directory the saved configuration the run was of is kept in, the run's --store, which the removal tells what it took, so that its next delta run reads those objects whole; a relative path is read from where the server was started. The person using you names it.`)}).refine(e=>e.store===void 0||e.module==="sync",{message:'store goes with module "sync": a Seed or Forge run keeps no configuration',path:["store"]}),writesTo:e=>e.org,writes:"deletes the records the run created, into the recycle bin",flags:{"--include-changed":"includeChanged","--accept-automation":"acceptAutomation","--mute-automation":"muteAutomation","--leave-undeletable":"leaveUndeletable"},named:{"--store":"is this tool's store: the directory of the run's saved configuration, as the person using you names it."},run:e=>({script:Me[e.module],args:["--remove",e.run,"--target",e.org,...e.includeChanged===!0?["--include-changed"]:[],...e.acceptAutomation===!0?["--accept-automation"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...e.leaveUndeletable===!0?["--leave-undeletable"]:[],...e.store!==void 0?["--store",e.store]:[],"--json"]})}),u({name:"checkpoint_list",title:"List checkpoints",description:"The checkpoints of org kept on this machine, newest first, with what a rewind and an undo can still reach. Reads this machine alone, and never contacts an org. Named org only: the other orgs' names and aliases never reach the agent.",readOnly:!0,args:o.strictObject({org:p("The org, by its sf CLI alias: its checkpoints alone.")}),run:e=>({script:"sandforge-checkpoint",args:["list","--org",e.org,"--json"]})}),u({name:"checkpoint_preview",title:"Preview a rewind",description:"What a rewind of org to a checkpoint would do: the records it would delete, give back and bring back, who last changed them, what the org runs as the rewind writes, the emails and API requests it takes, what neither a rewind nor its undo can take back, and the refusal a rewind would meet now. Given objects, those of a rewind limited to them, with what it would leave of them and the objects it needs added. Reads the org, writes nothing.",readOnly:!0,args:o.strictObject({org:p("The org: its sf CLI alias."),checkpoint:$("A checkpoint of it: its id, its name, or latest (the default).").optional(),objects:ae()}),named:De,run:e=>({script:"sandforge-checkpoint",args:["preview","--org",e.org,"--checkpoint",e.checkpoint??"latest",...(e.objects??[]).flatMap(t=>["--object",t]),"--json"]})}),u({name:"checkpoint_take",title:"Take a checkpoint",description:"Read org's records and keep them on this machine as a checkpoint, to rewind the org to later: every object people work in, or the objects named. estimate: true says the records, API requests, time and disk it would take, and keeps nothing. It writes nothing to the org; the checkpoint holds the records' values unencrypted, readable by this machine's user alone. A production org is refused.",readOnly:!1,destructive:!1,args:o.strictObject({org:p("The org: its sf CLI alias."),name:o.string().min(1).max(200).regex(I,'one line, not starting with "-"').optional().describe("What it is called (default: the date and time)."),objects:o.array(o.string().regex(x,"an object API name")).min(1).max(500).optional().describe("The objects to keep, by API name (default: every object people work in)."),estimate:o.boolean().optional().describe("true: say what it would take, then stop, keeping nothing.")}),run:e=>({script:"sandforge-checkpoint",args:["take","--org",e.org,...e.name!==void 0?["--name",e.name]:[],...(e.objects??[]).flatMap(t=>["--object",t]),...e.estimate===!0?["--estimate"]:[],"--json"]})}),u({name:"checkpoint_rewind",title:"Rewind an org",description:"Return org to a checkpoint: delete the records created since, give the records changed since their values back and bring back from the recycle bin the records deleted since \u2014 whoever made those changes \u2014 then read the org again. It rewinds from its own preview, said first in its answer with who last changed what; the answer says what Undo could not bring back, and checkpoint_undo takes the rewind back. Needs confirm, the alias of org: checkpoint_preview first. Refused without acceptAutomation when the org runs automation as the rewind writes, without acceptEmails when the org delivers every email what still runs sends, or would not say whether it does, without acceptNoUndo when Undo could not bring back records it deletes, without acceptRecreate when records no longer in the recycle bin would be made again with new Ids, without acceptUnseen when, for a user without View All Data and Modify All Data, what it deletes takes along records the user is not proven to see. Given objects, it rewinds those alone, never adding what they depend on: its answer names what it left of them, the objects to add, and what still differs in the others. A production org is refused.",readOnly:!1,destructive:!0,args:o.strictObject({org:p("The org: its sf CLI alias."),checkpoint:$("The checkpoint: its id or its name. latest is refused: one taken since would be the one the rewind returns to."),confirm:k("org").optional(),acceptAutomation:r("Rewind although the org runs flows, Apex triggers, processes or workflow rules as records are updated, deleted or brought back, or would not say what it runs."),acceptEmails:r("Rewind although the org delivers every email its automation sends (Setup > Deliverability: All email), or would not say whether it does, and what still runs as the rewind writes sends some. acceptAutomation never stands for it. Only once the person using you has accepted that these emails go out."),muteAutomation:C("the rewind"),acceptNoUndo:r("Rewind although Undo could not bring back some records it deletes (objects Salesforce undeletes only with their parent)."),acceptRecreate:r("Make again, with new Ids, the records deleted since that the recycle bin no longer gives back: what outside Salesforce names their old Ids no longer finds them."),acceptOutside:r("For a checkpoint of picked objects: also delete the records outside it created under records it deletes."),acceptUnseen:r("For a user without View All Data and Modify All Data: delete records whose delete takes along records of objects the user is not proven to see, tasks and events among them, which no count holds."),objects:ae()}),writesTo:e=>e.org,writes:"deletes the records created since the checkpoint, gives the records changed since their values back and brings back the records deleted since, whoever made those changes",readFirst:"checkpoint_preview says what it would do, writing nothing",flags:je,run:e=>({script:"sandforge-checkpoint",args:["rewind","--org",e.org,"--checkpoint",e.checkpoint,"--yes",...(e.objects??[]).flatMap(t=>["--object",t]),...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],...e.acceptNoUndo===!0?["--accept-no-undo"]:[],...e.acceptRecreate===!0?["--accept-recreate"]:[],...e.acceptOutside===!0?["--accept-outside"]:[],...e.acceptUnseen===!0?["--accept-unseen"]:[],"--json"]})}),u({name:"checkpoint_undo",title:"Undo a rewind",description:"Take back org's last rewind to a checkpoint: bring back what it deleted, give back what it wrote over, send back to the recycle bin what it brought back; what anyone changed since the rewind stays, and is said. Needs confirm, the alias of org. acceptAutomation and acceptEmails as for checkpoint_rewind.",readOnly:!1,destructive:!0,args:o.strictObject({org:p("The org: its sf CLI alias."),checkpoint:$("The checkpoint the rewind went back to: its id or its name."),confirm:k("org").optional(),acceptAutomation:r("Undo although the org runs flows, Apex triggers, processes or workflow rules as records are updated, deleted or brought back, or would not say what it runs."),acceptEmails:r("Undo although the org delivers every email its automation sends (Setup > Deliverability: All email), or would not say whether it does, and what still runs as the undo writes sends some. acceptAutomation never stands for it. Only once the person using you has accepted that these emails go out."),muteAutomation:C("the undo")}),writesTo:e=>e.org,writes:"brings back what its last rewind deleted, gives back what it wrote over and sends back to the recycle bin what it brought back",readFirst:"checkpoint_list says which rewind it would take back, and until when",flags:{"--accept-automation":"acceptAutomation","--accept-emails":"acceptEmails","--mute-automation":"muteAutomation"},run:e=>({script:"sandforge-checkpoint",args:["undo","--org",e.org,"--checkpoint",e.checkpoint,"--yes",...e.acceptAutomation===!0?["--accept-automation"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],...e.muteAutomation===!0?["--mute-automation"]:[],"--json"]})}),u({name:"checkpoint_delete",title:"Delete a checkpoint",description:"Delete a checkpoint of org from this machine: the org is not touched, and can no longer be rewound to it, nor its last rewind to it undone. Needs confirm, the alias of org.",readOnly:!1,destructive:!0,args:o.strictObject({org:p("The org: its sf CLI alias."),checkpoint:$("The checkpoint: its id or its name."),confirm:k("org").optional()}),writesTo:e=>e.org,writes:"deletes the checkpoint from this machine, and the org can no longer be rewound to it",run:e=>({script:"sandforge-checkpoint",args:["delete","--org",e.org,"--checkpoint",e.checkpoint,"--yes","--json"]})}),u({name:"empty_preview",title:"Preview an emptying",description:"What emptying objects of org, or every object people work in there, would do: per object the records it deletes and what the org deletes along with them, in the order it takes them; what will likely refuse, what blocks, what no undo would bring back, what it leaves out and why; the API requests, Bulk API batches and time against what the org has left today, and the recycle bin; what the user is not proven to see; what the org runs as the records go, and its emails; and every refusal a run with the same parameters would meet now. Reads the org, deletes nothing.",readOnly:!0,args:o.strictObject({org:p("The org: its sf CLI alias."),...de}).refine(le,{message:"give objects or wholeOrg, one of them"}),flags:ue,named:pe,run:e=>({script:"sandforge-empty",args:["--target",e.org,...he(e),...M(e),...e.acceptPeopleActive===!0?["--accept-people-active"]:[],"--dry-run","--json"]})}),u({name:"empty_run",title:"Empty objects or an org",description:"Delete every record of the objects named of org, or of every object people work in there, with what the org deletes along with them: to the recycle bin, which empty_undo brings them back from, or for good with hardDelete. It reads the org as empty_preview does, says it all first in its answer, and deletes only when nothing refuses it. Given resume, the run id of the org's last emptying stopped part way, it takes that run up instead. Needs confirm, the alias of org: empty_preview first. Refused without acceptAutomation when the org runs automation as the records go, without acceptEmails when the org delivers every email what still runs sends, or would not say whether it does, without acceptNoUndo when Undo could not bring back some records, without acceptPeopleActive while someone else changed records of these objects in the last hour, past the day's API requests or Bulk API batches, and on a production org, always.",readOnly:!1,destructive:!0,args:o.strictObject({org:p("The org: its sf CLI alias."),confirm:k("org").optional(),...de,resume:o.string().regex(ce,"the run id of an emptying, em-...").optional().describe("Take up the org's last emptying stopped part way, by its run id, in place of objects or wholeOrg: on what its journal confirmed.")}).refine(le,{message:"give objects, wholeOrg or resume, one of them"}),writesTo:e=>e.org,writes:"deletes every record of the objects named, or of every object people work in, with what the org deletes along with them",readFirst:"empty_preview says what it would delete and meet, deleting nothing",flags:ue,named:pe,after:(e,t)=>Le(t),run:e=>({script:"sandforge-empty",args:["--target",e.org,...e.resume!==void 0?["--resume",e.resume]:he(e),...M(e),...e.acceptPeopleActive===!0?["--accept-people-active"]:[],"--yes","--json"]})}),u({name:"empty_undo",title:"Undo an emptying",description:"Bring back from the recycle bin what org's last emptying deleted, parents first, while the bin holds them; the answer names what could not come back and why. Refused for a run that deleted for good. Needs confirm, the alias of org. acceptAutomation, acceptEmails and muteAutomation as for empty_run.",readOnly:!1,destructive:!0,args:o.strictObject({org:p("The org: its sf CLI alias."),run:o.string().regex(ce,"the run id of an emptying, em-...").describe("The org's last emptying, by the run id its answer gave."),confirm:k("org").optional(),acceptAutomation:r("Undo although the org runs flows, Apex triggers, processes or workflow rules as records are brought back, or would not say what it runs."),acceptEmails:r("Undo although the org delivers every email what still runs as records come back sends, or would not say whether it does. Only once the person using you has accepted that these emails go out."),muteAutomation:C("the undo")}),writesTo:e=>e.org,writes:"brings back from the recycle bin what the org's last emptying deleted",readFirst:"empty_run's answer names the run and whether its undo is offered",flags:Re,run:e=>({script:"sandforge-empty",args:["--target",e.org,"--undo",e.run,...M(e),"--yes","--json"]})}),u({name:"env_plan",title:"Plan an environment",description:"What env_apply would do to org from a sandforge.yaml (file), as sandforge env plan --json says it: per resource, create, keep, replace, delete, or why it is blocked; what an earlier apply left there and what changed since; per object the records it would write; the API requests, storage and emails it takes. Each resource is dry-run by its own script. Reads the org and the sources its resources clone from, writes nothing to an org. failOnDrift: true ends it exit 3 when the org no longer holds the environment as applied \u2014 records deleted or changed since.",readOnly:!0,args:o.strictObject({file:U(),org:p("The org to fill: its sf CLI alias."),failOnDrift:o.boolean().optional().describe("true: exit 3 when records the environment holds were deleted or changed since."),acceptEmails:r("Plan what env_apply would do with acceptEmails: a seed or a clone is otherwise blocked where the org delivers the emails what still runs sends, or would not say whether it does.")}),flags:{"--accept-emails":"acceptEmails"},exits:{3:"drift: the org no longer holds the environment as applied, records deleted or changed since, each said above"},run:e=>({script:"sandforge-env",args:["plan","--file",e.file,"--org",e.org,...e.failOnDrift===!0?["--fail-on-drift"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],"--json"]})}),u({name:"env_apply",title:"Apply an environment",description:"Do to org what env_plan says, as sandforge env apply --yes --json does: plans again, then creates what the file declares, replaces what it is told to (replace: the resources, by name) and deletes the resources the file no longer holds, each by its own script, into the state kept on this machine; applied again, it writes nothing. A production org is refused, and a sandbox the file does not list. Needs confirm, the alias of org: env_plan first. acceptNoState lets it apply to an org this machine has no state of, where records an earlier apply left would be created twice. A resource's accept: { automation: true } in the file is what lets its runs be taken back although the org runs automation. acceptEmails lets its resources write although the org delivers the emails what still runs sends, or would not say whether it does. The answer ends with the env_destroy call that takes the environment back.",readOnly:!1,destructive:!0,args:o.strictObject({file:U(),org:p("The org to fill: its sf CLI alias."),confirm:k("org").optional(),replace:o.array(o.string().regex(Fe,"a resource of the file, by its name")).min(1).max(50).optional().describe("Resources to replace although kept or drifted, by their names in the file: their earlier runs are taken back, then run again."),acceptNoState:r("Apply to a Developer Edition or a sandbox this machine has no state of: records an earlier apply left there would be created twice. Only once the person using you has accepted it."),acceptEmails:r("Apply although the org delivers every email its automation sends (Setup > Deliverability: All email), or would not say whether it does, and what still runs as its resources write sends some. Only once the person using you has accepted that these emails go out.")}),writesTo:e=>e.org,writes:"creates, replaces and deletes the resources of the file there as its plan says, taking back the earlier runs a replace or a delete takes back",readFirst:"env_plan of the same file says what it would do, writing nothing",flags:{"--accept-no-state":"acceptNoState","--accept-emails":"acceptEmails"},named:{"--accept-automation":ie("env_apply")},after:e=>[`env_destroy with file "${e.file}" and org "${e.org}" takes this environment back.`],run:e=>({script:"sandforge-env",args:["apply","--file",e.file,"--org",e.org,...(e.replace??[]).flatMap(t=>["--replace",t]),...e.acceptNoState===!0?["--accept-no-state"]:[],...e.acceptEmails===!0?["--accept-emails"]:[],"--yes","--json"]})}),u({name:"env_destroy",title:"Destroy an environment",description:"Take back from org what env_apply created there from file, the last resource first, into its recycle bin, as sandforge env destroy --yes --json does; what it cannot take back is named, with why. Records changed since the apply are kept unless includeChanged: on a shared sandbox, a colleague\u2019s work. A production org is refused. Needs confirm, the alias of org. It takes back by removal alone: no rewind to a checkpoint.",readOnly:!1,destructive:!0,args:o.strictObject({file:U(),org:p("The org the environment was applied to: its sf CLI alias."),confirm:k("org").optional(),includeChanged:r("Take also the records changed since the apply, and what was created under them since: on a shared sandbox, others' work. Only once the person using you has accepted it.")}),writesTo:e=>e.org,writes:"deletes the records its applies created, into the recycle bin, the last resource first",readFirst:"env_plan of the same file says what the org holds of the environment and what changed since",flags:{"--include-changed":"includeChanged"},named:{"--accept-automation":ie("env_destroy")},run:e=>({script:"sandforge-env",args:["destroy","--file",e.file,"--org",e.org,...e.includeChanged===!0?["--include-changed"]:[],"--yes","--json"]})})],Ue=new Map(F.map(e=>[e.definition.name,e]));async function We(){let{templateDisplayName:e}=await import("./sandforge-seed.mjs"),t=J.map(n=>{let s=n.objects.map(c=>({objectApiName:c.objectApiName,records:c.recordCount}));return{id:n.id,name:e(n),description:e({name:n.description}),objects:s,records:s.reduce((c,m)=>c+m.records,0)}});return{text:t.map(n=>`${n.id} \u2014 ${n.name}: ${n.records} records at most in ${n.objects.length} objects (${n.objects.map(s=>`${s.objectApiName} ${s.records}`).join(", ")})`).join(`
|
|
8
|
+
`),structured:{templates:t}}}function fe(e,t){let n={refusal:{code:e,message:t}};return{content:[{type:"text",text:t},{type:"text",text:JSON.stringify(n)}],structuredContent:n,isError:!0}}function ze(e){switch(e){case 0:return"done";case 1:return"refused before it wrote, could not start, or did nothing but fail";case 2:return"a request the script could not take, or a question for the person using you: nothing was written";case 3:return"partial: records were left, refused or not checked, each said with why";case 4:return"unstable: someone else wrote to the records meanwhile";default:{let t=Z.find(n=>q(n)===e);return t!==void 0?`stopped by ${t} before it was through`:"ended on an error"}}}var we=new Set([0,3,4]),Be="no terminal to answer",ye=(e,t)=>new RegExp(`(?<![\\w-])${t}(?![\\w-])`).test(e);function Oe(e,t){let n=t.map(s=>/^[\w.@:+/=,-]+$/.test(s)?s:`'${s.replace(/'/g,"'\\''")}'`);return["npx sandforge",e.replace(/^sandforge-/,""),...n].join(" ")}function He(e){let t=e.trim();if(t!=="")try{return JSON.parse(t)}catch{return}}function Je(e,t,n,s=()=>[]){let c=He(n.stdout),m=[`ran: ${Oe(t.script,t.args)}`,`exit ${n.code}: ${e.exits?.[n.code]??ze(n.code)}`],w=n.stderr.trimEnd();w!==""&&m.push("",w),c===void 0&&n.stdout.trim()!==""&&m.push("",n.stdout.trimEnd());let g=[];n.code===2&&n.stderr.includes(Be)&&g.push("The script asked the question above and had no terminal to answer it on, so it stopped having written nothing. It is a question for the person using you: no parameter of this tool answers it.");let b=`${n.stderr}
|
|
9
|
+
${n.stdout}`;for(let[R,T]of Object.entries(e.flags))ye(b,R)&&g.push(`${R}, named above, is this tool's ${T}: true. Give it only once the person using you has accepted what it lets through.`);for(let[R,T]of Object.entries(e.named??{}))ye(b,R)&&g.push(`${R}, named above, ${T}`);we.has(n.code)&&g.push(...s(c)),g.length>0&&m.push("",...g);let N={exitCode:n.code,...c!==void 0?{answer:c}:{}};return{content:[{type:"text",text:m.join(`
|
|
10
|
+
`)},{type:"text",text:JSON.stringify(N)}],structuredContent:N,isError:!we.has(n.code)}}var j=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),P=e=>typeof e=="string"||typeof e=="number"&&Number.isInteger(e);function Ve(e){let t=e.runCommand??Ne,n=e.log??(d=>{process.stderr.write(`${d}
|
|
11
|
+
`)}),s,c=new Map,m=new Set,w=new Set,g=d=>{e.send(JSON.stringify({jsonrpc:"2.0",...d}))},b=(d,a)=>d==="perRequest"?{resultType:"complete",...a,_meta:{[E.serverInfo]:te}}:a,N=d=>{let a=j(d)?d.protocolVersion:void 0;if(typeof a!="string")return{error:{code:f.invalidParams,message:"initialize names the protocol version it asks for in protocolVersion."}};let i=_.includes(a)?a:_[0];return s=i,n(`sandforge mcp: ${a===i?"agreed on":`asked for ${a}, offered`} ${i}`),{result:{protocolVersion:i,capabilities:{tools:{}},serverInfo:te,instructions:oe}}},R=async(d,a,i)=>{if(!j(a)||typeof a.name!="string")return{error:{code:f.invalidParams,message:"tools/call names its tool in name."}};let l=Ue.get(a.name);if(!l)return{error:{code:f.invalidParams,message:`Unknown tool: ${a.name}`}};if(a.arguments!==void 0&&!j(a.arguments))return{error:{code:f.invalidParams,message:"tools/call takes its arguments as an object."}};let y=l.read(a.arguments??{});if("refusal"in y)return{result:b(i,{...fe("ARGUMENTS",`${l.definition.name}: ${y.refusal}. Nothing was run.`)})};let{call:h}=y;if(h.writesTo!==void 0&&h.confirm!==h.writesTo)return{result:b(i,{...fe("CONFIRM",qe(l,h.writesTo,h.confirm))})};if("local"in h.run){let O=await h.run.local();return{result:b(i,{content:[{type:"text",text:O.text},{type:"text",text:JSON.stringify(O.structured)}],structuredContent:O.structured,isError:!1})}}let{script:A,args:v}=h.run,H=new AbortController;c.set(d,H);try{n(`sandforge mcp: ${l.definition.name} runs ${Oe(A,v)}`);let O;try{O=await t(A,v,H.signal)}catch(D){O={code:1,stdout:"",stderr:`${X(A)} could not be started: ${D instanceof Error?D.message:String(D)}`}}return m.has(d)?void 0:{result:b(i,{...Je(l,h.run,O,h.after)})}}finally{c.delete(d),m.delete(d)}},T=async(d,a,i)=>{if(a==="initialize")return N(i);let l=j(i)&&j(i._meta)?i._meta:void 0,y=l?.[E.version],h;if(y!==void 0){if(y!==S)return{error:{code:f.unsupportedVersion,message:"Unsupported protocol version",data:{supported:[S],requested:String(y)}}};if(!j(l?.[E.capabilities]))return{error:{code:f.invalidParams,message:`A request of ${S} names its client's capabilities in _meta["${E.capabilities}"].`}};h="perRequest"}else{if(a==="ping")return{result:{}};if(s!==void 0)h="handshake";else return{error:{code:f.invalidParams,message:`Name the protocol version in _meta["${E.version}"] (${S}), or open with initialize (${_.join(", ")}).`}}}switch(a){case"server/discover":if(h!=="perRequest")break;return{result:b(h,{supportedVersions:[S],capabilities:{tools:{}},instructions:oe,ttlMs:ee,cacheScope:"public"})};case"ping":return{result:b(h,{})};case"tools/list":return{result:b(h,{tools:F.map(A=>A.definition),...h==="perRequest"?{ttlMs:ee,cacheScope:"public"}:{}})};case"tools/call":return R(d,i,h)}return{error:{code:f.methodNotFound,message:`${a} is not a method of this server: it serves tools/list and tools/call.`}}},Se=(d,a)=>{if(d!=="notifications/cancelled"||!j(a))return;let{requestId:i}=a;if(!P(i))return;let l=c.get(i);l&&(m.add(i),n(`sandforge mcp: request ${String(i)} cancelled: its script is stopped as Ctrl-C stops it`),l.abort())},xe=d=>{let a=d.trim();if(a==="")return;let i;try{i=JSON.parse(a)}catch{g({error:{code:f.parse,message:"Parse error: a line that is not JSON."}});return}if(Array.isArray(i)){g({error:{code:f.invalidRequest,message:"A batch is not a message of this protocol: send one message a line."}});return}if(!j(i)){g({error:{code:f.invalidRequest,message:"A message is a JSON-RPC object."}});return}let{id:l,method:y,params:h}=i;if(y===void 0&&("result"in i||"error"in i))return;if(i.jsonrpc!=="2.0"||typeof y!="string"){g({...P(l)?{id:l}:{},error:{code:f.invalidRequest,message:'A message has jsonrpc "2.0" and a method.'}});return}if(l===void 0){Se(y,h);return}if(!P(l)||c.has(l)){g({error:{code:f.invalidRequest,message:P(l)?`A request with the id ${String(l)} is still under way: give each its own.`:"A request id is a string or a whole number."}});return}let A=T(l,y,h).then(v=>{v!==void 0&&g({id:l,...v})}).catch(v=>{g({id:l,error:{code:f.internal,message:v instanceof Error?v.message:String(v)}})}).finally(()=>{w.delete(A)});w.add(A)},z=async()=>{for(let d of c.values())d.abort();for(;w.size>0;)await Promise.allSettled([...w])},B=_e({input:e.input,crlfDelay:1/0});return B.on("line",xe),{done:new Promise(d=>{B.once("close",()=>{z().then(d)})}),stop:z}}function Ge(e,t){let n=e.write.bind(e);return e.write=t.write.bind(t),s=>{n(`${s}
|
|
12
|
+
`)}}var Ze=`sandforge mcp \u2014 Seed, Forge's clone of a record, the removal of a run, the emptying of
|
|
13
|
+
objects or of a whole org, Checkpoints and the environments of a sandforge.yaml, as tools for an AI
|
|
14
|
+
agent, over the Model Context Protocol on stdio.
|
|
15
|
+
|
|
16
|
+
Usage:
|
|
17
|
+
npx sandforge mcp
|
|
18
|
+
|
|
19
|
+
An MCP client starts it: it reads JSON-RPC messages on stdin, one a line, and answers on
|
|
20
|
+
stdout; every other line goes to stderr. In Claude Code:
|
|
21
|
+
claude mcp add sandforge -- npx -y sandforge mcp
|
|
22
|
+
|
|
23
|
+
Protocol: MCP ${S}, each request naming it in _meta; and the initialize handshake of
|
|
24
|
+
${_.join(", ")}.
|
|
25
|
+
|
|
26
|
+
Tools: ${F.map(e=>e.definition.name).join(", ")}.
|
|
27
|
+
Each one but seed_templates runs the script of this folder that does the same, with --json, in a
|
|
28
|
+
process of its own, and answers with its JSON, its exit code and its lines: every guard of the
|
|
29
|
+
script holds. A tool that writes to an org needs confirm, the alias of that org exactly, or it is
|
|
30
|
+
refused before anything is read. A script that asks a question stops at it, having written
|
|
31
|
+
nothing, and the question comes back as the call's error.
|
|
32
|
+
|
|
33
|
+
Environment:
|
|
34
|
+
SANDFORGE_JOURNAL_DIR=<dir> where the scripts keep their run files, journals and
|
|
35
|
+
checkpoints (default: ~/.sandforge), as each script's --help says
|
|
36
|
+
|
|
37
|
+
--help this text
|
|
38
|
+
`;async function Ke(e=process.argv){let t=e.slice(2);if(t.includes("--help")||t.includes("-h")){process.stdout.write(Ze);return}V(t,{switches:[],values:[]});let n=Ge(process.stdout,process.stderr),s=Ve({input:process.stdin,send:n});process.stdout.on("error",()=>{s.stop().then(()=>process.exit(0))});let c=K(m=>{s.stop().then(()=>process.exit(q(m)))});process.stderr.write(`sandforge mcp: ${F.length} tools on stdio, MCP ${S} (and ${_.join(", ")} by initialize)
|
|
39
|
+
`),await s.done,c()}/sandforge-mcp\.[cm]?[jt]s$/.test(process.argv[1]??"")&&(Q(),Ke().catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
|
|
40
|
+
`),process.exit(1)}));export{f as ERROR,_ as HANDSHAKE_VERSIONS,oe as INSTRUCTIONS,S as PROTOCOL_VERSION,F as TOOLS,Ge as claimStdout,Oe as commandText,qe as confirmRefusal,ze as exitWords,Ke as main,Je as resultOf,Ve as serve,Ie as toolRunner};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{e as j}from"./chunk-TNXUU6W7.mjs";import"./chunk-IC2C2GOF.mjs";import"./chunk-VGW4MXXZ.mjs";import"./chunk-JVL444U5.mjs";import"./chunk-KLX67VPL.mjs";import"./chunk-5CD257T7.mjs";import"./chunk-5AJRHRXA.mjs";import"./chunk-42RER7V4.mjs";import"./chunk-LRFAIUN7.mjs";import"./chunk-OQOZAPCI.mjs";import"./chunk-RSYICMZG.mjs";import"./chunk-IAZB4WIL.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-XEFDB2R4.mjs";import"./chunk-H45UXY6G.mjs";import"./chunk-WRU5FJFC.mjs";import"./chunk-GMY5427L.mjs";import"./chunk-GNC27UEU.mjs";import"./chunk-YBU4Z4QV.mjs";import{b as S,c as x}from"./chunk-I7O6C2B5.mjs";import"./chunk-4GL773D5.mjs";import"./chunk-SRQDABQ2.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LV6G4XTK.mjs";import"./chunk-HJKM3E56.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-YMJVMFPY.mjs";import"./chunk-ALJVEUUS.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-4HFRHFGQ.mjs";import"./chunk-342FN7AO.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-36U7IQ6Y.mjs";import"./chunk-XETCPL7E.mjs";import"./chunk-K2FBZIXY.mjs";import"./chunk-Z7X534S4.mjs";import"./chunk-6QSM2WIH.mjs";import"./chunk-WJY54JO7.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-NEVXIGR6.mjs";import"./chunk-NTDN2JQZ.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-F74IHMGL.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-Y5CGXLUB.mjs";import"./chunk-3F5YMM2F.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-L776PUMV.mjs";import"./chunk-6MUEPV7M.mjs";import"./chunk-HJC7AIBK.mjs";import"./chunk-OTWRDD6L.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-RH3N2H7P.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-55HEMHEG.mjs";import"./chunk-P42X3B4D.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VXHDBYMI.mjs";import"./chunk-ENLBYECD.mjs";import"./chunk-PA3MKJVH.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-ZLZRU6MO.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-PNCONNFJ.mjs";import"./chunk-CGWXQX75.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-SIOZXPFG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import{a as w,e as b,g as y}from"./chunk-MTMH6H2A.mjs";import"./chunk-B45CNPUX.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-SBIMVCXT.mjs";import"./chunk-NTOVCTRS.mjs";var v=`sandforge monitor \u2014 read an org the way the Monitor page does, without the editor.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
npx sandforge monitor --org <alias> [options]
|
|
11
|
+
|
|
12
|
+
Required:
|
|
13
|
+
--org <alias> sf CLI alias of the org; repeat to read several in turn
|
|
14
|
+
|
|
15
|
+
Options:
|
|
16
|
+
--op <name> one of the page's requests; repeat for more (default: all):
|
|
17
|
+
refresh, live-operations, storage, deployments, api-usage,
|
|
18
|
+
error-logs, sessions, apex-insights, sandbox-refresh, alerts
|
|
19
|
+
--acknowledge <id> acknowledge an alert (extension state only)
|
|
20
|
+
--dismiss <id> dismiss an alert (extension state only)
|
|
21
|
+
--repeat <n> send the set n times in the same host (default: 1)
|
|
22
|
+
--pause <seconds> wait between two passes (default: 0)
|
|
23
|
+
--store <dir> where the host keeps its config store, a folder of your
|
|
24
|
+
own (default: ~/.sandforge/monitor, under the folder
|
|
25
|
+
SANDFORGE_JOURNAL_DIR names when it is set)
|
|
26
|
+
--wait <seconds> how long to keep waiting for an answer (default: 300)
|
|
27
|
+
--json emit what the page would receive, every other line on
|
|
28
|
+
stderr
|
|
29
|
+
--help this text
|
|
30
|
+
|
|
31
|
+
Nothing is written to the org.
|
|
32
|
+
|
|
33
|
+
Exit codes: 0 every request was answered (read the answers); 1 it could not
|
|
34
|
+
start, or a request failed, was refused or was not answered in time; 2 a bad
|
|
35
|
+
command line.
|
|
36
|
+
`,$=["refresh","live-operations","storage","deployments","api-usage","error-logs","sessions","apex-insights","sandbox-refresh","alerts"],k={switches:["--json"],values:["--org","--op","--acknowledge","--dismiss","--repeat","--pause","--store","--wait"]};function P(g){let e=g.slice(2);(e.includes("--help")||e.includes("-h"))&&(process.stdout.write(v),process.exit(0)),w(e,k);let i=(c,m)=>{let p=e.indexOf(c);return p>=0&&p+1<e.length?e[p+1]:m},o=c=>{let m=[];for(let p=0;p<e.length;p++)e[p]===c&&p+1<e.length&&m.push(e[p+1]);return m},u=c=>{process.stderr.write(`${c}
|
|
37
|
+
`),process.exit(2)},t=(c,m,p)=>{let l=Number(i(c,m)??m);return(!Number.isInteger(l)||l<p)&&u(`${c} takes a whole number from ${p}.`),l},s=[...new Set(o("--org"))];s.length===0&&u("Missing --org. Run with --help.");let r=o("--op");for(let c of r)c==="open-apex-jobs"&&u("open-apex-jobs opens a browser and reads nothing: it is not run from here."),$.includes(c)||u(`Not a Monitor request: "${c}". One of: ${$.join(", ")}.`);let n=o("--acknowledge"),a=o("--dismiss"),d=r.length>0?[...new Set(r)]:n.length+a.length>0?[]:[...$];return{orgs:s,operations:d,acknowledge:n,dismiss:a,repeat:t("--repeat","1",1),pauseMs:t("--pause","0",0)*1e3,storeDir:i("--store")??S("monitor"),waitMs:t("--wait","300",1)*1e3,json:e.includes("--json")}}function R(g,e){switch(g){case"refresh":return{type:"monitor:refresh",payload:{orgId:e},responseType:"monitor:data"};case"live-operations":return{type:"monitor:live-operations"};case"alerts":return{type:"monitor:alerts",responseType:"monitor:alerts:result"};default:return{type:`monitor:${g}`,payload:{orgId:e}}}}function f(g,e=6){if(g.length===0)return"\u2014";let i=g.slice(0,e).join("; ");return g.length>e?`${i} \u2026 (+${g.length-e})`:i}function C(g,e,i){let o=t=>Array.isArray(e[t])?e[t]:[],u=t=>e.truncated===!0?`; the list stops at ${t}`:"";switch(g){case"refresh":{let t=o("limits"),s=[...t].sort((l,h)=>h.usedPercent-l.usedPercent).slice(0,5),r=o("jobs"),n={};for(let l of r)n[l.status]=(n[l.status]??0)+1;let a=e.orgInfo??void 0,d=e.orgHealthStatus??void 0,c=Array.isArray(e.jobInsights)?e.jobInsights:null,m=e.trends??{},p=a&&a.type!=="Sandbox"?`, created ${String(a.createdDate??"\u2014")}`:"";return[` health score ${String(e.healthScore)}; ${t.length} limit(s), highest: ${f(s.map(l=>`${l.name} ${l.usedPercent}% (${l.max-l.remaining}/${l.max})`),5)}`,` ${r.length} job(s)${e.jobsTruncated===!0?" (the window came back full: older jobs not read)":""}: ${f(Object.entries(n).map(([l,h])=>`${l} ${h}`))}`,` job insights: ${c===null?"none sent":f(c.map(l=>l.title))}`,a?` org: type ${String(a.type)}, edition ${String(a.edition)}, instance ${String(a.instanceName)}, API ${String(a.apiVersion)}, namespace ${String(a.namespacePrefix??"\u2014")}${p}, users ${String(a.userCount)}, custom objects ${String(a.customObjectCount)}, Apex classes ${String(a.apexClassCount)}, active flows ${String(a.flowCount)}`:" org: no org info sent",d?` health check: ${String(d.overall)}; api ${String(d.apiLimitsStatus)}, storage ${String(d.storageStatus)}, failed jobs ${String(d.failedJobs)}${typeof d.failedJobsOutOf=="number"?` of the ${d.failedJobsOutOf} latest`:""}, recent error logs ${String(d.recentErrorLogs)}`:" health check: none sent",` trends: ${f(Object.entries(m).map(([l,h])=>`${l} ${h.direction} (${h.sparklineData.length} pt)`),7)}`]}case"live-operations":return[` ${o("operations").length} operation(s)`];case"storage":{let t=o("objects");return[` ${t.length} of ${String(e.objectCount??t.length)} object(s) holding records listed, total ${String(e.totalRecords)} record(s)`,` ${f(t.map(s=>`${s.objectName} ${s.recordCount}`),10)}`]}case"deployments":{let t=o("deployments");return[` ${t.length} deployment(s)${u(t.length)}`,` ${f(t.map(s=>`${s.status} ${s.startDate} (${s.componentCount})`),5)}`]}case"api-usage":{let t=o("categories");return[` ${t.length} categor(ies)`,` ${f(t.map(s=>`${s.category} ${s.usedPercent}% (${s.used}/${s.max})`),16)}`]}case"error-logs":{let t=o("errors");return[` total ${String(e.totalCount)}; ${t.length} listed${u(t.length)}; by type ${f(o("errorsByType").map(s=>`${s.type} ${s.count}`))}`,t.length>0?` newest ${t[0].timestamp}, oldest ${t[t.length-1].timestamp}`:" \u2014"]}case"sessions":{let t=o("sessions"),s={};for(let r of t)s[r.sessionType]=(s[r.sessionType]??0)+1;return[` ${t.length} session(s), ${String(e.activeUserCount)} active user(s)${u(t.length)}`,` ${f(Object.entries(s).map(([r,n])=>`${r} ${n}`),10)}`]}case"apex-insights":return[` ${o("analyses").length} log(s) analysed${u(o("analyses").length)}; top issues: ${f(o("topIssues").map(t=>t.message))}`];case"sandbox-refresh":return[` supported ${String(e.supported)}; ${o("refreshes").length} refresh(es)${u(o("refreshes").length)}; in progress ${String(e.inProgress)}`];case"alerts":{let t=o("alerts"),s=o("history"),r=t.filter(n=>n.orgId===i);return[` ${t.length} active alert(s), ${r.length} of this org; ${s.length} in history, ${s.filter(n=>n.orgId===i).length} of this org`,...t.map(n=>` ${n.id} ${n.status} ${n.orgId===i?"this org":"another org"}: ${n.message}`)]}}}function O(g,e,i,o=""){let u=`${(i.elapsedMs/1e3).toFixed(1)}s`,t=`${g} ${i.outcome} in ${u}`,s=[i.late?`${t} \u2014 past the page's timeout: the page dropped it`:t],r=i.message?.payload??{};return i.outcome!=="answered"?(i.message&&s.push(` ${String(r.message??JSON.stringify(r))}`),s):e?[...s,...C(e,r,o)]:[...s,` ${JSON.stringify(r)}`]}async function T(g=process.argv){let e=P(g),i=r=>{process[e.json?"stderr":"stdout"].write(`${r}
|
|
38
|
+
`)},o=x(e.storeDir);if(o!==void 0){process.stderr.write(`${o}
|
|
39
|
+
`),process.exitCode=1;return}let u=j({storeDir:e.storeDir,log:r=>{/^\s*!|\[(ERR|WARN|ALERT)\]/.test(r)&&i(r)},waitMs:e.waitMs}),t=[];for(let r of e.orgs){let n=await u.connect(r);t.push(n),i(`sandforge monitor ${r} (${n.orgType}) store: ${e.storeDir}`)}let s=[];for(let r=1;r<=e.repeat;r++){e.repeat>1&&i(`
|
|
40
|
+
\u2014 pass ${r} of ${e.repeat}`);for(let n of t){t.length>1&&i(`
|
|
41
|
+
[${n.alias}]`);for(let a of e.operations){let d=await u.request(R(a,n.id));s.push({pass:r,org:n.alias,label:`monitor:${a}`,answer:d});for(let c of O(`monitor:${a}`,a,d,n.id))i(c)}}for(let[n,a]of[["acknowledge",e.acknowledge],["dismiss",e.dismiss]])for(let d of a){let c=`monitor:alert:${n}`,m=await u.request({type:c,payload:{alertId:d}});s.push({pass:r,org:"",label:c,answer:m});for(let p of O(`${c} ${d}`,void 0,m))i(p)}r<e.repeat&&e.pauseMs>0&&await new Promise(n=>setTimeout(n,e.pauseMs))}e.json&&process.stdout.write(`${JSON.stringify({tool:"sandforge-monitor",results:s,posted:u.posted},null,2)}
|
|
42
|
+
`),b(N(s.map(({answer:r})=>r)))}function N(g){return g.some(e=>e.outcome!=="answered")?1:0}process.argv[1]?.includes("sandforge-monitor")&&(y(),T().then(()=>process.exit(process.exitCode??0)).catch(g=>{process.stderr.write(`${g instanceof Error?g.message:String(g)}
|
|
43
|
+
`),process.exit(1)}));export{O as describeAnswer,T as main,N as monitorExitCode,R as pageRequest,P as parseArgs};
|