sandforge 1.83.0 → 1.84.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/chunk-23SEDORH.mjs +11 -0
- package/lib/{chunk-I5C4O3VA.mjs → chunk-24RFOFYT.mjs} +1 -1
- package/lib/chunk-26POJDIT.mjs +7 -0
- package/lib/{chunk-WJAZ5LHL.mjs → chunk-2AZQHBEF.mjs} +1 -1
- package/lib/{chunk-IHGYJZZ2.mjs → chunk-2HVOZUM4.mjs} +1 -1
- package/lib/{chunk-3V4YH5KO.mjs → chunk-2JDAOWUW.mjs} +1 -1
- package/lib/{chunk-BNKT3R3F.mjs → chunk-2METQHGG.mjs} +1 -1
- package/lib/chunk-2WFIVO4F.mjs +13 -0
- package/lib/chunk-2YHZBUZE.mjs +7 -0
- package/lib/{chunk-7DPHZWA4.mjs → chunk-326AJTIU.mjs} +14 -14
- package/lib/{chunk-UIR77ZJD.mjs → chunk-36JOHEJL.mjs} +1 -1
- package/lib/chunk-3PVRGTVK.mjs +7 -0
- package/lib/{chunk-2WMKJVD2.mjs → chunk-3Q353S2R.mjs} +1 -1
- package/lib/chunk-3TZSBHEY.mjs +7 -0
- package/lib/{chunk-T36DZJPH.mjs → chunk-43TOMFV4.mjs} +1 -1
- package/lib/{chunk-XAMMIPZ4.mjs → chunk-4CVUUVGJ.mjs} +1 -1
- package/lib/{chunk-6YC2ELCU.mjs → chunk-4EOHEDFP.mjs} +1 -1
- package/lib/{chunk-ZB5E7NHU.mjs → chunk-4JE4BYXK.mjs} +1 -1
- package/lib/{chunk-JREKJO3D.mjs → chunk-54WZUS7J.mjs} +1 -1
- package/lib/{chunk-CGZGL6VT.mjs → chunk-5CRLRHOJ.mjs} +1 -1
- package/lib/{chunk-UOHZW2L4.mjs → chunk-5IZTFMJM.mjs} +1 -1
- package/lib/{chunk-6VOQFISN.mjs → chunk-5M5FQ7RP.mjs} +1 -1
- package/lib/{chunk-U4YFYSF3.mjs → chunk-5SMWFNE7.mjs} +1 -1
- package/lib/{chunk-HQZUQXDC.mjs → chunk-5XTUSN72.mjs} +1 -1
- package/lib/chunk-6I6TWNV5.mjs +7 -0
- package/lib/{chunk-QLRWU3MB.mjs → chunk-6JWWSDM6.mjs} +1 -1
- package/lib/chunk-6O222PW6.mjs +7 -0
- package/lib/{chunk-J3TIHLWG.mjs → chunk-6PD6K7LP.mjs} +1 -1
- package/lib/{chunk-ISAUCWYK.mjs → chunk-6QE6R6RL.mjs} +1 -1
- package/lib/{chunk-2KTGDYUH.mjs → chunk-6WX5ZU7Q.mjs} +1 -1
- package/lib/{chunk-XAUQXYPW.mjs → chunk-6YL7BNYD.mjs} +1 -1
- package/lib/chunk-6ZLKIT3H.mjs +7 -0
- package/lib/{chunk-XKFHTBAB.mjs → chunk-7QYHEHMA.mjs} +1 -1
- package/lib/chunk-7SQSWVAU.mjs +9 -0
- package/lib/{chunk-NNV7IGM7.mjs → chunk-7UVKIWKV.mjs} +1 -1
- package/lib/{chunk-RZKJQOOC.mjs → chunk-7WATA4SB.mjs} +1 -1
- package/lib/{chunk-DMT5SCO3.mjs → chunk-7YNM6KFZ.mjs} +1 -1
- package/lib/{chunk-TMIESDE5.mjs → chunk-A3MYSOOC.mjs} +1 -1
- package/lib/chunk-AL4C3GFT.mjs +7 -0
- package/lib/chunk-B3FBHVNN.mjs +21 -0
- package/lib/{chunk-CDWZGQAJ.mjs → chunk-B63POIPQ.mjs} +1 -1
- package/lib/{chunk-YEVB7LVK.mjs → chunk-BAWCOKRW.mjs} +1 -1
- package/lib/{chunk-FVLFO2S6.mjs → chunk-BBRWFKS5.mjs} +1 -1
- package/lib/chunk-BEA27DLS.mjs +7 -0
- package/lib/chunk-BRY3PLIZ.mjs +7 -0
- package/lib/chunk-CBH3TOWK.mjs +341 -0
- package/lib/{chunk-7V2UYZ6S.mjs → chunk-CPQIZGG5.mjs} +1 -1
- package/lib/chunk-CVHNXJH3.mjs +7 -0
- package/lib/{chunk-ZOSESZ22.mjs → chunk-D4GF4FAB.mjs} +1 -1
- package/lib/chunk-DGDRQRCW.mjs +7 -0
- package/lib/{chunk-2N73W63D.mjs → chunk-DPMRIMUC.mjs} +1 -1
- package/lib/chunk-DUN2EPRC.mjs +7 -0
- package/lib/chunk-E3A3LOCY.mjs +7 -0
- package/lib/{chunk-KWAVSZ2B.mjs → chunk-EAC5QCE3.mjs} +1 -1
- package/lib/{chunk-JUOQUG7U.mjs → chunk-EC72TIEG.mjs} +1 -1
- package/lib/chunk-EPFCERGL.mjs +7 -0
- package/lib/{chunk-6KOUYHEY.mjs → chunk-ETDCBLGU.mjs} +1 -1
- package/lib/{chunk-2R6GFNKF.mjs → chunk-F3AQW6IU.mjs} +1 -1
- package/lib/{chunk-AHUGG3WU.mjs → chunk-FITPY3L4.mjs} +1 -1
- package/lib/chunk-FNJ4SGWO.mjs +7 -0
- package/lib/{chunk-EOQON3E5.mjs → chunk-FP7CYB2F.mjs} +1 -1
- package/lib/{chunk-262TP6UU.mjs → chunk-GKY2JMHY.mjs} +1 -1
- package/lib/{chunk-JBWJ6UEZ.mjs → chunk-GMIGWR6U.mjs} +1 -1
- package/lib/{chunk-OS5GE52G.mjs → chunk-GNRSF65U.mjs} +1 -1
- package/lib/chunk-GOOVPVWX.mjs +7 -0
- package/lib/{chunk-DB5RVDC5.mjs → chunk-GWZRR3MM.mjs} +1 -1
- package/lib/{chunk-SX6QWYCQ.mjs → chunk-H2BHESDA.mjs} +2 -2
- package/lib/chunk-H4CGM6YO.mjs +7 -0
- package/lib/{chunk-NFEBX75O.mjs → chunk-HCGXK7G7.mjs} +1 -1
- package/lib/{chunk-4X5D3MSV.mjs → chunk-HIDW7FNV.mjs} +1 -1
- package/lib/chunk-HSBXRQTI.mjs +7 -0
- package/lib/chunk-HUZPBE47.mjs +7 -0
- package/lib/{chunk-F5SBGJWW.mjs → chunk-HV7VPEXP.mjs} +1 -1
- package/lib/chunk-I6E6T6YY.mjs +7 -0
- package/lib/chunk-IUM4NFKI.mjs +10 -0
- package/lib/chunk-IVFVNNGB.mjs +37 -0
- package/lib/{chunk-L4MSL4U7.mjs → chunk-IZGCEOYO.mjs} +1 -1
- package/lib/{chunk-E3RQ575Y.mjs → chunk-J3DND3BC.mjs} +1 -1
- package/lib/{chunk-MJD6CPZZ.mjs → chunk-JAEDM4SI.mjs} +1 -1
- package/lib/chunk-JCFBFF4Y.mjs +7 -0
- package/lib/{chunk-U2CTKIPE.mjs → chunk-JE6SCT6R.mjs} +1 -1
- package/lib/{chunk-XJICAOAQ.mjs → chunk-JGZPD4IM.mjs} +1 -1
- package/lib/{chunk-XCJUNX63.mjs → chunk-JKJ74BX5.mjs} +1 -1
- package/lib/{chunk-WAYQLQAD.mjs → chunk-JLSIWO4Z.mjs} +1 -1
- package/lib/{chunk-D7XUNWWU.mjs → chunk-JSAJS3MY.mjs} +1 -1
- package/lib/chunk-JTJK2D36.mjs +7 -0
- package/lib/{chunk-OTJH6AEA.mjs → chunk-KAZS5Z6W.mjs} +1 -1
- package/lib/chunk-KB4ZHM4Q.mjs +10 -0
- package/lib/{chunk-N2HYG3BL.mjs → chunk-KGU4SVIT.mjs} +1 -1
- package/lib/{chunk-FKCIGJOI.mjs → chunk-KJWFYBMU.mjs} +2 -2
- package/lib/{chunk-KXUOHACP.mjs → chunk-KZTZDC7H.mjs} +1 -1
- package/lib/{chunk-S4PRKKGC.mjs → chunk-L2E5WBGD.mjs} +1 -1
- package/lib/{chunk-X2XZQ434.mjs → chunk-L53JWJ3S.mjs} +1 -1
- package/lib/{chunk-CQAFVEKP.mjs → chunk-LA4KIATH.mjs} +6 -6
- package/lib/chunk-LC3NDW4N.mjs +7 -0
- package/lib/{chunk-4V3QO7HF.mjs → chunk-LKTNQEBS.mjs} +1 -1
- package/lib/chunk-M2ABR4JM.mjs +7 -0
- package/lib/{chunk-3CM7LAPE.mjs → chunk-M4BLK6HJ.mjs} +1 -1
- package/lib/{chunk-Z3MGN42K.mjs → chunk-M6K34KGF.mjs} +1 -1
- package/lib/{chunk-TUPZY2QJ.mjs → chunk-MDMPJEV3.mjs} +1 -1
- package/lib/{chunk-BVZ5H3N4.mjs → chunk-MJZU3U5O.mjs} +68 -63
- package/lib/{chunk-OUU47Y7A.mjs → chunk-MSIEU5MR.mjs} +1 -1
- package/lib/{chunk-QQDZQCO2.mjs → chunk-N4WPCWJO.mjs} +1 -1
- package/lib/{chunk-MTM4KG3T.mjs → chunk-NCZKWSC7.mjs} +1 -1
- package/lib/{chunk-Y7YUNRKK.mjs → chunk-NED4MBIM.mjs} +1 -1
- package/lib/{chunk-QKJXIY6L.mjs → chunk-NOBQTEQD.mjs} +1 -1
- package/lib/{chunk-WBELLGNE.mjs → chunk-NSQWI7ZY.mjs} +1 -1
- package/lib/{chunk-BPHTA6KP.mjs → chunk-O677VOGO.mjs} +1 -1
- package/lib/chunk-OFTT7J2M.mjs +7 -0
- package/lib/{chunk-JH4ZTVQN.mjs → chunk-OLCVHL7I.mjs} +1 -1
- package/lib/chunk-OM5NORJG.mjs +7 -0
- package/lib/{chunk-QP3JLFIO.mjs → chunk-OMNMLKDT.mjs} +1 -1
- package/lib/{chunk-WABXKL4N.mjs → chunk-OPMO6I45.mjs} +1 -1
- package/lib/{chunk-7ZBDACVG.mjs → chunk-OUZQPYT3.mjs} +1 -1
- package/lib/chunk-OVNMB6Q2.mjs +7 -0
- package/lib/{chunk-DKDKCGXV.mjs → chunk-PAXNWTYK.mjs} +1 -1
- package/lib/{chunk-GLN4PI5P.mjs → chunk-PBY2O6OF.mjs} +1 -1
- package/lib/chunk-PEDQPM2P.mjs +926 -0
- package/lib/chunk-PH7SP4YK.mjs +21 -0
- package/lib/{chunk-BT43WSOS.mjs → chunk-PMN4PAC3.mjs} +1 -1
- package/lib/chunk-PMWAFDUB.mjs +48 -0
- package/lib/chunk-PPLVFX6N.mjs +7 -0
- package/lib/{chunk-L3I6DAHX.mjs → chunk-PR3XCSPO.mjs} +1 -1
- package/lib/{chunk-WZN36ACK.mjs → chunk-PR42EZSR.mjs} +1 -1
- package/lib/{chunk-NDFFIJL5.mjs → chunk-PWRJRL5U.mjs} +1 -1
- package/lib/{chunk-NS6ONPWL.mjs → chunk-Q7GIJBCD.mjs} +1 -1
- package/lib/chunk-Q7TLC3I2.mjs +7 -0
- package/lib/{chunk-ALBY5SOH.mjs → chunk-QAFPQ3YB.mjs} +1 -1
- package/lib/{chunk-KKS2KFBT.mjs → chunk-QKEKG2LD.mjs} +1 -1
- package/lib/{chunk-OOIDCHBQ.mjs → chunk-QO53K5W2.mjs} +2 -2
- package/lib/{chunk-HVX2AFYW.mjs → chunk-QTG6LUZT.mjs} +1 -1
- package/lib/{chunk-K7G3W7XH.mjs → chunk-RE7RYF3B.mjs} +1 -1
- package/lib/{chunk-JIPT5FUD.mjs → chunk-RGBGUCJA.mjs} +1 -1
- package/lib/{chunk-GT5ZKU6V.mjs → chunk-RGUQOSBU.mjs} +1 -1
- package/lib/{chunk-VXZ5PTOM.mjs → chunk-RHNTHGNU.mjs} +1 -1
- package/lib/chunk-RKTFFCNS.mjs +7 -0
- package/lib/chunk-RMFU4BAL.mjs +28 -0
- package/lib/{chunk-DNQKVCUV.mjs → chunk-ROV3QXEF.mjs} +11 -11
- package/lib/chunk-RT47RKLY.mjs +7 -0
- package/lib/{chunk-ISOSTAJR.mjs → chunk-S42RBRH2.mjs} +1 -1
- package/lib/{chunk-27BBEGUD.mjs → chunk-SI267LYR.mjs} +1 -1
- package/lib/chunk-T3G6VZNS.mjs +7 -0
- package/lib/chunk-TNT27RBG.mjs +7 -0
- package/lib/chunk-UBIKR5VO.mjs +7 -0
- package/lib/chunk-UI3JQVRU.mjs +8 -0
- package/lib/{chunk-RVCPQVKM.mjs → chunk-UIOMAX56.mjs} +1 -1
- package/lib/chunk-UX3BVH2Y.mjs +7 -0
- package/lib/{chunk-L4RJX7DG.mjs → chunk-VCUXCK36.mjs} +1 -1
- package/lib/chunk-VINGECAJ.mjs +10 -0
- package/lib/chunk-VOXJHJIE.mjs +7 -0
- package/lib/chunk-W6PN6TJG.mjs +7 -0
- package/lib/{chunk-D6JT4PAB.mjs → chunk-WAPSSYMT.mjs} +1 -1
- package/lib/{chunk-7BQMBXKX.mjs → chunk-WUUKFE2U.mjs} +1 -1
- package/lib/chunk-WWTCWWZI.mjs +7 -0
- package/lib/chunk-WXDLQT2O.mjs +10 -0
- package/lib/{chunk-TCEXCHXR.mjs → chunk-WY5V5PR3.mjs} +1 -1
- package/lib/chunk-X4BXESMQ.mjs +7 -0
- package/lib/chunk-XBQGZGWR.mjs +7 -0
- package/lib/{chunk-AXFD2OH6.mjs → chunk-XGGOUNPP.mjs} +1 -1
- package/lib/chunk-XKWW3GKF.mjs +7 -0
- package/lib/{chunk-PDRXM5WN.mjs → chunk-Y2DRK37K.mjs} +1 -1
- package/lib/{chunk-ZXOUWHYE.mjs → chunk-YA6ATMTB.mjs} +1 -1
- package/lib/{chunk-54HYHHVL.mjs → chunk-YDXMTWAT.mjs} +1 -1
- package/lib/chunk-YHR4WQPR.mjs +7 -0
- package/lib/{chunk-LWES2KZE.mjs → chunk-YTLUYSMF.mjs} +1 -1
- package/lib/{chunk-2K5BYZQM.mjs → chunk-YWEQQL3C.mjs} +1 -1
- package/lib/{chunk-C6RKM4BB.mjs → chunk-Z4LKKOFY.mjs} +1 -1
- package/lib/chunk-ZBAWJUG2.mjs +7 -0
- package/lib/{chunk-446GBKAC.mjs → chunk-ZJW6YOMV.mjs} +1 -1
- package/lib/chunk-ZQQXSCVI.mjs +7 -0
- package/lib/{chunk-L6CLN664.mjs → chunk-ZQWIVYVM.mjs} +1 -1
- package/lib/{chunk-CXKZ6TYV.mjs → chunk-ZV7ZFQQC.mjs} +1 -1
- package/lib/sandforge-autopilot.mjs +25 -25
- package/lib/sandforge-backup.mjs +1 -1
- package/lib/sandforge-checkpoint.mjs +1 -1
- package/lib/sandforge-cleanup.mjs +1 -1
- package/lib/sandforge-clone.mjs +1 -1
- package/lib/sandforge-compare.mjs +52 -21
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +1 -1
- package/lib/sandforge-env.mjs +95 -95
- package/lib/sandforge-frozen.mjs +1 -1
- package/lib/sandforge-mcp.mjs +12 -12
- package/lib/sandforge-monitor.mjs +1 -1
- package/lib/sandforge-pipeline.mjs +1 -1
- package/lib/sandforge-seed.mjs +1 -1
- package/lib/sandforge-sync.mjs +1 -1
- package/lib/sandforge-users.mjs +1 -1
- package/lib/sandforge.mjs +1 -1
- package/lib/sf/sandforge/compare.mjs +2 -2
- package/lib/sfPlugin.mjs +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/lib/chunk-2ADSD5WK.mjs +0 -7
- package/lib/chunk-2GSMHGIV.mjs +0 -7
- package/lib/chunk-36Y225OM.mjs +0 -7
- package/lib/chunk-3OVTKRS4.mjs +0 -7
- package/lib/chunk-4GCYGQXD.mjs +0 -7
- package/lib/chunk-4JKR4PTZ.mjs +0 -8
- package/lib/chunk-5OGNK3JP.mjs +0 -37
- package/lib/chunk-6QSHWIZI.mjs +0 -48
- package/lib/chunk-77IVKH7R.mjs +0 -7
- package/lib/chunk-77MZRBWX.mjs +0 -7
- package/lib/chunk-7WSQ65WG.mjs +0 -9
- package/lib/chunk-A32ISQ6M.mjs +0 -28
- package/lib/chunk-AG24QMSY.mjs +0 -7
- package/lib/chunk-BH76USTQ.mjs +0 -11
- package/lib/chunk-BZ24IAP5.mjs +0 -7
- package/lib/chunk-CN5HGFG4.mjs +0 -7
- package/lib/chunk-CTPLYUXA.mjs +0 -7
- package/lib/chunk-DIGUC7S4.mjs +0 -341
- package/lib/chunk-DSR2MSBH.mjs +0 -7
- package/lib/chunk-ETNQHIDI.mjs +0 -9
- package/lib/chunk-FBXH4VRQ.mjs +0 -7
- package/lib/chunk-FYWNSMOZ.mjs +0 -10
- package/lib/chunk-GEEWPTV5.mjs +0 -7
- package/lib/chunk-GTRU5AV5.mjs +0 -7
- package/lib/chunk-I3ZO76LL.mjs +0 -21
- package/lib/chunk-ISA2NYJV.mjs +0 -7
- package/lib/chunk-IXIY6Q4M.mjs +0 -7
- package/lib/chunk-JAV6F6OA.mjs +0 -7
- package/lib/chunk-JYUMD357.mjs +0 -7
- package/lib/chunk-L47JCNP3.mjs +0 -7
- package/lib/chunk-LI2XNV7F.mjs +0 -7
- package/lib/chunk-LP2D3JJP.mjs +0 -7
- package/lib/chunk-LYOGCIYD.mjs +0 -925
- package/lib/chunk-N5UIE4IR.mjs +0 -7
- package/lib/chunk-O7GCCRPW.mjs +0 -7
- package/lib/chunk-OO24ZYYJ.mjs +0 -7
- package/lib/chunk-OS6HFJ7L.mjs +0 -7
- package/lib/chunk-P6WRYJN3.mjs +0 -7
- package/lib/chunk-PGRY365W.mjs +0 -7
- package/lib/chunk-PPGDAUEQ.mjs +0 -7
- package/lib/chunk-Q4PPI3KG.mjs +0 -7
- package/lib/chunk-QFTF2PGS.mjs +0 -21
- package/lib/chunk-QO4MPHZD.mjs +0 -7
- package/lib/chunk-QXB6U3ZP.mjs +0 -7
- package/lib/chunk-R3OM3X4L.mjs +0 -8
- package/lib/chunk-R7GKMAT4.mjs +0 -7
- package/lib/chunk-SCKUIE3R.mjs +0 -7
- package/lib/chunk-SU65Z2BA.mjs +0 -7
- package/lib/chunk-T7DDS4UQ.mjs +0 -7
- package/lib/chunk-TQJ5NPRC.mjs +0 -7
- package/lib/chunk-VZLJZEV2.mjs +0 -7
- package/lib/chunk-W3BQGMTR.mjs +0 -7
- package/lib/chunk-WXU6ZJIV.mjs +0 -7
- package/lib/chunk-X4HZD5U2.mjs +0 -7
- package/lib/chunk-X6XNTOGO.mjs +0 -7
- package/lib/chunk-XMQ5R6TC.mjs +0 -10
- package/lib/chunk-XPXEQKLR.mjs +0 -7
- package/lib/chunk-YBZIDW6W.mjs +0 -7
- package/lib/chunk-ZCOSME6P.mjs +0 -7
- package/lib/chunk-ZTHC42X6.mjs +0 -7
|
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{q as
|
|
7
|
+
import{q as It}from"./chunk-CBH3TOWK.mjs";import{a as Bt,b as pe,c as Ut,e as Wt,f as Pe,g as Gt,h as qt,i as Vt,j as Kt,k as he,l as me,m as Ht}from"./chunk-B3FBHVNN.mjs";import{e as Mt,g as _t}from"./chunk-LA4KIATH.mjs";import{f as Pt,h as xt}from"./chunk-Y2DRK37K.mjs";import{a as Dt}from"./chunk-LKTNQEBS.mjs";import{a as Xt}from"./chunk-TW3N6W5Z.mjs";import{Eb as Nt,Xa as oe,c as Le,d as je,e as At,f as $t,h as kt,i as Ne,j as Rt,k as St,l as Ot,m as Et,mb as Ie,nb as zt,q as Tt,qb as De,rb as fe,tb as Ct,ub as ne,yb as Lt,zb as jt}from"./chunk-PEDQPM2P.mjs";import{a as te,d as wt,j as Ce}from"./chunk-2METQHGG.mjs";import{b as de,e as at}from"./chunk-RKTFFCNS.mjs";import{c as ee,d as ue}from"./chunk-6FARZYMJ.mjs";import{b as le}from"./chunk-XGGOUNPP.mjs";import{a as vt,b as bt}from"./chunk-QROPNEGY.mjs";import{n as yt}from"./chunk-IVFVNNGB.mjs";import{d as lt}from"./chunk-T63U4OZJ.mjs";import{a as ke}from"./chunk-AL4C3GFT.mjs";import{b as st,c as Se}from"./chunk-OUZQPYT3.mjs";import{Dc as ht,Sc as mt,Tc as gt,i as Ee,l as Fe,m as Te,mb as ze,pb as ce,s as Z,sb as ft,tb as pt,wc as J}from"./chunk-KB4ZHM4Q.mjs";import{q as ct}from"./chunk-3Q353S2R.mjs";import{h as ut}from"./chunk-CVHNXJH3.mjs";import{b as rt,f as it,g as dt,h as Ft}from"./chunk-LCDPCUXS.mjs";import{E as Oe}from"./chunk-TNT27RBG.mjs";import{Wc as et,Wd as tt,Xd as Re,Yd as ie,Zd as ot,ee as nt}from"./chunk-PMWAFDUB.mjs";import{existsSync as _e,mkdirSync as go,readdirSync as wo,readFileSync as ve}from"node:fs";import{dirname as yo,join as V}from"node:path";import{homedir as vo}from"node:os";var bo=`sandforge frozen \u2014 build and replay a Frozen Dataset, without the editor.
|
|
8
8
|
|
|
9
9
|
Usage:
|
|
10
10
|
npx sandforge frozen <step> --config <file> [options]
|
|
@@ -114,7 +114,7 @@ Options:
|
|
|
114
114
|
keeps quiet what tests the org's bypass; what an Apex
|
|
115
115
|
trigger sends is read nowhere. --dry-run says it all,
|
|
116
116
|
and what a load would be refused for
|
|
117
|
-
${
|
|
117
|
+
${At({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."]})}
|
|
118
118
|
--include-changed remove also the records changed since the load, and what
|
|
119
119
|
was added to them since (kept otherwise); with load
|
|
120
120
|
--reload --sweep, the sweep of each load replaced takes
|
|
@@ -241,10 +241,10 @@ of the load or its sweep did not take all it was asked to; 4 verify's verdict is
|
|
|
241
241
|
UNSTABLE: no two readings agreed; 130 Ctrl-C stopped the step, 143 a SIGTERM, 129 a
|
|
242
242
|
SIGHUP. A load is judged by its own report, which ends partial on a verification
|
|
243
243
|
FAILED or PARTIAL; one UNSTABLE is said, and the verify step gives it a code.
|
|
244
|
-
`,
|
|
244
|
+
`,Zt=["select","extract","load","verify","remove","status"],Ao={words:1,switches:["--pilot","--reload","--dry-run","--write-encrypted","--mute-automation","--accept-automation","--include-changed","--accept-emails","--sweep","--sweep-list",...Lt,"--preview","--yes","--json",...je.switches],values:["--config","--source","--target","--author","--salt-file","--store","--max-total","--gone-first",...je.values]},Jt=1e6;function $o(e){let t;try{t=JSON.parse(ve(e,"utf8"))}catch(o){process.stderr.write(`--gone-first: ${e} does not read: ${String(o)}
|
|
245
245
|
`),process.exit(2)}return(!Array.isArray(t)||!t.every(o=>typeof o=="string"&&/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(o)))&&(process.stderr.write(`--gone-first: ${e} holds no JSON array of record ids.
|
|
246
|
-
`),process.exit(2)),t}function
|
|
247
|
-
`),process.exit(2)),rt(t,
|
|
246
|
+
`),process.exit(2)),t}function ko(e){let t=e.slice(2);(t.includes("--help")||t.includes("-h")||t.length===0)&&(process.stdout.write(bo),process.exit(0));let o=p=>{let g=t.indexOf(p);return g>=0&&g+1<t.length?t[g+1]:void 0},n=t[0];Zt.includes(n)||(process.stderr.write(`The first word is the step: ${Zt.join(", ")} \u2014 not "${t[0]}".
|
|
247
|
+
`),process.exit(2)),rt(t,Ao);let s=o("--config");s||(process.stderr.write(`Missing --config. Run with --help.
|
|
248
248
|
`),process.exit(2));let i=o("--source"),m=o("--target");(n==="select"||n==="extract")&&!i&&(process.stderr.write(`${n} reads the source org: give --source.
|
|
249
249
|
`),process.exit(2)),(n==="load"||n==="verify"||n==="remove")&&!m&&(process.stderr.write(`${n} works on the target org: give --target.
|
|
250
250
|
`),process.exit(2)),t.includes("--sweep")&&t.includes("--sweep-list")&&(process.stderr.write(`--sweep deletes and --sweep-list only lists: give one of them. Run with --help.
|
|
@@ -257,16 +257,16 @@ FAILED or PARTIAL; one UNSTABLE is said, and the verify step gives it a code.
|
|
|
257
257
|
`),process.exit(2)),t.includes("--accept-emails")&&n!=="load"&&(process.stderr.write(`--accept-emails goes with load. Run with --help.
|
|
258
258
|
`),process.exit(2)),t.includes("--mute-automation")&&n!=="load"&&n!=="remove"&&(process.stderr.write(`--mute-automation goes with load or remove. Run with --help.
|
|
259
259
|
`),process.exit(2)),t.includes("--accept-automation")&&n!=="remove"&&n!=="load"&&(process.stderr.write(`--accept-automation goes with load or remove. Run with --help.
|
|
260
|
-
`),process.exit(2)),t.includes(
|
|
261
|
-
`),process.exit(2));let d
|
|
260
|
+
`),process.exit(2)),t.includes(Le)&&n!=="load"&&(process.stderr.write(`${Le} goes with load. Run with --help.
|
|
261
|
+
`),process.exit(2));let d=$t(t);t.includes("--preview")&&n!=="remove"&&(process.stderr.write(`--preview goes with remove${n==="load"?"; a load says what it would do with --dry-run":""}. Run with --help.
|
|
262
262
|
`),process.exit(2)),t.includes("--preview")&&t.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.
|
|
263
263
|
`),process.exit(2));let a=jt(t);"refusal"in a&&(process.stderr.write(`${a.refusal} Run with --help.
|
|
264
264
|
`),process.exit(2));let l;if(t.includes("--max-total")){let p=o("--max-total");l=Number(p),n!=="load"&&(process.stderr.write(`--max-total goes with load. Run with --help.
|
|
265
|
-
`),process.exit(2)),(p===void 0||!/^\d+$/.test(p)||l<1||l>
|
|
266
|
-
`),process.exit(2))}return{step:n,configPath:s,source:i,target:m,author:o("--author"),storePath:o("--store"),saltFile:o("--salt-file"),pilot:t.includes("--pilot"),reload:t.includes("--reload"),dryRun:t.includes("--dry-run"),writeEncrypted:t.includes("--write-encrypted"),muteAutomation:t.includes("--mute-automation"),acceptAutomation:t.includes("--accept-automation"),...d!==void 0?{checkpointFirst:d}:{},includeChanged:t.includes("--include-changed"),acceptEmails:t.includes("--accept-emails"),sweep:t.includes("--sweep"),sweepList:t.includes("--sweep-list"),...a,preview:t.includes("--preview"),...l!==void 0?{maxTotal:l}:{},...r!==void 0?{goneFirst:r}:{},yes:t.includes("--yes"),json:t.includes("--json")}}async function ko(e){let o=(await e.query("SELECT Id, IsSandbox FROM Organization LIMIT 1")).records[0];if(!o)throw new Error("The org gave no Organization record.");if(o.IsSandbox)return{id:o.Id,orgType:"Sandbox"};try{let s=(await e.query("SELECT OrganizationType FROM Organization LIMIT 1")).records[0]?.OrganizationType;return typeof s=="string"&&s!==""?{id:o.Id,orgType:et({isSandbox:!1,edition:s}),edition:s}:{id:o.Id,orgType:"Production"}}catch{return{id:o.Id,orgType:"Production"}}}async function Jt(e,t,o,n){let s=await st(e),i=Se(s),m;try{m=await ko(i)}catch(r){let d=r instanceof Error?r.message:String(r);throw new Error(`Could not read the Organization record of '${e}': ${d}`)}return t.set(m.id,{org:{id:m.id,alias:e,orgType:m.orgType,metadata:{apiVersion:"66.0",...m.edition?{edition:m.edition}:{}},username:s.username,instanceUrl:s.instanceUrl},credentials:{accessToken:s.accessToken,instanceUrl:s.instanceUrl}}),o?.set(m.id,i),n?.set(m.id,{session:s,typed:m}),m.id}var x={run:"load",done:"loaded",source:"the frozen dataset",recordedIn:"in this sas",remove:"`remove`",module:"frozen",again:"reload",againSubject:{purge:"reload",sweep:"reloadSweep"},maybeMasks:"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 We(e){return!e||e.length===0?[]:[`kept: the platform does not delete them \u2014 ${e.map(({objectApiName:o,count:n})=>`${o} (${n})`).join(", ")}`]}function Qt(e,t,o=x){let n=(e??[]).filter(i=>i.reason==="may-hold-masks");if(n.length===0)return[];let s=n.map(({objectApiName:i,field:m,affectedRecords:r})=>`${i}.${m} (${r})`).join(", ");return[`${t} out, encrypted in the target: ${s} \u2014 ${o.maybeMasks}`]}function Ro(e,t){let o=e==="token"?"each record its own, from the token the value carries":`each record its own, its rank appended: the field is ${e==="unique"?"unique in the target":"the record name"}`;return t===void 0?o:`${o} (first: "${t}")`}function Ge(e){return e.created.reduce((t,o)=>t+o.count,0)}function So(e){return{...e.includeChanged?{includeChanged:!0}:{},...e.sweep?{sweep:!0}:{},...e.sweepLate?{sweepLate:!0}:{},...e.sweepUntied?{sweepUntied:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{}}}var Oo={removal:{heading:"removal",writer:"this removal",verb:"remove"},reload:{heading:"reload",writer:"this reload's purge",verb:"reload"},reloadSweep:{heading:"reload",writer:"this reload's sweep",verb:"reload"},replayAgain:{heading:"replay",writer:"this replay's purge",verb:"replay again"},replayAgainSweep:{heading:"replay",writer:"this replay's sweep",verb:"replay again"}};function xe({read:e,steps:t,mute:o},n,s="removal",i){let m=o?Z(o.muted,n).map(l=>` ${l}`):[];if(!("objects"in e)){let l=Oo[s],p=s==="reload"||s==="replayAgain",g=`${l.writer}${p&&i?" and its sweep":""}`;return{lines:[`${l.heading} automation: what ${n} runs could not be read: ${e.unread}`,...m],refusal:`What ${n} runs as ${g} writes could not be read (${e.unread}), so what fires as the records go is not known. Nothing was written or deleted. Add --accept-automation to ${l.verb} all the same, or turn that automation off in ${n} first.`}}let r=o?.automation??e,d=i?tt(t,i.delete??[]):t,a=mt(r,n,{steps:t,...i?{sweep:i}:{},assign:pt(r,ot(r,d)),mayMute:o===void 0&&Ce("--mute-automation"),subject:s});return{lines:[...ht(e,n,t,s,i),...m],...a!==void 0?{refusal:a}:{}}}function Eo(e,t,o=x){let n=Ge(e),s=e.earlier?`a ${o.run} before the last one, whose records the ${o.run}s after it left in place,`:`the last ${o.run}`,i=`a removal deletes the ${n} record(s) it created, children first:`;return e.removed&&n===0?i=`its records were removed on ${e.removed.removedAt}, and none is left to remove`:n===0&&(e.keptByThePlatform?.length??0)>0?i="it created no record a removal takes":e.removed&&(i=`the removal of ${e.removed.removedAt} left ${n} of the records it created, and a removal deletes those, children first:`),[`${s} wrote to ${t} at ${e.loadedAt}; ${i}`,...e.created.map(m=>` ${m.objectApiName}: ${m.count}`),`${e.linked} record(s) it linked to or reused stay`,...We(e.keptByThePlatform)]}function Fo(e,t){return e.recorded&&(Ge(e)>0||(t?.delete??[]).length>0)}function To(e){return[e.deleted>0?`${e.deleted} deleted`:"",e.alreadyGone>0?`${e.alreadyGone} already gone`:"",e.keptChanged>0?`${e.keptChanged} kept, changed since the load`:"",e.keptDependents>0?`${e.keptDependents} kept for records that stay`+(e.heldBy.length>0?` (${e.heldBy.join(", ")})`:""):"",e.refused>0?`${e.refused} refused`:"",(e.notReached??0)>0?`${e.notReached} not reached`:""].filter(Boolean).join(", ")}function zo(e,t=x){let o=e.count>e.names.length?", \u2026":"";return`${e.count} file(s) attached to them stay in the org, as the ${t.run} did not create them: ${e.names.join(", ")}${o}`}function Yt(e){return`graph: ${e.objects} object(s) at a cap of ${e.maxNodes}`+(e.objects>e.maxNodes?" (raised for the parents their records cannot be written without)":"")+(e.truncated?" \u2014 TRUNCATED: objects further out were not read":"")}function eo(e){return"reusedFrom"in e?`graph reused from ${e.reusedFrom} (discovered ${e.discoveredAt}): the source's schema has not changed since`:`rediscovered: ${e.rediscovered}`}function Co(e){switch(e.phase){case"discovery":return` discovery: ${e.objects??0} object(s) reached`;case"axis":return` listing the values of axis ${e.axis??"?"}\u2026`;case"combination":return` combination ${e.index??"?"}/${e.of??"?"}: ${e.combinationKey??"?"}`;case"candidate":return` candidate ${e.candidate??"?"}/${e.candidates??"?"} of ${e.combinationKey??"?"}: measuring its own records\u2026`;case"measure":return` measuring the ${e.roots??0} root(s) kept, together\u2026`}}function jo(e){let t=e.reason==="timeout"?"its time ran out":"it was cancelled",o=e.during==="axes"?"while it listed the axis values":e.during==="measure"?"while it measured the roots it kept":`while it probed ${e.combinationKey??"?"}`+(e.candidate!==void 0?`, candidate ${e.candidate} of ${e.candidates??"?"}`:"");return[`STOPPED: ${t} ${o}; the combinations decided before are kept`,...e.notProbed.length>0?[` never probed: ${e.notProbed.join(", ")}`]:[]]}var Lo=new Set(["NO_LOAD","ALREADY_REMOVED","NOTHING_TO_REMOVE"]),uo="REMOVAL_DECLINED",to=["MUTE_PRODUCTION","MUTE_NO_RIGHT","MUTE_FAILED"],No=new Map([["frozen:load:error",new Set(["EMAILS_NOT_ACCEPTED","FROZEN_EMAILS_EXCEEDED",ze,"FROZEN_STORAGE_EXCEEDED","AUTOMATION_NOT_ACCEPTED",le.code,...to])],["frozen:remove:error",new Set(["AUTOMATION_NOT_ACCEPTED","GUARD_BLOCKED","GUARD_DECLINED",le.code,...to])]]);function Be(e){let t=e.payload?.code,o=No.get(String(e.type??""));if(!(typeof t!="string"||o?.has(t)!==!0))return{code:t,message:String(e.payload?.message??"")}}function Ue(e){let t=String(e.type??"");if(!t.endsWith(":error")||t==="frozen:remove:automation:error")return!1;let o=String(e.payload?.code);return t==="frozen:remove:error"&&o===uo?!1:!((t==="frozen:remove:error"||t==="frozen:remove:preview:error")&&Lo.has(o))}var oo={passed:0,partial:3,unstable:4,failed:1};function Io(e,t,o){return async(n,s)=>{let i=Date.parse(s?.first??""),m=Math.max(i,Date.parse(s?.last??""));return!Number.isFinite(i)||!Number.isFinite(m)?[]:[...(await Lt({organizationId:n,alias:e,span:{from:i,to:m},own:{ids:[]},...t!==void 0?{journalDir:t}:{}})).map(({ids:d})=>({ids:d,from:i,to:m})),...Gt(Vt(t??te(),n),{sasMark:o,own:[]})]}}function Do(e,t){return dt(t.map(o=>{let n=o.payload??{};if(e==="verify"&&o.type==="frozen:verify:result"){let s=String(n.verdict?.status??"");return Object.prototype.hasOwnProperty.call(oo,s)?oo[s]:1}if(e==="load"&&o.type==="frozen:load:response"){let s=n.report,i=n.replay?.summary.records.refusedBeforeWrite;return s?.status==="completed"&&(s.sweeps??[]).every(m=>m.result.status==="success")&&(i??0)===0?0:3}return e==="remove"&&o.type==="frozen:remove:response"?n.result?.status==="success"?0:3:0}))}function Po(e,t){return` data storage: about ${J(e.estimateMB)} MB`+(e.automationMB!==void 0&&e.automationMB>0?`, about ${J(e.automationMB)} MB of it for what the target's automation creates under them,`:"")+` of the ${J(e.remainingMB)} MB ${t} has left of ${J(e.maxMB)} MB`+(e.freedMB!==void 0?`, and the reload's purge frees about ${J(e.freedMB)} MB first`:"")}function no(e,t){return Ft(e.verdict==="unread"?{verdict:"unread",estimate:e.estimate,unread:e.unread??"not said"}:{verdict:e.verdict,estimate:e.estimate,remaining:e.remaining??0,max:e.max??0},t)}function xo(e){return(e.filter(o=>o.type==="frozen:remove:response").at(-1)?.payload?.result?.objects??[]).some(o=>o.deleted+o.alreadyGone>0)}function ge(e,t){if(gt()!==void 0)return De(e);let o=t.remove.replace(/`/g,"");return e==="--sweep"||e==="--sweep-list"?`${o} ${e}`:`${o} --sweep ${e}`}function Mo(e,t=x){if(!e||e.found.length===0)return[];let o=e.found.reduce((l,p)=>l+p.count,0),n=e.found.some(l=>l.overBound)?" or more":"",s=l=>e.found.reduce((p,g)=>p+(g.classes?l(g.classes):0),0),i=s(l=>l.made+l.madeOver),m=s(l=>l.late),r=s(l=>l.untied),d=e.found.filter(l=>l.overBound).map(l=>l.objectApiName),a=[...i>0?[`${ge("--sweep",t)} takes the ${i} tied to the ${t.run}`]:[],...m>0?[`${ge("--sweep-late",t)} takes the ${m} made late`]:[],...r>0?[e.untied?.refusal!==void 0?`the ${r} tied to nothing of the ${t.run} now stay: --sweep-untied is refused (${e.untied.refusal})`:`${ge("--sweep-untied",t)} takes the ${r} tied to nothing of the ${t.run} now`]:[],...d.length>0?[`no sweep takes those of ${d.join(", ")}, past its bound`]:[]];return[`not swept: ${o}${n} record(s) the ${t.run}'s user created in its window stay, what the target's automation made for the ${t.run} likely: `+e.found.map(l=>`${l.objectApiName}: ${l.count}`).join(", "),...a.map(l=>` ${l}`),` ${ge("--sweep-list",t)} names them first: a record made by hand as that user in the ${t.run}'s window reads as the automation's, so check the names before a sweep`]}function _o(e,t={},o=x){let n=String(e.type??""),s=e.payload??{},i=n.replace(/^frozen:/,`${o.module}:`),m=o===x?"load":"run";if((n==="frozen:remove:error"||n==="frozen:remove:preview:error")&&!Ue(e))return[`nothing to remove: ${String(s.message??"")}`];if(n==="frozen:remove:error"&&!Ue(e))return[String(s.message??"")];if(n==="frozen:remove:automation:error")return[];if(n.endsWith(":error")){let r=n==="frozen:load:error"?s.sweeps??[]:[],d=n==="frozen:load:error"?s.emails:void 0,a=n==="frozen:load:error"?s.automation:void 0,l=n==="frozen:load:error"?s.mutedAutomation:void 0,p=Be(e);return[...p?[]:[`! ${i}: ${String(s.message??"")}${s.code?` [${String(s.code)}]`:""}`],...a?me(a,"the target"):[],...d?he(d,"the target"):[],...l?Z(l,"the target"):[],...r.length>0?[`before the ${o.run} ended, its sweep had already done this:`]:[],...r.flatMap(({loadedAt:g,result:y})=>[`sweep of the ${o.run} of ${g}:`,...ne(y)]),...p?[ee(p)]:[]]}switch(n){case"frozen:select:progress":return[Co(s)];case"frozen:select:response":{let r=s.selection;return[`selected ${r.combinations.length} root(s): ${r.combinations.map(d=>d.combinationKey).join(", ")}`,...r.uncovered.map(d=>` uncovered ${d.combinationKey}: ${d.reason}`),...r.stopped?jo(r.stopped):[],...r.discovery?[eo(r.discovery)]:[],...r.graph?[Yt(r.graph)]:[],`volumetry ${r.volumetry.total} / ${r.volumetry.budgetMax} record(s)`+(r.volumetry.summed?" \u2014 each kept root's own records added up: they were not measured together":""),...Object.entries(r.volumetry.measured).filter(([,d])=>d>0).map(([d,a])=>` ${d}: ${a}`)]}case"frozen:control:result":{let r=s.report;return[`non-reidentification control: ${r.passed?"PASSED":"FAILED"}`,...r.checks.map(d=>` ${d.passed?"ok ":"FAIL"} ${d.name}`+(d.violations.length>0?` (${d.violations.length} violation(s))`:""))]}case"frozen:extract:response":{let r=s.manifest,d=s.discovery;return[`frozen ${String(s.recordCount)} record(s) as version ${r.version} in ${String(s.datasetDir)}`,...d?[eo(d)]:[],...r.coverage?[Yt(r.coverage)]:[],...r.coverage&&r.coverage.unboundedObjects.length>0?[`read without the time bound: ${r.coverage.unboundedObjects.join(", ")}`]:[],...(r.coverage?.leftToThePlatform??[]).map(a=>`${a.objectApiName}: ${a.note}`),...(r.coverage?.exclusionCosts??[]).map(a=>`${a.objectApiName}: ${a.note}`),...(r.coverage?.requiredLeftEmpty??[]).length>0?[`required in the source and left empty by the rules \u2014 a load will ask a value for each: ${(r.coverage?.requiredLeftEmpty??[]).join(", ")}`]:[],...(r.coverage?.keptWithoutARule??[]).length>0?["kept without a rule, the platform's own words: "+(r.coverage?.keptWithoutARule??[]).join(", ")]:[],...(r.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: "+(r.coverage?.encryptedNotKept??[]).join(", ")]:[],...Object.entries(r.volumetry.measured).filter(([,a])=>a>0).map(([a,l])=>` ${a}: ${l}`)]}case"frozen:load:response":{let r=s.report,d=[`${o.run}: ${r.status} in ${r.durationMs}ms \u2014 ${r.alignment.excludedObjects.length} object(s) excluded, ${r.alignment.removals.length} field removal(s), ${r.alignment.recordTypeIssues.length} record type issue(s), ${r.placeholders.length} placeholder(s)`];for(let f of r.alignment.excludedObjects)d.push(` ${f.objectApiName}: not ${o.done} \u2014 ${f.reason}`);d.push(...Qt(r.alignment.removals,"left",o));for(let f of r.perObject){let S=f.writtenByThePlatform??0;d.push(` ${f.objectApiName}: ${f.inserted} inserted, ${f.reused} reused`+(S>0?` (${S} written by the platform with ${Oe(f.objectApiName)})`:"")+`, ${f.skippedDuplicates.length} duplicate(s), ${f.failed.length} failed of ${f.fromFiles}`);let P=f.failed[0];P&&d.push(` first refusal: ${P.errors?.[0]??P.error??"?"}`)}for(let f of[...r.leftToThePlatform??[],...r.untypedFeedItems??[],...r.heldForExcludedParents??[],...r.quotesLeftUnsynced??[],...r.keysLeftEmpty??[]])d.push(` ${f.objectApiName}: ${f.note}`);let a=r.perObject.filter(f=>(f.writtenWithoutFields?.fields.length??0)>0);if(a.length>0){d.push(`written again without a field a validation rule or a restricted picklist refused (${a.length} object(s)):`);for(let{objectApiName:f,writtenWithoutFields:S}of a)for(let{field:P,refusedBy:q,reason:V,rows:Ve,replacedWith:se}of S?.fields??[]){let Q=q==="restricted-picklist"?"a restricted picklist refused its value":"a validation rule refused it",j=se===void 0?"":` \u2014 written with "${se}", as its picklist rule declares`;d.push(` ${f}.${P} ${Ve} record(s) \u2014 ${Q}${j} \u2014 ${V}`)}}d.push(`pass 2: ${r.pass2.resolved} resolved, ${r.pass2.unresolved.length} unresolved`);for(let f of r.pass2.unresolved.slice(0,5))d.push(` ${f.objectApiName}.${f.field}: ${f.detail}`);let l=r.personContact,p=l?.sent??[];if(l&&l.restored+p.length+l.unresolved.length>0){d.push(`person contacts: ${l.restored} linked, ${p.length} sent as contacts of their own, ${l.unresolved.length} not linked`);for(let f of p.slice(0,5))d.push(` ${f.contactReferenceId} sent: ${f.detail}`);for(let f of l.unresolved.slice(0,5))d.push(` ${f.contactReferenceId}: ${f.detail}`)}if(r.statuses&&r.statuses.restored+r.statuses.refused.length>0){d.push(`statuses applied after insert: ${r.statuses.restored}, refused ${r.statuses.refused.length}`);for(let f of r.statuses.refused.slice(0,5))d.push(` ${f.objectApiName} \u2192 ${f.status}: ${f.detail}`)}let g=f=>Object.values(f).reduce((S,P)=>S+P,0),y=g(r.purge.deleted),z=g(r.purge.deactivated??{});if(y+z+r.purge.failures.length>0){d.push(`purge of earlier ${o.run}s: ${y} deleted, ${z} deactivated, ${r.purge.failures.length} failed`);for(let f of r.purge.failures.slice(0,5))d.push(` ${f.objectApiName}: ${f.errors[0]??"?"}`)}for(let[f,S]of Object.entries(r.purge.cameAlong??{}))d.push(` ${f}: took along ${S.count} record(s) the ${o.run}s did not write that came with their records, made as they wrote: ${S.objects.join(", ")}`);let M=Object.entries(r.purge.leftUnrecorded??{});if(M.length>0){d.push("left in place, of a load recorded before loads kept what they created \u2014 it may have linked them:");for(let[f,S]of M)d.push(` ${f}: ${S}`)}let C=Object.entries(r.purge.keptByThePlatform??{});if(C.length>0){d.push("kept by the purge, the platform does not delete them:");for(let[f,S]of C)d.push(` ${f}: ${S}`)}for(let f of s.report.sweeps??[]){d.push(`sweep of the ${o.run} of ${f.loadedAt}:`,...ne(f.result));let S=f.result.objects.reduce((P,q)=>P+q.keptChanged,0);S>0&&d.push(` ${S} record(s) kept, changed since that ${o.run}: `+(o===x?"load --reload --sweep --include-changed, or remove --sweep --include-changed, ":`${o.remove} --sweep --include-changed `)+"takes them")}let F=s.report.mutedAutomation;F&&d.push(...Z(F,"the target"));let D=s.report.automation;D&&d.push(...me(D,"the target"));let u=s.report.emails;u&&d.push(...he(u,"the target"));let $=s.report.apiRequests;return $&&d.push(no($,"the target")),d.push(...lo(s.report.recordTypesGiven,!1)),d}case"frozen:load:preview:response":{let r=s.plan,d=u=>r.perObject.reduce(($,f)=>$+u(f),0),a=[`dry run${r.mode.pilot?" (pilot)":""}${r.mode.reload?` (${o.again})`:""}: ${d(u=>u.toInsert)} record(s) to insert, ${d(u=>u.reusedByKeys+u.reusedFromCatalog+(u.writtenByThePlatform??0))} to link, ${d(u=>u.notSent)} not sent`+(r.mode.reload?`, ${d(u=>u.toPurge)} to purge and ${d(u=>u.toDeactivate)} to deactivate of ${r.earlierLoads} earlier ${o.run}(s)`:"")+" \u2014 nothing written"];for(let u of r.perObject){let $=[`${u.toInsert} to insert`,u.reusedByKeys>0?`${u.reusedByKeys} found by identity keys`:"",u.reusedFromCatalog>0?`${u.reusedFromCatalog} found in the catalog`:"",(u.writtenByThePlatform??0)>0?`${u.writtenByThePlatform} to link (written by the platform with ${Oe(u.objectApiName)})`:"",u.fieldsDropped>0?`${u.fieldsDropped} field(s) dropped`:"",u.picklistsRewritten>0?`${u.picklistsRewritten} picklist value(s) rewritten`:"",u.notSent>0?`${u.notSent} not sent`:"",u.toPurge>0?`${u.toPurge} to purge`:"",u.toDeactivate>0?`${u.toDeactivate} to deactivate`:""].filter(Boolean);a.push(` ${u.objectApiName}: ${$.join(", ")} of ${u.fromFiles}`)}for(let u of r.excludedObjects)a.push(` ${u.objectApiName}: not ${o.done} \u2014 ${u.reason}`);a.push(...Qt(r.removals,"would leave",o));for(let u of[...r.heldForExcludedParents??[],...r.quotesLeftUnsynced??[],...r.keysLeftEmpty??[]])a.push(` ${u.objectApiName}: ${u.note}`);for(let u of r.placeholders)a.push(`placeholder for ${u.objectApiName}.${u.field}: ${u.affectedRecords} record(s)`);for(let u of r.requiredDefaults)a.push(`default for ${u.objectApiName}.${u.field}: ${u.affectedRecords} record(s)`+(u.perRecord?`, ${Ro(u.perRecord,u.example)}`:""));r.personContacts>0&&a.push(`${r.personContacts} person account contact(s) go in with their account, not counted above`);let l=Object.entries(r.leftUnrecorded??{});if(l.length>0){a.push("left in place, of a load recorded before loads kept what they created \u2014 it may have linked them:");for(let[u,$]of l)a.push(` ${u}: ${$}`)}let p=Object.entries(r.keptByThePlatform??{});if(p.length>0){a.push("left in place by the purge, the platform does not delete them:");for(let[u,$]of p)a.push(` ${u}: ${$}`)}let g=u=>` ${u.name}${u.field?` (${u.field})`:""}${u.message?` \u2014 ${u.message}`:""}`,y=r.perObject.filter(u=>(u.validationRules?.length??0)>0);for(let u of y){a.push(`${u.objectApiName}: ${u.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 $ of u.validationRules??[])a.push(g($))}for(let u of r.perObject){let $=u.lookupFilters??[];$.length!==0&&a.push(`${u.objectApiName}: ${$.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: `+$.map(f=>`${f.field} (${f.referenceTo.join(" or ")}, ${f.records} record(s))`).join(", "))}for(let u of r.perObject){let $=u.validationRulesOnChange??[];$.length!==0&&a.push(`${u.objectApiName}: ${$.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: `+$.join(", "))}let z=new Map(r.placeholders.filter(u=>(u.validationRules?.length??0)>0).map(u=>[u.placeholderObjectApiName,u.validationRules??[]]));for(let[u,$]of z){a.push(`placeholder of ${u}: ${$.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 f of $)a.push(g(f))}r.validationRulesUnread&&a.push(`the target's validation rules could not be listed (${r.validationRulesUnread}): any of them may refuse a record counted to insert`);let M=s.plan.automation;M&&a.push(...me(M,"the target"));let C=s.plan.emails;C&&a.push(...he(C,"the target"));let F=s.plan.apiRequests;F&&a.push(no(F,"the target"));let D=s.plan.storage;return D&&a.push(Po(D,"the target")),a}case"frozen:verify:result":{let r=s.verdict;return[`verification: ${r.status.toUpperCase()}`,...r.checks.map(d=>{let a=Vo(d,o);return` ${d.passed?"ok ":"FAIL"} ${a.name}: ${a.detail}`})]}case"frozen:remove:response":{let r=s.result,d=[...new Set(r.objects.flatMap(l=>l.unchecked))],a=r.sweep!==void 0&&r.objects.length===0;return[...r.sweep?ne(r.sweep):[],...(r.otherLoadSweeps??[]).flatMap(({loadedAt:l,result:p})=>[`sweep of the ${o.run} of ${l}:`,...ne(p)]),...a?[]:[`removal: ${r.status.toUpperCase()}`+(r.leftBy?` \u2014 of what the removal of ${r.leftBy} left`:"")],...r.objects.flatMap(l=>[` ${l.objectApiName}: ${To(l)||"nothing"} of ${l.planned}${Ie(l)}`,...Tt(l,m),...l.reasons.map(p=>` ${p}`),...l.filesLeft&&l.filesLeft.count>0?[` ${zo(l.filesLeft,o)}`]:[]]),...d.length>0?[`not checked, deleted with their parent: ${d.join(", ")}`]:[],...We(r.keptByThePlatform),...zt(r.objects,{sweep:r.sweep!==void 0}),...r.mutedAutomation?Z(r.mutedAutomation,"the target"):[]]}case"frozen:remove:sweep:response":{let r=s.loads;if(r)return r.flatMap(({loadedAt:a,listing:l})=>[`sweep of the ${o.run} of ${a}:`,...fe(l,"the target org",t,!0)]);let d=s.otherLoads??[];return d.length>0?[{loadedAt:String(s.loadedAt),listing:s.listing},...d].flatMap(({loadedAt:a,listing:l})=>[`sweep of the ${o.run} of ${a}:`,...fe(l,"the target org",t,!0)]):fe(s.listing,"the target org",t,!0)}case"frozen:remove:preview:response":return Uo(s.preview,o);case"frozen:status:response":return[JSON.stringify(s.status,null,2)];default:return[]}}var Bo="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 Uo(e,t=x){let o=i=>e.userNames[i]??i,n=["preview: what a removal would do; nothing was deleted"+(e.leftBy?` \u2014 of what the removal of ${e.leftBy} left`:"")];for(let i of e.objects){let m=[i.toDelete>0?`${i.toDelete} to delete`:"",e.includeChanged&&i.changedSince>0?`${i.changedSince} of them changed since the ${t.run}`:"",i.alreadyGone>0?`${i.alreadyGone} gone already`:"",i.notVisible>0?`${i.notVisible} not visible`:"",i.keptChanged>0?`${i.keptChanged} kept, changed since the ${t.run}`:"",i.undeletable>0?`${i.undeletable} left, the user may not delete them`:"",i.unread>0?`${i.unread} left, not read`:""].filter(Boolean);n.push(` ${i.objectApiName}: ${m.join(", ")||"nothing"} of ${i.planned}${Ie(i)}`);let r=Object.entries(i.changedBy).sort((d,a)=>a[1]-d[1]);r.length>0&&n.push(` last changed by: ${r.map(([d,a])=>`${o(d)} ${a}`).join(" \xB7 ")}`);for(let d of i.reasons)n.push(` ${d}`)}n.push(...We(e.keptByThePlatform));let s=e.refusalCodes;return e.refusals.forEach((i,m)=>{n.push(s?.length===e.refusals.length?ue({code:s[m],message:i},"a removal"):`a removal would be refused: ${i}`)}),n.push(Bo),n}async function Wo(e){let t=G(e,"manifest.json");if(_e(t))try{let o=await _t(e),{version:n}=JSON.parse(ve(t,"utf8"));return{dir:e,digest:o,...typeof n=="string"?{version:n}:{}}}catch{return}}function Go(e,t){let o=G(e,xt(t)),n=G(e,"referenceid-mapping.json");return!_e(o)&&_e(n)?n:o}function ro(e){return{status:e.status.toUpperCase(),objects:(e.objects??[]).map(({status:t,...o})=>({...o,verdict:t==="passed"?"PASSED":"FAILED"}))}}async function qo(e,t,o){let n=a=>t.filter(l=>l.type===a).at(-1)?.payload,s=o.targetOrgId?Go(o.sasDir,o.targetOrgId):void 0,i={tool:"sandforge-frozen",step:e,posted:t},m=[],r=[],d=async a=>{if(a===void 0)return;let l=await Wo(a);l&&(i.dataset=l)};switch(e){case"extract":{let a=n("frozen:extract:response");if(!a)break;await d(typeof a.datasetDir=="string"?a.datasetDir:o.datasetDir);let l=a.manifest?.volumetry?.measured??{};i.objects=Object.entries(l).filter(([,p])=>p>0).map(([p,g])=>({objectApiName:p,records:g}));break}case"load":{await d(o.datasetDir);let a=n("frozen:load:response")?.report,l=n("frozen:load:preview:response")?.plan,p=a?a.recordTypesGiven:l?.recordTypesGiven;p&&(i.recordTypesGiven=p),a?(i.mapping=a.mappingPath,i.objects=a.perObject.map(y=>({objectApiName:y.objectApiName,fromFiles:y.fromFiles,inserted:y.inserted,reused:y.reused,duplicates:y.skippedDuplicates.length,failed:y.failed.length}))):l&&(s&&(i.mapping=s),i.objects=l.perObject.map(y=>({objectApiName:y.objectApiName,fromFiles:y.fromFiles,toInsert:y.toInsert,toLink:y.reusedByKeys+y.reusedFromCatalog+(y.writtenByThePlatform??0),notSent:y.notSent,toPurge:y.toPurge,toDeactivate:y.toDeactivate}))),a&&(i.status=a.status),!a&&n("frozen:load:error")?.code==="LOAD_CANCELLED"&&(i.status="cancelled",s&&(i.mapping=s));let g=n("frozen:verify:result")?.verdict;g&&(i.verdict=ro(g));break}case"verify":{let a=n("frozen:verify:result")?.verdict;await d(a?.manifestPath?wo(a.manifestPath):o.datasetDir),s&&(i.mapping=s),a&&(i.verdict=ro(a));break}case"remove":{s&&(i.mapping=s);let a=n("frozen:remove:response")?.result,l=n("frozen:remove:preview:response")?.preview;a?(i.status=a.status,a.mutedAutomation&&(i.mutedAutomation=a.mutedAutomation),i.objects=a.objects.map(p=>({objectApiName:p.objectApiName,planned:p.planned,deleted:p.deleted,alreadyGone:p.alreadyGone,keptChanged:p.keptChanged,keptDependents:p.keptDependents,refused:p.refused,notReached:p.notReached??0,notVisible:p.notVisible??0,...p.tookAlong?{tookAlong:p.tookAlong}:{},...p.cameAlong?{cameAlong:p.cameAlong}:{}})),i.includeChanged=a.includeChanged):l&&(i.preview=!0,i.includeChanged=l.includeChanged,i.objects=l.objects.map(p=>({objectApiName:p.objectApiName,planned:p.planned,toDelete:p.toDelete,alreadyGone:p.alreadyGone,changedSince:p.changedSince,keptChanged:p.keptChanged,undeletable:p.undeletable,notVisible:p.notVisible,unread:p.unread})),m.push(...l.refusals),l.refusalCodes?.length===l.refusals.length&&r.push(...l.refusalCodes));break}}return m.push(...o.refusals??[]),o.refusalCodes?.length===(o.refusals??[]).length&&r.push(...o.refusalCodes??[]),m.length>0&&(i.refusals=m),m.length>0&&r.length===m.length&&(i.refusalCodes=r),o.mute&&Object.assign(i,o.mute),o.checkpoint&&(i.checkpoint=o.checkpoint),i}function Vo(e,t){return t===x?e:{name:e.name==="load"?t.run:e.name,detail:e.detail.replace(/\bThe load\b/g,`The ${t.run}`).replace(/\bthe load\b/g,`the ${t.run}`).replace(/\bnot loaded\b/g,`not ${t.done}`).replace(/\bnot loadable\b/g,`not ${t.run}able`)}}async function Ko(e=process.argv){await Ho($o(e))}async function Ho(e,t){let o=Date.now(),n=c=>{process[e.json?"stderr":"stdout"].write(`${c}
|
|
267
|
-
`)},s=t?.words??
|
|
265
|
+
`),process.exit(2)),(p===void 0||!/^\d+$/.test(p)||l<1||l>Jt)&&(process.stderr.write(`--max-total takes a whole number from 1 to ${Jt}, not "${p??""}".
|
|
266
|
+
`),process.exit(2))}return{step:n,configPath:s,source:i,target:m,author:o("--author"),storePath:o("--store"),saltFile:o("--salt-file"),pilot:t.includes("--pilot"),reload:t.includes("--reload"),dryRun:t.includes("--dry-run"),writeEncrypted:t.includes("--write-encrypted"),muteAutomation:t.includes("--mute-automation"),acceptAutomation:t.includes("--accept-automation"),...d!==void 0?{checkpointFirst:d}:{},includeChanged:t.includes("--include-changed"),acceptEmails:t.includes("--accept-emails"),sweep:t.includes("--sweep"),sweepList:t.includes("--sweep-list"),...a,preview:t.includes("--preview"),...l!==void 0?{maxTotal:l}:{},...r!==void 0?{goneFirst:r}:{},yes:t.includes("--yes"),json:t.includes("--json")}}async function Ro(e){let o=(await e.query("SELECT Id, IsSandbox FROM Organization LIMIT 1")).records[0];if(!o)throw new Error("The org gave no Organization record.");if(o.IsSandbox)return{id:o.Id,orgType:"Sandbox"};try{let s=(await e.query("SELECT OrganizationType FROM Organization LIMIT 1")).records[0]?.OrganizationType;return typeof s=="string"&&s!==""?{id:o.Id,orgType:et({isSandbox:!1,edition:s}),edition:s}:{id:o.Id,orgType:"Production"}}catch{return{id:o.Id,orgType:"Production"}}}async function Qt(e,t,o,n){let s=await st(e),i=Se(s),m;try{m=await Ro(i)}catch(r){let d=r instanceof Error?r.message:String(r);throw new Error(`Could not read the Organization record of '${e}': ${d}`)}return t.set(m.id,{org:{id:m.id,alias:e,orgType:m.orgType,metadata:{apiVersion:"66.0",...m.edition?{edition:m.edition}:{}},username:s.username,instanceUrl:s.instanceUrl},credentials:{accessToken:s.accessToken,instanceUrl:s.instanceUrl}}),o?.set(m.id,i),n?.set(m.id,{session:s,typed:m}),m.id}var M={run:"load",done:"loaded",source:"the frozen dataset",recordedIn:"in this sas",remove:"`remove`",module:"frozen",again:"reload",againSubject:{purge:"reload",sweep:"reloadSweep"},maybeMasks:"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 We(e){return!e||e.length===0?[]:[`kept: the platform does not delete them \u2014 ${e.map(({objectApiName:o,count:n})=>`${o} (${n})`).join(", ")}`]}function Yt(e,t,o=M){let n=(e??[]).filter(i=>i.reason==="may-hold-masks");if(n.length===0)return[];let s=n.map(({objectApiName:i,field:m,affectedRecords:r})=>`${i}.${m} (${r})`).join(", ");return[`${t} out, encrypted in the target: ${s} \u2014 ${o.maybeMasks}`]}function So(e,t){let o=e==="token"?"each record its own, from the token the value carries":`each record its own, its rank appended: the field is ${e==="unique"?"unique in the target":"the record name"}`;return t===void 0?o:`${o} (first: "${t}")`}function Ge(e){return e.created.reduce((t,o)=>t+o.count,0)}function Oo(e){return{...e.includeChanged?{includeChanged:!0}:{},...e.sweep?{sweep:!0}:{},...e.sweepLate?{sweepLate:!0}:{},...e.sweepUntied?{sweepUntied:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{}}}var Eo={removal:{heading:"removal",writer:"this removal",verb:"remove"},reload:{heading:"reload",writer:"this reload's purge",verb:"reload"},reloadSweep:{heading:"reload",writer:"this reload's sweep",verb:"reload"},replayAgain:{heading:"replay",writer:"this replay's purge",verb:"replay again"},replayAgainSweep:{heading:"replay",writer:"this replay's sweep",verb:"replay again"}};function xe({read:e,steps:t,mute:o},n,s="removal",i){let m=o?Z(o.muted,n).map(l=>` ${l}`):[];if(!("objects"in e)){let l=Eo[s],p=s==="reload"||s==="replayAgain",g=`${l.writer}${p&&i?" and its sweep":""}`;return{lines:[`${l.heading} automation: what ${n} runs could not be read: ${e.unread}`,...m],refusal:`What ${n} runs as ${g} writes could not be read (${e.unread}), so what fires as the records go is not known. Nothing was written or deleted. Add --accept-automation to ${l.verb} all the same, or turn that automation off in ${n} first.`}}let r=o?.automation??e,d=i?tt(t,i.delete??[]):t,a=gt(r,n,{steps:t,...i?{sweep:i}:{},assign:ht(r,ot(r,d)),mayMute:o===void 0&&Ce("--mute-automation"),subject:s});return{lines:[...mt(e,n,t,s,i),...m],...a!==void 0?{refusal:a}:{}}}function Fo(e,t,o=M){let n=Ge(e),s=e.earlier?`a ${o.run} before the last one, whose records the ${o.run}s after it left in place,`:`the last ${o.run}`,i=`a removal deletes the ${n} record(s) it created, children first:`;return e.removed&&n===0?i=`its records were removed on ${e.removed.removedAt}, and none is left to remove`:n===0&&(e.keptByThePlatform?.length??0)>0?i="it created no record a removal takes":e.removed&&(i=`the removal of ${e.removed.removedAt} left ${n} of the records it created, and a removal deletes those, children first:`),[`${s} wrote to ${t} at ${e.loadedAt}; ${i}`,...e.created.map(m=>` ${m.objectApiName}: ${m.count}`),`${e.linked} record(s) it linked to or reused stay`,...We(e.keptByThePlatform)]}function To(e,t){return e.recorded&&(Ge(e)>0||(t?.delete??[]).length>0)}function zo(e){return[e.deleted>0?`${e.deleted} deleted`:"",e.alreadyGone>0?`${e.alreadyGone} already gone`:"",e.keptChanged>0?`${e.keptChanged} kept, changed since the load`:"",e.keptDependents>0?`${e.keptDependents} kept for records that stay`+(e.heldBy.length>0?` (${e.heldBy.join(", ")})`:""):"",e.refused>0?`${e.refused} refused`:"",(e.notReached??0)>0?`${e.notReached} not reached`:""].filter(Boolean).join(", ")}function Co(e,t=M){let o=e.count>e.names.length?", \u2026":"";return`${e.count} file(s) attached to them stay in the org, as the ${t.run} did not create them: ${e.names.join(", ")}${o}`}function eo(e){return`graph: ${e.objects} object(s) at a cap of ${e.maxNodes}`+(e.objects>e.maxNodes?" (raised for the parents their records cannot be written without)":"")+(e.truncated?" \u2014 TRUNCATED: objects further out were not read":"")}function to(e){return"reusedFrom"in e?`graph reused from ${e.reusedFrom} (discovered ${e.discoveredAt}): the source's schema has not changed since`:`rediscovered: ${e.rediscovered}`}function Lo(e){switch(e.phase){case"discovery":return` discovery: ${e.objects??0} object(s) reached`;case"axis":return` listing the values of axis ${e.axis??"?"}\u2026`;case"combination":return` combination ${e.index??"?"}/${e.of??"?"}: ${e.combinationKey??"?"}`;case"candidate":return` candidate ${e.candidate??"?"}/${e.candidates??"?"} of ${e.combinationKey??"?"}: measuring its own records\u2026`;case"measure":return` measuring the ${e.roots??0} root(s) kept, together\u2026`}}function jo(e){let t=e.reason==="timeout"?"its time ran out":"it was cancelled",o=e.during==="axes"?"while it listed the axis values":e.during==="measure"?"while it measured the roots it kept":`while it probed ${e.combinationKey??"?"}`+(e.candidate!==void 0?`, candidate ${e.candidate} of ${e.candidates??"?"}`:"");return[`STOPPED: ${t} ${o}; the combinations decided before are kept`,...e.notProbed.length>0?[` never probed: ${e.notProbed.join(", ")}`]:[]]}var No=new Set(["NO_LOAD","ALREADY_REMOVED","NOTHING_TO_REMOVE"]),lo="REMOVAL_DECLINED",oo=["MUTE_PRODUCTION","MUTE_NO_RIGHT","MUTE_FAILED"],Io=new Map([["frozen:load:error",new Set(["EMAILS_NOT_ACCEPTED","FROZEN_EMAILS_EXCEEDED",ze,"FROZEN_STORAGE_EXCEEDED","AUTOMATION_NOT_ACCEPTED",le.code,...oo])],["frozen:remove:error",new Set(["AUTOMATION_NOT_ACCEPTED","GUARD_BLOCKED","GUARD_DECLINED",le.code,...oo])]]);function Be(e){let t=e.payload?.code,o=Io.get(String(e.type??""));if(!(typeof t!="string"||o?.has(t)!==!0))return{code:t,message:String(e.payload?.message??"")}}function Ue(e){let t=String(e.type??"");if(!t.endsWith(":error")||t==="frozen:remove:automation:error")return!1;let o=String(e.payload?.code);return t==="frozen:remove:error"&&o===lo?!1:!((t==="frozen:remove:error"||t==="frozen:remove:preview:error")&&No.has(o))}var no={passed:0,partial:3,unstable:4,failed:1};function Do(e,t,o){return async(n,s)=>{let i=Date.parse(s?.first??""),m=Math.max(i,Date.parse(s?.last??""));return!Number.isFinite(i)||!Number.isFinite(m)?[]:[...(await Nt({organizationId:n,alias:e,span:{from:i,to:m},own:{ids:[]},...t!==void 0?{journalDir:t}:{}})).map(({ids:d})=>({ids:d,from:i,to:m})),...qt(Kt(t??te(),n),{sasMark:o,own:[]})]}}function Po(e,t){return dt(t.map(o=>{let n=o.payload??{};if(e==="verify"&&o.type==="frozen:verify:result"){let s=String(n.verdict?.status??"");return Object.prototype.hasOwnProperty.call(no,s)?no[s]:1}if(e==="load"&&o.type==="frozen:load:response"){let s=n.report,i=n.replay?.summary.records.refusedBeforeWrite;return s?.status==="completed"&&(s.sweeps??[]).every(m=>m.result.status==="success")&&(i??0)===0?0:3}return e==="remove"&&o.type==="frozen:remove:response"?n.result?.status==="success"?0:3:0}))}function xo(e,t){return` data storage: about ${J(e.estimateMB)} MB`+(e.automationMB!==void 0&&e.automationMB>0?`, about ${J(e.automationMB)} MB of it for what the target's automation creates under them,`:"")+` of the ${J(e.remainingMB)} MB ${t} has left of ${J(e.maxMB)} MB`+(e.freedMB!==void 0?`, and the reload's purge frees about ${J(e.freedMB)} MB first`:"")}function ro(e,t){return Tt(e.verdict==="unread"?{verdict:"unread",estimate:e.estimate,unread:e.unread??"not said"}:{verdict:e.verdict,estimate:e.estimate,remaining:e.remaining??0,max:e.max??0},t)}function Mo(e){return(e.filter(o=>o.type==="frozen:remove:response").at(-1)?.payload?.result?.objects??[]).some(o=>o.deleted+o.alreadyGone>0)}function ge(e,t){if(wt()!==void 0)return De(e);let o=t.remove.replace(/`/g,"");return e==="--sweep"||e==="--sweep-list"?`${o} ${e}`:`${o} --sweep ${e}`}function _o(e,t=M){if(!e||e.found.length===0)return[];let o=e.found.reduce((l,p)=>l+p.count,0),n=e.found.some(l=>l.overBound)?" or more":"",s=l=>e.found.reduce((p,g)=>p+(g.classes?l(g.classes):0),0),i=s(l=>l.made+l.madeOver),m=s(l=>l.late),r=s(l=>l.untied),d=e.found.filter(l=>l.overBound).map(l=>l.objectApiName),a=[...i>0?[`${ge("--sweep",t)} takes the ${i} tied to the ${t.run}`]:[],...m>0?[`${ge("--sweep-late",t)} takes the ${m} made late`]:[],...r>0?[e.untied?.refusal!==void 0?`the ${r} tied to nothing of the ${t.run} now stay: --sweep-untied is refused (${e.untied.refusal})`:`${ge("--sweep-untied",t)} takes the ${r} tied to nothing of the ${t.run} now`]:[],...d.length>0?[`no sweep takes those of ${d.join(", ")}, past its bound`]:[]];return[`not swept: ${o}${n} record(s) the ${t.run}'s user created in its window stay, what the target's automation made for the ${t.run} likely: `+e.found.map(l=>`${l.objectApiName}: ${l.count}`).join(", "),...a.map(l=>` ${l}`),` ${ge("--sweep-list",t)} names them first: a record made by hand as that user in the ${t.run}'s window reads as the automation's, so check the names before a sweep`]}function Bo(e,t={},o=M){let n=String(e.type??""),s=e.payload??{},i=n.replace(/^frozen:/,`${o.module}:`),m=o===M?"load":"run";if((n==="frozen:remove:error"||n==="frozen:remove:preview:error")&&!Ue(e))return[`nothing to remove: ${String(s.message??"")}`];if(n==="frozen:remove:error"&&!Ue(e))return[String(s.message??"")];if(n==="frozen:remove:automation:error")return[];if(n.endsWith(":error")){let r=n==="frozen:load:error"?s.sweeps??[]:[],d=n==="frozen:load:error"?s.emails:void 0,a=n==="frozen:load:error"?s.automation:void 0,l=n==="frozen:load:error"?s.mutedAutomation:void 0,p=Be(e);return[...p?[]:[`! ${i}: ${String(s.message??"")}${s.code?` [${String(s.code)}]`:""}`],...a?me(a,"the target"):[],...d?he(d,"the target"):[],...l?Z(l,"the target"):[],...r.length>0?[`before the ${o.run} ended, its sweep had already done this:`]:[],...r.flatMap(({loadedAt:g,result:y})=>[`sweep of the ${o.run} of ${g}:`,...ne(y)]),...p?[ee(p)]:[]]}switch(n){case"frozen:select:progress":return[Lo(s)];case"frozen:select:response":{let r=s.selection;return[`selected ${r.combinations.length} root(s): ${r.combinations.map(d=>d.combinationKey).join(", ")}`,...r.uncovered.map(d=>` uncovered ${d.combinationKey}: ${d.reason}`),...r.stopped?jo(r.stopped):[],...r.discovery?[to(r.discovery)]:[],...r.graph?[eo(r.graph)]:[],`volumetry ${r.volumetry.total} / ${r.volumetry.budgetMax} record(s)`+(r.volumetry.summed?" \u2014 each kept root's own records added up: they were not measured together":""),...Object.entries(r.volumetry.measured).filter(([,d])=>d>0).map(([d,a])=>` ${d}: ${a}`)]}case"frozen:control:result":{let r=s.report;return[`non-reidentification control: ${r.passed?"PASSED":"FAILED"}`,...r.checks.map(d=>` ${d.passed?"ok ":"FAIL"} ${d.name}`+(d.violations.length>0?` (${d.violations.length} violation(s))`:""))]}case"frozen:extract:response":{let r=s.manifest,d=s.discovery;return[`frozen ${String(s.recordCount)} record(s) as version ${r.version} in ${String(s.datasetDir)}`,...d?[to(d)]:[],...r.coverage?[eo(r.coverage)]:[],...r.coverage&&r.coverage.unboundedObjects.length>0?[`read without the time bound: ${r.coverage.unboundedObjects.join(", ")}`]:[],...(r.coverage?.leftToThePlatform??[]).map(a=>`${a.objectApiName}: ${a.note}`),...(r.coverage?.exclusionCosts??[]).map(a=>`${a.objectApiName}: ${a.note}`),...(r.coverage?.requiredLeftEmpty??[]).length>0?[`required in the source and left empty by the rules \u2014 a load will ask a value for each: ${(r.coverage?.requiredLeftEmpty??[]).join(", ")}`]:[],...(r.coverage?.keptWithoutARule??[]).length>0?["kept without a rule, the platform's own words: "+(r.coverage?.keptWithoutARule??[]).join(", ")]:[],...(r.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: "+(r.coverage?.encryptedNotKept??[]).join(", ")]:[],...Object.entries(r.volumetry.measured).filter(([,a])=>a>0).map(([a,l])=>` ${a}: ${l}`)]}case"frozen:load:response":{let r=s.report,d=[`${o.run}: ${r.status} in ${r.durationMs}ms \u2014 ${r.alignment.excludedObjects.length} object(s) excluded, ${r.alignment.removals.length} field removal(s), ${r.alignment.recordTypeIssues.length} record type issue(s), ${r.placeholders.length} placeholder(s)`];for(let f of r.alignment.excludedObjects)d.push(` ${f.objectApiName}: not ${o.done} \u2014 ${f.reason}`);d.push(...Yt(r.alignment.removals,"left",o));for(let f of r.perObject){let S=f.writtenByThePlatform??0;d.push(` ${f.objectApiName}: ${f.inserted} inserted, ${f.reused} reused`+(S>0?` (${S} written by the platform with ${Oe(f.objectApiName)})`:"")+`, ${f.skippedDuplicates.length} duplicate(s), ${f.failed.length} failed of ${f.fromFiles}`);let x=f.failed[0];x&&d.push(` first refusal: ${x.errors?.[0]??x.error??"?"}`);let D=f.sentAgainForALock,U=D&&ut("record(s)",{refused:D.rows,sentAgain:D.rows,written:D.written,stillLocked:D.stillLocked,notSentAgain:0});U&&d.push(` ${U}`)}for(let f of[...r.leftToThePlatform??[],...r.untypedFeedItems??[],...r.heldForExcludedParents??[],...r.quotesLeftUnsynced??[],...r.keysLeftEmpty??[]])d.push(` ${f.objectApiName}: ${f.note}`);let a=r.perObject.filter(f=>(f.writtenWithoutFields?.fields.length??0)>0);if(a.length>0){d.push(`written again without a field a validation rule or a restricted picklist refused (${a.length} object(s)):`);for(let{objectApiName:f,writtenWithoutFields:S}of a)for(let{field:x,refusedBy:D,reason:U,rows:Ve,replacedWith:se}of S?.fields??[]){let Q=D==="restricted-picklist"?"a restricted picklist refused its value":"a validation rule refused it",L=se===void 0?"":` \u2014 written with "${se}", as its picklist rule declares`;d.push(` ${f}.${x} ${Ve} record(s) \u2014 ${Q}${L} \u2014 ${U}`)}}d.push(`pass 2: ${r.pass2.resolved} resolved, ${r.pass2.unresolved.length} unresolved`);for(let f of r.pass2.unresolved.slice(0,5))d.push(` ${f.objectApiName}.${f.field}: ${f.detail}`);let l=r.personContact,p=l?.sent??[];if(l&&l.restored+p.length+l.unresolved.length>0){d.push(`person contacts: ${l.restored} linked, ${p.length} sent as contacts of their own, ${l.unresolved.length} not linked`);for(let f of p.slice(0,5))d.push(` ${f.contactReferenceId} sent: ${f.detail}`);for(let f of l.unresolved.slice(0,5))d.push(` ${f.contactReferenceId}: ${f.detail}`)}if(r.statuses&&r.statuses.restored+r.statuses.refused.length>0){d.push(`statuses applied after insert: ${r.statuses.restored}, refused ${r.statuses.refused.length}`);for(let f of r.statuses.refused.slice(0,5))d.push(` ${f.objectApiName} \u2192 ${f.status}: ${f.detail}`)}let g=f=>Object.values(f).reduce((S,x)=>S+x,0),y=g(r.purge.deleted),z=g(r.purge.deactivated??{});if(y+z+r.purge.failures.length>0){d.push(`purge of earlier ${o.run}s: ${y} deleted, ${z} deactivated, ${r.purge.failures.length} failed`);for(let f of r.purge.failures.slice(0,5))d.push(` ${f.objectApiName}: ${f.errors[0]??"?"}`)}for(let[f,S]of Object.entries(r.purge.cameAlong??{}))d.push(` ${f}: took along ${S.count} record(s) the ${o.run}s did not write that came with their records, made as they wrote: ${S.objects.join(", ")}`);let _=Object.entries(r.purge.leftUnrecorded??{});if(_.length>0){d.push("left in place, of a load recorded before loads kept what they created \u2014 it may have linked them:");for(let[f,S]of _)d.push(` ${f}: ${S}`)}let C=Object.entries(r.purge.keptByThePlatform??{});if(C.length>0){d.push("kept by the purge, the platform does not delete them:");for(let[f,S]of C)d.push(` ${f}: ${S}`)}for(let f of s.report.sweeps??[]){d.push(`sweep of the ${o.run} of ${f.loadedAt}:`,...ne(f.result));let S=f.result.objects.reduce((x,D)=>x+D.keptChanged,0);S>0&&d.push(` ${S} record(s) kept, changed since that ${o.run}: `+(o===M?"load --reload --sweep --include-changed, or remove --sweep --include-changed, ":`${o.remove} --sweep --include-changed `)+"takes them")}let F=s.report.mutedAutomation;F&&d.push(...Z(F,"the target"));let P=s.report.automation;P&&d.push(...me(P,"the target"));let u=s.report.emails;u&&d.push(...he(u,"the target"));let $=s.report.apiRequests;return $&&d.push(ro($,"the target")),d.push(...co(s.report.recordTypesGiven,!1)),d}case"frozen:load:preview:response":{let r=s.plan,d=u=>r.perObject.reduce(($,f)=>$+u(f),0),a=[`dry run${r.mode.pilot?" (pilot)":""}${r.mode.reload?` (${o.again})`:""}: ${d(u=>u.toInsert)} record(s) to insert, ${d(u=>u.reusedByKeys+u.reusedFromCatalog+(u.writtenByThePlatform??0))} to link, ${d(u=>u.notSent)} not sent`+(r.mode.reload?`, ${d(u=>u.toPurge)} to purge and ${d(u=>u.toDeactivate)} to deactivate of ${r.earlierLoads} earlier ${o.run}(s)`:"")+" \u2014 nothing written"];for(let u of r.perObject){let $=[`${u.toInsert} to insert`,u.reusedByKeys>0?`${u.reusedByKeys} found by identity keys`:"",u.reusedFromCatalog>0?`${u.reusedFromCatalog} found in the catalog`:"",(u.writtenByThePlatform??0)>0?`${u.writtenByThePlatform} to link (written by the platform with ${Oe(u.objectApiName)})`:"",u.fieldsDropped>0?`${u.fieldsDropped} field(s) dropped`:"",u.picklistsRewritten>0?`${u.picklistsRewritten} picklist value(s) rewritten`:"",u.notSent>0?`${u.notSent} not sent`:"",u.toPurge>0?`${u.toPurge} to purge`:"",u.toDeactivate>0?`${u.toDeactivate} to deactivate`:""].filter(Boolean);a.push(` ${u.objectApiName}: ${$.join(", ")} of ${u.fromFiles}`)}for(let u of r.excludedObjects)a.push(` ${u.objectApiName}: not ${o.done} \u2014 ${u.reason}`);a.push(...Yt(r.removals,"would leave",o));for(let u of[...r.heldForExcludedParents??[],...r.quotesLeftUnsynced??[],...r.keysLeftEmpty??[]])a.push(` ${u.objectApiName}: ${u.note}`);for(let u of r.placeholders)a.push(`placeholder for ${u.objectApiName}.${u.field}: ${u.affectedRecords} record(s)`);for(let u of r.requiredDefaults)a.push(`default for ${u.objectApiName}.${u.field}: ${u.affectedRecords} record(s)`+(u.perRecord?`, ${So(u.perRecord,u.example)}`:""));r.personContacts>0&&a.push(`${r.personContacts} person account contact(s) go in with their account, not counted above`);let l=Object.entries(r.leftUnrecorded??{});if(l.length>0){a.push("left in place, of a load recorded before loads kept what they created \u2014 it may have linked them:");for(let[u,$]of l)a.push(` ${u}: ${$}`)}let p=Object.entries(r.keptByThePlatform??{});if(p.length>0){a.push("left in place by the purge, the platform does not delete them:");for(let[u,$]of p)a.push(` ${u}: ${$}`)}let g=u=>` ${u.name}${u.field?` (${u.field})`:""}${u.message?` \u2014 ${u.message}`:""}`,y=r.perObject.filter(u=>(u.validationRules?.length??0)>0);for(let u of y){a.push(`${u.objectApiName}: ${u.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 $ of u.validationRules??[])a.push(g($))}for(let u of r.perObject){let $=u.lookupFilters??[];$.length!==0&&a.push(`${u.objectApiName}: ${$.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: `+$.map(f=>`${f.field} (${f.referenceTo.join(" or ")}, ${f.records} record(s))`).join(", "))}for(let u of r.perObject){let $=u.validationRulesOnChange??[];$.length!==0&&a.push(`${u.objectApiName}: ${$.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: `+$.join(", "))}let z=new Map(r.placeholders.filter(u=>(u.validationRules?.length??0)>0).map(u=>[u.placeholderObjectApiName,u.validationRules??[]]));for(let[u,$]of z){a.push(`placeholder of ${u}: ${$.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 f of $)a.push(g(f))}r.validationRulesUnread&&a.push(`the target's validation rules could not be listed (${r.validationRulesUnread}): any of them may refuse a record counted to insert`);let _=s.plan.automation;_&&a.push(...me(_,"the target"));let C=s.plan.emails;C&&a.push(...he(C,"the target"));let F=s.plan.apiRequests;F&&a.push(ro(F,"the target"));let P=s.plan.storage;return P&&a.push(xo(P,"the target")),a}case"frozen:verify:result":{let r=s.verdict;return[`verification: ${r.status.toUpperCase()}`,...r.checks.map(d=>{let a=Ko(d,o);return` ${d.passed?"ok ":"FAIL"} ${a.name}: ${a.detail}`})]}case"frozen:remove:response":{let r=s.result,d=[...new Set(r.objects.flatMap(l=>l.unchecked))],a=r.sweep!==void 0&&r.objects.length===0;return[...r.sweep?ne(r.sweep):[],...(r.otherLoadSweeps??[]).flatMap(({loadedAt:l,result:p})=>[`sweep of the ${o.run} of ${l}:`,...ne(p)]),...a?[]:[`removal: ${r.status.toUpperCase()}`+(r.leftBy?` \u2014 of what the removal of ${r.leftBy} left`:"")],...r.objects.flatMap(l=>[` ${l.objectApiName}: ${zo(l)||"nothing"} of ${l.planned}${Ie(l)}`,...zt(l,m),...l.reasons.map(p=>` ${p}`),...l.filesLeft&&l.filesLeft.count>0?[` ${Co(l.filesLeft,o)}`]:[]]),...d.length>0?[`not checked, deleted with their parent: ${d.join(", ")}`]:[],...We(r.keptByThePlatform),...Ct(r.objects,{sweep:r.sweep!==void 0}),...r.mutedAutomation?Z(r.mutedAutomation,"the target"):[]]}case"frozen:remove:sweep:response":{let r=s.loads;if(r)return r.flatMap(({loadedAt:a,listing:l})=>[`sweep of the ${o.run} of ${a}:`,...fe(l,"the target org",t,!0)]);let d=s.otherLoads??[];return d.length>0?[{loadedAt:String(s.loadedAt),listing:s.listing},...d].flatMap(({loadedAt:a,listing:l})=>[`sweep of the ${o.run} of ${a}:`,...fe(l,"the target org",t,!0)]):fe(s.listing,"the target org",t,!0)}case"frozen:remove:preview:response":return Wo(s.preview,o);case"frozen:status:response":return[JSON.stringify(s.status,null,2)];default:return[]}}var Uo="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 Wo(e,t=M){let o=i=>e.userNames[i]??i,n=["preview: what a removal would do; nothing was deleted"+(e.leftBy?` \u2014 of what the removal of ${e.leftBy} left`:"")];for(let i of e.objects){let m=[i.toDelete>0?`${i.toDelete} to delete`:"",e.includeChanged&&i.changedSince>0?`${i.changedSince} of them changed since the ${t.run}`:"",i.alreadyGone>0?`${i.alreadyGone} gone already`:"",i.notVisible>0?`${i.notVisible} not visible`:"",i.keptChanged>0?`${i.keptChanged} kept, changed since the ${t.run}`:"",i.undeletable>0?`${i.undeletable} left, the user may not delete them`:"",i.unread>0?`${i.unread} left, not read`:""].filter(Boolean);n.push(` ${i.objectApiName}: ${m.join(", ")||"nothing"} of ${i.planned}${Ie(i)}`);let r=Object.entries(i.changedBy).sort((d,a)=>a[1]-d[1]);r.length>0&&n.push(` last changed by: ${r.map(([d,a])=>`${o(d)} ${a}`).join(" \xB7 ")}`);for(let d of i.reasons)n.push(` ${d}`)}n.push(...We(e.keptByThePlatform));let s=e.refusalCodes;return e.refusals.forEach((i,m)=>{n.push(s?.length===e.refusals.length?ue({code:s[m],message:i},"a removal"):`a removal would be refused: ${i}`)}),n.push(Uo),n}async function Go(e){let t=V(e,"manifest.json");if(_e(t))try{let o=await Bt(e),{version:n}=JSON.parse(ve(t,"utf8"));return{dir:e,digest:o,...typeof n=="string"?{version:n}:{}}}catch{return}}function qo(e,t){let o=V(e,Mt(t)),n=V(e,"referenceid-mapping.json");return!_e(o)&&_e(n)?n:o}function so(e){return{status:e.status.toUpperCase(),objects:(e.objects??[]).map(({status:t,...o})=>({...o,verdict:t==="passed"?"PASSED":"FAILED"}))}}async function Vo(e,t,o){let n=a=>t.filter(l=>l.type===a).at(-1)?.payload,s=o.targetOrgId?qo(o.sasDir,o.targetOrgId):void 0,i={tool:"sandforge-frozen",step:e,posted:t},m=[],r=[],d=async a=>{if(a===void 0)return;let l=await Go(a);l&&(i.dataset=l)};switch(e){case"extract":{let a=n("frozen:extract:response");if(!a)break;await d(typeof a.datasetDir=="string"?a.datasetDir:o.datasetDir);let l=a.manifest?.volumetry?.measured??{};i.objects=Object.entries(l).filter(([,p])=>p>0).map(([p,g])=>({objectApiName:p,records:g}));break}case"load":{await d(o.datasetDir);let a=n("frozen:load:response")?.report,l=n("frozen:load:preview:response")?.plan,p=a?a.recordTypesGiven:l?.recordTypesGiven;p&&(i.recordTypesGiven=p),a?(i.mapping=a.mappingPath,i.objects=a.perObject.map(y=>({objectApiName:y.objectApiName,fromFiles:y.fromFiles,inserted:y.inserted,reused:y.reused,duplicates:y.skippedDuplicates.length,failed:y.failed.length}))):l&&(s&&(i.mapping=s),i.objects=l.perObject.map(y=>({objectApiName:y.objectApiName,fromFiles:y.fromFiles,toInsert:y.toInsert,toLink:y.reusedByKeys+y.reusedFromCatalog+(y.writtenByThePlatform??0),notSent:y.notSent,toPurge:y.toPurge,toDeactivate:y.toDeactivate}))),a&&(i.status=a.status),!a&&n("frozen:load:error")?.code==="LOAD_CANCELLED"&&(i.status="cancelled",s&&(i.mapping=s));let g=n("frozen:verify:result")?.verdict;g&&(i.verdict=so(g));break}case"verify":{let a=n("frozen:verify:result")?.verdict;await d(a?.manifestPath?yo(a.manifestPath):o.datasetDir),s&&(i.mapping=s),a&&(i.verdict=so(a));break}case"remove":{s&&(i.mapping=s);let a=n("frozen:remove:response")?.result,l=n("frozen:remove:preview:response")?.preview;a?(i.status=a.status,a.mutedAutomation&&(i.mutedAutomation=a.mutedAutomation),i.objects=a.objects.map(p=>({objectApiName:p.objectApiName,planned:p.planned,deleted:p.deleted,alreadyGone:p.alreadyGone,keptChanged:p.keptChanged,keptDependents:p.keptDependents,refused:p.refused,notReached:p.notReached??0,notVisible:p.notVisible??0,...p.tookAlong?{tookAlong:p.tookAlong}:{},...p.cameAlong?{cameAlong:p.cameAlong}:{}})),i.includeChanged=a.includeChanged):l&&(i.preview=!0,i.includeChanged=l.includeChanged,i.objects=l.objects.map(p=>({objectApiName:p.objectApiName,planned:p.planned,toDelete:p.toDelete,alreadyGone:p.alreadyGone,changedSince:p.changedSince,keptChanged:p.keptChanged,undeletable:p.undeletable,notVisible:p.notVisible,unread:p.unread})),m.push(...l.refusals),l.refusalCodes?.length===l.refusals.length&&r.push(...l.refusalCodes));break}}return m.push(...o.refusals??[]),o.refusalCodes?.length===(o.refusals??[]).length&&r.push(...o.refusalCodes??[]),m.length>0&&(i.refusals=m),m.length>0&&r.length===m.length&&(i.refusalCodes=r),o.mute&&Object.assign(i,o.mute),o.checkpoint&&(i.checkpoint=o.checkpoint),i}function Ko(e,t){return t===M?e:{name:e.name==="load"?t.run:e.name,detail:e.detail.replace(/\bThe load\b/g,`The ${t.run}`).replace(/\bthe load\b/g,`the ${t.run}`).replace(/\bnot loaded\b/g,`not ${t.done}`).replace(/\bnot loadable\b/g,`not ${t.run}able`)}}async function Ho(e=process.argv){await Xo(ko(e))}async function Xo(e,t){let o=Date.now(),n=c=>{process[e.json?"stderr":"stdout"].write(`${c}
|
|
267
|
+
`)},s=t?.words??M,i=t?{}:JSON.parse(ve(e.configPath??"","utf8")),m=t?t.folder.dir:typeof i.sasDir=="string"?i.sasDir:V(vo(),".sandforge-sas");t||go(m,{recursive:!0});let r=yt(t?t.auditStore:e.storePath??V(m,"cli-store.json")),d=new Map,a=new Map,l=new Map,p=e.source?await Qt(e.source,d):void 0,g=e.target?await Qt(e.target,d,a,l):void 0,y=[],z=!1,_=!1,C=new Ht({log:()=>{},broker:{postToWebview:c=>{if(c.type==="frozen:load:progress")return;if(t&&String(c.type).endsWith(":error")&&c.payload){let w=c.payload.code;c.payload.message=t.reword(typeof w=="string"?w:void 0,String(c.payload.message??""),c.payload)}y.push(c),Ue(c)&&(z=!0);let h=t?.refusalOf(c);if(h&&(E??=h,L.push(h)),_)return;let v=h?[ee(h)]:Bo(c,e,s);for(let w of t?t.lines(c,v):v)n(w)}},orgManager:{getOrg:c=>d.get(c)?.org},orgRegistry:{getCredentials:async c=>d.get(c)?.credentials},configStore:r,infraServices:{productionGuard:Dt(n,e.target??e.source??"the org"),piiDetector:new lt},nextId:()=>`cli-${Date.now()}-${Math.random().toString(36).slice(2,8)}`});t&&C.setReplayStores(t.stores);let F=g?a.get(g):void 0,P=g?l.get(g):void 0,u=e.checkpointFirst&&P?kt({module:t?"replay":"frozen",operationId:`sandforge-frozen-load-${o}`,request:e.checkpointFirst,session:P.session,org:{id:P.typed.id,orgType:P.typed.orgType,...P.typed.edition!==void 0?{edition:P.typed.edition}:{}},connect:Se,journalDir:te(),say:n}):void 0;F&&C.setTargetAutomation(oe(F)),C.setMuteOffered(Ce("--mute-automation")),C.setSaltKeeper(Wt(process.env,e.saltFile)),e.target&&C.setOtherModuleRuns(Do(e.target,void 0,Pe(m)));let $=new Xt;C.setRegistry($);let f,S,x=!1,D=!1,U,se=at(c=>{if(U=c,process.stderr.write(`
|
|
268
268
|
interrupted: the ${e.step==="load"?s.run:e.step} stops after the call under way, and says what it wrote (Ctrl-C again ends it at once)
|
|
269
|
-
`),S){S.abort();return}for(let h of $.getRunning())$.abort(h.operationId);f&&$.cancelBeforeStart(f),(!f||
|
|
270
|
-
`)},
|
|
271
|
-
`),process.exitCode=de(V);return}if(it(z||j.length>0?1:Ke?3:Do(e.step,y)),e.json){await Ae();return}n(`done in ${Date.now()-o}ms`);async function Xe(c){await L("frozen:remove:automation",{...c,...B("removal")});let h=T=>y.find(W=>W.type===T)?.payload,v=h("frozen:remove:automation:response"),w=Array.isArray(c.sweptObjects)?c.sweptObjects:[],b=v?.purge&&w.length>0?v.purge:void 0,A=v&&e.muteAutomation?F&&(e.preview||e.dryRun)?await Fe(Ee(F),v.automation,{writes:ie(v.steps)}):Te(v.automation,ie(v.steps)):void 0,N=A&&!("refused"in A)?A:void 0,{lines:k,refusal:O}=xe({read:v?.automation??{unread:String(h("frozen:remove:automation:error")?.message)},steps:b??v?.steps??{},...N?{mute:{automation:N.automation,muted:N.planned}}:{}},e.target??"",c.reload===!0?s.againSubject.purge:"removal",b?{delete:w}:void 0);for(let T of k)n(T);let _=A&&"refused"in A?A.refused:O!==void 0&&!e.acceptAutomation?{code:"AUTOMATION_NOT_ACCEPTED",message:O}:void 0;return{...v?{steps:v.steps}:{},...N?{planned:N}:{},..._?{refusal:_.message,code:_.code}:{}}}function Ze(c){E={code:ce,message:c},j.push(E),n(ee(E)),z=!0}async function $e(){if(t){if(g===void 0)return;let h=Dt(await t.stores.replays.mappingStoreOf(t.folder,g).recordedLoads());return h?{...Pt(h),orgId:g}:void 0}return M=!0,await L("frozen:status",{}),M=!1,y.filter(h=>h.type==="frozen:status:response").at(-1)?.payload?.status?.loadRecords?.find(h=>h.orgId===g)}async function Je(c=[]){if(!e.reload||e.pilot)return;let h=await $e();if(!(!h||h.created.length===0&&c.length===0))return Xe({targetOrgId:g,loadedAt:h.loadedAt,reload:!0,...c.length>0?{sweptObjects:c}:{}})}async function Qe(){let c=await $e();if(!c)return[];n(`reading what a sweep of ${e.target} would take for the loads a reload replaces\u2026`);let h=y.length;await L("frozen:remove:sweep",{targetOrgId:g,loadedAt:c.loadedAt,reload:!0,...B("removal")});let v=y.slice(h);if(v.some(b=>b.type==="frozen:remove:sweep:error"))return;let w=v.filter(b=>b.type==="frozen:remove:sweep:response").at(-1)?.payload?.loads;return[...new Set((w??[]).flatMap(({listing:b})=>Re(b,e)))]}async function co(c){n(`reading what a sweep of ${e.target} would take\u2026`);let h=y.length;await L("frozen:remove:sweep",{targetOrgId:g,loadedAt:c,...B("removal")});let v=y.slice(h);if(v.some(A=>A.type==="frozen:remove:sweep:error"))return;let w=v.filter(A=>A.type==="frozen:remove:sweep:response").at(-1)?.payload,b=[...w?.listing?[w.listing]:[],...(w?.otherLoads??[]).map(({listing:A})=>A)];return[...new Set(b.flatMap(A=>Re(A,e)))]}async function Ye(c){n(`reading what ${t?`a replay of ${s.source}`:"a load"} into ${e.target}${e.pilot?" (pilot)":""} would do\u2026`),await L("frozen:load:preview",{targetOrgId:g,...B("load"),...e.pilot?{pilot:!0}:{},...e.reload?{reload:!0}:{},...e.goneFirst!==void 0?{goneFirst:Ao(e.goneFirst)}:{},...e.writeEncrypted?{writeEncrypted:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{},...e.acceptEmails?{acceptEmails:!0}:{},...e.acceptAutomation?{acceptAutomation:!0}:{}});let h=y.find(R=>R.type==="frozen:load:preview:response")?.payload?.plan,v=y.find(R=>R.type==="frozen:load:preview:error"&&R.payload?.code==="LOAD_CONFIG")?.payload;if(h===void 0&&v!==void 0){j.push({code:"LOAD_CONFIG",message:String(v.message??"")});let R=Array.isArray(v.refusedBeside)?v.refusedBeside:[];for(let{code:I,message:Y}of R)U({code:I,message:Y})}let w=h?Bt(pe(h),e.maxTotal):void 0;w&&U({code:"MAX_RECORDS",message:w});let b=h?.automation?.refused;b&&U(b);let A=h?.emails?.refused;A&&U(A);let k=y.find(R=>R.type==="frozen:load:preview:response")?.payload?.replay?.storage?.refusal??h?.storage?.refusal;k&&U(k);let O=h?.apiRequests?.refused;O&&U(O);let _=(h&&e.sweep?await Qe():[])??[],T=h?await Je(_):void 0;T?.refusal!==void 0&&U({code:T.code??"AUTOMATION_NOT_ACCEPTED",message:T.refusal});let W;if(e.muteAutomation&&h&&F){W=await oe(F).read(g,[...new Set([...h.perObject.map(I=>I.objectApiName),...T?.steps?.delete??[]])]);let R=await Fe(Ee(F),W,{writes:Xo(T?.steps)});if("refused"in R)j.some(({message:I})=>I===R.refused.message)||U(R.refused);else{for(let I of Z(R.planned,e.target??"the target"))n(I);K={mutedAutomation:R.planned,mutePlan:R.plan}}}for(let R of lo(h?.recordTypesGiven,!0,(K?.mutePlan.assign.length??0)>0))n(R);let ae=h?ao(h):[];if(c&&u&&h&&F&&ae.length>0){W??=await oe(F).read(g,h.perObject.map(Y=>Y.objectApiName)).catch(()=>{});let{estimate:R,refused:I}=await io(u,{written:ae,running:so(W,K?.mutePlan)});if(R){H=R;for(let Y of Ne(R))n(Y)}I!==void 0&&U({code:ce,message:I})}return h}async function fo(c){let h=y.length,v=z;M=!0;try{await L("frozen:remove:sweep",{targetOrgId:g,loadedAt:c,...B("removal")})}finally{M=!1}let w=y.splice(h);z=v;let b=w.find(A=>A.type==="frozen:remove:sweep:response")?.payload?.listing;return b&&b.refusal===void 0&&b.found.length>0?b:void 0}async function po(){if(t||await L("frozen:config:save",{config:i}),z)return"ended";switch(e.step){case"select":n(`selecting from ${e.source}\u2026`),await L("frozen:select",{sourceOrgId:p});break;case"extract":n(`extracting from ${e.source}\u2026`),await L("frozen:extract",{sourceOrgId:p,...e.author?{author:e.author}:{}});break;case"load":{if(e.dryRun){if(await Ye(!0),t&&!z)for(let k of t.dryRunEnd(j))n(k);break}let c;if(t){if(c=await Ye(!1),K=void 0,c===void 0||z||j.length>0)return E??=j[0],z=!0,n("Nothing written."),"ended";if(pe(c)===0)return n(`Nothing to create in ${e.target??"the target"}: nothing written.`),"ended"}let h=e.reload&&!e.pilot&&e.sweep?await Qe():[];if(h===void 0)return n("Nothing written."),"ended";let v=e.reload&&!e.pilot?await Je(h):void 0;if(v?.refusal!==void 0)return E={code:v.code??"AUTOMATION_NOT_ACCEPTED",message:v.refusal},j.push(E),n(ee(E)),z=!0,"ended";if(e.sweep&&(n(`around the purge, a sweep deletes what the target's automation made for each ${s.run} it replaces, as the ${s.run}'s user, tied to its records \u2014 run with --dry-run to see what`),C.setRemovalAsker(async k=>{let{lines:O,refusal:_}=xe(k,e.target??"",s.againSubject.sweep);for(let T of O)n(T);if(!(_===void 0||e.acceptAutomation))return E={code:"AUTOMATION_NOT_ACCEPTED",message:_},j.push(E),E})),!e.yes&&!await yt(t&&c?t.question(c):`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 n("Nothing written."),"ended";let w;if(u&&F){let k=c?ao(c):Zo(Q??""),O=await oe(F).read(g,k).catch(()=>{}),_={written:k,running:so(O,e.muteAutomation&&O?Te(O,qe).plan:void 0)},{estimate:T,refused:W}=await io(u,_);if(T){H=T;for(let I of Ne(T))n(I)}if(W!==void 0||T===void 0)return Ze(`${W??""} Nothing was written.`.trim()),"ended";S=new AbortController;let ae=S.signal,R=await ft(()=>u.take(_,T,{signal:ae})).finally(()=>{S=void 0});if("stop"in R)return R.stop.code!==ce?(P=!0,"ended"):(Ze(Rt(R.stop)),"ended");w=R.checkpoint,H=w;for(let I of St(w,e.target??"the target",e.muteAutomation))n(I)}n(t?`replaying ${s.source} into ${e.target}\u2026`:`loading into ${e.target}${e.pilot?" (pilot)":""}\u2026`);let b=new Date().toISOString(),A=e.maxTotal??(c?pe(c):void 0);await L("frozen:load",{targetOrgId:g,...B("load"),...e.pilot?{pilot:!0}:{},...e.reload?{reload:!0}:{},...e.writeEncrypted?{writeEncrypted:!0}:{},...A!==void 0?{maxRecords:A}:{},...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 N=y.filter(k=>k.type==="frozen:load:error").map(Be).find(k=>k!==void 0);if(N&&!E&&(E=N,j.push(E)),g&&Me(y)){let k=Wt(await new Mt(m,{orgId:g}).recorded().catch(()=>{}),b);try{qt(te(),{organizationId:g,sas:Pe(m),startedAt:b,endedAt:new Date().toISOString(),...k?{lastWriteAt:k}:{}})}catch(O){n(`warning: this load could not be added to ${te()}: another sas's sweep of ${e.target??""} will not see it (${O instanceof Error?O.message:String(O)})`)}}if(u&&w){let k=w;H=await u.settle(k,Me(y)).catch(O=>(n(`warning: the checkpoint '${k.name}' taken before the load could not be deleted (${O instanceof Error?O.message:String(O)}): delete it with ${ke("checkpoint")} delete --org ${e.target??""} --checkpoint `+k.checkpointId),k));for(let O of Ot(H))n(O)}break}case"verify":n(t?`verifying the replay of ${s.source} into ${e.target}\u2026`:`verifying ${e.target}\u2026`),await L("frozen:verify",{targetOrgId:g,...B("verify")});break;case"remove":{let c=await $e();if(!c)return n(`No ${s.run} into ${e.target} is recorded ${s.recordedIn}: nothing to remove.`),"ended";if(e.preview){if(n(`reading what a removal from ${e.target} would do\u2026`),await L("frozen:remove:preview",{targetOrgId:g,loadedAt:c.loadedAt,...e.includeChanged?{includeChanged:!0}:{},...B("removal")}),y.some(w=>w.type==="frozen:remove:preview:response")){let w=e.sweep?await co(c.loadedAt):[];if(w===void 0)break;let{planned:b,refusal:A,code:N}=await Xe({targetOrgId:g,loadedAt:c.loadedAt,...w.length>0?{sweptObjects:w}:{}});if(b&&(K={mutedAutomation:b.planned,mutePlan:b.plan}),A!==void 0){let k={code:N??"AUTOMATION_NOT_ACCEPTED",message:A};be.push(k),n(ue(k,"a removal"))}}break}if(e.sweepList){n(`reading what a sweep of ${e.target} would take\u2026`),await L("frozen:remove:sweep",{targetOrgId:g,loadedAt:c.loadedAt,...B("removal")});let w=y.filter(b=>b.type==="frozen:remove:sweep:response").at(-1)?.payload;Ke=[w?.listing,...(w?.otherLoads??[]).map(({listing:b})=>b)].some(b=>b?.refusal!==void 0);break}for(let w of Eo(c,e.target??"",s))n(w);e.sweep&&n(`${Ge(c)>0?"before them, a sweep deletes":"a sweep alone deletes"} what the target's automation made for the ${s.run}, as the ${s.run}'s user, tied to its records \u2014 run ${De("--sweep-list")} to see what`);let h=!1;if(C.setRemovalAsker(async w=>{let{lines:b,refusal:A}=xe(w,e.target??"");for(let N of b)n(N);if(A!==void 0&&!e.acceptAutomation)return{message:A,code:"AUTOMATION_NOT_ACCEPTED"};if(!e.yes&&Fo(c,w.steps)){q=!0;let N=await vt(`Type ${e.target} to delete them:`);if(q=!1,N!==e.target)return h=!0,{message:"Nothing deleted.",code:uo}}n(`removing from ${e.target}\u2026`)}),await L("frozen:remove",{targetOrgId:g,loadedAt:c.loadedAt,...So(e),...B("removal")}),h)return"ended";let v=y.filter(w=>w.type==="frozen:remove:error").map(Be).find(w=>w!==void 0);if(v&&(E=v,be.push(v)),!e.sweep&&!E&&xo(y)){X=await fo(c.loadedAt);for(let w of Mo(X,s))n(w)}break}case"status":await L("frozen:status",{});break}return"through"}}var qe=(e,t)=>t==="insert"||t==="update";function Xo(e){let t=e?ie(e):void 0;return(o,n)=>qe(o,n)||t?.(o,n)===!0}function lo(e,t,o=!1){return Nt((e??[]).map(n=>({recordTypeGiven:n})),t,o)}function so(e,t){return{firing:e?nt(e,t,qe).firing:[]}}function ao(e){let t=[...e.perObject.filter(o=>o.toInsert>0||o.toPurge>0||o.toDeactivate>0).map(o=>o.objectApiName),...(e.placeholders??[]).map(o=>o.placeholderObjectApiName)];return[...new Set(t)]}function Zo(e){try{let t=JSON.parse(ve(G(e,"manifest.json"),"utf8")),o=Object.entries(t.volumetry?.measured??{}).filter(([,n])=>typeof n=="number"&&n>0).map(([n])=>n);if(o.length>0)return o}catch{}try{return go(G(e,"data")).filter(t=>t.endsWith(".json")).map(t=>t.slice(0,-5)).sort()}catch{return[]}}var Jo=new Set(["INVALID_PAYLOAD","CONFIG_MISSING",le.code,"REPLACE_LEAVES_RECORDS","MUTE_PRODUCTION","MUTE_NO_RIGHT","MUTE_FAILED","EMAILS_NOT_ACCEPTED","FROZEN_EMAILS_EXCEEDED","AUTOMATION_NOT_ACCEPTED",ze,"FROZEN_STORAGE_EXCEEDED"]);function Me(e){let t=i=>e.filter(m=>m.type===i).at(-1)?.payload,o=t("frozen:load:response")?.report;if(o){let i=m=>Object.values(m??{}).reduce((r,d)=>r+d,0);return o.perObject.some(m=>m.inserted>0)||(o.placeholders??[]).length>0||i(o.purge?.deleted)>0||i(o.purge?.deactivated)>0}let n=t("frozen:load:error"),s=n?.code;return typeof s=="string"&&Jo.has(s)?!1:n?.written!==0}async function io(e,t){try{let o=await e.scope(t);return{estimate:o,...o.refusal!==void 0?{refused:kt(o.refusal)}:{}}}catch(o){return{refused:lt(o).replace(/ Nothing was written\.$/,"")}}}function Qo(e,t=!0,o=x){let n=o===x?"the sas":"the folder of its replays";return e==="load"&&!t?`interrupted: the ${o.run} stopped before it created or purged a record: ${n} is as it was, and ${o.remove} has nothing of this ${o.run} to take back`:e==="load"?`interrupted: the ${o.run} stopped before it was through; what it wrote is recorded in ${n} and the audit trail, and ${o.remove} takes it back`:e==="remove"?`interrupted: the removal stopped before it was through; what it deleted is recorded, and ${o.remove} again takes what it left`:e==="preview"?"interrupted: the preview stopped before it was through, and deleted nothing":`interrupted: the ${e} stopped before it was through`}process.argv[1]?.includes("sandforge-frozen")&&(Et(),Ko().then(()=>process.exit(process.exitCode??0)).catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
|
|
272
|
-
`),process.exit(1)}));export{
|
|
269
|
+
`),S){S.abort();return}for(let h of $.getRunning())$.abort(h.operationId);f&&$.cancelBeforeStart(f),(!f||D)&&process.exit(de(c))}),Q=t?void 0:typeof i.datasetDir=="string"?i.datasetDir:V(m,"dataset"),L=[],G=c=>{let h=t?{code:c.code,message:t.reword(c.code,c.message)}:c;L.push(h),n(ue(h,`a ${s.run}`))},W=c=>{if(!t)return{};let{organizationId:h,checkpointId:v,config:w}=t.request;return c==="load"?{replay:t.request}:c==="verify"?{replay:{organizationId:h,checkpointId:v,...w?{config:w}:{}}}:{replay:{organizationId:h,checkpointId:v}}},be=[],E,Ke=!1,K,H,X,Ae=async(c,h=Number(process.exitCode??0))=>{if(!e.json)return;let v=[...L,...be],w=await Vo(e.step,y,{...Q!==void 0?{datasetDir:Q}:{},sasDir:m,...g?{targetOrgId:g}:{},...v.length>0?{refusals:v.map(({message:A})=>A),refusalCodes:v.map(({code:A})=>A)}:{},...K?{mute:K}:{},...H?{checkpoint:H}:{}}),b=t?{...t.answer(w,{exit:h,...c?{ended:c}:{},...E?{refused:E}:{},...g?{targetOrgId:g}:{}}),...X?{notSwept:X}:{}}:{...w,...X?{notSwept:X}:{},...E?{refused:E}:{},...c?{ended:c}:{}};process.stdout.write(`${JSON.stringify(b,null,2)}
|
|
270
|
+
`)},j=async(c,h)=>{let v=`cli-${c}-${Date.now()}`;f=v;try{return await C.handle({id:v,type:c,payload:h})}finally{f=void 0}},He;try{He=await ho()}finally{se()}if(He==="ended"&&!U){z&&(process.exitCode=1),await Ae(!0);return}if(U){await Ae(void 0,de(U)),process.stderr.write(`${x?ft:Yo(e.preview?"preview":e.step,e.step!=="load"||e.dryRun||Me(y),s)}
|
|
271
|
+
`),process.exitCode=de(U);return}if(it(z||L.length>0?1:Ke?3:Po(e.step,y)),e.json){await Ae();return}n(`done in ${Date.now()-o}ms`);async function Xe(c){await j("frozen:remove:automation",{...c,...W("removal")});let h=T=>y.find(q=>q.type===T)?.payload,v=h("frozen:remove:automation:response"),w=Array.isArray(c.sweptObjects)?c.sweptObjects:[],b=v?.purge&&w.length>0?v.purge:void 0,A=v&&e.muteAutomation?F&&(e.preview||e.dryRun)?await Fe(Ee(F),v.automation,{writes:ie(v.steps)}):Te(v.automation,ie(v.steps)):void 0,N=A&&!("refused"in A)?A:void 0,{lines:k,refusal:O}=xe({read:v?.automation??{unread:String(h("frozen:remove:automation:error")?.message)},steps:b??v?.steps??{},...N?{mute:{automation:N.automation,muted:N.planned}}:{}},e.target??"",c.reload===!0?s.againSubject.purge:"removal",b?{delete:w}:void 0);for(let T of k)n(T);let B=A&&"refused"in A?A.refused:O!==void 0&&!e.acceptAutomation?{code:"AUTOMATION_NOT_ACCEPTED",message:O}:void 0;return{...v?{steps:v.steps}:{},...N?{planned:N}:{},...B?{refusal:B.message,code:B.code}:{}}}function Ze(c){E={code:ce,message:c},L.push(E),n(ee(E)),z=!0}async function $e(){if(t){if(g===void 0)return;let h=Pt(await t.stores.replays.mappingStoreOf(t.folder,g).recordedLoads());return h?{...xt(h),orgId:g}:void 0}return _=!0,await j("frozen:status",{}),_=!1,y.filter(h=>h.type==="frozen:status:response").at(-1)?.payload?.status?.loadRecords?.find(h=>h.orgId===g)}async function Je(c=[]){if(!e.reload||e.pilot)return;let h=await $e();if(!(!h||h.created.length===0&&c.length===0))return Xe({targetOrgId:g,loadedAt:h.loadedAt,reload:!0,...c.length>0?{sweptObjects:c}:{}})}async function Qe(){let c=await $e();if(!c)return[];n(`reading what a sweep of ${e.target} would take for the loads a reload replaces\u2026`);let h=y.length;await j("frozen:remove:sweep",{targetOrgId:g,loadedAt:c.loadedAt,reload:!0,...W("removal")});let v=y.slice(h);if(v.some(b=>b.type==="frozen:remove:sweep:error"))return;let w=v.filter(b=>b.type==="frozen:remove:sweep:response").at(-1)?.payload?.loads;return[...new Set((w??[]).flatMap(({listing:b})=>Re(b,e)))]}async function fo(c){n(`reading what a sweep of ${e.target} would take\u2026`);let h=y.length;await j("frozen:remove:sweep",{targetOrgId:g,loadedAt:c,...W("removal")});let v=y.slice(h);if(v.some(A=>A.type==="frozen:remove:sweep:error"))return;let w=v.filter(A=>A.type==="frozen:remove:sweep:response").at(-1)?.payload,b=[...w?.listing?[w.listing]:[],...(w?.otherLoads??[]).map(({listing:A})=>A)];return[...new Set(b.flatMap(A=>Re(A,e)))]}async function Ye(c){n(`reading what ${t?`a replay of ${s.source}`:"a load"} into ${e.target}${e.pilot?" (pilot)":""} would do\u2026`),await j("frozen:load:preview",{targetOrgId:g,...W("load"),...e.pilot?{pilot:!0}:{},...e.reload?{reload:!0}:{},...e.goneFirst!==void 0?{goneFirst:$o(e.goneFirst)}:{},...e.writeEncrypted?{writeEncrypted:!0}:{},...e.muteAutomation?{muteAutomation:!0}:{},...e.acceptEmails?{acceptEmails:!0}:{},...e.acceptAutomation?{acceptAutomation:!0}:{}});let h=y.find(R=>R.type==="frozen:load:preview:response")?.payload?.plan,v=y.find(R=>R.type==="frozen:load:preview:error"&&R.payload?.code==="LOAD_CONFIG")?.payload;if(h===void 0&&v!==void 0){L.push({code:"LOAD_CONFIG",message:String(v.message??"")});let R=Array.isArray(v.refusedBeside)?v.refusedBeside:[];for(let{code:I,message:Y}of R)G({code:I,message:Y})}let w=h?Ut(pe(h),e.maxTotal):void 0;w&&G({code:"MAX_RECORDS",message:w});let b=h?.automation?.refused;b&&G(b);let A=h?.emails?.refused;A&&G(A);let k=y.find(R=>R.type==="frozen:load:preview:response")?.payload?.replay?.storage?.refusal??h?.storage?.refusal;k&&G(k);let O=h?.apiRequests?.refused;O&&G(O);let B=(h&&e.sweep?await Qe():[])??[],T=h?await Je(B):void 0;T?.refusal!==void 0&&G({code:T.code??"AUTOMATION_NOT_ACCEPTED",message:T.refusal});let q;if(e.muteAutomation&&h&&F){q=await oe(F).read(g,[...new Set([...h.perObject.map(I=>I.objectApiName),...T?.steps?.delete??[]])]);let R=await Fe(Ee(F),q,{writes:Zo(T?.steps)});if("refused"in R)L.some(({message:I})=>I===R.refused.message)||G(R.refused);else{for(let I of Z(R.planned,e.target??"the target"))n(I);K={mutedAutomation:R.planned,mutePlan:R.plan}}}for(let R of co(h?.recordTypesGiven,!0,(K?.mutePlan.assign.length??0)>0))n(R);let ae=h?io(h):[];if(c&&u&&h&&F&&ae.length>0){q??=await oe(F).read(g,h.perObject.map(Y=>Y.objectApiName)).catch(()=>{});let{estimate:R,refused:I}=await uo(u,{written:ae,running:ao(q,K?.mutePlan)});if(R){H=R;for(let Y of Ne(R))n(Y)}I!==void 0&&G({code:ce,message:I})}return h}async function po(c){let h=y.length,v=z;_=!0;try{await j("frozen:remove:sweep",{targetOrgId:g,loadedAt:c,...W("removal")})}finally{_=!1}let w=y.splice(h);z=v;let b=w.find(A=>A.type==="frozen:remove:sweep:response")?.payload?.listing;return b&&b.refusal===void 0&&b.found.length>0?b:void 0}async function ho(){if(t||await j("frozen:config:save",{config:i}),z)return"ended";switch(e.step){case"select":n(`selecting from ${e.source}\u2026`),await j("frozen:select",{sourceOrgId:p});break;case"extract":n(`extracting from ${e.source}\u2026`),await j("frozen:extract",{sourceOrgId:p,...e.author?{author:e.author}:{}});break;case"load":{if(e.dryRun){if(await Ye(!0),t&&!z)for(let k of t.dryRunEnd(L))n(k);break}let c;if(t){if(c=await Ye(!1),K=void 0,c===void 0||z||L.length>0)return E??=L[0],z=!0,n("Nothing written."),"ended";if(pe(c)===0)return n(`Nothing to create in ${e.target??"the target"}: nothing written.`),"ended"}let h=e.reload&&!e.pilot&&e.sweep?await Qe():[];if(h===void 0)return n("Nothing written."),"ended";let v=e.reload&&!e.pilot?await Je(h):void 0;if(v?.refusal!==void 0)return E={code:v.code??"AUTOMATION_NOT_ACCEPTED",message:v.refusal},L.push(E),n(ee(E)),z=!0,"ended";if(e.sweep&&(n(`around the purge, a sweep deletes what the target's automation made for each ${s.run} it replaces, as the ${s.run}'s user, tied to its records \u2014 run with --dry-run to see what`),C.setRemovalAsker(async k=>{let{lines:O,refusal:B}=xe(k,e.target??"",s.againSubject.sweep);for(let T of O)n(T);if(!(B===void 0||e.acceptAutomation))return E={code:"AUTOMATION_NOT_ACCEPTED",message:B},L.push(E),E})),!e.yes&&!await vt(t&&c?t.question(c):`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 n("Nothing written."),"ended";let w;if(u&&F){let k=c?io(c):Jo(Q??""),O=await oe(F).read(g,k).catch(()=>{}),B={written:k,running:ao(O,e.muteAutomation&&O?Te(O,qe).plan:void 0)},{estimate:T,refused:q}=await uo(u,B);if(T){H=T;for(let I of Ne(T))n(I)}if(q!==void 0||T===void 0)return Ze(`${q??""} Nothing was written.`.trim()),"ended";S=new AbortController;let ae=S.signal,R=await pt(()=>u.take(B,T,{signal:ae})).finally(()=>{S=void 0});if("stop"in R)return R.stop.code!==ce?(x=!0,"ended"):(Ze(St(R.stop)),"ended");w=R.checkpoint,H=w;for(let I of Ot(w,e.target??"the target",e.muteAutomation))n(I)}n(t?`replaying ${s.source} into ${e.target}\u2026`:`loading into ${e.target}${e.pilot?" (pilot)":""}\u2026`);let b=new Date().toISOString(),A=e.maxTotal??(c?pe(c):void 0);await j("frozen:load",{targetOrgId:g,...W("load"),...e.pilot?{pilot:!0}:{},...e.reload?{reload:!0}:{},...e.writeEncrypted?{writeEncrypted:!0}:{},...A!==void 0?{maxRecords:A}:{},...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 N=y.filter(k=>k.type==="frozen:load:error").map(Be).find(k=>k!==void 0);if(N&&!E&&(E=N,L.push(E)),g&&Me(y)){let k=Gt(await new _t(m,{orgId:g}).recorded().catch(()=>{}),b);try{Vt(te(),{organizationId:g,sas:Pe(m),startedAt:b,endedAt:new Date().toISOString(),...k?{lastWriteAt:k}:{}})}catch(O){n(`warning: this load could not be added to ${te()}: another sas's sweep of ${e.target??""} will not see it (${O instanceof Error?O.message:String(O)})`)}}if(u&&w){let k=w;H=await u.settle(k,Me(y)).catch(O=>(n(`warning: the checkpoint '${k.name}' taken before the load could not be deleted (${O instanceof Error?O.message:String(O)}): delete it with ${ke("checkpoint")} delete --org ${e.target??""} --checkpoint `+k.checkpointId),k));for(let O of Et(H))n(O)}break}case"verify":n(t?`verifying the replay of ${s.source} into ${e.target}\u2026`:`verifying ${e.target}\u2026`),await j("frozen:verify",{targetOrgId:g,...W("verify")});break;case"remove":{let c=await $e();if(!c)return n(`No ${s.run} into ${e.target} is recorded ${s.recordedIn}: nothing to remove.`),"ended";if(e.preview){if(n(`reading what a removal from ${e.target} would do\u2026`),await j("frozen:remove:preview",{targetOrgId:g,loadedAt:c.loadedAt,...e.includeChanged?{includeChanged:!0}:{},...W("removal")}),y.some(w=>w.type==="frozen:remove:preview:response")){let w=e.sweep?await fo(c.loadedAt):[];if(w===void 0)break;let{planned:b,refusal:A,code:N}=await Xe({targetOrgId:g,loadedAt:c.loadedAt,...w.length>0?{sweptObjects:w}:{}});if(b&&(K={mutedAutomation:b.planned,mutePlan:b.plan}),A!==void 0){let k={code:N??"AUTOMATION_NOT_ACCEPTED",message:A};be.push(k),n(ue(k,"a removal"))}}break}if(e.sweepList){n(`reading what a sweep of ${e.target} would take\u2026`),await j("frozen:remove:sweep",{targetOrgId:g,loadedAt:c.loadedAt,...W("removal")});let w=y.filter(b=>b.type==="frozen:remove:sweep:response").at(-1)?.payload;Ke=[w?.listing,...(w?.otherLoads??[]).map(({listing:b})=>b)].some(b=>b?.refusal!==void 0);break}for(let w of Fo(c,e.target??"",s))n(w);e.sweep&&n(`${Ge(c)>0?"before them, a sweep deletes":"a sweep alone deletes"} what the target's automation made for the ${s.run}, as the ${s.run}'s user, tied to its records \u2014 run ${De("--sweep-list")} to see what`);let h=!1;if(C.setRemovalAsker(async w=>{let{lines:b,refusal:A}=xe(w,e.target??"");for(let N of b)n(N);if(A!==void 0&&!e.acceptAutomation)return{message:A,code:"AUTOMATION_NOT_ACCEPTED"};if(!e.yes&&To(c,w.steps)){D=!0;let N=await bt(`Type ${e.target} to delete them:`);if(D=!1,N!==e.target)return h=!0,{message:"Nothing deleted.",code:lo}}n(`removing from ${e.target}\u2026`)}),await j("frozen:remove",{targetOrgId:g,loadedAt:c.loadedAt,...Oo(e),...W("removal")}),h)return"ended";let v=y.filter(w=>w.type==="frozen:remove:error").map(Be).find(w=>w!==void 0);if(v&&(E=v,be.push(v)),!e.sweep&&!E&&Mo(y)){X=await po(c.loadedAt);for(let w of _o(X,s))n(w)}break}case"status":await j("frozen:status",{});break}return"through"}}var qe=(e,t)=>t==="insert"||t==="update";function Zo(e){let t=e?ie(e):void 0;return(o,n)=>qe(o,n)||t?.(o,n)===!0}function co(e,t,o=!1){return It((e??[]).map(n=>({recordTypeGiven:n})),t,o)}function ao(e,t){return{firing:e?nt(e,t,qe).firing:[]}}function io(e){let t=[...e.perObject.filter(o=>o.toInsert>0||o.toPurge>0||o.toDeactivate>0).map(o=>o.objectApiName),...(e.placeholders??[]).map(o=>o.placeholderObjectApiName)];return[...new Set(t)]}function Jo(e){try{let t=JSON.parse(ve(V(e,"manifest.json"),"utf8")),o=Object.entries(t.volumetry?.measured??{}).filter(([,n])=>typeof n=="number"&&n>0).map(([n])=>n);if(o.length>0)return o}catch{}try{return wo(V(e,"data")).filter(t=>t.endsWith(".json")).map(t=>t.slice(0,-5)).sort()}catch{return[]}}var Qo=new Set(["INVALID_PAYLOAD","CONFIG_MISSING",le.code,"REPLACE_LEAVES_RECORDS","MUTE_PRODUCTION","MUTE_NO_RIGHT","MUTE_FAILED","EMAILS_NOT_ACCEPTED","FROZEN_EMAILS_EXCEEDED","AUTOMATION_NOT_ACCEPTED",ze,"FROZEN_STORAGE_EXCEEDED"]);function Me(e){let t=i=>e.filter(m=>m.type===i).at(-1)?.payload,o=t("frozen:load:response")?.report;if(o){let i=m=>Object.values(m??{}).reduce((r,d)=>r+d,0);return o.perObject.some(m=>m.inserted>0)||(o.placeholders??[]).length>0||i(o.purge?.deleted)>0||i(o.purge?.deactivated)>0}let n=t("frozen:load:error"),s=n?.code;return typeof s=="string"&&Qo.has(s)?!1:n?.written!==0}async function uo(e,t){try{let o=await e.scope(t);return{estimate:o,...o.refusal!==void 0?{refused:Rt(o.refusal)}:{}}}catch(o){return{refused:ct(o).replace(/ Nothing was written\.$/,"")}}}function Yo(e,t=!0,o=M){let n=o===M?"the sas":"the folder of its replays";return e==="load"&&!t?`interrupted: the ${o.run} stopped before it created or purged a record: ${n} is as it was, and ${o.remove} has nothing of this ${o.run} to take back`:e==="load"?`interrupted: the ${o.run} stopped before it was through; what it wrote is recorded in ${n} and the audit trail, and ${o.remove} takes it back`:e==="remove"?`interrupted: the removal stopped before it was through; what it deleted is recorded, and ${o.remove} again takes what it left`:e==="preview"?"interrupted: the preview stopped before it was through, and deleted nothing":`interrupted: the ${e} stopped before it was through`}process.argv[1]?.includes("sandforge-frozen")&&(Ft(),Ho().then(()=>process.exit(process.exitCode??0)).catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
|
|
272
|
+
`),process.exit(1)}));export{$o as a,ko as b,Ro as c,M as d,Oo as e,xe as f,Fo as g,To as h,to as i,Lo as j,Be as k,Ue as l,Do as m,Po as n,xo as o,ro as p,Mo as q,_o as r,Bo as s,Uo as t,Wo as u,Vo as v,Ko as w,Ho as x,Xo as y,co as z,io as A,Jo as B,Me as C,Yo as D};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a}from"./chunk-
|
|
7
|
+
import{a}from"./chunk-EAC5QCE3.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as TransformPipeline};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{b as Ne}from"./chunk-WB2RIVO3.mjs";import{a as re}from"./chunk-BOGNK4LV.mjs";import{j as Oe}from"./chunk-VINGECAJ.mjs";import{a as Re,b as Q}from"./chunk-T63U4OZJ.mjs";import{e as Pe,f as we,g as Ie}from"./chunk-5XTUSN72.mjs";import{Bb as xe,Hb as Le,Kc as Ge,Za as Se,ec as Fe,hc as Me,jb as ke,lb as ae,mc as Be,nb as Ce,ob as De,pc as ve,qb as Te,rb as je,tb as _e,vc as Ue}from"./chunk-KB4ZHM4Q.mjs";import{a as B}from"./chunk-4TLYUZD5.mjs";import{i as be}from"./chunk-INIT2UKJ.mjs";import{b as ye}from"./chunk-CVHNXJH3.mjs";import{a as he}from"./chunk-EADHKH3A.mjs";import{b as ne,d as ie}from"./chunk-M6K34KGF.mjs";import{q,r as X}from"./chunk-TNT27RBG.mjs";import{a as v,h as j}from"./chunk-TZE3Y7IQ.mjs";import{b as G}from"./chunk-CA5NAXSU.mjs";import{a as Y,j as Ee}from"./chunk-ICIYL45C.mjs";import{Ac as fe,Ec as te,Fc as ge,Gc as K,Hc as Ae,Lc as V,Mc as oe,zc as me}from"./chunk-PMWAFDUB.mjs";import{b as Z,f as ee,k as de,l as pe}from"./chunk-WZQEK4WT.mjs";var He=we,Ke=Pe,$=200;function Ve(n,e){let t=new Set(e?.fields.map(r=>r.name)??[]),i=new Set(n.split(", "));for(let r of[Y,oe])t.has(r)&&i.add(r);return[...i].join(", ")}var Xe=10,Ye=new Set([q]),M="IsPersonAccount",qe="IsStandard",$e=class{maxConcurrent;constructor(e=10){this.maxConcurrent=e}async listObjects(e,t,i){let[r,c]=await Promise.all([e.describeGlobal(),t.describeGlobal()]),s=new Set(r.sobjects.filter(o=>o.createable).map(o=>o.name)),a=ie(c.sobjects.filter(o=>!s.has(o.name)),await this.toolingObjects(t)),l=new Map(c.sobjects.map(o=>[o.name,o.createable!==!1]));return r.sobjects.filter(o=>o.queryable&&(o.createable||l.get(o.name)===!0)).filter(o=>i||o.custom).filter(o=>!ne(o.name,a)).map(o=>({apiName:o.name,label:o.label,custom:o.custom,...l.has(o.name)?l.get(o.name)===!1?{notCreateableInTarget:!0}:{}:{missingInTarget:!0}}))}async countObjects(e,t){return this.countRecords(e,t)}async scan(e,t,i,r,c={}){let s=ce(c.maxDepth,He),a=ce(c.maxObjects,Ke),l=ce(c.maxRecordsPerObject,5e4),o=c.onProgress??(()=>{});if(i.length===0)throw new Error("Choose the objects to copy: a scan starts from them, and with none chosen it would describe and count every object of the org.");let g=await e.describeGlobal(),h=[...i],m=await t.describeGlobal(),N=ie(m.sobjects,await this.toolingObjects(t)),I=A=>ne(A,N);h=h.filter(A=>!I(A)),o(`describing ${h.length} selected object(s)\u2026`);let R=await this.describeAll(e,h),P=new Set(R.keys()),C=new Map(g.sobjects.map(A=>[A.name,A.custom])),D=new Map;for(let A of g.sobjects)A.keyPrefix&&D.set(A.keyPrefix,A.name);let f=await this.walkRecords(e,R,P,{isStandard:A=>C.get(A)===!1||!C.has(A)&&!A.includes("__"),includeStandardObjects:r,leftOut:I,keyPrefixes:D,maxDepth:s,maxObjects:a,maxRecords:l,say:o}),S=new Set(m.sobjects.map(A=>A.name)),_=[...R.keys()].filter(A=>!S.has(A)),x=await this.currenciesOf(e,t,R),W=await this.personAccountsOf(e,R,P,f.parentIds,{cutShort:f.cutShort,cutAt:f.cutAt});return{objectDescribes:R,autoDiscoveredObjects:f.added,missingInTarget:_,recordCounts:f.recordCounts,totalObjectsScanned:R.size,parentIds:f.parentIds,personAccounts:W,scope:{maxDepth:s,maxObjects:a,selected:[...P],parents:f.added.map(A=>({objectApiName:A,records:f.parentIds.get(A)?.length??0})),leftEmpty:f.leftEmpty,standardNeeded:f.standardNeeded,...f.followedByDefault.length>0?{followedByDefault:f.followedByDefault}:{},...x?{currencies:x}:{},...f.cutShort.length>0?{cutShort:f.cutShort}:{}}}}async readFitRows(e,t,i=()=>{}){let r=new Set(t.objectDescribes.keys()),c=new Map;for(let s of t.scope.selected){let a=t.objectDescribes.get(s);if(!a)continue;i(`reading the lookups of ${s} to fit it\u2026`);let l=new Set(a.fields.map(m=>m.name)),o=We(s,a).filter(m=>m.targets.some(N=>r.has(N))),g=["Id",...new Set(o.map(m=>m.field)),...(s===q||s===X)&&l.has(M)?[M]:[],...s===ge&&l.has(qe)?[qe]:[]],h=await be(`SELECT ${g.map(j).join(", ")} FROM ${j(s)} ORDER BY Id`,async m=>(await this.readAll(e,m)).records);c.set(s,h.filter(m=>typeof m.Id=="string"))}return c}async walkFrom(e,t,i,r=()=>{}){let c=new Map(t.objectDescribes),s=new Set(c.keys()),a=new Map;for(let[o,g]of c)g.keyPrefix&&a.set(g.keyPrefix,o);let l=await this.walkRecords(e,c,new Set(t.scope.selected),{isStandard:()=>!1,includeStandardObjects:!0,leftOut:o=>!s.has(o),keyPrefixes:a,maxDepth:t.scope.maxDepth,maxObjects:s.size,say:r},i);return{added:l.added,parentIds:l.parentIds,personAccounts:l.personAccounts,leftEmpty:l.leftEmpty,namingSelected:l.namingSelected}}async personAccountsOf(e,t,i,r,c){let s=new Map;for(let a of[q,X]){if(!t.get(a)?.fields.some(g=>g.name===M))continue;let o=`SELECT COUNT() FROM ${j(a)} WHERE ${M} = true`;try{let g=c.cutShort.find(m=>m.objectApiName===a)?.copied;if(i.has(a)&&g!==void 0){let m=c.cutAt.get(a)??await this.lastIdOfTheFirst(e,a,g);s.set(a,m!==void 0?(await e.query(`${o} AND Id <= '${v(m)}'`)).totalSize:Math.min((await e.query(o)).totalSize,g));continue}if(i.has(a)){s.set(a,(await e.query(o)).totalSize);continue}let h=0;for(let m of this.chunk([...r.get(a)??[]],$)){let N=m.map(I=>`'${v(I)}'`).join(", ");h+=(await e.query(`${o} AND Id IN (${N})`)).totalSize}s.set(a,h)}catch(g){B.warn("Autopilot could not count the person accounts it copies",{objectApiName:a,error:G(g)})}}return s}async lastIdOfTheFirst(e,t,i){let{records:r}=await this.readAll(e,`SELECT Id FROM ${j(t)} ORDER BY Id`),c=r.length>=i?r[i-1]?.Id:void 0;return typeof c=="string"?c:void 0}async currenciesOf(e,t,i){let r=[...i.values()].filter(l=>l.fields.some(o=>o.name===Y)).map(l=>l.name).sort();if(r.length===0)return;let c=await Ee(async l=>(await e.query(l)).records,async l=>(await t.query(l)).records),s=c?.target.corporate;if(!c||s===void 0)return;let a=[...c.source.active].filter(l=>!c.target.active.has(l));return a.length>0?{notInTarget:a.sort(),writtenIn:s,objects:r}:void 0}async walkRecords(e,t,i,r,c){let s=new Set(i),a=new Set,l=r.maxRecords??5e4,o=r.maxObjects,g=r.maxObjects*Ie,h=new Map,m=[],N=[],I=[],R=new Map,P=[],C=new Map,D=new Map,f=new Map,S=[],_=u=>{let b=t.get(u);return b?We(u,b).map(E=>({...E,targets:E.targets.filter(d=>!r.leftOut(d)&&!a.has(d))})).filter(E=>E.targets.length>0):[]},x=u=>["Id",...new Set(_(u).map(b=>b.field)),...c&&(u===q||u===X)&&t.get(u)?.fields.some(b=>b.name===M)?[M]:[]].map(j).join(", "),W=(u,b,E)=>{let d=`${u.objectApiName}.${u.field}>${b}`;h.has(d)||h.set(d,{objectApiName:u.objectApiName,fieldApiName:u.field,target:b,reason:E,...u.required?{required:!0}:{}})},A=new Map,z=(u,b,E)=>{let d=_(u);for(let w of b)for(let p of d){let y=w[p.field];if(typeof y!="string"||y==="")continue;let O=Qe(y,p.targets,r.keyPrefixes,c!==void 0&&p.polymorphic);if(!O)continue;if(i.has(O)){c&&E>0&&S.push({objectApiName:u,field:p.field,required:p.required,target:O,id:y});continue}let k={objectApiName:u,field:p.field,required:p.required};if(E>=r.maxDepth&&!p.required){s.has(O)||W(k,O,"depth");continue}if(D.get(O)?.has(y))continue;let L=A.get(O)??{ids:new Set,required:!1,via:[]};L.ids.add(y),L.required||=p.required,L.via.some(T=>T.objectApiName===u&&T.field===p.field)||L.via.push(k),A.set(O,L)}},J=[];for(let u of i){if(c){z(u,c.get(u)??[],0);continue}let b=_(u).filter(E=>E.targets.some(d=>!i.has(d)));if(b.length===0){J.push(u);continue}r.say(`reading the lookups of ${u}\u2026`);try{let E=["Id",...new Set(b.map(p=>p.field))].map(j).join(", "),{records:d,truncated:w}=await this.readAll(e,`SELECT ${E} FROM ${j(u)} ORDER BY Id`,l);if(C.set(u,d.length),w){let p=(await this.countRecords(e,[u])).get(u);I.push({objectApiName:u,copied:d.length,...p!==void 0?{total:p}:{}});let y=d[d.length-1]?.Id;typeof y=="string"&&R.set(u,y)}z(u,d,0)}catch(E){B.warn("Autopilot could not read the lookups of a selected object",{objectApiName:u,error:G(E)}),J.push(u)}}for(let[u,b]of await this.countRecords(e,J))b>l?(C.set(u,l),I.push({objectApiName:u,copied:l,total:b})):C.set(u,b);let ze=r.maxDepth+Xe;for(let u=1;A.size>0&&u<=ze;u++){let b=A;A=new Map;let E=[];for(let[d,w]of b){if(s.has(d))continue;let p=r.isStandard(d)&&!r.includeStandardObjects,y=p&&!w.required&&Ye.has(d),O;if(p&&!w.required&&!y?O="standard":s.size>=o&&(w.required&&o<g?o++:O="objects"),O){for(let k of w.via)W(k,d,O);b.delete(d);continue}if(s.add(d),E.push(d),y)N.push({objectApiName:d,referencedBy:w.via.map(k=>`${k.objectApiName}.${k.field}`)});else if(p){let k=w.via[0];m.push({objectApiName:d,neededBy:`${k.objectApiName}.${k.field}`})}}if(E.length>0){let d=E.filter(p=>!t.has(p));d.length>0&&r.say(`describing ${d.length} parent object(s) at depth ${u}\u2026`);let w=await this.describeAll(e,d);for(let p of E){let y=t.get(p)??w.get(p);y?(t.set(p,y),P.push(p)):(s.delete(p),a.add(p),b.delete(p))}}for(let[d,w]of b){let p=[...w.ids].filter(T=>!D.get(d)?.has(T));if(p.length===0)continue;r.say(`reading ${p.length} ${d} record(s) by id\u2026`);let y=D.get(d)??new Set;D.set(d,y);let O=d===te,k=O?Ve(x(d),t.get(d)):x(d),L=[];for(let T of this.chunk(p,$)){let U=T.map(F=>`'${v(F)}'`).join(", "),H=(await e.query(`SELECT ${k} FROM ${j(d)} WHERE Id IN (${U})`)).records.filter(F=>typeof F.Id=="string");for(let F of H)y.add(F.Id);L.push(...H);let ue=H.filter(F=>F[M]===!0).length;c&&ue>0&&f.set(d,(f.get(d)??0)+ue),z(d,H,u)}if(O){let T=await this.standardPricesOf(e,k,L,y);if(T.length>0){r.say(`reading ${T.length} standard price(s) the prices need\u2026`);for(let U of T)y.add(U.Id);z(d,T.map(U=>({...U,[K]:void 0})),u)}}}}let le=new Map;for(let u of P){let b=[...D.get(u)??[]];le.set(u,b),C.set(u,b.length)}return{added:P,leftEmpty:[...h.values()].filter(u=>!s.has(u.target)),standardNeeded:m,followedByDefault:N.filter(u=>s.has(u.objectApiName)),cutShort:I,cutAt:R,recordCounts:C,parentIds:le,personAccounts:f,namingSelected:S}}async standardPricesOf(e,t,i,r){let c=s=>[s[V],s[Y],s[oe]].map(a=>String(a??"")).join("|");try{let[s]=(await e.query(Ae)).records,a=s?.Id;if(typeof a!="string")return[];let l=i.filter(m=>m[K]!==a),o=[...new Set(l.flatMap(m=>{let N=m[V];return typeof N=="string"&&N!==""?[N]:[]}))];if(o.length===0)return[];let g=new Set(l.map(c)),h=[];for(let m of this.chunk(o,$)){let N=m.map(R=>`'${v(R)}'`).join(", "),I=await e.query(`SELECT ${t} FROM ${te} WHERE ${K} = '${v(a)}' AND ${V} IN (${N})`);for(let R of I.records){let P=R.Id;typeof P!="string"||r.has(P)||!g.has(c(R))||h.push(R)}}return h}catch(s){return B.warn("Autopilot could not read the standard prices its prices need",{error:G(s)}),[]}}async readAll(e,t,i=5e4){let{queryMore:r}=e;if(!r){let s=await e.query(t);return{records:s.records,truncated:s.done===!1}}let c=await he({query:s=>e.query(s),queryMore:s=>r.call(e,s)},t,i);return c.truncated&&B.warn("Autopilot read the lookups of a selected object to its bound only",{records:c.records.length}),{records:c.records,truncated:c.truncated}}async toolingObjects(e){if(!e.tooling)return[];try{return(await e.tooling.describeGlobal()).sobjects.map(i=>i.name)}catch(t){return B.warn("Autopilot could not ask the Tooling API which objects are metadata",{error:G(t)}),[]}}async describeAll(e,t){let i=new Map,r=this.chunk(t,this.maxConcurrent);for(let c of r){let s=await Promise.allSettled(c.map(a=>e.describe(a)));for(let a of s)a.status==="fulfilled"&&i.set(a.value.name,a.value)}return i}async countRecords(e,t){let i=new Map,r=this.chunk(t,this.maxConcurrent);for(let c of r){let s=await Promise.allSettled(c.map(async a=>{let l=await e.query(`SELECT COUNT() FROM ${j(a)}`);return{name:a,count:l.totalSize}}));for(let a of s)a.status==="fulfilled"&&i.set(a.value.name,a.value.count)}return i}chunk(e,t){let i=[];for(let r=0;r<e.length;r+=t)i.push(e.slice(r,r+t));return i}};function ce(n,e){return n!==void 0&&Number.isInteger(n)&&n>0?n:e}function We(n,e){return e.fields.filter(t=>t.referenceTo.length>0&&fe(t)).map(t=>({field:t.name,targets:[...t.referenceTo],required:me(n,t.name,t.nillable),polymorphic:t.referenceTo.length>1}))}function Qe(n,e,t,i=!1){if(e.length===1&&!i)return e[0];let r=t.get(n.slice(0,3));return r!==void 0&&e.includes(r)?r:void 0}var Je={PII:"PII",PHI:"PHI",PCI:"PCI",Confidential:"SENSITIVE"},Ze={PII:"fake",PHI:"nullify",PCI:"mask",SENSITIVE:"hash",NONE:"fake"},et={name_pattern:"field_name",type_analysis:"field_name",content_pattern:"content_sampling"},tt=.9;function Ot(n,e){let t=[];for(let[i,r]of e){let c=r.fields.filter(o=>o.createable&&Ne({name:o.name,label:o.label,type:o.type})),s=new Map(c.map(o=>[o.name,o])),a=new Map,l=n.detectPII(i,c.map(o=>({apiName:o.name,label:o.label,type:o.type})));for(let o of l.piiFields){let g=s.get(o.fieldApiName);if(!g)continue;let h=Je[o.classification];a.set(g.name,{objectApiName:i,fieldApiName:g.name,fieldLabel:g.label,fieldType:g.type,piiCategory:h,detectionMethod:et[o.detectionMethod],confidence:o.confidence,suggestedMethod:Ze[h]})}for(let o of c)a.has(o.name)||Q(o.name,o.type)===void 0||a.set(o.name,{objectApiName:i,fieldApiName:o.name,fieldLabel:o.label,fieldType:o.type,piiCategory:"PII",detectionMethod:"field_name",confidence:tt,suggestedMethod:"fake"});t.push(...a.values())}return t}function Pt(n,e){let t=r=>`${r.objectApiName}.${r.fieldApiName}`,i=new Set(n.map(t));return[...n,...e.filter(r=>!i.has(t(r)))]}var ot=["Contact","Lead"];function wt(n,e,t){if(n==="none")return[];let i=new Set(e),r=[];for(let c of ot){if(!i.has(c))continue;let s=t.filter(l=>l.objectApiName===c).map(l=>l.fieldApiName),a=[];s.some(Re)||a.push("name"),s.some(l=>Q(l,"string")==="email")||a.push("email"),s.some(l=>Q(l,"string")==="phone")||a.push("phone"),a.length>0&&r.push({objectApiName:c,missing:a})}return r}function St(n){return n.fatalError!==void 0?"failure":n.totalFailure>0||n.failedObjects.length>0?n.totalSuccess+(n.totalLinked??0)>0?"partial":"failure":[...Object.values(n.lookups??{}),...Object.values(n.statuses??{})].some(t=>t.refusals.length>0)||n.stopped===!0?"partial":"success"}var nt=pe({name:Z().min(1),referenceTo:de(Z()).min(1),createable:ee().optional(),updateable:ee().optional()}).loose();function Dt(n){if(!Array.isArray(n))return[];let e=[];for(let t of n){let i=nt.safeParse(t);i.success&&e.push({name:i.data.name,referenceTo:i.data.referenceTo,createable:i.data.createable??!1,updateable:i.data.updateable??!1})}return e}var Mt={STORAGE_EXCEEDED:"AUTOPILOT_STORAGE_EXCEEDED",API_BUDGET_EXCEEDED:"API_BUDGET_EXCEEDED",WRITE_DECLINED:"AUTOPILOT_WRITE_DECLINED",CONFIRMATION_UNAVAILABLE:"AUTOPILOT_CONFIRMATION_UNAVAILABLE",CHECKPOINT_REFUSED:"CHECKPOINT_REFUSED",RUN_CANCELLED:"RUN_CANCELLED",EMAILS_NOT_ACCEPTED:Be},Bt={NO_PLAN:"AUTOPILOT_NO_PLAN",STORAGE_UNREAD:"AUTOPILOT_FIT_STORAGE_UNREAD",READ_REFUSED:"AUTOPILOT_FIT_READ_REFUSED",STALE:"AUTOPILOT_FIT_STALE"};function vt(n,e,t=new Map){return Se(n.waves.flatMap(i=>i.objects).map(i=>{let r=t.get(i);return{objectApiName:i,rows:[],counted:{rows:e.get(i)??0,...r!==void 0?{personAccounts:r}:{}}}}))}function Ut(n){return[...new Set(n.waves.flatMap(e=>e.objects.map(String)))]}async function Gt(n){return Fe(n)}function it(n){return n.filter(e=>e.verdict==="exceeds").map(Me)}function rt(n){return n.filter(e=>e.verdict==="unread").map(e=>({limit:e.limit,emails:e.emails,unread:e.unread??""}))}function qt(n){return n.objects.filter(({rows:e})=>e>0).length}async function at(n,e,t,i,r={}){let c="unread"in e?await t().catch(o=>({unread:o instanceof Error?o.message:String(o)})):e.dailyApiRequests,{readBack:s=0,deliverability:a=0,mute:l=0}=r;return ae({run:ke(n.objects.map(({rows:o})=>({rows:o}))),...Te(i),...l>0?{mute:l}:{},...s>0?{readBack:s}:{},...a>0?{deliverability:a}:{}},c)}function st(n){return n.objects.reduce((e,{rows:t})=>e+Math.ceil(Math.max(0,t)/$),0)}async function ct(n,e){let t=await e().catch(i=>({unread:i instanceof Error?i.message:String(i)}));return ae(st(n),t)}async function $t(n){let{plan:e}=n,t=Le(e,n.storage);if(e.totalRows===0)return{go:!0,check:t,asked:!1};let i=n.checkpointFirst?.estimate,r=je(i);if(r)return{go:!1,...r,check:t};let c=Ge(t,n.org);if(c)return{go:!1,code:"STORAGE_EXCEEDED",message:`${c} Nothing was written.`,check:t};let s=await at(e,n.storage,n.readApiBudget,i,{...n.readBack!==void 0?{readBack:n.readBack}:{},...n.mute!==void 0?{mute:n.mute}:{},...ve(n.runEmails?.ofRun)}),a=Ce(s,n.org,ye);if(a)return{go:!1,code:"API_BUDGET_EXCEEDED",message:a,check:t};if(n.source){let f=await ct(e,n.source.readApiBudget),S=xe(f,n.source.org);if(S!==void 0&&f.verdict==="exceeds")return{go:!1,code:"API_BUDGET_EXCEEDED",message:S,check:t,source:{estimate:f.estimate,remaining:f.remaining,max:f.max}}}let l=n.confirmAboveRecords,o=l>0&&e.totalRows>l?l:void 0,g=it(n.emails??[]),h=rt(n.emails??[]),m=n.emailsUncounted,N=n.runEmails?.gate,I=N?.verdict==="asks",R=async f=>{let S=re(N,f&&I),_=n.checkpointFirst;if(_===void 0)return{go:!0,check:t,asked:f,...S};let x=await _e(()=>_.take(_.estimate));return"stop"in x?{go:!1,...x.stop,check:t,...S}:{go:!0,check:t,asked:f,checkpoint:x.checkpoint,...S}};if(o===void 0&&t.verdict==="fits"&&g.length===0&&h.length===0&&m===void 0&&i===void 0&&!I)return R(!1);let P=Oe(n.orgTier),C=await n.confirm({stage:"write",module:"autopilot",org:n.org,orgTier:n.orgTier,objects:e.objects.map(({objectApiName:f,rows:S})=>({objectApiName:f,rows:S})),total:e.totalRows,...o!==void 0?{aboveRecords:o}:{},...P!==void 0&&e.totalRows>P?{largeVolume:P}:{},storage:Ue(t),counted:!0,...g.length>0?{emails:g}:{},...h.length>0?{emailsUnread:h}:{},...m!==void 0?{emailsUncounted:m}:{},...De(s),...i!==void 0?{checkpoint:i}:{},...N?.confirmation});if(C==="confirmed")return R(!0);let D=re(N,!1);return C==="declined"?{go:!1,code:"WRITE_DECLINED",message:"The Autopilot run was cancelled before it wrote anything. Nothing was written.",check:t,...D}:{go:!1,code:"CONFIRMATION_UNAVAILABLE",message:"The Autopilot run needed a confirmation before it wrote, and there was no one to ask. Nothing was written: run it again from the Autopilot page, where the question is asked.",check:t,...D}}export{He as a,Ke as b,$ as c,M as d,qe as e,$e as f,We as g,Ot as h,Pt as i,wt as j,St as k,Dt as l,Mt as m,Bt as n,vt as o,Ut as p,Gt as q,qt as r,at as s,ct as t,$t as u};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{g as m,h as S,i as E,j as x}from"./chunk-
|
|
7
|
+
import{g as m,h as S,i as E,j as x}from"./chunk-M6K34KGF.mjs";import{b as C}from"./chunk-CA5NAXSU.mjs";import{ye as T,z as R}from"./chunk-PMWAFDUB.mjs";import{statfs as q}from"node:fs/promises";var re=["reads","leasePlan","stillRunning","deliverabilityRead","question","checkpointTake","leaseAcquire","afterLeaseCheck","write","leaseRelease","recordTypeReadBack","result"];function ie(e){let t=[],n=s=>e.indexOf(s),r=s=>e.lastIndexOf(s),o=(s,c,d,p=r(s),l=n(c))=>{p>=0&&l>=0&&p>l&&t.push(d)};o("leasePlan","stillRunning","what still runs was computed before the lease was planned"),o("stillRunning","deliverabilityRead","the deliverability was read before what still runs was known"),o("deliverabilityRead","question","the deliverability was read after the question it belongs to",n("deliverabilityRead")),o("question","checkpointTake","the checkpoint was taken before the last question"),o("question","leaseAcquire","the lease was taken before the last question"),o("checkpointTake","leaseAcquire","the lease was taken before the checkpoint"),o("leaseAcquire","afterLeaseCheck","the lease was checked before it was taken"),o("checkpointTake","write","a record was written before the checkpoint was taken"),o("leaseAcquire","write","a record was written before the lease was taken"),o("afterLeaseCheck","write","a record was written before the lease was checked"),o("write","leaseRelease","the lease was given back before the last write"),o("write","recordTypeReadBack","the record types were read back before the last write"),o("leaseRelease","recordTypeReadBack","the record types were read back while the lease was held"),n("leaseAcquire")>=0&&n("leaseRelease")<0&&t.push("the lease was never given back");let i=n("result");return i>=0&&e.slice(i+1).some(s=>s!=="result")&&t.push("the run went on past its result"),t}var W={insert:"go in",update:"are updated",delete:"are deleted",undelete:"come back"},L={flow:"flow",process:"process",workflowRule:"workflow rule",trigger:"Apex trigger"},h=3,v=/__e$/i;function u(e){return e.toLowerCase()}function A(e){let t=new Set,n=[];for(let r of e)t.has(u(r))||(t.add(u(r)),n.push(r));return n}function F(e){let t=e.slice(0,h),n=e.length-t.length,r=`${t.join("; ")}${n>0?`; and ${n} more`:""}`;return`${r.charAt(0).toUpperCase()}${r.slice(1)}.`}function I(e){let t=A(e.written),n=new Set(t.map(u)),r=new Map;for(let i of e.running.firing)if(i.flow!==void 0)for(let s of i.flow.creates??[]){let c=u(s);if(n.has(c)||v.test(s))continue;let d=r.get(c);d===void 0&&(d={objectApiName:s,clauses:[],by:[]},r.set(c,d));let p=`the target's ${L[i.kind]} '${i.name}' creates ${s} records as ${i.objectApiName} records ${W[i.write]}`;d.clauses.includes(p)||(d.clauses.push(p),d.by.push({kind:i.kind,name:i.name,objectApiName:i.objectApiName,write:i.write}))}let o=[...r.values()].map(({objectApiName:i,clauses:s,by:c})=>({objectApiName:i,code:"createdByAutomation",reason:F(s),creators:c.slice(0,h),...c.length>h?{moreCreators:c.length-h}:{}}));return{written:t,added:o,excluded:A(e.request.excluded??[]),picked:[...t,...o.map(({objectApiName:i})=>i)]}}var M={[u(m)]:{code:"files",reason:"Files, which every checkpoint of picked objects holds: a rewind deletes the files added since to the records it holds."},[u(x)]:{code:"attachments",reason:"Attachments, which every checkpoint of picked objects holds: a rewind deletes the attachments added since."}},K="Held as every checkpoint of picked objects holds it.",U={[u("AccountContactRelation")]:"Account contact relations, which the platform writes with each contact: a rewind deletes those made since with their contacts, and keeps no contact for them."},J=new Set([E,S].map(u)),z="A rewind leaves its records as they are.",k="No record was read.";function w(e,t,n){let r=new Map(t.map(a=>[u(a),a])),o=r.has(u(m)),i=a=>r.has(u(a))||o&&J.has(u(a)),s=[],c=a=>{let f=r.get(u(a));f!==void 0&&!s.includes(f)&&s.push(f)};for(let a of e.written)c(a);for(let{objectApiName:a}of e.added)c(a);for(let a of t)c(a);let d=new Set(e.picked.map(u)),p=[...e.added.flatMap(a=>{let f=r.get(u(a.objectApiName));return f===void 0?[]:[{...a,objectApiName:f}]}),...t.filter(a=>!d.has(u(a))).map(a=>({objectApiName:a,...M[u(a)]??{code:"heldUnasked",reason:U[u(a)]??K}}))],l=n.filter(({objectApiName:a})=>!i(a)).map(({objectApiName:a,reason:f,code:b,detail:y,records:O,limit:B})=>({objectApiName:a,...b!==void 0?{code:b}:{},reason:`${f} ${z}`,...y!==void 0?{detail:y}:{},...O!==void 0?{records:O}:{},...B!==void 0?{limit:B}:{}})),H=new Map(n.map(({objectApiName:a,reason:f})=>[u(a),f]));return{objects:s,added:p,notHeld:l,holds:i,why:a=>H.get(u(a))}}function g(e,t,n){return e.written.some(o=>t.holds(o))?void 0:e.written.length===0?{code:"NOTHING_HELD",message:`The run names no object it writes: a checkpoint before it would hold nothing a rewind could take back. ${n}`}:{code:"NOTHING_HELD",message:`The checkpoint before the run would hold none of the objects the run writes, so a rewind to it could take nothing of the run back. ${e.written.map(o=>`${o}: ${t.why(o)??"The take did not hold it."}`).join(" ")} ${n}`}}function G(e,t,n){let r={state:"planned",estimate:t.estimate,keepDays:n};if(t.objects.length===0&&t.leftOut.length===0&&t.refusal!==void 0)return{...r,objects:[],added:[],notHeld:[],refusal:t.refusal};let o=w(e,t.objects.map(({objectApiName:s})=>s),t.leftOut),i=g(e,o,k)??t.refusal;return{...r,objects:o.objects,added:o.added,notHeld:o.notHeld,...i!==void 0?{refusal:i}:{}}}var V=1.1;function N(e){return`${(e/(1024*1024)).toFixed(1)} MB`}function P(e,t){if(!(t===void 0||t>=Math.ceil(e*V)))return{code:"DISK",message:`The checkpoint before the run takes about ${N(e)} on this machine, and its disk has ${N(t)} free, less than that and a tenth more: make room, or leave objects out of the checkpoint. ${k}`}}async function _(e){try{let t=await q(e);return Number(t.bavail)*Number(t.bsize)}catch{return}}var Y={forge:"Forge run",sync:"Sync run",seed:"Seed run",autopilot:"Autopilot run",frozen:"Frozen Dataset load",empty:"emptying",replay:"checkpoint replay"};function Q(e){return`Before ${Y[e]} ${T}`}function se(e,t){let{min:n,max:r}=R,o=i=>typeof i=="number"&&Number.isInteger(i)&&i>=n&&i<=r;if(e!==void 0){if(!o(e))throw new RangeError(`Not a number of days to keep a checkpoint, ${n} to ${r}: ${e}`);return e}return o(t)?t:R.default}function X(e,t){return{mode:"picked",objects:e.picked,...e.excluded.length>0?{excluded:e.excluded}:{},nameWithDate:Q(t.module),keepDays:t.keepDays,unprovenLeftOut:!0,beforeRun:{module:t.module,operationId:t.operationId,tool:t.tool}}}function j(e,t){let{checkpoint:n}=t,r=w(e,n.objects.map(({objectApiName:o})=>o),n.scope.leftOut);return{state:"taken",checkpointId:n.checkpointId,name:n.name,takenAt:n.takenAt,expiresAt:n.expiresAt,objects:r.objects,records:n.objects.reduce((o,i)=>o+i.records,0),bytes:n.bytes,requests:t.requests?.total??t.estimate.apiRequests,added:r.added,notHeld:r.notHeld}}function D(e){return`${e.operation==="take"?"a checkpoint is being taken":e.operation==="rewind"?"a rewind is writing":e.operation==="undo"?"an undo is writing":e.operation==="empty"?"an emptying of its objects is writing":"SandForge is deleting checkpoints"} (process ${e.pid} on ${e.host})`}async function Z(e,t,n){let r=w(t,n.checkpoint.objects.map(({objectApiName:c})=>c),n.checkpoint.scope.leftOut);if(g(t,r,"")===void 0)return{taken:!0,checkpoint:j(t,n)};let o=await e.delete(n.checkpoint.checkpointId),i=o.outcome==="busy"?`It is kept all the same, as ${D(o.holder)}: delete it from the Checkpoints page once that has ended. Nothing was written.`:"It was deleted again; nothing was written.",s=g(t,r,i);return s===void 0?{taken:!0,checkpoint:j(t,n)}:{taken:!1,refusal:s}}function $(e,t,n){return{...e,...X(t,n)}}async function ae(e,t,n){let{scopeCheckpoint:r}=await import("./chunk-BEA27DLS.mjs"),o=I(n),i=await r(e,$(t,o,n)),s=G(o,i,n.keepDays);if(s.refusal!==void 0)return s;let c=P(s.estimate.bytes,await(e.freeBytes??_)(e.store.root));return c===void 0?s:{...s,refusal:c}}async function ce(e,t,n,r){let o=await import("./chunk-BEA27DLS.mjs"),i=I(n);if(r!==void 0){let c=P(r.estimate.bytes,await(e.freeBytes??_)(e.store.root));if(c!==void 0)return{taken:!1,refusal:c}}let s;try{s=await o.takeCheckpoint(e,$(t,i,n))}catch(c){if(c instanceof o.CheckpointTakeStopped)return{taken:!1,stopped:!0};throw c}return s.taken?Z(e.store,i,s):{taken:!1,refusal:s.refusal}}async function ue(e,t,n){if(n)return{info:t};let r=await e.delete(t.checkpointId);return r.outcome==="busy"?{info:t,notDeleted:`The checkpoint '${t.name}' taken before the run is kept, though the run wrote nothing: ${D(r.holder)}. Delete it from the Checkpoints page once that has ended.`}:{info:{state:"deleted",deleted:"nothingWritten"}}}function de(e){return`The checkpoint before the run was refused: ${e.message.endsWith(k)?e.message.slice(0,-k.length).trimEnd():e.message} Nothing was written. Untick Checkpoint first to run without it, or fix what refuses it.`}function fe(e){return`The checkpoint before the run could not be taken: ${C(e).replace(/\.$/,"")}. Nothing was written.`}var pe="The checkpoint taken before the run was deleted: the run wrote nothing.";function le(e){return`Taking the checkpoint first (${Math.round(e)}%)`}export{re as a,ie as b,I as c,G as d,V as e,P as f,_ as g,Q as h,se as i,X as j,j as k,Z as l,ae as m,ce as n,ue as o,de as p,fe as q,pe as r,le as s};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{y as he}from"./chunk-326AJTIU.mjs";import{i as ce,j as x,k as de,l as pe}from"./chunk-LA4KIATH.mjs";import{l as le,n as z}from"./chunk-GMIGWR6U.mjs";import{e as F,i as ae,k as D,l as se}from"./chunk-IZGCEOYO.mjs";import{d as j,f as oe,yb as re,zb as ie}from"./chunk-PEDQPM2P.mjs";import{$a as J}from"./chunk-XGGOUNPP.mjs";import{c as ne}from"./chunk-QROPNEGY.mjs";import{L as te,e as X,k as Q,z as ee}from"./chunk-KGU4SVIT.mjs";import{a as v,c as A}from"./chunk-AL4C3GFT.mjs";import{wc as C}from"./chunk-KB4ZHM4Q.mjs";import{Ra as Z,cb as V}from"./chunk-PMWAFDUB.mjs";import{existsSync as $e,readFileSync as ve}from"node:fs";import{hostname as be}from"node:os";import{join as ge,resolve as T}from"node:path";var Ae=["--custom-settings","--mask","--keep-contact-points","--no-real-data"],Ee=["--objects","--exclude-object","--owners","--owner-map","--link","--replay-config"],Ie=["--again","--accept-emails","--max-records",...j.switches,...j.values],Oe=["--preview","--sweep","--sweep-list",...re,"--include-changed"],Ne=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,E=/^00D[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/,me=e=>Z.safeParse(e).success,Se={ownerMap:"--owner-map",objects:"--objects",excluded:"--exclude-object",link:"--link"};function Rt(e,t){let n=c=>e.includes(c),o=c=>{let p=[];for(let w=1;w<e.length;w++){if(e[w]!==c)continue;let $=e[w+1];if($===void 0||$.startsWith("--"))return t(`${c} wants a value.`);p.push($),w++}return p},r=c=>{let p=o(c);return p.length>1&&t(`${c} is given ${p.length} times: give it once.`),p[0]},s=c=>{let p=r(c);if(p!==void 0)return/^\d{1,15}$/.test(p)||t(`${c} takes a whole number, not "${p}".`),Number(p)},d=["--dry-run","--verify","--remove"].filter(n);d.length>1&&t(`Give one of --dry-run, --verify and --remove, not ${d.join(" and ")}. Nothing was run.`);let i=n("--dry-run")?"dryRun":n("--verify")?"verify":n("--remove")?"remove":"replay",a=c=>c.filter(n);if(i==="verify"||i==="remove"){let c=a([...Ae,...Ee]);c.length>0&&t(`${c.join(", ")} ${c.length===1?"is a choice":"are choices"} of a replay and its dry run: --verify reads the choices its last replay was made with, and --remove takes back what it wrote. Nothing was run.`);let p=a(Ie);p.length>0&&t(`${p.join(", ")} goes with a replay or its dry run, not with --${i}. Nothing was run.`)}if(i!=="remove"){let c=a(Oe);c.length>0&&t(`${c.join(", ")} goes with --remove. Nothing was run.`)}n("--sweep")&&n("--sweep-list")&&t("--sweep deletes and --sweep-list only lists: give one of them. Nothing was run."),n("--preview")&&n("--sweep-list")&&t("--preview deletes nothing, and --sweep-list lists what a sweep would take: give --preview without it, or with --sweep. Nothing was run.");let u=ie(e);if("refusal"in u&&t(`${u.refusal} Nothing was run.`),i==="verify"){let c=a(["--mute-automation","--accept-automation"]);c.length>0&&t(`${c.join(", ")} goes with a replay or its removal: a verification only reads. Nothing was run.`)}let m=r("--checkpoint"),f=r("--file");if(m===void 0&&f===void 0)return t("replay needs --checkpoint <id|name> (list names them) or --file <.sfcheckpoint>. Run with --help.");m!==void 0&&f!==void 0&&t("Give --checkpoint or --file, not both. Nothing was run.");let h=r("--from");if(h!==void 0&&m===void 0&&t("--from goes with --checkpoint <name>: it names the org the checkpoint was taken of."),m!==void 0&&!me(m)&&h===void 0&&t(`--checkpoint '${m}' is not a checkpoint's id: a name names one of an org's checkpoints, so give --from <alias|username|00D\u2026>, the org it was taken of, or its id ("${v("checkpoint")} list" names them). Nothing was run.`),f===void 0){let c=a(["--key-env","--keep-days"]);c.length>0&&t(`${c.join(" and ")} goes with --file. Nothing was run.`)}let k=r("--target")??t("replay needs --target <alias>, the org the checkpoint's records go into. Run with --help."),R=o("--objects").flatMap(c=>c.split(",").map(p=>p.trim()).filter(p=>p!=="")),g=o("--exclude-object");for(let[c,p]of[["--objects",R],["--exclude-object",g]]){let w=p.find($=>!Ne.test($));w!==void 0&&t(`${c} takes objects' API names, not "${w}".`)}let I=c=>c.filter((p,w)=>c.findIndex($=>$.toLowerCase()===p.toLowerCase())===w),O=r("--owners")??"same";O!=="same"&&O!=="me"&&t(`--owners takes same or me, not "${O}".`);let we=o("--link").map(c=>{let p=/^([A-Za-z][A-Za-z0-9_]*)=([A-Za-z0-9_,]+)$/.exec(c);return p?{objectApiName:p[1],fields:p[2].split(",").filter(w=>w!=="")}:t(`--link takes Object=Field or Object=Field,Field \u2014 the fields a record of the other org is found by \u2014, not "${c}".`)}),N=r("--owner-map"),Y=N!==void 0?ye("--owner-map",N,t):void 0,Re={owners:O,...Y!==void 0?{ownerMap:Y}:{},customSettings:n("--custom-settings"),mask:n("--mask"),contactPoints:n("--keep-contact-points")?"kept":"neutralized",objects:I(R),excluded:I(g),link:we,...n("--no-real-data")?{noRealData:!0}:{}},_=V.safeParse(Re);if(!_.success){let c=_.error.issues[0],p=String(c?.path[0]??"");return t(`${Se[p]??p}: ${c?.message??"not read"}. Nothing was run.`)}let K=_.data,S=r("--replay-config"),H=S!==void 0?Ce(S,K,t):void 0,P=s("--max-records");P===0&&t('--max-records takes a whole number of 1 or more, not "0". Nothing was run.');let G=Fe(r("--key-env"),t),q=oe(e);return{action:i,...m!==void 0?{checkpoint:m}:{},...h!==void 0?{from:h}:{},...f!==void 0?{file:T(f)}:{},...G!==void 0?{keyEnv:G}:{},keepDays:s("--keep-days")??X,target:k,choices:K,...N!==void 0?{ownerMapFile:T(N)}:{},...H!==void 0?{config:H}:{},...S!==void 0?{configFile:T(S)}:{},again:n("--again"),muteAutomation:n("--mute-automation"),acceptAutomation:n("--accept-automation"),acceptEmails:n("--accept-emails"),...q!==void 0?{checkpointFirst:q}:{},...P!==void 0?{maxRecords:P}:{},preview:n("--preview"),sweep:n("--sweep"),sweepList:n("--sweep-list"),...u,includeChanged:n("--include-changed"),yes:n("--yes")}}function $t(e,t){let n=e.flatMap((r,s)=>r==="--target"?[e[s+1]]:[]);n.length>1&&t(`--target is given ${n.length} times: give it once.`);let o=n[0];return o!==void 0?{target:o}:{}}function ye(e,t,n){try{return JSON.parse(ve(t,"utf8"))}catch(o){return n(`${e}: ${t} does not read as JSON (${o instanceof Error?o.message:String(o)}). Nothing was run.`)}}function Ce(e,t,n){let o=ye("--replay-config",e,n),r=J.safeParse({targetOrgId:"command-line",replay:{organizationId:"00D000000000000AAA",checkpointId:"ck-20000101-000000-0000",choices:t,config:o}});if(!r.success){let s=r.error.issues[0],d=(s?.path??[]).slice(2).join(".");return n(`--replay-config: ${d!==""?`${d}: `:""}${s?.message??"not read"}. It takes the load\u2019s part of a Frozen project\u2019s configuration: requiredFieldDefaults, requiredLookupPlaceholders, picklistRules, defaultPicklistRule, identityKeys, undeletableObjects, duplicateErrorPatterns, mockDetection, protectedOrgIds. Nothing was run.`)}return o}function Fe(e,t){if(e!==void 0)return!/^[A-Za-z_][A-Za-z0-9_]{0,127}$/.test(e)||F(e)!==void 0?t("--key-env takes the name of an environment variable that holds the key, never the key: a key on the command line stays in the shell\u2019s history and the list of processes. Nothing was run."):e}var ze="cli-store.json";function W(e,t){return t?ge(e,".replays"):ce()}var y=class extends Error{constructor(n,o=1){super(n.message);this.refusal=n;this.code=o;this.name="ReplayStop"}refusal;code};function ke(e){try{return new x({root:e})}catch(t){throw new y({code:"STORE_REFUSED",message:`The replays cannot be kept in ${e}: ${t instanceof Error?t.message:String(t)} Name a store outside any repository with --store <folder>. Nothing was read or written.`})}}function B(e,t){let n=D(e);if(!$e(n))return;let o=te({root:n,...t!==void 0?{locksDir:t}:{}});return"store"in o?o.store:void 0}function vt(e,t){return`${v("checkpoint")} replay --file ${A(e)} --target ${t}`}function L(e,t,n){return`${v("checkpoint")} replay --checkpoint ${e} --target ${t}`+(n!==void 0?` --store ${A(n)}`:"")}var l=e=>e.toLocaleString("en-US");function b(e){let t=new Date(Date.parse(e)).toISOString();return`${t.slice(0,10)} ${t.slice(11,16)} UTC`}function M(e,t=8){return e.length<=t?e.join(", "):`${e.slice(0,t).join(", ")} and ${l(e.length-t)} more`}function Le(e){return{run:"replay",done:"replayed",source:e,recordedIn:"for this checkpoint on this machine",remove:"--remove",module:"replay",again:"again",againSubject:{purge:"replayAgain",sweep:"replayAgainSweep"},maybeMasks:"the checkpoint does not say whether its take read them unmasked, so they may hold the masks a user without View Encrypted Data reads, such as ****1234"}}var _e={fileContentNotKept:()=>"a checkpoint keeps no file's content",notInTarget:(e,t)=>`${t} has no such object: deploy it there, or leave it out (--exclude-object ${e})`,notCreateable:(e,t)=>`${t} lets no one create its records`,excluded:()=>"left out as asked"},Pe={objectNotReplayed:e=>`the checkpoint holds the records it names and does not replay them: add ${e.split(".")[0]}'s target with --objects`,objectNotHeld:(e,t)=>`the checkpoint does not hold what it names, and ${t} has no record of that Id`,userNotInTarget:(e,t)=>`${t} has no active standard user for it`},fe={requiredLookupMissing:"a required lookup names a record neither replayed nor in the other org",parentRefused:"a parent of theirs is refused, and no orphan is written",personAccountsUnsupported:"the other org has not turned person accounts on",inactiveCurrency:"their currency is not active in the other org",recordTypeUnavailable:"their record type is one the user who replays may not create"};function je(e){return`${Object.hasOwn(fe,e.reason)?fe[e.reason]:e.reason}${e.path?`: ${e.path}`:""}`}var De={byName:"found by its name",byId:"found by its Id",default:"the other org's default for the user who replays"};function xe(e){let{summary:t}=e,n=e.target.name,o=[],{records:r}=t;r.linkedById>0&&o.push(`${l(r.linkedById)} record(s) ${n} holds under the same Id \u2014 a sandbox copied from the same production \u2014: linked, not changed`),r.linkedByKey>0&&o.push(`${l(r.linkedByKey)} record(s) found in ${n} by the fields --link names: linked, not created`);let s=t.owners,d=[s.reasons.notInTarget>0?`their user is not in ${n}: ${l(s.reasons.notInTarget)}`:"",s.reasons.inactive>0?`their user is inactive in ${n}: ${l(s.reasons.inactive)}`:"",s.reasons.queueMissing>0?`their queue is not in ${n}: ${l(s.reasons.queueMissing)}`:""].filter(Boolean);o.push(`owners: ${l(s.kept)} kept, ${l(s.toRunningUser)} to the user who replays`+(d.length>0?` \u2014 ${d.join("; ")}`:""));for(let i of t.recordTypes)o.push(`record type ${i.object}.${i.recordType}: ${De[i.outcome]} \u2014 ${l(i.records)} record(s)`);for(let i of t.refused)o.push(`refused before anything is written: ${i.object} ${l(i.records)} \u2014 `+je(i));for(let i of t.notReplayed)o.push(`not replayed: ${i.object} ${l(i.records)} \u2014 `+_e[i.reason](i.object,n));e.filesLeft.length>0&&o.push(`${l(e.filesLeft.length)} file(s) left where they were, a checkpoint keeping no file's content:`,...e.filesLeft.map(i=>` ${i.objectApiName}${i.name!==void 0?` '${i.name}'`:""}`));for(let i of t.lookupsEmptied)o.push(`${i.field}: emptied on ${l(i.records)} record(s) \u2014 `+Pe[i.reason](i.field,n));for(let i of t.fieldsNotInTarget)o.push(`${i.object}: ${M(i.fields)} left out \u2014 ${n} does not have them`);t.customSettings&&o.push(`custom settings: ${l(t.customSettings.inserted)} row(s) set up, ${l(t.customSettings.alreadyThere)} already in ${n}, kept as they are`);for(let i of t.currencies.refused)o.push(`${i.code}: ${l(i.records)} record(s) refused \u2014 the currency is not active in ${n}: activate it there, or leave those records out`);if(t.currencies.singleCurrencyTarget&&o.push(`${n} has one currency: amounts are kept as they are, in its currency`),t.standardPricebook==="deduced"?o.push("standard price book: told from the price book entries, the checkpoint naming none"):t.standardPricebook==="ambiguous"&&o.push("standard price book: the price book entries do not tell which it was, and those that need it are refused"),t.masked.fields.length>0&&o.push(`masked: ${M(t.masked.fields)}`),(t.masked.unmaskedFreeText??[]).length>0&&o.push(`not masked, free text the masking does not read: ${M(t.masked.unmaskedFreeText??[])}`),o.push(t.contactPoints==="neutralized"?"emails and phone numbers made unreachable (.invalid, numbers that ring nobody); --keep-contact-points keeps them":"emails and phone numbers kept as they are: they reach the people they name"),(t.archivedActivities??0)>0&&o.push(`${l(t.archivedActivities??0)} archived task(s) and event(s) replayed, which ${n} holds live`),t.degraded.length>0&&o.push((e.checkpoint.annex?`its take could not read ${t.degraded.join(", ")}`:"taken before SandForge 1.81, it keeps no record types, users, queues nor standard price book")+`: the records they name get what ${n} gives them, each said above`),o.push("created and modified dates and users are the replay's own: the platform sets them"),e.storage){let{storage:i}=e;o.push(`data storage: about ${C(i.estimateMB)} MB of the ${C(i.remainingMB)} MB ${n} has left of ${C(i.maxMB)} MB`)}return o}var Te=new Set(["REPLAY_SAME_ORG","REPLAY_REAL_DATA","REPLAY_COPY_UNKNOWN","REPLAY_TOO_MANY","REPLAY_NOTHING","REPLAY_CHECKPOINT_UNUSABLE","REPLAY_NO_PILOT","CHECKPOINT_NOT_FOUND","OWNER_MAP_INACTIVE","OWNER_MAP_UNKNOWN","GUARD_REFUSED","NO_LOAD","TARGET_REFRESHED","LOAD_REMOVED","LOAD_STOPPED"]);function Me(e){let t=String(e.type??""),n=e.payload?.code;if(!(!t.endsWith(":error")||typeof n!="string")&&Te.has(n))return{code:n,message:String(e.payload?.message??"")}}function Ue(e,t,n,o={}){switch(e){case"TARGET_REFRESHED":if(/dataset/i.test(t))return`${n} was refreshed after the last replay: the records it created went with the refresh. Replay the checkpoint again, then verify.`;break;case"LOAD_REMOVED":{let r=/removal of (\S+) took part/.exec(t);if(r)return`The removal of ${r[1]} took part of the records the last replay created and left ${l(Number(o.left??0))} in ${n}: a verification would read the ones it took as missing. Remove what is left (--remove), or replay again (--again), which purges or finds it again; then verify.`;let s=/removed on (\S+?)\.(?:\s|$)/.exec(t);return`The records the last replay created were removed${s?` on ${s[1]}`:""}. Replay the checkpoint again, then verify.`}case"LOAD_STOPPED":return"The last replay stopped part way \u2014 it was cancelled, or failed once it had written \u2014 and wrote no counting contract: a verification would judge it by the one before. Replay it again (--again), which purges or finds again what the stopped replay wrote, or take it back (--remove); then verify.";case"NO_LOAD":if(/dataset|\bsas\b/i.test(t))return`No replay of this checkpoint into ${n} is recorded on this machine: nothing names the records to verify. Replay it there, then verify.`;break;case"MAX_RECORDS":{let r=/insert (\d+) record\(s\), more than the (\d+)/.exec(t);if(r)return`This replay would create ${l(Number(r[1]))} record(s), more than the ${l(Number(r[2]))} it may: nothing was written. The checkpoint's records or ${n} changed since that count was taken: run its dry run again, and replay with the count it gives (--max-records).`;break}case"REPLACE_LEAVES_RECORDS":{let r=/would leave (\d+) of their records in the org — (.*?): loaded again/.exec(t);if(r)return`Taking back what the replays before created in ${n} would leave ${r[1]} of their records there \u2014 ${r[2]}: replayed again, the checkpoint's records would stand beside them. Nothing was written. Take the replay back first (--remove; --include-changed takes too what was changed since, and what was added under it since), then replay it again.`;break}case"GUARD_REFUSED":if(o.guard==="non-sandbox")return`A replay goes into a sandbox, a scratch org or a Developer Edition org, never into a production org nor a sandbox marked Staging, which hold real data: ${n} is ${o.tier==="staging"?"a sandbox marked Staging":"a production org"}. Nothing was read or written.`;break}return/dataset/i.test(t)?t.replace(/frozen-dataset load/gi,"replay").replace(/the frozen dataset/gi,"the checkpoint").replace(/the dataset/gi,"the checkpoint").replace(/datasets?/gi,"checkpoint"):t}async function bt(e,t){let n=ke(W(t.storeRoot,t.storeNamed)),o=B(t.storeRoot,t.locksDir);o!==void 0&&await Ye(o,t.say);let r=e.file!==void 0?await qe(e,t):await Ke(e,t,n),s=n.folderOf(r.organizationId,r.checkpointId);await ee(n.root);let d={checkpoints:()=>[t.store,...[B(t.storeRoot,t.locksDir)].filter(f=>f!==void 0)],replays:n},i=t.storeNamed?t.storeRoot:void 0,a=L(r.checkpointId,e.target,i),u=r.name!==void 0?`checkpoint '${r.name}'`:`checkpoint ${r.checkpointId}`,m={request:{organizationId:r.organizationId,checkpointId:r.checkpointId,choices:e.choices,...e.config!==void 0?{config:e.config}:{}},stores:d,folder:s,auditStore:ge(n.root,ze),words:Le(u),refusalOf:Me,reword:(f,h,k)=>Ue(f,h,e.target,k),lines:(f,h)=>Qe(f,h,{asked:e,chosen:r,again:a}),question:f=>`Replay ${u} into ${e.target}, creating ${l(Be(f))} record(s) there${e.again?" once what its replays before created there is purged":""}?`,dryRunEnd:f=>f.length>0?[]:[`To replay it: ${a}${et(e)}`],answer:(f,h)=>nt(f,h,{asked:e,chosen:r,again:a})};await he(We(e,t.json),m)}function Be(e){return e.perObject.reduce((t,n)=>t+n.toInsert,0)}function We(e,t){return{step:e.action==="verify"?"verify":e.action==="remove"?"remove":"load",target:e.target,pilot:!1,reload:e.again,dryRun:e.action==="dryRun",writeEncrypted:!1,muteAutomation:e.muteAutomation,acceptAutomation:e.acceptAutomation,...e.checkpointFirst!==void 0?{checkpointFirst:e.checkpointFirst}:{},includeChanged:e.includeChanged,acceptEmails:e.acceptEmails,sweep:e.sweep,sweepList:e.sweepList,...e.sweepLate?{sweepLate:!0}:{},...e.sweepUntied?{sweepUntied:!0}:{},preview:e.preview,...e.maxRecords!==void 0?{maxTotal:e.maxRecords}:{},yes:e.yes,json:t}}async function Ye(e,t){let n=await e.sweep().catch(()=>{});for(let o of n?.checkpoints??[])t(`deleted the checkpoint '${o.name}' (${o.checkpointId}) of a file received, kept until ${b(o.expiresAt)}: its replays stay, and still take back with --remove`)}async function Ke(e,t,n){let o=e.checkpoint??"",r=B(t.storeRoot,t.locksDir),s=new Set,d=[...await t.listAll(),...await r?.list()??[]].filter(h=>{let k=`${h.organizationId.slice(0,15)}/${h.checkpointId}`;return s.has(k)?!1:(s.add(k),!0)}),i=h=>({organizationId:h.organizationId,checkpointId:h.checkpointId,...h.checkpoint?{name:h.checkpoint.name}:{},of:Ge(h)}),a=e.from;if(me(o)){let h=d.filter(g=>g.checkpointId===o&&(a===void 0||!E.test(a)||ue(g.organizationId,a)));if(h.length===1)return i(h[0]);let k=(await n.list({checkpointId:o})).filter(g=>a===void 0||!E.test(a)||ue(g.sourceOrganizationId,a)),R=[...new Set(k.map(g=>g.sourceOrganizationId))];if(h.length===0&&R.length===1){let g=k[0];return{organizationId:g.sourceOrganizationId,checkpointId:o,...g.checkpointName!==void 0?{name:g.checkpointName}:{}}}if(h.length+R.length>1){let g=[...new Set([...h.map(I=>I.organizationId),...R])];throw new y({code:"AMBIGUOUS",message:`Checkpoints of ${g.length} orgs have the id ${o}: name the org it was taken of with --from (${g.join(", ")}). Nothing was run.`},2)}throw new y({code:"NOT_FOUND",message:`No checkpoint ${o} is kept on this machine, nor a replay of it. `+He(t.storeNamed)})}let u=a??"",m=t.checkpointsOf(d,u,E.test(u)?u:void 0),f=t.resolve(d,m,o,u);if("entry"in f)return i(f.entry);throw"ambiguous"in f?new y({code:"AMBIGUOUS",message:f.ambiguous},2):new y({code:"NOT_FOUND",message:f.none})}function ue(e,t){return e.slice(0,15)===t.slice(0,15)}function He(e){return`"${v("checkpoint")} list" names the checkpoints kept, and "${v("checkpoint")} replays" the replays.${e?"":" One kept in another folder is read with --store <folder>."} A file a teammate sent replays with --file <.sfcheckpoint>.`}function Ge(e){let t=e.checkpoint?.org;if(t===void 0)return;let n=t.alias??t.username;return e.why==="refreshed"?`${n} before its refresh${e.refreshedAt?` on ${e.refreshedAt.slice(0,10)}`:""}`:e.why==="scratchExpired"?`${n}, a scratch org expired since`:n}async function qe(e,t){let n=e.file??"",o=await ae(n);if("refusal"in o)throw new y(o.refusal);let{header:r}=o.read;t.say(`the file holds checkpoint ${r.checkpointId} of org ${r.organizationId}, taken ${b(r.takenAt)}: ${l(r.records)} record(s) of ${l(r.objects)} object(s), exported by SandForge ${r.sandforgeVersion}`);let s={organizationId:r.organizationId,checkpointId:r.checkpointId,file:{path:n,header:r}};if(e.action==="remove")return s;if(e.action!=="verify"){let u=Ze(r,e);if(u!==void 0)throw new y(u)}let d=e.keyEnv!==void 0?Ve(e.keyEnv):await Je(),i=await se({storeRoot:t.storeRoot,...t.locksDir!==void 0?{locksDir:t.locksDir}:{},file:n,key:d,keepDays:e.keepDays,takenOn:{host:be(),pid:process.pid}});if(!i.imported)throw new y(i.refusal);let{checkpoint:a}=i;return t.say(i.outcome==="imported"?`kept checkpoint '${a.name}' of the file on this machine, apart from those it rewinds, to replay it: ${D(t.storeRoot)}, `+(a.expiresAt===null?"until it is deleted":`until ${b(a.expiresAt)} (--keep-days)`):`checkpoint '${a.name}' of the file is kept on this machine already, the same`),{...s,name:a.name,of:a.org.alias??a.org.username}}function Ze(e,t){if(t.choices.mask)return;let n=le({tier:e.orgTier,...e.dataStorageMaxMB!==void 0?{dataStorageMaxMB:e.dataStorageMaxMB}:{},...e.staging?{staging:!0}:{}}),o=`The file holds checkpoint ${e.checkpointId}`;if(n.kind==="real")return{code:"REPLAY_REAL_DATA",message:`${o} of ${n.why==="staging"?"a sandbox marked Staging":`a Partial Copy or Full sandbox, by its data storage (${l(n.dataStorageMaxMB??0)} MB)`}, which may hold real data: it goes into another org masked only. To replay it into ${t.target}, ${z.mask}. Its key was not read, and nothing was kept, read or written.`};if(n.kind==="unknown"&&t.choices.noRealData!==!0)return{code:"REPLAY_COPY_UNKNOWN",message:`${o} of a sandbox, and does not say which: made before SandForge 1.81, it keeps no data storage, and a Partial Copy or a Full sandbox holds production\u2019s records. To replay it into ${t.target}, ${z.mask}, or ${z.noRealData}. Its key was not read, and nothing was kept, read or written.`}}function Ve(e){let t=process.env[e];if(t===void 0||t.trim()==="")throw new y({code:"NO_KEY",message:`${e} is not set: it holds no key. Nothing was run.`},2);let n=F(t);if(n===void 0)throw new y({code:"NO_KEY",message:`${e} holds no key SandForge reads: 52 letters and digits, in groups of four as an export shows one. Nothing was run.`},2);return n}async function Je(){let e=await ne("Key of the file (not shown as you type it):","give --key-env VAR, the name of an environment variable that holds the key");if(e===void 0||e.trim()==="")throw new y({code:"DECLINED",message:"No key was typed. Nothing was run."});let t=F(e);if(t===void 0)throw new y({code:"IMPORT_KEY",message:"That is not a key SandForge draws: 52 letters and digits, in groups of four as the export showed it. Nothing was run."});return t}function Xe(e){let t=e.payload?.replay;return typeof t=="object"&&t!==null?t:void 0}function Qe(e,t,n){let o=Xe(e);if(o===void 0)return t;let{again:r}=n,s=o.target.name,d=o.filesLeft.length>0?` ${l(o.filesLeft.length)} file(s) are not replayed: a checkpoint keeps no file's content.`:"";if(e.type==="frozen:load:preview:response"){let i=n.chosen.of??o.checkpoint.alias??o.checkpoint.organizationId;return[`A replay of checkpoint '${o.checkpoint.name}' (of ${i}, taken ${b(o.checkpoint.takenAt)}) into ${s} would create copies of ${l(o.summary.records.toCreate)} of its records there, parents first, with new Ids; nothing ${s} holds is changed or deleted.${d}`,...t,...xe(o)]}return e.type==="frozen:load:response"?[...t,`To take it back: ${r} --remove`]:t}function et(e){let{choices:t}=e,n=e.checkpointFirst;return[t.objects.length>0?` --objects ${t.objects.join(",")}`:"",...t.excluded.map(o=>` --exclude-object ${o}`),t.owners!=="same"?` --owners ${t.owners}`:"",e.ownerMapFile!==void 0?` --owner-map ${A(e.ownerMapFile)}`:"",...t.link.map(o=>` --link ${o.objectApiName}=${o.fields.join(",")}`),t.customSettings?" --custom-settings":"",t.mask?" --mask":"",t.contactPoints==="kept"?" --keep-contact-points":"",t.noRealData?" --no-real-data":"",e.configFile!==void 0?` --replay-config ${A(e.configFile)}`:"",e.again?" --again":"",e.muteAutomation?" --mute-automation":"",e.acceptAutomation?" --accept-automation":"",e.acceptEmails?" --accept-emails":"",n!==void 0?" --checkpoint-first":"",n?.keepDays!==void 0?` --checkpoint-keep-days ${n.keepDays}`:"",...(n?.excluded??[]).map(o=>` --checkpoint-exclude-object ${o}`),e.maxRecords!==void 0?` --max-records ${e.maxRecords}`:""].join("")}function U(e,t){return e.filter(n=>n.type===t).at(-1)?.payload}var tt=new Set(["tool","step","posted","dataset","checkpoint"]);function nt(e,t,n){let{asked:o,chosen:r,again:s}=n,d=U(e.posted,"frozen:load:preview:response"),i=U(e.posted,"frozen:load:response"),a=i?.replay??d?.replay,u=d?.plan,m=i?.report,f=U(e.posted,"frozen:remove:response")?.result,h=Object.fromEntries(Object.entries(e).filter(([g])=>!tt.has(g))),k=e.checkpoint,R=a?.target.organizationId??t.targetOrgId;return{command:"replay",action:o.action,dryRun:o.action==="dryRun",checkpoint:a?{id:a.checkpoint.checkpointId,name:a.checkpoint.name,organizationId:a.checkpoint.organizationId,takenAt:a.checkpoint.takenAt,tier:a.checkpoint.tier,annex:a.checkpoint.annex}:{id:r.checkpointId,...r.name!==void 0?{name:r.name}:{},organizationId:r.organizationId},target:{alias:o.target,...R!==void 0?{organizationId:Q(R)}:{}},...o.action==="replay"||o.action==="dryRun"?{choices:a?.choices??o.choices}:{},...r.file?{file:r.file.path}:{},...u?{plan:u}:{},...a?{replay:{...a.summary,filesLeft:a.filesLeft,...a.storage?{storage:a.storage}:{},requests:a.requests}}:{},...m?{result:m}:{},...f!==void 0?{removal:f}:{},...h,...k?{checkpointFirst:k}:{},removeWith:`${s} --remove`,...t.refused?{refused:t.refused}:{},...t.ended?{ended:t.ended}:{},exit:t.exit}}function ot(e,t){return{checkpointId:e.checkpointId,...e.checkpointName!==void 0?{checkpointName:e.checkpointName}:{},sourceOrganizationId:e.sourceOrganizationId,...e.takenAt!==void 0?{takenAt:e.takenAt}:{},target:e.target,...e.choices!==void 0?{choices:e.choices}:{},...e.replayedAt!==void 0?{replayedAt:e.replayedAt}:{},inPlace:e.inPlace,inPlaceByObject:e.inPlaceByObject,...e.removed?{removed:!0}:{},removeWith:`${L(e.checkpointId,e.target.name??"<alias>",t)} --remove`}}function rt(e,t,n,o){return e.length===0?[`No replay${n!==void 0?` into ${n}`:""} is kept in ${t}.`]:e.flatMap(r=>{let s=r.target.name??r.target.organizationId,d=r.inPlaceByObject.map(i=>`${i.objectApiName} ${l(i.records)}`).join(", ");return[`${r.checkpointId} ${r.checkpointName!==void 0?`'${r.checkpointName}' `:""}of ${r.sourceOrganizationId}${r.takenAt!==void 0?`, taken ${b(r.takenAt)}`:""} into ${s} (${r.target.organizationId})`+(r.replayedAt!==void 0?` replayed ${b(r.replayedAt)}`:""),r.inPlace>0?` ${l(r.inPlace)} record(s) in place: ${d}`:r.removed?" removed: none of its records is left there":" none of its records is left there",...r.inPlace>0?[` to take it back: ${L(r.checkpointId,r.target.name??"<alias>",o)} --remove`]:[]]})}async function At(e,t){let n=ke(W(t.storeRoot,t.storeNamed)),o=await n.list(e!==void 0&&E.test(e)?{targetOrganizationId:e}:{}),r=e!==void 0&&!E.test(e)?o.filter(d=>d.target.name===e):o,s=t.storeNamed?t.storeRoot:void 0;for(let d of rt(r,n.root,e,s))t.say(d);t.answerJson(r.map(d=>ot(d,s)))}async function Et(e,t){let n;try{n=new x({root:W(t.storeRoot,t.storeNamed)})}catch{return{lines:[],entries:[]}}let o=t.storeNamed?t.storeRoot:void 0,r=[],s=[];for(let d of e){let i=await n.replaysOf(d.organizationId,d.checkpointId).catch(()=>[]),a=pe(i);if(a!==void 0){r.push(` ${a}`);for(let u of de(i))r.push(` to take it back: ${L(u.checkpointId,u.target.name??"<alias>",o)} --remove`),s.push(u)}}return{lines:r,entries:s}}export{Rt as a,$t as b,W as c,y as d,vt as e,L as f,je as g,bt as h,ot as i,At as j,Et as k};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a}from"./chunk-
|
|
7
|
+
import{a}from"./chunk-7UVKIWKV.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as ReferenceLinker};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{A as y,B as z,C as A,D as B,E as C,F as D,G as E,H as F,I as G,J as H,K as I,L as J,M as K,N as L,O as M,P as N,Q as O,c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i,l as j,m as k,n as l,o as m,p as n,q as o,r as p,s as q,t as r,u as s,v as t,w as u,x as v,y as w,z as x}from"./chunk-
|
|
7
|
+
import{A as y,B as z,C as A,D as B,E as C,F as D,G as E,H as F,I as G,J as H,K as I,L as J,M as K,N as L,O as M,P as N,Q as O,c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i,l as j,m as k,n as l,o as m,p as n,q as o,r as p,s as q,t as r,u as s,v as t,w as u,x as v,y as w,z as x}from"./chunk-KGU4SVIT.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-S42RBRH2.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as CHECKPOINT_DIR_MODE,b as CHECKPOINT_FILE_MODE,r as CHECKPOINT_FILE_PATH,F as CheckpointStoreError,c as DEFAULT_KEEP_DAYS,d as EXPIRY_WARNING_DAYS,K as OrgCheckpointStore,f as PREVIEW_KEEP_MS,e as RECYCLE_BIN_DAYS,q as REPLAY_ANNEX_PATH,N as acquireOrgLock,m as binFileOf,C as binReachSince,I as compressedFieldPrints,h as defaultCheckpointLocksDir,g as defaultCheckpointStoreRoot,z as expiresAtFor,B as expiresSoon,u as exportedFileIn,t as exportedFilesOf,n as filesDocumentsFileOf,o as filesLinksFileOf,j as indexFileOf,A as isExpired,s as isExportedPath,L as latestRewindOf,x as makePrivateDir,y as newFolderId,l as notInBinFileOf,J as openCheckpointStore,M as orgLockFileOf,O as orgLockHolder,i as organizationKey,v as previewDirOf,H as readFieldPrints,k as recreatedFileOf,p as replayAnnexFileOf,w as rewindDirOf,D as scratchOrgExpired,E as scratchOrgExpiresSoon,G as storeRefusalWords};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{h as M,i as T}from"./chunk-
|
|
7
|
+
import{h as M,i as T}from"./chunk-6JWWSDM6.mjs";import{p as b}from"./chunk-ICIYL45C.mjs";import{Ec as _,Fc as h,Gc as p,Hc as R,Lc as C,Mc as S,Pc as k}from"./chunk-PMWAFDUB.mjs";async function Y(r,e){try{let[c,i]=await Promise.all([r(R),e(R)]),d=c[0]?.Id,a=i[0]?.Id;return typeof d=="string"&&typeof a=="string"?{source:d,target:a}:void 0}catch{return}}function v(r,e){return r===h||e.some(c=>typeof c[p]=="string")}var K=[p,C,S];function A(r,e,c,i,d=()=>!1){let a={...e,standsFor:new Map,standardFirst:0,standardMatched:!1,prices:[],leftIn:new Map};if(!c)return a;let o=e.records.map((t,s)=>s),m=t=>({records:t.map(s=>e.records[s]),sources:t.map(s=>e.sources[s]),sourceIds:t.map(s=>e.sourceIds[s])});if(r===h){let t=o.filter(s=>e.sourceIds[s]!==c.source);return t.length===o.length?a:{...m(t),standsFor:new Map,standardFirst:0,standardMatched:!0,prices:[],leftIn:new Map}}if(r!==_)return a;let l=o,I=new Map,P=new Map,O=[];if(i){let{target:t}=i,s=e.sources.filter(n=>!K.some(f=>{let u=n[f];return typeof u=="string"&&u!==""&&d(u)})),E=n=>t.active.has(n)?n:b(void 0,t)?.to,g=M({prices:s,standardBookId:c.source,sellingModels:s.some(n=>typeof n[S]=="string"),writtenIn:E,active:t.active},[]),B=new Set(g.standsFor.keys());l=o.filter(n=>{let f=e.sourceIds[n];return f===void 0||!B.has(f)});let D=new Map(s.map(n=>[n.Id,n[k]]));for(let[n,f]of g.standsFor){I.set(n,f);let u=D.get(n),w=typeof u=="string"?E(u):void 0;typeof u=="string"&&w!==void 0&&P.set(n,{from:u,to:w})}O=T(g.said)}let y=t=>e.sources[t][p]===c.source,F=[...l.filter(y),...l.filter(t=>!y(t))];return{...m(F),standsFor:I,standardFirst:l.filter(y).length,standardMatched:!1,prices:O,leftIn:P}}function Q(r,e){let c=r.prices.map(i=>({...i}));for(let i of e){let d=r.leftIn.get(i),a=d&&(c.find(o=>o.from===d.from&&o.to===d.to&&o.how==="replaced"&&!o.forLines)??c.find(o=>o.from===d.from&&o.to===d.to&&o.how==="replaced"));a&&a.prices--}return c.filter(i=>i.prices>0)}function q(r,e){return e===1?`1 ${r} record held back, not sent: read in a currency the target org does not hold active, it stands for the source's own price of its product and price book in the currency written, which this run did not write.`:`${e} ${r} records held back, not sent: read in a currency the target org does not hold active, they stand for the source's own prices of their product and price book in the currency written, which this run did not write.`}var H="The standard price book is matched to the target org's, never written.";function $(r,e){return e.prices.length===0&&!e.standardMatched?r:{...r,...e.prices.length>0?{pricesSettled:[...e.prices]}:{},...e.standardMatched?{standardPricebookMatched:!0}:{}}}export{Y as a,v as b,A as c,Q as d,q as e,H as f,$ as g};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e,f,g}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e,f,g}from"./chunk-4EOHEDFP.mjs";import"./chunk-6JWWSDM6.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{f as STANDARD_PRICEBOOK_MATCHED_NOTE,b as namesAPricebook,d as pricesHeldWithTheirs,e as pricesHeldWithTheirsNote,a as readStandardPricebooks,c as settleSyncPrices,g as withPricesSettled};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{j as c}from"./chunk-
|
|
7
|
+
import{j as c}from"./chunk-PMWAFDUB.mjs";var a=/__kav$/i,d="Campaign";function u(e){return a.test(e)?"Salesforce Knowledge is not turned on in it: tick Knowledge User on your user (Setup > Users), then enable it in Setup > Knowledge Settings":void 0}var b="a campaign needs the Marketing User box ticked on the user, in Setup > Users",f=/^005[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/;function m(e){let n,t;return async s=>{n??=e.describeGlobal().then(o=>new Map(o.sobjects.map(i=>[i.name.toLowerCase(),i.createable===!0])));let r=(await n).get(s.toLowerCase());if(r===void 0){let o=u(s);return{access:"absent",...o?{reason:o}:{}}}return s===d&&(t??=l(e),!r||!await t)?{access:"readOnly",reason:b}:r?{access:"createable"}:{access:"readOnly"}}}async function j(e,n){let t=new Set;for(let{objectApiName:s,optional:r}of e.objects)if(r===!0)try{(await n(s)).access!=="createable"&&t.add(s)}catch{}if(t.size===0)return e;for(let s=!0;s;){s=!1;for(let r of e.objects)t.has(r.objectApiName)||c(r,e.relations).some(o=>t.has(o))&&(t.add(r.objectApiName),s=!0)}return{...e,objects:e.objects.filter(s=>!t.has(s.objectApiName)),...e.relations?{relations:e.relations.filter(({childObject:s,parentObject:r})=>!t.has(s)&&!t.has(r))}:{}}}async function l(e){try{let{user_id:n}=await e.identity();return f.test(n)?(await e.query(`SELECT UserPermissionsMarketingUser FROM User WHERE Id = '${n}'`)).records[0]?.UserPermissionsMarketingUser!==!1:!0}catch{return!0}}export{m as a,j as b};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b}from"./chunk-
|
|
7
|
+
import{a,b}from"./chunk-VCUXCK36.mjs";import"./chunk-WY5V5PR3.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as applyUsers,a as planUsersIn};
|