sandforge 1.84.1 → 1.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/{chunk-S42RBRH2.mjs → chunk-22L43JMK.mjs} +1 -1
- package/lib/{chunk-Y2DRK37K.mjs → chunk-2LSGWTWX.mjs} +1 -1
- package/lib/{chunk-24RFOFYT.mjs → chunk-2YJJTQNC.mjs} +1 -1
- package/lib/chunk-34SMB5PA.mjs +10 -0
- package/lib/chunk-35B73566.mjs +7 -0
- package/lib/{chunk-3TZSBHEY.mjs → chunk-35IJ4WEU.mjs} +1 -1
- package/lib/chunk-3EHPAFKV.mjs +7 -0
- package/lib/{chunk-6YL7BNYD.mjs → chunk-3HAVVEXF.mjs} +1 -1
- package/lib/{chunk-6JWWSDM6.mjs → chunk-3I6FXFCN.mjs} +1 -1
- package/lib/{chunk-WUUKFE2U.mjs → chunk-3KJCSYXY.mjs} +1 -1
- package/lib/{chunk-2HVOZUM4.mjs → chunk-3L6DVNCR.mjs} +1 -1
- package/lib/chunk-3LRFPGYZ.mjs +7 -0
- package/lib/{chunk-GWZRR3MM.mjs → chunk-3MVWGL5A.mjs} +1 -1
- package/lib/{chunk-KGU4SVIT.mjs → chunk-4CSBZZAL.mjs} +1 -1
- package/lib/{chunk-JE6SCT6R.mjs → chunk-4NSXPONF.mjs} +1 -1
- package/lib/{chunk-UIOMAX56.mjs → chunk-4VLP6RHC.mjs} +1 -1
- package/lib/{chunk-YA6ATMTB.mjs → chunk-4XROG5CT.mjs} +1 -1
- package/lib/chunk-54V4FVEY.mjs +7 -0
- package/lib/chunk-55OJJT2Q.mjs +7 -0
- package/lib/{chunk-6QE6R6RL.mjs → chunk-5EHHQ5UX.mjs} +1 -1
- package/lib/{chunk-FITPY3L4.mjs → chunk-5JMQXHJ2.mjs} +1 -1
- package/lib/{chunk-W6PN6TJG.mjs → chunk-65AMXOQU.mjs} +1 -1
- package/lib/{chunk-3Q353S2R.mjs → chunk-6HHSAPIM.mjs} +1 -1
- package/lib/chunk-6KVBCFVS.mjs +7 -0
- package/lib/chunk-6NG7C2U3.mjs +476 -0
- package/lib/chunk-6ROL3KBM.mjs +7 -0
- package/lib/{chunk-2JDAOWUW.mjs → chunk-72AWCN7U.mjs} +1 -1
- package/lib/{chunk-JLSIWO4Z.mjs → chunk-7KHA5UIQ.mjs} +1 -1
- package/lib/chunk-7O6EFNQS.mjs +10 -0
- package/lib/{chunk-WWTCWWZI.mjs → chunk-A2CH2QGX.mjs} +1 -1
- package/lib/chunk-A2TXLAC3.mjs +276 -0
- package/lib/chunk-ALWVNR34.mjs +7 -0
- package/lib/{chunk-D4GF4FAB.mjs → chunk-ATBQIE2V.mjs} +1 -1
- package/lib/{chunk-NED4MBIM.mjs → chunk-ATQML7ZK.mjs} +1 -1
- package/lib/chunk-AVY742BJ.mjs +7 -0
- package/lib/{chunk-YWEQQL3C.mjs → chunk-AXTB2HJS.mjs} +1 -1
- package/lib/chunk-BBZUGKBZ.mjs +10 -0
- package/lib/chunk-BIDXK7KA.mjs +7 -0
- package/lib/{chunk-O677VOGO.mjs → chunk-BLMJ4WVI.mjs} +1 -1
- package/lib/{chunk-RE7RYF3B.mjs → chunk-BNHJCJJM.mjs} +1 -1
- package/lib/{chunk-5M5FQ7RP.mjs → chunk-BNPQEQXC.mjs} +1 -1
- package/lib/chunk-C5AUNG6T.mjs +37 -0
- package/lib/{chunk-ETDCBLGU.mjs → chunk-C5EQ7GFC.mjs} +1 -1
- package/lib/{chunk-MJZU3U5O.mjs → chunk-C7CKDZMC.mjs} +61 -61
- package/lib/{chunk-HCGXK7G7.mjs → chunk-CB4U22NR.mjs} +1 -1
- package/lib/chunk-CJAWKLAL.mjs +7 -0
- package/lib/chunk-CL75DEMQ.mjs +9 -0
- package/lib/{chunk-VCUXCK36.mjs → chunk-CLUNF4FK.mjs} +1 -1
- package/lib/chunk-CSMGP53U.mjs +7 -0
- package/lib/{chunk-7YNM6KFZ.mjs → chunk-CT324C7I.mjs} +1 -1
- package/lib/{chunk-7UVKIWKV.mjs → chunk-CZXDJXQP.mjs} +1 -1
- package/lib/{chunk-43TOMFV4.mjs → chunk-D2X6U3MS.mjs} +1 -1
- package/lib/{chunk-M6K34KGF.mjs → chunk-DAUX63UB.mjs} +1 -1
- package/lib/chunk-DB7JNALQ.mjs +10 -0
- package/lib/chunk-DDNCJVZ2.mjs +17 -0
- package/lib/{chunk-FP7CYB2F.mjs → chunk-DLSU66MY.mjs} +1 -1
- package/lib/{chunk-JKJ74BX5.mjs → chunk-DO6PSHQZ.mjs} +1 -1
- package/lib/{chunk-MDMPJEV3.mjs → chunk-DUBECLZV.mjs} +1 -1
- package/lib/{chunk-KZTZDC7H.mjs → chunk-DYHF6DNT.mjs} +1 -1
- package/lib/chunk-E5FSPXYH.mjs +930 -0
- package/lib/{chunk-Q7GIJBCD.mjs → chunk-EGL3I3IX.mjs} +1 -1
- package/lib/chunk-EIYMQPMG.mjs +7 -0
- package/lib/{chunk-RHNTHGNU.mjs → chunk-EUIALBMX.mjs} +1 -1
- package/lib/{chunk-NCZKWSC7.mjs → chunk-FI3R5ZOQ.mjs} +1 -1
- package/lib/{chunk-PAXNWTYK.mjs → chunk-FM4QCTO7.mjs} +1 -1
- package/lib/{chunk-HV7VPEXP.mjs → chunk-FRSIEASH.mjs} +1 -1
- package/lib/{chunk-QAFPQ3YB.mjs → chunk-FV6MOSHD.mjs} +1 -1
- package/lib/chunk-FYG47CNA.mjs +7 -0
- package/lib/chunk-GB6W4Q56.mjs +7 -0
- package/lib/chunk-GEV2DCMK.mjs +7 -0
- package/lib/{chunk-NSQWI7ZY.mjs → chunk-GFB2DNCB.mjs} +1 -1
- package/lib/chunk-GFGMGFSH.mjs +7 -0
- package/lib/{chunk-RGUQOSBU.mjs → chunk-GIFQXB2Q.mjs} +1 -1
- package/lib/{chunk-JAEDM4SI.mjs → chunk-GP5J3DGS.mjs} +1 -1
- package/lib/chunk-GQZEX7LH.mjs +231 -0
- package/lib/{chunk-JSAJS3MY.mjs → chunk-GYDTM62J.mjs} +1 -1
- package/lib/{chunk-OPMO6I45.mjs → chunk-GYFIXUJG.mjs} +1 -1
- package/lib/chunk-GZW2GNFK.mjs +7 -0
- package/lib/chunk-H6BHWAX7.mjs +8 -0
- package/lib/{chunk-EAC5QCE3.mjs → chunk-HDDJ3CVN.mjs} +1 -1
- package/lib/{chunk-5SMWFNE7.mjs → chunk-HDWB4ZOG.mjs} +1 -1
- package/lib/chunk-HGVPBJR6.mjs +7 -0
- package/lib/{chunk-BBRWFKS5.mjs → chunk-HLROVOR6.mjs} +1 -1
- package/lib/{chunk-LKTNQEBS.mjs → chunk-HUOR4M2L.mjs} +1 -1
- package/lib/chunk-HZCS6EED.mjs +8 -0
- package/lib/{chunk-36JOHEJL.mjs → chunk-HZUI56KZ.mjs} +1 -1
- package/lib/chunk-IAB5H7WN.mjs +7 -0
- package/lib/{chunk-X4BXESMQ.mjs → chunk-IQ5UKRHU.mjs} +1 -1
- package/lib/{chunk-54WZUS7J.mjs → chunk-IRQ4WANV.mjs} +1 -1
- package/lib/{chunk-5IZTFMJM.mjs → chunk-IT3DGX37.mjs} +1 -1
- package/lib/chunk-J347SPU6.mjs +49 -0
- package/lib/{chunk-QO53K5W2.mjs → chunk-JANBNTR5.mjs} +1 -1
- package/lib/chunk-JFXQZPRY.mjs +9 -0
- package/lib/{chunk-KAZS5Z6W.mjs → chunk-JRLYWVF4.mjs} +1 -1
- package/lib/{chunk-GKY2JMHY.mjs → chunk-JSNMUTY6.mjs} +1 -1
- package/lib/chunk-JTNJKSAA.mjs +7 -0
- package/lib/{chunk-7WATA4SB.mjs → chunk-JV2LAKWQ.mjs} +1 -1
- package/lib/{chunk-WAPSSYMT.mjs → chunk-JV7K2ZHK.mjs} +1 -1
- package/lib/{chunk-ZBAWJUG2.mjs → chunk-K4TQ7YHX.mjs} +1 -1
- package/lib/chunk-K5PUMHZU.mjs +7 -0
- package/lib/chunk-KH4KLCYG.mjs +7 -0
- package/lib/{chunk-OLCVHL7I.mjs → chunk-KQVLZVOP.mjs} +1 -1
- package/lib/chunk-KWUS7UAV.mjs +19 -0
- package/lib/{chunk-JGZPD4IM.mjs → chunk-L6G73FXM.mjs} +1 -1
- package/lib/{chunk-BAWCOKRW.mjs → chunk-LG466Q5H.mjs} +1 -1
- package/lib/{chunk-GMIGWR6U.mjs → chunk-LHNAR6FC.mjs} +1 -1
- package/lib/chunk-LT4GHEI2.mjs +7 -0
- package/lib/{chunk-EC72TIEG.mjs → chunk-MR262Y3B.mjs} +1 -1
- package/lib/{chunk-LA4KIATH.mjs → chunk-NCCHOV2N.mjs} +1 -1
- package/lib/chunk-NICRSGLS.mjs +7 -0
- package/lib/chunk-NV5QA2HY.mjs +7 -0
- package/lib/{chunk-PR3XCSPO.mjs → chunk-O3GIN5TU.mjs} +1 -1
- package/lib/chunk-O6FHK6NQ.mjs +13 -0
- package/lib/{chunk-M4BLK6HJ.mjs → chunk-O7YIEFG7.mjs} +1 -1
- package/lib/chunk-OCUVAA5E.mjs +7 -0
- package/lib/chunk-OLCS7JCT.mjs +14 -0
- package/lib/chunk-ON7Y63FK.mjs +9 -0
- package/lib/{chunk-N4WPCWJO.mjs → chunk-OO2WY3UB.mjs} +1 -1
- package/lib/{chunk-MSIEU5MR.mjs → chunk-OT2NHL2V.mjs} +1 -1
- package/lib/{chunk-6WX5ZU7Q.mjs → chunk-P2M5ZXWU.mjs} +1 -1
- package/lib/{chunk-GNRSF65U.mjs → chunk-P4YOHLZ4.mjs} +1 -1
- package/lib/chunk-PBHDPTT6.mjs +343 -0
- package/lib/chunk-PE7CHD2W.mjs +7 -0
- package/lib/{chunk-PBY2O6OF.mjs → chunk-PIQ2I67B.mjs} +1 -1
- package/lib/chunk-PKYDNZJK.mjs +7 -0
- package/lib/chunk-PVZ72OOQ.mjs +7 -0
- package/lib/chunk-QACFTHJM.mjs +8 -0
- package/lib/{chunk-J3DND3BC.mjs → chunk-QGVL5EW3.mjs} +1 -1
- package/lib/chunk-QHE2RUWX.mjs +7 -0
- package/lib/{chunk-QKEKG2LD.mjs → chunk-RCW5BZNW.mjs} +1 -1
- package/lib/{chunk-4JE4BYXK.mjs → chunk-RJ6HHG7J.mjs} +1 -1
- package/lib/{chunk-ZQWIVYVM.mjs → chunk-RPTEEI4R.mjs} +1 -1
- package/lib/chunk-RQW5S67A.mjs +7 -0
- package/lib/chunk-RTCMYMED.mjs +7 -0
- package/lib/chunk-RWVX7XSD.mjs +7 -0
- package/lib/{chunk-WY5V5PR3.mjs → chunk-RZOINFNL.mjs} +1 -1
- package/lib/chunk-SOOTWGMQ.mjs +7 -0
- package/lib/chunk-STQ2JMIZ.mjs +7 -0
- package/lib/{chunk-6PD6K7LP.mjs → chunk-SUIPDW5O.mjs} +1 -1
- package/lib/{chunk-TNT27RBG.mjs → chunk-SZOJ7BEJ.mjs} +1 -1
- package/lib/{chunk-4EOHEDFP.mjs → chunk-T542Z54E.mjs} +1 -1
- package/lib/chunk-TAN2CIRI.mjs +21 -0
- package/lib/{chunk-A3MYSOOC.mjs → chunk-TCNBINOG.mjs} +1 -1
- package/lib/chunk-TFDF3DBN.mjs +7 -0
- package/lib/chunk-TICZXC53.mjs +9 -0
- package/lib/chunk-TLX45X5U.mjs +7 -0
- package/lib/{chunk-QTG6LUZT.mjs → chunk-TMIV3IWH.mjs} +1 -1
- package/lib/chunk-TQ6HEJ73.mjs +11 -0
- package/lib/chunk-TTU5EQZ6.mjs +7 -0
- package/lib/chunk-TYUYPFDJ.mjs +7 -0
- package/lib/chunk-TZXYVMZC.mjs +7 -0
- package/lib/chunk-UCUFLFNK.mjs +7 -0
- package/lib/chunk-UK3QLBHW.mjs +7 -0
- package/lib/{chunk-IZGCEOYO.mjs → chunk-UM2B4GR7.mjs} +1 -1
- package/lib/chunk-UZFTTNOP.mjs +7 -0
- package/lib/chunk-V3AXSKSU.mjs +7 -0
- package/lib/chunk-VA6EEI6X.mjs +21 -0
- package/lib/{chunk-OFTT7J2M.mjs → chunk-VFKG2G37.mjs} +1 -1
- package/lib/chunk-VJNEW5MQ.mjs +7 -0
- package/lib/{chunk-L53JWJ3S.mjs → chunk-VKREON6Q.mjs} +1 -1
- package/lib/{chunk-NOBQTEQD.mjs → chunk-VNNDYPBL.mjs} +1 -1
- package/lib/{chunk-ZJW6YOMV.mjs → chunk-VRBETPHY.mjs} +1 -1
- package/lib/{chunk-EPFCERGL.mjs → chunk-VT6P3X6R.mjs} +1 -1
- package/lib/{chunk-ZV7ZFQQC.mjs → chunk-VUTQY76O.mjs} +1 -1
- package/lib/chunk-WF5S4FW5.mjs +7 -0
- package/lib/{chunk-Z4LKKOFY.mjs → chunk-WJGK6VGU.mjs} +1 -1
- package/lib/{chunk-5CRLRHOJ.mjs → chunk-WJHMB3SL.mjs} +1 -1
- package/lib/{chunk-OUZQPYT3.mjs → chunk-WQCXOZEJ.mjs} +1 -1
- package/lib/{chunk-L2E5WBGD.mjs → chunk-WVVFR4E3.mjs} +1 -1
- package/lib/{chunk-PWRJRL5U.mjs → chunk-XBYXT74L.mjs} +1 -1
- package/lib/chunk-XJE3LJHP.mjs +7 -0
- package/lib/{chunk-CPQIZGG5.mjs → chunk-XV4CVZYD.mjs} +1 -1
- package/lib/chunk-Y37ED7AS.mjs +7 -0
- package/lib/{chunk-YTLUYSMF.mjs → chunk-YGBNZYT4.mjs} +1 -1
- package/lib/{chunk-4CVUUVGJ.mjs → chunk-YGTOX7IL.mjs} +1 -1
- package/lib/{chunk-OMNMLKDT.mjs → chunk-YJ27WHKR.mjs} +1 -1
- package/lib/chunk-YRULC27A.mjs +7 -0
- package/lib/{chunk-RMFU4BAL.mjs → chunk-YSVAHT4Q.mjs} +4 -4
- package/lib/chunk-YTOTMJTY.mjs +15 -0
- package/lib/{chunk-B63POIPQ.mjs → chunk-YZKZC62O.mjs} +1 -1
- package/lib/{chunk-DPMRIMUC.mjs → chunk-YZQN7BRB.mjs} +1 -1
- package/lib/{chunk-7SQSWVAU.mjs → chunk-Z5IUK2QO.mjs} +1 -1
- package/lib/{chunk-M2ABR4JM.mjs → chunk-ZEGSMW5A.mjs} +1 -1
- package/lib/{chunk-PR42EZSR.mjs → chunk-ZIKLQZBG.mjs} +1 -1
- package/lib/chunk-ZVU7MD2S.mjs +7 -0
- package/lib/sandforge-autopilot.mjs +33 -27
- package/lib/sandforge-backup.mjs +19 -19
- package/lib/sandforge-checkpoint.mjs +1 -1
- package/lib/sandforge-cleanup.mjs +1 -1
- package/lib/sandforge-clone.mjs +1 -1
- package/lib/sandforge-compare.mjs +32 -14
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +11 -13
- package/lib/sandforge-env.mjs +105 -105
- package/lib/sandforge-frozen.mjs +1 -1
- package/lib/sandforge-mcp.mjs +2 -2
- package/lib/sandforge-monitor.mjs +1 -1
- package/lib/sandforge-pipeline.mjs +13 -13
- package/lib/sandforge-seed.mjs +1 -1
- package/lib/sandforge-sync.mjs +1 -1
- package/lib/sandforge-users.mjs +13 -15
- package/lib/sandforge.mjs +1 -1
- package/lib/sf/sandforge/dataops.mjs +2 -2
- package/lib/sfPlugin.mjs +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/lib/chunk-23SEDORH.mjs +0 -11
- package/lib/chunk-26POJDIT.mjs +0 -7
- package/lib/chunk-2AZQHBEF.mjs +0 -7
- package/lib/chunk-2METQHGG.mjs +0 -7
- package/lib/chunk-2WFIVO4F.mjs +0 -13
- package/lib/chunk-2YHZBUZE.mjs +0 -7
- package/lib/chunk-326AJTIU.mjs +0 -272
- package/lib/chunk-3PVRGTVK.mjs +0 -7
- package/lib/chunk-5XTUSN72.mjs +0 -8
- package/lib/chunk-6I6TWNV5.mjs +0 -7
- package/lib/chunk-6O222PW6.mjs +0 -7
- package/lib/chunk-6ZLKIT3H.mjs +0 -7
- package/lib/chunk-7QYHEHMA.mjs +0 -9
- package/lib/chunk-B3FBHVNN.mjs +0 -21
- package/lib/chunk-BEA27DLS.mjs +0 -7
- package/lib/chunk-BRY3PLIZ.mjs +0 -7
- package/lib/chunk-CBH3TOWK.mjs +0 -341
- package/lib/chunk-CVHNXJH3.mjs +0 -7
- package/lib/chunk-DGDRQRCW.mjs +0 -7
- package/lib/chunk-DUN2EPRC.mjs +0 -7
- package/lib/chunk-E3A3LOCY.mjs +0 -7
- package/lib/chunk-F2424IKX.mjs +0 -7
- package/lib/chunk-F3AQW6IU.mjs +0 -7
- package/lib/chunk-FNJ4SGWO.mjs +0 -7
- package/lib/chunk-GOOVPVWX.mjs +0 -7
- package/lib/chunk-H2BHESDA.mjs +0 -9
- package/lib/chunk-H4CGM6YO.mjs +0 -7
- package/lib/chunk-HIDW7FNV.mjs +0 -9
- package/lib/chunk-HSBXRQTI.mjs +0 -7
- package/lib/chunk-HUZPBE47.mjs +0 -7
- package/lib/chunk-I6E6T6YY.mjs +0 -7
- package/lib/chunk-IUM4NFKI.mjs +0 -10
- package/lib/chunk-IVFVNNGB.mjs +0 -37
- package/lib/chunk-JCFBFF4Y.mjs +0 -7
- package/lib/chunk-JTJK2D36.mjs +0 -7
- package/lib/chunk-KB4ZHM4Q.mjs +0 -10
- package/lib/chunk-KJWFYBMU.mjs +0 -15
- package/lib/chunk-LC3NDW4N.mjs +0 -7
- package/lib/chunk-OM5NORJG.mjs +0 -7
- package/lib/chunk-OVNMB6Q2.mjs +0 -7
- package/lib/chunk-PEDQPM2P.mjs +0 -926
- package/lib/chunk-PH7SP4YK.mjs +0 -21
- package/lib/chunk-PMN4PAC3.mjs +0 -19
- package/lib/chunk-PMWAFDUB.mjs +0 -48
- package/lib/chunk-PPLVFX6N.mjs +0 -7
- package/lib/chunk-PZBZ7MNC.mjs +0 -7
- package/lib/chunk-QROPNEGY.mjs +0 -14
- package/lib/chunk-RGBGUCJA.mjs +0 -156
- package/lib/chunk-RKTFFCNS.mjs +0 -7
- package/lib/chunk-ROV3QXEF.mjs +0 -475
- package/lib/chunk-RT47RKLY.mjs +0 -7
- package/lib/chunk-SI267LYR.mjs +0 -8
- package/lib/chunk-SRPWW4A2.mjs +0 -10
- package/lib/chunk-T3G6VZNS.mjs +0 -7
- package/lib/chunk-T63U4OZJ.mjs +0 -7
- package/lib/chunk-TEIBWMJM.mjs +0 -7
- package/lib/chunk-TW3N6W5Z.mjs +0 -7
- package/lib/chunk-UBIKR5VO.mjs +0 -7
- package/lib/chunk-UI3JQVRU.mjs +0 -8
- package/lib/chunk-UX3BVH2Y.mjs +0 -7
- package/lib/chunk-VINGECAJ.mjs +0 -10
- package/lib/chunk-VOXJHJIE.mjs +0 -7
- package/lib/chunk-WB2RIVO3.mjs +0 -7
- package/lib/chunk-WXDLQT2O.mjs +0 -10
- package/lib/chunk-XBQGZGWR.mjs +0 -7
- package/lib/chunk-XGGOUNPP.mjs +0 -7
- package/lib/chunk-XKWW3GKF.mjs +0 -7
- package/lib/chunk-YHR4WQPR.mjs +0 -7
- package/lib/chunk-ZQQXSCVI.mjs +0 -7
- package/lib/chunk-ZRUDYB7O.mjs +0 -7
|
@@ -4,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{e as $}from"./chunk-
|
|
7
|
+
import{e as $}from"./chunk-CSMGP53U.mjs";import{m as F,o as A}from"./chunk-EUIALBMX.mjs";import{c as M}from"./chunk-HF6LAK3G.mjs";var k=class{avgSecondsPerApiCall;batchStrategy;constructor(u){this.avgSecondsPerApiCall=u?.avgSecondsPerApiCall??.5,this.batchStrategy=new M}generate(u){let a=u.nodes.filter(o=>o.included);if(a.length===0)return{waves:[],totalRecords:0,totalApiCalls:0,estimatedDurationSeconds:0,cycleResolutions:[]};let{edges:c,components:t}=G(u),i=this.computeTopoLevels(c,t),l=new Map;for(let o of a){let e=i.get(o.objectApiName)??o.level,h=l.get(e);h?h.push(o.objectApiName):l.set(e,[o.objectApiName])}let n=[...l.keys()].sort((o,e)=>o-e),s=new Map(a.map(o=>[o.objectApiName,o])),g=n.map((o,e)=>{let h=l.get(o)??[],v=0,b=0,w=0;for(let N of h){let j=s.get(N);if(!j)continue;v+=j.recordCount;let x=this.batchStrategy.resolve(j.batchStrategy,j.recordCount),C=$(x,j.recordCount).batchCount;b+=C;let O=C*this.avgSecondsPerApiCall;O>w&&(w=O)}return{order:e,objectApiNames:h,totalRecords:v,estimatedDurationSeconds:w,estimatedApiCalls:b}}),r=this.detectCycles(u,c,t),p=g.reduce((o,e)=>o+e.totalRecords,0),f=g.reduce((o,e)=>o+e.estimatedApiCalls,0),m=g.reduce((o,e)=>o+e.estimatedDurationSeconds,0);return{waves:g,totalRecords:p,totalApiCalls:f,estimatedDurationSeconds:m,cycleResolutions:r}}computeTopoLevels(u,a){let c=new Map;a.forEach((n,s)=>{for(let g of n)c.set(g,s)});let t=new Map;for(let n of u){let s=c.get(n.sourceObject),g=c.get(n.targetObject);if(s===void 0||g===void 0||s===g)continue;let r=t.get(s);r?r.push(g):t.set(s,[g])}let i=a.map(()=>0);for(let n=a.length-1;n>=0;n--)for(let s of t.get(n)??[])i[s]=Math.max(i[s],i[n]+1);let l=new Map;for(let[n,s]of c)l.set(n,i[s]);return l}detectCycles(u,a,c){let t=c.filter(n=>n.length>1);if(t.length===0)return[];let i=new Map(A(u).map((n,s)=>[n.objectApiName,s])),l=n=>i.get(n)??0;return t.map(n=>{let s=new Set(n),g=[...n].sort((e,h)=>l(e)-l(h)),r=a.filter(e=>s.has(e.sourceObject)&&s.has(e.targetObject)&&l(e.targetObject)<l(e.sourceObject)),p=r.filter(e=>e.required===!0);if(p.length>0){let e=[...new Set(p.map(b=>b.targetObject))],h=[...new Set(p.map(b=>b.sourceObject))],v=e.length===1;return{objects:g,strategy:"unbreakable",description:`The run cannot break this cycle: ${y(p.map(S))} may not be left empty, and no order writes ${y(h)} first. ${y(e)} ${v?"is":"are"} refused, and what cannot be written without ${v?"it":"them"} is skipped.`}}let f=r.filter(e=>e.insertOnly!==!0),m=r.filter(e=>e.insertOnly===!0),o=[...f.length>0?[`${y(f.map(S))} left empty at insert and filled in by the second pass`]:[],...m.length>0?[`${y(m.map(S))} left empty for good: only an insert sets ${m.length===1?"it":"them"}, and no order writes ${y([...new Set(m.map(e=>e.sourceObject))])} first`]:[]];return{objects:g,strategy:"nullable_lookup",description:`Written in this order, with ${o.join(", and ")}.`}})}};function G(d){let u=d.nodes.filter(t=>t.included).map(t=>t.objectApiName),a=new Set(u),c=d.edges.filter(t=>t.sourceObject!==t.targetObject&&a.has(t.sourceObject)&&a.has(t.targetObject)&&F(t));return{edges:c,components:R(u,c)}}function R(d,u){let a=new Map;for(let r of d)a.set(r,[]);for(let r of u)a.get(r.sourceObject)?.push(r.targetObject);let c=0,t=new Map,i=new Map,l=new Set,n=[],s=[],g=r=>{let p=[];for(t.set(r,c),i.set(r,c),c++,n.push(r),l.add(r),p.push({v:r,neighbors:a.get(r)??[],i:0});p.length>0;){let f=p[p.length-1];if(f.i<f.neighbors.length){let e=f.neighbors[f.i++];t.has(e)?l.has(e)&&i.set(f.v,Math.min(i.get(f.v),t.get(e))):(t.set(e,c),i.set(e,c),c++,n.push(e),l.add(e),p.push({v:e,neighbors:a.get(e)??[],i:0}));continue}let m=f.v;p.pop();let o=p[p.length-1];if(o&&i.set(o.v,Math.min(i.get(o.v),i.get(m))),i.get(m)===t.get(m)){let e=[],h;do h=n.pop(),l.delete(h),e.push(h);while(h!==m);s.push(e)}}};for(let r of d)t.has(r)||g(r);return s}function S(d){return`${d.targetObject}'s lookup to ${d.sourceObject}`}function y(d){return d.length<=1?d.join(""):`${d.slice(0,-1).join(", ")} and ${d[d.length-1]}`}export{k as a,R 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{n as a,o as b,p as c,q as d,r as e,s as f}from"./chunk-HZCS6EED.mjs";import"./chunk-NV5QA2HY.mjs";import"./chunk-EGL3I3IX.mjs";import"./chunk-CSMGP53U.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-YDXMTWAT.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-35B73566.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-TYUYPFDJ.mjs";import"./chunk-ATQML7ZK.mjs";import"./chunk-H6BHWAX7.mjs";import"./chunk-4CSBZZAL.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.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-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{a as WHOLE_ORG_MAX_NODES,b as WHOLE_ORG_MAX_PAIRS,f as discoverWholeOrg,d as eachInPool,e as recordCountsOf,c as refusedByTheOrg};
|
|
@@ -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 j,c as M}from"./chunk-INIT2UKJ.mjs";import{d as K}from"./chunk-TNT27RBG.mjs";import{a as T,h as N}from"./chunk-TZE3Y7IQ.mjs";import{Ac as J,Bc as Q,Ec as C,Fc as v,Mc as H,Nc as $,Oc as F,zc as z}from"./chunk-PMWAFDUB.mjs";var ee="Id = NULL",B="no parent in cache and not the root",Y=class{build(t){let n=this.buildMeasured(t);return{...n,statements:_(n.statements,t.node.objectApiName,t.selectFields)}}buildMeasured(t){let n=N(t.node.objectApiName),o=k(M(t.selectFields)),r=t.extraWhere?` AND (${t.extraWhere})`:"",i=t.extraWhere?" + extra filter":"",l=`SELECT ${o} FROM ${n} WHERE `,u=t.node.objectApiName===t.rootObjectApiName&&!t.under;if(u&&!(t.rootReadAgain&&t.cache.has(t.node.objectApiName))){if(t.rootRecordIds!==void 0)return{statements:L({prefix:l,suffix:r,wrap:!1,objectApiName:t.node.objectApiName},[{field:"Id",ids:t.rootRecordIds}]),scoped:t.rootRecordIds.size>0,scope:"root",reason:`${t.rootRecordIds.size} root records${i}`,parentObjectsUsed:[t.rootObjectApiName],scopeIdCount:t.rootRecordIds.size,byIdCount:0};let b=T(t.rootRecordId??"");return{statements:[`${l}Id = '${b}'${r}`],scoped:!0,scope:"root",reason:`root record${i}`,parentObjectsUsed:[t.rootObjectApiName],scopeIdCount:1,byIdCount:0}}let d=t.under?void 0:t.cache.get(t.node.objectApiName),s=d?.size??0,a=d&&s>0?L({prefix:l,suffix:r,wrap:!1,objectApiName:t.node.objectApiName},[{field:"Id",ids:d}]):[],h=`${s} ID(s) cached from earlier wave`,f={statements:a,scoped:!0,scope:"self-cached",reason:`${h}${i}`,parentObjectsUsed:[],scopeIdCount:s,byIdCount:a.length};if(s>0&&(!t.everyEdge||u))return f;let g=[],I=[],y=0;for(let b of t.edges){if(b.targetObject!==t.node.objectApiName||t.under&&!t.under.has(b.sourceObject)||b.sourceObject===b.targetObject)continue;let O=t.fromAboveOnly||t.catalog?.has(b.sourceObject)?t.cache.reachedOf(b.sourceObject):t.cache.scopeOf(b.sourceObject);if(!O||O.size===0)continue;let S=t.fields.filter(c=>c.type==="reference"&&c.referenceTo.includes(b.sourceObject));if(S.length!==0){for(let c of S)g.push({field:N(c.name),ids:O});I.includes(b.sourceObject)||(I.push(b.sourceObject),y+=O.size)}}let R=[];for(let b of t.fields){if(b.type!=="reference"||b.nillable!==!1)continue;let O=new Set;for(let S of b.referenceTo){if(!t.readObjects?.has(S))continue;let c=t.catalog?.has(S)===!0;if(c&&!t.cache.isRead(S))continue;let m=c?t.cache.scopeOf(S):t.cache.get(S);if(m)for(let p of m)O.add(p)}O.size!==0&&R.push({field:N(b.name),ids:O})}let x=R.length>0?" + required parents in scope":"";if(g.length===0)return s>0?f:{statements:[`${l}${ee}`],scoped:!1,scope:"unscoped",reason:B,parentObjectsUsed:[],scopeIdCount:0,byIdCount:1};let w=Z({prefix:l,extraSuffix:r,objectApiName:t.node.objectApiName},g,R),A=`via ${I.join(", ")}${i}${x}`;return s===0?{statements:w,scoped:!0,scope:"parent-fk",reason:A,parentObjectsUsed:I,scopeIdCount:y,byIdCount:0}:{statements:[...a,...w],scoped:!0,scope:"self-and-parent-fk",reason:`${h}, and ${A}`,parentObjectsUsed:I,scopeIdCount:s+y,byIdCount:a.length}}buildJoining(t){let n=N(t.objectApiName),r=`SELECT ${k(M(t.selectFields))} FROM ${n} WHERE `,i=t.extraWhere?` AND (${t.extraWhere})`:"";return _(Z({prefix:r,extraSuffix:i,objectApiName:t.objectApiName},[{field:N(t.split.field),ids:t.split.ids}],[{field:N(t.whole.field),ids:t.whole.ids}]),t.objectApiName,t.selectFields)}buildById(t){let n=N(t.objectApiName);return _(L({prefix:`SELECT ${k(M(t.selectFields))} FROM ${n} WHERE `,suffix:t.extraWhere?` AND (${t.extraWhere})`:"",wrap:!1,objectApiName:t.objectApiName},[{field:"Id",ids:t.ids}]),t.objectApiName,t.selectFields)}};function k(e){return e.length===0?"Id":e.map(t=>N(t)).join(", ")}function _(e,t,n){let o=N(t),r=`SELECT ${k(M(n))} FROM ${o} `,i=`SELECT ${k(n)} FROM ${o} `;return r===i?[...e]:e.map(l=>l.startsWith(r)?i+l.slice(r.length):l)}var te=500;function W(e,t){let n=[...t].map(o=>`'${T(o)}'`).join(", ");return` AND (${e.field} IN (${n}))`}function ne(e,t){if(e.field!==t.field)return!1;for(let n of e.ids)if(!t.ids.has(n))return!1;return!0}function oe(e,t,n){let o=j(W(e,[])),r=j(", "),i=[],l=[],u=o;for(let d of e.ids){let s=j(`'${T(d)}'`);if(l.length>0&&u+r+s>t&&(i.push(l),l=[],u=o),l.length===0&&o+s>t)throw X(n);u+=(l.length>0?r:0)+s,l.push(d)}return l.length>0&&i.push(l),i}function re(e,t,n){let o=[""];for(let r of e){let i=oe(r,t/e.length,n);o=o.flatMap(l=>i.map(u=>l+W(r,u)))}return o}function Z(e,t,n){let o=(d,s)=>L({prefix:e.prefix,suffix:d,wrap:d!=="",objectApiName:e.objectApiName},s),r=n.map(d=>W(d,d.ids)).join(""),i=14e3-j(`${e.prefix}()${e.extraSuffix}`);if(j(r)<=i/2)return o(`${r}${e.extraSuffix}`,t);let l=new Map;for(let d of t){let s=n.filter(f=>!ne(d,f)),a=s.map(f=>f.field).join("|"),h=l.get(a)??{needed:s,clauses:[]};h.clauses.push(d),l.set(a,h)}let u=[];for(let d of l.values())for(let s of re(d.needed,i/2,e.objectApiName))u.push(...o(`${s}${e.extraSuffix}`,d.clauses));return u}function X(e){return new Error(`Scoped clone for ${e}: its filter leaves a Salesforce query URI no room for a single record Id. Shorten the filter on this object and run it again.`)}function L(e,t){let n=e.wrap?"(":"",o=e.wrap?")":"",r=j(e.prefix+n+o+e.suffix),i=j(", "),l=j(" OR "),u=[],d=[],s=r,a=0,h=()=>{let f=d.map(g=>`${g.field} IN (${g.values.join(", ")})`).join(" OR ");u.push(`${e.prefix}${n}${f}${o}${e.suffix}`),d=[],s=r,a=0};for(let f of t){let g=j(`${f.field} IN ()`),I=!1;for(let y of f.ids){let R=`'${T(y)}'`,x=j(R),w=I?i+x:(d.length>0?l:0)+g+x,A=s+w>14e3||a>=te;if(d.length>0&&A&&(h(),I=!1,w=g+x),d.length===0&&s+w>14e3)throw X(e.objectApiName);I?d[d.length-1].values.push(R):(d.push({field:f.field,values:[R]}),I=!0),s+=w,a++}}return d.length>0&&h(),u}var G="Product2",U=[C,G,$,F,v,"ProductCategory","ProductCatalog"],Ne=new Set(U);function je(e,t){return z(e,t.name,t.nillable)||e===C&&t.name===H}function xe(e,t=new Set){let n=new Set(e.nodes.map(o=>o.objectApiName));return new Set(U.filter(o=>!n.has(o)&&!t.has(o)))}function we(e,t){return e.nodes.some(n=>n.included&&t.has(n.objectApiName))?{...e,nodes:e.nodes.map(n=>n.included&&t.has(n.objectApiName)?{...n,included:!1}:n)}:e}function se(e,t,n){if(t.length<2)return t;let o=e.slice(0,3),r=t.find(i=>n.get(i)===o);return r!==void 0?[r]:t.filter(i=>!n.has(i))}function Ae(e,t){let n=q(e);return t?he(n,t):n}function Ee(e,t,n){let o=U.flatMap(f=>t.filter(({node:g})=>g.objectApiName===f)),r=new Set(o.flatMap(({fieldInfos:f})=>f.flatMap(g=>g.isReference?g.referenceTo??[]:[]))),i=new Map,l=new Map,u=(f,g,I)=>{let y=f.get(g);y?y.push(I):f.set(g,[I])};for(let{sourceObject:f,targetObject:g}of n)u(i,g,f),u(l,f,g);let d=[],s=new Set,a=[...e],h=a.filter(f=>r.has(f.objectApiName));for(;h.length>0;){for(let f of h)s.add(f.objectApiName),d.push(f);a=a.filter(f=>!s.has(f.objectApiName)),h=a.filter(({objectApiName:f})=>(i.get(f)??[]).some(g=>s.has(g))||(l.get(f)??[]).some(g=>s.has(g)))}return[...a,...o.map(({node:f})=>f),...d]}function V(e){return e.settable!==!1}function Ce(e,t){let n=!1,o=e.edges.map(r=>{let i=(t.get(r.targetObject)??[]).filter(s=>s.isReference&&(s.referenceTo??[]).includes(r.sourceObject));if(i.length===0)return r;let l=i.some(s=>J(s)),u=i.some(s=>Q(s));if(l===V(r)&&u===(r.insertOnly===!0))return r;n=!0;let d={...r};return l?delete d.settable:d.settable=!1,u?d.insertOnly=!0:delete d.insertOnly,d});return n?{...e,edges:o}:e}function Fe(e,t=[]){let n=e.edges.filter(V),o=[...n.filter(c=>c.required===!0),...t],r=n.filter(c=>c.insertOnly===!0&&c.required!==!0);if(o.length===0&&r.length===0)return q(e,n);let i=new Set(e.nodes.map(c=>c.objectApiName)),l=q(e,n),u=new Map(l.map((c,m)=>[c.objectApiName,m])),d=new Map,s=new Map,a=new Map,h=(c,m,p)=>{let E=c.get(m)??new Set;E.add(p),c.set(m,E)};for(let c of o){let{sourceObject:m,targetObject:p}=c;m===p||!i.has(m)||!i.has(p)||(h(d,p,m),h(s,m,p))}for(let c of n){let{sourceObject:m,targetObject:p}=c;m===p||!i.has(m)||!i.has(p)||d.get(p)?.has(m)||h(a,p,m)}let f=new Map;for(let[c,m]of a)for(let p of m)h(f,p,c);let g=new Map,I=new Map;for(let{sourceObject:c,targetObject:m}of r)c===m||!i.has(c)||!i.has(m)||d.get(m)?.has(c)||(h(g,m,c),h(I,c,m));let y=new Map,R=new Map,x=new Map;for(let c of i)y.set(c,d.get(c)?.size??0),R.set(c,g.get(c)?.size??0),x.set(c,a.get(c)?.size??0);let w=(c,m)=>{for(let p of[R,x,u]){let E=p.get(c)??0,D=p.get(m)??0;if(E!==D)return E<D}return!1},A=new Set([...i].filter(c=>y.get(c)===0)),b=new Map(e.nodes.map(c=>[c.objectApiName,c])),O=[],S=new Set;for(;A.size>0;){let c;for(let p of A)(c===void 0||w(p,c))&&(c=p);if(c===void 0)break;A.delete(c),S.add(c);let m=b.get(c);m&&O.push(m);for(let p of s.get(c)??[]){let E=(y.get(p)??1)-1;y.set(p,E),E===0&&!S.has(p)&&A.add(p)}for(let p of I.get(c)??[])R.set(p,(R.get(p)??1)-1);for(let p of f.get(c)??[])x.set(p,(x.get(p)??1)-1)}for(let c of e.nodes)S.has(c.objectApiName)||O.push(c);return O}function $e(e,t){return[[G,F],[$,F],[G,C],[$,C],[F,C],[v,C],...t.map(o=>[C,o])].filter(([o,r])=>o!==r&&e.has(o)&&e.has(r)).map(([o,r])=>({sourceObject:o,targetObject:r,relationshipName:`${o}Before${r}`,type:"lookup",required:!0}))}var ie=new Set(["Id","Name","CurrencyIsoCode","IsPersonAccount","IsActive","Status","IsWhat","IsInvitee","Response","RespondedDate",...Object.values(K).flat()]);function de(e,t){let n=new Set(t??[]);return e.filter(o=>o.queryable&&(!n.has(o.name)||o.isReference||ie.has(o.name))).map(o=>o.name)}var ce=2;function ae(e,t){let n=Array.from({length:t.length+1},(o,r)=>r);for(let o=1;o<=e.length;o++){let r=[o];for(let i=1;i<=t.length;i++)r[i]=Math.min(n[i]+1,r[i-1]+1,n[i-1]+(e[o-1]===t[i-1]?0:1));n=r}return n[t.length]}function le(e,t){let n=e.toLowerCase(),o;for(let r of t){let i=ae(n,r.toLowerCase());i<=ce&&i<n.length&&(!o||i<o.edits)&&(o={name:r,edits:i})}return o?.name}function Te(e,t,n){let o={},r=[];for(let[i,l]of Object.entries(e)){let u=t.find(a=>a.toLowerCase()===i.toLowerCase())??i,d=n(u),s=o[u]??=[];for(let a of l){let h=d?.find(g=>g.toLowerCase()===a.toLowerCase());if(h===void 0&&d!==null){let g=d===void 0?void 0:le(a,d);r.push({objectApiName:u,field:a,missing:d===void 0?"object":"field",...g!==void 0?{nearest:g}:{}})}let f=h??a;s.includes(f)||s.push(f)}}return{exclusions:o,unmatched:r}}function Me(e){let t=de(e.fieldInfos,e.fieldsLeftOut);t.length===0&&t.push("Id");let n,o=0,r=[],i=!1,l=!!e.rootRecordId||e.rootRecordIds!==void 0;if(e.scopedBuilder&&e.scopeCache&&e.rootObjectApiName&&l&&e.node.objectApiName===F&&e.node.objectApiName!==e.rootObjectApiName&&e.catalog?.has(F)){let d=ge(e.scopedBuilder,e.scopeCache,t,e.extraWhere);if(!d)return{kind:"skip",reason:B};n=d,o=n.length}else if(e.scopedBuilder&&e.scopeCache&&e.rootObjectApiName&&l){let d=e.fieldInfos.filter(a=>a.isReference).map(a=>({name:a.name,type:"reference",referenceTo:a.referenceTo??[],nillable:a.nillable})),s=e.scopedBuilder.build({node:e.node,fields:d,selectFields:t,edges:e.edges,cache:e.scopeCache,rootObjectApiName:e.rootObjectApiName,...e.rootRecordIds!==void 0?{rootRecordIds:e.rootRecordIds}:{rootRecordId:e.rootRecordId},extraWhere:e.extraWhere,everyEdge:!0,readObjects:e.readObjects,catalog:e.catalog,rootReadAgain:e.rootReadAgain,under:e.under});if(!s.scoped)return{kind:"skip",reason:s.reason};n=s.statements,o=s.byIdCount,i=s.scope==="root"&&e.rootRecordIds!==void 0,e.rootRecordIds!==void 0&&(s.scope==="parent-fk"||s.scope==="self-and-parent-fk")&&(r=s.parentObjectsUsed)}else{let d=[...e.extraWhere?[`(${e.extraWhere})`]:[],...e.inIdOrder?.afterId!==void 0?[`Id > ${ue(e.inIdOrder.afterId)}`]:[]],s=d.length>0?` WHERE ${d.join(" AND ")}`:"",a=e.inIdOrder?" ORDER BY Id":"";n=[`SELECT ${t.join(", ")} FROM ${N(e.node.objectApiName)}${s}${a}`]}let u={...o>0?{byIdCount:o}:{},...r.length>0?{readUnder:[...r]}:{}};if(!i&&e.maxRecordsPerObject&&e.maxRecordsPerObject>0){let d=Math.floor(e.maxRecordsPerObject);if(d>0)return fe(n,d,u)}return{kind:"query",statements:n,...u}}function fe(e,t,n={}){return{kind:"query",statements:e.map(o=>`${o} LIMIT ${t+1}`),limit:t,...n}}function ue(e){if(!/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(e))throw new Error(`Not a record id to resume after: ${JSON.stringify(e.slice(0,40))}`);return`'${e}'`}function ge(e,t,n,o){let r=t.scopeOf(G),i=t.scopeOf($);if(!(!r||r.size===0||!i||i.size===0))return e.buildJoining({objectApiName:F,selectFields:n,split:{field:"Product2Id",ids:r},whole:{field:"ProductSellingModelId",ids:i},extraWhere:o})}function ke(e){return(e.byIdCount??0)<e.statements.length}async function Le(e,t,n,o){let r=e.byIdCount??0,i=e.limit,l=s=>{if(i===void 0||s.length<=i)return s;for(let a of s.slice(i))typeof a.Id=="string"&&n?.delete(a.Id);return o?.(),s.slice(0,i)};if(e.statements.length===1){let s=await t(e.statements[0]);if(n&&r===0)for(let a of s)typeof a.Id=="string"&&n.add(a.Id);return l(s)}let u=[],d=new Set;for(let[s,a]of e.statements.entries())for(let h of await t(a)){let f=h.Id;if(typeof f=="string"){if(n&&s>=r&&n.add(f),d.has(f))continue;d.add(f)}if(u.push(h),i!==void 0&&u.length>i)return l(u)}return u}function pe(e,t,n,{settle:o=!0}={}){let r=[];for(let i of n){let l=i.Id;typeof l=="string"&&l&&r.push(l)}o?e.addRead(t,r):e.add(t,r)}function Ge(e,t,n,o,r={}){pe(e,t,n,r);let i=r.keyPrefixes??new Map,l=o.filter(u=>u.isReference&&u.referenceTo&&u.referenceTo.length>0);for(let u of l){let d=u.referenceTo??[];for(let s of n){let a=s[u.name];if(!(typeof a!="string"||!a))for(let h of se(a,d,i))e.add(h,[a])}}}function he(e,t){let n=e.findIndex(l=>l.objectApiName===t);if(n<0)throw new Error(`Cannot run scoped clone with root "${t}" missing from the graph. The root node was excluded or filtered out \u2014 re-include it before executing.`);let o=e[n];if(!o.included)throw o.status==="error"?new Error(`Cannot run scoped clone: root "${t}" could not be measured during discovery (${o.errors[0]??"unknown discovery error"}), and nothing was read or written. Run discovery again once the org answers for it; if it refuses again, the user the clone reads as may not read ${t}: start from a record the user can read.`):new Error(`Cannot run scoped clone with root "${t}" excluded: the clone starts from its record, and the records that point at it would be written without it. Include it again, or clone from a query instead of a record.`);if(n===0)return e;let r=[...e],[i]=r.splice(n,1);return r.unshift(i),r}function q(e,t){let n=t??e.edges,o=new Map;for(let s of e.nodes)o.set(s.objectApiName,s);let r=new Map,i=new Map;for(let s of e.nodes)r.set(s.objectApiName,0);for(let s of n){r.has(s.targetObject)&&r.set(s.targetObject,(r.get(s.targetObject)??0)+1);let a=i.get(s.sourceObject);a?a.push(s.targetObject):i.set(s.sourceObject,[s.targetObject])}let l=[];for(let[s,a]of r)a===0&&l.push(s);let u=[],d=new Set;for(;l.length>0;){let s=l.shift();if(d.has(s))continue;d.add(s);let a=o.get(s);a&&u.push(a);let h=i.get(s);if(h){for(let f of h)if(r.has(f)){let g=(r.get(f)??1)-1;r.set(f,g),g===0&&!d.has(f)&&l.push(f)}}}for(let s of e.nodes)d.has(s.objectApiName)||u.push(s);return u}export{B as a,Y as b,te as c,G as d,U as e,Ne as f,je as g,xe as h,we as i,se as j,Ae as k,Ee as l,V as m,Ce as n,Fe as o,$e as p,de as q,Te as r,Me as s,fe as t,ke as u,Le as v,pe as w,Ge as x};
|
|
7
|
+
import{a as j,c as M}from"./chunk-INIT2UKJ.mjs";import{d as K}from"./chunk-SZOJ7BEJ.mjs";import{a as T,h as N}from"./chunk-TZE3Y7IQ.mjs";import{Gc as z,Hc as J,Ic as Q,Lc as C,Mc as v,Tc as H,Uc as $,Vc as F}from"./chunk-J347SPU6.mjs";var ee="Id = NULL",B="no parent in cache and not the root",Y=class{build(t){let n=this.buildMeasured(t);return{...n,statements:_(n.statements,t.node.objectApiName,t.selectFields)}}buildMeasured(t){let n=N(t.node.objectApiName),o=k(M(t.selectFields)),r=t.extraWhere?` AND (${t.extraWhere})`:"",i=t.extraWhere?" + extra filter":"",l=`SELECT ${o} FROM ${n} WHERE `,u=t.node.objectApiName===t.rootObjectApiName&&!t.under;if(u&&!(t.rootReadAgain&&t.cache.has(t.node.objectApiName))){if(t.rootRecordIds!==void 0)return{statements:L({prefix:l,suffix:r,wrap:!1,objectApiName:t.node.objectApiName},[{field:"Id",ids:t.rootRecordIds}]),scoped:t.rootRecordIds.size>0,scope:"root",reason:`${t.rootRecordIds.size} root records${i}`,parentObjectsUsed:[t.rootObjectApiName],scopeIdCount:t.rootRecordIds.size,byIdCount:0};let b=T(t.rootRecordId??"");return{statements:[`${l}Id = '${b}'${r}`],scoped:!0,scope:"root",reason:`root record${i}`,parentObjectsUsed:[t.rootObjectApiName],scopeIdCount:1,byIdCount:0}}let d=t.under?void 0:t.cache.get(t.node.objectApiName),s=d?.size??0,a=d&&s>0?L({prefix:l,suffix:r,wrap:!1,objectApiName:t.node.objectApiName},[{field:"Id",ids:d}]):[],h=`${s} ID(s) cached from earlier wave`,f={statements:a,scoped:!0,scope:"self-cached",reason:`${h}${i}`,parentObjectsUsed:[],scopeIdCount:s,byIdCount:a.length};if(s>0&&(!t.everyEdge||u))return f;let g=[],I=[],y=0;for(let b of t.edges){if(b.targetObject!==t.node.objectApiName||t.under&&!t.under.has(b.sourceObject)||b.sourceObject===b.targetObject)continue;let O=t.fromAboveOnly||t.catalog?.has(b.sourceObject)?t.cache.reachedOf(b.sourceObject):t.cache.scopeOf(b.sourceObject);if(!O||O.size===0)continue;let S=t.fields.filter(c=>c.type==="reference"&&c.referenceTo.includes(b.sourceObject));if(S.length!==0){for(let c of S)g.push({field:N(c.name),ids:O});I.includes(b.sourceObject)||(I.push(b.sourceObject),y+=O.size)}}let R=[];for(let b of t.fields){if(b.type!=="reference"||b.nillable!==!1)continue;let O=new Set;for(let S of b.referenceTo){if(!t.readObjects?.has(S))continue;let c=t.catalog?.has(S)===!0;if(c&&!t.cache.isRead(S))continue;let m=c?t.cache.scopeOf(S):t.cache.get(S);if(m)for(let p of m)O.add(p)}O.size!==0&&R.push({field:N(b.name),ids:O})}let x=R.length>0?" + required parents in scope":"";if(g.length===0)return s>0?f:{statements:[`${l}${ee}`],scoped:!1,scope:"unscoped",reason:B,parentObjectsUsed:[],scopeIdCount:0,byIdCount:1};let w=Z({prefix:l,extraSuffix:r,objectApiName:t.node.objectApiName},g,R),A=`via ${I.join(", ")}${i}${x}`;return s===0?{statements:w,scoped:!0,scope:"parent-fk",reason:A,parentObjectsUsed:I,scopeIdCount:y,byIdCount:0}:{statements:[...a,...w],scoped:!0,scope:"self-and-parent-fk",reason:`${h}, and ${A}`,parentObjectsUsed:I,scopeIdCount:s+y,byIdCount:a.length}}buildJoining(t){let n=N(t.objectApiName),r=`SELECT ${k(M(t.selectFields))} FROM ${n} WHERE `,i=t.extraWhere?` AND (${t.extraWhere})`:"";return _(Z({prefix:r,extraSuffix:i,objectApiName:t.objectApiName},[{field:N(t.split.field),ids:t.split.ids}],[{field:N(t.whole.field),ids:t.whole.ids}]),t.objectApiName,t.selectFields)}buildById(t){let n=N(t.objectApiName);return _(L({prefix:`SELECT ${k(M(t.selectFields))} FROM ${n} WHERE `,suffix:t.extraWhere?` AND (${t.extraWhere})`:"",wrap:!1,objectApiName:t.objectApiName},[{field:"Id",ids:t.ids}]),t.objectApiName,t.selectFields)}};function k(e){return e.length===0?"Id":e.map(t=>N(t)).join(", ")}function _(e,t,n){let o=N(t),r=`SELECT ${k(M(n))} FROM ${o} `,i=`SELECT ${k(n)} FROM ${o} `;return r===i?[...e]:e.map(l=>l.startsWith(r)?i+l.slice(r.length):l)}var te=500;function W(e,t){let n=[...t].map(o=>`'${T(o)}'`).join(", ");return` AND (${e.field} IN (${n}))`}function ne(e,t){if(e.field!==t.field)return!1;for(let n of e.ids)if(!t.ids.has(n))return!1;return!0}function oe(e,t,n){let o=j(W(e,[])),r=j(", "),i=[],l=[],u=o;for(let d of e.ids){let s=j(`'${T(d)}'`);if(l.length>0&&u+r+s>t&&(i.push(l),l=[],u=o),l.length===0&&o+s>t)throw X(n);u+=(l.length>0?r:0)+s,l.push(d)}return l.length>0&&i.push(l),i}function re(e,t,n){let o=[""];for(let r of e){let i=oe(r,t/e.length,n);o=o.flatMap(l=>i.map(u=>l+W(r,u)))}return o}function Z(e,t,n){let o=(d,s)=>L({prefix:e.prefix,suffix:d,wrap:d!=="",objectApiName:e.objectApiName},s),r=n.map(d=>W(d,d.ids)).join(""),i=14e3-j(`${e.prefix}()${e.extraSuffix}`);if(j(r)<=i/2)return o(`${r}${e.extraSuffix}`,t);let l=new Map;for(let d of t){let s=n.filter(f=>!ne(d,f)),a=s.map(f=>f.field).join("|"),h=l.get(a)??{needed:s,clauses:[]};h.clauses.push(d),l.set(a,h)}let u=[];for(let d of l.values())for(let s of re(d.needed,i/2,e.objectApiName))u.push(...o(`${s}${e.extraSuffix}`,d.clauses));return u}function X(e){return new Error(`Scoped clone for ${e}: its filter leaves a Salesforce query URI no room for a single record Id. Shorten the filter on this object and run it again.`)}function L(e,t){let n=e.wrap?"(":"",o=e.wrap?")":"",r=j(e.prefix+n+o+e.suffix),i=j(", "),l=j(" OR "),u=[],d=[],s=r,a=0,h=()=>{let f=d.map(g=>`${g.field} IN (${g.values.join(", ")})`).join(" OR ");u.push(`${e.prefix}${n}${f}${o}${e.suffix}`),d=[],s=r,a=0};for(let f of t){let g=j(`${f.field} IN ()`),I=!1;for(let y of f.ids){let R=`'${T(y)}'`,x=j(R),w=I?i+x:(d.length>0?l:0)+g+x,A=s+w>14e3||a>=te;if(d.length>0&&A&&(h(),I=!1,w=g+x),d.length===0&&s+w>14e3)throw X(e.objectApiName);I?d[d.length-1].values.push(R):(d.push({field:f.field,values:[R]}),I=!0),s+=w,a++}}return d.length>0&&h(),u}var G="Product2",U=[C,G,$,F,v,"ProductCategory","ProductCatalog"],Ne=new Set(U);function je(e,t){return z(e,t.name,t.nillable)||e===C&&t.name===H}function xe(e,t=new Set){let n=new Set(e.nodes.map(o=>o.objectApiName));return new Set(U.filter(o=>!n.has(o)&&!t.has(o)))}function we(e,t){return e.nodes.some(n=>n.included&&t.has(n.objectApiName))?{...e,nodes:e.nodes.map(n=>n.included&&t.has(n.objectApiName)?{...n,included:!1}:n)}:e}function se(e,t,n){if(t.length<2)return t;let o=e.slice(0,3),r=t.find(i=>n.get(i)===o);return r!==void 0?[r]:t.filter(i=>!n.has(i))}function Ae(e,t){let n=q(e);return t?he(n,t):n}function Ee(e,t,n){let o=U.flatMap(f=>t.filter(({node:g})=>g.objectApiName===f)),r=new Set(o.flatMap(({fieldInfos:f})=>f.flatMap(g=>g.isReference?g.referenceTo??[]:[]))),i=new Map,l=new Map,u=(f,g,I)=>{let y=f.get(g);y?y.push(I):f.set(g,[I])};for(let{sourceObject:f,targetObject:g}of n)u(i,g,f),u(l,f,g);let d=[],s=new Set,a=[...e],h=a.filter(f=>r.has(f.objectApiName));for(;h.length>0;){for(let f of h)s.add(f.objectApiName),d.push(f);a=a.filter(f=>!s.has(f.objectApiName)),h=a.filter(({objectApiName:f})=>(i.get(f)??[]).some(g=>s.has(g))||(l.get(f)??[]).some(g=>s.has(g)))}return[...a,...o.map(({node:f})=>f),...d]}function V(e){return e.settable!==!1}function Ce(e,t){let n=!1,o=e.edges.map(r=>{let i=(t.get(r.targetObject)??[]).filter(s=>s.isReference&&(s.referenceTo??[]).includes(r.sourceObject));if(i.length===0)return r;let l=i.some(s=>J(s)),u=i.some(s=>Q(s));if(l===V(r)&&u===(r.insertOnly===!0))return r;n=!0;let d={...r};return l?delete d.settable:d.settable=!1,u?d.insertOnly=!0:delete d.insertOnly,d});return n?{...e,edges:o}:e}function Fe(e,t=[]){let n=e.edges.filter(V),o=[...n.filter(c=>c.required===!0),...t],r=n.filter(c=>c.insertOnly===!0&&c.required!==!0);if(o.length===0&&r.length===0)return q(e,n);let i=new Set(e.nodes.map(c=>c.objectApiName)),l=q(e,n),u=new Map(l.map((c,m)=>[c.objectApiName,m])),d=new Map,s=new Map,a=new Map,h=(c,m,p)=>{let E=c.get(m)??new Set;E.add(p),c.set(m,E)};for(let c of o){let{sourceObject:m,targetObject:p}=c;m===p||!i.has(m)||!i.has(p)||(h(d,p,m),h(s,m,p))}for(let c of n){let{sourceObject:m,targetObject:p}=c;m===p||!i.has(m)||!i.has(p)||d.get(p)?.has(m)||h(a,p,m)}let f=new Map;for(let[c,m]of a)for(let p of m)h(f,p,c);let g=new Map,I=new Map;for(let{sourceObject:c,targetObject:m}of r)c===m||!i.has(c)||!i.has(m)||d.get(m)?.has(c)||(h(g,m,c),h(I,c,m));let y=new Map,R=new Map,x=new Map;for(let c of i)y.set(c,d.get(c)?.size??0),R.set(c,g.get(c)?.size??0),x.set(c,a.get(c)?.size??0);let w=(c,m)=>{for(let p of[R,x,u]){let E=p.get(c)??0,D=p.get(m)??0;if(E!==D)return E<D}return!1},A=new Set([...i].filter(c=>y.get(c)===0)),b=new Map(e.nodes.map(c=>[c.objectApiName,c])),O=[],S=new Set;for(;A.size>0;){let c;for(let p of A)(c===void 0||w(p,c))&&(c=p);if(c===void 0)break;A.delete(c),S.add(c);let m=b.get(c);m&&O.push(m);for(let p of s.get(c)??[]){let E=(y.get(p)??1)-1;y.set(p,E),E===0&&!S.has(p)&&A.add(p)}for(let p of I.get(c)??[])R.set(p,(R.get(p)??1)-1);for(let p of f.get(c)??[])x.set(p,(x.get(p)??1)-1)}for(let c of e.nodes)S.has(c.objectApiName)||O.push(c);return O}function $e(e,t){return[[G,F],[$,F],[G,C],[$,C],[F,C],[v,C],...t.map(o=>[C,o])].filter(([o,r])=>o!==r&&e.has(o)&&e.has(r)).map(([o,r])=>({sourceObject:o,targetObject:r,relationshipName:`${o}Before${r}`,type:"lookup",required:!0}))}var ie=new Set(["Id","Name","CurrencyIsoCode","IsPersonAccount","IsActive","Status","IsWhat","IsInvitee","Response","RespondedDate",...Object.values(K).flat()]);function de(e,t){let n=new Set(t??[]);return e.filter(o=>o.queryable&&(!n.has(o.name)||o.isReference||ie.has(o.name))).map(o=>o.name)}var ce=2;function ae(e,t){let n=Array.from({length:t.length+1},(o,r)=>r);for(let o=1;o<=e.length;o++){let r=[o];for(let i=1;i<=t.length;i++)r[i]=Math.min(n[i]+1,r[i-1]+1,n[i-1]+(e[o-1]===t[i-1]?0:1));n=r}return n[t.length]}function le(e,t){let n=e.toLowerCase(),o;for(let r of t){let i=ae(n,r.toLowerCase());i<=ce&&i<n.length&&(!o||i<o.edits)&&(o={name:r,edits:i})}return o?.name}function Te(e,t,n){let o={},r=[];for(let[i,l]of Object.entries(e)){let u=t.find(a=>a.toLowerCase()===i.toLowerCase())??i,d=n(u),s=o[u]??=[];for(let a of l){let h=d?.find(g=>g.toLowerCase()===a.toLowerCase());if(h===void 0&&d!==null){let g=d===void 0?void 0:le(a,d);r.push({objectApiName:u,field:a,missing:d===void 0?"object":"field",...g!==void 0?{nearest:g}:{}})}let f=h??a;s.includes(f)||s.push(f)}}return{exclusions:o,unmatched:r}}function Me(e){let t=de(e.fieldInfos,e.fieldsLeftOut);t.length===0&&t.push("Id");let n,o=0,r=[],i=!1,l=!!e.rootRecordId||e.rootRecordIds!==void 0;if(e.scopedBuilder&&e.scopeCache&&e.rootObjectApiName&&l&&e.node.objectApiName===F&&e.node.objectApiName!==e.rootObjectApiName&&e.catalog?.has(F)){let d=ge(e.scopedBuilder,e.scopeCache,t,e.extraWhere);if(!d)return{kind:"skip",reason:B};n=d,o=n.length}else if(e.scopedBuilder&&e.scopeCache&&e.rootObjectApiName&&l){let d=e.fieldInfos.filter(a=>a.isReference).map(a=>({name:a.name,type:"reference",referenceTo:a.referenceTo??[],nillable:a.nillable})),s=e.scopedBuilder.build({node:e.node,fields:d,selectFields:t,edges:e.edges,cache:e.scopeCache,rootObjectApiName:e.rootObjectApiName,...e.rootRecordIds!==void 0?{rootRecordIds:e.rootRecordIds}:{rootRecordId:e.rootRecordId},extraWhere:e.extraWhere,everyEdge:!0,readObjects:e.readObjects,catalog:e.catalog,rootReadAgain:e.rootReadAgain,under:e.under});if(!s.scoped)return{kind:"skip",reason:s.reason};n=s.statements,o=s.byIdCount,i=s.scope==="root"&&e.rootRecordIds!==void 0,e.rootRecordIds!==void 0&&(s.scope==="parent-fk"||s.scope==="self-and-parent-fk")&&(r=s.parentObjectsUsed)}else{let d=[...e.extraWhere?[`(${e.extraWhere})`]:[],...e.inIdOrder?.afterId!==void 0?[`Id > ${ue(e.inIdOrder.afterId)}`]:[]],s=d.length>0?` WHERE ${d.join(" AND ")}`:"",a=e.inIdOrder?" ORDER BY Id":"";n=[`SELECT ${t.join(", ")} FROM ${N(e.node.objectApiName)}${s}${a}`]}let u={...o>0?{byIdCount:o}:{},...r.length>0?{readUnder:[...r]}:{}};if(!i&&e.maxRecordsPerObject&&e.maxRecordsPerObject>0){let d=Math.floor(e.maxRecordsPerObject);if(d>0)return fe(n,d,u)}return{kind:"query",statements:n,...u}}function fe(e,t,n={}){return{kind:"query",statements:e.map(o=>`${o} LIMIT ${t+1}`),limit:t,...n}}function ue(e){if(!/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(e))throw new Error(`Not a record id to resume after: ${JSON.stringify(e.slice(0,40))}`);return`'${e}'`}function ge(e,t,n,o){let r=t.scopeOf(G),i=t.scopeOf($);if(!(!r||r.size===0||!i||i.size===0))return e.buildJoining({objectApiName:F,selectFields:n,split:{field:"Product2Id",ids:r},whole:{field:"ProductSellingModelId",ids:i},extraWhere:o})}function ke(e){return(e.byIdCount??0)<e.statements.length}async function Le(e,t,n,o){let r=e.byIdCount??0,i=e.limit,l=s=>{if(i===void 0||s.length<=i)return s;for(let a of s.slice(i))typeof a.Id=="string"&&n?.delete(a.Id);return o?.(),s.slice(0,i)};if(e.statements.length===1){let s=await t(e.statements[0]);if(n&&r===0)for(let a of s)typeof a.Id=="string"&&n.add(a.Id);return l(s)}let u=[],d=new Set;for(let[s,a]of e.statements.entries())for(let h of await t(a)){let f=h.Id;if(typeof f=="string"){if(n&&s>=r&&n.add(f),d.has(f))continue;d.add(f)}if(u.push(h),i!==void 0&&u.length>i)return l(u)}return u}function pe(e,t,n,{settle:o=!0}={}){let r=[];for(let i of n){let l=i.Id;typeof l=="string"&&l&&r.push(l)}o?e.addRead(t,r):e.add(t,r)}function Ge(e,t,n,o,r={}){pe(e,t,n,r);let i=r.keyPrefixes??new Map,l=o.filter(u=>u.isReference&&u.referenceTo&&u.referenceTo.length>0);for(let u of l){let d=u.referenceTo??[];for(let s of n){let a=s[u.name];if(!(typeof a!="string"||!a))for(let h of se(a,d,i))e.add(h,[a])}}}function he(e,t){let n=e.findIndex(l=>l.objectApiName===t);if(n<0)throw new Error(`Cannot run scoped clone with root "${t}" missing from the graph. The root node was excluded or filtered out \u2014 re-include it before executing.`);let o=e[n];if(!o.included)throw o.status==="error"?new Error(`Cannot run scoped clone: root "${t}" could not be measured during discovery (${o.errors[0]??"unknown discovery error"}), and nothing was read or written. Run discovery again once the org answers for it; if it refuses again, the user the clone reads as may not read ${t}: start from a record the user can read.`):new Error(`Cannot run scoped clone with root "${t}" excluded: the clone starts from its record, and the records that point at it would be written without it. Include it again, or clone from a query instead of a record.`);if(n===0)return e;let r=[...e],[i]=r.splice(n,1);return r.unshift(i),r}function q(e,t){let n=t??e.edges,o=new Map;for(let s of e.nodes)o.set(s.objectApiName,s);let r=new Map,i=new Map;for(let s of e.nodes)r.set(s.objectApiName,0);for(let s of n){r.has(s.targetObject)&&r.set(s.targetObject,(r.get(s.targetObject)??0)+1);let a=i.get(s.sourceObject);a?a.push(s.targetObject):i.set(s.sourceObject,[s.targetObject])}let l=[];for(let[s,a]of r)a===0&&l.push(s);let u=[],d=new Set;for(;l.length>0;){let s=l.shift();if(d.has(s))continue;d.add(s);let a=o.get(s);a&&u.push(a);let h=i.get(s);if(h){for(let f of h)if(r.has(f)){let g=(r.get(f)??1)-1;r.set(f,g),g===0&&!d.has(f)&&l.push(f)}}}for(let s of e.nodes)d.has(s.objectApiName)||u.push(s);return u}export{B as a,Y as b,te as c,G as d,U as e,Ne as f,je as g,xe as h,we as i,se as j,Ae as k,Ee as l,V as m,Ce as n,Fe as o,$e as p,de as q,Te as r,Me as s,fe as t,ke as u,Le as v,pe as w,Ge as x};
|
|
@@ -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-IRQ4WANV.mjs";import"./chunk-J347SPU6.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as seedObjectAccess,b as templateTheOrgTakes};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{G as w,
|
|
7
|
+
import{G as w,Qc as v,Xb as k,e as m,f as h,i as $,j as y,lc as j}from"./chunk-J347SPU6.mjs";var R=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,T=new Set(["static","random","sequence","formula","reference","picklist_random","ai_generate","faker","regex","from_csv"]),A=class{validate(n){let t=[],a=[];return S(n,t),N(n,t,a),P(n,t),n.objects?.length&&C(n,t),M(n,t),q(n,t),{valid:t.length===0,errors:t,warnings:a}}};function S(e,n){(!e.name||e.name.trim().length===0)&&n.push({field:"name",message:"Template name is required"})}function N(e,n,t){if(!e.objects||e.objects.length===0){n.push({field:"objects",message:"Template must have at least one object"});return}for(let a of e.objects)E(a,n,t,$(a.objectApiName,e.relations))}function E(e,n,t,a){let i=`objects[${e.objectApiName}]`;(!e.objectApiName||e.objectApiName.trim().length===0)&&n.push({field:i,message:"Object API name is required"}),e.recordCount<=0&&n.push({field:`${i}.recordCount`,message:"Record count must be positive"}),e.recordCount>0&&e.fieldRules.length===0&&!a&&!V(e.rows)&&n.push({field:`${i}.fieldRules`,message:`${e.objectApiName} asks for ${e.recordCount} record(s) and names no field to fill: add at least one field rule`}),e.recordCount>1e5&&t.push({field:`${i}.recordCount`,message:"Record count exceeds 100,000 \u2014 consider using grappe mode"}),e.batchSize<=0&&n.push({field:`${i}.batchSize`,message:"Batch size must be positive"});for(let s of e.fieldRules)F(s,i,n);e.rows!==void 0&&x(e.rows,i,n)}function V(e){return Array.isArray(e)&&e.some(n=>b(n?.values)&&Object.keys(n.values).length>0)}function b(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function x(e,n,t){if(!Array.isArray(e)||e.length===0){t.push({field:`${n}.rows`,message:"Rows, when given, are at least one"});return}let a=new Set,i=h.maxKeyLength;for(let[s,o]of e.entries()){let r=`${n}.rows[${s}]`,c=b(o)?o:{},{key:d,parentKey:l,values:f}=c;if(typeof d!="string"||d.length===0||d.length>i?t.push({field:`${r}.key`,message:`A row is named by a key of 1 to ${i} characters`}):a.has(d)?t.push({field:`${r}.key`,message:`The key "${d}" names more than one row: each row is named once`}):a.add(d),l!==void 0&&(typeof l!="string"||l.length===0||l.length>i)&&t.push({field:`${r}.parentKey`,message:`A row names its parent by a key of 1 to ${i} characters`}),!b(f)){t.push({field:`${r}.values`,message:"A row gives its values as fields and values"});continue}for(let[u,g]of Object.entries(f))O(g)||t.push({field:`${r}.values[${u}]`,message:`${u} is given a value no field takes: a text of at most ${h.maxTextLength} characters, a number, true or false, or null`})}}function O(e){return e===null||typeof e=="boolean"?!0:typeof e=="number"?Number.isFinite(e):typeof e=="string"&&e.length<=h.maxTextLength}function C(e,n){let t=i=>{let[s,o,...r]=i,c=s==="objects"?e.objects[Number(o)]:void 0,d=s==="relations"?e.relations?.[Number(o)]:void 0,l=c?`objects[${c.objectApiName}]`:d?`relations[${d.childObject}.${d.lookupField}]`:`${String(s)}[${String(o)}]`;return r.reduce((f,u)=>typeof u=="number"?`${f}[${u}]`:`${f}.${u}`,l)};if(e.objects.every(i=>i.rows===void 0||Array.isArray(i.rows)&&i.rows.every(b)))for(let i of w(e))n.push({field:t(i.path),message:i.message})}function F(e,n,t){let a=`${n}.fieldRules[${e.fieldApiName}]`;(!e.fieldApiName||e.fieldApiName.trim().length===0)&&t.push({field:a,message:"Field API name is required"}),T.has(e.ruleType)||t.push({field:`${a}.ruleType`,message:`Invalid rule type: ${e.ruleType}`}),I(e,a,t)}function I(e,n,t){switch(e.ruleType){case"reference":e.config.referenceObject||t.push({field:`${n}.config.referenceObject`,message:"Reference rule requires a referenceObject"});break;case"picklist_random":(!e.config.picklistValues||e.config.picklistValues.length===0)&&t.push({field:`${n}.config.picklistValues`,message:"Picklist rule requires at least one value"});break;case"faker":e.config.fakerMethod?j(e.config.fakerMethod)||t.push({field:`${n}.config.fakerMethod`,message:`Faker method "${e.config.fakerMethod}" in ${n} is not implemented: choose a method SandForge generates. No record was written.`}):t.push({field:`${n}.config.fakerMethod`,message:"Faker rule requires a fakerMethod"});break;case"ai_generate":e.fieldType!==void 0&&!k(e.fieldType)&&t.push({field:`${n}.ruleType`,message:`AI generation in ${n} writes text, which a "${e.fieldType}" field cannot hold: choose another rule for this field. No record was written.`});break;case"regex":e.config.regexPattern||t.push({field:`${n}.config.regexPattern`,message:"Regex rule requires a regexPattern"});break;case"from_csv":e.config.csvColumn||t.push({field:`${n}.config.csvColumn`,message:"CSV rule requires a csvColumn"});break}}function P(e,n){let t=new Set(e.objects.map(i=>i.objectApiName)),a=new Set;for(let i of e.relations??[]){let{childObject:s,lookupField:o,parentObject:r}=i,c=`relations[${s}.${o}]`;if(t.has(s)||n.push({field:c,message:`The relation on ${s}.${o} fills an object the template does not write`}),a.has(s)&&n.push({field:c,message:`${s} has more than one relation: an object takes its record count from one relation, so keep one and let the other lookup draw from its field rule`}),a.add(s),i.parents.kind==="generated")r===s?n.push({field:c,message:`${s} records cannot point at ${s} records written by the same insert: draw the parents from records already in the org`}):t.has(r)||n.push({field:c,message:`The relation draws ${s}'s parents from the ${r} records this run writes, and the template writes none`});else if(i.parents.kind==="records"){let d=Array.isArray(i.parents.ids)?i.parents.ids:[],l=m.maxExistingParents;if(d.length<1||d.length>l)n.push({field:`${c}.parents.ids`,message:`The relation on ${s}.${o} names between 1 and ${l} ${r} records by id, not ${d.length}`});else{let f=d.filter(g=>typeof g!="string"||!R.test(g)),u=d.filter(g=>typeof g=="string").map(g=>g.slice(0,15));f.length>0?n.push({field:`${c}.parents.ids`,message:`The relation on ${s}.${o} names ${f.length} parent(s) by something that is not a record id, 15 or 18 letters and digits: ${f.slice(0,3).map(String).join(", ")}`}):new Set(u).size!==u.length&&n.push({field:`${c}.parents.ids`,message:`The relation on ${s}.${o} names the same ${r} record more than once: each parent is given once`})}}else p(i.parents.limit,1,m.maxExistingParents)||n.push({field:`${c}.parents.limit`,message:`The relation on ${s}.${o} reads between 1 and ${m.maxExistingParents} existing ${r} records`});_(i.distribution)||n.push({field:`${c}.distribution`,message:`The relation on ${s}.${o} gives each ${r} a number of children it cannot use`})}}function p(e,n,t){return Number.isInteger(e)&&e>=n&&e<=t}function _(e){let n=m.maxPerParent;switch(e.mode){case"perParent":return p(e.count,1,n);case"range":return p(e.min,0,n)&&p(e.max,1,n)&&e.min<=e.max;case"ratio":return Number.isFinite(e.ratio)&&e.ratio>=m.minRatio&&e.ratio<=n;case"byKey":return!0;default:return!1}}function M(e,n){let t=new Set(e.objects.map(a=>a.objectApiName));for(let a of e.objects){let i=$(a.objectApiName,e.relations);for(let s of a.fieldRules)i&&s.fieldApiName===i.lookupField||v(s,t)||s.ruleType==="reference"&&s.config.referenceObject&&(t.has(s.config.referenceObject)||n.push({field:`objects[${a.objectApiName}].fieldRules[${s.fieldApiName}]`,message:`Reference target "${s.config.referenceObject}" is not in the template`}))}}function q(e,n){let t=new Map;for(let o of e.objects)t.set(o.objectApiName,y(o,e.relations));let a=new Set,i=new Set;function s(o){if(i.has(o))return!0;if(a.has(o))return!1;i.add(o);let r=t.get(o)??[];for(let c of r)if(s(c))return!0;return i.delete(o),a.add(o),!1}for(let o of e.objects)if(s(o.objectApiName)){n.push({field:`objects[${o.objectApiName}]`,message:"Circular dependency detected"});break}}export{A as a};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{
|
|
7
|
+
import{Lb as a}from"./chunk-J347SPU6.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";function r(e,n,o,s){return{id:e,status:n,reason:o,...s!==void 0?{at:s}:{}}}function t(e,n,o){return o!==void 0?r(e,"done","ranAfterRefresh",o):n.acks.steps[e]==="skipped"?r(e,"skipped","skipped"):r(e,"todo","toDo")}function p(e,n){let o=n.acks.steps[e];return o==="done"?r(e,"done","markedDone"):o==="skipped"?r(e,"skipped","skipped"):r(e,"todo","toDo")}function u(e){return e.kind!=="sandbox"?!0:e.sandboxType==="Developer"||e.sandboxType==="DeveloperPro"}function y(e){let n=e.checkpointsNow.at(-1);return[e.refresh!==void 0?r("refresh","done","refreshDetected",e.refresh.detectedAt):r("refresh","notApplicable","noRefreshDetected"),e.lastUsersRun?.status!=="success"&&e.usersToBringBack===0?r("users","notApplicable","noUserToBringBack"):t("users",e,e.lastUsersRun?.status==="success"&&e.lastUsersRunTakenBack!==!0?e.lastUsersRun.at:void 0),u(e)?r("masking","notApplicable","nothingCopied"):t("masking",e,e.maskedAt),e.checkpointBefore===void 0?r("replay","notApplicable","noCheckpointBefore"):t("replay",e,e.replayedAt),e.frozenManifest===void 0?r("frozen","notApplicable","noManifest"):e.tier==="staging"&&e.acks.steps.frozen!=="skipped"?r("frozen","refused","stagingSandbox"):t("frozen",e,e.frozenLoadedAt),t("testersCheckpoint",e,n?.takenAt),p("deliverability",e),e.inventoryBefore===void 0?r("scheduledJobs","notApplicable","noInventoryBefore"):t("scheduledJobs",e,e.inventoryNowAt),p("endpoints",e),t("handoff",e,e.handoffAt)]}function i(e,n,o){return n?{id:e,status:"done",reason:"ready",...o!==void 0?{at:o}:{}}:{id:e,status:"todo",reason:"toDo"}}function l(e){let n=e.checkpointsNow[0];return[i("beforeRefreshCheckpoint",n?.keptUntilDeleted===!0,n?.takenAt),i("jobsInventory",e.inventoryNowAt!==void 0,e.inventoryNowAt),i("testersList",e.testersSavedAt!==void 0,e.testersSavedAt),i("automation",e.refreshPipeline===!0)]}function c(e){let n=y(e),{done:o,total:s}=a(n),d=u(e)?void 0:e.maskObjects;return{orgId:e.orgId,alias:e.alias,tier:e.tier,...e.sandboxType!==void 0?{sandboxType:e.sandboxType}:{},...e.myDomainHost!==void 0?{myDomainHost:e.myDomainHost}:{},...e.organizationId!==void 0?{organizationId:e.organizationId}:{},...e.refresh!==void 0?{refresh:e.refresh}:{},...e.checkpointBefore!==void 0?{checkpointBefore:e.checkpointBefore}:{},...e.frozenManifest!==void 0?{frozenManifest:e.frozenManifest}:{},...e.inventoryBefore!==void 0?{inventoryBefore:e.inventoryBefore}:{},...d!==void 0?{maskObjects:d}:{},...e.handoffAt!==void 0?{handoffNote:{writtenAt:e.handoffAt}}:{},...e.acks.finishedAt!==void 0?{finishedAt:e.acks.finishedAt}:{},...e.lastUsersRun!==void 0?{lastUsersRun:{...e.lastUsersRun,...e.lastUsersRunTakenBack===!0?{takenBack:!0}:{}}}:{},steps:n,beforeNextRefresh:l(e),done:o,total:s}}export{c as recoveryStatusOf};
|
|
@@ -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 N}from"./chunk-
|
|
7
|
+
import{a as N}from"./chunk-DLSU66MY.mjs";import{a as j,h as D}from"./chunk-TZE3Y7IQ.mjs";import{b as J}from"./chunk-CA5NAXSU.mjs";function se(e){return`sync-before-${e.replace(/[^A-Za-z0-9-]+/g,"-")}`.slice(0,200)}var oe=1e3;function he(e){let o=se(e.runId),d=new Map,a=e.everyMs??oe,g=()=>(e.now?.()??new Date).getTime(),S,I=Number.NEGATIVE_INFINITY,k,E=!1,R=h=>{if(S===void 0)return;let t=[...d].map(([l,c])=>({objectApiName:l,recordCount:c,truncated:!1}));e.meta.set(`backup:${o}`,{operationId:o,orgId:e.orgId,...e.organizationId!==void 0?{organizationId:e.organizationId}:{},objects:t,partial:h,timestamp:S,totalRecords:t.reduce((l,c)=>l+c.recordCount,0),origin:"sync",runId:e.runId},"backups")},z=()=>{if(E)return;let h=I+a-g();if(h<=0){k!==void 0&&clearTimeout(k),k=void 0,I=g(),R(!0);return}k??=setTimeout(()=>{if(k=void 0,!E){I=g();try{R(!0)}catch{}}},h),k.unref?.()};return{id:o,keep:async(h,t)=>{t.length!==0&&(d.has(h)||(S??=(e.now?.()??new Date).toISOString(),d.set(h,0),R(!0),await e.files.begin(o,h)),await e.files.append(o,h,t),d.set(h,(d.get(h)??0)+t.length),z())},close:()=>{E=!0,k!==void 0&&clearTimeout(k),k=void 0,R(!1)}}}var F=200,de=["LastModifiedDate","LastModifiedById"],ee=100,te=4e3,ae=20,ne=255;function ce(e=ne){return 2*Math.max(0,e)+2}function ke(e,o){let d=o===void 0||o.creatable.size+4>ee;if(e.toLowerCase()==="id")return{characters:ae,wide:d};let a=o?.fields?.find(g=>g.name.toLowerCase()===e.toLowerCase());return a&&["double","int","long","currency","percent"].includes(a.type??"")?{characters:(a.precision??a.digits??18)+2,wide:d}:{characters:ce(a?.length??ne),wide:d}}function fe(e){let o=e.wide?F/4:F,d=Math.floor((te+2)/(Math.max(1,e.characters)+2));return Math.max(1,Math.min(o,d))}function me(e,o){let d=fe(o),a=e.reduce((g,S)=>g+Math.ceil(Math.max(0,S)/d),0);return a>0?a+1:0}function u(e){return e.slice(0,15)}function U(e,o){if(typeof e=="number"&&Number.isFinite(e))return`#${e}`;if(!(typeof e!="string"||e===""))return o?u(e):e.toLowerCase()}function ue(e){return typeof e=="number"?String(e):`'${j(String(e))}'`}function ge(e,o){let d=[],a=[],g=0;for(let S of e){let I=ue(S);a.length>0&&(a.length>=o||g+I.length>te)&&(d.push(a),a=[],g=0),a.push(I),g+=I.length+2}return a.length>0&&d.push(a),d}function le(e,o,d){return`What these ${o} ${e} record(s) would write over in the target could not be read and kept first (${J(d)}), so none of them was written: a run writes over nothing it cannot put back.`}function Se(e){let o=new Map,d=new Map,a=new Set,g=new Map,S=new Map,I=new Map,k=new Map,E=new Map,R=new Map,z=t=>{let l=e.describe,c=e.viewsEncrypted;if(!l||!c)return Promise.resolve(new Set);let y=I.get(t);return y||(y=l(t).then(async f=>{let m=(f.fields??[]).filter(M=>M.type===N).map(M=>M.name);return m.length>0&&!await c()?new Set(m):new Set},()=>new Set),I.set(t,y)),y},h=t=>{let l=e.describe;if(!l)return Promise.resolve(new Set);let c=S.get(t);return c||(c=l(t).then(y=>new Set((y.fields??[]).filter(f=>f.type==="base64"||f.queryable===!1).map(f=>f.name)),()=>new Set),S.set(t,c)),c};return{before:async(t,l,c,y)=>{if(g.delete(t),l!=="update"&&l!=="upsert"||c.length===0)return;let f=l==="update"?"Id":y??"Id",m=f==="Id";try{D(t),D(f);let M=await h(t),p=await z(t),v=new Set,O=new Set,T=new Map;for(let n of c){let i=U(n[f],m);i!==void 0&&!T.has(i)&&T.set(i,n[f]);for(let[r,s]of Object.entries(n))if(!(r==="Id"||r===f||r==="attributes")&&!M.has(r)&&!(typeof s=="object"&&s!==null)){if(p.has(r)){O.add(r);continue}v.add(D(r))}}if(T.size===0||v.size===0&&O.size===0)return;let x=["Id",...m?[]:[f],...v],V=[...x,...de.filter(n=>!x.includes(n))],re=V.length>ee?F/4:F,$=new Map,P=R.get(t)===!1?x:V;for(let n of ge([...T.values()],re)){let i=s=>`SELECT ${s.join(", ")} FROM ${t} WHERE ${f} IN (${n.join(", ")})`,r;try{r=await e.query(i(P))}catch(s){if(P===x)throw s;P=x,R.set(t,!1),r=await e.query(i(P))}for(let s of r){let w=U(m?s.Id:s[f],m);w===void 0||typeof s.Id!="string"||$.set(w,[...$.get(w)??[],s])}}let K=o.get(t)??new Map,_=[],B=new Map,C=new Map,G=new Map;for(let n of c){let i=U(n[f],m),r=i===void 0?void 0:$.get(i),s=r?.length===1?r[0]:void 0,w=s?.Id;if(_.push(w),!s||w===void 0||a.has(u(w)))continue;typeof s.LastModifiedDate=="string"&&G.set(u(w),{id:w,at:s.LastModifiedDate,...typeof s.LastModifiedById=="string"?{by:s.LastModifiedById}:{}});let ie=K.get(u(w)),q=B.get(u(w))??{Id:w},Q=C.get(u(w))??new Set;for(let b of Object.keys(n))!v.has(b)||ie?.has(b)||b in q||(q[b]=s[b]??null,Q.add(b));Q.size!==0&&(B.set(u(w),q),C.set(u(w),Q))}if(O.size>0&&_.some(n=>n!==void 0&&!a.has(u(n)))){let n=k.get(t)??new Set,i=[...O].filter(r=>!n.has(r));if(i.length>0){for(let r of i)n.add(r);k.set(t,n),e.recorder.unkept?.(t,i)}}if(B.size===0){g.set(t,{reaches:_,named:[],added:new Map});return}let X=[...B.values()],L=d.get(t)??new Map,Y=X.flatMap(n=>{let i=L.get(u(n.Id)),r=Object.entries(n).filter(([s])=>s==="Id"||!i?.has(s));return r.length>1?[Object.fromEntries(r)]:[]});Y.length>0&&await e.backup.keep(t,Y);for(let n of Y){let i=L.get(u(n.Id))??new Set;for(let r of Object.keys(n))r!=="Id"&&i.add(r);L.set(u(n.Id),i)}d.set(t,L);let A=X.map(n=>n.Id),W=E.get(t)??new Set,H=[];for(let n of A){let i=u(n);if(W.has(i))continue;W.add(i);let r=G.get(i);r&&H.push(r)}E.set(t,W),H.length>0?e.recorder.overwriting?.(t,e.backup.id,A,H):e.recorder.overwriting?.(t,e.backup.id,A);let Z=await e.recorder.flush();if(Z!==void 0)throw new Error(`the run's file could not be written: ${Z}`);for(let[n,i]of C){let r=K.get(n)??new Set;for(let s of i)r.add(s);K.set(n,r)}o.set(t,K),g.set(t,{reaches:_,named:A,added:C});return}catch(M){return le(t,c.length,M)}},answered:(t,l,c)=>{if(l==="insert"||l==="upsert")for(let p of c)p.success&&typeof p.id=="string"&&p.id!==""&&(l==="insert"||p.created===!0)&&a.add(u(p.id));let y=g.get(t);if(g.delete(t),!y||y.named.length===0)return;let f=new Set;c.forEach((p,v)=>{let O=y.reaches[v];O!==void 0&&p.success&&p.created!==!0&&f.add(u(O))});let m=y.named.filter(p=>!f.has(u(p))),M=o.get(t);for(let p of m){let v=M?.get(u(p));for(let O of y.added.get(u(p))??[])v?.delete(O)}e.recorder.overwrote?.(t,m)}}}export{se as a,he as b,ae as c,ce as d,ke as e,me as f,Se as g};
|
|
@@ -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 Ie}from"./chunk-GMY5427L.mjs";import{a as Fe,b as Ce,c as Le,f as We,g as Ae}from"./chunk-GB6W4Q56.mjs";import{h as Se,i as ke}from"./chunk-AVY742BJ.mjs";import{c as Te}from"./chunk-BWWQXU2B.mjs";import{f as me,i as we,m as Re,o as Oe,p as be}from"./chunk-35B73566.mjs";import{d as he}from"./chunk-UCUFLFNK.mjs";import{b as fe,c as q,m as pe}from"./chunk-HFSBDM7B.mjs";import{d as K}from"./chunk-OHEOJISY.mjs";import{G as se,q as te,s as ne,t as re,u as oe}from"./chunk-SZOJ7BEJ.mjs";import{b as ee}from"./chunk-CA5NAXSU.mjs";import{a as U,l as ie,o as ae,q as de,t as ce,u as ue,v as le}from"./chunk-ICIYL45C.mjs";import{b as ye,e as ge}from"./chunk-3KJCSYXY.mjs";import{Zc as X,qd as B}from"./chunk-J347SPU6.mjs";var H=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function b(t){return t.slice(0,15)}var Ee=class{constructor(e=new Map){this.earlier=e}earlier;written=new Map;refused=new Map;deleted=new Set;ownersRefused=new Set;contactsSentWith=new Map;noteSentWithContact(e,n){this.contactsSentWith.set(b(e),n)}contactSentWith(e){return this.contactsSentWith.get(b(e))}roleLinkedFor(e){this.contactsSentWith.delete(b(e))}get sentWithAContact(){return this.contactsSentWith.size>0}noteOwnerRefused(e){this.ownersRefused.add(b(e))}isOwnerRefused(e){return this.ownersRefused.has(b(e))}noteDeleted(e){for(let n of e)this.deleted.add(b(n))}standing(e){return e!==void 0&&this.deleted.has(b(e))?void 0:e}noteMatched(e,n){this.noteWritten(e,n)}noteWritten(e,n){this.written.set(b(e),n),this.refused.delete(b(e))}noteRefused(e,n){this.written.has(b(e))||this.refused.set(b(e),n)}targetOf(e){return this.standing(this.written.get(b(e)))??this.standing(this.earlier.get(b(e)))}refusedObjectOf(e){if(this.standing(this.earlier.get(b(e)))===void 0)return this.refused.get(b(e))}};function Pe(t,e,n){if(e.length===0||!n.some(o=>!o.master))return;let r={};for(let o of e)r[o]=(r[o]??0)+1;let s=Ce(Fe(n));return{objectApiName:t,rows:e.length,why:r,...s?{predicted:s}:{}}}function Ne(t,e){return q(t,e?.target??[])}function Y(t){switch(t.operation){case"insert":return null;case"upsert":return t.externalIdField??"Id";case"update":case"delete":return"Id"}}function Ke(t,e,n,r,s){let o=ge(t,e);for(let i of n)(!(i.fieldApiName in o)||i.overwriteExisting)&&(o[i.fieldApiName]=i.value);if(!r)return o;let a={};for(let i of Object.keys(o))i!=="attributes"&&(r.has(i)||i===s)&&(a[i]=o[i]);return a}function xe(t,e){return`${t} ${e} record${t===1?"":"s"}`}function qe(t,e,n){let r=a=>e.find(i=>b(i.recordTypeId)===b(a)),s=t;if(!r(t)&&n){let a=n.mappings.find(i=>b(i.sourceId)===b(t));if(!a){let i=n.source.find(d=>b(d.id)===b(t)),p=i?(n.target??[]).filter(d=>d.sobjectType===i.sobjectType&&d.developerName===i.developerName):[];return{unmapped:i?K(i):"",namesakes:p.map(K)}}s=a.targetId}let o=q(e.filter(a=>b(a.recordTypeId)===b(s)),n?.target??[])[0];return o&&!o.available&&!o.master?{unavailable:o}:o?{sent:s,info:o}:{sent:s}}function He(t,e,n){if(t?.personAccounts===!1)return!0;if(!n)return!1;let r=e??We(t?.recordTypes);return r!==void 0&&!n.has(b(r))}function ve(t,e,n){return{group:`parent:${e}:${n}`,reason:`PARENT_REFUSED: the ${n} record its ${e} names was refused in this run.`,say:r=>`PARENT_REFUSED: ${xe(r,t)} held back, not sent: the ${n} record their ${e} names was refused in this run, and written without it they would stand without their ${n}.`}}function je(t){let{config:e,records:n,target:r,run:s}=t,o=e.objectApiName,a=Y(e),i=r?.recordTypes??[],p=r?.references??new Set,d={payloads:[],sentAt:[],settled:[],held:[],deferred:[],deferredAcross:[],notes:[],currencies:[],withoutRecordType:new Map},g=new Map,m=new Map,F=(c,w,u,y)=>{d.held.push({index:c,reason:u}),g.delete(c);let R=m.get(w);R?R.count++:m.set(w,{count:1,say:y})},T=e.operation==="insert"||e.operation==="upsert",A=T&&i.some(c=>!c.master),l=new Map;s&&T&&s.sources.forEach((c,w)=>{let u=c?.Id;typeof u=="string"&&H.test(u)&&l.set(b(u),w)});let W=new Set([...s&&T?s.later??[]:[]].map(c=>c.toLowerCase())),S=new Set(W.size===0?[]:(r?.fields??[]).flatMap(c=>c.isReference&&(c.referenceTo??[]).some(w=>W.has(w.toLowerCase()))&&!(c.nillable===!1&&c.defaultedOnCreate!==!0)?[c.name]:[]));n.forEach((c,w)=>{let u=Ke(c,e.fieldMappings,e.addOnFields,r?.creatable??null,a);if(e.operation==="delete"){g.set(w,{payload:u,settled:new Set});return}let y=new Set;if(s)for(let O of Object.keys(u)){let h=u[O];if(O==="RecordTypeId"||!p.has(O)||typeof h!="string"||!H.test(h))continue;if(l.has(b(h))){delete u[O],d.deferred.push({index:w,field:O,parent:h});continue}let $=s.links.targetOf(h);if($){u[O]=$,y.add(O);continue}let z=s.links.refusedObjectOf(h);if(z===void 0){S.has(O)&&(delete u[O],d.deferredAcross.push({index:w,field:O,parent:h}));continue}let N=ve(o,O,z);F(w,N.group,N.reason,N.say);return}let R=u.RecordTypeId,P,x=Te(R);if(x)delete u.RecordTypeId;else if(typeof R=="string"&&H.test(R)){let O=qe(R,i,s?.recordTypes);if("unmapped"in O){let h=O.unmapped,$=O.namesakes.length>0?` The target org's ${O.namesakes.join(" and ")} carries its DeveloperName under another namespace, and a record type is mapped to one of the same namespace only.`:"";F(w,`unmapped:${h}`,"RECORD_TYPE_UNMAPPED: its record type has no counterpart in the target org.",z=>`RECORD_TYPE_UNMAPPED: ${xe(z,o)} held back, not sent: `+(h?`their record type ${h} has no active ${o} record type of that API name in the target org.${$} Create or activate record type ${h} on ${o} in the target org.`:"their record type is inactive in the source org, and has no counterpart in the target org."));return}if("unavailable"in O){let h=O.unavailable;F(w,`unavailable:${h.recordTypeId}`,`RECORD_TYPE_UNAVAILABLE: record type ${h.developerName} is closed to the running user in the target org.`,$=>`${pe({objectApiName:o,recordTypeId:h.recordTypeId,developerName:h.developerName,name:h.name,inactive:!h.active,recordCount:$})} Held back, not sent.`);return}u.RecordTypeId=O.sent,P=O.sent,O.info&&y.add("RecordTypeId")}let D=s?.sources[w]??c;if(re(D)){let O=oe(D,He(r,P,s?.recordTypes?.personTypes));for(let h of Object.keys(u))B(o,h,O)&&delete u[h]}else for(let O of Object.keys(u))B(o,O,"business")&&delete u[O];A&&!("RecordTypeId"in u)&&d.withoutRecordType.set(w,x?"masterInSource":"notRead"),g.set(w,{payload:u,settled:y})});let I=!0;for(;I;){I=!1;for(let{index:c,field:w,parent:u}of d.deferred){let y=l.get(b(u));if(!g.has(c)||y===void 0||g.has(y)||s?.links.targetOf(u)!==void 0)continue;let R=ve(o,w,o);F(c,R.group,R.reason,R.say),I=!0}}d.deferred=d.deferred.filter(({index:c})=>g.has(c)),d.deferredAcross=d.deferredAcross.filter(({index:c})=>g.has(c));for(let c of[...d.withoutRecordType.keys()])g.has(c)||d.withoutRecordType.delete(c);d.held.sort((c,w)=>c.index-w.index);let C=e.operation==="delete"?void 0:s?.currencies,v=r?.creatable.has(U)===!0,f=!v&&(s?.currencyChangesById?.size??0)>0&&r?.fields?.some(c=>c.name===U)===!0,L=C&&(v||f)?ae(r?.fields??[]):void 0,k=[...r?.references??[]],E=new le;for(let[c,{payload:w,settled:u}]of[...g].sort(([y],[R])=>y-R)){for(let y of X(o,w))delete w[y];if(C&&L){let y=s?.sources[c]??n[c],R=y?.[U],P=v?de(w,{read:R,currencyFields:L,ratesOn:ie(o,y)},C):ue(w,{read:R,parent:y?ce(o,y,k,D=>s?.currencyChangesById?.get(D)):void 0,currencyFields:L},C);E.add(o,P);let x=y?.Id;P&&typeof x=="string"&&s?.currencyChangesById?.set(x,P)}d.payloads.push(w),d.sentAt.push(c),d.settled.push(u)}return d.notes=[...m.values()].map(({count:c,say:w})=>w(c)),d.currencies=E.list(),d}function V(t){return typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0}function Ye(t){let e=V(t.length),n=V(t.precision),r=V(t.digits);return{name:t.name,queryable:t.queryable!==!1,createable:t.createable===!0,isReference:t.type==="reference",...t.type!==void 0?{type:t.type}:{},...e!==void 0?{length:e}:{},...t.nillable!==void 0?{nillable:t.nillable}:{},...t.defaultedOnCreate!==void 0?{defaultedOnCreate:t.defaultedOnCreate}:{},...t.calculated===!0?{calculated:!0}:{},...n!==void 0?{precision:n}:{},...n!==void 0&&typeof t.scale=="number"&&t.scale>=0?{scale:t.scale}:{},...r!==void 0?{digits:r}:{},...t.unique===!0?{unique:!0}:{},...t.referenceTo?{referenceTo:[...t.referenceTo]}:{}}}function wt(t){let e=t.fields.filter(r=>r.createable===!0),n=t.fields.some(r=>typeof r.idLookup=="boolean");return{creatable:new Set(e.map(r=>r.name)),references:new Set(e.filter(r=>r.type==="reference").map(r=>r.name)),...typeof t.createable=="boolean"?{objectCreateable:t.createable}:{},...typeof t.updateable=="boolean"?{objectUpdateable:t.updateable}:{},recordTypes:fe(t.recordTypeInfos),...t.name===te?{personAccounts:t.fields.some(r=>r.name===ne)}:{},fields:t.fields.map(Ye),...n?{upsertKeys:new Set(t.fields.filter(r=>r.externalId===!0||r.idLookup===!0).map(r=>r.name.toLowerCase()))}:{}}}function Z(t,e,n){switch(e){case"notInTarget":return`Object is not in the target org, or the user the run writes as cannot see it: ${t}. None of its records were sent.`;case"notCreateable":return`Object is not createable on target org: the user the run writes as may not create ${t} records there. None of its records were sent.`;case"notUpdateable":return`Object is not updateable on target org: the user the run writes as may not edit ${t} records there. None of its records were sent.`;case"unread":return`The target org did not describe ${t}${n?` (${n})`:""}, so what it takes could not be told and none of its records were sent.`;case"notAKey":return`The upsert of ${t} matches on ${n??"a field"}, which the target org does not match an upsert on: it takes an External ID field, the Id, or a field its describe marks idLookup. None of its records were sent.`}}function Rt(t,e){let n=t.externalIdField?.trim().toLowerCase();if(t.operation!=="upsert"||!n)return t;let r=e.fields?.find(s=>s.name.toLowerCase()===n)?.name;return r===void 0?t:{...t,externalIdField:r}}function Ot(t,e){if(t.operation==="delete"||t.query===void 0)return t;let n=Ie(t.query);if(!("list"in n))return t;let r=new Set([...n.list,t.externalIdField??"",...t.fieldMappings.filter(o=>ye.has(o.type)).map(o=>o.sourceField)].map(o=>o.toLowerCase())),s=[...e.creatable].filter(o=>!r.has(o.toLowerCase()));return s.length===0?t:{...t,excludedFields:[...new Set([...t.excludedFields??[],...s])]}}async function De(t,e,n,r){let s;try{s=await t(e)}catch(d){if(n==="delete")return{notAsked:!0};let g=Ae(d)?"notInTarget":"unread";return{refused:{why:g,message:Z(e,g,ee(d))}}}let o=n==="insert"||n==="upsert",a=n==="update"||n==="upsert",i=o&&s.objectCreateable===!1?"notCreateable":a&&s.objectUpdateable===!1?"notUpdateable":void 0;if(i)return{refused:{why:i,message:Z(e,i)},target:s};let p=r?.trim()||"Id";return n==="upsert"&&s.upsertKeys&&!s.upsertKeys.has(p.toLowerCase())?{refused:{why:"notAKey",message:Z(e,"notAKey",p),key:p},target:s}:{target:s}}function kt(t){return t.keepContactPoints===!0?void 0:new ke}function Tt(t,e){if(!t)return e?{neutralized:!1,fields:[],values:0}:void 0;let n=t.report();return n.values>0?n:void 0}function $e(t,e,n,r,s){let o=s?n.filter(i=>i.name!==s):n,a=t.forObject(e,o);if(a)for(let i of r)a(i)}var j=class extends Error{constructor(n,r=[],s=[],o=[],a){super(r.length===0?`The write of ${n} was cancelled before any of its records was written.`:`The write of ${n} was cancelled after ${r.length} of its records were sent.`);this.objectApiName=n;this.written=r;this.notes=s;this.lookupsLeftOut=o;this.writtenWithoutFields=a;this.name="WriteCancelledError"}objectApiName;written;notes;lookupsLeftOut;writtenWithoutFields};var Me=class{deps;constructor(e){this.deps=e}async sync(e,n,r){let{outcomes:s,notes:o,currencies:a,lookupsLeftOut:i,writtenWithoutFields:p}=await this.write(e,n,r);return tt(nt(e.objectApiName,e.operation,s,o,i,p),a)}updateRecords(e,n,r){return this.executeOperation(e,"update",n,r)}async write(e,n,r){let s=null;if(this.deps.describeTargetFields){let f=await De(this.deps.describeTargetFields,e.objectApiName,e.operation,e.externalIdField);if("refused"in f){let L=n.map(()=>({success:!1,errors:[f.refused.message]}));return r&&Ue(e,L,r),{outcomes:L,notes:[],currencies:[],lookupsLeftOut:[]}}"target"in f&&f.target.creatable.size>0&&(s=f.target)}let o=je({config:e,records:n,target:s,run:r}),a=r?r.contactPoints:this.deps.contactPoints;a&&s?.fields&&$e(a,e.objectApiName,s.fields,o.payloads,e.externalIdField);let i=Je(o.payloads,o.settled,r),p=new Map(o.held.map(({index:f,reason:L})=>[f,L])),d=f=>{let L=[],k=0;for(let E=0;E<n.length;E++){let c=p.get(E);if(c!==void 0){L.push({success:!1,errors:[c],heldBack:!0});continue}if(k>=f.length)break;L.push(f[k++])}return L},g,m=o.sentAt.filter(f=>f<(r?.standardFirst??0)).length,F=f=>this.executeOperation(e.objectApiName,e.operation,f,e.batchSize,e.externalIdField);try{g=o.payloads.length===0&&n.length>0?[]:m>0&&m<o.payloads.length?await Xe(e.objectApiName,F,o.payloads.slice(0,m),o.payloads.slice(m)):await F(o.payloads)}catch(f){if(!(f instanceof j))throw f;let L=_e(i,f.written),k=d(f.written);throw ze(e,o.withoutRecordType,k,s,r),new j(e.objectApiName,k,[...o.notes,...f.notes],[...L?[L]:[],...f.lookupsLeftOut,...Q(G([...o.deferred,...o.deferredAcross],k))],f.writtenWithoutFields)}let T=await this.retryRefused(e,o.payloads,g,s?.references??null,o.settled,a&&s?.fields?{neutralizer:a,fieldOf:Se(e.externalIdField?s.fields.filter(f=>f.name!==e.externalIdField):s.fields)}:void 0);if(r)for(let f of T.ownersRefused)r.links.noteOwnerRefused(f);let A=d(T.outcomes);ze(e,o.withoutRecordType,A,s,r);let l=_e(i,T.outcomes),W=[...o.notes,...T.notes],S=[...l?[l]:[],...T.lookupsLeftOut],{writtenWithoutFields:I}=T,C=G(o.deferredAcross,A),v=0;if(T.cancelled)throw new j(e.objectApiName,A,W,[...S,...Q([...G(o.deferred,A),...C])],I);if(r){Ue(e,A,r),et(e,o.payloads,T.outcomes,r.links);let f=await this.setLookups(e,G(o.deferred,A),r.links,!1);if(S.push(...f.leftOut),v=f.unset,f.cancelled)throw new j(e.objectApiName,A,W,[...S,...Q(C)],I)}return{outcomes:A,notes:W,currencies:o.currencies,lookupsLeftOut:S,...I?{writtenWithoutFields:I}:{},...C.length>0?{lookupsToSet:C}:{},...v>0?{lookupsUnset:v}:{}}}async setLookups(e,n,r,s){let o=e.objectApiName,a=new Map,i=new Map,p=new _;for(let{id:l,field:W,parent:S}of n){let I=r.targetOf(S),C=I!==void 0?a:s&&r.refusedObjectOf(S)===void 0?i:void 0;if(!C){p.add(l,W);continue}let v=C.get(l)??{Id:l};v[W]=I??S,C.set(l,v)}let d=new _,g=new _,m=new _,F=new _,T=!1;for(let l of[[...a.values()],[...i.values()]]){if(l.length===0)continue;if(T){for(let S of l)F.addRow(S);continue}let W;try{W=await this.executeOperation(o,"update",l,e.batchSize)}catch(S){if(!(S instanceof j)){let I=S instanceof Error?S.message:String(S);for(let C of l)m.addRow(C,I);continue}W=S.written,T=!0}l.forEach((S,I)=>{let C=W[I];C===void 0?F.addRow(S):C.success?d.addRow(S):C.errors.some(v=>J(v))?g.addRow(S):m.addRow(S,C.errors[0])})}let A=[p,g,m,F];return{...d.records>0?{set:{records:d.records,fields:d.fields()}}:{},leftOut:[p.leftOut("parentRefused"),g.leftOut("notInTarget"),m.leftOut("notSet"),F.leftOut("notReached")].flatMap(l=>l?[l]:[]),unset:new Set(A.flatMap(l=>[...l.recordIds])).size,cancelled:T}}async retryRefused(e,n,r,s,o,a){let i=Y(e)??void 0,p=[...r],d=[...n],g=n.map(()=>new Set),m=n.map(()=>[]),F=n.map(()=>[]),T=n.map(()=>new Map),A=n.map(()=>!1),l=[],W,S=new Set;for(let L=0;L<2+Re&&!W;L++){let k=[],E=[],c=[];if(p.forEach((u,y)=>{if(u.success)return;let R=d[y],P=o[y]??new Set;if(u.errors.some(h=>J(h))){let h=n[y]?.[M];if(typeof h=="string"&&!P.has(M)&&(u.errorDetails??[]).some(N=>J(N.statusCode)&&N.fields.includes(M))&&S.add(h),g[y].has("lookup")||!s||s.size===0)return;let $={},z=!1;for(let N of Object.keys(R)){if(s.has(N)&&!P.has(N)&&R[N]!==null&&R[N]!==void 0){z=!0;continue}$[N]=R[N]}if(!z)return;k.push(y),E.push($),c.push(null);return}if(g[y].has("fields")&&!A[y])return;let x=me(u.errorDetails,R,i);if(!x||x.some(({field:h})=>P.has(h)))return;let D=a?Oe(x,R,a.fieldOf,T[y]):{forms:{},leftOut:x},O=new Set(D.leftOut.map(({field:h})=>h));A[y]=Object.keys(D.forms).length>0,k.push(y),E.push({...Object.fromEntries(Object.entries(R).filter(([h])=>!O.has(h))),...D.forms}),c.push(D.leftOut)}),k.length===0)break;let w;try{w=await this.executeOperation(e.objectApiName,e.operation,E,e.batchSize,e.externalIdField)}catch(u){if(!(u instanceof j)){l.push(...Qe(k,d,E,c,u));break}w=u.written,W=u}w.forEach((u,y)=>{let R=k[y],P=c[y];g[R].add(P===null?"lookup":"fields"),P===null?m[R].push(...Object.keys(d[R]).filter(x=>!(x in E[y]))):F[R].push(...P),d[R]=E[y],p[R]=u})}let I=new Set,C=0,v,f=new Set(S);return p.forEach((L,k)=>{if(!(!L.success||g[k].size===0)){if(m[k].length>0){C++;for(let c of m[k])I.add(c);let E=n[k]?.[M];typeof E=="string"&&m[k].length===1&&m[k][0]===M&&f.add(E)}F[k].length>0&&(v=we(v,{rows:1,fields:F[k].map(E=>({...E,rows:1}))})),a&&g[k].has("fields")&&a.neutralizer.countForms(e.objectApiName,be(T[k],F[k],a.fieldOf))}}),{outcomes:p,notes:[...l,...W?.notes??[]],...v?{writtenWithoutFields:v}:{},cancelled:W!==void 0,ownersRefused:[...f],lookupsLeftOut:[...C>0?[{records:C,fields:[...I].sort(),reason:"notInTarget"}]:[],...W?.lookupsLeftOut??[]]}}async executeOperation(e,n,r,s,o){if(this.deps.crudFlsGuard){let a=r.length>0?Object.keys(r[0]):[],i=await this.deps.crudFlsGuard.checkCrudAndFls(e,n,a);if(!i.allowed)throw new Error(`CRUD/FLS check failed for ${n} on ${e}: ${i.reason}`)}switch(n){case"insert":return this.deps.insert(e,r,s);case"update":return this.deps.update(e,r,s);case"upsert":return this.deps.upsert(e,o??"Id",r,s);case"delete":{let a=r.map(i=>i.Id).filter(i=>typeof i=="string");return this.deps.delete(e,a,s)}}}},Ve=["INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY","INVALID_CROSS_REFERENCE_KEY"],Ze=/cross[- ]reference id|r[ée]f[ée]rence crois[ée]e/i;function J(t){return Ve.some(e=>t.includes(e))||Ze.test(t)}var M="OwnerId";function Je(t,e,n){let r=new Set;return n&&t.forEach((s,o)=>{let a=s[M];typeof a!="string"||e[o]?.has(M)||n.links.isOwnerRefused(a)&&(delete s[M],r.add(o))}),r}function _e(t,e){let n=0;for(let r of t)e[r]?.success&&n++;if(n!==0)return{records:n,fields:[M],reason:"ownerRefusedEarlier"}}function Qe(t,e,n,r,s){let o=s instanceof Error?s.message:String(s),a=new Set,i=new Set,p=0;return r.forEach((d,g)=>{if(d===null){p++;let m=n[g];for(let F of Object.keys(e[t[g]]))F in m||a.add(F)}else for(let{field:m}of d)i.add(m)}),[...p>0?[`${p} record(s) the target refused for a lookup it does not have could not be written again without ${[...a].sort().join(", ")}: ${o}`]:[],...i.size>0?[`${t.length-p} record(s) the target refused on fields it named could not be written again without ${[...i].sort().join(", ")}: ${o}`]:[]]}var _=class{ids=new Set;named=new Set;said;add(e,n){this.ids.add(e),this.named.add(n)}addRow(e,n){let r=String(e.Id);for(let s of Object.keys(e))s!=="Id"&&this.add(r,s);n!==void 0&&n!==""&&(this.said??=n)}get records(){return this.ids.size}get recordIds(){return this.ids}fields(){return[...this.named].sort()}leftOut(e){if(this.ids.size!==0)return{records:this.ids.size,fields:this.fields(),reason:e,...this.said!==void 0?{refusal:this.said}:{}}}};function G(t,e){return t.flatMap(({index:n,field:r,parent:s})=>{let o=e[n];return o?.success&&typeof o.id=="string"&&o.id!==""?[{id:o.id,field:r,parent:s}]:[]})}function Dt(t){return new Set(t.map(({id:e})=>e)).size}function Q(t){let e=new _;for(let{id:r,field:s}of t)e.add(r,s);let n=e.leftOut("notReached");return n?[n]:[]}function Be(t,e){if(!(e.success||t!=="insert"&&t!=="upsert"))return e.existingId!==void 0&&e.existingId!==""?e.existingId:void 0}async function Xe(t,e,n,r){let s=await e(n);try{return[...s,...await e(r)]}catch(o){throw o instanceof j?new j(t,[...s,...o.written],o.notes,o.lookupsLeftOut,o.writtenWithoutFields):o}}function ze(t,e,n,r,s){if(!s?.createdWithoutRecordType||e.size===0)return;let o=[],a=[];for(let[d,g]of e){let m=n[d];!m?.success||typeof m.id!="string"||m.id===""||t.operation!=="insert"&&m.created!==!0||(o.push(g),a.length<Le&&a.push(m.id))}let i=Ne(s.recordTypesUnderTheLease??r?.recordTypes??[],s.recordTypes),p=Pe(t.objectApiName,o,i);p&&s.createdWithoutRecordType.set(t.objectApiName,{given:p,types:i,ids:a})}function et(t,e,n,r){t.objectApiName==="Opportunity"&&(t.operation!=="insert"&&t.operation!=="upsert"||e.forEach((s,o)=>{let a=n[o],i=s[se];!a?.success||typeof a.id!="string"||a.id===""||t.operation!=="insert"&&a.created!==!0||typeof i=="string"&&i!==""&&r.noteSentWithContact(a.id,i)}))}function Ue(t,e,n){if(t.operation==="delete")return;let r=t.operation==="insert"||t.operation==="upsert";e.forEach((s,o)=>{let a=n.sources[o]?.Id;if(typeof a!="string"||a==="")return;let i=Be(t.operation,s);s.success&&typeof s.id=="string"&&s.id!==""?n.links.noteWritten(a,s.id):i!==void 0?n.links.noteWritten(a,i):!s.success&&r&&n.links.noteRefused(a,t.objectApiName)})}function tt(t,e){return e.length>0?{...t,currenciesReplaced:[...e]}:t}var Ge=1e3;function nt(t,e,n,r=[],s=[],o){let a=0,i=0,p=0,d,g=[],m=0,F={created:0,updated:0},T={rows:0,written:0,stillLocked:0};for(let l of n)l.lockResends!==void 0&&(T.rows++,l.success?T.written++:he(l.errors,l.errorDetails)&&T.stillLocked++),l.success?(a++,l.created===!0?F.created++:l.created===!1&&F.updated++):Be(e,l)!==void 0?(p++,d??=l.errors[0]):(i++,!l.heldBack&&m++<Ge&&g.push(...l.errors));let A=Math.max(0,m-Ge);return{objectApiName:t,operation:e,processed:n.length,success:a,failed:i,skipped:p,conflictCount:0,errors:[...g,...r],...p>0?{linkedToExisting:{records:p,...d?{refusal:d}:{}}}:{},...s.length>0?{lookupsLeftOut:[...s]}:{},...o?{writtenWithoutFields:o}:{},...T.rows>0?{sentAgainForALock:T}:{},...A>0?{refusalsDropped:A}:{},...e==="upsert"?{upsertSplit:F}:{}}}export{Ee as a,Pe as b,Ne as c,je as d,wt as e,Rt as f,Ot as g,De as h,kt as i,Tt as j,$e as k,j as l,Me as m,Dt as n,Q as o,Be as p,tt as q,Ge as r,nt as s};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{c as f}from"./chunk-BWWQXU2B.mjs";import{h as y}from"./chunk-TZE3Y7IQ.mjs";import{b as c,e as l,k as p,l as u}from"./chunk-WZQEK4WT.mjs";var g={kind:"master"};function m(e){return e.available&&e.active&&!e.master}function h(e){let t=e.find(a=>a.defaultRecordTypeMapping);if(t&&m(t))return{kind:"given",info:t,basis:"userDefault"};let r=e.filter(m);return r.length===1?{kind:"given",info:r[0],basis:"onlyOneOpen"}:g}function k(e){if(e.kind!=="master")return{developerName:e.info.developerName,label:e.info.name,basis:e.basis}}var b=200,v=/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/;function A(e,t){let r=t.filter(a=>v.test(a)).slice(0,b).map(a=>`'${a}'`);return`SELECT RecordTypeId, COUNT(Id) n FROM ${y(e)} WHERE Id IN (${r.join(", ")}) GROUP BY RecordTypeId`}var T=u({RecordTypeId:c().nullish(),n:l().int().nonnegative()});function D(e,t){let r=p(T).safeParse(e);if(!r.success)return{read:0,types:[],unread:"the org answered rows that name no record type count"};let a=new Map;for(let{RecordTypeId:n,n:o}of r.data){let i=R(n??null,t),d=a.get(i.developerName);d?d.rows+=o:a.set(i.developerName,{...i,rows:o})}let s=[...a.values()].sort((n,o)=>o.rows-n.rows);return{read:s.reduce((n,o)=>n+o.rows,0),types:s}}function R(e,t){if(e===null||f(e)){let a=t.find(s=>s.master);return{developerName:a?.developerName??"Master",label:a?.name??"Master"}}let r=t.find(a=>a.recordTypeId.slice(0,15)===e.slice(0,15));return r?{developerName:r.developerName,label:r.name}:{developerName:e,label:e}}function x(e){if(!e)return;let t=h(e);return t.kind==="given"?t.info.recordTypeId:e.find(r=>r.master)?.recordTypeId}function I(e){if(typeof e!="object"||e===null)return!1;let{errorCode:t,name:r}=e;return t==="NOT_FOUND"||r==="NOT_FOUND"}export{h as a,k as b,b as c,A as d,D as e,x as f,I as g};
|
|
@@ -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{Me as c}from"./chunk-J347SPU6.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";var y=[{type:"seed",label:"Seed Data",description:"Seed an org with a template saved on the Seed page or shipped with SandForge, never a production org; its records are taken back from Seed\u2019s History",category:"data",icon:"database",configSchema:{orgId:{type:"string"},templateId:{type:"string"}}},{type:"sync",label:"Sync Data",description:"Run a Sync configuration saved on the Sync page; a target Production Guard asks about, a production org or a sandbox marked Staging, needs an Approval step before it",category:"data",icon:"sync",configSchema:{configId:{type:"string"}}},{type:"backup",label:"Backup",description:"Take a DataOps snapshot of the listed objects into local storage",category:"data",icon:"archive",configSchema:{orgId:{type:"string"},objects:{type:"array"}}},{type:"restore",label:"Restore",description:"Restore data from a previous backup snapshot",category:"data",icon:"history",configSchema:{backupId:{type:"string"}}},{type:"anonymize",label:"Anonymize",description:"Mask an org with a DataOps template, after a snapshot of the values it writes over, never a production org",category:"data",icon:"shield",configSchema:{orgId:{type:"string"},templateId:{type:"string"},object:{type:"string",optional:!0},where:{type:"string",optional:!0},acceptAutomation:{type:"boolean",default:!1},acceptEmails:{type:"boolean",default:!1},muteAutomation:{type:"boolean",default:!1},purgeHistory:{type:"boolean",default:!1},verify:{type:"boolean",default:!1}}},{type:"delete",label:"Delete",description:"Delete records matching specified criteria",category:"data",icon:"trash",configSchema:{objectName:{type:"string"},where:{type:"string"}}},{type:"checkpoint",label:"Checkpoint",description:"Take a checkpoint of a sandbox, a scratch org or a Developer Edition org, kept on this machine",category:"data",icon:"bookmark",configSchema:{orgId:{type:"string"},mode:{type:"string",default:"everything"},objects:{type:"array",optional:!0},excluded:{type:"array",optional:!0},name:{type:"string",optional:!0},keepDays:{type:"number",default:c},maxTotal:{type:"number",optional:!0},ignoredFields:{type:"array",optional:!0}}},{type:"rewind",label:"Rewind",description:"Put an org back to a checkpoint kept on this machine, once confirmed by typing the org\u2019s alias, at most maxRecords records",category:"data",icon:"history",configSchema:{orgId:{type:"string"},checkpointId:{type:"string"},objects:{type:"array",optional:!0},acceptAutomation:{type:"boolean",default:!1},acceptEmails:{type:"boolean",default:!1},muteAutomation:{type:"boolean",default:!1},acceptNoUndo:{type:"boolean",default:!1},acceptRecreate:{type:"boolean",default:!1},acceptOutside:{type:"boolean",default:!1},acceptUnseen:{type:"boolean",default:!1},maxRecords:{type:"number",required:!0},refuseWhenActive:{type:"boolean",default:!0}}},{type:"compare",label:"Compare Orgs",description:"Compare the metadata of two orgs, as the Compare page does",category:"quality",icon:"git-compare",configSchema:{sourceOrgId:{type:"string"},targetOrgId:{type:"string"},types:{type:"array"}}},{type:"precheck",label:"Pre-check",description:"Read an org\u2019s API usage, storage, error logs or failed jobs as the Monitor does; the run stops on a critical reading",category:"quality",icon:"check-circle",configSchema:{orgId:{type:"string"},checks:{type:"array"}}},{type:"condition",label:"Condition",description:"Branch pipeline execution based on conditions",category:"control",icon:"git-branch",configSchema:{field:{type:"string"},operator:{type:"string"},value:{type:"string"}}},{type:"delay",label:"Delay",description:"Wait for a specified duration before continuing",category:"control",icon:"clock",configSchema:{durationMs:{type:"number"}}},{type:"approval",label:"Approval",description:"Pauses the run until someone approves it in VS Code; a rejection, or no answer in time, stops it",category:"control",icon:"user-check",configSchema:{message:{type:"string"},timeoutMinutes:{type:"number"}}},{type:"notification",label:"Notification",description:"Shows its message as a VS Code notification",category:"notification",icon:"bell",configSchema:{message:{type:"string"}}}],p=class{registry;constructor(){this.registry=new Map(y.map(e=>[e.type,e]))}getStepTypes(){return[...this.registry.values()]}getStepType(e){return this.registry.get(e)}getDefaultConfig(e){let r=this.registry.get(e);if(!r)return{};let o={};for(let[t,a]of Object.entries(r.configSchema)){let n=a;if(!(n.optional===!0||n.required===!0)){if("default"in n){o[t]=n.default;continue}switch(n.type){case"string":o[t]="";break;case"number":o[t]=0;break;case"array":o[t]=[];break;case"boolean":o[t]=!1;break;default:o[t]=null}}}return o}validateStepConfig(e,r){let o=this.registry.get(e);if(!o)return[`Unknown step type: ${e}`];let t=[];for(let[a,n]of Object.entries(o.configSchema)){let l=n,i=r[a],s=l.type;i!=null&&(s==="array"&&!Array.isArray(i)?t.push(`Field "${a}" must be an array`):s==="string"&&typeof i!="string"?t.push(`Field "${a}" must be a string`):s==="number"&&typeof i!="number"?t.push(`Field "${a}" must be a number`):s==="boolean"&&typeof i!="boolean"&&t.push(`Field "${a}" must be a boolean`))}return t}getStepCategories(){let e=new Set;for(let r of this.registry.values())e.add(r.category);return[...e]}};export{p as StepLibrary};
|
|
@@ -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 p,d as u,k as d,z as h}from"./chunk-
|
|
7
|
+
import{H as p,d as u,k as d,z as h}from"./chunk-4CSBZZAL.mjs";import{b as c}from"./chunk-CA5NAXSU.mjs";import{gb as a}from"./chunk-J347SPU6.mjs";import{randomBytes as E}from"node:crypto";import{open as k,readFile as b,rename as I,rm as T}from"node:fs/promises";import{dirname as l,join as m}from"node:path";var f="rewinds.ndjson",C=400,O=200;function P(e,n){return m(e,d(n),f)}function R(e){return m(l(e.dir),f)}async function y(e,n,t,i={maxLines:C,keptLines:O}){if(d(t.organizationId)!==n.organizationId)throw new p("invalid","A rewind is kept in its org\u2019s ledger, under its lock.");let r=a.safeParse(t);if(!r.success)throw new p("invalid","A line of the rewind ledger does not parse.");await h(l(e));let o=await w(e),x=o!==""&&!o.endsWith(`
|
|
8
8
|
`)?`
|
|
9
9
|
`:"",s=await k(e,"a",u);try{await s.writeFile(`${x}${JSON.stringify(r.data)}
|
|
10
10
|
`,"utf8"),await s.sync()}finally{await s.close()}L(o).length+1>i.maxLines&&await A(e,i.keptLines)}async function A(e,n){let t=L(await w(e)).slice(-n),i=`${e}.${process.pid}-${E(4).toString("hex")}.tmp`,r=await k(i,"wx",u);try{try{await r.writeFile(t.map(o=>`${o}
|
|
@@ -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{h as J}from"./chunk-JANBNTR5.mjs";import{d as Y,f as Z}from"./chunk-YJ27WHKR.mjs";import"./chunk-VUTQY76O.mjs";import"./chunk-CT324C7I.mjs";import{b as G}from"./chunk-WVVFR4E3.mjs";import"./chunk-H33DVU3D.mjs";import{a as V}from"./chunk-DUBECLZV.mjs";import{a as K}from"./chunk-XV4CVZYD.mjs";import{d as H}from"./chunk-AXTB2HJS.mjs";import"./chunk-LHNAR6FC.mjs";import"./chunk-UV74P4H2.mjs";import{k as D}from"./chunk-4CSBZZAL.mjs";import{f as R}from"./chunk-TQ6HEJ73.mjs";import"./chunk-65AMXOQU.mjs";import"./chunk-K5PUMHZU.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-Q7TLC3I2.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{Cb as F,Mb as C,Nb as B,Ob as M,Xa as E,ed as U,fd as L,kd as h,s as v}from"./chunk-J347SPU6.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";import{readFile as W}from"node:fs/promises";import{homedir as ee}from"node:os";import{join as b}from"node:path";var ne="none";function p(e){return e!==void 0&&E.safeParse(e).success?e:void 0}function te(e,n){return D(e)===D(n)}function l(e,n){return e!==void 0&&e!==""&&e.length<=n?e:void 0}function re(e,n,t){return B(e,n!==void 0?K(n,t):ne)}function oe(e,n){let t=M.safeParse(e.get(n));return t.success?t.data:{steps:{}}}function be(e,n=ee()){let t=e.get("frozen:config");if(typeof t?.datasetDir=="string"&&t.datasetDir!=="")return t.datasetDir;let i=typeof t?.sasDir=="string"&&t.sasDir!==""?t.sasDir:b(n,".sandforge-sas");return b(i,"dataset")}async function ie(e){let n;try{n=await W(b(e,"manifest.json"),"utf8")}catch{return}try{let t=H(JSON.parse(n)),i=Object.values(t.volumetry.measured),s=l(t.source.orgAlias,255);return{frozenAt:new Date(t.frozenAt).toISOString(),...s!==void 0?{sourceAlias:s}:{},objects:i.length,records:i.reduce((r,o)=>r+Math.max(0,Math.trunc(o)),0)}}catch{return}}function X(e,n,t,i){let s=i!==void 0?Date.parse(i):Number.NEGATIVE_INFINITY;return new R(e).list({orgId:n,limit:v}).entries.find(o=>o.action===t&&o.outcome==="success"&&Date.parse(o.timestamp)>s)?.timestamp}var se=/^[A-Za-z][A-Za-z0-9_]{0,79}$/;function ae(e,n){let t=new R(e).list({limit:v}).entries.filter(r=>r.action==="anonymize_execute").map(r=>({orgId:r.orgId,objects:[...new Set((Array.isArray(r.objects)?r.objects:[]).map(o=>o.objectApiName).filter(o=>typeof o=="string"&&se.test(o)))].slice(0,C)})).filter(r=>r.objects.length>0),i=t.find(r=>r.orgId===n),s=i??t[0];return s!==void 0?{objects:s.objects,from:i!==void 0?"org":"machine"}:void 0}function de(e){return(e.removals??[]).some(n=>n.status==="success"||n.undone>0)}function ce(e,n){return Object.values(e.getByCategory("pipelines")).some(t=>{let i=t?.triggers;return Array.isArray(i)&&i.some(s=>{let r=s;return r?.type==="sandbox_refresh"&&r.enabled!==!1&&r.config?.orgId===n})})}function fe(e,n,t){let i=p(e.organizationId),s=l(e.previousInstanceName,40),r=l(e.instanceName,40),o=e.reportedBy!==void 0?t(e.reportedBy):void 0,d=l(o!==void 0?h(o,o.username):void 0,255);return{detectedAt:new Date(e.detectedAt).toISOString(),evidence:e.evidence,...n!==void 0?{previousOrganizationId:n}:{},...i!==void 0?{organizationId:i}:{},...s!==void 0?{previousInstanceName:s}:{},...r!==void 0?{instanceName:r}:{},...d!==void 0?{reportedBy:d}:{},cachesForgotten:!0}}async function $(e,n){return(await e.list({organizationId:n})).flatMap(i=>i.checkpoint?.status==="ready"?[{checkpointId:i.checkpointId,name:i.checkpoint.name,takenAt:new Date(i.checkpoint.takenAt).toISOString(),keptUntilDeleted:i.checkpoint.expiresAt===null}]:[]).sort((i,s)=>Date.parse(s.takenAt)-Date.parse(i.takenAt))}async function Ie(e,n){let t=e.orgOf(n);if(t===void 0)return{refused:"ORG_NOT_FOUND"};if(!L(t))return{refused:"NOT_A_DEVELOPMENT_ORG"};let i=U(t);if(i==="production")return{refused:"NOT_A_DEVELOPMENT_ORG"};let s=t.orgType==="Sandbox"?"sandbox":t.orgType==="Scratch"?"scratch":"developer",r=s==="sandbox"?e.refreshesOf(n)[0]:void 0,o=p(r!==void 0?r.organizationId:e.organizationIdOf(n)??t.orgId),d=r!==void 0?p(r.previousOrganizationId??(r.organizationId===void 0?e.organizationIdOf(n):void 0)):void 0,y=V(t.instanceUrl),f=y!==void 0&&F.safeParse(y).success?y:void 0,I=r?.detectedAt,z=await e.checkpoints(),q=d!==void 0?await $(z,d):[],Q=o!==void 0?await $(z,o):[],u=q[0],k;d!==void 0&&o!==void 0&&(k=(await e.replays().list({sourceOrganizationId:d,targetOrganizationId:o})).flatMap(a=>a.replayedAt!==void 0&&a.removed!==!0?[a.replayedAt]:[]).sort().at(-1));let c=(o!==void 0?await e.users().list(o):[]).find(a=>a.status!=="running"),O,A;if(f!==void 0){let{kept:a}=await G(e.journalDir,f),g=S=>o!==void 0&&te(S.inventory.organizationId,o),m=a.find(S=>!g(S));m!==void 0&&(O={savedAt:m.inventory.savedAt,organizationId:m.inventory.organizationId,jobs:m.inventory.jobs.length}),A=a.find(g)?.inventory.savedAt}let N=Z(e.configStore,Y(f,n)),w=await ie(e.frozenDatasetDir()),_=o!==void 0?await J(e.journalDir,o):void 0,T=o!==void 0?e.usersListed?.(n,o):void 0,j=X(e.configStore,n,"anonymize_execute",I),P=X(e.configStore,n,"frozen_load",I),x=ae(e.configStore,n);return{facts:{orgId:n,alias:h(t,t.username)||n,tier:i,kind:s,...s==="sandbox"&&t.sandboxType!==void 0?{sandboxType:t.sandboxType}:{},...f!==void 0?{myDomainHost:f}:{},...o!==void 0?{organizationId:o}:{},...r!==void 0?{refresh:fe(r,d,e.orgOf)}:{},acks:oe(e.configStore,re(n,r,a=>e.organizationIdOf(a))),...u!==void 0?{checkpointBefore:{checkpointId:u.checkpointId,name:u.name,takenAt:u.takenAt}}:{},...k!==void 0?{replayedAt:k}:{},checkpointsNow:Q.map(({takenAt:a,keptUntilDeleted:g})=>({takenAt:a,keptUntilDeleted:g})),...c!==void 0?{lastUsersRun:{run:c.run,at:c.endedAt??c.startedAt,status:c.status}}:{},...c!==void 0&&de(c)?{lastUsersRunTakenBack:!0}:{},...T!==void 0?{usersToBringBack:T}:{},...j!==void 0?{maskedAt:j}:{},...x!==void 0?{maskObjects:x}:{},...P!==void 0?{frozenLoadedAt:P}:{},...w!==void 0?{frozenManifest:w}:{},...O!==void 0?{inventoryBefore:O}:{},...A!==void 0?{inventoryNowAt:A}:{},..._!==void 0?{handoffAt:_}:{},...N!==void 0?{testersSavedAt:N.savedAt}:{},refreshPipeline:ce(e.configStore,n)}}}export{ne as NO_REFRESH_KEY,be as frozenDatasetDirOf,oe as readAcks,re as recoveryAckKeyOf,Ie as recoveryFactsOf};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-GFB2DNCB.mjs";import"./chunk-4CSBZZAL.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{c as LEDGER_KEPT_LINES,b as LEDGER_MAX_LINES,i as OrgClockWatch,a as REWIND_LEDGER_FILE,f as appendToRewindLedger,l as noteRewindEnded,m as noteRewindUndone,g as readRewindLedger,h as readRewindLedgers,k as rewindEndedRecord,e as rewindLedgerBeside,d as rewindLedgerFileOf,j as rewindTotalsOf};
|
|
@@ -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 A}from"./chunk-5LFSFYFJ.mjs";import{a as z,h as p}from"./chunk-TZE3Y7IQ.mjs";import{b as S}from"./chunk-CA5NAXSU.mjs";import{
|
|
7
|
+
import{a as A}from"./chunk-5LFSFYFJ.mjs";import{a as z,h as p}from"./chunk-TZE3Y7IQ.mjs";import{b as S}from"./chunk-CA5NAXSU.mjs";import{Cc as C}from"./chunk-J347SPU6.mjs";import{b as g,f as b,k as w,l as m,o as j}from"./chunk-WZQEK4WT.mjs";function H(r,n){return{describe:e=>r.describe(e),describeGlobal:()=>r.describeGlobal(),query:async e=>{let t=await r.query(e);return A(r.limitInfo,n),{totalSize:t.totalSize,records:t.records}},update:(e,t)=>r.sobject(e).update(t,{headers:C()}),destroy:(e,t)=>r.sobject(e).destroy(t)}}var u=200,P=30,I=100,M=4,y=10,q=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function B(r){return typeof r=="string"&&q.test(r)}function k(r,n=u){let e=[];for(let t=0;t<r.length;t+=n)e.push(r.slice(t,t+n).map(s=>`'${z(s)}'`).join(", "));return e}var L=m({success:b(),id:g().nullish(),errors:w(j([m({message:g()}).loose(),g()])).optional()}).loose(),W=m({name:g(),label:g(),queryable:b().optional(),createable:b().optional(),layoutable:b().optional()}).loose(),_=m({sobjects:w(W)}).loose();async function F(r){let n=_.parse(await r.describeGlobal());return new Map(n.sobjects.filter(e=>e.queryable===!0&&e.createable===!0&&e.layoutable===!0).map(e=>[e.name,e.label]))}async function E(r,n){let e=new Array(r.length),t=0,s=async()=>{for(;t<r.length;){let i=t++;e[i]=await r[i]()}};return await Promise.all(Array.from({length:Math.min(n,r.length)},s)),e}async function Q(r,n,e,t){if(e.length===0)return{related:[],uncounted:[]};let s=(n.childRelationships??[]).filter(o=>o.cascadeDelete===!0&&t.has(o.childSObject)),i=s.slice(0,P),a=new Set(s.slice(P).map(o=>t.get(o.childSObject)??o.childSObject)),l=k(e),h=await E(i.map(o=>async()=>{try{let c=p(o.childSObject),d=p(o.field),O=0;for(let T of l)O+=(await r.query(`SELECT COUNT() FROM ${c} WHERE ${d} IN (${T})`)).totalSize;return{relationship:o,records:O}}catch{return{relationship:o,records:null}}}),M),f=new Map;for(let{relationship:o,records:c}of h){let d=t.get(o.childSObject)??o.childSObject;if(c===null){a.add(d);continue}f.set(o.childSObject,(f.get(o.childSObject)??0)+c)}return{related:[...f].filter(([,o])=>o>0).map(([o,c])=>({objectApiName:o,label:t.get(o)??o,records:c})).sort((o,c)=>c.records-o.records||o.label.localeCompare(c.label)),uncounted:[...a].sort()}}async function Z(r,n,e,t,s=1){let i=p(n),a=[...new Set(["Id",...e])].map(p),l=a.join(", "),h=a.length>I?u/4:u,f=await E(k(t,h).map(o=>()=>r.query(`SELECT ${l} FROM ${i} WHERE Id IN (${o})`)),s),R=[];for(let o of f)for(let c of o.records){if(typeof c!="object"||c===null)continue;let d={...c};delete d.attributes,R.push(d)}return R}function x(r,n,e){let t=Array.isArray(r)?r:[r];for(let s of t){let i=L.safeParse(s);if(i.success&&i.data.success){e.done++;continue}if(e.failed++,e.errors.length<y){let a=i.success?i.data.errors?.[0]:void 0,l=typeof a=="string"?a:a?.message??"The org gave no reason.";e.errors.push({objectApiName:n,message:l})}}}async function J(r,n,e,t){let s={done:0,failed:0,errors:[]};for(let i=0;i<e.length&&!t?.aborted;i+=u){let a=e.slice(i,i+u);try{x(await r.update(n,[...a]),n,s)}catch(l){s.failed+=a.length,s.errors.length<y&&s.errors.push({objectApiName:n,message:S(l)})}}return s}async function V(r,n,e,t){let s={done:0,failed:0,errors:[]};for(let i=0;i<e.length&&!t?.aborted;i+=u){let a=e.slice(i,i+u);try{x(await r.destroy(n,[...a]),n,s)}catch(l){s.failed+=a.length,s.errors.length<y&&s.errors.push({objectApiName:n,message:S(l)})}}return s}function D(r,n){return n===0?"success":r===0?"failure":"partial"}function Y(r){let n=r.reduce((t,s)=>t+s.counts.done,0),e=r.reduce((t,s)=>t+s.counts.failed,0);return{status:D(n,e),done:n,failed:e,objects:r.map(t=>({objectApiName:t.objectApiName,done:t.counts.done,failed:t.counts.failed})),errors:r.flatMap(t=>t.counts.errors).slice(0,y)}}export{H as a,u as b,B as c,k as d,F as e,E as f,Q as g,Z as h,J as i,V as j,Y as k};
|