sandforge 1.80.0 → 1.82.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-pipeline.mjs +12 -0
- package/bin/sandforge-users.mjs +12 -0
- package/lib/{chunk-J525F5KI.mjs → chunk-27Z76O2O.mjs} +1 -1
- package/lib/chunk-2JZGCCPG.mjs +9 -0
- package/lib/{chunk-ELFXJHU7.mjs → chunk-2UU42PTD.mjs} +1 -1
- package/lib/{chunk-N652NMZ4.mjs → chunk-32EUNQT6.mjs} +52 -52
- package/lib/chunk-3C2ZZIFN.mjs +7 -0
- package/lib/chunk-3CX7GPCR.mjs +7 -0
- package/lib/chunk-3HEMJTAP.mjs +925 -0
- package/lib/{chunk-BY2HJFFG.mjs → chunk-3HROD5RE.mjs} +1 -1
- package/lib/{chunk-OHWNPXWW.mjs → chunk-3MGMNK3Q.mjs} +1 -1
- package/lib/{chunk-PZPJKATS.mjs → chunk-3SKLBRPL.mjs} +8 -8
- package/lib/chunk-3XG25GTF.mjs +7 -0
- package/lib/chunk-42BFLWHR.mjs +7 -0
- package/lib/chunk-466F37VD.mjs +7 -0
- package/lib/chunk-47UHTN3Q.mjs +7 -0
- package/lib/chunk-4JKR4PTZ.mjs +8 -0
- package/lib/{chunk-COFG7Q6R.mjs → chunk-52EXDVPN.mjs} +1 -1
- package/lib/{chunk-SAR5622P.mjs → chunk-54HYHHVL.mjs} +1 -1
- package/lib/{chunk-RSWDYIHY.mjs → chunk-5GBO4KD5.mjs} +1 -1
- package/lib/chunk-5K2I2DMP.mjs +11 -0
- package/lib/{chunk-AV5SWEHP.mjs → chunk-6FARZYMJ.mjs} +1 -1
- package/lib/{chunk-BV6VTP3J.mjs → chunk-6GQUZ4IP.mjs} +1 -1
- package/lib/chunk-6KP6WETK.mjs +9 -0
- package/lib/{chunk-MJVTDA5Q.mjs → chunk-6VSZNZHH.mjs} +1 -1
- package/lib/{chunk-XUWL6ZPC.mjs → chunk-7CVDVBEE.mjs} +1 -1
- package/lib/{chunk-UCD54V2M.mjs → chunk-7EYQYZJP.mjs} +1 -1
- package/lib/{chunk-5K5VLULK.mjs → chunk-7LKI7OAS.mjs} +1 -1
- package/lib/chunk-7PY3VQP3.mjs +7 -0
- package/lib/chunk-7SDZR6SR.mjs +7 -0
- package/lib/chunk-7WSLT5VX.mjs +8 -0
- package/lib/chunk-A32ISQ6M.mjs +28 -0
- package/lib/{chunk-M3ROUWDX.mjs → chunk-A65ADTCR.mjs} +1 -1
- package/lib/chunk-A7JJWOLT.mjs +7 -0
- package/lib/chunk-AUS6NFLZ.mjs +8 -0
- package/lib/chunk-BMTNTBBM.mjs +7 -0
- package/lib/{chunk-SOU4FRYN.mjs → chunk-BN33LVPQ.mjs} +1 -1
- package/lib/chunk-BNKT3R3F.mjs +7 -0
- package/lib/{chunk-K2FBZIXY.mjs → chunk-BWWQXU2B.mjs} +1 -1
- package/lib/{chunk-IC2C2GOF.mjs → chunk-BXZ73A5M.mjs} +1 -1
- package/lib/{chunk-WA7EYLAQ.mjs → chunk-C2N2TNEU.mjs} +1 -1
- package/lib/{chunk-BKDV4ENO.mjs → chunk-C3LNYAVJ.mjs} +1 -1
- package/lib/{chunk-XLXIPIEW.mjs → chunk-CBL42DUU.mjs} +1 -1
- package/lib/chunk-CCEH7L53.mjs +7 -0
- package/lib/chunk-CELEBWEZ.mjs +7 -0
- package/lib/chunk-CV47FDQW.mjs +7 -0
- package/lib/{chunk-2UZPIMUC.mjs → chunk-CZLJZQCS.mjs} +1 -1
- package/lib/chunk-DBBPDSFN.mjs +7 -0
- package/lib/chunk-DIL62SUN.mjs +7 -0
- package/lib/chunk-DIS254AN.mjs +7 -0
- package/lib/{chunk-BTWDMNN3.mjs → chunk-DJCGURW7.mjs} +1 -1
- package/lib/{chunk-F6GUDTOB.mjs → chunk-DT3T7FRD.mjs} +1 -1
- package/lib/{chunk-IGYH7GMA.mjs → chunk-DWMRIWV5.mjs} +1 -1
- package/lib/{chunk-YRQGKDHM.mjs → chunk-EEFUE2ES.mjs} +1 -1
- package/lib/{chunk-FGRG7ANU.mjs → chunk-EOFO3PHS.mjs} +1 -1
- package/lib/{chunk-KBJ5VERV.mjs → chunk-FA4ZKDCU.mjs} +1 -1
- package/lib/{chunk-WU3GLFZO.mjs → chunk-FKK5YBGZ.mjs} +1 -1
- package/lib/chunk-FOIWWK7G.mjs +156 -0
- package/lib/chunk-FZF23M6R.mjs +7 -0
- package/lib/chunk-G2JR3F63.mjs +7 -0
- package/lib/{chunk-JEERQRLW.mjs → chunk-GBGHJTPC.mjs} +1 -1
- package/lib/{chunk-3RZQZHEB.mjs → chunk-GCGHHN4K.mjs} +1 -1
- package/lib/{chunk-RPI7LRTW.mjs → chunk-GGNUACTY.mjs} +1 -1
- package/lib/{chunk-EMNC6YI4.mjs → chunk-GGUOIDWP.mjs} +1 -1
- package/lib/chunk-GHPR5UVV.mjs +7 -0
- package/lib/{chunk-X5JYBPXP.mjs → chunk-GJ6SZVHT.mjs} +1 -1
- package/lib/{chunk-W622GUAW.mjs → chunk-H4JUYUSL.mjs} +1 -1
- package/lib/{chunk-XAMBCQPU.mjs → chunk-H4OBZIX3.mjs} +1 -1
- package/lib/{chunk-WIO4XO4F.mjs → chunk-HFSBDM7B.mjs} +1 -1
- package/lib/{chunk-L77FJZEP.mjs → chunk-HFUDCNU5.mjs} +1 -1
- package/lib/chunk-HIHCYMSL.mjs +7 -0
- package/lib/chunk-HKUWHVI7.mjs +9 -0
- package/lib/chunk-HQQVANWQ.mjs +20 -0
- package/lib/chunk-ICIYL45C.mjs +7 -0
- package/lib/chunk-IRZJU2PG.mjs +22 -0
- package/lib/chunk-ISSP2FZ5.mjs +7 -0
- package/lib/chunk-IVZJSDJD.mjs +7 -0
- package/lib/chunk-J24TIGSI.mjs +10 -0
- package/lib/{chunk-UNJA4J37.mjs → chunk-JESRFE2Z.mjs} +4 -4
- package/lib/chunk-JFNLKHY6.mjs +8 -0
- package/lib/chunk-JH27IKCO.mjs +9 -0
- package/lib/chunk-JJITOWZK.mjs +7 -0
- package/lib/{chunk-E5AHXLS6.mjs → chunk-JKT5YAQ2.mjs} +1 -1
- package/lib/{chunk-IWDREM66.mjs → chunk-JLZRZL5E.mjs} +1 -1
- package/lib/{chunk-FPKYYFM7.mjs → chunk-JPEVIXNH.mjs} +1 -1
- package/lib/chunk-JQZTMFO7.mjs +7 -0
- package/lib/chunk-KIMQQ6JQ.mjs +7 -0
- package/lib/{chunk-MILU7WFN.mjs → chunk-KJYEQHYP.mjs} +1 -1
- package/lib/chunk-KKOA62S4.mjs +474 -0
- package/lib/chunk-KP5G6FUC.mjs +7 -0
- package/lib/{chunk-JWTSEDIQ.mjs → chunk-L4INJ5TZ.mjs} +1 -1
- package/lib/{chunk-OLSGVAIL.mjs → chunk-LAUOSXMN.mjs} +53 -53
- package/lib/{chunk-MTMH6H2A.mjs → chunk-LCDPCUXS.mjs} +1 -1
- package/lib/{chunk-KDGMAGQR.mjs → chunk-LHU6CPGE.mjs} +1 -1
- package/lib/{chunk-YAZO75G2.mjs → chunk-LNXBCE7E.mjs} +1 -1
- package/lib/chunk-LXDSRP2W.mjs +7 -0
- package/lib/{chunk-2YIV2OB2.mjs → chunk-MIDBQ7SD.mjs} +1 -1
- package/lib/{chunk-TTKXMDBN.mjs → chunk-MKTXJCXN.mjs} +4 -4
- package/lib/chunk-MUEQRIK7.mjs +9 -0
- package/lib/{chunk-IOIWJ3DJ.mjs → chunk-NLB3RGIY.mjs} +1 -1
- package/lib/{chunk-O2HDYYUV.mjs → chunk-NWOI25WY.mjs} +1 -1
- package/lib/chunk-O2PUGRNW.mjs +10 -0
- package/lib/chunk-O4BROUGM.mjs +7 -0
- package/lib/chunk-OETEC3P7.mjs +7 -0
- package/lib/{chunk-GCOB7K5N.mjs → chunk-OHEOJISY.mjs} +1 -1
- package/lib/chunk-P55MKIZX.mjs +37 -0
- package/lib/chunk-P63WJMXQ.mjs +7 -0
- package/lib/chunk-PBE44M2Y.mjs +7 -0
- package/lib/{chunk-TYYOBZMU.mjs → chunk-PC247GKX.mjs} +1 -1
- package/lib/chunk-PE435FVH.mjs +15 -0
- package/lib/chunk-PPGDAUEQ.mjs +7 -0
- package/lib/{chunk-SE4QEZUG.mjs → chunk-PPHVWUFY.mjs} +1 -1
- package/lib/{chunk-CU2INBND.mjs → chunk-PR74GYVI.mjs} +1 -1
- package/lib/chunk-PWVDNN2C.mjs +7 -0
- package/lib/{chunk-6XYKJSGX.mjs → chunk-PYRZFUVU.mjs} +1 -1
- package/lib/{chunk-TLH7AD35.mjs → chunk-PZBZ7MNC.mjs} +1 -1
- package/lib/{chunk-DYFALGRT.mjs → chunk-Q3DY7TO2.mjs} +1 -1
- package/lib/{chunk-BGUEWRK2.mjs → chunk-Q6SXNKV2.mjs} +1 -1
- package/lib/chunk-QAPVKPEC.mjs +7 -0
- package/lib/{chunk-DBFJB2B6.mjs → chunk-QIRO4HTE.mjs} +1 -1
- package/lib/{chunk-TSLJUSLW.mjs → chunk-RCYEBY42.mjs} +1 -1
- package/lib/chunk-RLWB7F26.mjs +7 -0
- package/lib/{chunk-FXXLX4O6.mjs → chunk-RTWYLOCA.mjs} +1 -1
- package/lib/chunk-RYRMUPMY.mjs +7 -0
- package/lib/chunk-SAMWHL22.mjs +13 -0
- package/lib/{chunk-IZQZ6ZUF.mjs → chunk-SFGZFB4F.mjs} +1 -1
- package/lib/{chunk-FKG7Q3WH.mjs → chunk-SNEOKYV7.mjs} +1 -1
- package/lib/{chunk-3TJON4F3.mjs → chunk-STRMWSIQ.mjs} +1 -1
- package/lib/chunk-SZGGFST2.mjs +272 -0
- package/lib/{chunk-SOGQW4IG.mjs → chunk-T7WREYA5.mjs} +1 -1
- package/lib/{chunk-NTFIRZP6.mjs → chunk-TCBAE65A.mjs} +1 -1
- package/lib/{chunk-KYEDBS54.mjs → chunk-TEIBWMJM.mjs} +1 -1
- package/lib/{chunk-YKKRIEH4.mjs → chunk-TMA34QMA.mjs} +1 -1
- package/lib/chunk-TQ2TQHTT.mjs +9 -0
- package/lib/{chunk-HEKAZJRH.mjs → chunk-TWV4A5RK.mjs} +1 -1
- package/lib/{chunk-CEX3NEZL.mjs → chunk-UHFLKP26.mjs} +1 -1
- package/lib/chunk-UV74P4H2.mjs +7 -0
- package/lib/{chunk-WR4Q363I.mjs → chunk-V3R45ZWT.mjs} +1 -1
- package/lib/{chunk-GSKCGQIP.mjs → chunk-VPDEJGPS.mjs} +1 -1
- package/lib/{chunk-HLWMJF6Y.mjs → chunk-VQJMP3DC.mjs} +1 -1
- package/lib/chunk-VV3B6IC3.mjs +7 -0
- package/lib/{chunk-PJ5I73CK.mjs → chunk-VYOYXTCU.mjs} +1 -1
- package/lib/{chunk-NZC67CGR.mjs → chunk-VZT4E2OJ.mjs} +1 -1
- package/lib/{chunk-AEKONPF4.mjs → chunk-VZVICK7Q.mjs} +1 -1
- package/lib/{chunk-WR2GIKWE.mjs → chunk-WB2RIVO3.mjs} +1 -1
- package/lib/chunk-WEMLDUQA.mjs +7 -0
- package/lib/{chunk-MYW5QNGI.mjs → chunk-WOOUISSO.mjs} +1 -1
- package/lib/{chunk-G35N4P7D.mjs → chunk-WSUKC2U3.mjs} +1 -1
- package/lib/{chunk-ZVAED4QV.mjs → chunk-WT3SCUHS.mjs} +1 -1
- package/lib/{chunk-7EANH5PY.mjs → chunk-WZQEK4WT.mjs} +1 -1
- package/lib/{chunk-DBB3EMIN.mjs → chunk-XFU3HRUV.mjs} +1 -1
- package/lib/chunk-XK5W7BVE.mjs +7 -0
- package/lib/{chunk-2GTBABKU.mjs → chunk-XO5FBOQF.mjs} +1 -1
- package/lib/{chunk-CHYDMRSV.mjs → chunk-XSKPYGMT.mjs} +1 -1
- package/lib/chunk-XU25YA46.mjs +9 -0
- package/lib/chunk-XZISAZA6.mjs +7 -0
- package/lib/chunk-Y4TDVDP2.mjs +13 -0
- package/lib/chunk-YAIIRFKJ.mjs +8 -0
- package/lib/{chunk-LKQ5RKIV.mjs → chunk-YAJQS3OL.mjs} +1 -1
- package/lib/{chunk-74Q6DORA.mjs → chunk-YGJF55VJ.mjs} +1 -1
- package/lib/chunk-YH4DYI6D.mjs +7 -0
- package/lib/chunk-YMDFF657.mjs +10 -0
- package/lib/{chunk-2BA2XKAY.mjs → chunk-YT22LMF7.mjs} +1 -1
- package/lib/{chunk-IG2MTQRP.mjs → chunk-Z42PHCVZ.mjs} +1 -1
- package/lib/{chunk-2NBYT7GR.mjs → chunk-ZHIZY3ZC.mjs} +1 -1
- package/lib/chunk-ZQO5PDX5.mjs +48 -0
- package/lib/chunk-ZRUDYB7O.mjs +7 -0
- package/lib/{chunk-BXU6WFMH.mjs → chunk-ZUBBEP75.mjs} +1 -1
- package/lib/chunk-ZUOPC4W2.mjs +7 -0
- package/lib/{chunk-GGD7ON3M.mjs → chunk-ZUTUYBNW.mjs} +1 -1
- package/lib/{chunk-MHMH6MTP.mjs → chunk-ZXFL2MSN.mjs} +1 -1
- package/lib/sandforge-autopilot.mjs +11 -11
- package/lib/sandforge-backup.mjs +63 -32
- package/lib/sandforge-checkpoint.mjs +1 -348
- package/lib/sandforge-cleanup.mjs +1 -1
- package/lib/sandforge-clone.mjs +1 -1
- package/lib/sandforge-compare.mjs +1 -1
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +11 -11
- package/lib/sandforge-env.mjs +186 -140
- package/lib/sandforge-frozen.mjs +1 -266
- package/lib/sandforge-mcp.mjs +33 -14
- package/lib/sandforge-monitor.mjs +1 -1
- package/lib/sandforge-pipeline.mjs +88 -0
- package/lib/sandforge-seed.mjs +1 -1
- package/lib/sandforge-sync.mjs +1 -1
- package/lib/sandforge-users.mjs +157 -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 +18 -3
- package/lib/chunk-2CNCDM56.mjs +0 -7
- package/lib/chunk-3F6Q5E7I.mjs +0 -14
- package/lib/chunk-4VS2V6WU.mjs +0 -25
- package/lib/chunk-5P4PHJRL.mjs +0 -9
- package/lib/chunk-5TC3QB4U.mjs +0 -10
- package/lib/chunk-7ABODJ4G.mjs +0 -7
- package/lib/chunk-7EGQP6S4.mjs +0 -7
- package/lib/chunk-7FFGJWHN.mjs +0 -7
- package/lib/chunk-7YDNUBO5.mjs +0 -7
- package/lib/chunk-A527W53V.mjs +0 -7
- package/lib/chunk-ADOAS63R.mjs +0 -7
- package/lib/chunk-B5QQJ4SI.mjs +0 -7
- package/lib/chunk-CION3VMZ.mjs +0 -7
- package/lib/chunk-CSBS5U5I.mjs +0 -7
- package/lib/chunk-DB7RBE5D.mjs +0 -7
- package/lib/chunk-E5ZB3LU5.mjs +0 -7
- package/lib/chunk-EFR2Y7E4.mjs +0 -7
- package/lib/chunk-EHQ3FX6X.mjs +0 -7
- package/lib/chunk-EQNW3UC2.mjs +0 -7
- package/lib/chunk-F43REJDZ.mjs +0 -10
- package/lib/chunk-GSG7WZHM.mjs +0 -7
- package/lib/chunk-HOJYWTP7.mjs +0 -20
- package/lib/chunk-HS4YRX4J.mjs +0 -7
- package/lib/chunk-I7O6C2B5.mjs +0 -8
- package/lib/chunk-IFETCRWE.mjs +0 -10
- package/lib/chunk-IQXHJEYB.mjs +0 -7
- package/lib/chunk-JPUR2CFX.mjs +0 -10
- package/lib/chunk-K327QKMD.mjs +0 -7
- package/lib/chunk-KRCA6IPH.mjs +0 -8
- package/lib/chunk-LPBMBW3O.mjs +0 -13
- package/lib/chunk-LWW4U276.mjs +0 -7
- package/lib/chunk-MFG4MUIO.mjs +0 -9
- package/lib/chunk-MJU2PGZQ.mjs +0 -15
- package/lib/chunk-OAZRPP4I.mjs +0 -7
- package/lib/chunk-OO6CLPEH.mjs +0 -7
- package/lib/chunk-OPXCV2KL.mjs +0 -7
- package/lib/chunk-P33PSCXK.mjs +0 -7
- package/lib/chunk-Q3DM32KF.mjs +0 -11
- package/lib/chunk-QR3WELJQ.mjs +0 -7
- package/lib/chunk-QWT2C74M.mjs +0 -7
- package/lib/chunk-R3X3LV64.mjs +0 -14
- package/lib/chunk-RMBPOTD7.mjs +0 -7
- package/lib/chunk-SIHORWVK.mjs +0 -7
- package/lib/chunk-T62WNR54.mjs +0 -7
- package/lib/chunk-TTFDUKUS.mjs +0 -47
- package/lib/chunk-VE6XKGGD.mjs +0 -7
- package/lib/chunk-VGW4MXXZ.mjs +0 -7
- package/lib/chunk-VS7ZXUII.mjs +0 -824
- package/lib/chunk-VXQLDM4R.mjs +0 -7
- package/lib/chunk-VYXMVJL5.mjs +0 -7
- package/lib/chunk-W7U5E5ZL.mjs +0 -9
- package/lib/chunk-WXAQ7FK3.mjs +0 -115
- package/lib/chunk-YS4G22C2.mjs +0 -7
- package/lib/chunk-ZM6OJGIG.mjs +0 -7
- package/lib/chunk-ZUTYVST5.mjs +0 -7
|
@@ -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{p as it,q as vn}from"./chunk-VZVICK7Q.mjs";import{d as kn,h as Fn,m as Pn}from"./chunk-7PY3VQP3.mjs";import{b as gn}from"./chunk-SU65Z2BA.mjs";import{a as Bn,b as $n}from"./chunk-HF6LAK3G.mjs";import{j as wn,k as Rn,l as An,m as Sn,n as En}from"./chunk-HFUDCNU5.mjs";import{a as Tn,b as On}from"./chunk-TQ2TQHTT.mjs";import{d as st}from"./chunk-HFSBDM7B.mjs";import{c as yn,g as Ee,h as ot,j as bn}from"./chunk-OHEOJISY.mjs";import{a as hn}from"./chunk-EADHKH3A.mjs";import{E as te,_ as pn,b as ee,da as mn,q as Ae,r as Se,t as rt}from"./chunk-KIMQQ6JQ.mjs";import{h as nt}from"./chunk-TZE3Y7IQ.mjs";import{b as P}from"./chunk-CA5NAXSU.mjs";import{$ as Kt,Ac as an,Ad as ln,Bc as dn,Bd as et,Cd as cn,Fd as fn,Gd as tt,Id as be,Nd as we,Od as Re,P as zt,Sc as Ze,X as Qt,Z as Ht,_ as pe,aa as Yt,ba as Xt,ca as Jt,da as Zt,fa as me,ga as en,ha as tn,ia as nn,m as qt,pc as rn,rc as on,s as Vt,sc as sn,xd as he,yd as un,zd as ye}from"./chunk-ZQO5PDX5.mjs";import{b as H,e as x,i as fe,k as ge,l as $,s as Je}from"./chunk-WZQEK4WT.mjs";var Eo=/^[A-Za-z][A-Za-z0-9_]{0,79}$/;function Nn(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}function xn(e){return Array.isArray(e)?e.filter(t=>typeof t=="object"&&t):[]}function Cn(e){return typeof e=="string"&&Eo.test(e)?e:void 0}function Mn(e){let t=new Map;for(let r of xn(Nn(e,"variables"))){let o=r.name,i=Cn(r.objectType);typeof o=="string"&&i&&t.set(o.toLowerCase(),i)}let n=[];for(let r of xn(Nn(e,"recordCreates"))){let o=r.inputReference,i=Cn(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 In={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 od(e,t){let n=new Map,r=t!==void 0&&Object.prototype.hasOwnProperty.call(In,t)?In[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 To=new Set;function Oo(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 ko(e){return typeof e=="boolean"?String(e):typeof e=="string"&&e!==""?e:void 0}function Fo(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 Po(e,t,n,r,o,i,s){let a=new Set(o.values),d=a,l,u=r.controllerName?ko(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,b,w=n.filter(R=>d.has(R));return r.multi&&w.length>0?e[t]=w.join(";"):(o.defaultValue!==null&&d.has(o.defaultValue)?(m=o.defaultValue,b="default"):r.required&&(m=o.values.find(R=>d.has(R)),b=m===void 0?void 0:"first"),m===void 0?delete e[t]:e[t]=m),Fo(g,p).map(([R,O])=>({field:t,reason:R,values:O,recordType:i,...R==="controlling-value"&&l?{controllingField:l}:{},...m!==void 0&&b?{replacedBy:m,replacement:b}:{}}))}function sd(e,t,n,r,o=To){let i=[];for(let s of Oo(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(...Po(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 Bo="012000000000000AAA",Te="Master",Dn="";function id(e,t){return e?.get(typeof t=="string"?t:Dn)}async function $o(e,t,n){try{return{picklists:await e(t,n)}}catch(r){return{error:P(r)}}}var jn=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:Bo,developerName:Te},g=await this.readFor(o,t.objectApiName,f.targetId);this.keep(n,r,t.objectApiName,Dn,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=$o(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 ad(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 _n=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 vo(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 dd(e){return e.length===0?"":`, picklist values not written as read: ${e.map(vo).join("; ")}`}function pd(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 No=new Set(["picklist_value_refused","picklist_value_absent","currency_inactive"]);function Un(e){let t=zt(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"}:No.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 md(e){let t=Un(e);return"ignored"in t?t.ignored:void 0}function Ln(e,t,n){if(e===void 0)return!0;let r=t??Te;if(e===r)return!0;let o=Ee(e),i=Ee(r);if(o.namespacePrefix!==void 0||i.namespacePrefix===void 0||i.developerName!==e)return!1;if(n===void 0)return!0;let s=ot(e,n,a=>a);return"found"in s&&s.found.namespacePrefix===i.namespacePrefix}function xo(e){return e==null||e===""}var Wn=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=Un(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&&Ee(r).namespacePrefix===void 0)}holdsBack(t,n,r,o,i){for(let s of this.skipped.get(t)??[]){if(!Ln(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(!Ln(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)??[])xo(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 hd(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=Gn(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=Gn(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 Gn(e,t,n,r){let o=ot(t,n.filter(i=>!i.master),st);if("found"in o)return{type:o.found};if("ambiguous"in o){let i=o.ambiguous.map(st),s=i.find(a=>a.namespacePrefix);return{reason:bn(e,t,r,i)+(s?"; a package's is named with its namespace: "+yn(s.namespacePrefix,s.developerName):"")}}return{reason:`${r} has no ${e} record type named ${t}`}}function yd(e,t){return t.bySource.size===0?e?[...e]:void 0:[...(e??[]).filter(n=>!t.bySource.has(n.sourceId)),...t.mappings]}import{createHash as $i}from"node:crypto";import{createHash as jo}from"node:crypto";var qn="lineage:runs",Co="lineage";function Vn(e){let t=e.objects.filter(s=>s.records>0);if(t.length===0)return null;let n="source",r="target",o=[{id:n,type:"source",label:e.source.label,origin:e.source.origin,...e.source.orgId?{orgId:e.source.orgId}:{}}],i=[];for(let s of t){let a=`object:${s.objectApiName}`;o.push({id:a,type:"object",label:s.objectApiName,objectApiName:s.objectApiName,recordCount:s.records}),i.push({sourceId:n,targetId:a}),i.push({sourceId:a,targetId:r,recordCount:s.records})}return o.push({id:r,type:"destination",label:e.target.label,orgId:e.target.orgId,origin:"org"}),{nodes:o,edges:i,operationId:e.operationId,generatedAt:e.generatedAt,module:e.module,action:e.action}}var ke=class{constructor(t,n=100){this.configStore=t;this.limit=n}configStore;limit;save(t){let n=this.read().filter(r=>r.operationId!==t.operationId);n.push(t),this.configStore.set(qn,n.slice(-this.limit),Co)}get(t){let n=this.read();return t===void 0?n[n.length-1]??null:n.find(r=>r.operationId===t)??null}runs(){return this.read().reverse().map(t=>({operationId:t.operationId,generatedAt:t.generatedAt,...t.module?{module:t.module}:{},...t.action?{action:t.action}:{},...Mo(t)}))}read(){let t=this.configStore.get(qn);return Array.isArray(t)?t.filter(Io):[]}};function Mo(e){let t=e.nodes.find(n=>n.type==="destination");return t?{targetLabel:t.label}:{}}function Io(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.operationId=="string"&&typeof t.generatedAt=="string"&&Array.isArray(t.nodes)&&Array.isArray(t.edges)}var _o=100,zn="audit:trail",Do="audit",at=class{constructor(t,n=Vt){this.configStore=t;this.limit=n}configStore;limit;append(t){let n=this.read();n.push(t),this.configStore.set(zn,n.slice(-this.limit),Do)}list(t={}){let n=this.read().reverse(),r=n.filter(s=>(t.module===void 0||s.module===t.module)&&(t.orgId===void 0||s.orgId===t.orgId)),o=t.offset??0,i=t.limit??_o;return{entries:r.slice(o,o+i),total:r.length,offset:o,facets:Lo(n)}}read(){let t=this.configStore.get(zn);return Array.isArray(t)?t.filter(Wo):[]}};function Lo(e){let t=new Set,n=new Map;for(let r of e)t.add(r.module),r.orgId!==void 0&&!n.has(r.orgId)&&n.set(r.orgId,r.orgAlias);return{modules:[...t].sort(),orgs:[...n].map(([r,o])=>o?{orgId:r,orgAlias:o}:{orgId:r})}}function Wo(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.id=="string"&&typeof t.action=="string"&&typeof t.module=="string"&&typeof t.timestamp=="string"}var Td="ABORTED_BEFORE_START";function Go(e){let t=e?.trim().toLowerCase();if(t)return`sha256:${jo("sha256").update(t).digest("hex").slice(0,12)}`}function Od(e,t,n=new Date){try{let r=e.services?.getSandforgeSetting?.("safety.auditLogging",!0)!==!1;if(!r&&t.outcome==="stopped"&&t.code===void 0)return;let o=n.toISOString(),i=e.orgManager.getOrg(t.orgId),s=i?Ze(i):void 0,a=Go(i?.username),d=t.source?.origin==="org"?t.source.orgId:void 0,l=d!==void 0?e.orgManager.getOrg(d):void 0,u=l?Ze(l):void 0,f=t.objects??[];if(new at(e.configStore).append({id:crypto.randomUUID(),action:t.action,module:t.module,orgId:t.orgId,...s?{orgAlias:s}:{},...d!==void 0?{sourceOrgId:d}:{},...u?{sourceOrgAlias:u}:{},operationId:t.operationId,outcome:t.outcome,...r&&t.guard?{guard:t.guard}:{},objects:[...f],...t.leftBy?{leftBy:t.leftBy}:{},...a?{userId:a}:{},...t.context?{context:t.context}:{},...t.verdict?{verdict:t.verdict}:{},...t.muted?{muted:t.muted}:{},...t.checkpointId?{checkpointId:t.checkpointId}:{},...t.beforeRun?{beforeRun:{...t.beforeRun}}:{},...t.fit?{fit:{...t.fit}}:{},details:{...t.details,...t.code?{code:t.code}:{}},timestamp:o}),!t.source)return;let g=Vn({operationId:t.operationId,module:t.module,action:t.action,source:t.source.origin==="org"?{origin:"org",orgId:t.source.orgId,label:u??t.source.orgId}:{origin:t.source.origin,label:t.source.label??""},target:{label:s??t.orgId,orgId:t.orgId},objects:Uo(f,t.carried),generatedAt:o});g&&new ke(e.configStore).save(g)}catch(r){e.log(`[WARN] audit trail: run ${t.operationId} was not recorded \u2014 ${P(r)}`)}}function Uo(e,t){return t?Object.entries(t).map(([n,r])=>({objectApiName:n,records:r})):e.map(n=>({objectApiName:n.objectApiName,records:n.created+n.updated+(n.upserted??0)}))}function Qn(e){return{objectApiName:e,created:0,updated:0,deleted:0,failed:0}}var qo="__pass2__";function Hn(e){let t=e.errors??[],n=t.some(i=>i.skipped===!0),r=t.some(i=>i.objectApiName===qo&&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 Fd(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 Kn="RUN_CANCELLED";function vd(e){return{idRemapByObject:e.remapByObject,errors:e.errors,notSentByObject:e.notSentByObject,writtenWithoutFields:e.writtenWithoutFields,mayHaveBeenWritten:e.mayHaveBeenWritten}}function Nd(e){let t=new Map,n=r=>{let o=t.get(r)??Qn(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 xd(e,t){return t.some(r=>r.created+r.updated>0)?"cancelled":(e?Hn(e):"success")==="success"?"stopped":"cancelled"}function Cd(e){return e?{details:{contactPoints:e.neutralized?"neutralized":"kept",contactPointFields:e.fields.length,contactPointValues:e.values}}:{}}function Md(e){return Object.fromEntries((e.idRemapByObject??[]).map(t=>[t.objectApiName,t.created+t.linked+(t.updated??0)]))}var zd=2e3,Qd=1e4,zo=Qt;function Hd(e,t,n=zo){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 ir=.8,se=1024,Pe=2*se,ar=4*se,Qo=8*se,Ho=1*se,Ko=4*se,Yo=255,Xo=/__kav$/i,Jo=new Map([ee,Ae,Se,"Campaign","CampaignMember"].map(e=>[e.toLowerCase(),e]));function Be(e){return Jo.get(e.toLowerCase())??e}function Yn(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 ut(e,t){let n=Be(e);return n===ee?Yn(t):n===Ae?rt(t)?ar:Pe:n===Se&&rt(t)?0:n==="Campaign"?Qo:n==="CampaignMember"?Ho:Xo.test(e)?Ko+Yn(t,Yo):Pe}function Zo(e,t){let n=Math.min(t.personAccounts??0,t.rows),r=t.rows-n,o=Be(e);return o===Ae?r*Pe+n*ar:o===Se?r*Pe:r*ut(e,{})}function es(e){let t=e.map(({objectApiName:m,rows:b,counted:w,mayAdd:R=0,mayBeByThePlatform:O})=>{let T={rows:R,storageBytes:R*ut(m,{}),...R>0?{mayAdd:R}:{},...O&&O.rows>0?{mayBeByThePlatform:O}:{}};return w?{objectApiName:m,...T,rows:w.rows+T.rows,storageBytes:Zo(m,w)+T.storageBytes}:{objectApiName:m,...T,rows:b.length+T.rows,storageBytes:b.reduce((M,E)=>M+ut(m,E),0)+T.storageBytes}}).filter(({rows:m})=>m>0).sort((m,b)=>b.rows-m.rows||m.objectApiName.localeCompare(b.objectApiName)),n=e.reduce((m,b)=>m+(b.leftOut?.writtenBefore??0),0),r=e.filter(m=>(m.leftOut?.heldBack??0)>0).map(({objectApiName:m,leftOut:b})=>({objectApiName:m,rows:b?.heldBack??0})),o=e.filter(m=>(m.leftOut?.byThePlatform??0)>0).map(({objectApiName:m,leftOut:b})=>({objectApiName:m,rows:b?.byThePlatform??0})),i=e.flatMap(({objectApiName:m,leftOut:b})=>b?.linkedByValue&&b.linkedByValue.rows>0?[{objectApiName:m,...b.linkedByValue}]:[]),s=m=>e.filter(b=>(b.leftOut?.[m]??0)>0).map(({objectApiName:b,leftOut:w})=>({objectApiName:b,rows:w?.[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:b=[]})=>b.filter(({rows:w})=>w>0).map(({field:w,rows:R})=>({objectApiName:m,field:w,rows:R})));return{objects:t,...p.length>0?{leftEmpty:p}:{},totalRows:t.reduce((m,b)=>m+b.rows,0),storageBytes:t.reduce((m,b)=>m+b.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 Kd(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 ts=16,Xn=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<=ts)break;this.kept.delete(o)}}of(t){return this.kept.get(t)}},ns=500;function rs(e,t){return e>2*t||e-t>ns}function Yd(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})),...rs(t,e.total)?{farAbove:!0}:{}}}function Xd(e){let t=e.objects.reduce((n,r)=>n+(r.mayAdd??0),0);return t>0?{pricesForLines:t}:{}}function Jd(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 Fe=$({Max:x(),Remaining:x()}).loose(),os=$({DataStorageMB:Fe,DailyApiRequests:Fe.optional(),DailyBulkApiBatches:Fe.optional(),FileStorageMB:Fe.optional()}).loose(),ss=$({DailyApiRequests:$({Max:x(),Remaining:x()}).loose()}).loose(),is="the org does not tell this user its daily API requests";function dr(e,t,n){if(e!==null&&typeof e=="object"&&!(t in e))throw new Error(n)}async function as(e){let t=await e.request({method:"GET",url:"/limits"});dr(t,"DataStorageMB",qt);let n=os.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 Jn(e){let t=await e.request({method:"GET",url:"/limits"});dr(t,"DailyApiRequests",is);let n=ss.parse(t);return{max:n.DailyApiRequests.Max,remaining:n.DailyApiRequests.Remaining}}var lt=200,ur=2e3,ds=.1;function us(e){return e.reduce((t,{rows:n,bulk:r,readRows:o,perCall:i})=>{let s=Math.min(lt,Math.max(1,i??lt)),a=n<=0?0:r?En(n):Math.ceil(n/s),d=o&&o>0?Math.ceil(o/ur):0;return t+a+d},0)}var pt=["checkpoint","mute","readBack","deliverability","fit"],ls={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 cs(e){return pt.reduce((t,n)=>t+Math.max(0,e[n]??0),e.run)}function fs(e){return pt.some(t=>(e[t]??0)>0)?{...e}:void 0}function dt(e,t){let n=typeof e=="number"?void 0:fs(e),r=typeof e=="number"?e:cs(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<ds*i?"near":"fits",estimate:r,max:i,remaining:s,...o}}function gs(e){if(!e)return"";let t=pt.filter(n=>(e[n]??0)>0).map((n,r)=>`${e[n]}${r===0?" of them":""} ${ls[n]}`);return t.length>0?` (${t.join(", ")})`:""}var ne="API_BUDGET_EXCEEDED";function ps(e,t,n){if(e.verdict==="exceeds")return`The run takes about ${e.estimate} API requests${gs(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 ms(e){return e.verdict==="near"?{apiRequests:{estimate:e.estimate,remaining:e.remaining,max:e.max,...e.parts?{parts:{...e.parts}}:{}}}:{}}var $e="CHECKPOINT_REFUSED";function hs(e){return e?{checkpoint:e.estimate.apiRequests}:{}}function ys(e){let t=e?.refusal;if(t!==void 0)return{code:$e,message:it(t),refusal:t}}var bs="The run was stopped while it took the checkpoint first: nothing of it was kept, and nothing was written.";async function Zd(e){let t;try{t=await e()}catch(n){return{stop:{code:$e,message:vn(n)}}}return t.taken?{checkpoint:t.checkpoint}:"stopped"in t?{stop:{code:Kn,message:bs}}:{stop:{code:$e,message:it(t.refusal),refusal:t.refusal}}}var Zn=1e4,ws=1e4,Rs=.01;function As(e,t,n){return t<2e3||Bn.has(e)||(n??$n).has(e)}function ve(e,t,n){if(t<=0)return{jobs:[],rest:0};if(As(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 Rn({stateReads:Sn(e,wn,"save")})}function Es(e,t,n){let{jobs:r,rest:o}=ve(e,t,n);return r.reduce((i,s)=>i+Ss(s),0)+Math.ceil(o/lt)}var Ts=4,Os=3;function ks(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?Ts*r.filter(({rows:d})=>d>0).length:0;return{run:(i?[...r,...o].reduce((d,{objectApiName:l,rows:u})=>d+Es(l,u,i),0):us([...r,...o]))+s+a+Math.max(0,e.sentBefore??0),...hs(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 Fs=200;function Ps(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:ve(a,d,t),updates:n.has(a)?ve(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)/ur),0)+s+Math.ceil(s/Fs))+Os*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/ws),0),0),durationSeconds:o.reduce((a,{jobs:d,rest:l})=>a+d.reduce((u,f)=>u+An(f,"save"),0)+l*Rs,0),restObjects:r.filter(({rows:a,writes:d})=>a>0&&d.jobs.length===0).map(({objectApiName:a})=>a)}}var Bs="the limits the org answered list no DailyBulkApiBatches";function $s(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 vs(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 Ns(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 xs(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 Cs=200;function Ms(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:xs(n,t),readBound:{bound:t,objects:n.slice(0,Cs)}}}var lr="FILES_UNREAD",cr="FILE_STORAGE_UNREAD";function Is(e,t,n){if(!e)return{};if("unmeasured"in e)return{files:{unmeasured:!0},stop:{code:lr,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=fr({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:cr,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=Ns(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 js(e){let t=e.wholeOrg,n=t?.measures.files,r=dt(ks({...e,...t?{bulk:t.measures.restOnly?{restOnly:t.measures.restOnly}:{},...n&&"count"in n?{files:n.count}:{}}:{}}),e.budget),o=ps(r,e.target),i=[],s=ys(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=Ps({...e,measures:t.measures,...t.sourceSentBefore!==void 0?{sourceSentBefore:t.sourceSentBefore}:{}}),g=f.bulkBatches>0?dt(f.bulkBatches,t.bulkBatches??{unread:Bs}):void 0,p=g&&$s(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=dt(f.sourceRequests,t.sourceBudget),b=vs(m,t.source);b!==void 0&&m.verdict==="exceeds"&&i.push({code:ne,message:b,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:{...ms(r),...e.checkpoint?{checkpoint:e.checkpoint}:{}}}}function fr(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>ir*d*1048576?"near":"fits",estimateMB:i,maxMB:a,remainingMB:d,...s}}function _s(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 xe(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 Ds(e,t){let n=es(e),r=t.emailTextBytes,o=e.some(s=>Be(s.objectApiName)===ee&&s.counted);if(r===void 0||!Number.isFinite(r)||!o)return n;let i=n.objects.map(s=>Be(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 Ls(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 Ws(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 Gs=2;async function eu(e){let t=w=>({unread:P(w)}),n=Ds(e.objects,e.measures),r=await as(e.target.limits).catch(t),o="unread"in r?await Jn(e.target.limits).catch(t):r.dailyApiRequests,i=await Jn(e.source.limits).catch(t),s=fr(n,r,_s(n,e.automation)),a=Si(s,e.target.org),d=e.sample?Hs({sample:e.sample,storage:r,target:e.target.org}):void 0,l=Is(e.measures.files,r,e.target.org),u=e.sentBefore?.(),f=js({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??Gs,...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=[Ms(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(w=>w!==void 0),p=e.measures.restOnly?{restOnly:e.measures.restOnly}:{},m=new Set(n.objects.map(({objectApiName:w})=>w)),{wholeOrg:b}=f;return{wouldInsert:n.objects.map(({objectApiName:w,rows:R})=>{let{jobs:O,rest:T}=ve(w,R,p);return{objectApiName:w,rows:R,jobs:O.length,byRest:T}}),totalRows:n.totalRows,targetRequests:f.api,sourceRequests:b.source,...b.bulkBatches?{bulkBatches:b.bulkBatches}:{},storage:s,...l.files?{files:l.files}:{},durationSeconds:b.cost.durationSeconds,leftOut:{...Ws(e.graph),...n.leftOut?{rows:n.leftOut}:{}},personalAsIs:Ls(e.graph.nodes,m,e.anonymizePII),wouldBeRefused:g,...e.measures.personAccountsAsBusiness?{personAccountsAsBusiness:e.measures.personAccountsAsBusiness}:{},...e.sample?{sample:e.sample}:{}}}var Us="SAMPLE_STORAGE_UNREAD",gr="SAMPLE_CANNOT_FIT",qs="SAMPLE_TOO_LARGE",pr="SAMPLE_PLAN_MISMATCH",ct="SAMPLE_PLAN_GONE";function Vs(e){let{storage:t,bounds:n,target:r}=e;if("unread"in t&&!(n.withinMB!==void 0||n.maxTotal!==void 0))return{code:Us,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 zs(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 Qs(e){let{sample:t,storage:n,target:r}=e,o=zs(t.budget,n);if(o===void 0||t.storageBytes<=o)return;let i=Er(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 Hs(e){let{sample:t,storage:n,target:r}=e;return"unread"in n?Vs({storage:n,bounds:t.budget,target:r}):Qs({sample:t,storage:n,target:r})}var Ks=new Set(["gone","changed","otherOrg","otherSetup","otherSha"]),Ys={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:ct,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:ct,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:pr,message:`The plan given to --fit-plan ${Ys[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 Js=new Set([qs,gr,ct,pr]),Zs=20;function tu(e,t){if(e instanceof Error){if(e.name==="SampleRefusedError"){let{code:n,heaviest:r,sample:o}=e;if(typeof n!="string"||!Js.has(n))return;let i=Array.isArray(r)?r.flatMap(d=>{let l=d?.objectApiName;return typeof l=="string"?[l]:[]}):[],s=Xt({code:n,sample:o})?.sample??{},a={...s,...n===gr&&s.heaviest===void 0&&i.length>0?{heaviest:i.slice(0,Zs)}:{}};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"||!Ks.has(n)?void 0:V.of(Xs(n,t))}}}var ei=$({SingleEmail:$({Max:x(),Remaining:x()}).loose().optional(),DailyWorkflowEmails:$({Max:x(),Remaining:x()}).loose().optional()}).loose();async function nu(e){let t=ei.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 ti=15;function mr(e){let t=e.SingleEmail;return t!==void 0&&t.max<=ti}function ni(e){return mr(e)&&e.DailyWorkflowEmails!==void 0}function ri(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 hr(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 mt(e){return new Set([...hr(e)].flatMap(([t,{rows:n}])=>n>0?[t]:[]))}function oi(e,t,n){let r=hr(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=Ne(n)?n.unread:void 0;return[...o.values()].map(s=>{if(i!==void 0||Ne(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 Ne(e){return typeof e.unread=="string"}function si(e,t,n){let r=!Ne(n)&&mr(n),o=!Ne(n)&&ni(n),i=oi(e,ri(t,r,o),n);if(!r)return i;let s=mt(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 ru(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: ${P(s)}`}}let n=ai(t,ii(e.plan)),r=n!==void 0?{unread:n}:{},o=cn(t);if(o.length===0)return{checks:[],...r};let i=await e.readLimits().catch(s=>({unread:P(s)}));return{checks:si(e.plan,o,i),...r}}function ii(e){let t=mt(e);return(n,r)=>r==="insert"&&t.has(n)}function ai(e,t,n="the target's"){let r=[yr(e.unread,n),li(e,t)].filter(o=>o!==void 0).join("; ");return r!==""?r:void 0}var di={flows:"flows",processes:"processes",workflowRules:"workflow rules"};function yr(e,t){let n=e.flatMap(({part:r,reason:o})=>{let i=di[r];return i!==void 0?[`${t} ${i}: ${o}`]:[]});return n.length>0?n.join("; "):void 0}var K=10;function ui(e){if(e.condition!=="unreadable")return;let t=e.apiName.indexOf("__");return t>0?e.apiName.slice(0,t):void 0}function li(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=ui(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 ou(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 su(e){return{limit:e.limit,emails:e.emails,unread:e.unread??""}}var ci={SingleEmail:{one:"single email",more:"single emails"},DailyWorkflowEmails:{one:"workflow email",more:"workflow emails"}};function br(e,t){let n=ci[t];return`${e} ${e===1?n.one:n.more}`}function fi(e,t){return e.alertsCounted?`, its email alerts among them: ${t} counts them against its single emails, as a Developer Edition does`:""}function iu(e,t){let n=e.filter(o=>o.verdict==="exceeds");if(n.length===0)return;let r=n.map(o=>`about ${br(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 au(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 ${br(n.emails,n.limit)} (${r})`+fi(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 wr="EMAILS_NOT_ACCEPTED";function du(e,t={}){let n=[yr(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 uu(e){return"requests"in e&&typeof e.requests=="number"?Math.max(0,e.requests):sr}function lu(e){let t=e?.read?.requests??0;return t>0?{deliverability:t}:{}}var Rr={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"}},gi={flow:"flow",process:"process",workflowRule:"workflow rule",assignmentRule:"assignment rule"},pi={email:"",notRead:" (its definition was not read)",assignment:" (applied: it can mail the owner it assigns)"};function Ar(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(`${gi[n.kind]} "${n.name}"${pi[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`${Ar(o)} on ${n}`}).join("; ")}var er="read with one line of anonymous Apex that sends nothing";function Sr(e){return"level"in e&&e.level==="withheld"}function mi(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 (${er})`:`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 (${er})`}function hi(e,t){let{run:n,allTheSame:r}=Rr[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 cu(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=mi(t);return Sr(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:wr,message:hi(e,t)}},line:r,audit:"unread"in t?"unread":"all"}}function fu(e,t){let n=mt(t);return e.filter(r=>!n.has(r.objectApiName))}function gu(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 ${Ar(t)} record. A real run is refused all the same, and names them: it asks before it reads which records it writes`}function pu(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&&Sr(o))return;let{run:i,allTheSame:s}=Rr[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:wr,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 mu(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 ft(e,e<10?2:1)}function ft(e,t){if(e<=0)return"0";let n=10**t;return(Math.ceil(e*n-1e-9)/n).toString()}function Er(e,t){let n={over:e<10?2:1,bound:t<10?2:1};for(;;){let r={over:ft(e,n.over),bound:ft(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 Tr(e){return e.map(({objectApiName:t,kind:n,name:r})=>({objectApiName:t,kind:n,name:r}))}function yi(e){return Tr(et(e,"insert"))}function bi(e,t){let n=new Set(t);return Tr(et(e,"update",r=>n.has(r)))}var Or=["lookups","statuses","invitees","retry","upsert"];function hu(e,t={}){let n=gt(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=>Pn(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 b of a.get(m)??[]){if(b===f)return!0;g.has(b)||(g.add(b),p.push(b))}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(mn))i(u,"statuses");for(let u of Object.keys(pn))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:Or.filter(g=>f.has(g))}]:[]})}function wi(e){let t=new Set(e.flatMap(n=>n.steps));return Or.filter(n=>t.has(n))}function yu(e,t=[]){let n=new Set(t);return fn(e,(r,o)=>o==="insert"||o==="update"&&n.has(r))}function bu(e,t,n){let r=new Set(ye(e).map(s=>s.toLowerCase())),o=t.filter(s=>!r.has(s.toLowerCase())),i=we(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 wu="OWNER_MAP_INACTIVE",Ru="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(Yt(this.code))return{code:this.code,...this.storage?{storage:this.storage}:{},...this.ceiling!==void 0?{ceiling:this.ceiling}:{},...this.reason!==void 0&&this.code===$e?{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&&(Ai.has(this.code)||this.code==="STORAGE_EXCEEDED")?{roots:this.roots}:{}}}},Ai=new Set(["ROOTS_QUERY_REFUSED","NO_ROOTS","ROOTS_EXCEEDED","ROOTS_PLAN_MISMATCH","ROOTS_PLAN_GONE"]);function Au(e){return e instanceof V||e instanceof Error&&e.name==="ForgeRunGateError"&&typeof e.code=="string"}var tr="FILE_STORAGE_EXCEEDED";function Su(e){if(!(e instanceof Error)||e.name!=="ForgeFilesRefusedError")return;let{code:t,storage:n}=e;if(t===lr||t===cr)return new V(t,e.message);let r=n?.neededBytes,o=n?.remainingBytes;if(t!==tr||typeof r!="number"||typeof o!="number"||!Number.isFinite(r)||!Number.isFinite(o))return;let i=o/1048576;return new V(tr,e.message,{estimateMB:Number(Er(r/1048576,i).over),remainingMB:i,kind:"files"})}function Si(e,t){if(e.verdict==="exceeds")return`The records to write take ${xe(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 nr=10;function Eu(e,t,n){let r=[`write gate: ${e.totalRows} record(s) to write to ${n}, ${xe(t)}`];for(let i of e.objects.slice(0,nr))r.push(` ${i.objectApiName.padEnd(42)}${String(i.rows).padStart(8)}`);let o=e.objects.slice(nr);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(...Ei(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(ir*100)} % of what ${n} has left: Salesforce counts storage a while after a load, so less may be left than it says`),r)}function Ei(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 Ti={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"},Oi=["flows","triggers"];function Tu(e,t,n=[],r="--remove"){let o=Oi.filter(s=>n.some(a=>a.part===s)),i=o.length===0?[]:[` ${o.map(s=>j[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}: ${Ti[a](d??"")}`),...i]}var j={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 ki={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 Y(e){return e.map(t=>`${t.objectApiName}: ${W(t)}`).join("; ")}function ht(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 yt(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 Ou(e,t,n={}){let r=n.updated??[],o=yi(e),i=bi(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: ${Y(o)}.`),i.length>0){let l=wi(r.filter(u=>i.some(f=>f.objectApiName===u.objectApiName))).map(u=>ki[u]);a.push(`${t} runs automation as this clone updates records it inserted (${l.join("; ")}): ${Y(i)}.`)}let d=r.length>0?"inserts and updates":"inserts";for(let{part:l,reason:u}of s)a.push(`${j[l][0].toUpperCase()}${j[l].slice(1)} of ${t} could not be read (${u}), so what fires as the clone ${d} is not known.`);return a.push(...ht(n.assign??[],t,"the clone")),a.push(...yt(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 ku(e,t,n={}){let r=tt(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: ${Y(s)}.`);for(let{part:d,reason:l}of o)i.push(`${j[d][0].toUpperCase()}${j[d].slice(1)} of ${t} could not be read (${l}), so what fires as the removal deletes is not known.`);return i.push(...ht(n.assign??[],t,"the removal")),i.push(...yt(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 Fu(e,t,n,r){let o=[`removal automation: what ${t} runs as the removal takes the records back`];for(let s of tt(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(` ${j[s]} could not be read: ${a}`);return o}var Fi={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 Pu(e,t,n,r="removal",o){let i=ie(e),s=(a,d)=>{let l=[Pi[d](t)];for(let u of be(e,a))l.push(u.step==="delete"?` ${u.objectApiName}: ${oe[u.when]}: ${W(u)}`:` ${u.objectApiName}: ${Fi[u.step]}: ${W(u)}`);if(l.length===1&&i.length===0){let u=new Set(Object.values(a).flat()).size,f=Bi.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,kr(r)):[],...i.map(({part:a,reason:d})=>` ${j[a]} could not be read: ${d}`)]}var Pi={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 Bu(e,t,n){let r=be(e,n.steps),o=n.sweep?be(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=rr[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: ${Y(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: ${Y(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: ${Y(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 ${rr[kr(n.subject??"removal")].this} deletes: ${l.join("; ")}.`)}for(let{part:l,reason:u}of i)d.push(`${j[l][0].toUpperCase()}${j[l].slice(1)} of ${t} could not be read (${u}), so what fires as ${a.the} writes is not known.`);return d.push(...ht(n.assign??[],t,a.who)),d.push(...yt(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 Bi=new Set(["reloadSweep","replayAgainSweep"]);function kr(e){return e==="replayAgain"||e==="replayAgainSweep"?"replayAgainSweep":"reloadSweep"}var rr={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 vi=2e3,Ni=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function Pr(e,t){let n=e!==void 0&&Number.isFinite(e)?Math.floor(e):t;return Math.min(pe,Math.max(1,n))}function Iu(e){return e===void 0||!Number.isFinite(e)?vi:Math.max(1,Math.floor(e/10))}function Br(e){return e!==void 0&&Number.isFinite(e)&&e>=1?Math.floor(e):Kt}function ju(e){let t=tn(e);if(t!==void 0)return{issue:t};let n=Jt(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 _u(e){if(e.where!==void 0&&!Zt.safeParse(e.where).success)return{kind:"where"};if(e.orderBy!==void 0&&!en.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 Du(e,t,n,r){let o=nt(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 xi(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 Lu(e,t,n){let r=t.where!==void 0?` WHERE ${t.where}`:"";return`SELECT Id FROM ${nt(e)}${r} ORDER BY ${t.orderBy??me} LIMIT ${Math.max(1,Math.floor(n))}`}function Wu(e,t,n){if(e.verdict!=="exceeds")return;let r=xi(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 ${xe(e)}, and ${t} has ${e.remainingMB} MB left of ${e.maxMB} MB: ${i} ${G}`,storage:{estimateMB:Number(L(e.estimateMB)),remainingMB:e.remainingMB},...X(n.objectApiName).roots?{roots:{objectApiName:n.objectApiName,...r>=1?{fits:r}:{}}}:{}}}function Ci(e){let t=new Set,n=[];for(let r of e){let o=Tn(r);t.has(o)||(t.add(o),n.push(r))}return n.sort(On)}function Fr(e){return $i("sha256").update(Ci(e).join(`
|
|
8
|
+
`)).digest("hex")}function Gu(e){return Ni.test(e)}function Mi(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 Uu(e,t){if(e.sourceOrgId!==t.sourceOrgId)return"otherOrg";if(e.objectApiName.toLowerCase()!==t.objectApiName.toLowerCase()||t.query!==void 0&&!Mi(e.query,t.query)||t.ids!==void 0&&Fr(t.ids)!==e.sha256)return"otherQuery";if(Fr(e.ids)!==e.sha256)return"changed"}var G="Nothing was written.";function X(e,t={}){return e!==void 0&&/^[A-Za-z][A-Za-z0-9_]{0,79}$/.test(e)?{roots:{objectApiName:e,...t}}:{}}function qu(e,t){return{code:"ROOTS_QUERY_REFUSED",message:`${nn(e)}. Nothing was read or written.`,...X(t)}}function Vu(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}`,...X(e,{cap:n})}}function zu(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}`,...X(e,{cap:t,...i?{ordered:!0}:{}})}}var Ii={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 Qu(e,t){return{code:"ROOTS_PLAN_MISMATCH",message:`The records the dry run chose ${Ii[t]}: run the dry run again with this query, and give the run the plan it keeps. ${G}`,...X(e).roots?{roots:{objectApiName:e,plan:t}}:{}}}function Hu(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}`,...X(e).roots?{roots:{objectApiName:e,plan:"gone"}}:{}}}function Ku(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 Yu(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 bt=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 U(e){return e!==void 0&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0}function $r(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:Pr(t.cap,Ht),readTotal:Br(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 bt(new Map(Object.entries(e?.writtenBefore??{})),e?.stream?.store),beforeWrite:e?.beforeWrite,stream:e?.stream?{pageSize:U(e.stream.pageSize),ceiling:U(e.stream.ceiling),resumeAfter:e.stream.resumeAfter?new Map(Object.entries(e.stream.resumeAfter)):e.stream.store?.checkpoints()??new Map,onPage:e.stream.onPage,...e.stream.store?{store:e.stream.store}:{},...e.stream.summaryBound!==void 0?{summaryBound:Math.max(0,Math.floor(e.stream.summaryBound))}:{},...U(e.stream.secondPassPageSize)!==void 0?{secondPassPageSize:U(e.stream.secondPassPageSize)}:{},...U(e.stream.writeWindow)!==void 0?{writeWindow:U(e.stream.writeWindow)}:{},...e.stream.everything===!0?{everything:!0}:{},...U(e.stream.wholeReadBound)!==void 0?{wholeReadBound:U(e.stream.wholeReadBound)}:{},...e.stream.sample&&e.stream.everything===!0?{sample:e.stream.sample}:{}}:void 0,decisions:new Oe(e?.decisions),recordTypeDecisions:new Map}}async function vr(e,t){let{records:n,pages:r}=await hn(e,t);return{records:n,requests:r}}var Di=25,Lr=15,Ie=5,je=25,Rt=60,At=20,sr=6+Rt+At+1+6+1+20,ae=4,Li="SELECT ApiName, Label, TriggerType, RecordTriggerType, TriggerObjectOrEvent.QualifiedApiName, ActiveVersionId, HasAsyncAfterCommitPath FROM FlowDefinitionView WHERE IsActive = true AND TriggerType IN ('RecordBeforeSave', 'RecordAfterSave', 'RecordBeforeDelete')",Wi="SELECT Name, NamespacePrefix, TableEnumOrId, EntityDefinition.QualifiedApiName, UsageBeforeInsert, UsageAfterInsert, UsageBeforeUpdate, UsageAfterUpdate, UsageBeforeDelete, UsageAfterDelete, UsageAfterUndelete FROM ApexTrigger WHERE Status = 'Active'",Gi="SELECT ApiName, Label, TriggerObjectOrEvent.QualifiedApiName, ActiveVersionId FROM FlowDefinitionView WHERE IsActive = true AND ProcessType = 'Workflow'",Ui="SELECT Id, Name, NamespacePrefix, TableEnumOrId FROM WorkflowRule",qi="SELECT Name, SobjectType FROM AssignmentRule WHERE Active = true",Vi="SELECT DeveloperName, MasterLabel, SobjectType FROM DuplicateRule WHERE IsActive = true",zi="SELECT DeveloperName, NamespacePrefix FROM UserSetupEntityAccess WHERE KeyPrefix = '0CP'";function Nr(e){return`SELECT Metadata FROM Flow WHERE Id = '${e}'`}function Qi(e,t){if(t.length>Ie)throw new Error(`A Tooling composite holds ${Ie} 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 Hi(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 Me="PROCESSING_HALTED",Ki=$({compositeResponse:ge($({body:fe(),httpStatusCode:x(),referenceId:H()}).loose())}),Yi=$({records:ge(Je(H(),fe()))}).loose(),Xi=Je(H(),fe()),Ji=ge($({errorCode:H().optional(),message:H().optional()}).loose());function Wr(e,t,n,r,o){let i=Ki.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=Ji.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===Me?{halted:!0}:{}}})}function Zi(e,t){return Wr(e,t,"q","query",n=>{let r=Yi.safeParse(n);return r.success?r.data.records:void 0})}function ea(e,t){return Wr(e,t,"r","retrieve",n=>{let r=Xi.safeParse(n);return r.success?[r.data]:void 0})}function ta(e){return async t=>ea(await e.request({method:"POST",url:"/tooling/composite",body:JSON.stringify(Hi(`/services/data/v${e.version}`,t)),headers:{"Content-Type":"application/json"}}),t.length)}function ul(e){return{query:async(t,n)=>{let r=await e(t);return vr({query:async o=>r.query(o),queryMore:async o=>r.queryMore(o)},n)},toolingQuery:async(t,n)=>{let r=await e(t);return vr({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(Qi(`/services/data/v${r.version}`,n)),headers:{"Content-Type":"application/json"}});return Zi(o,n.length)},toolingRetrieves:async(t,n)=>ta(await e(t))(n)}}async function na(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:Ie},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(E=>E.left>0&&(E.retrieving.length>0||E.waiting.length>0));if(!u)return;let f=u.retrieving.length>0?"retrieving":"waiting";u.left--,d++;let g=[];for(let E of o){if(E!==u&&E.left<=0)continue;let C=i[f]-g.length;if(C<=0)break;for(let B of E[f].splice(0,C))g.push({query:B,queue:E})}let p;try{p=r&&f==="retrieving"?await r(g.map(({query:E})=>E.retrieve)):await e(g.map(({query:E})=>E.soql))}catch(E){let C=P(E);if(f==="retrieving")a(C,g);else for(let{query:B}of g)B.refused(C);continue}let m=f==="retrieving"?"retrieve":"query",b=[],w=[],R=0,O,T;if(g.forEach((E,C)=>{let B=p[C]??{refused:`The org gave no answer to this ${m} of the composite`};"records"in B?(E.query.take(B.records),R++):B.halted?(b.push(E),O??=B.refused):f==="retrieving"?(w.push(E),T??=B.refused):E.query.refused(B.refused)}),f==="retrieving"&&R===0){a(T??O??Me,g);continue}if(w.length>0){for(let{queue:E}of w)E.reason??=T;s("waiting",w)}if(b.length===0)continue;let M=g.length-b.length;if(M===0){for(let{query:E}of b)E.refused(O??Me);continue}i[f]=Math.min(i[f],M);for(let{queue:E}of b)E.reason=O;s(f,b)}};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??Me);return d}function ra(e){return`SELECT Metadata FROM WorkflowRule WHERE Id = '${e}'`}function oa(e){return`SELECT FlowVersionViewId, ApiName, ObjectType FROM FlowVariableView WHERE FlowVersionViewId IN (${e.map(n=>`'${n}'`).join(", ")})`}function sa(e){return`SELECT DurableId, QualifiedApiName FROM EntityDefinition WHERE QualifiedApiName IN (${e.map(n=>`'${n}'`).join(", ")})`}function ia(e){return`SELECT Id, DeveloperName, NamespacePrefix FROM CustomPermission WHERE DeveloperName IN (${e.map(n=>`'${n}'`).join(", ")})`}function aa(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 da(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})?$/,St=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,ua="myvariable_current",la={RecordBeforeSave:"beforeSave",RecordAfterSave:"afterSave",RecordBeforeDelete:"beforeDelete"},ca={Create:"create",Update:"update",CreateAndUpdate:"createAndUpdate",Delete:"delete"},Gr={onCreateOnly:"create",onAllChanges:"createAndUpdate",onCreateOrTriggeringUpdate:"createAndUpdate"},fa=[["UsageBeforeInsert","beforeInsert"],["UsageAfterInsert","afterInsert"],["UsageBeforeUpdate","beforeUpdate"],["UsageAfterUpdate","afterUpdate"],["UsageBeforeDelete","beforeDelete"],["UsageAfterDelete","afterDelete"],["UsageAfterUndelete","afterUndelete"]],ga={emailAlert:"email",emailSimple:"email",customNotificationAction:"notification",outboundMessage:"outbound"},pa={emailSimple:"SingleEmail",emailAlert:"DailyWorkflowEmails"},ma={Alert:"email",OutboundMessage:"outbound"},ha=new Set(["sms","mms","twilio","whatsapp","vonage","nexmo","messagebird","plivo","sinch"]);function Ot(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 A(e,t){return typeof e=="object"&&e!==null?e[t]:void 0}function N(e){return Array.isArray(e)?e.filter(t=>typeof t=="object"&&t):[]}function kt(e,t,n,r){return{apiName:e,label:t||e,timing:n,startsOn:r,condition:"notRead",permissions:[],paths:[],messages:[],switches:[]}}function ya(e){let t=Ot(e.TriggerObjectOrEvent),n=la[h(e.TriggerType)];if(!t||!n)return;let r=n==="beforeDelete"?"delete":ca[h(e.RecordTriggerType)]??"createAndUpdate",o=h(e.ActiveVersionId),i=kt(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 ba(e){let t=h(e.ActiveVersionId);return{objectApiName:Ot(e.TriggerObjectOrEvent),id:D.test(t)?t:null,flow:kt(h(e.ApiName),h(e.Label),"afterSave","createAndUpdate")}}function wa(e){let t=Ot(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:fa.filter(([o])=>e[o]===!0).map(([,o])=>o)}}}function xr(e){return e.startsOn==="create"||e.startsOn==="createAndUpdate"?e.timing==="afterSave"?0:1:e.startsOn==="update"?2:3}function Ur(e){let t=new Set(Yr(JSON.stringify(e??null)).filter(o=>de(o)==="Permission").map(Et));if(t.size===0)return[];let n=A(e,"filterFormula"),r=new Set((typeof n=="string"?ue(n):[]).filter(o=>de(o.reference)==="Permission"&&o.value===void 0).map(o=>Et(o.reference)));return[...t].sort((o,i)=>o.localeCompare(i)).map(o=>({name:o,bypass:r.has(o)}))}function qr(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=A(e,"filterFormula");if(typeof t=="string"&&t.trim()!=="")return[...new Set(De(t).flatMap(r=>{let o=Ea(r);return o?[o]:[]}))];let n=N(A(e,"filters"));return n.length===0||!Ta(h(A(e,"filterLogic")),n.length)?[]:[...new Set(n.filter(r=>h(r.operator)==="IsNull"&&A(r.value,"booleanValue")===!1).map(r=>h(r.field)).filter(r=>Aa.test(r)))]}var Aa=/^[A-Za-z][A-Za-z0-9_]*$/,Sa=/^(?:\{!\s*)?\$Record\.([A-Za-z][A-Za-z0-9_]*)\s*\}?$/i;function Ea(e){let t=z(e,"NOT");if(t===void 0)return;let n=Pt(t),r=z(n,"ISBLANK")??z(n,"ISNULL");return r===void 0?void 0:Sa.exec(r.trim())?.[1]}function Ta(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 Vr={permission:"Permission",setup:"Setup",user:"User",profile:"Profile",custommetadata:"CustomMetadata"},zr=String.raw`[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*`,Qr=new RegExp(String.raw`\$(?:Permission|Setup|User|Profile|CustomMetadata)\.${zr}`,"gi"),J=String.raw`(?:\{!\s*)?(\$(?:Permission|Setup|User|Profile|CustomMetadata)\.${zr})\s*\}?`,Oa=new RegExp(`^${J}$`,"i"),ka=new RegExp(`^NOT\\s+${J}$`,"i"),Hr=new RegExp(`^(?:${J}\\s*(==?|<>|!=)\\s*(TRUE|FALSE)|(TRUE|FALSE)\\s*(==?|<>|!=)\\s*${J})$`,"i"),Cr=String.raw`("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')`,Kr=new RegExp(`^(?:${J}\\s*(==?|<>|!=)\\s*${Cr}|${Cr}\\s*(==?|<>|!=)\\s*${J})$`,"i");function q(e){let t=e.indexOf("."),n=Vr[e.slice(1,t).toLowerCase()];return n?`$${n}${e.slice(t)}`:e}function de(e){return Vr[e.slice(1,e.indexOf(".")).toLowerCase()]}function Et(e){return e.slice(e.indexOf(".")+1)}function Yr(e){return[...new Set([...e.matchAll(Qr)].map(t=>q(t[0])))]}var Fa=new RegExp(`^${Qr.source}$`,"i");function Xr(e){return typeof e=="string"&&Fa.test(e)}function _e(e,t){return e.toLowerCase()===t.toLowerCase()}function Jr(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 Mr(e,t){return e.some(n=>_e(n.reference,t.reference)&&n.value===t.value)}function ue(e){return De(e).flatMap(Pa)}function Ft(e){return Tt(e).flatMap(Ba)}function Pa(e){let t=Hr.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:q(o??l)}]:[]}let n=Kr.exec(e);if(n){let[,o,i,s,a,d,l]=n;return(i??d).startsWith("=")?[]:[{reference:q(o??l),value:Jr(s??a)}]}let r=z(e,"NOT");if(r===void 0){let o=ka.exec(e);return o?[{reference:q(o[1])}]:[]}return Ft(r)}function Ba(e){let t=Oa.exec(e);if(t)return[{reference:q(t[1])}];let n=Hr.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:q(i??u)}]:[]}let r=Kr.exec(e);if(r){let[,i,s,a,d,l,u]=r;return(s??l).startsWith("=")?[{reference:q(i??u),value:Jr(a??d)}]:[]}let o=z(e,"NOT");return o===void 0?[]:ue(o)}function De(e){let t=Pt(e),n=z(t,"AND");if(n)return Le(n,",").flatMap(De);let r=Le(t,"&&");return r.length>1?r.flatMap(De):[t]}function Tt(e){let t=Pt(e),n=z(t,"OR");if(n)return Le(n,",").flatMap(Tt);let r=Le(t,"||");return r.length>1?r.flatMap(Tt):[t]}function z(e,t){let n=new RegExp(`^${t}\\s*\\(([\\s\\S]*)\\)$`,"i").exec(e);return n&&eo(n[1])?n[1]:void 0}function Pt(e){let t=e.trim();for(;t.startsWith("(")&&t.endsWith(")")&&eo(t.slice(1,-1));)t=t.slice(1,-1).trim();return t}function eo(e){let t=0;for(let{char:n,quoted:r}of to(e))if(!r){if(n==="(")t++;else if(n===")"&&--t<0)return!1}return t===0}function Le(e,t){let n=[],r=0,o=0;for(let{char:i,index:s,quoted:a}of to(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*to(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 $a(e){let t=A(e,"start");if(typeof t=="object"&&t!==null){let n=h(A(A(t,"connector"),"targetReference"))||void 0,r=N(A(t,"scheduledPaths")).map(o=>h(A(A(o,"connector"),"targetReference"))||void 0);return{name:n,everyPath:r.every(o=>o===n)}}return{name:h(A(e,"startElementReference"))||void 0,everyPath:!0}}function va(e,t){let n=e.leftValueReference,r=e.rightValue;if(Xr(n)){let i=q(n);if(typeof A(r,"booleanValue")=="boolean")return[{reference:i}];let s=A(r,"stringValue");return typeof s=="string"?[{reference:i,value:s}]:[]}let o=typeof n=="string"?t.get(n):void 0;return o===void 0?[]:[...Ft(o),...ue(o)]}function Na(e,t){let n=e.leftValueReference,r=typeof n=="string"?t.get(n):void 0;return Yr([typeof n=="string"?n:"",h(A(e.rightValue,"elementReference")),r??""].join(" "))}function xa(e,t,n){let{leftValueReference:r,operator:o,rightValue:i}=e;if(o!=="EqualTo"&&o!=="NotEqualTo")return"unknown";let s=o==="EqualTo",a=A(i,"booleanValue");if(Xr(r)){if(!_e(r,t.reference))return"unknown";if(typeof a=="boolean"&&t.value===void 0)return a===s?"true":"false";let u=A(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 Mr(Ft(d),t)?l?"true":"false":Mr(ue(d),t)?l?"false":"true":"unknown"}function Ca(e,t,n){let r=N(e.conditions);if(r.length===0)return"unknown";let o=r.map(s=>xa(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 Ma(e,t,n){for(let r of N(e.rules)){let o=Ca(r,t,n),i=!h(A(r.connector,"targetReference"));if(o!=="false"){if(o==="true")return i;if(!i)return!1}}return!h(A(e.defaultConnector,"targetReference"))}function no(e){let t=N(A(e,"decisions")),n=new Map(N(A(e,"formulas")).filter(f=>typeof f.expression=="string").map(f=>[h(f.name),h(f.expression)])),r=f=>N(f.rules).flatMap(g=>N(g.conditions)),o=[...new Set(t.flatMap(f=>r(f).flatMap(g=>Na(g,n))))];if(o.length===0)return{permissions:[],switches:[]};let{name:i,everyPath:s}=$a(e),a=s?t.find(f=>h(f.name)===i):void 0,d=a?Zr(r(a).flatMap(f=>va(f,n))).filter(f=>Ma(a,f,n)):[],l=o.filter(f=>de(f)==="Permission").map(f=>({name:Et(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 Ia(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 ja(...e){return e.some(t=>{let n=Ia(t);return n.some(r=>ha.has(r))||n.some((r,o)=>r==="text"&&/^messages?$/.test(n[o+1]??""))})}function ro(e){return N(A(e,"actionCalls")).flatMap(t=>{let n=h(t.actionType),r=h(t.label)||h(t.name)||h(t.actionName),o=ga[n],i=pa[n];return o?[{kind:o,name:r,...i?{limit:i}:{}}]:n==="apex"&&ja(h(t.actionName),h(t.name),r)?[{kind:"sms",name:r,guessed:!0}]:[]})}function _a(e){return N(A(A(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 oo(e,t){let n=Mn(t);n.length>0&&(e.creates=n)}function Da(e,t){if(typeof t!="object"||t===null)return;let n=A(t,"start"),r=no(t);e.permissions=[...Ur(n),...r.permissions],e.switches=[...qr(A(n,"filterFormula")),...r.switches];let o=Ra(n);o.length>0&&(e.requiresFilled=o),e.paths=_a(t),e.messages=ro(t),oo(e,t)}function La(e,t){let n=new Map(N(A(t,"processMetadataValues")).map(o=>[h(o.name),h(A(o.value,"stringValue"))]));e.startsOn=Gr[n.get("TriggerType")??""]??"createAndUpdate";let r=no(t);return e.permissions=r.permissions,e.switches=r.switches,e.messages=ro(t),oo(e,t),n.get("ObjectType")||void 0}function Wa(e,t){e.startsOn=Gr[h(A(t,"triggerType"))]??"createAndUpdate";let n=A(t,"formula");e.permissions=typeof n=="string"?Ur({filterFormula:n}):[],e.switches=qr(n);let r=N(A(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=[A(t,"actions"),...r.map(o=>o.actions)].flatMap(N).flatMap(o=>{let i=ma[h(o.type)];return i?[{kind:i,name:h(o.name),...i==="email"?{limit:"DailyWorkflowEmails"}:{}}]:[]}),A(t,"active")===!0}function so(e,t){return(e?`${e}__${t}`:t).toLowerCase()}function wt(e,t){let n=gn(t);return n===void 0?{part:e,reason:P(t)}:{part:e,reason:`the org could not be reached (${n})`,unreachable:n}}var Ir={flows:0,triggers:1,conditions:2,processes:3,workflowRules:4,definitions:5,assignmentRules:6,duplicateRules:7,userPermissions:8,permissionSets:9};function Ga(e){return[...e].sort((t,n)=>Ir[t.part]-Ir[n.part]||(t.reason<n.reason?-1:t.reason>n.reason?1:0))}async function Ce(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 jr=[on,kn,an,dn,sn],_r=["ProductCategory","ProductCatalog"];function gt(e,t=new Set){let{referenceDataObjects:n}=$r(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(rn).filter(([u,{object:f}])=>o.has(u)&&!i.has(f)&&!t.has(f)).map(([,{object:u}])=>u),a=Fn(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(jr);return[...new Set([...r,...s,...l?jr.filter(u=>a.has(u)):[],...d(_r)?_r.filter(u=>a.has(u)):[]])]}var Dr=class{deps;constructor(t){this.deps=t}async readForGraph(t,n,r=new Set){return this.read(t,gt(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 S=await y();return i+=S.requests,S.records}catch(S){return i++,o.push(wt(c,S)),[]}},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,b,w,R,O]=await Ce([d("flows",l(Li)),d("triggers",u(Wi)),d("processes",l(Gi)),d("workflowRules",u(Ui)),g?d("assignmentRules",l(qi)):f,d("duplicateRules",l(Vi))],ae),T=p.map(ya).filter(c=>c!==void 0).flatMap(c=>{let y=a(c.objectApiName);return y?[{...c,objectApiName:y}]:[]}),M=m.map(wa).filter(c=>c!==void 0).flatMap(c=>{let y=a(c.objectApiName),S=c.trigger.events.some(k=>k!=="afterUndelete"||r.undeletes===!0);return y&&S?[{...c,objectApiName:y}]:[]}),E=b.map(ba),C=E.filter(c=>c.objectApiName===void 0&&c.id!==null).map(c=>c.id),B=n.filter(c=>c.includes("__")&&St.test(c)),ao=w.some(c=>/^01I/.test(h(c.TableEnumOrId))),[uo,lo]=await Ce([C.length>0?d("processes",l(oa(C))):f,ao&&B.length>0?d("workflowRules",l(sa(B))):f],ae),co=new Map(uo.filter(c=>h(c.ApiName).toLowerCase()===ua).map(c=>[h(c.FlowVersionViewId),h(c.ObjectType)]));for(let c of E)c.objectApiName===void 0&&c.id!==null&&(c.objectApiName=co.get(c.id)||void 0);let fo=new Map(lo.map(c=>[h(c.DurableId),h(c.QualifiedApiName)])),We=w.flatMap(c=>{let y=h(c.TableEnumOrId),S=a(fo.get(y)??y),k=h(c.Name),F=h(c.Id);if(!S||!k)return[];let I=h(c.NamespacePrefix),Q=I?`${I}.${k}`:k;return[{objectApiName:S,id:D.test(F)?F:null,flow:kt(Q,Q,"afterSave","createAndUpdate")}]}),Ge=E.filter(c=>c.objectApiName===void 0||a(c.objectApiName)!==void 0),go=new Map(n.map((c,y)=>[c,y])),le=c=>go.get(a(c.objectApiName)??"")??n.length,Ue=T.filter(c=>c.id!==null).sort((c,y)=>xr(c.flow)-xr(y.flow)||le(c)-le(y)||c.flow.label.localeCompare(y.flow.label)),Z=this.deps.toolingQueries,qe=Z?this.deps.toolingRetrieves:void 0,Bt=qe?je:Ie,$t=Z?Rt*Bt:Di,vt=Z?At*Bt:Lr,Ve=Ue.slice(0,$t),Nt=[...Ge.map(c=>({read:c,kind:"process"})),...We.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)),xt=Nt.slice(0,vt),ze,Qe,Ct=new Set,Mt=c=>c[0]?.Metadata,po=(c,y)=>{c.flow.condition="read",Da(c.flow,Mt(y))},mo=(c,y)=>{c.flow.condition="unreadable",ze??=y},ho=({read:c,kind:y})=>y==="process"?Nr(c.id):ra(c.id),yo=({read:c,kind:y},S)=>{let k=Mt(S);if(typeof k!="object"||k===null){c.flow.condition="unreadable";return}if(c.flow.condition="read",y==="process"){let F=La(c.flow,k);c.objectApiName??=F}else Wa(c.flow,k)||Ct.add(c.flow)},bo=({read:c},y)=>{c.flow.condition="unreadable",Qe??=y},It=(c,y,S,k,F)=>c.map(I=>({soql:y(I),retrieve:S(I),take:Q=>k(I,Q),refused:Q=>F(I,Q)})),jt=It(Ve,c=>Nr(c.id),c=>({sobject:"Flow",id:c.id}),po,mo),_t=It(xt,ho,({read:c,kind:y})=>({sobject:y==="process"?"Flow":"WorkflowRule",id:c.id}),yo,bo);Z?i+=await na(c=>Z(t,c),[{queries:jt,requests:Rt},{queries:_t,requests:At}],ae,qe&&(c=>qe(t,c))):await Ce([...jt,..._t].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(P(y))}}),ae),ze!==void 0&&o.push(wt("conditions",ze)),Qe!==void 0&&o.push(wt("definitions",Qe));for(let c of[...T,...Ge,...We])c.id===null&&(c.flow.condition="unreadable");let Dt=Ge.flatMap(c=>{let y=a(c.objectApiName);return y?[{...c,objectApiName:y}]:[]}),Lt=We.filter(c=>!Ct.has(c.flow)),He=[...T,...Dt,...Lt].flatMap(c=>c.flow.permissions),Wt;if(He.length>0){let[c]=await Ce([d("userPermissions",l(zi))],ae);if(!o.some(y=>y.part==="userPermissions")){let y=new Set(c.map(S=>so(h(S.NamespacePrefix),h(S.DeveloperName))));Wt=y;for(let S of He)S.held=y.has(S.name.toLowerCase())}}let Gt=[...new Set(He.filter(c=>c.bypass&&c.held!==!0).map(c=>c.name))],Ke=Gt.length>0?await Ua(Gt,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(Ke?.some(c=>c.permissionSets.length>0)){let{toolingQueries:c,toolingRetrieves:y}=this.deps;try{let{readValidationRuleBypasses:S}=await import("./chunk-42BFLWHR.mjs"),k=await S(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(I=>Wt?.has(I.toLowerCase()))?[]:[F]),k.notRead>0&&(ce.validationRulesNotRead=k.notRead)}catch(S){i++,ce.validationRulesUnread=P(S)}}let wo=c=>R.filter(y=>h(y.SobjectType).toLowerCase()===c.toLowerCase()).map(y=>({name:h(y.Name)})).sort((y,S)=>y.name.localeCompare(S.name)),Ro=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,S)=>y.name.localeCompare(S.name)),Ao=(c,y)=>c.label.localeCompare(y.label),Ye=(c,y)=>c.filter(S=>S.objectApiName===y).map(S=>S.flow).sort(Ao),Xe=new Map;for(let c of Ue.slice(Ve.length))Xe.set(c.objectApiName,(Xe.get(c.objectApiName)??0)+1);let Ut=n.flatMap(c=>{let y=Xe.get(c);return y?[{objectApiName:c,flows:y}]:[]}),So=n.map(c=>({objectApiName:c,flows:Ye(T,c),triggers:M.filter(y=>y.objectApiName===c).map(y=>y.trigger).sort((y,S)=>y.name.localeCompare(S.name)),processes:Ye(Dt,c),workflowRules:Ye(Lt,c),assignmentRules:wo(c),duplicateRules:Ro(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:So,unread:Ga(o),conditionsNotRead:Ue.length-Ve.length,conditionsBound:$t,...Ut.length>0?{conditionsNotReadOn:Ut}:{},definitionsNotRead:Nt.length-xt.length,definitionsBound:vt,...Ke?{bypassGrants:Ke}:{},...ce,requests:i}}};function _(e){return e.slice(0,15)}async function Ua(e,t,n,r){let o=e.flatMap(p=>{let m=p.indexOf("__"),b=m>0?p.slice(0,m):"",w=m>0?p.slice(m+2):p;return St.test(w)&&(!b||St.test(b))?[{name:p,developerName:w}]:[]});if(o.length===0)return;let i=await t(ia([...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(so(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(aa(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(da(p,l));if(n())return;for(let b of m){let w=_(h(b.ParentId)),R=typeof b.n=="number"?b.n:Number(b.n);u.set(w,(u.get(w)??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(_(m),io(h(p.NamespacePrefix),h(p.DeveloperName)))}let g=r&&l.length>0?await za(l,f,r):void 0;return o.map(({name:p})=>{let m=s.get(p.toLowerCase()),b=new Map;for(let w of d){if(!m||_(h(w.SetupEntityId))!==_(m))continue;let R=_(h(w.ParentId)),O=w.Parent,T=h(A(O,"Name"));if(!T||b.has(R))continue;let M=h(A(O,"NamespacePrefix"));b.set(R,{name:M?`${M}__${T}`:T,label:h(A(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:[...b.values()].sort((w,R)=>w.grants-R.grants||w.name.localeCompare(R.name))}})}function io(e,t){return e?`${e}__${t}`:t}function qa(e){return`SELECT ParentId, SetupEntityId FROM SetupEntityAccess WHERE SetupEntityType = 'CustomPermission' AND ParentId IN (${e.map(n=>`'${n}'`).join(", ")})`}function Va(e){return`SELECT Id, DeveloperName, NamespacePrefix FROM CustomPermission WHERE Id IN (${e.map(n=>`'${n}'`).join(", ")})`}async function za(e,t,n){try{let r=await n(qa(e)),o=new Map(t),i=[...new Set(r.map(a=>h(a.SetupEntityId)).filter(a=>D.test(a)&&!o.has(_(a))))];if(i.length>0)for(let a of await n(Va(i))){let d=h(a.Id);D.test(d)&&o.set(_(d),io(h(a.NamespacePrefix),h(a.DeveloperName)))}let s=new Map;for(let a of r){let d=_(h(a.ParentId)),l=o.get(_(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:P(r)}}}var Qa={insert:"on insert",update:"on update",delete:"on delete"},Ha={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"}},Ka={flow:e=>`flow "${e}"`,trigger:e=>`Apex trigger ${e}`,process:e=>`process "${e}"`,workflowRule:e=>`workflow rule "${e}"`},Ya={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 Ja(e){let t=e.guessed?" (guessed from the name of an Apex action)":"";return`${Xa[e.kind]} "${e.name}"${t}`}function Za(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 ed(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 td(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[Ha[t][e.when],...i.length>0?[`SENDS MESSAGES: ${i.map(Ja).join(", ")}`]:[],...s.length>0?[`then after commit: ${s.map(Za).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(ed),...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 ll(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=>`${Ka[g.kind](g.name)} (${td(g,l).join("; ")})`);r.push(` ${Qa[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(ln(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=un(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 we(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??Lr} at most`);for(let{part:s,reason:a}of e.unread)r.push(` ${Ya[s]} could not be read: ${a}`);return r.push(` read in ${e.requests} request(s) to ${t}`),r}export{ke as a,at as b,Td as c,Go as d,Od as e,Qn as f,Hn as g,Fd as h,Kn as i,vd as j,Nd as k,xd as l,Cd as m,Md as n,od as o,sd as p,id as q,jn as r,ad as s,_n as t,vo as u,dd as v,pd as w,md as x,Wn as y,hd as z,yd as A,Pr as B,Iu as C,ju as D,_u as E,Du as F,xi as G,Lu as H,Wu as I,Ci as J,Fr as K,Gu as L,Uu as M,qu as N,Vu as O,zu as P,Qu as Q,Hu as R,Ku as S,Yu as T,$r as U,vr as V,Di as W,Lr as X,Ie as Y,je as Z,Rt as _,At as $,sr as aa,Li as ba,Wi as ca,Gi as da,Ui as ea,qi as fa,Vi as ga,zi as ha,Nr as ia,Qi as ja,Hi as ka,Zi as la,ea as ma,ta as na,ul as oa,na as pa,ra as qa,oa as ra,sa,ia as ta,aa as ua,da as va,Ur as wa,qr as xa,Ra as ya,no as za,ro as Aa,_a as Ba,so as Ca,wt as Da,Ce as Ea,gt as Fa,Dr as Ga,Ua as Ha,qa as Ia,Va as Ja,ll as Ka,zd as La,Qd as Ma,zo as Na,Hd as Oa,ir as Pa,ut as Qa,Zo as Ra,es as Sa,Kd as Ta,Xn as Ua,rs as Va,Yd as Wa,Xd as Xa,Jd as Ya,is as Za,as as _a,Jn as $a,ds as ab,us as bb,cs as cb,dt as db,ne as eb,ps as fb,ms as gb,$e as hb,hs as ib,ys as jb,bs as kb,Zd as lb,ve as mb,Ts as nb,Os as ob,ks as pb,Ps as qb,Bs as rb,$s as sb,vs as tb,Ns as ub,xs as vb,Ms as wb,Is as xb,js as yb,fr as zb,_s as Ab,xe as Bb,Ds as Cb,Ls as Db,Ws as Eb,Gs as Fb,eu as Gb,Us as Hb,gr as Ib,qs as Jb,pr as Kb,ct as Lb,Vs as Mb,Hs as Nb,tu as Ob,nu as Pb,ti as Qb,mr as Rb,ni as Sb,ri as Tb,oi as Ub,si as Vb,ru as Wb,ii as Xb,ai as Yb,ou as Zb,su as _b,br as $b,iu as ac,au as bc,wr as cc,du as dc,uu as ec,lu as fc,mi as gc,cu as hc,fu as ic,gu as jc,pu as kc,mu as lc,L as mc,Er as nc,yi as oc,bi as pc,hu as qc,wi as rc,yu as sc,bu as tc,ie as uc,wu as vc,Ru as wc,V as xc,Au as yc,Su as zc,Si as Ac,Eu as Bc,Ei as Cc,Tu as Dc,ht as Ec,Ou as Fc,ku as Gc,Fu as Hc,Pu as Ic,Bu as Jc};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{c as N,e as C,f as F}from"./chunk-6KP6WETK.mjs";import{d as I,z as P}from"./chunk-J24TIGSI.mjs";import{b as O}from"./chunk-TQ2TQHTT.mjs";import{ma as $,ta as _}from"./chunk-ZQO5PDX5.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
|
+
`);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
|
+
`),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};
|
|
@@ -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{jd as u}from"./chunk-ZQO5PDX5.mjs";var m={BusinessHours:["Name"]},j=["DUPLICATE_VALUE","DUPLICATES_DETECTED","duplicate value found"];var A=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,P=/^[A-Za-z][A-Za-z0-9_]*$/;function l(e){return e.slice(0,15)}function g(e,r){let t=e.mapping.get(r);return typeof t=="string"&&A.test(t)?t:void 0}function f(e){let r=new Set((e.created??[]).flatMap(i=>i.referenceIds)),t=new Set;for(let i of e.mapping.keys()){if(r.has(i))continue;let n=g(e,i);n&&t.add(l(n))}return t}function h(e){let r=new Set((e.created??[]).flatMap(n=>n.referenceIds)),t=[...Object.entries(e.personContacts??{}),...Object.entries(e.withTheirRecord??{})];for(let n=!0;n;){n=!1;for(let[o,s]of t)r.has(o)||!r.has(s)||(r.add(o),n=!0)}let i=new Set;for(let[n]of t){let o=r.has(n)?g(e,n):void 0;o&&i.add(l(o))}return i}function b(e){let r=f(e),t=new Map;for(let{objectApiName:o,referenceIds:s}of e.created??[])P.test(o)&&t.set(o,[...t.get(o)??[],...s]);let i=new Set,n=[];for(let[o,s]of[...t].reverse()){let a=[];for(let y of[...s].reverse()){let c=g(e,y);if(!c)continue;let d=l(c);r.has(d)||i.has(d)||(i.add(d),a.push(c))}a.length>0&&n.push({objectApiName:o,ids:a})}return n}function p(e){return u(e.removal)?[]:b(e).filter(r=>!R(r.objectApiName))}function R(e){return Object.prototype.hasOwnProperty.call(m,e)}function k(e){return b(e).filter(r=>R(r.objectApiName)).map(({objectApiName:r,ids:t})=>({objectApiName:r,count:t.length}))}function I(e){return e.find(r=>p(r).length>0)??e[0]}function O(e,r){return e.filter(t=>t.endedAt!==r.endedAt&&t.created!==void 0&&p(t).length===0)}function v(e){let r=e.created!==void 0,t=h(e),i=[...f(e)].filter(o=>!t.has(o)),n=k(e);return{orgId:e.orgId,loadedAt:e.endedAt,created:p(e).map(({objectApiName:o,ids:s})=>({objectApiName:o,count:s.length})),linked:r?i.length:0,recorded:r,...e.removal?{removed:e.removal}:{},...e.earlier?{earlier:!0}:{},...n.length>0?{keptByThePlatform:n}:{}}}export{m as a,j as b,b as c,p as d,k as e,I as f,O as g,v as h};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{h as S,i as g,j as m,
|
|
7
|
+
import{h as S,i as g,j as m,v as R}from"./chunk-3SKLBRPL.mjs";var y=20,v="seed-runs",l="sandforge-seed",h=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function O(s,e){let t=s.finishedAt??new Date().toISOString();return{runId:s.runId,configId:l,configName:l,sourceOrgId:s.targetOrgId,targetOrgId:s.targetOrgId,startedAt:s.startedAt??t,end:{at:t,status:s.status},lastWrittenAt:t,created:s.objectResults.filter(d=>d.createdIds.length>0).map(d=>({objectApiName:d.objectApiName,ids:[...d.createdIds]})),...s.runUserId!==void 0&&h.test(s.runUserId)?{runUserId:s.runUserId}:{},...e?{removal:e}:{}}}function N(s,e){return new I(S(s,v,e))}var I=class{constructor(e,t=y){this.runs=e;this.max=t}runs;max;recorder(e){let t=this.runs.recorder({runId:e.runId,configId:l,configName:l,sourceOrgId:e.sourceOrgId??e.targetOrgId,targetOrgId:e.targetOrgId,...e.startedAt!==void 0?{startedAt:e.startedAt}:{},...e.origin!==void 0?{origin:e.origin}:{},...e.pipeline!==void 0?{pipeline:{name:e.pipeline.name.slice(0,m)}}:{},...e.targetOrganizationId!==void 0?{targetOrganizationId:e.targetOrganizationId}:{},...e.targetAlias!==void 0?{targetAlias:e.targetAlias}:{},...e.runUserId!==void 0&&h.test(e.runUserId)?{runUserId:e.runUserId}:{}}),d=new Set,u=n=>{let i=n.filter(r=>!d.has(r.slice(0,15)));for(let r of i)d.add(r.slice(0,15));return i},a=(n,i)=>{for(let r=0;r<n.length;r+=g)i(n.slice(r,r+g))},f=(n,i,r)=>a(u(i),o=>t.note(n,o,r)),c=new Map,p=!1;return{runId:e.runId,note:(n,i)=>f(n,i),sending:(n,i,r)=>{r?.job!==void 0?c.set(n,r.job):c.delete(n),t.sending?.(n,i,r)},answered:(n,i)=>{c.delete(n);let r=u(i);t.answered?.(n,r.slice(0,g)),a(r.slice(g),o=>t.note(n,o))},wroteAgain:(n,i)=>a(i.filter(r=>d.has(r.slice(0,15))),r=>t.note(n,r)),checkpoint:n=>t.checkpoint?.(n),runUser:n=>{p||t.runUser?.(n)},end:async n=>{let i=n.finishedAt??new Date().toISOString();for(let{objectApiName:o,createdIds:A}of n.objectResults)f(o,A,i);if(d.size===0&&c.size===0){p=!0,await t.flush(),await this.runs.forget(e.runId);return}await t.end({status:n.status,...n.cancelled?{cancelled:!0}:{},at:i});let r=await t.flush();if(r!==void 0)throw new Error(r);await this.keepTheLatest()}}}record(e){let t=e.startedAt??e.finishedAt;return this.recorder({runId:e.runId,targetOrgId:e.targetOrgId,...t!==void 0?{startedAt:t}:{},...e.runUserId!==void 0?{runUserId:e.runUserId}:{}}).end(e)}async keepTheLatest(){let e=(await this.runs.list()).filter(R),t=e.length-this.max;for(let d of[...e].reverse()){if(t<=0)return;await this.runs.forget(d.runId),t--}}pathOf(e){return this.runs.pathOf(e)}get storagePath(){return this.runs.storagePath}get(e){return this.runs.get(e)}list(){return this.runs.list()}answerInFlight(e,t,d,u,a){return this.runs.answerInFlight(e,t,d,u,a)}async updateRemoval(e,t){await this.runs.get(e)&&await this.runs.updateRemoval(e,t)}};export{y as a,v as b,O as c,N as d,I as e};
|
|
@@ -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}from"./chunk-
|
|
7
|
+
import{a,b,c,d}from"./chunk-C3LNYAVJ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as PARENT_IDS_PER_QUERY,a as readExistingParentIds,c as readPresentParentIds,d as recordParentsRefusals};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-H4OBZIX3.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as AGENT_CATALOG_API,b as AGENT_CATALOG_FIELDS,c as AGENT_TEST_NAME_FIELD,i as GUARD_TOPIC_NAMES,e as NO_AGENTFORCE_MESSAGE,d as NO_AGENT_MESSAGE,g as agentNamed,k as declaresVariable,h as proposedActions,j as proposedGuardTopic,f as readAgentCatalog};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{dc as P,hc as v,kc as S}from"./chunk-JFNLKHY6.mjs";import{a as A,b as E}from"./chunk-VV3B6IC3.mjs";import{b as R}from"./chunk-CA5NAXSU.mjs";import{Ed as m,Qd as h,Td as c}from"./chunk-ZQO5PDX5.mjs";import{b,f,k as w,l as p}from"./chunk-WZQEK4WT.mjs";var k="Messaging.reserveSingleEmailCapacity(1);",M="System.NoAccessException: The organization is not permitted to send email",x=`/tooling/executeAnonymous?anonymousBody=${encodeURIComponent(k)}`,I=`/query?q=${encodeURIComponent("SELECT PermissionsEmailSingle FROM UserPermissionAccess")}`,L=3e4,$=p({compiled:f(),success:f(),compileProblem:b().nullish(),exceptionMessage:b().nullish()}).loose(),O=p({records:w(p({PermissionsEmailSingle:f().optional()}).loose())}).loose(),V={reading:{unread:"SandForge runs no Apex in a production org"},requests:0};function U(e){return e%1e3===0?`${e/1e3} s`:`${e} ms`}function T(e,n){return e instanceof A?`the org did not answer within ${U(n)}`:`the org refused it: ${R(e)}`}function _(e){let n=$.safeParse(e);if(!n.success)return{unread:"its answer is not one anonymous Apex gives"};let{compiled:t,success:s,compileProblem:r,exceptionMessage:i}=n.data;if(!t)return{unread:`it did not compile${r?`: ${r}`:""}`};if(s)return{level:"all"};let a=i?.trim();return a===M?{refused:!0}:{unread:a?`the org answered: ${a}`:"it failed, and the org did not say why"}}async function Y(e,n={}){let t=n.timeoutMs??L,s=u=>new E(t).withTimeout("forge:deliverability",()=>e.request({method:"GET",url:u})),r;try{r=await s(x)}catch(u){return{reading:{unread:T(u,t)},requests:1}}let i=_(r);if(!("refused"in i))return{reading:i,requests:1};let a="so the org's refusal does not say how it is set",d;try{d=await s(I)}catch(u){return{reading:{unread:`whether the user the run writes as may send email could not be read (${T(u,t)}), ${a}`},requests:2}}let l=O.safeParse(d),o=l.success?l.data.records[0]?.PermissionsEmailSingle:void 0;return o===!0?{reading:{level:"withheld"},requests:2}:{reading:{unread:o===!1?`the user the run writes as may not send email (Send Email), ${a}`:`the org did not say whether the user the run writes as may send email, ${a}`},requests:2}}async function F(e){let n=m(e.running,{applyAssignmentRules:e.applyAssignmentRules,writes:e.writes}),t=P(e.running.automation.unread??[],{applyAssignmentRules:e.applyAssignmentRules===!0}),s=t!==void 0?{sendersUnread:t}:{};if(n.length===0&&t===void 0)return{senders:n};let r;try{r=await e.read()}catch(i){r={reading:{unread:R(i)},requests:1}}return{senders:n,...s,read:r}}function N(e,n={}){let t=i=>`${i.objectApiName}\0${i.kind}\0${i.name}`,s=m(c(e,void 0,n.writes),n),r=new Set(m(c(e,h(e,n.writes),n.writes),n).map(t));return s.filter(i=>!r.has(t(i)))}function q(e,n){let t=new Set([...n.assigned,...n.held]);return{assign:e.assign.filter(s=>t.has(s.permissionSet))}}var z=["flows","processes","workflowRules"];async function Q(e){let{plan:n,writes:t,applyAssignmentRules:s,read:r,target:i,run:a}=e,d=typeof r.unread=="string"?void 0:r,l=s===!0?{applyAssignmentRules:s}:{},o=await F({running:d?c(d,n,t):{automation:{objects:[],unread:z.map(y=>({part:y,reason:String(r.unread)}))},firing:[]},...l,writes:t,read:e.readDeliverability}),u=e.mayMute===!0&&n===void 0&&d!==void 0&&o.senders.length>0?N(d,{...l,writes:t}):[],g=o.read?.reading;return{ofRun:o,gate:v({senders:o.senders,...o.sendersUnread!==void 0?{sendersUnread:o.sendersUnread}:{},...g!==void 0?{reading:g}:{},accepted:e.accepted,target:i,run:a,muteQuiets:u,keepsAddresses:e.keepsAddresses===!0}),afterLease:(y,D)=>{if(!(n===void 0||d===void 0))return S({planned:o.senders,held:m(c(d,q(n,y),t),{...l,writes:t}),...g!==void 0?{reading:g}:{},accepted:D,target:i,run:a})}}}export{L as a,V as b,Y as c,F as d,N as e,q as f,Q as g};
|
|
@@ -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 O,f as dt,h as C}from"./chunk-TZE3Y7IQ.mjs";import{Bc as at}from"./chunk-ZQO5PDX5.mjs";var It="AccountContactRelation",D="EmailMessage",z="Task",tt="TaskRelation",B="EventRelation",j=200,en={ProductSellingModel:["SellingModelType","PricingTerm","PricingTermUnit"]},rn={objectApiName:"FeedItem",field:"Type",value:"CreateRecordEvent",parent:"ParentId"},X={FeedItem:[{field:"Type",value:"TrackedChange",noun:"tracked change"}],[tt]:[{field:"IsWhat",value:!0,noun:"what relation",from:"the task's WhatId"}],[B]:[{field:"IsWhat",value:!0,noun:"what relation",from:"the event's WhatId"}],EmailMessageRelation:[{noun:"email relation",from:"the email's addresses"}]};function Et(t,n){return X[t]?.find(e=>e.field===void 0||e.value!==void 0&&String(n[e.field])===String(e.value))}var ut=class{constructor(n=Et){this.rowsOf=n}rowsOf;reasons=new Map;byObject=new Map;leaveOut(n,e,r,o=[]){let i=this.reasons.get(e);if(i)return i;let s=this.reasonFor(n,r,o);if(!s)return;this.reasons.set(e,s);let d=this.byObject.get(n)??new Map,u=`${s.rows.field}=${s.rows.value}|${s.through??""}`,l=d.get(u)??{why:s,ids:new Set};return l.ids.add(e),d.set(u,l),this.byObject.set(n,d),s}keep(n,e,r=[]){return e.filter(o=>!this.leaveOut(n,String(o.Id),o,r))}has(n){return this.reasons.has(n)}counts(n){return(n===void 0?[...this.byObject]:[[n,this.byObject.get(n)]]).flatMap(([r,o])=>[...o?.values()??[]].map(({why:i,ids:s})=>({objectApiName:r,why:i,count:s.size})))}reasonFor(n,e,r){let o=this.rowsOf(n,e);if(o)return{rows:o};for(let i of r){let s=e[i],d=typeof s=="string"?this.reasons.get(s):void 0;if(d)return{rows:d.rows,through:i}}}};function on(t,n){if(n.through)return`${t} left out: ${n.through} names a ${n.rows.noun}, which the platform writes itself`;let e=n.rows.from?`, from ${n.rows.from}`:"";return`${t} ${n.rows.noun}${t===1?"":"s"} left out: the platform writes them itself${e}`}function sn(t,n){let e=`${t} record${t===1?"":"s"}`;return n.through?`${n.through} \u2192 ${n.rows.noun} (${e})`:n.rows.field===void 0?`every ${n.rows.noun} (${e})`:`${n.rows.field}=${String(n.rows.value)} (${e})`}function an(t){return t.through?`Not written: ${t.through} may not be left empty, and the ${t.rows.noun} it names is one the platform writes itself, which no copy sends.`:t.rows.from?`Not written: the platform writes each ${t.rows.noun} itself, from ${t.rows.from}.`:`Not written: the platform writes each ${t.rows.noun} itself, and refuses one a copy sends.`}function ct({field:t,value:n},e){if(t===void 0)return e==="="?"Id != null":"Id = null";let r=typeof n=="boolean"?String(n):`'${O(n??"")}'`;return`${C(t)} ${e} ${r}`}function dn(t,n,e){let r=s=>s.map(d=>ct(d,"=")).join(" OR "),o=(X[t]??[]).map(s=>ct(s,"!=")),i=n.flatMap(s=>s.referenceTo.flatMap(d=>{let u=X[d];if(d===t||!e.has(d)||!u||u.length===0)return[];let l=e.get(d),I=l?`(${dt(l)}) AND (${r(u)})`:`(${r(u)})`;return[`${C(s.name)} NOT IN (SELECT Id FROM ${C(d)} WHERE ${I})`]}));return[...o,...i]}var $t={[tt]:new Set(["Contact","Lead"]),[B]:new Set(["Contact","Lead","User","Calendar"])};function un(t,n,e){let r=$t[t];if(!r)return n;let o=n.IsWhat;return o!==""&&o!==null&&o!==void 0||e===void 0||r.has(e)?n:{...n,IsWhat:!0}}var Ct="500";function Pt(t){return t.startsWith(Ct)?"Case":void 0}function ht(t,n=Pt){let e=t.ParentId;if(typeof e=="string"&&e!=="")return!0;let r=t.RelatedToId;return typeof r=="string"&&r!==""&&n(r)==="Case"}function cn(t,n){return t===D&&!ht(n)?["ActivityId"]:[]}function fn(t){return!t.has(D)||!t.has(z)?[]:[{sourceObject:D,targetObject:z,relationshipName:`${D}Before${z}`,type:"lookup",required:!0}]}function ln(t,n){let e=t.ActivityId;return typeof e=="string"&&e!==""&&ht(t,n)}var S=200;async function gn(t,n){let e=new Map;for(let r=0;r<n.length;r+=S){let o=n.slice(r,r+S).map(s=>`'${O(s)}'`).join(", "),i=await t(`SELECT Id, ActivityId FROM ${D} WHERE Id IN (${o})`);for(let s of i){let d=s.ActivityId;typeof s.Id=="string"&&typeof d=="string"&&d!==""&&e.set(s.Id,d)}}return e}var L="Account",H="Contact",Q="PersonContactId",mt="IsPersonAccount";function kt(t){let n=t[mt];return n===!0||n==="true"||n===1}function pn(t,n){return kt(t)?n?"personAsBusiness":"person":"business"}function yn(t,n){return t==="person"?n==="person":n!=="person"}function Rn(t,n){return!t.has(L)||!t.has(H)?[]:n.get(L)?.some(r=>r.name===Q)===!0||n.get(H)?.some(r=>r.name===mt)===!0?[{sourceObject:L,targetObject:H,relationshipName:`${L}Before${H}`,type:"lookup",required:!0}]:[]}function Mt(t){let n=t.map(e=>`'${O(e)}'`).join(", ");return`SELECT Id, ${Q} FROM ${L} WHERE Id IN (${n})`}var At=new RegExp(`^SELECT Id, ${Q} FROM ${L} WHERE Id IN \\((.*)\\)$`);function wn(t){let n=At.exec(t);if(n)return[...n[1].matchAll(/'([^']*)'/g)].map(([,e])=>e)}async function In(t,n){let e=new Map;for(let r=0;r<n.length;r+=S){let o=await t(Mt(n.slice(r,r+S)));for(let i of o){let s=i[Q];typeof i.Id=="string"&&typeof s=="string"&&s!==""&&e.set(i.Id,s)}}return e}var v="OpportunityTeamMember",M="OpportunitySplit",Nt="Opportunity",Z="OpportunitySplitType",$="SplitTypeId",nt={[v]:"UserId",[M]:"SplitOwnerId"};function hn(t){return nt[t]!==void 0}function mn(t){return t==="Task"?"their email":t==="Contact"?"their person account":t===It?"their contact":t===Ot?"their opportunity, for its contact":"their opportunity, for its owner"}var Ot="OpportunityContactRole",Y="ContactId",ft=t=>t.IsPrimary===!0||t.IsPrimary==="true";function Lt(t,n){let e=new Map;return t.forEach((r,o)=>{let i=w(r,"OpportunityId"),s=w(r,Y);if(i===void 0||s===void 0)return;let d=n(i);if(d===void 0||y(d)!==y(s))return;let u=y(i),l=e.get(u);(l===void 0||!ft(t[l])&&ft(r))&&e.set(u,o)}),[...e.values()].sort((r,o)=>r-o)}var lt=["CreatedDate","CreatedById","Opportunity.CreatedDate","Opportunity.CreatedById"];function xt(t,n=[]){let e=["Id","OpportunityId",Y],r=[...e,...lt];return`SELECT ${[...e,...lt,...n.filter(i=>!r.includes(i)).map(C)].join(", ")} FROM ${Ot} WHERE OpportunityId IN ${et(t)} ORDER BY CreatedDate, Id`}var bt=/^SELECT Id, OpportunityId, ContactId, CreatedDate, CreatedById, Opportunity\.CreatedDate, Opportunity\.CreatedById((?:, \w+)*) FROM OpportunityContactRole WHERE OpportunityId IN (\(.*\)) ORDER BY CreatedDate, Id$/;function On(t){let n=bt.exec(t);if(!n)return;let[,e,r]=n;return{fields:e.split(", ").filter(o=>o!==""),opportunities:rt(r)}}async function _t(t,n,e=[]){let r=[];for(let o=0;o<n.length;o+=S)r.push(...await t(xt(n.slice(o,o+S),e)));return r}var Ft=1,gt=t=>typeof t=="string"&&t!==""?Math.floor(Date.parse(t)/1e3):Number.NaN;function Wt(t){let n=t.Opportunity;if(typeof n!="object"||n===null)return!1;let e=n,r=w(t,"CreatedById"),o=w(e,"CreatedById"),i=gt(t.CreatedDate),s=gt(e.CreatedDate);return r!==void 0&&o!==void 0&&y(r)===y(o)&&!Number.isNaN(i)&&!Number.isNaN(s)&&i-s>=0&&i-s<=Ft}function Dt(t,n){let e=new Map;for(let i of n){let s=w(i,"Id"),d=w(i,"OpportunityId"),u=w(i,Y);if(!s||!d||!u||!Wt(i))continue;let l=`${y(d)}:${y(u)}`;e.set(l,[...e.get(l)??[],i])}let r=new Map,o=[];for(let[i,{opportunity:s,contact:d}]of t){let u=e.get(`${y(s)}:${y(d)}`)??[];u.length>1?o.push(i):u.length===1&&r.set(i,u[0])}return{found:r,alike:o}}function Tn(t,n="read"){return`${t} contact role(s) not linked to the one the platform wrote with their opportunity, so written as ${n}: the target holds more than one role of their contact under it made with it, within a second, by the same user, and nothing tells which the platform wrote. The opportunity holds the role of its contact more than once.`}var vt="the user the run writes as";function Sn(t,n){let e={CreatedDate:n,CreatedById:vt};return{...t,...e,Opportunity:{...e}}}async function En(t,n,e,r=[]){let o=Lt(n,e);if(o.length===0)return{found:new Map,alike:[]};let i=new Map(o.map(d=>[d,{opportunity:String(n[d].OpportunityId),contact:String(n[d][Y])}])),s=await _t(t,[...new Set([...i.values()].map(({opportunity:d})=>d))],r);return Dt(i,s)}function $n(t){return!t.has(v)||!t.has(M)?[]:[{sourceObject:v,targetObject:M,relationshipName:`${v}Before${M}`,type:"lookup",required:!0}]}var Ut={[v]:{TeamMemberRole:"Opportunity Owner",OpportunityAccessLevel:"All"},[M]:{}},pt=t=>!/__c$/i.test(t),qt=new Set(["SplitPercentage","SplitAmount","CurrencyIsoCode"]),U=`SELECT Id, OwnerId FROM ${Nt} WHERE Id IN `,Kt=`SELECT Id, DeveloperName, IsTotalValidated FROM ${Z} WHERE IsActive = true`,et=t=>`(${t.map(n=>`'${O(n)}'`).join(", ")})`,rt=t=>[...t.matchAll(/'([^']*)'/g)].map(([,n])=>n);function Cn(t){return`${U}${et(t)}`}function Pn(t){if(!t.startsWith(U))return;let n=t.slice(U.length);return/^\(.*\)$/.test(n)?rt(n):void 0}function Tt(t,n){let e=nt[t];return`SELECT ${["Id","OpportunityId",...t===M?[e,$]:[e],...n].join(", ")} FROM ${t} WHERE OpportunityId IN `}function kn(t,n,e){return`${Tt(t,n)}${et(e)}`}var Ht=/^SELECT Id, OpportunityId, (?:UserId|SplitOwnerId, SplitTypeId)((?:, \w+)*) FROM (OpportunityTeamMember|OpportunitySplit) WHERE OpportunityId IN (\(.*\))$/;function Mn(t){let n=Ht.exec(t);if(!n)return;let[,e,r,o]=n;return{objectApiName:r,fields:e.split(", ").filter(i=>i!==""),opportunities:rt(o)}}var y=t=>t.slice(0,15);async function W(t,n,e){let r=[];for(let o=0;o<e.length;o+=S){let i=e.slice(o,o+S).map(s=>`'${O(s)}'`).join(", ");r.push(...await t(`${n}(${i})`))}return r}function J(t,n){let e=new Map;for(let r of t){let o=r[n];typeof r.Id=="string"&&typeof o=="string"&&o!==""&&e.set(y(r.Id),o)}return e}var w=(t,n)=>{let e=t[n];return typeof e=="string"&&e!==""?e:void 0};async function An(t,n,e){let r={lookups:new Map,linked:new Map,held:new Map,defaulted:new Set},o=nt[t];if(o===void 0)return r;let i=t===M,s=n.filter(a=>{let f=w(a,"OpportunityId");return f!==void 0&&e.targetIdOf(f)!==void 0});if(s.length===0)return r;let d=[...new Set(s.map(a=>String(a.OpportunityId)))],u=J(await W(e.source,U,d),"OwnerId"),l=a=>e.targetIdOf(String(a.OpportunityId)),I=[...new Set(s.map(l))],{simulated:T}=e,x=T?void 0:J(await W(e.target,U,I),"OwnerId"),b=a=>{let f=u.get(y(String(a.OpportunityId)));return f===void 0?{}:{source:f,target:T?T.ownerOf(f):x?.get(y(l(a)))}},_=a=>{let f=w(a,o),R=b(a).source;return f!==void 0&&R!==void 0&&y(f)===y(R)},A=[...new Set(s.flatMap(a=>{let f=w(a,o);return f===void 0||_(a)||e.mappedUser(f)!==void 0?[]:[f]}))],q=A.length>0?new Set((await W(e.target,"SELECT Id FROM User WHERE IsActive = true AND Id IN ",A)).flatMap(a=>typeof a.Id=="string"?[y(a.Id)]:[])):new Set,K=i?J(await W(e.source,`SELECT Id, DeveloperName FROM ${Z} WHERE Id IN `,[...new Set(s.flatMap(a=>w(a,$)??[]))]),"DeveloperName"):new Map,F=new Map;if(i)for(let a of await e.target(Kt))typeof a.Id=="string"&&typeof a.DeveloperName=="string"&&F.set(a.DeveloperName,{id:a.Id,total:a.IsTotalValidated===!0||a.IsTotalValidated==="true"});let c=(e.written??[]).filter(a=>a!=="Id"&&a!=="OpportunityId"&&a!==o&&a!==$&&!qt.has(a)),g=(a,f)=>{let R=a[f];return!(R==null||R===""||R===!1)},p=(a,f,R=c)=>R.filter(P=>g(a,P)&&String(a[P])!==String(f[P]??"")),m=new Map,h=(a,f,R)=>[a,f,R??""].map(y).join("|");if(!T)for(let a of await W(e.target,Tt(t,c),I)){let f=w(a,"OpportunityId"),R=w(a,o);typeof a.Id!="string"||f===void 0||R===void 0||m.set(h(f,R,i?w(a,$):void 0),a)}for(let a of s){let f=w(a,o);if(f===void 0)continue;let R=_(a),P=b(a).target,N=R?P:e.mappedUser(f)??(q.has(y(f))?f:void 0),ot=!R&&N===void 0&&e.defaultUser!==void 0;if(ot&&(N=e.defaultUser),N===void 0){r.held.set(a,{field:o,parentObject:"User",why:R?`${o} names the owner of its opportunity, whose owner in the target could not be read.`:`${o} names a user the target has no counterpart of: a team member and a split go in for the opportunity's owner, which is the owner of its copy in the target, for a user an owner mapping gives, or for a user of the same id the target holds active.`});continue}let G={[o]:N},it=!1;if(i){let E=w(a,$);if(E!==void 0){let k=K.get(y(E)),V=k===void 0?void 0:F.get(k);if(V===void 0){r.held.set(a,{field:$,parentObject:Z,why:`${$} names ${k===void 0?"a split type":`the split type ${k}`}, which the target holds no active one of by that name: sent without it, the split would go in as one of the Revenue type.`});continue}G[$]=V.id,it=V.total}}let St=l(a),st=P!==void 0&&y(N)===y(P);if(T){if(st&&(!i||it)){let E=c.filter(k=>!pt(k)&&g(a,k));r.linked.set(a,{id:T.idFor(),owners:!0,notKept:p(a,Ut[t]??{},c.filter(pt)),...E.length>0?{unread:E}:{}});continue}}else{let E=m.get(h(St,N,G[$]));if(E!==void 0){r.linked.set(a,{id:String(E.Id),owners:st,notKept:p(a,E)});continue}}r.lookups.set(a,G),ot&&r.defaulted.add(a)}return r}var jt={[tt]:"TaskId",[B]:"EventId"};async function Nn(t,n,e){let r=new Map,o=jt[n];if(o===void 0)return r;let i=[...new Set(e.map(d=>d[o]).filter(d=>typeof d=="string"&&d!==""))];if(i.length===0)return r;let s=new Map;for(let d=0;d<i.length;d+=S){let u=i.slice(d,d+S).map(I=>`'${O(I)}'`).join(", "),l=await t(`SELECT Id, ${o}, RelationId FROM ${n} WHERE ${o} IN (${u})`);for(let I of l)typeof I.Id=="string"&&s.set(`${String(I[o])}|${String(I.RelationId)}`,I.Id)}return e.forEach((d,u)=>{let l=s.get(`${String(d[o])}|${String(d.RelationId)}`);l&&r.set(u,l)}),r}var Bt={[B]:["IsInvitee"]},yt={IsInvitee:["Status","Response","RespondedDate"]},Rt="the run was cancelled before it was updated";async function Ln(t,n,e,r,o=()=>!1){return Qt(await Yt(t,n,e,r,o))}function Qt(t){if(!(t===void 0||t.size===0))return[...t].map(([n,e])=>`${e} linked without ${n}`).join(", ")}function xn(t,n){if(n.size===0)return t;let e=new Map(t??[]);for(let[r,o]of n)e.set(r,(e.get(r)??0)+o);return e}async function Yt(t,n,e,r,o=()=>!1){let i=Bt[t]??[],s=new Set(i.flatMap(c=>[c,...yt[c]??[]]).filter(c=>!e(c))),d=new Map,u=(c,g)=>{let p=`${c}: ${g}`;d.set(p,(d.get(p)??0)+1)},l=[];for(let[c,g]of n){let p={},m={};for(let h of i.filter(a=>String(c[a])==="true")){if(s.has(h)){u(h,"the target does not let it be updated");continue}p[h]=!0;for(let a of yt[h]??[]){let f=c[a];f==null||f===""||(s.has(a)?u(a,"the target does not let it be updated"):m[a]=f)}}Object.keys(p).length>0&&l.push({Id:g,flagsGiven:p,answer:m})}let I=!1,T=async c=>{let g=new Map;if(c.length===0)return g;if(o()){for(let h of c)g.set(h.Id,Rt);return g}if(I)return g;let p=await r(c);I=p.length<c.length;let m=o();return c.forEach((h,a)=>{let f=p[a];f?.success||g.set(h.Id,f===void 0&&m?Rt:`the target refused the update, ${f?.errors[0]??"without saying why"}`)}),g},x=(c,g)=>{for(let p of c){let m=g.get(p.Id);if(m!==void 0)for(let h of Object.keys(p).filter(a=>a!=="Id"))u(h,m)}},b=l.map(({Id:c,flagsGiven:g,answer:p})=>({Id:c,...g,...p})),_=await T(b),A=I||o()?[]:l.filter(({Id:c,answer:g})=>_.has(c)&&Object.keys(g).length>0);x(b.filter(c=>!A.some(({Id:g})=>g===c.Id)),_);let q=A.map(({Id:c,flagsGiven:g})=>({Id:c,...g})),K=await T(q);x(q,K);let F=A.filter(({Id:c})=>!K.has(c));for(let c of new Set(F.flatMap(({answer:g})=>Object.keys(g)))){let g=F.filter(({answer:p})=>c in p).map(({Id:p,answer:m})=>({Id:p,[c]:m[c]}));x(g,await T(g))}return d}var bn={Order:"OrderStatus",Contract:"ContractStatus"},_n=new Set(["Contract"]);function Gt(t){return t==null||t===""?"null":typeof t=="number"||typeof t=="boolean"?String(t):`'${O(String(t))}'`}async function Fn(t,n){let e=new Map,r=[...new Set(n.map(i=>i.ContactId).filter(i=>typeof i=="string"&&i!==""))];if(r.length===0)return e;let o=new Map;for(let i=0;i<r.length;i+=j){let s=r.slice(i,i+j).map(u=>`'${O(u)}'`).join(", "),d=await t(`SELECT Id, AccountId, ContactId FROM ${It} WHERE IsDirect = true AND ContactId IN (${s})`);for(let u of d)typeof u.Id=="string"&&o.set(`${String(u.AccountId)}|${String(u.ContactId)}`,u.Id)}return n.forEach((i,s)=>{let d=o.get(`${String(i.AccountId)}|${String(i.ContactId)}`);d&&e.set(s,d)}),e}async function Wn(t,n){let e=new Set;for(let r=0;r<n.length;r+=j){let o=n.slice(r,r+j).map(s=>`'${O(s)}'`).join(", "),i=await t(`SELECT Id FROM PricebookEntry WHERE Id IN (${o}) AND Pricebook2.IsStandard = true`);for(let s of i)typeof s.Id=="string"&&e.add(s.Id)}return e}var wt=200;async function Dn(t,n){let e=new Map,r=[...new Set(n.map(i=>i.Product2Id).filter(i=>typeof i=="string"&&i!==""))];if(r.length===0)return e;let o=new Map;for(let i=0;i<r.length;i+=wt){let s=r.slice(i,i+wt).map(u=>`'${O(u)}'`).join(", "),d=await t(`SELECT Id, Product2Id, ProductSellingModelId FROM ${at} WHERE Product2Id IN (${s})`);for(let u of d)typeof u.Id=="string"&&o.set(`${String(u.Product2Id)}|${String(u.ProductSellingModelId)}`,u.Id)}return n.forEach((i,s)=>{let d=o.get(`${String(i.Product2Id)}|${String(i.ProductSellingModelId)}`);d&&e.set(s,d)}),e}async function vn(t,n,e,r){let o=new Map;for(let i of r){let s=JSON.stringify(e.map(l=>i[l]??null));if(o.has(s))continue;let d=e.map(l=>`${C(l)} = ${Gt(i[l])}`).join(" AND "),u=await t(`SELECT Id FROM ${C(n)} WHERE ${d} LIMIT 2`);o.set(s,u.length===1&&typeof u[0].Id=="string"?u[0].Id:void 0)}return r.map(i=>o.get(JSON.stringify(e.map(s=>i[s]??null))))}async function Un(t,n){let e;try{e=await t(`SELECT ApiName, StatusCode FROM ${C(n)}`)}catch{return}return{categoryOf:new Map(e.map(r=>[String(r.ApiName),String(r.StatusCode)])),draft:e.filter(r=>r.StatusCode==="Draft").map(r=>String(r.ApiName)).sort()[0]}}function qn(t,n){if(typeof t!="string"||t===""||!n.draft)return;let e=n.categoryOf.get(t);if(!(e===void 0||e==="Draft"))return n.draft}export{It as a,D as b,z as c,en as d,rn as e,ut as f,on as g,sn as h,an as i,dn as j,un as k,ht as l,cn as m,fn as n,ln as o,gn as p,L as q,H as r,Q as s,kt as t,pn as u,yn as v,Rn as w,Mt as x,wn as y,In as z,v as A,M as B,nt as C,hn as D,mn as E,Ot as F,Y as G,ft as H,Lt as I,xt as J,On as K,_t as L,Dt as M,Tn as N,Sn as O,En as P,$n as Q,Ut as R,Kt as S,Cn as T,Pn as U,kn as V,Mn as W,An as X,jt as Y,Nn as Z,Bt as _,Ln as $,Qt as aa,xn as ba,Yt as ca,bn as da,_n as ea,Fn as fa,Wn as ga,Dn as ha,vn as ia,Un as ja,qn as ka};
|
|
@@ -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-NWOI25WY.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as AIDataGenerator,c as buildPrompt,d as parseAIResponse,b as phoneReplacement,e as reachNobody};
|