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
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{b as Yt}from"./chunk-PE7CHD2W.mjs";import{b as ie,c as se,d as to,e as oo,f as be}from"./chunk-VKREON6Q.mjs";import{e as Jt,i as Qt}from"./chunk-7O6EFNQS.mjs";import{I as re,O as Le,a as Zt}from"./chunk-3LRFPGYZ.mjs";import{f as Be,p as ge,s as $e,u as eo,w as qe}from"./chunk-KWUS7UAV.mjs";import{b as me,d as ue}from"./chunk-GP5J3DGS.mjs";import{c as Kt}from"./chunk-OT2NHL2V.mjs";import{G as Vt}from"./chunk-4XROG5CT.mjs";import{c as Xt}from"./chunk-DAUX63UB.mjs";import{c as Ht,e as Me,g as Ue,h as pe}from"./chunk-TZE3Y7IQ.mjs";import{a as Wt,b as V}from"./chunk-CA5NAXSU.mjs";import{$b as Fe,Ad as Lt,Bd as Bt,C as mt,Cd as $t,D as ut,Dc as Ft,E as gt,F as bt,Fe as qt,Ge as Gt,Ha as xt,Ia as It,J as ft,K as yt,L as ht,M as zt,N as St,Na as ae,Oa as Ee,Sa as M,Ta as kt,Ua as F,Va as Ce,Vb as At,Wa as jt,Xa as Pt,Ya as Te,Za as _e,_a as Ne,_b as vt,fb as De,ib as Ot,jb as Rt,kb as wt,kd as Mt,n as st,oc as Et,qc as Ct,rc as Tt,s as Ae,sd as Ut,t as ct,u as lt,uc as _t,v as dt,vc as Nt,w as ne,wc as Dt,y as pt,z as ve}from"./chunk-J347SPU6.mjs";import{b as a,c as Oe,e as g,f as r,g as nt,i as D,k as c,l as o,m as Re,o as de,p as we,s as x,u as w,v as A,w as at,x as rt,y as G,z as it}from"./chunk-WZQEK4WT.mjs";function da(e,t,n){return async s=>{let d=s.map(f=>`${f.objectApiName} (${f.records})`).join(", ");e.log(`[WARN] ${n}: the user may not delete ${d} in the target: those records stay`);let p=e.infraServices?.confirmRemovalLeavingUndeletable;if(!p)return!0;let u=e.orgManager.getOrg(t);return p({org:Mt(u,t),objects:s})}}var no={code:"NOT_INITIALIZED",message:"Production Guard is not initialized \u2014 infrastructure services missing"};function pa(){return Object.assign(new Error(no.message),{code:no.code})}var Ge={blocked:"GUARD_BLOCKED",declined:"GUARD_DECLINED"};function ma(e){return Object.assign(new Error(`Operation blocked by Production Guard: ${e}`),{code:Ge.blocked})}function ua(e){return e instanceof Error&&e.code===Ge.blocked?Ge.blocked:void 0}function qo(e){return e.robustness??xt}function ga(e){return e.bulkManager??new Zt(qo(e).bulk.maxConcurrentJobs)}var Go={"sync:schedule":"sync:schedule:","sync:pipeline":"sync:pipeline:","seed:pipeline":"seed:pipeline:","offline-replay":"offline-replay-"};function ba(e,t,n){return{id:`${Go[e]}${t}`,type:n,timestamp:Date.now()}}function fa(e,t,n,s){return{id:e.nextId(),type:n,timestamp:Date.now(),correlationId:t.id,payload:s}}function ya(e,t,n,s,d={}){let p=t==="error"?null:d.autoDismissMs===void 0?5e3:d.autoDismissMs,u={id:e.nextId(),type:"notification",timestamp:Date.now(),payload:{level:t,title:n,message:s,...p===null?{}:{autoDismissMs:p},...d.actions?{actions:d.actions}:{},...d.code?{code:d.code}:{}}};e.broker.postToWebview(u),e.log(`[TX] notification: ${n}`)}function ha(e,t,n,s){let d={id:e.nextId(),type:"operation:started",timestamp:Date.now(),payload:{operationId:t,module:n,description:s}};e.broker.postToWebview(d)}function za(e,t,n,s,d,p,u){let f={id:e.nextId(),type:"operation:progress",timestamp:Date.now(),payload:{operationId:t,percentage:n,processedRecords:s,totalRecords:d,currentStep:p,...u}};e.broker.postToWebview(f)}function Sa(e,t,n){let s={id:e.nextId(),type:"operation:completed",timestamp:Date.now(),payload:{operationId:t,result:n}};e.broker.postToWebview(s)}var Wo=Symbol("sandforge.uncorrelated");function ao(e,t,n,s,d,p={}){let u=V(d),f=d instanceof Kt?d:void 0,k=Wo in s,E=p.code??f?.code??"UNKNOWN";k||Xo(e.broker,u,E),e.log(`[ERR] ${t}: ${u}${k?` (uncorrelated: ${String(s.reason)})`:""}`);let O={id:e.nextId(),type:n,timestamp:Date.now(),...k?{}:{correlationId:s.id},payload:{message:u,code:E,retryable:p.retryable??!1,...f?{orgId:f.orgId}:{},...p.extraPayload}};e.broker.postToWebview(O),e.log(`[TX] ${n}: ${u}`)}function xa(e,t){let n={id:e.nextId(),type:t.type,timestamp:Date.now(),payload:t.payload};e.broker.postToWebview(n)}function Ia(e){let t=e?.getSandforgeSetting;if(!(!t||!t("grappe.enabled",!1)))return{enabled:!0,autoActivateThreshold:t("grappe.autoActivateThreshold",1e4),maxWorkers:st.maxWorkers,grappeSize:t("grappe.grappeSize",5e3),strategy:"round_robin",backPressure:{enabled:!1,maxQueueDepth:3,highWaterMark:80,lowWaterMark:60,strategy:"pause",monitoringInterval:5e3},checkpointing:!0,isolationLevel:"per_grappe"}}function ka(e){let t=new Set(e.map(s=>s.batchSize)),[n]=t;return{...e.length>0?{objectName:e.map(s=>s.objectApiName).join(", ")}:{},...t.size===1&&n!==void 0?{batchSize:n}:{}}}function ja(e,t,n,s,d={}){let p={id:e.nextId(),type:"operation:failed",timestamp:Date.now(),payload:{operationId:t,error:n,retryable:s,...d.extraPayload}};e.broker.postToWebview(p),d.authored!==!0&&Yo(e,n,d.context)}var Ko=[/^Operation cancelled by user\b/,/^Operation blocked by Production Guard: /,/^Production Guard is not initialized\b/,/^Duplicate operation: /,/^A backup or rollback operation is already running for org /,/^Object describe not available for '/,/^CRUD_FLS_DENIED: /,/^CRUD\/FLS check failed for /,/^No backup found for operation /,/^Backup \S+ was taken from org /,/^Restore not run: /,/^Pipeline failed$/,/^Pipeline did not start: /,/^Pipeline ran out of time: /,/^Org not found: /,/^No credentials for org /,/^Invalid username format: /];function Ho(e){return Ko.some(t=>t.test(e))}var ro=1e4,We=new WeakMap;function Xo(e,t,n){let s=Fe(t,{code:n});if(!s?.actionKey)return;let d=We.get(e)??new Map,p=Date.now();for(let[u,f]of d)p-f>ro&&d.delete(u);d.set(s.code,p),We.set(e,d)}function Zo(e,t){let n=We.get(e)?.get(t);return n!==void 0&&Date.now()-n<=ro}function Yo(e,t,n={}){if(!(e.broker.panelCount>0)||Ho(t))return;let d=Wt(t,vt)??"UNKNOWN",p=Fe(t,{code:d});if(p?.actionKey){if(Zo(e.broker,p.code))return;e.broker.showFixSuggestion({source:"catalogue",code:p.code,actionKey:p.actionKey});return}let u=e.errorResolver;u&&u.resolveError({errorCode:d,message:t},n).then(f=>{e.broker.showFixSuggestion({source:"model",text:Vo(f)})}).catch(f=>{e.log?.(`[ERR] operation:failed resolution: ${V(f)}`)})}function Vo(e){return e.suggestions[0]?.description||e.explanation}import{isAbsolute as nn}from"node:path";var i=a().min(1).max(128),l=a().regex(/^[A-Za-z][A-Za-z0-9_]*$/,"Invalid Salesforce API name").max(80),Xe=c(l).max(300),m=a().min(1).max(200),J=a().max(2e3).refine(Me,{message:Ue}),an=a().refine(Ht,{message:"ORDER BY clause must list only field names with optional ASC/DESC and NULLS FIRST/LAST (no LIMIT, OFFSET, FOR UPDATE or subquery)."}),y=100,po=1e4,B=o({keepDays:g().int().min(ve.min).max(ve.max).optional(),excluded:c(l).max(y).refine(e=>new Set(e).size===e.length,"An object is left out twice").optional()}).strict(),he={sweepLate:r().optional(),sweepUntied:r().optional()};function rn(e){return Xt(e)}function sn(e,t='turn on "Copy the files of these records"'){return Ft(e)?`Sync copies files with the records they hang on, not as an object of their own: "${e}" keeps its content in a file body. Remove it from this configuration and ${t} instead; the sync was not started.`:`Sync does not copy "${e}": no copy writes it \u2014 users and their access, metadata, a record's history, feed or sharing rows, and the records the platform keeps for itself are not data a copy carries. Remove it from this configuration; the sync was not started.`}var cn=w(ft,{error:e=>e.input==="manual"?"Manual conflict review is not available for a sync run: no run shows its conflicts to anyone before it writes. Pick source wins, target wins, newest wins or merge \u2014 target wins keeps every value the target holds where the two orgs differ. The sync was not started.":`Conflict strategy "${String(e.input)}" is not one a sync run acts on: pick source wins, target wins, newest wins or merge. The sync was not started.`}),ln=yt.extend({objectApiName:l.refine(e=>!rn(e),{error:e=>sn(String(e.input))}),externalIdField:rt(e=>typeof e=="string"&&e.trim()===""?void 0:e,l.optional()),where:J.optional(),orderBy:an.optional(),batchSize:g().int().positive().max(po).optional()}).strip().refine(e=>e.operation!=="upsert"||(e.externalIdField??"Id").toLowerCase()!=="id",{path:["externalIdField"],error:e=>`An upsert of "${String(e.input.objectApiName)}" needs an External ID field: matching on Id cannot work, because the id belongs to the source org and the target has never issued it. Name an External ID field both orgs share, or set the operation to insert. The sync was not started.`}).superRefine((e,t)=>{let n=Bt([e]);n.length!==0&&t.addIssue({code:G.custom,message:`${$t(n)} The sync was not started.`,params:{unreadablePatterns:n}})});function io(e){return nt({error:()=>`Sync does not run Apex: remove "${e}" from this configuration. The sync was not started so the script cannot be skipped without you knowing.`}).optional()}var Ze=ht.extend({id:m.optional(),sourceOrgId:i,targetOrgId:i,objects:c(ln).min(1).max(y),conflictStrategy:cn,createdAt:a().max(40).optional(),updatedAt:a().max(40).optional(),preScript:io("preScript"),postScript:io("postScript"),dryRun:A(!1,{error:()=>'A sync configuration cannot ask for a dry run: remove "dryRun" from it. A run of it writes to the target org; to see what it would write, simulate it from the Sync page. The run was not started, so it cannot write while you believed it was only reporting.'}).optional()}).strip().superRefine((e,t)=>{e.direction==="target_to_source"&&t.addIssue({code:G.custom,path:["direction"],message:'Sync writes source to target only: direction "target_to_source" is not supported. Swap the source and target orgs to copy the other way. The sync was not started, so it cannot write into the org you meant to read from.'}),e.mode!=="full"&&e.mode!=="delta"&&t.addIssue({code:G.custom,path:["mode"],message:`Sync runs a full or a delta sync only: mode "${e.mode}" is not implemented. Set mode to "full" or "delta". The sync was not started, so it cannot replay the whole object set while you believed it was reading changes only.`}),e.mode==="delta"&&e.objects.forEach((n,s)=>{n.operation==="upsert"||n.operation==="update"||t.addIssue({code:G.custom,path:["objects",s,"operation"],message:`A delta sync writes ${n.objectApiName} again for every record it reads twice, and ${n.operation} would ${n.operation==="insert"?"create a second copy":"delete a record already gone"}. Write it by upsert on an External ID, or by update, or run the configuration in full. The sync was not started.`})}),e.propagateDeletes===!0&&(e.mode!=="delta"?t.addIssue({code:G.custom,path:["propagateDeletes"],message:'Deletions are carried by a delta sync only, which knows since when to look for them: set mode to "delta", or turn deletions off. The sync was not started.'}):e.objects.forEach((n,s)=>{if(n.operation!=="upsert"&&n.operation!=="update")return;let d=Vt(n);"refused"in d&&t.addIssue({code:G.custom,path:["objects",s],message:`${d.refused} Turn deletions off, or carry a source field onto the key. The sync was not started.`})}))}),Na=o({suggestedName:a().min(1).max(255).refine(e=>!e.includes("/")&&!e.includes("\\"),"suggestedName must not contain a path"),content:a().max(32*1024*1024),extensions:c(a().regex(/^[A-Za-z0-9]+$/)).max(8).optional()}),Da=o({config:Ze,muteAutomation:r().optional(),checkpointFirst:B.optional()}),Fa=o({config:Ze,checkpointFirst:B.optional()}),Ma=o({operationId:m}),Ua=o({config:Ze}),La=o({id:m}),Ba=o({orgId:i,targetOrgId:i.optional()}),$a=o({sourceOrgId:i,targetOrgId:i,objectApiName:l}),mo=w(["source_wins","target_wins","newest_wins","manual","merge"]),dn=we("kind",[o({kind:A("id")}),o({kind:A("externalId"),field:l}),o({kind:A("syncConfig"),configId:m})]),qa=o({sourceOrgId:i,targetOrgId:i,watchedObjects:c(l).min(1).max(y),apply:c(o({objectApiName:l,match:dn,applyDeletes:r()})).max(y),conflictStrategy:mo,flushIntervalMs:g().int().min(50).max(6e4),maxBatchSize:g().int().min(1).max(200),keepContactPoints:r().optional()}).refine(e=>e.apply.every(t=>e.watchedObjects.includes(t.objectApiName)),{message:"Every applied object must be watched.",path:["apply"]}),Ga=o({sessionId:a().max(200)}),Wa=o({sourceOrgId:i,targetOrgId:i}),Ka=o({conflictId:a().min(1).max(500),eventReplayId:g().optional(),resolution:mo,fieldResolutions:x(a(),o({value:D(),source:w(["source","target","manual"])})).optional()}),Ha=o({entryId:m}),Xa=o({runId:m}),Za=o({realtime:A(!0).optional()}).optional(),Ya=o({sourceOrgId:i,targetOrgId:i,objects:c(l).max(y),configId:m.optional()}),Va=o({runId:m,includeChanged:r().optional(),sweep:r().optional(),again:r().optional(),muteAutomation:r().optional(),...he}),Ja=o({runId:m}),Qa=o({runId:m,again:r().optional(),sweptObjects:Xe.optional()}),er=o({runId:m}),tr=o({runId:m,includeChanged:r().optional(),sweep:r().optional(),again:r().optional(),muteAutomation:r().optional(),...he}),or=o({runId:m}),nr=o({runId:m,again:r().optional(),sweptObjects:Xe.optional()}),ar=o({format:w(["csv","json"]),entryIds:c(m).max(500).optional()}),pn=o({id:m,name:a().min(1).max(200),configId:m,cron:a().min(1).max(100),timezone:a().min(1).max(100),enabled:r(),maxRetries:g().int().min(0).max(10),notifyOnComplete:r(),notifyOnFailure:r(),createdAt:a().max(40),updatedAt:a().max(40),version:g().int().positive()}).strip(),rr=o({schedule:pn}),ir=o({scheduleId:m,enabled:r()}),sr=o({scheduleId:m}),mn=mt.extend({objectApiName:l,recordCount:g().int().positive().max(ne),batchSize:g().int().positive().max(po).optional()}).loose(),un=ut.extend({childObject:l,lookupField:l,parentObject:l}).superRefine((e,t)=>{e.parents.kind==="existing"&&e.parents.where!==void 0&&!Me(e.parents.where)&&t.addIssue({code:G.custom,path:["parents","where"],message:Ue})}),gn=gt.extend({objects:c(mn).min(1).max(y),relations:c(un).max(y).optional()}).loose().superRefine(bt),cr=o({orgId:i,template:gn,muteAutomation:r().optional(),checkpointFirst:B.optional(),fit:o({share:g().gt(0).max(1),withinMB:g().positive().max(1e6).optional(),before:g().int().positive().max(ne*y)}).strict().optional(),locale:a().regex(/^[a-z]{2,3}(?:_[A-Za-z0-9]{2,4}){0,2}$/).optional(),dryRun:r().optional()}),lr=o({orgId:i}),dr=o({orgId:i,objects:c(l).min(1).max(y),publishes:r().optional()}).strict(),pr=o({orgId:i,objectApiName:l}),mr=o({id:m}),ur=o({template:x(a(),D())}),gr=o({description:a().max(1e4)}),br=o({}).strict(),fr=o({orgId:i,pack:ae,seed:Ee.shape.seed,articleBodyField:l.optional()}).strict(),yr=o({orgId:i,pack:ae,options:Ee,locale:a().regex(/^[a-z]{2,3}(?:_[A-Za-z0-9]{2,4}){0,2}$/).optional(),muteAutomation:r().optional(),checkpointFirst:B.optional()}).strict(),hr=o({orgId:i}).strict(),zr=o({pack:ae,overwrite:r().optional()}).strict(),Sr=o({runId:m,choice:At,overwrite:r().optional()}).strict(),bn=131072,fn=o({objectApiName:l,whereClause:J.optional()}).loose(),xr=o({sourceOrgId:i}),Ir=o({sourceOrgId:i,targetOrgId:i,objects:c(fn).min(1).max(y),upsert:r().optional(),externalIdField:l.optional(),previewId:m.optional(),keepContactPoints:r().optional(),checkpointFirst:B.optional()}).refine(e=>!e.upsert||e.externalIdField!==void 0,{message:"externalIdField is required when upsert is true",path:["externalIdField"]}),yn=o({csvHeader:a().min(1).max(500),sfFieldApiName:a().max(80),sfFieldType:a().max(40),sfFieldLength:g().int().positive().nullable()}).loose(),kr=o({orgId:i,objectApiName:l,records:c(x(a(),a().max(bn))).min(1).max(lt),columnMappings:c(yn).min(1).max(dt),externalIdField:l.optional(),checkpointFirst:B.optional()}),jr=o({orgId:i,objects:c(l).min(1).max(y),wheres:x(l,J).optional(),slices:r().optional()}).refine(e=>Object.keys(e.wheres??{}).every(t=>e.objects.some(n=>n.toLowerCase()===t.toLowerCase())),{message:"A filter names an object the backup reads: give it in objects",path:["wheres"]}),Pr=o({orgId:i}),Or=o({orgId:i,templateId:a().min(1).max(200).optional()}),Rr=o({orgId:i,operationId:a().min(1).max(200)}),wr=o({orgId:i,operationIds:c(a().min(1).max(200)).min(1).max(1e3).optional()}),W={acceptAutomation:r().optional(),acceptEmails:r().optional(),muteAutomation:r().optional()},Z={fromPage:A(!0).optional()},Ar=o({orgId:i,operationId:m,rewriteAll:r().optional(),includeChanged:r().optional(),slices:c(g().int().positive()).min(1).max(pt*y).optional(),...W,...Z}),vr=o({orgId:i,act:w(["masking","restore","cleanup"]),objects:c(o({objectApiName:l,records:g().int().min(0)})).max(y),erasure:r().optional(),...W,...Z}),Ye={objects:c(l).min(1).max(y).optional(),where:J.optional()},Ve=e=>e.where===void 0||e.where.trim()===""||e.objects?.length===1,Je={message:"A WHERE clause filters the rows of one object: name exactly one in objects",path:["where"]},Er=o({orgId:i,templateId:m,...Ye,resumeFrom:m.optional(),snapshot:r().optional(),slices:r().optional(),maxRequests:g().int().positive().max(1e9).optional(),abandon:r().optional(),purgeHistory:r().optional(),...W,...Z}).refine(Ve,Je).refine(e=>!(e.snapshot===!0&&e.resumeFrom!==void 0&&e.slices!==!0),{message:"A resume takes no snapshot: the run it resumes has written over some of its rows",path:["snapshot"]}).refine(e=>!(e.slices===!0&&e.snapshot===!1),{message:"A run in slices backs each slice up before it masks it: it cannot keep no snapshot",path:["slices"]}).refine(e=>e.maxRequests===void 0||e.slices===!0,{message:"A bound on requests stops a run in slices between two of them: give slices too",path:["maxRequests"]}).refine(e=>e.abandon!==!0||e.resumeFrom===void 0&&e.snapshot!==!0&&e.maxRequests===void 0&&e.purgeHistory!==!0,{message:"Giving up a set of slices masks nothing: it takes no resume, snapshot or bound",path:["abandon"]}),Cr=o({orgId:i,templateId:m,...Ye,slices:r().optional()}).refine(Ve,Je),Tr=o({orgId:i,templateId:m,...Ye}).refine(Ve,Je);function hn(e){let t=e.filter(s=>/salt/i.test(s));return t.length>0?`A template carries no salt: the run draws its key as it starts. Take ${t.join(", ")} out of the file`:`${e.map(s=>`"${s}"`).join(", ")} ${e.length===1?"is not a key":"are not keys"} of a template, which takes name and rules`}var _r=Re({name:a().trim().min(1).max(Ot),rules:c(wt).min(1).max(Rt).refine(e=>new Set(e.map(t=>t.fieldPattern.toLowerCase())).size===e.length,"A field has two rules")},{error:e=>e.code==="unrecognized_keys"?hn(e.keys):void 0}),Nr=o({templateId:m}),Dr=o({fileName:a().trim().min(1).max(255),content:a().max(Ut)}),Fr=o({orgId:i,templateId:m,objects:c(l).min(1).max(10).optional()}),Mr=o({orgId:i,objectNames:c(l).min(1).max(y)}),Ur=o({orgId:i,objects:c(o({objectApiName:l,duplicateKey:l.optional()})).min(1).max(10).refine(e=>new Set(e.map(t=>t.objectApiName.toLowerCase())).size===e.length,{message:"Each object may be named once per scan"}),staleDays:g().int().min(1).max(3650)}),uo=c(l).min(1).max(10).refine(e=>new Set(e.map(t=>t.toLowerCase())).size===e.length,{message:"Each object may be named once per request"}),Lr=o({orgId:i,objects:uo}),Br=o({orgId:i,objects:uo,requestId:Oe().optional(),email:a().trim().refine(Nt,"Not an email address").optional(),name:a().refine(Dt,"Not a name").optional(),phone:a().refine(_t,"Not a phone number").optional()}).refine(e=>e.email!==void 0||e.name!==void 0||e.phone!==void 0,{message:"A search needs an email address, a name or a phone number"}),zn=o({orgId:i,requestId:Oe()}),ze=a().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,"Not a record Id"),$r=o({runId:m,recordId:ze}).strict(),qr=zn.extend({mode:w(["anonymize","delete"]),records:c(o({objectApiName:l,ids:c(ze).min(1).max(200)})).min(1).max(10).refine(e=>new Set(e.map(t=>t.objectApiName.toLowerCase())).size===e.length,{message:"Each object may be named once per request"}),dryRun:r(),purgeHistory:r().optional(),...W}),Sn=we("kind",[o({kind:A("stale"),days:g().int().min(1).max(3650)}),o({kind:A("orphans"),fieldApiName:l}),o({kind:A("duplicates"),keyField:l})]),go=o({orgId:i,objectApiName:l,recommendation:Sn}),Gr=go.extend({after:o({skip:g().int().nonnegative().max(1e8),id:ze.optional(),modified:a().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:?\d{2})$/).optional()}).strict().optional()}),Wr=go.extend({dryRun:r(),...W,...Z}),Ke=2e3,bo={mode:w(["objects","org"]),objects:c(l).min(1).max(Ke).optional(),excluded:c(l).max(Ke).optional(),customSettings:r().optional(),files:r().optional(),managedPackages:r().optional(),unrestorable:r().optional()},xn=o(bo).strict().refine(e=>e.mode==="objects"==(e.objects!==void 0),{message:"The objects picked are named in objects mode, and only there"}),Kr=o({orgId:i,...bo,objects:c(l).max(Ke).optional()}).strict().refine(e=>e.mode==="objects"==(e.objects!==void 0),{message:"The objects picked are named in objects mode, and only there"}),Hr=o({orgId:i,request:xn,deleteMode:w(["recycle","hard"]),checkpointFirst:r().optional(),acceptNoUndo:r().optional(),acceptPeopleActive:r().optional(),...W,...Z}),Xr=o({orgId:i,previewId:m.optional(),resumeRunId:a().regex(/^em-\d{8}-\d{6}-[a-z0-9]{4}$/).optional(),acceptNoUndo:r().optional(),acceptPeopleActive:r().optional(),checkpointFirst:r().optional(),...W,...Z}).refine(e=>e.previewId===void 0!=(e.resumeRunId===void 0),{message:"An emptying acts on a simulation, or takes up a run: one of them"}),Zr=o({operationId:m}),Yr=o({orgId:i,runId:a().regex(/^em-\d{8}-\d{6}-[a-z0-9]{4}$/),...W,...Z}),Vr=o({orgId:i}),Jr=o({orgId:i}).strict(),Qr=o({alertId:m}),fo=o({sourceOrgId:i,targetOrgId:i}),ei=fo.extend({types:c(a().min(1).max(80)).min(1).max(50),includeManaged:r().optional(),readBudget:g().int().min(1).max(Yt).optional()}),In=o({componentType:w(Tt),fullName:a().min(1).max(400).regex(/^[^\u0000-\u001f\u007f]+$/,"A component name holds no control character")}),ti=fo.extend({components:c(In).min(1).max(500).refine(e=>new Set(e.map(t=>`${t.componentType}:${t.fullName}`)).size===e.length,{message:"Each component may be named once per deployment"}),testLevel:w(Et),runTests:c(a().max(255).regex(Ct,"Not an Apex class name")).max(100).optional()}).refine(e=>e.sourceOrgId!==e.targetOrgId,{message:"The source and the target are the same org",path:["targetOrgId"]}).refine(e=>e.testLevel!=="RunSpecifiedTests"||(e.runTests?.length??0)>0,{message:"RunSpecifiedTests names at least one test class",path:["runTests"]}),oi=o({validationId:a().regex(/^0Af[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/,"Not a deployment id"),targetOrgId:i}).strict(),kn=a().regex(/^\d+\.\d+\.\d+$/,"Invalid semver"),ye=a().regex(/^[A-Za-z][A-Za-z0-9_]*\.[A-Za-z][A-Za-z0-9_]*$/,"Expected an Object.field key").max(170),jn=o({name:a().min(1).max(80),label:a().min(1).max(200),filterField:l,valuesSoql:a().min(1).max(4e3)}),Pn=o({name:a().min(1).max(80),label:a().min(1).max(200),whereFragment:J}),so=de([o({action:A("clear")}),o({action:A("replace"),value:a().max(255)})]),yo=o({rootObject:l,axes:c(jn).max(20),edgeCases:c(Pn).max(50),budgetMaxRecords:g().int().positive().max(1e5).optional(),candidatesPerCombination:g().int().positive().max(20).optional(),expectedObjects:c(l).max(100).optional(),maxNodes:g().int().min(10).max(500).optional(),excludedObjects:c(l).max(200).optional(),excludedFields:x(l,c(l).max(500)).optional(),sasDir:a().min(1).max(500).optional(),datasetDir:a().min(1).max(500).optional(),rulesFilePath:a().min(1).max(500).optional(),datasetVersion:kn.optional(),protectedOrgIds:c(i).max(50).optional(),identityKeys:x(l,c(l).min(1).max(10)).optional(),undeletableObjects:x(l,l).optional(),requiredLookupPlaceholders:x(ye,o({name:a().min(1).max(200),recordTypeDeveloperName:a().min(1).max(97).optional(),targetObjectApiName:l.optional()})).optional(),requiredFieldDefaults:x(ye,D()).optional(),picklistRules:x(ye,so).optional(),defaultPicklistRule:so.optional(),duplicateErrorPatterns:c(a().min(1).max(200)).max(50).optional(),mockDetection:o({metadataTypeApiName:l,isMockedFieldApiName:l}).optional(),mandatoryLookups:x(l,c(l).min(1).max(50)).optional(),presenceKeys:x(l,l).optional()}),ni=o({config:yo}),ai=o({sourceOrgId:i}),ri=o({fields:c(ye).min(1).max(2e3)}),ii=o({sourceOrgId:i,author:a().min(1).max(120).optional()}),ce=o({organizationId:Pt,checkpointId:F}).strict(),On=yo.pick({requiredFieldDefaults:!0,requiredLookupPlaceholders:!0,picklistRules:!0,defaultPicklistRule:!0,identityKeys:!0,undeletableObjects:!0,duplicateErrorPatterns:!0,mockDetection:!0,protectedOrgIds:!0}).strict(),ho=ce.extend({choices:De,config:On.optional(),confirmStaging:a().min(1).max(255).optional()}).strict(),Rn=ho.extend({choices:De.optional()}).strict(),ci=o({targetOrgId:i,replay:ho.optional(),pilot:r().optional(),reload:r().optional(),writeEncrypted:r().optional(),maxRecords:g().int().positive().max(1e6).optional(),muteAutomation:r().optional(),checkpointFirst:B.optional(),sweep:r().optional(),...he,includeChanged:r().optional(),acceptEmails:r().optional(),acceptAutomation:r().optional(),goneFirst:c(ze).max(1e6).optional()}),wn=o({targetOrgId:i}),li=wn.extend({replay:Rn.optional()}),di=o({targetOrgId:i,loadedAt:a().min(1).max(64),includeChanged:r().optional(),sweep:r().optional(),...he,muteAutomation:r().optional(),replay:ce.optional()}),pi=o({targetOrgId:i,loadedAt:a().min(1).max(64),reload:r().optional(),replay:ce.optional()}),mi=o({targetOrgId:i,loadedAt:a().min(1).max(64),sweptObjects:Xe.optional(),reload:r().optional(),replay:ce.optional()}),ui=o({targetOrgId:i,loadedAt:a().min(1).max(64),includeChanged:r().optional(),replay:ce.optional()}),zo=1e3,So=3650,An=200,X=c(l).min(1).max(zo).refine(e=>new Set(e).size===e.length,"An object is named twice");function xo(e){return e.mode==="picked"?e.objects!==void 0:e.objects===void 0}var Io=de([A("all"),c(l.refine(e=>e.toLowerCase().endsWith("__c"),"A custom setting's API name ends in __c")).min(1).max(zo).refine(e=>new Set(e.map(t=>t.toLowerCase())).size===e.length,"A custom setting is named twice")]),ko={path:["objects"],message:'Name the objects with "picked", and none with "everything"'},gi=o({orgId:i.optional()}).optional(),vn=1e6,jo=g().int().min(1).max(vn),bi=o({orgId:i,mode:Ne,objects:X.optional(),excluded:X.optional(),customSettings:Io.optional(),maxTotal:jo.optional()}).refine(xo,ko),fi=o({orgId:i,name:_e,mode:Ne,objects:X.optional(),excluded:X.optional(),customSettings:Io.optional(),maxTotal:jo.optional(),keepDays:g().int().min(0).max(So),ignoredFields:Te.optional()}).refine(xo,ko),yi=o({checkpointId:F,objects:X.optional(),muteAutomation:r().optional(),acceptOutside:r().optional()}),hi=o({checkpointId:F,previewId:Ce,objects:X.optional(),acceptAutomation:r(),muteAutomation:r().optional(),acceptEmails:r().optional(),acceptNoUndo:r(),acceptRecreate:r(),acceptOutside:r(),acceptUnseen:r(),fromPage:A(!0).optional()}),zi=o({checkpointId:F,previewId:Ce,objects:X,acceptOutside:r()}),Si=o({checkpointId:F}),En=200,xi=o({token:m,orgId:i,key:a().min(1).max(En),keepDays:g().int().min(0).max(So)}),Ii=o({checkpointId:F,rewindId:jt,acceptAutomation:r(),muteAutomation:r().optional(),acceptEmails:r().optional(),fromPage:A(!0).optional()}),ki=o({checkpointIds:c(F).min(1).max(An).refine(e=>new Set(e).size===e.length,"A checkpoint is named twice")}),ji=o({checkpointId:F,keep:r()}),Pi=o({checkpointId:F,name:_e}),Oi=o({checkpointId:F,fields:Te}),Cn=500,Ri=o({orgIds:c(i).min(1).max(Cn).refine(e=>new Set(e).size===e.length,"An org is named twice").optional()}).strict().optional(),wi=o({sourceOrgId:i,targetOrgId:i,includeStandardObjects:r()}),Ai=o({sourceOrgId:i,objectApiNames:c(l).min(1).max(ct)}),vi=o({sourceOrgId:i,targetOrgId:i,selectedObjects:c(l).max(y),includeStandardObjects:r(),maxDepth:g().int().min(1).max(10).optional(),maxObjects:g().int().min(1).max(500).optional()}),Ei=o({complianceFramework:St,objectFilters:x(a(),J).optional(),overrides:c(o({objectApiName:l,fieldApiName:l,method:de([zt,A("skip")])})).max(500).optional()}),Ci=o({grappeThreshold:g().int().nonnegative(),keepContactPoints:r().optional(),muteAutomation:r().optional(),checkpointFirst:B.optional()}),Ti=o({mode:o({share:A(!0).optional(),caps:x(l,g().int().min(1).max(ne)).refine(e=>Object.keys(e).length<=y,"Too many caps").optional(),all:g().int().min(1).max(ne).optional(),withinMB:g().positive().max(1e6).optional()}).strict().refine(e=>e.share===!0||e.caps!==void 0||e.all!==void 0,"Fit by share, by caps, or both"),muteAutomation:r().optional(),checkpointFirst:B.optional()}),_i=o({objectApiName:l}),Ni=o({orgId:i.optional(),sourceOrgId:i.optional(),alreadySelected:c(l).max(y).optional()}).loose(),Di=o({orgId:i.optional(),sourceOrgId:i.optional(),objectApiName:l.optional(),alreadySelected:c(l).max(y).optional(),selectedObjects:c(l).max(y).optional(),availableObjects:c(l).max(500).optional()}).loose(),Fi=o({sourceOrgId:i,targetOrgId:i.optional(),selectedObjects:c(l).min(1).max(y),parentObjects:c(l).max(y).optional()}).loose(),Tn=It.extend({sourceOrgId:i,targetOrgId:i,selectedObjects:c(l).min(1).max(y),parentObjects:c(l).max(y).default([])}).loose(),Mi=o({config:Tn.optional(),sourceOrgId:i.optional(),targetOrgId:i.optional(),selectedObjects:c(l).min(1).max(y).optional(),parentObjects:c(l).max(y).optional()}).loose(),_n=a().min(1).max(5e4),Ui=o({conversationId:m,message:a().max(5e4)}),Li=o({title:a().min(1).max(300)}),Bi=o({conversationId:m}),$i=o({apiKey:a().min(1).max(500),errorResolution:r().optional()}),qi=o({enabled:r().optional(),errorResolution:r().optional()}),Gi=o({orgId:i,objectName:l,sampleSize:g().int().positive().max(1e4).optional()}),Wi=o({orgId:i,prompt:a().trim().min(1).max(2e3).optional(),soql:a().trim().min(1).max(2e4).optional()}).refine(e=>e.prompt===void 0!=(e.soql===void 0),{message:"Send a prompt to draft from or a query to check, not both and not neither"}),Ki=o({description:_n,orgIds:c(i).max(50).optional()}),Hi=o({requestId:m}),fe=c(a().min(1).max(M.picklistValue)).max(M.picklistValues),co={label:a().max(M.agentLabel).optional(),description:a().max(M.agentDescription).optional()},Xi=o({text:a().trim().min(1).max(M.text),language:ae.shape.language,casePicklists:o({Status:fe.optional(),Origin:fe.optional(),Priority:fe.optional(),Type:fe.optional()}).optional(),agent:o({topics:c(o({name:a().min(1).max(M.agentName),...co,actions:c(o({name:a().min(1).max(M.agentName),...co})).max(M.agentActions)})).max(M.agentTopics)}).optional(),draft:kt.optional(),maskOnly:r().optional()}),Zi=o({filePath:a().min(1).max(2e3)}),Yi=o({name:a().max(200),config:x(a(),D())}),Vi=o({operationId:m.optional(),executionId:m.optional(),objectName:a().min(1).max(200).optional()}).loose(),Ji=o({policyId:m}),Qi=o({policy:x(a(),D())}),es=o({policyId:m,orgId:i}),ts=o({module:a().min(1).max(50).optional(),orgId:i.optional(),offset:g().int().min(0).max(Ae).optional(),limit:g().int().min(1).max(Ae).optional()}).optional(),os=o({operationId:m.optional()}).optional(),Nn=w(["syncMappings","forgePlans","pipelines","anonymizationTemplates"]),ns=o({categories:c(Nn).min(1).max(50)}),as=o({json:a().min(1).max(5e6),overwrite:r()}),rs=o({json:a().min(1).max(5e6)}),is=o({orgId:a().max(128),authMethod:a().min(1).max(50),alias:a().max(100).optional(),loginUrl:a().max(500).optional(),username:a().max(300).optional(),password:a().max(500).optional(),securityToken:a().max(100).optional(),clientId:a().max(256).optional(),jwtKeyFile:a().max(4096).optional()}).loose(),Po=a().trim().max(100).regex(/^[\w.-]*$/,"an alias is letters, digits, dots, dashes and underscores").optional(),Dn=a().trim().min(1,"the username is required").max(80).regex(/^[\w.@+-]+$/,"a username is written like an email address"),Oo=a().trim().min(1,"the consumer key is required").max(256).regex(/^[A-Za-z0-9._-]+={0,2}$/,"a consumer key is letters, digits, dots, dashes and underscores"),Fn=a().trim().min(1,"the private key file is required").max(4096).regex(/^[^\u0000-\u001f\u007f]+$/,"the private key file path holds a control character").refine(e=>nn(e),"give the private key file as an absolute path"),ss=o({alias:Po,loginUrl:a().max(500).optional(),username:Dn,clientId:Oo,jwtKeyFile:Fn}).loose(),cs=o({alias:Po,loginUrl:a().max(500).optional(),clientId:Oo}).loose(),ls=o({requestId:m}),ds=o({orgId:i}),ps=o({orgId:i}),ms=o({orgId:i}).strict(),us=o({orgId:i}).strict(),gs=o({orgId:i,alias:a().trim().min(1).max(100),color:a().regex(/^#[0-9A-Fa-f]{6}$/),tags:c(a().trim().min(1).max(50)).max(20),staging:r().optional()}),bs=o({key:a().min(1).max(200),value:D()}),fs=o({enabled:r()}),ys=o({lng:w(["en","fr","de","es","ja","pt-BR"])}),hs=o({targetOrgId:i,sourceOrgId:i.optional()}),zs=o({moduleId:a().min(1).max(64),route:a().min(1).max(64),overlay:r()}),Ss=o({moduleId:a().min(1).max(64)}),Mn=80,Un=at(e=>qt(e)||Gt(e)||typeof e=="string"&&e.trim()!==""&&e.length<=Mn,{message:"Not a pipeline step type"}),Ln=o({pipeline:o({name:a().min(1).max(200),steps:c(o({type:Un,config:x(a(),D()).default({})}).loose()).max(200),variables:c(x(a(),D())).max(200).default([]),triggers:c(x(a(),D())).max(50).default([])}).loose(),variables:x(a(),a().max(2e3)).optional(),dryRun:r().optional()}),Bn=Re({since:it.datetime({offset:!0}),runner:w(["cron","taskScheduler","githubActions"]),file:a().min(1).max(255).refine(e=>!/[\\/]/.test(e),"The file's name, without its folder"),digest:a().regex(/^sha256:[0-9a-f]{64}$/,"Not a digest: sha256: and 64 hex digits")}),xs=Ln.shape.pipeline.extend({id:a().min(1).max(200),runsOutside:Bn.optional()}),Is=o({pipelineId:m}),ks=o({id:a().max(200),config:x(a(),D())}),js=o({id:m}),Ps=o({operationId:m,stepId:m,decision:w(["approved","rejected"])}),$n=255,Ro={pipelineId:m,stepId:m},Os=o({pipelineId:m}),Rs=o({...Ro,typed:a().min(1).max($n)}),ws=o(Ro),As=o({category:a().max(100).optional(),query:a().max(500).optional()}).loose().optional(),vs=o({templateId:m});function qn(e){return e.issues.slice(0,3).map(t=>`${t.path.join(".")||"(root)"}: ${t.message}`).join("; ")}function Gn(e){let t=e.issues.map(n=>n.code==="custom"?n.params?.unreadablePatterns:void 0);return t.every(n=>n!==void 0)?t.flat():void 0}function Es(e,t,n,s){let d=e.safeParse(t.payload);if(!d.success){let p=qn(d.error),u=Gn(d.error);return ao(s,t.type,n,t,new Error(`Invalid payload \u2014 ${p}`),u?{code:Lt,extraPayload:{rules:u}}:{code:"INVALID_PAYLOAD"}),null}return d.data}var Qe="backupSet:",Wn="backups",et=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,Q=a().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/),$=g().int().nonnegative(),Kn=o({index:g().int().positive(),afterId:a().regex(et).optional(),lastId:a().regex(et).optional(),rows:$,snapshotId:a().min(1).max(240),takenAt:Q.optional(),readSince:Q.optional(),state:w(["pending","snapshotted","masking","masked","restored"]),masked:$,refused:$,deletedSince:$,nothingToMask:$,unanswered:$.optional(),late:A(!0).optional(),sizeUsed:g().int().positive(),lateLeft:$.optional(),lateOf:g().int().positive().optional(),lateAfterId:a().regex(et).optional(),restoredAt:Q.optional()}),Hn=o({objectApiName:a().min(1).max(255),where:a().max(2e3).optional(),select:a().max(1e5).optional(),done:r(),tailLeft:$.optional(),slices:c(Kn)}),wo=o({setId:a().min(1).max(200),kind:w(["masking","backup"]),orgId:a().min(1).max(200),organizationId:a().max(18).optional(),templateId:a().min(1).max(200).optional(),fingerprint:a().regex(/^[0-9a-f]{64}$/).optional(),size:g().int().positive(),state:w(["open","done","abandoned"]),startedAt:Q,serverStartedAt:Q.optional(),lastActivityAt:Q,requestsSpent:$,keyCheck:a().regex(/^[0-9a-f]{16}$/).optional(),objects:c(Hn)});function Ts(e,t){return`${e}-s${String(t).padStart(4,"0")}`}function Se(e){return e.objects.flatMap(t=>t.slices).sort((t,n)=>t.index-n.index)}function _s(e){return Se(e).reduce((t,n)=>Math.max(t,n.index),0)+1}function vo(e){return e.state==="masked"||e.state==="snapshotted"||e.state==="restored"}function Xn(e){return Se(e).reduce((t,n)=>t+n.rows,0)}function Eo(e,t,n){return{index:t.index,objectApiName:e,snapshotId:t.snapshotId,rows:t.rows,masked:t.masked,refused:t.refused,deletedSince:t.deletedSince,nothingToMask:t.nothingToMask,state:t.state,...t.late?{late:!0}:{},...t.sizeUsed<n?{sizeUsed:t.sizeUsed}:{},...t.restoredAt?{restoredAt:t.restoredAt}:{}}}function Zn(e){return e.objects.reduce((t,n)=>t+(n.tailLeft??0)+n.slices.reduce((s,d)=>s+(d.lateLeft??0),0),0)}function Ns(e,t){return{setId:e.setId,size:e.size,state:e.state,objects:e.objects.map(n=>({objectApiName:n.objectApiName,slices:n.slices.map(s=>Eo(n.objectApiName,s,e.size))})),lateRecords:Zn(e),requestsSpent:t.requestsSpent,...t.stoppedOnBudget?{stoppedOnBudget:!0}:{},slicesLeft:e.objects.some(n=>!n.done||n.slices.some(s=>!vo(s)))}}function Yn(e){return e.kind==="backup"&&e.state==="open"?"partial":e.state}function Ds(e){let t=Object.fromEntries(e.objects.flatMap(n=>n.where?[[n.objectApiName,n.where]]:[]));return{setId:e.setId,orgId:e.orgId,kind:e.kind,state:Yn(e),startedAt:e.startedAt,lastActivityAt:e.lastActivityAt,size:e.size,totalRecords:Xn(e),...e.templateId?{templateId:e.templateId}:{},slices:e.objects.flatMap(n=>n.slices.map(s=>Eo(n.objectApiName,s,e.size))),...Object.keys(t).length>0?{wheres:t}:{}}}function Fs(e){let t=Se(e);return{setId:e.setId,savedAt:e.lastActivityAt,done:t.filter(vo).length,total:t.length,state:e.state,size:e.size}}var Ao=class{constructor(t){this.configStore=t}configStore;get(t){let n=wo.safeParse(this.configStore.get(this.key(t)));return n.success&&n.data.setId===t?n.data:void 0}save(t){this.configStore.set(this.key(t.setId),wo.parse(t),Wn)}delete(t){this.configStore.delete(this.key(t))}list(t){return this.configStore.getKeysByPrefix(Qe).map(n=>this.get(n.slice(Qe.length))).filter(n=>n!==void 0).filter(n=>t===void 0||n.orgId===t)}openFor(t,n){return this.list(t).find(s=>s.kind==="masking"&&s.state==="open"&&s.templateId===n)}ofSnapshot(t){return this.list().find(n=>Se(n).some(s=>s.snapshotId===t))}key(t){return`${Qe}${t}`}};var Vn=5;function xe(e){return e.slice(0,15)}function Jn(e){let t=e.errors?.[0];if(t===void 0)return"The org gave no reason.";if(typeof t=="string")return t;let n=t.statusCode??"",s=t.message??"";return n&&s?`${n}: ${s}`:n||s||"The org gave no reason."}function Co(e){let t=new Set;for(let n of e){let s=n.Id;typeof s=="string"&&t.add(xe(s))}return t}async function To(e){let t=[],n=[],s={},d=!1,p=!1,u=e.stampsFor,f=ie(e.org),k=e.org.serverTime?.bind(e.org),E=u&&k?Date.now()+await se({serverTime:k})-re:Number.NaN;for(let{objectApiName:O,ids:v}of e.plan){let I={objectApiName:O,planned:v.length,undeleted:0,alreadyBack:0,goneForGood:0,refused:0,reasons:[]};t.push(I);let z=_=>{I.reasons.length<Vn&&!I.reasons.includes(_)&&I.reasons.push(_)},R=pe(O);for(let _=0;_<v.length;_+=me){let C=v.slice(_,_+me);if(p||e.signal?.aborted){p=!0,I.notReached=(I.notReached??0)+C.length,n.push(...C);continue}let[ee]=ue(C,me),K,te;try{K=Co((await e.org.queryDeleted(`SELECT Id FROM ${R} WHERE Id IN (${ee}) AND IsDeleted = true`)).records),te=Co((await e.org.query(`SELECT Id FROM ${R} WHERE Id IN (${ee})`)).records)}catch(j){I.refused+=C.length,z(`The recycle bin could not be read: ${V(j)}`),n.push(...C);continue}let h=C.filter(j=>K.has(xe(j)));for(let j of C)K.has(xe(j))||(te.has(xe(j))?I.alreadyBack++:I.goneForGood++);if(h.length===0)continue;let U;try{d=!0;let j=await e.undelete(h),T=Array.isArray(j)?j:[j];U=h.map((H,oe)=>T[oe]??{success:!1})}catch(j){let T=V(j);U=h.map(()=>({success:!1,errors:[T]}))}let Y=[];U.forEach((j,T)=>{if(j.success===!0){I.undeleted++,u?.(h[T])&&Y.push(h[T]);return}I.refused++,z(Jn(j)),n.push(h[T])}),Y.length>0&&Number.isFinite(E)&&Object.assign(s,await be(e.org,R,Y,E,f))}}return{objects:t,left:n,wrote:d,cancelled:p,stamps:s}}function _o(e){return e.refused+e.goneForGood+(e.notReached??0)}async function Qn(e,t,n,s){let d=new Map(Object.entries(s).map(([u,f])=>[u.slice(0,15),Date.parse(f)])),p=new Set;for(let{objectApiName:u,ids:f}of t){let k=pe(u);for(let E of ue(f)){let O;try{O=(await e.query(`SELECT Id, LastModifiedDate FROM ${k} WHERE Id IN (${E})`)).records}catch{continue}for(let v of O){if(typeof v.Id!="string")continue;let I=v.Id.slice(0,15),z=Date.parse(String(v.LastModifiedDate??""));(z<=n||z<=(d.get(I)??Number.NaN))&&p.add(I)}}}return p}function No(e){let t=Date.parse(e.startedAt),n=Date.parse(e.lastWrittenAt??e.end?.at??"");return Number.isFinite(n)?{runRecordedAt:new Date(n),...Number.isFinite(t)?{runDurationMs:Math.max(0,n-t)}:{}}:{}}function ea(e){return e.filter(t=>t.deleted+t.alreadyGone>0).map(t=>t.objectApiName)}async function Js(e){let{run:t,includeChanged:n}=e,s=e.again===!0,d=ge(t,s),p=d.reduce((b,S)=>b+S.ids.length,0),u=$e(t),f=u.reduce((b,S)=>b+S.ids.length,0),k=eo(t),E=k.reduce((b,S)=>b+S.ids.length,0),O=[],v=e.backups,I=e.undelete;k.length>0&&!I&&O.push(`The ${E} record(s) the run deleted could not be brought back from the recycle bin here: the next removal offers them again.`),u.length>0&&!v&&O.push(`The values from before the run of ${f} record(s) it wrote over could not be read here: they were not put back, and the next removal offers them again.`);let z,R,_={},C=(e.earlierRuns??[]).map(b=>({runId:b.runId,keys:new Set([...ge(b),...$e(b)].flatMap(({ids:S})=>S.map(L=>L.slice(0,15))))})),ee=b=>C.some(({keys:S})=>S.has(b.slice(0,15))),K=e.sweep,te=u.length>0&&v||k.length>0&&I||K?async b=>{if(k.length>0&&I){let N=u.length>0&&v?await Qn(e.org,u,await to(e.org,Ie(t)),t.removal?.removalStamps??{}):void 0,q=N?Date.now()+await se(e.org)-re:0;if(R=await To({org:e.org,plan:k,undelete:I,...C.length>0?{stampsFor:ee}:{},...e.signal?{signal:e.signal}:{}}),N&&R.wrote){let P=ie(e.org);for(let{objectApiName:Pe,ids:Lo}of u){let Bo=Lo.filter($o=>N.has($o.slice(0,15)));Object.assign(_,await be(e.org,Pe,Bo,q,P))}}if(R.cancelled||e.signal?.aborted)return R.wrote}if(u.length>0&&v){let N={...t.removal?.removalStamps,..._};z=await oo({org:e.org,plan:u,backups:v,...Ie(t)!==void 0?{lastWriteAt:Ie(t)}:{},includeChanged:n,...Object.keys(N).length>0?{stamps:N}:{},...t.unkept?{unkept:t.unkept}:{},...C.length>0?{stampsFor:ee}:{},...e.signal?{signal:e.signal}:{}})}let S=(R?.wrote??!1)||(z?.wrote??!1);if(z?.cancelled||e.signal?.aborted)return S;let L=K?await K(b):!1;return S||L}:void 0,h=await Le(e.org,d,{...No(t),...t.removal?.removalStamps?{removalStamps:t.removal.removalStamps}:{},...t.removal?.removalSpans?{removalSpans:t.removal.removalSpans}:{},includeChanged:n,...te?{sweep:te}:{},...e.afterRemoval?{afterRemoval:e.afterRemoval}:{},...e.automationMade?{automationMade:e.automationMade}:{},...e.runUserId?{runUserId:e.runUserId}:{},...e.onUndeletable?{onUndeletable:e.onUndeletable}:{},...e.beforeFirstWrite?{beforeFirstWrite:e.beforeFirstWrite}:{},signal:e.signal,onProgress:e.onProgress}),U=new Date().toISOString();if(h.stoppedForUndeletable)return{result:{runId:t.runId,status:"cancelled",includeChanged:n,objects:[],finishedAt:U},planned:p,plannedBack:f,plannedUndelete:E,notes:[],stoppedForUndeletable:!0};let Y=s?void 0:t.removal?.undo?.removedAt,j={runId:t.runId,status:na(aa(Jt(h.objects,h.cancelled),h.objects,z),h.objects,z,R),includeChanged:n,objects:h.objects,finishedAt:U,...Y?{leftBy:Y}:{},...z&&z.objects.length>0?{restored:z.objects}:{},...R&&R.objects.length>0?{undeleted:R.objects}:{}},T=Qt(j,p,t.removal?.undo,s),H=new Set(h.gone),oe=H.size>0||s&&T?d.flatMap(({ids:b})=>b.filter(S=>!H.has(S))):void 0,tt={..._,...h.stamps},ot=Object.keys(tt).length>0,Fo=z?.objects.some(b=>b.restored+(b.restoredWithout??0)>0)===!0,Mo=R!==void 0&&!R.cancelled;if(T||ot||h.span||oe||z||R)try{await e.store.updateRemoval(t.runId,b=>({...b,...T?{undo:T}:{},...ot?{removalStamps:{...b.removalStamps,...tt}}:{},...h.span?{removalSpans:[...b.removalSpans??[],h.span]}:{},...oe?{removalLeft:oe}:{},...z?{restoreLeft:z.left}:{},...Fo?{restoredAt:U}:{},...R?{undeleteLeft:R.left}:{},...Mo?{undeletedAt:U}:{}}))}catch(b){O.push(`What this removal did could not be kept (${b instanceof Error?b.message:String(b)}): the next removal of the run may set out to take records already gone.`)}let Uo=Object.keys(z?.stamps??{}).length>0?await ta(e.org,t,e.earlierRuns??[]):new Map,ke=[];for(let{runId:b,keys:S}of C){let L=Uo.get(b),N=Object.fromEntries(Object.entries({...R?.stamps,...z?.stamps}).filter(([P])=>S.has(P.slice(0,15))&&!L?.has(P.slice(0,15)))),q=Object.keys(N).length;if(q!==0)try{await e.store.updateRemoval(b,P=>({...P,removalStamps:{...P.removalStamps,...N},...h.span?{removalSpans:[...P.removalSpans??[],h.span]}:{}})),ke.push({runId:b,records:q})}catch(P){O.push(`What this removal gave back of ${q} record(s) the run ${b} wrote too could not be kept on it (${P instanceof Error?P.message:String(P)}): its removal reads them as changed since it.`)}}let le=e.configs;if(le&&H.size>0&&le.isSaved(t.configId)){let b={sourceOrgId:t.sourceOrgId,targetOrgId:qe(t)};try{let S=d.filter(P=>Be.includes(P.objectApiName)).flatMap(({ids:P})=>P.filter(Pe=>H.has(Pe))),L=le.forgetFiles(t.configId,b,S),N=ea(h.objects).filter(P=>!Be.includes(P)),q=le.markRemoved(t.configId,b,[...new Set([...N,...L.map(P=>P.objectApiName)])],U);j={...j,...q.length>0?{readWhole:q}:{},...L.length>0?{filesForgotten:L.length}:{}}}catch(S){O.push(`The configuration could not be told what this removal took (${S instanceof Error?S.message:String(S)}): run it full next time.`)}}let je;if(e.links&&H.size>0)try{je=await e.links.forget(t.configId,{sourceOrgId:t.sourceOrgId,targetOrgId:qe(t)},[...H])}catch(b){O.push(`Which records of the target this removal took could not be forgotten (${b instanceof Error?b.message:String(b)}): a later run of the configuration may point a lookup at one of them.`)}return{result:j,planned:p,plannedBack:f,plannedUndelete:E,notes:O,...je?{linksForgotten:je}:{},...ke.length>0?{earlierStamped:ke}:{},...h.duplicateSets?{duplicateSets:h.duplicateSets}:{}}}async function Qs(e){let{run:t}=e,n=ge(t);return{outcome:await Le(e.org,n,{...No(t),...t.removal?.removalStamps?{removalStamps:t.removal.removalStamps}:{},...t.removal?.removalSpans?{removalSpans:t.removal.removalSpans}:{},includeChanged:e.includeChanged,...e.runUserId?{runUserId:e.runUserId}:{},previewOnly:!0,...e.signal?{signal:e.signal}:{}}),planned:n.reduce((d,p)=>d+p.ids.length,0)}}async function ta(e,t,n){let s=new Map,d=Object.entries(t.heldBefore??{});if(d.length===0||n.length===0)return s;let p=await ie(e)(),u=await se(e);for(let f of n){let k=Date.parse(Ie(f)??""),E=Number.isFinite(k)?k+u+re:Number.NEGATIVE_INFINITY,O=new Set;for(let[v,{at:I,by:z}]of d)Date.parse(I)>E&&(p!==void 0&&z!==void 0&&z.slice(0,15)===p||O.add(v));O.size>0&&s.set(f.runId,O)}return s}function Ie(e){return e.lastWriteAt??e.lastWrittenAt??e.end?.at}function oa(e){return e.keptChanged+e.refused+e.notKept+(e.notReached??0)+(e.restoredWithout??0)}function na(e,t,n,s){if(!s||e==="cancelled")return e;if(s.cancelled)return"cancelled";let d=s.objects.some(u=>_o(u)>0);if(e==="success"&&!d)return"success";let p=t.some(u=>u.deleted>0)||(n?.objects??[]).some(u=>u.restored>0)||s.objects.some(u=>u.undeleted>0);return e==="partial"||p?"partial":"failure"}function aa(e,t,n){if(!n||e==="cancelled")return e;if(n.cancelled)return"cancelled";let s=n.objects.some(p=>oa(p)>0);return e==="success"&&!s?"success":t.some(p=>p.deleted>0)||n.objects.some(p=>p.restored+(p.restoredWithout??0)>0)?"partial":"failure"}function tc(e){let t=e?.getSandforgeSetting?.("backup.maxAgeDays",30);return typeof t=="number"&&Number.isFinite(t)&&t>0?t:0}function oc(e,t,n){let s=[],d=0,p=Number.POSITIVE_INFINITY;for(let u of e){let f=t(u.backup);if(!f){d+=u.ids.length;continue}s.push(u);let k=Date.parse(f.timestamp??"");n>0&&Number.isFinite(k)&&(p=Math.min(p,k+n*864e5))}return{kept:s,notKept:d,...Number.isFinite(p)?{keptUntil:new Date(p).toISOString()}:{}}}async function ac(e,t){let n=e.check(t);if(!n.allowed)return{check:n,decision:"refused"};if(!await e.confirmIfNeeded(n,t.orgTier))return{check:n,decision:"declined"};let d=n.requiresConfirmation&&e.canAskForConfirmation===!0;return{check:n,decision:d?"confirmed":"allowed"}}var Do={allowed:0,confirmed:1,declined:2,refused:3};function rc(e,t){return e===void 0||Do[t]>Do[e]?t:e}export{da as a,no as b,pa as c,Ge as d,ma as e,ua as f,qo as g,ga as h,ba as i,fa as j,ya as k,ha as l,za as m,Sa as n,ao as o,xa as p,Ia as q,ka as r,ja as s,i as t,l as u,Xe as v,B as w,rn as x,sn as y,Ze as z,Na as A,Da as B,Fa as C,Ma as D,Ua as E,La as F,Ba as G,$a as H,qa as I,Ga as J,Wa as K,Ka as L,Ha as M,Xa as N,Za as O,Ya as P,Va as Q,Ja as R,Qa as S,er as T,tr as U,or as V,nr as W,ar as X,rr as Y,ir as Z,sr as _,gn as $,cr as aa,lr as ba,dr as ca,pr as da,mr as ea,ur as fa,gr as ga,br as ha,fr as ia,yr as ja,hr as ka,zr as la,Sr as ma,xr as na,Ir as oa,kr as pa,jr as qa,Pr as ra,Or as sa,Rr as ta,wr as ua,Ar as va,vr as wa,Er as xa,Cr as ya,Tr as za,_r as Aa,Nr as Ba,Dr as Ca,Fr as Da,Mr as Ea,Ur as Fa,Lr as Ga,Br as Ha,zn as Ia,$r as Ja,qr as Ka,Gr as La,Wr as Ma,Kr as Na,Hr as Oa,Xr as Pa,Zr as Qa,Yr as Ra,Vr as Sa,Jr as Ta,Qr as Ua,fo as Va,ei as Wa,ti as Xa,oi as Ya,yo as Za,ni as _a,ai as $a,ri as ab,ii as bb,ci as cb,li as db,di as eb,pi as fb,mi as gb,ui as hb,gi as ib,bi as jb,fi as kb,yi as lb,hi as mb,zi as nb,Si as ob,xi as pb,Ii as qb,ki as rb,ji as sb,Pi as tb,Oi as ub,Ri as vb,wi as wb,Ai as xb,vi as yb,Ei as zb,Ci as Ab,Ti as Bb,_i as Cb,Ni as Db,Di as Eb,Fi as Fb,Mi as Gb,Ui as Hb,Li as Ib,Bi as Jb,$i as Kb,qi as Lb,Gi as Mb,Wi as Nb,Ki as Ob,Hi as Pb,Xi as Qb,Zi as Rb,Yi as Sb,Vi as Tb,Ji as Ub,Qi as Vb,es as Wb,ts as Xb,os as Yb,ns as Zb,as as _b,rs as $b,is as ac,ss as bc,cs as cc,ls as dc,ds as ec,ps as fc,ms as gc,us as hc,gs as ic,bs as jc,fs as kc,ys as lc,hs as mc,Ln as nc,Bn as oc,xs as pc,Is as qc,ks as rc,js as sc,Ps as tc,Os as uc,Rs as vc,ws as wc,As as xc,vs as yc,qn as zc,Es as Ac,Ts as Bc,Se as Cc,_s as Dc,vo as Ec,Zn as Fc,Ns as Gc,Yn as Hc,Ds as Ic,Fs as Jc,Ao as Kc,To as Lc,Js as Mc,Qs as Nc,Ie as Oc,na as Pc,aa as Qc,ac as Rc,rc as Sc,tc as Tc,oc as Uc};
|
|
@@ -0,0 +1,9 @@
|
|
|
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{c as B}from"./chunk-BOGNK4LV.mjs";import{d as k,e as A,f as b}from"./chunk-ZVU7MD2S.mjs";import{Ac as L,fc as D,gc as P,hc as x,mc as O,tc as S,xc as v}from"./chunk-OLCS7JCT.mjs";import{da as y}from"./chunk-SZOJ7BEJ.mjs";import{de as R,ee as g,le as f,te as p}from"./chunk-J347SPU6.mjs";var N=["undelete","insert","update","delete"],W={SingleEmail:{one:"single email",more:"single emails"},DailyWorkflowEmails:{one:"workflow email",more:"workflow emails"}};function M(e,t){let n=W[t];return`${e} ${e===1?n.one:n.more}`}var U={rewind:{what:"This rewind",then:"rewind again"},undo:{what:"This undo",then:"undo the rewind again"}};function I(e){return e.toGiveBack.records+e.toBringBack.inBin+e.toBringBack.withParent}var C="Order";function T(e){return e.toDelete.createdSince+e.toDelete.broughtBackSince+e.toDelete.comesBackWithParent+(e.toBringBack.carriers??0)}function _(e){return e.objectApiName===C?T(e):0}function $(e){return e.deleted+e.withParentDeleted+e.nextPassDeleted}function F(e){return e.objectApiName===C?$(e):0}function G(e){return y[e.objectApiName]!==void 0?e.toRecreate??0:0}function j(e){return y[e.objectApiName]!==void 0?e.recreated:0}function K(e,t=[]){let n=new Map(t.map(({objectApiName:i,count:s})=>[i,s]));return e.flatMap(i=>h(i.objectApiName,{undelete:i.toBringBack.inBin+i.toBringBack.withParent+i.toBringBack.deletedWhileTaken+(i.toBringBack.carriers??0),insert:i.toRecreate??0,update:I(i)+G(i)+_(i),delete:Math.max(0,T(i)-(n.get(i.objectApiName)??0))}))}function Z(e){return e.flatMap(t=>h(t.objectApiName,{undelete:t.broughtBack+t.backWithParent+(t.carriers??0),insert:t.recreated,update:t.givenBackFirst+t.givenBackAfter+t.givenBackNextPass+j(t)+F(t),delete:t.deleted+t.nextPassDeleted}))}function ee(e,t=[],n=[]){let i=a=>{let d=new Map;for(let{objectApiName:m,count:l}of a)d.set(m,(d.get(m)??0)+l);return d},s=i(t),o=i(n);return[...new Set([...e.map(a=>a.objectApiName),...s.keys(),...o.keys()])].flatMap(a=>{let d=e.find(m=>m.objectApiName===a);return h(a,{undelete:d?.deleted??0,insert:0,update:(d?.givenBack??0)+(o.get(a)??0),delete:(d?.broughtBack??0)+(s.get(a)??0)})})}function h(e,t){return N.filter(n=>t[n]>0).map(n=>({objectApiName:e,write:n,records:t[n]}))}function te(e,t){let n=new Set(e.filter(i=>i.records>0).map(i=>`${i.objectApiName}
|
|
8
|
+
${i.write}`));return O(t,(i,s)=>n.has(`${i}
|
|
9
|
+
${s}`),"the org's")}function ne(e,t){return t===void 0?"":`The emails it sends as the ${e} writes were not counted against its daily limits, as what sends them was not read (${t}). `}function w(e){return typeof e.unread=="string"}function ie(e,t,n){let i=!w(n)&&D(n),s=!w(n)&&P(n),o=new Map;for(let r of N){let a=R(t,r);if(a.length===0)continue;let d=x(a,i,s),m=new Set(a.filter(l=>l.limit==="DailyWorkflowEmails").map(l=>l.objectApiName));for(let{objectApiName:l,records:E}of e.filter(c=>c.write===r))for(let c of d.filter(u=>u.objectApiName===l)){let u=o.get(c.limit)??{limit:c.limit,emails:0,objects:[],verdict:"fits"};u.emails+=E*c.perRecord,u.objects.push({objectApiName:l,write:r,records:E,perRecord:c.perRecord,sentBy:[...c.sentBy]}),i&&c.limit==="SingleEmail"&&m.has(l)&&(u.alertsCounted=!0),o.set(c.limit,u)}}return[...o.values()].map(r=>{if(w(n))return{...r,verdict:"unread",unread:n.unread};let a=n[r.limit];return a?{...r,verdict:r.emails>a.remaining?"exceeds":"fits",remaining:a.remaining,max:a.max}:{...r,verdict:"unread",unread:`the org's limits list no ${r.limit}`}})}function re(e,t,n){let i=t.filter(r=>r.verdict==="exceeds");if(i.length===0)return;let s=i.map(r=>`about ${M(r.emails,r.limit)}`+(r.alertsCounted?" (its email alerts among them, as a Developer Edition counts them)":"")+`, ${r.remaining??0} of ${r.max??0} left today`).join("; "),o=U[e];return{code:"EMAILS",message:`${o.what} would make ${n} send ${s}: past them, each record whose flow fails in the save is refused (CANNOT_EXECUTE_FLOW_TRIGGER), and the org's own emails stop for the rest of the day. Turn off what sends them, or assign the user a bypass that keeps it quiet, then ${o.then}. No record was written.`}}function ae(e){let t=f(e.steps),n=g(p(e.automation,e.plan,t),{writes:t}),i=S(e.automation.unread);return{senders:n,...i!==void 0?{sendersUnread:i}:{}}}function q(e){let t=e.mayMute&&e.plan===void 0&&e.senders.length>0?A(e.automation,{writes:f(e.steps)}):[],n=v({senders:e.senders,...e.sendersUnread!==void 0?{sendersUnread:e.sendersUnread}:{},...e.reading!==void 0?{reading:e.reading}:{},accepted:e.accepted,target:e.orgName,run:e.act,muteQuiets:t,keepsAddresses:!0});return n.stop?{gate:n,refusal:{code:"EMAILS_DELIVERED",message:n.stop.message}}:{gate:n}}async function se(e){let t=f(e.steps),n=await k({running:p(e.automation,e.plan,t),writes:t,read:e.read});return{ofRun:n,...q({...e,senders:n.senders,...n.sendersUnread!==void 0?{sendersUnread:n.sendersUnread}:{},...n.read!==void 0?{reading:n.read.reading}:{}})}}function oe(e){let t=f(e.steps),n=g(p(e.automation,b(e.plan,e.held),t),{writes:t}),i=L({planned:e.planned,held:n,...e.reading!==void 0?{reading:e.reading}:{},accepted:e.accepted,target:e.orgName,run:e.act});return i?{code:"EMAILS_DELIVERED",message:i.message}:void 0}var Q=", or run it again once the lease can assign them",V="--mute-automation keeps quiet";function de(e,t,n){if(e.code!=="EMAILS_DELIVERED")return e;let i=t==="undo"?"Tick the box for these emails in the undo's confirmation to undo all the same":e.message.includes(Q)?"Untick Mute automation to be asked about them and rewind all the same":`Tick "Let ${n} send these emails" in the preview to rewind all the same`;return{...e,message:B(e.message,t,i).replace(V,"Mute automation keeps quiet")}}export{M as a,I as b,_ as c,F as d,G as e,j as f,K as g,Z as h,ee as i,te as j,ne as k,ie as l,re as m,ae as n,q as o,se as p,oe as q,de as r};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as R,b,c as L,f as T,g as f,i as $,k as q,l as D}from"./chunk-
|
|
7
|
+
import{a as R,b,c as L,f as T,g as f,i as $,k as q,l as D}from"./chunk-RZOINFNL.mjs";async function B(s){let i=s.now??(()=>new Date),o=await $(s.org,s.users,{now:i(),...s.previous?{previous:s.previous}:{}}),h=q(o,s.users,{...s.previous?{previous:s.previous}:{},...s.acceptUserEmails!==void 0?{acceptUserEmails:s.acceptUserEmails}:{},...s.deliverability!==void 0?{deliverability:s.deliverability}:{},...s.acceptEmails!==void 0?{acceptEmails:s.acceptEmails}:{}});return{state:o,plan:h,answer:D(h,s.organization,o.requests)}}function F(s,i){let o=s.changes.find(i);if(!o)throw new Error(`No change of ${s.username} for this write`);return o}function k(s,i){let o=s?.errors[0];return{code:o?.code??"NO_ANSWER",message:L(o?.message??"the org answered nothing for it",i)}}var K=new Set(["ENTITY_IS_DELETED","NOT_FOUND","INVALID_CROSS_REFERENCE_KEY"]);function _(s){let{target:i}=s.planned;return{isActive:i.isActive!==void 0?s.standing.isActive:s.before.isActive,isFrozen:i.isFrozen!==void 0?s.standing.isFrozen:s.before.isFrozen,profileId:i.profileId!==void 0?s.standing.profileId:s.before.profileId}}function V(s){let i=_(s);return s.accesses.length>0||i.isActive!==s.before.isActive||i.isFrozen!==s.before.isFrozen||f(i.profileId)!==f(s.before.profileId)}function H(s){let i=s.found.permissionSetAssignments.length>0||s.found.groupMembers.length>0?{found:s.found}:{};return{username:s.planned.username,userId:s.userId,before:s.before,done:s.done,created:{permissionSetAssignments:s.accesses.filter(o=>o.what!=="group").map(o=>o.id),groupMembers:s.accesses.filter(o=>o.what==="group").map(o=>o.id)},...i,...s.address!==void 0?{address:s.address}:{},...s.refused.length>0?{refused:s.refused}:{}}}async function ee(s){let{org:i,store:o,signal:h}=s,y=s.now??(()=>new Date),E=i.requests(),{state:A,plan:P,answer:a}=await B(s);if(P.refusals.length>0)return{kind:"refused",plan:a};if(f(A.connected.organizationId)!==f(s.organization.organizationId))throw new Error(`The connection is to ${A.connected.organizationId}, not to ${s.organization.organizationId}: nothing was written`);let c=P.users.flatMap(e=>e.userId!==void 0&&e.current!==void 0&&e.before!==void 0?[{planned:e,userId:e.userId,before:e.before,standing:{...e.current},done:[],refused:[],accesses:[...e.carried,...e.writes.unassign,...e.writes.leave],found:{permissionSetAssignments:[...e.found.permissionSetAssignments],groupMembers:[...e.found.groupMembers]},...e.address!==void 0?{address:e.address}:{}}]:[]),l=c.map(e=>e.planned.username),d=0,g=y().toISOString(),v=(e,r)=>({...s.previous?{replaces:s.previous.run}:{},status:e,startedAt:g,...r?{endedAt:y().toISOString()}:{},emailsToPeople:d,users:c.filter(n=>n.planned.inFile||V(n)).map(n=>({applied:H(n),after:_(n),accesses:n.accesses,inFile:n.planned.inFile}))}),W=(e,r,n)=>({version:1,organizationId:A.connected.organizationId,run:e,...v(r,n)}),M=(await o.begin(A.connected.organizationId,v("running",!1))).run,C=new Set,z=async(e,r,n,p,u)=>{if(e.length===0)return;let t=await i.update(p,e.map(r));e.forEach((m,w)=>{let I=F(m.planned,n);t[w]?.success===!0?(u(m),m.done.push(I)):m.refused.push({change:I,...k(t[w],l)})})},x=[()=>z(c.filter(e=>e.planned.writes.profileId!==void 0),e=>({Id:e.userId,ProfileId:e.planned.writes.profileId}),e=>e.what==="profile","User",e=>{e.standing.profileId=e.planned.writes.profileId??e.standing.profileId}),async()=>{for(let e of[!1,!0])await z(c.filter(r=>r.planned.writes.isActive===e),r=>({Id:r.userId,IsActive:e}),r=>r.what==="active","User",r=>{r.standing.isActive=e})},()=>z(c.filter(e=>e.planned.writes.isFrozen!==void 0),e=>({Id:e.planned.writes.loginId??"",IsFrozen:e.planned.writes.isFrozen}),e=>e.what==="frozen","UserLogin",e=>{e.standing.isFrozen=e.planned.writes.isFrozen??e.standing.isFrozen}),async()=>{let e=c.flatMap(r=>r.planned.writes.assign.map(n=>({one:r,assign:n})));if(e.length>0){let r=await i.create("PermissionSetAssignment",e.map(({one:n,assign:p})=>p.what==="permissionSet"?{AssigneeId:n.userId,PermissionSetId:p.setId}:{AssigneeId:n.userId,PermissionSetGroupId:p.setId}));e.forEach(({one:n,assign:p},u)=>{let t=r[u],m=F(n.planned,w=>w.what===p.what&&w.name===p.name&&w.to==="added");t?.success===!0&&t.id!==void 0?(n.accesses.push({id:t.id,what:p.what,name:p.name}),n.done.push(m)):t?.errors[0]?.code==="DUPLICATE_VALUE"?C.add(n):n.refused.push({change:m,...k(t,l)})})}await N("PermissionSetAssignment",r=>r.planned.writes.unassign)},async()=>{let e=c.filter(r=>r.planned.writes.join.length>0);if(e.length>0){let r=new Map;for(let p of R(e.map(u=>u.userId),200)){let u=await i.query(`SELECT Id, GroupId, UserOrGroupId FROM GroupMember WHERE UserOrGroupId IN ${b(p)}`);for(let t of u)r.set(`${f(String(t.UserOrGroupId))}:${f(String(t.GroupId))}`,String(t.Id))}let n=e.flatMap(p=>p.planned.writes.join.flatMap(u=>{let t=r.get(`${f(p.userId)}:${f(u.groupId)}`);return t!==void 0?(p.found.groupMembers.push(t),[]):[{one:p,join:u}]}));if(n.length>0){let p=new Set([...r.values()].map(f)),u=await i.create("GroupMember",n.map(({one:t,join:m})=>({GroupId:m.groupId,UserOrGroupId:t.userId})));n.forEach(({one:t,join:m},w)=>{let I=u[w],O=F(t.planned,U=>U.what==="group"&&U.name===m.name&&U.to==="added");if(I?.success===!0&&I.id!==void 0){if(p.has(f(I.id))){t.found.groupMembers.push(I.id);return}t.accesses.push({id:I.id,what:"group",name:m.name,type:m.type}),t.done.push(O)}else t.refused.push({change:O,...k(I,l)})})}}await N("GroupMember",r=>r.planned.writes.leave)},()=>z(c.filter(e=>e.planned.writes.email!==void 0),e=>({Id:e.userId,Email:e.planned.writes.email}),e=>e.what==="email","User",e=>{d+=1,e.address="awaiting"})];async function N(e,r){let n=c.flatMap(u=>r(u).map(t=>({one:u,access:t})));if(n.length===0)return;let p=await i.destroy(e,n.map(({access:u})=>u.id));n.forEach(({one:u,access:t},m)=>{let w=p[m],I=F(u.planned,U=>U.what===t.what&&"name"in U&&U.name===t.name&&U.to==="removed"),O=w?.errors.some(U=>K.has(U.code))===!0;w?.success===!0||O?(u.accesses=u.accesses.filter(U=>U.id!==t.id),w?.success===!0&&u.done.push(I)):u.refused.push({change:I,...k(w,l)})})}let S="success";for(let e of x){if(h?.aborted){S="cancelled";break}await e(),await o.write(W(M,"running",!1))}S!=="cancelled"&&await Y(i,c,C),S!=="cancelled"&&c.some(e=>e.refused.length>0)&&(S="partial");let G=W(M,S,!0);return await o.write(G),{kind:"applied",answer:{org:s.organization,run:M,status:S,users:c.map(H),emailsToPeople:d,apiRequests:i.requests()-E},record:G}}async function Y(s,i,o){let h=i.filter(a=>a.planned.writes.profileId!==void 0||a.planned.writes.isActive!==void 0||a.planned.writes.isFrozen!==void 0||a.planned.writes.email!==void 0),y=new Map(i.map(a=>[f(a.userId),a])),E=(a,c)=>{let l=a.done.findIndex(g=>g.what===c);if(l<0)return;let[d]=a.done.splice(l,1);a.refused.push({change:d,code:"NOT_HELD",message:"the org answered success, and its read after the run holds the user otherwise"})};for(let a of R(h.map(c=>c.userId),200)){let c=await s.query(`SELECT Id, Email, IsActive, ProfileId FROM User WHERE Id IN ${b(a)}`);for(let l of c){let d=y.get(f(String(l.Id)));if(!d)continue;let g=l.IsActive===!0,v=String(l.ProfileId);d.planned.writes.isActive!==void 0&&g!==d.standing.isActive&&E(d,"active"),d.planned.writes.profileId!==void 0&&f(v)!==f(d.standing.profileId)&&E(d,"profile"),d.standing.isActive=g,d.standing.profileId=v,d.address==="awaiting"&&typeof l.Email=="string"&&T(l.Email)===void 0&&(d.address="restored")}}let A=h.filter(a=>a.planned.writes.isFrozen!==void 0);for(let a of R(A.map(c=>c.userId),200)){let c=await s.query(`SELECT Id, UserId, IsFrozen FROM UserLogin WHERE UserId IN ${b(a)}`);for(let l of c){let d=y.get(f(String(l.UserId)));if(!d)continue;let g=l.IsFrozen===!0;g!==d.standing.isFrozen&&E(d,"frozen"),d.standing.isFrozen=g}}if(o.size===0)return;let P=await s.query(`SELECT Id, AssigneeId, PermissionSetId, PermissionSetGroupId FROM PermissionSetAssignment WHERE AssigneeId IN ${b([...o].map(a=>a.userId))}`);for(let a of o)for(let c of a.planned.writes.assign){let l=P.find(g=>f(String(g.AssigneeId))===f(a.userId)&&f(String((c.what==="permissionSet"?g.PermissionSetId:g.PermissionSetGroupId)??""))===f(c.setId)),d=l?String(l.Id):void 0;d!==void 0&&!a.accesses.some(g=>f(g.id)===f(d))&&!a.found.permissionSetAssignments.includes(d)&&a.found.permissionSetAssignments.push(d)}}export{B as a,ee as b};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a as Le}from"./chunk-YYZL7UGV.mjs";import{a as be,f as we,i as ke,j as ve,l as re}from"./chunk-YDXMTWAT.mjs";import{a as Pe,b as $e,c as xe,d as _e,e as _,f as Me,g as Ue,h as V,i as se,o as Je,p as Ke}from"./chunk-35B73566.mjs";import{a as S}from"./chunk-4TLYUZD5.mjs";import{c as je}from"./chunk-HF6LAK3G.mjs";import{a as x,b as Fe,d as Be,e as Ce,f as ne,h as Ne,i as We,j as Oe}from"./chunk-ATBQIE2V.mjs";import{a as Se,d as Ee}from"./chunk-UCUFLFNK.mjs";import{Y as ee,Z as fe,_ as he,a as H,ba as pe,ca as ge,d as Z,fa as me,ha as ye,ia as Re}from"./chunk-SZOJ7BEJ.mjs";import{b as I}from"./chunk-CA5NAXSU.mjs";import{d as Ie,e as te,f as Ae,k as Te}from"./chunk-22L43JMK.mjs";import{Ac as Q,Vc as ce,Yb as ue}from"./chunk-J347SPU6.mjs";function Qe(a){return Array.isArray(a)?a.length:(a.successfulResults?.length??0)+(a.failedResults?.length??0)}function De(a,e){let t=!1,n=!1,s,r={},o=0,i=0,d=(u,h)=>(i+=u,e?.(u),h()),l=async u=>{let h=await d(We,u);return o=Qe(h),h},c={createJob:u=>{let h=a.bulk2.createJob(u);return{get id(){return h.id},open:async()=>{await d(1,()=>h.open()),s=Ce(h)},uploadData:k=>d(1,()=>h.uploadData(k)),close:async()=>{t=!0,await d(1,()=>h.close()),n=!0},abort:()=>d(1,()=>h.abort()),check:async()=>{let k=await d(1,()=>h.check());return r={state:k.state,message:k.errorMessage},k},getAllResults:()=>l(()=>h.getAllResults())}}};if("job"in a.bulk2){let u=a.bulk2;c.job=(h,k)=>{let v=u.job(h,k);return{check:async()=>{let g=await d(1,()=>v.check());return r={state:g.state,message:g.errorMessage??void 0},g},getSuccessfulResults:()=>d(1,()=>v.getSuccessfulResults()),getAllResults:()=>l(()=>v.getAllResults()),abort:()=>d(1,()=>v.abort())}}}return{connection:{bulk2:c},closeSent:()=>t,closed:()=>n,jobId:()=>s,last:()=>r,processed:()=>o,requests:()=>i}}var L=class extends Error{constructor(t,n,s=0,r=[]){super(`Bulk API job ${t||"(no id)"} was closed, and what it wrote could not be read back: ${n}`);this.jobId=t;this.requests=s;this.twins=r;this.name="BulkJobLostError"}jobId;requests;twins},U=1e4,z=50*1024*1024,Ze=10,et=/not supported by the Bulk API|InvalidEntity/i,tt={unprocessed:"The Bulk API job did not write this row.",twin:"Kept out of the Bulk API job: another row carries the same values, and the job's results could not tell them apart.","may-have-written":"The Bulk API job may have written this row without saying so: it is not sent again."};async function Mt(a,e,t,n,s,r={}){let o=n==="insert"?s.map(st):s,i=Fe(x(n,o,r.externalIdField)),d=[];o.forEach((w,A)=>{i.has(A)||d.push(A)});let l=d.map(w=>o[w]),c=o.map((w,A)=>i.has(A)?"twin":"unprocessed"),u=w=>({answers:c.map(A=>M(A==="twin"?"twin":"unprocessed")),rows:c,unmatchedIds:[],...w});if(l.length===0)return u({requests:0});let h=x(n,l,r.externalIdField),k=Buffer.byteLength(h.text,"utf8");if(l.length>U||k>z)return u({requests:0,untouched:{reason:`${l.length} rows, ${k} bytes of CSV: past what one job takes (${U} rows, ${z} bytes)`}});let v=(w,A,F,p)=>{let T={requests:w.requests,...w.jobId?{jobId:w.jobId}:{}};if(w.info.state!=="JobComplete"&&w.processed===0&&p===0)return u({...T,untouched:oe(ne(w.info)??"job not complete")});let N=new Map(A.map(R=>[R.recordIndex,R])),f=c.map(R=>M(R==="twin"?"twin":"unprocessed"));return d.forEach((R,B)=>{let W=rt(N.get(B),p>0);c[R]=W.state,f[R]=W.answer}),{answers:f,rows:c,unmatchedIds:[...F],...T}},g=De(a),b,O=()=>b?{jobId:b}:{},C=r.pollDelay??Oe,m;try{m=await new Ne().executeBulk({connection:g.connection,bulkManager:e,pollIntervalMs:C,...r.signal?{signal:r.signal}:{},...r.onProgress?{onProgress:r.onProgress}:{},onOpened:w=>{b=w,r.onOpened?.(w)}},t,n,l,r.externalIdField)}catch(w){let A=I(w);if(!g.closeSent())return u({requests:g.requests(),...O(),untouched:oe(A)});if(b===void 0)throw new L("",A,g.requests(),[...i]);let F=await nt(g.connection,b,C);if(F.state==="never-closed")return u({requests:g.requests(),jobId:b,untouched:oe(A)});if(F.state!=="ended")throw new L(b,F.state==="unread"?F.reason:"still running",g.requests(),[...i]);let p=Be(F.results,h,ne(F.info));return v({info:F.info,processed:g.processed(),requests:g.requests(),jobId:b},p.outcomes,p.unattributedSuccessIds,p.unattributedSuccesses)}if(m.aborted)return u({requests:g.requests(),...O(),aborted:!0});let y=g.last();return v({info:{state:y.state??"JobComplete",...y.message?{errorMessage:y.message}:{}},processed:g.processed(),requests:g.requests(),...O()},m.outcomes,m.unmatchedIds??[],m.unmatchedWrites??0)}async function nt(a,e,t){let n=await re(a,e,{openGraceMs:0});for(let s=1;s<Ze;s++){if(n.state==="ended"||n.state==="never-closed")return n;await new Promise(r=>setTimeout(r,t(s-1))),n=await re(a,e,{openGraceMs:0})}return n}function oe(a){return et.test(a)?{reason:a,unsupported:!0}:{reason:a}}function M(a){return{id:"",success:!1,errors:[tt[a]]}}function rt(a,e){if(a===void 0||a.state==="no-result"){let s=e?"may-have-written":"unprocessed";return{state:s,answer:M(s)}}if(a.state==="unprocessed")return{state:"unprocessed",answer:M("unprocessed")};if(a.success)return a.id?{state:"answered",answer:{id:a.id,success:!0,errors:[],...a.created!==void 0?{created:a.created}:{}}}:{state:"may-have-written",answer:M("may-have-written")};let t=a.error??"Unknown error",n=Ie(t);return{state:"answered",answer:n?{id:"",success:!1,errors:[Ae(n)],errorDetails:[n]}:{id:"",success:!1,errors:[t]}}}function st(a){let e;for(let[t,n]of Object.entries(a))n===""&&(e??={...a},e[t]=null);return e??a}var le={rest:200,bulk:1e4},qe=3,at=3,He=3,dt=2e3;function lt(a){return new Promise(e=>setTimeout(e,a))}function ut(a,e,t={bulk:!1}){let n=t.bulk&&a.api==="bulk"&&e>=2e3?"bulk":"rest",s=Math.min(a.batchSize,le[n]);return{api:n,batchSize:s,batchCount:Math.ceil(e/s),clamped:s<a.batchSize}}function P(a){return a.refusals.flatMap(e=>e.leftOut)}function ie(a){let e=a.built?.source.Id;return typeof e=="string"?e:void 0}function Ve(a){return(a.built?.nullifiedFks??[]).map(({field:e,sourceRefId:t,insertOnly:n})=>({field:e,sourceRefId:t,...n?{insertOnly:n}:{}}))}function ct(a){let e=a.RecordTypeId;return typeof e=="string"&&e!==""}function ae(a){let e=a.refusals.length===0?a.payload:V(a.payload,P(a));return a.forms?{...e,...a.forms}:e}function ze(a,e){let t=new Map;return e?.refusedIn?.answers.forEach((n,s)=>{let r=a[s];n&&r&&t.set(r,n.errors)}),t}var ft=new Set,ht=new Map;function G(a){return{objectApiName:a.objectApiName,op:a.upsertField?"upsert":"insert"}}function Ge(a){return a!==void 0&&!a.success?ue(a.errors):void 0}function pt(a){let e=a.automation??"the target's automation";S.warn(`[forge] ${a.objectApiName}: ${e} hit ${a.limit??"a Salesforce limit"} on a call of ${a.from} \u2014 sending a record on its own, then smaller calls`+(a.op==="upsert"?" (upsert).":"."))}var Y={"validation-rule":"a validation rule","restricted-picklist":"a restricted picklist","lookup-filter":"a lookup filter","inactive-owner":"the target, the owner being inactive there"};function gt(a){let e=new Set(a.map(o=>o.refusedBy)),t=Object.keys(Y).filter(o=>o!=="inactive-owner"&&e.has(o)).map(o=>Y[o]),n=t.length>1?`${t.slice(0,-1).join(", ")} or ${t[t.length-1]}`:t[0],s=n===void 0?void 0:`${n} of the target`;if(!e.has("inactive-owner"))return s??`${Y["validation-rule"]} of the target`;let r=`${Y["inactive-owner"]},`;return s===void 0?r:`${s} or ${r}`}function de(a,e){if(!a.ownersMapped||a.ownersMapped.size===0)return!1;let t=_(e,"OwnerId"),n=t===void 0?void 0:e[t];return typeof n=="string"&&a.ownersMapped.has(n.slice(0,15))}function mt(a,e,t,n,s){let r=a.errorDetails??[];if(r.length===a.errors.length)return Me(r,e,t,n,s)}function Ye(a){a.linkedToCreatedCount=(a.linkedToCreatedCount??0)+1}function yt(a){let e=a.errorDetails??[];return Ee(a.errors,e.length===a.errors.length?e:void 0)}function q(a){return a.map(e=>e.field).join(", ")}function Rt(a,e){return`Sent again without ${q(a)} after the first refusal: ${e.join("; ")}`}var bt=["first","second","third","fourth","fifth","sixth","seventh"];function J(a){return a.map(({leftOut:e,errors:t,formed:n},s)=>{let r=bt[s]??`${s+1}th`;if(n!==void 0){let o=e.length>0?` and without ${q(e)}`:"";return`Sent again with ${n.join(", ")} in another form that reaches no one${o} after the ${r} refusal: ${t.join("; ")}`}return s===0?Rt(e,t):`Sent again without ${q(e)} too after the ${r} refusal: `+t.join("; ")})}function K(a){let e=(t,n)=>t.length===0?[]:[`Sent without ${q(t)}: ${n} earlier in the run, `+[...new Set(t.map(s=>s.reason))].join("; ")];return[...e(a.filter(t=>t.refusedBy!=="inactive-owner"),"the target refused the same value under the same record type"),...e(a.filter(t=>t.refusedBy==="inactive-owner"),"the target refused the same owner, inactive there,")]}function E(a){return`${a} record${a===1?"":"s"}`}var wt="The call was sent and its answer never came back: the target may hold any of these records, and which of them is unknown. Counted as failed and never sent again, they are not among the records the run created, which removing its records takes back.",kt="Counted as failed and never sent again, they are not among the records the run created; the records the job wrote that no row was matched to are, and removing the run's records takes them back.",vt="DUPLICATES_DETECTED";function It(a,e){if(a==="twin"||a==="unprocessed")return!0;if(a!=="answered"||e.success)return!1;let t=e.errorDetails;return t?.length!==1||t[0].statusCode===vt}function At(a,e){let t=i=>i.reduce((d,l)=>d+Math.max(Buffer.byteLength(l,"utf8"),4)+(l.split('"').length-1)+3,1),n=t(e.columns),s=[],r=0,o=n;return e.rows.forEach((i,d)=>{let l=t(i);d>r&&o+l>a&&(s.push([r,d]),r=d,o=n),o+=l}),e.rows.length>r&&s.push([r,e.rows.length]),s}function Tt(a,e,t){let n=a.find(r=>r.isReference&&r.nillable===!1&&r.name!=="OwnerId"&&e.has(r.name))?.name;if(n===void 0)return;let s=r=>{let o=t[r][n];return typeof o=="string"?o:""};if(t.some((r,o)=>s(o)!==""))return t.map((r,o)=>o).sort((r,o)=>{let i=s(r),d=s(o);return i===d?r-o:i===""?1:d===""||i<d?-1:1})}var Ft="The target refused the call for its API request limit, which no retry gets past: the node stopped there.",Bt="A validation rule of the target, or a trigger with its code, refused the row without naming a field: there was none to send it again without.";function Ct(){return{successCount:0,updatedCount:0,linkedExistingCount:0,failureCount:0,alreadyExistsCount:0,unidentifiedExistingCount:0,errorSamples:[],pendingFkUpdates:[]}}var Xe=class{constructor(e,t,n=lt,s=be()){this.deps=e;this.wait=n;this.splitting=s;this.batchStrategy=t??new je}deps;wait;splitting;batchStrategy;refusedValues=new Map;refusedOwners=new Map;backoff=new Se({initialDelay:dt});async writeNode(e,t=Ct()){let{node:n,fieldInfos:s,creatableFields:r,targetOrgId:o,remapper:i}=e,d=await this.heldBeforeInsert(n.objectApiName,o,e.records),l=ee[n.objectApiName];for(let[p,T]of d){let N=e.cleanedRecords[p]?.source,f=N?.Id;if(typeof f!="string")continue;i.addExisting(f,T,n.objectApiName);let R=N?.ContactId;n.objectApiName===H&&typeof R=="string"&&i.wasCreated(R)&&(t.withTheirRecord=[...t.withTheirRecord??[],f]);let B=n.objectApiName===H?"ContactId":l,W=B===void 0?void 0:N?.[B];typeof W=="string"&&i.wasCreated(W)&&(t.writtenByThePlatformCount=(t.writtenByThePlatformCount??0)+1)}t.linkedExistingCount+=d.size;let c=await this.giveFlagsBack(n.objectApiName,o,e,d);c&&(t.flagsNotKept=pe(t.flagsNotKept,c));let u=e.records.filter((p,T)=>!d.has(T)),h=e.cleanedRecords.filter((p,T)=>!d.has(T)),k=this.batchStrategy.resolve(n.batchStrategy,u.length),{api:v,batchSize:g,batchCount:b,clamped:O}=ut(k,u.length,{bulk:this.jobsCanCarry(e.bulk,n.objectApiName)});if(O&&S.warn(`[forge] ${n.objectApiName}: batch strategy asked for ${k.batchSize} records per call (api="${k.api}") but the write path is "${v}" (max ${le[v]}) \u2014 using ${g} per call (${b} batch(es)).`),v==="bulk"){let p=Tt(s,r,u);if(p){let T={records:u,cleanedRecords:h};u=p.map(N=>T.records[N]),h=p.map(N=>T.cleanedRecords[N])}}e.onProgress({objectName:n.objectApiName,status:"running",progress:0,recordCount:u.length,fieldCount:s.length,createableFieldCount:r.size,message:`Inserting ${u.length} ${n.objectApiName} records in ${b} batch(es)...`});let C=0,m=this.pickUpsertField(s,r,u,e.upsertMode==="auto"&&this.deps.upsertRecords?"auto":"off",e.tableKeys),y={objectApiName:n.objectApiName,targetOrgId:o,targetKeyPrefix:e.targetKeyPrefix,remapper:i,tally:t,oweLookups:e.oweLookups,onWritten:e.onWritten,onCreatedWithoutRecordType:e.onCreatedWithoutRecordType,calls:e.calls,bulk:e.bulk,byNaturalKey:[],refusedOnTheirFields:[],locked:[],upsertField:m,ownersMapped:e.ownersMapped,contactPoints:e.contactPoints,remembered:new Set([...e.picklistFields??[]].filter(([,p])=>p.controllerName===void 0).map(([p])=>p.toLowerCase()))},{byNaturalKey:w}=y,A=p=>{let T=I(p);this.leaveLockedAsFailed(y,y.locked.splice(0),T),this.leaveRefusedAsFailed(y,y.refusedOnTheirFields.splice(0),T),this.settleByNaturalKey(n.objectApiName,w,[],i,t,`The record the target holds under the same key was not looked up: ${T}`)};for(let p=0;p<b;p++){let T=u.slice(p*g,(p+1)*g).map((B,W)=>{let{sent:$,before:X}=this.withoutRefusedValues(y,B);return{payload:$,built:h[C+W],before:X,refusals:[],lockResends:0}}),N=`${n.objectApiName} batch ${p+1}/${b}`,f;try{f=await this.sendRows(y,e,T,N,u.length-C-T.length)}catch(B){throw A(B),B}if(f){let B=I(f.thrown);this.leaveLockedAsFailed(y,y.locked.splice(0),B),this.leaveRefusedAsFailed(y,y.refusedOnTheirFields.splice(0),B);break}C+=T.length;let R;try{R=await this.sendLockedAgain(y,e,u.length-C)}catch(B){throw A(B),B}if(R){this.leaveRefusedAsFailed(y,y.refusedOnTheirFields.splice(0),I(R.thrown));break}e.onProgress({objectName:n.objectApiName,status:"running",progress:Math.round((p+1)/b*100),message:`batch ${p+1}/${b} \u2014 ${Math.min((p+1)*g,u.length)}/${u.length} records`})}try{await this.writeAgainWithoutTheirFields(y,e,Math.min(g,le.rest))}catch(p){throw A(p),p}let F=Z[n.objectApiName];if(F&&w.length>0){let p,T;try{p=await this.recordsByNaturalKey(o,n.objectApiName,F,w.map(N=>N.payload))}catch(N){p=[],T=`The record the target holds under the same key could not be looked up: ${I(N)}`}this.settleByNaturalKey(n.objectApiName,w,p,i,t,T)}return t}send(e,t){return e.upsertField&&this.deps.upsertRecords?this.deps.upsertRecords(e.targetOrgId,e.objectApiName,e.upsertField,t):this.deps.insertRecords(e.targetOrgId,e.objectApiName,t)}jobsCanCarry(e,t){return e!==void 0&&this.deps.bulkWriteRecords!==void 0&&!e.restOnly.has(t)&&!e.bulkUnsupported.has(t)}goesSmallerByRest(e){return this.splitting.sizes.of(e)<200}async sendRows(e,t,n,s,r,o){let{bulk:i}=e;if(!i||!this.jobsCanCarry(i,e.objectApiName)||n.length<2e3)return this.sendByRest(e,t,n,s,r,o);for(let d=0;d<n.length;d+=U){let l=n.slice(d,d+U),c=n.length-d-l.length+r,u;try{u=l.length>=2e3?await this.writeAsJobs(e,t,i,l,s,c,o):await this.sendByRest(e,t,l,s,c,o)}catch(h){throw o?.(n.slice(d+l.length),I(h)),h}if(u)return u}}async sendByRest(e,t,n,s,r,o,i){if(n.length===0)return;try{await t.waitIfPaused()}catch(l){let c=I(l);throw o?o(n,c):this.leaveLimitedAsFailed(e,n,ze(n,i),c),l}let d=await this.callAndSettle(e,t,n,o,i);if(d)return this.settleThrown(e,d.threw,d.rows,s,d.rest.length+r),d.threw}async writeAsJobs(e,t,n,s,r,o,i){let d=this.deps.bulkWriteRecords;if(!d)return this.sendByRest(e,t,s,r,o,i);let l=G(e);if(this.goesSmallerByRest(l))return this.sendJobByRest(e,t,n,s,r,o,i);let c=e.upsertField?"upsert":"insert",u=s.map(ae),h=At(z,x(c,u,e.upsertField));for(let[k,v]of h){let g=s.slice(k,v),b=s.length-v+o;if(this.goesSmallerByRest(l)){let f;try{f=await this.sendJobByRest(e,t,n,g,r,b,i)}catch(R){throw i?.(s.slice(v),I(R)),R}if(f)return f;continue}try{await t.waitIfPaused()}catch(f){throw i?.(s.slice(k),I(f)),f}let O=u.slice(k,v),C=e.calls?.sending(e.objectApiName,g.map((f,R)=>({sourceId:ie(f),payload:O[R],owes:Ve(f)})),e.upsertField,!0),m;try{m=await d(e.targetOrgId,e.objectApiName,c,O,{bulkManager:n.manager,signal:n.signal,...e.upsertField?{externalIdField:e.upsertField}:{},onOpened:f=>{C!==void 0&&e.calls?.opened?.(C,f)}})}catch(f){if(f instanceof L){let R={thrown:f,left:"may-have-written",tries:1},B=new Set(f.twins),W=g.filter(($,X)=>!B.has(X));return this.settleThrown(e,R,W,`${r} (Bulk API job)`,b),this.leaveTwinsUnsent(e,g.length-W.length,r,f),R}m={answers:[],rows:[],unmatchedIds:[],untouched:{reason:I(f)},requests:0}}if(m.aborted){try{await t.waitIfPaused()}catch(f){throw C!==void 0&&e.calls?.answered(C),i?.(s.slice(k),I(f)),f}m={...m,untouched:{reason:"the job was aborted"}}}if(m.untouched){C!==void 0&&e.calls?.answered(C),m.untouched.unsupported&&n.bulkUnsupported.add(e.objectApiName),S.warn(`[forge] ${e.objectApiName}: a Bulk API job of ${E(g.length)} wrote nothing (${m.untouched.reason}) \u2014 sent by REST`+(m.untouched.unsupported?", as every write of the object in the run.":"."));let f;try{f=await this.sendByRest(e,t,g,r,b,i)}catch(R){throw i?.(s.slice(v),I(R)),R}if(f)return f;continue}m.unmatchedIds.length>0&&(e.calls?.unattributed?.(e.objectApiName,m.unmatchedIds),S.warn(`[forge] ${e.objectApiName}: Bulk API job ${m.jobId??""} wrote ${E(m.unmatchedIds.length)} no row was matched to \u2014 kept for removal.`));let y=[],w=[],A=[],F=[],p=[],T=[],N;if(g.forEach((f,R)=>{let B=m.rows[R]??"unprocessed",W=m.answers[R],$=B==="answered"?Ge(W):void 0;B==="may-have-written"?T.push(f):$!==void 0&&W!==void 0?(N??=$,F.push(f),p.push(W)):!W||It(B,W)?A.push(f):(y.push(f),w.push(W))}),this.settleMayHaveBeenWritten(e,T,r,m.jobId),await this.settleAnswers(e,y,C===void 0?{answers:w}:{answers:w,callId:C}),A.length>0){let f;try{f=await this.sendByRest(e,t,A,`${r}, by REST`,F.length+b,i)}catch(R){throw i?.([...F,...s.slice(v)],I(R)),R}if(f)return f}if(F.length>0){let f;try{f=await this.sendByRest(e,t,F,`${r}, by REST`,b,i,{refusedIn:{from:200,answers:p,...N?{cause:N}:{}}})}catch(R){throw i?.(s.slice(v),I(R)),R}if(f)return f}}}async sendJobByRest(e,t,n,s,r,o,i){let d=G(e),{sizes:l,allowance:c}=this.splitting,u=l.of(d),h=Math.ceil(s.length/u),k=c.take(d,h);l.countExtraCalls(d,k);let v=s.slice(0,k*u),g=s.slice(v.length);if(v.length>0){let b;try{b=await this.sendByRest(e,t,v,r,g.length+o,i,{pricedAs:"job",paid:{calls:k}})}catch(O){throw i?.(g,I(O)),O}finally{k<h&&l.spend(d)}if(b)return b}else k<h&&l.spend(d);if(g.length!==0)return g.length>=2e3?this.writeAsJobs(e,t,n,g,r,o,i):this.sendByRest(e,t,g,r,o,i)}leaveTwinsUnsent(e,t,n,s){t!==0&&(e.tally.failureCount+=t,this.sample(e.tally,{recordSummary:`${n}: ${E(t)} not written`,messages:[I(s),"Kept out of the Bulk API job as twins of other rows, to be written by REST once it answered: never sent, the target holds none of them."]}))}settleMayHaveBeenWritten(e,t,n,s){if(t.length===0)return;let{tally:r}=e;r.failureCount+=t.length;let o=t.map(ie).filter(i=>i!==void 0);r.mayHaveBeenWritten=[...r.mayHaveBeenWritten??[],...o],this.sampleAhead(r,{recordSummary:`${n}: ${E(t.length)} may have been written`,messages:[`Bulk API job ${s??""} gave them no result of their own, and wrote records no row was matched to: the target may hold any of these records, and which of them is unknown.`,kt]})}async call(e,t,n){let s=n.map(ae);for(let r=0;;r++){let o=e.calls?.sending(e.objectApiName,n.map((i,d)=>({sourceId:ie(i),payload:s[d],owes:Ve(i)})),e.upsertField);try{let i=await this.send(e,s);return o===void 0?{answers:i}:{answers:i,callId:o}}catch(i){let d=Le(i);if(o!==void 0&&d!=="may-have-written"&&e.calls?.answered(o),d!=="not-received"||r===qe)return{thrown:i,left:d,tries:r+1};let l=this.backoff.calculateDelay(r);S.warn(`[forge] ${e.objectApiName}: a call of ${E(s.length)} never reached the target (${I(i)}) \u2014 sent again in ${l} ms (${r+1}/${qe}).`),await this.wait(l),await t.waitIfPaused()}}}async callAndSettle(e,t,n,s,r){let o,i={answers:[]},d=ze(n,r),{stopped:l}=await ve(n,{key:G(e),sizes:this.splitting.sizes,allowance:this.splitting.allowance,...r,beforeEachSend:()=>t.waitIfPaused(),send:async c=>{let u=await this.call(e,t,c);return"thrown"in u?(o=u,"stop"):(i=u,{answers:u.answers})},limited:(c,u)=>{let h=Ge(c);return h&&c&&d.set(u,c.errors),h},settle:(c,u,h,k,v)=>this.settleAnswers(e,c,v?{answers:u}:i,h,k),onThrow:(c,u)=>{let h=I(u);s?s(c,h):this.leaveLimitedAsFailed(e,c,d,h)},onFirstRefusal:pt});if(!(!l||o===void 0))return{threw:o,rows:l.part,rest:l.rest}}sample(e,t){e.errorSamples.length<3&&e.errorSamples.push(t)}sampleAhead(e,t){e.errorSamples.unshift(t),e.errorSamples.splice(3)}async settleAnswers(e,t,{answers:n,callId:s},r=ft,o=ht){t.forEach((i,d)=>{let l=n[d];l?.success&&!r.has(d)&&this.settle(e,l,i)}),e.remapper.persist(),await this.readWhatMayBeEmpty(e,n.filter(i=>i!==void 0)),t.forEach((i,d)=>{if(r.has(d))return;let l=n[d];if(l){l.success||this.settle(e,l,i,o.get(d));return}e.tally.failureCount++,this.sample(e.tally,{recordSummary:j(i.payload),messages:[`No result returned for record (API truncated batch: ${n.length}/${t.length})`,...J(i.refusals),...K(i.before)]})}),e.remapper.persist(),s!==void 0&&e.calls?.answered(s)}async readWhatMayBeEmpty(e,t){if(e.mayBeEmpty!==void 0||!t.some(r=>(r.errorDetails??[]).some(o=>o.statusCode===$e)))return;let s=await this.deps.describeFields?.(e.targetOrgId,e.objectApiName).catch(()=>{});e.mayBeEmpty=new Set((s??[]).filter(r=>r.nillable===!0).map(r=>r.name.toLowerCase()))}settleThrown(e,t,n,s,r){let{tally:o}=e,i=I(t.thrown);if(o.failureCount+=n.length+r,t.left==="may-have-written"){let l=n.map(c=>c.built?.source.Id).filter(c=>typeof c=="string");o.mayHaveBeenWritten=[...o.mayHaveBeenWritten??[],...l],this.sampleAhead(o,{recordSummary:`${s}: ${E(n.length)} may have been written`,messages:[i,wt,...r>0?[`${E(r)} after them not sent.`]:[]]});return}let d=n.length+r;this.sample(o,{recordSummary:`${s}: ${E(d)} not written`,messages:[i,...t.left==="request-limit"?[Ft]:[],...t.left==="not-received"?[`Sent ${t.tries} times, the call never reached the target: it holds none of them.`]:[]]})}async sendLockedAgain(e,t,n){for(let s=0;e.locked.length>0;s++){let r=this.backoff.calculateDelay(s);S.warn(`[forge] ${e.objectApiName}: the target could not lock a record for ${E(e.locked.length)} \u2014 sent again in ${r} ms.`),await this.wait(r),await t.waitIfPaused();let o=e.locked.splice(0),i=o.map(({row:c})=>({...c,lockResends:c.lockResends+1})),d=new Map(i.map((c,u)=>[c,o[u]])),l=await this.callAndSettle(e,t,i,(c,u)=>this.leaveLockedAsFailed(e,c.flatMap(h=>d.get(h)??[]),u));if(l)return this.settleThrown(e,l.threw,l.rows,`${e.objectApiName}, sent again`,n+l.rest.length),this.leaveLockedAsFailed(e,e.locked.splice(0),I(l.threw.thrown)),l.threw}}settle(e,t,n,s){let{tally:r,remapper:o,objectApiName:i}=e,{built:d,before:l}=n,c=ae(n);if(t.success){let m=d?.source.Id,y=t.created===!1;if(y?r.updatedCount++:r.successCount++,typeof m=="string"&&(y?o.addUpdated(m,t.id,i):o.add(m,t.id,i)),d&&e.onWritten?.(d,t.id),!y&&!ct(c)&&e.onCreatedWithoutRecordType?.(d,t.id),d&&d.nullifiedFks.length>0){let A=typeof d.source.Id=="string"?d.source.Id:void 0,F=d.nullifiedFks.map(p=>({objectApiName:i,newId:t.id,sourceId:A,fieldName:p.field,sourceRefId:p.sourceRefId,...p.insertOnly?{insertOnly:!0}:{}}));e.oweLookups?e.oweLookups(F):r.pendingFkUpdates.push(...F)}let w=[...l,...P(n)];w.length>0&&(r.writtenWithoutFields=se(r.writtenWithoutFields,{rows:1,fields:w.map(A=>({...A,rows:1}))})),e.contactPoints&&(n.formsTried||n.refusals.length>0)&&e.contactPoints.count(Ke(n.formsTried??new Map,P(n),e.contactPoints.fieldOf));for(let{field:A,refusedBy:F}of w)F!=="lookup-filter"||!t.id||(r.leftEmptyByFilter??=[]).push({field:A,recordId:t.id});return}this.rememberRefusedValues(e,t,c),this.rememberRefusedOwners(e,t,c);let u=Te(t,e.targetKeyPrefix);if(u.kind==="linked"){r.linkedExistingCount++,o.createdTarget(u.id)&&Ye(r);let m=d?.source.Id;typeof m=="string"&&o.addExisting(m,u.id,i);return}if(u.kind==="unidentified"&&Z[i]){e.byNaturalKey.push({payload:c,sourceId:d?.source.Id,errors:t.errors});return}let h=yt(t);if(h&&n.lockResends<at){e.locked.push({row:n,errors:t.errors});return}let k=m=>e.mayBeEmpty?.has(m.toLowerCase())??!1,v=mt(t,c,e.upsertField,k,{inactiveOwner:!de(e,c)}),g=n.formsTried??new Map,b=v&&e.contactPoints?Je(v,c,e.contactPoints.fieldOf,g):void 0;if(b&&Object.keys(b.forms).length>0){let m=new Set(b.leftOut.map(({field:y})=>y));e.refusedOnTheirFields.push({...n,forms:{...Object.fromEntries(Object.entries(n.forms??{}).filter(([y])=>!m.has(y))),...b.forms},formsTried:g,refusals:[...n.refusals,{errors:t.errors,leftOut:b.leftOut,formed:Object.keys(b.forms)}]});return}let O=b?.leftOut??v,C=n.refusals.filter(m=>m.formed===void 0).length<He;if(O&&C){let m=new Set(O.map(({field:y})=>y));e.refusedOnTheirFields.push({...n,...n.forms?{forms:Object.fromEntries(Object.entries(n.forms).filter(([y])=>!m.has(y)))}:{},refusals:[...n.refusals,{errors:t.errors,leftOut:O}]});return}r.failureCount++,u.kind==="unidentified"&&r.unidentifiedExistingCount++,t.errors.every(m=>Q(m))&&r.alreadyExistsCount++,this.sample(r,{recordSummary:j(n.payload),messages:[...t.errors,...J(n.refusals),...h?[`Sent again ${n.lockResends} times, the target still could not lock a record the write needed.`]:[],...O&&!C?[`Not sent again: a row goes again without the fields the target refused ${He} times at most.`]:[],...Ue(t.errorDetails)?[Bt]:[],...s?[we(s,ke(this.splitting.allowance,G(e)),"run")]:[],...K(l)]})}refusedValueKey(e,t,n){let s=t.RecordTypeId,r=t[n];if(typeof s!="string"||s===""||typeof r!="string"||r==="")return;let o=n.toLowerCase();if(!(!e.remembered.has(o)||o===e.upsertField?.toLowerCase()))return[e.objectApiName,s,o,r].join("\0")}rememberRefusedValues(e,t,n){for(let s of t.errorDetails??[])if(s.statusCode===Pe)for(let r of s.fields){let o=_(n,r),i=o===void 0?void 0:this.refusedValueKey(e,n,o);o===void 0||i===void 0||this.refusedValues.has(i)||this.refusedValues.set(i,{field:o,refusedBy:"restricted-picklist",reason:te(s)})}}rememberRefusedOwners(e,t,n){let s=_(n,"OwnerId");if(!(s===void 0||s.toLowerCase()===e.upsertField?.toLowerCase())&&!de(e,n))for(let r of t.errorDetails??[]){if(r.statusCode!==xe)continue;let o=_e(r,n);o===void 0||this.refusedOwners.has(o)||this.refusedOwners.set(o,{field:"OwnerId",refusedBy:"inactive-owner",reason:te(r)})}}withoutRefusedValues(e,t){let n=[];if(this.refusedValues.size===0&&this.refusedOwners.size===0)return{sent:t,before:n};for(let o of Object.keys(t)){let i=this.refusedValueKey(e,t,o),d=i===void 0?void 0:this.refusedValues.get(i);d&&n.push({...d,field:o})}let s=_(t,"OwnerId"),r=s===void 0?void 0:t[s];if(s!==void 0&&typeof r=="string"&&s.toLowerCase()!==e.upsertField?.toLowerCase()&&!de(e,t)){let o=this.refusedOwners.get(r.slice(0,15));o&&n.push({...o,field:s})}return n.length===0?{sent:t,before:n}:{sent:V(t,n),before:n}}leaveRefusedAsFailed(e,t,n){for(let s of t){let r=s.refusals[s.refusals.length-1];e.tally.failureCount++,this.sample(e.tally,{recordSummary:j(s.payload),messages:[...r?.errors??[],...J(s.refusals.slice(0,-1)),P(s).length>0||!s.forms?`Not written again without ${q(P(s))}: ${n}`:`Not written again with ${Object.keys(s.forms).join(", ")} in another form that reaches no one: ${n}`,...K(s.before)]})}}leaveLimitedAsFailed(e,t,n,s){for(let r of t){let o=n.get(r);o&&(e.tally.failureCount++,this.sample(e.tally,{recordSummary:j(r.payload),messages:[...o,...J(r.refusals),`Not sent again in a smaller call: ${s}`,...K(r.before)]}))}}leaveLockedAsFailed(e,t,n){for(let{row:s,errors:r}of t)e.tally.failureCount++,this.sample(e.tally,{recordSummary:j(s.payload),messages:[...r,...J(s.refusals),`Not sent again: ${n}`,...K(s.before)]})}async writeAgainWithoutTheirFields(e,t,n){for(;e.refusedOnTheirFields.length>0;){let s=e.refusedOnTheirFields.splice(0);if(t.onProgress({objectName:e.objectApiName,status:"running",progress:100,message:`Writing ${s.length} ${e.objectApiName} record${s.length===1?"":"s"} again without the fields ${gt(s.flatMap(P))} refused`+(s.some(r=>r.forms&&Object.keys(r.forms).length>0)?", or with another form of an address or a number that reaches no one...":"...")}),this.jobsCanCarry(e.bulk,e.objectApiName)&&s.length>=2e3){let r=`${e.objectApiName}, sent again`,o=await this.sendRows(e,t,s,r,0,(i,d)=>this.leaveRefusedAsFailed(e,i,d));if(o??=await this.sendLockedAgain(e,t,0),o){let i=I(o.thrown);this.leaveLockedAsFailed(e,e.locked.splice(0),i),this.leaveRefusedAsFailed(e,e.refusedOnTheirFields.splice(0),i);return}continue}for(let r=0;r<s.length;r+=n){let o=s.slice(r,r+n),i;try{await t.waitIfPaused()}catch(l){throw this.leaveRefusedAsFailed(e,s.slice(r),I(l)),l}try{i=await this.callAndSettle(e,t,o,(l,c)=>this.leaveRefusedAsFailed(e,l,c))}catch(l){throw this.leaveRefusedAsFailed(e,s.slice(r+n),I(l)),l}let d;if(i){d=i.threw;let l=I(i.threw.thrown),c=[...i.rest,...s.slice(r+n)];i.threw.left==="may-have-written"?(this.settleThrown(e,i.threw,i.rows,`${e.objectApiName}, sent again`,0),this.leaveRefusedAsFailed(e,c,l)):this.leaveRefusedAsFailed(e,[...i.rows,...c],l)}else{try{d=await this.sendLockedAgain(e,t,0)}catch(l){throw this.leaveRefusedAsFailed(e,s.slice(r+n),I(l)),l}d&&this.leaveRefusedAsFailed(e,s.slice(r+n),I(d.thrown))}if(d){this.leaveRefusedAsFailed(e,e.refusedOnTheirFields.splice(0),I(d.thrown));return}}}}settleByNaturalKey(e,t,n,s,r,o){t.forEach((i,d)=>{let l=n[d];if(l&&typeof i.sourceId=="string"){s.createdTarget(l)&&Ye(r),s.addExisting(i.sourceId,l,e),r.linkedExistingCount++;return}r.failureCount++,r.unidentifiedExistingCount++,i.errors.every(c=>Q(c))&&r.alreadyExistsCount++,r.errorSamples.length<3&&r.errorSamples.push({recordSummary:j(i.payload),messages:o?[...i.errors,o]:i.errors})})}async recordsByNaturalKey(e,t,n,s){let r=this.deps.queryRecords;return r?Re(o=>r(e,o),t,n,s):s.map(()=>{})}async giveFlagsBack(e,t,n,s){let r=this.deps.updateRecords;if(!r||s.size===0||!he[e])return;let o=[];for(let[d,l]of s){let c=n.cleanedRecords[d]?.source;c&&o.push([c,l])}let i=await this.deps.describeFields?.(t,e).catch(()=>{});return ge(e,o,d=>i?.find(l=>l.name===d)?.updateable!==!1,d=>r(t,e,d),n.stopped)}async heldBeforeInsert(e,t,n){let s=this.deps.queryRecords;if(!s)return new Map;let r=o=>s(t,o);return e===H?me(r,n):ee[e]!==void 0?fe(r,e,n):e===ce?ye(r,n):new Map}pickUpsertField(e,t,n,s,r){if(s==="off"||!this.deps.upsertRecords)return;let o=e.filter(i=>i.externalId&&t.has(i.name)).sort((i,d)=>i.name.localeCompare(d.name));if(r)return this.tableKeyOfThePage(o,n,r);if(o.length!==0){for(let i of o){let d=new Set,l=!0;for(let c of n){let u=c[i.name];if(typeof u!="string"||u.length===0){l=!1;break}if(d.has(u)){l=!1;break}d.add(u)}if(l)return S.info(`[forge] upsert: using "${i.name}" as external Id (unique across ${n.length} records)`),i.name}S.warn(`[forge] upsert: no externalId candidate is non-null+unique across batch (${o.map(i=>i.name).join(", ")}) \u2014 falling back to insert`)}}tableKeyOfThePage(e,t,n){let s=e.find(o=>n.unique.has(o.name))?.name;if(s===void 0){e.length>0&&S.warn(`[forge] upsert: no externalId candidate is non-null+unique across the rows read (${e.map(o=>o.name).join(", ")}) \u2014 falling back to insert`);return}let r=new Set;for(let o of t){let i=o[s];if(typeof i!="string"||i.length===0||r.has(i)){S.warn(`[forge] upsert: a row of this page leaves "${s}" empty or repeats it \u2014 inserting the page`);return}if(n.sent.has(i)){S.warn(`[forge] upsert: a row of this page repeats a "${s}" an earlier page sent \u2014 inserting the page`);return}r.add(i)}n.sent.size===0&&S.info(`[forge] upsert: using "${s}" as external Id (unique across the rows read of the object)`);for(let o of r)n.sent.add(o);return s}};function j(a){let e=Object.keys(a).slice(0,4),t=[];for(let n of e){let s=a[n],r;if(s===null)r="null";else if(s===void 0)r="undefined";else if(typeof s=="string")r=s.length>30?s.slice(0,30)+"\u2026":s;else if(typeof s=="object")try{let o=JSON.stringify(s);r=o.length>30?o.slice(0,30)+"\u2026":o}catch{r="<unserializable>"}else r=String(s);t.push(`${n}=${r}`)}return t.join(" ")||"(empty)"}export{L as a,U as b,Mt as c,le as d,ut as e,ct as f,mt as g,Rt as h,Ct as i,Xe as j,j as k};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{f as u,g as l}from"./chunk-H33DVU3D.mjs";import{c as d}from"./chunk-
|
|
7
|
+
import{f as u,g as l}from"./chunk-H33DVU3D.mjs";import{c as d}from"./chunk-DUBECLZV.mjs";var p="## Still to do, in this order",f="## Not touched by SandForge";function s(n){return`\`${n.replace(/[`\r\n]+/g," ").trim()}\``}function h(n){return n.replace(/[\r\n]+/g," ").trim()}function y(n){return n.replace(/\.\d{3}Z$/,"Z")}function S(n,o){return`# Handoff: ${s(n)} on ${s(o.alias??o.organizationId)}`}function $(n){let o=d(n.host),e=n.kind==="sandbox"?`sandbox${o!==void 0?` ${s(o)}`:""}`:n.kind==="scratch"?"scratch org":"Developer Edition org";return`- Org: ${n.alias!==void 0?`${s(n.alias)}, `:""}${e}, ${s(n.organizationId)}.`}function b(n,o){let e=[p,""];e.push("1. Credentials and technical components: point them away from production.");let r=n?.endpoints;if(r===void 0)e.push(` - Not audited: ${o.endpoints}`);else{for(let t of r.found)e.push(` - ${l[t.source]} ${s(t.name)} names ${s(t.host)}, ${u[t.why]}.`);r.found.length===0&&r.unread===void 0&&e.push(" - None of those read names production."),r.unread!==void 0&&e.push(" - Not all read: check the Named Credentials, the Remote Site Settings and the Custom Metadata in Setup.")}e.push("2. Scheduled jobs: schedule again those gone, and give those stuck a user who can run them.");let i=n?.schedules;if(i===void 0)e.push(` - Not audited: ${o.schedules}`);else{for(let t of i.jobs)t.status==="gone"?e.push(` - ${s(t.name)} (${h(t.type)}) was scheduled in the inventory of ${i.against?.savedAt.slice(0,10)??"?"}, and is not now.`):(t.status==="frozen"||t.status==="inactive")&&e.push(` - ${s(t.name)} (${h(t.type)}) runs as ${t.owner!==void 0?s(t.owner):"a user not read"}, who is ${t.status}: its next run fails.`);i.against===void 0&&e.push(" - No inventory from before the refresh was kept on this machine: what is gone is not known."),i.unread!==void 0&&e.push(" - Not all read: Setup > Scheduled Jobs lists them."),!i.jobs.some(t=>t.status!=="new")&&i.unread===void 0&&e.push(i.against!==void 0?" - None gone, none stuck.":" - None stuck.")}e.push("3. Automations that send emails \u2014 flows, workflow rules, Apex \u2014: turn them on last, once the addresses and the masking are as the testers need them."),e.push("4. Deliverability.");let a=n?.deliverability;return a?.read==="closed"?e.push(" - Read closed, System email only or No access: leave it so until the masking is done."):a?.read==="open"?e.push(" - Read open, All email: what runs there emails whoever its records name. Set it to System email only in Setup > Deliverability until the masking is done."):e.push(" - Not read: Setup > Deliverability shows it."),e}var c=["- Named and External Credentials: Setup, or a deployment of your project by `sf`.","- Metadata: your deployment.","- Single sign-on and DKIM keys: Setup.","- Deliverability: Setup > Deliverability.","- Passwords: each user's own, by Forgot your password? on the sandbox's login page."];function w(){return[f,"",...c]}export{s as a,y as b,S as c,$ as d,b as e,w as f};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{j as g}from"./chunk-
|
|
7
|
+
import{j as g}from"./chunk-J347SPU6.mjs";var f=class{link(n,r,i,t){return t.length===0?n:n.map(o=>({...o,[r]:t[Math.floor(Math.random()*t.length)]}))}resolveInsertOrder(n,r=[]){let i=new Map;for(let e of n)i.set(e.objectApiName,e);let t=new Set,o=new Set,d=[];function c(e){if(t.has(e))return;if(o.has(e))throw new Error(`Circular dependency detected involving: ${e}`);o.add(e);let s=i.get(e);if(s){let p=g(s,r);for(let j of p)c(j);d.push(s)}o.delete(e),t.add(e)}for(let e of n)c(e.objectApiName);return d}};export{f as a};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a}from"./chunk-
|
|
7
|
+
import{a}from"./chunk-CZXDJXQP.mjs";import"./chunk-J347SPU6.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as ReferenceLinker};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{
|
|
7
|
+
import{Dc as S,Ec as O}from"./chunk-J347SPU6.mjs";import{b as y,f as b,l as R}from"./chunk-WZQEK4WT.mjs";var v=["User","Group","Profile","UserRole","RecordType","Organization","Queue","PermissionSet","BusinessProcess","CurrencyType","DandBCompany","DuplicateRecordItem","DuplicateRecordSet","ProcessInstance","LoginHistory","LoginEvent","LoginIp","LoginGeo","AsyncApexJob","ApexLog","ApexTestResult","ApexTestQueueItem","LightningUsageByPageMetrics","LightningExitByPageMetrics","EventBusSubscriber","PlatformEventUsageMetric","CronTrigger","CronJobDetail","AttachedContentDocument","AttachedContentNote","CombinedAttachment","ContentBody","NoteAndAttachment","OwnedContentDocument","EntitySubscription","TopicAssignment","UserRecordAccess","DeclinedEventRelation","UndecidedEventRelation","AcceptedEventRelation","OpenActivity","ActivityHistory","AppUsageAssignment","AuthProvider","Folder","ContentDocument","ContentDocumentLink","OpportunityRelatedDeleteLog","CaseHistory2","Calendar","SlaProcess","AccountCleanInfo","ContactCleanInfo","LeadCleanInfo","ApprovalSubmission","ApprovalSubmissionDetail","ApprovalWorkItem","AIRecordInsight","AIInsightValue","MatchingInformation","Invoice","InvoiceLine","CreditMemo","CreditMemoLine","AppDefinition","BackgroundOperation","ContentTaxonomyTermRelationshipType","Dashboard","DashboardComponent","DeleteEvent","ManagedContentChannel","ManagedContentSpace","ManagedContentVariant","Report","ServiceSetupProvisioning","TabDefinition"],P=new Set(v.map(e=>e.toLowerCase())),W=["History","Feed","Share","ChangeEvent","__hd","__Tag","EventStore"].map(e=>e.toLowerCase()),F=/^vlocity_[a-z0-9]+__/;function B(e,t){return I(e,t,{byNamespace:!0})}function I(e,t,r){let n=e.toLowerCase();return P.has(n)||S(e)||t&&(t.has(e)||U(t).has(n))||r.byNamespace&&F.test(n)?!0:W.some(i=>n.endsWith(i))}var w=new WeakMap;function U(e){let t=w.get(e);if(t&&t.size===e.size)return t.names;let r=new Set([...e].map(n=>n.toLowerCase()));return w.set(e,{size:e.size,names:r}),r}function z(e,t){return O(e)||B(e,t)}function E(e){return O(e)||I(e,void 0,{byNamespace:!1})}function x(e,t=[]){let r=new Set(t);for(let n of e)n.createable===!1&&r.add(n.name);return r}function le(e,t=r=>z(r)){return new Set(e.filter(r=>{let n=r.referenceTo??[];return n.length>0&&n.every(i=>t(i))}).map(r=>r.name))}var ge=R({name:y(),queryable:b().optional(),createable:b().optional(),updateable:b().optional(),deletable:b().optional(),undeletable:b().optional(),customSetting:b().optional(),layoutable:b().optional(),keyPrefix:y().nullish()}).loose(),D="ContentDocument",H="ContentDocumentLink",G="ContentVersion",L="Attachment",J=[D,L],K={AccountContactRelation:["Contact"]},V=new Set(["feeditem","feedcomment","feedattachment"]),X=new Set(["casehistory2"]),Y=new Set(["AccountCleanInfo","ContactCleanInfo","LeadCleanInfo","ApprovalSubmission","ApprovalSubmissionDetail","ApprovalWorkItem","ProcessInstance","ProcessInstanceNode","ProcessInstanceStep","ProcessInstanceWorkitem","AIRecordInsight","AIInsightValue","AIInsightAction","AIInsightFeedback","AIInsightReason","MatchingInformation","Invoice","InvoiceLine","CreditMemo","CreditMemoLine","CreditMemoInvApplication"].map(e=>e.toLowerCase())),Q=new Set([G,H].map(e=>e.toLowerCase())),Z=["__b","__x","__dlm","__kav","__ka","__e"],$=new Set(["AccountContactRole",L,"CaseTeamMember","EmailMessageRelation","EventRelation","OpportunityCompetitor"].map(e=>e.toLowerCase()));function q(e,t,r,n,i){let o=e.name.toLowerCase();return V.has(o)||o.endsWith("feed")?"chatter":o.endsWith("history")||o.endsWith("__hd")||X.has(o)?"history":o.endsWith("share")?"sharing":o.endsWith("changeevent")?"changeEvent":Z.some(c=>o.endsWith(c))?"unsupportedKind":e.customSetting===!0?n?A(e,i)?void 0:"notWritable":"customSetting":Q.has(o)?"heldWithFiles":o===D.toLowerCase()?(i==="delete"?_(e):T(e))?void 0:"notWritable":o===L.toLowerCase()?A(e,i)?void 0:"notWritable":S(e.name)?"files":Y.has(o)?"platformCreated":E(e.name)||r==="everything"&&e.layoutable===!1&&!$.has(o)?"setup":t.out.has(o)?t.tooling.has(o)?"metadata":"notWritable":A(e,i)?void 0:"notWritable"}function A(e,t){return t==="delete"?_(e):ee(e)}function ee(e){return e.createable===!0&&T(e)}function _(e){return e.queryable===!0&&e.deletable===!0}function T(e){return e.queryable===!0&&e.updateable===!0&&e.deletable===!0}function k(e,t){return e.objectApiName<t.objectApiName?-1:e.objectApiName>t.objectApiName?1:0}var te="all";function ne(e){return e.customSetting===!0}function oe(e,t){let r=e.filter(ne);if(t===void 0)return{held:new Set,unknown:[]};if(t===te)return{held:new Set(r.map(c=>c.name.toLowerCase())),unknown:[]};let n=new Set(r.map(c=>c.name.toLowerCase())),i=new Set,o=[];for(let c of t){let p=c.toLowerCase();i.has(p)||o.some(u=>u.toLowerCase()===p)||(n.has(p)?i.add(p):o.push(c))}return{held:i,unknown:o}}function he(e,t,r=[]){let n=t.access??"write",i=n==="delete"?r:x(e,r),o={out:new Set([...i].map(a=>a.toLowerCase())),tooling:new Set(r.map(a=>a.toLowerCase()))},c=new Set((t.excluded??[]).map(a=>a.toLowerCase())),p=new Map(e.map(a=>[a.name.toLowerCase(),a])),u=oe(e,t.customSettings),h=u.unknown.map(a=>({objectApiName:a,reason:"notCustomSetting"})),g=[],f=[],s=[];if(t.mode==="picked"){let a=new Set;for(let d of t.objects??[]){let l=d.toLowerCase();if(a.has(l))continue;a.add(l);let m=p.get(l);m?f.push(m):h.push({objectApiName:d,reason:"notFound"})}for(let d of J){let l=d.toLowerCase(),m=p.get(l);if(!(a.has(l)||m===void 0)){if(c.has(l)){h.push({objectApiName:m.name,reason:"excludedByUser"});continue}f.push(m),s.push(m.name)}}for(let[d,l]of Object.entries(K)){let m=d.toLowerCase(),C=p.get(m);if(!(a.has(m)||C===void 0)&&l.some(j=>a.has(j.toLowerCase()))){if(a.add(m),c.has(m)){h.push({objectApiName:C.name,reason:"excludedByUser"});continue}f.push(C)}}for(let d of u.held){let l=p.get(d);a.has(d)||l===void 0||(a.add(d),f.push(l))}}else f.push(...p.values());for(let a of f){let d=a.name.toLowerCase(),l=c.has(d)?"excludedByUser":q(a,o,t.mode,u.held.has(d),n);l===void 0?g.push(a.name):h.push({objectApiName:a.name,reason:l})}return g.sort(),h.sort(k),{mode:t.mode,candidates:g,leftOut:h,addedToPicked:s}}function be(e){return e.fields.find(r=>r.name==="Name")?.nillable===!0?"hierarchy":"list"}function Ce(e){return e==="hierarchy"?"SetupOwnerId":"Name"}function Se(e){return e.objects.some(t=>t.customSetting!==void 0)}function re(e){let t=e.split("__");return t.length>=3&&t[0]!==""?t[0]:void 0}var se=()=>({first:"child",firmness:0});function ie(e,t,r=se){let n=new Map(e.map((o,c)=>[o.toLowerCase(),c])),i=e.map(()=>new Map);return e.forEach((o,c)=>{for(let p of t.get(o)?.childRelationships??[]){let u=n.get(p.childSObject.toLowerCase());if(u===void 0||u===c)continue;let h=r(p);if(h===void 0)continue;let[g,f]=h.first==="child"?[u,c]:[c,u],s=i[g].get(f);(s===void 0||h.firmness>s)&&i[g].set(f,h.firmness)}}),N(e.map((o,c)=>c),i,Number.NEGATIVE_INFINITY).map(o=>e[o])}function N(e,t,r){let n=new Set(e),i=f=>[...t[f]].filter(([s,a])=>n.has(s)&&a>r).map(([s])=>s),o=ae(e,i,t.length),c=new Map;o.forEach((f,s)=>{for(let a of f)c.set(a,s)});let p=o.map(()=>0),u=o.map(()=>new Set);for(let f of e){let s=c.get(f)??0;for(let a of i(f)){let d=c.get(a)??0;d===s||u[s].has(d)||(u[s].add(d),p[d]++)}}let h=o.map(()=>!1),g=[];for(let f=o.length;f>0;f--){let s=-1;for(let d=0;d<o.length;d++){if(h[d]||p[d]>0)continue;let l=o[d].length===1,m=s>=0&&o[s].length===1;(s<0||l&&!m||l===m&&o[d][0]<o[s][0])&&(s=d)}h[s]=!0;let a=o[s];if(a.length===1)g.push(a[0]);else{let d=Number.POSITIVE_INFINITY;for(let l of a)for(let[m,C]of t[l])C>r&&c.get(m)===s&&C<d&&(d=C);g.push(...N(a,t,d))}for(let d of u[s])p[d]--}return g}function ae(e,t,r){let n=new Array(r).fill(-1),i=new Array(r).fill(0),o=new Array(r).fill(!1),c=[],p=[],u=0;for(let h of e){if(n[h]>=0)continue;let g=[],f=s=>{n[s]=u,i[s]=u,u++,c.push(s),o[s]=!0,g.push({node:s,edges:t(s),at:0})};for(f(h);g.length>0;){let s=g[g.length-1];if(s.at<s.edges.length){let l=s.edges[s.at++];n[l]<0?f(l):o[l]&&(i[s.node]=Math.min(i[s.node],n[l]));continue}g.pop();let a=g[g.length-1];if(a&&(i[a.node]=Math.min(i[a.node],i[s.node])),i[s.node]!==n[s.node])continue;let d=[];for(let l=c.pop();l!==void 0&&(o[l]=!1,d.push(l),l!==s.node);l=c.pop());p.push(d.sort((l,m)=>l-m))}}return p}function M(e){let t=new Map;for(let{objectApiName:r,namespace:n}of e)n!==void 0&&t.set(n,[...t.get(n)??[],r]);return[...t].sort(([r],[n])=>r<n?-1:r>n?1:0).map(([r,n])=>({namespace:r,objects:n.sort()}))}function ce(e,t){return ie(e,t).map((r,n)=>{let i=re(r);return{objectApiName:r,readOrder:n,...i===void 0?{}:{namespace:i}}})}function ye(e,t,r=new Map){let n=[...e.leftOut],i=[];for(let c of e.candidates){let p=t.get(c);if(p)p.fields.some(u=>u.name==="SystemModstamp")?p.fields.some(u=>u.name==="IsDeleted")?i.push(c):n.push({objectApiName:c,reason:"noRecycleBin"}):n.push({objectApiName:c,reason:"noSystemModstamp"});else{let u=r.get(c);n.push({objectApiName:c,reason:"notDescribed",...u===void 0?{}:{detail:u}})}}let o=ce(i,t);return{mode:e.mode,objects:o,leftOut:n.sort(k),packages:M(o)}}function Oe(e,t){if(t.size===0)return e;let r=[...e.leftOut],n=[];for(let i of e.objects){let o=t.get(i.objectApiName);o===void 0?n.push({...i,readOrder:n.length}):r.push({objectApiName:i.objectApiName,reason:"unreadable",detail:o})}return{...e,objects:n,leftOut:r.sort(k),packages:M(n)}}export{B as a,z as b,E as c,x as d,le as e,ge as f,D as g,H as h,G as i,L as j,J as k,te as l,ne as m,he as n,be as o,Ce as p,Se as q,re as r,ie as s,ye as t,Oe as u};
|
|
@@ -0,0 +1,10 @@
|
|
|
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 w}from"./chunk-PE7CHD2W.mjs";import{a as C}from"./chunk-4TLYUZD5.mjs";import{createHash as _}from"node:crypto";var v=new Set(["unmanaged","beta","released"]);function N(c){let{namespacePrefix:a,manageableState:n}=c;return typeof a!="string"||a===""?!1:typeof n!="string"||!v.has(n)}function P(c){let a;try{a=JSON.parse(c)}catch{return!1}return typeof a!="object"||a===null?!1:N(a)}function x(c,a){let n=new Set;for(let t of[c,a])for(let[r,i]of t)P(i)&&n.add(r);let s=t=>new Map([...t].filter(([r])=>!n.has(r)));return{source:s(c),target:s(a),leftOut:n.size}}var k=4,D=3,O=30,b=240,R=class{fetchMetadata;diffEngine;reader;budget;now;constructor(a,n,s,t={}){this.fetchMetadata=a,this.diffEngine=n,this.reader=s,this.budget=t.budget??w,this.now=t.now??Date.now}async compare(a,n,s,t={includeManaged:!0},r){let i=[],d=0;for(let e of s){r?.throwIfAborted();let[p,o]=await Promise.all([this.fetchMetadata(a,e),this.fetchMetadata(n,e)]);if(t.includeManaged){i.push({componentType:e,source:p,target:o});continue}let{source:f,target:g,leftOut:h}=x(p,o);d+=h,i.push({componentType:e,source:f,target:g})}let l=B(i,e=>this.reader.batchSize(e),this.budget.components),m=await this.readPlanned(a,n,l.toRead,r);r?.throwIfAborted();let u=[];for(let{componentType:e,source:p,target:o}of i)u.push(...this.judge(e,p,o,l.toRead.get(e)??[],l.notCompared.get(e)??new Map,m.get(e)));return{items:u,managedLeftOut:d}}async readPlanned(a,n,s,t){let i=this.now()+this.budget.seconds*1e3,d=new Map,l=[];for(let[e,p]of s){let o={source:new Map,target:new Map,unread:new Set};d.set(e,o);let f=this.reader.batchSize(e)??p.length;for(let g=0;g<p.length;g+=f){let h=p.slice(g,g+f);l.push(async()=>{if(t?.throwIfAborted(),this.now()>=i){for(let M of h)o.unread.add(M);return}let[A,I]=await Promise.all([this.readOne(a,e,h,t),this.readOne(n,e,h,t)]);for(let[M,y]of A)o.source.set(M,y);for(let[M,y]of I)o.target.set(M,y)})}}let m=0,u=async()=>{for(;m<l.length;){let e=l[m];m+=1,await e()}};return await Promise.all(Array.from({length:Math.min(k,l.length)},u)),d}async readOne(a,n,s,t){try{return await this.reader.read(a,n,s)}catch(r){return t?.throwIfAborted(),C.warn(`[compare] reading ${s.length} ${n} failed: ${r instanceof Error?r.message:String(r)}`),new Map}}judge(a,n,s,t,r,i){let d=new Map(n),l=new Map(s),m=new Map,u=new Map(r);for(let e of t){let p=i?.source.get(e),o=i?.target.get(e);i?.unread.has(e)?u.set(e,"over_budget"):p===null||o===null?u.set(e,"unreadable"):p===void 0||o===void 0?u.set(e,"read_failed"):(d.set(e,E(p)),l.set(e,E(o)),m.set(e,{source:p,target:o}))}return this.diffEngine.diff(d,l,a,u).map(e=>{let p=[n,s].some(f=>{let g=f.get(e.fullName);return g!==void 0&&P(g)}),o=p?{...e,managed:p}:e;if(o.status==="modified"){let f=m.get(o.fullName),g=f?F(f.source,f.target):void 0;return{...o,sourceValue:g?.source,targetValue:g?.target}}return o.status==="unchanged"?{...o,sourceValue:void 0,targetValue:void 0}:o})}};function B(c,a,n){let s=new Map,t=new Map,r=[],i=[];for(let{componentType:u,source:e,target:p}of c){let o=[...e.keys()].filter(g=>p.has(g)).sort(),f=new Map;if(t.set(u,f),a(u)===void 0){for(let g of o)f.set(g,"unreadable");r.push([]),i.push([]);continue}r.push(o.filter(g=>e.get(g)!==p.get(g))),i.push(o.filter(g=>e.get(g)===p.get(g)))}let d=T(r.map(u=>u.length),n),l=d.reduce((u,e)=>u+e,0),m=T(i.map(u=>u.length),n-l);return c.forEach(({componentType:u},e)=>{let p=t.get(u)??new Map,o=[...r[e].slice(0,d[e]),...i[e].slice(0,m[e])];for(let f of r[e].slice(d[e]))p.set(f,"over_budget");for(let f of i[e].slice(m[e]))p.set(f,"over_budget");o.length>0&&s.set(u,o)}),{toRead:s,notCompared:t}}function T(c,a){let n=c.map(()=>0),s=c.map((i,d)=>d).sort((i,d)=>c[i]-c[d]),t=Math.max(0,a),r=s.length;for(let i of s){let d=Math.min(c[i],Math.floor(t/r));n[i]=d,t-=d,r-=1}return n}function E(c){return _("sha256").update(c).digest("hex")}function F(c,a){let n=c.split(`
|
|
8
|
+
`),s=a.split(`
|
|
9
|
+
`),t=0;for(;t<n.length&&t<s.length&&n[t]===s[t];)t+=1;let r=Math.max(0,t-D);return{source:S(n,r),target:S(s,r)}}function S(c,a){let n=Math.min(c.length,a+O),s=String(n).length,t=c.slice(a,n).map((r,i)=>{let d=r.length>b?`${r.slice(0,b)}\u2026`:r;return`${String(a+i+1).padStart(s)}\u2502 ${d}`});return a>0&&t.unshift("\u2026"),n<c.length&&t.push("\u2026"),t.join(`
|
|
10
|
+
`)}export{N as a,P as b,R as c,B as d,F as e};
|
|
@@ -0,0 +1,17 @@
|
|
|
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 g=()=>({input:process.stdin,output:process.stderr}),p;function w(){return p===void 0||p.ended?!1:(p.output.write(`
|
|
8
|
+
`),p.ended=!0,!0)}function v(t,s,o){let{input:n,output:r}=s;if(n.isTTY!==!0&&(r.write(`${t}
|
|
9
|
+
no terminal to answer: give --yes to go ahead without the question.
|
|
10
|
+
`),process.exit(2)),o?.aborted===!0)return Promise.resolve(void 0);r.write(`${t} `);let a={output:r,ended:!1};return p=a,new Promise(f=>{let u=i=>{p===a&&(p=void 0),n.off("data",e),n.off("end",d),o?.removeEventListener("abort",c),n.pause(),f(i)},e=i=>u(String(i).trim()),d=()=>u(void 0),c=()=>{a.ended||r.write(`
|
|
11
|
+
`),u(void 0)};n.on("data",e),n.on("end",d),o?.addEventListener("abort",c,{once:!0}),n.resume()})}async function R(t,s=g(),o){let n=await v(`${t} [y/N]`,s,o);return n!==void 0&&/^y(es)?$/i.test(n)}async function L(t,s=g(),o){return await v(t,s,o)??""}var N=new Set(["\r",`
|
|
12
|
+
`]),E=new Set(["\x7F","\b"]),b="",y="";function h(t,s,o=g()){let{input:n,output:r}=o;return n.isTTY!==!0&&(r.write(`${t}
|
|
13
|
+
no terminal to type it on: ${s}.
|
|
14
|
+
`),process.exit(2)),r.write(`${t} `),n.setRawMode?.(!0),new Promise(a=>{let f="",u=c=>{n.off("data",e),n.off("end",d),n.setRawMode?.(!1),n.pause(),r.write(`
|
|
15
|
+
`),a(c)},e=c=>{for(let i of String(c)){if(N.has(i))return u(f);if(i===b||i===y&&f==="")return u(void 0);E.has(i)?f=f.slice(0,-1):i>=" "&&(f+=i)}},d=()=>u(void 0);n.on("data",e),n.on("end",d),n.resume()})}var _=1e3,m=["SIGINT","SIGTERM","SIGHUP"],x={SIGHUP:129,SIGINT:130,SIGTERM:143};function M(t){return x[t]}var l=!1;function A(t){return l?"stopped by the command that started it":t==="SIGINT"?"Ctrl-C again ends it at once":"a second signal ends it at once"}function C(t,s){let o=w();process.stderr.write(`${o?"":`
|
|
16
|
+
`}interrupted: ${t} (${A(s)})
|
|
17
|
+
`)}var P="sandforge:stop",I="SANDFORGE_STOP_CHANNEL";function $(t){l=!1;let s=new Map,o=new Map,n,r,a=e=>{let d=o.get(e);d&&process.off(e,d),o.delete(e),r?.signal===e&&(clearTimeout(r.timer),r=void 0)},f=()=>{for(let[e,d]of s)process.off(e,d);s.clear(),n&&process.off("message",n),n=void 0},u=()=>{f();for(let e of m)a(e)};for(let e of m){let d=()=>{r?.signal===e&&a(e)};o.set(e,d),process.on(e,d);let c=()=>{f();for(let T of m)T!==e&&a(T);let i={signal:e};r=i;let S=setTimeout(()=>a(e),_);typeof S=="object"&&S.unref(),r===i&&(i.timer=S),l=process.env[I]==="signal",t(e)};s.set(e,c),process.once(e,c)}return process.env[I]==="ipc"&&typeof process.send=="function"&&(n=e=>{e===P&&(u(),l=!0,t("SIGINT"))},process.on("message",n),process.channel?.unref()),u}export{w as a,R as b,L as c,h as d,m as e,M as f,A as g,C as h,P as i,I as j,$ as k};
|
|
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{
|
|
7
|
+
import{q as ne}from"./chunk-H6BHWAX7.mjs";import{H as v,d as z,l as oe,m as se,n as ie}from"./chunk-4CSBZZAL.mjs";import{E as J,x as Be}from"./chunk-4XROG5CT.mjs";import{c as Pe}from"./chunk-EADHKH3A.mjs";import{h as Oe}from"./chunk-TZE3Y7IQ.mjs";import{b as L}from"./chunk-CA5NAXSU.mjs";import{a as re}from"./chunk-22L43JMK.mjs";import{$c as I}from"./chunk-J347SPU6.mjs";import{b as N,e as ee,f as ke,i as te,k as Q,l as D,s as xe}from"./chunk-WZQEK4WT.mjs";var rt="encryptedstring";async function nt(o){try{let[e]=await o("SELECT PermissionsViewEncryptedData FROM UserPermissionAccess");return e?.PermissionsViewEncryptedData===!0}catch{return!1}}function lr(o){let e;return()=>(e??=nt(o),e)}function ur(o,e){let r=new Map;return t=>{let n=r.get(t);return n||(n=(async()=>{let s;try{s=(await e(t)).fields.filter(i=>i.type===rt).map(i=>i.name)}catch{return[]}return s.length>0&&!await o()?s:[]})(),r.set(t,n)),n}}var _=5,ce=25,de=3;function mr(o){return{get version(){return o.version},request:async e=>await o.request(e),query:async(e,r)=>await o.query(e,{scanAll:r?.scanAll===!0}),queryMore:async e=>await o.queryMore(e)}}var j=class extends Error{constructor(){super("The read was stopped."),this.name="OrgReadStopped"}},st="PROCESSING_HALTED",Ce="If-Modified-Since",it=/^\d{1,3}\.\d$/,at=/^\/services\/data\/v\d{1,3}\.\d\/query(?:All)?\/[A-Za-z0-9-]+$/,ct=D({records:Q(xe(N(),te())),done:ke(),totalSize:ee().optional(),nextRecordsUrl:N().optional()}).loose(),dt=D({compositeResponse:Q(D({body:te(),httpStatusCode:ee(),referenceId:N()}).loose())}),lt=Q(D({errorCode:N().optional(),message:N().optional()}).loose());function ut(o,e,r){if(!it.test(o))throw new Error(`Not an API version: ${o}`);if(e.length>_)throw new Error(`A composite runs ${_} queries, not ${e.length}`);if(e.length+r.length>ce)throw new Error(`A composite holds ${ce} subrequests, not ${e.length+r.length}`);let t=`/services/data/v${o}`;return{allOrNone:!1,compositeRequest:[...e.map((n,s)=>({method:"GET",url:n.kind==="first"?`${t}/${n.scanAll?"queryAll":"query"}?q=${encodeURIComponent(n.soql)}`:n.path,referenceId:`q${s}`})),...r.map(({path:n,headers:s},a)=>({method:"GET",url:`${t}/${n}`,referenceId:`d${a}`,...s?{httpHeaders:s}:{}}))]}}function ft(o){let e=dt.safeParse(o);if(!e.success)return;let r=new Map;for(let t of e.data.compositeResponse){if(t.httpStatusCode<400){r.set(t.referenceId,{ok:!0,status:t.httpStatusCode,body:t.body});continue}let n=lt.safeParse(t.body),s=n.success?n.data[0]:void 0;r.set(t.referenceId,{ok:!1,refused:s?[s.errorCode,s.message].filter(Boolean).join(": "):`status ${t.httpStatusCode}`,halted:s?.errorCode===st})}return r}function ae(o){let e=ct.safeParse(o);return e.success?e.data:void 0}function ht(o){return typeof o=="object"&&o!==null&&typeof o.errorCode=="string"}function pt(o){let e=/^https:\/\//i.test(o)?new URL(o).pathname:o;if(!at.test(e))throw new Error(`Not the next page of a query: ${o}`);return e}function wr(o,e){let r=new Set,t=[],n=_,s="composite",a=0,i=!1,c=!1,d=0,p=0,f=!1,m=()=>{for(let u of r)u.state==="pending"&&(u.state="idle",u.settle?.reject(new j));for(let u of t.splice(0))u.settle.reject(new j)},A=()=>{c||(c=!0,queueMicrotask(()=>{c=!1,B()}))},h=(u,w)=>{u.state="idle";let y=u.settle;u.ask=void 0,u.settle=void 0,w instanceof Error?y?.reject(w):y?.resolve(w)},l=async(u,w)=>{let y=ut(o.version,u.map(E=>E.ask),w),g;p++;try{g=await o.request({method:"POST",url:"/composite",body:JSON.stringify(y),headers:{"Content-Type":"application/json"}})}catch(E){if(ht(E)){s="single";for(let R of u)R.state="pending";t.unshift(...w);return}let x=new Error(L(E));for(let R of u)h(R,x);for(let R of w)R.settle.reject(x);return}let k=ft(g);if(!k){s="single";for(let E of u)E.state="pending";t.unshift(...w);return}let P=0;if(u.forEach((E,x)=>{let R=k.get(`q${x}`);if(R&&!R.ok&&R.halted){P++,E.state="pending";return}if(!R){h(E,new Error("The org gave no answer to this query of the composite"));return}if(!R.ok){h(E,new Error(R.refused));return}let tt=ae(R.body);h(E,tt??new Error(`The org answered a query with status ${R.status} and no page`))}),P>0){let E=u.length-P;E===0?s="single":n=Math.min(n,E)}w.forEach((E,x)=>{let R=k.get(`d${x}`);R?R.ok?E.settle.resolve(R.status===304?{notModified:!0}:{body:R.body}):E.settle.reject(new Error(R.refused)):E.settle.reject(new Error("The org gave no answer to this describe of the composite"))})},b=async(u,w)=>{for(let y of u){let g=y.ask;p++;try{let k=g.kind==="first"?await o.query(g.soql,{scanAll:g.scanAll}):await o.queryMore(g.path);h(y,ae(k)??new Error("The org answered a query with no page"))}catch(k){h(y,new Error(L(k)))}}for(let y of w){p++;try{let g=await o.request({method:"GET",url:`/services/data/v${o.version}/${y.path}`,...y.headers?{headers:y.headers}:{}}),k=y.headers?.[Ce]!==void 0&&(g==null||g==="");y.settle.resolve(k?{notModified:!0}:{body:g})}catch(g){y.settle.reject(new Error(L(g)))}}},S=async(u,w,y)=>{try{s==="composite"?await l(u,w):await b(u,w)}catch(g){let k=new Error(L(g));for(let P of u)P.state==="sent"&&h(P,k);for(let P of w)P.settle.reject(k)}finally{a--,y||(i=!1),A(),Se()}},B=()=>{if(e?.aborted){m();return}for(;;){if(i)return;let u=[...r],w=u.filter(x=>x.state==="pending").sort((x,R)=>x.order-R.order);if(!(w.length>0&&!u.some(x=>x.state==="idle"))&&t.length===0)return;let g=w.slice(0,n),k=ce-g.length,P=s==="composite"&&t.length===0&&g.length>0&&g.every(x=>x.oneRow&&x.ask?.kind==="first");if(a>=(P?de:1))return;let E=t.splice(0,k);if(g.length===0&&E.length===0)return;for(let x of g)x.state="sent";a++,P||(i=!0),S(g,E,P)}},O=()=>{f=!1,A()},Y=()=>{f||e===void 0||e.aborted||(e.addEventListener("abort",O,{once:!0}),f=!0)},Se=()=>{!f||a>0||r.size>0||t.length>0||(e?.removeEventListener("abort",O),f=!1)},Re=(u,w)=>r.has(u)?u.state!=="idle"?Promise.reject(new Error("A read asks one page at a time.")):e?.aborted?Promise.reject(new j):new Promise((y,g)=>{u.ask=w,u.settle={resolve:y,reject:g},u.state="pending",u.order=++d,A()}):Promise.reject(new Error("This read is closed."));return{lane(u){let w={state:"idle",order:0,oneRow:u?.oneRow===!0};return r.add(w),Y(),{query:(y,g)=>Re(w,{kind:"first",soql:y,scanAll:g?.scanAll===!0}),queryMore:y=>{let g;try{g=pt(y)}catch(k){return Promise.reject(k instanceof Error?k:new Error(String(k)))}return Re(w,{kind:"next",path:g})},close(){r.delete(w)&&(w.state==="pending"&&h(w,new Error("This read is closed.")),A(),Se())}}},describe(u,w){return e?.aborted?Promise.reject(new j):new Promise((y,g)=>{let k=I(u),P;if(w!==void 0){let E=Date.parse(w);if(!Number.isFinite(E))throw new Error(`Not a date: ${w}`);P={[Ce]:new Date(E).toUTCString()}}Y(),t.push({path:`sobjects/${k}/describe`,...P?{headers:P}:{},settle:{resolve:y,reject:g}}),A()})},async tooling(u){if(e?.aborted)throw new j;p++;let w;try{w=await o.request({method:"GET",url:`/services/data/v${o.version}/tooling/query?q=${encodeURIComponent(u)}`})}catch(g){throw new Error(L(g))}let y=ae(w);if(!y)throw new Error("The org answered a Tooling API query with no page");return y},calls:()=>p}}import{createReadStream as mt}from"node:fs";import{appendFile as wt,stat as gt,writeFile as yt}from"node:fs/promises";import{StringDecoder as bt}from"node:string_decoder";import{promisify as je}from"node:util";import{createGunzip as At,gunzip as Et,gzip as St}from"node:zlib";var Rt=je(St),kt=je(Et),xt=64*1024,Ot=".gz",Pt=6,M=10,Ie=4,ve=Buffer.from("SF","latin1"),ue=8,H=6+ue,fe=M+H,he=fe+2+8;function $(o){return`${o}${Ot}`}async function Bt(o){let e=await Rt(o,{level:Pt});if(e[3]!==0)throw new Error("zlib wrote a gzip header with flags set");let r=Buffer.from(e.subarray(0,M));r[3]=Ie;let t=Buffer.alloc(H);return t.writeUInt16LE(H-2,0),ve.copy(t,2),t.writeUInt16LE(ue,4),t.writeUInt32LE(e.length+H,6),t.writeUInt32LE(o.length,10),Buffer.concat([r,t,e.subarray(M)])}function Me(o){if(o.length<fe||o[0]!==31||o[1]!==139||o[2]!==8||o[3]!==Ie||o.readUInt16LE(M)!==H-2||!o.subarray(M+2,M+4).equals(ve)||o.readUInt16LE(M+4)!==ue)return;let e=o.readUInt32LE(M+6),r=o.readUInt32LE(M+10);return e>=he&&r>0?{total:e,raw:r}:void 0}function Ct(o,e=xt){let r=[],t=0,n=0;for(;n<o.length;){let s=o.indexOf(10,n),a=s<0?o.length:s+1;a-t>e&&n>t&&(r.push(o.subarray(t,n)),t=n),n=a,n-t>=e&&(r.push(o.subarray(t,n)),t=n)}return n>t&&r.push(o.subarray(t,n)),r}async function Ne(o){let e=Ct(Buffer.from(o,"utf8"));return Buffer.concat(await Promise.all(e.map(r=>Bt(r))))}function U(o){return o.endsWith(".ndjson")}function kr(o){let e=new Map,r=(t,n)=>{let s=n(e.get(t)??Promise.resolve());return e.set(t,s),s.then(()=>{e.get(t)===s&&e.delete(t)},()=>{}),s};return{...o,writeFile:(t,n)=>{if(!U(t))return o.writeFile(t,n);let s=$(t);return r(s,a=>a.catch(()=>{}).then(async()=>{let i=n===""?Buffer.alloc(0):await Ne(n);await yt(s,i,{mode:z})}))},appendFile:(t,n)=>{if(!U(t))return o.appendFile(t,n);let s=$(t);return r(s,a=>a.then(async()=>{n!==""&&await wt(s,await Ne(n),{mode:z})}))},exists:t=>o.exists(U(t)?$(t):t),rm:t=>o.rm(U(t)?$(t):t),readLines:t=>U(t)?Nt($(t)):o.readLines(t)}}async function*Nt(o){if((await gt(o)).size===0)return;let e=mt(o),r=At(),t=a=>{r.destroy(a)};e.on("error",t),e.pipe(r);let n=new bt("utf8"),s="";try{for await(let a of r){let i=(s+n.write(a)).split(`
|
|
8
8
|
`);s=i.pop()??"",yield*i}s+=n.end(),s!==""&&(yield s)}finally{e.off("error",t),e.destroy(),r.destroy()}}async function le(o,e,r){let t=Buffer.alloc(r),n=0;for(;n<r;){let{bytesRead:s}=await o.read(t,n,r-n,e+n);if(s===0)break;n+=s}return n===r?t:t.subarray(0,n)}async function De(o,e,r,t){let n;try{n=await kt(o,{maxOutputLength:e.raw})}catch{throw t(`holds a block that does not inflate at byte ${r}`)}if(n.length!==e.raw)throw t(`holds a block at byte ${r} that inflates to other than its header says`);return n}async function Le(o,e,r,t){let n=await le(o,e,r);if(n.length<r)throw t(`is cut short at byte ${e+n.length}`);let s=Me(n);if(s===void 0)throw t(`holds no block where its index says, at byte ${e}`);if(s.total!==r)throw t(`holds another block than its index says at byte ${e}`);return De(n,s,e,t)}async function*$e(o,e,r){for(let t=0;t<e;){let n=Me(await le(o,t,Math.min(fe,e-t)));if(n===void 0)throw r(`holds no block at byte ${t}`);if(n.total>e-t)throw r(`is cut short: its block at byte ${t} ends past the file's end`);let s=await le(o,t,n.total);yield{at:t,total:n.total,lines:await De(s,n,t,r)},t+=n.total}}function*Te(o){let e=0;for(;e<o.length;){let r=o.indexOf(10,e),t=r<0?o.length:r;yield{at:e,length:t-e},e=t+1}}import{randomBytes as jt}from"node:crypto";import{open as W,readFile as we,rename as It,rm as vt,stat as Mt}from"node:fs/promises";import{dirname as Ge,join as Dt}from"node:path";var Fe=2e3,C=15,pe=C,T=pe+8,ge={format:1,head:Buffer.from("SFCKIDX1","latin1"),lengthAt:T+8,rowBytes:T+8+4},We={format:2,head:Buffer.from("SFCKIDX2","latin1"),memberBytesAt:T+8,lineAt:T+12,lengthAt:T+16,rowBytes:T+20},Ye={1:ge,2:We},G=ge.head.length,ze=1<<20,Lt=500,F=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,$t=/^[A-Za-z0-9]{15}$/,ye=/^[A-Za-z][A-Za-z0-9_]*$/;function Mr(o,e){return G+o*Ye[e].rowBytes}function _e(o){return o.replace(/[^A-Za-z0-9_-]/g,"_")}function Qe(o,e,r){if(!ye.test(r)||r.length>80)throw new v("invalid","Not a Salesforce API name");return Dt(o.dir,"backups",`${_e(e)}__${_e(r)}.ndjson`)}var Z=class{constructor(e,r){this.layout=e;this.rowBytes=e.rowBytes,this.bytes=r??Buffer.alloc(this.rowBytes*1024),this.size=r?r.length/this.rowBytes:0}layout;bytes;rowBytes;size;push(e,r,t){let n=this.size*this.rowBytes;if(n+this.rowBytes>this.bytes.length){let c=Buffer.alloc(Math.max(this.bytes.length*2,this.rowBytes*1024));this.bytes.copy(c,0,0,n),this.bytes=c}let{memberBytesAt:s,lineAt:a,lengthAt:i}=this.layout;return this.bytes.write(e,n,C,"latin1"),this.bytes.writeDoubleLE(r,n+pe),this.bytes.writeDoubleLE(t.offset,n+T),s!==void 0&&this.bytes.writeUInt32LE(t.memberBytes??0,n+s),a!==void 0&&this.bytes.writeUInt32LE(t.line??0,n+a),this.bytes.writeUInt32LE(t.length,n+i),this.size++}keyAt(e){let r=e*this.rowBytes;return this.bytes.toString("latin1",r,r+C)}holds(e,r){let t=e*this.rowBytes;for(let n=0;n<C;n++)if(this.bytes[t+n]!==r.charCodeAt(n))return!1;return!0}stampAt(e){return this.bytes.readDoubleLE(e*this.rowBytes+pe)}offsetAt(e){return this.bytes.readDoubleLE(e*this.rowBytes+T)}memberBytesAt(e){let r=this.layout.memberBytesAt;return r===void 0?0:this.bytes.readUInt32LE(e*this.rowBytes+r)}lineAt(e){let r=this.layout.lineAt;return r===void 0?0:this.bytes.readUInt32LE(e*this.rowBytes+r)}lengthAt(e){return this.bytes.readUInt32LE(e*this.rowBytes+this.layout.lengthAt)}before(e,r){return this.offsetAt(e)-this.offsetAt(r)||this.lineAt(e)-this.lineAt(r)}wellFormed(e){let r=this.stampAt(e),t=this.offsetAt(e);return $t.test(this.keyAt(e))&&Number.isFinite(r)&&Number.isSafeInteger(t)&&t>=0&&this.lengthAt(e)>0&&(this.layout.format===1||this.memberBytesAt(e)>=he)}written(){return this.bytes.subarray(0,this.size*this.rowBytes)}},X=class{constructor(e,r){this.rows=e;let t=1024;for(;t<r*2;)t*=2;this.slots=new Uint32Array(t)}rows;slots;used=0;find(e){let r=this.slots.length-1;for(let t=ne(e)&r;;t=t+1&r){let n=this.slots[t];if(n===0)return-1;if(this.rows.holds(n-1,e))return n-1}}add(e){let r=this.rows.keyAt(e),t=this.find(r);return t>=0?t:((this.used+1)*2>this.slots.length&&this.grow(),this.place(e,r),this.used++,-1)}place(e,r){let t=this.slots.length-1,n=ne(r)&t;for(;this.slots[n]!==0;)n=n+1&t;this.slots[n]=e+1}grow(){let e=this.slots;this.slots=new Uint32Array(e.length*2);for(let r of e)r!==0&&this.place(r-1,this.rows.keyAt(r-1))}};async function V(o,e){try{return await W(o,"r")}catch(r){throw r.code!=="ENOENT"?r:new v("damaged",`The checkpoint\u2019s snapshot of ${e} is not on this machine.`)}}async function*Je(o,e){let r=await V(o,e);try{let t=Buffer.alloc(ze),n=Buffer.alloc(0),s=0,a=0,i=0;for(;;){let{bytesRead:c}=await r.read(t,0,ze,a);if(c===0)break;a+=c;let d=n.length>0?Buffer.concat([n,t.subarray(0,c)]):t.subarray(0,c),p=0;for(let f=d.indexOf(10);f>=0;f=d.indexOf(10,p))i++,f>p&&(yield{number:i,offset:s+p,length:f-p,text:d.toString("utf8",p,f)}),p=f+1;n=Buffer.from(d.subarray(p)),s+=p}n.length>0&&(yield{number:i+1,offset:s,length:n.length,text:n.toString("utf8")})}finally{await r.close()}}async function*Tt(o,e,r){let t=await V(o,e);try{let n=0;for await(let s of $e(t,(await t.stat()).size,r))for(let a of Te(s.lines))n++,a.length!==0&&(yield{number:n,offset:s.at,memberBytes:s.total,line:a.at,length:a.length,text:s.lines.toString("utf8",a.at,a.at+a.length)})}finally{await t.close()}}async function Ft(o){try{return await Mt(o),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Ke(o){let e=J(o);return e===null?Number.NaN:Date.parse(e)}function K(o){let e;try{e=JSON.parse(o)}catch{return}return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}async function zt(o,e){let r=`${o}.${process.pid}-${jt(4).toString("hex")}.tmp`,t=await W(r,"wx",z);try{try{await t.writeFile(e),await t.sync()}finally{await t.close()}await It(r,o)}catch(n){throw await vt(r,{force:!0}),n}}async function Dr(o,e,r){let t=Qe(o,e,r),n=$(t),s=await Ft(n)?2:1,a=oe(o,r),i=new Z(Ye[s]),c=new X(i,0),d=(m,A)=>new v("damaged",`The snapshot of ${r} holds ${A} at line ${m} of its file: it cannot be indexed.`),p=s===2?Tt(n,r,m=>new v("damaged",`The snapshot of ${r} ${m}: it cannot be indexed.`)):Je(t,r);for await(let m of p){let A=K(m.text);if(!A)throw d(m.number,"no record");let h=A.Id;if(typeof h!="string"||!F.test(h))throw d(m.number,"a record without its Id");let l=Ke(A.SystemModstamp);if(!Number.isFinite(l))throw d(m.number,`record ${h} without its SystemModstamp`);let b=i.push(h.slice(0,C),l,m);if(c.add(b)>=0)throw d(m.number,`record ${h} a second time`)}let f=Buffer.concat([i.layout.head,i.written()]);return await zt(a,f),{rows:i.size,bytes:f.length}}var _t=D({objectApiName:N().regex(ye).max(80),from:N().regex(F),to:N().regex(F)});async function Ze(o){let e;try{e=await W(o,"r"),await e.sync()}catch{}finally{await e?.close().catch(()=>{})}}var me=class o{constructor(e,r){this.current=e;this.original=r}current;original;static none=new o(new Map,new Map);static of(e){let r=new Map;for(let{from:n,to:s}of e)r.set(n.slice(0,C),s);let t=new Map;for(let[n,s]of r)t.set(s.slice(0,C),n);return new o(r,t)}static async read(e){let r;try{r=await we(se(e),"utf8")}catch(s){if(s.code==="ENOENT")return o.none;throw s}let t=r.split(`
|
|
9
9
|
`).slice(0,-1),n=[];for(let[s,a]of t.entries()){if(a==="")continue;let i;try{i=JSON.parse(a)}catch{i=void 0}let c=_t.safeParse(i);if(!c.success)throw new v("damaged",`The checkpoint\u2019s list of the records a rewind made again is damaged at line ${s+1}.`);n.push(c.data)}return o.of(n)}static async add(e,r){if(r.length===0)return;let t=se(e),n=r.map(({objectApiName:i,from:c,to:d})=>`${JSON.stringify({objectApiName:i,from:c,to:d})}
|
|
10
10
|
`).join(""),s=await W(t,"a",z),a=!1;try{a=(await s.stat()).size===0,await s.appendFile(n,"utf8"),await s.sync()}finally{await s.close()}a&&await Ze(Ge(t))}get empty(){return this.current.size===0}currentOf(e){return this.current.get(e)}originalOf(e){return this.original.get(e)}retired(e){return typeof e=="string"&&F.test(e)&&this.current.has(e.slice(0,C))}remapped(e){return typeof e!="string"||!F.test(e)?e:this.current.get(e.slice(0,C))??e}rowAsNow(e){if(this.empty)return e;let r={...e};for(let[t,n]of Object.entries(e)){if(t==="attributes")continue;let s=this.remapped(n);s!==n&&(r[t]=s)}return r}},qt=D({objectApiName:N().regex(ye).max(80),id:N().regex(F)}),qe=class o{constructor(e){this.held=e}held;static none=new o(new Set);static async read(e){let r;try{r=await we(ie(e),"utf8")}catch(n){if(n.code==="ENOENT")return o.none;throw n}let t=new Set;for(let n of r.split(`
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{f as m,h as u}from"./chunk-TZE3Y7IQ.mjs";import{b as $}from"./chunk-CA5NAXSU.mjs";import{e as l}from"./chunk-
|
|
7
|
+
import{f as m,h as u}from"./chunk-TZE3Y7IQ.mjs";import{b as $}from"./chunk-CA5NAXSU.mjs";import{e as l}from"./chunk-J347SPU6.mjs";async function q(n,a,o,t){if(!Number.isInteger(t)||t<1||t>l.maxExistingParents)throw new Error(`A relation reads between 1 and ${l.maxExistingParents} existing records, not ${t}.`);let c=o?.trim()?` WHERE ${m(o.trim())}`:"",i=`SELECT Id FROM ${u(a)}${c} LIMIT ${t}`,r=[],e=await n.query(i);for(;;){for(let s of e.records)typeof s.Id=="string"&&r.push(s.Id);if(e.done||!e.nextRecordsUrl||r.length>=t)break;e=await n.queryMore(e.nextRecordsUrl)}return r.slice(0,t)}var w=200,E=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function R(n){return n.slice(0,15)}async function N(n,a,o){let t=u(a);for(let i of o)if(!E.test(i))throw new Error(`Not a record id: "${i}".`);let c=[];for(let i=0;i<o.length;i+=w){let r=o.slice(i,i+w).map(s=>`'${s}'`).join(", "),e=await n.query(`SELECT Id FROM ${t} WHERE Id IN (${r})`);for(;;){for(let s of e.records)typeof s.Id=="string"&&c.push(s.Id);if(e.done||!e.nextRecordsUrl)break;e=await n.queryMore(e.nextRecordsUrl)}}return c}function y(n){let a=n.slice(0,5).join(", ");return n.length>5?`${a}, and ${n.length-5} more`:a}async function b(n,a){let o=[];for(let t of n??[]){if(t.parents.kind!=="records")continue;let{childObject:c,lookupField:i,parentObject:r}=t,e=t.parents.ids,s=`${c}.${i}`,d;try{d=await a.keyPrefixOf?.(r)}catch{d=void 0}let f=d?e.filter(g=>g.slice(0,3)!==d):[];if(f.length>0){o.push(`The relation on ${s} names ${f.length} id(s) that are not ${r} ids \u2014 the org's ${r} ids start with ${d}: ${y(f)}. Nothing was written. Give the ids of ${r} records.`);continue}if(!a.presentIds){o.push(`This run cannot check that the ${e.length} ${r} record(s) the relation on ${s} names are in the org. Nothing was written.`);continue}let p;try{p=await a.presentIds(r,e)}catch(g){o.push(`Reading the ${r} records the relation on ${s} names failed (${$(g)}). Nothing was written.`);continue}let I=new Set(p.map(R)),h=e.filter(g=>!I.has(R(g)));h.length>0&&o.push(`${h.length} of the ${e.length} ${r} record(s) the relation on ${s} names are no longer in the org: ${y(h)}. Nothing was written. Run again what created them, or give the ids of ${r} records the org holds.`)}return o}export{q as a,w as b,N as c,b as d};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{m as d}from"./chunk-
|
|
7
|
+
import{m as d}from"./chunk-LHNAR6FC.mjs";var r=".my.salesforce.com",o=/^[a-z0-9-]+--[a-z0-9]+$/,s="scratch";function c(n){if(n===void 0||n==="")return;let e;try{e=new URL(n).hostname.toLowerCase()}catch{return}return e.endsWith(r)&&e.length>r.length?e:void 0}function t(n){if(n===void 0||!n.endsWith(r))return;let e=n.slice(0,-r.length).split(".");return e.every(i=>i!=="")?e:void 0}function a(n){return t(n)?.slice(1).includes(s)===!0}function f(n){let e=t(n);if(e===void 0||e.length>2||a(n))return;let[i]=e;return i!==void 0&&o.test(i)?i:void 0}function g(n,e){return t(n)?.[0]===e}function l(n,e){return n.kind!=="sandbox"||e.kind!=="sandbox"||n.host===void 0||f(e.host)===void 0||n.organizationId.slice(0,15)===e.organizationId.slice(0,15)?!1:d({tier:"sandbox",organizationId:n.organizationId,username:n.username??"",instanceUrl:`https://${n.host}`},{name:e.organizationId,organizationId:e.organizationId,instanceUrl:`https://${e.host??""}`})==="myDomain"}export{c as a,a as b,f as c,g as d,l as e};
|
|
@@ -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{c as u}from"./chunk-
|
|
7
|
+
import{c as u}from"./chunk-QACFTHJM.mjs";import{Na as d,jc as f}from"./chunk-J347SPU6.mjs";import{mkdir as h,readdir as g,readFile as m,rename as w,writeFile as S}from"node:fs/promises";import*as c from"node:path";var k=".sandforge-scenario.json",P={depth:3,files:50},y=new Set(["node_modules","dist","out","coverage"]),E=10;function O(){return{list:async r=>{try{return(await g(r,{withFileTypes:!0})).map(e=>({name:e.name,folder:e.isDirectory()}))}catch(t){let e=t.code;if(e==="ENOENT"||e==="ENOTDIR"||e==="EACCES")return[];throw t}},readFile:r=>m(r,"utf8"),writeNew:async(r,t)=>{await h(c.dirname(r),{recursive:!0});try{return await S(r,t,{encoding:"utf8",flag:"wx"}),!0}catch(e){if(e.code==="EEXIST")return!1;throw e}},replace:async(r,t)=>{let e=`${r}.${process.pid}.tmp`;await S(e,t,"utf8"),await w(e,r)}}}function x(r){let t;try{t=JSON.parse(r)}catch{return{issues:["The file is not JSON"]}}let e=d.safeParse(t);return e.success?{pack:e.data}:{issues:e.error.issues.slice(0,E).map(n=>`${n.path.join(".")||"the file"}: ${n.message}`)}}async function F(r,t){let e=[],n=async(a,o,i)=>{let p=[...await r.list(o)].sort((s,l)=>s.name.localeCompare(l.name));for(let s of p){if(e.length>=P.files)return;let l=c.join(o,s.name);s.folder?i<P.depth&&!v(s.name)&&await n(a,l,i+1):s.name.endsWith(k)&&e.push({path:l,relativePath:c.relative(a,l).split(c.sep).join("/")})}};for(let a of t)await n(a,a,0);return e}function v(r){return r.startsWith(".")||y.has(r)}async function N(r,t){let e=f.map(n=>({source:"built-in",pack:n}));for(let n of await F(r,t)){let a;try{a=await r.readFile(n.path)}catch{e.push({source:"workspace",...n,issues:["The file could not be read"]});continue}let o=x(a);e.push({source:"workspace",...n,...o})}return e}function A(r){return`${JSON.stringify(r,null,2)}
|
|
8
8
|
`}async function T(r,t,e,n=!1){let a=t[0];if(a===void 0)return{kind:"no-workspace"};let o=d.parse(e),i=`${o.id}${k}`,p=c.join(a,i),s=A(o);if(n)await r.replace(p,s);else if(!await r.writeNew(p,s))return{kind:"exists",path:p,relativePath:i};return{kind:"saved",path:p,relativePath:i}}async function b(r,t,e,n){let a=i=>i.id===e&&u(i)===n,o=f.find(a);if(o)return o;for(let i of await N(r,t))if(i.source==="workspace"&&"pack"in i&&a(i.pack))return i.pack}export{k as a,P as b,O as c,x as d,F as e,N as f,A as g,T as h,b as i};
|