sandforge 1.79.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-BN7A4GRQ.mjs → chunk-2IB7I3IQ.mjs} +1 -1
- package/lib/{chunk-PBI4BYWW.mjs → chunk-2NAIUKVL.mjs} +1 -1
- package/lib/chunk-2OIRJEYE.mjs +7 -0
- package/lib/{chunk-FOVVHGEP.mjs → chunk-2OZG6GRW.mjs} +1 -1
- package/lib/{chunk-5CD257T7.mjs → chunk-2Z54GB6X.mjs} +1 -1
- package/lib/chunk-2ZMGVBLW.mjs +7 -0
- package/lib/{chunk-4NAHW2D3.mjs → chunk-33ZX3A56.mjs} +1 -1
- package/lib/{chunk-4SNDMJP2.mjs → chunk-3AOKLIVE.mjs} +1 -1
- package/lib/{chunk-SIOZXPFG.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-GNC27UEU.mjs → chunk-5UT2ZBGF.mjs} +1 -1
- package/lib/chunk-5VQNKDFU.mjs +7 -0
- package/lib/chunk-5WGA5CZB.mjs +7 -0
- package/lib/chunk-5ZKCLBTN.mjs +474 -0
- package/lib/chunk-67CC7RAE.mjs +7 -0
- package/lib/{chunk-5O6JOMHS.mjs → chunk-6CDIIFNX.mjs} +1 -1
- package/lib/{chunk-AV5SWEHP.mjs → chunk-6FARZYMJ.mjs} +1 -1
- package/lib/{chunk-7UQD6V6F.mjs → chunk-6FMLW7PH.mjs} +1 -1
- package/lib/chunk-6IGEASOF.mjs +7 -0
- package/lib/{chunk-H2PJNIYJ.mjs → chunk-6NADW3OI.mjs} +1 -1
- package/lib/chunk-6SEDOIO3.mjs +10 -0
- package/lib/{chunk-AUTM6H6Z.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-HV2MXMGI.mjs → chunk-AJPSGVMD.mjs} +1 -1
- package/lib/{chunk-OTWRDD6L.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-XBG5SP6Q.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-BILZ3SSR.mjs → chunk-D7P7DTWL.mjs} +1 -1
- package/lib/chunk-DHGPDSXS.mjs +7 -0
- package/lib/{chunk-ZXH4MBWP.mjs → chunk-DHIW4IO5.mjs} +1 -1
- package/lib/{chunk-NM4MDLK4.mjs → chunk-DMBR24CK.mjs} +1 -1
- package/lib/chunk-DPYTG6DM.mjs +48 -0
- package/lib/chunk-DQR5NDMI.mjs +7 -0
- package/lib/chunk-DXOXLUZA.mjs +7 -0
- package/lib/chunk-E2OBAWSH.mjs +7 -0
- package/lib/chunk-E2YJVSX6.mjs +10 -0
- package/lib/chunk-EAFLDSQ2.mjs +7 -0
- package/lib/{chunk-HCIDVIOW.mjs → chunk-EH5YUA5W.mjs} +1 -1
- package/lib/{chunk-2BVTCNWA.mjs → chunk-EOSEMFPU.mjs} +1 -1
- package/lib/chunk-ETT5GP4P.mjs +13 -0
- package/lib/{chunk-3SRXFZSD.mjs → chunk-FDGFUEK3.mjs} +1 -1
- package/lib/{chunk-3DCUADVK.mjs → chunk-FLNLG43R.mjs} +1 -1
- package/lib/{chunk-HTJ5OGP5.mjs → chunk-FSDO4DJA.mjs} +1 -1
- package/lib/{chunk-HJKM3E56.mjs → chunk-FSZTXLNW.mjs} +1 -1
- package/lib/chunk-FTA5LOVX.mjs +7 -0
- package/lib/chunk-G4VXPS3A.mjs +7 -0
- package/lib/chunk-GF247DA7.mjs +7 -0
- package/lib/{chunk-QRV2OSIS.mjs → chunk-GK7VEYFM.mjs} +1 -1
- package/lib/{chunk-5MMXFWPD.mjs → chunk-GR3NGDVM.mjs} +1 -1
- package/lib/{chunk-P7GSGFJO.mjs → chunk-GTIXJCGS.mjs} +1 -1
- package/lib/{chunk-342FN7AO.mjs → chunk-GWRKS3AL.mjs} +1 -1
- package/lib/{chunk-LQ4DRFUH.mjs → chunk-GYKNCYES.mjs} +1 -1
- package/lib/{chunk-WIO4XO4F.mjs → chunk-HFSBDM7B.mjs} +1 -1
- package/lib/chunk-HVC5CYIB.mjs +7 -0
- package/lib/{chunk-EQF2IJS2.mjs → chunk-HYBH5PFM.mjs} +1 -1
- package/lib/chunk-HYOOJVR6.mjs +7 -0
- package/lib/{chunk-TQX3PURV.mjs → chunk-IBURU7T7.mjs} +1 -1
- package/lib/chunk-ICIYL45C.mjs +7 -0
- package/lib/{chunk-K22PA4XL.mjs → chunk-IKGHRYCN.mjs} +1 -1
- package/lib/chunk-IM2XA6JI.mjs +7 -0
- package/lib/{chunk-P2PJYWGQ.mjs → chunk-J6G23RUI.mjs} +1 -1
- package/lib/{chunk-JVL444U5.mjs → chunk-JU2XEKEO.mjs} +1 -1
- package/lib/{chunk-H45UXY6G.mjs → chunk-K55LH4ZQ.mjs} +1 -1
- package/lib/chunk-K5HV4YRO.mjs +7 -0
- package/lib/{chunk-IAZB4WIL.mjs → chunk-K77NR3UK.mjs} +1 -1
- package/lib/chunk-KE2PGD6C.mjs +7 -0
- package/lib/chunk-KGYXLSQ5.mjs +37 -0
- package/lib/{chunk-TEOLMRDO.mjs → chunk-KNIRA333.mjs} +1 -1
- package/lib/chunk-KOQV4WXC.mjs +8 -0
- package/lib/{chunk-PNCONNFJ.mjs → chunk-KRNFVAGC.mjs} +1 -1
- package/lib/chunk-L5FGY6YA.mjs +7 -0
- package/lib/{chunk-MTMH6H2A.mjs → chunk-LCDPCUXS.mjs} +1 -1
- package/lib/{chunk-YAZO75G2.mjs → chunk-LNXBCE7E.mjs} +1 -1
- package/lib/{chunk-ZOVSMN5C.mjs → chunk-LO527YLT.mjs} +1 -1
- package/lib/chunk-MAHZMPMZ.mjs +7 -0
- package/lib/{chunk-QQZZMKU3.mjs → chunk-MHW6DV6T.mjs} +1 -1
- package/lib/{chunk-2YIV2OB2.mjs → chunk-MIDBQ7SD.mjs} +1 -1
- package/lib/{chunk-6EBMEGZB.mjs → chunk-MKNAZPOT.mjs} +1 -1
- package/lib/{chunk-NTDN2JQZ.mjs → chunk-MNITSYI2.mjs} +8 -8
- package/lib/chunk-MO3N5XVV.mjs +341 -0
- package/lib/{chunk-SBIMVCXT.mjs → chunk-MS4FJDFD.mjs} +9 -9
- 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-PUOX4NBJ.mjs → chunk-NWVVCZUK.mjs} +1 -1
- package/lib/{chunk-DLDX6RRC.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-NZ5ZZLKS.mjs → chunk-ONMBSACW.mjs} +1 -1
- package/lib/chunk-OQQHNYR7.mjs +272 -0
- package/lib/{chunk-AAVJ5XVX.mjs → chunk-OU5W7SCB.mjs} +1 -1
- package/lib/{chunk-RSYICMZG.mjs → chunk-OVOLG3AL.mjs} +1 -1
- package/lib/{chunk-F74IHMGL.mjs → chunk-OXKZ4Y3B.mjs} +1 -1
- package/lib/{chunk-W7KFAY55.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-RACDTRZA.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-PZTSVQSF.mjs → chunk-QXLZINZB.mjs} +1 -1
- package/lib/chunk-R2BJWO5N.mjs +20 -0
- package/lib/chunk-R6TF26V4.mjs +10 -0
- package/lib/{chunk-P42X3B4D.mjs → chunk-RKALOKAU.mjs} +1 -1
- package/lib/chunk-SQGP46QS.mjs +7 -0
- package/lib/chunk-SU65Z2BA.mjs +7 -0
- package/lib/chunk-SW2NUKQL.mjs +9 -0
- package/lib/chunk-T26C576X.mjs +9 -0
- package/lib/{chunk-3OHPD72J.mjs → chunk-T3PLRQ2T.mjs} +1 -1
- package/lib/chunk-T5VAULLQ.mjs +7 -0
- package/lib/chunk-TEIBWMJM.mjs +7 -0
- package/lib/chunk-TKQQVB2D.mjs +9 -0
- package/lib/{chunk-RAAANPPG.mjs → chunk-TPHXRHOA.mjs} +1 -1
- package/lib/chunk-TQ2TQHTT.mjs +9 -0
- package/lib/{chunk-IEYG5ATY.mjs → chunk-TQM2XJ27.mjs} +1 -1
- package/lib/{chunk-X65MT4W3.mjs → chunk-UCHAZ4ZU.mjs} +1 -1
- package/lib/chunk-UIUPPEFB.mjs +7 -0
- package/lib/{chunk-QPF6C5MX.mjs → chunk-UT27HXE7.mjs} +1 -1
- package/lib/{chunk-J7HVXMSW.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-3CA767QB.mjs → chunk-WEZLXE34.mjs} +1 -1
- package/lib/{chunk-WFEB5X4U.mjs → chunk-WI4HYWV6.mjs} +1 -1
- package/lib/{chunk-AR7BE5O2.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-ZJKCWBRJ.mjs → chunk-X2ZVSQ54.mjs} +1 -1
- package/lib/{chunk-SFURUNJM.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-RFEO2KAN.mjs → chunk-Y5ZCPY36.mjs} +1 -1
- package/lib/{chunk-TBZMC2VV.mjs → chunk-YCSFP6ER.mjs} +4 -4
- package/lib/{chunk-YBU4Z4QV.mjs → chunk-YHIOS2PU.mjs} +1 -1
- package/lib/chunk-YIGFYZQY.mjs +7 -0
- package/lib/chunk-YJEXE6HZ.mjs +925 -0
- package/lib/{chunk-57VHUYNG.mjs → chunk-YOGMP72T.mjs} +4 -4
- package/lib/chunk-ZRUDYB7O.mjs +7 -0
- package/lib/{chunk-55HEMHEG.mjs → chunk-ZUA5BNAO.mjs} +1 -1
- package/lib/chunk-ZWCRWF7E.mjs +7 -0
- package/lib/{chunk-VHI54FBK.mjs → chunk-ZWZXQTAK.mjs} +53 -53
- package/lib/sandforge-autopilot.mjs +29 -24
- package/lib/sandforge-backup.mjs +67 -32
- package/lib/sandforge-checkpoint.mjs +1 -347
- package/lib/sandforge-cleanup.mjs +14 -10
- package/lib/sandforge-clone.mjs +1 -1
- package/lib/sandforge-compare.mjs +9 -8
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +15 -15
- package/lib/sandforge-env.mjs +101 -101
- package/lib/sandforge-frozen.mjs +1 -257
- package/lib/sandforge-mcp.mjs +33 -14
- package/lib/sandforge-monitor.mjs +7 -7
- 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-2S5OMIIA.mjs +0 -7
- package/lib/chunk-36U7IQ6Y.mjs +0 -25
- package/lib/chunk-3F5YMM2F.mjs +0 -7
- package/lib/chunk-3RYLICRX.mjs +0 -7
- package/lib/chunk-42RER7V4.mjs +0 -14
- package/lib/chunk-4GL773D5.mjs +0 -7
- package/lib/chunk-4HFRHFGQ.mjs +0 -7
- package/lib/chunk-4U6NXJNL.mjs +0 -7
- package/lib/chunk-4XZ5YT5O.mjs +0 -7
- package/lib/chunk-5AJRHRXA.mjs +0 -20
- package/lib/chunk-5HMAPZBV.mjs +0 -7
- package/lib/chunk-5P4PHJRL.mjs +0 -9
- package/lib/chunk-5QKTYCWE.mjs +0 -11
- package/lib/chunk-6LAXTAVN.mjs +0 -7
- package/lib/chunk-6MUEPV7M.mjs +0 -9
- package/lib/chunk-6QSM2WIH.mjs +0 -10
- package/lib/chunk-75ADZS6B.mjs +0 -7
- package/lib/chunk-ALJVEUUS.mjs +0 -7
- package/lib/chunk-ALUFROGA.mjs +0 -7
- package/lib/chunk-B45CNPUX.mjs +0 -47
- package/lib/chunk-BS5T3MOQ.mjs +0 -7
- package/lib/chunk-CGWXQX75.mjs +0 -7
- package/lib/chunk-D3QRXG63.mjs +0 -787
- package/lib/chunk-EEVVGGM6.mjs +0 -7
- package/lib/chunk-ENLBYECD.mjs +0 -7
- package/lib/chunk-EQOQASDQ.mjs +0 -7
- package/lib/chunk-FQBRBBY4.mjs +0 -7
- package/lib/chunk-GAM726CK.mjs +0 -7
- package/lib/chunk-HJC7AIBK.mjs +0 -7
- package/lib/chunk-HUMEKZT5.mjs +0 -8
- package/lib/chunk-I3JKJTLO.mjs +0 -110
- package/lib/chunk-I7O6C2B5.mjs +0 -8
- package/lib/chunk-KLX67VPL.mjs +0 -7
- package/lib/chunk-L776PUMV.mjs +0 -7
- package/lib/chunk-LRFAIUN7.mjs +0 -7
- package/lib/chunk-LV6G4XTK.mjs +0 -7
- package/lib/chunk-MYTIL2JD.mjs +0 -10
- package/lib/chunk-NEVXIGR6.mjs +0 -10
- package/lib/chunk-NGSMZZDA.mjs +0 -7
- package/lib/chunk-NHWE66K5.mjs +0 -7
- package/lib/chunk-OQOZAPCI.mjs +0 -7
- package/lib/chunk-PA3MKJVH.mjs +0 -7
- package/lib/chunk-QROPNEGY.mjs +0 -14
- package/lib/chunk-QWT2C74M.mjs +0 -7
- package/lib/chunk-RH3N2H7P.mjs +0 -7
- package/lib/chunk-SRQDABQ2.mjs +0 -15
- package/lib/chunk-SVS6UMDU.mjs +0 -323
- package/lib/chunk-TNXUU6W7.mjs +0 -14
- package/lib/chunk-VGW4MXXZ.mjs +0 -7
- package/lib/chunk-VXHDBYMI.mjs +0 -7
- package/lib/chunk-WJY54JO7.mjs +0 -13
- package/lib/chunk-WRU5FJFC.mjs +0 -7
- package/lib/chunk-X2PY6MWZ.mjs +0 -7
- package/lib/chunk-XEFDB2R4.mjs +0 -7
- package/lib/chunk-XETCPL7E.mjs +0 -7
- package/lib/chunk-Y5CGXLUB.mjs +0 -7
- package/lib/chunk-Y6J6QFI2.mjs +0 -7
- package/lib/chunk-YMJVMFPY.mjs +0 -7
- package/lib/chunk-YPSRZRIT.mjs +0 -7
- package/lib/chunk-YS4G22C2.mjs +0 -7
- package/lib/chunk-YW2SBL4Z.mjs +0 -7
- package/lib/chunk-Z7X534S4.mjs +0 -10
- package/lib/chunk-ZE6HKRR4.mjs +0 -9
- package/lib/chunk-ZLZRU6MO.mjs +0 -7
- package/lib/chunk-ZPYJPGDK.mjs +0 -7
- package/lib/chunk-ZQOZ4EFW.mjs +0 -7
- package/lib/chunk-ZUTYVST5.mjs +0 -7
- package/lib/chunk-ZYEE34WO.mjs +0 -7
package/lib/chunk-EEVVGGM6.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
-
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
-
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
-
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
-
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r}from"./chunk-342FN7AO.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-VXHDBYMI.mjs";import"./chunk-ENLBYECD.mjs";import"./chunk-PA3MKJVH.mjs";import"./chunk-ZLZRU6MO.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-PNCONNFJ.mjs";import"./chunk-CGWXQX75.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-SIOZXPFG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-B45CNPUX.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{p as actDeliverability,o as actEmailsGate,n as actSendersOf,q as afterLeaseEmailsRefusal,l as checkpointEmails,j as checkpointEmailsUncounted,c as draftedByDiff,d as draftedByPlan,a as emailsOfLimit,m as emailsRefusal,k as emailsUncountedWords,r as pageEmailsRefusal,e as statusBackByDiff,f as statusBackByPlan,b as updatedByDiff,g as writtenByDiff,h as writtenByPlan,i as writtenByUndo};
|
package/lib/chunk-ENLBYECD.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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{g as m,h as S,i as E,j as x}from"./chunk-PA3MKJVH.mjs";import{b as C}from"./chunk-CA5NAXSU.mjs";import{w as R,zd as T}from"./chunk-B45CNPUX.mjs";import{statfs as q}from"node:fs/promises";var oe=["reads","leasePlan","stillRunning","deliverabilityRead","question","checkpointTake","leaseAcquire","afterLeaseCheck","write","leaseRelease","recordTypeReadBack","result"];function re(e){let t=[],n=s=>e.indexOf(s),r=s=>e.lastIndexOf(s),o=(s,c,d,p=r(s),l=n(c))=>{p>=0&&l>=0&&p>l&&t.push(d)};o("leasePlan","stillRunning","what still runs was computed before the lease was planned"),o("stillRunning","deliverabilityRead","the deliverability was read before what still runs was known"),o("deliverabilityRead","question","the deliverability was read after the question it belongs to",n("deliverabilityRead")),o("question","checkpointTake","the checkpoint was taken before the last question"),o("question","leaseAcquire","the lease was taken before the last question"),o("checkpointTake","leaseAcquire","the lease was taken before the checkpoint"),o("leaseAcquire","afterLeaseCheck","the lease was checked before it was taken"),o("checkpointTake","write","a record was written before the checkpoint was taken"),o("leaseAcquire","write","a record was written before the lease was taken"),o("afterLeaseCheck","write","a record was written before the lease was checked"),o("write","leaseRelease","the lease was given back before the last write"),o("write","recordTypeReadBack","the record types were read back before the last write"),o("leaseRelease","recordTypeReadBack","the record types were read back while the lease was held"),n("leaseAcquire")>=0&&n("leaseRelease")<0&&t.push("the lease was never given back");let i=n("result");return i>=0&&e.slice(i+1).some(s=>s!=="result")&&t.push("the run went on past its result"),t}var W={insert:"go in",update:"are updated",delete:"are deleted",undelete:"come back"},L={flow:"flow",process:"process",workflowRule:"workflow rule",trigger:"Apex trigger"},h=3,v=/__e$/i;function u(e){return e.toLowerCase()}function N(e){let t=new Set,n=[];for(let r of e)t.has(u(r))||(t.add(u(r)),n.push(r));return n}function F(e){let t=e.slice(0,h),n=e.length-t.length,r=`${t.join("; ")}${n>0?`; and ${n} more`:""}`;return`${r.charAt(0).toUpperCase()}${r.slice(1)}.`}function I(e){let t=N(e.written),n=new Set(t.map(u)),r=new Map;for(let i of e.running.firing)if(i.flow!==void 0)for(let s of i.flow.creates??[]){let c=u(s);if(n.has(c)||v.test(s))continue;let d=r.get(c);d===void 0&&(d={objectApiName:s,clauses:[],by:[]},r.set(c,d));let p=`the target's ${L[i.kind]} '${i.name}' creates ${s} records as ${i.objectApiName} records ${W[i.write]}`;d.clauses.includes(p)||(d.clauses.push(p),d.by.push({kind:i.kind,name:i.name,objectApiName:i.objectApiName,write:i.write}))}let o=[...r.values()].map(({objectApiName:i,clauses:s,by:c})=>({objectApiName:i,code:"createdByAutomation",reason:F(s),creators:c.slice(0,h),...c.length>h?{moreCreators:c.length-h}:{}}));return{written:t,added:o,excluded:N(e.request.excluded??[]),picked:[...t,...o.map(({objectApiName:i})=>i)]}}var M={[u(m)]:{code:"files",reason:"Files, which every checkpoint of picked objects holds: a rewind deletes the files added since to the records it holds."},[u(x)]:{code:"attachments",reason:"Attachments, which every checkpoint of picked objects holds: a rewind deletes the attachments added since."}},K="Held as every checkpoint of picked objects holds it.",U=new Set([E,S].map(u)),J="A rewind leaves its records as they are.",k="No record was read.";function w(e,t,n){let r=new Map(t.map(a=>[u(a),a])),o=r.has(u(m)),i=a=>r.has(u(a))||o&&U.has(u(a)),s=[],c=a=>{let f=r.get(u(a));f!==void 0&&!s.includes(f)&&s.push(f)};for(let a of e.written)c(a);for(let{objectApiName:a}of e.added)c(a);for(let a of t)c(a);let d=new Set(e.picked.map(u)),p=[...e.added.flatMap(a=>{let f=r.get(u(a.objectApiName));return f===void 0?[]:[{...a,objectApiName:f}]}),...t.filter(a=>!d.has(u(a))).map(a=>({objectApiName:a,...M[u(a)]??{code:"heldUnasked",reason:K}}))],l=n.filter(({objectApiName:a})=>!i(a)).map(({objectApiName:a,reason:f,code:b,detail:y,records:O,limit:B})=>({objectApiName:a,...b!==void 0?{code:b}:{},reason:`${f} ${J}`,...y!==void 0?{detail:y}:{},...O!==void 0?{records:O}:{},...B!==void 0?{limit:B}:{}})),H=new Map(n.map(({objectApiName:a,reason:f})=>[u(a),f]));return{objects:s,added:p,notHeld:l,holds:i,why:a=>H.get(u(a))}}function g(e,t,n){return e.written.some(o=>t.holds(o))?void 0:e.written.length===0?{code:"NOTHING_HELD",message:`The run names no object it writes: a checkpoint before it would hold nothing a rewind could take back. ${n}`}:{code:"NOTHING_HELD",message:`The checkpoint before the run would hold none of the objects the run writes, so a rewind to it could take nothing of the run back. ${e.written.map(o=>`${o}: ${t.why(o)??"The take did not hold it."}`).join(" ")} ${n}`}}function z(e,t,n){let r={state:"planned",estimate:t.estimate,keepDays:n};if(t.objects.length===0&&t.leftOut.length===0&&t.refusal!==void 0)return{...r,objects:[],added:[],notHeld:[],refusal:t.refusal};let o=w(e,t.objects.map(({objectApiName:s})=>s),t.leftOut),i=g(e,o,k)??t.refusal;return{...r,objects:o.objects,added:o.added,notHeld:o.notHeld,...i!==void 0?{refusal:i}:{}}}var G=1.1;function j(e){return`${(e/(1024*1024)).toFixed(1)} MB`}function P(e,t){if(!(t===void 0||t>=Math.ceil(e*G)))return{code:"DISK",message:`The checkpoint before the run takes about ${j(e)} on this machine, and its disk has ${j(t)} free, less than that and a tenth more: make room, or leave objects out of the checkpoint. ${k}`}}async function _(e){try{let t=await q(e);return Number(t.bavail)*Number(t.bsize)}catch{return}}var V={forge:"Forge run",sync:"Sync run",seed:"Seed run",autopilot:"Autopilot run",frozen:"Frozen Dataset load",empty:"emptying"};function Y(e){return`Before ${V[e]} ${T}`}function ie(e,t){let{min:n,max:r}=R,o=i=>typeof i=="number"&&Number.isInteger(i)&&i>=n&&i<=r;if(e!==void 0){if(!o(e))throw new RangeError(`Not a number of days to keep a checkpoint, ${n} to ${r}: ${e}`);return e}return o(t)?t:R.default}function Q(e,t){return{mode:"picked",objects:e.picked,...e.excluded.length>0?{excluded:e.excluded}:{},nameWithDate:Y(t.module),keepDays:t.keepDays,unprovenLeftOut:!0,beforeRun:{module:t.module,operationId:t.operationId,tool:t.tool}}}function A(e,t){let{checkpoint:n}=t,r=w(e,n.objects.map(({objectApiName:o})=>o),n.scope.leftOut);return{state:"taken",checkpointId:n.checkpointId,name:n.name,takenAt:n.takenAt,expiresAt:n.expiresAt,objects:r.objects,records:n.objects.reduce((o,i)=>o+i.records,0),bytes:n.bytes,requests:t.requests?.total??t.estimate.apiRequests,added:r.added,notHeld:r.notHeld}}function D(e){return`${e.operation==="take"?"a checkpoint is being taken":e.operation==="rewind"?"a rewind is writing":e.operation==="undo"?"an undo is writing":e.operation==="empty"?"an emptying of its objects is writing":"SandForge is deleting checkpoints"} (process ${e.pid} on ${e.host})`}async function X(e,t,n){let r=w(t,n.checkpoint.objects.map(({objectApiName:c})=>c),n.checkpoint.scope.leftOut);if(g(t,r,"")===void 0)return{taken:!0,checkpoint:A(t,n)};let o=await e.delete(n.checkpoint.checkpointId),i=o.outcome==="busy"?`It is kept all the same, as ${D(o.holder)}: delete it from the Checkpoints page once that has ended. Nothing was written.`:"It was deleted again; nothing was written.",s=g(t,r,i);return s===void 0?{taken:!0,checkpoint:A(t,n)}:{taken:!1,refusal:s}}function $(e,t,n){return{...e,...Q(t,n)}}async function se(e,t,n){let{scopeCheckpoint:r}=await import("./chunk-EQOQASDQ.mjs"),o=I(n),i=await r(e,$(t,o,n)),s=z(o,i,n.keepDays);if(s.refusal!==void 0)return s;let c=P(s.estimate.bytes,await(e.freeBytes??_)(e.store.root));return c===void 0?s:{...s,refusal:c}}async function ae(e,t,n,r){let o=await import("./chunk-EQOQASDQ.mjs"),i=I(n);if(r!==void 0){let c=P(r.estimate.bytes,await(e.freeBytes??_)(e.store.root));if(c!==void 0)return{taken:!1,refusal:c}}let s;try{s=await o.takeCheckpoint(e,$(t,i,n))}catch(c){if(c instanceof o.CheckpointTakeStopped)return{taken:!1,stopped:!0};throw c}return s.taken?X(e.store,i,s):{taken:!1,refusal:s.refusal}}async function ce(e,t,n){if(n)return{info:t};let r=await e.delete(t.checkpointId);return r.outcome==="busy"?{info:t,notDeleted:`The checkpoint '${t.name}' taken before the run is kept, though the run wrote nothing: ${D(r.holder)}. Delete it from the Checkpoints page once that has ended.`}:{info:{state:"deleted",deleted:"nothingWritten"}}}function ue(e){return`The checkpoint before the run was refused: ${e.message.endsWith(k)?e.message.slice(0,-k.length).trimEnd():e.message} Nothing was written. Untick Checkpoint first to run without it, or fix what refuses it.`}function de(e){return`The checkpoint before the run could not be taken: ${C(e).replace(/\.$/,"")}. Nothing was written.`}var fe="The checkpoint taken before the run was deleted: the run wrote nothing.";function pe(e){return`Taking the checkpoint first (${Math.round(e)}%)`}export{oe as a,re as b,I as c,z as d,G as e,P as f,_ as g,Y as h,ie as i,Q as j,A as k,X as l,se as m,ae as n,ce as o,ue as p,de as q,fe as r,pe as s};
|
package/lib/chunk-EQOQASDQ.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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}from"./chunk-HUMEKZT5.mjs";import"./chunk-MYTIL2JD.mjs";import"./chunk-JVL444U5.mjs";import"./chunk-KLX67VPL.mjs";import"./chunk-5CD257T7.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-SRQDABQ2.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LV6G4XTK.mjs";import"./chunk-HJKM3E56.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-YMJVMFPY.mjs";import"./chunk-ALJVEUUS.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-4HFRHFGQ.mjs";import"./chunk-342FN7AO.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-Z7X534S4.mjs";import"./chunk-6QSM2WIH.mjs";import"./chunk-WJY54JO7.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-NEVXIGR6.mjs";import"./chunk-NTDN2JQZ.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-6MUEPV7M.mjs";import"./chunk-HJC7AIBK.mjs";import"./chunk-OTWRDD6L.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-RH3N2H7P.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-55HEMHEG.mjs";import"./chunk-P42X3B4D.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VXHDBYMI.mjs";import"./chunk-ENLBYECD.mjs";import"./chunk-PA3MKJVH.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-ZLZRU6MO.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-PNCONNFJ.mjs";import"./chunk-CGWXQX75.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-SIOZXPFG.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-B45CNPUX.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{c as CheckpointTakeStopped,a as DEFAULT_MAX_TOTAL,d as scopeCheckpoint,e as takeCheckpoint,b as takeOrgOf};
|
package/lib/chunk-FQBRBBY4.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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 Ge}from"./chunk-F74IHMGL.mjs";import{a as xe,b as je,c as Te,d as Oe,f as Pe}from"./chunk-M6P5ZZLE.mjs";import{S as Me,aa as Le,ca as De,ea as qe,ia as B,pa as Ie,qa as Ve,ua as Be,wa as U,xa as Ue,za as Qe}from"./chunk-ZLZRU6MO.mjs";import{b as E}from"./chunk-CA5NAXSU.mjs";import{J as Fe,L as ve,M as Ne,N as _e,O as Ae,P as Ce,Q as $e,R as Ee,Yc as Se}from"./chunk-B45CNPUX.mjs";import{e as X,l as ee}from"./chunk-7EANH5PY.mjs";var v=class extends Error{};function lt(e){let r=[],n=0;for(;n<e.length;){let t=e.slice(n),i=/^\s+/.exec(t);if(i){n+=i[0].length;continue}if(t.startsWith("/*")){let d=e.indexOf("*/",n+2);if(d<0)throw new v("an unclosed comment");n=d+2;continue}let l=t[0];if(l==="'"||l==='"'){let d=1;for(;d<t.length&&t[d]!==l;)d+=t[d]==="\\"?2:1;if(d>=t.length)throw new v("an unclosed text");r.push(t.slice(0,d+1)),n+=d+1;continue}let f=/^(?:\d+(?:\.\d+)?|[A-Za-z_$][A-Za-z0-9_$.]*)/.exec(t);if(f){r.push(f[0]),n+=f[0].length;continue}let p=/^(?:&&|\|\||==|!=|<>|<=|>=|[=<>+\-*/^&!(),])/.exec(t);if(!p)throw new v(`an unexpected character: ${t[0]}`);r.push(p[0]),n+=p[0].length}return r}var We=[new Set(["||"]),new Set(["&&"]),new Set(["=","==","<>","!=","<",">","<=",">="]),new Set(["+","-","&"]),new Set(["*","/"]),new Set(["^"])];function ut(e){let r=lt(e),n=0,t=()=>r[n],i=u=>{if(r[n]!==u)throw new v(`${u} expected`);n++},l=u=>{if(u>=We.length)return f();let o=l(u+1);for(let a=t();a!==void 0&&We[u].has(a);a=t())n++,o={kind:"binary",op:a,left:o,right:l(u+1)};return o},f=()=>{if(t()==="!")return n++,{kind:"not",arg:f()};if(t()==="-"||t()==="+"){let u=r[n++],o=f();return u==="-"?{kind:"negative",arg:o}:o}return p()},p=()=>{let u=r[n++];if(u===void 0)throw new v("the formula ends early");if(u==="("){let a=l(0);return i(")"),a}if(u.startsWith("'")||u.startsWith('"'))return{kind:"literal",value:`text:${u.slice(1,-1)}`};if(/^\d/.test(u))return{kind:"literal",value:`number:${Number(u)}`};if(!/^[A-Za-z_$]/.test(u))throw new v(`${u} out of place`);if(t()==="("){n++;let a=[];if(t()!==")")for(a.push(l(0));t()===",";)n++,a.push(l(0));return i(")"),{kind:"call",name:u.toUpperCase(),args:a}}let o=u.toUpperCase();return o==="TRUE"||o==="FALSE"||o==="NULL"?{kind:"literal",value:o.toLowerCase()}:{kind:"reference",name:u.toLowerCase()}},d=l(0);if(n!==r.length)throw new v(`${r[n]} out of place`);return d}function S(e){switch(e.kind){case"call":return e.name==="PRIORVALUE"&&e.args.length===1?S(e.args[0]):{...e,args:e.args.map(S)};case"binary":return{...e,left:S(e.left),right:S(e.right)};case"not":case"negative":return{...e,arg:S(e.arg)};default:return e}}function N(e){switch(e.kind){case"call":return`${e.name}(${e.args.map(N).join(",")})`;case"binary":{let r=e.op==="=="?"=":e.op==="!="?"<>":e.op,n=[N(e.left),N(e.right)];return(r==="="||r==="<>")&&n.sort(),`(${n[0]} ${r} ${n[1]})`}case"not":return`NOT(${N(e.arg)})`;case"negative":return`-(${N(e.arg)})`;case"literal":return e.value;case"reference":return e.name}}var Ke=e=>e==="true"?"false":e==="false"?"true":"unknown";function P(e){return e.kind==="call"&&e.name==="AND"?e.args.flatMap(P):e.kind==="binary"&&e.op==="&&"?[...P(e.left),...P(e.right)]:[e]}function M(e){return e.kind==="call"&&e.name==="OR"?e.args.flatMap(M):e.kind==="binary"&&e.op==="||"?[...M(e.left),...M(e.right)]:[e]}function te(e){if(e.kind==="not"){let r=te(e.arg);return{condition:r.condition,holds:!r.holds}}if(e.kind==="call"&&e.name==="NOT"&&e.args.length===1){let r=te(e.args[0]);return{condition:r.condition,holds:!r.holds}}return e.kind==="binary"&&(e.op==="<>"||e.op==="!=")?{condition:N({...e,op:"="}),holds:!1}:{condition:N(e),holds:!0}}function ne(e){if(e.kind==="literal"){if(e.value==="true")return"true";if(e.value==="false")return"false"}}function k(e){let r=ne(e);if(r)return r;if(e.kind==="not")return Ke(k(e.arg));if(e.kind==="call")switch(e.name){case"ISCHANGED":return"false";case"ISNEW":return"true";case"NOT":return e.args.length===1?Ke(k(e.args[0])):"unknown";case"AND":return ze(P(e));case"OR":return He(M(e));case"IF":{if(e.args.length!==3)return"unknown";let[n,t,i]=e.args,l=k(n);if(l==="true")return k(t);if(l==="false")return k(i);let f=k(t);return f===k(i)?f:"unknown"}default:return"unknown"}return e.kind==="binary"?e.op==="&&"?ze(P(e)):e.op==="||"?He(M(e)):ct(e):"unknown"}function ze(e){let r=e.map(k);if(r.includes("false"))return"false";let n=new Map;for(let t of e){let{condition:i,holds:l}=te(t),f=n.get(i);if(f!==void 0&&f!==l)return"false";n.set(i,l)}return r.every(t=>t==="true")?"true":"unknown"}function He(e){let r=e.map(k);return r.includes("true")?"true":r.every(n=>n==="false")?"false":"unknown"}function ct(e){let r=e.op==="="||e.op==="==",n=e.op==="<>"||e.op==="!=";if(N(e.left)===N(e.right))return n||e.op==="<"||e.op===">"?"false":"unknown";if(!r&&!n)return"unknown";let t=ne(e.left)??k(e.left),i=ne(e.right)??k(e.right);return t==="unknown"||i==="unknown"?"unknown":t===i===r?"true":"false"}function Ze(e){try{return k(S(ut(e)))==="false"}catch(r){if(r instanceof v)return!1;throw r}}var et=25,W=20,ie=W*Me,G=4,Ye=10,dt=2e3,ft=.8;function pt(e){return typeof e!="object"||e===null?null:{optional:e.optionalFilter===!0}}function It(e){return{name:e.name,type:String(e.type),createable:e.createable===!0,nillable:e.nillable!==!1,defaultedOnCreate:e.defaultedOnCreate===!0,referenceTo:(e.referenceTo??[]).filter(r=>typeof r=="string"),picklistValues:(e.picklistValues??[]).filter(r=>r?.active!==!1&&typeof r?.value=="string").map(r=>r?.value),lookupFilter:pt(e.filteredLookupInfo)}}function oe(e){return`SELECT Id, ValidationName, NamespacePrefix, ErrorDisplayField, ErrorMessage, EntityDefinition.QualifiedApiName FROM ValidationRule WHERE Active = true AND EntityDefinition.QualifiedApiName IN (${e.map(n=>`'${n}'`).join(", ")})`}function gt(e){return`SELECT QualifiedApiName, Label FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName = '${x.test(e)?e:""}'`}function q(e){return`SELECT Metadata FROM ValidationRule WHERE Id = '${e}'`}var mt="SELECT DeveloperName, MasterLabel, NamespacePrefix, SobjectType FROM DuplicateRule WHERE IsActive = true",ae=/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/,x=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,ht=ee({DailyApiRequests:ee({Max:X(),Remaining:X()}).loose()}).loose(),y=e=>typeof e=="string"?e:"";function le(e){if(typeof e!="object"||e===null)return;let r=e.QualifiedApiName;return typeof r=="string"&&r!==""?r:void 0}function Q(e,r){return e?`${e}__${r}`:r}function D(e){return typeof e=="string"?[e]:Array.isArray(e)?e.filter(r=>typeof r=="string"):[]}function yt(e){return{...e,nodes:e.nodes.map(r=>r.leftOutByUser===!0?{...r,included:!0}:r)}}function se(e,r){let n=y(e).trim(),t=n.slice(n.lastIndexOf(".")+1);if(x.test(t))return r?r.find(i=>i.name.toLowerCase()===t.toLowerCase())?.name:t}function tt(e){let r=Ie({filterFormula:e}).filter(t=>t.bypass).map(t=>t.name),n=Ve(e).map(t=>t.value===void 0?t.reference:`${t.reference} = '${t.value}'`);return{bypasses:[...r.map(t=>`$Permission.${t}`),...n],permissions:r}}function wt(e,r={}){let n=r.maxRecordsPerObject,t=e.nodes.filter(d=>d.included),i=r.inputMode==="record"&&typeof r.recordId=="string"?"atMost":"exact",l=t.map(d=>d.recordCountUnknown===!0?(n===void 0?i="unknown":i==="exact"&&(i="atMost"),{...d,recordCount:n??0}):{...d,recordCount:n===void 0?d.recordCount:Math.min(d.recordCount,n)}),f=new Ge().generate({...e,nodes:l}).totalApiCalls,p=l.reduce((d,u)=>d+Math.max(1,Math.ceil(u.recordCount/dt)),0);return{writes:f,reads:p,bound:i}}function j(e){let{idValue:r,...n}=e;return{id:Fe(e.kind,e.objectApiName,e.field,e.recordType,r??e.value),source:"metadata",rows:0,...n}}function ue(e){return e?{field:e}:{}}function Vt(e){return async r=>qe(await e.request({method:"POST",url:"/tooling/composite",body:JSON.stringify(De(`/services/data/v${e.version}`,r)),headers:{"Content-Type":"application/json"}}),r.length)}async function bt(e,r,n){let t=e.filter(({id:i})=>ae.test(i));t.length!==0&&await B(r,[{queries:t.map(({id:i,rule:l})=>({soql:q(i),retrieve:{sobject:"ValidationRule",id:i},take:f=>{let p=f[0]?.Metadata,d=typeof p=="object"&&p!==null?p.errorConditionFormula:void 0;typeof d=="string"&&Ze(d)&&(l.onChangeOnly=!0)},refused:()=>{}})),requests:W}],G,n)}async function kt(e,r,n,t,i){let l=[...new Set(r)].filter(g=>x.test(g));if(l.length===0)return[];let f=new Map(l.map(g=>[g.toLowerCase(),g])),p=new Map(l.map((g,b)=>[g,b])),d=await e(oe(l)),u=new Map,o=async(g,b)=>{let R=se(b,void 0);if(!n)return R;let F=u.get(g);F||(F=n(g).catch(()=>[]),u.set(g,F));let C=y(b).trim().toLowerCase();if(!C)return;let _=R?.toLowerCase(),$=await F;return $.length===0?R:$.find(A=>A.name.toLowerCase()===_)?.name??$.find(A=>A.label?.trim().toLowerCase()===C)?.name},h=(await Promise.all(d.map(async g=>{let b=le(g.EntityDefinition),R=b===void 0?void 0:f.get(b.toLowerCase()),F=y(g.ValidationName);return!R||!F?[]:[{id:y(g.Id),rule:{objectApiName:R,name:Q(y(g.NamespacePrefix),F),message:y(g.ErrorMessage),...ue(await o(R,g.ErrorDisplayField))}}]}))).flat().sort((g,b)=>(p.get(g.rule.objectApiName)??0)-(p.get(b.rule.objectApiName)??0)||g.rule.name.localeCompare(b.rule.name));return t&&await bt(h,t,i),h.map(({rule:g})=>g)}async function Bt(e,r,n,t){let i=[...new Set(r)].filter(a=>x.test(a));if(i.length===0)return{rules:[],notRead:0,requests:0};let l=new Map(i.map(a=>[a.toLowerCase(),a])),f=await e(oe(i)),p=f.requests,d=f.records.flatMap(a=>{let h=le(a.EntityDefinition),g=h===void 0?void 0:l.get(h.toLowerCase()),b=y(a.ValidationName);return!g||!b?[]:[{id:y(a.Id),objectApiName:g,name:Q(y(a.NamespacePrefix),b),read:!1,permissions:[]}]}),u=d.filter(a=>ae.test(a.id)),o=(a,h)=>{let g=typeof h=="object"&&h!==null?h.errorConditionFormula:void 0;typeof g=="string"&&(a.read=!0,a.permissions=tt(g).permissions)};return n?p+=await B(n,[{queries:u.slice(0,ie).map(a=>({soql:q(a.id),retrieve:{sobject:"ValidationRule",id:a.id},take:h=>o(a,h[0]?.Metadata),refused:()=>{}})),requests:W}],G,t):await U(u.slice(0,et).map(a=>async()=>{try{let h=await e(q(a.id));p+=h.requests,o(a,h.records[0]?.Metadata)}catch{p++}}),G),{rules:d.filter(a=>a.permissions.length>0).map(({objectApiName:a,name:h,permissions:g})=>({objectApiName:a,name:h,permissions:g})),notRead:d.filter(a=>!a.read).length,requests:p}}function Ut(e,r,n){let t=async i=>(await e(gt(i))).flatMap(l=>typeof l.QualifiedApiName=="string"?[{name:l.QualifiedApiName,...typeof l.Label=="string"?{label:l.Label}:{}}]:[]);return i=>kt(e,i,t,r,n)}var Je=class{deps;constructor(r){this.deps=r}async read(r,n,t,i={}){let l=new Set(i.excludedObjects??[]),f=Ue(yt(t),l),p=[];if(f.length===0)return{gaps:[],unread:p,requests:0};let d=0,u=(s,c)=>{p.push({part:s,reason:c})},o=new Map(f.map(s=>[s.toLowerCase(),s])),a=s=>s===void 0?void 0:o.get(s.toLowerCase()),h=new Map(f.map((s,c)=>[s,c])),g=f.filter(s=>x.test(s)),b=[],R=[],F,C,_=new Map,$=new Map,A=new Set,I=(s,c,m)=>async()=>{try{let w=await c();d+=w.requests,m(w.records)}catch(w){d++,u(s,E(w))}},ce=(s,c,m,w)=>async()=>{try{let{fields:J,sent:ot,createable:at}=await this.deps.describeFields(s,c);ot&&d++,w.set(c,J),w===_&&at===!1&&A.add(c)}catch(J){d++,u(m,`${c}: ${E(J)}`)}};await U([...g.length>0?[I("validationRules",()=>this.deps.toolingQuery(n,oe(g)),s=>{b=s})]:[],I("duplicateRules",()=>this.deps.query(n,mt),s=>{R=s}),async()=>{try{d++,F=await this.deps.readLimits(n)}catch(s){C=E(s)}},...f.flatMap(s=>[ce(n,s,"targetFields",_),ce(r,s,"sourceFields",$)])],G);let T=b.flatMap(s=>{let c=a(le(s.EntityDefinition)),m=y(s.ValidationName);if(!c||!m)return[];let w=y(s.Id);return[{id:ae.test(w)?w:null,name:Q(y(s.NamespacePrefix),m),objectApiName:c,...ue(se(s.ErrorDisplayField,_.get(c))),message:y(s.ErrorMessage),formula:"notRead",bypasses:[],permissions:[]}]}).sort((s,c)=>(h.get(s.objectApiName)??0)-(h.get(c.objectApiName)??0)||s.name.localeCompare(c.name)),{toolingQueries:O,toolingRetrieves:de}=this.deps,K=T.filter(s=>s.id!==null).slice(0,O?ie:et);for(let s of T)s.id===null&&(s.formula="unreadable");let z=R.flatMap(s=>{let c=a(y(s.SobjectType)),m=Q(y(s.NamespacePrefix),y(s.DeveloperName));return!c||!y(s.DeveloperName)?[]:[{objectApiName:c,developerName:m,label:y(s.MasterLabel)||m,fullName:`${y(s.SobjectType)}.${m}`}]}),fe=new Map,pe=[];for(let s=0;s<z.length;s+=Ye)pe.push(z.slice(s,s+Ye).map(c=>c.fullName));let V,H,ge=(s,c)=>{let m=typeof c=="object"&&c!==null?c.errorConditionFormula:void 0;if(typeof m!="string"){s.formula="unreadable";return}s.formula="read",Object.assign(s,tt(m));let w=se(c.errorDisplayField,_.get(s.objectApiName));w&&(s.field=w)},rt=async()=>{if(!O||K.length===0)return;let s=await B(c=>O(n,c),[{queries:K.map(c=>({soql:q(c.id),retrieve:{sobject:"ValidationRule",id:c.id},take:m=>ge(c,m[0]?.Metadata),refused:m=>{c.formula="unreadable",V??=m}})),requests:W}],G,de&&(c=>de(n,c)));d+=s},me=new Map,Z={},he=[...A].filter(s=>x.test(s)),st=async()=>{let[s,c]=await Promise.all([Oe((m,w)=>this.deps.toolingQuery(m,w),n,he),this.deps.createFacts?this.deps.createFacts(n).then(m=>({facts:m,requests:0})).catch(()=>({facts:{},requests:0})):Te(this.deps,n)]);d+=s.requests+c.requests;for(let[m,w]of s.answered)me.set(m,w);Z=c.facts};await U([...he.length>0?[st]:[],...O?[rt]:[],...(O?[]:K).map(s=>async()=>{try{let c=await this.deps.toolingQuery(n,q(s.id));d+=c.requests,ge(s,c.records[0]?.Metadata)}catch(c){d++,s.formula="unreadable",V??=E(c)}}),...pe.map(s=>async()=>{try{d++;for(let c of await this.deps.readDuplicateRules(n,s)){if(typeof c!="object"||c===null)continue;let m=c,w=y(m.fullName);w&&fe.set(w.toLowerCase(),m)}}catch(c){H??=E(c)}})],G),V!==void 0&&u("validationRuleFormulas",V),H!==void 0&&u("duplicateRuleActions",H);let Y=new Set,ye=!1;T.some(s=>s.permissions.length>0)&&await I("userPermissions",()=>this.deps.query(n,Le),s=>{ye=!0;for(let c of s)Y.add(Be(y(c.NamespacePrefix),y(c.DeveloperName)))})();let we=[...new Set(T.flatMap(s=>s.permissions.filter(c=>!Y.has(c.toLowerCase()))))],it=we.length>0?await Qe(we,async s=>{let c=[];return await I("permissionSets",()=>this.deps.query(n,s),m=>{c=m})(),c},()=>p.some(s=>s.part==="permissionSets")):void 0,be=[...T.map(s=>vt(s,ye?Y:void 0,it)),...z.map(s=>Nt(s,fe.get(s.fullName.toLowerCase()))),...f.flatMap(s=>{if(A.has(s))return[Ft(s,xe(s,Z,me.get(s.toLowerCase())),_.get(s)??[],Z)];let c=_.get(s),m=$.get(s);return c&&m?_t(s,c,m,i):[]})],ke=ht.safeParse(F),Re=C===void 0&&ke.success?ke.data.DailyApiRequests:void 0;return Re||u("apiBudget",C??"the limits the org answered hold no DailyApiRequests"),be.push(At(t,i,f[0],Re)),{gaps:Ae(be),unread:p,requests:d}}},Rt={platform:"object_platform_only",setup:"object_setup_only",feature:"object_feature_off",parent:"object_through_parent",user:"object_not_createable"};function Ft(e,r,n,t){let i=r==="parent"?Pe(n,t):[];return j({kind:Rt[r],severity:je(r)?"info":"blocking",objectApiName:e,...i.length>0?{detail:{editOn:i}}:{},decisions:["exclude_object"]})}function vt(e,r,n){let t=r?e.permissions.filter(f=>r.has(f.toLowerCase())):[],i=t.length>0?[]:e.permissions.flatMap(f=>{let p=n?.find(d=>d.permission.toLowerCase()===f.toLowerCase());return p?[Ce(p)]:[]}),l=e.field?["leave_empty","ignore"]:["ignore"];return j({kind:"validation_rule",severity:t.length>0?"info":"warning",objectApiName:e.objectApiName,...ue(e.field),idValue:e.name,detail:{rule:e.name,message:e.message,formula:e.formula,...e.bypasses.length>0?{bypasses:e.bypasses}:{},...t.length>0?{heldBypasses:t}:{},...i.length>0?{assign:i}:{}},decisions:l,...e.field?{defaultDecision:"leave_empty"}:{}})}function Nt(e,r){let n=y(r?.actionOnInsert).toLowerCase(),t=n==="block"||n==="allow"?n:"unknown",i=D(r?.operationsOnInsert).map(f=>f.toLowerCase());return j({kind:"duplicate_rule",severity:t==="allow"?"info":"warning",objectApiName:e.objectApiName,idValue:e.developerName,detail:{rule:e.label,developerName:e.developerName,action:t,...t==="allow"?{alert:i.includes("alert")}:{},...t==="allow"?{report:i.includes("report")}:{}},decisions:t==="allow"?["ignore"]:["ignore","exclude_object"],...t==="allow"?{defaultDecision:"ignore"}:{}})}function _t(e,r,n,t){let i=o=>o.toLowerCase(),l=new Set((t.fieldExclusions?.[e]??[]).map(i)),f=new Map(Object.entries(t.fieldMappings?.[e]??{}).map(([o,a])=>[i(o),i(a)])),p=new Set([...f].filter(([o])=>!l.has(o)).map(([,o])=>o)),d=new Map(n.map(o=>[i(o.name),o])),u=o=>{let a=i(o);if(p.has(a))return;let h=d.get(a);return h?l.has(a)||f.has(a)?"excluded":h.createable?void 0:"notCreateableInSource":"notInSource"};return r.flatMap(o=>{let a=u(o.name);if(o.createable&&!o.nillable&&!o.defaultedOnCreate&&a)return[j({kind:"required_field_missing",severity:"blocking",objectApiName:e,field:o.name,detail:{type:o.type,reason:a,...o.referenceTo.length>0?{referenceTo:o.referenceTo}:{},...o.picklistValues.length>0?{values:o.picklistValues}:{}},decisions:["set_default","exclude_object"]})];if(o.type==="reference"&&o.lookupFilter&&!a){let h=o.nillable;return[j({kind:"lookup_filter",severity:"warning",objectApiName:e,field:o.name,detail:{referenceTo:o.referenceTo,optional:h,filterOptional:o.lookupFilter.optional},decisions:h?["leave_empty","ignore"]:["ignore","exclude_object"],...h?{defaultDecision:"leave_empty"}:{}})]}return[]})}function At(e,r,n,t){let i=e.nodes[0]?.objectApiName??n,l=wt(e,r),f=l.writes+l.reads,p="warning";if(t&&l.bound!=="unknown"){let d=f>t.Remaining,u=t.Max-t.Remaining+f>ft*t.Max;p=d&&l.bound==="exact"?"blocking":d||u?"warning":"info"}return j({kind:"api_budget",severity:p,objectApiName:i,detail:{calls:f,writes:l.writes,reads:l.reads,estimate:l.bound,...t?{max:t.Max,remaining:t.Remaining}:{budgetRead:!1}},decisions:["ignore"]})}var Ct={blocking:"BLOCKING",warning:"warning",info:"info"},$t=new Set(["picklist_value_refused","dependent_value_invalid","picklist_value_absent","currency_inactive"]),Et=new Set(["record_type_unmapped","record_type_unavailable"]);function nt(e,r,n=[e.id]){if(ve(r.ignoredGaps,e.id,n)!==void 0)return"left as it is";let t=e.objectApiName;if(r.excludedObjects?.includes(t))return`${t} left out of the run`;let i=new Set(e.decisions),{field:l,value:f}=e;if(i.has("skip_rows")&&Ne((r.skippedRows??[]).filter(o=>o.object===t),e.id,n))return"these rows held back";if($t.has(e.kind)&&l!==void 0&&f!==void 0&&(i.has("map_value")||i.has("leave_empty"))){let o=(r.picklistValueMappings??[]).filter(h=>h.object===t&&h.field===l&&h.from===f),a=_e(o,e,n);if(a?.to===null&&i.has("leave_empty"))return"the field left empty in these rows";if(a&&a.to!==null&&i.has("map_value"))return`written as "${a.to}"`}let p=Et.has(e.kind)?e.value??e.recordType:void 0;if(p!==void 0&&i.has("map_record_type")){let o=r.recordTypeMappings?.find(a=>a.object===t&&a.from===p);if(o)return o.to===null?"written with the object's default record type":`written as record type ${o.to}`}if(l===void 0)return;let d=o=>o.object===t&&o.field===l,u=i.has("set_default")?r.defaultValues?.find(d):void 0;if(u)return`default "${String(u.value)}"`;if(i.has("truncate")&&r.truncateFields?.some(d))return"cut to the field's length";if(i.has("leave_empty")&&r.fieldExclusions?.[t]?.includes(l))return"the field left out of the rows"}function Qt(e,r){let n=e.gaps.map(t=>t.id);return{...e,gaps:e.gaps.map(t=>{let i=nt(t,r,n);return i===void 0?t:{...t,answeredBy:i}})}}function Xe(e,r,n,t){if(t)return`the mute lifts it (${t.permission}, in ${t.permissionSet}): ${re(e,!0)}`;let i=r?nt(e,r,n):void 0;return i===void 0?`${Ct[e.severity]}: ${re(e)}`:`answered by the run's decision: ${i} \u2014 ${re(e)}`}var St={validationRules:"the validation rules",validationRuleFormulas:"the formulas of some validation rules",duplicateRules:"the duplicate rules",duplicateRuleActions:"what the duplicate rules do on insert",userPermissions:"the custom permissions of the user the run writes as",permissionSets:"the permission sets that hold a bypass of a validation rule the user the run writes as does not",targetFields:"the fields of an object in the target",sourceFields:"the fields of an object in the source",apiBudget:"the daily API requests left"},Gt={notInSource:"the source has no such field",notCreateableInSource:"the source cannot give it",excluded:"the run leaves it out"},L=e=>typeof e=="number"?String(e):"?";function re(e,r=!1){let n=e.detail??{};switch(e.kind){case"required_field_missing":return`required field ${e.field??""} (${y(n.type)}): only the target requires it, and the run does not write it (${Gt[y(n.reason)]??y(n.reason)}): every row is refused unless it is given a value`;case"validation_rule":{let t=e.field?` on ${e.field}`:"",i=[...D(n.bypasses).map(f=>`not when ${f}`),...D(n.heldBypasses).length>0?[`kept quiet for this run: the user it writes as holds ${D(n.heldBypasses).join(", ")}`]:[],...n.formula==="notRead"?["formula not read"]:[],...n.formula==="unreadable"?["formula unreadable"]:[],...e.field&&!r?[`a row it refuses goes again without ${e.field}`]:[]],l=y(n.message)?`: "${y(n.message)}"`:"";return`validation rule "${y(n.rule)}"${t}${l}${i.length>0?` (${i.join("; ")})`:""}`}case"duplicate_rule":{let t=`duplicate rule "${y(n.rule)}"`;if(n.action==="block")return`${t}: blocks an insert it matches: a row it matches is refused, whatever allowSave says`;if(n.action==="allow"){let i=[n.alert===!0?"an alert":"",n.report===!0?"a report":""].filter(Boolean).join(" and ");return`${t}: allows an insert it matches${i?`, with ${i}`:""}: the run saves it (allowSave=true)`}return`${t}: what it does on insert was not read: a rule that blocks refuses a row it matches`}case"lookup_filter":return`lookup filter on ${e.field??""}: not checked before the run; `+(n.optional===!0?"a lookup it refuses is left empty":"the lookup is required, and a row it refuses is refused");case"object_not_createable":return"the user the run writes as may not create its records in the target: every row is skipped, after the objects written before it, unless the object is left out";case"object_platform_only":return"no user can create its records in the target, the platform writes them itself: the run skips every row of it";case"object_setup_only":return"no user can create its records in the target, not even one with Modify All Data, and no permission set gives Create on it: setup the org keeps as records, or the platform's own; the run skips every row of it";case"object_feature_off":return"even a user with Modify All Data may not create its records in the target, though a permission set can give Create on it: a feature or licence the target has not turned on for that user keeps it closed; turn it on, or every row is skipped, after the objects written before it, unless the object is left out";case"object_through_parent":{let t=D(n.editOn);return`no permission set gives Create on it: ${t.length>0?`the user the run writes as creates its records with Edit on ${t.join(" and ")}, which they hang from, or no user can`:"the records they hang from may open it to the user the run writes as, or no user can: read as a user with Modify All Data, the target would tell"}; every row is skipped, after the objects written before it, unless the object is left out`}case"api_budget":{let t=`about ${L(n.calls)} call(s) (${L(n.writes)} write(s) of 200 rows, ${L(n.reads)} read(s))`,i=n.estimate==="atMost"?`at most ${t}, counted on whole tables`:n.estimate==="unknown"?"an unknown number of calls: an object was never counted":t,l=n.budgetRead===!1?"the daily requests left could not be read":`${L(n.remaining)} of ${L(n.max)} daily requests left`;return`API budget: the run takes ${i}; ${l}`}default:return e.kind}}function xt(e,r,n){return $e(e).map(({permission:t,permissionSet:i,others:l})=>{if(!i)return` ${t}: no permission set of ${r} holds it: an admin creates one that includes it`;let f=l.length>0?`; also held by ${l.map(d=>d.name).join(", ")}`:"",p=n?`: ${Se(i.name,r,n)}`:"";return` ${t}: held by permission set ${i.name}, the smallest${f}${p}`})}function Wt(e,r,n={}){let t=[`target gaps: what ${r} holds against the rows, read from its metadata`],i=e.gaps.map(u=>u.id),l=e.gaps.filter(u=>u.kind==="api_budget"),f=e.gaps.filter(u=>u.kind!=="api_budget"),p=[...new Set(f.map(u=>u.objectApiName))].sort((u,o)=>u.localeCompare(o));for(let u of p){t.push(` ${u}`);for(let o of f.filter(a=>a.objectApiName===u)){let a=Ee(o,n.lifted);t.push(` ${Xe(o,n.decisions,i,a)}`),a||t.push(...xt(o,r,n.username))}}f.length===0&&t.push(e.unread.length>0?" nothing found in what could be read":" no validation rule, duplicate rule, field only the target requires or lookup filter");for(let u of l)t.push(` ${Xe(u,n.decisions,i)}`);let d=f.filter(u=>u.detail?.formula==="notRead").length;d>0&&t.push(` ${d} validation rule formula(s) not read: the read takes ${n.formulasBound??ie} at most`);for(let{part:u,reason:o}of e.unread)t.push(` ${St[u]??u} could not be read: ${o}`);return t.push(` read in ${e.requests} request(s) to ${r}`),t}export{et as a,W as b,ie as c,It as d,oe as e,gt as f,q as g,mt as h,tt as i,wt as j,Vt as k,kt as l,Bt as m,Ut as n,Je as o,nt as p,Qt as q,Wt as r};
|
package/lib/chunk-GAM726CK.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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{b as f}from"./chunk-SBIMVCXT.mjs";import{d as e}from"./chunk-NTOVCTRS.mjs";var o=e(f());var export_jsforce=o.default;export{export_jsforce as jsforce};
|
package/lib/chunk-HJC7AIBK.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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 P}from"./chunk-ZUTYVST5.mjs";import{d as X}from"./chunk-55HEMHEG.mjs";import{d as Z}from"./chunk-WIO4XO4F.mjs";import{a as F}from"./chunk-EADHKH3A.mjs";import{c as H,g as Y}from"./chunk-GCOB7K5N.mjs";import{f as Q,s as W}from"./chunk-CGWXQX75.mjs";import{a as U,f as D,h as _}from"./chunk-TZE3Y7IQ.mjs";import{J as B,L as z,O as V,Tb as k}from"./chunk-B45CNPUX.mjs";import{b as I,k as C,l as A,v as K,z as R}from"./chunk-7EANH5PY.mjs";function Pe(e){let n=new Set;for(let t of e)t.controllerName&&n.add(t.controllerName);return n}function J(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}function Me(e,n){let t=J(e.precision),r=typeof e.scale=="number"&&e.scale>=0?e.scale:void 0,o=J(e.digits),s=(e.picklistValues??[]).filter(d=>d!==null&&typeof d.value=="string"),i={};if(e.controllerName)for(let d of s)d.active===!1||typeof d.validFor!="string"||(i[d.value]=d.validFor);return{...t!==void 0?{precision:t}:{},...t!==void 0&&r!==void 0?{scale:r}:{},...o!==void 0?{digits:o}:{},...e.unique===!0?{unique:!0}:{},...e.unique===!0&&typeof e.caseSensitive=="boolean"?{caseSensitive:e.caseSensitive}:{},...e.calculated===!0?{calculated:!0}:{},...e.filteredLookupInfo?{filteredLookup:!0}:{},...Object.keys(i).length>0?{validFor:i}:{},...n.has(e.name)&&s.length>0?{controllingValues:s.map(d=>d.value)}:{}}}function je(e,n){return e.caseSensitive===!1?n.toLowerCase():n}function M(e,n){if(n<0)return!1;let r=Buffer.from(e,"base64")[n>>3];return r!==void 0&&(r&128>>n%8)!==0}var ie={picklist_value_refused:["map_value","leave_empty","skip_rows","exclude_object","ignore"],dependent_value_invalid:["map_value","leave_empty","exclude_object","ignore"],picklist_value_absent:["map_value","skip_rows","ignore"],required_field_missing:["set_default","exclude_object","ignore"],value_too_long:["truncate","exclude_object","ignore"],number_out_of_range:["exclude_object","ignore"],record_type_unmapped:["map_record_type","exclude_object","ignore"],record_type_unavailable:["map_record_type","exclude_object","ignore"],currency_inactive:["map_value","skip_rows","exclude_object","ignore"],unique_value_collision:["exclude_object","ignore"]};function S(e){return[...ie[e]??["ignore"]]}var se=100,ae=new Set(["longest","colliding"]),T=class{gaps=new Map;recordTypes=new Map;get size(){return this.gaps.size}knowRecordTypes(n,t,r){let o=de(r);o!==void 0&&this.recordTypes.set(n,{...this.recordTypes.get(n),[t]:o})}add(n){let t=B(n.kind,n.objectApiName,n.field,n.recordType,n.value),r=this.gaps.get(t);if(!r){this.gaps.set(t,{...n,id:t,source:"simulation",decisions:[...n.decisions]});return}r.rows+=n.rows,n.decisions.includes("skip_rows")||(r.decisions=r.decisions.filter(s=>s!=="skip_rows"));let o={...n.detail??{},...r.detail??{}};for(let s of ae){let i=r.detail?.[s],d=n.detail?.[s];typeof i=="number"&&typeof d=="number"&&(o[s]=Math.max(i,d))}r.detail=o}list(n){let t=[...this.gaps.keys()],r=[...this.gaps.values()].map(o=>this.withSameDeveloperName(o)).map(o=>z(n,o,t)!==void 0?{...o,detail:{...o.detail??{},ignored:!0}}:o);return V(r)}withSameDeveloperName(n){let t=n.kind==="record_type_unmapped";return le(n,this.recordTypes.get(n.objectApiName)?.[t?"source":"target"])}};function de(e){let n=e.filter(t=>!t.master);if(!n.some(t=>t.namespacePrefix===void 0))return n.map(Z)}function le(e,n){let t=e.kind==="record_type_unmapped"?e.value:e.recordType;if(t===void 0||n===void 0)return e;let r=Y(t);if(!r.namespacePrefix)return e;let o=n.filter(s=>s.developerName===r.developerName&&s.namespacePrefix!==r.namespacePrefix).map(s=>H(s.namespacePrefix,s.developerName));return o.length===0?e:{...e,detail:{...e.detail??{},sameDeveloperName:[...new Set(o)].sort()}}}function j(e){return[...new Set(e)].sort().slice(0,se)}function Ve(e,n,t){let r=[];for(let o of n){if(o.field===P)continue;let s=t(o);for(let i of o.values)r.push({kind:"picklist_value_refused",severity:"warning",objectApiName:e,field:o.field,...o.recordType!==void 0?{recordType:o.recordType}:{},value:i,rows:1,detail:{reason:o.reason,...s?{allowed:j(s)}:{},...o.controllingField?{controllingField:o.controllingField}:{},...o.replacedBy!==void 0?{replacement:o.replacedBy}:{}},decisions:S("picklist_value_refused").filter(d=>d!=="skip_rows"||o.reason!=="controlling-value"),defaultDecision:o.replacedBy!==void 0?"map_value":"leave_empty"})}return r}var ce=new Set(["string","textarea","email","phone","url","encryptedstring"]),ue=new Set(["double","currency","percent"]);function fe(e){return e==null||e===""}function ne(e){return e.createable&&e.nillable===!1&&e.defaultedOnCreate!==!0&&e.calculated!==!0&&e.type!=="boolean"}function pe(e,n,t){return e==="Account"&&n==="Name"&&W(t)}function ge(e,n,t,r){return r.filter(o=>ne(o)&&fe(n[o.name])&&!pe(e,o.name,t))}function me(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string"||e.trim()==="")return;let n=Number(e);return Number.isFinite(n)?n:void 0}function ee(e){if(e.type==="int"&&e.digits!==void 0)return e.digits;if(e.precision!==void 0)return e.precision-(e.scale??0)}function ye(e,n){return e?e.type==="boolean"?n===!0||n==="true"?1:n===!1||n==="false"?0:-1:typeof n!="string"||n===""?-1:(e.controllingValues??[]).indexOf(n):-1}function te(e,n){let{objectApiName:t,rows:r,targetFields:o,picklistValuesByField:s,picklistFields:i}=e,d=new Map(o.map(l=>[l.name,l])),u=o.filter(ne),g=o.filter(l=>l.createable&&ce.has(l.type??"")&&(l.length??0)>0),f=o.filter(l=>l.createable&&(ue.has(l.type??"")||l.type==="int")&&ee(l)!==void 0),y=[...i].filter(([l,c])=>c.anyValue===!0&&s?.has(l)===!0),m=o.filter(l=>l.createable&&l.controllerName!==void 0&&l.validFor!==void 0);for(let{payload:l,source:c,typed:p}of r){for(let a of ge(t,l,c,u))n.add({kind:"required_field_missing",severity:"blocking",objectApiName:t,field:a.name,rows:1,...a.type?{detail:{type:a.type}}:{},decisions:S("required_field_missing")});for(let a of g){let h=l[a.name],b=a.length??0;typeof h!="string"||h.length<=b||n.add({kind:"value_too_long",severity:"blocking",objectApiName:t,field:a.name,rows:1,detail:{length:b,longest:h.length},decisions:S("value_too_long")})}for(let a of f){let h=me(l[a.name]),b=ee(a);h===void 0||b===void 0||Math.abs(Math.trunc(h))<10**b||n.add({kind:"number_out_of_range",severity:"blocking",objectApiName:t,field:a.name,rows:1,detail:{...a.precision!==void 0?{precision:a.precision}:{},...a.scale!==void 0?{scale:a.scale}:{},...a.type==="int"&&a.digits!==void 0?{digits:a.digits}:{}},decisions:S("number_out_of_range")})}for(let[a,h]of y){let b=l[a];if(typeof b!="string"||b==="")continue;let O=s?.get(a),E=h.multi?b.split(";"):[b];for(let v of new Set(E))O?.has(v)||n.add({kind:"picklist_value_absent",severity:"info",objectApiName:t,field:a,value:v,rows:1,decisions:S("picklist_value_absent")})}if(!p)for(let a of m){let h=l[a.name];if(typeof h!="string"||h==="")continue;let b=d.get(a.controllerName??""),O=ye(b,l[a.controllerName??""]),E=i.get(a.name)?.restricted===!0,v=i.get(a.name)?.multi?h.split(";"):[h];for(let G of new Set(v)){let $=a.validFor?.[G];$!==void 0&&(O>=0&&M($,O)||n.add({kind:"dependent_value_invalid",severity:E?"blocking":"warning",objectApiName:t,field:a.name,value:G,rows:1,detail:{controllingField:a.controllerName??"",allowed:j((b?.controllingValues??[]).filter((De,oe)=>M($,oe)))},decisions:S("dependent_value_invalid")}))}}}}function Ue(e,n,t,r){return{kind:"currency_inactive",severity:"warning",objectApiName:e,field:P,value:n,rows:t,...r&&r.to.length>0?{detail:{replacement:r.to.join(", "),...r.converted.length>0?{amountsConverted:[...r.converted]}:{},...r.asRead?{amountsAsRead:!0}:{}}}:{},decisions:S("currency_inactive"),defaultDecision:"map_value"}}function Qe(e,n,t,r){return{kind:"unique_value_collision",severity:"warning",objectApiName:e,field:n,rows:t,detail:{colliding:r,linkedToTheRecordItNames:!0},decisions:S("unique_value_collision"),defaultDecision:"ignore"}}function We(e,n,t,r,o){return{kind:e,severity:"blocking",objectApiName:n,field:"RecordTypeId",...e==="record_type_unavailable"?{recordType:t}:{value:t},rows:r,detail:{mapTo:j(o)},decisions:S(e)}}var he=10;function re(e){switch(e.operation){case"insert":return null;case"upsert":return e.externalIdField??"Id";case"update":case"delete":return"Id"}}function w(e){if(e==null||typeof e!="string"&&typeof e!="number"&&typeof e!="boolean")return null;let n=String(e);return n===""?null:n.toLowerCase()}function x(e){return typeof e=="number"&&Number.isFinite(e)?String(e):typeof e=="boolean"?e?"true":"false":`'${U(String(e))}'`}var be=200,we=4e3;function N(e){let n=[],t=[],r=0;for(let o of e){let s=x(o).length+2;t.length>0&&(t.length>=be||r+s>we)&&(n.push(t),t=[],r=0),t.push(o),r+=s}return t.length>0&&n.push(t),n}function nn(e,n){return async(t,r,o,s)=>{let i=k(r.objectApiName),d=_(o),u=new Map;for(let g of N(s)){if(n?.aborted)throw new Error("The simulation was cancelled.");let{records:f}=await F(e,`SELECT ${d} FROM ${i} WHERE ${d} IN (${g.map(x).join(", ")})`);for(let y of f){let m=w(y[d]);m!==null&&u.set(m,(u.get(m)??0)+1)}}return u}}var Se=new Set(["attributes","Id"]);function ke(e,n,t,r){return n?e.conflictFields.filter(o=>o!==t&&!Se.has(o)&&o in n&&(r===null||r.has(o))):[]}var tn=new Set(["noKey","notInTarget","ambiguous"]);function Re(e,n,t){let r=e.operation,o=re(e);if(o===null)return"insert";let s=w(n[o]);if(s===null)return r==="delete"?"notSent":"noKey";let i=t.get(s)??0;return r==="upsert"?i===0?o.toLowerCase()==="id"?"notInTarget":"insert":i===1?"update":"ambiguous":i===0?"notInTarget":r==="update"?"update":"delete"}function rn(e){let{objectConfig:n,records:t,inTarget:r}=e,o=n.operation,s=re(n),i={insert:0,update:0,delete:0,noKey:0,notInTarget:0,notSent:0,ambiguous:0},d=new Set;t.forEach((c,p)=>{let a=Re(n,c,r);i[a]++,(a==="insert"||a==="update")&&d.add(p)});let u=e.leftOut.map(({why:c,count:p})=>Q(p,c));i.noKey>0&&u.push(o==="upsert"?`${i.noKey} record(s) carry no value in ${s}: an upsert matches on it, and the target refuses a record without one.`:`${i.noKey} record(s) carry no Id: an update finds its record by Id, and the target refuses one without it.`),i.notInTarget>0&&u.push(`${i.notInTarget} record(s) carry an Id the target does not hold: ${o==="upsert"?"an upsert on the Id finds no record there and creates none":`${o==="update"?"an update":"a delete"} finds no record there`}, and the target refuses it. Two orgs share a record's Id only when it was copied with the org.`),i.ambiguous>0&&u.push(`${i.ambiguous} record(s) match more than one record of the target on ${s}: an upsert finds no single record to update, and the target refuses it.`),i.notSent>0&&u.push(`${i.notSent} record(s) carry no Id: a delete sends ids alone, so the run leaves them out.`);let g=new Map;e.unsettled.forEach((c,p)=>{let a=String(c[e.matchField]??"");a&&d.has(p)&&g.set(a,c)});let f=new Map,y=0;for(let c of e.conflicts){let p=ke(c,g.get(c.recordId),e.matchField,e.writable);if(p.length!==0){y++;for(let a of p)f.set(a,(f.get(a)??0)+1)}}let m=[...f].sort(([c,p],[a,h])=>h-p||c.localeCompare(a)).slice(0,he).map(([c])=>c),l=e.leftOut.reduce((c,{count:p})=>c+p,0);return{objectApiName:n.objectApiName,operation:o,read:e.read,insert:i.insert,update:i.update,delete:i.delete,skipped:l+i.notSent,refused:i.noKey+i.notInTarget+i.ambiguous,conflicts:y,conflictFields:m,notes:u}}function _e(e){let n=e.field??"";switch(e.kind){case"required_field_missing":return`${e.rows} record(s) leave ${n} empty, which the target requires: it refuses them (REQUIRED_FIELD_MISSING).`;case"value_too_long":return`${e.rows} record(s) hold a ${n} longer than the ${String(e.detail?.length)} characters the target's field takes (the longest, ${String(e.detail?.longest)}): it refuses them (STRING_TOO_LONG).`;case"number_out_of_range":return`${e.rows} record(s) hold a ${n} larger than the target's field takes: it refuses them (NUMBER_OUTSIDE_VALID_RANGE).`;default:return}}function on(e,n,t){let r=new Set,o=new T;n.forEach(({payload:i,source:d,creates:u},g)=>{let f=new T;te({objectApiName:e,rows:[{payload:i,source:d,typed:!0}],targetFields:t,picklistValuesByField:null,picklistFields:new Map},f);let y=f.list(new Set).filter(m=>m.severity==="blocking"&&(u||m.kind!=="required_field_missing"));if(y.length!==0){r.add(g);for(let m of y)o.add(m)}});let s=o.list(new Set).flatMap(i=>{let d=_e(i);return d?[d]:[]});return{refused:r,notes:s}}function sn(e,n){let t=new Set,r=new Set,o=[];for(let[s,i]of n){let d=new Set,u=0,g=0,f=0;e.forEach((y,m)=>{let l=w(y[s]);if(l===null)return;let c=i.get(l)??0;c===1?(u++,r.add(m)):c>1?(g++,t.add(m)):d.has(l)&&(f++,t.add(m)),d.add(l)}),u>0&&o.push(`LINKED_TO_EXISTING: ${u} record(s) hold a ${s} the target keeps unique, which a record of the target holds already: it refuses them as duplicates (DUPLICATE_VALUE) and names that record, which the run links them to \u2014 what it writes under them points at that record.`),g+f!==0&&o.push(`${g+f} record(s) hold a ${s} the target keeps unique, which `+[g>0?`several records of the target hold already (${g})`:"",f>0?`a record sent before them holds (${f})`:""].filter(Boolean).join(" or ")+": it refuses them (DUPLICATE_VALUE).")}for(let s of t)r.delete(s);return{refused:t,linked:r,notes:o}}import{createHash as Fe}from"node:crypto";var Ie=5*6e4,Te=500,xe=A({sourceOrgId:I().min(1).max(200),targetOrgId:I().min(1).max(200),objectApiName:I().regex(/^[A-Za-z][A-Za-z0-9_]{0,79}$/),watermark:R.datetime(),fingerprint:I().regex(/^[0-9a-f]{64}$/),recordedAt:R.datetime(),filesSeen:R.datetime().optional(),removedAt:R.datetime().optional()}),Oe=A({version:K(1),entries:C(xe).max(Te),resetAt:R.datetime().optional()});function mn(e){if(e==null)return{kind:"none"};let n=Oe.safeParse(e);if(n.success)return{kind:"stored",state:n.data};let t=n.error.issues[0];return{kind:"unreadable",issue:`${t.path.join(".")||"state"}: ${t.message}`}}function L(e){return Array.isArray(e)?`[${e.map(L).join(",")}]`:e!==null&&typeof e=="object"?`{${Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[r])=>t<r?-1:t>r?1:0).map(([t,r])=>`${JSON.stringify(t)}:${L(r)}`).join(",")}}`:JSON.stringify(e)}function q(e){let n=e?.trim();return n||null}function ve(e,n){let t={direction:e.direction,conflictStrategy:e.conflictStrategy,copiesFiles:e.files?!0:void 0,objectApiName:n.objectApiName,operation:n.operation,externalIdField:q(n.externalIdField),where:q(n.where),fieldMappings:n.fieldMappings??[],unmappedSentAsRead:(n.fieldMappings??[]).length>0?!0:void 0,transformRules:n.transformRules??[],excludedFields:n.excludedFields??[],addOnFields:n.addOnFields??[]};return Fe("sha256").update(L(t)).digest("hex")}function yn(e,n,t){let r=ve(e,n);if(t===null)return{read:"full",reason:"not_saved",fingerprint:r};if(t.kind==="unreadable")return{read:"full",reason:"unreadable",fingerprint:r};if(t.kind==="none")return{read:"full",reason:"first_run",fingerprint:r};let o=t.state.entries.find(s=>s.sourceOrgId===e.sourceOrgId&&s.targetOrgId===e.targetOrgId&&s.objectApiName===n.objectApiName);return o?o.fingerprint!==r?{read:"full",reason:"scope_changed",fingerprint:r}:o.removedAt!==void 0?{read:"full",reason:"removed",fingerprint:r}:{read:"delta",since:o.watermark,fingerprint:r,...o.filesSeen!==void 0?{filesSeen:o.filesSeen}:{}}:{read:"full",reason:t.state.resetAt?"reset":"first_run",fingerprint:r}}var Ne=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;function hn(e,n=Ie){let t=Date.parse(e);if(!Number.isFinite(t))throw new Error(`Not a watermark: "${e}".`);let r=Math.floor((t-n)/1e3)*1e3;return new Date(r).toISOString().replace(/\.\d{3}Z$/,"Z")}function bn(e){let n=Date.parse(e);if(!Number.isFinite(n))throw new Error(`Not a date: "${e}".`);return new Date(Math.floor(n/1e3)*1e3).toISOString().replace(/\.\d{3}Z$/,"Z")}function Ee(e){if(!Ne.test(e)||!Number.isFinite(Date.parse(e)))throw new Error(`Not a SOQL datetime: "${e}".`);return e}function wn(e,n){let t=e?.trim()?D(e):void 0;if(n===void 0)return t;let r=`SystemModstamp > ${Ee(n)}`;return t?`${r} AND (${t})`:r}function $e(e){if(typeof e!="string"||e==="")return null;let n=Date.parse(e.replace(/([+-]\d{2})(\d{2})$/,"$1:$2"));return Number.isFinite(n)?new Date(n).toISOString():null}function Sn(e,n,t){let r={query:i=>e.query(i),queryMore:i=>e.queryMore(i)},o={query:i=>e.query(i,{scanAll:!0}),queryMore:i=>e.queryMore(i)},s=()=>{if(t?.aborted)throw new Error("The run was cancelled.")};return{async latestModstamp(i){let d=k(i),g=(await e.query(`SELECT SystemModstamp FROM ${d} ORDER BY SystemModstamp DESC LIMIT 1`)).records[0];if(!g)return null;let f=$e(g.SystemModstamp);if(f===null)throw new Error(`${d} answered a SystemModstamp that is not a date.`);return f},async deletedRows(i,d,u){let g=k(i),f=new Set(["Id","SystemModstamp",...d.map(_)]),{records:y,truncated:m}=await F(o,`SELECT ${[...f].join(", ")} FROM ${g} WHERE IsDeleted = true AND (${D(u)})`);return{records:y,truncated:m}},async heldInSource(i,d,u){let g=k(i),f=_(d),y=new Set;for(let m of N(u)){s();let{records:l}=await F(r,`SELECT ${f} FROM ${g} WHERE ${f} IN (${m.map(x).join(", ")})`);for(let c of l){let p=w(c[f]);p!==null&&y.add(p)}}return y},async targetIdsByKey(i,d,u){let g=k(i),f=_(d),y=f==="Id"?"Id":`Id, ${f}`,m=new Map;for(let l of N(u)){s();let{records:c}=await F(n,`SELECT ${y} FROM ${g} WHERE ${f} IN (${l.map(x).join(", ")})`);for(let p of c){let a=w(p[f]);a===null||typeof p.Id!="string"||m.set(a,[...m.get(a)??[],p.Id])}}return m}}}var Ae=new Set(["direct","rename","transform"]);function kn(e){let n=e.objectApiName;if(e.operation==="insert"||e.operation==="delete")return{refused:`${n} is written by ${e.operation}, which finds no record by a key: a deleted source record cannot be tied to a target record.`};if(e.operation==="update")return{sourceField:"Id",keyField:"Id"};let t=q(e.externalIdField)??"Id";if((e.addOnFields??[]).some(s=>s.fieldApiName===t))return{refused:`${n}: an add-on writes ${t}, the key the upsert matches on, so it ties no deleted source record to one target record.`};let r=e.fieldMappings??[],o=r.find(s=>s.targetField.toLowerCase()===t.toLowerCase());return!o&&!X(r,e.excludedFields??[]).has(t.toLowerCase())?{sourceField:t,keyField:t}:!o||!Ae.has(o.type)?{refused:`${n}: no source field is carried onto ${t}, the key the upsert matches on, so no deleted source record can be tied to a target record.`}:{sourceField:o.sourceField,keyField:t}}async function Rn(e,n,t,r,o){let s=n.objectApiName,{records:i,truncated:d}=await e.deletedRows(s,[t.sourceField],r),u={ids:[],read:i.length,stillInSource:0,ambiguous:0,noKey:0,truncated:d};if(i.length===0)return u;let g=[];for(let c of i){let p=c[t.sourceField],a=o(c);if(w(p)===null||w(a)===null){u.noKey++;continue}g.push({raw:p,key:a})}if(g.length===0)return u;let f=t.sourceField==="Id"?new Set:await e.heldInSource(s,t.sourceField,g.map(c=>c.raw)),y=g.filter(c=>f.has(w(c.raw))?(u.stillInSource++,!1):!0);if(y.length===0)return u;let m=await e.targetIdsByKey(s,t.keyField,y.map(c=>c.key)),l=new Set;for(let c of y){let p=m.get(w(c.key))??[];p.length>1?u.ambiguous++:p.length===1&&!l.has(p[0])&&(l.add(p[0]),u.ids.push(p[0]))}return u}function _n(e,n){let t=[];return e.stillInSource>0&&t.push(`${e.stillInSource} record(s) deleted in the source share their ${n} with a record the source still holds: their target record was kept.`),e.ambiguous>0&&t.push(`${e.ambiguous} record(s) deleted in the source match more than one target record on ${n}: none of those target records was deleted.`),e.noKey>0&&t.push(`${e.noKey} record(s) deleted in the source carry no ${n}: no target record is tied to them.`),e.truncated&&t.push("The source's deleted records were read up to a bound: the rest are read by the next run, from the same watermark."),t}function Fn(e,n,t,r,o=0){return{read:e.read,...e.read==="delta"?{since:e.since}:{reason:e.reason},changed:n,deletionsChecked:t!==void 0,deleted:t?.deleted??0,deleteFailed:t?.deleteFailed??0,...t?.error!==void 0?{deletionError:t.error}:{},...r!==void 0?{recorded:r}:{},...o>0?{lookupsOwed:o}:{}}}export{Pe as a,Me as b,je as c,ie as d,T as e,de as f,le as g,Ve as h,ge as i,te as j,Ue as k,Qe as l,We as m,re as n,w as o,nn as p,tn as q,Re as r,rn as s,on as t,sn as u,Ie as v,mn as w,yn as x,hn as y,bn as z,Ee as A,wn as B,$e as C,Sn as D,kn as E,Rn as F,_n as G,Fn as H};
|
package/lib/chunk-HUMEKZT5.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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{i as Xe,k as Ye}from"./chunk-MYTIL2JD.mjs";import{d as Ie,i as Le}from"./chunk-JVL444U5.mjs";import{b as Z}from"./chunk-KLX67VPL.mjs";import{c as qe,d as Ze}from"./chunk-5CD257T7.mjs";import{a as Ne,b as De}from"./chunk-5P4PHJRL.mjs";import{c as Oe,d as Ae,j as Te}from"./chunk-SRQDABQ2.mjs";import{a as Ce}from"./chunk-LV6G4XTK.mjs";import{A as ee,B as nt,o as Re,u as et,v as tt}from"./chunk-Z7X534S4.mjs";import{$ as X,T as je,X as xe,Z as We,_ as Q,aa as Y,ba as _e,ca as Ge,da as Ue,ga as ze,ha as Ve,ia as L,ka as q,na as He}from"./chunk-6QSM2WIH.mjs";import{a as Be,v as Ke,w as Je,z as Qe}from"./chunk-WJY54JO7.mjs";import{E as $e,G as Fe,a as Me,e as Pe,o as J,x as ve,y as Ee,z as I}from"./chunk-NEVXIGR6.mjs";import{C as Se}from"./chunk-HJC7AIBK.mjs";import{c as V}from"./chunk-RH3N2H7P.mjs";import{f as he,g as be,h as F,m as ke,n as we,o as H,t as ye,u as K}from"./chunk-PA3MKJVH.mjs";import{b as v}from"./chunk-CA5NAXSU.mjs";import{Tb as $,va as pe,wa as E,za as ge,zd as me}from"./chunk-B45CNPUX.mjs";import{b as ue,k as fe,l as z}from"./chunk-7EANH5PY.mjs";import{readdir as Rt,rm as at,stat as ct}from"node:fs/promises";import{existsSync as Nt,readFileSync as Dt,writeFileSync as Mt}from"node:fs";import{hostname as Pt}from"node:os";import{join as ne}from"node:path";var vt=5e5,Et=1e6,$t=100,Ft="taking",ot=500;function xn(e){let t=We(e),n=[V(e)];return{get version(){return e.version},request:o=>t.request(o),query:(o,s)=>t.query(o,s),queryMore:o=>t.queryMore(o),describeGlobal:async()=>await e.describeGlobal(),toolingObjects:async()=>{try{return(await e.tooling.describeGlobal()).sobjects.map(s=>s.name)}catch{return[]}},serverTime:async()=>(await e.soap.getServerTimestamp()).timestamp,userId:async()=>(await e.soap.getUserInfo()).userId,requestsSent:()=>n.reduce((o,s)=>o+s(),0),countAlso:o=>{n.push(V(o))}}}function It(e){return Be(Ne(e))}var N=class extends Error{constructor(){super("The checkpoint was stopped before it was taken: nothing of it was kept."),this.name="CheckpointTakeStopped"}},x="No record was read.",Lt={excludedByUser:"Left out as asked.",notFound:"The org has no object of this name.",chatter:"Chatter posts, comments and feeds are left out: Salesforce brings a post back only with what it was posted on.",history:"History is left out: it is the org's own trace of changes.",sharing:"Sharing is left out: the org keeps it itself.",changeEvent:"Change events are left out.",unsupportedKind:"Left out: neither the recycle bin nor an update reaches this kind of object as it reaches a record.",customSetting:"Custom settings are left out unless you pick them as custom settings: they are configuration, which a rewind sets back.",notCustomSetting:"Picked as a custom setting: the org has no custom setting of this name.",files:"Documents of the Documents tab are left out: they are shared content kept in folders, as setup is.",heldWithFiles:"Held with its file (ContentDocument): Salesforce neither deletes nor brings back a file's version on its own, and reads the links of a file through the records they tie it to.",setup:"Users, permissions and setup are left out, and so are the org's own logs and jobs.",platformCreated:"Left out: Salesforce alone creates its records, such as approvals, Einstein insights, Data.com clean info and invoices, and no permission lets a user create one.",metadata:"Left out: it is metadata, which a checkpoint doesn't hold.",notWritable:"Left out: the user SandForge connects as may not create, edit and delete its records.",notDescribed:"Left out: the org would not describe it.",noSystemModstamp:"Left out: it has no SystemModstamp, so nothing would tell a record changed since.",noRecycleBin:"Left out: the org deletes its records for good, with no recycle bin, so nothing would tell one deleted since, nor bring it back.",unreadable:"Left out: the org refuses to read it whole.",noViewAll:"Without View All Data and Modify All Data, an object is held only with View All and Modify All on it, and the user SandForge connects as has neither on this one: a record they cannot see would read as deleted since.",noModifyAll:"Without View All Data and Modify All Data, an object is held only with View All and Modify All on it, and the user SandForge connects as has View All on this one, not Modify All: a rewind could not put back what others changed.",activities:"Without View All Data and Modify All Data, tasks and events are left out: Salesforce has no View All for activities, and a private one linked to no record stays out of sight.",catalog:"Without View All Data and Modify All Data, products and price books are left out: Salesforce has no View All or Modify All for them.",filesNotProven:"Without View All Data and Modify All Data, files are left out: nothing proves the user sees every file.",settingNotProven:"Without View All Data and Modify All Data, custom settings are left out: no permission on an object proves the user sees and writes every row.",parentNotSeen:"Without View All Data and Modify All Data, an object with no permissions of its own is held only when the user has View All and Modify All on every record it hangs from, which is not proven here."};function dt(e){let t=Lt[e.reason],n=e.detail===void 0?t:`${t.replace(/\.$/,"")} (${e.detail}).`;return{objectApiName:e.objectApiName,code:e.reason,reason:st(n),...e.detail===void 0?{}:{detail:st(e.detail)}}}function xt(e,t,n){return{objectApiName:e,code:"pastTheLimit",records:t,limit:n,reason:`${e} has ${t} records, past the checkpoint's limit of ${n} for one object: left out of the checkpoint, as part of it would be taken for all of it.`}}function st(e){return e.length<=ot?e:`${e.slice(0,ot-1)}\u2026`}function lt(e,t){return{code:"RUN_WRITING",message:`${t.operation==="take"?`A checkpoint of ${e} is being taken`:t.operation==="rewind"?`A rewind is writing to ${e}`:t.operation==="undo"?`An undo is writing to ${e}`:t.operation==="empty"?`An emptying of its objects is writing to ${e}`:`SandForge is deleting checkpoints of ${e}`} (process ${t.pid} on ${t.host}): take the checkpoint once it has ended. ${x}`}}function ut(e){return typeof e!="object"||e===null?void 0:typeof e.errorCode=="string"?v(e):void 0}function W(e,t){return e instanceof Q||e instanceof Ce||e instanceof N||t?.aborted===!0}var Wt=z({sobjects:fe(he)}).loose();function D(e){return e.toLowerCase()===be.toLowerCase()}function Bt(e,t,n){if(e===void 0)return{why:`the org lists no ${F}`};let o=t.get(e);if(o===void 0)return{why:n.get(e)??"it was not described"};let a=o.fields.find(d=>d.name.toLowerCase()==="linkedentityid")?.referenceTo??[];return a.length===0?{why:"its describe names no record a link ties a file to"}:{linkable:new Set(a.map(d=>d.toLowerCase()))}}async function oe(e,t,n){let o=new Map,s=new Map,a=0,d=await Promise.allSettled(n.map(f=>t.describe(f)));for(let[f,i]of d.entries()){let c=n[f],l;if(i.status==="fulfilled"&&"body"in i.value)l=i.value.body;else{if(i.status==="rejected"&&i.reason instanceof Q)throw i.reason;a++;try{l=await e.request({method:"GET",url:`/services/data/v${e.version}/sobjects/${$(c)}/describe`})}catch(h){let r=ut(h);if(r===void 0)throw new Error(`The org did not answer the describe of ${c}: ${v(h)}`);s.set(c,r);continue}}let u=Ie.safeParse(l);u.success?o.set(c,u.data):s.set(c,"its describe does not read as one")}return{describes:o,errors:s,alone:a}}async function ft(e,t,n){let o=Wt.parse(await e.describeGlobal()),s=await e.toolingObjects?.()??[],a=we(o.sobjects,{mode:n.mode,...n.objects?{objects:n.objects}:{},...n.excluded?{excluded:n.excluded}:{},...n.customSettings?{customSettings:n.customSettings}:{}},s),d=a.candidates.some(D),f=d?o.sobjects.find(g=>g.name.toLowerCase()===F.toLowerCase())?.name:void 0,i=f===void 0?a.candidates:[...a.candidates,f],{describes:c,errors:l,alone:u}=await oe(e,t,i),h,r;if(d){let g=Bt(f,c,l);"linkable"in g?h=g.linkable:r=g.why,f!==void 0&&c.delete(f)}let m=ye(a,c,l);if(r!==void 0){let g=m.objects.find(({objectApiName:A})=>D(A));g!==void 0&&(m=K(m,new Map([[g.objectApiName,`its links to records, ${F}, could not be described: ${r}`]])))}let w=await je(async g=>(await e.query(g)).records),S=new Map(o.sobjects.map(g=>[g.name,it(g)])),O=o.sobjects.filter(ke),p=new Set(O.map(g=>g.name)),b=[...c.values()],y=[];for(let g of m.objects){let A=c.get(g.objectApiName);A&&y.push({scoped:g,label:S.get(g.objectApiName)??g.objectApiName,describe:A,capture:await Le(A,b,{viewsEncryptedData:w}),...p.has(g.objectApiName)?{customSetting:H(A)}:{}})}return{described:i.length,describedAlone:u,objects:y,leftOut:m.leftOut,addedToPicked:a.addedToPicked,...h!==void 0&&y.some(({scoped:g})=>D(g.objectApiName))?{linkable:h}:{},settings:O.map(g=>({objectApiName:g.name,label:it(g)}))}}function it(e){let t=e.label;return typeof t=="string"&&t!==""?t:e.name}async function _t(e,t,n,o){let s=await q(t,n.map(({capture:i})=>({objectApiName:i.objectApiName,readMode:i.readMode})),o),a=new Map,d=new Map,f=0;for(let[i,c]of s.entries()){let{objectApiName:l,readMode:u}=n[i].capture;if("count"in c){a.set(l,c.count);continue}f++;let h=Ge(l,u);try{let r=await e.query(h.soql,{scanAll:h.scanAll});if(typeof r.totalSize!="number")throw new Error("The org gave no count of its records.");a.set(l,r.totalSize)}catch(r){let m=ut(r);if(m===void 0)throw new Error(`The org did not count the records of ${l}: ${v(r)}`);d.set(l,m)}}return{counts:a,refused:d,alone:f}}function pt(e,t){return t?.has(e.toLowerCase())===!0&&!D(e)}async function Gt(e,t,n,o,s){let a=[];for(let{objectApiName:i,records:c}of t){let l=$(i);a.push({objectApiName:l,soql:`SELECT COUNT() FROM ${l} WHERE IsDeleted = true AND SystemModstamp < ${Y(o)}`,scanAll:!0,counts:"inBin"}),c!==0&&(a.push({objectApiName:l,soql:`SELECT COUNT() FROM ${l} WHERE SystemModstamp >= ${_e(o)}`,scanAll:!0,counts:"stampedSince"}),pt(l,n)&&a.push({...Xe(l),counts:"links"}))}let d=await ze(e,a,()=>{},s),f=new Map;return d.forEach((i,c)=>{let{objectApiName:l,counts:u}=a[c],h=i.read?i.totalSize:void 0,r=f.get(l)??{};u==="links"?r.links=h??null:h!==void 0&&(r[u]=h),f.set(l,r)}),{asked:a.length,of:f}}function gt({scoped:e,capture:t,customSetting:n,access:o},s,a,d){return{objectApiName:e.objectApiName,records:s,inBin:a,readOrder:e.readOrder,readMode:t.readMode,undeletable:t.undeletable,cascadeParents:t.cascadeParents,restrictParents:t.restrictParents,fingerprint:d,fields:t.fields,leftOutFields:t.leftOutFields,...n!==void 0?{customSetting:n}:{},...o!==void 0?{access:o}:{}}}function Ut(e){let t=e?.orgType==="Sandbox"||e?.orgType==="Scratch";return Oe(Ae(t)).defaultQueryLimit}async function mt(e,t,n,o,s,a,d,f=bt){let i=n.maxTotal??vt;if(!Number.isInteger(i)||i<1)throw new RangeError(`Not a number of records: ${i}`);let c=Math.min(i,Et),{counts:l,refused:u,alone:h}=await _t(e,t,o.objects,d),r=K({mode:n.mode,objects:o.objects.map(({scoped:k})=>k),leftOut:o.leftOut,packages:[]},u),m=new Map(o.objects.map(k=>[k.scoped.objectApiName,k])),w=r.leftOut.map(dt),S=[];for(let k of r.objects){let j=m.get(k.objectApiName),P=l.get(k.objectApiName);if(!(j===void 0||P===void 0)){if(P>c){w.push(xt(k.objectApiName,P,c));continue}S.push({...j,scoped:{...k,readOrder:S.length},records:P,otherGroups:et(k.objectApiName,j.capture.fields,j.capture.readMode),recount:{}})}}let O=S.some(({scoped:k})=>D(k.objectApiName))?o.linkable:void 0,p=await Gt(t,S.map(({scoped:k,records:j})=>({objectApiName:k.objectApiName,records:j})),O,a,d);for(let k of S)k.recount=p.of.get(k.scoped.objectApiName)??{};w.sort((k,j)=>k.objectApiName<j.objectApiName?-1:k.objectApiName>j.objectApiName?1:0);let b={};for(let{scoped:k,describe:j}of S)b[k.objectApiName]=Me(j.fields);let y=zt(f,tt({described:o.described,describedAlone:o.describedAlone,counted:o.objects.length,countedAlone:h,recounted:p.asked,objects:S.map(k=>({records:k.records,otherGroups:k.otherGroups,...k.recount,entry:gt(k,k.records,0,b[k.scoped.objectApiName].digest)})),pageRows:Ut(n.registered),leftOut:w,printsBytes:(await Fe(b)).length})),g={...y,apiRequestsLeft:s.remaining},A={objects:S,leftOut:w,estimate:g,objectLimit:c,prints:b,...O!==void 0?{linkable:O}:{}};if(y.records>i)return{...A,refusal:{code:"TOO_MANY_RECORDS",message:`The objects this checkpoint would keep hold ${y.records} records in ${n.orgName}, past its limit of ${i}: pick fewer objects, or raise the limit. ${x}`}};let M=nt("take",y.apiRequests,s,n.orgName);return M===void 0?A:{...A,refusal:M}}function ht(e){return{query:t=>e.query(t),queryMore:t=>e.queryMore(t)}}var bt={guard:0,scope:0};function zt(e,t){if(e.guard+e.scope===0)return t;let n=t.requestsByPhase;return{...t,apiRequests:t.apiRequests+e.guard+e.scope,...n!==void 0?{requestsByPhase:{...n,guard:n.guard+e.guard,scope:n.scope+e.scope}}:{}}}function Vt(e){let t=[...e.mode==="picked"?e.objects??[]:[],...Array.isArray(e.customSettings)?e.customSettings:[]];return new Set(t.map(n=>n.toLowerCase()))}function Ht(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}async function kt(e,t,n,o,s,a){if(s.kind==="org")return{scope:{...o,objects:o.objects.map(p=>({...p,access:"org"}))},reads:bt};let d=o.objects.map(({scoped:p})=>p.objectApiName),f={grants:s.objects,describes:o.objects.map(({describe:p})=>p),customSettings:o.objects.filter(({customSetting:p})=>p!==void 0).map(({scoped:p})=>p.objectApiName)},i=qe(d,f),c=[],l=0;if(i.length>0)try{let p=await oe(e,t,i);c=[...p.describes.values()],l=Math.ceil(i.length/xe)+p.alone}catch(p){if(W(p,a))throw p}let u=Ze(d,{...f,describes:[...f.describes,...c]}),h=Vt(n),r=[],m=[...o.leftOut],w=[];for(let p of o.objects){let b=p.scoped.objectApiName,y=u.get(b);if(y!==void 0&&"access"in y){r.push({...p,access:y.access});continue}let g={objectApiName:b,reason:y?.reason??"noViewAll",...y?.detail!==void 0?{detail:y.detail}:{}};m.push(g),h.has(b.toLowerCase())&&n.unprovenLeftOut!==!0&&w.push(g)}let S=new Set(r.map(({scoped:p})=>p.objectApiName)),O={scope:{...o,objects:r,leftOut:m,addedToPicked:o.addedToPicked.filter(p=>S.has(p))},reads:{guard:s.requests,scope:l}};if(w.length>0){let p=w.length===1;return{...O,refusal:{code:"PERMISSIONS",message:`${n.username} doesn't have View All Data and Modify All Data, and the checkpoint can't hold ${Ht(w.map(b=>b.objectApiName))}, asked for by name. ${w.map(b=>`${b.objectApiName}: ${dt(b).reason}`).join(" ")} Leave ${p?"it":"them"} out, or give the user View All Data and Modify All Data. ${x}`}}}return r.length===0&&o.objects.length>0?{...O,refusal:{code:"PERMISSIONS",message:`${n.username} doesn't have View All Data and Modify All Data, nor View All and Modify All on any object this checkpoint would hold: without them, a checkpoint holds only the objects its user sees and puts back whole. Give the user View All and Modify All on the objects to hold, or View All Data and Modify All Data. `+x}}:O}function Kt(e){return e.objects.map(({scoped:t,label:n,capture:o,records:s,customSetting:a,access:d})=>({objectApiName:t.objectApiName,label:n,...t.namespace!==void 0?{namespace:t.namespace}:{},records:s,undeletable:o.undeletable,leftOutFields:o.leftOutFields,...a!==void 0?{customSetting:a}:{},...d!==void 0?{access:d}:{}}))}function wt(e){let t=e.customSettings;return t!==void 0&&(t==="all"||t.length>0)}async function Jt(e,t,n,o,s){let a=new Map(o.objects.map(u=>[u.scoped.objectApiName,u])),d=n.settings.filter(({objectApiName:u})=>!a.has(u)),f=new Map;if(d.length>0)try{({describes:f}=await oe(e,t,d.map(({objectApiName:u})=>u)))}catch(u){if(W(u,s))throw u}let i=d.filter(({objectApiName:u})=>f.has(u)),c=await q(t,i.map(({objectApiName:u})=>({objectApiName:u,readMode:"query"})),s),l=new Map;return c.forEach((u,h)=>{"count"in u&&l.set(i[h].objectApiName,u.count)}),n.settings.map(({objectApiName:u,label:h})=>{let r=a.get(u);if(r?.customSetting!==void 0)return{objectApiName:u,label:h,kind:r.customSetting,records:r.records};let m=f.get(u),w=l.get(u);return{objectApiName:u,label:h,...m!==void 0?{kind:H(m)}:{},...w!==void 0?{records:w}:{}}})}var Qt={records:0,apiRequests:0,apiRequestsLeft:0,seconds:0,bytes:0};async function Wn(e,t){let n={mode:t.mode,objects:[],leftOut:[],estimate:Qt},o=await Z(ht(e.org),{act:"take",orgName:t.orgName,registered:t.registered,username:t.username,customSettings:wt(t)},{userId:()=>e.org.userId()});if(!o.allowed)return{...n,refusal:o.refusal};let s=e.store.heldBy(o.org.id),a=s===void 0?await e.runWriting?.(o.org.id):void 0,d=X(e.org,e.signal);try{let f=await ee(e.org,t.orgName),i=await kt(e.org,d,t,await ft(e.org,d,t),o.grants,e.signal),{scope:c}=i,l=await e.org.serverTime(),u=await mt(e.org,d,t,c,f,l,e.signal,i.reads),h={mode:t.mode,objects:Kt(u),leftOut:u.leftOut,estimate:u.estimate,files:{held:u.objects.some(({scoped:m})=>D(m.objectApiName)),queryAllFiles:o.queryAllFiles,addedToPicked:c.addedToPicked},customSettings:await Jt(e.org,d,c,u,e.signal)},r=s!==void 0?lt(t.orgName,s):a!==void 0?{code:"RUN_WRITING",message:a}:i.refusal??u.refusal;return r===void 0?h:{...h,refusal:r}}catch(f){throw W(f,e.signal)?new N:f}}function Xt(e){let t=e.requestsSent?()=>e.requestsSent?.()??0:void 0,n={guard:0,scope:0,start:0,counts:0,bin:0,snapshot:0,stability:0},o="guard",s=t?.()??0,a=()=>{if(!t)return;let d=t();n[o]+=d-s,s=d};return{enter(d){a(),o=d},requests(){return t?(a(),{total:Object.values(n).reduce((f,i)=>f+i,0),byPhase:{...n}}):void 0}}}async function Yt(e,t){if(t.edition!==void 0)return t.edition;let o=(await e.query("SELECT OrganizationType FROM Organization LIMIT 1")).records[0]?.OrganizationType;if(typeof o!="string"||o==="")throw new Error("The org did not say its edition (Organization.OrganizationType).");return o}var qt="Automated Process";async function Zt(e){let n=(await e.query("SELECT Id, Name FROM User WHERE UserType = 'AutomatedProcess'")).records.filter(s=>typeof s.Id=="string"),o=n.find(s=>s.Name===qt);return o!==void 0?o.Id:n.length===1?n[0].Id:void 0}function yt(e){let t=new Date(Date.parse(e)).toISOString();return`${t.slice(0,10)} ${t.slice(11,16)} UTC`}function rt(e,t){return e.split(me).join(yt(t))}function te(e){let t=Se(e);return t===null?Number.NaN:Date.parse(t)}function St(e){return typeof e=="string"&&e.length>=15?e.slice(0,15):void 0}async function en(e,t){let n=new Set;for await(let o of L(J(e,t))){let s=St(o.Id);s!==void 0&&n.add(s)}return n}async function tn(e,t,n,o,s,a){let d={changed:0,deleted:0,created:0};if(!o.live&&!o.deleted)return d;let f=await Qe.read(e,t,n);if(o.live)for await(let i of L(o.live.file)){let c=te(i.SystemModstamp);if(!(c<=a))continue;let l=f.stampOf(i.Id);l===void 0?d.created++:l!==c&&d.changed++}if(o.deleted){let i;for await(let c of L(o.deleted.file)){if(!(te(c.SystemModstamp)<=a))continue;if(f.has(c.Id)){d.deleted++;continue}if(!(te(c.CreatedDate)<s))continue;i??=await en(e,n);let l=St(c.Id);l!==void 0&&!i.has(l)&&d.deleted++}}return d}async function Ot(e){let t=0;for(let n of await Rt(e,{withFileTypes:!0})){let o=ne(e,n.name);n.isDirectory()?t+=await Ot(o):n.isFile()&&(t+=(await ct(o)).size)}return t}async function nn(e,t){let n=await Ot(e.dir)-(await ct(e.checkpointFile)).size,o=a=>Buffer.byteLength(`${JSON.stringify({...t,bytes:a},null,2)}
|
|
8
|
-
`,"utf8"),s=n+o(n);return s=n+o(s),s}function on(e){let t=e.snapshotsFile,n=new Re({getData:()=>Nt(t)?JSON.parse(Dt(t,"utf8")):{},setData:o=>Mt(t,JSON.stringify(o,null,2),{encoding:"utf8",mode:384})});return n.initialize(),n}var sn=z({organizationId:ue().optional()}).loose();async function rn(e,t,n,o,s){let a=on(e),d=0,f={log:n.handler.log,orgManager:n.handler.orgManager,orgRegistry:n.handler.orgRegistry,configStore:a,broker:{postToWebview:c=>{if(c.type!=="operation:progress")return;let l=c.payload;typeof l.percentage=="number"&&typeof l.currentStep=="string"&&s(l.percentage,l.currentStep)}},services:{getSandforgeSetting:(c,l)=>c==="backup.maxRecordsPerObject"?o:l},nextId:()=>`${e.checkpointId}-${++d}`},i=new Te(f);return i.setBackupRecordStore(new De(t)),await i.swept(),{handler:i,config:a}}function an(e,t){return e.slice(0,15)===t.slice(0,15)}async function Bn(e,t){let{org:n,store:o,signal:s}=e,a=e.now??(()=>new Date),d=pe.parse([...t.ignoredFields??[]]),f=t.name===void 0?void 0:E.parse(t.name),i=t.nameWithDate;i!==void 0&&E.parse(rt(i,a().toISOString()));let c=t.customSettings==="all"?[]:t.customSettings??[];for(let y of[...t.objects??[],...t.excluded??[],...c])$(y);let l=t.beforeRun===void 0?void 0:ge.parse(t.beforeRun),u=t.keepDays??Pe;I(a(),u);let h=(y,g,A=0,M=0)=>e.onProgress?.({percentage:Math.round(y),processedObjects:A,totalObjects:M,step:g});h(0,`Checking ${t.orgName}`);let r=Xt(n),m=await Z(ht(n),{act:"take",orgName:t.orgName,registered:t.registered,username:t.username,customSettings:wt(t)},{userId:()=>n.userId()});if(!m.allowed)return{taken:!1,refusal:m.refusal};let w=m.org.id,S=Ee("ck",a()),O=o.lock(w,"take",S);if("busy"in O)return{taken:!1,refusal:lt(t.orgName,O.busy)};let p,b;try{let y=await e.runWriting?.(w);if(y!==void 0)return{taken:!1,refusal:{code:"RUN_WRITING",message:y}};let g=X(n,s),A=await Yt(n,m.org),M=await ee(n,t.orgName);h(2,`Reading the objects of ${t.orgName}`),r.enter("scope");let k=await kt(n,g,t,await ft(n,g,t),m.grants,s);if(k.refusal!==void 0)return{taken:!1,refusal:k.refusal};let{scope:j}=k;r.enter("start");let P=await n.userId(),se=await Zt(n),R=await n.serverTime();h(8,`Counting the records of ${j.objects.length} objects`),r.enter("counts");let T=await mt(n,g,t,j,M,R,s,k.reads);if(T.refusal!==void 0)return{taken:!1,refusal:T.refusal};if(T.objects.length===0)throw new Error(`None of the objects asked for can be kept in a checkpoint of ${t.orgName}: ${T.leftOut.map(C=>`${C.objectApiName}: ${C.reason}`).join(" ")||"there are none."}`);if(s?.aborted)throw new N;p=await o.create(w,S);let B=`snapshot-${S}`;b={version:1,checkpointId:S,name:f??(i!==void 0?E.parse(rt(i,R)):yt(R)),org:{organizationId:w,...t.alias!==void 0?{alias:t.alias}:{},username:t.username,instanceUrl:t.instanceUrl,isSandbox:m.org.sandbox,organizationType:A,tier:m.tier,...t.scratchExpiresAt!==void 0?{scratchExpiresAt:t.scratchExpiresAt}:{}},takenBy:{userId:P,...se!==void 0?{automatedProcessUserId:se}:{},viewAllData:m.grants.kind==="org"||m.grants.viewAllData,modifyAllData:m.grants.kind==="org"||m.grants.modifyAllData,queryAllFiles:m.queryAllFiles},readFrom:R,takenAt:R,scope:{mode:t.mode,leftOut:T.leftOut},objects:[],ignoredFields:d,snapshotId:B,movedWhileTaken:{changed:0,deleted:0,created:0},bytes:0,expiresAt:I(a(),u),status:"taking",takenOn:{host:Pt(),pid:process.pid},...l!==void 0?{beforeRun:l}:{}},await o.write(b),h(12,"Reading the recycle bin as it was at the checkpoint"),r.enter("bin");let At=await Ve(g,T.objects.map(({scoped:C})=>({...Ue(C.objectApiName,R),file:J(p,C.objectApiName)})),s),ie=new Map;for(let C of At){if(!C.read)throw new Error(`The recycle bin of ${C.objectApiName} could not be read whole: ${C.reason}`);ie.set(C.objectApiName,C.rows)}r.enter("snapshot");let{records:jt,files:re}=await cn(p,B,T,t,e,w,g,h);h(88,"Reading the time on the org"),r.enter("stability");let ae=await n.serverTime();h(90,`Checking what changed in ${t.orgName} while it was read`);let{movedWhileTaken:Ct,notChecked:Tt}=await dn(p,B,T,g,R,ae,s),{prints:ce}=T;await o.writeFingerprints(p,ce);let _=T.objects.map(C=>{let U=C.scoped.objectApiName;return gt(C,jt.get(U)??0,ie.get(U)??0,ce[U].digest)});if(s?.aborted)throw new N;let de={...b,takenAt:ae,objects:_,movedWhileTaken:Ct,bytes:0,expiresAt:I(a(),u),status:"ready",...re!==void 0?{files:re}:{}},G={...de,bytes:await nn(p,de)};await o.write(G),h(100,`Checkpoint '${G.name}' taken`,_.length,_.length);let le=r.requests();return{taken:!0,checkpoint:G,notChecked:Tt,...le!==void 0?{requests:le}:{},estimate:T.estimate}}catch(y){throw p!==void 0&&await ln(o,p,b,e),W(y,s)?new N:y}finally{O.lock.release()}}async function cn(e,t,n,o,s,a,d,f){let i=n.objects.filter(r=>r.records>0),c=new Map,l=(s.snapshotFiles??It)(e.dir);if(i.length>0){let r=Math.max($t,n.objectLimit),{handler:m,config:w}=await rn(e,l,s,r,(b,y)=>f(15+b*.65,y)),S=await m.backupForPipeline({operationId:t,orgId:o.orgId,objects:i.map(({scoped:b})=>b.objectApiName),fields:new Map(i.map(({scoped:b,capture:y})=>[b.objectApiName,y.fields])),scanAll:i.filter(({capture:b})=>b.readMode==="scanAllLive").map(({scoped:b})=>b.objectApiName),origin:"checkpoint",failWhenTruncated:!0,onConnection:b=>s.org.countAlso?.(b)},s.signal),O=sn.safeParse(w.get(`backup:${t}`)),p=O.success?O.data.organizationId:void 0;if(p===void 0||!an(p,a))throw new Error(`The snapshot was read from ${p===void 0?"an org that did not say which it is":`another org (${p})`}, not from ${o.orgName}: it is not kept.`);for(let b of S.objects)c.set(b.objectApiName,b.recordCount)}f(82,"Indexing the snapshot",0,n.objects.length);for(let[r,{scoped:m}]of n.objects.entries()){let w=m.objectApiName,S=c.get(w)??0;c.has(w)||(await ve(ne(e.dir,"backups")),await l.writeFile(Ke(e,t,w),""),c.set(w,0));let O=await Je(e,t,w);if(O.rows!==S)throw new $e("damaged",`The snapshot of ${w} holds ${O.rows} records where its read kept ${S}: it is not kept.`);f(82+6*(r+1)/n.objects.length,`Indexed ${w}`,r+1,n.objects.length)}let u=n.objects.find(({scoped:r})=>D(r.objectApiName));if(u===void 0||n.linkable===void 0)return{records:c};f(88,"Reading the links of files to the records read");let h=await Ye({reader:d,folder:e,snapshotId:t,linked:n.objects.map(({scoped:r})=>r.objectApiName).filter(r=>(c.get(r)??0)>0&&pt(r,n.linkable)),documentsInSnapshot:(c.get(u.scoped.objectApiName)??0)>0,...s.signal!==void 0?{signal:s.signal}:{}});return{records:c,files:h}}async function dn(e,t,n,o,s,a,d){let f=ne(e.dir,Ft),i={changed:0,deleted:0,created:0},c=[];try{let l=await He(o,n.objects.map(({capture:r})=>({objectApiName:r.objectApiName,readMode:r.readMode,held:!1})),s,f,d),u=Date.parse(Y(s)),h=Date.parse(a);for(let r of l){if("unread"in r){c.push({objectApiName:r.objectApiName,reason:r.unread});continue}if(!r.moved)continue;let m=await tn(e,t,r.objectApiName,r,u,h);i.changed+=m.changed,i.deleted+=m.deleted,i.created+=m.created}}finally{await at(f,{recursive:!0,force:!0})}return{movedWhileTaken:i,notChecked:c}}async function ln(e,t,n,o){try{n!==void 0&&await e.write({...n,status:"failed"})}catch(s){o.handler.log(`[WARN] checkpoint ${t.checkpointId}: not marked failed: ${v(s)}`)}try{await at(t.dir,{recursive:!0,force:!0})}catch(s){o.handler.log(`[WARN] checkpoint ${t.checkpointId}: what its take wrote was not removed: ${v(s)}`)}}export{vt as a,xn as b,N as c,Wn as d,Bn as e};
|
package/lib/chunk-I3JKJTLO.mjs
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
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 $e}from"./chunk-TW3N6W5Z.mjs";import{a as ne,b as ae}from"./chunk-5P4PHJRL.mjs";import{a as ge,b as we,c as ye,d as be}from"./chunk-RSWDYIHY.mjs";import{K as ce,c as ie}from"./chunk-D3QRXG63.mjs";import{a as U}from"./chunk-SCKUIE3R.mjs";import{a as D}from"./chunk-QROPNEGY.mjs";import{b as _,e as z}from"./chunk-BZ24IAP5.mjs";import{c as W}from"./chunk-AV5SWEHP.mjs";import{a as le,c as pe,d as me,e as fe,f as he}from"./chunk-I7O6C2B5.mjs";import{a as ke}from"./chunk-4GL773D5.mjs";import{f as re,j as se}from"./chunk-SRQDABQ2.mjs";import{za as ee}from"./chunk-YMJVMFPY.mjs";import{x as de}from"./chunk-36U7IQ6Y.mjs";import{l as oe}from"./chunk-Z7X534S4.mjs";import{h as te}from"./chunk-NTDN2JQZ.mjs";import{b as Q}from"./chunk-L776PUMV.mjs";import{p as Y}from"./chunk-CGWXQX75.mjs";import{e as V,g as K}from"./chunk-TZE3Y7IQ.mjs";import{a as J,b as q,d as X,e as Z,g as ue}from"./chunk-MTMH6H2A.mjs";import{Vb as H}from"./chunk-B45CNPUX.mjs";import{readFileSync as xe}from"node:fs";import{basename as Oe,join as Ie}from"node:path";var Le=`sandforge dataops \u2014 mask an org's records, and put them back, without the editor.
|
|
8
|
-
|
|
9
|
-
Usage:
|
|
10
|
-
npx sandforge dataops anonymize \\
|
|
11
|
-
--org <alias> [--object <ApiName>] (--template <id> | --rules <file>) [options]
|
|
12
|
-
npx sandforge dataops anonymize \\
|
|
13
|
-
--org <alias> --restore <snapshot> [--rewrite-all] [--include-changed] [--store <dir>] [--yes]
|
|
14
|
-
Either takes [--accept-automation] [--accept-emails] [--mute-automation].
|
|
15
|
-
|
|
16
|
-
Required:
|
|
17
|
-
anonymize the command
|
|
18
|
-
--org <alias> sf CLI alias of the org
|
|
19
|
-
--template <id> a template that ships (tpl-gdpr-standard, tpl-ccpa-california,
|
|
20
|
-
tpl-hipaa-health, tpl-sandbox-scrub) or one saved in the store
|
|
21
|
-
--rules <file> or a JSON file of rules, saved in the store as a template:
|
|
22
|
-
{"name": "...", "rules": [{"fieldPattern": "Contact.Email",
|
|
23
|
-
"ruleType": "hash"}]} \u2014 a rule as the panel's editor saves it
|
|
24
|
-
|
|
25
|
-
Options:
|
|
26
|
-
--object <ApiName> the object to mask, one per run; without it, every object
|
|
27
|
-
the template masks, as the panel's Apply masks them \u2014
|
|
28
|
-
Account's person accounts among them, in an org that has
|
|
29
|
-
person accounts, when the template masks contacts
|
|
30
|
-
--where <clause> with --object: mask only the records this SOQL condition
|
|
31
|
-
selects, written without WHERE
|
|
32
|
-
--dry-run say what a run would mask \u2014 the fields, the records, the
|
|
33
|
-
first records masked as a run masks them \u2014 and write
|
|
34
|
-
nothing
|
|
35
|
-
--resume mask only what the last run of the same template, object
|
|
36
|
-
and filter left, from where it stopped
|
|
37
|
-
--restore <snapshot> put back the values a snapshot holds, by Id: the id a run
|
|
38
|
-
printed. It reads the org's values first and writes only
|
|
39
|
-
the rows where one of them differs from the snapshot, and
|
|
40
|
-
says how many it found unchanged
|
|
41
|
-
--rewrite-all with --restore: write every row of the snapshot back,
|
|
42
|
-
the ones the org already holds as the snapshot does
|
|
43
|
-
included
|
|
44
|
-
--include-changed with --restore of the snapshot a Sync run kept of what
|
|
45
|
-
it wrote over: put back the records changed or deleted
|
|
46
|
-
since the run too, which a restore of it otherwise
|
|
47
|
-
leaves as they are and counts, as removing the run does
|
|
48
|
-
--max-age-days <n> the retention, as sandforge.backup.maxAgeDays sets it:
|
|
49
|
-
snapshots taken more than <n> days ago are removed as
|
|
50
|
-
the command starts, each named on stderr \u2014 the one a
|
|
51
|
-
Sync run kept of what it wrote over too, which removing
|
|
52
|
-
that run then no longer puts back; 0 keeps them all
|
|
53
|
-
(default: 30)
|
|
54
|
-
--store <dir> where snapshots, saved templates and checkpoints live, a
|
|
55
|
-
folder of your own; the one sandforge backup reads and
|
|
56
|
-
lists (default: ~/.sandforge/backups, under the folder
|
|
57
|
-
SANDFORGE_JOURNAL_DIR names when it is set)
|
|
58
|
-
--max-records <n> most records of the object a snapshot holds, as
|
|
59
|
-
sandforge.backup.maxRecordsPerObject sets it; a run with
|
|
60
|
-
more writes nothing (default: 50000; 100 to 1000000)
|
|
61
|
-
${ye("written over","--dry-run")} --yes do not ask before writing. Without it, a command with no
|
|
62
|
-
terminal to answer the question \u2014 a CI step \u2014 stops
|
|
63
|
-
there, exit 2, and writes nothing
|
|
64
|
-
--json emit what the panel would receive, every other line on
|
|
65
|
-
stderr; a preview's original values are left out
|
|
66
|
-
--help this text
|
|
67
|
-
|
|
68
|
-
A run takes a snapshot of the records it masks, their masked fields as they are,
|
|
69
|
-
before its first write, and writes nothing unless the snapshot holds every one of
|
|
70
|
-
them. A production org is refused.
|
|
71
|
-
|
|
72
|
-
Before it writes, a run and a --restore say what the org runs as the records are
|
|
73
|
-
written over \u2014 its record-triggered flows, Apex triggers, processes and workflow
|
|
74
|
-
rules on update, and on undelete for what a restore brings back from the recycle
|
|
75
|
-
bin \u2014, the emails that sends against what the org has left today, and whether
|
|
76
|
-
the org delivers them; a dry run says it too, and what a real run would be
|
|
77
|
-
refused for (with --json, the dataops:automation:response it carries).
|
|
78
|
-
|
|
79
|
-
Ctrl-C stops a run as the panel's Cancel does: before its next page, what it
|
|
80
|
-
masked recorded in the audit trail of the store, and --resume masks only what it
|
|
81
|
-
left. It stops a --restore before its next batch, what it put back recorded the
|
|
82
|
-
same way, and the same --restore puts back the rest. Ctrl-C again ends the
|
|
83
|
-
process at once. A SIGTERM \u2014 a CI job cancelled or timed out \u2014 or a SIGHUP
|
|
84
|
-
stops it the same way.
|
|
85
|
-
|
|
86
|
-
Exit codes: 0 the run masked every record it counted, or the restore put back
|
|
87
|
-
every value; 1 it could not start, was refused or failed \u2014 what the org runs as
|
|
88
|
-
it writes, without --accept-automation (AUTOMATION_NOT_ACCEPTED), emails it
|
|
89
|
-
delivers, without --accept-emails (EMAILS_NOT_ACCEPTED), more emails than it
|
|
90
|
-
has left today (EMAILS_EXCEEDED), or a mute refused among the reasons \u2014, or a
|
|
91
|
-
--dry-run saw that a run would be refused; 2 a bad command line,
|
|
92
|
-
or a question with no terminal to answer it (give --yes); 3 the run left
|
|
93
|
-
records unmasked, their personal data still in the org (--resume masks what
|
|
94
|
-
it left), or the restore left values as they are (rows the org refused, a
|
|
95
|
-
snapshot that holds part of the records, or records of a Sync run's snapshot
|
|
96
|
-
changed since the run, held back without --include-changed); 130 Ctrl-C
|
|
97
|
-
stopped the run, 143 a SIGTERM, 129 a SIGHUP.
|
|
98
|
-
`,De=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,Te={words:1,switches:["--dry-run","--resume","--rewrite-all","--include-changed","--yes","--json",...ge],values:["--org","--object","--template","--rules","--where","--restore","--store","--max-records","--max-age-days"]};function h(o){process.stderr.write(`${o}
|
|
99
|
-
`),process.exit(2)}function Pe(o){let e;try{e=JSON.parse(xe(o,"utf8"))}catch(a){h(`Cannot read the rules in ${o}: ${a instanceof Error?a.message:String(a)}`)}let r=Array.isArray(e)?{rules:e}:e,s=typeof r=="object"&&r!==null&&!("name"in r)?{...r,name:`Rules from ${Oe(o)}`}:r,i=ee.safeParse(s);if(!i.success){let a=i.error.issues.map(g=>`${g.path.join(".")||"(file)"}: ${g.message}`).join("; ");h(`The rules in ${o} are not rules the panel saves: ${a}`)}return i.data}function Ee(o){let e=o.slice(2);(e.includes("--help")||e.includes("-h"))&&(process.stdout.write(Le),process.exit(0)),e[0]!=="anonymize"&&h(`The command is anonymize: ${U("dataops")} anonymize --org \u2026 Run with --help.`),J(e,Te);let r=p=>{let m=e.indexOf(p),O=m>=0?e[m+1]:void 0;return m>=0&&(O===void 0||O.startsWith("--"))&&h(`${p} needs a value.`),O},s=p=>e.filter(m=>m===p).length,i=r("--org");i||h("Missing --org. Run with --help."),q.test(i)||h(`Not an sf alias: "${i}"`);let a=r("--restore"),g=e.includes("--dry-run"),S=e.includes("--resume"),k=r("--max-records");k!==void 0&&!/^[1-9]\d*$/.test(k)&&h(`Not a number of records: "${k}"`);let c=e.includes("--rewrite-all");c&&a===void 0&&h("--rewrite-all goes with --restore.");let A=e.includes("--include-changed");A&&a===void 0&&h("--include-changed goes with --restore.");let f=me(r("--max-age-days")),$={org:i,rewriteAll:c,includeChanged:A,...f!==void 0?{maxAgeDays:f}:{},storeDir:r("--store")??le(),...k!==void 0?{maxRecords:Number(k)}:{},yes:e.includes("--yes"),json:e.includes("--json"),accord:we(e)};if(a!==void 0){let p=["--object","--template","--rules","--where","--dry-run","--resume"].filter(m=>e.includes(m));return p.length>0&&h(`--restore puts a snapshot back as it is: drop ${p.join(", ")}.`),{...$,mode:"restore",restoreId:a}}s("--object")>1&&h("Give one --object at most: a run masks one object, or every object its template masks.");let l=r("--object");l!==void 0&&!De.test(l)&&h(`Not an SObject API name: "${l}"`);let w=r("--template"),b=r("--rules");w===void 0==(b===void 0)&&h("Give one of --template or --rules: the rules a run masks with."),g&&S&&h("Give one of --dry-run or --resume.");let d=r("--where")?.trim();return d!==void 0&&(d===""||!V(d))&&h(`Not a filter --where can take: "${d}". ${K}`),d!==void 0&&l===void 0&&h("--where filters the records of one object: give it with --object."),{...$,mode:g?"dry-run":S?"resume":"run",...l!==void 0?{object:l}:{},...w!==void 0?{templateId:w}:{},...b!==void 0?{rules:Pe(b)}:{},...d!==void 0?{where:d}:{}}}function ve(o,e){let r=`${e.toLowerCase()}.`;return o.rules.filter(s=>s.fieldPattern.toLowerCase().startsWith(r)||s.fieldPattern==="*")}function Fe(o,e){return ve(o,e).length>0?!0:e.toLowerCase()===Y.toLowerCase()&&re(o.rules).length>0}function Me(o,e){let r=s=>JSON.stringify(s.map(i=>[i.fieldPattern.toLowerCase(),i.ruleType,i.config??null]).sort((i,a)=>String(i[0]).localeCompare(String(a[0]))));return r(o)===r(e)}function _e(o){if(o==null||o==="")return"(empty)";let e=typeof o=="string"?o:JSON.stringify(o);return JSON.stringify(e.length>40?`${e.slice(0,39)}\u2026`:e)}function ze(o,e){let r=[];typeof o.message=="string"&&r.push(o.message);for(let a of o.objects??[])r.push(` ${a.objectApiName.padEnd(28)} counted ${a.total} masked ${a.processed} refused ${a.failed} still original ${a.notMasked}`);let s=o.errors??[];s[0]&&r.push(` e.g. ${s[0].objectApiName}: ${s[0].message}`);let i=o.snapshot;return i&&r.push(`snapshot ${i.operationId}: ${i.totalRecords} record(s) as they were before the run. To put their values back:`,` ${e(i.operationId)}`),r}function We(o,e){return`${o}.${e}: the org has no such field, or field-level security hides it from this user \u2014 a run is refused and masks nothing (give the user read and edit access to it, or take it out of the template)`}function je(o,e){return e===void 0?`${o}: this user may not edit its records \u2014 a run is refused (CRUD_FLS_DENIED) and masks nothing (give the user edit access to the object)`:`${o}.${e}: this user may read it and not edit it \u2014 a run is refused (CRUD_FLS_DENIED) and masks nothing (give the user edit access to it, or take it out of the template)`}function Ue(o,e={}){let r=o.fieldsNotFound??[],s=o.objects??[],i=e.objects??[];return r.length>0||s.some(a=>a.notCovered===!0||a.error!==void 0||a.writeDenied!==void 0)||i.some(a=>a.count===null)}function Ge(o,e,r){let s=["dry run \u2014 nothing is written"],i=e.objects??[],a=r.objects??[],g=r.fieldsNotFound??[];for(let c of i){let A=c.count===null?"an unknown number of":String(c.count);s.push(` ${c.objectApiName}: ${A} record(s) to mask`),c.count===null&&s.push(" not counted by the org: a run stops at its count and masks nothing");let f=a.find(d=>d.objectApiName===c.objectApiName);if(f?.error){s.push(` not read: ${f.error}`);continue}let $=new Map([...ve(o,c.objectApiName).map(d=>[d.fieldPattern.split(".").pop()?.toLowerCase()??"",d.ruleType]),...Object.entries(f?.methods??{}).map(([d,p])=>[d.toLowerCase(),p])]),l=f?.fields??[];s.push(` fields: ${l.map(d=>`${d} (${$.get(d.toLowerCase())??"?"})`).join(", ")||"(none)"}`);for(let d of g.filter(p=>p.objectApiName===c.objectApiName))s.push(` ${We(d.objectApiName,d.fieldApiName)}`);f?.notCovered&&s.push(" no field of it can be masked: a run is refused and masks nothing");let w=f?.writeDenied?.deniedFields;w?.length===0&&s.push(` ${je(c.objectApiName)}`);for(let d of w??[])s.push(` ${je(c.objectApiName,d)}`);let b=f?.rows??[];if(b.length>0){s.push(" the first records, masked as a run masks them (a run draws its own key, so its made-up names and digests differ from these):");for(let d of b)s.push(` ${d.id}: ${l.map(p=>`${p} ${_e(d.after[p])}`).join(", ")}`)}}let S=i.reduce((c,A)=>c+(A.count??0),0);S>0&&s.push(` a run takes a snapshot of these ${S} record(s) first, and writes nothing without it`);let k=e.checkpoint;return k&&s.push(` a run of this template, object and filter stopped short on ${k.savedAt}: --resume masks only what it left`),s}function Be(o){return`interrupted: the restore stopped before it was through; what it restored is in the audit trail, and the same line puts back the rest: ${o}`}function He(){return"interrupted: the masking stopped before it was through; what it masked is in the audit trail, the snapshot puts their values back (--restore), and the same line with --resume masks only what it left"}function Je(o){return o.map(e=>{if(e.type!=="dataops:anonymize:preview:response")return e;let r=e.payload?.objects??[];return{...e,payload:{...e.payload,objects:r.map(s=>({...s,rows:(s.rows??[]).map(({id:i,after:a})=>({id:i,after:a}))}))}}})}async function qe(o=process.argv){let e=Ee(o),r=t=>{process[e.json?"stderr":"stdout"].write(`${t}
|
|
100
|
-
`)},s=t=>{process.stderr.write(`${t}
|
|
101
|
-
`),process.exitCode=1},i=pe(e.storeDir);if(i!==void 0){s(i);return}let a=await Q(e.org),g=await new ke().validateConnection(a.accessToken,a.instanceUrl),S={alias:e.org,orgType:H({isSandbox:g.isSandbox,edition:g.orgType}),metadata:{apiVersion:"66.0",edition:g.orgType}};r(`sandforge dataops ${e.org} (${g.isSandbox?"sandbox":g.orgType||"production"}) store: ${e.storeDir}`);let k=de(Ie(e.storeDir,"snapshots.json")),c=[],A=new Map,f=new $e,$=new se({log:t=>{/^\[(WARN|INFO)\]/.test(t)&&r(` ${t}`)},broker:{postToWebview:t=>{if(c.push(t),t.type!=="operation:progress")return;let n=String(t.payload?.operationId??""),u=Number(t.payload?.percentage??0);(u-(A.get(n)??-10)>=10||u===100)&&(A.set(n,u),r(` ${u}% ${String(t.payload?.currentStep??"")}`))}},orgManager:{getOrg:()=>S},orgRegistry:{getCredentials:async()=>({accessToken:a.accessToken,instanceUrl:a.instanceUrl})},configStore:k,services:{getSandforgeSetting:fe(e)},infraServices:{backgroundRegistry:f,productionGuard:new oe({requestConfirmation:(t,n)=>(r(`refused: ${e.org} is taken for a ${n} org, and this command writes to none (${t})`),Promise.resolve(!1))}),confirmRestoreIntoReplacedOrg:({alias:t,backedUpFrom:n,now:u})=>e.yes?Promise.resolve(!1):D(`${t} answered as org ${n} when this snapshot was taken and answers as org ${u} now. Write its saved values into the org it is now?`)},nextId:()=>`cli-${Date.now()}-${Math.random().toString(36).slice(2,8)}`});$.setExpiryListener(t=>process.stderr.write(`${he(t)}
|
|
102
|
-
`)),$.setBackupRecordStore(new ae(ne(e.storeDir))),await $.swept(),$.setSyncRuns(te(ce())),$.setMuteOffered(ie("--mute-automation"));let l=async(t,n)=>{let u=`cli-${t.replaceAll(":","-")}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return await $.handle({id:u,type:t,timestamp:Date.now(),payload:n}),c.find(v=>v.correlationId===u&&(v.type===`${t}:response`||v.type==="dataops:error"))??{type:"dataops:error",payload:{message:`${t} was not answered.`}}},w=t=>t.type==="dataops:error",b=t=>String(t.payload?.message??t.type),d=t=>`${U("dataops")} anonymize --org ${e.org} --restore ${t} --store ${e.storeDir}`,p=async(t,n)=>{let u=await l("dataops:automation",{orgId:e.org,act:t,objects:n,...e.accord});if(w(u)){s(b(u));return}let C=u.payload;for(let v of C.lines)r(v);return C},m=t=>{e.json&&process.stdout.write(`${JSON.stringify({tool:"sandforge-dataops",command:t,org:e.org,posted:Je(c)},null,2)}
|
|
103
|
-
`)};if(e.mode==="restore"){let t=e.restoreId,n=k.get(`backup:${t}`);if(!n){s(`No snapshot "${t}" in ${e.storeDir}.`);return}let u=(n.objects??[]).map(R=>R.objectApiName).join(", "),C=await p("restore",(n.objects??[]).map(R=>({objectApiName:R.objectApiName,records:R.recordCount??0})));if(!C){m("restore");return}if(C.refusals.length>0){m("restore");for(let R of C.refusals)s(W(R));return}if(!e.yes&&!await D(`Put back into ${e.org} the values snapshot ${t} holds? ${n.totalRecords??"?"} record(s) of ${u} will have those fields written over.`)){r("Nothing written.");return}r(`restoring ${t} into ${e.org}${e.rewriteAll?", every row written back":""}\u2026`);let v,Se=z(R=>{v=R,process.stderr.write(`
|
|
104
|
-
interrupted: the restore stops before its next batch, and says what it restored (Ctrl-C again ends it at once)
|
|
105
|
-
`);for(let Ce of f.getRunning())f.abort(Ce.operationId)}),x;try{x=await l("dataops:rollback",{orgId:e.org,operationId:t,...e.rewriteAll?{rewriteAll:!0}:{},...e.includeChanged?{includeChanged:!0}:{},...e.accord})}finally{Se()}if(m("restore"),w(x)){s(b(x));return}if(r(String(x.payload?.message??"")),v){process.stderr.write(`${Be(d(t))}
|
|
106
|
-
`),process.exitCode=_(v);return}Z(X(x.payload??{}));return}let T=(await l("dataops:anonymization-templates",{})).payload?.templates??[],y;if(e.rules){let t=e.rules,n=T.find(u=>u.saved===!0&&u.name.trim().toLowerCase()===t.name.toLowerCase());if(n&&Me(n.rules,t.rules))y=n;else{n&&await l("dataops:anonymization-template:delete",{templateId:n.id});let u=await l("dataops:anonymization-template:save",{name:t.name,rules:t.rules});if(w(u)){s(b(u));return}y=u.payload?.template,r(`rules saved in the store as template "${y.name}" (${y.id})`)}}else if(y=T.find(t=>t.id===e.templateId),!y){s(`No template "${e.templateId??""}". Templates: `+T.map(t=>`${t.id}${t.saved?` (saved: ${t.name})`:""}`).join(", "));return}let j=e.object;if(j!==void 0&&!Fe(y,j)){s(`Template "${y.name}" has no rule for ${j}: a run would mask nothing.`);return}let P={orgId:e.org,templateId:y.id,...j!==void 0?{objects:[j]}:{},...e.where!==void 0?{where:e.where}:{}};r(`template: ${y.name} (${y.id}) `+(j!==void 0?`object: ${j}`:"objects: every object the template masks")+(e.where!==void 0?` where: ${e.where}`:""));let N=await l("dataops:anonymize:coverage",P);if(w(N)){s(b(N));return}let I=N.payload?.objects??[],G=I.reduce((t,n)=>t+(n.count??0),0),B=I.map(t=>({objectApiName:t.objectApiName,records:t.count??0}));if(e.mode==="dry-run"){let t=await l("dataops:anonymize:preview",P);if(w(t)){m("dry-run"),s(b(t));return}for(let u of Ge(y,N.payload??{},t.payload??{}))r(u);let n=await p("masking",B);if(m("dry-run"),!n)return;for(let u of be(n))r(u);(n.refusals.length>0||Ue(t.payload??{},N.payload??{}))&&(process.exitCode=1);return}let E=N.payload?.checkpoint;if(e.mode==="resume"&&!E){s(`There is nothing to resume: no run of this template, object and filter stopped short in ${e.storeDir}.`);return}if(e.mode==="run"&&G===0){let t=I.filter(n=>n.count===null).map(n=>n.objectApiName);if(t.length>0){s(`${t.join(", ")}: the org did not count the records a run would mask, so nothing was masked (its reason is in the warning above).`);return}r(j!==void 0?"Nothing to mask: no record of the object is under the filter.":"Nothing to mask: no object the template masks holds a record."),m("run");return}let F=await p("masking",B);if(!F){m(e.mode);return}if(F.refusals.length>0){m(e.mode);for(let t of F.refusals)s(W(t));return}if(!e.yes){let t=j??I.map(u=>u.objectApiName).join(", "),n=e.mode==="resume"?`Resume the masking of ${t} in ${e.org} that stopped on ${E.savedAt}? What it left is written over; the snapshot the first run took holds their values.`:`Mask ${G} record(s) of ${t} in ${e.org} with ${y.name}? A snapshot of their values is taken first.`;if(!await D(n)){r("Nothing written.");return}}r(e.mode==="resume"?"resuming\u2026":"masking\u2026");let M,Re=z(t=>{M=t,process.stderr.write(`
|
|
107
|
-
interrupted: the masking stops before its next page, and says what it masked (Ctrl-C again ends it at once)
|
|
108
|
-
`);for(let n of f.getRunning())f.abort(n.operationId)}),L;try{L=await l("dataops:anonymize",{...P,...e.mode==="resume"?{resumeFrom:E.id}:{snapshot:!0},...e.accord})}finally{Re()}m(e.mode);for(let t of ze(L.payload??{},d))r(t);if(M){process.stderr.write(`${He()}
|
|
109
|
-
`),process.exitCode=_(M);return}if(w(L)){process.exitCode=1;return}Number(L.payload?.recordsNotMasked??0)>0&&(r("A resume masks only what this run left: the same line with --resume, in place of the snapshot it does not take again."),process.exitCode=3)}/sandforge-dataops\.[cm]?[jt]s$/.test(process.argv[1]??"")&&(ue(),qe().then(()=>process.exit()).catch(o=>{process.stderr.write(`${o instanceof Error?o.message:String(o)}
|
|
110
|
-
`),process.exit(1)}));export{Ee as a,Fe as b,ze as c,We as d,je as e,Ue as f,Ge as g,Be as h,He as i,qe as j};
|
package/lib/chunk-I7O6C2B5.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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{mkdirSync as s,statSync as i}from"node:fs";import{homedir as d}from"node:os";import{join as o,resolve as u}from"node:path";var a=448;function h(e=process.env){return c("backups",e)}function c(e,n=process.env){let r=n.SANDFORGE_JOURNAL_DIR,t=r!==void 0&&r.trim()!==""?u(r):o(d(),".sandforge");return o(t,e)}var f={mkdir:(e,n)=>{s(e,n)},stat:e=>i(e),...typeof process.getuid=="function"?{uid:()=>process.getuid?.()??-1}:{}};function y(e,n=f){try{n.mkdir(e,{recursive:!0,mode:a});let r=n.stat(e);if(!r.isDirectory())return`The store ${e} is not a folder.`;let t=n.uid?.();return t!==void 0&&r.uid!==t?`The store ${e} belongs to another user, who can read its snapshots and change them: name a folder of your own with --store.`:void 0}catch(r){return`The store ${e} could not be made: ${r instanceof Error?r.message:String(r)}`}}function k(e){if(e!==void 0)return/^\d{1,5}$/.test(e)||(process.stderr.write(`Not a number of days: "${e}"
|
|
8
|
-
`),process.exit(2)),Number(e)}function b(e){return(n,r)=>n==="backup.maxRecordsPerObject"&&e.maxRecords!==void 0?e.maxRecords:n==="backup.maxAgeDays"&&e.maxAgeDays!==void 0?e.maxAgeDays:r}function l(e){let n=`removed snapshot ${e.operationId}${e.takenAt!==void 0?`, taken ${e.takenAt}`:""}: past the retention of ${e.days} day(s) (--max-age-days, 0 keeps them all)`;return e.syncRunId!==void 0?`${n}. It held what the Sync run ${e.syncRunId||"(unknown)"} wrote over: removing that run with sandforge sync --remove no longer puts those values back`:n}export{h as a,c as b,y as c,k as d,b as e,l as f};
|
package/lib/chunk-KLX67VPL.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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 D}from"./chunk-5CD257T7.mjs";import{a as S,b as R}from"./chunk-RH3N2H7P.mjs";import{b as C}from"./chunk-CA5NAXSU.mjs";import{Zb as k}from"./chunk-B45CNPUX.mjs";var A=[{field:"PermissionsViewAllData",label:"View All Data"},{field:"PermissionsModifyAllData",label:"Modify All Data"}],O="PermissionsQueryAllFiles",E="PermissionsCustomizeApplication",d="No record was read or written.";function c(e,t){return{allowed:!1,refusal:{code:e,message:t}}}function g(e,t){return c("PRODUCTION",`${e} is a production org, or cannot be told from one: ${t}. Checkpoints are for sandboxes, scratch orgs and Developer Edition orgs: SandForge never takes a checkpoint of, or rewinds, a production org. ${d}`)}function T(e){return e.edition?`its Organization record says IsSandbox false, edition ${e.edition}`:"its Organization record says IsSandbox false, and no edition"}function $(e,t){return e.slice(0,15)===t.slice(0,15)}function v(e,t){return e.orgType==="Scratch"?"scratch":t.sandbox?"sandbox":"developer"}var G={take:"A checkpoint needs a user with View All Data and Modify All Data: a rewind to it must",preview:"A preview needs a user with View All Data and Modify All Data: a record the user cannot see would read as deleted since, and the rewind it shows must",rewind:"Rewind needs a user with View All Data and Modify All Data: it must",undo:"Undo needs a user with View All Data and Modify All Data: it must",import:"An import needs a user with View All Data and Modify All Data: SandForge never keeps on this machine records its user could not see in the org, and a rewind to it must"},j={take:"Leave the custom settings out of the checkpoint, or give the user Customize Application.",preview:"This checkpoint holds custom settings: give the user Customize Application.",rewind:"This checkpoint holds custom settings: give the user Customize Application.",undo:"This checkpoint holds custom settings: give the user Customize Application.",import:"This checkpoint holds custom settings: give the user Customize Application."};function N(e){return c("PERMISSIONS",`${e.username} needs Customize Application to keep and rewind custom settings, and doesn't have it: View All Custom Settings lets a user read them, never write them. ${j[e.act]} ${d}`)}async function V(e,t){let r=[...A.map(n=>n.field),...t?[E]:[]],i=async n=>(await e.query(`SELECT ${n.join(", ")} FROM UserPermissionAccess`)).records[0],o;try{o=await i([...r,O])}catch{try{o=await i(r)}catch(n){return{unread:n instanceof Error?n.message:String(n)}}}return{missing:A.filter(n=>o?.[n.field]!==!0).map(n=>n.label),viewAllData:o?.PermissionsViewAllData===!0,modifyAllData:o?.PermissionsModifyAllData===!0,queryAllFiles:o?.[O]===!0,customizeApplication:o?.[E]===!0}}var z=/^005[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/,x=/^0PG[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/,P="SobjectType, PermissionsViewAllRecords, PermissionsModifyAllRecords";async function f(e,t){let r=await e.query(t),i=1,o=[...r.records];for(;!r.done;){let n=r.nextRecordsUrl;if(n===void 0||e.queryMore===void 0)throw new Error(`the org answered ${o.length} rows of ${r.totalSize}, and no next page`);r=await e.queryMore(n),i++,o.push(...r.records)}return{rows:o,requests:i}}async function F(e,t){let r=0;try{let i=await t();if(r++,!z.test(i))throw new Error(`the org named the user ${JSON.stringify(i)}`);let o=await f(e,`SELECT ${P} FROM ObjectPermissions WHERE ParentId IN (SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId = '${i}' AND PermissionSetGroupId = null)`);r+=o.requests;let n=await f(e,`SELECT PermissionSetGroupId FROM PermissionSetAssignment WHERE AssigneeId = '${i}' AND PermissionSetGroupId != null`);r+=n.requests;let l=[...new Set(n.rows.map(a=>a.PermissionSetGroupId).filter(a=>typeof a=="string"&&x.test(a)))],s=[...o.rows];if(l.length>0){let a=await f(e,`SELECT ${P} FROM ObjectPermissions WHERE Parent.PermissionSetGroupId IN (${l.map(u=>`'${u}'`).join(", ")})`);r+=a.requests,s.push(...a.rows)}return{grants:b(s),requests:r}}catch(i){return{unread:C(i)}}}var I={take:"A checkpoint needs a user with View All Data and Modify All Data, or with View All and Modify All on each object it holds: a rewind to it must see and put back what everyone changed there.",preview:"A preview needs a user with View All Data and Modify All Data, or with View All and Modify All on each object it reads: a record the user cannot see would read as deleted since.",rewind:"Rewind needs a user with View All Data and Modify All Data, or with View All and Modify All on each object it puts back: it must see and put back what everyone changed there.",undo:"Undo needs a user with View All Data and Modify All Data, or with View All and Modify All on each object it takes back: it must see and put back what everyone changed there."};async function H(e,t,r={}){let{orgName:i,registered:o}=t;if(o===void 0)return g(i,"SandForge has no record of what kind of org it is");if(!k(o))return g(i,"SandForge has it registered as a production org");let n;try{n=await S(e)}catch(m){let M=m instanceof Error?m.message:String(m);return g(i,`it did not say what org it is (${M})`)}if(R(n))return g(i,T(n));if(t.act!=="take"&&!$(n.id,t.organizationId))return c("OTHER_ORG",t.act==="import"?`${i} is another org than the one this file holds a checkpoint of: it is imported for the org it was taken of alone, under any alias of it. Nothing was imported.`:`${i} is another org than the one this checkpoint was taken of: its Organization Id has changed, as a sandbox's does when it is refreshed. This checkpoint is of the org before it, and can only be deleted. ${d}`);let l=t.customSettings===!0,s=await V(e,l),a=`${G[t.act]} see and put back what everyone changed.`;if("unread"in s)return c("PERMISSIONS",`${a} SandForge could not read whether ${t.username} has them (${s.unread}), and takes an org that will not say for a user who has neither. `+d);let u=s.missing.length===A.length?"them":s.missing.join(" and "),p=t.act,w=p==="import"?void 0:r.userId;if(s.missing.length>0&&w===void 0)return c("PERMISSIONS",`${a} ${t.username} doesn't have ${u}. ${d}`);if(l&&!s.customizeApplication)return N(t);let y={allowed:!0,org:n,tier:v(o,n),queryAllFiles:s.queryAllFiles};if(s.missing.length===0||w===void 0||p==="import")return{...y,grants:{kind:"org"}};let h=await F(e,w);return"unread"in h?c("PERMISSIONS",`${I[p]} ${t.username} doesn't have ${u}, and SandForge could not read which objects they have View All and Modify All on (${h.unread}). View Setup and Configuration lets a user read their own permissions; with View All Data and Modify All Data, nothing needs reading. `+d):D(h.grants)?{...y,grants:{kind:"perObject",viewAllData:s.viewAllData,modifyAllData:s.modifyAllData,objects:h.grants,requests:h.requests}}:c("PERMISSIONS",`${I[p]} ${t.username} doesn't have ${u}, nor View All and Modify All on any object. Give the user View All and Modify All on the objects to hold, or View All Data and Modify All Data. ${d}`)}export{F as a,H as b};
|
package/lib/chunk-L776PUMV.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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{m,n as w}from"./chunk-6MUEPV7M.mjs";import{b as h}from"./chunk-MTMH6H2A.mjs";import{ac as g,o as l,p}from"./chunk-B45CNPUX.mjs";import{A as f}from"./chunk-7EANH5PY.mjs";import{a as b,b as C}from"./chunk-SBIMVCXT.mjs";import{d as u}from"./chunk-NTOVCTRS.mjs";var c=class extends Error{constructor(r,t){super(`${t} Nothing was read from ${r}.`);this.alias=r;this.reason=t;this.name="SfSessionError",this.stack=this.message}alias;reason},$=f.object({name:f.string().optional(),message:f.string().optional()}).loose();function S(e){if(typeof e!="string")return;let n=e.replace(/\u001b\[[0-9;]*m/g,""),r=n.indexOf("{");if(r!==-1)try{let t=$.safeParse(JSON.parse(n.slice(r)));return t.success?t.data:void 0}catch{return}}function E(e,n=process.platform){let r=typeof e=="object"&&e!==null?e:{};return r.code==="ENOENT"?!0:n==="win32"&&(r.status===9009||/is not recognized as an internal or external command/i.test(String(r.stderr??"")))}function x(e,n,r=process.platform){if(E(n,r))return new c(e,`${l} SandForge reads each org through the Salesforce CLI: install it with "npm install -g @salesforce/cli" (${p}), sign in to the org with "sf org login web --alias ${e}", and run again.`);let t=typeof n=="object"&&n!==null?n:{},o=S(t.stdout)??S(t.stderr);if(o?.name==="NamedOrgNotFoundError"||/^No authorization information found for /.test(o?.message??""))return new c(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 sfdxurl").`);let i=typeof t.stderr=="string"?t.stderr.split(/\r?\n/).find(a=>a.trim()!==""):void 0,s=o?.message?.trim()||i?.trim()||(n instanceof Error?n.message:String(n));return new c(e,`sf could not show ${e}: ${s}`)}var y=u(C()),k=u(b());import{execFileSync as I}from"node:child_process";function T(e){try{return I("sf",["org","display","--target-org",e,"--json"],{encoding:"utf8",maxBuffer:50*1024*1024,shell:process.platform==="win32"})}catch(n){throw x(e,n)}}async function J(e,n=w){if(!h.test(e))throw new Error(`Invalid SF org alias: "${e}" (an alias or a username: letters, digits, _ . @ + and -, not starting with . @ + or -)`);let r=T(e),t=JSON.parse(r),o=t.result;if(typeof o?.devHubId=="string"&&o.devHubId!==""){let s=typeof o.expirationDate=="string"?g({orgType:"Scratch",metadata:{expirationDate:o.expirationDate}},new Date().toISOString().slice(0,10)):void 0;if(s!==void 0||o.status==="Deleted")throw new Error(`The scratch org '${e}' ${s!==void 0?`expired on ${s}`:"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(!t.result?.instanceUrl)throw new Error(`sf org display did not return a usable session for alias '${e}'.`);let i=await n(e);if(!m(i.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 sfdxurl --alias ${e} --sfdx-url-file <file>" (see ci-examples/README.md).`);return{alias:e,username:t.result.username??"",instanceUrl:i.instanceUrl??t.result.instanceUrl,accessToken:i.accessToken,...typeof t.result.devHubId=="string"&&t.result.devHubId!==""?{scratch:!0}:{}}}function d(e,n){let r=(e[n.toLowerCase()]??e[n.toUpperCase()]??"").trim();return r===""?void 0:r}function L(e,n){if(n===void 0)return!1;let r=e.hostname.toLowerCase(),t=e.port||(e.protocol==="https:"?"443":"80");return n.split(/[\s,]+/).filter(o=>o!=="").some(o=>{if(o==="*")return!0;let[,i="",s]=/^(.*?)(?::(\d+))?$/.exec(o.toLowerCase())??[];if(s!==void 0&&s!==t)return!1;let a=i.replace(/^\*?\.?/,"");return a!==""&&(r===a||r.endsWith(`.${a}`))})}function N(e,n=process.env){let r;try{r=new URL(e)}catch{return}let t=r.protocol==="https:"?d(n,"https_proxy")??d(n,"http_proxy"):d(n,"http_proxy");if(t!==void 0)return L(r,d(n,"no_proxy"))?void 0:t}function A(e,n=process.env){let r=N(e.instanceUrl,n),t=new y.default.Connection({instanceUrl:e.instanceUrl,accessToken:e.accessToken,version:"66.0",...r!==void 0?{httpProxy:r}:{}});return r===void 0&&(t._transport=new k.HttpProxyTransport("")),t}export{c as a,J as b,A as c};
|
package/lib/chunk-LRFAIUN7.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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{b as N}from"./chunk-WR2GIKWE.mjs";import{a as k}from"./chunk-BOGNK4LV.mjs";import{i as S}from"./chunk-Z7X534S4.mjs";import{a as _,b as E}from"./chunk-T63U4OZJ.mjs";import{Ba as V,E as L,Ha as H,N as F,O as w,Q as U,R as x,T as G,U as v,W as B,Wa as X,_ as j,qa as M,ta as W,ya as z}from"./chunk-VXHDBYMI.mjs";import{b as h,f as P,k as b,l as D}from"./chunk-7EANH5PY.mjs";var q={PII:"PII",PHI:"PHI",PCI:"PCI",Confidential:"SENSITIVE"},K={PII:"fake",PHI:"nullify",PCI:"mask",SENSITIVE:"hash",NONE:"fake"},$={name_pattern:"field_name",type_analysis:"field_name",content_pattern:"content_sampling"},J=.9;function ie(e,t){let n=[];for(let[i,a]of t){let c=a.fields.filter(o=>o.createable&&N({name:o.name,label:o.label,type:o.type})),l=new Map(c.map(o=>[o.name,o])),r=new Map,s=e.detectPII(i,c.map(o=>({apiName:o.name,label:o.label,type:o.type})));for(let o of s.piiFields){let u=l.get(o.fieldApiName);if(!u)continue;let d=q[o.classification];r.set(u.name,{objectApiName:i,fieldApiName:u.name,fieldLabel:u.label,fieldType:u.type,piiCategory:d,detectionMethod:$[o.detectionMethod],confidence:o.confidence,suggestedMethod:K[d]})}for(let o of c)r.has(o.name)||E(o.name,o.type)===void 0||r.set(o.name,{objectApiName:i,fieldApiName:o.name,fieldLabel:o.label,fieldType:o.type,piiCategory:"PII",detectionMethod:"field_name",confidence:J,suggestedMethod:"fake"});n.push(...r.values())}return n}function ae(e,t){let n=a=>`${a.objectApiName}.${a.fieldApiName}`,i=new Set(e.map(n));return[...e,...t.filter(a=>!i.has(n(a)))]}var Y=["Contact","Lead"];function re(e,t,n){if(e==="none")return[];let i=new Set(t),a=[];for(let c of Y){if(!i.has(c))continue;let l=n.filter(s=>s.objectApiName===c).map(s=>s.fieldApiName),r=[];l.some(_)||r.push("name"),l.some(s=>E(s,"string")==="email")||r.push("email"),l.some(s=>E(s,"string")==="phone")||r.push("phone"),r.length>0&&a.push({objectApiName:c,missing:r})}return a}function ce(e){return e.fatalError!==void 0?"failure":e.totalFailure>0||e.failedObjects.length>0?e.totalSuccess+(e.totalLinked??0)>0?"partial":"failure":[...Object.values(e.lookups??{}),...Object.values(e.statuses??{})].some(n=>n.refusals.length>0)||e.stopped===!0?"partial":"success"}var Q=D({name:h().min(1),referenceTo:b(h()).min(1),createable:P().optional(),updateable:P().optional()}).loose();function de(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let i=Q.safeParse(n);i.success&&t.push({name:i.data.name,referenceTo:i.data.referenceTo,createable:i.data.createable??!1,updateable:i.data.updateable??!1})}return t}var ge={STORAGE_EXCEEDED:"AUTOPILOT_STORAGE_EXCEEDED",API_BUDGET_EXCEEDED:"API_BUDGET_EXCEEDED",WRITE_DECLINED:"AUTOPILOT_WRITE_DECLINED",CONFIRMATION_UNAVAILABLE:"AUTOPILOT_CONFIRMATION_UNAVAILABLE",CHECKPOINT_REFUSED:"CHECKPOINT_REFUSED",RUN_CANCELLED:"RUN_CANCELLED",EMAILS_NOT_ACCEPTED:z},Ae={NO_PLAN:"AUTOPILOT_NO_PLAN",STORAGE_UNREAD:"AUTOPILOT_FIT_STORAGE_UNREAD",READ_REFUSED:"AUTOPILOT_FIT_READ_REFUSED",STALE:"AUTOPILOT_FIT_STALE"};function Ie(e,t,n=new Map){return L(e.waves.flatMap(i=>i.objects).map(i=>{let a=n.get(i);return{objectApiName:i,rows:[],counted:{rows:t.get(i)??0,...a!==void 0?{personAccounts:a}:{}}}}))}function Ce(e){return[...new Set(e.waves.flatMap(t=>t.objects.map(String)))]}async function he(e){return M(e)}function Z(e){return e.filter(t=>t.verdict==="exceeds").map(W)}function ee(e){return e.filter(t=>t.verdict==="unread").map(t=>({limit:t.limit,emails:t.emails,unread:t.unread??""}))}function Pe(e){return e.objects.filter(({rows:t})=>t>0).length}async function te(e,t,n,i,a={}){let c="unread"in t?await n().catch(o=>({unread:o instanceof Error?o.message:String(o)})):t.dailyApiRequests,{readBack:l=0,deliverability:r=0,mute:s=0}=a;return w({run:F(e.objects.map(({rows:o})=>({rows:o}))),...G(i),...s>0?{mute:s}:{},...l>0?{readBack:l}:{},...r>0?{deliverability:r}:{}},c)}async function ke(e){let{plan:t}=e,n=j(t,e.storage);if(t.totalRows===0)return{go:!0,check:n,asked:!1};let i=e.checkpointFirst?.estimate,a=v(i);if(a)return{go:!1,...a,check:n};let c=X(n,e.org);if(c)return{go:!1,code:"STORAGE_EXCEEDED",message:`${c} Nothing was written.`,check:n};let l=await te(t,e.storage,e.readApiBudget,i,{...e.readBack!==void 0?{readBack:e.readBack}:{},...e.mute!==void 0?{mute:e.mute}:{},...V(e.runEmails?.ofRun)}),r=U(l,e.org);if(r)return{go:!1,code:"API_BUDGET_EXCEEDED",message:r,check:n};let s=e.confirmAboveRecords,o=s>0&&t.totalRows>s?s:void 0,u=Z(e.emails??[]),d=ee(e.emails??[]),g=e.emailsUncounted,f=e.runEmails?.gate,y=f?.verdict==="asks",R=async m=>{let p=k(f,m&&y),I=e.checkpointFirst;if(I===void 0)return{go:!0,check:n,asked:m,...p};let C=await B(()=>I.take(I.estimate));return"stop"in C?{go:!1,...C.stop,check:n,...p}:{go:!0,check:n,asked:m,checkpoint:C.checkpoint,...p}};if(o===void 0&&n.verdict==="fits"&&u.length===0&&d.length===0&&g===void 0&&i===void 0&&!y)return R(!1);let A=S(e.orgTier),T=await e.confirm({stage:"write",module:"autopilot",org:e.org,orgTier:e.orgTier,objects:t.objects.map(({objectApiName:m,rows:p})=>({objectApiName:m,rows:p})),total:t.totalRows,...o!==void 0?{aboveRecords:o}:{},...A!==void 0&&t.totalRows>A?{largeVolume:A}:{},storage:H(n),counted:!0,...u.length>0?{emails:u}:{},...d.length>0?{emailsUnread:d}:{},...g!==void 0?{emailsUncounted:g}:{},...x(l),...i!==void 0?{checkpoint:i}:{},...f?.confirmation});if(T==="confirmed")return R(!0);let O=k(f,!1);return T==="declined"?{go:!1,code:"WRITE_DECLINED",message:"The Autopilot run was cancelled before it wrote anything. Nothing was written.",check:n,...O}:{go:!1,code:"CONFIRMATION_UNAVAILABLE",message:"The Autopilot run needed a confirmation before it wrote, and there was no one to ask. Nothing was written.",check:n,...O}}export{ie as a,ae as b,re as c,ce as d,de as e,ge as f,Ae as g,Ie as h,Ce as i,he as j,Pe as k,te as l,ke as m};
|
package/lib/chunk-LV6G4XTK.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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{b as l}from"./chunk-CA5NAXSU.mjs";import{ld as m,md as S,qd as h,rd as g,sd as y}from"./chunk-B45CNPUX.mjs";var T=576*60*60*1e3,P=T,f=class extends Error{constructor(e){super(e),this.name="StepCancelledError"}},b=Symbol("stopped");function w(t,e,n,i){let r=new Date().toISOString();return{stepId:t.id,stepName:t.name,stepType:t.type,status:"completed",output:e,summary:i,startTime:n,endTime:r,duration:new Date(r).getTime()-new Date(n).getTime()}}function d(t,e,n){let i=new Date().toISOString();return{stepId:t.id,stepName:t.name,stepType:t.type,status:"failed",error:e,startTime:n,endTime:i,duration:new Date(i).getTime()-new Date(n).getTime()}}function v(t){return y(t.type)?`Step "${t.name}" is a ${String(t.type)} step, which SandForge no longer supports: remove it from the pipeline.`:g(t.type)?`Step "${t.name}" is a ${String(t.type)} step, and this step type cannot run in a pipeline yet.`:`Step "${t.name}" is a "${String(t.type)}" step, a step type this release of SandForge does not have: the pipeline was saved by a later release, or written by hand. Remove the step, or update SandForge.`}function x(t){let{timeout:e}=t;if(e!==void 0){if(typeof e!="number"||!Number.isFinite(e))return`Step "${t.name}" has a timeout that is not a number of milliseconds: ${JSON.stringify(e)}.`;if(e>P)return`Step "${t.name}" has a timeout of ${e} ms, longer than a step can be given: set at most 24 days (${P} ms).`}}function D(t){let e=t.seconds,n=e===void 0?t.durationMs:e;if(typeof n!="number"||!Number.isFinite(n)||n<0)return;let i=e===void 0?n:n*1e3;return i<=T?i:void 0}function C(t){if(t.config.seconds===void 0&&t.config.durationMs===void 0)return`Delay step "${t.name}" has no duration: set how many seconds it waits.`;if(D(t.config)===void 0)return`Delay step "${t.name}" has no usable duration: set a number of seconds, from 0 up to 24 days.`}function H(t,e,n){let i=`Condition step "${t.name}"`;switch(n){case"noEarlierStep":return`${i} tests how the previous step went, and no step comes before it.`;case"noCompare":return`${i} tests how many differences a comparison found, and no Compare step comes before it.`;case"noPrecheck":return`${i} tests ${e}, which a Pre-check hands on, and no Pre-check before it takes that reading.`}}function k(t){let e=t.condition;if(!e||typeof e.field!="string"||e.field.trim()==="")return`Condition step "${t.name}" has no condition to evaluate.`;let n=m(e);return n===void 0?void 0:`Condition step "${t.name}" ${n}.`}function M(t,e){let n=k(t);if(n!==void 0||!t.condition||!e)return n;let i=t.condition,r=h(i,e.steps.slice(0,e.index),e.declared);return r===void 0?void 0:H(t,i.field,r)}function E(t,e){return e?.aborted?Promise.resolve(!1):new Promise(n=>{let i=()=>{clearTimeout(r),n(!1)},r=setTimeout(()=>{e?.removeEventListener("abort",i),n(!0)},t);e?.addEventListener("abort",i,{once:!0})})}var $=class{handlers=new Map;checks=new Map;constructor(){this.registerDefaults()}async execute(e,n){let i=new Date().toISOString(),r=this.check(e);if(r)return d(e,r,i);let o=this.getExecutor(e.type),c=e.retries??0,u="";for(let p=0;p<=c;p++){let s=await this.attempt(o,e,n);if("result"in s)return s.result;if(s.stopped)return{...d(e,s.error,i),status:"stopped"};u=s.error}return d(e,u,i)}async attempt(e,n,i){let r=i.signal;if(r?.aborted)return{error:`Step "${n.name}" was stopped before it started.`,stopped:!0};let o=new AbortController,c=new Promise(a=>{o.signal.addEventListener("abort",()=>a(b),{once:!0})}),u=()=>o.abort();r?.addEventListener("abort",u,{once:!0});let p=!1,s=n.timeout,R=s!==void 0&&s>0?setTimeout(()=>{p=!0,o.abort()},s):void 0;try{let a=await Promise.race([e(n,{...i,signal:o.signal}),c]);return a!==b?{result:a}:p?{error:`Step "${n.name}" timed out after ${s} ms.`}:{error:`Step "${n.name}" was stopped before it finished.`,stopped:!0}}catch(a){return a instanceof f?{error:a.message,stopped:!0}:{error:l(a)}}finally{clearTimeout(R),r?.removeEventListener("abort",u)}}check(e,n){return this.handlers.has(e.type)?x(e)??this.checks.get(e.type)?.(e,n):v(e)}getExecutor(e){return this.handlers.get(e)??this.refusingHandler}registerHandler(e,n,i){this.handlers.set(e,n),i?this.checks.set(e,i):this.checks.delete(e)}refusingHandler=async e=>d(e,v(e),new Date().toISOString());registerDefaults(){this.handlers.set("delay",this.createDelayHandler()),this.checks.set("delay",C),this.handlers.set("condition",this.createConditionHandler()),this.checks.set("condition",M)}createDelayHandler(){return async(e,n)=>{let i=new Date().toISOString(),r=D(e.config);return r===void 0?d(e,C(e)??"No usable duration",i):await E(r,n.signal)?w(e,{delayed:r},i,`Waited ${r/1e3} s.`):d(e,`Delay step "${e.name}" was stopped before its ${r} ms wait ended.`,i)}}createConditionHandler(){return async(e,n)=>{let i=new Date().toISOString(),r=k(e);if(r||!e.condition)return d(e,r??"No condition",i);try{let o=S(e.condition,n.variables);return w(e,{conditionMet:o},i,o?"The condition held.":"The condition did not hold.")}catch(o){return d(e,`Condition step "${e.name}" could not be evaluated: ${l(o)}.`,i)}}}};export{f as a,$ as b};
|
package/lib/chunk-MYTIL2JD.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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 E}from"./chunk-5P4PHJRL.mjs";import{W as Y,ha as R,ia as P}from"./chunk-6QSM2WIH.mjs";import{a as O,z as _}from"./chunk-WJY54JO7.mjs";import{E as S,c as X,p as A,q as z}from"./chunk-NEVXIGR6.mjs";import{g as w,h as y}from"./chunk-PA3MKJVH.mjs";import{Tb as u}from"./chunk-B45CNPUX.mjs";import{b as D,e as W,f as Q,l as L}from"./chunk-7EANH5PY.mjs";import{mkdir as se,rm as M}from"node:fs/promises";import{join as I}from"node:path";var ee=200,ne=Y*10,B=2e3,te=["Id","ContentDocumentId","LinkedEntityId","ShareType","Visibility"],ae=["Id","LatestPublishedVersionId","ContentSize"],de="taking",h=D().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,"Not a record id"),T=D().regex(/^[A-Za-z]{1,40}$/,"Not a sharing value"),V=L({Id:h,ContentDocumentId:h,LinkedEntityId:h,ShareType:T,Visibility:T}),J=L({Id:h,LatestPublishedVersionId:h.nullable(),ContentSize:W().int().nonnegative().nullable(),anchored:Q()});function Re(e,n){return I(e,`${y}.${n}.ndjson`)}var Ce=V.extend({now:L({ShareType:T,Visibility:T})});function Fe(e,n){let t=new Set(n.map(r=>r.toLowerCase())),i=new Map;for(let r of e){let a=r.keyPrefix;t.has(r.name.toLowerCase())&&typeof a=="string"&&a.length===3&&i.set(a,r.name)}return i}function Te(e,n){let t=e.LinkedEntityId;return typeof t=="string"&&t.length>=15?n.get(t.slice(0,3)):void 0}function oe(e){return e.map(n=>{if(!h.safeParse(n).success)throw new Error(`Not a record id: ${n}`);return`'${n}'`}).join(", ")}function ce(e){let n=u(e);return{objectApiName:n,soql:`SELECT ${te.join(", ")} FROM ${y} WHERE LinkedEntityId IN (SELECT Id FROM ${n})`,scanAll:!1}}function be(e){let n=u(e);return{objectApiName:n,soql:`SELECT COUNT() FROM ${y} WHERE LinkedEntityId IN (SELECT Id FROM ${n})`,scanAll:!1}}function le(e,n){return{objectApiName:u(e),soql:`SELECT ${te.join(", ")} FROM ${y} WHERE LinkedEntityId IN (${oe(n)})`,scanAll:!1}}function fe(e){return{objectApiName:w,soql:`SELECT ${ae.join(", ")} FROM ${w} WHERE Id IN (${oe(e)})`,scanAll:!1}}async function*v(e,n){let t=[];for await(let i of e)t.push(i),t.length>=n&&(yield t,t=[]);t.length>0&&(yield t)}function*C(e,n){let t=[];for(let i of e)t.push(i),t.length>=n&&(yield t,t=[]);t.length>0&&(yield t)}function G(e,n,t){let i=e.safeParse(n);if(!i.success)throw new Error(`The org answered a ${t} that does not read as one: ${i.error.message}`);return i.data}function F(e){return e.slice(0,15)}async function xe(e){let{reader:n,folder:t,signal:i}=e,r=e.files??O(E(t.dir)),a=I(t.filesDir,de);await se(a,{recursive:!0,mode:X});let m=z(t),b=A(t);await r.writeFile(m,""),await r.writeFile(b,"");try{let x=new Map,q=0,H=async d=>{for await(let c of v(P(d),B)){let s=c.map(o=>G(V,o,"link"));for(let o of s)x.has(F(o.ContentDocumentId))||x.set(F(o.ContentDocumentId),o.ContentDocumentId);q+=s.length,await r.appendFile(m,s.map(o=>`${JSON.stringify(o)}
|
|
8
|
-
`).join(""))}await M(d,{force:!0})},K=e.linked.map(d=>({...ce(d),file:I(a,`${u(d)}.links.ndjson`)})),re=await R(n,K,i),$=[];for(let[d,c]of re.entries()){if(c.read){await H(K[d].file);continue}let s=e.linked[d];$.push(s);let o=await _.read(t,e.snapshotId,s),l=0;for(let g of C(C(pe(o),ee),ne)){let f=g.map(k=>({...le(s,k),file:I(a,`${u(s)}.links.${l++}.ndjson`)})),N=(await R(n,f,i)).find(k=>!k.read);if(N&&!N.read)throw new Error(`The links of the files of ${s} could not be read whole: ${c.reason}; read by the ids of its records, ${N.reason}`);for(let k of f)await H(k.file)}}let j=0,U=0,Z=new Set;for(let d of C(C(x.values(),ee),ne)){let c=d.map((l,g)=>({...fe(l),file:I(a,`documents.${g}.ndjson`)})),o=(await R(n,c,i)).find(l=>!l.read);if(o&&!o.read)throw new Error(`The files the links name could not be read by their ids: ${o.reason}`);for(let l of c){for await(let g of v(P(l.file),B)){let f=g.map(p=>({...G(J.omit({anchored:!0}),p,"file"),anchored:!0}));for(let p of f)Z.add(F(p.Id));j+=f.length,U+=f.length,await r.appendFile(b,f.map(p=>`${JSON.stringify(p)}
|
|
9
|
-
`).join(""))}await M(l.file,{force:!0})}}if(e.documentsInSnapshot){let d=await _.read(t,e.snapshotId,w);for await(let c of v(d.records(),B)){let s=c.filter(o=>typeof o.Id=="string"&&!Z.has(F(o.Id))).map(o=>({...G(J.omit({anchored:!0}),ue(o),"file"),anchored:!1}));j+=s.length,s.length>0&&await r.appendFile(b,s.map(o=>`${JSON.stringify(o)}
|
|
10
|
-
`).join(""))}}return{documents:j,links:q,anchored:U,...$.length>0?{readByIds:$}:{}}}finally{await M(a,{recursive:!0,force:!0})}}function*pe(e){for(let n=0;n<e.size;n++)yield e.idAt(n)}function ue(e){return{Id:e.Id,LatestPublishedVersionId:e.LatestPublishedVersionId??null,ContentSize:e.ContentSize??null}}async function*ie(e,n,t,i){if(!await e.exists(n))throw new S("damaged",`The checkpoint\u2019s ${i} are not there`);for await(let r of e.readLines(n)){if(r==="")continue;let a;try{a=JSON.parse(r)}catch{throw new S("damaged",`The checkpoint\u2019s ${i} hold a line that is not JSON`)}let m=t.safeParse(a);if(!m.success)throw new S("damaged",`The checkpoint\u2019s ${i} hold a line that does not parse`);yield m.data}}function $e(e,n=O(E(e.dir))){return ie(n,z(e),V,"file links")}function je(e,n=O(E(e.dir))){return ie(n,A(e),J,"files")}export{ee as a,te as b,V as c,Re as d,Ce as e,Fe as f,Te as g,ce as h,be as i,le as j,xe as k,$e as l,je as m};
|