sandforge 0.0.0-stage → 1.79.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/LICENSE +21 -0
- package/README.md +54 -2
- package/THIRD-PARTY-NOTICES.md +1624 -0
- package/bin/sandforge-autopilot.mjs +12 -0
- package/bin/sandforge-backup.mjs +12 -0
- package/bin/sandforge-checkpoint.mjs +12 -0
- package/bin/sandforge-cleanup.mjs +12 -0
- package/bin/sandforge-clone.mjs +12 -0
- package/bin/sandforge-compare.mjs +12 -0
- package/bin/sandforge-dataops.mjs +12 -0
- package/bin/sandforge-empty.mjs +12 -0
- package/bin/sandforge-env.mjs +12 -0
- package/bin/sandforge-frozen.mjs +12 -0
- package/bin/sandforge-mcp.mjs +12 -0
- package/bin/sandforge-monitor.mjs +12 -0
- package/bin/sandforge-seed.mjs +12 -0
- package/bin/sandforge-sync.mjs +12 -0
- package/bin/sandforge.mjs +12 -0
- package/lib/catalogue.en.json +1 -0
- package/lib/chunk-2BVTCNWA.mjs +7 -0
- package/lib/chunk-2S5OMIIA.mjs +7 -0
- package/lib/chunk-2YIV2OB2.mjs +7 -0
- package/lib/chunk-342FN7AO.mjs +9 -0
- package/lib/chunk-36U7IQ6Y.mjs +25 -0
- package/lib/chunk-3CA767QB.mjs +7 -0
- package/lib/chunk-3DCUADVK.mjs +7 -0
- package/lib/chunk-3F5YMM2F.mjs +7 -0
- package/lib/chunk-3OHPD72J.mjs +9 -0
- package/lib/chunk-3RYLICRX.mjs +7 -0
- package/lib/chunk-3SRXFZSD.mjs +7 -0
- package/lib/chunk-42RER7V4.mjs +14 -0
- package/lib/chunk-4GL773D5.mjs +7 -0
- package/lib/chunk-4HFRHFGQ.mjs +7 -0
- package/lib/chunk-4HW535YJ.mjs +7 -0
- package/lib/chunk-4NAHW2D3.mjs +7 -0
- package/lib/chunk-4SNDMJP2.mjs +7 -0
- package/lib/chunk-4TLYUZD5.mjs +7 -0
- package/lib/chunk-4U6NXJNL.mjs +7 -0
- package/lib/chunk-4XZ5YT5O.mjs +7 -0
- package/lib/chunk-55HEMHEG.mjs +7 -0
- package/lib/chunk-57VHUYNG.mjs +10 -0
- package/lib/chunk-5AJRHRXA.mjs +20 -0
- package/lib/chunk-5CD257T7.mjs +7 -0
- package/lib/chunk-5HMAPZBV.mjs +7 -0
- package/lib/chunk-5LFSFYFJ.mjs +7 -0
- package/lib/chunk-5MMXFWPD.mjs +7 -0
- package/lib/chunk-5O6JOMHS.mjs +13 -0
- package/lib/chunk-5P4PHJRL.mjs +9 -0
- package/lib/chunk-5QKTYCWE.mjs +11 -0
- package/lib/chunk-66NMFCWX.mjs +7 -0
- package/lib/chunk-6EBMEGZB.mjs +7 -0
- package/lib/chunk-6LAXTAVN.mjs +7 -0
- package/lib/chunk-6MUEPV7M.mjs +9 -0
- package/lib/chunk-6QSM2WIH.mjs +10 -0
- package/lib/chunk-75ADZS6B.mjs +7 -0
- package/lib/chunk-7EANH5PY.mjs +68 -0
- package/lib/chunk-7F54PZUS.mjs +7 -0
- package/lib/chunk-7UQD6V6F.mjs +7 -0
- package/lib/chunk-AAVJ5XVX.mjs +7 -0
- package/lib/chunk-ALJVEUUS.mjs +7 -0
- package/lib/chunk-ALUFROGA.mjs +7 -0
- package/lib/chunk-AR7BE5O2.mjs +7 -0
- package/lib/chunk-AUTM6H6Z.mjs +7 -0
- package/lib/chunk-AV5SWEHP.mjs +9 -0
- package/lib/chunk-B45CNPUX.mjs +47 -0
- package/lib/chunk-BILZ3SSR.mjs +7 -0
- package/lib/chunk-BN7A4GRQ.mjs +7 -0
- package/lib/chunk-BOGNK4LV.mjs +7 -0
- package/lib/chunk-BS5T3MOQ.mjs +7 -0
- package/lib/chunk-BZ24IAP5.mjs +7 -0
- package/lib/chunk-CA5NAXSU.mjs +7 -0
- package/lib/chunk-CE6ZDGBB.mjs +7 -0
- package/lib/chunk-CGWXQX75.mjs +7 -0
- package/lib/chunk-CHCHAE4B.mjs +7 -0
- package/lib/chunk-D3QRXG63.mjs +787 -0
- package/lib/chunk-DBFJB2B6.mjs +7 -0
- package/lib/chunk-DLDX6RRC.mjs +7 -0
- package/lib/chunk-EADHKH3A.mjs +7 -0
- package/lib/chunk-EEVVGGM6.mjs +7 -0
- package/lib/chunk-ENLBYECD.mjs +7 -0
- package/lib/chunk-EQF2IJS2.mjs +11 -0
- package/lib/chunk-EQOQASDQ.mjs +7 -0
- package/lib/chunk-F2424IKX.mjs +7 -0
- package/lib/chunk-F74IHMGL.mjs +7 -0
- package/lib/chunk-FOVVHGEP.mjs +7 -0
- package/lib/chunk-FQBRBBY4.mjs +7 -0
- package/lib/chunk-FQGHL7GR.mjs +259 -0
- package/lib/chunk-GAM726CK.mjs +7 -0
- package/lib/chunk-GCOB7K5N.mjs +7 -0
- package/lib/chunk-GMY5427L.mjs +7 -0
- package/lib/chunk-GNC27UEU.mjs +7 -0
- package/lib/chunk-H2PJNIYJ.mjs +7 -0
- package/lib/chunk-H45UXY6G.mjs +7 -0
- package/lib/chunk-HCIDVIOW.mjs +7 -0
- package/lib/chunk-HF6LAK3G.mjs +7 -0
- package/lib/chunk-HJC7AIBK.mjs +7 -0
- package/lib/chunk-HJKM3E56.mjs +7 -0
- package/lib/chunk-HTJ5OGP5.mjs +7 -0
- package/lib/chunk-HUMEKZT5.mjs +8 -0
- package/lib/chunk-HV2MXMGI.mjs +7 -0
- package/lib/chunk-HXS7ORUF.mjs +11 -0
- package/lib/chunk-I3JKJTLO.mjs +110 -0
- package/lib/chunk-I7O6C2B5.mjs +8 -0
- package/lib/chunk-IAZB4WIL.mjs +7 -0
- package/lib/chunk-IC2C2GOF.mjs +8 -0
- package/lib/chunk-IEYG5ATY.mjs +7 -0
- package/lib/chunk-INIQ23K6.mjs +7 -0
- package/lib/chunk-INIT2UKJ.mjs +7 -0
- package/lib/chunk-J7HVXMSW.mjs +7 -0
- package/lib/chunk-JVL444U5.mjs +7 -0
- package/lib/chunk-K22PA4XL.mjs +7 -0
- package/lib/chunk-K2FBZIXY.mjs +7 -0
- package/lib/chunk-KLX67VPL.mjs +7 -0
- package/lib/chunk-L776PUMV.mjs +7 -0
- package/lib/chunk-LQ4DRFUH.mjs +9 -0
- package/lib/chunk-LRFAIUN7.mjs +7 -0
- package/lib/chunk-LV6G4XTK.mjs +7 -0
- package/lib/chunk-M6P5ZZLE.mjs +7 -0
- package/lib/chunk-MTMH6H2A.mjs +8 -0
- package/lib/chunk-MYTIL2JD.mjs +10 -0
- package/lib/chunk-NEVXIGR6.mjs +10 -0
- package/lib/chunk-NGSMZZDA.mjs +7 -0
- package/lib/chunk-NHWE66K5.mjs +7 -0
- package/lib/chunk-NM4MDLK4.mjs +7 -0
- package/lib/chunk-NTDN2JQZ.mjs +19 -0
- package/lib/chunk-NTOVCTRS.mjs +7 -0
- package/lib/chunk-NZ5ZZLKS.mjs +7 -0
- package/lib/chunk-OQOZAPCI.mjs +7 -0
- package/lib/chunk-OTWRDD6L.mjs +7 -0
- package/lib/chunk-P2PJYWGQ.mjs +7 -0
- package/lib/chunk-P42X3B4D.mjs +7 -0
- package/lib/chunk-P7GSGFJO.mjs +7 -0
- package/lib/chunk-PA3MKJVH.mjs +7 -0
- package/lib/chunk-PBI4BYWW.mjs +7 -0
- package/lib/chunk-PNCONNFJ.mjs +10 -0
- package/lib/chunk-PTTHSSQO.mjs +7 -0
- package/lib/chunk-PUOX4NBJ.mjs +8 -0
- package/lib/chunk-PZTSVQSF.mjs +7 -0
- package/lib/chunk-QPF6C5MX.mjs +7 -0
- package/lib/chunk-QQZZMKU3.mjs +7 -0
- package/lib/chunk-QROPNEGY.mjs +14 -0
- package/lib/chunk-QRV2OSIS.mjs +7 -0
- package/lib/chunk-QSRAEUGZ.mjs +7 -0
- package/lib/chunk-QWT2C74M.mjs +7 -0
- package/lib/chunk-RAAANPPG.mjs +7 -0
- package/lib/chunk-RACDTRZA.mjs +7 -0
- package/lib/chunk-RFEO2KAN.mjs +7 -0
- package/lib/chunk-RH3N2H7P.mjs +7 -0
- package/lib/chunk-RSWDYIHY.mjs +37 -0
- package/lib/chunk-RSYICMZG.mjs +8 -0
- package/lib/chunk-SAR5622P.mjs +7 -0
- package/lib/chunk-SBIMVCXT.mjs +101 -0
- package/lib/chunk-SCKUIE3R.mjs +7 -0
- package/lib/chunk-SFURUNJM.mjs +7 -0
- package/lib/chunk-SIOZXPFG.mjs +7 -0
- package/lib/chunk-SRPWW4A2.mjs +10 -0
- package/lib/chunk-SRQDABQ2.mjs +15 -0
- package/lib/chunk-SVS6UMDU.mjs +323 -0
- package/lib/chunk-T63U4OZJ.mjs +7 -0
- package/lib/chunk-TBZMC2VV.mjs +11 -0
- package/lib/chunk-TEOLMRDO.mjs +7 -0
- package/lib/chunk-TLH7AD35.mjs +7 -0
- package/lib/chunk-TNXUU6W7.mjs +14 -0
- package/lib/chunk-TQX3PURV.mjs +7 -0
- package/lib/chunk-TUACWKIH.mjs +7 -0
- package/lib/chunk-TW3N6W5Z.mjs +7 -0
- package/lib/chunk-TYYOBZMU.mjs +10 -0
- package/lib/chunk-TZE3Y7IQ.mjs +7 -0
- package/lib/chunk-UNDIBZWG.mjs +7 -0
- package/lib/chunk-VGW4MXXZ.mjs +7 -0
- package/lib/chunk-VHI54FBK.mjs +441 -0
- package/lib/chunk-VXHDBYMI.mjs +7 -0
- package/lib/chunk-W7KFAY55.mjs +7 -0
- package/lib/chunk-WFEB5X4U.mjs +8 -0
- package/lib/chunk-WIO4XO4F.mjs +7 -0
- package/lib/chunk-WJY54JO7.mjs +13 -0
- package/lib/chunk-WR2GIKWE.mjs +7 -0
- package/lib/chunk-WRU5FJFC.mjs +7 -0
- package/lib/chunk-X2PY6MWZ.mjs +7 -0
- package/lib/chunk-X65MT4W3.mjs +7 -0
- package/lib/chunk-XBG5SP6Q.mjs +7 -0
- package/lib/chunk-XCA5AONB.mjs +7 -0
- package/lib/chunk-XEFDB2R4.mjs +7 -0
- package/lib/chunk-XETCPL7E.mjs +7 -0
- package/lib/chunk-Y5CGXLUB.mjs +7 -0
- package/lib/chunk-Y6J6QFI2.mjs +7 -0
- package/lib/chunk-YAZO75G2.mjs +8 -0
- package/lib/chunk-YBU4Z4QV.mjs +7 -0
- package/lib/chunk-YMJVMFPY.mjs +7 -0
- package/lib/chunk-YPSRZRIT.mjs +7 -0
- package/lib/chunk-YS4G22C2.mjs +7 -0
- package/lib/chunk-YW2SBL4Z.mjs +7 -0
- package/lib/chunk-YYZL7UGV.mjs +7 -0
- package/lib/chunk-Z7X534S4.mjs +10 -0
- package/lib/chunk-ZE6HKRR4.mjs +9 -0
- package/lib/chunk-ZHJP7L3K.mjs +7 -0
- package/lib/chunk-ZJKCWBRJ.mjs +7 -0
- package/lib/chunk-ZLZRU6MO.mjs +7 -0
- package/lib/chunk-ZOVSMN5C.mjs +7 -0
- package/lib/chunk-ZPYJPGDK.mjs +7 -0
- package/lib/chunk-ZQOZ4EFW.mjs +7 -0
- package/lib/chunk-ZUTYVST5.mjs +7 -0
- package/lib/chunk-ZXH4MBWP.mjs +7 -0
- package/lib/chunk-ZYEE34WO.mjs +7 -0
- package/lib/sandforge-autopilot.mjs +157 -0
- package/lib/sandforge-backup.mjs +99 -0
- package/lib/sandforge-checkpoint.mjs +353 -0
- package/lib/sandforge-cleanup.mjs +56 -0
- package/lib/sandforge-clone.mjs +7 -0
- package/lib/sandforge-compare.mjs +54 -0
- package/lib/sandforge-dataops.mjs +7 -0
- package/lib/sandforge-empty.mjs +140 -0
- package/lib/sandforge-env.mjs +355 -0
- package/lib/sandforge-frozen.mjs +263 -0
- package/lib/sandforge-mcp.mjs +40 -0
- package/lib/sandforge-monitor.mjs +43 -0
- package/lib/sandforge-seed.mjs +7 -0
- package/lib/sandforge-sync.mjs +7 -0
- package/lib/sandforge.mjs +28 -0
- package/package.json +52 -4
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import"./chunk-NTOVCTRS.mjs";var p=new Set(["ApexClass","ApexTrigger","Flow","ValidationRule","CustomObject","CustomField"]),u=class s{diff(e,o,a,i=new Map){let t=[],r=new Set([...e.keys(),...o.keys()]);for(let d of r){let n=e.get(d),m=o.get(d),f=i.get(d);n!==void 0&&m===void 0?t.push(s.createItem(a,d,"removed",n,void 0)):n===void 0&&m!==void 0?t.push(s.createItem(a,d,"added",void 0,m)):f!==void 0?t.push({...s.createItem(a,d,"not_compared",void 0,void 0),notComparedReason:f}):n!==m?t.push(s.createItem(a,d,"modified",n,m)):t.push(s.createItem(a,d,"unchanged",n,m))}return t}diffFields(e,o){let a=[],i=new Set([...Object.keys(e),...Object.keys(o)]);for(let t of i){let r=e[t]??"",d=o[t]??"";t in e?t in o?r!==d&&a.push({fieldPath:t,sourceValue:r,targetValue:d,status:"modified"}):a.push({fieldPath:t,sourceValue:r,targetValue:"",status:"removed"}):a.push({fieldPath:t,sourceValue:"",targetValue:d,status:"added"})}return a}computeSummary(e){let o=0,a=0,i=0,t=0,r=0,d={};for(let n of e){switch(n.status){case"added":o++;break;case"removed":a++;break;case"modified":i++;break;case"unchanged":t++;break;case"not_compared":r++;break}if(s.isChange(n.status)){d[n.componentType]||(d[n.componentType]={added:0,removed:0,modified:0});let m=d[n.componentType];n.status==="added"?m.added++:n.status==="removed"?m.removed++:n.status==="modified"&&m.modified++}}return{totalItems:e.length,added:o,removed:a,modified:i,unchanged:t,notCompared:r,byType:d}}computeCoverage(e,o,a=0){let i={unreadable:0,read_failed:0,over_budget:0},t=0;for(let r of e)r.status==="modified"||r.status==="unchanged"?t++:r.status==="not_compared"&&r.notComparedReason!==void 0&&i[r.notComparedReason]++;return{compared:t,notCompared:i,...a>0?{managedLeftOut:a}:{},budget:{...o}}}static isChange(e){return e==="added"||e==="removed"||e==="modified"}static determineSeverity(e,o){return!s.isChange(e)||e==="removed"?"info":p.has(o)?"breaking":"warning"}static isDeployable(e){return s.isChange(e)}static createItem(e,o,a,i,t){return{componentType:e,fullName:o,status:a,sourceValue:i,targetValue:t,severity:s.determineSeverity(a,e),deployable:s.isDeployable(a)}}};export{u as DiffEngine};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-3RYLICRX.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{a as AGENT_CATALOG_API,b as AGENT_CATALOG_FIELDS,c as AGENT_TEST_NAME_FIELD,i as GUARD_TOPIC_NAMES,e as NO_AGENTFORCE_MESSAGE,d as NO_AGENT_MESSAGE,g as agentNamed,k as declaresVariable,h as proposedActions,j as proposedGuardTopic,f as readAgentCatalog};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a as y,b as g}from"./chunk-EQF2IJS2.mjs";import{a as S,b as f,c as p}from"./chunk-IAZB4WIL.mjs";import{b as u}from"./chunk-CA5NAXSU.mjs";import{ha as d}from"./chunk-B45CNPUX.mjs";var h="SELECT ApiName, MasterLabel, IsClosed, IsDefault, SortOrder FROM CaseStatus ORDER BY SortOrder",w="SELECT MasterLabel, IsClosed, IsDefault, SortOrder FROM CaseStatus ORDER BY SortOrder",A="Closed";async function k(a){let e;try{e=await a(h)}catch{try{e=await a(w)}catch(t){return m(`the org would not read its case statuses: ${u(t)}`)}}let r=e.flatMap(t=>{let n=b(t.ApiName)??b(t.MasterLabel);return n===void 0?[]:[{value:n,closed:t.IsClosed===!0,isDefault:t.IsDefault===!0}]}),o=r.filter(t=>!t.closed),i=r.filter(t=>t.closed);return o.length===0||i.length===0?m(o.length===0?"the org has no case status that leaves a case open":"the org has no case status that closes a case"):{open:(o.find(t=>t.isDefault)??o[0]).value,closed:(i.find(t=>t.value===A)??i[0]).value,from:"org"}}function m(a){return{...d.caseStatus,from:"default",reason:a}}function b(a){return typeof a=="string"&&a.trim()!==""?a:void 0}var c=S;async function E(a,e){let r;try{r=await a(c)}catch{r={access:"createable"}}if(r.access==="absent")return{available:!1,reason:r.reason??`the org has no ${c}`};if(r.access==="readOnly")return{available:!1,reason:r.reason??`the user this seed runs as may read ${c} and not create it`};try{return{available:!0,bodyFields:f(await e(c))}}catch{return{available:!0,bodyFields:[]}}}var P=["Status","Origin","Priority","Type"];async function T(a){let e;try{e=(await a("Case")).fields}catch{return}let r={};for(let o of P){let t=(e.find(n=>n.name===o)?.picklistValues??[]).filter(n=>n.active!==!1).map(n=>n.value);t.length>0&&(r[o]=t)}return r}function v(a,e){let r=e.knowledge.available?e.knowledge.bodyFields:[],o=r.map(s=>s.name),i=e.articleBodyField===void 0?r[0]:r.find(s=>s.name===e.articleBodyField);if(e.articleBodyField!==void 0&&i===void 0)return{issues:[`options.articleBodyField: ${e.articleBodyField} is not a field of ${c} this org lets a body be written to`+(o.length>0?` (${o.join(", ")})`:"")]};let t=e.knowledge.available?{available:!0,bodyFields:o}:e.knowledge,n={seed:e.seed??d.seed,caseStatus:{open:e.caseStatus.open,closed:e.caseStatus.closed},...i!==void 0?p(i):{}},l;try{l=g(a,n)}catch(s){if(s instanceof y)return{issues:s.issues};throw s}return{preparation:{options:n,objects:[...l.template.objects].sort((s,C)=>s.insertOrder-C.insertOrder).map(s=>({objectApiName:s.objectApiName,recordCount:s.recordCount,...s.optional===!0?{optional:!0}:{}})),tests:l.tests.length,caseStatusFrom:e.caseStatus.from==="org"?{from:"org"}:{from:"default",reason:e.caseStatus.reason},knowledge:t}}}function D(a){return async e=>{let r=await a.query(e),o=[...r.records];for(;!r.done&&r.nextRecordsUrl;)r=await a.queryMore(r.nextRecordsUrl),o.push(...r.records);return o}}export{h as a,w as b,k as c,c as d,E as e,T as f,v as g,D as h};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{J as H}from"./chunk-6QSM2WIH.mjs";import{b as k,c as ie,d as $}from"./chunk-OTWRDD6L.mjs";import{i as oe}from"./chunk-INIT2UKJ.mjs";import{h as Y}from"./chunk-TZE3Y7IQ.mjs";import{b as S}from"./chunk-CA5NAXSU.mjs";var ye=5,pe=100;function y(t){return t.slice(0,15)}function L(t){return t==null||t===""}var ae=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;function he(t,n){if(L(t)||L(n))return L(t)&&L(n);if(typeof t=="number"||typeof n=="number")return Number(t)===Number(n);if(typeof t=="string"&&typeof n=="string"){if(t===n)return!0;if(ae.test(t)&&ae.test(n)){let a=Date.parse(t);return Number.isFinite(a)&&a===Date.parse(n)}return!1}return JSON.stringify(t)===JSON.stringify(n)}function me(t){let n;return()=>(n??=(async()=>{try{let a=await t.userId?.();return typeof a=="string"&&a!==""?y(a):void 0}catch{return}})(),n)}async function de(t){let n=Date.now();try{let a=Date.parse(await t.serverTime());return Number.isFinite(a)?a-(n+Date.now())/2:0}catch{return 0}}async function Ie(t,n){let a=Date.parse(n??"");return Number.isFinite(a)?a+await de(t)+H:Number.NEGATIVE_INFINITY}var be=1e3;function Re(t){let n=Date.parse(t);return Number.isFinite(n)?n-be:Number.NEGATIVE_INFINITY}function ke(t,n){let a=Object.hasOwn(t,n)?t[n]:[];return new Map(a.filter(c=>c.toLowerCase()!=="id").map(c=>[c.toLowerCase(),c]))}var Ae={INACTIVE_OWNER_OR_USER:"OwnerId"};function Oe(t,n){let a=new Set;for(let s of t.errors??[]){if(typeof s=="string")continue;if(Array.isArray(s.fields))for(let p of s.fields)typeof p=="string"&&a.add(p);let f=s.statusCode!==void 0?Ae[s.statusCode]:void 0;f!==void 0&&(!Array.isArray(s.fields)||s.fields.length===0)&&a.add(f)}let c=new Map(Object.keys(n).map(s=>[s.toLowerCase(),s]));return[...a].flatMap(s=>{let f=c.get(s.toLowerCase());return f!==void 0&&f!=="Id"?[f]:[]})}function ve(t,n){let a=Array.isArray(t)?t:[t];return Array.from({length:n},(c,s)=>a[s]??{success:!1})}function J(t){let n=t.errors?.[0];if(n===void 0)return{words:"The org gave no reason."};if(typeof n=="string")return{words:n};let a=n.statusCode,c=n.message??"";return{...a?{code:a}:{},words:a&&c?`${a}: ${c}`:a||c}}function P(t,{fields:n,why:a}){return`${n.map(c=>`${t}.${c}`).join(", ")}: the value from before is no longer taken (${a}) \u2014 left as the run wrote it`}async function je(t,n,a){let c=new Set;try{for(let s of $(a)){let f=await t.query(`SELECT Id FROM ${n} WHERE Id IN (${s})`);for(let p of f.records)typeof p.Id=="string"&&c.add(y(p.Id))}}catch(s){return{unread:S(s)}}return{live:c}}var Q=class{result;said=new Set;constructor(n,a){this.result={objectApiName:n,planned:a,restored:0,keptChanged:0,alreadyGone:0,refused:0,notKept:0,reasons:[]}}without(){this.result.restoredWithout=(this.result.restoredWithout??0)+1}reason(n){this.said.has(n)||this.said.size>=ye||(this.said.add(n),this.result.reasons.push(n))}};async function De(t){let{org:n,plan:a}=t,c=[],s=[],f={},p=!1,I=!1;if(a.length===0)return{objects:c,left:s,wrote:p,cancelled:I,stamps:f};let M=t.changedAfter!==void 0?Re(t.changedAfter):await Ie(n,t.lastWriteAt),R=new Map(Object.entries(t.stamps??{}).map(([h,_])=>[y(h),Date.parse(_)])),F=t.ownWriters&&t.ownWriters.length>0?new Set(t.ownWriters.map(y)):void 0,W=t.stampsFor,ce=me(n);for(let{objectApiName:h,backup:_,ids:C}of a){let u=new Q(h,C.length);c.push(u.result);let B=t.unkept?.find(e=>e.objectApiName===h);if(B&&B.fields.length>0&&u.reason(`${B.fields.map(e=>`${h}.${e}`).join(", ")}: not kept, encrypted \u2014 the run's user cannot view encrypted data, and read their values from before masked; left as the run wrote them`),I||t.signal?.aborted){I=!0,u.result.notReached=C.length,s.push(...C);continue}let x=Y(h),m=new Map(C.map(e=>[y(e),e])),U=t.fields?ke(t.fields,h):void 0,O=new Map,G=new Set;try{let e=await t.backups.batches(_,h,k);for await(let r of e??[])for(let o of r){if(typeof o.Id!="string"||!m.has(y(o.Id)))continue;let i=O.get(y(o.Id))??{};for(let[l,d]of Object.entries(o)){if(l==="Id")continue;let g=U?U.get(l.toLowerCase()):l;g!==void 0&&!(g in i)&&(i[g]=d)}if(U&&Object.keys(i).length===0){G.add(y(o.Id));continue}O.set(y(o.Id),i)}}catch(e){u.reason(`The values from before the run could not be read: ${S(e)}`),O.clear(),G.clear()}let X=[...G].filter(e=>!O.has(e)).length;X>0&&u.reason(`${X} ${h} record(s) hold no value of a field that may be written back now: left as they are`);for(let e of[...m.keys()])O.has(e)||(u.result.notKept++,m.delete(e));if(m.size===0)continue;let Z=new Set;for(let e of O.values())for(let r of Object.keys(e))Z.add(Y(r));let ee=["Id","LastModifiedDate",...F?["LastModifiedById"]:[],...Z],ue=ee.length>pe?k/4:k,q=new Map,fe=async e=>{if(t.signal?.aborted)throw new T;return(await n.query(e)).records};try{for(let e of $([...m.values()],ue)){let r=await oe(`SELECT ${ee.join(", ")} FROM ${x} WHERE Id IN (${e})`,fe,{stamp:"LastModifiedDate"});for(let o of r)typeof o.Id=="string"&&q.set(y(o.Id),o)}}catch(e){if(e instanceof T){I=!0,u.result.notReached=m.size,s.push(...m.values());continue}u.result.refused+=m.size,u.reason(S(e)),s.push(...m.values());continue}let D=[],te=new Set,le=W?Date.now()+await de(n)-H:0;for(let[e,r]of m){let o=q.get(e);if(!o){u.result.alreadyGone++,t.counted?.(r,"alreadyGone");continue}let i=Date.parse(String(o.LastModifiedDate??"")),l=o.LastModifiedById,d=i<=M||i<=(R.get(e)??Number.NaN)||F!==void 0&&typeof l=="string"&&F.has(y(l));if(!d&&!t.includeChanged){u.result.keptChanged++,s.push(r);continue}let g=O.get(e)??{},w={Id:o.Id};for(let[b,A]of Object.entries(g))he(A,o[b])||(w[b]=L(A)?null:A);if(Object.keys(w).length===1){u.result.restored++,t.counted?.(r,"restored"),d&&W?.(r)&&typeof o.LastModifiedDate=="string"&&(f[o.Id]=o.LastModifiedDate);continue}D.push(w),d&&W?.(r)&&te.add(r)}let j=[],v=[],E=(e,r)=>{u.result.refused++,u.reason(r),s.push(m.get(y(e.Id))??e.Id)},z=e=>{u.result.restored++,t.counted?.(m.get(y(e.Id))??e.Id,"restored")},ge=e=>{u.result.alreadyGone++,t.counted?.(m.get(y(e.Id))??e.Id,"alreadyGone")},ne=e=>{I=!0,u.result.notReached=(u.result.notReached??0)+e.length,s.push(...e.map(r=>m.get(y(r.Id))??r.Id))},re=(e,r,o,i)=>{let l=Object.keys(e).filter(w=>w!=="Id"&&!r.includes(w));if(l.length>0){let w={Id:e.Id};for(let b of l)w[b]=e[b];j.push({record:w,leftOut:o});return}if(o.length===0){z(e);return}let[d,...g]=o;i?(u.without(),u.reason(P(h,d))):E(e,P(h,d));for(let w of g)u.reason(P(h,w))},K=async e=>{try{return p=!0,ve(await n.update(h,[...e]),e.length)}catch(r){let o=S(r);return e.map(()=>({success:!1,errors:[o]}))}},we=async e=>{let r=t.keep;if(!r)return!0;let o=e.map(i=>{let l=q.get(y(i.Id))??{},d={Id:i.Id};for(let g of Object.keys(i))g!=="Id"&&(d[g]=l[g]??null);return d});try{return await r(h,o),!0}catch(i){let l=`What these ${e.length} ${h} record(s) hold now could not be kept before they were written (${S(i)}), so none of them was written: nothing is written over that cannot be put back.`;for(let d of e)E(d,l);return!1}};for(let e=0;e<D.length;e+=k){let r=D.slice(e,e+k);if(t.signal?.aborted){I=!0;let i=D.slice(e);u.result.notReached=(u.result.notReached??0)+i.length,s.push(...i.map(l=>m.get(y(l.Id))??l.Id));break}if(!await we(r))continue;(await K(r)).forEach((i,l)=>{let d=r[l];if(i.success===!0){z(d);return}let g=J(i),w=Oe(i,d);if(g.code==="ENTITY_IS_DELETED"&&w.length===0){v.push({record:d,why:g.words});return}let b=Object.keys(d).filter(A=>A!=="Id"&&!w.includes(A));if(w.length>0&&b.length>0){let A={Id:d.Id};for(let se of b)A[se]=d[se];j.push({record:A,leftOut:[{fields:w,why:g.words}]});return}E(d,g.words)})}let N=[];if(v.length>0&&t.signal?.aborted)ne(v.map(({record:e})=>e));else if(v.length>0){let e=await je(n,x,v.map(({record:r})=>r.Id));e.unread!==void 0&&u.reason(`Whether ${v.length} ${h} record(s) refused as deleted are still in the org could not be read (${e.unread}): left to be given back again`);for(let{record:r,why:o}of v){if(e.unread!==void 0){E(r,o);continue}if(!e.live.has(y(r.Id))){ge(r);continue}let i=Object.keys(r).filter(l=>l!=="Id"&&ie(r[l]));i.length===0?E(r,o):i.length===1?re(r,i,[{fields:i,why:o}],!1):N.push({record:r,lookups:i,given:[],refusedAlone:[]})}}let V=N.length>0;for(let e=0;V&&N.some(({lookups:r})=>r.length>e);e++){let r=N.filter(({lookups:o})=>o.length>e);for(let o=0;o<r.length;o+=k){if(t.signal?.aborted){ne(N.map(({record:d})=>d)),V=!1;break}let i=r.slice(o,o+k);(await K(i.map(({record:d,lookups:g})=>({Id:d.Id,[g[e]]:d[g[e]]})))).forEach((d,g)=>{let w=i[g],b=w.lookups[e];d.success===!0?w.given.push(b):w.refusedAlone.push({field:b,why:J(d).words})})}}for(let e of V?N:[]){let r=new Map;for(let{field:o,why:i}of e.refusedAlone)r.set(i,[...r.get(i)??[],o]);re(e.record,e.lookups,[...r].map(([o,i])=>({fields:i,why:o})),e.given.length>0)}for(let e=0;e<j.length;e+=k){let r=j.slice(e,e+k);if(t.signal?.aborted){I=!0,u.result.notReached=(u.result.notReached??0)+j.length-e,s.push(...j.slice(e).map(({record:i})=>m.get(y(i.Id))??i.Id));break}(await K(r.map(({record:i})=>i))).forEach((i,l)=>{let{record:d,leftOut:g}=r[l];if(i.success===!0){if(g.length===0){z(d);return}u.without();for(let w of g)u.reason(P(h,w));return}E(d,J(i).words)})}Object.assign(f,await Ee(n,x,[...te],le,ce))}return{objects:c,left:s,wrote:p,cancelled:I,stamps:f}}async function Ee(t,n,a,c,s){let f={};if(a.length===0)return f;let p=await s();if(p===void 0)return f;for(let I of $(a)){let M;try{M=(await t.query(`SELECT Id, LastModifiedDate, LastModifiedById FROM ${n} WHERE Id IN (${I})`)).records}catch{continue}for(let R of M)typeof R.Id=="string"&&typeof R.LastModifiedDate=="string"&&typeof R.LastModifiedById=="string"&&y(R.LastModifiedById)===p&&Date.parse(R.LastModifiedDate)>=c&&(f[R.Id]=R.LastModifiedDate)}return f}var T=class extends Error{};function $e(t,n,a=[]){let c=t.map(s=>({...s}));for(let s of a){if(s.undeleted+s.refused===0)continue;let f=c.find(p=>p.objectApiName===s.objectApiName);f?(f.created+=s.undeleted,f.failed+=s.refused):c.push({objectApiName:s.objectApiName,created:s.undeleted,updated:0,deleted:0,failed:s.refused})}for(let s of n){let f=s.restored+(s.restoredWithout??0);if(f+s.refused===0)continue;let p=c.find(I=>I.objectApiName===s.objectApiName);p?(p.updated+=f,p.failed+=s.refused):c.push({objectApiName:s.objectApiName,created:0,updated:f,deleted:0,failed:s.refused})}return c}export{he as a,me as b,de as c,Ie as d,De as e,Ee as f,$e as g};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a as je,b as Ne,c as Pe,d as Fe,k as We,l as xe,o as Le,q as _e}from"./chunk-TBZMC2VV.mjs";import{e as Me}from"./chunk-LQ4DRFUH.mjs";import{b as De,f as Te}from"./chunk-57VHUYNG.mjs";import{m as Be}from"./chunk-5O6JOMHS.mjs";import{b as Se}from"./chunk-KLX67VPL.mjs";import{i as he,j as we,k as ke,l as ye,m as be,p as Re,q as Ae}from"./chunk-342FN7AO.mjs";import{A as Ie,B as $e,C as ve,z as Ue}from"./chunk-Z7X534S4.mjs";import{$ as Ce,C as ge,_ as Oe}from"./chunk-6QSM2WIH.mjs";import{a as le,b as fe}from"./chunk-SAR5622P.mjs";import{s as pe}from"./chunk-6MUEPV7M.mjs";import{b as ue,d as ce}from"./chunk-OTWRDD6L.mjs";import{Ba as Ee,s as me}from"./chunk-VXHDBYMI.mjs";import{g as L,h as _,q as de}from"./chunk-PA3MKJVH.mjs";import{b as x}from"./chunk-CA5NAXSU.mjs";import{Kc as se,Sc as W}from"./chunk-B45CNPUX.mjs";var C=class extends Error{constructor(){super("The undo was stopped before it wrote anything to the org."),this.name="UndoStopped"}},z="No record was written.",Je="accept that it runs to undo the rewind all the same";function ze(e){return e.slice(0,15)}function Ke(e){return{query:n=>e.query(n),queryMore:n=>e.queryMore(n)}}function Ye(e,n,t){if(e.kind==="org")return;let a=e.userKey;if(n.users.some(i=>i.slice(0,15)!==a))return{code:"PERMISSIONS",message:`This rewind was made as another user than ${t}: what it deleted is that user's deletion in the recycle bin, which Salesforce brings back only for a user with View All Data and Modify All Data. Undo it as the user it was made as, or as a user with View All Data and Modify All Data. ${z}`};let r=n.objects.flatMap(i=>{let l=e.notHeld.get(i);return l===void 0?[]:[`${i}: ${l}`]});if(r.length!==0)return{code:"PERMISSIONS",message:`Undo takes back what the rewind did to objects ${t} no longer holds whole (${r.join("; ")}), and does not stop part way: an undo left part way could not be offered again. Undo it once the user has View All and Modify All on them again, or as a user with View All Data and Modify All Data. ${z}`}}function Qe(e,n){return{undone:!1,refusal:{code:e,message:n}}}function Xe(e,n){return{code:"RUN_WRITING",message:`${n.operation==="take"?`A checkpoint of ${e} is being taken`:n.operation==="rewind"?`A rewind is writing to ${e}`:n.operation==="undo"?`An undo is writing to ${e}`:`SandForge is deleting checkpoints of ${e}`} (process ${n.pid} on ${n.host}): undo the rewind once it has ended. No record was read or written.`}}function Ze(e,n,t,a){let r=W(n,t),i=[...new Set(r.map(b=>b.objectApiName))],l=(t.setToDraft??[]).length>0?", sets an order back to Draft":"",h=r.length>0?`${Me(r)} flow(s), trigger(s) or rule(s) of ${i.join(", ")} run as the undo brings records back, gives them their values back${l} or sends them back to the recycle bin`:"what runs as the undo writes could not all be read, so automation may run";return{code:"AUTOMATION",message:`${e}: ${h}. ${ke("undo",a)}Undo refused; ${Je}. ${z}`}}async function et(e,n){let t=0,a=0;for await(let r of n.bringBack.pages(L)){t+=r.length;for(let i of ce(r,ue)){let l=await e.queryDeleted(`SELECT Id, ContentSize FROM ${L} WHERE Id IN (${i}) AND IsDeleted = true`);for(let h of l.records)typeof h.ContentSize=="number"&&(a+=h.ContentSize)}}return{files:t,bytes:a}}function tt(e,n){return e.status==="cancelled"||e.status==="failure"?e.status:n.some(t=>t.reason==="changedDuringRewind")?"unstable":e.status}function nt(e,n){return e.map(t=>{let a=Object.keys(t.by).filter(i=>!n.has(ze(i)));if(a.length===0)return{objectApiName:t.objectApiName,reason:"automation",count:t.count,ids:[...t.ids]};let r=a.length===1&&a[0]!=="unknown"?a[0]:void 0;return{objectApiName:t.objectApiName,reason:"changedDuringRewind",...r!==void 0?{by:r}:{},count:t.count,ids:[...t.ids]}})}async function Ot(e,n){let{checkpoint:t,folder:a,orgName:r,rewindId:i}=n,l=e.signal,h=()=>l?.aborted===!0,b=(U,k)=>e.onProgress?.({percentage:U,step:k}),c=_e(e.org,e.undelete),T,S=await Se(Ke(c.org),{act:"undo",orgName:r,registered:n.registered,username:n.username,organizationId:t.org.organizationId,customSettings:de(t)},{userId:async()=>T=await c.org.userId()});if(!S.allowed)return{undone:!1,refusal:S.refusal};let R=e.store.lock(t.org.organizationId,"undo",t.checkpointId);if("busy"in R)return{undone:!1,refusal:Xe(r,R.busy)};try{let U=await e.runWriting?.(S.org.id);if(U!==void 0)return Qe("RUN_WRITING",U);let k=await Ie(c.org,r);if(h())throw new C;b(5,"Reading what the rewind did");let g=await Ne(a,i,t.objects),G=Pe(g),M=g.goesWithParent.objects,Ge=g.remade.keys.size>0?"Sending back to the recycle bin what the rewind brought back, and deleting again what it made again":"Sending back to the recycle bin what the rewind brought back",A=o=>o.filter(u=>u.count>0).map(u=>u.objectApiName),j=g.links,q=o=>o>0?[_]:[],N=g.remade.objects.filter(({objectApiName:o,count:u})=>u>0&&ge([o]).length>0),m={bringBack:A(g.bringBack.objects),giveBack:[...A(g.giveBack.objects),...q(j?.share.count??0)],...N.length>0?{setToDraft:A(N)}:{},delete:[...new Set([...A(M),...A(g.remove.objects),...q(j?.remove.count??0)])],...(j?.reinsert.count??0)>0?{recreate:[_]}:{}},H;try{H=await et(c.org,g)}finally{await g.dispose()}let V=ve("undo",H,k.fileStorage?.remaining,r);if(V)return{undone:!1,refusal:V};let w=[...new Set([...m.bringBack??[],...m.giveBack??[],...m.setToDraft??[],...m.delete??[],...m.recreate??[]])],P;try{P=await De({grants:S.grants,...T!==void 0?{userId:T}:{},username:n.username,checkpoint:t,reader:Ce(c.org,l)})}catch(o){throw o instanceof Oe||h()?new C:o}if(P.kind==="perObject"){let o=await je(a,i),u=Ye(P,{users:o.passes.map(f=>f.userId),objects:w},n.username);if(u)return{undone:!1,refusal:u}}let d;if(w.length>0&&e.readAutomation){try{d=await e.readAutomation(w)}catch(o){d=Le(w,x(o))}c.add(d.requests)}let I=d,y=w.length>0?await We(e.mute,d,m):{},$="refusal"in y?y:void 0,J="refusal"in y?void 0:y.mute;y.automation&&(d=y.automation);let v=$?$.plan:J?.plan,K=n.acceptEmails===!0,p=w.length>0&&I?await Re({act:"undo",orgName:r,automation:I,steps:m,...v?{plan:v}:{},accepted:K,mayMute:e.mute===void 0&&n.canMute===!0,read:()=>me(c.org)}):void 0,Y=he(G,M,N),Q=d?we(Y,d):void 0,O=$?[$.refusal]:[];d&&!n.acceptAutomation&&(W(d,m).length>0||se(d.unread)||Q!==void 0)&&O.push(Ze(r,d,m,Q));let X=Ue({objects:t.objects,rewound:G,along:M,automationRequests:0}),Z=Ee(p?.ofRun),ee=$e("undo",{run:c.used()-(Z.deliverability??0)+X.apiRequests,...Z},k,r);w.length>0&&ee&&O.push(ee);let te=d?be("undo",ye(Y,d,k.emails),r):void 0;w.length>0&&te&&O.push(te),p?.refusal&&O.push(p.refusal);let[ne,...oe]=O;if(ne)return{undone:!1,refusal:ne,...oe.length>0?{alsoRefused:oe}:{}};if(h())throw new C;let qe=await c.org.userId(),He=new Set(Te(t.takenBy,qe).map(ze));b(20,"Bringing back what the rewind deleted and giving back what it wrote over");let B,E;try{E=await xe(J,`undo ${t.checkpointId} ${i}`,o=>{let u=o&&v&&I&&p?Ae({act:"undo",orgName:r,automation:I,steps:m,plan:v,held:o.outcome,planned:p.ofRun.senders,...p.ofRun.read?{reading:p.ofRun.read.reading}:{},accepted:K}):void 0;return u?Promise.resolve({relit:u}):Fe({folder:a,rewindId:i,lock:R.lock,objects:t.objects,org:c.org,undelete:c.undelete,splitting:le(fe(k.remaining,c.used()+X.apiRequests)),...l?{signal:l}:{},...e.onUndeletable?{onUndeletable:e.onUndeletable}:{},onProgress:(f,ae,Ve)=>b(20+Math.round(70*f/Math.max(ae,1)),`${Ge}: ${Ve} ${f} / ${ae}`)})},o=>{B=o})}catch(o){if(!pe(o))throw o;return{undone:!1,refusal:{code:"MUTE",message:`${o.message} No record was written.`}}}if("relit"in E)return{undone:!1,refusal:E.relit};let s=E,re=nt(s.residual,He),D=tt(s,re),F=[...s.notes];if(D!=="cancelled"&&D!=="failure"){let o=(e.now??(()=>new Date))().toISOString();try{await e.store.update(t.checkpointId,f=>f.lastRewind?.rewindId===i?{...f,lastRewind:{...f.lastRewind,undoneAt:o}}:f)}catch(f){F.push(`The checkpoint could not be told the rewind was undone (${x(f)}): its list may still offer to undo it.`)}let u=await Be({folder:a,lock:R.lock,checkpoint:t,rewindId:i,status:D,undoneAt:o});u!==void 0&&F.push(u)}let ie=c.used();return{undone:!0,result:{checkpointId:t.checkpointId,rewindId:i,status:D,deleted:s.deleted,...s.remade?{remade:s.remade}:{},...s.carriedAlone?{carriedAlone:s.carriedAlone}:{},...s.wentAlong?{wentAlong:s.wentAlong}:{},restored:s.restored,undeleted:s.undeleted,...s.files?{files:s.files}:{},residual:re,passes:1,apiRequests:{used:ie,leftToday:Math.max(0,k.remaining-ie)},finishedAt:s.finishedAt,...B?{mutedAutomation:B}:{}},notes:F,...p?.gate.audit!==void 0?{deliverability:p.gate.audit}:{}}}finally{R.lock.release()}}export{C as a,Je as b,Ot as c};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{i as d}from"./chunk-3OHPD72J.mjs";import{i as s,j as c}from"./chunk-PUOX4NBJ.mjs";import{access as p}from"node:fs/promises";import*as l from"node:path";var u="sfdx-project.json";async function w(n,e=g){for(let t of n)if(await e(l.join(t,u)))return{kind:"dx",dir:t};let r=n[0];return r===void 0?{kind:"none"}:{kind:"folder",dir:r}}async function g(n){try{return await p(n),!0}catch{return!1}}async function S(n,e){if(e.project.kind==="none")return{kind:"unavailable",reason:"no-workspace",message:"Open a folder in VS Code: the test file is written into it."};let r=await c(n.sidecar,e.storagePath,e.runId);if(r.kind==="absent")return{kind:"unavailable",reason:"no-companion",message:"This run kept no companion file: it was not seeded from a scenario, or it wrote no open case for a test to be about."};if(r.kind==="invalid")return{kind:"unavailable",reason:"companion-invalid",message:r.message};let{sidecar:t}=r,o=await e.findPack(t.packId,t.packFingerprint);if(!o)return{kind:"unavailable",reason:"pack-not-found",message:`The scenario ${t.packId} this run was seeded from is no longer in the workspace as it was: its tests would be about subjects and addresses no record of the run holds.`};let i=await e.readCatalog();if(i.kind==="no-agent")return{kind:"no-agent",reason:i.reason,message:i.message};if(i.kind==="unreadable")return{kind:"unavailable",reason:"catalog-unreadable",message:i.message};let a=await d(n.spec,{sidecar:t,pack:o,catalog:i.catalog,choice:e.choice,projectDir:e.project.dir,alias:e.alias,...e.overwrite!==void 0?{overwrite:e.overwrite}:{}});if(a.kind==="refused")return a;if(a.kind==="exists")return{kind:"exists",path:a.path,specPath:a.specPath};await s(n.sidecar,e.storagePath,a.sidecar).catch(()=>{});let f=e.project.kind==="dx";return{kind:"written",path:a.path,specPath:a.specPath,apiName:a.apiName,...f?{commands:{create:a.commands.create.line,run:a.commands.run.line}}:{notDxProject:!0},leftOut:a.leftOut}}export{u as a,w as b,S as c};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{h as M,i as T}from"./chunk-NM4MDLK4.mjs";import{o as b}from"./chunk-ZUTYVST5.mjs";import{Eb as _,Fb as h,Gb as p,Hb as R,Lb as C,Mb as S,Pb as k}from"./chunk-B45CNPUX.mjs";async function Y(r,e){try{let[c,i]=await Promise.all([r(R),e(R)]),d=c[0]?.Id,a=i[0]?.Id;return typeof d=="string"&&typeof a=="string"?{source:d,target:a}:void 0}catch{return}}function v(r,e){return r===h||e.some(c=>typeof c[p]=="string")}var K=[p,C,S];function A(r,e,c,i,d=()=>!1){let a={...e,standsFor:new Map,standardFirst:0,standardMatched:!1,prices:[],leftIn:new Map};if(!c)return a;let o=e.records.map((t,s)=>s),m=t=>({records:t.map(s=>e.records[s]),sources:t.map(s=>e.sources[s]),sourceIds:t.map(s=>e.sourceIds[s])});if(r===h){let t=o.filter(s=>e.sourceIds[s]!==c.source);return t.length===o.length?a:{...m(t),standsFor:new Map,standardFirst:0,standardMatched:!0,prices:[],leftIn:new Map}}if(r!==_)return a;let l=o,I=new Map,P=new Map,O=[];if(i){let{target:t}=i,s=e.sources.filter(n=>!K.some(f=>{let u=n[f];return typeof u=="string"&&u!==""&&d(u)})),E=n=>t.active.has(n)?n:b(void 0,t)?.to,g=M({prices:s,standardBookId:c.source,sellingModels:s.some(n=>typeof n[S]=="string"),writtenIn:E,active:t.active},[]),B=new Set(g.standsFor.keys());l=o.filter(n=>{let f=e.sourceIds[n];return f===void 0||!B.has(f)});let D=new Map(s.map(n=>[n.Id,n[k]]));for(let[n,f]of g.standsFor){I.set(n,f);let u=D.get(n),w=typeof u=="string"?E(u):void 0;typeof u=="string"&&w!==void 0&&P.set(n,{from:u,to:w})}O=T(g.said)}let y=t=>e.sources[t][p]===c.source,F=[...l.filter(y),...l.filter(t=>!y(t))];return{...m(F),standsFor:I,standardFirst:l.filter(y).length,standardMatched:!1,prices:O,leftIn:P}}function Q(r,e){let c=r.prices.map(i=>({...i}));for(let i of e){let d=r.leftIn.get(i),a=d&&(c.find(o=>o.from===d.from&&o.to===d.to&&o.how==="replaced"&&!o.forLines)??c.find(o=>o.from===d.from&&o.to===d.to&&o.how==="replaced"));a&&a.prices--}return c.filter(i=>i.prices>0)}function q(r,e){return e===1?`1 ${r} record held back, not sent: read in a currency the target org does not hold active, it stands for the source's own price of its product and price book in the currency written, which this run did not write.`:`${e} ${r} records held back, not sent: read in a currency the target org does not hold active, they stand for the source's own prices of their product and price book in the currency written, which this run did not write.`}var H="The standard price book is matched to the target org's, never written.";function $(r,e){return e.prices.length===0&&!e.standardMatched?r:{...r,...e.prices.length>0?{pricesSettled:[...e.prices]}:{},...e.standardMatched?{standardPricebookMatched:!0}:{}}}export{Y as a,v as b,A as c,Q as d,q as e,H as f,$ as g};
|
|
@@ -0,0 +1,9 @@
|
|
|
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 n}from"./chunk-7EANH5PY.mjs";var d="OTHER_ORG",f="RUN_WRITING";function R({code:e,message:r}){return`refused (${e}): ${r}`}function l({code:e,message:r},t="a real run"){return`${t} would be refused (${e}): ${r}`}function g(e){return e.length>0?{wouldBeRefused:e.map(({message:r})=>r),wouldBeRefusedCodes:e.map(({code:r})=>r)}:{}}function c(e,r,t=[]){let{tool:u,source:s,target:o,elapsedMs:i}=e;return`${JSON.stringify({tool:u,...s!==void 0?{source:s}:{},target:o,dryRun:e.dryRun===!0,refused:r,...t.length>0?{alsoRefused:t}:{},...e.apiRequests!==void 0?{apiRequests:e.apiRequests}:{},elapsedMs:i},null,2)}
|
|
8
|
+
`}function m(e,r){let{tool:t,action:u="remove",summary:s,target:o,elapsedMs:i}=e;return`${JSON.stringify({tool:t,action:u,summary:s,target:o,refused:r,elapsedMs:i},null,2)}
|
|
9
|
+
`}function p(e,r){let t=n.object({tool:n.literal(r),dryRun:n.literal(!1),refused:n.object({code:n.string().min(1),message:n.string()}),result:n.never().optional()}).safeParse(e);return t.success?t.data.refused:void 0}function y(e,r){let t=n.object({tool:n.literal(r),dryRun:n.literal(!0),refused:n.object({code:n.string().min(1),message:n.string()}),result:n.never().optional()}).safeParse(e);return t.success?t.data.refused:void 0}function w({code:e},r="remove"){return`is the summary of a run refused before its first write (${e}), which wrote nothing to the target: there is nothing of it to ${r}.`}export{d as a,f as b,R as c,l as d,g as e,c as f,m as g,p as h,y as i,w as j};
|