sandforge 0.0.0-stage → 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/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-2BA2XKAY.mjs +7 -0
- package/lib/chunk-2CNCDM56.mjs +7 -0
- package/lib/chunk-2GTBABKU.mjs +7 -0
- package/lib/chunk-2NBYT7GR.mjs +7 -0
- package/lib/chunk-2UZPIMUC.mjs +7 -0
- package/lib/chunk-2YIV2OB2.mjs +7 -0
- package/lib/chunk-3F6Q5E7I.mjs +14 -0
- package/lib/chunk-3RZQZHEB.mjs +7 -0
- package/lib/chunk-3TJON4F3.mjs +7 -0
- package/lib/chunk-4HW535YJ.mjs +7 -0
- package/lib/chunk-4TLYUZD5.mjs +7 -0
- package/lib/chunk-4VS2V6WU.mjs +25 -0
- package/lib/chunk-5K5VLULK.mjs +7 -0
- package/lib/chunk-5LFSFYFJ.mjs +7 -0
- package/lib/chunk-5P4PHJRL.mjs +9 -0
- package/lib/chunk-5TC3QB4U.mjs +10 -0
- package/lib/chunk-66NMFCWX.mjs +7 -0
- package/lib/chunk-6XYKJSGX.mjs +7 -0
- package/lib/chunk-74Q6DORA.mjs +7 -0
- package/lib/chunk-7ABODJ4G.mjs +7 -0
- package/lib/chunk-7EANH5PY.mjs +68 -0
- package/lib/chunk-7EGQP6S4.mjs +7 -0
- package/lib/chunk-7F54PZUS.mjs +7 -0
- package/lib/chunk-7FFGJWHN.mjs +7 -0
- package/lib/chunk-7YDNUBO5.mjs +7 -0
- package/lib/chunk-A527W53V.mjs +7 -0
- package/lib/chunk-ADOAS63R.mjs +7 -0
- package/lib/chunk-AEKONPF4.mjs +7 -0
- package/lib/chunk-AV5SWEHP.mjs +9 -0
- package/lib/chunk-B5QQJ4SI.mjs +7 -0
- package/lib/chunk-BGUEWRK2.mjs +7 -0
- package/lib/chunk-BKDV4ENO.mjs +7 -0
- package/lib/chunk-BOGNK4LV.mjs +7 -0
- package/lib/chunk-BTWDMNN3.mjs +7 -0
- package/lib/chunk-BV6VTP3J.mjs +7 -0
- package/lib/chunk-BXU6WFMH.mjs +7 -0
- package/lib/chunk-BY2HJFFG.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-CEX3NEZL.mjs +7 -0
- package/lib/chunk-CHCHAE4B.mjs +7 -0
- package/lib/chunk-CHYDMRSV.mjs +7 -0
- package/lib/chunk-CION3VMZ.mjs +7 -0
- package/lib/chunk-COFG7Q6R.mjs +7 -0
- package/lib/chunk-CSBS5U5I.mjs +7 -0
- package/lib/chunk-CU2INBND.mjs +7 -0
- package/lib/chunk-DB7RBE5D.mjs +7 -0
- package/lib/chunk-DBB3EMIN.mjs +7 -0
- package/lib/chunk-DBFJB2B6.mjs +7 -0
- package/lib/chunk-DYFALGRT.mjs +7 -0
- package/lib/chunk-E5AHXLS6.mjs +7 -0
- package/lib/chunk-E5ZB3LU5.mjs +7 -0
- package/lib/chunk-EADHKH3A.mjs +7 -0
- package/lib/chunk-EFR2Y7E4.mjs +7 -0
- package/lib/chunk-EHQ3FX6X.mjs +7 -0
- package/lib/chunk-ELFXJHU7.mjs +7 -0
- package/lib/chunk-EMNC6YI4.mjs +7 -0
- package/lib/chunk-EQNW3UC2.mjs +7 -0
- package/lib/chunk-F2424IKX.mjs +7 -0
- package/lib/chunk-F43REJDZ.mjs +10 -0
- package/lib/chunk-F6GUDTOB.mjs +7 -0
- package/lib/chunk-FGRG7ANU.mjs +7 -0
- package/lib/chunk-FKG7Q3WH.mjs +7 -0
- package/lib/chunk-FPKYYFM7.mjs +7 -0
- package/lib/chunk-FQGHL7GR.mjs +259 -0
- package/lib/chunk-FXXLX4O6.mjs +7 -0
- package/lib/chunk-G35N4P7D.mjs +7 -0
- package/lib/chunk-GCOB7K5N.mjs +7 -0
- package/lib/chunk-GGD7ON3M.mjs +7 -0
- package/lib/chunk-GMY5427L.mjs +7 -0
- package/lib/chunk-GSG7WZHM.mjs +7 -0
- package/lib/chunk-GSKCGQIP.mjs +7 -0
- package/lib/chunk-HEKAZJRH.mjs +7 -0
- package/lib/chunk-HF6LAK3G.mjs +7 -0
- package/lib/chunk-HLWMJF6Y.mjs +7 -0
- package/lib/chunk-HOJYWTP7.mjs +20 -0
- package/lib/chunk-HS4YRX4J.mjs +7 -0
- package/lib/chunk-HXS7ORUF.mjs +11 -0
- package/lib/chunk-I7O6C2B5.mjs +8 -0
- package/lib/chunk-IC2C2GOF.mjs +8 -0
- package/lib/chunk-IFETCRWE.mjs +10 -0
- package/lib/chunk-IG2MTQRP.mjs +8 -0
- package/lib/chunk-IGYH7GMA.mjs +7 -0
- package/lib/chunk-INIQ23K6.mjs +7 -0
- package/lib/chunk-INIT2UKJ.mjs +7 -0
- package/lib/chunk-IOIWJ3DJ.mjs +7 -0
- package/lib/chunk-IQXHJEYB.mjs +7 -0
- package/lib/chunk-IWDREM66.mjs +7 -0
- package/lib/chunk-IZQZ6ZUF.mjs +7 -0
- package/lib/chunk-J525F5KI.mjs +7 -0
- package/lib/chunk-JEERQRLW.mjs +7 -0
- package/lib/chunk-JPUR2CFX.mjs +10 -0
- package/lib/chunk-JWTSEDIQ.mjs +7 -0
- package/lib/chunk-K2FBZIXY.mjs +7 -0
- package/lib/chunk-K327QKMD.mjs +7 -0
- package/lib/chunk-KBJ5VERV.mjs +7 -0
- 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-L77FJZEP.mjs +10 -0
- package/lib/chunk-LKQ5RKIV.mjs +9 -0
- package/lib/chunk-LPBMBW3O.mjs +13 -0
- package/lib/chunk-LWW4U276.mjs +7 -0
- package/lib/chunk-M3ROUWDX.mjs +7 -0
- package/lib/chunk-M6P5ZZLE.mjs +7 -0
- package/lib/chunk-MFG4MUIO.mjs +9 -0
- package/lib/chunk-MHMH6MTP.mjs +7 -0
- package/lib/chunk-MILU7WFN.mjs +7 -0
- package/lib/chunk-MJU2PGZQ.mjs +15 -0
- package/lib/chunk-MJVTDA5Q.mjs +7 -0
- package/lib/chunk-MS4FJDFD.mjs +101 -0
- package/lib/chunk-MTMH6H2A.mjs +8 -0
- package/lib/chunk-MYW5QNGI.mjs +7 -0
- package/lib/chunk-N652NMZ4.mjs +441 -0
- package/lib/chunk-NTFIRZP6.mjs +7 -0
- package/lib/chunk-NTOVCTRS.mjs +7 -0
- package/lib/chunk-NZC67CGR.mjs +9 -0
- package/lib/chunk-O2HDYYUV.mjs +8 -0
- package/lib/chunk-OAZRPP4I.mjs +7 -0
- package/lib/chunk-OHWNPXWW.mjs +7 -0
- 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-PJ5I73CK.mjs +7 -0
- package/lib/chunk-PTTHSSQO.mjs +7 -0
- package/lib/chunk-PZPJKATS.mjs +19 -0
- package/lib/chunk-Q3DM32KF.mjs +11 -0
- package/lib/chunk-QR3WELJQ.mjs +7 -0
- package/lib/chunk-QROPNEGY.mjs +14 -0
- package/lib/chunk-QSRAEUGZ.mjs +7 -0
- package/lib/chunk-QWT2C74M.mjs +7 -0
- package/lib/chunk-R3X3LV64.mjs +14 -0
- package/lib/chunk-RMBPOTD7.mjs +7 -0
- package/lib/chunk-RPI7LRTW.mjs +7 -0
- package/lib/chunk-RSWDYIHY.mjs +37 -0
- package/lib/chunk-SAR5622P.mjs +7 -0
- package/lib/chunk-SCKUIE3R.mjs +7 -0
- package/lib/chunk-SE4QEZUG.mjs +7 -0
- package/lib/chunk-SIHORWVK.mjs +7 -0
- package/lib/chunk-SOGQW4IG.mjs +7 -0
- package/lib/chunk-SOU4FRYN.mjs +7 -0
- package/lib/chunk-SRPWW4A2.mjs +10 -0
- package/lib/chunk-SU65Z2BA.mjs +7 -0
- package/lib/chunk-T62WNR54.mjs +7 -0
- package/lib/chunk-T63U4OZJ.mjs +7 -0
- package/lib/chunk-TLH7AD35.mjs +7 -0
- package/lib/chunk-TSLJUSLW.mjs +13 -0
- package/lib/chunk-TTFDUKUS.mjs +47 -0
- package/lib/chunk-TTKXMDBN.mjs +10 -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-UCD54V2M.mjs +7 -0
- package/lib/chunk-UNDIBZWG.mjs +7 -0
- package/lib/chunk-UNJA4J37.mjs +11 -0
- package/lib/chunk-VE6XKGGD.mjs +7 -0
- package/lib/chunk-VGW4MXXZ.mjs +7 -0
- package/lib/chunk-VS7ZXUII.mjs +824 -0
- package/lib/chunk-VXQLDM4R.mjs +7 -0
- package/lib/chunk-VYXMVJL5.mjs +7 -0
- package/lib/chunk-W622GUAW.mjs +8 -0
- package/lib/chunk-W7U5E5ZL.mjs +9 -0
- package/lib/chunk-WA7EYLAQ.mjs +7 -0
- package/lib/chunk-WIO4XO4F.mjs +7 -0
- package/lib/chunk-WR2GIKWE.mjs +7 -0
- package/lib/chunk-WR4Q363I.mjs +11 -0
- package/lib/chunk-WU3GLFZO.mjs +7 -0
- package/lib/chunk-WXAQ7FK3.mjs +115 -0
- package/lib/chunk-X5JYBPXP.mjs +7 -0
- package/lib/chunk-XAMBCQPU.mjs +7 -0
- package/lib/chunk-XCA5AONB.mjs +7 -0
- package/lib/chunk-XLXIPIEW.mjs +9 -0
- package/lib/chunk-XUWL6ZPC.mjs +7 -0
- package/lib/chunk-YAZO75G2.mjs +8 -0
- package/lib/chunk-YKKRIEH4.mjs +7 -0
- package/lib/chunk-YRQGKDHM.mjs +7 -0
- package/lib/chunk-YS4G22C2.mjs +7 -0
- package/lib/chunk-YYZL7UGV.mjs +7 -0
- package/lib/chunk-ZHJP7L3K.mjs +7 -0
- package/lib/chunk-ZM6OJGIG.mjs +7 -0
- package/lib/chunk-ZUTYVST5.mjs +7 -0
- package/lib/chunk-ZVAED4QV.mjs +7 -0
- package/lib/sandforge-autopilot.mjs +162 -0
- package/lib/sandforge-backup.mjs +103 -0
- package/lib/sandforge-checkpoint.mjs +354 -0
- package/lib/sandforge-cleanup.mjs +60 -0
- package/lib/sandforge-clone.mjs +7 -0
- package/lib/sandforge-compare.mjs +55 -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 +272 -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{d as Ce}from"./chunk-WIO4XO4F.mjs";import{a as In}from"./chunk-EADHKH3A.mjs";import{c as xn,g as le,h as Pe,j as vn}from"./chunk-GCOB7K5N.mjs";import{a as j,c as ee}from"./chunk-INIT2UKJ.mjs";import{b as kn}from"./chunk-SU65Z2BA.mjs";import{d as Nn}from"./chunk-A527W53V.mjs";import{a as X,h as C}from"./chunk-TZE3Y7IQ.mjs";import{b as G}from"./chunk-CA5NAXSU.mjs";import{$c as En,Cb as yn,Db as hn,Eb as wn,Fb as Rn,Hb as _,Ib as Y,Kc as Tn,Lc as Sn,M as mn,Mc as An,Nc as On,Pb as bn,Qb as V,Rb as L,_c as Fn}from"./chunk-TTFDUKUS.mjs";import{b as Q,e as pn,i as ce,k as de,l as Z,s as ve}from"./chunk-7EANH5PY.mjs";var _t=/^[A-Za-z][A-Za-z0-9_]{0,79}$/;function Pn(e,n){return typeof e=="object"&&e!==null?e[n]:void 0}function Cn(e){return Array.isArray(e)?e.filter(n=>typeof n=="object"&&n):[]}function Mn(e){return typeof e=="string"&&_t.test(e)?e:void 0}function jn(e){let n=new Map;for(let r of Cn(Pn(e,"variables"))){let o=r.name,s=Mn(r.objectType);typeof o=="string"&&s&&n.set(o.toLowerCase(),s)}let t=[];for(let r of Cn(Pn(e,"recordCreates"))){let o=r.inputReference,s=Mn(r.object)??(typeof o=="string"?n.get(o.toLowerCase()):void 0);s&&!t.some(i=>i.toLowerCase()===s.toLowerCase())&&t.push(s)}return t}var $n={AccountPartner:["Role"],CampaignMember:["Status"],Case:["Status"],Contract:["Status"],Lead:["Status"],Opportunity:["StageName"],OpportunityPartner:["Role"],Order:["Status"],Partner:["Role"],ServiceAppointment:["Status"],Solution:["Status"],Task:["Priority","Status"],WorkOrder:["Status"],WorkOrderLineItem:["Status"]};function Eo(e,n){let t=new Map,r=n!==void 0&&Object.prototype.hasOwnProperty.call($n,n)?$n[n]:[];for(let o of e){let s=o.type==="multipicklist";if(o.type!=="picklist"&&!s&&!o.picklistValues?.length)continue;let i=(o.type==="combobox"||o.restrictedPicklist===!1)&&!r.includes(o.name);t.set(o.name,{multi:s,restricted:o.restrictedPicklist===!0,required:o.nillable===!1&&o.defaultedOnCreate!==!0,...o.controllerName?{controllerName:o.controllerName}:{},...i?{anyValue:i}:{}})}return t}var Lt=new Set;function Dt(e,n){let t=new Set(e),r=[],o=new Set,s=(i,d)=>{if(o.has(i))return;let l=n.get(i)?.controllerName;l&&t.has(l)&&d<e.length&&s(l,d+1),!o.has(i)&&(o.add(i),r.push(i))};for(let i of e)s(i,0);return r}function qt(e){return typeof e=="boolean"?String(e):typeof e=="string"&&e!==""?e:void 0}function Bt(e,n){let t=new Map;for(let r of e){let o=n(r),s=t.get(o)??[];s.includes(r)||s.push(r),t.set(o,s)}return[...t]}function Gt(e,n,t,r,o,s,i){let d=new Set(o.values),l=d,a,u=r.controllerName?qt(e[r.controllerName]):void 0,f=u===void 0?void 0:o.allowedByControllingValue?.get(u);f&&(l=new Set(o.values.filter(b=>f.has(b))),a=r.controllerName);let g=t.filter(b=>!l.has(b));if(g.length===0)return[];let p=b=>i&&!i.has(b)?"not-in-target":d.has(b)?"controlling-value":"record-type",w,T,S=t.filter(b=>l.has(b));return r.multi&&S.length>0?e[n]=S.join(";"):(o.defaultValue!==null&&l.has(o.defaultValue)?(w=o.defaultValue,T="default"):r.required&&(w=o.values.find(b=>l.has(b)),T=w===void 0?void 0:"first"),w===void 0?delete e[n]:e[n]=w),Bt(g,p).map(([b,x])=>({field:n,reason:b,values:x,recordType:s,...b==="controlling-value"&&a?{controllingField:a}:{},...w!==void 0&&T?{replacedBy:w,replacement:T}:{}}))}function ko(e,n,t,r,o=Lt){let s=[];for(let i of Dt(Object.keys(e),t)){let d=e[i];if(typeof d!="string"||o.has(i))continue;let l=t.get(i),a=n?.get(i),u=l?.restricted?r?.picklists.get(i):void 0;if(!a&&!u)continue;if(d===""){delete e[i];continue}let f=l?.multi?d.split(";"):[d];if(l&&u&&r){s.push(...Gt(e,i,f,l,u,r.recordType,a));continue}if(!a||l?.anyValue)continue;let g=f.filter(w=>!a.has(w));if(g.length===0)continue;let p=f.filter(w=>a.has(w));l?.multi&&p.length>0?e[i]=p.join(";"):delete e[i],s.push({field:i,reason:"not-in-target",values:[...new Set(g)]})}return s}var Ut="012000000000000AAA",ue="Master",Dn="";function No(e,n){return e?.get(typeof n=="string"?n:Dn)}async function Wt(e,n,t){try{return{picklists:await e(n,t)}}catch(r){return{error:G(r)}}}var _n=class{constructor(n){this.read=n}read;reads=new Map;said=new Set;async forRows(n){let t=new Map,r=[],{read:o}=this;if(!o)return{byRecordType:t,notes:r};if(n.withoutRecordTypes){let a=[...n.fields].filter(([f,g])=>g.restricted&&g.controllerName&&n.written(f)).map(([f])=>f),u=new Set(a.filter(f=>n.rows.some(g=>typeof g[f]=="string"&&g[f]!=="")));if(u.size>0){let f={targetId:Ut,developerName:ue},g=await this.readFor(o,n.objectApiName,f.targetId);this.keep(t,r,n.objectApiName,Dn,u,f,g)}return{byRecordType:t,notes:r}}if(!n.recordTypeMappings||!n.written("RecordTypeId"))return{byRecordType:t,notes:r};let s=[...n.fields].filter(([a,u])=>u.restricted&&n.written(a)).map(([a])=>a);if(s.length===0)return{byRecordType:t,notes:r};let i=new Map(n.recordTypeMappings.map(a=>[a.sourceId,a])),d=new Map;for(let a of n.rows){let u=a.RecordTypeId;if(!(typeof u!="string"||!i.has(u)))for(let f of s){let g=a[f];if(typeof g!="string"||g==="")continue;let p=d.get(u)??new Set;p.add(f),d.set(u,p)}}let l=await Promise.all([...d].map(async([a,u])=>{let f=i.get(a);return{sourceId:a,fields:u,target:f,answer:await this.readFor(o,n.objectApiName,f.targetId)}}));for(let{sourceId:a,fields:u,target:f,answer:g}of l)this.keep(t,r,n.objectApiName,a,u,f,g);return{byRecordType:t,notes:r}}readFor(n,t,r){let o=`${t}|${r}`,s=this.reads.get(o);return s||(s=Wt(n,t,r),this.reads.set(o,s)),s}keep(n,t,r,o,s,i,d){let l=`${r}|${i.targetId}`;if("error"in d){this.said.has(l)||(this.said.add(l),t.push({recordType:i.developerName,error:d.error}));return}n.set(o,{recordType:i.developerName,picklists:d.picklists});let a=[...s].filter(u=>!d.picklists.has(u)&&!this.said.has(`${l}|${u}`));if(a.length!==0){for(let u of a)this.said.add(`${l}|${u}`);t.push({recordType:i.developerName,leftOut:a})}}};function Io(e){return e.error!==void 0?{recordSummary:`(picklist values of record type ${e.recordType} could not be read \u2014 checked against each field's values)`,messages:[e.error]}:{recordSummary:`(picklist values of record type ${e.recordType} not given for ${(e.leftOut??[]).join(", ")} \u2014 checked against each field's values)`,messages:[`The target's answer for record type ${e.recordType} leaves out ${(e.leftOut??[]).join(", ")}.`]}}var Ln=class{entries=new Map;get size(){return this.entries.size}add(n,t){for(let r of t){let o=[n,r.field,r.reason,r.recordType??"",r.controllingField??"",r.replacement??"",r.replacedBy??""].join("\0"),s=this.entries.get(o);if(s){s.entry.rows++;for(let i of r.values)s.values.add(i);continue}this.entries.set(o,{entry:{objectApiName:n,field:r.field,reason:r.reason,values:[],rows:1,...r.recordType!==void 0?{recordType:r.recordType}:{},...r.controllingField!==void 0?{controllingField:r.controllingField}:{},...r.replacedBy!==void 0?{replacedBy:r.replacedBy}:{},...r.replacement!==void 0?{replacement:r.replacement}:{}},values:new Set(r.values)})}}list(){return[...this.entries.values()].map(({entry:n,values:t})=>({...n,values:[...t].sort()}))}};function Vt(e){let n=`${e.rows} row${e.rows===1?"":"s"}`,t=e.values.map(s=>`"${s}"`).join(", "),r=e.reason==="not-in-target"?"not a value of the field in the target":e.reason==="record-type"?`not allowed for record type ${e.recordType??""}`:`not allowed with the value of ${e.controllingField??"its controlling field"}`,o=e.replacedBy===void 0?"left out":e.replacement==="first"?`replaced by "${e.replacedBy}", the first value record type ${e.recordType??""} allows: the field is required and has no default there`:`replaced by "${e.replacedBy}", the default of record type ${e.recordType??""}`;return`${e.field} on ${n}: ${t} ${r}, ${o}`}function xo(e){return e.length===0?"":`, picklist values not written as read: ${e.map(Vt).join("; ")}`}function $o(e){let n={...e.picklistValueMappings?.length?{picklistValueMappings:e.picklistValueMappings}:{},...e.recordTypeMappings?.length?{recordTypeMappings:e.recordTypeMappings}:{},...e.defaultValues?.length?{defaultValues:e.defaultValues}:{},...e.truncateFields?.length?{truncateFields:e.truncateFields}:{},...e.ignoredGaps?.length?{ignoredGaps:e.ignoredGaps}:{},...e.skippedRows?.length?{skippedRows:e.skippedRows}:{}};return Object.keys(n).length>0?n:void 0}var zt=new Set(["picklist_value_refused","picklist_value_absent","currency_inactive"]);function Un(e){let n=mn(e.gapId);return n?n.objectApiName!==e.object?{ignored:`the gap is of ${n.objectApiName}, not of ${e.object}`}:n.field===void 0||n.value===void 0?{ignored:"the gap names no field and value whose rows to hold back"}:zt.has(n.kind)?{held:{field:n.field,...n.recordType!==void 0?{recordType:n.recordType}:{},value:n.value}}:{ignored:`a ${n.kind} gap does not offer it: its rows are not exactly those holding its value`}:{ignored:"not the id of a gap"}}function _o(e){let n=Un(e);return"ignored"in n?n.ignored:void 0}function qn(e,n,t){if(e===void 0)return!0;let r=n??ue;if(e===r)return!0;let o=le(e),s=le(r);if(o.namespacePrefix!==void 0||s.namespacePrefix===void 0||s.developerName!==e)return!1;if(t===void 0)return!0;let i=Pe(e,t,d=>d);return"found"in i&&i.found.namespacePrefix===s.namespacePrefix}function Qt(e){return e==null||e===""}var Bn=class{entries=new Map;get size(){return this.entries.size}add(n,t=1){let r=[n.kind,n.objectApiName,n.field??"",n.recordType??"",n.from??"",n.to??""].join("\0"),o=this.entries.get(r);if(o){o.rows+=t;return}this.entries.set(r,{...n,rows:t})}list(){return[...this.entries.values()].map(n=>({...n}))}},fe=class{picklists=new Map;defaults=new Map;truncated=new Map;skipped=new Map;ignoredGaps;constructor(n){for(let t of n?.picklistValueMappings??[]){let r=this.picklists.get(t.object)??[];r.push(t),this.picklists.set(t.object,r)}for(let t of n?.defaultValues??[]){let r=this.defaults.get(t.object)??[];r.push(t),this.defaults.set(t.object,r)}for(let{object:t,field:r}of n?.truncateFields??[]){let o=this.truncated.get(t)??new Set;o.add(r),this.truncated.set(t,o)}this.ignoredGaps=new Set(n?.ignoredGaps??[]);for(let t of n?.skippedRows??[]){let r=Un(t);if(!("held"in r))continue;let o=this.skipped.get(t.object)??[];o.push(r.held),this.skipped.set(t.object,o)}}skipsRowsOf(n){return this.skipped.has(n)}namesARecordTypeBare(n){return[...(this.picklists.get(n)??[]).map(r=>r.recordType),...(this.skipped.get(n)??[]).map(r=>r.recordType)].some(r=>r!==void 0&&r!==ue&&le(r).namespacePrefix===void 0)}holdsBack(n,t,r,o,s){for(let i of this.skipped.get(n)??[]){if(!qn(i.recordType,r,s))continue;let d=t(i.field);if(!(typeof d!="string"||!d.split(";").includes(i.value)))return o.add({kind:"skip_rows",objectApiName:n,field:i.field,...i.recordType!==void 0?{recordType:i.recordType}:{},from:i.value}),!0}return!1}changesRowsOf(n){return this.picklists.has(n)||this.defaults.has(n)}defaultOf(n,t){let r=this.defaults.get(n)?.find(o=>o.field===t);return r===void 0?void 0:String(r.value)}applyToRow(n,t,r,o,s){for(let i of this.picklists.get(n)??[]){if(!qn(i.recordType,r,s))continue;let d=t[i.field];if(typeof d!="string"||d==="")continue;let l=d.split(";");if(!l.includes(i.from))continue;let a=l.flatMap(u=>u!==i.from?[u]:i.to===null?[]:[i.to]);a.length===0?delete t[i.field]:t[i.field]=[...new Set(a)].join(";"),o.add({kind:i.to===null?"leave_empty":"map_value",objectApiName:n,field:i.field,...i.recordType!==void 0?{recordType:i.recordType}:{},from:i.from,...i.to!==null?{to:i.to}:{}})}for(let{field:i,value:d}of this.defaults.get(n)??[])Qt(t[i])&&(t[i]=d,o.add({kind:"set_default",objectApiName:n,field:i,to:String(d)}))}truncate(n,t,r,o){for(let s of this.truncated.get(n)??[]){let i=t[s],d=r.get(s);typeof i!="string"||d===void 0||d<=0||i.length<=d||(t[s]=i.slice(0,d),o.add({kind:"truncate",objectApiName:n,field:s}))}}truncatedFieldsOf(n){return this.truncated.get(n)??new Set}};function Lo(e,n){let t=new Map(n.map(i=>[i.objectApiName,i])),r=[],o=new Map,s=[];for(let i of e){let d=t.get(i.object),l=Gn(i.object,i.from,d?.source??[],"the source");if("reason"in l){s.push({decision:i,reason:l.reason});continue}if(i.to===null){o.set(l.type.recordTypeId,i);continue}let a=Gn(i.object,i.to,d?.target??[],"the target");if("reason"in a){s.push({decision:i,reason:a.reason});continue}o.set(l.type.recordTypeId,i),r.push({sourceId:l.type.recordTypeId,targetId:a.type.recordTypeId,developerName:a.type.developerName})}return{mappings:r,bySource:o,unresolved:s}}function Gn(e,n,t,r){let o=Pe(n,t.filter(s=>!s.master),Ce);if("found"in o)return{type:o.found};if("ambiguous"in o){let s=o.ambiguous.map(Ce),i=s.find(d=>d.namespacePrefix);return{reason:vn(e,n,r,s)+(i?"; a package's is named with its namespace: "+xn(i.namespacePrefix,i.developerName):"")}}return{reason:`${r} has no ${e} record type named ${n}`}}function Do(e,n){return n.bySource.size===0?e?[...e]:void 0:[...(e??[]).filter(t=>!n.bySource.has(t.sourceId)),...n.mappings]}var Me=class{constructor(n,t){this.given=n;this.store=t}given;store;has(n){return this.given.has(n)||this.store?.mapping(n)?.earlier===!0}retried(n){return this.given.has(n)}get(n){let t=this.given.get(n);if(t!==void 0)return t;let r=this.store?.mapping(n);return r?.earlier?r.targetId:void 0}get from(){return this.given.size===0&&(this.store?.earlierMapped??0)>0?"resume":"retry"}get size(){return this.given.size+(this.store?.earlierMapped??0)}keys(){return this.given.keys()}[Symbol.iterator](){return this.given.entries()}};function U(e){return e!==void 0&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0}function Wn(e){let n=!!(e?.rootRecordId&&e.rootObjectApiName);return{isScoped:n,dryRun:e?.dryRun??!1,referenceFallback:e?.referenceFallback??(n?"nullify":"keep"),rootRecordId:e?.rootRecordId,rootObjectApiName:e?.rootObjectApiName,recordTypeMappings:e?.recordTypeMappings,maxRecordsPerObject:e?.maxRecordsPerObject,referenceDataObjects:new Set(e?.referenceDataObjects??["BusinessHours","OperatingHours"]),expandOrphanParents:e?.expandOrphanParents??!1,maxOrphanParentExpansions:e?.maxOrphanParentExpansions??20,upsertMode:e?.upsertMode==="auto"?"auto":"off",writeApi:e?.writeApi==="auto"?"auto":"rest",fieldExclusions:e?.fieldExclusions??{},excludedObjects:new Set(e?.excludedObjects??[]),ownerMappings:e?.ownerMappings??{},objectSoqlFilters:e?.objectSoqlFilters,fieldMappings:e?.fieldMappings??{},anonymization:e?.anonymization,keepContactPoints:e?.keepContactPoints===!0,files:e?.files?{maxFileBytes:Math.min(e.files.maxFileBytes>0?e.files.maxFileBytes:10*1048576,35*1048576),acceptedAsIs:e.files.acceptedAsIs===!0}:void 0,writtenBefore:new Me(new Map(Object.entries(e?.writtenBefore??{})),e?.stream?.store),beforeWrite:e?.beforeWrite,stream:e?.stream?{pageSize:U(e.stream.pageSize),ceiling:U(e.stream.ceiling),resumeAfter:e.stream.resumeAfter?new Map(Object.entries(e.stream.resumeAfter)):e.stream.store?.checkpoints()??new Map,onPage:e.stream.onPage,...e.stream.store?{store:e.stream.store}:{},...e.stream.summaryBound!==void 0?{summaryBound:Math.max(0,Math.floor(e.stream.summaryBound))}:{},...U(e.stream.secondPassPageSize)!==void 0?{secondPassPageSize:U(e.stream.secondPassPageSize)}:{},...U(e.stream.writeWindow)!==void 0?{writeWindow:U(e.stream.writeWindow)}:{},...e.stream.everything===!0?{everything:!0}:{},...U(e.stream.wholeReadBound)!==void 0?{wholeReadBound:U(e.stream.wholeReadBound)}:{},...e.stream.sample&&e.stream.everything===!0?{sample:e.stream.sample}:{}}:void 0,decisions:new fe(e?.decisions),recordTypeDecisions:new Map}}var Kt="Id = NULL",Le="no parent in cache and not the root",Vn=class{build(n){let t=this.buildMeasured(n);return{...t,statements:je(t.statements,n.node.objectApiName,n.selectFields)}}buildMeasured(n){let t=C(n.node.objectApiName),r=ne(ee(n.selectFields)),o=n.extraWhere?` AND (${n.extraWhere})`:"",s=n.extraWhere?" + extra filter":"",i=`SELECT ${r} FROM ${t} WHERE `,d=n.node.objectApiName===n.rootObjectApiName&&!n.under;if(d&&!(n.rootReadAgain&&n.cache.has(n.node.objectApiName))){let k=X(n.rootRecordId);return{statements:[`${i}Id = '${k}'${o}`],scoped:!0,scope:"root",reason:`root record${s}`,parentObjectsUsed:[n.rootObjectApiName],scopeIdCount:1,byIdCount:0}}let l=n.under?void 0:n.cache.get(n.node.objectApiName),a=l?.size??0,u=l&&a>0?_e({prefix:i,suffix:o,wrap:!1,objectApiName:n.node.objectApiName},[{field:"Id",ids:l}]):[],f=`${a} ID(s) cached from earlier wave`,g={statements:u,scoped:!0,scope:"self-cached",reason:`${f}${s}`,parentObjectsUsed:[],scopeIdCount:a,byIdCount:u.length};if(a>0&&(!n.everyEdge||d))return g;let p=[],w=[],T=0;for(let k of n.edges){if(k.targetObject!==n.node.objectApiName||n.under&&!n.under.has(k.sourceObject)||k.sourceObject===k.targetObject)continue;let R=n.fromAboveOnly||n.catalog?.has(k.sourceObject)?n.cache.reachedOf(k.sourceObject):n.cache.scopeOf(k.sourceObject);if(!R||R.size===0)continue;let I=n.fields.filter(h=>h.type==="reference"&&h.referenceTo.includes(k.sourceObject));if(I.length!==0){for(let h of I)p.push({field:C(h.name),ids:R});w.includes(k.sourceObject)||(w.push(k.sourceObject),T+=R.size)}}let S=[];for(let k of n.fields){if(k.type!=="reference"||k.nillable!==!1)continue;let R=new Set;for(let I of k.referenceTo){if(!n.readObjects?.has(I))continue;let h=n.catalog?.has(I)===!0;if(h&&!n.cache.isRead(I))continue;let F=h?n.cache.scopeOf(I):n.cache.get(I);if(F)for(let A of F)R.add(A)}R.size!==0&&S.push({field:C(k.name),ids:R})}let b=S.length>0?" + required parents in scope":"";if(p.length===0)return a>0?g:{statements:[`${i}${Kt}`],scoped:!1,scope:"unscoped",reason:Le,parentObjectsUsed:[],scopeIdCount:0,byIdCount:1};let x=zn({prefix:i,extraSuffix:o,objectApiName:n.node.objectApiName},p,S),N=`via ${w.join(", ")}${s}${b}`;return a===0?{statements:x,scoped:!0,scope:"parent-fk",reason:N,parentObjectsUsed:w,scopeIdCount:T,byIdCount:0}:{statements:[...u,...x],scoped:!0,scope:"self-and-parent-fk",reason:`${f}, and ${N}`,parentObjectsUsed:w,scopeIdCount:a+T,byIdCount:u.length}}buildJoining(n){let t=C(n.objectApiName),o=`SELECT ${ne(ee(n.selectFields))} FROM ${t} WHERE `,s=n.extraWhere?` AND (${n.extraWhere})`:"";return je(zn({prefix:o,extraSuffix:s,objectApiName:n.objectApiName},[{field:C(n.split.field),ids:n.split.ids}],[{field:C(n.whole.field),ids:n.whole.ids}]),n.objectApiName,n.selectFields)}buildById(n){let t=C(n.objectApiName);return je(_e({prefix:`SELECT ${ne(ee(n.selectFields))} FROM ${t} WHERE `,suffix:n.extraWhere?` AND (${n.extraWhere})`:"",wrap:!1,objectApiName:n.objectApiName},[{field:"Id",ids:n.ids}]),n.objectApiName,n.selectFields)}};function ne(e){return e.length===0?"Id":e.map(n=>C(n)).join(", ")}function je(e,n,t){let r=C(n),o=`SELECT ${ne(ee(t))} FROM ${r} `,s=`SELECT ${ne(t)} FROM ${r} `;return o===s?[...e]:e.map(i=>i.startsWith(o)?s+i.slice(o.length):i)}var Jt=500;function De(e,n){let t=[...n].map(r=>`'${X(r)}'`).join(", ");return` AND (${e.field} IN (${t}))`}function Zt(e,n){if(e.field!==n.field)return!1;for(let t of e.ids)if(!n.ids.has(t))return!1;return!0}function Yt(e,n,t){let r=j(De(e,[])),o=j(", "),s=[],i=[],d=r;for(let l of e.ids){let a=j(`'${X(l)}'`);if(i.length>0&&d+o+a>n&&(s.push(i),i=[],d=r),i.length===0&&r+a>n)throw Qn(t);d+=(i.length>0?o:0)+a,i.push(l)}return i.length>0&&s.push(i),s}function Xt(e,n,t){let r=[""];for(let o of e){let s=Yt(o,n/e.length,t);r=r.flatMap(i=>s.map(d=>i+De(o,d)))}return r}function zn(e,n,t){let r=(l,a)=>_e({prefix:e.prefix,suffix:l,wrap:l!=="",objectApiName:e.objectApiName},a),o=t.map(l=>De(l,l.ids)).join(""),s=14e3-j(`${e.prefix}()${e.extraSuffix}`);if(j(o)<=s/2)return r(`${o}${e.extraSuffix}`,n);let i=new Map;for(let l of n){let a=t.filter(g=>!Zt(l,g)),u=a.map(g=>g.field).join("|"),f=i.get(u)??{needed:a,clauses:[]};f.clauses.push(l),i.set(u,f)}let d=[];for(let l of i.values())for(let a of Xt(l.needed,s/2,e.objectApiName))d.push(...r(`${a}${e.extraSuffix}`,l.clauses));return d}function Qn(e){return new Error(`Scoped clone for ${e}: its filter leaves a Salesforce query URI no room for a single record Id. Shorten the filter on this object and run it again.`)}function _e(e,n){let t=e.wrap?"(":"",r=e.wrap?")":"",o=j(e.prefix+t+r+e.suffix),s=j(", "),i=j(" OR "),d=[],l=[],a=o,u=0,f=()=>{let g=l.map(p=>`${p.field} IN (${p.values.join(", ")})`).join(" OR ");d.push(`${e.prefix}${t}${g}${r}${e.suffix}`),l=[],a=o,u=0};for(let g of n){let p=j(`${g.field} IN ()`),w=!1;for(let T of g.ids){let S=`'${X(T)}'`,b=j(S),x=w?s+b:(l.length>0?i:0)+p+b,N=a+x>14e3||u>=Jt;if(l.length>0&&N&&(f(),w=!1,x=p+b),l.length===0&&a+x>14e3)throw Qn(e.objectApiName);w?l[l.length-1].values.push(S):(l.push({field:g.field,values:[S]}),w=!0),a+=x,u++}}return l.length>0&&f(),d}var H="Product2",Be=[_,H,V,L,Y,"ProductCategory","ProductCatalog"],Yo=new Set(Be);function Xo(e,n){return yn(e,n.name,n.nillable)||e===_&&n.name===bn}function Hn(e,n=new Set){let t=new Set(e.nodes.map(r=>r.objectApiName));return new Set(Be.filter(r=>!t.has(r)&&!n.has(r)))}function es(e,n){return e.nodes.some(t=>t.included&&n.has(t.objectApiName))?{...e,nodes:e.nodes.map(t=>t.included&&n.has(t.objectApiName)?{...t,included:!1}:t)}:e}function er(e,n,t){if(n.length<2)return n;let r=e.slice(0,3),o=n.find(s=>t.get(s)===r);return o!==void 0?[o]:n.filter(s=>!t.has(s))}function ns(e,n){let t=qe(e);return n?lr(t,n):t}function ts(e,n,t){let r=Be.flatMap(g=>n.filter(({node:p})=>p.objectApiName===g)),o=new Set(r.flatMap(({fieldInfos:g})=>g.flatMap(p=>p.isReference?p.referenceTo??[]:[]))),s=new Map,i=new Map,d=(g,p,w)=>{let T=g.get(p);T?T.push(w):g.set(p,[w])};for(let{sourceObject:g,targetObject:p}of t)d(s,p,g),d(i,g,p);let l=[],a=new Set,u=[...e],f=u.filter(g=>o.has(g.objectApiName));for(;f.length>0;){for(let g of f)a.add(g.objectApiName),l.push(g);u=u.filter(g=>!a.has(g.objectApiName)),f=u.filter(({objectApiName:g})=>(s.get(g)??[]).some(p=>a.has(p))||(i.get(g)??[]).some(p=>a.has(p)))}return[...u,...r.map(({node:g})=>g),...l]}function Kn(e){return e.settable!==!1}function rs(e,n){let t=!1,r=e.edges.map(o=>{let s=(n.get(o.targetObject)??[]).filter(a=>a.isReference&&(a.referenceTo??[]).includes(o.sourceObject));if(s.length===0)return o;let i=s.some(a=>hn(a)),d=s.some(a=>wn(a));if(i===Kn(o)&&d===(o.insertOnly===!0))return o;t=!0;let l={...o};return i?delete l.settable:l.settable=!1,d?l.insertOnly=!0:delete l.insertOnly,l});return t?{...e,edges:r}:e}function os(e,n=[]){let t=e.edges.filter(Kn),r=[...t.filter(h=>h.required===!0),...n],o=t.filter(h=>h.insertOnly===!0&&h.required!==!0);if(r.length===0&&o.length===0)return qe(e,t);let s=new Set(e.nodes.map(h=>h.objectApiName)),i=qe(e,t),d=new Map(i.map((h,F)=>[h.objectApiName,F])),l=new Map,a=new Map,u=new Map,f=(h,F,A)=>{let $=h.get(F)??new Set;$.add(A),h.set(F,$)};for(let h of r){let{sourceObject:F,targetObject:A}=h;F===A||!s.has(F)||!s.has(A)||(f(l,A,F),f(a,F,A))}for(let h of t){let{sourceObject:F,targetObject:A}=h;F===A||!s.has(F)||!s.has(A)||l.get(A)?.has(F)||f(u,A,F)}let g=new Map;for(let[h,F]of u)for(let A of F)f(g,A,h);let p=new Map,w=new Map;for(let{sourceObject:h,targetObject:F}of o)h===F||!s.has(h)||!s.has(F)||l.get(F)?.has(h)||(f(p,F,h),f(w,h,F));let T=new Map,S=new Map,b=new Map;for(let h of s)T.set(h,l.get(h)?.size??0),S.set(h,p.get(h)?.size??0),b.set(h,u.get(h)?.size??0);let x=(h,F)=>{for(let A of[S,b,d]){let $=A.get(h)??0,se=A.get(F)??0;if($!==se)return $<se}return!1},N=new Set([...s].filter(h=>T.get(h)===0)),k=new Map(e.nodes.map(h=>[h.objectApiName,h])),R=[],I=new Set;for(;N.size>0;){let h;for(let A of N)(h===void 0||x(A,h))&&(h=A);if(h===void 0)break;N.delete(h),I.add(h);let F=k.get(h);F&&R.push(F);for(let A of a.get(h)??[]){let $=(T.get(A)??1)-1;T.set(A,$),$===0&&!I.has(A)&&N.add(A)}for(let A of w.get(h)??[])S.set(A,(S.get(A)??1)-1);for(let A of g.get(h)??[])b.set(A,(b.get(A)??1)-1)}for(let h of e.nodes)I.has(h.objectApiName)||R.push(h);return R}function ss(e,n){return[[H,L],[V,L],[H,_],[V,_],[L,_],[Y,_],...n.map(r=>[_,r])].filter(([r,o])=>r!==o&&e.has(r)&&e.has(o)).map(([r,o])=>({sourceObject:r,targetObject:o,relationshipName:`${r}Before${o}`,type:"lookup",required:!0}))}var nr=new Set(["Id","Name","CurrencyIsoCode","IsPersonAccount","IsActive","Status","IsWhat","IsInvitee","Response","RespondedDate",...Object.values(Nn).flat()]);function tr(e,n){let t=new Set(n??[]);return e.filter(r=>r.queryable&&(!t.has(r.name)||r.isReference||nr.has(r.name))).map(r=>r.name)}var rr=2;function or(e,n){let t=Array.from({length:n.length+1},(r,o)=>o);for(let r=1;r<=e.length;r++){let o=[r];for(let s=1;s<=n.length;s++)o[s]=Math.min(t[s]+1,o[s-1]+1,t[s-1]+(e[r-1]===n[s-1]?0:1));t=o}return t[n.length]}function sr(e,n){let t=e.toLowerCase(),r;for(let o of n){let s=or(t,o.toLowerCase());s<=rr&&s<t.length&&(!r||s<r.edits)&&(r={name:o,edits:s})}return r?.name}function is(e,n,t){let r={},o=[];for(let[s,i]of Object.entries(e)){let d=n.find(u=>u.toLowerCase()===s.toLowerCase())??s,l=t(d),a=r[d]??=[];for(let u of i){let f=l?.find(p=>p.toLowerCase()===u.toLowerCase());if(f===void 0&&l!==null){let p=l===void 0?void 0:sr(u,l);o.push({objectApiName:d,field:u,missing:l===void 0?"object":"field",...p!==void 0?{nearest:p}:{}})}let g=f??u;a.includes(g)||a.push(g)}}return{exclusions:r,unmatched:o}}function as(e){let n=tr(e.fieldInfos,e.fieldsLeftOut);n.length===0&&n.push("Id");let t,r=0;if(e.scopedBuilder&&e.scopeCache&&e.rootObjectApiName&&e.rootRecordId&&e.node.objectApiName===L&&e.node.objectApiName!==e.rootObjectApiName&&e.catalog?.has(L)){let s=cr(e.scopedBuilder,e.scopeCache,n,e.extraWhere);if(!s)return{kind:"skip",reason:Le};t=s,r=t.length}else if(e.scopedBuilder&&e.scopeCache&&e.rootObjectApiName&&e.rootRecordId){let s=e.fieldInfos.filter(d=>d.isReference).map(d=>({name:d.name,type:"reference",referenceTo:d.referenceTo??[],nillable:d.nillable})),i=e.scopedBuilder.build({node:e.node,fields:s,selectFields:n,edges:e.edges,cache:e.scopeCache,rootObjectApiName:e.rootObjectApiName,rootRecordId:e.rootRecordId,extraWhere:e.extraWhere,everyEdge:!0,readObjects:e.readObjects,catalog:e.catalog,rootReadAgain:e.rootReadAgain,under:e.under});if(!i.scoped)return{kind:"skip",reason:i.reason};t=i.statements,r=i.byIdCount}else{let s=[...e.extraWhere?[`(${e.extraWhere})`]:[],...e.inIdOrder?.afterId!==void 0?[`Id > ${ar(e.inIdOrder.afterId)}`]:[]],i=s.length>0?` WHERE ${s.join(" AND ")}`:"",d=e.inIdOrder?" ORDER BY Id":"";t=[`SELECT ${n.join(", ")} FROM ${C(e.node.objectApiName)}${i}${d}`]}let o=r>0?{byIdCount:r}:{};if(e.maxRecordsPerObject&&e.maxRecordsPerObject>0){let s=Math.floor(e.maxRecordsPerObject);if(s>0)return ir(t,s,o)}return{kind:"query",statements:t,...o}}function ir(e,n,t={}){return{kind:"query",statements:e.map(r=>`${r} LIMIT ${n+1}`),limit:n,...t}}function ar(e){if(!/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(e))throw new Error(`Not a record id to resume after: ${JSON.stringify(e.slice(0,40))}`);return`'${e}'`}function cr(e,n,t,r){let o=n.scopeOf(H),s=n.scopeOf(V);if(!(!o||o.size===0||!s||s.size===0))return e.buildJoining({objectApiName:L,selectFields:t,split:{field:"Product2Id",ids:o},whole:{field:"ProductSellingModelId",ids:s},extraWhere:r})}function cs(e){return(e.byIdCount??0)<e.statements.length}async function ds(e,n,t,r){let o=e.byIdCount??0,s=e.limit,i=a=>{if(s===void 0||a.length<=s)return a;for(let u of a.slice(s))typeof u.Id=="string"&&t?.delete(u.Id);return r?.(),a.slice(0,s)};if(e.statements.length===1){let a=await n(e.statements[0]);if(t&&o===0)for(let u of a)typeof u.Id=="string"&&t.add(u.Id);return i(a)}let d=[],l=new Set;for(let[a,u]of e.statements.entries())for(let f of await n(u)){let g=f.Id;if(typeof g=="string"){if(t&&a>=o&&t.add(g),l.has(g))continue;l.add(g)}if(d.push(f),s!==void 0&&d.length>s)return i(d)}return d}function dr(e,n,t,{settle:r=!0}={}){let o=[];for(let s of t){let i=s.Id;typeof i=="string"&&i&&o.push(i)}r?e.addRead(n,o):e.add(n,o)}function ls(e,n,t,r,o={}){dr(e,n,t,o);let s=o.keyPrefixes??new Map,i=r.filter(d=>d.isReference&&d.referenceTo&&d.referenceTo.length>0);for(let d of i){let l=d.referenceTo??[];for(let a of t){let u=a[d.name];if(!(typeof u!="string"||!u))for(let f of er(u,l,s))e.add(f,[u])}}}function lr(e,n){let t=e.findIndex(i=>i.objectApiName===n);if(t<0)throw new Error(`Cannot run scoped clone with root "${n}" missing from the graph. The root node was excluded or filtered out \u2014 re-include it before executing.`);let r=e[t];if(!r.included)throw r.status==="error"?new Error(`Cannot run scoped clone: root "${n}" could not be measured during discovery (${r.errors[0]??"unknown discovery error"}), and nothing was read or written. Run discovery again once the org answers for it; if it refuses again, the user the clone reads as may not read ${n}: start from a record the user can read.`):new Error(`Cannot run scoped clone with root "${n}" excluded: the clone starts from its record, and the records that point at it would be written without it. Include it again, or clone from a query instead of a record.`);if(t===0)return e;let o=[...e],[s]=o.splice(t,1);return o.unshift(s),o}function qe(e,n){let t=n??e.edges,r=new Map;for(let a of e.nodes)r.set(a.objectApiName,a);let o=new Map,s=new Map;for(let a of e.nodes)o.set(a.objectApiName,0);for(let a of t){o.has(a.targetObject)&&o.set(a.targetObject,(o.get(a.targetObject)??0)+1);let u=s.get(a.sourceObject);u?u.push(a.targetObject):s.set(a.sourceObject,[a.targetObject])}let i=[];for(let[a,u]of o)u===0&&i.push(a);let d=[],l=new Set;for(;i.length>0;){let a=i.shift();if(l.has(a))continue;l.add(a);let u=r.get(a);u&&d.push(u);let f=s.get(a);if(f){for(let g of f)if(o.has(g)){let p=(o.get(g)??1)-1;o.set(g,p),p===0&&!l.has(g)&&i.push(g)}}}for(let a of e.nodes)l.has(a.objectApiName)||d.push(a);return d}async function Jn(e,n){let{records:t,pages:r}=await In(e,n);return{records:t,requests:r}}var ur=25,ot=15,me=5,ye=25,Ue=60,We=20,bs=6+Ue+We+1+6+1+20,te=4,fr="SELECT ApiName, Label, TriggerType, RecordTriggerType, TriggerObjectOrEvent.QualifiedApiName, ActiveVersionId, HasAsyncAfterCommitPath FROM FlowDefinitionView WHERE IsActive = true AND TriggerType IN ('RecordBeforeSave', 'RecordAfterSave', 'RecordBeforeDelete')",gr="SELECT Name, NamespacePrefix, TableEnumOrId, EntityDefinition.QualifiedApiName, UsageBeforeInsert, UsageAfterInsert, UsageBeforeUpdate, UsageAfterUpdate, UsageBeforeDelete, UsageAfterDelete, UsageAfterUndelete FROM ApexTrigger WHERE Status = 'Active'",pr="SELECT ApiName, Label, TriggerObjectOrEvent.QualifiedApiName, ActiveVersionId FROM FlowDefinitionView WHERE IsActive = true AND ProcessType = 'Workflow'",mr="SELECT Id, Name, NamespacePrefix, TableEnumOrId FROM WorkflowRule",yr="SELECT Name, SobjectType FROM AssignmentRule WHERE Active = true",hr="SELECT DeveloperName, MasterLabel, SobjectType FROM DuplicateRule WHERE IsActive = true",wr="SELECT DeveloperName, NamespacePrefix FROM UserSetupEntityAccess WHERE KeyPrefix = '0CP'";function Zn(e){return`SELECT Metadata FROM Flow WHERE Id = '${e}'`}function Rr(e,n){if(n.length>me)throw new Error(`A Tooling composite holds ${me} queries, not ${n.length}`);return{allOrNone:!1,compositeRequest:n.map((t,r)=>({method:"GET",url:`${e}/tooling/query?q=${encodeURIComponent(t)}`,referenceId:`q${r}`}))}}function br(e,n){if(n.length>ye)throw new Error(`A Tooling composite retrieves ${ye} records, not ${n.length}`);return{allOrNone:!1,compositeRequest:n.map(({sobject:t,id:r},o)=>{if(!B.test(r))throw new Error(`Not a record id: ${r}`);return{method:"GET",url:`${e}/tooling/sobjects/${t}/${r}`,referenceId:`r${o}`}})}}var pe="PROCESSING_HALTED",Tr=Z({compositeResponse:de(Z({body:ce(),httpStatusCode:pn(),referenceId:Q()}).loose())}),Sr=Z({records:de(ve(Q(),ce()))}).loose(),Ar=ve(Q(),ce()),Or=de(Z({errorCode:Q().optional(),message:Q().optional()}).loose());function st(e,n,t,r,o){let s=Tr.safeParse(e);if(!s.success)throw new Error("The org answered the Tooling composite with no composite answer");let i=new Map(s.data.compositeResponse.map(d=>[d.referenceId,d]));return Array.from({length:n},(d,l)=>{let a=i.get(`${t}${l}`);if(!a)return{refused:`The org gave no answer to this ${r} of the composite`};if(a.httpStatusCode<400){let g=o(a.body);return g?{records:g}:{refused:`The org answered with status ${a.httpStatusCode} and no rows`}}let u=Or.safeParse(a.body),f=u.success?u.data[0]:void 0;return{refused:f?[f.errorCode,f.message].filter(Boolean).join(": "):`status ${a.httpStatusCode}`,...f?.errorCode===pe?{halted:!0}:{}}})}function Fr(e,n){return st(e,n,"q","query",t=>{let r=Sr.safeParse(t);return r.success?r.data.records:void 0})}function Er(e,n){return st(e,n,"r","retrieve",t=>{let r=Ar.safeParse(t);return r.success?[r.data]:void 0})}function kr(e){return async n=>Er(await e.request({method:"POST",url:"/tooling/composite",body:JSON.stringify(br(`/services/data/v${e.version}`,n)),headers:{"Content-Type":"application/json"}}),n.length)}function Ts(e){return{query:async(n,t)=>{let r=await e(n);return Jn({query:async o=>r.query(o),queryMore:async o=>r.queryMore(o)},t)},toolingQuery:async(n,t)=>{let r=await e(n);return Jn({query:async o=>r.tooling.query(o),queryMore:async o=>r.tooling.queryMore(o)},t)},toolingQueries:async(n,t)=>{let r=await e(n),o=await r.request({method:"POST",url:"/tooling/composite",body:JSON.stringify(Rr(`/services/data/v${r.version}`,t)),headers:{"Content-Type":"application/json"}});return Fr(o,t.length)},toolingRetrieves:async(n,t)=>kr(await e(n))(t)}}async function Nr(e,n,t,r){let o=n.map(u=>({retrieving:r?u.queries.filter(f=>f.retrieve!==void 0):[],waiting:r?u.queries.filter(f=>f.retrieve===void 0):[...u.queries],left:u.requests})),s={retrieving:ye,waiting:me},i=(u,f)=>{for(let g of o){let p=f.filter(w=>w.queue===g).map(w=>w.query);p.length>0&&g[u].unshift(...p)}},d=(u,f)=>{for(let g of o){let p=f.filter(w=>w.queue===g).map(w=>w.query);p.length===0&&g.retrieving.length===0||(g.reason??=u,g.waiting.unshift(...p,...g.retrieving.splice(0)))}},l=0,a=async()=>{for(;;){let u=o.find(R=>R.left>0&&(R.retrieving.length>0||R.waiting.length>0));if(!u)return;let f=u.retrieving.length>0?"retrieving":"waiting";u.left--,l++;let g=[];for(let R of o){if(R!==u&&R.left<=0)continue;let I=s[f]-g.length;if(I<=0)break;for(let h of R[f].splice(0,I))g.push({query:h,queue:R})}let p;try{p=r&&f==="retrieving"?await r(g.map(({query:R})=>R.retrieve)):await e(g.map(({query:R})=>R.soql))}catch(R){let I=G(R);if(f==="retrieving")d(I,g);else for(let{query:h}of g)h.refused(I);continue}let w=f==="retrieving"?"retrieve":"query",T=[],S=[],b=0,x,N;if(g.forEach((R,I)=>{let h=p[I]??{refused:`The org gave no answer to this ${w} of the composite`};"records"in h?(R.query.take(h.records),b++):h.halted?(T.push(R),x??=h.refused):f==="retrieving"?(S.push(R),N??=h.refused):R.query.refused(h.refused)}),f==="retrieving"&&b===0){d(N??x??pe,g);continue}if(S.length>0){for(let{queue:R}of S)R.reason??=N;i("waiting",S)}if(T.length===0)continue;let k=g.length-T.length;if(k===0){for(let{query:R}of T)R.refused(x??pe);continue}s[f]=Math.min(s[f],k);for(let{queue:R}of T)R.reason=x;i(f,T)}};await Promise.all(Array.from({length:Math.max(1,t)},a));for(let u of o)for(let f of[...u.retrieving,...u.waiting])f.refused(u.reason??pe);return l}function Ir(e){return`SELECT Metadata FROM WorkflowRule WHERE Id = '${e}'`}function xr(e){return`SELECT FlowVersionViewId, ApiName, ObjectType FROM FlowVariableView WHERE FlowVersionViewId IN (${e.map(t=>`'${t}'`).join(", ")})`}function vr(e){return`SELECT DurableId, QualifiedApiName FROM EntityDefinition WHERE QualifiedApiName IN (${e.map(t=>`'${t}'`).join(", ")})`}function Pr(e){return`SELECT Id, DeveloperName, NamespacePrefix FROM CustomPermission WHERE DeveloperName IN (${e.map(t=>`'${t}'`).join(", ")})`}function Cr(e){return`SELECT SetupEntityId, ParentId, Parent.Name, Parent.Label, Parent.NamespacePrefix FROM SetupEntityAccess WHERE SetupEntityType = 'CustomPermission' AND SetupEntityId IN (${e.map(t=>`'${t}'`).join(", ")}) AND Parent.IsOwnedByProfile = false AND Parent.PermissionSetGroupId = null`}function Mr(e,n){let t=n.map(r=>`'${r}'`).join(", ");return`SELECT ParentId, COUNT(Id) n FROM ${e} WHERE ParentId IN (${t}) GROUP BY ParentId`}var B=/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/,Ve=/^[A-Za-z][A-Za-z0-9_]{0,79}$/,jr="myvariable_current",$r={RecordBeforeSave:"beforeSave",RecordAfterSave:"afterSave",RecordBeforeDelete:"beforeDelete"},_r={Create:"create",Update:"update",CreateAndUpdate:"createAndUpdate",Delete:"delete"},it={onCreateOnly:"create",onAllChanges:"createAndUpdate",onCreateOrTriggeringUpdate:"createAndUpdate"},Lr=[["UsageBeforeInsert","beforeInsert"],["UsageAfterInsert","afterInsert"],["UsageBeforeUpdate","beforeUpdate"],["UsageAfterUpdate","afterUpdate"],["UsageBeforeDelete","beforeDelete"],["UsageAfterDelete","afterDelete"],["UsageAfterUndelete","afterUndelete"]],Dr={emailAlert:"email",emailSimple:"email",customNotificationAction:"notification",outboundMessage:"outbound"},qr={emailSimple:"SingleEmail",emailAlert:"DailyWorkflowEmails"},Br={Alert:"email",OutboundMessage:"outbound"},Gr=new Set(["sms","mms","twilio","whatsapp","vonage","nexmo","messagebird","plivo","sinch"]);function Ke(e){if(typeof e!="object"||e===null)return;let n=e.QualifiedApiName;return typeof n=="string"&&n!==""?n:void 0}var y=e=>typeof e=="string"?e:"";function E(e,n){return typeof e=="object"&&e!==null?e[n]:void 0}function M(e){return Array.isArray(e)?e.filter(n=>typeof n=="object"&&n):[]}function Je(e,n,t,r){return{apiName:e,label:n||e,timing:t,startsOn:r,condition:"notRead",permissions:[],paths:[],messages:[],switches:[]}}function Ur(e){let n=Ke(e.TriggerObjectOrEvent),t=$r[y(e.TriggerType)];if(!n||!t)return;let r=t==="beforeDelete"?"delete":_r[y(e.RecordTriggerType)]??"createAndUpdate",o=y(e.ActiveVersionId),s=Je(y(e.ApiName),y(e.Label),t,r);return e.HasAsyncAfterCommitPath===!0&&(s.paths=[{kind:"async"}]),{objectApiName:n,id:B.test(o)?o:null,flow:s}}function Wr(e){let n=y(e.ActiveVersionId);return{objectApiName:Ke(e.TriggerObjectOrEvent),id:B.test(n)?n:null,flow:Je(y(e.ApiName),y(e.Label),"afterSave","createAndUpdate")}}function Vr(e){let n=Ke(e.EntityDefinition)??(y(e.TableEnumOrId)||void 0),t=y(e.Name);if(!n||!t)return;let r=y(e.NamespacePrefix);return{objectApiName:n,trigger:{name:r?`${r}.${t}`:t,events:Lr.filter(([o])=>e[o]===!0).map(([,o])=>o)}}}function Yn(e){return e.startsOn==="create"||e.startsOn==="createAndUpdate"?e.timing==="afterSave"?0:1:e.startsOn==="update"?2:3}function at(e){let n=new Set(pt(JSON.stringify(e??null)).filter(o=>re(o)==="Permission").map(ze));if(n.size===0)return[];let t=E(e,"filterFormula"),r=new Set((typeof t=="string"?oe(t):[]).filter(o=>re(o.reference)==="Permission"&&o.value===void 0).map(o=>ze(o.reference)));return[...n].sort((o,s)=>o.localeCompare(s)).map(o=>({name:o,bypass:r.has(o)}))}function ct(e){return typeof e!="string"?[]:ht(oe(e)).filter(n=>re(n.reference)!=="Permission").map(n=>({...n,where:"start",bypass:!0}))}var dt={permission:"Permission",setup:"Setup",user:"User",profile:"Profile",custommetadata:"CustomMetadata"},lt=String.raw`[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*`,ut=new RegExp(String.raw`\$(?:Permission|Setup|User|Profile|CustomMetadata)\.${lt}`,"gi"),K=String.raw`(?:\{!\s*)?(\$(?:Permission|Setup|User|Profile|CustomMetadata)\.${lt})\s*\}?`,zr=new RegExp(`^${K}$`,"i"),Qr=new RegExp(`^NOT\\s+${K}$`,"i"),ft=new RegExp(`^(?:${K}\\s*(==?|<>|!=)\\s*(TRUE|FALSE)|(TRUE|FALSE)\\s*(==?|<>|!=)\\s*${K})$`,"i"),Xn=String.raw`("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')`,gt=new RegExp(`^(?:${K}\\s*(==?|<>|!=)\\s*${Xn}|${Xn}\\s*(==?|<>|!=)\\s*${K})$`,"i");function W(e){let n=e.indexOf("."),t=dt[e.slice(1,n).toLowerCase()];return t?`$${t}${e.slice(n)}`:e}function re(e){return dt[e.slice(1,e.indexOf(".")).toLowerCase()]}function ze(e){return e.slice(e.indexOf(".")+1)}function pt(e){return[...new Set([...e.matchAll(ut)].map(n=>W(n[0])))]}var Hr=new RegExp(`^${ut.source}$`,"i");function mt(e){return typeof e=="string"&&Hr.test(e)}function he(e,n){return e.toLowerCase()===n.toLowerCase()}function yt(e){return e.slice(1,-1).replace(/\\(.)/g,"$1")}function ht(e){let n=new Map;for(let t of e)n.set(`${t.reference.toLowerCase()}=${t.value??""}`,t);return[...n.values()]}function et(e,n){return e.some(t=>he(t.reference,n.reference)&&t.value===n.value)}function oe(e){return Qe(e).flatMap(Kr)}function Ze(e){return He(e).flatMap(Jr)}function Kr(e){let n=ft.exec(e);if(n){let[,o,s,i,d,l,a]=n,u=s??l,f=(i??d).toUpperCase();return(u.startsWith("=")?f==="FALSE":f==="TRUE")?[{reference:W(o??a)}]:[]}let t=gt.exec(e);if(t){let[,o,s,i,d,l,a]=t;return(s??l).startsWith("=")?[]:[{reference:W(o??a),value:yt(i??d)}]}let r=Re(e,"NOT");if(r===void 0){let o=Qr.exec(e);return o?[{reference:W(o[1])}]:[]}return Ze(r)}function Jr(e){let n=zr.exec(e);if(n)return[{reference:W(n[1])}];let t=ft.exec(e);if(t){let[,s,i,d,l,a,u]=t,f=i??a,g=(d??l).toUpperCase();return(f.startsWith("=")?g==="TRUE":g==="FALSE")?[{reference:W(s??u)}]:[]}let r=gt.exec(e);if(r){let[,s,i,d,l,a,u]=r;return(i??a).startsWith("=")?[{reference:W(s??u),value:yt(d??l)}]:[]}let o=Re(e,"NOT");return o===void 0?[]:oe(o)}function Qe(e){let n=wt(e),t=Re(n,"AND");if(t)return we(t,",").flatMap(Qe);let r=we(n,"&&");return r.length>1?r.flatMap(Qe):[n]}function He(e){let n=wt(e),t=Re(n,"OR");if(t)return we(t,",").flatMap(He);let r=we(n,"||");return r.length>1?r.flatMap(He):[n]}function Re(e,n){let t=new RegExp(`^${n}\\s*\\(([\\s\\S]*)\\)$`,"i").exec(e);return t&&Rt(t[1])?t[1]:void 0}function wt(e){let n=e.trim();for(;n.startsWith("(")&&n.endsWith(")")&&Rt(n.slice(1,-1));)n=n.slice(1,-1).trim();return n}function Rt(e){let n=0;for(let{char:t,quoted:r}of bt(e))if(!r){if(t==="(")n++;else if(t===")"&&--n<0)return!1}return n===0}function we(e,n){let t=[],r=0,o=0;for(let{char:s,index:i,quoted:d}of bt(e))d||(s==="("?r++:s===")"?r--:r===0&&e.startsWith(n,i)&&(t.push(e.slice(o,i).trim()),o=i+n.length));return t.push(e.slice(o).trim()),t.filter(s=>s!=="")}function*bt(e){let n=null;for(let t=0;t<e.length;t++){let r=e[t];if(n){r==="\\"?t++:r===n&&(n=null),yield{char:r,index:t,quoted:!0};continue}if(r==='"'||r==="'"){n=r,yield{char:r,index:t,quoted:!0};continue}yield{char:r,index:t,quoted:!1}}}function Zr(e){let n=E(e,"start");if(typeof n=="object"&&n!==null){let t=y(E(E(n,"connector"),"targetReference"))||void 0,r=M(E(n,"scheduledPaths")).map(o=>y(E(E(o,"connector"),"targetReference"))||void 0);return{name:t,everyPath:r.every(o=>o===t)}}return{name:y(E(e,"startElementReference"))||void 0,everyPath:!0}}function Yr(e,n){let t=e.leftValueReference,r=e.rightValue;if(mt(t)){let s=W(t);if(typeof E(r,"booleanValue")=="boolean")return[{reference:s}];let i=E(r,"stringValue");return typeof i=="string"?[{reference:s,value:i}]:[]}let o=typeof t=="string"?n.get(t):void 0;return o===void 0?[]:[...Ze(o),...oe(o)]}function Xr(e,n){let t=e.leftValueReference,r=typeof t=="string"?n.get(t):void 0;return pt([typeof t=="string"?t:"",y(E(e.rightValue,"elementReference")),r??""].join(" "))}function eo(e,n,t){let{leftValueReference:r,operator:o,rightValue:s}=e;if(o!=="EqualTo"&&o!=="NotEqualTo")return"unknown";let i=o==="EqualTo",d=E(s,"booleanValue");if(mt(r)){if(!he(r,n.reference))return"unknown";if(typeof d=="boolean"&&n.value===void 0)return d===i?"true":"false";let u=E(s,"stringValue");return typeof u=="string"&&n.value!==void 0?u===n.value===i?"true":"false":"unknown"}let l=typeof r=="string"?t.get(r):void 0;if(l===void 0||typeof d!="boolean")return"unknown";let a=d===i;return et(Ze(l),n)?a?"true":"false":et(oe(l),n)?a?"false":"true":"unknown"}function no(e,n,t){let r=M(e.conditions);if(r.length===0)return"unknown";let o=r.map(i=>eo(i,n,t)),s=y(e.conditionLogic).toLowerCase()||"and";return s==="and"?o.includes("false")?"false":o.every(i=>i==="true")?"true":"unknown":s==="or"?o.includes("true")?"true":o.every(i=>i==="false")?"false":"unknown":"unknown"}function to(e,n,t){for(let r of M(e.rules)){let o=no(r,n,t),s=!y(E(r.connector,"targetReference"));if(o!=="false"){if(o==="true")return s;if(!s)return!1}}return!y(E(e.defaultConnector,"targetReference"))}function Tt(e){let n=M(E(e,"decisions")),t=new Map(M(E(e,"formulas")).filter(f=>typeof f.expression=="string").map(f=>[y(f.name),y(f.expression)])),r=f=>M(f.rules).flatMap(g=>M(g.conditions)),o=[...new Set(n.flatMap(f=>r(f).flatMap(g=>Xr(g,t))))];if(o.length===0)return{permissions:[],switches:[]};let{name:s,everyPath:i}=Zr(e),d=i?n.find(f=>y(f.name)===s):void 0,l=d?ht(r(d).flatMap(f=>Yr(f,t))).filter(f=>to(d,f,t)):[],a=o.filter(f=>re(f)==="Permission").map(f=>({name:ze(f),bypass:l.some(g=>he(g.reference,f)&&g.value===void 0),where:"decision"})).sort((f,g)=>f.name.localeCompare(g.name)),u=o.filter(f=>re(f)!=="Permission").flatMap(f=>{let g=l.filter(p=>he(p.reference,f));return g.length>0?g.map(p=>({...p,where:"decision",bypass:!0})):[{reference:f,where:"decision",bypass:!1}]}).sort((f,g)=>f.reference.localeCompare(g.reference));return{permissions:a,switches:u}}function ro(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(n=>n!=="").map(n=>n.toLowerCase())}function oo(...e){return e.some(n=>{let t=ro(n);return t.some(r=>Gr.has(r))||t.some((r,o)=>r==="text"&&/^messages?$/.test(t[o+1]??""))})}function St(e){return M(E(e,"actionCalls")).flatMap(n=>{let t=y(n.actionType),r=y(n.label)||y(n.name)||y(n.actionName),o=Dr[t],s=qr[t];return o?[{kind:o,name:r,...s?{limit:s}:{}}]:t==="apex"&&oo(y(n.actionName),y(n.name),r)?[{kind:"sms",name:r,guessed:!0}]:[]})}function so(e){return M(E(E(e,"start"),"scheduledPaths")).map(n=>{let t=y(n.label)||y(n.name)||void 0;if(y(n.pathType)==="AsyncAfterCommit")return{kind:"async",label:t};let r=Number(n.offsetNumber),o=y(n.timeSource)==="RecordField"?y(n.recordField):"";return{kind:"scheduled",label:t,...Number.isFinite(r)?{offset:r}:{},...y(n.offsetUnit)?{unit:y(n.offsetUnit)}:{},...o?{field:o}:{}}})}function At(e,n){let t=jn(n);t.length>0&&(e.creates=t)}function io(e,n){if(typeof n!="object"||n===null)return;let t=E(n,"start"),r=Tt(n);e.permissions=[...at(t),...r.permissions],e.switches=[...ct(E(t,"filterFormula")),...r.switches],e.paths=so(n),e.messages=St(n),At(e,n)}function ao(e,n){let t=new Map(M(E(n,"processMetadataValues")).map(o=>[y(o.name),y(E(o.value,"stringValue"))]));e.startsOn=it[t.get("TriggerType")??""]??"createAndUpdate";let r=Tt(n);return e.permissions=r.permissions,e.switches=r.switches,e.messages=St(n),At(e,n),t.get("ObjectType")||void 0}function co(e,n){e.startsOn=it[y(E(n,"triggerType"))]??"createAndUpdate";let t=E(n,"formula");e.permissions=typeof t=="string"?at({filterFormula:t}):[],e.switches=ct(t);let r=M(E(n,"workflowTimeTriggers"));return e.paths=r.map(o=>{let s=Number(o.timeLength);return{kind:"scheduled",...Number.isFinite(s)?{offset:s}:{},...y(o.workflowTimeTriggerUnit)?{unit:y(o.workflowTimeTriggerUnit)}:{},...y(o.offsetFromField)?{field:y(o.offsetFromField)}:{}}}),e.messages=[E(n,"actions"),...r.map(o=>o.actions)].flatMap(M).flatMap(o=>{let s=Br[y(o.type)];return s?[{kind:s,name:y(o.name),...s==="email"?{limit:"DailyWorkflowEmails"}:{}}]:[]}),E(n,"active")===!0}function Ot(e,n){return(e?`${e}__${n}`:n).toLowerCase()}function Ge(e,n){let t=kn(n);return t===void 0?{part:e,reason:G(n)}:{part:e,reason:`the org could not be reached (${t})`,unreachable:t}}async function ge(e,n){let t=new Array(e.length),r=0,o=async()=>{for(;r<e.length;){let s=r++;t[s]=await e[s]()}};return await Promise.all(Array.from({length:Math.min(n,e.length)},o)),t}var nt=[_,H,V,L,Y],tt=["ProductCategory","ProductCatalog"];function lo(e,n=new Set){let{referenceDataObjects:t}=Wn(void 0),r=e.nodes.filter(u=>u.included&&!n.has(u.objectApiName)&&!t.has(u.objectApiName)).map(u=>u.objectApiName),o=new Set(r),s=new Set(e.nodes.map(u=>u.objectApiName)),i=Object.entries(Rn).filter(([u,{object:f}])=>o.has(u)&&!s.has(f)&&!n.has(f)).map(([,{object:u}])=>u),d=Hn(e,n),l=u=>e.edges.some(f=>f.required===!0&&u.includes(f.sourceObject)&&d.has(f.sourceObject)&&o.has(f.targetObject)),a=i.length>0||l(nt);return[...new Set([...r,...i,...a?nt.filter(u=>d.has(u)):[],...l(tt)?tt.filter(u=>d.has(u)):[]])]}var rt=class{deps;constructor(n){this.deps=n}async readForGraph(n,t,r=new Set){return this.read(n,lo(t,r))}async read(n,t,r={}){let o=[],s=0,i=new Map(t.map(c=>[c.toLowerCase(),c])),d=c=>c===void 0?void 0:i.get(c.toLowerCase()),l=(c,m)=>async()=>{try{let O=await m();return s+=O.requests,O.records}catch(O){return s++,o.push(Ge(c,O)),[]}},a=c=>()=>this.deps.query(n,c),u=c=>()=>this.deps.toolingQuery(n,c),f=async()=>[],g=t.some(c=>/^(case|lead)$/i.test(c)),[p,w,T,S,b,x]=await ge([l("flows",a(fr)),l("triggers",u(gr)),l("processes",a(pr)),l("workflowRules",u(mr)),g?l("assignmentRules",a(yr)):f,l("duplicateRules",a(hr))],te),N=p.map(Ur).filter(c=>c!==void 0).flatMap(c=>{let m=d(c.objectApiName);return m?[{...c,objectApiName:m}]:[]}),k=w.map(Vr).filter(c=>c!==void 0).flatMap(c=>{let m=d(c.objectApiName),O=c.trigger.events.some(v=>v!=="afterUndelete"||r.undeletes===!0);return m&&O?[{...c,objectApiName:m}]:[]}),R=T.map(Wr),I=R.filter(c=>c.objectApiName===void 0&&c.id!==null).map(c=>c.id),h=t.filter(c=>c.includes("__")&&Ve.test(c)),F=S.some(c=>/^01I/.test(y(c.TableEnumOrId))),[A,$]=await ge([I.length>0?l("processes",a(xr(I))):f,F&&h.length>0?l("workflowRules",a(vr(h))):f],te),se=new Map(A.filter(c=>y(c.ApiName).toLowerCase()===jr).map(c=>[y(c.FlowVersionViewId),y(c.ObjectType)]));for(let c of R)c.objectApiName===void 0&&c.id!==null&&(c.objectApiName=se.get(c.id)||void 0);let Et=new Map($.map(c=>[y(c.DurableId),y(c.QualifiedApiName)])),be=S.flatMap(c=>{let m=y(c.TableEnumOrId),O=d(Et.get(m)??m),v=y(c.Name),P=y(c.Id);if(!O||!v)return[];let D=y(c.NamespacePrefix),z=D?`${D}.${v}`:v;return[{objectApiName:O,id:B.test(P)?P:null,flow:Je(z,z,"afterSave","createAndUpdate")}]}),Te=R.filter(c=>c.objectApiName===void 0||d(c.objectApiName)!==void 0),kt=new Map(t.map((c,m)=>[c,m])),ie=c=>kt.get(d(c.objectApiName)??"")??t.length,Se=N.filter(c=>c.id!==null).sort((c,m)=>Yn(c.flow)-Yn(m.flow)||ie(c)-ie(m)||c.flow.label.localeCompare(m.flow.label)),J=this.deps.toolingQueries,Ae=J?this.deps.toolingRetrieves:void 0,Ye=Ae?ye:me,Xe=J?Ue*Ye:ur,en=J?We*Ye:ot,Oe=Se.slice(0,Xe),nn=[...Te.map(c=>({read:c,kind:"process"})),...be.map(c=>({read:c,kind:"rule"}))].filter(({read:c})=>c.id!==null).sort((c,m)=>ie(c.read)-ie(m.read)||(c.kind===m.kind?0:c.kind==="process"?-1:1)||c.read.flow.label.localeCompare(m.read.flow.label)),tn=nn.slice(0,en),Fe,Ee,rn=new Set,on=c=>c[0]?.Metadata,Nt=(c,m)=>{c.flow.condition="read",io(c.flow,on(m))},It=(c,m)=>{c.flow.condition="unreadable",Fe??=m},xt=({read:c,kind:m})=>m==="process"?Zn(c.id):Ir(c.id),vt=({read:c,kind:m},O)=>{let v=on(O);if(typeof v!="object"||v===null){c.flow.condition="unreadable";return}if(c.flow.condition="read",m==="process"){let P=ao(c.flow,v);c.objectApiName??=P}else co(c.flow,v)||rn.add(c.flow)},Pt=({read:c},m)=>{c.flow.condition="unreadable",Ee??=m},sn=(c,m,O,v,P)=>c.map(D=>({soql:m(D),retrieve:O(D),take:z=>v(D,z),refused:z=>P(D,z)})),an=sn(Oe,c=>Zn(c.id),c=>({sobject:"Flow",id:c.id}),Nt,It),cn=sn(tn,xt,({read:c,kind:m})=>({sobject:m==="process"?"Flow":"WorkflowRule",id:c.id}),vt,Pt);J?s+=await Nr(c=>J(n,c),[{queries:an,requests:Ue},{queries:cn,requests:We}],te,Ae&&(c=>Ae(n,c))):await ge([...an,...cn].map(c=>async()=>{try{let m=await this.deps.toolingQuery(n,c.soql);s+=m.requests,c.take(m.records)}catch(m){s++,c.refused(G(m))}}),te),Fe!==void 0&&o.push(Ge("conditions",Fe)),Ee!==void 0&&o.push(Ge("definitions",Ee));for(let c of[...N,...Te,...be])c.id===null&&(c.flow.condition="unreadable");let dn=Te.flatMap(c=>{let m=d(c.objectApiName);return m?[{...c,objectApiName:m}]:[]}),ln=be.filter(c=>!rn.has(c.flow)),ke=[...N,...dn,...ln].flatMap(c=>c.flow.permissions),un;if(ke.length>0){let[c]=await ge([l("userPermissions",a(wr))],te);if(!o.some(m=>m.part==="userPermissions")){let m=new Set(c.map(O=>Ot(y(O.NamespacePrefix),y(O.DeveloperName))));un=m;for(let O of ke)O.held=m.has(O.name.toLowerCase())}}let fn=[...new Set(ke.filter(c=>c.bypass&&c.held!==!0).map(c=>c.name))],Ne=fn.length>0?await uo(fn,c=>l("permissionSets",a(c))(),()=>o.some(c=>c.part==="permissionSets"),async c=>{try{let m=await this.deps.query(n,c);return s+=m.requests,m.records}catch(m){throw s++,m}}):void 0,ae={};if(Ne?.some(c=>c.permissionSets.length>0)){let{toolingQueries:c,toolingRetrieves:m}=this.deps;try{let{readValidationRuleBypasses:O}=await import("./chunk-7ABODJ4G.mjs"),v=await O(P=>this.deps.toolingQuery(n,P),t,c&&(P=>c(n,P)),m&&(P=>m(n,P)));s+=v.requests,ae.validationRuleBypasses=v.rules.flatMap(P=>P.permissions.some(D=>un?.has(D.toLowerCase()))?[]:[P]),v.notRead>0&&(ae.validationRulesNotRead=v.notRead)}catch(O){s++,ae.validationRulesUnread=G(O)}}let Ct=c=>b.filter(m=>y(m.SobjectType).toLowerCase()===c.toLowerCase()).map(m=>({name:y(m.Name)})).sort((m,O)=>m.name.localeCompare(O.name)),Mt=c=>x.filter(m=>y(m.SobjectType).toLowerCase()===c.toLowerCase()).map(m=>({name:y(m.MasterLabel)||y(m.DeveloperName),developerName:y(m.DeveloperName)})).sort((m,O)=>m.name.localeCompare(O.name)),jt=(c,m)=>c.label.localeCompare(m.label),Ie=(c,m)=>c.filter(O=>O.objectApiName===m).map(O=>O.flow).sort(jt),xe=new Map;for(let c of Se.slice(Oe.length))xe.set(c.objectApiName,(xe.get(c.objectApiName)??0)+1);let gn=t.flatMap(c=>{let m=xe.get(c);return m?[{objectApiName:c,flows:m}]:[]}),$t=t.map(c=>({objectApiName:c,flows:Ie(N,c),triggers:k.filter(m=>m.objectApiName===c).map(m=>m.trigger).sort((m,O)=>m.name.localeCompare(O.name)),processes:Ie(dn,c),workflowRules:Ie(ln,c),assignmentRules:Ct(c),duplicateRules:Mt(c)})).filter(c=>c.flows.length>0||c.triggers.length>0||c.processes.length>0||c.workflowRules.length>0||c.assignmentRules.length>0||c.duplicateRules.length>0);return{objectsRead:[...t],objects:$t,unread:o,conditionsNotRead:Se.length-Oe.length,conditionsBound:Xe,...gn.length>0?{conditionsNotReadOn:gn}:{},definitionsNotRead:nn.length-tn.length,definitionsBound:en,...Ne?{bypassGrants:Ne}:{},...ae,requests:s}}};function q(e){return e.slice(0,15)}async function uo(e,n,t,r){let o=e.flatMap(p=>{let w=p.indexOf("__"),T=w>0?p.slice(0,w):"",S=w>0?p.slice(w+2):p;return Ve.test(S)&&(!T||Ve.test(T))?[{name:p,developerName:S}]:[]});if(o.length===0)return;let s=await n(Pr([...new Set(o.map(p=>p.developerName))]));if(t())return;let i=new Map;for(let p of s){let w=y(p.Id);B.test(w)&&i.set(Ot(y(p.NamespacePrefix),y(p.DeveloperName)),w)}let d=o.flatMap(p=>{let w=i.get(p.name.toLowerCase());return w?[w]:[]}),l=d.length>0?await n(Cr(d)):[];if(t())return;let a=[...new Set(l.map(p=>y(p.ParentId)).filter(p=>B.test(p)))],u=new Map;for(let p of["SetupEntityAccess","ObjectPermissions"]){if(a.length===0)break;let w=await n(Mr(p,a));if(t())return;for(let T of w){let S=q(y(T.ParentId)),b=typeof T.n=="number"?T.n:Number(T.n);u.set(S,(u.get(S)??0)+(Number.isFinite(b)?b:0))}}let f=new Map;for(let p of s){let w=y(p.Id);B.test(w)&&f.set(q(w),Ft(y(p.NamespacePrefix),y(p.DeveloperName)))}let g=r&&a.length>0?await po(a,f,r):void 0;return o.map(({name:p})=>{let w=i.get(p.toLowerCase()),T=new Map;for(let S of l){if(!w||q(y(S.SetupEntityId))!==q(w))continue;let b=q(y(S.ParentId)),x=S.Parent,N=y(E(x,"Name"));if(!N||T.has(b))continue;let k=y(E(x,"NamespacePrefix"));T.set(b,{name:k?`${k}__${N}`:N,label:y(E(x,"Label"))||N,grants:u.get(b)??0,...g===void 0?{}:"refused"in g?{customPermissionsUnread:g.refused}:{customPermissions:g.bySet.get(b)??[]}})}return{permission:p,permissionSets:[...T.values()].sort((S,b)=>S.grants-b.grants||S.name.localeCompare(b.name))}})}function Ft(e,n){return e?`${e}__${n}`:n}function fo(e){return`SELECT ParentId, SetupEntityId FROM SetupEntityAccess WHERE SetupEntityType = 'CustomPermission' AND ParentId IN (${e.map(t=>`'${t}'`).join(", ")})`}function go(e){return`SELECT Id, DeveloperName, NamespacePrefix FROM CustomPermission WHERE Id IN (${e.map(t=>`'${t}'`).join(", ")})`}async function po(e,n,t){try{let r=await t(fo(e)),o=new Map(n),s=[...new Set(r.map(d=>y(d.SetupEntityId)).filter(d=>B.test(d)&&!o.has(q(d))))];if(s.length>0)for(let d of await t(go(s))){let l=y(d.Id);B.test(l)&&o.set(q(l),Ft(y(d.NamespacePrefix),y(d.DeveloperName)))}let i=new Map;for(let d of r){let l=q(y(d.ParentId)),a=o.get(q(y(d.SetupEntityId)));if(!a)continue;let u=i.get(l)??[];u.includes(a)||u.push(a),i.set(l,u)}for(let d of i.values())d.sort((l,a)=>l.localeCompare(a));return{bySet:i}}catch(r){return{refused:G(r)}}}var mo={insert:"on insert",update:"on update",delete:"on delete"},yo={insert:{before:"before save",after:"after save",beforeAndAfter:"before and after save"},update:{before:"before save",after:"after save",beforeAndAfter:"before and after save"},delete:{before:"before delete",after:"after delete",beforeAndAfter:"before and after delete"}},ho={flow:e=>`flow "${e}"`,trigger:e=>`Apex trigger ${e}`,process:e=>`process "${e}"`,workflowRule:e=>`workflow rule "${e}"`},wo={flows:"the flows",triggers:"the Apex triggers",conditions:"the start conditions of some flows",processes:"the Process Builder processes",workflowRules:"the workflow rules",definitions:"the definitions of some processes or workflow rules",assignmentRules:"the assignment rules",duplicateRules:"the duplicate rules",userPermissions:"the custom permissions of the user the run writes as",permissionSets:"the permission sets that hold a bypass the user the run writes as does not"},Ro={email:"email",notification:"custom notification",outbound:"outbound message",sms:"text message"};function bo(e){let n=e.guessed?" (guessed from the name of an Apex action)":"";return`${Ro[e.kind]} "${e.name}"${n}`}function To(e){let n=e.label?` "${e.label}"`:"";if(e.kind==="async")return`asynchronous path${n}`;if(e.offset===void 0||e.unit===void 0)return`scheduled path${n}`;let t=Math.abs(e.offset),r=t===1?e.unit.replace(/s$/,""):e.unit,o=e.offset<0?"before":"after";return`scheduled path${n} (${t} ${r} ${o} ${e.field??"the save"})`}function So(e){let n=e.value===void 0?"true":`'${e.value}'`;return e.where==="decision"?`its first decision ends it when ${e.reference} is ${n}`:`not when ${e.reference} is ${n}`}function Ao(e,n){let t=e.flow,r=t?.permissions??[],o=t?.switches??[],s=t?.messages??[],i=t?.paths??[],d=p=>p.held===!0?" (held)":p.held===!1?" (not held)":"",l=r.filter(p=>p.bypass&&p.where!=="decision"),a=r.filter(p=>p.bypass&&p.where==="decision"),u=r.filter(p=>!p.bypass&&p.where!=="decision"),f=[...r.filter(p=>!p.bypass&&p.where==="decision").map(p=>p.name),...o.filter(p=>!p.bypass).map(p=>p.reference)],g=e.kind==="flow"?"start condition":"definition";return[yo[n][e.when],...s.length>0?[`SENDS MESSAGES: ${s.map(bo).join(", ")}`]:[],...i.length>0?[`then after commit: ${i.map(To).join(", ")}`]:[],...l.length>0?[`not for a user with ${l.map(p=>p.name+d(p)).join(", ")}`]:[],...a.length>0?[`its first decision ends it for a user with ${a.map(p=>p.name+d(p)).join(", ")}`]:[],...o.filter(p=>p.bypass).map(So),...e.keptQuiet?["quiet for this run"]:[],...u.length>0?[`its start condition names ${u.map(p=>p.name).join(", ")}`]:[],...f.length>0?[`its decisions test ${f.join(", ")}`]:[],...t?.condition==="notRead"?[`${g} not read`]:[],...t?.condition==="unreadable"?[`${g} unreadable`]:[]]}function Ss(e,n,t={}){let r=[`target automation: what ${n} runs on the ${e.objectsRead.length} object(s) the run writes`];for(let i of e.objects){r.push(` ${i.objectApiName}`);for(let{write:a,fired:u}of Tn(i)){let f=u.map(g=>`${ho[g.kind](g.name)} (${Ao(g,a).join("; ")})`);r.push(` ${mo[a]}: ${f.join(", ")}`)}let d=t.mayApplyAssignmentRules!==!1;for(let a of i.assignmentRules??[])r.push(t.applyAssignmentRules?` assignment rule "${a.name}": applied${d?" (--apply-assignment-rules)":""}: it can give the records it routes another owner, and mail that owner`:` assignment rule "${a.name}": not applied: the run sends Sforce-Auto-Assign: FALSE and keeps the owner it sets${d?" (--apply-assignment-rules applies it)":""}`);let l=i.duplicateRules??[];l.length>0&&r.push(` duplicate rules: ${l.map(a=>`"${a.name}"`).join(", ")}: the run saves a record a rule only alerts on; a rule that blocks still refuses it`)}e.objects.length===0&&r.push(On(e.unread)?" nothing found in what could be read":" no active flow, process, workflow rule, Apex trigger, assignment rule or duplicate rule runs on them");let o=An(e),s=Sn(e).filter(i=>!o.includes(i));if(s.length>0){r.push(` bypass: assign ${s.join(", ")} to the user the run writes as, and the flows whose start condition excludes them stay quiet`+(t.mayMute!==!1?"; --mute-automation assigns them for the run alone, and takes them back as it ends":""));for(let{permission:i,permissionSet:d,others:l}of Fn(e,s)){if(!d){r.push(` ${i}: no permission set of ${n} holds it: an admin creates one that includes it`);continue}let a=l.length>0?`; also held by ${l.map(f=>f.name).join(", ")}`:"",u=t.username?`: ${En(d.name,n,t.username)}`:"";r.push(` ${i}: held by permission set ${d.name}, the smallest${a}${u}`)}}if(o.length>0&&r.push(` bypass held: the user the run writes as holds ${o.join(", ")}, and what excludes them stays quiet for this run`),e.conditionsNotRead>0){let i=(e.conditionsNotReadOn??[]).map(({objectApiName:d,flows:l})=>`${d} (${l})`).join(", ");r.push(` ${e.conditionsNotRead} start condition(s) not read: the read takes ${e.conditionsBound} at most`+(i?`; left unread on ${i}`:""))}(e.definitionsNotRead??0)>0&&r.push(` ${e.definitionsNotRead} process or workflow rule definition(s) not read: the read takes ${e.definitionsBound??ot} at most`);for(let{part:i,reason:d}of e.unread)r.push(` ${wo[i]} could not be read: ${d}`);return r.push(` read in ${e.requests} request(s) to ${n}`),r}export{Eo as a,ko as b,No as c,_n as d,Io as e,Ln as f,Vt as g,xo as h,$o as i,_o as j,Bn as k,Lo as l,Do as m,Wn as n,Le as o,Vn as p,Jt as q,H as r,Be as s,Yo as t,Xo as u,Hn as v,es as w,er as x,ns as y,ts as z,Kn as A,rs as B,os as C,ss as D,tr as E,is as F,as as G,ir as H,cs as I,ds as J,dr as K,ls as L,Jn as M,ur as N,ot as O,me as P,ye as Q,Ue as R,We as S,bs as T,fr as U,gr as V,pr as W,mr as X,yr as Y,hr as Z,wr as _,Zn as $,Rr as aa,br as ba,Fr as ca,Er as da,kr as ea,Ts as fa,Nr as ga,Ir as ha,xr as ia,vr as ja,Pr as ka,Cr as la,Mr as ma,at as na,ct as oa,Tt as pa,St as qa,so as ra,Ot as sa,Ge as ta,ge as ua,lo as va,rt as wa,uo as xa,fo as ya,go as za,Ss as Aa};
|
|
@@ -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 Ce}from"./chunk-GMY5427L.mjs";import{h as Re,i as be,j as Se,k as ke,n as Te,o as Fe}from"./chunk-KYEDBS54.mjs";import{c as Oe}from"./chunk-K2FBZIXY.mjs";import{f as he,i as me,o as we}from"./chunk-G35N4P7D.mjs";import{a as z,k as ie,n as ae,p as de,s as ce,t as ue,u as le}from"./chunk-ZUTYVST5.mjs";import{b as ye,e as ge}from"./chunk-CU2INBND.mjs";import{b as fe,c as q,m as pe}from"./chunk-WIO4XO4F.mjs";import{d as K}from"./chunk-GCOB7K5N.mjs";import{F as se,p as te,r as ne,s as re,t as oe}from"./chunk-A527W53V.mjs";import{b as ee}from"./chunk-CA5NAXSU.mjs";import{Ub as X,ic as B}from"./chunk-TTFDUKUS.mjs";var H=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function b(t){return t.slice(0,15)}var We=class{constructor(e=new Map){this.earlier=e}earlier;written=new Map;refused=new Map;deleted=new Set;ownersRefused=new Set;contactsSentWith=new Map;noteSentWithContact(e,n){this.contactsSentWith.set(b(e),n)}contactSentWith(e){return this.contactsSentWith.get(b(e))}roleLinkedFor(e){this.contactsSentWith.delete(b(e))}get sentWithAContact(){return this.contactsSentWith.size>0}noteOwnerRefused(e){this.ownersRefused.add(b(e))}isOwnerRefused(e){return this.ownersRefused.has(b(e))}noteDeleted(e){for(let n of e)this.deleted.add(b(n))}standing(e){return e!==void 0&&this.deleted.has(b(e))?void 0:e}noteMatched(e,n){this.noteWritten(e,n)}noteWritten(e,n){this.written.set(b(e),n),this.refused.delete(b(e))}noteRefused(e,n){this.written.has(b(e))||this.refused.set(b(e),n)}targetOf(e){return this.standing(this.written.get(b(e)))??this.standing(this.earlier.get(b(e)))}refusedObjectOf(e){if(this.standing(this.earlier.get(b(e)))===void 0)return this.refused.get(b(e))}};function Ae(t,e,n){if(e.length===0||!n.some(o=>!o.master))return;let r={};for(let o of e)r[o]=(r[o]??0)+1;let s=Se(be(n));return{objectApiName:t,rows:e.length,why:r,...s?{predicted:s}:{}}}function Ie(t,e){return q(t,e?.target??[])}function Y(t){switch(t.operation){case"insert":return null;case"upsert":return t.externalIdField??"Id";case"update":case"delete":return"Id"}}function ze(t,e,n,r,s){let o=ge(t,e);for(let i of n)(!(i.fieldApiName in o)||i.overwriteExisting)&&(o[i.fieldApiName]=i.value);if(!r)return o;let a={};for(let i of Object.keys(o))i!=="attributes"&&(r.has(i)||i===s)&&(a[i]=o[i]);return a}function ve(t,e){return`${t} ${e} record${t===1?"":"s"}`}function Ue(t,e,n){let r=a=>e.find(i=>b(i.recordTypeId)===b(a)),s=t;if(!r(t)&&n){let a=n.mappings.find(i=>b(i.sourceId)===b(t));if(!a){let i=n.source.find(c=>b(c.id)===b(t)),y=i?(n.target??[]).filter(c=>c.sobjectType===i.sobjectType&&c.developerName===i.developerName):[];return{unmapped:i?K(i):"",namesakes:y.map(K)}}s=a.targetId}let o=q(e.filter(a=>b(a.recordTypeId)===b(s)),n?.target??[])[0];return o&&!o.available&&!o.master?{unavailable:o}:o?{sent:s,info:o}:{sent:s}}function Ge(t,e,n){if(t?.personAccounts===!1)return!0;if(!n)return!1;let r=e??Te(t?.recordTypes);return r!==void 0&&!n.has(b(r))}function Le(t,e,n){return{group:`parent:${e}:${n}`,reason:`PARENT_REFUSED: the ${n} record its ${e} names was refused in this run.`,say:r=>`PARENT_REFUSED: ${ve(r,t)} held back, not sent: the ${n} record their ${e} names was refused in this run, and written without it they would stand without their ${n}.`}}function Ee(t){let{config:e,records:n,target:r,run:s}=t,o=e.objectApiName,a=Y(e),i=r?.recordTypes??[],y=r?.references??new Set,c={payloads:[],sentAt:[],settled:[],held:[],deferred:[],deferredAcross:[],notes:[],currencies:[],withoutRecordType:new Map},h=new Map,m=new Map,T=(d,l,g,k)=>{c.held.push({index:d,reason:g}),h.delete(d);let I=m.get(l);I?I.count++:m.set(l,{count:1,say:k})},w=e.operation==="insert"||e.operation==="upsert",W=w&&i.some(d=>!d.master),f=new Map;s&&w&&s.sources.forEach((d,l)=>{let g=d?.Id;typeof g=="string"&&H.test(g)&&f.set(b(g),l)});let v=new Set([...s&&w?s.later??[]:[]].map(d=>d.toLowerCase())),R=new Set(v.size===0?[]:(r?.fields??[]).flatMap(d=>d.isReference&&(d.referenceTo??[]).some(l=>v.has(l.toLowerCase()))&&!(d.nillable===!1&&d.defaultedOnCreate!==!0)?[d.name]:[]));n.forEach((d,l)=>{let g=ze(d,e.fieldMappings,e.addOnFields,r?.creatable??null,a);if(e.operation==="delete"){h.set(l,{payload:g,settled:new Set});return}let k=new Set;if(s)for(let p of Object.keys(g)){let C=g[p];if(p==="RecordTypeId"||!y.has(p)||typeof C!="string"||!H.test(C))continue;if(f.has(b(C))){delete g[p],c.deferred.push({index:l,field:p,parent:C});continue}let _=s.links.targetOf(C);if(_){g[p]=_,k.add(p);continue}let M=s.links.refusedObjectOf(C);if(M===void 0){R.has(p)&&(delete g[p],c.deferredAcross.push({index:l,field:p,parent:C}));continue}let G=Le(o,p,M);T(l,G.group,G.reason,G.say);return}let I=g.RecordTypeId,E,j=Oe(I);if(j)delete g.RecordTypeId;else if(typeof I=="string"&&H.test(I)){let p=Ue(I,i,s?.recordTypes);if("unmapped"in p){let C=p.unmapped,_=p.namesakes.length>0?` The target org's ${p.namesakes.join(" and ")} carries its DeveloperName under another namespace, and a record type is mapped to one of the same namespace only.`:"";T(l,`unmapped:${C}`,"RECORD_TYPE_UNMAPPED: its record type has no counterpart in the target org.",M=>`RECORD_TYPE_UNMAPPED: ${ve(M,o)} held back, not sent: `+(C?`their record type ${C} has no active ${o} record type of that API name in the target org.${_} Create or activate record type ${C} on ${o} in the target org.`:"their record type is inactive in the source org, and has no counterpart in the target org."));return}if("unavailable"in p){let C=p.unavailable;T(l,`unavailable:${C.recordTypeId}`,`RECORD_TYPE_UNAVAILABLE: record type ${C.developerName} is closed to the running user in the target org.`,_=>`${pe({objectApiName:o,recordTypeId:C.recordTypeId,developerName:C.developerName,name:C.name,inactive:!C.active,recordCount:_})} Held back, not sent.`);return}g.RecordTypeId=p.sent,E=p.sent,p.info&&k.add("RecordTypeId")}let $=s?.sources[l]??d;if(re($)){let p=oe($,Ge(r,E,s?.recordTypes?.personTypes));for(let C of Object.keys(g))B(o,C,p)&&delete g[C]}else for(let p of Object.keys(g))B(o,p,"business")&&delete g[p];W&&!("RecordTypeId"in g)&&c.withoutRecordType.set(l,j?"masterInSource":"notRead"),h.set(l,{payload:g,settled:k})});let L=!0;for(;L;){L=!1;for(let{index:d,field:l,parent:g}of c.deferred){let k=f.get(b(g));if(!h.has(d)||k===void 0||h.has(k)||s?.links.targetOf(g)!==void 0)continue;let I=Le(o,l,o);T(d,I.group,I.reason,I.say),L=!0}}c.deferred=c.deferred.filter(({index:d})=>h.has(d)),c.deferredAcross=c.deferredAcross.filter(({index:d})=>h.has(d));for(let d of[...c.withoutRecordType.keys()])h.has(d)||c.withoutRecordType.delete(d);c.held.sort((d,l)=>d.index-l.index);let S=e.operation==="delete"?void 0:s?.currencies,O=r?.creatable.has(z)===!0,u=!O&&(s?.currencyChangesById?.size??0)>0&&r?.fields?.some(d=>d.name===z)===!0,F=S&&(O||u)?ae(r?.fields??[]):void 0,P=[...r?.references??[]],A=new le;for(let[d,{payload:l,settled:g}]of[...h].sort(([k],[I])=>k-I)){for(let k of X(o,l))delete l[k];if(S&&F){let k=s?.sources[d]??n[d],I=k?.[z],E=O?de(l,{read:I,currencyFields:F,ratesOn:ie(o,k)},S):ue(l,{read:I,parent:k?ce(o,k,P,$=>s?.currencyChangesById?.get($)):void 0,currencyFields:F},S);A.add(o,E);let j=k?.Id;E&&typeof j=="string"&&s?.currencyChangesById?.set(j,E)}c.payloads.push(l),c.sentAt.push(d),c.settled.push(g)}return c.notes=[...m.values()].map(({count:d,say:l})=>l(d)),c.currencies=A.list(),c}function V(t){return typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0}function Be(t){let e=V(t.length),n=V(t.precision),r=V(t.digits);return{name:t.name,queryable:t.queryable!==!1,createable:t.createable===!0,isReference:t.type==="reference",...t.type!==void 0?{type:t.type}:{},...e!==void 0?{length:e}:{},...t.nillable!==void 0?{nillable:t.nillable}:{},...t.defaultedOnCreate!==void 0?{defaultedOnCreate:t.defaultedOnCreate}:{},...t.calculated===!0?{calculated:!0}:{},...n!==void 0?{precision:n}:{},...n!==void 0&&typeof t.scale=="number"&&t.scale>=0?{scale:t.scale}:{},...r!==void 0?{digits:r}:{},...t.unique===!0?{unique:!0}:{},...t.referenceTo?{referenceTo:[...t.referenceTo]}:{}}}function yt(t){let e=t.fields.filter(r=>r.createable===!0),n=t.fields.some(r=>typeof r.idLookup=="boolean");return{creatable:new Set(e.map(r=>r.name)),references:new Set(e.filter(r=>r.type==="reference").map(r=>r.name)),...typeof t.createable=="boolean"?{objectCreateable:t.createable}:{},...typeof t.updateable=="boolean"?{objectUpdateable:t.updateable}:{},recordTypes:fe(t.recordTypeInfos),...t.name===te?{personAccounts:t.fields.some(r=>r.name===ne)}:{},fields:t.fields.map(Be),...n?{upsertKeys:new Set(t.fields.filter(r=>r.externalId===!0||r.idLookup===!0).map(r=>r.name.toLowerCase()))}:{}}}function Z(t,e,n){switch(e){case"notInTarget":return`Object is not in the target org, or the user the run writes as cannot see it: ${t}. None of its records were sent.`;case"notCreateable":return`Object is not createable on target org: the user the run writes as may not create ${t} records there. None of its records were sent.`;case"notUpdateable":return`Object is not updateable on target org: the user the run writes as may not edit ${t} records there. None of its records were sent.`;case"unread":return`The target org did not describe ${t}${n?` (${n})`:""}, so what it takes could not be told and none of its records were sent.`;case"notAKey":return`The upsert of ${t} matches on ${n??"a field"}, which the target org does not match an upsert on: it takes an External ID field, the Id, or a field its describe marks idLookup. None of its records were sent.`}}function gt(t,e){let n=t.externalIdField?.trim().toLowerCase();if(t.operation!=="upsert"||!n)return t;let r=e.fields?.find(s=>s.name.toLowerCase()===n)?.name;return r===void 0?t:{...t,externalIdField:r}}function ht(t,e){if(t.operation==="delete"||t.query===void 0)return t;let n=Ce(t.query);if(!("list"in n))return t;let r=new Set([...n.list,t.externalIdField??"",...t.fieldMappings.filter(o=>ye.has(o.type)).map(o=>o.sourceField)].map(o=>o.toLowerCase())),s=[...e.creatable].filter(o=>!r.has(o.toLowerCase()));return s.length===0?t:{...t,excludedFields:[...new Set([...t.excludedFields??[],...s])]}}async function Pe(t,e,n,r){let s;try{s=await t(e)}catch(c){if(n==="delete")return{notAsked:!0};let h=Fe(c)?"notInTarget":"unread";return{refused:{why:h,message:Z(e,h,ee(c))}}}let o=n==="insert"||n==="upsert",a=n==="update"||n==="upsert",i=o&&s.objectCreateable===!1?"notCreateable":a&&s.objectUpdateable===!1?"notUpdateable":void 0;if(i)return{refused:{why:i,message:Z(e,i)},target:s};let y=r?.trim()||"Id";return n==="upsert"&&s.upsertKeys&&!s.upsertKeys.has(y.toLowerCase())?{refused:{why:"notAKey",message:Z(e,"notAKey",y),key:y},target:s}:{target:s}}function Rt(t){return t.keepContactPoints===!0?void 0:new Re}function Ot(t,e){if(!t)return e?{neutralized:!1,fields:[],values:0}:void 0;let n=t.report();return n.values>0?n:void 0}function xe(t,e,n,r,s){let o=s?n.filter(i=>i.name!==s):n,a=t.forObject(e,o);if(a)for(let i of r)a(i)}var x=class extends Error{constructor(n,r=[],s=[],o=[],a){super(r.length===0?`The write of ${n} was cancelled before any of its records was written.`:`The write of ${n} was cancelled after ${r.length} of its records were sent.`);this.objectApiName=n;this.written=r;this.notes=s;this.lookupsLeftOut=o;this.writtenWithoutFields=a;this.name="WriteCancelledError"}objectApiName;written;notes;lookupsLeftOut;writtenWithoutFields};var Ne=class{deps;constructor(e){this.deps=e}async sync(e,n,r){let{outcomes:s,notes:o,currencies:a,lookupsLeftOut:i,writtenWithoutFields:y}=await this.write(e,n,r);return Je(Qe(e.objectApiName,e.operation,s,o,i,y),a)}updateRecords(e,n,r){return this.executeOperation(e,"update",n,r)}async write(e,n,r){let s=null;if(this.deps.describeTargetFields){let u=await Pe(this.deps.describeTargetFields,e.objectApiName,e.operation,e.externalIdField);if("refused"in u){let F=n.map(()=>({success:!1,errors:[u.refused.message]}));return r&&$e(e,F,r),{outcomes:F,notes:[],currencies:[],lookupsLeftOut:[]}}"target"in u&&u.target.creatable.size>0&&(s=u.target)}let o=Ee({config:e,records:n,target:s,run:r}),a=r?r.contactPoints:this.deps.contactPoints;a&&s?.fields&&xe(a,e.objectApiName,s.fields,o.payloads,e.externalIdField);let i=He(o.payloads,o.settled,r),y=new Map(o.held.map(({index:u,reason:F})=>[u,F])),c=u=>{let F=[],P=0;for(let A=0;A<n.length;A++){let d=y.get(A);if(d!==void 0){F.push({success:!1,errors:[d],heldBack:!0});continue}if(P>=u.length)break;F.push(u[P++])}return F},h,m=o.sentAt.filter(u=>u<(r?.standardFirst??0)).length,T=u=>this.executeOperation(e.objectApiName,e.operation,u,e.batchSize,e.externalIdField);try{h=o.payloads.length===0&&n.length>0?[]:m>0&&m<o.payloads.length?await Ve(e.objectApiName,T,o.payloads.slice(0,m),o.payloads.slice(m)):await T(o.payloads)}catch(u){if(!(u instanceof x))throw u;let F=je(i,u.written),P=c(u.written);throw De(e,o.withoutRecordType,P,s,r),new x(e.objectApiName,P,[...o.notes,...u.notes],[...F?[F]:[],...u.lookupsLeftOut,...Q(U([...o.deferred,...o.deferredAcross],P))],u.writtenWithoutFields)}let w=await this.retryRefused(e,o.payloads,h,s?.references??null,o.settled);if(r)for(let u of w.ownersRefused)r.links.noteOwnerRefused(u);let W=c(w.outcomes);De(e,o.withoutRecordType,W,s,r);let f=je(i,w.outcomes),v=[...o.notes,...w.notes],R=[...f?[f]:[],...w.lookupsLeftOut],{writtenWithoutFields:L}=w,S=U(o.deferredAcross,W),O=0;if(w.cancelled)throw new x(e.objectApiName,W,v,[...R,...Q([...U(o.deferred,W),...S])],L);if(r){$e(e,W,r),Ze(e,o.payloads,w.outcomes,r.links);let u=await this.setLookups(e,U(o.deferred,W),r.links,!1);if(R.push(...u.leftOut),O=u.unset,u.cancelled)throw new x(e.objectApiName,W,v,[...R,...Q(S)],L)}return{outcomes:W,notes:v,currencies:o.currencies,lookupsLeftOut:R,...L?{writtenWithoutFields:L}:{},...S.length>0?{lookupsToSet:S}:{},...O>0?{lookupsUnset:O}:{}}}async setLookups(e,n,r,s){let o=e.objectApiName,a=new Map,i=new Map,y=new D;for(let{id:f,field:v,parent:R}of n){let L=r.targetOf(R),S=L!==void 0?a:s&&r.refusedObjectOf(R)===void 0?i:void 0;if(!S){y.add(f,v);continue}let O=S.get(f)??{Id:f};O[v]=L??R,S.set(f,O)}let c=new D,h=new D,m=new D,T=new D,w=!1;for(let f of[[...a.values()],[...i.values()]]){if(f.length===0)continue;if(w){for(let R of f)T.addRow(R);continue}let v;try{v=await this.executeOperation(o,"update",f,e.batchSize)}catch(R){if(!(R instanceof x)){let L=R instanceof Error?R.message:String(R);for(let S of f)m.addRow(S,L);continue}v=R.written,w=!0}f.forEach((R,L)=>{let S=v[L];S===void 0?T.addRow(R):S.success?c.addRow(R):S.errors.some(O=>J(O))?h.addRow(R):m.addRow(R,S.errors[0])})}let W=[y,h,m,T];return{...c.records>0?{set:{records:c.records,fields:c.fields()}}:{},leftOut:[y.leftOut("parentRefused"),h.leftOut("notInTarget"),m.leftOut("notSet"),T.leftOut("notReached")].flatMap(f=>f?[f]:[]),unset:new Set(W.flatMap(f=>[...f.recordIds])).size,cancelled:w}}async retryRefused(e,n,r,s,o){let a=Y(e)??void 0,i=[...r],y=[...n],c=n.map(()=>new Set),h=n.map(()=>[]),m=n.map(()=>[]),T=[],w,W=new Set;for(let S=0;S<2&&!w;S++){let O=[],u=[],F=[];if(i.forEach((A,d)=>{if(A.success)return;let l=y[d],g=o[d]??new Set;if(A.errors.some(E=>J(E))){let E=n[d]?.[N];if(typeof E=="string"&&!g.has(N)&&(A.errorDetails??[]).some(p=>J(p.statusCode)&&p.fields.includes(N))&&W.add(E),c[d].has("lookup")||!s||s.size===0)return;let j={},$=!1;for(let p of Object.keys(l)){if(s.has(p)&&!g.has(p)&&l[p]!==null&&l[p]!==void 0){$=!0;continue}j[p]=l[p]}if(!$)return;O.push(d),u.push(j),F.push(null);return}if(c[d].has("fields"))return;let k=he(A.errorDetails,l,a);if(!k||k.some(({field:E})=>g.has(E)))return;let I=new Set(k.map(({field:E})=>E));O.push(d),u.push(Object.fromEntries(Object.entries(l).filter(([E])=>!I.has(E)))),F.push(k)}),O.length===0)break;let P;try{P=await this.executeOperation(e.objectApiName,e.operation,u,e.batchSize,e.externalIdField)}catch(A){if(!(A instanceof x)){T.push(...Ye(O,y,u,F,A));break}P=A.written,w=A}P.forEach((A,d)=>{let l=O[d],g=F[d];c[l].add(g===null?"lookup":"fields"),g===null?h[l].push(...Object.keys(y[l]).filter(k=>!(k in u[d]))):m[l].push(...g),y[l]=u[d],i[l]=A})}let f=new Set,v=0,R,L=new Set(W);return i.forEach((S,O)=>{if(!(!S.success||c[O].size===0)){if(h[O].length>0){v++;for(let F of h[O])f.add(F);let u=n[O]?.[N];typeof u=="string"&&h[O].length===1&&h[O][0]===N&&L.add(u)}m[O].length>0&&(R=me(R,{rows:1,fields:m[O].map(u=>({...u,rows:1}))}))}}),{outcomes:i,notes:[...T,...w?.notes??[]],...R?{writtenWithoutFields:R}:{},cancelled:w!==void 0,ownersRefused:[...L],lookupsLeftOut:[...v>0?[{records:v,fields:[...f].sort(),reason:"notInTarget"}]:[],...w?.lookupsLeftOut??[]]}}async executeOperation(e,n,r,s,o){if(this.deps.crudFlsGuard){let a=r.length>0?Object.keys(r[0]):[],i=await this.deps.crudFlsGuard.checkCrudAndFls(e,n,a);if(!i.allowed)throw new Error(`CRUD/FLS check failed for ${n} on ${e}: ${i.reason}`)}switch(n){case"insert":return this.deps.insert(e,r,s);case"update":return this.deps.update(e,r,s);case"upsert":return this.deps.upsert(e,o??"Id",r,s);case"delete":{let a=r.map(i=>i.Id).filter(i=>typeof i=="string");return this.deps.delete(e,a,s)}}}},Ke=["INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY","INVALID_CROSS_REFERENCE_KEY"],qe=/cross[- ]reference id|r[ée]f[ée]rence crois[ée]e/i;function J(t){return Ke.some(e=>t.includes(e))||qe.test(t)}var N="OwnerId";function He(t,e,n){let r=new Set;return n&&t.forEach((s,o)=>{let a=s[N];typeof a!="string"||e[o]?.has(N)||n.links.isOwnerRefused(a)&&(delete s[N],r.add(o))}),r}function je(t,e){let n=0;for(let r of t)e[r]?.success&&n++;if(n!==0)return{records:n,fields:[N],reason:"ownerRefusedEarlier"}}function Ye(t,e,n,r,s){let o=s instanceof Error?s.message:String(s),a=new Set,i=new Set,y=0;return r.forEach((c,h)=>{if(c===null){y++;let m=n[h];for(let T of Object.keys(e[t[h]]))T in m||a.add(T)}else for(let{field:m}of c)i.add(m)}),[...y>0?[`${y} record(s) the target refused for a lookup it does not have could not be written again without ${[...a].sort().join(", ")}: ${o}`]:[],...i.size>0?[`${t.length-y} record(s) the target refused on fields it named could not be written again without ${[...i].sort().join(", ")}: ${o}`]:[]]}var D=class{ids=new Set;named=new Set;said;add(e,n){this.ids.add(e),this.named.add(n)}addRow(e,n){let r=String(e.Id);for(let s of Object.keys(e))s!=="Id"&&this.add(r,s);n!==void 0&&n!==""&&(this.said??=n)}get records(){return this.ids.size}get recordIds(){return this.ids}fields(){return[...this.named].sort()}leftOut(e){if(this.ids.size!==0)return{records:this.ids.size,fields:this.fields(),reason:e,...this.said!==void 0?{refusal:this.said}:{}}}};function U(t,e){return t.flatMap(({index:n,field:r,parent:s})=>{let o=e[n];return o?.success&&typeof o.id=="string"&&o.id!==""?[{id:o.id,field:r,parent:s}]:[]})}function vt(t){return new Set(t.map(({id:e})=>e)).size}function Q(t){let e=new D;for(let{id:r,field:s}of t)e.add(r,s);let n=e.leftOut("notReached");return n?[n]:[]}function Me(t,e){if(!(e.success||t!=="insert"&&t!=="upsert"))return e.existingId!==void 0&&e.existingId!==""?e.existingId:void 0}async function Ve(t,e,n,r){let s=await e(n);try{return[...s,...await e(r)]}catch(o){throw o instanceof x?new x(t,[...s,...o.written],o.notes,o.lookupsLeftOut,o.writtenWithoutFields):o}}function De(t,e,n,r,s){if(!s?.createdWithoutRecordType||e.size===0)return;let o=[],a=[];for(let[c,h]of e){let m=n[c];!m?.success||typeof m.id!="string"||m.id===""||t.operation!=="insert"&&m.created!==!0||(o.push(h),a.length<ke&&a.push(m.id))}let i=Ie(s.recordTypesUnderTheLease??r?.recordTypes??[],s.recordTypes),y=Ae(t.objectApiName,o,i);y&&s.createdWithoutRecordType.set(t.objectApiName,{given:y,types:i,ids:a})}function Ze(t,e,n,r){t.objectApiName==="Opportunity"&&(t.operation!=="insert"&&t.operation!=="upsert"||e.forEach((s,o)=>{let a=n[o],i=s[se];!a?.success||typeof a.id!="string"||a.id===""||t.operation!=="insert"&&a.created!==!0||typeof i=="string"&&i!==""&&r.noteSentWithContact(a.id,i)}))}function $e(t,e,n){if(t.operation==="delete")return;let r=t.operation==="insert"||t.operation==="upsert";e.forEach((s,o)=>{let a=n.sources[o]?.Id;if(typeof a!="string"||a==="")return;let i=Me(t.operation,s);s.success&&typeof s.id=="string"&&s.id!==""?n.links.noteWritten(a,s.id):i!==void 0?n.links.noteWritten(a,i):!s.success&&r&&n.links.noteRefused(a,t.objectApiName)})}function Je(t,e){return e.length>0?{...t,currenciesReplaced:[...e]}:t}var _e=1e3;function Qe(t,e,n,r=[],s=[],o){let a=0,i=0,y=0,c,h=[],m=0,T={created:0,updated:0},w={rows:0,written:0,stillLocked:0};for(let f of n)f.lockResends!==void 0&&(w.rows++,f.success?w.written++:we(f.errors,f.errorDetails)&&w.stillLocked++),f.success?(a++,f.created===!0?T.created++:f.created===!1&&T.updated++):Me(e,f)!==void 0?(y++,c??=f.errors[0]):(i++,!f.heldBack&&m++<_e&&h.push(...f.errors));let W=Math.max(0,m-_e);return{objectApiName:t,operation:e,processed:n.length,success:a,failed:i,skipped:y,conflictCount:0,errors:[...h,...r],...y>0?{linkedToExisting:{records:y,...c?{refusal:c}:{}}}:{},...s.length>0?{lookupsLeftOut:[...s]}:{},...o?{writtenWithoutFields:o}:{},...w.rows>0?{sentAgainForALock:w}:{},...W>0?{refusalsDropped:W}:{},...e==="upsert"?{upsertSplit:T}:{}}}export{We as a,Ae as b,Ie as c,Ee as d,yt as e,gt as f,ht as g,Pe as h,Rt as i,Ot as j,xe as k,x as l,Ne as m,vt as n,Q as o,Me as p,Je as q,_e as r,Qe as s};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a,b,c,d,e,f,g,h}from"./chunk-KRCA6IPH.mjs";import"./chunk-5TC3QB4U.mjs";import"./chunk-2BA2XKAY.mjs";import"./chunk-OAZRPP4I.mjs";import"./chunk-JEERQRLW.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-MJU2PGZQ.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LWW4U276.mjs";import"./chunk-MJVTDA5Q.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-2CNCDM56.mjs";import"./chunk-SIHORWVK.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-B5QQJ4SI.mjs";import"./chunk-NZC67CGR.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-F43REJDZ.mjs";import"./chunk-JPUR2CFX.mjs";import"./chunk-LPBMBW3O.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-IFETCRWE.mjs";import"./chunk-PZPJKATS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-MFG4MUIO.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-HS4YRX4J.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{d as CheckpointTakeStopped,a as DEFAULT_MAX_TOTAL,b as OBJECT_ROWS_MAX,f as holdingLimit,e as pastTheLimit,g as scopeCheckpoint,h as takeCheckpoint,c as takeOrgOf};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a as c}from"./chunk-YKKRIEH4.mjs";var p=class{apply(n,r,t=[]){return m(n,r,t)}applyAddOns(n,r){let t={...n};for(let o of r)(!(o.fieldApiName in t)||o.overwriteExisting)&&(t[o.fieldApiName]=o.value);return t}},g=new Set(["direct","rename","transform","add_on"]),i=e=>e.toLowerCase();function S(e){return new Set(e.filter(n=>n.type!=="exclude").map(n=>i(n.targetField)))}function w(e,n=[]){let r=new Set(n.map(i));for(let t of e)(g.has(t.type)||t.type==="exclude")&&r.add(i(t.sourceField)),r.add(i(t.targetField));return r}var y=new c;function m(e,n,r=[]){if(n.length===0&&r.length===0)return{...e};let t=new Set(r.map(i)),o=Object.fromEntries(Object.entries(e).filter(([s])=>!t.has(i(s)))),d=w(n,r),l=Object.fromEntries(Object.entries(o).filter(([s])=>!d.has(i(s))));for(let s of n){let u=R(o,s);u!==void 0&&(l[s.targetField]=u)}return l}function a(e,n){if(n in e)return e[n];let r=i(n),t=Object.keys(e).find(o=>i(o)===r);return t===void 0?void 0:e[t]}var f=Symbol("exclude");function R(e,n){let r=F[n.type],t=r(e,n);if(!(t===f||t===void 0))return n.transformRules&&n.transformRules.length>0?y.transform(t,n.transformRules):t}var F={direct:(e,n)=>a(e,n.sourceField),rename:(e,n)=>a(e,n.sourceField),transform:(e,n)=>a(e,n.sourceField),constant:(e,n)=>n.targetField?n.sourceField:void 0,formula:(e,n)=>k(e,n.sourceField),exclude:()=>f,add_on:(e,n)=>a(e,n.sourceField)};function k(e,n){return/\{(\w+)\}/g.test(n)?n.replace(/\{(\w+)\}/g,(t,o)=>{let d=e[o];return d!=null?String(d):""}):e[n]}export{p as a,g as b,S as c,w as d,m as e};
|
|
@@ -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{e as a,f as b,g as c,h as d,i as e,j as f,k as g,l as h,m as i,n as j,o as k,p as l,q as m,r as n}from"./chunk-UNJA4J37.mjs";import"./chunk-XLXIPIEW.mjs";import"./chunk-TTKXMDBN.mjs";import"./chunk-TSLJUSLW.mjs";import"./chunk-KRCA6IPH.mjs";import"./chunk-5TC3QB4U.mjs";import"./chunk-2BA2XKAY.mjs";import"./chunk-OAZRPP4I.mjs";import"./chunk-JEERQRLW.mjs";import"./chunk-MHMH6MTP.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-MJU2PGZQ.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-LWW4U276.mjs";import"./chunk-MJVTDA5Q.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-WR2GIKWE.mjs";import"./chunk-2CNCDM56.mjs";import"./chunk-SIHORWVK.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-B5QQJ4SI.mjs";import"./chunk-NZC67CGR.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-F43REJDZ.mjs";import"./chunk-JPUR2CFX.mjs";import"./chunk-LPBMBW3O.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-DBFJB2B6.mjs";import"./chunk-IFETCRWE.mjs";import"./chunk-PZPJKATS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-MFG4MUIO.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-HS4YRX4J.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-VYXMVJL5.mjs";import"./chunk-AEKONPF4.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-CION3VMZ.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{d as NOT_REMADE_WORDS,b as OTHERS_DELETION_WORDS,c as OUT_OF_REACH_WORDS,j as REWIND_AUTOMATION_LIFTED_BY,a as REWIND_RESIDUAL_IDS,i as RewindStopped,k as automationUnread,m as counted,h as heldWhile,l as inRewindWords,g as muteOfSteps,e as notAskedWords,n as rewindOrg,f as rewindOrgOf};
|
|
@@ -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}from"./chunk-X5JYBPXP.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{a as OPPORTUNITY,c as SeedPlatformRoles,b as rolesNotLookedUpNote,d as rolesOfADryRun,f as seedTargetOf,e as writtenByThePlatformLine};
|
|
@@ -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{createHmac as c,randomBytes as C}from"node:crypto";import{deflateRawSync as P,inflateRawSync as A}from"node:zlib";var k="@example.invalid",M="+3363998",N=new Set(["picklist","multipicklist"]),R={FirstName:"firstName",LastName:"lastName",Email:"email",Phone:"phone",MobilePhone:"phone",HomePhone:"phone",MailingStreet:"address",OtherStreet:"address",BillingStreet:"address",ShippingStreet:"address",MailingCity:"city",OtherCity:"city",BillingCity:"city",ShippingCity:"city",MailingPostalCode:"postalCode",OtherPostalCode:"postalCode",BillingPostalCode:"postalCode",ShippingPostalCode:"postalCode",Company:"company",CompanyName:"company",Name:"company",PersonEmail:"email",PersonMobilePhone:"phone",PersonHomePhone:"phone",PersonOtherPhone:"phone",PersonMailingStreet:"address",PersonOtherStreet:"address",PersonMailingCity:"city",PersonOtherCity:"city",PersonMailingPostalCode:"postalCode",PersonOtherPostalCode:"postalCode"};function E(s,e){let t=s.split("");if(t.length<2)return s;let n=w(e,s,4*(t.length-1));for(let r=t.length-1,i=0;r>0;r--,i+=4){let a=n.readUInt32BE(i)%(r+1);[t[r],t[a]]=[t[a],t[r]]}return t.join("")}function w(s,e,t){let n=[];for(;n.length*32<t;)n.push(c("sha256",s).update(`${n.length}:${e}`).digest());return Buffer.concat(n).subarray(0,t)}function g(s,e){return c("sha256",s).update(e).digest().readUInt32BE(0)&2147483647}var d="Alex Jordan Morgan Casey Riley Quinn Avery Parker Reese Dakota Skyler Sage River Hayden Emery Finley Blake Charlie Drew Rowan Jamie Robin Kendall Logan Peyton Cameron Jesse Kai Arden Bailey Blair Brook Carson Corey Devon Eden Ellis Emerson Frankie Gray Harper Jules Jody Kerry Lane Leslie Linden Marley Micah Nico Noel Oakley Perry Quincy Reagan Remy Rory Sam Sasha Shawn Spencer Sutton Tatum Terry Toby Tracy Val Wren Wynn Adair Alden Ainsley Billie Briar Cass Dale Darcy Ellery Emory Fallon Glenn Hollis Ira Jaden Kit Lennon Lou Mackenzie Monroe Nova Palmer Presley Ridley Sawyer Scout Shay Sloane Tanner Teagan Winter".split(" "),h=["Ash","Birch","Brook","Clay","Fern","Hazel","Lark","Marsh","Oak","Thorn"].flatMap(s=>["bury","combe","dale","field","ford","gate","ridge","stone","ton","wood"].map(e=>`${s}${e}`)),$=32,p=d.length*h.length;function B(s){return{firstName:d[s%d.length],lastName:h[(s>>8)%h.length]}}function u(s){return s%d.length*h.length+(s>>8)%h.length}var m=class{personas=new Map;timesGiven=new Uint32Array(p);key;constructor(e){this.key=e??C(32).toString("hex")}cities=["Springfield","Riverside","Fairview","Greenville","Franklin","Clinton","Madison","Georgetown","Arlington","Salem"];streets=["Main St","Oak Ave","Elm St","Park Dr","Cedar Ln","Pine Rd","Maple Way","Lake Blvd"];companies=["Acme Corp","Global Tech","Sunrise Inc","Horizon Ltd","Evergreen Co","Summit Group","Atlas Partners","Apex Solutions","Nova Industries","Pinnacle LLC"];getPersona(e){let t=this.personas.get(e);if(t)return t;let n=g(this.key,`persona:${e}`);for(let y=1;y<=$&&this.timesGiven[u(n)]>0;y++)n=g(this.key,`persona:${e}:${y}`);let{firstName:r,lastName:i}=B(n),a=u(n),o=this.timesGiven[a];this.timesGiven[a]=o+1;let l=this.cities[(n>>16)%this.cities.length],f={sourceRecordId:e,firstName:r,lastName:i,email:this.emailFor(r,i,o,e),phone:`+1-555-${String(n%900+100).padStart(3,"0")}-${String((n>>4)%9e3+1e3).padStart(4,"0")}`,address:`${n%999+1} ${this.streets[(n>>12)%this.streets.length]}`,city:l,postalCode:String(n%9e4+1e4),company:this.companies[(n>>20)%this.companies.length]};return this.personas.set(e,f),f}emailFor(e,t,n,r){let i=n>0?String(n+1):"",a=`${e.toLowerCase()}.${t.toLowerCase()}${i}`,o=(g(this.key,`email:${r}`)&65535).toString(16).padStart(4,"0");return`${a}.${o}@example.com`}namesGiven(){let e=Buffer.alloc(p*4);return this.timesGiven.forEach((t,n)=>e.writeUInt32LE(t,n*4)),P(e).toString("base64")}continueFrom(e){let t;try{t=A(Buffer.from(e,"base64"),{maxOutputLength:p*4})}catch{return!1}if(t.length!==p*4)return!1;for(let n=0;n<p;n++)this.timesGiven[n]+=t.readUInt32LE(n*4);return!0}get size(){return this.personas.size}clear(){this.personas.clear(),this.timesGiven.fill(0)}},S=class{personaRegistry;hashSalt;constructor(e,t){this.hashSalt=t??C(32).toString("hex"),this.personaRegistry=e??new m(this.hashSalt)}getPersonaRegistry(){return this.personaRegistry}anonymize(e,t,n){let r=t.filter(i=>i.objectApiName===n);if(r.length===0)return e;for(let i of e){let a=String(i.Id??i.id??"");for(let o of r){let l=i[o.fieldApiName];l!=null&&(i[o.fieldApiName]=N.has(o.fieldType?.toLowerCase()??"")?null:this.applyMethod(o.method,String(l),o.fieldApiName,a,o.fieldType))}}return e}applyMethod(e,t,n,r,i){switch(e){case"fake":return this.applyFake(t,n,r,i);case"mask":return this.applyMask(t);case"hash":return this.applyHash(t);case"nullify":return null;case"redact":return"[REDACTED]";case"shuffle":return this.applyShuffle(t);case"truncate":return this.applyTruncate();case"preserve_format":return this.applyPreserveFormat(t);case"age_band":return this.applyAgeBand(t);case"generalize":return this.applyGeneralize(t,n);case"constant":return""}}applyFake(e,t,n,r){let i=this.personaRegistry.getPersona(n),a=R[t];if(a)return i[a];let o=c("sha256",this.hashSalt).update(`fake:${t}:${n}`).digest("hex");switch(r?.toLowerCase()){case"email":return`fake_${o.slice(0,8)}${k}`;case"phone":return`${M}${String(parseInt(o.slice(0,8),16)%1e4).padStart(4,"0")}`;default:return`fake_${o.slice(0,8)}`}}applyMask(e){return e.length<=4?"*".repeat(e.length):"*".repeat(e.length-4)+e.slice(-4)}applyHash(e){return c("sha256",this.hashSalt).update(e).digest("hex").slice(0,32)}applyShuffle(e){return E(e,this.hashSalt)}applyTruncate(){return""}applyPreserveFormat(e){let t=g(this.hashSalt,`preserve_format:${e}`);return e.split("").map(n=>(t=t*1664525+1013904223&2147483647,/[0-9]/.test(n)?String(t%10):/[A-Z]/.test(n)?String.fromCharCode(65+t%26):/[a-z]/.test(n)?String.fromCharCode(97+t%26):n)).join("")}applyAgeBand(e){let t=new Date(e);if(isNaN(t.getTime()))return"Unknown";let n=t.getFullYear(),r=Math.floor(n/10)*10;return`${r}-${r+9}`}applyGeneralize(e,t){if(e.includes("@")){let a=e.split("@");return`***@${a[a.length-1]}`}let n=(e.match(/\d/g)??[]).length;if(e.startsWith("+")||n>e.length/2)return e.slice(0,Math.min(3,e.length))+"-***";let r=t.toLowerCase();if(r.includes("street")||r.includes("address")||r.includes("city")||r.includes("state"))return e.split(/\s+/)[0]??e;let i=e.split(/\s+/);return i.length>1?`${i[0]} ...`:e.slice(0,Math.max(1,Math.ceil(e.length/2)))}};export{R as a,E as b,m as c,S as d};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{e as $}from"./chunk-7FFGJWHN.mjs";import{A as F,C as A}from"./chunk-CION3VMZ.mjs";import{c as M}from"./chunk-HF6LAK3G.mjs";var k=class{avgSecondsPerApiCall;batchStrategy;constructor(u){this.avgSecondsPerApiCall=u?.avgSecondsPerApiCall??.5,this.batchStrategy=new M}generate(u){let a=u.nodes.filter(o=>o.included);if(a.length===0)return{waves:[],totalRecords:0,totalApiCalls:0,estimatedDurationSeconds:0,cycleResolutions:[]};let{edges:c,components:t}=G(u),i=this.computeTopoLevels(c,t),l=new Map;for(let o of a){let e=i.get(o.objectApiName)??o.level,h=l.get(e);h?h.push(o.objectApiName):l.set(e,[o.objectApiName])}let n=[...l.keys()].sort((o,e)=>o-e),s=new Map(a.map(o=>[o.objectApiName,o])),g=n.map((o,e)=>{let h=l.get(o)??[],v=0,b=0,w=0;for(let N of h){let j=s.get(N);if(!j)continue;v+=j.recordCount;let x=this.batchStrategy.resolve(j.batchStrategy,j.recordCount),C=$(x,j.recordCount).batchCount;b+=C;let O=C*this.avgSecondsPerApiCall;O>w&&(w=O)}return{order:e,objectApiNames:h,totalRecords:v,estimatedDurationSeconds:w,estimatedApiCalls:b}}),r=this.detectCycles(u,c,t),p=g.reduce((o,e)=>o+e.totalRecords,0),f=g.reduce((o,e)=>o+e.estimatedApiCalls,0),m=g.reduce((o,e)=>o+e.estimatedDurationSeconds,0);return{waves:g,totalRecords:p,totalApiCalls:f,estimatedDurationSeconds:m,cycleResolutions:r}}computeTopoLevels(u,a){let c=new Map;a.forEach((n,s)=>{for(let g of n)c.set(g,s)});let t=new Map;for(let n of u){let s=c.get(n.sourceObject),g=c.get(n.targetObject);if(s===void 0||g===void 0||s===g)continue;let r=t.get(s);r?r.push(g):t.set(s,[g])}let i=a.map(()=>0);for(let n=a.length-1;n>=0;n--)for(let s of t.get(n)??[])i[s]=Math.max(i[s],i[n]+1);let l=new Map;for(let[n,s]of c)l.set(n,i[s]);return l}detectCycles(u,a,c){let t=c.filter(n=>n.length>1);if(t.length===0)return[];let i=new Map(A(u).map((n,s)=>[n.objectApiName,s])),l=n=>i.get(n)??0;return t.map(n=>{let s=new Set(n),g=[...n].sort((e,h)=>l(e)-l(h)),r=a.filter(e=>s.has(e.sourceObject)&&s.has(e.targetObject)&&l(e.targetObject)<l(e.sourceObject)),p=r.filter(e=>e.required===!0);if(p.length>0){let e=[...new Set(p.map(b=>b.targetObject))],h=[...new Set(p.map(b=>b.sourceObject))],v=e.length===1;return{objects:g,strategy:"unbreakable",description:`The run cannot break this cycle: ${y(p.map(S))} may not be left empty, and no order writes ${y(h)} first. ${y(e)} ${v?"is":"are"} refused, and what cannot be written without ${v?"it":"them"} is skipped.`}}let f=r.filter(e=>e.insertOnly!==!0),m=r.filter(e=>e.insertOnly===!0),o=[...f.length>0?[`${y(f.map(S))} left empty at insert and filled in by the second pass`]:[],...m.length>0?[`${y(m.map(S))} left empty for good: only an insert sets ${m.length===1?"it":"them"}, and no order writes ${y([...new Set(m.map(e=>e.sourceObject))])} first`]:[]];return{objects:g,strategy:"nullable_lookup",description:`Written in this order, with ${o.join(", and ")}.`}})}};function G(d){let u=d.nodes.filter(t=>t.included).map(t=>t.objectApiName),a=new Set(u),c=d.edges.filter(t=>t.sourceObject!==t.targetObject&&a.has(t.sourceObject)&&a.has(t.targetObject)&&F(t));return{edges:c,components:R(u,c)}}function R(d,u){let a=new Map;for(let r of d)a.set(r,[]);for(let r of u)a.get(r.sourceObject)?.push(r.targetObject);let c=0,t=new Map,i=new Map,l=new Set,n=[],s=[],g=r=>{let p=[];for(t.set(r,c),i.set(r,c),c++,n.push(r),l.add(r),p.push({v:r,neighbors:a.get(r)??[],i:0});p.length>0;){let f=p[p.length-1];if(f.i<f.neighbors.length){let e=f.neighbors[f.i++];t.has(e)?l.has(e)&&i.set(f.v,Math.min(i.get(f.v),t.get(e))):(t.set(e,c),i.set(e,c),c++,n.push(e),l.add(e),p.push({v:e,neighbors:a.get(e)??[],i:0}));continue}let m=f.v;p.pop();let o=p[p.length-1];if(o&&i.set(o.v,Math.min(i.get(o.v),i.get(m))),i.get(m)===t.get(m)){let e=[],h;do h=n.pop(),l.delete(h),e.push(h);while(h!==m);s.push(e)}}};for(let r of d)t.has(r)||g(r);return s}function S(d){return`${d.targetObject}'s lookup to ${d.sourceObject}`}function y(d){return d.length<=1?d.join(""):`${d.slice(0,-1).join(", ")} and ${d[d.length-1]}`}export{k as a,R as b};
|
|
@@ -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 S,i as g,j as m,u as R}from"./chunk-PZPJKATS.mjs";var y=20,v="seed-runs",l="sandforge-seed",h=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function O(s,e){let t=s.finishedAt??new Date().toISOString();return{runId:s.runId,configId:l,configName:l,sourceOrgId:s.targetOrgId,targetOrgId:s.targetOrgId,startedAt:s.startedAt??t,end:{at:t,status:s.status},lastWrittenAt:t,created:s.objectResults.filter(d=>d.createdIds.length>0).map(d=>({objectApiName:d.objectApiName,ids:[...d.createdIds]})),...s.runUserId!==void 0&&h.test(s.runUserId)?{runUserId:s.runUserId}:{},...e?{removal:e}:{}}}function N(s,e){return new I(S(s,v,e))}var I=class{constructor(e,t=y){this.runs=e;this.max=t}runs;max;recorder(e){let t=this.runs.recorder({runId:e.runId,configId:l,configName:l,sourceOrgId:e.sourceOrgId??e.targetOrgId,targetOrgId:e.targetOrgId,...e.startedAt!==void 0?{startedAt:e.startedAt}:{},...e.origin!==void 0?{origin:e.origin}:{},...e.pipeline!==void 0?{pipeline:{name:e.pipeline.name.slice(0,m)}}:{},...e.targetOrganizationId!==void 0?{targetOrganizationId:e.targetOrganizationId}:{},...e.targetAlias!==void 0?{targetAlias:e.targetAlias}:{},...e.runUserId!==void 0&&h.test(e.runUserId)?{runUserId:e.runUserId}:{}}),d=new Set,u=n=>{let i=n.filter(r=>!d.has(r.slice(0,15)));for(let r of i)d.add(r.slice(0,15));return i},a=(n,i)=>{for(let r=0;r<n.length;r+=g)i(n.slice(r,r+g))},f=(n,i,r)=>a(u(i),o=>t.note(n,o,r)),c=new Map,p=!1;return{runId:e.runId,note:(n,i)=>f(n,i),sending:(n,i,r)=>{r?.job!==void 0?c.set(n,r.job):c.delete(n),t.sending?.(n,i,r)},answered:(n,i)=>{c.delete(n);let r=u(i);t.answered?.(n,r.slice(0,g)),a(r.slice(g),o=>t.note(n,o))},wroteAgain:(n,i)=>a(i.filter(r=>d.has(r.slice(0,15))),r=>t.note(n,r)),checkpoint:n=>t.checkpoint?.(n),runUser:n=>{p||t.runUser?.(n)},end:async n=>{let i=n.finishedAt??new Date().toISOString();for(let{objectApiName:o,createdIds:A}of n.objectResults)f(o,A,i);if(d.size===0&&c.size===0){p=!0,await t.flush(),await this.runs.forget(e.runId);return}await t.end({status:n.status,...n.cancelled?{cancelled:!0}:{},at:i});let r=await t.flush();if(r!==void 0)throw new Error(r);await this.keepTheLatest()}}}record(e){let t=e.startedAt??e.finishedAt;return this.recorder({runId:e.runId,targetOrgId:e.targetOrgId,...t!==void 0?{startedAt:t}:{},...e.runUserId!==void 0?{runUserId:e.runUserId}:{}}).end(e)}async keepTheLatest(){let e=(await this.runs.list()).filter(R),t=e.length-this.max;for(let d of[...e].reverse()){if(t<=0)return;await this.runs.forget(d.runId),t--}}pathOf(e){return this.runs.pathOf(e)}get storagePath(){return this.runs.storagePath}get(e){return this.runs.get(e)}list(){return this.runs.list()}answerInFlight(e,t,d,u,a){return this.runs.answerInFlight(e,t,d,u,a)}async updateRemoval(e,t){await this.runs.get(e)&&await this.runs.updateRemoval(e,t)}};export{y as a,v as b,O as c,N as d,I as e};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{b as N}from"./chunk-WR2GIKWE.mjs";import{a as k}from"./chunk-BOGNK4LV.mjs";import{i as S}from"./chunk-F43REJDZ.mjs";import{a as _,b as E}from"./chunk-T63U4OZJ.mjs";import{Ba as V,E as L,Ha as H,N as F,O as w,Q as U,R as x,T as G,U as v,W as B,Wa as X,_ as j,qa as M,ta as W,ya as z}from"./chunk-VYXMVJL5.mjs";import{b as C,f as P,k as b,l as D}from"./chunk-7EANH5PY.mjs";var q={PII:"PII",PHI:"PHI",PCI:"PCI",Confidential:"SENSITIVE"},K={PII:"fake",PHI:"nullify",PCI:"mask",SENSITIVE:"hash",NONE:"fake"},$={name_pattern:"field_name",type_analysis:"field_name",content_pattern:"content_sampling"},J=.9;function ie(e,t){let n=[];for(let[i,a]of t){let c=a.fields.filter(o=>o.createable&&N({name:o.name,label:o.label,type:o.type})),l=new Map(c.map(o=>[o.name,o])),r=new Map,s=e.detectPII(i,c.map(o=>({apiName:o.name,label:o.label,type:o.type})));for(let o of s.piiFields){let u=l.get(o.fieldApiName);if(!u)continue;let d=q[o.classification];r.set(u.name,{objectApiName:i,fieldApiName:u.name,fieldLabel:u.label,fieldType:u.type,piiCategory:d,detectionMethod:$[o.detectionMethod],confidence:o.confidence,suggestedMethod:K[d]})}for(let o of c)r.has(o.name)||E(o.name,o.type)===void 0||r.set(o.name,{objectApiName:i,fieldApiName:o.name,fieldLabel:o.label,fieldType:o.type,piiCategory:"PII",detectionMethod:"field_name",confidence:J,suggestedMethod:"fake"});n.push(...r.values())}return n}function ae(e,t){let n=a=>`${a.objectApiName}.${a.fieldApiName}`,i=new Set(e.map(n));return[...e,...t.filter(a=>!i.has(n(a)))]}var Y=["Contact","Lead"];function re(e,t,n){if(e==="none")return[];let i=new Set(t),a=[];for(let c of Y){if(!i.has(c))continue;let l=n.filter(s=>s.objectApiName===c).map(s=>s.fieldApiName),r=[];l.some(_)||r.push("name"),l.some(s=>E(s,"string")==="email")||r.push("email"),l.some(s=>E(s,"string")==="phone")||r.push("phone"),r.length>0&&a.push({objectApiName:c,missing:r})}return a}function ce(e){return e.fatalError!==void 0?"failure":e.totalFailure>0||e.failedObjects.length>0?e.totalSuccess+(e.totalLinked??0)>0?"partial":"failure":[...Object.values(e.lookups??{}),...Object.values(e.statuses??{})].some(n=>n.refusals.length>0)||e.stopped===!0?"partial":"success"}var Q=D({name:C().min(1),referenceTo:b(C()).min(1),createable:P().optional(),updateable:P().optional()}).loose();function de(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let i=Q.safeParse(n);i.success&&t.push({name:i.data.name,referenceTo:i.data.referenceTo,createable:i.data.createable??!1,updateable:i.data.updateable??!1})}return t}var ge={STORAGE_EXCEEDED:"AUTOPILOT_STORAGE_EXCEEDED",API_BUDGET_EXCEEDED:"API_BUDGET_EXCEEDED",WRITE_DECLINED:"AUTOPILOT_WRITE_DECLINED",CONFIRMATION_UNAVAILABLE:"AUTOPILOT_CONFIRMATION_UNAVAILABLE",CHECKPOINT_REFUSED:"CHECKPOINT_REFUSED",RUN_CANCELLED:"RUN_CANCELLED",EMAILS_NOT_ACCEPTED:z},Ae={NO_PLAN:"AUTOPILOT_NO_PLAN",STORAGE_UNREAD:"AUTOPILOT_FIT_STORAGE_UNREAD",READ_REFUSED:"AUTOPILOT_FIT_READ_REFUSED",STALE:"AUTOPILOT_FIT_STALE"};function Ie(e,t,n=new Map){return L(e.waves.flatMap(i=>i.objects).map(i=>{let a=n.get(i);return{objectApiName:i,rows:[],counted:{rows:t.get(i)??0,...a!==void 0?{personAccounts:a}:{}}}}))}function he(e){return[...new Set(e.waves.flatMap(t=>t.objects.map(String)))]}async function Ce(e){return M(e)}function Z(e){return e.filter(t=>t.verdict==="exceeds").map(W)}function ee(e){return e.filter(t=>t.verdict==="unread").map(t=>({limit:t.limit,emails:t.emails,unread:t.unread??""}))}function Pe(e){return e.objects.filter(({rows:t})=>t>0).length}async function te(e,t,n,i,a={}){let c="unread"in t?await n().catch(o=>({unread:o instanceof Error?o.message:String(o)})):t.dailyApiRequests,{readBack:l=0,deliverability:r=0,mute:s=0}=a;return w({run:F(e.objects.map(({rows:o})=>({rows:o}))),...G(i),...s>0?{mute:s}:{},...l>0?{readBack:l}:{},...r>0?{deliverability:r}:{}},c)}async function ke(e){let{plan:t}=e,n=j(t,e.storage);if(t.totalRows===0)return{go:!0,check:n,asked:!1};let i=e.checkpointFirst?.estimate,a=v(i);if(a)return{go:!1,...a,check:n};let c=X(n,e.org);if(c)return{go:!1,code:"STORAGE_EXCEEDED",message:`${c} Nothing was written.`,check:n};let l=await te(t,e.storage,e.readApiBudget,i,{...e.readBack!==void 0?{readBack:e.readBack}:{},...e.mute!==void 0?{mute:e.mute}:{},...V(e.runEmails?.ofRun)}),r=U(l,e.org);if(r)return{go:!1,code:"API_BUDGET_EXCEEDED",message:r,check:n};let s=e.confirmAboveRecords,o=s>0&&t.totalRows>s?s:void 0,u=Z(e.emails??[]),d=ee(e.emails??[]),g=e.emailsUncounted,f=e.runEmails?.gate,y=f?.verdict==="asks",R=async m=>{let p=k(f,m&&y),I=e.checkpointFirst;if(I===void 0)return{go:!0,check:n,asked:m,...p};let h=await B(()=>I.take(I.estimate));return"stop"in h?{go:!1,...h.stop,check:n,...p}:{go:!0,check:n,asked:m,checkpoint:h.checkpoint,...p}};if(o===void 0&&n.verdict==="fits"&&u.length===0&&d.length===0&&g===void 0&&i===void 0&&!y)return R(!1);let A=S(e.orgTier),T=await e.confirm({stage:"write",module:"autopilot",org:e.org,orgTier:e.orgTier,objects:t.objects.map(({objectApiName:m,rows:p})=>({objectApiName:m,rows:p})),total:t.totalRows,...o!==void 0?{aboveRecords:o}:{},...A!==void 0&&t.totalRows>A?{largeVolume:A}:{},storage:H(n),counted:!0,...u.length>0?{emails:u}:{},...d.length>0?{emailsUnread:d}:{},...g!==void 0?{emailsUncounted:g}:{},...x(l),...i!==void 0?{checkpoint:i}:{},...f?.confirmation});if(T==="confirmed")return R(!0);let O=k(f,!1);return T==="declined"?{go:!1,code:"WRITE_DECLINED",message:"The Autopilot run was cancelled before it wrote anything. Nothing was written.",check:n,...O}:{go:!1,code:"CONFIRMATION_UNAVAILABLE",message:"The Autopilot run needed a confirmation before it wrote, and there was no one to ask. Nothing was written: run it again from the Autopilot page, where the question is asked.",check:n,...O}}export{ie as a,ae as b,re as c,ce as d,de as e,ge as f,Ae as g,Ie as h,he as i,Ce as j,Pe as k,te as l,ke as m};
|
|
@@ -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
|
+
async function i(r,l,n=5e4){let t=Math.max(500,Math.ceil(n/200)),e=await r.query(l),o=[...e.records],a=1;for(;!e.done&&e.nextRecordsUrl&&o.length<n&&a<t;)e=await r.queryMore(e.nextRecordsUrl),o.push(...e.records),a++;let s=o.length>n?o.slice(0,n):o;return{records:s,pages:a,truncated:!e.done||s.length<o.length}}var c=5;async function*g(r,l,n){if(n?.all&&!r.queryAll)throw new Error(`No queryAll to read ${u(l)} with its archived rows.`);let t=await(n?.all&&r.queryAll?r.queryAll(l):r.query(l)),e=t.records.length===0?1:0;for(yield t.records;!t.done&&t.nextRecordsUrl&&e<c;)t=await r.queryMore(t.nextRecordsUrl),e=t.records.length===0?e+1:0,yield t.records}function u(r){return/\bFROM\s+([A-Za-z0-9_]+)/i.exec(r)?.[1]??"unknown object"}export{i as a,c as b,g as c};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{a as Re}from"./chunk-M3ROUWDX.mjs";import{K as ye,Q as Se,b as we}from"./chunk-ZM6OJGIG.mjs";import{ab as he,cb as be,i as pe,j as fe,k as ge,l as D}from"./chunk-4VS2V6WU.mjs";import{o as oe,p as se,q as ie,r as ae,s as de}from"./chunk-G35N4P7D.mjs";import{Ja as me,la as ue,ma as ce,na as v,oa as le,va as B,w as ne}from"./chunk-VYXMVJL5.mjs";import{b as Z}from"./chunk-WIO4XO4F.mjs";import{h as re}from"./chunk-L77FJZEP.mjs";import{p as I}from"./chunk-A527W53V.mjs";import{c as z,d as ee,g as te}from"./chunk-GGD7ON3M.mjs";import{b as M}from"./chunk-CA5NAXSU.mjs";import{Kc as H,Nc as K,Pc as x,_c as Q,bd as V,cd as X,dd as J,ed as Y,g as q,h as F,ic as G,j as W,yb as U}from"./chunk-TTFDUKUS.mjs";var N=1e4,Oe=W.REST_API_BATCH_SIZE;function xe(e){return e.id===void 0&&e.error!==void 0&&(e.errorDetails?.length??0)>0&&oe([e.error],e.errorDetails)}function Pe(e,n){return e.error===void 0?e:{...e,error:ie(e.error,n)}}function P(e){return{successIds:e.flatMap(n=>n.id===void 0?[]:[n.id]),errors:e.flatMap(n=>n.error===void 0?[]:[n.error])}}function Ae(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=ee(o);t[r.recordIndex]={error:o,...i?{errorDetails:[i]}:{}}}}return t.every(r=>r!==void 0)?t:void 0}function Ze(e){let{conn:n,bulkManager:t,retry:r,signal:o,label:i}=e,m=new re(e.bulkThreshold),g,R=async(p,c,l)=>{g??=be(n).then(d=>(d||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`),d));let b=await g;if(b===void 0)return he.has(p)?(e.log(`[INFO] ${i}: ${p} goes through REST: the duplicate rules could not be read, and a standard rule watches it`),!0):!1;let w=b.has(p);return w&&e.log(`[INFO] ${i}: ${p} goes through REST: an active duplicate rule watches it, which a Bulk API job cannot waive`+(c>N?` \u2014 ${c} records in ${Math.ceil(c/Math.max(1,l))} calls, slower than one job`:"")),w},k=async(p,c,l)=>{let b=[];for(let w=0;w<c.length;w+=l){if(o.aborted)return{rows:b,stopped:!0};let d=c.slice(w,w+l);e.calls?.sending(p,d.length);let f=await r.execute(async()=>n.sobject(p).create(d,{headers:U()}));if(f.cancelled)return e.calls?.answered(p,[]),{rows:b,stopped:!0};if(f.success&&f.result){let s=[];for(let u of f.result)if(u.success&&u.id)s.push(u.id),b.push({id:u.id});else{let a=te(u.errors);b.push({error:a,errorDetails:(u.errors??[]).map(z)})}e.calls?.answered(p,s)}else{let s=f.error?.message??"Insert failed after retries";for(let u=0;u<d.length;u++)b.push({error:s});e.calls?.answered(p,[])}}return{rows:b}},S=e.wait??(p=>se(p,o)),E=async(p,c,l,b)=>{let w=Math.min(Math.max(1,b),Oe),d=await ae({outcomes:l,locked:xe,written:s=>s.id!==void 0,send:async s=>(await k(p,s.map(u=>c[u]),w)).rows,note:Pe,wait:S,stopped:()=>o.aborted}),f=de("record(s)",d);return{rows:d.outcomes,notes:f===void 0?[]:[`${p}: ${f}.`]}};return async(p,c,l,b)=>{let w=(l.length>N||m.shouldUseBulkApi(l.length))&&await R(c,l.length,b),d=w&&await g===void 0?[`The org's duplicate rules could not be read (the user SandForge connects as needs View Setup and Configuration): ${c}, 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(l.length>N&&!w){if(o.aborted)return{successIds:[],errors:[],stopped:!0};let a=new we({signal:o}),h={connection:n,bulkManager:t,onProgress:(T,$e)=>{e.onProgress(T,$e,`Streaming insert ${c}`)},onOpened:T=>e.calls?.sending(c,l.length,{job:T})};e.calls?.sending(c,l.length);let A=await a.executeChunked(h,c,"insert",a.createChunkGenerator(l),l.length);e.calls?.answered(c,A.aborted?[]:A.successIds);let j=A.aborted?void 0:Ae({outcomes:A.outcomes??[],unmatchedIds:A.unmatchedIds},l.length),y=j&&await E(c,l,j,b);return y&&y.notes.length>0?{...P(y.rows),notes:y.notes}:{successIds:A.successIds,errors:A.errors,...A.aborted?{stopped:!0}:{}}}if(m.shouldUseBulkApi(l.length)&&!w){if(o.aborted)return{successIds:[],errors:[],stopped:!0};let a={connection:n,bulkManager:t,onProgress:(y,T)=>{e.onProgress(y,T,`Bulk insert ${c}`)},signal:o,onOpened:y=>e.calls?.sending(c,l.length,{job:y})};e.calls?.sending(c,l.length);let h=await m.executeBulk(a,c,"insert",l);e.calls?.answered(c,h.aborted?[]:h.successIds);let A=Ae(h,l.length),j=A&&await E(c,l,A,b);return j&&j.notes.length>0?{...P(j.rows),rows:j.rows,notes:j.notes}:{successIds:h.successIds,errors:h.failures.map(y=>y.error),...A?{rows:A}:{},...h.aborted?{stopped:!0}:{}}}let f=await k(c,l,b);if(f.stopped)return{...P(f.rows),rows:f.rows,stopped:!0};let s=await E(c,l,f.rows,b),u=[...d,...s.notes];return{...P(s.rows),rows:s.rows,...u.length>0?{notes:u}:{}}}}var Ce="SELECT Id, DeveloperName FROM RecordType WHERE SobjectType = 'Account' AND IsPersonType = true";async function rt(e){try{return(await e.query(Ce)).records.flatMap(t=>typeof t.Id=="string"&&typeof t.DeveloperName=="string"?[{id:t.Id,developerName:t.DeveloperName}]:[])}catch{return[]}}function nt(e,n,t){let r=new Set(e===I?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 Fe(e){let{staticValue:n,picklistValues:t}=e.config;return e.ruleType==="static"&&typeof n=="string"?[n]:e.ruleType==="picklist_random"?[...t??[]]:[]}function ot(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!==I){o.push(i);continue}let m=i.fieldRules.find(S=>S.fieldApiName==="RecordTypeId"),g=m?Fe(m):[],R=g.filter(S=>t.has(S.slice(0,15)));if(R.length>0&&R.length<g.length){let S=R.map(E=>t.get(E.slice(0,15))).join(", ");return{refusal:`${I}: ${S} ${R.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 k=R.length>0?"person":"business";k==="person"&&r.push(i.objectApiName),o.push({...i,fieldRules:i.fieldRules.filter(S=>!G(I,S.fieldApiName,k))})}return{template:{...e,objects:o},personObjects:r}}var Me=/^[a-z]{2,3}(?:_[A-Za-z0-9]{2,4}){0,2}$/;async function ve(e){try{let t=(await e.query("SELECT DefaultLocaleSidKey FROM Organization LIMIT 1")).records[0]?.DefaultLocaleSidKey;return typeof t=="string"&&Me.test(t)?t:void 0}catch{return}}async function it(e,n){return e??await ve(n)??"en_US"}var pt="SEED_FIT_STORAGE_UNREAD",ft="SEED_CANNOT_FIT";function gt(e,n=!1){return _(e.objects.filter(t=>t.recordCount>0).map(t=>t.objectApiName),n)}function _(e,n=!1){let t=new Set(e);return(r,o)=>t.has(r)&&(o==="insert"||o==="update"&&n&&r===Re)}function ht(e,n,t){if(typeof e.unread=="string")return{room:{perRecord:[],notCounted:[],unread:e.unread},unread:e.unread};let r=Y(e,n,t);return{running:r,room:pe(r,t)}}function C(e,n){return F(e.objectApiName,n)?.distribution.mode==="byKey"?"byKey":e.rows!==void 0?"rows":void 0}function ke(e,n){let t=F(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 Ee(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 Be(e,n,t){let r=new Map(e.objects.map(g=>[g.objectApiName,g])),o=new Map,i=new Set,m=g=>{let R=o.get(g);if(R!==void 0)return R;let k=r.get(g);if(C(k,e.relations))return o.set(g,k.recordCount),k.recordCount;i.add(g);let S=Math.round(n*Ee(k,t)),E=ke(g,e),p=E&&!i.has(E.parentObject)?Math.max(1,Math.min(S,q(E.distribution,m(E.parentObject)))):Math.max(1,S);return i.delete(g),o.set(g,p),p};return new Map(e.objects.map(g=>[g.objectApiName,m(g.objectApiName)]))}function De(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 Ne(e,n){let t=e.objects.filter(i=>!C(i,e.relations)),r=t.filter(i=>!ke(i.objectApiName,e)),o;for(let i of r.length>0?r:t){let m=Ee(i,n);(!o||m>o.records)&&(o={objectApiName:i.objectApiName,records:m})}return o}function Le(e){return`${e} record${e===1?"":"s"}`}function _e(e){let{template:n,personObjects:t,budget:r,room:o}=e,i=e.ask?.caps,m=e.ask?.share===!0||i===void 0,g=a=>{let h=Be(n,a,i),A=De(n,{objects:n.objects.map(y=>({objectApiName:y.objectApiName,before:y.recordCount,after:h.get(y.objectApiName)??y.recordCount}))}),j=fe(o,y=>h.get(y)??0);return{counts:h,bytes:Se(A,t)+j,roomBytes:j,requests:ye(A,e.path),records:[...h.values()].reduce((y,T)=>y+T,0)}},R=a=>a.bytes<=r.bytes,k=a=>r.runRequests===void 0||a.requests<=r.runRequests,S=a=>R(a)&&k(a),E=(a,h,A,j)=>({share:a,budget:{...ge(r,h.roomBytes,o),...A==="apiRequests"?{limitedBy:"apiRequests"}:{}},objects:n.objects.map(y=>{let T=C(y,n.relations);return{objectApiName:y.objectApiName,before:y.recordCount,after:h.counts.get(y.objectApiName)??y.recordCount,...T?{keptWhole:T}:{}}}),estimateMB:h.bytes/1048576,...j!==void 0?{cannotFit:j}:{},...o.unread!==void 0?{automationUnread:o.unread}:{}}),p=(a,h,A,j)=>({proposal:E(a,h,A,j),heldBy:A,records:h.records,requests:h.requests}),c=a=>{if(R(a))return`about ${a.requests} API requests, past the ${r.runRequests??0} that leave the org a tenth of its daily requests`;let h=me(a.bytes/1048576,r.bytes/1048576);return`${h.over} MB`+(a.roomBytes>0?", room for what the org's automation creates under them included":"")+`, past the ${h.bound} MB that fit`},l=a=>R(a)?"apiRequests":r.terms.limitedBy,b=n.objects.filter(a=>C(a,n.relations)).reduce((a,h)=>a+h.recordCount,0),w=g(1);if(S(w)){let a=n.objects.some(h=>(w.counts.get(h.objectApiName)??0)<h.recordCount);return p(1,w,a?"caps":"whole")}if(!m)return p(1,w,l(w),`with these caps the seed takes ${c(w)}: lower them, or fit by share`);let d=Ne(n,i);if(!d)return p(1,w,l(w),`the ${b} rows the template gives take ${c(w)}, and rows are kept whole`);let f=a=>g(a/d.records),s=D(d.records,a=>S(f(a)));if(s===0){let a=f(1);return p(1/d.records,a,l(a),`the least it can be cut to \u2014 one ${d.objectApiName} and what follows it`+(b>0?`, with the ${b} rows the template gives kept whole`:"")+`, ${Le(a.records)} \u2014 takes ${c(a)}`)}let u=D(d.records,a=>R(f(a)));return p(s/d.records,f(s),u>s?"apiRequests":r.terms.limitedBy)}function bt(e,n,t,r,o){if(!("unread"in e))return _e({template:n,personObjects:t,budget:e,room:r,path:o}).proposal}function wt(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 Ie=(e,n)=>n==="insert";function je(e){return typeof e.unread=="string"}function qe(e){return(H(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:m})=>m===void 0?{name:i}:{name:i,held:m}),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 Te(e,n,t,r,o=Ie){let i=e.objects.flatMap(d=>{let f=qe(d);return f.length>0?[{objectApiName:d.objectApiName,entries:f}]:[]}),m=je(t)?void 0:t,g=m!==void 0&&ue(m),R=m!==void 0&&ce(m),k=v(x(e),g,R),S=i.flatMap(d=>d.entries.flatMap(f=>f.bypasses)),E=O(S.filter(d=>d.held===!0).map(d=>d.name)),p=O(S.map(d=>d.name)).filter(d=>!E.includes(d)),c=Q(e,p),l=p.map(d=>{let f=c.find(s=>s.permission.toLowerCase()===d.toLowerCase())?.permissionSet;return f?{permission:d,permissionSet:f.name}:{permission:d}}),b=V(e,o),w=b.assign.length>0;return{org:n,objectsRead:[...e.objectsRead],objects:i,emailsPerRecord:k,...m&&k.length>0?{limits:{...m}}:{},...je(t)?{limitsUnread:t.unread}:{},alertsAsSingle:g,bypasses:l,bypassesHeld:E,...w?{mute:b,emailsPerRecordMuted:v(x(J(e,X(b))),g,R)}:{},unread:e.unread.map(({part:d,reason:f})=>({part:d,reason:f})),blinded:K(e.unread),conditionsNotRead:e.conditionsNotRead,...r?{deliverability:r}:{}}}async function jt(e){let n=e.writes??_(e.objects),t;try{t=await e.readAutomation(e.objects)}catch(i){return{error:M(i)}}let r=e.deliverability??(e.readDeliverability?(await ne({read:t,writes:Ie,readDeliverability:e.readDeliverability,accepted:!1,target:e.org,run:"seed"})).gate.deliverability:void 0);if(x(t).length===0)return{preview:Te(t,e.org,{},r,n)};let o=await e.readLimits().catch(i=>({unread:M(i)}));return{preview:Te(t,e.org,o,r,n)}}function $(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 Tt="SEED_EMAILS_EXCEEDED";function It(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??{},m=le(o,r.emailsPerRecord,i),g=new Set(n.filter(s=>s.recordCount>0).map(s=>s.objectApiName)),R=r.objects.flatMap(s=>g.has(s.objectApiName)?s.entries.filter(u=>u.unread&&!u.keptQuiet&&u.when!=="before").map(u=>`"${u.name}" on ${s.objectApiName}`):[]),k=[...m.filter(s=>s.verdict==="unread").map(s=>`about ${B(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`]:[],...R.length>0?[`the emails of ${$(R)} are not counted: what ${R.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`]:[]],S=m.find(s=>s.verdict==="exceeds");if(!S)return k.length>0?{checks:m,unknown:k}:{checks:m};let E=m.filter(s=>s.verdict==="exceeds"),p=O(E.flatMap(s=>s.objects.map(u=>u.objectApiName))),c=O(E.flatMap(s=>s.objects.flatMap(u=>u.sentBy))),l=new Map;for(let s of r.objects.flatMap(u=>u.entries))if(!(s.emails===0||!c.includes(s.name)))for(let{name:u}of s.bypasses)l.set(u,(l.get(u)??new Set).add(s.name));let b=r.bypasses.flatMap(s=>{let u=l.get(s.permission);return u?[{...s,quiets:O([...u])}]:[]}),w=E.map(s=>`about ${B(s.emails,s.limit)} (`+s.objects.map(u=>`${u.perRecord} per ${u.objectApiName}`).join(", ")+`), ${s.remaining??0} of ${s.max??0} left today`).join("; "),d=["lower the record counts",`set ${$(p)} to 0`,`turn off ${$(c.map(s=>`"${s}"`))}`,...b.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 ${$(s.quiets.map(u=>`"${u}"`))} quiet`)],f=`The seed was refused before it wrote anything: its records would make ${t} send ${w}. 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, ${$(d,"or")}. Nothing was written.`;return{checks:m,refusal:f,figures:{org:t,limit:S.limit,emails:S.emails,remaining:S.remaining??0,max:S.max??0,objects:p,senders:c,bypasses:b},...k.length>0?{unknown:k}:{}}}var We={flow:e=>`flow "${e}"`,trigger:e=>`Apex trigger ${e}`,process:e=>`process "${e}"`,workflowRule:e=>`workflow rule "${e}"`},Ue={before:"before save",after:"after save",beforeAndAfter:"before and after save"},Ge={notification:"custom notifications",outbound:"outbound messages",sms:"text messages"};function He(e){let n=r=>r.held===!0?" (held)":r.held===!1?" (not held)":"",t=[Ue[e.when],...e.emails>0?[`${e.emails} email(s) a record`]:[],...e.messages.map(r=>`sends ${Ge[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`${We[e.kind](e.name)} (${t.join("; ")})`}function $t(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(He).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{Ze as a,rt as b,nt as c,ot as d,it as e,pt as f,ft as g,gt as h,_ as i,ht as j,De as k,_e as l,bt as m,wt as n,jt as o,Tt as p,It as q,$t as r};
|
|
@@ -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{f as a,g as b,h as c,i as d,j as e,k as f,l as g}from"./chunk-TTKXMDBN.mjs";import"./chunk-5TC3QB4U.mjs";import"./chunk-2BA2XKAY.mjs";import"./chunk-JEERQRLW.mjs";import"./chunk-5P4PHJRL.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-SIHORWVK.mjs";import"./chunk-JPUR2CFX.mjs";import"./chunk-LPBMBW3O.mjs";import"./chunk-IFETCRWE.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-SAR5622P.mjs";import"./chunk-EQNW3UC2.mjs";import"./chunk-GSKCGQIP.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-TYYOBZMU.mjs";import"./chunk-ZUTYVST5.mjs";import"./chunk-CU2INBND.mjs";import"./chunk-YKKRIEH4.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-JWTSEDIQ.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-WIO4XO4F.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-GCOB7K5N.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-L77FJZEP.mjs";import"./chunk-A527W53V.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-GGD7ON3M.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{d as diffOfPicked,b as heldInPlaceReason,g as planSelection,c as rewindPlan,a as rewindWriters,f as selectionPlanOf,e as snapshotRowsOf};
|
|
@@ -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 n,b as p,h as a}from"./chunk-K2FBZIXY.mjs";import{a as o}from"./chunk-EADHKH3A.mjs";import{p as d}from"./chunk-A527W53V.mjs";var R=`SELECT Id FROM RecordType WHERE SobjectType = '${d}' AND IsPersonType = true`;async function S(i,t){let[y,c]=await Promise.all([o(i,n).then(({records:e})=>p(e)),o(t,n).then(({records:e})=>p(e))]),r;try{let{records:e}=await o(t,R);r=new Set(e.flatMap(s=>typeof s.Id=="string"?[s.Id.slice(0,15)]:[]))}catch{r=void 0}return{mappings:new a().buildMapping(y,c),source:y,target:c,...r?{personTypes:r}:{}}}export{S as a};
|
|
@@ -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}from"./chunk-BV6VTP3J.mjs";import"./chunk-TTFDUKUS.mjs";import"./chunk-7EANH5PY.mjs";import"./chunk-NTOVCTRS.mjs";export{a as SeedValidator};
|
|
@@ -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 P}from"./chunk-ZUTYVST5.mjs";import{d as X}from"./chunk-CU2INBND.mjs";import{d as Z}from"./chunk-WIO4XO4F.mjs";import{a as F}from"./chunk-EADHKH3A.mjs";import{c as H,g as Y}from"./chunk-GCOB7K5N.mjs";import{f as Q,s as W}from"./chunk-A527W53V.mjs";import{a as U,f as D,h as _}from"./chunk-TZE3Y7IQ.mjs";import{L as B,N as z,Q as V,Wb as k}from"./chunk-TTFDUKUS.mjs";import{b as I,k as C,l as A,v as K,z as R}from"./chunk-7EANH5PY.mjs";function Pe(e){let n=new Set;for(let t of e)t.controllerName&&n.add(t.controllerName);return n}function J(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}function Me(e,n){let t=J(e.precision),r=typeof e.scale=="number"&&e.scale>=0?e.scale:void 0,o=J(e.digits),s=(e.picklistValues??[]).filter(d=>d!==null&&typeof d.value=="string"),i={};if(e.controllerName)for(let d of s)d.active===!1||typeof d.validFor!="string"||(i[d.value]=d.validFor);return{...t!==void 0?{precision:t}:{},...t!==void 0&&r!==void 0?{scale:r}:{},...o!==void 0?{digits:o}:{},...e.unique===!0?{unique:!0}:{},...e.unique===!0&&typeof e.caseSensitive=="boolean"?{caseSensitive:e.caseSensitive}:{},...e.calculated===!0?{calculated:!0}:{},...e.filteredLookupInfo?{filteredLookup:!0}:{},...Object.keys(i).length>0?{validFor:i}:{},...n.has(e.name)&&s.length>0?{controllingValues:s.map(d=>d.value)}:{}}}function je(e,n){return e.caseSensitive===!1?n.toLowerCase():n}function M(e,n){if(n<0)return!1;let r=Buffer.from(e,"base64")[n>>3];return r!==void 0&&(r&128>>n%8)!==0}var ie={picklist_value_refused:["map_value","leave_empty","skip_rows","exclude_object","ignore"],dependent_value_invalid:["map_value","leave_empty","exclude_object","ignore"],picklist_value_absent:["map_value","skip_rows","ignore"],required_field_missing:["set_default","exclude_object","ignore"],value_too_long:["truncate","exclude_object","ignore"],number_out_of_range:["exclude_object","ignore"],record_type_unmapped:["map_record_type","exclude_object","ignore"],record_type_unavailable:["map_record_type","exclude_object","ignore"],currency_inactive:["map_value","skip_rows","exclude_object","ignore"],unique_value_collision:["exclude_object","ignore"]};function S(e){return[...ie[e]??["ignore"]]}var se=100,ae=new Set(["longest","colliding"]),T=class{gaps=new Map;recordTypes=new Map;get size(){return this.gaps.size}knowRecordTypes(n,t,r){let o=de(r);o!==void 0&&this.recordTypes.set(n,{...this.recordTypes.get(n),[t]:o})}add(n){let t=B(n.kind,n.objectApiName,n.field,n.recordType,n.value),r=this.gaps.get(t);if(!r){this.gaps.set(t,{...n,id:t,source:"simulation",decisions:[...n.decisions]});return}r.rows+=n.rows,n.decisions.includes("skip_rows")||(r.decisions=r.decisions.filter(s=>s!=="skip_rows"));let o={...n.detail??{},...r.detail??{}};for(let s of ae){let i=r.detail?.[s],d=n.detail?.[s];typeof i=="number"&&typeof d=="number"&&(o[s]=Math.max(i,d))}r.detail=o}list(n){let t=[...this.gaps.keys()],r=[...this.gaps.values()].map(o=>this.withSameDeveloperName(o)).map(o=>z(n,o,t)!==void 0?{...o,detail:{...o.detail??{},ignored:!0}}:o);return V(r)}withSameDeveloperName(n){let t=n.kind==="record_type_unmapped";return le(n,this.recordTypes.get(n.objectApiName)?.[t?"source":"target"])}};function de(e){let n=e.filter(t=>!t.master);if(!n.some(t=>t.namespacePrefix===void 0))return n.map(Z)}function le(e,n){let t=e.kind==="record_type_unmapped"?e.value:e.recordType;if(t===void 0||n===void 0)return e;let r=Y(t);if(!r.namespacePrefix)return e;let o=n.filter(s=>s.developerName===r.developerName&&s.namespacePrefix!==r.namespacePrefix).map(s=>H(s.namespacePrefix,s.developerName));return o.length===0?e:{...e,detail:{...e.detail??{},sameDeveloperName:[...new Set(o)].sort()}}}function j(e){return[...new Set(e)].sort().slice(0,se)}function Ve(e,n,t){let r=[];for(let o of n){if(o.field===P)continue;let s=t(o);for(let i of o.values)r.push({kind:"picklist_value_refused",severity:"warning",objectApiName:e,field:o.field,...o.recordType!==void 0?{recordType:o.recordType}:{},value:i,rows:1,detail:{reason:o.reason,...s?{allowed:j(s)}:{},...o.controllingField?{controllingField:o.controllingField}:{},...o.replacedBy!==void 0?{replacement:o.replacedBy}:{}},decisions:S("picklist_value_refused").filter(d=>d!=="skip_rows"||o.reason!=="controlling-value"),defaultDecision:o.replacedBy!==void 0?"map_value":"leave_empty"})}return r}var ce=new Set(["string","textarea","email","phone","url","encryptedstring"]),ue=new Set(["double","currency","percent"]);function fe(e){return e==null||e===""}function ne(e){return e.createable&&e.nillable===!1&&e.defaultedOnCreate!==!0&&e.calculated!==!0&&e.type!=="boolean"}function pe(e,n,t){return e==="Account"&&n==="Name"&&W(t)}function ge(e,n,t,r){return r.filter(o=>ne(o)&&fe(n[o.name])&&!pe(e,o.name,t))}function me(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string"||e.trim()==="")return;let n=Number(e);return Number.isFinite(n)?n:void 0}function ee(e){if(e.type==="int"&&e.digits!==void 0)return e.digits;if(e.precision!==void 0)return e.precision-(e.scale??0)}function ye(e,n){return e?e.type==="boolean"?n===!0||n==="true"?1:n===!1||n==="false"?0:-1:typeof n!="string"||n===""?-1:(e.controllingValues??[]).indexOf(n):-1}function te(e,n){let{objectApiName:t,rows:r,targetFields:o,picklistValuesByField:s,picklistFields:i}=e,d=new Map(o.map(l=>[l.name,l])),u=o.filter(ne),g=o.filter(l=>l.createable&&ce.has(l.type??"")&&(l.length??0)>0),f=o.filter(l=>l.createable&&(ue.has(l.type??"")||l.type==="int")&&ee(l)!==void 0),y=[...i].filter(([l,c])=>c.anyValue===!0&&s?.has(l)===!0),m=o.filter(l=>l.createable&&l.controllerName!==void 0&&l.validFor!==void 0);for(let{payload:l,source:c,typed:p}of r){for(let a of ge(t,l,c,u))n.add({kind:"required_field_missing",severity:"blocking",objectApiName:t,field:a.name,rows:1,...a.type?{detail:{type:a.type}}:{},decisions:S("required_field_missing")});for(let a of g){let h=l[a.name],b=a.length??0;typeof h!="string"||h.length<=b||n.add({kind:"value_too_long",severity:"blocking",objectApiName:t,field:a.name,rows:1,detail:{length:b,longest:h.length},decisions:S("value_too_long")})}for(let a of f){let h=me(l[a.name]),b=ee(a);h===void 0||b===void 0||Math.abs(Math.trunc(h))<10**b||n.add({kind:"number_out_of_range",severity:"blocking",objectApiName:t,field:a.name,rows:1,detail:{...a.precision!==void 0?{precision:a.precision}:{},...a.scale!==void 0?{scale:a.scale}:{},...a.type==="int"&&a.digits!==void 0?{digits:a.digits}:{}},decisions:S("number_out_of_range")})}for(let[a,h]of y){let b=l[a];if(typeof b!="string"||b==="")continue;let O=s?.get(a),E=h.multi?b.split(";"):[b];for(let v of new Set(E))O?.has(v)||n.add({kind:"picklist_value_absent",severity:"info",objectApiName:t,field:a,value:v,rows:1,decisions:S("picklist_value_absent")})}if(!p)for(let a of m){let h=l[a.name];if(typeof h!="string"||h==="")continue;let b=d.get(a.controllerName??""),O=ye(b,l[a.controllerName??""]),E=i.get(a.name)?.restricted===!0,v=i.get(a.name)?.multi?h.split(";"):[h];for(let G of new Set(v)){let $=a.validFor?.[G];$!==void 0&&(O>=0&&M($,O)||n.add({kind:"dependent_value_invalid",severity:E?"blocking":"warning",objectApiName:t,field:a.name,value:G,rows:1,detail:{controllingField:a.controllerName??"",allowed:j((b?.controllingValues??[]).filter((De,oe)=>M($,oe)))},decisions:S("dependent_value_invalid")}))}}}}function Ue(e,n,t,r){return{kind:"currency_inactive",severity:"warning",objectApiName:e,field:P,value:n,rows:t,...r&&r.to.length>0?{detail:{replacement:r.to.join(", "),...r.converted.length>0?{amountsConverted:[...r.converted]}:{},...r.asRead?{amountsAsRead:!0}:{}}}:{},decisions:S("currency_inactive"),defaultDecision:"map_value"}}function Qe(e,n,t,r){return{kind:"unique_value_collision",severity:"warning",objectApiName:e,field:n,rows:t,detail:{colliding:r,linkedToTheRecordItNames:!0},decisions:S("unique_value_collision"),defaultDecision:"ignore"}}function We(e,n,t,r,o){return{kind:e,severity:"blocking",objectApiName:n,field:"RecordTypeId",...e==="record_type_unavailable"?{recordType:t}:{value:t},rows:r,detail:{mapTo:j(o)},decisions:S(e)}}var he=10;function re(e){switch(e.operation){case"insert":return null;case"upsert":return e.externalIdField??"Id";case"update":case"delete":return"Id"}}function w(e){if(e==null||typeof e!="string"&&typeof e!="number"&&typeof e!="boolean")return null;let n=String(e);return n===""?null:n.toLowerCase()}function x(e){return typeof e=="number"&&Number.isFinite(e)?String(e):typeof e=="boolean"?e?"true":"false":`'${U(String(e))}'`}var be=200,we=4e3;function N(e){let n=[],t=[],r=0;for(let o of e){let s=x(o).length+2;t.length>0&&(t.length>=be||r+s>we)&&(n.push(t),t=[],r=0),t.push(o),r+=s}return t.length>0&&n.push(t),n}function nn(e,n){return async(t,r,o,s)=>{let i=k(r.objectApiName),d=_(o),u=new Map;for(let g of N(s)){if(n?.aborted)throw new Error("The simulation was cancelled.");let{records:f}=await F(e,`SELECT ${d} FROM ${i} WHERE ${d} IN (${g.map(x).join(", ")})`);for(let y of f){let m=w(y[d]);m!==null&&u.set(m,(u.get(m)??0)+1)}}return u}}var Se=new Set(["attributes","Id"]);function ke(e,n,t,r){return n?e.conflictFields.filter(o=>o!==t&&!Se.has(o)&&o in n&&(r===null||r.has(o))):[]}var tn=new Set(["noKey","notInTarget","ambiguous"]);function Re(e,n,t){let r=e.operation,o=re(e);if(o===null)return"insert";let s=w(n[o]);if(s===null)return r==="delete"?"notSent":"noKey";let i=t.get(s)??0;return r==="upsert"?i===0?o.toLowerCase()==="id"?"notInTarget":"insert":i===1?"update":"ambiguous":i===0?"notInTarget":r==="update"?"update":"delete"}function rn(e){let{objectConfig:n,records:t,inTarget:r}=e,o=n.operation,s=re(n),i={insert:0,update:0,delete:0,noKey:0,notInTarget:0,notSent:0,ambiguous:0},d=new Set;t.forEach((c,p)=>{let a=Re(n,c,r);i[a]++,(a==="insert"||a==="update")&&d.add(p)});let u=e.leftOut.map(({why:c,count:p})=>Q(p,c));i.noKey>0&&u.push(o==="upsert"?`${i.noKey} record(s) carry no value in ${s}: an upsert matches on it, and the target refuses a record without one.`:`${i.noKey} record(s) carry no Id: an update finds its record by Id, and the target refuses one without it.`),i.notInTarget>0&&u.push(`${i.notInTarget} record(s) carry an Id the target does not hold: ${o==="upsert"?"an upsert on the Id finds no record there and creates none":`${o==="update"?"an update":"a delete"} finds no record there`}, and the target refuses it. Two orgs share a record's Id only when it was copied with the org.`),i.ambiguous>0&&u.push(`${i.ambiguous} record(s) match more than one record of the target on ${s}: an upsert finds no single record to update, and the target refuses it.`),i.notSent>0&&u.push(`${i.notSent} record(s) carry no Id: a delete sends ids alone, so the run leaves them out.`);let g=new Map;e.unsettled.forEach((c,p)=>{let a=String(c[e.matchField]??"");a&&d.has(p)&&g.set(a,c)});let f=new Map,y=0;for(let c of e.conflicts){let p=ke(c,g.get(c.recordId),e.matchField,e.writable);if(p.length!==0){y++;for(let a of p)f.set(a,(f.get(a)??0)+1)}}let m=[...f].sort(([c,p],[a,h])=>h-p||c.localeCompare(a)).slice(0,he).map(([c])=>c),l=e.leftOut.reduce((c,{count:p})=>c+p,0);return{objectApiName:n.objectApiName,operation:o,read:e.read,insert:i.insert,update:i.update,delete:i.delete,skipped:l+i.notSent,refused:i.noKey+i.notInTarget+i.ambiguous,conflicts:y,conflictFields:m,notes:u}}function _e(e){let n=e.field??"";switch(e.kind){case"required_field_missing":return`${e.rows} record(s) leave ${n} empty, which the target requires: it refuses them (REQUIRED_FIELD_MISSING).`;case"value_too_long":return`${e.rows} record(s) hold a ${n} longer than the ${String(e.detail?.length)} characters the target's field takes (the longest, ${String(e.detail?.longest)}): it refuses them (STRING_TOO_LONG).`;case"number_out_of_range":return`${e.rows} record(s) hold a ${n} larger than the target's field takes: it refuses them (NUMBER_OUTSIDE_VALID_RANGE).`;default:return}}function on(e,n,t){let r=new Set,o=new T;n.forEach(({payload:i,source:d,creates:u},g)=>{let f=new T;te({objectApiName:e,rows:[{payload:i,source:d,typed:!0}],targetFields:t,picklistValuesByField:null,picklistFields:new Map},f);let y=f.list(new Set).filter(m=>m.severity==="blocking"&&(u||m.kind!=="required_field_missing"));if(y.length!==0){r.add(g);for(let m of y)o.add(m)}});let s=o.list(new Set).flatMap(i=>{let d=_e(i);return d?[d]:[]});return{refused:r,notes:s}}function sn(e,n){let t=new Set,r=new Set,o=[];for(let[s,i]of n){let d=new Set,u=0,g=0,f=0;e.forEach((y,m)=>{let l=w(y[s]);if(l===null)return;let c=i.get(l)??0;c===1?(u++,r.add(m)):c>1?(g++,t.add(m)):d.has(l)&&(f++,t.add(m)),d.add(l)}),u>0&&o.push(`LINKED_TO_EXISTING: ${u} record(s) hold a ${s} the target keeps unique, which a record of the target holds already: it refuses them as duplicates (DUPLICATE_VALUE) and names that record, which the run links them to \u2014 what it writes under them points at that record.`),g+f!==0&&o.push(`${g+f} record(s) hold a ${s} the target keeps unique, which `+[g>0?`several records of the target hold already (${g})`:"",f>0?`a record sent before them holds (${f})`:""].filter(Boolean).join(" or ")+": it refuses them (DUPLICATE_VALUE).")}for(let s of t)r.delete(s);return{refused:t,linked:r,notes:o}}import{createHash as Fe}from"node:crypto";var Ie=5*6e4,Te=500,xe=A({sourceOrgId:I().min(1).max(200),targetOrgId:I().min(1).max(200),objectApiName:I().regex(/^[A-Za-z][A-Za-z0-9_]{0,79}$/),watermark:R.datetime(),fingerprint:I().regex(/^[0-9a-f]{64}$/),recordedAt:R.datetime(),filesSeen:R.datetime().optional(),removedAt:R.datetime().optional()}),Oe=A({version:K(1),entries:C(xe).max(Te),resetAt:R.datetime().optional()});function mn(e){if(e==null)return{kind:"none"};let n=Oe.safeParse(e);if(n.success)return{kind:"stored",state:n.data};let t=n.error.issues[0];return{kind:"unreadable",issue:`${t.path.join(".")||"state"}: ${t.message}`}}function L(e){return Array.isArray(e)?`[${e.map(L).join(",")}]`:e!==null&&typeof e=="object"?`{${Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[r])=>t<r?-1:t>r?1:0).map(([t,r])=>`${JSON.stringify(t)}:${L(r)}`).join(",")}}`:JSON.stringify(e)}function q(e){let n=e?.trim();return n||null}function ve(e,n){let t={direction:e.direction,conflictStrategy:e.conflictStrategy,copiesFiles:e.files?!0:void 0,objectApiName:n.objectApiName,operation:n.operation,externalIdField:q(n.externalIdField),where:q(n.where),fieldMappings:n.fieldMappings??[],unmappedSentAsRead:(n.fieldMappings??[]).length>0?!0:void 0,transformRules:n.transformRules??[],excludedFields:n.excludedFields??[],addOnFields:n.addOnFields??[]};return Fe("sha256").update(L(t)).digest("hex")}function yn(e,n,t){let r=ve(e,n);if(t===null)return{read:"full",reason:"not_saved",fingerprint:r};if(t.kind==="unreadable")return{read:"full",reason:"unreadable",fingerprint:r};if(t.kind==="none")return{read:"full",reason:"first_run",fingerprint:r};let o=t.state.entries.find(s=>s.sourceOrgId===e.sourceOrgId&&s.targetOrgId===e.targetOrgId&&s.objectApiName===n.objectApiName);return o?o.fingerprint!==r?{read:"full",reason:"scope_changed",fingerprint:r}:o.removedAt!==void 0?{read:"full",reason:"removed",fingerprint:r}:{read:"delta",since:o.watermark,fingerprint:r,...o.filesSeen!==void 0?{filesSeen:o.filesSeen}:{}}:{read:"full",reason:t.state.resetAt?"reset":"first_run",fingerprint:r}}var Ne=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;function hn(e,n=Ie){let t=Date.parse(e);if(!Number.isFinite(t))throw new Error(`Not a watermark: "${e}".`);let r=Math.floor((t-n)/1e3)*1e3;return new Date(r).toISOString().replace(/\.\d{3}Z$/,"Z")}function bn(e){let n=Date.parse(e);if(!Number.isFinite(n))throw new Error(`Not a date: "${e}".`);return new Date(Math.floor(n/1e3)*1e3).toISOString().replace(/\.\d{3}Z$/,"Z")}function Ee(e){if(!Ne.test(e)||!Number.isFinite(Date.parse(e)))throw new Error(`Not a SOQL datetime: "${e}".`);return e}function wn(e,n){let t=e?.trim()?D(e):void 0;if(n===void 0)return t;let r=`SystemModstamp > ${Ee(n)}`;return t?`${r} AND (${t})`:r}function $e(e){if(typeof e!="string"||e==="")return null;let n=Date.parse(e.replace(/([+-]\d{2})(\d{2})$/,"$1:$2"));return Number.isFinite(n)?new Date(n).toISOString():null}function Sn(e,n,t){let r={query:i=>e.query(i),queryMore:i=>e.queryMore(i)},o={query:i=>e.query(i,{scanAll:!0}),queryMore:i=>e.queryMore(i)},s=()=>{if(t?.aborted)throw new Error("The run was cancelled.")};return{async latestModstamp(i){let d=k(i),g=(await e.query(`SELECT SystemModstamp FROM ${d} ORDER BY SystemModstamp DESC LIMIT 1`)).records[0];if(!g)return null;let f=$e(g.SystemModstamp);if(f===null)throw new Error(`${d} answered a SystemModstamp that is not a date.`);return f},async deletedRows(i,d,u){let g=k(i),f=new Set(["Id","SystemModstamp",...d.map(_)]),{records:y,truncated:m}=await F(o,`SELECT ${[...f].join(", ")} FROM ${g} WHERE IsDeleted = true AND (${D(u)})`);return{records:y,truncated:m}},async heldInSource(i,d,u){let g=k(i),f=_(d),y=new Set;for(let m of N(u)){s();let{records:l}=await F(r,`SELECT ${f} FROM ${g} WHERE ${f} IN (${m.map(x).join(", ")})`);for(let c of l){let p=w(c[f]);p!==null&&y.add(p)}}return y},async targetIdsByKey(i,d,u){let g=k(i),f=_(d),y=f==="Id"?"Id":`Id, ${f}`,m=new Map;for(let l of N(u)){s();let{records:c}=await F(n,`SELECT ${y} FROM ${g} WHERE ${f} IN (${l.map(x).join(", ")})`);for(let p of c){let a=w(p[f]);a===null||typeof p.Id!="string"||m.set(a,[...m.get(a)??[],p.Id])}}return m}}}var Ae=new Set(["direct","rename","transform"]);function kn(e){let n=e.objectApiName;if(e.operation==="insert"||e.operation==="delete")return{refused:`${n} is written by ${e.operation}, which finds no record by a key: a deleted source record cannot be tied to a target record.`};if(e.operation==="update")return{sourceField:"Id",keyField:"Id"};let t=q(e.externalIdField)??"Id";if((e.addOnFields??[]).some(s=>s.fieldApiName===t))return{refused:`${n}: an add-on writes ${t}, the key the upsert matches on, so it ties no deleted source record to one target record.`};let r=e.fieldMappings??[],o=r.find(s=>s.targetField.toLowerCase()===t.toLowerCase());return!o&&!X(r,e.excludedFields??[]).has(t.toLowerCase())?{sourceField:t,keyField:t}:!o||!Ae.has(o.type)?{refused:`${n}: no source field is carried onto ${t}, the key the upsert matches on, so no deleted source record can be tied to a target record.`}:{sourceField:o.sourceField,keyField:t}}async function Rn(e,n,t,r,o){let s=n.objectApiName,{records:i,truncated:d}=await e.deletedRows(s,[t.sourceField],r),u={ids:[],read:i.length,stillInSource:0,ambiguous:0,noKey:0,truncated:d};if(i.length===0)return u;let g=[];for(let c of i){let p=c[t.sourceField],a=o(c);if(w(p)===null||w(a)===null){u.noKey++;continue}g.push({raw:p,key:a})}if(g.length===0)return u;let f=t.sourceField==="Id"?new Set:await e.heldInSource(s,t.sourceField,g.map(c=>c.raw)),y=g.filter(c=>f.has(w(c.raw))?(u.stillInSource++,!1):!0);if(y.length===0)return u;let m=await e.targetIdsByKey(s,t.keyField,y.map(c=>c.key)),l=new Set;for(let c of y){let p=m.get(w(c.key))??[];p.length>1?u.ambiguous++:p.length===1&&!l.has(p[0])&&(l.add(p[0]),u.ids.push(p[0]))}return u}function _n(e,n){let t=[];return e.stillInSource>0&&t.push(`${e.stillInSource} record(s) deleted in the source share their ${n} with a record the source still holds: their target record was kept.`),e.ambiguous>0&&t.push(`${e.ambiguous} record(s) deleted in the source match more than one target record on ${n}: none of those target records was deleted.`),e.noKey>0&&t.push(`${e.noKey} record(s) deleted in the source carry no ${n}: no target record is tied to them.`),e.truncated&&t.push("The source's deleted records were read up to a bound: the rest are read by the next run, from the same watermark."),t}function Fn(e,n,t,r,o=0){return{read:e.read,...e.read==="delta"?{since:e.since}:{reason:e.reason},changed:n,deletionsChecked:t!==void 0,deleted:t?.deleted??0,deleteFailed:t?.deleteFailed??0,...t?.error!==void 0?{deletionError:t.error}:{},...r!==void 0?{recorded:r}:{},...o>0?{lookupsOwed:o}:{}}}export{Pe as a,Me as b,je as c,ie as d,T as e,de as f,le as g,Ve as h,ge as i,te as j,Ue as k,Qe as l,We as m,re as n,w as o,nn as p,tn as q,Re as r,rn as s,on as t,sn as u,Ie as v,mn as w,yn as x,hn as y,bn as z,Ee as A,wn as B,$e as C,Sn as D,kn as E,Rn as F,_n as G,Fn as H};
|
|
@@ -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}from"./chunk-SRPWW4A2.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-NTOVCTRS.mjs";export{c as DEFAULT_READ_BUDGET,d as MetadataCompare,f as firstDifference,b as installedByPackage,a as isInstalledByPackage,e as planReads};
|