sandforge 1.79.0 → 1.80.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/lib/{chunk-JVL444U5.mjs → chunk-2BA2XKAY.mjs} +1 -1
- package/lib/chunk-2CNCDM56.mjs +7 -0
- package/lib/{chunk-W7KFAY55.mjs → chunk-2GTBABKU.mjs} +1 -1
- package/lib/{chunk-DLDX6RRC.mjs → chunk-2NBYT7GR.mjs} +1 -1
- package/lib/{chunk-HV2MXMGI.mjs → chunk-2UZPIMUC.mjs} +1 -1
- package/lib/chunk-3F6Q5E7I.mjs +14 -0
- package/lib/{chunk-PBI4BYWW.mjs → chunk-3RZQZHEB.mjs} +1 -1
- package/lib/{chunk-P7GSGFJO.mjs → chunk-3TJON4F3.mjs} +1 -1
- package/lib/chunk-4VS2V6WU.mjs +25 -0
- package/lib/{chunk-TQX3PURV.mjs → chunk-5K5VLULK.mjs} +1 -1
- package/lib/{chunk-MYTIL2JD.mjs → chunk-5TC3QB4U.mjs} +1 -1
- package/lib/{chunk-NM4MDLK4.mjs → chunk-6XYKJSGX.mjs} +1 -1
- package/lib/{chunk-RFEO2KAN.mjs → chunk-74Q6DORA.mjs} +1 -1
- package/lib/chunk-7ABODJ4G.mjs +7 -0
- package/lib/{chunk-ZPYJPGDK.mjs → chunk-7EGQP6S4.mjs} +1 -1
- package/lib/chunk-7FFGJWHN.mjs +7 -0
- package/lib/chunk-7YDNUBO5.mjs +7 -0
- package/lib/{chunk-CGWXQX75.mjs → chunk-A527W53V.mjs} +1 -1
- package/lib/chunk-ADOAS63R.mjs +7 -0
- package/lib/chunk-AEKONPF4.mjs +7 -0
- package/lib/{chunk-4HFRHFGQ.mjs → chunk-B5QQJ4SI.mjs} +1 -1
- package/lib/{chunk-2BVTCNWA.mjs → chunk-BGUEWRK2.mjs} +1 -1
- package/lib/{chunk-GNC27UEU.mjs → chunk-BKDV4ENO.mjs} +1 -1
- package/lib/{chunk-QRV2OSIS.mjs → chunk-BTWDMNN3.mjs} +1 -1
- package/lib/{chunk-FOVVHGEP.mjs → chunk-BV6VTP3J.mjs} +1 -1
- package/lib/{chunk-PZTSVQSF.mjs → chunk-BXU6WFMH.mjs} +1 -1
- package/lib/{chunk-ZQOZ4EFW.mjs → chunk-BY2HJFFG.mjs} +1 -1
- package/lib/{chunk-NZ5ZZLKS.mjs → chunk-CEX3NEZL.mjs} +1 -1
- package/lib/{chunk-HTJ5OGP5.mjs → chunk-CHYDMRSV.mjs} +1 -1
- package/lib/chunk-CION3VMZ.mjs +7 -0
- package/lib/chunk-COFG7Q6R.mjs +7 -0
- package/lib/chunk-CSBS5U5I.mjs +7 -0
- package/lib/{chunk-55HEMHEG.mjs → chunk-CU2INBND.mjs} +1 -1
- package/lib/chunk-DB7RBE5D.mjs +7 -0
- package/lib/{chunk-QPF6C5MX.mjs → chunk-DBB3EMIN.mjs} +1 -1
- package/lib/{chunk-F74IHMGL.mjs → chunk-DYFALGRT.mjs} +1 -1
- package/lib/{chunk-TEOLMRDO.mjs → chunk-E5AHXLS6.mjs} +1 -1
- package/lib/{chunk-LRFAIUN7.mjs → chunk-E5ZB3LU5.mjs} +1 -1
- package/lib/chunk-EFR2Y7E4.mjs +7 -0
- package/lib/chunk-EHQ3FX6X.mjs +7 -0
- package/lib/{chunk-RAAANPPG.mjs → chunk-ELFXJHU7.mjs} +1 -1
- package/lib/{chunk-BN7A4GRQ.mjs → chunk-EMNC6YI4.mjs} +1 -1
- package/lib/{chunk-HJC7AIBK.mjs → chunk-EQNW3UC2.mjs} +1 -1
- package/lib/{chunk-Z7X534S4.mjs → chunk-F43REJDZ.mjs} +2 -2
- package/lib/{chunk-QQZZMKU3.mjs → chunk-F6GUDTOB.mjs} +1 -1
- package/lib/{chunk-6EBMEGZB.mjs → chunk-FGRG7ANU.mjs} +1 -1
- package/lib/{chunk-4NAHW2D3.mjs → chunk-FKG7Q3WH.mjs} +1 -1
- package/lib/{chunk-7UQD6V6F.mjs → chunk-FPKYYFM7.mjs} +1 -1
- package/lib/{chunk-ZJKCWBRJ.mjs → chunk-FXXLX4O6.mjs} +1 -1
- package/lib/chunk-G35N4P7D.mjs +7 -0
- package/lib/{chunk-SIOZXPFG.mjs → chunk-GGD7ON3M.mjs} +1 -1
- package/lib/chunk-GSG7WZHM.mjs +7 -0
- package/lib/{chunk-OTWRDD6L.mjs → chunk-GSKCGQIP.mjs} +1 -1
- package/lib/{chunk-3CA767QB.mjs → chunk-HEKAZJRH.mjs} +1 -1
- package/lib/{chunk-4SNDMJP2.mjs → chunk-HLWMJF6Y.mjs} +1 -1
- package/lib/chunk-HOJYWTP7.mjs +20 -0
- package/lib/chunk-HS4YRX4J.mjs +7 -0
- package/lib/chunk-IFETCRWE.mjs +10 -0
- package/lib/{chunk-PUOX4NBJ.mjs → chunk-IG2MTQRP.mjs} +1 -1
- package/lib/{chunk-RACDTRZA.mjs → chunk-IGYH7GMA.mjs} +1 -1
- package/lib/{chunk-X65MT4W3.mjs → chunk-IOIWJ3DJ.mjs} +1 -1
- package/lib/{chunk-4U6NXJNL.mjs → chunk-IQXHJEYB.mjs} +1 -1
- package/lib/{chunk-P2PJYWGQ.mjs → chunk-IWDREM66.mjs} +1 -1
- package/lib/{chunk-ZOVSMN5C.mjs → chunk-IZQZ6ZUF.mjs} +1 -1
- package/lib/{chunk-XBG5SP6Q.mjs → chunk-J525F5KI.mjs} +1 -1
- package/lib/{chunk-5CD257T7.mjs → chunk-JEERQRLW.mjs} +1 -1
- package/lib/{chunk-6QSM2WIH.mjs → chunk-JPUR2CFX.mjs} +1 -1
- package/lib/chunk-JWTSEDIQ.mjs +7 -0
- package/lib/chunk-K327QKMD.mjs +7 -0
- package/lib/{chunk-J7HVXMSW.mjs → chunk-KBJ5VERV.mjs} +1 -1
- package/lib/chunk-KDGMAGQR.mjs +7 -0
- package/lib/chunk-KRCA6IPH.mjs +8 -0
- package/lib/chunk-KYEDBS54.mjs +7 -0
- package/lib/chunk-L5FGY6YA.mjs +7 -0
- package/lib/{chunk-PNCONNFJ.mjs → chunk-L77FJZEP.mjs} +1 -1
- package/lib/{chunk-3OHPD72J.mjs → chunk-LKQ5RKIV.mjs} +1 -1
- package/lib/{chunk-WJY54JO7.mjs → chunk-LPBMBW3O.mjs} +1 -1
- package/lib/{chunk-LV6G4XTK.mjs → chunk-LWW4U276.mjs} +1 -1
- package/lib/{chunk-IAZB4WIL.mjs → chunk-M3ROUWDX.mjs} +1 -1
- package/lib/chunk-MFG4MUIO.mjs +9 -0
- package/lib/{chunk-H45UXY6G.mjs → chunk-MHMH6MTP.mjs} +1 -1
- package/lib/{chunk-HCIDVIOW.mjs → chunk-MILU7WFN.mjs} +1 -1
- package/lib/chunk-MJU2PGZQ.mjs +15 -0
- package/lib/{chunk-HJKM3E56.mjs → chunk-MJVTDA5Q.mjs} +1 -1
- package/lib/{chunk-SBIMVCXT.mjs → chunk-MS4FJDFD.mjs} +9 -9
- package/lib/{chunk-3SRXFZSD.mjs → chunk-MYW5QNGI.mjs} +1 -1
- package/lib/{chunk-VHI54FBK.mjs → chunk-N652NMZ4.mjs} +26 -26
- package/lib/{chunk-3DCUADVK.mjs → chunk-NTFIRZP6.mjs} +1 -1
- package/lib/{chunk-342FN7AO.mjs → chunk-NZC67CGR.mjs} +1 -1
- package/lib/{chunk-RSYICMZG.mjs → chunk-O2HDYYUV.mjs} +1 -1
- package/lib/chunk-OAZRPP4I.mjs +7 -0
- package/lib/{chunk-BILZ3SSR.mjs → chunk-OHWNPXWW.mjs} +1 -1
- package/lib/chunk-OLSGVAIL.mjs +341 -0
- package/lib/chunk-OO6CLPEH.mjs +7 -0
- package/lib/chunk-OPXCV2KL.mjs +7 -0
- package/lib/chunk-P33PSCXK.mjs +7 -0
- package/lib/{chunk-AUTM6H6Z.mjs → chunk-PJ5I73CK.mjs} +1 -1
- package/lib/{chunk-NTDN2JQZ.mjs → chunk-PZPJKATS.mjs} +1 -1
- package/lib/{chunk-5QKTYCWE.mjs → chunk-Q3DM32KF.mjs} +1 -1
- package/lib/{chunk-K22PA4XL.mjs → chunk-QR3WELJQ.mjs} +1 -1
- package/lib/{chunk-42RER7V4.mjs → chunk-R3X3LV64.mjs} +1 -1
- package/lib/chunk-RMBPOTD7.mjs +7 -0
- package/lib/{chunk-IEYG5ATY.mjs → chunk-RPI7LRTW.mjs} +1 -1
- package/lib/{chunk-5MMXFWPD.mjs → chunk-SE4QEZUG.mjs} +1 -1
- package/lib/{chunk-ALJVEUUS.mjs → chunk-SIHORWVK.mjs} +1 -1
- package/lib/{chunk-AAVJ5XVX.mjs → chunk-SOGQW4IG.mjs} +1 -1
- package/lib/chunk-SOU4FRYN.mjs +7 -0
- package/lib/chunk-SU65Z2BA.mjs +7 -0
- package/lib/chunk-T62WNR54.mjs +7 -0
- package/lib/{chunk-5O6JOMHS.mjs → chunk-TSLJUSLW.mjs} +1 -1
- package/lib/chunk-TTFDUKUS.mjs +47 -0
- package/lib/{chunk-57VHUYNG.mjs → chunk-TTKXMDBN.mjs} +1 -1
- package/lib/chunk-UCD54V2M.mjs +7 -0
- package/lib/{chunk-TBZMC2VV.mjs → chunk-UNJA4J37.mjs} +1 -1
- package/lib/{chunk-NGSMZZDA.mjs → chunk-VE6XKGGD.mjs} +1 -1
- package/lib/chunk-VS7ZXUII.mjs +824 -0
- package/lib/{chunk-ALUFROGA.mjs → chunk-VXQLDM4R.mjs} +1 -1
- package/lib/chunk-VYXMVJL5.mjs +7 -0
- package/lib/{chunk-WFEB5X4U.mjs → chunk-W622GUAW.mjs} +1 -1
- package/lib/chunk-W7U5E5ZL.mjs +9 -0
- package/lib/{chunk-AR7BE5O2.mjs → chunk-WA7EYLAQ.mjs} +1 -1
- package/lib/{chunk-EQF2IJS2.mjs → chunk-WR4Q363I.mjs} +1 -1
- package/lib/{chunk-ZXH4MBWP.mjs → chunk-WU3GLFZO.mjs} +1 -1
- package/lib/chunk-WXAQ7FK3.mjs +115 -0
- package/lib/{chunk-YBU4Z4QV.mjs → chunk-X5JYBPXP.mjs} +1 -1
- package/lib/chunk-XAMBCQPU.mjs +7 -0
- package/lib/{chunk-LQ4DRFUH.mjs → chunk-XLXIPIEW.mjs} +1 -1
- package/lib/{chunk-H2PJNIYJ.mjs → chunk-XUWL6ZPC.mjs} +1 -1
- package/lib/{chunk-P42X3B4D.mjs → chunk-YKKRIEH4.mjs} +1 -1
- package/lib/chunk-YRQGKDHM.mjs +7 -0
- package/lib/chunk-ZM6OJGIG.mjs +7 -0
- package/lib/{chunk-SFURUNJM.mjs → chunk-ZVAED4QV.mjs} +1 -1
- package/lib/sandforge-autopilot.mjs +29 -24
- package/lib/sandforge-backup.mjs +25 -21
- package/lib/sandforge-checkpoint.mjs +15 -14
- 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 +88 -88
- package/lib/sandforge-frozen.mjs +43 -34
- package/lib/sandforge-mcp.mjs +12 -12
- package/lib/sandforge-monitor.mjs +7 -7
- package/lib/sandforge-seed.mjs +1 -1
- package/lib/sandforge-sync.mjs +1 -1
- package/lib/sandforge.mjs +4 -4
- package/package.json +1 -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-4GL773D5.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-6LAXTAVN.mjs +0 -7
- package/lib/chunk-6MUEPV7M.mjs +0 -9
- package/lib/chunk-75ADZS6B.mjs +0 -7
- package/lib/chunk-B45CNPUX.mjs +0 -47
- package/lib/chunk-BS5T3MOQ.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-HUMEKZT5.mjs +0 -8
- package/lib/chunk-I3JKJTLO.mjs +0 -110
- package/lib/chunk-KLX67VPL.mjs +0 -7
- package/lib/chunk-L776PUMV.mjs +0 -7
- package/lib/chunk-NEVXIGR6.mjs +0 -10
- package/lib/chunk-NHWE66K5.mjs +0 -7
- package/lib/chunk-OQOZAPCI.mjs +0 -7
- package/lib/chunk-PA3MKJVH.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-VXHDBYMI.mjs +0 -7
- 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-YW2SBL4Z.mjs +0 -7
- package/lib/chunk-ZE6HKRR4.mjs +0 -9
- package/lib/chunk-ZLZRU6MO.mjs +0 -7
- package/lib/chunk-ZYEE34WO.mjs +0 -7
|
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{u as Q,w as q}from"./chunk-
|
|
7
|
+
import{u as Q,w as q}from"./chunk-LPBMBW3O.mjs";import{F as W,H as Z,d as K,k as I,r as b,s as L,t as F,u as J,x as D,z as U}from"./chunk-IFETCRWE.mjs";import{Ca as Y,Da as G,Ea as N}from"./chunk-TTFDUKUS.mjs";import{b as H,e as _,m as $,v as X}from"./chunk-7EANH5PY.mjs";import{createCipheriv as be,createDecipheriv as Be,createHash as y,hkdfSync as Ae,randomBytes as S,timingSafeEqual as Ee}from"node:crypto";import{createReadStream as Oe}from"node:fs";import{lstat as ee,open as T,rename as xe,rm as Ie,statfs as Se}from"node:fs/promises";import{basename as ie,dirname as oe,join as ve}from"node:path";import{Readable as ae}from"node:stream";import{pipeline as se}from"node:stream/promises";import{createGunzip as Re,createGzip as Ce}from"node:zlib";var ct=".sfcheckpoint",Te=1024*1024,Pe=new Set([1]),He=new Set([1]),P=32,A=16,_e=4096,$e=1024,Ne=64*1024*1024,ce=2**32,he="sandforge-checkpoint/1 block key",fe="sandforge-checkpoint/1 key check",M="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",Ke=Math.ceil(P*8/5),w="Nothing was imported.";function ht(){return S(P)}function ft(n){if(n.length!==P)throw new RangeError("Not a key of a checkpoint file");let e="",t=0,r=0;for(let i of n)for(t=(t<<8|i)&65535,r+=8;r>=5;)e+=M[t>>>r-5&31],r-=5;return r>0&&(e+=M[t<<5-r&31]),(e.match(/.{1,4}/g)??[]).join("-")}function dt(n){let e=n.replace(/[\s-]/g,"").toUpperCase();if(e.length!==Ke||!/^[A-Z2-7]+$/.test(e))return;let t=Buffer.alloc(P),r=0,i=0,o=0;for(let a of e)r=(r<<5|M.indexOf(a))&65535,i+=5,i>=8&&(t[o++]=r>>>i-8&255,i-=8);if((r&(1<<i)-1)===0)return t}function v(n,e,t,r){return Buffer.from(Ae("sha256",n,e,t,r))}function de(n,e){let t=Buffer.alloc(12);return n.copy(t,0),t.writeUInt32BE(e,8),t}function le(n,e,t){let r=Buffer.alloc(37);return n.copy(r,0),r.writeUInt32BE(e,32),r[36]=t?1:0,r}function Fe(n,e,t,r){let i=be("aes-256-gcm",n.blockKey,de(n.prefix,e),{authTagLength:A});return i.setAAD(le(n.headerHash,e,t)),Buffer.concat([i.update(r),i.final(),i.getAuthTag()])}function De(n,e,t,r){let i=Be("aes-256-gcm",n.blockKey,de(n.prefix,e),{authTagLength:A});i.setAAD(le(n.headerHash,e,t)),i.setAuthTag(r.subarray(r.length-A));try{let o=i.update(r.subarray(0,r.length-A));return Buffer.concat([o,i.final()])}catch{return}}var R=class extends Error{constructor(t){super(t.message);this.refusal=t;this.name="ImportRefused"}refusal};function f(n){return new R({code:"IMPORT_DAMAGED",message:`This checkpoint file ${n}: it was changed or damaged after it was exported. ${w}`})}var E=class extends Error{constructor(t,r){super(r);this.code=t;this.name="CheckpointExportError"}code};function Me(n){return{...C(n,ue),org:C(n.org,pe)}}var ue=["lastRewind","takenOn","expiresAt","bytes","importedFrom"],pe=["alias"];function C(n,e){return Object.fromEntries(Object.entries(n).filter(([t])=>!e.includes(t)))}async function*ye(n,e){if(e===0)return;let t=0;for await(let r of Oe(n,{start:0,end:e-1})){let i=r;t+=i.length,yield i}if(t!==e)throw new E("EXPORT_CHANGED",`${ie(n)} of the checkpoint shrank while it was exported: export it again.`)}async function me(n,e){let t=y("sha256");for await(let r of ye(n,e))t.update(r);return t.digest("hex")}async function lt(n){let{folder:e,checkpoint:t,out:r,key:i}=n,o=n.chunkBytes??Te;if(await ee(r).catch(()=>{}))throw new E("EXPORT_EXISTS",`${r} is there already: name another file, or move that one away first.`);let a=Buffer.from(`${JSON.stringify(Me(t))}
|
|
8
8
|
`,"utf8"),s=[{path:b,bytes:a.length,sha256:y("sha256").update(a).digest("hex"),content:a}];for(let l of await F(e))l.path!==b&&s.push({...l,sha256:await me(l.file,l.bytes)});let h=S(32),c=S(8),d={format:"sandforge-checkpoint",formatVersion:1,checkpointFormat:1,sandforgeVersion:n.sandforgeVersion,organizationId:I(t.org.organizationId),orgTier:t.org.tier,checkpointId:t.checkpointId,takenAt:t.takenAt,records:we(t),objects:t.objects.length,files:s.length,bytes:s.reduce((l,p)=>l+p.bytes,0),cipher:"aes-256-gcm",kdf:"hkdf-sha256",salt:h.toString("hex"),noncePrefix:c.toString("hex"),keyCheck:v(i,h,fe,16).toString("hex"),chunkBytes:o},u=Buffer.from(`${JSON.stringify(N.parse(d))}
|
|
9
9
|
`),m={blockKey:v(i,h,he,32),prefix:c,headerHash:y("sha256").update(u).digest()},k=ve(oe(r),`.${ie(r)}.${process.pid}-${S(4).toString("hex")}.tmp`),O=y("sha256"),g=0,x=await T(k,"wx",K);try{try{let l=async p=>{O.update(p),g+=p.length,await ge(x,p)};await l(u),await se(ae.from(ze(s)),Ce({level:6}),async p=>{await je(p,o,m,l)}),await x.sync()}finally{await x.close()}if(await ee(r).catch(()=>{}))throw new E("EXPORT_EXISTS",`${r} appeared while the checkpoint was exported: name another file.`);await xe(k,r)}catch(l){throw await Ie(k,{force:!0}),l}return{header:d,bytes:g,sha256:O.digest("hex")}}async function ge(n,e){for(let t=0;t<e.length;){let{bytesWritten:r}=await n.write(e,t,e.length-t);t+=r}}function we(n){return n.objects.reduce((e,t)=>e+t.records,0)}async function*ze(n){for(let e of n){let{path:t,bytes:r,sha256:i}=e;if(yield Buffer.from(`${JSON.stringify({path:t,bytes:r,sha256:i})}
|
|
10
10
|
`,"utf8"),e.content!==void 0){yield e.content;continue}let o=y("sha256");for await(let a of ye(e.file??"",r))o.update(a),yield a;if(o.digest("hex")!==i)throw new E("EXPORT_CHANGED",`${t} of the checkpoint changed while it was exported: export it again.`)}yield Buffer.from(`${JSON.stringify({end:!0,files:n.length})}
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c}from"./chunk-
|
|
7
|
+
import{a,b,c}from"./chunk-WA7EYLAQ.mjs";import"./chunk-LKQ5RKIV.mjs";import"./chunk-XAMBCQPU.mjs";import"./chunk-IG2MTQRP.mjs";import"./chunk-WR4Q363I.mjs";import"./chunk-O2HDYYUV.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-E5AHXLS6.mjs";import"./chunk-PZPJKATS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{a as DX_PROJECT_FILE,b as scenarioProjectOf,c as writeRunTestFile};
|
|
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{f as ce}from"./chunk-
|
|
7
|
+
import{f as ce}from"./chunk-A527W53V.mjs";import{wc as de}from"./chunk-TTFDUKUS.mjs";import{b as u,e as f,i as ie,k as w,l as m,r as se,s as N,u as ae,v as D}from"./chunk-7EANH5PY.mjs";import{createHash as fe}from"node:crypto";import*as C from"node:fs/promises";import*as M from"node:path";import*as I from"node:fs/promises";import*as O from"node:path";import*as U from"node:fs";import*as b from"node:path";function Oe(t){let e=b.resolve(t);for(;;){if(U.existsSync(b.join(e,".git"))||U.existsSync(b.join(e,"pnpm-workspace.yaml")))return e;let r=b.dirname(e);if(r===e)throw new Error(`No repository root found above ${t}`);e=r}}function le(t){let e=b.resolve(t);return process.platform==="win32"?e.toLowerCase():e}function _(t){if(!/^[A-Za-z0-9_-]{1,128}$/.test(t))throw new Error(`Not an org id a file of the sas can be named after: "${t}"`);return t}var q=class extends Error{constructor(r,n){super(`Refusing output path inside the repository: ${r} (repo root: ${n}). Frozen-dataset exports, retained-ID lists and working manifests must live in a sas directory OUTSIDE the repo \u2014 versioning them would create a real\u2194anonymized correspondence table.`);this.resolvedPath=r;this.repoRoot=n;this.name="InsideRepoPathError"}resolvedPath;repoRoot},k=class{repoRoot;constructor(e){this.repoRoot=e?b.resolve(e):Oe(process.cwd())}isInsideRepo(e){let r=le(this.repoRoot),n=le(e);if(n===r)return!0;let i=b.relative(r,n);return i!==""&&!i.startsWith("..")&&!b.isAbsolute(i)}assertOutsideRepo(e){if(this.isInsideRepo(e))throw new q(b.resolve(e),this.repoRoot);return b.resolve(e)}};function ot(t){return t.map(({objectApiName:e,why:r,count:n})=>({objectApiName:e,count:n,note:ce(n,r)}))}var ue=/^\d+\.\d+\.\d+$/,Se=/^[0-9a-f]{12}$/,P=class extends Error{constructor(e){super(e),this.name="ManifestError"}};function it(t){let e=(t.now?.()??new Date).toISOString(),r={version:t.version,status:"frozen",frozenAt:e,source:t.source,saltFingerprint:t.saltFingerprint,rulesVersion:t.rulesVersion,volumetry:t.volumetry,controls:{nonReidentification:t.nonReidentification,dryRunLoad:null,author:t.author,date:e},...t.coverage?{coverage:t.coverage}:{}};return W(r),r}function W(t){if(!ue.test(t.version))throw new P(`version must be semver, got ${JSON.stringify(t.version)}`);if(t.status!=="frozen")throw new P(`status must be "frozen", got ${JSON.stringify(t.status)}`);if(!t.frozenAt)throw new P("frozenAt is required");if(!t.source?.orgId||!t.source.decisionDate)throw new P("source.orgId and source.decisionDate are required");if(!Se.test(t.saltFingerprint))throw new P("saltFingerprint must be 12 lowercase hex chars of the salt SHA-256");if(!ue.test(t.rulesVersion))throw new P(`rulesVersion must be semver, got ${JSON.stringify(t.rulesVersion)}`);if(typeof t.volumetry?.budgetMax!="number"||!t.volumetry.measured)throw new P("volumetry.budgetMax and volumetry.measured are required");if(!t.controls?.nonReidentification)throw new P("controls.nonReidentification is required");if(!t.controls.author||!t.controls.date)throw new P("controls.author and controls.date are required");let e=t.coverage;if(e!==void 0&&(typeof e.objects!="number"||typeof e.truncated!="boolean"||typeof e.maxNodes!="number"||!Array.isArray(e.unboundedObjects)||!Array.isArray(e.filesLeftOut)||e.leftToThePlatform!==void 0&&!Array.isArray(e.leftToThePlatform)||e.exclusionCosts!==void 0&&!Array.isArray(e.exclusionCosts)||e.requiredLeftEmpty!==void 0&&!Array.isArray(e.requiredLeftEmpty)||e.keptWithoutARule!==void 0&&!Array.isArray(e.keptWithoutARule)||e.encryptedNotKept!==void 0&&!Array.isArray(e.encryptedNotKept)))throw new P("coverage, when present, needs objects, truncated, maxNodes, unboundedObjects and filesLeftOut, and a list of what it left to the platform, of what its exclusions cost, of the required fields the rules leave empty, of the fields kept without a rule, or of the encrypted fields not kept, if it names any")}function pe(t){return W(t),`${JSON.stringify(t,null,2)}
|
|
8
8
|
`}function st(t){if(typeof t!="object"||t===null||Array.isArray(t))throw new P("Manifest must be a JSON object");let e=t;return W(e),e}var V="platform-records.json",G=class extends Error{constructor(e){let r=e.checks.filter(n=>!n.passed).map(n=>`${n.name} (${n.violations.length} violation(s))`).join(", ");super(`Refusing to write the frozen dataset: non-reidentification control FAILED [${r}]. A FAIL means nothing is written or versioned.`),this.name="ControlNotPassedError"}},ge=class{guard;constructor(e){this.guard=e??new k}async write(e,r,n,i){if(!i.passed)throw new G(i);let o=this.guard.assertOutsideRepo(e),s=this.guard.assertOutsideRepo(O.join(o,"data"));await I.mkdir(s,{recursive:!0});for(let l of await I.readdir(s))l.endsWith(".json")&&await I.rm(this.guard.assertOutsideRepo(O.join(s,l)));let a=[],d=async(l,p)=>{let g=this.guard.assertOutsideRepo(l);await I.writeFile(g,`${JSON.stringify(p)}
|
|
9
9
|
`,"utf8"),a.push(g)},c=this.guard.assertOutsideRepo(O.join(o,"manifest.json"));await I.writeFile(c,pe(n),"utf8"),a.push(c);for(let l of r.objects)await d(O.join(s,`${l.objectApiName}.json`),{objectApiName:l.objectApiName,records:l.records});return await d(O.join(o,"record-types.json"),r.recordTypes),await d(O.join(o,"personcontact-sidecar.json"),r.personContactSidecar),await d(O.join(o,V),{...r.standardPricebook?{standardPricebook:r.standardPricebook}:{}}),{dir:o,files:a}}};var K="manifest.json",Fe=["record-types.json","personcontact-sidecar.json",V],Z="data",Ee="sha256:";async function gt(t){let e=await H(M.join(t,K));if(e===void 0)throw new Error(`No frozen dataset at ${t}: it holds no ${K}.`);let r=[{name:K,content:ke(e)}];for(let i of Fe){let o=await H(M.join(t,i));o!==void 0&&r.push({name:i,content:o})}for(let i of await xe(M.join(t,Z))){let o=await H(M.join(t,Z,i));o!==void 0&&r.push({name:`${Z}/${i}`,content:o})}let n=fe("sha256");for(let{name:i,content:o}of r.sort((s,a)=>me(s.name,a.name)))n.update(`${i}\0${fe("sha256").update(o).digest("hex")}
|
|
10
10
|
`);return`${Ee}${n.digest("hex")}`}async function xe(t){let e;try{e=await C.readdir(t)}catch(r){if(r.code==="ENOENT")return[];throw r}return e.filter(r=>r.endsWith(".json"))}async function H(t){try{return await C.readFile(t)}catch(e){if(e.code==="ENOENT")return;throw e}}function ke(t){let e;try{e=JSON.parse(t.toString("utf8"))}catch{return t}if(Y(e)&&Y(e.controls)){let r={...e.controls};delete r.dryRunLoad,e={...e,controls:r}}return Buffer.from(X(e),"utf8")}function X(t){return Array.isArray(t)?`[${t.map(X).join(",")}]`:Y(t)?`{${Object.keys(t).sort(me).map(r=>`${JSON.stringify(r)}:${X(t[r])}`).join(",")}}`:JSON.stringify(t)??"null"}function Y(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function me(t,e){return t===e?0:t<e?-1:1}import*as h from"node:fs/promises";import*as z from"node:path";var yt=4*1024*1024,wt=64*1024*1024;var he=1e4,L=u().regex(/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/),S=u().min(1).max(40),bt=m({forgeId:u().min(1).max(200),targetOrgId:u().min(1).max(128),timestamp:S,duration:f().nonnegative(),status:ae(["success","partial","failure"]),cancelled:D(!0).optional(),writtenBetween:m({first:S,last:S}).optional(),retryOf:u().min(1).max(200).optional(),objects:w(m({objectApiName:u().regex(/^[A-Za-z][A-Za-z0-9_]*$/),ids:w(L)})),linked:f().int().nonnegative(),mayHaveBeenWritten:f().int().nonnegative().optional(),undo:m({removedAt:S,deleted:f().int().nonnegative(),alreadyGone:f().int().nonnegative(),kept:f().int().nonnegative(),refused:f().int().nonnegative(),notReached:f().int().nonnegative().optional(),notVisible:f().int().nonnegative().optional()}).optional(),removalStamps:N(L,S).optional(),removalSpans:w(m({first:S,last:S,userId:L})).optional(),removalLeft:w(L).optional(),sweep:m({sweptAt:S,deleted:f().int().nonnegative(),keptChanged:f().int().nonnegative(),refused:f().int().nonnegative()}).optional(),inJournal:m({journalId:u().min(1).max(200),part:f().int().nonnegative(),left:w(m({objectApiName:u().regex(/^[A-Za-z][A-Za-z0-9_]*$/),count:f().int().nonnegative()}))}).optional()}),Rt=m({version:D(1),plans:w(ie())}),Pt=m({version:D(1),runs:w(m({forgeId:u().min(1).max(300),ids:w(L),late:w(L).optional()}))});var J="referenceid-mapping.json",Ne=/^referenceid-mapping\.([A-Za-z0-9_-]{1,128})\.json$/,Me=/^referenceid-mapping\.([A-Za-z0-9_-]{1,128})\.load-\d{1,16}\.ndjson$/,T=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,Q=new Set;function De(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var _e=m({at:u().min(1).max(40),object:u().regex(/^[A-Za-z][A-Za-z0-9_]{0,79}$/),created:w(se([u().min(1).max(400),u().regex(T)])).max(1e4)}),Ce=m({journal:m({startedAt:u().min(1).max(40),pid:f().int().positive(),runUserId:u().regex(T).optional()})});function Be(t){let e,r={},n=new Map,i;for(let o of t.split(`
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r}from"./chunk-NZC67CGR.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.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};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{
|
|
7
|
+
import{Bd as c}from"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";var y=[{type:"seed",label:"Seed Data",description:"Seed an org with a template saved on the Seed page or shipped with SandForge, never a production org; its records are taken back from Seed\u2019s Recent runs",category:"data",icon:"database",configSchema:{orgId:{type:"string"},templateId:{type:"string"}}},{type:"sync",label:"Sync Data",description:"Run a Sync configuration saved on the Sync page; a target Production Guard asks about, a production org or a sandbox marked Staging, needs an Approval step before it",category:"data",icon:"sync",configSchema:{configId:{type:"string"}}},{type:"backup",label:"Backup",description:"Take a DataOps snapshot of the listed objects into local storage",category:"data",icon:"archive",configSchema:{orgId:{type:"string"},objects:{type:"array"}}},{type:"restore",label:"Restore",description:"Restore data from a previous backup snapshot",category:"data",icon:"history",configSchema:{backupId:{type:"string"}}},{type:"anonymize",label:"Anonymize",description:"Mask an org with a DataOps template, after a snapshot of the values it writes over, never a production org",category:"data",icon:"shield",configSchema:{orgId:{type:"string"},templateId:{type:"string"},object:{type:"string",optional:!0},where:{type:"string",optional:!0},acceptAutomation:{type:"boolean",default:!1},acceptEmails:{type:"boolean",default:!1},muteAutomation:{type:"boolean",default:!1}}},{type:"delete",label:"Delete",description:"Delete records matching specified criteria",category:"data",icon:"trash",configSchema:{objectName:{type:"string"},where:{type:"string"}}},{type:"checkpoint",label:"Checkpoint",description:"Take a checkpoint of a sandbox, a scratch org or a Developer Edition org, kept on this machine",category:"data",icon:"bookmark",configSchema:{orgId:{type:"string"},mode:{type:"string",default:"everything"},objects:{type:"array",optional:!0},excluded:{type:"array",optional:!0},name:{type:"string",optional:!0},keepDays:{type:"number",default:c},maxTotal:{type:"number",optional:!0},ignoredFields:{type:"array",optional:!0}}},{type:"rewind",label:"Rewind",description:"Put an org back to a checkpoint kept on this machine, once confirmed by typing the org\u2019s alias, at most maxRecords records",category:"data",icon:"history",configSchema:{orgId:{type:"string"},checkpointId:{type:"string"},objects:{type:"array",optional:!0},acceptAutomation:{type:"boolean",default:!1},acceptEmails:{type:"boolean",default:!1},muteAutomation:{type:"boolean",default:!1},acceptNoUndo:{type:"boolean",default:!1},acceptRecreate:{type:"boolean",default:!1},acceptOutside:{type:"boolean",default:!1},acceptUnseen:{type:"boolean",default:!1},maxRecords:{type:"number",required:!0},refuseWhenActive:{type:"boolean",default:!0}}},{type:"compare",label:"Compare Orgs",description:"Compare the metadata of two orgs, as the Compare page does",category:"quality",icon:"git-compare",configSchema:{sourceOrgId:{type:"string"},targetOrgId:{type:"string"},types:{type:"array"}}},{type:"precheck",label:"Pre-check",description:"Read an org\u2019s API usage, storage, error logs or failed jobs as the Monitor does; the run stops on a critical reading",category:"quality",icon:"check-circle",configSchema:{orgId:{type:"string"},checks:{type:"array"}}},{type:"condition",label:"Condition",description:"Branch pipeline execution based on conditions",category:"control",icon:"git-branch",configSchema:{field:{type:"string"},operator:{type:"string"},value:{type:"string"}}},{type:"delay",label:"Delay",description:"Wait for a specified duration before continuing",category:"control",icon:"clock",configSchema:{durationMs:{type:"number"}}},{type:"approval",label:"Approval",description:"Pauses the run until someone approves it in VS Code; a rejection, or no answer in time, stops it",category:"control",icon:"user-check",configSchema:{message:{type:"string"},timeoutMinutes:{type:"number"}}},{type:"notification",label:"Notification",description:"Shows its message as a VS Code notification",category:"notification",icon:"bell",configSchema:{message:{type:"string"}}}],p=class{registry;constructor(){this.registry=new Map(y.map(e=>[e.type,e]))}getStepTypes(){return[...this.registry.values()]}getStepType(e){return this.registry.get(e)}getDefaultConfig(e){let r=this.registry.get(e);if(!r)return{};let o={};for(let[t,a]of Object.entries(r.configSchema)){let n=a;if(!(n.optional===!0||n.required===!0)){if("default"in n){o[t]=n.default;continue}switch(n.type){case"string":o[t]="";break;case"number":o[t]=0;break;case"array":o[t]=[];break;case"boolean":o[t]=!1;break;default:o[t]=null}}}return o}validateStepConfig(e,r){let o=this.registry.get(e);if(!o)return[`Unknown step type: ${e}`];let t=[];for(let[a,n]of Object.entries(o.configSchema)){let l=n,i=r[a],s=l.type;i!=null&&(s==="array"&&!Array.isArray(i)?t.push(`Field "${a}" must be an array`):s==="string"&&typeof i!="string"?t.push(`Field "${a}" must be a string`):s==="number"&&typeof i!="number"?t.push(`Field "${a}" must be a number`):s==="boolean"&&typeof i!="boolean"&&t.push(`Field "${a}" must be a boolean`))}return t}getStepCategories(){let e=new Set;for(let r of this.registry.values())e.add(r.category);return[...e]}};export{p as StepLibrary};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e,f,g,h}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e,f,g,h}from"./chunk-SOGQW4IG.mjs";import"./chunk-WR4Q363I.mjs";import"./chunk-O2HDYYUV.mjs";import"./chunk-M3ROUWDX.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{d as ARTICLE_OBJECT,b as CASE_STATUS_BY_LABEL_SOQL,a as CASE_STATUS_SOQL,g as prepareScenario,c as readScenarioCaseStatus,f as scenarioCasePicklists,e as scenarioKnowledge,h as toolingQueryAll};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{J as H}from"./chunk-6QSM2WIH.mjs";import{b as k,c as ie,d as $}from"./chunk-OTWRDD6L.mjs";import{i as oe}from"./chunk-INIT2UKJ.mjs";import{h as Y}from"./chunk-TZE3Y7IQ.mjs";import{b as S}from"./chunk-CA5NAXSU.mjs";var ye=5,pe=100;function y(t){return t.slice(0,15)}function L(t){return t==null||t===""}var ae=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;function he(t,n){if(L(t)||L(n))return L(t)&&L(n);if(typeof t=="number"||typeof n=="number")return Number(t)===Number(n);if(typeof t=="string"&&typeof n=="string"){if(t===n)return!0;if(ae.test(t)&&ae.test(n)){let a=Date.parse(t);return Number.isFinite(a)&&a===Date.parse(n)}return!1}return JSON.stringify(t)===JSON.stringify(n)}function me(t){let n;return()=>(n??=(async()=>{try{let a=await t.userId?.();return typeof a=="string"&&a!==""?y(a):void 0}catch{return}})(),n)}async function de(t){let n=Date.now();try{let a=Date.parse(await t.serverTime());return Number.isFinite(a)?a-(n+Date.now())/2:0}catch{return 0}}async function Ie(t,n){let a=Date.parse(n??"");return Number.isFinite(a)?a+await de(t)+H:Number.NEGATIVE_INFINITY}var be=1e3;function Re(t){let n=Date.parse(t);return Number.isFinite(n)?n-be:Number.NEGATIVE_INFINITY}function ke(t,n){let a=Object.hasOwn(t,n)?t[n]:[];return new Map(a.filter(c=>c.toLowerCase()!=="id").map(c=>[c.toLowerCase(),c]))}var Ae={INACTIVE_OWNER_OR_USER:"OwnerId"};function Oe(t,n){let a=new Set;for(let s of t.errors??[]){if(typeof s=="string")continue;if(Array.isArray(s.fields))for(let p of s.fields)typeof p=="string"&&a.add(p);let f=s.statusCode!==void 0?Ae[s.statusCode]:void 0;f!==void 0&&(!Array.isArray(s.fields)||s.fields.length===0)&&a.add(f)}let c=new Map(Object.keys(n).map(s=>[s.toLowerCase(),s]));return[...a].flatMap(s=>{let f=c.get(s.toLowerCase());return f!==void 0&&f!=="Id"?[f]:[]})}function ve(t,n){let a=Array.isArray(t)?t:[t];return Array.from({length:n},(c,s)=>a[s]??{success:!1})}function J(t){let n=t.errors?.[0];if(n===void 0)return{words:"The org gave no reason."};if(typeof n=="string")return{words:n};let a=n.statusCode,c=n.message??"";return{...a?{code:a}:{},words:a&&c?`${a}: ${c}`:a||c}}function P(t,{fields:n,why:a}){return`${n.map(c=>`${t}.${c}`).join(", ")}: the value from before is no longer taken (${a}) \u2014 left as the run wrote it`}async function je(t,n,a){let c=new Set;try{for(let s of $(a)){let f=await t.query(`SELECT Id FROM ${n} WHERE Id IN (${s})`);for(let p of f.records)typeof p.Id=="string"&&c.add(y(p.Id))}}catch(s){return{unread:S(s)}}return{live:c}}var Q=class{result;said=new Set;constructor(n,a){this.result={objectApiName:n,planned:a,restored:0,keptChanged:0,alreadyGone:0,refused:0,notKept:0,reasons:[]}}without(){this.result.restoredWithout=(this.result.restoredWithout??0)+1}reason(n){this.said.has(n)||this.said.size>=ye||(this.said.add(n),this.result.reasons.push(n))}};async function De(t){let{org:n,plan:a}=t,c=[],s=[],f={},p=!1,I=!1;if(a.length===0)return{objects:c,left:s,wrote:p,cancelled:I,stamps:f};let M=t.changedAfter!==void 0?Re(t.changedAfter):await Ie(n,t.lastWriteAt),R=new Map(Object.entries(t.stamps??{}).map(([h,_])=>[y(h),Date.parse(_)])),F=t.ownWriters&&t.ownWriters.length>0?new Set(t.ownWriters.map(y)):void 0,W=t.stampsFor,ce=me(n);for(let{objectApiName:h,backup:_,ids:C}of a){let u=new Q(h,C.length);c.push(u.result);let B=t.unkept?.find(e=>e.objectApiName===h);if(B&&B.fields.length>0&&u.reason(`${B.fields.map(e=>`${h}.${e}`).join(", ")}: not kept, encrypted \u2014 the run's user cannot view encrypted data, and read their values from before masked; left as the run wrote them`),I||t.signal?.aborted){I=!0,u.result.notReached=C.length,s.push(...C);continue}let x=Y(h),m=new Map(C.map(e=>[y(e),e])),U=t.fields?ke(t.fields,h):void 0,O=new Map,G=new Set;try{let e=await t.backups.batches(_,h,k);for await(let r of e??[])for(let o of r){if(typeof o.Id!="string"||!m.has(y(o.Id)))continue;let i=O.get(y(o.Id))??{};for(let[l,d]of Object.entries(o)){if(l==="Id")continue;let g=U?U.get(l.toLowerCase()):l;g!==void 0&&!(g in i)&&(i[g]=d)}if(U&&Object.keys(i).length===0){G.add(y(o.Id));continue}O.set(y(o.Id),i)}}catch(e){u.reason(`The values from before the run could not be read: ${S(e)}`),O.clear(),G.clear()}let X=[...G].filter(e=>!O.has(e)).length;X>0&&u.reason(`${X} ${h} record(s) hold no value of a field that may be written back now: left as they are`);for(let e of[...m.keys()])O.has(e)||(u.result.notKept++,m.delete(e));if(m.size===0)continue;let Z=new Set;for(let e of O.values())for(let r of Object.keys(e))Z.add(Y(r));let ee=["Id","LastModifiedDate",...F?["LastModifiedById"]:[],...Z],ue=ee.length>pe?k/4:k,q=new Map,fe=async e=>{if(t.signal?.aborted)throw new T;return(await n.query(e)).records};try{for(let e of $([...m.values()],ue)){let r=await oe(`SELECT ${ee.join(", ")} FROM ${x} WHERE Id IN (${e})`,fe,{stamp:"LastModifiedDate"});for(let o of r)typeof o.Id=="string"&&q.set(y(o.Id),o)}}catch(e){if(e instanceof T){I=!0,u.result.notReached=m.size,s.push(...m.values());continue}u.result.refused+=m.size,u.reason(S(e)),s.push(...m.values());continue}let D=[],te=new Set,le=W?Date.now()+await de(n)-H:0;for(let[e,r]of m){let o=q.get(e);if(!o){u.result.alreadyGone++,t.counted?.(r,"alreadyGone");continue}let i=Date.parse(String(o.LastModifiedDate??"")),l=o.LastModifiedById,d=i<=M||i<=(R.get(e)??Number.NaN)||F!==void 0&&typeof l=="string"&&F.has(y(l));if(!d&&!t.includeChanged){u.result.keptChanged++,s.push(r);continue}let g=O.get(e)??{},w={Id:o.Id};for(let[b,A]of Object.entries(g))he(A,o[b])||(w[b]=L(A)?null:A);if(Object.keys(w).length===1){u.result.restored++,t.counted?.(r,"restored"),d&&W?.(r)&&typeof o.LastModifiedDate=="string"&&(f[o.Id]=o.LastModifiedDate);continue}D.push(w),d&&W?.(r)&&te.add(r)}let j=[],v=[],E=(e,r)=>{u.result.refused++,u.reason(r),s.push(m.get(y(e.Id))??e.Id)},z=e=>{u.result.restored++,t.counted?.(m.get(y(e.Id))??e.Id,"restored")},ge=e=>{u.result.alreadyGone++,t.counted?.(m.get(y(e.Id))??e.Id,"alreadyGone")},ne=e=>{I=!0,u.result.notReached=(u.result.notReached??0)+e.length,s.push(...e.map(r=>m.get(y(r.Id))??r.Id))},re=(e,r,o,i)=>{let l=Object.keys(e).filter(w=>w!=="Id"&&!r.includes(w));if(l.length>0){let w={Id:e.Id};for(let b of l)w[b]=e[b];j.push({record:w,leftOut:o});return}if(o.length===0){z(e);return}let[d,...g]=o;i?(u.without(),u.reason(P(h,d))):E(e,P(h,d));for(let w of g)u.reason(P(h,w))},K=async e=>{try{return p=!0,ve(await n.update(h,[...e]),e.length)}catch(r){let o=S(r);return e.map(()=>({success:!1,errors:[o]}))}},we=async e=>{let r=t.keep;if(!r)return!0;let o=e.map(i=>{let l=q.get(y(i.Id))??{},d={Id:i.Id};for(let g of Object.keys(i))g!=="Id"&&(d[g]=l[g]??null);return d});try{return await r(h,o),!0}catch(i){let l=`What these ${e.length} ${h} record(s) hold now could not be kept before they were written (${S(i)}), so none of them was written: nothing is written over that cannot be put back.`;for(let d of e)E(d,l);return!1}};for(let e=0;e<D.length;e+=k){let r=D.slice(e,e+k);if(t.signal?.aborted){I=!0;let i=D.slice(e);u.result.notReached=(u.result.notReached??0)+i.length,s.push(...i.map(l=>m.get(y(l.Id))??l.Id));break}if(!await we(r))continue;(await K(r)).forEach((i,l)=>{let d=r[l];if(i.success===!0){z(d);return}let g=J(i),w=Oe(i,d);if(g.code==="ENTITY_IS_DELETED"&&w.length===0){v.push({record:d,why:g.words});return}let b=Object.keys(d).filter(A=>A!=="Id"&&!w.includes(A));if(w.length>0&&b.length>0){let A={Id:d.Id};for(let se of b)A[se]=d[se];j.push({record:A,leftOut:[{fields:w,why:g.words}]});return}E(d,g.words)})}let N=[];if(v.length>0&&t.signal?.aborted)ne(v.map(({record:e})=>e));else if(v.length>0){let e=await je(n,x,v.map(({record:r})=>r.Id));e.unread!==void 0&&u.reason(`Whether ${v.length} ${h} record(s) refused as deleted are still in the org could not be read (${e.unread}): left to be given back again`);for(let{record:r,why:o}of v){if(e.unread!==void 0){E(r,o);continue}if(!e.live.has(y(r.Id))){ge(r);continue}let i=Object.keys(r).filter(l=>l!=="Id"&&ie(r[l]));i.length===0?E(r,o):i.length===1?re(r,i,[{fields:i,why:o}],!1):N.push({record:r,lookups:i,given:[],refusedAlone:[]})}}let V=N.length>0;for(let e=0;V&&N.some(({lookups:r})=>r.length>e);e++){let r=N.filter(({lookups:o})=>o.length>e);for(let o=0;o<r.length;o+=k){if(t.signal?.aborted){ne(N.map(({record:d})=>d)),V=!1;break}let i=r.slice(o,o+k);(await K(i.map(({record:d,lookups:g})=>({Id:d.Id,[g[e]]:d[g[e]]})))).forEach((d,g)=>{let w=i[g],b=w.lookups[e];d.success===!0?w.given.push(b):w.refusedAlone.push({field:b,why:J(d).words})})}}for(let e of V?N:[]){let r=new Map;for(let{field:o,why:i}of e.refusedAlone)r.set(i,[...r.get(i)??[],o]);re(e.record,e.lookups,[...r].map(([o,i])=>({fields:i,why:o})),e.given.length>0)}for(let e=0;e<j.length;e+=k){let r=j.slice(e,e+k);if(t.signal?.aborted){I=!0,u.result.notReached=(u.result.notReached??0)+j.length-e,s.push(...j.slice(e).map(({record:i})=>m.get(y(i.Id))??i.Id));break}(await K(r.map(({record:i})=>i))).forEach((i,l)=>{let{record:d,leftOut:g}=r[l];if(i.success===!0){if(g.length===0){z(d);return}u.without();for(let w of g)u.reason(P(h,w));return}E(d,J(i).words)})}Object.assign(f,await Ee(n,x,[...te],le,ce))}return{objects:c,left:s,wrote:p,cancelled:I,stamps:f}}async function Ee(t,n,a,c,s){let f={};if(a.length===0)return f;let p=await s();if(p===void 0)return f;for(let I of $(a)){let M;try{M=(await t.query(`SELECT Id, LastModifiedDate, LastModifiedById FROM ${n} WHERE Id IN (${I})`)).records}catch{continue}for(let R of M)typeof R.Id=="string"&&typeof R.LastModifiedDate=="string"&&typeof R.LastModifiedById=="string"&&y(R.LastModifiedById)===p&&Date.parse(R.LastModifiedDate)>=c&&(f[R.Id]=R.LastModifiedDate)}return f}var T=class extends Error{};function $e(t,n,a=[]){let c=t.map(s=>({...s}));for(let s of a){if(s.undeleted+s.refused===0)continue;let f=c.find(p=>p.objectApiName===s.objectApiName);f?(f.created+=s.undeleted,f.failed+=s.refused):c.push({objectApiName:s.objectApiName,created:s.undeleted,updated:0,deleted:0,failed:s.refused})}for(let s of n){let f=s.restored+(s.restoredWithout??0);if(f+s.refused===0)continue;let p=c.find(I=>I.objectApiName===s.objectApiName);p?(p.updated+=f,p.failed+=s.refused):c.push({objectApiName:s.objectApiName,created:0,updated:f,deleted:0,failed:s.refused})}return c}export{he as a,me as b,de as c,Ie as d,De as e,Ee as f,$e as g};
|
|
7
|
+
import{J as H}from"./chunk-JPUR2CFX.mjs";import{b as k,c as ie,d as $}from"./chunk-GSKCGQIP.mjs";import{i as oe}from"./chunk-INIT2UKJ.mjs";import{h as Y}from"./chunk-TZE3Y7IQ.mjs";import{b as S}from"./chunk-CA5NAXSU.mjs";var ye=5,pe=100;function y(t){return t.slice(0,15)}function L(t){return t==null||t===""}var ae=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;function he(t,n){if(L(t)||L(n))return L(t)&&L(n);if(typeof t=="number"||typeof n=="number")return Number(t)===Number(n);if(typeof t=="string"&&typeof n=="string"){if(t===n)return!0;if(ae.test(t)&&ae.test(n)){let a=Date.parse(t);return Number.isFinite(a)&&a===Date.parse(n)}return!1}return JSON.stringify(t)===JSON.stringify(n)}function me(t){let n;return()=>(n??=(async()=>{try{let a=await t.userId?.();return typeof a=="string"&&a!==""?y(a):void 0}catch{return}})(),n)}async function de(t){let n=Date.now();try{let a=Date.parse(await t.serverTime());return Number.isFinite(a)?a-(n+Date.now())/2:0}catch{return 0}}async function Ie(t,n){let a=Date.parse(n??"");return Number.isFinite(a)?a+await de(t)+H:Number.NEGATIVE_INFINITY}var be=1e3;function Re(t){let n=Date.parse(t);return Number.isFinite(n)?n-be:Number.NEGATIVE_INFINITY}function ke(t,n){let a=Object.hasOwn(t,n)?t[n]:[];return new Map(a.filter(c=>c.toLowerCase()!=="id").map(c=>[c.toLowerCase(),c]))}var Ae={INACTIVE_OWNER_OR_USER:"OwnerId"};function Oe(t,n){let a=new Set;for(let s of t.errors??[]){if(typeof s=="string")continue;if(Array.isArray(s.fields))for(let p of s.fields)typeof p=="string"&&a.add(p);let f=s.statusCode!==void 0?Ae[s.statusCode]:void 0;f!==void 0&&(!Array.isArray(s.fields)||s.fields.length===0)&&a.add(f)}let c=new Map(Object.keys(n).map(s=>[s.toLowerCase(),s]));return[...a].flatMap(s=>{let f=c.get(s.toLowerCase());return f!==void 0&&f!=="Id"?[f]:[]})}function ve(t,n){let a=Array.isArray(t)?t:[t];return Array.from({length:n},(c,s)=>a[s]??{success:!1})}function J(t){let n=t.errors?.[0];if(n===void 0)return{words:"The org gave no reason."};if(typeof n=="string")return{words:n};let a=n.statusCode,c=n.message??"";return{...a?{code:a}:{},words:a&&c?`${a}: ${c}`:a||c}}function P(t,{fields:n,why:a}){return`${n.map(c=>`${t}.${c}`).join(", ")}: the value from before is no longer taken (${a}) \u2014 left as the run wrote it`}async function je(t,n,a){let c=new Set;try{for(let s of $(a)){let f=await t.query(`SELECT Id FROM ${n} WHERE Id IN (${s})`);for(let p of f.records)typeof p.Id=="string"&&c.add(y(p.Id))}}catch(s){return{unread:S(s)}}return{live:c}}var Q=class{result;said=new Set;constructor(n,a){this.result={objectApiName:n,planned:a,restored:0,keptChanged:0,alreadyGone:0,refused:0,notKept:0,reasons:[]}}without(){this.result.restoredWithout=(this.result.restoredWithout??0)+1}reason(n){this.said.has(n)||this.said.size>=ye||(this.said.add(n),this.result.reasons.push(n))}};async function De(t){let{org:n,plan:a}=t,c=[],s=[],f={},p=!1,I=!1;if(a.length===0)return{objects:c,left:s,wrote:p,cancelled:I,stamps:f};let M=t.changedAfter!==void 0?Re(t.changedAfter):await Ie(n,t.lastWriteAt),R=new Map(Object.entries(t.stamps??{}).map(([h,_])=>[y(h),Date.parse(_)])),F=t.ownWriters&&t.ownWriters.length>0?new Set(t.ownWriters.map(y)):void 0,W=t.stampsFor,ce=me(n);for(let{objectApiName:h,backup:_,ids:C}of a){let u=new Q(h,C.length);c.push(u.result);let B=t.unkept?.find(e=>e.objectApiName===h);if(B&&B.fields.length>0&&u.reason(`${B.fields.map(e=>`${h}.${e}`).join(", ")}: not kept, encrypted \u2014 the run's user cannot view encrypted data, and read their values from before masked; left as the run wrote them`),I||t.signal?.aborted){I=!0,u.result.notReached=C.length,s.push(...C);continue}let x=Y(h),m=new Map(C.map(e=>[y(e),e])),U=t.fields?ke(t.fields,h):void 0,O=new Map,G=new Set;try{let e=await t.backups.batches(_,h,k);for await(let r of e??[])for(let o of r){if(typeof o.Id!="string"||!m.has(y(o.Id)))continue;let i=O.get(y(o.Id))??{};for(let[l,d]of Object.entries(o)){if(l==="Id")continue;let g=U?U.get(l.toLowerCase()):l;g!==void 0&&!(g in i)&&(i[g]=d)}if(U&&Object.keys(i).length===0){G.add(y(o.Id));continue}O.set(y(o.Id),i)}}catch(e){u.reason(`The values from before the run could not be read: ${S(e)}`),O.clear(),G.clear()}let X=[...G].filter(e=>!O.has(e)).length;X>0&&u.reason(`${X} ${h} record(s) hold no value of a field that may be written back now: left as they are`);for(let e of[...m.keys()])O.has(e)||(u.result.notKept++,m.delete(e));if(m.size===0)continue;let Z=new Set;for(let e of O.values())for(let r of Object.keys(e))Z.add(Y(r));let ee=["Id","LastModifiedDate",...F?["LastModifiedById"]:[],...Z],ue=ee.length>pe?k/4:k,q=new Map,fe=async e=>{if(t.signal?.aborted)throw new T;return(await n.query(e)).records};try{for(let e of $([...m.values()],ue)){let r=await oe(`SELECT ${ee.join(", ")} FROM ${x} WHERE Id IN (${e})`,fe,{stamp:"LastModifiedDate"});for(let o of r)typeof o.Id=="string"&&q.set(y(o.Id),o)}}catch(e){if(e instanceof T){I=!0,u.result.notReached=m.size,s.push(...m.values());continue}u.result.refused+=m.size,u.reason(S(e)),s.push(...m.values());continue}let D=[],te=new Set,le=W?Date.now()+await de(n)-H:0;for(let[e,r]of m){let o=q.get(e);if(!o){u.result.alreadyGone++,t.counted?.(r,"alreadyGone");continue}let i=Date.parse(String(o.LastModifiedDate??"")),l=o.LastModifiedById,d=i<=M||i<=(R.get(e)??Number.NaN)||F!==void 0&&typeof l=="string"&&F.has(y(l));if(!d&&!t.includeChanged){u.result.keptChanged++,s.push(r);continue}let g=O.get(e)??{},w={Id:o.Id};for(let[b,A]of Object.entries(g))he(A,o[b])||(w[b]=L(A)?null:A);if(Object.keys(w).length===1){u.result.restored++,t.counted?.(r,"restored"),d&&W?.(r)&&typeof o.LastModifiedDate=="string"&&(f[o.Id]=o.LastModifiedDate);continue}D.push(w),d&&W?.(r)&&te.add(r)}let j=[],v=[],E=(e,r)=>{u.result.refused++,u.reason(r),s.push(m.get(y(e.Id))??e.Id)},z=e=>{u.result.restored++,t.counted?.(m.get(y(e.Id))??e.Id,"restored")},ge=e=>{u.result.alreadyGone++,t.counted?.(m.get(y(e.Id))??e.Id,"alreadyGone")},ne=e=>{I=!0,u.result.notReached=(u.result.notReached??0)+e.length,s.push(...e.map(r=>m.get(y(r.Id))??r.Id))},re=(e,r,o,i)=>{let l=Object.keys(e).filter(w=>w!=="Id"&&!r.includes(w));if(l.length>0){let w={Id:e.Id};for(let b of l)w[b]=e[b];j.push({record:w,leftOut:o});return}if(o.length===0){z(e);return}let[d,...g]=o;i?(u.without(),u.reason(P(h,d))):E(e,P(h,d));for(let w of g)u.reason(P(h,w))},K=async e=>{try{return p=!0,ve(await n.update(h,[...e]),e.length)}catch(r){let o=S(r);return e.map(()=>({success:!1,errors:[o]}))}},we=async e=>{let r=t.keep;if(!r)return!0;let o=e.map(i=>{let l=q.get(y(i.Id))??{},d={Id:i.Id};for(let g of Object.keys(i))g!=="Id"&&(d[g]=l[g]??null);return d});try{return await r(h,o),!0}catch(i){let l=`What these ${e.length} ${h} record(s) hold now could not be kept before they were written (${S(i)}), so none of them was written: nothing is written over that cannot be put back.`;for(let d of e)E(d,l);return!1}};for(let e=0;e<D.length;e+=k){let r=D.slice(e,e+k);if(t.signal?.aborted){I=!0;let i=D.slice(e);u.result.notReached=(u.result.notReached??0)+i.length,s.push(...i.map(l=>m.get(y(l.Id))??l.Id));break}if(!await we(r))continue;(await K(r)).forEach((i,l)=>{let d=r[l];if(i.success===!0){z(d);return}let g=J(i),w=Oe(i,d);if(g.code==="ENTITY_IS_DELETED"&&w.length===0){v.push({record:d,why:g.words});return}let b=Object.keys(d).filter(A=>A!=="Id"&&!w.includes(A));if(w.length>0&&b.length>0){let A={Id:d.Id};for(let se of b)A[se]=d[se];j.push({record:A,leftOut:[{fields:w,why:g.words}]});return}E(d,g.words)})}let N=[];if(v.length>0&&t.signal?.aborted)ne(v.map(({record:e})=>e));else if(v.length>0){let e=await je(n,x,v.map(({record:r})=>r.Id));e.unread!==void 0&&u.reason(`Whether ${v.length} ${h} record(s) refused as deleted are still in the org could not be read (${e.unread}): left to be given back again`);for(let{record:r,why:o}of v){if(e.unread!==void 0){E(r,o);continue}if(!e.live.has(y(r.Id))){ge(r);continue}let i=Object.keys(r).filter(l=>l!=="Id"&&ie(r[l]));i.length===0?E(r,o):i.length===1?re(r,i,[{fields:i,why:o}],!1):N.push({record:r,lookups:i,given:[],refusedAlone:[]})}}let V=N.length>0;for(let e=0;V&&N.some(({lookups:r})=>r.length>e);e++){let r=N.filter(({lookups:o})=>o.length>e);for(let o=0;o<r.length;o+=k){if(t.signal?.aborted){ne(N.map(({record:d})=>d)),V=!1;break}let i=r.slice(o,o+k);(await K(i.map(({record:d,lookups:g})=>({Id:d.Id,[g[e]]:d[g[e]]})))).forEach((d,g)=>{let w=i[g],b=w.lookups[e];d.success===!0?w.given.push(b):w.refusedAlone.push({field:b,why:J(d).words})})}}for(let e of V?N:[]){let r=new Map;for(let{field:o,why:i}of e.refusedAlone)r.set(i,[...r.get(i)??[],o]);re(e.record,e.lookups,[...r].map(([o,i])=>({fields:i,why:o})),e.given.length>0)}for(let e=0;e<j.length;e+=k){let r=j.slice(e,e+k);if(t.signal?.aborted){I=!0,u.result.notReached=(u.result.notReached??0)+j.length-e,s.push(...j.slice(e).map(({record:i})=>m.get(y(i.Id))??i.Id));break}(await K(r.map(({record:i})=>i))).forEach((i,l)=>{let{record:d,leftOut:g}=r[l];if(i.success===!0){if(g.length===0){z(d);return}u.without();for(let w of g)u.reason(P(h,w));return}E(d,J(i).words)})}Object.assign(f,await Ee(n,x,[...te],le,ce))}return{objects:c,left:s,wrote:p,cancelled:I,stamps:f}}async function Ee(t,n,a,c,s){let f={};if(a.length===0)return f;let p=await s();if(p===void 0)return f;for(let I of $(a)){let M;try{M=(await t.query(`SELECT Id, LastModifiedDate, LastModifiedById FROM ${n} WHERE Id IN (${I})`)).records}catch{continue}for(let R of M)typeof R.Id=="string"&&typeof R.LastModifiedDate=="string"&&typeof R.LastModifiedById=="string"&&y(R.LastModifiedById)===p&&Date.parse(R.LastModifiedDate)>=c&&(f[R.Id]=R.LastModifiedDate)}return f}var T=class extends Error{};function $e(t,n,a=[]){let c=t.map(s=>({...s}));for(let s of a){if(s.undeleted+s.refused===0)continue;let f=c.find(p=>p.objectApiName===s.objectApiName);f?(f.created+=s.undeleted,f.failed+=s.refused):c.push({objectApiName:s.objectApiName,created:s.undeleted,updated:0,deleted:0,failed:s.refused})}for(let s of n){let f=s.restored+(s.restoredWithout??0);if(f+s.refused===0)continue;let p=c.find(I=>I.objectApiName===s.objectApiName);p?(p.updated+=f,p.failed+=s.refused):c.push({objectApiName:s.objectApiName,created:0,updated:f,deleted:0,failed:s.refused})}return c}export{he as a,me as b,de as c,Ie as d,De as e,Ee as f,$e as g};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as y,b as g}from"./chunk-
|
|
7
|
+
import{a as y,b as g}from"./chunk-WR4Q363I.mjs";import{a as S,b as f,c as p}from"./chunk-M3ROUWDX.mjs";import{b as u}from"./chunk-CA5NAXSU.mjs";import{ja as d}from"./chunk-TTFDUKUS.mjs";var h="SELECT ApiName, MasterLabel, IsClosed, IsDefault, SortOrder FROM CaseStatus ORDER BY SortOrder",w="SELECT MasterLabel, IsClosed, IsDefault, SortOrder FROM CaseStatus ORDER BY SortOrder",A="Closed";async function k(a){let e;try{e=await a(h)}catch{try{e=await a(w)}catch(t){return m(`the org would not read its case statuses: ${u(t)}`)}}let r=e.flatMap(t=>{let n=b(t.ApiName)??b(t.MasterLabel);return n===void 0?[]:[{value:n,closed:t.IsClosed===!0,isDefault:t.IsDefault===!0}]}),o=r.filter(t=>!t.closed),i=r.filter(t=>t.closed);return o.length===0||i.length===0?m(o.length===0?"the org has no case status that leaves a case open":"the org has no case status that closes a case"):{open:(o.find(t=>t.isDefault)??o[0]).value,closed:(i.find(t=>t.value===A)??i[0]).value,from:"org"}}function m(a){return{...d.caseStatus,from:"default",reason:a}}function b(a){return typeof a=="string"&&a.trim()!==""?a:void 0}var c=S;async function E(a,e){let r;try{r=await a(c)}catch{r={access:"createable"}}if(r.access==="absent")return{available:!1,reason:r.reason??`the org has no ${c}`};if(r.access==="readOnly")return{available:!1,reason:r.reason??`the user this seed runs as may read ${c} and not create it`};try{return{available:!0,bodyFields:f(await e(c))}}catch{return{available:!0,bodyFields:[]}}}var P=["Status","Origin","Priority","Type"];async function T(a){let e;try{e=(await a("Case")).fields}catch{return}let r={};for(let o of P){let t=(e.find(n=>n.name===o)?.picklistValues??[]).filter(n=>n.active!==!1).map(n=>n.value);t.length>0&&(r[o]=t)}return r}function v(a,e){let r=e.knowledge.available?e.knowledge.bodyFields:[],o=r.map(s=>s.name),i=e.articleBodyField===void 0?r[0]:r.find(s=>s.name===e.articleBodyField);if(e.articleBodyField!==void 0&&i===void 0)return{issues:[`options.articleBodyField: ${e.articleBodyField} is not a field of ${c} this org lets a body be written to`+(o.length>0?` (${o.join(", ")})`:"")]};let t=e.knowledge.available?{available:!0,bodyFields:o}:e.knowledge,n={seed:e.seed??d.seed,caseStatus:{open:e.caseStatus.open,closed:e.caseStatus.closed},...i!==void 0?p(i):{}},l;try{l=g(a,n)}catch(s){if(s instanceof y)return{issues:s.issues};throw s}return{preparation:{options:n,objects:[...l.template.objects].sort((s,C)=>s.insertOrder-C.insertOrder).map(s=>({objectApiName:s.objectApiName,recordCount:s.recordCount,...s.optional===!0?{optional:!0}:{}})),tests:l.tests.length,caseStatusFrom:e.caseStatus.from==="org"?{from:"org"}:{from:"default",reason:e.caseStatus.reason},knowledge:t}}}function D(a){return async e=>{let r=await a.query(e),o=[...r.records];for(;!r.done&&r.nextRecordsUrl;)r=await a.queryMore(r.nextRecordsUrl),o.push(...r.records);return o}}export{h as a,w as b,k as c,c as d,E as e,T as f,v as g,D as h};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a as T,b as F,d as B,k as R}from"./chunk-7FFGJWHN.mjs";import{b as j,l as x,o as N}from"./chunk-G35N4P7D.mjs";import{a as L,f as C,i as $,j as _}from"./chunk-SAR5622P.mjs";import{a as I}from"./chunk-4TLYUZD5.mjs";import{b as P}from"./chunk-CA5NAXSU.mjs";import{qc as A}from"./chunk-TTFDUKUS.mjs";var w=class{byObject=new Map;add(e){let t=this.byObject.get(e.objectApiName);t||(t=new Map,this.byObject.set(e.objectApiName,t));let s=t.get(e.recordId),r=s?.[e.fieldName];if(r!==void 0&&r!==e.value)return{taken:!1,kept:r};let n=s??{Id:e.recordId};return n[e.fieldName]=e.value,t.set(e.recordId,n),{taken:!0}}updates(){return[...this.byObject].map(([e,t])=>[e,[...t.values()]])}};var J="DUPLICATES_DETECTED",X=3,Y=2e3;function Z(i){return new Promise(e=>setTimeout(e,i))}function z(i){let e=i.errorDetails??[];return N(i.errors,e.length===i.errors.length?e:void 0)}function q(i){let e=i.errorDetails;return e?.length!==1||e[0].statusCode===J||z(i)}function Q(i){let e=Object.keys(i).find(s=>s!=="Id"),t=e===void 0?void 0:i[e];return typeof t=="string"?t:""}function U(i){return{objectApiName:i,op:"update"}}function V(i){let e=i.automation??"the target's automation";I.warn(`[forge] ${i.objectApiName}: ${e} hit ${i.limit??"a Salesforce limit"} on an update of ${i.from} records \u2014 sending a record on its own, then smaller calls.`)}function y(i){return Object.keys(i).filter(e=>e!=="Id").length}async function fe(i){if(!i.enabled||!i.updateRecords||i.pendingFkUpdates.length===0)return null;let e=new E(i);return await e.patch(i.pendingFkUpdates),e.finish()}var ee=1024,te=.6;function K(i){let e=2166136261;for(let t=0;t<i.length;t++)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0}function M(i){let e=2538058380;for(let t=0;t<i.length;t++)e=Math.imul(e^i.charCodeAt(t),1540483477),e^=e>>>15;return e>>>0}var H=class{capacity=ee;used=0;h1=new Uint32Array(this.capacity);h2=new Uint32Array(this.capacity);firstPart=new Float64Array(this.capacity);several=new Uint8Array(this.capacity);note(e,t){let s=K(t),r=M(t),n=this.find(s,r);if(n>=0){this.firstPart[n]!==e+1&&(this.several[n]=1);return}this.used+1>this.capacity*te&&this.grow();let o=this.freeSlotFor(r);this.h1[o]=s,this.h2[o]=r,this.firstPart[o]=e+1,this.used++}spans(e){let t=this.find(K(e),M(e));return t>=0&&this.several[t]===1}find(e,t){let s=this.capacity-1;for(let r=t&s;;r=r+1&s){if(this.firstPart[r]===0)return-1;if(this.h1[r]===e&&this.h2[r]===t)return r}}freeSlotFor(e){let t=this.capacity-1,s=e&t;for(;this.firstPart[s]!==0;)s=s+1&t;return s}grow(){let{h1:e,h2:t,firstPart:s,several:r}=this;this.capacity*=2,this.h1=new Uint32Array(this.capacity),this.h2=new Uint32Array(this.capacity),this.firstPart=new Float64Array(this.capacity),this.several=new Uint8Array(this.capacity);for(let n=0;n<s.length;n++){if(s[n]===0)continue;let o=this.freeSlotFor(t[n]);this.h1[o]=e[n],this.h2[o]=t[n],this.firstPart[o]=s[n],this.several[o]=r[n]}}},E=class{constructor(e){this.input=e;this.splits=e.splitting!==void 0,this.splitting=e.splitting??L(0),this.bulkUnsupported=e.bulkUnsupported??new Set}input;resolvedCount=0;unresolvedCount=0;insertOnlyLost=0;unresolved=[];pass2Failed=0;pass2Samples=[];notSent=0;notSentObjects=new Set;cancelled=!1;handed=0;held=new w;splitting;splits;bulkUnsupported;backoff=new x({initialDelay:Y});limitOf(e){return this.splits&&e&&!e.success?A(e.errors):void 0}async patch(e,t){let{input:s}=this;if(!s.enabled||!s.updateRecords||e.length===0)return;this.handed+=e.length;let r=new w;for(let n of e)this.take(n,t?.(n)===!0?this.held:r);await this.send(r)}async sendHeld(){await this.send(this.held)}take(e,t){let{input:s}=this,{remapper:r}=s,n=r.get(e.sourceRefId);if(!n){if(s.deferUnresolved){s.stillPending?.push(e);return}if(s.outsideTheSample?.(e)){s.onLeftOutsideTheSample?.(e.objectApiName,e.fieldName);return}this.unresolvedCount++,this.unresolved.length<3&&this.unresolved.push({recordSummary:`${e.objectApiName} source=${e.sourceId??"?"} target=${e.newId} ${e.fieldName}=<source ${e.sourceRefId}>`,messages:[`Cycle FK '${e.fieldName}' could not be resolved \u2014 referenced parent (source ${e.sourceRefId}) was not cloned`]});return}if(e.insertOnly){this.insertOnlyLost++,this.unresolved.length<3&&this.unresolved.push({recordSummary:`${e.objectApiName} source=${e.sourceId??"?"} target=${e.newId} ${e.fieldName}`,messages:[`Lookup '${e.fieldName}' left empty: only an insert sets it, and the record it names (source ${e.sourceRefId}) was written after this one`]});return}let o=t.add({objectApiName:e.objectApiName,recordId:e.newId,fieldName:e.fieldName,value:n});if(!o.taken){this.unresolvedCount++,this.unresolved.length<3&&this.unresolved.push({recordSummary:`${e.objectApiName} source=${e.sourceId??"?"} target=${e.newId} ${e.fieldName}`,messages:[`Conflicting cycle FK update for ${e.fieldName}: ${String(o.kept)} vs ${n}`]});return}this.resolvedCount++}async send(e){for(let[t,s]of e.updates()){if(this.jobsFor(t,s.length)){await this.sendAsJobs(t,s);continue}await this.sendObject(t,s)}}jobsFor(e,t){let{input:s}=this;return s.bulkUpdate!==void 0&&t>=2e3&&s.restOnly?.has(e)!==!0&&!this.bulkUnsupported.has(e)}leaveNotSent(e,t){for(let s of t)this.notSent+=y(s);t.length>0&&this.notSentObjects.add(e)}async sendObject(e,t,s,r){let{input:n}=this,{targetOrgId:o}=n,d=n.updateRecords;if(!d||t.length===0)return;let c=()=>(this.cancelled||(this.cancelled=n.stopped?.()===!0),this.cancelled);if(c()){this.leaveNotSent(e,t);return}let l,a=await _(t,{key:U(e),sizes:this.splitting.sizes,allowance:this.splitting.allowance,maxSize:B.rest,...r,beforeEachSend:()=>c()?"stop":void 0,send:async p=>{try{return{answers:await d(o,e,[...p])}}catch(h){return l={error:h},{answers:[]}}},limited:p=>this.limitOf(p),settle:(p,h,k,S)=>{let v=l;l=void 0,v?this.callThrew(e,p,v.error):this.settleAnswers(e,p,h,k,S,s),n.onAnswered?.()},onFirstRefusal:V});a.stopped&&this.leaveNotSent(e,[...a.stopped.part,...a.stopped.rest])}settleAnswers(e,t,s,r,n,o){let{input:d}=this;for(let c=0;c<t.length;c++){if(r.has(c))continue;let l=s[c];l?l.success?d.onPatched?.(e,t[c]):o&&z(l)?o.push(t[c]):this.refused(e,t[c],l,n.get(c)):(this.pass2Failed+=y(t[c]),this.pass2Samples.length<3&&this.pass2Samples.push({recordSummary:R(t[c]),messages:[`No result returned for record (API truncated batch: ${s.length}/${t.length})`]}))}}refused(e,t,s,r){this.tellRefusedByFilter(e,t,s),this.pass2Failed+=y(t),this.pass2Samples.length<3&&this.pass2Samples.push({recordSummary:R(t),messages:r===void 0?s.errors:[...s.errors,C(r,$(this.splitting.allowance,U(e)),"run")]})}callThrew(e,t,s){for(let r of t)this.pass2Failed+=y(r);this.pass2Samples.length<3&&this.pass2Samples.push({recordSummary:`${e} batch failed`,messages:[P(s)]})}async sendAsJobs(e,t){let{input:s}=this,r=s.bulkUpdate;if(!r)return;let n=t.map((l,a)=>({record:l,at:a,value:Q(l)})).sort((l,a)=>l.value===a.value?l.at-a.at:l.value<a.value?-1:1).map(({record:l})=>l),o=U(e),{sizes:d,allowance:c}=this.splitting;for(let l=0;l<n.length;l+=F){let a=n.slice(l,l+F);if(this.cancelled||(this.cancelled=s.stopped?.()===!0),this.cancelled){this.leaveNotSent(e,a);continue}let p=d.of(o);if(p<200){let u=Math.ceil(a.length/p),f=c.take(o,u);d.countExtraCalls(o,f);let m=a.slice(0,f*p);try{await this.sendObject(e,m,void 0,{pricedAs:"job",paid:{calls:f}})}finally{f<u&&d.spend(o)}if(f===u)continue;if(a=a.slice(m.length),this.cancelled){this.leaveNotSent(e,a);continue}if(a.length<2e3){await this.sendObject(e,a);continue}}let h;try{h=await r(e,a)}catch(u){if(!(u instanceof T)){await this.sendObject(e,a);continue}for(let f of a)this.pass2Failed+=y(f);this.pass2Samples.length<3&&this.pass2Samples.push({recordSummary:`${e}: a Bulk API job of ${a.length} updates was lost`,messages:[P(u),"The target may hold any of these lookups: they are counted as left empty."]}),s.onAnswered?.();continue}if(h.aborted){this.cancelled=!0,this.leaveNotSent(e,a);continue}if(h.untouched){h.untouched.unsupported&&this.bulkUnsupported.add(e),await this.sendObject(e,a);continue}let k=[],S=[],v=[],b;a.forEach((u,f)=>{let m=h.rows[f]??"unprocessed",g=h.answers[f],O=m==="answered"?this.limitOf(g):void 0;O&&g?(b??=O,S.push(u),v.push(g)):m==="answered"&&g?.success?s.onPatched?.(e,u):m==="may-have-written"?(this.pass2Failed+=y(u),this.pass2Samples.length<3&&this.pass2Samples.push({recordSummary:R(u),messages:["The Bulk API job may have written this update without saying so."]})):m!=="answered"||!g||q(g)?k.push(u):this.refused(e,u,g)}),s.onAnswered?.(),await this.sendAgainByRest(e,k),await this.sendObject(e,S,void 0,{refusedIn:{from:200,answers:v,...b?{cause:b}:{}}})}}async sendAgainByRest(e,t){let s=t;for(let r=0;s.length>0;r++){r>0&&await(this.input.wait??Z)(this.backoff.calculateDelay(r-1));let n=[];await this.sendObject(e,s,r<X-1?n:void 0),s=n}}tellRefusedByFilter(e,t,s){let r=this.input.onRefusedByFilter,n=t.Id;if(!r||typeof n!="string")return;let o=new Set((s.errorDetails??[]).filter(d=>d.statusCode===j).flatMap(d=>d.fields));for(let d of Object.keys(t))d!=="Id"&&o.has(d)&&r(e,d,n)}finish(){let{resolvedCount:e,unresolvedCount:t,insertOnlyLost:s,pass2Failed:r,notSent:n}=this;if(this.handed===0)return null;let o=e+t+s;if(this.input.deferUnresolved&&e===0&&r===0&&s===0)return null;let d=r+t+s+n;if(this.input.onProgress({objectName:"__pass2__",status:d>0?"error":"done",progress:100,message:`Pass 2 (cycle FK update): ${e-r-n}/${o} resolved`+(n>0?`; cancelled with ${n} not sent`:"")}),d>0){let c=n>0?[{recordSummary:`${[...this.notSentObjects].join(", ")}: ${n} lookup${n===1?"":"s"} not sent`,messages:["The run was cancelled before they were filled in: they stay empty."]}]:[];return{objectApiName:"__pass2__",stage:"insert",failedCount:d,attemptedCount:o,samples:[...c,...this.pass2Samples,...this.unresolved].slice(0,3)}}return null}};export{w as a,fe as b,H as c,E as d};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{b as i}from"./chunk-CA5NAXSU.mjs";var o=["ENOTFOUND","ECONNREFUSED","ETIMEDOUT","ECONNRESET","EAI_AGAIN","ENETUNREACH","EHOSTUNREACH"];function s(n){if(typeof n=="object"&&n!==null){let{code:t,name:u,cause:r}=n;if(typeof t=="string"&&o.includes(t)||u==="TimeoutError"||r!==void 0&&s(r))return!0}let e=i(n);return o.some(t=>e.includes(t))||e.includes("fetch failed")?!0:/\btimed out\b/i.test(e)}function c(n){let{code:e}=typeof n=="object"&&n!==null?n:{};if(typeof e=="string"&&o.includes(e))return e;let t=i(n),u=o.find(r=>t.includes(r));if(u!==void 0)return u;if(/socket hang up/i.test(t))return"socket hang up";if(s(n))return/\btimed out\b/i.test(t)?"timed out":"no connection"}function f(n){return typeof n.unread=="string"?c(n.unread):n.unread.find(e=>e.unreachable!==void 0)?.unreachable}export{s as a,c as b,f as c};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a as b}from"./chunk-74Q6DORA.mjs";import"./chunk-UNJA4J37.mjs";import{a}from"./chunk-XLXIPIEW.mjs";import"./chunk-TTKXMDBN.mjs";import"./chunk-TSLJUSLW.mjs";import"./chunk-KRCA6IPH.mjs";import"./chunk-5TC3QB4U.mjs";import"./chunk-2BA2XKAY.mjs";import"./chunk-OAZRPP4I.mjs";import"./chunk-JEERQRLW.mjs";import"./chunk-MHMH6MTP.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-MJU2PGZQ.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LWW4U276.mjs";import"./chunk-MJVTDA5Q.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-2CNCDM56.mjs";import"./chunk-SIHORWVK.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-B5QQJ4SI.mjs";import"./chunk-NZC67CGR.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-F43REJDZ.mjs";import"./chunk-JPUR2CFX.mjs";import"./chunk-LPBMBW3O.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-IFETCRWE.mjs";import"./chunk-PZPJKATS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-MFG4MUIO.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-HS4YRX4J.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{a as objectsWrittenBy,b as previewCheckpoint};
|
|
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{
|
|
7
|
+
import{F as p,d as u,k as d,x as h}from"./chunk-IFETCRWE.mjs";import{b as c}from"./chunk-CA5NAXSU.mjs";import{Fa as a}from"./chunk-TTFDUKUS.mjs";import{randomBytes as E}from"node:crypto";import{open as k,readFile as b,rename as I,rm as T}from"node:fs/promises";import{dirname as l,join as m}from"node:path";var f="rewinds.ndjson",C=400,O=200;function P(e,n){return m(e,d(n),f)}function R(e){return m(l(e.dir),f)}async function y(e,n,t,i={maxLines:C,keptLines:O}){if(d(t.organizationId)!==n.organizationId)throw new p("invalid","A rewind is kept in its org\u2019s ledger, under its lock.");let r=a.safeParse(t);if(!r.success)throw new p("invalid","A line of the rewind ledger does not parse.");await h(l(e));let o=await w(e),x=o!==""&&!o.endsWith(`
|
|
8
8
|
`)?`
|
|
9
9
|
`:"",s=await k(e,"a",u);try{await s.writeFile(`${x}${JSON.stringify(r.data)}
|
|
10
10
|
`,"utf8"),await s.sync()}finally{await s.close()}L(o).length+1>i.maxLines&&await A(e,i.keptLines)}async function A(e,n){let t=L(await w(e)).slice(-n),i=`${e}.${process.pid}-${E(4).toString("hex")}.tmp`,r=await k(i,"wx",u);try{try{await r.writeFile(t.map(o=>`${o}
|