sandforge 1.80.0 → 1.81.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/bin/sandforge-pipeline.mjs +12 -0
- package/lib/{chunk-EMNC6YI4.mjs → chunk-2IB7I3IQ.mjs} +1 -1
- package/lib/{chunk-3RZQZHEB.mjs → chunk-2NAIUKVL.mjs} +1 -1
- package/lib/{chunk-AEKONPF4.mjs → chunk-2OIRJEYE.mjs} +1 -1
- package/lib/{chunk-BV6VTP3J.mjs → chunk-2OZG6GRW.mjs} +1 -1
- package/lib/{chunk-JEERQRLW.mjs → chunk-2Z54GB6X.mjs} +1 -1
- package/lib/chunk-2ZMGVBLW.mjs +7 -0
- package/lib/{chunk-FKG7Q3WH.mjs → chunk-33ZX3A56.mjs} +1 -1
- package/lib/{chunk-HLWMJF6Y.mjs → chunk-3AOKLIVE.mjs} +1 -1
- package/lib/{chunk-GGD7ON3M.mjs → chunk-3B5H24ZG.mjs} +1 -1
- package/lib/chunk-43K2C6H2.mjs +7 -0
- package/lib/chunk-4JKR4PTZ.mjs +8 -0
- package/lib/chunk-4L7FBOJS.mjs +8 -0
- package/lib/chunk-5344TZBT.mjs +11 -0
- package/lib/{chunk-SAR5622P.mjs → chunk-54HYHHVL.mjs} +1 -1
- package/lib/chunk-55LQD3Y3.mjs +7 -0
- package/lib/chunk-56MPPWLA.mjs +7 -0
- package/lib/chunk-5C5XEVZN.mjs +11 -0
- package/lib/chunk-5CKWGZX4.mjs +9 -0
- package/lib/{chunk-RSWDYIHY.mjs → chunk-5GBO4KD5.mjs} +1 -1
- package/lib/{chunk-BKDV4ENO.mjs → chunk-5UT2ZBGF.mjs} +1 -1
- package/lib/chunk-5VQNKDFU.mjs +7 -0
- package/lib/{chunk-XAMBCQPU.mjs → chunk-5WGA5CZB.mjs} +1 -1
- package/lib/chunk-5ZKCLBTN.mjs +474 -0
- package/lib/{chunk-UCD54V2M.mjs → chunk-67CC7RAE.mjs} +1 -1
- package/lib/{chunk-TSLJUSLW.mjs → chunk-6CDIIFNX.mjs} +1 -1
- package/lib/{chunk-AV5SWEHP.mjs → chunk-6FARZYMJ.mjs} +1 -1
- package/lib/{chunk-FPKYYFM7.mjs → chunk-6FMLW7PH.mjs} +1 -1
- package/lib/chunk-6IGEASOF.mjs +7 -0
- package/lib/{chunk-XUWL6ZPC.mjs → chunk-6NADW3OI.mjs} +1 -1
- package/lib/chunk-6SEDOIO3.mjs +10 -0
- package/lib/{chunk-PJ5I73CK.mjs → chunk-742SSN7I.mjs} +1 -1
- package/lib/chunk-7DALDJMO.mjs +7 -0
- package/lib/chunk-7PK5QDQI.mjs +7 -0
- package/lib/chunk-AELFEK3G.mjs +7 -0
- package/lib/chunk-AITNZWLB.mjs +9 -0
- package/lib/{chunk-2UZPIMUC.mjs → chunk-AJPSGVMD.mjs} +1 -1
- package/lib/{chunk-GSKCGQIP.mjs → chunk-BNO5GIJ6.mjs} +1 -1
- package/lib/{chunk-K2FBZIXY.mjs → chunk-BWWQXU2B.mjs} +1 -1
- package/lib/{chunk-IC2C2GOF.mjs → chunk-BXZ73A5M.mjs} +1 -1
- package/lib/chunk-BZFIOZS3.mjs +156 -0
- package/lib/{chunk-J525F5KI.mjs → chunk-C4YGSK6W.mjs} +1 -1
- package/lib/chunk-CAFUNR6D.mjs +7 -0
- package/lib/chunk-CULAOP3U.mjs +7 -0
- package/lib/chunk-D62KWDDT.mjs +7 -0
- package/lib/{chunk-OHWNPXWW.mjs → chunk-D7P7DTWL.mjs} +1 -1
- package/lib/{chunk-COFG7Q6R.mjs → chunk-DHGPDSXS.mjs} +1 -1
- package/lib/{chunk-WU3GLFZO.mjs → chunk-DHIW4IO5.mjs} +1 -1
- package/lib/{chunk-6XYKJSGX.mjs → chunk-DMBR24CK.mjs} +1 -1
- package/lib/chunk-DPYTG6DM.mjs +48 -0
- package/lib/{chunk-BY2HJFFG.mjs → chunk-DQR5NDMI.mjs} +1 -1
- package/lib/chunk-DXOXLUZA.mjs +7 -0
- package/lib/{chunk-YRQGKDHM.mjs → chunk-E2OBAWSH.mjs} +1 -1
- package/lib/chunk-E2YJVSX6.mjs +10 -0
- package/lib/{chunk-JWTSEDIQ.mjs → chunk-EAFLDSQ2.mjs} +1 -1
- package/lib/{chunk-MILU7WFN.mjs → chunk-EH5YUA5W.mjs} +1 -1
- package/lib/{chunk-BGUEWRK2.mjs → chunk-EOSEMFPU.mjs} +1 -1
- package/lib/chunk-ETT5GP4P.mjs +13 -0
- package/lib/{chunk-MYW5QNGI.mjs → chunk-FDGFUEK3.mjs} +1 -1
- package/lib/{chunk-NTFIRZP6.mjs → chunk-FLNLG43R.mjs} +1 -1
- package/lib/{chunk-CHYDMRSV.mjs → chunk-FSDO4DJA.mjs} +1 -1
- package/lib/{chunk-MJVTDA5Q.mjs → chunk-FSZTXLNW.mjs} +1 -1
- package/lib/{chunk-SOU4FRYN.mjs → chunk-FTA5LOVX.mjs} +1 -1
- package/lib/chunk-G4VXPS3A.mjs +7 -0
- package/lib/chunk-GF247DA7.mjs +7 -0
- package/lib/{chunk-BTWDMNN3.mjs → chunk-GK7VEYFM.mjs} +1 -1
- package/lib/{chunk-SE4QEZUG.mjs → chunk-GR3NGDVM.mjs} +1 -1
- package/lib/{chunk-3TJON4F3.mjs → chunk-GTIXJCGS.mjs} +1 -1
- package/lib/{chunk-NZC67CGR.mjs → chunk-GWRKS3AL.mjs} +1 -1
- package/lib/{chunk-XLXIPIEW.mjs → chunk-GYKNCYES.mjs} +1 -1
- package/lib/{chunk-WIO4XO4F.mjs → chunk-HFSBDM7B.mjs} +1 -1
- package/lib/{chunk-KDGMAGQR.mjs → chunk-HVC5CYIB.mjs} +1 -1
- package/lib/{chunk-WR4Q363I.mjs → chunk-HYBH5PFM.mjs} +1 -1
- package/lib/chunk-HYOOJVR6.mjs +7 -0
- package/lib/{chunk-5K5VLULK.mjs → chunk-IBURU7T7.mjs} +1 -1
- package/lib/chunk-ICIYL45C.mjs +7 -0
- package/lib/{chunk-QR3WELJQ.mjs → chunk-IKGHRYCN.mjs} +1 -1
- package/lib/chunk-IM2XA6JI.mjs +7 -0
- package/lib/{chunk-IWDREM66.mjs → chunk-J6G23RUI.mjs} +1 -1
- package/lib/{chunk-2BA2XKAY.mjs → chunk-JU2XEKEO.mjs} +1 -1
- package/lib/{chunk-MHMH6MTP.mjs → chunk-K55LH4ZQ.mjs} +1 -1
- package/lib/chunk-K5HV4YRO.mjs +7 -0
- package/lib/{chunk-M3ROUWDX.mjs → chunk-K77NR3UK.mjs} +1 -1
- package/lib/chunk-KE2PGD6C.mjs +7 -0
- package/lib/chunk-KGYXLSQ5.mjs +37 -0
- package/lib/{chunk-E5AHXLS6.mjs → chunk-KNIRA333.mjs} +1 -1
- package/lib/chunk-KOQV4WXC.mjs +8 -0
- package/lib/{chunk-L77FJZEP.mjs → chunk-KRNFVAGC.mjs} +1 -1
- package/lib/{chunk-MTMH6H2A.mjs → chunk-LCDPCUXS.mjs} +1 -1
- package/lib/{chunk-YAZO75G2.mjs → chunk-LNXBCE7E.mjs} +1 -1
- package/lib/{chunk-IZQZ6ZUF.mjs → chunk-LO527YLT.mjs} +1 -1
- package/lib/chunk-MAHZMPMZ.mjs +7 -0
- package/lib/{chunk-F6GUDTOB.mjs → chunk-MHW6DV6T.mjs} +1 -1
- package/lib/{chunk-2YIV2OB2.mjs → chunk-MIDBQ7SD.mjs} +1 -1
- package/lib/{chunk-FGRG7ANU.mjs → chunk-MKNAZPOT.mjs} +1 -1
- package/lib/{chunk-PZPJKATS.mjs → chunk-MNITSYI2.mjs} +8 -8
- package/lib/{chunk-OLSGVAIL.mjs → chunk-MO3N5XVV.mjs} +53 -53
- package/lib/chunk-MWLFFVQV.mjs +8 -0
- package/lib/chunk-N6HHNR6J.mjs +7 -0
- package/lib/chunk-N7J6NJQ6.mjs +7 -0
- package/lib/chunk-NJ3EOEHS.mjs +9 -0
- package/lib/chunk-NWPQF5XR.mjs +7 -0
- package/lib/{chunk-IG2MTQRP.mjs → chunk-NWVVCZUK.mjs} +1 -1
- package/lib/{chunk-2NBYT7GR.mjs → chunk-O6ADMP36.mjs} +1 -1
- package/lib/chunk-O7DAFE6M.mjs +14 -0
- package/lib/chunk-OEHVAJAB.mjs +7 -0
- package/lib/chunk-OETEC3P7.mjs +7 -0
- package/lib/{chunk-GCOB7K5N.mjs → chunk-OHEOJISY.mjs} +1 -1
- package/lib/chunk-OIIL4NVI.mjs +7 -0
- package/lib/chunk-OMZJ37JI.mjs +15 -0
- package/lib/{chunk-CEX3NEZL.mjs → chunk-ONMBSACW.mjs} +1 -1
- package/lib/chunk-OQQHNYR7.mjs +272 -0
- package/lib/{chunk-SOGQW4IG.mjs → chunk-OU5W7SCB.mjs} +1 -1
- package/lib/{chunk-O2HDYYUV.mjs → chunk-OVOLG3AL.mjs} +1 -1
- package/lib/{chunk-DYFALGRT.mjs → chunk-OXKZ4Y3B.mjs} +1 -1
- package/lib/{chunk-2GTBABKU.mjs → chunk-OZNLOV4U.mjs} +1 -1
- package/lib/{chunk-TYYOBZMU.mjs → chunk-PC247GKX.mjs} +1 -1
- package/lib/chunk-PPGDAUEQ.mjs +7 -0
- package/lib/{chunk-IGYH7GMA.mjs → chunk-PYUEHBA6.mjs} +1 -1
- package/lib/{chunk-TLH7AD35.mjs → chunk-PZBZ7MNC.mjs} +1 -1
- package/lib/{chunk-DBFJB2B6.mjs → chunk-QIRO4HTE.mjs} +1 -1
- package/lib/{chunk-BXU6WFMH.mjs → chunk-QXLZINZB.mjs} +1 -1
- package/lib/chunk-R2BJWO5N.mjs +20 -0
- package/lib/chunk-R6TF26V4.mjs +10 -0
- package/lib/{chunk-YKKRIEH4.mjs → chunk-RKALOKAU.mjs} +1 -1
- package/lib/chunk-SQGP46QS.mjs +7 -0
- package/lib/chunk-SW2NUKQL.mjs +9 -0
- package/lib/{chunk-MFG4MUIO.mjs → chunk-T26C576X.mjs} +1 -1
- package/lib/{chunk-LKQ5RKIV.mjs → chunk-T3PLRQ2T.mjs} +1 -1
- package/lib/chunk-T5VAULLQ.mjs +7 -0
- package/lib/{chunk-KYEDBS54.mjs → chunk-TEIBWMJM.mjs} +1 -1
- package/lib/chunk-TKQQVB2D.mjs +9 -0
- package/lib/{chunk-ELFXJHU7.mjs → chunk-TPHXRHOA.mjs} +1 -1
- package/lib/chunk-TQ2TQHTT.mjs +9 -0
- package/lib/{chunk-RPI7LRTW.mjs → chunk-TQM2XJ27.mjs} +1 -1
- package/lib/{chunk-IOIWJ3DJ.mjs → chunk-UCHAZ4ZU.mjs} +1 -1
- package/lib/{chunk-G35N4P7D.mjs → chunk-UIUPPEFB.mjs} +1 -1
- package/lib/{chunk-DBB3EMIN.mjs → chunk-UT27HXE7.mjs} +1 -1
- package/lib/{chunk-KBJ5VERV.mjs → chunk-UUSLTW5V.mjs} +1 -1
- package/lib/chunk-V2QO6KOE.mjs +19 -0
- package/lib/chunk-V473C7LY.mjs +7 -0
- package/lib/chunk-V4RKM4QZ.mjs +8 -0
- package/lib/chunk-VSU74RQ3.mjs +9 -0
- package/lib/chunk-VV3B6IC3.mjs +7 -0
- package/lib/chunk-W2AAGIZF.mjs +7 -0
- package/lib/{chunk-WR2GIKWE.mjs → chunk-WB2RIVO3.mjs} +1 -1
- package/lib/chunk-WD47PGUS.mjs +10 -0
- package/lib/{chunk-HEKAZJRH.mjs → chunk-WEZLXE34.mjs} +1 -1
- package/lib/{chunk-W622GUAW.mjs → chunk-WI4HYWV6.mjs} +1 -1
- package/lib/{chunk-WA7EYLAQ.mjs → chunk-WM5JI4JI.mjs} +1 -1
- package/lib/chunk-WWTXRWNZ.mjs +7 -0
- package/lib/{chunk-7EANH5PY.mjs → chunk-WZQEK4WT.mjs} +1 -1
- package/lib/{chunk-FXXLX4O6.mjs → chunk-X2ZVSQ54.mjs} +1 -1
- package/lib/{chunk-ZVAED4QV.mjs → chunk-XC2QKQT5.mjs} +1 -1
- package/lib/chunk-XC54KKKC.mjs +7 -0
- package/lib/chunk-XEB6HZ34.mjs +7 -0
- package/lib/chunk-XGKSSCW7.mjs +7 -0
- package/lib/chunk-XIZ5LMQM.mjs +7 -0
- package/lib/{chunk-74Q6DORA.mjs → chunk-Y5ZCPY36.mjs} +1 -1
- package/lib/{chunk-UNJA4J37.mjs → chunk-YCSFP6ER.mjs} +4 -4
- package/lib/{chunk-X5JYBPXP.mjs → chunk-YHIOS2PU.mjs} +1 -1
- package/lib/chunk-YIGFYZQY.mjs +7 -0
- package/lib/chunk-YJEXE6HZ.mjs +925 -0
- package/lib/{chunk-TTKXMDBN.mjs → chunk-YOGMP72T.mjs} +4 -4
- package/lib/chunk-ZRUDYB7O.mjs +7 -0
- package/lib/{chunk-CU2INBND.mjs → chunk-ZUA5BNAO.mjs} +1 -1
- package/lib/chunk-ZWCRWF7E.mjs +7 -0
- package/lib/{chunk-N652NMZ4.mjs → chunk-ZWZXQTAK.mjs} +52 -52
- package/lib/sandforge-autopilot.mjs +11 -11
- package/lib/sandforge-backup.mjs +63 -32
- package/lib/sandforge-checkpoint.mjs +1 -348
- 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 +11 -11
- package/lib/sandforge-env.mjs +104 -104
- package/lib/sandforge-frozen.mjs +1 -266
- package/lib/sandforge-mcp.mjs +33 -14
- package/lib/sandforge-monitor.mjs +1 -1
- package/lib/sandforge-pipeline.mjs +88 -0
- package/lib/sandforge-seed.mjs +1 -1
- package/lib/sandforge-sync.mjs +1 -1
- package/lib/sandforge.mjs +6 -6
- package/package.json +2 -1
- package/lib/chunk-2CNCDM56.mjs +0 -7
- package/lib/chunk-3F6Q5E7I.mjs +0 -14
- package/lib/chunk-4VS2V6WU.mjs +0 -25
- package/lib/chunk-5P4PHJRL.mjs +0 -9
- package/lib/chunk-5TC3QB4U.mjs +0 -10
- package/lib/chunk-7ABODJ4G.mjs +0 -7
- package/lib/chunk-7EGQP6S4.mjs +0 -7
- package/lib/chunk-7FFGJWHN.mjs +0 -7
- package/lib/chunk-7YDNUBO5.mjs +0 -7
- package/lib/chunk-A527W53V.mjs +0 -7
- package/lib/chunk-ADOAS63R.mjs +0 -7
- package/lib/chunk-B5QQJ4SI.mjs +0 -7
- package/lib/chunk-CION3VMZ.mjs +0 -7
- package/lib/chunk-CSBS5U5I.mjs +0 -7
- package/lib/chunk-DB7RBE5D.mjs +0 -7
- package/lib/chunk-E5ZB3LU5.mjs +0 -7
- package/lib/chunk-EFR2Y7E4.mjs +0 -7
- package/lib/chunk-EHQ3FX6X.mjs +0 -7
- package/lib/chunk-EQNW3UC2.mjs +0 -7
- package/lib/chunk-F43REJDZ.mjs +0 -10
- package/lib/chunk-GSG7WZHM.mjs +0 -7
- package/lib/chunk-HOJYWTP7.mjs +0 -20
- package/lib/chunk-HS4YRX4J.mjs +0 -7
- package/lib/chunk-I7O6C2B5.mjs +0 -8
- package/lib/chunk-IFETCRWE.mjs +0 -10
- package/lib/chunk-IQXHJEYB.mjs +0 -7
- package/lib/chunk-JPUR2CFX.mjs +0 -10
- package/lib/chunk-K327QKMD.mjs +0 -7
- package/lib/chunk-KRCA6IPH.mjs +0 -8
- package/lib/chunk-LPBMBW3O.mjs +0 -13
- package/lib/chunk-LWW4U276.mjs +0 -7
- package/lib/chunk-MJU2PGZQ.mjs +0 -15
- package/lib/chunk-OAZRPP4I.mjs +0 -7
- package/lib/chunk-OO6CLPEH.mjs +0 -7
- package/lib/chunk-OPXCV2KL.mjs +0 -7
- package/lib/chunk-P33PSCXK.mjs +0 -7
- package/lib/chunk-Q3DM32KF.mjs +0 -11
- package/lib/chunk-QROPNEGY.mjs +0 -14
- package/lib/chunk-QWT2C74M.mjs +0 -7
- package/lib/chunk-R3X3LV64.mjs +0 -14
- package/lib/chunk-RMBPOTD7.mjs +0 -7
- package/lib/chunk-SIHORWVK.mjs +0 -7
- package/lib/chunk-T62WNR54.mjs +0 -7
- package/lib/chunk-TTFDUKUS.mjs +0 -47
- package/lib/chunk-VE6XKGGD.mjs +0 -7
- package/lib/chunk-VGW4MXXZ.mjs +0 -7
- package/lib/chunk-VS7ZXUII.mjs +0 -824
- package/lib/chunk-VXQLDM4R.mjs +0 -7
- package/lib/chunk-VYXMVJL5.mjs +0 -7
- package/lib/chunk-W7U5E5ZL.mjs +0 -9
- package/lib/chunk-WXAQ7FK3.mjs +0 -115
- package/lib/chunk-YS4G22C2.mjs +0 -7
- package/lib/chunk-ZM6OJGIG.mjs +0 -7
- package/lib/chunk-ZUTYVST5.mjs +0 -7
package/lib/chunk-7FFGJWHN.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
-
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
-
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
-
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
-
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as 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-G35N4P7D.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-SAR5622P.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-L77FJZEP.mjs";import{X as ce,Y as fe,Z as he,a as X,aa as pe,ba as ge,d as Q,ea as ye,ga as me,ha as Re}from"./chunk-A527W53V.mjs";import{d as Ie,e as Z,f as Ae,k as Te}from"./chunk-GGD7ON3M.mjs";import{b as I}from"./chunk-CA5NAXSU.mjs";import{Rb as le,qc as ue,wb as Y}from"./chunk-TTFDUKUS.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.isCreated(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};
|
package/lib/chunk-7YDNUBO5.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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{$ as p,Aa as Q,M as a,N as b,O as c,P as d,Q as e,R as f,S as g,T as h,U as i,V as j,W as k,X as l,Y as m,Z as n,_ as o,aa as q,ba as r,ca as s,da as t,ea as u,fa as v,ga as w,ha as x,ia as y,ja as z,ka as A,la as B,ma as C,na as D,oa as E,pa as F,qa as G,ra as H,sa as I,ta as J,ua as K,va as L,wa as M,xa as N,ya as O,za as P}from"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{m as ASSIGNMENT_RULES_SOQL,h as AUTOMATION_READ_MOST,b as CONDITIONS_BOUND,f as CONDITION_REQUESTS_BOUND,c as DEFINITIONS_BOUND,g as DEFINITION_REQUESTS_BOUND,n as DUPLICATE_RULES_SOQL,i as FLOWS_SOQL,k as PROCESSES_SOQL,d as TOOLING_QUERIES_PER_REQUEST,e as TOOLING_RETRIEVES_PER_REQUEST,j as TRIGGERS_SOQL,M as TargetAutomationReader,o as USER_PERMISSIONS_SOQL,l as WORKFLOW_RULES_SOQL,a as answerOf,Q as automationLines,p as conditionSoql,z as customObjectIdsSoql,P as customPermissionsByIdSoql,A as customPermissionsSoql,F as decisionChecks,K as inFlight,G as messagesOf,L as objectsTheRunWrites,H as pathsOf,I as permissionKey,C as permissionSetSizesSoql,B as permissionSetsHoldingSoql,D as permissionsNamed,y as processObjectsSoql,N as readBypassGrants,w as readInComposites,x as ruleDefinitionSoql,O as setCustomPermissionsSoql,E as switchesNamed,v as targetAutomationQueries,s as toolingAnswersOf,q as toolingCompositeBody,t as toolingRecordsOf,r as toolingRetrieveBody,u as toolingRetrievesOver,J as unreadPartOf};
|
package/lib/chunk-A527W53V.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
-
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
-
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
-
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
-
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as O,f as dt,h as C}from"./chunk-TZE3Y7IQ.mjs";import{Rb as at}from"./chunk-TTFDUKUS.mjs";var It="AccountContactRelation",D="EmailMessage",z="Task",tt="TaskRelation",j="EventRelation",B=200,en={ProductSellingModel:["SellingModelType","PricingTerm","PricingTermUnit"]},X={FeedItem:[{field:"Type",value:"TrackedChange",noun:"tracked change"}],[tt]:[{field:"IsWhat",value:!0,noun:"what relation",from:"the task's WhatId"}],[j]:[{field:"IsWhat",value:!0,noun:"what relation",from:"the event's WhatId"}],EmailMessageRelation:[{noun:"email relation",from:"the email's addresses"}]};function Et(t,n){return X[t]?.find(e=>e.field===void 0||e.value!==void 0&&String(n[e.field])===String(e.value))}var ut=class{constructor(n=Et){this.rowsOf=n}rowsOf;reasons=new Map;byObject=new Map;leaveOut(n,e,r,o=[]){let i=this.reasons.get(e);if(i)return i;let s=this.reasonFor(n,r,o);if(!s)return;this.reasons.set(e,s);let d=this.byObject.get(n)??new Map,u=`${s.rows.field}=${s.rows.value}|${s.through??""}`,l=d.get(u)??{why:s,ids:new Set};return l.ids.add(e),d.set(u,l),this.byObject.set(n,d),s}keep(n,e,r=[]){return e.filter(o=>!this.leaveOut(n,String(o.Id),o,r))}has(n){return this.reasons.has(n)}counts(n){return(n===void 0?[...this.byObject]:[[n,this.byObject.get(n)]]).flatMap(([r,o])=>[...o?.values()??[]].map(({why:i,ids:s})=>({objectApiName:r,why:i,count:s.size})))}reasonFor(n,e,r){let o=this.rowsOf(n,e);if(o)return{rows:o};for(let i of r){let s=e[i],d=typeof s=="string"?this.reasons.get(s):void 0;if(d)return{rows:d.rows,through:i}}}};function rn(t,n){if(n.through)return`${t} left out: ${n.through} names a ${n.rows.noun}, which the platform writes itself`;let e=n.rows.from?`, from ${n.rows.from}`:"";return`${t} ${n.rows.noun}${t===1?"":"s"} left out: the platform writes them itself${e}`}function on(t,n){let e=`${t} record${t===1?"":"s"}`;return n.through?`${n.through} \u2192 ${n.rows.noun} (${e})`:n.rows.field===void 0?`every ${n.rows.noun} (${e})`:`${n.rows.field}=${String(n.rows.value)} (${e})`}function sn(t){return t.through?`Not written: ${t.through} may not be left empty, and the ${t.rows.noun} it names is one the platform writes itself, which no copy sends.`:t.rows.from?`Not written: the platform writes each ${t.rows.noun} itself, from ${t.rows.from}.`:`Not written: the platform writes each ${t.rows.noun} itself, and refuses one a copy sends.`}function ct({field:t,value:n},e){if(t===void 0)return e==="="?"Id != null":"Id = null";let r=typeof n=="boolean"?String(n):`'${O(n??"")}'`;return`${C(t)} ${e} ${r}`}function an(t,n,e){let r=s=>s.map(d=>ct(d,"=")).join(" OR "),o=(X[t]??[]).map(s=>ct(s,"!=")),i=n.flatMap(s=>s.referenceTo.flatMap(d=>{let u=X[d];if(d===t||!e.has(d)||!u||u.length===0)return[];let l=e.get(d),I=l?`(${dt(l)}) AND (${r(u)})`:`(${r(u)})`;return[`${C(s.name)} NOT IN (SELECT Id FROM ${C(d)} WHERE ${I})`]}));return[...o,...i]}var $t={[tt]:new Set(["Contact","Lead"]),[j]:new Set(["Contact","Lead","User","Calendar"])};function dn(t,n,e){let r=$t[t];if(!r)return n;let o=n.IsWhat;return o!==""&&o!==null&&o!==void 0||e===void 0||r.has(e)?n:{...n,IsWhat:!0}}var Ct="500";function kt(t){return t.startsWith(Ct)?"Case":void 0}function ht(t,n=kt){let e=t.ParentId;if(typeof e=="string"&&e!=="")return!0;let r=t.RelatedToId;return typeof r=="string"&&r!==""&&n(r)==="Case"}function un(t,n){return t===D&&!ht(n)?["ActivityId"]:[]}function cn(t){return!t.has(D)||!t.has(z)?[]:[{sourceObject:D,targetObject:z,relationshipName:`${D}Before${z}`,type:"lookup",required:!0}]}function fn(t,n){let e=t.ActivityId;return typeof e=="string"&&e!==""&&ht(t,n)}var T=200;async function ln(t,n){let e=new Map;for(let r=0;r<n.length;r+=T){let o=n.slice(r,r+T).map(s=>`'${O(s)}'`).join(", "),i=await t(`SELECT Id, ActivityId FROM ${D} WHERE Id IN (${o})`);for(let s of i){let d=s.ActivityId;typeof s.Id=="string"&&typeof d=="string"&&d!==""&&e.set(s.Id,d)}}return e}var N="Account",H="Contact",Q="PersonContactId",mt="IsPersonAccount";function Pt(t){let n=t[mt];return n===!0||n==="true"||n===1}function gn(t,n){return Pt(t)?n?"personAsBusiness":"person":"business"}function pn(t,n){return t==="person"?n==="person":n!=="person"}function yn(t,n){return!t.has(N)||!t.has(H)?[]:n.get(N)?.some(r=>r.name===Q)===!0||n.get(H)?.some(r=>r.name===mt)===!0?[{sourceObject:N,targetObject:H,relationshipName:`${N}Before${H}`,type:"lookup",required:!0}]:[]}function Mt(t){let n=t.map(e=>`'${O(e)}'`).join(", ");return`SELECT Id, ${Q} FROM ${N} WHERE Id IN (${n})`}var At=new RegExp(`^SELECT Id, ${Q} FROM ${N} WHERE Id IN \\((.*)\\)$`);function Rn(t){let n=At.exec(t);if(n)return[...n[1].matchAll(/'([^']*)'/g)].map(([,e])=>e)}async function wn(t,n){let e=new Map;for(let r=0;r<n.length;r+=T){let o=await t(Mt(n.slice(r,r+T)));for(let i of o){let s=i[Q];typeof i.Id=="string"&&typeof s=="string"&&s!==""&&e.set(i.Id,s)}}return e}var v="OpportunityTeamMember",M="OpportunitySplit",Lt="Opportunity",Z="OpportunitySplitType",$="SplitTypeId",nt={[v]:"UserId",[M]:"SplitOwnerId"};function In(t){return nt[t]!==void 0}function hn(t){return t==="Task"?"their email":t==="Contact"?"their person account":t===It?"their contact":t===Ot?"their opportunity, for its contact":"their opportunity, for its owner"}var Ot="OpportunityContactRole",Y="ContactId",ft=t=>t.IsPrimary===!0||t.IsPrimary==="true";function Nt(t,n){let e=new Map;return t.forEach((r,o)=>{let i=w(r,"OpportunityId"),s=w(r,Y);if(i===void 0||s===void 0)return;let d=n(i);if(d===void 0||y(d)!==y(s))return;let u=y(i),l=e.get(u);(l===void 0||!ft(t[l])&&ft(r))&&e.set(u,o)}),[...e.values()].sort((r,o)=>r-o)}var lt=["CreatedDate","CreatedById","Opportunity.CreatedDate","Opportunity.CreatedById"];function xt(t,n=[]){let e=["Id","OpportunityId",Y],r=[...e,...lt];return`SELECT ${[...e,...lt,...n.filter(i=>!r.includes(i)).map(C)].join(", ")} FROM ${Ot} WHERE OpportunityId IN ${et(t)} ORDER BY CreatedDate, Id`}var bt=/^SELECT Id, OpportunityId, ContactId, CreatedDate, CreatedById, Opportunity\.CreatedDate, Opportunity\.CreatedById((?:, \w+)*) FROM OpportunityContactRole WHERE OpportunityId IN (\(.*\)) ORDER BY CreatedDate, Id$/;function mn(t){let n=bt.exec(t);if(!n)return;let[,e,r]=n;return{fields:e.split(", ").filter(o=>o!==""),opportunities:rt(r)}}async function _t(t,n,e=[]){let r=[];for(let o=0;o<n.length;o+=T)r.push(...await t(xt(n.slice(o,o+T),e)));return r}var Ft=1,gt=t=>typeof t=="string"&&t!==""?Math.floor(Date.parse(t)/1e3):Number.NaN;function Wt(t){let n=t.Opportunity;if(typeof n!="object"||n===null)return!1;let e=n,r=w(t,"CreatedById"),o=w(e,"CreatedById"),i=gt(t.CreatedDate),s=gt(e.CreatedDate);return r!==void 0&&o!==void 0&&y(r)===y(o)&&!Number.isNaN(i)&&!Number.isNaN(s)&&i-s>=0&&i-s<=Ft}function Dt(t,n){let e=new Map;for(let i of n){let s=w(i,"Id"),d=w(i,"OpportunityId"),u=w(i,Y);if(!s||!d||!u||!Wt(i))continue;let l=`${y(d)}:${y(u)}`;e.set(l,[...e.get(l)??[],i])}let r=new Map,o=[];for(let[i,{opportunity:s,contact:d}]of t){let u=e.get(`${y(s)}:${y(d)}`)??[];u.length>1?o.push(i):u.length===1&&r.set(i,u[0])}return{found:r,alike:o}}function On(t,n="read"){return`${t} contact role(s) not linked to the one the platform wrote with their opportunity, so written as ${n}: the target holds more than one role of their contact under it made with it, within a second, by the same user, and nothing tells which the platform wrote. The opportunity holds the role of its contact more than once.`}var vt="the user the run writes as";function Sn(t,n){let e={CreatedDate:n,CreatedById:vt};return{...t,...e,Opportunity:{...e}}}async function Tn(t,n,e,r=[]){let o=Nt(n,e);if(o.length===0)return{found:new Map,alike:[]};let i=new Map(o.map(d=>[d,{opportunity:String(n[d].OpportunityId),contact:String(n[d][Y])}])),s=await _t(t,[...new Set([...i.values()].map(({opportunity:d})=>d))],r);return Dt(i,s)}function En(t){return!t.has(v)||!t.has(M)?[]:[{sourceObject:v,targetObject:M,relationshipName:`${v}Before${M}`,type:"lookup",required:!0}]}var Ut={[v]:{TeamMemberRole:"Opportunity Owner",OpportunityAccessLevel:"All"},[M]:{}},pt=t=>!/__c$/i.test(t),qt=new Set(["SplitPercentage","SplitAmount","CurrencyIsoCode"]),U=`SELECT Id, OwnerId FROM ${Lt} WHERE Id IN `,Kt=`SELECT Id, DeveloperName, IsTotalValidated FROM ${Z} WHERE IsActive = true`,et=t=>`(${t.map(n=>`'${O(n)}'`).join(", ")})`,rt=t=>[...t.matchAll(/'([^']*)'/g)].map(([,n])=>n);function $n(t){return`${U}${et(t)}`}function Cn(t){if(!t.startsWith(U))return;let n=t.slice(U.length);return/^\(.*\)$/.test(n)?rt(n):void 0}function St(t,n){let e=nt[t];return`SELECT ${["Id","OpportunityId",...t===M?[e,$]:[e],...n].join(", ")} FROM ${t} WHERE OpportunityId IN `}function kn(t,n,e){return`${St(t,n)}${et(e)}`}var Ht=/^SELECT Id, OpportunityId, (?:UserId|SplitOwnerId, SplitTypeId)((?:, \w+)*) FROM (OpportunityTeamMember|OpportunitySplit) WHERE OpportunityId IN (\(.*\))$/;function Pn(t){let n=Ht.exec(t);if(!n)return;let[,e,r,o]=n;return{objectApiName:r,fields:e.split(", ").filter(i=>i!==""),opportunities:rt(o)}}var y=t=>t.slice(0,15);async function W(t,n,e){let r=[];for(let o=0;o<e.length;o+=T){let i=e.slice(o,o+T).map(s=>`'${O(s)}'`).join(", ");r.push(...await t(`${n}(${i})`))}return r}function J(t,n){let e=new Map;for(let r of t){let o=r[n];typeof r.Id=="string"&&typeof o=="string"&&o!==""&&e.set(y(r.Id),o)}return e}var w=(t,n)=>{let e=t[n];return typeof e=="string"&&e!==""?e:void 0};async function Mn(t,n,e){let r={lookups:new Map,linked:new Map,held:new Map,defaulted:new Set},o=nt[t];if(o===void 0)return r;let i=t===M,s=n.filter(a=>{let f=w(a,"OpportunityId");return f!==void 0&&e.targetIdOf(f)!==void 0});if(s.length===0)return r;let d=[...new Set(s.map(a=>String(a.OpportunityId)))],u=J(await W(e.source,U,d),"OwnerId"),l=a=>e.targetIdOf(String(a.OpportunityId)),I=[...new Set(s.map(l))],{simulated:S}=e,x=S?void 0:J(await W(e.target,U,I),"OwnerId"),b=a=>{let f=u.get(y(String(a.OpportunityId)));return f===void 0?{}:{source:f,target:S?S.ownerOf(f):x?.get(y(l(a)))}},_=a=>{let f=w(a,o),R=b(a).source;return f!==void 0&&R!==void 0&&y(f)===y(R)},A=[...new Set(s.flatMap(a=>{let f=w(a,o);return f===void 0||_(a)||e.mappedUser(f)!==void 0?[]:[f]}))],q=A.length>0?new Set((await W(e.target,"SELECT Id FROM User WHERE IsActive = true AND Id IN ",A)).flatMap(a=>typeof a.Id=="string"?[y(a.Id)]:[])):new Set,K=i?J(await W(e.source,`SELECT Id, DeveloperName FROM ${Z} WHERE Id IN `,[...new Set(s.flatMap(a=>w(a,$)??[]))]),"DeveloperName"):new Map,F=new Map;if(i)for(let a of await e.target(Kt))typeof a.Id=="string"&&typeof a.DeveloperName=="string"&&F.set(a.DeveloperName,{id:a.Id,total:a.IsTotalValidated===!0||a.IsTotalValidated==="true"});let c=(e.written??[]).filter(a=>a!=="Id"&&a!=="OpportunityId"&&a!==o&&a!==$&&!qt.has(a)),g=(a,f)=>{let R=a[f];return!(R==null||R===""||R===!1)},p=(a,f,R=c)=>R.filter(k=>g(a,k)&&String(a[k])!==String(f[k]??"")),m=new Map,h=(a,f,R)=>[a,f,R??""].map(y).join("|");if(!S)for(let a of await W(e.target,St(t,c),I)){let f=w(a,"OpportunityId"),R=w(a,o);typeof a.Id!="string"||f===void 0||R===void 0||m.set(h(f,R,i?w(a,$):void 0),a)}for(let a of s){let f=w(a,o);if(f===void 0)continue;let R=_(a),k=b(a).target,L=R?k:e.mappedUser(f)??(q.has(y(f))?f:void 0),ot=!R&&L===void 0&&e.defaultUser!==void 0;if(ot&&(L=e.defaultUser),L===void 0){r.held.set(a,{field:o,parentObject:"User",why:R?`${o} names the owner of its opportunity, whose owner in the target could not be read.`:`${o} names a user the target has no counterpart of: a team member and a split go in for the opportunity's owner, which is the owner of its copy in the target, for a user an owner mapping gives, or for a user of the same id the target holds active.`});continue}let G={[o]:L},it=!1;if(i){let E=w(a,$);if(E!==void 0){let P=K.get(y(E)),V=P===void 0?void 0:F.get(P);if(V===void 0){r.held.set(a,{field:$,parentObject:Z,why:`${$} names ${P===void 0?"a split type":`the split type ${P}`}, which the target holds no active one of by that name: sent without it, the split would go in as one of the Revenue type.`});continue}G[$]=V.id,it=V.total}}let Tt=l(a),st=k!==void 0&&y(L)===y(k);if(S){if(st&&(!i||it)){let E=c.filter(P=>!pt(P)&&g(a,P));r.linked.set(a,{id:S.idFor(),owners:!0,notKept:p(a,Ut[t]??{},c.filter(pt)),...E.length>0?{unread:E}:{}});continue}}else{let E=m.get(h(Tt,L,G[$]));if(E!==void 0){r.linked.set(a,{id:String(E.Id),owners:st,notKept:p(a,E)});continue}}r.lookups.set(a,G),ot&&r.defaulted.add(a)}return r}var Bt={[tt]:"TaskId",[j]:"EventId"};async function An(t,n,e){let r=new Map,o=Bt[n];if(o===void 0)return r;let i=[...new Set(e.map(d=>d[o]).filter(d=>typeof d=="string"&&d!==""))];if(i.length===0)return r;let s=new Map;for(let d=0;d<i.length;d+=T){let u=i.slice(d,d+T).map(I=>`'${O(I)}'`).join(", "),l=await t(`SELECT Id, ${o}, RelationId FROM ${n} WHERE ${o} IN (${u})`);for(let I of l)typeof I.Id=="string"&&s.set(`${String(I[o])}|${String(I.RelationId)}`,I.Id)}return e.forEach((d,u)=>{let l=s.get(`${String(d[o])}|${String(d.RelationId)}`);l&&r.set(u,l)}),r}var jt={[j]:["IsInvitee"]},yt={IsInvitee:["Status","Response","RespondedDate"]},Rt="the run was cancelled before it was updated";async function Ln(t,n,e,r,o=()=>!1){return Qt(await Yt(t,n,e,r,o))}function Qt(t){if(!(t===void 0||t.size===0))return[...t].map(([n,e])=>`${e} linked without ${n}`).join(", ")}function Nn(t,n){if(n.size===0)return t;let e=new Map(t??[]);for(let[r,o]of n)e.set(r,(e.get(r)??0)+o);return e}async function Yt(t,n,e,r,o=()=>!1){let i=jt[t]??[],s=new Set(i.flatMap(c=>[c,...yt[c]??[]]).filter(c=>!e(c))),d=new Map,u=(c,g)=>{let p=`${c}: ${g}`;d.set(p,(d.get(p)??0)+1)},l=[];for(let[c,g]of n){let p={},m={};for(let h of i.filter(a=>String(c[a])==="true")){if(s.has(h)){u(h,"the target does not let it be updated");continue}p[h]=!0;for(let a of yt[h]??[]){let f=c[a];f==null||f===""||(s.has(a)?u(a,"the target does not let it be updated"):m[a]=f)}}Object.keys(p).length>0&&l.push({Id:g,flagsGiven:p,answer:m})}let I=!1,S=async c=>{let g=new Map;if(c.length===0)return g;if(o()){for(let h of c)g.set(h.Id,Rt);return g}if(I)return g;let p=await r(c);I=p.length<c.length;let m=o();return c.forEach((h,a)=>{let f=p[a];f?.success||g.set(h.Id,f===void 0&&m?Rt:`the target refused the update, ${f?.errors[0]??"without saying why"}`)}),g},x=(c,g)=>{for(let p of c){let m=g.get(p.Id);if(m!==void 0)for(let h of Object.keys(p).filter(a=>a!=="Id"))u(h,m)}},b=l.map(({Id:c,flagsGiven:g,answer:p})=>({Id:c,...g,...p})),_=await S(b),A=I||o()?[]:l.filter(({Id:c,answer:g})=>_.has(c)&&Object.keys(g).length>0);x(b.filter(c=>!A.some(({Id:g})=>g===c.Id)),_);let q=A.map(({Id:c,flagsGiven:g})=>({Id:c,...g})),K=await S(q);x(q,K);let F=A.filter(({Id:c})=>!K.has(c));for(let c of new Set(F.flatMap(({answer:g})=>Object.keys(g)))){let g=F.filter(({answer:p})=>c in p).map(({Id:p,answer:m})=>({Id:p,[c]:m[c]}));x(g,await S(g))}return d}var xn={Order:"OrderStatus",Contract:"ContractStatus"},bn=new Set(["Contract"]);function Gt(t){return t==null||t===""?"null":typeof t=="number"||typeof t=="boolean"?String(t):`'${O(String(t))}'`}async function _n(t,n){let e=new Map,r=[...new Set(n.map(i=>i.ContactId).filter(i=>typeof i=="string"&&i!==""))];if(r.length===0)return e;let o=new Map;for(let i=0;i<r.length;i+=B){let s=r.slice(i,i+B).map(u=>`'${O(u)}'`).join(", "),d=await t(`SELECT Id, AccountId, ContactId FROM ${It} WHERE IsDirect = true AND ContactId IN (${s})`);for(let u of d)typeof u.Id=="string"&&o.set(`${String(u.AccountId)}|${String(u.ContactId)}`,u.Id)}return n.forEach((i,s)=>{let d=o.get(`${String(i.AccountId)}|${String(i.ContactId)}`);d&&e.set(s,d)}),e}async function Fn(t,n){let e=new Set;for(let r=0;r<n.length;r+=B){let o=n.slice(r,r+B).map(s=>`'${O(s)}'`).join(", "),i=await t(`SELECT Id FROM PricebookEntry WHERE Id IN (${o}) AND Pricebook2.IsStandard = true`);for(let s of i)typeof s.Id=="string"&&e.add(s.Id)}return e}var wt=200;async function Wn(t,n){let e=new Map,r=[...new Set(n.map(i=>i.Product2Id).filter(i=>typeof i=="string"&&i!==""))];if(r.length===0)return e;let o=new Map;for(let i=0;i<r.length;i+=wt){let s=r.slice(i,i+wt).map(u=>`'${O(u)}'`).join(", "),d=await t(`SELECT Id, Product2Id, ProductSellingModelId FROM ${at} WHERE Product2Id IN (${s})`);for(let u of d)typeof u.Id=="string"&&o.set(`${String(u.Product2Id)}|${String(u.ProductSellingModelId)}`,u.Id)}return n.forEach((i,s)=>{let d=o.get(`${String(i.Product2Id)}|${String(i.ProductSellingModelId)}`);d&&e.set(s,d)}),e}async function Dn(t,n,e,r){let o=new Map;for(let i of r){let s=JSON.stringify(e.map(l=>i[l]??null));if(o.has(s))continue;let d=e.map(l=>`${C(l)} = ${Gt(i[l])}`).join(" AND "),u=await t(`SELECT Id FROM ${C(n)} WHERE ${d} LIMIT 2`);o.set(s,u.length===1&&typeof u[0].Id=="string"?u[0].Id:void 0)}return r.map(i=>o.get(JSON.stringify(e.map(s=>i[s]??null))))}async function vn(t,n){let e;try{e=await t(`SELECT ApiName, StatusCode FROM ${C(n)}`)}catch{return}return{categoryOf:new Map(e.map(r=>[String(r.ApiName),String(r.StatusCode)])),draft:e.filter(r=>r.StatusCode==="Draft").map(r=>String(r.ApiName)).sort()[0]}}function Un(t,n){if(typeof t!="string"||t===""||!n.draft)return;let e=n.categoryOf.get(t);if(!(e===void 0||e==="Draft"))return n.draft}export{It as a,D as b,z as c,en as d,ut as e,rn as f,on as g,sn as h,an as i,dn as j,ht as k,un as l,cn as m,fn as n,ln as o,N as p,H as q,Q as r,Pt as s,gn as t,pn as u,yn as v,Mt as w,Rn as x,wn as y,v as z,M as A,nt as B,In as C,hn as D,Ot as E,Y as F,ft as G,Nt as H,xt as I,mn as J,_t as K,Dt as L,On as M,Sn as N,Tn as O,En as P,Ut as Q,Kt as R,$n as S,Cn as T,kn as U,Pn as V,Mn as W,Bt as X,An as Y,jt as Z,Ln as _,Qt as $,Nn as aa,Yt as ba,xn as ca,bn as da,_n as ea,Fn as fa,Wn as ga,Dn as ha,vn as ia,Un as ja};
|
package/lib/chunk-ADOAS63R.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
-
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
-
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
-
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
-
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c}from"./chunk-VXQLDM4R.mjs";import"./chunk-UNJA4J37.mjs";import"./chunk-XLXIPIEW.mjs";import"./chunk-TTKXMDBN.mjs";import"./chunk-TSLJUSLW.mjs";import"./chunk-KRCA6IPH.mjs";import"./chunk-5TC3QB4U.mjs";import"./chunk-2BA2XKAY.mjs";import"./chunk-OAZRPP4I.mjs";import"./chunk-JEERQRLW.mjs";import"./chunk-MHMH6MTP.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-MJU2PGZQ.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LWW4U276.mjs";import"./chunk-MJVTDA5Q.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-2CNCDM56.mjs";import"./chunk-SIHORWVK.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-B5QQJ4SI.mjs";import"./chunk-NZC67CGR.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-F43REJDZ.mjs";import"./chunk-JPUR2CFX.mjs";import"./chunk-LPBMBW3O.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-IFETCRWE.mjs";import"./chunk-PZPJKATS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-MFG4MUIO.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-HS4YRX4J.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{b as UNDO_AUTOMATION_LIFTED_BY,a as UndoStopped,c as undoCheckpoint};
|
package/lib/chunk-B5QQJ4SI.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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{j as Z,l as N}from"./chunk-NZC67CGR.mjs";import{B as Q,s as Y,t as T,v as K,z as J}from"./chunk-MFG4MUIO.mjs";import{z as H}from"./chunk-EQNW3UC2.mjs";import{d as G}from"./chunk-GSKCGQIP.mjs";import{Pa as se,Qa as M,Za as re,ka as ee,r as V,s as X,va as te,w as z}from"./chunk-VYXMVJL5.mjs";import{b as U,c as B}from"./chunk-SU65Z2BA.mjs";import{b as $}from"./chunk-CA5NAXSU.mjs";import{Mc as I,Qc as C,Vc as S,Yc as F,Zc as q}from"./chunk-TTFDUKUS.mjs";var _e=5e3,x=2e3,le=1e3,me={masking:{during:"during the masking",records:"records it masked"},restore:{during:"during the restore",records:"records it put back"},erasure:{during:"during the erasure",records:"records it overwrote"}};function ne(e,s){let r=new Set(s.map(t=>t.toLowerCase()));return(e?.objects??[]).filter(t=>r.has(t.objectApiName.toLowerCase())).filter(t=>(t.duplicateRules??[]).length>0).map(t=>({objectApiName:t.objectApiName,rules:(t.duplicateRules??[]).map(n=>n.name)}))}function ae(e){return typeof e=="string"?e.slice(0,15):""}async function pe(e,s){let{rules:r}=s,t=0,n=a=>(t++,e.query(a));try{let a=H(new Date(Date.parse(s.since)-le).toISOString()),i=new Set([...s.masked].map(ae)),d=await n(`SELECT Id, DuplicateRecordSetId, RecordId FROM DuplicateRecordItem WHERE CreatedDate >= ${a} LIMIT ${x+1}`),u=d.done===!1||d.records.length>x,c=d.records.slice(0,x),p=new Set(c.filter(o=>i.has(ae(o.RecordId))).map(o=>String(o.DuplicateRecordSetId??"")).filter(o=>o!=="")),l=c.filter(o=>p.has(String(o.DuplicateRecordSetId??""))).length,m=0;for(let o of G([...p])){let f=await n(`SELECT Id FROM DuplicateRecordSet WHERE CreatedDate >= ${a} AND Id IN (${o})`);m+=f.records.length}return{rules:r,sets:m,items:l,...u?{atLeast:!0}:{},requests:t}}catch(a){return{rules:r,sets:0,items:0,unread:$(a),requests:t}}}function Ie(e,s,r){let t=r.now??Date.now,n=r.sleep??(l=>new Promise(m=>setTimeout(m,l))),a=new Set(s.map(l=>l.objectApiName.toLowerCase())),i=l=>a.has(l.toLowerCase()),d,u=0,c=new Set,p=0;return{covers:i,beforeWrite:l=>{i(l)&&d===void 0&&(u=t())},wrote:(l,m)=>{if(!i(l))return;let o=!1;for(let h of m)typeof h!="string"||h===""||(c.add(h),o=!0);if(!o)return;p=t();let f=u;d??=e.serverTime().then(h=>{let A=Date.parse(h);return Number.isNaN(A)?{unread:`it answered "${h}"`}:{at:new Date(A-Math.max(0,t()-f)).toISOString()}},h=>({unread:$(h)}))},read:async()=>{if(c.size===0)return;let l=d?await d:void 0;if(!l||"unread"in l)return{rules:s,sets:0,items:0,unread:l?`the org's clock: ${l.unread}`:"the org's clock was not read",requests:l?1:0};let m=Math.max(0,p+r.settleMs-t());m>0&&await n(m);let o=await pe(e,{rules:s,since:l.at,masked:c});return{...o,requests:(o.requests??0)+1,waitedMs:m}}}}function Ce(e){return e!==void 0&&(e.sets>0||e.items>0||e.unread!==void 0)}function ge(e){return e.map(s=>`"${s}"`).join(", ")}function fe(e){return e<=0?"without waiting":e<1e3?"after waiting less than 1 s":`after waiting ${Math.round(e/1e3)} s`}function Fe(e,s,r="masking"){if(!e||e.rules.length===0)return"";let t=me[r],n=e.rules.map(d=>`${d.objectApiName} (${ge(d.rules)})`).join(", ");if(e.unread!==void 0)return`What the duplicate rules of ${s} on ${n} wrote ${t.during} could not be read (${e.unread}): a duplicate record set they wrote stays.`;let a=e.requests!==void 0?` Read in ${e.requests} request(s), ${fe(e.waitedMs??0)}.`:"";if(e.sets===0&&e.items===0)return`The duplicate rules of ${s} on ${n} wrote nothing for the ${t.records}.`+a;let i=e.atLeast===!0?"at least ":"";return`The duplicate rules of ${s} on ${n} wrote ${i}${e.sets} duplicate record set(s) and ${i}${e.items} item(s) ${t.during}, for ${t.records}: kept, as they name records that stay.${a}`}var he="AUTOMATION_NOT_ACCEPTED",we="EMAILS_EXCEEDED",Oe="ORG_TEMPORARILY_UNREACHABLE";function be(e,s){return e==="cleanup"||e==="empty"?{delete:[...s]}:e==="restore"?{bringBack:[...s],giveBack:[...s]}:e==="emptyUndo"?{bringBack:[...s]}:{giveBack:[...s]}}function Ae(e,s){let r=e==="cleanup"||e==="empty"?"delete":"update";return s.filter(t=>t.records>0).map(t=>({objectApiName:t.objectApiName,write:r,records:t.records}))}var E={masking:{heading:"masking automation: what {org} runs as the masking writes over the records",the:"the masking",this:"this masking",writes:"writes over",verb:"mask",nothing:"Nothing was written.",flag:"to mask all the same"},restore:{heading:"restore automation: what {org} runs as the restore puts the backup's values back",the:"the restore",this:"this restore",writes:"puts back",verb:"restore",nothing:"Nothing was written.",flag:"to restore all the same"},cleanup:{heading:"cleanup automation: what {org} runs as the cleanup deletes the records",the:"the cleanup",this:"this cleanup",writes:"deletes",verb:"delete",nothing:"Nothing was deleted.",flag:"to delete all the same"},empty:{heading:"emptying automation: what {org} runs as the emptying deletes the records",the:"the emptying",this:"this emptying",writes:"deletes",verb:"empty",nothing:"Nothing was deleted.",flag:"to empty all the same"},emptyUndo:{heading:"undo automation: what {org} runs as the undo brings the records back",the:"the undo",this:"this undo",writes:"brings back",verb:"undo",nothing:"Nothing was written.",flag:"to undo all the same"}},$e={masking:"masking",restore:"restore",cleanup:"cleanup",empty:"empty",emptyUndo:"undo"};function Ke(e){return e.erasure===!0?"erasure":e.fromPage===!0?"page":void 0}var ye={"accept-automation":"acceptAutomation","accept-emails":"acceptEmails","mute-automation":"muteAutomation"},De={"accept-emails":"the confirmation's box that lets the org send these emails","mute-automation":"the confirmation's box that mutes the target's automation"},Re={mask:"masking",restore:"restore",delete:"cleanup",erase:"erasure",empty:"emptying",undo:"undo"};function oe(e){let s=r=>De[r]??`--${r}`;return e.replace(/\bAdd --accept-automation to (mask|restore|delete|erase|empty|undo) all the same\b/g,(r,t)=>`Confirm the ${Re[t]??t} from its confirmation, which lists what fires, to ${t} all the same`).replace(/\bWith --mute-automation,/g,`With ${s("mute-automation")} ticked,`).replace(/\bAdd --(accept-emails|mute-automation)\b/g,(r,t)=>`Tick ${s(t)}`).replace(/(^|[.:;] )--(accept-emails|mute-automation)\b/g,(r,t,n)=>`${t}${W(s(n))}`).replace(/--(accept-emails|mute-automation)\b/g,(r,t)=>s(t))}function L(e,s="flags"){return s==="step"?e.replace(/--(accept-automation|accept-emails|mute-automation)\b/g,(r,t)=>`${ye[t]??t} in the step`).replace(/\bAdd (acceptAutomation|acceptEmails|muteAutomation) in the step\b/g,"Turn on $1 in the step"):s==="erasure"?oe(e.replace(/\b(this|the|This|The) (masking|cleanup)\b/g,"$1 erasure").replace(/\bto (mask|delete) all the same\b/g,"to erase all the same").replace(/\b(mask|delete) fewer records\b/g,"erase fewer records")):s==="page"?oe(e):e}var ke={before:"before save",after:"after save",beforeAndAfter:"before and after save"},Ee={before:"before delete",after:"after delete",beforeAndAfter:"before and after delete"},ue={flows:"the flows",triggers:"the Apex triggers",processes:"the Process Builder processes",workflowRules:"the workflow rules",automation:"the automation"};function de({kind:e,name:s}){return e==="flow"?`flow "${s}"`:e==="process"?`process "${s}"`:e==="workflowRule"?`workflow rule "${s}"`:`Apex trigger ${s}`}function ce(e,s){return s.step==="delete"?Ee[s.when]:s.step==="bringBack"?"as it comes back from the recycle bin":`${e==="restore"?"as its values are put back":"as it is masked"}, ${ke[s.when]}`}function W(e){return`${e[0]?.toUpperCase()??""}${e.slice(1)}`}function ve(e,s,r,t){let n=E[r],a=[n.heading.replace("{org}",s)];if(typeof e.unread=="string")return a.push(` what ${s} runs could not be read: ${e.unread}`),a;let i=e;for(let c of S(i,t))a.push(` ${c.objectApiName}: ${ce(r,c)}: ${de(c)}`);let d=M(i);if(a.length===1&&d.length===0){let c=new Set(Object.values(t).flat()).size;a.push(` nothing fires on the ${c} object(s) it ${n.writes} records of`)}for(let c of ne(i,t.giveBack??[]))a.push(` ${c.objectApiName}: duplicate rules ${c.rules.map(p=>`"${p}"`).join(", ")}: ${n.the} saves a record a rule only alerts on, a rule that blocks still refuses it, and what a rule that reports writes (a duplicate record set and its items) stays`);let u=I(i);u.length>0&&a.push(` bypass held: the user ${n.the} writes as holds ${u.join(", ")}, and what names it stays quiet`);for(let{part:c,reason:p}of d)a.push(` ${ue[c]??c} could not be read: ${p}`);return a}function Se(e,s,r){let t=E[r.act],n=`${t.nothing} Add --accept-automation ${t.flag}, or turn that automation off in ${s} first.`;if(typeof e.unread=="string")return`What ${s} runs as ${t.this} ${t.writes} its records could not be read (${e.unread}), so what fires is not known. ${n}`;let a=e,i=S(a,r.steps),d=M(a);if(i.length===0&&d.length===0)return;let u=[];if(i.length>0){let l=i.map(m=>`${m.objectApiName}: ${de(m)} (${ce(r.act,m)})`);u.push(`${s} runs automation as ${t.this} ${t.writes} its records: ${l.join("; ")}.`)}for(let{part:l,reason:m}of d)u.push(`${W(ue[l]??l)} of ${s} could not be read (${m}), so what fires as ${t.the} ${t.writes} its records is not known.`);let c=r.assign??[];u.push(...re(c,s,t.the));let p=[...new Set(c.flatMap(l=>l.permissionSet??[]))];return r.mayMute===!0&&p.length>0&&u.push(`With --mute-automation, ${t.the} assigns ${p.join(", ")} to the user it writes as for ${t.the} alone, under a lease, and what ${p.length===1?"it keeps":"they keep"} quiet does not fire.`),u.push(n),u.join(" ")}function k(e){let s=e.objects.map(r=>`${r.perRecord} per ${r.objectApiName}`).join(", ");return`about ${te(e.emails,e.limit)} (${s}`+(e.alertsCounted?"; its email alerts among them, as a Developer Edition counts them":"")+")"}function Te(e,s,r){let t=e.map(n=>{if(n.verdict==="unread")return` emails: ${k(n)}; what ${s} has left today could not be read (${n.unread??"not said"})`;let a=`${n.remaining??0} of ${n.max??0} left today`;return n.verdict==="exceeds"?` emails: ${k(n)}, past the ${a}`:` emails: ${k(n)}, ${a}`});return r!==void 0&&t.push(` emails not counted: what sends them was not read (${r})`),t}function Ne(e,s,r,t){let n=s.filter(u=>u.verdict==="exceeds");if(n.length===0)return;let a=E[e],i=n.map(u=>`${k(u)}, ${u.remaining??0} of ${u.max??0} left today`).join("; "),d=t?.kind==="enough"?`Turn off what sends them, give the user it writes as the bypass that keeps them quiet (--mute-automation assigns ${t.sets.join(", ")} for ${a.the} alone, and what still sends then fits what is left today), or ${a.verb} fewer records.`:`Turn off what sends them, or ${a.verb} fewer records.`+(t?.kind==="muting"?" What sends them still runs under the mute.":t?.kind==="notEnough"?" --mute-automation would not keep enough of them quiet.":"");return`${W(a.this)} would make ${r} send ${i}: past them, each record whose flow fails in the save is refused (CANNOT_EXECUTE_FLOW_TRIGGER), and the org's own emails stop for the rest of the day. ${d} ${a.nothing}`}function Je(e,s,r){return{readAutomation:s,readLimits:()=>ee(e),readDeliverability:()=>r?Promise.resolve(V):X(e),muteOrg:async()=>Y(e),...r?{production:r}:{}}}async function Qe(e,s,r,t){let n=e?.mute?.prepared;if(!e||!n)return{};let a;try{a=await n.acquire(s)}catch(d){if(!T(d))throw d;return{refused:{code:d.code,message:L(d.message,t)}}}let i=e.emails.afterLease(a.outcome,r);return i?(await a.release(),{refused:{code:i.code,message:L(i.message,t)}}):{held:a}}var Me={objectsRead:[],objects:[],unread:[],conditionsNotRead:0,conditionsBound:0,requests:0};async function Ze(e){let{act:s,target:r,accord:t}=e,n=e.objects.filter(g=>g.records>0),a=n.map(g=>g.objectApiName),i=e.writes?.steps??be(s,a),d=F(i),u=a.length===0?Me:await e.org.readAutomation(a).catch(g=>{let b=U(g);return{unread:b===void 0?$(g):`the org could not be reached (${b})`}}),c=typeof u.unread=="string"?void 0:u,p=B(u),l=E[s],m=[],o;if(t.muteAutomation===!0&&p===void 0)try{o=await J(e.org.muteOrg,u,{...e.muteLeases,writes:d})}catch(g){if(!T(g))throw g;m.push({code:g.code,message:g.message})}let f=o?.automation??c,h=e.mayMute&&t.muteAutomation!==!0&&e.org.production!==!0,A=[...ve(c??u,r,s,i),...o?Q(o.muted,r).map(g=>` ${g}`):[]],j=Se(f??u,r,{act:s,steps:i,...f?{assign:se(f,q(f,i),e.assignTo)}:{},mayMute:h});j!==void 0&&t.acceptAutomation!==!0&&m.push({code:he,message:j});let D=e.writes?e.writes.written.filter(g=>g.records>0):Ae(s,n),y=[],R,P;if(f&&p===void 0){if(D.some(b=>C(f,b.write).some(w=>w.objectApiName===b.objectApiName))){let b=await e.org.readLimits().catch(w=>({unread:$(w)}));if(y=N(D,f,b),y.some(w=>w.verdict==="exceeds")){let w=!o&&h&&c?K(c,d):void 0;P=o?{kind:"muting"}:w&&w.plan.assign.length>0?N(D,w.automation,b).some(v=>v.verdict==="exceeds")?{kind:"notEnough"}:{kind:"enough",sets:w.plan.assign.map(v=>v.permissionSet)}:void 0}}R=Z(D,f)}A.push(...Te(y,r,R));let _=Ne(s,y,r,P);_!==void 0&&m.push({code:we,message:_});let O=await z({read:u,...o?.plan?{plan:o.plan}:{},writes:d,readDeliverability:p===void 0?e.org.readDeliverability:async()=>({reading:{unread:`${r} could not be reached`},requests:0}),accepted:t.acceptEmails===!0,target:r,run:$e[s],keepsAddresses:!0,mayMute:h});return O.gate.line!==void 0&&A.push(` ${O.gate.line}`),O.gate.stop&&m.push({...O.gate.stop}),p!==void 0&&m.splice(0,m.length,{code:Oe,message:`${r} could not be reached as what it runs was read (${p}), so ${l.the} was not started. ${l.nothing} Check the network, then try again.`}),{answer:{act:s,objects:n,steps:i,...c?{automation:c}:{automationUnread:String(u.unread)},lines:A,emails:y,...R!==void 0?{emailsUncounted:R}:{},...O.gate.deliverability?{deliverability:O.gate.deliverability}:{},emailsAsk:O.gate.verdict==="asks",refusals:m.map(g=>({...g,message:L(g.message,e.voice)})),...o?{mutedAutomation:o.muted}:{},...o?.plan?{mutePlan:o.plan}:{}},...o?{mute:o}:{},emails:O}}var xe=/\bnothing (?:was )?(?:written|deleted)\b/i,ie=/\s*\bNothing was (?:written|deleted)\./g;function et(e){let[s,...r]=e.refusals;if(!s)return;let t=!1,n=e.refusals.map(a=>t?a.message.replace(ie,"").trim():(t=xe.test(a.message),a.message)).join(" ");return{code:s.code,message:n,alsoRefused:r.map(a=>({code:a.code,message:a.message.replace(ie,"").trim()}))}}function tt(e){return e.alsoRefused.length>0?{extraPayload:{alsoRefused:[...e.alsoRefused]}}:{}}export{_e as a,ne as b,Ie as c,Ce as d,Fe as e,Ke as f,Je as g,Qe as h,Ze as i,et as j,tt as k};
|
package/lib/chunk-CION3VMZ.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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{d as Ce}from"./chunk-WIO4XO4F.mjs";import{a as In}from"./chunk-EADHKH3A.mjs";import{c as xn,g as le,h as Pe,j as vn}from"./chunk-GCOB7K5N.mjs";import{a as j,c as ee}from"./chunk-INIT2UKJ.mjs";import{b as kn}from"./chunk-SU65Z2BA.mjs";import{d as Nn}from"./chunk-A527W53V.mjs";import{a as X,h as C}from"./chunk-TZE3Y7IQ.mjs";import{b as G}from"./chunk-CA5NAXSU.mjs";import{$c as En,Cb as yn,Db as hn,Eb as wn,Fb as Rn,Hb as _,Ib as Y,Kc as Tn,Lc as Sn,M as mn,Mc as An,Nc as On,Pb as bn,Qb as V,Rb as L,_c as Fn}from"./chunk-TTFDUKUS.mjs";import{b as Q,e as pn,i as ce,k as de,l as Z,s as ve}from"./chunk-7EANH5PY.mjs";var _t=/^[A-Za-z][A-Za-z0-9_]{0,79}$/;function Pn(e,n){return typeof e=="object"&&e!==null?e[n]:void 0}function Cn(e){return Array.isArray(e)?e.filter(n=>typeof n=="object"&&n):[]}function Mn(e){return typeof e=="string"&&_t.test(e)?e:void 0}function jn(e){let n=new Map;for(let r of Cn(Pn(e,"variables"))){let o=r.name,s=Mn(r.objectType);typeof o=="string"&&s&&n.set(o.toLowerCase(),s)}let t=[];for(let r of Cn(Pn(e,"recordCreates"))){let o=r.inputReference,s=Mn(r.object)??(typeof o=="string"?n.get(o.toLowerCase()):void 0);s&&!t.some(i=>i.toLowerCase()===s.toLowerCase())&&t.push(s)}return t}var $n={AccountPartner:["Role"],CampaignMember:["Status"],Case:["Status"],Contract:["Status"],Lead:["Status"],Opportunity:["StageName"],OpportunityPartner:["Role"],Order:["Status"],Partner:["Role"],ServiceAppointment:["Status"],Solution:["Status"],Task:["Priority","Status"],WorkOrder:["Status"],WorkOrderLineItem:["Status"]};function Eo(e,n){let t=new Map,r=n!==void 0&&Object.prototype.hasOwnProperty.call($n,n)?$n[n]:[];for(let o of e){let s=o.type==="multipicklist";if(o.type!=="picklist"&&!s&&!o.picklistValues?.length)continue;let i=(o.type==="combobox"||o.restrictedPicklist===!1)&&!r.includes(o.name);t.set(o.name,{multi:s,restricted:o.restrictedPicklist===!0,required:o.nillable===!1&&o.defaultedOnCreate!==!0,...o.controllerName?{controllerName:o.controllerName}:{},...i?{anyValue:i}:{}})}return t}var Lt=new Set;function Dt(e,n){let t=new Set(e),r=[],o=new Set,s=(i,d)=>{if(o.has(i))return;let l=n.get(i)?.controllerName;l&&t.has(l)&&d<e.length&&s(l,d+1),!o.has(i)&&(o.add(i),r.push(i))};for(let i of e)s(i,0);return r}function qt(e){return typeof e=="boolean"?String(e):typeof e=="string"&&e!==""?e:void 0}function Bt(e,n){let t=new Map;for(let r of e){let o=n(r),s=t.get(o)??[];s.includes(r)||s.push(r),t.set(o,s)}return[...t]}function Gt(e,n,t,r,o,s,i){let d=new Set(o.values),l=d,a,u=r.controllerName?qt(e[r.controllerName]):void 0,f=u===void 0?void 0:o.allowedByControllingValue?.get(u);f&&(l=new Set(o.values.filter(b=>f.has(b))),a=r.controllerName);let g=t.filter(b=>!l.has(b));if(g.length===0)return[];let p=b=>i&&!i.has(b)?"not-in-target":d.has(b)?"controlling-value":"record-type",w,T,S=t.filter(b=>l.has(b));return r.multi&&S.length>0?e[n]=S.join(";"):(o.defaultValue!==null&&l.has(o.defaultValue)?(w=o.defaultValue,T="default"):r.required&&(w=o.values.find(b=>l.has(b)),T=w===void 0?void 0:"first"),w===void 0?delete e[n]:e[n]=w),Bt(g,p).map(([b,x])=>({field:n,reason:b,values:x,recordType:s,...b==="controlling-value"&&a?{controllingField:a}:{},...w!==void 0&&T?{replacedBy:w,replacement:T}:{}}))}function ko(e,n,t,r,o=Lt){let s=[];for(let i of Dt(Object.keys(e),t)){let d=e[i];if(typeof d!="string"||o.has(i))continue;let l=t.get(i),a=n?.get(i),u=l?.restricted?r?.picklists.get(i):void 0;if(!a&&!u)continue;if(d===""){delete e[i];continue}let f=l?.multi?d.split(";"):[d];if(l&&u&&r){s.push(...Gt(e,i,f,l,u,r.recordType,a));continue}if(!a||l?.anyValue)continue;let g=f.filter(w=>!a.has(w));if(g.length===0)continue;let p=f.filter(w=>a.has(w));l?.multi&&p.length>0?e[i]=p.join(";"):delete e[i],s.push({field:i,reason:"not-in-target",values:[...new Set(g)]})}return s}var Ut="012000000000000AAA",ue="Master",Dn="";function No(e,n){return e?.get(typeof n=="string"?n:Dn)}async function Wt(e,n,t){try{return{picklists:await e(n,t)}}catch(r){return{error:G(r)}}}var _n=class{constructor(n){this.read=n}read;reads=new Map;said=new Set;async forRows(n){let t=new Map,r=[],{read:o}=this;if(!o)return{byRecordType:t,notes:r};if(n.withoutRecordTypes){let a=[...n.fields].filter(([f,g])=>g.restricted&&g.controllerName&&n.written(f)).map(([f])=>f),u=new Set(a.filter(f=>n.rows.some(g=>typeof g[f]=="string"&&g[f]!=="")));if(u.size>0){let f={targetId:Ut,developerName:ue},g=await this.readFor(o,n.objectApiName,f.targetId);this.keep(t,r,n.objectApiName,Dn,u,f,g)}return{byRecordType:t,notes:r}}if(!n.recordTypeMappings||!n.written("RecordTypeId"))return{byRecordType:t,notes:r};let s=[...n.fields].filter(([a,u])=>u.restricted&&n.written(a)).map(([a])=>a);if(s.length===0)return{byRecordType:t,notes:r};let i=new Map(n.recordTypeMappings.map(a=>[a.sourceId,a])),d=new Map;for(let a of n.rows){let u=a.RecordTypeId;if(!(typeof u!="string"||!i.has(u)))for(let f of s){let g=a[f];if(typeof g!="string"||g==="")continue;let p=d.get(u)??new Set;p.add(f),d.set(u,p)}}let l=await Promise.all([...d].map(async([a,u])=>{let f=i.get(a);return{sourceId:a,fields:u,target:f,answer:await this.readFor(o,n.objectApiName,f.targetId)}}));for(let{sourceId:a,fields:u,target:f,answer:g}of l)this.keep(t,r,n.objectApiName,a,u,f,g);return{byRecordType:t,notes:r}}readFor(n,t,r){let o=`${t}|${r}`,s=this.reads.get(o);return s||(s=Wt(n,t,r),this.reads.set(o,s)),s}keep(n,t,r,o,s,i,d){let l=`${r}|${i.targetId}`;if("error"in d){this.said.has(l)||(this.said.add(l),t.push({recordType:i.developerName,error:d.error}));return}n.set(o,{recordType:i.developerName,picklists:d.picklists});let a=[...s].filter(u=>!d.picklists.has(u)&&!this.said.has(`${l}|${u}`));if(a.length!==0){for(let u of a)this.said.add(`${l}|${u}`);t.push({recordType:i.developerName,leftOut:a})}}};function Io(e){return e.error!==void 0?{recordSummary:`(picklist values of record type ${e.recordType} could not be read \u2014 checked against each field's values)`,messages:[e.error]}:{recordSummary:`(picklist values of record type ${e.recordType} not given for ${(e.leftOut??[]).join(", ")} \u2014 checked against each field's values)`,messages:[`The target's answer for record type ${e.recordType} leaves out ${(e.leftOut??[]).join(", ")}.`]}}var Ln=class{entries=new Map;get size(){return this.entries.size}add(n,t){for(let r of t){let o=[n,r.field,r.reason,r.recordType??"",r.controllingField??"",r.replacement??"",r.replacedBy??""].join("\0"),s=this.entries.get(o);if(s){s.entry.rows++;for(let i of r.values)s.values.add(i);continue}this.entries.set(o,{entry:{objectApiName:n,field:r.field,reason:r.reason,values:[],rows:1,...r.recordType!==void 0?{recordType:r.recordType}:{},...r.controllingField!==void 0?{controllingField:r.controllingField}:{},...r.replacedBy!==void 0?{replacedBy:r.replacedBy}:{},...r.replacement!==void 0?{replacement:r.replacement}:{}},values:new Set(r.values)})}}list(){return[...this.entries.values()].map(({entry:n,values:t})=>({...n,values:[...t].sort()}))}};function Vt(e){let n=`${e.rows} row${e.rows===1?"":"s"}`,t=e.values.map(s=>`"${s}"`).join(", "),r=e.reason==="not-in-target"?"not a value of the field in the target":e.reason==="record-type"?`not allowed for record type ${e.recordType??""}`:`not allowed with the value of ${e.controllingField??"its controlling field"}`,o=e.replacedBy===void 0?"left out":e.replacement==="first"?`replaced by "${e.replacedBy}", the first value record type ${e.recordType??""} allows: the field is required and has no default there`:`replaced by "${e.replacedBy}", the default of record type ${e.recordType??""}`;return`${e.field} on ${n}: ${t} ${r}, ${o}`}function xo(e){return e.length===0?"":`, picklist values not written as read: ${e.map(Vt).join("; ")}`}function $o(e){let n={...e.picklistValueMappings?.length?{picklistValueMappings:e.picklistValueMappings}:{},...e.recordTypeMappings?.length?{recordTypeMappings:e.recordTypeMappings}:{},...e.defaultValues?.length?{defaultValues:e.defaultValues}:{},...e.truncateFields?.length?{truncateFields:e.truncateFields}:{},...e.ignoredGaps?.length?{ignoredGaps:e.ignoredGaps}:{},...e.skippedRows?.length?{skippedRows:e.skippedRows}:{}};return Object.keys(n).length>0?n:void 0}var zt=new Set(["picklist_value_refused","picklist_value_absent","currency_inactive"]);function Un(e){let n=mn(e.gapId);return n?n.objectApiName!==e.object?{ignored:`the gap is of ${n.objectApiName}, not of ${e.object}`}:n.field===void 0||n.value===void 0?{ignored:"the gap names no field and value whose rows to hold back"}:zt.has(n.kind)?{held:{field:n.field,...n.recordType!==void 0?{recordType:n.recordType}:{},value:n.value}}:{ignored:`a ${n.kind} gap does not offer it: its rows are not exactly those holding its value`}:{ignored:"not the id of a gap"}}function _o(e){let n=Un(e);return"ignored"in n?n.ignored:void 0}function qn(e,n,t){if(e===void 0)return!0;let r=n??ue;if(e===r)return!0;let o=le(e),s=le(r);if(o.namespacePrefix!==void 0||s.namespacePrefix===void 0||s.developerName!==e)return!1;if(t===void 0)return!0;let i=Pe(e,t,d=>d);return"found"in i&&i.found.namespacePrefix===s.namespacePrefix}function Qt(e){return e==null||e===""}var Bn=class{entries=new Map;get size(){return this.entries.size}add(n,t=1){let r=[n.kind,n.objectApiName,n.field??"",n.recordType??"",n.from??"",n.to??""].join("\0"),o=this.entries.get(r);if(o){o.rows+=t;return}this.entries.set(r,{...n,rows:t})}list(){return[...this.entries.values()].map(n=>({...n}))}},fe=class{picklists=new Map;defaults=new Map;truncated=new Map;skipped=new Map;ignoredGaps;constructor(n){for(let t of n?.picklistValueMappings??[]){let r=this.picklists.get(t.object)??[];r.push(t),this.picklists.set(t.object,r)}for(let t of n?.defaultValues??[]){let r=this.defaults.get(t.object)??[];r.push(t),this.defaults.set(t.object,r)}for(let{object:t,field:r}of n?.truncateFields??[]){let o=this.truncated.get(t)??new Set;o.add(r),this.truncated.set(t,o)}this.ignoredGaps=new Set(n?.ignoredGaps??[]);for(let t of n?.skippedRows??[]){let r=Un(t);if(!("held"in r))continue;let o=this.skipped.get(t.object)??[];o.push(r.held),this.skipped.set(t.object,o)}}skipsRowsOf(n){return this.skipped.has(n)}namesARecordTypeBare(n){return[...(this.picklists.get(n)??[]).map(r=>r.recordType),...(this.skipped.get(n)??[]).map(r=>r.recordType)].some(r=>r!==void 0&&r!==ue&&le(r).namespacePrefix===void 0)}holdsBack(n,t,r,o,s){for(let i of this.skipped.get(n)??[]){if(!qn(i.recordType,r,s))continue;let d=t(i.field);if(!(typeof d!="string"||!d.split(";").includes(i.value)))return o.add({kind:"skip_rows",objectApiName:n,field:i.field,...i.recordType!==void 0?{recordType:i.recordType}:{},from:i.value}),!0}return!1}changesRowsOf(n){return this.picklists.has(n)||this.defaults.has(n)}defaultOf(n,t){let r=this.defaults.get(n)?.find(o=>o.field===t);return r===void 0?void 0:String(r.value)}applyToRow(n,t,r,o,s){for(let i of this.picklists.get(n)??[]){if(!qn(i.recordType,r,s))continue;let d=t[i.field];if(typeof d!="string"||d==="")continue;let l=d.split(";");if(!l.includes(i.from))continue;let a=l.flatMap(u=>u!==i.from?[u]:i.to===null?[]:[i.to]);a.length===0?delete t[i.field]:t[i.field]=[...new Set(a)].join(";"),o.add({kind:i.to===null?"leave_empty":"map_value",objectApiName:n,field:i.field,...i.recordType!==void 0?{recordType:i.recordType}:{},from:i.from,...i.to!==null?{to:i.to}:{}})}for(let{field:i,value:d}of this.defaults.get(n)??[])Qt(t[i])&&(t[i]=d,o.add({kind:"set_default",objectApiName:n,field:i,to:String(d)}))}truncate(n,t,r,o){for(let s of this.truncated.get(n)??[]){let i=t[s],d=r.get(s);typeof i!="string"||d===void 0||d<=0||i.length<=d||(t[s]=i.slice(0,d),o.add({kind:"truncate",objectApiName:n,field:s}))}}truncatedFieldsOf(n){return this.truncated.get(n)??new Set}};function Lo(e,n){let t=new Map(n.map(i=>[i.objectApiName,i])),r=[],o=new Map,s=[];for(let i of e){let d=t.get(i.object),l=Gn(i.object,i.from,d?.source??[],"the source");if("reason"in l){s.push({decision:i,reason:l.reason});continue}if(i.to===null){o.set(l.type.recordTypeId,i);continue}let a=Gn(i.object,i.to,d?.target??[],"the target");if("reason"in a){s.push({decision:i,reason:a.reason});continue}o.set(l.type.recordTypeId,i),r.push({sourceId:l.type.recordTypeId,targetId:a.type.recordTypeId,developerName:a.type.developerName})}return{mappings:r,bySource:o,unresolved:s}}function Gn(e,n,t,r){let o=Pe(n,t.filter(s=>!s.master),Ce);if("found"in o)return{type:o.found};if("ambiguous"in o){let s=o.ambiguous.map(Ce),i=s.find(d=>d.namespacePrefix);return{reason:vn(e,n,r,s)+(i?"; a package's is named with its namespace: "+xn(i.namespacePrefix,i.developerName):"")}}return{reason:`${r} has no ${e} record type named ${n}`}}function Do(e,n){return n.bySource.size===0?e?[...e]:void 0:[...(e??[]).filter(t=>!n.bySource.has(t.sourceId)),...n.mappings]}var Me=class{constructor(n,t){this.given=n;this.store=t}given;store;has(n){return this.given.has(n)||this.store?.mapping(n)?.earlier===!0}retried(n){return this.given.has(n)}get(n){let t=this.given.get(n);if(t!==void 0)return t;let r=this.store?.mapping(n);return r?.earlier?r.targetId:void 0}get from(){return this.given.size===0&&(this.store?.earlierMapped??0)>0?"resume":"retry"}get size(){return this.given.size+(this.store?.earlierMapped??0)}keys(){return this.given.keys()}[Symbol.iterator](){return this.given.entries()}};function U(e){return e!==void 0&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0}function Wn(e){let n=!!(e?.rootRecordId&&e.rootObjectApiName);return{isScoped:n,dryRun:e?.dryRun??!1,referenceFallback:e?.referenceFallback??(n?"nullify":"keep"),rootRecordId:e?.rootRecordId,rootObjectApiName:e?.rootObjectApiName,recordTypeMappings:e?.recordTypeMappings,maxRecordsPerObject:e?.maxRecordsPerObject,referenceDataObjects:new Set(e?.referenceDataObjects??["BusinessHours","OperatingHours"]),expandOrphanParents:e?.expandOrphanParents??!1,maxOrphanParentExpansions:e?.maxOrphanParentExpansions??20,upsertMode:e?.upsertMode==="auto"?"auto":"off",writeApi:e?.writeApi==="auto"?"auto":"rest",fieldExclusions:e?.fieldExclusions??{},excludedObjects:new Set(e?.excludedObjects??[]),ownerMappings:e?.ownerMappings??{},objectSoqlFilters:e?.objectSoqlFilters,fieldMappings:e?.fieldMappings??{},anonymization:e?.anonymization,keepContactPoints:e?.keepContactPoints===!0,files:e?.files?{maxFileBytes:Math.min(e.files.maxFileBytes>0?e.files.maxFileBytes:10*1048576,35*1048576),acceptedAsIs:e.files.acceptedAsIs===!0}:void 0,writtenBefore:new Me(new Map(Object.entries(e?.writtenBefore??{})),e?.stream?.store),beforeWrite:e?.beforeWrite,stream:e?.stream?{pageSize:U(e.stream.pageSize),ceiling:U(e.stream.ceiling),resumeAfter:e.stream.resumeAfter?new Map(Object.entries(e.stream.resumeAfter)):e.stream.store?.checkpoints()??new Map,onPage:e.stream.onPage,...e.stream.store?{store:e.stream.store}:{},...e.stream.summaryBound!==void 0?{summaryBound:Math.max(0,Math.floor(e.stream.summaryBound))}:{},...U(e.stream.secondPassPageSize)!==void 0?{secondPassPageSize:U(e.stream.secondPassPageSize)}:{},...U(e.stream.writeWindow)!==void 0?{writeWindow:U(e.stream.writeWindow)}:{},...e.stream.everything===!0?{everything:!0}:{},...U(e.stream.wholeReadBound)!==void 0?{wholeReadBound:U(e.stream.wholeReadBound)}:{},...e.stream.sample&&e.stream.everything===!0?{sample:e.stream.sample}:{}}:void 0,decisions:new fe(e?.decisions),recordTypeDecisions:new Map}}var Kt="Id = NULL",Le="no parent in cache and not the root",Vn=class{build(n){let t=this.buildMeasured(n);return{...t,statements:je(t.statements,n.node.objectApiName,n.selectFields)}}buildMeasured(n){let t=C(n.node.objectApiName),r=ne(ee(n.selectFields)),o=n.extraWhere?` AND (${n.extraWhere})`:"",s=n.extraWhere?" + extra filter":"",i=`SELECT ${r} FROM ${t} WHERE `,d=n.node.objectApiName===n.rootObjectApiName&&!n.under;if(d&&!(n.rootReadAgain&&n.cache.has(n.node.objectApiName))){let k=X(n.rootRecordId);return{statements:[`${i}Id = '${k}'${o}`],scoped:!0,scope:"root",reason:`root record${s}`,parentObjectsUsed:[n.rootObjectApiName],scopeIdCount:1,byIdCount:0}}let l=n.under?void 0:n.cache.get(n.node.objectApiName),a=l?.size??0,u=l&&a>0?_e({prefix:i,suffix:o,wrap:!1,objectApiName:n.node.objectApiName},[{field:"Id",ids:l}]):[],f=`${a} ID(s) cached from earlier wave`,g={statements:u,scoped:!0,scope:"self-cached",reason:`${f}${s}`,parentObjectsUsed:[],scopeIdCount:a,byIdCount:u.length};if(a>0&&(!n.everyEdge||d))return g;let p=[],w=[],T=0;for(let k of n.edges){if(k.targetObject!==n.node.objectApiName||n.under&&!n.under.has(k.sourceObject)||k.sourceObject===k.targetObject)continue;let R=n.fromAboveOnly||n.catalog?.has(k.sourceObject)?n.cache.reachedOf(k.sourceObject):n.cache.scopeOf(k.sourceObject);if(!R||R.size===0)continue;let I=n.fields.filter(h=>h.type==="reference"&&h.referenceTo.includes(k.sourceObject));if(I.length!==0){for(let h of I)p.push({field:C(h.name),ids:R});w.includes(k.sourceObject)||(w.push(k.sourceObject),T+=R.size)}}let S=[];for(let k of n.fields){if(k.type!=="reference"||k.nillable!==!1)continue;let R=new Set;for(let I of k.referenceTo){if(!n.readObjects?.has(I))continue;let h=n.catalog?.has(I)===!0;if(h&&!n.cache.isRead(I))continue;let F=h?n.cache.scopeOf(I):n.cache.get(I);if(F)for(let A of F)R.add(A)}R.size!==0&&S.push({field:C(k.name),ids:R})}let b=S.length>0?" + required parents in scope":"";if(p.length===0)return a>0?g:{statements:[`${i}${Kt}`],scoped:!1,scope:"unscoped",reason:Le,parentObjectsUsed:[],scopeIdCount:0,byIdCount:1};let x=zn({prefix:i,extraSuffix:o,objectApiName:n.node.objectApiName},p,S),N=`via ${w.join(", ")}${s}${b}`;return a===0?{statements:x,scoped:!0,scope:"parent-fk",reason:N,parentObjectsUsed:w,scopeIdCount:T,byIdCount:0}:{statements:[...u,...x],scoped:!0,scope:"self-and-parent-fk",reason:`${f}, and ${N}`,parentObjectsUsed:w,scopeIdCount:a+T,byIdCount:u.length}}buildJoining(n){let t=C(n.objectApiName),o=`SELECT ${ne(ee(n.selectFields))} FROM ${t} WHERE `,s=n.extraWhere?` AND (${n.extraWhere})`:"";return je(zn({prefix:o,extraSuffix:s,objectApiName:n.objectApiName},[{field:C(n.split.field),ids:n.split.ids}],[{field:C(n.whole.field),ids:n.whole.ids}]),n.objectApiName,n.selectFields)}buildById(n){let t=C(n.objectApiName);return je(_e({prefix:`SELECT ${ne(ee(n.selectFields))} FROM ${t} WHERE `,suffix:n.extraWhere?` AND (${n.extraWhere})`:"",wrap:!1,objectApiName:n.objectApiName},[{field:"Id",ids:n.ids}]),n.objectApiName,n.selectFields)}};function ne(e){return e.length===0?"Id":e.map(n=>C(n)).join(", ")}function je(e,n,t){let r=C(n),o=`SELECT ${ne(ee(t))} FROM ${r} `,s=`SELECT ${ne(t)} FROM ${r} `;return o===s?[...e]:e.map(i=>i.startsWith(o)?s+i.slice(o.length):i)}var Jt=500;function De(e,n){let t=[...n].map(r=>`'${X(r)}'`).join(", ");return` AND (${e.field} IN (${t}))`}function Zt(e,n){if(e.field!==n.field)return!1;for(let t of e.ids)if(!n.ids.has(t))return!1;return!0}function Yt(e,n,t){let r=j(De(e,[])),o=j(", "),s=[],i=[],d=r;for(let l of e.ids){let a=j(`'${X(l)}'`);if(i.length>0&&d+o+a>n&&(s.push(i),i=[],d=r),i.length===0&&r+a>n)throw Qn(t);d+=(i.length>0?o:0)+a,i.push(l)}return i.length>0&&s.push(i),s}function Xt(e,n,t){let r=[""];for(let o of e){let s=Yt(o,n/e.length,t);r=r.flatMap(i=>s.map(d=>i+De(o,d)))}return r}function zn(e,n,t){let r=(l,a)=>_e({prefix:e.prefix,suffix:l,wrap:l!=="",objectApiName:e.objectApiName},a),o=t.map(l=>De(l,l.ids)).join(""),s=14e3-j(`${e.prefix}()${e.extraSuffix}`);if(j(o)<=s/2)return r(`${o}${e.extraSuffix}`,n);let i=new Map;for(let l of n){let a=t.filter(g=>!Zt(l,g)),u=a.map(g=>g.field).join("|"),f=i.get(u)??{needed:a,clauses:[]};f.clauses.push(l),i.set(u,f)}let d=[];for(let l of i.values())for(let a of Xt(l.needed,s/2,e.objectApiName))d.push(...r(`${a}${e.extraSuffix}`,l.clauses));return d}function Qn(e){return new Error(`Scoped clone for ${e}: its filter leaves a Salesforce query URI no room for a single record Id. Shorten the filter on this object and run it again.`)}function _e(e,n){let t=e.wrap?"(":"",r=e.wrap?")":"",o=j(e.prefix+t+r+e.suffix),s=j(", "),i=j(" OR "),d=[],l=[],a=o,u=0,f=()=>{let g=l.map(p=>`${p.field} IN (${p.values.join(", ")})`).join(" OR ");d.push(`${e.prefix}${t}${g}${r}${e.suffix}`),l=[],a=o,u=0};for(let g of n){let p=j(`${g.field} IN ()`),w=!1;for(let T of g.ids){let S=`'${X(T)}'`,b=j(S),x=w?s+b:(l.length>0?i:0)+p+b,N=a+x>14e3||u>=Jt;if(l.length>0&&N&&(f(),w=!1,x=p+b),l.length===0&&a+x>14e3)throw Qn(e.objectApiName);w?l[l.length-1].values.push(S):(l.push({field:g.field,values:[S]}),w=!0),a+=x,u++}}return l.length>0&&f(),d}var H="Product2",Be=[_,H,V,L,Y,"ProductCategory","ProductCatalog"],Yo=new Set(Be);function Xo(e,n){return yn(e,n.name,n.nillable)||e===_&&n.name===bn}function Hn(e,n=new Set){let t=new Set(e.nodes.map(r=>r.objectApiName));return new Set(Be.filter(r=>!t.has(r)&&!n.has(r)))}function es(e,n){return e.nodes.some(t=>t.included&&n.has(t.objectApiName))?{...e,nodes:e.nodes.map(t=>t.included&&n.has(t.objectApiName)?{...t,included:!1}:t)}:e}function er(e,n,t){if(n.length<2)return n;let r=e.slice(0,3),o=n.find(s=>t.get(s)===r);return o!==void 0?[o]:n.filter(s=>!t.has(s))}function ns(e,n){let t=qe(e);return n?lr(t,n):t}function ts(e,n,t){let r=Be.flatMap(g=>n.filter(({node:p})=>p.objectApiName===g)),o=new Set(r.flatMap(({fieldInfos:g})=>g.flatMap(p=>p.isReference?p.referenceTo??[]:[]))),s=new Map,i=new Map,d=(g,p,w)=>{let T=g.get(p);T?T.push(w):g.set(p,[w])};for(let{sourceObject:g,targetObject:p}of t)d(s,p,g),d(i,g,p);let l=[],a=new Set,u=[...e],f=u.filter(g=>o.has(g.objectApiName));for(;f.length>0;){for(let g of f)a.add(g.objectApiName),l.push(g);u=u.filter(g=>!a.has(g.objectApiName)),f=u.filter(({objectApiName:g})=>(s.get(g)??[]).some(p=>a.has(p))||(i.get(g)??[]).some(p=>a.has(p)))}return[...u,...r.map(({node:g})=>g),...l]}function Kn(e){return e.settable!==!1}function rs(e,n){let t=!1,r=e.edges.map(o=>{let s=(n.get(o.targetObject)??[]).filter(a=>a.isReference&&(a.referenceTo??[]).includes(o.sourceObject));if(s.length===0)return o;let i=s.some(a=>hn(a)),d=s.some(a=>wn(a));if(i===Kn(o)&&d===(o.insertOnly===!0))return o;t=!0;let l={...o};return i?delete l.settable:l.settable=!1,d?l.insertOnly=!0:delete l.insertOnly,l});return t?{...e,edges:r}:e}function os(e,n=[]){let t=e.edges.filter(Kn),r=[...t.filter(h=>h.required===!0),...n],o=t.filter(h=>h.insertOnly===!0&&h.required!==!0);if(r.length===0&&o.length===0)return qe(e,t);let s=new Set(e.nodes.map(h=>h.objectApiName)),i=qe(e,t),d=new Map(i.map((h,F)=>[h.objectApiName,F])),l=new Map,a=new Map,u=new Map,f=(h,F,A)=>{let $=h.get(F)??new Set;$.add(A),h.set(F,$)};for(let h of r){let{sourceObject:F,targetObject:A}=h;F===A||!s.has(F)||!s.has(A)||(f(l,A,F),f(a,F,A))}for(let h of t){let{sourceObject:F,targetObject:A}=h;F===A||!s.has(F)||!s.has(A)||l.get(A)?.has(F)||f(u,A,F)}let g=new Map;for(let[h,F]of u)for(let A of F)f(g,A,h);let p=new Map,w=new Map;for(let{sourceObject:h,targetObject:F}of o)h===F||!s.has(h)||!s.has(F)||l.get(F)?.has(h)||(f(p,F,h),f(w,h,F));let T=new Map,S=new Map,b=new Map;for(let h of s)T.set(h,l.get(h)?.size??0),S.set(h,p.get(h)?.size??0),b.set(h,u.get(h)?.size??0);let x=(h,F)=>{for(let A of[S,b,d]){let $=A.get(h)??0,se=A.get(F)??0;if($!==se)return $<se}return!1},N=new Set([...s].filter(h=>T.get(h)===0)),k=new Map(e.nodes.map(h=>[h.objectApiName,h])),R=[],I=new Set;for(;N.size>0;){let h;for(let A of N)(h===void 0||x(A,h))&&(h=A);if(h===void 0)break;N.delete(h),I.add(h);let F=k.get(h);F&&R.push(F);for(let A of a.get(h)??[]){let $=(T.get(A)??1)-1;T.set(A,$),$===0&&!I.has(A)&&N.add(A)}for(let A of w.get(h)??[])S.set(A,(S.get(A)??1)-1);for(let A of g.get(h)??[])b.set(A,(b.get(A)??1)-1)}for(let h of e.nodes)I.has(h.objectApiName)||R.push(h);return R}function ss(e,n){return[[H,L],[V,L],[H,_],[V,_],[L,_],[Y,_],...n.map(r=>[_,r])].filter(([r,o])=>r!==o&&e.has(r)&&e.has(o)).map(([r,o])=>({sourceObject:r,targetObject:o,relationshipName:`${r}Before${o}`,type:"lookup",required:!0}))}var nr=new Set(["Id","Name","CurrencyIsoCode","IsPersonAccount","IsActive","Status","IsWhat","IsInvitee","Response","RespondedDate",...Object.values(Nn).flat()]);function tr(e,n){let t=new Set(n??[]);return e.filter(r=>r.queryable&&(!t.has(r.name)||r.isReference||nr.has(r.name))).map(r=>r.name)}var rr=2;function or(e,n){let t=Array.from({length:n.length+1},(r,o)=>o);for(let r=1;r<=e.length;r++){let o=[r];for(let s=1;s<=n.length;s++)o[s]=Math.min(t[s]+1,o[s-1]+1,t[s-1]+(e[r-1]===n[s-1]?0:1));t=o}return t[n.length]}function sr(e,n){let t=e.toLowerCase(),r;for(let o of n){let s=or(t,o.toLowerCase());s<=rr&&s<t.length&&(!r||s<r.edits)&&(r={name:o,edits:s})}return r?.name}function is(e,n,t){let r={},o=[];for(let[s,i]of Object.entries(e)){let d=n.find(u=>u.toLowerCase()===s.toLowerCase())??s,l=t(d),a=r[d]??=[];for(let u of i){let f=l?.find(p=>p.toLowerCase()===u.toLowerCase());if(f===void 0&&l!==null){let p=l===void 0?void 0:sr(u,l);o.push({objectApiName:d,field:u,missing:l===void 0?"object":"field",...p!==void 0?{nearest:p}:{}})}let g=f??u;a.includes(g)||a.push(g)}}return{exclusions:r,unmatched:o}}function as(e){let n=tr(e.fieldInfos,e.fieldsLeftOut);n.length===0&&n.push("Id");let t,r=0;if(e.scopedBuilder&&e.scopeCache&&e.rootObjectApiName&&e.rootRecordId&&e.node.objectApiName===L&&e.node.objectApiName!==e.rootObjectApiName&&e.catalog?.has(L)){let s=cr(e.scopedBuilder,e.scopeCache,n,e.extraWhere);if(!s)return{kind:"skip",reason:Le};t=s,r=t.length}else if(e.scopedBuilder&&e.scopeCache&&e.rootObjectApiName&&e.rootRecordId){let s=e.fieldInfos.filter(d=>d.isReference).map(d=>({name:d.name,type:"reference",referenceTo:d.referenceTo??[],nillable:d.nillable})),i=e.scopedBuilder.build({node:e.node,fields:s,selectFields:n,edges:e.edges,cache:e.scopeCache,rootObjectApiName:e.rootObjectApiName,rootRecordId:e.rootRecordId,extraWhere:e.extraWhere,everyEdge:!0,readObjects:e.readObjects,catalog:e.catalog,rootReadAgain:e.rootReadAgain,under:e.under});if(!i.scoped)return{kind:"skip",reason:i.reason};t=i.statements,r=i.byIdCount}else{let s=[...e.extraWhere?[`(${e.extraWhere})`]:[],...e.inIdOrder?.afterId!==void 0?[`Id > ${ar(e.inIdOrder.afterId)}`]:[]],i=s.length>0?` WHERE ${s.join(" AND ")}`:"",d=e.inIdOrder?" ORDER BY Id":"";t=[`SELECT ${n.join(", ")} FROM ${C(e.node.objectApiName)}${i}${d}`]}let o=r>0?{byIdCount:r}:{};if(e.maxRecordsPerObject&&e.maxRecordsPerObject>0){let s=Math.floor(e.maxRecordsPerObject);if(s>0)return ir(t,s,o)}return{kind:"query",statements:t,...o}}function ir(e,n,t={}){return{kind:"query",statements:e.map(r=>`${r} LIMIT ${n+1}`),limit:n,...t}}function ar(e){if(!/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(e))throw new Error(`Not a record id to resume after: ${JSON.stringify(e.slice(0,40))}`);return`'${e}'`}function cr(e,n,t,r){let o=n.scopeOf(H),s=n.scopeOf(V);if(!(!o||o.size===0||!s||s.size===0))return e.buildJoining({objectApiName:L,selectFields:t,split:{field:"Product2Id",ids:o},whole:{field:"ProductSellingModelId",ids:s},extraWhere:r})}function cs(e){return(e.byIdCount??0)<e.statements.length}async function ds(e,n,t,r){let o=e.byIdCount??0,s=e.limit,i=a=>{if(s===void 0||a.length<=s)return a;for(let u of a.slice(s))typeof u.Id=="string"&&t?.delete(u.Id);return r?.(),a.slice(0,s)};if(e.statements.length===1){let a=await n(e.statements[0]);if(t&&o===0)for(let u of a)typeof u.Id=="string"&&t.add(u.Id);return i(a)}let d=[],l=new Set;for(let[a,u]of e.statements.entries())for(let f of await n(u)){let g=f.Id;if(typeof g=="string"){if(t&&a>=o&&t.add(g),l.has(g))continue;l.add(g)}if(d.push(f),s!==void 0&&d.length>s)return i(d)}return d}function dr(e,n,t,{settle:r=!0}={}){let o=[];for(let s of t){let i=s.Id;typeof i=="string"&&i&&o.push(i)}r?e.addRead(n,o):e.add(n,o)}function ls(e,n,t,r,o={}){dr(e,n,t,o);let s=o.keyPrefixes??new Map,i=r.filter(d=>d.isReference&&d.referenceTo&&d.referenceTo.length>0);for(let d of i){let l=d.referenceTo??[];for(let a of t){let u=a[d.name];if(!(typeof u!="string"||!u))for(let f of er(u,l,s))e.add(f,[u])}}}function lr(e,n){let t=e.findIndex(i=>i.objectApiName===n);if(t<0)throw new Error(`Cannot run scoped clone with root "${n}" missing from the graph. The root node was excluded or filtered out \u2014 re-include it before executing.`);let r=e[t];if(!r.included)throw r.status==="error"?new Error(`Cannot run scoped clone: root "${n}" could not be measured during discovery (${r.errors[0]??"unknown discovery error"}), and nothing was read or written. Run discovery again once the org answers for it; if it refuses again, the user the clone reads as may not read ${n}: start from a record the user can read.`):new Error(`Cannot run scoped clone with root "${n}" excluded: the clone starts from its record, and the records that point at it would be written without it. Include it again, or clone from a query instead of a record.`);if(t===0)return e;let o=[...e],[s]=o.splice(t,1);return o.unshift(s),o}function qe(e,n){let t=n??e.edges,r=new Map;for(let a of e.nodes)r.set(a.objectApiName,a);let o=new Map,s=new Map;for(let a of e.nodes)o.set(a.objectApiName,0);for(let a of t){o.has(a.targetObject)&&o.set(a.targetObject,(o.get(a.targetObject)??0)+1);let u=s.get(a.sourceObject);u?u.push(a.targetObject):s.set(a.sourceObject,[a.targetObject])}let i=[];for(let[a,u]of o)u===0&&i.push(a);let d=[],l=new Set;for(;i.length>0;){let a=i.shift();if(l.has(a))continue;l.add(a);let u=r.get(a);u&&d.push(u);let f=s.get(a);if(f){for(let g of f)if(o.has(g)){let p=(o.get(g)??1)-1;o.set(g,p),p===0&&!l.has(g)&&i.push(g)}}}for(let a of e.nodes)l.has(a.objectApiName)||d.push(a);return d}async function Jn(e,n){let{records:t,pages:r}=await In(e,n);return{records:t,requests:r}}var ur=25,ot=15,me=5,ye=25,Ue=60,We=20,bs=6+Ue+We+1+6+1+20,te=4,fr="SELECT ApiName, Label, TriggerType, RecordTriggerType, TriggerObjectOrEvent.QualifiedApiName, ActiveVersionId, HasAsyncAfterCommitPath FROM FlowDefinitionView WHERE IsActive = true AND TriggerType IN ('RecordBeforeSave', 'RecordAfterSave', 'RecordBeforeDelete')",gr="SELECT Name, NamespacePrefix, TableEnumOrId, EntityDefinition.QualifiedApiName, UsageBeforeInsert, UsageAfterInsert, UsageBeforeUpdate, UsageAfterUpdate, UsageBeforeDelete, UsageAfterDelete, UsageAfterUndelete FROM ApexTrigger WHERE Status = 'Active'",pr="SELECT ApiName, Label, TriggerObjectOrEvent.QualifiedApiName, ActiveVersionId FROM FlowDefinitionView WHERE IsActive = true AND ProcessType = 'Workflow'",mr="SELECT Id, Name, NamespacePrefix, TableEnumOrId FROM WorkflowRule",yr="SELECT Name, SobjectType FROM AssignmentRule WHERE Active = true",hr="SELECT DeveloperName, MasterLabel, SobjectType FROM DuplicateRule WHERE IsActive = true",wr="SELECT DeveloperName, NamespacePrefix FROM UserSetupEntityAccess WHERE KeyPrefix = '0CP'";function Zn(e){return`SELECT Metadata FROM Flow WHERE Id = '${e}'`}function Rr(e,n){if(n.length>me)throw new Error(`A Tooling composite holds ${me} queries, not ${n.length}`);return{allOrNone:!1,compositeRequest:n.map((t,r)=>({method:"GET",url:`${e}/tooling/query?q=${encodeURIComponent(t)}`,referenceId:`q${r}`}))}}function br(e,n){if(n.length>ye)throw new Error(`A Tooling composite retrieves ${ye} records, not ${n.length}`);return{allOrNone:!1,compositeRequest:n.map(({sobject:t,id:r},o)=>{if(!B.test(r))throw new Error(`Not a record id: ${r}`);return{method:"GET",url:`${e}/tooling/sobjects/${t}/${r}`,referenceId:`r${o}`}})}}var pe="PROCESSING_HALTED",Tr=Z({compositeResponse:de(Z({body:ce(),httpStatusCode:pn(),referenceId:Q()}).loose())}),Sr=Z({records:de(ve(Q(),ce()))}).loose(),Ar=ve(Q(),ce()),Or=de(Z({errorCode:Q().optional(),message:Q().optional()}).loose());function st(e,n,t,r,o){let s=Tr.safeParse(e);if(!s.success)throw new Error("The org answered the Tooling composite with no composite answer");let i=new Map(s.data.compositeResponse.map(d=>[d.referenceId,d]));return Array.from({length:n},(d,l)=>{let a=i.get(`${t}${l}`);if(!a)return{refused:`The org gave no answer to this ${r} of the composite`};if(a.httpStatusCode<400){let g=o(a.body);return g?{records:g}:{refused:`The org answered with status ${a.httpStatusCode} and no rows`}}let u=Or.safeParse(a.body),f=u.success?u.data[0]:void 0;return{refused:f?[f.errorCode,f.message].filter(Boolean).join(": "):`status ${a.httpStatusCode}`,...f?.errorCode===pe?{halted:!0}:{}}})}function Fr(e,n){return st(e,n,"q","query",t=>{let r=Sr.safeParse(t);return r.success?r.data.records:void 0})}function Er(e,n){return st(e,n,"r","retrieve",t=>{let r=Ar.safeParse(t);return r.success?[r.data]:void 0})}function kr(e){return async n=>Er(await e.request({method:"POST",url:"/tooling/composite",body:JSON.stringify(br(`/services/data/v${e.version}`,n)),headers:{"Content-Type":"application/json"}}),n.length)}function Ts(e){return{query:async(n,t)=>{let r=await e(n);return Jn({query:async o=>r.query(o),queryMore:async o=>r.queryMore(o)},t)},toolingQuery:async(n,t)=>{let r=await e(n);return Jn({query:async o=>r.tooling.query(o),queryMore:async o=>r.tooling.queryMore(o)},t)},toolingQueries:async(n,t)=>{let r=await e(n),o=await r.request({method:"POST",url:"/tooling/composite",body:JSON.stringify(Rr(`/services/data/v${r.version}`,t)),headers:{"Content-Type":"application/json"}});return Fr(o,t.length)},toolingRetrieves:async(n,t)=>kr(await e(n))(t)}}async function Nr(e,n,t,r){let o=n.map(u=>({retrieving:r?u.queries.filter(f=>f.retrieve!==void 0):[],waiting:r?u.queries.filter(f=>f.retrieve===void 0):[...u.queries],left:u.requests})),s={retrieving:ye,waiting:me},i=(u,f)=>{for(let g of o){let p=f.filter(w=>w.queue===g).map(w=>w.query);p.length>0&&g[u].unshift(...p)}},d=(u,f)=>{for(let g of o){let p=f.filter(w=>w.queue===g).map(w=>w.query);p.length===0&&g.retrieving.length===0||(g.reason??=u,g.waiting.unshift(...p,...g.retrieving.splice(0)))}},l=0,a=async()=>{for(;;){let u=o.find(R=>R.left>0&&(R.retrieving.length>0||R.waiting.length>0));if(!u)return;let f=u.retrieving.length>0?"retrieving":"waiting";u.left--,l++;let g=[];for(let R of o){if(R!==u&&R.left<=0)continue;let I=s[f]-g.length;if(I<=0)break;for(let h of R[f].splice(0,I))g.push({query:h,queue:R})}let p;try{p=r&&f==="retrieving"?await r(g.map(({query:R})=>R.retrieve)):await e(g.map(({query:R})=>R.soql))}catch(R){let I=G(R);if(f==="retrieving")d(I,g);else for(let{query:h}of g)h.refused(I);continue}let w=f==="retrieving"?"retrieve":"query",T=[],S=[],b=0,x,N;if(g.forEach((R,I)=>{let h=p[I]??{refused:`The org gave no answer to this ${w} of the composite`};"records"in h?(R.query.take(h.records),b++):h.halted?(T.push(R),x??=h.refused):f==="retrieving"?(S.push(R),N??=h.refused):R.query.refused(h.refused)}),f==="retrieving"&&b===0){d(N??x??pe,g);continue}if(S.length>0){for(let{queue:R}of S)R.reason??=N;i("waiting",S)}if(T.length===0)continue;let k=g.length-T.length;if(k===0){for(let{query:R}of T)R.refused(x??pe);continue}s[f]=Math.min(s[f],k);for(let{queue:R}of T)R.reason=x;i(f,T)}};await Promise.all(Array.from({length:Math.max(1,t)},a));for(let u of o)for(let f of[...u.retrieving,...u.waiting])f.refused(u.reason??pe);return l}function Ir(e){return`SELECT Metadata FROM WorkflowRule WHERE Id = '${e}'`}function xr(e){return`SELECT FlowVersionViewId, ApiName, ObjectType FROM FlowVariableView WHERE FlowVersionViewId IN (${e.map(t=>`'${t}'`).join(", ")})`}function vr(e){return`SELECT DurableId, QualifiedApiName FROM EntityDefinition WHERE QualifiedApiName IN (${e.map(t=>`'${t}'`).join(", ")})`}function Pr(e){return`SELECT Id, DeveloperName, NamespacePrefix FROM CustomPermission WHERE DeveloperName IN (${e.map(t=>`'${t}'`).join(", ")})`}function Cr(e){return`SELECT SetupEntityId, ParentId, Parent.Name, Parent.Label, Parent.NamespacePrefix FROM SetupEntityAccess WHERE SetupEntityType = 'CustomPermission' AND SetupEntityId IN (${e.map(t=>`'${t}'`).join(", ")}) AND Parent.IsOwnedByProfile = false AND Parent.PermissionSetGroupId = null`}function Mr(e,n){let t=n.map(r=>`'${r}'`).join(", ");return`SELECT ParentId, COUNT(Id) n FROM ${e} WHERE ParentId IN (${t}) GROUP BY ParentId`}var B=/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/,Ve=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,jr="myvariable_current",$r={RecordBeforeSave:"beforeSave",RecordAfterSave:"afterSave",RecordBeforeDelete:"beforeDelete"},_r={Create:"create",Update:"update",CreateAndUpdate:"createAndUpdate",Delete:"delete"},it={onCreateOnly:"create",onAllChanges:"createAndUpdate",onCreateOrTriggeringUpdate:"createAndUpdate"},Lr=[["UsageBeforeInsert","beforeInsert"],["UsageAfterInsert","afterInsert"],["UsageBeforeUpdate","beforeUpdate"],["UsageAfterUpdate","afterUpdate"],["UsageBeforeDelete","beforeDelete"],["UsageAfterDelete","afterDelete"],["UsageAfterUndelete","afterUndelete"]],Dr={emailAlert:"email",emailSimple:"email",customNotificationAction:"notification",outboundMessage:"outbound"},qr={emailSimple:"SingleEmail",emailAlert:"DailyWorkflowEmails"},Br={Alert:"email",OutboundMessage:"outbound"},Gr=new Set(["sms","mms","twilio","whatsapp","vonage","nexmo","messagebird","plivo","sinch"]);function Ke(e){if(typeof e!="object"||e===null)return;let n=e.QualifiedApiName;return typeof n=="string"&&n!==""?n:void 0}var y=e=>typeof e=="string"?e:"";function E(e,n){return typeof e=="object"&&e!==null?e[n]:void 0}function M(e){return Array.isArray(e)?e.filter(n=>typeof n=="object"&&n):[]}function Je(e,n,t,r){return{apiName:e,label:n||e,timing:t,startsOn:r,condition:"notRead",permissions:[],paths:[],messages:[],switches:[]}}function Ur(e){let n=Ke(e.TriggerObjectOrEvent),t=$r[y(e.TriggerType)];if(!n||!t)return;let r=t==="beforeDelete"?"delete":_r[y(e.RecordTriggerType)]??"createAndUpdate",o=y(e.ActiveVersionId),s=Je(y(e.ApiName),y(e.Label),t,r);return e.HasAsyncAfterCommitPath===!0&&(s.paths=[{kind:"async"}]),{objectApiName:n,id:B.test(o)?o:null,flow:s}}function Wr(e){let n=y(e.ActiveVersionId);return{objectApiName:Ke(e.TriggerObjectOrEvent),id:B.test(n)?n:null,flow:Je(y(e.ApiName),y(e.Label),"afterSave","createAndUpdate")}}function Vr(e){let n=Ke(e.EntityDefinition)??(y(e.TableEnumOrId)||void 0),t=y(e.Name);if(!n||!t)return;let r=y(e.NamespacePrefix);return{objectApiName:n,trigger:{name:r?`${r}.${t}`:t,events:Lr.filter(([o])=>e[o]===!0).map(([,o])=>o)}}}function Yn(e){return e.startsOn==="create"||e.startsOn==="createAndUpdate"?e.timing==="afterSave"?0:1:e.startsOn==="update"?2:3}function at(e){let n=new Set(pt(JSON.stringify(e??null)).filter(o=>re(o)==="Permission").map(ze));if(n.size===0)return[];let t=E(e,"filterFormula"),r=new Set((typeof t=="string"?oe(t):[]).filter(o=>re(o.reference)==="Permission"&&o.value===void 0).map(o=>ze(o.reference)));return[...n].sort((o,s)=>o.localeCompare(s)).map(o=>({name:o,bypass:r.has(o)}))}function ct(e){return typeof e!="string"?[]:ht(oe(e)).filter(n=>re(n.reference)!=="Permission").map(n=>({...n,where:"start",bypass:!0}))}var dt={permission:"Permission",setup:"Setup",user:"User",profile:"Profile",custommetadata:"CustomMetadata"},lt=String.raw`[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*`,ut=new RegExp(String.raw`\$(?:Permission|Setup|User|Profile|CustomMetadata)\.${lt}`,"gi"),K=String.raw`(?:\{!\s*)?(\$(?:Permission|Setup|User|Profile|CustomMetadata)\.${lt})\s*\}?`,zr=new RegExp(`^${K}$`,"i"),Qr=new RegExp(`^NOT\\s+${K}$`,"i"),ft=new RegExp(`^(?:${K}\\s*(==?|<>|!=)\\s*(TRUE|FALSE)|(TRUE|FALSE)\\s*(==?|<>|!=)\\s*${K})$`,"i"),Xn=String.raw`("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')`,gt=new RegExp(`^(?:${K}\\s*(==?|<>|!=)\\s*${Xn}|${Xn}\\s*(==?|<>|!=)\\s*${K})$`,"i");function W(e){let n=e.indexOf("."),t=dt[e.slice(1,n).toLowerCase()];return t?`$${t}${e.slice(n)}`:e}function re(e){return dt[e.slice(1,e.indexOf(".")).toLowerCase()]}function ze(e){return e.slice(e.indexOf(".")+1)}function pt(e){return[...new Set([...e.matchAll(ut)].map(n=>W(n[0])))]}var Hr=new RegExp(`^${ut.source}$`,"i");function mt(e){return typeof e=="string"&&Hr.test(e)}function he(e,n){return e.toLowerCase()===n.toLowerCase()}function yt(e){return e.slice(1,-1).replace(/\\(.)/g,"$1")}function ht(e){let n=new Map;for(let t of e)n.set(`${t.reference.toLowerCase()}=${t.value??""}`,t);return[...n.values()]}function et(e,n){return e.some(t=>he(t.reference,n.reference)&&t.value===n.value)}function oe(e){return Qe(e).flatMap(Kr)}function Ze(e){return He(e).flatMap(Jr)}function Kr(e){let n=ft.exec(e);if(n){let[,o,s,i,d,l,a]=n,u=s??l,f=(i??d).toUpperCase();return(u.startsWith("=")?f==="FALSE":f==="TRUE")?[{reference:W(o??a)}]:[]}let t=gt.exec(e);if(t){let[,o,s,i,d,l,a]=t;return(s??l).startsWith("=")?[]:[{reference:W(o??a),value:yt(i??d)}]}let r=Re(e,"NOT");if(r===void 0){let o=Qr.exec(e);return o?[{reference:W(o[1])}]:[]}return Ze(r)}function Jr(e){let n=zr.exec(e);if(n)return[{reference:W(n[1])}];let t=ft.exec(e);if(t){let[,s,i,d,l,a,u]=t,f=i??a,g=(d??l).toUpperCase();return(f.startsWith("=")?g==="TRUE":g==="FALSE")?[{reference:W(s??u)}]:[]}let r=gt.exec(e);if(r){let[,s,i,d,l,a,u]=r;return(i??a).startsWith("=")?[{reference:W(s??u),value:yt(d??l)}]:[]}let o=Re(e,"NOT");return o===void 0?[]:oe(o)}function Qe(e){let n=wt(e),t=Re(n,"AND");if(t)return we(t,",").flatMap(Qe);let r=we(n,"&&");return r.length>1?r.flatMap(Qe):[n]}function He(e){let n=wt(e),t=Re(n,"OR");if(t)return we(t,",").flatMap(He);let r=we(n,"||");return r.length>1?r.flatMap(He):[n]}function Re(e,n){let t=new RegExp(`^${n}\\s*\\(([\\s\\S]*)\\)$`,"i").exec(e);return t&&Rt(t[1])?t[1]:void 0}function wt(e){let n=e.trim();for(;n.startsWith("(")&&n.endsWith(")")&&Rt(n.slice(1,-1));)n=n.slice(1,-1).trim();return n}function Rt(e){let n=0;for(let{char:t,quoted:r}of bt(e))if(!r){if(t==="(")n++;else if(t===")"&&--n<0)return!1}return n===0}function we(e,n){let t=[],r=0,o=0;for(let{char:s,index:i,quoted:d}of bt(e))d||(s==="("?r++:s===")"?r--:r===0&&e.startsWith(n,i)&&(t.push(e.slice(o,i).trim()),o=i+n.length));return t.push(e.slice(o).trim()),t.filter(s=>s!=="")}function*bt(e){let n=null;for(let t=0;t<e.length;t++){let r=e[t];if(n){r==="\\"?t++:r===n&&(n=null),yield{char:r,index:t,quoted:!0};continue}if(r==='"'||r==="'"){n=r,yield{char:r,index:t,quoted:!0};continue}yield{char:r,index:t,quoted:!1}}}function Zr(e){let n=E(e,"start");if(typeof n=="object"&&n!==null){let t=y(E(E(n,"connector"),"targetReference"))||void 0,r=M(E(n,"scheduledPaths")).map(o=>y(E(E(o,"connector"),"targetReference"))||void 0);return{name:t,everyPath:r.every(o=>o===t)}}return{name:y(E(e,"startElementReference"))||void 0,everyPath:!0}}function Yr(e,n){let t=e.leftValueReference,r=e.rightValue;if(mt(t)){let s=W(t);if(typeof E(r,"booleanValue")=="boolean")return[{reference:s}];let i=E(r,"stringValue");return typeof i=="string"?[{reference:s,value:i}]:[]}let o=typeof t=="string"?n.get(t):void 0;return o===void 0?[]:[...Ze(o),...oe(o)]}function Xr(e,n){let t=e.leftValueReference,r=typeof t=="string"?n.get(t):void 0;return pt([typeof t=="string"?t:"",y(E(e.rightValue,"elementReference")),r??""].join(" "))}function eo(e,n,t){let{leftValueReference:r,operator:o,rightValue:s}=e;if(o!=="EqualTo"&&o!=="NotEqualTo")return"unknown";let i=o==="EqualTo",d=E(s,"booleanValue");if(mt(r)){if(!he(r,n.reference))return"unknown";if(typeof d=="boolean"&&n.value===void 0)return d===i?"true":"false";let u=E(s,"stringValue");return typeof u=="string"&&n.value!==void 0?u===n.value===i?"true":"false":"unknown"}let l=typeof r=="string"?t.get(r):void 0;if(l===void 0||typeof d!="boolean")return"unknown";let a=d===i;return et(Ze(l),n)?a?"true":"false":et(oe(l),n)?a?"false":"true":"unknown"}function no(e,n,t){let r=M(e.conditions);if(r.length===0)return"unknown";let o=r.map(i=>eo(i,n,t)),s=y(e.conditionLogic).toLowerCase()||"and";return s==="and"?o.includes("false")?"false":o.every(i=>i==="true")?"true":"unknown":s==="or"?o.includes("true")?"true":o.every(i=>i==="false")?"false":"unknown":"unknown"}function to(e,n,t){for(let r of M(e.rules)){let o=no(r,n,t),s=!y(E(r.connector,"targetReference"));if(o!=="false"){if(o==="true")return s;if(!s)return!1}}return!y(E(e.defaultConnector,"targetReference"))}function Tt(e){let n=M(E(e,"decisions")),t=new Map(M(E(e,"formulas")).filter(f=>typeof f.expression=="string").map(f=>[y(f.name),y(f.expression)])),r=f=>M(f.rules).flatMap(g=>M(g.conditions)),o=[...new Set(n.flatMap(f=>r(f).flatMap(g=>Xr(g,t))))];if(o.length===0)return{permissions:[],switches:[]};let{name:s,everyPath:i}=Zr(e),d=i?n.find(f=>y(f.name)===s):void 0,l=d?ht(r(d).flatMap(f=>Yr(f,t))).filter(f=>to(d,f,t)):[],a=o.filter(f=>re(f)==="Permission").map(f=>({name:ze(f),bypass:l.some(g=>he(g.reference,f)&&g.value===void 0),where:"decision"})).sort((f,g)=>f.name.localeCompare(g.name)),u=o.filter(f=>re(f)!=="Permission").flatMap(f=>{let g=l.filter(p=>he(p.reference,f));return g.length>0?g.map(p=>({...p,where:"decision",bypass:!0})):[{reference:f,where:"decision",bypass:!1}]}).sort((f,g)=>f.reference.localeCompare(g.reference));return{permissions:a,switches:u}}function ro(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(n=>n!=="").map(n=>n.toLowerCase())}function oo(...e){return e.some(n=>{let t=ro(n);return t.some(r=>Gr.has(r))||t.some((r,o)=>r==="text"&&/^messages?$/.test(t[o+1]??""))})}function St(e){return M(E(e,"actionCalls")).flatMap(n=>{let t=y(n.actionType),r=y(n.label)||y(n.name)||y(n.actionName),o=Dr[t],s=qr[t];return o?[{kind:o,name:r,...s?{limit:s}:{}}]:t==="apex"&&oo(y(n.actionName),y(n.name),r)?[{kind:"sms",name:r,guessed:!0}]:[]})}function so(e){return M(E(E(e,"start"),"scheduledPaths")).map(n=>{let t=y(n.label)||y(n.name)||void 0;if(y(n.pathType)==="AsyncAfterCommit")return{kind:"async",label:t};let r=Number(n.offsetNumber),o=y(n.timeSource)==="RecordField"?y(n.recordField):"";return{kind:"scheduled",label:t,...Number.isFinite(r)?{offset:r}:{},...y(n.offsetUnit)?{unit:y(n.offsetUnit)}:{},...o?{field:o}:{}}})}function At(e,n){let t=jn(n);t.length>0&&(e.creates=t)}function io(e,n){if(typeof n!="object"||n===null)return;let t=E(n,"start"),r=Tt(n);e.permissions=[...at(t),...r.permissions],e.switches=[...ct(E(t,"filterFormula")),...r.switches],e.paths=so(n),e.messages=St(n),At(e,n)}function ao(e,n){let t=new Map(M(E(n,"processMetadataValues")).map(o=>[y(o.name),y(E(o.value,"stringValue"))]));e.startsOn=it[t.get("TriggerType")??""]??"createAndUpdate";let r=Tt(n);return e.permissions=r.permissions,e.switches=r.switches,e.messages=St(n),At(e,n),t.get("ObjectType")||void 0}function co(e,n){e.startsOn=it[y(E(n,"triggerType"))]??"createAndUpdate";let t=E(n,"formula");e.permissions=typeof t=="string"?at({filterFormula:t}):[],e.switches=ct(t);let r=M(E(n,"workflowTimeTriggers"));return e.paths=r.map(o=>{let s=Number(o.timeLength);return{kind:"scheduled",...Number.isFinite(s)?{offset:s}:{},...y(o.workflowTimeTriggerUnit)?{unit:y(o.workflowTimeTriggerUnit)}:{},...y(o.offsetFromField)?{field:y(o.offsetFromField)}:{}}}),e.messages=[E(n,"actions"),...r.map(o=>o.actions)].flatMap(M).flatMap(o=>{let s=Br[y(o.type)];return s?[{kind:s,name:y(o.name),...s==="email"?{limit:"DailyWorkflowEmails"}:{}}]:[]}),E(n,"active")===!0}function Ot(e,n){return(e?`${e}__${n}`:n).toLowerCase()}function Ge(e,n){let t=kn(n);return t===void 0?{part:e,reason:G(n)}:{part:e,reason:`the org could not be reached (${t})`,unreachable:t}}async function ge(e,n){let t=new Array(e.length),r=0,o=async()=>{for(;r<e.length;){let s=r++;t[s]=await e[s]()}};return await Promise.all(Array.from({length:Math.min(n,e.length)},o)),t}var nt=[_,H,V,L,Y],tt=["ProductCategory","ProductCatalog"];function lo(e,n=new Set){let{referenceDataObjects:t}=Wn(void 0),r=e.nodes.filter(u=>u.included&&!n.has(u.objectApiName)&&!t.has(u.objectApiName)).map(u=>u.objectApiName),o=new Set(r),s=new Set(e.nodes.map(u=>u.objectApiName)),i=Object.entries(Rn).filter(([u,{object:f}])=>o.has(u)&&!s.has(f)&&!n.has(f)).map(([,{object:u}])=>u),d=Hn(e,n),l=u=>e.edges.some(f=>f.required===!0&&u.includes(f.sourceObject)&&d.has(f.sourceObject)&&o.has(f.targetObject)),a=i.length>0||l(nt);return[...new Set([...r,...i,...a?nt.filter(u=>d.has(u)):[],...l(tt)?tt.filter(u=>d.has(u)):[]])]}var rt=class{deps;constructor(n){this.deps=n}async readForGraph(n,t,r=new Set){return this.read(n,lo(t,r))}async read(n,t,r={}){let o=[],s=0,i=new Map(t.map(c=>[c.toLowerCase(),c])),d=c=>c===void 0?void 0:i.get(c.toLowerCase()),l=(c,m)=>async()=>{try{let O=await m();return s+=O.requests,O.records}catch(O){return s++,o.push(Ge(c,O)),[]}},a=c=>()=>this.deps.query(n,c),u=c=>()=>this.deps.toolingQuery(n,c),f=async()=>[],g=t.some(c=>/^(case|lead)$/i.test(c)),[p,w,T,S,b,x]=await ge([l("flows",a(fr)),l("triggers",u(gr)),l("processes",a(pr)),l("workflowRules",u(mr)),g?l("assignmentRules",a(yr)):f,l("duplicateRules",a(hr))],te),N=p.map(Ur).filter(c=>c!==void 0).flatMap(c=>{let m=d(c.objectApiName);return m?[{...c,objectApiName:m}]:[]}),k=w.map(Vr).filter(c=>c!==void 0).flatMap(c=>{let m=d(c.objectApiName),O=c.trigger.events.some(v=>v!=="afterUndelete"||r.undeletes===!0);return m&&O?[{...c,objectApiName:m}]:[]}),R=T.map(Wr),I=R.filter(c=>c.objectApiName===void 0&&c.id!==null).map(c=>c.id),h=t.filter(c=>c.includes("__")&&Ve.test(c)),F=S.some(c=>/^01I/.test(y(c.TableEnumOrId))),[A,$]=await ge([I.length>0?l("processes",a(xr(I))):f,F&&h.length>0?l("workflowRules",a(vr(h))):f],te),se=new Map(A.filter(c=>y(c.ApiName).toLowerCase()===jr).map(c=>[y(c.FlowVersionViewId),y(c.ObjectType)]));for(let c of R)c.objectApiName===void 0&&c.id!==null&&(c.objectApiName=se.get(c.id)||void 0);let Et=new Map($.map(c=>[y(c.DurableId),y(c.QualifiedApiName)])),be=S.flatMap(c=>{let m=y(c.TableEnumOrId),O=d(Et.get(m)??m),v=y(c.Name),P=y(c.Id);if(!O||!v)return[];let D=y(c.NamespacePrefix),z=D?`${D}.${v}`:v;return[{objectApiName:O,id:B.test(P)?P:null,flow:Je(z,z,"afterSave","createAndUpdate")}]}),Te=R.filter(c=>c.objectApiName===void 0||d(c.objectApiName)!==void 0),kt=new Map(t.map((c,m)=>[c,m])),ie=c=>kt.get(d(c.objectApiName)??"")??t.length,Se=N.filter(c=>c.id!==null).sort((c,m)=>Yn(c.flow)-Yn(m.flow)||ie(c)-ie(m)||c.flow.label.localeCompare(m.flow.label)),J=this.deps.toolingQueries,Ae=J?this.deps.toolingRetrieves:void 0,Ye=Ae?ye:me,Xe=J?Ue*Ye:ur,en=J?We*Ye:ot,Oe=Se.slice(0,Xe),nn=[...Te.map(c=>({read:c,kind:"process"})),...be.map(c=>({read:c,kind:"rule"}))].filter(({read:c})=>c.id!==null).sort((c,m)=>ie(c.read)-ie(m.read)||(c.kind===m.kind?0:c.kind==="process"?-1:1)||c.read.flow.label.localeCompare(m.read.flow.label)),tn=nn.slice(0,en),Fe,Ee,rn=new Set,on=c=>c[0]?.Metadata,Nt=(c,m)=>{c.flow.condition="read",io(c.flow,on(m))},It=(c,m)=>{c.flow.condition="unreadable",Fe??=m},xt=({read:c,kind:m})=>m==="process"?Zn(c.id):Ir(c.id),vt=({read:c,kind:m},O)=>{let v=on(O);if(typeof v!="object"||v===null){c.flow.condition="unreadable";return}if(c.flow.condition="read",m==="process"){let P=ao(c.flow,v);c.objectApiName??=P}else co(c.flow,v)||rn.add(c.flow)},Pt=({read:c},m)=>{c.flow.condition="unreadable",Ee??=m},sn=(c,m,O,v,P)=>c.map(D=>({soql:m(D),retrieve:O(D),take:z=>v(D,z),refused:z=>P(D,z)})),an=sn(Oe,c=>Zn(c.id),c=>({sobject:"Flow",id:c.id}),Nt,It),cn=sn(tn,xt,({read:c,kind:m})=>({sobject:m==="process"?"Flow":"WorkflowRule",id:c.id}),vt,Pt);J?s+=await Nr(c=>J(n,c),[{queries:an,requests:Ue},{queries:cn,requests:We}],te,Ae&&(c=>Ae(n,c))):await ge([...an,...cn].map(c=>async()=>{try{let m=await this.deps.toolingQuery(n,c.soql);s+=m.requests,c.take(m.records)}catch(m){s++,c.refused(G(m))}}),te),Fe!==void 0&&o.push(Ge("conditions",Fe)),Ee!==void 0&&o.push(Ge("definitions",Ee));for(let c of[...N,...Te,...be])c.id===null&&(c.flow.condition="unreadable");let dn=Te.flatMap(c=>{let m=d(c.objectApiName);return m?[{...c,objectApiName:m}]:[]}),ln=be.filter(c=>!rn.has(c.flow)),ke=[...N,...dn,...ln].flatMap(c=>c.flow.permissions),un;if(ke.length>0){let[c]=await ge([l("userPermissions",a(wr))],te);if(!o.some(m=>m.part==="userPermissions")){let m=new Set(c.map(O=>Ot(y(O.NamespacePrefix),y(O.DeveloperName))));un=m;for(let O of ke)O.held=m.has(O.name.toLowerCase())}}let fn=[...new Set(ke.filter(c=>c.bypass&&c.held!==!0).map(c=>c.name))],Ne=fn.length>0?await uo(fn,c=>l("permissionSets",a(c))(),()=>o.some(c=>c.part==="permissionSets"),async c=>{try{let m=await this.deps.query(n,c);return s+=m.requests,m.records}catch(m){throw s++,m}}):void 0,ae={};if(Ne?.some(c=>c.permissionSets.length>0)){let{toolingQueries:c,toolingRetrieves:m}=this.deps;try{let{readValidationRuleBypasses:O}=await import("./chunk-7ABODJ4G.mjs"),v=await O(P=>this.deps.toolingQuery(n,P),t,c&&(P=>c(n,P)),m&&(P=>m(n,P)));s+=v.requests,ae.validationRuleBypasses=v.rules.flatMap(P=>P.permissions.some(D=>un?.has(D.toLowerCase()))?[]:[P]),v.notRead>0&&(ae.validationRulesNotRead=v.notRead)}catch(O){s++,ae.validationRulesUnread=G(O)}}let Ct=c=>b.filter(m=>y(m.SobjectType).toLowerCase()===c.toLowerCase()).map(m=>({name:y(m.Name)})).sort((m,O)=>m.name.localeCompare(O.name)),Mt=c=>x.filter(m=>y(m.SobjectType).toLowerCase()===c.toLowerCase()).map(m=>({name:y(m.MasterLabel)||y(m.DeveloperName),developerName:y(m.DeveloperName)})).sort((m,O)=>m.name.localeCompare(O.name)),jt=(c,m)=>c.label.localeCompare(m.label),Ie=(c,m)=>c.filter(O=>O.objectApiName===m).map(O=>O.flow).sort(jt),xe=new Map;for(let c of Se.slice(Oe.length))xe.set(c.objectApiName,(xe.get(c.objectApiName)??0)+1);let gn=t.flatMap(c=>{let m=xe.get(c);return m?[{objectApiName:c,flows:m}]:[]}),$t=t.map(c=>({objectApiName:c,flows:Ie(N,c),triggers:k.filter(m=>m.objectApiName===c).map(m=>m.trigger).sort((m,O)=>m.name.localeCompare(O.name)),processes:Ie(dn,c),workflowRules:Ie(ln,c),assignmentRules:Ct(c),duplicateRules:Mt(c)})).filter(c=>c.flows.length>0||c.triggers.length>0||c.processes.length>0||c.workflowRules.length>0||c.assignmentRules.length>0||c.duplicateRules.length>0);return{objectsRead:[...t],objects:$t,unread:o,conditionsNotRead:Se.length-Oe.length,conditionsBound:Xe,...gn.length>0?{conditionsNotReadOn:gn}:{},definitionsNotRead:nn.length-tn.length,definitionsBound:en,...Ne?{bypassGrants:Ne}:{},...ae,requests:s}}};function q(e){return e.slice(0,15)}async function uo(e,n,t,r){let o=e.flatMap(p=>{let w=p.indexOf("__"),T=w>0?p.slice(0,w):"",S=w>0?p.slice(w+2):p;return Ve.test(S)&&(!T||Ve.test(T))?[{name:p,developerName:S}]:[]});if(o.length===0)return;let s=await n(Pr([...new Set(o.map(p=>p.developerName))]));if(t())return;let i=new Map;for(let p of s){let w=y(p.Id);B.test(w)&&i.set(Ot(y(p.NamespacePrefix),y(p.DeveloperName)),w)}let d=o.flatMap(p=>{let w=i.get(p.name.toLowerCase());return w?[w]:[]}),l=d.length>0?await n(Cr(d)):[];if(t())return;let a=[...new Set(l.map(p=>y(p.ParentId)).filter(p=>B.test(p)))],u=new Map;for(let p of["SetupEntityAccess","ObjectPermissions"]){if(a.length===0)break;let w=await n(Mr(p,a));if(t())return;for(let T of w){let S=q(y(T.ParentId)),b=typeof T.n=="number"?T.n:Number(T.n);u.set(S,(u.get(S)??0)+(Number.isFinite(b)?b:0))}}let f=new Map;for(let p of s){let w=y(p.Id);B.test(w)&&f.set(q(w),Ft(y(p.NamespacePrefix),y(p.DeveloperName)))}let g=r&&a.length>0?await po(a,f,r):void 0;return o.map(({name:p})=>{let w=i.get(p.toLowerCase()),T=new Map;for(let S of l){if(!w||q(y(S.SetupEntityId))!==q(w))continue;let b=q(y(S.ParentId)),x=S.Parent,N=y(E(x,"Name"));if(!N||T.has(b))continue;let k=y(E(x,"NamespacePrefix"));T.set(b,{name:k?`${k}__${N}`:N,label:y(E(x,"Label"))||N,grants:u.get(b)??0,...g===void 0?{}:"refused"in g?{customPermissionsUnread:g.refused}:{customPermissions:g.bySet.get(b)??[]}})}return{permission:p,permissionSets:[...T.values()].sort((S,b)=>S.grants-b.grants||S.name.localeCompare(b.name))}})}function Ft(e,n){return e?`${e}__${n}`:n}function fo(e){return`SELECT ParentId, SetupEntityId FROM SetupEntityAccess WHERE SetupEntityType = 'CustomPermission' AND ParentId IN (${e.map(t=>`'${t}'`).join(", ")})`}function go(e){return`SELECT Id, DeveloperName, NamespacePrefix FROM CustomPermission WHERE Id IN (${e.map(t=>`'${t}'`).join(", ")})`}async function po(e,n,t){try{let r=await t(fo(e)),o=new Map(n),s=[...new Set(r.map(d=>y(d.SetupEntityId)).filter(d=>B.test(d)&&!o.has(q(d))))];if(s.length>0)for(let d of await t(go(s))){let l=y(d.Id);B.test(l)&&o.set(q(l),Ft(y(d.NamespacePrefix),y(d.DeveloperName)))}let i=new Map;for(let d of r){let l=q(y(d.ParentId)),a=o.get(q(y(d.SetupEntityId)));if(!a)continue;let u=i.get(l)??[];u.includes(a)||u.push(a),i.set(l,u)}for(let d of i.values())d.sort((l,a)=>l.localeCompare(a));return{bySet:i}}catch(r){return{refused:G(r)}}}var mo={insert:"on insert",update:"on update",delete:"on delete"},yo={insert:{before:"before save",after:"after save",beforeAndAfter:"before and after save"},update:{before:"before save",after:"after save",beforeAndAfter:"before and after save"},delete:{before:"before delete",after:"after delete",beforeAndAfter:"before and after delete"}},ho={flow:e=>`flow "${e}"`,trigger:e=>`Apex trigger ${e}`,process:e=>`process "${e}"`,workflowRule:e=>`workflow rule "${e}"`},wo={flows:"the flows",triggers:"the Apex triggers",conditions:"the start conditions of some flows",processes:"the Process Builder processes",workflowRules:"the workflow rules",definitions:"the definitions of some processes or workflow rules",assignmentRules:"the assignment rules",duplicateRules:"the duplicate rules",userPermissions:"the custom permissions of the user the run writes as",permissionSets:"the permission sets that hold a bypass the user the run writes as does not"},Ro={email:"email",notification:"custom notification",outbound:"outbound message",sms:"text message"};function bo(e){let n=e.guessed?" (guessed from the name of an Apex action)":"";return`${Ro[e.kind]} "${e.name}"${n}`}function To(e){let n=e.label?` "${e.label}"`:"";if(e.kind==="async")return`asynchronous path${n}`;if(e.offset===void 0||e.unit===void 0)return`scheduled path${n}`;let t=Math.abs(e.offset),r=t===1?e.unit.replace(/s$/,""):e.unit,o=e.offset<0?"before":"after";return`scheduled path${n} (${t} ${r} ${o} ${e.field??"the save"})`}function So(e){let n=e.value===void 0?"true":`'${e.value}'`;return e.where==="decision"?`its first decision ends it when ${e.reference} is ${n}`:`not when ${e.reference} is ${n}`}function Ao(e,n){let t=e.flow,r=t?.permissions??[],o=t?.switches??[],s=t?.messages??[],i=t?.paths??[],d=p=>p.held===!0?" (held)":p.held===!1?" (not held)":"",l=r.filter(p=>p.bypass&&p.where!=="decision"),a=r.filter(p=>p.bypass&&p.where==="decision"),u=r.filter(p=>!p.bypass&&p.where!=="decision"),f=[...r.filter(p=>!p.bypass&&p.where==="decision").map(p=>p.name),...o.filter(p=>!p.bypass).map(p=>p.reference)],g=e.kind==="flow"?"start condition":"definition";return[yo[n][e.when],...s.length>0?[`SENDS MESSAGES: ${s.map(bo).join(", ")}`]:[],...i.length>0?[`then after commit: ${i.map(To).join(", ")}`]:[],...l.length>0?[`not for a user with ${l.map(p=>p.name+d(p)).join(", ")}`]:[],...a.length>0?[`its first decision ends it for a user with ${a.map(p=>p.name+d(p)).join(", ")}`]:[],...o.filter(p=>p.bypass).map(So),...e.keptQuiet?["quiet for this run"]:[],...u.length>0?[`its start condition names ${u.map(p=>p.name).join(", ")}`]:[],...f.length>0?[`its decisions test ${f.join(", ")}`]:[],...t?.condition==="notRead"?[`${g} not read`]:[],...t?.condition==="unreadable"?[`${g} unreadable`]:[]]}function Ss(e,n,t={}){let r=[`target automation: what ${n} runs on the ${e.objectsRead.length} object(s) the run writes`];for(let i of e.objects){r.push(` ${i.objectApiName}`);for(let{write:a,fired:u}of Tn(i)){let f=u.map(g=>`${ho[g.kind](g.name)} (${Ao(g,a).join("; ")})`);r.push(` ${mo[a]}: ${f.join(", ")}`)}let d=t.mayApplyAssignmentRules!==!1;for(let a of i.assignmentRules??[])r.push(t.applyAssignmentRules?` assignment rule "${a.name}": applied${d?" (--apply-assignment-rules)":""}: it can give the records it routes another owner, and mail that owner`:` assignment rule "${a.name}": not applied: the run sends Sforce-Auto-Assign: FALSE and keeps the owner it sets${d?" (--apply-assignment-rules applies it)":""}`);let l=i.duplicateRules??[];l.length>0&&r.push(` duplicate rules: ${l.map(a=>`"${a.name}"`).join(", ")}: the run saves a record a rule only alerts on; a rule that blocks still refuses it`)}e.objects.length===0&&r.push(On(e.unread)?" nothing found in what could be read":" no active flow, process, workflow rule, Apex trigger, assignment rule or duplicate rule runs on them");let o=An(e),s=Sn(e).filter(i=>!o.includes(i));if(s.length>0){r.push(` bypass: assign ${s.join(", ")} to the user the run writes as, and the flows whose start condition excludes them stay quiet`+(t.mayMute!==!1?"; --mute-automation assigns them for the run alone, and takes them back as it ends":""));for(let{permission:i,permissionSet:d,others:l}of Fn(e,s)){if(!d){r.push(` ${i}: no permission set of ${n} holds it: an admin creates one that includes it`);continue}let a=l.length>0?`; also held by ${l.map(f=>f.name).join(", ")}`:"",u=t.username?`: ${En(d.name,n,t.username)}`:"";r.push(` ${i}: held by permission set ${d.name}, the smallest${a}${u}`)}}if(o.length>0&&r.push(` bypass held: the user the run writes as holds ${o.join(", ")}, and what excludes them stays quiet for this run`),e.conditionsNotRead>0){let i=(e.conditionsNotReadOn??[]).map(({objectApiName:d,flows:l})=>`${d} (${l})`).join(", ");r.push(` ${e.conditionsNotRead} start condition(s) not read: the read takes ${e.conditionsBound} at most`+(i?`; left unread on ${i}`:""))}(e.definitionsNotRead??0)>0&&r.push(` ${e.definitionsNotRead} process or workflow rule definition(s) not read: the read takes ${e.definitionsBound??ot} at most`);for(let{part:i,reason:d}of e.unread)r.push(` ${wo[i]} could not be read: ${d}`);return r.push(` read in ${e.requests} request(s) to ${n}`),r}export{Eo as a,ko as b,No as c,_n as d,Io as e,Ln as f,Vt as g,xo as h,$o as i,_o as j,Bn as k,Lo as l,Do as m,Wn as n,Le as o,Vn as p,Jt as q,H as r,Be as s,Yo as t,Xo as u,Hn as v,es as w,er as x,ns as y,ts as z,Kn as A,rs as B,os as C,ss as D,tr as E,is as F,as as G,ir as H,cs as I,ds as J,dr as K,ls as L,Jn as M,ur as N,ot as O,me as P,ye as Q,Ue as R,We as S,bs as T,fr as U,gr as V,pr as W,mr as X,yr as Y,hr as Z,wr as _,Zn as $,Rr as aa,br as ba,Fr as ca,Er as da,kr as ea,Ts as fa,Nr as ga,Ir as ha,xr as ia,vr as ja,Pr as ka,Cr as la,Mr as ma,at as na,ct as oa,Tt as pa,St as qa,so as ra,Ot as sa,Ge as ta,ge as ua,lo as va,rt as wa,uo as xa,fo as ya,go as za,Ss as Aa};
|
package/lib/chunk-CSBS5U5I.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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,e,f,g,h}from"./chunk-KRCA6IPH.mjs";import"./chunk-5TC3QB4U.mjs";import"./chunk-2BA2XKAY.mjs";import"./chunk-OAZRPP4I.mjs";import"./chunk-JEERQRLW.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-MJU2PGZQ.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LWW4U276.mjs";import"./chunk-MJVTDA5Q.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-2CNCDM56.mjs";import"./chunk-SIHORWVK.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-B5QQJ4SI.mjs";import"./chunk-NZC67CGR.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-F43REJDZ.mjs";import"./chunk-JPUR2CFX.mjs";import"./chunk-LPBMBW3O.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-IFETCRWE.mjs";import"./chunk-PZPJKATS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-MFG4MUIO.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-HS4YRX4J.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{d as CheckpointTakeStopped,a as DEFAULT_MAX_TOTAL,b as OBJECT_ROWS_MAX,f as holdingLimit,e as pastTheLimit,g as scopeCheckpoint,h as takeCheckpoint,c as takeOrgOf};
|
package/lib/chunk-DB7RBE5D.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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{e as a,f as b,g as c,h as d,i as e,j as f,k as g,l as h,m as i,n as j,o as k,p as l,q as m,r as n}from"./chunk-UNJA4J37.mjs";import"./chunk-XLXIPIEW.mjs";import"./chunk-TTKXMDBN.mjs";import"./chunk-TSLJUSLW.mjs";import"./chunk-KRCA6IPH.mjs";import"./chunk-5TC3QB4U.mjs";import"./chunk-2BA2XKAY.mjs";import"./chunk-OAZRPP4I.mjs";import"./chunk-JEERQRLW.mjs";import"./chunk-MHMH6MTP.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-MJU2PGZQ.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LWW4U276.mjs";import"./chunk-MJVTDA5Q.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-2CNCDM56.mjs";import"./chunk-SIHORWVK.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-B5QQJ4SI.mjs";import"./chunk-NZC67CGR.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-F43REJDZ.mjs";import"./chunk-JPUR2CFX.mjs";import"./chunk-LPBMBW3O.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-IFETCRWE.mjs";import"./chunk-PZPJKATS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-MFG4MUIO.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-HS4YRX4J.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{d as NOT_REMADE_WORDS,b as OTHERS_DELETION_WORDS,c as OUT_OF_REACH_WORDS,j as REWIND_AUTOMATION_LIFTED_BY,a as REWIND_RESIDUAL_IDS,i as RewindStopped,k as automationUnread,m as counted,h as heldWhile,l as inRewindWords,g as muteOfSteps,e as notAskedWords,n as rewindOrg,f as rewindOrgOf};
|
package/lib/chunk-E5ZB3LU5.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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{b as N}from"./chunk-WR2GIKWE.mjs";import{a as k}from"./chunk-BOGNK4LV.mjs";import{i as S}from"./chunk-F43REJDZ.mjs";import{a as _,b as E}from"./chunk-T63U4OZJ.mjs";import{Ba as V,E as L,Ha as H,N as F,O as w,Q as U,R as x,T as G,U as v,W as B,Wa as X,_ as j,qa as M,ta as W,ya as z}from"./chunk-VYXMVJL5.mjs";import{b as C,f as P,k as b,l as D}from"./chunk-7EANH5PY.mjs";var q={PII:"PII",PHI:"PHI",PCI:"PCI",Confidential:"SENSITIVE"},K={PII:"fake",PHI:"nullify",PCI:"mask",SENSITIVE:"hash",NONE:"fake"},$={name_pattern:"field_name",type_analysis:"field_name",content_pattern:"content_sampling"},J=.9;function ie(e,t){let n=[];for(let[i,a]of t){let c=a.fields.filter(o=>o.createable&&N({name:o.name,label:o.label,type:o.type})),l=new Map(c.map(o=>[o.name,o])),r=new Map,s=e.detectPII(i,c.map(o=>({apiName:o.name,label:o.label,type:o.type})));for(let o of s.piiFields){let u=l.get(o.fieldApiName);if(!u)continue;let d=q[o.classification];r.set(u.name,{objectApiName:i,fieldApiName:u.name,fieldLabel:u.label,fieldType:u.type,piiCategory:d,detectionMethod:$[o.detectionMethod],confidence:o.confidence,suggestedMethod:K[d]})}for(let o of c)r.has(o.name)||E(o.name,o.type)===void 0||r.set(o.name,{objectApiName:i,fieldApiName:o.name,fieldLabel:o.label,fieldType:o.type,piiCategory:"PII",detectionMethod:"field_name",confidence:J,suggestedMethod:"fake"});n.push(...r.values())}return n}function ae(e,t){let n=a=>`${a.objectApiName}.${a.fieldApiName}`,i=new Set(e.map(n));return[...e,...t.filter(a=>!i.has(n(a)))]}var Y=["Contact","Lead"];function re(e,t,n){if(e==="none")return[];let i=new Set(t),a=[];for(let c of Y){if(!i.has(c))continue;let l=n.filter(s=>s.objectApiName===c).map(s=>s.fieldApiName),r=[];l.some(_)||r.push("name"),l.some(s=>E(s,"string")==="email")||r.push("email"),l.some(s=>E(s,"string")==="phone")||r.push("phone"),r.length>0&&a.push({objectApiName:c,missing:r})}return a}function ce(e){return e.fatalError!==void 0?"failure":e.totalFailure>0||e.failedObjects.length>0?e.totalSuccess+(e.totalLinked??0)>0?"partial":"failure":[...Object.values(e.lookups??{}),...Object.values(e.statuses??{})].some(n=>n.refusals.length>0)||e.stopped===!0?"partial":"success"}var Q=D({name:C().min(1),referenceTo:b(C()).min(1),createable:P().optional(),updateable:P().optional()}).loose();function de(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let i=Q.safeParse(n);i.success&&t.push({name:i.data.name,referenceTo:i.data.referenceTo,createable:i.data.createable??!1,updateable:i.data.updateable??!1})}return t}var ge={STORAGE_EXCEEDED:"AUTOPILOT_STORAGE_EXCEEDED",API_BUDGET_EXCEEDED:"API_BUDGET_EXCEEDED",WRITE_DECLINED:"AUTOPILOT_WRITE_DECLINED",CONFIRMATION_UNAVAILABLE:"AUTOPILOT_CONFIRMATION_UNAVAILABLE",CHECKPOINT_REFUSED:"CHECKPOINT_REFUSED",RUN_CANCELLED:"RUN_CANCELLED",EMAILS_NOT_ACCEPTED:z},Ae={NO_PLAN:"AUTOPILOT_NO_PLAN",STORAGE_UNREAD:"AUTOPILOT_FIT_STORAGE_UNREAD",READ_REFUSED:"AUTOPILOT_FIT_READ_REFUSED",STALE:"AUTOPILOT_FIT_STALE"};function Ie(e,t,n=new Map){return L(e.waves.flatMap(i=>i.objects).map(i=>{let a=n.get(i);return{objectApiName:i,rows:[],counted:{rows:t.get(i)??0,...a!==void 0?{personAccounts:a}:{}}}}))}function he(e){return[...new Set(e.waves.flatMap(t=>t.objects.map(String)))]}async function Ce(e){return M(e)}function Z(e){return e.filter(t=>t.verdict==="exceeds").map(W)}function ee(e){return e.filter(t=>t.verdict==="unread").map(t=>({limit:t.limit,emails:t.emails,unread:t.unread??""}))}function Pe(e){return e.objects.filter(({rows:t})=>t>0).length}async function te(e,t,n,i,a={}){let c="unread"in t?await n().catch(o=>({unread:o instanceof Error?o.message:String(o)})):t.dailyApiRequests,{readBack:l=0,deliverability:r=0,mute:s=0}=a;return w({run:F(e.objects.map(({rows:o})=>({rows:o}))),...G(i),...s>0?{mute:s}:{},...l>0?{readBack:l}:{},...r>0?{deliverability:r}:{}},c)}async function ke(e){let{plan:t}=e,n=j(t,e.storage);if(t.totalRows===0)return{go:!0,check:n,asked:!1};let i=e.checkpointFirst?.estimate,a=v(i);if(a)return{go:!1,...a,check:n};let c=X(n,e.org);if(c)return{go:!1,code:"STORAGE_EXCEEDED",message:`${c} Nothing was written.`,check:n};let l=await te(t,e.storage,e.readApiBudget,i,{...e.readBack!==void 0?{readBack:e.readBack}:{},...e.mute!==void 0?{mute:e.mute}:{},...V(e.runEmails?.ofRun)}),r=U(l,e.org);if(r)return{go:!1,code:"API_BUDGET_EXCEEDED",message:r,check:n};let s=e.confirmAboveRecords,o=s>0&&t.totalRows>s?s:void 0,u=Z(e.emails??[]),d=ee(e.emails??[]),g=e.emailsUncounted,f=e.runEmails?.gate,y=f?.verdict==="asks",R=async m=>{let p=k(f,m&&y),I=e.checkpointFirst;if(I===void 0)return{go:!0,check:n,asked:m,...p};let h=await B(()=>I.take(I.estimate));return"stop"in h?{go:!1,...h.stop,check:n,...p}:{go:!0,check:n,asked:m,checkpoint:h.checkpoint,...p}};if(o===void 0&&n.verdict==="fits"&&u.length===0&&d.length===0&&g===void 0&&i===void 0&&!y)return R(!1);let A=S(e.orgTier),T=await e.confirm({stage:"write",module:"autopilot",org:e.org,orgTier:e.orgTier,objects:t.objects.map(({objectApiName:m,rows:p})=>({objectApiName:m,rows:p})),total:t.totalRows,...o!==void 0?{aboveRecords:o}:{},...A!==void 0&&t.totalRows>A?{largeVolume:A}:{},storage:H(n),counted:!0,...u.length>0?{emails:u}:{},...d.length>0?{emailsUnread:d}:{},...g!==void 0?{emailsUncounted:g}:{},...x(l),...i!==void 0?{checkpoint:i}:{},...f?.confirmation});if(T==="confirmed")return R(!0);let O=k(f,!1);return T==="declined"?{go:!1,code:"WRITE_DECLINED",message:"The Autopilot run was cancelled before it wrote anything. Nothing was written.",check:n,...O}:{go:!1,code:"CONFIRMATION_UNAVAILABLE",message:"The Autopilot run needed a confirmation before it wrote, and there was no one to ask. Nothing was written: run it again from the Autopilot page, where the question is asked.",check:n,...O}}export{ie as a,ae as b,re as c,ce as d,de as e,ge as f,Ae as g,Ie as h,he as i,Ce as j,Pe as k,te as l,ke as m};
|
package/lib/chunk-EFR2Y7E4.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
-
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
-
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
-
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
-
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as Re}from"./chunk-M3ROUWDX.mjs";import{K as ye,Q as Se,b as we}from"./chunk-ZM6OJGIG.mjs";import{ab as he,cb as be,i as pe,j as fe,k as ge,l as D}from"./chunk-4VS2V6WU.mjs";import{o as oe,p as se,q as ie,r as ae,s as de}from"./chunk-G35N4P7D.mjs";import{Ja as me,la as ue,ma as ce,na as v,oa as le,va as B,w as ne}from"./chunk-VYXMVJL5.mjs";import{b as Z}from"./chunk-WIO4XO4F.mjs";import{h as re}from"./chunk-L77FJZEP.mjs";import{p as I}from"./chunk-A527W53V.mjs";import{c as z,d as ee,g as te}from"./chunk-GGD7ON3M.mjs";import{b as M}from"./chunk-CA5NAXSU.mjs";import{Kc as H,Nc as K,Pc as x,_c as Q,bd as V,cd as X,dd as J,ed as Y,g as q,h as F,ic as G,j as W,yb as U}from"./chunk-TTFDUKUS.mjs";var N=1e4,Oe=W.REST_API_BATCH_SIZE;function xe(e){return e.id===void 0&&e.error!==void 0&&(e.errorDetails?.length??0)>0&&oe([e.error],e.errorDetails)}function Pe(e,n){return e.error===void 0?e:{...e,error:ie(e.error,n)}}function P(e){return{successIds:e.flatMap(n=>n.id===void 0?[]:[n.id]),errors:e.flatMap(n=>n.error===void 0?[]:[n.error])}}function Ae(e,n){if(e.aborted||e.outcomes.length!==n||(e.unmatchedIds?.length??0)>0||(e.failures??[]).some(r=>r.recordIndex<0))return;let t=new Array(n);for(let r of e.outcomes){if(r.recordIndex<0||r.recordIndex>=n)return;if(r.success){if(!r.id)return;t[r.recordIndex]={id:r.id}}else{let o=r.error??"Unknown error",i=ee(o);t[r.recordIndex]={error:o,...i?{errorDetails:[i]}:{}}}}return t.every(r=>r!==void 0)?t:void 0}function Ze(e){let{conn:n,bulkManager:t,retry:r,signal:o,label:i}=e,m=new re(e.bulkThreshold),g,R=async(p,c,l)=>{g??=be(n).then(d=>(d||e.log(`[WARN] ${i}: the org's duplicate rules could not be read: an object of more than the Bulk API threshold goes as a Bulk API job, which a duplicate rule may refuse`),d));let b=await g;if(b===void 0)return he.has(p)?(e.log(`[INFO] ${i}: ${p} goes through REST: the duplicate rules could not be read, and a standard rule watches it`),!0):!1;let w=b.has(p);return w&&e.log(`[INFO] ${i}: ${p} goes through REST: an active duplicate rule watches it, which a Bulk API job cannot waive`+(c>N?` \u2014 ${c} records in ${Math.ceil(c/Math.max(1,l))} calls, slower than one job`:"")),w},k=async(p,c,l)=>{let b=[];for(let w=0;w<c.length;w+=l){if(o.aborted)return{rows:b,stopped:!0};let d=c.slice(w,w+l);e.calls?.sending(p,d.length);let f=await r.execute(async()=>n.sobject(p).create(d,{headers:U()}));if(f.cancelled)return e.calls?.answered(p,[]),{rows:b,stopped:!0};if(f.success&&f.result){let s=[];for(let u of f.result)if(u.success&&u.id)s.push(u.id),b.push({id:u.id});else{let a=te(u.errors);b.push({error:a,errorDetails:(u.errors??[]).map(z)})}e.calls?.answered(p,s)}else{let s=f.error?.message??"Insert failed after retries";for(let u=0;u<d.length;u++)b.push({error:s});e.calls?.answered(p,[])}}return{rows:b}},S=e.wait??(p=>se(p,o)),E=async(p,c,l,b)=>{let w=Math.min(Math.max(1,b),Oe),d=await ae({outcomes:l,locked:xe,written:s=>s.id!==void 0,send:async s=>(await k(p,s.map(u=>c[u]),w)).rows,note:Pe,wait:S,stopped:()=>o.aborted}),f=de("record(s)",d);return{rows:d.outcomes,notes:f===void 0?[]:[`${p}: ${f}.`]}};return async(p,c,l,b)=>{let w=(l.length>N||m.shouldUseBulkApi(l.length))&&await R(c,l.length,b),d=w&&await g===void 0?[`The org's duplicate rules could not be read (the user SandForge connects as needs View Setup and Configuration): ${c}, which a standard duplicate rule watches, was sent through REST, whose header lets its matches be saved, rather than as a Bulk API job.`]:[];if(l.length>N&&!w){if(o.aborted)return{successIds:[],errors:[],stopped:!0};let a=new we({signal:o}),h={connection:n,bulkManager:t,onProgress:(T,$e)=>{e.onProgress(T,$e,`Streaming insert ${c}`)},onOpened:T=>e.calls?.sending(c,l.length,{job:T})};e.calls?.sending(c,l.length);let A=await a.executeChunked(h,c,"insert",a.createChunkGenerator(l),l.length);e.calls?.answered(c,A.aborted?[]:A.successIds);let j=A.aborted?void 0:Ae({outcomes:A.outcomes??[],unmatchedIds:A.unmatchedIds},l.length),y=j&&await E(c,l,j,b);return y&&y.notes.length>0?{...P(y.rows),notes:y.notes}:{successIds:A.successIds,errors:A.errors,...A.aborted?{stopped:!0}:{}}}if(m.shouldUseBulkApi(l.length)&&!w){if(o.aborted)return{successIds:[],errors:[],stopped:!0};let a={connection:n,bulkManager:t,onProgress:(y,T)=>{e.onProgress(y,T,`Bulk insert ${c}`)},signal:o,onOpened:y=>e.calls?.sending(c,l.length,{job:y})};e.calls?.sending(c,l.length);let h=await m.executeBulk(a,c,"insert",l);e.calls?.answered(c,h.aborted?[]:h.successIds);let A=Ae(h,l.length),j=A&&await E(c,l,A,b);return j&&j.notes.length>0?{...P(j.rows),rows:j.rows,notes:j.notes}:{successIds:h.successIds,errors:h.failures.map(y=>y.error),...A?{rows:A}:{},...h.aborted?{stopped:!0}:{}}}let f=await k(c,l,b);if(f.stopped)return{...P(f.rows),rows:f.rows,stopped:!0};let s=await E(c,l,f.rows,b),u=[...d,...s.notes];return{...P(s.rows),rows:s.rows,...u.length>0?{notes:u}:{}}}}var Ce="SELECT Id, DeveloperName FROM RecordType WHERE SobjectType = 'Account' AND IsPersonType = true";async function rt(e){try{return(await e.query(Ce)).records.flatMap(t=>typeof t.Id=="string"&&typeof t.DeveloperName=="string"?[{id:t.Id,developerName:t.DeveloperName}]:[])}catch{return[]}}function nt(e,n,t){let r=new Set(e===I?t.map(o=>o.id.slice(0,15)):[]);return Z(n).filter(o=>!o.master&&o.active&&o.available).map(o=>({recordTypeId:o.recordTypeId,developerName:o.developerName,label:o.name,person:r.has(o.recordTypeId.slice(0,15)),isDefault:o.defaultRecordTypeMapping}))}function Fe(e){let{staticValue:n,picklistValues:t}=e.config;return e.ruleType==="static"&&typeof n=="string"?[n]:e.ruleType==="picklist_random"?[...t??[]]:[]}function ot(e,n){if(n.length===0)return{template:e,personObjects:[]};let t=new Map(n.map(i=>[i.id.slice(0,15),i.developerName])),r=[],o=[];for(let i of e.objects){if(i.objectApiName!==I){o.push(i);continue}let m=i.fieldRules.find(S=>S.fieldApiName==="RecordTypeId"),g=m?Fe(m):[],R=g.filter(S=>t.has(S.slice(0,15)));if(R.length>0&&R.length<g.length){let S=R.map(E=>t.get(E.slice(0,15))).join(", ");return{refusal:`${I}: ${S} ${R.length===1?"is a person account record type":"are person account record types"} and the other record types chosen are not: a person account and a business account take different fields. Seed one kind in a run.`}}let k=R.length>0?"person":"business";k==="person"&&r.push(i.objectApiName),o.push({...i,fieldRules:i.fieldRules.filter(S=>!G(I,S.fieldApiName,k))})}return{template:{...e,objects:o},personObjects:r}}var Me=/^[a-z]{2,3}(?:_[A-Za-z0-9]{2,4}){0,2}$/;async function ve(e){try{let t=(await e.query("SELECT DefaultLocaleSidKey FROM Organization LIMIT 1")).records[0]?.DefaultLocaleSidKey;return typeof t=="string"&&Me.test(t)?t:void 0}catch{return}}async function it(e,n){return e??await ve(n)??"en_US"}var pt="SEED_FIT_STORAGE_UNREAD",ft="SEED_CANNOT_FIT";function gt(e,n=!1){return _(e.objects.filter(t=>t.recordCount>0).map(t=>t.objectApiName),n)}function _(e,n=!1){let t=new Set(e);return(r,o)=>t.has(r)&&(o==="insert"||o==="update"&&n&&r===Re)}function ht(e,n,t){if(typeof e.unread=="string")return{room:{perRecord:[],notCounted:[],unread:e.unread},unread:e.unread};let r=Y(e,n,t);return{running:r,room:pe(r,t)}}function C(e,n){return F(e.objectApiName,n)?.distribution.mode==="byKey"?"byKey":e.rows!==void 0?"rows":void 0}function ke(e,n){let t=F(e,n.relations);if(!(!t||t.parents.kind!=="generated"||t.distribution.mode==="byKey"||t.parentObject===e||!n.objects.some(r=>r.objectApiName===t.parentObject)))return t}function Ee(e,n){let t=n?.objects?.[e.objectApiName]??n?.all;return t!==void 0?Math.min(e.recordCount,Math.max(1,Math.floor(t))):e.recordCount}function Be(e,n,t){let r=new Map(e.objects.map(g=>[g.objectApiName,g])),o=new Map,i=new Set,m=g=>{let R=o.get(g);if(R!==void 0)return R;let k=r.get(g);if(C(k,e.relations))return o.set(g,k.recordCount),k.recordCount;i.add(g);let S=Math.round(n*Ee(k,t)),E=ke(g,e),p=E&&!i.has(E.parentObject)?Math.max(1,Math.min(S,q(E.distribution,m(E.parentObject)))):Math.max(1,S);return i.delete(g),o.set(g,p),p};return new Map(e.objects.map(g=>[g.objectApiName,m(g.objectApiName)]))}function De(e,n){if(n.cannotFit!==void 0)return e;let t=new Map(n.objects.map(r=>[r.objectApiName,r.after]));return{...e,objects:e.objects.map(r=>{let o=t.get(r.objectApiName);return o!==void 0&&o<r.recordCount?{...r,recordCount:o}:r})}}function Ne(e,n){let t=e.objects.filter(i=>!C(i,e.relations)),r=t.filter(i=>!ke(i.objectApiName,e)),o;for(let i of r.length>0?r:t){let m=Ee(i,n);(!o||m>o.records)&&(o={objectApiName:i.objectApiName,records:m})}return o}function Le(e){return`${e} record${e===1?"":"s"}`}function _e(e){let{template:n,personObjects:t,budget:r,room:o}=e,i=e.ask?.caps,m=e.ask?.share===!0||i===void 0,g=a=>{let h=Be(n,a,i),A=De(n,{objects:n.objects.map(y=>({objectApiName:y.objectApiName,before:y.recordCount,after:h.get(y.objectApiName)??y.recordCount}))}),j=fe(o,y=>h.get(y)??0);return{counts:h,bytes:Se(A,t)+j,roomBytes:j,requests:ye(A,e.path),records:[...h.values()].reduce((y,T)=>y+T,0)}},R=a=>a.bytes<=r.bytes,k=a=>r.runRequests===void 0||a.requests<=r.runRequests,S=a=>R(a)&&k(a),E=(a,h,A,j)=>({share:a,budget:{...ge(r,h.roomBytes,o),...A==="apiRequests"?{limitedBy:"apiRequests"}:{}},objects:n.objects.map(y=>{let T=C(y,n.relations);return{objectApiName:y.objectApiName,before:y.recordCount,after:h.counts.get(y.objectApiName)??y.recordCount,...T?{keptWhole:T}:{}}}),estimateMB:h.bytes/1048576,...j!==void 0?{cannotFit:j}:{},...o.unread!==void 0?{automationUnread:o.unread}:{}}),p=(a,h,A,j)=>({proposal:E(a,h,A,j),heldBy:A,records:h.records,requests:h.requests}),c=a=>{if(R(a))return`about ${a.requests} API requests, past the ${r.runRequests??0} that leave the org a tenth of its daily requests`;let h=me(a.bytes/1048576,r.bytes/1048576);return`${h.over} MB`+(a.roomBytes>0?", room for what the org's automation creates under them included":"")+`, past the ${h.bound} MB that fit`},l=a=>R(a)?"apiRequests":r.terms.limitedBy,b=n.objects.filter(a=>C(a,n.relations)).reduce((a,h)=>a+h.recordCount,0),w=g(1);if(S(w)){let a=n.objects.some(h=>(w.counts.get(h.objectApiName)??0)<h.recordCount);return p(1,w,a?"caps":"whole")}if(!m)return p(1,w,l(w),`with these caps the seed takes ${c(w)}: lower them, or fit by share`);let d=Ne(n,i);if(!d)return p(1,w,l(w),`the ${b} rows the template gives take ${c(w)}, and rows are kept whole`);let f=a=>g(a/d.records),s=D(d.records,a=>S(f(a)));if(s===0){let a=f(1);return p(1/d.records,a,l(a),`the least it can be cut to \u2014 one ${d.objectApiName} and what follows it`+(b>0?`, with the ${b} rows the template gives kept whole`:"")+`, ${Le(a.records)} \u2014 takes ${c(a)}`)}let u=D(d.records,a=>R(f(a)));return p(s/d.records,f(s),u>s?"apiRequests":r.terms.limitedBy)}function bt(e,n,t,r,o){if(!("unread"in e))return _e({template:n,personObjects:t,budget:e,room:r,path:o}).proposal}function wt(e,n){if(!(!e||e.before<n))return{module:"seed",share:e.share,...e.withinMB!==void 0?{withinMB:e.withinMB}:{},kept:n,inSource:e.before}}var Ie=(e,n)=>n==="insert";function je(e){return typeof e.unread=="string"}function qe(e){return(H(e).find(t=>t.write==="insert")?.fired??[]).map(t=>{let r=t.flow,o=r?.messages??[];return{kind:t.kind,name:t.name,when:t.when,emails:o.filter(i=>i.kind==="email").length,messages:[...new Set(o.flatMap(i=>i.kind==="email"?[]:[i.kind]))],creates:[...r?.creates??[]],afterCommit:(r?.paths?.length??0)>0,bypasses:(r?.permissions??[]).filter(i=>i.bypass).map(({name:i,held:m})=>m===void 0?{name:i}:{name:i,held:m}),keptQuiet:t.keptQuiet===!0,unread:r!==void 0&&r.condition!=="read"}})}function O(e){return[...new Set(e)].sort((n,t)=>n.localeCompare(t))}function Te(e,n,t,r,o=Ie){let i=e.objects.flatMap(d=>{let f=qe(d);return f.length>0?[{objectApiName:d.objectApiName,entries:f}]:[]}),m=je(t)?void 0:t,g=m!==void 0&&ue(m),R=m!==void 0&&ce(m),k=v(x(e),g,R),S=i.flatMap(d=>d.entries.flatMap(f=>f.bypasses)),E=O(S.filter(d=>d.held===!0).map(d=>d.name)),p=O(S.map(d=>d.name)).filter(d=>!E.includes(d)),c=Q(e,p),l=p.map(d=>{let f=c.find(s=>s.permission.toLowerCase()===d.toLowerCase())?.permissionSet;return f?{permission:d,permissionSet:f.name}:{permission:d}}),b=V(e,o),w=b.assign.length>0;return{org:n,objectsRead:[...e.objectsRead],objects:i,emailsPerRecord:k,...m&&k.length>0?{limits:{...m}}:{},...je(t)?{limitsUnread:t.unread}:{},alertsAsSingle:g,bypasses:l,bypassesHeld:E,...w?{mute:b,emailsPerRecordMuted:v(x(J(e,X(b))),g,R)}:{},unread:e.unread.map(({part:d,reason:f})=>({part:d,reason:f})),blinded:K(e.unread),conditionsNotRead:e.conditionsNotRead,...r?{deliverability:r}:{}}}async function jt(e){let n=e.writes??_(e.objects),t;try{t=await e.readAutomation(e.objects)}catch(i){return{error:M(i)}}let r=e.deliverability??(e.readDeliverability?(await ne({read:t,writes:Ie,readDeliverability:e.readDeliverability,accepted:!1,target:e.org,run:"seed"})).gate.deliverability:void 0);if(x(t).length===0)return{preview:Te(t,e.org,{},r,n)};let o=await e.readLimits().catch(i=>({unread:M(i)}));return{preview:Te(t,e.org,o,r,n)}}function $(e,n="and"){return e.length<=1?e.join(""):e.length===2?`${e[0]} ${n} ${e[1]}`:`${e.slice(0,-1).join(", ")}, ${n} ${e[e.length-1]}`}var Tt="SEED_EMAILS_EXCEEDED";function It(e,n,t){if("error"in e)return{checks:[],unknown:[`what ${t} runs as these records are created could not be read (${e.error}): the emails they make it send are not known`]};let{preview:r}=e,o={objects:n.map(s=>({objectApiName:s.objectApiName,rows:s.recordCount,storageBytes:0}))},i=r.limitsUnread!==void 0?{unread:r.limitsUnread}:r.limits??{},m=le(o,r.emailsPerRecord,i),g=new Set(n.filter(s=>s.recordCount>0).map(s=>s.objectApiName)),R=r.objects.flatMap(s=>g.has(s.objectApiName)?s.entries.filter(u=>u.unread&&!u.keptQuiet&&u.when!=="before").map(u=>`"${u.name}" on ${s.objectApiName}`):[]),k=[...m.filter(s=>s.verdict==="unread").map(s=>`about ${B(s.emails,s.limit)}, but what ${t} has left today could not be read (${s.unread??"not said"})`),...r.blinded?[`part of what ${t} runs could not be read: emails it sends may not be counted`]:[],...R.length>0?[`the emails of ${$(R)} are not counted: what ${R.length===1?"it does":"they do"} was not read`]:r.conditionsNotRead>0?[`${r.conditionsNotRead} start condition(s) of ${t} not read: the emails of those flows are not counted`]:[]],S=m.find(s=>s.verdict==="exceeds");if(!S)return k.length>0?{checks:m,unknown:k}:{checks:m};let E=m.filter(s=>s.verdict==="exceeds"),p=O(E.flatMap(s=>s.objects.map(u=>u.objectApiName))),c=O(E.flatMap(s=>s.objects.flatMap(u=>u.sentBy))),l=new Map;for(let s of r.objects.flatMap(u=>u.entries))if(!(s.emails===0||!c.includes(s.name)))for(let{name:u}of s.bypasses)l.set(u,(l.get(u)??new Set).add(s.name));let b=r.bypasses.flatMap(s=>{let u=l.get(s.permission);return u?[{...s,quiets:O([...u])}]:[]}),w=E.map(s=>`about ${B(s.emails,s.limit)} (`+s.objects.map(u=>`${u.perRecord} per ${u.objectApiName}`).join(", ")+`), ${s.remaining??0} of ${s.max??0} left today`).join("; "),d=["lower the record counts",`set ${$(p)} to 0`,`turn off ${$(c.map(s=>`"${s}"`))}`,...b.map(s=>"give the user the seed writes as "+(s.permissionSet?`the permission set ${s.permissionSet}, whose ${s.permission}`:`a permission set holding ${s.permission}, which`)+` keeps ${$(s.quiets.map(u=>`"${u}"`))} quiet`)],f=`The seed was refused before it wrote anything: its records would make ${t} send ${w}. Past what is left, a flow that sends in the save refuses its record (CANNOT_EXECUTE_FLOW_TRIGGER), and the org's own emails stop for the rest of the day. To seed it, ${$(d,"or")}. Nothing was written.`;return{checks:m,refusal:f,figures:{org:t,limit:S.limit,emails:S.emails,remaining:S.remaining??0,max:S.max??0,objects:p,senders:c,bypasses:b},...k.length>0?{unknown:k}:{}}}var We={flow:e=>`flow "${e}"`,trigger:e=>`Apex trigger ${e}`,process:e=>`process "${e}"`,workflowRule:e=>`workflow rule "${e}"`},Ue={before:"before save",after:"after save",beforeAndAfter:"before and after save"},Ge={notification:"custom notifications",outbound:"outbound messages",sms:"text messages"};function He(e){let n=r=>r.held===!0?" (held)":r.held===!1?" (not held)":"",t=[Ue[e.when],...e.emails>0?[`${e.emails} email(s) a record`]:[],...e.messages.map(r=>`sends ${Ge[r]}`),...e.creates.length>0?[`creates ${e.creates.join(", ")}`]:[],...e.afterCommit?["then after commit"]:[],...e.bypasses.length>0?[`not for a user with ${e.bypasses.map(r=>r.name+n(r)).join(", ")}`]:[],...e.keptQuiet?["quiet for this seed"]:[],...e.unread?["what it does was not read"]:[]];return`${We[e.kind](e.name)} (${t.join("; ")})`}function $t(e,n){if("error"in e)return[`target automation: what ${n} runs as these records are created could not be read (${e.error}): the emails they make it send are not known`];let{preview:t}=e,r=[`target automation: what ${n} runs as these records are created`];for(let o of t.objects)r.push(` ${o.objectApiName}: ${o.entries.map(He).join(", ")}`);t.objects.length===0&&r.push(t.blinded?" nothing found in what could be read":" nothing runs on them: no flow, Apex trigger, process or workflow rule"),t.bypassesHeld.length>0&&r.push(` bypass held: the user the seed writes as holds ${t.bypassesHeld.join(", ")}, and what names it stays quiet`);for(let o of t.bypasses)r.push(o.permissionSet?` bypass: ${o.permission} keeps quiet what names it; permission set ${o.permissionSet} holds it`:` bypass: ${o.permission} keeps quiet what names it; no permission set of ${n} was found to hold it`);t.alertsAsSingle&&t.emailsPerRecord.some(o=>o.alertsAmong)&&r.push(` ${n} counts its email alerts against its single emails too, as a Developer Edition does`);for(let{part:o,reason:i}of t.unread)r.push(` ${o} could not be read: ${i}`);return t.conditionsNotRead>0&&r.push(` ${t.conditionsNotRead} start condition(s) not read`),r}export{Ze as a,rt as b,nt as c,ot as d,it as e,pt as f,ft as g,gt as h,_ as i,ht as j,De as k,_e as l,bt as m,wt as n,jt as o,Tt as p,It as q,$t as r};
|
package/lib/chunk-EHQ3FX6X.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
-
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
-
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
-
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
-
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{f as a,g as b,h as c,i as d,j as e,k as f,l as g}from"./chunk-TTKXMDBN.mjs";import"./chunk-5TC3QB4U.mjs";import"./chunk-2BA2XKAY.mjs";import"./chunk-JEERQRLW.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-SIHORWVK.mjs";import"./chunk-JPUR2CFX.mjs";import"./chunk-LPBMBW3O.mjs";import"./chunk-IFETCRWE.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{d as diffOfPicked,b as heldInPlaceReason,g as planSelection,c as rewindPlan,a as rewindWriters,f as selectionPlanOf,e as snapshotRowsOf};
|
package/lib/chunk-EQNW3UC2.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
-
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
-
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
-
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
-
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as P}from"./chunk-ZUTYVST5.mjs";import{d as X}from"./chunk-CU2INBND.mjs";import{d as Z}from"./chunk-WIO4XO4F.mjs";import{a as F}from"./chunk-EADHKH3A.mjs";import{c as H,g as Y}from"./chunk-GCOB7K5N.mjs";import{f as Q,s as W}from"./chunk-A527W53V.mjs";import{a as U,f as D,h as _}from"./chunk-TZE3Y7IQ.mjs";import{L as B,N as z,Q as V,Wb as k}from"./chunk-TTFDUKUS.mjs";import{b as I,k as C,l as A,v as K,z as R}from"./chunk-7EANH5PY.mjs";function Pe(e){let n=new Set;for(let t of e)t.controllerName&&n.add(t.controllerName);return n}function J(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}function Me(e,n){let t=J(e.precision),r=typeof e.scale=="number"&&e.scale>=0?e.scale:void 0,o=J(e.digits),s=(e.picklistValues??[]).filter(d=>d!==null&&typeof d.value=="string"),i={};if(e.controllerName)for(let d of s)d.active===!1||typeof d.validFor!="string"||(i[d.value]=d.validFor);return{...t!==void 0?{precision:t}:{},...t!==void 0&&r!==void 0?{scale:r}:{},...o!==void 0?{digits:o}:{},...e.unique===!0?{unique:!0}:{},...e.unique===!0&&typeof e.caseSensitive=="boolean"?{caseSensitive:e.caseSensitive}:{},...e.calculated===!0?{calculated:!0}:{},...e.filteredLookupInfo?{filteredLookup:!0}:{},...Object.keys(i).length>0?{validFor:i}:{},...n.has(e.name)&&s.length>0?{controllingValues:s.map(d=>d.value)}:{}}}function je(e,n){return e.caseSensitive===!1?n.toLowerCase():n}function M(e,n){if(n<0)return!1;let r=Buffer.from(e,"base64")[n>>3];return r!==void 0&&(r&128>>n%8)!==0}var ie={picklist_value_refused:["map_value","leave_empty","skip_rows","exclude_object","ignore"],dependent_value_invalid:["map_value","leave_empty","exclude_object","ignore"],picklist_value_absent:["map_value","skip_rows","ignore"],required_field_missing:["set_default","exclude_object","ignore"],value_too_long:["truncate","exclude_object","ignore"],number_out_of_range:["exclude_object","ignore"],record_type_unmapped:["map_record_type","exclude_object","ignore"],record_type_unavailable:["map_record_type","exclude_object","ignore"],currency_inactive:["map_value","skip_rows","exclude_object","ignore"],unique_value_collision:["exclude_object","ignore"]};function S(e){return[...ie[e]??["ignore"]]}var se=100,ae=new Set(["longest","colliding"]),T=class{gaps=new Map;recordTypes=new Map;get size(){return this.gaps.size}knowRecordTypes(n,t,r){let o=de(r);o!==void 0&&this.recordTypes.set(n,{...this.recordTypes.get(n),[t]:o})}add(n){let t=B(n.kind,n.objectApiName,n.field,n.recordType,n.value),r=this.gaps.get(t);if(!r){this.gaps.set(t,{...n,id:t,source:"simulation",decisions:[...n.decisions]});return}r.rows+=n.rows,n.decisions.includes("skip_rows")||(r.decisions=r.decisions.filter(s=>s!=="skip_rows"));let o={...n.detail??{},...r.detail??{}};for(let s of ae){let i=r.detail?.[s],d=n.detail?.[s];typeof i=="number"&&typeof d=="number"&&(o[s]=Math.max(i,d))}r.detail=o}list(n){let t=[...this.gaps.keys()],r=[...this.gaps.values()].map(o=>this.withSameDeveloperName(o)).map(o=>z(n,o,t)!==void 0?{...o,detail:{...o.detail??{},ignored:!0}}:o);return V(r)}withSameDeveloperName(n){let t=n.kind==="record_type_unmapped";return le(n,this.recordTypes.get(n.objectApiName)?.[t?"source":"target"])}};function de(e){let n=e.filter(t=>!t.master);if(!n.some(t=>t.namespacePrefix===void 0))return n.map(Z)}function le(e,n){let t=e.kind==="record_type_unmapped"?e.value:e.recordType;if(t===void 0||n===void 0)return e;let r=Y(t);if(!r.namespacePrefix)return e;let o=n.filter(s=>s.developerName===r.developerName&&s.namespacePrefix!==r.namespacePrefix).map(s=>H(s.namespacePrefix,s.developerName));return o.length===0?e:{...e,detail:{...e.detail??{},sameDeveloperName:[...new Set(o)].sort()}}}function j(e){return[...new Set(e)].sort().slice(0,se)}function Ve(e,n,t){let r=[];for(let o of n){if(o.field===P)continue;let s=t(o);for(let i of o.values)r.push({kind:"picklist_value_refused",severity:"warning",objectApiName:e,field:o.field,...o.recordType!==void 0?{recordType:o.recordType}:{},value:i,rows:1,detail:{reason:o.reason,...s?{allowed:j(s)}:{},...o.controllingField?{controllingField:o.controllingField}:{},...o.replacedBy!==void 0?{replacement:o.replacedBy}:{}},decisions:S("picklist_value_refused").filter(d=>d!=="skip_rows"||o.reason!=="controlling-value"),defaultDecision:o.replacedBy!==void 0?"map_value":"leave_empty"})}return r}var ce=new Set(["string","textarea","email","phone","url","encryptedstring"]),ue=new Set(["double","currency","percent"]);function fe(e){return e==null||e===""}function ne(e){return e.createable&&e.nillable===!1&&e.defaultedOnCreate!==!0&&e.calculated!==!0&&e.type!=="boolean"}function pe(e,n,t){return e==="Account"&&n==="Name"&&W(t)}function ge(e,n,t,r){return r.filter(o=>ne(o)&&fe(n[o.name])&&!pe(e,o.name,t))}function me(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string"||e.trim()==="")return;let n=Number(e);return Number.isFinite(n)?n:void 0}function ee(e){if(e.type==="int"&&e.digits!==void 0)return e.digits;if(e.precision!==void 0)return e.precision-(e.scale??0)}function ye(e,n){return e?e.type==="boolean"?n===!0||n==="true"?1:n===!1||n==="false"?0:-1:typeof n!="string"||n===""?-1:(e.controllingValues??[]).indexOf(n):-1}function te(e,n){let{objectApiName:t,rows:r,targetFields:o,picklistValuesByField:s,picklistFields:i}=e,d=new Map(o.map(l=>[l.name,l])),u=o.filter(ne),g=o.filter(l=>l.createable&&ce.has(l.type??"")&&(l.length??0)>0),f=o.filter(l=>l.createable&&(ue.has(l.type??"")||l.type==="int")&&ee(l)!==void 0),y=[...i].filter(([l,c])=>c.anyValue===!0&&s?.has(l)===!0),m=o.filter(l=>l.createable&&l.controllerName!==void 0&&l.validFor!==void 0);for(let{payload:l,source:c,typed:p}of r){for(let a of ge(t,l,c,u))n.add({kind:"required_field_missing",severity:"blocking",objectApiName:t,field:a.name,rows:1,...a.type?{detail:{type:a.type}}:{},decisions:S("required_field_missing")});for(let a of g){let h=l[a.name],b=a.length??0;typeof h!="string"||h.length<=b||n.add({kind:"value_too_long",severity:"blocking",objectApiName:t,field:a.name,rows:1,detail:{length:b,longest:h.length},decisions:S("value_too_long")})}for(let a of f){let h=me(l[a.name]),b=ee(a);h===void 0||b===void 0||Math.abs(Math.trunc(h))<10**b||n.add({kind:"number_out_of_range",severity:"blocking",objectApiName:t,field:a.name,rows:1,detail:{...a.precision!==void 0?{precision:a.precision}:{},...a.scale!==void 0?{scale:a.scale}:{},...a.type==="int"&&a.digits!==void 0?{digits:a.digits}:{}},decisions:S("number_out_of_range")})}for(let[a,h]of y){let b=l[a];if(typeof b!="string"||b==="")continue;let O=s?.get(a),E=h.multi?b.split(";"):[b];for(let v of new Set(E))O?.has(v)||n.add({kind:"picklist_value_absent",severity:"info",objectApiName:t,field:a,value:v,rows:1,decisions:S("picklist_value_absent")})}if(!p)for(let a of m){let h=l[a.name];if(typeof h!="string"||h==="")continue;let b=d.get(a.controllerName??""),O=ye(b,l[a.controllerName??""]),E=i.get(a.name)?.restricted===!0,v=i.get(a.name)?.multi?h.split(";"):[h];for(let G of new Set(v)){let $=a.validFor?.[G];$!==void 0&&(O>=0&&M($,O)||n.add({kind:"dependent_value_invalid",severity:E?"blocking":"warning",objectApiName:t,field:a.name,value:G,rows:1,detail:{controllingField:a.controllerName??"",allowed:j((b?.controllingValues??[]).filter((De,oe)=>M($,oe)))},decisions:S("dependent_value_invalid")}))}}}}function Ue(e,n,t,r){return{kind:"currency_inactive",severity:"warning",objectApiName:e,field:P,value:n,rows:t,...r&&r.to.length>0?{detail:{replacement:r.to.join(", "),...r.converted.length>0?{amountsConverted:[...r.converted]}:{},...r.asRead?{amountsAsRead:!0}:{}}}:{},decisions:S("currency_inactive"),defaultDecision:"map_value"}}function Qe(e,n,t,r){return{kind:"unique_value_collision",severity:"warning",objectApiName:e,field:n,rows:t,detail:{colliding:r,linkedToTheRecordItNames:!0},decisions:S("unique_value_collision"),defaultDecision:"ignore"}}function We(e,n,t,r,o){return{kind:e,severity:"blocking",objectApiName:n,field:"RecordTypeId",...e==="record_type_unavailable"?{recordType:t}:{value:t},rows:r,detail:{mapTo:j(o)},decisions:S(e)}}var he=10;function re(e){switch(e.operation){case"insert":return null;case"upsert":return e.externalIdField??"Id";case"update":case"delete":return"Id"}}function w(e){if(e==null||typeof e!="string"&&typeof e!="number"&&typeof e!="boolean")return null;let n=String(e);return n===""?null:n.toLowerCase()}function x(e){return typeof e=="number"&&Number.isFinite(e)?String(e):typeof e=="boolean"?e?"true":"false":`'${U(String(e))}'`}var be=200,we=4e3;function N(e){let n=[],t=[],r=0;for(let o of e){let s=x(o).length+2;t.length>0&&(t.length>=be||r+s>we)&&(n.push(t),t=[],r=0),t.push(o),r+=s}return t.length>0&&n.push(t),n}function nn(e,n){return async(t,r,o,s)=>{let i=k(r.objectApiName),d=_(o),u=new Map;for(let g of N(s)){if(n?.aborted)throw new Error("The simulation was cancelled.");let{records:f}=await F(e,`SELECT ${d} FROM ${i} WHERE ${d} IN (${g.map(x).join(", ")})`);for(let y of f){let m=w(y[d]);m!==null&&u.set(m,(u.get(m)??0)+1)}}return u}}var Se=new Set(["attributes","Id"]);function ke(e,n,t,r){return n?e.conflictFields.filter(o=>o!==t&&!Se.has(o)&&o in n&&(r===null||r.has(o))):[]}var tn=new Set(["noKey","notInTarget","ambiguous"]);function Re(e,n,t){let r=e.operation,o=re(e);if(o===null)return"insert";let s=w(n[o]);if(s===null)return r==="delete"?"notSent":"noKey";let i=t.get(s)??0;return r==="upsert"?i===0?o.toLowerCase()==="id"?"notInTarget":"insert":i===1?"update":"ambiguous":i===0?"notInTarget":r==="update"?"update":"delete"}function rn(e){let{objectConfig:n,records:t,inTarget:r}=e,o=n.operation,s=re(n),i={insert:0,update:0,delete:0,noKey:0,notInTarget:0,notSent:0,ambiguous:0},d=new Set;t.forEach((c,p)=>{let a=Re(n,c,r);i[a]++,(a==="insert"||a==="update")&&d.add(p)});let u=e.leftOut.map(({why:c,count:p})=>Q(p,c));i.noKey>0&&u.push(o==="upsert"?`${i.noKey} record(s) carry no value in ${s}: an upsert matches on it, and the target refuses a record without one.`:`${i.noKey} record(s) carry no Id: an update finds its record by Id, and the target refuses one without it.`),i.notInTarget>0&&u.push(`${i.notInTarget} record(s) carry an Id the target does not hold: ${o==="upsert"?"an upsert on the Id finds no record there and creates none":`${o==="update"?"an update":"a delete"} finds no record there`}, and the target refuses it. Two orgs share a record's Id only when it was copied with the org.`),i.ambiguous>0&&u.push(`${i.ambiguous} record(s) match more than one record of the target on ${s}: an upsert finds no single record to update, and the target refuses it.`),i.notSent>0&&u.push(`${i.notSent} record(s) carry no Id: a delete sends ids alone, so the run leaves them out.`);let g=new Map;e.unsettled.forEach((c,p)=>{let a=String(c[e.matchField]??"");a&&d.has(p)&&g.set(a,c)});let f=new Map,y=0;for(let c of e.conflicts){let p=ke(c,g.get(c.recordId),e.matchField,e.writable);if(p.length!==0){y++;for(let a of p)f.set(a,(f.get(a)??0)+1)}}let m=[...f].sort(([c,p],[a,h])=>h-p||c.localeCompare(a)).slice(0,he).map(([c])=>c),l=e.leftOut.reduce((c,{count:p})=>c+p,0);return{objectApiName:n.objectApiName,operation:o,read:e.read,insert:i.insert,update:i.update,delete:i.delete,skipped:l+i.notSent,refused:i.noKey+i.notInTarget+i.ambiguous,conflicts:y,conflictFields:m,notes:u}}function _e(e){let n=e.field??"";switch(e.kind){case"required_field_missing":return`${e.rows} record(s) leave ${n} empty, which the target requires: it refuses them (REQUIRED_FIELD_MISSING).`;case"value_too_long":return`${e.rows} record(s) hold a ${n} longer than the ${String(e.detail?.length)} characters the target's field takes (the longest, ${String(e.detail?.longest)}): it refuses them (STRING_TOO_LONG).`;case"number_out_of_range":return`${e.rows} record(s) hold a ${n} larger than the target's field takes: it refuses them (NUMBER_OUTSIDE_VALID_RANGE).`;default:return}}function on(e,n,t){let r=new Set,o=new T;n.forEach(({payload:i,source:d,creates:u},g)=>{let f=new T;te({objectApiName:e,rows:[{payload:i,source:d,typed:!0}],targetFields:t,picklistValuesByField:null,picklistFields:new Map},f);let y=f.list(new Set).filter(m=>m.severity==="blocking"&&(u||m.kind!=="required_field_missing"));if(y.length!==0){r.add(g);for(let m of y)o.add(m)}});let s=o.list(new Set).flatMap(i=>{let d=_e(i);return d?[d]:[]});return{refused:r,notes:s}}function sn(e,n){let t=new Set,r=new Set,o=[];for(let[s,i]of n){let d=new Set,u=0,g=0,f=0;e.forEach((y,m)=>{let l=w(y[s]);if(l===null)return;let c=i.get(l)??0;c===1?(u++,r.add(m)):c>1?(g++,t.add(m)):d.has(l)&&(f++,t.add(m)),d.add(l)}),u>0&&o.push(`LINKED_TO_EXISTING: ${u} record(s) hold a ${s} the target keeps unique, which a record of the target holds already: it refuses them as duplicates (DUPLICATE_VALUE) and names that record, which the run links them to \u2014 what it writes under them points at that record.`),g+f!==0&&o.push(`${g+f} record(s) hold a ${s} the target keeps unique, which `+[g>0?`several records of the target hold already (${g})`:"",f>0?`a record sent before them holds (${f})`:""].filter(Boolean).join(" or ")+": it refuses them (DUPLICATE_VALUE).")}for(let s of t)r.delete(s);return{refused:t,linked:r,notes:o}}import{createHash as Fe}from"node:crypto";var Ie=5*6e4,Te=500,xe=A({sourceOrgId:I().min(1).max(200),targetOrgId:I().min(1).max(200),objectApiName:I().regex(/^[A-Za-z][A-Za-z0-9_]{0,79}$/),watermark:R.datetime(),fingerprint:I().regex(/^[0-9a-f]{64}$/),recordedAt:R.datetime(),filesSeen:R.datetime().optional(),removedAt:R.datetime().optional()}),Oe=A({version:K(1),entries:C(xe).max(Te),resetAt:R.datetime().optional()});function mn(e){if(e==null)return{kind:"none"};let n=Oe.safeParse(e);if(n.success)return{kind:"stored",state:n.data};let t=n.error.issues[0];return{kind:"unreadable",issue:`${t.path.join(".")||"state"}: ${t.message}`}}function L(e){return Array.isArray(e)?`[${e.map(L).join(",")}]`:e!==null&&typeof e=="object"?`{${Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[r])=>t<r?-1:t>r?1:0).map(([t,r])=>`${JSON.stringify(t)}:${L(r)}`).join(",")}}`:JSON.stringify(e)}function q(e){let n=e?.trim();return n||null}function ve(e,n){let t={direction:e.direction,conflictStrategy:e.conflictStrategy,copiesFiles:e.files?!0:void 0,objectApiName:n.objectApiName,operation:n.operation,externalIdField:q(n.externalIdField),where:q(n.where),fieldMappings:n.fieldMappings??[],unmappedSentAsRead:(n.fieldMappings??[]).length>0?!0:void 0,transformRules:n.transformRules??[],excludedFields:n.excludedFields??[],addOnFields:n.addOnFields??[]};return Fe("sha256").update(L(t)).digest("hex")}function yn(e,n,t){let r=ve(e,n);if(t===null)return{read:"full",reason:"not_saved",fingerprint:r};if(t.kind==="unreadable")return{read:"full",reason:"unreadable",fingerprint:r};if(t.kind==="none")return{read:"full",reason:"first_run",fingerprint:r};let o=t.state.entries.find(s=>s.sourceOrgId===e.sourceOrgId&&s.targetOrgId===e.targetOrgId&&s.objectApiName===n.objectApiName);return o?o.fingerprint!==r?{read:"full",reason:"scope_changed",fingerprint:r}:o.removedAt!==void 0?{read:"full",reason:"removed",fingerprint:r}:{read:"delta",since:o.watermark,fingerprint:r,...o.filesSeen!==void 0?{filesSeen:o.filesSeen}:{}}:{read:"full",reason:t.state.resetAt?"reset":"first_run",fingerprint:r}}var Ne=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;function hn(e,n=Ie){let t=Date.parse(e);if(!Number.isFinite(t))throw new Error(`Not a watermark: "${e}".`);let r=Math.floor((t-n)/1e3)*1e3;return new Date(r).toISOString().replace(/\.\d{3}Z$/,"Z")}function bn(e){let n=Date.parse(e);if(!Number.isFinite(n))throw new Error(`Not a date: "${e}".`);return new Date(Math.floor(n/1e3)*1e3).toISOString().replace(/\.\d{3}Z$/,"Z")}function Ee(e){if(!Ne.test(e)||!Number.isFinite(Date.parse(e)))throw new Error(`Not a SOQL datetime: "${e}".`);return e}function wn(e,n){let t=e?.trim()?D(e):void 0;if(n===void 0)return t;let r=`SystemModstamp > ${Ee(n)}`;return t?`${r} AND (${t})`:r}function $e(e){if(typeof e!="string"||e==="")return null;let n=Date.parse(e.replace(/([+-]\d{2})(\d{2})$/,"$1:$2"));return Number.isFinite(n)?new Date(n).toISOString():null}function Sn(e,n,t){let r={query:i=>e.query(i),queryMore:i=>e.queryMore(i)},o={query:i=>e.query(i,{scanAll:!0}),queryMore:i=>e.queryMore(i)},s=()=>{if(t?.aborted)throw new Error("The run was cancelled.")};return{async latestModstamp(i){let d=k(i),g=(await e.query(`SELECT SystemModstamp FROM ${d} ORDER BY SystemModstamp DESC LIMIT 1`)).records[0];if(!g)return null;let f=$e(g.SystemModstamp);if(f===null)throw new Error(`${d} answered a SystemModstamp that is not a date.`);return f},async deletedRows(i,d,u){let g=k(i),f=new Set(["Id","SystemModstamp",...d.map(_)]),{records:y,truncated:m}=await F(o,`SELECT ${[...f].join(", ")} FROM ${g} WHERE IsDeleted = true AND (${D(u)})`);return{records:y,truncated:m}},async heldInSource(i,d,u){let g=k(i),f=_(d),y=new Set;for(let m of N(u)){s();let{records:l}=await F(r,`SELECT ${f} FROM ${g} WHERE ${f} IN (${m.map(x).join(", ")})`);for(let c of l){let p=w(c[f]);p!==null&&y.add(p)}}return y},async targetIdsByKey(i,d,u){let g=k(i),f=_(d),y=f==="Id"?"Id":`Id, ${f}`,m=new Map;for(let l of N(u)){s();let{records:c}=await F(n,`SELECT ${y} FROM ${g} WHERE ${f} IN (${l.map(x).join(", ")})`);for(let p of c){let a=w(p[f]);a===null||typeof p.Id!="string"||m.set(a,[...m.get(a)??[],p.Id])}}return m}}}var Ae=new Set(["direct","rename","transform"]);function kn(e){let n=e.objectApiName;if(e.operation==="insert"||e.operation==="delete")return{refused:`${n} is written by ${e.operation}, which finds no record by a key: a deleted source record cannot be tied to a target record.`};if(e.operation==="update")return{sourceField:"Id",keyField:"Id"};let t=q(e.externalIdField)??"Id";if((e.addOnFields??[]).some(s=>s.fieldApiName===t))return{refused:`${n}: an add-on writes ${t}, the key the upsert matches on, so it ties no deleted source record to one target record.`};let r=e.fieldMappings??[],o=r.find(s=>s.targetField.toLowerCase()===t.toLowerCase());return!o&&!X(r,e.excludedFields??[]).has(t.toLowerCase())?{sourceField:t,keyField:t}:!o||!Ae.has(o.type)?{refused:`${n}: no source field is carried onto ${t}, the key the upsert matches on, so no deleted source record can be tied to a target record.`}:{sourceField:o.sourceField,keyField:t}}async function Rn(e,n,t,r,o){let s=n.objectApiName,{records:i,truncated:d}=await e.deletedRows(s,[t.sourceField],r),u={ids:[],read:i.length,stillInSource:0,ambiguous:0,noKey:0,truncated:d};if(i.length===0)return u;let g=[];for(let c of i){let p=c[t.sourceField],a=o(c);if(w(p)===null||w(a)===null){u.noKey++;continue}g.push({raw:p,key:a})}if(g.length===0)return u;let f=t.sourceField==="Id"?new Set:await e.heldInSource(s,t.sourceField,g.map(c=>c.raw)),y=g.filter(c=>f.has(w(c.raw))?(u.stillInSource++,!1):!0);if(y.length===0)return u;let m=await e.targetIdsByKey(s,t.keyField,y.map(c=>c.key)),l=new Set;for(let c of y){let p=m.get(w(c.key))??[];p.length>1?u.ambiguous++:p.length===1&&!l.has(p[0])&&(l.add(p[0]),u.ids.push(p[0]))}return u}function _n(e,n){let t=[];return e.stillInSource>0&&t.push(`${e.stillInSource} record(s) deleted in the source share their ${n} with a record the source still holds: their target record was kept.`),e.ambiguous>0&&t.push(`${e.ambiguous} record(s) deleted in the source match more than one target record on ${n}: none of those target records was deleted.`),e.noKey>0&&t.push(`${e.noKey} record(s) deleted in the source carry no ${n}: no target record is tied to them.`),e.truncated&&t.push("The source's deleted records were read up to a bound: the rest are read by the next run, from the same watermark."),t}function Fn(e,n,t,r,o=0){return{read:e.read,...e.read==="delta"?{since:e.since}:{reason:e.reason},changed:n,deletionsChecked:t!==void 0,deleted:t?.deleted??0,deleteFailed:t?.deleteFailed??0,...t?.error!==void 0?{deletionError:t.error}:{},...r!==void 0?{recorded:r}:{},...o>0?{lookupsOwed:o}:{}}}export{Pe as a,Me as b,je as c,ie as d,T as e,de as f,le as g,Ve as h,ge as i,te as j,Ue as k,Qe as l,We as m,re as n,w as o,nn as p,tn as q,Re as r,rn as s,on as t,sn as u,Ie as v,mn as w,yn as x,hn as y,bn as z,Ee as A,wn as B,$e as C,Sn as D,kn as E,Rn as F,_n as G,Fn as H};
|