sandforge 1.81.0 → 1.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/bin/sandforge-users.mjs +12 -0
- package/lib/{chunk-J6G23RUI.mjs → chunk-262TP6UU.mjs} +1 -1
- package/lib/{chunk-NWVVCZUK.mjs → chunk-27BBEGUD.mjs} +1 -1
- package/lib/{chunk-Y5ZCPY36.mjs → chunk-2ADSD5WK.mjs} +1 -1
- package/lib/{chunk-55LQD3Y3.mjs → chunk-2GSMHGIV.mjs} +1 -1
- package/lib/chunk-2K5BYZQM.mjs +8 -0
- package/lib/{chunk-GK7VEYFM.mjs → chunk-2KTGDYUH.mjs} +1 -1
- package/lib/{chunk-T3PLRQ2T.mjs → chunk-2N73W63D.mjs} +1 -1
- package/lib/{chunk-7PK5QDQI.mjs → chunk-2R6GFNKF.mjs} +1 -1
- package/lib/{chunk-2OIRJEYE.mjs → chunk-2WMKJVD2.mjs} +1 -1
- package/lib/{chunk-D62KWDDT.mjs → chunk-36Y225OM.mjs} +1 -1
- package/lib/{chunk-HYOOJVR6.mjs → chunk-3CM7LAPE.mjs} +1 -1
- package/lib/{chunk-OIIL4NVI.mjs → chunk-3OVTKRS4.mjs} +1 -1
- package/lib/{chunk-UT27HXE7.mjs → chunk-3V4YH5KO.mjs} +1 -1
- package/lib/{chunk-OZNLOV4U.mjs → chunk-446GBKAC.mjs} +1 -1
- package/lib/{chunk-SQGP46QS.mjs → chunk-4GCYGQXD.mjs} +1 -1
- package/lib/{chunk-2NAIUKVL.mjs → chunk-4V3QO7HF.mjs} +1 -1
- package/lib/{chunk-GWRKS3AL.mjs → chunk-4X5D3MSV.mjs} +1 -1
- package/lib/{chunk-KGYXLSQ5.mjs → chunk-5OGNK3JP.mjs} +1 -1
- package/lib/{chunk-D7P7DTWL.mjs → chunk-6KOUYHEY.mjs} +1 -1
- package/lib/chunk-6QSHWIZI.mjs +48 -0
- package/lib/chunk-6VOQFISN.mjs +7 -0
- package/lib/{chunk-742SSN7I.mjs → chunk-6YC2ELCU.mjs} +1 -1
- package/lib/chunk-77IVKH7R.mjs +7 -0
- package/lib/{chunk-KNIRA333.mjs → chunk-77MZRBWX.mjs} +1 -1
- package/lib/{chunk-ZUA5BNAO.mjs → chunk-7BQMBXKX.mjs} +1 -1
- package/lib/{chunk-OQQHNYR7.mjs → chunk-7DPHZWA4.mjs} +2 -2
- package/lib/chunk-7V2UYZ6S.mjs +7 -0
- package/lib/chunk-7WSQ65WG.mjs +9 -0
- package/lib/{chunk-HVC5CYIB.mjs → chunk-7ZBDACVG.mjs} +1 -1
- package/lib/chunk-A32ISQ6M.mjs +28 -0
- package/lib/{chunk-XC2QKQT5.mjs → chunk-AG24QMSY.mjs} +1 -1
- package/lib/{chunk-K77NR3UK.mjs → chunk-AHUGG3WU.mjs} +1 -1
- package/lib/{chunk-K55LH4ZQ.mjs → chunk-ALBY5SOH.mjs} +1 -1
- package/lib/chunk-AXFD2OH6.mjs +7 -0
- package/lib/{chunk-YCSFP6ER.mjs → chunk-BH76USTQ.mjs} +1 -1
- package/lib/chunk-BNKT3R3F.mjs +7 -0
- package/lib/{chunk-YIGFYZQY.mjs → chunk-BPHTA6KP.mjs} +1 -1
- package/lib/{chunk-MNITSYI2.mjs → chunk-BT43WSOS.mjs} +1 -1
- package/lib/{chunk-ZWZXQTAK.mjs → chunk-BVZ5H3N4.mjs} +14 -14
- package/lib/{chunk-43K2C6H2.mjs → chunk-C6RKM4BB.mjs} +1 -1
- package/lib/{chunk-C4YGSK6W.mjs → chunk-CDWZGQAJ.mjs} +1 -1
- package/lib/chunk-CGZGL6VT.mjs +7 -0
- package/lib/{chunk-KE2PGD6C.mjs → chunk-CN5HGFG4.mjs} +1 -1
- package/lib/chunk-CQAFVEKP.mjs +13 -0
- package/lib/{chunk-XIZ5LMQM.mjs → chunk-CTPLYUXA.mjs} +1 -1
- package/lib/chunk-CXKZ6TYV.mjs +9 -0
- package/lib/{chunk-DHIW4IO5.mjs → chunk-D6JT4PAB.mjs} +1 -1
- package/lib/{chunk-AELFEK3G.mjs → chunk-D7XUNWWU.mjs} +1 -1
- package/lib/{chunk-GR3NGDVM.mjs → chunk-DB5RVDC5.mjs} +1 -1
- package/lib/{chunk-MO3N5XVV.mjs → chunk-DIGUC7S4.mjs} +2 -2
- package/lib/{chunk-2OZG6GRW.mjs → chunk-DKDKCGXV.mjs} +1 -1
- package/lib/chunk-DMT5SCO3.mjs +7 -0
- package/lib/chunk-DNQKVCUV.mjs +475 -0
- package/lib/{chunk-MAHZMPMZ.mjs → chunk-DSR2MSBH.mjs} +1 -1
- package/lib/{chunk-O6ADMP36.mjs → chunk-E3RQ575Y.mjs} +1 -1
- package/lib/{chunk-ETT5GP4P.mjs → chunk-EOQON3E5.mjs} +1 -1
- package/lib/{chunk-TKQQVB2D.mjs → chunk-ETNQHIDI.mjs} +1 -1
- package/lib/chunk-F5SBGJWW.mjs +7 -0
- package/lib/chunk-FBXH4VRQ.mjs +7 -0
- package/lib/chunk-FKCIGJOI.mjs +15 -0
- package/lib/{chunk-OVOLG3AL.mjs → chunk-FVLFO2S6.mjs} +1 -1
- package/lib/{chunk-YOGMP72T.mjs → chunk-FYWNSMOZ.mjs} +1 -1
- package/lib/{chunk-DHGPDSXS.mjs → chunk-GEEWPTV5.mjs} +1 -1
- package/lib/{chunk-FSDO4DJA.mjs → chunk-GLN4PI5P.mjs} +1 -1
- package/lib/{chunk-PYUEHBA6.mjs → chunk-GT5ZKU6V.mjs} +1 -1
- package/lib/chunk-GTRU5AV5.mjs +7 -0
- package/lib/chunk-H33DVU3D.mjs +7 -0
- package/lib/{chunk-5WGA5CZB.mjs → chunk-H4OBZIX3.mjs} +1 -1
- package/lib/{chunk-4L7FBOJS.mjs → chunk-HQZUQXDC.mjs} +1 -1
- package/lib/{chunk-VSU74RQ3.mjs → chunk-HVX2AFYW.mjs} +1 -1
- package/lib/chunk-I3ZO76LL.mjs +21 -0
- package/lib/{chunk-V4RKM4QZ.mjs → chunk-I5C4O3VA.mjs} +1 -1
- package/lib/{chunk-FSZTXLNW.mjs → chunk-IHGYJZZ2.mjs} +1 -1
- package/lib/chunk-ISA2NYJV.mjs +7 -0
- package/lib/{chunk-2IB7I3IQ.mjs → chunk-ISAUCWYK.mjs} +1 -1
- package/lib/{chunk-3B5H24ZG.mjs → chunk-ISOSTAJR.mjs} +1 -1
- package/lib/chunk-IXIY6Q4M.mjs +7 -0
- package/lib/{chunk-TPHXRHOA.mjs → chunk-J3TIHLWG.mjs} +1 -1
- package/lib/{chunk-TQM2XJ27.mjs → chunk-JAV6F6OA.mjs} +1 -1
- package/lib/chunk-JBWJ6UEZ.mjs +7 -0
- package/lib/{chunk-WM5JI4JI.mjs → chunk-JH4ZTVQN.mjs} +1 -1
- package/lib/{chunk-BZFIOZS3.mjs → chunk-JIPT5FUD.mjs} +1 -1
- package/lib/{chunk-6FMLW7PH.mjs → chunk-JPEVIXNH.mjs} +1 -1
- package/lib/{chunk-67CC7RAE.mjs → chunk-JREKJO3D.mjs} +1 -1
- package/lib/{chunk-3AOKLIVE.mjs → chunk-JUOQUG7U.mjs} +1 -1
- package/lib/chunk-JYUMD357.mjs +7 -0
- package/lib/{chunk-56MPPWLA.mjs → chunk-K7G3W7XH.mjs} +1 -1
- package/lib/{chunk-OU5W7SCB.mjs → chunk-KKS2KFBT.mjs} +1 -1
- package/lib/{chunk-RKALOKAU.mjs → chunk-KWAVSZ2B.mjs} +1 -1
- package/lib/{chunk-WI4HYWV6.mjs → chunk-KXUOHACP.mjs} +1 -1
- package/lib/{chunk-GTIXJCGS.mjs → chunk-L3I6DAHX.mjs} +1 -1
- package/lib/{chunk-FLNLG43R.mjs → chunk-L47JCNP3.mjs} +1 -1
- package/lib/{chunk-5344TZBT.mjs → chunk-L4MSL4U7.mjs} +1 -1
- package/lib/chunk-L4RJX7DG.mjs +7 -0
- package/lib/chunk-L6CLN664.mjs +7 -0
- package/lib/chunk-LI2XNV7F.mjs +7 -0
- package/lib/chunk-LP2D3JJP.mjs +7 -0
- package/lib/{chunk-EH5YUA5W.mjs → chunk-LWES2KZE.mjs} +1 -1
- package/lib/{chunk-YJEXE6HZ.mjs → chunk-LYOGCIYD.mjs} +2 -2
- package/lib/{chunk-BNO5GIJ6.mjs → chunk-MJD6CPZZ.mjs} +1 -1
- package/lib/{chunk-33ZX3A56.mjs → chunk-MTM4KG3T.mjs} +1 -1
- package/lib/{chunk-E2YJVSX6.mjs → chunk-N2HYG3BL.mjs} +1 -1
- package/lib/chunk-N5UIE4IR.mjs +7 -0
- package/lib/{chunk-R6TF26V4.mjs → chunk-NDFFIJL5.mjs} +1 -1
- package/lib/{chunk-FDGFUEK3.mjs → chunk-NFEBX75O.mjs} +1 -1
- package/lib/{chunk-QXLZINZB.mjs → chunk-NNV7IGM7.mjs} +1 -1
- package/lib/{chunk-OXKZ4Y3B.mjs → chunk-NS6ONPWL.mjs} +1 -1
- package/lib/{chunk-OEHVAJAB.mjs → chunk-O7GCCRPW.mjs} +1 -1
- package/lib/chunk-OO24ZYYJ.mjs +7 -0
- package/lib/chunk-OOIDCHBQ.mjs +9 -0
- package/lib/{chunk-MWLFFVQV.mjs → chunk-OS5GE52G.mjs} +1 -1
- package/lib/chunk-OS6HFJ7L.mjs +7 -0
- package/lib/{chunk-HYBH5PFM.mjs → chunk-OTJH6AEA.mjs} +1 -1
- package/lib/chunk-OUU47Y7A.mjs +7 -0
- package/lib/{chunk-FTA5LOVX.mjs → chunk-P6WRYJN3.mjs} +1 -1
- package/lib/{chunk-DXOXLUZA.mjs → chunk-PDRXM5WN.mjs} +1 -1
- package/lib/chunk-PGRY365W.mjs +7 -0
- package/lib/chunk-Q4PPI3KG.mjs +7 -0
- package/lib/chunk-QFTF2PGS.mjs +21 -0
- package/lib/chunk-QKJXIY6L.mjs +7 -0
- package/lib/{chunk-DMBR24CK.mjs → chunk-QLRWU3MB.mjs} +1 -1
- package/lib/chunk-QO4MPHZD.mjs +7 -0
- package/lib/chunk-QP3JLFIO.mjs +7 -0
- package/lib/{chunk-UCHAZ4ZU.mjs → chunk-QQDZQCO2.mjs} +1 -1
- package/lib/chunk-QROPNEGY.mjs +14 -0
- package/lib/{chunk-6NADW3OI.mjs → chunk-QXB6U3ZP.mjs} +1 -1
- package/lib/chunk-R3OM3X4L.mjs +8 -0
- package/lib/chunk-R7GKMAT4.mjs +7 -0
- package/lib/{chunk-JU2XEKEO.mjs → chunk-RVCPQVKM.mjs} +1 -1
- package/lib/{chunk-WEZLXE34.mjs → chunk-RZKJQOOC.mjs} +1 -1
- package/lib/chunk-S4PRKKGC.mjs +8 -0
- package/lib/{chunk-NJ3EOEHS.mjs → chunk-SX6QWYCQ.mjs} +1 -1
- package/lib/{chunk-ONMBSACW.mjs → chunk-T36DZJPH.mjs} +1 -1
- package/lib/{chunk-AJPSGVMD.mjs → chunk-T7DDS4UQ.mjs} +1 -1
- package/lib/chunk-TCEXCHXR.mjs +7 -0
- package/lib/chunk-TMIESDE5.mjs +7 -0
- package/lib/chunk-TQJ5NPRC.mjs +7 -0
- package/lib/chunk-TUPZY2QJ.mjs +7 -0
- package/lib/{chunk-2Z54GB6X.mjs → chunk-U2CTKIPE.mjs} +1 -1
- package/lib/{chunk-DQR5NDMI.mjs → chunk-U4YFYSF3.mjs} +1 -1
- package/lib/{chunk-EOSEMFPU.mjs → chunk-UIR77ZJD.mjs} +1 -1
- package/lib/{chunk-UUSLTW5V.mjs → chunk-UOHZW2L4.mjs} +1 -1
- package/lib/chunk-UV74P4H2.mjs +7 -0
- package/lib/{chunk-CULAOP3U.mjs → chunk-VXZ5PTOM.mjs} +1 -1
- package/lib/{chunk-IBURU7T7.mjs → chunk-VZLJZEV2.mjs} +1 -1
- package/lib/chunk-W3BQGMTR.mjs +7 -0
- package/lib/{chunk-WWTXRWNZ.mjs → chunk-WABXKL4N.mjs} +1 -1
- package/lib/{chunk-E2OBAWSH.mjs → chunk-WAYQLQAD.mjs} +1 -1
- package/lib/{chunk-6CDIIFNX.mjs → chunk-WBELLGNE.mjs} +1 -1
- package/lib/{chunk-LO527YLT.mjs → chunk-WJAZ5LHL.mjs} +1 -1
- package/lib/{chunk-6IGEASOF.mjs → chunk-WXU6ZJIV.mjs} +1 -1
- package/lib/{chunk-YHIOS2PU.mjs → chunk-WZN36ACK.mjs} +1 -1
- package/lib/{chunk-AITNZWLB.mjs → chunk-X2XZQ434.mjs} +1 -1
- package/lib/chunk-X4HZD5U2.mjs +7 -0
- package/lib/chunk-X6XNTOGO.mjs +7 -0
- package/lib/{chunk-5VQNKDFU.mjs → chunk-XAMMIPZ4.mjs} +1 -1
- package/lib/{chunk-MHW6DV6T.mjs → chunk-XAUQXYPW.mjs} +1 -1
- package/lib/{chunk-5UT2ZBGF.mjs → chunk-XCJUNX63.mjs} +1 -1
- package/lib/chunk-XJICAOAQ.mjs +7 -0
- package/lib/{chunk-GYKNCYES.mjs → chunk-XKFHTBAB.mjs} +1 -1
- package/lib/{chunk-6SEDOIO3.mjs → chunk-XMQ5R6TC.mjs} +1 -1
- package/lib/chunk-XPXEQKLR.mjs +7 -0
- package/lib/{chunk-SW2NUKQL.mjs → chunk-Y7YUNRKK.mjs} +1 -1
- package/lib/{chunk-UIUPPEFB.mjs → chunk-YBZIDW6W.mjs} +1 -1
- package/lib/{chunk-X2ZVSQ54.mjs → chunk-YEVB7LVK.mjs} +1 -1
- package/lib/{chunk-EAFLDSQ2.mjs → chunk-Z3MGN42K.mjs} +1 -1
- package/lib/{chunk-MKNAZPOT.mjs → chunk-ZB5E7NHU.mjs} +1 -1
- package/lib/chunk-ZCOSME6P.mjs +7 -0
- package/lib/{chunk-KRNFVAGC.mjs → chunk-ZOSESZ22.mjs} +1 -1
- package/lib/chunk-ZTHC42X6.mjs +7 -0
- package/lib/{chunk-XEB6HZ34.mjs → chunk-ZXOUWHYE.mjs} +1 -1
- package/lib/sandforge-autopilot.mjs +1 -1
- package/lib/sandforge-backup.mjs +1 -1
- package/lib/sandforge-checkpoint.mjs +1 -1
- package/lib/sandforge-cleanup.mjs +1 -1
- package/lib/sandforge-clone.mjs +1 -1
- package/lib/sandforge-compare.mjs +1 -1
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +4 -4
- package/lib/sandforge-env.mjs +184 -139
- package/lib/sandforge-frozen.mjs +1 -1
- package/lib/sandforge-mcp.mjs +14 -14
- package/lib/sandforge-monitor.mjs +1 -1
- package/lib/sandforge-pipeline.mjs +1 -1
- package/lib/sandforge-seed.mjs +1 -1
- package/lib/sandforge-sync.mjs +1 -1
- package/lib/sandforge-users.mjs +155 -0
- package/lib/sandforge.mjs +1 -22
- package/lib/sf/sandforge/autopilot.mjs +20 -0
- package/lib/sf/sandforge/backup.mjs +20 -0
- package/lib/sf/sandforge/checkpoint.mjs +20 -0
- package/lib/sf/sandforge/cleanup.mjs +20 -0
- package/lib/sf/sandforge/clone.mjs +20 -0
- package/lib/sf/sandforge/compare.mjs +20 -0
- package/lib/sf/sandforge/dataops.mjs +20 -0
- package/lib/sf/sandforge/empty.mjs +20 -0
- package/lib/sf/sandforge/env.mjs +20 -0
- package/lib/sf/sandforge/frozen.mjs +20 -0
- package/lib/sf/sandforge/hardis-commands.mjs +20 -0
- package/lib/sf/sandforge/index.mjs +20 -0
- package/lib/sf/sandforge/mcp.mjs +20 -0
- package/lib/sf/sandforge/monitor.mjs +20 -0
- package/lib/sf/sandforge/pipeline.mjs +20 -0
- package/lib/sf/sandforge/seed.mjs +20 -0
- package/lib/sf/sandforge/sync.mjs +20 -0
- package/lib/sf/sandforge/users.mjs +20 -0
- package/lib/sfHelpHook.mjs +7 -0
- package/lib/sfPlugin.mjs +11 -0
- package/oclif.manifest.json +1 -0
- package/package.json +17 -3
- package/lib/chunk-2ZMGVBLW.mjs +0 -7
- package/lib/chunk-5C5XEVZN.mjs +0 -11
- package/lib/chunk-5CKWGZX4.mjs +0 -9
- package/lib/chunk-5ZKCLBTN.mjs +0 -474
- package/lib/chunk-7DALDJMO.mjs +0 -7
- package/lib/chunk-CAFUNR6D.mjs +0 -7
- package/lib/chunk-DPYTG6DM.mjs +0 -48
- package/lib/chunk-G4VXPS3A.mjs +0 -7
- package/lib/chunk-GF247DA7.mjs +0 -7
- package/lib/chunk-IKGHRYCN.mjs +0 -7
- package/lib/chunk-IM2XA6JI.mjs +0 -7
- package/lib/chunk-K5HV4YRO.mjs +0 -7
- package/lib/chunk-KOQV4WXC.mjs +0 -8
- package/lib/chunk-N6HHNR6J.mjs +0 -7
- package/lib/chunk-N7J6NJQ6.mjs +0 -7
- package/lib/chunk-NWPQF5XR.mjs +0 -7
- package/lib/chunk-O7DAFE6M.mjs +0 -14
- package/lib/chunk-OMZJ37JI.mjs +0 -15
- package/lib/chunk-R2BJWO5N.mjs +0 -20
- package/lib/chunk-T26C576X.mjs +0 -9
- package/lib/chunk-T5VAULLQ.mjs +0 -7
- package/lib/chunk-V2QO6KOE.mjs +0 -19
- package/lib/chunk-V473C7LY.mjs +0 -7
- package/lib/chunk-W2AAGIZF.mjs +0 -7
- package/lib/chunk-WD47PGUS.mjs +0 -10
- package/lib/chunk-XC54KKKC.mjs +0 -7
- package/lib/chunk-XGKSSCW7.mjs +0 -7
- package/lib/chunk-ZWCRWF7E.mjs +0 -7
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a,b,c,d}from"./chunk-CXKZ6TYV.mjs";import"./chunk-UV74P4H2.mjs";import"./chunk-N2HYG3BL.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-ISOSTAJR.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{d as UsersRunStore,a as defaultUsersStoreRoot,b as usersHeldUserSchema,c as usersRunRecordSchema};
|
|
@@ -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{r as L}from"./chunk-ICIYL45C.mjs";import{
|
|
7
|
+
import{r as L}from"./chunk-ICIYL45C.mjs";import{Ec as C,Gc as R,Lc as S,Mc as m,Pc as b}from"./chunk-6QSHWIZI.mjs";var A="PricebookEntryId",F=Object.fromEntries([["OpportunityLineItem","Opportunity"],["QuoteLineItem","Quote"],["OrderItem","Order"],["ContractLineItem","ServiceContract"]].map(([e,o])=>[e,{record:o,field:L[e]}]));function K(e,o,c){if(!e.has(C))return[];let t=new Map;for(let{sourceObject:n,targetObject:a}of c)t.set(n,[...t.get(n)??[],a]);let i=n=>{let a=new Set,l=[C];for(;l.length>0;){let u=l.pop();if(u===n)return!0;a.has(u)||(a.add(u),l.push(...t.get(u)??[]))}return!1};return[...new Set(o.flatMap(n=>F[n]?.record??[]))].filter(n=>e.has(n)&&!i(n)).map(n=>({sourceObject:n,targetObject:C,relationshipName:`${n}Before${C}`,type:"lookup",required:!0}))}function k(e,o){return[e[R],e[S],o?e[m]:""].map(c=>String(c??"")).join("|")}function h(e,o){return`${e}|${o}`}function Y(e){return h([e.book,e.product,e.model].join("|"),e.currency)}function v(e){let o=e[b];return typeof o=="string"&&o!==""?o:void 0}function x(e){let o=e.wanted??new Map,c=e.prices.flatMap(i=>{let d=i.Id,n=v(i);if(typeof d!="string"||n===void 0)return[];let a=e.writtenIn(n),l=new Set(o.get(d)??[]);l.size===0&&!e.active.has(n)&&a!==void 0&&l.add(a);let u=i[R]===e.standardBookId;return[{row:i,id:d,read:n,alone:a,own:l,standard:u}]}),t=new Map;for(let{row:i,read:d,alone:n,own:a,standard:l}of c){if(l)continue;let u=a.size>0?a:n!==void 0?[n]:[],w=h(k({...i,[R]:e.standardBookId},e.sellingModels),d),p=t.get(w)??new Set;for(let y of u)p.add(y);t.set(w,p)}return c.map(({row:i,id:d,read:n,alone:a,own:l,standard:u})=>{let w=k(i,e.sellingModels),p=new Set(o.get(d)??[]);if(u)for(let y of t.get(h(w,n))??[])p.add(y);if(p.size===0)for(let y of l)p.add(y);return{row:i,id:d,key:w,read:n,alone:a,targets:[...p]}})}function _(e,o){let c=new Map;for(let t of e){if(t.alone!==t.read||!o.has(t.read))continue;let i=h(t.key,t.read);c.has(i)||c.set(i,t)}return c}function W(e){let o=x(e),c=_(o,e.active),t=new Map;for(let{row:i,key:d,targets:n}of o)for(let a of n){let l=h(d,a);c.has(l)||t.has(l)||t.set(l,{book:String(i[R]??""),product:String(i[S]??""),model:e.sellingModels?String(i[m]??""):"",currency:a})}return[...t.values()]}function G(e,o){let c=x(e),t=_(c,e.active),i=new Map(c.map(r=>[r.id,r.key])),d=new Map;for(let r of o){let s=r.Id,f=v(r);if(typeof s!="string"||f===void 0||e.writtenIn(f)!==f)continue;let g=k(r,e.sellingModels),P=h(g,f);if(t.has(P))continue;let M=d.get(P);M!==void 0&&!(r.IsActive===!0&&M.IsActive!==!0)||(d.set(P,r),i.set(s,g))}let n=new Map,a=new Set,l=new Set,u=new Map,w=new Set,p=[],y=(r,s,f)=>{s!==r.read&&p.push({from:r.read,to:s,how:f,forLines:s!==r.alone})},E=[];for(let r of c)for(let s of r.targets){let f=h(r.key,s),g=t.get(f);if(g){n.set(f,g.id),a.add(g.id),g!==r&&y(r,s,"replaced");continue}let P=d.get(f);if(P){n.set(f,String(P.Id)),l.add(P),y(r,s,"replaced");continue}E.push({price:r,to:s})}for(let{price:r,to:s}of E){let f=h(r.key,s);n.has(f)?y(r,s,"replaced"):!a.has(r.id)&&!w.has(r.id)?(w.add(r.id),n.set(f,r.id),s!==r.alone&&u.set(r.id,s),y(r,s,"converted")):y(r,s,"none")}let O=new Map,I=[],B=new Map(c.map(r=>[r.row,r]));for(let r of e.prices){let s=B.get(r);if(!s||s.targets.length===0||a.has(s.id)||w.has(s.id)){I.push(r);continue}let f=s.targets.map(g=>n.get(h(s.key,g))).find(g=>g!==void 0&&g!==s.id);if(f===void 0){I.push(r);continue}O.set(s.id,f)}I.push(...o.filter(r=>l.has(r)));for(let r of c){if(r.targets.length>0||r.alone===void 0)continue;let s=h(r.key,r.alone);n.has(s)||n.set(s,r.id)}return{rows:I,standsFor:O,convertedInto:u,written:n,keys:i,said:p}}function N(e){let o=new Map;for(let{from:c,to:t,how:i,forLines:d}of e){let n=[c,t,i,d?"lines":""].join("|"),a=o.get(n)??{from:c,to:t,how:i,forLines:d,prices:0};a.prices++,o.set(n,a)}return[...o.values()]}function $(e){let o=new Map;for(let{from:c,to:t,prices:i}of e){let d=`${c} \u2192 ${t}`;o.set(d,(o.get(d)??0)+i)}return[...o].map(([c,t])=>`${t} ${c}`).join(", ")}function H(e){return T(N(e))}function T(e){let o=(t,i)=>e.filter(d=>d.forLines===t&&d.how===i);return[[o(!1,"replaced"),"price(s) in a currency the target does not hold active replaced by the source's own price in the currency written, for the same product and price book"],[o(!1,"converted"),"no price in the currency written in the source for the same product and price book, written in it at the amount converted at the source's rates"],[o(!0,"replaced"),"price(s) replaced by the source's own price in the currency of the record their lines belong to, for the same product and price book"],[o(!0,"converted"),"no price in the currency of the record their lines belong to in the source for the same product and price book, written in it at its amount converted"],[e.filter(t=>t.how==="none"),"no price in the currency of the record their lines belong to in the source for the same product and price book, and the price goes in another currency for other lines: the target refuses the lines of a record in it"]].filter(([t])=>t.length>0).map(([t,i])=>`${$(t)}: ${i}`)}export{A as a,F as b,K as c,k as d,h as e,Y as f,W as g,G as h,N as i,H as j,T as k};
|
|
@@ -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{$ as m,Aa as N,Ba as O,Ca as P,Da as Q,Ea as R,P as a,Q as b,R as c,S as d,T as e,U as f,V as g,W as h,X as i,Y as j,Z as k,_ as l,aa as n,ba as o,ca as p,da as q,ea as r,fa as s,ga as t,ha as u,ia as v,ja as w,ka as x,la as y,ma as z,na as A,oa as B,pa as C,qa as D,ra as E,sa as F,ta as G,ua as H,va as I,wa as J,xa as K,ya as L,za as M}from"./chunk-R3OM3X4L.mjs";import"./chunk-77IVKH7R.mjs";import"./chunk-2WMKJVD2.mjs";import"./chunk-VXZ5PTOM.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-ZOSESZ22.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-Z3MGN42K.mjs";import"./chunk-2GSMHGIV.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ISOSTAJR.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{m as ASSIGNMENT_RULES_SOQL,h as AUTOMATION_READ_MOST,b as CONDITIONS_BOUND,f as CONDITION_REQUESTS_BOUND,c as DEFINITIONS_BOUND,g as DEFINITION_REQUESTS_BOUND,n as DUPLICATE_RULES_SOQL,i as FLOWS_SOQL,k as PROCESSES_SOQL,d as TOOLING_QUERIES_PER_REQUEST,e as TOOLING_RETRIEVES_PER_REQUEST,j as TRIGGERS_SOQL,N as TargetAutomationReader,o as USER_PERMISSIONS_SOQL,l as WORKFLOW_RULES_SOQL,a as answerOf,R as automationLines,p as conditionSoql,z as customObjectIdsSoql,Q as customPermissionsByIdSoql,A as customPermissionsSoql,G as decisionChecks,F as fieldsRequiredFilled,L as inFlight,H as messagesOf,M as objectsTheRunWrites,I as pathsOf,J as permissionKey,C as permissionSetSizesSoql,B as permissionSetsHoldingSoql,D as permissionsNamed,y as processObjectsSoql,O as readBypassGrants,w as readInComposites,x as ruleDefinitionSoql,P as setCustomPermissionsSoql,E as switchesNamed,v as targetAutomationQueries,s as toolingAnswersOf,q as toolingCompositeBody,t as toolingRecordsOf,r as toolingRetrieveBody,u as toolingRetrievesOver,K as unreadPartOf};
|
|
@@ -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{d as f}from"./chunk-CXKZ6TYV.mjs";import{mb as i,nb as d}from"./chunk-6QSHWIZI.mjs";import{m as u,z as c}from"./chunk-WZQEK4WT.mjs";function w(e){let s=new Set,r=new Set;for(let t of e)for(let n of t.users){let o=i(n.applied.username);s.has(o)||(s.add(o),n.applied.address==="awaiting"&&r.add(o))}return r}function v(e,s){return e.map(r=>({username:r.username,userId:r.userId,address:r.address==="valid"?"restored":s.has(i(r.username))?"awaiting":"invalid",active:r.active,frozen:r.frozen,...r.profile!==void 0?{profile:r.profile}:{}}))}var l="recovery";function O(e,s){return e!==void 0?`recoveryTesters:host:${e}`:`recoveryTesters:entry:${s}`}var g=u({config:d,savedAt:c.datetime({offset:!0})});function A(e,s){let r=g.safeParse(e.get(s));return r.success?r.data:void 0}function P(e,s,r,t){let n={config:r,savedAt:t.toISOString()};return e.set(s,n,l),n}var m="USERS_RUN_NOT_FOUND",U="USERS_RUN_REPLACED";async function x(e,s,r){let t=await e.read(s,r);if(!t)return{refusal:{code:m,message:`Run ${r} is not kept on this machine for this org, whose Organization Id is ${s}: a sandbox refreshed since answers another, and its runs went with the copy they set up. Simulate without it to set the users up anew.`}};let n=(await e.list(s)).find(o=>o.replaces===r);return n?{refusal:{code:U,message:`Run ${r} was replaced by run ${n.run}, which holds what it set up: simulate again, replacing run ${n.run}.`}}:{record:t}}function C(e){return JSON.stringify([e.orgId,e.config,e.replaces??null,e.acceptUserEmails,e.acceptEmails,e.acceptAutomation])}function T(e){return JSON.stringify({org:e.org.organizationId,users:e.users.map(s=>[s.username,s.userId??null,s.address??null,s.changes,s.emailsToPeople??0]),licenses:(e.licenses??[]).map(s=>[s.name,s.toUse]),emailsToPeople:e.emailsToPeople,refusals:(e.refusals??[]).map(s=>[s.code,s.username??null])})}function b(e){return e.users.filter(s=>s.changes.length>0).length}function E(e,s){let r=new Map(s.users.filter(n=>n.changes.length>0).map(n=>[i(n.username),n.changes.length])),t=0;for(let n of e.users){let o=r.get(i(n.applied.username));if(o===void 0)continue;n.applied.done.length+(n.applied.refused?.length??0)>=o&&(t+=1)}return t}function a(e){return e.what==="frozen"?"UserLogin":e.what==="group"?"GroupMember":e.what==="permissionSet"||e.what==="permissionSetGroup"?"PermissionSetAssignment":"User"}function j(e){let s=new Map(["User","UserLogin","PermissionSetAssignment","GroupMember"].map(t=>[t,{objectApiName:t,created:0,updated:0,deleted:0,failed:0}])),r=t=>s.get(t);for(let t of e.users){let n=new Set(t.done.filter(o=>!("name"in o)).map(o=>a(o)));for(let o of n)r(o).updated+=1;r("PermissionSetAssignment").created+=t.created.permissionSetAssignments.length,r("GroupMember").created+=t.created.groupMembers.length;for(let o of t.done)"name"in o&&o.to==="removed"&&(r(a(o)).deleted+=1);for(let o of t.refused??[])r(a(o.change)).failed+=1}return[...s.values()].filter(t=>t.created+t.updated+t.deleted+t.failed>0)}var p=class extends f{constructor(r,t){super(r);this.onWrite=t}onWrite;async write(r){await super.write(r),this.onWrite(r)}};export{w as a,v as b,l as c,O as d,g as e,A as f,P as g,m as h,U as i,x as j,C as k,T as l,b as m,E as n,j as o,p};
|
|
@@ -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,l,m,n,o,p,q,r,s}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s}from"./chunk-2WMKJVD2.mjs";import"./chunk-Z3MGN42K.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{r as BEFORE_RUN_DELETED_WORDS,e as BEFORE_RUN_DISK_ROOM,a as WRITE_PATH_STEPS,j as beforeRunAskedOf,f as beforeRunDiskRefusal,d as beforeRunEstimateOf,q as beforeRunFailedWords,i as beforeRunKeepDaysOf,h as beforeRunNameOf,l as beforeRunOutcomeOf,s as beforeRunProgressWords,p as beforeRunRefusedWords,c as beforeRunScopeOf,k as beforeRunTakenOf,g as freeBytesOf,m as scopeBeforeRun,o as settleBeforeRun,n as takeBeforeRun,b as writePathOrderDefects};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
var m=()=>({input:process.stdin,output:process.stderr});function p(t,o,r){let{input:e,output:i}=o;return e.isTTY!==!0&&(i.write(`${t}
|
|
8
|
+
no terminal to answer: give --yes to go ahead without the question.
|
|
9
|
+
`),process.exit(2)),r?.aborted===!0?Promise.resolve(void 0):(i.write(`${t} `),new Promise(c=>{let n=s=>{e.off("data",a),e.off("end",u),r?.removeEventListener("abort",f),e.pause(),c(s)},a=s=>n(String(s).trim()),u=()=>n(void 0),f=()=>{i.write(`
|
|
10
|
+
`),n(void 0)};e.on("data",a),e.on("end",u),r?.addEventListener("abort",f,{once:!0}),e.resume()}))}async function T(t,o=m(),r){let e=await p(`${t} [y/N]`,o,r);return e!==void 0&&/^y(es)?$/i.test(e)}async function E(t,o=m()){return await p(t,o)??""}var w=new Set(["\r",`
|
|
11
|
+
`]),g=new Set(["\x7F","\b"]),l="",S="";function v(t,o,r=m()){let{input:e,output:i}=r;return e.isTTY!==!0&&(i.write(`${t}
|
|
12
|
+
no terminal to type it on: ${o}.
|
|
13
|
+
`),process.exit(2)),i.write(`${t} `),e.setRawMode?.(!0),new Promise(c=>{let n="",a=s=>{e.off("data",u),e.off("end",f),e.setRawMode?.(!1),e.pause(),i.write(`
|
|
14
|
+
`),c(s)},u=s=>{for(let d of String(s)){if(w.has(d))return a(n);if(d===l||d===S&&n==="")return a(void 0);g.has(d)?n=n.slice(0,-1):d>=" "&&(n+=d)}},f=()=>a(void 0);e.on("data",u),e.on("end",f),e.resume()})}export{T as a,E as b,v 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{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-27BBEGUD.mjs";import"./chunk-OTJH6AEA.mjs";import"./chunk-FVLFO2S6.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-77MZRBWX.mjs";import"./chunk-BT43WSOS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-6QSHWIZI.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,8 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{f as fn}from"./chunk-77IVKH7R.mjs";import{p as ot,q as $n}from"./chunk-2WMKJVD2.mjs";import{d as An,h as Tn,m as On}from"./chunk-VXZ5PTOM.mjs";import{b as un}from"./chunk-SU65Z2BA.mjs";import{a as kn,b as Fn}from"./chunk-HF6LAK3G.mjs";import{j as hn,k as yn,l as wn,m as bn,n as Rn}from"./chunk-ZOSESZ22.mjs";import{a as Sn,b as En}from"./chunk-TQ2TQHTT.mjs";import{d as rt}from"./chunk-HFSBDM7B.mjs";import{c as pn,g as Ae,h as nt,j as mn}from"./chunk-OHEOJISY.mjs";import{a as gn}from"./chunk-EADHKH3A.mjs";import{E as te,_ as ln,b as ee,da as cn,q as Se,r as Ee,t as tt}from"./chunk-2GSMHGIV.mjs";import{h as et}from"./chunk-TZE3Y7IQ.mjs";import{b as N}from"./chunk-CA5NAXSU.mjs";import{$ as Vt,$d as Re,Cc as Zt,Ec as en,Fc as tn,Kd as he,Ld as on,Md as ye,Nc as nn,Nd as sn,Oc as rn,Od as Je,P as Gt,Pd as an,Sd as dn,Td as Ze,Vd as we,X as qt,Z as Ut,_ as pe,_d as be,aa as zt,ba as Qt,ca as Ht,da as Kt,fa as me,ga as Xt,ha as Yt,ia as Jt,m as Wt}from"./chunk-6QSHWIZI.mjs";import{b as H,e as M,i as fe,k as ge,l as P,s as Ye}from"./chunk-WZQEK4WT.mjs";var ho=/^[A-Za-z][A-Za-z0-9_]{0,79}$/;function Pn(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}function Bn(e){return Array.isArray(e)?e.filter(t=>typeof t=="object"&&t):[]}function vn(e){return typeof e=="string"&&ho.test(e)?e:void 0}function Nn(e){let t=new Map;for(let r of Bn(Pn(e,"variables"))){let o=r.name,i=vn(r.objectType);typeof o=="string"&&i&&t.set(o.toLowerCase(),i)}let n=[];for(let r of Bn(Pn(e,"recordCreates"))){let o=r.inputReference,i=vn(r.object)??(typeof o=="string"?t.get(o.toLowerCase()):void 0);i&&!n.some(s=>s.toLowerCase()===i.toLowerCase())&&n.push(i)}return n}var Mn={AccountPartner:["Role"],CampaignMember:["Status"],Case:["Status"],Contract:["Status"],Lead:["Status"],Opportunity:["StageName"],OpportunityPartner:["Role"],Order:["Status"],Partner:["Role"],ServiceAppointment:["Status"],Solution:["Status"],Task:["Priority","Status"],WorkOrder:["Status"],WorkOrderLineItem:["Status"]};function Wa(e,t){let n=new Map,r=t!==void 0&&Object.prototype.hasOwnProperty.call(Mn,t)?Mn[t]:[];for(let o of e){let i=o.type==="multipicklist";if(o.type!=="picklist"&&!i&&!o.picklistValues?.length)continue;let s=(o.type==="combobox"||o.restrictedPicklist===!1)&&!r.includes(o.name);n.set(o.name,{multi:i,restricted:o.restrictedPicklist===!0,required:o.nillable===!1&&o.defaultedOnCreate!==!0,...o.controllerName?{controllerName:o.controllerName}:{},...s?{anyValue:s}:{}})}return n}var yo=new Set;function wo(e,t){let n=new Set(e),r=[],o=new Set,i=(s,a)=>{if(o.has(s))return;let d=t.get(s)?.controllerName;d&&n.has(d)&&a<e.length&&i(d,a+1),!o.has(s)&&(o.add(s),r.push(s))};for(let s of e)i(s,0);return r}function bo(e){return typeof e=="boolean"?String(e):typeof e=="string"&&e!==""?e:void 0}function Ro(e,t){let n=new Map;for(let r of e){let o=t(r),i=n.get(o)??[];i.includes(r)||i.push(r),n.set(o,i)}return[...n]}function So(e,t,n,r,o,i,s){let a=new Set(o.values),d=a,l,u=r.controllerName?bo(e[r.controllerName]):void 0,f=u===void 0?void 0:o.allowedByControllingValue?.get(u);f&&(d=new Set(o.values.filter(R=>f.has(R))),l=r.controllerName);let g=n.filter(R=>!d.has(R));if(g.length===0)return[];let p=R=>s&&!s.has(R)?"not-in-target":a.has(R)?"controlling-value":"record-type",m,w,b=n.filter(R=>d.has(R));return r.multi&&b.length>0?e[t]=b.join(";"):(o.defaultValue!==null&&d.has(o.defaultValue)?(m=o.defaultValue,w="default"):r.required&&(m=o.values.find(R=>d.has(R)),w=m===void 0?void 0:"first"),m===void 0?delete e[t]:e[t]=m),Ro(g,p).map(([R,O])=>({field:t,reason:R,values:O,recordType:i,...R==="controlling-value"&&l?{controllingField:l}:{},...m!==void 0&&w?{replacedBy:m,replacement:w}:{}}))}function Ga(e,t,n,r,o=yo){let i=[];for(let s of wo(Object.keys(e),n)){let a=e[s];if(typeof a!="string"||o.has(s))continue;let d=n.get(s),l=t?.get(s),u=d?.restricted?r?.picklists.get(s):void 0;if(!l&&!u)continue;if(a===""){delete e[s];continue}let f=d?.multi?a.split(";"):[a];if(d&&u&&r){i.push(...So(e,s,f,d,u,r.recordType,l));continue}if(!l||d?.anyValue)continue;let g=f.filter(m=>!l.has(m));if(g.length===0)continue;let p=f.filter(m=>l.has(m));d?.multi&&p.length>0?e[s]=p.join(";"):delete e[s],i.push({field:s,reason:"not-in-target",values:[...new Set(g)]})}return i}var Eo="012000000000000AAA",Te="Master",jn="";function qa(e,t){return e?.get(typeof t=="string"?t:jn)}async function Ao(e,t,n){try{return{picklists:await e(t,n)}}catch(r){return{error:N(r)}}}var xn=class{constructor(t){this.read=t}read;reads=new Map;said=new Set;async forRows(t){let n=new Map,r=[],{read:o}=this;if(!o)return{byRecordType:n,notes:r};if(t.withoutRecordTypes){let l=[...t.fields].filter(([f,g])=>g.restricted&&g.controllerName&&t.written(f)).map(([f])=>f),u=new Set(l.filter(f=>t.rows.some(g=>typeof g[f]=="string"&&g[f]!=="")));if(u.size>0){let f={targetId:Eo,developerName:Te},g=await this.readFor(o,t.objectApiName,f.targetId);this.keep(n,r,t.objectApiName,jn,u,f,g)}return{byRecordType:n,notes:r}}if(!t.recordTypeMappings||!t.written("RecordTypeId"))return{byRecordType:n,notes:r};let i=[...t.fields].filter(([l,u])=>u.restricted&&t.written(l)).map(([l])=>l);if(i.length===0)return{byRecordType:n,notes:r};let s=new Map(t.recordTypeMappings.map(l=>[l.sourceId,l])),a=new Map;for(let l of t.rows){let u=l.RecordTypeId;if(!(typeof u!="string"||!s.has(u)))for(let f of i){let g=l[f];if(typeof g!="string"||g==="")continue;let p=a.get(u)??new Set;p.add(f),a.set(u,p)}}let d=await Promise.all([...a].map(async([l,u])=>{let f=s.get(l);return{sourceId:l,fields:u,target:f,answer:await this.readFor(o,t.objectApiName,f.targetId)}}));for(let{sourceId:l,fields:u,target:f,answer:g}of d)this.keep(n,r,t.objectApiName,l,u,f,g);return{byRecordType:n,notes:r}}readFor(t,n,r){let o=`${n}|${r}`,i=this.reads.get(o);return i||(i=Ao(t,n,r),this.reads.set(o,i)),i}keep(t,n,r,o,i,s,a){let d=`${r}|${s.targetId}`;if("error"in a){this.said.has(d)||(this.said.add(d),n.push({recordType:s.developerName,error:a.error}));return}t.set(o,{recordType:s.developerName,picklists:a.picklists});let l=[...i].filter(u=>!a.picklists.has(u)&&!this.said.has(`${d}|${u}`));if(l.length!==0){for(let u of l)this.said.add(`${d}|${u}`);n.push({recordType:s.developerName,leftOut:l})}}};function Ua(e){return e.error!==void 0?{recordSummary:`(picklist values of record type ${e.recordType} could not be read \u2014 checked against each field's values)`,messages:[e.error]}:{recordSummary:`(picklist values of record type ${e.recordType} not given for ${(e.leftOut??[]).join(", ")} \u2014 checked against each field's values)`,messages:[`The target's answer for record type ${e.recordType} leaves out ${(e.leftOut??[]).join(", ")}.`]}}var Cn=class{entries=new Map;get size(){return this.entries.size}add(t,n){for(let r of n){let o=[t,r.field,r.reason,r.recordType??"",r.controllingField??"",r.replacement??"",r.replacedBy??""].join("\0"),i=this.entries.get(o);if(i){i.entry.rows++;for(let s of r.values)i.values.add(s);continue}this.entries.set(o,{entry:{objectApiName:t,field:r.field,reason:r.reason,values:[],rows:1,...r.recordType!==void 0?{recordType:r.recordType}:{},...r.controllingField!==void 0?{controllingField:r.controllingField}:{},...r.replacedBy!==void 0?{replacedBy:r.replacedBy}:{},...r.replacement!==void 0?{replacement:r.replacement}:{}},values:new Set(r.values)})}}list(){return[...this.entries.values()].map(({entry:t,values:n})=>({...t,values:[...n].sort()}))}};function To(e){let t=`${e.rows} row${e.rows===1?"":"s"}`,n=e.values.map(i=>`"${i}"`).join(", "),r=e.reason==="not-in-target"?"not a value of the field in the target":e.reason==="record-type"?`not allowed for record type ${e.recordType??""}`:`not allowed with the value of ${e.controllingField??"its controlling field"}`,o=e.replacedBy===void 0?"left out":e.replacement==="first"?`replaced by "${e.replacedBy}", the first value record type ${e.recordType??""} allows: the field is required and has no default there`:`replaced by "${e.replacedBy}", the default of record type ${e.recordType??""}`;return`${e.field} on ${t}: ${n} ${r}, ${o}`}function Va(e){return e.length===0?"":`, picklist values not written as read: ${e.map(To).join("; ")}`}function Ya(e){let t={...e.picklistValueMappings?.length?{picklistValueMappings:e.picklistValueMappings}:{},...e.recordTypeMappings?.length?{recordTypeMappings:e.recordTypeMappings}:{},...e.defaultValues?.length?{defaultValues:e.defaultValues}:{},...e.truncateFields?.length?{truncateFields:e.truncateFields}:{},...e.ignoredGaps?.length?{ignoredGaps:e.ignoredGaps}:{},...e.skippedRows?.length?{skippedRows:e.skippedRows}:{}};return Object.keys(t).length>0?t:void 0}var Oo=new Set(["picklist_value_refused","picklist_value_absent","currency_inactive"]);function Ln(e){let t=Gt(e.gapId);return t?t.objectApiName!==e.object?{ignored:`the gap is of ${t.objectApiName}, not of ${e.object}`}:t.field===void 0||t.value===void 0?{ignored:"the gap names no field and value whose rows to hold back"}:Oo.has(t.kind)?{held:{field:t.field,...t.recordType!==void 0?{recordType:t.recordType}:{},value:t.value}}:{ignored:`a ${t.kind} gap does not offer it: its rows are not exactly those holding its value`}:{ignored:"not the id of a gap"}}function Ja(e){let t=Ln(e);return"ignored"in t?t.ignored:void 0}function _n(e,t,n){if(e===void 0)return!0;let r=t??Te;if(e===r)return!0;let o=Ae(e),i=Ae(r);if(o.namespacePrefix!==void 0||i.namespacePrefix===void 0||i.developerName!==e)return!1;if(n===void 0)return!0;let s=nt(e,n,a=>a);return"found"in s&&s.found.namespacePrefix===i.namespacePrefix}function ko(e){return e==null||e===""}var In=class{entries=new Map;get size(){return this.entries.size}add(t,n=1){let r=[t.kind,t.objectApiName,t.field??"",t.recordType??"",t.from??"",t.to??""].join("\0"),o=this.entries.get(r);if(o){o.rows+=n;return}this.entries.set(r,{...t,rows:n})}list(){return[...this.entries.values()].map(t=>({...t}))}},Oe=class{picklists=new Map;defaults=new Map;truncated=new Map;skipped=new Map;ignoredGaps;constructor(t){for(let n of t?.picklistValueMappings??[]){let r=this.picklists.get(n.object)??[];r.push(n),this.picklists.set(n.object,r)}for(let n of t?.defaultValues??[]){let r=this.defaults.get(n.object)??[];r.push(n),this.defaults.set(n.object,r)}for(let{object:n,field:r}of t?.truncateFields??[]){let o=this.truncated.get(n)??new Set;o.add(r),this.truncated.set(n,o)}this.ignoredGaps=new Set(t?.ignoredGaps??[]);for(let n of t?.skippedRows??[]){let r=Ln(n);if(!("held"in r))continue;let o=this.skipped.get(n.object)??[];o.push(r.held),this.skipped.set(n.object,o)}}skipsRowsOf(t){return this.skipped.has(t)}namesARecordTypeBare(t){return[...(this.picklists.get(t)??[]).map(r=>r.recordType),...(this.skipped.get(t)??[]).map(r=>r.recordType)].some(r=>r!==void 0&&r!==Te&&Ae(r).namespacePrefix===void 0)}holdsBack(t,n,r,o,i){for(let s of this.skipped.get(t)??[]){if(!_n(s.recordType,r,i))continue;let a=n(s.field);if(!(typeof a!="string"||!a.split(";").includes(s.value)))return o.add({kind:"skip_rows",objectApiName:t,field:s.field,...s.recordType!==void 0?{recordType:s.recordType}:{},from:s.value}),!0}return!1}changesRowsOf(t){return this.picklists.has(t)||this.defaults.has(t)}defaultOf(t,n){let r=this.defaults.get(t)?.find(o=>o.field===n);return r===void 0?void 0:String(r.value)}applyToRow(t,n,r,o,i){for(let s of this.picklists.get(t)??[]){if(!_n(s.recordType,r,i))continue;let a=n[s.field];if(typeof a!="string"||a==="")continue;let d=a.split(";");if(!d.includes(s.from))continue;let l=d.flatMap(u=>u!==s.from?[u]:s.to===null?[]:[s.to]);l.length===0?delete n[s.field]:n[s.field]=[...new Set(l)].join(";"),o.add({kind:s.to===null?"leave_empty":"map_value",objectApiName:t,field:s.field,...s.recordType!==void 0?{recordType:s.recordType}:{},from:s.from,...s.to!==null?{to:s.to}:{}})}for(let{field:s,value:a}of this.defaults.get(t)??[])ko(n[s])&&(n[s]=a,o.add({kind:"set_default",objectApiName:t,field:s,to:String(a)}))}truncate(t,n,r,o){for(let i of this.truncated.get(t)??[]){let s=n[i],a=r.get(i);typeof s!="string"||a===void 0||a<=0||s.length<=a||(n[i]=s.slice(0,a),o.add({kind:"truncate",objectApiName:t,field:i}))}}truncatedFieldsOf(t){return this.truncated.get(t)??new Set}};function Za(e,t){let n=new Map(t.map(s=>[s.objectApiName,s])),r=[],o=new Map,i=[];for(let s of e){let a=n.get(s.object),d=Dn(s.object,s.from,a?.source??[],"the source");if("reason"in d){i.push({decision:s,reason:d.reason});continue}if(s.to===null){o.set(d.type.recordTypeId,s);continue}let l=Dn(s.object,s.to,a?.target??[],"the target");if("reason"in l){i.push({decision:s,reason:l.reason});continue}o.set(d.type.recordTypeId,s),r.push({sourceId:d.type.recordTypeId,targetId:l.type.recordTypeId,developerName:l.type.developerName})}return{mappings:r,bySource:o,unresolved:i}}function Dn(e,t,n,r){let o=nt(t,n.filter(i=>!i.master),rt);if("found"in o)return{type:o.found};if("ambiguous"in o){let i=o.ambiguous.map(rt),s=i.find(a=>a.namespacePrefix);return{reason:mn(e,t,r,i)+(s?"; a package's is named with its namespace: "+pn(s.namespacePrefix,s.developerName):"")}}return{reason:`${r} has no ${e} record type named ${t}`}}function ed(e,t){return t.bySource.size===0?e?[...e]:void 0:[...(e??[]).filter(n=>!t.bySource.has(n.sourceId)),...t.mappings]}import{createHash as gi}from"node:crypto";var Fo="__pass2__";function Wn(e){let t=e.errors??[],n=t.some(i=>i.skipped===!0),r=t.some(i=>i.objectApiName===Fo&&i.failedCount>0);return e.failedCount===0&&e.failedReads.length===0&&!n&&!r?"success":e.successCount+e.updatedCount+e.linkedCount+(e.wouldInsertCount??0)>0?"partial":"failure"}function nd(e,t,n){return{forgeId:`forge-${Date.now()}`,status:n.status,graph:t,duration:Date.now()-n.startedAt,timestamp:new Date().toISOString(),idRemapCount:e.remapCount,idRemapTable:e.remapTable,idRemapExisting:e.existingSourceIds,...e.withTheirRecordSourceIds?{idRemapWithTheirRecord:e.withTheirRecordSourceIds}:{},...e.withTheirRecordCount!==void 0&&e.withTheirRecordCount>0?{withTheirRecordCount:e.withTheirRecordCount}:{},...e.linkedToCreatedCount!==void 0&&e.linkedToCreatedCount>0?{linkedToCreatedCount:e.linkedToCreatedCount}:{},createdCount:e.successCount,...e.updatedCount>0?{updatedCount:e.updatedCount}:{},linkedExistingCount:e.linkedCount,existingRecords:e.existingRecords,idRemapByObject:e.remapByObject,idRemapCreated:e.createdByObject,readByObject:e.readByObject,failedReads:e.failedReads,errors:e.errors,truncatedObjects:e.truncatedObjects,...e.cappedObjects?{cappedObjects:e.cappedObjects}:{},...e.fieldExclusionsUnmatched?{fieldExclusionsUnmatched:e.fieldExclusionsUnmatched}:{},...e.orphanParentsCapped?{orphanParentsCapped:e.orphanParentsCapped}:{},...e.files?{files:e.files}:{},...e.fileContentFieldsLeftOut?{fileContentFieldsLeftOut:e.fileContentFieldsLeftOut}:{},...e.encryptedFieldsLeftOut?{encryptedFieldsLeftOut:e.encryptedFieldsLeftOut}:{},...e.picklistValuesChanged?{picklistValuesChanged:e.picklistValuesChanged}:{},...e.currenciesReplaced?{currenciesReplaced:e.currenciesReplaced}:{},...e.recordTypesGiven?{recordTypesGiven:e.recordTypesGiven}:{},...e.writtenWithoutFields?{writtenWithoutFields:e.writtenWithoutFields}:{},...e.lookupsLeftEmptyByFilter?{lookupsLeftEmptyByFilter:e.lookupsLeftEmptyByFilter}:{},...e.contactPoints?{contactPoints:e.contactPoints}:{},...e.writtenBetween?{writtenBetween:e.writtenBetween}:{},...e.apiCalls!==void 0?{apiCalls:e.apiCalls}:{},...e.dryRun?{dryRun:!0,wouldInsertCount:e.wouldInsertCount}:{},...e.gaps?{gaps:e.gaps}:{},...e.decisionsApplied?{decisionsApplied:e.decisionsApplied}:{},...e.mayHaveBeenWritten?{mayHaveBeenWritten:e.mayHaveBeenWritten}:{},...e.remapInJournal?{remapInJournal:!0}:{},...e.sample?{sample:e.sample}:{},...e.roots?{roots:e.roots}:{},...e.reads?{reads:e.reads}:{}}}var Gn="RUN_CANCELLED";function id(e){return{idRemapByObject:e.remapByObject,errors:e.errors,notSentByObject:e.notSentByObject,writtenWithoutFields:e.writtenWithoutFields,mayHaveBeenWritten:e.mayHaveBeenWritten}}function ad(e){let t=new Map,n=r=>{let o=t.get(r)??fn(r);return t.set(r,o),o};for(let r of e.idRemapByObject??[]){let o=n(r.objectApiName);o.created+=r.created,o.updated+=r.updated??0}for(let r of e.errors??[]){if(r.objectApiName.startsWith("__")||r.referenceData===!0||r.stage==="scope"&&r.failedCount===0&&r.skipped!==!0)continue;let o=n(r.objectApiName);o.failed+=r.failedCount,r.skipped===!0&&(o.skipped=r.failedCount>0?"counted":"uncounted")}for(let r of e.notSentByObject??[]){let o=n(r.objectApiName);o.notSent=(o.notSent??0)+r.notSent}for(let r of e.writtenWithoutFields??[]){let o=n(r.objectApiName);o.writtenWithoutFields=(o.writtenWithoutFields??0)+r.rows}for(let{objectApiName:r,sourceIds:o}of e.mayHaveBeenWritten??[]){let i=n(r);i.mayHaveBeenWritten=(i.mayHaveBeenWritten??0)+o.length}return[...t.values()]}function dd(e,t){return t.some(r=>r.created+r.updated>0)?"cancelled":(e?Wn(e):"success")==="success"?"stopped":"cancelled"}function ud(e){return e?{details:{contactPoints:e.neutralized?"neutralized":"kept",contactPointFields:e.fields.length,contactPointValues:e.values}}:{}}function ld(e){return Object.fromEntries((e.idRemapByObject??[]).map(t=>[t.objectApiName,t.created+t.linked+(t.updated??0)]))}var Sd=2e3,Ed=1e4,Po=qt;function Ad(e,t,n=Po){let r=t!==void 0&&t>0?Math.floor(t):void 0;return r!==void 0&&r<=n?[]:e.nodes.filter(o=>o.included&&o.recordCountUnknown!==!0).map(o=>({objectApiName:o.objectApiName,rows:r===void 0?o.recordCount:Math.min(o.recordCount,r)})).filter(o=>o.rows>n).sort((o,i)=>i.rows-o.rows)}var Zn=.8,se=1024,Fe=2*se,er=4*se,Bo=8*se,vo=1*se,No=4*se,Mo=255,xo=/__kav$/i,Co=new Map([ee,Se,Ee,"Campaign","CampaignMember"].map(e=>[e.toLowerCase(),e]));function $e(e){return Co.get(e.toLowerCase())??e}function qn(e,t=0){let n=0;for(let r of Object.values(e))typeof r=="string"&&r.length>t&&(n+=Buffer.byteLength(r,"utf8"));return n}function it(e,t){let n=$e(e);return n===ee?qn(t):n===Se?tt(t)?er:Fe:n===Ee&&tt(t)?0:n==="Campaign"?Bo:n==="CampaignMember"?vo:xo.test(e)?No+qn(t,Mo):Fe}function jo(e,t){let n=Math.min(t.personAccounts??0,t.rows),r=t.rows-n,o=$e(e);return o===Se?r*Fe+n*er:o===Ee?r*Fe:r*it(e,{})}function _o(e){let t=e.map(({objectApiName:m,rows:w,counted:b,mayAdd:R=0,mayBeByThePlatform:O})=>{let T={rows:R,storageBytes:R*it(m,{}),...R>0?{mayAdd:R}:{},...O&&O.rows>0?{mayBeByThePlatform:O}:{}};return b?{objectApiName:m,...T,rows:b.rows+T.rows,storageBytes:jo(m,b)+T.storageBytes}:{objectApiName:m,...T,rows:w.length+T.rows,storageBytes:w.reduce((C,A)=>C+it(m,A),0)+T.storageBytes}}).filter(({rows:m})=>m>0).sort((m,w)=>w.rows-m.rows||m.objectApiName.localeCompare(w.objectApiName)),n=e.reduce((m,w)=>m+(w.leftOut?.writtenBefore??0),0),r=e.filter(m=>(m.leftOut?.heldBack??0)>0).map(({objectApiName:m,leftOut:w})=>({objectApiName:m,rows:w?.heldBack??0})),o=e.filter(m=>(m.leftOut?.byThePlatform??0)>0).map(({objectApiName:m,leftOut:w})=>({objectApiName:m,rows:w?.byThePlatform??0})),i=e.flatMap(({objectApiName:m,leftOut:w})=>w?.linkedByValue&&w.linkedByValue.rows>0?[{objectApiName:m,...w.linkedByValue}]:[]),s=m=>e.filter(w=>(w.leftOut?.[m]??0)>0).map(({objectApiName:w,leftOut:b})=>({objectApiName:w,rows:b?.[m]??0})),a=s("recordTypeNotInTarget"),d=s("withoutParent"),l=s("noParentInSource"),u=s("outsideFilter"),f=s("linkedToTarget"),g=s("currencyReplaced"),p=e.flatMap(({objectApiName:m,leftEmpty:w=[]})=>w.filter(({rows:b})=>b>0).map(({field:b,rows:R})=>({objectApiName:m,field:b,rows:R})));return{objects:t,...p.length>0?{leftEmpty:p}:{},totalRows:t.reduce((m,w)=>m+w.rows,0),storageBytes:t.reduce((m,w)=>m+w.storageBytes,0),...n>0||r.length>0||a.length>0||o.length>0||i.length>0||d.length>0||l.length>0||u.length>0||f.length>0||g.length>0?{leftOut:{writtenBefore:n,heldBack:r,...a.length>0?{recordTypeNotInTarget:a}:{},...o.length>0?{byThePlatform:o}:{},...i.length>0?{linkedByValue:i}:{},...d.length>0?{withoutParent:d}:{},...l.length>0?{noParentInSource:l}:{},...u.length>0?{outsideFilter:u}:{},...f.length>0?{linkedToTarget:f}:{},...g.length>0?{currencyReplaced:g}:{}}}:{}}}function Td(e){return JSON.stringify([e.sourceOrgId,e.targetOrgId,e.inputMode,e.recordId??null,e.soqlQuery??null,e.templateId??null,e.aiPrompt??null,...e.queryScope==="records"?["records"]:[]])}var Io=16,Un=class{kept=new Map;note(t,n,r=Date.now()){this.kept.delete(t),this.kept.set(t,{at:r,total:n.totalRows,objects:n.objects.map(({objectApiName:o,rows:i})=>({objectApiName:o,rows:i}))});for(let o of this.kept.keys()){if(this.kept.size<=Io)break;this.kept.delete(o)}}of(t){return this.kept.get(t)}},Do=500;function Lo(e,t){return e>2*t||e-t>Do}function Od(e,t,n=Date.now()){return{minutesBefore:Math.max(1,Math.ceil((n-e.at)/6e4)),total:e.total,objects:e.objects.map(({objectApiName:r,rows:o})=>({objectApiName:r,rows:o})),...Lo(t,e.total)?{farAbove:!0}:{}}}function kd(e){let t=e.objects.reduce((n,r)=>n+(r.mayAdd??0),0);return t>0?{pricesForLines:t}:{}}function Fd(e){let t=e.objects.find(n=>n.mayBeByThePlatform)?.mayBeByThePlatform;return!t||t.rows<=0?{}:{rolesMayBeByThePlatform:{rows:t.rows,...t.before===!0?{before:!0}:{}}}}var ke=P({Max:M(),Remaining:M()}).loose(),Wo=P({DataStorageMB:ke,DailyApiRequests:ke.optional(),DailyBulkApiBatches:ke.optional(),FileStorageMB:ke.optional()}).loose(),Go=P({DailyApiRequests:P({Max:M(),Remaining:M()}).loose()}).loose(),qo="the org does not tell this user its daily API requests";function tr(e,t,n){if(e!==null&&typeof e=="object"&&!(t in e))throw new Error(n)}async function Uo(e){let t=await e.request({method:"GET",url:"/limits"});tr(t,"DataStorageMB",Wt);let n=Wo.parse(t);return{maxMB:n.DataStorageMB.Max,remainingMB:n.DataStorageMB.Remaining,...n.DailyApiRequests?{dailyApiRequests:{max:n.DailyApiRequests.Max,remaining:n.DailyApiRequests.Remaining}}:{},...n.DailyBulkApiBatches?{dailyBulkApiBatches:{max:n.DailyBulkApiBatches.Max,remaining:n.DailyBulkApiBatches.Remaining}}:{},...n.FileStorageMB?{fileStorage:{maxMB:n.FileStorageMB.Max,remainingMB:n.FileStorageMB.Remaining}}:{}}}async function Vn(e){let t=await e.request({method:"GET",url:"/limits"});tr(t,"DailyApiRequests",qo);let n=Go.parse(t);return{max:n.DailyApiRequests.Max,remaining:n.DailyApiRequests.Remaining}}var at=200,nr=2e3,Vo=.1;function zo(e){return e.reduce((t,{rows:n,bulk:r,readRows:o,perCall:i})=>{let s=Math.min(at,Math.max(1,i??at)),a=n<=0?0:r?Rn(n):Math.ceil(n/s),d=o&&o>0?Math.ceil(o/nr):0;return t+a+d},0)}var ct=["checkpoint","mute","readBack","deliverability","fit"],Qo={checkpoint:"for the checkpoint taken first",mute:"to assign and take back the permission sets that mute the target's automation",readBack:"to read back the record types the target gave",deliverability:"to read whether the target delivers its emails",fit:"to fit the run to the storage"};function Ho(e){return ct.reduce((t,n)=>t+Math.max(0,e[n]??0),e.run)}function Ko(e){return ct.some(t=>(e[t]??0)>0)?{...e}:void 0}function st(e,t){let n=typeof e=="number"?void 0:Ko(e),r=typeof e=="number"?e:Ho(e),o=n?{parts:n}:{};if(!t)return{verdict:"unread",estimate:r,unread:"the limits the org answered list no DailyApiRequests",...o};if("unread"in t)return{verdict:"unread",estimate:r,unread:t.unread,...o};let{max:i,remaining:s}=t;return{verdict:r>s?"exceeds":s-r<Vo*i?"near":"fits",estimate:r,max:i,remaining:s,...o}}function Xo(e){if(!e)return"";let t=ct.filter(n=>(e[n]??0)>0).map((n,r)=>`${e[n]}${r===0?" of them":""} ${Qo[n]}`);return t.length>0?` (${t.join(", ")})`:""}var ne="API_BUDGET_EXCEEDED";function Yo(e,t,n){if(e.verdict==="exceeds")return`The run takes about ${e.estimate} API requests${Xo(e.parts)}, and ${t} has ${e.remaining} of its ${e.max} daily requests left: it would stop part way through, its records refused with REQUEST_LIMIT_EXCEEDED. Run it once the org has requests to spare \u2014 the limit is counted over the last 24 hours \u2014 or write fewer records. `+(n?`${n} `:"")+"Nothing was written."}function Jo(e){return e.verdict==="near"?{apiRequests:{estimate:e.estimate,remaining:e.remaining,max:e.max,...e.parts?{parts:{...e.parts}}:{}}}:{}}var Pe="CHECKPOINT_REFUSED";function Zo(e){return e?{checkpoint:e.estimate.apiRequests}:{}}function es(e){let t=e?.refusal;if(t!==void 0)return{code:Pe,message:ot(t),refusal:t}}var ts="The run was stopped while it took the checkpoint first: nothing of it was kept, and nothing was written.";async function $d(e){let t;try{t=await e()}catch(n){return{stop:{code:Pe,message:$n(n)}}}return t.taken?{checkpoint:t.checkpoint}:"stopped"in t?{stop:{code:Gn,message:ts}}:{stop:{code:Pe,message:ot(t.refusal),refusal:t.refusal}}}var zn=1e4,ns=1e4,rs=.01;function os(e,t,n){return t<2e3||kn.has(e)||(n??Fn).has(e)}function Be(e,t,n){if(t<=0)return{jobs:[],rest:0};if(os(e,t,n.restOnly))return{jobs:[],rest:t};let r=[];for(let o=t;o>0;o-=zn){let i=Math.min(o,zn);if(i<2e3)return{jobs:r,rest:i};r.push(i)}return{jobs:r,rest:0}}function ss(e){return yn({stateReads:bn(e,hn,"save")})}function is(e,t,n){let{jobs:r,rest:o}=Be(e,t,n);return r.reduce((i,s)=>i+ss(s),0)+Math.ceil(o/at)}var as=4,ds=3;function us(e){let t=new Set(e.updatedAfterInsert??[]),n=new Map((e.plan.leftOut?.linkedByValue??[]).map(({objectApiName:d,rows:l})=>[d,l])),r=[...e.plan.objects.map(({objectApiName:d,rows:l})=>({objectApiName:d,rows:l+(n.get(d)??0)})),...[...n].filter(([d])=>!e.plan.objects.some(l=>l.objectApiName===d)).map(([d,l])=>({objectApiName:d,rows:l}))],o=e.plan.objects.filter(({objectApiName:d})=>t.has(d)).map(({objectApiName:d,rows:l})=>({objectApiName:d,rows:l})),{bulk:i}=e,s=e.files!==void 0&&e.files>0?e.files:0,a=i?as*r.filter(({rows:d})=>d>0).length:0;return{run:(i?[...r,...o].reduce((d,{objectApiName:l,rows:u})=>d+is(l,u,i),0):zo([...r,...o]))+s+a+Math.max(0,e.sentBefore??0),...Zo(e.checkpoint),...e.mute!==void 0&&e.mute>0?{mute:e.mute}:{},...e.readBack!==void 0&&e.readBack>0?{readBack:e.readBack}:{},...e.deliverability!==void 0&&e.deliverability>0?{deliverability:e.deliverability}:{}}}var ls=200;function cs(e){let t={...e.measures.restOnly?{restOnly:e.measures.restOnly}:{}},n=new Set(e.updatedAfterInsert??[]),r=e.plan.objects.map(({objectApiName:a,rows:d})=>({objectApiName:a,rows:d,writes:Be(a,d,t),updates:n.has(a)?Be(a,d,t):void 0})),o=r.flatMap(({writes:a,updates:d})=>d?[a,d]:[a]),i=e.measures.files,s=i&&"count"in i&&i.count>0?i.count:0;return{objects:r.map(({objectApiName:a,rows:d,writes:l})=>({objectApiName:a,rows:d,jobs:l.jobs.length})),sourceRequests:(e.measures.sourceReads??r.reduce((a,{rows:d})=>a+Math.ceil(Math.max(0,d)/nr),0)+s+Math.ceil(s/ls))+ds*r.filter(({rows:a})=>a>0).length+(e.sourceSentBefore===void 0?Math.max(0,e.measures.heldReads??0):Math.max(0,e.sourceSentBefore)),bulkBatches:o.reduce((a,{jobs:d})=>a+d.reduce((l,u)=>l+Math.ceil(u/ns),0),0),durationSeconds:o.reduce((a,{jobs:d,rest:l})=>a+d.reduce((u,f)=>u+wn(f,"save"),0)+l*rs,0),restObjects:r.filter(({rows:a,writes:d})=>a>0&&d.jobs.length===0).map(({objectApiName:a})=>a)}}var fs="the limits the org answered list no DailyBulkApiBatches";function gs(e,t){if(e.verdict==="exceeds")return`The run writes through Bulk API jobs that take about ${e.estimate} of the daily Bulk API batches, and ${t} has ${e.remaining} of its ${e.max} left: its jobs would be refused part way through. Run it once the org has batches to spare \u2014 the limit is counted over the last 24 hours, and Bulk API 1.0 shares it \u2014 or leave objects out. Nothing was written.`}function ps(e,t){if(e.verdict==="exceeds")return`The run reads the source records in about ${e.estimate} API requests, and ${t} has ${e.remaining} of its ${e.max} daily requests left: the reads would stop part way through, and the org's own integrations with them. Run it once the org has requests to spare \u2014 the limit is counted over the last 24 hours \u2014 or leave objects out. Nothing was written.`}function ms(e,t){if(e.verdict==="exceeds")return`The files to copy take about ${L(e.estimateMB)} MB of file storage, and ${t} has ${e.remainingMB} MB left of ${e.maxMB} MB: leave out the objects whose files take it, turn the copy of files off on Review, or free file storage in ${t}. Nothing was written.`}function hs(e,t){return`A clone of the whole org reads a few objects whole, and ${e.map(({objectApiName:r,rows:o})=>`${r} (${o} rows)`).join(", ")} ${e.length===1?"holds":"hold"} more than the ${t} rows of one object the sandforge.forge.maxRecordsPerObject setting lets a run hold at once: raise the setting or leave the object out on Review. Nothing was written.`}var ys=200;function ws(e){if(!e||e.length===0)return;let t=Math.min(...e.map(r=>r.bound)),n=e.map(({objectApiName:r,rows:o})=>({objectApiName:r,rows:o}));return{code:"READ_BOUND_EXCEEDED",message:hs(n,t),readBound:{bound:t,objects:n.slice(0,ys)}}}var rr="FILES_UNREAD",or="FILE_STORAGE_UNREAD";function bs(e,t,n){if(!e)return{};if("unmeasured"in e)return{files:{unmeasured:!0},stop:{code:rr,message:`The source would neither sum nor list its files, so what they take of the file storage ${n} has left is not known: turn the copy of files off on Review, or run it again once the source answers. Nothing was written.`}};if(e.count<=0)return{};let r=sr({storageBytes:e.bytes},"unread"in t?t:t.fileStorage??{unread:"the limits the org answered list no FileStorageMB"});if(r.verdict==="unread")return{files:{count:e.count,check:r},stop:{code:or,message:`The file storage ${n} has left could not be read (${r.unread}), so the ${e.count} files to copy could not be checked against it: turn the copy of files off on Review, or run it again once the org answers. Nothing was written.`}};let o=ms(r,n);return{files:{count:e.count,check:r},...o!==void 0&&r.verdict==="exceeds"?{stop:{code:"STORAGE_EXCEEDED",message:o,storage:{estimateMB:Number(L(r.estimateMB)),remainingMB:r.remainingMB,kind:"files"}}}:{}}}function Rs(e){let t=e.wholeOrg,n=t?.measures.files,r=st(us({...e,...t?{bulk:t.measures.restOnly?{restOnly:t.measures.restOnly}:{},...n&&"count"in n?{files:n.count}:{}}:{}}),e.budget),o=Yo(r,e.target),i=[],s=es(e.checkpoint);s&&i.push(s),o!==void 0&&i.push({code:ne,message:o,...t&&r.verdict==="exceeds"?{api:{kind:"requests",org:"target",estimate:r.estimate,remaining:r.remaining}}:{}});let a;if(t){let f=cs({...e,measures:t.measures,...t.sourceSentBefore!==void 0?{sourceSentBefore:t.sourceSentBefore}:{}}),g=f.bulkBatches>0?st(f.bulkBatches,t.bulkBatches??{unread:fs}):void 0,p=g&&gs(g,e.target);p!==void 0&&g?.verdict==="exceeds"&&i.push({code:ne,message:p,api:{kind:"bulkBatches",org:"target",estimate:g.estimate,remaining:g.remaining}});let m=st(f.sourceRequests,t.sourceBudget),w=ps(m,t.source);w!==void 0&&m.verdict==="exceeds"&&i.push({code:ne,message:w,api:{kind:"requests",org:"source",estimate:m.estimate,remaining:m.remaining}}),a={source:m,...g?{bulkBatches:g}:{},cost:f}}let[d,...l]=i,u=l.filter(f=>f.code===ne);return{api:r,...d?{stop:d}:{},...t&&u.length>0?{alsoRefused:u}:{},...a?{wholeOrg:a}:{},asks:e.checkpoint!==void 0||t!==void 0,confirmation:{...Jo(r),...e.checkpoint?{checkpoint:e.checkpoint}:{}}}}function sr(e,t,n=0){let r=Math.max(0,n),o=e.storageBytes+r,i=o/1048576,s=r>0?{automationMB:r/1048576}:{};if("unread"in t)return{verdict:"unread",estimateMB:i,unread:t.unread,...s};let{maxMB:a,remainingMB:d}=t;return{verdict:o>d*1048576?"exceeds":o>Zn*d*1048576?"near":"fits",estimateMB:i,maxMB:a,remainingMB:d,...s}}function Ss(e,t){if(!t||t.length===0)return 0;let n=new Map;for(let{objectApiName:r,bytes:o}of t)n.set(r,(n.get(r)??0)+Math.max(0,o));return e.objects.reduce((r,{objectApiName:o,rows:i})=>r+i*(n.get(o)??0),0)}function Ne(e){return`about ${L(e.estimateMB)} MB of data storage`+(e.automationMB!==void 0&&e.automationMB>0?`, about ${L(e.automationMB)} MB of it for what the target's automation creates under them`:"")}function Es(e,t){let n=_o(e),r=t.emailTextBytes,o=e.some(s=>$e(s.objectApiName)===ee&&s.counted);if(r===void 0||!Number.isFinite(r)||!o)return n;let i=n.objects.map(s=>$e(s.objectApiName)===ee?{...s,storageBytes:s.storageBytes+Math.max(0,r)}:s);return{...n,objects:i,storageBytes:i.reduce((s,a)=>s+a.storageBytes,0)}}function As(e,t,n){return e.flatMap(({objectApiName:r,included:o,piiFields:i,anonymizeFields:s})=>{if(!o||!t.has(r))return[];let a=new Set(n?s:[]),d=i.filter(l=>!a.has(l));return d.length>0?[{objectApiName:r,fields:d}]:[]})}function Ts(e){let t=e.leftOut??[],n=new Set(t.map(({objectApiName:i})=>i)),r=[...t,...e.nodes.filter(i=>i.leftOutByUser===!0&&!n.has(i.objectApiName)).map(({objectApiName:i})=>({objectApiName:i,reason:"excludedByUser"}))],o=new Map;for(let{reason:i}of r)o.set(i,(o.get(i)??0)+1);return{objects:r,counts:[...o].map(([i,s])=>({reason:i,count:s})).sort((i,s)=>s.count-i.count||i.reason.localeCompare(s.reason))}}var Os=2;async function Pd(e){let t=b=>({unread:N(b)}),n=Es(e.objects,e.measures),r=await Uo(e.target.limits).catch(t),o="unread"in r?await Vn(e.target.limits).catch(t):r.dailyApiRequests,i=await Vn(e.source.limits).catch(t),s=sr(n,r,Ss(n,e.automation)),a=si(s,e.target.org),d=e.sample?vs({sample:e.sample,storage:r,target:e.target.org}):void 0,l=bs(e.measures.files,r,e.target.org),u=e.sentBefore?.(),f=Rs({plan:n,...e.updatedAfterInsert?{updatedAfterInsert:e.updatedAfterInsert}:{},...e.readBack!==void 0?{readBack:e.readBack}:{},...e.checkpoint?{checkpoint:e.checkpoint}:{},...e.mute!==void 0?{mute:e.mute}:{},deliverability:e.deliverability??Os,...u?{sentBefore:u.target}:{},budget:o,target:e.target.org,wholeOrg:{measures:e.measures,bulkBatches:"unread"in r?r:r.dailyBulkApiBatches,sourceBudget:i,source:e.source.org,...u?.source!==void 0?{sourceSentBefore:u.source}:{}}}),g=[ws(e.measures.readWholeOver),d,d===void 0&&a!==void 0&&s.verdict==="exceeds"?{code:"STORAGE_EXCEEDED",message:`${a} Nothing was written.`,storage:{estimateMB:Number(L(s.estimateMB)),remainingMB:s.remainingMB}}:void 0,l.stop,f.stop,...f.alsoRefused??[]].filter(b=>b!==void 0),p=e.measures.restOnly?{restOnly:e.measures.restOnly}:{},m=new Set(n.objects.map(({objectApiName:b})=>b)),{wholeOrg:w}=f;return{wouldInsert:n.objects.map(({objectApiName:b,rows:R})=>{let{jobs:O,rest:T}=Be(b,R,p);return{objectApiName:b,rows:R,jobs:O.length,byRest:T}}),totalRows:n.totalRows,targetRequests:f.api,sourceRequests:w.source,...w.bulkBatches?{bulkBatches:w.bulkBatches}:{},storage:s,...l.files?{files:l.files}:{},durationSeconds:w.cost.durationSeconds,leftOut:{...Ts(e.graph),...n.leftOut?{rows:n.leftOut}:{}},personalAsIs:As(e.graph.nodes,m,e.anonymizePII),wouldBeRefused:g,...e.measures.personAccountsAsBusiness?{personAccountsAsBusiness:e.measures.personAccountsAsBusiness}:{},...e.sample?{sample:e.sample}:{}}}var ks="SAMPLE_STORAGE_UNREAD",ir="SAMPLE_CANNOT_FIT",Fs="SAMPLE_TOO_LARGE",ar="SAMPLE_PLAN_MISMATCH",dt="SAMPLE_PLAN_GONE";function $s(e){let{storage:t,bounds:n,target:r}=e;if("unread"in t&&!(n.withinMB!==void 0||n.maxTotal!==void 0))return{code:ks,message:`The data storage ${r} has left could not be read (${t.unread}), and a sample is fitted to it: there is nothing to hold it to. Give the most it may take (--fit-within <MB>) or the most records (--max-total <n>), or run it again once the org answers. Nothing was written.`}}function Ps(e,t){if(e.remainingMB===void 0||e.share===void 0)return;let n=Math.max(0,t.remainingMB-(e.roundingMB??0));return Math.floor(e.share*n*1048576)}function Bs(e){let{sample:t,storage:n,target:r}=e,o=Ps(t.budget,n);if(o===void 0||t.storageBytes<=o)return;let i=hr(t.storageBytes/1048576,o/1048576),s=L(t.budget.bytes/1048576);return{code:"STORAGE_EXCEEDED",message:`The sample was fitted to ${s} MB of the data storage ${r} had left (${t.budget.remainingMB} MB), and ${r} now says ${n.remainingMB} MB left, which holds ${i.bound} MB of a sample: the sample takes about ${i.over} MB. Simulate again \u2014 run the dry run again \u2014 to draw a sample that fits: a run never cuts its sample short. Nothing was written.`,storage:{estimateMB:Number(i.over),remainingMB:n.remainingMB},sample:{fittedMB:Number(s),holdsMB:Number(i.bound)}}}function vs(e){let{sample:t,storage:n,target:r}=e;return"unread"in n?$s({storage:n,bounds:t.budget,target:r}):Bs({sample:t,storage:n,target:r})}var Ns=new Set(["gone","changed","otherOrg","otherSetup","otherSha"]),Ms={changed:"is no longer as its dry run wrote it: its ids changed since",otherOrg:"was drawn of another org than the source",otherSetup:"was drawn for another setup of the run \u2014 other flags, filters, objects or options of the sample",otherSha:"is not the plan its dry run printed"};function xs(e,t){return t==="resume"?{code:dt,message:`The plan of the sample this run resumes ${e==="gone"?"is no longer on this machine":"is no longer as it was written"}: the records it was to write cannot be taken up after where it stopped (--resume). Remove what it wrote (--remove), or run the clone again without --resume to draw a new sample. Nothing was written.`,sample:{plan:e}}:e==="gone"?{code:dt,message:'No plan of a sample is at the path given to --fit-plan: give the folder its dry run printed ("sample plan: \u2026"), within a day of it, or leave --fit-plan out to draw a new sample. Nothing was written.',sample:{plan:e}}:{code:ar,message:`The plan given to --fit-plan ${Ms[e]}: run the dry run again with the flags of this run, and replay the plan it prints. Nothing was written.`,sample:{plan:e}}}var Cs=new Set([Fs,ir,dt,ar]),js=20;function Bd(e,t){if(e instanceof Error){if(e.name==="SampleRefusedError"){let{code:n,heaviest:r,sample:o}=e;if(typeof n!="string"||!Cs.has(n))return;let i=Array.isArray(r)?r.flatMap(d=>{let l=d?.objectApiName;return typeof l=="string"?[l]:[]}):[],s=Qt({code:n,sample:o})?.sample??{},a={...s,...n===ir&&s.heaviest===void 0&&i.length>0?{heaviest:i.slice(0,js)}:{}};return V.of({code:n,message:e.message,...Object.keys(a).length>0?{sample:a}:{}})}if(e.name==="SamplePlanError"&&t!=="draw"){let{refusal:n}=e;return typeof n!="string"||!Ns.has(n)?void 0:V.of(xs(n,t))}}}var _s=P({SingleEmail:P({Max:M(),Remaining:M()}).loose().optional(),DailyWorkflowEmails:P({Max:M(),Remaining:M()}).loose().optional()}).loose();async function vd(e){let t=_s.parse(await e.request({method:"GET",url:"/limits"})),n={};for(let r of["SingleEmail","DailyWorkflowEmails"]){let o=t[r];o&&(n[r]={max:o.Max,remaining:o.Remaining})}return n}var Is=15;function dr(e){let t=e.SingleEmail;return t!==void 0&&t.max<=Is}function Ds(e){return dr(e)&&e.DailyWorkflowEmails!==void 0}function Ls(e,t,n=!1){let r=e.map(a=>({...a,sentBy:[...a.sentBy]})),o=(a,d)=>{let l=r.find(u=>u.objectApiName===a.objectApiName&&u.limit===d);if(!l){let u={...a,limit:d,sentBy:[...a.sentBy]};return r.push(u),u}l.perRecord+=a.perRecord;for(let u of a.sentBy)l.sentBy.includes(u)||l.sentBy.push(u);return l},i=e.filter(a=>a.limit==="SingleEmail"),s=e.filter(a=>a.limit==="DailyWorkflowEmails");if(n)for(let a of i)o(a,"DailyWorkflowEmails");if(t)for(let a of s)o(a,"SingleEmail").alertsAmong=!0;return r}function ur(e){let t=new Map(e.objects.map(n=>[n.objectApiName,{rows:n.rows,byThePlatform:0}]));for(let{objectApiName:n,rows:r}of e.leftOut?.byThePlatform??[]){let o=t.get(n)??{rows:0,byThePlatform:0};t.set(n,{rows:o.rows+r,byThePlatform:o.byThePlatform+r})}return t}function ft(e){return new Set([...ur(e)].flatMap(([t,{rows:n}])=>n>0?[t]:[]))}function Ws(e,t,n){let r=ur(e),o=new Map;for(let s of t){let{rows:a,byThePlatform:d}=r.get(s.objectApiName)??{rows:0,byThePlatform:0};if(a===0)continue;let l=o.get(s.limit)??{limit:s.limit,objects:[],emails:0,verdict:"fits"};l.objects.push({objectApiName:s.objectApiName,rows:a,perRecord:s.perRecord,sentBy:s.sentBy,...d>0?{byThePlatform:d}:{}}),l.emails+=a*s.perRecord,o.set(s.limit,l)}let i=ve(n)?n.unread:void 0;return[...o.values()].map(s=>{if(i!==void 0||ve(n))return{...s,verdict:"unread",unread:i};let a=n[s.limit];return a?{...s,verdict:s.emails>a.remaining?"exceeds":"fits",remaining:a.remaining,max:a.max}:{...s,verdict:"unread",unread:`the org's limits list no ${s.limit}`}})}function ve(e){return typeof e.unread=="string"}function Gs(e,t,n){let r=!ve(n)&&dr(n),o=!ve(n)&&Ds(n),i=Ws(e,Ls(t,r,o),n);if(!r)return i;let s=ft(e);return t.some(d=>d.limit==="DailyWorkflowEmails"&&s.has(d.objectApiName))?i.map(d=>d.limit==="SingleEmail"?{...d,alertsCounted:!0}:d):i}async function Nd(e){if(e.plan.totalRows===0||e.objects.length===0)return{checks:[]};let t;try{t=await e.readAutomation(e.objects)}catch(s){return{checks:[],unread:`the target's automation: ${N(s)}`}}let n=Us(t,qs(e.plan)),r=n!==void 0?{unread:n}:{},o=an(t);if(o.length===0)return{checks:[],...r};let i=await e.readLimits().catch(s=>({unread:N(s)}));return{checks:Gs(e.plan,o,i),...r}}function qs(e){let t=ft(e);return(n,r)=>r==="insert"&&t.has(n)}function Us(e,t,n="the target's"){let r=[lr(e.unread,n),Qs(e,t)].filter(o=>o!==void 0).join("; ");return r!==""?r:void 0}var Vs={flows:"flows",processes:"processes",workflowRules:"workflow rules"};function lr(e,t){let n=e.flatMap(({part:r,reason:o})=>{let i=Vs[r];return i!==void 0?[`${t} ${i}: ${o}`]:[]});return n.length>0?n.join("; "):void 0}var K=10;function zs(e){if(e.condition!=="unreadable")return;let t=e.apiName.indexOf("__");return t>0?e.apiName.slice(0,t):void 0}function Qs(e,t){let n=e.objects.flatMap(o=>{let s=[...new Set(he(o).filter(d=>t(o.objectApiName,d.write)).flatMap(d=>d.fired).flatMap(({flow:d,keptQuiet:l})=>d!==void 0&&l!==!0&&d.condition!=="read"&&d.timing!=="beforeSave"?[d]:[]))].map(d=>{let l=zs(d);return l!==void 0?`${d.label} (package ${l}, whose flows the org lets no one read)`:d.label});if(s.length===0)return[];let a=s.length>K?` and ${s.length-K} more`:"";return[{count:s.length,words:`${s.slice(0,K).join(", ")}${a} on ${o.objectApiName}`}]});return n.length===0?void 0:`the definition${n.reduce((o,{count:i})=>o+i,0)===1?"":"s"} of ${n.map(({words:o})=>o).join("; ")}`}function Md(e){return{limit:e.limit,emails:e.emails,remaining:e.remaining??0,max:e.max??0,objects:e.objects.map(({objectApiName:t,perRecord:n})=>({objectApiName:t,perRecord:n})),...e.alertsCounted?{alertsCounted:!0}:{}}}function xd(e){return{limit:e.limit,emails:e.emails,unread:e.unread??""}}var Hs={SingleEmail:{one:"single email",more:"single emails"},DailyWorkflowEmails:{one:"workflow email",more:"workflow emails"}};function cr(e,t){let n=Hs[t];return`${e} ${e===1?n.one:n.more}`}function Ks(e,t){return e.alertsCounted?`, its email alerts among them: ${t} counts them against its single emails, as a Developer Edition does`:""}function Cd(e,t){let n=e.filter(o=>o.verdict==="exceeds");if(n.length===0)return;let r=n.map(o=>`about ${cr(o.emails,o.limit)}`+(o.alertsCounted?" (its email alerts among them, as a Developer Edition counts them)":"")+`, ${o.remaining??0} of ${o.max??0} left today`).join("; ");return`The target's automation would make ${t} send ${r}: past them, each record whose flow fails in the save is refused (CANNOT_EXECUTE_FLOW_TRIGGER), and the org's own emails stop for the rest of the day. Assign the user a bypass that keeps what sends quiet \u2014 muting the target's automation for the run (--mute-automation on the command line, the Mute box on a page) assigns, for the run alone, those the target's flows test \u2014 or write fewer records.`}function jd(e,t){return e.map(n=>{let r=n.objects.map(i=>`${i.perRecord} per ${i.objectApiName}, by ${i.sentBy.join(", ")}`+(i.byThePlatform?`; ${i.byThePlatform} ${i.objectApiName} written by the platform with ${te(i.objectApiName)}, whose flows run all the same`:"")).join("; "),o=` emails: these records make ${t} send about ${cr(n.emails,n.limit)} (${r})`+Ks(n,t);return n.verdict==="unread"?`${o}; what it has left today could not be read (${n.unread??""})`:n.verdict==="fits"?`${o}; it has ${n.remaining??"?"} of ${n.max??"?"} left today`:`${o}, more than the ${n.remaining??"?"} of ${n.max??"?"} it has left today: past them the action fails, and a record whose flow fails in the save is refused (CANNOT_EXECUTE_FLOW_TRIGGER). A bypass that keeps the flow quiet, or a smaller run, avoids it`})}var fr="EMAILS_NOT_ACCEPTED";function _d(e,t={}){let n=[lr(e,"the target's"),...t.applyAssignmentRules===!0?e.filter(({part:r})=>r==="assignmentRules").map(({reason:r})=>`the target's assignment rules: ${r}`):[]].filter(r=>r!==void 0);return n.length>0?n.join("; "):void 0}function Id(e){return"requests"in e&&typeof e.requests=="number"?Math.max(0,e.requests):Jn}function Dd(e){let t=e?.read?.requests??0;return t>0?{deliverability:t}:{}}var gr={clone:{run:"this clone",allTheSame:"to clone all the same"},sync:{run:"this sync",allTheSame:"to sync all the same"},seed:{run:"this seed",allTheSame:"to seed all the same"},autopilot:{run:"this Autopilot run",allTheSame:"to run it all the same"},rewind:{run:"this rewind",allTheSame:"to rewind all the same"},undo:{run:"this undo",allTheSame:"to undo all the same"},masking:{run:"this masking",allTheSame:"to mask all the same"},restore:{run:"this restore",allTheSame:"to restore all the same"},cleanup:{run:"this cleanup",allTheSame:"to delete all the same"},empty:{run:"this emptying",allTheSame:"to empty all the same"},load:{run:"this load",allTheSame:"to load all the same"}},Xs={flow:"flow",process:"process",workflowRule:"workflow rule",assignmentRule:"assignment rule"},Ys={email:"",notRead:" (its definition was not read)",assignment:" (applied: it can mail the owner it assigns)"};function pr(e){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function re(e){let t=new Map;for(let n of e){let r=t.get(n.objectApiName)??[];r.push(`${Xs[n.kind]} "${n.name}"${Ys[n.why]}`),t.set(n.objectApiName,r)}return[...t].map(([n,r])=>{let o=r.length>K?[...r.slice(0,K),`${r.length-K} more`]:r;return`${pr(o)} on ${n}`}).join("; ")}var Qn="read with one line of anonymous Apex that sends nothing";function mr(e){return"level"in e&&e.level==="withheld"}function Js(e){return"unread"in e?`deliverability: not read (${e.unread}) \u2014 the run is refused without --accept-emails, as on All email`:e.level==="all"?`deliverability: All email \u2014 the emails of what still runs go out (${Qn})`:`deliverability: System email only or No access \u2014 none of the emails its flows, processes, workflow rules and Apex send goes out, and the org still counts them against its daily email limits (${Qn})`}function Zs(e,t){let{run:n,allTheSame:r}=gr[e.run],{target:o}=e,i=re(e.senders),s=e.sendersUnread,a=i!==""?`what still runs as ${n} writes its records sends some: ${i}`+(s!==void 0?`; what could not be read may send more (${s})`:""):`what runs as ${n} writes its records could not all be read (${s??""}), so it may send some`,d=[];"unread"in t?d.push(`Whether ${o} delivers the emails its automation sends could not be read (${t.unread}), and ${a}.`,`Nothing was written. Add --accept-emails ${r}, or check Setup > Deliverability: on System email only or No access, none of them goes out.`):d.push(`${o} delivers every email its automation sends (Setup > Deliverability: All email), and ${a}.`,e.keepsAddresses===!0?`They go to the addresses the records and the alerts name: those of the records ${n} writes, as they hold them, the records' owners, the records already in ${o}, and an address an alert names.`:`They go to the addresses the records and the alerts name: those ${n} writes are under .invalid, but not the records' owners, the records already in ${o}, nor an address an alert names.`,`Nothing was written. Add --accept-emails ${r}, set the org's deliverability to System email only, or turn off what sends them.`);let l=e.muteQuiets??[];if(l.length>0){let u=new Set(l.map(g=>`${g.objectApiName}\0${g.kind}\0${g.name}`)),f=e.senders.filter(g=>!u.has(`${g.objectApiName}\0${g.kind}\0${g.name}`));d.push(`--mute-automation keeps quiet ${re(l)}, which ${l.length===1?"tests":"test"} a bypass a permission set of ${o} holds`+(f.length>0?`; it cannot quiet ${re(f)}.`:"."))}return d.join(" ")}function Ld(e){if(e.senders.length===0&&e.sendersUnread===void 0)return{verdict:"nothingSends",confirmation:{}};let t=e.reading??{unread:"the run did not read it"},n={reading:t,senders:[...e.senders],...e.sendersUnread!==void 0?{sendersUnread:e.sendersUnread}:{}},r=Js(t);return mr(t)?{verdict:"withheld",deliverability:n,confirmation:{},line:r,audit:"withheld"}:{verdict:"asks",deliverability:n,confirmation:{deliverability:e.keepsAddresses===!0?{...n,keepsAddresses:!0}:n},...e.accepted?{}:{stop:{code:fr,message:Zs(e,t)}},line:r,audit:"unread"in t?"unread":"all"}}function Wd(e,t){let n=ft(t);return e.filter(r=>!n.has(r.objectApiName))}function Gd(e){if(e.length===0)return;let t=[...new Set(e.map(n=>n.objectApiName))];return` emails: ${re(e)} send nothing: the run writes no ${pr(t)} record. A real run is refused all the same, and names them: it asks before it reads which records it writes`}function qd(e){let t=d=>`${d.objectApiName}\0${d.kind}\0${d.name}`,n=new Set(e.planned.map(t)),r=e.held.filter(d=>!n.has(t(d)));if(r.length===0||e.accepted)return;let o=e.reading;if(o!==void 0&&mr(o))return;let{run:i,allTheSame:s}=gr[e.run],a=o===void 0?`whether ${e.target} delivers them was not read, as nothing that sends one was to run`:"unread"in o?`whether ${e.target} delivers them could not be read (${o.unread})`:`${e.target} delivers every one of them (All email)`;return{code:fr,relit:r,message:`The mute's lease does not hold every permission set it was to assign, and what they were to keep quiet still runs for ${i}: ${re(r)} may send emails, and ${a}. The run's question did not ask about them. Nothing was written. Add --accept-emails ${s}, or run it again once the lease can assign them.`}}function Ud(e){return e.verdict==="unread"?{estimateMB:e.estimateMB,unread:e.unread}:{estimateMB:e.estimateMB,maxMB:e.maxMB,remainingMB:e.remainingMB,near:e.verdict==="near"}}function L(e){return ut(e,e<10?2:1)}function ut(e,t){if(e<=0)return"0";let n=10**t;return(Math.ceil(e*n-1e-9)/n).toString()}function hr(e,t){let n={over:e<10?2:1,bound:t<10?2:1};for(;;){let r={over:ut(e,n.over),bound:ut(t,n.bound)},o=Math.max(n.over,n.bound);if(Number(r.over)>Number(r.bound)||o>=6)return r;n={over:o+1,bound:o+1}}}function yr(e){return e.map(({objectApiName:t,kind:n,name:r})=>({objectApiName:t,kind:n,name:r}))}function ei(e){return yr(Je(e,"insert"))}function ti(e,t){let n=new Set(t);return yr(Je(e,"update",r=>n.has(r)))}var wr=["lookups","statuses","invitees","retry","upsert"];function Vd(e,t={}){let n=lt(e,t.leftOut),r=new Set(n),o=new Map,i=(u,f)=>{if(!r.has(u))return;let g=o.get(u)??new Set;g.add(f),o.set(u,g)},s=e.edges.filter(u=>On(u)&&r.has(u.sourceObject)&&r.has(u.targetObject)),a=new Map;for(let{sourceObject:u,targetObject:f}of s)u!==f&&a.set(u,[...a.get(u)??[],f]);let d=(u,f)=>{let g=new Set([u]),p=[u];for(let m=p.shift();m!==void 0;m=p.shift())for(let w of a.get(m)??[]){if(w===f)return!0;g.has(w)||(g.add(w),p.push(w))}return!1},l=s.filter(u=>u.required!==!0&&u.insertOnly!==!0);for(let{sourceObject:u,targetObject:f}of l)(u===f||d(f,u))&&i(f,"lookups");for(let u of Object.keys(cn))i(u,"statuses");for(let u of Object.keys(ln))i(u,"invitees");if(t.retry===!0)for(let{sourceObject:u,targetObject:f}of l)u!==f&&i(f,"retry");if(t.upsert===!0)for(let u of n)i(u,"upsert");return n.flatMap(u=>{let f=o.get(u);return f?[{objectApiName:u,steps:wr.filter(g=>f.has(g))}]:[]})}function ni(e){let t=new Set(e.flatMap(n=>n.steps));return wr.filter(n=>t.has(n))}function zd(e,t=[]){let n=new Set(t);return dn(e,(r,o)=>o==="insert"||o==="update"&&n.has(r))}function Qd(e,t,n){let r=new Set(ye(e).map(s=>s.toLowerCase())),o=t.filter(s=>!r.has(s.toLowerCase())),i=be(e,o);return o.map(s=>{let a=i.find(l=>l.permission.toLowerCase()===s.toLowerCase()),d=a?.permissionSet?.name;return{permission:s,...d?{permissionSet:d}:{},others:a?.others.map(l=>l.name)??[],...a&&!d?{noneHolds:!0}:{},...d&&n?.alias&&n.username?{command:Re(d,n.alias,n.username)}:{}}})}function ri(e){return e==="flows"||e==="triggers"||e==="processes"||e==="workflowRules"||e==="automation"}function ie(e){return e.unread.flatMap(({part:t,reason:n})=>ri(t)?[{part:t,reason:n}]:[])}var Hd="OWNER_MAP_INACTIVE",Kd="OWNER_MAP_UNKNOWN",V=class e extends Error{code;storage;ceiling;reason;api;readBound;sample;roots;constructor(t,n,r,o,i,s){super(n),this.name="ForgeRunGateError",this.code=t,r&&(this.storage=r),o!==void 0&&(this.ceiling=o),i!==void 0&&(this.reason=i),s?.api&&(this.api=s.api),s?.readBound&&(this.readBound=s.readBound),s?.sample&&(this.sample=s.sample),s?.roots&&(this.roots=s.roots)}static of(t){return new e(t.code,t.message,t.storage,void 0,t.refusal?.code,{...t.api?{api:t.api}:{},...t.readBound?{readBound:t.readBound}:{},...t.sample?{sample:t.sample}:{},...t.roots?{roots:t.roots}:{}})}get stop(){if(zt(this.code))return{code:this.code,...this.storage?{storage:this.storage}:{},...this.ceiling!==void 0?{ceiling:this.ceiling}:{},...this.reason!==void 0&&this.code===Pe?{reason:this.reason}:{},...this.api&&this.code===ne?{api:this.api}:{},...this.readBound&&this.code==="READ_BOUND_EXCEEDED"?{readBound:this.readBound}:{},...this.sample?{sample:this.sample}:{},...this.roots&&(oi.has(this.code)||this.code==="STORAGE_EXCEEDED")?{roots:this.roots}:{}}}},oi=new Set(["ROOTS_QUERY_REFUSED","NO_ROOTS","ROOTS_EXCEEDED","ROOTS_PLAN_MISMATCH","ROOTS_PLAN_GONE"]);function Xd(e){return e instanceof V||e instanceof Error&&e.name==="ForgeRunGateError"&&typeof e.code=="string"}var Hn="FILE_STORAGE_EXCEEDED";function Yd(e){if(!(e instanceof Error)||e.name!=="ForgeFilesRefusedError")return;let{code:t,storage:n}=e;if(t===rr||t===or)return new V(t,e.message);let r=n?.neededBytes,o=n?.remainingBytes;if(t!==Hn||typeof r!="number"||typeof o!="number"||!Number.isFinite(r)||!Number.isFinite(o))return;let i=o/1048576;return new V(Hn,e.message,{estimateMB:Number(hr(r/1048576,i).over),remainingMB:i,kind:"files"})}function si(e,t){if(e.verdict==="exceeds")return`The records to write take ${Ne(e)}, and ${t} has ${e.remainingMB} MB left of ${e.maxMB} MB: leave objects out, lower the records per object, or free data storage in ${t}.`}var Kn=10;function Jd(e,t,n){let r=[`write gate: ${e.totalRows} record(s) to write to ${n}, ${Ne(t)}`];for(let i of e.objects.slice(0,Kn))r.push(` ${i.objectApiName.padEnd(42)}${String(i.rows).padStart(8)}`);let o=e.objects.slice(Kn);if(o.length>0){let i=o.reduce((s,a)=>s+a.rows,0);r.push(` and ${o.length} more object(s), ${i} record(s)`)}for(let{objectApiName:i,mayAdd:s}of e.objects)s!==void 0&&r.push(` counted in: up to ${s} ${i} record(s) the run may read as it writes them, a price in the currency of the record its lines belong to, the source's own beside the one read`);for(let{objectApiName:i,mayBeByThePlatform:s}of e.objects)s!==void 0&&r.push(` counted in: up to ${s.rows} ${i} record(s) the platform `+(s.before===!0?`may have written with ${te(i)}, in the run this one takes up`:`may write itself with ${te(i)}`)+", which the run then links to and does not send");r.push(...ii(e.leftOut));for(let{objectApiName:i,field:s,rows:a}of e.leftEmpty??[])r.push(` written empty: ${i}.${s} on ${a} record(s), the record it names held back by the run, never written`);return t.verdict==="unread"?(r.push(` the data storage ${n} has left could not be read (${t.unread}): whether the records fit is not known`),r):(r.push(` data storage of ${n}: ${t.remainingMB} MB left of ${t.maxMB} MB`),t.verdict==="near"&&r.push(` that is more than ${Math.round(Zn*100)} % of what ${n} has left: Salesforce counts storage a while after a load, so less may be left than it says`),r)}function ii(e){if(!e)return[];let t=[];e.writtenBefore>0&&t.push(` not counted: ${e.writtenBefore} record(s) the run it retries or resumes wrote, which it links to and does not write again`);for(let{objectApiName:n,rows:r}of e.heldBack)t.push(` not counted: ${n}, ${r} record(s), held back for a record type closed to the user the run writes as`);for(let{objectApiName:n,rows:r}of e.recordTypeNotInTarget??[])t.push(` not counted: ${n}, ${r} record(s), held back for a record type the target has none of, which it would refuse`);for(let{objectApiName:n,rows:r}of e.withoutParent??[])t.push(` not counted: ${n}, ${r} record(s) held back with a record they cannot be written without, held back itself`);for(let{objectApiName:n,rows:r}of e.noParentInSource??[])t.push(` not counted: ${n}, ${r} record(s) left aside: a lookup they may not leave empty names a record the source does not hold, which no copy can write`);for(let{objectApiName:n,rows:r}of e.outsideFilter??[])t.push(` not counted: ${n}, ${r} record(s) left aside: a lookup they may not leave empty names a record outside its object's filter, which the run does not copy`);for(let{objectApiName:n,rows:r}of e.byThePlatform??[])t.push(` not counted: ${n}, ${r} record(s) written by the platform with ${te(n)}, which the run links to and does not send`);for(let{objectApiName:n,rows:r,fields:o}of e.linkedByValue??[])t.push(` not counted: ${n}, ${r} record(s) the target holds under the same ${o.join(", ")}, which the run links to and does not create`);for(let{objectApiName:n,rows:r}of e.linkedToTarget??[])t.push(` not counted: ${n}, ${r} record(s), the standard price book: linked to the target's own, never written`);for(let{objectApiName:n,rows:r}of e.currencyReplaced??[])t.push(` not counted: ${n}, ${r} record(s) in a currency the target lacks, replaced by the source's own price in the currency written, for the same product and price book`);return t}var ai={flow:e=>`flow "${e}" runs before a record is deleted, and can refuse the delete`,trigger:e=>`Apex trigger ${e} runs on a delete, and can refuse it`,packageTrigger:e=>`Apex trigger ${e}, installed by a managed package, runs on a delete and can refuse it; no one in the org can change it`,lock:()=>"once activated, a record locks the records under it, which a removal then takes only with it, or once it is back in Draft"},di=["flows","triggers"];function Zd(e,t,n=[],r="--remove"){let o=di.filter(s=>n.some(a=>a.part===s)),i=o.length===0?[]:[` ${o.map(s=>_[s]).join(" and ")} could not be read: whether one refuses the removal is not known`];if(e.length===0&&o.length===0)return[`reversibility: nothing found in ${t} that refuses a removal of this run's records (no flow before a delete, no Apex trigger on one, no record that locks past Draft)`];if(e.length===0){let s=[...o.includes("flows")?[]:["no flow before a delete"],...o.includes("triggers")?[]:["no Apex trigger on a delete"],"no record that locks past Draft"];return[`reversibility: nothing found in ${t} that refuses a removal of this run's records in what could be read (${s.join(", ")})`,...i]}return[`reversibility: a removal of this run's records (${r}) may be refused in ${t}:`,...e.map(({objectApiName:s,kind:a,name:d})=>` ${s}: ${ai[a](d??"")}`),...i]}var _={flows:"the flows",triggers:"the Apex triggers",processes:"the Process Builder processes",workflowRules:"the workflow rules",automation:"the automation"};function W({kind:e,name:t}){return e==="flow"?`flow "${t}"`:e==="process"?`process "${t}"`:e==="workflowRule"?`workflow rule "${t}"`:`Apex trigger ${t}`}var ui={lookups:"a lookup filled in once its record exists",statuses:"an order or a contract given back its status after it went in as a draft",invitees:"an event's invitee given its answer",retry:"a lookup the run it retries left empty filled in",upsert:"a record the target holds written over by --upsert"};function X(e){return e.map(t=>`${t.objectApiName}: ${W(t)}`).join("; ")}function gt(e,t,n){return e.flatMap(r=>{if(r.command){let o=r.others.length>0?`; ${r.others.join(", ")} hold${r.others.length===1?"s":""} it too`:"";return[`${r.permissionSet} is the smallest permission set of ${t} that holds ${r.permission}${o}. Assigned to the user ${n} writes as, it keeps quiet what ${r.permission} excludes: ${r.command}`]}return r.noneHolds?[`No permission set of ${t} holds ${r.permission}: an admin creates one that includes it, and assigns it to the user ${n} writes as.`]:[]})}function pt(e,t,n){let r=[...new Set(e.flatMap(o=>o.permissionSet??[]))];return!n||r.length===0?[]:[`With --mute-automation, the ${t} assigns ${r.join(", ")} to the user it writes as for the ${t} alone, under a lease, and what ${r.length===1?"it keeps":"they keep"} quiet does not fire.`]}function eu(e,t,n={}){let r=n.updated??[],o=ei(e),i=ti(e,r.map(l=>l.objectApiName)),s=ie(e);if(o.length===0&&i.length===0&&s.length===0)return;let a=[];if(o.length>0&&a.push(`${t} runs automation on the records this clone inserts: ${X(o)}.`),i.length>0){let l=ni(r.filter(u=>i.some(f=>f.objectApiName===u.objectApiName))).map(u=>ui[u]);a.push(`${t} runs automation as this clone updates records it inserted (${l.join("; ")}): ${X(i)}.`)}let d=r.length>0?"inserts and updates":"inserts";for(let{part:l,reason:u}of s)a.push(`${_[l][0].toUpperCase()}${_[l].slice(1)} of ${t} could not be read (${u}), so what fires as the clone ${d} is not known.`);return a.push(...gt(n.assign??[],t,"the clone")),a.push(...pt(n.assign??[],"clone",n.mayMute===!0)),a.push(`Nothing was written. Add --accept-automation to clone all the same, or turn that automation off in ${t} first.`),a.join(" ")}function tu(e,t,n={}){let r=Ze(e,n.drafted??[]),o=ie(e);if(r.length===0&&o.length===0)return;let i=[],s=r.filter(d=>d.write==="update"),a=r.filter(d=>d.write==="delete");if(a.length>0){let d=a.map(l=>`${l.objectApiName}: ${W(l)} (${oe[l.when]})`);i.push(`${t} runs automation on the records this removal deletes: ${d.join("; ")}.`)}s.length>0&&i.push(`${t} runs automation as this removal sets activated records back to Draft, the only way the platform deletes them: ${X(s)}.`);for(let{part:d,reason:l}of o)i.push(`${_[d][0].toUpperCase()}${_[d].slice(1)} of ${t} could not be read (${l}), so what fires as the removal deletes is not known.`);return i.push(...gt(n.assign??[],t,"the removal")),i.push(...pt(n.assign??[],"removal",n.mayMute===!0)),i.push(`Nothing was deleted. Add --accept-automation to remove all the same, or turn that automation off in ${t} first.`),i.join(" ")}var oe={before:"before delete",after:"after delete",beforeAndAfter:"before and after delete"};function nu(e,t,n,r){let o=[`removal automation: what ${t} runs as the removal takes the records back`];for(let s of Ze(e,r))o.push(s.write==="delete"?` ${s.objectApiName}: ${oe[s.when]}: ${W(s)}`:` ${s.objectApiName}: set back to Draft before its delete: ${W(s)}`);let i=ie(e);o.length===1&&i.length===0&&o.push(` nothing fires on the ${n} object(s) it deletes records of`);for(let{part:s,reason:a}of i)o.push(` ${_[s]} could not be read: ${a}`);return o}var li={bringBack:"brought back from the recycle bin",recreate:"made again with a new Id",giveBack:"given back its values from before the run",setToDraft:"set back to Draft before its delete"};function ru(e,t,n,r="removal",o){let i=ie(e),s=(a,d)=>{let l=[ci[d](t)];for(let u of we(e,a))l.push(u.step==="delete"?` ${u.objectApiName}: ${oe[u.when]}: ${W(u)}`:` ${u.objectApiName}: ${li[u.step]}: ${W(u)}`);if(l.length===1&&i.length===0){let u=new Set(Object.values(a).flat()).size,f=fi.has(d)?"deletes":"writes";l.push(` nothing fires on the ${u} object(s) it ${f} records of`)}return l};return[...s(n,r),...o?s(o,br(r)):[],...i.map(({part:a,reason:d})=>` ${_[a]} could not be read: ${d}`)]}var ci={removal:e=>`removal automation: what ${e} runs as the removal takes the run back`,reload:e=>`reload automation: what ${e} runs as the reload purges what earlier loads created`,reloadSweep:e=>`reload automation: what ${e} runs as the reload's sweep deletes what the target's automation made for the loads it replaces`,replayAgain:e=>`replay automation: what ${e} runs as the replay purges what earlier replays created`,replayAgainSweep:e=>`replay automation: what ${e} runs as the replay's sweep deletes what the target's automation made for the replays it replaces`};function ou(e,t,n){let r=we(e,n.steps),o=n.sweep?we(e,n.sweep):[],i=ie(e);if(r.length===0&&o.length===0&&i.length===0)return;let s=l=>r.filter(u=>u.step===l),a=Xn[n.subject??"removal"],d=[];if(s("bringBack").length>0&&d.push(`${t} runs automation as ${a.this} brings back from the recycle bin what the run deleted: ${X(s("bringBack"))}.`),s("giveBack").length>0&&d.push(`${t} runs automation as ${a.this} gives the records the run wrote over their values from before it: ${X(s("giveBack"))}.`),s("setToDraft").length>0&&d.push(`${t} runs automation as ${a.this} sets activated records back to Draft, the only way the platform deletes them: ${X(s("setToDraft"))}.`),s("delete").length>0){let l=s("delete").map(u=>`${u.objectApiName}: ${W(u)} (${oe[u.when]})`);d.push(`${t} runs automation on the records ${a.this} deletes: ${l.join("; ")}.`)}if(o.length>0){let l=o.map(u=>`${u.objectApiName}: ${W(u)} (${oe[u.when]})`);d.push(`${t} runs automation on the records ${Xn[br(n.subject??"removal")].this} deletes: ${l.join("; ")}.`)}for(let{part:l,reason:u}of i)d.push(`${_[l][0].toUpperCase()}${_[l].slice(1)} of ${t} could not be read (${u}), so what fires as ${a.the} writes is not known.`);return d.push(...gt(n.assign??[],t,a.who)),d.push(...pt(n.assign??[],a.run,n.mayMute===!0)),d.push(`Nothing was written or deleted. Add --accept-automation to ${a.verb} all the same, or turn that automation off in ${t} first.`),d.join(" ")}var fi=new Set(["reloadSweep","replayAgainSweep"]);function br(e){return e==="replayAgain"||e==="replayAgainSweep"?"replayAgainSweep":"reloadSweep"}var Xn={removal:{this:"this removal",the:"the removal",who:"the removal",run:"removal",verb:"remove"},reload:{this:"this reload's purge",the:"the reload's purge",who:"the reload",run:"reload",verb:"reload"},reloadSweep:{this:"this reload's sweep",the:"the reload's sweep",who:"the reload",run:"reload",verb:"reload"},replayAgain:{this:"this replay's purge",the:"the replay's purge",who:"the replay",run:"replay",verb:"replay again"},replayAgainSweep:{this:"this replay's sweep",the:"the replay's sweep",who:"the replay",run:"replay",verb:"replay again"}};var pi=2e3,mi=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function Sr(e,t){let n=e!==void 0&&Number.isFinite(e)?Math.floor(e):t;return Math.min(pe,Math.max(1,n))}function cu(e){return e===void 0||!Number.isFinite(e)?pi:Math.max(1,Math.floor(e/10))}function Er(e){return e!==void 0&&Number.isFinite(e)&&e>=1?Math.floor(e):Vt}function fu(e){let t=Yt(e);if(t!==void 0)return{issue:t};let n=Ht(e);return n?{objectApiName:n.objectApiName,query:{...n.where!==null?{where:n.where}:{},...n.orderBy!==null?{orderBy:n.orderBy}:{},...n.limit!==null?{limit:n.limit}:{}}}:{issue:{kind:"noObject"}}}function gu(e){if(e.where!==void 0&&!Kt.safeParse(e.where).success)return{kind:"where"};if(e.orderBy!==void 0&&!Xt.safeParse(e.orderBy).success)return{kind:"orderBy"};if(e.limit!==void 0&&!(Number.isInteger(e.limit)&&e.limit>=1&&e.limit<=pe))return{kind:"limit"}}function pu(e,t,n,r){let o=et(e),i=[...t.where!==void 0?[`(${t.where})`]:[],...n!==void 0&&n!==""?[`(${n})`]:[]],s=i.length>0?` WHERE ${i.join(" AND ")}`:"",a=t.limit!==void 0&&t.limit<=r?t.limit:r+1;return`SELECT Id FROM ${o}${s} ORDER BY ${t.orderBy??"Id"} LIMIT ${a}`}function hi(e,t,n){return!Number.isFinite(e)||e<1||!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0?0:Math.max(0,Math.min(Math.floor(e)-1,Math.floor(n*e/t)))}function mu(e,t,n){let r=t.where!==void 0?` WHERE ${t.where}`:"";return`SELECT Id FROM ${et(e)}${r} ORDER BY ${t.orderBy??me} LIMIT ${Math.max(1,Math.floor(n))}`}function hu(e,t,n){if(e.verdict!=="exceeds")return;let r=hi(n.count,e.estimateMB,e.remainingMB),o=`the ${n.count} ${n.objectApiName} records the query chooses`,i=r>=1?`about ${r} of ${o} fit, each with what its clone copies: a LIMIT of ${r} in the query clones that many \u2014 after ORDER BY ${me}, the newest \u2014, or narrow its WHERE; or leave objects out, or free data storage in ${t}.`:`one of ${o} takes more than that by itself, with what its clone copies: leave objects out, clone less deep, or free data storage in ${t}.`;return{code:"STORAGE_EXCEEDED",message:`The records to write take ${Ne(e)}, and ${t} has ${e.remainingMB} MB left of ${e.maxMB} MB: ${i} ${G}`,storage:{estimateMB:Number(L(e.estimateMB)),remainingMB:e.remainingMB},...Y(n.objectApiName).roots?{roots:{objectApiName:n.objectApiName,...r>=1?{fits:r}:{}}}:{}}}function yi(e){let t=new Set,n=[];for(let r of e){let o=Sn(r);t.has(o)||(t.add(o),n.push(r))}return n.sort(En)}function Rr(e){return gi("sha256").update(yi(e).join(`
|
|
8
|
+
`)).digest("hex")}function yu(e){return mi.test(e)}function wi(e,t){let n=r=>r===void 0?void 0:r.replace(/\s+/g," ").trim();return n(e?.where)===n(t?.where)&&n(e?.orderBy??"Id")===n(t?.orderBy??"Id")&&e?.limit===t?.limit}function wu(e,t){if(e.sourceOrgId!==t.sourceOrgId)return"otherOrg";if(e.objectApiName.toLowerCase()!==t.objectApiName.toLowerCase()||t.query!==void 0&&!wi(e.query,t.query)||t.ids!==void 0&&Rr(t.ids)!==e.sha256)return"otherQuery";if(Rr(e.ids)!==e.sha256)return"changed"}var G="Nothing was written.";function Y(e,t={}){return e!==void 0&&/^[A-Za-z][A-Za-z0-9_]{0,79}$/.test(e)?{roots:{objectApiName:e,...t}}:{}}function bu(e,t){return{code:"ROOTS_QUERY_REFUSED",message:`${Jt(e)}. Nothing was read or written.`,...Y(t)}}function Ru(e,t,n){let r=t?.where!==void 0?` WHERE ${t.where}`:"";return{code:"NO_ROOTS",message:t===void 0?`None of the ${e} records named is in the source org: there is nothing to clone. ${G}`:`The query chooses no ${e} record of the source org: there is nothing to clone. Count what it chooses there with sf data query -q "SELECT COUNT() FROM ${e}${r}", and check its WHERE. ${G}`,...Y(e,{cap:n})}}function Su(e,t,n,r){let o=pe.toLocaleString("en-US"),i=n==="query"&&r?.orderBy!==void 0,s=`${i?"":`ORDER BY ${me} `}LIMIT ${t}`,a=n==="query"?`Give the query ${s}`+(r?.limit!==void 0?` in place of its LIMIT ${r.limit}`:"")+` to clone the first ${t} of its order, narrow its WHERE, or raise --max-roots (the sandforge.forge.maxRoots setting) up to ${o}; past that, copy a sample of the whole org with a filter on its roots.`:`Name ${t} at most, or raise --max-roots up to ${o}.`;return{code:"ROOTS_EXCEEDED",message:`The ${n==="query"?"query chooses":"records named are"} more than the ${t} ${e} records a run clones, and nothing holds ${n==="query"?"it":"them"} to that: refused before anything else was read, rather than cut at an order nobody chose. ${a} ${G}`,...Y(e,{cap:t,...i?{ordered:!0}:{}})}}var bi={otherOrg:"were read of another org than this run reads",otherQuery:"were chosen by another query, of another object, or are other records",changed:"are no longer the ids it was kept with"};function Eu(e,t){return{code:"ROOTS_PLAN_MISMATCH",message:`The records the dry run chose ${bi[t]}: run the dry run again with this query, and give the run the plan it keeps. ${G}`,...Y(e).roots?{roots:{objectApiName:e,plan:t}}:{}}}function Au(e){return{code:"ROOTS_PLAN_GONE",message:`The run this one resumes cloned the records a query chose, and its journal does not name them: reading the query again could choose others. Remove what it wrote, then run the clone again. ${G}`,...Y(e).roots?{roots:{objectApiName:e,plan:"gone"}}:{}}}function Tu(e,t,n){let r=n[n.length-1],o=r?` (${r.objectApiName} came to ${r.rows.toLocaleString("en-US")} after ${n.length} object${n.length===1?"":"s"})`:"";return{code:"READ_BOUND_EXCEEDED",message:`The ${e} roots reach more than ${t.toLocaleString("en-US")} records${o}, and a clone from records holds all it reads before it writes. Take fewer records (a LIMIT), clone less deep (--depth direct), leave objects out, or raise --max-read-total. `+G,readBound:{bound:t,objects:n.slice(0,200).map(i=>({...i})),of:"roots"}}}function Ou(e){let{bound:t,sent:n,next:r,objectApiName:o,sourceRequestsLeft:i}=e,s=i===void 0?"the source would not say what it has left today":`a tenth of the ${i.toLocaleString("en-US")} it has left today`;return{code:"API_BUDGET_EXCEEDED",message:`Reading what the ${e.roots} roots reach would send the source more than ${t.toLocaleString("en-US")} requests (${s}): ${n} sent, ${r} more for ${o}. Take fewer records, clone less deep (--depth direct), or leave objects out. ${G}`,api:{kind:"requests",org:"source",estimate:n+r,remaining:i??t,reading:{bound:t}}}}var mt=class{constructor(t,n){this.given=t;this.store=n}given;store;has(t){return this.given.has(t)||this.store?.mapping(t)?.earlier===!0}retried(t){return this.given.has(t)}get(t){let n=this.given.get(t);if(n!==void 0)return n;let r=this.store?.mapping(t);return r?.earlier?r.targetId:void 0}get from(){return this.given.size===0&&(this.store?.earlierMapped??0)>0?"resume":"retry"}get size(){return this.given.size+(this.store?.earlierMapped??0)}keys(){return this.given.keys()}[Symbol.iterator](){return this.given.entries()}};function q(e){return e!==void 0&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0}function Ar(e){let t=e?.roots,n=e?.rootObjectApiName??t?.objectApiName,r=!!(n&&(e?.rootRecordId||t));return{isScoped:r,dryRun:e?.dryRun??!1,referenceFallback:e?.referenceFallback??(r?"nullify":"keep"),rootRecordId:e?.rootRecordId,rootObjectApiName:n,...t&&n?{roots:{...t,objectApiName:n,cap:Sr(t.cap,Ut),readTotal:Er(t.readTotal)}}:{},recordTypeMappings:e?.recordTypeMappings,maxRecordsPerObject:e?.maxRecordsPerObject,referenceDataObjects:new Set(e?.referenceDataObjects??["BusinessHours","OperatingHours"]),expandOrphanParents:e?.expandOrphanParents??!1,maxOrphanParentExpansions:e?.maxOrphanParentExpansions??20,upsertMode:e?.upsertMode==="auto"?"auto":"off",writeApi:e?.writeApi==="auto"?"auto":"rest",fieldExclusions:e?.fieldExclusions??{},excludedObjects:new Set(e?.excludedObjects??[]),ownerMappings:e?.ownerMappings??{},objectSoqlFilters:e?.objectSoqlFilters,fieldMappings:e?.fieldMappings??{},anonymization:e?.anonymization,keepContactPoints:e?.keepContactPoints===!0,files:e?.files?{maxFileBytes:Math.min(e.files.maxFileBytes>0?e.files.maxFileBytes:10*1048576,35*1048576),acceptedAsIs:e.files.acceptedAsIs===!0}:void 0,writtenBefore:new mt(new Map(Object.entries(e?.writtenBefore??{})),e?.stream?.store),beforeWrite:e?.beforeWrite,stream:e?.stream?{pageSize:q(e.stream.pageSize),ceiling:q(e.stream.ceiling),resumeAfter:e.stream.resumeAfter?new Map(Object.entries(e.stream.resumeAfter)):e.stream.store?.checkpoints()??new Map,onPage:e.stream.onPage,...e.stream.store?{store:e.stream.store}:{},...e.stream.summaryBound!==void 0?{summaryBound:Math.max(0,Math.floor(e.stream.summaryBound))}:{},...q(e.stream.secondPassPageSize)!==void 0?{secondPassPageSize:q(e.stream.secondPassPageSize)}:{},...q(e.stream.writeWindow)!==void 0?{writeWindow:q(e.stream.writeWindow)}:{},...e.stream.everything===!0?{everything:!0}:{},...q(e.stream.wholeReadBound)!==void 0?{wholeReadBound:q(e.stream.wholeReadBound)}:{},...e.stream.sample&&e.stream.everything===!0?{sample:e.stream.sample}:{}}:void 0,decisions:new Oe(e?.decisions),recordTypeDecisions:new Map}}async function Tr(e,t){let{records:n,pages:r}=await gn(e,t);return{records:n,requests:r}}var Ei=25,Mr=15,Ce=5,je=25,yt=60,wt=20,Jn=6+yt+wt+1+6+1+20,ae=4,Ai="SELECT ApiName, Label, TriggerType, RecordTriggerType, TriggerObjectOrEvent.QualifiedApiName, ActiveVersionId, HasAsyncAfterCommitPath FROM FlowDefinitionView WHERE IsActive = true AND TriggerType IN ('RecordBeforeSave', 'RecordAfterSave', 'RecordBeforeDelete')",Ti="SELECT Name, NamespacePrefix, TableEnumOrId, EntityDefinition.QualifiedApiName, UsageBeforeInsert, UsageAfterInsert, UsageBeforeUpdate, UsageAfterUpdate, UsageBeforeDelete, UsageAfterDelete, UsageAfterUndelete FROM ApexTrigger WHERE Status = 'Active'",Oi="SELECT ApiName, Label, TriggerObjectOrEvent.QualifiedApiName, ActiveVersionId FROM FlowDefinitionView WHERE IsActive = true AND ProcessType = 'Workflow'",ki="SELECT Id, Name, NamespacePrefix, TableEnumOrId FROM WorkflowRule",Fi="SELECT Name, SobjectType FROM AssignmentRule WHERE Active = true",$i="SELECT DeveloperName, MasterLabel, SobjectType FROM DuplicateRule WHERE IsActive = true",Pi="SELECT DeveloperName, NamespacePrefix FROM UserSetupEntityAccess WHERE KeyPrefix = '0CP'";function Or(e){return`SELECT Metadata FROM Flow WHERE Id = '${e}'`}function Bi(e,t){if(t.length>Ce)throw new Error(`A Tooling composite holds ${Ce} queries, not ${t.length}`);return{allOrNone:!1,compositeRequest:t.map((n,r)=>({method:"GET",url:`${e}/tooling/query?q=${encodeURIComponent(n)}`,referenceId:`q${r}`}))}}function vi(e,t){if(t.length>je)throw new Error(`A Tooling composite retrieves ${je} records, not ${t.length}`);return{allOrNone:!1,compositeRequest:t.map(({sobject:n,id:r},o)=>{if(!D.test(r))throw new Error(`Not a record id: ${r}`);return{method:"GET",url:`${e}/tooling/sobjects/${n}/${r}`,referenceId:`r${o}`}})}}var xe="PROCESSING_HALTED",Ni=P({compositeResponse:ge(P({body:fe(),httpStatusCode:M(),referenceId:H()}).loose())}),Mi=P({records:ge(Ye(H(),fe()))}).loose(),xi=Ye(H(),fe()),Ci=ge(P({errorCode:H().optional(),message:H().optional()}).loose());function xr(e,t,n,r,o){let i=Ni.safeParse(e);if(!i.success)throw new Error("The org answered the Tooling composite with no composite answer");let s=new Map(i.data.compositeResponse.map(a=>[a.referenceId,a]));return Array.from({length:t},(a,d)=>{let l=s.get(`${n}${d}`);if(!l)return{refused:`The org gave no answer to this ${r} of the composite`};if(l.httpStatusCode<400){let g=o(l.body);return g?{records:g}:{refused:`The org answered with status ${l.httpStatusCode} and no rows`}}let u=Ci.safeParse(l.body),f=u.success?u.data[0]:void 0;return{refused:f?[f.errorCode,f.message].filter(Boolean).join(": "):`status ${l.httpStatusCode}`,...f?.errorCode===xe?{halted:!0}:{}}})}function ji(e,t){return xr(e,t,"q","query",n=>{let r=Mi.safeParse(n);return r.success?r.data.records:void 0})}function _i(e,t){return xr(e,t,"r","retrieve",n=>{let r=xi.safeParse(n);return r.success?[r.data]:void 0})}function Ii(e){return async t=>_i(await e.request({method:"POST",url:"/tooling/composite",body:JSON.stringify(vi(`/services/data/v${e.version}`,t)),headers:{"Content-Type":"application/json"}}),t.length)}function Iu(e){return{query:async(t,n)=>{let r=await e(t);return Tr({query:async o=>r.query(o),queryMore:async o=>r.queryMore(o)},n)},toolingQuery:async(t,n)=>{let r=await e(t);return Tr({query:async o=>r.tooling.query(o),queryMore:async o=>r.tooling.queryMore(o)},n)},toolingQueries:async(t,n)=>{let r=await e(t),o=await r.request({method:"POST",url:"/tooling/composite",body:JSON.stringify(Bi(`/services/data/v${r.version}`,n)),headers:{"Content-Type":"application/json"}});return ji(o,n.length)},toolingRetrieves:async(t,n)=>Ii(await e(t))(n)}}async function Di(e,t,n,r){let o=t.map(u=>({retrieving:r?u.queries.filter(f=>f.retrieve!==void 0):[],waiting:r?u.queries.filter(f=>f.retrieve===void 0):[...u.queries],left:u.requests})),i={retrieving:je,waiting:Ce},s=(u,f)=>{for(let g of o){let p=f.filter(m=>m.queue===g).map(m=>m.query);p.length>0&&g[u].unshift(...p)}},a=(u,f)=>{for(let g of o){let p=f.filter(m=>m.queue===g).map(m=>m.query);p.length===0&&g.retrieving.length===0||(g.reason??=u,g.waiting.unshift(...p,...g.retrieving.splice(0)))}},d=0,l=async()=>{for(;;){let u=o.find(A=>A.left>0&&(A.retrieving.length>0||A.waiting.length>0));if(!u)return;let f=u.retrieving.length>0?"retrieving":"waiting";u.left--,d++;let g=[];for(let A of o){if(A!==u&&A.left<=0)continue;let x=i[f]-g.length;if(x<=0)break;for(let $ of A[f].splice(0,x))g.push({query:$,queue:A})}let p;try{p=r&&f==="retrieving"?await r(g.map(({query:A})=>A.retrieve)):await e(g.map(({query:A})=>A.soql))}catch(A){let x=N(A);if(f==="retrieving")a(x,g);else for(let{query:$}of g)$.refused(x);continue}let m=f==="retrieving"?"retrieve":"query",w=[],b=[],R=0,O,T;if(g.forEach((A,x)=>{let $=p[x]??{refused:`The org gave no answer to this ${m} of the composite`};"records"in $?(A.query.take($.records),R++):$.halted?(w.push(A),O??=$.refused):f==="retrieving"?(b.push(A),T??=$.refused):A.query.refused($.refused)}),f==="retrieving"&&R===0){a(T??O??xe,g);continue}if(b.length>0){for(let{queue:A}of b)A.reason??=T;s("waiting",b)}if(w.length===0)continue;let C=g.length-w.length;if(C===0){for(let{query:A}of w)A.refused(O??xe);continue}i[f]=Math.min(i[f],C);for(let{queue:A}of w)A.reason=O;s(f,w)}};await Promise.all(Array.from({length:Math.max(1,n)},l));for(let u of o)for(let f of[...u.retrieving,...u.waiting])f.refused(u.reason??xe);return d}function Li(e){return`SELECT Metadata FROM WorkflowRule WHERE Id = '${e}'`}function Wi(e){return`SELECT FlowVersionViewId, ApiName, ObjectType FROM FlowVariableView WHERE FlowVersionViewId IN (${e.map(n=>`'${n}'`).join(", ")})`}function Gi(e){return`SELECT DurableId, QualifiedApiName FROM EntityDefinition WHERE QualifiedApiName IN (${e.map(n=>`'${n}'`).join(", ")})`}function qi(e){return`SELECT Id, DeveloperName, NamespacePrefix FROM CustomPermission WHERE DeveloperName IN (${e.map(n=>`'${n}'`).join(", ")})`}function Ui(e){return`SELECT SetupEntityId, ParentId, Parent.Name, Parent.Label, Parent.NamespacePrefix FROM SetupEntityAccess WHERE SetupEntityType = 'CustomPermission' AND SetupEntityId IN (${e.map(n=>`'${n}'`).join(", ")}) AND Parent.IsOwnedByProfile = false AND Parent.PermissionSetGroupId = null`}function Vi(e,t){let n=t.map(r=>`'${r}'`).join(", ");return`SELECT ParentId, COUNT(Id) n FROM ${e} WHERE ParentId IN (${n}) GROUP BY ParentId`}var D=/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/,bt=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,zi="myvariable_current",Qi={RecordBeforeSave:"beforeSave",RecordAfterSave:"afterSave",RecordBeforeDelete:"beforeDelete"},Hi={Create:"create",Update:"update",CreateAndUpdate:"createAndUpdate",Delete:"delete"},Cr={onCreateOnly:"create",onAllChanges:"createAndUpdate",onCreateOrTriggeringUpdate:"createAndUpdate"},Ki=[["UsageBeforeInsert","beforeInsert"],["UsageAfterInsert","afterInsert"],["UsageBeforeUpdate","beforeUpdate"],["UsageAfterUpdate","afterUpdate"],["UsageBeforeDelete","beforeDelete"],["UsageAfterDelete","afterDelete"],["UsageAfterUndelete","afterUndelete"]],Xi={emailAlert:"email",emailSimple:"email",customNotificationAction:"notification",outboundMessage:"outbound"},Yi={emailSimple:"SingleEmail",emailAlert:"DailyWorkflowEmails"},Ji={Alert:"email",OutboundMessage:"outbound"},Zi=new Set(["sms","mms","twilio","whatsapp","vonage","nexmo","messagebird","plivo","sinch"]);function Et(e){if(typeof e!="object"||e===null)return;let t=e.QualifiedApiName;return typeof t=="string"&&t!==""?t:void 0}var h=e=>typeof e=="string"?e:"";function S(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}function v(e){return Array.isArray(e)?e.filter(t=>typeof t=="object"&&t):[]}function At(e,t,n,r){return{apiName:e,label:t||e,timing:n,startsOn:r,condition:"notRead",permissions:[],paths:[],messages:[],switches:[]}}function ea(e){let t=Et(e.TriggerObjectOrEvent),n=Qi[h(e.TriggerType)];if(!t||!n)return;let r=n==="beforeDelete"?"delete":Hi[h(e.RecordTriggerType)]??"createAndUpdate",o=h(e.ActiveVersionId),i=At(h(e.ApiName),h(e.Label),n,r);return e.HasAsyncAfterCommitPath===!0&&(i.paths=[{kind:"async"}]),{objectApiName:t,id:D.test(o)?o:null,flow:i}}function ta(e){let t=h(e.ActiveVersionId);return{objectApiName:Et(e.TriggerObjectOrEvent),id:D.test(t)?t:null,flow:At(h(e.ApiName),h(e.Label),"afterSave","createAndUpdate")}}function na(e){let t=Et(e.EntityDefinition)??(h(e.TableEnumOrId)||void 0),n=h(e.Name);if(!t||!n)return;let r=h(e.NamespacePrefix);return{objectApiName:t,trigger:{name:r?`${r}.${n}`:n,events:Ki.filter(([o])=>e[o]===!0).map(([,o])=>o)}}}function kr(e){return e.startsOn==="create"||e.startsOn==="createAndUpdate"?e.timing==="afterSave"?0:1:e.startsOn==="update"?2:3}function jr(e){let t=new Set(qr(JSON.stringify(e??null)).filter(o=>de(o)==="Permission").map(Rt));if(t.size===0)return[];let n=S(e,"filterFormula"),r=new Set((typeof n=="string"?ue(n):[]).filter(o=>de(o.reference)==="Permission"&&o.value===void 0).map(o=>Rt(o.reference)));return[...t].sort((o,i)=>o.localeCompare(i)).map(o=>({name:o,bypass:r.has(o)}))}function _r(e){return typeof e!="string"?[]:zr(ue(e)).filter(t=>de(t.reference)!=="Permission").map(t=>({...t,where:"start",bypass:!0}))}function ra(e){let t=S(e,"filterFormula");if(typeof t=="string"&&t.trim()!=="")return[...new Set(Ie(t).flatMap(r=>{let o=ia(r);return o?[o]:[]}))];let n=v(S(e,"filters"));return n.length===0||!aa(h(S(e,"filterLogic")),n.length)?[]:[...new Set(n.filter(r=>h(r.operator)==="IsNull"&&S(r.value,"booleanValue")===!1).map(r=>h(r.field)).filter(r=>oa.test(r)))]}var oa=/^[A-Za-z][A-Za-z0-9_]*$/,sa=/^(?:\{!\s*)?\$Record\.([A-Za-z][A-Za-z0-9_]*)\s*\}?$/i;function ia(e){let t=z(e,"NOT");if(t===void 0)return;let n=Ot(t),r=z(n,"ISBLANK")??z(n,"ISNULL");return r===void 0?void 0:sa.exec(r.trim())?.[1]}function aa(e,t){let n=e.trim().toLowerCase();if(n==="and"||t===1&&n!=="or")return!0;if(!/^\d+(\s+and\s+\d+)*$/.test(n))return!1;let r=new Set(n.split(/\s+and\s+/).map(Number));return Array.from({length:t},(o,i)=>i+1).every(o=>r.has(o))}var Ir={permission:"Permission",setup:"Setup",user:"User",profile:"Profile",custommetadata:"CustomMetadata"},Dr=String.raw`[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*`,Lr=new RegExp(String.raw`\$(?:Permission|Setup|User|Profile|CustomMetadata)\.${Dr}`,"gi"),J=String.raw`(?:\{!\s*)?(\$(?:Permission|Setup|User|Profile|CustomMetadata)\.${Dr})\s*\}?`,da=new RegExp(`^${J}$`,"i"),ua=new RegExp(`^NOT\\s+${J}$`,"i"),Wr=new RegExp(`^(?:${J}\\s*(==?|<>|!=)\\s*(TRUE|FALSE)|(TRUE|FALSE)\\s*(==?|<>|!=)\\s*${J})$`,"i"),Fr=String.raw`("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')`,Gr=new RegExp(`^(?:${J}\\s*(==?|<>|!=)\\s*${Fr}|${Fr}\\s*(==?|<>|!=)\\s*${J})$`,"i");function U(e){let t=e.indexOf("."),n=Ir[e.slice(1,t).toLowerCase()];return n?`$${n}${e.slice(t)}`:e}function de(e){return Ir[e.slice(1,e.indexOf(".")).toLowerCase()]}function Rt(e){return e.slice(e.indexOf(".")+1)}function qr(e){return[...new Set([...e.matchAll(Lr)].map(t=>U(t[0])))]}var la=new RegExp(`^${Lr.source}$`,"i");function Ur(e){return typeof e=="string"&&la.test(e)}function _e(e,t){return e.toLowerCase()===t.toLowerCase()}function Vr(e){return e.slice(1,-1).replace(/\\(.)/g,"$1")}function zr(e){let t=new Map;for(let n of e)t.set(`${n.reference.toLowerCase()}=${n.value??""}`,n);return[...t.values()]}function $r(e,t){return e.some(n=>_e(n.reference,t.reference)&&n.value===t.value)}function ue(e){return Ie(e).flatMap(ca)}function Tt(e){return St(e).flatMap(fa)}function ca(e){let t=Wr.exec(e);if(t){let[,o,i,s,a,d,l]=t,u=i??d,f=(s??a).toUpperCase();return(u.startsWith("=")?f==="FALSE":f==="TRUE")?[{reference:U(o??l)}]:[]}let n=Gr.exec(e);if(n){let[,o,i,s,a,d,l]=n;return(i??d).startsWith("=")?[]:[{reference:U(o??l),value:Vr(s??a)}]}let r=z(e,"NOT");if(r===void 0){let o=ua.exec(e);return o?[{reference:U(o[1])}]:[]}return Tt(r)}function fa(e){let t=da.exec(e);if(t)return[{reference:U(t[1])}];let n=Wr.exec(e);if(n){let[,i,s,a,d,l,u]=n,f=s??l,g=(a??d).toUpperCase();return(f.startsWith("=")?g==="TRUE":g==="FALSE")?[{reference:U(i??u)}]:[]}let r=Gr.exec(e);if(r){let[,i,s,a,d,l,u]=r;return(s??l).startsWith("=")?[{reference:U(i??u),value:Vr(a??d)}]:[]}let o=z(e,"NOT");return o===void 0?[]:ue(o)}function Ie(e){let t=Ot(e),n=z(t,"AND");if(n)return De(n,",").flatMap(Ie);let r=De(t,"&&");return r.length>1?r.flatMap(Ie):[t]}function St(e){let t=Ot(e),n=z(t,"OR");if(n)return De(n,",").flatMap(St);let r=De(t,"||");return r.length>1?r.flatMap(St):[t]}function z(e,t){let n=new RegExp(`^${t}\\s*\\(([\\s\\S]*)\\)$`,"i").exec(e);return n&&Qr(n[1])?n[1]:void 0}function Ot(e){let t=e.trim();for(;t.startsWith("(")&&t.endsWith(")")&&Qr(t.slice(1,-1));)t=t.slice(1,-1).trim();return t}function Qr(e){let t=0;for(let{char:n,quoted:r}of Hr(e))if(!r){if(n==="(")t++;else if(n===")"&&--t<0)return!1}return t===0}function De(e,t){let n=[],r=0,o=0;for(let{char:i,index:s,quoted:a}of Hr(e))a||(i==="("?r++:i===")"?r--:r===0&&e.startsWith(t,s)&&(n.push(e.slice(o,s).trim()),o=s+t.length));return n.push(e.slice(o).trim()),n.filter(i=>i!=="")}function*Hr(e){let t=null;for(let n=0;n<e.length;n++){let r=e[n];if(t){r==="\\"?n++:r===t&&(t=null),yield{char:r,index:n,quoted:!0};continue}if(r==='"'||r==="'"){t=r,yield{char:r,index:n,quoted:!0};continue}yield{char:r,index:n,quoted:!1}}}function ga(e){let t=S(e,"start");if(typeof t=="object"&&t!==null){let n=h(S(S(t,"connector"),"targetReference"))||void 0,r=v(S(t,"scheduledPaths")).map(o=>h(S(S(o,"connector"),"targetReference"))||void 0);return{name:n,everyPath:r.every(o=>o===n)}}return{name:h(S(e,"startElementReference"))||void 0,everyPath:!0}}function pa(e,t){let n=e.leftValueReference,r=e.rightValue;if(Ur(n)){let i=U(n);if(typeof S(r,"booleanValue")=="boolean")return[{reference:i}];let s=S(r,"stringValue");return typeof s=="string"?[{reference:i,value:s}]:[]}let o=typeof n=="string"?t.get(n):void 0;return o===void 0?[]:[...Tt(o),...ue(o)]}function ma(e,t){let n=e.leftValueReference,r=typeof n=="string"?t.get(n):void 0;return qr([typeof n=="string"?n:"",h(S(e.rightValue,"elementReference")),r??""].join(" "))}function ha(e,t,n){let{leftValueReference:r,operator:o,rightValue:i}=e;if(o!=="EqualTo"&&o!=="NotEqualTo")return"unknown";let s=o==="EqualTo",a=S(i,"booleanValue");if(Ur(r)){if(!_e(r,t.reference))return"unknown";if(typeof a=="boolean"&&t.value===void 0)return a===s?"true":"false";let u=S(i,"stringValue");return typeof u=="string"&&t.value!==void 0?u===t.value===s?"true":"false":"unknown"}let d=typeof r=="string"?n.get(r):void 0;if(d===void 0||typeof a!="boolean")return"unknown";let l=a===s;return $r(Tt(d),t)?l?"true":"false":$r(ue(d),t)?l?"false":"true":"unknown"}function ya(e,t,n){let r=v(e.conditions);if(r.length===0)return"unknown";let o=r.map(s=>ha(s,t,n)),i=h(e.conditionLogic).toLowerCase()||"and";return i==="and"?o.includes("false")?"false":o.every(s=>s==="true")?"true":"unknown":i==="or"?o.includes("true")?"true":o.every(s=>s==="false")?"false":"unknown":"unknown"}function wa(e,t,n){for(let r of v(e.rules)){let o=ya(r,t,n),i=!h(S(r.connector,"targetReference"));if(o!=="false"){if(o==="true")return i;if(!i)return!1}}return!h(S(e.defaultConnector,"targetReference"))}function Kr(e){let t=v(S(e,"decisions")),n=new Map(v(S(e,"formulas")).filter(f=>typeof f.expression=="string").map(f=>[h(f.name),h(f.expression)])),r=f=>v(f.rules).flatMap(g=>v(g.conditions)),o=[...new Set(t.flatMap(f=>r(f).flatMap(g=>ma(g,n))))];if(o.length===0)return{permissions:[],switches:[]};let{name:i,everyPath:s}=ga(e),a=s?t.find(f=>h(f.name)===i):void 0,d=a?zr(r(a).flatMap(f=>pa(f,n))).filter(f=>wa(a,f,n)):[],l=o.filter(f=>de(f)==="Permission").map(f=>({name:Rt(f),bypass:d.some(g=>_e(g.reference,f)&&g.value===void 0),where:"decision"})).sort((f,g)=>f.name.localeCompare(g.name)),u=o.filter(f=>de(f)!=="Permission").flatMap(f=>{let g=d.filter(p=>_e(p.reference,f));return g.length>0?g.map(p=>({...p,where:"decision",bypass:!0})):[{reference:f,where:"decision",bypass:!1}]}).sort((f,g)=>f.reference.localeCompare(g.reference));return{permissions:l,switches:u}}function ba(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(t=>t!=="").map(t=>t.toLowerCase())}function Ra(...e){return e.some(t=>{let n=ba(t);return n.some(r=>Zi.has(r))||n.some((r,o)=>r==="text"&&/^messages?$/.test(n[o+1]??""))})}function Xr(e){return v(S(e,"actionCalls")).flatMap(t=>{let n=h(t.actionType),r=h(t.label)||h(t.name)||h(t.actionName),o=Xi[n],i=Yi[n];return o?[{kind:o,name:r,...i?{limit:i}:{}}]:n==="apex"&&Ra(h(t.actionName),h(t.name),r)?[{kind:"sms",name:r,guessed:!0}]:[]})}function Sa(e){return v(S(S(e,"start"),"scheduledPaths")).map(t=>{let n=h(t.label)||h(t.name)||void 0;if(h(t.pathType)==="AsyncAfterCommit")return{kind:"async",label:n};let r=Number(t.offsetNumber),o=h(t.timeSource)==="RecordField"?h(t.recordField):"";return{kind:"scheduled",label:n,...Number.isFinite(r)?{offset:r}:{},...h(t.offsetUnit)?{unit:h(t.offsetUnit)}:{},...o?{field:o}:{}}})}function Yr(e,t){let n=Nn(t);n.length>0&&(e.creates=n)}function Ea(e,t){if(typeof t!="object"||t===null)return;let n=S(t,"start"),r=Kr(t);e.permissions=[...jr(n),...r.permissions],e.switches=[..._r(S(n,"filterFormula")),...r.switches];let o=ra(n);o.length>0&&(e.requiresFilled=o),e.paths=Sa(t),e.messages=Xr(t),Yr(e,t)}function Aa(e,t){let n=new Map(v(S(t,"processMetadataValues")).map(o=>[h(o.name),h(S(o.value,"stringValue"))]));e.startsOn=Cr[n.get("TriggerType")??""]??"createAndUpdate";let r=Kr(t);return e.permissions=r.permissions,e.switches=r.switches,e.messages=Xr(t),Yr(e,t),n.get("ObjectType")||void 0}function Ta(e,t){e.startsOn=Cr[h(S(t,"triggerType"))]??"createAndUpdate";let n=S(t,"formula");e.permissions=typeof n=="string"?jr({filterFormula:n}):[],e.switches=_r(n);let r=v(S(t,"workflowTimeTriggers"));return e.paths=r.map(o=>{let i=Number(o.timeLength);return{kind:"scheduled",...Number.isFinite(i)?{offset:i}:{},...h(o.workflowTimeTriggerUnit)?{unit:h(o.workflowTimeTriggerUnit)}:{},...h(o.offsetFromField)?{field:h(o.offsetFromField)}:{}}}),e.messages=[S(t,"actions"),...r.map(o=>o.actions)].flatMap(v).flatMap(o=>{let i=Ji[h(o.type)];return i?[{kind:i,name:h(o.name),...i==="email"?{limit:"DailyWorkflowEmails"}:{}}]:[]}),S(t,"active")===!0}function Jr(e,t){return(e?`${e}__${t}`:t).toLowerCase()}function ht(e,t){let n=un(t);return n===void 0?{part:e,reason:N(t)}:{part:e,reason:`the org could not be reached (${n})`,unreachable:n}}var Pr={flows:0,triggers:1,conditions:2,processes:3,workflowRules:4,definitions:5,assignmentRules:6,duplicateRules:7,userPermissions:8,permissionSets:9};function Oa(e){return[...e].sort((t,n)=>Pr[t.part]-Pr[n.part]||(t.reason<n.reason?-1:t.reason>n.reason?1:0))}async function Me(e,t){let n=new Array(e.length),r=0,o=async()=>{for(;r<e.length;){let i=r++;n[i]=await e[i]()}};return await Promise.all(Array.from({length:Math.min(t,e.length)},o)),n}var Br=[en,An,nn,rn,tn],vr=["ProductCategory","ProductCatalog"];function lt(e,t=new Set){let{referenceDataObjects:n}=Ar(void 0),r=e.nodes.filter(u=>u.included&&!t.has(u.objectApiName)&&!n.has(u.objectApiName)).map(u=>u.objectApiName),o=new Set(r),i=new Set(e.nodes.map(u=>u.objectApiName)),s=Object.entries(Zt).filter(([u,{object:f}])=>o.has(u)&&!i.has(f)&&!t.has(f)).map(([,{object:u}])=>u),a=Tn(e,t),d=u=>e.edges.some(f=>f.required===!0&&u.includes(f.sourceObject)&&a.has(f.sourceObject)&&o.has(f.targetObject)),l=s.length>0||d(Br);return[...new Set([...r,...s,...l?Br.filter(u=>a.has(u)):[],...d(vr)?vr.filter(u=>a.has(u)):[]])]}var Nr=class{deps;constructor(t){this.deps=t}async readForGraph(t,n,r=new Set){return this.read(t,lt(n,r))}async read(t,n,r={}){let o=[],i=0,s=new Map(n.map(c=>[c.toLowerCase(),c])),a=c=>c===void 0?void 0:s.get(c.toLowerCase()),d=(c,y)=>async()=>{try{let E=await y();return i+=E.requests,E.records}catch(E){return i++,o.push(ht(c,E)),[]}},l=c=>()=>this.deps.query(t,c),u=c=>()=>this.deps.toolingQuery(t,c),f=async()=>[],g=n.some(c=>/^(case|lead)$/i.test(c)),[p,m,w,b,R,O]=await Me([d("flows",l(Ai)),d("triggers",u(Ti)),d("processes",l(Oi)),d("workflowRules",u(ki)),g?d("assignmentRules",l(Fi)):f,d("duplicateRules",l($i))],ae),T=p.map(ea).filter(c=>c!==void 0).flatMap(c=>{let y=a(c.objectApiName);return y?[{...c,objectApiName:y}]:[]}),C=m.map(na).filter(c=>c!==void 0).flatMap(c=>{let y=a(c.objectApiName),E=c.trigger.events.some(k=>k!=="afterUndelete"||r.undeletes===!0);return y&&E?[{...c,objectApiName:y}]:[]}),A=w.map(ta),x=A.filter(c=>c.objectApiName===void 0&&c.id!==null).map(c=>c.id),$=n.filter(c=>c.includes("__")&&bt.test(c)),eo=b.some(c=>/^01I/.test(h(c.TableEnumOrId))),[to,no]=await Me([x.length>0?d("processes",l(Wi(x))):f,eo&&$.length>0?d("workflowRules",l(Gi($))):f],ae),ro=new Map(to.filter(c=>h(c.ApiName).toLowerCase()===zi).map(c=>[h(c.FlowVersionViewId),h(c.ObjectType)]));for(let c of A)c.objectApiName===void 0&&c.id!==null&&(c.objectApiName=ro.get(c.id)||void 0);let oo=new Map(no.map(c=>[h(c.DurableId),h(c.QualifiedApiName)])),Le=b.flatMap(c=>{let y=h(c.TableEnumOrId),E=a(oo.get(y)??y),k=h(c.Name),F=h(c.Id);if(!E||!k)return[];let j=h(c.NamespacePrefix),Q=j?`${j}.${k}`:k;return[{objectApiName:E,id:D.test(F)?F:null,flow:At(Q,Q,"afterSave","createAndUpdate")}]}),We=A.filter(c=>c.objectApiName===void 0||a(c.objectApiName)!==void 0),so=new Map(n.map((c,y)=>[c,y])),le=c=>so.get(a(c.objectApiName)??"")??n.length,Ge=T.filter(c=>c.id!==null).sort((c,y)=>kr(c.flow)-kr(y.flow)||le(c)-le(y)||c.flow.label.localeCompare(y.flow.label)),Z=this.deps.toolingQueries,qe=Z?this.deps.toolingRetrieves:void 0,kt=qe?je:Ce,Ft=Z?yt*kt:Ei,$t=Z?wt*kt:Mr,Ue=Ge.slice(0,Ft),Pt=[...We.map(c=>({read:c,kind:"process"})),...Le.map(c=>({read:c,kind:"rule"}))].filter(({read:c})=>c.id!==null).sort((c,y)=>le(c.read)-le(y.read)||(c.kind===y.kind?0:c.kind==="process"?-1:1)||c.read.flow.label.localeCompare(y.read.flow.label)),Bt=Pt.slice(0,$t),Ve,ze,vt=new Set,Nt=c=>c[0]?.Metadata,io=(c,y)=>{c.flow.condition="read",Ea(c.flow,Nt(y))},ao=(c,y)=>{c.flow.condition="unreadable",Ve??=y},uo=({read:c,kind:y})=>y==="process"?Or(c.id):Li(c.id),lo=({read:c,kind:y},E)=>{let k=Nt(E);if(typeof k!="object"||k===null){c.flow.condition="unreadable";return}if(c.flow.condition="read",y==="process"){let F=Aa(c.flow,k);c.objectApiName??=F}else Ta(c.flow,k)||vt.add(c.flow)},co=({read:c},y)=>{c.flow.condition="unreadable",ze??=y},Mt=(c,y,E,k,F)=>c.map(j=>({soql:y(j),retrieve:E(j),take:Q=>k(j,Q),refused:Q=>F(j,Q)})),xt=Mt(Ue,c=>Or(c.id),c=>({sobject:"Flow",id:c.id}),io,ao),Ct=Mt(Bt,uo,({read:c,kind:y})=>({sobject:y==="process"?"Flow":"WorkflowRule",id:c.id}),lo,co);Z?i+=await Di(c=>Z(t,c),[{queries:xt,requests:yt},{queries:Ct,requests:wt}],ae,qe&&(c=>qe(t,c))):await Me([...xt,...Ct].map(c=>async()=>{try{let y=await this.deps.toolingQuery(t,c.soql);i+=y.requests,c.take(y.records)}catch(y){i++,c.refused(N(y))}}),ae),Ve!==void 0&&o.push(ht("conditions",Ve)),ze!==void 0&&o.push(ht("definitions",ze));for(let c of[...T,...We,...Le])c.id===null&&(c.flow.condition="unreadable");let jt=We.flatMap(c=>{let y=a(c.objectApiName);return y?[{...c,objectApiName:y}]:[]}),_t=Le.filter(c=>!vt.has(c.flow)),Qe=[...T,...jt,..._t].flatMap(c=>c.flow.permissions),It;if(Qe.length>0){let[c]=await Me([d("userPermissions",l(Pi))],ae);if(!o.some(y=>y.part==="userPermissions")){let y=new Set(c.map(E=>Jr(h(E.NamespacePrefix),h(E.DeveloperName))));It=y;for(let E of Qe)E.held=y.has(E.name.toLowerCase())}}let Dt=[...new Set(Qe.filter(c=>c.bypass&&c.held!==!0).map(c=>c.name))],He=Dt.length>0?await ka(Dt,c=>d("permissionSets",l(c))(),()=>o.some(c=>c.part==="permissionSets"),async c=>{try{let y=await this.deps.query(t,c);return i+=y.requests,y.records}catch(y){throw i++,y}}):void 0,ce={};if(He?.some(c=>c.permissionSets.length>0)){let{toolingQueries:c,toolingRetrieves:y}=this.deps;try{let{readValidationRuleBypasses:E}=await import("./chunk-TQJ5NPRC.mjs"),k=await E(F=>this.deps.toolingQuery(t,F),n,c&&(F=>c(t,F)),y&&(F=>y(t,F)));i+=k.requests,ce.validationRuleBypasses=k.rules.flatMap(F=>F.permissions.some(j=>It?.has(j.toLowerCase()))?[]:[F]),k.notRead>0&&(ce.validationRulesNotRead=k.notRead)}catch(E){i++,ce.validationRulesUnread=N(E)}}let fo=c=>R.filter(y=>h(y.SobjectType).toLowerCase()===c.toLowerCase()).map(y=>({name:h(y.Name)})).sort((y,E)=>y.name.localeCompare(E.name)),go=c=>O.filter(y=>h(y.SobjectType).toLowerCase()===c.toLowerCase()).map(y=>({name:h(y.MasterLabel)||h(y.DeveloperName),developerName:h(y.DeveloperName)})).sort((y,E)=>y.name.localeCompare(E.name)),po=(c,y)=>c.label.localeCompare(y.label),Ke=(c,y)=>c.filter(E=>E.objectApiName===y).map(E=>E.flow).sort(po),Xe=new Map;for(let c of Ge.slice(Ue.length))Xe.set(c.objectApiName,(Xe.get(c.objectApiName)??0)+1);let Lt=n.flatMap(c=>{let y=Xe.get(c);return y?[{objectApiName:c,flows:y}]:[]}),mo=n.map(c=>({objectApiName:c,flows:Ke(T,c),triggers:C.filter(y=>y.objectApiName===c).map(y=>y.trigger).sort((y,E)=>y.name.localeCompare(E.name)),processes:Ke(jt,c),workflowRules:Ke(_t,c),assignmentRules:fo(c),duplicateRules:go(c)})).filter(c=>c.flows.length>0||c.triggers.length>0||c.processes.length>0||c.workflowRules.length>0||c.assignmentRules.length>0||c.duplicateRules.length>0);return{objectsRead:[...n],objects:mo,unread:Oa(o),conditionsNotRead:Ge.length-Ue.length,conditionsBound:Ft,...Lt.length>0?{conditionsNotReadOn:Lt}:{},definitionsNotRead:Pt.length-Bt.length,definitionsBound:$t,...He?{bypassGrants:He}:{},...ce,requests:i}}};function I(e){return e.slice(0,15)}async function ka(e,t,n,r){let o=e.flatMap(p=>{let m=p.indexOf("__"),w=m>0?p.slice(0,m):"",b=m>0?p.slice(m+2):p;return bt.test(b)&&(!w||bt.test(w))?[{name:p,developerName:b}]:[]});if(o.length===0)return;let i=await t(qi([...new Set(o.map(p=>p.developerName))]));if(n())return;let s=new Map;for(let p of i){let m=h(p.Id);D.test(m)&&s.set(Jr(h(p.NamespacePrefix),h(p.DeveloperName)),m)}let a=o.flatMap(p=>{let m=s.get(p.name.toLowerCase());return m?[m]:[]}),d=a.length>0?await t(Ui(a)):[];if(n())return;let l=[...new Set(d.map(p=>h(p.ParentId)).filter(p=>D.test(p)))],u=new Map;for(let p of["SetupEntityAccess","ObjectPermissions"]){if(l.length===0)break;let m=await t(Vi(p,l));if(n())return;for(let w of m){let b=I(h(w.ParentId)),R=typeof w.n=="number"?w.n:Number(w.n);u.set(b,(u.get(b)??0)+(Number.isFinite(R)?R:0))}}let f=new Map;for(let p of i){let m=h(p.Id);D.test(m)&&f.set(I(m),Zr(h(p.NamespacePrefix),h(p.DeveloperName)))}let g=r&&l.length>0?await Pa(l,f,r):void 0;return o.map(({name:p})=>{let m=s.get(p.toLowerCase()),w=new Map;for(let b of d){if(!m||I(h(b.SetupEntityId))!==I(m))continue;let R=I(h(b.ParentId)),O=b.Parent,T=h(S(O,"Name"));if(!T||w.has(R))continue;let C=h(S(O,"NamespacePrefix"));w.set(R,{name:C?`${C}__${T}`:T,label:h(S(O,"Label"))||T,grants:u.get(R)??0,...g===void 0?{}:"refused"in g?{customPermissionsUnread:g.refused}:{customPermissions:g.bySet.get(R)??[]}})}return{permission:p,permissionSets:[...w.values()].sort((b,R)=>b.grants-R.grants||b.name.localeCompare(R.name))}})}function Zr(e,t){return e?`${e}__${t}`:t}function Fa(e){return`SELECT ParentId, SetupEntityId FROM SetupEntityAccess WHERE SetupEntityType = 'CustomPermission' AND ParentId IN (${e.map(n=>`'${n}'`).join(", ")})`}function $a(e){return`SELECT Id, DeveloperName, NamespacePrefix FROM CustomPermission WHERE Id IN (${e.map(n=>`'${n}'`).join(", ")})`}async function Pa(e,t,n){try{let r=await n(Fa(e)),o=new Map(t),i=[...new Set(r.map(a=>h(a.SetupEntityId)).filter(a=>D.test(a)&&!o.has(I(a))))];if(i.length>0)for(let a of await n($a(i))){let d=h(a.Id);D.test(d)&&o.set(I(d),Zr(h(a.NamespacePrefix),h(a.DeveloperName)))}let s=new Map;for(let a of r){let d=I(h(a.ParentId)),l=o.get(I(h(a.SetupEntityId)));if(!l)continue;let u=s.get(d)??[];u.includes(l)||u.push(l),s.set(d,u)}for(let a of s.values())a.sort((d,l)=>d.localeCompare(l));return{bySet:s}}catch(r){return{refused:N(r)}}}var Ba={insert:"on insert",update:"on update",delete:"on delete"},va={insert:{before:"before save",after:"after save",beforeAndAfter:"before and after save"},update:{before:"before save",after:"after save",beforeAndAfter:"before and after save"},delete:{before:"before delete",after:"after delete",beforeAndAfter:"before and after delete"}},Na={flow:e=>`flow "${e}"`,trigger:e=>`Apex trigger ${e}`,process:e=>`process "${e}"`,workflowRule:e=>`workflow rule "${e}"`},Ma={flows:"the flows",triggers:"the Apex triggers",conditions:"the start conditions of some flows",processes:"the Process Builder processes",workflowRules:"the workflow rules",definitions:"the definitions of some processes or workflow rules",assignmentRules:"the assignment rules",duplicateRules:"the duplicate rules",userPermissions:"the custom permissions of the user the run writes as",permissionSets:"the permission sets that hold a bypass the user the run writes as does not"},xa={email:"email",notification:"custom notification",outbound:"outbound message",sms:"text message"};function Ca(e){let t=e.guessed?" (guessed from the name of an Apex action)":"";return`${xa[e.kind]} "${e.name}"${t}`}function ja(e){let t=e.label?` "${e.label}"`:"";if(e.kind==="async")return`asynchronous path${t}`;if(e.offset===void 0||e.unit===void 0)return`scheduled path${t}`;let n=Math.abs(e.offset),r=n===1?e.unit.replace(/s$/,""):e.unit,o=e.offset<0?"before":"after";return`scheduled path${t} (${n} ${r} ${o} ${e.field??"the save"})`}function _a(e){let t=e.value===void 0?"true":`'${e.value}'`;return e.where==="decision"?`its first decision ends it when ${e.reference} is ${t}`:`not when ${e.reference} is ${t}`}function Ia(e,t){let n=e.flow,r=n?.permissions??[],o=n?.switches??[],i=n?.messages??[],s=n?.paths??[],a=p=>p.held===!0?" (held)":p.held===!1?" (not held)":"",d=r.filter(p=>p.bypass&&p.where!=="decision"),l=r.filter(p=>p.bypass&&p.where==="decision"),u=r.filter(p=>!p.bypass&&p.where!=="decision"),f=[...r.filter(p=>!p.bypass&&p.where==="decision").map(p=>p.name),...o.filter(p=>!p.bypass).map(p=>p.reference)],g=e.kind==="flow"?"start condition":"definition";return[va[t][e.when],...i.length>0?[`SENDS MESSAGES: ${i.map(Ca).join(", ")}`]:[],...s.length>0?[`then after commit: ${s.map(ja).join(", ")}`]:[],...d.length>0?[`not for a user with ${d.map(p=>p.name+a(p)).join(", ")}`]:[],...l.length>0?[`its first decision ends it for a user with ${l.map(p=>p.name+a(p)).join(", ")}`]:[],...o.filter(p=>p.bypass).map(_a),...e.keptQuiet?["quiet for this run"]:[],...u.length>0?[`its start condition names ${u.map(p=>p.name).join(", ")}`]:[],...f.length>0?[`its decisions test ${f.join(", ")}`]:[],...n?.condition==="notRead"?[`${g} not read`]:[],...n?.condition==="unreadable"?[`${g} unreadable`]:[]]}function Du(e,t,n={}){let r=[`target automation: what ${t} runs on the ${e.objectsRead.length} object(s) the run writes`];for(let s of e.objects){r.push(` ${s.objectApiName}`);for(let{write:l,fired:u}of he(s)){let f=u.map(g=>`${Na[g.kind](g.name)} (${Ia(g,l).join("; ")})`);r.push(` ${Ba[l]}: ${f.join(", ")}`)}let a=n.mayApplyAssignmentRules!==!1;for(let l of s.assignmentRules??[])r.push(n.applyAssignmentRules?` assignment rule "${l.name}": applied${a?" (--apply-assignment-rules)":""}: it can give the records it routes another owner, and mail that owner`:` assignment rule "${l.name}": not applied: the run sends Sforce-Auto-Assign: FALSE and keeps the owner it sets${a?" (--apply-assignment-rules applies it)":""}`);let d=s.duplicateRules??[];d.length>0&&r.push(` duplicate rules: ${d.map(l=>`"${l.name}"`).join(", ")}: the run saves a record a rule only alerts on; a rule that blocks still refuses it`)}e.objects.length===0&&r.push(sn(e.unread)?" nothing found in what could be read":" no active flow, process, workflow rule, Apex trigger, assignment rule or duplicate rule runs on them");let o=ye(e),i=on(e).filter(s=>!o.includes(s));if(i.length>0){r.push(` bypass: assign ${i.join(", ")} to the user the run writes as, and the flows whose start condition excludes them stay quiet`+(n.mayMute!==!1?"; --mute-automation assigns them for the run alone, and takes them back as it ends":""));for(let{permission:s,permissionSet:a,others:d}of be(e,i)){if(!a){r.push(` ${s}: no permission set of ${t} holds it: an admin creates one that includes it`);continue}let l=d.length>0?`; also held by ${d.map(f=>f.name).join(", ")}`:"",u=n.username?`: ${Re(a.name,t,n.username)}`:"";r.push(` ${s}: held by permission set ${a.name}, the smallest${l}${u}`)}}if(o.length>0&&r.push(` bypass held: the user the run writes as holds ${o.join(", ")}, and what excludes them stays quiet for this run`),e.conditionsNotRead>0){let s=(e.conditionsNotReadOn??[]).map(({objectApiName:a,flows:d})=>`${a} (${d})`).join(", ");r.push(` ${e.conditionsNotRead} start condition(s) not read: the read takes ${e.conditionsBound} at most`+(s?`; left unread on ${s}`:""))}(e.definitionsNotRead??0)>0&&r.push(` ${e.definitionsNotRead} process or workflow rule definition(s) not read: the read takes ${e.definitionsBound??Mr} at most`);for(let{part:s,reason:a}of e.unread)r.push(` ${Ma[s]} could not be read: ${a}`);return r.push(` read in ${e.requests} request(s) to ${t}`),r}export{Wn as a,nd as b,Gn as c,id as d,ad as e,dd as f,ud as g,ld as h,Wa as i,Ga as j,qa as k,xn as l,Ua as m,Cn as n,To as o,Va as p,Ya as q,Ja as r,In as s,Za as t,ed as u,Sr as v,cu as w,fu as x,gu as y,pu as z,hi as A,mu as B,hu as C,yi as D,Rr as E,yu as F,wu as G,bu as H,Ru as I,Su as J,Eu as K,Au as L,Tu as M,Ou as N,Ar as O,Tr as P,Ei as Q,Mr as R,Ce as S,je as T,yt as U,wt as V,Jn as W,Ai as X,Ti as Y,Oi as Z,ki as _,Fi as $,$i as aa,Pi as ba,Or as ca,Bi as da,vi as ea,ji as fa,_i as ga,Ii as ha,Iu as ia,Di as ja,Li as ka,Wi as la,Gi as ma,qi as na,Ui as oa,Vi as pa,jr as qa,_r as ra,ra as sa,Kr as ta,Xr as ua,Sa as va,Jr as wa,ht as xa,Me as ya,lt as za,Nr as Aa,ka as Ba,Fa as Ca,$a as Da,Du as Ea,Sd as Fa,Ed as Ga,Po as Ha,Ad as Ia,Zn as Ja,it as Ka,jo as La,_o as Ma,Td as Na,Un as Oa,Lo as Pa,Od as Qa,kd as Ra,Fd as Sa,qo as Ta,Uo as Ua,Vn as Va,Vo as Wa,zo as Xa,Ho as Ya,st as Za,ne as _a,Yo as $a,Jo as ab,Pe as bb,Zo as cb,es as db,ts as eb,$d as fb,Be as gb,as as hb,ds as ib,us as jb,cs as kb,fs as lb,gs as mb,ps as nb,ms as ob,hs as pb,ws as qb,bs as rb,Rs as sb,sr as tb,Ss as ub,Ne as vb,Es as wb,As as xb,Ts as yb,Os as zb,Pd as Ab,ks as Bb,ir as Cb,Fs as Db,ar as Eb,dt as Fb,$s as Gb,vs as Hb,Bd as Ib,vd as Jb,Is as Kb,dr as Lb,Ds as Mb,Ls as Nb,Ws as Ob,Gs as Pb,Nd as Qb,qs as Rb,Us as Sb,Md as Tb,xd as Ub,cr as Vb,Cd as Wb,jd as Xb,fr as Yb,_d as Zb,Id as _b,Dd as $b,Js as ac,Ld as bc,Wd as cc,Gd as dc,qd as ec,Ud as fc,L as gc,hr as hc,ei as ic,ti as jc,Vd as kc,ni as lc,zd as mc,Qd as nc,ie as oc,Hd as pc,Kd as qc,V as rc,Xd as sc,Yd as tc,si as uc,Jd as vc,ii as wc,Zd as xc,gt as yc,eu as zc,tu as Ac,nu as Bc,ru as Cc,ou as Dc};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-XKFHTBAB.mjs";import"./chunk-FYWNSMOZ.mjs";import"./chunk-U2CTKIPE.mjs";import"./chunk-NDFFIJL5.mjs";import"./chunk-RVCPQVKM.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-X2XZQ434.mjs";import"./chunk-4X5D3MSV.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-IXIY6Q4M.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-EOQON3E5.mjs";import"./chunk-Y7YUNRKK.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-N2HYG3BL.mjs";import"./chunk-MJD6CPZZ.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-WXU6ZJIV.mjs";import"./chunk-R3OM3X4L.mjs";import"./chunk-77IVKH7R.mjs";import"./chunk-2WMKJVD2.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-VXZ5PTOM.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-ZOSESZ22.mjs";import"./chunk-ZXOUWHYE.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-Z3MGN42K.mjs";import"./chunk-2GSMHGIV.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ISOSTAJR.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-7BQMBXKX.mjs";import"./chunk-KWAVSZ2B.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{h as REWIND_MUTING_STEP_WORDS,g as REWIND_STEP_WORDS,i as acceptanceRefusal,j as boundsRefusal,k as boundsRefusals,e as firedCount,m as notConfirmedRefusal,a as objectsWrittenBy,b as previewTotals,f as remakeUnasked,d as rewindStepsOf,c as selectionDiff,l as undeletableUnattendedRefusal};
|
|
@@ -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{c as A}from"./chunk-66NMFCWX.mjs";import{a as D}from"./chunk-
|
|
7
|
+
import{c as A}from"./chunk-66NMFCWX.mjs";import{a as D}from"./chunk-EOQON3E5.mjs";import{g as R}from"./chunk-Z3MGN42K.mjs";import{c as x,q as g,r as h,t as P,u as k}from"./chunk-2GSMHGIV.mjs";import{id as O}from"./chunk-6QSHWIZI.mjs";import{b as d,f as l,k as m,l as b}from"./chunk-WZQEK4WT.mjs";var j=[{child:"Entitlement",field:"AccountId",parent:"Account",refused:"always"},{child:"Order",field:"AccountId",parent:"Account",refused:"pastDraft"},{child:"Opportunity",field:"AccountId",parent:"Account",refused:"closedWon",rows:{field:"IsWon",value:!0}}];function C(e,n,t){let[s,r,a]=[e,n,t??""].map(i=>i.toLowerCase());return j.some(i=>i.refused==="always"&&i.child.toLowerCase()===s&&i.field.toLowerCase()===r&&(t===void 0||i.parent.toLowerCase()===a))}var W=b({name:d(),type:d(),createable:l().optional(),updateable:l().optional(),nillable:l().optional(),calculated:l().optional(),autoNumber:l().optional(),permissionable:l().optional(),encrypted:l().optional(),referenceTo:m(d()).nullish()}).loose(),oe=b({name:d(),undeletable:l().optional(),fields:m(W),childRelationships:m(b({childSObject:d(),field:d(),cascadeDelete:l().optional(),restrictedDelete:l().optional()}).loose()).nullish()}).loose(),F=["Id","SystemModstamp","CreatedDate","CreatedById","LastModifiedDate","LastModifiedById"],S="IsPersonAccount",M="Event",I=["LatestPublishedVersionId","ContentSize"],_=["ParentId","ContentAssetId","IsArchived"],v="VersionData";function N(e){return e.toLowerCase()===R.toLowerCase()}function B(e){return new Set(N(e)?I.map(n=>n.toLowerCase()):[])}function U(e){return e===x||e===M?"scanAllLive":"query"}function V(e){let n={name:e.name,label:e.name,labelPlural:e.name,keyPrefix:null,custom:!1,createable:!0,updateable:!0,deletable:!0,queryable:!0,fields:e.fields.map(t=>({name:t.name,label:t.name,type:t.type,length:0,nillable:t.nillable===!0,createable:t.createable===!0,updateable:t.updateable===!0,externalId:!1,referenceTo:t.referenceTo??[],relationshipName:null,picklistValues:[],defaultValue:null,calculated:t.calculated===!0,autoNumber:t.autoNumber===!0,unique:!1,...t.permissionable===void 0?{}:{permissionable:t.permissionable}})),recordTypeInfos:[],childRelationships:[]};return new A(async()=>n)}function G(e){return e.type==="address"||e.type==="location"}function y(e){return new Map(e.fields.map(n=>[n.name.toLowerCase(),n]))}async function K(e,n){let t=y(e),s=F.filter(o=>t.has(o.toLowerCase())),r=t.get(S.toLowerCase());r&&(e.name===g||e.name===h)&&s.push(r.name);let a=N(e.name);if(a)for(let o of I){let c=t.get(o.toLowerCase());c&&s.push(c.name)}let i=new Set(a?_.map(o=>o.toLowerCase()):[]),p=new Set(s.map(o=>o.toLowerCase())),f=e.fields.map(o=>o.name).filter(o=>!p.has(o.toLowerCase())&&!i.has(o.toLowerCase())),{writable:L,skipped:z,denied:T}=await V(e).partitionWritableFields(e.name,"upsert",f),w=[],u=new Map;for(let o of T)u.set(o,"fls");for(let o of z){let c=t.get(o.toLowerCase());c&&G(c)&&u.set(o,"compound")}let E=new Set(L);for(let o of L){let c=t.get(o.toLowerCase())?.type;c==="base64"?u.set(o,"base64"):c===D&&!n.viewsEncryptedData&&u.set(o,"encrypted")}for(let o of f){let c=u.get(o);c!==void 0?w.push({field:o,reason:c}):E.has(o)&&s.push(o)}return a&&w.push({field:v,reason:"base64"}),{fields:s,leftOutFields:w}}function q(e,n){let t=y(e),s=e.name.toLowerCase(),r=new Set;for(let a of n)for(let i of a.childRelationships??[]){if(i.cascadeDelete!==!0||i.childSObject.toLowerCase()!==s||C(e.name,i.field,a.name))continue;let p=t.get(i.field.toLowerCase());p&&r.add(p.name)}return[...r].sort()}function Y(e,n){let t=y(e),s=e.name.toLowerCase(),r=new Set;for(let a of n)for(let i of a.childRelationships??[]){if(!(i.restrictedDelete===!0&&i.cascadeDelete!==!0||C(e.name,i.field,a.name))||i.childSObject.toLowerCase()!==s)continue;let f=t.get(i.field.toLowerCase());f&&r.add(f.name)}return[...r].sort()}function re(e){let n=e.cascadeParents.filter(t=>C(e.objectApiName,t));return n.length===0?e:{...e,cascadeParents:e.cascadeParents.filter(t=>!n.includes(t)),restrictParents:[...new Set([...e.restrictParents??[],...n])].sort()}}async function se(e,n,t){return{objectApiName:e.name,readMode:U(e.name),undeletable:e.undeletable===!0,cascadeParents:q(e,n),restrictParents:Y(e,n),...await K(e,t)}}function H(e,n){let t=e.toLowerCase(),s=new Set;for(let r of n){let a=r.indexOf(".");a<=0||a===r.length-1||r.slice(0,a).toLowerCase()===t&&s.add(r.slice(a+1).toLowerCase())}return s}function J(e,n){let t=n.toLowerCase();return t!==S.toLowerCase()&&!F.some(s=>s.toLowerCase()===t)&&!B(e).has(t)}function ae(e,n,t){let s=H(e,t);return n.filter(r=>J(e,r)&&!s.has(r.toLowerCase()))}function ie(e,n){return e===h&&P(n)}function ce(e,n,t){let s=e===g?k(n,!1):void 0,r={};typeof n.Id=="string"&&(r.Id=n.Id);for(let a of t)a in n&&(s!==void 0&&O(g,a,s)||(r[a]=n[a]));return r}export{j as a,C as b,W as c,oe as d,F as e,S as f,I as g,U as h,re as i,se as j,H as k,ae as l,ie as m,ce as n};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b}from"./chunk-
|
|
7
|
+
import{a,b}from"./chunk-OTJH6AEA.mjs";import"./chunk-FVLFO2S6.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as ScenarioCompileError,b as compileScenario};
|
|
@@ -0,0 +1,8 @@
|
|
|
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{k as f}from"./chunk-N2HYG3BL.mjs";import{Ua as l}from"./chunk-6QSHWIZI.mjs";import{b as c,k as h,m,v,z as A}from"./chunk-WZQEK4WT.mjs";import{randomBytes as S}from"node:crypto";import{mkdir as k,open as O,readFile as E,readdir as $,rename as D,rm as F}from"node:fs/promises";import{join as u,resolve as N}from"node:path";var T=448,b=384,_=1e4,I=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$/,J=/^\d{8}T\d{9}Z-00D[A-Za-z0-9]{15}\.json$/,y=A.datetime({offset:!0}),j=m({name:c().min(1).max(255),type:c().min(1).max(80),cronExpression:c().min(1).max(255).optional(),state:c().min(1).max(40),nextFireTime:y.optional(),previousFireTime:y.optional(),owner:c().min(1).max(255).optional()}),x=m({version:v(1),savedAt:y,organizationId:l,host:c().regex(I),jobs:h(j).max(_)});function z(e){return u(N(e),"audits")}function w(e){let n=e.trim().toLowerCase().replace(/\.$/,"");return I.test(n)?n:void 0}function K(e,n){let r=w(n);if(r===void 0)throw new Error(`Not a host name: "${n}"`);return u(z(e),r)}function R(e){return`${new Date(e.savedAt).toISOString().replace(/[-:.]/g,"")}-${f(e.organizationId)}.json`}async function Z(e,n){let r=x.parse(n),i=K(e,r.host);await k(i,{recursive:!0,mode:T});let s=u(i,R(r)),a=`${s}.${process.pid}-${S(4).toString("hex")}.tmp`,d=await O(a,"wx",b);try{try{await d.writeFile(`${JSON.stringify(r,null,2)}
|
|
8
|
+
`,"utf8"),await d.sync()}finally{await d.close()}await D(a,s)}catch(t){throw await F(a,{force:!0}),t}return s}async function C(e,n){let r=w(n);if(r===void 0)return{kept:[],setAside:[],unread:`${n} is not a host name`};let i=u(z(e),r),s;try{s=(await $(i,{withFileTypes:!0})).filter(t=>t.isFile()&&t.name.endsWith(".json")).map(t=>t.name).sort()}catch(t){let o=t?.code;return o==="ENOENT"||o==="ENOTDIR"?{kept:[],setAside:[]}:{kept:[],setAside:[],unread:`${i} could not be read: ${t instanceof Error?t.message:String(t)}`}}let a=[],d=[];for(let t of s){let o=u(i,t);if(!J.test(t)){d.push({path:o,why:"its name is not one --save gives"});continue}let g;try{g=JSON.parse(await E(o,"utf8"))}catch{d.push({path:o,why:"it does not read as JSON"});continue}let p=x.safeParse(g);if(!p.success){d.push({path:o,why:"it does not read as an inventory of this SandForge"});continue}if(p.data.host!==r){d.push({path:o,why:`it is of ${p.data.host}, not of the host its folder names`});continue}a.push({inventory:p.data,path:o})}return a.sort((t,o)=>Date.parse(o.inventory.savedAt)-Date.parse(t.inventory.savedAt)),{kept:a,setAside:d}}function V(e,n){let r=f(n),i=e.find(a=>f(a.inventory.organizationId)!==r);if(i!==void 0)return{kept:i,refreshed:!0};let s=e[0];return s!==void 0?{kept:s,refreshed:!1}:void 0}export{Z as a,C as b,V as c};
|
|
@@ -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{c as N,e as C,f as F}from"./chunk-
|
|
7
|
+
import{c as N,e as C,f as F}from"./chunk-Y7YUNRKK.mjs";import{d as I,z as P}from"./chunk-N2HYG3BL.mjs";import{b as O}from"./chunk-TQ2TQHTT.mjs";import{ma as $,ta as _}from"./chunk-6QSHWIZI.mjs";import{b as u,e as m,f as M,h as R,k as l,l as i,o as A,s as k,u as z,v as S,z as E}from"./chunk-WZQEK4WT.mjs";import{createHash as K,randomBytes as q}from"node:crypto";import{createReadStream as re}from"node:fs";import{chmod as ne,copyFile as oe,open as ae,readFile as G,readdir as H,rename as j,rm as w,stat as U}from"node:fs/promises";import{join as h}from"node:path";var X=1440*6e4,se="forge-samples",Q="forge-runs",B="sample.json",W="the run of this sample",ie=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,V=/^[A-Za-z0-9_-]{1,128}$/,f=class extends Error{constructor(e,r){super(r);this.refusal=e;this.name="SamplePlanError"}refusal};function x(n){return h(n,se)}function ce(n,t){if(!V.test(t))throw new f("otherSetup","Not the fingerprint of a setup of a run.");return h(x(n),t)}function v(n,t){return h(n,Q,`${t.replace(/[^A-Za-z0-9_-]/g,"_")}.sample`)}var p=u().regex(/^[A-Za-z][A-Za-z0-9_]*$/),s=m().int().nonnegative(),le=i({window:i({field:z(["CreatedDate","LastModifiedDate"]),from:u().optional(),to:u().optional(),lastDays:m().int().positive().optional()}).optional(),notWindowed:l(p).optional(),where:l(i({objectApiName:p,where:u()})).optional(),strata:l(i({objectApiName:p,field:u(),values:l(i({value:A([u(),M(),R()]),label:u().optional(),roots:s,kept:s})),more:s.optional()})).optional()}),pe=i({seed:m().int().min(0),draw:$,floor:s,parents:_,children:A([S("all"),m().int().min(1)]),share:m().min(0).max(1),budget:i({bytes:m().nonnegative(),remainingMB:m().optional(),maxMB:m().optional(),share:m().optional(),roundingMB:m().optional(),automationMB:m().optional(),withinMB:m().optional(),maxTotal:m().optional(),limitedBy:z(["storage","within","maxTotal","targetRequests","bulkBatches","sourceRequests","heavyRoots","whole","draw"])}),rows:s,storageBytes:m().nonnegative(),objects:l(i({objectApiName:p,sourceRows:s,kept:s,roots:s,below:s,asParents:s,whole:S(!0).optional(),childrenCut:l(i({field:u(),rows:s})).optional(),rootsInTheSource:s.optional(),rootsInTheDraw:s.optional()})),whole:l(i({objectApiName:p,why:z(["referenceData","catalog","smallParent","asked"])})),heavyRoots:l(i({objectApiName:p,id:u().regex(ie),rows:s,relation:i({objectApiName:p,field:u()})})),dropped:l(i({objectApiName:p,rows:s,reason:z(["noParentInSource","outsideFilter","excludedObject","withoutParent","heldBack","recordTypeNotInTarget"])})),leftEmpty:l(i({objectApiName:p,field:u(),rows:s})),noRecordDrawn:l(i({objectApiName:p,sourceRows:s,noRootInTheDraw:S(!0).optional()})),roots:le.optional(),partialMasters:l(i({objectApiName:p,details:p,field:u(),kept:s.optional(),sourceRows:s.optional(),asParents:s.optional()})).optional(),planRequests:i({source:s}),newestByIds:l(p).optional(),oldestByIds:l(p).optional()}),ue=i({personAccounts:k(p,s),byThePlatform:l(i({objectApiName:p,inPlan:s,beyond:s}))}),T=i({version:S(1),sourceOrgId:u().min(1),fingerprint:u().regex(V),drawnAt:E.datetime(),drawnBy:z(["run","dryRun"]),sha256:u().regex(/^[0-9a-f]{64}$/),objects:l(i({objectApiName:p,count:m().int().positive(),sha256:u().regex(/^[0-9a-f]{64}$/)})),sample:pe,newestByIds:l(p).optional(),oldestByIds:l(p).optional(),counts:ue.optional()});async function Z(n){let t=K("sha256");for await(let e of re(n))t.update(e);return t.digest("hex")}function L(n){let t=K("sha256"),e=[...n].sort((r,o)=>r.objectApiName<o.objectApiName?-1:r.objectApiName>o.objectApiName?1:0);for(let{objectApiName:r,count:o,sha256:a}of e)t.update(`${r} ${o} ${a}
|
|
8
8
|
`);return t.digest("hex")}async function me(n,t){let e=await ae(n,"wx",I);try{await e.writeFile(t,"utf8"),await e.sync()}finally{await e.close()}}function D(n){let t=n?.code;return t==="ENOENT"||t==="ENOTDIR"}var y=class n{constructor(t,e,r){this.dir=t;this.manifest=e;this.spool=r}dir;manifest;spool;get sha256(){return this.manifest.sha256}get count(){return this.spool.count}countOf(t){return this.manifest.objects.find(e=>e.objectApiName===t)?.count??0}ageMs(t){return t.getTime()-Date.parse(this.manifest.drawnAt)}get place(){return{path:this.dir,sha256:this.manifest.sha256,drawnAt:this.manifest.drawnAt,drawnBy:this.manifest.drawnBy}}async*ids(t,e={}){let r=Math.max(1,Math.floor(e.size??2e3)),o=e.after,a=[];for await(let c of this.spool.pages(t,r))for(let d of c)o!==void 0&&O(d,o)<=0||(a.push(d),a.length>=r&&(yield a,a=[]));a.length>0&&(yield a)}static async open(t,e={}){let r;try{r=JSON.parse(await G(h(t,B),"utf8"))}catch(d){throw D(d)?new f("gone","The plan of this sample is no longer on this machine."):new f("changed","The plan of this sample does not read as one.")}let o=T.safeParse(r);if(!o.success)throw new f("changed","The plan of this sample does not read as one.");let a=o.data,c;try{c=await F.open(t,W)}catch{throw new f("changed","The ids of this sample are not as they were written.")}if(await n.holdToManifest(t,a,c),e.sourceOrgId!==void 0&&e.sourceOrgId!==a.sourceOrgId)throw new f("otherOrg","This plan was drawn of another org.");if(e.fingerprint!==void 0&&e.fingerprint!==a.fingerprint)throw new f("otherSetup","This plan was drawn for another setup of the run.");if(e.sha256!==void 0&&e.sha256!==a.sha256)throw new f("otherSha","This is not the plan the run was drawn with.");return new n(t,a,c)}static async holdToManifest(t,e,r){let o=()=>new f("changed","The ids of this sample are not as they were written."),a=r.objects.filter(c=>c.count>0);if(a.length!==e.objects.length)throw o();for(let c of e.objects){let d=a.find(b=>b.objectApiName===c.objectApiName);if(!d||d.count!==c.count)throw o();let g;try{g=await Z(N(t,c.objectApiName))}catch{throw o()}if(g!==c.sha256)throw o()}if(L(e.objects)!==e.sha256)throw o()}static async keep(t,e){let r=`${t}.${process.pid}-${q(4).toString("hex")}.tmp`;try{await P(r);let o=new C(r,W);for(let{objectApiName:g,ids:b}of e.ids){let ee=[...b].sort(O);for(let te of ee)await o.add(g,te)}let a=await o.finish(),c=[];for(let{objectApiName:g,count:b}of a.objects)b!==0&&c.push({objectApiName:g,count:b,sha256:await Z(N(r,g))});let d={version:1,sourceOrgId:e.sourceOrgId,fingerprint:e.fingerprint,drawnAt:e.drawnAt.toISOString(),drawnBy:e.drawnBy,sha256:L(c),objects:c,sample:e.sample,...e.newestByIds!==void 0&&e.newestByIds.length>0?{newestByIds:[...e.newestByIds]}:{},...e.oldestByIds!==void 0&&e.oldestByIds.length>0?{oldestByIds:[...e.oldestByIds]}:{},...e.counts?{counts:e.counts}:{}};T.parse(d),await me(h(r,B),`${JSON.stringify(d)}
|
|
9
9
|
`),await w(t,{recursive:!0,force:!0}),await j(r,t)}catch(o){throw await w(r,{recursive:!0,force:!0}),o}return n.open(t)}};function Pe(n,t){return y.keep(n,t)}async function je(n,t,e){let r;try{r=await y.open(ce(n,t),{fingerprint:t})}catch(o){if(o instanceof f)return;throw o}return r.ageMs(e)>=X?"tooOld":r}async function Ae(n,t,e){let r=v(t,e);return await P(h(t,Q)),await w(r,{recursive:!0,force:!0}),await j(n.dir,r),y.open(r,{sha256:n.sha256})}async function Ie(n,t,e){let r=v(n,t);return!await J(r)||await J(e)?!1:(await P(x(n)),await j(r,e),!0)}async function Ne(n,t,e){let r=v(t,e);return await Y(n.dir,r),y.open(r,{sha256:n.sha256})}async function Oe(n,t,e){let r=await y.open(n,{sha256:e});await Y(r.dir,t);try{return await y.open(t,{sha256:e})}catch(o){throw await w(t,{recursive:!0,force:!0}),o}}async function Y(n,t){let e=`${t}.${process.pid}-${q(4).toString("hex")}.tmp`;try{await P(e);for(let r of await H(n))await oe(h(n,r),h(e,r)),await ne(h(e,r),I);await w(t,{recursive:!0,force:!0}),await j(e,t)}catch(r){throw await w(e,{recursive:!0,force:!0}),r}}async function J(n){try{return await U(n),!0}catch(t){if(D(t))return!1;throw t}}async function Be(n){await w(n,{recursive:!0,force:!0})}async function Te(n,t){let e=x(n),r;try{r=await H(e)}catch(a){if(D(a))return 0;throw a}let o=0;for(let a of r){let c=h(e,a),d;try{let g=T.parse(JSON.parse(await G(h(c,B),"utf8")));d=Date.parse(g.drawnAt)}catch{d=(await U(c)).mtimeMs}t.getTime()-d<X||(await w(c,{recursive:!0,force:!0}),o++)}return o}export{X as a,f as b,ce as c,v as d,y as e,Pe as f,je as g,Ae as h,Ie as i,Ne as j,Oe as k,Be as l,Te as m};
|
|
@@ -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}from"./chunk-
|
|
7
|
+
import{a}from"./chunk-NNV7IGM7.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as ReferenceLinker};
|
|
@@ -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-77MZRBWX.mjs";import"./chunk-BT43WSOS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-6QSHWIZI.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};
|
|
@@ -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 ee}from"./chunk-TZE3Y7IQ.mjs";import{b as le}from"./chunk-CA5NAXSU.mjs";import{mb as $,vc as Y}from"./chunk-6QSHWIZI.mjs";var se=200;function j(e,s){let a=[];for(let n=0;n<e.length;n+=s)a.push(e.slice(n,n+s));return a}function ne(e){return`'${ee(e)}'`}function H(e){return`(${e.map(ne).join(", ")})`}function me(e){return`'${ee(e).replace(/[%_]/g,a=>`\\${a}`)}.%'`}function Fe(e,s){let a=new Set(s.map(n=>n.toLowerCase()));return e.replace(/[^\s@<>()[\]"',;:]+@[^\s@<>()[\]"',;:]+/g,n=>a.has(n.toLowerCase())?n:"<address>")}function Se(e){let s=e;return typeof s?.errorCode=="string"&&s.errorCode!==""?s.errorCode:typeof s?.name=="string"&&/^[A-Z][A-Z_]+$/.test(s.name)?s.name:"REQUEST_FAILED"}function we(e,s){let a={code:Se(e),message:le(e),fields:[]};return Array.from({length:s},()=>({success:!1,errors:[a]}))}function Ie(e){let s=e;if(s==null)return{success:!1,errors:[{code:"NO_ANSWER",message:"the org answered nothing for it",fields:[]}]};let a=(s.errors??[]).map(d=>({code:typeof d.statusCode=="string"?d.statusCode:typeof d.errorCode=="string"?d.errorCode:"UNKNOWN_ERROR",message:typeof d.message=="string"?d.message:"the org gave no words",fields:Array.isArray(d.fields)?d.fields.filter(c=>typeof c=="string"):[]})),n=s.success===!0;return{...typeof s.id=="string"?{id:s.id}:{},success:n,errors:n||a.length>0?a:[{code:"UNKNOWN_ERROR",message:"the org refused it",fields:[]}]}}function Re(e,s){let a=Array.isArray(e)?e:[e];return Array.from({length:s},(n,d)=>Ie(a[d]))}function Me(e){let s=0,a=async(n,d)=>{let c=[];for(let i of j(n,se)){s+=1;try{c.push(...Re(await d(i),i.length))}catch(U){c.push(...we(U,i.length))}}return c};return{identity:async()=>{s+=1;let n=await e.identity();return{userId:n.user_id,organizationId:n.organization_id,username:n.username}},query:async n=>{s+=1;let d=await e.query(n),c=[...d.records];for(;!d.done&&d.nextRecordsUrl;)s+=1,d=await e.queryMore(d.nextRecordsUrl),c.push(...d.records);return c},update:(n,d)=>a(d,c=>e.sobject(n).update(c,{allOrNone:!1,headers:Y()})),create:(n,d)=>a(d,c=>e.sobject(n).create(c,{allOrNone:!1,headers:Y()})),destroy:(n,d)=>a(d,c=>e.sobject(n).destroy(c,{allOrNone:!1})),requests:()=>s}}var ye=72,Pe=50,Ae=20,Ee=200,Ne=100,fe=".invalid";function Q(e){let s=e.length-fe.length;if(!(s<=0||e.slice(s).toLowerCase()!==fe))return e.slice(0,s)}function E(e){return e.slice(0,15)}function x(e){return typeof e=="string"&&e!==""?e:void 0}var te="Id, Username, Email, IsActive, ProfileId, Profile.Name, Profile.UserLicenseId";function oe(e){let s=e.Profile??void 0,a=x(s?.UserLicenseId);return{id:String(e.Id),username:String(e.Username),isActive:e.IsActive===!0,profileId:String(e.ProfileId),profileName:x(s?.Name)??String(e.ProfileId),...a?{licenseId:a}:{},email:x(e.Email)??""}}function pe(e){let s=e.indexOf("__");return s>0&&!e.slice(s+2).includes("__")?{namespace:e.slice(0,s),own:e.slice(s+2)}:{own:e}}function D(e,s){return s?`${s}__${e}`:e}async function Oe(e,s){let a=new Map,n=[...new Map(s.map(i=>[$(i),i])).values()];for(let i of j(n,Pe)){let U=await e.query(`SELECT ${te} FROM User WHERE Username IN ${H(i)}`);for(let l of U){let u=oe(l);a.set($(u.username),u)}}let d=n.filter(i=>!a.has($(i))),c=new Map;for(let i of j(d,Ae)){let U=i.map(u=>`Username LIKE ${me(u)}`).join(" OR "),l=(await e.query(`SELECT ${te} FROM User WHERE ${U}`)).map(oe);for(let u of i){let S=`${$(u)}.`,N=[...new Map(l.filter(w=>$(w.username).startsWith(S)).map(w=>[w.id,w])).values()];c.set($(u),N)}}return s.map(i=>{let U=a.get($(i));if(U)return{given:i,kind:"found",user:U};let l=c.get($(i))??[];return l.length===1?{given:i,kind:"found",user:l[0]}:l.length===0?{given:i,kind:"none"}:{given:i,kind:"two",usernames:l.map(u=>u.username).sort((u,S)=>u<S?-1:u>S?1:0)}})}async function K(e,s,a,n,d,c=""){let i=[];for(let U of j([...new Set(d)],Ee))i.push(...await e.query(`SELECT ${s} FROM ${a} WHERE ${n} IN ${H(U)}${c}`));return i}async function re(e,s,a,n,d,c=""){let i=[];for(let U of j([...new Set(d)],Ne))i.push(...await e.query(`SELECT ${s} FROM ${a} WHERE ${n} IN ${H(U)}${c}`));return i}async function ve(e){try{let[s]=await e.query("SELECT PermissionsManageUsers FROM UserPermissionAccess"),a=s?.PermissionsManageUsers;return typeof a=="boolean"?a:void 0}catch{return}}function ie(e,s){let a=new Set(s.map(n=>n.toLowerCase()));return e.filter(n=>!a.has(n.toLowerCase()))}async function be(e,s,a){if(s.length===0)return[];let n=new Date(a.getTime()-ye*36e5).toISOString().replace(/\.\d{3}Z$/,"Z"),d;try{d=await e.query(`SELECT Display, CreatedDate FROM SetupAuditTrail WHERE Action = ${ne("useremailchangesent")} AND CreatedDate >= ${n}`)}catch{return[]}let c=d.map(i=>(x(i.Display)??"").trim().toLowerCase());return s.filter(i=>{let U=Q(i.email)?.toLowerCase();if(U===void 0)return!1;let l=`[${E(i.id).toLowerCase()}]`;return c.some(u=>u.includes(l)&&u.endsWith(` ${U}`))}).map(i=>E(i.id))}async function ze(e,s,a){let n=e.requests(),d=await e.identity(),c=await ve(e),i=await Oe(e,s.map(o=>o.username)),U=i.flatMap(o=>o.kind==="found"?[o.user]:[]),l=new Set(U.map(o=>E(o.id))),u=a.previous?.users??[],S=u.map(o=>o.applied.userId).filter(o=>!l.has(E(o))),N=(await K(e,te,"User","Id",S)).map(oe),w=[...U,...N].map(o=>o.id),P=o=>[...new Map(s.flatMap(h=>o(h)??[]).map(h=>[h.toLowerCase(),h])).values()],_=P(o=>o.permissionSets),M=P(o=>o.permissionSetGroups),G=P(o=>o.groups),b=u.length>0,J=s.some(o=>o.frozen!==void 0)||b?(await K(e,"Id, UserId, IsFrozen","UserLogin","UserId",w)).map(o=>({id:String(o.Id),userId:String(o.UserId),isFrozen:o.IsFrozen===!0})):[],r=s.some(o=>o.profile!==void 0)||b?(await e.query("SELECT Id, Name, UserLicenseId FROM Profile")).map(o=>{let h=x(o.UserLicenseId);return{id:String(o.Id),name:String(o.Name),...h?{licenseId:h}:{}}}):void 0,f={},g=[];if(_.length>0){let o=await re(e,"Id, Name, NamespacePrefix, LicenseId","PermissionSet","Name",_.map(t=>pe(t).own)," AND IsOwnedByProfile = false");for(let t of o){let R=x(t.NamespacePrefix),I=x(t.LicenseId);g.push({id:String(t.Id),name:String(t.Name),...R?{namespace:R}:{},...I?{licenseId:I}:{}})}let h=g.map(t=>D(t.name,t.namespace));ie(_,h).length>0&&(f.permissionSets=(await e.query("SELECT Name, NamespacePrefix FROM PermissionSet WHERE IsOwnedByProfile = false")).map(t=>D(String(t.Name),x(t.NamespacePrefix))))}let m=[];if(M.length>0){let o=await re(e,"Id, DeveloperName, NamespacePrefix","PermissionSetGroup","DeveloperName",M.map(t=>pe(t).own));for(let t of o){let R=x(t.NamespacePrefix);m.push({id:String(t.Id),name:String(t.DeveloperName),...R?{namespace:R}:{}})}let h=m.map(t=>D(t.name,t.namespace));ie(M,h).length>0&&(f.permissionSetGroups=(await e.query("SELECT DeveloperName, NamespacePrefix FROM PermissionSetGroup")).map(t=>D(String(t.DeveloperName),x(t.NamespacePrefix))))}let O=[];if(G.length>0){let o=await re(e,"Id, DeveloperName, Type","Group","DeveloperName",G,` AND Type IN ${H(["Regular","Queue"])}`);for(let h of o){let t=h.Type;t!=="Regular"&&t!=="Queue"||O.push({id:String(h.Id),name:String(h.DeveloperName),type:t})}ie(G,O.map(h=>h.name)).length>0&&(f.groups=(await e.query(`SELECT DeveloperName FROM Group WHERE Type IN ${H(["Regular","Queue"])}`)).map(h=>String(h.DeveloperName)))}let q=s.some(o=>o.active===!0||o.profile!==void 0)||b||g.some(o=>o.licenseId?.startsWith("100"))?(await e.query("SELECT Id, Name, TotalLicenses, UsedLicenses FROM UserLicense")).map(o=>({id:String(o.Id),name:String(o.Name),total:Number(o.TotalLicenses??0),used:Number(o.UsedLicenses??0)})):[],p=_.length>0||M.length>0||b?(await K(e,"Id, AssigneeId, PermissionSetId, PermissionSetGroupId","PermissionSetAssignment","AssigneeId",w)).map(o=>{let h=x(o.PermissionSetId),t=x(o.PermissionSetGroupId);return{id:String(o.Id),assigneeId:String(o.AssigneeId),...h?{permissionSetId:h}:{},...t?{permissionSetGroupId:t}:{}}}):[],k=G.length>0||b?(await K(e,"Id, GroupId, UserOrGroupId","GroupMember","UserOrGroupId",w)).map(o=>({id:String(o.Id),groupId:String(o.GroupId),userId:String(o.UserOrGroupId)})):[],F=g.some(o=>o.licenseId?.startsWith("0PL"))?(await K(e,"AssigneeId, PermissionSetLicenseId","PermissionSetLicenseAssign","AssigneeId",w)).map(o=>({assigneeId:String(o.AssigneeId),permissionSetLicenseId:String(o.PermissionSetLicenseId)})):[],T=i.flatMap((o,h)=>o.kind==="found"&&s[h]?.email==="restore"&&Q(o.user.email)!==void 0?[o.user]:[]),v=await be(e,T,a.now);return{connected:d,manageUsers:c,resolutions:i,held:N,logins:J,...r?{profiles:r}:{},licenses:q,permissionSets:g,permissionSetGroups:m,groups:O,knownNames:f,assignments:p,memberships:k,licenseAssignments:F,addressesAsked:v,requests:e.requests()-n}}function ge(e){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function he(e){return[...new Set(e)].sort((s,a)=>s<a?-1:s>a?1:0)}function Le(e,s,a){if(Math.abs(e.length-s.length)>a)return a+1;let n=Array.from({length:s.length+1},(d,c)=>c);for(let d=1;d<=e.length;d+=1){let c=[d];for(let i=1;i<=s.length;i+=1)c[i]=Math.min(n[i]+1,c[i-1]+1,n[i-1]+(e[d-1]===s[i-1]?0:1));n=c}return n[s.length]}function Ue(e){return e.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(s=>s.length>=3)}function ae(e,s){let a=e.toLowerCase(),n=new Set(Ue(e));return he(s.filter(d=>{let c=d.toLowerCase();return c.includes(a)||a.includes(c)||Ue(d).some(i=>n.has(i))||Le(c,a,2)<=2}))}function de(e){let s=e.slice(0,20).join(", ");return e.length>20?`${s}, and ${e.length-20} more`:s}var ue={profile:"change its profile",active:"deactivate it",frozen:"freeze it"};function ke(e,s){return{code:"USERS_NO_RIGHT",message:(s===!1?`${e} cannot manage users here (Manage Users)`:`the org would not say whether ${e} may manage users (Manage Users)`)+": give it Manage Users, or connect as a user who has it"}}function A(e,s){return e!==void 0&&s!==void 0&&E(e)===E(s)}function ce(e){return e.what==="group"?{what:"group",name:e.name,type:e.type??"Regular",to:"removed"}:{what:e.what,name:e.name,to:"removed"}}function Z(){return{assign:[],unassign:[],join:[],leave:[]}}function Be(e,s,a={}){let n=[],d=e.connected;e.manageUsers!==!0&&n.push(ke(d.username,e.manageUsers));let c=a.previous?.users??[],i=r=>c.find(f=>A(f.applied.userId,r)),U=r=>e.profiles?.find(f=>A(f.id,r)),l=r=>e.logins.find(f=>A(f.userId,r)),u=r=>e.assignments.some(f=>A(f.id,r)),S=r=>e.memberships.some(f=>A(f.id,r)),N=(r,f,g,m)=>{let O={isActive:r.isActive,isFrozen:l(r.id)?.isFrozen??!1,profileId:r.profileId},q=f?.applied.before??O;m.current=O,m.before=q,r.licenseId!==void 0&&(m.licenseId=r.licenseId);let p=v=>{if(g[v]!==void 0)return g[v];if(f&&f.after[v]!==f.applied.before[v]&&O[v]===f.after[v])return q[v]},k=p("profileId");k!==void 0&&(m.target.profileId=k,A(k,O.profileId)||(m.writes.profileId=k,m.changes.push({what:"profile",from:r.profileName,to:U(k)?.name??k})));let F=p("isActive");F!==void 0&&(m.target.isActive=F,F!==O.isActive&&(m.writes.isActive=F,m.changes.push({what:"active",from:O.isActive,to:F})));let T=p("isFrozen");if(T!==void 0&&(m.target.isFrozen=T,T!==O.isFrozen)){let v=l(r.id);m.writes.isFrozen=T,v&&(m.writes.loginId=v.id),m.changes.push({what:"frozen",from:O.isFrozen,to:T})}},w=(r,f)=>{for(let g of r)g.what==="group"?S(g.id)&&f.writes.leave.push(g):u(g.id)&&f.writes.unassign.push(g)},P=[],_=new Map;s.forEach((r,f)=>{let g=e.resolutions[f];if(g===void 0||g.kind!=="found"){P.push({given:r.username,username:r.username,inFile:!0,changes:[],emailsToPeople:0,target:{},writes:Z(),found:{permissionSetAssignments:[],groupMembers:[]},carried:[]}),g?.kind==="two"?n.push({code:"USERS_TWO_USERS",username:r.username,message:`${r.username} names ${g.usernames.length} users: write the sandbox\u2019s username in full: ${g.usernames.join(" or ")}`}):n.push({code:"USERS_NO_USER",username:r.username,message:`${r.username}: no user has this username, nor this username followed by .<sandbox>: check the username, as Setup > Users gives it, or take it out of the file`});return}let m=g.user,O=_.get(E(m.id));if(O!==void 0){P.push({given:r.username,username:m.username,inFile:!0,changes:[],emailsToPeople:0,target:{},writes:Z(),found:{permissionSetAssignments:[],groupMembers:[]},carried:[]}),n.push({code:"USERS_SAME_USER",username:r.username,message:`${r.username} and ${O} name one user, ${m.username}: one entry per user`});return}_.set(E(m.id),r.username);let q=i(m.id),p={given:r.username,username:m.username,userId:m.id,inFile:!0,changes:[],emailsToPeople:0,target:{},writes:Z(),found:{permissionSetAssignments:[],groupMembers:[]},carried:[]},k;if(r.profile!==void 0){let t=(e.profiles??[]).filter(R=>R.name===r.profile);if(t.length===1)k=t[0].id;else{let R=(e.profiles??[]).map(z=>z.name),I=ae(r.profile,R);n.push({code:"USERS_PROFILE_UNKNOWN",username:r.username,message:`profile ${r.profile}: `+(t.length===0?"no profile has this name":`${t.length} profiles have this name`)+": profiles are named as Setup > Profiles names them, in the org\u2019s language: "+de(I.length>0?I:he(R))})}}N(m,q,{...k!==void 0?{profileId:k}:{},...r.active!==void 0?{isActive:r.active}:{},...r.frozen!==void 0?{isFrozen:r.frozen}:{}},p);let F=(p.target.profileId!==void 0?U(p.target.profileId)?.licenseId:void 0)??m.licenseId,T=q?.accesses??[],v=(t,R)=>T.find(I=>I.what===t&&I.name.toLowerCase()===R.toLowerCase()),o=(t,R)=>{for(let I of R??[]){let L=(t==="permissionSet"?e.permissionSets.map(y=>({...y,apiName:D(y.name,y.namespace)})):e.permissionSetGroups.map(y=>({...y,licenseId:void 0,apiName:D(y.name,y.namespace)}))).find(y=>y.apiName.toLowerCase()===I.toLowerCase());if(!L){let y=(t==="permissionSet"?e.knownNames.permissionSets:e.knownNames.permissionSetGroups)??[],B=ae(I,y);n.push({code:"USERS_PERMISSION_SET_UNKNOWN",username:r.username,message:(t==="permissionSet"?`permission set ${I}: no permission set has this API name: names are API names (Setup > Permission Sets > API Name)`:`permission set group ${I}: no permission set group has this API name: names are API names (Setup > Permission Set Groups > API Name)`)+(B.length>0?`; close: ${de(B)}`:"")});continue}let V=e.assignments.find(y=>A(y.assigneeId,m.id)&&A(t==="permissionSet"?y.permissionSetId:y.permissionSetGroupId,L.id)),X=v(t,I);if(V){X&&A(X.id,V.id)?p.carried.push(X):p.found.permissionSetAssignments.push(V.id);continue}let W=L.licenseId;if(W?.startsWith("100")&&!A(W,F)){let y=e.licenses.find(B=>A(B.id,W))?.name??W;n.push({code:"USERS_PERMISSION_SET_LICENSE",username:r.username,message:`${m.username}: permission set ${I} needs the license ${y}, which this user will not have: assign the permission set license first, in Setup, or take the set out`});continue}if(W?.startsWith("0PL")&&!e.licenseAssignments.some(y=>A(y.assigneeId,m.id)&&A(y.permissionSetLicenseId,W))){n.push({code:"USERS_PERMISSION_SET_LICENSE",username:r.username,message:`${m.username}: permission set ${I} needs a permission set license this user does not hold: assign the permission set license first, in Setup, or take the set out`});continue}p.writes.assign.push({what:t,name:I,setId:L.id})}};o("permissionSet",r.permissionSets),o("permissionSetGroup",r.permissionSetGroups);for(let t of r.groups??[]){let R=e.groups.find(L=>L.name.toLowerCase()===t.toLowerCase());if(!R){let L=ae(t,e.knownNames.groups??[]);n.push({code:"USERS_GROUP_UNKNOWN",username:r.username,message:`group ${t}: no public group or queue has this API name (DeveloperName)`+(L.length>0?`; close: ${de(L)}`:"")});continue}let I=e.memberships.find(L=>A(L.userId,m.id)&&A(L.groupId,R.id)),z=v("group",t);if(I){z&&A(z.id,I.id)?p.carried.push(z):p.found.groupMembers.push(I.id);continue}p.writes.join.push({name:t,type:R.type,groupId:R.id})}let h=t=>((t.what==="permissionSet"?r.permissionSets:t.what==="permissionSetGroup"?r.permissionSetGroups:r.groups)??[]).some(I=>I.toLowerCase()===t.name.toLowerCase());w(T.filter(t=>!h(t)),p);for(let t of p.writes.assign)p.changes.push({what:t.what,name:t.name,to:"added"});for(let t of p.writes.unassign)p.changes.push(ce(t));for(let t of p.writes.join)p.changes.push({what:"group",name:t.name,type:t.type,to:"added"});for(let t of p.writes.leave)p.changes.push(ce(t));if(r.email==="keep"&&(p.address="kept"),r.email==="restore"){let t=Q(m.email);t===void 0?p.address="restored":e.addressesAsked.includes(E(m.id))?p.address="awaiting":(p.address="invalid",p.writes.email=t,p.emailsToPeople=1,p.changes.push({what:"email",to:"awaiting"}))}P.push(p)});let M=new Set(P.flatMap(r=>r.userId?[E(r.userId)]:[]));for(let r of c){if(M.has(E(r.applied.userId)))continue;let f=e.held.find(m=>A(m.id,r.applied.userId));if(!f)continue;let g={username:f.username,userId:f.id,inFile:!1,changes:[],emailsToPeople:0,target:{},writes:Z(),found:{permissionSetAssignments:[],groupMembers:[]},carried:[]};N(f,r,{},g),w(r.accesses,g);for(let m of[...g.writes.unassign,...g.writes.leave])g.changes.push(ce(m));P.push(g)}for(let r of P)r.writes.isFrozen===void 0||r.writes.loginId!==void 0||n.push({code:"USERS_NO_LOGIN",...r.given!==void 0?{username:r.given}:{},message:`${r.username}: the org keeps no login of this user (UserLogin), which a freeze writes`+(r.inFile?`: take frozen off ${r.username}`:"")});for(let r of P){if(!A(r.userId,d.userId))continue;let f=[...r.writes.profileId!==void 0?[ue.profile]:[],...r.writes.isActive===!1?[ue.active]:[],...r.writes.isFrozen===!0?[ue.frozen]:[]];f.length!==0&&n.push({code:"USERS_SELF",...r.given!==void 0?{username:r.given}:{},message:r.inFile?`${r.username} is the user connected, and the file would ${ge(f)}: SandForge would lock itself out: take ${r.username} out of the file, or connect as another`:`${r.username} is the user connected, and putting it back as it was would ${ge(f)}: SandForge would lock itself out: connect as another`})}let G=$e(e,P,n),b=P.reduce((r,f)=>r+f.emailsToPeople,0);b>0&&a.acceptUserEmails!==!0&&n.push({code:"USERS_EMAILS_NOT_ACCEPTED",message:`Salesforce would email ${b} ${b===1?"person":"people"}: the confirmation of each address asked back, a system email, which only the line accepts: --accept-user-emails, once those people may receive them`});let J=a.deliverability==="open"||a.deliverability==="unread";return b>0&&J&&a.acceptEmails!==!0&&n.push({code:"USERS_EMAILS_OPEN",message:(a.deliverability==="unread"?"the org's deliverability could not be read, so it may deliver all email, and ":"the org delivers all email, and ")+`${b} ${b===1?"address":"addresses"} would be asked back before the masking is done: set Setup > Deliverability to System email only until the masking is done, or accept with --accept-emails that what runs there emails these people`}),{users:P,licenses:G,emailsToPeople:b,refusals:n}}function $e(e,s,a){let n=new Map,d=l=>{let u=E(l),S=n.get(u);return S||(S={takesFirst:0,freesFirst:0,takesThen:0,freesThen:0,takers:new Map},n.set(u,S)),S},c=l=>e.profiles?.find(u=>E(u.id)===E(l))?.licenseId,i=(l,u,S)=>{let N=d(l).takers;N.set(u,[...N.get(u)??[],S])};for(let l of s){let u=l.current;if(!u)continue;let S=c(u.profileId)??l.licenseId,N=l.writes.profileId??u.profileId,w=c(N)??S;if(l.writes.profileId!==void 0&&u.isActive&&w!==void 0&&(S===void 0||E(S)!==E(w))){d(w).takesFirst+=1;let P=l.changes.find(_=>_.what==="profile");i(w,`profile: ${P?.what==="profile"?P.to:N}`,l.username),S!==void 0&&(d(S).freesFirst+=1)}w!==void 0&&(l.writes.isActive===!0&&(d(w).takesThen+=1,i(w,"active: true",l.username)),l.writes.isActive===!1&&(d(w).freesThen+=1))}let U=[];for(let l of e.licenses){let u=n.get(E(l.id)),S=u?u.takesFirst+u.takesThen:0;if(!u||S===0)continue;let N=Math.max(0,S-u.freesFirst-u.freesThen),w=l.total-l.used,P=u.takesFirst>w||u.takesThen>w-u.takesFirst+u.freesFirst+u.freesThen;if(U.push({name:l.name,total:l.total,used:l.used,toUse:N}),P){let _=[...u.takers].map(([M,G])=>`${M} off ${G.join(" or ")}`);a.push({code:"USERS_LICENSE",message:`${l.name}: ${l.used} of ${l.total} used, and the file takes ${N} more: deactivate a user who no longer needs it, or take ${_.join(", or ")}`})}}return U}function C(e){return Math.ceil(e/se)}function xe(e){let s=i=>e.users.filter(i).length,a=i=>e.users.reduce((U,l)=>U+i(l),0),n=s(i=>i.writes.join.length>0),d=s(i=>i.writes.isFrozen!==void 0),c=s(i=>i.writes.profileId!==void 0||i.writes.isActive!==void 0||i.writes.isFrozen!==void 0||i.writes.email!==void 0);return C(s(i=>i.writes.profileId!==void 0))+C(s(i=>i.writes.isActive===!1))+C(s(i=>i.writes.isActive===!0))+C(d)+C(a(i=>i.writes.assign.length))+C(a(i=>i.writes.unassign.length))+C(n)+C(a(i=>i.writes.join.length))+C(a(i=>i.writes.leave.length))+C(s(i=>i.writes.email!==void 0))+C(c)+C(d)}function Qe(e,s,a){return{org:s,users:e.users.map(n=>({username:n.username,...n.given!==void 0&&$(n.given)!==$(n.username)?{given:n.given}:{},...n.userId!==void 0?{userId:n.userId}:{},...n.address!==void 0?{address:n.address}:{},changes:n.changes,...n.emailsToPeople>0?{emailsToPeople:n.emailsToPeople}:{}})),...e.licenses.length>0?{licenses:e.licenses}:{},emailsToPeople:e.emailsToPeople,apiRequests:a+xe(e),...e.refusals.length>0?{refusals:e.refusals}:{}}}export{j as a,H as b,Fe as c,Me as d,ye as e,Q as f,E as g,ve as h,ze as i,ke as j,Be as k,Qe as l};
|