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
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{j as c}from"./chunk-DPYTG6DM.mjs";var a=/__kav$/i,d="Campaign";function u(e){return a.test(e)?"Salesforce Knowledge is not turned on in it: tick Knowledge User on your user (Setup > Users), then enable it in Setup > Knowledge Settings":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 m(e){let n,t;return async s=>{n??=e.describeGlobal().then(o=>new Map(o.sobjects.map(i=>[i.name.toLowerCase(),i.createable===!0])));let r=(await n).get(s.toLowerCase());if(r===void 0){let o=u(s);return{access:"absent",...o?{reason:o}:{}}}return s===d&&(t??=l(e),!r||!await t)?{access:"readOnly",reason:b}:r?{access:"createable"}:{access:"readOnly"}}}async function j(e,n){let t=new Set;for(let{objectApiName:s,optional:r}of e.objects)if(r===!0)try{(await n(s)).access!=="createable"&&t.add(s)}catch{}if(t.size===0)return e;for(let s=!0;s;){s=!1;for(let r of e.objects)t.has(r.objectApiName)||c(r,e.relations).some(o=>t.has(o))&&(t.add(r.objectApiName),s=!0)}return{...e,objects:e.objects.filter(s=>!t.has(s.objectApiName)),...e.relations?{relations:e.relations.filter(({childObject:s,parentObject:r})=>!t.has(s)&&!t.has(r))}:{}}}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{m as a,j as b};
|
|
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{
|
|
7
|
+
import{H as p,d as u,k as d,z as h}from"./chunk-E2YJVSX6.mjs";import{b as c}from"./chunk-CA5NAXSU.mjs";import{db as a}from"./chunk-DPYTG6DM.mjs";import{randomBytes as E}from"node:crypto";import{open as k,readFile as b,rename as I,rm as T}from"node:fs/promises";import{dirname as l,join as m}from"node:path";var f="rewinds.ndjson",C=400,O=200;function P(e,n){return m(e,d(n),f)}function R(e){return m(l(e.dir),f)}async function y(e,n,t,i={maxLines:C,keptLines:O}){if(d(t.organizationId)!==n.organizationId)throw new p("invalid","A rewind is kept in its org\u2019s ledger, under its lock.");let r=a.safeParse(t);if(!r.success)throw new p("invalid","A line of the rewind ledger does not parse.");await h(l(e));let o=await w(e),x=o!==""&&!o.endsWith(`
|
|
8
8
|
`)?`
|
|
9
9
|
`:"",s=await k(e,"a",u);try{await s.writeFile(`${x}${JSON.stringify(r.data)}
|
|
10
10
|
`,"utf8"),await s.sync()}finally{await s.close()}L(o).length+1>i.maxLines&&await A(e,i.keptLines)}async function A(e,n){let t=L(await w(e)).slice(-n),i=`${e}.${process.pid}-${E(4).toString("hex")}.tmp`,r=await k(i,"wx",u);try{try{await r.writeFile(t.map(o=>`${o}
|
|
@@ -4,6 +4,6 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{A as n}from"./chunk-
|
|
7
|
+
import{A as n}from"./chunk-WZQEK4WT.mjs";var d="OTHER_ORG",f="RUN_WRITING";function R({code:e,message:r}){return`refused (${e}): ${r}`}function l({code:e,message:r},t="a real run"){return`${t} would be refused (${e}): ${r}`}function g(e){return e.length>0?{wouldBeRefused:e.map(({message:r})=>r),wouldBeRefusedCodes:e.map(({code:r})=>r)}:{}}function c(e,r,t=[]){let{tool:u,source:s,target:o,elapsedMs:i}=e;return`${JSON.stringify({tool:u,...s!==void 0?{source:s}:{},target:o,dryRun:e.dryRun===!0,refused:r,...t.length>0?{alsoRefused:t}:{},...e.apiRequests!==void 0?{apiRequests:e.apiRequests}:{},elapsedMs:i},null,2)}
|
|
8
8
|
`}function m(e,r){let{tool:t,action:u="remove",summary:s,target:o,elapsedMs:i}=e;return`${JSON.stringify({tool:t,action:u,summary:s,target:o,refused:r,elapsedMs:i},null,2)}
|
|
9
9
|
`}function p(e,r){let t=n.object({tool:n.literal(r),dryRun:n.literal(!1),refused:n.object({code:n.string().min(1),message:n.string()}),result:n.never().optional()}).safeParse(e);return t.success?t.data.refused:void 0}function y(e,r){let t=n.object({tool:n.literal(r),dryRun:n.literal(!0),refused:n.object({code:n.string().min(1),message:n.string()}),result:n.never().optional()}).safeParse(e);return t.success?t.data.refused:void 0}function w({code:e},r="remove"){return`is the summary of a run refused before its first write (${e}), which wrote nothing to the target: there is nothing of it to ${r}.`}export{d as a,f as b,R as c,l as d,g as e,c as f,m as g,p as h,y as i,w as j};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-5WGA5CZB.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as AGENT_CATALOG_API,b as AGENT_CATALOG_FIELDS,c as AGENT_TEST_NAME_FIELD,i as GUARD_TOPIC_NAMES,e as NO_AGENTFORCE_MESSAGE,d as NO_AGENT_MESSAGE,g as agentNamed,k as declaresVariable,h as proposedActions,j as proposedGuardTopic,f as readAgentCatalog};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{dc as P,hc as v,kc as S}from"./chunk-KOQV4WXC.mjs";import{a as A,b as E}from"./chunk-VV3B6IC3.mjs";import{b as R}from"./chunk-CA5NAXSU.mjs";import{Ed as h,Hd as c,sd as m}from"./chunk-DPYTG6DM.mjs";import{b,f,k as w,l as p}from"./chunk-WZQEK4WT.mjs";var k="Messaging.reserveSingleEmailCapacity(1);",M="System.NoAccessException: The organization is not permitted to send email",x=`/tooling/executeAnonymous?anonymousBody=${encodeURIComponent(k)}`,I=`/query?q=${encodeURIComponent("SELECT PermissionsEmailSingle FROM UserPermissionAccess")}`,L=3e4,$=p({compiled:f(),success:f(),compileProblem:b().nullish(),exceptionMessage:b().nullish()}).loose(),O=p({records:w(p({PermissionsEmailSingle:f().optional()}).loose())}).loose(),V={reading:{unread:"SandForge runs no Apex in a production org"},requests:0};function U(e){return e%1e3===0?`${e/1e3} s`:`${e} ms`}function T(e,n){return e instanceof A?`the org did not answer within ${U(n)}`:`the org refused it: ${R(e)}`}function _(e){let n=$.safeParse(e);if(!n.success)return{unread:"its answer is not one anonymous Apex gives"};let{compiled:t,success:s,compileProblem:r,exceptionMessage:i}=n.data;if(!t)return{unread:`it did not compile${r?`: ${r}`:""}`};if(s)return{level:"all"};let a=i?.trim();return a===M?{refused:!0}:{unread:a?`the org answered: ${a}`:"it failed, and the org did not say why"}}async function Y(e,n={}){let t=n.timeoutMs??L,s=u=>new E(t).withTimeout("forge:deliverability",()=>e.request({method:"GET",url:u})),r;try{r=await s(x)}catch(u){return{reading:{unread:T(u,t)},requests:1}}let i=_(r);if(!("refused"in i))return{reading:i,requests:1};let a="so the org's refusal does not say how it is set",d;try{d=await s(I)}catch(u){return{reading:{unread:`whether the user the run writes as may send email could not be read (${T(u,t)}), ${a}`},requests:2}}let l=O.safeParse(d),o=l.success?l.data.records[0]?.PermissionsEmailSingle:void 0;return o===!0?{reading:{level:"withheld"},requests:2}:{reading:{unread:o===!1?`the user the run writes as may not send email (Send Email), ${a}`:`the org did not say whether the user the run writes as may send email, ${a}`},requests:2}}async function F(e){let n=m(e.running,{applyAssignmentRules:e.applyAssignmentRules,writes:e.writes}),t=P(e.running.automation.unread??[],{applyAssignmentRules:e.applyAssignmentRules===!0}),s=t!==void 0?{sendersUnread:t}:{};if(n.length===0&&t===void 0)return{senders:n};let r;try{r=await e.read()}catch(i){r={reading:{unread:R(i)},requests:1}}return{senders:n,...s,read:r}}function N(e,n={}){let t=i=>`${i.objectApiName}\0${i.kind}\0${i.name}`,s=m(c(e,void 0,n.writes),n),r=new Set(m(c(e,h(e,n.writes),n.writes),n).map(t));return s.filter(i=>!r.has(t(i)))}function q(e,n){let t=new Set([...n.assigned,...n.held]);return{assign:e.assign.filter(s=>t.has(s.permissionSet))}}var z=["flows","processes","workflowRules"];async function Q(e){let{plan:n,writes:t,applyAssignmentRules:s,read:r,target:i,run:a}=e,d=typeof r.unread=="string"?void 0:r,l=s===!0?{applyAssignmentRules:s}:{},o=await F({running:d?c(d,n,t):{automation:{objects:[],unread:z.map(y=>({part:y,reason:String(r.unread)}))},firing:[]},...l,writes:t,read:e.readDeliverability}),u=e.mayMute===!0&&n===void 0&&d!==void 0&&o.senders.length>0?N(d,{...l,writes:t}):[],g=o.read?.reading;return{ofRun:o,gate:v({senders:o.senders,...o.sendersUnread!==void 0?{sendersUnread:o.sendersUnread}:{},...g!==void 0?{reading:g}:{},accepted:e.accepted,target:i,run:a,muteQuiets:u,keepsAddresses:e.keepsAddresses===!0}),afterLease:(y,D)=>{if(!(n===void 0||d===void 0))return S({planned:o.senders,held:m(c(d,q(n,y),t),{...l,writes:t}),...g!==void 0?{reading:g}:{},accepted:D,target:i,run:a})}}}export{L as a,V as b,Y as c,F as d,N as e,q as f,Q as g};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-NWVVCZUK.mjs";import"./chunk-HYBH5PFM.mjs";import"./chunk-OVOLG3AL.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-KNIRA333.mjs";import"./chunk-MNITSYI2.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as SCENARIO_SIDECAR_SUFFIX,f as compiledForSidecar,g as nodeScenarioSidecarFiles,j as readScenarioRunSidecar,c as scenarioPackFingerprint,d as scenarioRunSidecar,b as scenarioRunSidecarSchema,h as scenarioSidecarPath,e as withAgentChoice,i as writeScenarioRunSidecar};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{n as Ae,o as Ce}from"./chunk-ZWCRWF7E.mjs";import{e as k,f as $,g as Ee,l as v,m as Be}from"./chunk-ETT5GP4P.mjs";import{a as re}from"./chunk-SW2NUKQL.mjs";import{b as M}from"./chunk-BNO5GIJ6.mjs";import{$a as ve,Pb as je,bb as z,db as Te,f as ye}from"./chunk-KOQV4WXC.mjs";import{b as ne,f as we}from"./chunk-INIT2UKJ.mjs";import{k as Oe,l as Se,m as ke}from"./chunk-KRNFVAGC.mjs";import{da as V,ea as Re}from"./chunk-55LQD3Y3.mjs";import{b as I}from"./chunk-CA5NAXSU.mjs";import{b as be,e as K,f as te,k as he,l as D}from"./chunk-WZQEK4WT.mjs";function it(e){return e.keptChanged+e.keptDependents+e.refused+(e.notVisible??0)}function Cn(e,t){return t?"cancelled":e.every(n=>it(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 Bn(e){return e.status}function vn(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 Tn(e,t,n,r=!1){let o=R=>e.objects.reduce((B,C)=>B+R(C),0),i=o(R=>R.deleted),a=o(R=>R.alreadyGone),l=o(R=>R.keptChanged+R.keptDependents),u=o(R=>R.refused),c=o(R=>R.notVisible??0);if(i+a===0&&(!r||e.status==="cancelled"||l+u+c===0))return;let g=r?void 0:n,O=o(R=>R.platformCopies??0),E=e.status==="cancelled"?Math.max(0,t+O-i-a-l-u-c):0;return{removedAt:e.finishedAt,deleted:(g?.deleted??0)+i,alreadyGone:(g?.alreadyGone??0)+a,kept:l,refused:u,...E>0?{notReached:E}:{},...c>0?{notVisible:c}:{}}}function jn(...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 P(e,t,n=1/0){return[...new Set([...e,...t])].slice(0,n)}function _(e,t){return e===void 0&&t===void 0?void 0:(e??0)+(t??0)}function Ne(e,t){if(!(!e&&!t))return{count:(e?.count??0)+(t?.count??0),objects:P(e?.objects??[],t?.objects??[])}}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});continue}let o={notVisible:_(r.notVisible,n.notVisible),notReached:_(r.notReached,n.notReached),heldByAutomation:_(r.heldByAutomation,n.heldByAutomation),heldByAutomationAfterRun:_(r.heldByAutomationAfterRun,n.heldByAutomationAfterRun),heldByAutomationAlong:_(r.heldByAutomationAlong,n.heldByAutomationAlong),platformCopies:_(r.platformCopies,n.platformCopies)},i=P(r.automationHolders??[],n.automationHolders??[]),a=r.filesLeft||n.filesLeft?{count:(r.filesLeft?.count??0)+(n.filesLeft?.count??0),names:P(r.filesLeft?.names??[],n.filesLeft?.names??[],oe)}:void 0,l=Ne(r.tookAlong,n.tookAlong),u=Ne(r.cameAlong,n.cameAlong);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(([,c])=>c!==void 0)),heldBy:P(r.heldBy,n.heldBy),...i.length>0?{automationHolders:i}:{},unchecked:P(r.unchecked,n.unchecked),reasons:P(r.reasons,n.reasons,oe),...a?{filesLeft:a}:{},...l?{tookAlong:l}:{},...u?{cameAlong:u}:{}})}return[...t.values()]}function Dn(...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,l]of Object.entries(n.changedBy))o[a]=(o[a]??0)+l;let i=_(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:P(r.reasons,n.reasons,oe)})}return[...t.values()]}import{AsyncLocalStorage as st}from"node:async_hooks";var De=new Set(["delete","hardDelete"]),de=1e4,xe=5e4;function xn(e){switch(e){case"production":return;case"staging":return de;case"development":case"scratch":return xe}}var Ie=new st;function ie(){let e=Ie.getStore();return e?.live?e:void 0}async function In(e,t){let n={approved:e.approved,live:!0};try{return await Ie.run(n,t)}finally{n.live=!1}}var _e=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:ct(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=De.has(t.operation),o=this.isProductionOverridden(t.orgId);n.push(`Production operation: ${t.operation} on ${t.objectName} (${q(t.recordCount)} ${at(t)}${t.alsoWrites?`, plus ${t.alsoWrites}`:""})`);let i=this.options.questionWords??Me;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=De.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)>xe&&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 at(e){return e.operation==="deploy"?"components":"records"}var Mn="the related records the run adds",Me={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}: bring the change there through your release process, as a change set or a deployment from source control.`,deleteRefused:(e,t)=>e==="hardDelete"?`Permanently deleting records is not allowed in ${t}.`:`Deleting records is not allowed in ${t}.`},dt=new Set(["SeedData","SyncData","CloneData","AutopilotData"]);function ct(e,t,n=Me){let r=e.operation==="deploy"?"component":"record",o=dt.has(e.objectName)?"":` (${e.objectName})`,i=`${n.counted(r,e.recordCount)}${o}`,a=e.alsoWrites?n.besides(i,e.alsoWrites):i,l=t?n.org(e.orgTier,t,!0):n.org(e.orgTier,e.orgId,!1);return n.sentence(e.operation,a,l)}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 ut={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 lt(e){return e<=0?"0":Math.max(.1,Math.ceil(e/1048576*10-1e-9)/10).toFixed(1)}function $n(e,t=ut){let{estimate:n}=e,r=[t.cost({records:n.records,objects:e.objects.length,requests:n.apiRequests,seconds:Math.ceil(n.seconds),megabytes:lt(n.bytes),keepDays:e.keepDays})],o=(i,a)=>{for(let{objectApiName:l,reason:u}of i.slice(0,ae))r.push(a(l,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}var mt=300,ft=1024,pt=160,gt=500,Ke=40,bt=4,ht=3,Rt=3,yt=1,wt=1e3,Ot=1,$e=200,St=60,kt=50,At=Buffer.byteLength(`${JSON.stringify({Id:"0".repeat(18)})}
|
|
8
|
+
`),Ct="IsDeleted = false",Ve=4;function Et(e){return e.access?.kind==="perObject"?e.access.requests:0}var Bt=1,vt=200,Tt=3,jt=1,Nt=1,ze=2,Dt=3,_t=2e3,Pt=100,Je=["Id","SystemModstamp"],Le=23,N=2.5,h=.35,xt=1,It=.9,S=.5,fe=.25,T=.86,Mt="ContentVersion",$t="ContentDocument",ce=200,Fe=150,w={apiRequests:0,seconds:0};function d(e,t){return{apiRequests:e,seconds:e*t}}function G(e){return{apiRequests:e,seconds:f(e,Ee)*h}}function m(...e){return e.reduce((t,n)=>({apiRequests:t.apiRequests+n.apiRequests,seconds:t.seconds+n.seconds}),w)}function f(e,t){return e>0?Math.ceil(e/t):0}function A(e){return f(e,M)}function Ye(e){return ne(e,Je).length}function Lt(e){return e.length>Pt?M/4:M}function Q(e,t){return f(e,Lt(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 Ft(e){let t=ft+(e.printsBytes??0),n=[];for(let r of e.objects)t+=r.records*mt+Be(r.records,2),r.records>0&&(t+=pt),t+=(r.inBin??0)*At,t+=(r.links??0)*(St+kt),r.entry!==void 0&&n.push(r.entry);return t+We(n,2)+We(e.leftOut??[],3)}function Yn(e,t,n){let[,...r]=ne(t,Je),o=n==="scanAllLive"?Ct:void 0;return r.map(i=>we(e,i,o))}function Ue(e,t){return t.reduce((n,r)=>n+f(e,Math.max(1,r)),0)}function Wt(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 Xn(e){let t=e.objects.length,n=f(e.described,$),r=e.describedAlone??0,o=G(f(e.counted??t,k)),i=(e.countedAlone??0)+f(e.recounted??0,k),a=o.apiRequests+i,l=G(f(t,k)),u=Math.min(e.pageRows,wt),c=0,g=0,O=0;for(let b of e.objects){O+=b.records;let y=Wt(b,u);c+=y.pages,g+=y.reads}let E=H(e.objects.map(b=>L(b.inBin??0))),R=Ut(e.objects),B=e.objects.filter(b=>(b.stampedSince??0)>0),C=m(H(B.flatMap(b=>[L(b.stampedSince??0),1])),G(f(B.length,k))),W=c+g+(c>0?yt:0),s=e.annexCalls??0,p={guard:bt,scope:ht+n+r,start:Rt,counts:a,bin:E.apiRequests,snapshot:W+R.apiRequests+s,stability:Ot+l.apiRequests+C.apiRequests};return{records:O,apiRequests:Object.values(p).reduce((b,y)=>b+y,0),requestsByPhase:p,seconds:Math.ceil(n*N+(r+i+s)*h+o.seconds+l.seconds+E.seconds+C.seconds+R.seconds+c*xt+g*S),bytes:Ft(e)}}function Ut(e){let t=e.filter(o=>o.links!==void 0);if(t.length===0)return w;let n=0,r=0;for(let o of t)o.links===null?n+=f(f(o.records,$e),k):r+=o.links??0;return m(H(t.map(o=>L(o.links??0))),d(n,S),d(f(f(r,$e),k),S))}function L(e){return Math.max(1,f(e,_t))}function H(e){let t=0,n=0;for(let r=0;r<e.length;r+=k){let o=Math.max(1,...e.slice(r,r+k));t+=1,n+=o-1}return m(d(t,h),d(n,It))}function qt(e){let t=new Set([...e.held,...e.moved.map(n=>n.objectApiName)]);return m(G(f(e.objects,k)),H(e.moved.flatMap(({live:n,deleted:r})=>[L(n),L(r)])),G(f(t.size,k)))}function Xe(e){let t=e.reduce((n,r)=>n+A(r),0);return m(d(t*(Tt-1),S),d(t,T))}function Gt(e){return m(...e.filter(t=>t.records>0).map(({records:t,cascades:n,described:r})=>{let o=A(t);return m(d(r?0:1,N),Xe([t]),d(o*f(n,k),h),d(o*jt,S))}))}function ue(e,t){let n=w;for(let r=e;r>0;r-=v){let o=Math.min(r,v);n=m(n,d(ze,h),d(Q(o,t),S),d(z([{rows:o}]),T),d(A(o),S))}return n}function Ht(e,t,n,r){return e===0||n===0?w:m(d(r?0:1,N),d((n+A(e))*f(t,k),h))}var Qt=D({childRelationships:he(D({childSObject:be().optional(),cascadeDelete:te().optional(),restrictedDelete:te().optional()}).loose()).nullish()}).loose();function Zn(e,t){let n=Qt.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())),l=a.filter(u=>u.childSObject!==void 0&&t.worked?.has(u.childSObject)===!0);return{...i,outside:{all:a.length,worked:l.length}}}function pe(e,t){return e?.get(t)??{dependents:Le,cascades:Le}}function Kt(e,t){if(e<Ae||t===Mt||t===$t)return d(z([{rows:e}]),T);let n=Math.ceil(e/Ce),r=Math.ceil(e/n),o=w;for(let i=e;i>0;i-=r){let a=Math.min(i,r);o=m(o,{apiRequests:Oe({stateReads:ke(a)}),seconds:Se(a)})}return o}function le(e,t=Number.POSITIVE_INFINITY){let n=e.filter(r=>r.records>0);return n.length===0?w:m(d(Dt,h),...n.map(({records:r,dependents:o,objectApiName:i})=>{let a=A(r),l=0;for(let c=r;c>0;c-=t)Math.min(c,t)>M&&l++;let u=l*o;return m(d(1,h),d(a,S),d(u+o*a,fe),zt(i,a,u+o*a),Kt(r,i))}))}function Vt(e,t,n){return m(...e.filter(({count:r})=>r>0).map(({objectApiName:r,count:o})=>{let{dependents:i}=pe(t,r),a=o>M?i:0;return m(d(n.has(r)?0:1,N),d(a+i*A(o),fe))}))}function zt(e,t,n){return e===void 0||V[e]===void 0||Re.has(e)?w:m(d(1,h),d(t,S),d(n,fe),d(t,T))}function j(e){return e.toDelete.createdSince+e.toDelete.broughtBackSince}function Y(e){return e.toBringBack.inBin+e.toBringBack.deletedWhileTaken+ee(e)}function ee(e){return e.toBringBack.carriers??0}function F(e){return e.toDelete.comesBackWithParent+ee(e)}function X(e){return e.cannotUndo.filter(t=>t.reason==="deletedWithCreatedParent"||t.reason==="deletedWithParentOutside").reduce((t,n)=>t+n.count,0)}function Z(e){return Y(e)-ee(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 x(e){return e.toRecreate??0}function Jt(e){return me(e)+x(e)}function Yt(e,t){let n=0;for(let r=e;r>0&&t>0;r-=v){let o=Math.min(r,v);n+=f(t*A(o),k)}return n}function et(e,t,n){let r=Jt(e);return{objectApiName:e.objectApiName,live:e.toGiveBack.records+e.touched+j(e)+e.unexplained,deleted:Z(e)+F(e)+X(e),valued:e.toGiveBack.records+e.touched+e.toBringBack.withParent,backTo:Z(e)+ee(e)+X(e)>0||t.undeletable===!1&&r>0,deletes:j(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 Xt(e,t,n,r){let o=et(e,t,n),i=e.toBringBack,a=r?0:F(e);return{...o,live:e.toGiveBack.records+e.touched+e.unexplained+Z(e)+x(e)+a,deleted:j(e)+F(e)-a+X(e),valued:e.toGiveBack.records+e.touched+i.inBin+i.withParent+x(e),backTo:X(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,l=0){let u=[],c=[],g=0,O=0,E=0,R=!1,B=0;for(let{objectApiName:s,records:p,fields:b}of e){let y=t.get(s);if(y===void 0){n.has(s)&&u.push({objectApiName:s,live:0,deleted:0});continue}u.push({objectApiName:s,live:y.live,deleted:y.deleted}),g+=Q(y.valued,b),y.backTo&&!y.whole&&O++,y.scans&&c.push(H([L(p)])),y.deletes!==0&&(!y.whole&&!y.backTo&&E++,y.outside.all>0&&(R=!0),B+=Yt(y.deletes,y.outside.worked))}a!==void 0&&(R=!0);let C=a!==void 0?1:0,W=o===void 0?f(e.length+C,$):f(o.first+C,$)+f(o.later,$);return m(d(Bt,h),d(W,N),qt({objects:e.length,held:e.filter(s=>s.records>0).map(s=>s.objectApiName),moved:u}),d(g,S),d(f(O,$),N),d(E,h),d(R?1:0,N),d(B,h),d(i,h),d(l,h),d(a?.requests??0,S),...c,d(f(f(r,vt),k),h))}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 Zt(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=>F(i)>0)),o=e.diff.described;return tt(e.objects,rt(e,(i,a)=>Xt(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 en(e){return m(...e.filter(t=>t>0).map(t=>m(d(1,h),d(A(t),T))))}var tn=new Set(["activateddate","activatedbyid"]);function nn(e){return m(...e.filter(({objectApiName:t,records:n})=>n>0&&V[t]!==void 0).map(({records:t})=>m(d(1,h),d(A(t),T))))}function rn(e,t){return e*gt+t*Ke}function Ge(e){return m(d(ze,h),d(Ye(e),S),d(1,T),d(1,S))}function on(e,t,n,r){if(t===0)return w;let o=e==="Order"?n.find(c=>c.toLowerCase()==="status"):void 0,i=o===void 0?[]:[o],a=c=>m(ue(c,n),o?ue(c,i):w),l=m(Ge(n),o?Ge(i):w),u=d(Q(t,n),S);return m(a(t),r.held?m(u,l):w,r.held&&r.twice?m(a(t),l):w,r.nextPass?m(u,l):w)}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 sn(e){let t=e.diff.objects,n=new Map(e.objects.map(s=>[s.objectApiName,s])),r=s=>pe(e.relationships,s),o=e.diff.undoCannot?e.diff.undoCannot.reduce((s,{objectApiName:p,count:b})=>s.set(p,(s.get(p)??0)+b),new Map):void 0,i=e.diff.withParentDeleted?new Map(e.diff.withParentDeleted.map(({objectApiName:s,count:p})=>[s,p])):void 0,a=s=>{if(i!==void 0)return Math.max(0,j(s)-(i.get(s.objectApiName)??0));if(o===void 0||n.get(s.objectApiName)?.undeletable!==!1)return j(s);let p=(o.get(s.objectApiName)??0)-s.toDelete.comesBackWithParent;return Math.max(0,Math.min(j(s),p))},l=t.filter(s=>a(s)>0),u=t.filter(s=>F(s)>0),c=(s,p)=>p.some(b=>b.objectApiName!==s.objectApiName&&He(n.get(b.objectApiName),b.objectApiName,s,e.relationships)),g=(s,p)=>p.some(b=>{let y=n.get(b.objectApiName);return y!==void 0&&b.objectApiName!==s.objectApiName&&He(s,s.objectApiName,y,e.relationships)}),O=t.reduce((s,p)=>s+A(Y(p)),0),E=e.reusesPreview!==!0&&t.some(s=>j(s)>0&&(e.relationships?.get(s.objectApiName)?.outside?.all??s.outside.length)>0),R=t.some(s=>Y(s)>0&&r(s.objectApiName).cascades>0),B=m(d(R&&!E?1:0,N),Gt(t.map(s=>({records:Y(s),cascades:r(s.objectApiName).cascades,described:e.reusesPreview!==!0}))),...t.map(s=>Ht(s.toBringBack.withParent,r(s.objectApiName).cascades,O,e.reusesPreview!==!0)),...t.map(s=>{let p=n.get(s.objectApiName);return p===void 0?w:on(s.objectApiName,Ze(s),p.fields,{held:c(p,l),twice:g(p,l),nextPass:c(p,u)})}),en(t.map(x)),nn(t.map(s=>({objectApiName:s.objectApiName,records:x(s)}))),le(t.map(s=>({objectApiName:s.objectApiName,records:a(s),dependents:r(s.objectApiName).dependents})),re)),C=t.flatMap(s=>{let p=n.get(s.objectApiName),b=x(s);return b===0||p===void 0?[]:V[s.objectApiName]===void 0?[]:p.fields.some(y=>tn.has(y.toLowerCase()))?[ue(b,p.fields)]:[]}),W=u.length>0||C.length>0?m(le(u.map(s=>({objectApiName:s.objectApiName,records:F(s),dependents:r(s.objectApiName).dependents})),re),...C,qe(e,!0)):w;return m(d(Nt,h),B,dn(e.diff.files),qe(e,!1,C.length>0),W)}function an(e){return e===void 0?0:e.unlink+e.relink+e.updateLinks}function dn(e){return e===void 0?w:d(f(e.unlink,ce)+f(e.relink,ce)+f(e.updateLinks,ce),T)}function er(e){let t=e.diff.objects,n=t.reduce((g,O)=>g+j(O)+O.toDelete.comesBackWithParent,0),r=t.reduce((g,O)=>g+O.toGiveBack.records,0),o=t.reduce((g,O)=>g+Z(O),0),i=t.reduce((g,O)=>g+x(O),0),a=n+r+o+i,l=m(d(Ve+Et(e.diff),h),e.reusesPreview===!0?w:Zt(e)),u=e.diff.files;if(a===0&&an(u)===0)return{records:0,apiRequests:l.apiRequests,seconds:Math.ceil(l.seconds),bytes:0};let c=m(l,d(e.automationRequests,S),d(e.deliverabilityRequests??0,h),sn(e));return{records:a,apiRequests:c.apiRequests,seconds:Math.ceil(c.seconds),bytes:rn(t.reduce((g,O)=>g+Ze(O),0),n+o+2*i)+cn(u)}}function cn(e){return e===void 0?0:e.unlink*Fe+e.relink*Ke+e.updateLinks*Fe}var un=1;function Qe(e,t){let n=w;for(let r=e;r>0;r-=v){let o=Math.min(r,v);n=m(n,d(un,h),d(Q(o,t),S),d(z([{rows:o}]),T))}return n}function ln(e,t){let n=Math.min(e.givenBackHeld??0,e.givenBack),r=w;for(let o=e.givenBack;o>0;o-=v)r=m(r,d(Q(Math.min(o,v),t),S));return m(Qe(n,t),Qe(e.givenBack-n,t),r)}var mn=2;function fn(e){let t=Math.min(e.givenBackHeld??0,e.givenBack);return d(A(e.givenBack)+A(t)+A(e.givenBack-t),S)}function tr(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,h);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)),l=o&&i?m(d(mn,h),...e.rewound.map(fn)):w,u=m(r,d(e.automationRequests,S),l,le(e.rewound.map(c=>({objectApiName:c.objectApiName,records:c.broughtBack,dependents:pe(e.relationships,c.objectApiName).dependents}))),a.size>0?Vt(e.along??[],e.relationships,a):w,Xe(e.rewound.map(c=>c.deleted)),...e.rewound.map(c=>ln(c,t.get(c.objectApiName)??[])));return{records:n,apiRequests:u.apiRequests,seconds:Math.ceil(u.seconds),bytes:0}}var pn={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 \u2014 or rewind fewer of its objects at a time, which sends only theirs (the objects ticked in the preview, or --object on a command line).",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."}},gn=D({FileStorageMB:D({Max:K(),Remaining:K()}).loose()}).loose(),bn=D({DataStorageMB:D({Max:K().int().nonnegative()}).loose()}).loose();async function nr(e,t){let n,r;try{n=await e.request({method:"GET",url:"/limits"}),r=await ve({request:()=>Promise.resolve(n)})}catch(l){throw new Error(`${t} did not say how many API requests it has left today: ${I(l)}`)}let o;try{o=await je({request:()=>Promise.resolve(n)})}catch(l){o={unread:I(l)}}let i=gn.safeParse(n),a=bn.safeParse(n);return{...r,emails:o,...i.success?{fileStorage:{max:i.data.FileStorageMB.Max,remaining:i.data.FileStorageMB.Remaining}}:{},...a.success?{dataStorageMaxMB:a.data.DataStorageMB.Max}:{}}}var hn={deliverability:e=>`to read whether ${e} delivers its emails`};function Rn(e,t){if(e===void 0)return"";let n=Object.entries(hn).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 rr(e,t,n,r){let o=Te(t,n);if(o.verdict!=="exceeds")return;let i=pn[e];return{code:"API_BUDGET",message:`${i.what} takes about ${o.estimate} API requests${Rn(o.parts,r)}; ${r} has ${n.remaining} of its ${n.max} left today. ${i.then} ${i.done}`}}var yn={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 or(e,t,n,r){if(n===void 0||t.files===0||t.bytes<=n*1048576)return;let o=yn[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}`}}import{randomUUID as On}from"node:crypto";var ge="\0configStore:revision",Sn="\0configStore";function kn(e){let t=e[ge]?.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 ot=class{backend;logWarning;writer=On();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=I(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=I(i);this.logWarning?.(`[ConfigStore] Corrupted entry in category "${t}", key "${r}": ${a}`)}return n}getAllKeys(){return Object.keys(this.current()).filter(t=>t!==ge)}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=kn(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[ge]={value:JSON.stringify({writer:this.writer,write:this.writes}),category:Sn},this.backend.setData(t),this.written=t}};export{Cn as a,En as b,Bn as c,vn as d,Tn as e,jn as f,Nn as g,Dn as h,xn as i,ie as j,In as k,_e as l,Mn as m,$n as n,wt as o,_t as p,h as q,xt as r,T as s,Yn as t,Xn as u,Zn as v,sn as w,er as x,tr as y,nr as z,rr as A,or as B,ot as C};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{h as M,i as T}from"./chunk-
|
|
7
|
+
import{h as M,i as T}from"./chunk-DMBR24CK.mjs";import{p as b}from"./chunk-ICIYL45C.mjs";import{fc as _,gc as h,hc as p,ic as R,mc as C,nc as S,qc as k}from"./chunk-DPYTG6DM.mjs";async function Y(r,e){try{let[c,i]=await Promise.all([r(R),e(R)]),d=c[0]?.Id,a=i[0]?.Id;return typeof d=="string"&&typeof a=="string"?{source:d,target:a}:void 0}catch{return}}function v(r,e){return r===h||e.some(c=>typeof c[p]=="string")}var K=[p,C,S];function A(r,e,c,i,d=()=>!1){let a={...e,standsFor:new Map,standardFirst:0,standardMatched:!1,prices:[],leftIn:new Map};if(!c)return a;let o=e.records.map((t,s)=>s),m=t=>({records:t.map(s=>e.records[s]),sources:t.map(s=>e.sources[s]),sourceIds:t.map(s=>e.sourceIds[s])});if(r===h){let t=o.filter(s=>e.sourceIds[s]!==c.source);return t.length===o.length?a:{...m(t),standsFor:new Map,standardFirst:0,standardMatched:!0,prices:[],leftIn:new Map}}if(r!==_)return a;let l=o,I=new Map,P=new Map,O=[];if(i){let{target:t}=i,s=e.sources.filter(n=>!K.some(f=>{let u=n[f];return typeof u=="string"&&u!==""&&d(u)})),E=n=>t.active.has(n)?n:b(void 0,t)?.to,g=M({prices:s,standardBookId:c.source,sellingModels:s.some(n=>typeof n[S]=="string"),writtenIn:E,active:t.active},[]),B=new Set(g.standsFor.keys());l=o.filter(n=>{let f=e.sourceIds[n];return f===void 0||!B.has(f)});let D=new Map(s.map(n=>[n.Id,n[k]]));for(let[n,f]of g.standsFor){I.set(n,f);let u=D.get(n),w=typeof u=="string"?E(u):void 0;typeof u=="string"&&w!==void 0&&P.set(n,{from:u,to:w})}O=T(g.said)}let y=t=>e.sources[t][p]===c.source,F=[...l.filter(y),...l.filter(t=>!y(t))];return{...m(F),standsFor:I,standardFirst:l.filter(y).length,standardMatched:!1,prices:O,leftIn:P}}function Q(r,e){let c=r.prices.map(i=>({...i}));for(let i of e){let d=r.leftIn.get(i),a=d&&(c.find(o=>o.from===d.from&&o.to===d.to&&o.how==="replaced"&&!o.forLines)??c.find(o=>o.from===d.from&&o.to===d.to&&o.how==="replaced"));a&&a.prices--}return c.filter(i=>i.prices>0)}function q(r,e){return e===1?`1 ${r} record held back, not sent: read in a currency the target org does not hold active, it stands for the source's own price of its product and price book in the currency written, which this run did not write.`:`${e} ${r} records held back, not sent: read in a currency the target org does not hold active, they stand for the source's own prices of their product and price book in the currency written, which this run did not write.`}var H="The standard price book is matched to the target org's, never written.";function $(r,e){return e.prices.length===0&&!e.standardMatched?r:{...r,...e.prices.length>0?{pricesSettled:[...e.prices]}:{},...e.standardMatched?{standardPricebookMatched:!0}:{}}}export{Y as a,v as b,A as c,Q as d,q as e,H as f,$ as g};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a as xe}from"./chunk-OXKZ4Y3B.mjs";import{a as je,b as Te,c as Oe,d as Pe,f as Me}from"./chunk-M6P5ZZLE.mjs";import{Ca as Ue,Ea as U,Fa as Qe,Ha as We,Z as Le,ha as De,ja as qe,la as Ie,pa as B,wa as Ve,xa as Be}from"./chunk-KOQV4WXC.mjs";import{b as $}from"./chunk-CA5NAXSU.mjs";import{Cd as Ge,O as Fe,Q as ve,R as Ne,S as _e,T as Ae,U as Ce,V as Se,W as $e,ja as Ee}from"./chunk-DPYTG6DM.mjs";import{e as X,l as ee}from"./chunk-WZQEK4WT.mjs";var v=class extends Error{};function ut(e){let r=[],n=0;for(;n<e.length;){let t=e.slice(n),i=/^\s+/.exec(t);if(i){n+=i[0].length;continue}if(t.startsWith("/*")){let d=e.indexOf("*/",n+2);if(d<0)throw new v("an unclosed comment");n=d+2;continue}let l=t[0];if(l==="'"||l==='"'){let d=1;for(;d<t.length&&t[d]!==l;)d+=t[d]==="\\"?2:1;if(d>=t.length)throw new v("an unclosed text");r.push(t.slice(0,d+1)),n+=d+1;continue}let f=/^(?:\d+(?:\.\d+)?|[A-Za-z_$][A-Za-z0-9_$.]*)/.exec(t);if(f){r.push(f[0]),n+=f[0].length;continue}let p=/^(?:&&|\|\||==|!=|<>|<=|>=|[=<>+\-*/^&!(),])/.exec(t);if(!p)throw new v(`an unexpected character: ${t[0]}`);r.push(p[0]),n+=p[0].length}return r}var Ke=[new Set(["||"]),new Set(["&&"]),new Set(["=","==","<>","!=","<",">","<=",">="]),new Set(["+","-","&"]),new Set(["*","/"]),new Set(["^"])];function ct(e){let r=ut(e),n=0,t=()=>r[n],i=u=>{if(r[n]!==u)throw new v(`${u} expected`);n++},l=u=>{if(u>=Ke.length)return f();let o=l(u+1);for(let a=t();a!==void 0&&Ke[u].has(a);a=t())n++,o={kind:"binary",op:a,left:o,right:l(u+1)};return o},f=()=>{if(t()==="!")return n++,{kind:"not",arg:f()};if(t()==="-"||t()==="+"){let u=r[n++],o=f();return u==="-"?{kind:"negative",arg:o}:o}return p()},p=()=>{let u=r[n++];if(u===void 0)throw new v("the formula ends early");if(u==="("){let a=l(0);return i(")"),a}if(u.startsWith("'")||u.startsWith('"'))return{kind:"literal",value:`text:${u.slice(1,-1)}`};if(/^\d/.test(u))return{kind:"literal",value:`number:${Number(u)}`};if(!/^[A-Za-z_$]/.test(u))throw new v(`${u} out of place`);if(t()==="("){n++;let a=[];if(t()!==")")for(a.push(l(0));t()===",";)n++,a.push(l(0));return i(")"),{kind:"call",name:u.toUpperCase(),args:a}}let o=u.toUpperCase();return o==="TRUE"||o==="FALSE"||o==="NULL"?{kind:"literal",value:o.toLowerCase()}:{kind:"reference",name:u.toLowerCase()}},d=l(0);if(n!==r.length)throw new v(`${r[n]} out of place`);return d}function E(e){switch(e.kind){case"call":return e.name==="PRIORVALUE"&&e.args.length===1?E(e.args[0]):{...e,args:e.args.map(E)};case"binary":return{...e,left:E(e.left),right:E(e.right)};case"not":case"negative":return{...e,arg:E(e.arg)};default:return e}}function N(e){switch(e.kind){case"call":return`${e.name}(${e.args.map(N).join(",")})`;case"binary":{let r=e.op==="=="?"=":e.op==="!="?"<>":e.op,n=[N(e.left),N(e.right)];return(r==="="||r==="<>")&&n.sort(),`(${n[0]} ${r} ${n[1]})`}case"not":return`NOT(${N(e.arg)})`;case"negative":return`-(${N(e.arg)})`;case"literal":return e.value;case"reference":return e.name}}var ze=e=>e==="true"?"false":e==="false"?"true":"unknown";function P(e){return e.kind==="call"&&e.name==="AND"?e.args.flatMap(P):e.kind==="binary"&&e.op==="&&"?[...P(e.left),...P(e.right)]:[e]}function M(e){return e.kind==="call"&&e.name==="OR"?e.args.flatMap(M):e.kind==="binary"&&e.op==="||"?[...M(e.left),...M(e.right)]:[e]}function te(e){if(e.kind==="not"){let r=te(e.arg);return{condition:r.condition,holds:!r.holds}}if(e.kind==="call"&&e.name==="NOT"&&e.args.length===1){let r=te(e.args[0]);return{condition:r.condition,holds:!r.holds}}return e.kind==="binary"&&(e.op==="<>"||e.op==="!=")?{condition:N({...e,op:"="}),holds:!1}:{condition:N(e),holds:!0}}function ne(e){if(e.kind==="literal"){if(e.value==="true")return"true";if(e.value==="false")return"false"}}function R(e){let r=ne(e);if(r)return r;if(e.kind==="not")return ze(R(e.arg));if(e.kind==="call")switch(e.name){case"ISCHANGED":return"false";case"ISNEW":return"true";case"NOT":return e.args.length===1?ze(R(e.args[0])):"unknown";case"AND":return He(P(e));case"OR":return Ze(M(e));case"IF":{if(e.args.length!==3)return"unknown";let[n,t,i]=e.args,l=R(n);if(l==="true")return R(t);if(l==="false")return R(i);let f=R(t);return f===R(i)?f:"unknown"}default:return"unknown"}return e.kind==="binary"?e.op==="&&"?He(P(e)):e.op==="||"?Ze(M(e)):dt(e):"unknown"}function He(e){let r=e.map(R);if(r.includes("false"))return"false";let n=new Map;for(let t of e){let{condition:i,holds:l}=te(t),f=n.get(i);if(f!==void 0&&f!==l)return"false";n.set(i,l)}return r.every(t=>t==="true")?"true":"unknown"}function Ze(e){let r=e.map(R);return r.includes("true")?"true":r.every(n=>n==="false")?"false":"unknown"}function dt(e){let r=e.op==="="||e.op==="==",n=e.op==="<>"||e.op==="!=";if(N(e.left)===N(e.right))return n||e.op==="<"||e.op===">"?"false":"unknown";if(!r&&!n)return"unknown";let t=ne(e.left)??R(e.left),i=ne(e.right)??R(e.right);return t==="unknown"||i==="unknown"?"unknown":t===i===r?"true":"false"}function Ye(e){try{return R(E(ct(e)))==="false"}catch(r){if(r instanceof v)return!1;throw r}}var tt=25,W=20,ie=W*Le,G=4,Je=10,ft=2e3,pt=.8;function gt(e){return typeof e!="object"||e===null?null:{optional:e.optionalFilter===!0}}function Vt(e){return{name:e.name,type:String(e.type),createable:e.createable===!0,nillable:e.nillable!==!1,defaultedOnCreate:e.defaultedOnCreate===!0,referenceTo:(e.referenceTo??[]).filter(r=>typeof r=="string"),picklistValues:(e.picklistValues??[]).filter(r=>r?.active!==!1&&typeof r?.value=="string").map(r=>r?.value),lookupFilter:gt(e.filteredLookupInfo)}}function oe(e){return`SELECT Id, ValidationName, NamespacePrefix, ErrorDisplayField, ErrorMessage, EntityDefinition.QualifiedApiName FROM ValidationRule WHERE Active = true AND EntityDefinition.QualifiedApiName IN (${e.map(n=>`'${n}'`).join(", ")})`}function mt(e){return`SELECT QualifiedApiName, Label FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName = '${x.test(e)?e:""}'`}function q(e){return`SELECT Metadata FROM ValidationRule WHERE Id = '${e}'`}var ht="SELECT DeveloperName, MasterLabel, NamespacePrefix, SobjectType FROM DuplicateRule WHERE IsActive = true",ae=/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/,x=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,yt=ee({DailyApiRequests:ee({Max:X(),Remaining:X()}).loose()}).loose(),y=e=>typeof e=="string"?e:"";function le(e){if(typeof e!="object"||e===null)return;let r=e.QualifiedApiName;return typeof r=="string"&&r!==""?r:void 0}function Q(e,r){return e?`${e}__${r}`:r}function D(e){return typeof e=="string"?[e]:Array.isArray(e)?e.filter(r=>typeof r=="string"):[]}function wt(e){return{...e,nodes:e.nodes.map(r=>r.leftOutByUser===!0?{...r,included:!0}:r)}}function se(e,r){let n=y(e).trim(),t=n.slice(n.lastIndexOf(".")+1);if(x.test(t))return r?r.find(i=>i.name.toLowerCase()===t.toLowerCase())?.name:t}function nt(e){let r=Ve({filterFormula:e}).filter(t=>t.bypass).map(t=>t.name),n=Be(e).map(t=>t.value===void 0?t.reference:`${t.reference} = '${t.value}'`);return{bypasses:[...r.map(t=>`$Permission.${t}`),...n],permissions:r}}function bt(e,r={}){let n=r.maxRecordsPerObject,t=e.nodes.filter(d=>d.included),i=Ee(r)?"atMost":"exact",l=t.map(d=>d.recordCountUnknown===!0?(n===void 0?i="unknown":i==="exact"&&(i="atMost"),{...d,recordCount:n??0}):{...d,recordCount:n===void 0?d.recordCount:Math.min(d.recordCount,n)}),f=new xe().generate({...e,nodes:l}).totalApiCalls,p=l.reduce((d,u)=>d+Math.max(1,Math.ceil(u.recordCount/ft)),0);return{writes:f,reads:p,bound:i}}function j(e){let{idValue:r,...n}=e;return{id:Fe(e.kind,e.objectApiName,e.field,e.recordType,r??e.value),source:"metadata",rows:0,...n}}function ue(e){return e?{field:e}:{}}function Bt(e){return async r=>Ie(await e.request({method:"POST",url:"/tooling/composite",body:JSON.stringify(qe(`/services/data/v${e.version}`,r)),headers:{"Content-Type":"application/json"}}),r.length)}async function Rt(e,r,n){let t=e.filter(({id:i})=>ae.test(i));t.length!==0&&await B(r,[{queries:t.map(({id:i,rule:l})=>({soql:q(i),retrieve:{sobject:"ValidationRule",id:i},take:f=>{let p=f[0]?.Metadata,d=typeof p=="object"&&p!==null?p.errorConditionFormula:void 0;typeof d=="string"&&Ye(d)&&(l.onChangeOnly=!0)},refused:()=>{}})),requests:W}],G,n)}async function kt(e,r,n,t,i){let l=[...new Set(r)].filter(g=>x.test(g));if(l.length===0)return[];let f=new Map(l.map(g=>[g.toLowerCase(),g])),p=new Map(l.map((g,b)=>[g,b])),d=await e(oe(l)),u=new Map,o=async(g,b)=>{let k=se(b,void 0);if(!n)return k;let F=u.get(g);F||(F=n(g).catch(()=>[]),u.set(g,F));let C=y(b).trim().toLowerCase();if(!C)return;let _=k?.toLowerCase(),S=await F;return S.length===0?k:S.find(A=>A.name.toLowerCase()===_)?.name??S.find(A=>A.label?.trim().toLowerCase()===C)?.name},h=(await Promise.all(d.map(async g=>{let b=le(g.EntityDefinition),k=b===void 0?void 0:f.get(b.toLowerCase()),F=y(g.ValidationName);return!k||!F?[]:[{id:y(g.Id),rule:{objectApiName:k,name:Q(y(g.NamespacePrefix),F),message:y(g.ErrorMessage),...ue(await o(k,g.ErrorDisplayField))}}]}))).flat().sort((g,b)=>(p.get(g.rule.objectApiName)??0)-(p.get(b.rule.objectApiName)??0)||g.rule.name.localeCompare(b.rule.name));return t&&await Rt(h,t,i),h.map(({rule:g})=>g)}async function Ut(e,r,n,t){let i=[...new Set(r)].filter(a=>x.test(a));if(i.length===0)return{rules:[],notRead:0,requests:0};let l=new Map(i.map(a=>[a.toLowerCase(),a])),f=await e(oe(i)),p=f.requests,d=f.records.flatMap(a=>{let h=le(a.EntityDefinition),g=h===void 0?void 0:l.get(h.toLowerCase()),b=y(a.ValidationName);return!g||!b?[]:[{id:y(a.Id),objectApiName:g,name:Q(y(a.NamespacePrefix),b),read:!1,permissions:[]}]}),u=d.filter(a=>ae.test(a.id)),o=(a,h)=>{let g=typeof h=="object"&&h!==null?h.errorConditionFormula:void 0;typeof g=="string"&&(a.read=!0,a.permissions=nt(g).permissions)};return n?p+=await B(n,[{queries:u.slice(0,ie).map(a=>({soql:q(a.id),retrieve:{sobject:"ValidationRule",id:a.id},take:h=>o(a,h[0]?.Metadata),refused:()=>{}})),requests:W}],G,t):await U(u.slice(0,tt).map(a=>async()=>{try{let h=await e(q(a.id));p+=h.requests,o(a,h.records[0]?.Metadata)}catch{p++}}),G),{rules:d.filter(a=>a.permissions.length>0).map(({objectApiName:a,name:h,permissions:g})=>({objectApiName:a,name:h,permissions:g})),notRead:d.filter(a=>!a.read).length,requests:p}}function Qt(e,r,n){let t=async i=>(await e(mt(i))).flatMap(l=>typeof l.QualifiedApiName=="string"?[{name:l.QualifiedApiName,...typeof l.Label=="string"?{label:l.Label}:{}}]:[]);return i=>kt(e,i,t,r,n)}var Xe=class{deps;constructor(r){this.deps=r}async read(r,n,t,i={}){let l=new Set(i.excludedObjects??[]),f=Qe(wt(t),l),p=[];if(f.length===0)return{gaps:[],unread:p,requests:0};let d=0,u=(s,c)=>{p.push({part:s,reason:c})},o=new Map(f.map(s=>[s.toLowerCase(),s])),a=s=>s===void 0?void 0:o.get(s.toLowerCase()),h=new Map(f.map((s,c)=>[s,c])),g=f.filter(s=>x.test(s)),b=[],k=[],F,C,_=new Map,S=new Map,A=new Set,I=(s,c,m)=>async()=>{try{let w=await c();d+=w.requests,m(w.records)}catch(w){d++,u(s,$(w))}},ce=(s,c,m,w)=>async()=>{try{let{fields:J,sent:at,createable:lt}=await this.deps.describeFields(s,c);at&&d++,w.set(c,J),w===_&<===!1&&A.add(c)}catch(J){d++,u(m,`${c}: ${$(J)}`)}};await U([...g.length>0?[I("validationRules",()=>this.deps.toolingQuery(n,oe(g)),s=>{b=s})]:[],I("duplicateRules",()=>this.deps.query(n,ht),s=>{k=s}),async()=>{try{d++,F=await this.deps.readLimits(n)}catch(s){C=$(s)}},...f.flatMap(s=>[ce(n,s,"targetFields",_),ce(r,s,"sourceFields",S)])],G);let T=b.flatMap(s=>{let c=a(le(s.EntityDefinition)),m=y(s.ValidationName);if(!c||!m)return[];let w=y(s.Id);return[{id:ae.test(w)?w:null,name:Q(y(s.NamespacePrefix),m),objectApiName:c,...ue(se(s.ErrorDisplayField,_.get(c))),message:y(s.ErrorMessage),formula:"notRead",bypasses:[],permissions:[]}]}).sort((s,c)=>(h.get(s.objectApiName)??0)-(h.get(c.objectApiName)??0)||s.name.localeCompare(c.name)),{toolingQueries:O,toolingRetrieves:de}=this.deps,K=T.filter(s=>s.id!==null).slice(0,O?ie:tt);for(let s of T)s.id===null&&(s.formula="unreadable");let z=k.flatMap(s=>{let c=a(y(s.SobjectType)),m=Q(y(s.NamespacePrefix),y(s.DeveloperName));return!c||!y(s.DeveloperName)?[]:[{objectApiName:c,developerName:m,label:y(s.MasterLabel)||m,fullName:`${y(s.SobjectType)}.${m}`}]}),fe=new Map,pe=[];for(let s=0;s<z.length;s+=Je)pe.push(z.slice(s,s+Je).map(c=>c.fullName));let V,H,ge=(s,c)=>{let m=typeof c=="object"&&c!==null?c.errorConditionFormula:void 0;if(typeof m!="string"){s.formula="unreadable";return}s.formula="read",Object.assign(s,nt(m));let w=se(c.errorDisplayField,_.get(s.objectApiName));w&&(s.field=w)},st=async()=>{if(!O||K.length===0)return;let s=await B(c=>O(n,c),[{queries:K.map(c=>({soql:q(c.id),retrieve:{sobject:"ValidationRule",id:c.id},take:m=>ge(c,m[0]?.Metadata),refused:m=>{c.formula="unreadable",V??=m}})),requests:W}],G,de&&(c=>de(n,c)));d+=s},me=new Map,Z={},he=[...A].filter(s=>x.test(s)),it=async()=>{let[s,c]=await Promise.all([Pe((m,w)=>this.deps.toolingQuery(m,w),n,he),this.deps.createFacts?this.deps.createFacts(n).then(m=>({facts:m,requests:0})).catch(()=>({facts:{},requests:0})):Oe(this.deps,n)]);d+=s.requests+c.requests;for(let[m,w]of s.answered)me.set(m,w);Z=c.facts};await U([...he.length>0?[it]:[],...O?[st]:[],...(O?[]:K).map(s=>async()=>{try{let c=await this.deps.toolingQuery(n,q(s.id));d+=c.requests,ge(s,c.records[0]?.Metadata)}catch(c){d++,s.formula="unreadable",V??=$(c)}}),...pe.map(s=>async()=>{try{d++;for(let c of await this.deps.readDuplicateRules(n,s)){if(typeof c!="object"||c===null)continue;let m=c,w=y(m.fullName);w&&fe.set(w.toLowerCase(),m)}}catch(c){H??=$(c)}})],G),V!==void 0&&u("validationRuleFormulas",V),H!==void 0&&u("duplicateRuleActions",H);let Y=new Set,ye=!1;T.some(s=>s.permissions.length>0)&&await I("userPermissions",()=>this.deps.query(n,De),s=>{ye=!0;for(let c of s)Y.add(Ue(y(c.NamespacePrefix),y(c.DeveloperName)))})();let we=[...new Set(T.flatMap(s=>s.permissions.filter(c=>!Y.has(c.toLowerCase()))))],ot=we.length>0?await We(we,async s=>{let c=[];return await I("permissionSets",()=>this.deps.query(n,s),m=>{c=m})(),c},()=>p.some(s=>s.part==="permissionSets")):void 0,be=[...T.map(s=>Nt(s,ye?Y:void 0,ot)),...z.map(s=>_t(s,fe.get(s.fullName.toLowerCase()))),...f.flatMap(s=>{if(A.has(s))return[vt(s,je(s,Z,me.get(s.toLowerCase())),_.get(s)??[],Z)];let c=_.get(s),m=S.get(s);return c&&m?At(s,c,m,i):[]})],Re=yt.safeParse(F),ke=C===void 0&&Re.success?Re.data.DailyApiRequests:void 0;return ke||u("apiBudget",C??"the limits the org answered hold no DailyApiRequests"),be.push(Ct(t,i,f[0],ke)),{gaps:Ae(be),unread:p,requests:d}}},Ft={platform:"object_platform_only",setup:"object_setup_only",feature:"object_feature_off",parent:"object_through_parent",user:"object_not_createable"};function vt(e,r,n,t){let i=r==="parent"?Me(n,t):[];return j({kind:Ft[r],severity:Te(r)?"info":"blocking",objectApiName:e,...i.length>0?{detail:{editOn:i}}:{},decisions:["exclude_object"]})}function Nt(e,r,n){let t=r?e.permissions.filter(f=>r.has(f.toLowerCase())):[],i=t.length>0?[]:e.permissions.flatMap(f=>{let p=n?.find(d=>d.permission.toLowerCase()===f.toLowerCase());return p?[Ce(p)]:[]}),l=e.field?["leave_empty","ignore"]:["ignore"];return j({kind:"validation_rule",severity:t.length>0?"info":"warning",objectApiName:e.objectApiName,...ue(e.field),idValue:e.name,detail:{rule:e.name,message:e.message,formula:e.formula,...e.bypasses.length>0?{bypasses:e.bypasses}:{},...t.length>0?{heldBypasses:t}:{},...i.length>0?{assign:i}:{}},decisions:l,...e.field?{defaultDecision:"leave_empty"}:{}})}function _t(e,r){let n=y(r?.actionOnInsert).toLowerCase(),t=n==="block"||n==="allow"?n:"unknown",i=D(r?.operationsOnInsert).map(f=>f.toLowerCase());return j({kind:"duplicate_rule",severity:t==="allow"?"info":"warning",objectApiName:e.objectApiName,idValue:e.developerName,detail:{rule:e.label,developerName:e.developerName,action:t,...t==="allow"?{alert:i.includes("alert")}:{},...t==="allow"?{report:i.includes("report")}:{}},decisions:t==="allow"?["ignore"]:["ignore","exclude_object"],...t==="allow"?{defaultDecision:"ignore"}:{}})}function At(e,r,n,t){let i=o=>o.toLowerCase(),l=new Set((t.fieldExclusions?.[e]??[]).map(i)),f=new Map(Object.entries(t.fieldMappings?.[e]??{}).map(([o,a])=>[i(o),i(a)])),p=new Set([...f].filter(([o])=>!l.has(o)).map(([,o])=>o)),d=new Map(n.map(o=>[i(o.name),o])),u=o=>{let a=i(o);if(p.has(a))return;let h=d.get(a);return h?l.has(a)||f.has(a)?"excluded":h.createable?void 0:"notCreateableInSource":"notInSource"};return r.flatMap(o=>{let a=u(o.name);if(o.createable&&!o.nillable&&!o.defaultedOnCreate&&a)return[j({kind:"required_field_missing",severity:"blocking",objectApiName:e,field:o.name,detail:{type:o.type,reason:a,...o.referenceTo.length>0?{referenceTo:o.referenceTo}:{},...o.picklistValues.length>0?{values:o.picklistValues}:{}},decisions:["set_default","exclude_object"]})];if(o.type==="reference"&&o.lookupFilter&&!a){let h=o.nillable;return[j({kind:"lookup_filter",severity:"warning",objectApiName:e,field:o.name,detail:{referenceTo:o.referenceTo,optional:h,filterOptional:o.lookupFilter.optional},decisions:h?["leave_empty","ignore"]:["ignore","exclude_object"],...h?{defaultDecision:"leave_empty"}:{}})]}return[]})}function Ct(e,r,n,t){let i=e.nodes[0]?.objectApiName??n,l=bt(e,r),f=l.writes+l.reads,p="warning";if(t&&l.bound!=="unknown"){let d=f>t.Remaining,u=t.Max-t.Remaining+f>pt*t.Max;p=d&&l.bound==="exact"?"blocking":d||u?"warning":"info"}return j({kind:"api_budget",severity:p,objectApiName:i,detail:{calls:f,writes:l.writes,reads:l.reads,estimate:l.bound,...t?{max:t.Max,remaining:t.Remaining}:{budgetRead:!1}},decisions:["ignore"]})}var St={blocking:"BLOCKING",warning:"warning",info:"info"},$t=new Set(["picklist_value_refused","dependent_value_invalid","picklist_value_absent","currency_inactive"]),Et=new Set(["record_type_unmapped","record_type_unavailable"]);function rt(e,r,n=[e.id]){if(ve(r.ignoredGaps,e.id,n)!==void 0)return"left as it is";let t=e.objectApiName;if(r.excludedObjects?.includes(t))return`${t} left out of the run`;let i=new Set(e.decisions),{field:l,value:f}=e;if(i.has("skip_rows")&&Ne((r.skippedRows??[]).filter(o=>o.object===t),e.id,n))return"these rows held back";if($t.has(e.kind)&&l!==void 0&&f!==void 0&&(i.has("map_value")||i.has("leave_empty"))){let o=(r.picklistValueMappings??[]).filter(h=>h.object===t&&h.field===l&&h.from===f),a=_e(o,e,n);if(a?.to===null&&i.has("leave_empty"))return"the field left empty in these rows";if(a&&a.to!==null&&i.has("map_value"))return`written as "${a.to}"`}let p=Et.has(e.kind)?e.value??e.recordType:void 0;if(p!==void 0&&i.has("map_record_type")){let o=r.recordTypeMappings?.find(a=>a.object===t&&a.from===p);if(o)return o.to===null?"written with the object's default record type":`written as record type ${o.to}`}if(l===void 0)return;let d=o=>o.object===t&&o.field===l,u=i.has("set_default")?r.defaultValues?.find(d):void 0;if(u)return`default "${String(u.value)}"`;if(i.has("truncate")&&r.truncateFields?.some(d))return"cut to the field's length";if(i.has("leave_empty")&&r.fieldExclusions?.[t]?.includes(l))return"the field left out of the rows"}function Wt(e,r){let n=e.gaps.map(t=>t.id);return{...e,gaps:e.gaps.map(t=>{let i=rt(t,r,n);return i===void 0?t:{...t,answeredBy:i}})}}function et(e,r,n,t){if(t)return`the mute lifts it (${t.permission}, in ${t.permissionSet}): ${re(e,!0)}`;let i=r?rt(e,r,n):void 0;return i===void 0?`${St[e.severity]}: ${re(e)}`:`answered by the run's decision: ${i} \u2014 ${re(e)}`}var Gt={validationRules:"the validation rules",validationRuleFormulas:"the formulas of some validation rules",duplicateRules:"the duplicate rules",duplicateRuleActions:"what the duplicate rules do on insert",userPermissions:"the custom permissions of the user the run writes as",permissionSets:"the permission sets that hold a bypass of a validation rule the user the run writes as does not",targetFields:"the fields of an object in the target",sourceFields:"the fields of an object in the source",apiBudget:"the daily API requests left"},xt={notInSource:"the source has no such field",notCreateableInSource:"the source cannot give it",excluded:"the run leaves it out"},L=e=>typeof e=="number"?String(e):"?";function re(e,r=!1){let n=e.detail??{};switch(e.kind){case"required_field_missing":return`required field ${e.field??""} (${y(n.type)}): only the target requires it, and the run does not write it (${xt[y(n.reason)]??y(n.reason)}): every row is refused unless it is given a value`;case"validation_rule":{let t=e.field?` on ${e.field}`:"",i=[...D(n.bypasses).map(f=>`not when ${f}`),...D(n.heldBypasses).length>0?[`kept quiet for this run: the user it writes as holds ${D(n.heldBypasses).join(", ")}`]:[],...n.formula==="notRead"?["formula not read"]:[],...n.formula==="unreadable"?["formula unreadable"]:[],...e.field&&!r?[`a row it refuses goes again without ${e.field}`]:[]],l=y(n.message)?`: "${y(n.message)}"`:"";return`validation rule "${y(n.rule)}"${t}${l}${i.length>0?` (${i.join("; ")})`:""}`}case"duplicate_rule":{let t=`duplicate rule "${y(n.rule)}"`;if(n.action==="block")return`${t}: blocks an insert it matches: a row it matches is refused, whatever allowSave says`;if(n.action==="allow"){let i=[n.alert===!0?"an alert":"",n.report===!0?"a report":""].filter(Boolean).join(" and ");return`${t}: allows an insert it matches${i?`, with ${i}`:""}: the run saves it (allowSave=true)`}return`${t}: what it does on insert was not read: a rule that blocks refuses a row it matches`}case"lookup_filter":return`lookup filter on ${e.field??""}: not checked before the run; `+(n.optional===!0?"a lookup it refuses is left empty":"the lookup is required, and a row it refuses is refused");case"object_not_createable":return"the user the run writes as may not create its records in the target: every row is skipped, after the objects written before it, unless the object is left out";case"object_platform_only":return"no user can create its records in the target, the platform writes them itself: the run skips every row of it";case"object_setup_only":return"no user can create its records in the target, not even one with Modify All Data, and no permission set gives Create on it: setup the org keeps as records, or the platform's own; the run skips every row of it";case"object_feature_off":return"even a user with Modify All Data may not create its records in the target, though a permission set can give Create on it: a feature or licence the target has not turned on for that user keeps it closed; turn it on, or every row is skipped, after the objects written before it, unless the object is left out";case"object_through_parent":{let t=D(n.editOn);return`no permission set gives Create on it: ${t.length>0?`the user the run writes as creates its records with Edit on ${t.join(" and ")}, which they hang from, or no user can`:"the records they hang from may open it to the user the run writes as, or no user can: read as a user with Modify All Data, the target would tell"}; every row is skipped, after the objects written before it, unless the object is left out`}case"api_budget":{let t=`about ${L(n.calls)} call(s) (${L(n.writes)} write(s) of 200 rows, ${L(n.reads)} read(s))`,i=n.estimate==="atMost"?`at most ${t}, counted on whole tables`:n.estimate==="unknown"?"an unknown number of calls: an object was never counted":t,l=n.budgetRead===!1?"the daily requests left could not be read":`${L(n.remaining)} of ${L(n.max)} daily requests left`;return`API budget: the run takes ${i}; ${l}`}default:return e.kind}}function jt(e,r,n){return Se(e).map(({permission:t,permissionSet:i,others:l})=>{if(!i)return` ${t}: no permission set of ${r} holds it: an admin creates one that includes it`;let f=l.length>0?`; also held by ${l.map(d=>d.name).join(", ")}`:"",p=n?`: ${Ge(i.name,r,n)}`:"";return` ${t}: held by permission set ${i.name}, the smallest${f}${p}`})}function Kt(e,r,n={}){let t=[`target gaps: what ${r} holds against the rows, read from its metadata`],i=e.gaps.map(u=>u.id),l=e.gaps.filter(u=>u.kind==="api_budget"),f=e.gaps.filter(u=>u.kind!=="api_budget"),p=[...new Set(f.map(u=>u.objectApiName))].sort((u,o)=>u.localeCompare(o));for(let u of p){t.push(` ${u}`);for(let o of f.filter(a=>a.objectApiName===u)){let a=$e(o,n.lifted);t.push(` ${et(o,n.decisions,i,a)}`),a||t.push(...jt(o,r,n.username))}}f.length===0&&t.push(e.unread.length>0?" nothing found in what could be read":" no validation rule, duplicate rule, field only the target requires or lookup filter");for(let u of l)t.push(` ${et(u,n.decisions,i)}`);let d=f.filter(u=>u.detail?.formula==="notRead").length;d>0&&t.push(` ${d} validation rule formula(s) not read: the read takes ${n.formulasBound??ie} at most`);for(let{part:u,reason:o}of e.unread)t.push(` ${Gt[u]??u} could not be read: ${o}`);return t.push(` read in ${e.requests} request(s) to ${r}`),t}export{tt as a,W as b,ie as c,Vt as d,oe as e,mt as f,q as g,ht as h,nt as i,bt as j,Bt as k,kt as l,Ut as m,Qt as n,Xe as o,rt as p,Wt as q,Kt as r};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i,l as j,m as k,n as l,o as m,p as n,q as o,r as p,s as q,t as r,u as s,v as t,w as u,x as v,y as w,z as x}from"./chunk-MNITSYI2.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{g as IDS_PER_LINE,m as OverwritesRead,h as PIPELINE_NAME_KEPT,e as SCENARIO_COMPANION_SUFFIX,d as SYNC_FILE_OBJECTS,a as SYNC_RUNS_DIR,c as SYNC_RUNS_HARD_MAX_BYTES,b as SYNC_RUNS_MAX_BYTES,x as SyncRunCreations,i as backupIdSchema,u as configTargetOf,o as createdCount,r as deletedCount,v as earlierRunsOf,f as nodeSyncRunCreations,p as overwrittenCount,j as readRemovalState,l as readRunFile,t as settled,n as syncRemovalPlan,q as syncRestorePlan,k as syncRunFileId,s as syncUndeletePlan,w as writtenAgainBy};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a as Re}from"./chunk-K77NR3UK.mjs";import{K as we,Q as Se,b as ye}from"./chunk-IM2XA6JI.mjs";import{Ga as he,Ia as be,h as x,i as fe,j as ge,k as D}from"./chunk-KGYXLSQ5.mjs";import{o as se,p as ie,q as ae,r as de,s as ue}from"./chunk-UIUPPEFB.mjs";import{g as oe}from"./chunk-6IGEASOF.mjs";import{$b as B,Rb as ce,Sb as le,Tb as N,Ub as me,nc as pe}from"./chunk-KOQV4WXC.mjs";import{h as re}from"./chunk-KRNFVAGC.mjs";import{b as z}from"./chunk-HFSBDM7B.mjs";import{q as F}from"./chunk-55LQD3Y3.mjs";import{c as ee,d as te,g as ne}from"./chunk-3B5H24ZG.mjs";import{b as v}from"./chunk-CA5NAXSU.mjs";import{Bd as V,Ed as X,Fd as J,Gd as Y,Hd as Z,Lc as H,Yb as G,h as W,i as O,k as U,ld as K,od as Q,qd as P}from"./chunk-DPYTG6DM.mjs";var L=1e4,$e=U.REST_API_BATCH_SIZE;function Oe(e){return e.id===void 0&&e.error!==void 0&&(e.errorDetails?.length??0)>0&&se([e.error],e.errorDetails)}function Pe(e,r){return e.error===void 0?e:{...e,error:ae(e.error,r)}}function C(e){return{successIds:e.flatMap(r=>r.id===void 0?[]:[r.id]),errors:e.flatMap(r=>r.error===void 0?[]:[r.error])}}function Ae(e,r){if(e.aborted||e.outcomes.length!==r||(e.unmatchedIds?.length??0)>0||(e.failures??[]).some(n=>n.recordIndex<0))return;let t=new Array(r);for(let n of e.outcomes){if(n.recordIndex<0||n.recordIndex>=r)return;if(n.success){if(!n.id)return;t[n.recordIndex]={id:n.id}}else{let o=n.error??"Unknown error",s=te(o);t[n.recordIndex]={error:o,...s?{errorDetails:[s]}:{}}}}return t.every(n=>n!==void 0)?t:void 0}function ze(e){let{conn:r,bulkManager:t,retry:n,signal:o,label:s}=e,p=new re(e.bulkThreshold),g,y=async(f,a,c)=>{g??=be(r).then(l=>(l||e.log(`[WARN] ${s}: the org's duplicate rules could not be read: an object of more than the Bulk API threshold goes as a Bulk API job, which a duplicate rule may refuse`),l));let h=await g;if(h===void 0)return he.has(f)?(e.log(`[INFO] ${s}: ${f} goes through REST: the duplicate rules could not be read, and a standard rule watches it`),!0):!1;let b=h.has(f);return b&&e.log(`[INFO] ${s}: ${f} goes through REST: an active duplicate rule watches it, which a Bulk API job cannot waive`+(a>L?` \u2014 ${a} records in ${Math.ceil(a/Math.max(1,c))} calls, slower than one job`:"")),b},R=async(f,a,c)=>{let h=[];for(let b=0;b<a.length;b+=c){if(o.aborted)return{rows:h,stopped:!0};let l=a.slice(b,b+c);e.calls?.sending(f,l.length);let w=await n.execute(async()=>r.sobject(f).create(l,{headers:G()}));if(w.cancelled)return e.calls?.answered(f,[]),{rows:h,stopped:!0};if(w.success&&w.result){let i=[];for(let m of w.result)if(m.success&&m.id)i.push(m.id),h.push({id:m.id});else{let d=ne(m.errors);h.push({error:d,errorDetails:(m.errors??[]).map(ee)})}e.calls?.answered(f,i)}else{let i=w.error?.message??"Insert failed after retries";for(let m=0;m<l.length;m++)h.push({error:i});e.calls?.answered(f,[])}}return{rows:h}},u=e.wait??(f=>ie(f,o)),A=async(f,a,c,h)=>{let b=Math.min(Math.max(1,h),$e),l=await de({outcomes:c,locked:Oe,written:i=>i.id!==void 0,send:async i=>(await R(f,i.map(m=>a[m]),b)).rows,note:Pe,wait:u,stopped:()=>o.aborted}),w=ue("record(s)",l);return{rows:l.outcomes,notes:w===void 0?[]:[`${f}: ${w}.`]}};return async(f,a,c,h)=>{let b=(c.length>L||p.shouldUseBulkApi(c.length))&&await y(a,c.length,h),l=b&&await g===void 0?[`The org's duplicate rules could not be read (the user SandForge connects as needs View Setup and Configuration): ${a}, which a standard duplicate rule watches, was sent through REST, whose header lets its matches be saved, rather than as a Bulk API job.`]:[];if(c.length>L&&!b){if(o.aborted)return{successIds:[],errors:[],stopped:!0};let d=new ye({signal:o}),S={connection:r,bulkManager:t,onProgress:(T,Ie)=>{e.onProgress(T,Ie,`Streaming insert ${a}`)},onOpened:T=>e.calls?.sending(a,c.length,{job:T})};e.calls?.sending(a,c.length);let E=await d.executeChunked(S,a,"insert",d.createChunkGenerator(c),c.length);e.calls?.answered(a,E.aborted?[]:E.successIds);let j=E.aborted?void 0:Ae({outcomes:E.outcomes??[],unmatchedIds:E.unmatchedIds},c.length),k=j&&await A(a,c,j,h);return k&&k.notes.length>0?{...C(k.rows),notes:k.notes}:{successIds:E.successIds,errors:E.errors,...E.aborted?{stopped:!0}:{}}}if(p.shouldUseBulkApi(c.length)&&!b){if(o.aborted)return{successIds:[],errors:[],stopped:!0};let d={connection:r,bulkManager:t,onProgress:(k,T)=>{e.onProgress(k,T,`Bulk insert ${a}`)},signal:o,onOpened:k=>e.calls?.sending(a,c.length,{job:k})};e.calls?.sending(a,c.length);let S=await p.executeBulk(d,a,"insert",c);e.calls?.answered(a,S.aborted?[]:S.successIds);let E=Ae(S,c.length),j=E&&await A(a,c,E,h);return j&&j.notes.length>0?{...C(j.rows),rows:j.rows,notes:j.notes}:{successIds:S.successIds,errors:S.failures.map(k=>k.error),...E?{rows:E}:{},...S.aborted?{stopped:!0}:{}}}let w=await R(a,c,h);if(w.stopped)return{...C(w.rows),rows:w.rows,stopped:!0};let i=await A(a,c,w.rows,h),m=[...l,...i.notes];return{...C(i.rows),rows:i.rows,...m.length>0?{notes:m}:{}}}}var xe="SELECT Id, DeveloperName FROM RecordType WHERE SobjectType = 'Account' AND IsPersonType = true";async function rt(e){try{return(await e.query(xe)).records.flatMap(t=>typeof t.Id=="string"&&typeof t.DeveloperName=="string"?[{id:t.Id,developerName:t.DeveloperName}]:[])}catch{return[]}}function ot(e,r,t){let n=new Set(e===F?t.map(o=>o.id.slice(0,15)):[]);return z(r).filter(o=>!o.master&&o.active&&o.available).map(o=>({recordTypeId:o.recordTypeId,developerName:o.developerName,label:o.name,person:n.has(o.recordTypeId.slice(0,15)),isDefault:o.defaultRecordTypeMapping}))}function Ce(e){let{staticValue:r,picklistValues:t}=e.config;return e.ruleType==="static"&&typeof r=="string"?[r]:e.ruleType==="picklist_random"?[...t??[]]:[]}function st(e,r){if(r.length===0)return{template:e,personObjects:[]};let t=new Map(r.map(s=>[s.id.slice(0,15),s.developerName])),n=[],o=[];for(let s of e.objects){if(s.objectApiName!==F){o.push(s);continue}let p=s.fieldRules.find(u=>u.fieldApiName==="RecordTypeId"),g=p?Ce(p):[],y=g.filter(u=>t.has(u.slice(0,15)));if(y.length>0&&y.length<g.length){let u=y.map(A=>t.get(A.slice(0,15))).join(", ");return{refusal:`${F}: ${u} ${y.length===1?"is a person account record type":"are person account record types"} and the other record types chosen are not: a person account and a business account take different fields. Seed one kind in a run.`}}let R=y.length>0?"person":"business";R==="person"&&n.push(s.objectApiName),o.push({...s,fieldRules:s.fieldRules.filter(u=>!H(F,u.fieldApiName,R))})}return{template:{...e,objects:o},personObjects:n}}var Me=/^[a-z]{2,3}(?:_[A-Za-z0-9]{2,4}){0,2}$/;async function ve(e){try{let t=(await e.query("SELECT DefaultLocaleSidKey FROM Organization LIMIT 1")).records[0]?.DefaultLocaleSidKey;return typeof t=="string"&&Me.test(t)?t:void 0}catch{return}}async function at(e,r){return e??await ve(r)??"en_US"}var ft="SEED_FIT_STORAGE_UNREAD",gt="SEED_CANNOT_FIT";function ht(e,r=!1){return q(e.objects.filter(t=>t.recordCount>0).map(t=>t.objectApiName),r)}function q(e,r=!1){let t=new Set(e);return(n,o)=>t.has(n)&&(o==="insert"||o==="update"&&r&&n===Re)}function bt(e,r,t,n){if(typeof e.unread=="string")return{room:{perRecord:[],notCounted:[],unread:e.unread},unread:e.unread};let o=Z(e,r,t);if(!n)return{running:o,room:x(o,t)};let s=[],p=new Set,g=[];for(let u of o.firing){let A=u.flow,f=A?.requiresFilled??[];if(u.write!=="insert"||A?.condition!=="read"||!A.creates?.length)continue;let a=f.filter(b=>n(u.objectApiName,b)==="every"),c=f.filter(b=>n(u.objectApiName,b)==="some"),h={objectApiName:u.objectApiName,name:u.name};a.length>0&&!Ne(o.firing,u)?(p.add(u),s.push({...h,fields:a,why:"leftEmpty"})):(a.length>0||c.length>0)&&(g.push(u),s.push({...h,fields:a.length>0?a:c,why:a.length>0?"automationMayFill":"mayBeLeftEmpty"}))}let y=x({firing:o.firing.filter(u=>!p.has(u))},t),R=x({firing:g},t).perRecord;return{running:o,room:{...y,...R.length>0?{atMost:R}:{},...s.length>0?{starts:s}:{}}}}function Ne(e,r){return e.some(t=>t!==r&&t.objectApiName===r.objectApiName&&t.write==="insert"&&(t.kind==="trigger"||t.kind==="process"||t.kind==="workflowRule"||t.flow?.timing==="beforeSave"))}async function yt(e,r,t){let n=new Set("objects"in r?r.objects.filter(s=>s.flows.some(p=>(p.requiresFilled??[]).length>0)).map(s=>s.objectApiName):[]),o=new Map;for(let s of e.objects)s.recordCount<=0||!n.has(s.objectApiName)||o.set(s.objectApiName,await t(s.objectApiName).catch(()=>{}));return(s,p)=>{let g=e.objects.find(a=>a.objectApiName===s);if(!g)return"none";let y=a=>a.toLowerCase()===p.toLowerCase();if(g.fieldRules.some(a=>y(a.fieldApiName)))return"none";let R=O(s,e.relations);if(R&&y(R.lookupField))return"none";let u=g.rows??[],A=u.filter(a=>Object.entries(a.values).some(([c,h])=>y(c)&&h!==null&&h!=="")).length;if(u.length>0&&A===u.length)return"none";let f=o.get(s);return f?[...f.filled].some(y)?"none":A>0?"some":[...f.empty].some(y)?"every":"some":"some"}}function M(e,r){return O(e.objectApiName,r)?.distribution.mode==="byKey"?"byKey":e.rows!==void 0?"rows":void 0}function ke(e,r){let t=O(e,r.relations);if(!(!t||t.parents.kind!=="generated"||t.distribution.mode==="byKey"||t.parentObject===e||!r.objects.some(n=>n.objectApiName===t.parentObject)))return t}function Ee(e,r){let t=r?.objects?.[e.objectApiName]??r?.all;return t!==void 0?Math.min(e.recordCount,Math.max(1,Math.floor(t))):e.recordCount}function Be(e,r,t){let n=new Map(e.objects.map(g=>[g.objectApiName,g])),o=new Map,s=new Set,p=g=>{let y=o.get(g);if(y!==void 0)return y;let R=n.get(g);if(M(R,e.relations))return o.set(g,R.recordCount),R.recordCount;s.add(g);let u=Math.round(r*Ee(R,t)),A=ke(g,e),f=A&&!s.has(A.parentObject)?Math.max(1,Math.min(u,W(A.distribution,p(A.parentObject)))):Math.max(1,u);return s.delete(g),o.set(g,f),f};return new Map(e.objects.map(g=>[g.objectApiName,p(g.objectApiName)]))}function De(e,r){if(r.cannotFit!==void 0)return e;let t=new Map(r.objects.map(n=>[n.objectApiName,n.after]));return{...e,objects:e.objects.map(n=>{let o=t.get(n.objectApiName);return o!==void 0&&o<n.recordCount?{...n,recordCount:o}:n})}}function Le(e,r){let t=e.objects.filter(s=>!M(s,e.relations)),n=t.filter(s=>!ke(s.objectApiName,e)),o;for(let s of n.length>0?n:t){let p=Ee(s,r);(!o||p>o.records)&&(o={objectApiName:s.objectApiName,records:p})}return o}function _e(e){return`${e} record${e===1?"":"s"}`}function qe(e){let{template:r,personObjects:t,budget:n,room:o}=e,s=e.ask?.caps,p=e.ask?.share===!0||s===void 0,g=d=>{let S=Be(r,d,s),E=De(r,{objects:r.objects.map(k=>({objectApiName:k.objectApiName,before:k.recordCount,after:S.get(k.objectApiName)??k.recordCount}))}),j=fe(o,k=>S.get(k)??0);return{counts:S,bytes:Se(E,t)+j,roomBytes:j,requests:we(E,e.path),records:[...S.values()].reduce((k,T)=>k+T,0)}},y=d=>d.bytes<=n.bytes,R=d=>n.runRequests===void 0||d.requests<=n.runRequests,u=d=>y(d)&&R(d),A=(d,S,E,j)=>({share:d,budget:{...ge(n,S.roomBytes,o),...E==="apiRequests"?{limitedBy:"apiRequests"}:{}},objects:r.objects.map(k=>{let T=M(k,r.relations);return{objectApiName:k.objectApiName,before:k.recordCount,after:S.counts.get(k.objectApiName)??k.recordCount,...T?{keptWhole:T}:{}}}),estimateMB:S.bytes/1048576,...j!==void 0?{cannotFit:j}:{},...o.unread!==void 0?{automationUnread:o.unread}:{}}),f=(d,S,E,j)=>({proposal:A(d,S,E,j),heldBy:E,records:S.records,requests:S.requests}),a=d=>{if(y(d))return`about ${d.requests} API requests, past the ${n.runRequests??0} that leave the org a tenth of its daily requests`;let S=pe(d.bytes/1048576,n.bytes/1048576);return`${S.over} MB`+(d.roomBytes>0?", room for what the org's automation creates under them included":"")+`, past the ${S.bound} MB that fit`},c=d=>y(d)?"apiRequests":n.terms.limitedBy,h=r.objects.filter(d=>M(d,r.relations)).reduce((d,S)=>d+S.recordCount,0),b=g(1);if(u(b)){let d=r.objects.some(S=>(b.counts.get(S.objectApiName)??0)<S.recordCount);return f(1,b,d?"caps":"whole")}if(!p)return f(1,b,c(b),`with these caps the seed takes ${a(b)}: lower them, or fit by share`);let l=Le(r,s);if(!l)return f(1,b,c(b),`the ${h} rows the template gives take ${a(b)}, and rows are kept whole`);let w=d=>g(d/l.records),i=D(l.records,d=>u(w(d)));if(i===0){let d=w(1);return f(1/l.records,d,c(d),`the least it can be cut to \u2014 one ${l.objectApiName} and what follows it`+(h>0?`, with the ${h} rows the template gives kept whole`:"")+`, ${_e(d.records)} \u2014 takes ${a(d)}`)}let m=D(l.records,d=>y(w(d)));return f(i/l.records,w(i),m>i?"apiRequests":n.terms.limitedBy)}function wt(e,r,t,n,o){if(!("unread"in e))return qe({template:r,personObjects:t,budget:e,room:n,path:o}).proposal}function St(e,r){if(!(!e||e.before<r))return{module:"seed",share:e.share,...e.withinMB!==void 0?{withinMB:e.withinMB}:{},kept:r,inSource:e.before}}var Fe=(e,r)=>r==="insert";function je(e){return typeof e.unread=="string"}function We(e){return(K(e).find(t=>t.write==="insert")?.fired??[]).map(t=>{let n=t.flow,o=n?.messages??[];return{kind:t.kind,name:t.name,when:t.when,emails:o.filter(s=>s.kind==="email").length,messages:[...new Set(o.flatMap(s=>s.kind==="email"?[]:[s.kind]))],creates:[...n?.creates??[]],afterCommit:(n?.paths?.length??0)>0,bypasses:(n?.permissions??[]).filter(s=>s.bypass).map(({name:s,held:p})=>p===void 0?{name:s}:{name:s,held:p}),keptQuiet:t.keptQuiet===!0,unread:n!==void 0&&n.condition!=="read"}})}function $(e){return[...new Set(e)].sort((r,t)=>r.localeCompare(t))}function Te(e,r,t,n,o=Fe){let s=e.objects.flatMap(l=>{let w=We(l);return w.length>0?[{objectApiName:l.objectApiName,entries:w}]:[]}),p=je(t)?void 0:t,g=p!==void 0&&ce(p),y=p!==void 0&&le(p),R=N(P(e),g,y),u=s.flatMap(l=>l.entries.flatMap(w=>w.bypasses)),A=$(u.filter(l=>l.held===!0).map(l=>l.name)),f=$(u.map(l=>l.name)).filter(l=>!A.includes(l)),a=V(e,f),c=f.map(l=>{let w=a.find(i=>i.permission.toLowerCase()===l.toLowerCase())?.permissionSet;return w?{permission:l,permissionSet:w.name}:{permission:l}}),h=X(e,o),b=h.assign.length>0;return{org:r,objectsRead:[...e.objectsRead],objects:s,emailsPerRecord:R,...p&&R.length>0?{limits:{...p}}:{},...je(t)?{limitsUnread:t.unread}:{},alertsAsSingle:g,bypasses:c,bypassesHeld:A,...b?{mute:h,emailsPerRecordMuted:N(P(Y(e,J(h))),g,y)}:{},unread:e.unread.map(({part:l,reason:w})=>({part:l,reason:w})),blinded:Q(e.unread),conditionsNotRead:e.conditionsNotRead,...n?{deliverability:n}:{}}}async function Ft(e){let r=e.writes??q(e.objects),t;try{t=await e.readAutomation(e.objects)}catch(s){return{error:v(s)}}let n=e.deliverability??(e.readDeliverability?(await oe({read:t,writes:Fe,readDeliverability:e.readDeliverability,accepted:!1,target:e.org,run:"seed"})).gate.deliverability:void 0);if(P(t).length===0)return{preview:Te(t,e.org,{},n,r)};let o=await e.readLimits().catch(s=>({unread:v(s)}));return{preview:Te(t,e.org,o,n,r)}}function I(e,r="and"){return e.length<=1?e.join(""):e.length===2?`${e[0]} ${r} ${e[1]}`:`${e.slice(0,-1).join(", ")}, ${r} ${e[e.length-1]}`}var It="SEED_EMAILS_EXCEEDED";function $t(e,r,t){if("error"in e)return{checks:[],unknown:[`what ${t} runs as these records are created could not be read (${e.error}): the emails they make it send are not known`]};let{preview:n}=e,o={objects:r.map(i=>({objectApiName:i.objectApiName,rows:i.recordCount,storageBytes:0}))},s=n.limitsUnread!==void 0?{unread:n.limitsUnread}:n.limits??{},p=me(o,n.emailsPerRecord,s),g=new Set(r.filter(i=>i.recordCount>0).map(i=>i.objectApiName)),y=n.objects.flatMap(i=>g.has(i.objectApiName)?i.entries.filter(m=>m.unread&&!m.keptQuiet&&m.when!=="before").map(m=>`"${m.name}" on ${i.objectApiName}`):[]),R=[...p.filter(i=>i.verdict==="unread").map(i=>`about ${B(i.emails,i.limit)}, but what ${t} has left today could not be read (${i.unread??"not said"})`),...n.blinded?[`part of what ${t} runs could not be read: emails it sends may not be counted`]:[],...y.length>0?[`the emails of ${I(y)} are not counted: what ${y.length===1?"it does":"they do"} was not read`]:n.conditionsNotRead>0?[`${n.conditionsNotRead} start condition(s) of ${t} not read: the emails of those flows are not counted`]:[]],u=p.find(i=>i.verdict==="exceeds");if(!u)return R.length>0?{checks:p,unknown:R}:{checks:p};let A=p.filter(i=>i.verdict==="exceeds"),f=$(A.flatMap(i=>i.objects.map(m=>m.objectApiName))),a=$(A.flatMap(i=>i.objects.flatMap(m=>m.sentBy))),c=new Map;for(let i of n.objects.flatMap(m=>m.entries))if(!(i.emails===0||!a.includes(i.name)))for(let{name:m}of i.bypasses)c.set(m,(c.get(m)??new Set).add(i.name));let h=n.bypasses.flatMap(i=>{let m=c.get(i.permission);return m?[{...i,quiets:$([...m])}]:[]}),b=A.map(i=>`about ${B(i.emails,i.limit)} (`+i.objects.map(m=>`${m.perRecord} per ${m.objectApiName}`).join(", ")+`), ${i.remaining??0} of ${i.max??0} left today`).join("; "),l=["lower the record counts",`set ${I(f)} to 0`,`turn off ${I(a.map(i=>`"${i}"`))}`,...h.map(i=>"give the user the seed writes as "+(i.permissionSet?`the permission set ${i.permissionSet}, whose ${i.permission}`:`a permission set holding ${i.permission}, which`)+` keeps ${I(i.quiets.map(m=>`"${m}"`))} quiet`)],w=`The seed was refused before it wrote anything: its records would make ${t} send ${b}. Past what is left, a flow that sends in the save refuses its record (CANNOT_EXECUTE_FLOW_TRIGGER), and the org's own emails stop for the rest of the day. To seed it, ${I(l,"or")}. Nothing was written.`;return{checks:p,refusal:w,figures:{org:t,limit:u.limit,emails:u.emails,remaining:u.remaining??0,max:u.max??0,objects:f,senders:a,bypasses:h},...R.length>0?{unknown:R}:{}}}var Ue={flow:e=>`flow "${e}"`,trigger:e=>`Apex trigger ${e}`,process:e=>`process "${e}"`,workflowRule:e=>`workflow rule "${e}"`},Ge={before:"before save",after:"after save",beforeAndAfter:"before and after save"},He={notification:"custom notifications",outbound:"outbound messages",sms:"text messages"};function Ke(e){let r=n=>n.held===!0?" (held)":n.held===!1?" (not held)":"",t=[Ge[e.when],...e.emails>0?[`${e.emails} email(s) a record`]:[],...e.messages.map(n=>`sends ${He[n]}`),...e.creates.length>0?[`creates ${e.creates.join(", ")}`]:[],...e.afterCommit?["then after commit"]:[],...e.bypasses.length>0?[`not for a user with ${e.bypasses.map(n=>n.name+r(n)).join(", ")}`]:[],...e.keptQuiet?["quiet for this seed"]:[],...e.unread?["what it does was not read"]:[]];return`${Ue[e.kind](e.name)} (${t.join("; ")})`}function Ot(e,r){if("error"in e)return[`target automation: what ${r} runs as these records are created could not be read (${e.error}): the emails they make it send are not known`];let{preview:t}=e,n=[`target automation: what ${r} runs as these records are created`];for(let o of t.objects)n.push(` ${o.objectApiName}: ${o.entries.map(Ke).join(", ")}`);t.objects.length===0&&n.push(t.blinded?" nothing found in what could be read":" nothing runs on them: no flow, Apex trigger, process or workflow rule"),t.bypassesHeld.length>0&&n.push(` bypass held: the user the seed writes as holds ${t.bypassesHeld.join(", ")}, and what names it stays quiet`);for(let o of t.bypasses)n.push(o.permissionSet?` bypass: ${o.permission} keeps quiet what names it; permission set ${o.permissionSet} holds it`:` bypass: ${o.permission} keeps quiet what names it; no permission set of ${r} was found to hold it`);t.alertsAsSingle&&t.emailsPerRecord.some(o=>o.alertsAmong)&&n.push(` ${r} counts its email alerts against its single emails too, as a Developer Edition does`);for(let{part:o,reason:s}of t.unread)n.push(` ${o} could not be read: ${s}`);return t.conditionsNotRead>0&&n.push(` ${t.conditionsNotRead} start condition(s) not read`),n}export{ze as a,rt as b,ot as c,st as d,at as e,ft as f,gt as g,ht as h,q as i,bt as j,yt as k,De as l,qe as m,wt as n,St as o,Ft as p,It as q,$t as r,Ot as s};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{J as H}from"./chunk-ZWCRWF7E.mjs";import{b as R,c as de,d as _}from"./chunk-BNO5GIJ6.mjs";import{i as ae}from"./chunk-INIT2UKJ.mjs";import{h as Y}from"./chunk-TZE3Y7IQ.mjs";import{b as F}from"./chunk-CA5NAXSU.mjs";var ke=5,Ie=100;function m(n){return n.slice(0,15)}function N(n){return n==null||n===""}var ce=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;function Re(n,e){if(N(n)||N(e))return N(n)&&N(e);if(typeof n=="number"||typeof e=="number")return Number(n)===Number(e);if(typeof n=="string"&&typeof e=="string"){if(n===e)return!0;if(ce.test(n)&&ce.test(e)){let s=Date.parse(n);return Number.isFinite(s)&&s===Date.parse(e)}return!1}return JSON.stringify(n)===JSON.stringify(e)}function Ae(n){let e;return()=>(e??=(async()=>{try{let s=await n.userId?.();return typeof s=="string"&&s!==""?m(s):void 0}catch{return}})(),e)}async function fe(n){let e=Date.now();try{let s=Date.parse(await n.serverTime());return Number.isFinite(s)?s-(e+Date.now())/2:0}catch{return 0}}async function Oe(n,e){let s=Date.parse(e??"");return Number.isFinite(s)?s+await fe(n)+H:Number.NEGATIVE_INFINITY}var ve=1e3;function Se(n){let e=Date.parse(n);return Number.isFinite(e)?e-ve:Number.NEGATIVE_INFINITY}function Pe(n,e){let s=Object.hasOwn(n,e)?n[e]:[];return new Map(s.filter(o=>o.toLowerCase()!=="id").map(o=>[o.toLowerCase(),o]))}var Ee={INACTIVE_OWNER_OR_USER:"OwnerId"};function je(n,e){let s=new Set;for(let r of n.errors??[]){if(typeof r=="string")continue;if(Array.isArray(r.fields))for(let g of r.fields)typeof g=="string"&&s.add(g);let c=r.statusCode!==void 0?Ee[r.statusCode]:void 0;c!==void 0&&(!Array.isArray(r.fields)||r.fields.length===0)&&s.add(c)}let o=new Map(Object.keys(e).map(r=>[r.toLowerCase(),r]));return[...s].flatMap(r=>{let c=o.get(r.toLowerCase());return c!==void 0&&c!=="Id"?[c]:[]})}function Fe(n,e){let s=Array.isArray(n)?n:[n];return Array.from({length:e},(o,r)=>s[r]??{success:!1})}function Q(n){let e=n.errors?.[0];if(e===void 0)return{words:"The org gave no reason."};if(typeof e=="string")return{words:e};let s=e.statusCode,o=e.message??"";return{...s?{code:s}:{},words:s&&o?`${s}: ${o}`:s||o}}function C(n,{fields:e,why:s}){return`${e.map(o=>`${n}.${o}`).join(", ")}: the value from before is no longer taken (${s}) \u2014 left as the run wrote it`}async function Le(n,e,s){let o=new Set;try{for(let r of _(s)){let c=await n.query(`SELECT Id FROM ${e} WHERE Id IN (${r})`);for(let g of c.records)typeof g.Id=="string"&&o.add(m(g.Id))}}catch(r){return{unread:F(r)}}return{live:o}}var Z=class{result;said=new Set;constructor(e,s){this.result={objectApiName:e,planned:s,restored:0,keptChanged:0,alreadyGone:0,refused:0,notKept:0,reasons:[]}}without(){this.result.restoredWithout=(this.result.restoredWithout??0)+1}reason(e){this.said.has(e)||this.said.size>=ke||(this.said.add(e),this.result.reasons.push(e))}};async function Qe(n){let{org:e,plan:s}=n,o=[],r=[],c={},g=!1,u=!1;if(s.length===0)return{objects:o,left:r,wrote:g,cancelled:u,stamps:c};let A=n.changedAfter!==void 0?Se(n.changedAfter):await Oe(e,n.lastWriteAt),w=new Map(Object.entries(n.stamps??{}).map(([b,x])=>[m(b),Date.parse(x)])),L=n.ownWriters&&n.ownWriters.length>0?new Set(n.ownWriters.map(m)):void 0,T=n.stampsFor,he=Ae(e);for(let{objectApiName:b,backup:x,ids:D}of s){let l=new Z(b,D.length);o.push(l.result);let W=n.unkept?.find(t=>t.objectApiName===b);if(W&&W.fields.length>0&&l.reason(`${W.fields.map(t=>`${b}.${t}`).join(", ")}: not kept, encrypted \u2014 the run's user cannot view encrypted data, and read their values from before masked; left as the run wrote them`),u||n.signal?.aborted){u=!0,l.result.notReached=D.length,r.push(...D);continue}let G=Y(b),k=new Map(D.map(t=>[m(t),t])),U=n.fields?Pe(n.fields,b):void 0,v=new Map,q=new Set;try{let t=await n.backups.batches(x,b,R);for await(let i of t??[])for(let a of i){if(typeof a.Id!="string"||!k.has(m(a.Id)))continue;let d=v.get(m(a.Id))??{};for(let[h,f]of Object.entries(a)){if(h==="Id")continue;let p=U?U.get(h.toLowerCase()):h;p!==void 0&&!(p in d)&&(d[p]=f)}if(U&&Object.keys(d).length===0){q.add(m(a.Id));continue}v.set(m(a.Id),d)}}catch(t){l.reason(`The values from before the run could not be read: ${F(t)}`),v.clear(),q.clear()}let ee=[...q].filter(t=>!v.has(t)).length;ee>0&&l.reason(`${ee} ${b} record(s) hold no value of a field that may be written back now: left as they are`);for(let t of[...k.keys()])v.has(t)||(l.result.notKept++,k.delete(t));if(k.size===0)continue;let te=new Set;for(let t of v.values())for(let i of Object.keys(t))te.add(Y(i));let ne=["Id","LastModifiedDate",...L?["LastModifiedById"]:[],...te],pe=ne.length>Ie?R/4:R,J=new Map,ye=async t=>{if(n.signal?.aborted)throw new B;return(await e.query(t)).records};try{for(let t of _([...k.values()],pe)){let i=await ae(`SELECT ${ne.join(", ")} FROM ${G} WHERE Id IN (${t})`,ye,{stamp:"LastModifiedDate"});for(let a of i)typeof a.Id=="string"&&J.set(m(a.Id),a)}}catch(t){if(t instanceof B){u=!0,l.result.notReached=k.size,r.push(...k.values());continue}l.result.refused+=k.size,l.reason(F(t)),r.push(...k.values());continue}let $=[],re=new Set,me=T?Date.now()+await fe(e)-H:0;for(let[t,i]of k){let a=J.get(t);if(!a){l.result.alreadyGone++,n.counted?.(i,"alreadyGone");continue}let d=Date.parse(String(a.LastModifiedDate??"")),h=a.LastModifiedById,f=d<=A||d<=(w.get(t)??Number.NaN)||L!==void 0&&typeof h=="string"&&L.has(m(h));if(!f&&!n.includeChanged){l.result.keptChanged++,r.push(i);continue}let p=v.get(t)??{},y={Id:a.Id};for(let[I,O]of Object.entries(p))Re(O,a[I])||(y[I]=N(O)?null:O);if(Object.keys(y).length===1){l.result.restored++,n.counted?.(i,"restored"),f&&T?.(i)&&typeof a.LastModifiedDate=="string"&&(c[a.Id]=a.LastModifiedDate);continue}$.push(y),f&&T?.(i)&&re.add(i)}let P=[],S=[],E=(t,i)=>{l.result.refused++,l.reason(i),r.push(k.get(m(t.Id))??t.Id)},K=t=>{l.result.restored++,n.counted?.(k.get(m(t.Id))??t.Id,"restored")},we=t=>{l.result.alreadyGone++,n.counted?.(k.get(m(t.Id))??t.Id,"alreadyGone")},se=t=>{u=!0,l.result.notReached=(l.result.notReached??0)+t.length,r.push(...t.map(i=>k.get(m(i.Id))??i.Id))},oe=(t,i,a,d)=>{let h=Object.keys(t).filter(y=>y!=="Id"&&!i.includes(y));if(h.length>0){let y={Id:t.Id};for(let I of h)y[I]=t[I];P.push({record:y,leftOut:a});return}if(a.length===0){K(t);return}let[f,...p]=a;d?(l.without(),l.reason(C(b,f))):E(t,C(b,f));for(let y of p)l.reason(C(b,y))},z=async t=>{try{return g=!0,Fe(await e.update(b,[...t]),t.length)}catch(i){let a=F(i);return t.map(()=>({success:!1,errors:[a]}))}},be=async t=>{let i=n.keep;if(!i)return!0;let a=t.map(d=>{let h=J.get(m(d.Id))??{},f={Id:d.Id};for(let p of Object.keys(d))p!=="Id"&&(f[p]=h[p]??null);return f});try{return await i(b,a),!0}catch(d){let h=`What these ${t.length} ${b} record(s) hold now could not be kept before they were written (${F(d)}), so none of them was written: nothing is written over that cannot be put back.`;for(let f of t)E(f,h);return!1}};for(let t=0;t<$.length;t+=R){let i=$.slice(t,t+R);if(n.signal?.aborted){u=!0;let d=$.slice(t);l.result.notReached=(l.result.notReached??0)+d.length,r.push(...d.map(h=>k.get(m(h.Id))??h.Id));break}if(!await be(i))continue;(await z(i)).forEach((d,h)=>{let f=i[h];if(d.success===!0){K(f);return}let p=Q(d),y=je(d,f);if(p.code==="ENTITY_IS_DELETED"&&y.length===0){S.push({record:f,why:p.words});return}let I=Object.keys(f).filter(O=>O!=="Id"&&!y.includes(O));if(y.length>0&&I.length>0){let O={Id:f.Id};for(let ie of I)O[ie]=f[ie];P.push({record:O,leftOut:[{fields:y,why:p.words}]});return}E(f,p.words)})}let j=[];if(S.length>0&&n.signal?.aborted)se(S.map(({record:t})=>t));else if(S.length>0){let t=await Le(e,G,S.map(({record:i})=>i.Id));t.unread!==void 0&&l.reason(`Whether ${S.length} ${b} record(s) refused as deleted are still in the org could not be read (${t.unread}): left to be given back again`);for(let{record:i,why:a}of S){if(t.unread!==void 0){E(i,a);continue}if(!t.live.has(m(i.Id))){we(i);continue}let d=Object.keys(i).filter(h=>h!=="Id"&&de(i[h]));d.length===0?E(i,a):d.length===1?oe(i,d,[{fields:d,why:a}],!1):j.push({record:i,lookups:d,given:[],refusedAlone:[]})}}let V=j.length>0;for(let t=0;V&&j.some(({lookups:i})=>i.length>t);t++){let i=j.filter(({lookups:a})=>a.length>t);for(let a=0;a<i.length;a+=R){if(n.signal?.aborted){se(j.map(({record:f})=>f)),V=!1;break}let d=i.slice(a,a+R);(await z(d.map(({record:f,lookups:p})=>({Id:f.Id,[p[t]]:f[p[t]]})))).forEach((f,p)=>{let y=d[p],I=y.lookups[t];f.success===!0?y.given.push(I):y.refusedAlone.push({field:I,why:Q(f).words})})}}for(let t of V?j:[]){let i=new Map;for(let{field:a,why:d}of t.refusedAlone)i.set(d,[...i.get(d)??[],a]);oe(t.record,t.lookups,[...i].map(([a,d])=>({fields:d,why:a})),t.given.length>0)}for(let t=0;t<P.length;t+=R){let i=P.slice(t,t+R);if(n.signal?.aborted){u=!0,l.result.notReached=(l.result.notReached??0)+P.length-t,r.push(...P.slice(t).map(({record:d})=>k.get(m(d.Id))??d.Id));break}(await z(i.map(({record:d})=>d))).forEach((d,h)=>{let{record:f,leftOut:p}=i[h];if(d.success===!0){if(p.length===0){K(f);return}l.without();for(let y of p)l.reason(C(b,y));return}E(f,Q(d).words)})}Object.assign(c,await Ne(e,G,[...re],me,he))}return{objects:o,left:r,wrote:g,cancelled:u,stamps:c}}async function Ne(n,e,s,o,r){let c={};if(s.length===0)return c;let g=await r();if(g===void 0)return c;for(let u of _(s)){let A;try{A=(await n.query(`SELECT Id, LastModifiedDate, LastModifiedById FROM ${e} WHERE Id IN (${u})`)).records}catch{continue}for(let w of A)typeof w.Id=="string"&&typeof w.LastModifiedDate=="string"&&typeof w.LastModifiedById=="string"&&m(w.LastModifiedById)===g&&Date.parse(w.LastModifiedDate)>=o&&(c[w.Id]=w.LastModifiedDate)}return c}var B=class extends Error{};function Ze(n,e,s=[]){let o=n.map(r=>({...r}));for(let r of s){if(r.undeleted+r.refused===0)continue;let c=o.find(g=>g.objectApiName===r.objectApiName);c?(c.created+=r.undeleted,c.failed+=r.refused):o.push({objectApiName:r.objectApiName,created:r.undeleted,updated:0,deleted:0,failed:r.refused})}for(let r of e){let c=r.restored+(r.restoredWithout??0);if(c+r.refused===0)continue;let g=o.find(u=>u.objectApiName===r.objectApiName);g?(g.updated+=c,g.failed+=r.refused):o.push({objectApiName:r.objectApiName,created:0,updated:c,deleted:0,failed:r.refused})}return o}import{createReadStream as Me}from"node:fs";import{access as De,appendFile as $e,mkdir as _e,readFile as Ce,readdir as Be,rm as Te,stat as xe,writeFile as We}from"node:fs/promises";import*as M from"node:path";import{createInterface as Ge}from"node:readline";var ue=384,Ue=448;function rt(n){return{storagePath:n,readFile:e=>Ce(e,"utf8"),writeFile:(e,s)=>We(e,s,{encoding:"utf8",mode:ue}),appendFile:(e,s)=>$e(e,s,{encoding:"utf8",mode:ue}),exists:e=>De(e).then(()=>!0,()=>!1),readLines:e=>Je(e),mkdir:async e=>{await _e(e,{recursive:!0,mode:Ue})},rm:e=>Te(e,{force:!0}),listFiles:e=>qe(e)}}async function qe(n){let e;try{e=await Be(n,{withFileTypes:!0})}catch(o){if(o.code==="ENOENT")return[];throw o}let s=[];for(let o of e){if(!o.isFile())continue;let r=await xe(M.join(n,o.name)).catch(()=>{});r&&s.push({name:o.name,modifiedMs:r.mtimeMs})}return s}async function*Je(n){let e=Me(n,{encoding:"utf8"}),s=Ge({input:e,crlfDelay:1/0});try{for await(let o of s)yield o}finally{s.close(),e.destroy()}}function X(n){return n.replace(/[^A-Za-z0-9_-]/g,"_")}function le(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var ge=class{constructor(e){this.deps=e;this.dir=M.join(e.storagePath,"backups")}deps;dir;get directory(){return this.dir}filePath(e,s,o="lines"){let r=`${X(e)}__${X(s)}`;return M.join(this.dir,`${r}.${o==="lines"?"ndjson":"json"}`)}async begin(e,s){await this.deps.mkdir(this.dir).catch(()=>{}),await this.deps.writeFile(this.filePath(e,s),"")}async append(e,s,o){if(o.length===0)return;let r=o.map(c=>JSON.stringify(c)).join(`
|
|
8
|
+
`);await this.deps.appendFile(this.filePath(e,s),`${r}
|
|
9
|
+
`)}async batches(e,s,o){let r=this.filePath(e,s);if(await this.deps.exists(r))return{[Symbol.asyncIterator]:()=>this.readLineBatches(r,s,o)};let c=this.filePath(e,s,"array");return await this.deps.exists(c)?{[Symbol.asyncIterator]:()=>this.readArrayBatches(c,s,o)}:null}async*readLineBatches(e,s,o){let r=[],c=0;for await(let g of this.deps.readLines(e)){if(c+=1,g.trim()==="")continue;let u;try{u=JSON.parse(g)}catch{u=void 0}if(!le(u))throw new Error(`The backup of ${s} is damaged at line ${c} of its file: it holds no record there.`);r.push(u),r.length===o&&(yield r,r=[])}r.length>0&&(yield r)}async*readArrayBatches(e,s,o){let r=JSON.parse(await this.deps.readFile(e));if(!Array.isArray(r)||!r.every(le))throw new Error(`The backup of ${s} is damaged: its file holds no records.`);for(let c=0;c<r.length;c+=o)yield r.slice(c,c+o)}async delete(e,s){await this.deps.rm(this.filePath(e,s)).catch(()=>{}),await this.deps.rm(this.filePath(e,s,"array")).catch(()=>{})}async sweep(e,s,o){let r=[...e].map(u=>`${X(u)}__`),c=new Map;for(let u of await this.deps.listFiles(this.dir)){if(!/\.(?:ndjson|json)$/.test(u.name))continue;let A=u.name.indexOf("__");if(A<=0||r.some(L=>u.name.startsWith(L)))continue;let w=u.name.slice(0,A);c.set(w,[...c.get(w)??[],u])}let g=[];for(let u of c.values()){let A=Math.max(...u.map(w=>w.modifiedMs));if(!(o-A<s))for(let w of u)await this.deps.rm(M.join(this.dir,w.name)).then(()=>g.push(w.name),()=>{})}return g}};export{Re as a,Ae as b,fe as c,Oe as d,Qe as e,Ne as f,Ze as g,rt as h,ge as i};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e}from"./chunk-KNIRA333.mjs";import"./chunk-MNITSYI2.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as SEED_RUNS_DIR,a as SEED_RUNS_KEPT,e as SeedRunCreations,d as nodeSeedRunCreations,c as seedRunKept};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as A}from"./chunk-5LFSFYFJ.mjs";import{a as z,h as p}from"./chunk-TZE3Y7IQ.mjs";import{b as S}from"./chunk-CA5NAXSU.mjs";import{
|
|
7
|
+
import{a as A}from"./chunk-5LFSFYFJ.mjs";import{a as z,h as p}from"./chunk-TZE3Y7IQ.mjs";import{b as S}from"./chunk-CA5NAXSU.mjs";import{Yb as C}from"./chunk-DPYTG6DM.mjs";import{b as g,f as b,k as w,l as m,o as j}from"./chunk-WZQEK4WT.mjs";function H(r,n){return{describe:e=>r.describe(e),describeGlobal:()=>r.describeGlobal(),query:async e=>{let t=await r.query(e);return A(r.limitInfo,n),{totalSize:t.totalSize,records:t.records}},update:(e,t)=>r.sobject(e).update(t,{headers:C()}),destroy:(e,t)=>r.sobject(e).destroy(t)}}var u=200,P=30,I=100,M=4,y=10,q=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function B(r){return typeof r=="string"&&q.test(r)}function k(r,n=u){let e=[];for(let t=0;t<r.length;t+=n)e.push(r.slice(t,t+n).map(s=>`'${z(s)}'`).join(", "));return e}var L=m({success:b(),id:g().nullish(),errors:w(j([m({message:g()}).loose(),g()])).optional()}).loose(),W=m({name:g(),label:g(),queryable:b().optional(),createable:b().optional(),layoutable:b().optional()}).loose(),_=m({sobjects:w(W)}).loose();async function F(r){let n=_.parse(await r.describeGlobal());return new Map(n.sobjects.filter(e=>e.queryable===!0&&e.createable===!0&&e.layoutable===!0).map(e=>[e.name,e.label]))}async function E(r,n){let e=new Array(r.length),t=0,s=async()=>{for(;t<r.length;){let i=t++;e[i]=await r[i]()}};return await Promise.all(Array.from({length:Math.min(n,r.length)},s)),e}async function Q(r,n,e,t){if(e.length===0)return{related:[],uncounted:[]};let s=(n.childRelationships??[]).filter(o=>o.cascadeDelete===!0&&t.has(o.childSObject)),i=s.slice(0,P),a=new Set(s.slice(P).map(o=>t.get(o.childSObject)??o.childSObject)),l=k(e),h=await E(i.map(o=>async()=>{try{let c=p(o.childSObject),d=p(o.field),O=0;for(let T of l)O+=(await r.query(`SELECT COUNT() FROM ${c} WHERE ${d} IN (${T})`)).totalSize;return{relationship:o,records:O}}catch{return{relationship:o,records:null}}}),M),f=new Map;for(let{relationship:o,records:c}of h){let d=t.get(o.childSObject)??o.childSObject;if(c===null){a.add(d);continue}f.set(o.childSObject,(f.get(o.childSObject)??0)+c)}return{related:[...f].filter(([,o])=>o>0).map(([o,c])=>({objectApiName:o,label:t.get(o)??o,records:c})).sort((o,c)=>c.records-o.records||o.label.localeCompare(c.label)),uncounted:[...a].sort()}}async function Z(r,n,e,t,s=1){let i=p(n),a=[...new Set(["Id",...e])].map(p),l=a.join(", "),h=a.length>I?u/4:u,f=await E(k(t,h).map(o=>()=>r.query(`SELECT ${l} FROM ${i} WHERE Id IN (${o})`)),s),R=[];for(let o of f)for(let c of o.records){if(typeof c!="object"||c===null)continue;let d={...c};delete d.attributes,R.push(d)}return R}function x(r,n,e){let t=Array.isArray(r)?r:[r];for(let s of t){let i=L.safeParse(s);if(i.success&&i.data.success){e.done++;continue}if(e.failed++,e.errors.length<y){let a=i.success?i.data.errors?.[0]:void 0,l=typeof a=="string"?a:a?.message??"The org gave no reason.";e.errors.push({objectApiName:n,message:l})}}}async function J(r,n,e,t){let s={done:0,failed:0,errors:[]};for(let i=0;i<e.length&&!t?.aborted;i+=u){let a=e.slice(i,i+u);try{x(await r.update(n,[...a]),n,s)}catch(l){s.failed+=a.length,s.errors.length<y&&s.errors.push({objectApiName:n,message:S(l)})}}return s}async function V(r,n,e,t){let s={done:0,failed:0,errors:[]};for(let i=0;i<e.length&&!t?.aborted;i+=u){let a=e.slice(i,i+u);try{x(await r.destroy(n,[...a]),n,s)}catch(l){s.failed+=a.length,s.errors.length<y&&s.errors.push({objectApiName:n,message:S(l)})}}return s}function D(r,n){return n===0?"success":r===0?"failure":"partial"}function Y(r){let n=r.reduce((t,s)=>t+s.counts.done,0),e=r.reduce((t,s)=>t+s.counts.failed,0);return{status:D(n,e),done:n,failed:e,objects:r.map(t=>({objectApiName:t.objectApiName,done:t.counts.done,failed:t.counts.failed})),errors:r.flatMap(t=>t.counts.errors).slice(0,y)}}export{H as a,u as b,B as c,k as d,F as e,E as f,Q as g,Z as h,J as i,V as j,Y as k};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as y}from"./chunk-4TLYUZD5.mjs";import{d,f as i,g as u}from"./chunk-
|
|
7
|
+
import{a as y}from"./chunk-4TLYUZD5.mjs";import{d,f as i,g as u}from"./chunk-OHEOJISY.mjs";import{b as p,k as m,l as f}from"./chunk-WZQEK4WT.mjs";var M="SELECT Id, Name, DeveloperName, NamespacePrefix, SobjectType FROM RecordType WHERE IsActive = true",l=m(f({Id:p().min(1),Name:p(),DeveloperName:p().min(1),NamespacePrefix:p().nullable().optional(),SobjectType:p().min(1)}));function b(e){return l.parse(e).map(t=>({id:t.Id,name:t.Name,developerName:t.DeveloperName,namespacePrefix:t.NamespacePrefix?t.NamespacePrefix:null,sobjectType:t.SobjectType}))}var I=/^012000000000000(AAA)?$/;function T(e){return e===null||e===""||typeof e=="string"&&I.test(e)}function h(e){if(!T(e.RecordTypeId))return e;let t={...e};return delete t.RecordTypeId,t}function j(e,t,s="forge"){y.warn(`[${s}] ${e}: RecordTypeId ${t} has no active ${e} record type with the same API name on the target org. Records keep the source Id and the target org will likely refuse them \u2014 create or activate that record type on the target.`)}function k(e,t){let s=new Set(t.map(i)),a=[];for(let n of e){if(s.has(i(n)))continue;let o=t.filter(r=>r.developerName===n.developerName&&(r.sobjectType??"")===(n.sobjectType??""));o.length!==0&&a.push({objectApiName:n.sobjectType??"",source:d(n),target:o.map(d)})}return a}function v(e){let t=u(e.source).namespacePrefix,s=t?`of package ${t}`:"the source org's own";return`${e.objectApiName}: record type ${e.source}, ${s}, is not mapped to ${e.target.join(" or ")} in the target org: a record type is matched to one of the same namespace only. Its records keep the source Id unless the target gets ${e.source}, or a decision maps it.`}var R=class{buildMapping(t,s){let a=new Map;for(let o of s)a.set(i(o),o);let n=[];for(let o of t){let r=a.get(i(o));r&&n.push({sourceId:o.id,targetId:r.id,developerName:d(o)})}return n}apply(t,s,a){let n=new Map;for(let r of s)n.set(r.sourceId,r.targetId);let o=new Set;return t.map(r=>{let c=r.RecordTypeId;if(T(c))return h(r);if(typeof c!="string")return{...r};let g=n.get(c);return g?{...r,RecordTypeId:g}:(a&&!o.has(c)&&(o.add(c),a(c)),{...r})})}};export{M as a,b,T as c,h as d,j as e,k as f,v as g,R as h};
|