sandforge 1.83.0 → 1.84.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 +1 -1
- package/lib/chunk-23SEDORH.mjs +11 -0
- package/lib/{chunk-I5C4O3VA.mjs → chunk-24RFOFYT.mjs} +1 -1
- package/lib/chunk-26POJDIT.mjs +7 -0
- package/lib/{chunk-WJAZ5LHL.mjs → chunk-2AZQHBEF.mjs} +1 -1
- package/lib/{chunk-IHGYJZZ2.mjs → chunk-2HVOZUM4.mjs} +1 -1
- package/lib/{chunk-3V4YH5KO.mjs → chunk-2JDAOWUW.mjs} +1 -1
- package/lib/{chunk-BNKT3R3F.mjs → chunk-2METQHGG.mjs} +1 -1
- package/lib/chunk-2WFIVO4F.mjs +13 -0
- package/lib/chunk-2YHZBUZE.mjs +7 -0
- package/lib/{chunk-7DPHZWA4.mjs → chunk-326AJTIU.mjs} +14 -14
- package/lib/{chunk-UIR77ZJD.mjs → chunk-36JOHEJL.mjs} +1 -1
- package/lib/chunk-3PVRGTVK.mjs +7 -0
- package/lib/{chunk-2WMKJVD2.mjs → chunk-3Q353S2R.mjs} +1 -1
- package/lib/chunk-3TZSBHEY.mjs +7 -0
- package/lib/{chunk-T36DZJPH.mjs → chunk-43TOMFV4.mjs} +1 -1
- package/lib/{chunk-XAMMIPZ4.mjs → chunk-4CVUUVGJ.mjs} +1 -1
- package/lib/{chunk-6YC2ELCU.mjs → chunk-4EOHEDFP.mjs} +1 -1
- package/lib/{chunk-ZB5E7NHU.mjs → chunk-4JE4BYXK.mjs} +1 -1
- package/lib/{chunk-JREKJO3D.mjs → chunk-54WZUS7J.mjs} +1 -1
- package/lib/{chunk-CGZGL6VT.mjs → chunk-5CRLRHOJ.mjs} +1 -1
- package/lib/{chunk-UOHZW2L4.mjs → chunk-5IZTFMJM.mjs} +1 -1
- package/lib/{chunk-6VOQFISN.mjs → chunk-5M5FQ7RP.mjs} +1 -1
- package/lib/{chunk-U4YFYSF3.mjs → chunk-5SMWFNE7.mjs} +1 -1
- package/lib/{chunk-HQZUQXDC.mjs → chunk-5XTUSN72.mjs} +1 -1
- package/lib/chunk-6I6TWNV5.mjs +7 -0
- package/lib/{chunk-QLRWU3MB.mjs → chunk-6JWWSDM6.mjs} +1 -1
- package/lib/chunk-6O222PW6.mjs +7 -0
- package/lib/{chunk-J3TIHLWG.mjs → chunk-6PD6K7LP.mjs} +1 -1
- package/lib/{chunk-ISAUCWYK.mjs → chunk-6QE6R6RL.mjs} +1 -1
- package/lib/{chunk-2KTGDYUH.mjs → chunk-6WX5ZU7Q.mjs} +1 -1
- package/lib/{chunk-XAUQXYPW.mjs → chunk-6YL7BNYD.mjs} +1 -1
- package/lib/chunk-6ZLKIT3H.mjs +7 -0
- package/lib/{chunk-XKFHTBAB.mjs → chunk-7QYHEHMA.mjs} +1 -1
- package/lib/chunk-7SQSWVAU.mjs +9 -0
- package/lib/{chunk-NNV7IGM7.mjs → chunk-7UVKIWKV.mjs} +1 -1
- package/lib/{chunk-RZKJQOOC.mjs → chunk-7WATA4SB.mjs} +1 -1
- package/lib/{chunk-DMT5SCO3.mjs → chunk-7YNM6KFZ.mjs} +1 -1
- package/lib/{chunk-TMIESDE5.mjs → chunk-A3MYSOOC.mjs} +1 -1
- package/lib/chunk-AL4C3GFT.mjs +7 -0
- package/lib/chunk-B3FBHVNN.mjs +21 -0
- package/lib/{chunk-CDWZGQAJ.mjs → chunk-B63POIPQ.mjs} +1 -1
- package/lib/{chunk-YEVB7LVK.mjs → chunk-BAWCOKRW.mjs} +1 -1
- package/lib/{chunk-FVLFO2S6.mjs → chunk-BBRWFKS5.mjs} +1 -1
- package/lib/chunk-BEA27DLS.mjs +7 -0
- package/lib/chunk-BRY3PLIZ.mjs +7 -0
- package/lib/chunk-CBH3TOWK.mjs +341 -0
- package/lib/{chunk-7V2UYZ6S.mjs → chunk-CPQIZGG5.mjs} +1 -1
- package/lib/chunk-CVHNXJH3.mjs +7 -0
- package/lib/{chunk-ZOSESZ22.mjs → chunk-D4GF4FAB.mjs} +1 -1
- package/lib/chunk-DGDRQRCW.mjs +7 -0
- package/lib/{chunk-2N73W63D.mjs → chunk-DPMRIMUC.mjs} +1 -1
- package/lib/chunk-DUN2EPRC.mjs +7 -0
- package/lib/chunk-E3A3LOCY.mjs +7 -0
- package/lib/{chunk-KWAVSZ2B.mjs → chunk-EAC5QCE3.mjs} +1 -1
- package/lib/{chunk-JUOQUG7U.mjs → chunk-EC72TIEG.mjs} +1 -1
- package/lib/chunk-EPFCERGL.mjs +7 -0
- package/lib/{chunk-6KOUYHEY.mjs → chunk-ETDCBLGU.mjs} +1 -1
- package/lib/{chunk-2R6GFNKF.mjs → chunk-F3AQW6IU.mjs} +1 -1
- package/lib/{chunk-AHUGG3WU.mjs → chunk-FITPY3L4.mjs} +1 -1
- package/lib/chunk-FNJ4SGWO.mjs +7 -0
- package/lib/{chunk-EOQON3E5.mjs → chunk-FP7CYB2F.mjs} +1 -1
- package/lib/{chunk-262TP6UU.mjs → chunk-GKY2JMHY.mjs} +1 -1
- package/lib/{chunk-JBWJ6UEZ.mjs → chunk-GMIGWR6U.mjs} +1 -1
- package/lib/{chunk-OS5GE52G.mjs → chunk-GNRSF65U.mjs} +1 -1
- package/lib/chunk-GOOVPVWX.mjs +7 -0
- package/lib/{chunk-DB5RVDC5.mjs → chunk-GWZRR3MM.mjs} +1 -1
- package/lib/{chunk-SX6QWYCQ.mjs → chunk-H2BHESDA.mjs} +2 -2
- package/lib/chunk-H4CGM6YO.mjs +7 -0
- package/lib/{chunk-NFEBX75O.mjs → chunk-HCGXK7G7.mjs} +1 -1
- package/lib/{chunk-4X5D3MSV.mjs → chunk-HIDW7FNV.mjs} +1 -1
- package/lib/chunk-HSBXRQTI.mjs +7 -0
- package/lib/chunk-HUZPBE47.mjs +7 -0
- package/lib/{chunk-F5SBGJWW.mjs → chunk-HV7VPEXP.mjs} +1 -1
- package/lib/chunk-I6E6T6YY.mjs +7 -0
- package/lib/chunk-IUM4NFKI.mjs +10 -0
- package/lib/chunk-IVFVNNGB.mjs +37 -0
- package/lib/{chunk-L4MSL4U7.mjs → chunk-IZGCEOYO.mjs} +1 -1
- package/lib/{chunk-E3RQ575Y.mjs → chunk-J3DND3BC.mjs} +1 -1
- package/lib/{chunk-MJD6CPZZ.mjs → chunk-JAEDM4SI.mjs} +1 -1
- package/lib/chunk-JCFBFF4Y.mjs +7 -0
- package/lib/{chunk-U2CTKIPE.mjs → chunk-JE6SCT6R.mjs} +1 -1
- package/lib/{chunk-XJICAOAQ.mjs → chunk-JGZPD4IM.mjs} +1 -1
- package/lib/{chunk-XCJUNX63.mjs → chunk-JKJ74BX5.mjs} +1 -1
- package/lib/{chunk-WAYQLQAD.mjs → chunk-JLSIWO4Z.mjs} +1 -1
- package/lib/{chunk-D7XUNWWU.mjs → chunk-JSAJS3MY.mjs} +1 -1
- package/lib/chunk-JTJK2D36.mjs +7 -0
- package/lib/{chunk-OTJH6AEA.mjs → chunk-KAZS5Z6W.mjs} +1 -1
- package/lib/chunk-KB4ZHM4Q.mjs +10 -0
- package/lib/{chunk-N2HYG3BL.mjs → chunk-KGU4SVIT.mjs} +1 -1
- package/lib/{chunk-FKCIGJOI.mjs → chunk-KJWFYBMU.mjs} +2 -2
- package/lib/{chunk-KXUOHACP.mjs → chunk-KZTZDC7H.mjs} +1 -1
- package/lib/{chunk-S4PRKKGC.mjs → chunk-L2E5WBGD.mjs} +1 -1
- package/lib/{chunk-X2XZQ434.mjs → chunk-L53JWJ3S.mjs} +1 -1
- package/lib/{chunk-CQAFVEKP.mjs → chunk-LA4KIATH.mjs} +6 -6
- package/lib/chunk-LC3NDW4N.mjs +7 -0
- package/lib/{chunk-4V3QO7HF.mjs → chunk-LKTNQEBS.mjs} +1 -1
- package/lib/chunk-M2ABR4JM.mjs +7 -0
- package/lib/{chunk-3CM7LAPE.mjs → chunk-M4BLK6HJ.mjs} +1 -1
- package/lib/{chunk-Z3MGN42K.mjs → chunk-M6K34KGF.mjs} +1 -1
- package/lib/{chunk-TUPZY2QJ.mjs → chunk-MDMPJEV3.mjs} +1 -1
- package/lib/{chunk-BVZ5H3N4.mjs → chunk-MJZU3U5O.mjs} +68 -63
- package/lib/{chunk-OUU47Y7A.mjs → chunk-MSIEU5MR.mjs} +1 -1
- package/lib/{chunk-QQDZQCO2.mjs → chunk-N4WPCWJO.mjs} +1 -1
- package/lib/{chunk-MTM4KG3T.mjs → chunk-NCZKWSC7.mjs} +1 -1
- package/lib/{chunk-Y7YUNRKK.mjs → chunk-NED4MBIM.mjs} +1 -1
- package/lib/{chunk-QKJXIY6L.mjs → chunk-NOBQTEQD.mjs} +1 -1
- package/lib/{chunk-WBELLGNE.mjs → chunk-NSQWI7ZY.mjs} +1 -1
- package/lib/{chunk-BPHTA6KP.mjs → chunk-O677VOGO.mjs} +1 -1
- package/lib/chunk-OFTT7J2M.mjs +7 -0
- package/lib/{chunk-JH4ZTVQN.mjs → chunk-OLCVHL7I.mjs} +1 -1
- package/lib/chunk-OM5NORJG.mjs +7 -0
- package/lib/{chunk-QP3JLFIO.mjs → chunk-OMNMLKDT.mjs} +1 -1
- package/lib/{chunk-WABXKL4N.mjs → chunk-OPMO6I45.mjs} +1 -1
- package/lib/{chunk-7ZBDACVG.mjs → chunk-OUZQPYT3.mjs} +1 -1
- package/lib/chunk-OVNMB6Q2.mjs +7 -0
- package/lib/{chunk-DKDKCGXV.mjs → chunk-PAXNWTYK.mjs} +1 -1
- package/lib/{chunk-GLN4PI5P.mjs → chunk-PBY2O6OF.mjs} +1 -1
- package/lib/chunk-PEDQPM2P.mjs +926 -0
- package/lib/chunk-PH7SP4YK.mjs +21 -0
- package/lib/{chunk-BT43WSOS.mjs → chunk-PMN4PAC3.mjs} +1 -1
- package/lib/chunk-PMWAFDUB.mjs +48 -0
- package/lib/chunk-PPLVFX6N.mjs +7 -0
- package/lib/{chunk-L3I6DAHX.mjs → chunk-PR3XCSPO.mjs} +1 -1
- package/lib/{chunk-WZN36ACK.mjs → chunk-PR42EZSR.mjs} +1 -1
- package/lib/{chunk-NDFFIJL5.mjs → chunk-PWRJRL5U.mjs} +1 -1
- package/lib/{chunk-NS6ONPWL.mjs → chunk-Q7GIJBCD.mjs} +1 -1
- package/lib/chunk-Q7TLC3I2.mjs +7 -0
- package/lib/{chunk-ALBY5SOH.mjs → chunk-QAFPQ3YB.mjs} +1 -1
- package/lib/{chunk-KKS2KFBT.mjs → chunk-QKEKG2LD.mjs} +1 -1
- package/lib/{chunk-OOIDCHBQ.mjs → chunk-QO53K5W2.mjs} +2 -2
- package/lib/{chunk-HVX2AFYW.mjs → chunk-QTG6LUZT.mjs} +1 -1
- package/lib/{chunk-K7G3W7XH.mjs → chunk-RE7RYF3B.mjs} +1 -1
- package/lib/{chunk-JIPT5FUD.mjs → chunk-RGBGUCJA.mjs} +1 -1
- package/lib/{chunk-GT5ZKU6V.mjs → chunk-RGUQOSBU.mjs} +1 -1
- package/lib/{chunk-VXZ5PTOM.mjs → chunk-RHNTHGNU.mjs} +1 -1
- package/lib/chunk-RKTFFCNS.mjs +7 -0
- package/lib/chunk-RMFU4BAL.mjs +28 -0
- package/lib/{chunk-DNQKVCUV.mjs → chunk-ROV3QXEF.mjs} +11 -11
- package/lib/chunk-RT47RKLY.mjs +7 -0
- package/lib/{chunk-ISOSTAJR.mjs → chunk-S42RBRH2.mjs} +1 -1
- package/lib/{chunk-27BBEGUD.mjs → chunk-SI267LYR.mjs} +1 -1
- package/lib/chunk-T3G6VZNS.mjs +7 -0
- package/lib/chunk-TNT27RBG.mjs +7 -0
- package/lib/chunk-UBIKR5VO.mjs +7 -0
- package/lib/chunk-UI3JQVRU.mjs +8 -0
- package/lib/{chunk-RVCPQVKM.mjs → chunk-UIOMAX56.mjs} +1 -1
- package/lib/chunk-UX3BVH2Y.mjs +7 -0
- package/lib/{chunk-L4RJX7DG.mjs → chunk-VCUXCK36.mjs} +1 -1
- package/lib/chunk-VINGECAJ.mjs +10 -0
- package/lib/chunk-VOXJHJIE.mjs +7 -0
- package/lib/chunk-W6PN6TJG.mjs +7 -0
- package/lib/{chunk-D6JT4PAB.mjs → chunk-WAPSSYMT.mjs} +1 -1
- package/lib/{chunk-7BQMBXKX.mjs → chunk-WUUKFE2U.mjs} +1 -1
- package/lib/chunk-WWTCWWZI.mjs +7 -0
- package/lib/chunk-WXDLQT2O.mjs +10 -0
- package/lib/{chunk-TCEXCHXR.mjs → chunk-WY5V5PR3.mjs} +1 -1
- package/lib/chunk-X4BXESMQ.mjs +7 -0
- package/lib/chunk-XBQGZGWR.mjs +7 -0
- package/lib/{chunk-AXFD2OH6.mjs → chunk-XGGOUNPP.mjs} +1 -1
- package/lib/chunk-XKWW3GKF.mjs +7 -0
- package/lib/{chunk-PDRXM5WN.mjs → chunk-Y2DRK37K.mjs} +1 -1
- package/lib/{chunk-ZXOUWHYE.mjs → chunk-YA6ATMTB.mjs} +1 -1
- package/lib/{chunk-54HYHHVL.mjs → chunk-YDXMTWAT.mjs} +1 -1
- package/lib/chunk-YHR4WQPR.mjs +7 -0
- package/lib/{chunk-LWES2KZE.mjs → chunk-YTLUYSMF.mjs} +1 -1
- package/lib/{chunk-2K5BYZQM.mjs → chunk-YWEQQL3C.mjs} +1 -1
- package/lib/{chunk-C6RKM4BB.mjs → chunk-Z4LKKOFY.mjs} +1 -1
- package/lib/chunk-ZBAWJUG2.mjs +7 -0
- package/lib/{chunk-446GBKAC.mjs → chunk-ZJW6YOMV.mjs} +1 -1
- package/lib/chunk-ZQQXSCVI.mjs +7 -0
- package/lib/{chunk-L6CLN664.mjs → chunk-ZQWIVYVM.mjs} +1 -1
- package/lib/{chunk-CXKZ6TYV.mjs → chunk-ZV7ZFQQC.mjs} +1 -1
- package/lib/sandforge-autopilot.mjs +25 -25
- 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 +52 -21
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +1 -1
- package/lib/sandforge-env.mjs +95 -95
- package/lib/sandforge-frozen.mjs +1 -1
- package/lib/sandforge-mcp.mjs +12 -12
- 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 +1 -1
- package/lib/sandforge.mjs +1 -1
- package/lib/sf/sandforge/compare.mjs +2 -2
- package/lib/sfPlugin.mjs +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/lib/chunk-2ADSD5WK.mjs +0 -7
- package/lib/chunk-2GSMHGIV.mjs +0 -7
- package/lib/chunk-36Y225OM.mjs +0 -7
- package/lib/chunk-3OVTKRS4.mjs +0 -7
- package/lib/chunk-4GCYGQXD.mjs +0 -7
- package/lib/chunk-4JKR4PTZ.mjs +0 -8
- package/lib/chunk-5OGNK3JP.mjs +0 -37
- package/lib/chunk-6QSHWIZI.mjs +0 -48
- package/lib/chunk-77IVKH7R.mjs +0 -7
- package/lib/chunk-77MZRBWX.mjs +0 -7
- package/lib/chunk-7WSQ65WG.mjs +0 -9
- package/lib/chunk-A32ISQ6M.mjs +0 -28
- package/lib/chunk-AG24QMSY.mjs +0 -7
- package/lib/chunk-BH76USTQ.mjs +0 -11
- package/lib/chunk-BZ24IAP5.mjs +0 -7
- package/lib/chunk-CN5HGFG4.mjs +0 -7
- package/lib/chunk-CTPLYUXA.mjs +0 -7
- package/lib/chunk-DIGUC7S4.mjs +0 -341
- package/lib/chunk-DSR2MSBH.mjs +0 -7
- package/lib/chunk-ETNQHIDI.mjs +0 -9
- package/lib/chunk-FBXH4VRQ.mjs +0 -7
- package/lib/chunk-FYWNSMOZ.mjs +0 -10
- package/lib/chunk-GEEWPTV5.mjs +0 -7
- package/lib/chunk-GTRU5AV5.mjs +0 -7
- package/lib/chunk-I3ZO76LL.mjs +0 -21
- package/lib/chunk-ISA2NYJV.mjs +0 -7
- package/lib/chunk-IXIY6Q4M.mjs +0 -7
- package/lib/chunk-JAV6F6OA.mjs +0 -7
- package/lib/chunk-JYUMD357.mjs +0 -7
- package/lib/chunk-L47JCNP3.mjs +0 -7
- package/lib/chunk-LI2XNV7F.mjs +0 -7
- package/lib/chunk-LP2D3JJP.mjs +0 -7
- package/lib/chunk-LYOGCIYD.mjs +0 -925
- package/lib/chunk-N5UIE4IR.mjs +0 -7
- package/lib/chunk-O7GCCRPW.mjs +0 -7
- package/lib/chunk-OO24ZYYJ.mjs +0 -7
- package/lib/chunk-OS6HFJ7L.mjs +0 -7
- package/lib/chunk-P6WRYJN3.mjs +0 -7
- package/lib/chunk-PGRY365W.mjs +0 -7
- package/lib/chunk-PPGDAUEQ.mjs +0 -7
- package/lib/chunk-Q4PPI3KG.mjs +0 -7
- package/lib/chunk-QFTF2PGS.mjs +0 -21
- package/lib/chunk-QO4MPHZD.mjs +0 -7
- package/lib/chunk-QXB6U3ZP.mjs +0 -7
- package/lib/chunk-R3OM3X4L.mjs +0 -8
- package/lib/chunk-R7GKMAT4.mjs +0 -7
- package/lib/chunk-SCKUIE3R.mjs +0 -7
- package/lib/chunk-SU65Z2BA.mjs +0 -7
- package/lib/chunk-T7DDS4UQ.mjs +0 -7
- package/lib/chunk-TQJ5NPRC.mjs +0 -7
- package/lib/chunk-VZLJZEV2.mjs +0 -7
- package/lib/chunk-W3BQGMTR.mjs +0 -7
- package/lib/chunk-WXU6ZJIV.mjs +0 -7
- package/lib/chunk-X4HZD5U2.mjs +0 -7
- package/lib/chunk-X6XNTOGO.mjs +0 -7
- package/lib/chunk-XMQ5R6TC.mjs +0 -10
- package/lib/chunk-XPXEQKLR.mjs +0 -7
- package/lib/chunk-YBZIDW6W.mjs +0 -7
- package/lib/chunk-ZCOSME6P.mjs +0 -7
- package/lib/chunk-ZTHC42X6.mjs +0 -7
|
@@ -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{f as $}from"./chunk-4GCYGQXD.mjs";import{a as F}from"./chunk-PPGDAUEQ.mjs";import{a as N}from"./chunk-4TLYUZD5.mjs";import{b as O}from"./chunk-CA5NAXSU.mjs";import{bd as k,k as M}from"./chunk-6QSHWIZI.mjs";var x=class e{static DEFAULT_MAX_PER_ORG=5;static DEFAULT_RECYCLE_INTERVAL=900*1e3;connections=new Map;config;cleanupTimer;recycleTimer;maxPerOrg;recycleIntervalMs;latencySamples=new Map;constructor(t,r){this.config={maxConnections:t?.maxConnections??10,keepAliveInterval:t?.keepAliveInterval??6e4,connectionTimeout:t?.connectionTimeout??3e4,idleTimeout:t?.idleTimeout??3e5},this.maxPerOrg=r?.maxPerOrg??e.DEFAULT_MAX_PER_ORG,this.recycleIntervalMs=r?.recycleIntervalMs??e.DEFAULT_RECYCLE_INTERVAL}acquire(t,r,n){let s=this.connections.get(t);if(s&&s.active)return s.lastUsedAt=Date.now(),s.accessToken=n,s;this.connections.size>=this.config.maxConnections&&this.evictOldest();let i={orgId:t,instanceUrl:r,accessToken:n,createdAt:Date.now(),lastUsedAt:Date.now(),active:!0};return this.connections.set(t,i),i}release(t){let r=this.connections.get(t);r&&(r.lastUsedAt=Date.now())}remove(t){return this.latencySamples.delete(t),this.connections.delete(t)}get(t){return this.connections.get(t)}get size(){return this.connections.size}getConfig(){return{...this.config}}getMaxPerOrg(){return this.maxPerOrg}recordLatency(t,r){if(!Number.isFinite(r)||r<0)return;let n=this.latencySamples.get(t);n||(n=[],this.latencySamples.set(t,n)),n.push(r),n.length>1e3&&n.splice(0,n.length-1e3)}getLatencyMetrics(t){let r=this.latencySamples.get(t);if(!r||r.length===0)return;let n=[...r].sort((a,c)=>a-c),s=n.reduce((a,c)=>a+c,0),i=Math.floor(n.length*.95),u=Math.floor(n.length*.99);return{min:n[0],max:n[n.length-1],avg:Math.round(s/n.length),p95:n[Math.min(i,n.length-1)],p99:n[Math.min(u,n.length-1)],sampleCount:n.length}}getAllLatencyMetrics(){let t=new Map;for(let r of this.latencySamples.keys()){let n=this.getLatencyMetrics(r);n&&t.set(r,n)}return t}cleanupIdle(){let t=Date.now(),r=0;for(let[n,s]of this.connections)t-s.lastUsedAt>this.config.idleTimeout&&(this.connections.delete(n),r++);return r}recycleStale(){let t=Date.now(),r=0;for(let[n,s]of this.connections)t-s.createdAt>this.recycleIntervalMs&&(s.active=!1,this.connections.delete(n),r++);return r}startCleanup(){this.stopCleanup(),this.cleanupTimer=setInterval(()=>this.cleanupIdle(),this.config.keepAliveInterval)}stopCleanup(){this.cleanupTimer&&(clearInterval(this.cleanupTimer),this.cleanupTimer=void 0)}startRecycling(){this.stopRecycling(),this.recycleTimer=setInterval(()=>this.recycleStale(),this.recycleIntervalMs)}stopRecycling(){this.recycleTimer&&(clearInterval(this.recycleTimer),this.recycleTimer=void 0)}evictOldest(){let t,r=1/0;for(let[n,s]of this.connections)s.lastUsedAt<r&&(r=s.lastUsedAt,t=n);t&&this.connections.delete(t)}dispose(){this.stopCleanup(),this.stopRecycling(),this.connections.clear(),this.latencySamples.clear()}};var S=class{state="closed";failureCount=0;lastFailureTime=0;halfOpenSuccesses=0;halfOpenInFlight=0;config;constructor(t){this.config={failureThreshold:t?.failureThreshold??5,resetTimeout:t?.resetTimeout??6e4,halfOpenRequests:t?.halfOpenRequests??1}}getState(){return this.state==="open"&&this.shouldTransitionToHalfOpen()&&(this.state="half_open",this.halfOpenSuccesses=0),this.state}canExecute(){let t=this.getState();return t==="closed"?!0:t==="half_open"?this.halfOpenInFlight<this.config.halfOpenRequests:!1}recordSuccess(){this.state==="half_open"?(this.halfOpenSuccesses++,this.halfOpenInFlight=Math.max(0,this.halfOpenInFlight-1),this.halfOpenSuccesses>=this.config.halfOpenRequests&&this.reset()):this.failureCount=0}recordFailure(){this.failureCount++,this.lastFailureTime=Date.now(),this.state==="half_open"?this.trip():this.failureCount>=this.config.failureThreshold&&this.trip()}trip(){this.state="open",this.lastFailureTime=Date.now()}reset(){this.state="closed",this.failureCount=0,this.halfOpenSuccesses=0,this.halfOpenInFlight=0}getFailureCount(){return this.failureCount}acquirePermit(){return this.canExecute()?(this.getState()==="half_open"&&this.halfOpenInFlight++,!0):!1}releasePermit(){this.halfOpenInFlight=Math.max(0,this.halfOpenInFlight-1)}getConfig(){return{...this.config}}shouldTransitionToHalfOpen(){return Date.now()-this.lastFailureTime>=this.config.resetTimeout}};var B=0;function we(){return B}async function I(e,t){let r=$(e);try{return await t()}finally{B+=r()}}var C=class extends Error{constructor(r,n,s){super(`${r}: ${s}`);this.code=r;this.orgId=n;this.name="OrgConnectionError"}code;orgId};import{homedir as ee,userInfo as te}from"node:os";var ne=[/^ELECTRON_.+$/,/^VSCODE_(?!(PORTABLE|SHELL_LOGIN|ENV_REPLACE|ENV_APPEND|ENV_PREPEND)).+$/,/^SNAP(|_.*)$/,/^GDK_PIXBUF_.+$/],V=["HTTP_PROXY","HTTPS_PROXY","NO_PROXY","NODE_EXTRA_CA_CERTS","NODE_OPTIONS","NODE_TLS_REJECT_UNAUTHORIZED"];function X(e){return ne.some(t=>t.test(e))}function P(e=process.env){let t={};for(let[r,n]of Object.entries(e))X(r)||(t[r]=n);return t.NO_COLOR="1",t}function Ee(e=process.env){let t=Object.keys(e).filter(c=>(e[c]??"")!==""),r=V.filter(c=>t.some(d=>d.toUpperCase()===c)),n=t.filter(c=>/^(SF|SFDX)_/i.test(c)).sort(),s=t.filter(c=>X(c)),i=s.filter(c=>c.startsWith("ELECTRON_")).sort(),u=s.length-i.length,a=s.length===0?"none":[...i,...u>0?[`${u} VSCODE_ or other VS Code variables`]:[]].join(", ");return`set: ${r.length>0?r.join(", "):"none of "+V.join(", ")}; SF_/SFDX_: ${n.length>0?n.join(", "):"none"}; not passed to sf, as a terminal does not get them: ${a}`}function re(){try{return te().username}catch{return process.env.USERNAME??process.env.USER??""}}function H(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function j(e,t=ee(),r=re()){let n=e;return t.length>3&&(n=n.replace(new RegExp(H(t),"gi"),"~")),r.length>=2&&(n=n.replace(new RegExp(`(?<=[\\\\/])${H(r)}(?=[\\\\/]|$)`,"gim"),"<user>")),n.replace(/00D\w{12,15}![\w.]+/g,"<token>").replace(/[\w.+-]+@[\w-]+(\.[\w-]+)+/g,"<username>")}function ve(e){return e.split(/\r?\n/).map(t=>t.trim()).find(t=>t.length>0)}function se(e,t){if(process.platform!=="win32")return e[0];let n=(Object.entries(t).find(([s])=>s.toUpperCase()==="PATHEXT")?.[1]??".COM;.EXE;.BAT;.CMD").split(";").map(s=>s.trim().toLowerCase()).filter(s=>s.length>0);return e.find(s=>{let i=s.lastIndexOf(".");return i>Math.max(s.lastIndexOf("\\"),s.lastIndexOf("/"))&&n.includes(s.slice(i).toLowerCase())})}async function Oe(e=1e4){let{exec:t}=await import("child_process"),{promisify:r}=await import("util"),n=process.platform==="win32"?"where sf node":"which -a sf node",s=P(),i,u;try{let l=await r(t)(n,{timeout:e,windowsHide:!0,env:s});i=String(l.stdout)}catch(l){let o=l;i=String(o.stdout??""),i.trim()===""&&(u=j(o.message??String(l)))}let a=i.split(/\r?\n/).map(l=>l.trim()).filter(l=>l.length>0).map(l=>j(l)),c=l=>a.filter(o=>new RegExp(`(^|[\\\\/])${l}(\\.[A-Za-z0-9]+)?$`,"i").test(o)),d=c("sf"),p=se(d,s);return{sf:d,node:c("node"),...p!==void 0?{runs:p}:{},...u?{failure:u}:{}}}function R(e,t){let r=(e[t.toLowerCase()]??e[t.toUpperCase()]??"").trim();return r===""?void 0:r}function ie(e,t){if(t===void 0)return!1;let r=e.hostname.toLowerCase(),n=e.port||(e.protocol==="https:"?"443":"80");return t.split(/[\s,]+/).filter(s=>s!=="").some(s=>{if(s==="*")return!0;let[,i="",u]=/^(.*?)(?::(\d+))?$/.exec(s.toLowerCase())??[];if(u!==void 0&&u!==n)return!1;let a=i.replace(/^\*?\.?/,"");return a!==""&&(r===a||r.endsWith(`.${a}`))})}function G(e,t=process.env){let r;try{r=new URL(e)}catch{return}let n=r.protocol==="https:"?R(t,"https_proxy")??R(t,"http_proxy"):R(t,"http_proxy");if(n!==void 0)return ie(r,R(t,"no_proxy"))?void 0:n}var oe="https://login.salesforce.com";async function v(e,t=process.env){let{jsforce:r,HttpProxyTransport:n}=await import("./chunk-L5FGY6YA.mjs"),s=G(e.instanceUrl??e.loginUrl??oe,t),i=new r.Connection({...e,...s!==void 0?{httpProxy:s}:{}});return s===void 0&&(i._transport=new n("")),i}var ae=10*1024*1024,L=3e4,q=L+2e3,A=`sf did not answer within ${L/1e3} s \u2014 check the Salesforce CLI`;function J(e){return e instanceof Error&&e.message===A}var D=2e4;function U(e,t,r){let n,s=new Promise((i,u)=>{n=setTimeout(()=>u(new Error(r)),t)});return Promise.race([e,s]).finally(()=>clearTimeout(n))}var E=new x,ce=300*1e3,_=new Map,le={failureThreshold:3,resetTimeout:3e4},z=new Map;function Ne(){return E}function ue(e){let t=z.get(e);return t||(t=new S({...le}),z.set(e,t)),t}var Y;var b="panel";function Be(e){b=e}function fe(e,t=b){return t==="panel"?"Reconnect it on the Organizations page (Try Reconnect on its card).":`Sign in to it again with "sf org login web --alias ${e}" (in a CI job, "sf org login jwt" or "sf org login sfdx-url"), then run the command again, with its --resume if it stopped a run part way.`}function W(e=b){return e==="panel"?"Create a new one and import it.":'Create a new one ("sf org create scratch") and give its alias.'}function K(e,t){let r=t?.organization_id;if(!(!Y||typeof r!="string"))try{Y(e,{organizationId:r})}catch(n){N.warn("Identity observer threw",{orgId:e,error:O(n)})}}var de="[REDACTED]";function Z(e){return typeof e=="string"&&e.length>0&&!e.startsWith(de)&&!/\s/.test(e)}async function pe(e){if(!/^[\w.@+-]+$/.test(e))throw new Error(`Invalid username format: "${e}"`);let{execFile:t,exec:r}=await import("child_process"),{promisify:n}=await import("util"),s={maxBuffer:ae,timeout:L,windowsHide:!0,env:P()},i=o=>U(n(t)("sf",o,s),q,A),u=o=>{let f=!1,h,y=new Promise((T,m)=>{h=r(o,s,(g,w)=>{f=!0,g?m(g):T({stdout:w})})});return U(y,q,A).catch(T=>{throw!f&&h?.pid!==void 0&&t("taskkill",["/pid",String(h.pid),"/T","/F"],{windowsHide:!0},()=>{}),T})},a=(o,f)=>process.platform==="win32"?u(o):i(f),c=(o,f)=>{let h=o.replace(/\[[0-9;]*m/g,""),y=h.search(/[{[]/);if(y===-1)throw new Error(`Failed to parse "${f}" output: no JSON found. Ensure Salesforce CLI (sf) is installed and the org is authenticated.`);return JSON.parse(h.slice(y)).result??{}},d;try{let{stdout:o}=await a(`sf org display -u "${e}" --json`,["org","display","-u",e,"--json"]),f=c(o,"sf org display");d=typeof f.instanceUrl=="string"?f.instanceUrl:void 0}catch(o){if(J(o))throw o;d=void 0}try{let{stdout:o}=await a(`sf org auth show-access-token -o "${e}" --json`,["org","auth","show-access-token","-o",e,"--json"]),f=c(o,"sf org auth show-access-token");if(Z(f.accessToken))return{accessToken:f.accessToken,instanceUrl:d}}catch(o){if(J(o))throw o}let{stdout:p}=await a(`sf org display -u "${e}" --json`,["org","display","-u",e,"--json"]),l=c(p,"sf org display");if(!Z(l.accessToken))throw new Error('Neither "sf org auth show-access-token" nor "sf org display" returned an access token. The org session may have expired \u2014 try re-authenticating with "sf org login".');return!d&&typeof l.instanceUrl=="string"&&(d=l.instanceUrl),{accessToken:l.accessToken,instanceUrl:d}}async function Ve(e,t){return v({instanceUrl:e.instanceUrl,accessToken:e.accessToken??void 0,version:e.version,callOptions:{client:t}})}async function He(e){return v({instanceUrl:e.instanceUrl,accessToken:e.accessToken,version:e.version})}async function je(e,t,r){let n=e,s=r.getOrg(e);if(!s)throw new Error(`Org not found: ${e}`);let i=await t.getCredentials(e);if(!i?.accessToken||!i.instanceUrl)throw new Error(`No credentials for org "${s.alias}" (${e}). Reconnect the org.`);let u=s.metadata.apiVersion||M.DEFAULT_API_VERSION,a=E.get(n),c=Date.now()-(_.get(e)??0)<ce;if(a&&a.active&&a.accessToken===i.accessToken&&c)return a.lastUsedAt=Date.now(),v({instanceUrl:a.instanceUrl,accessToken:a.accessToken,version:u});let d=await v({instanceUrl:i.instanceUrl,accessToken:i.accessToken,version:u}),p=ue(e);if(!p.acquirePermit())throw new C("ORG_TEMPORARILY_UNREACHABLE",e,`"${s.alias}" failed several times in a row, so SandForge waits a moment before calling it again. Try again in a minute.`);let l=Date.now(),o=`identity check did not answer within ${D/1e3} s`;try{let f=await I(d,()=>U(d.identity(),D,o)),h=Date.now()-l;return p.recordSuccess(),E.acquire(n,i.instanceUrl,i.accessToken),E.recordLatency(n,h),_.set(e,Date.now()),K(e,f),d}catch(f){let h=Date.now()-l;if(E.remove(n),_.delete(e),F(f))try{let m=await pe(s.username),g=m.instanceUrl??i.instanceUrl;if(m.accessToken===i.accessToken&&g===i.instanceUrl)throw new Error("sf CLI token store is stale too (same expired token) \u2014 re-authenticate the org");let w=await v({instanceUrl:g,accessToken:m.accessToken,version:u}),Q=await I(w,()=>U(w.identity(),D,o));return await t.saveOrg(s,{...i,accessToken:m.accessToken,instanceUrl:g}),p.recordSuccess(),E.acquire(n,g,m.accessToken),E.recordLatency(n,h),_.set(e,Date.now()),K(e,Q),w}catch(m){p.recordFailure();let g=O(m);r.updateStatus(e,"expired");let w=k(s,new Date().toISOString().slice(0,10));throw w!==void 0?new C("SCRATCH_ORG_EXPIRED",e,`The scratch org "${s.alias}" expired on ${w}: Salesforce deletes a scratch org when it expires, and no reconnect brings it back. ${W()} (cause: ${g})`):new C("ORG_AUTH_EXPIRED",e,`The session with "${s.alias}" has expired and could not be renewed. ${fe(s.alias)} (cause: ${g})`)}p.recordFailure();let y=O(f),T=k(s,new Date().toISOString().slice(0,10));throw T!==void 0?(r.updateStatus(e,"expired"),new C("SCRATCH_ORG_EXPIRED",e,`The scratch org "${s.alias}" expired on ${T}: Salesforce deletes a scratch org when it expires, and no reconnect brings it back. ${W()} (cause: ${y})`)):new Error(`Connection failed for "${s.alias}": ${y}`)}finally{p.releasePermit()}}export{we as a,I as b,C as c,P as d,Ee as e,j as f,ve as g,Oe as h,G as i,v as j,U as k,Ne as l,Be as m,Z as n,pe as o,Ve as p,He as q,je as r};
|
|
7
|
+
import{f as $}from"./chunk-W6PN6TJG.mjs";import{a as N}from"./chunk-4TLYUZD5.mjs";import{a as F}from"./chunk-Q7TLC3I2.mjs";import{b as O}from"./chunk-CA5NAXSU.mjs";import{bd as k,k as M}from"./chunk-PMWAFDUB.mjs";var x=class e{static DEFAULT_MAX_PER_ORG=5;static DEFAULT_RECYCLE_INTERVAL=900*1e3;connections=new Map;config;cleanupTimer;recycleTimer;maxPerOrg;recycleIntervalMs;latencySamples=new Map;constructor(t,r){this.config={maxConnections:t?.maxConnections??10,keepAliveInterval:t?.keepAliveInterval??6e4,connectionTimeout:t?.connectionTimeout??3e4,idleTimeout:t?.idleTimeout??3e5},this.maxPerOrg=r?.maxPerOrg??e.DEFAULT_MAX_PER_ORG,this.recycleIntervalMs=r?.recycleIntervalMs??e.DEFAULT_RECYCLE_INTERVAL}acquire(t,r,n){let s=this.connections.get(t);if(s&&s.active)return s.lastUsedAt=Date.now(),s.accessToken=n,s;this.connections.size>=this.config.maxConnections&&this.evictOldest();let i={orgId:t,instanceUrl:r,accessToken:n,createdAt:Date.now(),lastUsedAt:Date.now(),active:!0};return this.connections.set(t,i),i}release(t){let r=this.connections.get(t);r&&(r.lastUsedAt=Date.now())}remove(t){return this.latencySamples.delete(t),this.connections.delete(t)}get(t){return this.connections.get(t)}get size(){return this.connections.size}getConfig(){return{...this.config}}getMaxPerOrg(){return this.maxPerOrg}recordLatency(t,r){if(!Number.isFinite(r)||r<0)return;let n=this.latencySamples.get(t);n||(n=[],this.latencySamples.set(t,n)),n.push(r),n.length>1e3&&n.splice(0,n.length-1e3)}getLatencyMetrics(t){let r=this.latencySamples.get(t);if(!r||r.length===0)return;let n=[...r].sort((a,c)=>a-c),s=n.reduce((a,c)=>a+c,0),i=Math.floor(n.length*.95),u=Math.floor(n.length*.99);return{min:n[0],max:n[n.length-1],avg:Math.round(s/n.length),p95:n[Math.min(i,n.length-1)],p99:n[Math.min(u,n.length-1)],sampleCount:n.length}}getAllLatencyMetrics(){let t=new Map;for(let r of this.latencySamples.keys()){let n=this.getLatencyMetrics(r);n&&t.set(r,n)}return t}cleanupIdle(){let t=Date.now(),r=0;for(let[n,s]of this.connections)t-s.lastUsedAt>this.config.idleTimeout&&(this.connections.delete(n),r++);return r}recycleStale(){let t=Date.now(),r=0;for(let[n,s]of this.connections)t-s.createdAt>this.recycleIntervalMs&&(s.active=!1,this.connections.delete(n),r++);return r}startCleanup(){this.stopCleanup(),this.cleanupTimer=setInterval(()=>this.cleanupIdle(),this.config.keepAliveInterval)}stopCleanup(){this.cleanupTimer&&(clearInterval(this.cleanupTimer),this.cleanupTimer=void 0)}startRecycling(){this.stopRecycling(),this.recycleTimer=setInterval(()=>this.recycleStale(),this.recycleIntervalMs)}stopRecycling(){this.recycleTimer&&(clearInterval(this.recycleTimer),this.recycleTimer=void 0)}evictOldest(){let t,r=1/0;for(let[n,s]of this.connections)s.lastUsedAt<r&&(r=s.lastUsedAt,t=n);t&&this.connections.delete(t)}dispose(){this.stopCleanup(),this.stopRecycling(),this.connections.clear(),this.latencySamples.clear()}};var S=class{state="closed";failureCount=0;lastFailureTime=0;halfOpenSuccesses=0;halfOpenInFlight=0;config;constructor(t){this.config={failureThreshold:t?.failureThreshold??5,resetTimeout:t?.resetTimeout??6e4,halfOpenRequests:t?.halfOpenRequests??1}}getState(){return this.state==="open"&&this.shouldTransitionToHalfOpen()&&(this.state="half_open",this.halfOpenSuccesses=0),this.state}canExecute(){let t=this.getState();return t==="closed"?!0:t==="half_open"?this.halfOpenInFlight<this.config.halfOpenRequests:!1}recordSuccess(){this.state==="half_open"?(this.halfOpenSuccesses++,this.halfOpenInFlight=Math.max(0,this.halfOpenInFlight-1),this.halfOpenSuccesses>=this.config.halfOpenRequests&&this.reset()):this.failureCount=0}recordFailure(){this.failureCount++,this.lastFailureTime=Date.now(),this.state==="half_open"?this.trip():this.failureCount>=this.config.failureThreshold&&this.trip()}trip(){this.state="open",this.lastFailureTime=Date.now()}reset(){this.state="closed",this.failureCount=0,this.halfOpenSuccesses=0,this.halfOpenInFlight=0}getFailureCount(){return this.failureCount}acquirePermit(){return this.canExecute()?(this.getState()==="half_open"&&this.halfOpenInFlight++,!0):!1}releasePermit(){this.halfOpenInFlight=Math.max(0,this.halfOpenInFlight-1)}getConfig(){return{...this.config}}shouldTransitionToHalfOpen(){return Date.now()-this.lastFailureTime>=this.config.resetTimeout}};var B=0;function we(){return B}async function I(e,t){let r=$(e);try{return await t()}finally{B+=r()}}var C=class extends Error{constructor(r,n,s){super(`${r}: ${s}`);this.code=r;this.orgId=n;this.name="OrgConnectionError"}code;orgId};import{homedir as ee,userInfo as te}from"node:os";var ne=[/^ELECTRON_.+$/,/^VSCODE_(?!(PORTABLE|SHELL_LOGIN|ENV_REPLACE|ENV_APPEND|ENV_PREPEND)).+$/,/^SNAP(|_.*)$/,/^GDK_PIXBUF_.+$/],V=["HTTP_PROXY","HTTPS_PROXY","NO_PROXY","NODE_EXTRA_CA_CERTS","NODE_OPTIONS","NODE_TLS_REJECT_UNAUTHORIZED"];function X(e){return ne.some(t=>t.test(e))}function P(e=process.env){let t={};for(let[r,n]of Object.entries(e))X(r)||(t[r]=n);return t.NO_COLOR="1",t}function Ee(e=process.env){let t=Object.keys(e).filter(c=>(e[c]??"")!==""),r=V.filter(c=>t.some(d=>d.toUpperCase()===c)),n=t.filter(c=>/^(SF|SFDX)_/i.test(c)).sort(),s=t.filter(c=>X(c)),i=s.filter(c=>c.startsWith("ELECTRON_")).sort(),u=s.length-i.length,a=s.length===0?"none":[...i,...u>0?[`${u} VSCODE_ or other VS Code variables`]:[]].join(", ");return`set: ${r.length>0?r.join(", "):"none of "+V.join(", ")}; SF_/SFDX_: ${n.length>0?n.join(", "):"none"}; not passed to sf, as a terminal does not get them: ${a}`}function re(){try{return te().username}catch{return process.env.USERNAME??process.env.USER??""}}function H(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function j(e,t=ee(),r=re()){let n=e;return t.length>3&&(n=n.replace(new RegExp(H(t),"gi"),"~")),r.length>=2&&(n=n.replace(new RegExp(`(?<=[\\\\/])${H(r)}(?=[\\\\/]|$)`,"gim"),"<user>")),n.replace(/00D\w{12,15}![\w.]+/g,"<token>").replace(/[\w.+-]+@[\w-]+(\.[\w-]+)+/g,"<username>")}function ve(e){return e.split(/\r?\n/).map(t=>t.trim()).find(t=>t.length>0)}function se(e,t){if(process.platform!=="win32")return e[0];let n=(Object.entries(t).find(([s])=>s.toUpperCase()==="PATHEXT")?.[1]??".COM;.EXE;.BAT;.CMD").split(";").map(s=>s.trim().toLowerCase()).filter(s=>s.length>0);return e.find(s=>{let i=s.lastIndexOf(".");return i>Math.max(s.lastIndexOf("\\"),s.lastIndexOf("/"))&&n.includes(s.slice(i).toLowerCase())})}async function Oe(e=1e4){let{exec:t}=await import("child_process"),{promisify:r}=await import("util"),n=process.platform==="win32"?"where sf node":"which -a sf node",s=P(),i,u;try{let l=await r(t)(n,{timeout:e,windowsHide:!0,env:s});i=String(l.stdout)}catch(l){let o=l;i=String(o.stdout??""),i.trim()===""&&(u=j(o.message??String(l)))}let a=i.split(/\r?\n/).map(l=>l.trim()).filter(l=>l.length>0).map(l=>j(l)),c=l=>a.filter(o=>new RegExp(`(^|[\\\\/])${l}(\\.[A-Za-z0-9]+)?$`,"i").test(o)),d=c("sf"),p=se(d,s);return{sf:d,node:c("node"),...p!==void 0?{runs:p}:{},...u?{failure:u}:{}}}function R(e,t){let r=(e[t.toLowerCase()]??e[t.toUpperCase()]??"").trim();return r===""?void 0:r}function ie(e,t){if(t===void 0)return!1;let r=e.hostname.toLowerCase(),n=e.port||(e.protocol==="https:"?"443":"80");return t.split(/[\s,]+/).filter(s=>s!=="").some(s=>{if(s==="*")return!0;let[,i="",u]=/^(.*?)(?::(\d+))?$/.exec(s.toLowerCase())??[];if(u!==void 0&&u!==n)return!1;let a=i.replace(/^\*?\.?/,"");return a!==""&&(r===a||r.endsWith(`.${a}`))})}function G(e,t=process.env){let r;try{r=new URL(e)}catch{return}let n=r.protocol==="https:"?R(t,"https_proxy")??R(t,"http_proxy"):R(t,"http_proxy");if(n!==void 0)return ie(r,R(t,"no_proxy"))?void 0:n}var oe="https://login.salesforce.com";async function v(e,t=process.env){let{jsforce:r,HttpProxyTransport:n}=await import("./chunk-L5FGY6YA.mjs"),s=G(e.instanceUrl??e.loginUrl??oe,t),i=new r.Connection({...e,...s!==void 0?{httpProxy:s}:{}});return s===void 0&&(i._transport=new n("")),i}var ae=10*1024*1024,L=3e4,q=L+2e3,A=`sf did not answer within ${L/1e3} s \u2014 check the Salesforce CLI`;function J(e){return e instanceof Error&&e.message===A}var D=2e4;function U(e,t,r){let n,s=new Promise((i,u)=>{n=setTimeout(()=>u(new Error(r)),t)});return Promise.race([e,s]).finally(()=>clearTimeout(n))}var E=new x,ce=300*1e3,_=new Map,le={failureThreshold:3,resetTimeout:3e4},z=new Map;function Ne(){return E}function ue(e){let t=z.get(e);return t||(t=new S({...le}),z.set(e,t)),t}var Y;var b="panel";function Be(e){b=e}function fe(e,t=b){return t==="panel"?"Reconnect it on the Organizations page (Try Reconnect on its card).":`Sign in to it again with "sf org login web --alias ${e}" (in a CI job, "sf org login jwt" or "sf org login sfdx-url"), then run the command again, with its --resume if it stopped a run part way.`}function W(e=b){return e==="panel"?"Create a new one and import it.":'Create a new one ("sf org create scratch") and give its alias.'}function K(e,t){let r=t?.organization_id;if(!(!Y||typeof r!="string"))try{Y(e,{organizationId:r})}catch(n){N.warn("Identity observer threw",{orgId:e,error:O(n)})}}var de="[REDACTED]";function Z(e){return typeof e=="string"&&e.length>0&&!e.startsWith(de)&&!/\s/.test(e)}async function pe(e){if(!/^[\w.@+-]+$/.test(e))throw new Error(`Invalid username format: "${e}"`);let{execFile:t,exec:r}=await import("child_process"),{promisify:n}=await import("util"),s={maxBuffer:ae,timeout:L,windowsHide:!0,env:P()},i=o=>U(n(t)("sf",o,s),q,A),u=o=>{let f=!1,h,y=new Promise((T,m)=>{h=r(o,s,(g,w)=>{f=!0,g?m(g):T({stdout:w})})});return U(y,q,A).catch(T=>{throw!f&&h?.pid!==void 0&&t("taskkill",["/pid",String(h.pid),"/T","/F"],{windowsHide:!0},()=>{}),T})},a=(o,f)=>process.platform==="win32"?u(o):i(f),c=(o,f)=>{let h=o.replace(/\[[0-9;]*m/g,""),y=h.search(/[{[]/);if(y===-1)throw new Error(`Failed to parse "${f}" output: no JSON found. Ensure Salesforce CLI (sf) is installed and the org is authenticated.`);return JSON.parse(h.slice(y)).result??{}},d;try{let{stdout:o}=await a(`sf org display -u "${e}" --json`,["org","display","-u",e,"--json"]),f=c(o,"sf org display");d=typeof f.instanceUrl=="string"?f.instanceUrl:void 0}catch(o){if(J(o))throw o;d=void 0}try{let{stdout:o}=await a(`sf org auth show-access-token -o "${e}" --json`,["org","auth","show-access-token","-o",e,"--json"]),f=c(o,"sf org auth show-access-token");if(Z(f.accessToken))return{accessToken:f.accessToken,instanceUrl:d}}catch(o){if(J(o))throw o}let{stdout:p}=await a(`sf org display -u "${e}" --json`,["org","display","-u",e,"--json"]),l=c(p,"sf org display");if(!Z(l.accessToken))throw new Error('Neither "sf org auth show-access-token" nor "sf org display" returned an access token. The org session may have expired \u2014 try re-authenticating with "sf org login".');return!d&&typeof l.instanceUrl=="string"&&(d=l.instanceUrl),{accessToken:l.accessToken,instanceUrl:d}}async function Ve(e,t){return v({instanceUrl:e.instanceUrl,accessToken:e.accessToken??void 0,version:e.version,callOptions:{client:t}})}async function He(e){return v({instanceUrl:e.instanceUrl,accessToken:e.accessToken,version:e.version})}async function je(e,t,r){let n=e,s=r.getOrg(e);if(!s)throw new Error(`Org not found: ${e}`);let i=await t.getCredentials(e);if(!i?.accessToken||!i.instanceUrl)throw new Error(`No credentials for org "${s.alias}" (${e}). Reconnect the org.`);let u=s.metadata.apiVersion||M.DEFAULT_API_VERSION,a=E.get(n),c=Date.now()-(_.get(e)??0)<ce;if(a&&a.active&&a.accessToken===i.accessToken&&c)return a.lastUsedAt=Date.now(),v({instanceUrl:a.instanceUrl,accessToken:a.accessToken,version:u});let d=await v({instanceUrl:i.instanceUrl,accessToken:i.accessToken,version:u}),p=ue(e);if(!p.acquirePermit())throw new C("ORG_TEMPORARILY_UNREACHABLE",e,`"${s.alias}" failed several times in a row, so SandForge waits a moment before calling it again. Try again in a minute.`);let l=Date.now(),o=`identity check did not answer within ${D/1e3} s`;try{let f=await I(d,()=>U(d.identity(),D,o)),h=Date.now()-l;return p.recordSuccess(),E.acquire(n,i.instanceUrl,i.accessToken),E.recordLatency(n,h),_.set(e,Date.now()),K(e,f),d}catch(f){let h=Date.now()-l;if(E.remove(n),_.delete(e),F(f))try{let m=await pe(s.username),g=m.instanceUrl??i.instanceUrl;if(m.accessToken===i.accessToken&&g===i.instanceUrl)throw new Error("sf CLI token store is stale too (same expired token) \u2014 re-authenticate the org");let w=await v({instanceUrl:g,accessToken:m.accessToken,version:u}),Q=await I(w,()=>U(w.identity(),D,o));return await t.saveOrg(s,{...i,accessToken:m.accessToken,instanceUrl:g}),p.recordSuccess(),E.acquire(n,g,m.accessToken),E.recordLatency(n,h),_.set(e,Date.now()),K(e,Q),w}catch(m){p.recordFailure();let g=O(m);r.updateStatus(e,"expired");let w=k(s,new Date().toISOString().slice(0,10));throw w!==void 0?new C("SCRATCH_ORG_EXPIRED",e,`The scratch org "${s.alias}" expired on ${w}: Salesforce deletes a scratch org when it expires, and no reconnect brings it back. ${W()} (cause: ${g})`):new C("ORG_AUTH_EXPIRED",e,`The session with "${s.alias}" has expired and could not be renewed. ${fe(s.alias)} (cause: ${g})`)}p.recordFailure();let y=O(f),T=k(s,new Date().toISOString().slice(0,10));throw T!==void 0?(r.updateStatus(e,"expired"),new C("SCRATCH_ORG_EXPIRED",e,`The scratch org "${s.alias}" expired on ${T}: Salesforce deletes a scratch org when it expires, and no reconnect brings it back. ${W()} (cause: ${y})`)):new Error(`Connection failed for "${s.alias}": ${y}`)}finally{p.releasePermit()}}export{we as a,I as b,C as c,P as d,Ee as e,j as f,ve as g,Oe as h,G as i,v as j,U as k,Ne as l,Be as m,Z as n,pe as o,Ve as p,He as q,je as r};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s}from"./chunk-3Q353S2R.mjs";import"./chunk-M6K34KGF.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{r as BEFORE_RUN_DELETED_WORDS,e as BEFORE_RUN_DISK_ROOM,a as WRITE_PATH_STEPS,j as beforeRunAskedOf,f as beforeRunDiskRefusal,d as beforeRunEstimateOf,q as beforeRunFailedWords,i as beforeRunKeepDaysOf,h as beforeRunNameOf,l as beforeRunOutcomeOf,s as beforeRunProgressWords,p as beforeRunRefusedWords,c as beforeRunScopeOf,k as beforeRunTakenOf,g as freeBytesOf,m as scopeBeforeRun,o as settleBeforeRun,n as takeBeforeRun,b as writePathOrderDefects};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b}from"./chunk-
|
|
7
|
+
import{a,b}from"./chunk-54WZUS7J.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as seedObjectAccess,b as templateTheOrgTakes};
|
|
@@ -4,6 +4,6 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{o as m}from"./chunk-
|
|
7
|
+
import{o as m}from"./chunk-UI3JQVRU.mjs";import{H as d,d as w,z as b}from"./chunk-KGU4SVIT.mjs";import{Uc as u}from"./chunk-PMWAFDUB.mjs";import{b as R,e as A,k as j,l as p,v as P}from"./chunk-WZQEK4WT.mjs";import{randomBytes as O}from"node:crypto";import{createReadStream as T}from"node:fs";import{appendFile as C,open as $,readFile as D,rename as F,rm as _}from"node:fs/promises";import{join as k}from"node:path";import{createInterface as M}from"node:readline";var U=2e3,a=15,x=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,W=2e3,z="spool.json",h="a rewind";function v(r){return typeof r=="string"&&x.test(r)?r.slice(0,a):void 0}var g=class{bytes=Buffer.alloc(a*1024);flags=new Uint16Array(1024);slots=new Uint32Array(2048);used=0;get size(){return this.used}find(t){let e=this.slots.length-1;for(let s=m(t)&e;;s=s+1&e){let n=this.slots[s];if(n===0)return-1;if(this.holds(n-1,t))return n-1}}holds(t,e){let s=t*a;for(let n=0;n<a;n++)if(this.bytes[s+n]!==e.charCodeAt(n))return!1;return!0}keyAt(t){let e=t*a;return this.bytes.toString("latin1",e,e+a)}place(t,e){let s=this.slots.length-1,n=m(e)&s;for(;this.slots[n]!==0;)n=n+1&s;this.slots[n]=t+1}add(t,e=0){let s=v(t);if(s===void 0)throw new RangeError(`Not a Salesforce id: ${String(t)}`);let n=this.find(s);if(n>=0)return this.flags[n]|=e,!1;if((this.used+1)*2>this.slots.length){let o=this.slots;this.slots=new Uint32Array(o.length*2);for(let i of o)i!==0&&this.place(i-1,this.keyAt(i-1))}if((this.used+1)*a>this.bytes.length){let o=Buffer.alloc(this.bytes.length*2);this.bytes.copy(o),this.bytes=o;let i=new Uint16Array(this.flags.length*2);i.set(this.flags),this.flags=i}return this.bytes.write(s,this.used*a,a,"latin1"),this.flags[this.used]=e,this.place(this.used,s),this.used++,!0}has(t){let e=v(t);return e!==void 0&&this.find(e)>=0}count(t){let e=0;for(let s=0;s<this.used;s++)t(this.flags[s])&&e++;return e}flagsOf(t){let e=v(t);if(e===void 0)return 0;let s=this.find(e);return s<0?0:this.flags[s]}},B=p({version:P(1),objects:j(p({objectApiName:R().min(1),count:A().int().nonnegative()}))});function S(r,t){return k(r,`${u(t)}.ids`)}async function G(r,t){let e=`${r}.${process.pid}-${O(4).toString("hex")}.tmp`,s=await $(e,"wx",w);try{try{await s.writeFile(t,"utf8"),await s.sync()}finally{await s.close()}await F(e,r)}catch(n){throw await _(e,{force:!0}),n}}async function J(r){let t=await $(r,"r+");try{await t.sync()}finally{await t.close()}}async function L(r,t,e=h){for(let{objectApiName:s,count:n}of t)n>0&&await J(S(r,s));return await G(k(r,z),`${JSON.stringify({version:1,objects:t})}
|
|
8
8
|
`),new y(r,t,e)}var I=class{constructor(t,e=h){this.dir=t;this.act=e}dir;act;order=[];counts=new Map;lines=new Map;written=new Set;keys=new g;made=!1;async add(t,e){if(!this.keys.add(e))return!1;let s=this.lines.get(t);return s||(u(t),s=[],this.lines.set(t,s),this.order.push(t)),s.push(e),this.counts.set(t,(this.counts.get(t)??0)+1),s.length>=W&&await this.flush(t),!0}async flush(t){let e=this.lines.get(t)??[];this.made||(await b(this.dir),this.made=!0);let s=!this.written.has(t);e.length===0&&!s||(await C(S(this.dir,t),e.map(n=>`${n}
|
|
9
9
|
`).join(""),{encoding:"utf8",mode:w,flag:s?"w":"a"}),this.written.add(t),this.lines.set(t,[]))}get objects(){return this.order.map(t=>({objectApiName:t,count:this.counts.get(t)??0}))}async finish(t){this.made||(await b(this.dir),this.made=!0);for(let e of this.order)await this.flush(e);return L(this.dir,t?t(this.objects):this.objects,this.act)}},y=class r{constructor(t,e,s=h){this.dir=t;this.objects=e;this.act=s}dir;objects;act;get count(){return this.objects.reduce((t,e)=>t+e.count,0)}static async open(t,e=h){let s;try{s=JSON.parse(await D(k(t,z),"utf8"))}catch{throw new d("damaged",`The list of what ${e} sets out to do is not on this machine.`)}let n=B.safeParse(s);if(!n.success)throw new d("damaged",`The list of what ${e} sets out to do does not read as one.`);for(let{objectApiName:o}of n.data.objects)u(o);return new r(t,n.data.objects,e)}async*pages(t,e=U){let s=this.objects.find(c=>c.objectApiName===t);if(!s||s.count===0)return;let n=()=>new d("damaged",`The ${t} records ${this.act} sets out to act on are not as they were written.`),o=Math.max(1,Math.floor(e)),i=T(S(this.dir,t),{encoding:"utf8"}),f=M({input:i,crlfDelay:1/0}),E=0,l=[];try{for await(let c of f)if(c!==""){if(!x.test(c))throw n();E++,l.push(c),l.length>=o&&(yield l,l=[])}}catch(c){throw c.code==="ENOENT"?n():c}finally{f.close(),i.destroy()}if(E!==s.count)throw n();l.length>0&&(yield l)}},N=class r{constructor(t,e){this.spool=t;this.keys=e}spool;keys;static async of(t,e){return new r(await t.finish(e),t.keys)}static async open(t,e=h){let s=await y.open(t,e),n=new g;for(let{objectApiName:o}of s.objects)for await(let i of s.pages(o))for(let f of i)n.add(f);return new r(s,n)}get objects(){return this.spool.objects}pages(t){return this.spool.pages(t)}has(t){return this.keys.has(t)}};export{U as a,g as b,S as c,L as d,I as e,y as f,N as g};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d}from"./chunk-
|
|
7
|
+
import{a,b,c,d}from"./chunk-ZV7ZFQQC.mjs";import"./chunk-UV74P4H2.mjs";import"./chunk-KGU4SVIT.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-S42RBRH2.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{d as UsersRunStore,a as defaultUsersStoreRoot,b as usersHeldUserSchema,c as usersRunRecordSchema};
|
|
@@ -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{H as p,d as u,k as d,z as h}from"./chunk-
|
|
7
|
+
import{H as p,d as u,k as d,z as h}from"./chunk-KGU4SVIT.mjs";import{b as c}from"./chunk-CA5NAXSU.mjs";import{db as a}from"./chunk-PMWAFDUB.mjs";import{randomBytes as E}from"node:crypto";import{open as k,readFile as b,rename as I,rm as T}from"node:fs/promises";import{dirname as l,join as m}from"node:path";var f="rewinds.ndjson",C=400,O=200;function P(e,n){return m(e,d(n),f)}function R(e){return m(l(e.dir),f)}async function y(e,n,t,i={maxLines:C,keptLines:O}){if(d(t.organizationId)!==n.organizationId)throw new p("invalid","A rewind is kept in its org\u2019s ledger, under its lock.");let r=a.safeParse(t);if(!r.success)throw new p("invalid","A line of the rewind ledger does not parse.");await h(l(e));let o=await w(e),x=o!==""&&!o.endsWith(`
|
|
8
8
|
`)?`
|
|
9
9
|
`:"",s=await k(e,"a",u);try{await s.writeFile(`${x}${JSON.stringify(r.data)}
|
|
10
10
|
`,"utf8"),await s.sync()}finally{await s.close()}L(o).length+1>i.maxLines&&await A(e,i.keptLines)}async function A(e,n){let t=L(await w(e)).slice(-n),i=`${e}.${process.pid}-${E(4).toString("hex")}.tmp`,r=await k(i,"wx",u);try{try{await r.writeFile(t.map(o=>`${o}
|
|
@@ -4,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 P,b as $}from"./chunk-
|
|
7
|
+
import{a as P,b as $}from"./chunk-JE6SCT6R.mjs";import{a as O,b,d as E,e as D}from"./chunk-W6PN6TJG.mjs";import{b as S}from"./chunk-CA5NAXSU.mjs";import{A as m,_c as R}from"./chunk-PMWAFDUB.mjs";var y=[{field:"PermissionsViewAllData",label:"View All Data"},{field:"PermissionsModifyAllData",label:"Modify All Data"}],I="PermissionsQueryAllFiles",T="PermissionsCustomizeApplication",d="No record was read or written.";function c(e,t){return{allowed:!1,refusal:{code:e,message:t}}}function w(e,t){return c("PRODUCTION",`${e} is a production org, or cannot be told from one: ${t}. Checkpoints are for sandboxes, scratch orgs and Developer Edition orgs: SandForge never takes a checkpoint of, or rewinds, a production org. ${d}`)}function N(e){return e.edition?`its Organization record says IsSandbox false, edition ${e.edition}`:"its Organization record says IsSandbox false, and no edition"}function j(e,t){return e.slice(0,15)===t.slice(0,15)}function V(e,t){return e.orgType==="Scratch"?"scratch":t.sandbox?"sandbox":"developer"}var z={take:"A checkpoint needs a user with View All Data and Modify All Data: a rewind to it must",preview:"A preview needs a user with View All Data and Modify All Data: a record the user cannot see would read as deleted since, and the rewind it shows must",rewind:"Rewind needs a user with View All Data and Modify All Data: it must",undo:"Undo needs a user with View All Data and Modify All Data: it must",import:"An import needs a user with View All Data and Modify All Data: SandForge never keeps on this machine records its user could not see in the org, and a rewind to it must"},F={take:"Leave the custom settings out of the checkpoint, or give the user Customize Application.",preview:"This checkpoint holds custom settings: give the user Customize Application.",rewind:"This checkpoint holds custom settings: give the user Customize Application.",undo:"This checkpoint holds custom settings: give the user Customize Application.",import:"This checkpoint holds custom settings: give the user Customize Application."};function x(e){return c("PERMISSIONS",`${e.username} needs Customize Application to keep and rewind custom settings, and doesn't have it: View All Custom Settings lets a user read them, never write them. ${F[e.act]} ${d}`)}async function _(e,t){let r=[...y.map(n=>n.field),...t?[T]:[]],i=async n=>(await e.query(`SELECT ${n.join(", ")} FROM UserPermissionAccess`)).records[0],o;try{o=await i([...r,I])}catch{try{o=await i(r)}catch(n){return{unread:n instanceof Error?n.message:String(n)}}}return{missing:y.filter(n=>o?.[n.field]!==!0).map(n=>n.label),viewAllData:o?.PermissionsViewAllData===!0,modifyAllData:o?.PermissionsModifyAllData===!0,queryAllFiles:o?.[I]===!0,customizeApplication:o?.[T]===!0}}var q=/^005[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/,L=/^0PG[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/,M="SobjectType, PermissionsViewAllRecords, PermissionsModifyAllRecords";async function A(e,t){let r=await e.query(t),i=1,o=[...r.records];for(;!r.done;){let n=r.nextRecordsUrl;if(n===void 0||e.queryMore===void 0)throw new Error(`the org answered ${o.length} rows of ${r.totalSize}, and no next page`);r=await e.queryMore(n),i++,o.push(...r.records)}return{rows:o,requests:i}}async function U(e,t){let r=0;try{let i=await t();if(r++,!q.test(i))throw new Error(`the org named the user ${JSON.stringify(i)}`);let o=await A(e,`SELECT ${M} FROM ObjectPermissions WHERE ParentId IN (SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId = '${i}' AND PermissionSetGroupId = null)`);r+=o.requests;let n=await A(e,`SELECT PermissionSetGroupId FROM PermissionSetAssignment WHERE AssigneeId = '${i}' AND PermissionSetGroupId != null`);r+=n.requests;let l=[...new Set(n.rows.map(a=>a.PermissionSetGroupId).filter(a=>typeof a=="string"&&L.test(a)))],s=[...o.rows];if(l.length>0){let a=await A(e,`SELECT ${M} FROM ObjectPermissions WHERE Parent.PermissionSetGroupId IN (${l.map(u=>`'${u}'`).join(", ")})`);r+=a.requests,s.push(...a.rows)}return{grants:P(s),requests:r}}catch(i){return{unread:S(i)}}}var v={take:"A checkpoint needs a user with View All Data and Modify All Data, or with View All and Modify All on each object it holds: a rewind to it must see and put back what everyone changed there.",preview:"A preview needs a user with View All Data and Modify All Data, or with View All and Modify All on each object it reads: a record the user cannot see would read as deleted since.",rewind:"Rewind needs a user with View All Data and Modify All Data, or with View All and Modify All on each object it puts back: it must see and put back what everyone changed there.",undo:"Undo needs a user with View All Data and Modify All Data, or with View All and Modify All on each object it takes back: it must see and put back what everyone changed there."};async function Y(e,t,r={}){let{orgName:i,registered:o}=t;if(o===void 0)return w(i,"SandForge has no record of what kind of org it is");if(!R(o))return w(i,"SandForge has it registered as a production org");let n;try{n=await O(e)}catch(p){let C=E(p);if(C!==void 0)return c("ORG_UNTYPED",`${D(i,p,C)} SandForge takes a checkpoint of no org it cannot tell from a production one. ${d}`);let G=p instanceof Error?p.message:String(p);return w(i,`it did not say what org it is (${G})`)}if(b(n))return w(i,N(n));if(t.act!=="take"&&!j(n.id,t.organizationId))return c("OTHER_ORG",t.act==="import"?`${i} is another org than the one this file holds a checkpoint of: it is imported for the org it was taken of alone, under any alias of it. ${m} Replay the file in ${i} instead. Nothing was imported.`:`${i} is another org than the one this checkpoint was taken of: its Organization Id has changed, as a sandbox's does when it is refreshed. This checkpoint is of the org before it, and no longer rewinds. ${m} `+d);let l=t.customSettings===!0,s=await _(e,l),a=`${z[t.act]} see and put back what everyone changed.`;if("unread"in s)return c("PERMISSIONS",`${a} SandForge could not read whether ${t.username} has them (${s.unread}), and takes an org that will not say for a user who has neither. `+d);let u=s.missing.length===y.length?"them":s.missing.join(" and "),g=t.act,f=g==="import"?void 0:r.userId;if(s.missing.length>0&&f===void 0)return c("PERMISSIONS",`${a} ${t.username} doesn't have ${u}. ${d}`);if(l&&!s.customizeApplication)return x(t);let k={allowed:!0,org:n,tier:V(o,n),queryAllFiles:s.queryAllFiles};if(s.missing.length===0||f===void 0||g==="import")return{...k,grants:{kind:"org"}};let h=await U(e,f);return"unread"in h?c("PERMISSIONS",`${v[g]} ${t.username} doesn't have ${u}, and SandForge could not read which objects they have View All and Modify All on (${h.unread}). View Setup and Configuration lets a user read their own permissions; with View All Data and Modify All Data, nothing needs reading. `+d):$(h.grants)?{...k,grants:{kind:"perObject",viewAllData:s.viewAllData,modifyAllData:s.modifyAllData,objects:h.grants,requests:h.requests}}:c("PERMISSIONS",`${v[g]} ${t.username} doesn't have ${u}, nor View All and Modify All on any object. Give the user View All and Modify All on the objects to hold, or View All Data and Modify All Data. ${d}`)}export{U as a,Y as b};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{j as ee,l as M}from"./chunk-HIDW7FNV.mjs";import{d as G}from"./chunk-JAEDM4SI.mjs";import{b as V,c as X,g as z}from"./chunk-LC3NDW4N.mjs";import{Dc as ne,Ec as N,Oc as re,Zb as te,i as Y,j as T,jc as se,k as K,m as J,q as Q,s as Z}from"./chunk-KB4ZHM4Q.mjs";import{c as U,d as B}from"./chunk-Q7TLC3I2.mjs";import{B as H}from"./chunk-YA6ATMTB.mjs";import{b as $}from"./chunk-CA5NAXSU.mjs";import{Md as P,Qd as C,Vd as S,Yd as F,Zd as q}from"./chunk-PMWAFDUB.mjs";var Pe=5e3,x=2e3,me=1e3,pe={masking:{during:"during the masking",records:"records it masked"},restore:{during:"during the restore",records:"records it put back"},erasure:{during:"during the erasure",records:"records it overwrote"}};function oe(e,t){let n=new Set(t.map(s=>s.toLowerCase()));return(e?.objects??[]).filter(s=>n.has(s.objectApiName.toLowerCase())).filter(s=>(s.duplicateRules??[]).length>0).map(s=>({objectApiName:s.objectApiName,rules:(s.duplicateRules??[]).map(a=>a.name)}))}function ae(e){return typeof e=="string"?e.slice(0,15):""}async function ge(e,t){let{rules:n}=t,s=0,a=r=>(s++,e.query(r));try{let r=H(new Date(Date.parse(t.since)-me).toISOString()),i=new Set([...t.masked].map(ae)),c=await a(`SELECT Id, DuplicateRecordSetId, RecordId FROM DuplicateRecordItem WHERE CreatedDate >= ${r} LIMIT ${x+1}`),u=c.done===!1||c.records.length>x,d=c.records.slice(0,x),p=new Set(d.filter(o=>i.has(ae(o.RecordId))).map(o=>String(o.DuplicateRecordSetId??"")).filter(o=>o!=="")),l=d.filter(o=>p.has(String(o.DuplicateRecordSetId??""))).length,m=0;for(let o of G([...p])){let f=await a(`SELECT Id FROM DuplicateRecordSet WHERE CreatedDate >= ${r} AND Id IN (${o})`);m+=f.records.length}return{rules:n,sets:m,items:l,...u?{atLeast:!0}:{},requests:s}}catch(r){return{rules:n,sets:0,items:0,unread:$(r),requests:s}}}function Ce(e,t,n){let s=n.now??Date.now,a=n.sleep??(l=>new Promise(m=>setTimeout(m,l))),r=new Set(t.map(l=>l.objectApiName.toLowerCase())),i=l=>r.has(l.toLowerCase()),c,u=0,d=new Set,p=0;return{covers:i,beforeWrite:l=>{i(l)&&c===void 0&&(u=s())},wrote:(l,m)=>{if(!i(l))return;let o=!1;for(let h of m)typeof h!="string"||h===""||(d.add(h),o=!0);if(!o)return;p=s();let f=u;c??=e.serverTime().then(h=>{let b=Date.parse(h);return Number.isNaN(b)?{unread:`it answered "${h}"`}:{at:new Date(b-Math.max(0,s()-f)).toISOString()}},h=>({unread:$(h)}))},held:()=>d.size,read:async()=>{if(d.size===0)return;let l=c?await c:void 0;if(!l||"unread"in l)return{rules:t,sets:0,items:0,unread:l?`the org's clock: ${l.unread}`:"the org's clock was not read",requests:l?1:0};let m=Math.max(0,p+n.settleMs-s());m>0&&await a(m);let o=await ge(e,{rules:t,since:l.at,masked:d});return{...o,requests:(o.requests??0)+1,waitedMs:m}}}}function Fe(e,t){if(!e)return t;if(!t)return e;let n=[e.unread,t.unread].filter(s=>s!==void 0);return{rules:t.rules.length>=e.rules.length?t.rules:e.rules,sets:e.sets+t.sets,items:e.items+t.items,...e.atLeast||t.atLeast?{atLeast:!0}:{},...n.length>0?{unread:n.join("; ")}:{},requests:(e.requests??0)+(t.requests??0),waitedMs:(e.waitedMs??0)+(t.waitedMs??0)}}function qe(e){return e!==void 0&&(e.sets>0||e.items>0||e.unread!==void 0)}function fe(e){return e.map(t=>`"${t}"`).join(", ")}function he(e){return e<=0?"without waiting":e<1e3?"after waiting less than 1 s":`after waiting ${Math.round(e/1e3)} s`}function Ue(e,t,n="masking"){if(!e||e.rules.length===0)return"";let s=pe[n],a=e.rules.map(c=>`${c.objectApiName} (${fe(c.rules)})`).join(", ");if(e.unread!==void 0)return`What the duplicate rules of ${t} on ${a} wrote ${s.during} could not be read (${e.unread}): a duplicate record set they wrote stays.`;let r=e.requests!==void 0?` Read in ${e.requests} request(s), ${he(e.waitedMs??0)}.`:"";if(e.sets===0&&e.items===0)return`The duplicate rules of ${t} on ${a} wrote nothing for the ${s.records}.`+r;let i=e.atLeast===!0?"at least ":"";return`The duplicate rules of ${t} on ${a} wrote ${i}${e.sets} duplicate record set(s) and ${i}${e.items} item(s) ${s.during}, for ${s.records}: kept, as they name records that stay.${r}`}var we="AUTOMATION_NOT_ACCEPTED",Oe="EMAILS_EXCEEDED",Ae="ORG_TEMPORARILY_UNREACHABLE";function be(e,t){return e==="cleanup"||e==="empty"?{delete:[...t]}:e==="restore"?{bringBack:[...t],giveBack:[...t]}:e==="emptyUndo"?{bringBack:[...t]}:{giveBack:[...t]}}function $e(e,t){let n=e==="cleanup"||e==="empty"?"delete":"update";return t.filter(s=>s.records>0).map(s=>({objectApiName:s.objectApiName,write:n,records:s.records}))}var E={masking:{heading:"masking automation: what {org} runs as the masking writes over the records",the:"the masking",this:"this masking",writes:"writes over",verb:"mask",nothing:"Nothing was written.",flag:"to mask all the same"},restore:{heading:"restore automation: what {org} runs as the restore puts the backup's values back",the:"the restore",this:"this restore",writes:"puts back",verb:"restore",nothing:"Nothing was written.",flag:"to restore all the same"},cleanup:{heading:"cleanup automation: what {org} runs as the cleanup deletes the records",the:"the cleanup",this:"this cleanup",writes:"deletes",verb:"delete",nothing:"Nothing was deleted.",flag:"to delete all the same"},empty:{heading:"emptying automation: what {org} runs as the emptying deletes the records",the:"the emptying",this:"this emptying",writes:"deletes",verb:"empty",nothing:"Nothing was deleted.",flag:"to empty all the same"},emptyUndo:{heading:"undo automation: what {org} runs as the undo brings the records back",the:"the undo",this:"this undo",writes:"brings back",verb:"undo",nothing:"Nothing was written.",flag:"to undo all the same"}},ye={masking:"masking",restore:"restore",cleanup:"cleanup",empty:"empty",emptyUndo:"undo"};function Qe(e){return e.erasure===!0?"erasure":e.fromPage===!0?"page":void 0}var De={"accept-automation":"acceptAutomation","accept-emails":"acceptEmails","mute-automation":"muteAutomation"},Re={"accept-emails":"the confirmation's box that lets the org send these emails","mute-automation":"the confirmation's box that mutes the target's automation"},ke={mask:"masking",restore:"restore",delete:"cleanup",erase:"erasure",empty:"emptying",undo:"undo"};function ie(e){let t=n=>Re[n]??`--${n}`;return e.replace(/\bAdd --accept-automation to (mask|restore|delete|erase|empty|undo) all the same\b/g,(n,s)=>`Confirm the ${ke[s]??s} from its confirmation, which lists what fires, to ${s} all the same`).replace(/\bWith --mute-automation,/g,`With ${t("mute-automation")} ticked,`).replace(/\bAdd --(accept-emails|mute-automation)\b/g,(n,s)=>`Tick ${t(s)}`).replace(/(^|[.:;] )--(accept-emails|mute-automation)\b/g,(n,s,a)=>`${s}${W(t(a))}`).replace(/--(accept-emails|mute-automation)\b/g,(n,s)=>t(s))}function L(e,t="flags"){return t==="step"?e.replace(/--(accept-automation|accept-emails|mute-automation)\b/g,(n,s)=>`${De[s]??s} in the step`).replace(/\bAdd (acceptAutomation|acceptEmails|muteAutomation) in the step\b/g,"Turn on $1 in the step"):t==="erasure"?ie(e.replace(/\b(this|the|This|The) (masking|cleanup)\b/g,"$1 erasure").replace(/\bto (mask|delete) all the same\b/g,"to erase all the same").replace(/\b(mask|delete) fewer records\b/g,"erase fewer records")):t==="page"?ie(e):e}var Ee={before:"before save",after:"after save",beforeAndAfter:"before and after save"},ve={before:"before delete",after:"after delete",beforeAndAfter:"before and after delete"},de={flows:"the flows",triggers:"the Apex triggers",processes:"the Process Builder processes",workflowRules:"the workflow rules",automation:"the automation"};function ce({kind:e,name:t}){return e==="flow"?`flow "${t}"`:e==="process"?`process "${t}"`:e==="workflowRule"?`workflow rule "${t}"`:`Apex trigger ${t}`}function le(e,t){return t.step==="delete"?ve[t.when]:t.step==="bringBack"?"as it comes back from the recycle bin":`${e==="restore"?"as its values are put back":"as it is masked"}, ${Ee[t.when]}`}function W(e){return`${e[0]?.toUpperCase()??""}${e.slice(1)}`}function Se(e,t,n,s){let a=E[n],r=[a.heading.replace("{org}",t)];if(typeof e.unread=="string")return r.push(` what ${t} runs could not be read: ${e.unread}`),r;let i=e;for(let d of S(i,s))r.push(` ${d.objectApiName}: ${le(n,d)}: ${ce(d)}`);let c=N(i);if(r.length===1&&c.length===0){let d=new Set(Object.values(s).flat()).size;r.push(` nothing fires on the ${d} object(s) it ${a.writes} records of`)}for(let d of oe(i,s.giveBack??[]))r.push(` ${d.objectApiName}: duplicate rules ${d.rules.map(p=>`"${p}"`).join(", ")}: ${a.the} saves a record a rule only alerts on, a rule that blocks still refuses it, and what a rule that reports writes (a duplicate record set and its items) stays`);let u=P(i);u.length>0&&r.push(` bypass held: the user ${a.the} writes as holds ${u.join(", ")}, and what names it stays quiet`);for(let{part:d,reason:p}of c)r.push(` ${de[d]??d} could not be read: ${p}`);return r}function Te(e,t,n){let s=E[n.act],a=`${s.nothing} Add --accept-automation ${s.flag}, or turn that automation off in ${t} first.`;if(typeof e.unread=="string")return`What ${t} runs as ${s.this} ${s.writes} its records could not be read (${e.unread}), so what fires is not known. ${a}`;let r=e,i=S(r,n.steps),c=N(r);if(i.length===0&&c.length===0)return;let u=[];if(i.length>0){let l=i.map(m=>`${m.objectApiName}: ${ce(m)} (${le(n.act,m)})`);u.push(`${t} runs automation as ${s.this} ${s.writes} its records: ${l.join("; ")}.`)}for(let{part:l,reason:m}of c)u.push(`${W(de[l]??l)} of ${t} could not be read (${m}), so what fires as ${s.the} ${s.writes} its records is not known.`);let d=n.assign??[];u.push(...re(d,t,s.the));let p=[...new Set(d.flatMap(l=>l.permissionSet??[]))];return n.mayMute===!0&&p.length>0&&u.push(r.cannotAssign===!0?`--mute-automation would be refused: ${K}.`:`With --mute-automation, ${s.the} assigns ${p.join(", ")} to the user it writes as for ${s.the} alone, under a lease, and what ${p.length===1?"it keeps":"they keep"} quiet does not fire.`),u.push(a),u.join(" ")}function k(e){let t=e.objects.map(n=>`${n.perRecord} per ${n.objectApiName}`).join(", ");return`about ${se(e.emails,e.limit)} (${t}`+(e.alertsCounted?"; its email alerts among them, as a Developer Edition counts them":"")+")"}function Me(e,t,n){let s=e.map(a=>{if(a.verdict==="unread")return` emails: ${k(a)}; what ${t} has left today could not be read (${a.unread??"not said"})`;let r=`${a.remaining??0} of ${a.max??0} left today`;return a.verdict==="exceeds"?` emails: ${k(a)}, past the ${r}`:` emails: ${k(a)}, ${r}`});return n!==void 0&&s.push(` emails not counted: what sends them was not read (${n})`),s}function Ne(e,t,n,s){let a=t.filter(u=>u.verdict==="exceeds");if(a.length===0)return;let r=E[e],i=a.map(u=>`${k(u)}, ${u.remaining??0} of ${u.max??0} left today`).join("; "),c=s?.kind==="enough"?`Turn off what sends them, give the user it writes as the bypass that keeps them quiet (--mute-automation assigns ${s.sets.join(", ")} for ${r.the} alone, and what still sends then fits what is left today), or ${r.verb} fewer records.`:`Turn off what sends them, or ${r.verb} fewer records.`+(s?.kind==="muting"?" What sends them still runs under the mute.":s?.kind==="notEnough"?" --mute-automation would not keep enough of them quiet.":"");return`${W(r.this)} would make ${n} send ${i}: past them, each record whose flow fails in the save is refused (CANNOT_EXECUTE_FLOW_TRIGGER), and the org's own emails stop for the rest of the day. ${c} ${r.nothing}`}function Ze(e,t,n){return{readAutomation:t,readLimits:()=>te(e),readDeliverability:()=>n?Promise.resolve(V):X(e),muteOrg:async()=>Y(e),...n?{production:n}:{}}}async function et(e,t,n,s){let a=e?.mute?.prepared;if(!e||!a)return{};let r;try{r=await a.acquire(t)}catch(c){if(!T(c))throw c;return{refused:{code:c.code,message:L(c.message,s)}}}let i=e.emails.afterLease(r.outcome,n);return i?(await r.release(),{refused:{code:i.code,message:L(i.message,s)}}):{held:r}}var xe={objectsRead:[],objects:[],unread:[],conditionsNotRead:0,conditionsBound:0,requests:0};async function tt(e){let{act:t,target:n,accord:s}=e,a=e.objects.filter(g=>g.records>0),r=a.map(g=>g.objectApiName),i=e.writes?.steps??be(t,r),c=F(i),u=r.length===0?xe:await e.org.readAutomation(r).catch(g=>{let A=U(g);return{unread:A===void 0?$(g):`the org could not be reached (${A})`}}),d=typeof u.unread=="string"?void 0:u,p=B(u),l=E[t],m=[],o;if(s.muteAutomation===!0&&p===void 0)try{o=await Q(e.org.muteOrg,u,{...e.muteLeases,writes:c})}catch(g){if(!T(g))throw g;m.push({code:g.code,message:g.message})}let f=o?.automation??d,h=e.mayMute&&s.muteAutomation!==!0&&e.org.production!==!0,b=[...Se(d??u,n,t,i),...o?Z(o.muted,n).map(g=>` ${g}`):[]],_=Te(f??u,n,{act:t,steps:i,...f?{assign:ne(f,q(f,i),e.assignTo)}:{},mayMute:h});_!==void 0&&s.acceptAutomation!==!0&&m.push({code:we,message:_});let D=e.writes?e.writes.written.filter(g=>g.records>0):$e(t,a),y=[],R,j;if(f&&p===void 0){if(D.some(A=>C(f,A.write).some(w=>w.objectApiName===A.objectApiName))){let A=await e.org.readLimits().catch(w=>({unread:$(w)}));if(y=M(D,f,A),y.some(w=>w.verdict==="exceeds")){let w=!o&&h&&d?J(d,c):void 0;j=o?{kind:"muting"}:w&&w.plan.assign.length>0&&w.plan.cannotAssign!==!0?M(D,w.automation,A).some(v=>v.verdict==="exceeds")?{kind:"notEnough"}:{kind:"enough",sets:w.plan.assign.map(v=>v.permissionSet)}:void 0}}R=ee(D,f)}b.push(...Me(y,n,R));let I=Ne(t,y,n,j);I!==void 0&&m.push({code:Oe,message:I});let O=await z({read:u,...o?.plan?{plan:o.plan}:{},writes:c,readDeliverability:p===void 0?e.org.readDeliverability:async()=>({reading:{unread:`${n} could not be reached`},requests:0}),accepted:s.acceptEmails===!0,target:n,run:ye[t],keepsAddresses:!0,mayMute:h});return O.gate.line!==void 0&&b.push(` ${O.gate.line}`),O.gate.stop&&m.push({...O.gate.stop}),p!==void 0&&m.splice(0,m.length,{code:Ae,message:`${n} could not be reached as what it runs was read (${p}), so ${l.the} was not started. ${l.nothing} Check the network, then try again.`}),{answer:{act:t,objects:a,steps:i,...d?{automation:d}:{automationUnread:String(u.unread)},lines:b,emails:y,...R!==void 0?{emailsUncounted:R}:{},...O.gate.deliverability?{deliverability:O.gate.deliverability}:{},emailsAsk:O.gate.verdict==="asks",refusals:m.map(g=>({...g,message:L(g.message,e.voice)})),...o?{mutedAutomation:o.muted}:{},...o?.plan?{mutePlan:o.plan}:{}},...o?{mute:o}:{},emails:O}}var Le=/\bnothing (?:was )?(?:written|deleted)\b/i,ue=/\s*\bNothing was (?:written|deleted)\./g;function st(e){let[t,...n]=e.refusals;if(!t)return;let s=!1,a=e.refusals.map(r=>s?r.message.replace(ue,"").trim():(s=Le.test(r.message),r.message)).join(" ");return{code:t.code,message:a,alsoRefused:n.map(r=>({code:r.code,message:r.message.replace(ue,"").trim()}))}}function nt(e){return e.alsoRefused.length>0?{extraPayload:{alsoRefused:[...e.alsoRefused]}}:{}}export{Pe as a,oe as b,Ce as c,Fe as d,qe as e,Ue as f,Qe as g,Ze as h,et as i,tt as j,st as k,nt 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{i as d}from"./chunk-
|
|
7
|
+
import{i as d}from"./chunk-DPMRIMUC.mjs";import{i as s,j as c}from"./chunk-SI267LYR.mjs";import{access as p}from"node:fs/promises";import*as l from"node:path";var u="sfdx-project.json";async function w(n,e=g){for(let t of n)if(await e(l.join(t,u)))return{kind:"dx",dir:t};let r=n[0];return r===void 0?{kind:"none"}:{kind:"folder",dir:r}}async function g(n){try{return await p(n),!0}catch{return!1}}async function S(n,e){if(e.project.kind==="none")return{kind:"unavailable",reason:"no-workspace",message:"Open a folder in VS Code: the test file is written into it."};let r=await c(n.sidecar,e.storagePath,e.runId);if(r.kind==="absent")return{kind:"unavailable",reason:"no-companion",message:"This run kept no companion file: it was not seeded from a scenario, or it wrote no open case for a test to be about."};if(r.kind==="invalid")return{kind:"unavailable",reason:"companion-invalid",message:r.message};let{sidecar:t}=r,o=await e.findPack(t.packId,t.packFingerprint);if(!o)return{kind:"unavailable",reason:"pack-not-found",message:`The scenario ${t.packId} this run was seeded from is no longer in the workspace as it was: its tests would be about subjects and addresses no record of the run holds.`};let i=await e.readCatalog();if(i.kind==="no-agent")return{kind:"no-agent",reason:i.reason,message:i.message};if(i.kind==="unreadable")return{kind:"unavailable",reason:"catalog-unreadable",message:i.message};let a=await d(n.spec,{sidecar:t,pack:o,catalog:i.catalog,choice:e.choice,projectDir:e.project.dir,alias:e.alias,...e.overwrite!==void 0?{overwrite:e.overwrite}:{}});if(a.kind==="refused")return a;if(a.kind==="exists")return{kind:"exists",path:a.path,specPath:a.specPath};await s(n.sidecar,e.storagePath,a.sidecar).catch(()=>{});let f=e.project.kind==="dx";return{kind:"written",path:a.path,specPath:a.specPath,apiName:a.apiName,...f?{commands:{create:a.commands.create.line,run:a.commands.run.line}}:{notDxProject:!0},leftOut:a.leftOut}}export{u as a,w as b,S as c};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a as xe}from"./chunk-Q7GIJBCD.mjs";import{a as Pe,b as Te,c as je,d as Oe,f as Me}from"./chunk-M6P5ZZLE.mjs";import{Ba as Ve,Ca as Ue,Ha as Be,Ja as B,Ka as Qe,Ma as We,ca as De,ma as Le,oa as qe,qa as Ie,ua as U}from"./chunk-KB4ZHM4Q.mjs";import{b as E}from"./chunk-CA5NAXSU.mjs";import{$d as Ge,O as Fe,Q as ve,R as Ne,S as _e,T as Ae,U as Ce,V as Se,W as Ee,ja as $e}from"./chunk-PMWAFDUB.mjs";import{e as X,l as ee}from"./chunk-WZQEK4WT.mjs";var v=class extends Error{};function ct(e){let r=[],n=0;for(;n<e.length;){let t=e.slice(n),s=/^\s+/.exec(t);if(s){n+=s[0].length;continue}if(t.startsWith("/*")){let d=e.indexOf("*/",n+2);if(d<0)throw new v("an unclosed comment");n=d+2;continue}let l=t[0];if(l==="'"||l==='"'){let d=1;for(;d<t.length&&t[d]!==l;)d+=t[d]==="\\"?2:1;if(d>=t.length)throw new v("an unclosed text");r.push(t.slice(0,d+1)),n+=d+1;continue}let f=/^(?:\d+(?:\.\d+)?|[A-Za-z_$][A-Za-z0-9_$.]*)/.exec(t);if(f){r.push(f[0]),n+=f[0].length;continue}let p=/^(?:&&|\|\||==|!=|<>|<=|>=|[=<>+\-*/^&!(),])/.exec(t);if(!p)throw new v(`an unexpected character: ${t[0]}`);r.push(p[0]),n+=p[0].length}return r}var Ke=[new Set(["||"]),new Set(["&&"]),new Set(["=","==","<>","!=","<",">","<=",">="]),new Set(["+","-","&"]),new Set(["*","/"]),new Set(["^"])];function dt(e){let r=ct(e),n=0,t=()=>r[n],s=u=>{if(r[n]!==u)throw new v(`${u} expected`);n++},l=u=>{if(u>=Ke.length)return f();let o=l(u+1);for(let a=t();a!==void 0&&Ke[u].has(a);a=t())n++,o={kind:"binary",op:a,left:o,right:l(u+1)};return o},f=()=>{if(t()==="!")return n++,{kind:"not",arg:f()};if(t()==="-"||t()==="+"){let u=r[n++],o=f();return u==="-"?{kind:"negative",arg:o}:o}return p()},p=()=>{let u=r[n++];if(u===void 0)throw new v("the formula ends early");if(u==="("){let a=l(0);return s(")"),a}if(u.startsWith("'")||u.startsWith('"'))return{kind:"literal",value:`text:${u.slice(1,-1)}`};if(/^\d/.test(u))return{kind:"literal",value:`number:${Number(u)}`};if(!/^[A-Za-z_$]/.test(u))throw new v(`${u} out of place`);if(t()==="("){n++;let a=[];if(t()!==")")for(a.push(l(0));t()===",";)n++,a.push(l(0));return s(")"),{kind:"call",name:u.toUpperCase(),args:a}}let o=u.toUpperCase();return o==="TRUE"||o==="FALSE"||o==="NULL"?{kind:"literal",value:o.toLowerCase()}:{kind:"reference",name:u.toLowerCase()}},d=l(0);if(n!==r.length)throw new v(`${r[n]} out of place`);return d}function $(e){switch(e.kind){case"call":return e.name==="PRIORVALUE"&&e.args.length===1?$(e.args[0]):{...e,args:e.args.map($)};case"binary":return{...e,left:$(e.left),right:$(e.right)};case"not":case"negative":return{...e,arg:$(e.arg)};default:return e}}function N(e){switch(e.kind){case"call":return`${e.name}(${e.args.map(N).join(",")})`;case"binary":{let r=e.op==="=="?"=":e.op==="!="?"<>":e.op,n=[N(e.left),N(e.right)];return(r==="="||r==="<>")&&n.sort(),`(${n[0]} ${r} ${n[1]})`}case"not":return`NOT(${N(e.arg)})`;case"negative":return`-(${N(e.arg)})`;case"literal":return e.value;case"reference":return e.name}}var ze=e=>e==="true"?"false":e==="false"?"true":"unknown";function O(e){return e.kind==="call"&&e.name==="AND"?e.args.flatMap(O):e.kind==="binary"&&e.op==="&&"?[...O(e.left),...O(e.right)]:[e]}function M(e){return e.kind==="call"&&e.name==="OR"?e.args.flatMap(M):e.kind==="binary"&&e.op==="||"?[...M(e.left),...M(e.right)]:[e]}function te(e){if(e.kind==="not"){let r=te(e.arg);return{condition:r.condition,holds:!r.holds}}if(e.kind==="call"&&e.name==="NOT"&&e.args.length===1){let r=te(e.args[0]);return{condition:r.condition,holds:!r.holds}}return e.kind==="binary"&&(e.op==="<>"||e.op==="!=")?{condition:N({...e,op:"="}),holds:!1}:{condition:N(e),holds:!0}}function ne(e){if(e.kind==="literal"){if(e.value==="true")return"true";if(e.value==="false")return"false"}}function R(e){let r=ne(e);if(r)return r;if(e.kind==="not")return ze(R(e.arg));if(e.kind==="call")switch(e.name){case"ISCHANGED":return"false";case"ISNEW":return"true";case"NOT":return e.args.length===1?ze(R(e.args[0])):"unknown";case"AND":return He(O(e));case"OR":return Ze(M(e));case"IF":{if(e.args.length!==3)return"unknown";let[n,t,s]=e.args,l=R(n);if(l==="true")return R(t);if(l==="false")return R(s);let f=R(t);return f===R(s)?f:"unknown"}default:return"unknown"}return e.kind==="binary"?e.op==="&&"?He(O(e)):e.op==="||"?Ze(M(e)):ft(e):"unknown"}function He(e){let r=e.map(R);if(r.includes("false"))return"false";let n=new Map;for(let t of e){let{condition:s,holds:l}=te(t),f=n.get(s);if(f!==void 0&&f!==l)return"false";n.set(s,l)}return r.every(t=>t==="true")?"true":"unknown"}function Ze(e){let r=e.map(R);return r.includes("true")?"true":r.every(n=>n==="false")?"false":"unknown"}function ft(e){let r=e.op==="="||e.op==="==",n=e.op==="<>"||e.op==="!=";if(N(e.left)===N(e.right))return n||e.op==="<"||e.op===">"?"false":"unknown";if(!r&&!n)return"unknown";let t=ne(e.left)??R(e.left),s=ne(e.right)??R(e.right);return t==="unknown"||s==="unknown"?"unknown":t===s===r?"true":"false"}function Ye(e){try{return R($(dt(e)))==="false"}catch(r){if(r instanceof v)return!1;throw r}}var nt=25,W=20,ie=W*De,G=4,Je=10,pt=2e3,gt=.8,Xe=["validationRules","validationRuleFormulas","duplicateRules","duplicateRuleActions","userPermissions","permissionSets","targetFields","sourceFields","apiBudget"];function mt(e){return typeof e!="object"||e===null?null:{optional:e.optionalFilter===!0}}function Bt(e){return{name:e.name,type:String(e.type),createable:e.createable===!0,nillable:e.nillable!==!1,defaultedOnCreate:e.defaultedOnCreate===!0,referenceTo:(e.referenceTo??[]).filter(r=>typeof r=="string"),picklistValues:(e.picklistValues??[]).filter(r=>r?.active!==!1&&typeof r?.value=="string").map(r=>r?.value),lookupFilter:mt(e.filteredLookupInfo)}}function oe(e){return`SELECT Id, ValidationName, NamespacePrefix, ErrorDisplayField, ErrorMessage, EntityDefinition.QualifiedApiName FROM ValidationRule WHERE Active = true AND EntityDefinition.QualifiedApiName IN (${e.map(n=>`'${n}'`).join(", ")})`}function ht(e){return`SELECT QualifiedApiName, Label FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName = '${x.test(e)?e:""}'`}function q(e){return`SELECT Metadata FROM ValidationRule WHERE Id = '${e}'`}var yt="SELECT DeveloperName, MasterLabel, NamespacePrefix, SobjectType FROM DuplicateRule WHERE IsActive = true",ae=/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/,x=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,wt=ee({DailyApiRequests:ee({Max:X(),Remaining:X()}).loose()}).loose(),y=e=>typeof e=="string"?e:"";function le(e){if(typeof e!="object"||e===null)return;let r=e.QualifiedApiName;return typeof r=="string"&&r!==""?r:void 0}function Q(e,r){return e?`${e}__${r}`:r}function L(e){return typeof e=="string"?[e]:Array.isArray(e)?e.filter(r=>typeof r=="string"):[]}function bt(e){return{...e,nodes:e.nodes.map(r=>r.leftOutByUser===!0?{...r,included:!0}:r)}}function se(e,r){let n=y(e).trim(),t=n.slice(n.lastIndexOf(".")+1);if(x.test(t))return r?r.find(s=>s.name.toLowerCase()===t.toLowerCase())?.name:t}function rt(e){let r=Ve({filterFormula:e}).filter(t=>t.bypass).map(t=>t.name),n=Ue(e).map(t=>t.value===void 0?t.reference:`${t.reference} = '${t.value}'`);return{bypasses:[...r.map(t=>`$Permission.${t}`),...n],permissions:r}}function Rt(e,r={}){let n=r.maxRecordsPerObject,t=e.nodes.filter(d=>d.included),s=$e(r)?"atMost":"exact",l=t.map(d=>d.recordCountUnknown===!0?(n===void 0?s="unknown":s==="exact"&&(s="atMost"),{...d,recordCount:n??0}):{...d,recordCount:n===void 0?d.recordCount:Math.min(d.recordCount,n)}),f=new xe().generate({...e,nodes:l}).totalApiCalls,p=l.reduce((d,u)=>d+Math.max(1,Math.ceil(u.recordCount/pt)),0);return{writes:f,reads:p,bound:s}}function P(e){let{idValue:r,...n}=e;return{id:Fe(e.kind,e.objectApiName,e.field,e.recordType,r??e.value),source:"metadata",rows:0,...n}}function ue(e){return e?{field:e}:{}}function Qt(e){return async r=>Ie(await e.request({method:"POST",url:"/tooling/composite",body:JSON.stringify(qe(`/services/data/v${e.version}`,r)),headers:{"Content-Type":"application/json"}}),r.length)}async function kt(e,r,n){let t=e.filter(({id:s})=>ae.test(s));t.length!==0&&await U(r,[{queries:t.map(({id:s,rule:l})=>({soql:q(s),retrieve:{sobject:"ValidationRule",id:s},take:f=>{let p=f[0]?.Metadata,d=typeof p=="object"&&p!==null?p.errorConditionFormula:void 0;typeof d=="string"&&Ye(d)&&(l.onChangeOnly=!0)},refused:()=>{}})),requests:W}],G,n)}async function Ft(e,r,n,t,s){let l=[...new Set(r)].filter(m=>x.test(m));if(l.length===0)return[];let f=new Map(l.map(m=>[m.toLowerCase(),m])),p=new Map(l.map((m,b)=>[m,b])),d=await e(oe(l)),u=new Map,o=async(m,b)=>{let k=se(b,void 0);if(!n)return k;let F=u.get(m);F||(F=n(m).catch(()=>[]),u.set(m,F));let C=y(b).trim().toLowerCase();if(!C)return;let _=k?.toLowerCase(),S=await F;return S.length===0?k:S.find(A=>A.name.toLowerCase()===_)?.name??S.find(A=>A.label?.trim().toLowerCase()===C)?.name},h=(await Promise.all(d.map(async m=>{let b=le(m.EntityDefinition),k=b===void 0?void 0:f.get(b.toLowerCase()),F=y(m.ValidationName);return!k||!F?[]:[{id:y(m.Id),rule:{objectApiName:k,name:Q(y(m.NamespacePrefix),F),message:y(m.ErrorMessage),...ue(await o(k,m.ErrorDisplayField))}}]}))).flat().sort((m,b)=>(p.get(m.rule.objectApiName)??0)-(p.get(b.rule.objectApiName)??0)||m.rule.name.localeCompare(b.rule.name));return t&&await kt(h,t,s),h.map(({rule:m})=>m)}async function Wt(e,r,n,t){let s=[...new Set(r)].filter(a=>x.test(a));if(s.length===0)return{rules:[],notRead:0,requests:0};let l=new Map(s.map(a=>[a.toLowerCase(),a])),f=await e(oe(s)),p=f.requests,d=f.records.flatMap(a=>{let h=le(a.EntityDefinition),m=h===void 0?void 0:l.get(h.toLowerCase()),b=y(a.ValidationName);return!m||!b?[]:[{id:y(a.Id),objectApiName:m,name:Q(y(a.NamespacePrefix),b),read:!1,permissions:[]}]}),u=d.filter(a=>ae.test(a.id)),o=(a,h)=>{let m=typeof h=="object"&&h!==null?h.errorConditionFormula:void 0;typeof m=="string"&&(a.read=!0,a.permissions=rt(m).permissions)};return n?p+=await U(n,[{queries:u.slice(0,ie).map(a=>({soql:q(a.id),retrieve:{sobject:"ValidationRule",id:a.id},take:h=>o(a,h[0]?.Metadata),refused:()=>{}})),requests:W}],G,t):await B(u.slice(0,nt).map(a=>async()=>{try{let h=await e(q(a.id));p+=h.requests,o(a,h.records[0]?.Metadata)}catch{p++}}),G),{rules:d.filter(a=>a.permissions.length>0).map(({objectApiName:a,name:h,permissions:m})=>({objectApiName:a,name:h,permissions:m})),notRead:d.filter(a=>!a.read).length,requests:p}}function Kt(e,r,n){let t=async s=>(await e(ht(s))).flatMap(l=>typeof l.QualifiedApiName=="string"?[{name:l.QualifiedApiName,...typeof l.Label=="string"?{label:l.Label}:{}}]:[]);return s=>Ft(e,s,t,r,n)}var et=class{deps;constructor(r){this.deps=r}async read(r,n,t,s={}){let l=new Set(s.excludedObjects??[]),f=Qe(bt(t),l),p=[];if(f.length===0)return{gaps:[],unread:[],requests:0};let d=0,u=(i,c,g)=>{p.push({part:i,reason:c,...g!==void 0?{objectApiName:g}:{}})},o=new Map(f.map(i=>[i.toLowerCase(),i])),a=i=>i===void 0?void 0:o.get(i.toLowerCase()),h=new Map(f.map((i,c)=>[i,c])),m=f.filter(i=>x.test(i)),b=[],k=[],F,C,_=new Map,S=new Map,A=new Set,I=(i,c,g)=>async()=>{try{let w=await c();d+=w.requests,g(w.records)}catch(w){d++,u(i,E(w))}},ce=(i,c,g,w)=>async()=>{try{let{fields:J,sent:lt,createable:ut}=await this.deps.describeFields(i,c);lt&&d++,w.set(c,J),w===_&&ut===!1&&A.add(c)}catch(J){d++,u(g,`${c}: ${E(J)}`,c)}};await B([...m.length>0?[I("validationRules",()=>this.deps.toolingQuery(n,oe(m)),i=>{b=i})]:[],I("duplicateRules",()=>this.deps.query(n,yt),i=>{k=i}),async()=>{try{d++,F=await this.deps.readLimits(n)}catch(i){C=E(i)}},...f.flatMap(i=>[ce(n,i,"targetFields",_),ce(r,i,"sourceFields",S)])],G);let T=b.flatMap(i=>{let c=a(le(i.EntityDefinition)),g=y(i.ValidationName);if(!c||!g)return[];let w=y(i.Id);return[{id:ae.test(w)?w:null,name:Q(y(i.NamespacePrefix),g),objectApiName:c,...ue(se(i.ErrorDisplayField,_.get(c))),message:y(i.ErrorMessage),formula:"notRead",bypasses:[],permissions:[]}]}).sort((i,c)=>(h.get(i.objectApiName)??0)-(h.get(c.objectApiName)??0)||i.name.localeCompare(c.name)),{toolingQueries:j,toolingRetrieves:de}=this.deps,K=T.filter(i=>i.id!==null).slice(0,j?ie:nt);for(let i of T)i.id===null&&(i.formula="unreadable");let z=k.flatMap(i=>{let c=a(y(i.SobjectType)),g=Q(y(i.NamespacePrefix),y(i.DeveloperName));return!c||!y(i.DeveloperName)?[]:[{objectApiName:c,developerName:g,label:y(i.MasterLabel)||g,fullName:`${y(i.SobjectType)}.${g}`}]}),fe=new Map,pe=[];for(let i=0;i<z.length;i+=Je)pe.push(z.slice(i,i+Je).map(c=>c.fullName));let V,H,ge=(i,c)=>{let g=typeof c=="object"&&c!==null?c.errorConditionFormula:void 0;if(typeof g!="string"){i.formula="unreadable";return}i.formula="read",Object.assign(i,rt(g));let w=se(c.errorDisplayField,_.get(i.objectApiName));w&&(i.field=w)},it=async()=>{if(!j||K.length===0)return;let i=await U(c=>j(n,c),[{queries:K.map(c=>({soql:q(c.id),retrieve:{sobject:"ValidationRule",id:c.id},take:g=>ge(c,g[0]?.Metadata),refused:g=>{c.formula="unreadable",V??=g}})),requests:W}],G,de&&(c=>de(n,c)));d+=i},me=new Map,Z={},he=[...A].filter(i=>x.test(i)),ot=async()=>{let[i,c]=await Promise.all([Oe((g,w)=>this.deps.toolingQuery(g,w),n,he),this.deps.createFacts?this.deps.createFacts(n).then(g=>({facts:g,requests:0})).catch(()=>({facts:{},requests:0})):je(this.deps,n)]);d+=i.requests+c.requests;for(let[g,w]of i.answered)me.set(g,w);Z=c.facts};await B([...he.length>0?[ot]:[],...j?[it]:[],...(j?[]:K).map(i=>async()=>{try{let c=await this.deps.toolingQuery(n,q(i.id));d+=c.requests,ge(i,c.records[0]?.Metadata)}catch(c){d++,i.formula="unreadable",V??=E(c)}}),...pe.map(i=>async()=>{try{d++;for(let c of await this.deps.readDuplicateRules(n,i)){if(typeof c!="object"||c===null)continue;let g=c,w=y(g.fullName);w&&fe.set(w.toLowerCase(),g)}}catch(c){H??=E(c)}})],G),V!==void 0&&u("validationRuleFormulas",V),H!==void 0&&u("duplicateRuleActions",H);let Y=new Set,ye=!1;T.some(i=>i.permissions.length>0)&&await I("userPermissions",()=>this.deps.query(n,Le),i=>{ye=!0;for(let c of i)Y.add(Be(y(c.NamespacePrefix),y(c.DeveloperName)))})();let we=[...new Set(T.flatMap(i=>i.permissions.filter(c=>!Y.has(c.toLowerCase()))))],at=we.length>0?await We(we,async i=>{let c=[];return await I("permissionSets",()=>this.deps.query(n,i),g=>{c=g})(),c},()=>p.some(i=>i.part==="permissionSets")):void 0,be=[...T.map(i=>At(i,ye?Y:void 0,at)),...z.map(i=>Ct(i,fe.get(i.fullName.toLowerCase()))),...f.flatMap(i=>{if(A.has(i))return[_t(i,Pe(i,Z,me.get(i.toLowerCase())),_.get(i)??[],Z)];let c=_.get(i),g=S.get(i);return c&&g?St(i,c,g,s):[]})],Re=wt.safeParse(F),ke=C===void 0&&Re.success?Re.data.DailyApiRequests:void 0;return ke||u("apiBudget",C??"the limits the org answered hold no DailyApiRequests"),be.push(Et(t,s,f[0],ke)),{gaps:Ae(be),unread:vt(p,h),requests:d}}};function vt(e,r){let n=t=>t===void 0?-1:r.get(t)??r.size;return[...e].sort((t,s)=>n(t.objectApiName)-n(s.objectApiName)||Xe.indexOf(t.part)-Xe.indexOf(s.part)||(t.reason<s.reason?-1:t.reason>s.reason?1:0)).map(({part:t,reason:s})=>({part:t,reason:s}))}var Nt={platform:"object_platform_only",setup:"object_setup_only",feature:"object_feature_off",parent:"object_through_parent",user:"object_not_createable"};function _t(e,r,n,t){let s=r==="parent"?Me(n,t):[];return P({kind:Nt[r],severity:Te(r)?"info":"blocking",objectApiName:e,...s.length>0?{detail:{editOn:s}}:{},decisions:["exclude_object"]})}function At(e,r,n){let t=r?e.permissions.filter(f=>r.has(f.toLowerCase())):[],s=t.length>0?[]:e.permissions.flatMap(f=>{let p=n?.find(d=>d.permission.toLowerCase()===f.toLowerCase());return p?[Ce(p)]:[]}),l=e.field?["leave_empty","ignore"]:["ignore"];return P({kind:"validation_rule",severity:t.length>0?"info":"warning",objectApiName:e.objectApiName,...ue(e.field),idValue:e.name,detail:{rule:e.name,message:e.message,formula:e.formula,...e.bypasses.length>0?{bypasses:e.bypasses}:{},...t.length>0?{heldBypasses:t}:{},...s.length>0?{assign:s}:{}},decisions:l,...e.field?{defaultDecision:"leave_empty"}:{}})}function Ct(e,r){let n=y(r?.actionOnInsert).toLowerCase(),t=n==="block"||n==="allow"?n:"unknown",s=L(r?.operationsOnInsert).map(f=>f.toLowerCase());return P({kind:"duplicate_rule",severity:t==="allow"?"info":"warning",objectApiName:e.objectApiName,idValue:e.developerName,detail:{rule:e.label,developerName:e.developerName,action:t,...t==="allow"?{alert:s.includes("alert")}:{},...t==="allow"?{report:s.includes("report")}:{}},decisions:t==="allow"?["ignore"]:["ignore","exclude_object"],...t==="allow"?{defaultDecision:"ignore"}:{}})}function St(e,r,n,t){let s=o=>o.toLowerCase(),l=new Set((t.fieldExclusions?.[e]??[]).map(s)),f=new Map(Object.entries(t.fieldMappings?.[e]??{}).map(([o,a])=>[s(o),s(a)])),p=new Set([...f].filter(([o])=>!l.has(o)).map(([,o])=>o)),d=new Map(n.map(o=>[s(o.name),o])),u=o=>{let a=s(o);if(p.has(a))return;let h=d.get(a);return h?l.has(a)||f.has(a)?"excluded":h.createable?void 0:"notCreateableInSource":"notInSource"};return r.flatMap(o=>{let a=u(o.name);if(o.createable&&!o.nillable&&!o.defaultedOnCreate&&a)return[P({kind:"required_field_missing",severity:"blocking",objectApiName:e,field:o.name,detail:{type:o.type,reason:a,...o.referenceTo.length>0?{referenceTo:o.referenceTo}:{},...o.picklistValues.length>0?{values:o.picklistValues}:{}},decisions:["set_default","exclude_object"]})];if(o.type==="reference"&&o.lookupFilter&&!a){let h=o.nillable;return[P({kind:"lookup_filter",severity:"warning",objectApiName:e,field:o.name,detail:{referenceTo:o.referenceTo,optional:h,filterOptional:o.lookupFilter.optional},decisions:h?["leave_empty","ignore"]:["ignore","exclude_object"],...h?{defaultDecision:"leave_empty"}:{}})]}return[]})}function Et(e,r,n,t){let s=e.nodes[0]?.objectApiName??n,l=Rt(e,r),f=l.writes+l.reads,p="warning";if(t&&l.bound!=="unknown"){let d=f>t.Remaining,u=t.Max-t.Remaining+f>gt*t.Max;p=d&&l.bound==="exact"?"blocking":d||u?"warning":"info"}return P({kind:"api_budget",severity:p,objectApiName:s,detail:{calls:f,writes:l.writes,reads:l.reads,estimate:l.bound,...t?{max:t.Max,remaining:t.Remaining}:{budgetRead:!1}},decisions:["ignore"]})}var $t={blocking:"BLOCKING",warning:"warning",info:"info"},Gt=new Set(["picklist_value_refused","dependent_value_invalid","picklist_value_absent","currency_inactive"]),xt=new Set(["record_type_unmapped","record_type_unavailable"]);function st(e,r,n=[e.id]){if(ve(r.ignoredGaps,e.id,n)!==void 0)return"left as it is";let t=e.objectApiName;if(r.excludedObjects?.includes(t))return`${t} left out of the run`;let s=new Set(e.decisions),{field:l,value:f}=e;if(s.has("skip_rows")&&Ne((r.skippedRows??[]).filter(o=>o.object===t),e.id,n))return"these rows held back";if(Gt.has(e.kind)&&l!==void 0&&f!==void 0&&(s.has("map_value")||s.has("leave_empty"))){let o=(r.picklistValueMappings??[]).filter(h=>h.object===t&&h.field===l&&h.from===f),a=_e(o,e,n);if(a?.to===null&&s.has("leave_empty"))return"the field left empty in these rows";if(a&&a.to!==null&&s.has("map_value"))return`written as "${a.to}"`}let p=xt.has(e.kind)?e.value??e.recordType:void 0;if(p!==void 0&&s.has("map_record_type")){let o=r.recordTypeMappings?.find(a=>a.object===t&&a.from===p);if(o)return o.to===null?"written with the object's default record type":`written as record type ${o.to}`}if(l===void 0)return;let d=o=>o.object===t&&o.field===l,u=s.has("set_default")?r.defaultValues?.find(d):void 0;if(u)return`default "${String(u.value)}"`;if(s.has("truncate")&&r.truncateFields?.some(d))return"cut to the field's length";if(s.has("leave_empty")&&r.fieldExclusions?.[t]?.includes(l))return"the field left out of the rows"}function zt(e,r){let n=e.gaps.map(t=>t.id);return{...e,gaps:e.gaps.map(t=>{let s=st(t,r,n);return s===void 0?t:{...t,answeredBy:s}})}}function tt(e,r,n,t){if(t)return`the mute lifts it (${t.permission}, in ${t.permissionSet}): ${re(e,!0)}`;let s=r?st(e,r,n):void 0;return s===void 0?`${$t[e.severity]}: ${re(e)}`:`answered by the run's decision: ${s} \u2014 ${re(e)}`}var Pt={validationRules:"the validation rules",validationRuleFormulas:"the formulas of some validation rules",duplicateRules:"the duplicate rules",duplicateRuleActions:"what the duplicate rules do on insert",userPermissions:"the custom permissions of the user the run writes as",permissionSets:"the permission sets that hold a bypass of a validation rule the user the run writes as does not",targetFields:"the fields of an object in the target",sourceFields:"the fields of an object in the source",apiBudget:"the daily API requests left"},Tt={notInSource:"the source has no such field",notCreateableInSource:"the source cannot give it",excluded:"the run leaves it out"},D=e=>typeof e=="number"?String(e):"?";function re(e,r=!1){let n=e.detail??{};switch(e.kind){case"required_field_missing":return`required field ${e.field??""} (${y(n.type)}): only the target requires it, and the run does not write it (${Tt[y(n.reason)]??y(n.reason)}): every row is refused unless it is given a value`;case"validation_rule":{let t=e.field?` on ${e.field}`:"",s=[...L(n.bypasses).map(f=>`not when ${f}`),...L(n.heldBypasses).length>0?[`kept quiet for this run: the user it writes as holds ${L(n.heldBypasses).join(", ")}`]:[],...n.formula==="notRead"?["formula not read"]:[],...n.formula==="unreadable"?["formula unreadable"]:[],...e.field&&!r?[`a row it refuses goes again without ${e.field}`]:[]],l=y(n.message)?`: "${y(n.message)}"`:"";return`validation rule "${y(n.rule)}"${t}${l}${s.length>0?` (${s.join("; ")})`:""}`}case"duplicate_rule":{let t=`duplicate rule "${y(n.rule)}"`;if(n.action==="block")return`${t}: blocks an insert it matches: a row it matches is refused, whatever allowSave says`;if(n.action==="allow"){let s=[n.alert===!0?"an alert":"",n.report===!0?"a report":""].filter(Boolean).join(" and ");return`${t}: allows an insert it matches${s?`, with ${s}`:""}: the run saves it (allowSave=true)`}return`${t}: what it does on insert was not read: a rule that blocks refuses a row it matches`}case"lookup_filter":return`lookup filter on ${e.field??""}: not checked before the run; `+(n.optional===!0?"a lookup it refuses is left empty":"the lookup is required, and a row it refuses is refused");case"object_not_createable":return"the user the run writes as may not create its records in the target: every row is skipped, after the objects written before it, unless the object is left out";case"object_platform_only":return"no user can create its records in the target, the platform writes them itself: the run skips every row of it";case"object_setup_only":return"no user can create its records in the target, not even one with Modify All Data, and no permission set gives Create on it: setup the org keeps as records, or the platform's own; the run skips every row of it";case"object_feature_off":return"even a user with Modify All Data may not create its records in the target, though a permission set can give Create on it: a feature or licence the target has not turned on for that user keeps it closed; turn it on, or every row is skipped, after the objects written before it, unless the object is left out";case"object_through_parent":{let t=L(n.editOn);return`no permission set gives Create on it: ${t.length>0?`the user the run writes as creates its records with Edit on ${t.join(" and ")}, which they hang from, or no user can`:"the records they hang from may open it to the user the run writes as, or no user can: read as a user with Modify All Data, the target would tell"}; every row is skipped, after the objects written before it, unless the object is left out`}case"api_budget":{let t=`about ${D(n.calls)} call(s) (${D(n.writes)} write(s) of 200 rows, ${D(n.reads)} read(s))`,s=n.estimate==="atMost"?`at most ${t}, counted on whole tables`:n.estimate==="unknown"?"an unknown number of calls: an object was never counted":t,l=n.budgetRead===!1?"the daily requests left could not be read":`${D(n.remaining)} of ${D(n.max)} daily requests left`;return`API budget: the run takes ${s}; ${l}`}default:return e.kind}}function jt(e,r,n){return Se(e).map(({permission:t,permissionSet:s,others:l})=>{if(!s)return` ${t}: no permission set of ${r} holds it: an admin creates one that includes it`;let f=l.length>0?`; also held by ${l.map(d=>d.name).join(", ")}`:"",p=n?`: ${Ge(s.name,r,n)}`:"";return` ${t}: held by permission set ${s.name}, the smallest${f}${p}`})}function Ht(e,r,n={}){let t=[`target gaps: what ${r} holds against the rows, read from its metadata`],s=e.gaps.map(u=>u.id),l=e.gaps.filter(u=>u.kind==="api_budget"),f=e.gaps.filter(u=>u.kind!=="api_budget"),p=[...new Set(f.map(u=>u.objectApiName))].sort((u,o)=>u.localeCompare(o));for(let u of p){t.push(` ${u}`);for(let o of f.filter(a=>a.objectApiName===u)){let a=Ee(o,n.lifted);t.push(` ${tt(o,n.decisions,s,a)}`),a||t.push(...jt(o,r,n.username))}}f.length===0&&t.push(e.unread.length>0?" nothing found in what could be read":" no validation rule, duplicate rule, field only the target requires or lookup filter");for(let u of l)t.push(` ${tt(u,n.decisions,s)}`);let d=f.filter(u=>u.detail?.formula==="notRead").length;d>0&&t.push(` ${d} validation rule formula(s) not read: the read takes ${n.formulasBound??ie} at most`);for(let{part:u,reason:o}of e.unread)t.push(` ${Pt[u]??u} could not be read: ${o}`);return t.push(` read in ${e.requests} request(s) to ${r}`),t}export{nt as a,W as b,ie as c,Bt as d,oe as e,ht as f,q as g,yt as h,rt as i,Rt as j,Qt as k,Ft as l,Wt as m,Kt as n,et as o,st as p,zt as q,Ht as r};
|
|
@@ -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{d as f}from"./chunk-
|
|
7
|
+
import{d as f}from"./chunk-ZV7ZFQQC.mjs";import{mb as i,nb as d}from"./chunk-PMWAFDUB.mjs";import{m as u,z as c}from"./chunk-WZQEK4WT.mjs";function w(e){let s=new Set,r=new Set;for(let t of e)for(let n of t.users){let o=i(n.applied.username);s.has(o)||(s.add(o),n.applied.address==="awaiting"&&r.add(o))}return r}function v(e,s){return e.map(r=>({username:r.username,userId:r.userId,address:r.address==="valid"?"restored":s.has(i(r.username))?"awaiting":"invalid",active:r.active,frozen:r.frozen,...r.profile!==void 0?{profile:r.profile}:{}}))}var l="recovery";function O(e,s){return e!==void 0?`recoveryTesters:host:${e}`:`recoveryTesters:entry:${s}`}var g=u({config:d,savedAt:c.datetime({offset:!0})});function A(e,s){let r=g.safeParse(e.get(s));return r.success?r.data:void 0}function P(e,s,r,t){let n={config:r,savedAt:t.toISOString()};return e.set(s,n,l),n}var m="USERS_RUN_NOT_FOUND",U="USERS_RUN_REPLACED";async function x(e,s,r){let t=await e.read(s,r);if(!t)return{refusal:{code:m,message:`Run ${r} is not kept on this machine for this org, whose Organization Id is ${s}: a sandbox refreshed since answers another, and its runs went with the copy they set up. Simulate without it to set the users up anew.`}};let n=(await e.list(s)).find(o=>o.replaces===r);return n?{refusal:{code:U,message:`Run ${r} was replaced by run ${n.run}, which holds what it set up: simulate again, replacing run ${n.run}.`}}:{record:t}}function C(e){return JSON.stringify([e.orgId,e.config,e.replaces??null,e.acceptUserEmails,e.acceptEmails,e.acceptAutomation])}function T(e){return JSON.stringify({org:e.org.organizationId,users:e.users.map(s=>[s.username,s.userId??null,s.address??null,s.changes,s.emailsToPeople??0]),licenses:(e.licenses??[]).map(s=>[s.name,s.toUse]),emailsToPeople:e.emailsToPeople,refusals:(e.refusals??[]).map(s=>[s.code,s.username??null])})}function b(e){return e.users.filter(s=>s.changes.length>0).length}function E(e,s){let r=new Map(s.users.filter(n=>n.changes.length>0).map(n=>[i(n.username),n.changes.length])),t=0;for(let n of e.users){let o=r.get(i(n.applied.username));if(o===void 0)continue;n.applied.done.length+(n.applied.refused?.length??0)>=o&&(t+=1)}return t}function a(e){return e.what==="frozen"?"UserLogin":e.what==="group"?"GroupMember":e.what==="permissionSet"||e.what==="permissionSetGroup"?"PermissionSetAssignment":"User"}function j(e){let s=new Map(["User","UserLogin","PermissionSetAssignment","GroupMember"].map(t=>[t,{objectApiName:t,created:0,updated:0,deleted:0,failed:0}])),r=t=>s.get(t);for(let t of e.users){let n=new Set(t.done.filter(o=>!("name"in o)).map(o=>a(o)));for(let o of n)r(o).updated+=1;r("PermissionSetAssignment").created+=t.created.permissionSetAssignments.length,r("GroupMember").created+=t.created.groupMembers.length;for(let o of t.done)"name"in o&&o.to==="removed"&&(r(a(o)).deleted+=1);for(let o of t.refused??[])r(a(o.change)).failed+=1}return[...s.values()].filter(t=>t.created+t.updated+t.deleted+t.failed>0)}var p=class extends f{constructor(r,t){super(r);this.onWrite=t}onWrite;async write(r){await super.write(r),this.onWrite(r)}};export{w as a,v as b,l as c,O as d,g as e,A as f,P as g,m as h,U as i,x as j,C as k,T as l,b as m,E as n,j as o,p};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{h as a,i as b,j as c,k as d,l as e}from"./chunk-
|
|
7
|
+
import{h as a,i as b,j as c,k as d,l as e}from"./chunk-LA4KIATH.mjs";import"./chunk-Y2DRK37K.mjs";import"./chunk-UV74P4H2.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-KGU4SVIT.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-S42RBRH2.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as REPLAY_RECORD_FILE,c as ReplayStore,b as defaultReplayStoreRoot,d as replaysInPlace,e as replaysInPlaceWords};
|
|
@@ -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{i as g,n as p,o as m}from"./chunk-
|
|
7
|
+
import{i as g,n as p,o as m}from"./chunk-MSIEU5MR.mjs";import{a as b,b as I}from"./chunk-MS4FJDFD.mjs";import{c as w}from"./chunk-LCDPCUXS.mjs";import{bd as l,p as d,q as u}from"./chunk-PMWAFDUB.mjs";import{A as c}from"./chunk-WZQEK4WT.mjs";import{d as f}from"./chunk-NTOVCTRS.mjs";var a=class extends Error{constructor(t,n){super(`${n} Nothing was read from ${t}.`);this.alias=t;this.reason=n;this.name="SfSessionError",this.stack=this.message}alias;reason},$=c.object({name:c.string().optional(),message:c.string().optional()}).loose();function h(e){if(typeof e!="string")return;let r=e.replace(/\u001b\[[0-9;]*m/g,""),t=r.indexOf("{");if(t!==-1)try{let n=$.safeParse(JSON.parse(r.slice(t)));return n.success?n.data:void 0}catch{return}}function C(e,r=process.platform){let t=typeof e=="object"&&e!==null?e:{};return t.code==="ENOENT"?!0:r==="win32"&&(t.status===9009||/is not recognized as an internal or external command/i.test(String(t.stderr??"")))}function S(e,r,t=process.platform){if(C(r,t))return new a(e,`${d} SandForge reads each org through the Salesforce CLI: install it with "npm install -g @salesforce/cli" (${u}), sign in to the org with "sf org login web --alias ${e}", and run again.`);let n=typeof r=="object"&&r!==null?r:{},o=h(n.stdout)??h(n.stderr);if(o?.name==="NamedOrgNotFoundError"||/^No authorization information found for /.test(o?.message??""))return new a(e,`sf does not know ${e}: "sf org list" names the orgs it knows; "sf org login web --alias ${e}" adds it (in a CI job, "sf org login jwt" or "sf org login sfdx-url").`);let s=typeof n.stderr=="string"?n.stderr.split(/\r?\n/).find(y=>y.trim()!==""):void 0,i=o?.message?.trim()||s?.trim()||(r instanceof Error?r.message:String(r));return new a(e,`sf could not show ${e}: ${i}`)}var k=f(I()),x=f(b());import{execFileSync as E}from"node:child_process";function T(e){try{return E("sf",["org","display","--target-org",e,"--json"],{encoding:"utf8",maxBuffer:50*1024*1024,shell:process.platform==="win32"})}catch(r){throw S(e,r)}}async function A(e,r=m){if(!w.test(e))throw new Error(`Invalid SF org alias: "${e}" (an alias or a username: letters, digits, _ . @ + and -, not starting with . @ + or -)`);let t=T(e),n=JSON.parse(t),o=n.result;if(typeof o?.devHubId=="string"&&o.devHubId!==""){let i=typeof o.expirationDate=="string"?l({orgType:"Scratch",metadata:{expirationDate:o.expirationDate}},new Date().toISOString().slice(0,10)):void 0;if(i!==void 0||o.status==="Deleted")throw new Error(`The scratch org '${e}' ${i!==void 0?`expired on ${i}`:"is deleted"}: Salesforce deletes a scratch org when it expires, and no sign-in brings it back. Create a new one ("sf org create scratch") and give its alias.`)}if(!n.result?.instanceUrl)throw new Error(`sf org display did not return a usable session for alias '${e}'.`);let s=await r(e);if(!p(s.accessToken))throw new Error(`The Salesforce CLI showed no usable access token for alias '${e}'. Sign in again with "sf org login web --alias ${e}" where a browser opens; in a CI job, with "sf org login jwt --alias ${e}" (a client id, a key file and a username) or "sf org login sfdx-url --alias ${e} --sfdx-url-file <file>" (see ci-examples/README.md).`);return{alias:e,username:n.result.username??"",instanceUrl:s.instanceUrl??n.result.instanceUrl,accessToken:s.accessToken,...typeof n.result.id=="string"&&n.result.id!==""?{orgId:n.result.id}:{},...typeof n.result.devHubId=="string"&&n.result.devHubId!==""?{scratch:!0}:{}}}function H(e,r=process.env){let t=g(e.instanceUrl,r),n=new k.default.Connection({instanceUrl:e.instanceUrl,accessToken:e.accessToken,version:"66.0",...t!==void 0?{httpProxy:t}:{}});return t===void 0&&(n._transport=new x.HttpProxyTransport("")),n}export{a,A as b,H as c};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r}from"./chunk-HIDW7FNV.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-LC3NDW4N.mjs";import"./chunk-KB4ZHM4Q.mjs";import"./chunk-23SEDORH.mjs";import"./chunk-W6PN6TJG.mjs";import"./chunk-3Q353S2R.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-RHNTHGNU.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-Q7TLC3I2.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-D4GF4FAB.mjs";import"./chunk-CVHNXJH3.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-M6K34KGF.mjs";import"./chunk-TNT27RBG.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-S42RBRH2.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-PMWAFDUB.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{p as actDeliverability,o as actEmailsGate,n as actSendersOf,q as afterLeaseEmailsRefusal,l as checkpointEmails,j as checkpointEmailsUncounted,c as draftedByDiff,d as draftedByPlan,a as emailsOfLimit,m as emailsRefusal,k as emailsUncountedWords,r as pageEmailsRefusal,e as statusBackByDiff,f as statusBackByPlan,b as updatedByDiff,g as writtenByDiff,h as writtenByPlan,i as writtenByUndo};
|
|
@@ -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,Jc as v,Ub as k,e as m,ec as j,f as h,i as $,j as y}from"./chunk-
|
|
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-PMWAFDUB.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};
|
|
@@ -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{i as u,j as f}from"./chunk-
|
|
7
|
+
import{i as u,j as f}from"./chunk-PMWAFDUB.mjs";var p=1e4,g=150,m=200,l=class{build(o){let t=o.relations??[],c=j(o.objects,t),i=S(c),r=b(c),n=r*g,s=i>p;return{objects:c.map(a=>({objectApiName:a.objectApiName,recordCount:a.recordCount,sampleRecords:C(a,3,u(a.objectApiName,t)),dependsOn:f(a,t)})),totalRecords:i,estimatedApiCalls:r,estimatedDuration:n,grappeRecommended:s}}};function S(e){return e.reduce((o,t)=>o+t.recordCount,0)}function b(e){return e.reduce((o,t)=>{let c=t.batchSize>0?t.batchSize:m;return o+Math.ceil(t.recordCount/c)},0)}function C(e,o,t){let c=Math.min(o,e.recordCount),i=[];for(let r=0;r<c;r++){let n={};for(let d of e.fieldRules)n[d.fieldApiName]=R(d,r);let s=e.rows?.[r];s&&(Object.assign(n,s.values),t?.distribution.mode==="byKey"&&s.parentKey!==void 0&&(n[t.lookupField]=`[key:${s.parentKey}]`)),i.push(n)}return i}function R(e,o){switch(e.ruleType){case"static":return e.config.staticValue??null;case"sequence":{let t=e.config.sequenceStart??1,c=e.config.sequenceStep??1;return`${e.config.sequencePrefix??""}${t+o*c}`}case"picklist_random":return e.config.picklistValues&&e.config.picklistValues.length>0?e.config.picklistValues[o%e.config.picklistValues.length]:null;case"reference":return`[ref:${e.config.referenceObject??"unknown"}]`;case"faker":return`[faker:${e.config.fakerMethod??"lorem"}]`;case"ai_generate":return`[ai:${e.config.aiPrompt??"generated"}]`;case"random":return`sample_${o}`;case"formula":return`[formula:${e.config.formula??""}]`;case"regex":return`[regex:${e.config.regexPattern??""}]`;case"from_csv":return`[csv:${e.config.csvColumn??""}]`;default:return null}}function j(e,o=[]){let t=new Map;for(let n of e)t.set(n.objectApiName,n);let c=new Set,i=[];function r(n){if(c.has(n))return;c.add(n);let s=t.get(n);if(!s)return;let d=f(s,o);for(let a of d)r(a);i.push(s)}for(let n of e)r(n.objectApiName);return i}export{l as a,j as b};
|