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
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-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-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-NEVXIGR6.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 B,b as J}from"./chunk-TYYOBZMU.mjs";import{a as S}from"./chunk-SIOZXPFG.mjs";import{Aa as C,ra as g,sa as D,ta as U,ua as E}from"./chunk-B45CNPUX.mjs";import{b as l,l as m,s as I,u as M,v as K}from"./chunk-7EANH5PY.mjs";import{randomBytes as R}from"node:crypto";import{mkdirSync as ke,statSync as Y}from"node:fs";import{mkdir as w,open as me,readFile as A,readdir as _,rename as we,rm as f,rmdir as ye,stat as x}from"node:fs/promises";import{homedir as V}from"node:os";import{join as c,resolve as Oe}from"node:path";import{promisify as Q}from"node:util";import{gunzip as Fe,gzip as xe}from"node:zlib";import{createHash as ge}from"node:crypto";var G=16,Z=m({digest:l().regex(/^[0-9a-f]{64}$/),fields:I(l(),l().regex(new RegExp(`^[0-9a-f]{${G}}$`)))});function W(n){return ge("sha256").update(n).digest("hex")}function he(n){return JSON.stringify([n.name.toLowerCase(),n.type,n.createable===!0,n.updateable===!0,n.nillable===!0,[...n.referenceTo??[]].sort(),n.encrypted===!0])}function sn(n){let e=n.map(t=>({name:t.name,key:t.name.toLowerCase(),line:he(t)})).sort((t,r)=>t.key<r.key?-1:t.key>r.key?1:0);return{digest:W(e.map(({line:t})=>t).join(`
|
|
8
|
-
`)),fields:Object.fromEntries(e.map(({name:t,line:r})=>[t,W(r).slice(0,G)]))}}function cn(n,e){let t={added:[],removed:[],changed:[]};if(n.digest===e.digest)return t;let r=new Map(Object.entries(n.fields).map(([o,s])=>[o.toLowerCase(),{name:o,print:s}])),i=new Map(Object.entries(e.fields).map(([o,s])=>[o.toLowerCase(),{name:o,print:s}]));for(let[o,{name:s,print:a}]of i){let p=r.get(o);p===void 0?t.added.push(s):p.print!==a&&t.changed.push(s)}for(let[o,{name:s}]of r)i.has(o)||t.removed.push(s);return t.added.sort(),t.removed.sort(),t.changed.sort(),t}var h=448,Ie=384,Ce=30,be=3,Pe=15,ee=1440*6e4,P=1440*6e4,De=Q(xe),Ee=Q(Fe),T="checkpoint.json",Se="fingerprints.json.gz",ve="fingerprints.json",ze="snapshots.json",ne=/^[A-Za-z][A-Za-z0-9_]*$/;function On(n=process.env){let e=n.SANDFORGE_JOURNAL_DIR,t=e!==void 0&&e.trim()!==""?Oe(e):c(V(),".sandforge");return c(t,"checkpoints")}function Le(n=V()){return c(n,".sandforge","locks")}function k(n){let e=E.safeParse(n).success?S(n.slice(0,15)):void 0;if(e===void 0)throw new d("invalid","Not an Organization Id");return e}function Re(n){return n.length===18&&E.safeParse(n).success&&S(n.slice(0,15))===n}function v(n,e,t){return te(c(n,e,t),e,t)}function te(n,e,t){return{organizationId:e,checkpointId:t,dir:n,checkpointFile:c(n,T),fingerprintsFile:c(n,Se),plainFingerprintsFile:c(n,ve),snapshotsFile:c(n,ze),indexDir:c(n,"index"),binDir:c(n,"bin"),filesDir:c(n,"files"),previewsDir:c(n,"previews"),rewindsDir:c(n,"rewinds")}}function re(n){if(!ne.test(n)||n.length>80)throw new d("invalid","Not a Salesforce API name");return n}function Fn(n,e){return c(n.indexDir,`${re(e)}.idx`)}function xn(n){return c(n.indexDir,"recreated.ndjson")}function In(n){return c(n.indexDir,"notInBin.ndjson")}function Cn(n,e){return c(n.binDir,`${re(e)}.ids`)}function bn(n){return c(n.filesDir,"documents.ndjson")}function Pn(n){return c(n.filesDir,"links.ndjson")}var Ae=[/^checkpoint\.json$/,/^fingerprints\.json(?:\.gz)?$/,/^snapshots\.json$/,/^backups\/[A-Za-z0-9_-]{1,200}__[A-Za-z][A-Za-z0-9_]{0,79}\.ndjson(?:\.gz)?$/,/^bin\/[A-Za-z][A-Za-z0-9_]{0,79}\.ids$/,/^files\/(?:links|documents)\.ndjson(?:\.gz)?$/,/^index\/(?:recreated|notInBin)\.ndjson$/],je=["","backups","bin","files","index"],Dn=T;function ie(n){return Ae.some(e=>e.test(n))}async function En(n){let e=[];for(let t of je){let r;try{r=await _(c(n.dir,t),{withFileTypes:!0})}catch(i){if(F(i)==="ENOENT"||F(i)==="ENOTDIR")continue;throw i}for(let i of r){let o=t===""?i.name:`${t}/${i.name}`;if(!i.isFile()||!ie(o))continue;let s=c(n.dir,t,i.name);e.push({path:o,file:s,bytes:(await x(s)).size})}}return e.sort((t,r)=>fe(t.path,r.path))}function Sn(n,e){if(!ie(e))throw new d("invalid","Not a file a checkpoint holds");return c(n,...e.split("/"))}function vn(n,e){return c(n.previewsDir,O(D,e))}function H(n,e){return c(n.rewindsDir,O(U,e))}function O(n,e){let t=n.safeParse(e);if(!t.success)throw new d("invalid","Not an id of this store");return t.data}async function X(n){await w(n,{recursive:!0,mode:h})}var q="abcdefghijklmnopqrstuvwxyz0123456789";function zn(n,e=new Date){let t=e.toISOString(),r=`${t.slice(0,4)}${t.slice(5,7)}${t.slice(8,10)}`,i=`${t.slice(11,13)}${t.slice(14,16)}${t.slice(17,19)}`,o=Array.from(R(4),s=>q[s%q.length]).join("");return`${n}-${r}-${i}-${o}`}function Ne(n,e){if(!Number.isInteger(e)||e<0)throw new RangeError(`Not a number of days: ${e}`);return e===0?null:new Date(n.getTime()+e*P).toISOString()}function oe(n,e){return n.expiresAt!==null&&Date.parse(n.expiresAt)<=e}function $e(n,e){if(n.expiresAt===null)return!1;let t=Date.parse(n.expiresAt);return t>e&&t-e<=be*P}function _e(n,e){let t=e-Pe*P;return Date.parse(n.readFrom)<t?new Date(t).toISOString():void 0}function Te(n,e){let t=n.scratchExpiresAt;if(t===void 0)return!1;let r=Date.parse(t);return Number.isFinite(r)?/^\d{4}-\d{2}-\d{2}$/.test(t)?r+P<=e:r<=e:!1}var d=class extends Error{constructor(t,r){super(r);this.code=t;this.name="CheckpointStoreError"}code},se=m({version:K(1),objects:I(l().regex(ne).max(80),Z)});async function He(n,e){let t;try{t=JSON.parse(await Ke(n))}catch{throw new d("damaged","The checkpoint\u2019s field prints cannot be read")}let r=se.safeParse(t);if(!r.success)throw new d("damaged","The checkpoint\u2019s field prints do not parse");let i=new Map(Object.entries(r.data.objects));for(let o of e)if(i.get(o.objectApiName)?.digest!==o.fingerprint)throw new d("damaged",`The field prints of ${o.objectApiName} are not the checkpoint\u2019s`);return i}async function Me(n){let e=se.safeParse({version:1,objects:n});if(!e.success)throw new d("invalid",`Not field prints: ${e.error.message}`);return De(`${JSON.stringify(e.data)}
|
|
9
|
-
`)}async function Ke(n){let e;try{e=await A(n.fingerprintsFile)}catch(t){if(t.code!=="ENOENT")throw t;return A(n.plainFingerprintsFile,"utf8")}return(await Ee(e)).toString("utf8")}function Ln(n){let e=n.uid??(()=>process.getuid?.()),t=n.locksDir??Le();for(let r of[n.root,t]){let i=Ue(r,e);if(i!==void 0)return{refusal:i}}return{store:new j({...n,locksDir:t})}}function Ue(n,e){try{let t=Y(n,{throwIfNoEntry:!1});if(t!==void 0&&!t.isDirectory())return{reason:"notAFolder",path:n};ke(n,{recursive:!0,mode:h});let r=e();return r!==void 0&&Y(n).uid!==r?{reason:"otherOwner",path:n}:void 0}catch(t){return{reason:"cannotMake",path:n,detail:rn(t)}}}var j=class{root;locksDir;renameFile;lockOptions;changes=new Map;constructor(e){this.root=e.root,this.locksDir=e.locksDir,this.renameFile=e.rename??((t,r)=>we(t,r)),this.lockOptions={...e.lockSelf?{self:e.lockSelf}:{},...e.lockChecks?{checks:e.lockChecks}:{}}}folderOf(e,t){return v(this.root,k(e),O(g,t))}async create(e,t){let r=this.folderOf(e,t);await X(c(this.root,r.organizationId));try{await w(r.dir,{mode:h})}catch(i){throw F(i)==="EEXIST"?new d("exists",`A checkpoint ${t} is kept already`):i}return await w(r.indexDir,{mode:h}),await w(r.binDir,{mode:h}),r}async write(e){let t=z(e),r=this.folderOf(t.org.organizationId,t.checkpointId);await this.writeWhole(r.checkpointFile,N(t))}async writeFingerprints(e,t){await this.writeWhole(e.fingerprintsFile,await Me(t))}async readFingerprints(e,t){return He(e,t.objects)}async checkpointsOf(e){return this.readsOf(k(e))}async read(e){let t=O(g,e);for(let r of await this.organizationKeys()){let i=v(this.root,r,t);if(await y(i.dir))return L(i)}}async update(e,t){let r=async()=>{let a=await this.read(e);if(a===void 0)throw new d("notFound",`No checkpoint ${e} is kept`);if(a.checkpoint===void 0)throw new d("damaged",`The checkpoint ${e} is damaged`);let p=t(structuredClone(a.checkpoint));if(p.checkpointId!==a.folder.checkpointId||$(p.org.organizationId)!==a.folder.organizationId)throw new d("invalid","A change never moves a checkpoint");return await this.write(p),C.parse(p)},o=(this.changes.get(e)??Promise.resolve()).then(r,r),s=o.catch(()=>{});return this.changes.set(e,s),s.then(()=>{this.changes.get(e)===s&&this.changes.delete(e)}),o}keep(e,t,r=new Date){return this.update(e,i=>({...i,expiresAt:t?null:Ne(r,Ce)}))}async list(e={}){let t=(e.now??new Date).getTime(),r=e.organizationId!==void 0?k(e.organizationId):void 0,i=[];for(let o of await this.organizationKeys(r)){let s=await this.readsOf(o),a=Ze(s);for(let p of s)i.push(await Xe(p,t,a,e.refreshedAt))}return i.sort((o,s)=>fe(s.checkpointId,o.checkpointId))}async delete(e){let t=await this.read(e);if(t===void 0)return{outcome:"notFound"};let r=this.lock(t.folder.organizationId,"delete",t.folder.checkpointId);if("busy"in r)return{outcome:"busy",holder:r.busy};try{await f(t.folder.dir,{recursive:!0,force:!0})}finally{r.lock.release()}return t.checkpoint?{outcome:"deleted",checkpoint:t.checkpoint}:{outcome:"deleted"}}async importInto(e,t,r){let i=this.folderOf(e,t),o=c(this.root,i.organizationId);await X(o);let s=te(c(o,`${Be}${R(6).toString("hex")}`),i.organizationId,i.checkpointId);await w(s.dir,{mode:h});try{let a=z(await r(s));if(a.checkpointId!==i.checkpointId||$(a.org.organizationId)!==i.organizationId)throw new d("invalid","An import keeps the checkpoint it was asked to");let p=z({...a,bytes:await Ge(s.dir,a)});if(await this.writeWhole(s.checkpointFile,N(p)),await y(i.dir))return{outcome:"exists"};try{await this.renameFile(s.dir,i.dir)}catch(u){if(await y(i.dir))return{outcome:"exists"};throw u}return{outcome:"imported",checkpoint:p}}finally{await f(s.dir,{recursive:!0,force:!0}),await ye(o).catch(()=>{})}}async sweep(e=new Date){let t=e.getTime(),r={checkpoints:[],journals:[],previews:0,skipped:[]};for(let i of await this.organizationKeys()){await We(c(this.root,i),t);let o=await qe(await this.readsOf(i),t);if(o.length===0)continue;let s=this.lock(i,"sweep");if("busy"in s){r.skipped.push(i);continue}try{for(let a of o)await Ve(await L(a),t,r)}finally{s.lock.release()}}return r}lock(e,t,r){return nn(this.locksDir,e,{operation:t,...r!==void 0?{checkpointId:r}:{}},this.lockOptions)}heldBy(e){return tn(this.locksDir,e,this.lockOptions)}async organizationKeys(e){return(await b(this.root)).filter(r=>Re(r)&&(e===void 0||r===e))}async readsOf(e){let t=(await b(c(this.root,e))).filter(i=>g.safeParse(i).success),r=[];for(let i of t)r.push(await L(v(this.root,e,i)));return r}async writeWhole(e,t){let r=`${e}.${process.pid}-${R(4).toString("hex")}.tmp`,i=await me(r,"wx",Ie);try{try{await i.writeFile(t,typeof t=="string"?"utf8":void 0),await i.sync()}finally{await i.close()}await this.renameFile(r,e)}catch(o){throw await f(r,{force:!0}),o}}},Be=".importing-",Je=/^\.importing-[0-9a-f]{12}$/;async function We(n,e){for(let t of await b(n)){if(!Je.test(t))continue;let r=c(n,t),i=await x(r).catch(()=>{});i!==void 0&&i.mtimeMs+ee<=e&&await f(r,{recursive:!0,force:!0})}}function z(n){let e=C.safeParse(n);if(!e.success)throw new d("invalid",`Not a checkpoint: ${e.error.message}`);return e.data}function N(n){return`${JSON.stringify(n,null,2)}
|
|
10
|
-
`}async function ce(n,e){let t=0;for(let r of await _(n,{withFileTypes:!0})){let i=c(n,r.name);r.isDirectory()?t+=await ce(i,e):r.isFile()&&i!==e&&(t+=(await x(i)).size)}return t}async function Ge(n,e){let t=await ce(n,c(n,T)),r=o=>Buffer.byteLength(N({...e,bytes:o}),"utf8"),i=t+r(t);return i=t+r(i),i}async function L(n){let e;try{e=JSON.parse(await A(n.checkpointFile,"utf8"))}catch{return{folder:n}}let t=C.safeParse(e);return t.success?t.data.checkpointId!==n.checkpointId||$(t.data.org.organizationId)!==n.organizationId?{folder:n}:{folder:n,checkpoint:t.data}:{folder:n}}function Ze(n){let e;for(let{folder:t,checkpoint:r}of n){let i=r?.lastRewind?.rewindId;i!==void 0&&(e===void 0||i>e.rewindId)&&(e={checkpointId:t.checkpointId,rewindId:i})}return e}function Ye(n,e,t,r){if(n.status==="taking")return{why:"taking"};if(n.status==="failed")return{why:"failed"};let i=r?.(e);if(i!==void 0)return{why:"refreshed",refreshedAt:i};if(Te(n.org,t))return{why:"scratchExpired"}}async function Xe({folder:n,checkpoint:e},t,r,i){let o={checkpointId:n.checkpointId,organizationId:n.organizationId};if(e===void 0)return{...o,valid:!1,why:"damaged"};let s=Ye(e,n.organizationId,t,i);if(s!==void 0)return{...o,checkpoint:e,valid:!1,why:s.why,...s.refreshedAt!==void 0?{refreshedAt:s.refreshedAt}:{}};let a={...o,checkpoint:e,valid:!0};$e(e,t)&&(a.expiresSoon=!0);let p=_e(e,t);p!==void 0&&(a.binReachSince=p);let u=e.lastRewind;return u!==void 0&&r?.checkpointId===n.checkpointId&&u.undoUntil!==void 0&&u.undoneAt===void 0&&Date.parse(u.undoUntil)>t&&await y(H(n,u.rewindId))&&(a.undo={rewindId:u.rewindId,until:u.undoUntil}),a}async function qe(n,e){let t=[];for(let{folder:r,checkpoint:i}of n)i!==void 0&&(oe(i,e)||await ae(r,i,e)||(await de(r,e)).length>0)&&t.push(r);return t}async function ae(n,e,t){let r=e.lastRewind?.undoUntil;return e.lastRewind!==void 0&&r!==void 0&&Date.parse(r)<=t&&await y(H(n,e.lastRewind.rewindId))}async function de(n,e){let t=[];for(let r of await b(n.previewsDir)){if(!D.safeParse(r).success)continue;let i=c(n.previewsDir,r),o=await x(i).catch(()=>{});o!==void 0&&o.mtimeMs+ee<=e&&t.push(i)}return t}async function Ve(n,e,t){let{folder:r,checkpoint:i}=n;if(i===void 0)return;if(i.expiresAt!==null&&oe(i,e)){await f(r.dir,{recursive:!0,force:!0});let s=i.lastRewind?.undoUntil,a=s!==void 0&&i.lastRewind?.undoneAt===void 0&&Date.parse(s)>e;t.checkpoints.push({organizationId:r.organizationId,checkpointId:r.checkpointId,name:i.name,...i.org.alias!==void 0?{alias:i.org.alias}:{},takenAt:i.takenAt,expiresAt:i.expiresAt,...a?{undoUntil:s}:{}});return}let o=i.lastRewind;o?.undoUntil!==void 0&&await ae(r,i,e)&&(await f(H(r,o.rewindId),{recursive:!0,force:!0}),t.journals.push({organizationId:r.organizationId,checkpointId:r.checkpointId,name:i.name,rewindId:o.rewindId,undoUntil:o.undoUntil}));for(let s of await de(r,e))await f(s,{recursive:!0,force:!0}),t.previews+=1}var Qe=m({...B,operation:M(["take","rewind","undo","delete","sweep","empty"]),checkpointId:g.optional()}),pe=J(n=>{let e=Qe.safeParse(n);return e.success?e.data:void 0});function en(n,e){return c(n,`${k(e)}.lock`)}function nn(n,e,t,r={}){let i=k(e),o=t.checkpointId!==void 0?O(g,t.checkpointId):void 0,s=pe.acquire(c(n,`${i}.lock`),a=>({...a,operation:t.operation,...o!==void 0?{checkpointId:o}:{}}),r);return"busy"in s?{busy:ue(s.busy)}:{lock:{organizationId:i,release:s.lock.release}}}function tn(n,e,t={}){let r=pe.holder(en(n,e),t);return r!==void 0?ue(r):void 0}function ue({version:n,token:e,...t}){return t}async function b(n){try{return(await _(n,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name)}catch(e){if(F(e)==="ENOENT"||F(e)==="ENOTDIR")return[];throw e}}async function y(n){return(await x(n).catch(()=>{}))?.isDirectory()===!0}function $(n){try{return k(n)}catch{return}}function fe(n,e){return n<e?-1:n>e?1:0}function F(n){return n?.code}function rn(n){return n instanceof Error?n.message:String(n)}export{sn as a,cn as b,h as c,Ie as d,Ce as e,be as f,Pe as g,ee as h,On as i,Le as j,k,Fn as l,xn as m,In as n,Cn as o,bn as p,Pn as q,Dn as r,ie as s,En as t,Sn as u,vn as v,H as w,X as x,zn as y,Ne as z,oe as A,$e as B,_e as C,Te as D,d as E,He as F,Me as G,Ln as H,j as I,Ze as J,en as K,nn as L,tn as M};
|
package/lib/chunk-NHWE66K5.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}from"./chunk-ALUFROGA.mjs";import"./chunk-TBZMC2VV.mjs";import"./chunk-LQ4DRFUH.mjs";import"./chunk-57VHUYNG.mjs";import"./chunk-5O6JOMHS.mjs";import"./chunk-HUMEKZT5.mjs";import"./chunk-MYTIL2JD.mjs";import"./chunk-JVL444U5.mjs";import"./chunk-KLX67VPL.mjs";import"./chunk-5CD257T7.mjs";import"./chunk-H45UXY6G.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{b as UNDO_AUTOMATION_LIFTED_BY,a as UndoStopped,c as undoCheckpoint};
|
package/lib/chunk-OQOZAPCI.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 fe}from"./chunk-IAZB4WIL.mjs";import{I as me,O as pe,b as le}from"./chunk-XEFDB2R4.mjs";import{$a as ue,bb as ce,h as ie,i as ae,j as de,k as B}from"./chunk-36U7IQ6Y.mjs";import{Ja as se,la as re,ma as ne,na as M,oa as oe,va as v,w as te}from"./chunk-VXHDBYMI.mjs";import{b as z}from"./chunk-WIO4XO4F.mjs";import{h as ee}from"./chunk-PNCONNFJ.mjs";import{p as $}from"./chunk-CGWXQX75.mjs";import{c as J,d as Y,g as Z}from"./chunk-SIOZXPFG.mjs";import{b as F}from"./chunk-CA5NAXSU.mjs";import{$c as Q,Hc as U,Kc as G,Mc as C,Xc as K,_c as H,ad as V,bd as X,fc as W,g as _,h as I,vb as q}from"./chunk-B45CNPUX.mjs";var N=1e4;function we(e,n){if(e.aborted||e.outcomes.length!==n||(e.unmatchedIds?.length??0)>0||e.failures.some(r=>r.recordIndex<0))return;let t=new Array(n);for(let r of e.outcomes){if(r.recordIndex<0||r.recordIndex>=n)return;if(r.success){if(!r.id)return;t[r.recordIndex]={id:r.id}}else{let o=r.error??"Unknown error",i=Y(o);t[r.recordIndex]={error:o,...i?{errorDetails:[i]}:{}}}}return t.every(r=>r!==void 0)?t:void 0}function _e(e){let{conn:n,bulkManager:t,retry:r,signal:o,label:i}=e,p=new ee(e.bulkThreshold),f,b=async(h,d,m)=>{f??=ce(n).then(R=>(R||e.log(`[WARN] ${i}: the org's duplicate rules could not be read: an object of more than the Bulk API threshold goes as a Bulk API job, which a duplicate rule may refuse`),R));let y=await f;if(y===void 0)return ue.has(h)?(e.log(`[INFO] ${i}: ${h} goes through REST: the duplicate rules could not be read, and a standard rule watches it`),!0):!1;let w=y.has(h);return w&&e.log(`[INFO] ${i}: ${h} goes through REST: an active duplicate rule watches it, which a Bulk API job cannot waive`+(d>N?` \u2014 ${d} records in ${Math.ceil(d/Math.max(1,m))} calls, slower than one job`:"")),w};return async(h,d,m,y)=>{let w=(m.length>N||p.shouldUseBulkApi(m.length))&&await b(d,m.length,y),R=w&&await f===void 0?[`The org's duplicate rules could not be read (the user SandForge connects as needs View Setup and Configuration): ${d}, which a standard duplicate rule watches, was sent through REST, whose header lets its matches be saved, rather than as a Bulk API job.`]:[];if(m.length>N&&!w){if(o.aborted)return{successIds:[],errors:[],stopped:!0};let g=new le({signal:o}),s={connection:n,bulkManager:t,onProgress:(a,l)=>{e.onProgress(a,l,`Streaming insert ${d}`)},onOpened:a=>e.calls?.sending(d,m.length,{job:a})};e.calls?.sending(d,m.length);let u=await g.executeChunked(s,d,"insert",g.createChunkGenerator(m),m.length);return e.calls?.answered(d,u.aborted?[]:u.successIds),{successIds:u.successIds,errors:u.errors,...u.aborted?{stopped:!0}:{}}}if(p.shouldUseBulkApi(m.length)&&!w){if(o.aborted)return{successIds:[],errors:[],stopped:!0};let g={connection:n,bulkManager:t,onProgress:(a,l)=>{e.onProgress(a,l,`Bulk insert ${d}`)},signal:o,onOpened:a=>e.calls?.sending(d,m.length,{job:a})};e.calls?.sending(d,m.length);let s=await p.executeBulk(g,d,"insert",m);e.calls?.answered(d,s.aborted?[]:s.successIds);let u=we(s,m.length);return{successIds:s.successIds,errors:s.failures.map(a=>a.error),...u?{rows:u}:{},...s.aborted?{stopped:!0}:{}}}let A=[],S=[],c=[];for(let g=0;g<m.length;g+=y){if(o.aborted)return{successIds:A,errors:S,rows:c,stopped:!0};let s=m.slice(g,g+y);e.calls?.sending(d,s.length);let u=await r.execute(async()=>n.sobject(d).create(s,{headers:q()}));if(u.cancelled)return e.calls?.answered(d,[]),{successIds:A,errors:S,rows:c,stopped:!0};if(u.success&&u.result){let a=[];for(let l of u.result)if(l.success&&l.id)A.push(l.id),a.push(l.id),c.push({id:l.id});else{let E=Z(l.errors);S.push(E),c.push({error:E,errorDetails:(l.errors??[]).map(J)})}e.calls?.answered(d,a)}else{let a=u.error?.message??"Insert failed after retries";for(let l=0;l<s.length;l++)S.push(a),c.push({error:a});e.calls?.answered(d,[])}}return{successIds:A,errors:S,rows:c,...R.length>0?{notes:R}:{}}}}var Re="SELECT Id, DeveloperName FROM RecordType WHERE SobjectType = 'Account' AND IsPersonType = true";async function Ge(e){try{return(await e.query(Re)).records.flatMap(t=>typeof t.Id=="string"&&typeof t.DeveloperName=="string"?[{id:t.Id,developerName:t.DeveloperName}]:[])}catch{return[]}}function Ke(e,n,t){let r=new Set(e===$?t.map(o=>o.id.slice(0,15)):[]);return z(n).filter(o=>!o.master&&o.active&&o.available).map(o=>({recordTypeId:o.recordTypeId,developerName:o.developerName,label:o.name,person:r.has(o.recordTypeId.slice(0,15)),isDefault:o.defaultRecordTypeMapping}))}function Ae(e){let{staticValue:n,picklistValues:t}=e.config;return e.ruleType==="static"&&typeof n=="string"?[n]:e.ruleType==="picklist_random"?[...t??[]]:[]}function He(e,n){if(n.length===0)return{template:e,personObjects:[]};let t=new Map(n.map(i=>[i.id.slice(0,15),i.developerName])),r=[],o=[];for(let i of e.objects){if(i.objectApiName!==$){o.push(i);continue}let p=i.fieldRules.find(d=>d.fieldApiName==="RecordTypeId"),f=p?Ae(p):[],b=f.filter(d=>t.has(d.slice(0,15)));if(b.length>0&&b.length<f.length){let d=b.map(m=>t.get(m.slice(0,15))).join(", ");return{refusal:`${$}: ${d} ${b.length===1?"is a person account record type":"are person account record types"} and the other record types chosen are not: a person account and a business account take different fields. Seed one kind in a run.`}}let h=b.length>0?"person":"business";h==="person"&&r.push(i.objectApiName),o.push({...i,fieldRules:i.fieldRules.filter(d=>!W($,d.fieldApiName,h))})}return{template:{...e,objects:o},personObjects:r}}var ke=/^[a-z]{2,3}(?:_[A-Za-z0-9]{2,4}){0,2}$/;async function Ee(e){try{let t=(await e.query("SELECT DefaultLocaleSidKey FROM Organization LIMIT 1")).records[0]?.DefaultLocaleSidKey;return typeof t=="string"&&ke.test(t)?t:void 0}catch{return}}async function Ve(e,n){return e??await Ee(n)??"en_US"}var tt="SEED_FIT_STORAGE_UNREAD",rt="SEED_CANNOT_FIT";function nt(e,n=!1){return L(e.objects.filter(t=>t.recordCount>0).map(t=>t.objectApiName),n)}function L(e,n=!1){let t=new Set(e);return(r,o)=>t.has(r)&&(o==="insert"||o==="update"&&n&&r===fe)}function ot(e,n,t){if(typeof e.unread=="string")return{room:{perRecord:[],notCounted:[],unread:e.unread},unread:e.unread};let r=X(e,n,t);return{running:r,room:ie(r,t)}}function P(e,n){return I(e.objectApiName,n)?.distribution.mode==="byKey"?"byKey":e.rows!==void 0?"rows":void 0}function ge(e,n){let t=I(e,n.relations);if(!(!t||t.parents.kind!=="generated"||t.distribution.mode==="byKey"||t.parentObject===e||!n.objects.some(r=>r.objectApiName===t.parentObject)))return t}function he(e,n){let t=n?.objects?.[e.objectApiName]??n?.all;return t!==void 0?Math.min(e.recordCount,Math.max(1,Math.floor(t))):e.recordCount}function je(e,n,t){let r=new Map(e.objects.map(f=>[f.objectApiName,f])),o=new Map,i=new Set,p=f=>{let b=o.get(f);if(b!==void 0)return b;let h=r.get(f);if(P(h,e.relations))return o.set(f,h.recordCount),h.recordCount;i.add(f);let d=Math.round(n*he(h,t)),m=ge(f,e),y=m&&!i.has(m.parentObject)?Math.max(1,Math.min(d,_(m.distribution,p(m.parentObject)))):Math.max(1,d);return i.delete(f),o.set(f,y),y};return new Map(e.objects.map(f=>[f.objectApiName,p(f.objectApiName)]))}function $e(e,n){if(n.cannotFit!==void 0)return e;let t=new Map(n.objects.map(r=>[r.objectApiName,r.after]));return{...e,objects:e.objects.map(r=>{let o=t.get(r.objectApiName);return o!==void 0&&o<r.recordCount?{...r,recordCount:o}:r})}}function Te(e,n){let t=e.objects.filter(i=>!P(i,e.relations)),r=t.filter(i=>!ge(i.objectApiName,e)),o;for(let i of r.length>0?r:t){let p=he(i,n);(!o||p>o.records)&&(o={objectApiName:i.objectApiName,records:p})}return o}function Oe(e){return`${e} record${e===1?"":"s"}`}function xe(e){let{template:n,personObjects:t,budget:r,room:o}=e,i=e.ask?.caps,p=e.ask?.share===!0||i===void 0,f=a=>{let l=je(n,a,i),E=$e(n,{objects:n.objects.map(k=>({objectApiName:k.objectApiName,before:k.recordCount,after:l.get(k.objectApiName)??k.recordCount}))}),j=ae(o,k=>l.get(k)??0);return{counts:l,bytes:pe(E,t)+j,roomBytes:j,requests:me(E,e.path),records:[...l.values()].reduce((k,x)=>k+x,0)}},b=a=>a.bytes<=r.bytes,h=a=>r.runRequests===void 0||a.requests<=r.runRequests,d=a=>b(a)&&h(a),m=(a,l,E,j)=>({share:a,budget:{...de(r,l.roomBytes,o),...E==="apiRequests"?{limitedBy:"apiRequests"}:{}},objects:n.objects.map(k=>{let x=P(k,n.relations);return{objectApiName:k.objectApiName,before:k.recordCount,after:l.counts.get(k.objectApiName)??k.recordCount,...x?{keptWhole:x}:{}}}),estimateMB:l.bytes/1048576,...j!==void 0?{cannotFit:j}:{},...o.unread!==void 0?{automationUnread:o.unread}:{}}),y=(a,l,E,j)=>({proposal:m(a,l,E,j),heldBy:E,records:l.records,requests:l.requests}),w=a=>{if(b(a))return`about ${a.requests} API requests, past the ${r.runRequests??0} that leave the org a tenth of its daily requests`;let l=se(a.bytes/1048576,r.bytes/1048576);return`${l.over} MB`+(a.roomBytes>0?", room for what the org's automation creates under them included":"")+`, past the ${l.bound} MB that fit`},R=a=>b(a)?"apiRequests":r.terms.limitedBy,A=n.objects.filter(a=>P(a,n.relations)).reduce((a,l)=>a+l.recordCount,0),S=f(1);if(d(S)){let a=n.objects.some(l=>(S.counts.get(l.objectApiName)??0)<l.recordCount);return y(1,S,a?"caps":"whole")}if(!p)return y(1,S,R(S),`with these caps the seed takes ${w(S)}: lower them, or fit by share`);let c=Te(n,i);if(!c)return y(1,S,R(S),`the ${A} rows the template gives take ${w(S)}, and rows are kept whole`);let g=a=>f(a/c.records),s=B(c.records,a=>d(g(a)));if(s===0){let a=g(1);return y(1/c.records,a,R(a),`the least it can be cut to \u2014 one ${c.objectApiName} and what follows it`+(A>0?`, with the ${A} rows the template gives kept whole`:"")+`, ${Oe(a.records)} \u2014 takes ${w(a)}`)}let u=B(c.records,a=>b(g(a)));return y(s/c.records,g(s),u>s?"apiRequests":r.terms.limitedBy)}function st(e,n,t,r,o){if(!("unread"in e))return xe({template:n,personObjects:t,budget:e,room:r,path:o}).proposal}function it(e,n){if(!(!e||e.before<n))return{module:"seed",share:e.share,...e.withinMB!==void 0?{withinMB:e.withinMB}:{},kept:n,inSource:e.before}}var Se=(e,n)=>n==="insert";function be(e){return typeof e.unread=="string"}function Ce(e){return(U(e).find(t=>t.write==="insert")?.fired??[]).map(t=>{let r=t.flow,o=r?.messages??[];return{kind:t.kind,name:t.name,when:t.when,emails:o.filter(i=>i.kind==="email").length,messages:[...new Set(o.flatMap(i=>i.kind==="email"?[]:[i.kind]))],creates:[...r?.creates??[]],afterCommit:(r?.paths?.length??0)>0,bypasses:(r?.permissions??[]).filter(i=>i.bypass).map(({name:i,held:p})=>p===void 0?{name:i}:{name:i,held:p}),keptQuiet:t.keptQuiet===!0,unread:r!==void 0&&r.condition!=="read"}})}function O(e){return[...new Set(e)].sort((n,t)=>n.localeCompare(t))}function ye(e,n,t,r,o=Se){let i=e.objects.flatMap(c=>{let g=Ce(c);return g.length>0?[{objectApiName:c.objectApiName,entries:g}]:[]}),p=be(t)?void 0:t,f=p!==void 0&&re(p),b=p!==void 0&&ne(p),h=M(C(e),f,b),d=i.flatMap(c=>c.entries.flatMap(g=>g.bypasses)),m=O(d.filter(c=>c.held===!0).map(c=>c.name)),y=O(d.map(c=>c.name)).filter(c=>!m.includes(c)),w=K(e,y),R=y.map(c=>{let g=w.find(s=>s.permission.toLowerCase()===c.toLowerCase())?.permissionSet;return g?{permission:c,permissionSet:g.name}:{permission:c}}),A=H(e,o),S=A.assign.length>0;return{org:n,objectsRead:[...e.objectsRead],objects:i,emailsPerRecord:h,...p&&h.length>0?{limits:{...p}}:{},...be(t)?{limitsUnread:t.unread}:{},alertsAsSingle:f,bypasses:R,bypassesHeld:m,...S?{mute:A,emailsPerRecordMuted:M(C(V(e,Q(A))),f,b)}:{},unread:e.unread.map(({part:c,reason:g})=>({part:c,reason:g})),blinded:G(e.unread),conditionsNotRead:e.conditionsNotRead,...r?{deliverability:r}:{}}}async function pt(e){let n=e.writes??L(e.objects),t;try{t=await e.readAutomation(e.objects)}catch(i){return{error:F(i)}}let r=e.deliverability??(e.readDeliverability?(await te({read:t,writes:Se,readDeliverability:e.readDeliverability,accepted:!1,target:e.org,run:"seed"})).gate.deliverability:void 0);if(C(t).length===0)return{preview:ye(t,e.org,{},r,n)};let o=await e.readLimits().catch(i=>({unread:F(i)}));return{preview:ye(t,e.org,o,r,n)}}function T(e,n="and"){return e.length<=1?e.join(""):e.length===2?`${e[0]} ${n} ${e[1]}`:`${e.slice(0,-1).join(", ")}, ${n} ${e[e.length-1]}`}var ft="SEED_EMAILS_EXCEEDED";function gt(e,n,t){if("error"in e)return{checks:[],unknown:[`what ${t} runs as these records are created could not be read (${e.error}): the emails they make it send are not known`]};let{preview:r}=e,o={objects:n.map(s=>({objectApiName:s.objectApiName,rows:s.recordCount,storageBytes:0}))},i=r.limitsUnread!==void 0?{unread:r.limitsUnread}:r.limits??{},p=oe(o,r.emailsPerRecord,i),f=new Set(n.filter(s=>s.recordCount>0).map(s=>s.objectApiName)),b=r.objects.flatMap(s=>f.has(s.objectApiName)?s.entries.filter(u=>u.unread&&!u.keptQuiet&&u.when!=="before").map(u=>`"${u.name}" on ${s.objectApiName}`):[]),h=[...p.filter(s=>s.verdict==="unread").map(s=>`about ${v(s.emails,s.limit)}, but what ${t} has left today could not be read (${s.unread??"not said"})`),...r.blinded?[`part of what ${t} runs could not be read: emails it sends may not be counted`]:[],...b.length>0?[`the emails of ${T(b)} are not counted: what ${b.length===1?"it does":"they do"} was not read`]:r.conditionsNotRead>0?[`${r.conditionsNotRead} start condition(s) of ${t} not read: the emails of those flows are not counted`]:[]],d=p.find(s=>s.verdict==="exceeds");if(!d)return h.length>0?{checks:p,unknown:h}:{checks:p};let m=p.filter(s=>s.verdict==="exceeds"),y=O(m.flatMap(s=>s.objects.map(u=>u.objectApiName))),w=O(m.flatMap(s=>s.objects.flatMap(u=>u.sentBy))),R=new Map;for(let s of r.objects.flatMap(u=>u.entries))if(!(s.emails===0||!w.includes(s.name)))for(let{name:u}of s.bypasses)R.set(u,(R.get(u)??new Set).add(s.name));let A=r.bypasses.flatMap(s=>{let u=R.get(s.permission);return u?[{...s,quiets:O([...u])}]:[]}),S=m.map(s=>`about ${v(s.emails,s.limit)} (`+s.objects.map(u=>`${u.perRecord} per ${u.objectApiName}`).join(", ")+`), ${s.remaining??0} of ${s.max??0} left today`).join("; "),c=["lower the record counts",`set ${T(y)} to 0`,`turn off ${T(w.map(s=>`"${s}"`))}`,...A.map(s=>"give the user the seed writes as "+(s.permissionSet?`the permission set ${s.permissionSet}, whose ${s.permission}`:`a permission set holding ${s.permission}, which`)+` keeps ${T(s.quiets.map(u=>`"${u}"`))} quiet`)],g=`The seed was refused before it wrote anything: its records would make ${t} send ${S}. Past what is left, a flow that sends in the save refuses its record (CANNOT_EXECUTE_FLOW_TRIGGER), and the org's own emails stop for the rest of the day. To seed it, ${T(c,"or")}. Nothing was written.`;return{checks:p,refusal:g,figures:{org:t,limit:d.limit,emails:d.emails,remaining:d.remaining??0,max:d.max??0,objects:y,senders:w,bypasses:A},...h.length>0?{unknown:h}:{}}}var Pe={flow:e=>`flow "${e}"`,trigger:e=>`Apex trigger ${e}`,process:e=>`process "${e}"`,workflowRule:e=>`workflow rule "${e}"`},Ie={before:"before save",after:"after save",beforeAndAfter:"before and after save"},Fe={notification:"custom notifications",outbound:"outbound messages",sms:"text messages"};function Me(e){let n=r=>r.held===!0?" (held)":r.held===!1?" (not held)":"",t=[Ie[e.when],...e.emails>0?[`${e.emails} email(s) a record`]:[],...e.messages.map(r=>`sends ${Fe[r]}`),...e.creates.length>0?[`creates ${e.creates.join(", ")}`]:[],...e.afterCommit?["then after commit"]:[],...e.bypasses.length>0?[`not for a user with ${e.bypasses.map(r=>r.name+n(r)).join(", ")}`]:[],...e.keptQuiet?["quiet for this seed"]:[],...e.unread?["what it does was not read"]:[]];return`${Pe[e.kind](e.name)} (${t.join("; ")})`}function ht(e,n){if("error"in e)return[`target automation: what ${n} runs as these records are created could not be read (${e.error}): the emails they make it send are not known`];let{preview:t}=e,r=[`target automation: what ${n} runs as these records are created`];for(let o of t.objects)r.push(` ${o.objectApiName}: ${o.entries.map(Me).join(", ")}`);t.objects.length===0&&r.push(t.blinded?" nothing found in what could be read":" nothing runs on them: no flow, Apex trigger, process or workflow rule"),t.bypassesHeld.length>0&&r.push(` bypass held: the user the seed writes as holds ${t.bypassesHeld.join(", ")}, and what names it stays quiet`);for(let o of t.bypasses)r.push(o.permissionSet?` bypass: ${o.permission} keeps quiet what names it; permission set ${o.permissionSet} holds it`:` bypass: ${o.permission} keeps quiet what names it; no permission set of ${n} was found to hold it`);t.alertsAsSingle&&t.emailsPerRecord.some(o=>o.alertsAmong)&&r.push(` ${n} counts its email alerts against its single emails too, as a Developer Edition does`);for(let{part:o,reason:i}of t.unread)r.push(` ${o} could not be read: ${i}`);return t.conditionsNotRead>0&&r.push(` ${t.conditionsNotRead} start condition(s) not read`),r}export{_e as a,Ge as b,Ke as c,He as d,Ve as e,tt as f,rt as g,nt as h,L as i,ot as j,$e as k,xe as l,st as m,it as n,pt as o,ft as p,gt as q,ht as r};
|
package/lib/chunk-PA3MKJVH.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{wb as C,xb as O}from"./chunk-B45CNPUX.mjs";import{b as y,f as b,l as R}from"./chunk-7EANH5PY.mjs";var j=["User","Group","Profile","UserRole","RecordType","Organization","Queue","PermissionSet","BusinessProcess","CurrencyType","DandBCompany","DuplicateRecordItem","DuplicateRecordSet","ProcessInstance","LoginHistory","LoginEvent","LoginIp","LoginGeo","AsyncApexJob","ApexLog","ApexTestResult","ApexTestQueueItem","LightningUsageByPageMetrics","LightningExitByPageMetrics","EventBusSubscriber","PlatformEventUsageMetric","CronTrigger","CronJobDetail","AttachedContentDocument","AttachedContentNote","CombinedAttachment","ContentBody","NoteAndAttachment","OwnedContentDocument","EntitySubscription","TopicAssignment","UserRecordAccess","DeclinedEventRelation","UndecidedEventRelation","AcceptedEventRelation","OpenActivity","ActivityHistory","AppUsageAssignment","AuthProvider","Folder","ContentDocument","ContentDocumentLink","OpportunityRelatedDeleteLog","CaseHistory2","Calendar","SlaProcess","AccountCleanInfo","ContactCleanInfo","LeadCleanInfo","ApprovalSubmission","ApprovalSubmissionDetail","ApprovalWorkItem","AIRecordInsight","AIInsightValue","MatchingInformation","Invoice","InvoiceLine","CreditMemo","CreditMemoLine","AppDefinition","BackgroundOperation","ContentTaxonomyTermRelationshipType","Dashboard","DashboardComponent","DeleteEvent","ManagedContentChannel","ManagedContentSpace","ManagedContentVariant","Report","ServiceSetupProvisioning","TabDefinition"],v=new Set(j.map(e=>e.toLowerCase())),P=["History","Feed","Share","ChangeEvent","__hd","__Tag","EventStore"].map(e=>e.toLowerCase()),F=/^vlocity_[a-z0-9]+__/;function W(e,t){return I(e,t,{byNamespace:!0})}function I(e,t,r){let n=e.toLowerCase();return v.has(n)||C(e)||t&&(t.has(e)||B(t).has(n))||r.byNamespace&&F.test(n)?!0:P.some(s=>n.endsWith(s))}var w=new WeakMap;function B(e){let t=w.get(e);if(t&&t.size===e.size)return t.names;let r=new Set([...e].map(n=>n.toLowerCase()));return w.set(e,{size:e.size,names:r}),r}function U(e,t){return O(e)||W(e,t)}function E(e){return O(e)||I(e,void 0,{byNamespace:!1})}function x(e,t=[]){let r=new Set(t);for(let n of e)n.createable===!1&&r.add(n.name);return r}function ce(e,t=r=>U(r)){return new Set(e.filter(r=>{let n=r.referenceTo??[];return n.length>0&&n.every(s=>t(s))}).map(r=>r.name))}var fe=R({name:y(),queryable:b().optional(),createable:b().optional(),updateable:b().optional(),deletable:b().optional(),undeletable:b().optional(),customSetting:b().optional(),layoutable:b().optional(),keyPrefix:y().nullish()}).loose(),D="ContentDocument",z="ContentDocumentLink",G="ContentVersion",L="Attachment",H=[D,L],J=new Set(["feeditem","feedcomment","feedattachment"]),K=new Set(["casehistory2"]),V=new Set(["AccountCleanInfo","ContactCleanInfo","LeadCleanInfo","ApprovalSubmission","ApprovalSubmissionDetail","ApprovalWorkItem","ProcessInstance","ProcessInstanceNode","ProcessInstanceStep","ProcessInstanceWorkitem","AIRecordInsight","AIInsightValue","AIInsightAction","AIInsightFeedback","AIInsightReason","MatchingInformation","Invoice","InvoiceLine","CreditMemo","CreditMemoLine","CreditMemoInvApplication"].map(e=>e.toLowerCase())),X=new Set([G,z].map(e=>e.toLowerCase())),Y=["__b","__x","__dlm","__kav","__ka","__e"],Q=new Set(["AccountContactRole",L,"CaseTeamMember","EmailMessageRelation","EventRelation","OpportunityCompetitor"].map(e=>e.toLowerCase()));function Z(e,t,r,n,s){let o=e.name.toLowerCase();return J.has(o)||o.endsWith("feed")?"chatter":o.endsWith("history")||o.endsWith("__hd")||K.has(o)?"history":o.endsWith("share")?"sharing":o.endsWith("changeevent")?"changeEvent":Y.some(a=>o.endsWith(a))?"unsupportedKind":e.customSetting===!0?n?A(e,s)?void 0:"notWritable":"customSetting":X.has(o)?"heldWithFiles":o===D.toLowerCase()?(s==="delete"?_(e):T(e))?void 0:"notWritable":o===L.toLowerCase()?A(e,s)?void 0:"notWritable":C(e.name)?"files":V.has(o)?"platformCreated":E(e.name)||r==="everything"&&e.layoutable===!1&&!Q.has(o)?"setup":t.out.has(o)?t.tooling.has(o)?"metadata":"notWritable":A(e,s)?void 0:"notWritable"}function A(e,t){return t==="delete"?_(e):$(e)}function $(e){return e.createable===!0&&T(e)}function _(e){return e.queryable===!0&&e.deletable===!0}function T(e){return e.queryable===!0&&e.updateable===!0&&e.deletable===!0}function k(e,t){return e.objectApiName<t.objectApiName?-1:e.objectApiName>t.objectApiName?1:0}var q="all";function ee(e){return e.customSetting===!0}function te(e,t){let r=e.filter(ee);if(t===void 0)return{held:new Set,unknown:[]};if(t===q)return{held:new Set(r.map(a=>a.name.toLowerCase())),unknown:[]};let n=new Set(r.map(a=>a.name.toLowerCase())),s=new Set,o=[];for(let a of t){let p=a.toLowerCase();s.has(p)||o.some(u=>u.toLowerCase()===p)||(n.has(p)?s.add(p):o.push(a))}return{held:s,unknown:o}}function me(e,t,r=[]){let n=t.access??"write",s=n==="delete"?r:x(e,r),o={out:new Set([...s].map(c=>c.toLowerCase())),tooling:new Set(r.map(c=>c.toLowerCase()))},a=new Set((t.excluded??[]).map(c=>c.toLowerCase())),p=new Map(e.map(c=>[c.name.toLowerCase(),c])),u=te(e,t.customSettings),g=u.unknown.map(c=>({objectApiName:c,reason:"notCustomSetting"})),m=[],f=[],i=[];if(t.mode==="picked"){let c=new Set;for(let d of t.objects??[]){let l=d.toLowerCase();if(c.has(l))continue;c.add(l);let h=p.get(l);h?f.push(h):g.push({objectApiName:d,reason:"notFound"})}for(let d of H){let l=d.toLowerCase(),h=p.get(l);if(!(c.has(l)||h===void 0)){if(a.has(l)){g.push({objectApiName:h.name,reason:"excludedByUser"});continue}f.push(h),i.push(h.name)}}for(let d of u.held){let l=p.get(d);c.has(d)||l===void 0||(c.add(d),f.push(l))}}else f.push(...p.values());for(let c of f){let d=c.name.toLowerCase(),l=a.has(d)?"excludedByUser":Z(c,o,t.mode,u.held.has(d),n);l===void 0?m.push(c.name):g.push({objectApiName:c.name,reason:l})}return m.sort(),g.sort(k),{mode:t.mode,candidates:m,leftOut:g,addedToPicked:i}}function ge(e){return e.fields.find(r=>r.name==="Name")?.nillable===!0?"hierarchy":"list"}function he(e){return e==="hierarchy"?"SetupOwnerId":"Name"}function be(e){return e.objects.some(t=>t.customSetting!==void 0)}function ne(e){let t=e.split("__");return t.length>=3&&t[0]!==""?t[0]:void 0}var oe=()=>({first:"child",firmness:0});function re(e,t,r=oe){let n=new Map(e.map((o,a)=>[o.toLowerCase(),a])),s=e.map(()=>new Map);return e.forEach((o,a)=>{for(let p of t.get(o)?.childRelationships??[]){let u=n.get(p.childSObject.toLowerCase());if(u===void 0||u===a)continue;let g=r(p);if(g===void 0)continue;let[m,f]=g.first==="child"?[u,a]:[a,u],i=s[m].get(f);(i===void 0||g.firmness>i)&&s[m].set(f,g.firmness)}}),N(e.map((o,a)=>a),s,Number.NEGATIVE_INFINITY).map(o=>e[o])}function N(e,t,r){let n=new Set(e),s=f=>[...t[f]].filter(([i,c])=>n.has(i)&&c>r).map(([i])=>i),o=ie(e,s,t.length),a=new Map;o.forEach((f,i)=>{for(let c of f)a.set(c,i)});let p=o.map(()=>0),u=o.map(()=>new Set);for(let f of e){let i=a.get(f)??0;for(let c of s(f)){let d=a.get(c)??0;d===i||u[i].has(d)||(u[i].add(d),p[d]++)}}let g=o.map(()=>!1),m=[];for(let f=o.length;f>0;f--){let i=-1;for(let d=0;d<o.length;d++){if(g[d]||p[d]>0)continue;let l=o[d].length===1,h=i>=0&&o[i].length===1;(i<0||l&&!h||l===h&&o[d][0]<o[i][0])&&(i=d)}g[i]=!0;let c=o[i];if(c.length===1)m.push(c[0]);else{let d=Number.POSITIVE_INFINITY;for(let l of c)for(let[h,S]of t[l])S>r&&a.get(h)===i&&S<d&&(d=S);m.push(...N(c,t,d))}for(let d of u[i])p[d]--}return m}function ie(e,t,r){let n=new Array(r).fill(-1),s=new Array(r).fill(0),o=new Array(r).fill(!1),a=[],p=[],u=0;for(let g of e){if(n[g]>=0)continue;let m=[],f=i=>{n[i]=u,s[i]=u,u++,a.push(i),o[i]=!0,m.push({node:i,edges:t(i),at:0})};for(f(g);m.length>0;){let i=m[m.length-1];if(i.at<i.edges.length){let l=i.edges[i.at++];n[l]<0?f(l):o[l]&&(s[i.node]=Math.min(s[i.node],n[l]));continue}m.pop();let c=m[m.length-1];if(c&&(s[c.node]=Math.min(s[c.node],s[i.node])),s[i.node]!==n[i.node])continue;let d=[];for(let l=a.pop();l!==void 0&&(o[l]=!1,d.push(l),l!==i.node);l=a.pop());p.push(d.sort((l,h)=>l-h))}}return p}function M(e){let t=new Map;for(let{objectApiName:r,namespace:n}of e)n!==void 0&&t.set(n,[...t.get(n)??[],r]);return[...t].sort(([r],[n])=>r<n?-1:r>n?1:0).map(([r,n])=>({namespace:r,objects:n.sort()}))}function se(e,t){return re(e,t).map((r,n)=>{let s=ne(r);return{objectApiName:r,readOrder:n,...s===void 0?{}:{namespace:s}}})}function Ce(e,t,r=new Map){let n=[...e.leftOut],s=[];for(let a of e.candidates){let p=t.get(a);if(p)p.fields.some(u=>u.name==="SystemModstamp")?p.fields.some(u=>u.name==="IsDeleted")?s.push(a):n.push({objectApiName:a,reason:"noRecycleBin"}):n.push({objectApiName:a,reason:"noSystemModstamp"});else{let u=r.get(a);n.push({objectApiName:a,reason:"notDescribed",...u===void 0?{}:{detail:u}})}}let o=se(s,t);return{mode:e.mode,objects:o,leftOut:n.sort(k),packages:M(o)}}function Se(e,t){if(t.size===0)return e;let r=[...e.leftOut],n=[];for(let s of e.objects){let o=t.get(s.objectApiName);o===void 0?n.push({...s,readOrder:n.length}):r.push({objectApiName:s.objectApiName,reason:"unreadable",detail:o})}return{...e,objects:n,leftOut:r.sort(k),packages:M(n)}}export{W as a,U as b,E as c,x as d,ce as e,fe as f,D as g,z as h,G as i,L as j,H as k,q as l,ee as m,me as n,ge as o,he as p,be as q,ne as r,re as s,Ce as t,Se as u};
|
package/lib/chunk-RH3N2H7P.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{Vb as a,Xb as d}from"./chunk-B45CNPUX.mjs";async function T(t){let e=(await t.query("SELECT Id, IsSandbox FROM Organization LIMIT 1")).records[0];if(typeof e?.Id!="string")throw new Error("The org gave no Organization record: whether it is a sandbox cannot be told.");if(e.IsSandbox===!0)return{id:e.Id,sandbox:!0};try{let r=(await t.query("SELECT OrganizationType FROM Organization LIMIT 1")).records[0]?.OrganizationType;return typeof r=="string"&&r!==""?{id:e.Id,sandbox:!1,edition:r}:{id:e.Id,sandbox:!1}}catch{return{id:e.Id,sandbox:!1}}}function b(t){let n=a({isSandbox:t.sandbox,edition:t.edition});return d(n,t.edition)==="production"}var c=/\/services\/Soap\//,u=/\/services\/data\/v\d+\.\d+\/jobs\/(?:ingest|query)(?:[/?]|$)/,p=/^\/jobs\/(?:ingest|query)(?:[/?]|$)/;function f(t){let n=typeof t=="string"?t:t?.url??"";return u.test(n)||p.test(n)}function g(t){let n=0;if(typeof t.request!="function")return()=>n;let e=t._transport,o=t.request.bind(t);if(t.request=(...r)=>((e===void 0||!f(r[0]))&&n++,o(...r)),e!==void 0){let r=e.httpRequest.bind(e);e.httpRequest=(...i)=>{let s=i[0].url;return(c.test(s)||u.test(s))&&n++,r(...i)}}return()=>n}export{T as a,b,g as c};
|