sandforge 1.81.0 → 1.83.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-J6G23RUI.mjs → chunk-262TP6UU.mjs} +1 -1
- package/lib/{chunk-NWVVCZUK.mjs → chunk-27BBEGUD.mjs} +1 -1
- package/lib/{chunk-Y5ZCPY36.mjs → chunk-2ADSD5WK.mjs} +1 -1
- package/lib/{chunk-55LQD3Y3.mjs → chunk-2GSMHGIV.mjs} +1 -1
- package/lib/chunk-2K5BYZQM.mjs +8 -0
- package/lib/{chunk-GK7VEYFM.mjs → chunk-2KTGDYUH.mjs} +1 -1
- package/lib/{chunk-T3PLRQ2T.mjs → chunk-2N73W63D.mjs} +1 -1
- package/lib/{chunk-7PK5QDQI.mjs → chunk-2R6GFNKF.mjs} +1 -1
- package/lib/{chunk-2OIRJEYE.mjs → chunk-2WMKJVD2.mjs} +1 -1
- package/lib/{chunk-D62KWDDT.mjs → chunk-36Y225OM.mjs} +1 -1
- package/lib/{chunk-HYOOJVR6.mjs → chunk-3CM7LAPE.mjs} +1 -1
- package/lib/{chunk-OIIL4NVI.mjs → chunk-3OVTKRS4.mjs} +1 -1
- package/lib/{chunk-UT27HXE7.mjs → chunk-3V4YH5KO.mjs} +1 -1
- package/lib/{chunk-OZNLOV4U.mjs → chunk-446GBKAC.mjs} +1 -1
- package/lib/{chunk-SQGP46QS.mjs → chunk-4GCYGQXD.mjs} +1 -1
- package/lib/{chunk-2NAIUKVL.mjs → chunk-4V3QO7HF.mjs} +1 -1
- package/lib/{chunk-GWRKS3AL.mjs → chunk-4X5D3MSV.mjs} +1 -1
- package/lib/{chunk-KGYXLSQ5.mjs → chunk-5OGNK3JP.mjs} +1 -1
- package/lib/{chunk-D7P7DTWL.mjs → chunk-6KOUYHEY.mjs} +1 -1
- package/lib/chunk-6QSHWIZI.mjs +48 -0
- package/lib/chunk-6VOQFISN.mjs +7 -0
- package/lib/{chunk-742SSN7I.mjs → chunk-6YC2ELCU.mjs} +1 -1
- package/lib/chunk-77IVKH7R.mjs +7 -0
- package/lib/{chunk-KNIRA333.mjs → chunk-77MZRBWX.mjs} +1 -1
- package/lib/{chunk-ZUA5BNAO.mjs → chunk-7BQMBXKX.mjs} +1 -1
- package/lib/{chunk-OQQHNYR7.mjs → chunk-7DPHZWA4.mjs} +2 -2
- package/lib/chunk-7V2UYZ6S.mjs +7 -0
- package/lib/chunk-7WSQ65WG.mjs +9 -0
- package/lib/{chunk-HVC5CYIB.mjs → chunk-7ZBDACVG.mjs} +1 -1
- package/lib/chunk-A32ISQ6M.mjs +28 -0
- package/lib/{chunk-XC2QKQT5.mjs → chunk-AG24QMSY.mjs} +1 -1
- package/lib/{chunk-K77NR3UK.mjs → chunk-AHUGG3WU.mjs} +1 -1
- package/lib/{chunk-K55LH4ZQ.mjs → chunk-ALBY5SOH.mjs} +1 -1
- package/lib/chunk-AXFD2OH6.mjs +7 -0
- package/lib/{chunk-YCSFP6ER.mjs → chunk-BH76USTQ.mjs} +1 -1
- package/lib/chunk-BNKT3R3F.mjs +7 -0
- package/lib/{chunk-YIGFYZQY.mjs → chunk-BPHTA6KP.mjs} +1 -1
- package/lib/{chunk-MNITSYI2.mjs → chunk-BT43WSOS.mjs} +1 -1
- package/lib/{chunk-ZWZXQTAK.mjs → chunk-BVZ5H3N4.mjs} +14 -14
- package/lib/{chunk-43K2C6H2.mjs → chunk-C6RKM4BB.mjs} +1 -1
- package/lib/{chunk-C4YGSK6W.mjs → chunk-CDWZGQAJ.mjs} +1 -1
- package/lib/chunk-CGZGL6VT.mjs +7 -0
- package/lib/{chunk-KE2PGD6C.mjs → chunk-CN5HGFG4.mjs} +1 -1
- package/lib/chunk-CQAFVEKP.mjs +13 -0
- package/lib/{chunk-XIZ5LMQM.mjs → chunk-CTPLYUXA.mjs} +1 -1
- package/lib/chunk-CXKZ6TYV.mjs +9 -0
- package/lib/{chunk-DHIW4IO5.mjs → chunk-D6JT4PAB.mjs} +1 -1
- package/lib/{chunk-AELFEK3G.mjs → chunk-D7XUNWWU.mjs} +1 -1
- package/lib/{chunk-GR3NGDVM.mjs → chunk-DB5RVDC5.mjs} +1 -1
- package/lib/{chunk-MO3N5XVV.mjs → chunk-DIGUC7S4.mjs} +2 -2
- package/lib/{chunk-2OZG6GRW.mjs → chunk-DKDKCGXV.mjs} +1 -1
- package/lib/chunk-DMT5SCO3.mjs +7 -0
- package/lib/chunk-DNQKVCUV.mjs +475 -0
- package/lib/{chunk-MAHZMPMZ.mjs → chunk-DSR2MSBH.mjs} +1 -1
- package/lib/{chunk-O6ADMP36.mjs → chunk-E3RQ575Y.mjs} +1 -1
- package/lib/{chunk-ETT5GP4P.mjs → chunk-EOQON3E5.mjs} +1 -1
- package/lib/{chunk-TKQQVB2D.mjs → chunk-ETNQHIDI.mjs} +1 -1
- package/lib/chunk-F5SBGJWW.mjs +7 -0
- package/lib/chunk-FBXH4VRQ.mjs +7 -0
- package/lib/chunk-FKCIGJOI.mjs +15 -0
- package/lib/{chunk-OVOLG3AL.mjs → chunk-FVLFO2S6.mjs} +1 -1
- package/lib/{chunk-YOGMP72T.mjs → chunk-FYWNSMOZ.mjs} +1 -1
- package/lib/{chunk-DHGPDSXS.mjs → chunk-GEEWPTV5.mjs} +1 -1
- package/lib/{chunk-FSDO4DJA.mjs → chunk-GLN4PI5P.mjs} +1 -1
- package/lib/{chunk-PYUEHBA6.mjs → chunk-GT5ZKU6V.mjs} +1 -1
- package/lib/chunk-GTRU5AV5.mjs +7 -0
- package/lib/chunk-H33DVU3D.mjs +7 -0
- package/lib/{chunk-5WGA5CZB.mjs → chunk-H4OBZIX3.mjs} +1 -1
- package/lib/{chunk-4L7FBOJS.mjs → chunk-HQZUQXDC.mjs} +1 -1
- package/lib/{chunk-VSU74RQ3.mjs → chunk-HVX2AFYW.mjs} +1 -1
- package/lib/chunk-I3ZO76LL.mjs +21 -0
- package/lib/{chunk-V4RKM4QZ.mjs → chunk-I5C4O3VA.mjs} +1 -1
- package/lib/{chunk-FSZTXLNW.mjs → chunk-IHGYJZZ2.mjs} +1 -1
- package/lib/chunk-ISA2NYJV.mjs +7 -0
- package/lib/{chunk-2IB7I3IQ.mjs → chunk-ISAUCWYK.mjs} +1 -1
- package/lib/{chunk-3B5H24ZG.mjs → chunk-ISOSTAJR.mjs} +1 -1
- package/lib/chunk-IXIY6Q4M.mjs +7 -0
- package/lib/{chunk-TPHXRHOA.mjs → chunk-J3TIHLWG.mjs} +1 -1
- package/lib/{chunk-TQM2XJ27.mjs → chunk-JAV6F6OA.mjs} +1 -1
- package/lib/chunk-JBWJ6UEZ.mjs +7 -0
- package/lib/{chunk-WM5JI4JI.mjs → chunk-JH4ZTVQN.mjs} +1 -1
- package/lib/{chunk-BZFIOZS3.mjs → chunk-JIPT5FUD.mjs} +1 -1
- package/lib/{chunk-6FMLW7PH.mjs → chunk-JPEVIXNH.mjs} +1 -1
- package/lib/{chunk-67CC7RAE.mjs → chunk-JREKJO3D.mjs} +1 -1
- package/lib/{chunk-3AOKLIVE.mjs → chunk-JUOQUG7U.mjs} +1 -1
- package/lib/chunk-JYUMD357.mjs +7 -0
- package/lib/{chunk-56MPPWLA.mjs → chunk-K7G3W7XH.mjs} +1 -1
- package/lib/{chunk-OU5W7SCB.mjs → chunk-KKS2KFBT.mjs} +1 -1
- package/lib/{chunk-RKALOKAU.mjs → chunk-KWAVSZ2B.mjs} +1 -1
- package/lib/{chunk-WI4HYWV6.mjs → chunk-KXUOHACP.mjs} +1 -1
- package/lib/{chunk-GTIXJCGS.mjs → chunk-L3I6DAHX.mjs} +1 -1
- package/lib/{chunk-FLNLG43R.mjs → chunk-L47JCNP3.mjs} +1 -1
- package/lib/{chunk-5344TZBT.mjs → chunk-L4MSL4U7.mjs} +1 -1
- package/lib/chunk-L4RJX7DG.mjs +7 -0
- package/lib/chunk-L6CLN664.mjs +7 -0
- package/lib/chunk-LI2XNV7F.mjs +7 -0
- package/lib/chunk-LP2D3JJP.mjs +7 -0
- package/lib/{chunk-EH5YUA5W.mjs → chunk-LWES2KZE.mjs} +1 -1
- package/lib/{chunk-YJEXE6HZ.mjs → chunk-LYOGCIYD.mjs} +2 -2
- package/lib/{chunk-BNO5GIJ6.mjs → chunk-MJD6CPZZ.mjs} +1 -1
- package/lib/{chunk-33ZX3A56.mjs → chunk-MTM4KG3T.mjs} +1 -1
- package/lib/{chunk-E2YJVSX6.mjs → chunk-N2HYG3BL.mjs} +1 -1
- package/lib/chunk-N5UIE4IR.mjs +7 -0
- package/lib/{chunk-R6TF26V4.mjs → chunk-NDFFIJL5.mjs} +1 -1
- package/lib/{chunk-FDGFUEK3.mjs → chunk-NFEBX75O.mjs} +1 -1
- package/lib/{chunk-QXLZINZB.mjs → chunk-NNV7IGM7.mjs} +1 -1
- package/lib/{chunk-OXKZ4Y3B.mjs → chunk-NS6ONPWL.mjs} +1 -1
- package/lib/{chunk-OEHVAJAB.mjs → chunk-O7GCCRPW.mjs} +1 -1
- package/lib/chunk-OO24ZYYJ.mjs +7 -0
- package/lib/chunk-OOIDCHBQ.mjs +9 -0
- package/lib/{chunk-MWLFFVQV.mjs → chunk-OS5GE52G.mjs} +1 -1
- package/lib/chunk-OS6HFJ7L.mjs +7 -0
- package/lib/{chunk-HYBH5PFM.mjs → chunk-OTJH6AEA.mjs} +1 -1
- package/lib/chunk-OUU47Y7A.mjs +7 -0
- package/lib/{chunk-FTA5LOVX.mjs → chunk-P6WRYJN3.mjs} +1 -1
- package/lib/{chunk-DXOXLUZA.mjs → chunk-PDRXM5WN.mjs} +1 -1
- package/lib/chunk-PGRY365W.mjs +7 -0
- package/lib/chunk-Q4PPI3KG.mjs +7 -0
- package/lib/chunk-QFTF2PGS.mjs +21 -0
- package/lib/chunk-QKJXIY6L.mjs +7 -0
- package/lib/{chunk-DMBR24CK.mjs → chunk-QLRWU3MB.mjs} +1 -1
- package/lib/chunk-QO4MPHZD.mjs +7 -0
- package/lib/chunk-QP3JLFIO.mjs +7 -0
- package/lib/{chunk-UCHAZ4ZU.mjs → chunk-QQDZQCO2.mjs} +1 -1
- package/lib/chunk-QROPNEGY.mjs +14 -0
- package/lib/{chunk-6NADW3OI.mjs → chunk-QXB6U3ZP.mjs} +1 -1
- package/lib/chunk-R3OM3X4L.mjs +8 -0
- package/lib/chunk-R7GKMAT4.mjs +7 -0
- package/lib/{chunk-JU2XEKEO.mjs → chunk-RVCPQVKM.mjs} +1 -1
- package/lib/{chunk-WEZLXE34.mjs → chunk-RZKJQOOC.mjs} +1 -1
- package/lib/chunk-S4PRKKGC.mjs +8 -0
- package/lib/{chunk-NJ3EOEHS.mjs → chunk-SX6QWYCQ.mjs} +1 -1
- package/lib/{chunk-ONMBSACW.mjs → chunk-T36DZJPH.mjs} +1 -1
- package/lib/{chunk-AJPSGVMD.mjs → chunk-T7DDS4UQ.mjs} +1 -1
- package/lib/chunk-TCEXCHXR.mjs +7 -0
- package/lib/chunk-TMIESDE5.mjs +7 -0
- package/lib/chunk-TQJ5NPRC.mjs +7 -0
- package/lib/chunk-TUPZY2QJ.mjs +7 -0
- package/lib/{chunk-2Z54GB6X.mjs → chunk-U2CTKIPE.mjs} +1 -1
- package/lib/{chunk-DQR5NDMI.mjs → chunk-U4YFYSF3.mjs} +1 -1
- package/lib/{chunk-EOSEMFPU.mjs → chunk-UIR77ZJD.mjs} +1 -1
- package/lib/{chunk-UUSLTW5V.mjs → chunk-UOHZW2L4.mjs} +1 -1
- package/lib/chunk-UV74P4H2.mjs +7 -0
- package/lib/{chunk-CULAOP3U.mjs → chunk-VXZ5PTOM.mjs} +1 -1
- package/lib/{chunk-IBURU7T7.mjs → chunk-VZLJZEV2.mjs} +1 -1
- package/lib/chunk-W3BQGMTR.mjs +7 -0
- package/lib/{chunk-WWTXRWNZ.mjs → chunk-WABXKL4N.mjs} +1 -1
- package/lib/{chunk-E2OBAWSH.mjs → chunk-WAYQLQAD.mjs} +1 -1
- package/lib/{chunk-6CDIIFNX.mjs → chunk-WBELLGNE.mjs} +1 -1
- package/lib/{chunk-LO527YLT.mjs → chunk-WJAZ5LHL.mjs} +1 -1
- package/lib/{chunk-6IGEASOF.mjs → chunk-WXU6ZJIV.mjs} +1 -1
- package/lib/{chunk-YHIOS2PU.mjs → chunk-WZN36ACK.mjs} +1 -1
- package/lib/{chunk-AITNZWLB.mjs → chunk-X2XZQ434.mjs} +1 -1
- package/lib/chunk-X4HZD5U2.mjs +7 -0
- package/lib/chunk-X6XNTOGO.mjs +7 -0
- package/lib/{chunk-5VQNKDFU.mjs → chunk-XAMMIPZ4.mjs} +1 -1
- package/lib/{chunk-MHW6DV6T.mjs → chunk-XAUQXYPW.mjs} +1 -1
- package/lib/{chunk-5UT2ZBGF.mjs → chunk-XCJUNX63.mjs} +1 -1
- package/lib/chunk-XJICAOAQ.mjs +7 -0
- package/lib/{chunk-GYKNCYES.mjs → chunk-XKFHTBAB.mjs} +1 -1
- package/lib/{chunk-6SEDOIO3.mjs → chunk-XMQ5R6TC.mjs} +1 -1
- package/lib/chunk-XPXEQKLR.mjs +7 -0
- package/lib/{chunk-SW2NUKQL.mjs → chunk-Y7YUNRKK.mjs} +1 -1
- package/lib/{chunk-UIUPPEFB.mjs → chunk-YBZIDW6W.mjs} +1 -1
- package/lib/{chunk-X2ZVSQ54.mjs → chunk-YEVB7LVK.mjs} +1 -1
- package/lib/{chunk-EAFLDSQ2.mjs → chunk-Z3MGN42K.mjs} +1 -1
- package/lib/{chunk-MKNAZPOT.mjs → chunk-ZB5E7NHU.mjs} +1 -1
- package/lib/chunk-ZCOSME6P.mjs +7 -0
- package/lib/{chunk-KRNFVAGC.mjs → chunk-ZOSESZ22.mjs} +1 -1
- package/lib/chunk-ZTHC42X6.mjs +7 -0
- package/lib/{chunk-XEB6HZ34.mjs → chunk-ZXOUWHYE.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 +4 -4
- package/lib/sandforge-env.mjs +184 -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 +155 -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-CAFUNR6D.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-KOQV4WXC.mjs +0 -8
- package/lib/chunk-N6HHNR6J.mjs +0 -7
- package/lib/chunk-N7J6NJQ6.mjs +0 -7
- package/lib/chunk-NWPQF5XR.mjs +0 -7
- package/lib/chunk-O7DAFE6M.mjs +0 -14
- package/lib/chunk-OMZJ37JI.mjs +0 -15
- package/lib/chunk-R2BJWO5N.mjs +0 -20
- package/lib/chunk-T26C576X.mjs +0 -9
- package/lib/chunk-T5VAULLQ.mjs +0 -7
- package/lib/chunk-V2QO6KOE.mjs +0 -19
- package/lib/chunk-V473C7LY.mjs +0 -7
- package/lib/chunk-W2AAGIZF.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,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as Le,b as je,c as $e,d as Pe,e as _,f as _e,g as xe,h as D,i as ne,l as Me,o as Je}from"./chunk-UIUPPEFB.mjs";import{a as Se}from"./chunk-YYZL7UGV.mjs";import{a as be,f as we,i as ke,j as ve,l as te}from"./chunk-54HYHHVL.mjs";import{a as E}from"./chunk-4TLYUZD5.mjs";import{c as Oe}from"./chunk-HF6LAK3G.mjs";import{a as P,b as Fe,d as Be,e as Ce,f as ee,h as Ne,i as We,j as Ee}from"./chunk-KRNFVAGC.mjs";import{Y as ce,Z as fe,_ as he,a as X,ba as pe,ca as ge,d as Q,fa as ye,ha as me,ia as Re}from"./chunk-55LQD3Y3.mjs";import{d as Ie,e as Z,f as Ae,k as Te}from"./chunk-3B5H24ZG.mjs";import{b as I}from"./chunk-CA5NAXSU.mjs";import{Tc as ue,Wb as Y,pc as le}from"./chunk-DPYTG6DM.mjs";function Ye(a){return Array.isArray(a)?a.length:(a.successfulResults?.length??0)+(a.failedResults?.length??0)}function Ue(a,e){let t=!1,n=!1,s,r={},o=0,i=0,d=(c,p)=>(i+=c,e?.(c),p()),l=async c=>{let p=await d(We,c);return o=Ye(p),p},u={createJob:c=>{let p=a.bulk2.createJob(c);return{get id(){return p.id},open:async()=>{await d(1,()=>p.open()),s=Ce(p)},uploadData:w=>d(1,()=>p.uploadData(w)),close:async()=>{t=!0,await d(1,()=>p.close()),n=!0},abort:()=>d(1,()=>p.abort()),check:async()=>{let w=await d(1,()=>p.check());return r={state:w.state,message:w.errorMessage},w},getAllResults:()=>l(()=>p.getAllResults())}}};if("job"in a.bulk2){let c=a.bulk2;u.job=(p,w)=>{let R=c.job(p,w);return{check:async()=>{let y=await d(1,()=>R.check());return r={state:y.state,message:y.errorMessage??void 0},y},getSuccessfulResults:()=>d(1,()=>R.getSuccessfulResults()),getAllResults:()=>l(()=>R.getAllResults()),abort:()=>d(1,()=>R.abort())}}}return{connection:{bulk2:u},closeSent:()=>t,closed:()=>n,jobId:()=>s,last:()=>r,processed:()=>o,requests:()=>i}}var L=class extends Error{constructor(t,n,s=0,r=[]){super(`Bulk API job ${t||"(no id)"} was closed, and what it wrote could not be read back: ${n}`);this.jobId=t;this.requests=s;this.twins=r;this.name="BulkJobLostError"}jobId;requests;twins},M=1e4,q=50*1024*1024,Xe=10,Qe=/not supported by the Bulk API|InvalidEntity/i,Ze={unprocessed:"The Bulk API job did not write this row.",twin:"Kept out of the Bulk API job: another row carries the same values, and the job's results could not tell them apart.","may-have-written":"The Bulk API job may have written this row without saying so: it is not sent again."};async function Pt(a,e,t,n,s,r={}){let o=n==="insert"?s.map(nt):s,i=Fe(P(n,o,r.externalIdField)),d=[];o.forEach((k,A)=>{i.has(A)||d.push(A)});let l=d.map(k=>o[k]),u=o.map((k,A)=>i.has(A)?"twin":"unprocessed"),c=k=>({answers:u.map(A=>x(A==="twin"?"twin":"unprocessed")),rows:u,unmatchedIds:[],...k});if(l.length===0)return c({requests:0});let p=P(n,l,r.externalIdField),w=Buffer.byteLength(p.text,"utf8");if(l.length>M||w>q)return c({requests:0,untouched:{reason:`${l.length} rows, ${w} bytes of CSV: past what one job takes (${M} rows, ${q} bytes)`}});let R=(k,A,h,v)=>{let F={requests:k.requests,...k.jobId?{jobId:k.jobId}:{}};if(k.info.state!=="JobComplete"&&k.processed===0&&v===0)return c({...F,untouched:re(ee(k.info)??"job not complete")});let W=new Map(A.map(m=>[m.recordIndex,m])),f=u.map(m=>x(m==="twin"?"twin":"unprocessed"));return d.forEach((m,S)=>{let N=tt(W.get(S),v>0);u[m]=N.state,f[m]=N.answer}),{answers:f,rows:u,unmatchedIds:[...h],...F}},y=Ue(a),b,T=()=>b?{jobId:b}:{},B=r.pollDelay??Ee,g;try{g=await new Ne().executeBulk({connection:y.connection,bulkManager:e,pollIntervalMs:B,...r.signal?{signal:r.signal}:{},...r.onProgress?{onProgress:r.onProgress}:{},onOpened:k=>{b=k,r.onOpened?.(k)}},t,n,l,r.externalIdField)}catch(k){let A=I(k);if(!y.closeSent())return c({requests:y.requests(),...T(),untouched:re(A)});if(b===void 0)throw new L("",A,y.requests(),[...i]);let h=await et(y.connection,b,B);if(h.state==="never-closed")return c({requests:y.requests(),jobId:b,untouched:re(A)});if(h.state!=="ended")throw new L(b,h.state==="unread"?h.reason:"still running",y.requests(),[...i]);let v=Be(h.results,p,ee(h.info));return R({info:h.info,processed:y.processed(),requests:y.requests(),jobId:b},v.outcomes,v.unattributedSuccessIds,v.unattributedSuccesses)}if(g.aborted)return c({requests:y.requests(),...T(),aborted:!0});let C=y.last();return R({info:{state:C.state??"JobComplete",...C.message?{errorMessage:C.message}:{}},processed:y.processed(),requests:y.requests(),...T()},g.outcomes,g.unmatchedIds??[],g.unmatchedWrites??0)}async function et(a,e,t){let n=await te(a,e,{openGraceMs:0});for(let s=1;s<Xe;s++){if(n.state==="ended"||n.state==="never-closed")return n;await new Promise(r=>setTimeout(r,t(s-1))),n=await te(a,e,{openGraceMs:0})}return n}function re(a){return Qe.test(a)?{reason:a,unsupported:!0}:{reason:a}}function x(a){return{id:"",success:!1,errors:[Ze[a]]}}function tt(a,e){if(a===void 0||a.state==="no-result"){let s=e?"may-have-written":"unprocessed";return{state:s,answer:x(s)}}if(a.state==="unprocessed")return{state:"unprocessed",answer:x("unprocessed")};if(a.success)return a.id?{state:"answered",answer:{id:a.id,success:!0,errors:[],...a.created!==void 0?{created:a.created}:{}}}:{state:"may-have-written",answer:x("may-have-written")};let t=a.error??"Unknown error",n=Ie(t);return{state:"answered",answer:n?{id:"",success:!1,errors:[Ae(n)],errorDetails:[n]}:{id:"",success:!1,errors:[t]}}}function nt(a){let e;for(let[t,n]of Object.entries(a))n===""&&(e??={...a},e[t]=null);return e??a}var ae={rest:200,bulk:1e4},Ke=3,ot=3,De=3,it=2e3;function at(a){return new Promise(e=>setTimeout(e,a))}function dt(a,e,t={bulk:!1}){let n=t.bulk&&a.api==="bulk"&&e>=2e3?"bulk":"rest",s=Math.min(a.batchSize,ae[n]);return{api:n,batchSize:s,batchCount:Math.ceil(e/s),clamped:s<a.batchSize}}function z(a){return a.refusals.flatMap(e=>e.leftOut)}function se(a){let e=a.built?.source.Id;return typeof e=="string"?e:void 0}function qe(a){return(a.built?.nullifiedFks??[]).map(({field:e,sourceRefId:t,insertOnly:n})=>({field:e,sourceRefId:t,...n?{insertOnly:n}:{}}))}function lt(a){let e=a.RecordTypeId;return typeof e=="string"&&e!==""}function oe(a){return a.refusals.length===0?a.payload:D(a.payload,z(a))}function He(a,e){let t=new Map;return e?.refusedIn?.answers.forEach((n,s)=>{let r=a[s];n&&r&&t.set(r,n.errors)}),t}var ut=new Set,ct=new Map;function H(a){return{objectApiName:a.objectApiName,op:a.upsertField?"upsert":"insert"}}function Ve(a){return a!==void 0&&!a.success?ue(a.errors):void 0}function ft(a){let e=a.automation??"the target's automation";E.warn(`[forge] ${a.objectApiName}: ${e} hit ${a.limit??"a Salesforce limit"} on a call of ${a.from} \u2014 sending a record on its own, then smaller calls`+(a.op==="upsert"?" (upsert).":"."))}var V={"validation-rule":"a validation rule","restricted-picklist":"a restricted picklist","lookup-filter":"a lookup filter","inactive-owner":"the target, the owner being inactive there"};function ht(a){let e=new Set(a.map(o=>o.refusedBy)),t=Object.keys(V).filter(o=>o!=="inactive-owner"&&e.has(o)).map(o=>V[o]),n=t.length>1?`${t.slice(0,-1).join(", ")} or ${t[t.length-1]}`:t[0],s=n===void 0?void 0:`${n} of the target`;if(!e.has("inactive-owner"))return s??`${V["validation-rule"]} of the target`;let r=`${V["inactive-owner"]},`;return s===void 0?r:`${s} or ${r}`}function ie(a,e){if(!a.ownersMapped||a.ownersMapped.size===0)return!1;let t=_(e,"OwnerId"),n=t===void 0?void 0:e[t];return typeof n=="string"&&a.ownersMapped.has(n.slice(0,15))}function pt(a,e,t,n,s){let r=a.errorDetails??[];if(r.length===a.errors.length)return _e(r,e,t,n,s)}function ze(a){a.linkedToCreatedCount=(a.linkedToCreatedCount??0)+1}function gt(a){let e=a.errorDetails??[];return Je(a.errors,e.length===a.errors.length?e:void 0)}function G(a){return a.map(e=>e.field).join(", ")}function yt(a,e){return`Sent again without ${G(a)} after the first refusal: ${e.join("; ")}`}var mt=["first","second","third"];function J(a){return a.map(({leftOut:e,errors:t},n)=>n===0?yt(e,t):`Sent again without ${G(e)} too after the ${mt[n]} refusal: `+t.join("; "))}function U(a){let e=(t,n)=>t.length===0?[]:[`Sent without ${G(t)}: ${n} earlier in the run, `+[...new Set(t.map(s=>s.reason))].join("; ")];return[...e(a.filter(t=>t.refusedBy!=="inactive-owner"),"the target refused the same value under the same record type"),...e(a.filter(t=>t.refusedBy==="inactive-owner"),"the target refused the same owner, inactive there,")]}function O(a){return`${a} record${a===1?"":"s"}`}var Rt="The call was sent and its answer never came back: the target may hold any of these records, and which of them is unknown. Counted as failed and never sent again, they are not among the records the run created, which removing its records takes back.",bt="Counted as failed and never sent again, they are not among the records the run created; the records the job wrote that no row was matched to are, and removing the run's records takes them back.",wt="DUPLICATES_DETECTED";function kt(a,e){if(a==="twin"||a==="unprocessed")return!0;if(a!=="answered"||e.success)return!1;let t=e.errorDetails;return t?.length!==1||t[0].statusCode===wt}function vt(a,e){let t=i=>i.reduce((d,l)=>d+Math.max(Buffer.byteLength(l,"utf8"),4)+(l.split('"').length-1)+3,1),n=t(e.columns),s=[],r=0,o=n;return e.rows.forEach((i,d)=>{let l=t(i);d>r&&o+l>a&&(s.push([r,d]),r=d,o=n),o+=l}),e.rows.length>r&&s.push([r,e.rows.length]),s}function It(a,e,t){let n=a.find(r=>r.isReference&&r.nillable===!1&&r.name!=="OwnerId"&&e.has(r.name))?.name;if(n===void 0)return;let s=r=>{let o=t[r][n];return typeof o=="string"?o:""};if(t.some((r,o)=>s(o)!==""))return t.map((r,o)=>o).sort((r,o)=>{let i=s(r),d=s(o);return i===d?r-o:i===""?1:d===""||i<d?-1:1})}var At="The target refused the call for its API request limit, which no retry gets past: the node stopped there.",Tt="A validation rule of the target, or a trigger with its code, refused the row without naming a field: there was none to send it again without.";function Ft(){return{successCount:0,updatedCount:0,linkedExistingCount:0,failureCount:0,alreadyExistsCount:0,unidentifiedExistingCount:0,errorSamples:[],pendingFkUpdates:[]}}var Ge=class{constructor(e,t,n=at,s=be()){this.deps=e;this.wait=n;this.splitting=s;this.batchStrategy=t??new Oe}deps;wait;splitting;batchStrategy;refusedValues=new Map;refusedOwners=new Map;backoff=new Me({initialDelay:it});async writeNode(e,t=Ft()){let{node:n,fieldInfos:s,creatableFields:r,targetOrgId:o,remapper:i}=e,d=await this.heldBeforeInsert(n.objectApiName,o,e.records);for(let[h,v]of d){let F=e.cleanedRecords[h]?.source,W=F?.Id;if(typeof W!="string")continue;i.addExisting(W,v,n.objectApiName);let f=F?.ContactId;n.objectApiName===X&&typeof f=="string"&&i.wasCreated(f)&&(t.withTheirRecord=[...t.withTheirRecord??[],W])}t.linkedExistingCount+=d.size;let l=await this.giveFlagsBack(n.objectApiName,o,e,d);l&&(t.flagsNotKept=pe(t.flagsNotKept,l));let u=e.records.filter((h,v)=>!d.has(v)),c=e.cleanedRecords.filter((h,v)=>!d.has(v)),p=this.batchStrategy.resolve(n.batchStrategy,u.length),{api:w,batchSize:R,batchCount:y,clamped:b}=dt(p,u.length,{bulk:this.jobsCanCarry(e.bulk,n.objectApiName)});if(b&&E.warn(`[forge] ${n.objectApiName}: batch strategy asked for ${p.batchSize} records per call (api="${p.api}") but the write path is "${w}" (max ${ae[w]}) \u2014 using ${R} per call (${y} batch(es)).`),w==="bulk"){let h=It(s,r,u);if(h){let v={records:u,cleanedRecords:c};u=h.map(F=>v.records[F]),c=h.map(F=>v.cleanedRecords[F])}}e.onProgress({objectName:n.objectApiName,status:"running",progress:0,recordCount:u.length,fieldCount:s.length,createableFieldCount:r.size,message:`Inserting ${u.length} ${n.objectApiName} records in ${y} batch(es)...`});let T=0,B=this.pickUpsertField(s,r,u,e.upsertMode==="auto"&&this.deps.upsertRecords?"auto":"off",e.tableKeys),g={objectApiName:n.objectApiName,targetOrgId:o,targetKeyPrefix:e.targetKeyPrefix,remapper:i,tally:t,oweLookups:e.oweLookups,onWritten:e.onWritten,onCreatedWithoutRecordType:e.onCreatedWithoutRecordType,calls:e.calls,bulk:e.bulk,byNaturalKey:[],refusedOnTheirFields:[],locked:[],upsertField:B,ownersMapped:e.ownersMapped,remembered:new Set([...e.picklistFields??[]].filter(([,h])=>h.controllerName===void 0).map(([h])=>h.toLowerCase()))},{byNaturalKey:C}=g,k=h=>{let v=I(h);this.leaveLockedAsFailed(g,g.locked.splice(0),v),this.leaveRefusedAsFailed(g,g.refusedOnTheirFields.splice(0),v),this.settleByNaturalKey(n.objectApiName,C,[],i,t,`The record the target holds under the same key was not looked up: ${v}`)};for(let h=0;h<y;h++){let v=u.slice(h*R,(h+1)*R).map((m,S)=>{let{sent:N,before:$}=this.withoutRefusedValues(g,m);return{payload:N,built:c[T+S],before:$,refusals:[],lockResends:0}}),F=`${n.objectApiName} batch ${h+1}/${y}`,W;try{W=await this.sendRows(g,e,v,F,u.length-T-v.length)}catch(m){throw k(m),m}if(W){let m=I(W.thrown);this.leaveLockedAsFailed(g,g.locked.splice(0),m),this.leaveRefusedAsFailed(g,g.refusedOnTheirFields.splice(0),m);break}T+=v.length;let f;try{f=await this.sendLockedAgain(g,e,u.length-T)}catch(m){throw k(m),m}if(f){this.leaveRefusedAsFailed(g,g.refusedOnTheirFields.splice(0),I(f.thrown));break}e.onProgress({objectName:n.objectApiName,status:"running",progress:Math.round((h+1)/y*100),message:`batch ${h+1}/${y} \u2014 ${Math.min((h+1)*R,u.length)}/${u.length} records`})}try{await this.writeAgainWithoutTheirFields(g,e,Math.min(R,ae.rest))}catch(h){throw k(h),h}let A=Q[n.objectApiName];if(A&&C.length>0){let h,v;try{h=await this.recordsByNaturalKey(o,n.objectApiName,A,C.map(F=>F.payload))}catch(F){h=[],v=`The record the target holds under the same key could not be looked up: ${I(F)}`}this.settleByNaturalKey(n.objectApiName,C,h,i,t,v)}return t}send(e,t){return e.upsertField&&this.deps.upsertRecords?this.deps.upsertRecords(e.targetOrgId,e.objectApiName,e.upsertField,t):this.deps.insertRecords(e.targetOrgId,e.objectApiName,t)}jobsCanCarry(e,t){return e!==void 0&&this.deps.bulkWriteRecords!==void 0&&!e.restOnly.has(t)&&!e.bulkUnsupported.has(t)}goesSmallerByRest(e){return this.splitting.sizes.of(e)<200}async sendRows(e,t,n,s,r,o){let{bulk:i}=e;if(!i||!this.jobsCanCarry(i,e.objectApiName)||n.length<2e3)return this.sendByRest(e,t,n,s,r,o);for(let d=0;d<n.length;d+=M){let l=n.slice(d,d+M),u=n.length-d-l.length+r,c;try{c=l.length>=2e3?await this.writeAsJobs(e,t,i,l,s,u,o):await this.sendByRest(e,t,l,s,u,o)}catch(p){throw o?.(n.slice(d+l.length),I(p)),p}if(c)return c}}async sendByRest(e,t,n,s,r,o,i){if(n.length===0)return;try{await t.waitIfPaused()}catch(l){let u=I(l);throw o?o(n,u):this.leaveLimitedAsFailed(e,n,He(n,i),u),l}let d=await this.callAndSettle(e,t,n,o,i);if(d)return this.settleThrown(e,d.threw,d.rows,s,d.rest.length+r),d.threw}async writeAsJobs(e,t,n,s,r,o,i){let d=this.deps.bulkWriteRecords;if(!d)return this.sendByRest(e,t,s,r,o,i);let l=H(e);if(this.goesSmallerByRest(l))return this.sendJobByRest(e,t,n,s,r,o,i);let u=e.upsertField?"upsert":"insert",c=s.map(oe),p=vt(q,P(u,c,e.upsertField));for(let[w,R]of p){let y=s.slice(w,R),b=s.length-R+o;if(this.goesSmallerByRest(l)){let f;try{f=await this.sendJobByRest(e,t,n,y,r,b,i)}catch(m){throw i?.(s.slice(R),I(m)),m}if(f)return f;continue}try{await t.waitIfPaused()}catch(f){throw i?.(s.slice(w),I(f)),f}let T=c.slice(w,R),B=e.calls?.sending(e.objectApiName,y.map((f,m)=>({sourceId:se(f),payload:T[m],owes:qe(f)})),e.upsertField,!0),g;try{g=await d(e.targetOrgId,e.objectApiName,u,T,{bulkManager:n.manager,signal:n.signal,...e.upsertField?{externalIdField:e.upsertField}:{},onOpened:f=>{B!==void 0&&e.calls?.opened?.(B,f)}})}catch(f){if(f instanceof L){let m={thrown:f,left:"may-have-written",tries:1},S=new Set(f.twins),N=y.filter(($,de)=>!S.has(de));return this.settleThrown(e,m,N,`${r} (Bulk API job)`,b),this.leaveTwinsUnsent(e,y.length-N.length,r,f),m}g={answers:[],rows:[],unmatchedIds:[],untouched:{reason:I(f)},requests:0}}if(g.aborted){try{await t.waitIfPaused()}catch(f){throw B!==void 0&&e.calls?.answered(B),i?.(s.slice(w),I(f)),f}g={...g,untouched:{reason:"the job was aborted"}}}if(g.untouched){B!==void 0&&e.calls?.answered(B),g.untouched.unsupported&&n.bulkUnsupported.add(e.objectApiName),E.warn(`[forge] ${e.objectApiName}: a Bulk API job of ${O(y.length)} wrote nothing (${g.untouched.reason}) \u2014 sent by REST`+(g.untouched.unsupported?", as every write of the object in the run.":"."));let f;try{f=await this.sendByRest(e,t,y,r,b,i)}catch(m){throw i?.(s.slice(R),I(m)),m}if(f)return f;continue}g.unmatchedIds.length>0&&(e.calls?.unattributed?.(e.objectApiName,g.unmatchedIds),E.warn(`[forge] ${e.objectApiName}: Bulk API job ${g.jobId??""} wrote ${O(g.unmatchedIds.length)} no row was matched to \u2014 kept for removal.`));let C=[],k=[],A=[],h=[],v=[],F=[],W;if(y.forEach((f,m)=>{let S=g.rows[m]??"unprocessed",N=g.answers[m],$=S==="answered"?Ve(N):void 0;S==="may-have-written"?F.push(f):$!==void 0&&N!==void 0?(W??=$,h.push(f),v.push(N)):!N||kt(S,N)?A.push(f):(C.push(f),k.push(N))}),this.settleMayHaveBeenWritten(e,F,r,g.jobId),await this.settleAnswers(e,C,B===void 0?{answers:k}:{answers:k,callId:B}),A.length>0){let f;try{f=await this.sendByRest(e,t,A,`${r}, by REST`,h.length+b,i)}catch(m){throw i?.([...h,...s.slice(R)],I(m)),m}if(f)return f}if(h.length>0){let f;try{f=await this.sendByRest(e,t,h,`${r}, by REST`,b,i,{refusedIn:{from:200,answers:v,...W?{cause:W}:{}}})}catch(m){throw i?.(s.slice(R),I(m)),m}if(f)return f}}}async sendJobByRest(e,t,n,s,r,o,i){let d=H(e),{sizes:l,allowance:u}=this.splitting,c=l.of(d),p=Math.ceil(s.length/c),w=u.take(d,p);l.countExtraCalls(d,w);let R=s.slice(0,w*c),y=s.slice(R.length);if(R.length>0){let b;try{b=await this.sendByRest(e,t,R,r,y.length+o,i,{pricedAs:"job",paid:{calls:w}})}catch(T){throw i?.(y,I(T)),T}finally{w<p&&l.spend(d)}if(b)return b}else w<p&&l.spend(d);if(y.length!==0)return y.length>=2e3?this.writeAsJobs(e,t,n,y,r,o,i):this.sendByRest(e,t,y,r,o,i)}leaveTwinsUnsent(e,t,n,s){t!==0&&(e.tally.failureCount+=t,this.sample(e.tally,{recordSummary:`${n}: ${O(t)} not written`,messages:[I(s),"Kept out of the Bulk API job as twins of other rows, to be written by REST once it answered: never sent, the target holds none of them."]}))}settleMayHaveBeenWritten(e,t,n,s){if(t.length===0)return;let{tally:r}=e;r.failureCount+=t.length;let o=t.map(se).filter(i=>i!==void 0);r.mayHaveBeenWritten=[...r.mayHaveBeenWritten??[],...o],this.sampleAhead(r,{recordSummary:`${n}: ${O(t.length)} may have been written`,messages:[`Bulk API job ${s??""} gave them no result of their own, and wrote records no row was matched to: the target may hold any of these records, and which of them is unknown.`,bt]})}async call(e,t,n){let s=n.map(oe);for(let r=0;;r++){let o=e.calls?.sending(e.objectApiName,n.map((i,d)=>({sourceId:se(i),payload:s[d],owes:qe(i)})),e.upsertField);try{let i=await this.send(e,s);return o===void 0?{answers:i}:{answers:i,callId:o}}catch(i){let d=Se(i);if(o!==void 0&&d!=="may-have-written"&&e.calls?.answered(o),d!=="not-received"||r===Ke)return{thrown:i,left:d,tries:r+1};let l=this.backoff.calculateDelay(r);E.warn(`[forge] ${e.objectApiName}: a call of ${O(s.length)} never reached the target (${I(i)}) \u2014 sent again in ${l} ms (${r+1}/${Ke}).`),await this.wait(l),await t.waitIfPaused()}}}async callAndSettle(e,t,n,s,r){let o,i={answers:[]},d=He(n,r),{stopped:l}=await ve(n,{key:H(e),sizes:this.splitting.sizes,allowance:this.splitting.allowance,...r,beforeEachSend:()=>t.waitIfPaused(),send:async u=>{let c=await this.call(e,t,u);return"thrown"in c?(o=c,"stop"):(i=c,{answers:c.answers})},limited:(u,c)=>{let p=Ve(u);return p&&u&&d.set(c,u.errors),p},settle:(u,c,p,w,R)=>this.settleAnswers(e,u,R?{answers:c}:i,p,w),onThrow:(u,c)=>{let p=I(c);s?s(u,p):this.leaveLimitedAsFailed(e,u,d,p)},onFirstRefusal:ft});if(!(!l||o===void 0))return{threw:o,rows:l.part,rest:l.rest}}sample(e,t){e.errorSamples.length<3&&e.errorSamples.push(t)}sampleAhead(e,t){e.errorSamples.unshift(t),e.errorSamples.splice(3)}async settleAnswers(e,t,{answers:n,callId:s},r=ut,o=ct){t.forEach((i,d)=>{let l=n[d];l?.success&&!r.has(d)&&this.settle(e,l,i)}),e.remapper.persist(),await this.readWhatMayBeEmpty(e,n.filter(i=>i!==void 0)),t.forEach((i,d)=>{if(r.has(d))return;let l=n[d];if(l){l.success||this.settle(e,l,i,o.get(d));return}e.tally.failureCount++,this.sample(e.tally,{recordSummary:j(i.payload),messages:[`No result returned for record (API truncated batch: ${n.length}/${t.length})`,...J(i.refusals),...U(i.before)]})}),e.remapper.persist(),s!==void 0&&e.calls?.answered(s)}async readWhatMayBeEmpty(e,t){if(e.mayBeEmpty!==void 0||!t.some(r=>(r.errorDetails??[]).some(o=>o.statusCode===je)))return;let s=await this.deps.describeFields?.(e.targetOrgId,e.objectApiName).catch(()=>{});e.mayBeEmpty=new Set((s??[]).filter(r=>r.nillable===!0).map(r=>r.name.toLowerCase()))}settleThrown(e,t,n,s,r){let{tally:o}=e,i=I(t.thrown);if(o.failureCount+=n.length+r,t.left==="may-have-written"){let l=n.map(u=>u.built?.source.Id).filter(u=>typeof u=="string");o.mayHaveBeenWritten=[...o.mayHaveBeenWritten??[],...l],this.sampleAhead(o,{recordSummary:`${s}: ${O(n.length)} may have been written`,messages:[i,Rt,...r>0?[`${O(r)} after them not sent.`]:[]]});return}let d=n.length+r;this.sample(o,{recordSummary:`${s}: ${O(d)} not written`,messages:[i,...t.left==="request-limit"?[At]:[],...t.left==="not-received"?[`Sent ${t.tries} times, the call never reached the target: it holds none of them.`]:[]]})}async sendLockedAgain(e,t,n){for(let s=0;e.locked.length>0;s++){let r=this.backoff.calculateDelay(s);E.warn(`[forge] ${e.objectApiName}: the target could not lock a record for ${O(e.locked.length)} \u2014 sent again in ${r} ms.`),await this.wait(r),await t.waitIfPaused();let o=e.locked.splice(0),i=o.map(({row:u})=>({...u,lockResends:u.lockResends+1})),d=new Map(i.map((u,c)=>[u,o[c]])),l=await this.callAndSettle(e,t,i,(u,c)=>this.leaveLockedAsFailed(e,u.flatMap(p=>d.get(p)??[]),c));if(l)return this.settleThrown(e,l.threw,l.rows,`${e.objectApiName}, sent again`,n+l.rest.length),this.leaveLockedAsFailed(e,e.locked.splice(0),I(l.threw.thrown)),l.threw}}settle(e,t,n,s){let{tally:r,remapper:o,objectApiName:i}=e,{built:d,before:l}=n,u=oe(n);if(t.success){let b=d?.source.Id,T=t.created===!1;if(T?r.updatedCount++:r.successCount++,typeof b=="string"&&(T?o.addUpdated(b,t.id,i):o.add(b,t.id,i)),d&&e.onWritten?.(d,t.id),!T&&!lt(u)&&e.onCreatedWithoutRecordType?.(d,t.id),d&&d.nullifiedFks.length>0){let g=typeof d.source.Id=="string"?d.source.Id:void 0,C=d.nullifiedFks.map(k=>({objectApiName:i,newId:t.id,sourceId:g,fieldName:k.field,sourceRefId:k.sourceRefId,...k.insertOnly?{insertOnly:!0}:{}}));e.oweLookups?e.oweLookups(C):r.pendingFkUpdates.push(...C)}let B=[...l,...z(n)];B.length>0&&(r.writtenWithoutFields=ne(r.writtenWithoutFields,{rows:1,fields:B.map(g=>({...g,rows:1}))}));for(let{field:g,refusedBy:C}of B)C!=="lookup-filter"||!t.id||(r.leftEmptyByFilter??=[]).push({field:g,recordId:t.id});return}this.rememberRefusedValues(e,t,u),this.rememberRefusedOwners(e,t,u);let c=Te(t,e.targetKeyPrefix);if(c.kind==="linked"){r.linkedExistingCount++,o.createdTarget(c.id)&&ze(r);let b=d?.source.Id;typeof b=="string"&&o.addExisting(b,c.id,i);return}if(c.kind==="unidentified"&&Q[i]){e.byNaturalKey.push({payload:u,sourceId:d?.source.Id,errors:t.errors});return}let p=gt(t);if(p&&n.lockResends<ot){e.locked.push({row:n,errors:t.errors});return}let w=b=>e.mayBeEmpty?.has(b.toLowerCase())??!1,R=pt(t,u,e.upsertField,w,{inactiveOwner:!ie(e,u)}),y=n.refusals.length<De;if(R&&y){e.refusedOnTheirFields.push({...n,refusals:[...n.refusals,{errors:t.errors,leftOut:R}]});return}r.failureCount++,c.kind==="unidentified"&&r.unidentifiedExistingCount++,t.errors.every(b=>Y(b))&&r.alreadyExistsCount++,this.sample(r,{recordSummary:j(n.payload),messages:[...t.errors,...J(n.refusals),...p?[`Sent again ${n.lockResends} times, the target still could not lock a record the write needed.`]:[],...R&&!y?[`Not sent again: a row goes again without the fields the target refused ${De} times at most.`]:[],...xe(t.errorDetails)?[Tt]:[],...s?[we(s,ke(this.splitting.allowance,H(e)),"run")]:[],...U(l)]})}refusedValueKey(e,t,n){let s=t.RecordTypeId,r=t[n];if(typeof s!="string"||s===""||typeof r!="string"||r==="")return;let o=n.toLowerCase();if(!(!e.remembered.has(o)||o===e.upsertField?.toLowerCase()))return[e.objectApiName,s,o,r].join("\0")}rememberRefusedValues(e,t,n){for(let s of t.errorDetails??[])if(s.statusCode===Le)for(let r of s.fields){let o=_(n,r),i=o===void 0?void 0:this.refusedValueKey(e,n,o);o===void 0||i===void 0||this.refusedValues.has(i)||this.refusedValues.set(i,{field:o,refusedBy:"restricted-picklist",reason:Z(s)})}}rememberRefusedOwners(e,t,n){let s=_(n,"OwnerId");if(!(s===void 0||s.toLowerCase()===e.upsertField?.toLowerCase())&&!ie(e,n))for(let r of t.errorDetails??[]){if(r.statusCode!==$e)continue;let o=Pe(r,n);o===void 0||this.refusedOwners.has(o)||this.refusedOwners.set(o,{field:"OwnerId",refusedBy:"inactive-owner",reason:Z(r)})}}withoutRefusedValues(e,t){let n=[];if(this.refusedValues.size===0&&this.refusedOwners.size===0)return{sent:t,before:n};for(let o of Object.keys(t)){let i=this.refusedValueKey(e,t,o),d=i===void 0?void 0:this.refusedValues.get(i);d&&n.push({...d,field:o})}let s=_(t,"OwnerId"),r=s===void 0?void 0:t[s];if(s!==void 0&&typeof r=="string"&&s.toLowerCase()!==e.upsertField?.toLowerCase()&&!ie(e,t)){let o=this.refusedOwners.get(r.slice(0,15));o&&n.push({...o,field:s})}return n.length===0?{sent:t,before:n}:{sent:D(t,n),before:n}}leaveRefusedAsFailed(e,t,n){for(let s of t){let r=s.refusals[s.refusals.length-1];e.tally.failureCount++,this.sample(e.tally,{recordSummary:j(s.payload),messages:[...r?.errors??[],...J(s.refusals.slice(0,-1)),`Not written again without ${G(z(s))}: ${n}`,...U(s.before)]})}}leaveLimitedAsFailed(e,t,n,s){for(let r of t){let o=n.get(r);o&&(e.tally.failureCount++,this.sample(e.tally,{recordSummary:j(r.payload),messages:[...o,...J(r.refusals),`Not sent again in a smaller call: ${s}`,...U(r.before)]}))}}leaveLockedAsFailed(e,t,n){for(let{row:s,errors:r}of t)e.tally.failureCount++,this.sample(e.tally,{recordSummary:j(s.payload),messages:[...r,...J(s.refusals),`Not sent again: ${n}`,...U(s.before)]})}async writeAgainWithoutTheirFields(e,t,n){for(;e.refusedOnTheirFields.length>0;){let s=e.refusedOnTheirFields.splice(0);if(t.onProgress({objectName:e.objectApiName,status:"running",progress:100,message:`Writing ${s.length} ${e.objectApiName} record${s.length===1?"":"s"} again without the fields ${ht(s.flatMap(z))} refused...`}),this.jobsCanCarry(e.bulk,e.objectApiName)&&s.length>=2e3){let r=`${e.objectApiName}, sent again`,o=await this.sendRows(e,t,s,r,0,(i,d)=>this.leaveRefusedAsFailed(e,i,d));if(o??=await this.sendLockedAgain(e,t,0),o){let i=I(o.thrown);this.leaveLockedAsFailed(e,e.locked.splice(0),i),this.leaveRefusedAsFailed(e,e.refusedOnTheirFields.splice(0),i);return}continue}for(let r=0;r<s.length;r+=n){let o=s.slice(r,r+n),i;try{await t.waitIfPaused()}catch(l){throw this.leaveRefusedAsFailed(e,s.slice(r),I(l)),l}try{i=await this.callAndSettle(e,t,o,(l,u)=>this.leaveRefusedAsFailed(e,l,u))}catch(l){throw this.leaveRefusedAsFailed(e,s.slice(r+n),I(l)),l}let d;if(i){d=i.threw;let l=I(i.threw.thrown),u=[...i.rest,...s.slice(r+n)];i.threw.left==="may-have-written"?(this.settleThrown(e,i.threw,i.rows,`${e.objectApiName}, sent again`,0),this.leaveRefusedAsFailed(e,u,l)):this.leaveRefusedAsFailed(e,[...i.rows,...u],l)}else{try{d=await this.sendLockedAgain(e,t,0)}catch(l){throw this.leaveRefusedAsFailed(e,s.slice(r+n),I(l)),l}d&&this.leaveRefusedAsFailed(e,s.slice(r+n),I(d.thrown))}if(d){this.leaveRefusedAsFailed(e,e.refusedOnTheirFields.splice(0),I(d.thrown));return}}}}settleByNaturalKey(e,t,n,s,r,o){t.forEach((i,d)=>{let l=n[d];if(l&&typeof i.sourceId=="string"){s.createdTarget(l)&&ze(r),s.addExisting(i.sourceId,l,e),r.linkedExistingCount++;return}r.failureCount++,r.unidentifiedExistingCount++,i.errors.every(u=>Y(u))&&r.alreadyExistsCount++,r.errorSamples.length<3&&r.errorSamples.push({recordSummary:j(i.payload),messages:o?[...i.errors,o]:i.errors})})}async recordsByNaturalKey(e,t,n,s){let r=this.deps.queryRecords;return r?Re(o=>r(e,o),t,n,s):s.map(()=>{})}async giveFlagsBack(e,t,n,s){let r=this.deps.updateRecords;if(!r||s.size===0||!he[e])return;let o=[];for(let[d,l]of s){let u=n.cleanedRecords[d]?.source;u&&o.push([u,l])}let i=await this.deps.describeFields?.(t,e).catch(()=>{});return ge(e,o,d=>i?.find(l=>l.name===d)?.updateable!==!1,d=>r(t,e,d),n.stopped)}async heldBeforeInsert(e,t,n){let s=this.deps.queryRecords;if(!s)return new Map;let r=o=>s(t,o);return e===X?ye(r,n):ce[e]!==void 0?fe(r,e,n):e===le?me(r,n):new Map}pickUpsertField(e,t,n,s,r){if(s==="off"||!this.deps.upsertRecords)return;let o=e.filter(i=>i.externalId&&t.has(i.name)).sort((i,d)=>i.name.localeCompare(d.name));if(r)return this.tableKeyOfThePage(o,n,r);if(o.length!==0){for(let i of o){let d=new Set,l=!0;for(let u of n){let c=u[i.name];if(typeof c!="string"||c.length===0){l=!1;break}if(d.has(c)){l=!1;break}d.add(c)}if(l)return E.info(`[forge] upsert: using "${i.name}" as external Id (unique across ${n.length} records)`),i.name}E.warn(`[forge] upsert: no externalId candidate is non-null+unique across batch (${o.map(i=>i.name).join(", ")}) \u2014 falling back to insert`)}}tableKeyOfThePage(e,t,n){let s=e.find(o=>n.unique.has(o.name))?.name;if(s===void 0){e.length>0&&E.warn(`[forge] upsert: no externalId candidate is non-null+unique across the rows read (${e.map(o=>o.name).join(", ")}) \u2014 falling back to insert`);return}let r=new Set;for(let o of t){let i=o[s];if(typeof i!="string"||i.length===0||r.has(i)){E.warn(`[forge] upsert: a row of this page leaves "${s}" empty or repeats it \u2014 inserting the page`);return}if(n.sent.has(i)){E.warn(`[forge] upsert: a row of this page repeats a "${s}" an earlier page sent \u2014 inserting the page`);return}r.add(i)}n.sent.size===0&&E.info(`[forge] upsert: using "${s}" as external Id (unique across the rows read of the object)`);for(let o of r)n.sent.add(o);return s}};function j(a){let e=Object.keys(a).slice(0,4),t=[];for(let n of e){let s=a[n],r;if(s===null)r="null";else if(s===void 0)r="undefined";else if(typeof s=="string")r=s.length>30?s.slice(0,30)+"\u2026":s;else if(typeof s=="object")try{let o=JSON.stringify(s);r=o.length>30?o.slice(0,30)+"\u2026":o}catch{r="<unserializable>"}else r=String(s);t.push(`${n}=${r}`)}return t.join(" ")||"(empty)"}export{L as a,M as b,Pt as c,ae as d,dt as e,lt as f,pt as g,yt as h,Ft as i,Ge as j,j as k};
|
|
7
|
+
import{a as Se}from"./chunk-YYZL7UGV.mjs";import{a as be,f as we,i as ke,j as ve,l as te}from"./chunk-54HYHHVL.mjs";import{a as Le,b as je,c as $e,d as Pe,e as _,f as _e,g as xe,h as D,i as ne,l as Me,o as Je}from"./chunk-YBZIDW6W.mjs";import{a as E}from"./chunk-4TLYUZD5.mjs";import{c as Oe}from"./chunk-HF6LAK3G.mjs";import{a as P,b as Fe,d as Be,e as Ce,f as ee,h as Ne,i as We,j as Ee}from"./chunk-ZOSESZ22.mjs";import{Y as ce,Z as fe,_ as he,a as X,ba as pe,ca as ge,d as Q,fa as ye,ha as me,ia as Re}from"./chunk-2GSMHGIV.mjs";import{b as I}from"./chunk-CA5NAXSU.mjs";import{d as Ie,e as Z,f as Ae,k as Te}from"./chunk-ISOSTAJR.mjs";import{Oc as le,qd as ue,tc as Y}from"./chunk-6QSHWIZI.mjs";function Ye(a){return Array.isArray(a)?a.length:(a.successfulResults?.length??0)+(a.failedResults?.length??0)}function Ue(a,e){let t=!1,n=!1,s,r={},o=0,i=0,d=(c,p)=>(i+=c,e?.(c),p()),l=async c=>{let p=await d(We,c);return o=Ye(p),p},u={createJob:c=>{let p=a.bulk2.createJob(c);return{get id(){return p.id},open:async()=>{await d(1,()=>p.open()),s=Ce(p)},uploadData:w=>d(1,()=>p.uploadData(w)),close:async()=>{t=!0,await d(1,()=>p.close()),n=!0},abort:()=>d(1,()=>p.abort()),check:async()=>{let w=await d(1,()=>p.check());return r={state:w.state,message:w.errorMessage},w},getAllResults:()=>l(()=>p.getAllResults())}}};if("job"in a.bulk2){let c=a.bulk2;u.job=(p,w)=>{let R=c.job(p,w);return{check:async()=>{let y=await d(1,()=>R.check());return r={state:y.state,message:y.errorMessage??void 0},y},getSuccessfulResults:()=>d(1,()=>R.getSuccessfulResults()),getAllResults:()=>l(()=>R.getAllResults()),abort:()=>d(1,()=>R.abort())}}}return{connection:{bulk2:u},closeSent:()=>t,closed:()=>n,jobId:()=>s,last:()=>r,processed:()=>o,requests:()=>i}}var L=class extends Error{constructor(t,n,s=0,r=[]){super(`Bulk API job ${t||"(no id)"} was closed, and what it wrote could not be read back: ${n}`);this.jobId=t;this.requests=s;this.twins=r;this.name="BulkJobLostError"}jobId;requests;twins},M=1e4,q=50*1024*1024,Xe=10,Qe=/not supported by the Bulk API|InvalidEntity/i,Ze={unprocessed:"The Bulk API job did not write this row.",twin:"Kept out of the Bulk API job: another row carries the same values, and the job's results could not tell them apart.","may-have-written":"The Bulk API job may have written this row without saying so: it is not sent again."};async function Pt(a,e,t,n,s,r={}){let o=n==="insert"?s.map(nt):s,i=Fe(P(n,o,r.externalIdField)),d=[];o.forEach((k,A)=>{i.has(A)||d.push(A)});let l=d.map(k=>o[k]),u=o.map((k,A)=>i.has(A)?"twin":"unprocessed"),c=k=>({answers:u.map(A=>x(A==="twin"?"twin":"unprocessed")),rows:u,unmatchedIds:[],...k});if(l.length===0)return c({requests:0});let p=P(n,l,r.externalIdField),w=Buffer.byteLength(p.text,"utf8");if(l.length>M||w>q)return c({requests:0,untouched:{reason:`${l.length} rows, ${w} bytes of CSV: past what one job takes (${M} rows, ${q} bytes)`}});let R=(k,A,h,v)=>{let F={requests:k.requests,...k.jobId?{jobId:k.jobId}:{}};if(k.info.state!=="JobComplete"&&k.processed===0&&v===0)return c({...F,untouched:re(ee(k.info)??"job not complete")});let W=new Map(A.map(m=>[m.recordIndex,m])),f=u.map(m=>x(m==="twin"?"twin":"unprocessed"));return d.forEach((m,S)=>{let N=tt(W.get(S),v>0);u[m]=N.state,f[m]=N.answer}),{answers:f,rows:u,unmatchedIds:[...h],...F}},y=Ue(a),b,T=()=>b?{jobId:b}:{},B=r.pollDelay??Ee,g;try{g=await new Ne().executeBulk({connection:y.connection,bulkManager:e,pollIntervalMs:B,...r.signal?{signal:r.signal}:{},...r.onProgress?{onProgress:r.onProgress}:{},onOpened:k=>{b=k,r.onOpened?.(k)}},t,n,l,r.externalIdField)}catch(k){let A=I(k);if(!y.closeSent())return c({requests:y.requests(),...T(),untouched:re(A)});if(b===void 0)throw new L("",A,y.requests(),[...i]);let h=await et(y.connection,b,B);if(h.state==="never-closed")return c({requests:y.requests(),jobId:b,untouched:re(A)});if(h.state!=="ended")throw new L(b,h.state==="unread"?h.reason:"still running",y.requests(),[...i]);let v=Be(h.results,p,ee(h.info));return R({info:h.info,processed:y.processed(),requests:y.requests(),jobId:b},v.outcomes,v.unattributedSuccessIds,v.unattributedSuccesses)}if(g.aborted)return c({requests:y.requests(),...T(),aborted:!0});let C=y.last();return R({info:{state:C.state??"JobComplete",...C.message?{errorMessage:C.message}:{}},processed:y.processed(),requests:y.requests(),...T()},g.outcomes,g.unmatchedIds??[],g.unmatchedWrites??0)}async function et(a,e,t){let n=await te(a,e,{openGraceMs:0});for(let s=1;s<Xe;s++){if(n.state==="ended"||n.state==="never-closed")return n;await new Promise(r=>setTimeout(r,t(s-1))),n=await te(a,e,{openGraceMs:0})}return n}function re(a){return Qe.test(a)?{reason:a,unsupported:!0}:{reason:a}}function x(a){return{id:"",success:!1,errors:[Ze[a]]}}function tt(a,e){if(a===void 0||a.state==="no-result"){let s=e?"may-have-written":"unprocessed";return{state:s,answer:x(s)}}if(a.state==="unprocessed")return{state:"unprocessed",answer:x("unprocessed")};if(a.success)return a.id?{state:"answered",answer:{id:a.id,success:!0,errors:[],...a.created!==void 0?{created:a.created}:{}}}:{state:"may-have-written",answer:x("may-have-written")};let t=a.error??"Unknown error",n=Ie(t);return{state:"answered",answer:n?{id:"",success:!1,errors:[Ae(n)],errorDetails:[n]}:{id:"",success:!1,errors:[t]}}}function nt(a){let e;for(let[t,n]of Object.entries(a))n===""&&(e??={...a},e[t]=null);return e??a}var ae={rest:200,bulk:1e4},Ke=3,ot=3,De=3,it=2e3;function at(a){return new Promise(e=>setTimeout(e,a))}function dt(a,e,t={bulk:!1}){let n=t.bulk&&a.api==="bulk"&&e>=2e3?"bulk":"rest",s=Math.min(a.batchSize,ae[n]);return{api:n,batchSize:s,batchCount:Math.ceil(e/s),clamped:s<a.batchSize}}function z(a){return a.refusals.flatMap(e=>e.leftOut)}function se(a){let e=a.built?.source.Id;return typeof e=="string"?e:void 0}function qe(a){return(a.built?.nullifiedFks??[]).map(({field:e,sourceRefId:t,insertOnly:n})=>({field:e,sourceRefId:t,...n?{insertOnly:n}:{}}))}function lt(a){let e=a.RecordTypeId;return typeof e=="string"&&e!==""}function oe(a){return a.refusals.length===0?a.payload:D(a.payload,z(a))}function He(a,e){let t=new Map;return e?.refusedIn?.answers.forEach((n,s)=>{let r=a[s];n&&r&&t.set(r,n.errors)}),t}var ut=new Set,ct=new Map;function H(a){return{objectApiName:a.objectApiName,op:a.upsertField?"upsert":"insert"}}function Ve(a){return a!==void 0&&!a.success?ue(a.errors):void 0}function ft(a){let e=a.automation??"the target's automation";E.warn(`[forge] ${a.objectApiName}: ${e} hit ${a.limit??"a Salesforce limit"} on a call of ${a.from} \u2014 sending a record on its own, then smaller calls`+(a.op==="upsert"?" (upsert).":"."))}var V={"validation-rule":"a validation rule","restricted-picklist":"a restricted picklist","lookup-filter":"a lookup filter","inactive-owner":"the target, the owner being inactive there"};function ht(a){let e=new Set(a.map(o=>o.refusedBy)),t=Object.keys(V).filter(o=>o!=="inactive-owner"&&e.has(o)).map(o=>V[o]),n=t.length>1?`${t.slice(0,-1).join(", ")} or ${t[t.length-1]}`:t[0],s=n===void 0?void 0:`${n} of the target`;if(!e.has("inactive-owner"))return s??`${V["validation-rule"]} of the target`;let r=`${V["inactive-owner"]},`;return s===void 0?r:`${s} or ${r}`}function ie(a,e){if(!a.ownersMapped||a.ownersMapped.size===0)return!1;let t=_(e,"OwnerId"),n=t===void 0?void 0:e[t];return typeof n=="string"&&a.ownersMapped.has(n.slice(0,15))}function pt(a,e,t,n,s){let r=a.errorDetails??[];if(r.length===a.errors.length)return _e(r,e,t,n,s)}function ze(a){a.linkedToCreatedCount=(a.linkedToCreatedCount??0)+1}function gt(a){let e=a.errorDetails??[];return Je(a.errors,e.length===a.errors.length?e:void 0)}function G(a){return a.map(e=>e.field).join(", ")}function yt(a,e){return`Sent again without ${G(a)} after the first refusal: ${e.join("; ")}`}var mt=["first","second","third"];function J(a){return a.map(({leftOut:e,errors:t},n)=>n===0?yt(e,t):`Sent again without ${G(e)} too after the ${mt[n]} refusal: `+t.join("; "))}function U(a){let e=(t,n)=>t.length===0?[]:[`Sent without ${G(t)}: ${n} earlier in the run, `+[...new Set(t.map(s=>s.reason))].join("; ")];return[...e(a.filter(t=>t.refusedBy!=="inactive-owner"),"the target refused the same value under the same record type"),...e(a.filter(t=>t.refusedBy==="inactive-owner"),"the target refused the same owner, inactive there,")]}function O(a){return`${a} record${a===1?"":"s"}`}var Rt="The call was sent and its answer never came back: the target may hold any of these records, and which of them is unknown. Counted as failed and never sent again, they are not among the records the run created, which removing its records takes back.",bt="Counted as failed and never sent again, they are not among the records the run created; the records the job wrote that no row was matched to are, and removing the run's records takes them back.",wt="DUPLICATES_DETECTED";function kt(a,e){if(a==="twin"||a==="unprocessed")return!0;if(a!=="answered"||e.success)return!1;let t=e.errorDetails;return t?.length!==1||t[0].statusCode===wt}function vt(a,e){let t=i=>i.reduce((d,l)=>d+Math.max(Buffer.byteLength(l,"utf8"),4)+(l.split('"').length-1)+3,1),n=t(e.columns),s=[],r=0,o=n;return e.rows.forEach((i,d)=>{let l=t(i);d>r&&o+l>a&&(s.push([r,d]),r=d,o=n),o+=l}),e.rows.length>r&&s.push([r,e.rows.length]),s}function It(a,e,t){let n=a.find(r=>r.isReference&&r.nillable===!1&&r.name!=="OwnerId"&&e.has(r.name))?.name;if(n===void 0)return;let s=r=>{let o=t[r][n];return typeof o=="string"?o:""};if(t.some((r,o)=>s(o)!==""))return t.map((r,o)=>o).sort((r,o)=>{let i=s(r),d=s(o);return i===d?r-o:i===""?1:d===""||i<d?-1:1})}var At="The target refused the call for its API request limit, which no retry gets past: the node stopped there.",Tt="A validation rule of the target, or a trigger with its code, refused the row without naming a field: there was none to send it again without.";function Ft(){return{successCount:0,updatedCount:0,linkedExistingCount:0,failureCount:0,alreadyExistsCount:0,unidentifiedExistingCount:0,errorSamples:[],pendingFkUpdates:[]}}var Ge=class{constructor(e,t,n=at,s=be()){this.deps=e;this.wait=n;this.splitting=s;this.batchStrategy=t??new Oe}deps;wait;splitting;batchStrategy;refusedValues=new Map;refusedOwners=new Map;backoff=new Me({initialDelay:it});async writeNode(e,t=Ft()){let{node:n,fieldInfos:s,creatableFields:r,targetOrgId:o,remapper:i}=e,d=await this.heldBeforeInsert(n.objectApiName,o,e.records);for(let[h,v]of d){let F=e.cleanedRecords[h]?.source,W=F?.Id;if(typeof W!="string")continue;i.addExisting(W,v,n.objectApiName);let f=F?.ContactId;n.objectApiName===X&&typeof f=="string"&&i.wasCreated(f)&&(t.withTheirRecord=[...t.withTheirRecord??[],W])}t.linkedExistingCount+=d.size;let l=await this.giveFlagsBack(n.objectApiName,o,e,d);l&&(t.flagsNotKept=pe(t.flagsNotKept,l));let u=e.records.filter((h,v)=>!d.has(v)),c=e.cleanedRecords.filter((h,v)=>!d.has(v)),p=this.batchStrategy.resolve(n.batchStrategy,u.length),{api:w,batchSize:R,batchCount:y,clamped:b}=dt(p,u.length,{bulk:this.jobsCanCarry(e.bulk,n.objectApiName)});if(b&&E.warn(`[forge] ${n.objectApiName}: batch strategy asked for ${p.batchSize} records per call (api="${p.api}") but the write path is "${w}" (max ${ae[w]}) \u2014 using ${R} per call (${y} batch(es)).`),w==="bulk"){let h=It(s,r,u);if(h){let v={records:u,cleanedRecords:c};u=h.map(F=>v.records[F]),c=h.map(F=>v.cleanedRecords[F])}}e.onProgress({objectName:n.objectApiName,status:"running",progress:0,recordCount:u.length,fieldCount:s.length,createableFieldCount:r.size,message:`Inserting ${u.length} ${n.objectApiName} records in ${y} batch(es)...`});let T=0,B=this.pickUpsertField(s,r,u,e.upsertMode==="auto"&&this.deps.upsertRecords?"auto":"off",e.tableKeys),g={objectApiName:n.objectApiName,targetOrgId:o,targetKeyPrefix:e.targetKeyPrefix,remapper:i,tally:t,oweLookups:e.oweLookups,onWritten:e.onWritten,onCreatedWithoutRecordType:e.onCreatedWithoutRecordType,calls:e.calls,bulk:e.bulk,byNaturalKey:[],refusedOnTheirFields:[],locked:[],upsertField:B,ownersMapped:e.ownersMapped,remembered:new Set([...e.picklistFields??[]].filter(([,h])=>h.controllerName===void 0).map(([h])=>h.toLowerCase()))},{byNaturalKey:C}=g,k=h=>{let v=I(h);this.leaveLockedAsFailed(g,g.locked.splice(0),v),this.leaveRefusedAsFailed(g,g.refusedOnTheirFields.splice(0),v),this.settleByNaturalKey(n.objectApiName,C,[],i,t,`The record the target holds under the same key was not looked up: ${v}`)};for(let h=0;h<y;h++){let v=u.slice(h*R,(h+1)*R).map((m,S)=>{let{sent:N,before:$}=this.withoutRefusedValues(g,m);return{payload:N,built:c[T+S],before:$,refusals:[],lockResends:0}}),F=`${n.objectApiName} batch ${h+1}/${y}`,W;try{W=await this.sendRows(g,e,v,F,u.length-T-v.length)}catch(m){throw k(m),m}if(W){let m=I(W.thrown);this.leaveLockedAsFailed(g,g.locked.splice(0),m),this.leaveRefusedAsFailed(g,g.refusedOnTheirFields.splice(0),m);break}T+=v.length;let f;try{f=await this.sendLockedAgain(g,e,u.length-T)}catch(m){throw k(m),m}if(f){this.leaveRefusedAsFailed(g,g.refusedOnTheirFields.splice(0),I(f.thrown));break}e.onProgress({objectName:n.objectApiName,status:"running",progress:Math.round((h+1)/y*100),message:`batch ${h+1}/${y} \u2014 ${Math.min((h+1)*R,u.length)}/${u.length} records`})}try{await this.writeAgainWithoutTheirFields(g,e,Math.min(R,ae.rest))}catch(h){throw k(h),h}let A=Q[n.objectApiName];if(A&&C.length>0){let h,v;try{h=await this.recordsByNaturalKey(o,n.objectApiName,A,C.map(F=>F.payload))}catch(F){h=[],v=`The record the target holds under the same key could not be looked up: ${I(F)}`}this.settleByNaturalKey(n.objectApiName,C,h,i,t,v)}return t}send(e,t){return e.upsertField&&this.deps.upsertRecords?this.deps.upsertRecords(e.targetOrgId,e.objectApiName,e.upsertField,t):this.deps.insertRecords(e.targetOrgId,e.objectApiName,t)}jobsCanCarry(e,t){return e!==void 0&&this.deps.bulkWriteRecords!==void 0&&!e.restOnly.has(t)&&!e.bulkUnsupported.has(t)}goesSmallerByRest(e){return this.splitting.sizes.of(e)<200}async sendRows(e,t,n,s,r,o){let{bulk:i}=e;if(!i||!this.jobsCanCarry(i,e.objectApiName)||n.length<2e3)return this.sendByRest(e,t,n,s,r,o);for(let d=0;d<n.length;d+=M){let l=n.slice(d,d+M),u=n.length-d-l.length+r,c;try{c=l.length>=2e3?await this.writeAsJobs(e,t,i,l,s,u,o):await this.sendByRest(e,t,l,s,u,o)}catch(p){throw o?.(n.slice(d+l.length),I(p)),p}if(c)return c}}async sendByRest(e,t,n,s,r,o,i){if(n.length===0)return;try{await t.waitIfPaused()}catch(l){let u=I(l);throw o?o(n,u):this.leaveLimitedAsFailed(e,n,He(n,i),u),l}let d=await this.callAndSettle(e,t,n,o,i);if(d)return this.settleThrown(e,d.threw,d.rows,s,d.rest.length+r),d.threw}async writeAsJobs(e,t,n,s,r,o,i){let d=this.deps.bulkWriteRecords;if(!d)return this.sendByRest(e,t,s,r,o,i);let l=H(e);if(this.goesSmallerByRest(l))return this.sendJobByRest(e,t,n,s,r,o,i);let u=e.upsertField?"upsert":"insert",c=s.map(oe),p=vt(q,P(u,c,e.upsertField));for(let[w,R]of p){let y=s.slice(w,R),b=s.length-R+o;if(this.goesSmallerByRest(l)){let f;try{f=await this.sendJobByRest(e,t,n,y,r,b,i)}catch(m){throw i?.(s.slice(R),I(m)),m}if(f)return f;continue}try{await t.waitIfPaused()}catch(f){throw i?.(s.slice(w),I(f)),f}let T=c.slice(w,R),B=e.calls?.sending(e.objectApiName,y.map((f,m)=>({sourceId:se(f),payload:T[m],owes:qe(f)})),e.upsertField,!0),g;try{g=await d(e.targetOrgId,e.objectApiName,u,T,{bulkManager:n.manager,signal:n.signal,...e.upsertField?{externalIdField:e.upsertField}:{},onOpened:f=>{B!==void 0&&e.calls?.opened?.(B,f)}})}catch(f){if(f instanceof L){let m={thrown:f,left:"may-have-written",tries:1},S=new Set(f.twins),N=y.filter(($,de)=>!S.has(de));return this.settleThrown(e,m,N,`${r} (Bulk API job)`,b),this.leaveTwinsUnsent(e,y.length-N.length,r,f),m}g={answers:[],rows:[],unmatchedIds:[],untouched:{reason:I(f)},requests:0}}if(g.aborted){try{await t.waitIfPaused()}catch(f){throw B!==void 0&&e.calls?.answered(B),i?.(s.slice(w),I(f)),f}g={...g,untouched:{reason:"the job was aborted"}}}if(g.untouched){B!==void 0&&e.calls?.answered(B),g.untouched.unsupported&&n.bulkUnsupported.add(e.objectApiName),E.warn(`[forge] ${e.objectApiName}: a Bulk API job of ${O(y.length)} wrote nothing (${g.untouched.reason}) \u2014 sent by REST`+(g.untouched.unsupported?", as every write of the object in the run.":"."));let f;try{f=await this.sendByRest(e,t,y,r,b,i)}catch(m){throw i?.(s.slice(R),I(m)),m}if(f)return f;continue}g.unmatchedIds.length>0&&(e.calls?.unattributed?.(e.objectApiName,g.unmatchedIds),E.warn(`[forge] ${e.objectApiName}: Bulk API job ${g.jobId??""} wrote ${O(g.unmatchedIds.length)} no row was matched to \u2014 kept for removal.`));let C=[],k=[],A=[],h=[],v=[],F=[],W;if(y.forEach((f,m)=>{let S=g.rows[m]??"unprocessed",N=g.answers[m],$=S==="answered"?Ve(N):void 0;S==="may-have-written"?F.push(f):$!==void 0&&N!==void 0?(W??=$,h.push(f),v.push(N)):!N||kt(S,N)?A.push(f):(C.push(f),k.push(N))}),this.settleMayHaveBeenWritten(e,F,r,g.jobId),await this.settleAnswers(e,C,B===void 0?{answers:k}:{answers:k,callId:B}),A.length>0){let f;try{f=await this.sendByRest(e,t,A,`${r}, by REST`,h.length+b,i)}catch(m){throw i?.([...h,...s.slice(R)],I(m)),m}if(f)return f}if(h.length>0){let f;try{f=await this.sendByRest(e,t,h,`${r}, by REST`,b,i,{refusedIn:{from:200,answers:v,...W?{cause:W}:{}}})}catch(m){throw i?.(s.slice(R),I(m)),m}if(f)return f}}}async sendJobByRest(e,t,n,s,r,o,i){let d=H(e),{sizes:l,allowance:u}=this.splitting,c=l.of(d),p=Math.ceil(s.length/c),w=u.take(d,p);l.countExtraCalls(d,w);let R=s.slice(0,w*c),y=s.slice(R.length);if(R.length>0){let b;try{b=await this.sendByRest(e,t,R,r,y.length+o,i,{pricedAs:"job",paid:{calls:w}})}catch(T){throw i?.(y,I(T)),T}finally{w<p&&l.spend(d)}if(b)return b}else w<p&&l.spend(d);if(y.length!==0)return y.length>=2e3?this.writeAsJobs(e,t,n,y,r,o,i):this.sendByRest(e,t,y,r,o,i)}leaveTwinsUnsent(e,t,n,s){t!==0&&(e.tally.failureCount+=t,this.sample(e.tally,{recordSummary:`${n}: ${O(t)} not written`,messages:[I(s),"Kept out of the Bulk API job as twins of other rows, to be written by REST once it answered: never sent, the target holds none of them."]}))}settleMayHaveBeenWritten(e,t,n,s){if(t.length===0)return;let{tally:r}=e;r.failureCount+=t.length;let o=t.map(se).filter(i=>i!==void 0);r.mayHaveBeenWritten=[...r.mayHaveBeenWritten??[],...o],this.sampleAhead(r,{recordSummary:`${n}: ${O(t.length)} may have been written`,messages:[`Bulk API job ${s??""} gave them no result of their own, and wrote records no row was matched to: the target may hold any of these records, and which of them is unknown.`,bt]})}async call(e,t,n){let s=n.map(oe);for(let r=0;;r++){let o=e.calls?.sending(e.objectApiName,n.map((i,d)=>({sourceId:se(i),payload:s[d],owes:qe(i)})),e.upsertField);try{let i=await this.send(e,s);return o===void 0?{answers:i}:{answers:i,callId:o}}catch(i){let d=Se(i);if(o!==void 0&&d!=="may-have-written"&&e.calls?.answered(o),d!=="not-received"||r===Ke)return{thrown:i,left:d,tries:r+1};let l=this.backoff.calculateDelay(r);E.warn(`[forge] ${e.objectApiName}: a call of ${O(s.length)} never reached the target (${I(i)}) \u2014 sent again in ${l} ms (${r+1}/${Ke}).`),await this.wait(l),await t.waitIfPaused()}}}async callAndSettle(e,t,n,s,r){let o,i={answers:[]},d=He(n,r),{stopped:l}=await ve(n,{key:H(e),sizes:this.splitting.sizes,allowance:this.splitting.allowance,...r,beforeEachSend:()=>t.waitIfPaused(),send:async u=>{let c=await this.call(e,t,u);return"thrown"in c?(o=c,"stop"):(i=c,{answers:c.answers})},limited:(u,c)=>{let p=Ve(u);return p&&u&&d.set(c,u.errors),p},settle:(u,c,p,w,R)=>this.settleAnswers(e,u,R?{answers:c}:i,p,w),onThrow:(u,c)=>{let p=I(c);s?s(u,p):this.leaveLimitedAsFailed(e,u,d,p)},onFirstRefusal:ft});if(!(!l||o===void 0))return{threw:o,rows:l.part,rest:l.rest}}sample(e,t){e.errorSamples.length<3&&e.errorSamples.push(t)}sampleAhead(e,t){e.errorSamples.unshift(t),e.errorSamples.splice(3)}async settleAnswers(e,t,{answers:n,callId:s},r=ut,o=ct){t.forEach((i,d)=>{let l=n[d];l?.success&&!r.has(d)&&this.settle(e,l,i)}),e.remapper.persist(),await this.readWhatMayBeEmpty(e,n.filter(i=>i!==void 0)),t.forEach((i,d)=>{if(r.has(d))return;let l=n[d];if(l){l.success||this.settle(e,l,i,o.get(d));return}e.tally.failureCount++,this.sample(e.tally,{recordSummary:j(i.payload),messages:[`No result returned for record (API truncated batch: ${n.length}/${t.length})`,...J(i.refusals),...U(i.before)]})}),e.remapper.persist(),s!==void 0&&e.calls?.answered(s)}async readWhatMayBeEmpty(e,t){if(e.mayBeEmpty!==void 0||!t.some(r=>(r.errorDetails??[]).some(o=>o.statusCode===je)))return;let s=await this.deps.describeFields?.(e.targetOrgId,e.objectApiName).catch(()=>{});e.mayBeEmpty=new Set((s??[]).filter(r=>r.nillable===!0).map(r=>r.name.toLowerCase()))}settleThrown(e,t,n,s,r){let{tally:o}=e,i=I(t.thrown);if(o.failureCount+=n.length+r,t.left==="may-have-written"){let l=n.map(u=>u.built?.source.Id).filter(u=>typeof u=="string");o.mayHaveBeenWritten=[...o.mayHaveBeenWritten??[],...l],this.sampleAhead(o,{recordSummary:`${s}: ${O(n.length)} may have been written`,messages:[i,Rt,...r>0?[`${O(r)} after them not sent.`]:[]]});return}let d=n.length+r;this.sample(o,{recordSummary:`${s}: ${O(d)} not written`,messages:[i,...t.left==="request-limit"?[At]:[],...t.left==="not-received"?[`Sent ${t.tries} times, the call never reached the target: it holds none of them.`]:[]]})}async sendLockedAgain(e,t,n){for(let s=0;e.locked.length>0;s++){let r=this.backoff.calculateDelay(s);E.warn(`[forge] ${e.objectApiName}: the target could not lock a record for ${O(e.locked.length)} \u2014 sent again in ${r} ms.`),await this.wait(r),await t.waitIfPaused();let o=e.locked.splice(0),i=o.map(({row:u})=>({...u,lockResends:u.lockResends+1})),d=new Map(i.map((u,c)=>[u,o[c]])),l=await this.callAndSettle(e,t,i,(u,c)=>this.leaveLockedAsFailed(e,u.flatMap(p=>d.get(p)??[]),c));if(l)return this.settleThrown(e,l.threw,l.rows,`${e.objectApiName}, sent again`,n+l.rest.length),this.leaveLockedAsFailed(e,e.locked.splice(0),I(l.threw.thrown)),l.threw}}settle(e,t,n,s){let{tally:r,remapper:o,objectApiName:i}=e,{built:d,before:l}=n,u=oe(n);if(t.success){let b=d?.source.Id,T=t.created===!1;if(T?r.updatedCount++:r.successCount++,typeof b=="string"&&(T?o.addUpdated(b,t.id,i):o.add(b,t.id,i)),d&&e.onWritten?.(d,t.id),!T&&!lt(u)&&e.onCreatedWithoutRecordType?.(d,t.id),d&&d.nullifiedFks.length>0){let g=typeof d.source.Id=="string"?d.source.Id:void 0,C=d.nullifiedFks.map(k=>({objectApiName:i,newId:t.id,sourceId:g,fieldName:k.field,sourceRefId:k.sourceRefId,...k.insertOnly?{insertOnly:!0}:{}}));e.oweLookups?e.oweLookups(C):r.pendingFkUpdates.push(...C)}let B=[...l,...z(n)];B.length>0&&(r.writtenWithoutFields=ne(r.writtenWithoutFields,{rows:1,fields:B.map(g=>({...g,rows:1}))}));for(let{field:g,refusedBy:C}of B)C!=="lookup-filter"||!t.id||(r.leftEmptyByFilter??=[]).push({field:g,recordId:t.id});return}this.rememberRefusedValues(e,t,u),this.rememberRefusedOwners(e,t,u);let c=Te(t,e.targetKeyPrefix);if(c.kind==="linked"){r.linkedExistingCount++,o.createdTarget(c.id)&&ze(r);let b=d?.source.Id;typeof b=="string"&&o.addExisting(b,c.id,i);return}if(c.kind==="unidentified"&&Q[i]){e.byNaturalKey.push({payload:u,sourceId:d?.source.Id,errors:t.errors});return}let p=gt(t);if(p&&n.lockResends<ot){e.locked.push({row:n,errors:t.errors});return}let w=b=>e.mayBeEmpty?.has(b.toLowerCase())??!1,R=pt(t,u,e.upsertField,w,{inactiveOwner:!ie(e,u)}),y=n.refusals.length<De;if(R&&y){e.refusedOnTheirFields.push({...n,refusals:[...n.refusals,{errors:t.errors,leftOut:R}]});return}r.failureCount++,c.kind==="unidentified"&&r.unidentifiedExistingCount++,t.errors.every(b=>Y(b))&&r.alreadyExistsCount++,this.sample(r,{recordSummary:j(n.payload),messages:[...t.errors,...J(n.refusals),...p?[`Sent again ${n.lockResends} times, the target still could not lock a record the write needed.`]:[],...R&&!y?[`Not sent again: a row goes again without the fields the target refused ${De} times at most.`]:[],...xe(t.errorDetails)?[Tt]:[],...s?[we(s,ke(this.splitting.allowance,H(e)),"run")]:[],...U(l)]})}refusedValueKey(e,t,n){let s=t.RecordTypeId,r=t[n];if(typeof s!="string"||s===""||typeof r!="string"||r==="")return;let o=n.toLowerCase();if(!(!e.remembered.has(o)||o===e.upsertField?.toLowerCase()))return[e.objectApiName,s,o,r].join("\0")}rememberRefusedValues(e,t,n){for(let s of t.errorDetails??[])if(s.statusCode===Le)for(let r of s.fields){let o=_(n,r),i=o===void 0?void 0:this.refusedValueKey(e,n,o);o===void 0||i===void 0||this.refusedValues.has(i)||this.refusedValues.set(i,{field:o,refusedBy:"restricted-picklist",reason:Z(s)})}}rememberRefusedOwners(e,t,n){let s=_(n,"OwnerId");if(!(s===void 0||s.toLowerCase()===e.upsertField?.toLowerCase())&&!ie(e,n))for(let r of t.errorDetails??[]){if(r.statusCode!==$e)continue;let o=Pe(r,n);o===void 0||this.refusedOwners.has(o)||this.refusedOwners.set(o,{field:"OwnerId",refusedBy:"inactive-owner",reason:Z(r)})}}withoutRefusedValues(e,t){let n=[];if(this.refusedValues.size===0&&this.refusedOwners.size===0)return{sent:t,before:n};for(let o of Object.keys(t)){let i=this.refusedValueKey(e,t,o),d=i===void 0?void 0:this.refusedValues.get(i);d&&n.push({...d,field:o})}let s=_(t,"OwnerId"),r=s===void 0?void 0:t[s];if(s!==void 0&&typeof r=="string"&&s.toLowerCase()!==e.upsertField?.toLowerCase()&&!ie(e,t)){let o=this.refusedOwners.get(r.slice(0,15));o&&n.push({...o,field:s})}return n.length===0?{sent:t,before:n}:{sent:D(t,n),before:n}}leaveRefusedAsFailed(e,t,n){for(let s of t){let r=s.refusals[s.refusals.length-1];e.tally.failureCount++,this.sample(e.tally,{recordSummary:j(s.payload),messages:[...r?.errors??[],...J(s.refusals.slice(0,-1)),`Not written again without ${G(z(s))}: ${n}`,...U(s.before)]})}}leaveLimitedAsFailed(e,t,n,s){for(let r of t){let o=n.get(r);o&&(e.tally.failureCount++,this.sample(e.tally,{recordSummary:j(r.payload),messages:[...o,...J(r.refusals),`Not sent again in a smaller call: ${s}`,...U(r.before)]}))}}leaveLockedAsFailed(e,t,n){for(let{row:s,errors:r}of t)e.tally.failureCount++,this.sample(e.tally,{recordSummary:j(s.payload),messages:[...r,...J(s.refusals),`Not sent again: ${n}`,...U(s.before)]})}async writeAgainWithoutTheirFields(e,t,n){for(;e.refusedOnTheirFields.length>0;){let s=e.refusedOnTheirFields.splice(0);if(t.onProgress({objectName:e.objectApiName,status:"running",progress:100,message:`Writing ${s.length} ${e.objectApiName} record${s.length===1?"":"s"} again without the fields ${ht(s.flatMap(z))} refused...`}),this.jobsCanCarry(e.bulk,e.objectApiName)&&s.length>=2e3){let r=`${e.objectApiName}, sent again`,o=await this.sendRows(e,t,s,r,0,(i,d)=>this.leaveRefusedAsFailed(e,i,d));if(o??=await this.sendLockedAgain(e,t,0),o){let i=I(o.thrown);this.leaveLockedAsFailed(e,e.locked.splice(0),i),this.leaveRefusedAsFailed(e,e.refusedOnTheirFields.splice(0),i);return}continue}for(let r=0;r<s.length;r+=n){let o=s.slice(r,r+n),i;try{await t.waitIfPaused()}catch(l){throw this.leaveRefusedAsFailed(e,s.slice(r),I(l)),l}try{i=await this.callAndSettle(e,t,o,(l,u)=>this.leaveRefusedAsFailed(e,l,u))}catch(l){throw this.leaveRefusedAsFailed(e,s.slice(r+n),I(l)),l}let d;if(i){d=i.threw;let l=I(i.threw.thrown),u=[...i.rest,...s.slice(r+n)];i.threw.left==="may-have-written"?(this.settleThrown(e,i.threw,i.rows,`${e.objectApiName}, sent again`,0),this.leaveRefusedAsFailed(e,u,l)):this.leaveRefusedAsFailed(e,[...i.rows,...u],l)}else{try{d=await this.sendLockedAgain(e,t,0)}catch(l){throw this.leaveRefusedAsFailed(e,s.slice(r+n),I(l)),l}d&&this.leaveRefusedAsFailed(e,s.slice(r+n),I(d.thrown))}if(d){this.leaveRefusedAsFailed(e,e.refusedOnTheirFields.splice(0),I(d.thrown));return}}}}settleByNaturalKey(e,t,n,s,r,o){t.forEach((i,d)=>{let l=n[d];if(l&&typeof i.sourceId=="string"){s.createdTarget(l)&&ze(r),s.addExisting(i.sourceId,l,e),r.linkedExistingCount++;return}r.failureCount++,r.unidentifiedExistingCount++,i.errors.every(u=>Y(u))&&r.alreadyExistsCount++,r.errorSamples.length<3&&r.errorSamples.push({recordSummary:j(i.payload),messages:o?[...i.errors,o]:i.errors})})}async recordsByNaturalKey(e,t,n,s){let r=this.deps.queryRecords;return r?Re(o=>r(e,o),t,n,s):s.map(()=>{})}async giveFlagsBack(e,t,n,s){let r=this.deps.updateRecords;if(!r||s.size===0||!he[e])return;let o=[];for(let[d,l]of s){let u=n.cleanedRecords[d]?.source;u&&o.push([u,l])}let i=await this.deps.describeFields?.(t,e).catch(()=>{});return ge(e,o,d=>i?.find(l=>l.name===d)?.updateable!==!1,d=>r(t,e,d),n.stopped)}async heldBeforeInsert(e,t,n){let s=this.deps.queryRecords;if(!s)return new Map;let r=o=>s(t,o);return e===X?ye(r,n):ce[e]!==void 0?fe(r,e,n):e===le?me(r,n):new Map}pickUpsertField(e,t,n,s,r){if(s==="off"||!this.deps.upsertRecords)return;let o=e.filter(i=>i.externalId&&t.has(i.name)).sort((i,d)=>i.name.localeCompare(d.name));if(r)return this.tableKeyOfThePage(o,n,r);if(o.length!==0){for(let i of o){let d=new Set,l=!0;for(let u of n){let c=u[i.name];if(typeof c!="string"||c.length===0){l=!1;break}if(d.has(c)){l=!1;break}d.add(c)}if(l)return E.info(`[forge] upsert: using "${i.name}" as external Id (unique across ${n.length} records)`),i.name}E.warn(`[forge] upsert: no externalId candidate is non-null+unique across batch (${o.map(i=>i.name).join(", ")}) \u2014 falling back to insert`)}}tableKeyOfThePage(e,t,n){let s=e.find(o=>n.unique.has(o.name))?.name;if(s===void 0){e.length>0&&E.warn(`[forge] upsert: no externalId candidate is non-null+unique across the rows read (${e.map(o=>o.name).join(", ")}) \u2014 falling back to insert`);return}let r=new Set;for(let o of t){let i=o[s];if(typeof i!="string"||i.length===0||r.has(i)){E.warn(`[forge] upsert: a row of this page leaves "${s}" empty or repeats it \u2014 inserting the page`);return}if(n.sent.has(i)){E.warn(`[forge] upsert: a row of this page repeats a "${s}" an earlier page sent \u2014 inserting the page`);return}r.add(i)}n.sent.size===0&&E.info(`[forge] upsert: using "${s}" as external Id (unique across the rows read of the object)`);for(let o of r)n.sent.add(o);return s}};function j(a){let e=Object.keys(a).slice(0,4),t=[];for(let n of e){let s=a[n],r;if(s===null)r="null";else if(s===void 0)r="undefined";else if(typeof s=="string")r=s.length>30?s.slice(0,30)+"\u2026":s;else if(typeof s=="object")try{let o=JSON.stringify(s);r=o.length>30?o.slice(0,30)+"\u2026":o}catch{r="<unserializable>"}else r=String(s);t.push(`${n}=${r}`)}return t.join(" ")||"(empty)"}export{L as a,M as b,Pt as c,ae as d,dt as e,lt as f,pt as g,yt as h,Ft as i,Ge as j,j as k};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b}from"./chunk-
|
|
7
|
+
import{a,b}from"./chunk-XAUQXYPW.mjs";import"./chunk-FVLFO2S6.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as FieldMapper,b as generateValue};
|
|
@@ -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{o as ne}from"./chunk-4JKR4PTZ.mjs";import{H as v,d as z,l as oe,m as se,n as ie}from"./chunk-
|
|
7
|
+
import{o as ne}from"./chunk-4JKR4PTZ.mjs";import{H as v,d as z,l as oe,m as se,n as ie}from"./chunk-N2HYG3BL.mjs";import{E as J,x as Be}from"./chunk-ZXOUWHYE.mjs";import{c as Pe}from"./chunk-EADHKH3A.mjs";import{h as Oe}from"./chunk-TZE3Y7IQ.mjs";import{b as L}from"./chunk-CA5NAXSU.mjs";import{a as re}from"./chunk-ISOSTAJR.mjs";import{Uc as I}from"./chunk-6QSHWIZI.mjs";import{b as N,e as ee,f as ke,i as te,k as Q,l as D,s as xe}from"./chunk-WZQEK4WT.mjs";var rt="encryptedstring";async function nt(o){try{let[e]=await o("SELECT PermissionsViewEncryptedData FROM UserPermissionAccess");return e?.PermissionsViewEncryptedData===!0}catch{return!1}}function lr(o){let e;return()=>(e??=nt(o),e)}function ur(o,e){let r=new Map;return t=>{let n=r.get(t);return n||(n=(async()=>{let s;try{s=(await e(t)).fields.filter(i=>i.type===rt).map(i=>i.name)}catch{return[]}return s.length>0&&!await o()?s:[]})(),r.set(t,n)),n}}var _=5,ce=25,de=3;function mr(o){return{get version(){return o.version},request:async e=>await o.request(e),query:async(e,r)=>await o.query(e,{scanAll:r?.scanAll===!0}),queryMore:async e=>await o.queryMore(e)}}var j=class extends Error{constructor(){super("The read was stopped."),this.name="OrgReadStopped"}},st="PROCESSING_HALTED",Ce="If-Modified-Since",it=/^\d{1,3}\.\d$/,at=/^\/services\/data\/v\d{1,3}\.\d\/query(?:All)?\/[A-Za-z0-9-]+$/,ct=D({records:Q(xe(N(),te())),done:ke(),totalSize:ee().optional(),nextRecordsUrl:N().optional()}).loose(),dt=D({compositeResponse:Q(D({body:te(),httpStatusCode:ee(),referenceId:N()}).loose())}),lt=Q(D({errorCode:N().optional(),message:N().optional()}).loose());function ut(o,e,r){if(!it.test(o))throw new Error(`Not an API version: ${o}`);if(e.length>_)throw new Error(`A composite runs ${_} queries, not ${e.length}`);if(e.length+r.length>ce)throw new Error(`A composite holds ${ce} subrequests, not ${e.length+r.length}`);let t=`/services/data/v${o}`;return{allOrNone:!1,compositeRequest:[...e.map((n,s)=>({method:"GET",url:n.kind==="first"?`${t}/${n.scanAll?"queryAll":"query"}?q=${encodeURIComponent(n.soql)}`:n.path,referenceId:`q${s}`})),...r.map(({path:n,headers:s},a)=>({method:"GET",url:`${t}/${n}`,referenceId:`d${a}`,...s?{httpHeaders:s}:{}}))]}}function ft(o){let e=dt.safeParse(o);if(!e.success)return;let r=new Map;for(let t of e.data.compositeResponse){if(t.httpStatusCode<400){r.set(t.referenceId,{ok:!0,status:t.httpStatusCode,body:t.body});continue}let n=lt.safeParse(t.body),s=n.success?n.data[0]:void 0;r.set(t.referenceId,{ok:!1,refused:s?[s.errorCode,s.message].filter(Boolean).join(": "):`status ${t.httpStatusCode}`,halted:s?.errorCode===st})}return r}function ae(o){let e=ct.safeParse(o);return e.success?e.data:void 0}function ht(o){return typeof o=="object"&&o!==null&&typeof o.errorCode=="string"}function pt(o){let e=/^https:\/\//i.test(o)?new URL(o).pathname:o;if(!at.test(e))throw new Error(`Not the next page of a query: ${o}`);return e}function wr(o,e){let r=new Set,t=[],n=_,s="composite",a=0,i=!1,c=!1,d=0,p=0,f=!1,m=()=>{for(let u of r)u.state==="pending"&&(u.state="idle",u.settle?.reject(new j));for(let u of t.splice(0))u.settle.reject(new j)},A=()=>{c||(c=!0,queueMicrotask(()=>{c=!1,B()}))},h=(u,w)=>{u.state="idle";let y=u.settle;u.ask=void 0,u.settle=void 0,w instanceof Error?y?.reject(w):y?.resolve(w)},l=async(u,w)=>{let y=ut(o.version,u.map(E=>E.ask),w),g;p++;try{g=await o.request({method:"POST",url:"/composite",body:JSON.stringify(y),headers:{"Content-Type":"application/json"}})}catch(E){if(ht(E)){s="single";for(let R of u)R.state="pending";t.unshift(...w);return}let x=new Error(L(E));for(let R of u)h(R,x);for(let R of w)R.settle.reject(x);return}let k=ft(g);if(!k){s="single";for(let E of u)E.state="pending";t.unshift(...w);return}let P=0;if(u.forEach((E,x)=>{let R=k.get(`q${x}`);if(R&&!R.ok&&R.halted){P++,E.state="pending";return}if(!R){h(E,new Error("The org gave no answer to this query of the composite"));return}if(!R.ok){h(E,new Error(R.refused));return}let tt=ae(R.body);h(E,tt??new Error(`The org answered a query with status ${R.status} and no page`))}),P>0){let E=u.length-P;E===0?s="single":n=Math.min(n,E)}w.forEach((E,x)=>{let R=k.get(`d${x}`);R?R.ok?E.settle.resolve(R.status===304?{notModified:!0}:{body:R.body}):E.settle.reject(new Error(R.refused)):E.settle.reject(new Error("The org gave no answer to this describe of the composite"))})},b=async(u,w)=>{for(let y of u){let g=y.ask;p++;try{let k=g.kind==="first"?await o.query(g.soql,{scanAll:g.scanAll}):await o.queryMore(g.path);h(y,ae(k)??new Error("The org answered a query with no page"))}catch(k){h(y,new Error(L(k)))}}for(let y of w){p++;try{let g=await o.request({method:"GET",url:`/services/data/v${o.version}/${y.path}`,...y.headers?{headers:y.headers}:{}}),k=y.headers?.[Ce]!==void 0&&(g==null||g==="");y.settle.resolve(k?{notModified:!0}:{body:g})}catch(g){y.settle.reject(new Error(L(g)))}}},S=async(u,w,y)=>{try{s==="composite"?await l(u,w):await b(u,w)}catch(g){let k=new Error(L(g));for(let P of u)P.state==="sent"&&h(P,k);for(let P of w)P.settle.reject(k)}finally{a--,y||(i=!1),A(),Se()}},B=()=>{if(e?.aborted){m();return}for(;;){if(i)return;let u=[...r],w=u.filter(x=>x.state==="pending").sort((x,R)=>x.order-R.order);if(!(w.length>0&&!u.some(x=>x.state==="idle"))&&t.length===0)return;let g=w.slice(0,n),k=ce-g.length,P=s==="composite"&&t.length===0&&g.length>0&&g.every(x=>x.oneRow&&x.ask?.kind==="first");if(a>=(P?de:1))return;let E=t.splice(0,k);if(g.length===0&&E.length===0)return;for(let x of g)x.state="sent";a++,P||(i=!0),S(g,E,P)}},O=()=>{f=!1,A()},Y=()=>{f||e===void 0||e.aborted||(e.addEventListener("abort",O,{once:!0}),f=!0)},Se=()=>{!f||a>0||r.size>0||t.length>0||(e?.removeEventListener("abort",O),f=!1)},Re=(u,w)=>r.has(u)?u.state!=="idle"?Promise.reject(new Error("A read asks one page at a time.")):e?.aborted?Promise.reject(new j):new Promise((y,g)=>{u.ask=w,u.settle={resolve:y,reject:g},u.state="pending",u.order=++d,A()}):Promise.reject(new Error("This read is closed."));return{lane(u){let w={state:"idle",order:0,oneRow:u?.oneRow===!0};return r.add(w),Y(),{query:(y,g)=>Re(w,{kind:"first",soql:y,scanAll:g?.scanAll===!0}),queryMore:y=>{let g;try{g=pt(y)}catch(k){return Promise.reject(k instanceof Error?k:new Error(String(k)))}return Re(w,{kind:"next",path:g})},close(){r.delete(w)&&(w.state==="pending"&&h(w,new Error("This read is closed.")),A(),Se())}}},describe(u,w){return e?.aborted?Promise.reject(new j):new Promise((y,g)=>{let k=I(u),P;if(w!==void 0){let E=Date.parse(w);if(!Number.isFinite(E))throw new Error(`Not a date: ${w}`);P={[Ce]:new Date(E).toUTCString()}}Y(),t.push({path:`sobjects/${k}/describe`,...P?{headers:P}:{},settle:{resolve:y,reject:g}}),A()})},async tooling(u){if(e?.aborted)throw new j;p++;let w;try{w=await o.request({method:"GET",url:`/services/data/v${o.version}/tooling/query?q=${encodeURIComponent(u)}`})}catch(g){throw new Error(L(g))}let y=ae(w);if(!y)throw new Error("The org answered a Tooling API query with no page");return y},calls:()=>p}}import{createReadStream as mt}from"node:fs";import{appendFile as wt,stat as gt,writeFile as yt}from"node:fs/promises";import{StringDecoder as bt}from"node:string_decoder";import{promisify as je}from"node:util";import{createGunzip as At,gunzip as Et,gzip as St}from"node:zlib";var Rt=je(St),kt=je(Et),xt=64*1024,Ot=".gz",Pt=6,M=10,Ie=4,ve=Buffer.from("SF","latin1"),ue=8,H=6+ue,fe=M+H,he=fe+2+8;function $(o){return`${o}${Ot}`}async function Bt(o){let e=await Rt(o,{level:Pt});if(e[3]!==0)throw new Error("zlib wrote a gzip header with flags set");let r=Buffer.from(e.subarray(0,M));r[3]=Ie;let t=Buffer.alloc(H);return t.writeUInt16LE(H-2,0),ve.copy(t,2),t.writeUInt16LE(ue,4),t.writeUInt32LE(e.length+H,6),t.writeUInt32LE(o.length,10),Buffer.concat([r,t,e.subarray(M)])}function Me(o){if(o.length<fe||o[0]!==31||o[1]!==139||o[2]!==8||o[3]!==Ie||o.readUInt16LE(M)!==H-2||!o.subarray(M+2,M+4).equals(ve)||o.readUInt16LE(M+4)!==ue)return;let e=o.readUInt32LE(M+6),r=o.readUInt32LE(M+10);return e>=he&&r>0?{total:e,raw:r}:void 0}function Ct(o,e=xt){let r=[],t=0,n=0;for(;n<o.length;){let s=o.indexOf(10,n),a=s<0?o.length:s+1;a-t>e&&n>t&&(r.push(o.subarray(t,n)),t=n),n=a,n-t>=e&&(r.push(o.subarray(t,n)),t=n)}return n>t&&r.push(o.subarray(t,n)),r}async function Ne(o){let e=Ct(Buffer.from(o,"utf8"));return Buffer.concat(await Promise.all(e.map(r=>Bt(r))))}function U(o){return o.endsWith(".ndjson")}function kr(o){let e=new Map,r=(t,n)=>{let s=n(e.get(t)??Promise.resolve());return e.set(t,s),s.then(()=>{e.get(t)===s&&e.delete(t)},()=>{}),s};return{...o,writeFile:(t,n)=>{if(!U(t))return o.writeFile(t,n);let s=$(t);return r(s,a=>a.catch(()=>{}).then(async()=>{let i=n===""?Buffer.alloc(0):await Ne(n);await yt(s,i,{mode:z})}))},appendFile:(t,n)=>{if(!U(t))return o.appendFile(t,n);let s=$(t);return r(s,a=>a.then(async()=>{n!==""&&await wt(s,await Ne(n),{mode:z})}))},exists:t=>o.exists(U(t)?$(t):t),rm:t=>o.rm(U(t)?$(t):t),readLines:t=>U(t)?Nt($(t)):o.readLines(t)}}async function*Nt(o){if((await gt(o)).size===0)return;let e=mt(o),r=At(),t=a=>{r.destroy(a)};e.on("error",t),e.pipe(r);let n=new bt("utf8"),s="";try{for await(let a of r){let i=(s+n.write(a)).split(`
|
|
8
8
|
`);s=i.pop()??"",yield*i}s+=n.end(),s!==""&&(yield s)}finally{e.off("error",t),e.destroy(),r.destroy()}}async function le(o,e,r){let t=Buffer.alloc(r),n=0;for(;n<r;){let{bytesRead:s}=await o.read(t,n,r-n,e+n);if(s===0)break;n+=s}return n===r?t:t.subarray(0,n)}async function De(o,e,r,t){let n;try{n=await kt(o,{maxOutputLength:e.raw})}catch{throw t(`holds a block that does not inflate at byte ${r}`)}if(n.length!==e.raw)throw t(`holds a block at byte ${r} that inflates to other than its header says`);return n}async function Le(o,e,r,t){let n=await le(o,e,r);if(n.length<r)throw t(`is cut short at byte ${e+n.length}`);let s=Me(n);if(s===void 0)throw t(`holds no block where its index says, at byte ${e}`);if(s.total!==r)throw t(`holds another block than its index says at byte ${e}`);return De(n,s,e,t)}async function*$e(o,e,r){for(let t=0;t<e;){let n=Me(await le(o,t,Math.min(fe,e-t)));if(n===void 0)throw r(`holds no block at byte ${t}`);if(n.total>e-t)throw r(`is cut short: its block at byte ${t} ends past the file's end`);let s=await le(o,t,n.total);yield{at:t,total:n.total,lines:await De(s,n,t,r)},t+=n.total}}function*Te(o){let e=0;for(;e<o.length;){let r=o.indexOf(10,e),t=r<0?o.length:r;yield{at:e,length:t-e},e=t+1}}import{randomBytes as jt}from"node:crypto";import{open as W,readFile as we,rename as It,rm as vt,stat as Mt}from"node:fs/promises";import{dirname as Ge,join as Dt}from"node:path";var Fe=2e3,C=15,pe=C,T=pe+8,ge={format:1,head:Buffer.from("SFCKIDX1","latin1"),lengthAt:T+8,rowBytes:T+8+4},We={format:2,head:Buffer.from("SFCKIDX2","latin1"),memberBytesAt:T+8,lineAt:T+12,lengthAt:T+16,rowBytes:T+20},Ye={1:ge,2:We},G=ge.head.length,ze=1<<20,Lt=500,F=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,$t=/^[A-Za-z0-9]{15}$/,ye=/^[A-Za-z][A-Za-z0-9_]*$/;function Mr(o,e){return G+o*Ye[e].rowBytes}function _e(o){return o.replace(/[^A-Za-z0-9_-]/g,"_")}function Qe(o,e,r){if(!ye.test(r)||r.length>80)throw new v("invalid","Not a Salesforce API name");return Dt(o.dir,"backups",`${_e(e)}__${_e(r)}.ndjson`)}var Z=class{constructor(e,r){this.layout=e;this.rowBytes=e.rowBytes,this.bytes=r??Buffer.alloc(this.rowBytes*1024),this.size=r?r.length/this.rowBytes:0}layout;bytes;rowBytes;size;push(e,r,t){let n=this.size*this.rowBytes;if(n+this.rowBytes>this.bytes.length){let c=Buffer.alloc(Math.max(this.bytes.length*2,this.rowBytes*1024));this.bytes.copy(c,0,0,n),this.bytes=c}let{memberBytesAt:s,lineAt:a,lengthAt:i}=this.layout;return this.bytes.write(e,n,C,"latin1"),this.bytes.writeDoubleLE(r,n+pe),this.bytes.writeDoubleLE(t.offset,n+T),s!==void 0&&this.bytes.writeUInt32LE(t.memberBytes??0,n+s),a!==void 0&&this.bytes.writeUInt32LE(t.line??0,n+a),this.bytes.writeUInt32LE(t.length,n+i),this.size++}keyAt(e){let r=e*this.rowBytes;return this.bytes.toString("latin1",r,r+C)}holds(e,r){let t=e*this.rowBytes;for(let n=0;n<C;n++)if(this.bytes[t+n]!==r.charCodeAt(n))return!1;return!0}stampAt(e){return this.bytes.readDoubleLE(e*this.rowBytes+pe)}offsetAt(e){return this.bytes.readDoubleLE(e*this.rowBytes+T)}memberBytesAt(e){let r=this.layout.memberBytesAt;return r===void 0?0:this.bytes.readUInt32LE(e*this.rowBytes+r)}lineAt(e){let r=this.layout.lineAt;return r===void 0?0:this.bytes.readUInt32LE(e*this.rowBytes+r)}lengthAt(e){return this.bytes.readUInt32LE(e*this.rowBytes+this.layout.lengthAt)}before(e,r){return this.offsetAt(e)-this.offsetAt(r)||this.lineAt(e)-this.lineAt(r)}wellFormed(e){let r=this.stampAt(e),t=this.offsetAt(e);return $t.test(this.keyAt(e))&&Number.isFinite(r)&&Number.isSafeInteger(t)&&t>=0&&this.lengthAt(e)>0&&(this.layout.format===1||this.memberBytesAt(e)>=he)}written(){return this.bytes.subarray(0,this.size*this.rowBytes)}},X=class{constructor(e,r){this.rows=e;let t=1024;for(;t<r*2;)t*=2;this.slots=new Uint32Array(t)}rows;slots;used=0;find(e){let r=this.slots.length-1;for(let t=ne(e)&r;;t=t+1&r){let n=this.slots[t];if(n===0)return-1;if(this.rows.holds(n-1,e))return n-1}}add(e){let r=this.rows.keyAt(e),t=this.find(r);return t>=0?t:((this.used+1)*2>this.slots.length&&this.grow(),this.place(e,r),this.used++,-1)}place(e,r){let t=this.slots.length-1,n=ne(r)&t;for(;this.slots[n]!==0;)n=n+1&t;this.slots[n]=e+1}grow(){let e=this.slots;this.slots=new Uint32Array(e.length*2);for(let r of e)r!==0&&this.place(r-1,this.rows.keyAt(r-1))}};async function V(o,e){try{return await W(o,"r")}catch(r){throw r.code!=="ENOENT"?r:new v("damaged",`The checkpoint\u2019s snapshot of ${e} is not on this machine.`)}}async function*Je(o,e){let r=await V(o,e);try{let t=Buffer.alloc(ze),n=Buffer.alloc(0),s=0,a=0,i=0;for(;;){let{bytesRead:c}=await r.read(t,0,ze,a);if(c===0)break;a+=c;let d=n.length>0?Buffer.concat([n,t.subarray(0,c)]):t.subarray(0,c),p=0;for(let f=d.indexOf(10);f>=0;f=d.indexOf(10,p))i++,f>p&&(yield{number:i,offset:s+p,length:f-p,text:d.toString("utf8",p,f)}),p=f+1;n=Buffer.from(d.subarray(p)),s+=p}n.length>0&&(yield{number:i+1,offset:s,length:n.length,text:n.toString("utf8")})}finally{await r.close()}}async function*Tt(o,e,r){let t=await V(o,e);try{let n=0;for await(let s of $e(t,(await t.stat()).size,r))for(let a of Te(s.lines))n++,a.length!==0&&(yield{number:n,offset:s.at,memberBytes:s.total,line:a.at,length:a.length,text:s.lines.toString("utf8",a.at,a.at+a.length)})}finally{await t.close()}}async function Ft(o){try{return await Mt(o),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Ke(o){let e=J(o);return e===null?Number.NaN:Date.parse(e)}function K(o){let e;try{e=JSON.parse(o)}catch{return}return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}async function zt(o,e){let r=`${o}.${process.pid}-${jt(4).toString("hex")}.tmp`,t=await W(r,"wx",z);try{try{await t.writeFile(e),await t.sync()}finally{await t.close()}await It(r,o)}catch(n){throw await vt(r,{force:!0}),n}}async function Dr(o,e,r){let t=Qe(o,e,r),n=$(t),s=await Ft(n)?2:1,a=oe(o,r),i=new Z(Ye[s]),c=new X(i,0),d=(m,A)=>new v("damaged",`The snapshot of ${r} holds ${A} at line ${m} of its file: it cannot be indexed.`),p=s===2?Tt(n,r,m=>new v("damaged",`The snapshot of ${r} ${m}: it cannot be indexed.`)):Je(t,r);for await(let m of p){let A=K(m.text);if(!A)throw d(m.number,"no record");let h=A.Id;if(typeof h!="string"||!F.test(h))throw d(m.number,"a record without its Id");let l=Ke(A.SystemModstamp);if(!Number.isFinite(l))throw d(m.number,`record ${h} without its SystemModstamp`);let b=i.push(h.slice(0,C),l,m);if(c.add(b)>=0)throw d(m.number,`record ${h} a second time`)}let f=Buffer.concat([i.layout.head,i.written()]);return await zt(a,f),{rows:i.size,bytes:f.length}}var _t=D({objectApiName:N().regex(ye).max(80),from:N().regex(F),to:N().regex(F)});async function Ze(o){let e;try{e=await W(o,"r"),await e.sync()}catch{}finally{await e?.close().catch(()=>{})}}var me=class o{constructor(e,r){this.current=e;this.original=r}current;original;static none=new o(new Map,new Map);static of(e){let r=new Map;for(let{from:n,to:s}of e)r.set(n.slice(0,C),s);let t=new Map;for(let[n,s]of r)t.set(s.slice(0,C),n);return new o(r,t)}static async read(e){let r;try{r=await we(se(e),"utf8")}catch(s){if(s.code==="ENOENT")return o.none;throw s}let t=r.split(`
|
|
9
9
|
`).slice(0,-1),n=[];for(let[s,a]of t.entries()){if(a==="")continue;let i;try{i=JSON.parse(a)}catch{i=void 0}let c=_t.safeParse(i);if(!c.success)throw new v("damaged",`The checkpoint\u2019s list of the records a rewind made again is damaged at line ${s+1}.`);n.push(c.data)}return o.of(n)}static async add(e,r){if(r.length===0)return;let t=se(e),n=r.map(({objectApiName:i,from:c,to:d})=>`${JSON.stringify({objectApiName:i,from:c,to:d})}
|
|
10
10
|
`).join(""),s=await W(t,"a",z),a=!1;try{a=(await s.stat()).size===0,await s.appendFile(n,"utf8"),await s.sync()}finally{await s.close()}a&&await Ze(Ge(t))}get empty(){return this.current.size===0}currentOf(e){return this.current.get(e)}originalOf(e){return this.original.get(e)}retired(e){return typeof e=="string"&&F.test(e)&&this.current.has(e.slice(0,C))}remapped(e){return typeof e!="string"||!F.test(e)?e:this.current.get(e.slice(0,C))??e}rowAsNow(e){if(this.empty)return e;let r={...e};for(let[t,n]of Object.entries(e)){if(t==="attributes")continue;let s=this.remapped(n);s!==n&&(r[t]=s)}return r}},qt=D({objectApiName:N().regex(ye).max(80),id:N().regex(F)}),qe=class o{constructor(e){this.held=e}held;static none=new o(new Set);static async read(e){let r;try{r=await we(ie(e),"utf8")}catch(n){if(n.code==="ENOENT")return o.none;throw n}let t=new Set;for(let n of r.split(`
|
|
@@ -4,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{a as d,b as g,c as f}from"./chunk-
|
|
7
|
+
import{a as d,b as g,c as f}from"./chunk-4GCYGQXD.mjs";import{a as s}from"./chunk-PPGDAUEQ.mjs";import{a}from"./chunk-SU65Z2BA.mjs";function c(n,t,e){if(!g(t))return;let o=t.edition?`IsSandbox false, edition ${t.edition}`:"IsSandbox false, and no edition",r=e.action==="write"?`${e.tool} writes to sandboxes and Developer Edition orgs only. Nothing was written`:`${e.tool} deletes from sandboxes and Developer Edition orgs only. Nothing was deleted`;return`${n} is a production org (its Organization record says ${o}): ${r}; ${e.readOnly}, which only reads, runs against it.`}function p(n,t,e){let o=t instanceof Error?t.message:String(t),r=`Nothing was ${e.action==="write"?"written":"deleted"}.`,i=`${e.tool} ${e.action==="write"?"writes to":"deletes from"} no org it cannot tell from a production one`;return s(t)?`${n} refused the session sf gave for it (${o}), and ${i}. "sf org display --target-org ${n}" says what sf holds for it; "sf org login web --alias ${n}" signs in again (in a CI job, "sf org login jwt" or "sf org login sfdx-url"); then run the command again. ${r}`:a(t)?`${n} did not answer (${o}), and ${i}. Run the command again once it answers. ${r}`:f(t)?`${n} would not show its Organization record (${o}), and ${i}. Reading it takes the View Setup and Configuration permission: give it to the user the alias signs in as, or name an alias of a user who has it. ${r}`:`${n} did not say what org it is (${o}), and ${i}. ${r}`}var u=1;async function y(n,t,e){let o;try{o=await d(n)}catch(i){process.stderr.write(`${p(t,i,e)}
|
|
8
8
|
`),process.exit(u)}let r=c(t,o,e);return r!==void 0&&(process.stderr.write(`${r}
|
|
9
9
|
`),process.exit(u)),o}export{p as a,y as b};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{Ib as a}from"./chunk-6QSHWIZI.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}:{},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{a,b,c,d}from"./chunk-XJICAOAQ.mjs";import"./chunk-S4PRKKGC.mjs";import"./chunk-H33DVU3D.mjs";import"./chunk-N2HYG3BL.mjs";import"./chunk-WXU6ZJIV.mjs";import"./chunk-R3OM3X4L.mjs";import"./chunk-77IVKH7R.mjs";import"./chunk-2WMKJVD2.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-VXZ5PTOM.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-ZOSESZ22.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-Z3MGN42K.mjs";import"./chunk-2GSMHGIV.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ISOSTAJR.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as auditRequestsOf,a as auditsAskedOf,c as findingsOf,d as readAudits};
|