sandforge 1.82.0 → 1.84.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-23SEDORH.mjs +11 -0
- package/lib/{chunk-7WSLT5VX.mjs → chunk-24RFOFYT.mjs} +1 -1
- package/lib/chunk-26POJDIT.mjs +7 -0
- package/lib/{chunk-SFGZFB4F.mjs → chunk-2AZQHBEF.mjs} +1 -1
- package/lib/{chunk-6VSZNZHH.mjs → chunk-2HVOZUM4.mjs} +1 -1
- package/lib/{chunk-XFU3HRUV.mjs → chunk-2JDAOWUW.mjs} +1 -1
- package/lib/{chunk-BNKT3R3F.mjs → chunk-2METQHGG.mjs} +1 -1
- package/lib/chunk-2WFIVO4F.mjs +13 -0
- package/lib/chunk-2YHZBUZE.mjs +7 -0
- package/lib/{chunk-SZGGFST2.mjs → chunk-326AJTIU.mjs} +14 -14
- package/lib/{chunk-Q6SXNKV2.mjs → chunk-36JOHEJL.mjs} +1 -1
- package/lib/chunk-3PVRGTVK.mjs +7 -0
- package/lib/{chunk-VZVICK7Q.mjs → chunk-3Q353S2R.mjs} +1 -1
- package/lib/chunk-3TZSBHEY.mjs +7 -0
- package/lib/{chunk-UHFLKP26.mjs → chunk-43TOMFV4.mjs} +1 -1
- package/lib/{chunk-XK5W7BVE.mjs → chunk-4CVUUVGJ.mjs} +1 -1
- package/lib/{chunk-VYOYXTCU.mjs → chunk-4EOHEDFP.mjs} +1 -1
- package/lib/{chunk-EOFO3PHS.mjs → chunk-4JE4BYXK.mjs} +1 -1
- package/lib/{chunk-7EYQYZJP.mjs → chunk-54WZUS7J.mjs} +1 -1
- package/lib/chunk-5CRLRHOJ.mjs +7 -0
- package/lib/{chunk-FA4ZKDCU.mjs → chunk-5IZTFMJM.mjs} +1 -1
- package/lib/chunk-5M5FQ7RP.mjs +7 -0
- package/lib/{chunk-3HROD5RE.mjs → chunk-5SMWFNE7.mjs} +1 -1
- package/lib/{chunk-YAIIRFKJ.mjs → chunk-5XTUSN72.mjs} +1 -1
- package/lib/chunk-6I6TWNV5.mjs +7 -0
- package/lib/{chunk-PYRZFUVU.mjs → chunk-6JWWSDM6.mjs} +1 -1
- package/lib/chunk-6O222PW6.mjs +7 -0
- package/lib/{chunk-2UU42PTD.mjs → chunk-6PD6K7LP.mjs} +1 -1
- package/lib/{chunk-GGUOIDWP.mjs → chunk-6QE6R6RL.mjs} +1 -1
- package/lib/{chunk-DJCGURW7.mjs → chunk-6WX5ZU7Q.mjs} +1 -1
- package/lib/{chunk-DT3T7FRD.mjs → chunk-6YL7BNYD.mjs} +1 -1
- package/lib/chunk-6ZLKIT3H.mjs +7 -0
- package/lib/{chunk-CBL42DUU.mjs → chunk-7QYHEHMA.mjs} +1 -1
- package/lib/chunk-7SQSWVAU.mjs +9 -0
- package/lib/{chunk-ZUBBEP75.mjs → chunk-7UVKIWKV.mjs} +1 -1
- package/lib/{chunk-TWV4A5RK.mjs → chunk-7WATA4SB.mjs} +1 -1
- package/lib/chunk-7YNM6KFZ.mjs +7 -0
- package/lib/chunk-A3MYSOOC.mjs +7 -0
- package/lib/chunk-AL4C3GFT.mjs +7 -0
- package/lib/chunk-B3FBHVNN.mjs +21 -0
- package/lib/{chunk-27Z76O2O.mjs → chunk-B63POIPQ.mjs} +1 -1
- package/lib/{chunk-RTWYLOCA.mjs → chunk-BAWCOKRW.mjs} +1 -1
- package/lib/{chunk-NWOI25WY.mjs → chunk-BBRWFKS5.mjs} +1 -1
- package/lib/chunk-BEA27DLS.mjs +7 -0
- package/lib/chunk-BRY3PLIZ.mjs +7 -0
- package/lib/chunk-CBH3TOWK.mjs +341 -0
- package/lib/chunk-CPQIZGG5.mjs +7 -0
- package/lib/chunk-CVHNXJH3.mjs +7 -0
- package/lib/{chunk-HFUDCNU5.mjs → chunk-D4GF4FAB.mjs} +1 -1
- package/lib/chunk-DGDRQRCW.mjs +7 -0
- package/lib/{chunk-YAJQS3OL.mjs → chunk-DPMRIMUC.mjs} +1 -1
- package/lib/chunk-DUN2EPRC.mjs +7 -0
- package/lib/chunk-E3A3LOCY.mjs +7 -0
- package/lib/{chunk-TMA34QMA.mjs → chunk-EAC5QCE3.mjs} +1 -1
- package/lib/{chunk-VQJMP3DC.mjs → chunk-EC72TIEG.mjs} +1 -1
- package/lib/chunk-EPFCERGL.mjs +7 -0
- package/lib/{chunk-3MGMNK3Q.mjs → chunk-ETDCBLGU.mjs} +1 -1
- package/lib/{chunk-LXDSRP2W.mjs → chunk-F3AQW6IU.mjs} +1 -1
- package/lib/{chunk-A65ADTCR.mjs → chunk-FITPY3L4.mjs} +1 -1
- package/lib/chunk-FNJ4SGWO.mjs +7 -0
- package/lib/{chunk-SAMWHL22.mjs → chunk-FP7CYB2F.mjs} +1 -1
- package/lib/{chunk-JLZRZL5E.mjs → chunk-GKY2JMHY.mjs} +1 -1
- package/lib/chunk-GMIGWR6U.mjs +7 -0
- package/lib/{chunk-AUS6NFLZ.mjs → chunk-GNRSF65U.mjs} +1 -1
- package/lib/chunk-GOOVPVWX.mjs +7 -0
- package/lib/{chunk-PPHVWUFY.mjs → chunk-GWZRR3MM.mjs} +1 -1
- package/lib/{chunk-JH27IKCO.mjs → chunk-H2BHESDA.mjs} +2 -2
- package/lib/chunk-H33DVU3D.mjs +7 -0
- package/lib/chunk-H4CGM6YO.mjs +7 -0
- package/lib/{chunk-WOOUISSO.mjs → chunk-HCGXK7G7.mjs} +1 -1
- package/lib/{chunk-VZT4E2OJ.mjs → chunk-HIDW7FNV.mjs} +1 -1
- package/lib/chunk-HSBXRQTI.mjs +7 -0
- package/lib/chunk-HUZPBE47.mjs +7 -0
- package/lib/chunk-HV7VPEXP.mjs +7 -0
- package/lib/chunk-I6E6T6YY.mjs +7 -0
- package/lib/chunk-IUM4NFKI.mjs +10 -0
- package/lib/chunk-IVFVNNGB.mjs +37 -0
- package/lib/{chunk-5K2I2DMP.mjs → chunk-IZGCEOYO.mjs} +1 -1
- package/lib/{chunk-ZHIZY3ZC.mjs → chunk-J3DND3BC.mjs} +1 -1
- package/lib/{chunk-VPDEJGPS.mjs → chunk-JAEDM4SI.mjs} +1 -1
- package/lib/chunk-JCFBFF4Y.mjs +7 -0
- package/lib/{chunk-GBGHJTPC.mjs → chunk-JE6SCT6R.mjs} +1 -1
- package/lib/chunk-JGZPD4IM.mjs +7 -0
- package/lib/{chunk-C3LNYAVJ.mjs → chunk-JKJ74BX5.mjs} +1 -1
- package/lib/{chunk-EEFUE2ES.mjs → chunk-JLSIWO4Z.mjs} +1 -1
- package/lib/{chunk-3CX7GPCR.mjs → chunk-JSAJS3MY.mjs} +1 -1
- package/lib/chunk-JTJK2D36.mjs +7 -0
- package/lib/{chunk-V3R45ZWT.mjs → chunk-KAZS5Z6W.mjs} +1 -1
- package/lib/chunk-KB4ZHM4Q.mjs +10 -0
- package/lib/{chunk-J24TIGSI.mjs → chunk-KGU4SVIT.mjs} +1 -1
- package/lib/chunk-KJWFYBMU.mjs +15 -0
- package/lib/{chunk-H4JUYUSL.mjs → chunk-KZTZDC7H.mjs} +1 -1
- package/lib/chunk-L2E5WBGD.mjs +8 -0
- package/lib/{chunk-XU25YA46.mjs → chunk-L53JWJ3S.mjs} +1 -1
- package/lib/{chunk-Y4TDVDP2.mjs → chunk-LA4KIATH.mjs} +6 -6
- package/lib/chunk-LC3NDW4N.mjs +7 -0
- package/lib/{chunk-GCGHHN4K.mjs → chunk-LKTNQEBS.mjs} +1 -1
- package/lib/chunk-M2ABR4JM.mjs +7 -0
- package/lib/{chunk-3C2ZZIFN.mjs → chunk-M4BLK6HJ.mjs} +1 -1
- package/lib/{chunk-L4INJ5TZ.mjs → chunk-M6K34KGF.mjs} +1 -1
- package/lib/chunk-MDMPJEV3.mjs +7 -0
- package/lib/{chunk-32EUNQT6.mjs → chunk-MJZU3U5O.mjs} +68 -63
- package/lib/{chunk-PBE44M2Y.mjs → chunk-MSIEU5MR.mjs} +1 -1
- package/lib/{chunk-NLB3RGIY.mjs → chunk-N4WPCWJO.mjs} +1 -1
- package/lib/{chunk-SNEOKYV7.mjs → chunk-NCZKWSC7.mjs} +1 -1
- package/lib/{chunk-6KP6WETK.mjs → chunk-NED4MBIM.mjs} +1 -1
- package/lib/chunk-NOBQTEQD.mjs +7 -0
- package/lib/{chunk-RCYEBY42.mjs → chunk-NSQWI7ZY.mjs} +1 -1
- package/lib/{chunk-DBBPDSFN.mjs → chunk-O677VOGO.mjs} +1 -1
- package/lib/chunk-OFTT7J2M.mjs +7 -0
- package/lib/{chunk-C2N2TNEU.mjs → chunk-OLCVHL7I.mjs} +1 -1
- package/lib/chunk-OM5NORJG.mjs +7 -0
- package/lib/chunk-OMNMLKDT.mjs +7 -0
- package/lib/{chunk-CELEBWEZ.mjs → chunk-OPMO6I45.mjs} +1 -1
- package/lib/{chunk-LHU6CPGE.mjs → chunk-OUZQPYT3.mjs} +1 -1
- package/lib/chunk-OVNMB6Q2.mjs +7 -0
- package/lib/{chunk-6GQUZ4IP.mjs → chunk-PAXNWTYK.mjs} +1 -1
- package/lib/{chunk-XSKPYGMT.mjs → chunk-PBY2O6OF.mjs} +1 -1
- package/lib/chunk-PEDQPM2P.mjs +926 -0
- package/lib/chunk-PH7SP4YK.mjs +21 -0
- package/lib/{chunk-3SKLBRPL.mjs → chunk-PMN4PAC3.mjs} +1 -1
- package/lib/chunk-PMWAFDUB.mjs +48 -0
- package/lib/chunk-PPLVFX6N.mjs +7 -0
- package/lib/{chunk-STRMWSIQ.mjs → chunk-PR3XCSPO.mjs} +1 -1
- package/lib/{chunk-GJ6SZVHT.mjs → chunk-PR42EZSR.mjs} +1 -1
- package/lib/{chunk-YMDFF657.mjs → chunk-PWRJRL5U.mjs} +1 -1
- package/lib/{chunk-Q3DY7TO2.mjs → chunk-Q7GIJBCD.mjs} +1 -1
- package/lib/chunk-Q7TLC3I2.mjs +7 -0
- package/lib/{chunk-ZXFL2MSN.mjs → chunk-QAFPQ3YB.mjs} +1 -1
- package/lib/{chunk-T7WREYA5.mjs → chunk-QKEKG2LD.mjs} +1 -1
- package/lib/chunk-QO53K5W2.mjs +9 -0
- package/lib/{chunk-MUEQRIK7.mjs → chunk-QTG6LUZT.mjs} +1 -1
- package/lib/{chunk-KP5G6FUC.mjs → chunk-RE7RYF3B.mjs} +1 -1
- package/lib/{chunk-FOIWWK7G.mjs → chunk-RGBGUCJA.mjs} +1 -1
- package/lib/{chunk-DWMRIWV5.mjs → chunk-RGUQOSBU.mjs} +1 -1
- package/lib/{chunk-7PY3VQP3.mjs → chunk-RHNTHGNU.mjs} +1 -1
- package/lib/chunk-RKTFFCNS.mjs +7 -0
- package/lib/chunk-RMFU4BAL.mjs +28 -0
- package/lib/{chunk-KKOA62S4.mjs → chunk-ROV3QXEF.mjs} +14 -13
- package/lib/chunk-RT47RKLY.mjs +7 -0
- package/lib/{chunk-ZUTUYBNW.mjs → chunk-S42RBRH2.mjs} +1 -1
- package/lib/{chunk-Z42PHCVZ.mjs → chunk-SI267LYR.mjs} +1 -1
- package/lib/chunk-T3G6VZNS.mjs +7 -0
- package/lib/chunk-TNT27RBG.mjs +7 -0
- package/lib/chunk-UBIKR5VO.mjs +7 -0
- package/lib/chunk-UI3JQVRU.mjs +8 -0
- package/lib/{chunk-YT22LMF7.mjs → chunk-UIOMAX56.mjs} +1 -1
- package/lib/chunk-UX3BVH2Y.mjs +7 -0
- package/lib/chunk-VCUXCK36.mjs +7 -0
- package/lib/chunk-VINGECAJ.mjs +10 -0
- package/lib/chunk-VOXJHJIE.mjs +7 -0
- package/lib/chunk-W6PN6TJG.mjs +7 -0
- package/lib/{chunk-FKK5YBGZ.mjs → chunk-WAPSSYMT.mjs} +1 -1
- package/lib/{chunk-PR74GYVI.mjs → chunk-WUUKFE2U.mjs} +1 -1
- package/lib/chunk-WWTCWWZI.mjs +7 -0
- package/lib/chunk-WXDLQT2O.mjs +10 -0
- package/lib/chunk-WY5V5PR3.mjs +7 -0
- package/lib/chunk-X4BXESMQ.mjs +7 -0
- package/lib/chunk-XBQGZGWR.mjs +7 -0
- package/lib/chunk-XGGOUNPP.mjs +7 -0
- package/lib/chunk-XKWW3GKF.mjs +7 -0
- package/lib/{chunk-JJITOWZK.mjs → chunk-Y2DRK37K.mjs} +1 -1
- package/lib/{chunk-XZISAZA6.mjs → chunk-YA6ATMTB.mjs} +1 -1
- package/lib/{chunk-54HYHHVL.mjs → chunk-YDXMTWAT.mjs} +1 -1
- package/lib/chunk-YHR4WQPR.mjs +7 -0
- package/lib/{chunk-KJYEQHYP.mjs → chunk-YTLUYSMF.mjs} +1 -1
- package/lib/chunk-YWEQQL3C.mjs +8 -0
- package/lib/{chunk-PWVDNN2C.mjs → chunk-Z4LKKOFY.mjs} +1 -1
- package/lib/chunk-ZBAWJUG2.mjs +7 -0
- package/lib/{chunk-XO5FBOQF.mjs → chunk-ZJW6YOMV.mjs} +1 -1
- package/lib/chunk-ZQQXSCVI.mjs +7 -0
- package/lib/{chunk-47UHTN3Q.mjs → chunk-ZQWIVYVM.mjs} +1 -1
- package/lib/chunk-ZV7ZFQQC.mjs +9 -0
- package/lib/sandforge-autopilot.mjs +25 -25
- package/lib/sandforge-backup.mjs +1 -1
- 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 +52 -21
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +4 -4
- package/lib/sandforge-env.mjs +106 -107
- package/lib/sandforge-frozen.mjs +1 -1
- package/lib/sandforge-mcp.mjs +12 -12
- package/lib/sandforge-monitor.mjs +1 -1
- package/lib/sandforge-pipeline.mjs +1 -1
- package/lib/sandforge-seed.mjs +1 -1
- package/lib/sandforge-sync.mjs +1 -1
- package/lib/sandforge-users.mjs +21 -23
- package/lib/sandforge.mjs +1 -1
- package/lib/sf/sandforge/compare.mjs +2 -2
- package/lib/sfPlugin.mjs +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/lib/chunk-2JZGCCPG.mjs +0 -9
- package/lib/chunk-3HEMJTAP.mjs +0 -925
- package/lib/chunk-3XG25GTF.mjs +0 -7
- package/lib/chunk-42BFLWHR.mjs +0 -7
- package/lib/chunk-466F37VD.mjs +0 -7
- package/lib/chunk-4JKR4PTZ.mjs +0 -8
- package/lib/chunk-52EXDVPN.mjs +0 -7
- package/lib/chunk-7CVDVBEE.mjs +0 -7
- package/lib/chunk-7LKI7OAS.mjs +0 -7
- package/lib/chunk-7SDZR6SR.mjs +0 -7
- package/lib/chunk-A32ISQ6M.mjs +0 -28
- package/lib/chunk-A7JJWOLT.mjs +0 -7
- package/lib/chunk-BMTNTBBM.mjs +0 -7
- package/lib/chunk-BN33LVPQ.mjs +0 -7
- package/lib/chunk-BZ24IAP5.mjs +0 -7
- package/lib/chunk-CCEH7L53.mjs +0 -7
- package/lib/chunk-CV47FDQW.mjs +0 -7
- package/lib/chunk-CZLJZQCS.mjs +0 -7
- package/lib/chunk-DIL62SUN.mjs +0 -7
- package/lib/chunk-DIS254AN.mjs +0 -7
- package/lib/chunk-FZF23M6R.mjs +0 -7
- package/lib/chunk-G2JR3F63.mjs +0 -7
- package/lib/chunk-GGNUACTY.mjs +0 -7
- package/lib/chunk-GHPR5UVV.mjs +0 -7
- package/lib/chunk-HIHCYMSL.mjs +0 -7
- package/lib/chunk-HKUWHVI7.mjs +0 -9
- package/lib/chunk-HQQVANWQ.mjs +0 -20
- package/lib/chunk-IRZJU2PG.mjs +0 -22
- package/lib/chunk-ISSP2FZ5.mjs +0 -7
- package/lib/chunk-IVZJSDJD.mjs +0 -7
- package/lib/chunk-JESRFE2Z.mjs +0 -11
- package/lib/chunk-JFNLKHY6.mjs +0 -8
- package/lib/chunk-JKT5YAQ2.mjs +0 -7
- package/lib/chunk-JQZTMFO7.mjs +0 -7
- package/lib/chunk-KIMQQ6JQ.mjs +0 -7
- package/lib/chunk-LAUOSXMN.mjs +0 -341
- package/lib/chunk-MKTXJCXN.mjs +0 -10
- package/lib/chunk-O2PUGRNW.mjs +0 -10
- package/lib/chunk-O4BROUGM.mjs +0 -7
- package/lib/chunk-P55MKIZX.mjs +0 -37
- package/lib/chunk-P63WJMXQ.mjs +0 -7
- package/lib/chunk-PE435FVH.mjs +0 -15
- package/lib/chunk-PPGDAUEQ.mjs +0 -7
- package/lib/chunk-QAPVKPEC.mjs +0 -7
- package/lib/chunk-RLWB7F26.mjs +0 -7
- package/lib/chunk-RYRMUPMY.mjs +0 -7
- package/lib/chunk-SCKUIE3R.mjs +0 -7
- package/lib/chunk-SU65Z2BA.mjs +0 -7
- package/lib/chunk-TCBAE65A.mjs +0 -7
- package/lib/chunk-WEMLDUQA.mjs +0 -7
- package/lib/chunk-WSUKC2U3.mjs +0 -7
- package/lib/chunk-WT3SCUHS.mjs +0 -7
- package/lib/chunk-YGJF55VJ.mjs +0 -7
- package/lib/chunk-YH4DYI6D.mjs +0 -7
- package/lib/chunk-ZQO5PDX5.mjs +0 -48
- package/lib/chunk-ZUOPC4W2.mjs +0 -7
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a as vt,d as Tt,e as jt,g as _t,h as Bt,i as xt,j as Ft,k as et}from"./chunk-YDXMTWAT.mjs";import{a as Ce,b as z,d as H,e as Lt,f as Xe,h as L}from"./chunk-JAEDM4SI.mjs";import{e as Ut,h as $t,i as Ht}from"./chunk-D4GF4FAB.mjs";import{d as Jt}from"./chunk-CVHNXJH3.mjs";import{da as me,e as te,ea as Ze,ga as pe,ja as Pe}from"./chunk-TNT27RBG.mjs";import{h as T}from"./chunk-TZE3Y7IQ.mjs";import{b as C}from"./chunk-CA5NAXSU.mjs";import{Dc as Ct,Ec as X,Ic as Ee,Lc as ge,Mc as Ge,Oc as Ye,Pc as Nt,qd as Mt,yc as Pt}from"./chunk-PMWAFDUB.mjs";import{b as x,e as Qe,f as M,i as It,k as ae,l as Z,o as Ie,s as Et}from"./chunk-WZQEK4WT.mjs";var Ne=class{activeJobs=new Map;maxConcurrentJobs;maxCompletedJobs=50;constructor(t=5){this.maxConcurrentJobs=t}registerJob(t){this.activeJobs.set(t.id,t)}updateJobState(t,e){let n=this.activeJobs.get(t);return n?(n.state=e,(e==="JobComplete"||e==="Failed"||e==="Aborted")&&this.purgeCompletedJobs(),!0):!1}updateJobCounts(t,e,n){let o=this.activeJobs.get(t);return o?(o.numberRecordsProcessed=e,o.numberRecordsFailed=n,!0):!1}updateTotalRecords(t,e){let n=this.activeJobs.get(t);return n?(n.totalRecords=e,!0):!1}getJob(t){return this.activeJobs.get(t)}getActiveJobs(){return Array.from(this.activeJobs.values()).filter(t=>t.state==="UploadComplete"||t.state==="InProgress")}getCompletedJobs(){return Array.from(this.activeJobs.values()).filter(t=>t.state==="JobComplete"||t.state==="Failed"||t.state==="Aborted")}canStartNewJob(){return this.getActiveJobs().length<this.maxConcurrentJobs}removeJob(t){return this.activeJobs.delete(t)}get totalJobs(){return this.activeJobs.size}purgeCompletedJobs(){let t=Array.from(this.activeJobs.entries()).filter(([,e])=>["JobComplete","Failed","Aborted"].includes(e.state));if(t.length>this.maxCompletedJobs){let e=t.slice(0,t.length-this.maxCompletedJobs);for(let[n]of e)this.activeJobs.delete(n)}}clear(){this.activeJobs.clear()}};function Fn(r,t){let e=et(r,t);if(e.state==="Open")throw new Error(`Bulk API job ${r||"(no id)"} is still open after its close was sent`);return{state:e.state,...e.numberRecordsProcessed!==void 0?{numberRecordsProcessed:e.numberRecordsProcessed}:{},...e.errorMessage?{errorMessage:e.errorMessage}:{}}}function Me(r){return{bulk2:{createJob:t=>{let e=r.bulk2.createJob(t);return{get id(){return e.id},open:async()=>{await e.open()},uploadData:n=>e.uploadData(n),close:()=>e.close(),abort:()=>e.abort(),check:async()=>Fn(Ut(e)??"",await e.check()),getAllResults:()=>e.getAllResults()}},job:(t,{id:e})=>{let n=r.bulk2.job(t,{id:e});return{check:async()=>et(e,await n.check()),getSuccessfulResults:()=>n.getSuccessfulResults(),getAllResults:()=>n.getAllResults(),abort:()=>n.abort()}}}}}var qt=100,zt=2e3,$n=20,Hn=20,Jn=Z({name:x(),label:x(),type:x(),createable:M().optional(),updateable:M().optional(),nillable:M().optional(),defaultedOnCreate:M().optional(),aggregatable:M().optional(),groupable:M().optional(),filterable:M().optional(),nameField:M().optional(),autoNumber:M().optional(),calculated:M().optional(),referenceTo:ae(x()).optional()}).loose(),ee=Z({name:x(),label:x(),queryable:M().optional(),updateable:M().optional(),deletable:M().optional(),fields:ae(Jn),childRelationships:ae(Z({childSObject:x(),field:x(),cascadeDelete:M().optional(),restrictedDelete:M().optional()}).loose()).optional()}).loose(),qn=Et(x(),It()),zn=Z({k:Ie([x(),Qe(),M()]).nullable(),n:Qe().int().nonnegative()}).loose();function Wn(r){return(r.createable===!0||r.updateable===!0)&&r.type!=="boolean"}function to(r){return r.groupable===!0&&(Wn(r)||r.nameField===!0)}function Vn(r,t){return t.createable===!0&&t.nillable===!1&&t.defaultedOnCreate!==!0||Pt(r,t.name)}function Le(r,t,e){let n=C(e);r.some(o=>o.check===t&&o.message===n)||r.push({check:t,message:n})}async function no(r,t,e,n){let o=new Map,i=[],a=[],s=(u,l)=>{i.push({fieldApiName:u.name,label:u.label,reason:l})},d=e.filter(u=>u.aggregatable===!0),f=e.filter(u=>u.aggregatable!==!0&&u.filterable===!0);for(let u of e)u.aggregatable!==!0&&u.filterable!==!0&&s(u,"not-countable");if(n===0)for(let u of[...d,...f])o.set(u.name,0);else{for(let u=0;u<d.length;u+=qt){let l=d.slice(u,u+qt);try{let g=l.map(R=>`COUNT(${T(R.name)})`).join(", "),m=await r.query(`SELECT ${g} FROM ${t}`),h=qn.parse(m.records[0]??{});l.forEach((R,y)=>{let w=h[`expr${y}`];if(typeof w!="number")throw new Error(`The org answered no count for ${t}.${R.name}.`);o.set(R.name,w)})}catch(g){Le(a,"fill",g);for(let m of l)o.delete(m.name),s(m,"refused")}}for(let[u,l]of f.entries()){if(u>=Hn){s(l,"query-budget");continue}try{let g=await r.query(`SELECT COUNT() FROM ${t} WHERE ${T(l.name)} != null`);o.set(l.name,g.totalSize)}catch(g){Le(a,"fill",g),s(l,"refused")}}}return{fields:e.filter(u=>o.has(u.name)).map(u=>({fieldApiName:u.name,label:u.label,filled:o.get(u.name)??0,required:Vn(t,u)})).sort((u,l)=>u.filled-l.filled||u.fieldApiName.localeCompare(l.fieldApiName)),unmeasured:i,errors:a}}async function ro(r,t,e,n,o){let i=[],a=n?e.find(d=>d.name.toLowerCase()===n.toLowerCase()):e.find(d=>d.name==="Email")??e.find(d=>d.nameField===!0);if(!a)return n&&i.push({check:"duplicates",message:`${t} has no field ${n} the org can group records by.`}),{duplicates:null,errors:i};let s={keyField:a.name,keyLabel:a.label,groups:[],groupCount:0,recordCount:0,truncated:!1};if(o===0)return{duplicates:s,errors:i};try{let d=await Kn(r,t,a.name),f=d.rows.map(c=>({value:String(c.value),count:c.count}));return{duplicates:{...s,groups:f.slice(0,$n),groupCount:f.length,recordCount:f.reduce((c,u)=>c+u.count,0),truncated:d.truncated},errors:i}}catch(d){return Le(i,"duplicates",d),{duplicates:null,errors:i}}}async function Kn(r,t,e){let n=T(e),o=await r.query(`SELECT ${n} k, COUNT(Id) n FROM ${t} WHERE ${n} != null GROUP BY ${n} HAVING COUNT(Id) > 1 ORDER BY COUNT(Id) DESC LIMIT ${zt}`),i=[];for(let a of o.records){let s=zn.safeParse(a);!s.success||s.data.k===null||i.push({value:s.data.k,count:s.data.n})}return{rows:i,truncated:o.records.length>=zt}}async function oo(r,t,e,n,o){let i=[];if(!e.some(a=>a.name==="LastModifiedDate"&&a.filterable===!0))return{stale:null,errors:i};if(o===0)return{stale:{days:n,records:0},errors:i};try{let a=await r.query(`SELECT COUNT() FROM ${t} WHERE LastModifiedDate < LAST_N_DAYS:${n}`);return{stale:{days:n,records:a.totalSize},errors:i}}catch(a){return Le(i,"stale",a),{stale:null,errors:i}}}var tt=1e4,Te=5e4,Wt="DELETE_FAILED",Qn="UNABLE_TO_LOCK_ROW",Vt=3,Gn=2e3,Kt="FEATURENOTENABLED",nt="ContentVersion",Qt="ContentDocument",rt=new Set([nt,Qt]);async function he(r,t,e,n,o="delete"){let i=!1,a={},s=0,d=0,f=(g,m)=>(d+=g,m()),c={bulk2:{createJob:g=>{let m=r.bulk2.createJob(g);return{get id(){return m.id},open:()=>f(1,()=>m.open()),uploadData:h=>f(1,()=>m.uploadData(h)),close:async()=>{await f(1,()=>m.close()),i=!0},abort:()=>f(1,()=>m.abort()),check:async()=>{let h=await f(1,()=>m.check());return a={state:h.state,message:h.errorMessage},h},getAllResults:async()=>{let h=await f(Ht,()=>m.getAllResults());return s=Array.isArray(h)?h.length:(h.successfulResults?.length??0)+(h.failedResults?.length??0),h}}}}},u;try{u=await new $t().executeBulk({connection:c,bulkManager:new Ne(1),...n?{signal:n}:{}},t,o,e.map(g=>({Id:g})))}catch(g){if(!i){let m=g?.errorCode;return{kind:"untouched",reason:C(g),...typeof m=="string"&&m!==""?{code:m}:{},requests:d}}throw g}if(u.aborted)return{kind:"aborted",requests:d};if(a.state!=="JobComplete"&&s===0)return{kind:"untouched",reason:a.message||`job ${a.state??"not complete"}`,requests:d};let l=new Map(u.outcomes.map(g=>[g.recordIndex,g]));return{kind:"answered",requests:d,rows:e.map((g,m)=>{let h=l.get(m);return h?.success?{success:!0}:{success:!1,error:h?.error??"The job gave no result for it."}})}}function bo(r,t){let e=Me(r);return{...Ce(r,t),queryDeleted:async n=>({records:(await r.query(n,{scanAll:!0})).records}),bulkDestroy:(n,o,i)=>he(e,n,o,i),bulkHardDestroy:(n,o,i)=>he(e,n,o,i,"hardDelete")}}var ot=Z({success:M(),errors:ae(Ie([Z({statusCode:x().optional(),errorCode:x().optional(),message:x().optional()}).loose(),x()])).optional()}).loose();function ne(r){return r.slice(0,15)}function ve(r){return typeof r=="string"?void 0:r.statusCode??r.errorCode}function Gt(r){return Jt(r.map(({statusCode:t,message:e})=>`${t}: ${e}`),r)}function st(r){if(typeof r=="string")return r;let t=ve(r),e=r.message??"";return t&&e?`${t}: ${e}`:t||e||"The org gave no reason."}function de(r){return async t=>(await r.query(t)).records.filter(n=>typeof n=="object"&&n!==null)}function Yn(r){return new Promise(t=>setTimeout(t,r))}function Zn(r){let t=Gn*2**r;return Math.floor(t/2+Math.random()*(t/2))}async function Yt(r,t,e,n){let o=[...e];for(let i=0;i<Vt;i++){let a=o.flatMap((d,f)=>d.kind==="refused"&&d.locked===!0?[f]:[]);if(a.length===0||n.stopped?.()===!0||(await(n.wait??Yn)(Zn(i)),n.stopped?.()===!0))break;let s=await t(a.map(d=>r[d]));if(s===void 0)break;a.forEach((d,f)=>{let c=s[f];c&&(o[d]={...c,lockResends:i+1})})}return o}async function it(r,t,e,n={}){if(t===nt)return sr(r,e,n);let o=i=>Xn(r,t,i);return Yt(e,o,await o(e),n)}async function Xn(r,t,e){let n;try{n=await r.destroy(t,[...e])}catch(i){let a=C(i);return e.map(()=>({kind:"refused",reason:a,dependency:!1}))}let o=Array.isArray(n)?n:[n];return e.map((i,a)=>{let s=ot.safeParse(o[a]);if(s.success&&s.data.success)return{kind:"deleted"};let d=s.success?s.data.errors??[]:[];if(d.some(c=>ve(c)==="ENTITY_IS_DELETED"))return{kind:"gone"};let f=Gt(d.map(c=>({statusCode:ve(c)??"",message:typeof c=="string"?c:c.message??""})));return{kind:"refused",reason:d.length>0?st(d[0]):"The org gave no reason.",dependency:d.some(c=>ve(c)===Wt),...f?{locked:!0}:{}}})}async function er(r,t,e,n="recycle",o={}){let i=n==="hard"?r.bulkHardDestroy?.bind(r):r.bulkDestroy?.bind(r);if(i===void 0)return n==="hard"?{hardRefused:tr}:"untouched";let a=async d=>{let f;try{f=await i(t,d,o.signal)}catch(u){let l=C(u);return d.map(()=>({kind:"refused",reason:l,dependency:!1}))}if(f.kind==="aborted")return"aborted";if(f.kind==="untouched"){if(n!=="hard")return"untouched";if(f.code===Kt)return{hardRefused:nr(f.reason)};let u=`Not deleted for good: the job was not handed over \u2014 ${f.reason}`;return d.map(()=>({kind:"refused",reason:u,dependency:!1}))}let{rows:c}=f;return d.map((u,l)=>{let g=c[l];if(g?.success===!0)return{kind:"deleted"};let{code:m,message:h}=or(g?.error??"");return m==="ENTITY_IS_DELETED"?{kind:"gone"}:{kind:"refused",reason:m&&h?`${m}: ${h}`:g?.error||m||h||"The org gave no reason.",dependency:m===Wt,...Gt([{statusCode:m??"",message:h}])?{locked:!0}:{}}})},s=await a(e);return Array.isArray(s)?Yt(e,async d=>{let f=await a(d);return Array.isArray(f)?f:void 0},s,o):s}var tr="Records cannot be deleted for good through this connection: nothing was sent.";function nr(r){return`The user SandForge connects as may not delete records for good in this org: Salesforce refused the job before it held a record (${Kt}: ${r}). Nothing was deleted for good, and nothing was sent to the recycle bin instead.`}var rr="A file is never deleted for good: that takes a Bulk API job, which no file was ever sent by. Not sent.";function or(r){let t=/^([A-Z][A-Z0-9_]*):([\s\S]*?)(?::(?:--|[\w.,]+))?$/.exec(r.trim());return t?{code:t[1],message:t[2].trim()}:{message:r.trim()}}async function sr(r,t,e){let n;try{n=await L(r,nt,["ContentDocumentId"],t)}catch(d){let f=C(d);return t.map(()=>({kind:"refused",reason:f,dependency:!1}))}let o=new Map;for(let d of n)typeof d.Id=="string"&&typeof d.ContentDocumentId=="string"&&o.set(ne(d.Id),d.ContentDocumentId);let i=[...new Set(o.values())],a=i.length>0?await it(r,Qt,i,e):[],s=new Map(i.map((d,f)=>[d,a[f]]));return t.map(d=>{let f=o.get(ne(d));return f===void 0?{kind:"gone"}:s.get(f)??{kind:"refused",reason:"The org gave no answer for its document.",dependency:!1}})}function Zt(r){let t=[];for(let e=0;e<r.length;e+=z)t.push({ids:r.slice(e,e+z),byJob:!1});return t}function Xt(r,t,e,n="recycle"){return rt.has(t)?!1:n==="hard"||r.bulkDestroy!==void 0&&e>=tt}async function ir(r,t,e,n="recycle"){let o=[],i=!rt.has(t)&&(n==="hard"||r.bulkDestroy!==void 0),a=d=>{if(d.length===0)return;if(!i||n!=="hard"&&d.length<tt){o.push(...Zt(d));return}let f=Math.ceil(d.length/Math.ceil(d.length/Te));for(let c=0;c<d.length;c+=f)o.push({ids:d.slice(c,c+f),byJob:!0})};if(!Ee(t)||e.length===0)return a(e),o;let s=new Set;try{s=new Set([...await pe(de(r),e)].map(ne))}catch{}return a(e.filter(d=>!s.has(ne(d)))),a(e.filter(d=>s.has(ne(d)))),o}function en(r){return{objectApiName:r,op:"delete"}}async function tn(r,t,e,n,o){let i={stopped:o.stopped,...o.wait?{wait:o.wait}:{}},{stopped:a}=await Ft(e,{key:en(t),sizes:n.sizes,allowance:n.allowance,beforeEachSend:()=>o.stopped()?"stop":void 0,send:async s=>({answers:await it(r,t,s,i)}),limited:s=>s?.kind==="refused"?Mt([s.reason]):void 0,settle:(s,d,f,c)=>{let u=[],l=[];s.forEach((g,m)=>{if(f.has(m))return;let h=d[m]??{kind:"refused",reason:"The org gave no answer for it.",dependency:!1},R=c.get(m);u.push(g),l.push(R!==void 0&&h.kind==="refused"?{...h,dependency:!1,limit:R}:h)}),u.length>0&&o.settle(u,l)}});return a!==void 0}function at(r,t){let e=en(r),n=t.sizes.report(e);if(!n)return[];let o=[];return n.rows+n.alone+n.notSplit+n.keptWhole>0&&o.push(_t(n)),n.notSplit>0&&o.push(Bt(n.notSplit,xt(t.allowance,e),"removal")),n.keptWhole>0?o.push(jt):n.alone>0&&o.push(Tt),o}function nn(r){let t=0,e=0,n=0,o=0;for(let a of r)t++,a==="deleted"?e++:a==="gone"?n++:o++;if(t===0)return[];let i=[e>0?`${e} deleted`:"",n>0?`${n} already gone`:"",o>0?`${o} still refused`:""].filter(Boolean);return[`The org could not lock ${t} record(s) (${Qn}), each sent again up to ${Vt} times, a wait before each: ${i.join(", ")}.`]}async function rn(r,t,e,n){let o=n.mode??"recycle";if(o==="hard"&&rt.has(t))return e.length>0&&n.settle(e,e.map(()=>({kind:"refused",reason:rr,dependency:!1}))),{stopped:!1};let i=n.wait?{wait:n.wait}:{},a=await ir(r,t,e,o);for(let s=a.shift();s!==void 0;s=a.shift()){let{ids:d,byJob:f}=s;if(n.stopped())return{stopped:!0};if(await n.prepare?.(d),!f){if(await tn(r,t,d,n.splitting,{stopped:n.stopped,settle:n.settle,...i}))return{stopped:!0};continue}let c=await er(r,t,d,o,{stopped:n.stopped,...i,...n.signal?{signal:n.signal}:{}});if(c==="aborted")return{stopped:!0};if(c==="untouched"){a.unshift(...Zt(d));continue}if(!Array.isArray(c))return{stopped:!0,hardRefused:c.hardRefused};n.settle(d,c)}return{stopped:!1}}async function on(r,t){for(let e=0,n=!0;n;e++){n=!1;for(let o of r){let i=t.idsOf(o,e);if(i.length===0)continue;if(t.stopped())return!0;let a=t.deleted(o);if(await t.send(o,i,e))return!0;t.deleted(o)>a&&(n=!0)}}return!1}async function je(r,t){let e=new Set(t.map(a=>a.objectApiName)),n=new Map;for(let{objectApiName:a}of t){let s;try{s=(ee.parse(await r.describe(a)).childRelationships??[]).map(f=>f.childSObject)}catch{continue}for(let d of s){if(d===a||!e.has(d))continue;let f=n.get(d)??new Set;f.add(a),n.set(d,f)}}let o=[...t],i=[];for(;o.length>0;){let a=o.findIndex(s=>!o.some(d=>d!==s&&n.get(d.objectApiName)?.has(s.objectApiName)));i.push(...o.splice(a>=0?a:0,1))}return i}async function dt(r,t,e){if(r.length===0)return{gone:[],unchecked:[]};let n;try{n=await t(r)}catch(a){return{gone:[],unchecked:[...r],failure:C(a)}}let o=new Set(n.map(a=>ne(String(a.Id)))),i=r.filter(a=>!o.has(ne(a)));return{gone:i.filter(e),unchecked:i.filter(a=>!e(a))}}function ar(r){return r.filter(t=>me[t]!==void 0&&!Ze.has(t))}async function ct(r,t,e,n,o,i){let a=de(r),s=[];for(let{objectApiName:d}of t){let f=me[d];if(!f||Ze.has(d))continue;let c;for await(let u of e.pages(d)){let l=u.filter(w=>n(d,w));if(l.length===0)continue;if(o())return{drafted:s,cancelled:!0};c??=await Pe(a,f);let g=c,m=g?.draft;if(!g||!m)break;let h=await i(d,l),R;try{R=await L(r,d,["Status"],l)}catch{continue}let y=R.filter(w=>typeof w.Id=="string"&&!h.has(w.Id.slice(0,15))).filter(w=>{let k=g.categoryOf.get(String(w.Status));return k!==void 0&&k!=="Draft"}).map(w=>({objectApiName:d,id:String(w.Id),draft:m,status:String(w.Status)}));for(let w=0;w<y.length;w+=z){if(o())return{drafted:s,cancelled:!0};let k=y.slice(w,w+z);s.push(...k);try{await r.update(d,k.map(({id:I})=>({Id:I,Status:m})))}catch{}}}}return{drafted:s,cancelled:!1}}function Ao(r,t,e,n){if(e)return`${r} ${e.id}: ${t}`;let o=n.filter(i=>i.objectApiName===r).map(i=>`${i.id} (${i.status})`);return o.length>0?`${r}: ${t} Set to Draft, with the status each had: ${o.join(", ")}.`:`${r}: ${t}`}async function sn(r,t,e){let n=[...new Set(t.map(o=>o.objectApiName))];for(let o of n){let i=t.filter(c=>c.objectApiName===o),a=new Map(i.map(c=>[c.id.slice(0,15),c])),s=i.map(c=>c.id),d;try{d=await L(r,o,["Status"],s)}catch(c){e.note(o,`Status set to ${i[0].draft} for the delete, and not read back to be restored: ${C(c)}`,!0);continue}let f=d.flatMap(c=>{let u=typeof c.Id=="string"?a.get(c.Id.slice(0,15)):void 0;return u&&c.Status===u.draft?[u]:[]});for(let c=0;c<f.length;c+=z){let u=f.slice(c,c+z),l;try{l=await r.update(o,u.map(({id:m,status:h})=>({Id:m,Status:h})))}catch(m){l=u.map(()=>({success:!1,errors:[C(m)]}))}let g=Array.isArray(l)?l:[l];u.forEach(({draft:m,status:h},R)=>{let y=ot.safeParse(g[R]);if(y.success&&y.data.success){e.note(o,`Status set to ${m} for the delete, then back to ${h}.`,!1,u[R]);return}let w=y.success?y.data.errors??[]:[],k=w.length>0?st(w[0]):"The org gave no reason.";e.note(o,`Status set to ${m} for the delete, and left there: the org refused ${h} back \u2014 ${k}`,!0,u[R])})}}}var le="DuplicateRecordSet",dr="DuplicateRecordItem",_e=2e3,cr=999,lr=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function j(r){return r.slice(0,15)}function an(r){return new Date(r).toISOString().replace(/\.\d{3}Z$/,"Z")}function lt(r){return typeof r=="string"?Date.parse(r):Number.NaN}async function dn(r,t){return(await ur(r,t)).map(e=>({id:e.id,modified:fr(e,t)}))}async function ur(r,t){let e=t.madeFrom??t.start-2e3;if(!Number.isFinite(e)||!Number.isFinite(t.end)||t.user!==void 0&&!lr.test(t.user))return[];let n;try{let c=await r.query(`SELECT Id, CreatedDate, LastModifiedDate, LastModifiedById FROM ${le} WHERE CreatedDate >= ${an(e)} AND CreatedDate <= ${an(t.end+6e4)} LIMIT ${_e}`);if(c.records.length>=_e)return[];n=c.records.filter(u=>typeof u=="object"&&u!==null)}catch{return[]}let o=n.flatMap(c=>typeof c.Id=="string"?[c.Id]:[]);if(o.length===0)return[];let i=new Map,a=new Map,s=new Map;try{for(let c of H(o)){let u=await r.query(`SELECT Id, RecordId, DuplicateRecordSetId, CreatedDate FROM ${dr} WHERE DuplicateRecordSetId IN (${c}) LIMIT ${_e}`);if(u.records.length>=_e)return[];for(let l of u.records){let g=l??{},m=g.DuplicateRecordSetId,h=g.RecordId;if(typeof m!="string")continue;let R=lt(g.CreatedDate);if(Number.isFinite(R)&&!(R<=(s.get(j(m))??Number.NaN))&&s.set(j(m),R),typeof h!="string"||!t.has(j(h))){let y=i.get(j(m))??new Set;y.add(typeof h=="string"?j(h):`item ${String(g.Id)}`),i.set(j(m),y)}else a.set(j(m),[...a.get(j(m))??[],j(h)])}}}catch{return[]}let d=t.user!==void 0?j(t.user):void 0,f=(c,u)=>{let l=i.get(c)?.size??0;return a.has(c)?l<=1:d!==void 0&&l===0&&typeof u=="string"&&j(u)===d};return n.flatMap(c=>typeof c.Id=="string"&&f(j(c.Id),c.LastModifiedById)?[{id:c.Id,created:lt(c.CreatedDate),modified:lt(c.LastModifiedDate),...typeof c.LastModifiedById=="string"?{modifiedBy:c.LastModifiedById}:{},names:a.get(j(c.Id))??[],...s.has(j(c.Id))?{itemsMade:s.get(j(c.Id))}:{}}]:[])}function fr(r,t){let e=r.modifiedBy!==void 0?j(r.modifiedBy):"";if(t.user!==void 0&&e===j(t.user)&&r.modified<=t.end+6e4)return Math.min(r.modified,t.end);let n=t.end+6e4;return r.names.length>0&&r.created<=n&&r.modified<=n&&(r.modified===r.created||r.modified<=(r.itemsMade??Number.NaN)+cr)?Math.min(r.modified,t.end):r.modified}async function cn(r,t,e,n="recycle"){let o=T(t),i=new Set;try{for(let a of H(e)){let s=await r.queryDeleted(`SELECT Id FROM ${o} WHERE Id IN (${a}) AND IsDeleted = true`);for(let d of s.records){let f=d?.Id;typeof f=="string"&&i.add(f.slice(0,15))}}}catch(a){return{error:C(a)}}return{deleted:i,inBin:n!=="hard"}}var gr=/__kav$/i;function ye(r){return gr.test(r)}function un(r){return r.replace(/v$/i,"")}var ut="Kept: its article holds a version the run did not write \u2014 a draft begun on it, or a version published since \u2014 which deleting the article would take with it. A removal that takes what changed since the run takes it too.",mr={statusCode:"ENTITY_IS_DELETED",message:"The version is no longer in the org: it went with its article."},ln=" AND IsLatestVersion = false AND PublishStatus = 'Archived'",pr="An article version is deleted through its article, over REST.",hr={success:!1,errors:[{message:"The org gave no reason."}]};function J(r){return r.slice(0,15)}function fn(r,t){let e=r.bulkDestroy?.bind(r);return{query:n=>r.query(n),queryDeleted:n=>r.queryDeleted(n),update:(n,o)=>r.update(n,o),serverTime:()=>r.serverTime(),userId:()=>r.userId(),describeGlobal:()=>r.describeGlobal(),describe:n=>ye(n)?yr(r,n):r.describe(n),destroy:(n,o)=>ye(n)?br(r,n,o,t):r.destroy(n,o),...e?{bulkDestroy:(n,o,i)=>ye(n)?Promise.resolve({kind:"untouched",reason:pr,requests:0}):e(n,o,i)}:{}}}async function yr(r,t){let e=await r.describe(t);if(typeof e!="object"||e===null)return e;let n;try{n=(await r.describe(un(t)))?.deletable}catch{n=void 0}let o={...e};return delete o.deletable,typeof n=="boolean"?{...o,deletable:n}:o}async function gn(r,t,e){let n=T(t),o=new Map,i=new Map,a=(d,f)=>{for(let c of d){let u=c;if(typeof u?.Id!="string"||typeof u.KnowledgeArticleId!="string")continue;f?.set(J(u.Id),u.KnowledgeArticleId);let l=J(u.KnowledgeArticleId),g=i.get(l)??new Set;g.add(J(u.Id)),i.set(l,g)}};for(let d of["",ln])for(let f of H(e)){let c=await r.query(`SELECT Id, KnowledgeArticleId FROM ${n} WHERE Id IN (${f})${d}`);a(c.records,o)}let s=[...new Set(o.values())];for(let d of["",ln])for(let f of H(s)){let c=await r.query(`SELECT Id, KnowledgeArticleId FROM ${n} WHERE KnowledgeArticleId IN (${f})${d}`);a(c.records)}return{articleOf:o,versions:i}}function mn({articleOf:r,versions:t},e,n){if(n.includeChanged)return new Set;let o=new Set(e.map(J)),i=a=>[...t.get(a)??[]].some(s=>!o.has(s));return new Set([...r.values()].map(J).filter(i))}async function pn(r,t,e,n){let o=await gn(r,t,e),i=mn(o,e,n);return new Set(e.map(J).filter(a=>{let s=o.articleOf.get(a);return s!==void 0&&i.has(J(s))}))}async function br(r,t,e,n){let o=await gn(r,t,e),{articleOf:i}=o,a=[...new Set(i.values())],s=mn(o,e,n),d=a.filter(c=>!s.has(J(c))),f=new Map;if(d.length>0){let c;try{c=await r.destroy(un(t),d)}catch(l){let g=C(l);c=d.map(()=>({success:!1,errors:[{message:g}]}))}let u=Array.isArray(c)?c:[c];d.forEach((l,g)=>f.set(J(l),u[g]))}return e.map(c=>{let u=i.get(J(c));return u===void 0?{success:!1,errors:[mr]}:s.has(J(u))?{success:!1,errors:[{message:ut}]}:f.get(J(u))??hr})}var xe="Quote",Re="QuoteLineItem",be="Opportunity",we="OpportunityLineItem",hn=2e3;function Rr(r){return r.slice(0,15)}function yn(r){return typeof r=="string"?Date.parse(r):Number.NaN}function F(r,t){let e=r[t];return typeof e=="string"&&e!==""?Rr(e):void 0}function gt(r,t){return r.has(t)||r.otherParts?.has(t)===!0}function wr(r,t){let e=new Set,n=new Set;for(let g of r.syncing){let m=F(g,"Id"),h=F(g,"SyncedQuoteId");!m||!h||!gt(t,m)||!t.has(h)||(e.add(h),n.add(m))}if(e.size===0)return[];let o=r.quoteLines.filter(g=>{let m=F(g,"QuoteId");return m!==void 0&&e.has(m)&&F(g,"Id")!==void 0}),i=r.opportunityLines.filter(g=>{let m=F(g,"OpportunityId");return m!==void 0&&n.has(m)&&F(g,"Id")!==void 0}),a=g=>F(g,"CreatedById"),s=(g,m)=>{let h=F(g,"Id");if(!h||gt(t,h)||!m)return!1;let R=t.user??a(m),y=yn(g.CreatedDate);return R!==void 0&&a(g)===R&&y>=t.start&&y<=t.end},d=g=>({id:String(g.Id),modified:yn(g.LastModifiedDate)}),f=new Map(i.flatMap(g=>{let m=F(g,"Id");return m&&t.has(m)?[[m,g]]:[]})),c=new Map;for(let g of o){let m=F(g,"Id"),h=F(g,"OpportunityLineItemId");m&&h&&t.has(m)&&!c.has(h)&&c.set(h,g)}let u=o.filter(g=>{let m=F(g,"OpportunityLineItemId");return s(g,m?f.get(m):void 0)}).map(d),l=i.filter(g=>{let m=F(g,"Id");return s(g,m?c.get(m):void 0)}).map(d);return[...u.length>0?[{objectApiName:Re,copies:u}]:[],...l.length>0?[{objectApiName:we,copies:l}]:[]]}function bn(r,t=[]){let e=new Set(r),n=e.has(be)||new Set(t).has(be);if(!e.has(xe)||!n)return[];let o=e.has(Re),i=e.has(we);return o===i?[]:[o?we:Re]}async function ft(r,t,e,n,o){let i=e.map(T).join(", "),a=[];for(let s of H(o)){let d=await r.query(`SELECT ${i} FROM ${T(t)} WHERE ${T(n)} IN (${s}) LIMIT ${hn}`);if(d.records.length>=hn)throw new Error(`More ${t} records than one read takes.`);for(let f of d.records)typeof f=="object"&&f!==null&&a.push(f)}return a}async function Rn(r,t,e,n){let o=n.has(Re)||n.has(we),i=n.has(be)||t.otherParts?.objects.has(be)===!0;if(e.length===0||!i||!o)return[];try{let s=(await ft(r,be,["Id","SyncedQuoteId"],"SyncedQuoteId",e)).filter(c=>{let u=F(c,"Id");return u!==void 0&>(t,u)});if(s.length===0)return[];let d=await ft(r,Re,["Id","QuoteId","OpportunityLineItemId","CreatedById","CreatedDate","LastModifiedDate"],"QuoteId",[...new Set(s.map(c=>String(c.SyncedQuoteId)))]),f=await ft(r,we,["Id","OpportunityId","CreatedById","CreatedDate","LastModifiedDate"],"OpportunityId",s.map(c=>String(c.Id)));return wr({syncing:s,quoteLines:d,opportunityLines:f},t)}catch{return[]}}var Sr=5,Se=4,Fe=2e3,kr=4,He=[["CreatedDate","LastModifiedDate","CreatedById","LastModifiedById"],["CreatedDate","LastModifiedDate","CreatedById"],["SystemModstamp"],[]],pt=1e4,Or="005",wn="ContentDocumentLink",Ar="ContentDocument",Dr="ContentVersion",Ir=5;function Je(r){let t=new Set(r.flatMap(n=>n.ids.map(b))),e=new Map;for(let{objectApiName:n,ids:o}of r)e.set(n,[...e.get(n)??[],...o]);return{objects:[...e].map(([n,o])=>({objectApiName:n,count:o.length})),pages:async function*(n){let o=e.get(n);o&&o.length>0&&(yield o)},has:n=>t.has(n)}}function re(r){return!Array.isArray(r)}function ts(r){return re(r)?r.objects.reduce((t,e)=>t+e.count,0):r.reduce((t,e)=>t+e.ids.length,0)}function ns(r){return(re(r)?r.objects:r).map(t=>t.objectApiName)}var qe=class{bits=new Uint8Array(0);add(t){let e=t>>3;if(e>=this.bits.length){let n=new Uint8Array(Math.max(e+1,this.bits.length*2,64));n.set(this.bits),this.bits=n}this.bits[e]|=1<<(t&7)}has(t){let e=t>>3;return e<this.bits.length&&(this.bits[e]&1<<(t&7))!==0}},ht=class{dates=new Float64Array(0);set(t,e){if(t>=this.dates.length){let n=new Float64Array(Math.max(t+1,this.dates.length*2,64)).fill(Number.NaN);n.set(this.dates),this.dates=n}this.dates[t]=e}at(t){return t<this.dates.length?this.dates[t]:Number.NaN}latestWithin(t,e){let n=Number.NaN;for(let o of this.dates)o>=t&&o<=e&&!(o<=n)&&(n=o);return n}};function ue(r,t){return typeof r=="string"&&t.has(b(r))}var Sn=[{created:"CreatedDate",modified:"LastModifiedDate"},{modified:"SystemModstamp"}],mt={ContentDocumentLink:{ends:["ContentDocumentId","LinkedEntityId"],cameWithRun:(r,t)=>{let e=r.LinkedEntityId;return ue(r.ContentDocumentId,t)&&(ue(e,t)||typeof e=="string"&&e.startsWith(Or))}},DuplicateRecordItem:{ends:["RecordId"],cameWithRun:(r,t)=>ue(r.RecordId,t)},ContentVersion:{ends:["ContentDocumentId"],cameWithRun:(r,t)=>ue(r.ContentDocumentId,t)},[te.objectApiName]:{ends:[te.parent,te.field],cameWithRun:(r,t)=>r[te.field]===te.value&&ue(r[te.parent],t)}};function rs(r,t){return{...Ce(r,t),serverTime:async()=>(await r.soap.getServerTimestamp()).timestamp,userId:async()=>(await r.soap.getUserInfo()).userId,queryDeleted:async e=>({records:(await r.query(e,{scanAll:!0})).records}),bulkDestroy:(e,n,o)=>he(Me(r),e,n,o)}}function yt(r,t,e){let n=new Map;for(let o of r??[]){let i=wt(o.span,[],e);if(Number.isFinite(i.end))for(let a of o[t]??[]){let s=b(a);i.end<=(n.get(s)?.end??Number.NEGATIVE_INFINITY)||n.set(s,i)}}return n}function Er(r=[],t=[]){if(r.length===0&&t.length===0)return;let e=[...r.map(({plan:n})=>re(n)?n:Je(n)),Je(t)];return{has:n=>e.some(o=>o.has(n))}}function Pr(r=[],t=[]){return new Set([...r.map(({plan:e})=>re(e)?e.objects:e),t].flat().map(e=>e.objectApiName))}function In(r,t){return new Map([...yt(r,"wrote",t)].map(([e,{end:n}])=>[e,n]))}function En(r,t){return`The user SandForge connects as may not delete ${r} records in this org: the ${t} record(s) of the run stay, and were not sent.`}function bt(r,t){return`Not visible: ${r} record(s) found neither in the org nor in its recycle bin, as the user the removal runs as sees them \u2014 out of that user's sight, or deleted for good \u2014 are not counted as removed`+(t?` (the recycle bin could not be read: ${t})`:".")}function kn(r,t,e){for(let o of r){let i=o.deleted+o.alreadyGone+o.keptChanged+o.keptDependents+o.refused+(o.notVisible??0);o.planned>i&&(o.notReached=o.planned-i)}let n=new Set(r.map(o=>o.objectApiName));for(let{objectApiName:o,count:i}of t)i===0||n.has(o)||(n.add(o),r.push({...new ke(o,i,e(o)).result,notReached:i}));return r}var os={objects:[],cancelled:!1,gone:[],stamps:{},left:async function*(){}};function b(r){return r.slice(0,15)}function Cr(r){return r?.errorCode==="INVALID_FIELD"||/no such column/i.test(C(r))}function Nr(r,t){let e=/no such column '(\w+)'/i.exec(C(r))?.[1],n=He.findIndex((o,i)=>i>t&&(e===void 0||!o.includes(e)));return n===-1?He.length:n}function N(r){return typeof r=="string"?Date.parse(r):Number.NaN}function Pn(){return{modified:new ht,missing:new Set,firstCreated:Number.NaN,lastCreated:Number.NaN,binned:new Set}}var ke=class{result;notes=[];refused=new Map;unread;held=[];goneAt=new qe;goneLater=new Set;deletedLater=new Set;notVisible=0;notVisibleNote;secondTry=new Set;filesLeft=new Map;automationHeld=new Map;automationHeldAfter=new Set;automationHeldAlong=new Set;tookAlong=new Map;cameAlong=new Map;limitNotes=[];lockResent=new Map;constructor(t,e,n=0){this.result={objectApiName:t,planned:e,deleted:0,alreadyGone:0,keptChanged:0,keptDependents:0,refused:0,heldBy:[],...n>0?{platformCopies:n}:{},unchecked:[],reasons:[]}}note(t){this.notes.includes(t)||this.notes.push(t)}isGone(t,e){return this.goneAt.has(e)||this.goneLater.has(b(t))}waiting(){return[...[...this.refused].filter(([,t])=>t.dependency).map(([t])=>t),...this.held]}refusedSent(){return[...this.refused].filter(([,t])=>t.sent).map(([t])=>t)}refusedToSendAgain(){return[...this.refused].filter(([,t])=>t.sent&&t.limit!==!0).map(([t])=>t)}secondTryNote(){if(this.secondTry.size===0)return[];let t=0,e=0,n=0,o=0;for(let a of this.secondTry){let s=b(a);this.deletedLater.has(s)?t++:this.goneLater.has(s)?e++:this.refused.has(a)?o++:n++}return[`Refused at first, sent again once the rest had gone: ${[t>0?`${t} deleted`:"",e>0?`${e} already gone`:"",n>0?`${n} kept for records that stay`:"",o>0?`${o} refused again`:""].filter(Boolean).join(", ")}.`]}settle(){this.result.keptDependents=this.held.length,this.result.refused=this.refused.size+(this.unread?.count??0),this.notVisible>0&&(this.result.notVisible=this.notVisible),this.held.length===0&&(this.result.heldBy=[]);let t=this.held.flatMap(i=>{let a=this.automationHeld.get(b(i));return a?[a]:[]}),e=this.held.filter(i=>{let a=b(i);return this.automationHeld.has(a)&&this.automationHeldAfter.has(a)}).length,n=this.held.filter(i=>{let a=b(i);return this.automationHeld.has(a)&&this.automationHeldAlong.has(a)}).length;t.length>0?(this.result.heldByAutomation=t.length,e>0?this.result.heldByAutomationAfterRun=e:delete this.result.heldByAutomationAfterRun,n>0?this.result.heldByAutomationAlong=n:delete this.result.heldByAutomationAlong,this.result.automationHolders=[...new Set(t.flatMap(i=>[...i]))]):(delete this.result.heldByAutomation,delete this.result.heldByAutomationAfterRun,delete this.result.heldByAutomationAlong,delete this.result.automationHolders);let o=[...this.notVisibleNote?[this.notVisibleNote]:[],...this.notes,...this.limitNotes,...nn(this.lockResent.values()),...this.secondTryNote(),...this.unread?[this.unread.reason]:[],...[...this.refused.values()].map(i=>i.reason)];return this.result.reasons=[...new Set(o)].slice(0,Sr),this.filesLeft.size>0&&(this.result.filesLeft={count:this.filesLeft.size,names:[...this.filesLeft.values()].slice(0,Ir)}),this.tookAlong.size>0&&(this.result.tookAlong={count:this.tookAlong.size,objects:[...new Set(this.tookAlong.values())]}),this.cameAlong.size>0&&(this.result.cameAlong={count:this.cameAlong.size,objects:[...new Set(this.cameAlong.values())]}),this.result}};async function ss(r,t,e){let n=re(t)?t:Je(t),o=n,i=o.objects.reduce((p,S)=>p+S.count,0),a=new Map,s=p=>a.get(p)??0,d=()=>e.signal?.aborted===!0,f=e.splitting??vt(),c=()=>({objects:kn([],o.objects,s),cancelled:!0,gone:[],stamps:{},left:()=>Dn(n)}),u=new Map,l=new Map;for(let{objectApiName:p}of o.objects){let S=Pn();u.set(p,S);let O=0;for await(let A of o.pages(p)){if(d())return c();let v=A[0];v!==void 0&&!l.has(v.slice(0,3))&&l.set(v.slice(0,3),p);let E=O;if(O+=A.length,S.error!==void 0)continue;let D=await Br(r,p,A,E,S);if(S.error!==void 0||D.length===0)continue;if(d())return c();let B=await cn(r,p,D);if("error"in B)S.binError=B.error;else for(let q of B.deleted)S.binned.add(q)}}let g=new Map,m=!1,h=r.bulkDestroy?.bind(r),R={query:p=>r.query(p),destroy:(p,S)=>(m=!0,r.destroy(p,S)),...h?{bulkDestroy:(p,S)=>(m=!0,h(p,S,e.signal))}:{},update:(p,S)=>(m=!0,r.update(p,S)),serverTime:()=>r.serverTime(),userId:()=>r.userId(),queryDeleted:p=>r.queryDeleted(p),describeGlobal:()=>r.describeGlobal(),describe:p=>{let S=g.get(p);return S||(S=r.describe(p),g.set(p,S)),S}},y=fn(R,{includeChanged:e.includeChanged}),w=await je(y,o.objects),k=await jr(y,w,(p,S)=>S-(u.get(p)?.missing.size??0)),I=new Set(k.map(p=>p.objectApiName));if(k.length>0&&e.onUndeletable&&e.previewOnly!==!0){if(d())return c();if(!await e.onUndeletable(k))return{...c(),objects:[],undeletable:k,stoppedForUndeletable:!0}}let[P,_]=await Promise.all([Ur(y),e.previewOnly===!0?void 0:$r(y)]),{start:G,end:K}=wt(e,u.values(),P.aheadMs);if(d())return c();let oe=Er(e.otherParts,e.otherPartRecords),ze=Pr(e.otherParts,e.otherPartRecords),Ae=await xr(y,o,{start:G,end:K,...e.runUserId?{user:b(e.runUserId)}:{},...oe?{otherParts:{has:p=>oe.has(p),objects:ze}}:{},undeletable:I,snapshots:u}),We=[];if(e.runUserId&&e.alongAccepted!==!0){let p=await dn(y,{has:S=>o.has(S),start:G,end:K,user:e.runUserId});if(p.length>0&&!o.objects.some(S=>S.objectApiName===le)&&await Cn(y,le)){Ae.push({objectApiName:le,copies:p});for(let S of p)We.push(S.id)}}if(Ae.length>0){o=await Fr(o,Ae,u,l);for(let{objectApiName:p,copies:S}of Ae)a.set(p,S.length);i=o.objects.reduce((p,S)=>p+S.count,0),w=await je(y,o.objects)}let vn=new Map(Object.entries(e.removalStamps??{}).map(([p,S])=>[b(p),N(S)])),Tn=In(e.laterParts,P.aheadMs),se=new Set;for(let{objectApiName:p}of o.objects){let S=u.get(p);if(!S||S.error!==void 0)continue;let O=0;for await(let A of o.pages(p))for(let v of A){let E=S.modified.at(O++),D=b(v);if(S.missing.has(D))continue;E<=K||E<=(vn.get(D)??Number.NaN)||E<=(Tn.get(D)??Number.NaN)||se.add(D)}}if(e.previewOnly===!0){if(d())return c();let p=new Set,S=await Lr(y,o,w,{snapshots:u,changed:se,undeletable:I,includeChanged:e.includeChanged,stopped:d,copiesOf:s,...e.previewHeld===!0?{held:{notSent:p,check:new Oe(y,{runRecords:o,reached:{has:()=>!1},stays:O=>p.has(O),runStart:G,runEnd:K,removalStart:P.start,removalUser:void 0,earlierRemovals:(e.removalSpans??[]).map(O=>({start:N(O.first),end:N(O.last),user:b(O.userId)})),includeChanged:e.includeChanged,previewing:!0,...e.goesWithParent?{goesWithParent:e.goesWithParent}:{},...e.goesWithParentReadBelow?{goesWithParentReadBelow:!0}:{},...e.alongAccepted?{alongAccepted:e.alongAccepted}:{},...e.runUserId?{runUser:b(e.runUserId)}:{},...e.laterParts?{linkedLater:yt(e.laterParts,"linked",P.aheadMs)}:{},...oe?{otherPartRecords:oe,otherPartObjects:ze}:{}})}}:{}});return S?{...k.length>0?{undeletable:k}:{},objects:[],cancelled:!1,gone:[],stamps:{},left:()=>Dn(n),preview:S}:c()}let St=await _r(y,e.otherParts??[],P.aheadMs,d);if(!St)return c();let kt=new Set,jn={has:p=>o.has(p)&&kt.has(l.get(p.slice(0,3))??"")},Ve=new Oe(y,{runRecords:o,reached:jn,stays:p=>se.has(p)&&!e.includeChanged,runStart:G,runEnd:K,removalStart:P.start,removalUser:_,earlierRemovals:(e.removalSpans??[]).map(p=>({start:N(p.first),end:N(p.last),user:b(p.userId)})),includeChanged:e.includeChanged,...e.goesWithParent?{goesWithParent:e.goesWithParent}:{},...e.goesWithParentReadBelow?{goesWithParentReadBelow:!0}:{},...e.alongAccepted?{alongAccepted:e.alongAccepted}:{},...e.alongToDraft?{alongToDraft:e.alongToDraft}:{},...e.runUserId?{runUser:b(e.runUserId)}:{},...e.automationMade?{automationMade:Ln(e.automationMade)}:{},...e.laterParts?{linkedLater:yt(e.laterParts,"linked",P.aheadMs)}:{},...oe?{otherPartRecords:oe,otherPartObjects:ze}:{}});if(d())return c();await e.beforeFirstWrite?.(),e.sweep&&await e.sweep(f)&&(m=!0);let Y=[],Ot=p=>Y.find(S=>S.result.objectApiName===p);async function*Ke(p,S,O){for(let{objectApiName:A}of S){let v=Ot(A),E=0;for await(let D of p.pages(A)){let B=D.filter(q=>O(A,q,v?.isGone(q,E++)===!0));B.length>0&&(yield{objectApiName:A,ids:B})}}}let _n=()=>Ke(o,w,(p,S,O)=>{let A=u.get(p),v=b(S);return A?.modifiedColumn==="LastModifiedDate"&&!A.missing.has(v)&&!se.has(v)&&!O}),De=[],$=async p=>{await sn(y,De,{note:(D,B,q)=>{let U=Ot(D);if(!U){if(!q)return;let W=o.objects.find(V=>V.objectApiName===D);U=new ke(D,W?.count??0,s(D)),Y.push(U)}U.note(B)}});let S=m?await On(y,_n(),{start:P.start,user:_}):{},O=[];if(m)for(let D of St)O.push(await On(y,D.unchanged(),{start:P.start,user:_}));let A=m?Hr(P,_):void 0,v=[];if(!re(t))for await(let{ids:D}of Ke(n,w,(B,q,U)=>U))for(let B of D)v.push(B);for(let D of Y)D.limitNotes=at(D.result.objectApiName,f);let E=Y.map(D=>D.settle());return{...k.length>0?{undeletable:k}:{},objects:p?kn(E,w,s):E,cancelled:p,gone:v,left:()=>Ke(n,n.objects,(D,B,q)=>!q),stamps:S,...A?{span:A}:{},...O.length>0?{otherPartStamps:O}:{},...We.length>0?{duplicateSets:We}:{}}};if(d())return m?$(!0):c();let At=async(p,S)=>(await Ve.heldAmong(p,S)).held,Dt=await ct(y,w,o,(p,S)=>{let O=b(S),A=u.get(p);return A!==void 0&&A.error===void 0&&!I.has(p)&&!A.missing.has(O)&&!(se.has(O)&&!e.includeChanged)},d,At);if(De=Dt.drafted,Dt.cancelled)return $(!0);if(e.alongToDraft){let p=await ct(y,e.alongToDraft.objects,e.alongToDraft,()=>!0,d,At);if(De=[...De,...p.drafted],p.cancelled)return $(!0)}let Q=0;for(let{objectApiName:p,count:S}of w){if(d())return $(!0);let O=new ke(p,S,s(p));Y.push(O),kt.add(p);let A=u.get(p);if(!A||A.error!==void 0){O.unread={reason:A?.error??"The org gave no reason.",count:S},Q+=S,e.onProgress?.(Q,i,p);continue}if(I.has(p)){let U=0,W=0;for await(let V of o.pages(p))for(let ie of V){let fe=b(ie),xn=U++;A.missing.has(fe)?A.binned.has(fe)?(O.result.alreadyGone++,O.goneAt.add(xn)):O.notVisible++:W++}O.notVisible>0&&(O.notVisibleNote=bt(O.notVisible,A.binError)),W>0&&(O.unread={reason:En(p,W),count:W}),Q+=S,e.onProgress?.(Q,i,p);continue}let v=Xt(y,p,S),E=[],D=new Map,B=async()=>{let U=E,W=D;return E=[],D=new Map,An(y,Ve,O,U,{stopped:d,splitting:f,placeOf:W,onDeleted:V=>{Q+=V,e.onProgress?.(Q,i,p)},onHeld:V=>{Q+=V,e.onProgress?.(Q,i,p)}})},q=0;for await(let U of o.pages(p)){if(d())return $(!0);let W=E.length;for(let V of U){let ie=b(V),fe=q++;A.missing.has(ie)?A.binned.has(ie)?(O.result.alreadyGone++,O.goneAt.add(fe)):O.notVisible++:se.has(ie)&&!e.includeChanged?O.result.keptChanged++:(E.push(V),D.set(ie,fe))}if(O.notVisible>0&&(O.notVisibleNote=bt(O.notVisible,A.binError)),Q+=U.length-(E.length-W),!(v&&E.length<Te)&&await B())return $(!0)}if(v&&E.length>0&&(d()||await B()))return $(!0)}let Bn=Y.some(p=>p.result.deleted>0);if(await on(Y,{stopped:d,idsOf:(p,S)=>{if(S>0)return p.waiting();let O=p.refusedToSendAgain();return O.length>0||Bn?[...O,...p.held]:[]},send:async(p,S,O)=>{let A=new Set(O===0?p.refusedToSendAgain():[]),v=await An(y,Ve,p,S,{stopped:d,splitting:f,onSent:E=>{for(let D of E)A.has(D)&&p.secondTry.add(D)}});for(let E of p.held)A.has(E)&&p.secondTry.add(E);return v},deleted:p=>p.result.deleted}))return $(!0);if(e.afterRemoval){if(d())return $(!0);await e.afterRemoval(f)&&(m=!0)}for(let p of Y){if(d())return $(!0);await Tr(y,p,u.get(p.result.objectApiName))}return $(!1)}async function Mr(r,t,e,n,o){let{changed:i,includeChanged:a}=o,s=[];for await(let d of t.pages(e))for(let f of d){let c=b(f);!n.has(c)&&(a||!i.has(c))&&s.push(f)}try{return{kept:await pn(r,e,s,{includeChanged:a})}}catch(d){return{kept:new Set,unread:C(d)}}}async function Lr(r,t,e,n){let o=[],i=new Set,a=new Set;for(let{objectApiName:s,count:d}of e){let f=n.copiesOf(s),c={objectApiName:s,planned:d,toDelete:0,alreadyGone:0,changedSince:0,keptChanged:0,changedBy:{},undeletable:0,notVisible:0,unread:0,...f>0?{platformCopies:f}:{},reasons:[]};o.push(c);let u=n.snapshots.get(s);if(!u||u.error!==void 0){if(c.unread=d,c.reasons.push(u?.error??"The org gave no reason."),n.held)for await(let R of t.pages(s))for(let y of R)n.held.notSent.add(b(y));continue}let l=ye(s)&&!n.undeletable.has(s)?await Mr(r,t,s,u.missing,n):void 0,g=[],m=[],h=R=>{n.held?.notSent.add(R)};for await(let R of t.pages(s))for(let y of R){let w=b(y);u.missing.has(w)?u.binned.has(w)?c.alreadyGone++:c.notVisible++:n.undeletable.has(s)?(c.undeletable++,h(w)):l?.unread!==void 0?(c.unread++,h(w)):n.changed.has(w)?(c.changedSince++,g.push(y),n.includeChanged?(c.toDelete++,m.push(y)):(c.keptChanged++,h(w))):l?.kept.has(w)?(c.changedSince++,c.keptChanged++,h(w)):(c.toDelete++,m.push(y))}if(n.held&&m.length>0){if(n.stopped())return;let R=await n.held.check.heldAmong(s,m),y=m.filter(k=>R.held.has(b(k)));if(y.length>0){c.toDelete-=y.length,c.keptDependents=y.length,c.heldBy=[...R.holders];for(let I of y)n.held.notSent.add(b(I));let k=y.filter(I=>R.byAutomation.has(b(I)));k.length>0&&(c.heldByAutomation=k.length)}let w=new Map;for(let k of m)if(!R.held.has(b(k)))for(let[I,P]of R.cameAlong.get(b(k))??[])a.has(I)||(a.add(I),w.set(I,P));w.size>0&&(c.cameAlong={count:w.size,objects:[...new Set(w.values())]}),R.reason!==void 0&&c.reasons.push(R.reason),R.unchecked.size>0&&c.reasons.push(`Not checked: what hangs from them through ${[...R.unchecked].join(", ")}, which the org deletes along but does not let be read by the record it hangs from.`)}if(l?.unread!==void 0?c.reasons.push(`Its articles could not be read: ${l.unread}`):l!==void 0&&l.kept.size>0&&c.reasons.push(ut),c.notVisible>0&&c.reasons.push(bt(c.notVisible,u.binError)),c.undeletable>0&&c.reasons.push(En(s,c.undeletable)),!(g.length===0||u.modifiedColumn!=="LastModifiedDate")){if(n.stopped())return;try{let R=await L(r,s,["LastModifiedById"],g,Se);for(let y of R){let w=y.LastModifiedById;typeof w!="string"||w===""||(c.changedBy[w]=(c.changedBy[w]??0)+1,i.add(w))}}catch(R){c.reasons.push(`Who changed them since the run could not be read: ${C(R)}`)}}}if(!n.stopped())return{objects:o,userNames:await vr(r,[...i])}}async function vr(r,t){let e={};if(t.length===0)return e;try{for(let n of await L(r,"User",["Name"],[...t].sort()))typeof n.Id=="string"&&typeof n.Name=="string"&&(e[n.Id]=n.Name)}catch{}return e}async function Tr(r,t,e){let{gone:n,unchecked:o,failure:i}=await dt(t.refusedSent(),a=>L(r,t.result.objectApiName,[],a),a=>e!==void 0&&e.error===void 0&&!e.missing.has(b(a)));for(let a of n)t.refused.delete(a),t.goneLater.add(b(a)),t.result.alreadyGone++;o.length>0&&t.note(`Not checked: ${o.length} refused record(s) could not be read back once the rest had gone, to tell whether a parent deleted after them took them along`+(i?` \u2014 ${i}`:"."))}function is(r,t=[],e={}){return[...new Set([...r,...bn(r,t),...e.userKept===!0&&r.length>0?[le]:[]])]}async function jr(r,t,e){let n=[];for(let{objectApiName:o,count:i}of t){if(o===Dr||i===0)continue;let a=e(o,i);if(a!==0)try{let s=ee.safeParse(await r.describe(o));s.success&&s.data.deletable===!1&&n.push({objectApiName:o,records:a})}catch{}}return n}async function On(r,t,e){let n={},{start:o,user:i}=e;if(i===void 0||!Number.isFinite(o))return n;for await(let{objectApiName:a,ids:s}of t){let d;try{d=await L(r,a,["LastModifiedDate","LastModifiedById"],s)}catch{continue}for(let f of d)typeof f.Id=="string"&&typeof f.LastModifiedDate=="string"&&typeof f.LastModifiedById=="string"&&b(f.LastModifiedById)===i&&N(f.LastModifiedDate)>=o&&(n[f.Id]=f.LastModifiedDate)}return n}async function _r(r,t,e,n){let o=[];for(let i of t){let a=re(i.plan)?i.plan:Je(i.plan),{end:s}=wt(i.span,[],e),d=new Map(Object.entries(i.removalStamps??{}).map(([u,l])=>[b(u),N(l)])),f=In(i.laterParts,e),c=new Map;if(Number.isFinite(s))for(let{objectApiName:u}of a.objects){let l=new qe,g=0,m=!1;for await(let h of a.pages(u)){if(n())return;let R=g;if(g+=h.length,m)continue;let y;try{y=await L(r,u,["LastModifiedDate"],h,Se)}catch{m=!0;continue}let w=new Map;for(let k of y)typeof k.Id=="string"&&w.set(b(k.Id),N(k.LastModifiedDate));h.forEach((k,I)=>{let P=b(k),_=w.get(P);_!==void 0&&(_<=s||_<=(d.get(P)??Number.NaN)||_<=(f.get(P)??Number.NaN))&&l.add(R+I)})}m||c.set(u,l)}o.push({unchanged:async function*(){for(let{objectApiName:u}of a.objects){let l=c.get(u);if(!l)continue;let g=0;for await(let m of a.pages(u)){let h=m.filter(()=>l.has(g++));h.length>0&&(yield{objectApiName:u,ids:h})}}}})}return o}async function An(r,t,e,n,o){let{objectApiName:i}=e.result,a=await t.heldAmong(i,n);a.reason!==void 0&&e.note(a.reason);for(let l of a.unchecked)e.result.unchecked.includes(l)||e.result.unchecked.push(l);let s=n.filter(l=>a.held.has(b(l)));if(o.placeOf){for(let l of s)e.held.push(l);e.result.heldBy=[...new Set([...e.result.heldBy,...a.holders])]}else e.held=s,e.result.heldBy=[...a.holders];for(let l of s)e.refused.delete(l);for(let l of n){let g=b(l),m=a.byAutomation.get(g);m?e.automationHeld.set(g,m):e.automationHeld.delete(g),m&&a.automationAfter.has(g)?e.automationHeldAfter.add(g):e.automationHeldAfter.delete(g),m&&a.automationAlong.has(g)?e.automationHeldAlong.add(g):e.automationHeldAlong.delete(g)}o.onHeld?.(s.length);let d=n.filter(l=>!a.held.has(b(l))),f=new Map,c=(l,g)=>{l.forEach((m,h)=>{let R=g[h],y=b(m);if((R.lockResends!==void 0||e.lockResent.has(y))&&e.lockResent.set(y,R.kind),R.kind==="refused"){e.refused.set(m,{reason:R.reason,dependency:R.dependency,sent:!0,...R.limit?{limit:!0}:{}});return}e.refused.delete(m);let w=o.placeOf?.get(y);if(w!==void 0?e.goneAt.add(w):e.goneLater.add(y),R.kind==="deleted"){e.result.deleted++,w===void 0&&e.deletedLater.add(y);for(let k of f.get(y)??[])e.filesLeft.set(k.key,k.name);for(let[k,I]of a.along.get(y)??[])e.tookAlong.set(k,I);for(let[k,I]of a.cameAlong.get(y)??[])e.cameAlong.set(k,I)}else e.result.alreadyGone++}),o.onSent?.(l),o.onDeleted?.(l.length)},{stopped:u}=await rn(r,i,d,{stopped:o.stopped,splitting:o.splitting,prepare:async l=>{f=await t.filesOn(l)},settle:c});return u}async function Br(r,t,e,n,o){let i,a=o.modifiedColumn?Sn.filter(({modified:s})=>s===o.modifiedColumn):Sn;for(let{created:s,modified:d}of a)try{let c=await L(r,t,s?[s,d]:[d],e,Se),u=new Map;for(let g of c)typeof g.Id=="string"&&u.set(b(g.Id),N(g[d])),s&&(o.firstCreated=Nn(o.firstCreated,N(g[s])),o.lastCreated=Rt(o.lastCreated,N(g[s])));o.modifiedColumn=d;let l=[];return e.forEach((g,m)=>{let h=b(g),R=u.get(h);R===void 0&&(o.missing.add(h),l.push(g)),o.modified.set(n+m,R??Number.NaN)}),l}catch(f){i??=C(f)}return o.error=i,o.modifiedColumn=void 0,[]}async function*Dn(r){for(let{objectApiName:t}of r.objects)for await(let e of r.pages(t))e.length>0&&(yield{objectApiName:t,ids:[...e]})}async function xr(r,t,e){let n=new Set(t.objects.filter(s=>s.count>0).map(s=>s.objectApiName));if(!n.has(xe))return[];let o=[];for await(let s of t.pages(xe))o.push(...s);let i=await Rn(r,{has:s=>t.has(s),start:e.start,end:e.end,...e.user!==void 0?{user:e.user}:{},...e.otherParts?{otherParts:e.otherParts}:{}},o,n),a=[];for(let s of i){let{objectApiName:d}=s;if(e.undeletable.has(d))continue;let f=e.snapshots.get(d);if(f){if(f.error!==void 0||f.modifiedColumn!=="LastModifiedDate")continue}else if(!await Cn(r,d))continue;a.push(s)}return a}async function Cn(r,t){try{let e=ee.safeParse(await r.describe(t));return e.success&&e.data.deletable!==!1}catch{return!1}}async function Fr(r,t,e,n){let o=new Map(t.map(({objectApiName:s,copies:d})=>[s,d])),i=new Set(t.flatMap(({copies:s})=>s.map(d=>b(d.id)))),a=r.objects.map(s=>{let d=o.get(s.objectApiName);return d?{objectApiName:s.objectApiName,count:s.count+d.length}:s});for(let[s,d]of o){r.objects.some(l=>l.objectApiName===s)||a.push({objectApiName:s,count:d.length});let f=e.get(s);f||(f={...Pn(),modifiedColumn:"LastModifiedDate"},e.set(s,f));let c=0;for await(let l of r.pages(s))c+=l.length;for(let l of d)f.modified.set(c++,l.modified);let u=d[0]?.id.slice(0,3);u!==void 0&&!n.has(u)&&n.set(u,s)}return{objects:a,pages:async function*(s){yield*r.pages(s);let d=o.get(s);d&&d.length>0&&(yield d.map(f=>f.id))},has:s=>r.has(s)||i.has(s)}}async function Ur(r){let t=Date.now(),e=Number.NaN;try{e=N(await r.serverTime())}catch{}return Number.isFinite(e)?{start:Math.floor(e/1e3)*1e3,aheadMs:e-(t+Date.now())/2}:{start:Number.POSITIVE_INFINITY,aheadMs:Number.NaN}}async function $r(r){try{let t=await r.userId();return typeof t=="string"&&t!==""?b(t):void 0}catch{return}}function Hr(r,t){if(!(t===void 0||!Number.isFinite(r.start)))return{first:new Date(r.start).toISOString(),last:new Date(Date.now()+r.aheadMs+pt).toISOString(),userId:t}}function Nn(r,t){return Number.isNaN(r)||t<r?t:r}function Rt(r,t){return Number.isNaN(r)||t>r?t:r}var Mn=999;function Jr(r,t,e){let n=Number.NaN;for(let o of r)o.lastCreated>=t&&o.lastCreated<=e&&(n=Rt(n,o.lastCreated)),n=Rt(n,o.modified.latestWithin(t,e));return n}function wt(r,t,e){let n=qr(r,t,e),o=(r.writtenUntil?.getTime()??Number.NaN)+Mn;return Number.isFinite(n.end)&&o>n.end?{...n,end:o}:n}function qr(r,t,e){let n=[...t],o=Number.NaN;for(let f of n)o=Nn(o,f.firstCreated);let i=r.runDurationMs??0,a=(r.runRecordedAt?.getTime()??Number.NaN)+e;if(r.runEndedAt===void 0&&Number.isFinite(a)){let f=a-i-pt,c=a+pt,u=r.endedByItsWrites===!0?Jr(n,f,c):Number.NaN;return{start:r.runStartedAt?.getTime()??(o>f?o:f),end:Number.isFinite(u)?Math.min(u+Mn,c):c}}let s=r.runStartedAt?.getTime()??o,d=r.runEndedAt?.getTime()??s+i;return{start:s,end:d}}function Ln(r){let t=new Set,e=-1;return{has:n=>(r.size!==e&&(t=new Set([...r].map(b)),e=r.size),t.has(n))}}function as(r,t){let e=new Oe(r,{runRecords:t.runRecords,reached:{has:()=>!1},stays:()=>!1,runStart:t.runStart,runEnd:t.runEnd,removalStart:Number.POSITIVE_INFINITY,removalUser:void 0,earlierRemovals:(t.removalSpans??[]).map(n=>({start:N(n.first),end:N(n.last),user:b(n.userId)})),includeChanged:t.includeChanged,automationMade:Ln(t.taken),...t.runUserId?{runUser:b(t.runUserId)}:{}});return async(n,o)=>{let i=await e.heldAmong(n,o,1);return{held:i.held,holders:[...i.holders],...i.reason!==void 0?{reason:i.reason}:{}}}}var Ue="IsPersonAccount";function zr(r,t){return{holding:new Set([...r.holding,...t.holding]),automation:[...r.automation,...t.automation],along:[...r.along,...t.along],goes:[...r.goes,...t.goes],unchecked:r.unchecked||t.unchecked}}var Wr=50;function $e(r,t){return JSON.stringify(t.map(e=>r[e]??null))}var Oe=class{constructor(t,e){this.org=t;this.context=e}org;context;worked;statuses=new Map;lockedUnder=new Map;files=new Map;datesKept=new Map;cascadeEnds=new Map;async heldAmong(t,e,n=0){let o={held:new Set,holders:new Set,otherwise:new Set,mayBeAutomation:[],byAutomation:new Map,automationAfter:new Set,automationAlong:new Set,along:new Map,cameAlong:new Map,unchecked:new Set};if(e.length===0)return o;let i;try{let l=ee.parse(await this.org.describe(t)),g=await this.workedObjects(),m=t==="Account"&&l.fields.some(h=>h.name===Ue);i=(l.childRelationships??[]).filter(h=>(h.cascadeDelete===!0||h.restrictedDelete===!0)&&g.has(h.childSObject)).map(h=>({childSObject:h.childSObject,field:h.field,restricted:h.cascadeDelete!==!0,...m&&h.childSObject==="Contact"&&h.field==="AccountId"?{personContacts:!0}:{}}))}catch(l){return o.reason=C(l),e.forEach(g=>this.hold(o,b(g))),o}let a=[];for(let l=0;l<e.length;l+=z)a.push(e.slice(l,l+z));let s=a.length>1?await Xe(i.map(l=>()=>this.anyPointing(l)),Se):i.map(()=>!0),d=i.filter((l,g)=>s[g]).flatMap(l=>a.map(g=>async()=>({relationship:l,...await this.holdingIn(l,g)}))),f=o.mayBeAutomation,c=new Map;for(let{relationship:l,holding:g,unchecked:m,automation:h,along:R,goes:y}of await Xe(d,Se)){m&&o.unchecked.add(l.childSObject),(g.size>0||h.length>0)&&o.holders.add(l.childSObject),g.forEach(w=>this.hold(o,w));for(let w of h)o.held.add(b(w.parent));f.push(...h);for(let{parent:w,key:k}of R){let I=o.along.get(w)??new Map;I.set(k,l.childSObject),o.along.set(w,I)}y.length>0&&c.set(l.childSObject,[...c.get(l.childSObject)??[],...y])}if(await this.heldBelow(c,o,n),n>0)return o;this.context.previewing!==!0&&await this.lockedPastDraft(t,e,o),Ee(t)&&await this.standardPricesHeld(e,o),t===Ye&&await this.sellingModelOptionsHeld(e,o),this.context.alongAccepted!==!0&&await this.automationHeldBelow(f,o);let u=await this.byAutomationOnly(t,f,o.otherwise);return o.byAutomation=u.objects,o.automationAfter=u.after,o.automationAlong=u.along,o}hold(t,e){t.held.add(e),t.otherwise.add(e)}async heldBelow(t,e,n){let o=(i,a,s,d)=>{let f=i.get(a)??new Map;f.set(s,d),i.set(a,f)};for(let[i,a]of t){let s=[...new Set(a.map(f=>f.id))],d=n+1<kr?await this.heldAmong(i,s,n+1):void 0;for(let{parent:f,id:c,came:u}of a){let l=b(c);if(!d||d.held.has(l)){this.hold(e,f),e.holders.add(i),d?.holders.forEach(g=>e.holders.add(g));continue}u&&o(e.cameAlong,f,l,i);for(let[g,m]of d.along.get(l)??[])o(e.along,f,g,m);for(let[g,m]of d.cameAlong.get(l)??[])o(e.cameAlong,f,g,m)}d?.unchecked.forEach(f=>e.unchecked.add(f))}}async automationHeldBelow(t,e){let n=new Map;for(let o of t)e.otherwise.has(b(o.parent))||n.set(o.object,[...n.get(o.object)??[],o]);for(let[o,i]of n){let a=await this.heldAmong(o,[...new Set(i.map(s=>s.id))],1);for(let s of i){let d=b(s.id),f=a.mayBeAutomation.some(c=>b(c.parent)===d&&c.creator!==s.creator);!a.otherwise.has(d)&&!f||(this.hold(e,b(s.parent)),a.holders.forEach(c=>e.holders.add(c)))}a.unchecked.forEach(s=>e.unchecked.add(s))}}async byAutomationOnly(t,e,n){let o=new Map,i=new Set,a=e.filter(u=>!n.has(b(u.parent)));if(a.length===0)return{objects:o,after:i,along:new Set};let s;try{let u=await L(this.org,t,["CreatedDate","CreatedById"],[...new Set(a.map(l=>l.parent))]);s=new Map(u.flatMap(l=>typeof l.Id=="string"?[[b(l.Id),l]]:[]))}catch{return{objects:o,after:i,along:new Set}}let d=new Set,f=new Set;for(let u of a){let l=b(u.parent),g=s.get(l),m=N(g?.CreatedDate),h=g?.CreatedById,R=this.context.runUser??(typeof h=="string"?b(h):void 0),y=u.created-m;if(!(R!==void 0&&u.creator===R&&y>=-2e3&&y<=6e4)){d.add(l);continue}let k=o.get(l)??new Set;k.add(u.object),o.set(l,k),u.created>this.context.runEnd&&i.add(l),u.along||f.add(l)}for(let u of d)o.delete(u),i.delete(u);let c=new Set([...o.keys()].filter(u=>!f.has(u)));return{objects:o,after:i,along:c}}async holdingIn(t,e){let n=T(t.childSObject),o=T(t.field),[i]=H(e,e.length),a=new Set(["Id",o,...mt[n]?.ends??[],...t.personContacts?[Ue]:[]]),s=this.datesKept.get(n)??0;for(;s<He.length;){let d=He[s],f;try{f=await this.org.query(`SELECT ${[...a,...d].join(", ")} FROM ${n} WHERE ${o} IN (${i}) LIMIT ${Fe}`)}catch(R){Cr(R)?(s=Nr(R,s),this.datesKept.set(n,s)):s++;continue}if(f.records.length>=Fe){if(e.length>1){let R=Math.ceil(e.length/2);return zr(await this.holdingIn(t,e.slice(0,R)),await this.holdingIn(t,e.slice(R)))}return{holding:new Set(e.map(b)),automation:[],along:[],goes:[],unchecked:!1}}let c=new Set,u=[],l=[],g=[],m=new Map;for(let R of f.records){if(typeof R!="object"||R===null)continue;let y=R,w=y[t.field];if(typeof w!="string"||typeof y.Id!="string"||(n===wn&&o==="LinkedEntityId"&&this.noteFile(y),this.lockedUnder.get(b(y.Id))===b(w)))continue;let k={onlyIncluded:!1};if(!this.stays(y,n,t.restricted,t.personContacts,k)){if(k.onlyIncluded&&l.push({parent:b(w),key:b(y.Id)}),n!==wn&&this.goesAlongUnread(y)){let _=!(mt[n]?.cameWithRun(y,this.context.runRecords)===!0||t.personContacts===!0&&y[Ue]===!0)&&!k.onlyIncluded&&k.byRemoval!==!0&&this.context.goesWithParent?.(y,this.context.runEnd)!==!0;g.push({parent:b(w),id:y.Id,came:_})}continue}let I=this.mayBeAutomation(y);if(I){let P={parent:w,id:y.Id,object:n,along:!t.restricted,...I};u.push(P),t.restricted&&m.set(y.Id,P)}else c.add(b(w))}let h=await this.ofOtherParts(n,[...m.keys()]);for(let[R,y]of m)h.has(b(R))&&(u.splice(u.indexOf(y),1),c.add(b(y.parent)));return{holding:c,automation:u,along:l,goes:g,unchecked:!1}}return{holding:new Set,automation:[],along:[],goes:[],unchecked:!t.restricted}}goesAlongUnread(t){let e=b(t.Id),{runRecords:n,otherPartRecords:o,automationMade:i,goesWithParent:a,runEnd:s}=this.context;return this.context.alongAccepted!==!0&&!n.has(e)&&o?.has(e)!==!0&&i?.has(e)!==!0&&(this.context.goesWithParentReadBelow===!0||a?.(t,s)!==!0)}async ofOtherParts(t,e){let n=new Set,{otherPartRecords:o,otherPartObjects:i,runRecords:a}=this.context;if(e.length===0||!o||!i)return n;let s=this.cascadeEnds.get(t);s||(s=(async()=>{let c=new Set;for(let u of i)try{let l=ee.parse(await this.org.describe(u));for(let g of l.childRelationships??[])g.childSObject===t&&g.cascadeDelete===!0&&c.add(g.field)}catch{}return[...c]})(),this.cascadeEnds.set(t,s));let d=await s;if(d.length===0)return n;let f;try{f=await L(this.org,t,d,e)}catch{return n}for(let c of f){if(typeof c.Id!="string")continue;let u=d.flatMap(l=>{let g=c[l];return typeof g=="string"?[b(g)]:[]});u.some(l=>a.has(l))||u.some(l=>o.has(l))&&n.add(b(c.Id))}return n}mayBeAutomation(t){let{runRecords:e,runStart:n,runEnd:o,runUser:i,otherPartRecords:a}=this.context;if(typeof t.Id!="string"||e.has(b(t.Id))||a?.has(b(t.Id))===!0||typeof t.CreatedById!="string")return;let s=b(t.CreatedById);if(i!==void 0&&s!==i)return;let d=N(t.CreatedDate);if(!(d>=n-2e3&&d<=o+6e4))return;let f=N(t.LastModifiedDate),c=typeof t.LastModifiedById=="string"?b(t.LastModifiedById):void 0;if(!(f>o&&c!==void 0&&c!==s))return{created:d,creator:s}}async anyPointing(t){try{let e=T(t.childSObject),n=T(t.field);return(await this.org.query(`SELECT Id FROM ${e} WHERE ${n} != null LIMIT 1`)).records.length>0}catch{return!0}}noteFile(t){let e=t.LinkedEntityId,n=t.ContentDocumentId;if(typeof e!="string"||typeof n!="string"||ue(n,this.context.runRecords))return;let o=this.files.get(b(e))??new Set;o.add(n),this.files.set(b(e),o)}async filesOn(t){let e=new Map;for(let i of t){let a=this.files.get(b(i));a&&a.size>0&&e.set(b(i),[...a])}let n=[...new Set([...e.values()].flat())];if(n.length===0)return new Map;let o=new Map;try{for(let i of await L(this.org,Ar,["Title"],n))typeof i.Id=="string"&&typeof i.Title=="string"&&i.Title!==""&&o.set(b(i.Id),i.Title)}catch{}return new Map([...e].map(([i,a])=>[i,a.map(s=>({key:b(s),name:o.get(b(s))??s}))]))}async lockedPastDraft(t,e,n){for(let[o,i]of Object.entries(Ct)){let a=i.find(l=>l.object===t)?.lookup,s=me[o];if(!a||!s)continue;let d=await this.statusCategoriesOf(s);if(!d)continue;let f,c;try{f=await L(this.org,t,[a],e);let l=[...new Set(f.map(g=>g[a]).filter(g=>typeof g=="string"))];c=l.length>0?await L(this.org,o,["Status"],l):[]}catch{continue}let u=new Set(c.filter(l=>{let g=d.categoryOf.get(String(l.Status));return g!==void 0&&g!=="Draft"}).map(l=>b(String(l.Id))));for(let l of f){let g=l[a];typeof l.Id!="string"||typeof g!="string"||u.has(b(g))&&(this.hold(n,b(l.Id)),n.holders.add(o),this.lockedUnder.set(b(l.Id),b(g)))}}}statusCategoriesOf(t){let e=this.statuses.get(t);return e||(e=Pe(de(this.org),t),this.statuses.set(t,e)),e}async standardPricesHeld(t,e){try{let n=de(this.org),o=[...await pe(n,t)];if(o.length===0)return;let i=await this.priceKeyFields(),a=await L(this.org,X,i,o),s=await this.pricesOfProducts(a,i),d=s.flatMap(l=>typeof l.Id=="string"?[l.Id]:[]),f=new Set([...await pe(n,d)].map(b)),c=new Set(t.map(b)),u=new Set;for(let l of s){if(typeof l.Id!="string")continue;let g=b(l.Id);if(f.has(g))continue;(c.has(g)?e.held.has(g):this.stays(l,X,!0))&&u.add($e(l,i))}for(let l of a)typeof l.Id!="string"||!u.has($e(l,i))||(this.hold(e,b(l.Id)),e.holders.add(X))}catch{}}async sellingModelOptionsHeld(t,e){let n=[ge,Ge];try{let o=await L(this.org,Ye,n,t),i=await this.pricesOfProducts(o,[...n,"IsActive"]),a=new Set(i.filter(s=>typeof s.Id=="string"&&s.IsActive===!0&&this.stays(s,X,!0)).map(s=>$e(s,n)));for(let s of o)typeof s.Id!="string"||!a.has($e(s,n))||(this.hold(e,b(s.Id)),e.holders.add(X))}catch{}}async priceKeyFields(){let t=ee.parse(await this.org.describe(X)),e=new Set(t.fields.map(n=>n.name));return[ge,...[Ge,Nt].filter(n=>e.has(n))]}async pricesOfProducts(t,e){let n=[...new Set(t.map(a=>a[ge]).filter(a=>typeof a=="string"))],o=[...new Set(["Id",...e])].map(T).join(", "),i=[];for(let a of H(n,Wr)){let s=await this.org.query(`SELECT ${o} FROM ${X} WHERE ${ge} IN (${a}) LIMIT ${Fe}`);if(s.records.length>=Fe)throw new Error("More prices than one read takes.");for(let d of s.records)typeof d=="object"&&d!==null&&i.push(d)}return i}stays(t,e,n=!1,o=!1,i){let a=b(t.Id),{runRecords:s,reached:d,runStart:f,runEnd:c,removalStart:u,removalUser:l,earlierRemovals:g,includeChanged:m}=this.context;if(s.has(a))return d.has(a)||this.context.stays(a);if(n)return!0;if(this.context.automationMade?.has(a)===!0||this.context.goesWithParent?.(t,c)===!0||this.context.alongToDraft?.has(a)===!0||mt[e]?.cameWithRun(t,s))return!1;if(o&&t[Ue]===!0)return!(N(t.LastModifiedDate??t.SystemModstamp)<=c)&&!m;let h="CreatedDate"in t?"CreatedDate":"SystemModstamp"in t?"SystemModstamp":void 0;if(!h)return!0;let R=N(t[h]),y=N(h==="CreatedDate"?t.LastModifiedDate:t.SystemModstamp);if(!(R>=f))return!0;let w=this.context.linkedLater?.get(a);if(w&&(R<=c||R>=w.start)&&y<=w.end)return!1;let k=typeof t.CreatedById=="string"?b(t.CreatedById):void 0,I=(_,G)=>_!==void 0&&(_===l&&G>=u||g.some(K=>_===K.user&&G>=K.start&&G<=K.end));if(I(k,R))return i&&(i.byRemoval=!0),!1;if(y<=c)return!1;let P=typeof t.LastModifiedById=="string"?b(t.LastModifiedById):void 0;return R<=c&&I(P,y)?!1:(m&&i&&(i.onlyIncluded=!0),!m)}workedObjects(){return this.worked??=Lt(this.org),this.worked}};export{Ne as a,zt as b,$n as c,Hn as d,ee as e,Wn as f,to as g,no as h,ro as i,Kn as j,oo as k,Me as l,tt as m,Te as n,he as o,bo as p,it as q,tr as r,rr as s,Xt as t,tn as u,at as v,nn as w,rn as x,on as y,je as z,dt as A,ar as B,ct as C,Ao as D,sn as E,Rn as F,le as G,ur as H,pt as I,re as J,ts as K,ns as L,rs as M,os as N,ss as O,is as P,as as Q};
|
|
@@ -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-ZJW6YOMV.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as FakerFallback,b as generateByMethod};
|
|
@@ -4,6 +4,6 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{c as B}from"./chunk-BOGNK4LV.mjs";import{d as k,e as A,f as b}from"./chunk-
|
|
7
|
+
import{c as B}from"./chunk-BOGNK4LV.mjs";import{d as k,e as A,f as b}from"./chunk-LC3NDW4N.mjs";import{$b as D,ac as P,bc as O,gc as S,nc as v,rc as x,uc as L}from"./chunk-KB4ZHM4Q.mjs";import{da as w}from"./chunk-TNT27RBG.mjs";import{Qd as R,Rd as g,Yd as f,ee as p}from"./chunk-PMWAFDUB.mjs";var C=["undelete","insert","update","delete"],M={SingleEmail:{one:"single email",more:"single emails"},DailyWorkflowEmails:{one:"workflow email",more:"workflow emails"}};function U(e,t){let n=M[t];return`${e} ${e===1?n.one:n.more}`}var I={rewind:{what:"This rewind",then:"rewind again"},undo:{what:"This undo",then:"undo the rewind again"}};function _(e){return e.toGiveBack.records+e.toBringBack.inBin+e.toBringBack.withParent}var N="Order";function T(e){return e.toDelete.createdSince+e.toDelete.broughtBackSince+e.toDelete.comesBackWithParent+(e.toBringBack.carriers??0)}function $(e){return e.objectApiName===N?T(e):0}function W(e){return e.deleted+e.withParentDeleted+e.nextPassDeleted}function F(e){return e.objectApiName===N?W(e):0}function G(e){return w[e.objectApiName]!==void 0?e.toRecreate??0:0}function j(e){return w[e.objectApiName]!==void 0?e.recreated:0}function K(e){return e.flatMap(t=>h(t.objectApiName,{undelete:t.toBringBack.inBin+t.toBringBack.withParent+t.toBringBack.deletedWhileTaken+(t.toBringBack.carriers??0),insert:t.toRecreate??0,update:_(t)+G(t)+$(t),delete:T(t)}))}function Z(e){return e.flatMap(t=>h(t.objectApiName,{undelete:t.broughtBack+t.backWithParent+(t.carriers??0),insert:t.recreated,update:t.givenBackFirst+t.givenBackAfter+t.givenBackNextPass+j(t)+F(t),delete:W(t)}))}function ee(e,t=[],n=[]){let i=a=>{let o=new Map;for(let{objectApiName:m,count:d}of a)o.set(m,(o.get(m)??0)+d);return o},c=i(t),s=i(n);return[...new Set([...e.map(a=>a.objectApiName),...c.keys(),...s.keys()])].flatMap(a=>{let o=e.find(m=>m.objectApiName===a);return h(a,{undelete:o?.deleted??0,insert:0,update:(o?.givenBack??0)+(s.get(a)??0),delete:(o?.broughtBack??0)+(c.get(a)??0)})})}function h(e,t){return C.filter(n=>t[n]>0).map(n=>({objectApiName:e,write:n,records:t[n]}))}function te(e,t){let n=new Set(e.filter(i=>i.records>0).map(i=>`${i.objectApiName}
|
|
8
8
|
${i.write}`));return S(t,(i,c)=>n.has(`${i}
|
|
9
9
|
${c}`),"the org's")}function ne(e,t){return t===void 0?"":`The emails it sends as the ${e} writes were not counted against its daily limits, as what sends them was not read (${t}). `}function y(e){return typeof e.unread=="string"}function ie(e,t,n){let i=!y(n)&&D(n),c=!y(n)&&P(n),s=new Map;for(let r of C){let a=R(t,r);if(a.length===0)continue;let o=O(a,i,c),m=new Set(a.filter(d=>d.limit==="DailyWorkflowEmails").map(d=>d.objectApiName));for(let{objectApiName:d,records:E}of e.filter(l=>l.write===r))for(let l of o.filter(u=>u.objectApiName===d)){let u=s.get(l.limit)??{limit:l.limit,emails:0,objects:[],verdict:"fits"};u.emails+=E*l.perRecord,u.objects.push({objectApiName:d,write:r,records:E,perRecord:l.perRecord,sentBy:[...l.sentBy]}),i&&l.limit==="SingleEmail"&&m.has(d)&&(u.alertsCounted=!0),s.set(l.limit,u)}}return[...s.values()].map(r=>{if(y(n))return{...r,verdict:"unread",unread:n.unread};let a=n[r.limit];return a?{...r,verdict:r.emails>a.remaining?"exceeds":"fits",remaining:a.remaining,max:a.max}:{...r,verdict:"unread",unread:`the org's limits list no ${r.limit}`}})}function re(e,t,n){let i=t.filter(r=>r.verdict==="exceeds");if(i.length===0)return;let c=i.map(r=>`about ${U(r.emails,r.limit)}`+(r.alertsCounted?" (its email alerts among them, as a Developer Edition counts them)":"")+`, ${r.remaining??0} of ${r.max??0} left today`).join("; "),s=I[e];return{code:"EMAILS",message:`${s.what} would make ${n} send ${c}: past them, each record whose flow fails in the save is refused (CANNOT_EXECUTE_FLOW_TRIGGER), and the org's own emails stop for the rest of the day. Turn off what sends them, or assign the user a bypass that keeps it quiet, then ${s.then}. No record was written.`}}function ae(e){let t=f(e.steps),n=g(p(e.automation,e.plan,t),{writes:t}),i=v(e.automation.unread);return{senders:n,...i!==void 0?{sendersUnread:i}:{}}}function q(e){let t=e.mayMute&&e.plan===void 0&&e.senders.length>0?A(e.automation,{writes:f(e.steps)}):[],n=x({senders:e.senders,...e.sendersUnread!==void 0?{sendersUnread:e.sendersUnread}:{},...e.reading!==void 0?{reading:e.reading}:{},accepted:e.accepted,target:e.orgName,run:e.act,muteQuiets:t,keepsAddresses:!0});return n.stop?{gate:n,refusal:{code:"EMAILS_DELIVERED",message:n.stop.message}}:{gate:n}}async function se(e){let t=f(e.steps),n=await k({running:p(e.automation,e.plan,t),writes:t,read:e.read});return{ofRun:n,...q({...e,senders:n.senders,...n.sendersUnread!==void 0?{sendersUnread:n.sendersUnread}:{},...n.read!==void 0?{reading:n.read.reading}:{}})}}function oe(e){let t=f(e.steps),n=g(p(e.automation,b(e.plan,e.held),t),{writes:t}),i=L({planned:e.planned,held:n,...e.reading!==void 0?{reading:e.reading}:{},accepted:e.accepted,target:e.orgName,run:e.act});return i?{code:"EMAILS_DELIVERED",message:i.message}:void 0}var Q=", or run it again once the lease can assign them",V="--mute-automation keeps quiet";function de(e,t,n){if(e.code!=="EMAILS_DELIVERED")return e;let i=t==="undo"?"Tick the box for these emails in the undo's confirmation to undo all the same":e.message.includes(Q)?"Untick Mute automation to be asked about them and rewind all the same":`Tick "Let ${n} send these emails" in the preview to rewind all the same`;return{...e,message:B(e.message,t,i).replace(V,"Mute automation keeps quiet")}}export{U as a,_ as b,$ as c,F as d,G as e,j as f,K as g,Z as h,ee as i,te as j,ne as k,ie as l,re as m,ae as n,q as o,se as p,oe as q,de as r};
|
|
@@ -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,b,c}from"./chunk-2YHZBUZE.mjs";import"./chunk-2WFIVO4F.mjs";import"./chunk-7QYHEHMA.mjs";import"./chunk-WXDLQT2O.mjs";import"./chunk-NSQWI7ZY.mjs";import"./chunk-GNRSF65U.mjs";import"./chunk-O677VOGO.mjs";import"./chunk-JE6SCT6R.mjs";import"./chunk-PWRJRL5U.mjs";import"./chunk-24RFOFYT.mjs";import"./chunk-UIOMAX56.mjs";import"./chunk-QAFPQ3YB.mjs";import"./chunk-KJWFYBMU.mjs";import"./chunk-Z4LKKOFY.mjs";import"./chunk-2HVOZUM4.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-WB2RIVO3.mjs";import"./chunk-XGGOUNPP.mjs";import"./chunk-L53JWJ3S.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-OFTT7J2M.mjs";import"./chunk-HIDW7FNV.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-VINGECAJ.mjs";import"./chunk-H4CGM6YO.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-YDXMTWAT.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-PMN4PAC3.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-FP7CYB2F.mjs";import"./chunk-NED4MBIM.mjs";import"./chunk-UI3JQVRU.mjs";import"./chunk-KGU4SVIT.mjs";import"./chunk-JAEDM4SI.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-MSIEU5MR.mjs";import"./chunk-LC3NDW4N.mjs";import"./chunk-KB4ZHM4Q.mjs";import"./chunk-23SEDORH.mjs";import"./chunk-W6PN6TJG.mjs";import"./chunk-3Q353S2R.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-RHNTHGNU.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-Q7TLC3I2.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-D4GF4FAB.mjs";import"./chunk-CVHNXJH3.mjs";import"./chunk-YA6ATMTB.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-M6K34KGF.mjs";import"./chunk-TNT27RBG.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-S42RBRH2.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-WUUKFE2U.mjs";import"./chunk-EAC5QCE3.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as UNDO_AUTOMATION_LIFTED_BY,a as UndoStopped,c as undoCheckpoint};
|
|
@@ -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 Se,b as W,g as De,h as Pe,i as Ee,p as Te}from"./chunk-2WFIVO4F.mjs";import{a as Ae,c as L,d as je}from"./chunk-7QYHEHMA.mjs";import{b as Oe,e as Ce,i as ve,j as M,l as _}from"./chunk-WXDLQT2O.mjs";import{b as Re}from"./chunk-O677VOGO.mjs";import{g as F,j as le,l as G,m as ue,p as fe}from"./chunk-HIDW7FNV.mjs";import{B as ke,C as ye,D as he,w as ge,x as we,z as be}from"./chunk-VINGECAJ.mjs";import{j as pe}from"./chunk-FP7CYB2F.mjs";import{A as me,x as C}from"./chunk-KGU4SVIT.mjs";import{e as N}from"./chunk-JAEDM4SI.mjs";import{c as ae}from"./chunk-LC3NDW4N.mjs";import{m as de,n as ce}from"./chunk-KB4ZHM4Q.mjs";import{g as ne,h as oe,i as re,q as se}from"./chunk-M6K34KGF.mjs";import{b as ie}from"./chunk-CA5NAXSU.mjs";import{Yd as te}from"./chunk-PMWAFDUB.mjs";var Le="No record would be read or written.";function We(i,e){return{code:"RUN_WRITING",message:`${e.operation==="take"?`A checkpoint of ${i} is being taken`:e.operation==="rewind"?`A rewind is writing to ${i}`:e.operation==="undo"?`An undo is writing to ${i}`:e.operation==="empty"?`An emptying of its objects is writing to ${i}`:`SandForge is deleting checkpoints of ${i}`} (process ${e.pid} on ${e.host}): rewind once it has ended. ${Le}`}}function $e(i){return{query:e=>i.query(e),queryMore:e=>i.queryMore(e)}}function xe(i){let e=i.objects.find(r=>r.objectApiName===ne);if(e===void 0)return 0;let o=e.toBringBack;return o.inBin+o.withParent+o.deletedWhileTaken}function Ue(i,e){return{objectsRead:[...i],objects:[],unread:["flows","triggers","processes","workflowRules"].map(o=>({part:o,reason:e})),conditionsNotRead:0,conditionsBound:0,requests:0}}function ze(i,e){let o=new Map,r;return{bodies:o,global:()=>r,describeGlobal:()=>r??=i.describeGlobal(),reader:{lane:()=>e.lane(),tooling:n=>e.tooling(n),calls:()=>e.calls(),describe:async(n,a)=>{let p=await e.describe(n,a);return"body"in p&&o.set(n,p.body),p}}}}async function ct(i,e){let{org:o,signal:r}=i,{checkpoint:n,orgName:a}=e,p,k=await Re($e(o),{act:"preview",orgName:a,registered:e.registered,username:e.username,organizationId:n.org.organizationId,customSettings:se(n)},{userId:async()=>p=await o.userId()});if(!k.allowed)return{previewed:!1,refusal:k.refusal};let y=await ke(o,a),l=ze(o,pe(o,r)),Ie=await Oe({grants:k.grants,...p!==void 0?{userId:p}:{},username:e.username,checkpoint:n,reader:l.reader}),j=await o.serverTime(),h=me("pv",(i.now??(()=>new Date))()),d=await Ce({checkpoint:n,folder:e.folder,reader:l.reader,describeGlobal:l.describeGlobal,previewId:h,readAt:j,queryAllFiles:k.queryAllFiles,access:Ie,...r?{signal:r}:{}}),S=y.fileStorage;d.files!==void 0&&S!==void 0&&(d.files.storage.remaining=S.remaining*1048576),await Se(o,d,C(e.folder,h),n.takenAt);let m=e.objects!==void 0?new Set(e.objects):void 0,c=ve(d,m),R=Ae(c),$=m===void 0&&n.scope.mode==="picked"&&d.objects.some(t=>t.outside.length>0),Be=$&&e.acceptOutside===!1,w;if(m!==void 0||Be){w=await _({checkpoint:n,previewDir:C(e.folder,h),readAt:j,...m!==void 0?{objects:m}:{},acceptOutside:e.acceptOutside===!0,heldRows:M(n,e.folder),...r?{signal:r}:{}});for(let{objectApiName:t}of w.acts)R.includes(t)||R.push(t)}let s;if(R.length>0&&i.readAutomation)try{s=await i.readAutomation(R)}catch(t){s=Ue(R,ie(t))}let D,O=0,x=w?L(d,w):c,P=je(x),u=s&&e.muteAutomation===!0?de(s,te(P)):void 0,g=s&&u&&u.plan.assign.length>0&&i.mute?await Te(i.mute,s,P):void 0,Ne=g&&"refusal"in g?g.refusal:void 0,v=ce(g===void 0?u?.plan:"refusal"in g?g.plan:g.mute?.plan??u?.plan);if(s){let t=await fe({act:"rewind",orgName:a,automation:s,steps:P,...u?{plan:u.plan}:{},accepted:!1,mayMute:u===void 0,read:()=>ae(o)});D=t.gate.deliverability,O=t.ofRun.read?.requests??0}let U=l.global(),E=U?new Set((await N({describeGlobal:()=>U})).keys()):void 0,z=new Set(n.objects.map(({objectApiName:t})=>t.toLowerCase()));if(n.files!==void 0)for(let t of[oe,re])z.add(t.toLowerCase());let A=new Map;for(let[t,f]of l.bodies)A.set(t,ge(f,{inCheckpoint:z,...E?{worked:E}:{}}));let T=w!==void 0&&m!==void 0?{...c,withParentDeleted:w.acts.flatMap(({objectApiName:t,withParent:f})=>(f??0)>0?[{objectApiName:t,count:f??0}]:[])}:c,Fe=new Map((T.withParentDeleted??[]).map(({objectApiName:t,count:f})=>[t,f])),H=new Map;for(let t of T.objects){let f=t.toDelete.createdSince+t.toDelete.broughtBackSince-(Fe.get(t.objectApiName)??0),X=l.bodies.get(t.objectApiName),Z=A.get(t.objectApiName);if(f<=De||X===void 0||Z===void 0)continue;let Me=E??new Set((await N({describeGlobal:l.describeGlobal})).keys()),ee=await Pe(l.reader,we(X,Me),r);H.set(t.objectApiName,ee),A.set(t.objectApiName,{...Z,pointing:ee})}await Ee(C(e.folder,h),H);let K=be({objects:n.objects,diff:T,...m!==void 0?{readDiff:d}:{},automationRequests:s?.requests??0,...O>0?{deliverabilityRequests:O}:{},...v>0?{muteRequests:v}:{},...W(c)>0?{duplicateSets:W(c)}:{},relationships:A,...e.reusesPreview===!0?{reusesPreview:!0}:{}}),Ge={...K,apiRequestsLeft:y.remaining},J=F(x.objects),b=u?.automation??s,I=b?G(J,b,y.emails):[],V=b?le(J,b):void 0,Y=$&&e.acceptOutside===void 0&&b?G(F(L(d,await _({checkpoint:n,previewDir:C(e.folder,h),readAt:j,acceptOutside:!1,heldRows:M(n,e.folder),...r?{signal:r}:{}})).objects),b,y.emails):void 0,B=i.store.heldBy(n.org.organizationId),q=B===void 0?await i.runWriting?.(k.org.id):void 0,Q=B!==void 0?We(a,B):q!==void 0?{code:"RUN_WRITING",message:q}:Ne??ye("rewind",{run:K.apiRequests-O-v,deliverability:O,mute:v},y,a)??ue("rewind",I,a)??(c.files!==void 0?he("rewind",{files:xe(c),bytes:c.files.storage.bringBack},S?.remaining,a):void 0);return{previewed:!0,diff:d,...s?{automation:s}:{},...I.length>0?{emails:I}:{},...Y?{emailsKeepingOutside:Y}:{},...V!==void 0?{emailsUncounted:V}:{},...D?{deliverability:D}:{},estimate:Ge,...Q?{refusal:Q}:{}}}export{ct as a};
|
|
@@ -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{Ib as a}from"./chunk-PMWAFDUB.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};
|
|
@@ -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{m as a,n as b,o as c,p as d,q as e,r as f,s as g}from"./chunk-UX3BVH2Y.mjs";import"./chunk-GMY5427L.mjs";import"./chunk-TEIBWMJM.mjs";import"./chunk-BWWQXU2B.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-26POJDIT.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-CVHNXJH3.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-TNT27RBG.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-S42RBRH2.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-WUUKFE2U.mjs";import"./chunk-EAC5QCE3.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as DataSync,f as MAX_RESULT_REFUSALS_PER_OBJECT,g as buildObjectResult,d as linkedRecordOf,c as notReachedOf,b as unsetOf,e as withCurrencies};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{p as g}from"./chunk-PMN4PAC3.mjs";import{b as o,e as c,k as u,l as d,u as l}from"./chunk-WZQEK4WT.mjs";import{appendFile as h,mkdir as m,readFile as w,writeFile as S}from"node:fs/promises";import{dirname as f,join as y}from"node:path";var D="seed-runs-dropped.ndjson",R=50,v={readFile:e=>w(e,"utf8"),appendFile:async(e,t)=>{await m(f(e),{recursive:!0}),await h(e,t,"utf8")},writeFile:async(e,t)=>{await m(f(e),{recursive:!0}),await S(e,t,"utf8")}},F=d({runId:o().min(1),targetOrgId:o().min(1),origin:l(["csv","clone"]).optional(),startedAt:o().min(1),droppedAt:o().min(1),left:u(d({objectApiName:o().min(1),count:c().int().nonnegative()}))});function P(e,t){return{runId:e.runId,targetOrgId:e.targetOrgId,...e.origin?{origin:e.origin}:{},startedAt:e.startedAt,droppedAt:t,left:g(e).map(({objectApiName:i,ids:n})=>({objectApiName:i,count:n.length}))}}var p=class{constructor(t,i=v,n=R){this.file=t;this.files=i;this.kept=n}file;files;kept;writes=Promise.resolve();note(t,i=new Date().toISOString()){let n=P(t,i);return this.writes=this.writes.then(()=>this.append(n)).catch(()=>{}),this.writes}async find(t){return await this.writes,(await this.read()).reverse().find(i=>i.runId===t)}async read(){let t;try{t=await this.files.readFile(this.file)}catch{return[]}let i=[];for(let n of t.split(`
|
|
8
|
+
`)){if(n.trim()==="")continue;let r;try{r=JSON.parse(n)}catch{continue}let s=F.safeParse(r);s.success&&i.push(s.data)}return i}async append(t){let i=await this.read();if(i.length<this.kept){await this.files.appendFile(this.file,`${JSON.stringify(t)}
|
|
9
|
+
`);return}let n=[...i.slice(i.length-this.kept+1),t];await this.files.writeFile(this.file,n.map(r=>`${JSON.stringify(r)}
|
|
10
|
+
`).join(""))}};function I(e){return new p(y(e,D))}function $(e,t){let i=e.left.reduce((r,{count:s})=>r+s,0),n=e.left.map(({objectApiName:r})=>r).join(", ");return`Nothing this run created is kept: it was dropped on ${e.droppedAt} to keep the runs kept on this machine within their bound, ${i} of its records still in its org${n?` (${n})`:""}. ${t} lists, deleting nothing, every record you created there since the day the run started, its records among them; the same line without --dry-run deletes what it counted.`}function E(e,t,i){let n=new Date(e.startedAt).toISOString().slice(0,10),r=e.left.map(({objectApiName:a})=>a),s=Math.max(1,...e.left.map(({count:a})=>a));return[t,`--target ${i}`,`--since ${n}`,...r.length>0?[`--objects ${r.join(",")}`,`--max ${s}`]:[],"--dry-run"].join(" ")}export{I as a,$ as b,E as c};
|