sandforge 1.81.0 → 1.82.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 +48 -0
- package/bin/sandforge-users.mjs +12 -0
- package/lib/{chunk-C4YGSK6W.mjs → chunk-27Z76O2O.mjs} +1 -1
- package/lib/{chunk-TKQQVB2D.mjs → chunk-2JZGCCPG.mjs} +1 -1
- package/lib/{chunk-TPHXRHOA.mjs → chunk-2UU42PTD.mjs} +1 -1
- package/lib/{chunk-ZWZXQTAK.mjs → chunk-32EUNQT6.mjs} +14 -14
- package/lib/{chunk-HYOOJVR6.mjs → chunk-3C2ZZIFN.mjs} +1 -1
- package/lib/{chunk-AELFEK3G.mjs → chunk-3CX7GPCR.mjs} +1 -1
- package/lib/{chunk-YJEXE6HZ.mjs → chunk-3HEMJTAP.mjs} +2 -2
- package/lib/{chunk-DQR5NDMI.mjs → chunk-3HROD5RE.mjs} +1 -1
- package/lib/{chunk-D7P7DTWL.mjs → chunk-3MGMNK3Q.mjs} +1 -1
- package/lib/{chunk-MNITSYI2.mjs → chunk-3SKLBRPL.mjs} +1 -1
- package/lib/{chunk-MAHZMPMZ.mjs → chunk-3XG25GTF.mjs} +1 -1
- package/lib/{chunk-N7J6NJQ6.mjs → chunk-42BFLWHR.mjs} +1 -1
- package/lib/chunk-466F37VD.mjs +7 -0
- package/lib/chunk-47UHTN3Q.mjs +7 -0
- package/lib/{chunk-DHGPDSXS.mjs → chunk-52EXDVPN.mjs} +1 -1
- package/lib/{chunk-5344TZBT.mjs → chunk-5K2I2DMP.mjs} +1 -1
- package/lib/{chunk-2OZG6GRW.mjs → chunk-6GQUZ4IP.mjs} +1 -1
- package/lib/{chunk-SW2NUKQL.mjs → chunk-6KP6WETK.mjs} +1 -1
- package/lib/{chunk-FSZTXLNW.mjs → chunk-6VSZNZHH.mjs} +1 -1
- package/lib/{chunk-6NADW3OI.mjs → chunk-7CVDVBEE.mjs} +1 -1
- package/lib/{chunk-67CC7RAE.mjs → chunk-7EYQYZJP.mjs} +1 -1
- package/lib/{chunk-IBURU7T7.mjs → chunk-7LKI7OAS.mjs} +1 -1
- package/lib/{chunk-CULAOP3U.mjs → chunk-7PY3VQP3.mjs} +1 -1
- package/lib/chunk-7SDZR6SR.mjs +7 -0
- package/lib/{chunk-V4RKM4QZ.mjs → chunk-7WSLT5VX.mjs} +1 -1
- package/lib/chunk-A32ISQ6M.mjs +28 -0
- package/lib/{chunk-K77NR3UK.mjs → chunk-A65ADTCR.mjs} +1 -1
- package/lib/chunk-A7JJWOLT.mjs +7 -0
- package/lib/{chunk-MWLFFVQV.mjs → chunk-AUS6NFLZ.mjs} +1 -1
- package/lib/{chunk-NWPQF5XR.mjs → chunk-BMTNTBBM.mjs} +1 -1
- package/lib/{chunk-FTA5LOVX.mjs → chunk-BN33LVPQ.mjs} +1 -1
- package/lib/chunk-BNKT3R3F.mjs +7 -0
- package/lib/{chunk-WM5JI4JI.mjs → chunk-C2N2TNEU.mjs} +1 -1
- package/lib/{chunk-5UT2ZBGF.mjs → chunk-C3LNYAVJ.mjs} +1 -1
- package/lib/{chunk-GYKNCYES.mjs → chunk-CBL42DUU.mjs} +1 -1
- package/lib/{chunk-W2AAGIZF.mjs → chunk-CCEH7L53.mjs} +1 -1
- package/lib/{chunk-WWTXRWNZ.mjs → chunk-CELEBWEZ.mjs} +1 -1
- package/lib/{chunk-D62KWDDT.mjs → chunk-CV47FDQW.mjs} +1 -1
- package/lib/{chunk-AJPSGVMD.mjs → chunk-CZLJZQCS.mjs} +1 -1
- package/lib/{chunk-YIGFYZQY.mjs → chunk-DBBPDSFN.mjs} +1 -1
- package/lib/{chunk-T5VAULLQ.mjs → chunk-DIL62SUN.mjs} +1 -1
- package/lib/chunk-DIS254AN.mjs +7 -0
- package/lib/{chunk-GK7VEYFM.mjs → chunk-DJCGURW7.mjs} +1 -1
- package/lib/{chunk-MHW6DV6T.mjs → chunk-DT3T7FRD.mjs} +1 -1
- package/lib/{chunk-PYUEHBA6.mjs → chunk-DWMRIWV5.mjs} +1 -1
- package/lib/{chunk-E2OBAWSH.mjs → chunk-EEFUE2ES.mjs} +1 -1
- package/lib/{chunk-MKNAZPOT.mjs → chunk-EOFO3PHS.mjs} +1 -1
- package/lib/{chunk-UUSLTW5V.mjs → chunk-FA4ZKDCU.mjs} +1 -1
- package/lib/{chunk-DHIW4IO5.mjs → chunk-FKK5YBGZ.mjs} +1 -1
- package/lib/{chunk-BZFIOZS3.mjs → chunk-FOIWWK7G.mjs} +1 -1
- package/lib/chunk-FZF23M6R.mjs +7 -0
- package/lib/{chunk-XIZ5LMQM.mjs → chunk-G2JR3F63.mjs} +1 -1
- package/lib/{chunk-2Z54GB6X.mjs → chunk-GBGHJTPC.mjs} +1 -1
- package/lib/{chunk-2NAIUKVL.mjs → chunk-GCGHHN4K.mjs} +1 -1
- package/lib/{chunk-TQM2XJ27.mjs → chunk-GGNUACTY.mjs} +1 -1
- package/lib/{chunk-2IB7I3IQ.mjs → chunk-GGUOIDWP.mjs} +1 -1
- package/lib/chunk-GHPR5UVV.mjs +7 -0
- package/lib/{chunk-YHIOS2PU.mjs → chunk-GJ6SZVHT.mjs} +1 -1
- package/lib/{chunk-WI4HYWV6.mjs → chunk-H4JUYUSL.mjs} +1 -1
- package/lib/{chunk-5WGA5CZB.mjs → chunk-H4OBZIX3.mjs} +1 -1
- package/lib/{chunk-KRNFVAGC.mjs → chunk-HFUDCNU5.mjs} +1 -1
- package/lib/{chunk-OIIL4NVI.mjs → chunk-HIHCYMSL.mjs} +1 -1
- package/lib/chunk-HKUWHVI7.mjs +9 -0
- package/lib/chunk-HQQVANWQ.mjs +20 -0
- package/lib/{chunk-V2QO6KOE.mjs → chunk-IRZJU2PG.mjs} +14 -11
- package/lib/{chunk-CAFUNR6D.mjs → chunk-ISSP2FZ5.mjs} +1 -1
- package/lib/{chunk-OEHVAJAB.mjs → chunk-IVZJSDJD.mjs} +1 -1
- package/lib/{chunk-E2YJVSX6.mjs → chunk-J24TIGSI.mjs} +1 -1
- package/lib/{chunk-YCSFP6ER.mjs → chunk-JESRFE2Z.mjs} +1 -1
- package/lib/{chunk-KOQV4WXC.mjs → chunk-JFNLKHY6.mjs} +2 -2
- package/lib/{chunk-NJ3EOEHS.mjs → chunk-JH27IKCO.mjs} +1 -1
- package/lib/{chunk-DXOXLUZA.mjs → chunk-JJITOWZK.mjs} +1 -1
- package/lib/{chunk-KNIRA333.mjs → chunk-JKT5YAQ2.mjs} +1 -1
- package/lib/{chunk-J6G23RUI.mjs → chunk-JLZRZL5E.mjs} +1 -1
- package/lib/{chunk-6FMLW7PH.mjs → chunk-JPEVIXNH.mjs} +1 -1
- package/lib/{chunk-6IGEASOF.mjs → chunk-JQZTMFO7.mjs} +1 -1
- package/lib/{chunk-55LQD3Y3.mjs → chunk-KIMQQ6JQ.mjs} +1 -1
- package/lib/{chunk-EH5YUA5W.mjs → chunk-KJYEQHYP.mjs} +1 -1
- package/lib/chunk-KKOA62S4.mjs +474 -0
- package/lib/{chunk-56MPPWLA.mjs → chunk-KP5G6FUC.mjs} +1 -1
- package/lib/{chunk-EAFLDSQ2.mjs → chunk-L4INJ5TZ.mjs} +1 -1
- package/lib/{chunk-MO3N5XVV.mjs → chunk-LAUOSXMN.mjs} +2 -2
- package/lib/{chunk-HVC5CYIB.mjs → chunk-LHU6CPGE.mjs} +1 -1
- package/lib/{chunk-7PK5QDQI.mjs → chunk-LXDSRP2W.mjs} +1 -1
- package/lib/{chunk-YOGMP72T.mjs → chunk-MKTXJCXN.mjs} +1 -1
- package/lib/{chunk-VSU74RQ3.mjs → chunk-MUEQRIK7.mjs} +1 -1
- package/lib/{chunk-UCHAZ4ZU.mjs → chunk-NLB3RGIY.mjs} +1 -1
- package/lib/{chunk-OVOLG3AL.mjs → chunk-NWOI25WY.mjs} +1 -1
- package/lib/{chunk-6SEDOIO3.mjs → chunk-O2PUGRNW.mjs} +1 -1
- package/lib/chunk-O4BROUGM.mjs +7 -0
- package/lib/{chunk-KGYXLSQ5.mjs → chunk-P55MKIZX.mjs} +1 -1
- package/lib/{chunk-KE2PGD6C.mjs → chunk-P63WJMXQ.mjs} +1 -1
- package/lib/chunk-PBE44M2Y.mjs +7 -0
- package/lib/{chunk-OMZJ37JI.mjs → chunk-PE435FVH.mjs} +2 -2
- package/lib/{chunk-GR3NGDVM.mjs → chunk-PPHVWUFY.mjs} +1 -1
- package/lib/{chunk-ZUA5BNAO.mjs → chunk-PR74GYVI.mjs} +1 -1
- package/lib/{chunk-43K2C6H2.mjs → chunk-PWVDNN2C.mjs} +1 -1
- package/lib/{chunk-DMBR24CK.mjs → chunk-PYRZFUVU.mjs} +1 -1
- package/lib/{chunk-OXKZ4Y3B.mjs → chunk-Q3DY7TO2.mjs} +1 -1
- package/lib/{chunk-EOSEMFPU.mjs → chunk-Q6SXNKV2.mjs} +1 -1
- package/lib/chunk-QAPVKPEC.mjs +7 -0
- package/lib/chunk-QROPNEGY.mjs +14 -0
- package/lib/{chunk-6CDIIFNX.mjs → chunk-RCYEBY42.mjs} +1 -1
- package/lib/chunk-RLWB7F26.mjs +7 -0
- package/lib/{chunk-X2ZVSQ54.mjs → chunk-RTWYLOCA.mjs} +1 -1
- package/lib/chunk-RYRMUPMY.mjs +7 -0
- package/lib/{chunk-ETT5GP4P.mjs → chunk-SAMWHL22.mjs} +1 -1
- package/lib/{chunk-LO527YLT.mjs → chunk-SFGZFB4F.mjs} +1 -1
- package/lib/{chunk-33ZX3A56.mjs → chunk-SNEOKYV7.mjs} +1 -1
- package/lib/{chunk-GTIXJCGS.mjs → chunk-STRMWSIQ.mjs} +1 -1
- package/lib/{chunk-OQQHNYR7.mjs → chunk-SZGGFST2.mjs} +2 -2
- package/lib/{chunk-OU5W7SCB.mjs → chunk-T7WREYA5.mjs} +1 -1
- package/lib/{chunk-FLNLG43R.mjs → chunk-TCBAE65A.mjs} +1 -1
- package/lib/{chunk-RKALOKAU.mjs → chunk-TMA34QMA.mjs} +1 -1
- package/lib/{chunk-WEZLXE34.mjs → chunk-TWV4A5RK.mjs} +1 -1
- package/lib/{chunk-ONMBSACW.mjs → chunk-UHFLKP26.mjs} +1 -1
- package/lib/chunk-UV74P4H2.mjs +7 -0
- package/lib/{chunk-HYBH5PFM.mjs → chunk-V3R45ZWT.mjs} +1 -1
- package/lib/{chunk-BNO5GIJ6.mjs → chunk-VPDEJGPS.mjs} +1 -1
- package/lib/{chunk-3AOKLIVE.mjs → chunk-VQJMP3DC.mjs} +1 -1
- package/lib/{chunk-742SSN7I.mjs → chunk-VYOYXTCU.mjs} +1 -1
- package/lib/{chunk-GWRKS3AL.mjs → chunk-VZT4E2OJ.mjs} +1 -1
- package/lib/{chunk-2OIRJEYE.mjs → chunk-VZVICK7Q.mjs} +1 -1
- package/lib/chunk-WEMLDUQA.mjs +7 -0
- package/lib/{chunk-FDGFUEK3.mjs → chunk-WOOUISSO.mjs} +1 -1
- package/lib/{chunk-UIUPPEFB.mjs → chunk-WSUKC2U3.mjs} +1 -1
- package/lib/{chunk-XC2QKQT5.mjs → chunk-WT3SCUHS.mjs} +1 -1
- package/lib/{chunk-UT27HXE7.mjs → chunk-XFU3HRUV.mjs} +1 -1
- package/lib/{chunk-5VQNKDFU.mjs → chunk-XK5W7BVE.mjs} +1 -1
- package/lib/{chunk-OZNLOV4U.mjs → chunk-XO5FBOQF.mjs} +1 -1
- package/lib/{chunk-FSDO4DJA.mjs → chunk-XSKPYGMT.mjs} +1 -1
- package/lib/{chunk-AITNZWLB.mjs → chunk-XU25YA46.mjs} +1 -1
- package/lib/{chunk-XEB6HZ34.mjs → chunk-XZISAZA6.mjs} +1 -1
- package/lib/chunk-Y4TDVDP2.mjs +13 -0
- package/lib/{chunk-4L7FBOJS.mjs → chunk-YAIIRFKJ.mjs} +1 -1
- package/lib/{chunk-T3PLRQ2T.mjs → chunk-YAJQS3OL.mjs} +1 -1
- package/lib/{chunk-Y5ZCPY36.mjs → chunk-YGJF55VJ.mjs} +1 -1
- package/lib/chunk-YH4DYI6D.mjs +7 -0
- package/lib/{chunk-R6TF26V4.mjs → chunk-YMDFF657.mjs} +1 -1
- package/lib/{chunk-JU2XEKEO.mjs → chunk-YT22LMF7.mjs} +1 -1
- package/lib/{chunk-NWVVCZUK.mjs → chunk-Z42PHCVZ.mjs} +1 -1
- package/lib/{chunk-O6ADMP36.mjs → chunk-ZHIZY3ZC.mjs} +1 -1
- package/lib/chunk-ZQO5PDX5.mjs +48 -0
- package/lib/{chunk-QXLZINZB.mjs → chunk-ZUBBEP75.mjs} +1 -1
- package/lib/{chunk-SQGP46QS.mjs → chunk-ZUOPC4W2.mjs} +1 -1
- package/lib/{chunk-3B5H24ZG.mjs → chunk-ZUTUYBNW.mjs} +1 -1
- package/lib/{chunk-K55LH4ZQ.mjs → chunk-ZXFL2MSN.mjs} +1 -1
- package/lib/sandforge-autopilot.mjs +1 -1
- 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 +1 -1
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +1 -1
- package/lib/sandforge-env.mjs +185 -139
- package/lib/sandforge-frozen.mjs +1 -1
- package/lib/sandforge-mcp.mjs +14 -14
- 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 +157 -0
- package/lib/sandforge.mjs +1 -22
- package/lib/sf/sandforge/autopilot.mjs +20 -0
- package/lib/sf/sandforge/backup.mjs +20 -0
- package/lib/sf/sandforge/checkpoint.mjs +20 -0
- package/lib/sf/sandforge/cleanup.mjs +20 -0
- package/lib/sf/sandforge/clone.mjs +20 -0
- package/lib/sf/sandforge/compare.mjs +20 -0
- package/lib/sf/sandforge/dataops.mjs +20 -0
- package/lib/sf/sandforge/empty.mjs +20 -0
- package/lib/sf/sandforge/env.mjs +20 -0
- package/lib/sf/sandforge/frozen.mjs +20 -0
- package/lib/sf/sandforge/hardis-commands.mjs +20 -0
- package/lib/sf/sandforge/index.mjs +20 -0
- package/lib/sf/sandforge/mcp.mjs +20 -0
- package/lib/sf/sandforge/monitor.mjs +20 -0
- package/lib/sf/sandforge/pipeline.mjs +20 -0
- package/lib/sf/sandforge/seed.mjs +20 -0
- package/lib/sf/sandforge/sync.mjs +20 -0
- package/lib/sf/sandforge/users.mjs +20 -0
- package/lib/sfHelpHook.mjs +7 -0
- package/lib/sfPlugin.mjs +11 -0
- package/oclif.manifest.json +1 -0
- package/package.json +17 -3
- package/lib/chunk-2ZMGVBLW.mjs +0 -7
- package/lib/chunk-5C5XEVZN.mjs +0 -11
- package/lib/chunk-5CKWGZX4.mjs +0 -9
- package/lib/chunk-5ZKCLBTN.mjs +0 -474
- package/lib/chunk-7DALDJMO.mjs +0 -7
- package/lib/chunk-DPYTG6DM.mjs +0 -48
- package/lib/chunk-G4VXPS3A.mjs +0 -7
- package/lib/chunk-GF247DA7.mjs +0 -7
- package/lib/chunk-IKGHRYCN.mjs +0 -7
- package/lib/chunk-IM2XA6JI.mjs +0 -7
- package/lib/chunk-K5HV4YRO.mjs +0 -7
- package/lib/chunk-N6HHNR6J.mjs +0 -7
- package/lib/chunk-O7DAFE6M.mjs +0 -14
- package/lib/chunk-R2BJWO5N.mjs +0 -20
- package/lib/chunk-T26C576X.mjs +0 -9
- package/lib/chunk-V473C7LY.mjs +0 -7
- package/lib/chunk-WD47PGUS.mjs +0 -10
- package/lib/chunk-XC54KKKC.mjs +0 -7
- package/lib/chunk-XGKSSCW7.mjs +0 -7
- package/lib/chunk-ZWCRWF7E.mjs +0 -7
|
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{
|
|
7
|
+
import{C as ts,r as Jo}from"./chunk-O2PUGRNW.mjs";import{A as hn,B as wn,H as ce,I as No,J as St,R as Eo,e as yt,m as So,v as Ao,w as ko,x as Io}from"./chunk-7SDZR6SR.mjs";import{e as ps,h as ms}from"./chunk-TEIBWMJM.mjs";import{a as Fo,b as Po}from"./chunk-T63U4OZJ.mjs";import{a as et,d as Xo,i as es,o as Ne}from"./chunk-YAIIRFKJ.mjs";import{a as vo}from"./chunk-YYZL7UGV.mjs";import{a as ho,l as Ro}from"./chunk-54HYHHVL.mjs";import{d as To}from"./chunk-QIRO4HTE.mjs";import{b as jo}from"./chunk-QSRAEUGZ.mjs";import{d as gs}from"./chunk-JH27IKCO.mjs";import{t as Oe}from"./chunk-SAMWHL22.mjs";import{a as Mo,c as Lo,d as At,e as je,f as _o,g as Do,h as kt,i as Bo,j as $o,k as Wo,l as qo,m as zo,n as Uo,o as se,p as ie,q as It,r as we,s as Vo}from"./chunk-4JKR4PTZ.mjs";import{d as yn,z as Go}from"./chunk-J24TIGSI.mjs";import{a as mo,b as Me,c as go,d as X,h as pe}from"./chunk-VPDEJGPS.mjs";import{a as po}from"./chunk-5LFSFYFJ.mjs";import{Db as is,Eb as as,J as Zo,K as Sn,L as Qo,Pa as Ee,Qa as ns,Ra as ye,ab as Te,db as rs,eb as os,f as to,oc as ds,pc as cs,uc as ls,vc as us,wc as fs,xc as me,zb as ss}from"./chunk-JFNLKHY6.mjs";import{b as Ot}from"./chunk-VV3B6IC3.mjs";import{f as Et}from"./chunk-7PY3VQP3.mjs";import{a as no,b as ro,c as fn,e as oo,f as so,g as io,i as pn,j as ao}from"./chunk-INIT2UKJ.mjs";import{a as bo,c as gn,j as Oo}from"./chunk-HFUDCNU5.mjs";import{f as uo,g as fo}from"./chunk-XZISAZA6.mjs";import{a as q,b as le,c as jt,d as bn,e as Ho,f as Nt,g as Ko,h as Rn,i as Yo}from"./chunk-TQ2TQHTT.mjs";import{g as lo}from"./chunk-OHEOJISY.mjs";import{a as Co,b as xo}from"./chunk-PC247GKX.mjs";import{c as co}from"./chunk-EADHKH3A.mjs";import{b as Xr,r as eo}from"./chunk-L4INJ5TZ.mjs";import{A as Wr,B as ln,C as qr,F as zr,G as un,J as Ur,K as Vr,O as Gr,R as Jr,S as Hr,T as Kr,U as Yr,V as Zr,W as Qr,e as cn,q as de,r as oe,s as xe,x as Br,y as $r}from"./chunk-KIMQQ6JQ.mjs";import{a as Ce,h as J}from"./chunk-TZE3Y7IQ.mjs";import{a as wt,b as H}from"./chunk-CA5NAXSU.mjs";import{a as bt,c as mn,f as wo,i as Rt,k as yo}from"./chunk-ZUTUYBNW.mjs";import{Aa as Tr,Ba as Fr,Ca as Pr,Cc as ht,O as Ze,T as sn,Uc as Se,Ya as vr,_ as an,fc as Cr,hd as Lr,lc as xr,mc as Mr,nc as Qe,oc as pt,rc as Xe,sc as dn,tc as mt,td as _r,ua as Re,ud as Dr,va as Er,yc as ve,zc as gt}from"./chunk-ZQO5PDX5.mjs";import{b as W,e as te,f as Ke,i as Ie,k as Z,l as V,m as rn,r as Nr,s as on,u as Pe,v as Ye}from"./chunk-WZQEK4WT.mjs";var Le=.5;function xu(n){return`Salesforce can take several minutes to count a load in what ${n} says it has left: a run started sooner after another may read room it no longer has`}function ws(n){if("unread"in n.storage)return n.withinMB===void 0?{unread:n.storage.unread}:hs(n,Math.floor(Math.max(0,n.withinMB)*1048576),{share:Ee,roundingMB:Le,withinMB:n.withinMB,limitedBy:"within"});let{remainingMB:e,maxMB:t}=n.storage,r=Ee*Math.max(0,e-Le)*1048576,o=n.withinMB!==void 0?Math.max(0,n.withinMB)*1048576:1/0,s=o<r?"within":"storage",i={remainingMB:e,maxMB:t,share:Ee,roundingMB:Le,...n.withinMB!==void 0?{withinMB:n.withinMB}:{},limitedBy:s},a=Math.floor(Math.min(r,o));return hs(n,a,i)}function ys(n,e){return e.bytesLimit==="within"&&e.storageBytes!==void 0&&n>e.storageBytes?"storage":e.bytesLimit}function hs(n,e,t){if(!n.api)return{bytes:e,terms:t};if("unread"in n.api)return{bytes:e,terms:t,requestsUnread:n.api.unread};let r=Object.values(n.otherRequests??{}).reduce((s,i)=>s+Math.max(0,i??0),0),o=Math.max(0,Math.floor(n.api.remaining-Te*n.api.max-r));return{bytes:e,terms:t,runRequests:o}}var wa=/__e$/i,ya=/Share$/;function Mu(n,e){let t=new Map,r=new Map,o=(i,a)=>{let d=`${i}
|
|
8
8
|
${a}`,c=t.get(d);return c||(c={objectApiName:i,act:a,bytes:0,creates:[]},t.set(d,c)),c},s=i=>{r.set(`${i.objectApiName}
|
|
9
9
|
${i.kind}
|
|
10
10
|
${i.name}`,i)};for(let i of n.firing){let a=i.write;if(!(a!=="insert"&&a!=="update")&&e(i.objectApiName,a)){if(i.kind==="trigger"||!i.flow){s({objectApiName:i.objectApiName,kind:"trigger",name:i.name});continue}if(i.flow.condition!=="read"){s({objectApiName:i.objectApiName,kind:"notRead",name:i.name});continue}for(let d of i.flow.creates??[]){if(wa.test(d))continue;if(ya.test(d)){s({objectApiName:i.objectApiName,kind:"share",name:d});continue}let c=o(i.objectApiName,a);c.bytes+=ye(d,{rows:1}),c.creates.push({objectApiName:d,by:i.name})}}}return{perRecord:[...t.values()].filter(i=>i.bytes>0),notCounted:[...r.values()]}}function Lu(n,e){return n.perRecord.reduce((t,r)=>t+r.bytes*Math.max(0,e(r.objectApiName,r.act)),0)}function _u(n,e,t){return{budgetMB:Math.max(0,n.bytes-e)/1048576,...n.terms,automationMB:e/1048576,...t.notCounted.length>0?{notCounted:t.notCounted.map(r=>({...r}))}:{}}}function bs(n,e){if(!e(1))return 0;if(e(n))return n;let t=1,r=n;for(;r-t>1;){let o=Math.floor((t+r)/2);e(o)?t=o:r=o}return t}function Du(n,e){let t=Math.max(0,Math.floor(n)),r=Math.min(t,Math.max(0,Math.floor(e))),o=[];if(r===0)return o;for(let s=0;s<t;s++)Math.floor((s+1)*r/t)>Math.floor(s*r/t)&&o.push(s);return o}import{existsSync as ba,readFileSync as Ra,writeFileSync as Sa}from"node:fs";function qu(n){let e={getData:()=>ba(n)?JSON.parse(Ra(n,"utf8")):{},setData:r=>Sa(n,JSON.stringify(r,null,2),{encoding:"utf8",mode:384})},t=new ts(e);return t.initialize(),t}var On="User",Oa="005",Ss=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function Aa(n,e,t=Xr){let r=n.referenceTo??[];return n.name==="RecordTypeId"||r.length===0?!1:r.every(o=>t(o))?!0:r.length===1&&e?.(r[0])===!0}var Rs=1e5;async function Ju(n){let{known:e,ownerMappings:t={},mapped:r,refused:o,inactive:s}=n,i=n.lookups.filter(m=>Aa(m,n.outsideTheRun,n.neverCopied)),a=new Map,d=new Set;for(let m of i)for(let h of n.rows){let w=h[m.name];if(typeof w!="string"||!Ss.test(w)||m.name==="OwnerId"&&t[w]!==void 0||r?.(w)===!0||(d.add(w),e.has(w)))continue;let y=m.referenceTo??[];if(!y.some(R=>o?.has(R)===!0))for(let R of y)a.set(R,(a.get(R)??new Set).add(w))}let c=new Set,f=new Set,u=new Set;for(let[m,h]of a){let w=s!==void 0&&m===On,y=w?"Id, IsActive":"Id";for(let R of X([...h]))try{let O=await n.query(`SELECT ${y} FROM ${J(m)} WHERE Id IN (${R})`);for(let g of O){let b=g.Id;typeof b=="string"&&(c.add(b),c.add(b.slice(0,15)),w&&g.IsActive===!1&&(u.add(b),u.add(b.slice(0,15))))}}catch{for(let O of h)f.add(O);o?.add(m);break}}let p=new Map;for(let m of a.values())for(let h of m)c.has(h)||c.has(h.slice(0,15))?p.set(h,!0):!f.has(h)&&!p.has(h)&&p.set(h,!1);for(let[m,h]of p){if(e.size>=Rs)break;e.set(m,h)}if(s&&u.size>0){let m=[...a.get(On)??[]].filter(h=>u.has(h)||u.has(h.slice(0,15)));for(let h of[...u,...m]){if(s.size>=Rs)break;s.add(h)}}let l=new Set;for(let m of d)(p.get(m)??e.get(m))===!1&&l.add(m);return l}function Hu(n,e,t={}){let r=new Set;if(e.size===0)return r;for(let o of n){let s=o.OwnerId;typeof s!="string"||!s||t[s]===void 0&&e.has(s)&&r.add(s)}return r}var ka="SELECT PermissionsUpdateWithInactiveOwner FROM UserPermissionAccess";async function Ia(n){try{let[e]=await n(ka);return e?.PermissionsUpdateWithInactiveOwner===!0}catch{return!1}}function Ku(n){let e;return()=>(e??=Ia(n),e)}async function Os(n,e){let t=new Map;for(let[i,a]of Object.entries(n)){if(!Ss.test(a))continue;let d=a.slice(0,15),c=t.get(d)??{user:a,sources:[]};c.sources.push(i),t.set(d,c)}let r=[],o=[],s=[...t.values()];for(let i=0;i<s.length;i+=Me){let a=s.slice(i,i+Me),[d]=X(a.map(({user:u})=>u)),c;try{c=await e(`SELECT Id, Name, IsActive FROM ${On} WHERE Id IN (${d})`)}catch{continue}let f=new Set;for(let u of c){let p=u.Id;if(typeof p!="string"||(f.add(p.slice(0,15)),u.IsActive!==!1))continue;let l=t.get(p.slice(0,15));if(!l)continue;let m=u.Name;r.push({user:l.user,...typeof m=="string"&&m!==""?{name:m}:{},sources:l.sources})}for(let{user:u,sources:p}of a)u.startsWith(Oa)&&!f.has(u.slice(0,15))&&o.push({user:u,sources:p})}return{inactive:r,unknown:o}}var Tt=10,An="Nothing was read or written.",Xu="Nothing was written.";function As(n,e=An){let t=n.slice(0,Tt).map(({user:o,name:s,sources:i})=>`${s!==void 0?`${s} (${o})`:o}, given the records of `+i.join(", ")).join("; "),r=n.length-Tt;return`Owners given to users the target holds inactive: ${t}${r>0?`; and ${r} more`:""}. The target refuses a record owned by an inactive user, and the run will not give it to the user it writes as instead of the one chosen. Give those records to an active user under Owners (Review \u2192 Controls, or --owner-map on the command line), or reactivate the user in the target. `+e}function ja(n,e=An){let t=n.slice(0,Tt).map(({user:o,sources:s})=>`${o}, given the records of ${s.join(", ")}`).join("; "),r=n.length-Tt;return`Owners given to users the target does not hold: ${t}${r>0?`; and ${r} more`:""}. The target refuses a record owned by a user it does not hold (INVALID_CROSS_REFERENCE_KEY), and the run will not give it to the user it writes as instead of the one chosen. Give those records to a user of the target under Owners (Review \u2192 Controls, or --owner-map on the command line). `+e}async function ef(n,e,t=An){let{inactive:r,unknown:o}=await Os(n,e);if(o.length>0){let s=ja(o,t);return new me(fs,r.length>0?`${s.slice(0,-t.length)}${As(r,t)}`:s)}return r.length>0?new me(us,As(r,t)):void 0}import{createHash as Na}from"node:crypto";var js={ContentVersion:"VersionData",Attachment:"Body"},Ea=3,ks=class extends Error{constructor(t,r,o){super(t);this.code=r;this.storage=o;this.name="ForgeFilesRefusedError"}code;storage};function Y(n,e){let t=n[e];return typeof t=="string"&&t!==""?t:void 0}function Is(n,e){let t=n[e];return typeof t=="number"&&Number.isFinite(t)?t:0}function kn(n,e,t){return{objectApiName:n,stage:"query",failedCount:0,attemptedCount:0,samples:[{recordSummary:e,messages:[H(t)]}]}}async function cf(n){let{scope:e,sourceOrgId:t,maxFileBytes:r,queryRecords:o}=n,s=new Map;for(let u of e.values())for(let p of u)s.has(p)||s.set(p,s.size);let i={files:[],leftOut:[],errors:[]},a=[...s.keys()];if(a.length===0)return i;let d=u=>s.get(u)??Number.MAX_SAFE_INTEGER,c=new Map;try{for(let u of X(a)){let p=await o(t,`SELECT ContentDocumentId, LinkedEntityId, ShareType, Visibility FROM ContentDocumentLink WHERE LinkedEntityId IN (${u})`);for(let l of p){let m=Y(l,"ContentDocumentId"),h=Y(l,"LinkedEntityId");if(!m||!h||!s.has(h))continue;let w=c.get(m)??[];w.some(y=>y.id===h)||w.push({id:h,shareType:Y(l,"ShareType"),visibility:Y(l,"Visibility")}),c.set(m,w)}}}catch(u){i.errors.push(kn("ContentDocument","(links of the records in scope)",u))}let f=[];try{for(let u of X([...c.keys()])){let p=await o(t,`SELECT Id, ContentDocumentId, Title, PathOnClient, ContentSize, ContentLocation, SharingPrivacy FROM ContentVersion WHERE ContentDocumentId IN (${u}) AND IsLatest = true`);for(let l of p){let m=Y(l,"ContentDocumentId"),h=Y(l,"Id"),w=m?c.get(m):void 0;if(!m||!h||!w)continue;let y=Y(l,"Title")??m;f.push({external:(Y(l,"ContentLocation")??"S")!=="S",file:{objectApiName:"ContentDocument",sourceId:m,body:{objectApiName:"ContentVersion",id:h},name:y,bytes:Is(l,"ContentSize"),hosts:[...w].sort((R,O)=>d(R.id)-d(O.id)),fields:{Title:y,PathOnClient:Y(l,"PathOnClient")??y,...Y(l,"SharingPrivacy")==="P"?{SharingPrivacy:"P"}:{}}}})}}}catch(u){i.errors.push(kn("ContentDocument","(latest versions of the files)",u))}try{for(let u of X(a)){let p=await o(t,`SELECT Id, ParentId, Name, ContentType, BodyLength, IsPrivate FROM Attachment WHERE ParentId IN (${u})`);for(let l of p){let m=Y(l,"Id"),h=Y(l,"ParentId");if(!m||!h||!s.has(h))continue;let w=Y(l,"Name")??m;f.push({external:!1,file:{objectApiName:"Attachment",sourceId:m,body:{objectApiName:"Attachment",id:m},name:w,bytes:Is(l,"BodyLength"),hosts:[{id:h}],fields:{Name:w,...Y(l,"ContentType")?{ContentType:Y(l,"ContentType")}:{},IsPrivate:l.IsPrivate===!0}}})}}}catch(u){i.errors.push(kn("Attachment","(attachments of the records in scope)",u))}f.sort((u,p)=>d(u.file.hosts[0].id)-d(p.file.hosts[0].id));for(let{file:u,external:p}of f){let l=p?"external":u.bytes>r?"too-large":void 0;l?i.leftOut.push({objectApiName:u.objectApiName,sourceId:u.sourceId,name:u.name,bytes:u.bytes,reason:l}):i.files.push(u)}return i}function lf(n){return n.errors.length===0?null:`The files of the records to clone could not all be looked up in the source (${[...new Set(n.errors.flatMap(t=>t.samples.flatMap(r=>r.messages)))].join("; ")}). Run it again, or leave the files out.`}async function uf(n){let{files:e,targetOrgId:t,copiedBefore:r,queryRecords:o}=n,s={files:[],errors:[]},i=new Map;for(let l of e){let m=r(l.sourceId);m&&i.set(l.sourceId,m)}if(i.size===0)return{...s,files:[...e]};let a=new Map,d,c=new Map;for(let[l,m]of i)m.objectApiName==="ContentVersion"&&c.set(m.targetId,l),m.objectApiName==="ContentDocument"&&a.set(l,m.targetId);try{for(let l of X([...c.keys()])){let m=await o(t,`SELECT Id, ContentDocumentId FROM ContentVersion WHERE Id IN (${l})`);for(let h of m){let w=Y(h,"Id"),y=Y(h,"ContentDocumentId"),R=w?c.get(w):void 0;R&&y&&a.set(R,y)}}}catch(l){d=H(l)}let f=new Map,u;try{for(let l of X([...new Set(a.values())])){let m=await o(t,`SELECT ContentDocumentId, LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId IN (${l})`);for(let h of m){let w=Y(h,"ContentDocumentId"),y=Y(h,"LinkedEntityId");w&&y&&f.set(w,[...f.get(w)??[],y])}}}catch(l){u=H(l)}let p=(l,m)=>{s.errors.push({objectApiName:"ContentDocument",stage:"query",failedCount:0,attemptedCount:0,samples:[{recordSummary:`${l.name} (${Se(l.bytes)})`,messages:[m]}]})};for(let l of e){let m=i.get(l.sourceId);if(!m){s.files.push(l);continue}if(l.body.objectApiName==="Attachment")continue;let h=a.get(l.sourceId);if(!h){p(l,`Copied as ContentVersion ${m.targetId} by the run this one takes up, and its document still cannot be read back`+(d?` (${d})`:"")+": the file is not copied again, nor linked to the records it lacks.");continue}if(u){p(l,`Copied by the run this one takes up; its links could not be read (${u}): it is not linked to the records it lacks.`);continue}s.files.push({...l,into:{documentId:h,linked:f.get(h)??[],unchanged:!0}})}return s}function ff(n){return{objectApiName:"__files__",stage:"scope",failedCount:0,attemptedCount:0,samples:[{recordSummary:"(files)",messages:[n]}]}}function pf(n){return n.reduce((e,t)=>e+t.bytes,0)}function mf(n,e){return n<=e?null:`The files to copy take ${Se(n)} and the target has ${Se(Math.max(0,e))} of file storage left. Lower the largest file copied, or leave the files out.`}async function gf(n,e){let t=await n.remainingFileStorageMB(e);if(!Number.isFinite(t))throw new Error("The target did not say how much file storage it has left.");return t*1048576}function hf(n,e,t){let r=[];for(let o of n.files){let s=r.find(i=>i.objectApiName===o.objectApiName);s||(s={objectApiName:o.objectApiName,planned:0,plannedBytes:0,copied:0,failed:0},r.push(s)),s.planned++,s.plannedBytes+=o.bytes}return{maxFileBytes:e,objects:r,links:0,leftOut:[...n.leftOut],...t===void 0?{}:{remainingStorageBytes:t}}}function In(n,e){let t=n==="Attachment"?"attachment":"file";return e===1?t:`${t}s`}function wf(n){return`[dry-run] ${n.objectApiName}: ${n.planned} ${In(n.objectApiName,n.planned)} would be copied (${Se(n.plannedBytes)})`}function Ta(n,e,t){return n.body.objectApiName==="Attachment"?{Name:n.fields.Name??n.name,BodyLength:n.bytes,ParentId:t}:{Title:n.fields.Title??n.name,Checksum:Na("md5").update(Buffer.from(e,"base64")).digest("hex"),ContentSize:n.bytes}}function Fa(n){let e={};for(let[t,r]of Object.entries(n))t!=="SharingPrivacy"&&(e[t]=r);return e}async function yf(n){let{files:e,sourceOrgId:t,targetOrgId:r,remapper:o,deps:s,report:i,errors:a,onProgress:d,onCopied:c}=n,f=0,u=g=>{let b=i.objects.find(A=>A.objectApiName===g);return b||(b={objectApiName:g,planned:0,plannedBytes:0,copied:0,failed:0},i.objects.push(b)),b},p=(g,b)=>a.find(A=>A.objectApiName===g&&A.stage===b),l=new Map,m=(g,b,A=1)=>{let N=`${g}/${b}`;l.set(N,(l.get(N)??0)+A);let x=p(g,b);x&&(x.attemptedCount+=A)},h=(g,b,A,N,x=!1)=>{let v=p(g,b);v||(v={objectApiName:g,stage:b,failedCount:0,attemptedCount:l.get(`${g}/${b}`)??0,samples:[]},a.push(v)),x||(v.failedCount++,f++),v.samples.length<Ea&&v.samples.push({recordSummary:A,messages:[N]})},w=(g,b,A)=>{h(g.objectApiName,b,`${g.name} (${Se(g.bytes)})`,A),u(g.objectApiName).failed++},y=async(g,b,A)=>{let N=A.flatMap(v=>{let P=o.get(v.id);return P?[{ContentDocumentId:b,LinkedEntityId:P,ShareType:v.shareType??"V",Visibility:v.visibility??"AllUsers"}]:[]});if(N.length===0)return[];let x=[];m("ContentDocumentLink","insert",N.length);try{let v=await s.insertRecords(r,"ContentDocumentLink",N);N.forEach((P,k)=>{let j=v[k];if(j?.success){i.links++,x.push(P.LinkedEntityId);return}h("ContentDocumentLink","insert",g.name,j?.errors.join("; ")||"The target gave no reason.")})}catch(v){for(let P=0;P<N.length;P++)h("ContentDocumentLink","insert",g.name,H(v))}return x},R=e.filter(g=>!(g.body.objectApiName==="ContentVersion"&&g.into?.unchanged)).length,O=0;for(let g of e){await n.waitIfPaused();let b=g.hosts.filter(I=>o.isCreated(I.id)),A=g.body.objectApiName==="ContentVersion"?g.into:void 0,N=A?b.filter(I=>{let C=o.get(I.id);return C!==void 0&&!A.linked.includes(C)}):[];if(A?.unchanged){let I=await y(g,A.documentId,N);I.length>0&&c?.(g,{targetId:A.documentId,linked:I,asVersion:!1});continue}let x=O++,v=b.length>0?o.get(b[0].id):void 0;if(!v&&!A){i.leftOut.push({objectApiName:g.objectApiName,sourceId:g.sourceId,name:g.name,bytes:g.bytes,reason:"record-not-created"});continue}d({objectName:g.objectApiName,status:"running",progress:Math.round(x/R*100),message:`Copying ${In(g.objectApiName,1)} ${x+1} of ${R} (${Se(g.bytes)})`});let P;m(g.objectApiName,"query");try{P=await s.readFileBody(t,g.body.objectApiName,g.body.id)}catch(I){w(g,"query",H(I));continue}let k=Buffer.byteLength(P,"base64");if(k!==g.bytes){w(g,"query",`Read ${k} bytes of the ${g.bytes} the source reports: the file was not written.`);continue}let j=A?{...Fa(g.fields),VersionData:P,ContentDocumentId:A.documentId}:g.body.objectApiName==="ContentVersion"?{...g.fields,VersionData:P,FirstPublishLocationId:v}:{...g.fields,Body:P,ParentId:v},M;m(g.objectApiName,"insert");let D=n.calls?.sending(g.body.objectApiName,[{sourceId:g.sourceId,payload:Ta(g,P,v)}]),E=()=>{D!==void 0&&n.calls?.answered(D)};try{M=await s.insertFile(r,g.body.objectApiName,j)}catch(I){vo(I)!=="may-have-written"&&E(),w(g,"insert",H(I));continue}if(!M.success||!M.id){E(),w(g,"insert",M.errors.join("; ")||"The target gave no reason.");continue}if(u(g.objectApiName).copied++,g.body.objectApiName==="Attachment"){o.add(g.sourceId,M.id,"Attachment"),E(),o.persist?.(),c?.(g,{targetId:M.id,linked:v?[v]:[],asVersion:!1});continue}if(A){o.add(g.sourceId,A.documentId,"ContentDocument"),E(),o.persist?.();let I=await y(g,A.documentId,N);c?.(g,{targetId:A.documentId,linked:I,asVersion:!0});continue}o.add(g.sourceId,M.id,"ContentVersion"),E(),o.persist?.();let F;try{let I=await s.queryRecords(r,`SELECT ContentDocumentId FROM ContentVersion WHERE Id = '${Ce(M.id)}'`);F=I[0]?Y(I[0],"ContentDocumentId"):void 0}catch{F=void 0}if(!F){h("ContentDocument","query",`${g.name} (${Se(g.bytes)})`,`Copied as ContentVersion ${M.id}, but its document could not be read back: the run keeps the version, which a removal of the run takes with its document, and links it to no other record.`,!0);continue}o.add(g.sourceId,F,"ContentDocument"),o.persist?.();let S=await y(g,F,b.slice(1));c?.(g,{targetId:F,linked:v?[v,...S]:S,asVersion:!1})}for(let g of i.objects)d({objectName:g.objectApiName,status:g.failed>0&&g.copied===0?"error":"done",progress:100,message:`Copied ${g.copied} ${In(g.objectApiName,g.copied)} of ${g.planned}`+(g.failed>0?`, ${g.failed} failed`:"")});return f}function If(n,e,t={},r){if(!n)return;let o={};for(let s of e.nodes)es(s)&&(o[s.objectApiName]=[...s.anonymizeFields]);return{fields:o,methods:{...t},...r?{personalFieldsOf:r}:{}}}var Pa=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,va=/@example\.com$/i,jn="@example.invalid",Ca=64,xa=new Set(["fake","mask","preserve_format","shuffle"]);function Ma(n,e,t){return typeof n!="string"||n===""?n:Pa.test(n)?e.email(n.replace(va,jn),t):`${n.replace(/[^A-Za-z0-9._-]/g,"_").slice(0,Ca).replace(/^[._]+|[._]+$/g,"")||"anonymized"}${jn}`}var Ns=class{smartAnonymizer;contactPoints;constructor(e,t){this.smartAnonymizer=new To(e),this.contactPoints=new ms(t)}categorizeField(e,t){let r=t.toLowerCase();if(r==="email")return"email";if(r==="phone")return"phone";let o=Po(e,t);if(o)return o;let s=e.toLowerCase();return s.includes("email")?"email":s.includes("phone")||s.includes("fax")||s.includes("mobile")?"phone":s.includes("firstname")||s.includes("lastname")||s==="name"||Fo(e)?"name":s.includes("street")||s.includes("address")||s.includes("city")||s.includes("state")||s.includes("postalcode")||s.includes("zip")||s.includes("country")?"address":s.includes("ssn")||s.includes("national_id")||s.includes("passport")||s.includes("driver")||s.includes("license")?"ssn_id":s.includes("credit")||s.includes("card")||s.includes("cvv")||s.includes("iban")||s.includes("routing")||s.includes("bank")?"financial":"other"}getDefaultMethod(e){return{email:"fake",phone:"mask",name:"fake",address:"fake",ssn_id:"redact",financial:"hash",other:"nullify"}[e]}getDefaults(){return{email:"fake",phone:"mask",name:"fake",address:"fake",ssn_id:"redact",financial:"hash",other:"nullify"}}anonymize(e){if(e.fields.length===0)return e.records;let t={...this.getDefaults(),...e.methods},r=e.records.map((a,d)=>({...a,Id:e.sourceIds[d]??""})),o=this.anonymizeRecords(r,e.fields,t,e.objectApiName),s=e.fields.filter(a=>this.categorizeField(a.name,a.type)==="email"),i=xa.has(t.phone)?e.fields.filter(a=>this.categorizeField(a.name,a.type)==="phone"):[];return o.map((a,d)=>{let c=e.records[d],f={...a};for(let u of s)f[u.name]=this.undeliverable(f[u.name],u);for(let u of i)f[u.name]=this.fictionalNumber(c[u.name],f[u.name],u);return"Id"in c?f.Id=c.Id:delete f.Id,f})}undeliverable(e,t){let r=t.length!==void 0&&t.length>0?t.length:void 0;return t.type.toLowerCase()==="email"?Ma(e,this.contactPoints,r??ps):typeof e!="string"?e:this.contactPoints.addressesIn(e.replace(/@example\.com(?![\w.-])/gi,jn),r)}fictionalNumber(e,t,r){if(typeof e!="string")return t;if(!/\d/.test(e))return e;let o=r.length!==void 0&&r.length>0?r.length:void 0;return this.contactPoints.phone(e,o)}anonymizeRecords(e,t,r,o){let s=t.map(a=>{let d=this.categorizeField(a.name,a.type);return{objectApiName:o,fieldApiName:a.name,method:r[d],piiCategory:"PII",aiConfidence:1,userOverridden:!1}}),i=e.map(a=>({...a}));return this.smartAnonymizer.anonymize(i,s,o)}};var Es=new WeakMap;function Nf(n,e){typeof n=="object"&&n!==null&&Es.set(n,e)}function Ef(n){return typeof n=="object"&&n!==null?Es.get(n):void 0}var Nn=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,Ts=/^[A-Za-z][A-Za-z0-9_]*$/;function tt(n){if(!n.startsWith('["'))return;let e;try{e=JSON.parse(n)}catch{return}if(!Array.isArray(e))return;let[t,r,o,s]=e;if(!(t!=="c"&&t!=="e"&&t!=="u")&&!(typeof r!="string"||!Nn.test(r))&&!(typeof o!="string"||!Nn.test(o)))return{tag:t,sourceId:r,targetId:o,object:typeof s=="string"&&Ts.test(s)?s:""}}function _e(n){if(!n.startsWith(`["${kt}"`))return;let e;try{e=JSON.parse(n)}catch{return}if(!Array.isArray(e))return;let[,t,r]=e;if(!(typeof t!="string"||!Ts.test(t)||!Array.isArray(r)))return{object:t,ids:r.filter(o=>typeof o=="string"&&Nn.test(o))}}function nt(n){return n.slice(0,15)}var rt=class{offsets=new Float64Array(64);lengths=new Uint16Array(64);size=0;push(e,t){if(this.size===this.offsets.length){let r=new Float64Array(this.size*2);r.set(this.offsets),this.offsets=r;let o=new Uint16Array(this.size*2);o.set(this.lengths),this.lengths=o}this.offsets[this.size]=e,this.lengths[this.size]=t,this.size++}offsetAt(e){return this.offsets[e]}lengthAt(e){return this.lengths[e]}},be=class{capacity=1024;used=0;h1=new Uint32Array(this.capacity);h2=new Uint32Array(this.capacity);taken=new Uint8Array(this.capacity);add(e){let t=se(e),r=ie(e);if(this.slotOf(t,r)>=0)return;this.used+1>this.capacity*.6&&this.grow();let o=this.freeSlotFor(r);this.h1[o]=t,this.h2[o]=r,this.taken[o]=1,this.used++}has(e){return this.slotOf(se(e),ie(e))>=0}get size(){return this.used}slotOf(e,t){let r=this.capacity-1;for(let o=t&r;;o=o+1&r){if(this.taken[o]===0)return-1;if(this.h1[o]===e&&this.h2[o]===t)return o}}freeSlotFor(e){let t=this.capacity-1,r=e&t;for(;this.taken[r]!==0;)r=r+1&t;return r}grow(){let{h1:e,h2:t,taken:r}=this;this.capacity*=2,this.h1=new Uint32Array(this.capacity),this.h2=new Uint32Array(this.capacity),this.taken=new Uint8Array(this.capacity);for(let o=0;o<r.length;o++){if(r[o]===0)continue;let s=this.freeSlotFor(t[o]);this.h1[s]=e[o],this.h2[s]=t[o],this.taken[s]=1}}},La=2e3,ot=class n{constructor(e,t,r,o,s){this.file=e;this.all=t;this.mine=r;this.firstInPart=o;this.unattributed=s}file;all;mine;firstInPart;unattributed;static read(e,t){let r=(f,u)=>tt(e.read(f,u).toString("utf8"))?.sourceId??"",o=new It(r),s=new It(r),i=new rt,a=new rt,d=!1,c=-1;for(let f of we(e)){if(!d){if(!f.text.startsWith('{"run":'))return;d=!0;continue}if(f.text.startsWith('{"part":')){c++;continue}if(f.text.startsWith('{"object":'))return;if(c===t&&_e(f.text)){a.push(f.offset,f.length);continue}let u=tt(f.text);if(!u)continue;let p=se(u.sourceId),l=ie(u.sourceId);if(o.put(o.find(u.sourceId,p,l),p,l,f.offset,f.length,0),c!==t)continue;let m=s.find(u.sourceId,p,l);m<0&&i.push(f.offset,f.length);let h=u.tag==="c"&&u.object!=="";s.put(m,p,l,f.offset,f.length,h?1:0)}return d?new n(e,o,s,i,a):void 0}mappingAt(e,t){return tt(this.file.read(e,t).toString("utf8"))}wordsOn(e){let t=se(e),r=ie(e),o=this.all.find(e,t,r),s=this.mine.find(e,t,r);return{latest:o>=0?{offset:this.all.offsetOf(o),length:this.all.lengthOf(o)}:void 0,createdByThePart:s>=0&&this.mine.codeOf(s)===1,inThePart:s>=0?{offset:this.mine.offsetOf(s),length:this.mine.lengthOf(s)}:void 0}}createdByObject(){let e=new Map;for(let t=0;t<this.firstInPart.size;t++){let r=this.mappingAt(this.firstInPart.offsetAt(t),this.firstInPart.lengthAt(t));if(!r)continue;let o=this.wordsOn(r.sourceId);if(!o.createdByThePart||!o.latest||!o.inThePart)continue;let s=this.mappingAt(o.inThePart.offset,o.inThePart.length);if(!s)continue;let i=e.get(s.object)??new rt;i.push(o.latest.offset,o.latest.length),e.set(s.object,i)}return e}runRecords(e,t=La){let{file:r}=this,o=(h,w)=>tt(r.read(h,w).toString("utf8")),s=(h,w)=>{let y=o(h,w);return y?nt(y.targetId):""},i=new It(s),a=this.createdByObject(),d=[];for(let h of[...a.keys()].reverse()){let w=a.get(h);if(!w)continue;let y=0;for(let R=w.size-1;R>=0;R--){let O=w.offsetAt(R),g=o(O,w.lengthAt(R));if(!g||g.object==="")continue;let b=nt(g.targetId),A=se(b),N=ie(b),x=i.find(b,A,N);x>=0||(i.put(x,A,N,O,w.lengthAt(R),0),(!e||e.has(b))&&y++)}y>0&&d.push({objectApiName:h,count:y})}let c=(h,w)=>{let y=i.find(h,se(h),ie(h),w);return y>=0&&(w===void 0||i.offsetOf(y)===w)&&(!e||e.has(h))},f=h=>_e(r.read(this.unattributed.offsetAt(h),this.unattributed.lengthAt(h)).toString("utf8")),u=new be,p=this.unattributed.size,l=new Map;for(let h=0;h<p;h++){let w=f(h);if(w)for(let y of w.ids){let R=nt(y);u.has(R)||i.find(R,se(R),ie(R))>=0||(u.add(R),(!e||e.has(R))&&l.set(w.object,(l.get(w.object)??0)+1))}}for(let[h,w]of l){let y=d.find(R=>R.objectApiName===h);y?y.count+=w:d.unshift({objectApiName:h,count:w})}let m=h=>u.size>0&&u.has(h)&&(!e||e.has(h));return{objects:d,pages:async function*(h){let w=a.get(h),y=[];if(w)for(let R=w.size-1;R>=0;R--){let O=w.offsetAt(R),g=o(O,w.lengthAt(R));if(!g||g.object==="")continue;let b=nt(g.targetId);c(b,O)&&(y.push(g.targetId),y.length>=t&&(yield y,y=[]))}if(l.has(h)){let R=new be;for(let O=0;O<p;O++){let g=f(O);if(g?.object===h)for(let b of g.ids){let A=nt(b);R.has(A)||!m(A)||i.find(A,se(A),ie(A))>=0||(R.add(A),y.push(b),y.length>=t&&(yield y,y=[]))}}}y.length>0&&(yield y)},has:h=>c(h)||m(h)}}*idMapRows(){let e=new Map;for(let[r,o]of this.createdByObject())for(let s=0;s<o.size;s++){let i=this.mappingAt(o.offsetAt(s),o.lengthAt(s));i&&e.set(i.sourceId.slice(0,3),r)}let t=new Uint8Array(Math.ceil(this.all.slots/8));for(let r of we(this.file)){let o=tt(r.text);if(!o)continue;let s=this.all.find(o.sourceId,se(o.sourceId),ie(o.sourceId));if(s<0||(t[s>>3]&1<<(s&7))!==0)continue;t[s>>3]|=1<<(s&7);let i=this.wordsOn(o.sourceId);if(!i.latest)continue;let a=this.mappingAt(i.latest.offset,i.latest.length);if(!a||a.object==="")continue;yield{objectApiName:(i.createdByThePart&&i.inThePart?this.mappingAt(i.inThePart.offset,i.inThePart.length):void 0)?.object??e.get(a.sourceId.slice(0,3)),sourceId:a.sourceId,targetId:a.targetId,outcome:i.createdByThePart?"created":"linked to existing"}}}};var Ae=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,st=/^[A-Za-z][A-Za-z0-9_]*$/,_a=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,Da=255,Ba=40,$a=2*6e4,Wa=10*6e4;function $f(n){let[e]=n;return e?Object.keys(e).filter(t=>t!=="Id"&&st.test(t)).filter(t=>n.every(r=>qa(r[t]))).sort().slice(0,Ba):[]}function qa(n){return typeof n=="string"?n.trim()!==""&&n.length<=Da:typeof n=="number"?Number.isFinite(n):typeof n=="boolean"}function za(n){if(typeof n=="boolean")return n?"true":"false";if(typeof n=="number")return Number.isFinite(n)?String(n):"";if(typeof n!="string")return"";let e=n.trim();if(Ae.test(e))return e.slice(0,15);if(_a.test(e)){let r=Date.parse(e);if(Number.isFinite(r))return new Date(r).toISOString()}if(e!==""&&Number.isFinite(Number(e)))return String(Number(e));let t=e.replace(/\s+/g," ").toLowerCase();return t.includes(";")?t.split(";").map(r=>r.trim()).sort().join(";"):t}function Tn(n,e){return Fn(e.map(t=>`${t}${za(n[t])}`).join(""))}function Fn(n){return se(n).toString(36).padStart(7,"0")+ie(n).toString(36).padStart(7,"0")}function Wf(n){let e=bo("insert",n);return e.rows.map(t=>Fn(gn(e.columns.map((r,o)=>[r,t[o]??""]))))}var Ua=/^sf__/;function Fs(n){let e=[];for(let[t,r]of Object.entries(n))Ua.test(t)||e.push([t,typeof r=="string"?r:r==null?"":String(r)]);return Fn(gn(e))}function vs(n,e){return Tn(n,[e])}function Va(n,e){if(!Array.isArray(n))return!1;for(let t of n){if(!Array.isArray(t)||t.length<4)return!1;let[r,o,s,i]=t;if(typeof r!="number"||!Number.isInteger(r)||!e[r]||typeof o!="string"||!st.test(o)||typeof s!="string"||!Ae.test(s))return!1;e[r].owes.push({field:o,sourceRefId:s,...i===1?{insertOnly:!0}:{}})}return!0}function En(n){if(!n.startsWith(`["${At}"`))return;let e;try{e=JSON.parse(n)}catch{return}if(!Array.isArray(e)||e.length<6)return;let[,t,r,o,s,i,a,d]=e;if(typeof t!="string"||typeof r!="string"||!st.test(r)||typeof o!="string")return;let c=Date.parse(o);if(!Number.isFinite(c)||!Array.isArray(s)||!Array.isArray(i)||!s.every(p=>typeof p=="string"&&st.test(p))||d!==void 0&&(typeof d!="string"||!st.test(d)))return;let f=[];for(let p of i){if(!Array.isArray(p)||p.length<2)return;let[l,m,h,w]=p;if(typeof l!="string"||!Ae.test(l)||typeof m!="string"||h!==void 0&&typeof h!="string"||w!==void 0&&typeof w!="string")return;f.push({sourceId:l,fingerprint:m,owes:[],...typeof h=="string"&&h!==""?{externalKey:h}:{},...typeof w=="string"&&w!==""?{jobKey:w}:{}})}let u=a!==void 0;if(!(u&&!Va(a,f)))return{callId:t,objectApiName:r,at:c,fields:s,rows:f,owesKept:u,...typeof d=="string"?{upsertField:d}:{}}}function Cs(n){if(n.startsWith(`["${je}"`))try{let e=JSON.parse(n);return Array.isArray(e)&&typeof e[1]=="string"?e[1]:void 0}catch{return}}function Ga(n){if(n.startsWith(`["${Do}"`))try{let e=JSON.parse(n);return Array.isArray(e)&&typeof e[1]=="string"?e[1]:void 0}catch{return}}function Ja(n){if(n.startsWith(`["${_o}"`))try{let e=JSON.parse(n);if(!Array.isArray(e))return;let[,t,r]=e;return typeof t!="string"||typeof r!="string"||r===""?void 0:{callId:t,jobId:r}}catch{return}}function Ha(n){if(!(!n.startsWith('["c"')&&!n.startsWith('["e"')&&!n.startsWith('["u"')))try{let e=JSON.parse(n);if(!Array.isArray(e))return;let[,t,r,o]=e;return typeof t!="string"||typeof r!="string"||!Ae.test(t)||!Ae.test(r)?void 0:{sourceId:t,targetId:r,object:typeof o=="string"?o:""}}catch{return}}function Ka(n){let e=/"(?:startedAt|at)":"([^"]{10,40})"/.exec(n);return e?Date.parse(e[1]):Number.NaN}function qf(n){return{queryPages:e=>co({query:async t=>n.query(t),queryMore:async t=>n.queryMore(t)},e),userId:async()=>(await n.identity()).user_id,serverTime:async()=>(await n.soap.getServerTimestamp()).timestamp,readJob:e=>Ro(So(n),e)}}function Ya(){return{calls:0,found:[],notFound:[],uncertain:[],unread:[]}}function K(n,e,t=1){if(t<=0)return;let r=n.find(o=>o.objectApiName===e);r?r.rows+=t:n.push({objectApiName:e,rows:t})}function Ps(n){return new Date(n).toISOString().replace(/\.\d{3}Z$/,"Z")}function Pn(n,e,t){return[JSON.stringify(["c",e.sourceId,t,n.objectApiName,n.owesKept?Wo:$o]),...e.owes.map(({field:r,sourceRefId:o,insertOnly:s})=>Uo({objectApiName:n.objectApiName,newId:t,sourceId:e.sourceId,fieldName:r,sourceRefId:o,...s?{insertOnly:s}:{}}))]}function Za(n,e,t,r){let{call:o,rows:s,read:i}=n,{objectApiName:a}=o,d=JSON.stringify([je,o.callId]);if(i.state==="never-closed")return K(r.notFound,a,s.length),{lines:[d],taken:[]};if(i.state==="running")return K(r.uncertain,a,s.length),(r.underway??=[]).push({objectApiName:a,jobId:n.jobId,rows:s.length,...i.info?{state:i.info.state}:{},...i.info?.numberRecordsProcessed!==void 0?{processed:i.info.numberRecordsProcessed}:{},...i.openUntil?{openUntil:i.openUntil}:{},...i.graceLeftMs!==void 0?{graceLeftMs:i.graceLeftMs}:{}}),{lines:[],taken:[]};if(i.state==="unread")return r.unread.push({objectApiName:a,reason:i.reason}),K(r.uncertain,a,s.length),{lines:[],taken:[]};let c=o.upsertField===void 0&&s.every(u=>u.jobKey!==void 0)?Qa(o,s,i.results,e,t,r):Xa(o,s,i.results,e,t,r),f=Date.parse(i.info.systemModstamp??"");return!n.endKept&&c.taken.length>0&&Number.isFinite(f)&&c.lines.unshift(qo(o.callId,n.jobId,new Date(f).toISOString(),new Date(f-n.ahead).toISOString())),c}function Qa(n,e,t,r,o,s){let{objectApiName:i}=n,a=new Map,d=new Set;for(let O of t.successfulResults??[]){let g=O.sf__Id,b=Fs(O);if(typeof g!="string"||!Ae.test(g)){d.add(b);continue}let A=g.slice(0,15);r.has(A)&&!o.has(A)||a.set(b,[...a.get(b)??[],g])}let c=new Set,f=t.unprocessedRecords;for(let O of[...t.failedResults??[],...Array.isArray(f)?f:[]])c.add(Fs(O));let u=new Map;for(let O of e){let g=O.jobKey??"";u.set(g,[...u.get(g)??[],O])}let p=[],l=[],m=[],h=0,w=!1,y=0;for(let[O,g]of u){let b=a.get(O)??[];a.delete(O);let A=d.delete(O);if(g.length===1&&b.length===1&&!A){p.push(...Pn(n,g[0],b[0])),l.push(b[0]),K(s.found,i);continue}if(b.length>0||A){K(s.uncertain,i,g.length),g.length>1&&K(s.untold??=[],i,g.length),A||(y+=g.length),m.push(...b),w=!0;continue}if(g.length>1||c.has(O)){K(s.notFound,i,g.length);continue}h+=g.length}let R=d.size>0;for(let O of a.values())m.push(...O),O.length>0&&(R=!0);return h>0&&(K(R?s.uncertain:s.notFound,i,h),R&&(w=!0,d.size===0&&(y+=h))),y>0&&K(s.ofEndedJobs??=[],i,y),p.push(...xs(n,m,o,w,s)),{lines:p,taken:[...l,...m]}}function xs(n,e,t,r,o){e.length>0&&K(o.unattributed??=[],n.objectApiName,e.length);let s=e.filter(i=>!t.has(i.slice(0,15)));return[...s.length>0?[JSON.stringify([kt,n.objectApiName,s])]:[],...r?[]:[JSON.stringify([je,n.callId])]]}function Xa(n,e,t,r,o,s){let{objectApiName:i}=n,a=n.upsertField,d=new Map;for(let w of t.successfulResults??[]){let y=w.sf__Id;if(typeof y!="string"||!Ae.test(y))continue;let R=y.slice(0,15);if(r.has(R)&&!o.has(R)||a!==void 0&&String(w.sf__Created).toLowerCase()!=="true")continue;let O=a!==void 0?vs(w,a):Tn(w,n.fields);d.set(O,[...d.get(O)??[],y])}let c=new Map;for(let w of e){let y=a!==void 0?w.externalKey??"":w.fingerprint;c.set(y,[...c.get(y)??[],w])}let f=[],u=[],p=[],l=0,m=!1;for(let[w,y]of c){let R=w===""?[]:d.get(w)??[];if(d.delete(w),R.length===0){l+=y.length;continue}if(y.length===1&&R.length===1){f.push(...Pn(n,y[0],R[0])),u.push(R[0]),K(s.found,i);continue}K(s.uncertain,i,y.length),K(s.ofEndedJobs??=[],i,y.length),y.length>1&&K(s.untold??=[],i,y.length),p.push(...R),m=!0}let h=!1;for(let w of d.values())p.push(...w),w.length>0&&(h=!0);return l>0&&(K(h?s.uncertain:s.notFound,i,l),h&&(m=!0,K(s.ofEndedJobs??=[],i,l))),f.push(...xs(n,p,o,m,s)),{lines:f,taken:[...u,...p]}}function Ms(n){let e=new Set;for(let t of we(n)){let r=Cs(t.text);if(r!==void 0)e.delete(r);else{let o=t.text.startsWith(`["${At}"`)?En(t.text):void 0;o&&e.add(o.callId)}}return e.size}async function Ls(n,e,t=()=>new Date){let r=Ya(),o=new Map,s=new Map,i=new Set,a=Number.NEGATIVE_INFINITY;for(let g of we(n)){let b=Cs(g.text);if(b!==void 0){o.delete(b);continue}let A=Ja(g.text);if(A){s.set(A.callId,A.jobId);continue}let N=Ga(g.text);if(N!==void 0){i.add(N);continue}if(g.text.startsWith(`["${At}"`)){let x=En(g.text);x&&(o.set(x.callId,{offset:g.offset,length:g.length}),a=Math.max(a,x.at));continue}if(g.text.startsWith("{")){let x=Ka(g.text);Number.isFinite(x)&&(a=Math.max(a,x))}}if(o.size===0)return r;let d=[];for(let{offset:g,length:b}of o.values()){let A=En(n.read(g,b).toString("utf8"));A&&d.push(A)}r.calls=d.length;let c=new Set(d.map(g=>g.objectApiName)),f=new Set(d.flatMap(g=>g.rows.map(b=>b.sourceId)));r.lookedFor=f;let u=new Set,p=new be,l=new be;for(let g of we(n)){let b=_e(g.text);if(b){if(c.has(b.object))for(let N of b.ids)p.add(N.slice(0,15)),l.add(N.slice(0,15));continue}let A=Ha(g.text);A&&(f.has(A.sourceId)&&u.add(A.sourceId),(A.object===""||c.has(A.object))&&p.add(A.targetId.slice(0,15)))}let m=0;if(e.serverTime)try{let g=t().getTime(),b=Date.parse(await e.serverTime());Number.isFinite(b)&&(m=b-(g+t().getTime())/2)}catch{}let h,w,y=[],R=e.readJob?.bind(e),O=new Set;if(R)for(let g of d){let b=s.get(g.callId);if(b===void 0)continue;O.add(g.callId);let A=g.rows.filter(x=>!u.has(x.sourceId));if(A.length===0){y.push(JSON.stringify([je,g.callId]));continue}let N=Za({call:g,rows:A,jobId:b,read:await R(b),ahead:m,endKept:i.has(g.callId)},p,l,r);y.push(...N.lines);for(let x of N.taken)p.add(x.slice(0,15))}for(let g of c){let b=d.filter(S=>S.objectApiName===g&&!O.has(S.callId));if(b.length===0)continue;let A=b.map(S=>({call:S,rows:S.rows.filter(I=>!u.has(I.sourceId))})),N=A.reduce((S,{rows:I})=>S+I.length,0);if(N===0){for(let{call:S}of A)y.push(JSON.stringify([je,S.callId]));continue}let x=new Map;for(let S of b)x.set(S.fields.join(","),S.fields);let v=[...new Set(b.flatMap(S=>S.upsertField?[S.upsertField]:[]))],P=[...new Set([...b.flatMap(S=>S.fields),...v])].sort(),k;try{if(h===void 0&&w===void 0)try{h=await e.userId()}catch(L){w=H(L)}if(h===void 0)throw new Error(`the user the run writes as is not known: ${w}`);let S=Math.min(...b.map(L=>L.at))+m-$a,I=a+m+Wa,C=P.includes("CreatedDate")?"SystemModstamp":"CreatedDate",B=P.includes("CreatedById")?"":`CreatedById = '${h}' AND `,T=`SELECT ${["Id",...P.filter(L=>L!=="Id")].join(", ")} FROM ${J(g)} WHERE ${B}${C} >= ${Ps(S)} AND ${C} <= ${Ps(I)} ORDER BY Id`;k=[];for await(let L of e.queryPages(T))for(let _ of L){let $=_.Id;if(typeof $!="string"||!Ae.test($)||p.has($.slice(0,15)))continue;let U=new Map;for(let[fe,ft]of x)U.set(fe,Tn(_,ft));let Q=new Map;for(let fe of v)Q.set(fe,vs(_,fe));k.push({id:$,fingerprints:U,externalKeys:Q,taken:!1})}}catch(S){r.unread.push({objectApiName:g,reason:H(S)}),K(r.uncertain,g,N);continue}k.sort((S,I)=>S.id<I.id?-1:S.id>I.id?1:0);let j=new Map;for(let S of x.keys()){let I=new Map;for(let C of k){let B=C.fingerprints.get(S)??"",T=I.get(B)??[];T.push(C),I.set(B,T)}j.set(S,I)}let M=(S,I,C)=>{C.taken=!0,y.push(...Pn(S,I,C.id)),K(r.found,g)},D=new Set;for(let{call:S,rows:I}of A){let C=S.upsertField;if(C===void 0)continue;let B=new Map;for(let L of k){let _=L.externalKeys.get(C);L.taken||_===void 0||B.set(_,[...B.get(_)??[],L])}let T=new Map;for(let L of I){let _=L.externalKey??"";T.set(_,[...T.get(_)??[],L])}for(let[L,_]of T){let $=L===""?[]:B.get(L)??[];if(L===""||_.length>1||$.length>1){K(r.uncertain,g,_.length),D.add(S.callId);continue}$.length===1?M(S,_[0],$[0]):K(r.notFound,g)}}let E=[];for(let{call:S,rows:I}of A){if(S.upsertField!==void 0)continue;let C=S.fields.join(","),B=new Map;for(let T of I){let L=B.get(T.fingerprint)??[];L.push(T),B.set(T.fingerprint,L)}for(let[T,L]of B){let _=(j.get(C)?.get(T)??[]).filter($=>!$.taken);if(_.length>L.length){for(let $ of L)E.push({callId:S.callId,sourceId:$.sourceId});D.add(S.callId);continue}_.forEach(($,U)=>M(S,L[U],$));for(let $ of L.slice(_.length))E.push({callId:S.callId,sourceId:$.sourceId})}}let F=k.some(S=>!S.taken);for(let S of E)F||D.has(S.callId)?(K(r.uncertain,g),D.add(S.callId)):K(r.notFound,g);for(let{call:S}of A)D.has(S.callId)||y.push(JSON.stringify([je,S.callId]))}return y.length>0&&n.append(`${y.join(`
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{b as a,c as b,d as c}from"./chunk-
|
|
7
|
+
import{b as a,c as b,d as c}from"./chunk-BN33LVPQ.mjs";import"./chunk-3XG25GTF.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-WSUKC2U3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-HFUDCNU5.mjs";import"./chunk-KIMQQ6JQ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{c as CycleFkPass,b as RecordsOwingAcrossParts,a as patchCycleFkUpdates};
|
|
@@ -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{f as $}from"./chunk-ZUOPC4W2.mjs";import{a as F}from"./chunk-PPGDAUEQ.mjs";import{a as N}from"./chunk-4TLYUZD5.mjs";import{b as O}from"./chunk-CA5NAXSU.mjs";import{Qc as k,k as M}from"./chunk-ZQO5PDX5.mjs";var x=class e{static DEFAULT_MAX_PER_ORG=5;static DEFAULT_RECYCLE_INTERVAL=900*1e3;connections=new Map;config;cleanupTimer;recycleTimer;maxPerOrg;recycleIntervalMs;latencySamples=new Map;constructor(t,r){this.config={maxConnections:t?.maxConnections??10,keepAliveInterval:t?.keepAliveInterval??6e4,connectionTimeout:t?.connectionTimeout??3e4,idleTimeout:t?.idleTimeout??3e5},this.maxPerOrg=r?.maxPerOrg??e.DEFAULT_MAX_PER_ORG,this.recycleIntervalMs=r?.recycleIntervalMs??e.DEFAULT_RECYCLE_INTERVAL}acquire(t,r,n){let s=this.connections.get(t);if(s&&s.active)return s.lastUsedAt=Date.now(),s.accessToken=n,s;this.connections.size>=this.config.maxConnections&&this.evictOldest();let i={orgId:t,instanceUrl:r,accessToken:n,createdAt:Date.now(),lastUsedAt:Date.now(),active:!0};return this.connections.set(t,i),i}release(t){let r=this.connections.get(t);r&&(r.lastUsedAt=Date.now())}remove(t){return this.latencySamples.delete(t),this.connections.delete(t)}get(t){return this.connections.get(t)}get size(){return this.connections.size}getConfig(){return{...this.config}}getMaxPerOrg(){return this.maxPerOrg}recordLatency(t,r){if(!Number.isFinite(r)||r<0)return;let n=this.latencySamples.get(t);n||(n=[],this.latencySamples.set(t,n)),n.push(r),n.length>1e3&&n.splice(0,n.length-1e3)}getLatencyMetrics(t){let r=this.latencySamples.get(t);if(!r||r.length===0)return;let n=[...r].sort((a,c)=>a-c),s=n.reduce((a,c)=>a+c,0),i=Math.floor(n.length*.95),u=Math.floor(n.length*.99);return{min:n[0],max:n[n.length-1],avg:Math.round(s/n.length),p95:n[Math.min(i,n.length-1)],p99:n[Math.min(u,n.length-1)],sampleCount:n.length}}getAllLatencyMetrics(){let t=new Map;for(let r of this.latencySamples.keys()){let n=this.getLatencyMetrics(r);n&&t.set(r,n)}return t}cleanupIdle(){let t=Date.now(),r=0;for(let[n,s]of this.connections)t-s.lastUsedAt>this.config.idleTimeout&&(this.connections.delete(n),r++);return r}recycleStale(){let t=Date.now(),r=0;for(let[n,s]of this.connections)t-s.createdAt>this.recycleIntervalMs&&(s.active=!1,this.connections.delete(n),r++);return r}startCleanup(){this.stopCleanup(),this.cleanupTimer=setInterval(()=>this.cleanupIdle(),this.config.keepAliveInterval)}stopCleanup(){this.cleanupTimer&&(clearInterval(this.cleanupTimer),this.cleanupTimer=void 0)}startRecycling(){this.stopRecycling(),this.recycleTimer=setInterval(()=>this.recycleStale(),this.recycleIntervalMs)}stopRecycling(){this.recycleTimer&&(clearInterval(this.recycleTimer),this.recycleTimer=void 0)}evictOldest(){let t,r=1/0;for(let[n,s]of this.connections)s.lastUsedAt<r&&(r=s.lastUsedAt,t=n);t&&this.connections.delete(t)}dispose(){this.stopCleanup(),this.stopRecycling(),this.connections.clear(),this.latencySamples.clear()}};var S=class{state="closed";failureCount=0;lastFailureTime=0;halfOpenSuccesses=0;halfOpenInFlight=0;config;constructor(t){this.config={failureThreshold:t?.failureThreshold??5,resetTimeout:t?.resetTimeout??6e4,halfOpenRequests:t?.halfOpenRequests??1}}getState(){return this.state==="open"&&this.shouldTransitionToHalfOpen()&&(this.state="half_open",this.halfOpenSuccesses=0),this.state}canExecute(){let t=this.getState();return t==="closed"?!0:t==="half_open"?this.halfOpenInFlight<this.config.halfOpenRequests:!1}recordSuccess(){this.state==="half_open"?(this.halfOpenSuccesses++,this.halfOpenInFlight=Math.max(0,this.halfOpenInFlight-1),this.halfOpenSuccesses>=this.config.halfOpenRequests&&this.reset()):this.failureCount=0}recordFailure(){this.failureCount++,this.lastFailureTime=Date.now(),this.state==="half_open"?this.trip():this.failureCount>=this.config.failureThreshold&&this.trip()}trip(){this.state="open",this.lastFailureTime=Date.now()}reset(){this.state="closed",this.failureCount=0,this.halfOpenSuccesses=0,this.halfOpenInFlight=0}getFailureCount(){return this.failureCount}acquirePermit(){return this.canExecute()?(this.getState()==="half_open"&&this.halfOpenInFlight++,!0):!1}releasePermit(){this.halfOpenInFlight=Math.max(0,this.halfOpenInFlight-1)}getConfig(){return{...this.config}}shouldTransitionToHalfOpen(){return Date.now()-this.lastFailureTime>=this.config.resetTimeout}};var B=0;function we(){return B}async function I(e,t){let r=$(e);try{return await t()}finally{B+=r()}}var C=class extends Error{constructor(r,n,s){super(`${r}: ${s}`);this.code=r;this.orgId=n;this.name="OrgConnectionError"}code;orgId};import{homedir as ee,userInfo as te}from"node:os";var ne=[/^ELECTRON_.+$/,/^VSCODE_(?!(PORTABLE|SHELL_LOGIN|ENV_REPLACE|ENV_APPEND|ENV_PREPEND)).+$/,/^SNAP(|_.*)$/,/^GDK_PIXBUF_.+$/],V=["HTTP_PROXY","HTTPS_PROXY","NO_PROXY","NODE_EXTRA_CA_CERTS","NODE_OPTIONS","NODE_TLS_REJECT_UNAUTHORIZED"];function X(e){return ne.some(t=>t.test(e))}function P(e=process.env){let t={};for(let[r,n]of Object.entries(e))X(r)||(t[r]=n);return t.NO_COLOR="1",t}function Ee(e=process.env){let t=Object.keys(e).filter(c=>(e[c]??"")!==""),r=V.filter(c=>t.some(d=>d.toUpperCase()===c)),n=t.filter(c=>/^(SF|SFDX)_/i.test(c)).sort(),s=t.filter(c=>X(c)),i=s.filter(c=>c.startsWith("ELECTRON_")).sort(),u=s.length-i.length,a=s.length===0?"none":[...i,...u>0?[`${u} VSCODE_ or other VS Code variables`]:[]].join(", ");return`set: ${r.length>0?r.join(", "):"none of "+V.join(", ")}; SF_/SFDX_: ${n.length>0?n.join(", "):"none"}; not passed to sf, as a terminal does not get them: ${a}`}function re(){try{return te().username}catch{return process.env.USERNAME??process.env.USER??""}}function H(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function j(e,t=ee(),r=re()){let n=e;return t.length>3&&(n=n.replace(new RegExp(H(t),"gi"),"~")),r.length>=2&&(n=n.replace(new RegExp(`(?<=[\\\\/])${H(r)}(?=[\\\\/]|$)`,"gim"),"<user>")),n.replace(/00D\w{12,15}![\w.]+/g,"<token>").replace(/[\w.+-]+@[\w-]+(\.[\w-]+)+/g,"<username>")}function ve(e){return e.split(/\r?\n/).map(t=>t.trim()).find(t=>t.length>0)}function se(e,t){if(process.platform!=="win32")return e[0];let n=(Object.entries(t).find(([s])=>s.toUpperCase()==="PATHEXT")?.[1]??".COM;.EXE;.BAT;.CMD").split(";").map(s=>s.trim().toLowerCase()).filter(s=>s.length>0);return e.find(s=>{let i=s.lastIndexOf(".");return i>Math.max(s.lastIndexOf("\\"),s.lastIndexOf("/"))&&n.includes(s.slice(i).toLowerCase())})}async function Oe(e=1e4){let{exec:t}=await import("child_process"),{promisify:r}=await import("util"),n=process.platform==="win32"?"where sf node":"which -a sf node",s=P(),i,u;try{let l=await r(t)(n,{timeout:e,windowsHide:!0,env:s});i=String(l.stdout)}catch(l){let o=l;i=String(o.stdout??""),i.trim()===""&&(u=j(o.message??String(l)))}let a=i.split(/\r?\n/).map(l=>l.trim()).filter(l=>l.length>0).map(l=>j(l)),c=l=>a.filter(o=>new RegExp(`(^|[\\\\/])${l}(\\.[A-Za-z0-9]+)?$`,"i").test(o)),d=c("sf"),p=se(d,s);return{sf:d,node:c("node"),...p!==void 0?{runs:p}:{},...u?{failure:u}:{}}}function R(e,t){let r=(e[t.toLowerCase()]??e[t.toUpperCase()]??"").trim();return r===""?void 0:r}function ie(e,t){if(t===void 0)return!1;let r=e.hostname.toLowerCase(),n=e.port||(e.protocol==="https:"?"443":"80");return t.split(/[\s,]+/).filter(s=>s!=="").some(s=>{if(s==="*")return!0;let[,i="",u]=/^(.*?)(?::(\d+))?$/.exec(s.toLowerCase())??[];if(u!==void 0&&u!==n)return!1;let a=i.replace(/^\*?\.?/,"");return a!==""&&(r===a||r.endsWith(`.${a}`))})}function G(e,t=process.env){let r;try{r=new URL(e)}catch{return}let n=r.protocol==="https:"?R(t,"https_proxy")??R(t,"http_proxy"):R(t,"http_proxy");if(n!==void 0)return ie(r,R(t,"no_proxy"))?void 0:n}var oe="https://login.salesforce.com";async function v(e,t=process.env){let{jsforce:r,HttpProxyTransport:n}=await import("./chunk-L5FGY6YA.mjs"),s=G(e.instanceUrl??e.loginUrl??oe,t),i=new r.Connection({...e,...s!==void 0?{httpProxy:s}:{}});return s===void 0&&(i._transport=new n("")),i}var ae=10*1024*1024,L=3e4,q=L+2e3,A=`sf did not answer within ${L/1e3} s \u2014 check the Salesforce CLI`;function J(e){return e instanceof Error&&e.message===A}var D=2e4;function U(e,t,r){let n,s=new Promise((i,u)=>{n=setTimeout(()=>u(new Error(r)),t)});return Promise.race([e,s]).finally(()=>clearTimeout(n))}var E=new x,ce=300*1e3,_=new Map,le={failureThreshold:3,resetTimeout:3e4},z=new Map;function Ne(){return E}function ue(e){let t=z.get(e);return t||(t=new S({...le}),z.set(e,t)),t}var Y;var b="panel";function Be(e){b=e}function fe(e,t=b){return t==="panel"?"Reconnect it on the Organizations page (Try Reconnect on its card).":`Sign in to it again with "sf org login web --alias ${e}" (in a CI job, "sf org login jwt" or "sf org login sfdx-url"), then run the command again, with its --resume if it stopped a run part way.`}function W(e=b){return e==="panel"?"Create a new one and import it.":'Create a new one ("sf org create scratch") and give its alias.'}function K(e,t){let r=t?.organization_id;if(!(!Y||typeof r!="string"))try{Y(e,{organizationId:r})}catch(n){N.warn("Identity observer threw",{orgId:e,error:O(n)})}}var de="[REDACTED]";function Z(e){return typeof e=="string"&&e.length>0&&!e.startsWith(de)&&!/\s/.test(e)}async function pe(e){if(!/^[\w.@+-]+$/.test(e))throw new Error(`Invalid username format: "${e}"`);let{execFile:t,exec:r}=await import("child_process"),{promisify:n}=await import("util"),s={maxBuffer:ae,timeout:L,windowsHide:!0,env:P()},i=o=>U(n(t)("sf",o,s),q,A),u=o=>{let f=!1,h,y=new Promise((T,m)=>{h=r(o,s,(g,w)=>{f=!0,g?m(g):T({stdout:w})})});return U(y,q,A).catch(T=>{throw!f&&h?.pid!==void 0&&t("taskkill",["/pid",String(h.pid),"/T","/F"],{windowsHide:!0},()=>{}),T})},a=(o,f)=>process.platform==="win32"?u(o):i(f),c=(o,f)=>{let h=o.replace(/\[[0-9;]*m/g,""),y=h.search(/[{[]/);if(y===-1)throw new Error(`Failed to parse "${f}" output: no JSON found. Ensure Salesforce CLI (sf) is installed and the org is authenticated.`);return JSON.parse(h.slice(y)).result??{}},d;try{let{stdout:o}=await a(`sf org display -u "${e}" --json`,["org","display","-u",e,"--json"]),f=c(o,"sf org display");d=typeof f.instanceUrl=="string"?f.instanceUrl:void 0}catch(o){if(J(o))throw o;d=void 0}try{let{stdout:o}=await a(`sf org auth show-access-token -o "${e}" --json`,["org","auth","show-access-token","-o",e,"--json"]),f=c(o,"sf org auth show-access-token");if(Z(f.accessToken))return{accessToken:f.accessToken,instanceUrl:d}}catch(o){if(J(o))throw o}let{stdout:p}=await a(`sf org display -u "${e}" --json`,["org","display","-u",e,"--json"]),l=c(p,"sf org display");if(!Z(l.accessToken))throw new Error('Neither "sf org auth show-access-token" nor "sf org display" returned an access token. The org session may have expired \u2014 try re-authenticating with "sf org login".');return!d&&typeof l.instanceUrl=="string"&&(d=l.instanceUrl),{accessToken:l.accessToken,instanceUrl:d}}async function Ve(e,t){return v({instanceUrl:e.instanceUrl,accessToken:e.accessToken??void 0,version:e.version,callOptions:{client:t}})}async function He(e){return v({instanceUrl:e.instanceUrl,accessToken:e.accessToken,version:e.version})}async function je(e,t,r){let n=e,s=r.getOrg(e);if(!s)throw new Error(`Org not found: ${e}`);let i=await t.getCredentials(e);if(!i?.accessToken||!i.instanceUrl)throw new Error(`No credentials for org "${s.alias}" (${e}). Reconnect the org.`);let u=s.metadata.apiVersion||M.DEFAULT_API_VERSION,a=E.get(n),c=Date.now()-(_.get(e)??0)<ce;if(a&&a.active&&a.accessToken===i.accessToken&&c)return a.lastUsedAt=Date.now(),v({instanceUrl:a.instanceUrl,accessToken:a.accessToken,version:u});let d=await v({instanceUrl:i.instanceUrl,accessToken:i.accessToken,version:u}),p=ue(e);if(!p.acquirePermit())throw new C("ORG_TEMPORARILY_UNREACHABLE",e,`"${s.alias}" failed several times in a row, so SandForge waits a moment before calling it again. Try again in a minute.`);let l=Date.now(),o=`identity check did not answer within ${D/1e3} s`;try{let f=await I(d,()=>U(d.identity(),D,o)),h=Date.now()-l;return p.recordSuccess(),E.acquire(n,i.instanceUrl,i.accessToken),E.recordLatency(n,h),_.set(e,Date.now()),K(e,f),d}catch(f){let h=Date.now()-l;if(E.remove(n),_.delete(e),F(f))try{let m=await pe(s.username),g=m.instanceUrl??i.instanceUrl;if(m.accessToken===i.accessToken&&g===i.instanceUrl)throw new Error("sf CLI token store is stale too (same expired token) \u2014 re-authenticate the org");let w=await v({instanceUrl:g,accessToken:m.accessToken,version:u}),Q=await I(w,()=>U(w.identity(),D,o));return await t.saveOrg(s,{...i,accessToken:m.accessToken,instanceUrl:g}),p.recordSuccess(),E.acquire(n,g,m.accessToken),E.recordLatency(n,h),_.set(e,Date.now()),K(e,Q),w}catch(m){p.recordFailure();let g=O(m);r.updateStatus(e,"expired");let w=k(s,new Date().toISOString().slice(0,10));throw w!==void 0?new C("SCRATCH_ORG_EXPIRED",e,`The scratch org "${s.alias}" expired on ${w}: Salesforce deletes a scratch org when it expires, and no reconnect brings it back. ${W()} (cause: ${g})`):new C("ORG_AUTH_EXPIRED",e,`The session with "${s.alias}" has expired and could not be renewed. ${fe(s.alias)} (cause: ${g})`)}p.recordFailure();let y=O(f),T=k(s,new Date().toISOString().slice(0,10));throw T!==void 0?(r.updateStatus(e,"expired"),new C("SCRATCH_ORG_EXPIRED",e,`The scratch org "${s.alias}" expired on ${T}: Salesforce deletes a scratch org when it expires, and no reconnect brings it back. ${W()} (cause: ${y})`)):new Error(`Connection failed for "${s.alias}": ${y}`)}finally{p.releasePermit()}}export{we as a,I as b,C as c,P as d,Ee as e,j as f,ve as g,Oe as h,G as i,v as j,U as k,Ne as l,Be as m,Z as n,pe as o,Ve as p,He as q,je as r};
|