sandforge 1.81.0 → 1.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/bin/sandforge-users.mjs +12 -0
- package/lib/{chunk-J6G23RUI.mjs → chunk-262TP6UU.mjs} +1 -1
- package/lib/{chunk-NWVVCZUK.mjs → chunk-27BBEGUD.mjs} +1 -1
- package/lib/{chunk-Y5ZCPY36.mjs → chunk-2ADSD5WK.mjs} +1 -1
- package/lib/{chunk-55LQD3Y3.mjs → chunk-2GSMHGIV.mjs} +1 -1
- package/lib/chunk-2K5BYZQM.mjs +8 -0
- package/lib/{chunk-GK7VEYFM.mjs → chunk-2KTGDYUH.mjs} +1 -1
- package/lib/{chunk-T3PLRQ2T.mjs → chunk-2N73W63D.mjs} +1 -1
- package/lib/{chunk-7PK5QDQI.mjs → chunk-2R6GFNKF.mjs} +1 -1
- package/lib/{chunk-2OIRJEYE.mjs → chunk-2WMKJVD2.mjs} +1 -1
- package/lib/{chunk-D62KWDDT.mjs → chunk-36Y225OM.mjs} +1 -1
- package/lib/{chunk-HYOOJVR6.mjs → chunk-3CM7LAPE.mjs} +1 -1
- package/lib/{chunk-OIIL4NVI.mjs → chunk-3OVTKRS4.mjs} +1 -1
- package/lib/{chunk-UT27HXE7.mjs → chunk-3V4YH5KO.mjs} +1 -1
- package/lib/{chunk-OZNLOV4U.mjs → chunk-446GBKAC.mjs} +1 -1
- package/lib/{chunk-SQGP46QS.mjs → chunk-4GCYGQXD.mjs} +1 -1
- package/lib/{chunk-2NAIUKVL.mjs → chunk-4V3QO7HF.mjs} +1 -1
- package/lib/{chunk-GWRKS3AL.mjs → chunk-4X5D3MSV.mjs} +1 -1
- package/lib/{chunk-KGYXLSQ5.mjs → chunk-5OGNK3JP.mjs} +1 -1
- package/lib/{chunk-D7P7DTWL.mjs → chunk-6KOUYHEY.mjs} +1 -1
- package/lib/chunk-6QSHWIZI.mjs +48 -0
- package/lib/chunk-6VOQFISN.mjs +7 -0
- package/lib/{chunk-742SSN7I.mjs → chunk-6YC2ELCU.mjs} +1 -1
- package/lib/chunk-77IVKH7R.mjs +7 -0
- package/lib/{chunk-KNIRA333.mjs → chunk-77MZRBWX.mjs} +1 -1
- package/lib/{chunk-ZUA5BNAO.mjs → chunk-7BQMBXKX.mjs} +1 -1
- package/lib/{chunk-OQQHNYR7.mjs → chunk-7DPHZWA4.mjs} +2 -2
- package/lib/chunk-7V2UYZ6S.mjs +7 -0
- package/lib/chunk-7WSQ65WG.mjs +9 -0
- package/lib/{chunk-HVC5CYIB.mjs → chunk-7ZBDACVG.mjs} +1 -1
- package/lib/chunk-A32ISQ6M.mjs +28 -0
- package/lib/{chunk-XC2QKQT5.mjs → chunk-AG24QMSY.mjs} +1 -1
- package/lib/{chunk-K77NR3UK.mjs → chunk-AHUGG3WU.mjs} +1 -1
- package/lib/{chunk-K55LH4ZQ.mjs → chunk-ALBY5SOH.mjs} +1 -1
- package/lib/chunk-AXFD2OH6.mjs +7 -0
- package/lib/{chunk-YCSFP6ER.mjs → chunk-BH76USTQ.mjs} +1 -1
- package/lib/chunk-BNKT3R3F.mjs +7 -0
- package/lib/{chunk-YIGFYZQY.mjs → chunk-BPHTA6KP.mjs} +1 -1
- package/lib/{chunk-MNITSYI2.mjs → chunk-BT43WSOS.mjs} +1 -1
- package/lib/{chunk-ZWZXQTAK.mjs → chunk-BVZ5H3N4.mjs} +14 -14
- package/lib/{chunk-43K2C6H2.mjs → chunk-C6RKM4BB.mjs} +1 -1
- package/lib/{chunk-C4YGSK6W.mjs → chunk-CDWZGQAJ.mjs} +1 -1
- package/lib/chunk-CGZGL6VT.mjs +7 -0
- package/lib/{chunk-KE2PGD6C.mjs → chunk-CN5HGFG4.mjs} +1 -1
- package/lib/chunk-CQAFVEKP.mjs +13 -0
- package/lib/{chunk-XIZ5LMQM.mjs → chunk-CTPLYUXA.mjs} +1 -1
- package/lib/chunk-CXKZ6TYV.mjs +9 -0
- package/lib/{chunk-DHIW4IO5.mjs → chunk-D6JT4PAB.mjs} +1 -1
- package/lib/{chunk-AELFEK3G.mjs → chunk-D7XUNWWU.mjs} +1 -1
- package/lib/{chunk-GR3NGDVM.mjs → chunk-DB5RVDC5.mjs} +1 -1
- package/lib/{chunk-MO3N5XVV.mjs → chunk-DIGUC7S4.mjs} +2 -2
- package/lib/{chunk-2OZG6GRW.mjs → chunk-DKDKCGXV.mjs} +1 -1
- package/lib/chunk-DMT5SCO3.mjs +7 -0
- package/lib/chunk-DNQKVCUV.mjs +475 -0
- package/lib/{chunk-MAHZMPMZ.mjs → chunk-DSR2MSBH.mjs} +1 -1
- package/lib/{chunk-O6ADMP36.mjs → chunk-E3RQ575Y.mjs} +1 -1
- package/lib/{chunk-ETT5GP4P.mjs → chunk-EOQON3E5.mjs} +1 -1
- package/lib/{chunk-TKQQVB2D.mjs → chunk-ETNQHIDI.mjs} +1 -1
- package/lib/chunk-F5SBGJWW.mjs +7 -0
- package/lib/chunk-FBXH4VRQ.mjs +7 -0
- package/lib/chunk-FKCIGJOI.mjs +15 -0
- package/lib/{chunk-OVOLG3AL.mjs → chunk-FVLFO2S6.mjs} +1 -1
- package/lib/{chunk-YOGMP72T.mjs → chunk-FYWNSMOZ.mjs} +1 -1
- package/lib/{chunk-DHGPDSXS.mjs → chunk-GEEWPTV5.mjs} +1 -1
- package/lib/{chunk-FSDO4DJA.mjs → chunk-GLN4PI5P.mjs} +1 -1
- package/lib/{chunk-PYUEHBA6.mjs → chunk-GT5ZKU6V.mjs} +1 -1
- package/lib/chunk-GTRU5AV5.mjs +7 -0
- package/lib/chunk-H33DVU3D.mjs +7 -0
- package/lib/{chunk-5WGA5CZB.mjs → chunk-H4OBZIX3.mjs} +1 -1
- package/lib/{chunk-4L7FBOJS.mjs → chunk-HQZUQXDC.mjs} +1 -1
- package/lib/{chunk-VSU74RQ3.mjs → chunk-HVX2AFYW.mjs} +1 -1
- package/lib/chunk-I3ZO76LL.mjs +21 -0
- package/lib/{chunk-V4RKM4QZ.mjs → chunk-I5C4O3VA.mjs} +1 -1
- package/lib/{chunk-FSZTXLNW.mjs → chunk-IHGYJZZ2.mjs} +1 -1
- package/lib/chunk-ISA2NYJV.mjs +7 -0
- package/lib/{chunk-2IB7I3IQ.mjs → chunk-ISAUCWYK.mjs} +1 -1
- package/lib/{chunk-3B5H24ZG.mjs → chunk-ISOSTAJR.mjs} +1 -1
- package/lib/chunk-IXIY6Q4M.mjs +7 -0
- package/lib/{chunk-TPHXRHOA.mjs → chunk-J3TIHLWG.mjs} +1 -1
- package/lib/{chunk-TQM2XJ27.mjs → chunk-JAV6F6OA.mjs} +1 -1
- package/lib/chunk-JBWJ6UEZ.mjs +7 -0
- package/lib/{chunk-WM5JI4JI.mjs → chunk-JH4ZTVQN.mjs} +1 -1
- package/lib/{chunk-BZFIOZS3.mjs → chunk-JIPT5FUD.mjs} +1 -1
- package/lib/{chunk-6FMLW7PH.mjs → chunk-JPEVIXNH.mjs} +1 -1
- package/lib/{chunk-67CC7RAE.mjs → chunk-JREKJO3D.mjs} +1 -1
- package/lib/{chunk-3AOKLIVE.mjs → chunk-JUOQUG7U.mjs} +1 -1
- package/lib/chunk-JYUMD357.mjs +7 -0
- package/lib/{chunk-56MPPWLA.mjs → chunk-K7G3W7XH.mjs} +1 -1
- package/lib/{chunk-OU5W7SCB.mjs → chunk-KKS2KFBT.mjs} +1 -1
- package/lib/{chunk-RKALOKAU.mjs → chunk-KWAVSZ2B.mjs} +1 -1
- package/lib/{chunk-WI4HYWV6.mjs → chunk-KXUOHACP.mjs} +1 -1
- package/lib/{chunk-GTIXJCGS.mjs → chunk-L3I6DAHX.mjs} +1 -1
- package/lib/{chunk-FLNLG43R.mjs → chunk-L47JCNP3.mjs} +1 -1
- package/lib/{chunk-5344TZBT.mjs → chunk-L4MSL4U7.mjs} +1 -1
- package/lib/chunk-L4RJX7DG.mjs +7 -0
- package/lib/chunk-L6CLN664.mjs +7 -0
- package/lib/chunk-LI2XNV7F.mjs +7 -0
- package/lib/chunk-LP2D3JJP.mjs +7 -0
- package/lib/{chunk-EH5YUA5W.mjs → chunk-LWES2KZE.mjs} +1 -1
- package/lib/{chunk-YJEXE6HZ.mjs → chunk-LYOGCIYD.mjs} +2 -2
- package/lib/{chunk-BNO5GIJ6.mjs → chunk-MJD6CPZZ.mjs} +1 -1
- package/lib/{chunk-33ZX3A56.mjs → chunk-MTM4KG3T.mjs} +1 -1
- package/lib/{chunk-E2YJVSX6.mjs → chunk-N2HYG3BL.mjs} +1 -1
- package/lib/chunk-N5UIE4IR.mjs +7 -0
- package/lib/{chunk-R6TF26V4.mjs → chunk-NDFFIJL5.mjs} +1 -1
- package/lib/{chunk-FDGFUEK3.mjs → chunk-NFEBX75O.mjs} +1 -1
- package/lib/{chunk-QXLZINZB.mjs → chunk-NNV7IGM7.mjs} +1 -1
- package/lib/{chunk-OXKZ4Y3B.mjs → chunk-NS6ONPWL.mjs} +1 -1
- package/lib/{chunk-OEHVAJAB.mjs → chunk-O7GCCRPW.mjs} +1 -1
- package/lib/chunk-OO24ZYYJ.mjs +7 -0
- package/lib/chunk-OOIDCHBQ.mjs +9 -0
- package/lib/{chunk-MWLFFVQV.mjs → chunk-OS5GE52G.mjs} +1 -1
- package/lib/chunk-OS6HFJ7L.mjs +7 -0
- package/lib/{chunk-HYBH5PFM.mjs → chunk-OTJH6AEA.mjs} +1 -1
- package/lib/chunk-OUU47Y7A.mjs +7 -0
- package/lib/{chunk-FTA5LOVX.mjs → chunk-P6WRYJN3.mjs} +1 -1
- package/lib/{chunk-DXOXLUZA.mjs → chunk-PDRXM5WN.mjs} +1 -1
- package/lib/chunk-PGRY365W.mjs +7 -0
- package/lib/chunk-Q4PPI3KG.mjs +7 -0
- package/lib/chunk-QFTF2PGS.mjs +21 -0
- package/lib/chunk-QKJXIY6L.mjs +7 -0
- package/lib/{chunk-DMBR24CK.mjs → chunk-QLRWU3MB.mjs} +1 -1
- package/lib/chunk-QO4MPHZD.mjs +7 -0
- package/lib/chunk-QP3JLFIO.mjs +7 -0
- package/lib/{chunk-UCHAZ4ZU.mjs → chunk-QQDZQCO2.mjs} +1 -1
- package/lib/chunk-QROPNEGY.mjs +14 -0
- package/lib/{chunk-6NADW3OI.mjs → chunk-QXB6U3ZP.mjs} +1 -1
- package/lib/chunk-R3OM3X4L.mjs +8 -0
- package/lib/chunk-R7GKMAT4.mjs +7 -0
- package/lib/{chunk-JU2XEKEO.mjs → chunk-RVCPQVKM.mjs} +1 -1
- package/lib/{chunk-WEZLXE34.mjs → chunk-RZKJQOOC.mjs} +1 -1
- package/lib/chunk-S4PRKKGC.mjs +8 -0
- package/lib/{chunk-NJ3EOEHS.mjs → chunk-SX6QWYCQ.mjs} +1 -1
- package/lib/{chunk-ONMBSACW.mjs → chunk-T36DZJPH.mjs} +1 -1
- package/lib/{chunk-AJPSGVMD.mjs → chunk-T7DDS4UQ.mjs} +1 -1
- package/lib/chunk-TCEXCHXR.mjs +7 -0
- package/lib/chunk-TMIESDE5.mjs +7 -0
- package/lib/chunk-TQJ5NPRC.mjs +7 -0
- package/lib/chunk-TUPZY2QJ.mjs +7 -0
- package/lib/{chunk-2Z54GB6X.mjs → chunk-U2CTKIPE.mjs} +1 -1
- package/lib/{chunk-DQR5NDMI.mjs → chunk-U4YFYSF3.mjs} +1 -1
- package/lib/{chunk-EOSEMFPU.mjs → chunk-UIR77ZJD.mjs} +1 -1
- package/lib/{chunk-UUSLTW5V.mjs → chunk-UOHZW2L4.mjs} +1 -1
- package/lib/chunk-UV74P4H2.mjs +7 -0
- package/lib/{chunk-CULAOP3U.mjs → chunk-VXZ5PTOM.mjs} +1 -1
- package/lib/{chunk-IBURU7T7.mjs → chunk-VZLJZEV2.mjs} +1 -1
- package/lib/chunk-W3BQGMTR.mjs +7 -0
- package/lib/{chunk-WWTXRWNZ.mjs → chunk-WABXKL4N.mjs} +1 -1
- package/lib/{chunk-E2OBAWSH.mjs → chunk-WAYQLQAD.mjs} +1 -1
- package/lib/{chunk-6CDIIFNX.mjs → chunk-WBELLGNE.mjs} +1 -1
- package/lib/{chunk-LO527YLT.mjs → chunk-WJAZ5LHL.mjs} +1 -1
- package/lib/{chunk-6IGEASOF.mjs → chunk-WXU6ZJIV.mjs} +1 -1
- package/lib/{chunk-YHIOS2PU.mjs → chunk-WZN36ACK.mjs} +1 -1
- package/lib/{chunk-AITNZWLB.mjs → chunk-X2XZQ434.mjs} +1 -1
- package/lib/chunk-X4HZD5U2.mjs +7 -0
- package/lib/chunk-X6XNTOGO.mjs +7 -0
- package/lib/{chunk-5VQNKDFU.mjs → chunk-XAMMIPZ4.mjs} +1 -1
- package/lib/{chunk-MHW6DV6T.mjs → chunk-XAUQXYPW.mjs} +1 -1
- package/lib/{chunk-5UT2ZBGF.mjs → chunk-XCJUNX63.mjs} +1 -1
- package/lib/chunk-XJICAOAQ.mjs +7 -0
- package/lib/{chunk-GYKNCYES.mjs → chunk-XKFHTBAB.mjs} +1 -1
- package/lib/{chunk-6SEDOIO3.mjs → chunk-XMQ5R6TC.mjs} +1 -1
- package/lib/chunk-XPXEQKLR.mjs +7 -0
- package/lib/{chunk-SW2NUKQL.mjs → chunk-Y7YUNRKK.mjs} +1 -1
- package/lib/{chunk-UIUPPEFB.mjs → chunk-YBZIDW6W.mjs} +1 -1
- package/lib/{chunk-X2ZVSQ54.mjs → chunk-YEVB7LVK.mjs} +1 -1
- package/lib/{chunk-EAFLDSQ2.mjs → chunk-Z3MGN42K.mjs} +1 -1
- package/lib/{chunk-MKNAZPOT.mjs → chunk-ZB5E7NHU.mjs} +1 -1
- package/lib/chunk-ZCOSME6P.mjs +7 -0
- package/lib/{chunk-KRNFVAGC.mjs → chunk-ZOSESZ22.mjs} +1 -1
- package/lib/chunk-ZTHC42X6.mjs +7 -0
- package/lib/{chunk-XEB6HZ34.mjs → chunk-ZXOUWHYE.mjs} +1 -1
- package/lib/sandforge-autopilot.mjs +1 -1
- package/lib/sandforge-backup.mjs +1 -1
- package/lib/sandforge-checkpoint.mjs +1 -1
- package/lib/sandforge-cleanup.mjs +1 -1
- package/lib/sandforge-clone.mjs +1 -1
- package/lib/sandforge-compare.mjs +1 -1
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +4 -4
- package/lib/sandforge-env.mjs +184 -139
- package/lib/sandforge-frozen.mjs +1 -1
- package/lib/sandforge-mcp.mjs +14 -14
- package/lib/sandforge-monitor.mjs +1 -1
- package/lib/sandforge-pipeline.mjs +1 -1
- package/lib/sandforge-seed.mjs +1 -1
- package/lib/sandforge-sync.mjs +1 -1
- package/lib/sandforge-users.mjs +155 -0
- package/lib/sandforge.mjs +1 -22
- package/lib/sf/sandforge/autopilot.mjs +20 -0
- package/lib/sf/sandforge/backup.mjs +20 -0
- package/lib/sf/sandforge/checkpoint.mjs +20 -0
- package/lib/sf/sandforge/cleanup.mjs +20 -0
- package/lib/sf/sandforge/clone.mjs +20 -0
- package/lib/sf/sandforge/compare.mjs +20 -0
- package/lib/sf/sandforge/dataops.mjs +20 -0
- package/lib/sf/sandforge/empty.mjs +20 -0
- package/lib/sf/sandforge/env.mjs +20 -0
- package/lib/sf/sandforge/frozen.mjs +20 -0
- package/lib/sf/sandforge/hardis-commands.mjs +20 -0
- package/lib/sf/sandforge/index.mjs +20 -0
- package/lib/sf/sandforge/mcp.mjs +20 -0
- package/lib/sf/sandforge/monitor.mjs +20 -0
- package/lib/sf/sandforge/pipeline.mjs +20 -0
- package/lib/sf/sandforge/seed.mjs +20 -0
- package/lib/sf/sandforge/sync.mjs +20 -0
- package/lib/sf/sandforge/users.mjs +20 -0
- package/lib/sfHelpHook.mjs +7 -0
- package/lib/sfPlugin.mjs +11 -0
- package/oclif.manifest.json +1 -0
- package/package.json +17 -3
- package/lib/chunk-2ZMGVBLW.mjs +0 -7
- package/lib/chunk-5C5XEVZN.mjs +0 -11
- package/lib/chunk-5CKWGZX4.mjs +0 -9
- package/lib/chunk-5ZKCLBTN.mjs +0 -474
- package/lib/chunk-7DALDJMO.mjs +0 -7
- package/lib/chunk-CAFUNR6D.mjs +0 -7
- package/lib/chunk-DPYTG6DM.mjs +0 -48
- package/lib/chunk-G4VXPS3A.mjs +0 -7
- package/lib/chunk-GF247DA7.mjs +0 -7
- package/lib/chunk-IKGHRYCN.mjs +0 -7
- package/lib/chunk-IM2XA6JI.mjs +0 -7
- package/lib/chunk-K5HV4YRO.mjs +0 -7
- package/lib/chunk-KOQV4WXC.mjs +0 -8
- package/lib/chunk-N6HHNR6J.mjs +0 -7
- package/lib/chunk-N7J6NJQ6.mjs +0 -7
- package/lib/chunk-NWPQF5XR.mjs +0 -7
- package/lib/chunk-O7DAFE6M.mjs +0 -14
- package/lib/chunk-OMZJ37JI.mjs +0 -15
- package/lib/chunk-R2BJWO5N.mjs +0 -20
- package/lib/chunk-T26C576X.mjs +0 -9
- package/lib/chunk-T5VAULLQ.mjs +0 -7
- package/lib/chunk-V2QO6KOE.mjs +0 -19
- package/lib/chunk-V473C7LY.mjs +0 -7
- package/lib/chunk-W2AAGIZF.mjs +0 -7
- package/lib/chunk-WD47PGUS.mjs +0 -10
- package/lib/chunk-XC54KKKC.mjs +0 -7
- package/lib/chunk-XGKSSCW7.mjs +0 -7
- package/lib/chunk-ZWCRWF7E.mjs +0 -7
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{d as ae}from"./chunk-PDRXM5WN.mjs";import{b as F,d as B}from"./chunk-UV74P4H2.mjs";import{H as ne,d as te,k as E,z as re}from"./chunk-N2HYG3BL.mjs";import{Ra as J,Ua as Z,cb as q}from"./chunk-6QSHWIZI.mjs";import{b as l,e as h,i as X,k as I,l as f,r as Q,s as T,u as _,v as x,z as ee}from"./chunk-WZQEK4WT.mjs";import{randomBytes as _e}from"node:crypto";import{open as Je,readFile as Be,readdir as De,rename as $e,rm as Ue,stat as Ge}from"node:fs/promises";import{homedir as We}from"node:os";import{join as k,resolve as Ze}from"node:path";import*as L from"node:fs";import*as D from"node:path";function Ie(n){return`counting-contract.${F(n)}.json`}function K(n,e,t){return n.assertOutsideRepo(D.join(e,Ie(t)))}function Qe(n,e,t){let r=K(n,e,t.orgId);return L.mkdirSync(D.dirname(r),{recursive:!0}),L.writeFileSync(r,`${JSON.stringify(t,null,2)}
|
|
8
|
+
`,"utf8"),r}function et(n,e){let t=n.assertOutsideRepo(e),r=JSON.parse(L.readFileSync(t,"utf8"));if(r.version!==1||typeof r.objects!="object"||r.objects===null)throw new Error(`Invalid counting contract at ${t}: version 1 with objects expected`);return r}function tt(n,e){if(n.loadStartedAt!==void 0)return n.loadStartedAt===e.startedAt;let t=Date.parse(n.writtenAt),r=Date.parse(e.endedAt);return Number.isFinite(t)&&Number.isFinite(r)&&t>=r}import*as w from"node:fs/promises";import*as O from"node:path";var it=4*1024*1024,ot=64*1024*1024;var oe=1e4,M=l().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/),b=l().min(1).max(40),st=f({forgeId:l().min(1).max(200),targetOrgId:l().min(1).max(128),timestamp:b,duration:h().nonnegative(),status:_(["success","partial","failure"]),cancelled:x(!0).optional(),writtenBetween:f({first:b,last:b}).optional(),retryOf:l().min(1).max(200).optional(),objects:I(f({objectApiName:l().regex(/^[A-Za-z][A-Za-z0-9_]*$/),ids:I(M)})),linked:h().int().nonnegative(),mayHaveBeenWritten:h().int().nonnegative().optional(),undo:f({removedAt:b,deleted:h().int().nonnegative(),alreadyGone:h().int().nonnegative(),kept:h().int().nonnegative(),refused:h().int().nonnegative(),notReached:h().int().nonnegative().optional(),notVisible:h().int().nonnegative().optional()}).optional(),removalStamps:T(M,b).optional(),removalSpans:I(f({first:b,last:b,userId:M})).optional(),removalLeft:I(M).optional(),sweep:f({sweptAt:b,deleted:h().int().nonnegative(),keptChanged:h().int().nonnegative(),refused:h().int().nonnegative()}).optional(),inJournal:f({journalId:l().min(1).max(200),part:h().int().nonnegative(),left:I(f({objectApiName:l().regex(/^[A-Za-z][A-Za-z0-9_]*$/),count:h().int().nonnegative()}))}).optional()}),dt=f({version:x(1),plans:I(X())}),ct=f({version:x(1),runs:I(f({forgeId:l().min(1).max(300),ids:I(M),late:I(M).optional()}))});var U="referenceid-mapping.json",ze=/^referenceid-mapping\.([A-Za-z0-9_-]{1,128})\.json$/,Re=/^referenceid-mapping\.([A-Za-z0-9_-]{1,128})\.load-\d{1,16}\.ndjson$/,N=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,V=new Set;function ve(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var Se=f({at:l().min(1).max(40),object:l().regex(/^[A-Za-z][A-Za-z0-9_]{0,79}$/),created:I(Q([l().min(1).max(400),l().regex(N)])).max(1e4)}),Oe=f({journal:f({startedAt:l().min(1).max(40),pid:h().int().positive(),runUserId:l().regex(N).optional()})});function be(n){let e,t={},r=new Map,o;for(let a of n.split(`
|
|
9
|
+
`)){if(a.trim()==="")continue;let s;try{s=JSON.parse(a)}catch{continue}if(!e){let c=Oe.safeParse(s);c.success&&(e=c.data.journal);continue}let i=Se.safeParse(s);if(!i.success)continue;let d=r.get(i.data.object)??[];for(let[c,u]of i.data.created)Object.prototype.hasOwnProperty.call(t,c)||d.push(c),t[c]=u;r.set(i.data.object,d),o=i.data.at}if(!(!e||o===void 0||Object.keys(t).length===0))return{startedAt:e.startedAt,pid:e.pid,load:{updatedAt:o,mapping:t,created:[...r].filter(([,a])=>a.length>0).map(([a,s])=>({objectApiName:a,referenceIds:s})),load:{startedAt:e.startedAt,endedAt:o},...e.runUserId?{runUserId:e.runUserId}:{}}}}function je(n){return`referenceid-mapping.${F(n)}.json`}async function $(n){let e;try{e=await w.readFile(n,"utf8")}catch(t){if(t.code==="ENOENT")return;throw t}return JSON.parse(e)}async function pe(n,e){let t=e.assertOutsideRepo(n),r;try{r=await w.readdir(t)}catch(a){if(a.code==="ENOENT")return[];throw a}let o=new Set(r.flatMap(a=>ze.exec(a)?.[1]??Re.exec(a)?.[1]??[]));if(r.includes(U)){let s=(await $(e.assertOutsideRepo(O.join(t,U))))?.orgId;typeof s=="string"&&Ae(s)&&o.add(s)}return[...o].sort()}function Ae(n){try{return F(n),!0}catch{return!1}}var Ee=I(f({objectApiName:l(),referenceIds:I(l())})),ke=f({startedAt:l(),endedAt:l()}),xe=f({first:l(),last:l()}),Fe=f({removedAt:l(),deleted:h(),alreadyGone:h(),kept:h(),refused:h(),notReached:h().optional()}),Le=T(l(),l()),Me=I(f({first:l(),last:l(),userId:l()})),se=T(l(),l()),Y=l().regex(N);function R(n,e){let t=n.safeParse(e);return t.success?t.data:void 0}function S(n){if(typeof n!="object"||n===null)return;let e=n,t=typeof e.mapping=="object"&&e.mapping!==null?Object.fromEntries(Object.entries(e.mapping).filter(m=>typeof m[1]=="string")):{},r=R(Ee,e.created),o=R(ke,e.load),a=R(xe,e.writtenBetween),s=R(Fe,e.removal),i=R(Le,e.removalStamps),d=R(Me,e.removalSpans),c=R(se,e.personContacts),u=R(se,e.withTheirRecord),g=R(Y,e.runUserId),p=R(I(Y),e.madeEarlier),P=R(I(Y),e.lateEarlier);return{updatedAt:typeof e.updatedAt=="string"?e.updatedAt:"",mapping:t,...r?{created:r}:{},...o?{load:o}:{},...a?{writtenBetween:a}:{},...s?{removal:s}:{},...i?{removalStamps:i}:{},...d?{removalSpans:d}:{},...c?{personContacts:c}:{},...u?{withTheirRecord:u}:{},...g?{runUserId:g}:{},...p?{madeEarlier:p}:{},...P?{lateEarlier:P}:{}}}function j(n){return Array.isArray(n.earlier)?n.earlier.flatMap(e=>S(e)??[]):[]}function A(n){return n.load?.endedAt??n.updatedAt}function Ne(n,e){return n.slice(0,15)===e.slice(0,15)}function v(n){return n.slice(0,15)}function de(n,e){let t={};for(let[r,o]of Object.entries(n??{}))Object.prototype.hasOwnProperty.call(e,o)?Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=o):delete e[r];return t}function ce(n,e){if(e.size===0)return n;let t=Object.fromEntries(Object.entries(n.mapping).filter(([,d])=>!e.has(v(d)))),r=de(n.personContacts,t),o=de(n.withTheirRecord,t),a=n.created?.map(({objectApiName:d,referenceIds:c})=>({objectApiName:d,referenceIds:c.filter(u=>Object.prototype.hasOwnProperty.call(t,u))})).filter(d=>d.referenceIds.length>0),s=Object.fromEntries(Object.entries(n.removalStamps??{}).filter(([d])=>!e.has(v(d)))),i={...n,mapping:t};return delete i.removalStamps,delete i.personContacts,delete i.withTheirRecord,{...i,...a?{created:a}:{},...Object.keys(s).length>0?{removalStamps:s}:{},...Object.keys(r).length>0?{personContacts:r}:{},...Object.keys(o).length>0?{withTheirRecord:o}:{}}}function le(n){return n.created?n.created.some(e=>e.referenceIds.length>0):Object.keys(n.mapping).length>0}var G=class{constructor(e,t){this.sasDir=e;this.guard=t?.guard??new B,this.orgId=t?.orgId??"";let r=t?.organizationId;this.askOrganizationId=typeof r=="function"?r:async()=>r,this.now=t?.now??(()=>new Date)}sasDir;guard;orgId;askOrganizationId;organizationId;now;get filePath(){return this.guard.assertOutsideRepo(O.join(this.sasDir,this.orgId===""?U:je(this.orgId)))}get singleFilePath(){return this.orgId===""?void 0:this.guard.assertOutsideRepo(O.join(this.sasDir,U))}get journalStem(){return this.orgId===""?"referenceid-mapping":`referenceid-mapping.${F(this.orgId)}`}journalPath(e){let t=typeof e=="string"?Date.parse(e):e.getTime();return this.guard.assertOutsideRepo(O.join(this.sasDir,`${this.journalStem}.load-${Math.max(0,Math.trunc(t))}.ndjson`))}retiring=new Map;journal(e){let t=this.journalPath(e),r=!1,o=!1,a=!1,s,i=Promise.resolve(),d;V.add(t);let c=g=>{i=i.then(async()=>{if(!(d!==void 0||o))try{if(!r){r=!0,await w.mkdir(O.dirname(t),{recursive:!0});let p={journal:{startedAt:e.toISOString(),pid:process.pid,...s?{runUserId:s}:{}}};await w.appendFile(t,`${JSON.stringify(p)}
|
|
10
|
+
`,"utf8")}await w.appendFile(t,`${JSON.stringify(g)}
|
|
11
|
+
`,"utf8")}catch(p){d=p instanceof Error?p.message:String(p)}})},u=async()=>{await i,o=!0,await w.rm(t,{force:!0})};return this.retiring.set(t,u),{writtenAs:g=>{N.test(g)&&(s=g)},created:(g,p)=>{let P=p.filter(([m,y])=>m!==""&&N.test(y));if(P.length!==0){a=!0;for(let m=0;m<P.length;m+=1e4)c({at:this.now().toISOString(),object:g,created:P.slice(m,m+1e4)})}},flush:async()=>(await i,d),close:async()=>{await i,this.retiring.delete(t),(o||!a)&&await w.rm(t,{force:!0}),o=!0,V.delete(t)}}}async stoppedLoads(e){let t;try{t=await w.readdir(this.guard.assertOutsideRepo(this.sasDir))}catch(s){if(s.code==="ENOENT")return[];throw s}let r=`${this.journalStem}.load-`,o=new Set(e.flatMap(s=>s.load?[s.load.startedAt]:[])),a=[];for(let s of t){if(!s.startsWith(r)||!/^\d{1,16}\.ndjson$/.test(s.slice(r.length)))continue;let i=this.guard.assertOutsideRepo(O.join(this.sasDir,s));if(V.has(i))continue;let d;try{d=await w.readFile(i,"utf8")}catch{continue}let c=be(d);!c||o.has(c.startedAt)||c.pid!==process.pid&&ve(c.pid)||a.push({file:i,load:c.load})}return a}async load(){let e=await this.read();return e===void 0||await this.writtenToAnotherOrg(e)?new Map:new Map(Object.entries(e.mapping??{}))}async previousLoads(){let e=await this.read();if(e===void 0||await this.writtenToAnotherOrg(e))return[];let t=S(e);return[...t?[t]:[],...j(e)].map(r=>({mapping:new Map(Object.entries(r.mapping)),...r.created?{created:r.created}:{},...r.writtenBetween?{writtenBetween:r.writtenBetween}:{},endedAt:A(r),...r.removalStamps?{removalStamps:r.removalStamps}:{}}))}async recorded(){return(await this.recordedLoads())[0]}async recordedLoads(){let e=await this.read();if(e===void 0)return[];let t=typeof e.orgId=="string"?e.orgId:"",r=S(e);return[...r?[this.recordedOf(r,t)]:[],...j(e).map(o=>({...this.recordedOf(o,t),earlier:!0}))]}recordedOf(e,t){return{orgId:t,mapping:new Map(Object.entries(e.mapping)),...e.created?{created:e.created}:{},...e.load?{startedAt:e.load.startedAt}:{},endedAt:A(e),...e.writtenBetween?{writtenBetween:e.writtenBetween}:{},...e.removal?{removal:e.removal}:{},removalStamps:e.removalStamps??{},removalSpans:e.removalSpans??[],...e.personContacts?{personContacts:e.personContacts}:{},...e.withTheirRecord?{withTheirRecord:e.withTheirRecord}:{},...e.runUserId?{runUserId:e.runUserId}:{},...e.madeEarlier?{madeEarlier:e.madeEarlier}:{},...e.lateEarlier?{lateEarlier:e.lateEarlier}:{}}}async isStale(){let e=await this.read();return e!==void 0&&await this.writtenToAnotherOrg(e)}async writtenToAnotherOrg(e){let t=e.organizationId;if(t===void 0)return!1;let r=await this.currentOrganizationId();return r!==void 0&&!Ne(t,r)}currentOrganizationId(){return this.organizationId??=this.askOrganizationId(),this.organizationId}async read(){return(await this.readWithJournals()).payload}async readFile(){let e=await $(this.filePath);if(e!==void 0)return e;let t=this.singleFilePath;if(t===void 0)return;let r=await $(t);return r?.orgId===this.orgId?r:void 0}async readWithJournals(){let e=await this.readFile(),t=e?[S(e),...j(e)]:[],r=await this.stoppedLoads(t.filter(i=>i!==void 0));if(r.length===0)return{payload:e,journals:[]};let o=[...t.filter(i=>i!==void 0),...r.map(({load:i})=>i)].sort((i,d)=>Date.parse(A(d))-Date.parse(A(i))),[a,...s]=o;return{payload:{version:1,orgId:typeof e?.orgId=="string"?e.orgId:this.orgId,...e?.organizationId!==void 0?{organizationId:e.organizationId}:{},...a,...s.length>0?{earlier:s}:{}},journals:r.map(({file:i})=>i)}}async dropJournals(e){for(let t of e)await w.rm(t,{force:!0}).catch(()=>{})}async write(e){let t=this.filePath;await w.mkdir(O.dirname(t),{recursive:!0}),await w.writeFile(t,`${JSON.stringify(e,null,2)}
|
|
12
|
+
`,"utf8");let r=this.singleFilePath;if(r!==void 0)try{(await $(r))?.orgId===this.orgId&&await w.rm(r)}catch{}}async keptLoads(e,t,r=[]){if(e===void 0||e.orgId!==this.orgId)return[];if(await this.writtenToAnotherOrg(e))return[];let o=new Set(t.map(v)),a=new Set(r),s=S(e);return[...s?[s]:[],...j(e)].map(i=>ce(i,o)).filter(i=>le(i)||a.has(A(i)))}async persist(e,t){let{payload:r,journals:o}=await this.readWithJournals(),a=t?.earlier?await this.keptLoads(r,t.earlier.settled,t.earlier.stillToSweep):[],s=await this.currentOrganizationId(),i=this.now().toISOString(),d=g=>Object.fromEntries(Object.entries(g??{}).filter(([p,P])=>e.has(p)&&e.has(P))),c=d(t?.personContacts),u=d(t?.withTheirRecord);if(await this.write({version:1,orgId:this.orgId,...s!==void 0?{organizationId:s}:{},updatedAt:i,mapping:Object.fromEntries([...e.entries()].sort(([g],[p])=>g.localeCompare(p))),...t?{created:t.created.map(({objectApiName:g,referenceIds:p})=>({objectApiName:g,referenceIds:p.filter(P=>e.has(P))})).filter(g=>g.referenceIds.length>0),load:{startedAt:t.startedAt.toISOString(),endedAt:i},...t.writtenBetween?{writtenBetween:{...t.writtenBetween}}:{},...Object.keys(c).length>0?{personContacts:c}:{},...Object.keys(u).length>0?{withTheirRecord:u}:{},...t.runUserId?{runUserId:t.runUserId}:{}}:{},...a.length>0?{earlier:a}:{}}),t?.earlier&&await this.dropJournals(o),t){let g=this.journalPath(t.startedAt),p=this.retiring.get(g);p?await p():await w.rm(g,{force:!0}).catch(()=>{})}}async recordRemoval(e,t){let{payload:r,journals:o}=await this.readWithJournals(),a=S(r);if(r===void 0||a===void 0)return!1;let s=[a,...j(r)],i=s.findIndex(g=>A(g)===e);if(i<0)return!1;let d=new Set(t.gone.map(v)),[c,...u]=s.map((g,p)=>ce(p===i?Te(g,t):g,d));return await this.write({version:1,orgId:typeof r.orgId=="string"?r.orgId:"",...r.organizationId!==void 0?{organizationId:r.organizationId}:{},...c,updatedAt:this.now().toISOString(),...u.length>0?{earlier:u}:{}}),await this.dropJournals(o),!0}async recordMade(e,t,r=[],o=[]){let{payload:a,journals:s}=await this.readWithJournals(),i=S(a);if(a===void 0||i===void 0)return!1;let d=[i,...j(a)],c=d.findIndex(m=>A(m)===e);if(c<0)return!1;let u=[...o],g=m=>{let y=ge(m.madeEarlier,t,u),z=ge(m.lateEarlier,r,u),C={...m};return delete C.madeEarlier,delete C.lateEarlier,{...C,...y.length>0?{madeEarlier:y}:{},...z.length>0?{lateEarlier:z}:{}}},[p,...P]=d.map((m,y)=>y===c?g(m):m);return await this.write({version:1,orgId:typeof a.orgId=="string"?a.orgId:"",...a.organizationId!==void 0?{organizationId:a.organizationId}:{},...p,...P.length>0?{earlier:P}:{}}),await this.dropJournals(s),!0}async letSweptGo(e){if(e.length===0)return!1;let{payload:t,journals:r}=await this.readWithJournals(),o=S(t);if(t===void 0||o===void 0)return!1;let a=new Set(e),s=j(t),i=s.filter(d=>le(d)||!a.has(A(d)));return i.length===s.length?!1:(await this.write({version:1,orgId:typeof t.orgId=="string"?t.orgId:"",...t.organizationId!==void 0?{organizationId:t.organizationId}:{},...o,...i.length>0?{earlier:i}:{}}),await this.dropJournals(r),!0)}async recordStamps(e){let{payload:t,journals:r}=await this.readWithJournals(),o=S(t);if(t===void 0||o===void 0)return!1;let a=[o,...j(t)],s=a.map(c=>Ce(c,e));if(s.every((c,u)=>c===a[u]))return!1;let[i,...d]=s;return await this.write({version:1,orgId:typeof t.orgId=="string"?t.orgId:"",...t.organizationId!==void 0?{organizationId:t.organizationId}:{},...i,...d.length>0?{earlier:d}:{}}),await this.dropJournals(r),!0}};function ge(n,e,t=[]){let r=new Map,o=new Set(t.map(v)),a=[];for(let s of[...n??[],...e]){let i=v(s),d=i.slice(0,3),c=r.get(d)??0;!N.test(s)||o.has(i)||c>=oe||(o.add(i),r.set(d,c+1),a.push(s))}return a}function Ce(n,e){let t=new Set(Object.values(n.mapping).map(v)),r=Object.entries(e).filter(([a])=>t.has(v(a)));if(r.length===0)return n;let o=new Set(r.map(([a])=>v(a)));return{...n,removalStamps:{...Object.fromEntries(Object.entries(n.removalStamps??{}).filter(([a])=>!o.has(v(a)))),...Object.fromEntries(r)}}}function Te(n,e){let t={...n.removalStamps,...e.stamps},r=[...n.removalSpans??[],...e.span?[e.span]:[]],o=e.mark??n.removal;return{...n,...o?{removal:o}:{},...Object.keys(t).length>0?{removalStamps:t}:{},...r.length>0?{removalSpans:r}:{}}}var qe="replays",ue="replay.json";function St(n=process.env){let e=n.SANDFORGE_JOURNAL_DIR,t=e!==void 0&&e.trim()!==""?Ze(e):k(We(),".sandforge");return k(t,qe)}var H=ee.datetime({offset:!0}),Ke=f({organizationId:Z,name:l().min(1).max(255),choices:q,firstAt:H,lastAt:H}),we=f({version:x(1),checkpoint:f({checkpointId:J,name:l().min(1).max(255),organizationId:Z,alias:l().min(1).max(255).optional(),tier:_(["sandbox","scratch","developer"]),takenAt:H}),targets:I(Ke).max(1e4)}),fe=/^00D[A-Za-z0-9]{15}$/,me=class{root;guard;now;writes=new Map;constructor(e){this.guard=e.guard??new B,this.root=this.guard.assertOutsideRepo(e.root),this.now=e.now??(()=>new Date)}folderOf(e,t){let r=E(e),o=J.safeParse(t);if(!o.success)throw new ne("invalid","Not a checkpoint\u2019s id");return{dir:this.guard.assertOutsideRepo(k(this.root,r,o.data)),sourceOrganizationId:r,checkpointId:o.data}}async record(e,t,r){let o=this.folderOf(e.org.organizationId,e.checkpointId),a=E(t.organizationId),s=q.parse(r);await re(o.dir);let i=k(o.dir,ue),d=async()=>{let g=this.now().toISOString(),p=await he(i),P=p?.targets.find(y=>y.organizationId===a),m={version:1,checkpoint:{checkpointId:o.checkpointId,name:e.name,organizationId:o.sourceOrganizationId,...e.org.alias!==void 0?{alias:e.org.alias}:{},tier:e.org.tier,takenAt:e.takenAt},targets:[...p?.targets.filter(y=>y.organizationId!==a)??[],{organizationId:a,name:t.name,choices:s,firstAt:P?.firstAt??g,lastAt:g}]};await Ye(i,`${JSON.stringify(we.parse(m),null,2)}
|
|
13
|
+
`)},c=(this.writes.get(i)??Promise.resolve()).then(d,d),u=c.catch(()=>{});return this.writes.set(i,u),u.then(()=>{this.writes.get(i)===u&&this.writes.delete(i)}),await c,o}mappingStoreOf(e,t,r={}){return new G(e.dir,{guard:this.guard,orgId:E(t),...r})}contractPathOf(e,t){return K(this.guard,e.dir,E(t))}async read(e){return he(k(e.dir,ue))}async list(e={}){let t=e.sourceOrganizationId!==void 0?E(e.sourceOrganizationId):void 0,r=e.targetOrganizationId!==void 0?E(e.targetOrganizationId):void 0,o=[];for(let a of await ye(this.root))if(!(!fe.test(a)||t!==void 0&&a!==t))for(let s of await ye(k(this.root,a))){if(!J.safeParse(s).success||e.checkpointId!==void 0&&s!==e.checkpointId)continue;let i=this.folderOf(a,s);o.push(...await this.entriesOf(i,r))}return o.sort((a,s)=>W(s.replayedAt??"",a.replayedAt??"")||W(a.checkpointId,s.checkpointId)||W(a.target.organizationId,s.target.organizationId))}async replaysOf(e,t){return this.list({sourceOrganizationId:e,checkpointId:t})}async entriesOf(e,t){let r=await this.read(e),o=new Map(r?.targets.map(d=>[d.organizationId,d])),a=(await pe(e.dir,this.guard)).filter(d=>fe.test(d)),s=[...new Set([...o.keys(),...a])].filter(d=>t===void 0||d===t),i=[];for(let d of s){let c=o.get(d),u=await this.mappingStoreOf(e,d).recordedLoads(),g=new Map;for(let y of u)for(let{objectApiName:z,ids:C}of ae(y))g.set(z,(g.get(z)??0)+C.length);let p=[...g].map(([y,z])=>({objectApiName:y,records:z})).sort((y,z)=>W(y.objectApiName,z.objectApiName)),P=p.reduce((y,z)=>y+z.records,0),m=u.find(y=>y.earlier!==!0);i.push({sourceOrganizationId:e.sourceOrganizationId,checkpointId:e.checkpointId,...r?{checkpointName:r.checkpoint.name}:{},...r?{takenAt:r.checkpoint.takenAt}:{},target:{organizationId:d,...c?{name:c.name}:{}},...c?{choices:c.choices}:{},...m?{replayedAt:m.endedAt}:{},inPlace:P,inPlaceByObject:p,...m!==void 0&&P===0&&m.removal!==void 0?{removed:!0}:{}})}return i}};function Ve(n){return n.filter(e=>e.inPlace>0)}function Ot(n){let e=Ve(n);if(e.length===0)return;let t=e.map(r=>`${r.inPlace.toLocaleString("en-US")} record${r.inPlace===1?"":"s"} in ${r.target.name??r.target.organizationId}`).join(", ");return`${e.length===1?"A replay":`${e.length} replays`} of it ${e.length===1?"is":"are"} still in place: ${t}. Deleting the checkpoint leaves them there, and each replay is still removed without it.`}async function he(n){let e;try{e=await Be(n,"utf8")}catch(t){if(t.code==="ENOENT")return;throw t}try{let t=we.safeParse(JSON.parse(e));return t.success?t.data:void 0}catch{return}}async function Ye(n,e){let t=`${n}.${process.pid}-${_e(4).toString("hex")}.tmp`,r=await Je(t,"wx",te);try{try{await r.writeFile(e,"utf8"),await r.sync()}finally{await r.close()}await $e(t,n)}catch(o){throw await Ue(t,{force:!0}),o}}async function ye(n){let e;try{e=await De(n)}catch(r){if(r.code==="ENOENT")return[];throw r}let t=[];for(let r of e)(await Ge(k(n,r)).catch(()=>{}))?.isDirectory()&&t.push(r);return t.sort()}function W(n,e){return n<e?-1:n>e?1:0}export{K as a,Qe as b,et as c,tt as d,je as e,pe as f,G as g,ue as h,St as i,me as j,Ve as k,Ot as l};
|
|
@@ -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{b as N}from"./chunk-WB2RIVO3.mjs";import{a as k}from"./chunk-BOGNK4LV.mjs";import{i as S}from"./chunk-
|
|
7
|
+
import{b as N}from"./chunk-WB2RIVO3.mjs";import{a as k}from"./chunk-BOGNK4LV.mjs";import{i as S}from"./chunk-XMQ5R6TC.mjs";import{a as _,b as E}from"./chunk-T63U4OZJ.mjs";import{$a as U,$b as V,Ma as L,Qb as M,Tb as W,Xa as F,Yb as z,Za as w,ab as x,cb as G,db as v,fb as B,fc as H,tb as j,uc as X}from"./chunk-R3OM3X4L.mjs";import{b as C,f as P,k as b,l as D}from"./chunk-WZQEK4WT.mjs";var q={PII:"PII",PHI:"PHI",PCI:"PCI",Confidential:"SENSITIVE"},K={PII:"fake",PHI:"nullify",PCI:"mask",SENSITIVE:"hash",NONE:"fake"},$={name_pattern:"field_name",type_analysis:"field_name",content_pattern:"content_sampling"},J=.9;function ie(e,t){let n=[];for(let[i,a]of t){let c=a.fields.filter(o=>o.createable&&N({name:o.name,label:o.label,type:o.type})),l=new Map(c.map(o=>[o.name,o])),r=new Map,s=e.detectPII(i,c.map(o=>({apiName:o.name,label:o.label,type:o.type})));for(let o of s.piiFields){let u=l.get(o.fieldApiName);if(!u)continue;let d=q[o.classification];r.set(u.name,{objectApiName:i,fieldApiName:u.name,fieldLabel:u.label,fieldType:u.type,piiCategory:d,detectionMethod:$[o.detectionMethod],confidence:o.confidence,suggestedMethod:K[d]})}for(let o of c)r.has(o.name)||E(o.name,o.type)===void 0||r.set(o.name,{objectApiName:i,fieldApiName:o.name,fieldLabel:o.label,fieldType:o.type,piiCategory:"PII",detectionMethod:"field_name",confidence:J,suggestedMethod:"fake"});n.push(...r.values())}return n}function ae(e,t){let n=a=>`${a.objectApiName}.${a.fieldApiName}`,i=new Set(e.map(n));return[...e,...t.filter(a=>!i.has(n(a)))]}var Y=["Contact","Lead"];function re(e,t,n){if(e==="none")return[];let i=new Set(t),a=[];for(let c of Y){if(!i.has(c))continue;let l=n.filter(s=>s.objectApiName===c).map(s=>s.fieldApiName),r=[];l.some(_)||r.push("name"),l.some(s=>E(s,"string")==="email")||r.push("email"),l.some(s=>E(s,"string")==="phone")||r.push("phone"),r.length>0&&a.push({objectApiName:c,missing:r})}return a}function ce(e){return e.fatalError!==void 0?"failure":e.totalFailure>0||e.failedObjects.length>0?e.totalSuccess+(e.totalLinked??0)>0?"partial":"failure":[...Object.values(e.lookups??{}),...Object.values(e.statuses??{})].some(n=>n.refusals.length>0)||e.stopped===!0?"partial":"success"}var Q=D({name:C().min(1),referenceTo:b(C()).min(1),createable:P().optional(),updateable:P().optional()}).loose();function de(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let i=Q.safeParse(n);i.success&&t.push({name:i.data.name,referenceTo:i.data.referenceTo,createable:i.data.createable??!1,updateable:i.data.updateable??!1})}return t}var ge={STORAGE_EXCEEDED:"AUTOPILOT_STORAGE_EXCEEDED",API_BUDGET_EXCEEDED:"API_BUDGET_EXCEEDED",WRITE_DECLINED:"AUTOPILOT_WRITE_DECLINED",CONFIRMATION_UNAVAILABLE:"AUTOPILOT_CONFIRMATION_UNAVAILABLE",CHECKPOINT_REFUSED:"CHECKPOINT_REFUSED",RUN_CANCELLED:"RUN_CANCELLED",EMAILS_NOT_ACCEPTED:z},Ae={NO_PLAN:"AUTOPILOT_NO_PLAN",STORAGE_UNREAD:"AUTOPILOT_FIT_STORAGE_UNREAD",READ_REFUSED:"AUTOPILOT_FIT_READ_REFUSED",STALE:"AUTOPILOT_FIT_STALE"};function Ie(e,t,n=new Map){return L(e.waves.flatMap(i=>i.objects).map(i=>{let a=n.get(i);return{objectApiName:i,rows:[],counted:{rows:t.get(i)??0,...a!==void 0?{personAccounts:a}:{}}}}))}function he(e){return[...new Set(e.waves.flatMap(t=>t.objects.map(String)))]}async function Ce(e){return M(e)}function Z(e){return e.filter(t=>t.verdict==="exceeds").map(W)}function ee(e){return e.filter(t=>t.verdict==="unread").map(t=>({limit:t.limit,emails:t.emails,unread:t.unread??""}))}function Pe(e){return e.objects.filter(({rows:t})=>t>0).length}async function te(e,t,n,i,a={}){let c="unread"in t?await n().catch(o=>({unread:o instanceof Error?o.message:String(o)})):t.dailyApiRequests,{readBack:l=0,deliverability:r=0,mute:s=0}=a;return w({run:F(e.objects.map(({rows:o})=>({rows:o}))),...G(i),...s>0?{mute:s}:{},...l>0?{readBack:l}:{},...r>0?{deliverability:r}:{}},c)}async function ke(e){let{plan:t}=e,n=j(t,e.storage);if(t.totalRows===0)return{go:!0,check:n,asked:!1};let i=e.checkpointFirst?.estimate,a=v(i);if(a)return{go:!1,...a,check:n};let c=X(n,e.org);if(c)return{go:!1,code:"STORAGE_EXCEEDED",message:`${c} Nothing was written.`,check:n};let l=await te(t,e.storage,e.readApiBudget,i,{...e.readBack!==void 0?{readBack:e.readBack}:{},...e.mute!==void 0?{mute:e.mute}:{},...V(e.runEmails?.ofRun)}),r=U(l,e.org);if(r)return{go:!1,code:"API_BUDGET_EXCEEDED",message:r,check:n};let s=e.confirmAboveRecords,o=s>0&&t.totalRows>s?s:void 0,u=Z(e.emails??[]),d=ee(e.emails??[]),g=e.emailsUncounted,f=e.runEmails?.gate,y=f?.verdict==="asks",R=async m=>{let p=k(f,m&&y),I=e.checkpointFirst;if(I===void 0)return{go:!0,check:n,asked:m,...p};let h=await B(()=>I.take(I.estimate));return"stop"in h?{go:!1,...h.stop,check:n,...p}:{go:!0,check:n,asked:m,checkpoint:h.checkpoint,...p}};if(o===void 0&&n.verdict==="fits"&&u.length===0&&d.length===0&&g===void 0&&i===void 0&&!y)return R(!1);let A=S(e.orgTier),T=await e.confirm({stage:"write",module:"autopilot",org:e.org,orgTier:e.orgTier,objects:t.objects.map(({objectApiName:m,rows:p})=>({objectApiName:m,rows:p})),total:t.totalRows,...o!==void 0?{aboveRecords:o}:{},...A!==void 0&&t.totalRows>A?{largeVolume:A}:{},storage:H(n),counted:!0,...u.length>0?{emails:u}:{},...d.length>0?{emailsUnread:d}:{},...g!==void 0?{emailsUncounted:g}:{},...x(l),...i!==void 0?{checkpoint:i}:{},...f?.confirmation});if(T==="confirmed")return R(!0);let O=k(f,!1);return T==="declined"?{go:!1,code:"WRITE_DECLINED",message:"The Autopilot run was cancelled before it wrote anything. Nothing was written.",check:n,...O}:{go:!1,code:"CONFIRMATION_UNAVAILABLE",message:"The Autopilot run needed a confirmation before it wrote, and there was no one to ask. Nothing was written: run it again from the Autopilot page, where the question is asked.",check:n,...O}}export{ie as a,ae as b,re as c,ce as d,de as e,ge as f,Ae as g,Ie as h,he as i,Ce as j,Pe as k,te as l,ke as m};
|
|
@@ -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{d as v}from"./chunk-UV74P4H2.mjs";import{d as f,k as h,z as b}from"./chunk-N2HYG3BL.mjs";import{Ua as E,ib as x,jb as U,kb as A,lb as P,sb as _}from"./chunk-6QSHWIZI.mjs";import{b as o,e as l,f as m,k as i,m as a,u as c,v as w,z as O}from"./chunk-WZQEK4WT.mjs";import{randomBytes as k}from"node:crypto";import{open as I,readFile as j,readdir as F,rename as M,rm as J}from"node:fs/promises";import{homedir as Z}from"node:os";import{join as p,resolve as G}from"node:path";var T="users";function se(n=process.env){let e=n.SANDFORGE_JOURNAL_DIR,r=e!==void 0&&e.trim()!==""?G(e):p(Z(),".sandforge");return p(r,T)}var g=O.datetime({offset:!0}),R=l().int().nonnegative(),y=l().int().positive().max(999999),D=a({isActive:m(),isFrozen:m(),profileId:o().regex(/^00e[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/)}),H=a({id:o().regex(/^(?:0Pa|011)[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/),what:c(["permissionSet","permissionSetGroup","group"]),name:o().regex(/^[A-Za-z][A-Za-z0-9_]*$/).max(80),type:c(["Regular","Queue"]).optional()}),X=a({applied:_,after:D,accesses:i(H).max(U+A+P),inFile:m()}),L=a({at:g,status:c(["success","partial","failure","cancelled"]),undone:R,kept:R,codes:i(o().regex(/^[A-Z][A-Z_]{1,63}$/)).max(50)}),S=a({version:w(1),organizationId:E,run:y,replaces:y.optional(),status:c(["running","success","partial","failure","cancelled"]),startedAt:g,endedAt:g.optional(),emailsToPeople:R,users:i(X).max(2*x),removals:i(L).max(1e3).optional()});function C(n){return`refused with ${n}; the org\u2019s words are not kept, as they may name the person`}function N(n){return{...n,users:n.users.map(e=>e.applied.refused===void 0?e:{...e,applied:{...e.applied,refused:e.applied.refused.map(r=>({...r,message:C(r.code)}))}})}}var K=/^run-([1-9]\d{0,5})\.json$/,$=class{root;guard;constructor(e){this.guard=e.guard??new v,this.root=this.guard.assertOutsideRepo(e.root)}folderOf(e){return this.guard.assertOutsideRepo(p(this.root,h(e)))}fileOf(e,r){return p(this.folderOf(e),`run-${y.parse(r)}.json`)}async begin(e,r){let s=this.folderOf(e);await b(s);for(let t=await this.highest(e)+1;;t+=1){let u=S.parse(N({...r,version:1,organizationId:h(e),run:t})),d;try{d=await I(this.fileOf(e,t),"wx",f)}catch(z){if(z.code==="EEXIST")continue;throw z}try{await d.writeFile(`${JSON.stringify(u,null,2)}
|
|
8
|
+
`,"utf8"),await d.sync()}finally{await d.close()}return u}}async write(e){let r=S.parse(N(e));await W(this.fileOf(r.organizationId,r.run),`${JSON.stringify(r,null,2)}
|
|
9
|
+
`)}async read(e,r){let s;try{s=await j(this.fileOf(e,r),"utf8")}catch(t){if(t.code==="ENOENT")return;throw t}try{let t=S.safeParse(JSON.parse(s));return t.success&&t.data.run===r?t.data:void 0}catch{return}}async list(e){let r=[];for(let s of(await this.numbers(e)).sort((t,u)=>u-t)){let t=await this.read(e,s);t&&r.push(t)}return r}async numbers(e){let r;try{r=await F(this.folderOf(e))}catch(s){if(s.code==="ENOENT")return[];throw s}return r.flatMap(s=>{let t=K.exec(s);return t?[Number(t[1])]:[]})}async highest(e){return Math.max(0,...await this.numbers(e))}};async function W(n,e){let r=`${n}.${process.pid}-${k(4).toString("hex")}.tmp`,s=await I(r,"wx",f);try{try{await s.writeFile(e,"utf8"),await s.sync()}finally{await s.close()}await M(r,n)}catch(t){throw await J(r,{force:!0}),t}}export{se as a,X as b,S as c,$ as d};
|
|
@@ -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{Q as f,j as k,k as s}from"./chunk-
|
|
7
|
+
import{Q as f,j as k,k as s}from"./chunk-N2HYG3BL.mjs";import{a as d,b as u}from"./chunk-PC247GKX.mjs";import{vb as i}from"./chunk-6QSHWIZI.mjs";import{b as c,l as a,u as p}from"./chunk-WZQEK4WT.mjs";import{homedir as E}from"node:os";import{join as O}from"node:path";var $=a({...d,operation:p(["apply","destroy","reset","recover"]),env:i,alias:c().min(1).max(255).optional()}),l=u(n=>{let e=$.safeParse(n);return e.success?e.data:void 0});function j(n=E()){return k(n)}function v(n,e){return O(n,`${s(e)}.env.lock`)}function K(n,e,o,r={}){let m=v(n,e),y=i.parse(o.env),t=l.acquire(m,h=>({...h,operation:o.operation,env:y,...o.alias!==void 0?{alias:o.alias}:{}}),r);return"busy"in t?{busy:L(t.busy)}:{lock:{organizationId:s(e),release:t.lock.release}}}function N(n,e,o={}){let r=l.holder(v(n,e),o);return r!==void 0?L(r):void 0}function L({version:n,token:e,...o}){return o}function g(n){return`process ${n.pid} on ${n.host}, since ${n.acquiredAt}`}function R(n){return`${w(n)}. Nothing was written: run this again once it ends. Two jobs applying to one org from two machines are not kept apart: give them one concurrency group.`}function w(n){let e=n.alias!==void 0?` to ${n.alias}`:"";return`${n.operation==="apply"?"an apply":n.operation==="recover"?"a state recover":`a ${n.operation}`} of ${n.env}${e} is under way on this machine (${g(n)})`}function _(n,e,o={}){let r=f(n,e,o);if(r!==void 0)return`a checkpoint ${r.operation} of this org is under way on this machine (${g(r)}): its records would be read or written as the step writes. Run this again once it ends.`}export{j as a,v as b,K as c,N as d,R as e,w as f,_ as g};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as Re}from"./chunk-K77NR3UK.mjs";import{K as we,Q as Se,b as ye}from"./chunk-IM2XA6JI.mjs";import{Ga as he,Ia as be,h as x,i as fe,j as ge,k as D}from"./chunk-KGYXLSQ5.mjs";import{o as se,p as ie,q as ae,r as de,s as ue}from"./chunk-UIUPPEFB.mjs";import{g as oe}from"./chunk-6IGEASOF.mjs";import{$b as B,Rb as ce,Sb as le,Tb as N,Ub as me,nc as pe}from"./chunk-KOQV4WXC.mjs";import{h as re}from"./chunk-KRNFVAGC.mjs";import{b as z}from"./chunk-HFSBDM7B.mjs";import{q as F}from"./chunk-55LQD3Y3.mjs";import{c as ee,d as te,g as ne}from"./chunk-3B5H24ZG.mjs";import{b as v}from"./chunk-CA5NAXSU.mjs";import{Bd as V,Ed as X,Fd as J,Gd as Y,Hd as Z,Lc as H,Yb as G,h as W,i as O,k as U,ld as K,od as Q,qd as P}from"./chunk-DPYTG6DM.mjs";var L=1e4,$e=U.REST_API_BATCH_SIZE;function Oe(e){return e.id===void 0&&e.error!==void 0&&(e.errorDetails?.length??0)>0&&se([e.error],e.errorDetails)}function Pe(e,r){return e.error===void 0?e:{...e,error:ae(e.error,r)}}function C(e){return{successIds:e.flatMap(r=>r.id===void 0?[]:[r.id]),errors:e.flatMap(r=>r.error===void 0?[]:[r.error])}}function Ae(e,r){if(e.aborted||e.outcomes.length!==r||(e.unmatchedIds?.length??0)>0||(e.failures??[]).some(n=>n.recordIndex<0))return;let t=new Array(r);for(let n of e.outcomes){if(n.recordIndex<0||n.recordIndex>=r)return;if(n.success){if(!n.id)return;t[n.recordIndex]={id:n.id}}else{let o=n.error??"Unknown error",s=te(o);t[n.recordIndex]={error:o,...s?{errorDetails:[s]}:{}}}}return t.every(n=>n!==void 0)?t:void 0}function ze(e){let{conn:r,bulkManager:t,retry:n,signal:o,label:s}=e,p=new re(e.bulkThreshold),g,y=async(f,a,c)=>{g??=be(r).then(l=>(l||e.log(`[WARN] ${s}: the org's duplicate rules could not be read: an object of more than the Bulk API threshold goes as a Bulk API job, which a duplicate rule may refuse`),l));let h=await g;if(h===void 0)return he.has(f)?(e.log(`[INFO] ${s}: ${f} goes through REST: the duplicate rules could not be read, and a standard rule watches it`),!0):!1;let b=h.has(f);return b&&e.log(`[INFO] ${s}: ${f} goes through REST: an active duplicate rule watches it, which a Bulk API job cannot waive`+(a>L?` \u2014 ${a} records in ${Math.ceil(a/Math.max(1,c))} calls, slower than one job`:"")),b},R=async(f,a,c)=>{let h=[];for(let b=0;b<a.length;b+=c){if(o.aborted)return{rows:h,stopped:!0};let l=a.slice(b,b+c);e.calls?.sending(f,l.length);let w=await n.execute(async()=>r.sobject(f).create(l,{headers:G()}));if(w.cancelled)return e.calls?.answered(f,[]),{rows:h,stopped:!0};if(w.success&&w.result){let i=[];for(let m of w.result)if(m.success&&m.id)i.push(m.id),h.push({id:m.id});else{let d=ne(m.errors);h.push({error:d,errorDetails:(m.errors??[]).map(ee)})}e.calls?.answered(f,i)}else{let i=w.error?.message??"Insert failed after retries";for(let m=0;m<l.length;m++)h.push({error:i});e.calls?.answered(f,[])}}return{rows:h}},u=e.wait??(f=>ie(f,o)),A=async(f,a,c,h)=>{let b=Math.min(Math.max(1,h),$e),l=await de({outcomes:c,locked:Oe,written:i=>i.id!==void 0,send:async i=>(await R(f,i.map(m=>a[m]),b)).rows,note:Pe,wait:u,stopped:()=>o.aborted}),w=ue("record(s)",l);return{rows:l.outcomes,notes:w===void 0?[]:[`${f}: ${w}.`]}};return async(f,a,c,h)=>{let b=(c.length>L||p.shouldUseBulkApi(c.length))&&await y(a,c.length,h),l=b&&await g===void 0?[`The org's duplicate rules could not be read (the user SandForge connects as needs View Setup and Configuration): ${a}, which a standard duplicate rule watches, was sent through REST, whose header lets its matches be saved, rather than as a Bulk API job.`]:[];if(c.length>L&&!b){if(o.aborted)return{successIds:[],errors:[],stopped:!0};let d=new ye({signal:o}),S={connection:r,bulkManager:t,onProgress:(T,Ie)=>{e.onProgress(T,Ie,`Streaming insert ${a}`)},onOpened:T=>e.calls?.sending(a,c.length,{job:T})};e.calls?.sending(a,c.length);let E=await d.executeChunked(S,a,"insert",d.createChunkGenerator(c),c.length);e.calls?.answered(a,E.aborted?[]:E.successIds);let j=E.aborted?void 0:Ae({outcomes:E.outcomes??[],unmatchedIds:E.unmatchedIds},c.length),k=j&&await A(a,c,j,h);return k&&k.notes.length>0?{...C(k.rows),notes:k.notes}:{successIds:E.successIds,errors:E.errors,...E.aborted?{stopped:!0}:{}}}if(p.shouldUseBulkApi(c.length)&&!b){if(o.aborted)return{successIds:[],errors:[],stopped:!0};let d={connection:r,bulkManager:t,onProgress:(k,T)=>{e.onProgress(k,T,`Bulk insert ${a}`)},signal:o,onOpened:k=>e.calls?.sending(a,c.length,{job:k})};e.calls?.sending(a,c.length);let S=await p.executeBulk(d,a,"insert",c);e.calls?.answered(a,S.aborted?[]:S.successIds);let E=Ae(S,c.length),j=E&&await A(a,c,E,h);return j&&j.notes.length>0?{...C(j.rows),rows:j.rows,notes:j.notes}:{successIds:S.successIds,errors:S.failures.map(k=>k.error),...E?{rows:E}:{},...S.aborted?{stopped:!0}:{}}}let w=await R(a,c,h);if(w.stopped)return{...C(w.rows),rows:w.rows,stopped:!0};let i=await A(a,c,w.rows,h),m=[...l,...i.notes];return{...C(i.rows),rows:i.rows,...m.length>0?{notes:m}:{}}}}var xe="SELECT Id, DeveloperName FROM RecordType WHERE SobjectType = 'Account' AND IsPersonType = true";async function rt(e){try{return(await e.query(xe)).records.flatMap(t=>typeof t.Id=="string"&&typeof t.DeveloperName=="string"?[{id:t.Id,developerName:t.DeveloperName}]:[])}catch{return[]}}function ot(e,r,t){let n=new Set(e===F?t.map(o=>o.id.slice(0,15)):[]);return z(r).filter(o=>!o.master&&o.active&&o.available).map(o=>({recordTypeId:o.recordTypeId,developerName:o.developerName,label:o.name,person:n.has(o.recordTypeId.slice(0,15)),isDefault:o.defaultRecordTypeMapping}))}function Ce(e){let{staticValue:r,picklistValues:t}=e.config;return e.ruleType==="static"&&typeof r=="string"?[r]:e.ruleType==="picklist_random"?[...t??[]]:[]}function st(e,r){if(r.length===0)return{template:e,personObjects:[]};let t=new Map(r.map(s=>[s.id.slice(0,15),s.developerName])),n=[],o=[];for(let s of e.objects){if(s.objectApiName!==F){o.push(s);continue}let p=s.fieldRules.find(u=>u.fieldApiName==="RecordTypeId"),g=p?Ce(p):[],y=g.filter(u=>t.has(u.slice(0,15)));if(y.length>0&&y.length<g.length){let u=y.map(A=>t.get(A.slice(0,15))).join(", ");return{refusal:`${F}: ${u} ${y.length===1?"is a person account record type":"are person account record types"} and the other record types chosen are not: a person account and a business account take different fields. Seed one kind in a run.`}}let R=y.length>0?"person":"business";R==="person"&&n.push(s.objectApiName),o.push({...s,fieldRules:s.fieldRules.filter(u=>!H(F,u.fieldApiName,R))})}return{template:{...e,objects:o},personObjects:n}}var Me=/^[a-z]{2,3}(?:_[A-Za-z0-9]{2,4}){0,2}$/;async function ve(e){try{let t=(await e.query("SELECT DefaultLocaleSidKey FROM Organization LIMIT 1")).records[0]?.DefaultLocaleSidKey;return typeof t=="string"&&Me.test(t)?t:void 0}catch{return}}async function at(e,r){return e??await ve(r)??"en_US"}var ft="SEED_FIT_STORAGE_UNREAD",gt="SEED_CANNOT_FIT";function ht(e,r=!1){return q(e.objects.filter(t=>t.recordCount>0).map(t=>t.objectApiName),r)}function q(e,r=!1){let t=new Set(e);return(n,o)=>t.has(n)&&(o==="insert"||o==="update"&&r&&n===Re)}function bt(e,r,t,n){if(typeof e.unread=="string")return{room:{perRecord:[],notCounted:[],unread:e.unread},unread:e.unread};let o=Z(e,r,t);if(!n)return{running:o,room:x(o,t)};let s=[],p=new Set,g=[];for(let u of o.firing){let A=u.flow,f=A?.requiresFilled??[];if(u.write!=="insert"||A?.condition!=="read"||!A.creates?.length)continue;let a=f.filter(b=>n(u.objectApiName,b)==="every"),c=f.filter(b=>n(u.objectApiName,b)==="some"),h={objectApiName:u.objectApiName,name:u.name};a.length>0&&!Ne(o.firing,u)?(p.add(u),s.push({...h,fields:a,why:"leftEmpty"})):(a.length>0||c.length>0)&&(g.push(u),s.push({...h,fields:a.length>0?a:c,why:a.length>0?"automationMayFill":"mayBeLeftEmpty"}))}let y=x({firing:o.firing.filter(u=>!p.has(u))},t),R=x({firing:g},t).perRecord;return{running:o,room:{...y,...R.length>0?{atMost:R}:{},...s.length>0?{starts:s}:{}}}}function Ne(e,r){return e.some(t=>t!==r&&t.objectApiName===r.objectApiName&&t.write==="insert"&&(t.kind==="trigger"||t.kind==="process"||t.kind==="workflowRule"||t.flow?.timing==="beforeSave"))}async function yt(e,r,t){let n=new Set("objects"in r?r.objects.filter(s=>s.flows.some(p=>(p.requiresFilled??[]).length>0)).map(s=>s.objectApiName):[]),o=new Map;for(let s of e.objects)s.recordCount<=0||!n.has(s.objectApiName)||o.set(s.objectApiName,await t(s.objectApiName).catch(()=>{}));return(s,p)=>{let g=e.objects.find(a=>a.objectApiName===s);if(!g)return"none";let y=a=>a.toLowerCase()===p.toLowerCase();if(g.fieldRules.some(a=>y(a.fieldApiName)))return"none";let R=O(s,e.relations);if(R&&y(R.lookupField))return"none";let u=g.rows??[],A=u.filter(a=>Object.entries(a.values).some(([c,h])=>y(c)&&h!==null&&h!=="")).length;if(u.length>0&&A===u.length)return"none";let f=o.get(s);return f?[...f.filled].some(y)?"none":A>0?"some":[...f.empty].some(y)?"every":"some":"some"}}function M(e,r){return O(e.objectApiName,r)?.distribution.mode==="byKey"?"byKey":e.rows!==void 0?"rows":void 0}function ke(e,r){let t=O(e,r.relations);if(!(!t||t.parents.kind!=="generated"||t.distribution.mode==="byKey"||t.parentObject===e||!r.objects.some(n=>n.objectApiName===t.parentObject)))return t}function Ee(e,r){let t=r?.objects?.[e.objectApiName]??r?.all;return t!==void 0?Math.min(e.recordCount,Math.max(1,Math.floor(t))):e.recordCount}function Be(e,r,t){let n=new Map(e.objects.map(g=>[g.objectApiName,g])),o=new Map,s=new Set,p=g=>{let y=o.get(g);if(y!==void 0)return y;let R=n.get(g);if(M(R,e.relations))return o.set(g,R.recordCount),R.recordCount;s.add(g);let u=Math.round(r*Ee(R,t)),A=ke(g,e),f=A&&!s.has(A.parentObject)?Math.max(1,Math.min(u,W(A.distribution,p(A.parentObject)))):Math.max(1,u);return s.delete(g),o.set(g,f),f};return new Map(e.objects.map(g=>[g.objectApiName,p(g.objectApiName)]))}function De(e,r){if(r.cannotFit!==void 0)return e;let t=new Map(r.objects.map(n=>[n.objectApiName,n.after]));return{...e,objects:e.objects.map(n=>{let o=t.get(n.objectApiName);return o!==void 0&&o<n.recordCount?{...n,recordCount:o}:n})}}function Le(e,r){let t=e.objects.filter(s=>!M(s,e.relations)),n=t.filter(s=>!ke(s.objectApiName,e)),o;for(let s of n.length>0?n:t){let p=Ee(s,r);(!o||p>o.records)&&(o={objectApiName:s.objectApiName,records:p})}return o}function _e(e){return`${e} record${e===1?"":"s"}`}function qe(e){let{template:r,personObjects:t,budget:n,room:o}=e,s=e.ask?.caps,p=e.ask?.share===!0||s===void 0,g=d=>{let S=Be(r,d,s),E=De(r,{objects:r.objects.map(k=>({objectApiName:k.objectApiName,before:k.recordCount,after:S.get(k.objectApiName)??k.recordCount}))}),j=fe(o,k=>S.get(k)??0);return{counts:S,bytes:Se(E,t)+j,roomBytes:j,requests:we(E,e.path),records:[...S.values()].reduce((k,T)=>k+T,0)}},y=d=>d.bytes<=n.bytes,R=d=>n.runRequests===void 0||d.requests<=n.runRequests,u=d=>y(d)&&R(d),A=(d,S,E,j)=>({share:d,budget:{...ge(n,S.roomBytes,o),...E==="apiRequests"?{limitedBy:"apiRequests"}:{}},objects:r.objects.map(k=>{let T=M(k,r.relations);return{objectApiName:k.objectApiName,before:k.recordCount,after:S.counts.get(k.objectApiName)??k.recordCount,...T?{keptWhole:T}:{}}}),estimateMB:S.bytes/1048576,...j!==void 0?{cannotFit:j}:{},...o.unread!==void 0?{automationUnread:o.unread}:{}}),f=(d,S,E,j)=>({proposal:A(d,S,E,j),heldBy:E,records:S.records,requests:S.requests}),a=d=>{if(y(d))return`about ${d.requests} API requests, past the ${n.runRequests??0} that leave the org a tenth of its daily requests`;let S=pe(d.bytes/1048576,n.bytes/1048576);return`${S.over} MB`+(d.roomBytes>0?", room for what the org's automation creates under them included":"")+`, past the ${S.bound} MB that fit`},c=d=>y(d)?"apiRequests":n.terms.limitedBy,h=r.objects.filter(d=>M(d,r.relations)).reduce((d,S)=>d+S.recordCount,0),b=g(1);if(u(b)){let d=r.objects.some(S=>(b.counts.get(S.objectApiName)??0)<S.recordCount);return f(1,b,d?"caps":"whole")}if(!p)return f(1,b,c(b),`with these caps the seed takes ${a(b)}: lower them, or fit by share`);let l=Le(r,s);if(!l)return f(1,b,c(b),`the ${h} rows the template gives take ${a(b)}, and rows are kept whole`);let w=d=>g(d/l.records),i=D(l.records,d=>u(w(d)));if(i===0){let d=w(1);return f(1/l.records,d,c(d),`the least it can be cut to \u2014 one ${l.objectApiName} and what follows it`+(h>0?`, with the ${h} rows the template gives kept whole`:"")+`, ${_e(d.records)} \u2014 takes ${a(d)}`)}let m=D(l.records,d=>y(w(d)));return f(i/l.records,w(i),m>i?"apiRequests":n.terms.limitedBy)}function wt(e,r,t,n,o){if(!("unread"in e))return qe({template:r,personObjects:t,budget:e,room:n,path:o}).proposal}function St(e,r){if(!(!e||e.before<r))return{module:"seed",share:e.share,...e.withinMB!==void 0?{withinMB:e.withinMB}:{},kept:r,inSource:e.before}}var Fe=(e,r)=>r==="insert";function je(e){return typeof e.unread=="string"}function We(e){return(K(e).find(t=>t.write==="insert")?.fired??[]).map(t=>{let n=t.flow,o=n?.messages??[];return{kind:t.kind,name:t.name,when:t.when,emails:o.filter(s=>s.kind==="email").length,messages:[...new Set(o.flatMap(s=>s.kind==="email"?[]:[s.kind]))],creates:[...n?.creates??[]],afterCommit:(n?.paths?.length??0)>0,bypasses:(n?.permissions??[]).filter(s=>s.bypass).map(({name:s,held:p})=>p===void 0?{name:s}:{name:s,held:p}),keptQuiet:t.keptQuiet===!0,unread:n!==void 0&&n.condition!=="read"}})}function $(e){return[...new Set(e)].sort((r,t)=>r.localeCompare(t))}function Te(e,r,t,n,o=Fe){let s=e.objects.flatMap(l=>{let w=We(l);return w.length>0?[{objectApiName:l.objectApiName,entries:w}]:[]}),p=je(t)?void 0:t,g=p!==void 0&&ce(p),y=p!==void 0&&le(p),R=N(P(e),g,y),u=s.flatMap(l=>l.entries.flatMap(w=>w.bypasses)),A=$(u.filter(l=>l.held===!0).map(l=>l.name)),f=$(u.map(l=>l.name)).filter(l=>!A.includes(l)),a=V(e,f),c=f.map(l=>{let w=a.find(i=>i.permission.toLowerCase()===l.toLowerCase())?.permissionSet;return w?{permission:l,permissionSet:w.name}:{permission:l}}),h=X(e,o),b=h.assign.length>0;return{org:r,objectsRead:[...e.objectsRead],objects:s,emailsPerRecord:R,...p&&R.length>0?{limits:{...p}}:{},...je(t)?{limitsUnread:t.unread}:{},alertsAsSingle:g,bypasses:c,bypassesHeld:A,...b?{mute:h,emailsPerRecordMuted:N(P(Y(e,J(h))),g,y)}:{},unread:e.unread.map(({part:l,reason:w})=>({part:l,reason:w})),blinded:Q(e.unread),conditionsNotRead:e.conditionsNotRead,...n?{deliverability:n}:{}}}async function Ft(e){let r=e.writes??q(e.objects),t;try{t=await e.readAutomation(e.objects)}catch(s){return{error:v(s)}}let n=e.deliverability??(e.readDeliverability?(await oe({read:t,writes:Fe,readDeliverability:e.readDeliverability,accepted:!1,target:e.org,run:"seed"})).gate.deliverability:void 0);if(P(t).length===0)return{preview:Te(t,e.org,{},n,r)};let o=await e.readLimits().catch(s=>({unread:v(s)}));return{preview:Te(t,e.org,o,n,r)}}function I(e,r="and"){return e.length<=1?e.join(""):e.length===2?`${e[0]} ${r} ${e[1]}`:`${e.slice(0,-1).join(", ")}, ${r} ${e[e.length-1]}`}var It="SEED_EMAILS_EXCEEDED";function $t(e,r,t){if("error"in e)return{checks:[],unknown:[`what ${t} runs as these records are created could not be read (${e.error}): the emails they make it send are not known`]};let{preview:n}=e,o={objects:r.map(i=>({objectApiName:i.objectApiName,rows:i.recordCount,storageBytes:0}))},s=n.limitsUnread!==void 0?{unread:n.limitsUnread}:n.limits??{},p=me(o,n.emailsPerRecord,s),g=new Set(r.filter(i=>i.recordCount>0).map(i=>i.objectApiName)),y=n.objects.flatMap(i=>g.has(i.objectApiName)?i.entries.filter(m=>m.unread&&!m.keptQuiet&&m.when!=="before").map(m=>`"${m.name}" on ${i.objectApiName}`):[]),R=[...p.filter(i=>i.verdict==="unread").map(i=>`about ${B(i.emails,i.limit)}, but what ${t} has left today could not be read (${i.unread??"not said"})`),...n.blinded?[`part of what ${t} runs could not be read: emails it sends may not be counted`]:[],...y.length>0?[`the emails of ${I(y)} are not counted: what ${y.length===1?"it does":"they do"} was not read`]:n.conditionsNotRead>0?[`${n.conditionsNotRead} start condition(s) of ${t} not read: the emails of those flows are not counted`]:[]],u=p.find(i=>i.verdict==="exceeds");if(!u)return R.length>0?{checks:p,unknown:R}:{checks:p};let A=p.filter(i=>i.verdict==="exceeds"),f=$(A.flatMap(i=>i.objects.map(m=>m.objectApiName))),a=$(A.flatMap(i=>i.objects.flatMap(m=>m.sentBy))),c=new Map;for(let i of n.objects.flatMap(m=>m.entries))if(!(i.emails===0||!a.includes(i.name)))for(let{name:m}of i.bypasses)c.set(m,(c.get(m)??new Set).add(i.name));let h=n.bypasses.flatMap(i=>{let m=c.get(i.permission);return m?[{...i,quiets:$([...m])}]:[]}),b=A.map(i=>`about ${B(i.emails,i.limit)} (`+i.objects.map(m=>`${m.perRecord} per ${m.objectApiName}`).join(", ")+`), ${i.remaining??0} of ${i.max??0} left today`).join("; "),l=["lower the record counts",`set ${I(f)} to 0`,`turn off ${I(a.map(i=>`"${i}"`))}`,...h.map(i=>"give the user the seed writes as "+(i.permissionSet?`the permission set ${i.permissionSet}, whose ${i.permission}`:`a permission set holding ${i.permission}, which`)+` keeps ${I(i.quiets.map(m=>`"${m}"`))} quiet`)],w=`The seed was refused before it wrote anything: its records would make ${t} send ${b}. Past what is left, a flow that sends in the save refuses its record (CANNOT_EXECUTE_FLOW_TRIGGER), and the org's own emails stop for the rest of the day. To seed it, ${I(l,"or")}. Nothing was written.`;return{checks:p,refusal:w,figures:{org:t,limit:u.limit,emails:u.emails,remaining:u.remaining??0,max:u.max??0,objects:f,senders:a,bypasses:h},...R.length>0?{unknown:R}:{}}}var Ue={flow:e=>`flow "${e}"`,trigger:e=>`Apex trigger ${e}`,process:e=>`process "${e}"`,workflowRule:e=>`workflow rule "${e}"`},Ge={before:"before save",after:"after save",beforeAndAfter:"before and after save"},He={notification:"custom notifications",outbound:"outbound messages",sms:"text messages"};function Ke(e){let r=n=>n.held===!0?" (held)":n.held===!1?" (not held)":"",t=[Ge[e.when],...e.emails>0?[`${e.emails} email(s) a record`]:[],...e.messages.map(n=>`sends ${He[n]}`),...e.creates.length>0?[`creates ${e.creates.join(", ")}`]:[],...e.afterCommit?["then after commit"]:[],...e.bypasses.length>0?[`not for a user with ${e.bypasses.map(n=>n.name+r(n)).join(", ")}`]:[],...e.keptQuiet?["quiet for this seed"]:[],...e.unread?["what it does was not read"]:[]];return`${Ue[e.kind](e.name)} (${t.join("; ")})`}function Ot(e,r){if("error"in e)return[`target automation: what ${r} runs as these records are created could not be read (${e.error}): the emails they make it send are not known`];let{preview:t}=e,n=[`target automation: what ${r} runs as these records are created`];for(let o of t.objects)n.push(` ${o.objectApiName}: ${o.entries.map(Ke).join(", ")}`);t.objects.length===0&&n.push(t.blinded?" nothing found in what could be read":" nothing runs on them: no flow, Apex trigger, process or workflow rule"),t.bypassesHeld.length>0&&n.push(` bypass held: the user the seed writes as holds ${t.bypassesHeld.join(", ")}, and what names it stays quiet`);for(let o of t.bypasses)n.push(o.permissionSet?` bypass: ${o.permission} keeps quiet what names it; permission set ${o.permissionSet} holds it`:` bypass: ${o.permission} keeps quiet what names it; no permission set of ${r} was found to hold it`);t.alertsAsSingle&&t.emailsPerRecord.some(o=>o.alertsAmong)&&n.push(` ${r} counts its email alerts against its single emails too, as a Developer Edition does`);for(let{part:o,reason:s}of t.unread)n.push(` ${o} could not be read: ${s}`);return t.conditionsNotRead>0&&n.push(` ${t.conditionsNotRead} start condition(s) not read`),n}export{ze as a,rt as b,ot as c,st as d,at as e,ft as f,gt as g,ht as h,q as i,bt as j,yt as k,De as l,qe as m,wt as n,St as o,Ft as p,It as q,$t as r,Ot as s};
|
|
7
|
+
import{a as Re}from"./chunk-AHUGG3WU.mjs";import{K as we,Q as Se,b as ye}from"./chunk-OO24ZYYJ.mjs";import{Ga as he,Ia as be,h as x,i as fe,j as ge,k as D}from"./chunk-5OGNK3JP.mjs";import{o as se,p as ie,q as ae,r as de,s as ue}from"./chunk-YBZIDW6W.mjs";import{g as oe}from"./chunk-WXU6ZJIV.mjs";import{Lb as ce,Mb as le,Nb as N,Ob as me,Vb as B,hc as pe}from"./chunk-R3OM3X4L.mjs";import{h as re}from"./chunk-ZOSESZ22.mjs";import{b as z}from"./chunk-HFSBDM7B.mjs";import{q as F}from"./chunk-2GSMHGIV.mjs";import{b as v}from"./chunk-CA5NAXSU.mjs";import{c as ee,d as te,g as ne}from"./chunk-ISOSTAJR.mjs";import{Kd as K,Nd as Q,Pd as P,_d as V,be as X,ce as J,de as Y,ee as Z,h as W,i as O,id as H,k as U,vc as G}from"./chunk-6QSHWIZI.mjs";var L=1e4,$e=U.REST_API_BATCH_SIZE;function Oe(e){return e.id===void 0&&e.error!==void 0&&(e.errorDetails?.length??0)>0&&se([e.error],e.errorDetails)}function Pe(e,r){return e.error===void 0?e:{...e,error:ae(e.error,r)}}function C(e){return{successIds:e.flatMap(r=>r.id===void 0?[]:[r.id]),errors:e.flatMap(r=>r.error===void 0?[]:[r.error])}}function Ae(e,r){if(e.aborted||e.outcomes.length!==r||(e.unmatchedIds?.length??0)>0||(e.failures??[]).some(n=>n.recordIndex<0))return;let t=new Array(r);for(let n of e.outcomes){if(n.recordIndex<0||n.recordIndex>=r)return;if(n.success){if(!n.id)return;t[n.recordIndex]={id:n.id}}else{let o=n.error??"Unknown error",s=te(o);t[n.recordIndex]={error:o,...s?{errorDetails:[s]}:{}}}}return t.every(n=>n!==void 0)?t:void 0}function ze(e){let{conn:r,bulkManager:t,retry:n,signal:o,label:s}=e,p=new re(e.bulkThreshold),g,y=async(f,a,c)=>{g??=be(r).then(l=>(l||e.log(`[WARN] ${s}: the org's duplicate rules could not be read: an object of more than the Bulk API threshold goes as a Bulk API job, which a duplicate rule may refuse`),l));let h=await g;if(h===void 0)return he.has(f)?(e.log(`[INFO] ${s}: ${f} goes through REST: the duplicate rules could not be read, and a standard rule watches it`),!0):!1;let b=h.has(f);return b&&e.log(`[INFO] ${s}: ${f} goes through REST: an active duplicate rule watches it, which a Bulk API job cannot waive`+(a>L?` \u2014 ${a} records in ${Math.ceil(a/Math.max(1,c))} calls, slower than one job`:"")),b},R=async(f,a,c)=>{let h=[];for(let b=0;b<a.length;b+=c){if(o.aborted)return{rows:h,stopped:!0};let l=a.slice(b,b+c);e.calls?.sending(f,l.length);let w=await n.execute(async()=>r.sobject(f).create(l,{headers:G()}));if(w.cancelled)return e.calls?.answered(f,[]),{rows:h,stopped:!0};if(w.success&&w.result){let i=[];for(let m of w.result)if(m.success&&m.id)i.push(m.id),h.push({id:m.id});else{let d=ne(m.errors);h.push({error:d,errorDetails:(m.errors??[]).map(ee)})}e.calls?.answered(f,i)}else{let i=w.error?.message??"Insert failed after retries";for(let m=0;m<l.length;m++)h.push({error:i});e.calls?.answered(f,[])}}return{rows:h}},u=e.wait??(f=>ie(f,o)),A=async(f,a,c,h)=>{let b=Math.min(Math.max(1,h),$e),l=await de({outcomes:c,locked:Oe,written:i=>i.id!==void 0,send:async i=>(await R(f,i.map(m=>a[m]),b)).rows,note:Pe,wait:u,stopped:()=>o.aborted}),w=ue("record(s)",l);return{rows:l.outcomes,notes:w===void 0?[]:[`${f}: ${w}.`]}};return async(f,a,c,h)=>{let b=(c.length>L||p.shouldUseBulkApi(c.length))&&await y(a,c.length,h),l=b&&await g===void 0?[`The org's duplicate rules could not be read (the user SandForge connects as needs View Setup and Configuration): ${a}, which a standard duplicate rule watches, was sent through REST, whose header lets its matches be saved, rather than as a Bulk API job.`]:[];if(c.length>L&&!b){if(o.aborted)return{successIds:[],errors:[],stopped:!0};let d=new ye({signal:o}),S={connection:r,bulkManager:t,onProgress:(T,Ie)=>{e.onProgress(T,Ie,`Streaming insert ${a}`)},onOpened:T=>e.calls?.sending(a,c.length,{job:T})};e.calls?.sending(a,c.length);let E=await d.executeChunked(S,a,"insert",d.createChunkGenerator(c),c.length);e.calls?.answered(a,E.aborted?[]:E.successIds);let j=E.aborted?void 0:Ae({outcomes:E.outcomes??[],unmatchedIds:E.unmatchedIds},c.length),k=j&&await A(a,c,j,h);return k&&k.notes.length>0?{...C(k.rows),notes:k.notes}:{successIds:E.successIds,errors:E.errors,...E.aborted?{stopped:!0}:{}}}if(p.shouldUseBulkApi(c.length)&&!b){if(o.aborted)return{successIds:[],errors:[],stopped:!0};let d={connection:r,bulkManager:t,onProgress:(k,T)=>{e.onProgress(k,T,`Bulk insert ${a}`)},signal:o,onOpened:k=>e.calls?.sending(a,c.length,{job:k})};e.calls?.sending(a,c.length);let S=await p.executeBulk(d,a,"insert",c);e.calls?.answered(a,S.aborted?[]:S.successIds);let E=Ae(S,c.length),j=E&&await A(a,c,E,h);return j&&j.notes.length>0?{...C(j.rows),rows:j.rows,notes:j.notes}:{successIds:S.successIds,errors:S.failures.map(k=>k.error),...E?{rows:E}:{},...S.aborted?{stopped:!0}:{}}}let w=await R(a,c,h);if(w.stopped)return{...C(w.rows),rows:w.rows,stopped:!0};let i=await A(a,c,w.rows,h),m=[...l,...i.notes];return{...C(i.rows),rows:i.rows,...m.length>0?{notes:m}:{}}}}var xe="SELECT Id, DeveloperName FROM RecordType WHERE SobjectType = 'Account' AND IsPersonType = true";async function rt(e){try{return(await e.query(xe)).records.flatMap(t=>typeof t.Id=="string"&&typeof t.DeveloperName=="string"?[{id:t.Id,developerName:t.DeveloperName}]:[])}catch{return[]}}function ot(e,r,t){let n=new Set(e===F?t.map(o=>o.id.slice(0,15)):[]);return z(r).filter(o=>!o.master&&o.active&&o.available).map(o=>({recordTypeId:o.recordTypeId,developerName:o.developerName,label:o.name,person:n.has(o.recordTypeId.slice(0,15)),isDefault:o.defaultRecordTypeMapping}))}function Ce(e){let{staticValue:r,picklistValues:t}=e.config;return e.ruleType==="static"&&typeof r=="string"?[r]:e.ruleType==="picklist_random"?[...t??[]]:[]}function st(e,r){if(r.length===0)return{template:e,personObjects:[]};let t=new Map(r.map(s=>[s.id.slice(0,15),s.developerName])),n=[],o=[];for(let s of e.objects){if(s.objectApiName!==F){o.push(s);continue}let p=s.fieldRules.find(u=>u.fieldApiName==="RecordTypeId"),g=p?Ce(p):[],y=g.filter(u=>t.has(u.slice(0,15)));if(y.length>0&&y.length<g.length){let u=y.map(A=>t.get(A.slice(0,15))).join(", ");return{refusal:`${F}: ${u} ${y.length===1?"is a person account record type":"are person account record types"} and the other record types chosen are not: a person account and a business account take different fields. Seed one kind in a run.`}}let R=y.length>0?"person":"business";R==="person"&&n.push(s.objectApiName),o.push({...s,fieldRules:s.fieldRules.filter(u=>!H(F,u.fieldApiName,R))})}return{template:{...e,objects:o},personObjects:n}}var Me=/^[a-z]{2,3}(?:_[A-Za-z0-9]{2,4}){0,2}$/;async function ve(e){try{let t=(await e.query("SELECT DefaultLocaleSidKey FROM Organization LIMIT 1")).records[0]?.DefaultLocaleSidKey;return typeof t=="string"&&Me.test(t)?t:void 0}catch{return}}async function at(e,r){return e??await ve(r)??"en_US"}var ft="SEED_FIT_STORAGE_UNREAD",gt="SEED_CANNOT_FIT";function ht(e,r=!1){return q(e.objects.filter(t=>t.recordCount>0).map(t=>t.objectApiName),r)}function q(e,r=!1){let t=new Set(e);return(n,o)=>t.has(n)&&(o==="insert"||o==="update"&&r&&n===Re)}function bt(e,r,t,n){if(typeof e.unread=="string")return{room:{perRecord:[],notCounted:[],unread:e.unread},unread:e.unread};let o=Z(e,r,t);if(!n)return{running:o,room:x(o,t)};let s=[],p=new Set,g=[];for(let u of o.firing){let A=u.flow,f=A?.requiresFilled??[];if(u.write!=="insert"||A?.condition!=="read"||!A.creates?.length)continue;let a=f.filter(b=>n(u.objectApiName,b)==="every"),c=f.filter(b=>n(u.objectApiName,b)==="some"),h={objectApiName:u.objectApiName,name:u.name};a.length>0&&!Ne(o.firing,u)?(p.add(u),s.push({...h,fields:a,why:"leftEmpty"})):(a.length>0||c.length>0)&&(g.push(u),s.push({...h,fields:a.length>0?a:c,why:a.length>0?"automationMayFill":"mayBeLeftEmpty"}))}let y=x({firing:o.firing.filter(u=>!p.has(u))},t),R=x({firing:g},t).perRecord;return{running:o,room:{...y,...R.length>0?{atMost:R}:{},...s.length>0?{starts:s}:{}}}}function Ne(e,r){return e.some(t=>t!==r&&t.objectApiName===r.objectApiName&&t.write==="insert"&&(t.kind==="trigger"||t.kind==="process"||t.kind==="workflowRule"||t.flow?.timing==="beforeSave"))}async function yt(e,r,t){let n=new Set("objects"in r?r.objects.filter(s=>s.flows.some(p=>(p.requiresFilled??[]).length>0)).map(s=>s.objectApiName):[]),o=new Map;for(let s of e.objects)s.recordCount<=0||!n.has(s.objectApiName)||o.set(s.objectApiName,await t(s.objectApiName).catch(()=>{}));return(s,p)=>{let g=e.objects.find(a=>a.objectApiName===s);if(!g)return"none";let y=a=>a.toLowerCase()===p.toLowerCase();if(g.fieldRules.some(a=>y(a.fieldApiName)))return"none";let R=O(s,e.relations);if(R&&y(R.lookupField))return"none";let u=g.rows??[],A=u.filter(a=>Object.entries(a.values).some(([c,h])=>y(c)&&h!==null&&h!=="")).length;if(u.length>0&&A===u.length)return"none";let f=o.get(s);return f?[...f.filled].some(y)?"none":A>0?"some":[...f.empty].some(y)?"every":"some":"some"}}function M(e,r){return O(e.objectApiName,r)?.distribution.mode==="byKey"?"byKey":e.rows!==void 0?"rows":void 0}function ke(e,r){let t=O(e,r.relations);if(!(!t||t.parents.kind!=="generated"||t.distribution.mode==="byKey"||t.parentObject===e||!r.objects.some(n=>n.objectApiName===t.parentObject)))return t}function Ee(e,r){let t=r?.objects?.[e.objectApiName]??r?.all;return t!==void 0?Math.min(e.recordCount,Math.max(1,Math.floor(t))):e.recordCount}function Be(e,r,t){let n=new Map(e.objects.map(g=>[g.objectApiName,g])),o=new Map,s=new Set,p=g=>{let y=o.get(g);if(y!==void 0)return y;let R=n.get(g);if(M(R,e.relations))return o.set(g,R.recordCount),R.recordCount;s.add(g);let u=Math.round(r*Ee(R,t)),A=ke(g,e),f=A&&!s.has(A.parentObject)?Math.max(1,Math.min(u,W(A.distribution,p(A.parentObject)))):Math.max(1,u);return s.delete(g),o.set(g,f),f};return new Map(e.objects.map(g=>[g.objectApiName,p(g.objectApiName)]))}function De(e,r){if(r.cannotFit!==void 0)return e;let t=new Map(r.objects.map(n=>[n.objectApiName,n.after]));return{...e,objects:e.objects.map(n=>{let o=t.get(n.objectApiName);return o!==void 0&&o<n.recordCount?{...n,recordCount:o}:n})}}function Le(e,r){let t=e.objects.filter(s=>!M(s,e.relations)),n=t.filter(s=>!ke(s.objectApiName,e)),o;for(let s of n.length>0?n:t){let p=Ee(s,r);(!o||p>o.records)&&(o={objectApiName:s.objectApiName,records:p})}return o}function _e(e){return`${e} record${e===1?"":"s"}`}function qe(e){let{template:r,personObjects:t,budget:n,room:o}=e,s=e.ask?.caps,p=e.ask?.share===!0||s===void 0,g=d=>{let S=Be(r,d,s),E=De(r,{objects:r.objects.map(k=>({objectApiName:k.objectApiName,before:k.recordCount,after:S.get(k.objectApiName)??k.recordCount}))}),j=fe(o,k=>S.get(k)??0);return{counts:S,bytes:Se(E,t)+j,roomBytes:j,requests:we(E,e.path),records:[...S.values()].reduce((k,T)=>k+T,0)}},y=d=>d.bytes<=n.bytes,R=d=>n.runRequests===void 0||d.requests<=n.runRequests,u=d=>y(d)&&R(d),A=(d,S,E,j)=>({share:d,budget:{...ge(n,S.roomBytes,o),...E==="apiRequests"?{limitedBy:"apiRequests"}:{}},objects:r.objects.map(k=>{let T=M(k,r.relations);return{objectApiName:k.objectApiName,before:k.recordCount,after:S.counts.get(k.objectApiName)??k.recordCount,...T?{keptWhole:T}:{}}}),estimateMB:S.bytes/1048576,...j!==void 0?{cannotFit:j}:{},...o.unread!==void 0?{automationUnread:o.unread}:{}}),f=(d,S,E,j)=>({proposal:A(d,S,E,j),heldBy:E,records:S.records,requests:S.requests}),a=d=>{if(y(d))return`about ${d.requests} API requests, past the ${n.runRequests??0} that leave the org a tenth of its daily requests`;let S=pe(d.bytes/1048576,n.bytes/1048576);return`${S.over} MB`+(d.roomBytes>0?", room for what the org's automation creates under them included":"")+`, past the ${S.bound} MB that fit`},c=d=>y(d)?"apiRequests":n.terms.limitedBy,h=r.objects.filter(d=>M(d,r.relations)).reduce((d,S)=>d+S.recordCount,0),b=g(1);if(u(b)){let d=r.objects.some(S=>(b.counts.get(S.objectApiName)??0)<S.recordCount);return f(1,b,d?"caps":"whole")}if(!p)return f(1,b,c(b),`with these caps the seed takes ${a(b)}: lower them, or fit by share`);let l=Le(r,s);if(!l)return f(1,b,c(b),`the ${h} rows the template gives take ${a(b)}, and rows are kept whole`);let w=d=>g(d/l.records),i=D(l.records,d=>u(w(d)));if(i===0){let d=w(1);return f(1/l.records,d,c(d),`the least it can be cut to \u2014 one ${l.objectApiName} and what follows it`+(h>0?`, with the ${h} rows the template gives kept whole`:"")+`, ${_e(d.records)} \u2014 takes ${a(d)}`)}let m=D(l.records,d=>y(w(d)));return f(i/l.records,w(i),m>i?"apiRequests":n.terms.limitedBy)}function wt(e,r,t,n,o){if(!("unread"in e))return qe({template:r,personObjects:t,budget:e,room:n,path:o}).proposal}function St(e,r){if(!(!e||e.before<r))return{module:"seed",share:e.share,...e.withinMB!==void 0?{withinMB:e.withinMB}:{},kept:r,inSource:e.before}}var Fe=(e,r)=>r==="insert";function je(e){return typeof e.unread=="string"}function We(e){return(K(e).find(t=>t.write==="insert")?.fired??[]).map(t=>{let n=t.flow,o=n?.messages??[];return{kind:t.kind,name:t.name,when:t.when,emails:o.filter(s=>s.kind==="email").length,messages:[...new Set(o.flatMap(s=>s.kind==="email"?[]:[s.kind]))],creates:[...n?.creates??[]],afterCommit:(n?.paths?.length??0)>0,bypasses:(n?.permissions??[]).filter(s=>s.bypass).map(({name:s,held:p})=>p===void 0?{name:s}:{name:s,held:p}),keptQuiet:t.keptQuiet===!0,unread:n!==void 0&&n.condition!=="read"}})}function $(e){return[...new Set(e)].sort((r,t)=>r.localeCompare(t))}function Te(e,r,t,n,o=Fe){let s=e.objects.flatMap(l=>{let w=We(l);return w.length>0?[{objectApiName:l.objectApiName,entries:w}]:[]}),p=je(t)?void 0:t,g=p!==void 0&&ce(p),y=p!==void 0&&le(p),R=N(P(e),g,y),u=s.flatMap(l=>l.entries.flatMap(w=>w.bypasses)),A=$(u.filter(l=>l.held===!0).map(l=>l.name)),f=$(u.map(l=>l.name)).filter(l=>!A.includes(l)),a=V(e,f),c=f.map(l=>{let w=a.find(i=>i.permission.toLowerCase()===l.toLowerCase())?.permissionSet;return w?{permission:l,permissionSet:w.name}:{permission:l}}),h=X(e,o),b=h.assign.length>0;return{org:r,objectsRead:[...e.objectsRead],objects:s,emailsPerRecord:R,...p&&R.length>0?{limits:{...p}}:{},...je(t)?{limitsUnread:t.unread}:{},alertsAsSingle:g,bypasses:c,bypassesHeld:A,...b?{mute:h,emailsPerRecordMuted:N(P(Y(e,J(h))),g,y)}:{},unread:e.unread.map(({part:l,reason:w})=>({part:l,reason:w})),blinded:Q(e.unread),conditionsNotRead:e.conditionsNotRead,...n?{deliverability:n}:{}}}async function Ft(e){let r=e.writes??q(e.objects),t;try{t=await e.readAutomation(e.objects)}catch(s){return{error:v(s)}}let n=e.deliverability??(e.readDeliverability?(await oe({read:t,writes:Fe,readDeliverability:e.readDeliverability,accepted:!1,target:e.org,run:"seed"})).gate.deliverability:void 0);if(P(t).length===0)return{preview:Te(t,e.org,{},n,r)};let o=await e.readLimits().catch(s=>({unread:v(s)}));return{preview:Te(t,e.org,o,n,r)}}function I(e,r="and"){return e.length<=1?e.join(""):e.length===2?`${e[0]} ${r} ${e[1]}`:`${e.slice(0,-1).join(", ")}, ${r} ${e[e.length-1]}`}var It="SEED_EMAILS_EXCEEDED";function $t(e,r,t){if("error"in e)return{checks:[],unknown:[`what ${t} runs as these records are created could not be read (${e.error}): the emails they make it send are not known`]};let{preview:n}=e,o={objects:r.map(i=>({objectApiName:i.objectApiName,rows:i.recordCount,storageBytes:0}))},s=n.limitsUnread!==void 0?{unread:n.limitsUnread}:n.limits??{},p=me(o,n.emailsPerRecord,s),g=new Set(r.filter(i=>i.recordCount>0).map(i=>i.objectApiName)),y=n.objects.flatMap(i=>g.has(i.objectApiName)?i.entries.filter(m=>m.unread&&!m.keptQuiet&&m.when!=="before").map(m=>`"${m.name}" on ${i.objectApiName}`):[]),R=[...p.filter(i=>i.verdict==="unread").map(i=>`about ${B(i.emails,i.limit)}, but what ${t} has left today could not be read (${i.unread??"not said"})`),...n.blinded?[`part of what ${t} runs could not be read: emails it sends may not be counted`]:[],...y.length>0?[`the emails of ${I(y)} are not counted: what ${y.length===1?"it does":"they do"} was not read`]:n.conditionsNotRead>0?[`${n.conditionsNotRead} start condition(s) of ${t} not read: the emails of those flows are not counted`]:[]],u=p.find(i=>i.verdict==="exceeds");if(!u)return R.length>0?{checks:p,unknown:R}:{checks:p};let A=p.filter(i=>i.verdict==="exceeds"),f=$(A.flatMap(i=>i.objects.map(m=>m.objectApiName))),a=$(A.flatMap(i=>i.objects.flatMap(m=>m.sentBy))),c=new Map;for(let i of n.objects.flatMap(m=>m.entries))if(!(i.emails===0||!a.includes(i.name)))for(let{name:m}of i.bypasses)c.set(m,(c.get(m)??new Set).add(i.name));let h=n.bypasses.flatMap(i=>{let m=c.get(i.permission);return m?[{...i,quiets:$([...m])}]:[]}),b=A.map(i=>`about ${B(i.emails,i.limit)} (`+i.objects.map(m=>`${m.perRecord} per ${m.objectApiName}`).join(", ")+`), ${i.remaining??0} of ${i.max??0} left today`).join("; "),l=["lower the record counts",`set ${I(f)} to 0`,`turn off ${I(a.map(i=>`"${i}"`))}`,...h.map(i=>"give the user the seed writes as "+(i.permissionSet?`the permission set ${i.permissionSet}, whose ${i.permission}`:`a permission set holding ${i.permission}, which`)+` keeps ${I(i.quiets.map(m=>`"${m}"`))} quiet`)],w=`The seed was refused before it wrote anything: its records would make ${t} send ${b}. Past what is left, a flow that sends in the save refuses its record (CANNOT_EXECUTE_FLOW_TRIGGER), and the org's own emails stop for the rest of the day. To seed it, ${I(l,"or")}. Nothing was written.`;return{checks:p,refusal:w,figures:{org:t,limit:u.limit,emails:u.emails,remaining:u.remaining??0,max:u.max??0,objects:f,senders:a,bypasses:h},...R.length>0?{unknown:R}:{}}}var Ue={flow:e=>`flow "${e}"`,trigger:e=>`Apex trigger ${e}`,process:e=>`process "${e}"`,workflowRule:e=>`workflow rule "${e}"`},Ge={before:"before save",after:"after save",beforeAndAfter:"before and after save"},He={notification:"custom notifications",outbound:"outbound messages",sms:"text messages"};function Ke(e){let r=n=>n.held===!0?" (held)":n.held===!1?" (not held)":"",t=[Ge[e.when],...e.emails>0?[`${e.emails} email(s) a record`]:[],...e.messages.map(n=>`sends ${He[n]}`),...e.creates.length>0?[`creates ${e.creates.join(", ")}`]:[],...e.afterCommit?["then after commit"]:[],...e.bypasses.length>0?[`not for a user with ${e.bypasses.map(n=>n.name+r(n)).join(", ")}`]:[],...e.keptQuiet?["quiet for this seed"]:[],...e.unread?["what it does was not read"]:[]];return`${Ue[e.kind](e.name)} (${t.join("; ")})`}function Ot(e,r){if("error"in e)return[`target automation: what ${r} runs as these records are created could not be read (${e.error}): the emails they make it send are not known`];let{preview:t}=e,n=[`target automation: what ${r} runs as these records are created`];for(let o of t.objects)n.push(` ${o.objectApiName}: ${o.entries.map(Ke).join(", ")}`);t.objects.length===0&&n.push(t.blinded?" nothing found in what could be read":" nothing runs on them: no flow, Apex trigger, process or workflow rule"),t.bypassesHeld.length>0&&n.push(` bypass held: the user the seed writes as holds ${t.bypassesHeld.join(", ")}, and what names it stays quiet`);for(let o of t.bypasses)n.push(o.permissionSet?` bypass: ${o.permission} keeps quiet what names it; permission set ${o.permissionSet} holds it`:` bypass: ${o.permission} keeps quiet what names it; no permission set of ${r} was found to hold it`);t.alertsAsSingle&&t.emailsPerRecord.some(o=>o.alertsAmong)&&n.push(` ${r} counts its email alerts against its single emails too, as a Developer Edition does`);for(let{part:o,reason:s}of t.unread)n.push(` ${o} could not be read: ${s}`);return t.conditionsNotRead>0&&n.push(` ${t.conditionsNotRead} start condition(s) not read`),n}export{ze as a,rt as b,ot as c,st as d,at as e,ft as f,gt as g,ht as h,q as i,bt as j,yt as k,De as l,qe as m,wt as n,St as o,Ft as p,It as q,$t as r,Ot as s};
|
|
@@ -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}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e,f,g,h}from"./chunk-KKS2KFBT.mjs";import"./chunk-OTJH6AEA.mjs";import"./chunk-AHUGG3WU.mjs";import"./chunk-FVLFO2S6.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-MJD6CPZZ.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{d as ARTICLE_OBJECT,b as CASE_STATUS_BY_LABEL_SOQL,a as CASE_STATUS_SOQL,g as prepareScenario,c as readScenarioCaseStatus,f as scenarioCasePicklists,e as scenarioKnowledge,h as toolingQueryAll};
|
|
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as qr}from"./chunk-INIQ23K6.mjs";import{a as Gr}from"./chunk-
|
|
7
|
+
import{a as qr}from"./chunk-INIQ23K6.mjs";import{a as Gr}from"./chunk-J3TIHLWG.mjs";import{b as Kt}from"./chunk-ETNQHIDI.mjs";import{$ as Kr,C as _r,F as Wr,G as Ur,H as Br,V as zr,W as mt,X as wt,Y as Jr,Z as Hr,aa as yt,ba as Yr,c as Or,e as jr,f as Cr,h as xr,j as Ir,k as Er,u as Tr,x as Mr}from"./chunk-OO24ZYYJ.mjs";import{b as Fr,g as Pr}from"./chunk-ALBY5SOH.mjs";import{a as Lr,f as Dr}from"./chunk-6YC2ELCU.mjs";import{e as gt,m as Nr}from"./chunk-GEEWPTV5.mjs";import{Ab as Sr,Bb as ft,Cb as vr,Db as $r,Eb as Ar,Wa as De,Y as hr,cb as pr,d as at,db as ct,e as rr,f as or,g as sr,h as ir,i as dt,j as ar,k as dr,l as cr,lb as gr,mb as mr,n as ur,p as lr,pb as ut,qb as We,rb as wr,sb as lt,tb as yr,xb as br,yb as Rr,zb as kr}from"./chunk-LYOGCIYD.mjs";import{k as Mn,n as _n}from"./chunk-X4HZD5U2.mjs";import{a as _e,j as Xn,k as Zn}from"./chunk-BNKT3R3F.mjs";import{b as xe,e as Ve}from"./chunk-BZ24IAP5.mjs";import{a as _t}from"./chunk-SCKUIE3R.mjs";import{a as Yt,b as Vt,c as Te,d as Xt,e as Zt,g as Qt,h as en,j as tn}from"./chunk-6FARZYMJ.mjs";import{a as ht,c as pt}from"./chunk-HVX2AFYW.mjs";import{B as hn,Gc as En,x as ln,y as fn,yc as Cn}from"./chunk-AXFD2OH6.mjs";import{h as ot,i as st}from"./chunk-X2XZQ434.mjs";import{Wa as Qn,Xa as er,bb as tr,db as nr,m as Le}from"./chunk-5OGNK3JP.mjs";import{k as Vn}from"./chunk-QLRWU3MB.mjs";import{b as yn,l as In}from"./chunk-XMQ5R6TC.mjs";import{B as mn,M as Fe,P as wn,a as nn}from"./chunk-IXIY6Q4M.mjs";import{n as Nn}from"./chunk-YBZIDW6W.mjs";import{a as Ze,b as bn,c as kn,f as Sn,h as Qe,k as vn,l as $n,n as An,o as On,p as et,s as tt,u as nt,x as jn}from"./chunk-BT43WSOS.mjs";import{c as rt,d as xn}from"./chunk-EOQON3E5.mjs";import{a as Pe,b as Ne,g as Pn,h as Me,j as fe}from"./chunk-7WSQ65WG.mjs";import{b as Ce,c as ke}from"./chunk-7ZBDACVG.mjs";import{a as Re,b as Jt,f as Ye}from"./chunk-4GCYGQXD.mjs";import{b as Tn,c as Fn}from"./chunk-WXU6ZJIV.mjs";import{Cc as Kn,Dc as Yn,Fa as Dn,Jb as qn,Ua as Wn,Va as Un,Vb as Gn,Yb as it,_a as Bn,ac as zn,bb as he,c as Xe,gc as Jn,ha as Ln,nc as Hn}from"./chunk-R3OM3X4L.mjs";import{i as rn}from"./chunk-INIT2UKJ.mjs";import{h as gn}from"./chunk-ZOSESZ22.mjs";import{b as co}from"./chunk-MS4FJDFD.mjs";import{D as le,F as un,p as an}from"./chunk-ZXOUWHYE.mjs";import{b as Ht,d as Ie,f as Ee,h as fr}from"./chunk-LCDPCUXS.mjs";import{a as re}from"./chunk-EADHKH3A.mjs";import{j as pn}from"./chunk-ISOSTAJR.mjs";import{j as on,w as sn}from"./chunk-ICIYL45C.mjs";import{a as cn}from"./chunk-7BQMBXKX.mjs";import{a as dn}from"./chunk-KWAVSZ2B.mjs";import{d as Rn}from"./chunk-TUACWKIH.mjs";import{Vc as Dt,Wc as Ke,Wd as qt,Yd as Gt,Zc as Wt,Zd as zt,ld as Ut,md as Bt,vc as Lt}from"./chunk-6QSHWIZI.mjs";import{A as R}from"./chunk-WZQEK4WT.mjs";import{d as ao}from"./chunk-NTOVCTRS.mjs";var ko=ao(co());import{randomUUID as go}from"node:crypto";import{existsSync as Se,mkdirSync as mo,readFileSync as ve,renameSync as wo,writeFileSync as yo}from"node:fs";import{dirname as bo,join as pe,resolve as Ro}from"node:path";var So=`sandforge sync \u2014 run a Sync between two orgs, without the editor.
|
|
8
8
|
|
|
9
9
|
Usage:
|
|
10
10
|
npx sandforge sync \\
|
|
@@ -335,7 +335,7 @@ done in ${Date.now()-r}ms`)},g=i.runs!==void 0&&(l.jobs??[]).length>0;if(et(l).l
|
|
|
335
335
|
`):n(`
|
|
336
336
|
done in ${Date.now()-r}ms`),h.refusal!==void 0&&process.exit(Zr);return}let S=tt(l),A,b={kept:[...S],notKept:0};if(S.length>0){let h=ht(),m=pt(h);if(m!==void 0)n(m);else{A=new st(ot(h));let j=Le(pe(h,"snapshots.json"));b=En(S,v=>j.get(`backup:${v}`),30)}}n(`sandforge sync --remove ${e.summaryPath} from ${e.target}`);for(let{objectApiName:h,ids:m}of b.kept)n(` ${h}: ${m.length} to give back their values from before the run`);b.notKept>0&&n(` values from before no longer kept (past sandforge.backup.maxAgeDays, or deleted): ${b.notKept} record(s) the run wrote over keep its values`),b.keptUntil!==void 0&&b.kept.length>0&&n(` values from before kept until ${b.keptUntil}, at the default retention`);let G=nt(l);for(let{objectApiName:h,ids:m}of G)n(` ${h}: ${m.length} the run deleted, as the source had, to bring back from the recycle bin`);for(let{objectApiName:h,ids:m}of x)n(` ${h}: ${m.length} to remove`);x.length===0&&S.length===0&&G.length===0&&n("nothing left of the run to remove"),e.sweep&&n(`before them, a sweep deletes what the target's automation made for the run, as the run's user, tied to its records \u2014 run ${ut("--sweep-list")} to see what`);let P=new AbortController,z=Ve(()=>P.abort()),Q=d??{},_=e.sweep?er(ft(k,"sandforge sync --sweep",P.signal),await U(P.signal),{includeChanged:e.includeChanged,removalSpans:Q.removalSpans??[],...kr(e),approve:async h=>{a=h,n("");for(let m of We(h,e.target,e))n(m)}}):void 0;await _?.ask();let J=wr(_,a);if(J){a=J,n("");for(let h of We(J,e.target,e))n(h)}let L=h=>[...new Set(h.map(({objectApiName:m})=>m))],B=qt({bringBack:L(G),giveBack:L(b.kept),setToDraft:mn(L(x)),delete:wn(L(x))},_?.takes??[]),$e=[...new Set(Object.values(B).flat())];function H(h){return process.stderr.write(`${Te(h)}
|
|
337
337
|
`),e.json&&process.stdout.write(Qt({tool:"sandforge-sync",summary:e.summaryPath,target:e.target,elapsedMs:Date.now()-r},h)),process.exit(1)}let K=h=>(z(),H(h)),D;if($e.length>0&&!P.signal.aborted){let h=await De(k).read(e.target,$e,{undeletes:!0});n("");for(let v of Kn(h,e.target,B))n(v);if(e.muteAutomation)try{D=await Me(async()=>Pe(k),h,{writes:Gt(B)});for(let v of fe(D.muted,e.target))n(` ${v}`)}catch(v){if(!Ne(v))throw v;K(v.refusal)}let m=D?.automation??h,j=Yn(m,e.target,{steps:B,assign:Hn(m,zt(m,B)),mayMute:D===void 0&&Xn("--mute-automation")});j&&!e.acceptAutomation&&K({code:"AUTOMATION_NOT_ACCEPTED",message:j})}let O,oe,N=D?.muted,W=async()=>{!D?.prepared||P.signal.aborted||(oe=await D.prepared.acquire(`sandforge sync --remove ${l.runId}`).catch(h=>{if(!Ne(h))throw h;return K(h.refusal)}),N=oe.outcome)},se=Fe(k,"sandforge sync --remove"),Y=await Ir(se,l.created),ie;try{O=await Cn({run:l,org:se,includeChanged:e.includeChanged,...Sr(_),...i.runUserId?{runUserId:i.runUserId}:{},onUndeletable:lr(e.leaveUndeletable,e.target,h=>{ie=h}),beforeFirstWrite:W,signal:P.signal,...u&&e.store!==void 0?{configs:u,links:Ze(e.store)}:{},...A?{backups:A}:{},undelete:h=>k.soap.undelete(h),...i.runs?{earlierRuns:jn(l,await i.runs.list())}:{},store:{updateRemoval:(h,m)=>h!==l.runId&&i.runs?i.runs.updateRemoval(h,m):i.updateRemoval(j=>(Q=m(j),Q))}})}finally{z();let h=_?.made??new Set,m=_?.late??new Set,j=_?.gone??new Set;if((h.size>0||m.size>0||j.size>0)&&await i.updateRemoval(v=>Tr(v,h,m,j)).catch(v=>{process.stderr.write(`What the sweep found made for the run could not be kept (${v instanceof Error?v.message:String(v)}): a later --sweep may list it as tied to nothing.
|
|
338
|
-
`)}),oe){N=await oe.release();for(let v of fe(N,e.target))n(v)}}N&&(O={...O,result:{...O.result,mutedAutomation:N}}),O.stoppedForUndeletable&&(ie&&H(ie),process.exit(1));let T=O.result.status==="cancelled"?{}:await Y.take();for(let h of[...O.notes,...T.note?[T.note]:[]])process.stderr.write(`${h}
|
|
338
|
+
`)}),oe){N=await oe.release();for(let v of fe(N,e.target))n(v)}}N&&(O={...O,result:{...O.result,mutedAutomation:N}}),O.stoppedForUndeletable&&(ie&&H(ie),process.exit(1));let T=O.result.status==="cancelled"?{}:await Y.take(O.duplicateSets);for(let h of[...O.notes,...T.note?[T.note]:[]])process.stderr.write(`${h}
|
|
339
339
|
`);let qe=O.result.objects.some(h=>h.deleted+h.alreadyGone>0);i.configId!==void 0&&!u&&qe&&process.stderr.write(`The run was of the saved configuration ${i.configId}, and its store was not given: its next delta run is not told what this removal took, and a later run may point a lookup at a record it deleted. Give ${Zn("--store")} with the next removal, or run the configuration full next time.
|
|
340
340
|
`);let{readWhole:V,filesForgotten:ge}=O.result,ae=_?.result(),me=yn(O.result.status,ae);f(me,T.object?[...O.result.objects,T.object]:O.result.objects,O.planned,{...V?{readWhole:V}:{},...ge!==void 0?{filesForgotten:ge}:{},...O.linksForgotten!==void 0?{linksForgotten:O.linksForgotten}:{}},ae,O.result.restored,O.result.undeleted,N),me!=="success"&&process.exit(Zr)}process.argv[1]?.includes("sandforge-sync")&&(fr(),Zo().then(()=>process.exit(process.exitCode??0)).catch(t=>{process.stderr.write(`${t instanceof Error?t.message:String(t)}
|
|
341
341
|
`),process.exit(1)}));export{ko as a,Oo as b,jo as c,Co as d,Qr as e,xo as f,Io as g,Vr as h,Eo as i,Rt as j,To as k,Fo as l,Po as m,Xr as n,kt as o,eo as p,to as q,no as r,Mo as s,Lo as t,Uo as u,qo as v,ro as w,Go as x,zo as y,Jo as z,Ho as A,Ko as B,Yo as C,St as D,Zo as E,es as F,ns as G,rs as H,os as I,ss as J,is as K,as as L,ds as M,cs as N,ls as O,gs as P,ms as Q};
|
|
@@ -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{G as w,
|
|
7
|
+
import{G as w,Jc as v,Ub as k,e as m,ec as j,f as h,i as $,j as y}from"./chunk-6QSHWIZI.mjs";var R=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,T=new Set(["static","random","sequence","formula","reference","picklist_random","ai_generate","faker","regex","from_csv"]),A=class{validate(n){let t=[],a=[];return S(n,t),N(n,t,a),P(n,t),n.objects?.length&&C(n,t),M(n,t),q(n,t),{valid:t.length===0,errors:t,warnings:a}}};function S(e,n){(!e.name||e.name.trim().length===0)&&n.push({field:"name",message:"Template name is required"})}function N(e,n,t){if(!e.objects||e.objects.length===0){n.push({field:"objects",message:"Template must have at least one object"});return}for(let a of e.objects)E(a,n,t,$(a.objectApiName,e.relations))}function E(e,n,t,a){let i=`objects[${e.objectApiName}]`;(!e.objectApiName||e.objectApiName.trim().length===0)&&n.push({field:i,message:"Object API name is required"}),e.recordCount<=0&&n.push({field:`${i}.recordCount`,message:"Record count must be positive"}),e.recordCount>0&&e.fieldRules.length===0&&!a&&!V(e.rows)&&n.push({field:`${i}.fieldRules`,message:`${e.objectApiName} asks for ${e.recordCount} record(s) and names no field to fill: add at least one field rule`}),e.recordCount>1e5&&t.push({field:`${i}.recordCount`,message:"Record count exceeds 100,000 \u2014 consider using grappe mode"}),e.batchSize<=0&&n.push({field:`${i}.batchSize`,message:"Batch size must be positive"});for(let s of e.fieldRules)F(s,i,n);e.rows!==void 0&&x(e.rows,i,n)}function V(e){return Array.isArray(e)&&e.some(n=>b(n?.values)&&Object.keys(n.values).length>0)}function b(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function x(e,n,t){if(!Array.isArray(e)||e.length===0){t.push({field:`${n}.rows`,message:"Rows, when given, are at least one"});return}let a=new Set,i=h.maxKeyLength;for(let[s,o]of e.entries()){let r=`${n}.rows[${s}]`,c=b(o)?o:{},{key:d,parentKey:l,values:f}=c;if(typeof d!="string"||d.length===0||d.length>i?t.push({field:`${r}.key`,message:`A row is named by a key of 1 to ${i} characters`}):a.has(d)?t.push({field:`${r}.key`,message:`The key "${d}" names more than one row: each row is named once`}):a.add(d),l!==void 0&&(typeof l!="string"||l.length===0||l.length>i)&&t.push({field:`${r}.parentKey`,message:`A row names its parent by a key of 1 to ${i} characters`}),!b(f)){t.push({field:`${r}.values`,message:"A row gives its values as fields and values"});continue}for(let[u,g]of Object.entries(f))O(g)||t.push({field:`${r}.values[${u}]`,message:`${u} is given a value no field takes: a text of at most ${h.maxTextLength} characters, a number, true or false, or null`})}}function O(e){return e===null||typeof e=="boolean"?!0:typeof e=="number"?Number.isFinite(e):typeof e=="string"&&e.length<=h.maxTextLength}function C(e,n){let t=i=>{let[s,o,...r]=i,c=s==="objects"?e.objects[Number(o)]:void 0,d=s==="relations"?e.relations?.[Number(o)]:void 0,l=c?`objects[${c.objectApiName}]`:d?`relations[${d.childObject}.${d.lookupField}]`:`${String(s)}[${String(o)}]`;return r.reduce((f,u)=>typeof u=="number"?`${f}[${u}]`:`${f}.${u}`,l)};if(e.objects.every(i=>i.rows===void 0||Array.isArray(i.rows)&&i.rows.every(b)))for(let i of w(e))n.push({field:t(i.path),message:i.message})}function F(e,n,t){let a=`${n}.fieldRules[${e.fieldApiName}]`;(!e.fieldApiName||e.fieldApiName.trim().length===0)&&t.push({field:a,message:"Field API name is required"}),T.has(e.ruleType)||t.push({field:`${a}.ruleType`,message:`Invalid rule type: ${e.ruleType}`}),I(e,a,t)}function I(e,n,t){switch(e.ruleType){case"reference":e.config.referenceObject||t.push({field:`${n}.config.referenceObject`,message:"Reference rule requires a referenceObject"});break;case"picklist_random":(!e.config.picklistValues||e.config.picklistValues.length===0)&&t.push({field:`${n}.config.picklistValues`,message:"Picklist rule requires at least one value"});break;case"faker":e.config.fakerMethod?j(e.config.fakerMethod)||t.push({field:`${n}.config.fakerMethod`,message:`Faker method "${e.config.fakerMethod}" in ${n} is not implemented: choose a method SandForge generates. No record was written.`}):t.push({field:`${n}.config.fakerMethod`,message:"Faker rule requires a fakerMethod"});break;case"ai_generate":e.fieldType!==void 0&&!k(e.fieldType)&&t.push({field:`${n}.ruleType`,message:`AI generation in ${n} writes text, which a "${e.fieldType}" field cannot hold: choose another rule for this field. No record was written.`});break;case"regex":e.config.regexPattern||t.push({field:`${n}.config.regexPattern`,message:"Regex rule requires a regexPattern"});break;case"from_csv":e.config.csvColumn||t.push({field:`${n}.config.csvColumn`,message:"CSV rule requires a csvColumn"});break}}function P(e,n){let t=new Set(e.objects.map(i=>i.objectApiName)),a=new Set;for(let i of e.relations??[]){let{childObject:s,lookupField:o,parentObject:r}=i,c=`relations[${s}.${o}]`;if(t.has(s)||n.push({field:c,message:`The relation on ${s}.${o} fills an object the template does not write`}),a.has(s)&&n.push({field:c,message:`${s} has more than one relation: an object takes its record count from one relation, so keep one and let the other lookup draw from its field rule`}),a.add(s),i.parents.kind==="generated")r===s?n.push({field:c,message:`${s} records cannot point at ${s} records written by the same insert: draw the parents from records already in the org`}):t.has(r)||n.push({field:c,message:`The relation draws ${s}'s parents from the ${r} records this run writes, and the template writes none`});else if(i.parents.kind==="records"){let d=Array.isArray(i.parents.ids)?i.parents.ids:[],l=m.maxExistingParents;if(d.length<1||d.length>l)n.push({field:`${c}.parents.ids`,message:`The relation on ${s}.${o} names between 1 and ${l} ${r} records by id, not ${d.length}`});else{let f=d.filter(g=>typeof g!="string"||!R.test(g)),u=d.filter(g=>typeof g=="string").map(g=>g.slice(0,15));f.length>0?n.push({field:`${c}.parents.ids`,message:`The relation on ${s}.${o} names ${f.length} parent(s) by something that is not a record id, 15 or 18 letters and digits: ${f.slice(0,3).map(String).join(", ")}`}):new Set(u).size!==u.length&&n.push({field:`${c}.parents.ids`,message:`The relation on ${s}.${o} names the same ${r} record more than once: each parent is given once`})}}else p(i.parents.limit,1,m.maxExistingParents)||n.push({field:`${c}.parents.limit`,message:`The relation on ${s}.${o} reads between 1 and ${m.maxExistingParents} existing ${r} records`});_(i.distribution)||n.push({field:`${c}.distribution`,message:`The relation on ${s}.${o} gives each ${r} a number of children it cannot use`})}}function p(e,n,t){return Number.isInteger(e)&&e>=n&&e<=t}function _(e){let n=m.maxPerParent;switch(e.mode){case"perParent":return p(e.count,1,n);case"range":return p(e.min,0,n)&&p(e.max,1,n)&&e.min<=e.max;case"ratio":return Number.isFinite(e.ratio)&&e.ratio>=m.minRatio&&e.ratio<=n;case"byKey":return!0;default:return!1}}function M(e,n){let t=new Set(e.objects.map(a=>a.objectApiName));for(let a of e.objects){let i=$(a.objectApiName,e.relations);for(let s of a.fieldRules)i&&s.fieldApiName===i.lookupField||v(s,t)||s.ruleType==="reference"&&s.config.referenceObject&&(t.has(s.config.referenceObject)||n.push({field:`objects[${a.objectApiName}].fieldRules[${s.fieldApiName}]`,message:`Reference target "${s.config.referenceObject}" is not in the template`}))}}function q(e,n){let t=new Map;for(let o of e.objects)t.set(o.objectApiName,y(o,e.relations));let a=new Set,i=new Set;function s(o){if(i.has(o))return!0;if(a.has(o))return!1;i.add(o);let r=t.get(o)??[];for(let c of r)if(s(c))return!0;return i.delete(o),a.add(o),!1}for(let o of e.objects)if(s(o.objectApiName)){n.push({field:`objects[${o.objectApiName}]`,message:"Circular dependency detected"});break}}export{A as a};
|
|
@@ -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{f as u,g as l}from"./chunk-H33DVU3D.mjs";import{c as d}from"./chunk-TUPZY2QJ.mjs";var p="## Still to do, in this order",f="## Not touched by SandForge";function s(n){return`\`${n.replace(/[`\r\n]+/g," ").trim()}\``}function h(n){return n.replace(/[\r\n]+/g," ").trim()}function y(n){return n.replace(/\.\d{3}Z$/,"Z")}function S(n,o){return`# Handoff: ${s(n)} on ${s(o.alias??o.organizationId)}`}function $(n){let o=d(n.host),e=n.kind==="sandbox"?`sandbox${o!==void 0?` ${s(o)}`:""}`:n.kind==="scratch"?"scratch org":"Developer Edition org";return`- Org: ${n.alias!==void 0?`${s(n.alias)}, `:""}${e}, ${s(n.organizationId)}.`}function b(n,o){let e=[p,""];e.push("1. Credentials and technical components: point them away from production.");let r=n?.endpoints;if(r===void 0)e.push(` - Not audited: ${o.endpoints}`);else{for(let t of r.found)e.push(` - ${l[t.source]} ${s(t.name)} names ${s(t.host)}, ${u[t.why]}.`);r.found.length===0&&r.unread===void 0&&e.push(" - None of those read names production."),r.unread!==void 0&&e.push(" - Not all read: check the Named Credentials, the Remote Site Settings and the Custom Metadata in Setup.")}e.push("2. Scheduled jobs: schedule again those gone, and give those stuck a user who can run them.");let i=n?.schedules;if(i===void 0)e.push(` - Not audited: ${o.schedules}`);else{for(let t of i.jobs)t.status==="gone"?e.push(` - ${s(t.name)} (${h(t.type)}) was scheduled in the inventory of ${i.against?.savedAt.slice(0,10)??"?"}, and is not now.`):(t.status==="frozen"||t.status==="inactive")&&e.push(` - ${s(t.name)} (${h(t.type)}) runs as ${t.owner!==void 0?s(t.owner):"a user not read"}, who is ${t.status}: its next run fails.`);i.against===void 0&&e.push(" - No inventory from before the refresh was kept on this machine: what is gone is not known."),i.unread!==void 0&&e.push(" - Not all read: Setup > Scheduled Jobs lists them."),!i.jobs.some(t=>t.status!=="new")&&i.unread===void 0&&e.push(i.against!==void 0?" - None gone, none stuck.":" - None stuck.")}e.push("3. Automations that send emails \u2014 flows, workflow rules, Apex \u2014: turn them on last, once the addresses and the masking are as the testers need them."),e.push("4. Deliverability.");let a=n?.deliverability;return a?.read==="closed"?e.push(" - Read closed, System email only or No access: leave it so until the masking is done."):a?.read==="open"?e.push(" - Read open, All email: what runs there emails whoever its records name. Set it to System email only in Setup > Deliverability until the masking is done."):e.push(" - Not read: Setup > Deliverability shows it."),e}var c=["- Named and External Credentials: Setup, or a deployment of your project by `sf`.","- Metadata: your deployment.","- Single sign-on and DKIM keys: Setup.","- Deliverability: Setup > Deliverability.","- Passwords: each user's own, by Forgot your password? on the sandbox's login page."];function w(){return[f,"",...c]}export{s as a,y as b,S as c,$ as d,b as e,w as f};
|