sandforge 1.85.0 → 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-THYQOG24.mjs → chunk-22L43JMK.mjs} +1 -1
- package/lib/{chunk-U4S27YRP.mjs → chunk-2LSGWTWX.mjs} +1 -1
- package/lib/{chunk-MRN72UEO.mjs → chunk-2YJJTQNC.mjs} +1 -1
- package/lib/chunk-34SMB5PA.mjs +10 -0
- package/lib/chunk-35B73566.mjs +7 -0
- package/lib/{chunk-YZKE6D3K.mjs → chunk-35IJ4WEU.mjs} +1 -1
- package/lib/chunk-3EHPAFKV.mjs +7 -0
- package/lib/{chunk-3OKDWZ32.mjs → chunk-3HAVVEXF.mjs} +1 -1
- package/lib/{chunk-32ZB5ICW.mjs → chunk-3I6FXFCN.mjs} +1 -1
- package/lib/{chunk-JFVY66BS.mjs → chunk-3KJCSYXY.mjs} +1 -1
- package/lib/{chunk-ULEYGOZU.mjs → chunk-3L6DVNCR.mjs} +1 -1
- package/lib/chunk-3LRFPGYZ.mjs +7 -0
- package/lib/{chunk-GHUA6OQQ.mjs → chunk-3MVWGL5A.mjs} +1 -1
- package/lib/{chunk-SF52ZSIV.mjs → chunk-4CSBZZAL.mjs} +1 -1
- package/lib/{chunk-FBYFCKPG.mjs → chunk-4NSXPONF.mjs} +1 -1
- package/lib/{chunk-A3QNSALB.mjs → chunk-4VLP6RHC.mjs} +1 -1
- package/lib/{chunk-TWYNQ2OO.mjs → chunk-4XROG5CT.mjs} +1 -1
- package/lib/chunk-54V4FVEY.mjs +7 -0
- package/lib/chunk-55OJJT2Q.mjs +7 -0
- package/lib/{chunk-JRI6A24G.mjs → chunk-5EHHQ5UX.mjs} +1 -1
- package/lib/{chunk-VPGX5Z5D.mjs → chunk-5JMQXHJ2.mjs} +1 -1
- package/lib/{chunk-CI2O7WBH.mjs → chunk-65AMXOQU.mjs} +1 -1
- package/lib/{chunk-5T3LFDJ5.mjs → chunk-6HHSAPIM.mjs} +1 -1
- package/lib/chunk-6KVBCFVS.mjs +7 -0
- package/lib/chunk-6NG7C2U3.mjs +476 -0
- package/lib/{chunk-F2424IKX.mjs → chunk-6ROL3KBM.mjs} +1 -1
- package/lib/{chunk-7ZYCRIHE.mjs → chunk-72AWCN7U.mjs} +1 -1
- package/lib/{chunk-MQLTEXB7.mjs → chunk-7KHA5UIQ.mjs} +1 -1
- package/lib/chunk-7O6EFNQS.mjs +10 -0
- package/lib/{chunk-73SLYGWD.mjs → chunk-A2CH2QGX.mjs} +1 -1
- package/lib/chunk-A2TXLAC3.mjs +276 -0
- package/lib/chunk-ALWVNR34.mjs +7 -0
- package/lib/{chunk-JBOGAUGH.mjs → chunk-ATBQIE2V.mjs} +1 -1
- package/lib/{chunk-C2MHMI7U.mjs → chunk-ATQML7ZK.mjs} +1 -1
- package/lib/chunk-AVY742BJ.mjs +7 -0
- package/lib/{chunk-VLAU5QQT.mjs → chunk-AXTB2HJS.mjs} +1 -1
- package/lib/chunk-BBZUGKBZ.mjs +10 -0
- package/lib/chunk-BIDXK7KA.mjs +7 -0
- package/lib/{chunk-KYLHS74X.mjs → chunk-BLMJ4WVI.mjs} +1 -1
- package/lib/{chunk-A7YP27GQ.mjs → chunk-BNHJCJJM.mjs} +1 -1
- package/lib/{chunk-ZDMSTL2L.mjs → chunk-BNPQEQXC.mjs} +1 -1
- package/lib/chunk-C5AUNG6T.mjs +37 -0
- package/lib/{chunk-LY6EPMIP.mjs → chunk-C5EQ7GFC.mjs} +1 -1
- package/lib/{chunk-LOO42EW5.mjs → chunk-C7CKDZMC.mjs} +62 -62
- package/lib/{chunk-ZP3WJGS3.mjs → chunk-CB4U22NR.mjs} +1 -1
- package/lib/chunk-CJAWKLAL.mjs +7 -0
- package/lib/chunk-CL75DEMQ.mjs +9 -0
- package/lib/{chunk-7L6FE5PP.mjs → chunk-CLUNF4FK.mjs} +1 -1
- package/lib/chunk-CSMGP53U.mjs +7 -0
- package/lib/{chunk-S6BMJSLD.mjs → chunk-CT324C7I.mjs} +1 -1
- package/lib/{chunk-YXOPKGDX.mjs → chunk-CZXDJXQP.mjs} +1 -1
- package/lib/{chunk-PGG4ULEW.mjs → chunk-D2X6U3MS.mjs} +1 -1
- package/lib/{chunk-FG4Y4ZVL.mjs → chunk-DAUX63UB.mjs} +1 -1
- package/lib/chunk-DB7JNALQ.mjs +10 -0
- package/lib/chunk-DDNCJVZ2.mjs +17 -0
- package/lib/{chunk-YGE4AUXG.mjs → chunk-DLSU66MY.mjs} +1 -1
- package/lib/{chunk-DCJBP3LE.mjs → chunk-DO6PSHQZ.mjs} +1 -1
- package/lib/{chunk-ROTDZKOE.mjs → chunk-DUBECLZV.mjs} +1 -1
- package/lib/{chunk-SES5HPBZ.mjs → chunk-DYHF6DNT.mjs} +1 -1
- package/lib/chunk-E5FSPXYH.mjs +930 -0
- package/lib/{chunk-QAXKUEJT.mjs → chunk-EGL3I3IX.mjs} +1 -1
- package/lib/chunk-EIYMQPMG.mjs +7 -0
- package/lib/{chunk-AX3YF7SC.mjs → chunk-EUIALBMX.mjs} +1 -1
- package/lib/{chunk-57QRXYAZ.mjs → chunk-FI3R5ZOQ.mjs} +1 -1
- package/lib/{chunk-FCZDWGQI.mjs → chunk-FM4QCTO7.mjs} +1 -1
- package/lib/{chunk-74HZ274R.mjs → chunk-FRSIEASH.mjs} +1 -1
- package/lib/{chunk-G6IYOZEH.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-NZJXEULY.mjs → chunk-GFB2DNCB.mjs} +1 -1
- package/lib/chunk-GFGMGFSH.mjs +7 -0
- package/lib/{chunk-EFHDE7W4.mjs → chunk-GIFQXB2Q.mjs} +1 -1
- package/lib/{chunk-P6A22FMQ.mjs → chunk-GP5J3DGS.mjs} +1 -1
- package/lib/chunk-GQZEX7LH.mjs +231 -0
- package/lib/{chunk-BRN42U26.mjs → chunk-GYDTM62J.mjs} +1 -1
- package/lib/{chunk-GNCEHAJY.mjs → chunk-GYFIXUJG.mjs} +1 -1
- package/lib/chunk-GZW2GNFK.mjs +7 -0
- package/lib/chunk-H6BHWAX7.mjs +8 -0
- package/lib/{chunk-GUYEXPJ4.mjs → chunk-HDDJ3CVN.mjs} +1 -1
- package/lib/{chunk-3GATEVHC.mjs → chunk-HDWB4ZOG.mjs} +1 -1
- package/lib/chunk-HGVPBJR6.mjs +7 -0
- package/lib/{chunk-55VBV2WK.mjs → chunk-HLROVOR6.mjs} +1 -1
- package/lib/{chunk-HV3TDLFR.mjs → chunk-HUOR4M2L.mjs} +1 -1
- package/lib/chunk-HZCS6EED.mjs +8 -0
- package/lib/{chunk-WZX6VCIT.mjs → chunk-HZUI56KZ.mjs} +1 -1
- package/lib/chunk-IAB5H7WN.mjs +7 -0
- package/lib/{chunk-RY7WUJXH.mjs → chunk-IQ5UKRHU.mjs} +1 -1
- package/lib/{chunk-OUWR5M5G.mjs → chunk-IRQ4WANV.mjs} +1 -1
- package/lib/{chunk-F44EHXLI.mjs → chunk-IT3DGX37.mjs} +1 -1
- package/lib/chunk-J347SPU6.mjs +49 -0
- package/lib/{chunk-IZ2M2RGO.mjs → chunk-JANBNTR5.mjs} +1 -1
- package/lib/chunk-JFXQZPRY.mjs +9 -0
- package/lib/{chunk-VKA5OZBJ.mjs → chunk-JRLYWVF4.mjs} +1 -1
- package/lib/{chunk-FM5ESRH6.mjs → chunk-JSNMUTY6.mjs} +1 -1
- package/lib/chunk-JTNJKSAA.mjs +7 -0
- package/lib/{chunk-4D6OHSX3.mjs → chunk-JV2LAKWQ.mjs} +1 -1
- package/lib/{chunk-BY42YL4D.mjs → chunk-JV7K2ZHK.mjs} +1 -1
- package/lib/{chunk-A6IJUOLB.mjs → chunk-K4TQ7YHX.mjs} +1 -1
- package/lib/chunk-K5PUMHZU.mjs +7 -0
- package/lib/chunk-KH4KLCYG.mjs +7 -0
- package/lib/{chunk-FZF6FB65.mjs → chunk-KQVLZVOP.mjs} +1 -1
- package/lib/chunk-KWUS7UAV.mjs +19 -0
- package/lib/{chunk-2UUSF32M.mjs → chunk-L6G73FXM.mjs} +1 -1
- package/lib/{chunk-LUNGNCM3.mjs → chunk-LG466Q5H.mjs} +1 -1
- package/lib/{chunk-YTBM3TSW.mjs → chunk-LHNAR6FC.mjs} +1 -1
- package/lib/chunk-LT4GHEI2.mjs +7 -0
- package/lib/{chunk-P3OYE2FS.mjs → chunk-MR262Y3B.mjs} +1 -1
- package/lib/{chunk-TSTCHIBU.mjs → chunk-NCCHOV2N.mjs} +1 -1
- package/lib/chunk-NICRSGLS.mjs +7 -0
- package/lib/chunk-NV5QA2HY.mjs +7 -0
- package/lib/{chunk-6HAKOS6W.mjs → chunk-O3GIN5TU.mjs} +1 -1
- package/lib/chunk-O6FHK6NQ.mjs +13 -0
- package/lib/{chunk-OXIIKAUZ.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-K2WOT75I.mjs → chunk-OO2WY3UB.mjs} +1 -1
- package/lib/{chunk-3EOIAC2M.mjs → chunk-OT2NHL2V.mjs} +1 -1
- package/lib/{chunk-BK5SRDAD.mjs → chunk-P2M5ZXWU.mjs} +1 -1
- package/lib/{chunk-DCZYWMSA.mjs → chunk-P4YOHLZ4.mjs} +1 -1
- package/lib/chunk-PBHDPTT6.mjs +343 -0
- package/lib/chunk-PE7CHD2W.mjs +7 -0
- package/lib/{chunk-LU7M5URW.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-LNAZHI3J.mjs → chunk-QGVL5EW3.mjs} +1 -1
- package/lib/chunk-QHE2RUWX.mjs +7 -0
- package/lib/{chunk-4RNP65FV.mjs → chunk-RCW5BZNW.mjs} +1 -1
- package/lib/{chunk-OTKXTBTX.mjs → chunk-RJ6HHG7J.mjs} +1 -1
- package/lib/{chunk-IVDBVWKK.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-2UUS4IGB.mjs → chunk-RZOINFNL.mjs} +1 -1
- package/lib/chunk-SOOTWGMQ.mjs +7 -0
- package/lib/chunk-STQ2JMIZ.mjs +7 -0
- package/lib/{chunk-RC25QQVF.mjs → chunk-SUIPDW5O.mjs} +1 -1
- package/lib/{chunk-Z354SAEF.mjs → chunk-SZOJ7BEJ.mjs} +1 -1
- package/lib/{chunk-45375WT5.mjs → chunk-T542Z54E.mjs} +1 -1
- package/lib/chunk-TAN2CIRI.mjs +21 -0
- package/lib/{chunk-BGJBYDRW.mjs → chunk-TCNBINOG.mjs} +1 -1
- package/lib/chunk-TFDF3DBN.mjs +7 -0
- package/lib/{chunk-B5A4JHNN.mjs → chunk-TICZXC53.mjs} +1 -1
- package/lib/chunk-TLX45X5U.mjs +7 -0
- package/lib/{chunk-W6SLQZKQ.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-4N425UJC.mjs → chunk-UCUFLFNK.mjs} +1 -1
- package/lib/chunk-UK3QLBHW.mjs +7 -0
- package/lib/{chunk-SKGAERV4.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-LSEM2BZH.mjs → chunk-VFKG2G37.mjs} +1 -1
- package/lib/chunk-VJNEW5MQ.mjs +7 -0
- package/lib/{chunk-EYFP3NA6.mjs → chunk-VKREON6Q.mjs} +1 -1
- package/lib/{chunk-TIVI2KGB.mjs → chunk-VNNDYPBL.mjs} +1 -1
- package/lib/{chunk-J3FJ3BWE.mjs → chunk-VRBETPHY.mjs} +1 -1
- package/lib/{chunk-UX4AOSMU.mjs → chunk-VT6P3X6R.mjs} +1 -1
- package/lib/{chunk-CUOWQMGW.mjs → chunk-VUTQY76O.mjs} +1 -1
- package/lib/chunk-WF5S4FW5.mjs +7 -0
- package/lib/{chunk-JHJDDQDE.mjs → chunk-WJGK6VGU.mjs} +1 -1
- package/lib/{chunk-IZREPWYQ.mjs → chunk-WJHMB3SL.mjs} +1 -1
- package/lib/{chunk-XZRON54U.mjs → chunk-WQCXOZEJ.mjs} +1 -1
- package/lib/{chunk-N2MXYD67.mjs → chunk-WVVFR4E3.mjs} +1 -1
- package/lib/{chunk-GG5I52UT.mjs → chunk-XBYXT74L.mjs} +1 -1
- package/lib/chunk-XJE3LJHP.mjs +7 -0
- package/lib/{chunk-3QCUSZIZ.mjs → chunk-XV4CVZYD.mjs} +1 -1
- package/lib/chunk-Y37ED7AS.mjs +7 -0
- package/lib/{chunk-MN3XBJPE.mjs → chunk-YGBNZYT4.mjs} +1 -1
- package/lib/{chunk-SBDF4AE5.mjs → chunk-YGTOX7IL.mjs} +1 -1
- package/lib/{chunk-SQM32AOQ.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-SU24AE3H.mjs → chunk-YZKZC62O.mjs} +1 -1
- package/lib/{chunk-LJNRN7MY.mjs → chunk-YZQN7BRB.mjs} +1 -1
- package/lib/{chunk-NMF55UBQ.mjs → chunk-Z5IUK2QO.mjs} +1 -1
- package/lib/{chunk-6ZWY36LK.mjs → chunk-ZEGSMW5A.mjs} +1 -1
- package/lib/{chunk-YV7JYHJP.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 +29 -16
- 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-26EGXYZ4.mjs +0 -21
- package/lib/chunk-2JRVBXJL.mjs +0 -7
- package/lib/chunk-2METQHGG.mjs +0 -7
- package/lib/chunk-3XU7CEJQ.mjs +0 -7
- package/lib/chunk-4BQPAVMP.mjs +0 -14
- package/lib/chunk-4KMKOE77.mjs +0 -156
- package/lib/chunk-4RPA7Z52.mjs +0 -7
- package/lib/chunk-5C7LQXYS.mjs +0 -7
- package/lib/chunk-5EESNYE3.mjs +0 -8
- package/lib/chunk-6ZW6BLV5.mjs +0 -7
- package/lib/chunk-AAOMUI7S.mjs +0 -15
- package/lib/chunk-AIUAEBHR.mjs +0 -7
- package/lib/chunk-BD724WOH.mjs +0 -7
- package/lib/chunk-CRPLDXJU.mjs +0 -48
- package/lib/chunk-CSSOLHE3.mjs +0 -7
- package/lib/chunk-D63HEQ3B.mjs +0 -7
- package/lib/chunk-DN7YBILC.mjs +0 -21
- package/lib/chunk-DNE7JI3A.mjs +0 -11
- package/lib/chunk-EFHM2U4D.mjs +0 -7
- package/lib/chunk-EINEGS6E.mjs +0 -7
- package/lib/chunk-EM5EFMHA.mjs +0 -272
- package/lib/chunk-FH5UR35W.mjs +0 -7
- package/lib/chunk-FN7TOBJR.mjs +0 -7
- package/lib/chunk-HGJFATSI.mjs +0 -10
- package/lib/chunk-HOEE3PE5.mjs +0 -7
- package/lib/chunk-HV63UGL5.mjs +0 -7
- package/lib/chunk-JKFCGYJE.mjs +0 -7
- package/lib/chunk-KATBU46O.mjs +0 -7
- package/lib/chunk-LD34JNCC.mjs +0 -7
- package/lib/chunk-LPN4WYTP.mjs +0 -478
- package/lib/chunk-MAOUFJ47.mjs +0 -7
- package/lib/chunk-MB2DG66I.mjs +0 -13
- package/lib/chunk-NCASRA7L.mjs +0 -9
- package/lib/chunk-NEKNAILD.mjs +0 -7
- package/lib/chunk-NN2IO4WE.mjs +0 -7
- package/lib/chunk-O3ZQSWDN.mjs +0 -10
- package/lib/chunk-OFQOKSEW.mjs +0 -7
- package/lib/chunk-PP7PJXRJ.mjs +0 -341
- package/lib/chunk-PT2E2HFD.mjs +0 -7
- package/lib/chunk-PZBZ7MNC.mjs +0 -7
- package/lib/chunk-QBYK5XIT.mjs +0 -8
- package/lib/chunk-RFD6NPWJ.mjs +0 -8
- package/lib/chunk-RIIJJRGF.mjs +0 -7
- package/lib/chunk-RKTFFCNS.mjs +0 -7
- package/lib/chunk-RM5G4IP6.mjs +0 -19
- package/lib/chunk-RTPNK7OB.mjs +0 -7
- package/lib/chunk-RZXEO5IE.mjs +0 -7
- package/lib/chunk-SAHGDSZQ.mjs +0 -37
- package/lib/chunk-SRPWW4A2.mjs +0 -10
- package/lib/chunk-SVNSAHG3.mjs +0 -7
- package/lib/chunk-T63U4OZJ.mjs +0 -7
- package/lib/chunk-TE2W76II.mjs +0 -10
- package/lib/chunk-TEIBWMJM.mjs +0 -7
- package/lib/chunk-TFGJDZFE.mjs +0 -7
- package/lib/chunk-TG52WNGV.mjs +0 -10
- package/lib/chunk-TQONVFI3.mjs +0 -7
- package/lib/chunk-TW3N6W5Z.mjs +0 -7
- package/lib/chunk-UZMLPKW6.mjs +0 -7
- package/lib/chunk-WB2RIVO3.mjs +0 -7
- package/lib/chunk-WQO7RXEB.mjs +0 -926
- package/lib/chunk-X3MBY2RX.mjs +0 -7
- package/lib/chunk-XMJRXXUN.mjs +0 -7
- package/lib/chunk-YNMU5I7P.mjs +0 -7
- package/lib/chunk-YSQJKIO6.mjs +0 -7
- package/lib/chunk-YVVPJRZC.mjs +0 -7
- package/lib/chunk-ZLQHBI6V.mjs +0 -9
- 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{c as yt,d as qs,e as Ks,f as wt}from"./chunk-FV6MOSHD.mjs";import{b as St,c as bt,d as sn,e as on,f as ro,g as an}from"./chunk-T542Z54E.mjs";import{b as so,d as oo}from"./chunk-DO6PSHQZ.mjs";import{a as io,c as ao}from"./chunk-ZIKLQZBG.mjs";import{a as Ke,b as Hs,c as Ys,d as Js,f as Vs,g as Xs,h as Zs,i as Qs,j as eo,l as Q,n as nn,o as rn,p as to,q as no,s as He}from"./chunk-FYG47CNA.mjs";import{Rc as Gr}from"./chunk-CJAWKLAL.mjs";import{a as ve,c as Qt}from"./chunk-BOGNK4LV.mjs";import{G as Es,H as Ts,La as vs,M as Fs,Ma as Ns,N as Ms,P as js,Ra as Ds,Sa as xs,Ta as Ls,Ua as $s,Va as Bs,Xa as _s,Ya as Ws,_a as Gs,cb as Us,db as zs,h as Os,j as tn}from"./chunk-C5AUNG6T.mjs";import{k as Is}from"./chunk-3I6FXFCN.mjs";import{n as Ur,t as Vr}from"./chunk-7O6EFNQS.mjs";import{F as Br,G as ut,M as _r,P as Wr,l as Xt,q as $r}from"./chunk-3LRFPGYZ.mjs";import{d as Cs,e as Ps}from"./chunk-GB6W4Q56.mjs";import{g as As}from"./chunk-AVY742BJ.mjs";import{a as Zt}from"./chunk-QSRAEUGZ.mjs";import{l as Mr}from"./chunk-YDXMTWAT.mjs";import{f as Xr,h as Zr,i as ze,k as Qr,m as es,n as ts,o as ns,p as rs,r as ss}from"./chunk-35B73566.mjs";import{h as Yr,j as Jr}from"./chunk-DLSU66MY.mjs";import{b as Kt,c as We,d as ee}from"./chunk-GP5J3DGS.mjs";import{f as zr,g as qr}from"./chunk-ZVU7MD2S.mjs";import{Ac as bs,Bc as Rs,Cc as De,Nb as Ne,Ob as qe,Pb as ht,Qc as ks,bb as en,cb as is,db as as,k as Kr,kc as gs,mb as ds,nb as cs,nc as ms,oc as hs,pb as we,q as Hr,qc as ys,rb as pt,sb as ls,tb as ft,ub as us,uc as ws,vb as ps,vc as Ss,wb as gt,xb as mt,zb as fs}from"./chunk-OLCS7JCT.mjs";import{q as os}from"./chunk-6HHSAPIM.mjs";import{b as nr,f as rr}from"./chunk-INIT2UKJ.mjs";import{a as Pr,d as Ir,e as Er,f as Tr,g as Fr}from"./chunk-ATBQIE2V.mjs";import{a as jr,b as Ue,d as vr,e as Nr,f as Dr,g as xr,h as Lr}from"./chunk-UCUFLFNK.mjs";import{A as Pe,B as wr,C as Ht,D as lt,E as Yt,G as Jt,H as Sr,I as br,J as je,n as ar,o as Me,q as dr,r as cr,s as lr,t as ur,u as pr,v as fr,w as gr,y as yr,z as Ge}from"./chunk-4XROG5CT.mjs";import{a as sr}from"./chunk-EADHKH3A.mjs";import{F as X,G as ie,I as qt,N as er,P as tr,f as ct,g as Zn,m as Qn,r as zt}from"./chunk-SZOJ7BEJ.mjs";import{f as Xn,h as ye}from"./chunk-TZE3Y7IQ.mjs";import{b as q}from"./chunk-CA5NAXSU.mjs";import{c as Rr,d as kr,f as Or,h as Ar,j as Cr,k as Vt}from"./chunk-22L43JMK.mjs";import{a as or,w as ir}from"./chunk-ICIYL45C.mjs";import{c as mr,d as hr}from"./chunk-3KJCSYXY.mjs";import{$c as at,Ad as Hn,Bd as Yn,Cc as ot,Cd as Jn,Lc as Fe,Mc as ge,Qc as it,ac as Wn,bc as st,ed as Un,ee as Vn,g as Bn,i as Gt,j as _n,k as fe,nc as Gn,nd as dt,te as Ut,xd as zn,yd as qn,zd as Kn}from"./chunk-J347SPU6.mjs";import{b as _e,k as Bt,l as _t,u as Ln,v as $n,z as Wt}from"./chunk-WZQEK4WT.mjs";var Rt=class{classify(e){let t=st(e.statusCode,e.message),r=this.getSuggestedAction(e.statusCode,t);return{originalError:e,classification:t,suggestedAction:r}}classifyBatch(e){let t=e.map(a=>this.classify(a)),r={auth:0,permission:0,schema:0,data:0,validation:0,limit:0,network:0,trigger:0,reference:0,unknown:0},s={},o=0;for(let a of t){a.classification.retryable&&o++;let d=a.classification.category??"unknown";r[d]=(r[d]??0)+1,s[a.originalError.statusCode]=(s[a.originalError.statusCode]??0)+1}let i={totalErrors:e.length,retryableCount:o,nonRetryableCount:e.length-o,byCategory:r,byErrorCode:s,sampleErrors:e.slice(0,5)};return{classified:t,summary:i}}isRetryable(e,t){return st(e,t).retryable}hasBlockingError(e){return e.some(t=>st(t.statusCode,t.message).blockAll===!0)}get knownErrorCount(){return Object.keys(Wn).length}getSuggestedAction(e,t){return t.suggestUpsert?"Consider using upsert with external ID":t.suggestTruncate?"Truncate field values to fit within limits":t.blockAll?"Operation blocked: resolve storage/limit issue first":t.strategy==="reauth_then_retry"?"Re-authenticate and retry":t.strategy==="reduce_batch"?"Reduce batch size and retry":t.retryable?`Retry after ${t.delay??0}ms`:`Fix ${e} error and retry manually`}};function mi(n,e){return new Promise(t=>{if(e?.aborted){t();return}let r=()=>{clearTimeout(s),e?.removeEventListener("abort",r),t()},s=setTimeout(r,n);e?.addEventListener("abort",r,{once:!0})})}var kt=class{constructor(e={}){this.options=e;this.strategy=new jr({...e.retryConfig,jitter:e.retryConfig?.jitter??!0}),this.classifier=new Rt}options;strategy;classifier;async execute(e){let t=this.strategy.getConfig(),r,s=0;for(let o=0;o<=t.maxRetries;o++)try{return{success:!0,result:await e(),attempts:o+1,totalDelay:s}}catch(i){r=i instanceof Error?i:new Error(String(i));let a=hi(i),d=this.classifier.classify(a);if(!d.classification.retryable)return{success:!1,error:r,attempts:o+1,totalDelay:s};if(o<t.maxRetries){let c={success:!1,error:r,attempts:o+1,totalDelay:s,cancelled:!0};if(this.options.signal?.aborted)return c;let l=this.strategy.calculateDelay(o);if(this.options.onRetry?.(o,d,l),s+=l,await mi(l,this.options.signal),this.options.signal?.aborted)return{...c,totalDelay:s}}}return{success:!1,error:r,attempts:t.maxRetries+1,totalDelay:s}}async executeBatch(e,t){let r=[...e],s=[],o=[],i=0,a=this.options.retryConfig?.maxRetries??3;for(;r.length>0&&i<=a;){let d=await t(r);s.push(...d.successes);let c=[];for(let l of d.failures)this.classifier.classify(l.error).classification.retryable&&i<a?c.push(l.record):o.push(l);if(r=c,r.length>0){let l=this.options.retryConfig?.initialDelay??1e3,u=this.options.retryConfig?.maxDelay??3e4,f=l*Math.pow(2,i);await new Promise(p=>setTimeout(p,Math.min(f,u))),i++}}return{successes:s,failures:o}}getClassifier(){return this.classifier}getStrategy(){return this.strategy}};function hi(n){if(typeof n!="object"||n===null)return{statusCode:"UNKNOWN_ERROR",message:String(n)};let e=n,t=[e.errorCode,e.statusCode,e.name].find(s=>typeof s=="string"&&s.length>0&&s!=="Error"),r=e.fields??e.data?.fields;return{statusCode:t??"UNKNOWN_ERROR",errorCode:typeof e.errorCode=="string"?e.errorCode:void 0,message:typeof e.message=="string"?e.message:String(n),fields:Array.isArray(r)?r.filter(s=>typeof s=="string"):void 0}}var yi=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function wi(n){if(n===!0||n==="true")return!0;if(n===!1||n==="false")return!1}async function Si(n,e,t,r=()=>Date.now()){let s=await Mr(n,e,{now:r,successfulOnly:!0});return s.state==="running"?{state:"running"}:s.state!=="ended"?s:{state:"ended",created:(s.results.successfulResults??[]).flatMap(i=>{let a=i.sf__Id;return typeof a!="string"||!yi.test(a)?[]:t&&wi(i.sf__Created)!==!0?[]:[a]}),...typeof s.info.systemModstamp=="string"?{at:s.info.systemModstamp}:{}}}async function Md(n,e,t,r,s=()=>new Date){let o,i=()=>(o??=(async()=>{if(!r)return 0;try{let d=s().getTime(),c=Date.parse(await r());return Number.isFinite(c)?c-(d+s().getTime())/2:0}catch{return 0}})(),o),a=[];for(let d of e.jobs??[]){if(d.job===void 0)continue;let c={job:d.job,objectApiName:d.objectApiName},l=await Si(t,d.job,d.upsert===!0,()=>s().getTime());if(l.state==="running"||l.state==="unread"){a.push({...c,read:l,answered:!1});continue}let u=s().toISOString();l.state==="ended"&&l.at!==void 0&&Number.isFinite(Date.parse(l.at))?u=new Date(Date.parse(l.at)-await i()).toISOString():e.lastWrittenAt!==void 0&&(u=e.lastWrittenAt);let f=l.state==="ended"?l.created:[],p=await n.answerInFlight(e.runId,d.objectApiName,f,u,d.job);a.push({...c,read:l,answered:p})}return a}function jd(n,e){return e.map(({job:t,read:r})=>{let s=`${n}, job ${t}`;switch(r.state){case"ended":return`[INFO] ${s}: the job no line of the run answered ended in the org; ${r.created.length} record(s) it created kept with the run`;case"never-closed":return`[INFO] ${s}: the job was never closed, and wrote nothing`;case"running":return`[INFO] ${s}: the job is still running in the org; read again later`;default:return`[WARN] ${s}: the job could not be read back: ${r.reason}`}})}var Le=5e3,cn=200,Ot=_e().refine(n=>We(n),"not a record id"),bi=_t({sourceOrgId:_e().min(1).max(200),targetOrgId:_e().min(1).max(200),objectApiName:_e().regex(/^[A-Za-z][A-Za-z0-9_]{0,79}$/),kind:Ln(["document","attachment"]),sourceId:Ot,targetId:Ot,sourceVersionId:Ot.optional(),sourceModifiedAt:Wt.datetime().optional(),linked:Bt(Ot).max(cn),copiedAt:Wt.datetime()}),Ri=_t({version:$n(1),entries:Bt(bi).max(Le)});function lo(n){if(n==null)return{kind:"none"};let e=Ri.safeParse(n);if(e.success)return{kind:"stored",map:e.data};let t=e.error.issues[0];return{kind:"unreadable",issue:`${t.path.join(".")||"map"}: ${t.message}`}}function zd(n,e,t){return n?n.check({orgId:e,orgTier:Un(t),operation:"delete",objectName:"Attachment",recordCount:1,module:"sync"}).allowed:!1}var ue=class extends Error{constructor(e){super(e),this.name="SyncFilesRefusedError"}},Ye=class extends Error{};function ki(){return{copied:0,versions:0,bytes:0,links:0,unchanged:0,tooLarge:0,pastRunCap:0,external:0,recordNotWritten:0,failed:0}}function te(n,e){let t=n[e];return typeof t=="string"&&t!==""?t:void 0}function At(n,e){let t=n;for(let r of e.split(".")){if(typeof t!="object"||t===null)return null;t=t[r]}return Yt(t)}function xe(n,e){return e==null?n:n===void 0||Date.parse(e)>Date.parse(n)?e:n}function Oi(n,e){let t=n[e];return typeof t=="number"&&Number.isFinite(t)?t:0}function Je(n,e,t){return`${n}|${e}|${t}`}function Ai(n,e){let t=e.load(n.id);if(t===null)throw new ue("Files are copied by a saved configuration only: it keeps which file it copied where, so that running it again copies none of them twice. Save the configuration, then run it. Nothing was read or written.");if(t.kind==="unreadable")throw new ue(`The record of the files this configuration copied could not be read (${t.issue}), so a run could copy them a second time. Turn the files off, or save the configuration again under a new name. Nothing was read or written.`);let r=new Map;if(t.kind==="stored")for(let s of t.map.entries)r.set(Je(s.sourceOrgId,s.targetOrgId,s.sourceId),s);return r}var dn="ContentDocument.LatestPublishedVersion.SystemModstamp";async function Ci(n,e,t,r){let s=at(t.objectApiName),o=t.where?.trim()?` WHERE (${Xn(t.where)})`:"",i=`SELECT Id FROM ${s}${o}`,a=Ht(r),d=new Set,c,l=await n.copy.queryRecords(e.sourceOrgId,`SELECT LinkedEntityId, SystemModstamp, ${dn} FROM ContentDocumentLink WHERE LinkedEntityId IN (${i}) AND (SystemModstamp > ${a} OR ${dn} > ${a})`);for(let f of l){let p=te(f,"LinkedEntityId");p&&We(p)&&d.add(p),c=xe(xe(c,At(f,"SystemModstamp")),At(f,dn))}let u=await n.copy.queryRecords(e.sourceOrgId,`SELECT ParentId, LastModifiedDate FROM Attachment WHERE ParentId IN (${i}) AND LastModifiedDate > ${a}`);for(let f of u){let p=te(f,"ParentId");p&&We(p)&&d.add(p),c=xe(c,At(f,"LastModifiedDate"))}return{ids:[...d],...c!==void 0?{newest:c}:{}}}async function Pi(n,e,t){let r=new Map;for(let s of ee(t)){let o=await n.copy.queryRecords(e.sourceOrgId,`SELECT Id, LastModifiedDate FROM Attachment WHERE Id IN (${s})`);for(let i of o){let a=te(i,"Id"),d=Yt(i.LastModifiedDate);a&&d&&r.set(a,d)}}return r}function Ii(n,e,t){return e===void 0||n.targetId===n.sourceId?!1:n.sourceModifiedAt!==void 0?n.sourceModifiedAt!==e:t!==void 0&&Date.parse(e)>Date.parse(t)}async function Ei(n,e,t,r,s,o){let i=[...s.values()].filter(l=>l.kind==="document"&&l.objectApiName===t&&l.sourceOrgId===e.sourceOrgId&&l.targetOrgId===e.targetOrgId&&!o.has(l.sourceId)).map(l=>l.sourceId),a=Ht(r),d=[],c;for(let l of ee(i)){let u=await n.copy.queryRecords(e.sourceOrgId,`SELECT Id, ContentDocumentId, Title, PathOnClient, ContentSize, ContentLocation, SystemModstamp FROM ContentVersion WHERE ContentDocumentId IN (${l}) AND IsLatest = true AND SystemModstamp > ${a}`);for(let f of u){c=xe(c,At(f,"SystemModstamp"));let p=te(f,"ContentDocumentId"),m=te(f,"Id");if(!p||!m||(te(f,"ContentLocation")??"S")!=="S")continue;let y=te(f,"Title")??p;d.push({objectApiName:"ContentDocument",sourceId:p,body:{objectApiName:"ContentVersion",id:m},name:y,bytes:Oi(f,"ContentSize"),hosts:[],fields:{Title:y,PathOnClient:te(f,"PathOnClient")??y}})}}return{files:d,...c!==void 0?{newest:c}:{}}}async function Ti(n,e,t,r){let s=new Map,o=new Date().toISOString(),i=(l,u,f)=>({sourceOrgId:e.sourceOrgId,targetOrgId:e.targetOrgId,objectApiName:t,kind:l,sourceId:u,targetId:u,linked:[],copiedAt:o,...f}),a=r.filter(l=>l.objectApiName==="ContentDocument").map(l=>l.sourceId);for(let l of ee(a)){let u=await n.copy.queryRecords(e.targetOrgId,`SELECT Id, LatestPublishedVersionId FROM ContentDocument WHERE Id IN (${l})`);for(let f of u){let p=te(f,"Id");if(!p)continue;let m=te(f,"LatestPublishedVersionId");s.set(p,i("document",p,m?{sourceVersionId:m}:{}))}}let d=[...s.keys()];for(let l of ee(d)){let u=await n.copy.queryRecords(e.targetOrgId,`SELECT ContentDocumentId, LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId IN (${l})`);for(let f of u){let p=te(f,"ContentDocumentId"),m=te(f,"LinkedEntityId"),y=p?s.get(p):void 0;y&&m&&We(m)&&y.linked.length<cn&&y.linked.push(m)}}let c=r.filter(l=>l.objectApiName==="Attachment").map(l=>l.sourceId);for(let l of ee(c)){let u=await n.copy.queryRecords(e.targetOrgId,`SELECT Id FROM Attachment WHERE Id IN (${l})`);for(let f of u){let p=te(f,"Id");p&&s.set(p,i("attachment",p,{}))}}return s}async function uo(n){let{config:e,option:t,objects:r,deps:s}=n,o=Ai(e,s.store),i;try{i=await Fs(s.copy,e.targetOrgId)}catch(p){throw new ue(`The file storage the target has left could not be read (${q(p)}), so the files could not be measured against it. Nothing was written.`)}let a=t.maxFileSizeMB*1048576,d=t.maxRunMB*1048576,c=0,l=0,u=new Set,f={objects:new Map,storage:{remainingBytes:i,plannedBytes:0}};for(let{objectConfig:p,changedSince:m,filesSeen:y}of r){if(p.operation==="delete")continue;let h=p.objectApiName,w=await s.sourceIds(p,m),S=[],R=m===void 0?void 0:y!==void 0&&Date.parse(y)>Date.parse(m)?wr(y):m,O=m===void 0?void 0:y,g=new Map;if(R!==void 0)try{let P=new Set(w),v=await Ci(s,e,p,R);O=xe(O,v.newest);let $=v.ids.filter(H=>!P.has(H));if($.length>0){let H=n.tie?await n.tie(p,$):{held:new Map};g=H.held;let K=$.filter(G=>!g.has(G)).length;K>0&&S.push(`${K} record(s) whose files changed since the last run, and nothing else of them, could not be tied to their copy in the target`+(H.refused?` (${H.refused})`:"")+": their new files are copied when the record changes, or on a full read.")}}catch(P){throw new ue(`${h}: the files its records gained since the last run could not be looked up (${q(P)}). Run it again, or turn the files off. Nothing was written.`)}let b=[...w,...g.keys()],A=await Es({scope:new Map([[h,b]]),sourceOrgId:e.sourceOrgId,maxFileBytes:a,queryRecords:s.copy.queryRecords});if(Ts(A)){let P=new Set(A.errors.flatMap(v=>v.samples.flatMap($=>$.messages)));throw new ue(`${h}: the files of its records could not all be looked up in the source (${[...P].join("; ")}). Run it again, or turn the files off. Nothing was written.`)}let k=ki();for(let P of A.leftOut)P.reason==="too-large"?k.tooLarge++:P.reason==="external"&&k.external++;k.tooLarge>0&&S.push(`${k.tooLarge} file(s) larger than ${t.maxFileSizeMB} MB were not copied.`);let C=A.files,F=[],j=new Map;try{if(R!==void 0){let $=new Set(C.map(K=>K.sourceId)),H=await Ei(s,e,h,R,o,$);O=xe(O,H.newest);for(let K of H.files)K.bytes>a?k.tooLarge++:C=[...C,K]}let P=C.filter($=>!o.has(Je(e.sourceOrgId,e.targetOrgId,$.sourceId)));if(P.length>0)for(let[$,H]of await Ti(s,e,h,P))o.set(Je(e.sourceOrgId,e.targetOrgId,$),H),F.push(H);let v=C.filter($=>$.objectApiName==="Attachment");v.length>0&&(j=await Pi(s,e,v.map($=>$.sourceId)))}catch(P){throw new ue(`${h}: the files an earlier run copied could not be looked up (${q(P)}), so a run could copy them twice. Nothing was written.`)}let N=[],L=new Map,W=0,M=0;for(let P of C){if(u.has(P.sourceId)){k.unchanged++,N.push(P);continue}let v=o.get(Je(e.sourceOrgId,e.targetOrgId,P.sourceId)),$=v?.kind==="attachment"&&Ii(v,j.get(P.sourceId),m);if($&&!s.deleteFromTarget){M++;continue}if(v&&!$&&(v.kind==="attachment"||v.sourceVersionId===P.body.id)){k.unchanged++,v.kind==="document"&&N.push({...P,into:{documentId:v.targetId,linked:v.linked,unchanged:!0}});continue}if(!v&&l>=Le-o.size){W++,k.pastRunCap++;continue}if(c+P.bytes>d){k.pastRunCap++;continue}c+=P.bytes,k.bytes+=P.bytes,u.add(P.sourceId),v&&$?(k.replaced=(k.replaced??0)+1,L.set(P.sourceId,v.targetId),N.push(P)):v?(k.versions++,N.push({...P,into:{documentId:v.targetId,linked:v.linked}})):(l++,k.copied++,N.push(P))}k.pastRunCap>W&&S.push(`${k.pastRunCap-W} file(s) past the ${t.maxRunMB} MB a run copies were not copied: the next run copies them.`),M>0&&S.push(`${M} legacy attachment(s) the source changed since they were copied were left as copied: replacing one deletes its earlier copy, and this run may not delete in the target.`),W>0&&S.push(`${W} file(s) were not copied: this configuration keeps the record of ${Le} copied files at most, which it holds already. Removing an earlier run of it frees the entries of the files that run copied: Remove what this run created on its History entry, or --remove on the command line.`),f.objects.set(h,{scope:new Set(b),files:N,outcome:k,notes:S,shared:F,held:g,replacing:L,attachmentsChangedAt:j,...O!==void 0?{filesSeen:O}:{}})}return f.storage={remainingBytes:i,plannedBytes:c,...c>i?{shortfall:`The files to copy take ${dt(c)} and the target has ${dt(Math.max(0,i))} of file storage left. Lower the largest file or the most a run copies, or leave the files out.`}:{}},f}function Fi(n){return n.flatMap(e=>e.samples.map(t=>`${e.objectApiName}: ${t.recordSummary}: ${t.messages.join("; ")}`))}async function po(n){let{config:e,option:t,objectApiName:r,planned:s,written:o,deps:i,signal:a}=n,d={...s.outcome,copied:0,versions:0,bytes:0,...s.outcome.replaced!==void 0?{replaced:0}:{}},c=[...s.notes],l=[...o.keys()].filter(g=>!s.scope.has(g)).length;l>0&&c.push(`${l} record(s) written were not in the source when the files were looked up: their files are copied by the next run.`);try{for(let g of s.shared)i.store.record(e.id,g)}catch(g){c.push(`The files the target already held could not be recorded (${q(g)}): the next run looks them up again.`)}if(s.files.length===0)return{outcome:d,notes:c,unplanned:l,cancelled:!1};let u=i.store.load(e.id),f=new Map((u?.kind==="stored"?u.map.entries:[]).filter(g=>g.sourceOrgId===e.sourceOrgId&&g.targetOrgId===e.targetOrgId).map(g=>[g.sourceId,g])),p=s.files.map(g=>{let b=g.into?void 0:f.get(g.sourceId);return b&&b.kind==="document"?{...g,into:{documentId:b.targetId,linked:b.linked,unchanged:!0}}:g}),m=Ms({files:p.filter(g=>!g.into?.unchanged),leftOut:[],errors:[]},t.maxFileSizeMB*1048576),y=[],h,w=!1,S=[],R={ids:[],note:void 0},O=(g,b)=>{let A=Je(e.sourceOrgId,e.targetOrgId,g.sourceId),k=[...new Set([...g.into?.linked??[],...b.linked])].slice(0,cn),C=g.objectApiName==="ContentDocument",F=s.replacing.get(g.sourceId),j=s.attachmentsChangedAt.get(g.sourceId);b.asVersion?(d.versions++,d.bytes+=g.bytes):F!==void 0?(d.replaced=(d.replaced??0)+1,d.bytes+=g.bytes):g.into?.unchanged||(d.copied++,d.bytes+=g.bytes),!b.asVersion&&!g.into&&n.onCreated?.(C?"ContentDocument":"Attachment",b.targetId);try{i.store.record(e.id,{sourceOrgId:e.sourceOrgId,targetOrgId:e.targetOrgId,objectApiName:r,kind:C?"document":"attachment",sourceId:g.sourceId,targetId:b.targetId,...C?{sourceVersionId:g.body.id}:{},...!C&&j!==void 0?{sourceModifiedAt:j}:{},linked:k,copiedAt:new Date().toISOString()}),F!==void 0&&F!==b.targetId&&S.push(F)}catch(N){h=`${q(N)} (${A})`}};try{await js({files:p,sourceOrgId:e.sourceOrgId,targetOrgId:e.targetOrgId,remapper:{isCreated:g=>o.has(g)||s.held.has(g),get:g=>o.get(g)??s.held.get(g),add:()=>{}},deps:i.copy,report:m,errors:y,waitIfPaused:async()=>{if(h!==void 0)throw new Ye;if(await n.waitIfPaused?.(),a?.aborted)throw new Ye},onProgress:g=>{g.status==="running"&&i.onProgress?.(g.progress,`${r}: ${g.message}`)},onCopied:O})}catch(g){if(!(g instanceof Ye))throw g;w=h===void 0}finally{S.length>0&&(R=await Mi(i,S))}return d.links=m.links,d.failed=m.objects.reduce((g,b)=>g+b.failed,0)+R.ids.length,d.recordNotWritten=m.leftOut.filter(g=>g.reason==="record-not-created").length,c.push(...Fi(y)),R.note!==void 0&&c.push(R.note),d.recordNotWritten>0&&c.push(`${d.recordNotWritten} file(s) were not copied: no record they hang on was written.`),h!==void 0&&(d.failed++,c.push(`A copied file could not be recorded, so no more files were copied: ${h}. Check the copies of the last files in the target before running it again.`)),{outcome:d,notes:c,unplanned:l,cancelled:w}}var co=200;async function Mi(n,e){let t=[],r=new Set;for(let s=0;s<e.length;s+=co){let o=e.slice(s,s+co);try{let i=await n.deleteFromTarget?.("Attachment",o)??[];o.forEach((a,d)=>{let c=i[d];c?.success||(t.push(a),r.add(c?.errors.join("; ")||"The target gave no reason."))})}catch(i){t.push(...o),r.add(q(i))}}return t.length===0?{ids:[],note:void 0}:{ids:t,note:`${t.length} earlier copy(ies) of an attachment replaced could not be deleted from the target (${[...r].join("; ")}): the record holds the new copy and the old one, ${t.join(", ")}.`}}function qd(n){let e=t=>{let r=n[t];if(!r)throw new Error(`No connection for the org ${t}.`);return r};return{queryRecords:async(t,r)=>(await sr(e(t).pages,r)).records,readFileBody:(t,r,s)=>Ds(e(t).transport,r,s),insertFile:(t,r,s)=>xs(e(t).transport,r,s),insertRecords:async(t,r,s)=>Cr(await e(t).create(r,s),r).map(o=>({id:o.id,success:o.success,errors:o.errors})),remainingFileStorageMB:t=>Ls(e(t).transport)}}function Kd(n){let e=0,t=0,r=0;for(let s of n)e+=s.copied+s.versions+(s.replaced??0),t+=s.bytes,r+=s.tooLarge+s.pastRunCap;return`${e} file(s), ${dt(t)} copied, ${r} skipped past the caps`}var ln="sync:config:",fo="syncConfigs",Xe="sync:delta:",un="syncDelta",Ct="sync:files:",go="syncFiles",mo=class{constructor(e){this.configStore=e}configStore;save(e){this.configStore.set(`${ln}${e.id}`,e,fo)}load(e){return this.configStore.get(`${ln}${e}`)}isSaved(e){return this.load(e)!==void 0}deltaStore(){return{load:e=>this.isSaved(e)?this.loadDelta(e):null,record:(e,t)=>this.recordWatermark(e,t)}}fileStore(){return{load:e=>this.isSaved(e)?this.loadFiles(e):null,record:(e,t)=>this.recordFile(e,t)}}list(){let e=this.configStore.getByCategory(fo);return Object.values(e).sort((r,s)=>s.updatedAt.localeCompare(r.updatedAt))}delete(e){return this.configStore.delete(`${Xe}${e}`),this.configStore.delete(`${Ct}${e}`),this.configStore.delete(`${ln}${e}`)}loadDelta(e){return yr(this.configStore.get(`${Xe}${e}`))}recordWatermark(e,t){let r=this.loadDelta(e),i={version:1,entries:[...(r.kind==="stored"?r.state.entries:[]).filter(a=>a.sourceOrgId!==t.sourceOrgId||a.targetOrgId!==t.targetOrgId||a.objectApiName!==t.objectApiName),t],...r.kind==="stored"&&r.state.resetAt?{resetAt:r.state.resetAt}:{}};this.configStore.set(`${Xe}${e}`,i,un)}loadFiles(e){return lo(this.configStore.get(`${Ct}${e}`))}recordFile(e,t){let r=this.loadFiles(e);if(r.kind==="unreadable")throw new Error(`the record of copied files does not read: ${r.issue}`);let o=(r.kind==="stored"?r.map.entries:[]).filter(a=>a.sourceOrgId!==t.sourceOrgId||a.targetOrgId!==t.targetOrgId||a.sourceId!==t.sourceId);if(o.length>=Le)throw new Error(`the record of copied files holds ${Le} files already`);let i={version:1,entries:[...o,t]};this.configStore.set(`${Ct}${e}`,i,go)}forgetFiles(e,t,r){let s=this.loadFiles(e);if(s.kind!=="stored"||r.length===0)return[];let o=new Set(r.map(d=>d.slice(0,15))),i=[],a=s.map.entries.filter(d=>{let c=d.sourceOrgId===t.sourceOrgId&&d.targetOrgId===t.targetOrgId&&o.has(d.targetId.slice(0,15));return c&&i.push(d),!c});if(i.length>0){let d={version:1,entries:a};this.configStore.set(`${Ct}${e}`,d,go)}return i}markRemoved(e,t,r,s){let o=this.loadDelta(e);if(o.kind!=="stored"||r.length===0)return[];let i=[],a=o.state.entries.map(d=>d.sourceOrgId!==t.sourceOrgId||d.targetOrgId!==t.targetOrgId||!r.includes(d.objectApiName)?d:(i.push(d.objectApiName),{...d,removedAt:s}));if(i.length>0){let d={...o.state,entries:a};this.configStore.set(`${Xe}${e}`,d,un)}return i}clearDelta(e){let t=this.loadDelta(e),r=t.kind==="stored"?t.state.entries.length:0,s={version:1,entries:[],resetAt:new Date().toISOString()};return this.configStore.set(`${Xe}${e}`,s,un),r}};async function ji(n,e,t){let r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(let{objectApiName:o,ids:i}of e){let a=ye(o);for(let d of ee(i)){if(t?.aborted)return;let c=await n.queryDeleted(`SELECT Id, CreatedDate FROM ${a} WHERE Id IN (${d})`);for(let l of c.records){let u=Date.parse(String(l.CreatedDate??""));Number.isFinite(u)&&(r=Math.min(r,u),s=Math.max(s,u))}}}if(!(!Number.isFinite(r)||!Number.isFinite(s)))return{first:new Date(r).toISOString(),last:new Date(s).toISOString()}}async function rc(n,e){let t=s=>({note:`What the duplicate rules of the target reported of the run could not be read (${q(s)}): the empty DuplicateRecordSet records it left, if any, stay.`}),r=new Set;try{for(let{ids:s}of e)for(let o of ee(s)){let{records:i}=await n.query(`SELECT DuplicateRecordSetId FROM DuplicateRecordItem WHERE RecordId IN (${o})`);for(let a of i){let d=a.DuplicateRecordSetId;typeof d=="string"&&r.add(d)}}}catch(s){let o=q(s);return{objects:[],unread:o,take:async()=>t(s),emptiedBy:async()=>({unread:o})}}return{objects:r.size>0?[ut]:[],emptiedBy:async(s,o=[])=>{let i=new Set(o.map(u=>u.slice(0,15))),a=[...r].filter(u=>!i.has(u.slice(0,15))),d=new Map;try{for(let u of ee(a)){let{records:f}=await n.query(`SELECT DuplicateRecordSetId, RecordId FROM DuplicateRecordItem WHERE DuplicateRecordSetId IN (${u})`);for(let p of f){let m=String(p.DuplicateRecordSetId),y=d.get(m)??[];y.push(typeof p.RecordId=="string"?s(p.RecordId):"stays"),d.set(m,y)}}}catch(u){return{unread:q(u)}}let c=0,l=0;for(let u of a){let f=d.get(u)??[];f.every(p=>p==="goes")?c++:f.every(p=>p!=="stays")&&l++}return{empty:c,may:l}},take:async(s=[])=>{let o=new Set(s.map(l=>l.slice(0,15))),i=[...r].filter(l=>!o.has(l.slice(0,15)));if(i.length===0)return{};let a=new Set;try{for(let l of ee(i)){let{records:u}=await n.query(`SELECT DuplicateRecordSetId FROM DuplicateRecordItem WHERE DuplicateRecordSetId IN (${l})`);for(let f of u)a.add(String(f.DuplicateRecordSetId))}}catch(l){return t(l)}let d=i.filter(l=>!a.has(l));if(d.length===0)return{};let c={objectApiName:ut,planned:d.length,deleted:0,alreadyGone:0,keptChanged:0,keptDependents:0,refused:0,heldBy:[],unchecked:[],reasons:[]};for(let l=0;l<d.length;l+=Kt){let u=d.slice(l,l+Kt);for(let f of await $r(n,c.objectApiName,u))f.kind==="deleted"?c.deleted+=1:f.kind==="gone"?c.alreadyGone+=1:(c.refused+=1,c.reasons.includes(f.reason)||c.reasons.push(f.reason))}return{object:c}}}}function sc(n,e,t){return[...new Set([...Wr(n,[],t),...e.objects])]}function oc(n,e){return n==="success"&&(e.object?.refused??0)>0?"partial":n}function ic(n,e){let t=n.object;return!t||t.refused===0?[]:[`duplicate record sets: ${e} refused to delete ${t.refused} of the ${t.planned} the removal's deletes left empty: ${t.reasons.join("; ")}`]}var vi="deleted after the removal's deletes, once these leave them empty: the duplicate rules of the target wrote them for the run's records";async function ac(n,e,t,r={}){let s=new Map;for(let{objectApiName:l,ids:u}of e)for(let f of u)s.set(f.slice(0,15),l);let o=new Map(t.map(l=>[l.objectApiName,l])),{kept:i}=r,a=await n.emptiedBy(l=>{let u=o.get(s.get(l.slice(0,15))??"");return!u||u.toDelete===0?"stays":i?i.has(l.slice(0,15))?"stays":"goes":u.toDelete+u.alreadyGone>=u.planned?"goes":"may"},r.taken);if("unread"in a)return{note:`the duplicate record sets the removal's deletes may leave empty could not be read (${a.unread}): those it would delete after them are not counted`};let{empty:d,may:c}=a;return d+c===0?{}:{object:{objectApiName:ut,planned:d+c,toDelete:d,alreadyGone:0,changedSince:0,keptChanged:0,changedBy:{},undeletable:0,notVisible:0,unread:0,reasons:[vi,...c>0?[`${c} of them name a record of the run the removal may keep: deleted only if it goes`]:[]]}}}async function Ni(n,e){if(!n||!e)return n;let t=Date.parse(e.at),r=Date.parse(e.lastAt??""),s=Date.parse(n.first),o=Date.parse(n.last);if(!Number.isFinite(s)||!Number.isFinite(o)||!Number.isFinite(t)&&!Number.isFinite(r))return n;let i=await ho(e);if(i===void 0)return n;let a=Number.isFinite(t)?Math.min(s,t+i):s,d=Number.isFinite(r)?Math.max(o,r+i):o;return a===s&&d===o?n:{first:a===s?n.first:new Date(a).toISOString(),last:d===o?n.last:new Date(d).toISOString()}}async function ho(n){let e=n.now??(()=>new Date);try{let t=e().getTime(),r=Date.parse(await n.serverTime());return Number.isFinite(r)?r-(t+e().getTime())/2:void 0}catch{return}}async function Di(n){if(!n)return;let e=Date.parse(n.at);if(!Number.isFinite(e))return;let t=Date.parse(n.lastAt??""),r=await ho(n);if(r===void 0)return;let s=Number.isFinite(t)?Math.max(e,t):e;return{first:new Date(e+r).toISOString(),last:new Date(s+r).toISOString()}}var xi=50,Li=3,yo=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;async function $i(n,e,t,r){let s=Date.parse(t.first)-$s,o=Date.parse(t.last)+Bs;if(!Number.isFinite(s)||!Number.isFinite(o))return;let i=new Map,a=0;for(let{objectApiName:d,ids:c}of e){if(a>=Li||i.size>1||r?.aborted)break;let l=c.slice(0,xi);if(l.length===0)continue;let u;try{let[p]=ee(l,l.length);u=(await n.query(`SELECT Id, LastModifiedById, LastModifiedDate FROM ${ye(d)} WHERE Id IN (${p})`)).records}catch{continue}let f=!1;for(let p of u){let{LastModifiedById:m,LastModifiedDate:y}=p??{},h=typeof y=="string"?Date.parse(y):Number.NaN;typeof m!="string"||!yo.test(m)||!(h>=s&&h<=o)||(i.has(m.slice(0,15))||i.set(m.slice(0,15),m),f=!0)}f&&a++}return i.size===1?[...i.values()][0]:void 0}async function dc(n,e,t,r,s,o,i){let a=e.some(({ids:p})=>p.length>0),d=a?await Ni(await ji(n,e,r),s):await Di(s),c=i.runUserId!==void 0&&yo.test(i.runUserId)?i.runUserId:void 0,l=n.query?.bind(n),u=!c&&!a&&d&&l?await $i({query:l},o,d,r):void 0,f=o.filter(({ids:p})=>p.length>0);return{writtenBetween:d,created:e,remap:new Set([...e,...o].flatMap(({ids:p})=>p.map(m=>m.slice(0,15)))),automation:_s(t),...c?{runUserId:c}:{},...u?{user:u}:{},ties:{...i.ties,...f.length>0?{writtenOver:f}:{}},...r?{signal:r}:{}}}var Pt={status:"cancelled",objects:[],unread:[],handWork:[]};function yc(n,e,t){return{..._r(n,e),counts:Ws(Jr(Yr(n),t))}}async function wc(n,e){let t=Date.parse(n.writtenBetween?.first??""),r=Date.parse(n.writtenBetween?.last??"");if(!Number.isFinite(t)||!Number.isFinite(r))return n;let{created:s}=n,o=new Set(s.flatMap(({ids:c})=>c.map(l=>l.slice(0,15)))),i=await Br(e,{has:c=>o.has(c),start:t,end:r,...n.runUserId?{user:n.runUserId.slice(0,15)}:{}},s.filter(c=>c.objectApiName==="Quote").flatMap(({ids:c})=>c),new Set(s.map(c=>c.objectApiName))),a=new Set(i.flatMap(c=>c.copies.map(l=>l.id.slice(0,15))));if(a.size===0)return n;let{remap:d}=n;return{...n,remap:{has:c=>d.has(c)||a.has(c)}}}async function Sc(n){let e,t,r;try{let i=await n.input();"refused"in i?r={...Pt,status:"refused",refusal:i.refused}:t=Gs(n.org,i,{...n.options,approve:async a=>{let{check:d,decision:c}=await Gr(n.guard,{...n.guardOf,objectName:zs(a).join(", "),recordCount:Us(a)});if(e=c,c==="refused")return`Operation blocked by Production Guard: ${d.blockedReason??d.impactSummary}`;if(c==="declined")return"Operation cancelled by user (confirmation declined)."}})}catch(i){r={...Pt,status:"failure",refusal:q(i)}}let s=async i=>{if(!t||r)return!1;try{return await i(t)}catch(a){return r={...t.result(),status:"failure",refusal:q(a)},!1}},o;return{automationMade:t?.automationMade??new Set,ask:async()=>{await s(async i=>(await i.ask(),!1))},get takes(){return r?[]:t?.takes??[]},first:i=>s(a=>a.first(i)),afterRemoval:i=>s(a=>a.afterRemoval(i)),result:()=>r??t?.result()??Pt,settle:()=>(o??=(async()=>{let i=r??t?.result()??Pt;return n.onGuardDecision(i,e),t&&(t.made.size>0||t.late.size>0||t.gone.size>0)&&await n.keepMade?.(t.made,t.late,t.gone).catch(()=>{}),i})(),o)}}function bc(n){return n?"GUARD_BLOCKED":"SWEEP_REFUSED"}var wo=6e4;function Wi(n,e){return e.filter(t=>(t.ids.length>0||t.idsUntold===!0)&&Gi(n,t)).map(t=>({ids:[...t.ids],...t.idsUntold?{idsUntold:!0}:{}}))}function Gi(n,e){let t=Date.parse(n?.first??""),r=Math.max(t,Date.parse(n?.last??""));return!Number.isFinite(t)||!Number.isFinite(r)?!1:Number.isFinite(e.from)&&Number.isFinite(e.to)&&e.from<=r+9e5+wo&&Math.max(e.from,e.to)>=t-2e3-wo}var Ui=new Set(["autopilot_execute","anonymize_execute","subject_erase","backup_restore","checkpoint_rewind","checkpoint_undo","frozen_load"]);function Rc(n,e){return n.filter(t=>Ui.has(t.action)&&t.action!==e&&t.outcome!=="stopped").map(t=>{let r=Date.parse(t.timestamp);return{ids:[],idsUntold:!0,from:r,to:r}})}function zi(n){let e=Date.parse(n.firstWrittenAt??n.startedAt),t=Date.parse(n.lastWriteAt??n.lastWrittenAt??n.end?.at??n.startedAt);return{ids:[...n.created,...n.overwritten??[]].flatMap(({ids:r})=>r),from:e,to:Number.isFinite(t)?t:e}}function qi(n,e,t){return n.filter(r=>r.targetOrgId===e&&r.runId!==t).map(zi)}async function kc(n,e,t,r){let s=await r(n.targetOrgId,e).catch(()=>[]),o=Ki(n.removal?.removalSpans),i=n.removal?.madeEarlier,a=n.removal?.lateEarlier;return{otherRuns:Wi(e,[...qi(t,n.targetOrgId,n.runId),...s]),...o?{removalBegan:o}:{},...i&&i.length>0?{madeEarlier:i}:{},...a&&a.length>0?{lateEarlier:a}:{}}}function Oc(n,e,t,r=[]){let s=[...r],o=Zt(n.madeEarlier,e,s),i=Zt(n.lateEarlier,t,s),a={...n};return delete a.madeEarlier,delete a.lateEarlier,{...a,...o.length>0?{madeEarlier:o}:{},...i.length>0?{lateEarlier:i}:{}}}function Ki(n){let e;for(let t of n??[]){let r=Date.parse(t.first);Number.isFinite(r)&&(!e||r<e.at)&&(e={at:r,first:t.first})}return e?.first}var ae=class extends Error{constructor(t,r,s){super(t);this.result=r;this.cause=s;this.name="SyncRunFailure"}result;cause},$e=class extends ae{constructor(t,r,s){super(t,r);this.code=s;this.name="SyncRunRefused"}code};function Pc(n){return typeof n!="number"||!Number.isFinite(n)?5e4:Math.min(5e4,Math.max(1,Math.floor(n)))}var Hi=/\b(QUERY_TIMEOUT|OPERATION_TOO_LARGE)\b/;function pn(n){return Hi.test(n)?" Salesforce gave up on the count: filter the object on an indexed field (CreatedDate, SystemModstamp, Id, Name or an External ID) or on a narrower range of CreatedDate, then run it again. A user with View All Data reads the source without its sharing, which is what slows such a count most.":""}var Yi={raise:"the sandforge.sync.maxRecordsPerObject setting",sample:"Forge, with Depth ALL and Records per object set to A sample that fits the target"};function Ji(n,e,t){let r=e<5e4?`raise ${t.raise} (50000 at most), or `:"";return n==="target"?`To compare every record, ${r}narrow the object's filter.`:`To copy the rest, ${r}read it in slices: a filter on CreatedDate, one range per run. To copy a sample of the source that fits the target instead, use ${t.sample}.`}function Ic(n){let e=n.cutAtReadCap??[];if(!(n.readCap===void 0||e.length===0))return`the read of the source stopped at ${n.readCap} records of ${e.join(", ")} (sandforge.sync.maxRecordsPerObject): the run copied part of ${e.length===1?"it":"each"}. `+Ji("source",n.readCap,Yi)}var Vi=2e3,Xi=5e3,It=class{chunkSize;pollIntervalMs;signal;constructor(e={}){this.chunkSize=e.chunkSize??Vi,this.pollIntervalMs=e.pollIntervalMs??Xi,this.signal=e.signal}async executeChunked(e,t,r,s,o,i){if(!e.bulkManager.canStartNewJob())throw new Error("Maximum concurrent bulk jobs reached");let a=e.connection.bulk2.createJob({operation:r,object:t,...i?{externalIdFieldName:i}:{}}),d=a.id??`bulk-${crypto.randomUUID()}`,c={id:d,operation:r,object:t,state:"UploadComplete",numberRecordsProcessed:0,numberRecordsFailed:0,totalProcessingTime:0,createdDate:new Date().toISOString(),totalRecords:o};e.bulkManager.registerJob(c);try{await a.open();let l=Er(a);l!==void 0&&e.onOpened?.(l);let u=[];for await(let b of s){if(this.signal?.aborted)break;for(let A of b)u.push(A);e.onProgress?.(u.length,o)}let f,p=0;if(this.signal?.aborted||(f=Pr(r,u,i),await a.uploadData(f.text),p=u.length),this.signal?.aborted||f===void 0)return await Fr(a),e.bulkManager.updateJobState(d,"Aborted"),this.buildAbortedResult(p);await a.close();let m=await a.check();for(;m.state==="InProgress"||m.state==="UploadComplete";)e.bulkManager.updateJobState(d,m.state),e.onProgress?.(m.numberRecordsProcessed??0,o),await new Promise(b=>setTimeout(b,this.pollIntervalMs)),m=await a.check();let y=await a.getAllResults(),h=Ir(y,f,Tr(m)),w=h.outcomes,S=[],R=[],O=h.unattributedSuccessIds.length;for(let b of w)b.success?(O++,b.id!==void 0&&S.push(b.id)):R.push(b.error??"Unknown error");S.push(...h.unattributedSuccessIds),R.push(...h.unattributedFailures);let g=m.state==="JobComplete"?"JobComplete":"Failed";return e.bulkManager.updateJobState(d,g),e.bulkManager.updateJobCounts(d,m.numberRecordsProcessed??o,R.length),{totalRecords:p,successCount:O,failureCount:R.length,successIds:S,errors:R,aborted:!1,outcomes:w,...h.unattributedSuccessIds.length>0?{unmatchedIds:h.unattributedSuccessIds}:{}}}catch(l){throw e.bulkManager.updateJobState(d,"Failed"),l}}async*createChunkGenerator(e,t){let r=t??this.chunkSize;for(let s=0;s<e.length;s+=r)yield e.slice(s,s+r)}buildAbortedResult(e){return{totalRecords:e,successCount:0,failureCount:0,successIds:[],errors:[],aborted:!0}}};var Zi=1e4,So=fe.REST_API_BATCH_SIZE;function Qi(n){return!n.success&&n.errors.some(e=>e.startsWith("DUPLICATES_DETECTED"))}function ea(n){return!n.success&&vr(n.errors,n.errorDetails)}function ta(n,e){let[t,...r]=n.errors;return t===void 0?n:{...n,errors:[Dr(t,e),...r]}}function fn(n){return typeof n.created=="boolean"?{created:n.created}:{}}function ko(n){return n.some(e=>e.fields.length>0)?{errorDetails:n}:{}}function bo(n){let e=n===void 0?void 0:kr(n);return e?ko([e]):{}}function gn(n,e){return n!=="insert"&&n!=="upsert"?[]:e.flatMap(t=>t.success&&typeof t.id=="string"&&t.id!==""&&(n==="insert"||t.created===!0)?[t.id]:[])}function na(n,e){return!n||!e?n??e:{before:async(t,r,s,o)=>await n.before?.(t,r,s,o)??await e.before?.(t,r,s,o),sending:(t,r,s)=>{n.sending(t,r,s),e.sending(t,r,s)},opened:(t,r,s,o)=>{n.opened?.(t,r,s,o),e.opened?.(t,r,s,o)},answered:(t,r,s,o)=>{n.answered(t,r,s,o),e.answered(t,r,s,o)}}}function Bc(n,e){let t=r=>r==="insert"||r==="upsert";return{...e?{before:(r,s,o,i)=>e.before(r,s,o,i)}:{},sending:(r,s,o)=>{t(s)?n.sending?.(r,o,s==="upsert"?{upsert:!0}:void 0):n.writing?.(r,o)},opened:(r,s,o,i)=>{t(s)&&n.sending?.(r,o,{job:i,...s==="upsert"?{upsert:!0}:{}})},answered:(r,s,o)=>{t(s)?n.answered?.(r,gn(s,o)):o.length>0&&n.writing?.(r,o.length),e?.answered(r,s,o)}}}var Ro=class{constructor(e){this.deps=e;this.wait=e.wait??(t=>Nr(t,e.signal)),this.retryOp=new kt({retryConfig:e.retryConfig,signal:e.signal,onRetry:(t,r,s)=>{e.log(`[RETRY] sync attempt=${t} code=${r.originalError.statusCode} delay=${s}ms`)}})}deps;retryOp;wait;async insert(e,t,r,s){let o=na(this.deps.calls,s),i=l=>this.deps.connection.sobject(e).create(l,{headers:ot()}),a="Insert failed after retries",d=await this.tryStreaming("insert",e,t,void 0,o)??await this.tryBulk("insert",e,t,void 0,o),c=d?await this.duplicatesAgain("insert",e,t,d,i,a,o):await this.executeRestBatches("insert",e,t,r,i,a,o);return this.locksAgain("insert",e,t,c,i,a,o)}async upsert(e,t,r,s){let o=c=>this.deps.connection.sobject(e).upsert(c,t,{headers:ot()}),i="Upsert failed after retries",a=await this.tryStreaming("upsert",e,r,t)??await this.tryBulk("upsert",e,r,t),d=a?await this.duplicatesAgain("upsert",e,r,a,o,i,this.deps.calls,t):await this.executeRestBatches("upsert",e,r,s,o,i,this.deps.calls,t);return this.locksAgain("upsert",e,r,d,o,i,this.deps.calls,t)}async update(e,t,r){let s=d=>this.deps.connection.sobject(e).update(d,{headers:ot()}),o="Update failed after retries",i=await this.tryStreaming("update",e,t)??await this.tryBulk("update",e,t),a=i?await this.duplicatesAgain("update",e,t,i,s,o):await this.executeRestBatches("update",e,t,r,s,o);return this.locksAgain("update",e,t,a,s,o)}async delete(e,t,r){let s=d=>this.deps.connection.sobject(e).destroy(d),o="Delete failed after retries",i=t.map(d=>({Id:d})),a=await this.tryBulk("delete",e,i)??await this.executeRestBatches("delete",e,t,r,s,o);return this.locksAgain("delete",e,t,a,s,o)}async tryStreaming(e,t,r,s,o=this.deps.calls){if(r.length<=Zi)return;if(await this.deps.pauseGate?.whilePaused(this.deps.signal),this.deps.signal?.aborted)throw new Q(t);let i=await this.refusedBefore(o,t,e,r,s);if(i)return i;let a=new It({signal:this.deps.signal});o?.sending(t,e,r.length);let d={connection:Xt(this.deps.connection),bulkManager:this.deps.bulkManager,onProgress:(u,f)=>{this.deps.onProgress(u,f,`Streaming ${e} ${t}`)},onOpened:u=>o?.opened?.(t,e,r.length,u)},c=await a.executeChunked(d,t,e,a.createChunkGenerator(r),r.length,s);if(c.aborted)throw o?.answered(t,e,[]),new Q(t);this.logUnmatched(`Streaming ${e} ${t}`,c.unmatchedIds);let l=(c.outcomes??[]).map(u=>this.withExistingRecord(t,{id:u.id,success:u.success,errors:u.success?[]:[u.error??"Streaming error"],...fn(u),...u.success?{}:bo(u.error)}));return o?.answered(t,e,l),l}async tryBulk(e,t,r,s,o=this.deps.calls){if(!this.deps.bulkExecutor.shouldUseBulkApi(r.length))return;if(await this.deps.pauseGate?.whilePaused(this.deps.signal),this.deps.signal?.aborted)throw new Q(t);let i={connection:Xt(this.deps.connection),bulkManager:this.deps.bulkManager,onProgress:(l,u)=>{this.deps.onProgress(l,u,`Bulk ${e} ${t}`)},signal:this.deps.signal,onOpened:l=>o?.opened?.(t,e,r.length,l)},a=await this.refusedBefore(o,t,e,r,s);if(a)return a;o?.sending(t,e,r.length);let d=await this.deps.bulkExecutor.executeBulk(i,t,e,r,s);if(d.aborted)throw o?.answered(t,e,[]),new Q(t);this.logUnmatched(`Bulk ${e} ${t}`,d.unmatchedIds);let c=d.outcomes.map(l=>this.withExistingRecord(t,{id:l.id,success:l.success,errors:l.success?[]:[l.error??"Bulk error"],...fn(l),...l.success?{}:bo(l.error)}));return o?.answered(t,e,c),c}async refusedBefore(e,t,r,s,o){if(r==="delete"||!e?.before)return;let i=await e.before(t,r,s,o);if(i!==void 0)return this.deps.log(`[WARN] ${r} ${t}: ${s.length} row(s) not sent: ${i}`),s.map(()=>({success:!1,errors:[i]}))}async duplicatesAgain(e,t,r,s,o,i,a=this.deps.calls,d){let c=s.flatMap((p,m)=>m<r.length&&Qi(p)?[m]:[]);if(c.length===0||this.deps.signal?.aborted)return s;let l;try{l=await this.executeRestBatches(e,t,c.map(p=>r[p]),So,o,i,a,d,c)}catch(p){if(!(p instanceof Q))throw p;l=p.written}let u=[...s];l.forEach((p,m)=>{u[c[m]]=p});let f=l.filter(p=>p.success).length;return this.deps.log(`[INFO] ${e} ${t}: ${c.length} row(s) a duplicate rule refused in the Bulk API job, which cannot carry the header that lets a rule's matches be saved, went again through REST with it: ${f} saved`+(l.length<c.length?`, ${c.length-l.length} not sent (cancelled)`:"")),u}async locksAgain(e,t,r,s,o,i,a=this.deps.calls,d){let c=new Map,l=await xr({outcomes:s.slice(0,r.length),locked:ea,written:p=>p.success,send:async p=>{let m;try{m=await this.executeRestBatches(e,t,p.map(y=>r[y]),So,o,i,a,d,p)}catch(y){if(!(y instanceof Q))throw y;m=y.written}for(let y of p.slice(0,m.length))c.set(y,(c.get(y)??0)+1);return m},note:ta,wait:p=>this.wait(p),stopped:()=>this.deps.signal?.aborted===!0}),u=Lr("row(s)",l,e==="delete"?"deleted":"written");return u===void 0?s:(this.deps.log(`[INFO] ${e} ${t}: ${u}`),[...l.outcomes.map((p,m)=>{let y=c.get(m);return y===void 0?p:{...p,lockResends:y}}),...s.slice(r.length)])}logUnmatched(e,t){t&&t.length>0&&this.deps.log(`[WARN] ${e}: the job wrote ${t.length} record(s) no row was matched to: ${t.join(", ")}`)}withExistingRecord(e,t){if(t.success)return t;let r=Vt(t,this.deps.keyPrefixOf?.(e));return r.kind==="linked"?{...t,existingId:r.id}:t}async executeRestBatches(e,t,r,s,o,i,a=this.deps.calls,d,c){let l=[];for(let u=0;u<r.length;u+=s){if(await this.deps.pauseGate?.whilePaused(this.deps.signal),this.deps.signal?.aborted)throw new Q(t,l);let f=r.slice(u,u+s);if(e!=="delete"){let y=await this.refusedBefore(a,t,e,f,d);if(y){l.push(...y);continue}if(this.deps.signal?.aborted)throw new Q(t,l)}a?.sending(t,e,f.length);let p=await this.retryOp.execute(()=>o(f));if(p.cancelled)throw a?.answered(t,e,[],c&&[]),new Q(t,l);let m=[];if(p.success&&p.result)for(let y of Array.isArray(p.result)?p.result:[p.result])m.push(this.restOutcome(t,y));else m.push(...f.map(()=>({success:!1,errors:[p.error?.message??i]})));l.push(...m),a?.answered(t,e,m,c?.slice(u,u+f.length))}return l}restOutcome(e,t){if(t.success)return{id:t.id,success:!0,errors:[],...fn(t)};let r=t.errors??[],s=r.map(Or),o={id:t.id,success:!1,errors:[s[0]??"Unknown error"],...ko(r.map(Rr))},i=Vt({success:!1,errors:s,duplicateMatchIds:r.flatMap(a=>Ar(a,e))},this.deps.keyPrefixOf?.(e));return i.kind==="linked"?{...o,existingId:i.id}:o}};function Oo(n,e){if(n.operation==="delete")return[];let t=hr(n.fieldMappings,n.excludedFields??[]),r=new Set([...mr(n.fieldMappings),...n.addOnFields.map(o=>o.fieldApiName.toLowerCase())]),s=o=>!t.has(o.toLowerCase())||r.has(o.toLowerCase());return(e.fields??[]).flatMap(o=>o.isReference&&o.createable&&o.name!=="RecordTypeId"&&(o.referenceTo?.length??0)>0&&s(o.name)?[{field:o.name,referenceTo:o.referenceTo??[]}]:[])}function Ao(n,e){let t=[...n].sort((R,O)=>R.insertOrder-O.insertOrder),r=new Map(t.map((R,O)=>[R.objectApiName,O])),s=new Set(t.filter(R=>R.operation!=="delete").map(R=>R.objectApiName)),o=new Map([...s].map(R=>[R.toLowerCase(),R])),i=[],a=new Set;for(let R of t){let O=R.objectApiName;if(s.has(O))for(let{field:g,referenceTo:b}of e.get(O)??[])for(let A of b){let k=o.get(A.toLowerCase());if(k===void 0||k===O)continue;let C=`${k}>${O}`;a.has(C)||(a.add(C),i.push({parent:k,child:O,field:g}))}}let d=ra(t.map(R=>R.objectApiName),i),c=new Map;d.forEach((R,O)=>{for(let g of R)c.set(g,O)});let l=d.map(R=>[...R].sort((O,g)=>(r.get(O)??0)-(r.get(g)??0))),u=l.map(R=>r.get(R[0])??0),f=l.map(()=>new Set);for(let{parent:R,child:O}of i){let g=c.get(R)??0,b=c.get(O)??0;g!==b&&f[b].add(g)}let p=new Set,m=[];for(;p.size<l.length;){let R;if(l.forEach((O,g)=>{p.has(g)||[...f[g]].some(b=>!p.has(b))||(R===void 0||u[g]<u[R])&&(R=g)}),R===void 0)break;p.add(R),m.push(...l[R])}let y=new Map(t.map(R=>[R.objectApiName,R])),h=m.flatMap(R=>{let O=y.get(R);return O?[O]:[]}),w=new Map(m.map((R,O)=>[R,O])),S=[];for(let R of h){let O=R.objectApiName,g=i.filter(b=>b.child===O&&(r.get(b.parent)??0)>(r.get(O)??0)&&(w.get(b.parent)??0)<(w.get(O)??0)).sort((b,A)=>(w.get(A.parent)??0)-(w.get(b.parent)??0));g.length>0&&S.push({objectApiName:O,after:g[0].parent,field:g[0].field})}return{ordered:h,order:{objects:m,moved:S,cycles:l.filter(R=>R.length>1)}}}function ra(n,e){let t=new Map(n.map(l=>[l,[]]));for(let{parent:l,child:u}of e)t.get(l)?.push(u);let r=0,s=new Map,o=new Map,i=[],a=new Set,d=[],c=l=>{s.set(l,r),o.set(l,r),r++,i.push(l),a.add(l);for(let p of t.get(l)??[])s.has(p)?a.has(p)&&o.set(l,Math.min(o.get(l)??0,s.get(p)??0)):(c(p),o.set(l,Math.min(o.get(l)??0,o.get(p)??0)));if(o.get(l)!==s.get(l))return;let u=[],f;do{if(f=i.pop(),f===void 0)break;a.delete(f),u.push(f)}while(f!==l);d.push(u)};for(let l of n)s.has(l)||c(l);return d}var sa=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,de=n=>n.toLowerCase();function Et(n){return n==="insert"||n==="upsert"}function oa(n,e){let t=de(e);if(n.addOnFields.some(s=>de(s.fieldApiName)===t)||n.transformRules.some(s=>s.field&&de(s.field)===t))return;let r=n.fieldMappings.find(s=>s.type!=="exclude"&&de(s.targetField)===t);return r?(r.type==="direct"||r.type==="rename")&&(r.transformRules??[]).length===0?r.sourceField:void 0:e}function ia(n){return n!==void 0&&[...n.source.active].some(e=>!n.target.active.has(e))}async function Co(n){let e=new Map,t=new Ke(n.earlier),r=new Set,s=new Set([...n.leftOut].map(de)),o,i=async l=>{let u=await n.read(l);return u.length>0&&St(l.objectApiName,u)&&(o=await n.standardPricebooks?.(),o&&t.noteMatched(o.source,o.target)),u},a=n.matched,d=(l,u)=>{a&&u>0&&a.set(l,(a.get(l)??0)+u)},c=(l,u)=>{let f=o?.source;return l===ge&&f!==void 0?u.filter(p=>p.Id===f).length:0};for(let l of n.ordered){let u=l.objectApiName;if(s.has(de(u))){if(!Et(l.operation))continue;let k=await i(l);for(let C of k){let F=C.Id;typeof F=="string"&&F!==""&&t.noteRefused(F,u)}d(u,c(u,k)),r.add(de(u));continue}if(l.operation==="delete")continue;let f=(n.lookups.get(u)??[]).flatMap(({field:k,referenceTo:C})=>{let j=C.filter(N=>de(N)!==de(u)&&r.has(de(N))).length>0?oa(l,k):void 0;return j!==void 0?[{field:k,source:j}]:[]}),p=a!==void 0&&Et(l.operation),m=p&&u===ge&&await n.standardPricebooks?.()!==void 0,y=p&&u===Fe&&await n.standardPricebooks?.()?await n.currencies?.():void 0,h=ia(y);if(f.length===0&&!m&&!h)continue;let w=new Map,S=k=>{let C=`${k.parent}|${k.field}`,F=w.get(C);F?F.rows++:w.set(C,{...k,rows:1})},R=n.copied?.get(u),O=(await i(l)).filter(k=>{let C=k.Id;return!(R&&typeof C=="string"&&R.has(C.slice(0,15)))}),g=new Map;for(let k of f.length>0?O:[]){let C=k.Id,F=f.find(({source:N})=>{let L=k[N];return typeof L=="string"&&sa.test(L)&&t.refusedObjectOf(L)!==void 0});if(!F)continue;let j={parent:t.refusedObjectOf(k[F.source])??"",field:F.field};S(j),typeof C=="string"&&C!==""&&g.set(C,j),Et(l.operation)&&typeof C=="string"&&C!==""&&t.noteRefused(C,u)}if(m&&d(u,c(u,O)),h){let k=bt(Fe,{records:O,sources:O,sourceIds:O.map(F=>typeof F.Id=="string"?F.Id:void 0)},o,y,F=>t.refusedObjectOf(F)!==void 0),C=0;for(let[F,j]of k.standsFor){if(g.has(F))continue;let N=t.refusedObjectOf(j)!==void 0?g.get(j):void 0;if(N){S(N),g.set(F,N),t.noteRefused(F,u);continue}C++}d(u,C)}let b=[...w.values()],A=b.reduce((k,C)=>k+C.rows,0);A>0&&(e.set(u,{objectApiName:u,rows:A,parent:b[0].parent,field:b[0].field,parents:b}),Et(l.operation)&&r.add(de(u)))}return e}var Po=Symbol("not written");function aa(n,e,t=[]){if(n==="delete")return{rules:[],onChange:[]};let r=[],s=[];for(let{onChangeOnly:o,reads:i,...a}of e){if(o&&n==="insert"){s.push(a.name);continue}let d=ss(i,t).map(({field:c})=>c);r.push(d.length>0?{...a,readsUnreachable:d}:a)}return{rules:r,onChange:s}}function da(n){return`${n.length} active validation rule(s) of the target left out of what may refuse these inserts: their formula holds only on a change of a record (ISCHANGED, PRIORVALUE, NOT(ISNEW())), which an insert never is \u2014 ${n.join(", ")}`}var ca=/^012000000000000(AAA)?$/;function la(n){let e=n.RecordTypeId;return typeof e=="string"&&e.length>=15&&!ca.test(e)}function yn(n){let e=n?.[or];return typeof e=="string"&&e!==""}async function Io(n,e,t,r){let s=e.some(la)?await n.recordTypes():void 0,o=t.some(yn)||e.some(yn)?await n.currencies():void 0,i=n.later?.get(r),a=n.recordTypesUnderTheLease?.get(r);return{links:n.links,sources:t,...s?{recordTypes:s}:{},...o?{currencies:o,currencyChangesById:n.currencyChangesById}:{},...n.contactPoints?{contactPoints:n.contactPoints}:{},...i&&i.size>0?{later:i}:{},...a?{recordTypesUnderTheLease:a}:{},...n.createdWithoutRecordType?{createdWithoutRecordType:n.createdWithoutRecordType}:{}}}function mn(n){let e=new Map;for(let t of n?.cycles??[])t.forEach((r,s)=>{s<t.length-1&&e.set(r,new Set(t.slice(s+1)))});return e}function ua(n,e,t){return{...n,...e.set?{lookupsSetAfter:{...e.set,after:[...t]}}:{},...e.leftOut.length>0?{lookupsLeftOut:[...n.lookupsLeftOut??[],...e.leftOut]}:{}}}function Eo(n,e){return e.flatMap((t,r)=>{let s=n[r];return t.success&&s!==void 0?[s]:[]})}function To(n,e){let t=e.encryptedLeftOut??[];return t.length>0?{...n,encryptedLeftOut:[...t]}:n}function re(n){return n.slice(0,15)}function pa(n,e){if(!e)return n;if(e.unread!==void 0)return{...n,errors:[...n.errors,`The contact roles the platform wrote with the run's opportunities were not looked up, so written as read: an opportunity may hold the role of its contact twice. ${e.unread}`]};let{records:t,given:r,refusal:s,alike:o}=e,i=o!==void 0?{...n,errors:[...n.errors,er(o)]}:n;return t===0?i:{...i,skipped:i.skipped+t,writtenByThePlatform:{records:t,given:r,...s!==void 0?{refusal:s}:{}}}}function fa(n,e,t){if(n.objectApiName!==X||!ce(n.operation)||!t.sentWithAContact||e.records.length===0)return{prepared:e,linked:0};let r=a=>typeof a=="string"&&a!==""?t.targetOf(a):void 0,s=e.records.map((a,d)=>({OpportunityId:r(a.OpportunityId),[ie]:r(a[ie]),IsPrimary:e.sources[d]?.IsPrimary??a.IsPrimary})),o=new Set(qt(s,a=>t.contactSentWith(a)));if(o.size===0)return{prepared:e,linked:0};for(let a of o){t.roleLinkedFor(String(s[a].OpportunityId));let d=e.sourceIds[a];d!==void 0&&t.noteWritten(d,d)}let i=(a,d)=>!o.has(d);return{prepared:{...e,records:e.records.filter(i),sourceIds:e.sourceIds.filter(i),sources:e.sources.filter(i),unsettled:e.unsettled.length===e.records.length?e.unsettled.filter(i):e.unsettled},linked:o.size}}var ga=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,hn=200;function ma(n,e,t){let r=c=>{let l=t?.fields?.find(u=>u.name===c);return l?.nillable===!1&&l.defaultedOnCreate!==!0},s=[],o=new Set,i=new Set,a=0;for(let[c,l]of n){let u=e[c]==="insert"?l.filter(r):[];if(u.length>0){s.push(c);for(let f of u)o.add(f);continue}a++;for(let f of l)i.add(f)}let d=[];return a>0&&d.push(`${a} record(s) would be written without ${[...i].sort().join(", ")}: a lookup held an id from the source org that the target does not have, which the run learns from its first refusal and sends the record again without the lookups it did not settle.`),s.length>0&&d.push(`${s.length} record(s) would be refused: a lookup held an id from the source org that the target does not have, and sent again without the lookups the run did not settle, the record lacks ${[...o].sort().join(", ")}, which the target requires (REQUIRED_FIELD_MISSING).`),{refused:s,notes:d}}function ha(n){return`${n} record(s) would be linked to the contact role the platform writes with their opportunity, for its contact, not written.`}function wn(n){let e=n.alreadyLinked,t=n.alreadyCopied-e;return{...t>0?{alreadyCopied:t}:{},...e>0?{alreadyLinked:e}:{}}}function ya(n,e){return e.alreadyCopied===0?n:{...n,skipped:n.skipped+e.alreadyCopied,...wn(e)}}function Fo(n,e){return`What earlier runs of this configuration copied could not be read (${n}), and ${e.map(t=>t.objectApiName).join(", ")} ${e.length===1?"is":"are"} inserted: the records they copied would be copied a second time. Nothing was written.`}var wa="SYNC_EARLIER_UNREAD",Sa=new Set(["account","contact"]);function ce(n){return n==="insert"||n==="upsert"}function ba(n,e,t=[],r=new Set){if(e<=0||!ce(n.operation))return;let s=n.objectApiName.toLowerCase(),o=new Set([...r].map(c=>c.toLowerCase())),i=t.flatMap(({referenceTo:c})=>c.map(l=>l.toLowerCase())),a=i.includes(s),d=i.some(c=>o.has(c));if(!(!a&&!d))return{...a?{within:e}:{},...d?{cycle:e}:{}}}function Mo(n,e,t,r=new Map,s=new Set,o=new Map,i=new Map,a=new Set,d,c={}){let l=0,u=0,f=n.map(g=>{let b=g.objectApiName,A=e.get(b)??{rows:0},k=t.get(b)??new Set,C=k.size,F=Math.min(C,A.rows),j=Math.min([...k].filter(v=>a.has(v)).length,F);u+=j,l+=F-j;let L=(r.has(b)?0:o.get(b)?.rows??0)+(i.get(b)??0),W=c.keys?.get(b),M=Math.max(0,A.rows-C-L),P=ba(g,M,c.lookups?.get(b),c.later?.get(b));return{objectApiName:b,operation:g.operation,rows:M,...A.personAccounts!==void 0?{personAccounts:A.personAccounts}:{},batchSize:g.batchSize,...W?{overwriteKey:W}:{},...P?{lookupPasses:P}:{}}}),p=f.flatMap(g=>{let b=r.get(g.objectApiName);return b?[{...g,why:b.why,...b.key?{key:b.key}:{}}]:[]}),m=f.find(g=>g.objectApiName===X),y=m&&d!==void 0?Math.min(d,m.rows):0;m&&y>0&&(m.rows-=y);let h=f.filter(g=>!r.has(g.objectApiName)),w=h.filter(g=>g.rows>0&&ce(g.operation)&&s.has(g.objectApiName)).length,S=[...o.values()].filter(({objectApiName:g})=>!r.has(g)),R=d===void 0?Ra(n,h):0,O=h.filter(g=>c.typed?.has(g.objectApiName)).length;return{objects:h,alreadyCopied:l,...u>0?{alreadyLinked:u}:{},...p.length>0?{unwritable:p}:{},...S.length>0?{heldBack:S}:{},...w>0?{readBack:w}:{},...R>0?{rolesByThePlatform:R}:{},...y>0?{rolesLinked:y}:{},...O>0?{describedAgain:O}:{}}}var Ee="Opportunity";function Ra(n,e){let t=i=>e.find(a=>a.objectApiName===i&&ce(a.operation)),r=t(Ee),s=t(X);return!r||!s||n.find(i=>i.objectApiName===Ee)?.excludedFields.includes(ie)?0:Math.min(r.rows,s.rows)}function ka(n,e,t){return{objectApiName:n.objectApiName,operation:n.operation,processed:0,success:0,failed:0,skipped:t,conflictCount:0,errors:[`${e.message} Left out of the run, as confirmed before it wrote.`]}}function jo(n,e,t){if(ce(e.operation))for(let r of t){let s=r?.Id;typeof s=="string"&&s!==""&&n.noteRefused(s,e.objectApiName)}}function Tt(n,e,t){let r=[];for(let[s,o]of t){let i=n.targetOf(o);i!==void 0?n.noteMatched(s,i):ce(e.operation)&&n.refusedObjectOf(o)!==void 0&&(n.noteRefused(s,e.objectApiName),r.push(s))}return r}function vo(n,e,t){let r=sn(e,t),s=an(n,{...e,prices:r});return t.length===0?s:{...s,processed:s.processed+t.length,failed:s.failed+t.length,errors:[...s.errors,on(n.objectApiName,t.length)]}}function No(n){let e=qn(n.objects);return e.length>0?`${Kn(e)} Nothing was read or written.`:void 0}function Do(n){let e=Yn(n.objects);return e.length>0?`${Jn(e)} Nothing was read or written.`:void 0}var xo=class{deps;constructor(e){this.deps=e}async execute(e){let t=Date.now(),r=`sync-${Date.now()}`,s=[],o=No(e);if(o!==void 0)throw new $e(o,{...se(e.id,r,[],t,"failure"),error:o},zn);let i=Do(e);if(i!==void 0)throw new $e(i,{...se(e.id,r,[],t,"failure"),error:i},Hn);let{ordered:a,order:d,refused:c,typed:l,lookups:u,keys:f}=await this.writeOrderOf(e.objects),p=mn(d),m=this.deps.queryTargetRows?l:new Set,y=this.deltaLoadOf(e),h=(I,E)=>new $e(I,{...se(e.id,r,[],t,"failure"),error:I},E),w;try{w=await this.planFiles(e,a,y)}catch(I){let E=I instanceof Error?I.message:String(I);throw new ae(E,se(e.id,r,[],t,"failure"),I)}if(w?.storage.shortfall)throw new ae(`${w.storage.shortfall} Nothing was written.`,{...se(e.id,r,[],t,"failure"),files:w.storage});let S=await this.earlierLinks(e),R=a.filter(I=>I.operation==="insert");if(S.unread!==void 0&&R.length>0)throw h(Fo(S.unread,R),wa);let O;try{O=await this.alreadyCopiedOf(e,a,S.links)}catch(I){let E=`What earlier runs of this configuration copied could not be looked up in the target (${I instanceof Error?I.message:String(I)}), so nothing was written.`;throw new ae(E,{...se(e.id,r,[],t,"failure"),error:E},I)}let g=await this.countRun(e,a,y,this.deps.writeGate!==void 0);if(this.deps.writeGate&&"unread"in g){let I=`The records to write could not be counted (${g.unread}), so nothing was written.`+pn(g.unread);throw new ae(I,{...se(e.id,r,[],t,"failure"),error:I})}let b=new Map,A=this.standardPricebooksOnce(),k=this.currenciesOnce(),C=y===void 0?new Map:void 0;if(this.deps.writeGate&&"counted"in g){let I;try{I=await this.heldBackOfRun(e,a,c,u,y,S.links,O,A,k,C)}catch(B){let z=B instanceof Error?B.message:String(B);throw new ae(z,{...se(e.id,r,[],t,"failure"),error:z},B)}let E=Mo(a,g.counted,O,c,m,I.heldBack,I.matched,S.linked,await this.rolesLinkedAtTheGate(e,a,c,I.heldBack,O,S.links,C),{keys:f,...this.deps.describeTargetFieldsAgain?{typed:l}:{},lookups:u,later:p}),{answer:D}=await this.deps.writeGate.hold(E);if(!D.go)throw h(D.message,D.code);for(let B of E.unwritable??[])b.set(B.objectApiName,B.rows)}let F=this.deps.leaseOfTheGate?.(),j=F&&F.assigned>0?await this.recordTypesReadAgain(a.map(I=>I.objectApiName).filter(I=>l.has(I)&&!b.has(I))):void 0,N=new Map,L=async()=>{let I=F;F=void 0,await I?.giveBack().catch(()=>{});for(let[E,D]of await this.readBackRecordTypes(N))for(let B=s.length-1;B>=0;B--)if(s[B].objectApiName===E){s[B]={...s[B],recordTypeGiven:D};break}},W=new Ke(S.links),M=this.recordTypesOnce(),P=new Map,v=Qs(e),$=this.deps.idMap,H={sourceOrgId:e.sourceOrgId,targetOrgId:e.targetOrgId},K=Promise.resolve(),G,ne=(I,E,D)=>{if(!$)return;let B=Oa(I.operation,E,D);for(let[z,Y]of[[B.written,!1],[B.linked,!0]])z.length!==0&&(K=K.then(()=>$.record(e.id,H,I.objectApiName,z,Y).catch(pe=>{G??=pe instanceof Error?pe.message:String(pe)})))},Te=0,Se=(I,E)=>{if(E.length===0)return;this.deps.creations?.deleted?.(I,E),Te+=E.length,W.noteDeleted(E);let D=$?.forget?.bind($);D&&(K=K.then(()=>D(e.id,H,E).then(()=>{},B=>{G??=B instanceof Error?B.message:String(B)})))},V=this.deps.creations,be=new Map,oe=0,T=(I,E)=>{if(!V)return;let D=gn(I.operation,E);if(D.length===0)return;let B=I.objectApiName;V.noteUnanswered?V.noteUnanswered(B,D):V.note(B,D),be.set(B,(be.get(B)??0)+D.length)},_=(I,E)=>{V&&(V.note(I,[E]),oe++)},Z=!1,me=!1,Be=!1,ci=async I=>{let E=await V?.flush();await K;let D=[];return S.unread!==void 0&&!Be&&(Be=!0,D.push(`What earlier runs of this configuration wrote could not be read (${S.unread}): a lookup at a record one of them wrote went as the source holds it.`)),E!==void 0&&!Z&&(Z=!0,D.push(`What this run created could not all be kept (${E}): removing the run may leave some of it in the target.`)),G!==void 0&&!me&&(me=!0,D.push(`Which record of the target each record this run wrote became could not all be kept (${G}): a later run may send a lookup at one of them as the source holds it.`)),D.length===0?I:{...I,errors:[...I.errors,...D]}},le=async I=>{s.push(await ci(I))},Re=new Map,li=new Set((d?.cycles??[]).map(I=>I[I.length-1])),Tn=(I,E)=>{for(let D=s.length-1;D>=0;D--)if(s[D].objectApiName===I){s[D]=ua(s[D],E,[...p.get(I)??[]]);return}},Qe=new Map,ui=(I,E)=>{for(let D=s.length-1;D>=0;D--)if(s[D].objectApiName===I){s[D]={...s[D],errors:[...s[D].errors,E]};return}},Nt=(I,E,D)=>{for(let B=s.length-1;B>=0;B--){let z=s[B];if(z.objectApiName!==I)continue;if(!z.delta)return;let Y=(z.delta.lookupsOwed??0)+E;s[B]={...z,delta:{...z.delta,...D!==void 0?{recorded:D}:{},...Y>0?{lookupsOwed:Y}:{}}};return}},pi=async()=>{for(let[I,E]of[...Re]){Re.delete(I),await this.deps.pauseGate?.whilePaused(this.deps.signal);let D=this.deps.signal?.aborted?{leftOut:rn(E.pending),unset:nn(E.pending)}:await this.deps.dataSync.setLookups(E.objectConfig,E.pending,W,!0);"set"in D&&D.set&&V?.touched?.(I,D.set.records),Tn(I,D);let B=Qe.get(I);if(Qe.delete(I),D.unset===0){let z=B?.();z!==void 0&&Nt(I,0,z)}else Nt(I,D.unset)}},Dt=()=>{for(let[I,E]of[...Re])Re.delete(I),Qe.delete(I),Tn(I,{leftOut:rn(E.pending)}),Nt(I,nn(E.pending))},et=I=>{let E=eo(v,I.objectResults.some(Y=>Y.success>0)),D={...I,...w?{files:w.storage}:{},...E?{contactPoints:E}:{}},B=V?.overwrittenCount?.()??0,z=V?.deleted?Te:0;return!V||be.size===0&&oe===0&&B===0&&z===0?D:{...D,created:{runId:V.runId,objects:[...be].map(([Y,pe])=>({objectApiName:Y,count:pe})),files:oe,...B>0?{overwritten:B}:{},...z>0?{deleted:z}:{}}}},Fn="counted"in g?[...g.counted.values()].reduce((I,{rows:E})=>I+E,0):void 0,tt=this.isGrappeActive(Fn);tt&&this.deps.onGrappeEvent?.({type:"grappe:started",payload:{operationId:r,totalPartitions:a.length,totalRecords:Fn}});let Mn=()=>{if(!tt)return;let I=0,E=0;for(let D of s)I+=D.processed,E+=D.failed;this.deps.onGrappeEvent?.({type:"grappe:completed",payload:{operationId:r,totalProcessed:I,totalFailed:E}})},ke=async(I,E)=>(Dt(),await L(),Mn(),await V?.flush(),await K,et(Ca(e.id,r,s,t,I,E))),nt=0;for(let[I,E]of a.entries()){if(await this.deps.pauseGate?.whilePaused(this.deps.signal),this.deps.signal?.aborted)return ke(a.slice(I));let D=c.get(E.objectApiName),B=b.get(E.objectApiName);if(D&&B!==void 0){let x=ka(E,D,B);try{await this.noteLeftOutRefused(e,E,y,{links:W,...S.linked?{earlierLinked:S.linked}:{},recordTypes:M,currencies:k,currencyChangesById:P,standardPricebooks:A,...C?{gateReads:C}:{}},O.get(E.objectApiName))}catch(U){let he=U instanceof Error?U.message:String(U);throw await le({...x,errors:[...x.errors,he]}),Dt(),new ae(he,et(se(e.id,r,s,t,"failure")),U)}await le(x),tt&&(nt++,this.deps.onGrappeEvent?.({type:"grappe:partitionProgress",payload:{grappeId:`sync-partition-${nt}`,percentage:100,processedRecords:x.processed}}));continue}let z=new ct,{plan:Y,mark:pe}=await this.readPlan(e,E,y),Oe={changedSince:Y?.read==="delta"?Pe(Y.since):void 0,rows:0,cut:!1},Ae=(x,U)=>Y?{...x,delta:je(Y,Oe.rows,U)}:x,rt=w?.objects.get(E.objectApiName),xt=rt?new Map:void 0,Lt;try{Lt=await this.syncObject(e,E,z,{links:W,...S.linked?{earlierLinked:S.linked}:{},recordTypes:M,currencies:k,currencyChangesById:P,standardPricebooks:A,...v?{contactPoints:v}:{},later:p,...j?{recordTypesUnderTheLease:j}:{},createdWithoutRecordType:N,...C?{gateReads:C}:{}},Y?Oe:void 0,xt,V||$?(x,U)=>{T(E,x),ne(E,x,U)}:void 0,O.get(E.objectApiName),(p.get(E.objectApiName)?.size??0)>0?x=>{let U=Re.get(E.objectApiName);U?U.pending.push(...x):Re.set(E.objectApiName,{objectConfig:E,pending:x})}:void 0)}catch(x){if(x instanceof Q){let U=Ie(He(E.objectApiName,E.operation,x.written,x.notes,x.lookupsLeftOut,x.writtenWithoutFields),z);return(U.processed>0||U.skipped>0)&&await le(Ae(U)),ke(a.slice(I))}throw await le(Ae(Ie({...Ft(E),failed:1,errors:[x instanceof Error?x.message:String(x)]},z))),Dt(),new ae(x instanceof Error?x.message:String(x),et(se(e.id,r,s,t,"failure")),x)}if(Lt===Po){let x=Ie(Ft(E),z);return x.skipped>0&&await le(Ae(x)),ke(a.slice(I))}let J=Lt,jn=!0;if(rt&&xt&&e.files){if(await this.deps.pauseGate?.whilePaused(this.deps.signal),this.deps.signal?.aborted)return await le(Ae(J)),ke(a.slice(I+1),Lo(E));let x=await po({config:e,option:e.files,objectApiName:E.objectApiName,planned:rt,written:xt,deps:this.deps.files,signal:this.deps.signal,waitIfPaused:()=>this.deps.pauseGate?.whilePaused(this.deps.signal)??Promise.resolve(),onCreated:_});if(J={...J,files:x.outcome,errors:[...J.errors,...x.notes]},jn=x.outcome.failed===0&&x.outcome.pastRunCap===0&&x.unplanned===0,x.cancelled)return await le(Ae(J)),ke(a.slice(I+1),Lo(E))}let Ce;if(Y?.read==="delta"&&e.propagateDeletes===!0&&Oe.changedSince){if(await this.deps.pauseGate?.whilePaused(this.deps.signal),this.deps.signal?.aborted)return await le(Ae(J)),ke(a.slice(I));try{Ce=await this.carryDeletions(E,Oe.changedSince,x=>Se(E.objectApiName,x))}catch(x){if(!(x instanceof Q))throw x;let U=He(E.objectApiName,"delete",x.written);return await le(Ae({...J,errors:[...J.errors,...U.errors,...x.notes]},{deleted:U.success,deleteFailed:U.failed,notes:[],complete:!1})),ke(a.slice(I))}J={...J,errors:[...J.errors,...Ce.notes]}}let vn=Oe.lookupsUnset??0,gi=J.failed===0&&jn&&!Oe.cut&&vn===0&&(Ce===void 0||Ce.deleteFailed===0&&Ce.error===void 0&&Ce.complete),Nn=(x,U,he)=>{let xn=rt?.filesSeen;try{return this.deps.deltaStore?.record(e.id,{sourceOrgId:e.sourceOrgId,targetOrgId:e.targetOrgId,objectApiName:E.objectApiName,watermark:x,fingerprint:U,recordedAt:new Date().toISOString(),...xn!==void 0?{filesSeen:xn}:{}}),x}catch($t){he(`The watermark could not be saved, so the next run reads from the previous one: ${$t instanceof Error?$t.message:String($t)}`);return}},Dn;if(Y&&pe!==null&&gi){let{fingerprint:x}=Y,U=E.objectApiName;Re.has(U)?Qe.set(U,()=>Nn(pe,x,he=>ui(U,he))):Dn=Nn(pe,x,he=>{J={...J,errors:[...J.errors,he]}})}Y&&(J={...J,delta:je(Y,Oe.rows,Ce,Dn,vn)}),await le(J),li.has(E.objectApiName)&&await pi(),tt&&(nt++,this.deps.onGrappeEvent?.({type:"grappe:partitionProgress",payload:{grappeId:`sync-partition-${nt}`,percentage:100,processedRecords:J.processed}}))}await L();let fi=$o(s);return Mn(),await V?.flush(),await K,et(se(e.id,r,s,t,fi))}async recordTypesReadAgain(e){let t=this.deps.describeTargetFieldsAgain,r=new Map;return t&&await Promise.all(e.map(async s=>{try{r.set(s,(await t(s)).recordTypes??[])}catch{}})),r}async readBackRecordTypes(e){let t=this.deps.queryTargetRows,r=new Map;return await Promise.all([...e].map(async([s,{given:o,types:i,ids:a}])=>{if(!t||a.length===0){r.set(s,o);return}try{let d=await t(Cs(s,a));r.set(s,{...o,readBack:Ps(d,i)})}catch(d){let c=d instanceof Error?d.message:String(d);r.set(s,{...o,readBack:{read:0,types:[],unread:c}})}})),r}async earlierLinks(e){let t=this.deps.idMap;if(!t)return{};try{let r={sourceOrgId:e.sourceOrgId,targetOrgId:e.targetOrgId},s=await t.load(e.id,r);if(!s)return{};let o=await t.linked?.(e.id,r);return{links:s,...o!==void 0&&o.size>0?{linked:o}:{}}}catch(r){return{unread:r instanceof Error?r.message:String(r)}}}recordTypesOnce(){let e;return()=>{let t=this.deps.recordTypes;return t?(e??=t().catch(r=>{throw new Error(`The record types of the two orgs could not be read, so none of these records was sent: ${r instanceof Error?r.message:String(r)}`)}),e):Promise.resolve(void 0)}}currenciesOnce(){let e;return()=>{let t=this.deps.currencies;return t?(e??=t().catch(()=>{}),e):Promise.resolve(void 0)}}standardPricebooksOnce(){let e;return()=>{let t=this.deps.standardPricebooks;return t?(e??=t().catch(()=>{}),e):Promise.resolve(void 0)}}async pricesSettled(e,t,r){let s=e.objectApiName,o=e.operation!=="delete"&&St(s,t.sources)?await r.standardPricebooks?.():void 0;o&&r.links.noteMatched(o.source,o.target);let i=o&&s===Fe&&t.sources.some(yn)?await r.currencies():void 0;return bt(s,t,o,i,a=>r.links.refusedObjectOf(a)!==void 0)}deltaLoadOf(e){if(e.mode==="delta")return!this.deps.deltaStore||!this.deps.deltaReads?null:this.deps.deltaStore.load(e.id)}async readPlan(e,t,r){if(r===void 0)return{plan:null,mark:null};let s=Ge(e,t,r),o=this.deps.deltaReads;if(!o||s.read==="full"&&s.reason==="not_saved")return{plan:s,mark:null};try{return{plan:s,mark:await o.latestModstamp(t.objectApiName)}}catch{return{plan:{read:"full",reason:"no_modstamp",fingerprint:s.fingerprint},mark:null}}}async carryDeletions(e,t,r){let s=await this.tallyObjectDeletions(e,t);if("error"in s)return{deleted:0,deleteFailed:0,error:s.error,notes:[s.error],complete:!1};let{tally:o,notes:i}=s;if(o.ids.length===0)return{deleted:0,deleteFailed:0,notes:i,complete:!o.truncated};let a={...e,operation:"delete",fieldMappings:[],transformRules:[],addOnFields:[]},d;try{d=await this.deps.dataSync.write(a,o.ids.map(l=>({Id:l})))}catch(l){throw l instanceof Q&&r(Eo(o.ids,l.written)),l}r(Eo(o.ids,d.outcomes));let c=He(e.objectApiName,"delete",d.outcomes,d.notes);return{deleted:c.success,deleteFailed:c.failed,notes:[...c.errors,...i],complete:!o.truncated}}async tallyObjectDeletions(e,t){let r=this.deps.deltaReads;if(!r)return{error:"Deletions need the source's recycle bin, and none was given."};let s=Jt(e);if("refused"in s)return{error:s.refused};let o=lt(e.where,t)??"";try{let i=await Sr(r,e,s,o,a=>{if(s.sourceField==="Id")return a.Id;let d=this.deps.fieldMapping.apply(a,e.fieldMappings,e.excludedFields);return this.deps.transformPipeline.transformRecord(d,e)[s.keyField]});return{tally:i,notes:br(i,s.keyField)}}catch(i){if(this.deps.signal?.aborted)throw new Q(e.objectApiName,[]);return{error:`The source's deletions could not be read, so none was carried; the next run looks for them again: ${i instanceof Error?i.message:String(i)}`}}}async countRun(e,t,r,s){let o=this.deps.countSource;if(!s&&!this.deps.grappeConfig?.enabled||!o)return{none:!0};let i=new Map;try{for(let a of t){let d=r===void 0?null:Ge(e,a,r),c=d?.read==="delta"?{changedSince:Pe(d.since)}:void 0,l=c?await o(e.sourceOrgId,a,c):await o(e.sourceOrgId,a);if(!Number.isFinite(l)||l<0)throw new Error(`the source answered no count of ${a.objectApiName}`);let u=s&&l>0&&this.deps.countPersonAccounts&&Sa.has(a.objectApiName.toLowerCase())?await this.deps.countPersonAccounts(a,c):void 0;i.set(a.objectApiName,{rows:l,...u!==void 0&&u>0?{personAccounts:u}:{}})}}catch(a){return{unread:a instanceof Error?a.message:String(a)}}return{counted:i}}async alreadyCopiedOf(e,t,r){let s=new Map,o=this.deps.readSourceIds,i=this.deps.findInTarget;if(!r||r.size===0||!o||!i)return s;for(let a of t){if(a.operation!=="insert")continue;if(this.deps.signal?.aborted)break;let d=new Map;for(let f of await o(a)){let p=r.get(re(f));p!==void 0&&d.set(re(f),p)}if(d.size===0)continue;let c=await i(e.targetOrgId,a,"Id",[...new Set(d.values())]),l=new Set([...c.keys()].map(f=>f.slice(0,15))),u=new Set;for(let[f,p]of d)l.has(p.slice(0,15).toLowerCase())&&u.add(f);u.size>0&&s.set(a.objectApiName,u)}return s}async writeOrderOf(e){let t=this.deps.describeTargetFields,r=new Map,s=new Set,o=new Map;if(!t)return{ordered:[...e].sort((d,c)=>d.insertOrder-c.insertOrder),refused:r,typed:s,lookups:new Map,keys:o};let i=new Map,a=[];for(let d of e){if(d.operation==="delete"){a.push(d);continue}let c=await Zs(t,d.objectApiName,d.operation,d.externalIdField);"refused"in c&&r.set(d.objectApiName,c.refused);let l="target"in c&&c.target?Xs(Vs(d,c.target),c.target):d;a.push(l),!("refused"in c)&&(l.operation==="update"||l.operation==="upsert"||l.objectApiName===X)&&o.set(d.objectApiName,Ks(l.operation==="upsert"?l.externalIdField??"Id":"Id","target"in c?c.target:void 0)),"target"in c&&c.target&&(i.set(d.objectApiName,Oo(l,c.target)),ce(d.operation)&&(c.target.recordTypes??[]).some(u=>!u.master)&&s.add(d.objectApiName))}return{...Ao(a,i),refused:r,typed:s,lookups:i,keys:o}}async heldBackOfRun(e,t,r,s,o,i,a,d,c,l){let u=new Map,f=t.some(m=>ce(m.operation)&&(m.objectApiName===ge||m.objectApiName===Fe));return r.size===0&&!f?{heldBack:new Map,matched:u}:{heldBack:await Co({ordered:t,lookups:s,leftOut:new Set(r.keys()),...i?{earlier:i}:{},copied:a,standardPricebooks:d,currencies:c,matched:u,read:async m=>{let y=o===void 0?null:Ge(e,m,o);if(y?.read==="delta")return this.deps.querySource(e.sourceOrgId,m,{changedSince:Pe(y.since)});let h=await this.deps.querySource(e.sourceOrgId,m);return l?.set(m.objectApiName,h),h}}),matched:u}}async rolesLinkedAtTheGate(e,t,r,s,o,i,a){let d=h=>t.find(w=>w.objectApiName===h),c=d(Ee),l=d(X);if(!c||!l||!ce(l.operation))return;if(!this.deps.queryTargetRows||c.excludedFields.includes(ie))return 0;if(!a||c.operation!=="insert")return;let u=h=>h.fieldMappings.length===0&&h.addOnFields.length===0&&h.transformRules.length===0;if(!u(c)||!u(l)||[Ee,X,zt].some(h=>r.has(h)||s.has(h)))return;let p=await this.deps.describeTargetFields?.(Ee).catch(()=>{});if(!p)return;if(!p.creatable.has(ie))return 0;let m=async h=>{let w=a.get(h.objectApiName);if(w)return w;let S=await this.deps.querySource(e.sourceOrgId,h);return a.set(h.objectApiName,S),S},y=h=>typeof h.Id=="string"&&h.Id!==""?h.Id:void 0;try{let h=new Set([...i?.keys()??[]].map(re)),w=d(zt);if(w&&ce(w.operation)&&t.indexOf(w)<t.indexOf(c))for(let g of await m(w)){let b=y(g);b&&h.add(re(b))}let S=g=>o.get(g)??new Set,R=new Map;for(let g of await m(c)){let b=y(g),A=g[ie];!b||typeof A!="string"||A===""||S(Ee).has(re(b))||!h.has(re(A))||R.set(re(b),A)}if(R.size===0)return 0;let O=(await m(l)).filter(g=>{let b=y(g);return b!==void 0&&!S(X).has(re(b))});return qt(O,g=>R.get(re(g))).length}catch{return}}isGrappeActive(e){let t=this.deps.grappeConfig;return!!(t?.enabled&&e!==void 0&&e>=t.autoActivateThreshold)}async simulate(e){let t=No(e);if(t!==void 0)throw new Error(t);let r=Do(e);if(r!==void 0)throw new Error(r);let s=Date.now(),o=[],{ordered:i,order:a,refused:d,typed:c,lookups:l,keys:u}=await this.writeOrderOf(e.objects),f,p,m,y=await this.validationRulesOf(i),h=(j={})=>({configId:e.id,operationId:`sync-simulation-${s}`,direction:e.direction,conflictStrategy:e.conflictStrategy,objects:o,duration:Date.now()-s,timestamp:new Date().toISOString(),...f?{files:f.storage}:{},...y.unread!==void 0?{validationRulesUnread:y.unread}:{},...a?{writeOrder:a}:{},...p?{writeCheck:p}:{},...m!==void 0?{writeCheckUnread:m}:{},...j}),w=this.deltaLoadOf(e);try{f=await this.planFiles(e,i,w)}catch(j){return this.deps.signal?.aborted?h({cancelled:!0}):h({error:j instanceof Error?j.message:String(j)})}let S=await this.earlierLinks(e),R=i.filter(j=>j.operation==="insert");if(S.unread!==void 0&&R.length>0)return h({error:Fo(S.unread,R)});let O;try{O=await this.alreadyCopiedOf(e,i,S.links)}catch(j){return this.deps.signal?.aborted?h({cancelled:!0}):h({error:j instanceof Error?j.message:String(j)})}let g=this.deps.writeGate,b=this.standardPricebooksOnce(),A=this.currenciesOnce(),k=w===void 0?new Map:void 0,C=g?await this.countRun(e,i,w,!0):void 0;if(g&&C&&"unread"in C&&(m=`${C.unread}${pn(C.unread)}`),g&&C&&"counted"in C)try{let j=await this.heldBackOfRun(e,i,d,l,w,S.links,O,b,A,k);p=await g.measure(Mo(i,C.counted,O,d,this.deps.queryTargetRows?c:new Set,j.heldBack,j.matched,S.linked,await this.rolesLinkedAtTheGate(e,i,d,j.heldBack,O,S.links,k),{keys:u,typed:c,lookups:l,later:mn(a)}))}catch(j){m=j instanceof Error?j.message:String(j)}let F={links:new Ke(S.links),...S.linked?{earlierLinked:S.linked}:{},recordTypes:this.recordTypesOnce(),currencies:A,currencyChangesById:new Map,standardPricebooks:b,later:mn(a),...k?{gateReads:k}:{}};for(let[j,N]of i.entries()){if(this.deps.signal?.aborted)return h({cancelled:!0});this.deps.onSimulationProgress?.(j,i.length,N.objectApiName);try{let L=await this.simulateObject(e,N,w,F,O.get(N.objectApiName),d.get(N.objectApiName)),W=f?.objects.get(N.objectApiName),M=y.byObject.get(N.objectApiName)??[],{rules:P,onChange:v}=aa(N.operation,M,await this.unreachableFieldsOf(e,N,M)),$=[...L.notes,...W?.notes??[],...v.length>0?[da(v)]:[]];o.push({...L,...W?{files:W.outcome}:{},notes:$,...P.length>0?{validationRules:P}:{}})}catch(L){return this.deps.signal?.aborted?h({cancelled:!0}):h({error:L instanceof Error?L.message:String(L),failedObject:N.objectApiName})}}if(p){let j=new Set([...p.objects.map(G=>G.objectApiName),...(p.rolesLinked??0)>0?[X]:[]]),N=o.filter(G=>j.has(G.objectApiName)).reduce((G,ne)=>G+(ne.operation==="delete"?ne.delete:ne.insert+ne.update),0),L={...p};delete L.rolesByThePlatform,delete L.rolesLinked;let W=o.filter(G=>j.has(G.objectApiName)).reduce((G,ne)=>G+(ne.writtenByThePlatform??0),0),M=(p.rolesLinked??0)-W,P=p.total+M,v=P-N,$={objectApiName:X,rows:0},H=L.objects.some(G=>G.objectApiName===X)?L.objects:[...L.objects,$],K=P>0&&N===0;p={...L,objects:H.map(G=>G.objectApiName===X?{...G,rows:Math.max(0,G.rows+M)}:G).filter(G=>G.rows>0),total:P,...W>0?{rolesLinked:W}:{},...v>0?{notWritten:v}:{},...K?{total:0}:{},...K&&L.verdict==="writes"?{verdict:"nothing"}:{}}}return h()}async unreachableFieldsOf(e,t,r){let s=this.deps.describeTargetFields;if(e.keepContactPoints===!0||!s)return[];if(!r.some(a=>a.reads&&a.reads.length>0))return[];let o=await s(t.objectApiName).catch(()=>{});if(!o?.fields)return[];let i=t.externalIdField;return As(i?o.fields.filter(a=>a.name!==i):o.fields).map(({name:a,kind:d})=>({name:a,kind:d}))}async validationRulesOf(e){let t=this.deps.readValidationRules,r=e.filter(o=>o.operation!=="delete").map(o=>o.objectApiName),s=new Map;if(!t||r.length===0)return{byObject:s};try{for(let{objectApiName:o,...i}of await t(r))s.set(o,[...s.get(o)??[],i]);return{byObject:s}}catch(o){return{byObject:s,unread:o instanceof Error?o.message:String(o)}}}async simulateObject(e,t,r,s,o,i){let a=this.deps.findInTarget;if(!a)throw new Error("A simulation needs to look records up in the target org.");let d=new ct,{plan:c}=await this.readPlan(e,t,r),l={changedSince:c?.read==="delta"?Pe(c.since):void 0,rows:0,cut:!1},u=await this.prepare(e,t,d,c?l:void 0,o,s.gateReads,s.earlierLinked),f=u.records.length>0?await this.pricesSettled(t,u,s):void 0,p=f?{...u,...f}:u;if(i&&p.records.length>0){jo(s.links,t,p.sources);let T=f?Tt(s.links,t,f.standsFor):[];return To({objectApiName:t.objectApiName,operation:t.operation,read:p.read,insert:0,update:0,delete:0,skipped:p.alreadyCopied,...wn(p),refused:p.records.length+T.length,conflicts:0,conflictFields:[],notes:[i.message]},p)}let m=fa(t,p,s.links),y=m.prepared,h=null;if(y.records.length>0&&this.deps.describeTargetFields)try{let T=await this.deps.describeTargetFields(t.objectApiName);h=T.creatable.size>0?T:null}catch{h=null}let w=await Io(s,y.records,y.sources,t.objectApiName),S=Js({config:{...t,fieldMappings:[],addOnFields:[]},records:y.records,target:h,run:w}),R=S.sentAt.map(T=>y.records[T]),O=ar(t),g=new Map;if(O!==null){let T=new Map;for(let _ of R){let Z=_[O],me=Me(Z);me!==null&&T.set(me,Z)}T.size>0&&(g=await a(e.targetOrgId,t,O,[...T.values()]))}let b=R.map(T=>cr(t,T,g)),A=t.operation==="upsert"&&O!==null&&O.toLowerCase()!=="id"?ur(O,R.map(T=>Me(T[O])),b,lr(R.length,t.batchSize,this.deps.bulkThreshold??fe.REST_API_BATCH_SIZE)):void 0;for(let T of A?.updated??[])b[T]="update";let k=b.flatMap((T,_)=>(T==="insert"||T==="update")&&A?.refused.has(_)!==!0?[_]:[]),C=h?.fields!==void 0&&k.length>0?fr(t.objectApiName,k.map(T=>({payload:S.payloads[T],source:y.sources[S.sentAt[T]]??{},creates:b[T]==="insert"})),h.fields):{refused:new Set,notes:[],refusedFor:[]},F=new Set([...[...C.refused].map(T=>k[T]),...A?.refused??[]]),j=await this.lookupsTheTargetLacks(k.filter(T=>!F.has(T)),S.payloads,S.settled,h),N=ma(j,b,h);for(let T of N.refused)F.add(T);let L=k.filter(T=>b[T]==="insert"&&!F.has(T)),W=t.operation==="insert"?(h?.fields??[]).filter(T=>T.unique===!0&&T.createable):[],M=new Map;for(let T of W){let _=new Map;for(let Z of L){let me=S.payloads[Z][T.name],Be=Me(me);Be!==null&&_.set(Be,me)}_.size!==0&&M.set(T.name,await a(e.targetOrgId,t,T.name,[..._.values()]))}let P=gr(L.map(T=>S.payloads[T]),M);for(let T of P.refused)F.add(L[T]);let v=new Set([...P.linked].map(T=>L[T])),$=R.flatMap((T,_)=>F.has(_)||v.has(_)?[]:[_]),H=new Set($.map(T=>S.sentAt[T])),K=y.unsettled.filter((T,_)=>H.has(_)),G=pr({objectConfig:t,read:y.read,records:$.map(T=>R[T]),leftOut:d.counts(t.objectApiName),inTarget:g,simulated:$.map(T=>b[T]),conflicts:y.conflicts,unsettled:K,matchField:y.matchField,writable:h?.creatable??null}),ne=t.operation==="insert"||t.operation==="upsert",Te=T=>{let _=y.sources[T]?.Id;return typeof _=="string"&&_!==""?_:void 0},Se=[];if(t.operation!=="delete"){for(let{index:T}of S.held){let _=Te(T);_&&ne&&s.links.noteRefused(_,t.objectApiName)}if(S.sentAt.forEach((T,_)=>{let Z=Te(T);Z&&(F.has(_)||dr.has(b[_])?ne&&s.links.noteRefused(Z,t.objectApiName):s.links.noteWritten(Z,Z))}),t.objectApiName===Ee&&ne)for(let T of $){let _=Te(S.sentAt[T]),Z=S.payloads[T]?.[ie];b[T]!=="insert"||!_||typeof Z!="string"||Z===""||s.links.noteSentWithContact(_,Z)}f&&(Se=Tt(s.links,t,f.standsFor))}let V=Hs(t.objectApiName,$.flatMap(T=>{let _=b[T]==="insert"?S.withoutRecordType.get(S.sentAt[T]):void 0;return _?[_]:[]}),Ys(h?.recordTypes??[],w.recordTypes)),be=[...A?.refusedFor??[],...C.refusedFor,...P.refusedFor],oe={...G,skipped:G.skipped+v.size+y.alreadyCopied+m.linked,...wn(y),...m.linked>0?{writtenByThePlatform:m.linked}:{},...y.encryptedLeftOut?{encryptedLeftOut:[...y.encryptedLeftOut]}:{},...V?{recordTypeGiven:V}:{},refused:G.refused+S.held.length+F.size+Se.length,...be.length>0?{refusedFor:be}:{},notes:[...f?.standardMatched?[ro]:[],...Is(f?sn(f,Se):[]).map(T=>`${T}.`),...m.linked>0?[ha(m.linked)]:[],...G.notes,...A?.notes??[],...S.notes,...Se.length>0?[on(t.objectApiName,Se.length)]:[],...S.currencies.map(T=>`${ir(T)}.`),...C.notes,...N.notes,...P.notes]};if(!c)return oe;if(c.read==="delta"&&e.propagateDeletes===!0&&l.changedSince){let T=await this.tallyObjectDeletions(t,l.changedSince);if("error"in T)return{...oe,notes:[...oe.notes,T.error],delta:je(c,l.rows,{deleted:0,deleteFailed:0,error:T.error})};let _=T.tally.ids.length;return{...oe,delete:oe.delete+_,notes:[...oe.notes,...T.notes],delta:je(c,l.rows,{deleted:_,deleteFailed:0})}}return{...oe,delta:je(c,l.rows)}}async lookupsTheTargetLacks(e,t,r,s){let o=this.deps.queryTargetRows,i=new Map;if(!o||!s?.fields||s.references.size===0)return i;let a=new Map,d=new Map;for(let u of e){let f=t[u]??{},p=[];for(let[m,y]of Object.entries(f)){if(m==="RecordTypeId"||!s.references.has(m)||r[u]?.has(m)||typeof y!="string"||!ga.test(y))continue;p.push({field:m,id:y});let h=s.fields.find(w=>w.name===m)?.referenceTo??[];for(let w of h)d.set(w,(d.get(w)??new Set).add(y))}p.length>0&&a.set(u,p)}if(a.size===0)return i;let c=new Set,l=new Set;for(let[u,f]of d){let p=[...f];for(let[m,y]of ee(p,hn).entries())try{let h=await o(`SELECT Id FROM ${ye(u)} WHERE Id IN (${y})`);for(let w of h){let S=w.Id;typeof S=="string"&&c.add(S.slice(0,15))}}catch{let h=m*hn;for(let w of p.slice(h,h+hn))l.add(w.slice(0,15))}}for(let[u,f]of a)f.some(({id:m})=>!c.has(m.slice(0,15))&&!l.has(m.slice(0,15)))&&i.set(u,f.map(({field:m})=>m).sort());return i}async noteLeftOutRefused(e,t,r,s,o){if(!ce(t.operation))return;let{plan:i}=await this.readPlan(e,t,r),a={changedSince:i?.read==="delta"?Pe(i.since):void 0,rows:0,cut:!1},d=await this.prepare(e,t,new ct,i?a:void 0,o,s.gateReads,s.earlierLinked);if(d.records.length===0)return;let c=await this.pricesSettled(t,d,s);jo(s.links,t,c.sources),Tt(s.links,t,c.standsFor)}async syncObject(e,t,r,s,o,i,a,d,c){let l=await this.prepare(e,t,r,o,d,s.gateReads,s.earlierLinked),u=await this.rolesWrittenWithTheirOpportunity(t,l,s,a),f=u.prepared,p=b=>pa(To(ya(b,f),f),u.said);if(f.records.length===0)return p(Ie(Ft(t),r));let m=await this.pricesSettled(t,f,s),{records:y,sourceIds:h,sources:w}=m;if(y.length===0)return p(Ie(an(Ft(t),m),r));let S={...await Io(s,y,w,t.objectApiName),...m.standardFirst>0?{standardFirst:m.standardFirst}:{}},R=()=>Tt(s.links,t,m.standsFor);if(await this.deps.pauseGate?.whilePaused(this.deps.signal),this.deps.signal?.aborted)return Po;if(i||a||c||o){let b=A=>{A.forEach((k,C)=>{let F=h[C];i&&k.success&&k.id&&F&&i.set(F,k.id)}),a?.(A,h)};try{let{outcomes:A,notes:k,currencies:C,lookupsLeftOut:F,writtenWithoutFields:j,lookupsToSet:N,lookupsUnset:L}=await this.deps.dataSync.write({...t,fieldMappings:[],addOnFields:[]},y,S);o&&L!==void 0&&(o.lookupsUnset=L),b(A);let W=R();return N&&c?.(N),p(Ie(vo(no(He(t.objectApiName,t.operation,A,k,F,j),C),m,W),r))}catch(A){throw A instanceof Q&&b(A.written),A}}let O=await this.deps.dataSync.sync({...t,fieldMappings:[],addOnFields:[]},y,S),g=R();return p(Ie(vo(O,m,g),r))}async rolesWrittenWithTheirOpportunity(e,t,r,s){let o=this.deps.queryTargetRows;if(e.objectApiName!==X||e.operation!=="insert"&&e.operation!=="upsert"||!o||!r.links.sentWithAContact||t.records.length===0)return{prepared:t};let i=g=>typeof g=="string"&&g!==""?r.links.targetOf(g):void 0,a=t.records.map((g,b)=>({OpportunityId:i(g.OpportunityId),[ie]:i(g[ie]),IsPrimary:t.sources[b]?.IsPrimary??g.IsPrimary})),d=await this.deps.describeTargetFields?.(X).catch(()=>{}),c=g=>g!=="Id"&&g!=="OpportunityId"&&g!==ie&&(d?.creatable.has(g)??!0),l=[...new Set(t.records.flatMap(g=>Object.keys(g)))].filter(c),u;try{u=await tr(async g=>await o(g),a,g=>r.links.contactSentWith(g),l)}catch(g){return{prepared:t,said:{records:0,given:0,unread:g instanceof Error?g.message:String(g)}}}let{found:f,alike:p}=u;for(let g of p)r.links.roleLinkedFor(String(a[g].OpportunityId));let m=p.length>0?{alike:p.length}:{};if(f.size===0)return p.length>0?{prepared:t,said:{records:0,given:0,...m}}:{prepared:t};let y=[];for(let[g,b]of f){let A=Object.entries(t.records[g]??{}).filter(([k,C])=>c(k)&&C!==null&&C!==void 0&&String(b[k]??"")!==String(C));A.length>0&&y.push({Id:String(b.Id),...Object.fromEntries(A)})}let h=0,w;if(y.length>0)try{let g=await this.deps.dataSync.updateRecords(X,y,e.batchSize);y.forEach((b,A)=>{let k=g[A];k?.success?h++:w??=`${String(b.Id)}: ${k?.errors[0]??"not updated"}`})}catch(g){w=g instanceof Error?g.message:String(g)}let S=[],R=[];for(let[g,b]of f){let A=t.sourceIds[g],k=String(b.Id);r.links.roleLinkedFor(String(a[g].OpportunityId)),A!==void 0&&(r.links.noteWritten(A,k),S.push(A),R.push({success:!1,errors:[],existingId:k}))}s?.(R,S);let O=(g,b)=>!f.has(b);return{prepared:{...t,records:t.records.filter(O),sourceIds:t.sourceIds.filter(O),sources:t.sources.filter(O)},said:{records:f.size,given:h,...w!==void 0?{refusal:w}:{},...m}}}async prepare(e,t,r,s,o,i,a){let d=s?void 0:i?.get(t.objectApiName);d&&i?.delete(t.objectApiName);let c=s?await this.deps.querySource(e.sourceOrgId,t,{changedSince:s.changedSince,onBoundReached:()=>{s.cut=!0}}):d??await this.deps.querySource(e.sourceOrgId,t);s&&(s.rows=c.length);let l=t.externalIdField??"Id",u=this.deps.maskedSourceFields,p=(c.length>0&&u?await u(t.objectApiName).catch(()=>[]):[]).filter(C=>c.some(F=>Object.prototype.hasOwnProperty.call(F,C)));for(let C of c)for(let F of p)delete C[F];let m=p.length>0?{encryptedLeftOut:p}:{},y=t.operation==="insert"||t.operation==="upsert",h=y?r.keep(t.objectApiName,c):c,w=o&&o.size>0&&t.operation==="insert"?h.filter(C=>!(typeof C.Id=="string"&&o.has(re(C.Id)))):h,S=h.length-w.length,R=S>0&&a&&a.size>0?h.filter(C=>typeof C.Id=="string"&&o?.has(re(C.Id))===!0&&a.has(re(C.Id))).length:0;if(w.length===0)return{read:c.length,records:[],sourceIds:[],sources:[],conflicts:[],unsettled:[],matchField:l,alreadyCopied:S,alreadyLinked:R,...m};let g=w.map(C=>{let F=this.deps.fieldMapping.apply(C,t.fieldMappings,t.excludedFields);return this.deps.transformPipeline.transformRecord(F,t)}).map(C=>{let F=this.deps.fieldMapping.applyAddOns(C,t.addOnFields);return y?Aa(t.objectApiName,F):F}),b=g,A=[],k=t.operation==="upsert"||t.operation==="update";if(e.direction==="bidirectional"&&k){let C=await this.deps.queryTarget(e.targetOrgId,t);for(let F of C)for(let j of p)delete F[j];if(A=this.deps.conflictResolver.detectConflicts(g,C,l),A.length>0){let F=this.deps.conflictResolver.resolve(A,e.conflictStrategy),j=new Map(F.map(N=>[N.recordId,N.resolvedValues]));b=g.map(N=>{let L=String(N[l]??""),W=j.get(L);return W?{...N,...W}:N})}}return{read:c.length,records:b,sourceIds:w.map(C=>typeof C.Id=="string"?C.Id:void 0),sources:w,conflicts:A,unsettled:g,matchField:l,alreadyCopied:S,alreadyLinked:R,...m}}async planFiles(e,t,r){let s=e.files;if(!s)return;let o=this.deps.files;if(!o)throw new ue("This session cannot copy files: it reads no file content or file storage. Nothing was read or written.");return uo({config:e,option:s,deps:o,tie:(i,a)=>this.tieToTarget(e,i,a),objects:t.map(i=>{let a=r===void 0?null:Ge(e,i,r);return{objectConfig:i,...a?.read==="delta"?{changedSince:Pe(a.since),...a.filesSeen!==void 0?{filesSeen:a.filesSeen}:{}}:{}}})})}async tieToTarget(e,t,r){let s=this.deps.deltaReads,o=this.deps.files;if(!s||!o)return{held:new Map,refused:"the target cannot be asked"};let i=Jt(t);if("refused"in i)return{held:new Map,refused:i.refused};let a=t.objectApiName,d=new Map;if(i.sourceField==="Id")for(let u of r)d.set(u,u);else{let u=at(a),f=ye(i.sourceField);for(let p of ee(r)){let m=await o.copy.queryRecords(e.sourceOrgId,`SELECT Id, ${f} FROM ${u} WHERE Id IN (${p})`);for(let y of m){let h=this.deps.fieldMapping.apply(y,t.fieldMappings,t.excludedFields),w=this.deps.transformPipeline.transformRecord(h,t)[i.keyField];typeof y.Id=="string"&&Me(w)!==null&&d.set(y.Id,w)}}}if(d.size===0)return{held:new Map};let c=await s.targetIdsByKey(a,i.keyField,[...new Set(d.values())]),l=new Map;for(let[u,f]of d){let p=c.get(Me(f))??[];p.length===1&&l.set(u,p[0])}return{held:l}}};function Oa(n,e,t){let r=[],s=[];return n!=="insert"&&n!=="upsert"?{written:r,linked:s}:(e.forEach((o,i)=>{let a=t[i];if(a===void 0)return;if(o.success&&typeof o.id=="string"&&o.id!==""){r.push([a,o.id]);return}let d=to(n,o);d!==void 0&&s.push([a,d])}),{written:r,linked:s})}function Aa(n,e){let t=Qn(n,e);if(t.length===0)return e;let r={...e};for(let s of t)delete r[s];return r}function Ie(n,e){let t=e.counts();return t.length===0?n:{...n,skipped:n.skipped+t.reduce((r,{count:s})=>r+s,0),errors:[...n.errors,...t.map(({why:r,count:s})=>Zn(s,r))]}}function Ft(n){return{objectApiName:n.objectApiName,operation:n.operation,processed:0,success:0,failed:0,skipped:0,conflictCount:0,errors:[]}}function Ca(n,e,t,r,s,o){let i=$o(t)==="failure"?"failure":"partial",a=s.map(c=>c.objectApiName),d=a.length>0?`Cancelled before ${a.join(", ")} ${a.length===1?"was":"were"} synced.`:"Cancelled.";return{...se(n,e,t,r,i),cancelled:!0,error:o?`${o} ${a.length>0?d:""}`.trim():d}}function Lo(n){return`Cancelled while the files of ${n.objectApiName} were copied: those copied stay in the target, the others are copied by the next run.`}function $o(n){return n.length===0?"success":n.every(r=>r.failed>0&&r.success===0)?"failure":n.some(r=>r.failed>0||Pa(r.delta)||(r.files?.failed??0)>0)?"partial":"success"}function Pa(n){return n!==void 0&&(n.deleteFailed>0||n.deletionError!==void 0)}function se(n,e,t,r,s){let o=0,i=0,a=0,d=0;for(let c of t)o+=c.processed,i+=c.success,a+=c.failed,d+=c.skipped;return{configId:n,operationId:e,status:s,objectResults:t,totalProcessed:o,totalSuccess:i,totalFailed:a,totalSkipped:d,duration:Date.now()-r,timestamp:new Date().toISOString()}}var Bo=2;async function _o(n,e,t,r,s=()=>!1){let o=t.rows;if(!o||o.length!==e.length||t.stopped)return{result:t,unsent:[]};let i=[...o],a=[...e],d=e.map(()=>[]),c=e.map(()=>new Map),l=e.map(()=>0),u=h=>w=>ts(e[h][w]),f=[],p=!1;for(let h=0;h<Bo+es&&!s();h++){let w=[],S=[],R=[];if(i.forEach((b,A)=>{if(b.id)return;let k=Xr(b.errorDetails,a[A],void 0);if(!k||k.some(({field:F})=>r.has(F)))return;let C=ns(k,a[A],u(A),c[A]);if(Object.keys(C.forms).length===0){if(l[A]>=Bo)return;l[A]++}w.push(A),S.push({...Zr(a[A],C.leftOut),...C.forms}),R.push(C.leftOut)}),w.length===0)break;let O;try{O=await n(S)}catch(b){let A=[...new Set(R.flat().map(({field:k})=>k))].sort();f.push(`${w.length} record(s) refused on ${A.join(", ")} could not be written again without ${A.length===1?"it":"them"}: ${q(b)}`);break}if(Ia(O,S.length).forEach((b,A)=>{let k=w[A];i[k]=b,a[k]=S[A],d[k].push(...R[A])}),O.stopped){p=!0;break}}let m,y=new Map;return i.forEach((h,w)=>{if(h.id){for(let{field:S,kind:R,how:O}of rs(c[w],d[w],u(w))){let g=y.get(S)??{field:S,kind:R,otherForm:0,withoutField:0};g[O]+=1,y.set(S,g)}d[w].length!==0&&(m=ze(m,{rows:1,fields:d[w].map(S=>({...S,rows:1}))}))}}),{result:{successIds:i.flatMap(h=>h.id?[h.id]:[]),errors:i.flatMap(h=>h.id?[]:[h.error??"Unknown insert error"]),rows:i,...p?{stopped:!0}:{}},...m?{written:m}:{},...y.size>0?{forms:[...y.values()]}:{},unsent:f}}function Sn(n,e){if(!e||e.length===0)return n;let t=n??[];for(let r of e){let s=t.find(o=>o.field===r.field);s?(s.otherForm+=r.otherForm,s.withoutField+=r.withoutField):t.push({...r})}return t}function Wo(n){return!n||n.length===0?"":`A validation rule of the target refused the first form of an address or a phone number the seed drew, which reaches no one \u2014 ${n.map(({field:t,kind:r,otherForm:s,withoutField:o})=>`${t}: ${s} written ${r==="email"?"under .test":"in another layout of the same fictional number"}, ${o} without it`).join("; ")}.`}function Ia(n,e){if(n.rows&&(n.rows.length===e||n.stopped))return n.rows.slice(0,e);let t=[...n.successIds.map(s=>({id:s})),...n.errors.map(s=>({error:s}))];return(e===1?t:t.map(s=>({...s,unmatched:!0}))).slice(0,e)}var Ea=1e4,Ta=5e5,On=200;function jt(n){let e=Math.floor(Ta/Math.max(1,n.fieldRules.length));return Math.max(On,Math.min(Ea,e))}var Go=class{deps;constructor(e){this.deps=e}async execute(e,t,r){let s=r??this.deps.generateId(),o=Date.now(),i=this.deps.validator.validate(e);if(!i.valid)return Ho(e.id,s,i.errors.map(l=>l.message),this.deps.now());let a=await oo(e.relations,{...this.deps.describeKeyPrefix?{keyPrefixOf:this.deps.describeKeyPrefix}:{},...this.deps.readPresentParentIds?{presentIds:this.deps.readPresentParentIds}:{}});if(a.length>0)return Ho(e.id,s,a,this.deps.now());let d=e.objects.reduce((l,u)=>l+u.recordCount,0);return this.shouldActivateGrappe(d)?this.executeWithGrappe(e,t,s,o):this.executeSequential(e,t,s,o)}preview(e){return this.deps.planBuilder.build(e)}shouldActivateGrappe(e){let t=this.deps.grappeConfig;return!!(t?.enabled&&this.deps.grappeAdapter&&e>=t.autoActivateThreshold)}reportProgress(e,t,r,s=0){let o=t.reduce((i,a)=>i+a.recordsCreated+a.recordsFailed,s);this.deps.onProgress?.({objectApiName:e,processedRecords:o,totalRecords:r,percentage:Math.round(o/Math.max(r,1)*100)})}async executeSequential(e,t,r,s){let o=Uo(e,this.platformRolesOf(t),this.deps.onRowIds),i=this.deps.referenceLinker.resolveInsertOrder(e.objects,o.relations),a=e.objects.reduce((d,c)=>d+c.recordCount,0);for(let d of i){if(this.deps.signal?.aborted)return this.stoppedResult(e,r,o,s);let c=await this.readyToWrite(d,o,a);if(!c)continue;let l={},u={successIds:[],errors:[]},f={result:u,unsent:[]},p=zo(c),m=0,y=0,h=!1,w=jt(c.config);for await(let S of this.slicesOf(c,o,w,l)){if(this.deps.signal?.aborted){h=!0;break}m>0&&this.reportProgress(d.objectApiName,o.objectResults,a,u.successIds.length+u.errors.length);let R=await this.insert(t,d,S,c,o);if(m++,qo(p,c.config.rows,y,S.length,R.result),y+=S.length,Wa(f,R),R.result.stopped){h=!0;break}}if(m>0&&Mt(o,d,kn(u,c),[...c.notes,...bn(f)],{...l,...Rn(f)},p),h)return this.stoppedResult(e,r,o,s)}return this.ended(e,r,o,s)}async ended(e,t,r,s){let o,i=!1;try{o=await this.deps.knowledge?.({ids:va(r),results:r.objectResults})}catch(l){i=!0,o={skipped:`The articles were neither published nor linked: ${q(l)}`}}let a=Ko(e.id,t,r.objectResults,s,this.deps.now());if(!o)return a;let d=i||[o.publish,o.links].some(l=>(l?.notDone.length??0)>0),c=this.deps.signal?.aborted===!0;return{...a,knowledge:o,...(d||c)&&a.status==="success"?{status:"partial"}:{},...c?{cancelled:!0}:{}}}async readyToWrite(e,t,r){let s=Gt(e.objectApiName,t.relations),o=_n(e,t.relations).filter(h=>t.wroteNothing.has(h));if(o.length>0)return Ze(t,e.objectApiName,`Skipped: ${o.join(", ")} wrote no records, so there is nothing for ${e.objectApiName} to point at.`);let i=await this.closedObject(e.objectApiName);if(i)return Ze(t,e.objectApiName,i,e.optional===!0);this.reportProgress(e.objectApiName,t.objectResults,r);let a=Xo(e,s),{config:d,dropped:c}=await Yo(a,this.deps.describeCreateableFields),l=await this.whyDropped(e.objectApiName,c),u=h=>h.fieldRules.length===0&&An(h.rows).length===0;if(u(d)&&!u(a))return Ze(t,e.objectApiName,`Skipped: none of the fields the template names can be written (${l.join("; ")}).`);let{config:f,filled:p}=await Jo(await this.withTheOrgsPicklistValues(d),s,this.deps.describeRequiredFields),m=await this.matchStandardPricebook(f,t);if(m)return Ze(t,e.objectApiName,m);let y;if(s){let h=await this.placeChildren(f,s,t);if("skipped"in h)return Ze(t,e.objectApiName,h.skipped);if(h.parentIds.length===0&&h.unwritten){let{lines:w,keys:S}=h.unwritten;return Mt(t,e,{successIds:[],errors:w},[],{},S),null}y=h}return{relation:s,config:y?{...f,recordCount:y.parentIds.length,...y.rows?{rows:y.rows}:{}}:f,placed:y,...f.rows?{lengths:await this.fieldLengths(e.objectApiName)}:{},notes:[...l.map(h=>`Written without ${h}.`),...p.length>0?[`Written with ${p.join(", ")}, which this org requires and the template names no rule for.`]:[],...y?.notes??[]]}}async placeChildren(e,t,r){let{childObject:s,lookupField:o,parentObject:i}=t;if(!await this.orgTakesField(s,o))return{skipped:`Skipped: this org does not let a seed write ${s}.${o}, the lookup the relation fills.`};if(t.distribution.mode==="byKey")return ja(e.rows??[],t,r.keys.get(i));let a=r.existingIds,d;if(t.parents.kind==="generated")d=a.get(i)??[];else if(t.parents.kind==="records")d=[...t.parents.ids];else{let f=this.deps.readExistingParentIds;if(!f)return{skipped:`Skipped: this run cannot read the ${i} records already in the org, so ${s} has nothing to point at.`};try{d=await f(i,t.parents.where,t.parents.limit)}catch(p){return{skipped:`Skipped: reading the ${i} records already in the org failed (${q(p)}), so ${s} has nothing to point at.`}}}if(d.length===0){let f=t.parents.kind==="existing"?t.parents.where?.trim():"";return{skipped:`Skipped: ${t.parents.kind==="generated"?`${i} wrote no records`:`no ${i} record in the org matches ${f?`"${f}"`:"the relation"}`}, so there is nothing for ${s} to point at.`}}let c=Bn(t.distribution,d.length,this.deps.random),l=c.reduce((f,p)=>f+p,0),u=[];for(let[f,p]of c.entries())for(let m=0;m<p&&u.length<e.recordCount;m++)u.push(d[f]);return u.length===0?{skipped:`Skipped: the relation gives none of the ${d.length} ${i} records a ${s}.`}:{parentIds:u,notes:l>u.length?[`Stopped at ${u.length} ${s} records, the most the template asks for: the relation spreads ${l} over ${d.length} ${i} records.`]:[]}}async*slicesOf(e,t,r,s){let o=e.config.recordCount,i=Math.max(1,Math.floor(r)),a=0;do{let d=Math.max(0,Math.min(i,o-a)),c=La(e.config,e.relation)?$a(d):await this.deps.fieldMapper.mapFields(d===o?e.config:{...e.config,recordCount:d},t.existingIds,l=>{s.aiFallback=_a(s.aiFallback,l)},a,e.lengths);Ba(c,e.relation,e.placed,a),yield c,a+=d}while(a<o)}async insert(e,t,r,s,o){let i=f=>this.deps.insert(e,t.objectApiName,f,t.batchSize),a=t.objectApiName===X?await o.platformRoles.link(r):new Map,d=a.size>0?r.filter((f,p)=>!a.has(p)):r,c=d.length===0&&r.length>0?{successIds:[],errors:[],rows:[]}:await i(d),l=await _o(i,d,c,Fa(s),()=>this.deps.signal?.aborted===!0);t.objectApiName===io&&o.platformRoles.opportunitiesWritten(d,l.result);let u=a.size>0?Na(l,r.length,a):l;return c.notes&&c.notes.length>0?{...u,notes:c.notes}:u}platformRolesOf(e){return new ao({orgId:e,readTarget:this.deps.readTarget,update:this.deps.update,stopped:()=>this.deps.signal?.aborted===!0})}async closedObject(e){if(!this.deps.objectAccess)return;let t;try{t=await this.deps.objectAccess(e)}catch{return}if(t.access==="createable")return;let r=t.reason?` (${t.reason})`:"";return t.access==="absent"?`Skipped: this org has no ${e} object${r}.`:`Skipped: the user this seed runs as may not create ${e} records${r}`+(t.reason?".":`: give that user Create on ${e} in a permission set.`)}async withTheOrgsPicklistValues(e){if(!this.deps.describePicklistValues||!e.fieldRules.some(o=>o.ruleType==="picklist_random"))return e;let t;try{t=await this.deps.describePicklistValues(e.objectApiName)}catch{return e}let r=!1,s=e.fieldRules.map(o=>{let i=t.get(o.fieldApiName),a=o.config.picklistValues;if(o.ruleType!=="picklist_random"||!i?.length||!a)return o;let d=a.filter(c=>i.includes(c));return d.length===a.length?o:(r=!0,{...o,config:{...o.config,picklistValues:d.length?d:[...i]}})});return r?{...e,fieldRules:s}:e}async matchStandardPricebook(e,t){if(!e.fieldRules.some(i=>it(i,t.written))||t.existingIds.has(ge))return;let r=this.deps.readExistingParentIds,s=`${e.objectApiName} points at the org's standard price book`;if(!r)return`Skipped: ${s}, and this run cannot read it.`;let o;try{o=await r(ge,"IsStandard = true",1)}catch(i){return`Skipped: ${s}, and reading it failed (${q(i)}).`}if(o.length===0)return`Skipped: ${s}, and the org shows this user no standard price book (Pricebook2): give that user Read on Price Books in a permission set.`;t.existingIds.set(ge,o)}async orgTakesField(e,t){if(!this.deps.describeCreateableFields)return!0;try{return(await this.deps.describeCreateableFields(e)).has(t)}catch{return!0}}async whyDropped(e,t){if(t.length===0)return[];let r=new Set;try{this.deps.describeVisibleFields&&(r=await this.deps.describeVisibleFields(e))}catch{}let s;try{this.deps.describeComputedFields&&(s=await this.deps.describeComputedFields(e))}catch{}let o=t.filter(c=>r.has(c)&&s?.has(c)===!0),i=t.filter(c=>r.has(c)&&s?.has(c)!==!0),a=t.filter(c=>!r.has(c)),d=(c,l,u)=>c.length===1?l:u;return[...a.length>0?[`${a.join(", ")}: this org does not have ${d(a,"that field","those fields")}, or field-level security hides ${d(a,"it","them")} from the user SandForge connects as`]:[],...o.length>0?[`${o.join(", ")}: ${d(o,"a formula or auto-number field","formula or auto-number fields")}, which the org fills itself and no user sets: take ${d(o,"its rule","their rules")} out of the template`]:[],...i.length>0?[`${i.join(", ")}: ${d(i,"it exists","they exist")}, but the user SandForge connects as may not set ${d(i,"it","them")}`+(s!==void 0?`: give that user Edit on ${d(i,"it","them")} (field-level security, in a permission set)`:`: give that user Edit on ${d(i,"it","them")} (field-level security, in a permission set), unless it is a formula or auto-number field, whose rule comes out of the template`)]:[]]}async fieldLengths(e){if(!this.deps.describeFieldLengths)return new Map;try{return await this.deps.describeFieldLengths(e)}catch{return new Map}}async executeWithGrappe(e,t,r,s){let i=this.deps.grappeAdapter.partition(e),a=i.reduce((y,h)=>y+h.recordCount,0);this.deps.onGrappeEvent?.({type:"grappe:started",payload:{operationId:r,totalPartitions:i.length,totalRecords:a}});let d=Uo(e,this.platformRolesOf(t),this.deps.onRowIds),c=this.deps.referenceLinker.resolveInsertOrder(e.objects,d.relations),l=[],u=0,f=this.deps.grappeConfig?.grappeSize??2e3,p=()=>{let y=d.objectResults.reduce((w,S)=>w+S.recordsCreated,0),h=d.objectResults.reduce((w,S)=>w+S.recordsFailed,0);this.deps.onGrappeEvent?.({type:"grappe:completed",payload:{operationId:r,totalProcessed:y,totalFailed:h}})},m=()=>(p(),this.stoppedResult(e,r,d,s));for(let y of c){if(this.deps.signal?.aborted)return m();let h=Math.ceil(y.recordCount/f),w=await this.readyToWrite(y,d,a);if(!w){u=this.settleUnusedPartitions(i,u,h,0);continue}let S={},R=Math.max(1,Math.ceil(w.config.recordCount/f)),O=0,g=0,b=[],A=[],k={result:{successIds:[],errors:[]},unsent:[]},C,F=zo(w),j=0,N=-1;for await(let L of this.slicesOf(w,d,f,S)){if(N++,this.deps.signal?.aborted){C=N;break}N>0&&this.reportProgress(y.objectApiName,d.objectResults,a,O+g);let W=Date.now(),M=i[u]?.id??this.deps.generateId(),P=await this.insert(t,y,L,w,d),v=P.result;qo(F,w.config.rows,j,L.length,v),j+=L.length,P.written&&(k.written=ze(k.written,P.written)),k.forms=Sn(k.forms,P.forms),k.unsent.push(...P.unsent);for(let $ of P.notes??[])(k.notes??[]).includes($)||(k.notes=[...k.notes??[],$]);if(O+=v.successIds.length,g+=v.errors.length,b.push(...v.errors),A.push(...v.successIds),l.push({grappeId:M,status:v.errors.length===0?"success":v.successIds.length>0?"partial":"failure",processedRecords:L.length,successCount:v.successIds.length,failureCount:v.errors.length,errors:v.errors,duration:Date.now()-W}),u++,v.stopped){C=N+1;break}this.deps.onGrappeEvent?.({type:"grappe:partitionProgress",payload:{grappeId:M,percentage:100,processedRecords:O+g}})}if(C!==void 0)return C>0&&Mt(d,y,kn({successIds:A,errors:b},w),[...w.notes,...bn(k)],{...S,...Rn(k)},F),m();u=this.settleUnusedPartitions(i,u,h-R,O+g),Mt(d,y,kn({successIds:A,errors:b},w),[...w.notes,...bn(k)],{...S,...Rn(k)},F)}return p(),this.ended(e,r,d,s)}stoppedResult(e,t,r,s){let o=Ko(e.id,t,r.objectResults,s,this.deps.now());return{...o,status:o.status==="success"?"partial":o.status,cancelled:!0}}settleUnusedPartitions(e,t,r,s){let o=t;for(let i=r;i>0;i--){let a=e[o]?.id??this.deps.generateId();o++,this.deps.onGrappeEvent?.({type:"grappe:partitionProgress",payload:{grappeId:a,percentage:100,processedRecords:s}})}return o}};function Uo(n,e,t){return{relations:n.relations??[],written:new Set(n.objects.map(r=>r.objectApiName)),existingIds:new Map,wroteNothing:new Set,keys:new Map,...t?{onRowIds:t}:{},platformRoles:e,objectResults:[]}}function Fa(n){return new Set(["RecordTypeId",...n.relation?[n.relation.lookupField]:[],...n.config.fieldRules.filter(e=>e.ruleType==="reference").map(e=>e.fieldApiName)])}function bn(n){let e=Wo(n.forms);return[...n.notes??[],...n.written?[Qr(n.written)]:[],...e?[e]:[],...n.unsent]}function Rn(n){return n.forms&&n.forms.length>0?{contactPointForms:n.forms}:{}}function Ze(n,e,t,r=!1){let s=Ga(e,t);return n.objectResults.push(r?{...s,optional:!0}:s),n.wroteNothing.add(e),null}function Mt(n,e,t,r,s,o){o&&(n.keys.set(e.objectApiName,o),n.onRowIds?.(e.objectApiName,Ma(o)));let i=n.platformRoles.resultOf(e.objectApiName),a=[...t.successIds,...i.linkedIds];n.existingIds.set(e.objectApiName,a),e.recordCount>0&&a.length===0&&n.wroteNothing.add(e.objectApiName),n.objectResults.push({objectApiName:e.objectApiName,recordsCreated:t.successIds.length,recordsFailed:t.errors.length,createdIds:t.successIds,errors:[...t.errors,...r,...i.notes],...s,...i.writtenByThePlatform?{writtenByThePlatform:i.writtenByThePlatform}:{}})}function Ma(n){let e={};for(let[t,r]of n)"id"in r&&(e[t]=r.id);return e}function ja(n,e,t){let{childObject:r,parentObject:s}=e;if(!t)return{skipped:`Skipped: ${r} is placed by key, and ${s} wrote no rows to place it under.`};let o=[],i=[],a=[],d=new Map;for(let c of n){let l=c.parentKey,u=l===void 0?void 0:t.get(l);if(u&&"id"in u){o.push(u.id),i.push(c);continue}let f=l===void 0?`it names no ${s} row`:`its ${s} ${l} ${u?u.why:`is no ${s} row this run wrote`}`;a.push(`${r} ${c.key} not written: ${f}.`),d.set(c.key,{why:`was not written, as ${f}`})}return{parentIds:o,notes:[],rows:i,unwritten:{lines:a,keys:d}}}function va(n){let e=new Map;for(let[t,r]of n.keys){let s=new Map;for(let[o,i]of r)"id"in i&&s.set(o,i.id);e.set(t,s)}return e}function zo(n){if(n.config.rows)return new Map(n.placed?.unwritten?.keys??[])}function qo(n,e,t,r,s){if(!n||!e)return;let o=s.rows&&(s.rows.length===r||s.stopped)?s.rows:void 0;for(let i=0;i<r;i++){let a=e[t+i];if(!a)continue;let d=o?.[i];o?d?d.id&&d.unmatched?n.set(a.key,{why:"has no id this run can tell: the org did not say which of the ids it answered is its"}):d.id?n.set(a.key,{id:d.id}):n.set(a.key,{why:`was refused (${d.error??"Unknown insert error"})`}):n.set(a.key,{why:"was not sent: the run was stopped before it"}):n.set(a.key,{why:"has no id this run can tell: the insert did not answer record by record"})}}function kn(n,e){let t=e.placed?.unwritten?.lines??[];return t.length===0?n:{...n,errors:[...n.errors,...t]}}function Na(n,e,t){let r=n.result.rows;if(!r)return n;let s=[],o=0;for(let i=0;i<e;i++){let a=t.get(i);if(a){s.push({id:String(a.Id)});continue}let d=r[o++];if(!d)break;s.push(d)}return{...n,result:{...n.result,rows:s}}}function An(n){return[...new Set((n??[]).flatMap(e=>Object.keys(e.values)))]}function Da(n){return!n||n.length===0?[]:An(n).filter(e=>n.every(t=>e in t.values))}function xa(n,e){return e.size===0?[...n]:n.map(t=>({...t,values:Object.fromEntries(Object.entries(t.values).filter(([r])=>!e.has(r)))}))}async function Yo(n,e){if(!e)return{config:n,dropped:[]};let t;try{t=await e(n.objectApiName)}catch{return{config:n,dropped:[]}}let r=n.fieldRules.filter(a=>a.ruleType==="reference"||t.has(a.fieldApiName)),s=An(n.rows).filter(a=>!t.has(a));if(r.length===n.fieldRules.length&&s.length===0)return{config:n,dropped:[]};let o=[...new Set([...n.fieldRules.filter(a=>!r.includes(a)).map(a=>a.fieldApiName),...s])],i=n.rows&&xa(n.rows,new Set(s));return{config:{...n,fieldRules:r,...i?{rows:i}:{}},dropped:o}}async function Jo(n,e,t){if(!t)return{config:n,filled:[]};let r;try{r=await t(n.objectApiName)}catch{return{config:n,filled:[]}}let s=new Set([...n.fieldRules.map(i=>i.fieldApiName),...Da(n.rows),...e?[e.lookupField]:[]]),o=[];for(let i of r){if(s.has(i.fieldApiName))continue;let a=Gn(i);a.ruleType==="static"&&a.config.staticValue===void 0||o.push({fieldApiName:i.fieldApiName,fieldType:i.type,...a})}return o.length===0?{config:n,filled:[]}:{config:{...n,fieldRules:[...n.fieldRules,...o]},filled:o.map(i=>i.fieldApiName)}}async function Vo(n,e,t){let r=Gt(n.objectApiName,e),{config:s}=await Yo(Xo(n,r),t.describeCreateableFields),{config:o}=await Jo(s,r,t.describeRequiredFields);return jt(o)}function Xo(n,e){if(!e)return n;let t=n.fieldRules.filter(r=>r.fieldApiName!==e.lookupField);return t.length===n.fieldRules.length?n:{...n,fieldRules:t}}function La(n,e){return e!==void 0&&n.fieldRules.length===0&&!n.rows}function $a(n){return Array.from({length:n},()=>({}))}function Ba(n,e,t,r=0){if(!(!e||!t))for(let[s,o]of n.entries())o[e.lookupField]=t.parentIds[r+s]}function _a(n,e){return n?{fields:[...new Set([...n.fields,...e.fields])],reason:n.reason==="no-answer"&&e.reason==="no-answer"?"no-answer":"short-answer"}:e}function Wa(n,e){for(let t of e.result.successIds)n.result.successIds.push(t);for(let t of e.result.errors)n.result.errors.push(t);e.written&&(n.written=ze(n.written,e.written)),n.forms=Sn(n.forms,e.forms),n.unsent.push(...e.unsent);for(let t of e.notes??[])(n.notes??[]).includes(t)||(n.notes=[...n.notes??[],t])}function Ga(n,e){return{objectApiName:n,recordsCreated:0,recordsFailed:0,createdIds:[],errors:[e]}}function Ko(n,e,t,r,s){let o=t.reduce((d,c)=>d+c.recordsCreated,0),i=t.reduce((d,c)=>d+c.recordsFailed,0),a=t.some(d=>!d.optional&&d.recordsCreated===0&&d.recordsFailed===0&&d.errors.length>0);return{templateId:n,operationId:e,status:Ua(o,i,a),objectResults:t,totalRecordsCreated:o,totalRecordsFailed:i,duration:Date.now()-r,timestamp:s}}function Ua(n,e,t){return e===0&&!t?"success":n===0?"failure":"partial"}function Ho(n,e,t,r){return{templateId:n,operationId:e,status:"failure",objectResults:[{objectApiName:"validation",recordsCreated:0,recordsFailed:0,createdIds:[],errors:t}],totalRecordsCreated:0,totalRecordsFailed:0,duration:0,timestamp:r}}var za=200,qa=1,Ka=1,Cn=2,Ha=2,ei=3,Ya=1,Ja=200,Va="Campaign";function ti(n,e){if(!n)return;let t=e.toLowerCase();for(let[r,s]of n)if(r.toLowerCase()===t)return s}function Xa(n,e){let t=Math.max(1,Math.floor(e)),r=[],s=0;do{let o=Math.max(0,Math.min(t,n-s));r.push(o),s+=o}while(s<n);return r}function Za(n,e={}){let t=e.bulkThreshold??za,r=!1;return n.objects.flatMap(o=>{let i=ti(e.duplicateRules,o.objectApiName),a=i===!1&&!vs.has(o.objectApiName),d=e.partition??e.slices?.get(o.objectApiName)??jt(o);return Xa(o.recordCount,d).map(c=>{let l=we([{rows:c,perCall:o.batchSize}]);if(c<=t||(r=!0,i===!0))return l;let u=we([{rows:c,bulk:!0}]);return a?u:Math.max(u,l)})}).reduce((o,i)=>o+i,0)+(r?qa:0)+we(td(n))}function Qa(n,e={}){return Za(n,e)+ed(n,e)}function ed(n,e={}){let t=new Set(n.objects.map(o=>o.objectApiName)),r=n.objects.some(o=>o.fieldRules.some(i=>it(i,t))),s=(n.relations??[]).reduce((o,{parents:i})=>i.kind==="existing"?o+we([{rows:0,readRows:i.limit}]):i.kind==="records"?o+Math.ceil(i.ids.length/so):o,0);return Ka+n.objects.length+Cn+(t.has(Va)?Cn+1:0)+s+(r?Ya:0)+(e.typedFirst?Ha:0)+ei+Math.max(0,e.sentBefore??0)+Math.max(0,e.automationRead??0)+Math.max(0,e.slicesRead??0)}async function Ll(n,e,t){let r=new Map;if(t!==void 0)return r;for(let s of n.objects)s.recordCount<=On||r.set(s.objectApiName,await Vo(s,n.relations,e));return r}function $l(n,e){return n?.enabled&&e.objects.reduce((r,s)=>r+s.recordCount,0)>=n.autoActivateThreshold?n.grappeSize:void 0}function vt(n,e){return n.reduce((t,{objectApiName:r,rows:s,perCall:o,deletes:i})=>{if(s<=e.threshold)return t+we([{rows:s,perCall:o??e.perCall}]);let a=i===!0||ti(e.duplicateRules,r)===!1?0:s;return t+we([{rows:s,bulk:!0},{rows:a}])},0)}function Pn(n=0,e=0){return ei+Cn+Math.max(0,n)+Math.max(0,e)}function Bl(n,e){let t=o=>n.find(i=>i.objectApiName===o)?.rows??0,r=Math.min(t("Opportunity"),t("OpportunityContactRole")),s=n.filter(({objectApiName:o})=>e.secondPass?.has(o)===!0).map(({rows:o})=>({rows:o}));return vt(n,e)+(r>0?Math.ceil(r/Ja)+vt([{objectApiName:"OpportunityContactRole",rows:r}],e):0)+we(s)+Pn(n.length,e.automationRead)}function td(n){let e=r=>n.objects.find(s=>s.objectApiName===r)?.recordCount??0,t=Math.min(e("OpportunityContactRole"),e("Opportunity"));return t>0?[{rows:t},{rows:t}]:[]}function nd(n,e){return n.objects.reduce((t,r)=>t+en(r.objectApiName,{rows:r.recordCount,personAccounts:e.includes(r.objectApiName)?r.recordCount:0}),0)}function rd(n,e){return Object.fromEntries(n.objects.filter(t=>t.recordCount>0).map(t=>[t.objectApiName,en(t.objectApiName,{rows:t.recordCount,personAccounts:e.includes(t.objectApiName)?t.recordCount:0})/t.recordCount]))}function Wl(n,e){let t=n.automationStarts??[],r=t.filter(a=>a.why!=="leftEmpty"),s=n.automationAtMostMB!==void 0&&n.automationAtMostMB>0&&r.length>0?` (${De(n.automationAtMostMB)} MB of it at most: ${r.map(a=>`${Zo(a)} ${Qo(a)}`).join("; ")})`:"",o=`data storage: about ${De(n.estimateMB)} MB to write`+(n.automationMB!==void 0&&n.automationMB>0?`, about ${De(n.automationMB)} MB of it for what the target's automation creates under them${s}`:""),i=t.filter(a=>a.why==="leftEmpty").map(a=>`; nothing counted for ${Zo(a)}: it ${Qo(a)}`).join("");return n.verdict==="unread"?`${o}; what ${e} has left could not be read (${n.unread})${i}`:`${o}, ${e} has ${n.remainingMB} MB left of ${n.maxMB} MB`+ht(qe(n),e)+(n.verdict==="near"?": close to what it has left":"")+i}function Zo(n){return`${n.name} on ${n.objectApiName}`}function Qo(n){let e=n.why==="leftEmpty"?"which the seed leaves empty":n.why==="automationMayFill"?"which the seed leaves empty and the target's automation may fill first":"which the seed may leave empty";return`starts only on a record whose ${n.fields.join(" and ")} ${n.fields.length===1?"is":"are"} filled, ${e}`}var Gl="SEED_STORAGE_EXCEEDED";async function Ul(n,e,t,r,s,o={},i={},a={perRecord:[]}){let d={storageBytes:nd(e,t)},c;try{c=await ds(n)}catch(A){c={unread:q(A)}}let l=new Map(e.objects.map(A=>[A.objectApiName,A.recordCount])),u=A=>l.get(A)??0,f=tn(a,u),p=a.atMost?tn({perRecord:a.atMost},u):0,m=Ne(d,c,f),h={...m.verdict==="exceeds"&&p>0&&Ne(d,c,f-p).verdict!=="exceeds"?{...m,verdict:"near"}:m,...p>0?{automationAtMostMB:p/1048576}:{},...a.starts&&a.starts.length>0?{automationStarts:a.starts}:{}},w=rd(e,t),S="unread"in c?await cs(n).catch(A=>({unread:q(A)})):c.dailyApiRequests,R=pt({run:Qa(e,i),...gt(s),...o},S),O=mt(s);if(O)return{check:h,api:R,rowBytes:w,refusal:O.message,refusedFor:"checkpoint",checkpointRefusal:O.refusal};let g=ks(h,r);if(g)return{check:h,api:R,rowBytes:w,refusal:`${g} Nothing was written.`,refusedFor:"storage"};let b=ft(R,r,Ue);return b?{check:h,api:R,rowBytes:w,refusal:b,refusedFor:"apiRequests"}:{check:h,api:R,rowBytes:w}}function zl(n,e){let{check:t,api:r}=n,s=r.parts??{},o={checkpoint:s.checkpoint??0,mute:s.mute??0,readBack:s.readBack??0,deliverability:s.deliverability??0,fit:s.fit??0};return Os({storage:t.verdict==="unread"?{unread:t.unread}:{maxMB:t.maxMB,remainingMB:t.remainingMB,...t.uncountedWrites?{uncountedWrites:t.uncountedWrites}:{}},...e!==void 0?{withinMB:e}:{},api:r.verdict==="unread"?{unread:r.unread}:{max:r.max,remaining:r.remaining},otherRequests:o})}function sd(n){return n==="insert"||n==="upsert"}function oi(n){return n==="update"||n==="upsert"}function od(n){return as(n.objects.filter(e=>sd(e.operation)).map(({objectApiName:e,rows:t,personAccounts:r})=>({objectApiName:e,rows:[],counted:{rows:t,...r!==void 0?{personAccounts:r}:{}}})))}var ii=fe.REST_API_BATCH_SIZE;function id(n,e){return vt(n.filter(t=>t.rows>0).map(({objectApiName:t,operation:r,rows:s,batchSize:o})=>({objectApiName:t,rows:s,...o!==void 0?{perCall:o}:{},...r==="delete"?{deletes:!0}:{}})),{threshold:e.bulkThreshold??ii,...e.duplicateRules?{duplicateRules:e.duplicateRules}:{}})}var ad="Opportunity",dd="OpportunityContactRole",cd=200,ld={update:{characters:yt,wide:!0},upsert:{characters:qs(),wide:!0}},ud=2,ni=Array.from({length:ud},()=>1),pd={characters:yt,wide:!1},fd=1;function gd(n,e=[]){let t=Math.min(Math.max(0,n),5e4),r=e.reduce((s,o)=>s+Math.ceil(t/Math.max(1,o)),0);return fd+Math.max(1,Math.ceil(t/Vr))+r}function md(n,e){let[,...t]=nr(e.length>0?e:["Id"]);return t.map(r=>rr(n,r))}function En(n,e){let t=Math.max(1,Math.floor(e));return Array.from({length:Math.ceil(Math.max(0,n)/t)},(r,s)=>Math.min(t,n-s*t))}function ri(n,e){if(n.rows<=(e.bulkThreshold??ii))return En(n.rows,n.batchSize??fe.REST_API_BATCH_SIZE);let t=e.duplicateRules?[...e.duplicateRules].find(([r])=>r.toLowerCase()===n.objectApiName.toLowerCase())?.[1]:void 0;return[n.rows,...t===!1?[]:En(n.rows,fe.REST_API_BATCH_SIZE)]}function hd(n,e){let t=0,r=!1;for(let[d,c]of e.targetHeld??[])t+=gd(c,e.targetGroups?.get(d));for(let d of n.objects){if(d.rows<=0||d.operation==="delete")continue;t+=ni.length;let{within:c=0,cycle:l=0}=d.lookupPasses??{};for(let[u,f]of[[c,[]],[l,[1]]]){if(u<=0)continue;let p=[...ri({...d,rows:u},e),...f];r=!0,t+=p.length+wt(p,pd)}d.operation!=="update"&&d.operation!=="upsert"||(r=!0,t+=wt([...ri(d,e),...ni],d.overwriteKey??ld[d.operation]))}let s=d=>n.objects.find(c=>c.objectApiName===d&&(c.operation==="insert"||c.operation==="upsert")),o=s(ad),i=s(dd),a=o&&i?Math.min(o.rows,i.rows+(n.rolesLinked??0)):0;if(i&&a>0){let d=En(a,i.batchSize??fe.REST_API_BATCH_SIZE);r=!0,t+=Math.ceil(a/cd)+d.length+wt(d,{characters:yt,wide:i.overwriteKey?.wide??!0})}return r&&(t+=1),e.leaseAssigns===!0&&(t+=Math.max(0,n.describedAgain??0)),t}function ai(n){let e=new Map;for(let{objectApiName:t,operation:r}of n.objects){let s=e.get(t)??new Set;(r==="insert"||r==="upsert")&&s.add("insert"),(r==="update"||r==="upsert")&&s.add("update"),r==="delete"&&s.add("delete"),e.set(t,s)}return(t,r)=>e.get(t)?.has(r)===!0}function di(n,e){let t=new Set(e);return{...n,objectsRead:n.objectsRead.filter(r=>t.has(r)),objects:n.objects.filter(r=>t.has(r.objectApiName))}}function yd(n){let e;return t=>{if(e&&t.every(s=>e?.objects.includes(s)))return e.answer.then(s=>di(s,t));let r=n(t);return e??={objects:[...t],answer:r},r}}function wd(n){return`A read of the target that fails for a passing reason is sent again whole, up to ${n} more times: its requests are not counted either.`}function du(n,e){if(n.direction==="bidirectional")return async t=>{let r=n.objects.find(o=>o.objectApiName===t),s=lt(r?.where,void 0);return e(`SELECT COUNT() FROM ${ye(t)}${s?` WHERE ${s}`:""}`)}}async function Sd(n,e,t){let r=new Set((n.heldBack??[]).filter(({rows:i})=>i>0).map(({objectApiName:i})=>i)),s=new Map,o=new Map;for(let{objectApiName:i,operation:a,rows:d}of n.objects){if(!oi(a)||s.has(i)||d<=0&&!r.has(i))continue;let c=await e(i).catch(()=>5e4);s.set(i,Number.isFinite(c)&&c>=0?c:5e4);let l=await t?.(i).catch(()=>{}),u=l?md(i,l):[];u.length>0&&o.set(i,u)}return{held:s,groups:o}}async function si(n,e){let t=od(n),r=n.objects.filter(M=>M.rows>0).map(({objectApiName:M,rows:P})=>({objectApiName:M,rows:P})).sort((M,P)=>P.rows-M.rows||M.objectApiName.localeCompare(P.objectApiName)),s=r.reduce((M,P)=>M+P.rows,0),o=n.objects.filter(M=>oi(M.operation)).reduce((M,P)=>M+P.rows,0),i=Ne(t,{maxMB:0,remainingMB:0}),a=[],d,c=s>0?yd(e.readAutomation):e.readAutomation,l,u,f,p=ai(n),m;if(s>0){let M=n.objects.filter(P=>P.rows>0).map(P=>P.objectApiName);if(m=await c(M).catch(P=>({unread:P instanceof Error?P.message:String(P)})),e.checkpointFirst){let P="objects"in m?Ut(m,void 0,p):{firing:[]};try{l=await e.checkpointFirst.scope(M,P)}catch(v){u=os(v)}}}let y={unread:"not read"};if(s>0){let M=await e.readStorage().catch(P=>({unread:P instanceof Error?P.message:String(P)}));y="unread"in M?await e.readApiBudget().catch(P=>({unread:P instanceof Error?P.message:String(P)})):M.dailyApiRequests,t.totalRows>0&&(i=Ne(t,M))}if(t.totalRows>0){let M=await gs({plan:t,objects:t.objects.map(P=>P.objectApiName),readAutomation:c,readLimits:e.readLimits});a=M.checks,d=M.unread}m!==void 0&&(f=await qr({...e.emails,read:m,writes:p,readDeliverability:e.readDeliverability,run:"sync"}));let h=s>0&&e.countTarget?await Sd(n,e.countTarget,e.targetFields):void 0,w=h!==void 0&&h.held.size>0&&(e.readRetries??0)>0?e.readRetries:void 0,S=Ss(f?.ofRun),R=e.sentBefore?.(),O=s===0?0:R!==void 0?Math.max(0,R-(S.deliverability??0)):Pn(0,m!==void 0?ws(m):0)+(h?.held.size??0),g=m!==void 0?Ns(m):void 0,b=s===0?0:hd(n,{bulkThreshold:e.bulkThreshold,duplicateRules:g,leaseAssigns:(e.mutePlan?.()?.assign.length??0)>0,...h?{targetHeld:h.held,targetGroups:h.groups}:{}}),A=pt({run:id(n.objects,{bulkThreshold:e.bulkThreshold,duplicateRules:g})+O+b,...gt(l),...Hr(e.mutePlan?.()),...n.readBack!==void 0&&n.readBack>0?{readBack:n.readBack}:{},...S},y),k=e.confirmAboveRecords,C=k>0&&s>k?k:void 0,F=(n.unwritable??[]).map(({objectApiName:M,rows:P,why:v,key:$})=>({...$!==void 0?{key:$}:{},objectApiName:M,rows:P,why:v})),j=(n.heldBack??[]).map(({objectApiName:M,rows:P,parent:v,field:$,parents:H})=>({objectApiName:M,rows:P,parent:v,field:$,...H!==void 0?{parents:H.map(K=>({...K}))}:{}})),N=f?.gate,L=s===0?F.length>0?"refused":"writes":i.verdict==="exceeds"||A.verdict==="exceeds"||u!==void 0||l?.refusal!==void 0?"refused":C!==void 0||F.length>0||t.totalRows>0&&i.verdict!=="fits"||a.some(M=>M.verdict!=="fits")||d!==void 0||l!==void 0||N?.verdict==="asks"?"asks":"writes";return{check:{objects:r,total:s,alreadyCopied:n.alreadyCopied,...(n.alreadyLinked??0)>0?{alreadyLinked:n.alreadyLinked}:{},...o>0?{overwrites:o}:{},...(n.rolesByThePlatform??0)>0?{rolesByThePlatform:n.rolesByThePlatform}:{},...(n.rolesLinked??0)>0?{rolesLinked:n.rolesLinked}:{},...C!==void 0?{aboveRecords:C}:{},storage:i.verdict==="unread"?{verdict:"unread",estimateMB:i.estimateMB,unread:i.unread}:t.totalRows===0?{verdict:"fits",estimateMB:0}:{verdict:i.verdict,estimateMB:i.estimateMB,maxMB:i.maxMB,remainingMB:i.remainingMB,...qe(i)},emails:a.map(M=>({limit:M.limit,emails:M.emails,verdict:M.verdict,...M.remaining!==void 0?{remaining:M.remaining}:{},...M.max!==void 0?{max:M.max}:{},...M.alertsCounted?{alertsCounted:!0}:{},objects:M.objects.map(({objectApiName:P,perRecord:v})=>({objectApiName:P,perRecord:v})),...M.unread!==void 0?{unread:M.unread}:{}})),...d!==void 0?{emailsUnread:d}:{},...N?.deliverability?{deliverability:N.deliverability}:{},...F.length>0?{unwritable:F}:{},...j.length>0?{heldBack:j}:{},...s>0?{apiRequests:{...A.verdict==="unread"?{verdict:"unread",estimate:A.estimate,unread:A.unread}:{verdict:A.verdict,estimate:A.estimate,remaining:A.remaining,max:A.max},...w!==void 0?{readsAgain:w}:{}}}:{},verdict:L,...u!==void 0?{checkpointUnread:u}:{}},plan:t,storage:i,emails:a,api:A,...l!==void 0?{checkpoint:l}:{},...u!==void 0?{checkpointFailed:u}:{},...f!==void 0?{runEmails:f}:{},emailsAccepted:e.emails.accepted}}function bd(n,e){let{check:t,storage:r,emails:s,plan:o,api:i}=n,a=[],d=t.unwritable??[];if(d.length>0&&(e.policy!=="ask"||t.total===0)&&a.push({code:"SYNC_TARGET_UNWRITABLE",message:Od(d,e.org,t.heldBack)}),t.total===0)return a;if(n.checkpointFailed!==void 0)a.push({code:ps,message:n.checkpointFailed});else{let u=mt(n.checkpoint);u&&a.push(u)}o.totalRows>0&&r.verdict==="exceeds"&&a.push({code:"SYNC_STORAGE_EXCEEDED",message:`The records to write take about ${De(r.estimateMB)} MB of data storage, and ${e.org} has ${r.remainingMB} MB left of ${r.maxMB} MB${ht(qe(r),e.org)}: leave objects out, narrow their filters, or free data storage in ${e.org}. To copy a sample of the source that fits ${e.org} instead, use Forge with Depth ALL and a sample that fits the target (sandforge clone --depth all --fit share). Nothing was written.`});let c=t.apiRequests?.readsAgain,l=ft(i,e.org,c!==void 0?`${Ue} ${wd(c)}`:Ue);if(l&&a.push({code:ls,message:l}),e.policy!=="ask"){let u=ys(s,e.org);u&&a.push({code:"SYNC_EMAILS_EXCEEDED",message:`${u} Nothing was written.`});let f=n.runEmails?.gate,p=f?.stop;p&&a.push({code:p.code,message:Qt(p.message,"sync",e.emailsLiftedBy),...ve(f,!1)})}return a}async function Rd(n,e){let{check:t,storage:r,emails:s,api:o}=n,[i]=bd(n,e);if(i)return{go:!1,...i};if(t.total===0)return{go:!0,asked:!1};let a=n.runEmails?.gate;if(e.policy!=="ask")return{go:!0,asked:!1,...ve(a,n.emailsAccepted)};let d=t.unwritable??[];if(t.verdict==="writes")return{go:!0,asked:!1,...ve(a,!1)};let c=Ur(e.orgTier),l=s.filter(m=>m.verdict==="exceeds").map(ms),u=s.filter(m=>m.verdict==="unread").map(hs),f=e.confirm?await e.confirm({stage:"write",module:"sync",org:e.org,orgTier:e.orgTier,objects:t.objects,total:t.total,...t.aboveRecords!==void 0?{aboveRecords:t.aboveRecords}:{},...c!==void 0&&t.total>c?{largeVolume:c}:{},storage:Rs(r),counted:!0,...t.overwrites!==void 0?{overwrites:t.overwrites}:{},...l.length>0?{emails:l}:{},...u.length>0?{emailsUnread:u}:{},...t.emailsUnread!==void 0?{emailsUncounted:t.emailsUnread}:{},...t.alreadyCopied>0?{alreadyCopied:t.alreadyCopied}:{},...(t.alreadyLinked??0)>0?{alreadyLinked:t.alreadyLinked}:{},...(t.rolesLinked??0)>0?{rolesLinked:t.rolesLinked}:{},...d.length>0?{unwritable:d}:{},...t.heldBack!==void 0&&t.heldBack.length>0?{heldBack:t.heldBack}:{},...us(o),...n.checkpoint!==void 0?{checkpoint:n.checkpoint}:{},...a?.confirmation}):"unavailable";if(f==="confirmed")return{go:!0,asked:!0,...ve(a,a?.verdict==="asks")};let p=ve(a,!1);return f==="declined"?{go:!1,code:"SYNC_WRITE_DECLINED",message:"The sync was cancelled before it wrote anything. Nothing was written.",...p}:{go:!1,code:"SYNC_CONFIRMATION_UNAVAILABLE",message:"The sync needed a confirmation before it wrote, and there was no one to ask. Nothing was written.",...p}}var kd={notInTarget:n=>`${n} has no such object, or the user the run writes as cannot see it`,notCreateable:n=>`the user the run writes as may not create its records in ${n}`,notUpdateable:n=>`the user the run writes as may not edit its records in ${n}`,unread:n=>`${n} did not describe it, so what it takes could not be told`,notAKey:(n,e)=>`its upsert matches on ${e??"a field"}, neither an External ID nor an idLookup field in ${n}`};function Od(n,e,t=[]){let r=n.map(({objectApiName:w,rows:S,why:R,key:O})=>`${w} (${S} record${S===1?"":"s"}): ${kd[R](e,O)}`).join("; "),s=n.length===1?"it":"them",o=n.filter(({why:w})=>w==="notAKey"),i=n.filter(({why:w})=>w!=="notAKey"),a=o.length>0&&i.length>0,d=w=>w.map(({objectApiName:S})=>S).join(" and "),c=`give the user SandForge writes as access to ${a?d(i):s} in ${e}`,l=`match ${a?`${d(o)} `:""}on an External ID field of ${e}`,u=a?`${c}, or ${l}`:o.length>0?`or ${l}`:`or ${c}`,f=new Set(n.map(({objectApiName:w})=>w)),p=({parent:w,field:S})=>`whose ${S} names ${/^[aeiou]/i.test(w)?"an":"a"} ${w} record `+(f.has(w)?"left out":"held back"),m=t.flatMap(({objectApiName:w,rows:S,parent:R,field:O,parents:g})=>(g??[{parent:R,field:O,rows:S}]).map(b=>`${b.rows} ${w} record${b.rows===1?"":"s"}, ${p(b)}`)).join("; "),y=n.filter(({why:w})=>w==="notInTarget"),h=y.length>0?` Where ${e} has not ${d(y)}, Compare deploys ${y.length===1?"it":"them"} from the source: tick Data Model, compare, then Deploy from Diff.`:"";return`${e} would take no record of ${n.length===1?"one object":`${n.length} objects`} the sync writes \u2014 ${r}.`+(m!==""?` Left out, ${s==="it"?"it holds":"they hold"} back ${m}.`:"")+` Leave ${s} out of the run, ${u}.${h} Nothing was written.`}function cu(n,e){return{measure:async t=>(await si(t,n)).check,hold:async t=>{let r=await si(t,n),s=await Rd(r,e);return{check:r.check,answer:await Ad(r,s,n.checkpointFirst),rowBytes:is(r.plan)}}}}async function Ad(n,e,t){let r=n.checkpoint;if(!e.go||r===void 0||t===void 0)return e;let s=await fs(()=>t.take(r));return"stop"in s?{go:!1,...s.stop}:{...e,checkpoint:s.checkpoint}}function lu(n,e){return e==="insert"||e==="update"||e==="delete"}function uu(n,e,t,r,s){let o,i,a,d,c=n(async u=>{let f=o?.automation;return f&&u.every(p=>f.objectsRead.includes(p))?di(f,u):e(u)},()=>o?.plan),l=u=>{if(!Kr(u))throw u;return{go:!1,code:u.code,message:u.message}};return{gate:{measure:u=>c.measure(u),hold:async u=>{let f=u.objects.filter(m=>m.rows>0).map(m=>m.objectApiName);if(!o&&f.length>0){d=await e(f).catch(m=>({unread:m instanceof Error?m.message:String(m)}));try{o=await t(d),a=o.muted}catch(m){return{check:await c.measure(u),answer:l(m)}}}let p=await c.hold(u);if(p.answer.go&&o?.prepared&&!i){try{i=await o.prepared.acquire(r),a=i.outcome}catch(R){let{checkpoint:O}=p.answer;return{check:p.check,answer:{...l(R),...O?{checkpoint:O}:{}}}}let{checkpoint:m,emails:y}=p.answer,{deliverability:h}=p.check,w=ai(u),S=o.plan&&d&&"objects"in d?bs({planned:h?.senders??[],held:Vn(Ut(d,zr(o.plan,i.outcome),w),{writes:w}),...h?{reading:h.reading}:{},accepted:y?.accepted===!0,target:s.target,run:"sync"}):void 0;if(S)return{check:p.check,answer:{go:!1,code:S.code,message:Qt(S.message,"sync",s.liftedBy),...m?{checkpoint:m}:{},...y?{emails:y}:{}}}}return p}},release:async()=>(i&&(a=await i.release()),a),lease:()=>{let u=i;if(u)return{assigned:u.outcome.assigned.length,giveBack:async()=>(a=await u.release(),a)}}}}export{kt as a,It as b,Md as c,jd as d,zd as e,qd as f,Kd as g,mo as h,ji as i,rc as j,sc as k,oc as l,ic as m,ac as n,dc as o,yc as p,wc as q,Sc as r,bc as s,Wi as t,Gi as u,Rc as v,qi as w,kc as x,Oc as y,Ki as z,ae as A,$e as B,Oo as C,Ao as D,Pc as E,Yi as F,Ji as G,Ic as H,gn as I,Bc as J,Ro as K,xo as L,Go as M,ti as N,Qa as O,Ll as P,$l as Q,vt as R,Pn as S,Bl as T,nd as U,Wl as V,Gl as W,Ul as X,zl as Y,du as Z,si as _,bd as $,Rd as aa,Od as ba,cu as ca,Ad as da,lu as ea,uu as fa};
|
|
@@ -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{b as f}from"./chunk-CA5NAXSU.mjs";import{
|
|
7
|
+
import{b as f}from"./chunk-CA5NAXSU.mjs";import{Ae as h,Ee as g,Fe as y,Ge as P,ze as S}from"./chunk-J347SPU6.mjs";var T=576*60*60*1e3,b=T,m=class extends Error{constructor(e){super(e),this.name="StepCancelledError"}},w=Symbol("stopped");function $(t,e,n,i){let r=new Date().toISOString();return{stepId:t.id,stepName:t.name,stepType:t.type,status:"completed",output:e,summary:i,startTime:n,endTime:r,duration:new Date(r).getTime()-new Date(n).getTime()}}function u(t,e,n){let i=new Date().toISOString();return{stepId:t.id,stepName:t.name,stepType:t.type,status:"failed",error:e,startTime:n,endTime:i,duration:new Date(i).getTime()-new Date(n).getTime()}}function v(t){return P(t.type)?`Step "${t.name}" is a ${String(t.type)} step, which SandForge no longer supports: remove it from the pipeline.`:y(t.type)?`Step "${t.name}" is a ${String(t.type)} step, and this step type cannot run in a pipeline yet.`:`Step "${t.name}" is a "${String(t.type)}" step, a step type this release of SandForge does not have: the pipeline was saved by a later release, or written by hand. Remove the step, or update SandForge.`}function H(t){let{timeout:e}=t;if(e!==void 0){if(typeof e!="number"||!Number.isFinite(e))return`Step "${t.name}" has a timeout that is not a number of milliseconds: ${JSON.stringify(e)}.`;if(e>b)return`Step "${t.name}" has a timeout of ${e} ms, longer than a step can be given: set at most 24 days (${b} ms).`}}function x(t){let e=t.seconds,n=e===void 0?t.durationMs:e;if(typeof n!="number"||!Number.isFinite(n)||n<0)return;let i=e===void 0?n:n*1e3;return i<=T?i:void 0}function l(t){return String(Math.round(t/100)/10)}function M(t,e){let n=Math.max(t,e),i=n-t;return i<=Math.max(5e3,t/100)?`Waited ${l(n)} s.`:`Waited ${l(n)} s by the wall clock, ${l(i)} s more than the ${l(t)} s asked: the machine's clock or a sleep may account for it.`}function C(t){if(t.config.seconds===void 0&&t.config.durationMs===void 0)return`Delay step "${t.name}" has no duration: set how many seconds it waits.`;if(x(t.config)===void 0)return`Delay step "${t.name}" has no usable duration: set a number of seconds, from 0 up to 24 days.`}function E(t,e,n){let i=`Condition step "${t.name}"`;switch(n){case"noEarlierStep":return`${i} tests how the previous step went, and no step comes before it.`;case"noCompare":return`${i} tests how many differences a comparison found, and no Compare step comes before it.`;case"noPrecheck":return`${i} tests ${e}, which a Pre-check hands on, and no Pre-check before it takes that reading.`}}function k(t){let e=t.condition;if(!e||typeof e.field!="string"||e.field.trim()==="")return`Condition step "${t.name}" has no condition to evaluate.`;let n=S(e);return n===void 0?void 0:`Condition step "${t.name}" ${n}.`}function I(t,e){let n=k(t);if(n!==void 0||!t.condition||!e)return n;let i=t.condition,r=g(i,e.steps.slice(0,e.index),e.declared);return r===void 0?void 0:E(t,i.field,r)}function O(t,e){return e?.aborted?Promise.resolve(!1):new Promise(n=>{let i=()=>{clearTimeout(r),n(!1)},r=setTimeout(()=>{e?.removeEventListener("abort",i),n(!0)},t);e?.addEventListener("abort",i,{once:!0})})}var D=class{handlers=new Map;checks=new Map;constructor(){this.registerDefaults()}async execute(e,n){let i=new Date().toISOString(),r=this.check(e);if(r)return u(e,r,i);let o=this.getExecutor(e.type),c=e.retries??0,a="";for(let p=0;p<=c;p++){let s=await this.attempt(o,e,n);if("result"in s)return s.result;if(s.stopped)return{...u(e,s.error,i),status:"stopped"};a=s.error}return u(e,a,i)}async attempt(e,n,i){let r=i.signal;if(r?.aborted)return{error:`Step "${n.name}" was stopped before it started.`,stopped:!0};let o=new AbortController,c=new Promise(d=>{o.signal.addEventListener("abort",()=>d(w),{once:!0})}),a=()=>o.abort();r?.addEventListener("abort",a,{once:!0});let p=!1,s=n.timeout,R=s!==void 0&&s>0?setTimeout(()=>{p=!0,o.abort()},s):void 0;try{let d=await Promise.race([e(n,{...i,signal:o.signal}),c]);return d!==w?{result:d}:p?{error:`Step "${n.name}" timed out after ${s} ms.`}:{error:`Step "${n.name}" was stopped before it finished.`,stopped:!0}}catch(d){return d instanceof m?{error:d.message,stopped:!0}:{error:f(d)}}finally{clearTimeout(R),r?.removeEventListener("abort",a)}}check(e,n){return this.handlers.has(e.type)?H(e)??this.checks.get(e.type)?.(e,n):v(e)}getExecutor(e){return this.handlers.get(e)??this.refusingHandler}registerHandler(e,n,i){this.handlers.set(e,n),i?this.checks.set(e,i):this.checks.delete(e)}wrapHandler(e,n){let i=this.handlers.get(e);i&&this.handlers.set(e,n(i))}refusingHandler=async e=>u(e,v(e),new Date().toISOString());registerDefaults(){this.handlers.set("delay",this.createDelayHandler()),this.checks.set("delay",C),this.handlers.set("condition",this.createConditionHandler()),this.checks.set("condition",I)}createDelayHandler(){return async(e,n)=>{let i=new Date().toISOString(),r=x(e.config);if(r===void 0)return u(e,C(e)??"No usable duration",i);let o=Date.now();if(!await O(r,n.signal))return u(e,`Delay step "${e.name}" was stopped before its ${r} ms wait ended.`,i);let a=Math.max(r,Date.now()-o);return $(e,{delayed:r,heldMs:a},i,M(r,a))}}createConditionHandler(){return async(e,n)=>{let i=new Date().toISOString(),r=k(e);if(r||!e.condition)return u(e,r??"No condition",i);try{let o=h(e.condition,n.variables);return $(e,{conditionMet:o},i,o?"The condition held.":"The condition did not hold.")}catch(o){return u(e,`Condition step "${e.name}" could not be evaluated: ${f(o)}.`,i)}}}};export{m as a,x as b,M as c,D as d};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b}from"./chunk-
|
|
7
|
+
import{a,b}from"./chunk-CLUNF4FK.mjs";import"./chunk-RZOINFNL.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-J347SPU6.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as applyUsers,a as planUsersIn};
|
|
@@ -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{i as g,n as p,o as m}from"./chunk-
|
|
7
|
+
import{i as g,n as p,o as m}from"./chunk-OT2NHL2V.mjs";import{a as b,b as I}from"./chunk-MS4FJDFD.mjs";import{c as w}from"./chunk-LCDPCUXS.mjs";import{id as l,p as d,q as u}from"./chunk-J347SPU6.mjs";import{A as c}from"./chunk-WZQEK4WT.mjs";import{d as f}from"./chunk-NTOVCTRS.mjs";var a=class extends Error{constructor(t,n){super(`${n} Nothing was read from ${t}.`);this.alias=t;this.reason=n;this.name="SfSessionError",this.stack=this.message}alias;reason},$=c.object({name:c.string().optional(),message:c.string().optional()}).loose();function h(e){if(typeof e!="string")return;let r=e.replace(/\u001b\[[0-9;]*m/g,""),t=r.indexOf("{");if(t!==-1)try{let n=$.safeParse(JSON.parse(r.slice(t)));return n.success?n.data:void 0}catch{return}}function C(e,r=process.platform){let t=typeof e=="object"&&e!==null?e:{};return t.code==="ENOENT"?!0:r==="win32"&&(t.status===9009||/is not recognized as an internal or external command/i.test(String(t.stderr??"")))}function S(e,r,t=process.platform){if(C(r,t))return new a(e,`${d} SandForge reads each org through the Salesforce CLI: install it with "npm install -g @salesforce/cli" (${u}), sign in to the org with "sf org login web --alias ${e}", and run again.`);let n=typeof r=="object"&&r!==null?r:{},o=h(n.stdout)??h(n.stderr);if(o?.name==="NamedOrgNotFoundError"||/^No authorization information found for /.test(o?.message??""))return new a(e,`sf does not know ${e}: "sf org list" names the orgs it knows; "sf org login web --alias ${e}" adds it (in a CI job, "sf org login jwt" or "sf org login sfdx-url").`);let s=typeof n.stderr=="string"?n.stderr.split(/\r?\n/).find(y=>y.trim()!==""):void 0,i=o?.message?.trim()||s?.trim()||(r instanceof Error?r.message:String(r));return new a(e,`sf could not show ${e}: ${i}`)}var k=f(I()),x=f(b());import{execFileSync as E}from"node:child_process";function T(e){try{return E("sf",["org","display","--target-org",e,"--json"],{encoding:"utf8",maxBuffer:50*1024*1024,shell:process.platform==="win32"})}catch(r){throw S(e,r)}}async function A(e,r=m){if(!w.test(e))throw new Error(`Invalid SF org alias: "${e}" (an alias or a username: letters, digits, _ . @ + and -, not starting with . @ + or -)`);let t=T(e),n=JSON.parse(t),o=n.result;if(typeof o?.devHubId=="string"&&o.devHubId!==""){let i=typeof o.expirationDate=="string"?l({orgType:"Scratch",metadata:{expirationDate:o.expirationDate}},new Date().toISOString().slice(0,10)):void 0;if(i!==void 0||o.status==="Deleted")throw new Error(`The scratch org '${e}' ${i!==void 0?`expired on ${i}`:"is deleted"}: Salesforce deletes a scratch org when it expires, and no sign-in brings it back. Create a new one ("sf org create scratch") and give its alias.`)}if(!n.result?.instanceUrl)throw new Error(`sf org display did not return a usable session for alias '${e}'.`);let s=await r(e);if(!p(s.accessToken))throw new Error(`The Salesforce CLI showed no usable access token for alias '${e}'. Sign in again with "sf org login web --alias ${e}" where a browser opens; in a CI job, with "sf org login jwt --alias ${e}" (a client id, a key file and a username) or "sf org login sfdx-url --alias ${e} --sfdx-url-file <file>" (see ci-examples/README.md).`);return{alias:e,username:n.result.username??"",instanceUrl:s.instanceUrl??n.result.instanceUrl,accessToken:s.accessToken,...typeof n.result.id=="string"&&n.result.id!==""?{orgId:n.result.id}:{},...typeof n.result.devHubId=="string"&&n.result.devHubId!==""?{scratch:!0}:{}}}function H(e,r=process.env){let t=g(e.instanceUrl,r),n=new k.default.Connection({instanceUrl:e.instanceUrl,accessToken:e.accessToken,version:"66.0",...t!==void 0?{httpProxy:t}:{}});return t===void 0&&(n._transport=new x.HttpProxyTransport("")),n}export{a,A as b,H as c};
|
|
@@ -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{k as f}from"./chunk-
|
|
7
|
+
import{k as f}from"./chunk-4CSBZZAL.mjs";import{Xa as l}from"./chunk-J347SPU6.mjs";import{b as c,k as h,m,v,z as A}from"./chunk-WZQEK4WT.mjs";import{randomBytes as S}from"node:crypto";import{mkdir as k,open as O,readFile as E,readdir as $,rename as D,rm as F}from"node:fs/promises";import{join as u,resolve as N}from"node:path";var T=448,b=384,_=1e4,I=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$/,J=/^\d{8}T\d{9}Z-00D[A-Za-z0-9]{15}\.json$/,y=A.datetime({offset:!0}),j=m({name:c().min(1).max(255),type:c().min(1).max(80),cronExpression:c().min(1).max(255).optional(),state:c().min(1).max(40),nextFireTime:y.optional(),previousFireTime:y.optional(),owner:c().min(1).max(255).optional()}),x=m({version:v(1),savedAt:y,organizationId:l,host:c().regex(I),jobs:h(j).max(_)});function z(e){return u(N(e),"audits")}function w(e){let n=e.trim().toLowerCase().replace(/\.$/,"");return I.test(n)?n:void 0}function K(e,n){let r=w(n);if(r===void 0)throw new Error(`Not a host name: "${n}"`);return u(z(e),r)}function R(e){return`${new Date(e.savedAt).toISOString().replace(/[-:.]/g,"")}-${f(e.organizationId)}.json`}async function Z(e,n){let r=x.parse(n),i=K(e,r.host);await k(i,{recursive:!0,mode:T});let s=u(i,R(r)),a=`${s}.${process.pid}-${S(4).toString("hex")}.tmp`,d=await O(a,"wx",b);try{try{await d.writeFile(`${JSON.stringify(r,null,2)}
|
|
8
8
|
`,"utf8"),await d.sync()}finally{await d.close()}await D(a,s)}catch(t){throw await F(a,{force:!0}),t}return s}async function C(e,n){let r=w(n);if(r===void 0)return{kept:[],setAside:[],unread:`${n} is not a host name`};let i=u(z(e),r),s;try{s=(await $(i,{withFileTypes:!0})).filter(t=>t.isFile()&&t.name.endsWith(".json")).map(t=>t.name).sort()}catch(t){let o=t?.code;return o==="ENOENT"||o==="ENOTDIR"?{kept:[],setAside:[]}:{kept:[],setAside:[],unread:`${i} could not be read: ${t instanceof Error?t.message:String(t)}`}}let a=[],d=[];for(let t of s){let o=u(i,t);if(!J.test(t)){d.push({path:o,why:"its name is not one --save gives"});continue}let g;try{g=JSON.parse(await E(o,"utf8"))}catch{d.push({path:o,why:"it does not read as JSON"});continue}let p=x.safeParse(g);if(!p.success){d.push({path:o,why:"it does not read as an inventory of this SandForge"});continue}if(p.data.host!==r){d.push({path:o,why:`it is of ${p.data.host}, not of the host its folder names`});continue}a.push({inventory:p.data,path:o})}return a.sort((t,o)=>Date.parse(o.inventory.savedAt)-Date.parse(t.inventory.savedAt)),{kept:a,setAside:d}}function V(e,n){let r=f(n),i=e.find(a=>f(a.inventory.organizationId)!==r);if(i!==void 0)return{kept:i,refreshed:!0};let s=e[0];return s!==void 0?{kept:s,refreshed:!1}:void 0}export{Z as a,C as b,V as c};
|
|
@@ -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{h as O}from"./chunk-
|
|
7
|
+
import{h as O}from"./chunk-VKREON6Q.mjs";import{A as R,B as _,e as X,k as S,r as P}from"./chunk-DLSU66MY.mjs";import{H as E,c as Y,p as A,q as z}from"./chunk-4CSBZZAL.mjs";import{g as w,h as y}from"./chunk-DAUX63UB.mjs";import{$c as u}from"./chunk-J347SPU6.mjs";import{b as D,e as W,f as Q,l as L}from"./chunk-WZQEK4WT.mjs";import{mkdir as se,rm as M}from"node:fs/promises";import{join as I}from"node:path";var ee=200,ne=X*10,B=2e3,te=["Id","ContentDocumentId","LinkedEntityId","ShareType","Visibility"],ae=["Id","LatestPublishedVersionId","ContentSize"],de="taking",h=D().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,"Not a record id"),T=D().regex(/^[A-Za-z]{1,40}$/,"Not a sharing value"),V=L({Id:h,ContentDocumentId:h,LinkedEntityId:h,ShareType:T,Visibility:T}),J=L({Id:h,LatestPublishedVersionId:h.nullable(),ContentSize:W().int().nonnegative().nullable(),anchored:Q()});function Re(e,n){return I(e,`${y}.${n}.ndjson`)}var Ce=V.extend({now:L({ShareType:T,Visibility:T})});function Fe(e,n){let t=new Set(n.map(r=>r.toLowerCase())),i=new Map;for(let r of e){let a=r.keyPrefix;t.has(r.name.toLowerCase())&&typeof a=="string"&&a.length===3&&i.set(a,r.name)}return i}function Te(e,n){let t=e.LinkedEntityId;return typeof t=="string"&&t.length>=15?n.get(t.slice(0,3)):void 0}function oe(e){return e.map(n=>{if(!h.safeParse(n).success)throw new Error(`Not a record id: ${n}`);return`'${n}'`}).join(", ")}function ce(e){let n=u(e);return{objectApiName:n,soql:`SELECT ${te.join(", ")} FROM ${y} WHERE LinkedEntityId IN (SELECT Id FROM ${n})`,scanAll:!1}}function be(e){let n=u(e);return{objectApiName:n,soql:`SELECT COUNT() FROM ${y} WHERE LinkedEntityId IN (SELECT Id FROM ${n})`,scanAll:!1}}function le(e,n){return{objectApiName:u(e),soql:`SELECT ${te.join(", ")} FROM ${y} WHERE LinkedEntityId IN (${oe(n)})`,scanAll:!1}}function fe(e){return{objectApiName:w,soql:`SELECT ${ae.join(", ")} FROM ${w} WHERE Id IN (${oe(e)})`,scanAll:!1}}async function*v(e,n){let t=[];for await(let i of e)t.push(i),t.length>=n&&(yield t,t=[]);t.length>0&&(yield t)}function*C(e,n){let t=[];for(let i of e)t.push(i),t.length>=n&&(yield t,t=[]);t.length>0&&(yield t)}function G(e,n,t){let i=e.safeParse(n);if(!i.success)throw new Error(`The org answered a ${t} that does not read as one: ${i.error.message}`);return i.data}function F(e){return e.slice(0,15)}async function xe(e){let{reader:n,folder:t,signal:i}=e,r=e.files??S(O(t.dir)),a=I(t.filesDir,de);await se(a,{recursive:!0,mode:Y});let m=z(t),b=A(t);await r.writeFile(m,""),await r.writeFile(b,"");try{let x=new Map,q=0,H=async d=>{for await(let c of v(_(d),B)){let s=c.map(o=>G(V,o,"link"));for(let o of s)x.has(F(o.ContentDocumentId))||x.set(F(o.ContentDocumentId),o.ContentDocumentId);q+=s.length,await r.appendFile(m,s.map(o=>`${JSON.stringify(o)}
|
|
8
8
|
`).join(""))}await M(d,{force:!0})},K=e.linked.map(d=>({...ce(d),file:I(a,`${u(d)}.links.ndjson`)})),re=await R(n,K,i),$=[];for(let[d,c]of re.entries()){if(c.read){await H(K[d].file);continue}let s=e.linked[d];$.push(s);let o=await P.read(t,e.snapshotId,s),l=0;for(let g of C(C(pe(o),ee),ne)){let f=g.map(k=>({...le(s,k),file:I(a,`${u(s)}.links.${l++}.ndjson`)})),N=(await R(n,f,i)).find(k=>!k.read);if(N&&!N.read)throw new Error(`The links of the files of ${s} could not be read whole: ${c.reason}; read by the ids of its records, ${N.reason}`);for(let k of f)await H(k.file)}}let j=0,U=0,Z=new Set;for(let d of C(C(x.values(),ee),ne)){let c=d.map((l,g)=>({...fe(l),file:I(a,`documents.${g}.ndjson`)})),o=(await R(n,c,i)).find(l=>!l.read);if(o&&!o.read)throw new Error(`The files the links name could not be read by their ids: ${o.reason}`);for(let l of c){for await(let g of v(_(l.file),B)){let f=g.map(p=>({...G(J.omit({anchored:!0}),p,"file"),anchored:!0}));for(let p of f)Z.add(F(p.Id));j+=f.length,U+=f.length,await r.appendFile(b,f.map(p=>`${JSON.stringify(p)}
|
|
9
9
|
`).join(""))}await M(l.file,{force:!0})}}if(e.documentsInSnapshot){let d=await P.read(t,e.snapshotId,w);for await(let c of v(d.records(),B)){let s=c.filter(o=>typeof o.Id=="string"&&!Z.has(F(o.Id))).map(o=>({...G(J.omit({anchored:!0}),ue(o),"file"),anchored:!1}));j+=s.length,s.length>0&&await r.appendFile(b,s.map(o=>`${JSON.stringify(o)}
|
|
10
10
|
`).join(""))}}return{documents:j,links:q,anchored:U,...$.length>0?{readByIds:$}:{}}}finally{await M(a,{recursive:!0,force:!0})}}function*pe(e){for(let n=0;n<e.size;n++)yield e.idAt(n)}function ue(e){return{Id:e.Id,LatestPublishedVersionId:e.LatestPublishedVersionId??null,ContentSize:e.ContentSize??null}}async function*ie(e,n,t,i){if(!await e.exists(n))throw new E("damaged",`The checkpoint\u2019s ${i} are not there`);for await(let r of e.readLines(n)){if(r==="")continue;let a;try{a=JSON.parse(r)}catch{throw new E("damaged",`The checkpoint\u2019s ${i} hold a line that is not JSON`)}let m=t.safeParse(a);if(!m.success)throw new E("damaged",`The checkpoint\u2019s ${i} hold a line that does not parse`);yield m.data}}function $e(e,n=S(O(e.dir))){return ie(n,z(e),V,"file links")}function je(e,n=S(O(e.dir))){return ie(n,A(e),J,"files")}export{ee as a,te as b,V as c,Re as d,Ce as e,Fe as f,Te as g,ce as h,be as i,le as j,xe as k,$e as l,je as m};
|
|
@@ -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 R}from"./chunk-DB7JNALQ.mjs";import"./chunk-PE7CHD2W.mjs";import"./chunk-4TLYUZD5.mjs";import{pc as v}from"./chunk-J347SPU6.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";function A(e){return{async retrieve(n){return{id:(await e.metadata.retrieve(n)).id}},checkRetrieveStatus:n=>e.metadata.checkRetrieveStatus(n),async deploy(n,t){return{id:(await e.metadata.deploy(n,t)).id}},checkDeployStatus:(n,t)=>e.metadata.checkDeployStatus(n,t)}}var P={pollMs:3e3,retrieveTimeoutMs:v.retrieve*6e4,deployTimeoutMs:v.deploy*6e4,sleep:e=>new Promise(n=>setTimeout(n,e)),now:Date.now},b=class extends Error{constructor(t,r,s,i){super(t==="deployment"?`Deployment ${r} was still ${s} after ${i} min; it goes on in the target org, and Setup \u203A Deployment Status follows it.`:`Retrieval ${r} was still ${s} after ${i} min; nothing was deployed.`);this.kind=t;this.asyncId=r;this.status=s;this.name="DeploymentStillRunning"}kind;asyncId;status},T=class extends Error{constructor(t,r){super(r?t!==void 0?`Deployment ${t} goes on in the target org, which keeps what it deploys unless it fails and is rolled back whole; SandForge stopped following it, and Setup \u203A Deployment Status follows it.`:"The deployment was on its way to the target org when SandForge stopped following it: if the org took it, it goes on there, and Setup \u203A Deployment Status follows it.":"The deployment was let go of before it was sent: nothing was deployed.");this.deployId=t;this.sent=r;this.name="DeploymentLetGo"}deployId;sent};function N(e,n,t){return n?new Promise((r,s)=>{let i=()=>s(new T(t(),!0));n.aborted?i():n.addEventListener("abort",i,{once:!0}),e.then(u=>{n.removeEventListener("abort",i),r(u)},u=>{n.removeEventListener("abort",i),s(u instanceof Error?u:new Error(String(u)))})}):e}function d(e,n){return`${e}\0${k(n)}`}function k(e){try{return decodeURIComponent(e)}catch{return e}}function g(e){return e==null?[]:Array.isArray(e)?e:[e]}function h(e){return e===!0||e==="true"}function w(e){if(e==null||e==="")return;let n=Number(e);return Number.isFinite(n)?n:void 0}var S=/^Entity of type '(.+?)' named '(.+)' cannot be found$/;async function M(e,n,t,r){let s=new Map;for(let{componentType:l,fullName:m}of t)s.set(l,[...s.get(l)??[],m]);let i={apiVersion:Number(n),singlePackage:!0,unpackaged:{objectPermissions:[],types:[...s].map(([l,m])=>({members:m,name:l})),version:n}},{id:u}=await e.retrieve(i),p=r.now();for(;;){let l=await e.checkRetrieveStatus(u);if(l.done){if(l.success===!1||l.status==="Failed")throw new Error(`Retrieval ${u} from the source failed: ${l.errorMessage??l.status??"no reason given"}`);return l}if(r.now()-p>=r.retrieveTimeoutMs)throw new b("retrieval",u,l.status??"running",Math.round(r.retrieveTimeoutMs/6e4));await r.sleep(r.pollMs)}}async function I(e,n,t,r={}){let s=r.waiting??P;r.onProgress?.({step:"retrieve",done:0,total:t.length});let i=await M(e,n,t,s),u=new Map(t.map(a=>[d(a.componentType,a.fullName),a])),p=new Map,l=[];for(let a of g(i.messages)){let f=a.problem??"",D=S.exec(f),y=D?u.get(d(D[1],D[2])):void 0;y?p.set(d(y.componentType,y.fullName),{...y,problem:f}):f&&l.push(a.fileName?`${a.fileName}: ${f}`:f)}let m=t.filter(a=>!p.has(d(a.componentType,a.fullName))),o=i;m.length===0?o={...i,zipFile:""}:p.size>0&&(o=await M(e,n,m,s)),r.onProgress?.({step:"retrieve",done:m.length,total:t.length});let c=g(o.fileProperties).filter(a=>R(a)).map(a=>u.get(d(a.type??"",a.fullName??""))).filter(a=>a!==void 0);return{zipFile:o.zipFile??"",retrieved:m,missing:[...p.values()],managed:c,problems:l}}function $(e,n,t){return{allowMissingFiles:!1,autoUpdatePackage:!1,checkOnly:e,ignoreWarnings:!1,performRetrieve:!1,purgeOnDelete:!1,rollbackOnError:!0,...n==="RunSpecifiedTests"?{runTests:[...t]}:{},singlePackage:!0,testLevel:n}}async function L(e,n,t,r={}){let s=r.waiting??P,{letGo:i}=r;if(i?.aborted)throw new T(void 0,!1);let u={},p=o=>N(o,i,()=>u.id),{id:l}=await p(e.deploy(n,t));u.id=l;let m=s.now();for(;;){let o=await p(e.checkDeployStatus(l,!1));if(o.done)return p(e.checkDeployStatus(l,!0));if(r.onProgress?.({...C(o),deployId:l}),s.now()-m>=s.deployTimeoutMs)throw new b("deployment",l,o.status??"running",Math.round(s.deployTimeoutMs/6e4));await p(s.sleep(s.pollMs))}}function C(e){let n=e.numberTestsTotal??0,t=e.numberComponentsTotal??0,r=(e.numberComponentsDeployed??0)+(e.numberComponentErrors??0);return n>0&&r>=t?{step:"tests",done:(e.numberTestsCompleted??0)+(e.numberTestErrors??0),total:n}:{step:"components",done:r,total:t}}function F(e){let n=/line (\d+), column \d+/.exec(e??"");return n?Number(n[1]):void 0}function O(e){let n=w(e.lineNumber),t=w(e.columnNumber),r=e.problemType==="Warning"||e.problemType==="Error"?e.problemType:void 0,s={componentType:e.componentType??"",fullName:e.fullName??"",...e.fileName?{fileName:e.fileName}:{}};if(!h(e.success))return{...s,outcome:"failed",...e.problem?{problem:e.problem}:{},...r?{problemType:r}:{},...n!==void 0?{line:n}:{},...t!==void 0?{column:t}:{}};let i=h(e.created)?"created":h(e.changed)?"changed":"unchanged";return{...s,outcome:i}}function W(e,n,t){let r=e?.details??void 0,s=new Map,i=[...g(r?.componentFailures),...g(r?.componentSuccesses)];for(let o of i){if(!o.componentType&&o.fullName==="package.xml")continue;let c=O(o),a=d(c.componentType,c.fullName);s.has(a)||s.set(a,c)}let u=n.missing.map(o=>({componentType:o.componentType,fullName:o.fullName,outcome:"not_retrieved",...o.problem?{problem:o.problem}:{}})),p=r?.runTestResult??void 0,l=g(p?.failures).map(o=>{let c=F(o.stackTrace);return{className:o.name??"",...o.methodName?{methodName:o.methodName}:{},message:o.message??"",...o.stackTrace?{stackTrace:o.stackTrace}:{},...c!==void 0?{line:c}:{}}}),m=g(p?.codeCoverageWarnings).map(o=>o.name?`${o.name}: ${o.message??""}`:o.message??"").filter(o=>o!=="");return{...e?.id?{deployId:e.id}:{},checkOnly:t.checkOnly,status:e?.status??"NotStarted",success:e?.success===!0&&n.missing.length===0,...e?.errorMessage?{errorMessage:e.errorMessage}:{},sourceOrgId:t.sourceOrgId,targetOrgId:t.targetOrgId,testLevel:t.testLevel,runTests:[...t.runTests],components:[...s.values(),...u],counts:{componentsTotal:e?.numberComponentsTotal??0,componentsDeployed:e?.numberComponentsDeployed??0,componentErrors:e?.numberComponentErrors??0,testsTotal:e?.numberTestsTotal??0,testsCompleted:e?.numberTestsCompleted??0,testErrors:e?.numberTestErrors??0},testFailures:l,coverageWarnings:m,...n.problems.length>0?{retrieveProblems:[...n.problems]}:{},...e?.startDate?{startedAt:e.startDate}:{},...e?.completedDate?{completedAt:e.completedDate}:{}}}export{P as DEFAULT_WAITING,T as DeploymentLetGo,b as DeploymentStillRunning,$ as deployOptions,L as deployPackage,W as deploymentReport,A as metadataApiOf,I as retrieveComponents};
|
|
@@ -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{Kb as h,Nb as D,Ob as R,kd as O}from"./chunk-J347SPU6.mjs";function P(t,f){return t.previousOrganizationId??(t.organizationId===void 0?f?.(t.orgId):void 0)??t.detectedAt}function x(t){let f=(i,s)=>{let o=R.safeParse(t.configStore.get(D(i,P(s,t.organizationIdOf))));return o.success&&o.data.finishedAt!==void 0};return{progressOf(i){let s=t.orgOf(i);if(s?.orgType!=="Sandbox")return;let[o]=t.refreshesOf(i);if(!(o===void 0||f(i,o)))return{orgId:i,alias:O(s,s.username),detectedAt:o.detectedAt,done:0,total:h}}}}var b=3e4;function A(t){let f=x(t),i=t.ttlMs??b,s=t.now??(()=>Date.now()),o=new Map,g=new Map,a=new Map,u=new Set,l=new Set,p=()=>{for(let e of[...l])try{e()}catch(r){t.log?.(`[recovery] a listener of the progress failed: ${String(r)}`)}},v=(e,r)=>{if(u.has(e))return;let n=g.get(e);if(n!==void 0&&s()-n<i)return;let c=a.get(e)??0;u.add(e),t.statusOf(e).then(d=>{if(u.delete(e),g.delete(e),(a.get(e)??0)!==c){v(e,r);return}let S=o.get(e),m=S!==void 0&&S.detectedAt===r.detectedAt?S:r;if(d===void 0){o.delete(e);return}o.set(e,{...d,detectedAt:r.detectedAt,at:s()}),(m.done!==d.done||m.total!==d.total)&&p()},d=>{u.delete(e),g.set(e,s()),t.log?.(`[recovery] the steps of ${e} could not be deduced: ${d instanceof Error?d.message:String(d)}`)})};return{progressOf(e){let r=f.progressOf(e);if(r===void 0)return;let n=o.get(e),c=n!==void 0&&n.detectedAt===r.detectedAt;return(!c||s()-n.at>=i)&&v(e,r),c?{...r,done:n.done,total:n.total}:r},onDidChange(e){return l.add(e),{dispose:()=>l.delete(e)}},invalidate(e){let r=e!==void 0?[e]:[...o.keys()];for(let n of r){a.set(n,(a.get(n)??0)+1),g.delete(n);let c=o.get(n);c!==void 0&&o.set(n,{...c,at:Number.NEGATIVE_INFINITY})}p()}}}export{P as a,A 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 g,$b as ga,Ab as H,Ac as Ha,Bb as I,Bc as Ia,Cb as J,Cc as Ja,Db as K,Dc as Ka,Eb as L,Ec as La,Fb as M,Fc as Ma,Gb as N,Gc as Na,Hb as O,Hc as Oa,Ib as P,Ic as Pa,Jb as Q,Jc as Qa,Kb as R,Kc as Ra,Lb as S,Lc as Sa,Mb as T,Mc as Ta,Nb as U,Nc as Ua,Ob as V,Oc as Va,Pb as W,Pc as Wa,Qb as X,Qc as Xa,Rb as Y,Rc as Ya,Sb as Z,Sc as Za,Tb as _,Tc as _a,Ub as $,Uc as $a,Va as a,Vb as aa,Vc as ab,Wa as b,Wb as ba,Wc as bb,Xa as c,Xb as ca,Xc as cb,Ya as d,Yb as da,Yc as db,Za as e,Zb as ea,Zc as eb,_a as f,_b as fa,ab as h,ac as ha,bb as i,bc as ia,cb as j,cc as ja,db as k,dc as ka,eb as l,ec as la,fb as m,fc as ma,gb as n,gc as na,hb as o,hc as oa,ib as p,ic as pa,jb as q,jc as qa,kb as r,kc as ra,lb as s,lc as sa,mb as t,mc as ta,nb as u,nc as ua,ob as v,oc as va,pb as w,pc as wa,qb as x,qc as xa,rb as y,rc as ya,sb as z,sc as za,tb as A,tc as Aa,ub as B,uc as Ba,vb as C,vc as Ca,wb as D,wc as Da,xb as E,xc as Ea,yb as F,yc as Fa,zb as G,zc as Ga}from"./chunk-OLCS7JCT.mjs";import"./chunk-TQ6HEJ73.mjs";import"./chunk-65AMXOQU.mjs";import"./chunk-6HHSAPIM.mjs";import"./chunk-K5PUMHZU.mjs";import"./chunk-EUIALBMX.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-Q7TLC3I2.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-ATBQIE2V.mjs";import"./chunk-UCUFLFNK.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-DAUX63UB.mjs";import"./chunk-SZOJ7BEJ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-22L43JMK.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-J347SPU6.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{z as API_BUDGET_EXCEEDED,v as API_BUDGET_NEAR_SHARE,s as API_REQUESTS_NOT_TOLD,M as BULK_BATCHES_NOT_TOLD,C as CHECKPOINT_REFUSED,F as CHECKPOINT_STOPPED_WORDS,a as DEFAULT_CONFIRM_ABOVE_RECORDS,b as DEFAULT_MAX_TOTAL,aa as DELIVERABILITY_READ_MOST,la as DEVELOPER_EDITION_SINGLE_EMAILS,za as EMAILS_NOT_ACCEPTED,Ua as ForgeRunGateError,m as LastSimulations,Sa as OWNER_MAP_INACTIVE,Ta as OWNER_MAP_UNKNOWN,c as READ_CEILING_PER_OBJECT,da as SAMPLE_CANNOT_FIT,ga as SAMPLE_PLAN_GONE,fa as SAMPLE_PLAN_MISMATCH,ca as SAMPLE_STORAGE_UNREAD,ea as SAMPLE_TOO_LARGE,e as STORAGE_NEAR_SHARE,f as STORAGE_ROUNDING_MARGIN_MB,J as WHOLE_ORG_SOURCE_READS_PER_OBJECT,I as WHOLE_ORG_TARGET_READS_PER_OBJECT,ma as alertsCountAsSingle,y as apiBudgetCheckOf,A as apiBudgetRefusal,X as automationBytesOf,Ba as automationReadRequests,ab as automationRefusal,Ra as automationUnreadOf,N as bulkBatchesRefusal,$a as bypassAssistantSentences,Qa as bypassesToAssign,D as checkpointPartOf,E as checkpointScopeStop,B as confirmationApiOf,o as confirmationSimulatedOf,Ia as confirmationStorageOf,qa as countedEmailChecksOf,i as countedStorageBytes,ra as countedTargetEmails,Ha as deliverabilityAfterLeaseStop,Ea as deliverabilityGate,Da as deliverabilityLineOf,Ca as deliverabilityPartOf,ya as emailCheckLines,pa as emailChecksOf,xa as emailRefusal,oa as emailsCountedPerRecord,wa as emailsOfLimit,ta as emailsUncountedOf,n as farPastTheSimulation,P as fileStorageRefusal,Wa as filesRefusalStop,La as firedOnInsertOf,Ma as firedOnUpdateOf,K as forgeRequestPartsOf,l as forgeVolumeCaseKey,T as forgeWriteBudgetOf,H as forgeWritesOf,Ja as formatMB,Ka as formatMBPast,sa as insertsOf,Va as isForgeRunGateError,Za as leftOutLines,r as limitsOfOrg,d as objectsAboveReadCeiling,Na as objectsUpdatedAfterInsert,ua as overEmailOf,_ as personalFieldsAsIsOf,p as pricesForLinesOf,u as readApiBudget,Q as readBoundRefusal,R as readBoundStopOf,t as readDataStorage,ka as readEmailLimits,cb as removalAutomationLines,bb as removalAutomationRefusal,_a as removalRiskLines,db as removalStepsAutomationLines,eb as removalStepsAutomationRefusal,q as rolesMayBeOf,j as rowBytesOf,h as rowStorageBytes,Pa as runBypassesOf,w as runRequestsEstimate,x as runRequestsTotal,ja as sampleGateErrorOf,ia as sampleGateStopOf,ha as sampleStorageUnreadStopOf,Fa as sendersOfNothingWritten,Ga as sendersOfNothingWrittenLine,Aa as sendersUnreadOf,na as singleCountAsWorkflow,O as sourceApiBudgetRefusal,U as storageCheckOf,V as storageCountedOf,W as storageCountedWords,Xa as storageRefusal,g as storageRoomMB,Y as storageTakesWords,G as takeCheckpointFirst,va as unreadEmailOf,Oa as updateStepsOf,L as wholeOrgCostOf,ba as wholeOrgDryRunOf,S as wholeOrgFilesOf,$ as wholeOrgLeftOutOf,Z as wholeOrgWritePlanOf,Ya as writePlanLines,k as writePlanOf};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e}from"./chunk-HLROVOR6.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-J347SPU6.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as AIDataGenerator,c as buildPrompt,d as parseAIResponse,b as phoneReplacement,e as reachNobody};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{A as y,B as z,C as A,D as B,E as C,F as D,G as E,H as F,I as G,J as H,K as I,L as J,M as K,N as L,O as M,P as N,Q as O,c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i,l as j,m as k,n as l,o as m,p as n,q as o,r as p,s as q,t as r,u as s,v as t,w as u,x as v,y as w,z as x}from"./chunk-
|
|
7
|
+
import{A as y,B as z,C as A,D as B,E as C,F as D,G as E,H as F,I as G,J as H,K as I,L as J,M as K,N as L,O as M,P as N,Q as O,c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i,l as j,m as k,n as l,o as m,p as n,q as o,r as p,s as q,t as r,u as s,v as t,w as u,x as v,y as w,z as x}from"./chunk-4CSBZZAL.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-22L43JMK.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-J347SPU6.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as CHECKPOINT_DIR_MODE,b as CHECKPOINT_FILE_MODE,r as CHECKPOINT_FILE_PATH,F as CheckpointStoreError,c as DEFAULT_KEEP_DAYS,d as EXPIRY_WARNING_DAYS,K as OrgCheckpointStore,f as PREVIEW_KEEP_MS,e as RECYCLE_BIN_DAYS,q as REPLAY_ANNEX_PATH,N as acquireOrgLock,m as binFileOf,C as binReachSince,I as compressedFieldPrints,h as defaultCheckpointLocksDir,g as defaultCheckpointStoreRoot,z as expiresAtFor,B as expiresSoon,u as exportedFileIn,t as exportedFilesOf,n as filesDocumentsFileOf,o as filesLinksFileOf,j as indexFileOf,A as isExpired,s as isExportedPath,L as latestRewindOf,x as makePrivateDir,y as newFolderId,l as notInBinFileOf,J as openCheckpointStore,M as orgLockFileOf,O as orgLockHolder,i as organizationKey,v as previewDirOf,H as readFieldPrints,k as recreatedFileOf,p as replayAnnexFileOf,w as rewindDirOf,D as scratchOrgExpired,E as scratchOrgExpiresSoon,G as storeRefusalWords};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{d as f}from"./chunk-
|
|
7
|
+
import{d as f}from"./chunk-VUTQY76O.mjs";import{pb as i,qb as d}from"./chunk-J347SPU6.mjs";import{m as u,z as c}from"./chunk-WZQEK4WT.mjs";function w(e){let s=new Set,r=new Set;for(let t of e)for(let n of t.users){let o=i(n.applied.username);s.has(o)||(s.add(o),n.applied.address==="awaiting"&&r.add(o))}return r}function v(e,s){return e.map(r=>({username:r.username,userId:r.userId,address:r.address==="valid"?"restored":s.has(i(r.username))?"awaiting":"invalid",active:r.active,frozen:r.frozen,...r.profile!==void 0?{profile:r.profile}:{}}))}var l="recovery";function O(e,s){return e!==void 0?`recoveryTesters:host:${e}`:`recoveryTesters:entry:${s}`}var g=u({config:d,savedAt:c.datetime({offset:!0})});function A(e,s){let r=g.safeParse(e.get(s));return r.success?r.data:void 0}function P(e,s,r,t){let n={config:r,savedAt:t.toISOString()};return e.set(s,n,l),n}var m="USERS_RUN_NOT_FOUND",U="USERS_RUN_REPLACED";async function x(e,s,r){let t=await e.read(s,r);if(!t)return{refusal:{code:m,message:`Run ${r} is not kept on this machine for this org, whose Organization Id is ${s}: a sandbox refreshed since answers another, and its runs went with the copy they set up. Simulate without it to set the users up anew.`}};let n=(await e.list(s)).find(o=>o.replaces===r);return n?{refusal:{code:U,message:`Run ${r} was replaced by run ${n.run}, which holds what it set up: simulate again, replacing run ${n.run}.`}}:{record:t}}function C(e){return JSON.stringify([e.orgId,e.config,e.replaces??null,e.acceptUserEmails,e.acceptEmails,e.acceptAutomation])}function T(e){return JSON.stringify({org:e.org.organizationId,users:e.users.map(s=>[s.username,s.userId??null,s.address??null,s.changes,s.emailsToPeople??0]),licenses:(e.licenses??[]).map(s=>[s.name,s.toUse]),emailsToPeople:e.emailsToPeople,refusals:(e.refusals??[]).map(s=>[s.code,s.username??null])})}function b(e){return e.users.filter(s=>s.changes.length>0).length}function E(e,s){let r=new Map(s.users.filter(n=>n.changes.length>0).map(n=>[i(n.username),n.changes.length])),t=0;for(let n of e.users){let o=r.get(i(n.applied.username));if(o===void 0)continue;n.applied.done.length+(n.applied.refused?.length??0)>=o&&(t+=1)}return t}function a(e){return e.what==="frozen"?"UserLogin":e.what==="group"?"GroupMember":e.what==="permissionSet"||e.what==="permissionSetGroup"?"PermissionSetAssignment":"User"}function j(e){let s=new Map(["User","UserLogin","PermissionSetAssignment","GroupMember"].map(t=>[t,{objectApiName:t,created:0,updated:0,deleted:0,failed:0}])),r=t=>s.get(t);for(let t of e.users){let n=new Set(t.done.filter(o=>!("name"in o)).map(o=>a(o)));for(let o of n)r(o).updated+=1;r("PermissionSetAssignment").created+=t.created.permissionSetAssignments.length,r("GroupMember").created+=t.created.groupMembers.length;for(let o of t.done)"name"in o&&o.to==="removed"&&(r(a(o)).deleted+=1);for(let o of t.refused??[])r(a(o.change)).failed+=1}return[...s.values()].filter(t=>t.created+t.updated+t.deleted+t.failed>0)}var p=class extends f{constructor(r,t){super(r);this.onWrite=t}onWrite;async write(r){await super.write(r),this.onWrite(r)}};export{w as a,v as b,l as c,O as d,g as e,A as f,P as g,m as h,U as i,x as j,C as k,T as l,b as m,E as n,j as o,p};
|