sandforge 1.84.1 → 1.86.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-S42RBRH2.mjs → chunk-22L43JMK.mjs} +1 -1
- package/lib/{chunk-Y2DRK37K.mjs → chunk-2LSGWTWX.mjs} +1 -1
- package/lib/{chunk-24RFOFYT.mjs → chunk-2YJJTQNC.mjs} +1 -1
- package/lib/chunk-34SMB5PA.mjs +10 -0
- package/lib/chunk-35B73566.mjs +7 -0
- package/lib/{chunk-3TZSBHEY.mjs → chunk-35IJ4WEU.mjs} +1 -1
- package/lib/chunk-3EHPAFKV.mjs +7 -0
- package/lib/{chunk-6YL7BNYD.mjs → chunk-3HAVVEXF.mjs} +1 -1
- package/lib/{chunk-6JWWSDM6.mjs → chunk-3I6FXFCN.mjs} +1 -1
- package/lib/{chunk-WUUKFE2U.mjs → chunk-3KJCSYXY.mjs} +1 -1
- package/lib/{chunk-2HVOZUM4.mjs → chunk-3L6DVNCR.mjs} +1 -1
- package/lib/chunk-3LRFPGYZ.mjs +7 -0
- package/lib/{chunk-GWZRR3MM.mjs → chunk-3MVWGL5A.mjs} +1 -1
- package/lib/{chunk-KGU4SVIT.mjs → chunk-4CSBZZAL.mjs} +1 -1
- package/lib/{chunk-JE6SCT6R.mjs → chunk-4NSXPONF.mjs} +1 -1
- package/lib/{chunk-UIOMAX56.mjs → chunk-4VLP6RHC.mjs} +1 -1
- package/lib/{chunk-YA6ATMTB.mjs → chunk-4XROG5CT.mjs} +1 -1
- package/lib/chunk-54V4FVEY.mjs +7 -0
- package/lib/chunk-55OJJT2Q.mjs +7 -0
- package/lib/{chunk-6QE6R6RL.mjs → chunk-5EHHQ5UX.mjs} +1 -1
- package/lib/{chunk-FITPY3L4.mjs → chunk-5JMQXHJ2.mjs} +1 -1
- package/lib/{chunk-W6PN6TJG.mjs → chunk-65AMXOQU.mjs} +1 -1
- package/lib/{chunk-3Q353S2R.mjs → chunk-6HHSAPIM.mjs} +1 -1
- package/lib/chunk-6KVBCFVS.mjs +7 -0
- package/lib/chunk-6NG7C2U3.mjs +476 -0
- package/lib/chunk-6ROL3KBM.mjs +7 -0
- package/lib/{chunk-2JDAOWUW.mjs → chunk-72AWCN7U.mjs} +1 -1
- package/lib/{chunk-JLSIWO4Z.mjs → chunk-7KHA5UIQ.mjs} +1 -1
- package/lib/chunk-7O6EFNQS.mjs +10 -0
- package/lib/{chunk-WWTCWWZI.mjs → chunk-A2CH2QGX.mjs} +1 -1
- package/lib/chunk-A2TXLAC3.mjs +276 -0
- package/lib/chunk-ALWVNR34.mjs +7 -0
- package/lib/{chunk-D4GF4FAB.mjs → chunk-ATBQIE2V.mjs} +1 -1
- package/lib/{chunk-NED4MBIM.mjs → chunk-ATQML7ZK.mjs} +1 -1
- package/lib/chunk-AVY742BJ.mjs +7 -0
- package/lib/{chunk-YWEQQL3C.mjs → chunk-AXTB2HJS.mjs} +1 -1
- package/lib/chunk-BBZUGKBZ.mjs +10 -0
- package/lib/chunk-BIDXK7KA.mjs +7 -0
- package/lib/{chunk-O677VOGO.mjs → chunk-BLMJ4WVI.mjs} +1 -1
- package/lib/{chunk-RE7RYF3B.mjs → chunk-BNHJCJJM.mjs} +1 -1
- package/lib/{chunk-5M5FQ7RP.mjs → chunk-BNPQEQXC.mjs} +1 -1
- package/lib/chunk-C5AUNG6T.mjs +37 -0
- package/lib/{chunk-ETDCBLGU.mjs → chunk-C5EQ7GFC.mjs} +1 -1
- package/lib/{chunk-MJZU3U5O.mjs → chunk-C7CKDZMC.mjs} +61 -61
- package/lib/{chunk-HCGXK7G7.mjs → chunk-CB4U22NR.mjs} +1 -1
- package/lib/chunk-CJAWKLAL.mjs +7 -0
- package/lib/chunk-CL75DEMQ.mjs +9 -0
- package/lib/{chunk-VCUXCK36.mjs → chunk-CLUNF4FK.mjs} +1 -1
- package/lib/chunk-CSMGP53U.mjs +7 -0
- package/lib/{chunk-7YNM6KFZ.mjs → chunk-CT324C7I.mjs} +1 -1
- package/lib/{chunk-7UVKIWKV.mjs → chunk-CZXDJXQP.mjs} +1 -1
- package/lib/{chunk-43TOMFV4.mjs → chunk-D2X6U3MS.mjs} +1 -1
- package/lib/{chunk-M6K34KGF.mjs → chunk-DAUX63UB.mjs} +1 -1
- package/lib/chunk-DB7JNALQ.mjs +10 -0
- package/lib/chunk-DDNCJVZ2.mjs +17 -0
- package/lib/{chunk-FP7CYB2F.mjs → chunk-DLSU66MY.mjs} +1 -1
- package/lib/{chunk-JKJ74BX5.mjs → chunk-DO6PSHQZ.mjs} +1 -1
- package/lib/{chunk-MDMPJEV3.mjs → chunk-DUBECLZV.mjs} +1 -1
- package/lib/{chunk-KZTZDC7H.mjs → chunk-DYHF6DNT.mjs} +1 -1
- package/lib/chunk-E5FSPXYH.mjs +930 -0
- package/lib/{chunk-Q7GIJBCD.mjs → chunk-EGL3I3IX.mjs} +1 -1
- package/lib/chunk-EIYMQPMG.mjs +7 -0
- package/lib/{chunk-RHNTHGNU.mjs → chunk-EUIALBMX.mjs} +1 -1
- package/lib/{chunk-NCZKWSC7.mjs → chunk-FI3R5ZOQ.mjs} +1 -1
- package/lib/{chunk-PAXNWTYK.mjs → chunk-FM4QCTO7.mjs} +1 -1
- package/lib/{chunk-HV7VPEXP.mjs → chunk-FRSIEASH.mjs} +1 -1
- package/lib/{chunk-QAFPQ3YB.mjs → chunk-FV6MOSHD.mjs} +1 -1
- package/lib/chunk-FYG47CNA.mjs +7 -0
- package/lib/chunk-GB6W4Q56.mjs +7 -0
- package/lib/chunk-GEV2DCMK.mjs +7 -0
- package/lib/{chunk-NSQWI7ZY.mjs → chunk-GFB2DNCB.mjs} +1 -1
- package/lib/chunk-GFGMGFSH.mjs +7 -0
- package/lib/{chunk-RGUQOSBU.mjs → chunk-GIFQXB2Q.mjs} +1 -1
- package/lib/{chunk-JAEDM4SI.mjs → chunk-GP5J3DGS.mjs} +1 -1
- package/lib/chunk-GQZEX7LH.mjs +231 -0
- package/lib/{chunk-JSAJS3MY.mjs → chunk-GYDTM62J.mjs} +1 -1
- package/lib/{chunk-OPMO6I45.mjs → chunk-GYFIXUJG.mjs} +1 -1
- package/lib/chunk-GZW2GNFK.mjs +7 -0
- package/lib/chunk-H6BHWAX7.mjs +8 -0
- package/lib/{chunk-EAC5QCE3.mjs → chunk-HDDJ3CVN.mjs} +1 -1
- package/lib/{chunk-5SMWFNE7.mjs → chunk-HDWB4ZOG.mjs} +1 -1
- package/lib/chunk-HGVPBJR6.mjs +7 -0
- package/lib/{chunk-BBRWFKS5.mjs → chunk-HLROVOR6.mjs} +1 -1
- package/lib/{chunk-LKTNQEBS.mjs → chunk-HUOR4M2L.mjs} +1 -1
- package/lib/chunk-HZCS6EED.mjs +8 -0
- package/lib/{chunk-36JOHEJL.mjs → chunk-HZUI56KZ.mjs} +1 -1
- package/lib/chunk-IAB5H7WN.mjs +7 -0
- package/lib/{chunk-X4BXESMQ.mjs → chunk-IQ5UKRHU.mjs} +1 -1
- package/lib/{chunk-54WZUS7J.mjs → chunk-IRQ4WANV.mjs} +1 -1
- package/lib/{chunk-5IZTFMJM.mjs → chunk-IT3DGX37.mjs} +1 -1
- package/lib/chunk-J347SPU6.mjs +49 -0
- package/lib/{chunk-QO53K5W2.mjs → chunk-JANBNTR5.mjs} +1 -1
- package/lib/chunk-JFXQZPRY.mjs +9 -0
- package/lib/{chunk-KAZS5Z6W.mjs → chunk-JRLYWVF4.mjs} +1 -1
- package/lib/{chunk-GKY2JMHY.mjs → chunk-JSNMUTY6.mjs} +1 -1
- package/lib/chunk-JTNJKSAA.mjs +7 -0
- package/lib/{chunk-7WATA4SB.mjs → chunk-JV2LAKWQ.mjs} +1 -1
- package/lib/{chunk-WAPSSYMT.mjs → chunk-JV7K2ZHK.mjs} +1 -1
- package/lib/{chunk-ZBAWJUG2.mjs → chunk-K4TQ7YHX.mjs} +1 -1
- package/lib/chunk-K5PUMHZU.mjs +7 -0
- package/lib/chunk-KH4KLCYG.mjs +7 -0
- package/lib/{chunk-OLCVHL7I.mjs → chunk-KQVLZVOP.mjs} +1 -1
- package/lib/chunk-KWUS7UAV.mjs +19 -0
- package/lib/{chunk-JGZPD4IM.mjs → chunk-L6G73FXM.mjs} +1 -1
- package/lib/{chunk-BAWCOKRW.mjs → chunk-LG466Q5H.mjs} +1 -1
- package/lib/{chunk-GMIGWR6U.mjs → chunk-LHNAR6FC.mjs} +1 -1
- package/lib/chunk-LT4GHEI2.mjs +7 -0
- package/lib/{chunk-EC72TIEG.mjs → chunk-MR262Y3B.mjs} +1 -1
- package/lib/{chunk-LA4KIATH.mjs → chunk-NCCHOV2N.mjs} +1 -1
- package/lib/chunk-NICRSGLS.mjs +7 -0
- package/lib/chunk-NV5QA2HY.mjs +7 -0
- package/lib/{chunk-PR3XCSPO.mjs → chunk-O3GIN5TU.mjs} +1 -1
- package/lib/chunk-O6FHK6NQ.mjs +13 -0
- package/lib/{chunk-M4BLK6HJ.mjs → chunk-O7YIEFG7.mjs} +1 -1
- package/lib/chunk-OCUVAA5E.mjs +7 -0
- package/lib/chunk-OLCS7JCT.mjs +14 -0
- package/lib/chunk-ON7Y63FK.mjs +9 -0
- package/lib/{chunk-N4WPCWJO.mjs → chunk-OO2WY3UB.mjs} +1 -1
- package/lib/{chunk-MSIEU5MR.mjs → chunk-OT2NHL2V.mjs} +1 -1
- package/lib/{chunk-6WX5ZU7Q.mjs → chunk-P2M5ZXWU.mjs} +1 -1
- package/lib/{chunk-GNRSF65U.mjs → chunk-P4YOHLZ4.mjs} +1 -1
- package/lib/chunk-PBHDPTT6.mjs +343 -0
- package/lib/chunk-PE7CHD2W.mjs +7 -0
- package/lib/{chunk-PBY2O6OF.mjs → chunk-PIQ2I67B.mjs} +1 -1
- package/lib/chunk-PKYDNZJK.mjs +7 -0
- package/lib/chunk-PVZ72OOQ.mjs +7 -0
- package/lib/chunk-QACFTHJM.mjs +8 -0
- package/lib/{chunk-J3DND3BC.mjs → chunk-QGVL5EW3.mjs} +1 -1
- package/lib/chunk-QHE2RUWX.mjs +7 -0
- package/lib/{chunk-QKEKG2LD.mjs → chunk-RCW5BZNW.mjs} +1 -1
- package/lib/{chunk-4JE4BYXK.mjs → chunk-RJ6HHG7J.mjs} +1 -1
- package/lib/{chunk-ZQWIVYVM.mjs → chunk-RPTEEI4R.mjs} +1 -1
- package/lib/chunk-RQW5S67A.mjs +7 -0
- package/lib/chunk-RTCMYMED.mjs +7 -0
- package/lib/chunk-RWVX7XSD.mjs +7 -0
- package/lib/{chunk-WY5V5PR3.mjs → chunk-RZOINFNL.mjs} +1 -1
- package/lib/chunk-SOOTWGMQ.mjs +7 -0
- package/lib/chunk-STQ2JMIZ.mjs +7 -0
- package/lib/{chunk-6PD6K7LP.mjs → chunk-SUIPDW5O.mjs} +1 -1
- package/lib/{chunk-TNT27RBG.mjs → chunk-SZOJ7BEJ.mjs} +1 -1
- package/lib/{chunk-4EOHEDFP.mjs → chunk-T542Z54E.mjs} +1 -1
- package/lib/chunk-TAN2CIRI.mjs +21 -0
- package/lib/{chunk-A3MYSOOC.mjs → chunk-TCNBINOG.mjs} +1 -1
- package/lib/chunk-TFDF3DBN.mjs +7 -0
- package/lib/chunk-TICZXC53.mjs +9 -0
- package/lib/chunk-TLX45X5U.mjs +7 -0
- package/lib/{chunk-QTG6LUZT.mjs → chunk-TMIV3IWH.mjs} +1 -1
- package/lib/chunk-TQ6HEJ73.mjs +11 -0
- package/lib/chunk-TTU5EQZ6.mjs +7 -0
- package/lib/chunk-TYUYPFDJ.mjs +7 -0
- package/lib/chunk-TZXYVMZC.mjs +7 -0
- package/lib/chunk-UCUFLFNK.mjs +7 -0
- package/lib/chunk-UK3QLBHW.mjs +7 -0
- package/lib/{chunk-IZGCEOYO.mjs → chunk-UM2B4GR7.mjs} +1 -1
- package/lib/chunk-UZFTTNOP.mjs +7 -0
- package/lib/chunk-V3AXSKSU.mjs +7 -0
- package/lib/chunk-VA6EEI6X.mjs +21 -0
- package/lib/{chunk-OFTT7J2M.mjs → chunk-VFKG2G37.mjs} +1 -1
- package/lib/chunk-VJNEW5MQ.mjs +7 -0
- package/lib/{chunk-L53JWJ3S.mjs → chunk-VKREON6Q.mjs} +1 -1
- package/lib/{chunk-NOBQTEQD.mjs → chunk-VNNDYPBL.mjs} +1 -1
- package/lib/{chunk-ZJW6YOMV.mjs → chunk-VRBETPHY.mjs} +1 -1
- package/lib/{chunk-EPFCERGL.mjs → chunk-VT6P3X6R.mjs} +1 -1
- package/lib/{chunk-ZV7ZFQQC.mjs → chunk-VUTQY76O.mjs} +1 -1
- package/lib/chunk-WF5S4FW5.mjs +7 -0
- package/lib/{chunk-Z4LKKOFY.mjs → chunk-WJGK6VGU.mjs} +1 -1
- package/lib/{chunk-5CRLRHOJ.mjs → chunk-WJHMB3SL.mjs} +1 -1
- package/lib/{chunk-OUZQPYT3.mjs → chunk-WQCXOZEJ.mjs} +1 -1
- package/lib/{chunk-L2E5WBGD.mjs → chunk-WVVFR4E3.mjs} +1 -1
- package/lib/{chunk-PWRJRL5U.mjs → chunk-XBYXT74L.mjs} +1 -1
- package/lib/chunk-XJE3LJHP.mjs +7 -0
- package/lib/{chunk-CPQIZGG5.mjs → chunk-XV4CVZYD.mjs} +1 -1
- package/lib/chunk-Y37ED7AS.mjs +7 -0
- package/lib/{chunk-YTLUYSMF.mjs → chunk-YGBNZYT4.mjs} +1 -1
- package/lib/{chunk-4CVUUVGJ.mjs → chunk-YGTOX7IL.mjs} +1 -1
- package/lib/{chunk-OMNMLKDT.mjs → chunk-YJ27WHKR.mjs} +1 -1
- package/lib/chunk-YRULC27A.mjs +7 -0
- package/lib/{chunk-RMFU4BAL.mjs → chunk-YSVAHT4Q.mjs} +4 -4
- package/lib/chunk-YTOTMJTY.mjs +15 -0
- package/lib/{chunk-B63POIPQ.mjs → chunk-YZKZC62O.mjs} +1 -1
- package/lib/{chunk-DPMRIMUC.mjs → chunk-YZQN7BRB.mjs} +1 -1
- package/lib/{chunk-7SQSWVAU.mjs → chunk-Z5IUK2QO.mjs} +1 -1
- package/lib/{chunk-M2ABR4JM.mjs → chunk-ZEGSMW5A.mjs} +1 -1
- package/lib/{chunk-PR42EZSR.mjs → chunk-ZIKLQZBG.mjs} +1 -1
- package/lib/chunk-ZVU7MD2S.mjs +7 -0
- package/lib/sandforge-autopilot.mjs +33 -27
- package/lib/sandforge-backup.mjs +19 -19
- 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 +32 -14
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +11 -13
- package/lib/sandforge-env.mjs +105 -105
- package/lib/sandforge-frozen.mjs +1 -1
- package/lib/sandforge-mcp.mjs +2 -2
- package/lib/sandforge-monitor.mjs +1 -1
- package/lib/sandforge-pipeline.mjs +13 -13
- package/lib/sandforge-seed.mjs +1 -1
- package/lib/sandforge-sync.mjs +1 -1
- package/lib/sandforge-users.mjs +13 -15
- package/lib/sandforge.mjs +1 -1
- package/lib/sf/sandforge/dataops.mjs +2 -2
- package/lib/sfPlugin.mjs +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/lib/chunk-23SEDORH.mjs +0 -11
- package/lib/chunk-26POJDIT.mjs +0 -7
- package/lib/chunk-2AZQHBEF.mjs +0 -7
- package/lib/chunk-2METQHGG.mjs +0 -7
- package/lib/chunk-2WFIVO4F.mjs +0 -13
- package/lib/chunk-2YHZBUZE.mjs +0 -7
- package/lib/chunk-326AJTIU.mjs +0 -272
- package/lib/chunk-3PVRGTVK.mjs +0 -7
- package/lib/chunk-5XTUSN72.mjs +0 -8
- package/lib/chunk-6I6TWNV5.mjs +0 -7
- package/lib/chunk-6O222PW6.mjs +0 -7
- package/lib/chunk-6ZLKIT3H.mjs +0 -7
- package/lib/chunk-7QYHEHMA.mjs +0 -9
- package/lib/chunk-B3FBHVNN.mjs +0 -21
- package/lib/chunk-BEA27DLS.mjs +0 -7
- package/lib/chunk-BRY3PLIZ.mjs +0 -7
- package/lib/chunk-CBH3TOWK.mjs +0 -341
- package/lib/chunk-CVHNXJH3.mjs +0 -7
- package/lib/chunk-DGDRQRCW.mjs +0 -7
- package/lib/chunk-DUN2EPRC.mjs +0 -7
- package/lib/chunk-E3A3LOCY.mjs +0 -7
- package/lib/chunk-F2424IKX.mjs +0 -7
- package/lib/chunk-F3AQW6IU.mjs +0 -7
- package/lib/chunk-FNJ4SGWO.mjs +0 -7
- package/lib/chunk-GOOVPVWX.mjs +0 -7
- package/lib/chunk-H2BHESDA.mjs +0 -9
- package/lib/chunk-H4CGM6YO.mjs +0 -7
- package/lib/chunk-HIDW7FNV.mjs +0 -9
- package/lib/chunk-HSBXRQTI.mjs +0 -7
- package/lib/chunk-HUZPBE47.mjs +0 -7
- package/lib/chunk-I6E6T6YY.mjs +0 -7
- package/lib/chunk-IUM4NFKI.mjs +0 -10
- package/lib/chunk-IVFVNNGB.mjs +0 -37
- package/lib/chunk-JCFBFF4Y.mjs +0 -7
- package/lib/chunk-JTJK2D36.mjs +0 -7
- package/lib/chunk-KB4ZHM4Q.mjs +0 -10
- package/lib/chunk-KJWFYBMU.mjs +0 -15
- package/lib/chunk-LC3NDW4N.mjs +0 -7
- package/lib/chunk-OM5NORJG.mjs +0 -7
- package/lib/chunk-OVNMB6Q2.mjs +0 -7
- package/lib/chunk-PEDQPM2P.mjs +0 -926
- package/lib/chunk-PH7SP4YK.mjs +0 -21
- package/lib/chunk-PMN4PAC3.mjs +0 -19
- package/lib/chunk-PMWAFDUB.mjs +0 -48
- package/lib/chunk-PPLVFX6N.mjs +0 -7
- package/lib/chunk-PZBZ7MNC.mjs +0 -7
- package/lib/chunk-QROPNEGY.mjs +0 -14
- package/lib/chunk-RGBGUCJA.mjs +0 -156
- package/lib/chunk-RKTFFCNS.mjs +0 -7
- package/lib/chunk-ROV3QXEF.mjs +0 -475
- package/lib/chunk-RT47RKLY.mjs +0 -7
- package/lib/chunk-SI267LYR.mjs +0 -8
- package/lib/chunk-SRPWW4A2.mjs +0 -10
- package/lib/chunk-T3G6VZNS.mjs +0 -7
- package/lib/chunk-T63U4OZJ.mjs +0 -7
- package/lib/chunk-TEIBWMJM.mjs +0 -7
- package/lib/chunk-TW3N6W5Z.mjs +0 -7
- package/lib/chunk-UBIKR5VO.mjs +0 -7
- package/lib/chunk-UI3JQVRU.mjs +0 -8
- package/lib/chunk-UX3BVH2Y.mjs +0 -7
- package/lib/chunk-VINGECAJ.mjs +0 -10
- package/lib/chunk-VOXJHJIE.mjs +0 -7
- package/lib/chunk-WB2RIVO3.mjs +0 -7
- package/lib/chunk-WXDLQT2O.mjs +0 -10
- package/lib/chunk-XBQGZGWR.mjs +0 -7
- package/lib/chunk-XGGOUNPP.mjs +0 -7
- package/lib/chunk-XKWW3GKF.mjs +0 -7
- package/lib/chunk-YHR4WQPR.mjs +0 -7
- package/lib/chunk-ZQQXSCVI.mjs +0 -7
- package/lib/chunk-ZRUDYB7O.mjs +0 -7
package/lib/chunk-326AJTIU.mjs
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
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{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
|
-
|
|
9
|
-
Usage:
|
|
10
|
-
npx sandforge frozen <step> --config <file> [options]
|
|
11
|
-
|
|
12
|
-
Steps:
|
|
13
|
-
select pick one root per combination of the coverage matrix (needs --source)
|
|
14
|
-
extract read, pseudonymize, check and freeze those roots (needs --source)
|
|
15
|
-
load replay the frozen dataset into a sandbox or a Developer Edition
|
|
16
|
-
\u2014 WRITES (needs --target);
|
|
17
|
-
what the target runs as it inserts and updates is named first, and takes
|
|
18
|
-
--accept-automation or --mute-automation
|
|
19
|
-
verify check the last load against the dataset (needs --target)
|
|
20
|
-
remove delete the records a load created, the last first \u2014 DELETES (needs --target);
|
|
21
|
-
what the target runs as they go is named first, and takes --accept-automation
|
|
22
|
-
or --mute-automation; with --preview, say what it would delete, and delete
|
|
23
|
-
nothing
|
|
24
|
-
status what the store knows so far
|
|
25
|
-
|
|
26
|
-
Required:
|
|
27
|
-
--config <file> the project configuration, as the panel saves it (JSON)
|
|
28
|
-
|
|
29
|
-
Options:
|
|
30
|
-
--source <alias> sf CLI alias of the org the dataset is read from
|
|
31
|
-
--target <alias> sf CLI alias of the sandbox, or Developer Edition org, it is
|
|
32
|
-
loaded into
|
|
33
|
-
--author <name> who froze the dataset, for the manifest (default: sandforge)
|
|
34
|
-
--salt-file <file> the file holding the pseudonymization salt, when
|
|
35
|
-
SANDFORGE_FROZEN_SALT is not set
|
|
36
|
-
--store <file> where the run keeps its state (default: <sasDir>/cli-store.json)
|
|
37
|
-
--pilot load one root folder only
|
|
38
|
-
--reload replace the loads before: purge what earlier loads created,
|
|
39
|
-
then load again. Refused before anything is written when a
|
|
40
|
-
removal of those loads would leave records in the org \u2014
|
|
41
|
-
records changed since, kept for records that stay under them
|
|
42
|
-
(a contact made by hand since under one of their accounts,
|
|
43
|
-
which the org would delete along), of an object the user may
|
|
44
|
-
not delete, out of the user's sight or unread: take the load
|
|
45
|
-
back with remove first (--include-changed takes what changed
|
|
46
|
-
since, and what was added under them since). Refused as well
|
|
47
|
-
when one of them was recorded before loads kept what they
|
|
48
|
-
created, which no removal takes: refresh the sandbox, or find
|
|
49
|
-
what your user created that day with
|
|
50
|
-
${ke("cleanup")}, its dry run
|
|
51
|
-
first, then delete it. Refused
|
|
52
|
-
the same way when the purge would have the org delete along a
|
|
53
|
-
record the reload finds again by its keys \u2014 a quote under the
|
|
54
|
-
opportunity an earlier load wrote: give that parent identity
|
|
55
|
-
keys too, or take the load back first. What the target's
|
|
56
|
-
automation likely made for a load holds nothing with --sweep,
|
|
57
|
-
which takes it first. What the target runs as the purge
|
|
58
|
-
deletes is read and named first, and nothing is written
|
|
59
|
-
while something fires unless --accept-automation or
|
|
60
|
-
--mute-automation answers it. The purge takes what those
|
|
61
|
-
loads created, not what the target's automation made for
|
|
62
|
-
them: --sweep takes that too. With --pilot, a reload purges
|
|
63
|
-
nothing, and is not asked
|
|
64
|
-
--gone-first <file> with load --reload --dry-run: the records taken back before
|
|
65
|
-
the reload runs, a JSON array of their ids \u2014 hanging from the
|
|
66
|
-
loads' records, they hold nothing. sandforge env gives it what
|
|
67
|
-
its apply takes back first; a reload that runs reads what is
|
|
68
|
-
still there
|
|
69
|
-
--max-total <n> with load: the most records it may insert \u2014 the count its dry
|
|
70
|
-
run gave. A load, or a reload, that would insert more is
|
|
71
|
-
refused before anything is written, the purge included; a dry
|
|
72
|
-
run says it would be, exit 1
|
|
73
|
-
--dry-run with load: say what the load would do \u2014 per object, what it
|
|
74
|
-
would insert, link, drop, rewrite and purge \u2014 and write nothing
|
|
75
|
-
--write-encrypted with load: write the fields the target encrypts as the dataset
|
|
76
|
-
holds them, though its manifest does not say its extraction
|
|
77
|
-
left out what it read masked \u2014 they may hold masks such as
|
|
78
|
-
****1234 (left out otherwise, each named)
|
|
79
|
-
--mute-automation with load or remove: mute the target's automation for that
|
|
80
|
-
step through its own bypass \u2014 assign the user it writes as,
|
|
81
|
-
for the step alone, the permission sets holding the custom
|
|
82
|
-
permissions its flows, processes and workflow rules test to
|
|
83
|
-
stay quiet, those of what --sweep deletes included, and take
|
|
84
|
-
them back as it ends; what no bypass keeps quiet still runs,
|
|
85
|
-
and is named, and a load or a removal then needs
|
|
86
|
-
--accept-automation.
|
|
87
|
-
Refused on a production org and for a user who cannot assign
|
|
88
|
-
permission sets, exit 1; with --dry-run or --preview, says
|
|
89
|
-
what would be muted and assigns nothing
|
|
90
|
-
--accept-automation with load: write although the target runs flows, Apex
|
|
91
|
-
triggers, processes or workflow rules as the load inserts
|
|
92
|
-
its records and updates them \u2014 what --mute-automation
|
|
93
|
-
keeps quiet and a bypass the user holds aside \u2014 or could
|
|
94
|
-
not say what it runs; with remove, or load --reload:
|
|
95
|
-
delete although it runs them as the records go, those
|
|
96
|
-
--sweep deletes included \u2014 before or after a delete, or
|
|
97
|
-
as an activated order is set back to Draft for its
|
|
98
|
-
delete. Each is named before anything is written or
|
|
99
|
-
deleted; without the flag the load or the reload writes
|
|
100
|
-
nothing (AUTOMATION_NOT_ACCEPTED), the removal deletes
|
|
101
|
-
nothing, exit 1; --dry-run says so
|
|
102
|
-
--accept-emails with load: write although the target delivers every email
|
|
103
|
-
what still runs sends as the records go in, a reload's
|
|
104
|
-
purge and sweep included (Setup > Deliverability: All
|
|
105
|
-
email), or would not say whether it does: without it
|
|
106
|
-
such a load is refused, exit 1 (EMAILS_NOT_ACCEPTED),
|
|
107
|
-
nothing written. Read only when something that still
|
|
108
|
-
runs sends one, with one line of anonymous Apex that
|
|
109
|
-
sends nothing; on System email only or No access it is
|
|
110
|
-
not needed. The emails are counted too, on the records
|
|
111
|
-
of the dataset, at most, against what the target has
|
|
112
|
-
left today: past it, the load is refused whatever the
|
|
113
|
-
flag, exit 1 (FROZEN_EMAILS_EXCEEDED). --mute-automation
|
|
114
|
-
keeps quiet what tests the org's bypass; what an Apex
|
|
115
|
-
trigger sends is read nowhere. --dry-run says it all,
|
|
116
|
-
and what a load would be refused for
|
|
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
|
-
--include-changed remove also the records changed since the load, and what
|
|
119
|
-
was added to them since (kept otherwise); with load
|
|
120
|
-
--reload --sweep, the sweep of each load replaced takes
|
|
121
|
-
too what it finds changed since that load, which it
|
|
122
|
-
keeps and names otherwise, the load kept recorded for
|
|
123
|
-
a later sweep, and the reload no partial for them
|
|
124
|
-
--sweep with remove: before the load's records go, delete too what
|
|
125
|
-
the target's automation made for the load, that the
|
|
126
|
-
load's mapping does not hold: what the load's user
|
|
127
|
-
created under the load's records, what they point at,
|
|
128
|
-
or what hangs from those, three links at most, at most
|
|
129
|
-
a minute after the record it is tied to \u2014 in the
|
|
130
|
-
objects the load wrote and their children, tasks,
|
|
131
|
-
events, feed, email messages, notes, case comments, and
|
|
132
|
-
the objects the target's flows create; the window is
|
|
133
|
-
the load's writes, from a second before the first to a
|
|
134
|
-
minute after the last. What a record of the load points
|
|
135
|
-
at by a lookup the org refuses the delete for goes once
|
|
136
|
-
that record is gone. Listed and kept: what is tied to
|
|
137
|
-
the load but came later, up to 15 minutes, or as the
|
|
138
|
-
org's Automated Process user; and what the load's user
|
|
139
|
-
created in the window tied to nothing of it. Such
|
|
140
|
-
records then keep none of the load's records as records
|
|
141
|
-
that stay. A sweep refused, or that did not take all it was
|
|
142
|
-
asked to, exits 3, and ends partial a removal that took
|
|
143
|
-
every record of the load; one that left records of its own
|
|
144
|
-
keeps its own status. Once the load's records went already,
|
|
145
|
-
the sweep runs alone, the way to take what such a sweep
|
|
146
|
-
left (off otherwise: a removal that took the load's
|
|
147
|
-
records then reads what a sweep would take now, read
|
|
148
|
-
only, and names what stays and the option that takes
|
|
149
|
-
it, "notSwept" with --json). It sweeps too, each in its
|
|
150
|
-
own window, every other load recorded whose records
|
|
151
|
-
went \u2014 a load a reload replaced, kept for what its
|
|
152
|
-
sweep left \u2014, and lets it go once that sweep took all
|
|
153
|
-
it found. With load --reload: the sweep of each load
|
|
154
|
-
the reload replaces, as its removal sweeps it, around
|
|
155
|
-
the purge; what the target runs as it deletes is named
|
|
156
|
-
once it has read what it takes, before the first
|
|
157
|
-
delete, and answered as the purge's; with --dry-run, it
|
|
158
|
-
lists what it would take. One refused, or that did not
|
|
159
|
-
take all it was asked to, exits 3
|
|
160
|
-
--sweep-late with --sweep: take too what it lists as made late; with
|
|
161
|
-
--sweep-list, say what it would take
|
|
162
|
-
--sweep-untied with --sweep: take too what it lists as tied to nothing of
|
|
163
|
-
the load; with --sweep-list, say what it would take;
|
|
164
|
-
refused when another run wrote to the target
|
|
165
|
-
in the window \u2014 a load swept with it is none, a load
|
|
166
|
-
this command ran from another sas into the org is one
|
|
167
|
-
\u2014, or when that user created records in the window on
|
|
168
|
-
objects neither the load nor the automation reaches
|
|
169
|
-
(hand work, likely)
|
|
170
|
-
--sweep-list with remove: list what --sweep would delete, per object
|
|
171
|
-
with a few names and how many it ties to the load, and
|
|
172
|
-
for each other load it sweeps with it, and delete nothing;
|
|
173
|
-
exit 3 when it says a sweep is refused, as --sweep would
|
|
174
|
-
--preview with remove: say what the removal would do, per object \u2014 the
|
|
175
|
-
records it would delete, those it would keep as changed since
|
|
176
|
-
the load and who changed them, those gone already, those it
|
|
177
|
-
cannot see, and those it would leave because the user may not
|
|
178
|
-
delete them \u2014 what the target runs as they go, and what it
|
|
179
|
-
would be refused for, that automation without
|
|
180
|
-
--accept-automation included. It deletes nothing, writes
|
|
181
|
-
nothing to the sas and asks nothing; it exits 0 once it has
|
|
182
|
-
said it. It cannot know what hangs from the records, which a
|
|
183
|
-
removal reads at each object's turn. With --sweep, it lists
|
|
184
|
-
what the sweep would take, and reads what fires on it with
|
|
185
|
-
the load's own. Not with --sweep-list
|
|
186
|
-
--yes do not ask before a load writes or a removal deletes: a
|
|
187
|
-
removal asks last, once what it deletes and what the
|
|
188
|
-
target runs as they go are said. Without it, a step
|
|
189
|
-
with no terminal to answer the question \u2014 a CI step \u2014
|
|
190
|
-
stops there, exit 2, and writes nothing
|
|
191
|
-
--json emit what the panel would receive, every other line on
|
|
192
|
-
stderr; a step that ends before its request, refused or
|
|
193
|
-
with nothing to do, says "ended": true. Beside it, "step";
|
|
194
|
-
"dataset" \u2014 its folder, its digest (sha256 of the files a load
|
|
195
|
-
reads, the manifest less the verdict a verification writes
|
|
196
|
-
into it) and its version \u2014 for extract, load and verify;
|
|
197
|
-
"mapping", the file in the sas naming the records the loads
|
|
198
|
-
into the target created, for load, verify and remove; per
|
|
199
|
-
object, what the step counted ("objects"); how a load or a
|
|
200
|
-
removal ended ("status"); verify's verdict, and a load's, per
|
|
201
|
-
object ("verdict"); what a dry run or a
|
|
202
|
-
removal's preview would be refused for ("refusals"), with the
|
|
203
|
-
code of each ("refusalCodes"), as its line names it: a load
|
|
204
|
-
would be refused (CODE): ..., a removal would be refused
|
|
205
|
-
(CODE): ...; and what refused a load before it wrote \u2014 what
|
|
206
|
-
runs as it writes, its purge, its checkpoint, its emails or
|
|
207
|
-
its mute \u2014 or a removal
|
|
208
|
-
before its first delete \u2014 what fires as it deletes, its mute
|
|
209
|
-
or Production Guard \u2014 ("refused": {"code", "message"}), as
|
|
210
|
-
its line names it: refused (CODE): ...
|
|
211
|
-
--help this text
|
|
212
|
-
|
|
213
|
-
The salt that makes pseudonyms repeatable is read from SANDFORGE_FROZEN_SALT,
|
|
214
|
-
or else from --salt-file, and never made up here: an extraction without one is
|
|
215
|
-
refused. The editor keeps its own in VS Code's secret storage; copy it from there
|
|
216
|
-
with "SandForge: Copy Frozen Dataset Salt" to extract the same pseudonyms.
|
|
217
|
-
|
|
218
|
-
The graph a selection or an extraction discovers is kept in the sas
|
|
219
|
-
(discovery.json) and reused by the next one while the source's schema has not
|
|
220
|
-
changed and a day has not gone by: each says "graph reused from <step>" or
|
|
221
|
-
"rediscovered: <why>".
|
|
222
|
-
|
|
223
|
-
Ctrl-C stops a step after the call under way, a load recorded in the sas with
|
|
224
|
-
what it wrote, which remove takes back; a SIGTERM \u2014 a CI job cancelled or timed
|
|
225
|
-
out \u2014 or a SIGHUP stops it the same way. Ctrl-C again ends it at once.
|
|
226
|
-
|
|
227
|
-
Exit codes: 0 the step finished \u2014 a removal with nothing to take included, and a
|
|
228
|
-
removal's preview once said, its refusals included \u2014, and verify's verdict is
|
|
229
|
-
PASSED; 1 it failed or could not start, verify's verdict is FAILED, a dry run says
|
|
230
|
-
the load would be refused, a load was refused before it wrote for what the target
|
|
231
|
-
runs as it writes (AUTOMATION_NOT_ACCEPTED without --accept-automation), for its
|
|
232
|
-
emails (EMAILS_NOT_ACCEPTED without --accept-emails, FROZEN_EMAILS_EXCEEDED) or for
|
|
233
|
-
the data storage its records take past what the target has left
|
|
234
|
-
(FROZEN_STORAGE_EXCEEDED: --pilot, or a smaller dataset), or a removal
|
|
235
|
-
stopped before its first delete at what the target runs, without
|
|
236
|
-
--accept-automation; 2 a bad command line, or a question with
|
|
237
|
-
no terminal to answer it (give --yes); 3 verify's verdict is PARTIAL, a load
|
|
238
|
-
completed with errors, the verification it runs after it was FAILED or PARTIAL, or
|
|
239
|
-
the sweep of a reload did not take all it was asked to, or a removal left records
|
|
240
|
-
of the load or its sweep did not take all it was asked to; 4 verify's verdict is
|
|
241
|
-
UNSTABLE: no two readings agreed; 130 Ctrl-C stopped the step, 143 a SIGTERM, 129 a
|
|
242
|
-
SIGHUP. A load is judged by its own report, which ends partial on a verification
|
|
243
|
-
FAILED or PARTIAL; one UNSTABLE is said, and the verify step gives it a code.
|
|
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
|
-
`),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 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
|
-
`),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
|
-
`),process.exit(2)),(n==="load"||n==="verify"||n==="remove")&&!m&&(process.stderr.write(`${n} works on the target org: give --target.
|
|
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.
|
|
251
|
-
`),process.exit(2)),t.includes("--sweep-list")&&n!=="remove"&&(process.stderr.write(`--sweep-list goes with remove${n==="load"?"; a reload lists what its sweep would take with --dry-run --sweep":""}. Run with --help.
|
|
252
|
-
`),process.exit(2)),t.includes("--sweep")&&n!=="remove"&&!(n==="load"&&t.includes("--reload")&&!t.includes("--pilot"))&&(process.stderr.write(`--sweep goes with remove or load --reload${n==="load"&&t.includes("--pilot")?", and a pilot purges nothing":""}. Run with --help.
|
|
253
|
-
`),process.exit(2)),t.includes("--include-changed")&&n!=="remove"&&!(n==="load"&&t.includes("--reload")&&t.includes("--sweep"))&&(process.stderr.write(`--include-changed goes with remove, or with load --reload --sweep, whose sweep then takes what changed since the loads it replaces. Run with --help.
|
|
254
|
-
`),process.exit(2)),t.includes("--gone-first")&&!(n==="load"&&t.includes("--reload")&&t.includes("--dry-run"))&&(process.stderr.write(`--gone-first goes with load --reload --dry-run. Run with --help.
|
|
255
|
-
`),process.exit(2));let r=o("--gone-first");t.includes("--gone-first")&&r===void 0&&(process.stderr.write(`--gone-first takes the file of the ids taken back first.
|
|
256
|
-
`),process.exit(2)),t.includes("--write-encrypted")&&n!=="load"&&(process.stderr.write(`--write-encrypted goes with load. Run with --help.
|
|
257
|
-
`),process.exit(2)),t.includes("--accept-emails")&&n!=="load"&&(process.stderr.write(`--accept-emails goes with load. Run with --help.
|
|
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
|
-
`),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(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
|
-
`),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
|
-
`),process.exit(2));let a=jt(t);"refusal"in a&&(process.stderr.write(`${a.refusal} Run with --help.
|
|
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>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
|
-
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||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};
|
package/lib/chunk-3PVRGTVK.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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};
|
package/lib/chunk-5XTUSN72.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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 $e}from"./chunk-Q7GIJBCD.mjs";import{a as We}from"./chunk-M6P5ZZLE.mjs";import{c as ke,d as Ge}from"./chunk-NED4MBIM.mjs";import{d as _e,z as Le}from"./chunk-KGU4SVIT.mjs";import{a as Me}from"./chunk-VV3B6IC3.mjs";import{a as k}from"./chunk-4TLYUZD5.mjs";import{m as qe}from"./chunk-RHNTHGNU.mjs";import{a as re,b as De}from"./chunk-Q7TLC3I2.mjs";import{b as xe}from"./chunk-EADHKH3A.mjs";import{a as H,c as Ae,g as oe,j as Pe,n as Ne}from"./chunk-M6K34KGF.mjs";import{a as Te,h as q}from"./chunk-TZE3Y7IQ.mjs";import{a as je,b as x}from"./chunk-CA5NAXSU.mjs";import{Ac as ee,Bc as te,ca as Ie,ja as Fe,wa as ve,za as ue,zc as Z}from"./chunk-PMWAFDUB.mjs";import{b as Ce,e as Ee,i as Re,k as Se,l as de}from"./chunk-WZQEK4WT.mjs";import{appendFile as tt}from"node:fs/promises";var fe=new Set(["Task","Event"]),rt=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,ot="an emptying";function nt(t){let e=q(t.objectApiName),o=fe.has(t.objectApiName),r=[...t.filter!==void 0&&t.filter.trim()!==""?[`(${t.filter})`]:[],...o?["IsDeleted = false"]:[]];return{soql:`SELECT Id FROM ${e}${r.length>0?` WHERE ${r.join(" AND ")}`:""}`,scanAll:o}}async function zt(t,e,o,r={}){let n=()=>r.signal?.aborted===!0,c=[];await Le(e);for(let a of o){let{soql:d,scanAll:u}=nt(a),m={objectApiName:a.objectApiName,count:0};if(c.push(m),n())return{stopped:!0,read:c};let R=ke(e,a.objectApiName),i=!0,h=0,b=await t.query(d,{scanAll:u});for(;;){let S=b.records.map(y=>{let C=y.Id;if(typeof C!="string"||!rt.test(C))throw new Error(`The org answered a ${a.objectApiName} row with no record id: its ids are not read.`);return C});if((S.length>0||i)&&(await tt(R,S.map(y=>`${y}
|
|
8
|
-
`).join(""),{encoding:"utf8",mode:_e,flag:i?"w":"a"}),i=!1),m.count+=S.length,r.onPage?.(a.objectApiName,m.count),h=S.length===0?h+1:0,b.done||!b.nextRecordsUrl)break;if(h>=xe)throw new Error(`The org kept answering empty pages of ${a.objectApiName} without saying it was done: ${m.count} id(s) read, the rest not.`);if(n())return{stopped:!0,read:c};b=await t.queryMore(b.nextRecordsUrl)}}return{stopped:!1,spool:await Ge(e,c,ot)}}function ne(t,e,o){return e.nillable!==!1||e.referenceTo.length!==1?!1:e.isMasterDetail||(o??[]).some(r=>r.isCascadeDelete&&r.childSObject===t&&r.field===e.name)}var V=.001,ge=.01,st=50,it=5,at=2,ct=4;function lt(t){return t.level===0||t.recordCount>0||t.status==="error"||t.recordCountUnknown===!0}function Be(t){return t.inputMode==="record"&&typeof t.recordId=="string"&&t.recordId!==""}function pe(t){if(!Fe(t)||t.inputMode!=="soql")return;let e=Ie(t.soqlQuery??"");return e?{where:e.where,limit:e.limit}:void 0}function dt(t,e,o){let r=[];o===0&&Be(t)&&r.push(`Id = '${Te(t.recordId??"")}'`);let n=o===0?pe(t):void 0;n?.where&&r.push(`(${n.where})`);let c=t.objectSoqlFilters?.[e];return c&&r.push(`(${c})`),`SELECT COUNT() FROM ${q(e)}${r.length>0?` WHERE ${r.join(" AND ")}`:""}`}var me=typeof setImmediate=="function"?()=>new Promise(t=>setImmediate(t)):()=>new Promise(t=>setTimeout(t,0)),A=class extends Error{constructor(){super("Discovery cancelled"),this.name="DiscoveryCancelled"}};function M(t,e){return e?e.aborted?Promise.reject(new A):new Promise((o,r)=>{let n=()=>r(new A);e.addEventListener("abort",n,{once:!0}),t().then(c=>{e.removeEventListener("abort",n),o(c)},c=>{e.removeEventListener("abort",n),r(c)})}):t()}function ut(t){return t.fieldCount>0||t.piiFields.length>0}function ft(t,e){if(t.type!=="master-detail")return t;let o=(e.get(t.targetObject)?.fields??[]).filter(n=>n.referenceTo.includes(t.sourceObject)),r=e.get(t.sourceObject)?.childRelationships;return o.some(n=>ne(t.targetObject,n,r))?t:{...t,type:"lookup"}}function Y(){return{nodes:[],edges:[],totalRecords:0,estimatedSizeMB:0,estimatedDurationSeconds:0,truncated:!1}}var Ue=class{deps;constructor(e){this.deps=e}async discover(e,o){if(e.inputMode==="org"||e.depth==="all")return ze(this.deps,e,o);let r=o?.signal;if(r?.aborted)return Y();o?.onProgress?.({phase:"resolving-root",discoveredCount:0,queueRemaining:1});let n=Date.now(),c;try{c=await this.resolveRootObject(e,r)}catch(g){if(g instanceof A)return Y();throw g}let a=Date.now();a-n>2e3&&k.warn(`[forge-discover] resolveRootObject took ${a-n}ms (cold path, consider verifying describeGlobal cache state)`);let d=this.resolveMaxDepth(e),u=o?.maxNodes??st,m=u,R=u*at,i=new Set,h=[],b=u*ct,S=0,y=0,C=new Set,I=[],$=new Map,N=new Map,L=()=>S+y+w.length<m&&I.length+y+w.length<b,W=(g,j)=>{i.has(g)||h.push([g,j]),i.add(g)},D=g=>{i.delete(g)&&(h=h.filter(([j])=>j!==g))},U=new Map,B=(g,j,P,F)=>{if(H(g.sourceObject)||H(g.targetObject)||g.sourceObject===g.targetObject)return;let s=`${g.sourceObject}|${g.targetObject}`,l=U.get(s)??new Map;(P!==void 0||!l.has(j))&&l.set(j,{settable:P,insertOnly:F}),U.set(s,l);let p=$.get(s);if(!p){$.set(s,g);return}let f=g.type==="master-detail"&&p.type==="lookup"?g:p,v=p.required===!0||g.required===!0;$.set(s,v?{...f,required:v}:f)},w=[[c,0]];for(C.add(c);w.length>0&&!r?.aborted;){await me();let g=m-S;if(g<=0)break;let j=Math.min(6,g,w.length),P=w.splice(0,j),F=await Promise.all(P.map(async([s,l])=>{let p,f=!1,v=dt(e,s,l);try{let[E,Q]=await Promise.all([M(()=>this.deps.describeObject(e.sourceOrgId,s,r),r),M(()=>this.deps.queryCount(e.sourceOrgId,v,r),r).catch(_=>{if(_ instanceof A)throw _;return p=x(_),f=se(_),-1})]);return{objectName:s,depth:l,describe:E,recordCount:Q,countError:p,countRefused:f}}catch(E){return E instanceof A||r?.aborted?{objectName:s,depth:l,describe:null,recordCount:-1,cancelled:!0}:{objectName:s,depth:l,describe:null,recordCount:-1,describeError:x(E)}}}));y=F.length;for(let s of F){if(y--,s.cancelled)continue;let{objectName:l,depth:p,describe:f,recordCount:v,countError:E,countRefused:Q,describeError:_}=s;if(!f){I.push({objectApiName:l,recordCount:0,fieldCount:0,status:"error",progress:0,included:!1,piiFields:[],anonymizeFields:[],level:p,successCount:0,failureCount:0,errors:[`Describe unavailable: ${_??"unknown error"}`],createableFieldCount:0,estimatedSizeMB:0,estimatedApiCalls:0,batchStrategy:"auto"}),S++,o?.onProgress?.({phase:"object",objectApiName:l,discoveredCount:I.length,queueRemaining:w.length});continue}N.set(l,f);let ie=v<0,ae=ie&&Q!==!0,ce=ie&&!ae,le=p===0?pe(e)?.limit:void 0,J=ie?0:typeof le=="number"&&Number.isFinite(le)?Math.min(v,le):v,Je=p===0&&(Be(e)||pe(e)!==void 0),be=this.deps.detectPII(f.fields),Ke=f.fields.filter(O=>O.type!=="id").length,Oe={objectApiName:l,...f.label?{label:f.label}:{},recordCount:J,...ae?{recordCountUnknown:!0}:{},fieldCount:f.fields.length,status:ce?"error":"idle",progress:0,included:ce?!1:ae||Je||!e.skipEmpty||J>0,piiFields:be,anonymizeFields:e.anonymizePII?be:[],level:p,successCount:0,failureCount:0,errors:ce?[`Record count unavailable: ${E??"unknown error"}`]:[],createableFieldCount:Ke,estimatedSizeMB:J*V,estimatedApiCalls:Math.ceil(J/200),batchStrategy:"auto"};I.push(Oe);let ye=lt(Oe);if(ye&&S++,p<d&&ye){for(let O of f.fields){if(O.referenceTo.length===0)continue;let we=ee(O),K=we&&Z(l,O.name,O.nillable),Ze=te(O);for(let T of O.referenceTo){B({sourceObject:T,targetObject:l,relationshipName:O.relationshipName??O.name,type:O.isMasterDetail?"master-detail":"lookup",required:K},O.name,we,Ze);let et=i.has(T);(!C.has(T)||K&&et)&&!H(T)&&(L()?(C.add(T),D(T),K?w.unshift([T,p+1]):w.push([T,p+1])):K&&m<R?(C.add(T),D(T),m++,w.unshift([T,p+1])):(C.add(T),W(T,p+1)))}}for(let O of f.childRelationships)B({sourceObject:l,targetObject:O.childSObject,relationshipName:O.relationshipName,type:O.isCascadeDelete?"master-detail":"lookup"},O.field,void 0,void 0),!C.has(O.childSObject)&&!H(O.childSObject)&&(C.add(O.childSObject),L()?w.push([O.childSObject,p+1]):W(O.childSObject,p+1))}o?.onProgress?.({phase:"object",objectApiName:l,discoveredCount:I.length,queueRemaining:w.length})}for(;h.length>0&&L();){let[s,l]=h.shift();i.delete(s),w.push([s,l])}}let z=I.reduce((g,j)=>g+j.recordCount,0),G=[...$].map(([g,j])=>{let P=[...U.get(g)?.values()??[]],F=ft(j,N);return P.length>0&&P.every(s=>s.settable===!1)&&(F={...F,settable:!1}),P.some(s=>s.insertOnly===!0)&&(F={...F,insertOnly:!0}),F});return{nodes:I,edges:G,totalRecords:z,estimatedSizeMB:z*V,estimatedDurationSeconds:z*ge,truncated:h.length>0}}personalFields(e){return this.deps.detectPII(e)}async readPersonalFields(e,o,r){let n=e.nodes.filter(a=>!ut(a)&&a.status!=="error"),c=new Map;for(let a=0;a<n.length&&!r?.aborted;a+=6)await Promise.all(n.slice(a,a+6).map(async({objectApiName:d})=>{try{let u=await this.deps.describeObject(o.sourceOrgId,d,r),m=this.deps.detectPII(u.fields);m.length>0&&c.set(d,m)}catch(u){k.warn(`[forge] personal fields of ${d} not read: ${x(u)}`)}}));return c.size===0?e:{...e,nodes:e.nodes.map(a=>{let d=c.get(a.objectApiName);return d?{...a,piiFields:d,anonymizeFields:o.anonymizePII?[...d]:[]}:a})}}async resolveRootObject(e,o){if(e.inputMode==="record"&&e.recordId){let r=e.recordId.substring(0,3),c=(await M(()=>this.deps.describeGlobal(e.sourceOrgId,o),o)).find(a=>a.keyPrefix===r);if(!c)throw new Error(`No object found for record ID prefix "${r}". The ID may not belong to any accessible object in this org.`);return c.name}if(e.inputMode==="soql"&&e.soqlQuery)return pt(e.soqlQuery);throw new Error(`Cannot resolve root object for inputMode "${e.inputMode}". Provide a valid recordId (for "record" mode) or soqlQuery (for "soql" mode).`)}resolveMaxDepth(e){switch(e.depth){case"direct":return 1;case"full":return it;case"custom":return Math.max(1,Math.min(10,e.customDepth??3));case"all":throw new Error("A clone of the whole org is discovered without a walk (WholeOrgDiscovery)")}}};function pt(t){let e=t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/--[^\n]*/g,"");for(let r=0;r<32;r++){let n=e.replace(/\([^()]*\)/g,"");if(n===e)break;e=n}let o=/\bFROM\s+(\w+)/i.exec(e);if(!o)throw new Error('Could not parse object name from SOQL query. Ensure the query uses standard "SELECT ... FROM ObjectName" syntax.');return q(o[1])}var gt={clone:"write",empty:"delete"},mt=["settings","definition"],ht=new Set(["contentworkspace"]);function bt(t){if(t.name.includes("__"))return!1;let e=t.name.toLowerCase();return ht.has(e)||mt.some(o=>e.endsWith(o))?!0:t.createable===!1&&e!==oe.toLowerCase()}function Ot(t,e){return t.objectApiName<e.objectApiName?-1:t.objectApiName>e.objectApiName?1:0}function yt(t,e,o,r={}){let n=Ne(t,{mode:"everything",access:gt[o],...r.excluded!==void 0?{excluded:r.excluded}:{},...r.customSettings!==void 0?{customSettings:r.customSettings}:{}},e),c=new Map(t.map(u=>[u.name.toLowerCase(),u])),a=[],d=[];for(let u of n.candidates){let m=c.get(u.toLowerCase());m!==void 0&&bt(m)?d.push({objectApiName:u,reason:"configuration"}):a.push(u)}return d.length===0?n:{...n,candidates:a,leftOut:[...n.leftOut,...d].sort(Ot)}}var wt=new Set([oe,Pe].map(t=>t.toLowerCase())),Qe="withTheirRecords",Ct="noLayout";function Et(t){switch(t){case"configuration":return{reason:"setup"};case"chatter":case"history":case"sharing":case"changeEvent":case"unsupportedKind":case"customSetting":case"files":case"setup":case"platformCreated":case"metadata":case"notWritable":case"excludedByUser":return{reason:t};case"heldWithFiles":return{reason:"files",detail:Qe};case"notFound":case"notCustomSetting":return{reason:"missingInTarget"}}}function Rt(t){switch(t){case"platform":return{reason:"platformCreated"};case"setup":return{reason:"setup"};case"feature":case"parent":return{reason:"notWritable",detail:t};case"user":return{reason:"notWritable"}}}function St(t){if(t.createable!==!0||t.queryable!==!0)return;let e=t.updateable===!0,o=t.deletable===!0;if(!(e&&o))return!e&&!o?{reason:"createOnly"}:{reason:"createOnly",detail:e?Ft:It}}var It="noEdit",Ft="noDelete";function vt(t,e){return t.objectApiName<e.objectApiName?-1:t.objectApiName>e.objectApiName?1:0}function He(t,e,o,r={}){let n=yt(e,o,"clone",r),c=new Map(t.map(i=>[i.name.toLowerCase(),i])),a=new Map(e.map(i=>[i.name.toLowerCase(),i])),d=[],u=[],m=new Set,R=(i,h,b)=>{m.add(i.toLowerCase()),u.push({objectApiName:i,reason:h,...b!==void 0?{detail:b}:{}})};for(let i of t)a.has(i.name.toLowerCase())||R(i.name,"missingInTarget");for(let i of n.leftOut){let h=i.objectApiName.toLowerCase(),b=c.get(h);if(!b||m.has(h))continue;let S=a.get(h),y=Et(i.reason),C=h!==oe.toLowerCase();y.reason==="notWritable"&&C&&S?.createable!==!0&&r.createFacts&&(y=Rt(We(b.name,r.createFacts))),y.reason==="notWritable"&&C&&S&&(y=St(S)??y);let I=i.reason==="setup"&&S?.layoutable===!1&&!Ae(i.objectApiName);R(b.name,y.reason,I?Ct:y.detail??i.detail)}for(let i of n.candidates){let h=i.toLowerCase(),b=c.get(h);b&&(b.queryable!==!0?R(b.name,"notQueryable"):wt.has(h)?R(b.name,"files",Qe):d.push(b.name))}return d.sort(),u.sort(vt),{candidates:d,leftOut:u}}var he=1950,Xe=2e4,jt=1e6,Dt=18,Tt=200,At=new Set(["QUERY_TIMEOUT","OPERATION_TOO_LARGE","REQUEST_LIMIT_EXCEEDED","REQUEST_RUNNING_TOO_LONG","SERVER_UNAVAILABLE","UNKNOWN_EXCEPTION"]);function se(t){if(t instanceof Me||De(t))return!1;let e=je(x(t));return e===void 0?!1:!At.has(e)&&!e.startsWith("ERROR_HTTP_")}function Pt(t,e){let o=fe.has(t),r=[...e?[`(${e})`]:[],...o?["IsDeleted = false"]:[]];return{soql:`SELECT COUNT() FROM ${q(t)}${r.length>0?` WHERE ${r.join(" AND ")}`:""}`,all:o}}async function Ve(t,e){let o=0,r=!1,n=()=>r,c=async()=>{for(;!r&&o<t.length;){let a=o++;try{await e(t[a],a,n)}catch(d){throw r=!0,d}}};await Promise.all(Array.from({length:Math.min(6,t.length)},c))}async function Nt(t,e){try{return await t()}catch(o){if(o instanceof A||re(o)||se(o))throw o;return k.warn(`[forge-discover] whole org: describe of ${e} unanswered, asked again: ${x(o)}`),t()}}function Ye(t){if(!(t<=ue))throw new Error(`The source org lists ${t} objects a clone of the whole org leaves out, more than the ${ue} one graph says. Nothing was written. Clone the org in parts instead: a run from a record or from a query for each part.`)}var xt=de({name:Ce().min(1),count:Ee().int().nonnegative()});function Mt(t){let e=de({sObjects:Se(Re())}).safeParse(t);if(!e.success)return;let o=new Map;for(let r of e.data.sObjects){let n=xt.safeParse(r);n.success&&o.set(n.data.name,n.data.count)}return o}function _t(t){let e=new Map;for(let[o,r]of t)for(let n of r.fields){if(n.referenceTo.length===0)continue;let c=ee(n),a=c&&Z(o,n.name,n.nillable),d=te(n);for(let u of n.referenceTo){if(u===o||!t.has(u))continue;let m=`${u}|${o}`,R={sourceObject:u,targetObject:o,relationshipName:n.relationshipName??n.name,type:ne(o,n,t.get(u)?.childRelationships)?"master-detail":"lookup",required:a},i=e.get(m);if(!i){e.set(m,{edge:R,noneSettable:!c,insertOnly:d});continue}let h=R.type==="master-detail"&&i.edge.type==="lookup"?R:i.edge;i.edge={...h,required:i.edge.required===!0||a},i.noneSettable=i.noneSettable&&!c,i.insertOnly=i.insertOnly||d}}return[...e.values()].map(({edge:o,noneSettable:r,insertOnly:n})=>({...o,...r?{settable:!1}:{},...n?{insertOnly:!0}:{}}))}function Lt(t,e){let o=e.filter(qe),r=$e(t,o).reverse(),n=new Map;r.forEach((d,u)=>{for(let m of d)n.set(m,u)});let c=new Map;for(let d of o){let u=c.get(d.targetObject)??[];u.push(d.sourceObject),c.set(d.targetObject,u)}let a=r.map(()=>0);return r.forEach((d,u)=>{for(let m of d)for(let R of c.get(m)??[]){let i=n.get(R);i!==void 0&&i!==u&&(a[u]=Math.max(a[u],a[i]+1))}}),new Map(t.map(d=>[d,Math.min(Dt,1+a[n.get(d)??0])]))}async function ze(t,e,o){let r=ve(e);if(r!==void 0)throw new Error(r);let n=o?.signal;if(n?.aborted)return Y();try{return await kt(t,e,o)}catch(c){if(c instanceof A||n?.aborted)return Y();throw c}}async function kt(t,e,o){let r=o?.signal,n=s=>o?.onProgress?.(s),c=Date.now(),a=s=>l=>{if(l instanceof A)throw l;return k.warn(`[forge-discover] whole org: ${x(l)}`),s},{toolingObjects:d,recordCounts:u,createFacts:m}=t;n({phase:"listing",discoveredCount:0,queueRemaining:0});let[R,i,h,b,S]=await Promise.all([M(()=>t.describeGlobal(e.sourceOrgId,r),r),M(()=>t.describeGlobal(e.targetOrgId,r),r),d?M(()=>d(e.targetOrgId,r),r).catch(a([])):Promise.resolve([]),m?M(()=>m(e.targetOrgId),r).catch(a(void 0)):Promise.resolve(void 0),u?M(()=>u(e.sourceOrgId,r),r).catch(a(void 0)):Promise.resolve(void 0)]),y=Mt(S),C=e.excludedObjects??[],{candidates:I,leftOut:$}=He(R,i,h,{...b?{createFacts:b}:{},...C.length>0?{excluded:C}:{}}),N=[...$];Ye(N.length);let L=I.map(()=>{}),W=0;n({phase:"counting",discoveredCount:0,queueRemaining:I.length,total:I.length}),await Ve(I,async(s,l,p)=>{let f=y?.get(s),v=e.objectSoqlFilters?.[s];if(f!==void 0&&f>jt&&!v)L[l]={objectApiName:s,rows:f,approximate:!0};else try{let{soql:E,all:Q}=Pt(s,v),_=await M(()=>t.queryCount(e.sourceOrgId,E,r,Q?{all:!0}:void 0),r);if(p())return;_>0?L[l]={objectApiName:s,rows:_}:N.push({objectApiName:s,reason:"empty"})}catch(E){if(E instanceof A||re(E))throw E;if(p())return;se(E)?N.push({objectApiName:s,reason:"unreadable",detail:x(E)}):(k.warn(`[forge-discover] whole org: ${s} not counted, kept: ${x(E)}`),L[l]=f!==void 0&&f>0&&!v?{objectApiName:s,rows:f,approximate:!0}:{objectApiName:s,rows:0,unknown:!0})}W++,n({phase:"counting",objectApiName:s,discoveredCount:W,queueRemaining:I.length-W,total:I.length})});let D=L.filter(s=>s!==void 0);if(D.length>he)throw new Error(`The source org holds records in ${D.length} objects a clone of the whole org would take, more than the ${he} one run writes. Nothing was written. Leave ${D.length-he} of them out or more, or clone the org in parts instead: a run from a record or from a query for each part.`);let U=D.map(()=>{}),B=0;n({phase:"describing",discoveredCount:0,queueRemaining:D.length,total:D.length}),await Ve(D,async({objectApiName:s},l,p)=>{try{let f=await Nt(()=>M(()=>t.describeObject(e.sourceOrgId,s,r),r),s);if(p())return;U[l]=f}catch(f){if(f instanceof A||re(f))throw f;if(p())return;N.push({objectApiName:s,reason:"notDescribed",detail:x(f)})}B++,n({phase:"describing",objectApiName:s,discoveredCount:B,queueRemaining:D.length-B,total:D.length})}),await me();let w=new Map,z=new Map;D.forEach((s,l)=>{let p=U[l];p&&(w.set(s.objectApiName,p),z.set(s.objectApiName,s))});let G=_t(w);if(G.length>Xe)throw new Error(`The ${w.size} objects of the source org a clone of the whole org would take relate ${G.length} pairs of objects, more than the ${Xe} one run writes in order. Nothing was written. Clone the org in parts instead: a run from a record or from a query for each part.`);let g=[...w.keys()],j=Lt(g,G),P=g.map(s=>{let l=w.get(s),p=z.get(s),f=p.rows,v=t.detectPII(l.fields);return{objectApiName:s,...l.label?{label:l.label}:{},recordCount:f,...p.approximate?{recordCountApproximate:!0}:{},...p.unknown?{recordCountUnknown:!0}:{},fieldCount:l.fields.length,status:"idle",progress:0,included:!0,piiFields:v,anonymizeFields:e.anonymizePII?[...v]:[],level:j.get(s)??1,successCount:0,failureCount:0,errors:[],createableFieldCount:l.fields.filter(E=>E.type!=="id").length,estimatedSizeMB:f*V,estimatedApiCalls:Math.ceil(f/Tt),batchStrategy:"auto"}});Ye(N.length);let F=P.reduce((s,l)=>s+l.recordCount,0);return N.sort((s,l)=>s.objectApiName<l.objectApiName?-1:s.objectApiName>l.objectApiName?1:0),k.info(`[forge-discover] whole org: ${P.length} object(s), ${G.length} relation(s), ${N.length} left out, ${F} record(s), in ${Date.now()-c}ms`),{nodes:P,edges:G,totalRecords:F,estimatedSizeMB:F*V,estimatedDurationSeconds:F*ge,truncated:!1,leftOut:N}}export{fe as a,ot as b,zt as c,ne as d,st as e,it as f,at as g,lt as h,ut as i,Ue as j,yt as k,he as l,Xe as m,se as n,Ve as o,Mt as p,ze as q};
|