sandforge 1.79.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-BN7A4GRQ.mjs → chunk-2IB7I3IQ.mjs} +1 -1
- package/lib/{chunk-PBI4BYWW.mjs → chunk-2NAIUKVL.mjs} +1 -1
- package/lib/chunk-2OIRJEYE.mjs +7 -0
- package/lib/{chunk-FOVVHGEP.mjs → chunk-2OZG6GRW.mjs} +1 -1
- package/lib/{chunk-5CD257T7.mjs → chunk-2Z54GB6X.mjs} +1 -1
- package/lib/chunk-2ZMGVBLW.mjs +7 -0
- package/lib/{chunk-4NAHW2D3.mjs → chunk-33ZX3A56.mjs} +1 -1
- package/lib/{chunk-4SNDMJP2.mjs → chunk-3AOKLIVE.mjs} +1 -1
- package/lib/{chunk-SIOZXPFG.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-GNC27UEU.mjs → chunk-5UT2ZBGF.mjs} +1 -1
- package/lib/chunk-5VQNKDFU.mjs +7 -0
- package/lib/chunk-5WGA5CZB.mjs +7 -0
- package/lib/chunk-5ZKCLBTN.mjs +474 -0
- package/lib/chunk-67CC7RAE.mjs +7 -0
- package/lib/{chunk-5O6JOMHS.mjs → chunk-6CDIIFNX.mjs} +1 -1
- package/lib/{chunk-AV5SWEHP.mjs → chunk-6FARZYMJ.mjs} +1 -1
- package/lib/{chunk-7UQD6V6F.mjs → chunk-6FMLW7PH.mjs} +1 -1
- package/lib/chunk-6IGEASOF.mjs +7 -0
- package/lib/{chunk-H2PJNIYJ.mjs → chunk-6NADW3OI.mjs} +1 -1
- package/lib/chunk-6SEDOIO3.mjs +10 -0
- package/lib/{chunk-AUTM6H6Z.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-HV2MXMGI.mjs → chunk-AJPSGVMD.mjs} +1 -1
- package/lib/{chunk-OTWRDD6L.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-XBG5SP6Q.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-BILZ3SSR.mjs → chunk-D7P7DTWL.mjs} +1 -1
- package/lib/chunk-DHGPDSXS.mjs +7 -0
- package/lib/{chunk-ZXH4MBWP.mjs → chunk-DHIW4IO5.mjs} +1 -1
- package/lib/{chunk-NM4MDLK4.mjs → chunk-DMBR24CK.mjs} +1 -1
- package/lib/chunk-DPYTG6DM.mjs +48 -0
- package/lib/chunk-DQR5NDMI.mjs +7 -0
- package/lib/chunk-DXOXLUZA.mjs +7 -0
- package/lib/chunk-E2OBAWSH.mjs +7 -0
- package/lib/chunk-E2YJVSX6.mjs +10 -0
- package/lib/chunk-EAFLDSQ2.mjs +7 -0
- package/lib/{chunk-HCIDVIOW.mjs → chunk-EH5YUA5W.mjs} +1 -1
- package/lib/{chunk-2BVTCNWA.mjs → chunk-EOSEMFPU.mjs} +1 -1
- package/lib/chunk-ETT5GP4P.mjs +13 -0
- package/lib/{chunk-3SRXFZSD.mjs → chunk-FDGFUEK3.mjs} +1 -1
- package/lib/{chunk-3DCUADVK.mjs → chunk-FLNLG43R.mjs} +1 -1
- package/lib/{chunk-HTJ5OGP5.mjs → chunk-FSDO4DJA.mjs} +1 -1
- package/lib/{chunk-HJKM3E56.mjs → chunk-FSZTXLNW.mjs} +1 -1
- package/lib/chunk-FTA5LOVX.mjs +7 -0
- package/lib/chunk-G4VXPS3A.mjs +7 -0
- package/lib/chunk-GF247DA7.mjs +7 -0
- package/lib/{chunk-QRV2OSIS.mjs → chunk-GK7VEYFM.mjs} +1 -1
- package/lib/{chunk-5MMXFWPD.mjs → chunk-GR3NGDVM.mjs} +1 -1
- package/lib/{chunk-P7GSGFJO.mjs → chunk-GTIXJCGS.mjs} +1 -1
- package/lib/{chunk-342FN7AO.mjs → chunk-GWRKS3AL.mjs} +1 -1
- package/lib/{chunk-LQ4DRFUH.mjs → chunk-GYKNCYES.mjs} +1 -1
- package/lib/{chunk-WIO4XO4F.mjs → chunk-HFSBDM7B.mjs} +1 -1
- package/lib/chunk-HVC5CYIB.mjs +7 -0
- package/lib/{chunk-EQF2IJS2.mjs → chunk-HYBH5PFM.mjs} +1 -1
- package/lib/chunk-HYOOJVR6.mjs +7 -0
- package/lib/{chunk-TQX3PURV.mjs → chunk-IBURU7T7.mjs} +1 -1
- package/lib/chunk-ICIYL45C.mjs +7 -0
- package/lib/{chunk-K22PA4XL.mjs → chunk-IKGHRYCN.mjs} +1 -1
- package/lib/chunk-IM2XA6JI.mjs +7 -0
- package/lib/{chunk-P2PJYWGQ.mjs → chunk-J6G23RUI.mjs} +1 -1
- package/lib/{chunk-JVL444U5.mjs → chunk-JU2XEKEO.mjs} +1 -1
- package/lib/{chunk-H45UXY6G.mjs → chunk-K55LH4ZQ.mjs} +1 -1
- package/lib/chunk-K5HV4YRO.mjs +7 -0
- package/lib/{chunk-IAZB4WIL.mjs → chunk-K77NR3UK.mjs} +1 -1
- package/lib/chunk-KE2PGD6C.mjs +7 -0
- package/lib/chunk-KGYXLSQ5.mjs +37 -0
- package/lib/{chunk-TEOLMRDO.mjs → chunk-KNIRA333.mjs} +1 -1
- package/lib/chunk-KOQV4WXC.mjs +8 -0
- package/lib/{chunk-PNCONNFJ.mjs → chunk-KRNFVAGC.mjs} +1 -1
- package/lib/chunk-L5FGY6YA.mjs +7 -0
- package/lib/{chunk-MTMH6H2A.mjs → chunk-LCDPCUXS.mjs} +1 -1
- package/lib/{chunk-YAZO75G2.mjs → chunk-LNXBCE7E.mjs} +1 -1
- package/lib/{chunk-ZOVSMN5C.mjs → chunk-LO527YLT.mjs} +1 -1
- package/lib/chunk-MAHZMPMZ.mjs +7 -0
- package/lib/{chunk-QQZZMKU3.mjs → chunk-MHW6DV6T.mjs} +1 -1
- package/lib/{chunk-2YIV2OB2.mjs → chunk-MIDBQ7SD.mjs} +1 -1
- package/lib/{chunk-6EBMEGZB.mjs → chunk-MKNAZPOT.mjs} +1 -1
- package/lib/{chunk-NTDN2JQZ.mjs → chunk-MNITSYI2.mjs} +8 -8
- package/lib/chunk-MO3N5XVV.mjs +341 -0
- package/lib/{chunk-SBIMVCXT.mjs → chunk-MS4FJDFD.mjs} +9 -9
- 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-PUOX4NBJ.mjs → chunk-NWVVCZUK.mjs} +1 -1
- package/lib/{chunk-DLDX6RRC.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-NZ5ZZLKS.mjs → chunk-ONMBSACW.mjs} +1 -1
- package/lib/chunk-OQQHNYR7.mjs +272 -0
- package/lib/{chunk-AAVJ5XVX.mjs → chunk-OU5W7SCB.mjs} +1 -1
- package/lib/{chunk-RSYICMZG.mjs → chunk-OVOLG3AL.mjs} +1 -1
- package/lib/{chunk-F74IHMGL.mjs → chunk-OXKZ4Y3B.mjs} +1 -1
- package/lib/{chunk-W7KFAY55.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-RACDTRZA.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-PZTSVQSF.mjs → chunk-QXLZINZB.mjs} +1 -1
- package/lib/chunk-R2BJWO5N.mjs +20 -0
- package/lib/chunk-R6TF26V4.mjs +10 -0
- package/lib/{chunk-P42X3B4D.mjs → chunk-RKALOKAU.mjs} +1 -1
- package/lib/chunk-SQGP46QS.mjs +7 -0
- package/lib/chunk-SU65Z2BA.mjs +7 -0
- package/lib/chunk-SW2NUKQL.mjs +9 -0
- package/lib/chunk-T26C576X.mjs +9 -0
- package/lib/{chunk-3OHPD72J.mjs → chunk-T3PLRQ2T.mjs} +1 -1
- package/lib/chunk-T5VAULLQ.mjs +7 -0
- package/lib/chunk-TEIBWMJM.mjs +7 -0
- package/lib/chunk-TKQQVB2D.mjs +9 -0
- package/lib/{chunk-RAAANPPG.mjs → chunk-TPHXRHOA.mjs} +1 -1
- package/lib/chunk-TQ2TQHTT.mjs +9 -0
- package/lib/{chunk-IEYG5ATY.mjs → chunk-TQM2XJ27.mjs} +1 -1
- package/lib/{chunk-X65MT4W3.mjs → chunk-UCHAZ4ZU.mjs} +1 -1
- package/lib/chunk-UIUPPEFB.mjs +7 -0
- package/lib/{chunk-QPF6C5MX.mjs → chunk-UT27HXE7.mjs} +1 -1
- package/lib/{chunk-J7HVXMSW.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-3CA767QB.mjs → chunk-WEZLXE34.mjs} +1 -1
- package/lib/{chunk-WFEB5X4U.mjs → chunk-WI4HYWV6.mjs} +1 -1
- package/lib/{chunk-AR7BE5O2.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-ZJKCWBRJ.mjs → chunk-X2ZVSQ54.mjs} +1 -1
- package/lib/{chunk-SFURUNJM.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-RFEO2KAN.mjs → chunk-Y5ZCPY36.mjs} +1 -1
- package/lib/{chunk-TBZMC2VV.mjs → chunk-YCSFP6ER.mjs} +4 -4
- package/lib/{chunk-YBU4Z4QV.mjs → chunk-YHIOS2PU.mjs} +1 -1
- package/lib/chunk-YIGFYZQY.mjs +7 -0
- package/lib/chunk-YJEXE6HZ.mjs +925 -0
- package/lib/{chunk-57VHUYNG.mjs → chunk-YOGMP72T.mjs} +4 -4
- package/lib/chunk-ZRUDYB7O.mjs +7 -0
- package/lib/{chunk-55HEMHEG.mjs → chunk-ZUA5BNAO.mjs} +1 -1
- package/lib/chunk-ZWCRWF7E.mjs +7 -0
- package/lib/{chunk-VHI54FBK.mjs → chunk-ZWZXQTAK.mjs} +53 -53
- package/lib/sandforge-autopilot.mjs +29 -24
- package/lib/sandforge-backup.mjs +67 -32
- package/lib/sandforge-checkpoint.mjs +1 -347
- package/lib/sandforge-cleanup.mjs +14 -10
- package/lib/sandforge-clone.mjs +1 -1
- package/lib/sandforge-compare.mjs +9 -8
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +15 -15
- package/lib/sandforge-env.mjs +101 -101
- package/lib/sandforge-frozen.mjs +1 -257
- package/lib/sandforge-mcp.mjs +33 -14
- package/lib/sandforge-monitor.mjs +7 -7
- 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-2S5OMIIA.mjs +0 -7
- package/lib/chunk-36U7IQ6Y.mjs +0 -25
- package/lib/chunk-3F5YMM2F.mjs +0 -7
- package/lib/chunk-3RYLICRX.mjs +0 -7
- package/lib/chunk-42RER7V4.mjs +0 -14
- package/lib/chunk-4GL773D5.mjs +0 -7
- package/lib/chunk-4HFRHFGQ.mjs +0 -7
- package/lib/chunk-4U6NXJNL.mjs +0 -7
- package/lib/chunk-4XZ5YT5O.mjs +0 -7
- package/lib/chunk-5AJRHRXA.mjs +0 -20
- package/lib/chunk-5HMAPZBV.mjs +0 -7
- package/lib/chunk-5P4PHJRL.mjs +0 -9
- package/lib/chunk-5QKTYCWE.mjs +0 -11
- package/lib/chunk-6LAXTAVN.mjs +0 -7
- package/lib/chunk-6MUEPV7M.mjs +0 -9
- package/lib/chunk-6QSM2WIH.mjs +0 -10
- package/lib/chunk-75ADZS6B.mjs +0 -7
- package/lib/chunk-ALJVEUUS.mjs +0 -7
- package/lib/chunk-ALUFROGA.mjs +0 -7
- package/lib/chunk-B45CNPUX.mjs +0 -47
- package/lib/chunk-BS5T3MOQ.mjs +0 -7
- package/lib/chunk-CGWXQX75.mjs +0 -7
- package/lib/chunk-D3QRXG63.mjs +0 -787
- package/lib/chunk-EEVVGGM6.mjs +0 -7
- package/lib/chunk-ENLBYECD.mjs +0 -7
- package/lib/chunk-EQOQASDQ.mjs +0 -7
- package/lib/chunk-FQBRBBY4.mjs +0 -7
- package/lib/chunk-GAM726CK.mjs +0 -7
- package/lib/chunk-HJC7AIBK.mjs +0 -7
- package/lib/chunk-HUMEKZT5.mjs +0 -8
- package/lib/chunk-I3JKJTLO.mjs +0 -110
- package/lib/chunk-I7O6C2B5.mjs +0 -8
- package/lib/chunk-KLX67VPL.mjs +0 -7
- package/lib/chunk-L776PUMV.mjs +0 -7
- package/lib/chunk-LRFAIUN7.mjs +0 -7
- package/lib/chunk-LV6G4XTK.mjs +0 -7
- package/lib/chunk-MYTIL2JD.mjs +0 -10
- package/lib/chunk-NEVXIGR6.mjs +0 -10
- package/lib/chunk-NGSMZZDA.mjs +0 -7
- package/lib/chunk-NHWE66K5.mjs +0 -7
- package/lib/chunk-OQOZAPCI.mjs +0 -7
- package/lib/chunk-PA3MKJVH.mjs +0 -7
- package/lib/chunk-QROPNEGY.mjs +0 -14
- package/lib/chunk-QWT2C74M.mjs +0 -7
- package/lib/chunk-RH3N2H7P.mjs +0 -7
- package/lib/chunk-SRQDABQ2.mjs +0 -15
- package/lib/chunk-SVS6UMDU.mjs +0 -323
- package/lib/chunk-TNXUU6W7.mjs +0 -14
- package/lib/chunk-VGW4MXXZ.mjs +0 -7
- package/lib/chunk-VXHDBYMI.mjs +0 -7
- package/lib/chunk-WJY54JO7.mjs +0 -13
- package/lib/chunk-WRU5FJFC.mjs +0 -7
- package/lib/chunk-X2PY6MWZ.mjs +0 -7
- package/lib/chunk-XEFDB2R4.mjs +0 -7
- package/lib/chunk-XETCPL7E.mjs +0 -7
- package/lib/chunk-Y5CGXLUB.mjs +0 -7
- package/lib/chunk-Y6J6QFI2.mjs +0 -7
- package/lib/chunk-YMJVMFPY.mjs +0 -7
- package/lib/chunk-YPSRZRIT.mjs +0 -7
- package/lib/chunk-YS4G22C2.mjs +0 -7
- package/lib/chunk-YW2SBL4Z.mjs +0 -7
- package/lib/chunk-Z7X534S4.mjs +0 -10
- package/lib/chunk-ZE6HKRR4.mjs +0 -9
- package/lib/chunk-ZLZRU6MO.mjs +0 -7
- package/lib/chunk-ZPYJPGDK.mjs +0 -7
- package/lib/chunk-ZQOZ4EFW.mjs +0 -7
- package/lib/chunk-ZUTYVST5.mjs +0 -7
- package/lib/chunk-ZYEE34WO.mjs +0 -7
package/lib/chunk-Y5CGXLUB.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 je,b as xe,c as Pe,d as _e,e as _,f as $e,g as Me,h as J,i as re}from"./chunk-3F5YMM2F.mjs";import{a as Oe}from"./chunk-YYZL7UGV.mjs";import{a as we,f as ke,i as ve,j as Ie,l as ne}from"./chunk-SAR5622P.mjs";import{a as E}from"./chunk-4TLYUZD5.mjs";import{c as Le}from"./chunk-HF6LAK3G.mjs";import{a as P,b as Fe,d as Ce,e as We,f as te,h as Ne,i as Ee,j as Se}from"./chunk-PNCONNFJ.mjs";import{X as fe,Y as he,Z as pe,a as Q,aa as ge,ba as me,d as Z,ea as ye,ga as Re,ha as be}from"./chunk-CGWXQX75.mjs";import{d as Ae,e as ee,f as Te,k as Be}from"./chunk-SIOZXPFG.mjs";import{b as I}from"./chunk-CA5NAXSU.mjs";import{Ob as ue,nc as ce,tb as X}from"./chunk-B45CNPUX.mjs";var q=class{config;constructor(e){this.config={maxRetries:e?.maxRetries??3,initialDelay:e?.initialDelay??1e3,maxDelay:e?.maxDelay??3e4,backoffMultiplier:e?.backoffMultiplier??2,jitter:e?.jitter??!0}}calculateDelay(e){let t=this.config.initialDelay*Math.pow(this.config.backoffMultiplier,e),n=Math.min(t,this.config.maxDelay);if(!this.config.jitter)return n;let s=n/2;return Math.floor(s+Math.random()*s)}async execute(e){let t,n=0;for(let s=0;s<=this.config.maxRetries;s++)try{return{success:!0,result:await e(),attempts:s+1,totalDelay:n}}catch(r){if(t=r instanceof Error?r:new Error(String(r)),s<this.config.maxRetries){let o=this.calculateDelay(s);n+=o,await new Promise(i=>setTimeout(i,o))}}return{success:!1,error:t,attempts:this.config.maxRetries+1,totalDelay:n}}shouldRetry(e){return e<this.config.maxRetries}getConfig(){return{...this.config}}};function Ye(a){return Array.isArray(a)?a.length:(a.successfulResults?.length??0)+(a.failedResults?.length??0)}function De(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(Ee,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=We(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 m=await d(1,()=>R.check());return r={state:m.state,message:m.errorMessage??void 0},m},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,H=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 _t(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=>$(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>H)return c({requests:0,untouched:{reason:`${l.length} rows, ${w} bytes of CSV: past what one job takes (${M} rows, ${H} bytes)`}});let R=(k,A,h,v)=>{let B={requests:k.requests,...k.jobId?{jobId:k.jobId}:{}};if(k.info.state!=="JobComplete"&&k.processed===0&&v===0)return c({...B,untouched:se(te(k.info)??"job not complete")});let N=new Map(A.map(y=>[y.recordIndex,y])),f=u.map(y=>$(y==="twin"?"twin":"unprocessed"));return d.forEach((y,S)=>{let W=tt(N.get(S),v>0);u[y]=W.state,f[y]=W.answer}),{answers:f,rows:u,unmatchedIds:[...h],...B}},m=De(a),b,T=()=>b?{jobId:b}:{},F=r.pollDelay??Se,g;try{g=await new Ne().executeBulk({connection:m.connection,bulkManager:e,pollIntervalMs:F,...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(!m.closeSent())return c({requests:m.requests(),...T(),untouched:se(A)});if(b===void 0)throw new L("",A,m.requests(),[...i]);let h=await et(m.connection,b,F);if(h.state==="never-closed")return c({requests:m.requests(),jobId:b,untouched:se(A)});if(h.state!=="ended")throw new L(b,h.state==="unread"?h.reason:"still running",m.requests(),[...i]);let v=Ce(h.results,p,te(h.info));return R({info:h.info,processed:m.processed(),requests:m.requests(),jobId:b},v.outcomes,v.unattributedSuccessIds,v.unattributedSuccesses)}if(g.aborted)return c({requests:m.requests(),...T(),aborted:!0});let C=m.last();return R({info:{state:C.state??"JobComplete",...C.message?{errorMessage:C.message}:{}},processed:m.processed(),requests:m.requests(),...T()},g.outcomes,g.unmatchedIds??[],g.unmatchedWrites??0)}async function et(a,e,t){let n=await ne(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 ne(a,e,{openGraceMs:0})}return n}function se(a){return Qe.test(a)?{reason:a,unsupported:!0}:{reason:a}}function $(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:$(s)}}if(a.state==="unprocessed")return{state:"unprocessed",answer:$("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:$("may-have-written")};let t=a.error??"Unknown error",n=Ae(t);return{state:"answered",answer:n?{id:"",success:!1,errors:[Te(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 de={rest:200,bulk:1e4},Ue=3,ot=3,Ke="UNABLE_TO_LOCK_ROW",Je=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,de[n]);return{api:n,batchSize:s,batchCount:Math.ceil(e/s),clamped:s<a.batchSize}}function G(a){return a.refusals.flatMap(e=>e.leftOut)}function oe(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 ie(a){return a.refusals.length===0?a.payload:J(a.payload,G(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 V(a){return{objectApiName:a.objectApiName,op:a.upsertField?"upsert":"insert"}}function Ve(a){return a!==void 0&&!a.success?ce(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 z={"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(z).filter(o=>o!=="inactive-owner"&&e.has(o)).map(o=>z[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??`${z["validation-rule"]} of the target`;let r=`${z["inactive-owner"]},`;return s===void 0?r:`${s} or ${r}`}function ae(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 e.length>0&&e.length===a.errors.length?e.every(t=>t.statusCode===Ke):a.errors.length>0&&a.errors.every(t=>t.startsWith(Ke))}function Y(a){return a.map(e=>e.field).join(", ")}function mt(a,e){return`Sent again without ${Y(a)} after the first refusal: ${e.join("; ")}`}var yt=["first","second","third"];function D(a){return a.map(({leftOut:e,errors:t},n)=>n===0?mt(e,t):`Sent again without ${Y(e)} too after the ${yt[n]} refusal: `+t.join("; "))}function U(a){let e=(t,n)=>t.length===0?[]:[`Sent without ${Y(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 Bt(){return{successCount:0,updatedCount:0,linkedExistingCount:0,failureCount:0,alreadyExistsCount:0,unidentifiedExistingCount:0,errorSamples:[],pendingFkUpdates:[]}}var Ge=class{constructor(e,t,n=at,s=we()){this.deps=e;this.wait=n;this.splitting=s;this.batchStrategy=t??new Le}deps;wait;splitting;batchStrategy;refusedValues=new Map;refusedOwners=new Map;backoff=new q({initialDelay:it});async writeNode(e,t=Bt()){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 B=e.cleanedRecords[h]?.source,N=B?.Id;if(typeof N!="string")continue;i.addExisting(N,v,n.objectApiName);let f=B?.ContactId;n.objectApiName===Q&&typeof f=="string"&&i.isCreated(f)&&(t.withTheirRecord=[...t.withTheirRecord??[],N])}t.linkedExistingCount+=d.size;let l=await this.giveFlagsBack(n.objectApiName,o,e,d);l&&(t.flagsNotKept=ge(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:m,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 ${de[w]}) \u2014 using ${R} per call (${m} batch(es)).`),w==="bulk"){let h=It(s,r,u);if(h){let v={records:u,cleanedRecords:c};u=h.map(B=>v.records[B]),c=h.map(B=>v.cleanedRecords[B])}}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 ${m} batch(es)...`});let T=0,F=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:F,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<m;h++){let v=u.slice(h*R,(h+1)*R).map((y,S)=>{let{sent:W,before:x}=this.withoutRefusedValues(g,y);return{payload:W,built:c[T+S],before:x,refusals:[],lockResends:0}}),B=`${n.objectApiName} batch ${h+1}/${m}`,N;try{N=await this.sendRows(g,e,v,B,u.length-T-v.length)}catch(y){throw k(y),y}if(N){let y=I(N.thrown);this.leaveLockedAsFailed(g,g.locked.splice(0),y),this.leaveRefusedAsFailed(g,g.refusedOnTheirFields.splice(0),y);break}T+=v.length;let f;try{f=await this.sendLockedAgain(g,e,u.length-T)}catch(y){throw k(y),y}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)/m*100),message:`batch ${h+1}/${m} \u2014 ${Math.min((h+1)*R,u.length)}/${u.length} records`})}try{await this.writeAgainWithoutTheirFields(g,e,Math.min(R,de.rest))}catch(h){throw k(h),h}let A=Z[n.objectApiName];if(A&&C.length>0){let h,v;try{h=await this.recordsByNaturalKey(o,n.objectApiName,A,C.map(B=>B.payload))}catch(B){h=[],v=`The record the target holds under the same key could not be looked up: ${I(B)}`}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=V(e);if(this.goesSmallerByRest(l))return this.sendJobByRest(e,t,n,s,r,o,i);let u=e.upsertField?"upsert":"insert",c=s.map(ie),p=vt(H,P(u,c,e.upsertField));for(let[w,R]of p){let m=s.slice(w,R),b=s.length-R+o;if(this.goesSmallerByRest(l)){let f;try{f=await this.sendJobByRest(e,t,n,m,r,b,i)}catch(y){throw i?.(s.slice(R),I(y)),y}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),F=e.calls?.sending(e.objectApiName,m.map((f,y)=>({sourceId:oe(f),payload:T[y],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=>{F!==void 0&&e.calls?.opened?.(F,f)}})}catch(f){if(f instanceof L){let y={thrown:f,left:"may-have-written",tries:1},S=new Set(f.twins),W=m.filter((x,le)=>!S.has(le));return this.settleThrown(e,y,W,`${r} (Bulk API job)`,b),this.leaveTwinsUnsent(e,m.length-W.length,r,f),y}g={answers:[],rows:[],unmatchedIds:[],untouched:{reason:I(f)},requests:0}}if(g.aborted){try{await t.waitIfPaused()}catch(f){throw F!==void 0&&e.calls?.answered(F),i?.(s.slice(w),I(f)),f}g={...g,untouched:{reason:"the job was aborted"}}}if(g.untouched){F!==void 0&&e.calls?.answered(F),g.untouched.unsupported&&n.bulkUnsupported.add(e.objectApiName),E.warn(`[forge] ${e.objectApiName}: a Bulk API job of ${O(m.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,m,r,b,i)}catch(y){throw i?.(s.slice(R),I(y)),y}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=[],B=[],N;if(m.forEach((f,y)=>{let S=g.rows[y]??"unprocessed",W=g.answers[y],x=S==="answered"?Ve(W):void 0;S==="may-have-written"?B.push(f):x!==void 0&&W!==void 0?(N??=x,h.push(f),v.push(W)):!W||kt(S,W)?A.push(f):(C.push(f),k.push(W))}),this.settleMayHaveBeenWritten(e,B,r,g.jobId),await this.settleAnswers(e,C,F===void 0?{answers:k}:{answers:k,callId:F}),A.length>0){let f;try{f=await this.sendByRest(e,t,A,`${r}, by REST`,h.length+b,i)}catch(y){throw i?.([...h,...s.slice(R)],I(y)),y}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,...N?{cause:N}:{}}})}catch(y){throw i?.(s.slice(R),I(y)),y}if(f)return f}}}async sendJobByRest(e,t,n,s,r,o,i){let d=V(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),m=s.slice(R.length);if(R.length>0){let b;try{b=await this.sendByRest(e,t,R,r,m.length+o,i,{pricedAs:"job",paid:{calls:w}})}catch(T){throw i?.(m,I(T)),T}finally{w<p&&l.spend(d)}if(b)return b}else w<p&&l.spend(d);if(m.length!==0)return m.length>=2e3?this.writeAsJobs(e,t,n,m,r,o,i):this.sendByRest(e,t,m,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(oe).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(ie);for(let r=0;;r++){let o=e.calls?.sending(e.objectApiName,n.map((i,d)=>({sourceId:oe(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=Oe(i);if(o!==void 0&&d!=="may-have-written"&&e.calls?.answered(o),d!=="not-received"||r===Ue)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}/${Ue}).`),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 Ie(n,{key:V(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})`,...D(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===xe)))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=ie(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 F=[...l,...G(n)];F.length>0&&(r.writtenWithoutFields=re(r.writtenWithoutFields,{rows:1,fields:F.map(g=>({...g,rows:1}))}));for(let{field:g,refusedBy:C}of F)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=Be(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"&&Z[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:!ae(e,u)}),m=n.refusals.length<Je;if(R&&m){e.refusedOnTheirFields.push({...n,refusals:[...n.refusals,{errors:t.errors,leftOut:R}]});return}r.failureCount++,c.kind==="unidentified"&&r.unidentifiedExistingCount++,t.errors.every(b=>X(b))&&r.alreadyExistsCount++,this.sample(r,{recordSummary:j(n.payload),messages:[...t.errors,...D(n.refusals),...p?[`Sent again ${n.lockResends} times, the target still could not lock a record the write needed.`]:[],...R&&!m?[`Not sent again: a row goes again without the fields the target refused ${Je} times at most.`]:[],...Me(t.errorDetails)?[Tt]:[],...s?[ke(s,ve(this.splitting.allowance,V(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===je)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:ee(s)})}}rememberRefusedOwners(e,t,n){let s=_(n,"OwnerId");if(!(s===void 0||s.toLowerCase()===e.upsertField?.toLowerCase())&&!ae(e,n))for(let r of t.errorDetails??[]){if(r.statusCode!==Pe)continue;let o=_e(r,n);o===void 0||this.refusedOwners.has(o)||this.refusedOwners.set(o,{field:"OwnerId",refusedBy:"inactive-owner",reason:ee(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()&&!ae(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:J(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??[],...D(s.refusals.slice(0,-1)),`Not written again without ${Y(G(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,...D(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,...D(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(G))} 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=>X(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?be(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||!pe[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 me(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===Q?ye(r,n):fe[e]!==void 0?he(r,e,n):e===ue?Re(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{q as a,L as b,M as c,_t as d,de as e,dt as f,lt as g,pt as h,mt as i,Bt as j,Ge as k,j as l};
|
package/lib/chunk-Y6J6QFI2.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 b}from"./chunk-RFEO2KAN.mjs";import"./chunk-TBZMC2VV.mjs";import{a}from"./chunk-LQ4DRFUH.mjs";import"./chunk-57VHUYNG.mjs";import"./chunk-5O6JOMHS.mjs";import"./chunk-HUMEKZT5.mjs";import"./chunk-MYTIL2JD.mjs";import"./chunk-JVL444U5.mjs";import"./chunk-KLX67VPL.mjs";import"./chunk-5CD257T7.mjs";import"./chunk-H45UXY6G.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-SRQDABQ2.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LV6G4XTK.mjs";import"./chunk-HJKM3E56.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-YMJVMFPY.mjs";import"./chunk-ALJVEUUS.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-4HFRHFGQ.mjs";import"./chunk-342FN7AO.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-Z7X534S4.mjs";import"./chunk-6QSM2WIH.mjs";import"./chunk-WJY54JO7.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-NEVXIGR6.mjs";import"./chunk-NTDN2JQZ.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-6MUEPV7M.mjs";import"./chunk-HJC7AIBK.mjs";import"./chunk-OTWRDD6L.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-RH3N2H7P.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-55HEMHEG.mjs";import"./chunk-P42X3B4D.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VXHDBYMI.mjs";import"./chunk-ENLBYECD.mjs";import"./chunk-PA3MKJVH.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-ZLZRU6MO.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-PNCONNFJ.mjs";import"./chunk-CGWXQX75.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-SIOZXPFG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-B45CNPUX.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{a as objectsWrittenBy,b as previewCheckpoint};
|
package/lib/chunk-YMJVMFPY.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 ne,c as ae,d as Bo,e as $o,f as me}from"./chunk-ALJVEUUS.mjs";import{a as Mo,e as Uo}from"./chunk-Z7X534S4.mjs";import{J as te,P as Te,a as Do}from"./chunk-6QSM2WIH.mjs";import{f as _e,o as pe,r as Ne,t as Lo,v as De}from"./chunk-NTDN2JQZ.mjs";import{d as To}from"./chunk-6MUEPV7M.mjs";import{E as Fo}from"./chunk-HJC7AIBK.mjs";import{b as le,d as de}from"./chunk-OTWRDD6L.mjs";import{c as No}from"./chunk-PA3MKJVH.mjs";import{c as _o,e as Ee,g as Ce,h as ce}from"./chunk-TZE3Y7IQ.mjs";import{a as Co,b as V}from"./chunk-CA5NAXSU.mjs";import{A as no,E as ao,F as ro,Fa as go,G as io,Ga as bo,H as so,Ha as yo,I as co,Sa as fo,bc as ko,ea as lo,fa as po,hb as ho,jb as zo,ka as oe,kb as So,kc as Oo,la as ke,lc as Ro,m as Xe,mc as wo,nb as xo,ob as Io,oc as vo,pa as F,pb as jo,pc as Ae,qa as mo,r as je,ra as M,rd as Ao,s as Ve,sa as Oe,sd as Eo,t as Je,ta as uo,u as Qe,v as X,va as Re,w as Pe,wa as we,wb as Po,x as eo,xa as ve,y as oo,z as to}from"./chunk-B45CNPUX.mjs";import{b as n,c as xe,e as b,f as r,g as Ke,i as D,k as c,l as o,o as se,p as Ie,s as I,u as A,v as w,w as Ye,x as Ze,y as G}from"./chunk-7EANH5PY.mjs";function Tn(e,t,a){return async l=>{let d=l.map(y=>`${y.objectApiName} (${y.records})`).join(", ");e.log(`[WARN] ${a}: the user may not delete ${d} in the target: those records stay`);let p=e.infraServices?.confirmRemovalLeavingUndeletable;if(!p)return!0;let m=e.orgManager.getOrg(t);return p({org:ko(m,t),objects:l})}}var Go={code:"NOT_INITIALIZED",message:"Production Guard is not initialized \u2014 infrastructure services missing"};function _n(){return Object.assign(new Error(Go.message),{code:Go.code})}var Fe={blocked:"GUARD_BLOCKED",declined:"GUARD_DECLINED"};function Nn(e){return Object.assign(new Error(`Operation blocked by Production Guard: ${e}`),{code:Fe.blocked})}function Dn(e){return e instanceof Error&&e.code===Fe.blocked?Fe.blocked:void 0}function jt(e){return e.robustness??lo}function Fn(e){return e.bulkManager??new Do(jt(e).bulk.maxConcurrentJobs)}var Pt={"sync:schedule":"sync:schedule:","sync:pipeline":"sync:pipeline:","seed:pipeline":"seed:pipeline:","offline-replay":"offline-replay-"};function Mn(e,t,a){return{id:`${Pt[e]}${t}`,type:a,timestamp:Date.now()}}function Un(e,t,a,l){return{id:e.nextId(),type:a,timestamp:Date.now(),correlationId:t.id,payload:l}}function Ln(e,t,a,l,d={}){let p=t==="error"?null:d.autoDismissMs===void 0?5e3:d.autoDismissMs,m={id:e.nextId(),type:"notification",timestamp:Date.now(),payload:{level:t,title:a,message:l,...p===null?{}:{autoDismissMs:p},...d.actions?{actions:d.actions}:{},...d.code?{code:d.code}:{}}};e.broker.postToWebview(m),e.log(`[TX] notification: ${a}`)}function Bn(e,t,a,l){let d={id:e.nextId(),type:"operation:started",timestamp:Date.now(),payload:{operationId:t,module:a,description:l}};e.broker.postToWebview(d)}function $n(e,t,a,l,d,p){let m={id:e.nextId(),type:"operation:progress",timestamp:Date.now(),payload:{operationId:t,percentage:a,processedRecords:l,totalRecords:d,currentStep:p}};e.broker.postToWebview(m)}function Gn(e,t,a){let l={id:e.nextId(),type:"operation:completed",timestamp:Date.now(),payload:{operationId:t,result:a}};e.broker.postToWebview(l)}var kt=Symbol("sandforge.uncorrelated");function Wo(e,t,a,l,d,p={}){let m=V(d),y=d instanceof To?d:void 0,j=kt in l,E=p.code??y?.code??"UNKNOWN";j||wt(e.broker,m,E),e.log(`[ERR] ${t}: ${m}${j?` (uncorrelated: ${String(l.reason)})`:""}`);let O={id:e.nextId(),type:a,timestamp:Date.now(),...j?{}:{correlationId:l.id},payload:{message:m,code:E,retryable:p.retryable??!1,...y?{orgId:y.orgId}:{},...p.extraPayload}};e.broker.postToWebview(O),e.log(`[TX] ${a}: ${m}`)}function Wn(e,t){let a={id:e.nextId(),type:t.type,timestamp:Date.now(),payload:t.payload};e.broker.postToWebview(a)}function qn(e){let t=e?.getSandforgeSetting;if(!(!t||!t("grappe.enabled",!1)))return{enabled:!0,autoActivateThreshold:t("grappe.autoActivateThreshold",1e4),maxWorkers:Xe.maxWorkers,grappeSize:t("grappe.grappeSize",5e3),strategy:"round_robin",backPressure:{enabled:!1,maxQueueDepth:3,highWaterMark:80,lowWaterMark:60,strategy:"pause",monitoringInterval:5e3},checkpointing:!0,isolationLevel:"per_grappe"}}function Hn(e){let t=new Set(e.map(l=>l.batchSize)),[a]=t;return{...e.length>0?{objectName:e.map(l=>l.objectApiName).join(", ")}:{},...t.size===1&&a!==void 0?{batchSize:a}:{}}}function Kn(e,t,a,l,d={}){let p={id:e.nextId(),type:"operation:failed",timestamp:Date.now(),payload:{operationId:t,error:a,retryable:l,...d.extraPayload}};e.broker.postToWebview(p),d.authored!==!0&&At(e,a,d.context)}var Ot=[/^Operation cancelled by user\b/,/^Operation blocked by Production Guard: /,/^Production Guard is not initialized\b/,/^Duplicate operation: /,/^A backup or rollback operation is already running for org /,/^Object describe not available for '/,/^CRUD_FLS_DENIED: /,/^CRUD\/FLS check failed for /,/^No backup found for operation /,/^Backup \S+ was taken from org /,/^Restore not run: /,/^Pipeline failed$/,/^Pipeline did not start: /,/^Pipeline ran out of time: /,/^Org not found: /,/^No credentials for org /,/^Invalid username format: /];function Rt(e){return Ot.some(t=>t.test(e))}var qo=1e4,Me=new WeakMap;function wt(e,t,a){let l=Ae(t,{code:a});if(!l?.actionKey)return;let d=Me.get(e)??new Map,p=Date.now();for(let[m,y]of d)p-y>qo&&d.delete(m);d.set(l.code,p),Me.set(e,d)}function vt(e,t){let a=Me.get(e)?.get(t);return a!==void 0&&Date.now()-a<=qo}function At(e,t,a={}){if(!(e.broker.panelCount>0)||Rt(t))return;let d=Co(t,vo)??"UNKNOWN",p=Ae(t,{code:d});if(p?.actionKey){if(vt(e.broker,p.code))return;e.broker.showFixSuggestion({source:"catalogue",code:p.code,actionKey:p.actionKey});return}let m=e.errorResolver;m&&m.resolveError({errorCode:d,message:t},a).then(y=>{e.broker.showFixSuggestion({source:"model",text:Et(y)})}).catch(y=>{e.log?.(`[ERR] operation:failed resolution: ${V(y)}`)})}function Et(e){return e.suggestions[0]?.description||e.explanation}import{isAbsolute as Dt}from"node:path";var i=n().min(1).max(128),s=n().regex(/^[A-Za-z][A-Za-z0-9_]*$/,"Invalid Salesforce API name").max(80),Vo=c(s).max(300),u=n().min(1).max(200),re=n().max(2e3).refine(Ee,{message:Ce}),Ft=n().refine(_o,{message:"ORDER BY clause must list only field names with optional ASC/DESC and NULLS FIRST/LAST (no LIMIT, OFFSET, FOR UPDATE or subquery)."}),f=100,Jo=1e4,B=o({keepDays:b().int().min(Pe.min).max(Pe.max).optional(),excluded:c(s).max(f).refine(e=>new Set(e).size===e.length,"An object is left out twice").optional()}).strict(),be={sweepLate:r().optional(),sweepUntied:r().optional()};function Mt(e){return No(e)}function Ut(e){return Po(e)?`Sync copies files with the records they hang on, not as an object of their own: "${e}" keeps its content in a file body. Remove it from this configuration and turn on "Copy the files of these records" instead; the sync was not started.`:`Sync does not copy "${e}": no copy writes it \u2014 users and their access, metadata, a record's history, feed or sharing rows, and the records the platform keeps for itself are not data a copy carries. Remove it from this configuration; the sync was not started.`}var Lt=A(ao,{error:e=>e.input==="manual"?"Manual conflict review is not available for a sync run: no run shows its conflicts to anyone before it writes. Pick source wins, target wins, newest wins or merge \u2014 target wins keeps every value the target holds where the two orgs differ. The sync was not started.":`Conflict strategy "${String(e.input)}" is not one a sync run acts on: pick source wins, target wins, newest wins or merge. The sync was not started.`}),Bt=ro.extend({objectApiName:s.refine(e=>!Mt(e),{error:e=>Ut(String(e.input))}),externalIdField:Ze(e=>typeof e=="string"&&e.trim()===""?void 0:e,s.optional()),where:re.optional(),orderBy:Ft.optional(),batchSize:b().int().positive().max(Jo).optional()}).strip().refine(e=>e.operation!=="upsert"||(e.externalIdField??"Id").toLowerCase()!=="id",{path:["externalIdField"],error:e=>`An upsert of "${String(e.input.objectApiName)}" needs an External ID field: matching on Id cannot work, because the id belongs to the source org and the target has never issued it. Name an External ID field both orgs share, or set the operation to insert. The sync was not started.`}).superRefine((e,t)=>{let a=Ro([e]);a.length!==0&&t.addIssue({code:G.custom,message:`${wo(a)} The sync was not started.`,params:{unreadablePatterns:a}})});function Ho(e){return Ke({error:()=>`Sync does not run Apex: remove "${e}" from this configuration. The sync was not started so the script cannot be skipped without you knowing.`}).optional()}var Le=io.extend({id:u.optional(),sourceOrgId:i,targetOrgId:i,objects:c(Bt).min(1).max(f),conflictStrategy:Lt,createdAt:n().max(40).optional(),updatedAt:n().max(40).optional(),preScript:Ho("preScript"),postScript:Ho("postScript"),dryRun:w(!1,{error:()=>'A sync configuration cannot ask for a dry run: remove "dryRun" from it. A run of it writes to the target org; to see what it would write, simulate it from the Sync page. The run was not started, so it cannot write while you believed it was only reporting.'}).optional()}).strip().superRefine((e,t)=>{e.direction==="target_to_source"&&t.addIssue({code:G.custom,path:["direction"],message:'Sync writes source to target only: direction "target_to_source" is not supported. Swap the source and target orgs to copy the other way. The sync was not started, so it cannot write into the org you meant to read from.'}),e.mode!=="full"&&e.mode!=="delta"&&t.addIssue({code:G.custom,path:["mode"],message:`Sync runs a full or a delta sync only: mode "${e.mode}" is not implemented. Set mode to "full" or "delta". The sync was not started, so it cannot replay the whole object set while you believed it was reading changes only.`}),e.mode==="delta"&&e.objects.forEach((a,l)=>{a.operation==="upsert"||a.operation==="update"||t.addIssue({code:G.custom,path:["objects",l,"operation"],message:`A delta sync writes ${a.objectApiName} again for every record it reads twice, and ${a.operation} would ${a.operation==="insert"?"create a second copy":"delete a record already gone"}. Write it by upsert on an External ID, or by update, or run the configuration in full. The sync was not started.`})}),e.propagateDeletes===!0&&(e.mode!=="delta"?t.addIssue({code:G.custom,path:["propagateDeletes"],message:'Deletions are carried by a delta sync only, which knows since when to look for them: set mode to "delta", or turn deletions off. The sync was not started.'}):e.objects.forEach((a,l)=>{if(a.operation!=="upsert"&&a.operation!=="update")return;let d=Fo(a);"refused"in d&&t.addIssue({code:G.custom,path:["objects",l],message:`${d.refused} Turn deletions off, or carry a source field onto the key. The sync was not started.`})}))}),aa=o({suggestedName:n().min(1).max(255).refine(e=>!e.includes("/")&&!e.includes("\\"),"suggestedName must not contain a path"),content:n().max(32*1024*1024),extensions:c(n().regex(/^[A-Za-z0-9]+$/)).max(8).optional()}),ra=o({config:Le,muteAutomation:r().optional(),checkpointFirst:B.optional()}),ia=o({config:Le,checkpointFirst:B.optional()}),sa=o({operationId:u}),ca=o({config:Le}),la=o({id:u}),da=o({orgId:i,targetOrgId:i.optional()}),pa=o({sourceOrgId:i,targetOrgId:i,objectApiName:s}),Qo=A(["source_wins","target_wins","newest_wins","manual","merge"]),$t=Ie("kind",[o({kind:w("id")}),o({kind:w("externalId"),field:s}),o({kind:w("syncConfig"),configId:u})]),ma=o({sourceOrgId:i,targetOrgId:i,watchedObjects:c(s).min(1).max(f),apply:c(o({objectApiName:s,match:$t,applyDeletes:r()})).max(f),conflictStrategy:Qo,flushIntervalMs:b().int().min(50).max(6e4),maxBatchSize:b().int().min(1).max(200),keepContactPoints:r().optional()}).refine(e=>e.apply.every(t=>e.watchedObjects.includes(t.objectApiName)),{message:"Every applied object must be watched.",path:["apply"]}),ua=o({sessionId:n().max(200)}),ga=o({sourceOrgId:i,targetOrgId:i}),ba=o({conflictId:n().min(1).max(500),eventReplayId:b().optional(),resolution:Qo,fieldResolutions:I(n(),o({value:D(),source:A(["source","target","manual"])})).optional()}),ya=o({entryId:u}),fa=o({runId:u}),ha=o({realtime:w(!0).optional()}).optional(),za=o({sourceOrgId:i,targetOrgId:i,objects:c(s).max(f),configId:u.optional()}),Sa=o({runId:u,includeChanged:r().optional(),sweep:r().optional(),again:r().optional(),muteAutomation:r().optional(),...be}),xa=o({runId:u}),Ia=o({runId:u,again:r().optional(),sweptObjects:Vo.optional()}),ja=o({runId:u}),Pa=o({runId:u,includeChanged:r().optional(),sweep:r().optional(),again:r().optional(),muteAutomation:r().optional(),...be}),ka=o({runId:u}),Oa=o({format:A(["csv","json"]),entryIds:c(u).max(500).optional()}),Gt=o({id:u,name:n().min(1).max(200),configId:u,cron:n().min(1).max(100),timezone:n().min(1).max(100),enabled:r(),maxRetries:b().int().min(0).max(10),notifyOnComplete:r(),notifyOnFailure:r(),createdAt:n().max(40),updatedAt:n().max(40),version:b().int().positive()}).strip(),Ra=o({schedule:Gt}),wa=o({scheduleId:u,enabled:r()}),va=o({scheduleId:u}),Wt=eo.extend({objectApiName:s,recordCount:b().int().positive().max(X),batchSize:b().int().positive().max(Jo).optional()}).loose(),qt=oo.extend({childObject:s,lookupField:s,parentObject:s}).superRefine((e,t)=>{e.parents.kind==="existing"&&e.parents.where!==void 0&&!Ee(e.parents.where)&&t.addIssue({code:G.custom,path:["parents","where"],message:Ce})}),Ht=to.extend({objects:c(Wt).min(1).max(f),relations:c(qt).max(f).optional()}).loose().superRefine(no),Aa=o({orgId:i,template:Ht,muteAutomation:r().optional(),checkpointFirst:B.optional(),fit:o({share:b().gt(0).max(1),withinMB:b().positive().max(1e6).optional(),before:b().int().positive().max(X*f)}).strict().optional(),locale:n().regex(/^[a-z]{2,3}(?:_[A-Za-z0-9]{2,4}){0,2}$/).optional(),dryRun:r().optional()}),Ea=o({orgId:i}),Ca=o({orgId:i,objects:c(s).min(1).max(f),publishes:r().optional()}).strict(),Ta=o({orgId:i,objectApiName:s}),_a=o({id:u}),Na=o({template:I(n(),D())}),Da=o({description:n().max(1e4)}),Fa=o({}).strict(),Ma=o({orgId:i,pack:oe,seed:ke.shape.seed,articleBodyField:s.optional()}).strict(),Ua=o({orgId:i,pack:oe,options:ke,locale:n().regex(/^[a-z]{2,3}(?:_[A-Za-z0-9]{2,4}){0,2}$/).optional(),muteAutomation:r().optional(),checkpointFirst:B.optional()}).strict(),La=o({orgId:i}).strict(),Ba=o({pack:oe,overwrite:r().optional()}).strict(),$a=o({runId:u,choice:fo,overwrite:r().optional()}).strict(),Kt=131072,Yt=o({objectApiName:s,whereClause:re.optional()}).loose(),Ga=o({sourceOrgId:i}),Wa=o({sourceOrgId:i,targetOrgId:i,objects:c(Yt).min(1).max(f),upsert:r().optional(),externalIdField:s.optional(),previewId:u.optional(),keepContactPoints:r().optional(),checkpointFirst:B.optional()}).refine(e=>!e.upsert||e.externalIdField!==void 0,{message:"externalIdField is required when upsert is true",path:["externalIdField"]}),Zt=o({csvHeader:n().min(1).max(500),sfFieldApiName:n().max(80),sfFieldType:n().max(40),sfFieldLength:b().int().positive().nullable()}).loose(),qa=o({orgId:i,objectApiName:s,records:c(I(n(),n().max(Kt))).min(1).max(Je),columnMappings:c(Zt).min(1).max(Qe),externalIdField:s.optional(),checkpointFirst:B.optional()}),Ha=o({orgId:i,objects:c(s).min(1).max(f)}),Ka=o({orgId:i}),Ya=o({orgId:i,templateId:n().min(1).max(200).optional()}),Za=o({orgId:i,operationId:n().min(1).max(200)}),Xa=o({orgId:i,operationIds:c(n().min(1).max(200)).min(1).max(1e3).optional()}),W={acceptAutomation:r().optional(),acceptEmails:r().optional(),muteAutomation:r().optional()},Y={fromPage:w(!0).optional()},Va=o({orgId:i,operationId:u,rewriteAll:r().optional(),includeChanged:r().optional(),...W,...Y}),Ja=o({orgId:i,act:A(["masking","restore","cleanup"]),objects:c(o({objectApiName:s,records:b().int().min(0)})).max(f),erasure:r().optional(),...W,...Y}),Be={objects:c(s).min(1).max(f).optional(),where:re.optional()},$e=e=>e.where===void 0||e.where.trim()===""||e.objects?.length===1,Ge={message:"A WHERE clause filters the rows of one object: name exactly one in objects",path:["where"]},Qa=o({orgId:i,templateId:u,...Be,resumeFrom:u.optional(),snapshot:r().optional(),...W,...Y}).refine($e,Ge).refine(e=>!(e.snapshot===!0&&e.resumeFrom!==void 0),{message:"A resume takes no snapshot: the run it resumes has written over some of its rows",path:["snapshot"]}),er=o({orgId:i,templateId:u,...Be}).refine($e,Ge),or=o({orgId:i,templateId:u,...Be}).refine($e,Ge),tr=o({name:n().trim().min(1).max(go),rules:c(yo).min(1).max(bo).refine(e=>new Set(e.map(t=>t.fieldPattern.toLowerCase())).size===e.length,"A field has two rules")}),nr=o({templateId:u}),ar=o({orgId:i,objectNames:c(s).min(1).max(f)}),rr=o({orgId:i,objects:c(o({objectApiName:s,duplicateKey:s.optional()})).min(1).max(10).refine(e=>new Set(e.map(t=>t.objectApiName.toLowerCase())).size===e.length,{message:"Each object may be named once per scan"}),staleDays:b().int().min(1).max(3650)}),et=c(s).min(1).max(10).refine(e=>new Set(e.map(t=>t.toLowerCase())).size===e.length,{message:"Each object may be named once per request"}),ir=o({orgId:i,objects:et}),sr=o({orgId:i,objects:et,requestId:xe().optional(),email:n().trim().refine(Io,"Not an email address").optional(),name:n().refine(jo,"Not a name").optional(),phone:n().refine(xo,"Not a phone number").optional()}).refine(e=>e.email!==void 0||e.name!==void 0||e.phone!==void 0,{message:"A search needs an email address, a name or a phone number"}),Xt=o({orgId:i,requestId:xe()}),We=n().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,"Not a record Id"),cr=o({runId:u,recordId:We}).strict(),lr=Xt.extend({mode:A(["anonymize","delete"]),records:c(o({objectApiName:s,ids:c(We).min(1).max(200)})).min(1).max(10).refine(e=>new Set(e.map(t=>t.objectApiName.toLowerCase())).size===e.length,{message:"Each object may be named once per request"}),dryRun:r(),...W}),Vt=Ie("kind",[o({kind:w("stale"),days:b().int().min(1).max(3650)}),o({kind:w("orphans"),fieldApiName:s}),o({kind:w("duplicates"),keyField:s})]),Jt=o({orgId:i,objectApiName:s,recommendation:Vt}),dr=Jt.extend({dryRun:r(),...W,...Y}),Ue=2e3,ot={mode:A(["objects","org"]),objects:c(s).min(1).max(Ue).optional(),excluded:c(s).max(Ue).optional(),customSettings:r().optional(),files:r().optional(),managedPackages:r().optional(),unrestorable:r().optional()},Qt=o(ot).strict().refine(e=>e.mode==="objects"==(e.objects!==void 0),{message:"The objects picked are named in objects mode, and only there"}),pr=o({orgId:i,...ot,objects:c(s).max(Ue).optional()}).strict().refine(e=>e.mode==="objects"==(e.objects!==void 0),{message:"The objects picked are named in objects mode, and only there"}),mr=o({orgId:i,request:Qt,deleteMode:A(["recycle","hard"]),checkpointFirst:r().optional(),acceptNoUndo:r().optional(),acceptPeopleActive:r().optional(),...W,...Y}),ur=o({orgId:i,previewId:u.optional(),resumeRunId:n().regex(/^em-\d{8}-\d{6}-[a-z0-9]{4}$/).optional(),acceptNoUndo:r().optional(),acceptPeopleActive:r().optional(),checkpointFirst:r().optional(),...W,...Y}).refine(e=>e.previewId===void 0!=(e.resumeRunId===void 0),{message:"An emptying acts on a preview, or takes up a run: one of them"}),gr=o({operationId:u}),br=o({orgId:i,runId:n().regex(/^em-\d{8}-\d{6}-[a-z0-9]{4}$/),...W,...Y}),yr=o({orgId:i}),fr=o({orgId:i}).strict(),hr=o({alertId:u}),tt=o({sourceOrgId:i,targetOrgId:i}),zr=tt.extend({types:c(n().min(1).max(80)).min(1).max(50),includeManaged:r().optional()}),en=o({componentType:A(So),fullName:n().min(1).max(400).regex(/^[^\u0000-\u001f\u007f]+$/,"A component name holds no control character")}),Sr=tt.extend({components:c(en).min(1).max(500).refine(e=>new Set(e.map(t=>`${t.componentType}:${t.fullName}`)).size===e.length,{message:"Each component may be named once per deployment"}),testLevel:A(ho),runTests:c(n().max(255).regex(zo,"Not an Apex class name")).max(100).optional()}).refine(e=>e.sourceOrgId!==e.targetOrgId,{message:"The source and the target are the same org",path:["targetOrgId"]}).refine(e=>e.testLevel!=="RunSpecifiedTests"||(e.runTests?.length??0)>0,{message:"RunSpecifiedTests names at least one test class",path:["runTests"]}),xr=o({validationId:n().regex(/^0Af[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/,"Not a deployment id"),targetOrgId:i}).strict(),on=n().regex(/^\d+\.\d+\.\d+$/,"Invalid semver"),ge=n().regex(/^[A-Za-z][A-Za-z0-9_]*\.[A-Za-z][A-Za-z0-9_]*$/,"Expected an Object.field key").max(170),tn=o({name:n().min(1).max(80),label:n().min(1).max(200),filterField:s,valuesSoql:n().min(1).max(4e3)}),nn=o({name:n().min(1).max(80),label:n().min(1).max(200),whereFragment:re}),Ko=se([o({action:w("clear")}),o({action:w("replace"),value:n().max(255)})]),an=o({rootObject:s,axes:c(tn).max(20),edgeCases:c(nn).max(50),budgetMaxRecords:b().int().positive().max(1e5).optional(),candidatesPerCombination:b().int().positive().max(20).optional(),expectedObjects:c(s).max(100).optional(),maxNodes:b().int().min(10).max(500).optional(),excludedObjects:c(s).max(200).optional(),excludedFields:I(s,c(s).max(500)).optional(),sasDir:n().min(1).max(500).optional(),datasetDir:n().min(1).max(500).optional(),rulesFilePath:n().min(1).max(500).optional(),datasetVersion:on.optional(),protectedOrgIds:c(i).max(50).optional(),identityKeys:I(s,c(s).min(1).max(10)).optional(),undeletableObjects:I(s,s).optional(),requiredLookupPlaceholders:I(ge,o({name:n().min(1).max(200),recordTypeDeveloperName:n().min(1).max(97).optional(),targetObjectApiName:s.optional()})).optional(),requiredFieldDefaults:I(ge,D()).optional(),picklistRules:I(ge,Ko).optional(),defaultPicklistRule:Ko.optional(),duplicateErrorPatterns:c(n().min(1).max(200)).max(50).optional(),mockDetection:o({metadataTypeApiName:s,isMockedFieldApiName:s}).optional(),mandatoryLookups:I(s,c(s).min(1).max(50)).optional(),presenceKeys:I(s,s).optional()}),Ir=o({config:an}),jr=o({sourceOrgId:i}),Pr=o({fields:c(ge).min(1).max(2e3)}),kr=o({sourceOrgId:i,author:n().min(1).max(120).optional()}),Or=o({targetOrgId:i,pilot:r().optional(),reload:r().optional(),writeEncrypted:r().optional(),maxRecords:b().int().positive().max(1e6).optional(),muteAutomation:r().optional(),checkpointFirst:B.optional(),sweep:r().optional(),...be,includeChanged:r().optional(),acceptEmails:r().optional(),acceptAutomation:r().optional(),goneFirst:c(We).max(1e6).optional()}),Rr=o({targetOrgId:i}),wr=o({targetOrgId:i,loadedAt:n().min(1).max(64),includeChanged:r().optional(),sweep:r().optional(),...be,muteAutomation:r().optional()}),vr=o({targetOrgId:i,loadedAt:n().min(1).max(64),reload:r().optional()}),Ar=o({targetOrgId:i,loadedAt:n().min(1).max(64),sweptObjects:Vo.optional(),reload:r().optional()}),Er=o({targetOrgId:i,loadedAt:n().min(1).max(64),includeChanged:r().optional()}),nt=1e3,at=3650,rn=200,K=c(s).min(1).max(nt).refine(e=>new Set(e).size===e.length,"An object is named twice");function rt(e){return e.mode==="picked"?e.objects!==void 0:e.objects===void 0}var it=se([w("all"),c(s.refine(e=>e.toLowerCase().endsWith("__c"),"A custom setting's API name ends in __c")).min(1).max(nt).refine(e=>new Set(e.map(t=>t.toLowerCase())).size===e.length,"A custom setting is named twice")]),st={path:["objects"],message:'Name the objects with "picked", and none with "everything"'},Cr=o({orgId:i.optional()}).optional(),ct=b().int().min(1),Tr=o({orgId:i,mode:ve,objects:K.optional(),excluded:K.optional(),customSettings:it.optional(),maxTotal:ct.optional()}).refine(rt,st),_r=o({orgId:i,name:we,mode:ve,objects:K.optional(),excluded:K.optional(),customSettings:it.optional(),maxTotal:ct.optional(),keepDays:b().int().min(0).max(at),ignoredFields:Re.optional()}).refine(rt,st),Nr=o({checkpointId:M,objects:K.optional(),muteAutomation:r().optional(),acceptOutside:r().optional()}),Dr=o({checkpointId:M,previewId:Oe,objects:K.optional(),acceptAutomation:r(),muteAutomation:r().optional(),acceptEmails:r().optional(),acceptNoUndo:r(),acceptRecreate:r(),acceptOutside:r(),acceptUnseen:r(),fromPage:w(!0).optional()}),Fr=o({checkpointId:M,previewId:Oe,objects:K,acceptOutside:r()}),Mr=o({checkpointId:M}),sn=200,Ur=o({token:u,orgId:i,key:n().min(1).max(sn),keepDays:b().int().min(0).max(at)}),Lr=o({checkpointId:M,rewindId:uo,acceptAutomation:r(),muteAutomation:r().optional(),acceptEmails:r().optional(),fromPage:w(!0).optional()}),Br=o({checkpointIds:c(M).min(1).max(rn).refine(e=>new Set(e).size===e.length,"A checkpoint is named twice")}),$r=o({checkpointId:M,keep:r()}),Gr=o({checkpointId:M,name:we}),Wr=o({checkpointId:M,fields:Re}),cn=500,qr=o({orgIds:c(i).min(1).max(cn).refine(e=>new Set(e).size===e.length,"An org is named twice").optional()}).strict().optional(),Hr=o({sourceOrgId:i,targetOrgId:i,includeStandardObjects:r()}),Kr=o({sourceOrgId:i,objectApiNames:c(s).min(1).max(Ve)}),Yr=o({sourceOrgId:i,targetOrgId:i,selectedObjects:c(s).max(f),includeStandardObjects:r(),maxDepth:b().int().min(1).max(10).optional(),maxObjects:b().int().min(1).max(500).optional()}),Zr=o({complianceFramework:co,maxRecordsPerObject:b().int().nonnegative().max(X).optional(),objectFilters:I(n(),re).optional(),overrides:c(o({objectApiName:s,fieldApiName:s,method:se([so,w("skip")])})).max(500).optional()}),Xr=o({grappeThreshold:b().int().nonnegative(),keepContactPoints:r().optional(),muteAutomation:r().optional(),checkpointFirst:B.optional()}),Vr=o({mode:o({share:w(!0).optional(),caps:I(s,b().int().min(1).max(X)).refine(e=>Object.keys(e).length<=f,"Too many caps").optional(),all:b().int().min(1).max(X).optional(),withinMB:b().positive().max(1e6).optional()}).strict().refine(e=>e.share===!0||e.caps!==void 0||e.all!==void 0,"Fit by share, by caps, or both"),muteAutomation:r().optional(),checkpointFirst:B.optional()}),Jr=o({objectApiName:s}),Qr=o({orgId:i.optional(),sourceOrgId:i.optional(),alreadySelected:c(s).max(f).optional()}).loose(),ei=o({orgId:i.optional(),sourceOrgId:i.optional(),objectApiName:s.optional(),alreadySelected:c(s).max(f).optional(),selectedObjects:c(s).max(f).optional(),availableObjects:c(s).max(500).optional()}).loose(),oi=o({sourceOrgId:i,targetOrgId:i.optional(),selectedObjects:c(s).min(1).max(f),parentObjects:c(s).max(f).optional()}).loose(),ln=po.extend({sourceOrgId:i,targetOrgId:i,selectedObjects:c(s).min(1).max(f),parentObjects:c(s).max(f).default([])}).loose(),ti=o({config:ln.optional(),sourceOrgId:i.optional(),targetOrgId:i.optional(),selectedObjects:c(s).min(1).max(f).optional(),parentObjects:c(s).max(f).optional()}).loose(),dn=n().min(1).max(5e4),ni=o({conversationId:u,message:n().max(5e4)}),ai=o({title:n().min(1).max(300)}),ri=o({conversationId:u}),ii=o({apiKey:n().min(1).max(500),errorResolution:r().optional()}),si=o({enabled:r().optional(),errorResolution:r().optional()}),ci=o({orgId:i,objectName:s,sampleSize:b().int().positive().max(1e4).optional()}),li=o({orgId:i,prompt:n().trim().min(1).max(2e3).optional(),soql:n().trim().min(1).max(2e4).optional()}).refine(e=>e.prompt===void 0!=(e.soql===void 0),{message:"Send a prompt to draft from or a query to check, not both and not neither"}),di=o({description:dn,orgIds:c(i).max(50).optional()}),pi=o({requestId:u}),ue=c(n().min(1).max(F.picklistValue)).max(F.picklistValues),Yo={label:n().max(F.agentLabel).optional(),description:n().max(F.agentDescription).optional()},mi=o({text:n().trim().min(1).max(F.text),language:oe.shape.language,casePicklists:o({Status:ue.optional(),Origin:ue.optional(),Priority:ue.optional(),Type:ue.optional()}).optional(),agent:o({topics:c(o({name:n().min(1).max(F.agentName),...Yo,actions:c(o({name:n().min(1).max(F.agentName),...Yo})).max(F.agentActions)})).max(F.agentTopics)}).optional(),draft:mo.optional(),maskOnly:r().optional()}),ui=o({filePath:n().min(1).max(2e3)}),gi=o({name:n().max(200),config:I(n(),D())}),bi=o({operationId:u.optional(),executionId:u.optional(),objectName:n().min(1).max(200).optional()}).loose(),yi=o({policyId:u}),fi=o({policy:I(n(),D())}),hi=o({policyId:u,orgId:i}),zi=o({module:n().min(1).max(50).optional(),orgId:i.optional(),offset:b().int().min(0).max(je).optional(),limit:b().int().min(1).max(je).optional()}).optional(),Si=o({operationId:u.optional()}).optional(),pn=A(["syncMappings","forgePlans","pipelines","anonymizationTemplates"]),xi=o({categories:c(pn).min(1).max(50)}),Ii=o({json:n().min(1).max(5e6),overwrite:r()}),ji=o({json:n().min(1).max(5e6)}),Pi=o({orgId:n().max(128),authMethod:n().min(1).max(50),alias:n().max(100).optional(),loginUrl:n().max(500).optional(),username:n().max(300).optional(),password:n().max(500).optional(),securityToken:n().max(100).optional(),clientId:n().max(256).optional(),jwtKeyFile:n().max(4096).optional()}).loose(),lt=n().trim().max(100).regex(/^[\w.-]*$/,"an alias is letters, digits, dots, dashes and underscores").optional(),mn=n().trim().min(1,"the username is required").max(80).regex(/^[\w.@+-]+$/,"a username is written like an email address"),dt=n().trim().min(1,"the consumer key is required").max(256).regex(/^[A-Za-z0-9._-]+={0,2}$/,"a consumer key is letters, digits, dots, dashes and underscores"),un=n().trim().min(1,"the private key file is required").max(4096).regex(/^[^\u0000-\u001f\u007f]+$/,"the private key file path holds a control character").refine(e=>Dt(e),"give the private key file as an absolute path"),ki=o({alias:lt,loginUrl:n().max(500).optional(),username:mn,clientId:dt,jwtKeyFile:un}).loose(),Oi=o({alias:lt,loginUrl:n().max(500).optional(),clientId:dt}).loose(),Ri=o({requestId:u}),wi=o({orgId:i}),vi=o({orgId:i}),Ai=o({orgId:i}).strict(),Ei=o({orgId:i,alias:n().trim().min(1).max(100),color:n().regex(/^#[0-9A-Fa-f]{6}$/),tags:c(n().trim().min(1).max(50)).max(20),staging:r().optional()}),Ci=o({key:n().min(1).max(200),value:D()}),Ti=o({enabled:r()}),_i=o({lng:A(["en","fr","de","es","ja","pt-BR"])}),Ni=o({targetOrgId:i,sourceOrgId:i.optional()}),Di=o({moduleId:n().min(1).max(64),route:n().min(1).max(64),overlay:r()}),Fi=o({moduleId:n().min(1).max(64)}),gn=80,bn=Ye(e=>Ao(e)||Eo(e)||typeof e=="string"&&e.trim()!==""&&e.length<=gn,{message:"Not a pipeline step type"}),yn=o({pipeline:o({name:n().min(1).max(200),steps:c(o({type:bn,config:I(n(),D()).default({})}).loose()).max(200),variables:c(I(n(),D())).max(200).default([]),triggers:c(I(n(),D())).max(50).default([])}).loose(),variables:I(n(),n().max(2e3)).optional()}),Mi=yn.shape.pipeline.extend({id:n().min(1).max(200)}),Ui=o({id:n().max(200),config:I(n(),D())}),Li=o({id:u}),Bi=o({operationId:u,stepId:u,decision:A(["approved","rejected"])}),fn=255,pt={pipelineId:u,stepId:u},$i=o({pipelineId:u}),Gi=o({...pt,typed:n().min(1).max(fn)}),Wi=o(pt),qi=o({category:n().max(100).optional(),query:n().max(500).optional()}).loose().optional(),Hi=o({templateId:u});function hn(e){return e.issues.slice(0,3).map(t=>`${t.path.join(".")||"(root)"}: ${t.message}`).join("; ")}function zn(e){let t=e.issues.map(a=>a.code==="custom"?a.params?.unreadablePatterns:void 0);return t.every(a=>a!==void 0)?t.flat():void 0}function Ki(e,t,a,l){let d=e.safeParse(t.payload);if(!d.success){let p=hn(d.error),m=zn(d.error);return Wo(l,t.type,a,t,new Error(`Invalid payload \u2014 ${p}`),m?{code:Oo,extraPayload:{rules:m}}:{code:"INVALID_PAYLOAD"}),null}return d.data}var Sn=5;function ye(e){return e.slice(0,15)}function xn(e){let t=e.errors?.[0];if(t===void 0)return"The org gave no reason.";if(typeof t=="string")return t;let a=t.statusCode??"",l=t.message??"";return a&&l?`${a}: ${l}`:a||l||"The org gave no reason."}function mt(e){let t=new Set;for(let a of e){let l=a.Id;typeof l=="string"&&t.add(ye(l))}return t}async function ut(e){let t=[],a=[],l={},d=!1,p=!1,m=e.stampsFor,y=ne(e.org),j=e.org.serverTime?.bind(e.org),E=m&&j?Date.now()+await ae({serverTime:j})-te:Number.NaN;for(let{objectApiName:O,ids:v}of e.plan){let x={objectApiName:O,planned:v.length,undeleted:0,alreadyBack:0,goneForGood:0,refused:0,reasons:[]};t.push(x);let h=_=>{x.reasons.length<Sn&&!x.reasons.includes(_)&&x.reasons.push(_)},R=ce(O);for(let _=0;_<v.length;_+=le){let C=v.slice(_,_+le);if(p||e.signal?.aborted){p=!0,x.notReached=(x.notReached??0)+C.length,a.push(...C);continue}let[J]=de(C,le),q,Q;try{q=mt((await e.org.queryDeleted(`SELECT Id FROM ${R} WHERE Id IN (${J}) AND IsDeleted = true`)).records),Q=mt((await e.org.query(`SELECT Id FROM ${R} WHERE Id IN (${J})`)).records)}catch(P){x.refused+=C.length,h(`The recycle bin could not be read: ${V(P)}`),a.push(...C);continue}let z=C.filter(P=>q.has(ye(P)));for(let P of C)q.has(ye(P))||(Q.has(ye(P))?x.alreadyBack++:x.goneForGood++);if(z.length===0)continue;let U;try{d=!0;let P=await e.undelete(z),T=Array.isArray(P)?P:[P];U=z.map((H,ee)=>T[ee]??{success:!1})}catch(P){let T=V(P);U=z.map(()=>({success:!1,errors:[T]}))}let Z=[];U.forEach((P,T)=>{if(P.success===!0){x.undeleted++,m?.(z[T])&&Z.push(z[T]);return}x.refused++,h(xn(P)),a.push(z[T])}),Z.length>0&&Number.isFinite(E)&&Object.assign(l,await me(e.org,R,Z,E,y))}}return{objects:t,left:a,wrote:d,cancelled:p,stamps:l}}function gt(e){return e.refused+e.goneForGood+(e.notReached??0)}async function In(e,t,a,l){let d=new Map(Object.entries(l).map(([m,y])=>[m.slice(0,15),Date.parse(y)])),p=new Set;for(let{objectApiName:m,ids:y}of t){let j=ce(m);for(let E of de(y)){let O;try{O=(await e.query(`SELECT Id, LastModifiedDate FROM ${j} WHERE Id IN (${E})`)).records}catch{continue}for(let v of O){if(typeof v.Id!="string")continue;let x=v.Id.slice(0,15),h=Date.parse(String(v.LastModifiedDate??""));(h<=a||h<=(d.get(x)??Number.NaN))&&p.add(x)}}}return p}function bt(e){let t=Date.parse(e.startedAt),a=Date.parse(e.lastWrittenAt??e.end?.at??"");return Number.isFinite(a)?{runRecordedAt:new Date(a),...Number.isFinite(t)?{runDurationMs:Math.max(0,a-t)}:{}}:{}}function jn(e){return e.filter(t=>t.deleted+t.alreadyGone>0).map(t=>t.objectApiName)}async function cs(e){let{run:t,includeChanged:a}=e,l=e.again===!0,d=pe(t,l),p=d.reduce((g,S)=>g+S.ids.length,0),m=Ne(t),y=m.reduce((g,S)=>g+S.ids.length,0),j=Lo(t),E=j.reduce((g,S)=>g+S.ids.length,0),O=[],v=e.backups,x=e.undelete;j.length>0&&!x&&O.push(`The ${E} record(s) the run deleted could not be brought back from the recycle bin here: the next removal offers them again.`),m.length>0&&!v&&O.push(`The values from before the run of ${y} record(s) it wrote over could not be read here: they were not put back, and the next removal offers them again.`);let h,R,_={},C=(e.earlierRuns??[]).map(g=>({runId:g.runId,keys:new Set([...pe(g),...Ne(g)].flatMap(({ids:S})=>S.map(L=>L.slice(0,15))))})),J=g=>C.some(({keys:S})=>S.has(g.slice(0,15))),q=e.sweep,Q=m.length>0&&v||j.length>0&&x||q?async g=>{if(j.length>0&&x){let N=m.length>0&&v?await In(e.org,m,await Bo(e.org,fe(t)),t.removal?.removalStamps??{}):void 0,$=N?Date.now()+await ae(e.org)-te:0;if(R=await ut({org:e.org,plan:j,undelete:x,...C.length>0?{stampsFor:J}:{},...e.signal?{signal:e.signal}:{}}),N&&R.wrote){let k=ne(e.org);for(let{objectApiName:Se,ids:St}of m){let xt=St.filter(It=>N.has(It.slice(0,15)));Object.assign(_,await me(e.org,Se,xt,$,k))}}if(R.cancelled||e.signal?.aborted)return R.wrote}if(m.length>0&&v){let N={...t.removal?.removalStamps,..._};h=await $o({org:e.org,plan:m,backups:v,...fe(t)!==void 0?{lastWriteAt:fe(t)}:{},includeChanged:a,...Object.keys(N).length>0?{stamps:N}:{},...t.unkept?{unkept:t.unkept}:{},...C.length>0?{stampsFor:J}:{},...e.signal?{signal:e.signal}:{}})}let S=(R?.wrote??!1)||(h?.wrote??!1);if(h?.cancelled||e.signal?.aborted)return S;let L=q?await q(g):!1;return S||L}:void 0,z=await Te(e.org,d,{...bt(t),...t.removal?.removalStamps?{removalStamps:t.removal.removalStamps}:{},...t.removal?.removalSpans?{removalSpans:t.removal.removalSpans}:{},includeChanged:a,...Q?{sweep:Q}:{},...e.afterRemoval?{afterRemoval:e.afterRemoval}:{},...e.automationMade?{automationMade:e.automationMade}:{},...e.runUserId?{runUserId:e.runUserId}:{},...e.onUndeletable?{onUndeletable:e.onUndeletable}:{},...e.beforeFirstWrite?{beforeFirstWrite:e.beforeFirstWrite}:{},signal:e.signal,onProgress:e.onProgress}),U=new Date().toISOString();if(z.stoppedForUndeletable)return{result:{runId:t.runId,status:"cancelled",includeChanged:a,objects:[],finishedAt:U},planned:p,plannedBack:y,plannedUndelete:E,notes:[],stoppedForUndeletable:!0};let Z=l?void 0:t.removal?.undo?.removedAt,P={runId:t.runId,status:On(Rn(Mo(z.objects,z.cancelled),z.objects,h),z.objects,h,R),includeChanged:a,objects:z.objects,finishedAt:U,...Z?{leftBy:Z}:{},...h&&h.objects.length>0?{restored:h.objects}:{},...R&&R.objects.length>0?{undeleted:R.objects}:{}},T=Uo(P,p,t.removal?.undo,l),H=new Set(z.gone),ee=H.size>0||l&&T?d.flatMap(({ids:g})=>g.filter(S=>!H.has(S))):void 0,qe={..._,...z.stamps},He=Object.keys(qe).length>0,ft=h?.objects.some(g=>g.restored+(g.restoredWithout??0)>0)===!0,ht=R!==void 0&&!R.cancelled;if(T||He||z.span||ee||h||R)try{await e.store.updateRemoval(t.runId,g=>({...g,...T?{undo:T}:{},...He?{removalStamps:{...g.removalStamps,...qe}}:{},...z.span?{removalSpans:[...g.removalSpans??[],z.span]}:{},...ee?{removalLeft:ee}:{},...h?{restoreLeft:h.left}:{},...ft?{restoredAt:U}:{},...R?{undeleteLeft:R.left}:{},...ht?{undeletedAt:U}:{}}))}catch(g){O.push(`What this removal did could not be kept (${g instanceof Error?g.message:String(g)}): the next removal of the run may set out to take records already gone.`)}let zt=Object.keys(h?.stamps??{}).length>0?await Pn(e.org,t,e.earlierRuns??[]):new Map,he=[];for(let{runId:g,keys:S}of C){let L=zt.get(g),N=Object.fromEntries(Object.entries({...R?.stamps,...h?.stamps}).filter(([k])=>S.has(k.slice(0,15))&&!L?.has(k.slice(0,15)))),$=Object.keys(N).length;if($!==0)try{await e.store.updateRemoval(g,k=>({...k,removalStamps:{...k.removalStamps,...N},...z.span?{removalSpans:[...k.removalSpans??[],z.span]}:{}})),he.push({runId:g,records:$})}catch(k){O.push(`What this removal gave back of ${$} record(s) the run ${g} wrote too could not be kept on it (${k instanceof Error?k.message:String(k)}): its removal reads them as changed since it.`)}}let ie=e.configs;if(ie&&H.size>0&&ie.isSaved(t.configId)){let g={sourceOrgId:t.sourceOrgId,targetOrgId:De(t)};try{let S=d.filter(k=>_e.includes(k.objectApiName)).flatMap(({ids:k})=>k.filter(Se=>H.has(Se))),L=ie.forgetFiles(t.configId,g,S),N=jn(z.objects).filter(k=>!_e.includes(k)),$=ie.markRemoved(t.configId,g,[...new Set([...N,...L.map(k=>k.objectApiName)])],U);P={...P,...$.length>0?{readWhole:$}:{},...L.length>0?{filesForgotten:L.length}:{}}}catch(S){O.push(`The configuration could not be told what this removal took (${S instanceof Error?S.message:String(S)}): run it full next time.`)}}let ze;if(e.links&&H.size>0)try{ze=await e.links.forget(t.configId,{sourceOrgId:t.sourceOrgId,targetOrgId:De(t)},[...H])}catch(g){O.push(`Which records of the target this removal took could not be forgotten (${g instanceof Error?g.message:String(g)}): a later run of the configuration may point a lookup at one of them.`)}return{result:P,planned:p,plannedBack:y,plannedUndelete:E,notes:O,...ze?{linksForgotten:ze}:{},...he.length>0?{earlierStamped:he}:{}}}async function ls(e){let{run:t}=e,a=pe(t);return{outcome:await Te(e.org,a,{...bt(t),...t.removal?.removalStamps?{removalStamps:t.removal.removalStamps}:{},...t.removal?.removalSpans?{removalSpans:t.removal.removalSpans}:{},includeChanged:e.includeChanged,...e.runUserId?{runUserId:e.runUserId}:{},previewOnly:!0,...e.signal?{signal:e.signal}:{}}),planned:a.reduce((d,p)=>d+p.ids.length,0)}}async function Pn(e,t,a){let l=new Map,d=Object.entries(t.heldBefore??{});if(d.length===0||a.length===0)return l;let p=await ne(e)(),m=await ae(e);for(let y of a){let j=Date.parse(fe(y)??""),E=Number.isFinite(j)?j+m+te:Number.NEGATIVE_INFINITY,O=new Set;for(let[v,{at:x,by:h}]of d)Date.parse(x)>E&&(p!==void 0&&h!==void 0&&h.slice(0,15)===p||O.add(v));O.size>0&&l.set(y.runId,O)}return l}function fe(e){return e.lastWriteAt??e.lastWrittenAt??e.end?.at}function kn(e){return e.keptChanged+e.refused+e.notKept+(e.notReached??0)+(e.restoredWithout??0)}function On(e,t,a,l){if(!l||e==="cancelled")return e;if(l.cancelled)return"cancelled";let d=l.objects.some(m=>gt(m)>0);if(e==="success"&&!d)return"success";let p=t.some(m=>m.deleted>0)||(a?.objects??[]).some(m=>m.restored>0)||l.objects.some(m=>m.undeleted>0);return e==="partial"||p?"partial":"failure"}function Rn(e,t,a){if(!a||e==="cancelled")return e;if(a.cancelled)return"cancelled";let l=a.objects.some(p=>kn(p)>0);return e==="success"&&!l?"success":t.some(p=>p.deleted>0)||a.objects.some(p=>p.restored+(p.restoredWithout??0)>0)?"partial":"failure"}function ps(e){let t=e?.getSandforgeSetting?.("backup.maxAgeDays",30);return typeof t=="number"&&Number.isFinite(t)&&t>0?t:0}function ms(e,t,a){let l=[],d=0,p=Number.POSITIVE_INFINITY;for(let m of e){let y=t(m.backup);if(!y){d+=m.ids.length;continue}l.push(m);let j=Date.parse(y.timestamp??"");a>0&&Number.isFinite(j)&&(p=Math.min(p,j+a*864e5))}return{kept:l,notKept:d,...Number.isFinite(p)?{keptUntil:new Date(p).toISOString()}:{}}}async function gs(e,t){let a=e.check(t);if(!a.allowed)return{check:a,decision:"refused"};if(!await e.confirmIfNeeded(a,t.orgTier))return{check:a,decision:"declined"};let d=a.requiresConfirmation&&e.canAskForConfirmation===!0;return{check:a,decision:d?"confirmed":"allowed"}}var yt={allowed:0,confirmed:1,declined:2,refused:3};function bs(e,t){return e===void 0||yt[t]>yt[e]?t:e}export{Tn as a,Go as b,_n as c,Fe as d,Nn as e,Dn as f,jt as g,Fn as h,Mn as i,Un as j,Ln as k,Bn as l,$n as m,Gn as n,Wo as o,Wn as p,qn as q,Hn as r,Kn as s,i as t,s as u,Vo as v,B as w,Mt as x,Ut as y,Le as z,aa as A,ra as B,ia as C,sa as D,ca as E,la as F,da as G,pa as H,ma as I,ua as J,ga as K,ba as L,ya as M,fa as N,ha as O,za as P,Sa as Q,xa as R,Ia as S,ja as T,Pa as U,ka as V,Oa as W,Ra as X,wa as Y,va as Z,Ht as _,Aa as $,Ea as aa,Ca as ba,Ta as ca,_a as da,Na as ea,Da as fa,Fa as ga,Ma as ha,Ua as ia,La as ja,Ba as ka,$a as la,Ga as ma,Wa as na,qa as oa,Ha as pa,Ka as qa,Ya as ra,Za as sa,Xa as ta,Va as ua,Ja as va,Qa as wa,er as xa,or as ya,tr as za,nr as Aa,ar as Ba,rr as Ca,ir as Da,sr as Ea,Xt as Fa,cr as Ga,lr as Ha,Jt as Ia,dr as Ja,pr as Ka,mr as La,ur as Ma,gr as Na,br as Oa,yr as Pa,fr as Qa,hr as Ra,tt as Sa,zr as Ta,Sr as Ua,xr as Va,an as Wa,Ir as Xa,jr as Ya,Pr as Za,kr as _a,Or as $a,Rr as ab,wr as bb,vr as cb,Ar as db,Er as eb,Cr as fb,Tr as gb,_r as hb,Nr as ib,Dr as jb,Fr as kb,Mr as lb,Ur as mb,Lr as nb,Br as ob,$r as pb,Gr as qb,Wr as rb,qr as sb,Hr as tb,Kr as ub,Yr as vb,Zr as wb,Xr as xb,Vr as yb,Jr as zb,Qr as Ab,ei as Bb,oi as Cb,ti as Db,ni as Eb,ai as Fb,ri as Gb,ii as Hb,si as Ib,ci as Jb,li as Kb,di as Lb,pi as Mb,mi as Nb,ui as Ob,gi as Pb,bi as Qb,yi as Rb,fi as Sb,hi as Tb,zi as Ub,Si as Vb,xi as Wb,Ii as Xb,ji as Yb,Pi as Zb,ki as _b,Oi as $b,Ri as ac,wi as bc,vi as cc,Ai as dc,Ei as ec,Ci as fc,Ti as gc,_i as hc,Ni as ic,yn as jc,Mi as kc,Ui as lc,Li as mc,Bi as nc,$i as oc,Gi as pc,Wi as qc,qi as rc,Hi as sc,hn as tc,Ki as uc,ut as vc,cs as wc,ls as xc,fe as yc,On as zc,Rn as Ac,gs as Bc,bs as Cc,ps as Dc,ms as Ec};
|
package/lib/chunk-YPSRZRIT.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{i as c}from"./chunk-B45CNPUX.mjs";var a=/__kav$/i,d="Campaign";function u(e){return a.test(e)?"Salesforce Knowledge is not turned on in it":void 0}var b="a campaign needs the Marketing User box ticked on the user, in Setup > Users",f=/^005[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/;function g(e){let n,r;return async s=>{n??=e.describeGlobal().then(o=>new Map(o.sobjects.map(i=>[i.name.toLowerCase(),i.createable===!0])));let t=(await n).get(s.toLowerCase());if(t===void 0){let o=u(s);return{access:"absent",...o?{reason:o}:{}}}return s===d&&(r??=l(e),!t||!await r)?{access:"readOnly",reason:b}:t?{access:"createable"}:{access:"readOnly"}}}async function j(e,n){let r=new Set;for(let{objectApiName:s,optional:t}of e.objects)if(t===!0)try{(await n(s)).access!=="createable"&&r.add(s)}catch{}if(r.size===0)return e;for(let s=!0;s;){s=!1;for(let t of e.objects)r.has(t.objectApiName)||c(t,e.relations).some(o=>r.has(o))&&(r.add(t.objectApiName),s=!0)}return{...e,objects:e.objects.filter(s=>!r.has(s.objectApiName)),...e.relations?{relations:e.relations.filter(({childObject:s,parentObject:t})=>!r.has(s)&&!r.has(t))}:{}}}async function l(e){try{let{user_id:n}=await e.identity();return f.test(n)?(await e.query(`SELECT UserPermissionsMarketingUser FROM User WHERE Id = '${n}'`)).records[0]?.UserPermissionsMarketingUser!==!1:!0}catch{return!0}}export{g as a,j as b};
|
package/lib/chunk-YS4G22C2.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 as c,c as f,d as u}from"./chunk-BZ24IAP5.mjs";import{spawn as y}from"node:child_process";import{join as v}from"node:path";function w(){return process.execArgv.filter(r=>!/^--inspect/.test(r))}function x(r){return v(__dirname,`${r}.mjs`)}var P="SANDFORGE_RELAYED_BY";function N(r={}){let n=(r.platform??process.platform)==="win32",m=r.scriptPath??x;return(S,l,o)=>new Promise((g,E)=>{let R={...process.env,...r.relayedBy!==void 0?{[P]:r.relayedBy}:{},...n?{[u]:"ipc"}:{}},t=y(process.execPath,[...w(),m(S),...l],{stdio:n?["ignore","pipe","pipe","ipc"]:["ignore","pipe","pipe"],env:R,detached:!n,windowsHide:!0}),i=[],d=[];t.stdout?.on("data",e=>i.push(e)),t.stderr?.on("data",e=>{d.push(e),process.stderr.write(e)});let s=()=>{if(!n||!t.connected){t.kill("SIGINT");return}t.send(f,e=>{e&&t.kill("SIGINT")})};o.aborted?s():o.addEventListener("abort",s,{once:!0}),t.on("error",e=>{o.removeEventListener("abort",s),E(e)}),t.on("close",(e,A)=>{o.removeEventListener("abort",s);let p=a.find(B=>B===A);g({code:e??(p!==void 0?c(p):1),stdout:Buffer.concat(i).toString("utf8"),stderr:Buffer.concat(d).toString("utf8")})})})}export{P as a,N as b};
|
package/lib/chunk-YW2SBL4Z.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-TBZMC2VV.mjs";import"./chunk-LQ4DRFUH.mjs";import"./chunk-57VHUYNG.mjs";import"./chunk-5O6JOMHS.mjs";import"./chunk-HUMEKZT5.mjs";import"./chunk-MYTIL2JD.mjs";import"./chunk-JVL444U5.mjs";import"./chunk-KLX67VPL.mjs";import"./chunk-5CD257T7.mjs";import"./chunk-H45UXY6G.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-SRQDABQ2.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LV6G4XTK.mjs";import"./chunk-HJKM3E56.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-YMJVMFPY.mjs";import"./chunk-ALJVEUUS.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-4HFRHFGQ.mjs";import"./chunk-342FN7AO.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-Z7X534S4.mjs";import"./chunk-6QSM2WIH.mjs";import"./chunk-WJY54JO7.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-NEVXIGR6.mjs";import"./chunk-NTDN2JQZ.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-6MUEPV7M.mjs";import"./chunk-HJC7AIBK.mjs";import"./chunk-OTWRDD6L.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-RH3N2H7P.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-55HEMHEG.mjs";import"./chunk-P42X3B4D.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VXHDBYMI.mjs";import"./chunk-ENLBYECD.mjs";import"./chunk-PA3MKJVH.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-ZLZRU6MO.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-PNCONNFJ.mjs";import"./chunk-CGWXQX75.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-SIOZXPFG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-B45CNPUX.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-Z7X534S4.mjs
DELETED
|
@@ -1,10 +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{W as S,X as I,Y as Ae,n as Ee,o as Ce,oa as re}from"./chunk-6QSM2WIH.mjs";import{t as v,u as Be}from"./chunk-WJY54JO7.mjs";import{b as x}from"./chunk-OTWRDD6L.mjs";import{L as ve,N as V,O as Te,f as ye,ka as Ne}from"./chunk-VXHDBYMI.mjs";import{b as ne,f as Oe}from"./chunk-INIT2UKJ.mjs";import{k as we,l as ke,m as Se}from"./chunk-PNCONNFJ.mjs";import{ca as K,da as Re}from"./chunk-CGWXQX75.mjs";import{b as P}from"./chunk-CA5NAXSU.mjs";import{b as be,e as ee,f as te,k as he,l as W}from"./chunk-7EANH5PY.mjs";function ot(e){return e.keptChanged+e.keptDependents+e.refused+(e.notVisible??0)}function Sn(e,t){return t?"cancelled":e.every(n=>ot(n)===0)?"success":e.some(n=>n.deleted>0)?"partial":"failure"}function En(e,t){return e!=="success"||!t||t.status==="success"?e:t.status==="cancelled"?"cancelled":"partial"}function Cn(e){return e.status}function An(e){return e.filter(t=>t.deleted+t.refused+(t.notReached??0)>0).map(t=>({...ye(t.objectApiName),deleted:t.deleted,failed:t.refused,...(t.notReached??0)>0?{notSent:t.notReached}:{}}))}function Bn(e,t,n,r=!1){let o=h=>e.objects.reduce((B,C)=>B+h(C),0),i=o(h=>h.deleted),a=o(h=>h.alreadyGone),m=o(h=>h.keptChanged+h.keptDependents),u=o(h=>h.refused),c=o(h=>h.notVisible??0);if(i+a===0&&(!r||e.status==="cancelled"||m+u+c===0))return;let g=r?void 0:n,y=o(h=>h.platformCopies??0),A=e.status==="cancelled"?Math.max(0,t+y-i-a-m-u-c):0;return{removedAt:e.finishedAt,deleted:(g?.deleted??0)+i,alreadyGone:(g?.alreadyGone??0)+a,kept:m,refused:u,...A>0?{notReached:A}:{},...c>0?{notVisible:c}:{}}}function vn(...e){let t=new Set,n=[];for(let r of e.flatMap(o=>o??[])){let o=`${r.first}|${r.last}|${r.userId.slice(0,15)}`;t.has(o)||(t.add(o),n.push(r))}return n.sort((r,o)=>Date.parse(r.first)-Date.parse(o.first))}var oe=5;function M(e,t,n=1/0){return[...new Set([...e,...t])].slice(0,n)}function D(e,t){return e===void 0&&t===void 0?void 0:(e??0)+(t??0)}function Tn(...e){let t=new Map;for(let n of e.flat()){let r=t.get(n.objectApiName);if(!r){t.set(n.objectApiName,{...n});continue}let o={notVisible:D(r.notVisible,n.notVisible),notReached:D(r.notReached,n.notReached),heldByAutomation:D(r.heldByAutomation,n.heldByAutomation),heldByAutomationAfterRun:D(r.heldByAutomationAfterRun,n.heldByAutomationAfterRun),heldByAutomationAlong:D(r.heldByAutomationAlong,n.heldByAutomationAlong),platformCopies:D(r.platformCopies,n.platformCopies)},i=M(r.automationHolders??[],n.automationHolders??[]),a=r.filesLeft||n.filesLeft?{count:(r.filesLeft?.count??0)+(n.filesLeft?.count??0),names:M(r.filesLeft?.names??[],n.filesLeft?.names??[],oe)}:void 0;t.set(n.objectApiName,{objectApiName:n.objectApiName,planned:r.planned+n.planned,deleted:r.deleted+n.deleted,alreadyGone:r.alreadyGone+n.alreadyGone,keptChanged:r.keptChanged+n.keptChanged,keptDependents:r.keptDependents+n.keptDependents,refused:r.refused+n.refused,...Object.fromEntries(Object.entries(o).filter(([,m])=>m!==void 0)),heldBy:M(r.heldBy,n.heldBy),...i.length>0?{automationHolders:i}:{},unchecked:M(r.unchecked,n.unchecked),reasons:M(r.reasons,n.reasons,oe),...a?{filesLeft:a}:{}})}return[...t.values()]}function Nn(...e){let t=new Map;for(let n of e.flat()){let r=t.get(n.objectApiName);if(!r){t.set(n.objectApiName,{...n,changedBy:{...n.changedBy}});continue}let o={...r.changedBy};for(let[a,m]of Object.entries(n.changedBy))o[a]=(o[a]??0)+m;let i=D(r.platformCopies,n.platformCopies);t.set(n.objectApiName,{objectApiName:n.objectApiName,planned:r.planned+n.planned,toDelete:r.toDelete+n.toDelete,alreadyGone:r.alreadyGone+n.alreadyGone,changedSince:r.changedSince+n.changedSince,keptChanged:r.keptChanged+n.keptChanged,changedBy:o,undeletable:r.undeletable+n.undeletable,notVisible:r.notVisible+n.notVisible,unread:r.unread+n.unread,...i!==void 0?{platformCopies:i}:{},reasons:M(r.reasons,n.reasons,oe)})}return[...t.values()]}import{AsyncLocalStorage as it}from"node:async_hooks";var je=new Set(["delete","hardDelete"]),de=1e4,Pe=5e4;function _n(e){switch(e){case"production":return;case"staging":return de;case"development":case"scratch":return Pe}}var xe=new it;function ie(){let e=xe.getStore();return e?.live?e:void 0}async function Pn(e,t){let n={approved:e.approved,live:!0};try{return await xe.run(n,t)}finally{n.live=!1}}var De=class{overrides=new Map;options;constructor(t){this.options=t??{}}check(t){let n=this.checkTier(t),{orgNameOf:r}=this.options;return!n.requiresConfirmation||!r?n:{...n,question:dt(t,r(t.orgId),this.options.questionWords)}}checkTier(t){switch(t.orgTier){case"production":return this.checkProduction(t);case"staging":return this.checkStaging(t);case"development":case"scratch":return this.checkDevelopment(t)}}setProductionOverride(t,n){this.overrides.set(t,n)}isProductionOverridden(t){return this.overrides.get(t)===!0}get canAskForConfirmation(){return this.options.requestConfirmation!==void 0||ie()!==void 0}async confirmIfNeeded(t,n){if(!t.allowed||!t.requiresConfirmation)return t.allowed;let r=ie();return r?r.approved:this.options.requestConfirmation?t.question===void 0?this.options.requestConfirmation(t.impactSummary,n):this.options.requestConfirmation(t.impactSummary,n,t.question):!0}declinedWithoutAsking(t,n){if(!(!t.allowed||!t.requiresConfirmation||ie())&&this.options.requestConfirmation)return this.options.declinesWithoutAsking?.(n)}async confirmRun(t){return this.options.requestRunConfirmation?await this.options.requestRunConfirmation(t)?"confirmed":"declined":"unavailable"}orgPhrase(t,n){let r=this.options.orgNameOf?.(t.orgId);return r?n.org(t.orgTier,r,!0):n.org(t.orgTier,t.orgId,!1)}checkProduction(t){let n=[],r=je.has(t.operation),o=this.isProductionOverridden(t.orgId);n.push(`Production operation: ${t.operation} on ${t.objectName} (${q(t.recordCount)} ${st(t)}${t.alsoWrites?`, plus ${t.alsoWrites}`:""})`);let i=this.options.questionWords??Ie;return t.operation==="deploy"?{allowed:!1,requiresConfirmation:!1,blockedReason:i.deployRefused(this.orgPhrase(t,i)),warnings:n,impactSummary:U(t)}:r&&!o?{allowed:!1,requiresConfirmation:!1,blockedReason:i.deleteRefused(t.operation==="hardDelete"?"hardDelete":"delete",this.orgPhrase(t,i)),warnings:n,impactSummary:U(t)}:(r&&o&&n.push("Production override is active \u2014 destructive operation permitted"),{allowed:!0,requiresConfirmation:!0,warnings:n,impactSummary:U(t)})}checkStaging(t){let n=[],r=je.has(t.operation),o=t.operation==="deploy",i=r||o||se(t.recordCount)>de;return r&&n.push(`Destructive operation (${t.operation}) on staging org \u2014 confirmation required`),o&&n.push("Metadata deployment on staging org \u2014 confirmation required"),se(t.recordCount)>de&&n.push(`Large volume operation: ${q(t.recordCount)} records on staging`),{allowed:!0,requiresConfirmation:i,warnings:n,impactSummary:U(t)}}checkDevelopment(t){let n=[];return se(t.recordCount)>Pe&&n.push(`Large volume operation: ${q(t.recordCount)} records on ${t.orgTier} org`),{allowed:!0,requiresConfirmation:!1,warnings:n,impactSummary:U(t)}}};function q(e){return e==="unknown"?"an unknown number of":typeof e=="number"?String(e):`at most ${e.atMost}`}function se(e){return e==="unknown"?0:typeof e=="number"?e:e.atMost}function st(e){return e.operation==="deploy"?"components":"records"}var xn="the related records the run adds",Ie={sentence:(e,t,n)=>{switch(e){case"insert":return`Insert ${t} into ${n}.`;case"update":return`Update ${t} in ${n}.`;case"upsert":return`Insert or update ${t} in ${n}.`;case"delete":return`Delete ${t} in ${n}.`;case"hardDelete":return`Permanently delete ${t} in ${n}.`;case"deploy":return`Deploy ${t} to ${n}.`}},counted:(e,t)=>t==="unknown"?`${e}s`:typeof t=="number"?`${t} ${e}${t===1?"":"s"}`:`at most ${t.atMost} ${e}s`,besides:(e,t)=>`${e}, plus ${t},`,org:(e,t,n)=>n?`the ${e} org "${t}"`:`the ${e} org ${t}`,deployRefused:e=>`SandForge deploys metadata only to a sandbox, a scratch org or a Developer Edition org, not to ${e}.`,deleteRefused:(e,t)=>e==="hardDelete"?`Permanently deleting records is not allowed in ${t}.`:`Deleting records is not allowed in ${t}.`},at=new Set(["SeedData","SyncData","CloneData","AutopilotData"]);function dt(e,t,n=Ie){let r=e.operation==="deploy"?"component":"record",o=at.has(e.objectName)?"":` (${e.objectName})`,i=`${n.counted(r,e.recordCount)}${o}`,a=e.alsoWrites?n.besides(i,e.alsoWrites):i,m=t?n.org(e.orgTier,t,!0):n.org(e.orgTier,e.orgId,!1);return n.sentence(e.operation,a,m)}function U(e){if(e.operation==="deploy")return`DEPLOY ${q(e.recordCount)} component(s) (${e.objectName}) to ${e.orgTier} org ${e.orgId} [module: ${e.module}]`;let t=e.alsoWrites?`, plus ${e.alsoWrites},`:"";return`${e.operation.toUpperCase()} ${q(e.recordCount)} ${e.objectName} record(s)${t} on ${e.orgTier} org ${e.orgId} [module: ${e.module}]`}function J(e,t){return`${e} ${t}${e===1?"":"s"}`}var ct={cost:({records:e,objects:t,requests:n,seconds:r,megabytes:o,keepDays:i})=>`Checkpoint first: about ${J(e,"record")} of ${J(t,"object")}, ${J(n,"API request")}, ${r} s, ${o} MB on this machine, unencrypted, and none of the org's storage, `+(i===0?"kept until you delete it.":`kept ${J(i,"day")}.`),added:(e,t)=>`Added: ${e} \u2014 ${t}`,notHeld:(e,t)=>`Not in the checkpoint: ${e} \u2014 ${t}`,more:e=>`\u2026 and ${e} more`,unknown:"What an Apex trigger, or automation that could not be read, creates as the run writes is not known: a rewind leaves those records as they are."},ae=10;function ut(e){return e<=0?"0":Math.max(.1,Math.ceil(e/1048576*10-1e-9)/10).toFixed(1)}function In(e,t=ct){let{estimate:n}=e,r=[t.cost({records:n.records,objects:e.objects.length,requests:n.apiRequests,seconds:Math.ceil(n.seconds),megabytes:ut(n.bytes),keepDays:e.keepDays})],o=(i,a)=>{for(let{objectApiName:m,reason:u}of i.slice(0,ae))r.push(a(m,u));i.length>ae&&r.push(t.more(i.length-ae))};return o(e.added,t.added),o(e.notHeld,t.notHeld),r.push(t.unknown),r}import{randomUUID as lt}from"node:crypto";var ce="\0configStore:revision",ft="\0configStore";function mt(e){let t=e[ce]?.value;if(t!==void 0)try{let n=JSON.parse(t);return typeof n.writer=="string"&&typeof n.write=="number"?{writer:n.writer,write:n.write}:void 0}catch{return}}var Me=class{backend;logWarning;writer=lt();writes=0;written;constructor(t,n){this.backend=t,this.logWarning=n}initialize(){this.backend.getData()}get(t){let n=this.current()[t];if(n)try{return JSON.parse(n.value)}catch(r){let o=P(r);this.logWarning?.(`[ConfigStore] Failed to parse JSON for key "${t}": ${o}`);return}}set(t,n,r="general"){let o=JSON.stringify(n);this.update(i=>{let a=i[t];return a&&a.value===o&&a.category===r?!1:(i[t]={value:o,category:r},!0)})}delete(t){return this.update(n=>t in n?(delete n[t],!0):!1)}has(t){return t in this.current()}getByCategory(t){let n={};for(let[r,o]of Object.entries(this.current()))if(o.category===t)try{n[r]=JSON.parse(o.value)}catch(i){let a=P(i);this.logWarning?.(`[ConfigStore] Corrupted entry in category "${t}", key "${r}": ${a}`)}return n}getAllKeys(){return Object.keys(this.current()).filter(t=>t!==ce)}getKeysByPrefix(t){return this.getAllKeys().filter(n=>n.startsWith(t))}clearCategory(t){let n=0;return this.update(r=>{for(let[o,i]of Object.entries(r))i.category===t&&(delete r[o],n++);return n>0}),n}clearAll(){this.write({})}current(){let t=this.backend.getData(),n=mt(t);return this.written&&n?.writer===this.writer&&n.write<this.writes?this.written:t}update(t){let n={...this.current()},r=t(n);return r&&this.write(n),r}write(t){this.writes+=1,t[ce]={value:JSON.stringify({writer:this.writer,write:this.writes}),category:ft},this.backend.setData(t),this.written=t}};var pt=300,gt=1024,bt=160,ht=500,Ke=40,Rt=4,yt=3,Ot=3,wt=1,kt=1e3,St=1,$e=200,Et=60,Ct=50,At=Buffer.byteLength(`${JSON.stringify({Id:"0".repeat(18)})}
|
|
8
|
-
`),Bt="IsDeleted = false",Ve=4;function vt(e){return e.access?.kind==="perObject"?e.access.requests:0}var Tt=1,Nt=200,jt=3,Dt=1,_t=1,Je=2,Pt=3,xt=2e3,It=100,ze=["Id","SystemModstamp"],Le=23,j=2.5,b=.35,Mt=1,$t=.9,O=.5,pe=.25,T=.86,Lt="ContentVersion",Ft="ContentDocument",ue=200,Fe=150,R={apiRequests:0,seconds:0};function d(e,t){return{apiRequests:e,seconds:e*t}}function G(e){return{apiRequests:e,seconds:p(e,Ae)*b}}function l(...e){return e.reduce((t,n)=>({apiRequests:t.apiRequests+n.apiRequests,seconds:t.seconds+n.seconds}),R)}function p(e,t){return e>0?Math.ceil(e/t):0}function E(e){return p(e,x)}function Ye(e){return ne(e,ze).length}function Wt(e){return e.length>It?x/4:x}function Q(e,t){return p(e,Wt(t))*Ye(t)}function We(e,t){if(e.length===0)return 0;let n=2*(e.length-1)+2+2*(t-1);for(let r of e){let o=JSON.stringify(r,null,2),i=1;for(let a=o.indexOf(`
|
|
9
|
-
`);a>=0;a=o.indexOf(`
|
|
10
|
-
`,a+1))i++;n+=Buffer.byteLength(o,"utf8")+i*2*t}return n}function Ut(e){let t=gt+(e.printsBytes??0),n=[];for(let r of e.objects)t+=r.records*pt+Be(r.records,2),r.records>0&&(t+=bt),t+=(r.inBin??0)*At,t+=(r.links??0)*(Et+Ct),r.entry!==void 0&&n.push(r.entry);return t+We(n,2)+We(e.leftOut??[],3)}function Xn(e,t,n){let[,...r]=ne(t,ze),o=n==="scanAllLive"?Bt:void 0;return r.map(i=>Oe(e,i,o))}function Ue(e,t){return t.reduce((n,r)=>n+p(e,Math.max(1,r)),0)}function qt(e,t){if(e.records===0)return{pages:0,reads:0};let n=Math.floor(e.records/t),r=e.records-n*t,o=e.otherGroups??[];return{pages:n+(r>0?1:0),reads:n*Ue(t,o)+Ue(r,o)}}function Zn(e){let t=e.objects.length,n=p(e.described,I),r=e.describedAlone??0,o=G(p(e.counted??t,S)),i=(e.countedAlone??0)+p(e.recounted??0,S),a=o.apiRequests+i,m=G(p(t,S)),u=Math.min(e.pageRows,kt),c=0,g=0,y=0;for(let f of e.objects){y+=f.records;let w=qt(f,u);c+=w.pages,g+=w.reads}let A=H(e.objects.map(f=>$(f.inBin??0))),h=Gt(e.objects),B=e.objects.filter(f=>(f.stampedSince??0)>0),C=l(H(B.flatMap(f=>[$(f.stampedSince??0),1])),G(p(B.length,S))),F=c+g+(c>0?wt:0),s={guard:Rt,scope:yt+n+r,start:Ot,counts:a,bin:A.apiRequests,snapshot:F+h.apiRequests,stability:St+m.apiRequests+C.apiRequests};return{records:y,apiRequests:Object.values(s).reduce((f,w)=>f+w,0),requestsByPhase:s,seconds:Math.ceil(n*j+(r+i)*b+o.seconds+m.seconds+A.seconds+C.seconds+h.seconds+c*Mt+g*O),bytes:Ut(e)}}function Gt(e){let t=e.filter(o=>o.links!==void 0);if(t.length===0)return R;let n=0,r=0;for(let o of t)o.links===null?n+=p(p(o.records,$e),S):r+=o.links??0;return l(H(t.map(o=>$(o.links??0))),d(n,O),d(p(p(r,$e),S),O))}function $(e){return Math.max(1,p(e,xt))}function H(e){let t=0,n=0;for(let r=0;r<e.length;r+=S){let o=Math.max(1,...e.slice(r,r+S));t+=1,n+=o-1}return l(d(t,b),d(n,$t))}function Ht(e){let t=new Set([...e.held,...e.moved.map(n=>n.objectApiName)]);return l(G(p(e.objects,S)),H(e.moved.flatMap(({live:n,deleted:r})=>[$(n),$(r)])),G(p(t.size,S)))}function Xe(e){let t=e.reduce((n,r)=>n+E(r),0);return l(d(t*(jt-1),O),d(t,T))}function Qt(e){return l(...e.filter(t=>t.records>0).map(({records:t,cascades:n,described:r})=>{let o=E(t);return l(d(r?0:1,j),Xe([t]),d(o*p(n,S),b),d(o*Dt,O))}))}function le(e,t){let n=R;for(let r=e;r>0;r-=v){let o=Math.min(r,v);n=l(n,d(Je,b),d(Q(o,t),O),d(V([{rows:o}]),T),d(E(o),O))}return n}function Kt(e,t,n,r){return e===0||n===0?R:l(d(r?0:1,j),d((n+E(e))*p(t,S),b))}var Vt=W({childRelationships:he(W({childSObject:be().optional(),cascadeDelete:te().optional(),restrictedDelete:te().optional()}).loose()).nullish()}).loose();function er(e,t){let n=Vt.parse(e).childRelationships??[],r=n.filter(u=>u.cascadeDelete===!0),o=t?.worked,i={dependents:n.filter(u=>(u.cascadeDelete===!0||u.restrictedDelete===!0)&&(o===void 0||u.childSObject!==void 0&&o.has(u.childSObject))).length,cascades:r.length,cascadeChildren:[...new Set(r.flatMap(u=>u.childSObject===void 0?[]:[u.childSObject]))]};if(t===void 0)return i;let a=n.filter(u=>u.cascadeDelete===!0&&u.childSObject!==void 0&&!t.inCheckpoint.has(u.childSObject.toLowerCase())),m=a.filter(u=>u.childSObject!==void 0&&t.worked?.has(u.childSObject)===!0);return{...i,outside:{all:a.length,worked:m.length}}}function ge(e,t){return e?.get(t)??{dependents:Le,cascades:Le}}function Jt(e,t){if(e<Ee||t===Lt||t===Ft)return d(V([{rows:e}]),T);let n=Math.ceil(e/Ce),r=Math.ceil(e/n),o=R;for(let i=e;i>0;i-=r){let a=Math.min(i,r);o=l(o,{apiRequests:we({stateReads:Se(a)}),seconds:ke(a)})}return o}function fe(e,t=Number.POSITIVE_INFINITY){let n=e.filter(r=>r.records>0);return n.length===0?R:l(d(Pt,b),...n.map(({records:r,dependents:o,objectApiName:i})=>{let a=E(r),m=0;for(let c=r;c>0;c-=t)Math.min(c,t)>x&&m++;let u=m*o;return l(d(1,b),d(a,O),d(u+o*a,pe),Yt(i,a,u+o*a),Jt(r,i))}))}function zt(e,t,n){return l(...e.filter(({count:r})=>r>0).map(({objectApiName:r,count:o})=>{let{dependents:i}=ge(t,r),a=o>x?i:0;return l(d(n.has(r)?0:1,j),d(a+i*E(o),pe))}))}function Yt(e,t,n){return e===void 0||K[e]===void 0||Re.has(e)?R:l(d(1,b),d(t,O),d(n,pe),d(t,T))}function N(e){return e.toDelete.createdSince+e.toDelete.broughtBackSince}function z(e){return e.toBringBack.inBin+e.toBringBack.deletedWhileTaken+Z(e)}function Z(e){return e.toBringBack.carriers??0}function L(e){return e.toDelete.comesBackWithParent+Z(e)}function Y(e){return e.cannotUndo.filter(t=>t.reason==="deletedWithCreatedParent"||t.reason==="deletedWithParentOutside").reduce((t,n)=>t+n.count,0)}function X(e){return z(e)-Z(e)+e.toBringBack.withParent}function Ze(e){return e.toGiveBack.records+e.toBringBack.inBin+e.toBringBack.withParent}function me(e){return e.cannotUndo.filter(t=>t.reason==="goneForGood").reduce((t,n)=>t+n.count,0)}function _(e){return e.toRecreate??0}function Xt(e){return me(e)+_(e)}function Zt(e,t){let n=0;for(let r=e;r>0&&t>0;r-=v){let o=Math.min(r,v);n+=p(t*E(o),S)}return n}function et(e,t,n){let r=Xt(e);return{objectApiName:e.objectApiName,live:e.toGiveBack.records+e.touched+N(e)+e.unexplained,deleted:X(e)+L(e)+Y(e),valued:e.toGiveBack.records+e.touched+e.toBringBack.withParent,backTo:X(e)+Z(e)+Y(e)>0||t.undeletable===!1&&r>0,deletes:N(e),scans:r>0&&t.undeletable!==!1,whole:e.schemaDrift!==void 0,outside:n?.get(e.objectApiName)?.outside??{all:e.outside.length,worked:e.outside.length}}}function en(e,t,n,r){let o=et(e,t,n),i=e.toBringBack,a=r?0:L(e);return{...o,live:e.toGiveBack.records+e.touched+e.unexplained+X(e)+_(e)+a,deleted:N(e)+L(e)-a+Y(e),valued:e.toGiveBack.records+e.touched+i.inBin+i.withParent+_(e),backTo:Y(e)>0||t.undeletable===!1&&me(e)>0,scans:me(e)>0&&t.undeletable!==!1,deletes:a}}function tt(e,t,n,r,o,i=0,a,m=0){let u=[],c=[],g=0,y=0,A=0,h=!1,B=0;for(let{objectApiName:s,records:f,fields:w}of e){let k=t.get(s);if(k===void 0){n.has(s)&&u.push({objectApiName:s,live:0,deleted:0});continue}u.push({objectApiName:s,live:k.live,deleted:k.deleted}),g+=Q(k.valued,w),k.backTo&&!k.whole&&y++,k.scans&&c.push(H([$(f)])),k.deletes!==0&&(!k.whole&&!k.backTo&&A++,k.outside.all>0&&(h=!0),B+=Zt(k.deletes,k.outside.worked))}a!==void 0&&(h=!0);let C=a!==void 0?1:0,F=o===void 0?p(e.length+C,I):p(o.first+C,I)+p(o.later,I);return l(d(Tt,b),d(F,j),Ht({objects:e.length,held:e.filter(s=>s.records>0).map(s=>s.objectApiName),moved:u}),d(g,O),d(p(y,I),j),d(A,b),d(h?1:0,j),d(B,b),d(i,b),d(m,b),d(a?.requests??0,O),...c,d(p(p(r,Nt),S),b))}function nt(e){return e.files!==void 0?{requests:e.filesRequests??0}:void 0}function rt(e,t){let n=new Map(e.diff.objects.map(o=>[o.objectApiName,o])),r=new Map;for(let o of e.objects){let i=n.get(o.objectApiName);i&&r.set(o.objectApiName,t(i,o))}return r}function tn(e){let t=new Set(e.diff.objects.flatMap(n=>Object.keys(n.lastChangedBy)));return tt(e.objects,rt(e,(n,r)=>et(n,r,e.relationships)),new Set(e.diff.unread.map(n=>n.objectApiName)),t.size,e.diff.described,e.diff.parentsOutsideRequests??0,nt(e.diff),e.diff.fieldsRequests??0)}function qe(e,t,n=!1){let r=!t&&(n||e.diff.objects.some(i=>L(i)>0)),o=e.diff.described;return tt(e.objects,rt(e,(i,a)=>en(i,a,e.relationships,t)),new Set(e.diff.unread.map(i=>i.objectApiName)),r?1:0,o===void 0?void 0:{first:o.first+o.later,later:0},e.diff.parentsOutsideRequests??0,nt(e.diff),e.diff.fieldsRequests??0)}function nn(e){return l(...e.filter(t=>t>0).map(t=>l(d(1,b),d(E(t),T))))}var rn=new Set(["activateddate","activatedbyid"]);function on(e){return l(...e.filter(({objectApiName:t,records:n})=>n>0&&K[t]!==void 0).map(({records:t})=>l(d(1,b),d(E(t),T))))}function sn(e,t){return e*ht+t*Ke}function Ge(e){return l(d(Je,b),d(Ye(e),O),d(1,T),d(1,O))}function an(e,t,n,r){if(t===0)return R;let o=e==="Order"?n.find(c=>c.toLowerCase()==="status"):void 0,i=o===void 0?[]:[o],a=c=>l(le(c,n),o?le(c,i):R),m=l(Ge(n),o?Ge(i):R),u=d(Q(t,n),O);return l(a(t),r.held?l(u,m):R,r.held&&r.twice?l(a(t),m):R,r.nextPass?l(u,m):R)}function He(e,t,n,r){let o=r?.get(n.objectApiName)?.cascadeChildren;return o!==void 0?o.includes(t):e?.cascadeParents!==void 0&&e.cascadeParents.length===0?!1:e?.readOrder!==void 0&&n.readOrder!==void 0?e.readOrder<n.readOrder:!0}function dn(e){let t=e.diff.objects,n=new Map(e.objects.map(s=>[s.objectApiName,s])),r=s=>ge(e.relationships,s),o=e.diff.undoCannot?e.diff.undoCannot.reduce((s,{objectApiName:f,count:w})=>s.set(f,(s.get(f)??0)+w),new Map):void 0,i=e.diff.withParentDeleted?new Map(e.diff.withParentDeleted.map(({objectApiName:s,count:f})=>[s,f])):void 0,a=s=>{if(i!==void 0)return Math.max(0,N(s)-(i.get(s.objectApiName)??0));if(o===void 0||n.get(s.objectApiName)?.undeletable!==!1)return N(s);let f=(o.get(s.objectApiName)??0)-s.toDelete.comesBackWithParent;return Math.max(0,Math.min(N(s),f))},m=t.filter(s=>a(s)>0),u=t.filter(s=>L(s)>0),c=(s,f)=>f.some(w=>w.objectApiName!==s.objectApiName&&He(n.get(w.objectApiName),w.objectApiName,s,e.relationships)),g=(s,f)=>f.some(w=>{let k=n.get(w.objectApiName);return k!==void 0&&w.objectApiName!==s.objectApiName&&He(s,s.objectApiName,k,e.relationships)}),y=t.reduce((s,f)=>s+E(z(f)),0),A=e.reusesPreview!==!0&&t.some(s=>N(s)>0&&(e.relationships?.get(s.objectApiName)?.outside?.all??s.outside.length)>0),h=t.some(s=>z(s)>0&&r(s.objectApiName).cascades>0),B=l(d(h&&!A?1:0,j),Qt(t.map(s=>({records:z(s),cascades:r(s.objectApiName).cascades,described:e.reusesPreview!==!0}))),...t.map(s=>Kt(s.toBringBack.withParent,r(s.objectApiName).cascades,y,e.reusesPreview!==!0)),...t.map(s=>{let f=n.get(s.objectApiName);return f===void 0?R:an(s.objectApiName,Ze(s),f.fields,{held:c(f,m),twice:g(f,m),nextPass:c(f,u)})}),nn(t.map(_)),on(t.map(s=>({objectApiName:s.objectApiName,records:_(s)}))),fe(t.map(s=>({objectApiName:s.objectApiName,records:a(s),dependents:r(s.objectApiName).dependents})),re)),C=t.flatMap(s=>{let f=n.get(s.objectApiName),w=_(s);return w===0||f===void 0?[]:K[s.objectApiName]===void 0?[]:f.fields.some(k=>rn.has(k.toLowerCase()))?[le(w,f.fields)]:[]}),F=u.length>0||C.length>0?l(fe(u.map(s=>({objectApiName:s.objectApiName,records:L(s),dependents:r(s.objectApiName).dependents})),re),...C,qe(e,!0)):R;return l(d(_t,b),B,un(e.diff.files),qe(e,!1,C.length>0),F)}function cn(e){return e===void 0?0:e.unlink+e.relink+e.updateLinks}function un(e){return e===void 0?R:d(p(e.unlink,ue)+p(e.relink,ue)+p(e.updateLinks,ue),T)}function tr(e){let t=e.diff.objects,n=t.reduce((g,y)=>g+N(y)+y.toDelete.comesBackWithParent,0),r=t.reduce((g,y)=>g+y.toGiveBack.records,0),o=t.reduce((g,y)=>g+X(y),0),i=t.reduce((g,y)=>g+_(y),0),a=n+r+o+i,m=l(d(Ve+vt(e.diff),b),e.reusesPreview===!0?R:tn(e)),u=e.diff.files;if(a===0&&cn(u)===0)return{records:0,apiRequests:m.apiRequests,seconds:Math.ceil(m.seconds),bytes:0};let c=l(m,d(e.automationRequests,O),d(e.deliverabilityRequests??0,b),dn(e));return{records:a,apiRequests:c.apiRequests,seconds:Math.ceil(c.seconds),bytes:sn(t.reduce((g,y)=>g+Ze(y),0),n+o+2*i)+ln(u)}}function ln(e){return e===void 0?0:e.unlink*Fe+e.relink*Ke+e.updateLinks*Fe}var fn=1;function Qe(e,t){let n=R;for(let r=e;r>0;r-=v){let o=Math.min(r,v);n=l(n,d(fn,b),d(Q(o,t),O),d(V([{rows:o}]),T))}return n}function mn(e,t){let n=Math.min(e.givenBackHeld??0,e.givenBack),r=R;for(let o=e.givenBack;o>0;o-=v)r=l(r,d(Q(Math.min(o,v),t),O));return l(Qe(n,t),Qe(e.givenBack-n,t),r)}var pn=2;function gn(e){let t=Math.min(e.givenBackHeld??0,e.givenBack);return d(E(e.givenBack)+E(t)+E(e.givenBack-t),O)}function nr(e){let t=new Map(e.objects.map(c=>[c.objectApiName,c.fields])),n=e.rewound.reduce((c,g)=>c+g.deleted+g.broughtBack+g.givenBack,0),r=d(Ve,b);if(n===0)return{records:0,apiRequests:r.apiRequests,seconds:Math.ceil(r.seconds),bytes:0};let o=e.rewound.some(c=>c.deleted>0),i=e.rewound.some(c=>c.givenBack>0),a=new Set(e.rewound.filter(c=>c.broughtBack>0).map(c=>c.objectApiName)),m=o&&i?l(d(pn,b),...e.rewound.map(gn)):R,u=l(r,d(e.automationRequests,O),m,fe(e.rewound.map(c=>({objectApiName:c.objectApiName,records:c.broughtBack,dependents:ge(e.relationships,c.objectApiName).dependents}))),a.size>0?zt(e.along??[],e.relationships,a):R,Xe(e.rewound.map(c=>c.deleted)),...e.rewound.map(c=>mn(c,t.get(c.objectApiName)??[])));return{records:n,apiRequests:u.apiRequests,seconds:Math.ceil(u.seconds),bytes:0}}var bn={take:{what:"This checkpoint",then:"Take it once the org has requests to spare \u2014 the limit is counted over the last 24 hours \u2014 or pick fewer objects.",done:"No record was read."},rewind:{what:"This rewind",then:"Rewind once the org has requests to spare \u2014 the limit is counted over the last 24 hours.",done:"No record was read or written."},undo:{what:"This undo",then:"Undo the rewind once the org has requests to spare \u2014 the limit is counted over the last 24 hours \u2014 while the recycle bin still holds what it brings back.",done:"No record was read or written."}},hn=W({FileStorageMB:W({Max:ee(),Remaining:ee()}).loose()}).loose();async function rr(e,t){let n,r;try{n=await e.request({method:"GET",url:"/limits"}),r=await ve({request:()=>Promise.resolve(n)})}catch(a){throw new Error(`${t} did not say how many API requests it has left today: ${P(a)}`)}let o;try{o=await Ne({request:()=>Promise.resolve(n)})}catch(a){o={unread:P(a)}}let i=hn.safeParse(n);return{...r,emails:o,...i.success?{fileStorage:{max:i.data.FileStorageMB.Max,remaining:i.data.FileStorageMB.Remaining}}:{}}}var Rn={deliverability:e=>`to read whether ${e} delivers its emails`};function yn(e,t){if(e===void 0)return"";let n=Object.entries(Rn).flatMap(([r,o])=>{let i=e[r]??0;return i>0&&o?[{requests:i,words:o(t)}]:[]}).map(({requests:r,words:o},i)=>`${r}${i===0?" of them":""} ${o}`);return n.length>0?` (${n.join(", ")})`:""}function or(e,t,n,r){let o=Te(t,n);if(o.verdict!=="exceeds")return;let i=bn[e];return{code:"API_BUDGET",message:`${i.what} takes about ${o.estimate} API requests${yn(o.parts,r)}; ${r} has ${n.remaining} of its ${n.max} left today. ${i.then} ${i.done}`}}var On={rewind:{then:"Free file storage, then rewind again.",done:"Nothing was written."},undo:{then:"Free file storage, then undo the rewind again while the recycle bin still holds them.",done:"Nothing was written."}};function wn(e){let t=e/1048576;return t<1?`${Math.max(1,Math.round(t*10))/10} MB`:`${Math.ceil(t)} MB`}function ir(e,t,n,r){if(n===void 0||t.files===0||t.bytes<=n*1048576)return;let o=On[e];return{code:"FILE_STORAGE",message:`Bringing back ${t.files===1?"1 file":`${t.files} files`} takes ${wn(t.bytes)} of file storage; ${r} has ${n} MB left. ${o.then} ${o.done}`}}export{Sn as a,En as b,Cn as c,An as d,Bn as e,vn as f,Tn as g,Nn as h,_n as i,ie as j,Pn as k,De as l,xn as m,In as n,Me as o,kt as p,xt as q,b as r,Mt as s,T as t,Xn as u,Zn as v,er as w,dn as x,tr as y,nr as z,rr as A,or as B,ir as C};
|
package/lib/chunk-ZE6HKRR4.mjs
DELETED
|
@@ -1,9 +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 s}from"./chunk-6MUEPV7M.mjs";import{a,b as d}from"./chunk-RH3N2H7P.mjs";import{a as g}from"./chunk-ZLZRU6MO.mjs";function f(t,n,o){if(!d(n))return;let e=n.edition?`IsSandbox false, edition ${n.edition}`:"IsSandbox false, and no edition",r=o.action==="write"?`${o.tool} writes to sandboxes and Developer Edition orgs only. Nothing was written`:`${o.tool} deletes from sandboxes and Developer Edition orgs only. Nothing was deleted`;return`${t} is a production org (its Organization record says ${e}): ${r}; ${o.readOnly}, which only reads, runs against it.`}function c(t){let{errorCode:n,statusCode:o}=typeof t=="object"&&t!==null?t:{},e=t instanceof Error?t.message:String(t);return o===403||typeof n=="string"&&/^INSUFFICIENT_ACCESS/.test(n)||/\bINSUFFICIENT_ACCESS/.test(e)||(n==="INVALID_TYPE"||/\bINVALID_TYPE\b/.test(e))&&/\bOrganization\b/.test(e)}function p(t,n,o){let e=n instanceof Error?n.message:String(n),r=`Nothing was ${o.action==="write"?"written":"deleted"}.`,i=`${o.tool} ${o.action==="write"?"writes to":"deletes from"} no org it cannot tell from a production one`;return s(n)?`${t} refused the session sf gave for it (${e}), and ${i}. "sf org display --target-org ${t}" says what sf holds for it; "sf org login web --alias ${t}" signs in again (in a CI job, "sf org login jwt" or "sf org login sfdxurl"); then run the command again. ${r}`:g(n)?`${t} did not answer (${e}), and ${i}. Run the command again once it answers. ${r}`:c(n)?`${t} would not show its Organization record (${e}), and ${i}. Reading it takes the View Setup and Configuration permission: give it to the user the alias signs in as, or name an alias of a user who has it. ${r}`:`${t} did not say what org it is (${e}), and ${i}. ${r}`}var u=1;async function y(t,n,o){let e;try{e=await a(t)}catch(i){process.stderr.write(`${p(n,i,o)}
|
|
8
|
-
`),process.exit(u)}let r=f(n,e,o);return r!==void 0&&(process.stderr.write(`${r}
|
|
9
|
-
`),process.exit(u)),e}export{y as a};
|
package/lib/chunk-ZLZRU6MO.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 Me}from"./chunk-WIO4XO4F.mjs";import{a as xn}from"./chunk-EADHKH3A.mjs";import{c as Pn,g as le,h as Ce,j as vn}from"./chunk-GCOB7K5N.mjs";import{a as $,c as ee}from"./chunk-INIT2UKJ.mjs";import{d as In}from"./chunk-CGWXQX75.mjs";import{a as X,h as C}from"./chunk-TZE3Y7IQ.mjs";import{b as j}from"./chunk-CA5NAXSU.mjs";import{Ab as Rn,Bb as bn,Cb as Tn,Eb as L,Fb as Y,Hc as On,Ic as An,Jc as En,K as hn,Kc as Fn,Mb as Sn,Nb as V,Ob as D,Xc as kn,Yc as Nn,zb as wn}from"./chunk-B45CNPUX.mjs";import{b as Q,e as yn,i as ce,k as de,l as Z,s as ve}from"./chunk-7EANH5PY.mjs";var ue=["ENOTFOUND","ECONNREFUSED","ETIMEDOUT","ECONNRESET","EAI_AGAIN","ENETUNREACH","EHOSTUNREACH"];function Cn(e){if(typeof e=="object"&&e!==null){let{code:t,name:r,cause:o}=e;if(typeof t=="string"&&ue.includes(t)||r==="TimeoutError"||o!==void 0&&Cn(o))return!0}let n=j(e);return ue.some(t=>n.includes(t))||n.includes("fetch failed")?!0:/\btimed out\b/i.test(n)}function je(e){let{code:n}=typeof e=="object"&&e!==null?e:{};if(typeof n=="string"&&ue.includes(n))return n;let t=j(e),r=ue.find(o=>t.includes(o));if(r!==void 0)return r;if(/socket hang up/i.test(t))return"socket hang up";if(Cn(e))return/\btimed out\b/i.test(t)?"timed out":"no connection"}function Ao(e){return typeof e.unread=="string"?je(e.unread):e.unread.find(n=>n.unreachable!==void 0)?.unreachable}var Dt=/^[A-Za-z][A-Za-z0-9_]{0,79}$/;function Mn(e,n){return typeof e=="object"&&e!==null?e[n]:void 0}function jn(e){return Array.isArray(e)?e.filter(n=>typeof n=="object"&&n):[]}function $n(e){return typeof e=="string"&&Dt.test(e)?e:void 0}function _n(e){let n=new Map;for(let r of jn(Mn(e,"variables"))){let o=r.name,s=$n(r.objectType);typeof o=="string"&&s&&n.set(o.toLowerCase(),s)}let t=[];for(let r of jn(Mn(e,"recordCreates"))){let o=r.inputReference,s=$n(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 Ln={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 No(e,n){let t=new Map,r=n!==void 0&&Object.prototype.hasOwnProperty.call(Ln,n)?Ln[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 qt=new Set;function Bt(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 Gt(e){return typeof e=="boolean"?String(e):typeof e=="string"&&e!==""?e:void 0}function Ut(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 Wt(e,n,t,r,o,s,i){let d=new Set(o.values),l=d,a,u=r.controllerName?Gt(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),Ut(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 Io(e,n,t,r,o=qt){let s=[];for(let i of Bt(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(...Wt(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 Vt="012000000000000AAA",fe="Master",Bn="";function xo(e,n){return e?.get(typeof n=="string"?n:Bn)}async function zt(e,n,t){try{return{picklists:await e(n,t)}}catch(r){return{error:j(r)}}}var Dn=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:Vt,developerName:fe},g=await this.readFor(o,n.objectApiName,f.targetId);this.keep(t,r,n.objectApiName,Bn,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=zt(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 Po(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 qn=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 Qt(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 vo(e){return e.length===0?"":`, picklist values not written as read: ${e.map(Qt).join("; ")}`}function Lo(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 Ht=new Set(["picklist_value_refused","picklist_value_absent","currency_inactive"]);function Vn(e){let n=hn(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"}:Ht.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 Do(e){let n=Vn(e);return"ignored"in n?n.ignored:void 0}function Gn(e,n,t){if(e===void 0)return!0;let r=n??fe;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=Ce(e,t,d=>d);return"found"in i&&i.found.namespacePrefix===s.namespacePrefix}function Kt(e){return e==null||e===""}var Un=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}))}},ge=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=Vn(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!==fe&&le(r).namespacePrefix===void 0)}holdsBack(n,t,r,o,s){for(let i of this.skipped.get(n)??[]){if(!Gn(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(!Gn(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)??[])Kt(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 qo(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=Wn(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=Wn(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 Wn(e,n,t,r){let o=Ce(n,t.filter(s=>!s.master),Me);if("found"in o)return{type:o.found};if("ambiguous"in o){let s=o.ambiguous.map(Me),i=s.find(d=>d.namespacePrefix);return{reason:vn(e,n,r,s)+(i?"; a package's is named with its namespace: "+Pn(i.namespacePrefix,i.developerName):"")}}return{reason:`${r} has no ${e} record type named ${n}`}}function Bo(e,n){return n.bySource.size===0?e?[...e]:void 0:[...(e??[]).filter(t=>!n.bySource.has(t.sourceId)),...n.mappings]}var $e=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 zn(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 $e(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 ge(e?.decisions),recordTypeDecisions:new Map}}var Zt="Id = NULL",qe="no parent in cache and not the root",Qn=class{build(n){let t=this.buildMeasured(n);return{...t,statements:_e(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?De({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 E=h?n.cache.scopeOf(I):n.cache.get(I);if(E)for(let O of E)R.add(O)}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}${Zt}`],scoped:!1,scope:"unscoped",reason:qe,parentObjectsUsed:[],scopeIdCount:0,byIdCount:1};let x=Hn({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 _e(Hn({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 _e(De({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 _e(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 Yt=500;function Be(e,n){let t=[...n].map(r=>`'${X(r)}'`).join(", ");return` AND (${e.field} IN (${t}))`}function Xt(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 er(e,n,t){let r=$(Be(e,[])),o=$(", "),s=[],i=[],d=r;for(let l of e.ids){let a=$(`'${X(l)}'`);if(i.length>0&&d+o+a>n&&(s.push(i),i=[],d=r),i.length===0&&r+a>n)throw Kn(t);d+=(i.length>0?o:0)+a,i.push(l)}return i.length>0&&s.push(i),s}function nr(e,n,t){let r=[""];for(let o of e){let s=er(o,n/e.length,t);r=r.flatMap(i=>s.map(d=>i+Be(o,d)))}return r}function Hn(e,n,t){let r=(l,a)=>De({prefix:e.prefix,suffix:l,wrap:l!=="",objectApiName:e.objectApiName},a),o=t.map(l=>Be(l,l.ids)).join(""),s=14e3-$(`${e.prefix}()${e.extraSuffix}`);if($(o)<=s/2)return r(`${o}${e.extraSuffix}`,n);let i=new Map;for(let l of n){let a=t.filter(g=>!Xt(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 nr(l.needed,s/2,e.objectApiName))d.push(...r(`${a}${e.extraSuffix}`,l.clauses));return d}function Kn(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 De(e,n){let t=e.wrap?"(":"",r=e.wrap?")":"",o=$(e.prefix+t+r+e.suffix),s=$(", "),i=$(" 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=$(`${g.field} IN ()`),w=!1;for(let T of g.ids){let S=`'${X(T)}'`,b=$(S),x=w?s+b:(l.length>0?i:0)+p+b,N=a+x>14e3||u>=Yt;if(l.length>0&&N&&(f(),w=!1,x=p+b),l.length===0&&a+x>14e3)throw Kn(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",Ue=[L,H,V,D,Y,"ProductCategory","ProductCatalog"],es=new Set(Ue);function ns(e,n){return wn(e,n.name,n.nillable)||e===L&&n.name===Sn}function Jn(e,n=new Set){let t=new Set(e.nodes.map(r=>r.objectApiName));return new Set(Ue.filter(r=>!t.has(r)&&!n.has(r)))}function ts(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 tr(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 rs(e,n){let t=Ge(e);return n?dr(t,n):t}function os(e,n,t){let r=Ue.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 Zn(e){return e.settable!==!1}function ss(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=>Rn(a)),d=s.some(a=>bn(a));if(i===Zn(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 is(e,n=[]){let t=e.edges.filter(Zn),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 Ge(e,t);let s=new Set(e.nodes.map(h=>h.objectApiName)),i=Ge(e,t),d=new Map(i.map((h,E)=>[h.objectApiName,E])),l=new Map,a=new Map,u=new Map,f=(h,E,O)=>{let _=h.get(E)??new Set;_.add(O),h.set(E,_)};for(let h of r){let{sourceObject:E,targetObject:O}=h;E===O||!s.has(E)||!s.has(O)||(f(l,O,E),f(a,E,O))}for(let h of t){let{sourceObject:E,targetObject:O}=h;E===O||!s.has(E)||!s.has(O)||l.get(O)?.has(E)||f(u,O,E)}let g=new Map;for(let[h,E]of u)for(let O of E)f(g,O,h);let p=new Map,w=new Map;for(let{sourceObject:h,targetObject:E}of o)h===E||!s.has(h)||!s.has(E)||l.get(E)?.has(h)||(f(p,E,h),f(w,h,E));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,E)=>{for(let O of[S,b,d]){let _=O.get(h)??0,se=O.get(E)??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 O of N)(h===void 0||x(O,h))&&(h=O);if(h===void 0)break;N.delete(h),I.add(h);let E=k.get(h);E&&R.push(E);for(let O of a.get(h)??[]){let _=(T.get(O)??1)-1;T.set(O,_),_===0&&!I.has(O)&&N.add(O)}for(let O of w.get(h)??[])S.set(O,(S.get(O)??1)-1);for(let O of g.get(h)??[])b.set(O,(b.get(O)??1)-1)}for(let h of e.nodes)I.has(h.objectApiName)||R.push(h);return R}function as(e,n){return[[H,D],[V,D],[H,L],[V,L],[D,L],[Y,L],...n.map(r=>[L,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 rr=new Set(["Id","Name","CurrencyIsoCode","IsPersonAccount","IsActive","Status","IsWhat","IsInvitee","Response","RespondedDate",...Object.values(In).flat()]);function or(e,n){let t=new Set(n??[]);return e.filter(r=>r.queryable&&(!t.has(r.name)||r.isReference||rr.has(r.name))).map(r=>r.name)}function cs(e){let n=or(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===D&&e.node.objectApiName!==e.rootObjectApiName&&e.catalog?.has(D)){let s=ar(e.scopedBuilder,e.scopeCache,n,e.extraWhere);if(!s)return{kind:"skip",reason:qe};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 > ${ir(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 sr(t,s,o)}return{kind:"query",statements:t,...o}}function sr(e,n,t={}){return{kind:"query",statements:e.map(r=>`${r} LIMIT ${n+1}`),limit:n,...t}}function ir(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 ar(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:D,selectFields:t,split:{field:"Product2Id",ids:o},whole:{field:"ProductSellingModelId",ids:s},extraWhere:r})}function ds(e){return(e.byIdCount??0)<e.statements.length}async function ls(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 cr(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 us(e,n,t,r,o={}){cr(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 tr(u,l,s))e.add(f,[u])}}}function dr(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"}). Its record count is unknown, not zero \u2014 re-run discovery once the org answers for this object instead of re-including the node.`):new Error(`Cannot run scoped clone with root "${n}" excluded. Children referencing the root would orphan-nullify their FK silently. Either include the root node or switch to non-scoped mode.`);if(t===0)return e;let o=[...e],[s]=o.splice(t,1);return o.unshift(s),o}function Ge(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 Yn(e,n){let{records:t,pages:r}=await xn(e,n);return{records:t,requests:r}}var lr=25,it=15,ye=5,he=25,Ve=60,ze=20,Ts=6+Ve+ze+1+6+1+20,te=4,ur="SELECT ApiName, Label, TriggerType, RecordTriggerType, TriggerObjectOrEvent.QualifiedApiName, ActiveVersionId, HasAsyncAfterCommitPath FROM FlowDefinitionView WHERE IsActive = true AND TriggerType IN ('RecordBeforeSave', 'RecordAfterSave', 'RecordBeforeDelete')",fr="SELECT Name, NamespacePrefix, TableEnumOrId, EntityDefinition.QualifiedApiName, UsageBeforeInsert, UsageAfterInsert, UsageBeforeUpdate, UsageAfterUpdate, UsageBeforeDelete, UsageAfterDelete, UsageAfterUndelete FROM ApexTrigger WHERE Status = 'Active'",gr="SELECT ApiName, Label, TriggerObjectOrEvent.QualifiedApiName, ActiveVersionId FROM FlowDefinitionView WHERE IsActive = true AND ProcessType = 'Workflow'",pr="SELECT Id, Name, NamespacePrefix, TableEnumOrId FROM WorkflowRule",mr="SELECT Name, SobjectType FROM AssignmentRule WHERE Active = true",yr="SELECT DeveloperName, MasterLabel, SobjectType FROM DuplicateRule WHERE IsActive = true",hr="SELECT DeveloperName, NamespacePrefix FROM UserSetupEntityAccess WHERE KeyPrefix = '0CP'";function Xn(e){return`SELECT Metadata FROM Flow WHERE Id = '${e}'`}function wr(e,n){if(n.length>ye)throw new Error(`A Tooling composite holds ${ye} 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 Rr(e,n){if(n.length>he)throw new Error(`A Tooling composite retrieves ${he} records, not ${n.length}`);return{allOrNone:!1,compositeRequest:n.map(({sobject:t,id:r},o)=>{if(!G.test(r))throw new Error(`Not a record id: ${r}`);return{method:"GET",url:`${e}/tooling/sobjects/${t}/${r}`,referenceId:`r${o}`}})}}var me="PROCESSING_HALTED",br=Z({compositeResponse:de(Z({body:ce(),httpStatusCode:yn(),referenceId:Q()}).loose())}),Tr=Z({records:de(ve(Q(),ce()))}).loose(),Sr=ve(Q(),ce()),Or=de(Z({errorCode:Q().optional(),message:Q().optional()}).loose());function at(e,n,t,r,o){let s=br.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===me?{halted:!0}:{}}})}function Ar(e,n){return at(e,n,"q","query",t=>{let r=Tr.safeParse(t);return r.success?r.data.records:void 0})}function Er(e,n){return at(e,n,"r","retrieve",t=>{let r=Sr.safeParse(t);return r.success?[r.data]:void 0})}function Fr(e){return async n=>Er(await e.request({method:"POST",url:"/tooling/composite",body:JSON.stringify(Rr(`/services/data/v${e.version}`,n)),headers:{"Content-Type":"application/json"}}),n.length)}function Ss(e){return{query:async(n,t)=>{let r=await e(n);return Yn({query:async o=>r.query(o),queryMore:async o=>r.queryMore(o)},t)},toolingQuery:async(n,t)=>{let r=await e(n);return Yn({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(wr(`/services/data/v${r.version}`,t)),headers:{"Content-Type":"application/json"}});return Ar(o,t.length)},toolingRetrieves:async(n,t)=>Fr(await e(n))(t)}}async function kr(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:he,waiting:ye},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=j(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??me,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??me);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??me);return l}function Nr(e){return`SELECT Metadata FROM WorkflowRule WHERE Id = '${e}'`}function Ir(e){return`SELECT FlowVersionViewId, ApiName, ObjectType FROM FlowVariableView WHERE FlowVersionViewId IN (${e.map(t=>`'${t}'`).join(", ")})`}function xr(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 vr(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 Cr(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 G=/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/,Qe=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,Mr="myvariable_current",jr={RecordBeforeSave:"beforeSave",RecordAfterSave:"afterSave",RecordBeforeDelete:"beforeDelete"},$r={Create:"create",Update:"update",CreateAndUpdate:"createAndUpdate",Delete:"delete"},ct={onCreateOnly:"create",onAllChanges:"createAndUpdate",onCreateOrTriggeringUpdate:"createAndUpdate"},_r=[["UsageBeforeInsert","beforeInsert"],["UsageAfterInsert","afterInsert"],["UsageBeforeUpdate","beforeUpdate"],["UsageAfterUpdate","afterUpdate"],["UsageBeforeDelete","beforeDelete"],["UsageAfterDelete","afterDelete"],["UsageAfterUndelete","afterUndelete"]],Lr={emailAlert:"email",emailSimple:"email",customNotificationAction:"notification",outboundMessage:"outbound"},Dr={emailSimple:"SingleEmail",emailAlert:"DailyWorkflowEmails"},qr={Alert:"email",OutboundMessage:"outbound"},Br=new Set(["sms","mms","twilio","whatsapp","vonage","nexmo","messagebird","plivo","sinch"]);function Ze(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 F(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 Ye(e,n,t,r){return{apiName:e,label:n||e,timing:t,startsOn:r,condition:"notRead",permissions:[],paths:[],messages:[],switches:[]}}function Gr(e){let n=Ze(e.TriggerObjectOrEvent),t=jr[y(e.TriggerType)];if(!n||!t)return;let r=t==="beforeDelete"?"delete":$r[y(e.RecordTriggerType)]??"createAndUpdate",o=y(e.ActiveVersionId),s=Ye(y(e.ApiName),y(e.Label),t,r);return e.HasAsyncAfterCommitPath===!0&&(s.paths=[{kind:"async"}]),{objectApiName:n,id:G.test(o)?o:null,flow:s}}function Ur(e){let n=y(e.ActiveVersionId);return{objectApiName:Ze(e.TriggerObjectOrEvent),id:G.test(n)?n:null,flow:Ye(y(e.ApiName),y(e.Label),"afterSave","createAndUpdate")}}function Wr(e){let n=Ze(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:_r.filter(([o])=>e[o]===!0).map(([,o])=>o)}}}function et(e){return e.startsOn==="create"||e.startsOn==="createAndUpdate"?e.timing==="afterSave"?0:1:e.startsOn==="update"?2:3}function dt(e){let n=new Set(yt(JSON.stringify(e??null)).filter(o=>re(o)==="Permission").map(He));if(n.size===0)return[];let t=F(e,"filterFormula"),r=new Set((typeof t=="string"?oe(t):[]).filter(o=>re(o.reference)==="Permission"&&o.value===void 0).map(o=>He(o.reference)));return[...n].sort((o,s)=>o.localeCompare(s)).map(o=>({name:o,bypass:r.has(o)}))}function lt(e){return typeof e!="string"?[]:Rt(oe(e)).filter(n=>re(n.reference)!=="Permission").map(n=>({...n,where:"start",bypass:!0}))}var ut={permission:"Permission",setup:"Setup",user:"User",profile:"Profile",custommetadata:"CustomMetadata"},ft=String.raw`[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*`,gt=new RegExp(String.raw`\$(?:Permission|Setup|User|Profile|CustomMetadata)\.${ft}`,"gi"),K=String.raw`(?:\{!\s*)?(\$(?:Permission|Setup|User|Profile|CustomMetadata)\.${ft})\s*\}?`,Vr=new RegExp(`^${K}$`,"i"),zr=new RegExp(`^NOT\\s+${K}$`,"i"),pt=new RegExp(`^(?:${K}\\s*(==?|<>|!=)\\s*(TRUE|FALSE)|(TRUE|FALSE)\\s*(==?|<>|!=)\\s*${K})$`,"i"),nt=String.raw`("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')`,mt=new RegExp(`^(?:${K}\\s*(==?|<>|!=)\\s*${nt}|${nt}\\s*(==?|<>|!=)\\s*${K})$`,"i");function W(e){let n=e.indexOf("."),t=ut[e.slice(1,n).toLowerCase()];return t?`$${t}${e.slice(n)}`:e}function re(e){return ut[e.slice(1,e.indexOf(".")).toLowerCase()]}function He(e){return e.slice(e.indexOf(".")+1)}function yt(e){return[...new Set([...e.matchAll(gt)].map(n=>W(n[0])))]}var Qr=new RegExp(`^${gt.source}$`,"i");function ht(e){return typeof e=="string"&&Qr.test(e)}function we(e,n){return e.toLowerCase()===n.toLowerCase()}function wt(e){return e.slice(1,-1).replace(/\\(.)/g,"$1")}function Rt(e){let n=new Map;for(let t of e)n.set(`${t.reference.toLowerCase()}=${t.value??""}`,t);return[...n.values()]}function tt(e,n){return e.some(t=>we(t.reference,n.reference)&&t.value===n.value)}function oe(e){return Ke(e).flatMap(Hr)}function Xe(e){return Je(e).flatMap(Kr)}function Hr(e){let n=pt.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=mt.exec(e);if(t){let[,o,s,i,d,l,a]=t;return(s??l).startsWith("=")?[]:[{reference:W(o??a),value:wt(i??d)}]}let r=be(e,"NOT");if(r===void 0){let o=zr.exec(e);return o?[{reference:W(o[1])}]:[]}return Xe(r)}function Kr(e){let n=Vr.exec(e);if(n)return[{reference:W(n[1])}];let t=pt.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=mt.exec(e);if(r){let[,s,i,d,l,a,u]=r;return(i??a).startsWith("=")?[{reference:W(s??u),value:wt(d??l)}]:[]}let o=be(e,"NOT");return o===void 0?[]:oe(o)}function Ke(e){let n=bt(e),t=be(n,"AND");if(t)return Re(t,",").flatMap(Ke);let r=Re(n,"&&");return r.length>1?r.flatMap(Ke):[n]}function Je(e){let n=bt(e),t=be(n,"OR");if(t)return Re(t,",").flatMap(Je);let r=Re(n,"||");return r.length>1?r.flatMap(Je):[n]}function be(e,n){let t=new RegExp(`^${n}\\s*\\(([\\s\\S]*)\\)$`,"i").exec(e);return t&&Tt(t[1])?t[1]:void 0}function bt(e){let n=e.trim();for(;n.startsWith("(")&&n.endsWith(")")&&Tt(n.slice(1,-1));)n=n.slice(1,-1).trim();return n}function Tt(e){let n=0;for(let{char:t,quoted:r}of St(e))if(!r){if(t==="(")n++;else if(t===")"&&--n<0)return!1}return n===0}function Re(e,n){let t=[],r=0,o=0;for(let{char:s,index:i,quoted:d}of St(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*St(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 Jr(e){let n=F(e,"start");if(typeof n=="object"&&n!==null){let t=y(F(F(n,"connector"),"targetReference"))||void 0,r=M(F(n,"scheduledPaths")).map(o=>y(F(F(o,"connector"),"targetReference"))||void 0);return{name:t,everyPath:r.every(o=>o===t)}}return{name:y(F(e,"startElementReference"))||void 0,everyPath:!0}}function Zr(e,n){let t=e.leftValueReference,r=e.rightValue;if(ht(t)){let s=W(t);if(typeof F(r,"booleanValue")=="boolean")return[{reference:s}];let i=F(r,"stringValue");return typeof i=="string"?[{reference:s,value:i}]:[]}let o=typeof t=="string"?n.get(t):void 0;return o===void 0?[]:[...Xe(o),...oe(o)]}function Yr(e,n){let t=e.leftValueReference,r=typeof t=="string"?n.get(t):void 0;return yt([typeof t=="string"?t:"",y(F(e.rightValue,"elementReference")),r??""].join(" "))}function Xr(e,n,t){let{leftValueReference:r,operator:o,rightValue:s}=e;if(o!=="EqualTo"&&o!=="NotEqualTo")return"unknown";let i=o==="EqualTo",d=F(s,"booleanValue");if(ht(r)){if(!we(r,n.reference))return"unknown";if(typeof d=="boolean"&&n.value===void 0)return d===i?"true":"false";let u=F(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 tt(Xe(l),n)?a?"true":"false":tt(oe(l),n)?a?"false":"true":"unknown"}function eo(e,n,t){let r=M(e.conditions);if(r.length===0)return"unknown";let o=r.map(i=>Xr(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 no(e,n,t){for(let r of M(e.rules)){let o=eo(r,n,t),s=!y(F(r.connector,"targetReference"));if(o!=="false"){if(o==="true")return s;if(!s)return!1}}return!y(F(e.defaultConnector,"targetReference"))}function Ot(e){let n=M(F(e,"decisions")),t=new Map(M(F(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=>Yr(g,t))))];if(o.length===0)return{permissions:[],switches:[]};let{name:s,everyPath:i}=Jr(e),d=i?n.find(f=>y(f.name)===s):void 0,l=d?Rt(r(d).flatMap(f=>Zr(f,t))).filter(f=>no(d,f,t)):[],a=o.filter(f=>re(f)==="Permission").map(f=>({name:He(f),bypass:l.some(g=>we(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=>we(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 to(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 ro(...e){return e.some(n=>{let t=to(n);return t.some(r=>Br.has(r))||t.some((r,o)=>r==="text"&&/^messages?$/.test(t[o+1]??""))})}function At(e){return M(F(e,"actionCalls")).flatMap(n=>{let t=y(n.actionType),r=y(n.label)||y(n.name)||y(n.actionName),o=Lr[t],s=Dr[t];return o?[{kind:o,name:r,...s?{limit:s}:{}}]:t==="apex"&&ro(y(n.actionName),y(n.name),r)?[{kind:"sms",name:r,guessed:!0}]:[]})}function oo(e){return M(F(F(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 Et(e,n){let t=_n(n);t.length>0&&(e.creates=t)}function so(e,n){if(typeof n!="object"||n===null)return;let t=F(n,"start"),r=Ot(n);e.permissions=[...dt(t),...r.permissions],e.switches=[...lt(F(t,"filterFormula")),...r.switches],e.paths=oo(n),e.messages=At(n),Et(e,n)}function io(e,n){let t=new Map(M(F(n,"processMetadataValues")).map(o=>[y(o.name),y(F(o.value,"stringValue"))]));e.startsOn=ct[t.get("TriggerType")??""]??"createAndUpdate";let r=Ot(n);return e.permissions=r.permissions,e.switches=r.switches,e.messages=At(n),Et(e,n),t.get("ObjectType")||void 0}function ao(e,n){e.startsOn=ct[y(F(n,"triggerType"))]??"createAndUpdate";let t=F(n,"formula");e.permissions=typeof t=="string"?dt({filterFormula:t}):[],e.switches=lt(t);let r=M(F(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=[F(n,"actions"),...r.map(o=>o.actions)].flatMap(M).flatMap(o=>{let s=qr[y(o.type)];return s?[{kind:s,name:y(o.name),...s==="email"?{limit:"DailyWorkflowEmails"}:{}}]:[]}),F(n,"active")===!0}function Ft(e,n){return(e?`${e}__${n}`:n).toLowerCase()}function We(e,n){let t=je(n);return t===void 0?{part:e,reason:j(n)}:{part:e,reason:`the org could not be reached (${t})`,unreachable:t}}async function pe(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 rt=[L,H,V,D,Y],ot=["ProductCategory","ProductCatalog"];function co(e,n=new Set){let{referenceDataObjects:t}=zn(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(Tn).filter(([u,{object:f}])=>o.has(u)&&!s.has(f)&&!n.has(f)).map(([,{object:u}])=>u),d=Jn(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(rt);return[...new Set([...r,...i,...a?rt.filter(u=>d.has(u)):[],...l(ot)?ot.filter(u=>d.has(u)):[]])]}var st=class{deps;constructor(n){this.deps=n}async readForGraph(n,t,r=new Set){return this.read(n,co(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 A=await m();return s+=A.requests,A.records}catch(A){return s++,o.push(We(c,A)),[]}},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 pe([l("flows",a(ur)),l("triggers",u(fr)),l("processes",a(gr)),l("workflowRules",u(pr)),g?l("assignmentRules",a(mr)):f,l("duplicateRules",a(yr))],te),N=p.map(Gr).filter(c=>c!==void 0).flatMap(c=>{let m=d(c.objectApiName);return m?[{...c,objectApiName:m}]:[]}),k=w.map(Wr).filter(c=>c!==void 0).flatMap(c=>{let m=d(c.objectApiName),A=c.trigger.events.some(P=>P!=="afterUndelete"||r.undeletes===!0);return m&&A?[{...c,objectApiName:m}]:[]}),R=T.map(Ur),I=R.filter(c=>c.objectApiName===void 0&&c.id!==null).map(c=>c.id),h=t.filter(c=>c.includes("__")&&Qe.test(c)),E=S.some(c=>/^01I/.test(y(c.TableEnumOrId))),[O,_]=await pe([I.length>0?l("processes",a(Ir(I))):f,E&&h.length>0?l("workflowRules",a(xr(h))):f],te),se=new Map(O.filter(c=>y(c.ApiName).toLowerCase()===Mr).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 Nt=new Map(_.map(c=>[y(c.DurableId),y(c.QualifiedApiName)])),Te=S.flatMap(c=>{let m=y(c.TableEnumOrId),A=d(Nt.get(m)??m),P=y(c.Name),v=y(c.Id);if(!A||!P)return[];let q=y(c.NamespacePrefix),z=q?`${q}.${P}`:P;return[{objectApiName:A,id:G.test(v)?v:null,flow:Ye(z,z,"afterSave","createAndUpdate")}]}),Se=R.filter(c=>c.objectApiName===void 0||d(c.objectApiName)!==void 0),It=new Map(t.map((c,m)=>[c,m])),ie=c=>It.get(d(c.objectApiName)??"")??t.length,Oe=N.filter(c=>c.id!==null).sort((c,m)=>et(c.flow)-et(m.flow)||ie(c)-ie(m)||c.flow.label.localeCompare(m.flow.label)),J=this.deps.toolingQueries,Ae=J?this.deps.toolingRetrieves:void 0,en=Ae?he:ye,nn=J?Ve*en:lr,tn=J?ze*en:it,Ee=Oe.slice(0,nn),rn=[...Se.map(c=>({read:c,kind:"process"})),...Te.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)),on=rn.slice(0,tn),Fe,ke,sn=new Set,an=c=>c[0]?.Metadata,xt=(c,m)=>{c.flow.condition="read",so(c.flow,an(m))},Pt=(c,m)=>{c.flow.condition="unreadable",Fe??=m},vt=({read:c,kind:m})=>m==="process"?Xn(c.id):Nr(c.id),Ct=({read:c,kind:m},A)=>{let P=an(A);if(typeof P!="object"||P===null){c.flow.condition="unreadable";return}if(c.flow.condition="read",m==="process"){let v=io(c.flow,P);c.objectApiName??=v}else ao(c.flow,P)||sn.add(c.flow)},Mt=({read:c},m)=>{c.flow.condition="unreadable",ke??=m},cn=(c,m,A,P,v)=>c.map(q=>({soql:m(q),retrieve:A(q),take:z=>P(q,z),refused:z=>v(q,z)})),dn=cn(Ee,c=>Xn(c.id),c=>({sobject:"Flow",id:c.id}),xt,Pt),ln=cn(on,vt,({read:c,kind:m})=>({sobject:m==="process"?"Flow":"WorkflowRule",id:c.id}),Ct,Mt);J?s+=await kr(c=>J(n,c),[{queries:dn,requests:Ve},{queries:ln,requests:ze}],te,Ae&&(c=>Ae(n,c))):await pe([...dn,...ln].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(j(m))}}),te),Fe!==void 0&&o.push(We("conditions",Fe)),ke!==void 0&&o.push(We("definitions",ke));for(let c of[...N,...Se,...Te])c.id===null&&(c.flow.condition="unreadable");let un=Se.flatMap(c=>{let m=d(c.objectApiName);return m?[{...c,objectApiName:m}]:[]}),fn=Te.filter(c=>!sn.has(c.flow)),Ne=[...N,...un,...fn].flatMap(c=>c.flow.permissions),gn;if(Ne.length>0){let[c]=await pe([l("userPermissions",a(hr))],te);if(!o.some(m=>m.part==="userPermissions")){let m=new Set(c.map(A=>Ft(y(A.NamespacePrefix),y(A.DeveloperName))));gn=m;for(let A of Ne)A.held=m.has(A.name.toLowerCase())}}let pn=[...new Set(Ne.filter(c=>c.bypass&&c.held!==!0).map(c=>c.name))],Ie=pn.length>0?await lo(pn,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(Ie?.some(c=>c.permissionSets.length>0)){let{toolingQueries:c,toolingRetrieves:m}=this.deps;try{let{readValidationRuleBypasses:A}=await import("./chunk-X2PY6MWZ.mjs"),P=await A(v=>this.deps.toolingQuery(n,v),t,c&&(v=>c(n,v)),m&&(v=>m(n,v)));s+=P.requests,ae.validationRuleBypasses=P.rules.flatMap(v=>v.permissions.some(q=>gn?.has(q.toLowerCase()))?[]:[v]),P.notRead>0&&(ae.validationRulesNotRead=P.notRead)}catch(A){s++,ae.validationRulesUnread=j(A)}}let jt=c=>b.filter(m=>y(m.SobjectType).toLowerCase()===c.toLowerCase()).map(m=>({name:y(m.Name)})).sort((m,A)=>m.name.localeCompare(A.name)),$t=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,A)=>m.name.localeCompare(A.name)),_t=(c,m)=>c.label.localeCompare(m.label),xe=(c,m)=>c.filter(A=>A.objectApiName===m).map(A=>A.flow).sort(_t),Pe=new Map;for(let c of Oe.slice(Ee.length))Pe.set(c.objectApiName,(Pe.get(c.objectApiName)??0)+1);let mn=t.flatMap(c=>{let m=Pe.get(c);return m?[{objectApiName:c,flows:m}]:[]}),Lt=t.map(c=>({objectApiName:c,flows:xe(N,c),triggers:k.filter(m=>m.objectApiName===c).map(m=>m.trigger).sort((m,A)=>m.name.localeCompare(A.name)),processes:xe(un,c),workflowRules:xe(fn,c),assignmentRules:jt(c),duplicateRules:$t(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:Lt,unread:o,conditionsNotRead:Oe.length-Ee.length,conditionsBound:nn,...mn.length>0?{conditionsNotReadOn:mn}:{},definitionsNotRead:rn.length-on.length,definitionsBound:tn,...Ie?{bypassGrants:Ie}:{},...ae,requests:s}}};function B(e){return e.slice(0,15)}async function lo(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 Qe.test(S)&&(!T||Qe.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);G.test(w)&&i.set(Ft(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(vr(d)):[];if(t())return;let a=[...new Set(l.map(p=>y(p.ParentId)).filter(p=>G.test(p)))],u=new Map;for(let p of["SetupEntityAccess","ObjectPermissions"]){if(a.length===0)break;let w=await n(Cr(p,a));if(t())return;for(let T of w){let S=B(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);G.test(w)&&f.set(B(w),kt(y(p.NamespacePrefix),y(p.DeveloperName)))}let g=r&&a.length>0?await go(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||B(y(S.SetupEntityId))!==B(w))continue;let b=B(y(S.ParentId)),x=S.Parent,N=y(F(x,"Name"));if(!N||T.has(b))continue;let k=y(F(x,"NamespacePrefix"));T.set(b,{name:k?`${k}__${N}`:N,label:y(F(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 kt(e,n){return e?`${e}__${n}`:n}function uo(e){return`SELECT ParentId, SetupEntityId FROM SetupEntityAccess WHERE SetupEntityType = 'CustomPermission' AND ParentId IN (${e.map(t=>`'${t}'`).join(", ")})`}function fo(e){return`SELECT Id, DeveloperName, NamespacePrefix FROM CustomPermission WHERE Id IN (${e.map(t=>`'${t}'`).join(", ")})`}async function go(e,n,t){try{let r=await t(uo(e)),o=new Map(n),s=[...new Set(r.map(d=>y(d.SetupEntityId)).filter(d=>G.test(d)&&!o.has(B(d))))];if(s.length>0)for(let d of await t(fo(s))){let l=y(d.Id);G.test(l)&&o.set(B(l),kt(y(d.NamespacePrefix),y(d.DeveloperName)))}let i=new Map;for(let d of r){let l=B(y(d.ParentId)),a=o.get(B(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:j(r)}}}var po={insert:"on insert",update:"on update",delete:"on delete"},mo={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"}},yo={flow:e=>`flow "${e}"`,trigger:e=>`Apex trigger ${e}`,process:e=>`process "${e}"`,workflowRule:e=>`workflow rule "${e}"`},ho={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"},wo={email:"email",notification:"custom notification",outbound:"outbound message",sms:"text message"};function Ro(e){let n=e.guessed?" (guessed from the name of an Apex action)":"";return`${wo[e.kind]} "${e.name}"${n}`}function bo(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 To(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 So(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[mo[n][e.when],...s.length>0?[`SENDS MESSAGES: ${s.map(Ro).join(", ")}`]:[],...i.length>0?[`then after commit: ${i.map(bo).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(To),...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 Os(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 On(i)){let f=u.map(g=>`${yo[g.kind](g.name)} (${So(g,a).join("; ")})`);r.push(` ${po[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(Fn(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=En(e),s=An(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 kn(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?`: ${Nn(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??it} at most`);for(let{part:i,reason:d}of e.unread)r.push(` ${ho[i]} could not be read: ${d}`);return r.push(` read in ${e.requests} request(s) to ${n}`),r}export{Cn as a,je as b,Ao as c,No as d,Io as e,xo as f,Dn as g,Po as h,qn as i,Qt as j,vo as k,Lo as l,Do as m,Un as n,qo as o,Bo as p,zn as q,qe as r,Qn as s,Yt as t,H as u,Ue as v,es as w,ns as x,Jn as y,ts as z,tr as A,rs as B,os as C,Zn as D,ss as E,is as F,as as G,or as H,cs as I,sr as J,ds as K,ls as L,cr as M,us as N,Yn as O,lr as P,it as Q,ye as R,he as S,Ve as T,ze as U,Ts as V,ur as W,fr as X,gr as Y,pr as Z,mr as _,yr as $,hr as aa,Xn as ba,wr as ca,Rr as da,Ar as ea,Er as fa,Fr as ga,Ss as ha,kr as ia,Nr as ja,Ir as ka,xr as la,Pr as ma,vr as na,Cr as oa,dt as pa,lt as qa,Ot as ra,At as sa,oo as ta,Ft as ua,We as va,pe as wa,co as xa,st as ya,lo as za,uo as Aa,fo as Ba,Os as Ca};
|
package/lib/chunk-ZPYJPGDK.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 a,c as b,d as c}from"./chunk-BS5T3MOQ.mjs";import"./chunk-Y5CGXLUB.mjs";import"./chunk-3F5YMM2F.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-PNCONNFJ.mjs";import"./chunk-CGWXQX75.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-SIOZXPFG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-B45CNPUX.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{c as CycleFkPass,b as RecordsOwingAcrossParts,a as patchCycleFkUpdates};
|
package/lib/chunk-ZQOZ4EFW.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}from"./chunk-LV6G4XTK.mjs";import"./chunk-HJKM3E56.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-B45CNPUX.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{a as StepCancelledError,b as StepExecutor};
|
package/lib/chunk-ZUTYVST5.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
|
-
var u="CurrencyIsoCode",S="SELECT IsoCode, ConversionRate, DecimalPlaces, IsActive, IsCorporate FROM CurrencyType",I="SELECT Metadata FROM CurrencySettings",x="SELECT RunningUserEntityAccess.IsCreatable FROM EntityDefinition WHERE QualifiedApiName = 'DatedConversionRate'",D="SELECT IsoCode, ConversionRate, StartDate, NextStartDate FROM DatedConversionRate ORDER BY IsoCode, StartDate";function g(e){let n=typeof e=="string"&&e.trim()!==""?Number(e):e;return typeof n=="number"&&Number.isFinite(n)?n:void 0}function m(e){return e===!0||e==="true"}function E(e){let n=new Set,r=new Map,t=new Map,o;for(let d of e){let i=d.IsoCode;if(typeof i!="string"||i==="")continue;let a=g(d.ConversionRate);a!==void 0&&a>0&&r.set(i,a);let s=g(d.DecimalPlaces);s!==void 0&&s>=0&&t.set(i,s),(d.IsActive===void 0||m(d.IsActive))&&n.add(i),m(d.IsCorporate)&&(o=i)}if(!(n.size===0&&r.size===0))return{...o!==void 0?{corporate:o}:{},active:n,rates:r,decimals:t}}function C(e){return typeof e=="string"&&/^\d{4}-\d{2}-\d{2}/.test(e)?e.slice(0,10):void 0}function v(e){let n=new Map;for(let r of e){let t=r.IsoCode,o=C(r.StartDate),d=C(r.NextStartDate),i=g(r.ConversionRate);if(typeof t!="string"||t===""||!o||!d||i===void 0||i<=0)continue;let a=n.get(t)??[];a.push({start:o,next:d,rate:i}),n.set(t,a)}for(let r of n.values())r.sort((t,o)=>t.start.localeCompare(o.start));return n}async function B(e){if(e)try{let[n]=await e(I),r=n?.Metadata,t=typeof r=="object"&&r!==null?r.enableCurrencyEffectiveDates:void 0;return t===!0||t==="true"?!0:t===!1||t==="false"?!1:void 0}catch{return}}async function M(e){try{let[n]=await e(x),r=n?.RunningUserEntityAccess;return typeof r=="object"&&r!==null&&m(r.IsCreatable)}catch{return!1}}async function T(e,n){let r=await B(n);if(r===!1)return{};if(r===void 0&&!await M(e))return{unconfirmed:!0};try{let t=v(await e(D));return t.size>0?{dated:t}:{}}catch{return{unconfirmed:!0}}}async function R(e,n){let r;try{r=E(await e(S))}catch{return}if(!r)return;let{dated:t,unconfirmed:o}=await T(e,n);return{...r,...t?{dated:t}:{},...o?{datedUnconfirmed:!0}:{}}}async function A(e,n,r={}){let[t,o]=await Promise.all([R(e,r.source),R(n,r.target)]);return t&&o?{source:t,target:o}:void 0}var U={Opportunity:"CloseDate"};function _(e,n){let r=U[e],t=r!==void 0?C(n?.[r]):void 0;return r!==void 0&&t!==void 0?{field:r,on:t}:void 0}function l(e,n,r){if(r!==void 0){let o=e.dated?.get(n)?.find(d=>d.start<=r&&r<d.next);if(o)return{rate:o.rate,dated:!0}}let t=e.rates.get(n);return t===void 0?void 0:{rate:t,dated:!1}}function O(e,n,r,t){let{source:o,target:d}=r,i=l(o,e,t),a=l(d,n,t);if(i===void 0||a===void 0)return;let s=1,c=i.dated||a.dated,f=t!==void 0&&(o.datedUnconfirmed===!0&&!i.dated&&e!==o.corporate||d.datedUnconfirmed===!0&&!a.dated&&n!==d.corporate);if(o.corporate!==d.corporate){let y=d.corporate!==void 0?l(o,d.corporate,t):void 0,p=o.corporate!==void 0?l(d,o.corporate,t):void 0;if(y!==void 0)s=y.rate;else if(p!==void 0)s=1/p.rate;else return;c||=(y??p)?.dated===!0}return{factor:s*a.rate/i.rate,dated:c,unconfirmed:f}}function P(e,n,r,t){return O(e,n,r,t)?.factor}function F(e,n){let t=10**Math.max(0,Math.min(Math.trunc(n),15)),o=Math.abs(e)*t,d=Math.round(o+o*Number.EPSILON)/t;return e<0?-d:d}function q(e){return new Map(e.filter(n=>n.type==="currency").map(n=>[n.name,typeof n.scale=="number"&&n.scale>=0?n.scale:void 0]))}function k(e,n){if(typeof e=="string"&&n.active.has(e))return{to:e,chosenBy:"record-type-default"};if(n.corporate!==void 0&&n.active.has(n.corporate))return{to:n.corporate,chosenBy:"corporate"}}function Q(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 Y(e,n,r){let t=typeof n.read=="string"&&n.read!==""?n.read:void 0,o=e[u];if(t===void 0||typeof o!="string"||o==="")return;let{target:d}=r,i,a;if(n.pricedIn!==void 0&&d.active.has(n.pricedIn)){if(e[u]=n.pricedIn,n.pricedIn===t)return;i=n.pricedIn,a="lines"}else if(d.active.has(o)){if(o===t)return;i=o,a="decision"}else{let f=k(n.recordTypeDefault,d);if(!f)return;({to:i,chosenBy:a}=f),e[u]=i}let s=O(t,i,r,n.ratesOn?.on),c=w(e,n.currencyFields,s?.factor,d.decimals.get(i));return{from:t,to:i,chosenBy:a,fields:c,...s===void 0?{notConverted:!0}:{factor:s.factor},...s!==void 0&&i!==d.corporate?{atTargetRate:!0}:{},...s?.dated&&n.ratesOn?{datedBy:n.ratesOn.field}:{},...s?.unconfirmed&&n.ratesOn?{datedUnconfirmed:n.ratesOn.field}:{}}}function w(e,n,r,t){let o=[];if(r===void 0)return o;for(let[d,i]of n){let a=Q(e[d]);a!==void 0&&(e[d]=F(a*r,i??t??2),o.push(d))}return o}var h={OpportunityLineItem:"OpportunityId",OpportunityLineItemSchedule:"OpportunityLineItemId",OpportunitySplit:"OpportunityId",Quote:"OpportunityId",QuoteLineItem:"QuoteId",OrderItem:"OrderId",ContractLineItem:"ServiceContractId"};function j(e){return h[e]!==void 0}function z(e,n,r,t){let o=n[u];if(typeof o!="string"||o==="")return;let d=h[e];for(let i of d!==void 0?[d]:r){let a=n[i];if(typeof a!="string"||a==="")continue;let s=t(a);if(s&&s.from===o)return s}}function W(e,n,r){let{parent:t}=n;if(!t||n.read!==t.from)return;typeof e[u]=="string"&&(e[u]=t.to);let o=w(e,n.currencyFields,t.factor,r?.target.decimals.get(t.to));return{from:t.from,to:t.to,chosenBy:"parent",fields:o,...t.factor===void 0?{notConverted:!0}:{factor:t.factor},...t.atTargetRate?{atTargetRate:!0}:{},...t.datedBy!==void 0?{datedBy:t.datedBy}:{},...t.datedUnconfirmed!==void 0?{datedUnconfirmed:t.datedUnconfirmed}:{}}}var b=class{entries=new Map;get size(){return this.entries.size}add(n,r){if(!r)return;let t=[n,r.from,r.to,r.chosenBy,r.notConverted?"kept":"",r.datedBy??"",r.datedUnconfirmed??""].join("\0"),o=this.entries.get(t);if(o){o.entry.rows++;for(let d of r.fields)o.fields.add(d);return}this.entries.set(t,{entry:{objectApiName:n,from:r.from,to:r.to,chosenBy:r.chosenBy,rows:1,fields:[],...r.notConverted?{notConverted:!0}:{},...r.atTargetRate?{atTargetRate:!0}:{},...r.datedBy!==void 0?{datedBy:r.datedBy}:{},...r.datedUnconfirmed!==void 0?{datedUnconfirmed:r.datedUnconfirmed}:{}},fields:new Set(r.fields)})}list(){return[...this.entries.values()].map(({entry:n,fields:r})=>({...n,fields:[...r].sort()}))}};function L(e){switch(e.chosenBy){case"decision":return"as decided";case"record-type-default":return`the default of their record type, ${e.from} not being active in the target`;case"corporate":return`the target's corporate currency, ${e.from} not being active there`;case"parent":return"the currency of the record they belong to";case"lines":return"the currency of the records their lines belong to"}}function N(e){if(e.notConverted)return`amounts written as read: no rate converts ${e.from} into ${e.to}`;if(e.fields.length===0)return"no amount to convert";let n=e.atTargetRate?`at the source's rate for ${e.from} and the target's for ${e.to}`:"at the source's rates",r=e.datedBy!==void 0?`, dated by ${e.datedBy}`:e.datedUnconfirmed!==void 0?`, the static ones: dated rates by ${e.datedUnconfirmed} could not be confirmed`:"";return`amounts converted ${n}${r} (${e.fields.join(", ")})`}function $(e){return`${e.rows} row(s) in ${e.from} written in ${e.to}, ${L(e)}: `+N(e)}function G(e){return e.length===0?"":`, written in another currency: ${e.map($).join("; ")}`}export{u as a,S as b,I as c,x as d,D as e,E as f,v as g,R as h,A as i,U as j,_ as k,P as l,F as m,q as n,k as o,Y as p,h as q,j as r,z as s,W as t,b as u,$ as v,G as w};
|
package/lib/chunk-ZYEE34WO.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}from"./chunk-KLX67VPL.mjs";import"./chunk-5CD257T7.mjs";import"./chunk-RH3N2H7P.mjs";import"./chunk-PA3MKJVH.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-B45CNPUX.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{a as grantsByObject,b as guardCheckpoint};
|