sandforge 1.80.0 → 1.81.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/sandforge-pipeline.mjs +12 -0
- package/lib/{chunk-EMNC6YI4.mjs → chunk-2IB7I3IQ.mjs} +1 -1
- package/lib/{chunk-3RZQZHEB.mjs → chunk-2NAIUKVL.mjs} +1 -1
- package/lib/{chunk-AEKONPF4.mjs → chunk-2OIRJEYE.mjs} +1 -1
- package/lib/{chunk-BV6VTP3J.mjs → chunk-2OZG6GRW.mjs} +1 -1
- package/lib/{chunk-JEERQRLW.mjs → chunk-2Z54GB6X.mjs} +1 -1
- package/lib/chunk-2ZMGVBLW.mjs +7 -0
- package/lib/{chunk-FKG7Q3WH.mjs → chunk-33ZX3A56.mjs} +1 -1
- package/lib/{chunk-HLWMJF6Y.mjs → chunk-3AOKLIVE.mjs} +1 -1
- package/lib/{chunk-GGD7ON3M.mjs → chunk-3B5H24ZG.mjs} +1 -1
- package/lib/chunk-43K2C6H2.mjs +7 -0
- package/lib/chunk-4JKR4PTZ.mjs +8 -0
- package/lib/chunk-4L7FBOJS.mjs +8 -0
- package/lib/chunk-5344TZBT.mjs +11 -0
- package/lib/{chunk-SAR5622P.mjs → chunk-54HYHHVL.mjs} +1 -1
- package/lib/chunk-55LQD3Y3.mjs +7 -0
- package/lib/chunk-56MPPWLA.mjs +7 -0
- package/lib/chunk-5C5XEVZN.mjs +11 -0
- package/lib/chunk-5CKWGZX4.mjs +9 -0
- package/lib/{chunk-RSWDYIHY.mjs → chunk-5GBO4KD5.mjs} +1 -1
- package/lib/{chunk-BKDV4ENO.mjs → chunk-5UT2ZBGF.mjs} +1 -1
- package/lib/chunk-5VQNKDFU.mjs +7 -0
- package/lib/{chunk-XAMBCQPU.mjs → chunk-5WGA5CZB.mjs} +1 -1
- package/lib/chunk-5ZKCLBTN.mjs +474 -0
- package/lib/{chunk-UCD54V2M.mjs → chunk-67CC7RAE.mjs} +1 -1
- package/lib/{chunk-TSLJUSLW.mjs → chunk-6CDIIFNX.mjs} +1 -1
- package/lib/{chunk-AV5SWEHP.mjs → chunk-6FARZYMJ.mjs} +1 -1
- package/lib/{chunk-FPKYYFM7.mjs → chunk-6FMLW7PH.mjs} +1 -1
- package/lib/chunk-6IGEASOF.mjs +7 -0
- package/lib/{chunk-XUWL6ZPC.mjs → chunk-6NADW3OI.mjs} +1 -1
- package/lib/chunk-6SEDOIO3.mjs +10 -0
- package/lib/{chunk-PJ5I73CK.mjs → chunk-742SSN7I.mjs} +1 -1
- package/lib/chunk-7DALDJMO.mjs +7 -0
- package/lib/chunk-7PK5QDQI.mjs +7 -0
- package/lib/chunk-AELFEK3G.mjs +7 -0
- package/lib/chunk-AITNZWLB.mjs +9 -0
- package/lib/{chunk-2UZPIMUC.mjs → chunk-AJPSGVMD.mjs} +1 -1
- package/lib/{chunk-GSKCGQIP.mjs → chunk-BNO5GIJ6.mjs} +1 -1
- package/lib/{chunk-K2FBZIXY.mjs → chunk-BWWQXU2B.mjs} +1 -1
- package/lib/{chunk-IC2C2GOF.mjs → chunk-BXZ73A5M.mjs} +1 -1
- package/lib/chunk-BZFIOZS3.mjs +156 -0
- package/lib/{chunk-J525F5KI.mjs → chunk-C4YGSK6W.mjs} +1 -1
- package/lib/chunk-CAFUNR6D.mjs +7 -0
- package/lib/chunk-CULAOP3U.mjs +7 -0
- package/lib/chunk-D62KWDDT.mjs +7 -0
- package/lib/{chunk-OHWNPXWW.mjs → chunk-D7P7DTWL.mjs} +1 -1
- package/lib/{chunk-COFG7Q6R.mjs → chunk-DHGPDSXS.mjs} +1 -1
- package/lib/{chunk-WU3GLFZO.mjs → chunk-DHIW4IO5.mjs} +1 -1
- package/lib/{chunk-6XYKJSGX.mjs → chunk-DMBR24CK.mjs} +1 -1
- package/lib/chunk-DPYTG6DM.mjs +48 -0
- package/lib/{chunk-BY2HJFFG.mjs → chunk-DQR5NDMI.mjs} +1 -1
- package/lib/chunk-DXOXLUZA.mjs +7 -0
- package/lib/{chunk-YRQGKDHM.mjs → chunk-E2OBAWSH.mjs} +1 -1
- package/lib/chunk-E2YJVSX6.mjs +10 -0
- package/lib/{chunk-JWTSEDIQ.mjs → chunk-EAFLDSQ2.mjs} +1 -1
- package/lib/{chunk-MILU7WFN.mjs → chunk-EH5YUA5W.mjs} +1 -1
- package/lib/{chunk-BGUEWRK2.mjs → chunk-EOSEMFPU.mjs} +1 -1
- package/lib/chunk-ETT5GP4P.mjs +13 -0
- package/lib/{chunk-MYW5QNGI.mjs → chunk-FDGFUEK3.mjs} +1 -1
- package/lib/{chunk-NTFIRZP6.mjs → chunk-FLNLG43R.mjs} +1 -1
- package/lib/{chunk-CHYDMRSV.mjs → chunk-FSDO4DJA.mjs} +1 -1
- package/lib/{chunk-MJVTDA5Q.mjs → chunk-FSZTXLNW.mjs} +1 -1
- package/lib/{chunk-SOU4FRYN.mjs → chunk-FTA5LOVX.mjs} +1 -1
- package/lib/chunk-G4VXPS3A.mjs +7 -0
- package/lib/chunk-GF247DA7.mjs +7 -0
- package/lib/{chunk-BTWDMNN3.mjs → chunk-GK7VEYFM.mjs} +1 -1
- package/lib/{chunk-SE4QEZUG.mjs → chunk-GR3NGDVM.mjs} +1 -1
- package/lib/{chunk-3TJON4F3.mjs → chunk-GTIXJCGS.mjs} +1 -1
- package/lib/{chunk-NZC67CGR.mjs → chunk-GWRKS3AL.mjs} +1 -1
- package/lib/{chunk-XLXIPIEW.mjs → chunk-GYKNCYES.mjs} +1 -1
- package/lib/{chunk-WIO4XO4F.mjs → chunk-HFSBDM7B.mjs} +1 -1
- package/lib/{chunk-KDGMAGQR.mjs → chunk-HVC5CYIB.mjs} +1 -1
- package/lib/{chunk-WR4Q363I.mjs → chunk-HYBH5PFM.mjs} +1 -1
- package/lib/chunk-HYOOJVR6.mjs +7 -0
- package/lib/{chunk-5K5VLULK.mjs → chunk-IBURU7T7.mjs} +1 -1
- package/lib/chunk-ICIYL45C.mjs +7 -0
- package/lib/{chunk-QR3WELJQ.mjs → chunk-IKGHRYCN.mjs} +1 -1
- package/lib/chunk-IM2XA6JI.mjs +7 -0
- package/lib/{chunk-IWDREM66.mjs → chunk-J6G23RUI.mjs} +1 -1
- package/lib/{chunk-2BA2XKAY.mjs → chunk-JU2XEKEO.mjs} +1 -1
- package/lib/{chunk-MHMH6MTP.mjs → chunk-K55LH4ZQ.mjs} +1 -1
- package/lib/chunk-K5HV4YRO.mjs +7 -0
- package/lib/{chunk-M3ROUWDX.mjs → chunk-K77NR3UK.mjs} +1 -1
- package/lib/chunk-KE2PGD6C.mjs +7 -0
- package/lib/chunk-KGYXLSQ5.mjs +37 -0
- package/lib/{chunk-E5AHXLS6.mjs → chunk-KNIRA333.mjs} +1 -1
- package/lib/chunk-KOQV4WXC.mjs +8 -0
- package/lib/{chunk-L77FJZEP.mjs → chunk-KRNFVAGC.mjs} +1 -1
- package/lib/{chunk-MTMH6H2A.mjs → chunk-LCDPCUXS.mjs} +1 -1
- package/lib/{chunk-YAZO75G2.mjs → chunk-LNXBCE7E.mjs} +1 -1
- package/lib/{chunk-IZQZ6ZUF.mjs → chunk-LO527YLT.mjs} +1 -1
- package/lib/chunk-MAHZMPMZ.mjs +7 -0
- package/lib/{chunk-F6GUDTOB.mjs → chunk-MHW6DV6T.mjs} +1 -1
- package/lib/{chunk-2YIV2OB2.mjs → chunk-MIDBQ7SD.mjs} +1 -1
- package/lib/{chunk-FGRG7ANU.mjs → chunk-MKNAZPOT.mjs} +1 -1
- package/lib/{chunk-PZPJKATS.mjs → chunk-MNITSYI2.mjs} +8 -8
- package/lib/{chunk-OLSGVAIL.mjs → chunk-MO3N5XVV.mjs} +53 -53
- package/lib/chunk-MWLFFVQV.mjs +8 -0
- package/lib/chunk-N6HHNR6J.mjs +7 -0
- package/lib/chunk-N7J6NJQ6.mjs +7 -0
- package/lib/chunk-NJ3EOEHS.mjs +9 -0
- package/lib/chunk-NWPQF5XR.mjs +7 -0
- package/lib/{chunk-IG2MTQRP.mjs → chunk-NWVVCZUK.mjs} +1 -1
- package/lib/{chunk-2NBYT7GR.mjs → chunk-O6ADMP36.mjs} +1 -1
- package/lib/chunk-O7DAFE6M.mjs +14 -0
- package/lib/chunk-OEHVAJAB.mjs +7 -0
- package/lib/chunk-OETEC3P7.mjs +7 -0
- package/lib/{chunk-GCOB7K5N.mjs → chunk-OHEOJISY.mjs} +1 -1
- package/lib/chunk-OIIL4NVI.mjs +7 -0
- package/lib/chunk-OMZJ37JI.mjs +15 -0
- package/lib/{chunk-CEX3NEZL.mjs → chunk-ONMBSACW.mjs} +1 -1
- package/lib/chunk-OQQHNYR7.mjs +272 -0
- package/lib/{chunk-SOGQW4IG.mjs → chunk-OU5W7SCB.mjs} +1 -1
- package/lib/{chunk-O2HDYYUV.mjs → chunk-OVOLG3AL.mjs} +1 -1
- package/lib/{chunk-DYFALGRT.mjs → chunk-OXKZ4Y3B.mjs} +1 -1
- package/lib/{chunk-2GTBABKU.mjs → chunk-OZNLOV4U.mjs} +1 -1
- package/lib/{chunk-TYYOBZMU.mjs → chunk-PC247GKX.mjs} +1 -1
- package/lib/chunk-PPGDAUEQ.mjs +7 -0
- package/lib/{chunk-IGYH7GMA.mjs → chunk-PYUEHBA6.mjs} +1 -1
- package/lib/{chunk-TLH7AD35.mjs → chunk-PZBZ7MNC.mjs} +1 -1
- package/lib/{chunk-DBFJB2B6.mjs → chunk-QIRO4HTE.mjs} +1 -1
- package/lib/{chunk-BXU6WFMH.mjs → chunk-QXLZINZB.mjs} +1 -1
- package/lib/chunk-R2BJWO5N.mjs +20 -0
- package/lib/chunk-R6TF26V4.mjs +10 -0
- package/lib/{chunk-YKKRIEH4.mjs → chunk-RKALOKAU.mjs} +1 -1
- package/lib/chunk-SQGP46QS.mjs +7 -0
- package/lib/chunk-SW2NUKQL.mjs +9 -0
- package/lib/{chunk-MFG4MUIO.mjs → chunk-T26C576X.mjs} +1 -1
- package/lib/{chunk-LKQ5RKIV.mjs → chunk-T3PLRQ2T.mjs} +1 -1
- package/lib/chunk-T5VAULLQ.mjs +7 -0
- package/lib/{chunk-KYEDBS54.mjs → chunk-TEIBWMJM.mjs} +1 -1
- package/lib/chunk-TKQQVB2D.mjs +9 -0
- package/lib/{chunk-ELFXJHU7.mjs → chunk-TPHXRHOA.mjs} +1 -1
- package/lib/chunk-TQ2TQHTT.mjs +9 -0
- package/lib/{chunk-RPI7LRTW.mjs → chunk-TQM2XJ27.mjs} +1 -1
- package/lib/{chunk-IOIWJ3DJ.mjs → chunk-UCHAZ4ZU.mjs} +1 -1
- package/lib/{chunk-G35N4P7D.mjs → chunk-UIUPPEFB.mjs} +1 -1
- package/lib/{chunk-DBB3EMIN.mjs → chunk-UT27HXE7.mjs} +1 -1
- package/lib/{chunk-KBJ5VERV.mjs → chunk-UUSLTW5V.mjs} +1 -1
- package/lib/chunk-V2QO6KOE.mjs +19 -0
- package/lib/chunk-V473C7LY.mjs +7 -0
- package/lib/chunk-V4RKM4QZ.mjs +8 -0
- package/lib/chunk-VSU74RQ3.mjs +9 -0
- package/lib/chunk-VV3B6IC3.mjs +7 -0
- package/lib/chunk-W2AAGIZF.mjs +7 -0
- package/lib/{chunk-WR2GIKWE.mjs → chunk-WB2RIVO3.mjs} +1 -1
- package/lib/chunk-WD47PGUS.mjs +10 -0
- package/lib/{chunk-HEKAZJRH.mjs → chunk-WEZLXE34.mjs} +1 -1
- package/lib/{chunk-W622GUAW.mjs → chunk-WI4HYWV6.mjs} +1 -1
- package/lib/{chunk-WA7EYLAQ.mjs → chunk-WM5JI4JI.mjs} +1 -1
- package/lib/chunk-WWTXRWNZ.mjs +7 -0
- package/lib/{chunk-7EANH5PY.mjs → chunk-WZQEK4WT.mjs} +1 -1
- package/lib/{chunk-FXXLX4O6.mjs → chunk-X2ZVSQ54.mjs} +1 -1
- package/lib/{chunk-ZVAED4QV.mjs → chunk-XC2QKQT5.mjs} +1 -1
- package/lib/chunk-XC54KKKC.mjs +7 -0
- package/lib/chunk-XEB6HZ34.mjs +7 -0
- package/lib/chunk-XGKSSCW7.mjs +7 -0
- package/lib/chunk-XIZ5LMQM.mjs +7 -0
- package/lib/{chunk-74Q6DORA.mjs → chunk-Y5ZCPY36.mjs} +1 -1
- package/lib/{chunk-UNJA4J37.mjs → chunk-YCSFP6ER.mjs} +4 -4
- package/lib/{chunk-X5JYBPXP.mjs → chunk-YHIOS2PU.mjs} +1 -1
- package/lib/chunk-YIGFYZQY.mjs +7 -0
- package/lib/chunk-YJEXE6HZ.mjs +925 -0
- package/lib/{chunk-TTKXMDBN.mjs → chunk-YOGMP72T.mjs} +4 -4
- package/lib/chunk-ZRUDYB7O.mjs +7 -0
- package/lib/{chunk-CU2INBND.mjs → chunk-ZUA5BNAO.mjs} +1 -1
- package/lib/chunk-ZWCRWF7E.mjs +7 -0
- package/lib/{chunk-N652NMZ4.mjs → chunk-ZWZXQTAK.mjs} +52 -52
- package/lib/sandforge-autopilot.mjs +11 -11
- package/lib/sandforge-backup.mjs +63 -32
- package/lib/sandforge-checkpoint.mjs +1 -348
- package/lib/sandforge-cleanup.mjs +1 -1
- package/lib/sandforge-clone.mjs +1 -1
- package/lib/sandforge-compare.mjs +1 -1
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +11 -11
- package/lib/sandforge-env.mjs +104 -104
- package/lib/sandforge-frozen.mjs +1 -266
- package/lib/sandforge-mcp.mjs +33 -14
- package/lib/sandforge-monitor.mjs +1 -1
- package/lib/sandforge-pipeline.mjs +88 -0
- package/lib/sandforge-seed.mjs +1 -1
- package/lib/sandforge-sync.mjs +1 -1
- package/lib/sandforge.mjs +6 -6
- package/package.json +2 -1
- package/lib/chunk-2CNCDM56.mjs +0 -7
- package/lib/chunk-3F6Q5E7I.mjs +0 -14
- package/lib/chunk-4VS2V6WU.mjs +0 -25
- package/lib/chunk-5P4PHJRL.mjs +0 -9
- package/lib/chunk-5TC3QB4U.mjs +0 -10
- package/lib/chunk-7ABODJ4G.mjs +0 -7
- package/lib/chunk-7EGQP6S4.mjs +0 -7
- package/lib/chunk-7FFGJWHN.mjs +0 -7
- package/lib/chunk-7YDNUBO5.mjs +0 -7
- package/lib/chunk-A527W53V.mjs +0 -7
- package/lib/chunk-ADOAS63R.mjs +0 -7
- package/lib/chunk-B5QQJ4SI.mjs +0 -7
- package/lib/chunk-CION3VMZ.mjs +0 -7
- package/lib/chunk-CSBS5U5I.mjs +0 -7
- package/lib/chunk-DB7RBE5D.mjs +0 -7
- package/lib/chunk-E5ZB3LU5.mjs +0 -7
- package/lib/chunk-EFR2Y7E4.mjs +0 -7
- package/lib/chunk-EHQ3FX6X.mjs +0 -7
- package/lib/chunk-EQNW3UC2.mjs +0 -7
- package/lib/chunk-F43REJDZ.mjs +0 -10
- package/lib/chunk-GSG7WZHM.mjs +0 -7
- package/lib/chunk-HOJYWTP7.mjs +0 -20
- package/lib/chunk-HS4YRX4J.mjs +0 -7
- package/lib/chunk-I7O6C2B5.mjs +0 -8
- package/lib/chunk-IFETCRWE.mjs +0 -10
- package/lib/chunk-IQXHJEYB.mjs +0 -7
- package/lib/chunk-JPUR2CFX.mjs +0 -10
- package/lib/chunk-K327QKMD.mjs +0 -7
- package/lib/chunk-KRCA6IPH.mjs +0 -8
- package/lib/chunk-LPBMBW3O.mjs +0 -13
- package/lib/chunk-LWW4U276.mjs +0 -7
- package/lib/chunk-MJU2PGZQ.mjs +0 -15
- package/lib/chunk-OAZRPP4I.mjs +0 -7
- package/lib/chunk-OO6CLPEH.mjs +0 -7
- package/lib/chunk-OPXCV2KL.mjs +0 -7
- package/lib/chunk-P33PSCXK.mjs +0 -7
- package/lib/chunk-Q3DM32KF.mjs +0 -11
- package/lib/chunk-QROPNEGY.mjs +0 -14
- package/lib/chunk-QWT2C74M.mjs +0 -7
- package/lib/chunk-R3X3LV64.mjs +0 -14
- package/lib/chunk-RMBPOTD7.mjs +0 -7
- package/lib/chunk-SIHORWVK.mjs +0 -7
- package/lib/chunk-T62WNR54.mjs +0 -7
- package/lib/chunk-TTFDUKUS.mjs +0 -47
- package/lib/chunk-VE6XKGGD.mjs +0 -7
- package/lib/chunk-VGW4MXXZ.mjs +0 -7
- package/lib/chunk-VS7ZXUII.mjs +0 -824
- package/lib/chunk-VXQLDM4R.mjs +0 -7
- package/lib/chunk-VYXMVJL5.mjs +0 -7
- package/lib/chunk-W7U5E5ZL.mjs +0 -9
- package/lib/chunk-WXAQ7FK3.mjs +0 -115
- package/lib/chunk-YS4G22C2.mjs +0 -7
- package/lib/chunk-ZM6OJGIG.mjs +0 -7
- package/lib/chunk-ZUTYVST5.mjs +0 -7
|
@@ -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,c,d}from"./chunk-43K2C6H2.mjs";import"./chunk-FSZTXLNW.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as StepCancelledError,d as StepExecutor,b as delayMs,c as waitedWords};
|
|
@@ -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{Zc as u}from"./chunk-DPYTG6DM.mjs";var m={BusinessHours:["Name"]},j=["DUPLICATE_VALUE","DUPLICATES_DETECTED","duplicate value found"];var A=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,P=/^[A-Za-z][A-Za-z0-9_]*$/;function l(e){return e.slice(0,15)}function g(e,r){let t=e.mapping.get(r);return typeof t=="string"&&A.test(t)?t:void 0}function f(e){let r=new Set((e.created??[]).flatMap(i=>i.referenceIds)),t=new Set;for(let i of e.mapping.keys()){if(r.has(i))continue;let n=g(e,i);n&&t.add(l(n))}return t}function h(e){let r=new Set((e.created??[]).flatMap(n=>n.referenceIds)),t=[...Object.entries(e.personContacts??{}),...Object.entries(e.withTheirRecord??{})];for(let n=!0;n;){n=!1;for(let[o,s]of t)r.has(o)||!r.has(s)||(r.add(o),n=!0)}let i=new Set;for(let[n]of t){let o=r.has(n)?g(e,n):void 0;o&&i.add(l(o))}return i}function b(e){let r=f(e),t=new Map;for(let{objectApiName:o,referenceIds:s}of e.created??[])P.test(o)&&t.set(o,[...t.get(o)??[],...s]);let i=new Set,n=[];for(let[o,s]of[...t].reverse()){let a=[];for(let y of[...s].reverse()){let c=g(e,y);if(!c)continue;let d=l(c);r.has(d)||i.has(d)||(i.add(d),a.push(c))}a.length>0&&n.push({objectApiName:o,ids:a})}return n}function p(e){return u(e.removal)?[]:b(e).filter(r=>!R(r.objectApiName))}function R(e){return Object.prototype.hasOwnProperty.call(m,e)}function k(e){return b(e).filter(r=>R(r.objectApiName)).map(({objectApiName:r,ids:t})=>({objectApiName:r,count:t.length}))}function I(e){return e.find(r=>p(r).length>0)??e[0]}function O(e,r){return e.filter(t=>t.endedAt!==r.endedAt&&t.created!==void 0&&p(t).length===0)}function v(e){let r=e.created!==void 0,t=h(e),i=[...f(e)].filter(o=>!t.has(o)),n=k(e);return{orgId:e.orgId,loadedAt:e.endedAt,created:p(e).map(({objectApiName:o,ids:s})=>({objectApiName:o,count:s.length})),linked:r?i.length:0,recorded:r,...e.removal?{removed:e.removal}:{},...e.earlier?{earlier:!0}:{},...n.length>0?{keptByThePlatform:n}:{}}}export{m as a,j as b,b as c,p as d,k as e,I as f,O as g,v as h};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{b as c,j as o,k as d}from"./chunk-
|
|
7
|
+
import{b as c,j as o,k as d}from"./chunk-T26C576X.mjs";import{b as i}from"./chunk-CA5NAXSU.mjs";import{o as a}from"./chunk-DPYTG6DM.mjs";var u=6e4,g=class{tokenCache=new Map;sfdxBridge;setSfdxBridge(e){this.sfdxBridge=e}async authenticate(e){switch(e.method){case"oauth_web":return this.authenticateOAuth(e);case"oauth_device":return{success:!1,error:"OAuth device flow handled via DeviceLogin and SfdxBridge.loginWithRefreshToken()"};case"jwt":return this.authenticateJwt(e);case"usernamePassword":return this.authenticateUsernamePassword(e);case"sfdx_import":return this.importFromSfdx(e.username);default:return{success:!1,error:`Unsupported auth method: ${e.method}`}}}buildConnectionConfig(e,r){return{loginUrl:e.loginUrl,clientId:e.clientId,clientSecret:e.clientSecret,accessToken:r.accessToken,refreshToken:r.refreshToken,instanceUrl:r.instanceUrl,username:e.username}}async validateConnection(e,r){let t=await o({accessToken:e,instanceUrl:r}),{identity:s,orgResult:h}=await c(t,async()=>({identity:await t.identity(),orgResult:await t.query(`SELECT Id, Name, OrganizationType, IsSandbox FROM Organization LIMIT ${a.singleRecord}`)})),n=h.records[0];return{userId:s.user_id,username:s.username,displayName:s.display_name,orgId:n.Id,orgName:n.Name,orgType:n.OrganizationType,isSandbox:n.IsSandbox}}isTokenValid(e){let r=this.tokenCache.get(e);return r?Date.now()<r.expiresAt:!1}cacheToken(e,r,t){this.tokenCache.set(e,{token:r,expiresAt:Date.now()+t})}getCachedToken(e){let r=this.tokenCache.get(e);if(!r||Date.now()>=r.expiresAt){this.tokenCache.delete(e);return}return r.token}clearTokenCache(e){this.tokenCache.delete(e)}clearAllTokens(){this.tokenCache.clear()}async authenticateOAuth(e){return{success:!1,error:"OAuth handled via SfdxBridge.loginWeb()"}}async authenticateJwt(e){return{success:!1,error:"JWT handled via SfdxBridge.loginJwt()"}}async authenticateUsernamePassword(e){if(!e.username||!e.password)return{success:!1,error:"Username and password are required"};try{let r=await o({loginUrl:e.loginUrl}),t=await d(r.login(e.username,e.password+(e.securityToken??"")),u,`${new URL(e.loginUrl).host} did not answer within ${u/1e3} s: check that this machine reaches it, through its proxy if it has one`);return{success:!0,accessToken:r.accessToken??void 0,instanceUrl:r.instanceUrl,userId:t.id,orgId:t.organizationId}}catch(r){return{success:!1,error:`Login failed: ${i(r)}`}}}async importFromSfdx(e){if(!this.sfdxBridge)return{success:!1,error:"SFDX bridge not configured"};if(!e)return{success:!1,error:"An SFDX import needs the username of the org to import"};try{let r=await this.sfdxBridge.findOrg(e);return r?{success:!0,accessToken:r.credentials.accessToken,instanceUrl:r.credentials.instanceUrl,orgId:r.org.orgId}:{success:!1,error:`No connected org for ${e} found in SF CLI`}}catch(r){return{success:!1,error:`SFDX import failed: ${i(r)}`}}}};export{g as a};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a as B,b as J}from"./chunk-PC247GKX.mjs";import{a as S}from"./chunk-3B5H24ZG.mjs";import{$a as b,Ra as h,Sa as E,Ta as U,Ua as D}from"./chunk-DPYTG6DM.mjs";import{b as l,l as m,s as C,u as M,v as K}from"./chunk-WZQEK4WT.mjs";import{randomBytes as L}from"node:crypto";import{mkdirSync as ye,statSync as Z}from"node:fs";import{mkdir as w,open as Oe,readFile as R,readdir as _,rename as Fe,rm as f,rmdir as xe,stat as x}from"node:fs/promises";import{homedir as V}from"node:os";import{join as c,resolve as Ie}from"node:path";import{promisify as Q}from"node:util";import{gunzip as Ce,gzip as be}from"node:zlib";import{createHash as me}from"node:crypto";var G=16,Y=m({digest:l().regex(/^[0-9a-f]{64}$/),fields:C(l(),l().regex(new RegExp(`^[0-9a-f]{${G}}$`)))});function W(n){return me("sha256").update(n).digest("hex")}function we(n){return JSON.stringify([n.name.toLowerCase(),n.type,n.createable===!0,n.updateable===!0,n.nillable===!0,[...n.referenceTo??[]].sort(),n.encrypted===!0])}function dn(n){let e=n.map(t=>({name:t.name,key:t.name.toLowerCase(),line:we(t)})).sort((t,r)=>t.key<r.key?-1:t.key>r.key?1:0);return{digest:W(e.map(({line:t})=>t).join(`
|
|
8
|
+
`)),fields:Object.fromEntries(e.map(({name:t,line:r})=>[t,W(r).slice(0,G)]))}}function pn(n,e){let t={added:[],removed:[],changed:[]};if(n.digest===e.digest)return t;let r=new Map(Object.entries(n.fields).map(([o,s])=>[o.toLowerCase(),{name:o,print:s}])),i=new Map(Object.entries(e.fields).map(([o,s])=>[o.toLowerCase(),{name:o,print:s}]));for(let[o,{name:s,print:a}]of i){let p=r.get(o);p===void 0?t.added.push(s):p.print!==a&&t.changed.push(s)}for(let[o,{name:s}]of r)i.has(o)||t.removed.push(s);return t.added.sort(),t.removed.sort(),t.changed.sort(),t}var g=448,Pe=384,Ee=30,ee=3,De=15,ne=1440*6e4,I=1440*6e4,Se=Q(be),ve=Q(Ce),T="checkpoint.json",ze="fingerprints.json.gz",Ae="fingerprints.json",Le="snapshots.json",te="replay.json.gz",re=/^[A-Za-z][A-Za-z0-9_]*$/;function In(n=process.env){let e=n.SANDFORGE_JOURNAL_DIR,t=e!==void 0&&e.trim()!==""?Ie(e):c(V(),".sandforge");return c(t,"checkpoints")}function Re(n=V()){return c(n,".sandforge","locks")}function k(n){let e=D.safeParse(n).success?S(n.slice(0,15)):void 0;if(e===void 0)throw new d("invalid","Not an Organization Id");return e}function Ne(n){return n.length===18&&D.safeParse(n).success&&S(n.slice(0,15))===n}function v(n,e,t){return ie(c(n,e,t),e,t)}function ie(n,e,t){return{organizationId:e,checkpointId:t,dir:n,checkpointFile:c(n,T),fingerprintsFile:c(n,ze),plainFingerprintsFile:c(n,Ae),snapshotsFile:c(n,Le),indexDir:c(n,"index"),binDir:c(n,"bin"),filesDir:c(n,"files"),previewsDir:c(n,"previews"),rewindsDir:c(n,"rewinds")}}function oe(n){if(!re.test(n)||n.length>80)throw new d("invalid","Not a Salesforce API name");return n}function Cn(n,e){return c(n.indexDir,`${oe(e)}.idx`)}function bn(n){return c(n.indexDir,"recreated.ndjson")}function Pn(n){return c(n.indexDir,"notInBin.ndjson")}function En(n,e){return c(n.binDir,`${oe(e)}.ids`)}function Dn(n){return c(n.filesDir,"documents.ndjson")}function Sn(n){return c(n.filesDir,"links.ndjson")}function vn(n){return c(n.dir,te)}var $e=[/^checkpoint\.json$/,/^fingerprints\.json(?:\.gz)?$/,/^snapshots\.json$/,/^backups\/[A-Za-z0-9_-]{1,200}__[A-Za-z][A-Za-z0-9_]{0,79}\.ndjson(?:\.gz)?$/,/^bin\/[A-Za-z][A-Za-z0-9_]{0,79}\.ids$/,/^files\/(?:links|documents)\.ndjson(?:\.gz)?$/,/^index\/(?:recreated|notInBin)\.ndjson$/,/^replay\.json\.gz$/],zn=te,je=["","backups","bin","files","index"],An=T;function se(n){return $e.some(e=>e.test(n))}async function Ln(n){let e=[];for(let t of je){let r;try{r=await _(c(n.dir,t),{withFileTypes:!0})}catch(i){if(F(i)==="ENOENT"||F(i)==="ENOTDIR")continue;throw i}for(let i of r){let o=t===""?i.name:`${t}/${i.name}`;if(!i.isFile()||!se(o))continue;let s=c(n.dir,t,i.name);e.push({path:o,file:s,bytes:(await x(s)).size})}}return e.sort((t,r)=>ge(t.path,r.path))}function Rn(n,e){if(!se(e))throw new d("invalid","Not a file a checkpoint holds");return c(n,...e.split("/"))}function Nn(n,e){return c(n.previewsDir,O(E,e))}function H(n,e){return c(n.rewindsDir,O(U,e))}function O(n,e){let t=n.safeParse(e);if(!t.success)throw new d("invalid","Not an id of this store");return t.data}async function X(n){await w(n,{recursive:!0,mode:g})}var q="abcdefghijklmnopqrstuvwxyz0123456789";function $n(n,e=new Date){let t=e.toISOString(),r=`${t.slice(0,4)}${t.slice(5,7)}${t.slice(8,10)}`,i=`${t.slice(11,13)}${t.slice(14,16)}${t.slice(17,19)}`,o=Array.from(L(4),s=>q[s%q.length]).join("");return`${n}-${r}-${i}-${o}`}function _e(n,e){if(!Number.isInteger(e)||e<0)throw new RangeError(`Not a number of days: ${e}`);return e===0?null:new Date(n.getTime()+e*I).toISOString()}function ce(n,e){return n.expiresAt!==null&&Date.parse(n.expiresAt)<=e}function Te(n,e){if(n.expiresAt===null)return!1;let t=Date.parse(n.expiresAt);return t>e&&t-e<=ee*I}function He(n,e){let t=e-De*I;return Date.parse(n.readFrom)<t?new Date(t).toISOString():void 0}function Me(n,e){let t=ae(n);return t!==void 0&&t<=e}function ae(n){let e=n.scratchExpiresAt;if(e===void 0)return;let t=Date.parse(e);if(Number.isFinite(t))return/^\d{4}-\d{2}-\d{2}$/.test(e)?t+I:t}function Ke(n,e){let t=ae(n);return t!==void 0&&t>e&&t-e<=ee*I}var d=class extends Error{constructor(t,r){super(r);this.code=t;this.name="CheckpointStoreError"}code};function jn(n,e,t){let r=n.detail!==void 0?` (${n.detail})`:"";if(n.path===e)switch(n.reason){case"otherOwner":return`another user of this machine owns it, and could read and replace the checkpoints in it. ${t} names a folder of your own.`;case"notAFolder":return`it is a file, not a folder. ${t} names a folder for them, or move the file away.`;case"cannotMake":return`it could not be made${r}. ${t} names a folder this user can write.`}let i="the folder of every org\u2019s lock, whatever the store";switch(n.reason){case"otherOwner":return`${i}, is owned by another user of this machine: run as its owner, or remove it.`;case"notAFolder":return`${i}, is a file, not a folder: move the file away.`;case"cannotMake":return`${i}, could not be made${r}: make it a folder this user can write.`}}var de=m({version:K(1),objects:C(l().regex(re).max(80),Y)});async function Ue(n,e){let t;try{t=JSON.parse(await Je(n))}catch{throw new d("damaged","The checkpoint\u2019s field prints cannot be read")}let r=de.safeParse(t);if(!r.success)throw new d("damaged","The checkpoint\u2019s field prints do not parse");let i=new Map(Object.entries(r.data.objects));for(let o of e)if(i.get(o.objectApiName)?.digest!==o.fingerprint)throw new d("damaged",`The field prints of ${o.objectApiName} are not the checkpoint\u2019s`);return i}async function Be(n){let e=de.safeParse({version:1,objects:n});if(!e.success)throw new d("invalid",`Not field prints: ${e.error.message}`);return Se(`${JSON.stringify(e.data)}
|
|
9
|
+
`)}async function Je(n){let e;try{e=await R(n.fingerprintsFile)}catch(t){if(t.code!=="ENOENT")throw t;return R(n.plainFingerprintsFile,"utf8")}return(await ve(e)).toString("utf8")}function _n(n){let e=n.uid??(()=>process.getuid?.()),t=n.locksDir??Re();for(let r of[n.root,t]){let i=We(r,e);if(i!==void 0)return{refusal:i}}return{store:new N({...n,locksDir:t})}}function We(n,e){try{let t=Z(n,{throwIfNoEntry:!1});if(t!==void 0&&!t.isDirectory())return{reason:"notAFolder",path:n};ye(n,{recursive:!0,mode:g});let r=e();return r!==void 0&&Z(n).uid!==r?{reason:"otherOwner",path:n}:void 0}catch(t){return{reason:"cannotMake",path:n,detail:cn(t)}}}var N=class{root;locksDir;renameFile;lockOptions;changes=new Map;constructor(e){this.root=e.root,this.locksDir=e.locksDir,this.renameFile=e.rename??((t,r)=>Fe(t,r)),this.lockOptions={...e.lockSelf?{self:e.lockSelf}:{},...e.lockChecks?{checks:e.lockChecks}:{}}}folderOf(e,t){return v(this.root,k(e),O(h,t))}async create(e,t){let r=this.folderOf(e,t);await X(c(this.root,r.organizationId));try{await w(r.dir,{mode:g})}catch(i){throw F(i)==="EEXIST"?new d("exists",`A checkpoint ${t} is kept already`):i}return await w(r.indexDir,{mode:g}),await w(r.binDir,{mode:g}),r}async write(e){let t=z(e),r=this.folderOf(t.org.organizationId,t.checkpointId);await this.writeWhole(r.checkpointFile,$(t))}async writeFingerprints(e,t){await this.writeWhole(e.fingerprintsFile,await Be(t))}async readFingerprints(e,t){return Ue(e,t.objects)}async checkpointsOf(e){return this.readsOf(k(e))}async read(e){let t=O(h,e);for(let r of await this.organizationKeys()){let i=v(this.root,r,t);if(await y(i.dir))return A(i)}}async update(e,t){let r=async()=>{let a=await this.read(e);if(a===void 0)throw new d("notFound",`No checkpoint ${e} is kept`);if(a.checkpoint===void 0)throw new d("damaged",`The checkpoint ${e} is damaged`);let p=t(structuredClone(a.checkpoint));if(p.checkpointId!==a.folder.checkpointId||j(p.org.organizationId)!==a.folder.organizationId)throw new d("invalid","A change never moves a checkpoint");return await this.write(p),b.parse(p)},o=(this.changes.get(e)??Promise.resolve()).then(r,r),s=o.catch(()=>{});return this.changes.set(e,s),s.then(()=>{this.changes.get(e)===s&&this.changes.delete(e)}),o}keep(e,t,r=new Date){return this.update(e,i=>({...i,expiresAt:t?null:_e(r,Ee)}))}async list(e={}){let t=(e.now??new Date).getTime(),r=e.organizationId!==void 0?k(e.organizationId):void 0,i=[];for(let o of await this.organizationKeys(r)){let s=await this.readsOf(o),a=qe(s);for(let p of s)i.push(await Qe(p,t,a,e.refreshedAt))}return i.sort((o,s)=>ge(s.checkpointId,o.checkpointId))}async delete(e){let t=await this.read(e);if(t===void 0)return{outcome:"notFound"};let r=this.lock(t.folder.organizationId,"delete",t.folder.checkpointId);if("busy"in r)return{outcome:"busy",holder:r.busy};try{await f(t.folder.dir,{recursive:!0,force:!0})}finally{r.lock.release()}return t.checkpoint?{outcome:"deleted",checkpoint:t.checkpoint}:{outcome:"deleted"}}async importInto(e,t,r){let i=this.folderOf(e,t),o=c(this.root,i.organizationId);await X(o);let s=ie(c(o,`${Ge}${L(6).toString("hex")}`),i.organizationId,i.checkpointId);await w(s.dir,{mode:g});try{let a=z(await r(s));if(a.checkpointId!==i.checkpointId||j(a.org.organizationId)!==i.organizationId)throw new d("invalid","An import keeps the checkpoint it was asked to");let p=z({...a,bytes:await Xe(s.dir,a)});if(await this.writeWhole(s.checkpointFile,$(p)),await y(i.dir))return{outcome:"exists"};try{await this.renameFile(s.dir,i.dir)}catch(u){if(await y(i.dir))return{outcome:"exists"};throw u}return{outcome:"imported",checkpoint:p}}finally{await f(s.dir,{recursive:!0,force:!0}),await xe(o).catch(()=>{})}}async sweep(e=new Date){let t=e.getTime(),r={checkpoints:[],journals:[],previews:0,skipped:[]};for(let i of await this.organizationKeys()){await Ze(c(this.root,i),t);let o=await en(await this.readsOf(i),t);if(o.length===0)continue;let s=this.lock(i,"sweep");if("busy"in s){r.skipped.push(i);continue}try{for(let a of o)await nn(await A(a),t,r)}finally{s.lock.release()}}return r}lock(e,t,r){return on(this.locksDir,e,{operation:t,...r!==void 0?{checkpointId:r}:{}},this.lockOptions)}heldBy(e){return sn(this.locksDir,e,this.lockOptions)}async organizationKeys(e){return(await P(this.root)).filter(r=>Ne(r)&&(e===void 0||r===e))}async readsOf(e){let t=(await P(c(this.root,e))).filter(i=>h.safeParse(i).success),r=[];for(let i of t)r.push(await A(v(this.root,e,i)));return r}async writeWhole(e,t){let r=`${e}.${process.pid}-${L(4).toString("hex")}.tmp`,i=await Oe(r,"wx",Pe);try{try{await i.writeFile(t,typeof t=="string"?"utf8":void 0),await i.sync()}finally{await i.close()}await this.renameFile(r,e)}catch(o){throw await f(r,{force:!0}),o}}},Ge=".importing-",Ye=/^\.importing-[0-9a-f]{12}$/;async function Ze(n,e){for(let t of await P(n)){if(!Ye.test(t))continue;let r=c(n,t),i=await x(r).catch(()=>{});i!==void 0&&i.mtimeMs+ne<=e&&await f(r,{recursive:!0,force:!0})}}function z(n){let e=b.safeParse(n);if(!e.success)throw new d("invalid",`Not a checkpoint: ${e.error.message}`);return e.data}function $(n){return`${JSON.stringify(n,null,2)}
|
|
10
|
+
`}async function pe(n,e){let t=0;for(let r of await _(n,{withFileTypes:!0})){let i=c(n,r.name);r.isDirectory()?t+=await pe(i,e):r.isFile()&&i!==e&&(t+=(await x(i)).size)}return t}async function Xe(n,e){let t=await pe(n,c(n,T)),r=o=>Buffer.byteLength($({...e,bytes:o}),"utf8"),i=t+r(t);return i=t+r(i),i}async function A(n){let e;try{e=JSON.parse(await R(n.checkpointFile,"utf8"))}catch{return{folder:n}}let t=b.safeParse(e);return t.success?t.data.checkpointId!==n.checkpointId||j(t.data.org.organizationId)!==n.organizationId?{folder:n}:{folder:n,checkpoint:t.data}:{folder:n}}function qe(n){let e;for(let{folder:t,checkpoint:r}of n){let i=r?.lastRewind?.rewindId;i!==void 0&&(e===void 0||i>e.rewindId)&&(e={checkpointId:t.checkpointId,rewindId:i})}return e}function Ve(n,e,t,r){if(n.status==="taking")return{why:"taking"};if(n.status==="failed")return{why:"failed"};let i=r?.(e);if(i!==void 0)return{why:"refreshed",refreshedAt:i};if(Me(n.org,t))return{why:"scratchExpired"}}async function Qe({folder:n,checkpoint:e},t,r,i){let o={checkpointId:n.checkpointId,organizationId:n.organizationId};if(e===void 0)return{...o,valid:!1,why:"damaged"};let s=Ve(e,n.organizationId,t,i);if(s!==void 0)return{...o,checkpoint:e,valid:!1,why:s.why,...s.refreshedAt!==void 0?{refreshedAt:s.refreshedAt}:{}};let a={...o,checkpoint:e,valid:!0};Te(e,t)&&(a.expiresSoon=!0),Ke(e.org,t)&&(a.scratchExpiresSoon=!0);let p=He(e,t);p!==void 0&&(a.binReachSince=p);let u=e.lastRewind;return u!==void 0&&r?.checkpointId===n.checkpointId&&u.undoUntil!==void 0&&u.undoneAt===void 0&&Date.parse(u.undoUntil)>t&&await y(H(n,u.rewindId))&&(a.undo={rewindId:u.rewindId,until:u.undoUntil}),a}async function en(n,e){let t=[];for(let{folder:r,checkpoint:i}of n)i!==void 0&&(ce(i,e)||await ue(r,i,e)||(await fe(r,e)).length>0)&&t.push(r);return t}async function ue(n,e,t){let r=e.lastRewind?.undoUntil;return e.lastRewind!==void 0&&r!==void 0&&Date.parse(r)<=t&&await y(H(n,e.lastRewind.rewindId))}async function fe(n,e){let t=[];for(let r of await P(n.previewsDir)){if(!E.safeParse(r).success)continue;let i=c(n.previewsDir,r),o=await x(i).catch(()=>{});o!==void 0&&o.mtimeMs+ne<=e&&t.push(i)}return t}async function nn(n,e,t){let{folder:r,checkpoint:i}=n;if(i===void 0)return;if(i.expiresAt!==null&&ce(i,e)){await f(r.dir,{recursive:!0,force:!0});let s=i.lastRewind?.undoUntil,a=s!==void 0&&i.lastRewind?.undoneAt===void 0&&Date.parse(s)>e;t.checkpoints.push({organizationId:r.organizationId,checkpointId:r.checkpointId,name:i.name,...i.org.alias!==void 0?{alias:i.org.alias}:{},takenAt:i.takenAt,expiresAt:i.expiresAt,...a?{undoUntil:s}:{}});return}let o=i.lastRewind;o?.undoUntil!==void 0&&await ue(r,i,e)&&(await f(H(r,o.rewindId),{recursive:!0,force:!0}),t.journals.push({organizationId:r.organizationId,checkpointId:r.checkpointId,name:i.name,rewindId:o.rewindId,undoUntil:o.undoUntil}));for(let s of await fe(r,e))await f(s,{recursive:!0,force:!0}),t.previews+=1}var tn=m({...B,operation:M(["take","rewind","undo","delete","sweep","empty"]),checkpointId:h.optional()}),le=J(n=>{let e=tn.safeParse(n);return e.success?e.data:void 0});function rn(n,e){return c(n,`${k(e)}.lock`)}function on(n,e,t,r={}){let i=k(e),o=t.checkpointId!==void 0?O(h,t.checkpointId):void 0,s=le.acquire(c(n,`${i}.lock`),a=>({...a,operation:t.operation,...o!==void 0?{checkpointId:o}:{}}),r);return"busy"in s?{busy:he(s.busy)}:{lock:{organizationId:i,release:s.lock.release}}}function sn(n,e,t={}){let r=le.holder(rn(n,e),t);return r!==void 0?he(r):void 0}function he({version:n,token:e,...t}){return t}async function P(n){try{return(await _(n,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name)}catch(e){if(F(e)==="ENOENT"||F(e)==="ENOTDIR")return[];throw e}}async function y(n){return(await x(n).catch(()=>{}))?.isDirectory()===!0}function j(n){try{return k(n)}catch{return}}function ge(n,e){return n<e?-1:n>e?1:0}function F(n){return n?.code}function cn(n){return n instanceof Error?n.message:String(n)}export{dn as a,pn as b,g as c,Pe as d,Ee as e,ee as f,De as g,ne as h,In as i,Re as j,k,Cn as l,bn as m,Pn as n,En as o,Dn as p,Sn as q,vn as r,zn as s,An as t,se as u,Ln as v,Rn as w,Nn as x,H as y,X as z,$n as A,_e as B,ce as C,Te as D,He as E,Me as F,Ke as G,d as H,jn as I,Ue as J,Be as K,_n as L,N as M,qe as N,rn as O,on as P,sn as Q};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{
|
|
7
|
+
import{Zb as S,_b as O}from"./chunk-DPYTG6DM.mjs";import{b as y,f as b,l as R}from"./chunk-WZQEK4WT.mjs";var v=["User","Group","Profile","UserRole","RecordType","Organization","Queue","PermissionSet","BusinessProcess","CurrencyType","DandBCompany","DuplicateRecordItem","DuplicateRecordSet","ProcessInstance","LoginHistory","LoginEvent","LoginIp","LoginGeo","AsyncApexJob","ApexLog","ApexTestResult","ApexTestQueueItem","LightningUsageByPageMetrics","LightningExitByPageMetrics","EventBusSubscriber","PlatformEventUsageMetric","CronTrigger","CronJobDetail","AttachedContentDocument","AttachedContentNote","CombinedAttachment","ContentBody","NoteAndAttachment","OwnedContentDocument","EntitySubscription","TopicAssignment","UserRecordAccess","DeclinedEventRelation","UndecidedEventRelation","AcceptedEventRelation","OpenActivity","ActivityHistory","AppUsageAssignment","AuthProvider","Folder","ContentDocument","ContentDocumentLink","OpportunityRelatedDeleteLog","CaseHistory2","Calendar","SlaProcess","AccountCleanInfo","ContactCleanInfo","LeadCleanInfo","ApprovalSubmission","ApprovalSubmissionDetail","ApprovalWorkItem","AIRecordInsight","AIInsightValue","MatchingInformation","Invoice","InvoiceLine","CreditMemo","CreditMemoLine","AppDefinition","BackgroundOperation","ContentTaxonomyTermRelationshipType","Dashboard","DashboardComponent","DeleteEvent","ManagedContentChannel","ManagedContentSpace","ManagedContentVariant","Report","ServiceSetupProvisioning","TabDefinition"],P=new Set(v.map(e=>e.toLowerCase())),W=["History","Feed","Share","ChangeEvent","__hd","__Tag","EventStore"].map(e=>e.toLowerCase()),F=/^vlocity_[a-z0-9]+__/;function B(e,t){return I(e,t,{byNamespace:!0})}function I(e,t,r){let n=e.toLowerCase();return P.has(n)||S(e)||t&&(t.has(e)||U(t).has(n))||r.byNamespace&&F.test(n)?!0:W.some(i=>n.endsWith(i))}var w=new WeakMap;function U(e){let t=w.get(e);if(t&&t.size===e.size)return t.names;let r=new Set([...e].map(n=>n.toLowerCase()));return w.set(e,{size:e.size,names:r}),r}function z(e,t){return O(e)||B(e,t)}function E(e){return O(e)||I(e,void 0,{byNamespace:!1})}function x(e,t=[]){let r=new Set(t);for(let n of e)n.createable===!1&&r.add(n.name);return r}function le(e,t=r=>z(r)){return new Set(e.filter(r=>{let n=r.referenceTo??[];return n.length>0&&n.every(i=>t(i))}).map(r=>r.name))}var ge=R({name:y(),queryable:b().optional(),createable:b().optional(),updateable:b().optional(),deletable:b().optional(),undeletable:b().optional(),customSetting:b().optional(),layoutable:b().optional(),keyPrefix:y().nullish()}).loose(),D="ContentDocument",H="ContentDocumentLink",G="ContentVersion",L="Attachment",J=[D,L],K={AccountContactRelation:["Contact"]},V=new Set(["feeditem","feedcomment","feedattachment"]),X=new Set(["casehistory2"]),Y=new Set(["AccountCleanInfo","ContactCleanInfo","LeadCleanInfo","ApprovalSubmission","ApprovalSubmissionDetail","ApprovalWorkItem","ProcessInstance","ProcessInstanceNode","ProcessInstanceStep","ProcessInstanceWorkitem","AIRecordInsight","AIInsightValue","AIInsightAction","AIInsightFeedback","AIInsightReason","MatchingInformation","Invoice","InvoiceLine","CreditMemo","CreditMemoLine","CreditMemoInvApplication"].map(e=>e.toLowerCase())),Q=new Set([G,H].map(e=>e.toLowerCase())),Z=["__b","__x","__dlm","__kav","__ka","__e"],$=new Set(["AccountContactRole",L,"CaseTeamMember","EmailMessageRelation","EventRelation","OpportunityCompetitor"].map(e=>e.toLowerCase()));function q(e,t,r,n,i){let o=e.name.toLowerCase();return V.has(o)||o.endsWith("feed")?"chatter":o.endsWith("history")||o.endsWith("__hd")||X.has(o)?"history":o.endsWith("share")?"sharing":o.endsWith("changeevent")?"changeEvent":Z.some(c=>o.endsWith(c))?"unsupportedKind":e.customSetting===!0?n?A(e,i)?void 0:"notWritable":"customSetting":Q.has(o)?"heldWithFiles":o===D.toLowerCase()?(i==="delete"?_(e):T(e))?void 0:"notWritable":o===L.toLowerCase()?A(e,i)?void 0:"notWritable":S(e.name)?"files":Y.has(o)?"platformCreated":E(e.name)||r==="everything"&&e.layoutable===!1&&!$.has(o)?"setup":t.out.has(o)?t.tooling.has(o)?"metadata":"notWritable":A(e,i)?void 0:"notWritable"}function A(e,t){return t==="delete"?_(e):ee(e)}function ee(e){return e.createable===!0&&T(e)}function _(e){return e.queryable===!0&&e.deletable===!0}function T(e){return e.queryable===!0&&e.updateable===!0&&e.deletable===!0}function k(e,t){return e.objectApiName<t.objectApiName?-1:e.objectApiName>t.objectApiName?1:0}var te="all";function ne(e){return e.customSetting===!0}function oe(e,t){let r=e.filter(ne);if(t===void 0)return{held:new Set,unknown:[]};if(t===te)return{held:new Set(r.map(c=>c.name.toLowerCase())),unknown:[]};let n=new Set(r.map(c=>c.name.toLowerCase())),i=new Set,o=[];for(let c of t){let p=c.toLowerCase();i.has(p)||o.some(u=>u.toLowerCase()===p)||(n.has(p)?i.add(p):o.push(c))}return{held:i,unknown:o}}function he(e,t,r=[]){let n=t.access??"write",i=n==="delete"?r:x(e,r),o={out:new Set([...i].map(a=>a.toLowerCase())),tooling:new Set(r.map(a=>a.toLowerCase()))},c=new Set((t.excluded??[]).map(a=>a.toLowerCase())),p=new Map(e.map(a=>[a.name.toLowerCase(),a])),u=oe(e,t.customSettings),h=u.unknown.map(a=>({objectApiName:a,reason:"notCustomSetting"})),g=[],f=[],s=[];if(t.mode==="picked"){let a=new Set;for(let d of t.objects??[]){let l=d.toLowerCase();if(a.has(l))continue;a.add(l);let m=p.get(l);m?f.push(m):h.push({objectApiName:d,reason:"notFound"})}for(let d of J){let l=d.toLowerCase(),m=p.get(l);if(!(a.has(l)||m===void 0)){if(c.has(l)){h.push({objectApiName:m.name,reason:"excludedByUser"});continue}f.push(m),s.push(m.name)}}for(let[d,l]of Object.entries(K)){let m=d.toLowerCase(),C=p.get(m);if(!(a.has(m)||C===void 0)&&l.some(j=>a.has(j.toLowerCase()))){if(a.add(m),c.has(m)){h.push({objectApiName:C.name,reason:"excludedByUser"});continue}f.push(C)}}for(let d of u.held){let l=p.get(d);a.has(d)||l===void 0||(a.add(d),f.push(l))}}else f.push(...p.values());for(let a of f){let d=a.name.toLowerCase(),l=c.has(d)?"excludedByUser":q(a,o,t.mode,u.held.has(d),n);l===void 0?g.push(a.name):h.push({objectApiName:a.name,reason:l})}return g.sort(),h.sort(k),{mode:t.mode,candidates:g,leftOut:h,addedToPicked:s}}function be(e){return e.fields.find(r=>r.name==="Name")?.nillable===!0?"hierarchy":"list"}function Ce(e){return e==="hierarchy"?"SetupOwnerId":"Name"}function Se(e){return e.objects.some(t=>t.customSetting!==void 0)}function re(e){let t=e.split("__");return t.length>=3&&t[0]!==""?t[0]:void 0}var se=()=>({first:"child",firmness:0});function ie(e,t,r=se){let n=new Map(e.map((o,c)=>[o.toLowerCase(),c])),i=e.map(()=>new Map);return e.forEach((o,c)=>{for(let p of t.get(o)?.childRelationships??[]){let u=n.get(p.childSObject.toLowerCase());if(u===void 0||u===c)continue;let h=r(p);if(h===void 0)continue;let[g,f]=h.first==="child"?[u,c]:[c,u],s=i[g].get(f);(s===void 0||h.firmness>s)&&i[g].set(f,h.firmness)}}),N(e.map((o,c)=>c),i,Number.NEGATIVE_INFINITY).map(o=>e[o])}function N(e,t,r){let n=new Set(e),i=f=>[...t[f]].filter(([s,a])=>n.has(s)&&a>r).map(([s])=>s),o=ae(e,i,t.length),c=new Map;o.forEach((f,s)=>{for(let a of f)c.set(a,s)});let p=o.map(()=>0),u=o.map(()=>new Set);for(let f of e){let s=c.get(f)??0;for(let a of i(f)){let d=c.get(a)??0;d===s||u[s].has(d)||(u[s].add(d),p[d]++)}}let h=o.map(()=>!1),g=[];for(let f=o.length;f>0;f--){let s=-1;for(let d=0;d<o.length;d++){if(h[d]||p[d]>0)continue;let l=o[d].length===1,m=s>=0&&o[s].length===1;(s<0||l&&!m||l===m&&o[d][0]<o[s][0])&&(s=d)}h[s]=!0;let a=o[s];if(a.length===1)g.push(a[0]);else{let d=Number.POSITIVE_INFINITY;for(let l of a)for(let[m,C]of t[l])C>r&&c.get(m)===s&&C<d&&(d=C);g.push(...N(a,t,d))}for(let d of u[s])p[d]--}return g}function ae(e,t,r){let n=new Array(r).fill(-1),i=new Array(r).fill(0),o=new Array(r).fill(!1),c=[],p=[],u=0;for(let h of e){if(n[h]>=0)continue;let g=[],f=s=>{n[s]=u,i[s]=u,u++,c.push(s),o[s]=!0,g.push({node:s,edges:t(s),at:0})};for(f(h);g.length>0;){let s=g[g.length-1];if(s.at<s.edges.length){let l=s.edges[s.at++];n[l]<0?f(l):o[l]&&(i[s.node]=Math.min(i[s.node],n[l]));continue}g.pop();let a=g[g.length-1];if(a&&(i[a.node]=Math.min(i[a.node],i[s.node])),i[s.node]!==n[s.node])continue;let d=[];for(let l=c.pop();l!==void 0&&(o[l]=!1,d.push(l),l!==s.node);l=c.pop());p.push(d.sort((l,m)=>l-m))}}return p}function M(e){let t=new Map;for(let{objectApiName:r,namespace:n}of e)n!==void 0&&t.set(n,[...t.get(n)??[],r]);return[...t].sort(([r],[n])=>r<n?-1:r>n?1:0).map(([r,n])=>({namespace:r,objects:n.sort()}))}function ce(e,t){return ie(e,t).map((r,n)=>{let i=re(r);return{objectApiName:r,readOrder:n,...i===void 0?{}:{namespace:i}}})}function ye(e,t,r=new Map){let n=[...e.leftOut],i=[];for(let c of e.candidates){let p=t.get(c);if(p)p.fields.some(u=>u.name==="SystemModstamp")?p.fields.some(u=>u.name==="IsDeleted")?i.push(c):n.push({objectApiName:c,reason:"noRecycleBin"}):n.push({objectApiName:c,reason:"noSystemModstamp"});else{let u=r.get(c);n.push({objectApiName:c,reason:"notDescribed",...u===void 0?{}:{detail:u}})}}let o=ce(i,t);return{mode:e.mode,objects:o,leftOut:n.sort(k),packages:M(o)}}function Oe(e,t){if(t.size===0)return e;let r=[...e.leftOut],n=[];for(let i of e.objects){let o=t.get(i.objectApiName);o===void 0?n.push({...i,readOrder:n.length}):r.push({objectApiName:i.objectApiName,reason:"unreadable",detail:o})}return{...e,objects:n,leftOut:r.sort(k),packages:M(n)}}export{B as a,z as b,E as c,x as d,le as e,ge as f,D as g,H as h,G as i,L as j,J as k,te as l,ne as m,he as n,be as o,Ce as p,Se as q,re as r,ie as s,ye as t,Oe as u};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e}from"./chunk-OVOLG3AL.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as AIDataGenerator,c as buildPrompt,d as parseAIResponse,b as phoneReplacement,e as reachNobody};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a}from"./chunk-
|
|
7
|
+
import{a}from"./chunk-RKALOKAU.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as TransformPipeline};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{o as ne}from"./chunk-4JKR4PTZ.mjs";import{H as v,d as z,l as oe,m as se,n as ie}from"./chunk-E2YJVSX6.mjs";import{E as J,x as Be}from"./chunk-XEB6HZ34.mjs";import{c as Pe}from"./chunk-EADHKH3A.mjs";import{h as Oe}from"./chunk-TZE3Y7IQ.mjs";import{a as re}from"./chunk-3B5H24ZG.mjs";import{b as L}from"./chunk-CA5NAXSU.mjs";import{vc as I}from"./chunk-DPYTG6DM.mjs";import{b as N,e as ee,f as ke,i as te,k as Q,l as D,s as xe}from"./chunk-WZQEK4WT.mjs";var rt="encryptedstring";async function nt(o){try{let[e]=await o("SELECT PermissionsViewEncryptedData FROM UserPermissionAccess");return e?.PermissionsViewEncryptedData===!0}catch{return!1}}function lr(o){let e;return()=>(e??=nt(o),e)}function ur(o,e){let r=new Map;return t=>{let n=r.get(t);return n||(n=(async()=>{let s;try{s=(await e(t)).fields.filter(i=>i.type===rt).map(i=>i.name)}catch{return[]}return s.length>0&&!await o()?s:[]})(),r.set(t,n)),n}}var _=5,ce=25,de=3;function mr(o){return{get version(){return o.version},request:async e=>await o.request(e),query:async(e,r)=>await o.query(e,{scanAll:r?.scanAll===!0}),queryMore:async e=>await o.queryMore(e)}}var j=class extends Error{constructor(){super("The read was stopped."),this.name="OrgReadStopped"}},st="PROCESSING_HALTED",Ce="If-Modified-Since",it=/^\d{1,3}\.\d$/,at=/^\/services\/data\/v\d{1,3}\.\d\/query(?:All)?\/[A-Za-z0-9-]+$/,ct=D({records:Q(xe(N(),te())),done:ke(),totalSize:ee().optional(),nextRecordsUrl:N().optional()}).loose(),dt=D({compositeResponse:Q(D({body:te(),httpStatusCode:ee(),referenceId:N()}).loose())}),lt=Q(D({errorCode:N().optional(),message:N().optional()}).loose());function ut(o,e,r){if(!it.test(o))throw new Error(`Not an API version: ${o}`);if(e.length>_)throw new Error(`A composite runs ${_} queries, not ${e.length}`);if(e.length+r.length>ce)throw new Error(`A composite holds ${ce} subrequests, not ${e.length+r.length}`);let t=`/services/data/v${o}`;return{allOrNone:!1,compositeRequest:[...e.map((n,s)=>({method:"GET",url:n.kind==="first"?`${t}/${n.scanAll?"queryAll":"query"}?q=${encodeURIComponent(n.soql)}`:n.path,referenceId:`q${s}`})),...r.map(({path:n,headers:s},a)=>({method:"GET",url:`${t}/${n}`,referenceId:`d${a}`,...s?{httpHeaders:s}:{}}))]}}function ft(o){let e=dt.safeParse(o);if(!e.success)return;let r=new Map;for(let t of e.data.compositeResponse){if(t.httpStatusCode<400){r.set(t.referenceId,{ok:!0,status:t.httpStatusCode,body:t.body});continue}let n=lt.safeParse(t.body),s=n.success?n.data[0]:void 0;r.set(t.referenceId,{ok:!1,refused:s?[s.errorCode,s.message].filter(Boolean).join(": "):`status ${t.httpStatusCode}`,halted:s?.errorCode===st})}return r}function ae(o){let e=ct.safeParse(o);return e.success?e.data:void 0}function ht(o){return typeof o=="object"&&o!==null&&typeof o.errorCode=="string"}function pt(o){let e=/^https:\/\//i.test(o)?new URL(o).pathname:o;if(!at.test(e))throw new Error(`Not the next page of a query: ${o}`);return e}function wr(o,e){let r=new Set,t=[],n=_,s="composite",a=0,i=!1,c=!1,d=0,p=0,f=!1,m=()=>{for(let u of r)u.state==="pending"&&(u.state="idle",u.settle?.reject(new j));for(let u of t.splice(0))u.settle.reject(new j)},A=()=>{c||(c=!0,queueMicrotask(()=>{c=!1,B()}))},h=(u,w)=>{u.state="idle";let y=u.settle;u.ask=void 0,u.settle=void 0,w instanceof Error?y?.reject(w):y?.resolve(w)},l=async(u,w)=>{let y=ut(o.version,u.map(E=>E.ask),w),g;p++;try{g=await o.request({method:"POST",url:"/composite",body:JSON.stringify(y),headers:{"Content-Type":"application/json"}})}catch(E){if(ht(E)){s="single";for(let R of u)R.state="pending";t.unshift(...w);return}let x=new Error(L(E));for(let R of u)h(R,x);for(let R of w)R.settle.reject(x);return}let k=ft(g);if(!k){s="single";for(let E of u)E.state="pending";t.unshift(...w);return}let P=0;if(u.forEach((E,x)=>{let R=k.get(`q${x}`);if(R&&!R.ok&&R.halted){P++,E.state="pending";return}if(!R){h(E,new Error("The org gave no answer to this query of the composite"));return}if(!R.ok){h(E,new Error(R.refused));return}let tt=ae(R.body);h(E,tt??new Error(`The org answered a query with status ${R.status} and no page`))}),P>0){let E=u.length-P;E===0?s="single":n=Math.min(n,E)}w.forEach((E,x)=>{let R=k.get(`d${x}`);R?R.ok?E.settle.resolve(R.status===304?{notModified:!0}:{body:R.body}):E.settle.reject(new Error(R.refused)):E.settle.reject(new Error("The org gave no answer to this describe of the composite"))})},b=async(u,w)=>{for(let y of u){let g=y.ask;p++;try{let k=g.kind==="first"?await o.query(g.soql,{scanAll:g.scanAll}):await o.queryMore(g.path);h(y,ae(k)??new Error("The org answered a query with no page"))}catch(k){h(y,new Error(L(k)))}}for(let y of w){p++;try{let g=await o.request({method:"GET",url:`/services/data/v${o.version}/${y.path}`,...y.headers?{headers:y.headers}:{}}),k=y.headers?.[Ce]!==void 0&&(g==null||g==="");y.settle.resolve(k?{notModified:!0}:{body:g})}catch(g){y.settle.reject(new Error(L(g)))}}},S=async(u,w,y)=>{try{s==="composite"?await l(u,w):await b(u,w)}catch(g){let k=new Error(L(g));for(let P of u)P.state==="sent"&&h(P,k);for(let P of w)P.settle.reject(k)}finally{a--,y||(i=!1),A(),Se()}},B=()=>{if(e?.aborted){m();return}for(;;){if(i)return;let u=[...r],w=u.filter(x=>x.state==="pending").sort((x,R)=>x.order-R.order);if(!(w.length>0&&!u.some(x=>x.state==="idle"))&&t.length===0)return;let g=w.slice(0,n),k=ce-g.length,P=s==="composite"&&t.length===0&&g.length>0&&g.every(x=>x.oneRow&&x.ask?.kind==="first");if(a>=(P?de:1))return;let E=t.splice(0,k);if(g.length===0&&E.length===0)return;for(let x of g)x.state="sent";a++,P||(i=!0),S(g,E,P)}},O=()=>{f=!1,A()},Y=()=>{f||e===void 0||e.aborted||(e.addEventListener("abort",O,{once:!0}),f=!0)},Se=()=>{!f||a>0||r.size>0||t.length>0||(e?.removeEventListener("abort",O),f=!1)},Re=(u,w)=>r.has(u)?u.state!=="idle"?Promise.reject(new Error("A read asks one page at a time.")):e?.aborted?Promise.reject(new j):new Promise((y,g)=>{u.ask=w,u.settle={resolve:y,reject:g},u.state="pending",u.order=++d,A()}):Promise.reject(new Error("This read is closed."));return{lane(u){let w={state:"idle",order:0,oneRow:u?.oneRow===!0};return r.add(w),Y(),{query:(y,g)=>Re(w,{kind:"first",soql:y,scanAll:g?.scanAll===!0}),queryMore:y=>{let g;try{g=pt(y)}catch(k){return Promise.reject(k instanceof Error?k:new Error(String(k)))}return Re(w,{kind:"next",path:g})},close(){r.delete(w)&&(w.state==="pending"&&h(w,new Error("This read is closed.")),A(),Se())}}},describe(u,w){return e?.aborted?Promise.reject(new j):new Promise((y,g)=>{let k=I(u),P;if(w!==void 0){let E=Date.parse(w);if(!Number.isFinite(E))throw new Error(`Not a date: ${w}`);P={[Ce]:new Date(E).toUTCString()}}Y(),t.push({path:`sobjects/${k}/describe`,...P?{headers:P}:{},settle:{resolve:y,reject:g}}),A()})},async tooling(u){if(e?.aborted)throw new j;p++;let w;try{w=await o.request({method:"GET",url:`/services/data/v${o.version}/tooling/query?q=${encodeURIComponent(u)}`})}catch(g){throw new Error(L(g))}let y=ae(w);if(!y)throw new Error("The org answered a Tooling API query with no page");return y},calls:()=>p}}import{createReadStream as mt}from"node:fs";import{appendFile as wt,stat as gt,writeFile as yt}from"node:fs/promises";import{StringDecoder as bt}from"node:string_decoder";import{promisify as je}from"node:util";import{createGunzip as At,gunzip as Et,gzip as St}from"node:zlib";var Rt=je(St),kt=je(Et),xt=64*1024,Ot=".gz",Pt=6,M=10,Ie=4,ve=Buffer.from("SF","latin1"),ue=8,H=6+ue,fe=M+H,he=fe+2+8;function $(o){return`${o}${Ot}`}async function Bt(o){let e=await Rt(o,{level:Pt});if(e[3]!==0)throw new Error("zlib wrote a gzip header with flags set");let r=Buffer.from(e.subarray(0,M));r[3]=Ie;let t=Buffer.alloc(H);return t.writeUInt16LE(H-2,0),ve.copy(t,2),t.writeUInt16LE(ue,4),t.writeUInt32LE(e.length+H,6),t.writeUInt32LE(o.length,10),Buffer.concat([r,t,e.subarray(M)])}function Me(o){if(o.length<fe||o[0]!==31||o[1]!==139||o[2]!==8||o[3]!==Ie||o.readUInt16LE(M)!==H-2||!o.subarray(M+2,M+4).equals(ve)||o.readUInt16LE(M+4)!==ue)return;let e=o.readUInt32LE(M+6),r=o.readUInt32LE(M+10);return e>=he&&r>0?{total:e,raw:r}:void 0}function Ct(o,e=xt){let r=[],t=0,n=0;for(;n<o.length;){let s=o.indexOf(10,n),a=s<0?o.length:s+1;a-t>e&&n>t&&(r.push(o.subarray(t,n)),t=n),n=a,n-t>=e&&(r.push(o.subarray(t,n)),t=n)}return n>t&&r.push(o.subarray(t,n)),r}async function Ne(o){let e=Ct(Buffer.from(o,"utf8"));return Buffer.concat(await Promise.all(e.map(r=>Bt(r))))}function U(o){return o.endsWith(".ndjson")}function kr(o){let e=new Map,r=(t,n)=>{let s=n(e.get(t)??Promise.resolve());return e.set(t,s),s.then(()=>{e.get(t)===s&&e.delete(t)},()=>{}),s};return{...o,writeFile:(t,n)=>{if(!U(t))return o.writeFile(t,n);let s=$(t);return r(s,a=>a.catch(()=>{}).then(async()=>{let i=n===""?Buffer.alloc(0):await Ne(n);await yt(s,i,{mode:z})}))},appendFile:(t,n)=>{if(!U(t))return o.appendFile(t,n);let s=$(t);return r(s,a=>a.then(async()=>{n!==""&&await wt(s,await Ne(n),{mode:z})}))},exists:t=>o.exists(U(t)?$(t):t),rm:t=>o.rm(U(t)?$(t):t),readLines:t=>U(t)?Nt($(t)):o.readLines(t)}}async function*Nt(o){if((await gt(o)).size===0)return;let e=mt(o),r=At(),t=a=>{r.destroy(a)};e.on("error",t),e.pipe(r);let n=new bt("utf8"),s="";try{for await(let a of r){let i=(s+n.write(a)).split(`
|
|
8
|
+
`);s=i.pop()??"",yield*i}s+=n.end(),s!==""&&(yield s)}finally{e.off("error",t),e.destroy(),r.destroy()}}async function le(o,e,r){let t=Buffer.alloc(r),n=0;for(;n<r;){let{bytesRead:s}=await o.read(t,n,r-n,e+n);if(s===0)break;n+=s}return n===r?t:t.subarray(0,n)}async function De(o,e,r,t){let n;try{n=await kt(o,{maxOutputLength:e.raw})}catch{throw t(`holds a block that does not inflate at byte ${r}`)}if(n.length!==e.raw)throw t(`holds a block at byte ${r} that inflates to other than its header says`);return n}async function Le(o,e,r,t){let n=await le(o,e,r);if(n.length<r)throw t(`is cut short at byte ${e+n.length}`);let s=Me(n);if(s===void 0)throw t(`holds no block where its index says, at byte ${e}`);if(s.total!==r)throw t(`holds another block than its index says at byte ${e}`);return De(n,s,e,t)}async function*$e(o,e,r){for(let t=0;t<e;){let n=Me(await le(o,t,Math.min(fe,e-t)));if(n===void 0)throw r(`holds no block at byte ${t}`);if(n.total>e-t)throw r(`is cut short: its block at byte ${t} ends past the file's end`);let s=await le(o,t,n.total);yield{at:t,total:n.total,lines:await De(s,n,t,r)},t+=n.total}}function*Te(o){let e=0;for(;e<o.length;){let r=o.indexOf(10,e),t=r<0?o.length:r;yield{at:e,length:t-e},e=t+1}}import{randomBytes as jt}from"node:crypto";import{open as W,readFile as we,rename as It,rm as vt,stat as Mt}from"node:fs/promises";import{dirname as Ge,join as Dt}from"node:path";var Fe=2e3,C=15,pe=C,T=pe+8,ge={format:1,head:Buffer.from("SFCKIDX1","latin1"),lengthAt:T+8,rowBytes:T+8+4},We={format:2,head:Buffer.from("SFCKIDX2","latin1"),memberBytesAt:T+8,lineAt:T+12,lengthAt:T+16,rowBytes:T+20},Ye={1:ge,2:We},G=ge.head.length,ze=1<<20,Lt=500,F=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,$t=/^[A-Za-z0-9]{15}$/,ye=/^[A-Za-z][A-Za-z0-9_]*$/;function Mr(o,e){return G+o*Ye[e].rowBytes}function _e(o){return o.replace(/[^A-Za-z0-9_-]/g,"_")}function Qe(o,e,r){if(!ye.test(r)||r.length>80)throw new v("invalid","Not a Salesforce API name");return Dt(o.dir,"backups",`${_e(e)}__${_e(r)}.ndjson`)}var Z=class{constructor(e,r){this.layout=e;this.rowBytes=e.rowBytes,this.bytes=r??Buffer.alloc(this.rowBytes*1024),this.size=r?r.length/this.rowBytes:0}layout;bytes;rowBytes;size;push(e,r,t){let n=this.size*this.rowBytes;if(n+this.rowBytes>this.bytes.length){let c=Buffer.alloc(Math.max(this.bytes.length*2,this.rowBytes*1024));this.bytes.copy(c,0,0,n),this.bytes=c}let{memberBytesAt:s,lineAt:a,lengthAt:i}=this.layout;return this.bytes.write(e,n,C,"latin1"),this.bytes.writeDoubleLE(r,n+pe),this.bytes.writeDoubleLE(t.offset,n+T),s!==void 0&&this.bytes.writeUInt32LE(t.memberBytes??0,n+s),a!==void 0&&this.bytes.writeUInt32LE(t.line??0,n+a),this.bytes.writeUInt32LE(t.length,n+i),this.size++}keyAt(e){let r=e*this.rowBytes;return this.bytes.toString("latin1",r,r+C)}holds(e,r){let t=e*this.rowBytes;for(let n=0;n<C;n++)if(this.bytes[t+n]!==r.charCodeAt(n))return!1;return!0}stampAt(e){return this.bytes.readDoubleLE(e*this.rowBytes+pe)}offsetAt(e){return this.bytes.readDoubleLE(e*this.rowBytes+T)}memberBytesAt(e){let r=this.layout.memberBytesAt;return r===void 0?0:this.bytes.readUInt32LE(e*this.rowBytes+r)}lineAt(e){let r=this.layout.lineAt;return r===void 0?0:this.bytes.readUInt32LE(e*this.rowBytes+r)}lengthAt(e){return this.bytes.readUInt32LE(e*this.rowBytes+this.layout.lengthAt)}before(e,r){return this.offsetAt(e)-this.offsetAt(r)||this.lineAt(e)-this.lineAt(r)}wellFormed(e){let r=this.stampAt(e),t=this.offsetAt(e);return $t.test(this.keyAt(e))&&Number.isFinite(r)&&Number.isSafeInteger(t)&&t>=0&&this.lengthAt(e)>0&&(this.layout.format===1||this.memberBytesAt(e)>=he)}written(){return this.bytes.subarray(0,this.size*this.rowBytes)}},X=class{constructor(e,r){this.rows=e;let t=1024;for(;t<r*2;)t*=2;this.slots=new Uint32Array(t)}rows;slots;used=0;find(e){let r=this.slots.length-1;for(let t=ne(e)&r;;t=t+1&r){let n=this.slots[t];if(n===0)return-1;if(this.rows.holds(n-1,e))return n-1}}add(e){let r=this.rows.keyAt(e),t=this.find(r);return t>=0?t:((this.used+1)*2>this.slots.length&&this.grow(),this.place(e,r),this.used++,-1)}place(e,r){let t=this.slots.length-1,n=ne(r)&t;for(;this.slots[n]!==0;)n=n+1&t;this.slots[n]=e+1}grow(){let e=this.slots;this.slots=new Uint32Array(e.length*2);for(let r of e)r!==0&&this.place(r-1,this.rows.keyAt(r-1))}};async function V(o,e){try{return await W(o,"r")}catch(r){throw r.code!=="ENOENT"?r:new v("damaged",`The checkpoint\u2019s snapshot of ${e} is not on this machine.`)}}async function*Je(o,e){let r=await V(o,e);try{let t=Buffer.alloc(ze),n=Buffer.alloc(0),s=0,a=0,i=0;for(;;){let{bytesRead:c}=await r.read(t,0,ze,a);if(c===0)break;a+=c;let d=n.length>0?Buffer.concat([n,t.subarray(0,c)]):t.subarray(0,c),p=0;for(let f=d.indexOf(10);f>=0;f=d.indexOf(10,p))i++,f>p&&(yield{number:i,offset:s+p,length:f-p,text:d.toString("utf8",p,f)}),p=f+1;n=Buffer.from(d.subarray(p)),s+=p}n.length>0&&(yield{number:i+1,offset:s,length:n.length,text:n.toString("utf8")})}finally{await r.close()}}async function*Tt(o,e,r){let t=await V(o,e);try{let n=0;for await(let s of $e(t,(await t.stat()).size,r))for(let a of Te(s.lines))n++,a.length!==0&&(yield{number:n,offset:s.at,memberBytes:s.total,line:a.at,length:a.length,text:s.lines.toString("utf8",a.at,a.at+a.length)})}finally{await t.close()}}async function Ft(o){try{return await Mt(o),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Ke(o){let e=J(o);return e===null?Number.NaN:Date.parse(e)}function K(o){let e;try{e=JSON.parse(o)}catch{return}return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}async function zt(o,e){let r=`${o}.${process.pid}-${jt(4).toString("hex")}.tmp`,t=await W(r,"wx",z);try{try{await t.writeFile(e),await t.sync()}finally{await t.close()}await It(r,o)}catch(n){throw await vt(r,{force:!0}),n}}async function Dr(o,e,r){let t=Qe(o,e,r),n=$(t),s=await Ft(n)?2:1,a=oe(o,r),i=new Z(Ye[s]),c=new X(i,0),d=(m,A)=>new v("damaged",`The snapshot of ${r} holds ${A} at line ${m} of its file: it cannot be indexed.`),p=s===2?Tt(n,r,m=>new v("damaged",`The snapshot of ${r} ${m}: it cannot be indexed.`)):Je(t,r);for await(let m of p){let A=K(m.text);if(!A)throw d(m.number,"no record");let h=A.Id;if(typeof h!="string"||!F.test(h))throw d(m.number,"a record without its Id");let l=Ke(A.SystemModstamp);if(!Number.isFinite(l))throw d(m.number,`record ${h} without its SystemModstamp`);let b=i.push(h.slice(0,C),l,m);if(c.add(b)>=0)throw d(m.number,`record ${h} a second time`)}let f=Buffer.concat([i.layout.head,i.written()]);return await zt(a,f),{rows:i.size,bytes:f.length}}var _t=D({objectApiName:N().regex(ye).max(80),from:N().regex(F),to:N().regex(F)});async function Ze(o){let e;try{e=await W(o,"r"),await e.sync()}catch{}finally{await e?.close().catch(()=>{})}}var me=class o{constructor(e,r){this.current=e;this.original=r}current;original;static none=new o(new Map,new Map);static of(e){let r=new Map;for(let{from:n,to:s}of e)r.set(n.slice(0,C),s);let t=new Map;for(let[n,s]of r)t.set(s.slice(0,C),n);return new o(r,t)}static async read(e){let r;try{r=await we(se(e),"utf8")}catch(s){if(s.code==="ENOENT")return o.none;throw s}let t=r.split(`
|
|
9
|
+
`).slice(0,-1),n=[];for(let[s,a]of t.entries()){if(a==="")continue;let i;try{i=JSON.parse(a)}catch{i=void 0}let c=_t.safeParse(i);if(!c.success)throw new v("damaged",`The checkpoint\u2019s list of the records a rewind made again is damaged at line ${s+1}.`);n.push(c.data)}return o.of(n)}static async add(e,r){if(r.length===0)return;let t=se(e),n=r.map(({objectApiName:i,from:c,to:d})=>`${JSON.stringify({objectApiName:i,from:c,to:d})}
|
|
10
|
+
`).join(""),s=await W(t,"a",z),a=!1;try{a=(await s.stat()).size===0,await s.appendFile(n,"utf8"),await s.sync()}finally{await s.close()}a&&await Ze(Ge(t))}get empty(){return this.current.size===0}currentOf(e){return this.current.get(e)}originalOf(e){return this.original.get(e)}retired(e){return typeof e=="string"&&F.test(e)&&this.current.has(e.slice(0,C))}remapped(e){return typeof e!="string"||!F.test(e)?e:this.current.get(e.slice(0,C))??e}rowAsNow(e){if(this.empty)return e;let r={...e};for(let[t,n]of Object.entries(e)){if(t==="attributes")continue;let s=this.remapped(n);s!==n&&(r[t]=s)}return r}},qt=D({objectApiName:N().regex(ye).max(80),id:N().regex(F)}),qe=class o{constructor(e){this.held=e}held;static none=new o(new Set);static async read(e){let r;try{r=await we(ie(e),"utf8")}catch(n){if(n.code==="ENOENT")return o.none;throw n}let t=new Set;for(let n of r.split(`
|
|
11
|
+
`)){if(n==="")continue;let s;try{s=JSON.parse(n)}catch{continue}let a=qt.safeParse(s);a.success&&t.add(a.data.id.slice(0,C))}return new o(t)}static async add(e,r,t){if(t.length===0)return;let n=ie(e),s=t.map(c=>`${JSON.stringify({objectApiName:r,id:c})}
|
|
12
|
+
`).join(""),a=await W(n,"a",z),i=!1;try{i=(await a.stat()).size===0,await a.appendFile(s,"utf8"),await a.sync()}finally{await a.close()}i&&await Ze(Ge(n))}has(e){return this.held.has(e.slice(0,C))}keys(){return this.held.values()}},Ue=class o{constructor(e,r,t,n,s,a,i){this.objectApiName=e;this.snapshotId=r;this.snapshotFile=t;this.rows=n;this.byKey=s;this.recreated=a;this.extent=i}objectApiName;snapshotId;snapshotFile;rows;byKey;recreated;extent;static async read(e,r,t,n){let s=oe(e,t),a=h=>new v("damaged",`The checkpoint\u2019s index of ${t} ${h}.`),i;try{i=await we(s)}catch(h){throw h.code==="ENOENT"?a("is not on this machine"):h}let c=[ge,We].find(({head:h})=>i.length>=G&&i.subarray(0,G).equals(h));if(c===void 0||(i.length-G)%c.rowBytes!==0)throw a("is not an index of its snapshot");let d=Qe(e,r,t),p=c.format===2?$(d):d,f=new Z(c,i.subarray(G)),m=new X(f,f.size),A=0;for(let h=0;h<f.size;h++){if(!f.wellFormed(h))throw a(`is damaged at row ${h+1}`);if(m.add(h)>=0)throw a(`holds record ${f.keyAt(h)} twice`);c.format===2&&(A=Math.max(A,f.offsetAt(h)+f.memberBytesAt(h)))}return new o(t,r,p,f,m,n??await me.read(e),A)}get format(){return this.rows.layout.format}get size(){return this.rows.size}rowOf(e){if(typeof e!="string"||!F.test(e))return-1;let r=e.slice(0,C),t=this.recreated.originalOf(r);return t!==void 0?this.byKey.find(t):this.recreated.retired(e)?-1:this.byKey.find(r)}retired(e){return this.recreated.retired(e)&&this.byKey.find(String(e).slice(0,C))>=0}snapshotIdOf(e){let r=this.rowOf(e);if(r<0)return e;let t=this.rows.keyAt(r);return re(t)??t}has(e){return this.rowOf(e)>=0}stampOf(e){let r=this.rowOf(e);return r<0?void 0:this.rows.stampAt(r)}idAt(e){let r=this.rows.keyAt(e);return this.recreated.currentOf(r)??re(r)??r}chunk(e){if(e.length>Fe)throw new RangeError(`A chunk of the snapshot reads ${Fe} records at most; ${e.length} were asked.`);let r=new Set;for(let n of e){let s=this.rowOf(n);s>=0&&r.add(s)}let t=[...r].sort((n,s)=>this.rows.before(n,s));return{batches:async(n,s,a)=>{if(n!==this.snapshotId||s!==this.objectApiName)return null;let i=a>=1?Math.floor(a):1;return{[Symbol.asyncIterator]:()=>this.rowsAt(t,i)}}}}async*records(){if(this.size===0)return;if(this.format===2){let r=function*(t){for(let n=0;n<t;n++)yield n};for await(let t of this.compressedRowsAt(r(this.size),Lt))yield*t;return}let e=0;for await(let r of Je(this.snapshotFile,this.objectApiName)){let t=K(r.text);if(e>=this.size)throw this.moreThanIndexed();if(!t||!this.isRowOf(e,t))throw this.notWhereIndexed(e);yield this.recreated.rowAsNow(t),e++}if(e<this.size)throw this.notWhereIndexed(e)}notWhereIndexed(e){return new v("damaged",`The checkpoint\u2019s snapshot of ${this.objectApiName} does not hold record ${this.idAt(e)} where its index says: the file changed since the checkpoint was taken.`)}moreThanIndexed(){return new v("damaged",`The checkpoint\u2019s snapshot of ${this.objectApiName} holds more records than its index: the file changed since the checkpoint was taken.`)}async*rowsAt(e,r){if(e.length===0)return;if(this.format===2){yield*this.compressedRowsAt(e,r);return}let t=await V(this.snapshotFile,this.objectApiName);try{let n=Buffer.alloc(0),s=[];for(let a of e){let i=this.rows.lengthAt(a),c=this.rows.offsetAt(a);n.length<i&&(n=Buffer.alloc(Math.max(i,n.length*2)));let d=0;for(;d<i;){let{bytesRead:f}=await t.read(n,d,i-d,c+d);if(f===0)break;d+=f}let p=d===i?K(n.toString("utf8",0,i)):void 0;if(!p||!this.isRowOf(a,p))throw this.notWhereIndexed(a);s.push(this.recreated.rowAsNow(p)),s.length===r&&(yield s,s=[])}s.length>0&&(yield s)}finally{await t.close()}}async*compressedRowsAt(e,r){let t=s=>new v("damaged",`The checkpoint\u2019s snapshot of ${this.objectApiName} ${s}: the file changed since the checkpoint was taken.`),n=await V(this.snapshotFile,this.objectApiName);try{let s=(await n.stat()).size;if(s!==this.extent)throw t(`takes ${s} bytes where its index says ${this.extent}`);let a=-1,i=0,c=Buffer.alloc(0),d=[];for(let p of e){let f=this.rows.offsetAt(p);(f!==a||this.rows.memberBytesAt(p)!==i)&&(i=this.rows.memberBytesAt(p),c=await Le(n,f,i,t),a=f);let m=this.rows.lineAt(p),A=m+this.rows.lengthAt(p),l=A<=c.length&&(m===0||c[m-1]===10)&&(A===c.length||c[A]===10)?K(c.toString("utf8",m,A)):void 0;if(!l||!this.isRowOf(p,l))throw this.notWhereIndexed(p);d.push(this.recreated.rowAsNow(l)),d.length===r&&(yield d,d=[])}d.length>0&&(yield d)}finally{await n.close()}}isRowOf(e,r){let t=r.Id;return typeof t=="string"&&F.test(t)&&this.rows.holds(e,t.slice(0,C))&&Ke(r.SystemModstamp)===this.rows.stampAt(e)}},He=class{constructor(e){this.index=e;this.marked=new Uint8Array(Math.ceil(e.size/8))}index;marked;found=0;mark(e){let r=this.index.rowOf(e);if(r<0)return!1;let t=1<<(r&7),n=r>>>3;return(this.marked[n]&t)===0&&(this.marked[n]|=t,this.found++),!0}get count(){return this.index.size-this.found}*ids(){for(let e=0;e<this.index.size;e++)(this.marked[e>>>3]&1<<(e&7))===0&&(yield this.index.idAt(e))}};import{createReadStream as Ut}from"node:fs";import{appendFile as Ht,mkdir as Gt,rm as Wt,writeFile as Yt}from"node:fs/promises";import*as q from"node:path";import{createInterface as Qt}from"node:readline";var Jt="The org stopped answering before it said the read was done: some of its records were not read.",Xe=384,Kt=448;function Ve(o){let e=typeof o=="number"?o:Date.parse(o);if(!Number.isFinite(e))throw new Error(`Not a date: ${String(o)}`);let r=e-(e%1e3+1e3)%1e3;return new Date(r).toISOString().replace(/\.\d{3}Z$/,"Z")}function be(o){let e=Date.parse(o);if(!Number.isFinite(e))throw new Error(`Not a date: ${o}`);return Ve(e-Be)}function et(o,e){return[...new Set([...o,...e.map(Oe)])].join(", ")}function Ae(o,e,r,t){let n=I(o),s=[t,e==="scanAllLive"?"IsDeleted = false":void 0].filter(a=>a!==void 0);return{objectApiName:n,soql:`SELECT ${r} FROM ${n}${s.length>0?` WHERE ${s.join(" AND ")}`:""}`,scanAll:e==="scanAllLive"}}function Zt(o){let e=I(o);return{objectApiName:e,soql:`SELECT SystemModstamp FROM ${e} ORDER BY SystemModstamp DESC LIMIT 1`,scanAll:!0}}var Xt=["Id","SystemModstamp","CreatedDate","LastModifiedDate","LastModifiedById"],Vt=["Id","SystemModstamp","CreatedDate"];function er(o,e,r,t=[]){return Ae(o,e,et(Xt,t),`SystemModstamp >= ${be(r)}`)}function tr(o,e,r=[]){let t=I(o);return{objectApiName:t,soql:`SELECT ${et(Vt,r)} FROM ${t} WHERE IsDeleted = true AND SystemModstamp >= ${be(e)}`,scanAll:!0}}function rr(o,e){return Ae(o,e,"COUNT()")}function Wr(o,e){let r=I(o);return{objectApiName:r,soql:`SELECT Id FROM ${r} WHERE IsDeleted = true AND SystemModstamp < ${Ve(e)}`,scanAll:!0}}function Yr(o,e){return Ae(o,e,"Id")}async function nr(o,e,r){let t,n,s={query:async i=>{let c=await o.query(i,{scanAll:e.scanAll});return t=c,n=c.totalSize,c},queryMore:async i=>(t=await o.queryMore(i),t)},a=0;try{for await(let i of Pe(s,e.soql))await r(i),a+=i.length}catch(i){if(i instanceof j)throw i;return{objectApiName:e.objectApiName,read:!1,rows:a,reason:L(i)}}return t?.done!==!0?{objectApiName:e.objectApiName,read:!1,rows:a,reason:Jt}:{objectApiName:e.objectApiName,read:!0,rows:a,...n!==void 0?{totalSize:n}:{}}}async function Ee(o,e,r,t,n={}){let s=n.oneRow===!0,a=new Array(e.length),i=async m=>{let A=e.slice(m,m+_),h=A.map(()=>o.lane({oneRow:s})),l=await Promise.allSettled(A.map(async(b,S)=>{let B=h[S];try{return await nr(B,b,O=>r(m+S,O))}finally{B.close()}}));for(let[b,S]of l.entries()){if(S.status==="rejected")throw S.reason instanceof Error?S.reason:new Error(String(S.reason));a[m+b]=S.value}},c=0,d=async()=>{for(;c<e.length;){if(t?.aborted)throw new j;let m=c;c+=_,await i(m)}},p=Math.ceil(e.length/_),f=await Promise.allSettled(Array.from({length:Math.min(s?de:1,p)},d));for(let m of f)if(m.status==="rejected")throw m.reason instanceof Error?m.reason:new Error(String(m.reason));if(t?.aborted)throw new j;return a}function or(o){return`${JSON.stringify(Object.fromEntries(Object.entries(o).filter(([e])=>e!=="attributes")))}
|
|
13
|
+
`}async function sr(o,e,r){for(let n of e)await Gt(q.dirname(n.file),{recursive:!0,mode:Kt}),await Yt(n.file,"",{encoding:"utf8",mode:Xe});let t=await Ee(o,e,async(n,s)=>{s.length!==0&&await Ht(e[n].file,s.map(or).join(""),{encoding:"utf8",mode:Xe})},r);return await Promise.all(t.map((n,s)=>n.read?void 0:Wt(e[s].file,{force:!0}))),t}async function*Qr(o){let e=Ut(o,{encoding:"utf8"}),r=Qt({input:e,crlfDelay:1/0});try{for await(let t of r){if(t==="")continue;let n=JSON.parse(t);if(typeof n!="object"||n===null||Array.isArray(n))throw new Error(`${q.basename(o)} holds a line that is no record.`);yield n}}finally{r.close(),e.destroy()}}async function ir(o,e,r,t){let n=Date.parse(be(r)),s=[];return(await Ee(o,e.map(Zt),(i,c)=>{c.length>0&&(s[i]=c[0].SystemModstamp)},t,{oneRow:!0})).map((i,c)=>{if(!i.read)return{objectApiName:i.objectApiName,unread:i.reason};if(s[c]===void 0)return{objectApiName:i.objectApiName,latest:null,moved:!1};let d=J(s[c]);return d===null?{objectApiName:i.objectApiName,unread:`${i.objectApiName} answered a SystemModstamp that is not a date.`}:{objectApiName:i.objectApiName,latest:d,moved:Date.parse(d)>=n}})}async function ar(o,e,r){return(await Ee(o,e.map(({objectApiName:n,readMode:s})=>rr(n,s)),()=>{},r,{oneRow:!0})).map(n=>n.read?n.totalSize===void 0?{objectApiName:n.objectApiName,unread:"The org gave no count of its records."}:{objectApiName:n.objectApiName,count:n.totalSize}:{objectApiName:n.objectApiName,unread:n.reason})}function cr(o,e){return q.join(o,`${I(e)}.live.ndjson`)}function dr(o,e){return q.join(o,`${I(e)}.deleted.ndjson`)}async function Jr(o,e,r,t,n,s){if(s!==void 0&&s.length!==e.length)throw new Error(`${s.length} pre-checks for ${e.length} objects`);let a=s??await ir(o,e.map(({objectApiName:l})=>l),r,n),i=new Map,c=[];a.forEach((l,b)=>{"unread"in l?i.set(b,l.unread):l.moved&&c.push(b)});let d=c.flatMap(l=>{let{objectApiName:b,readMode:S,fields:B=[]}=e[l],O=I(b);return[{...er(O,S,r,B),file:cr(t,O)},{...tr(O,r,B),file:dr(t,O)}]}),p=await sr(o,d,n),f=new Map;c.forEach((l,b)=>{let S=p[b*2],B=p[b*2+1],O=[S,B].find(Y=>!Y.read);if(O&&!O.read){i.set(l,O.reason);return}f.set(l,{live:{file:d[b*2].file,rows:S.rows},deleted:{file:d[b*2+1].file,rows:B.rows}})});let m=e.map((l,b)=>({object:l,index:b})).filter(({object:l,index:b})=>!i.has(b)&&(f.has(b)||l.held)).map(({index:l})=>l),A=await ar(o,m.map(l=>e[l]),n),h=new Map;return m.forEach((l,b)=>{let S=A[b];"unread"in S?i.set(l,S.unread):h.set(l,S.count)}),a.map((l,b)=>{if("unread"in l)return l;let S=i.get(b);if(S!==void 0)return{objectApiName:l.objectApiName,unread:S};let B=f.get(b),O=h.get(b);return{objectApiName:l.objectApiName,latest:l.latest,moved:l.moved,...B?.live?{live:B.live}:{},...B?.deleted?{deleted:B.deleted}:{},...O!==void 0?{count:O}:{}}})}export{rt as a,nt as b,lr as c,ur as d,_ as e,ce as f,de as g,mr as h,j as i,wr as j,kr as k,Fe as l,Mr as m,Qe as n,Dr as o,me as p,qe as q,Ue as r,He as s,Ve as t,be as u,rr as v,Wr as w,Yr as x,nr as y,Ee as z,sr as A,Qr as B,ir as C,ar as D,cr as E,dr as F,Jr 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}from"./chunk-
|
|
7
|
+
import{a,b}from"./chunk-OZNLOV4U.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as FakerFallback,b as generateByMethod};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-T3PLRQ2T.mjs";import"./chunk-5WGA5CZB.mjs";import"./chunk-NWVVCZUK.mjs";import"./chunk-HYBH5PFM.mjs";import"./chunk-OVOLG3AL.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-KNIRA333.mjs";import"./chunk-MNITSYI2.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as AGENT_TEST_RUN_WAIT_MINUTES,a as AGENT_TEST_SPECS_DIR,e as agentTestApiName,f as agentTestCommands,d as agentTestSpecFileName,c as agentTestSpecYaml,g as nodeAgentTestSpecFiles,h as writeAgentTestSpec,i as writeScenarioTestSpec,j as yamlOf};
|
|
@@ -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{
|
|
7
|
+
import{i as u,j as f}from"./chunk-DPYTG6DM.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};
|
|
@@ -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{
|
|
7
|
+
import{Nd as s,Od as d}from"./chunk-DPYTG6DM.mjs";function c(l,e){return l.type==="condition"&&e.status==="completed"&&e.output?.conditionMet===!1}var f=class{evaluate(e,n){return d(e,n)}check(e){return s(e)}evaluateGroup(e,n){return e.length===0?!0:e.some(t=>t.logicalGroup==="or")?e.some(t=>this.evaluate(t,n)):e.every(t=>this.evaluate(t,n))}getNextStep(e,n){if(n.status==="completed")return c(e,n)?e.onFailure:e.onSuccess;if(n.status==="failed")return e.onFailure}endsRun(e,n){return c(e,n)&&!e.onFailure}findBranch(e,n,o){let t=new Map(e.map(r=>[r.id,r])),u=[],a=new Set,i=n,p=t.get(i);if(!p)return u;for(i=o?p.onSuccess:p.onFailure;i&&!a.has(i);){a.add(i);let r=t.get(i);if(!r)break;u.push(r),i=o?r.onSuccess:r.onFailure}return u}};export{f 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{a as T,b as F,d as B,k as R}from"./chunk-
|
|
7
|
+
import{a as T,b as F,d as B,k as R}from"./chunk-MAHZMPMZ.mjs";import{b as j,l as x,o as N}from"./chunk-UIUPPEFB.mjs";import{a as L,f as C,i as $,j as _}from"./chunk-54HYHHVL.mjs";import{a as I}from"./chunk-4TLYUZD5.mjs";import{b as P}from"./chunk-CA5NAXSU.mjs";import{Tc as A}from"./chunk-DPYTG6DM.mjs";var w=class{byObject=new Map;add(e){let t=this.byObject.get(e.objectApiName);t||(t=new Map,this.byObject.set(e.objectApiName,t));let s=t.get(e.recordId),r=s?.[e.fieldName];if(r!==void 0&&r!==e.value)return{taken:!1,kept:r};let n=s??{Id:e.recordId};return n[e.fieldName]=e.value,t.set(e.recordId,n),{taken:!0}}updates(){return[...this.byObject].map(([e,t])=>[e,[...t.values()]])}};var J="DUPLICATES_DETECTED",X=3,Y=2e3;function Z(i){return new Promise(e=>setTimeout(e,i))}function z(i){let e=i.errorDetails??[];return N(i.errors,e.length===i.errors.length?e:void 0)}function q(i){let e=i.errorDetails;return e?.length!==1||e[0].statusCode===J||z(i)}function Q(i){let e=Object.keys(i).find(s=>s!=="Id"),t=e===void 0?void 0:i[e];return typeof t=="string"?t:""}function U(i){return{objectApiName:i,op:"update"}}function V(i){let e=i.automation??"the target's automation";I.warn(`[forge] ${i.objectApiName}: ${e} hit ${i.limit??"a Salesforce limit"} on an update of ${i.from} records \u2014 sending a record on its own, then smaller calls.`)}function y(i){return Object.keys(i).filter(e=>e!=="Id").length}async function fe(i){if(!i.enabled||!i.updateRecords||i.pendingFkUpdates.length===0)return null;let e=new E(i);return await e.patch(i.pendingFkUpdates),e.finish()}var ee=1024,te=.6;function K(i){let e=2166136261;for(let t=0;t<i.length;t++)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0}function M(i){let e=2538058380;for(let t=0;t<i.length;t++)e=Math.imul(e^i.charCodeAt(t),1540483477),e^=e>>>15;return e>>>0}var H=class{capacity=ee;used=0;h1=new Uint32Array(this.capacity);h2=new Uint32Array(this.capacity);firstPart=new Float64Array(this.capacity);several=new Uint8Array(this.capacity);note(e,t){let s=K(t),r=M(t),n=this.find(s,r);if(n>=0){this.firstPart[n]!==e+1&&(this.several[n]=1);return}this.used+1>this.capacity*te&&this.grow();let o=this.freeSlotFor(r);this.h1[o]=s,this.h2[o]=r,this.firstPart[o]=e+1,this.used++}spans(e){let t=this.find(K(e),M(e));return t>=0&&this.several[t]===1}find(e,t){let s=this.capacity-1;for(let r=t&s;;r=r+1&s){if(this.firstPart[r]===0)return-1;if(this.h1[r]===e&&this.h2[r]===t)return r}}freeSlotFor(e){let t=this.capacity-1,s=e&t;for(;this.firstPart[s]!==0;)s=s+1&t;return s}grow(){let{h1:e,h2:t,firstPart:s,several:r}=this;this.capacity*=2,this.h1=new Uint32Array(this.capacity),this.h2=new Uint32Array(this.capacity),this.firstPart=new Float64Array(this.capacity),this.several=new Uint8Array(this.capacity);for(let n=0;n<s.length;n++){if(s[n]===0)continue;let o=this.freeSlotFor(t[n]);this.h1[o]=e[n],this.h2[o]=t[n],this.firstPart[o]=s[n],this.several[o]=r[n]}}},E=class{constructor(e){this.input=e;this.splits=e.splitting!==void 0,this.splitting=e.splitting??L(0),this.bulkUnsupported=e.bulkUnsupported??new Set}input;resolvedCount=0;unresolvedCount=0;insertOnlyLost=0;unresolved=[];pass2Failed=0;pass2Samples=[];notSent=0;notSentObjects=new Set;cancelled=!1;handed=0;held=new w;splitting;splits;bulkUnsupported;backoff=new x({initialDelay:Y});limitOf(e){return this.splits&&e&&!e.success?A(e.errors):void 0}async patch(e,t){let{input:s}=this;if(!s.enabled||!s.updateRecords||e.length===0)return;this.handed+=e.length;let r=new w;for(let n of e)this.take(n,t?.(n)===!0?this.held:r);await this.send(r)}async sendHeld(){await this.send(this.held)}take(e,t){let{input:s}=this,{remapper:r}=s,n=r.get(e.sourceRefId);if(!n){if(s.deferUnresolved){s.stillPending?.push(e);return}if(s.outsideTheSample?.(e)){s.onLeftOutsideTheSample?.(e.objectApiName,e.fieldName);return}this.unresolvedCount++,this.unresolved.length<3&&this.unresolved.push({recordSummary:`${e.objectApiName} source=${e.sourceId??"?"} target=${e.newId} ${e.fieldName}=<source ${e.sourceRefId}>`,messages:[`Cycle FK '${e.fieldName}' could not be resolved \u2014 referenced parent (source ${e.sourceRefId}) was not cloned`]});return}if(e.insertOnly){this.insertOnlyLost++,this.unresolved.length<3&&this.unresolved.push({recordSummary:`${e.objectApiName} source=${e.sourceId??"?"} target=${e.newId} ${e.fieldName}`,messages:[`Lookup '${e.fieldName}' left empty: only an insert sets it, and the record it names (source ${e.sourceRefId}) was written after this one`]});return}let o=t.add({objectApiName:e.objectApiName,recordId:e.newId,fieldName:e.fieldName,value:n});if(!o.taken){this.unresolvedCount++,this.unresolved.length<3&&this.unresolved.push({recordSummary:`${e.objectApiName} source=${e.sourceId??"?"} target=${e.newId} ${e.fieldName}`,messages:[`Conflicting cycle FK update for ${e.fieldName}: ${String(o.kept)} vs ${n}`]});return}this.resolvedCount++}async send(e){for(let[t,s]of e.updates()){if(this.jobsFor(t,s.length)){await this.sendAsJobs(t,s);continue}await this.sendObject(t,s)}}jobsFor(e,t){let{input:s}=this;return s.bulkUpdate!==void 0&&t>=2e3&&s.restOnly?.has(e)!==!0&&!this.bulkUnsupported.has(e)}leaveNotSent(e,t){for(let s of t)this.notSent+=y(s);t.length>0&&this.notSentObjects.add(e)}async sendObject(e,t,s,r){let{input:n}=this,{targetOrgId:o}=n,d=n.updateRecords;if(!d||t.length===0)return;let c=()=>(this.cancelled||(this.cancelled=n.stopped?.()===!0),this.cancelled);if(c()){this.leaveNotSent(e,t);return}let l,a=await _(t,{key:U(e),sizes:this.splitting.sizes,allowance:this.splitting.allowance,maxSize:B.rest,...r,beforeEachSend:()=>c()?"stop":void 0,send:async p=>{try{return{answers:await d(o,e,[...p])}}catch(h){return l={error:h},{answers:[]}}},limited:p=>this.limitOf(p),settle:(p,h,k,S)=>{let v=l;l=void 0,v?this.callThrew(e,p,v.error):this.settleAnswers(e,p,h,k,S,s),n.onAnswered?.()},onFirstRefusal:V});a.stopped&&this.leaveNotSent(e,[...a.stopped.part,...a.stopped.rest])}settleAnswers(e,t,s,r,n,o){let{input:d}=this;for(let c=0;c<t.length;c++){if(r.has(c))continue;let l=s[c];l?l.success?d.onPatched?.(e,t[c]):o&&z(l)?o.push(t[c]):this.refused(e,t[c],l,n.get(c)):(this.pass2Failed+=y(t[c]),this.pass2Samples.length<3&&this.pass2Samples.push({recordSummary:R(t[c]),messages:[`No result returned for record (API truncated batch: ${s.length}/${t.length})`]}))}}refused(e,t,s,r){this.tellRefusedByFilter(e,t,s),this.pass2Failed+=y(t),this.pass2Samples.length<3&&this.pass2Samples.push({recordSummary:R(t),messages:r===void 0?s.errors:[...s.errors,C(r,$(this.splitting.allowance,U(e)),"run")]})}callThrew(e,t,s){for(let r of t)this.pass2Failed+=y(r);this.pass2Samples.length<3&&this.pass2Samples.push({recordSummary:`${e} batch failed`,messages:[P(s)]})}async sendAsJobs(e,t){let{input:s}=this,r=s.bulkUpdate;if(!r)return;let n=t.map((l,a)=>({record:l,at:a,value:Q(l)})).sort((l,a)=>l.value===a.value?l.at-a.at:l.value<a.value?-1:1).map(({record:l})=>l),o=U(e),{sizes:d,allowance:c}=this.splitting;for(let l=0;l<n.length;l+=F){let a=n.slice(l,l+F);if(this.cancelled||(this.cancelled=s.stopped?.()===!0),this.cancelled){this.leaveNotSent(e,a);continue}let p=d.of(o);if(p<200){let u=Math.ceil(a.length/p),f=c.take(o,u);d.countExtraCalls(o,f);let m=a.slice(0,f*p);try{await this.sendObject(e,m,void 0,{pricedAs:"job",paid:{calls:f}})}finally{f<u&&d.spend(o)}if(f===u)continue;if(a=a.slice(m.length),this.cancelled){this.leaveNotSent(e,a);continue}if(a.length<2e3){await this.sendObject(e,a);continue}}let h;try{h=await r(e,a)}catch(u){if(!(u instanceof T)){await this.sendObject(e,a);continue}for(let f of a)this.pass2Failed+=y(f);this.pass2Samples.length<3&&this.pass2Samples.push({recordSummary:`${e}: a Bulk API job of ${a.length} updates was lost`,messages:[P(u),"The target may hold any of these lookups: they are counted as left empty."]}),s.onAnswered?.();continue}if(h.aborted){this.cancelled=!0,this.leaveNotSent(e,a);continue}if(h.untouched){h.untouched.unsupported&&this.bulkUnsupported.add(e),await this.sendObject(e,a);continue}let k=[],S=[],v=[],b;a.forEach((u,f)=>{let m=h.rows[f]??"unprocessed",g=h.answers[f],O=m==="answered"?this.limitOf(g):void 0;O&&g?(b??=O,S.push(u),v.push(g)):m==="answered"&&g?.success?s.onPatched?.(e,u):m==="may-have-written"?(this.pass2Failed+=y(u),this.pass2Samples.length<3&&this.pass2Samples.push({recordSummary:R(u),messages:["The Bulk API job may have written this update without saying so."]})):m!=="answered"||!g||q(g)?k.push(u):this.refused(e,u,g)}),s.onAnswered?.(),await this.sendAgainByRest(e,k),await this.sendObject(e,S,void 0,{refusedIn:{from:200,answers:v,...b?{cause:b}:{}}})}}async sendAgainByRest(e,t){let s=t;for(let r=0;s.length>0;r++){r>0&&await(this.input.wait??Z)(this.backoff.calculateDelay(r-1));let n=[];await this.sendObject(e,s,r<X-1?n:void 0),s=n}}tellRefusedByFilter(e,t,s){let r=this.input.onRefusedByFilter,n=t.Id;if(!r||typeof n!="string")return;let o=new Set((s.errorDetails??[]).filter(d=>d.statusCode===j).flatMap(d=>d.fields));for(let d of Object.keys(t))d!=="Id"&&o.has(d)&&r(e,d,n)}finish(){let{resolvedCount:e,unresolvedCount:t,insertOnlyLost:s,pass2Failed:r,notSent:n}=this;if(this.handed===0)return null;let o=e+t+s;if(this.input.deferUnresolved&&e===0&&r===0&&s===0)return null;let d=r+t+s+n;if(this.input.onProgress({objectName:"__pass2__",status:d>0?"error":"done",progress:100,message:`Pass 2 (cycle FK update): ${e-r-n}/${o} resolved`+(n>0?`; cancelled with ${n} not sent`:"")}),d>0){let c=n>0?[{recordSummary:`${[...this.notSentObjects].join(", ")}: ${n} lookup${n===1?"":"s"} not sent`,messages:["The run was cancelled before they were filled in: they stay empty."]}]:[];return{objectApiName:"__pass2__",stage:"insert",failedCount:d,attemptedCount:o,samples:[...c,...this.pass2Samples,...this.unresolved].slice(0,3)}}return null}};export{w as a,fe as b,H as c,E as d};
|
|
@@ -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}from"./chunk-MWLFFVQV.mjs";import"./chunk-YIGFYZQY.mjs";import"./chunk-2Z54GB6X.mjs";import"./chunk-R6TF26V4.mjs";import"./chunk-V4RKM4QZ.mjs";import"./chunk-JU2XEKEO.mjs";import"./chunk-OMZJ37JI.mjs";import"./chunk-43K2C6H2.mjs";import"./chunk-FSZTXLNW.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-WB2RIVO3.mjs";import"./chunk-CAFUNR6D.mjs";import"./chunk-AITNZWLB.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-OEHVAJAB.mjs";import"./chunk-GWRKS3AL.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-6SEDOIO3.mjs";import"./chunk-ZWCRWF7E.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-MNITSYI2.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-ETT5GP4P.mjs";import"./chunk-SW2NUKQL.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-E2YJVSX6.mjs";import"./chunk-T26C576X.mjs";import"./chunk-BNO5GIJ6.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-SQGP46QS.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-6IGEASOF.mjs";import"./chunk-KOQV4WXC.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-CULAOP3U.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-KRNFVAGC.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-2OIRJEYE.mjs";import"./chunk-XEB6HZ34.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-ZUA5BNAO.mjs";import"./chunk-RKALOKAU.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-55LQD3Y3.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-3B5H24ZG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-EAFLDSQ2.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{d as CheckpointTakeStopped,a as DEFAULT_MAX_TOTAL,b as OBJECT_ROWS_MAX,f as holdingLimit,e as pastTheLimit,g as scopeCheckpoint,h as takeCheckpoint,c as takeOrgOf};
|
|
@@ -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 b}from"./chunk-Y5ZCPY36.mjs";import"./chunk-YCSFP6ER.mjs";import{a}from"./chunk-GYKNCYES.mjs";import"./chunk-YOGMP72T.mjs";import"./chunk-6CDIIFNX.mjs";import"./chunk-MWLFFVQV.mjs";import"./chunk-YIGFYZQY.mjs";import"./chunk-2Z54GB6X.mjs";import"./chunk-R6TF26V4.mjs";import"./chunk-V4RKM4QZ.mjs";import"./chunk-JU2XEKEO.mjs";import"./chunk-K55LH4ZQ.mjs";import"./chunk-OMZJ37JI.mjs";import"./chunk-43K2C6H2.mjs";import"./chunk-FSZTXLNW.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-WB2RIVO3.mjs";import"./chunk-CAFUNR6D.mjs";import"./chunk-AITNZWLB.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-OEHVAJAB.mjs";import"./chunk-GWRKS3AL.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-6SEDOIO3.mjs";import"./chunk-ZWCRWF7E.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-MNITSYI2.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-ETT5GP4P.mjs";import"./chunk-SW2NUKQL.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-E2YJVSX6.mjs";import"./chunk-T26C576X.mjs";import"./chunk-BNO5GIJ6.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-SQGP46QS.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-6IGEASOF.mjs";import"./chunk-KOQV4WXC.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-CULAOP3U.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-KRNFVAGC.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-2OIRJEYE.mjs";import"./chunk-XEB6HZ34.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-ZUA5BNAO.mjs";import"./chunk-RKALOKAU.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-55LQD3Y3.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-3B5H24ZG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-EAFLDSQ2.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as objectsWrittenBy,b as previewCheckpoint};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a}from"./chunk-
|
|
7
|
+
import{a}from"./chunk-TPHXRHOA.mjs";import"./chunk-BWWQXU2B.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-55LQD3Y3.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as readSyncRecordTypes};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e,f,g,h}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e,f,g,h}from"./chunk-OU5W7SCB.mjs";import"./chunk-HYBH5PFM.mjs";import"./chunk-K77NR3UK.mjs";import"./chunk-OVOLG3AL.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-BNO5GIJ6.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{d as ARTICLE_OBJECT,b as CASE_STATUS_BY_LABEL_SOQL,a as CASE_STATUS_SOQL,g as prepareScenario,c as readScenarioCaseStatus,f as scenarioCasePicklists,e as scenarioKnowledge,h as toolingQueryAll};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e}from"./chunk-ZUA5BNAO.mjs";import"./chunk-RKALOKAU.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as FieldMappingService,b as MOVES_ITS_SOURCE,e as mapFields,c as mappedTargets,d as notSentAsRead};
|
|
@@ -4,6 +4,6 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{c as B}from"./chunk-BOGNK4LV.mjs";import{
|
|
7
|
+
import{c as B}from"./chunk-BOGNK4LV.mjs";import{d as k,e as A,f as b}from"./chunk-6IGEASOF.mjs";import{Rb as D,Sb as P,Tb as O,Yb as S,dc as v,hc as x,kc as L}from"./chunk-KOQV4WXC.mjs";import{da as w}from"./chunk-55LQD3Y3.mjs";import{Hd as p,rd as R,sd as g,zd as f}from"./chunk-DPYTG6DM.mjs";var C=["undelete","insert","update","delete"],M={SingleEmail:{one:"single email",more:"single emails"},DailyWorkflowEmails:{one:"workflow email",more:"workflow emails"}};function U(e,t){let n=M[t];return`${e} ${e===1?n.one:n.more}`}var I={rewind:{what:"This rewind",then:"rewind again"},undo:{what:"This undo",then:"undo the rewind again"}};function _(e){return e.toGiveBack.records+e.toBringBack.inBin+e.toBringBack.withParent}var N="Order";function T(e){return e.toDelete.createdSince+e.toDelete.broughtBackSince+e.toDelete.comesBackWithParent+(e.toBringBack.carriers??0)}function $(e){return e.objectApiName===N?T(e):0}function W(e){return e.deleted+e.withParentDeleted+e.nextPassDeleted}function F(e){return e.objectApiName===N?W(e):0}function G(e){return w[e.objectApiName]!==void 0?e.toRecreate??0:0}function j(e){return w[e.objectApiName]!==void 0?e.recreated:0}function K(e){return e.flatMap(t=>h(t.objectApiName,{undelete:t.toBringBack.inBin+t.toBringBack.withParent+t.toBringBack.deletedWhileTaken+(t.toBringBack.carriers??0),insert:t.toRecreate??0,update:_(t)+G(t)+$(t),delete:T(t)}))}function Z(e){return e.flatMap(t=>h(t.objectApiName,{undelete:t.broughtBack+t.backWithParent+(t.carriers??0),insert:t.recreated,update:t.givenBackFirst+t.givenBackAfter+t.givenBackNextPass+j(t)+F(t),delete:W(t)}))}function ee(e,t=[],n=[]){let i=a=>{let o=new Map;for(let{objectApiName:m,count:d}of a)o.set(m,(o.get(m)??0)+d);return o},c=i(t),s=i(n);return[...new Set([...e.map(a=>a.objectApiName),...c.keys(),...s.keys()])].flatMap(a=>{let o=e.find(m=>m.objectApiName===a);return h(a,{undelete:o?.deleted??0,insert:0,update:(o?.givenBack??0)+(s.get(a)??0),delete:(o?.broughtBack??0)+(c.get(a)??0)})})}function h(e,t){return C.filter(n=>t[n]>0).map(n=>({objectApiName:e,write:n,records:t[n]}))}function te(e,t){let n=new Set(e.filter(i=>i.records>0).map(i=>`${i.objectApiName}
|
|
8
8
|
${i.write}`));return S(t,(i,c)=>n.has(`${i}
|
|
9
9
|
${c}`),"the org's")}function ne(e,t){return t===void 0?"":`The emails it sends as the ${e} writes were not counted against its daily limits, as what sends them was not read (${t}). `}function y(e){return typeof e.unread=="string"}function ie(e,t,n){let i=!y(n)&&D(n),c=!y(n)&&P(n),s=new Map;for(let r of C){let a=R(t,r);if(a.length===0)continue;let o=O(a,i,c),m=new Set(a.filter(d=>d.limit==="DailyWorkflowEmails").map(d=>d.objectApiName));for(let{objectApiName:d,records:E}of e.filter(l=>l.write===r))for(let l of o.filter(u=>u.objectApiName===d)){let u=s.get(l.limit)??{limit:l.limit,emails:0,objects:[],verdict:"fits"};u.emails+=E*l.perRecord,u.objects.push({objectApiName:d,write:r,records:E,perRecord:l.perRecord,sentBy:[...l.sentBy]}),i&&l.limit==="SingleEmail"&&m.has(d)&&(u.alertsCounted=!0),s.set(l.limit,u)}}return[...s.values()].map(r=>{if(y(n))return{...r,verdict:"unread",unread:n.unread};let a=n[r.limit];return a?{...r,verdict:r.emails>a.remaining?"exceeds":"fits",remaining:a.remaining,max:a.max}:{...r,verdict:"unread",unread:`the org's limits list no ${r.limit}`}})}function re(e,t,n){let i=t.filter(r=>r.verdict==="exceeds");if(i.length===0)return;let c=i.map(r=>`about ${U(r.emails,r.limit)}`+(r.alertsCounted?" (its email alerts among them, as a Developer Edition counts them)":"")+`, ${r.remaining??0} of ${r.max??0} left today`).join("; "),s=I[e];return{code:"EMAILS",message:`${s.what} would make ${n} send ${c}: 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. Turn off what sends them, or assign the user a bypass that keeps it quiet, then ${s.then}. No record was written.`}}function ae(e){let t=f(e.steps),n=g(p(e.automation,e.plan,t),{writes:t}),i=v(e.automation.unread);return{senders:n,...i!==void 0?{sendersUnread:i}:{}}}function q(e){let t=e.mayMute&&e.plan===void 0&&e.senders.length>0?A(e.automation,{writes:f(e.steps)}):[],n=x({senders:e.senders,...e.sendersUnread!==void 0?{sendersUnread:e.sendersUnread}:{},...e.reading!==void 0?{reading:e.reading}:{},accepted:e.accepted,target:e.orgName,run:e.act,muteQuiets:t,keepsAddresses:!0});return n.stop?{gate:n,refusal:{code:"EMAILS_DELIVERED",message:n.stop.message}}:{gate:n}}async function se(e){let t=f(e.steps),n=await k({running:p(e.automation,e.plan,t),writes:t,read:e.read});return{ofRun:n,...q({...e,senders:n.senders,...n.sendersUnread!==void 0?{sendersUnread:n.sendersUnread}:{},...n.read!==void 0?{reading:n.read.reading}:{}})}}function oe(e){let t=f(e.steps),n=g(p(e.automation,b(e.plan,e.held),t),{writes:t}),i=L({planned:e.planned,held:n,...e.reading!==void 0?{reading:e.reading}:{},accepted:e.accepted,target:e.orgName,run:e.act});return i?{code:"EMAILS_DELIVERED",message:i.message}:void 0}var Q=", or run it again once the lease can assign them",V="--mute-automation keeps quiet";function de(e,t,n){if(e.code!=="EMAILS_DELIVERED")return e;let i=t==="undo"?"Tick the box for these emails in the undo's confirmation to undo all the same":e.message.includes(Q)?"Untick Mute automation to be asked about them and rewind all the same":`Tick "Let ${n} send these emails" in the preview to rewind all the same`;return{...e,message:B(e.message,t,i).replace(V,"Mute automation keeps quiet")}}export{U as a,_ as b,$ as c,F as d,G as e,j as f,K as g,Z as h,ee as i,te as j,ne as k,ie as l,re as m,ae as n,q as o,se as p,oe as q,de as r};
|
|
@@ -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{i as E}from"./chunk-
|
|
7
|
+
import{i as E}from"./chunk-YOGMP72T.mjs";import{b as j,c as S,e as U,m as O,n as P,o as C}from"./chunk-GWRKS3AL.mjs";import{da as N}from"./chunk-55LQD3Y3.mjs";import{h as B}from"./chunk-EAFLDSQ2.mjs";import{od as A,wd as y}from"./chunk-DPYTG6DM.mjs";var h="No record was written.",l=e=>e.toLocaleString("en-US"),D=e=>e.toDelete.createdSince+e.toDelete.broughtBackSince+e.toDelete.comesBackWithParent,$=e=>e.toBringBack.inBin+e.toBringBack.withParent+e.toBringBack.deletedWhileTaken,k=e=>e.toRecreate??0,v=e=>e.toBringBack.carriers??0;function L(e){let n=t=>D(t)+t.toGiveBack.records+$(t)+v(t)+k(t)>0,o=e.objects.filter(n).map(t=>t.objectApiName),a=e.files;return a!==void 0&&a.unlink+a.relink+a.updateLinks>0&&o.push(B),o}function M(e){return e.objects.reduce((n,o)=>({toDelete:n.toDelete+D(o),toGiveBack:n.toGiveBack+o.toGiveBack.records,toBringBack:n.toBringBack+$(o),toRecreate:n.toRecreate+k(o)}),{toDelete:0,toGiveBack:0,toBringBack:0,toRecreate:0})}function te(e,n){let o=new Set(n.objects),a=new Map(n.acts.map(i=>[i.objectApiName,i]));return{...E(e,o),objects:e.objects.filter(i=>o.has(i.objectApiName)||a.has(i.objectApiName)).map(i=>{let s=a.get(i.objectApiName),r=o.has(i.objectApiName);return{...i,toDelete:{createdSince:s?.toDelete??0,broughtBackSince:0,comesBackWithParent:0},toGiveBack:{...i.toGiveBack,records:s?.toGiveBack??0},toBringBack:{inBin:s?.toBringBack??0,withParent:0,deletedWhileTaken:0,...r&&i.toBringBack.carriers!==void 0?{carriers:i.toBringBack.carriers}:{}},toRecreate:s?.toRecreate??0,cannotUndo:r?i.cannotUndo:[],unexplained:r?i.unexplained:0}}),undoCannot:[...n.undoCannot]}}function W(e){let n=e.objects.filter(t=>D(t)+v(t)>0).map(t=>t.objectApiName),o=e.files,a=(t,i)=>i>0?[...t,B]:t;return{bringBack:e.objects.filter(t=>$(t)+v(t)>0).map(t=>t.objectApiName),recreate:a(e.objects.filter(t=>k(t)>0).map(t=>t.objectApiName),o?.relink??0),giveBack:a(e.objects.filter(t=>j(t)+U(t)>0).map(t=>t.objectApiName),o?.updateLinks??0),setToDraft:e.objects.filter(t=>S(t)>0).map(t=>t.objectApiName),delete:a(n,o?.unlink??0)}}function z(e){return new Set(e.map(n=>`${n.objectApiName}
|
|
8
8
|
${n.kind}
|
|
9
9
|
${n.name}`)).size}function ne(e,n,o,a=!1){let t=(c,f)=>(c??[]).includes(f),i=o.filter(c=>!t(n.recreate,c)),s=o.filter(c=>N[c]!==void 0&&!t(n.giveBack,c)),r=new Set(e.objectsRead),d=[...i,...s];return{fired:y(e,{recreate:i,giveBack:s}),blind:d.length>0&&(!a&&A(e.unread)||d.some(c=>!r.has(c)))}}var T={limit:e=>`this step's limit of ${l(e)}`,mutes:!1,lift:{acceptAutomation:"turn on muteAutomation in the step for what a bypass keeps quiet, or acceptAutomation to let it run, and confirm it again to rewind all the same",acceptEmails:"turn on acceptEmails in the step and confirm it again to rewind all the same",acceptNoUndo:"turn on acceptNoUndo in the step and confirm it again to rewind all the same",acceptRecreate:"turn on acceptRecreate in the step and confirm it again to rewind all the same",acceptUnseen:"turn on acceptUnseen in the step and confirm it again to rewind all the same",maxRecords:"preview the rewind, then raise the step's maxRecords to what it rewinds and confirm it again",refuseWhenActive:"run it once they are done, or turn off refuseWhenActive in the step and confirm it again"}},oe={...T,lift:{...T.lift,acceptAutomation:"turn on acceptAutomation in the step to let what no bypass keeps quiet run, and confirm it again to rewind all the same"}},H=[{reason:"onlyWithParent",words:"Salesforce undeletes them only with their parent, which stays"},{reason:"deletedBeforeParent",words:"deleted before a record they point at, which the rewind deletes next, Salesforce cannot bring them back after that"}],Y="Add --accept-emails to rewind all the same";function q(e,n,o,a,t){let{automation:i,deliverability:s}=n;if(!i||!s)return;let r=W(n.diff),{refusal:d}=C({act:"rewind",orgName:e,automation:i,steps:r,accepted:o.acceptEmails===!0,mayMute:t,...P({automation:i,steps:r}),reading:s.reading});if(!d)return;let c=a.acceptEmails;return{...d,message:d.message.replace(Y,`${c.charAt(0).toUpperCase()}${c.slice(1)}`)}}function ie(e,n,o,a,t="the user SandForge connects as",i=!1){return _(e,n,o,a,t,i)[0]}function _(e,n,o,a,t="the user SandForge connects as",i=!1){let s=[],{diff:r,automation:d}=n;if(r.undoCannot.length>0&&!o.acceptNoUndo){let u=H.flatMap(({reason:w,words:g})=>{let R=r.undoCannot.filter(b=>(b.reason??"onlyWithParent")===w);if(R.length===0)return[];let F=R.reduce((b,G)=>b+G.count,0),I=[...new Set(R.map(b=>b.objectApiName))].join(", ");return[`Undo couldn't bring back ${l(F)} ${I} record(s) this rewind deletes: ${g}.`]});s.push({code:"NO_UNDO",message:`${u.join(" ")} Rewind refused; ${a.acceptNoUndo}. ${h}`})}let c=r.objects.filter(u=>k(u)>0);if(c.length>0&&!o.acceptRecreate){let u=c.reduce((w,g)=>w+k(g),0);s.push({code:"RECREATE",message:`${l(u)} ${c.map(w=>w.objectApiName).join(", ")} record(s) deleted since are no longer in the recycle bin, or Salesforce keeps them there for good: this rewind makes them again from the checkpoint, with new Ids. Anything outside Salesforce that names their old Ids \u2014 an integration, a link, a report filter \u2014 no longer finds them. Rewind refused; ${a.acceptRecreate}. ${h}`})}let f=r.unseen??[];if(f.length>0&&o.acceptUnseen!==!0){let u=f.map(({objectApiName:w,children:g,records:R})=>`Deleting ${l(R)} ${w} record(s) created since also deletes what ${t} can't see under them in ${g.join(", ")}: Rewind can't count those.`);s.push({code:"UNSEEN",message:`${u.join(" ")} Rewind refused; ${a.acceptUnseen}. ${h}`})}if(!d)return s;let m=K(e,n,o,a),p=q(e,n,o,a,i);return[...s,...m?[m]:[],...p?[p]:[]]}function K(e,n,o,a){let{diff:t,automation:i,emailsUncounted:s}=n;if(!i||o.acceptAutomation)return;let r=W(t),d=y(i,r);if(d.length===0&&!A(i.unread)&&s===void 0)return;let c=[...new Set(d.map(u=>u.objectApiName))],f=(r.recreate??[]).some(u=>u!==B)?"makes them again, ":"",m=d.length>0?`${z(d)} flow(s), trigger(s) or rule(s) of ${c.join(", ")} run as the rewind brings records back, ${f}gives them their values back or deletes them`:"what runs as the rewind writes could not all be read, so automation may run",p=s!==void 0?`The emails it sends as the rewind writes were not counted against its daily limits, as what sends them was not read (${s}). `:"";return{code:"AUTOMATION",message:`${e}: ${m}. ${p}Rewind refused; ${a.acceptAutomation}. `+h}}var x=e=>e.slice(0,15);async function ae(e){return(await J(e))[0]}async function J(e){let{orgName:n,preview:o,bounds:a,words:t}=e,{diff:i}=o;if(L(i).length===0)return[];let s=[],r=M(i),d=r.toDelete+r.toGiveBack+r.toBringBack+r.toRecreate;if(a.maxRecords!==void 0&&d>a.maxRecords){let f=[`${l(r.toDelete)} to delete`,`${l(r.toGiveBack)} to give back`,`${l(r.toBringBack)} to bring back`,...r.toRecreate>0?[`${l(r.toRecreate)} to make again`]:[]];s.push({code:"TOO_MANY_TO_REWIND",message:`The rewind of ${n} would rewind ${l(d)} records (${f.join(", ")}), past ${t.limit(a.maxRecords)}. Rewind refused; ${t.lift.maxRecords}. `+h})}if(a.refuseWhenActive&&i.activeLastHour.length>0){let f=new Set((await e.writers()).map(x)),m=new Set(i.activeLastHour.map(x).filter(p=>!f.has(p)));if(m.size>0){let p=m.size===1?"1 person":`${l(m.size)} people`;s.push({code:"PEOPLE_ACTIVE",message:`${p} other than the user the rewind writes as changed records of the checkpoint's objects in ${n} in the hour before the rewind read it: it would take their work back. Rewind refused; ${t.lift.refuseWhenActive}. `+h})}}let c=O("rewind",o.emails??[],n);return[...s,..._(n,o,e.accepted,t.lift,e.user,t.mutes),...c?[c]:[]]}function re(e,n,o){let a=n.map(t=>`${t.objectApiName} (${l(t.records)})`).join(", ");return{code:"UNDELETABLE_UNATTENDED",message:`The user SandForge connects to ${e} as may not delete the ${a} record(s) this rewind deletes. With nobody to ask whether to delete the rest, the deletion was left untouched. Give the user Delete on those objects, or rewind from the Checkpoints page, which asks. `+(o?"What the rewind's first pass wrote stays: its result says what, and Undo takes it back.":h)}}function se(e,n){return{code:"NOT_CONFIRMED",message:`Rewind step "${e}" has `+(n?"not been confirmed since it was changed":"never been confirmed")+": open it and type the org's alias, or, for an org that has none, its name or Organization Id. "+h}}export{L as a,M as b,te as c,W as d,z as e,ne as f,T as g,oe as h,ie as i,ae as j,J as k,re as l,se as m};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{d as R,g as b}from"./chunk-
|
|
7
|
+
import{d as R,g as b}from"./chunk-OHEOJISY.mjs";import{b as l,e as f,f as y,l as g}from"./chunk-WZQEK4WT.mjs";var N="RECORD_TYPE_UNAVAILABLE",h="RECORD_TYPE_UNMAPPED",A=g({recordTypeId:l().regex(/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/),developerName:l().min(1).optional(),name:l().optional(),available:y(),active:y().optional(),master:y().optional(),defaultRecordTypeMapping:y().optional()}).loose();function w(e){if(!Array.isArray(e))return[];let r=[];for(let t of e){let n=A.safeParse(t);if(!n.success)continue;let o=n.data,c=o.name??o.developerName??o.recordTypeId;r.push({recordTypeId:o.recordTypeId,developerName:o.master===!0?"Master":o.developerName??c,name:c,available:o.available,active:o.active??!0,master:o.master??!1,defaultRecordTypeMapping:o.defaultRecordTypeMapping??!1})}return r}function p(e){return e.slice(0,15)}function E(e,r){if(r.length===0)return[...e];let t=new Map(r.map(n=>[p(n.id),n]));return e.map(n=>{let o=t.get(p(n.recordTypeId));return o?{...n,developerName:R(o),namespacePrefix:o.namespacePrefix??null}:n})}function z(e){let r=e.namespacePrefix;if(r===void 0)return b(e.developerName);let t=r?`${r}__`:"";return{namespacePrefix:r,developerName:e.developerName.startsWith(t)?e.developerName.slice(t.length):e.developerName}}function O(e,r,t){if(t.length===0)return[];let n=new Map;for(let o of r){let c=o.RecordTypeId;typeof c!="string"||c.length<15||n.set(c,(n.get(c)??0)+1)}return I(e,n,t)}function I(e,r,t){if(t.length===0)return[];let n=new Map(t.map(c=>[p(c.recordTypeId),c])),o=new Map;for(let[c,i]of r){if(c.length<15||i<=0)continue;let a=n.get(p(c));if(!a||a.available||a.master)continue;let d=o.get(a.recordTypeId);d?d.recordCount+=i:o.set(a.recordTypeId,{objectApiName:e,recordTypeId:a.recordTypeId,developerName:a.developerName,name:a.name,inactive:!a.active,recordCount:i})}return[...o.values()].sort((c,i)=>c.developerName.localeCompare(i.developerName))}var $=/^012000000000000(AAA)?$/;function _(e,r,t,n){if(t.length===0)return[];let o=new Set(t.map(a=>p(a.recordTypeId))),c=new Map(n.map(a=>[p(a.recordTypeId),a])),i=new Map;for(let[a,d]of r){if(a.length<15||d<=0||$.test(a))continue;let u=p(a);if(o.has(u))continue;let T=i.get(u);if(T){T.recordCount+=d;continue}let s=c.get(u);i.set(u,{objectApiName:e,recordTypeId:a,developerName:s?.developerName??a,name:s?.name??s?.developerName??a,inactive:!1,recordCount:d,unmapped:!0,...s&&!s.active?{inactiveInSource:!0}:{}})}return[...i.values()].sort((a,d)=>a.developerName.localeCompare(d.developerName))}function k(e){return`SELECT RecordTypeId, COUNT(Id) n FROM ${e} GROUP BY RecordTypeId`}var U=g({RecordTypeId:l().nullable(),n:f().int().nonnegative()}).loose();function j(e){let r=new Map;for(let[t,n]of M(e))t&&r.set(t,n);return r}function M(e){let r=new Map;if(!Array.isArray(e))return r;for(let t of e){let n=U.safeParse(t);if(!n.success)continue;let o=n.data.RecordTypeId||null;r.set(o,(r.get(o)??0)+n.data.n)}return r}function S(e,r){let t=e.RecordTypeId;return typeof t=="string"&&r.some(n=>p(n.recordTypeId)===p(t))}function m(e){return`${e.recordCount} ${e.objectApiName} record${e.recordCount===1?"":"s"}`}function v(e){return e.name&&e.name!==e.developerName?`${e.developerName} (${e.name})`:e.developerName}function x(e){let r=e.recordCount===1?"uses":"use";return e.unmapped&&e.inactiveInSource?`${m(e)} ${r} record type ${v(e)}, which is inactive in the source org: no record type of the target org is mapped to it. Map it to one the running user has on ${e.objectApiName}.`:e.unmapped?`${m(e)} ${r} record type ${v(e)}, which has no active ${e.objectApiName} record type of that API name in the target org. Create or activate record type ${e.developerName} on ${e.objectApiName} in the target org, or map it to one the running user has.`:e.inactive?`${m(e)} ${r} record type ${v(e)}, which is inactive in the target org. Activate record type ${e.developerName} on ${e.objectApiName} in the target org, or map it to an active one the running user has.`:`${m(e)} ${r} record type ${v(e)}, which the running user cannot use in the target org. Give the running user access to record type ${e.developerName} on ${e.objectApiName}, or map it to one they have.`}function D(e){return`${e.unmapped?h:N}: ${x(e)}`}export{N as a,w as b,E as c,z as d,O as e,I as f,_ as g,k as h,j as i,M as j,S as k,x as l,D as m};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{i as g,n as p,o as m}from"./chunk-
|
|
7
|
+
import{i as g,n as p,o as m}from"./chunk-T26C576X.mjs";import{a as b,b as I}from"./chunk-MS4FJDFD.mjs";import{c as w}from"./chunk-LCDPCUXS.mjs";import{Ec as l,p as d,q as u}from"./chunk-DPYTG6DM.mjs";import{A as c}from"./chunk-WZQEK4WT.mjs";import{d as f}from"./chunk-NTOVCTRS.mjs";var a=class extends Error{constructor(t,r){super(`${r} Nothing was read from ${t}.`);this.alias=t;this.reason=r;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 n=e.replace(/\u001b\[[0-9;]*m/g,""),t=n.indexOf("{");if(t!==-1)try{let r=$.safeParse(JSON.parse(n.slice(t)));return r.success?r.data:void 0}catch{return}}function C(e,n=process.platform){let t=typeof e=="object"&&e!==null?e:{};return t.code==="ENOENT"?!0:n==="win32"&&(t.status===9009||/is not recognized as an internal or external command/i.test(String(t.stderr??"")))}function S(e,n,t=process.platform){if(C(n,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 r=typeof n=="object"&&n!==null?n:{},o=h(r.stdout)??h(r.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 r.stderr=="string"?r.stderr.split(/\r?\n/).find(y=>y.trim()!==""):void 0,i=o?.message?.trim()||s?.trim()||(n instanceof Error?n.message:String(n));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(n){throw S(e,n)}}async function A(e,n=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),r=JSON.parse(t),o=r.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(!r.result?.instanceUrl)throw new Error(`sf org display did not return a usable session for alias '${e}'.`);let s=await n(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:r.result.username??"",instanceUrl:s.instanceUrl??r.result.instanceUrl,accessToken:s.accessToken,...typeof r.result.devHubId=="string"&&r.result.devHubId!==""?{scratch:!0}:{}}}function H(e,n=process.env){let t=g(e.instanceUrl,n),r=new k.default.Connection({instanceUrl:e.instanceUrl,accessToken:e.accessToken,version:"66.0",...t!==void 0?{httpProxy:t}:{}});return t===void 0&&(r._transport=new x.HttpProxyTransport("")),r}export{a,A as b,H as c};
|
|
@@ -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{b as X,e as Y}from"./chunk-
|
|
7
|
+
import{b as X,e as Y}from"./chunk-OVOLG3AL.mjs";import{a as G,b as q,e as J,f as Q,j as L}from"./chunk-FQGHL7GR.mjs";import{Ha as A,Ja as N,Ka as Z,La as W}from"./chunk-DPYTG6DM.mjs";var O=class extends Error{constructor(t){super(`The scenario cannot be compiled: ${t.join("; ")}`);this.issues=t;this.name="ScenarioCompileError"}issues},ee="2026-10-28T00:00:00.000Z",x={subject:255,description:32e3,commentBody:4e3,articleTitle:255,articleSummary:1e3},ie=new Set(["Phone"]);function $e(e,n={}){let t=Z.safeParse(e),a=W.safeParse(n);if(!t.success||!a.success)throw new O([...t.error?.issues.map(i=>te(["pack",...i.path],i))??[],...a.error?.issues.map(i=>te(["options",...i.path],i))??[]]);let r=n.customers??e.customers.count;if(r<e.topics.length)throw new O([`options.customers: ${r} customer(s) for ${e.topics.length} topics: each topic's utterances are said about a customer's open case on it`]);let s=n.seed??A.seed,u=n.historyPerCustomer??A.historyPerCustomer,l=n.caseStatus??A.caseStatus,c=ge(e.language),o=ce(),p=e.id,m=e.topics,f=fe(p,r,c,s),S=f.map((i,d)=>({key:i.key,values:o.row({Name:i.company,Industry:e.customers.industry,Type:"Customer - Direct",Phone:L(c,2*d),Website:`https://www.${se(i.company)}`})})),$=f.map((i,d)=>({key:i.key,parentKey:i.key,values:o.row({FirstName:i.firstName,LastName:i.lastName,Email:i.email,Phone:L(c,2*d+1)})})),T=m.map(()=>0),k=[],M=[],D=[],z=[],F=i=>`${p}-article-${m[i].key}`;for(let[i,d]of f.entries()){let I=[...Array.from({length:u},(g,h)=>({topicIndex:(i+1+h)%m.length,key:`${d.key}-h${h+1}`,open:!1})),{topicIndex:i%m.length,key:`${d.key}-open`,open:!0}];for(let{topicIndex:g,key:h,open:j}of I){let U=m[g].caseTemplates,w=U[T[g]++%U.length],v=o.text(P(w.subject,d),x.subject),V={...d,caseSubject:v};k.push({key:h,parentKey:d.key,values:o.row({Subject:v,Description:o.text(P(w.description,V),x.description),Status:j?l.open:l.closed,Priority:w.priority,Origin:w.origin})}),M.push(...le(h,w,j,V,o)),j?D.push({key:h,subject:v,topicIndex:g,customer:d}):z.push({caseKey:h,articleKey:F(g)})}}let y=ue(n),_=[],oe=m.map((i,d)=>{if(!y)return;let I=i.article.facts.map(h=>o.text(h)),g=me(o.text(i.article.body),I,y);if(typeof g=="string")return g;_.push(`pack.topics[${d}].article.facts[${g.unfit}]: the fact "${i.article.facts[g.unfit]}" does not fit, with the facts before it, in the ${y.max} characters of ${y.name}, the field the article's body goes to in this org: shorten the facts, or give Knowledge a longer field for the body`)});if(_.length>0)throw new O(_);let H=[...m.map((i,d)=>({key:F(d),values:ne(i.article,`${p}-${i.key}-${s}`,e,o,y&&{name:y.name,text:oe[d]??""})})),{key:`${p}-decoy-article`,values:ne(e.decoy,`${p}-${s}-decoy`,e,o,y&&{name:y.name,text:de(o.text(e.decoy.body),o.text(e.decoy.summary),y)})}],ae={id:`scenario-${p}`,name:o.text(e.name),description:o.text(e.businessContext),version:1,strategy:"template",objects:[R("Account",0,S),R("Contact",1,$),R("Case",2,k),R("CaseComment",3,M),{...R("Knowledge__kav",4,H),optional:!0}],relations:[B("Contact","AccountId","Account"),B("Case","ContactId","Contact"),B("CaseComment","ParentId","Case")],tags:["scenario",p],createdAt:ee,updatedAt:ee};return{packId:p,seed:s,template:ae,tests:pe(e,D,F,H,o),closedCaseArticles:z}}function te(e,n){return`${e.reduce((a,r)=>typeof r=="number"?`${a}[${r}]`:`${a}.${String(r)}`,"").replace(/^\./,"")}: ${n.message}`}function ce(){let e=X(),n=new Map,t=r=>{let s=n.get(r);if(s!==void 0)return s;let u=e(r);return n.set(r,u),u},a=(r,s)=>Y(r,s,t);return{text(r,s){let u=a({text:r},new Set).text;return E(typeof u=="string"?u:r,s)},row(r){return a(r,ie)}}}function E(e,n){if(n===void 0||e.length<=n)return e;let t=e.slice(0,n);if(/\s/.test(e.charAt(n)))return t.trimEnd();let a=t.search(/\s\S*$/);return a>0?t.slice(0,a).trimEnd():t}function P(e,n){return e.replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g,(t,a)=>n[a]??t)}function le(e,n,t,a,r){return(t?[n.followUp]:n.resolution).map((u,l)=>({key:`${e}-${l+1}`,parentKey:e,values:{CommentBody:r.text(P(u,a),x.commentBody),IsPublished:!1}}))}function ne(e,n,t,a,r){let s={Title:a.text(e.title,x.articleTitle),UrlName:n,Summary:a.text(e.summary,x.articleSummary),Language:t.language,IsVisibleInPkb:!1,IsVisibleInCsp:!1,IsVisibleInPrm:!1};return r&&(s[r.name]=r.text),s}function ue(e){let n=e.articleBodyField;if(n===void 0)return;let t=e.articleBodyLength??(n==="Summary"?x.articleSummary:void 0);return{name:n,...t!==void 0?{max:t}:{},html:e.articleBodyHtml===!0}}function K(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function C(e,n){return n.html?e.map(t=>`<p>${re(t)}</p>`).join(""):e.join(`
|
|
8
8
|
|
|
9
9
|
`)}function re(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function b(e,n){return n.max===void 0||e.length<=n.max}function me(e,n,t){let a=K(e),r=t.html?C(a,t):e;if(b(r,t))return r;let s=a.filter(c=>n.some(o=>N(c,o)));if(n.every(c=>N(s.join(`
|
|
10
10
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{c as a,d as b,e as c,f as d,g as e,h as f}from"./chunk-DXOXLUZA.mjs";import"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as loadCreatedRecords,f as loadRecordsInfo,c as loadRecordsKept,b as loadRecordsLeft,d as loadToRemove,e as loadsSweptWith};
|