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
|
@@ -4,5 +4,5 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{b as te}from"./chunk-O677VOGO.mjs";import{c as nt,d as ot}from"./chunk-JE6SCT6R.mjs";import{i as et,k as tt}from"./chunk-PWRJRL5U.mjs";import{a as st,b as it,c as rt,d as at,e as ct,f as dt,h as lt}from"./chunk-24RFOFYT.mjs";import{d as He,j as Ke}from"./chunk-UIOMAX56.mjs";import{c as Oe,d as Ce,p as Ge}from"./chunk-KJWFYBMU.mjs";import{a as Te}from"./chunk-Z4LKKOFY.mjs";import{h as ze,i as Ve}from"./chunk-L53JWJ3S.mjs";import{B as q,C as _e,E as Ue,u as Be,v as We}from"./chunk-VINGECAJ.mjs";import{A as qe,B as x,D as ee,G as Ze,b as je,f as Re,h as Ne,i as Q,j as X,k as Fe,n as Le,o as Ie,r as xe,t as Z,u as Je,v as Qe,w as Xe,z as Ye}from"./chunk-FP7CYB2F.mjs";import{A as ve,B as I,H as Ee,K as $e,a as De,e as Me,o as Y,z as Pe}from"./chunk-KGU4SVIT.mjs";import{f as H}from"./chunk-W6PN6TJG.mjs";import{E as Se}from"./chunk-YA6ATMTB.mjs";import{f as be,g as ke,h as L,m as we,n as ye,o as K,t as Ae,u as J}from"./chunk-M6K34KGF.mjs";import{b as v}from"./chunk-CA5NAXSU.mjs";import{Uc as F,Va as me,Wa as $,Za as ge,ye as he}from"./chunk-PMWAFDUB.mjs";import{b as pe,k as fe,l as V}from"./chunk-WZQEK4WT.mjs";import{readdir as It,rm as gt,stat as ht}from"node:fs/promises";import{existsSync as xt,readFileSync as Bt,writeFileSync as Wt}from"node:fs";import{hostname as _t}from"node:os";import{join as oe}from"node:path";var Gt=5e5,B=1e6,Ut=100,zt="taking",ut=500;function Xn(e){let t=Ne(e),n=[H(e)];return{get version(){return e.version},request:o=>t.request(o),query:(o,s)=>t.query(o,s),queryMore:o=>t.queryMore(o),describeGlobal:async()=>await e.describeGlobal(),toolingObjects:async()=>{try{return(await e.tooling.describeGlobal()).sobjects.map(s=>s.name)}catch{return[]}},serverTime:async()=>(await e.soap.getServerTimestamp()).timestamp,userId:async()=>(await e.soap.getUserInfo()).userId,requestsSent:()=>n.reduce((o,s)=>o+s(),0),countAlso:o=>{n.push(H(o))}}}function Vt(e){return Fe(ze(e))}var D=class extends Error{constructor(){super("The checkpoint was stopped before it was taken: nothing of it was kept."),this.name="CheckpointTakeStopped"}},W="No record was read.",Ht={excludedByUser:"Left out as asked.",notFound:"The org has no object of this name.",chatter:"Chatter posts, comments and feeds are left out: Salesforce brings a post back only with what it was posted on.",history:"History is left out: it is the org's own trace of changes.",sharing:"Sharing is left out: the org keeps it itself.",changeEvent:"Change events are left out.",unsupportedKind:"Left out: neither the recycle bin nor an update reaches this kind of object as it reaches a record.",customSetting:"Custom settings are left out unless you pick them as custom settings: they are configuration, which a rewind sets back.",notCustomSetting:"Picked as a custom setting: the org has no custom setting of this name.",files:"Documents of the Documents tab are left out: they are shared content kept in folders, as setup is.",heldWithFiles:"Held with its file (ContentDocument): Salesforce neither deletes nor brings back a file's version on its own, and reads the links of a file through the records they tie it to.",setup:"Users, permissions and setup are left out, and so are the org's own logs and jobs.",platformCreated:"Left out: Salesforce alone creates its records, such as approvals, Einstein insights, Data.com clean info and invoices, and no permission lets a user create one.",metadata:"Left out: it is metadata, which a checkpoint doesn't hold.",notWritable:"Left out: the user SandForge connects as may not create, edit and delete its records.",notDescribed:"Left out: the org would not describe it.",noSystemModstamp:"Left out: it has no SystemModstamp, so nothing would tell a record changed since.",noRecycleBin:"Left out: the org deletes its records for good, with no recycle bin, so nothing would tell one deleted since, nor bring it back.",unreadable:"Left out: the org refuses to read it whole.",noViewAll:"Without View All Data and Modify All Data, an object is held only with View All and Modify All on it, and the user SandForge connects as has neither on this one: a record they cannot see would read as deleted since.",noModifyAll:"Without View All Data and Modify All Data, an object is held only with View All and Modify All on it, and the user SandForge connects as has View All on this one, not Modify All: a rewind could not put back what others changed.",activities:"Without View All Data and Modify All Data, tasks and events are left out: Salesforce has no View All for activities, and a private one linked to no record stays out of sight.",catalog:"Without View All Data and Modify All Data, products and price books are left out: Salesforce has no View All or Modify All for them.",filesNotProven:"Without View All Data and Modify All Data, files are left out: nothing proves the user sees every file.",settingNotProven:"Without View All Data and Modify All Data, custom settings are left out: no permission on an object proves the user sees and writes every row.",parentNotSeen:"Without View All Data and Modify All Data, an object with no permissions of its own is held only when the user has View All and Modify All on every record it hangs from, which is not proven here."};function bt(e){let t=Ht[e.reason],n=e.detail===void 0?t:`${t.replace(/\.$/,"")} (${e.detail}).`;return{objectApiName:e.objectApiName,code:e.reason,reason:pt(n),...e.detail===void 0?{}:{detail:pt(e.detail)}}}function Kt(e,t,n){return{objectApiName:e,code:"pastTheLimit",records:t,limit:n,reason:t>B?`${e} has ${t} records, more than any checkpoint holds of one object (${B}): left out of the checkpoint, and a rewind to it does not touch ${e}. Data Export, in Setup, or a Bulk API query keeps a copy of it.`:`${e} has ${t} records, past the checkpoint's limit of ${n} for one object: left out of the checkpoint, as part of it would be taken for all of it.`}}function Jt(e,t){let n=t;for(;;){let o=e.filter(s=>s<=Math.min(n,B)).reduce((s,r)=>s+r,0);if(o<=n)return n;n=o}}function pt(e){return e.length<=ut?e:`${e.slice(0,ut-1)}\u2026`}function kt(e,t){return{code:"RUN_WRITING",message:`${t.operation==="take"?`A checkpoint of ${e} is being taken`:t.operation==="rewind"?`A rewind is writing to ${e}`:t.operation==="undo"?`An undo is writing to ${e}`:t.operation==="empty"?`An emptying of its objects is writing to ${e}`:`SandForge is deleting checkpoints of ${e}`} (process ${t.pid} on ${t.host}): take the checkpoint once it has ended. ${W}`}}function wt(e){return typeof e!="object"||e===null?void 0:typeof e.errorCode=="string"?v(e):void 0}function _(e,t){return e instanceof Q||e instanceof Te||e instanceof D||t?.aborted===!0}var Qt=V({sobjects:fe(be)}).loose();function M(e){return e.toLowerCase()===ke.toLowerCase()}function Xt(e,t,n){if(e===void 0)return{why:`the org lists no ${L}`};let o=t.get(e);if(o===void 0)return{why:n.get(e)??"it was not described"};let r=o.fields.find(d=>d.name.toLowerCase()==="linkedentityid")?.referenceTo??[];return r.length===0?{why:"its describe names no record a link ties a file to"}:{linkable:new Set(r.map(d=>d.toLowerCase()))}}async function se(e,t,n){let o=new Map,s=new Map,r=0,d=await Promise.allSettled(n.map(p=>t.describe(p)));for(let[p,i]of d.entries()){let c=n[p],l;if(i.status==="fulfilled"&&"body"in i.value)l=i.value.body;else{if(i.status==="rejected"&&i.reason instanceof Q)throw i.reason;r++;try{l=await e.request({method:"GET",url:`/services/data/v${e.version}/sobjects/${F(c)}/describe`})}catch(h){let a=wt(h);if(a===void 0)throw new Error(`The org did not answer the describe of ${c}: ${v(h)}`);s.set(c,a);continue}}let u=He.safeParse(l);u.success?o.set(c,u.data):s.set(c,"its describe does not read as one")}return{describes:o,errors:s,alone:r}}async function yt(e,t,n){let o=Qt.parse(await e.describeGlobal()),s=await e.toolingObjects?.()??[],r=ye(o.sobjects,{mode:n.mode,...n.objects?{objects:n.objects}:{},...n.excluded?{excluded:n.excluded}:{},...n.customSettings?{customSettings:n.customSettings}:{}},s),d=r.candidates.some(M),p=d?o.sobjects.find(m=>m.name.toLowerCase()===L.toLowerCase())?.name:void 0,i=p===void 0?r.candidates:[...r.candidates,p],{describes:c,errors:l,alone:u}=await se(e,t,i),h,a;if(d){let m=Xt(p,c,l);"linkable"in m?h=m.linkable:a=m.why,p!==void 0&&c.delete(p)}let g=Ae(r,c,l);if(a!==void 0){let m=g.objects.find(({objectApiName:C})=>M(C));m!==void 0&&(g=J(g,new Map([[m.objectApiName,`its links to records, ${L}, could not be described: ${a}`]])))}let w=await je(async m=>(await e.query(m)).records),A=new Map(o.sobjects.map(m=>[m.name,ft(m)])),S=o.sobjects.filter(we),f=new Set(S.map(m=>m.name)),k=[...c.values()],y=[];for(let m of g.objects){let C=c.get(m.objectApiName);C&&y.push({scoped:m,label:A.get(m.objectApiName)??m.objectApiName,describe:C,capture:await Ke(C,k,{viewsEncryptedData:w}),...f.has(m.objectApiName)?{customSetting:K(C)}:{}})}return{described:i.length,describedAlone:u,objects:y,leftOut:g.leftOut,addedToPicked:r.addedToPicked,...h!==void 0&&y.some(({scoped:m})=>M(m.objectApiName))?{linkable:h}:{},settings:S.map(m=>({objectApiName:m.name,label:ft(m)}))}}function ft(e){let t=e.label;return typeof t=="string"&&t!==""?t:e.name}async function Yt(e,t,n,o){let s=await ee(t,n.map(({capture:i})=>({objectApiName:i.objectApiName,readMode:i.readMode})),o),r=new Map,d=new Map,p=0;for(let[i,c]of s.entries()){let{objectApiName:l,readMode:u}=n[i].capture;if("count"in c){r.set(l,c.count);continue}p++;let h=Qe(l,u);try{let a=await e.query(h.soql,{scanAll:h.scanAll});if(typeof a.totalSize!="number")throw new Error("The org gave no count of its records.");r.set(l,a.totalSize)}catch(a){let g=wt(a);if(g===void 0)throw new Error(`The org did not count the records of ${l}: ${v(a)}`);d.set(l,g)}}return{counts:r,refused:d,alone:p}}function At(e,t){return t?.has(e.toLowerCase())===!0&&!M(e)}async function qt(e,t,n,o,s){let r=[];for(let{objectApiName:i,records:c}of t){let l=F(i);r.push({objectApiName:l,soql:`SELECT COUNT() FROM ${l} WHERE IsDeleted = true AND SystemModstamp < ${Z(o)}`,scanAll:!0,counts:"inBin"}),c!==0&&(r.push({objectApiName:l,soql:`SELECT COUNT() FROM ${l} WHERE SystemModstamp >= ${Je(o)}`,scanAll:!0,counts:"stampedSince"}),At(l,n)&&r.push({...et(l),counts:"links"}))}let d=await Ye(e,r,()=>{},s),p=new Map;return d.forEach((i,c)=>{let{objectApiName:l,counts:u}=r[c],h=i.read?i.totalSize:void 0,a=p.get(l)??{};u==="links"?a.links=h??null:h!==void 0&&(a[u]=h),p.set(l,a)}),{asked:r.length,of:p}}function St({scoped:e,capture:t,customSetting:n,access:o},s,r,d){return{objectApiName:e.objectApiName,records:s,inBin:r,readOrder:e.readOrder,readMode:t.readMode,undeletable:t.undeletable,cascadeParents:t.cascadeParents,restrictParents:t.restrictParents,fingerprint:d,fields:t.fields,leftOutFields:t.leftOutFields,...n!==void 0?{customSetting:n}:{},...o!==void 0?{access:o}:{}}}function Ot(e){return{personAccounts:rt(e.map(({describe:t})=>t)),catalog:at(e.map(({scoped:t})=>t.objectApiName))}}function Zt(e){let t=e?.orgType==="Sandbox"||e?.orgType==="Scratch";return Oe(Ce(t)).defaultQueryLimit}async function Ct(e,t,n,o,s,r,d,p=Tt){let i=n.maxTotal??Gt;if(!Number.isInteger(i)||i<1)throw new RangeError(`Not a number of records: ${i}`);let c=Math.min(i,B),{counts:l,refused:u,alone:h}=await Yt(e,t,o.objects,d),a=J({mode:n.mode,objects:o.objects.map(({scoped:b})=>b),leftOut:o.leftOut,packages:[]},u),g=new Map(o.objects.map(b=>[b.scoped.objectApiName,b])),w=a.leftOut.map(bt),A=[];for(let b of a.objects){let O=g.get(b.objectApiName),P=l.get(b.objectApiName);if(!(O===void 0||P===void 0)){if(P>c){w.push(Kt(b.objectApiName,P,c));continue}A.push({...O,scoped:{...b,readOrder:A.length},records:P,otherGroups:Be(b.objectApiName,O.capture.fields,O.capture.readMode),recount:{}})}}let S=A.some(({scoped:b})=>M(b.objectApiName))?o.linkable:void 0,f=await qt(t,A.map(({scoped:b,records:O})=>({objectApiName:b.objectApiName,records:O})),S,r,d);for(let b of A)b.recount=f.of.get(b.scoped.objectApiName)??{};w.sort((b,O)=>b.objectApiName<O.objectApiName?-1:b.objectApiName>O.objectApiName?1:0);let k={};for(let{scoped:b,describe:O}of A)k[b.objectApiName]=De(O.fields);let y=en(p,We({described:o.described,describedAlone:o.describedAlone,counted:o.objects.length,countedAlone:h,recounted:f.asked,objects:A.map(b=>({records:b.records,otherGroups:b.otherGroups,...b.recount,entry:St(b,b.records,0,k[b.scoped.objectApiName].digest)})),pageRows:Zt(n.registered),leftOut:w,printsBytes:(await $e(k)).length,annexCalls:ct(Ot(A))})),m={...y,apiRequestsLeft:s.remaining},C={objects:A,leftOut:w,estimate:m,objectLimit:c,prints:k,...S!==void 0?{linkable:S}:{}};if(y.records>i){let b=[...A.map(O=>O.records),...w.flatMap(O=>O.code==="pastTheLimit"?[O.records??0]:[])];return{...C,refusal:{code:"TOO_MANY_RECORDS",message:`The objects this checkpoint would keep hold ${y.records} records in ${n.orgName}, past its limit of ${i}: pick fewer objects. ${W}`,holdingLimit:Jt(b,y.records)}}}let R=_e("take",y.apiRequests,s,n.orgName);return R===void 0?C:{...C,refusal:R}}function jt(e){return{query:t=>e.query(t),queryMore:t=>e.queryMore(t)}}var Tt={guard:0,scope:0};function en(e,t){if(e.guard+e.scope===0)return t;let n=t.requestsByPhase;return{...t,apiRequests:t.apiRequests+e.guard+e.scope,...n!==void 0?{requestsByPhase:{...n,guard:n.guard+e.guard,scope:n.scope+e.scope}}:{}}}function tn(e){let t=[...e.mode==="picked"?e.objects??[]:[],...Array.isArray(e.customSettings)?e.customSettings:[]];return new Set(t.map(n=>n.toLowerCase()))}function nn(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}async function Rt(e,t,n,o,s,r){if(s.kind==="org")return{scope:{...o,objects:o.objects.map(f=>({...f,access:"org"}))},reads:Tt};let d=o.objects.map(({scoped:f})=>f.objectApiName),p={grants:s.objects,describes:o.objects.map(({describe:f})=>f),customSettings:o.objects.filter(({customSetting:f})=>f!==void 0).map(({scoped:f})=>f.objectApiName)},i=nt(d,p),c=[],l=0;if(i.length>0)try{let f=await se(e,t,i);c=[...f.describes.values()],l=Math.ceil(i.length/Re)+f.alone}catch(f){if(_(f,r))throw f}let u=ot(d,{...p,describes:[...p.describes,...c]}),h=tn(n),a=[],g=[...o.leftOut],w=[];for(let f of o.objects){let k=f.scoped.objectApiName,y=u.get(k);if(y!==void 0&&"access"in y){a.push({...f,access:y.access});continue}let m={objectApiName:k,reason:y?.reason??"noViewAll",...y?.detail!==void 0?{detail:y.detail}:{}};g.push(m),h.has(k.toLowerCase())&&n.unprovenLeftOut!==!0&&w.push(m)}let A=new Set(a.map(({scoped:f})=>f.objectApiName)),S={scope:{...o,objects:a,leftOut:g,addedToPicked:o.addedToPicked.filter(f=>A.has(f))},reads:{guard:s.requests,scope:l}};if(w.length>0){let f=w.length===1;return{...S,refusal:{code:"PERMISSIONS",message:`${n.username} doesn't have View All Data and Modify All Data, and the checkpoint can't hold ${nn(w.map(k=>k.objectApiName))}, asked for by name. ${w.map(k=>`${k.objectApiName}: ${bt(k).reason}`).join(" ")} Leave ${f?"it":"them"} out, or give the user View All Data and Modify All Data. ${W}`}}}return a.length===0&&o.objects.length>0?{...S,refusal:{code:"PERMISSIONS",message:`${n.username} doesn't have View All Data and Modify All Data, nor View All and Modify All on any object this checkpoint would hold: without them, a checkpoint holds only the objects its user sees and puts back whole. Give the user View All and Modify All on the objects to hold, or View All Data and Modify All Data. `+W}}:S}function on(e){return e.objects.map(({scoped:t,label:n,capture:o,records:s,customSetting:r,access:d})=>({objectApiName:t.objectApiName,label:n,...t.namespace!==void 0?{namespace:t.namespace}:{},records:s,undeletable:o.undeletable,leftOutFields:o.leftOutFields,...r!==void 0?{customSetting:r}:{},...d!==void 0?{access:d}:{}}))}function Nt(e){let t=e.customSettings;return t!==void 0&&(t==="all"||t.length>0)}async function sn(e,t,n,o,s){let r=new Map(o.objects.map(u=>[u.scoped.objectApiName,u])),d=n.settings.filter(({objectApiName:u})=>!r.has(u)),p=new Map;if(d.length>0)try{({describes:p}=await se(e,t,d.map(({objectApiName:u})=>u)))}catch(u){if(_(u,s))throw u}let i=d.filter(({objectApiName:u})=>p.has(u)),c=await ee(t,i.map(({objectApiName:u})=>({objectApiName:u,readMode:"query"})),s),l=new Map;return c.forEach((u,h)=>{"count"in u&&l.set(i[h].objectApiName,u.count)}),n.settings.map(({objectApiName:u,label:h})=>{let a=r.get(u);if(a?.customSetting!==void 0)return{objectApiName:u,label:h,kind:a.customSetting,records:a.records};let g=p.get(u),w=l.get(u);return{objectApiName:u,label:h,...g!==void 0?{kind:K(g)}:{},...w!==void 0?{records:w}:{}}})}var rn={records:0,apiRequests:0,apiRequestsLeft:0,seconds:0,bytes:0};async function Yn(e,t){let n={mode:t.mode,objects:[],leftOut:[],estimate:rn},o=await te(jt(e.org),{act:"take",orgName:t.orgName,registered:t.registered,username:t.username,customSettings:Nt(t)},{userId:()=>e.org.userId()});if(!o.allowed)return{...n,refusal:o.refusal};let s=e.store.heldBy(o.org.id),r=s===void 0?await e.runWriting?.(o.org.id):void 0,d=X(e.org,e.signal);try{let p=await q(e.org,t.orgName),i=await Rt(e.org,d,t,await yt(e.org,d,t),o.grants,e.signal),{scope:c}=i,l=await e.org.serverTime(),u=await Ct(e.org,d,t,c,p,l,e.signal,i.reads),h={mode:t.mode,objects:on(u),leftOut:u.leftOut,estimate:u.estimate,files:{held:u.objects.some(({scoped:g})=>M(g.objectApiName)),queryAllFiles:o.queryAllFiles,addedToPicked:c.addedToPicked},customSettings:await sn(e.org,d,c,u,e.signal)},a=s!==void 0?kt(t.orgName,s):r!==void 0?{code:"RUN_WRITING",message:r}:i.refusal??u.refusal;return a===void 0?h:{...h,refusal:a}}catch(p){throw _(p,e.signal)?new D:p}}function an(e){let t=e.requestsSent?()=>e.requestsSent?.()??0:void 0,n={guard:0,scope:0,start:0,counts:0,bin:0,snapshot:0,stability:0},o="guard",s=t?.()??0,r=()=>{if(!t)return;let d=t();n[o]+=d-s,s=d};return{enter(d){r(),o=d},requests(){return t?(r(),{total:Object.values(n).reduce((p,i)=>p+i,0),byPhase:{...n}}):void 0}}}async function cn(e,t){if(t.edition!==void 0)return t.edition;let o=(await e.query("SELECT OrganizationType FROM Organization LIMIT 1")).records[0]?.OrganizationType;if(typeof o!="string"||o==="")throw new Error("The org did not say its edition (Organization.OrganizationType).");return o}var dn="Automated Process";async function ln(e){let n=(await e.query("SELECT Id, Name FROM User WHERE UserType = 'AutomatedProcess'")).records.filter(s=>typeof s.Id=="string"),o=n.find(s=>s.Name===dn);return o!==void 0?o.Id:n.length===1?n[0].Id:void 0}function Dt(e){let t=new Date(Date.parse(e)).toISOString();return`${t.slice(0,10)} ${t.slice(11,16)} UTC`}function mt(e,t){return e.split(he).join(Dt(t))}function ne(e){let t=Se(e);return t===null?Number.NaN:Date.parse(t)}function Mt(e){return typeof e=="string"&&e.length>=15?e.slice(0,15):void 0}async function un(e,t){let n=new Set;for await(let o of x(Y(e,t))){let s=Mt(o.Id);s!==void 0&&n.add(s)}return n}async function pn(e,t,n,o,s,r){let d={changed:0,deleted:0,created:0};if(!o.live&&!o.deleted)return d;let p=await xe.read(e,t,n);if(o.live)for await(let i of x(o.live.file)){let c=ne(i.SystemModstamp);if(!(c<=r))continue;let l=p.stampOf(i.Id);l===void 0?d.created++:l!==c&&d.changed++}if(o.deleted){let i;for await(let c of x(o.deleted.file)){if(!(ne(c.SystemModstamp)<=r))continue;if(p.has(c.Id)){d.deleted++;continue}if(!(ne(c.CreatedDate)<s))continue;i??=await un(e,n);let l=Mt(c.Id);l!==void 0&&!i.has(l)&&d.deleted++}}return d}async function Pt(e){let t=0;for(let n of await It(e,{withFileTypes:!0})){let o=oe(e,n.name);n.isDirectory()?t+=await Pt(o):n.isFile()&&(t+=(await ht(o)).size)}return t}async function fn(e,t){let n=await Pt(e.dir)-(await ht(e.checkpointFile)).size,o=r=>Buffer.byteLength(`${JSON.stringify({...t,bytes:r},null,2)}
|
|
7
|
+
import{b as te}from"./chunk-BLMJ4WVI.mjs";import{c as nt,d as ot}from"./chunk-4NSXPONF.mjs";import{i as et,k as tt}from"./chunk-XBYXT74L.mjs";import{a as st,b as it,c as rt,d as at,e as ct,f as dt,h as lt}from"./chunk-2YJJTQNC.mjs";import{d as He,j as Ke}from"./chunk-4VLP6RHC.mjs";import{H as Ge,e as Oe,f as Ce}from"./chunk-YTOTMJTY.mjs";import{a as Te}from"./chunk-WJGK6VGU.mjs";import{h as ze,i as Ve}from"./chunk-VKREON6Q.mjs";import{F as q,G as _e,I as Ue,y as Be,z as We}from"./chunk-7O6EFNQS.mjs";import{A as qe,B as x,D as ee,G as Ze,b as je,f as Re,h as Ne,i as Q,j as X,k as Fe,n as Le,o as Ie,r as xe,t as Z,u as Je,v as Qe,w as Xe,z as Ye}from"./chunk-DLSU66MY.mjs";import{A as ve,B as I,H as Ee,K as $e,a as De,e as Me,o as Y,z as Pe}from"./chunk-4CSBZZAL.mjs";import{f as H}from"./chunk-65AMXOQU.mjs";import{E as Se}from"./chunk-4XROG5CT.mjs";import{f as be,g as ke,h as L,m as we,n as ye,o as K,t as Ae,u as J}from"./chunk-DAUX63UB.mjs";import{b as v}from"./chunk-CA5NAXSU.mjs";import{$c as F,Ne as he,Ya as me,Za as $,ab as ge}from"./chunk-J347SPU6.mjs";import{b as pe,k as fe,l as V}from"./chunk-WZQEK4WT.mjs";import{readdir as It,rm as gt,stat as ht}from"node:fs/promises";import{existsSync as xt,readFileSync as Bt,writeFileSync as Wt}from"node:fs";import{hostname as _t}from"node:os";import{join as oe}from"node:path";var Gt=5e5,B=1e6,Ut=100,zt="taking",ut=500;function Xn(e){let t=Ne(e),n=[H(e)];return{get version(){return e.version},request:o=>t.request(o),query:(o,s)=>t.query(o,s),queryMore:o=>t.queryMore(o),describeGlobal:async()=>await e.describeGlobal(),toolingObjects:async()=>{try{return(await e.tooling.describeGlobal()).sobjects.map(s=>s.name)}catch{return[]}},serverTime:async()=>(await e.soap.getServerTimestamp()).timestamp,userId:async()=>(await e.soap.getUserInfo()).userId,requestsSent:()=>n.reduce((o,s)=>o+s(),0),countAlso:o=>{n.push(H(o))}}}function Vt(e){return Fe(ze(e))}var D=class extends Error{constructor(){super("The checkpoint was stopped before it was taken: nothing of it was kept."),this.name="CheckpointTakeStopped"}},W="No record was read.",Ht={excludedByUser:"Left out as asked.",notFound:"The org has no object of this name.",chatter:"Chatter posts, comments and feeds are left out: Salesforce brings a post back only with what it was posted on.",history:"History is left out: it is the org's own trace of changes.",sharing:"Sharing is left out: the org keeps it itself.",changeEvent:"Change events are left out.",unsupportedKind:"Left out: neither the recycle bin nor an update reaches this kind of object as it reaches a record.",customSetting:"Custom settings are left out unless you pick them as custom settings: they are configuration, which a rewind sets back.",notCustomSetting:"Picked as a custom setting: the org has no custom setting of this name.",files:"Documents of the Documents tab are left out: they are shared content kept in folders, as setup is.",heldWithFiles:"Held with its file (ContentDocument): Salesforce neither deletes nor brings back a file's version on its own, and reads the links of a file through the records they tie it to.",setup:"Users, permissions and setup are left out, and so are the org's own logs and jobs.",platformCreated:"Left out: Salesforce alone creates its records, such as approvals, Einstein insights, Data.com clean info and invoices, and no permission lets a user create one.",metadata:"Left out: it is metadata, which a checkpoint doesn't hold.",notWritable:"Left out: the user SandForge connects as may not create, edit and delete its records.",notDescribed:"Left out: the org would not describe it.",noSystemModstamp:"Left out: it has no SystemModstamp, so nothing would tell a record changed since.",noRecycleBin:"Left out: the org deletes its records for good, with no recycle bin, so nothing would tell one deleted since, nor bring it back.",unreadable:"Left out: the org refuses to read it whole.",noViewAll:"Without View All Data and Modify All Data, an object is held only with View All and Modify All on it, and the user SandForge connects as has neither on this one: a record they cannot see would read as deleted since.",noModifyAll:"Without View All Data and Modify All Data, an object is held only with View All and Modify All on it, and the user SandForge connects as has View All on this one, not Modify All: a rewind could not put back what others changed.",activities:"Without View All Data and Modify All Data, tasks and events are left out: Salesforce has no View All for activities, and a private one linked to no record stays out of sight.",catalog:"Without View All Data and Modify All Data, products and price books are left out: Salesforce has no View All or Modify All for them.",filesNotProven:"Without View All Data and Modify All Data, files are left out: nothing proves the user sees every file.",settingNotProven:"Without View All Data and Modify All Data, custom settings are left out: no permission on an object proves the user sees and writes every row.",parentNotSeen:"Without View All Data and Modify All Data, an object with no permissions of its own is held only when the user has View All and Modify All on every record it hangs from, which is not proven here."};function bt(e){let t=Ht[e.reason],n=e.detail===void 0?t:`${t.replace(/\.$/,"")} (${e.detail}).`;return{objectApiName:e.objectApiName,code:e.reason,reason:pt(n),...e.detail===void 0?{}:{detail:pt(e.detail)}}}function Kt(e,t,n){return{objectApiName:e,code:"pastTheLimit",records:t,limit:n,reason:t>B?`${e} has ${t} records, more than any checkpoint holds of one object (${B}): left out of the checkpoint, and a rewind to it does not touch ${e}. Data Export, in Setup, or a Bulk API query keeps a copy of it.`:`${e} has ${t} records, past the checkpoint's limit of ${n} for one object: left out of the checkpoint, as part of it would be taken for all of it.`}}function Jt(e,t){let n=t;for(;;){let o=e.filter(s=>s<=Math.min(n,B)).reduce((s,r)=>s+r,0);if(o<=n)return n;n=o}}function pt(e){return e.length<=ut?e:`${e.slice(0,ut-1)}\u2026`}function kt(e,t){return{code:"RUN_WRITING",message:`${t.operation==="take"?`A checkpoint of ${e} is being taken`:t.operation==="rewind"?`A rewind is writing to ${e}`:t.operation==="undo"?`An undo is writing to ${e}`:t.operation==="empty"?`An emptying of its objects is writing to ${e}`:`SandForge is deleting checkpoints of ${e}`} (process ${t.pid} on ${t.host}): take the checkpoint once it has ended. ${W}`}}function wt(e){return typeof e!="object"||e===null?void 0:typeof e.errorCode=="string"?v(e):void 0}function _(e,t){return e instanceof Q||e instanceof Te||e instanceof D||t?.aborted===!0}var Qt=V({sobjects:fe(be)}).loose();function M(e){return e.toLowerCase()===ke.toLowerCase()}function Xt(e,t,n){if(e===void 0)return{why:`the org lists no ${L}`};let o=t.get(e);if(o===void 0)return{why:n.get(e)??"it was not described"};let r=o.fields.find(d=>d.name.toLowerCase()==="linkedentityid")?.referenceTo??[];return r.length===0?{why:"its describe names no record a link ties a file to"}:{linkable:new Set(r.map(d=>d.toLowerCase()))}}async function se(e,t,n){let o=new Map,s=new Map,r=0,d=await Promise.allSettled(n.map(p=>t.describe(p)));for(let[p,i]of d.entries()){let c=n[p],l;if(i.status==="fulfilled"&&"body"in i.value)l=i.value.body;else{if(i.status==="rejected"&&i.reason instanceof Q)throw i.reason;r++;try{l=await e.request({method:"GET",url:`/services/data/v${e.version}/sobjects/${F(c)}/describe`})}catch(h){let a=wt(h);if(a===void 0)throw new Error(`The org did not answer the describe of ${c}: ${v(h)}`);s.set(c,a);continue}}let u=He.safeParse(l);u.success?o.set(c,u.data):s.set(c,"its describe does not read as one")}return{describes:o,errors:s,alone:r}}async function yt(e,t,n){let o=Qt.parse(await e.describeGlobal()),s=await e.toolingObjects?.()??[],r=ye(o.sobjects,{mode:n.mode,...n.objects?{objects:n.objects}:{},...n.excluded?{excluded:n.excluded}:{},...n.customSettings?{customSettings:n.customSettings}:{}},s),d=r.candidates.some(M),p=d?o.sobjects.find(m=>m.name.toLowerCase()===L.toLowerCase())?.name:void 0,i=p===void 0?r.candidates:[...r.candidates,p],{describes:c,errors:l,alone:u}=await se(e,t,i),h,a;if(d){let m=Xt(p,c,l);"linkable"in m?h=m.linkable:a=m.why,p!==void 0&&c.delete(p)}let g=Ae(r,c,l);if(a!==void 0){let m=g.objects.find(({objectApiName:C})=>M(C));m!==void 0&&(g=J(g,new Map([[m.objectApiName,`its links to records, ${L}, could not be described: ${a}`]])))}let w=await je(async m=>(await e.query(m)).records),A=new Map(o.sobjects.map(m=>[m.name,ft(m)])),S=o.sobjects.filter(we),f=new Set(S.map(m=>m.name)),k=[...c.values()],y=[];for(let m of g.objects){let C=c.get(m.objectApiName);C&&y.push({scoped:m,label:A.get(m.objectApiName)??m.objectApiName,describe:C,capture:await Ke(C,k,{viewsEncryptedData:w}),...f.has(m.objectApiName)?{customSetting:K(C)}:{}})}return{described:i.length,describedAlone:u,objects:y,leftOut:g.leftOut,addedToPicked:r.addedToPicked,...h!==void 0&&y.some(({scoped:m})=>M(m.objectApiName))?{linkable:h}:{},settings:S.map(m=>({objectApiName:m.name,label:ft(m)}))}}function ft(e){let t=e.label;return typeof t=="string"&&t!==""?t:e.name}async function Yt(e,t,n,o){let s=await ee(t,n.map(({capture:i})=>({objectApiName:i.objectApiName,readMode:i.readMode})),o),r=new Map,d=new Map,p=0;for(let[i,c]of s.entries()){let{objectApiName:l,readMode:u}=n[i].capture;if("count"in c){r.set(l,c.count);continue}p++;let h=Qe(l,u);try{let a=await e.query(h.soql,{scanAll:h.scanAll});if(typeof a.totalSize!="number")throw new Error("The org gave no count of its records.");r.set(l,a.totalSize)}catch(a){let g=wt(a);if(g===void 0)throw new Error(`The org did not count the records of ${l}: ${v(a)}`);d.set(l,g)}}return{counts:r,refused:d,alone:p}}function At(e,t){return t?.has(e.toLowerCase())===!0&&!M(e)}async function qt(e,t,n,o,s){let r=[];for(let{objectApiName:i,records:c}of t){let l=F(i);r.push({objectApiName:l,soql:`SELECT COUNT() FROM ${l} WHERE IsDeleted = true AND SystemModstamp < ${Z(o)}`,scanAll:!0,counts:"inBin"}),c!==0&&(r.push({objectApiName:l,soql:`SELECT COUNT() FROM ${l} WHERE SystemModstamp >= ${Je(o)}`,scanAll:!0,counts:"stampedSince"}),At(l,n)&&r.push({...et(l),counts:"links"}))}let d=await Ye(e,r,()=>{},s),p=new Map;return d.forEach((i,c)=>{let{objectApiName:l,counts:u}=r[c],h=i.read?i.totalSize:void 0,a=p.get(l)??{};u==="links"?a.links=h??null:h!==void 0&&(a[u]=h),p.set(l,a)}),{asked:r.length,of:p}}function St({scoped:e,capture:t,customSetting:n,access:o},s,r,d){return{objectApiName:e.objectApiName,records:s,inBin:r,readOrder:e.readOrder,readMode:t.readMode,undeletable:t.undeletable,cascadeParents:t.cascadeParents,restrictParents:t.restrictParents,fingerprint:d,fields:t.fields,leftOutFields:t.leftOutFields,...n!==void 0?{customSetting:n}:{},...o!==void 0?{access:o}:{}}}function Ot(e){return{personAccounts:rt(e.map(({describe:t})=>t)),catalog:at(e.map(({scoped:t})=>t.objectApiName))}}function Zt(e){let t=e?.orgType==="Sandbox"||e?.orgType==="Scratch";return Oe(Ce(t)).defaultQueryLimit}async function Ct(e,t,n,o,s,r,d,p=Tt){let i=n.maxTotal??Gt;if(!Number.isInteger(i)||i<1)throw new RangeError(`Not a number of records: ${i}`);let c=Math.min(i,B),{counts:l,refused:u,alone:h}=await Yt(e,t,o.objects,d),a=J({mode:n.mode,objects:o.objects.map(({scoped:b})=>b),leftOut:o.leftOut,packages:[]},u),g=new Map(o.objects.map(b=>[b.scoped.objectApiName,b])),w=a.leftOut.map(bt),A=[];for(let b of a.objects){let O=g.get(b.objectApiName),P=l.get(b.objectApiName);if(!(O===void 0||P===void 0)){if(P>c){w.push(Kt(b.objectApiName,P,c));continue}A.push({...O,scoped:{...b,readOrder:A.length},records:P,otherGroups:Be(b.objectApiName,O.capture.fields,O.capture.readMode),recount:{}})}}let S=A.some(({scoped:b})=>M(b.objectApiName))?o.linkable:void 0,f=await qt(t,A.map(({scoped:b,records:O})=>({objectApiName:b.objectApiName,records:O})),S,r,d);for(let b of A)b.recount=f.of.get(b.scoped.objectApiName)??{};w.sort((b,O)=>b.objectApiName<O.objectApiName?-1:b.objectApiName>O.objectApiName?1:0);let k={};for(let{scoped:b,describe:O}of A)k[b.objectApiName]=De(O.fields);let y=en(p,We({described:o.described,describedAlone:o.describedAlone,counted:o.objects.length,countedAlone:h,recounted:f.asked,objects:A.map(b=>({records:b.records,otherGroups:b.otherGroups,...b.recount,entry:St(b,b.records,0,k[b.scoped.objectApiName].digest)})),pageRows:Zt(n.registered),leftOut:w,printsBytes:(await $e(k)).length,annexCalls:ct(Ot(A))})),m={...y,apiRequestsLeft:s.remaining},C={objects:A,leftOut:w,estimate:m,objectLimit:c,prints:k,...S!==void 0?{linkable:S}:{}};if(y.records>i){let b=[...A.map(O=>O.records),...w.flatMap(O=>O.code==="pastTheLimit"?[O.records??0]:[])];return{...C,refusal:{code:"TOO_MANY_RECORDS",message:`The objects this checkpoint would keep hold ${y.records} records in ${n.orgName}, past its limit of ${i}: pick fewer objects. ${W}`,holdingLimit:Jt(b,y.records)}}}let R=_e("take",y.apiRequests,s,n.orgName);return R===void 0?C:{...C,refusal:R}}function jt(e){return{query:t=>e.query(t),queryMore:t=>e.queryMore(t)}}var Tt={guard:0,scope:0};function en(e,t){if(e.guard+e.scope===0)return t;let n=t.requestsByPhase;return{...t,apiRequests:t.apiRequests+e.guard+e.scope,...n!==void 0?{requestsByPhase:{...n,guard:n.guard+e.guard,scope:n.scope+e.scope}}:{}}}function tn(e){let t=[...e.mode==="picked"?e.objects??[]:[],...Array.isArray(e.customSettings)?e.customSettings:[]];return new Set(t.map(n=>n.toLowerCase()))}function nn(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}async function Rt(e,t,n,o,s,r){if(s.kind==="org")return{scope:{...o,objects:o.objects.map(f=>({...f,access:"org"}))},reads:Tt};let d=o.objects.map(({scoped:f})=>f.objectApiName),p={grants:s.objects,describes:o.objects.map(({describe:f})=>f),customSettings:o.objects.filter(({customSetting:f})=>f!==void 0).map(({scoped:f})=>f.objectApiName)},i=nt(d,p),c=[],l=0;if(i.length>0)try{let f=await se(e,t,i);c=[...f.describes.values()],l=Math.ceil(i.length/Re)+f.alone}catch(f){if(_(f,r))throw f}let u=ot(d,{...p,describes:[...p.describes,...c]}),h=tn(n),a=[],g=[...o.leftOut],w=[];for(let f of o.objects){let k=f.scoped.objectApiName,y=u.get(k);if(y!==void 0&&"access"in y){a.push({...f,access:y.access});continue}let m={objectApiName:k,reason:y?.reason??"noViewAll",...y?.detail!==void 0?{detail:y.detail}:{}};g.push(m),h.has(k.toLowerCase())&&n.unprovenLeftOut!==!0&&w.push(m)}let A=new Set(a.map(({scoped:f})=>f.objectApiName)),S={scope:{...o,objects:a,leftOut:g,addedToPicked:o.addedToPicked.filter(f=>A.has(f))},reads:{guard:s.requests,scope:l}};if(w.length>0){let f=w.length===1;return{...S,refusal:{code:"PERMISSIONS",message:`${n.username} doesn't have View All Data and Modify All Data, and the checkpoint can't hold ${nn(w.map(k=>k.objectApiName))}, asked for by name. ${w.map(k=>`${k.objectApiName}: ${bt(k).reason}`).join(" ")} Leave ${f?"it":"them"} out, or give the user View All Data and Modify All Data. ${W}`}}}return a.length===0&&o.objects.length>0?{...S,refusal:{code:"PERMISSIONS",message:`${n.username} doesn't have View All Data and Modify All Data, nor View All and Modify All on any object this checkpoint would hold: without them, a checkpoint holds only the objects its user sees and puts back whole. Give the user View All and Modify All on the objects to hold, or View All Data and Modify All Data. `+W}}:S}function on(e){return e.objects.map(({scoped:t,label:n,capture:o,records:s,customSetting:r,access:d})=>({objectApiName:t.objectApiName,label:n,...t.namespace!==void 0?{namespace:t.namespace}:{},records:s,undeletable:o.undeletable,leftOutFields:o.leftOutFields,...r!==void 0?{customSetting:r}:{},...d!==void 0?{access:d}:{}}))}function Nt(e){let t=e.customSettings;return t!==void 0&&(t==="all"||t.length>0)}async function sn(e,t,n,o,s){let r=new Map(o.objects.map(u=>[u.scoped.objectApiName,u])),d=n.settings.filter(({objectApiName:u})=>!r.has(u)),p=new Map;if(d.length>0)try{({describes:p}=await se(e,t,d.map(({objectApiName:u})=>u)))}catch(u){if(_(u,s))throw u}let i=d.filter(({objectApiName:u})=>p.has(u)),c=await ee(t,i.map(({objectApiName:u})=>({objectApiName:u,readMode:"query"})),s),l=new Map;return c.forEach((u,h)=>{"count"in u&&l.set(i[h].objectApiName,u.count)}),n.settings.map(({objectApiName:u,label:h})=>{let a=r.get(u);if(a?.customSetting!==void 0)return{objectApiName:u,label:h,kind:a.customSetting,records:a.records};let g=p.get(u),w=l.get(u);return{objectApiName:u,label:h,...g!==void 0?{kind:K(g)}:{},...w!==void 0?{records:w}:{}}})}var rn={records:0,apiRequests:0,apiRequestsLeft:0,seconds:0,bytes:0};async function Yn(e,t){let n={mode:t.mode,objects:[],leftOut:[],estimate:rn},o=await te(jt(e.org),{act:"take",orgName:t.orgName,registered:t.registered,username:t.username,customSettings:Nt(t)},{userId:()=>e.org.userId()});if(!o.allowed)return{...n,refusal:o.refusal};let s=e.store.heldBy(o.org.id),r=s===void 0?await e.runWriting?.(o.org.id):void 0,d=X(e.org,e.signal);try{let p=await q(e.org,t.orgName),i=await Rt(e.org,d,t,await yt(e.org,d,t),o.grants,e.signal),{scope:c}=i,l=await e.org.serverTime(),u=await Ct(e.org,d,t,c,p,l,e.signal,i.reads),h={mode:t.mode,objects:on(u),leftOut:u.leftOut,estimate:u.estimate,files:{held:u.objects.some(({scoped:g})=>M(g.objectApiName)),queryAllFiles:o.queryAllFiles,addedToPicked:c.addedToPicked},customSettings:await sn(e.org,d,c,u,e.signal)},a=s!==void 0?kt(t.orgName,s):r!==void 0?{code:"RUN_WRITING",message:r}:i.refusal??u.refusal;return a===void 0?h:{...h,refusal:a}}catch(p){throw _(p,e.signal)?new D:p}}function an(e){let t=e.requestsSent?()=>e.requestsSent?.()??0:void 0,n={guard:0,scope:0,start:0,counts:0,bin:0,snapshot:0,stability:0},o="guard",s=t?.()??0,r=()=>{if(!t)return;let d=t();n[o]+=d-s,s=d};return{enter(d){r(),o=d},requests(){return t?(r(),{total:Object.values(n).reduce((p,i)=>p+i,0),byPhase:{...n}}):void 0}}}async function cn(e,t){if(t.edition!==void 0)return t.edition;let o=(await e.query("SELECT OrganizationType FROM Organization LIMIT 1")).records[0]?.OrganizationType;if(typeof o!="string"||o==="")throw new Error("The org did not say its edition (Organization.OrganizationType).");return o}var dn="Automated Process";async function ln(e){let n=(await e.query("SELECT Id, Name FROM User WHERE UserType = 'AutomatedProcess'")).records.filter(s=>typeof s.Id=="string"),o=n.find(s=>s.Name===dn);return o!==void 0?o.Id:n.length===1?n[0].Id:void 0}function Dt(e){let t=new Date(Date.parse(e)).toISOString();return`${t.slice(0,10)} ${t.slice(11,16)} UTC`}function mt(e,t){return e.split(he).join(Dt(t))}function ne(e){let t=Se(e);return t===null?Number.NaN:Date.parse(t)}function Mt(e){return typeof e=="string"&&e.length>=15?e.slice(0,15):void 0}async function un(e,t){let n=new Set;for await(let o of x(Y(e,t))){let s=Mt(o.Id);s!==void 0&&n.add(s)}return n}async function pn(e,t,n,o,s,r){let d={changed:0,deleted:0,created:0};if(!o.live&&!o.deleted)return d;let p=await xe.read(e,t,n);if(o.live)for await(let i of x(o.live.file)){let c=ne(i.SystemModstamp);if(!(c<=r))continue;let l=p.stampOf(i.Id);l===void 0?d.created++:l!==c&&d.changed++}if(o.deleted){let i;for await(let c of x(o.deleted.file)){if(!(ne(c.SystemModstamp)<=r))continue;if(p.has(c.Id)){d.deleted++;continue}if(!(ne(c.CreatedDate)<s))continue;i??=await un(e,n);let l=Mt(c.Id);l!==void 0&&!i.has(l)&&d.deleted++}}return d}async function Pt(e){let t=0;for(let n of await It(e,{withFileTypes:!0})){let o=oe(e,n.name);n.isDirectory()?t+=await Pt(o):n.isFile()&&(t+=(await ht(o)).size)}return t}async function fn(e,t){let n=await Pt(e.dir)-(await ht(e.checkpointFile)).size,o=r=>Buffer.byteLength(`${JSON.stringify({...t,bytes:r},null,2)}
|
|
8
8
|
`,"utf8"),s=n+o(n);return s=n+o(s),s}function mn(e){let t=e.snapshotsFile,n=new Ue({getData:()=>xt(t)?JSON.parse(Bt(t,"utf8")):{},setData:o=>Wt(t,JSON.stringify(o,null,2),{encoding:"utf8",mode:384})});return n.initialize(),n}var gn=V({organizationId:pe().optional()}).loose();async function hn(e,t,n,o,s){let r=mn(e),d=0,p={log:n.handler.log,orgManager:n.handler.orgManager,orgRegistry:n.handler.orgRegistry,configStore:r,broker:{postToWebview:c=>{if(c.type!=="operation:progress")return;let l=c.payload;typeof l.percentage=="number"&&typeof l.currentStep=="string"&&s(l.percentage,l.currentStep)}},services:{getSandforgeSetting:(c,l)=>c==="backup.maxRecordsPerObject"?o:l},nextId:()=>`${e.checkpointId}-${++d}`},i=new Ge(p);return i.setBackupRecordStore(new Ve(t)),await i.swept(),{handler:i,config:r}}function bn(e,t){return e.slice(0,15)===t.slice(0,15)}async function qn(e,t){let{org:n,store:o,signal:s}=e,r=e.now??(()=>new Date),d=me.parse([...t.ignoredFields??[]]),p=t.name===void 0?void 0:$.parse(t.name),i=t.nameWithDate;i!==void 0&&$.parse(mt(i,r().toISOString()));let c=t.customSettings==="all"?[]:t.customSettings??[];for(let y of[...t.objects??[],...t.excluded??[],...c])F(y);let l=t.beforeRun===void 0?void 0:ge.parse(t.beforeRun),u=t.keepDays??Me;I(r(),u);let h=(y,m,C=0,R=0)=>e.onProgress?.({percentage:Math.round(y),processedObjects:C,totalObjects:R,step:m});h(0,`Checking ${t.orgName}`);let a=an(n),g=await te(jt(n),{act:"take",orgName:t.orgName,registered:t.registered,username:t.username,customSettings:Nt(t)},{userId:()=>n.userId()});if(!g.allowed)return{taken:!1,refusal:g.refusal};let w=g.org.id,A=ve("ck",r()),S=o.lock(w,"take",A);if("busy"in S)return{taken:!1,refusal:kt(t.orgName,S.busy)};let f,k;try{let y=await e.runWriting?.(w);if(y!==void 0)return{taken:!1,refusal:{code:"RUN_WRITING",message:y}};let m=X(n,s),C=await cn(n,g.org),R=await q(n,t.orgName);h(2,`Reading the objects of ${t.orgName}`),a.enter("scope");let b=await Rt(n,m,t,await yt(n,m,t),g.grants,s);if(b.refusal!==void 0)return{taken:!1,refusal:b.refusal};let{scope:O}=b;a.enter("start");let P=await n.userId(),ie=await ln(n),N=await n.serverTime();h(8,`Counting the records of ${O.objects.length} objects`),a.enter("counts");let T=await Ct(n,m,t,O,R,N,s,b.reads);if(T.refusal!==void 0)return{taken:!1,refusal:T.refusal};if(T.objects.length===0)throw new Error(`None of the objects asked for can be kept in a checkpoint of ${t.orgName}: ${T.leftOut.map(j=>`${j.objectApiName}: ${j.reason}`).join(" ")||"there are none."}`);if(s?.aborted)throw new D;f=await o.create(w,A);let E=`snapshot-${A}`;k={version:1,checkpointId:A,name:p??(i!==void 0?$.parse(mt(i,N)):Dt(N)),org:{organizationId:w,...t.alias!==void 0?{alias:t.alias}:{},username:t.username,instanceUrl:t.instanceUrl,isSandbox:g.org.sandbox,organizationType:C,tier:g.tier,...t.scratchExpiresAt!==void 0?{scratchExpiresAt:t.scratchExpiresAt}:{},...R.dataStorageMaxMB!==void 0?{dataStorageMaxMB:R.dataStorageMaxMB}:{},...t.registered?.staging===!0&&g.org.sandbox?{staging:!0}:{}},takenBy:{userId:P,...ie!==void 0?{automatedProcessUserId:ie}:{},viewAllData:g.grants.kind==="org"||g.grants.viewAllData,modifyAllData:g.grants.kind==="org"||g.grants.modifyAllData,queryAllFiles:g.queryAllFiles},readFrom:N,takenAt:N,scope:{mode:t.mode,leftOut:T.leftOut},objects:[],ignoredFields:d,snapshotId:E,movedWhileTaken:{changed:0,deleted:0,created:0},bytes:0,expiresAt:I(r(),u),status:"taking",takenOn:{host:_t(),pid:process.pid},...l!==void 0?{beforeRun:l}:{}},await o.write(k),h(12,"Reading the recycle bin as it was at the checkpoint"),a.enter("bin");let vt=await qe(m,T.objects.map(({scoped:j})=>({...Xe(j.objectApiName,N),file:Y(f,j.objectApiName)})),s),re=new Map;for(let j of vt){if(!j.read)throw new Error(`The recycle bin of ${j.objectApiName} could not be read whole: ${j.reason}`);re.set(j.objectApiName,j.rows)}a.enter("snapshot");let{records:Et,files:ae}=await kn(f,E,T,t,e,w,m,h);h(88,`Reading the record types, users and queues ${t.orgName} names`);let $t=await wn(f,E,T,m,w,s);h(89,"Reading the time on the org"),a.enter("stability");let ce=await n.serverTime();h(90,`Checking what changed in ${t.orgName} while it was read`);let{movedWhileTaken:Ft,notChecked:Lt}=await yn(f,E,T,m,N,ce,s),{prints:de}=T;await o.writeFingerprints(f,de);let G=T.objects.map(j=>{let z=j.scoped.objectApiName;return St(j,Et.get(z)??0,re.get(z)??0,de[z].digest)});if(s?.aborted)throw new D;let le={...k,takenAt:ce,objects:G,movedWhileTaken:Ft,bytes:0,expiresAt:I(r(),u),status:"ready",...ae!==void 0?{files:ae}:{},replayAnnex:$t},U={...le,bytes:await fn(f,le)};await o.write(U),h(100,`Checkpoint '${U.name}' taken`,G.length,G.length);let ue=a.requests();return{taken:!0,checkpoint:U,notChecked:Lt,...ue!==void 0?{requests:ue}:{},estimate:T.estimate}}catch(y){throw f!==void 0&&await An(o,f,k,e),_(y,s)?new D:y}finally{S.lock.release()}}async function kn(e,t,n,o,s,r,d,p){let i=n.objects.filter(a=>a.records>0),c=new Map,l=(s.snapshotFiles??Vt)(e.dir);if(i.length>0){let a=Math.max(Ut,n.objectLimit),{handler:g,config:w}=await hn(e,l,s,a,(k,y)=>p(15+k*.65,y)),A=await g.backupForPipeline({operationId:t,orgId:o.orgId,objects:i.map(({scoped:k})=>k.objectApiName),fields:new Map(i.map(({scoped:k,capture:y})=>[k.objectApiName,y.fields])),scanAll:i.filter(({capture:k})=>k.readMode==="scanAllLive").map(({scoped:k})=>k.objectApiName),origin:"checkpoint",failWhenTruncated:!0,onConnection:k=>s.org.countAlso?.(k)},s.signal),S=gn.safeParse(w.get(`backup:${t}`)),f=S.success?S.data.organizationId:void 0;if(f===void 0||!bn(f,r))throw new Error(`The snapshot was read from ${f===void 0?"an org that did not say which it is":`another org (${f})`}, not from ${o.orgName}: it is not kept.`);for(let k of A.objects)c.set(k.objectApiName,k.recordCount)}p(82,"Indexing the snapshot",0,n.objects.length);for(let[a,{scoped:g}]of n.objects.entries()){let w=g.objectApiName,A=c.get(w)??0;c.has(w)||(await Pe(oe(e.dir,"backups")),await l.writeFile(Le(e,t,w),""),c.set(w,0));let S=await Ie(e,t,w);if(S.rows!==A)throw new Ee("damaged",`The snapshot of ${w} holds ${S.rows} records where its read kept ${A}: it is not kept.`);p(82+6*(a+1)/n.objects.length,`Indexed ${w}`,a+1,n.objects.length)}let u=n.objects.find(({scoped:a})=>M(a.objectApiName));if(u===void 0||n.linkable===void 0)return{records:c};p(88,"Reading the links of files to the records read");let h=await tt({reader:d,folder:e,snapshotId:t,linked:n.objects.map(({scoped:a})=>a.objectApiName).filter(a=>(c.get(a)??0)>0&&At(a,n.linkable)),documentsInSnapshot:(c.get(u.scoped.objectApiName)??0)>0,...s.signal!==void 0?{signal:s.signal}:{}});return{records:c,files:h}}async function wn(e,t,n,o,s,r){let d=await it(e,t,n.objects.map(({scoped:i,describe:c,capture:l})=>({objectApiName:i.objectApiName,userLookups:st(c,l.fields)}))),p=await dt({reader:o,organizationId:s,users:d,...Ot(n.objects),...r!==void 0?{signal:r}:{}});return lt(e,p)}async function yn(e,t,n,o,s,r,d){let p=oe(e.dir,zt),i={changed:0,deleted:0,created:0},c=[];try{let l=await Ze(o,n.objects.map(({capture:a})=>({objectApiName:a.objectApiName,readMode:a.readMode,held:!1})),s,p,d),u=Date.parse(Z(s)),h=Date.parse(r);for(let a of l){if("unread"in a){c.push({objectApiName:a.objectApiName,reason:a.unread});continue}if(!a.moved)continue;let g=await pn(e,t,a.objectApiName,a,u,h);i.changed+=g.changed,i.deleted+=g.deleted,i.created+=g.created}}finally{await gt(p,{recursive:!0,force:!0})}return{movedWhileTaken:i,notChecked:c}}async function An(e,t,n,o){try{n!==void 0&&await e.write({...n,status:"failed"})}catch(s){o.handler.log(`[WARN] checkpoint ${t.checkpointId}: not marked failed: ${v(s)}`)}try{await gt(t.dir,{recursive:!0,force:!0})}catch(s){o.handler.log(`[WARN] checkpoint ${t.checkpointId}: what its take wrote was not removed: ${v(s)}`)}}export{Gt as a,B as b,Xn as c,D as d,Kt as e,Jt as f,Yn as g,qn as h};
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a as yo}from"./chunk-INIQ23K6.mjs";import{a as bo}from"./chunk-SUIPDW5O.mjs";import{$ as xt,B as lo,G as fo,J as go,K as mo,L as wo,Z as Ro,_ as Ct,aa as ko,ba as So,c as Xr,da as vo,e as Zr,ea as It,f as Qr,fa as $o,h as eo,j as to,k as no,l as ro,m as oo,o as so,y as io}from"./chunk-WF5S4FW5.mjs";import{b as ao,g as co}from"./chunk-FV6MOSHD.mjs";import{a as ho,f as po}from"./chunk-T542Z54E.mjs";import{e as jt,m as uo}from"./chunk-FYG47CNA.mjs";import{c as fn}from"./chunk-Z5IUK2QO.mjs";import{Ab as zr,Bb as Gr,Cb as Jr,Db as Hr,Eb as $t,Fb as Yr,Gb as Kr,Hb as Vr,Za as ze,_ as Lr,d as Rt,e as Cr,f as xr,fb as Dr,g as Ir,gb as Ge,h as Er,i as kt,j as Tr,k as Fr,l as Pr,n as Mr,ob as Wr,p as Nr,pb as Ur,sb as St,tb as Je,ub as Br,vb as vt,wb as qr}from"./chunk-E5FSPXYH.mjs";import{k as or,n as sr}from"./chunk-ALWVNR34.mjs";import{a as Be,j as bt,k as vr}from"./chunk-QHE2RUWX.mjs";import{a as pn,b as gn,c as _e,d as mn,e as wn,g as yn,h as bn,j as Rn}from"./chunk-6FARZYMJ.mjs";import{a as At,c as Ot}from"./chunk-TMIV3IWH.mjs";import{B as Fn,Mc as Kn,Uc as Zn,x as En,y as Tn}from"./chunk-CJAWKLAL.mjs";import{g as Yn,h as mt,i as wt}from"./chunk-VKREON6Q.mjs";import{f as Pe,h as hn,k as ot}from"./chunk-DDNCJVZ2.mjs";import{Za as $r,_a as Ar,eb as Or,gb as jr,n as qe}from"./chunk-C5AUNG6T.mjs";import{k as Sr}from"./chunk-3I6FXFCN.mjs";import{f as Ln,h as Dn,q as Xn}from"./chunk-7O6EFNQS.mjs";import{B as _n,M as Le,a as kn}from"./chunk-3LRFPGYZ.mjs";import{a as ct,b as Wn,c as Bn,f as qn,h as ut,k as zn,l as Gn,n as lt,o as Jn,p as ft,s as ht,u as pt,x as Hn}from"./chunk-KWUS7UAV.mjs";import{q as nr,u as rr}from"./chunk-35B73566.mjs";import{c as gt,d as Vn}from"./chunk-DLSU66MY.mjs";import{a as Te,c as fe}from"./chunk-AL4C3GFT.mjs";import{b as Fe,c as Ae}from"./chunk-WQCXOZEJ.mjs";import{b as Qn,c as er}from"./chunk-ZVU7MD2S.mjs";import{Cc as yr,Jc as br,Pb as pr,Ua as ar,Va as dr,Yc as Rr,Zc as kr,cb as cr,d as dt,dc as gr,j as De,k as We,kb as ur,mb as lr,nb as fr,pc as mr,r as tr,s as Ue,sb as hr,sc as yt,vb as me,wc as wr,x as ge,xa as ir}from"./chunk-OLCS7JCT.mjs";import{i as it,j as vn,l as at}from"./chunk-TQ6HEJ73.mjs";import{a as $e,b as un,f as rt}from"./chunk-65AMXOQU.mjs";import{b as st,f as Sn}from"./chunk-K5PUMHZU.mjs";import{i as $n}from"./chunk-INIT2UKJ.mjs";import{h as Mn}from"./chunk-ATBQIE2V.mjs";import{c as Nn}from"./chunk-UCUFLFNK.mjs";import{b as Wo}from"./chunk-MS4FJDFD.mjs";import{D as pe,F as In,p as jn}from"./chunk-4XROG5CT.mjs";import{b as ln,d as Me,f as Ne,h as _r}from"./chunk-LCDPCUXS.mjs";import{a as oe}from"./chunk-EADHKH3A.mjs";import{j as Pn}from"./chunk-22L43JMK.mjs";import{d as Un}from"./chunk-TUACWKIH.mjs";import{j as An,w as On}from"./chunk-ICIYL45C.mjs";import{a as xn}from"./chunk-3KJCSYXY.mjs";import{a as Cn}from"./chunk-HDDJ3CVN.mjs";import{Cc as en,Qd as sn,Rd as he,Vd as nt,ad as tn,bd as tt,ed as nn,je as an,le as dn,me as cn,yd as rn,zd as on}from"./chunk-J347SPU6.mjs";import{A as R}from"./chunk-WZQEK4WT.mjs";import{d as Do}from"./chunk-NTOVCTRS.mjs";var Zo=Do(Wo());import{randomUUID as Jo}from"node:crypto";import{existsSync as Oe,mkdirSync as Ho,readFileSync as we,renameSync as Yo,writeFileSync as Ko}from"node:fs";import{dirname as Vo,join as ye,resolve as Xo}from"node:path";var Qo=`sandforge sync \u2014 run a Sync between two orgs, without the editor.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
npx sandforge sync \\
|
|
11
|
+
--source <alias> --target <alias> --object <ApiName> [options]
|
|
12
|
+
|
|
13
|
+
Required:
|
|
14
|
+
--source <alias> sf CLI alias of the source org
|
|
15
|
+
--target <alias> sf CLI alias of the target org
|
|
16
|
+
--object <ApiName> object to sync; repeat for more. The run writes the
|
|
17
|
+
parents their lookups name first, and keeps the
|
|
18
|
+
order given otherwise.
|
|
19
|
+
Append ":<Field>" to match on an external Id, which
|
|
20
|
+
turns that object's operation into an upsert.
|
|
21
|
+
|
|
22
|
+
Options:
|
|
23
|
+
--operation <op> insert | upsert | update (default: insert)
|
|
24
|
+
Per-object ":<Field>" wins over this.
|
|
25
|
+
--where <obj=clause> SOQL WHERE for one object (repeatable)
|
|
26
|
+
e.g. --where "Account=BillingCountry = 'France'"
|
|
27
|
+
--batch-size <n> records per write call (default: 200)
|
|
28
|
+
--dry-run simulate: read both orgs and say what the run
|
|
29
|
+
would insert, update, skip or refuse, writing
|
|
30
|
+
nothing (default: off)
|
|
31
|
+
--max-records-per-object <n>
|
|
32
|
+
the most records of one object the run reads, from
|
|
33
|
+
1 to 50000; an object with more is read up to it, and
|
|
34
|
+
the run says so on stderr and under readCut with
|
|
35
|
+
--json, and ends partial (default: 50000)
|
|
36
|
+
--files copy the files of the records each object writes:
|
|
37
|
+
Salesforce Files and legacy attachments, 10 MB each
|
|
38
|
+
and 100 MB a run at most unless --max-file-mb and
|
|
39
|
+
--max-run-mb say otherwise, as a configuration that
|
|
40
|
+
copies files does. The command keeps no record of
|
|
41
|
+
the files it copied: run again, it copies them
|
|
42
|
+
again (default: off)
|
|
43
|
+
--max-file-mb <n> with --files, the largest file copied, from 1 to 35;
|
|
44
|
+
a larger one is left out and counted (default: 10)
|
|
45
|
+
--max-run-mb <n> with --files, the most a run copies, from 1 to 2000;
|
|
46
|
+
the files past it are left out and counted
|
|
47
|
+
(default: 100)
|
|
48
|
+
--keep-contact-points write emails and phone numbers as read. Without
|
|
49
|
+
it, as in the panel, every address is written
|
|
50
|
+
under .invalid and every phone number as a
|
|
51
|
+
fictional one (default: off)
|
|
52
|
+
--anonymize-everything say that the run copies the personal data as the
|
|
53
|
+
source holds it, and what anonymizes it: Sync
|
|
54
|
+
anonymizes nothing. ${sn}=everything
|
|
55
|
+
does the same; --json says anonymizationMode
|
|
56
|
+
--json emit the run summary as JSON (default: off)
|
|
57
|
+
Saved to a file, it is what --remove takes the
|
|
58
|
+
run back from: it names what the run created.
|
|
59
|
+
The run's file does too, whatever becomes of the
|
|
60
|
+
run (see SANDFORGE_JOURNAL_DIR). A dry run's names
|
|
61
|
+
under wouldBeRefused what a real run would be
|
|
62
|
+
refused for, the code of each under
|
|
63
|
+
wouldBeRefusedCodes, as its line names it. A real
|
|
64
|
+
run refused before its first write prints
|
|
65
|
+
"refused": {"code", "message"} instead, the code its
|
|
66
|
+
line names: refused (CODE): ..., each other reason
|
|
67
|
+
of its gate under "alsoRefused", on a line of its own.
|
|
68
|
+
--fail-on-partial exit 3, not 0, when the run wrote some records and
|
|
69
|
+
the target refused others, or read an object up to
|
|
70
|
+
--max-records-per-object, a dry run's read
|
|
71
|
+
included (default: off)
|
|
72
|
+
--mute-automation mute the target's automation for the run through
|
|
73
|
+
its own bypass: assign the user the run writes as,
|
|
74
|
+
for the run alone, the permission sets holding the
|
|
75
|
+
custom permissions its flows, processes and
|
|
76
|
+
workflow rules test to stay quiet, and take them
|
|
77
|
+
back as it ends; what no bypass keeps quiet still
|
|
78
|
+
runs, and is named. Refused on a production org and
|
|
79
|
+
for a user who cannot assign permission sets, exit
|
|
80
|
+
1; with --dry-run, says what would be muted and
|
|
81
|
+
assigns nothing (default: off)
|
|
82
|
+
--accept-emails write although the target delivers the emails its
|
|
83
|
+
flows, processes and workflow rules send as the run
|
|
84
|
+
writes (Setup > Deliverability: All email), or would
|
|
85
|
+
not say whether it does. Read only when something
|
|
86
|
+
that still runs sends one, with one line of
|
|
87
|
+
anonymous Apex that sends nothing; without the flag
|
|
88
|
+
the run is refused, exit 1 (EMAILS_NOT_ACCEPTED),
|
|
89
|
+
nothing written. On System email only or No access
|
|
90
|
+
it is not needed. --mute-automation keeps quiet what
|
|
91
|
+
tests the org's bypass; what an Apex trigger sends is
|
|
92
|
+
read nowhere (default: off)
|
|
93
|
+
${Cr({run:"the run",simulation:"--dry-run"})}
|
|
94
|
+
--help this text
|
|
95
|
+
|
|
96
|
+
Run a saved configuration:
|
|
97
|
+
npx sandforge sync \\
|
|
98
|
+
--config-file <config.json> --store <dir> --source <alias> --target <alias> \\
|
|
99
|
+
[--dry-run] [--json]
|
|
100
|
+
|
|
101
|
+
--config-file <file> a Sync configuration as the panel saves one, checked
|
|
102
|
+
as the panel checks it: its objects, filters,
|
|
103
|
+
mappings, add-ons, mode, and whether it copies files.
|
|
104
|
+
It runs between the two orgs given, whatever orgs it
|
|
105
|
+
names. In delta mode, each object reads only what the
|
|
106
|
+
source changed since its last good run. A transform
|
|
107
|
+
rule that names no field is refused before any org is
|
|
108
|
+
reached, exit 1: it would change every field of every
|
|
109
|
+
record.
|
|
110
|
+
--store <dir> where the configuration is kept between runs, with
|
|
111
|
+
its watermarks, the files it copied and which record
|
|
112
|
+
of the target each source record it wrote became, as
|
|
113
|
+
the panel keeps them beside it: give every run of it
|
|
114
|
+
the same directory, and --remove too. A later run
|
|
115
|
+
points a lookup at the copy an earlier run wrote.
|
|
116
|
+
--object, --where, --operation, --batch-size, --files, --max-file-mb,
|
|
117
|
+
--max-run-mb and --keep-contact-points come from the file (files,
|
|
118
|
+
keepContactPoints), and are refused with it. A legacy attachment the source changed since it was copied is
|
|
119
|
+
replaced, its earlier copy deleted, on a sandbox or a Developer Edition org,
|
|
120
|
+
as in the panel; a production org keeps the copy.
|
|
121
|
+
|
|
122
|
+
Remove what a run created:
|
|
123
|
+
npx sandforge sync \\
|
|
124
|
+
--remove <summary.json | run file | run id> --target <alias>
|
|
125
|
+
[--include-changed] [--accept-automation] [--store <dir>]
|
|
126
|
+
[--sweep | --sweep-list] [--sweep-late] [--sweep-untied] [--json]
|
|
127
|
+
|
|
128
|
+
--remove <file | id> the summary a run printed with --json, saved to a
|
|
129
|
+
file; or the run's file, which it names as it
|
|
130
|
+
begins, or its run id. Deletes from the target what
|
|
131
|
+
the run created: the records it inserted, or
|
|
132
|
+
upserted where the target held none, the last object
|
|
133
|
+
written first, into the target's recycle bin. Before
|
|
134
|
+
that, gives the records it wrote over \u2014 an update,
|
|
135
|
+
an upsert that found the record \u2014 the values they
|
|
136
|
+
held before the run, of the fields it wrote, which
|
|
137
|
+
the run kept first in <dir>/backups (below); one
|
|
138
|
+
changed since the run stays as it is unless
|
|
139
|
+
--include-changed. First of all, what a delta run
|
|
140
|
+
deleted as the source had is brought back from the
|
|
141
|
+
target's recycle bin, while it is there. A run
|
|
142
|
+
another process still writes is refused, exit 1.
|
|
143
|
+
From its file, a run killed,
|
|
144
|
+
stopped or ended by an error is taken back too: a
|
|
145
|
+
Bulk API job it had under way, which ran on in the
|
|
146
|
+
target, is read back by its id first, and its
|
|
147
|
+
records go with the rest.
|
|
148
|
+
--target <alias> the org the run wrote to, and no other. It must be a
|
|
149
|
+
sandbox or a Developer Edition org.
|
|
150
|
+
--include-changed remove also the records changed since the run, which
|
|
151
|
+
are kept otherwise, and give back their values from
|
|
152
|
+
before the run to the records it wrote over that
|
|
153
|
+
were changed since
|
|
154
|
+
--accept-automation remove although the target runs flows, Apex
|
|
155
|
+
triggers, processes or workflow rules as the removal
|
|
156
|
+
brings records back from the recycle bin, gives them
|
|
157
|
+
their values back, sets them back to Draft or
|
|
158
|
+
deletes them, those --sweep deletes included, or
|
|
159
|
+
could not say what it runs. Each is named before
|
|
160
|
+
anything is written; without the flag the removal
|
|
161
|
+
then writes nothing, exit 1 (default: off)
|
|
162
|
+
--mute-automation mute the target's automation for the removal through
|
|
163
|
+
its own bypass, as for a run; what no bypass keeps
|
|
164
|
+
quiet still needs --accept-automation (default: off)
|
|
165
|
+
--store <dir> for a run of a saved configuration: its store, which
|
|
166
|
+
the removal tells what it took, so that the next
|
|
167
|
+
delta run reads those objects whole and copies the
|
|
168
|
+
files it deleted again
|
|
169
|
+
--sweep before the run's records go, delete too what the
|
|
170
|
+
target's automation made for the run, that the run did
|
|
171
|
+
not write: what the run's user created under the
|
|
172
|
+
records it created or wrote over, what they point
|
|
173
|
+
at, or what hangs from those, three links at most, at
|
|
174
|
+
most a minute after the record it is tied to \u2014 in the
|
|
175
|
+
objects whose records it created and their children,
|
|
176
|
+
tasks, events, feed, email messages, notes, case
|
|
177
|
+
comments, and the objects the target's flows create.
|
|
178
|
+
What a record of the run points at by a lookup the
|
|
179
|
+
org refuses the delete for goes once that record is
|
|
180
|
+
gone. The window runs from a second
|
|
181
|
+
before the run's first write \u2014 its first call, an
|
|
182
|
+
update before anything was created included, which
|
|
183
|
+
the summary dates by this machine's clock, read on
|
|
184
|
+
the org's \u2014 to a minute after its last write: the
|
|
185
|
+
last record it created, read back from the org, or
|
|
186
|
+
a later call, an update included, as the summary
|
|
187
|
+
dates it. Listed and kept: what is tied to the run
|
|
188
|
+
but came later, up to 15 minutes, or as the org's
|
|
189
|
+
Automated Process user; and what the run's user
|
|
190
|
+
created in the window tied to nothing of the run.
|
|
191
|
+
What anyone changed more than 2 s after the run's
|
|
192
|
+
last write, and after its own creation, stays \u2014 the
|
|
193
|
+
run's user and its automation too \u2014 unless
|
|
194
|
+
--include-changed, and the sweep then ends partial,
|
|
195
|
+
exit 3; a change made before the run's last write
|
|
196
|
+
reads as unchanged
|
|
197
|
+
(default: off)
|
|
198
|
+
--sweep-late with --sweep, take too what it lists as made late;
|
|
199
|
+
with --sweep-list, say what it would take
|
|
200
|
+
--sweep-untied with --sweep, take too what it lists as tied to
|
|
201
|
+
nothing of the run; with --sweep-list, say what it
|
|
202
|
+
would take; refused when another run of this
|
|
203
|
+
machine wrote to the target in the window, or when
|
|
204
|
+
that user created records in the window on objects
|
|
205
|
+
neither the run nor the automation reaches (hand
|
|
206
|
+
work, likely)
|
|
207
|
+
--sweep-list list what --sweep would delete, per object with a few
|
|
208
|
+
names and how many it ties to the run, and delete
|
|
209
|
+
nothing, the run's records included; exit 3, as a
|
|
210
|
+
refused --sweep, when it says the sweep is refused.
|
|
211
|
+
What a sweep leaves: what another user created; what
|
|
212
|
+
is tied to nothing, unless --sweep-untied; what came
|
|
213
|
+
more than 15 minutes after its record, or after the
|
|
214
|
+
removal began; what anyone changed after the run's
|
|
215
|
+
last write, the run's own user included, unless
|
|
216
|
+
--include-changed; what the automation changed
|
|
217
|
+
rather than created; what left the org; and what the
|
|
218
|
+
panel or another machine wrote
|
|
219
|
+
--leave-undeletable remove the rest when the user the removal runs as
|
|
220
|
+
may not delete the records of some objects of the
|
|
221
|
+
run, leaving those with what they hang from; without
|
|
222
|
+
it the removal stops before its first delete and
|
|
223
|
+
names them (default: off)
|
|
224
|
+
--json print the removal as JSON; refused before its first
|
|
225
|
+
write, "refused": {"code", "message"}, the code its
|
|
226
|
+
line names: refused (CODE): ... \u2014 a production org
|
|
227
|
+
(PRODUCTION_TARGET), what fires as it writes
|
|
228
|
+
(AUTOMATION_NOT_ACCEPTED), its mute (MUTE_PRODUCTION,
|
|
229
|
+
MUTE_NO_RIGHT, MUTE_FAILED), objects its user may not
|
|
230
|
+
delete (UNDELETABLE_NOT_LEFT), an org that is not the
|
|
231
|
+
one the run wrote to (OTHER_ORG), a run still writing
|
|
232
|
+
(RUN_WRITING)
|
|
233
|
+
|
|
234
|
+
What the removal left on the run's records is kept beside the summary, in
|
|
235
|
+
<summary>.removals.json, or beside the run's file, in <run id>.removal.json,
|
|
236
|
+
and the next --remove of the same summary or file reads it.
|
|
237
|
+
|
|
238
|
+
Environment:
|
|
239
|
+
SANDFORGE_JOURNAL_DIR=<dir>
|
|
240
|
+
where every run that writes keeps its file, in
|
|
241
|
+
<dir>/sync-runs/<run id>.ndjson (default: ~/.sandforge),
|
|
242
|
+
said as it begins: what it created, its calls as
|
|
243
|
+
they went and answered, a Bulk API job's id once the
|
|
244
|
+
org opened it, and how it ended. Ids and dates only.
|
|
245
|
+
What a run writes over \u2014 an update, an upsert that
|
|
246
|
+
finds the record \u2014 is read from the target first and
|
|
247
|
+
kept in <dir>/backups, readable by you alone, as
|
|
248
|
+
sandforge backup keeps a snapshot: the values the
|
|
249
|
+
records held, of the fields the run writes, which
|
|
250
|
+
--remove gives back. A call whose values cannot be
|
|
251
|
+
kept is not sent, its rows refused with why.
|
|
252
|
+
|
|
253
|
+
Before its first write, a run counts the records it writes under each filter,
|
|
254
|
+
and is refused, with nothing written, when they would take more data storage
|
|
255
|
+
than the target has left, or make the target's automation send more emails
|
|
256
|
+
than it has left today; --dry-run says what it would meet. A run of a saved
|
|
257
|
+
configuration leaves as they are the records an earlier run of it copied that
|
|
258
|
+
are still in the target, and inserts the others.
|
|
259
|
+
|
|
260
|
+
Exit codes: 0 the run finished, some of its records refused included (read
|
|
261
|
+
the summary for per-object failures), or the removal took every record it set
|
|
262
|
+
out to; 1 the run or the removal could not be started, either was refused
|
|
263
|
+
before it wrote anything \u2014 a production target among the reasons; for the
|
|
264
|
+
run, more data storage than the target has left, more emails or API requests
|
|
265
|
+
than it has left today, emails it delivers without --accept-emails
|
|
266
|
+
(EMAILS_NOT_ACCEPTED), a checkpoint asked first refused or not taken
|
|
267
|
+
(CHECKPOINT_REFUSED); for the removal, what the target runs as it writes,
|
|
268
|
+
without --accept-automation \u2014 or the run produced only failures, or it
|
|
269
|
+
stopped on an error (its file keeps what it created); 2 a bad command line,
|
|
270
|
+
or a summary or a file --remove cannot take a run back from; 3 the removal
|
|
271
|
+
left records of the run in the target, or its sweep was refused or did not
|
|
272
|
+
take all it was asked to (a --sweep-untied refused included), or the run was
|
|
273
|
+
partial \u2014 records refused, or an object read up to --max-records-per-object,
|
|
274
|
+
a dry run's read among them \u2014 and --fail-on-partial was given; 130 a Ctrl-C
|
|
275
|
+
stopped the run, 143 a SIGTERM (a CI job cancelled or timed out), 129 a
|
|
276
|
+
SIGHUP: its file keeps what it created.
|
|
277
|
+
`,es=["--object","--where","--operation","--batch-size","--files","--max-file-mb","--max-run-mb","--keep-contact-points"],D=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,ts=new Set(["SYNC_TARGET_UNWRITABLE",me,yt]),ns={switches:["--dry-run","--files","--keep-contact-points","--json","--fail-on-partial","--mute-automation","--accept-emails",he,...Rt.switches],values:["--source","--target","--object","--operation","--where","--batch-size","--max-records-per-object","--max-file-mb","--max-run-mb","--config-file","--store",...Rt.values]};function Et(t,r,e,n){if(t===void 0)return n;let i=Number(t);return(!/^\d+$/.test(t)||i<e.min||i>e.max)&&(process.stderr.write(`${r} takes a whole number from ${e.min} to ${e.max}, not "${t}".
|
|
278
|
+
`),process.exit(2)),i}function rs(t,r=process.env){let e=t.slice(2);(e.includes("--help")||e.includes("-h"))&&(process.stdout.write(Qo),process.exit(0)),ln(e,ns);let n=(S,k)=>{let v=e.indexOf(S);return v>=0&&v+1<e.length?e[v+1]:k},i=S=>{let k=[];for(let v=0;v<e.length;v++)e[v]===S&&v+1<e.length&&k.push(e[v+1]);return k},s=S=>e.includes(S),a=xr(e),h=a!==void 0?{checkpointFirst:a}:{},l=Et(n("--max-records-per-object"),"--max-records-per-object",{min:1,max:5e4},5e4),u=n("--source"),c=n("--target");if(s("--config-file")){let S=n("--config-file"),k=n("--store");(!S||!k||!u||!c)&&(process.stderr.write(`--config-file wants the file, --store <dir> where it is kept between runs, --source and --target. Run with --help.
|
|
279
|
+
`),process.exit(2));let v=es.filter(s);return v.length>0&&(process.stderr.write(`--config-file takes its objects, filters and files from the file: ${v.join(", ")} cannot be given with it.
|
|
280
|
+
`),process.exit(2)),{source:u,target:c,objects:[],operation:"insert",where:{},batchSize:200,dryRun:s("--dry-run"),files:!1,maxRecordsPerObject:l,keepContactPoints:!1,anonymizationMode:nt(s(he),r),json:s("--json"),failOnPartial:s("--fail-on-partial"),muteAutomation:s("--mute-automation"),acceptEmails:s("--accept-emails"),...h,configFile:S,store:k}}s("--store")&&(process.stderr.write(`--store keeps a saved configuration between runs: give it with --config-file.
|
|
281
|
+
`),process.exit(2));let g=i("--object");(!u||!c||g.length===0)&&(process.stderr.write(`Missing --source, --target or --object. Run with --help.
|
|
282
|
+
`),process.exit(2));let y=g.map(S=>{let[k,v]=S.split(":");return D.test(k)||(process.stderr.write(`Not an SObject API name: "${k}"
|
|
283
|
+
`),process.exit(2)),En(k)&&(process.stderr.write(`${Tn(k,"give --files")}
|
|
284
|
+
`),process.exit(2)),v!==void 0&&!D.test(v)&&(process.stderr.write(`Not a field API name: "${v}"
|
|
285
|
+
`),process.exit(2)),{objectApiName:k,externalIdField:v}}),b=n("--operation","insert")??"insert";b!=="insert"&&b!=="upsert"&&b!=="update"&&(process.stderr.write(`--operation takes insert, upsert or update, not "${b}".
|
|
286
|
+
`),process.exit(2));let C={};for(let S of i("--where")){let k=S.indexOf("="),v=k>0?S.slice(0,k):"";D.test(v)||(process.stderr.write(`--where wants "Object=clause", not "${S}".
|
|
287
|
+
`),process.exit(2)),C[v]=S.slice(k+1)}let j=n("--batch-size","200")??"200",x=Number(j);(!Number.isInteger(x)||x<1||x>1e4)&&(process.stderr.write(`--batch-size takes a whole number between 1 and 10000.
|
|
288
|
+
`),process.exit(2)),!s("--files")&&(s("--max-file-mb")||s("--max-run-mb"))&&(process.stderr.write(`--max-file-mb and --max-run-mb go with --files.
|
|
289
|
+
`),process.exit(2));let T=Et(n("--max-file-mb"),"--max-file-mb",{min:1,max:35}),M=Et(n("--max-run-mb"),"--max-run-mb",{min:1,max:2e3});return{source:u,target:c,objects:y,operation:b,where:C,batchSize:x,dryRun:s("--dry-run"),files:s("--files"),...T!==void 0?{maxFileMB:T}:{},...M!==void 0?{maxRunMB:M}:{},maxRecordsPerObject:l,keepContactPoints:s("--keep-contact-points"),anonymizationMode:nt(s(he),r),json:s("--json"),failOnPartial:s("--fail-on-partial"),muteAutomation:s("--mute-automation"),acceptEmails:s("--accept-emails"),...h}}function os(t,r){if(t.anonymizationMode!=="everything")return;let e=n=>n.map(i=>fe(i)).join(" ");return`anonymize everything: Sync does not anonymize, it copies the personal data as ${t.source} holds it (emails and phone numbers neutralized unless kept). A copy that anonymizes: ${Te("clone")} ${e(ss(t,r))}; or mask the target afterwards: ${Te("dataops")} ${e(["anonymize","--org",t.target,he])}.`}function ss(t,r){return["--source",t.source,"--target",t.target,...r.flatMap(e=>["--object",e.objectApiName,...e.where!==void 0&&e.where.trim()!==""?["--where",e.where]:[]]),he]}function Tt(t){return{anonymizationMode:t.anonymizationMode,anonymized:!1}}function is(t){let r=new Date().toISOString(),e=t.objects.map((n,i)=>({objectApiName:n.objectApiName,externalIdField:n.externalIdField,operation:n.externalIdField?"upsert":t.operation,fieldMappings:[],transformRules:[],excludedFields:[],addOnFields:[],batchSize:t.batchSize,where:t.where[n.objectApiName],insertOrder:i}));return{id:`cli-${Date.now()}`,name:"sandforge-sync",description:"Headless run",sourceOrgId:t.source,targetOrgId:t.target,direction:"source_to_target",mode:"full",objects:e,conflictStrategy:"source_wins",enableRollback:!1,createdAt:r,updatedAt:r,...t.files?{files:{maxFileSizeMB:t.maxFileMB??10,maxRunMB:t.maxRunMB??100}}:{},...t.keepContactPoints?{keepContactPoints:!0}:{}}}function as(t,r){let e;try{e=JSON.parse(t)}catch{return{refusal:"is not JSON: give a Sync configuration as the panel saves one."}}if(typeof e!="object"||e===null||Array.isArray(e))return{refusal:"is not a Sync configuration: it holds no object."};let n=Fn.safeParse({config:{...e,sourceOrgId:r.source,targetOrgId:r.target}});if(!n.success){let a=n.error.issues[0];return{refusal:`is not a configuration a run takes (${a.path.slice(1).join(".")||"configuration"}: ${a.message})`}}let i=n.data.config;if(i.id===void 0)return{refusal:"names no id: a saved configuration keeps its watermarks and the files it copied under its id."};let s=new Date().toISOString();return{config:{...i,id:i.id,createdAt:i.createdAt??s,updatedAt:i.updatedAt??s,objects:i.objects.map(a=>({...a,batchSize:a.batchSize??200}))}}}function Co(t){return Ho(t,{recursive:!0}),new eo(qe(ye(t,"configStore.json")))}function ds(t,r,e,n,i=!1,s=5e4){let a=u=>({query:async c=>u.query(c),queryMore:async c=>u.queryMore(c)}),h=u=>({pages:a(u),transport:u,create:async(c,g)=>u.sobject(c).create(g,{headers:en()})}),l=new Map;return{copy:Qr({[t.sourceOrgId]:h(r),[t.targetOrgId]:h(e)}),sourceIds:async(u,c)=>{let g=u.objectApiName;if(!D.test(g))throw new Error(`Not an SObject API name: ${g}`);let y=pe(u.where,c),{records:b}=await oe(a(r),`SELECT Id FROM ${g}${y?` WHERE ${y}`:""}`,s);return b.flatMap(C=>typeof C.Id=="string"?[C.Id]:[])},store:n??{load:()=>l.size===0?{kind:"none"}:{kind:"stored",map:{version:1,entries:[...l.values()]}},record:(u,c)=>{l.set(`${c.sourceOrgId}|${c.targetOrgId}|${c.sourceId}`,c)}},...i?{deleteFromTarget:async(u,c)=>Pn(await e.sobject(u).destroy(c),u).map(g=>({id:g.id,success:g.success,errors:g.errors}))}:{}}}function cs(t){let r=tt({isSandbox:t.sandbox,edition:t.edition});return Zr(new Xn,t.id,{orgType:r})}function xo(t){return t.filter(r=>r.type!=="address"&&r.type!=="location").map(r=>r.name)}function Ao(t,r=5e4,e){return async(n,i,s)=>{let a=i.objectApiName;if(!D.test(a))throw new Error(`Not an SObject API name: ${a}`);let h=pe(i.where,s?.changedSince),l=h?` WHERE ${h}`:"",u={query:async C=>t.query(C),queryMore:async C=>t.queryMore(C)},c=await t.sobject(a).describe(),g=xo(c.fields),y=!1,b=await $n(`SELECT ${(g.length>0?g:["Id"]).join(", ")} FROM ${a}${l}`,async C=>{let j=await oe(u,C,r);return y||=j.truncated,j.records});return y&&(s?.onBoundReached?.(),e?.(a,b.length)),b}}function us(t,r){let e=`${Te("clone")} --depth all --source ${r.source} --target ${r.target} --fit share --dry-run`;return t.map(n=>`${n.objectApiName}: the read of the source stopped at ${n.read} records (--max-records-per-object ${n.bound}): this run copied part of the object. `+fo("source",n.bound,{raise:"--max-records-per-object",sample:e}))}function Ft(t,r){return t==="success"&&r.length>0?"partial":t}function ls(t,r){return async(e,n,i)=>{let s=n.objectApiName;if(!D.test(s))throw new Error(`Not an SObject API name: ${s}`);let a=pe(n.where,i?.changedSince),{totalSize:h}=await t.query(`SELECT COUNT() FROM ${s}${a?` WHERE ${a}`:""}`);return r===void 0?h:Math.min(h,r)}}function fs(t){return async(r,e)=>{let n=r.objectApiName;if(!D.test(n))return 0;let i=pe(r.where,e?.changedSince);try{return(await t.query(`SELECT COUNT() FROM ${n} WHERE IsPersonAccount = true`+(i?` AND (${i})`:""))).totalSize}catch{return 0}}}function hs(t){return async r=>{let e=r.objectApiName;if(!D.test(e))throw new Error(`Not an SObject API name: ${e}`);let n=pe(r.where,void 0),{records:i}=await oe({query:async s=>t.query(s),queryMore:async s=>t.queryMore(s)},`SELECT Id FROM ${e}${n?` WHERE ${n}`:""}`);return i.flatMap(s=>typeof s.Id=="string"?[s.Id]:[])}}function Oo(t){if(t.go||t.code!==me&&t.code!==dt)return t;let{code:r,message:e,refusal:n}=t;return{...t,message:Fr({code:r,message:e,...n?{refusal:n}:{}})}}var ps={notInTarget:"it has no such object, or the user the run writes as cannot see it",notCreateable:"the user the run writes as may not create its records",notUpdateable:"the user the run writes as may not edit its records",unread:"it did not describe the object",notAKey:"its upsert matches on a field that is neither an External ID nor an idLookup field"};function Pt(t,r){return{...t??{},sent:r}}function Io(t,r){let e=t.notWritten??0,n=t.total>0?t.total:e,i=[`write gate: ${n-e} record(s) to write to ${r}, about ${yr(t.storage.estimateMB)} MB of data storage`];for(let u of t.objects)i.push(` ${u.objectApiName.padEnd(42)}${String(u.rows).padStart(8)}`);e>0&&i.push(` of the ${n} a run counts from the source, ${e} would not be written: held back or refused, as each object says; what follows is measured on all of them`),t.alreadyCopied>0&&i.push(` not counted: ${t.alreadyCopied} record(s) an earlier run of this configuration copied, still in the target, left as they are`),(t.alreadyLinked??0)>0&&i.push(` not counted: ${t.alreadyLinked} record(s) an earlier run of this configuration linked to records the target held, left as they are`),(t.overwrites??0)>0&&i.push(` of them, up to ${t.overwrites} written by an update or an upsert over records ${r} holds: their values are kept first, and --remove puts them back`),(t.rolesLinked??0)>0&&i.push(` not counted: ${t.rolesLinked} OpportunityContactRole record(s) the platform writes itself with the opportunities the run creates, for their contact: the run links each and does not send it`),(t.rolesByThePlatform??0)>0&&i.push(` of them, up to ${t.rolesByThePlatform} OpportunityContactRole record(s) the platform writes itself with the opportunities the run creates, for their contact: the run links each and does not send it`);let{storage:s}=t;s.verdict==="unread"?i.push(` the data storage ${r} has left could not be read (${s.unread??""}): whether the records fit is not known`):s.remainingMB!==void 0&&s.maxMB!==void 0&&i.push(` data storage of ${r}: ${s.remainingMB} MB left of ${s.maxMB} MB`+pr(s,r)+(s.verdict==="exceeds"?": the records do not fit":s.verdict==="near"?": the records take more than 80 % of it":""));for(let u of t.emails){let c=u.objects.map(y=>`${y.perRecord} per ${y.objectApiName}`).join("; "),g=` emails: these records make ${r} send about ${mr(u.emails,u.limit)} (${c})`+(u.alertsCounted?", its email alerts among them, as a Developer Edition counts them":"");i.push(u.verdict==="unread"?`${g}; what it has left today could not be read (${u.unread??""})`:u.verdict==="fits"?`${g}; it has ${u.remaining??"?"} of ${u.max??"?"} left today`:`${g}, more than the ${u.remaining??"?"} of ${u.max??"?"} it has left today`)}t.emailsUnread!==void 0&&i.push(` emails: not counted, ${t.emailsUnread} could not be read`),t.deliverability&&i.push(` ${wr(t.deliverability.reading)}`);let a=t.apiRequests;a&&(i.push(a.verdict==="unread"?` API requests: about ${a.estimate}; what ${r} has left today could not be read (${a.unread??""})`:` API requests: about ${a.estimate}, of the ${a.remaining??"?"} ${r} has left of its ${a.max??"?"} a day`+(a.verdict==="exceeds"?": more than it has left":a.verdict==="near"?": it would leave less than a tenth of them":"")),i.push(` ${Nn}`));for(let u of t.unwritable??[])i.push(` ${u.objectApiName}: ${u.rows} record(s) ${r} takes none of \u2014 ${ps[u.why]}${u.key!==void 0?` (${u.key})`:""}`);let h=new Set((t.unwritable??[]).map(({objectApiName:u})=>u)),l=({parent:u,field:c})=>`${c} names ${u} records ${h.has(u)?"left out":"held back"}`;for(let u of t.heldBack??[]){let c=u.parents??[u];i.push(` ${u.objectApiName}: ${u.rows} record(s) held back, not written \u2014 `+(c.length===1?`their ${l(c[0])}`:c.map(g=>`${g.rows} whose ${l(g)}`).join("; ")))}return t.aboveRecords!==void 0&&i.push(` more than ${t.aboveRecords} records: the panel asks before it writes (sandforge.safety.confirmAboveRecords)`),i}function Eo(t,r,e=!1){let n=t.flatMap(s=>s.recordTypeGiven?[s.recordTypeGiven]:[]),i=Lr(n,r);return i.length>0&&r&&e&&i.push(" the permission sets a real run assigns to mute the automation may open other record types to the user it writes as: it reads them again once assigned, and its summary says what the target gave"),i}function To(t){return`${t} already linked by an earlier run of this configuration to records the target held, left as they are`}function gs(t,r="the target",e=!1,n,i){let s=[`
|
|
290
|
+
simulation: ${t.objects.length} object(s), nothing written`];if(t.writeOrder){s.push(` write order: ${t.writeOrder.objects.join(", ")}`);for(let a of t.writeOrder.moved)s.push(` ${a.objectApiName} after ${a.after}: its ${a.field} names one`);for(let a of t.writeOrder.cycles)s.push(` ${a.join(", ")} name each other: in this order, the lookup at the one written later is left empty`)}if(t.writeCheck){for(let h of Io(t.writeCheck,r))s.push(` ${h}`);for(let h of t.checkpoint?kt(t.checkpoint):[])s.push(` ${h}`);if(t.writeCheck.verdict==="refused"){let h=t.writeCheck,[l,u]=(h.unwritable??[]).length>0?["SYNC_TARGET_UNWRITABLE","the target takes none of the records of an object it writes"]:n!==void 0?[me,n]:h.storage.verdict==="exceeds"?["SYNC_STORAGE_EXCEEDED","the records do not fit"]:h.apiRequests?.verdict==="exceeds"?[hr,"it takes more API requests than the target has left today"]:[me,h.checkpointUnread??"the checkpoint asked first is refused"];s.push(` a run would be refused before it writes (${l}): ${u}`)}else(t.writeCheck.unwritable??[]).length>0&&s.push(" a run of the command would be refused before it writes (SYNC_TARGET_UNWRITABLE): the target takes none of the records of an object it writes; leave it out of the configuration");let a=t.writeCheck.emails.some(h=>h.verdict==="exceeds");t.writeCheck.verdict!=="refused"&&a?s.push(" a run of the command would be refused before it writes (SYNC_EMAILS_EXCEEDED): past a daily email limit"):t.writeCheck.verdict!=="refused"&&i!==void 0&&s.push(` a run of the command would be refused before it writes (${yt}): `+i)}t.writeCheckUnread!==void 0&&s.push(` the records to write could not be counted: ${t.writeCheckUnread}`);for(let a of t.objects){s.push(` ${a.objectApiName} (${a.operation}): ${a.read} read, would insert ${a.insert}, update ${a.update}, delete ${a.delete}, skip ${a.skipped}, refuse ${a.refused}`+(t.direction==="bidirectional"?`, ${a.conflicts} in conflict`:"")),a.alreadyCopied!==void 0&&s.push(` ${a.alreadyCopied} already copied by an earlier run of this configuration, left as they are`),a.alreadyLinked!==void 0&&s.push(` ${To(a.alreadyLinked)}`),(a.encryptedLeftOut??[]).length>0&&s.push(` ${Fo(a.encryptedLeftOut??[])}`),a.conflictFields.length>0&&s.push(` differ on: ${a.conflictFields.join(", ")}`),a.files&&s.push(` files: would copy ${a.files.copied}, add ${a.files.versions} version(s), ${a.files.unchanged} unchanged, ${a.files.tooLarge+a.files.pastRunCap} skipped past the caps`);for(let h of a.notes)s.push(` ${h}`);if(a.validationRules&&a.validationRules.length>0){s.push(` ${a.validationRules.length} active validation rule(s) of the target, which a simulation cannot evaluate \u2014 a record one of them refuses is counted as written:`);for(let h of a.validationRules)s.push(` ${h.name}${h.field?` (${h.field})`:""}: ${h.message||"(no message)"}`),h.readsUnreachable&&h.readsUnreachable.length>0&&s.push(` ${rr(h.readsUnreachable.map(l=>({field:l})))}`)}}t.validationRulesUnread&&s.push(` the target's validation rules could not be listed (${t.validationRulesUnread}): any of them may refuse a record counted as written`);for(let a of Eo(t.objects,!0,e))s.push(` ${a}`);return t.cancelled&&s.push(" stopped by a cancel before its last object"),t.error&&s.push(` stopped at ${t.failedObject??"an object"}: ${t.error}`),s}var ms=/^(PARENT_REFUSED|RECORD_TYPE_UNAVAILABLE|RECORD_TYPE_UNMAPPED):/;function ws(t){let r=t.slice(0,3);for(let e of t.slice(3))ms.test(e)&&r.push(e);return r}var ys={notInTarget:": the lookup held an id from the source org that the target does not have.",ownerRefusedEarlier:", left out from the start: the target refused the same owner earlier in this run, an id from the source org that the target does not have.",parentRefused:": the record it names, written after them, was refused in this run.",notSet:": the target refused setting it once the record it names was written",notReached:": the run was stopped before it was set, once the record it names was written."},bs={"validation-rule":"a validation rule of the target refused it","restricted-picklist":"a restricted picklist of the target refused its value","lookup-filter":"a lookup filter of the target refused the record it names","inactive-owner":"the target holds the owner it names inactive"};function Rs(t){let r=ks(t),e=Math.max(0,(t.skipped??0)-r);return`${t.objectApiName}: ${t.processed??0} processed, ${t.success??0} succeeded, ${t.failed??0} failed, ${e} skipped`+(r>0?`, ${r} linked`:"")}function ks(t){return(t.writtenByThePlatform?.records??0)+(t.linkedToExisting?.records??0)}function Ss(t){let r=[];(t.encryptedLeftOut??[]).length>0&&r.push(Fo(t.encryptedLeftOut??[]));let e=t.linkedToExisting;e&&r.push(`${e.records} record(s) linked to a record the target holds, not written: the target refused them as a duplicate of it${e.refusal?` (${e.refusal})`:""}; what the run writes under them points at that record.`);let n=t.writtenByThePlatform;n&&r.push(`${n.records} record(s) linked to the contact role the platform wrote with their opportunity, for its contact, not written; ${n.given} given the source's fields ${n.given===1?"it":"they"} lacked`+(n.refusal?`, the others left as the platform wrote them (${n.refusal}).`:"."));for(let{records:a,fields:h,reason:l,refusal:u}of t.lookupsLeftOut??[]){let c=l==="notSet"?`${u?` (${u})`:""}.`:"";r.push(`${a} record(s) written without ${h.join(", ")}${ys[l]}${c}`)}let i=t.lookupsSetAfter;i&&r.push(`${i.records} record(s) given ${i.fields.join(", ")} by a second write once ${i.after.join(", ")} ${i.after.length===1?"was":"were"} written: the objects name each other, and no order writes both first.`);let s=t.writtenWithoutFields;return s&&r.push(`${s.rows} record(s) written again without the fields the target refused them on:`,...s.fields.map(({field:a,rows:h,refusedBy:l="validation-rule",reason:u})=>` ${h} without ${a}: ${bs[l]}, ${u}`)),r}function Fo(t){return`${t.join(", ")}: encrypted, and read masked by the user the source is read as (it lacks View Encrypted Data): left out of every record written, never copied as masks`}function vs(t){return t?t.neutralized?[`emails and phone numbers: ${t.values} value(s) in ${t.fields.length} field(s) neutralized, addresses under .invalid and numbers fictional, so what the target's automation sends to them reaches no one`,...t.fields.map(({objectApiName:r,field:e,values:n})=>` ${r}.${e} ${n}`),...t.numbersExhausted?[` ${t.numbersExhausted} phone number(s) left out, their field empty: the 10 000 fictional numbers were all given to other numbers of the run`]:[],...nr(t).map(r=>` ${r}`)]:["emails and phone numbers: written as read (--keep-contact-points): the target's automation may have emailed or texted the people the records name"]:[]}function $s(t){return(t??[]).map(r=>`${On(r)}.`)}function As(t,r=!1){return[...r?[po]:[],...Sr(t??[]).map(e=>`${e}.`)]}function Os(t){let r=t.read==="delta"?`delta: ${t.changed} record(s) changed since ${t.since??"the last run"}`:`delta: read whole (${t.reason??"no watermark"}), ${t.changed} record(s)`,e=t.deletionsChecked?`, ${t.deleted} deleted as the source deleted them`+(t.deleteFailed>0?`, ${t.deleteFailed} refused`:""):"",n=t.recorded!==void 0?"; watermark recorded":"; watermark kept as it was: the next run reads from the same point",i=(t.lookupsOwed??0)>0?`, ${t.lookupsOwed} record(s) left without a lookup this run was to set among them`:"";return`${r}${e}${n}${i}`}function js(t){let r=new Map,e=new Jn,n=new Map,i=new Set,s,a,h,l=u=>{if(u<=0)return;let c=new Date().toISOString();a??=c,h=c};return{runId:t,sending:(u,c)=>l(c),writing:(u,c)=>l(c),answered:()=>{h=new Date().toISOString()},note:(u,c)=>{if(c.length===0)return;let g=c.filter(y=>{let b=y.slice(0,15);return i.has(b)?!1:(i.add(b),!0)});g.length>0&&r.set(u,[...r.get(u)??[],...g]),s=new Date().toISOString(),a??=s,h=s},touched:(u,c)=>{c<=0||(s=new Date().toISOString(),h=s)},overwriting:(u,c,g)=>{g.length!==0&&(e.candidates(u,c,g),l(g.length))},overwrote:(u,c)=>{e.answer(u,c),h=new Date().toISOString()},deleted:(u,c)=>{if(c.length===0)return;let g=n.get(u)??new Map;for(let y of c)g.has(y.slice(0,15))||g.set(y.slice(0,15),y);n.set(u,g),l(c.length)},overwrittenCount:()=>e.count,flush:async()=>{},created:()=>[...r].map(([u,c])=>({objectApiName:u,ids:[...c]})),lastWrittenAt:()=>s,firstWrittenAt:()=>a,lastWriteAt:()=>h,overwritten:()=>e.read(),deletions:()=>[...n].map(([u,c])=>({objectApiName:u,ids:[...c.values()]}))}}function Cs(t,r){return r?{runId:t.runId,note:(e,n,i)=>{t.note(e,n,i),r.note(e,n,i)},noteUnanswered:(e,n)=>{t.note(e,n),r.noteUnanswered?r.noteUnanswered(e,n):r.note(e,n)},sending:(e,n,i)=>{t.sending?.(e,n,i),r.sending?.(e,n,i)},answered:(e,n)=>{t.answered?.(e,n),r.answered?.(e,n)},writing:(e,n)=>{t.writing?.(e,n),r.writing?.(e,n)},touched:(e,n)=>{t.touched?.(e,n),r.touched?.(e,n)},overwriting:(e,n,i,s)=>{t.overwriting?.(e,n,i),r.overwriting?.(e,n,i,s)},overwrote:(e,n)=>{t.overwrote?.(e,n),r.overwrote?.(e,n)},deleted:(e,n)=>{t.deleted?.(e,n),r.deleted?.(e,n)},checkpoint:e=>{t.checkpoint?.(e),r.checkpoint?.(e)},overwrittenCount:()=>t.overwrittenCount?.()??r.overwrittenCount?.()??0,flush:async()=>await t.flush()??await r.flush()}:t}var Mt="sandforge-sync";function xs(t,r){let e=new Set(r);return{...t,objectsRead:t.objectsRead.filter(n=>e.has(n)),objects:t.objects.filter(n=>e.has(n.objectApiName))}}async function Is(t){try{let e=(await t.query("SELECT Id FROM Organization LIMIT 1")).records[0]?.Id;return typeof e=="string"?e:void 0}catch{return}}async function Es(t=process.argv){if(t.slice(2).includes("--remove"))return Vs(t);let r=Date.now(),e=rs(t),n=o=>{e.json||process.stdout.write(`${o}
|
|
291
|
+
`)},i=o=>{process[e.json?"stderr":"stdout"].write(`${o}
|
|
292
|
+
`)},s,a;if(e.configFile!==void 0&&e.store!==void 0){let o;try{o=we(e.configFile,"utf8")}catch(w){process.stderr.write(`--config-file ${e.configFile} cannot be read: ${w instanceof Error?w.message:String(w)}
|
|
293
|
+
`),process.exit(2)}let d=as(o,e);"refusal"in d&&(process.stderr.write(`--config-file ${e.configFile} ${d.refusal}
|
|
294
|
+
`),process.exit(2));let p=rn(d.config.objects);p.length>0&&(process.stderr.write(`--config-file ${e.configFile}: ${on(p)} Nothing was read or written.
|
|
295
|
+
`),process.exit(1)),s=d.config,a=Co(e.store),a.save(s)}else s=is(e);n(`sandforge sync ${e.source} -> ${e.target}`),n(`objects: ${s.objects.map(o=>o.objectApiName).join(", ")}`+(a?` (configuration ${s.id}, ${s.mode})`:""));let h=os(e,s.objects);h!==void 0&&i(h);let l=Ae(await Fe(e.source)),u=await Fe(e.target),c=Ae(u),g=[rt(c)],y=()=>g.reduce((o,d)=>o+d(),0),b=new Map,C=new AbortController,j=e.dryRun?await $e(c).catch(()=>{}):await fn(c,e.target,{tool:"sandforge sync",action:"write",readOnly:"--dry-run"}),x=`sandforge-sync-${Jo()}`,T=js(x),M=e.dryRun?void 0:ut(Be()),S=M?.recorder({runId:x,configId:a?s.id:Mt,configName:a?s.name:Mt,sourceOrgId:e.source,targetOrgId:j?.id??e.target,targetAlias:e.target,...j?{targetOrganizationId:j.id}:{}}),k;jr(S&&{runUser:o=>{k=o,S.runUser?.(o)}},()=>c.identity(),"sandforge sync");let v=!1,N=()=>{let o=M?.pathOf(x);v||o===void 0||(v=!0,i(`run file: ${o} (--remove ${fe(o)} takes back what the run creates)`))},ee=Cs(T,S),G=S?{...ee,note:(o,d,p)=>{N(),ee.note(o,d,p)},sending:(o,d,p)=>{N(),ee.sending?.(o,d,p)}}:ee,F=e.checkpointFirst?Er({module:"sync",operationId:x,request:e.checkpointFirst,session:u,org:Ir(u,j??await $e(c)),connect:o=>{let d=Ae(o);return g.push(rt(d)),d},journalDir:Be(),say:i,own:{runId:x}}):void 0,J=async o=>{let d=b.get(o);if(d)return d;let p=await c.sobject(o).describe(),w=jt(p);return b.set(o,w),w},se=s.objects.some(o=>o.operation==="update"||o.operation==="upsert"),te=At(),H;if(!e.dryRun&&se){let o=Ot(te);o!==void 0&&(process.stderr.write(`${o} What the run would write over could not be kept, so nothing was written.
|
|
296
|
+
`),process.exit(1)),H=ao({runId:x,orgId:e.target,...j?{organizationId:j.id}:{},files:new wt(mt(te)),meta:qe(ye(te,"snapshots.json"))})}let q=async o=>(await oe({query:async d=>c.query(d),queryMore:async d=>c.queryMore(d)},o)).records,je=H?co({query:q,backup:H,recorder:G,describe:o=>J(o),viewsEncrypted:gt(q)}):void 0,Y=new Mn,K=new mo({connection:c,bulkExecutor:Y,bulkManager:new kn,retryConfig:{},signal:C.signal,onProgress:(o,d,p)=>n(` ${p}: ${o}/${d}`),log:n,calls:go(G,je)}),W=!1,$=async(o,d,p,w,P)=>{if(e.dryRun)throw new Error(`A dry run writes nothing: ${o} ${d} refused.`);return N(),p.length>0&&(W=!0),o==="delete"?K.delete(d,p,w):o==="upsert"?K.upsert(d,P??"Id",p,w):o==="update"?K.update(d,p,w):K.insert(d,p,w)},ie=new Date().toISOString(),_,U,L,B,Ce=Ro(s,async o=>Math.min((await c.query(o)).totalSize,e.maxRecordsPerObject)),ae,be=!1,Re=o=>{if(!be){be=!0,n("");for(let d of o)n(d)}},xe=async o=>{try{let d=await ze(c).read(e.target,o);return ae??=d,Re(ar(d,e.target,{mayMute:bt("--mute-automation"),mayApplyAssignmentRules:!1})),d}catch(d){throw Re([`target automation: what ${e.target} runs on the objects the run writes could not be read (${d instanceof Error?d.message:String(d)})`]),d}},V=j?.id??u.orgId,f={readStorage:()=>lr(ur(c,V)),readApiBudget:()=>fr(c),readAutomation:xe,readLimits:()=>gr(c),readDeliverability:async()=>un(j??await $e(c))?Qn:er(c),emails:{target:e.target,accepted:e.acceptEmails,keepsAddresses:s.keepContactPoints===!0,mayMute:!e.muteAutomation},confirmAboveRecords:dr,sentBefore:()=>y()+(e.dryRun?Or:0),...Ce?{countTarget:Ce}:{},targetFields:async o=>xo((await J(o)).fields??[]),...F?{checkpointFirst:{scope:async(o,d)=>(_={written:o,running:d},U=await F.scope(_),U),take:async o=>{if(!_)throw new Error("its scope was not read");let d=await F.take(_,o,{signal:C.signal});if(d.taken){L=d.checkpoint,G.checkpoint?.(d.checkpoint);for(let p of Pr(d.checkpoint,e.target,e.muteAutomation))i(p)}return d}}}:{}},m=j?nn({orgType:tt({isSandbox:j.sandbox,edition:j.edition}),metadata:{edition:j.edition}}):"production",O,A,I,ne=[],X=[],ke=o=>{let d=Oo({go:!1,...o});return d.go?o:{code:d.code,message:d.message}},E=(o,d)=>({measure:async p=>{let w=await Ct(p,{...f,readAutomation:o,...d?{mutePlan:d}:{}});A=w.checkpointFailed,I=w.runEmails?.gate.stop;let P=xt(w,{policy:"refuse",org:e.target});return ne=P.filter(Q=>!ts.has(Q.code)).map(({code:Q,message:ve})=>({code:Q,message:ve})),e.dryRun||(X=P.map(ke)),w.check},hold:async p=>{let w=await Ct(p,{...f,readAutomation:o,...d?{mutePlan:d}:{}});O=w.check,n("");for(let le of Io(w.check,e.target))n(le);for(let le of w.checkpoint?kt(w.checkpoint):[])i(le);let P=await ko(w,{policy:"refuse",org:e.target,orgTier:m}),[Q,...ve]=xt(w,{policy:"refuse",org:e.target});return X=!P.go&&Q?.code===P.code?ve.map(ke):[],{check:w.check,answer:Oo(await vo(w,P,f.checkpointFirst)),rowBytes:cr(w.plan)}}}),Ke=e.muteAutomation&&!e.dryRun?$o(E,f.readAutomation,async o=>{let d=await Ue(async()=>De(c),o,{writes:It});for(let p of ge(d.muted,e.target))n(` ${p}`);return d},`sandforge sync ${x}`,{target:e.target}):void 0,Po,_t,Lt=()=>Po??=(async()=>{let o=s.objects.map(p=>p.objectApiName),d=await f.readAutomation(o).catch(p=>({unread:p instanceof Error?p.message:String(p)}));try{let p=await Ue(async()=>De(c),d,{writes:It});for(let w of ge(p.muted,e.target))n(w);return _t=p,{planned:p}}catch(p){if(!We(p))throw p;return n(mn(p.refusal)),{refused:p.refusal}}})(),Mo=async o=>{let d=(await Lt()).planned?.automation;return d&&o.every(p=>d.objectsRead.includes(p))?xs(d,o):f.readAutomation(o)},Dt=Ke?.gate??(e.dryRun&&e.muteAutomation?E(Mo,()=>_t?.plan):E(f.readAutomation)),No={measure:o=>Dt.measure(o),hold:async o=>{let d=await Dt.hold(o);return d.answer.go&&(N(),!e.dryRun&&V!==void 0&&vn({action:"sync_execute",orgId:V,operationId:x},{mb:d.check.storage.estimateMB,...d.rowBytes?{rowBytes:d.rowBytes}:{}})),d}},Wt=!1,Ve=()=>{Wt||V===void 0||(Wt=!0,it({action:"sync_execute",orgId:V,operationId:x,objects:[...T.created().map(({objectApiName:o,ids:d})=>({...at(o),created:d.length})),...T.deletions().map(({objectApiName:o,ids:d})=>({...at(o),deleted:d.length}))]}))},Se,de;if(s.files!==void 0){let o=j?cs(j):!1;de=ds(s,l,c,a?.fileStore(),o,e.maxRecordsPerObject),e.dryRun&&de.deleteFromTarget&&(de={...de,deleteFromTarget:async d=>{throw new Error(`A dry run writes nothing: delete ${d} refused.`)}})}let re=new Map,Ut=()=>{let o=us([...re.values()],e);o.length>0&&process.stderr.write(`${o.join(`
|
|
297
|
+
`)}
|
|
298
|
+
`)},Bt=()=>re.size>0?{readCut:[...re.values()]}:{},qt=new wo({...e.dryRun?{}:{creations:G},signal:C.signal,...de?{files:de}:{},...a&&e.store!==void 0?{idMap:Wn(ct(e.store),o=>a.isSaved(o))}:{},...a?{deltaStore:a.deltaStore(),deltaReads:In({query:async(o,d)=>l.query(o,d),queryMore:async o=>l.queryMore(o)},{query:async o=>c.query(o),queryMore:async o=>c.queryMore(o)},C.signal)}:{},dataSync:new uo({insert:(o,d,p)=>$("insert",o,d,p),update:(o,d,p)=>$("update",o,d,p),upsert:(o,d,p,w)=>$("upsert",o,p,w,d),delete:(o,d,p)=>$("delete",o,d,p),describeTargetFields:J}),conflictResolver:new yo,fieldMapping:new xn,transformPipeline:new Cn,querySource:Ao(l,e.maxRecordsPerObject,(o,d)=>{re.set(o,{objectApiName:o,read:d,bound:e.maxRecordsPerObject})}),queryTarget:Ao(c,e.maxRecordsPerObject),maskedSourceFields:Vn(gt(async o=>(await oe({query:async d=>l.query(d),queryMore:async d=>l.queryMore(d)},o)).records),o=>l.sobject(o).describe()),findInTarget:jn({query:async o=>c.query(o),queryMore:async o=>c.queryMore(o)}),bulkThreshold:Y.getThreshold(),describeTargetFields:J,describeTargetFieldsAgain:async o=>jt(await c.sobject(o).describe()),leaseOfTheGate:()=>Ke?.lease(),queryTargetRows:q,countSource:ls(l,e.maxRecordsPerObject),countPersonAccounts:fs(l),readSourceIds:hs(l),writeGate:No,readValidationRules:sr(async o=>(await oe({query:async d=>c.tooling.query(d),queryMore:async d=>c.tooling.queryMore(d)},o)).records,or(c),ir(c),{reads:!0}),currencies:()=>An(async o=>(await l.query(o)).records,async o=>(await c.query(o)).records,{source:async o=>(await l.tooling.query(o)).records,target:async o=>(await c.tooling.query(o)).records}),standardPricebooks:()=>ho(async o=>(await l.query(o)).records,async o=>(await c.query(o)).records),recordTypes:()=>bo({query:async o=>l.query(o),queryMore:async o=>l.queryMore(o)},{query:async o=>c.query(o),queryMore:async o=>c.queryMore(o)})});if(e.dryRun){n(`
|
|
299
|
+
simulating\u2026 (DRY-RUN: nothing is written)`);let d={...await qt.simulate(s),...U?{checkpoint:U}:{}},{planned:p,refused:w}=e.muteAutomation?await Lt():{},P=A??(U?.refusal?Tr(U.refusal):void 0),Q=d.writeCheck?.unwritable??[],ve=[w,Q.length>0?{code:"SYNC_TARGET_UNWRITABLE",message:So(Q,e.target,d.writeCheck?.heldBack)}:void 0,P!==void 0?{code:me,message:P}:void 0,...ne,I].filter(et=>et!==void 0),le=Date.now()-r;if(Ut(),Ne(Me(Ft("success",[...re.values()]),e.failOnPartial)),e.json){process.stdout.write(`${JSON.stringify({tool:"sandforge-sync",source:e.source,target:e.target,dryRun:!0,...Tt(e),simulation:d,...ae?{targetAutomation:ae}:{},...Bt(),...tr(p),...U?{checkpoint:U}:{},apiRequests:Pt(d.writeCheck?.apiRequests,y()),...wn(ve),elapsedMs:le},null,2)}
|
|
300
|
+
`);return}let Lo=(p?.plan?.assign.length??0)>0;for(let et of gs(d,e.target,Lo,P,I?.message))n(et);n(`
|
|
301
|
+
done in ${le}ms`);return}n(`
|
|
302
|
+
executing\u2026 (REAL)`);let Z=M?.pathOf(x),ce,_o=ot(o=>{ce=o,hn("the run stops before its next call, and its file keeps what it created",o),C.abort()}),zt=async()=>{!F||!L||B||(B=await Mr(F,L,W,e.target,i))},z,Xe={status:"failure"};try{z=await qt.execute(s).finally(async()=>{Se=await Ke?.release()}),Se&&(z={...z,mutedAutomation:Se}),Xe={status:Ft(z.status,[...re.values()]),...z.cancelled?{cancelled:!0}:{}},await zt()}catch(o){if(H?.close(),await zt(),!(o instanceof lo))throw await S?.end(Xe),Ve(),Z!==void 0&&Oe(Z)&&process.stderr.write(`the run stopped on an error; what it created is kept in ${Z}, and --remove ${fe(Z)} takes it back
|
|
303
|
+
`),o;Ve();let d=o.code===dt,p=d?[]:X;e.json?(d||process.stderr.write(`${[o,...p].map(_e).join(`
|
|
304
|
+
`)}
|
|
305
|
+
`),process.stdout.write(`${JSON.stringify({tool:"sandforge-sync",source:e.source,target:e.target,dryRun:!1,...Tt(e),refused:{code:o.code,message:o.message},...p.length>0?{alsoRefused:p}:{},...O?{writeCheck:O}:{},...B?{checkpoint:B}:{},apiRequests:Pt(O?.apiRequests,y()),elapsedMs:Date.now()-r},null,2)}
|
|
306
|
+
`)):n(d?`
|
|
307
|
+
${o.message}`:`
|
|
308
|
+
${[o,...p].map(_e).join(`
|
|
309
|
+
`)}`),process.exit(d?Pe(ce??"SIGINT"):1)}finally{_o()}await S?.end(Xe),Ve(),H?.close();let Gt=await S?.flush();Gt!==void 0&&process.stderr.write(`what the run created could not all be written to ${Z??"its file"} (${Gt}): --remove takes it back from the --json summary
|
|
310
|
+
`);let Jt=Date.now()-r,Ze=T.created(),Ht=T.lastWrittenAt(),Yt=T.firstWrittenAt(),Kt=T.lastWriteAt(),Ie=T.overwritten(),Qe=T.deletions(),Vt=Ze.length>0||Ie.length>0||Qe.length>0?j?.id??await Is(c):void 0,ue=Z!==void 0&&Oe(Z)?Z:void 0;Ut();let Ee=Ft(z.status,[...re.values()]);if(e.json){process.stdout.write(`${JSON.stringify({tool:"sandforge-sync",source:e.source,target:e.target,...Vt?{targetOrgId:Vt}:{},...a?{configId:s.id}:{},dryRun:e.dryRun,...Tt(e),startedAt:ie,finishedAt:new Date().toISOString(),result:{...z,status:Ee,...k!==void 0?{runUserId:k}:{}},...Bt(),...B?{checkpoint:B}:{},apiRequests:Pt(O?.apiRequests,y()),created:{runId:T.runId,...Ht?{lastWrittenAt:Ht}:{},...Yt?{firstWrittenAt:Yt}:{},...Kt?{lastWriteAt:Kt}:{},...ue?{runFile:ue}:{},objects:Ze,...Ie.length>0?{overwritten:Ie}:{},...Qe.length>0?{deleted:Qe}:{}},elapsedMs:Jt},null,2)}
|
|
311
|
+
`),ce&&process.exit(Pe(ce)),Ne(Me(Ee,e.failOnPartial));return}let Xt=z.objectResults??[];n(`
|
|
312
|
+
status: ${Ee}`);for(let o of Se?ge(Se,e.target):[])n(o);for(let o of Xt){n(` ${Rs(o)}`),typeof o.alreadyCopied=="number"&&n(` ${o.alreadyCopied} already copied by an earlier run of this configuration, left as they are`),typeof o.alreadyLinked=="number"&&n(` ${To(o.alreadyLinked)}`);for(let w of ws(o.errors??[]))n(` ${w}`);for(let w of Ss(o))n(` ${w}`);for(let w of $s(o.currenciesReplaced))n(` ${w}`);for(let w of As(o.pricesSettled,o.standardPricebookMatched===!0))n(` ${w}`);let d=o.files;d&&n(` files: ${d.copied??0} copied, ${d.versions??0} version(s) added, ${d.failed??0} failed`);let p=o.delta;p&&n(` ${Os(p)}`)}for(let o of Eo(Xt,!1))n(` ${o}`);for(let o of vs(z.contactPoints))n(` ${o}`);let Zt=Ze.reduce((o,d)=>o+d.ids.length,0),Qt=Ie.reduce((o,d)=>o+d.ids.length,0);Qt>0&&n(`
|
|
313
|
+
wrote over ${Qt} record(s) of ${e.target}, their values from before kept in ${ye(te,"backups")}: --remove ${ue!==void 0?fe(ue):"with the --json summary"} gives them back`),Zt>0&&n(`
|
|
314
|
+
created ${Zt} record(s) and file(s) in ${e.target}: `+(ue!==void 0?`--remove ${fe(ue)} takes them back`:"run with --json and save the summary to a file, and --remove takes them back from it")),n(`
|
|
315
|
+
done in ${Jt}ms`),ce&&process.exit(Pe(ce)),Ne(Me(Ee,e.failOnPartial))}var He=new Set(["--remove","--target","--include-changed","--accept-automation","--mute-automation","--store","--sweep","--sweep-list",...zr,"--leave-undeletable","--json"]),Ts=new Set(["--remove","--target","--store"]);function Fs(t){let r=t.slice(2);for(let h=0;h<r.length;h++){let l=r[h];if(Ts.has(l)){h++;continue}He.has(l)||(process.stderr.write(`--remove takes --target, --include-changed, --accept-automation, --mute-automation, --store, --sweep, --sweep-late, --sweep-untied, --sweep-list, --leave-undeletable and --json, not "${l}". Run with --help.
|
|
316
|
+
`),process.exit(2))}let e=h=>{let l=r.indexOf(h);return l>=0&&l+1<r.length?r[l+1]:void 0},n=e("--remove"),i=e("--target"),s=e("--store");r.includes("--store")&&(!s||He.has(s))&&(process.stderr.write(`--store wants the directory the configuration of the run is kept in.
|
|
317
|
+
`),process.exit(2)),(!n||!i||He.has(n)||He.has(i))&&(process.stderr.write(`--remove takes the file a run printed its --json summary to, or the run file it named as it began, or its run id, and --target the org the run wrote to. Run with --help.
|
|
318
|
+
`),process.exit(2)),r.includes("--sweep")&&r.includes("--sweep-list")&&(process.stderr.write(`--sweep deletes and --sweep-list only lists: give one of them. Run with --help.
|
|
319
|
+
`),process.exit(2));let a=Gr(r);return"refusal"in a&&(process.stderr.write(`${a.refusal} Run with --help.
|
|
320
|
+
`),process.exit(2)),{summaryPath:n,target:i,includeChanged:r.includes("--include-changed"),acceptAutomation:r.includes("--accept-automation"),muteAutomation:r.includes("--mute-automation"),json:r.includes("--json"),...s!==void 0?{store:s}:{},sweep:r.includes("--sweep"),sweepList:r.includes("--sweep-list"),...a,leaveUndeletable:r.includes("--leave-undeletable")}}var Ye=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,Ps=R.object({tool:R.literal("sandforge-sync"),source:R.string().min(1),target:R.string().min(1),targetOrgId:R.string().regex(Ye).optional(),configId:R.string().min(1).max(200).optional(),dryRun:R.boolean().optional(),startedAt:R.string().min(1).max(40).optional(),finishedAt:R.string().min(1).max(40).optional(),result:R.object({status:R.enum(["success","partial","failure"])}).loose(),created:R.object({runId:R.string().min(1).max(200),lastWrittenAt:R.string().min(1).max(40).optional(),firstWrittenAt:R.string().min(1).max(40).optional(),lastWriteAt:R.string().min(1).max(40).optional(),runFile:R.string().min(1).max(4096).optional(),objects:R.array(R.object({objectApiName:R.string().regex(D),ids:R.array(R.string().regex(Ye))})),overwritten:R.array(R.object({objectApiName:R.string().regex(D),backup:zn,ids:R.array(R.string().regex(Ye))})).optional(),deleted:R.array(R.object({objectApiName:R.string().regex(D),ids:R.array(R.string().regex(Ye))})).optional()}).optional()}).loose();function Ms(t){let r;try{r=JSON.parse(t)}catch{return{refusal:"is not JSON: save the output of a run printed with --json."}}let e=bn(r,"sandforge-sync");if(e)return{refusal:Rn(e)};let n=Ps.safeParse(r);if(!n.success){let i=n.error.issues[0];return{refusal:`is not the summary of a sandforge sync run (${i.path.join(".")||"summary"}: ${i.message}).`}}return n.data.dryRun===!0?{refusal:"is the summary of a dry run, which wrote nothing: there is nothing to remove."}:n.data.created?{summary:n.data}:{refusal:"names nothing the run created: it was printed before runs named what they created, so its records cannot be told from the ones it updated."}}function Ns(t){return/\.json$/i.test(t)?t.replace(/\.json$/i,".removals.json"):`${t}.removals.json`}function _s(t,r){let e=t.created,n=t.finishedAt??e?.lastWrittenAt??new Date().toISOString();return{runId:e?.runId??"sandforge-sync",configId:t.configId??"sandforge-sync",configName:t.configId??"sandforge-sync",sourceOrgId:t.source,targetOrgId:t.target,startedAt:t.startedAt??n,end:{at:n,status:t.result.status},...e?.lastWrittenAt?{lastWrittenAt:e.lastWrittenAt}:{},...e?.firstWrittenAt?{firstWrittenAt:e.firstWrittenAt}:{},...e?.lastWriteAt?{lastWriteAt:e.lastWriteAt}:{},created:(e?.objects??[]).filter(i=>i.ids.length>0),...(e?.overwritten??[]).some(i=>i.ids.length>0)?{overwritten:(e?.overwritten??[]).filter(i=>i.ids.length>0)}:{},...(e?.deleted??[]).some(i=>i.ids.length>0)?{deleted:(e?.deleted??[]).filter(i=>i.ids.length>0)}:{},...r?{removal:r}:{}}}function Ls(t,r,e="sandforge sync"){if(r.sandbox||tn(r.edition))return;let n=r.edition?`IsSandbox false, edition ${r.edition}`:"IsSandbox false, and no edition";return`${t} is a production org (its Organization record says ${n}): ${e} removes records from sandboxes and Developer Edition orgs only. Nothing was deleted.`}function Ds(t,r){let e=n=>[n.deleted>0?`${n.deleted} deleted`:"",n.alreadyGone>0?`${n.alreadyGone} already gone`:"",(n.notVisible??0)>0?`${n.notVisible} not visible`:"",n.keptChanged>0?`${n.keptChanged} kept, changed since the run`:"",n.keptDependents>0?`${n.keptDependents} kept, records that stay depend on them`:"",n.refused>0?`${n.refused} refused`:"",(n.notReached??0)>0?`${n.notReached} not reached`:""].filter(Boolean).join(", ");return[`removal: ${t.toUpperCase()}`,...r.flatMap(n=>[` ${n.objectApiName}: ${e(n)||"nothing"} of ${n.planned}${Wr(n)}`,...Ur(n),...n.reasons.map(i=>` ${i}`)])]}function Ws(t){return t.flatMap(r=>{let e=[r.keptChanged>0?`${r.keptChanged} left as they are, changed since the run`:"",r.alreadyGone>0?`${r.alreadyGone} no longer in the org`:"",r.refused>0?`${r.refused} refused`:"",r.notKept>0?`${r.notKept} whose values from before are no longer kept (their backup was deleted, or past its retention)`:"",(r.notReached??0)>0?`${r.notReached} not reached`:"",(r.restoredWithout??0)>0?`${r.restoredWithout} given back but for fields the org no longer takes, which keep the run's values`:""].filter(Boolean);return[` ${r.objectApiName}: ${r.restored} of ${r.planned} given back their values from before the run${e.length>0?`; ${e.join(", ")}`:""}`,...r.reasons.map(n=>` ${n}`)]})}function Us(t){return t.flatMap(r=>{let e=[r.alreadyBack>0?`${r.alreadyBack} back in the org already`:"",r.goneForGood>0?`${r.goneForGood} no longer in the recycle bin, gone for good`:"",r.refused>0?`${r.refused} refused`:"",(r.notReached??0)>0?`${r.notReached} not reached`:""].filter(Boolean);return[` ${r.objectApiName}: ${r.undeleted} of ${r.planned} the run deleted brought back from the recycle bin${e.length>0?`; ${e.join(", ")}`:""}`,...r.reasons.map(n=>` ${n}`)]})}function Bs(t,r){return t===void 0?[]:[...r.readWhole&&r.readWhole.length>0?[`configuration ${t}: its next run reads ${r.readWhole.join(", ")} whole`]:[],...(r.filesForgotten??0)>0?[`configuration ${t}: ${r.filesForgotten} copied file(s) forgotten, copied again by its next run`]:[],...(r.linksForgotten??0)>0?[`configuration ${t}: ${r.linksForgotten} record(s) forgotten, which no later run points a lookup at`]:[]]}var jo=3,qs=/^[A-Za-z0-9][A-Za-z0-9_-]{0,199}$/;function zs(t,r=Be(),e=Bn){if(Oe(t)){let i;try{i=we(t,"utf8").split(`
|
|
321
|
+
`).find(a=>a.trim()!=="")}catch{return}let s;try{s=JSON.parse(i??"")}catch{return}return typeof s=="object"&&s!==null&&"run"in s?Xo(t):void 0}if(!qs.test(t))return;let n=ye(r,e,`${t}.ndjson`);return Oe(n)?n:void 0}function Gs(t){let r=Ge(t.runUserId),e=Dr.safeParse(t.mutedAutomation);return{...r?{runUserId:r}:{},...e.success?{muted:e.data}:{}}}function Js(t,r,e){if(t===void 0||r===void 0)return;let n;try{n=lt(we(t,"utf8"))}catch{return}if(!(!n||n.runId!==r)&&!(e!==void 0&&n.configId!==e))return Ge(n.runUserId)}function Hs(t,r){let e;try{e=we(t.summaryPath,"utf8")}catch(y){process.stderr.write(`--remove ${t.summaryPath} cannot be read: ${y instanceof Error?y.message:String(y)}
|
|
322
|
+
`),process.exit(2)}let n=Ms(e);"refusal"in n&&(process.stderr.write(`--remove ${t.summaryPath} ${n.refusal}
|
|
323
|
+
`),process.exit(2));let{summary:i}=n;i.targetOrgId===void 0&&i.target!==t.target&&(process.stderr.write(`The run wrote to ${i.target}, and what it created is removed from that org only: give --target ${i.target}.
|
|
324
|
+
`),process.exit(2));let s=Ns(t.summaryPath),a,h;try{h=we(s,"utf8")}catch(y){y?.code!=="ENOENT"&&(process.stderr.write(`${s} cannot be read: ${y instanceof Error?y.message:String(y)}
|
|
325
|
+
`),process.exit(2))}if(h!==void 0){let y;try{y=JSON.parse(h)}catch{y=void 0}let b=y?.runId;a=b===i.created?.runId?Gn(y):void 0,b!==i.created?.runId?r(`${s} is of another run: it is not read, and this removal's takes its place`):a||(process.stderr.write(`${s} does not read as what earlier removals did.
|
|
326
|
+
`),process.exit(2))}let l=_s(i,a),u=a??{},c=Gs(i.result),g=c.runUserId??Js(i.created?.runFile,i.created?.runId);return{run:l,...i.configId!==void 0?{configId:i.configId}:{},...i.targetOrgId!==void 0?{targetOrgId:i.targetOrgId}:{},...a?{earlier:a}:{},...c,...g!==void 0?{runUserId:g}:{},updateRemoval:async y=>{u=y(u);let b=`${s}.${process.pid}.tmp`;Ko(b,`${JSON.stringify({version:1,runId:l.runId,...u},null,2)}
|
|
327
|
+
`,{mode:st}),Sn(b,st),Yo(b,s)}}}async function Ys(t,r){let e=ut(Vo(t),""),n;try{n=lt(we(t,"utf8"))}catch(a){process.stderr.write(`--remove ${t} cannot be read: ${a instanceof Error?a.message:String(a)}
|
|
328
|
+
`),process.exit(2)}n||(process.stderr.write(`--remove ${t} names no run of sandforge sync.
|
|
329
|
+
`),process.exit(2)),e.pathOf(n.runId)!==t&&(process.stderr.write(`--remove ${t} is the file of the run ${n.runId} under another name: give it as ${e.pathOf(n.runId)}, where what its removals did is kept beside it.
|
|
330
|
+
`),process.exit(2));let i=await e.get(n.runId)??n;i.targetOrganizationId===void 0&&i.targetOrgId!==r.target&&(process.stderr.write(`The run wrote to ${i.targetOrgId}, and what it created is removed from that org only: give --target ${i.targetOrgId}.
|
|
331
|
+
`),process.exit(2));let s=Ge(i.runUserId);return{run:i,...i.configId!==Mt?{configId:i.configId}:{},...i.targetOrganizationId!==void 0?{targetOrgId:i.targetOrganizationId}:{},...i.removal?{earlier:i.removal}:{},updateRemoval:a=>e.updateRemoval(i.runId,a),runs:e,...s?{runUserId:s}:{}}}function Ks(t,r){return t.map(({job:e,objectApiName:n,read:i})=>{let s=` Bulk API job ${e} (${n})`;switch(i.state){case"ended":return`${s}: the run's file holds no answer of it; it ended in ${r}, and the ${i.created.length} record(s) it created are removed with the rest`;case"never-closed":return`${s}: never closed, it wrote nothing`;case"running":return`${s}: still running in ${r}: what it creates stays, and the next --remove of the run reads it again`;default:return`${s}: could not be read back (${i.reason}): what it created stays`}})}async function Vs(t=process.argv){let r=Date.now(),e=Fs(t),n=f=>{process[e.json?"stderr":"stdout"].write(`${f}
|
|
332
|
+
`)},i=zs(e.summaryPath),s=i!==void 0?await Ys(i,e):Hs(e,n),{earlier:a}=s,h;e.store!==void 0&&(s.configId===void 0&&(process.stderr.write(`--store tells the configuration a run was of what its removal took, and ${e.summaryPath} names none: the run was not of a saved configuration (--config-file).
|
|
333
|
+
`),process.exit(2)),h=Oe(ye(e.store,"configStore.json"))?Co(e.store):void 0,h?.isSaved(s.configId)||(process.stderr.write(`${e.store} holds no configuration ${s.configId}: give the --store the run was made with.
|
|
334
|
+
`),process.exit(2)));let l=s.run;Un(l)&&Y({code:gn,message:`The run is still writing, in process ${l.writer?.pid??"?"}: remove it once it has ended. Nothing was deleted.`});let u,c=(f,m,O,A={},I,ne,X,ke)=>{if(e.json){process.stdout.write(`${JSON.stringify({tool:"sandforge-sync",action:"remove",summary:e.summaryPath,target:e.target,includeChanged:e.includeChanged,result:{status:f,planned:O,objects:m,...A,...I?{sweep:I}:{},...u?{sweepListing:u}:{},...ne?{restored:ne}:{},...X?{undeleted:X}:{},...ke?{mutedAutomation:ke}:{}},elapsedMs:Date.now()-r},null,2)}
|
|
335
|
+
`);for(let E of vt(m,e))n(E);return}for(let E of I?qr(I):[])n(E);for(let E of Ds(f,m))n(E);for(let E of vt(m,e))n(E);for(let E of X?Us(X):[])n(E);for(let E of ne?Ws(ne):[])n(E);for(let E of Bs(s.configId,A))n(E);n(`
|
|
336
|
+
done in ${Date.now()-r}ms`)},g=s.runs!==void 0&&(l.jobs??[]).length>0;if(ft(l).length===0&&ht(l).length===0&&pt(l).length===0&&!g&&!e.sweep&&!e.sweepList){let f=a?.undo?.removedAt??a?.restoredAt??a?.undeletedAt;n(f!==void 0?`what the run created was removed already, on ${f}`:"The run created nothing: there is nothing of it to remove."),c("success",[],0);return}let y=await Fe(e.target),b=Ae(y),C=await $e(b),j=e.sweepList?void 0:Ls(e.target,C);if(j&&Y({code:"PRODUCTION_TARGET",message:j}),s.targetOrgId!==void 0&&s.targetOrgId.slice(0,15)!==C.id.slice(0,15)&&Y({code:pn,message:`${e.target} is not the org the run wrote to (${s.targetOrgId}), and what it created is removed from that org only. Nothing was deleted.`}),g&&s.runs){let f=s.runs,m=await Xr(f,l,b,()=>Le(b,"sandforge sync --remove").serverTime());for(let O of Ks(m,e.target))n(O);m.some(O=>O.answered)&&(l=await f.get(l.runId)??l)}!l.end&&l.inFlight&&l.inFlight.job===void 0&&n(` the run stopped during a call of ${l.inFlight.rows} ${l.inFlight.objectApiName} row(s): those ${e.target} took are not in its file, and stay; ${St("--sweep-list")} shows what the run's user created in the run's window`);let x=ft(l),T=async f=>{let m;try{m=await ze(b).read(e.target,[...new Set([...l.created,...l.overwritten??[]].map(I=>I.objectApiName).filter(I=>!qn.includes(I)))])}catch(I){m={error:I instanceof Error?I.message:String(I)}}let O=Le(b,"sandforge sync --sweep"),A=Vr({otherRuns:await Kr({organizationId:C.id,alias:e.target,span:Yr(l),own:{runId:l.runId,ids:l.created.flatMap(I=>I.ids)}}),...s.muted?{muted:s.muted}:{},...a?.removalSpans?{removalSpans:a.removalSpans}:{},...a?.madeEarlier?{made:a.madeEarlier}:{},...a?.lateEarlier?{late:a.lateEarlier}:{}});return so(O,l.created,m,f,l.firstWrittenAt!==void 0?{at:l.firstWrittenAt,...l.lastWriteAt!==void 0?{lastAt:l.lastWriteAt}:{},serverTime:()=>O.serverTime()}:void 0,l.overwritten??[],{...s.runUserId?{runUserId:s.runUserId}:{},ties:A})};if(e.sweepList){let f=await $r($t(b,"sandforge sync --sweep-list"),await T(),a?.removalSpans??[]);for(let m of Je(f,e.target,e,!0))n(m);e.json?process.stdout.write(`${JSON.stringify({tool:"sandforge-sync",action:"sweep-list",summary:e.summaryPath,target:e.target,listing:f,elapsedMs:Date.now()-r},null,2)}
|
|
337
|
+
`):n(`
|
|
338
|
+
done in ${Date.now()-r}ms`),f.refusal!==void 0&&process.exit(jo);return}let M=ht(l),S,k={kept:[...M],notKept:0};if(M.length>0){let f=At(),m=Ot(f);if(m!==void 0)n(m);else{S=new wt(mt(f));let O=qe(ye(f,"snapshots.json"));k=Zn(M,A=>O.get(`backup:${A}`),30)}}n(`sandforge sync --remove ${e.summaryPath} from ${e.target}`);for(let{objectApiName:f,ids:m}of k.kept)n(` ${f}: ${m.length} to give back their values from before the run`);k.notKept>0&&n(` values from before no longer kept (past sandforge.backup.maxAgeDays, or deleted): ${k.notKept} record(s) the run wrote over keep its values`),k.keptUntil!==void 0&&k.kept.length>0&&n(` values from before kept until ${k.keptUntil}, at the default retention`);let v=pt(l);for(let{objectApiName:f,ids:m}of v)n(` ${f}: ${m.length} the run deleted, as the source had, to bring back from the recycle bin`);for(let{objectApiName:f,ids:m}of x)n(` ${f}: ${m.length} to remove`);x.length===0&&M.length===0&&v.length===0&&n("nothing left of the run to remove"),e.sweep&&n(`before them, a sweep deletes what the target's automation made for the run, as the run's user, tied to its records \u2014 run ${St("--sweep-list")} to see what`);let N=new AbortController,ee=ot(()=>N.abort()),G=a??{},F=e.sweep?Ar($t(b,"sandforge sync --sweep",N.signal),await T(N.signal),{includeChanged:e.includeChanged,removalSpans:G.removalSpans??[],...Jr(e),approve:async f=>{u=f,n("");for(let m of Je(f,e.target,e))n(m)}}):void 0;await F?.ask();let J=Br(F,u);if(J){u=J,n("");for(let f of Je(J,e.target,e))n(f)}let se=f=>[...new Set(f.map(({objectApiName:m})=>m))],te=Le(b,"sandforge sync --remove"),H=await to(te,l.created),q=an({bringBack:se(v),giveBack:se(k.kept),setToDraft:_n(se(x)),delete:no(se(x),H,{userKept:s.runUserId!==void 0})},F?.takes??[]),je=[...new Set(Object.values(q).flat())];function Y(f){return process.stderr.write(`${_e(f)}
|
|
339
|
+
`),e.json&&process.stdout.write(yn({tool:"sandforge-sync",summary:e.summaryPath,target:e.target,elapsedMs:Date.now()-r},f)),process.exit(1)}let K=f=>(ee(),Y(f)),W;if(je.length>0&&!N.signal.aborted){let f=await ze(b).read(e.target,je,{undeletes:!0});n("");for(let A of Rr(f,e.target,q))n(A);if(e.muteAutomation)try{W=await Ue(async()=>De(b),f,{writes:dn(q)});for(let A of ge(W.muted,e.target))n(` ${A}`)}catch(A){if(!We(A))throw A;K(A.refusal)}let m=W?.automation??f,O=kr(m,e.target,{steps:q,assign:br(m,cn(m,q)),mayMute:W===void 0&&bt("--mute-automation")});O&&!e.acceptAutomation&&K({code:"AUTOMATION_NOT_ACCEPTED",message:O})}let $,ie,_=W?.muted,U=async()=>{!W?.prepared||N.signal.aborted||(ie=await W.prepared.acquire(`sandforge sync --remove ${l.runId}`).catch(f=>{if(!We(f))throw f;return K(f.refusal)}),_=ie.outcome)},L={},B;try{$=await Kn({run:l,org:te,includeChanged:e.includeChanged,...Hr(F),...s.runUserId?{runUserId:s.runUserId}:{},onUndeletable:Nr(e.leaveUndeletable,e.target,f=>{B=f}),beforeFirstWrite:U,signal:N.signal,...h&&e.store!==void 0?{configs:h,links:ct(e.store)}:{},...S?{backups:S}:{},undelete:f=>b.soap.undelete(f),...s.runs?{earlierRuns:Hn(l,await s.runs.list())}:{},store:{updateRemoval:(f,m)=>f!==l.runId&&s.runs?s.runs.updateRemoval(f,m):s.updateRemoval(O=>(G=m(O),G))}}),$.result.status!=="cancelled"&&!$.stoppedForUndeletable&&(L=await H.take($.duplicateSets))}finally{ee();let f=F?.made??new Set,m=F?.late??new Set,O=F?.gone??new Set;if((f.size>0||m.size>0||O.size>0)&&await s.updateRemoval(A=>io(A,f,m,O)).catch(A=>{process.stderr.write(`What the sweep found made for the run could not be kept (${A instanceof Error?A.message:String(A)}): a later --sweep may list it as tied to nothing.
|
|
340
|
+
`)}),ie){_=await ie.release();for(let A of ge(_,e.target))n(A)}}_&&($={...$,result:{...$.result,mutedAutomation:_}}),$.stoppedForUndeletable&&(B&&Y(B),process.exit(1));for(let f of[...$.notes,...L.note?[L.note]:[]])process.stderr.write(`${f}
|
|
341
|
+
`);let Ce=$.result.objects.some(f=>f.deleted+f.alreadyGone>0);s.configId!==void 0&&!h&&Ce&&process.stderr.write(`The run was of the saved configuration ${s.configId}, and its store was not given: its next delta run is not told what this removal took, and a later run may point a lookup at a record it deleted. Give ${vr("--store")} with the next removal, or run the configuration full next time.
|
|
342
|
+
`);let{readWhole:ae,filesForgotten:be}=$.result,Re=F?.result(),xe=Ln(ro($.result.status,L),Re);if(it({action:"cleanup_delete",orgId:C.id,objects:Yn(Dn($.result.objects),$.result.restored??[],$.result.undeleted??[])}),e.json)for(let f of oo(L,e.target))n(f);let V=L.object?[...$.result.objects,L.object]:$.result.objects;c(xe,V,V.reduce((f,m)=>f+m.planned,0),{...ae?{readWhole:ae}:{},...be!==void 0?{filesForgotten:be}:{},...$.linksForgotten!==void 0?{linksForgotten:$.linksForgotten}:{}},Re,$.result.restored,$.result.undeleted,_),xe!=="success"&&process.exit(jo)}process.argv[1]?.includes("sandforge-sync")&&(_r(),Es().then(()=>process.exit(process.exitCode??0)).catch(t=>{process.stderr.write(`${t instanceof Error?t.message:String(t)}
|
|
343
|
+
`),process.exit(1)}));export{Zo as a,rs as b,os as c,ss as d,is as e,as as f,Co as g,ds as h,cs as i,Ao as j,us as k,Ft as l,ls as m,fs as n,hs as o,Oo as p,Pt as q,Io as r,Eo as s,To as t,gs as u,ws as v,Rs as w,Ss as x,Fo as y,vs as z,$s as A,As as B,Os as C,js as D,Cs as E,Mt as F,Es as G,Fs as H,Ms as I,Ns as J,_s as K,Ls as L,Ds as M,Ws as N,Us as O,Bs as P,zs as Q,Js as R,Ks as S,Vs as T};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
var r={components:500,seconds:90},a=3e4,o=10;function d(e){if(e===void 0)return r;let{components:n,seconds:t}=r;return{components:e,seconds:Math.max(t,Math.ceil(e*t/n))}}function u(e){return Math.ceil(e/o)}export{r as a,a as b,d as c,u as d};
|