sandforge 1.81.0 → 1.82.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/README.md +48 -0
- package/bin/sandforge-users.mjs +12 -0
- package/lib/{chunk-C4YGSK6W.mjs → chunk-27Z76O2O.mjs} +1 -1
- package/lib/{chunk-TKQQVB2D.mjs → chunk-2JZGCCPG.mjs} +1 -1
- package/lib/{chunk-TPHXRHOA.mjs → chunk-2UU42PTD.mjs} +1 -1
- package/lib/{chunk-ZWZXQTAK.mjs → chunk-32EUNQT6.mjs} +14 -14
- package/lib/{chunk-HYOOJVR6.mjs → chunk-3C2ZZIFN.mjs} +1 -1
- package/lib/{chunk-AELFEK3G.mjs → chunk-3CX7GPCR.mjs} +1 -1
- package/lib/{chunk-YJEXE6HZ.mjs → chunk-3HEMJTAP.mjs} +2 -2
- package/lib/{chunk-DQR5NDMI.mjs → chunk-3HROD5RE.mjs} +1 -1
- package/lib/{chunk-D7P7DTWL.mjs → chunk-3MGMNK3Q.mjs} +1 -1
- package/lib/{chunk-MNITSYI2.mjs → chunk-3SKLBRPL.mjs} +1 -1
- package/lib/{chunk-MAHZMPMZ.mjs → chunk-3XG25GTF.mjs} +1 -1
- package/lib/{chunk-N7J6NJQ6.mjs → chunk-42BFLWHR.mjs} +1 -1
- package/lib/chunk-466F37VD.mjs +7 -0
- package/lib/chunk-47UHTN3Q.mjs +7 -0
- package/lib/{chunk-DHGPDSXS.mjs → chunk-52EXDVPN.mjs} +1 -1
- package/lib/{chunk-5344TZBT.mjs → chunk-5K2I2DMP.mjs} +1 -1
- package/lib/{chunk-2OZG6GRW.mjs → chunk-6GQUZ4IP.mjs} +1 -1
- package/lib/{chunk-SW2NUKQL.mjs → chunk-6KP6WETK.mjs} +1 -1
- package/lib/{chunk-FSZTXLNW.mjs → chunk-6VSZNZHH.mjs} +1 -1
- package/lib/{chunk-6NADW3OI.mjs → chunk-7CVDVBEE.mjs} +1 -1
- package/lib/{chunk-67CC7RAE.mjs → chunk-7EYQYZJP.mjs} +1 -1
- package/lib/{chunk-IBURU7T7.mjs → chunk-7LKI7OAS.mjs} +1 -1
- package/lib/{chunk-CULAOP3U.mjs → chunk-7PY3VQP3.mjs} +1 -1
- package/lib/chunk-7SDZR6SR.mjs +7 -0
- package/lib/{chunk-V4RKM4QZ.mjs → chunk-7WSLT5VX.mjs} +1 -1
- package/lib/chunk-A32ISQ6M.mjs +28 -0
- package/lib/{chunk-K77NR3UK.mjs → chunk-A65ADTCR.mjs} +1 -1
- package/lib/chunk-A7JJWOLT.mjs +7 -0
- package/lib/{chunk-MWLFFVQV.mjs → chunk-AUS6NFLZ.mjs} +1 -1
- package/lib/{chunk-NWPQF5XR.mjs → chunk-BMTNTBBM.mjs} +1 -1
- package/lib/{chunk-FTA5LOVX.mjs → chunk-BN33LVPQ.mjs} +1 -1
- package/lib/chunk-BNKT3R3F.mjs +7 -0
- package/lib/{chunk-WM5JI4JI.mjs → chunk-C2N2TNEU.mjs} +1 -1
- package/lib/{chunk-5UT2ZBGF.mjs → chunk-C3LNYAVJ.mjs} +1 -1
- package/lib/{chunk-GYKNCYES.mjs → chunk-CBL42DUU.mjs} +1 -1
- package/lib/{chunk-W2AAGIZF.mjs → chunk-CCEH7L53.mjs} +1 -1
- package/lib/{chunk-WWTXRWNZ.mjs → chunk-CELEBWEZ.mjs} +1 -1
- package/lib/{chunk-D62KWDDT.mjs → chunk-CV47FDQW.mjs} +1 -1
- package/lib/{chunk-AJPSGVMD.mjs → chunk-CZLJZQCS.mjs} +1 -1
- package/lib/{chunk-YIGFYZQY.mjs → chunk-DBBPDSFN.mjs} +1 -1
- package/lib/{chunk-T5VAULLQ.mjs → chunk-DIL62SUN.mjs} +1 -1
- package/lib/chunk-DIS254AN.mjs +7 -0
- package/lib/{chunk-GK7VEYFM.mjs → chunk-DJCGURW7.mjs} +1 -1
- package/lib/{chunk-MHW6DV6T.mjs → chunk-DT3T7FRD.mjs} +1 -1
- package/lib/{chunk-PYUEHBA6.mjs → chunk-DWMRIWV5.mjs} +1 -1
- package/lib/{chunk-E2OBAWSH.mjs → chunk-EEFUE2ES.mjs} +1 -1
- package/lib/{chunk-MKNAZPOT.mjs → chunk-EOFO3PHS.mjs} +1 -1
- package/lib/{chunk-UUSLTW5V.mjs → chunk-FA4ZKDCU.mjs} +1 -1
- package/lib/{chunk-DHIW4IO5.mjs → chunk-FKK5YBGZ.mjs} +1 -1
- package/lib/{chunk-BZFIOZS3.mjs → chunk-FOIWWK7G.mjs} +1 -1
- package/lib/chunk-FZF23M6R.mjs +7 -0
- package/lib/{chunk-XIZ5LMQM.mjs → chunk-G2JR3F63.mjs} +1 -1
- package/lib/{chunk-2Z54GB6X.mjs → chunk-GBGHJTPC.mjs} +1 -1
- package/lib/{chunk-2NAIUKVL.mjs → chunk-GCGHHN4K.mjs} +1 -1
- package/lib/{chunk-TQM2XJ27.mjs → chunk-GGNUACTY.mjs} +1 -1
- package/lib/{chunk-2IB7I3IQ.mjs → chunk-GGUOIDWP.mjs} +1 -1
- package/lib/chunk-GHPR5UVV.mjs +7 -0
- package/lib/{chunk-YHIOS2PU.mjs → chunk-GJ6SZVHT.mjs} +1 -1
- package/lib/{chunk-WI4HYWV6.mjs → chunk-H4JUYUSL.mjs} +1 -1
- package/lib/{chunk-5WGA5CZB.mjs → chunk-H4OBZIX3.mjs} +1 -1
- package/lib/{chunk-KRNFVAGC.mjs → chunk-HFUDCNU5.mjs} +1 -1
- package/lib/{chunk-OIIL4NVI.mjs → chunk-HIHCYMSL.mjs} +1 -1
- package/lib/chunk-HKUWHVI7.mjs +9 -0
- package/lib/chunk-HQQVANWQ.mjs +20 -0
- package/lib/{chunk-V2QO6KOE.mjs → chunk-IRZJU2PG.mjs} +14 -11
- package/lib/{chunk-CAFUNR6D.mjs → chunk-ISSP2FZ5.mjs} +1 -1
- package/lib/{chunk-OEHVAJAB.mjs → chunk-IVZJSDJD.mjs} +1 -1
- package/lib/{chunk-E2YJVSX6.mjs → chunk-J24TIGSI.mjs} +1 -1
- package/lib/{chunk-YCSFP6ER.mjs → chunk-JESRFE2Z.mjs} +1 -1
- package/lib/{chunk-KOQV4WXC.mjs → chunk-JFNLKHY6.mjs} +2 -2
- package/lib/{chunk-NJ3EOEHS.mjs → chunk-JH27IKCO.mjs} +1 -1
- package/lib/{chunk-DXOXLUZA.mjs → chunk-JJITOWZK.mjs} +1 -1
- package/lib/{chunk-KNIRA333.mjs → chunk-JKT5YAQ2.mjs} +1 -1
- package/lib/{chunk-J6G23RUI.mjs → chunk-JLZRZL5E.mjs} +1 -1
- package/lib/{chunk-6FMLW7PH.mjs → chunk-JPEVIXNH.mjs} +1 -1
- package/lib/{chunk-6IGEASOF.mjs → chunk-JQZTMFO7.mjs} +1 -1
- package/lib/{chunk-55LQD3Y3.mjs → chunk-KIMQQ6JQ.mjs} +1 -1
- package/lib/{chunk-EH5YUA5W.mjs → chunk-KJYEQHYP.mjs} +1 -1
- package/lib/chunk-KKOA62S4.mjs +474 -0
- package/lib/{chunk-56MPPWLA.mjs → chunk-KP5G6FUC.mjs} +1 -1
- package/lib/{chunk-EAFLDSQ2.mjs → chunk-L4INJ5TZ.mjs} +1 -1
- package/lib/{chunk-MO3N5XVV.mjs → chunk-LAUOSXMN.mjs} +2 -2
- package/lib/{chunk-HVC5CYIB.mjs → chunk-LHU6CPGE.mjs} +1 -1
- package/lib/{chunk-7PK5QDQI.mjs → chunk-LXDSRP2W.mjs} +1 -1
- package/lib/{chunk-YOGMP72T.mjs → chunk-MKTXJCXN.mjs} +1 -1
- package/lib/{chunk-VSU74RQ3.mjs → chunk-MUEQRIK7.mjs} +1 -1
- package/lib/{chunk-UCHAZ4ZU.mjs → chunk-NLB3RGIY.mjs} +1 -1
- package/lib/{chunk-OVOLG3AL.mjs → chunk-NWOI25WY.mjs} +1 -1
- package/lib/{chunk-6SEDOIO3.mjs → chunk-O2PUGRNW.mjs} +1 -1
- package/lib/chunk-O4BROUGM.mjs +7 -0
- package/lib/{chunk-KGYXLSQ5.mjs → chunk-P55MKIZX.mjs} +1 -1
- package/lib/{chunk-KE2PGD6C.mjs → chunk-P63WJMXQ.mjs} +1 -1
- package/lib/chunk-PBE44M2Y.mjs +7 -0
- package/lib/{chunk-OMZJ37JI.mjs → chunk-PE435FVH.mjs} +2 -2
- package/lib/{chunk-GR3NGDVM.mjs → chunk-PPHVWUFY.mjs} +1 -1
- package/lib/{chunk-ZUA5BNAO.mjs → chunk-PR74GYVI.mjs} +1 -1
- package/lib/{chunk-43K2C6H2.mjs → chunk-PWVDNN2C.mjs} +1 -1
- package/lib/{chunk-DMBR24CK.mjs → chunk-PYRZFUVU.mjs} +1 -1
- package/lib/{chunk-OXKZ4Y3B.mjs → chunk-Q3DY7TO2.mjs} +1 -1
- package/lib/{chunk-EOSEMFPU.mjs → chunk-Q6SXNKV2.mjs} +1 -1
- package/lib/chunk-QAPVKPEC.mjs +7 -0
- package/lib/chunk-QROPNEGY.mjs +14 -0
- package/lib/{chunk-6CDIIFNX.mjs → chunk-RCYEBY42.mjs} +1 -1
- package/lib/chunk-RLWB7F26.mjs +7 -0
- package/lib/{chunk-X2ZVSQ54.mjs → chunk-RTWYLOCA.mjs} +1 -1
- package/lib/chunk-RYRMUPMY.mjs +7 -0
- package/lib/{chunk-ETT5GP4P.mjs → chunk-SAMWHL22.mjs} +1 -1
- package/lib/{chunk-LO527YLT.mjs → chunk-SFGZFB4F.mjs} +1 -1
- package/lib/{chunk-33ZX3A56.mjs → chunk-SNEOKYV7.mjs} +1 -1
- package/lib/{chunk-GTIXJCGS.mjs → chunk-STRMWSIQ.mjs} +1 -1
- package/lib/{chunk-OQQHNYR7.mjs → chunk-SZGGFST2.mjs} +2 -2
- package/lib/{chunk-OU5W7SCB.mjs → chunk-T7WREYA5.mjs} +1 -1
- package/lib/{chunk-FLNLG43R.mjs → chunk-TCBAE65A.mjs} +1 -1
- package/lib/{chunk-RKALOKAU.mjs → chunk-TMA34QMA.mjs} +1 -1
- package/lib/{chunk-WEZLXE34.mjs → chunk-TWV4A5RK.mjs} +1 -1
- package/lib/{chunk-ONMBSACW.mjs → chunk-UHFLKP26.mjs} +1 -1
- package/lib/chunk-UV74P4H2.mjs +7 -0
- package/lib/{chunk-HYBH5PFM.mjs → chunk-V3R45ZWT.mjs} +1 -1
- package/lib/{chunk-BNO5GIJ6.mjs → chunk-VPDEJGPS.mjs} +1 -1
- package/lib/{chunk-3AOKLIVE.mjs → chunk-VQJMP3DC.mjs} +1 -1
- package/lib/{chunk-742SSN7I.mjs → chunk-VYOYXTCU.mjs} +1 -1
- package/lib/{chunk-GWRKS3AL.mjs → chunk-VZT4E2OJ.mjs} +1 -1
- package/lib/{chunk-2OIRJEYE.mjs → chunk-VZVICK7Q.mjs} +1 -1
- package/lib/chunk-WEMLDUQA.mjs +7 -0
- package/lib/{chunk-FDGFUEK3.mjs → chunk-WOOUISSO.mjs} +1 -1
- package/lib/{chunk-UIUPPEFB.mjs → chunk-WSUKC2U3.mjs} +1 -1
- package/lib/{chunk-XC2QKQT5.mjs → chunk-WT3SCUHS.mjs} +1 -1
- package/lib/{chunk-UT27HXE7.mjs → chunk-XFU3HRUV.mjs} +1 -1
- package/lib/{chunk-5VQNKDFU.mjs → chunk-XK5W7BVE.mjs} +1 -1
- package/lib/{chunk-OZNLOV4U.mjs → chunk-XO5FBOQF.mjs} +1 -1
- package/lib/{chunk-FSDO4DJA.mjs → chunk-XSKPYGMT.mjs} +1 -1
- package/lib/{chunk-AITNZWLB.mjs → chunk-XU25YA46.mjs} +1 -1
- package/lib/{chunk-XEB6HZ34.mjs → chunk-XZISAZA6.mjs} +1 -1
- package/lib/chunk-Y4TDVDP2.mjs +13 -0
- package/lib/{chunk-4L7FBOJS.mjs → chunk-YAIIRFKJ.mjs} +1 -1
- package/lib/{chunk-T3PLRQ2T.mjs → chunk-YAJQS3OL.mjs} +1 -1
- package/lib/{chunk-Y5ZCPY36.mjs → chunk-YGJF55VJ.mjs} +1 -1
- package/lib/chunk-YH4DYI6D.mjs +7 -0
- package/lib/{chunk-R6TF26V4.mjs → chunk-YMDFF657.mjs} +1 -1
- package/lib/{chunk-JU2XEKEO.mjs → chunk-YT22LMF7.mjs} +1 -1
- package/lib/{chunk-NWVVCZUK.mjs → chunk-Z42PHCVZ.mjs} +1 -1
- package/lib/{chunk-O6ADMP36.mjs → chunk-ZHIZY3ZC.mjs} +1 -1
- package/lib/chunk-ZQO5PDX5.mjs +48 -0
- package/lib/{chunk-QXLZINZB.mjs → chunk-ZUBBEP75.mjs} +1 -1
- package/lib/{chunk-SQGP46QS.mjs → chunk-ZUOPC4W2.mjs} +1 -1
- package/lib/{chunk-3B5H24ZG.mjs → chunk-ZUTUYBNW.mjs} +1 -1
- package/lib/{chunk-K55LH4ZQ.mjs → chunk-ZXFL2MSN.mjs} +1 -1
- package/lib/sandforge-autopilot.mjs +1 -1
- package/lib/sandforge-backup.mjs +1 -1
- package/lib/sandforge-checkpoint.mjs +1 -1
- package/lib/sandforge-cleanup.mjs +1 -1
- package/lib/sandforge-clone.mjs +1 -1
- package/lib/sandforge-compare.mjs +1 -1
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +1 -1
- package/lib/sandforge-env.mjs +185 -139
- package/lib/sandforge-frozen.mjs +1 -1
- package/lib/sandforge-mcp.mjs +14 -14
- package/lib/sandforge-monitor.mjs +1 -1
- package/lib/sandforge-pipeline.mjs +1 -1
- package/lib/sandforge-seed.mjs +1 -1
- package/lib/sandforge-sync.mjs +1 -1
- package/lib/sandforge-users.mjs +157 -0
- package/lib/sandforge.mjs +1 -22
- package/lib/sf/sandforge/autopilot.mjs +20 -0
- package/lib/sf/sandforge/backup.mjs +20 -0
- package/lib/sf/sandforge/checkpoint.mjs +20 -0
- package/lib/sf/sandforge/cleanup.mjs +20 -0
- package/lib/sf/sandforge/clone.mjs +20 -0
- package/lib/sf/sandforge/compare.mjs +20 -0
- package/lib/sf/sandforge/dataops.mjs +20 -0
- package/lib/sf/sandforge/empty.mjs +20 -0
- package/lib/sf/sandforge/env.mjs +20 -0
- package/lib/sf/sandforge/frozen.mjs +20 -0
- package/lib/sf/sandforge/hardis-commands.mjs +20 -0
- package/lib/sf/sandforge/index.mjs +20 -0
- package/lib/sf/sandforge/mcp.mjs +20 -0
- package/lib/sf/sandforge/monitor.mjs +20 -0
- package/lib/sf/sandforge/pipeline.mjs +20 -0
- package/lib/sf/sandforge/seed.mjs +20 -0
- package/lib/sf/sandforge/sync.mjs +20 -0
- package/lib/sf/sandforge/users.mjs +20 -0
- package/lib/sfHelpHook.mjs +7 -0
- package/lib/sfPlugin.mjs +11 -0
- package/oclif.manifest.json +1 -0
- package/package.json +17 -3
- package/lib/chunk-2ZMGVBLW.mjs +0 -7
- package/lib/chunk-5C5XEVZN.mjs +0 -11
- package/lib/chunk-5CKWGZX4.mjs +0 -9
- package/lib/chunk-5ZKCLBTN.mjs +0 -474
- package/lib/chunk-7DALDJMO.mjs +0 -7
- package/lib/chunk-DPYTG6DM.mjs +0 -48
- package/lib/chunk-G4VXPS3A.mjs +0 -7
- package/lib/chunk-GF247DA7.mjs +0 -7
- package/lib/chunk-IKGHRYCN.mjs +0 -7
- package/lib/chunk-IM2XA6JI.mjs +0 -7
- package/lib/chunk-K5HV4YRO.mjs +0 -7
- package/lib/chunk-N6HHNR6J.mjs +0 -7
- package/lib/chunk-O7DAFE6M.mjs +0 -14
- package/lib/chunk-R2BJWO5N.mjs +0 -20
- package/lib/chunk-T26C576X.mjs +0 -9
- package/lib/chunk-V473C7LY.mjs +0 -7
- package/lib/chunk-WD47PGUS.mjs +0 -10
- package/lib/chunk-XC54KKKC.mjs +0 -7
- package/lib/chunk-XGKSSCW7.mjs +0 -7
- package/lib/chunk-ZWCRWF7E.mjs +0 -7
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{j as g}from"./chunk-
|
|
7
|
+
import{j as g}from"./chunk-ZQO5PDX5.mjs";var f=class{link(n,r,i,t){return t.length===0?n:n.map(o=>({...o,[r]:t[Math.floor(Math.random()*t.length)]}))}resolveInsertOrder(n,r=[]){let i=new Map;for(let e of n)i.set(e.objectApiName,e);let t=new Set,o=new Set,d=[];function c(e){if(t.has(e))return;if(o.has(e))throw new Error(`Circular dependency detected involving: ${e}`);o.add(e);let s=i.get(e);if(s){let p=g(s,r);for(let j of p)c(j);d.push(s)}o.delete(e),t.add(e)}for(let e of n)c(e.objectApiName);return d}};export{f as a};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as d}from"./chunk-PPGDAUEQ.mjs";import{a as c}from"./chunk-SU65Z2BA.mjs";import{
|
|
7
|
+
import{a as d}from"./chunk-PPGDAUEQ.mjs";import{a as c}from"./chunk-SU65Z2BA.mjs";import{Jc as a,Lc as u}from"./chunk-ZQO5PDX5.mjs";async function I(t){let e=(await t.query("SELECT Id, IsSandbox FROM Organization LIMIT 1")).records[0];if(typeof e?.Id!="string")throw new Error("The org gave no Organization record: whether it is a sandbox cannot be told.");if(e.IsSandbox===!0)return{id:e.Id,sandbox:!0};try{let r=(await t.query("SELECT OrganizationType FROM Organization LIMIT 1")).records[0]?.OrganizationType;return typeof r=="string"&&r!==""?{id:e.Id,sandbox:!1,edition:r}:{id:e.Id,sandbox:!1}}catch{return{id:e.Id,sandbox:!1}}}function h(t){let n=a({isSandbox:t.sandbox,edition:t.edition});return u(n,t.edition)==="production"}function p(t){let{errorCode:n,statusCode:e}=typeof t=="object"&&t!==null?t:{},o=t instanceof Error?t.message:String(t);return e===403||typeof n=="string"&&/^INSUFFICIENT_ACCESS/.test(n)||/\bINSUFFICIENT_ACCESS/.test(o)||(n==="INVALID_TYPE"||/\bINVALID_TYPE\b/.test(o))&&/\bOrganization\b/.test(o)}function l(t){if(d(t))return"auth";if(c(t))return"network";if(p(t))return"organizationRefused"}function O(t,n,e){let o=n instanceof Error?n.message:String(n);switch(e){case"auth":return`${t} refused the session SandForge holds for it (${o}): reconnect it \u2014 Reconnect on the Organizations page, or "sf org login web --alias ${t}" for a command line \u2014 then try again.`;case"network":return`${t} did not answer (${o}): try again once it answers.`;case"organizationRefused":return`${t} would not show its Organization record (${o}): reading it takes the View Setup and Configuration permission, which the user SandForge connects as lacks: give it to them, or connect as a user who has it.`}}var g=/\/services\/Soap\//,f=/\/services\/data\/v\d+\.\d+\/jobs\/(?:ingest|query)(?:[/?]|$)/,y=/^\/jobs\/(?:ingest|query)(?:[/?]|$)/;function b(t){let n=typeof t=="string"?t:t?.url??"";return f.test(n)||y.test(n)}function S(t){let n=0;if(typeof t.request!="function")return()=>n;let e=t._transport,o=t.request.bind(t);if(t.request=(...r)=>((e===void 0||!b(r[0]))&&n++,o(...r)),e!==void 0){let r=e.httpRequest.bind(e);e.httpRequest=(...i)=>{let s=i[0].url;return(g.test(s)||f.test(s))&&n++,r(...i)}}return()=>n}export{I as a,h as b,p as c,l as d,O as e,S as f};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as S,b as k}from"./chunk-UNDIBZWG.mjs";import{
|
|
7
|
+
import{a as S,b as k}from"./chunk-UNDIBZWG.mjs";import{dc as m,ec as z,fc as E,gc as h}from"./chunk-ZQO5PDX5.mjs";import{b as c,f as g,i as f,k as l,l as d}from"./chunk-WZQEK4WT.mjs";var D=/\bid\.?\s*:\s*([A-Za-z0-9]{18}|[A-Za-z0-9]{15})(?![A-Za-z0-9])/i;function x(e,s){let t;if(/^[A-Za-z0-9]{15}$/.test(e))t=S(e);else if(k(e))t=e;else return;if(!(s&&!t.startsWith(s)))return t}function v(e){return D.exec(e)?.[1]}var R=d({statusCode:c().optional(),errorCode:c().optional(),message:c().optional(),fields:l(f()).optional(),duplicateResult:f().optional()}).loose(),p="UNKNOWN_ERROR";function y(e){if(typeof e=="string")return{statusCode:p,message:e,fields:[]};let s=R.safeParse(e);return s.success?{statusCode:s.data.statusCode??s.data.errorCode??p,message:s.data.message??"",fields:(s.data.fields??[]).filter(t=>typeof t=="string")}:{statusCode:p,message:"Unknown error",fields:[]}}var _=/^([A-Z][A-Z0-9_]*):([\s\S]*):([A-Za-z0-9_]+(?: [A-Za-z0-9_]+)*)? ?--$/;function M(e){let s=e.trim();if(!s.endsWith("--")||s.slice(0,-2).includes("--"))return;let t=_.exec(s);if(t)return{statusCode:t[1],message:t[2],fields:t[3]===void 0?[]:t[3].split(" ")}}var b=d({matchResults:l(d({entityType:c().optional(),matchRecords:l(d({record:d({Id:c().optional(),attributes:d({type:c().optional()}).loose().optional()}).loose().optional()}).loose()).optional()}).loose()).optional()}).loose(),I=d({id:c().nullish(),success:g(),created:g().optional(),errors:l(f()).optional()}).loose();function P(e){return e.statusCode===p?e.message:`${e.statusCode}: ${e.message}`}function A(e){if(typeof e=="string")return e;let s=R.safeParse(e);if(!s.success)return"Unknown error";let t=s.data.statusCode??s.data.errorCode,n=s.data.message??"",r=t?`${t}: ${n}`:n,i=(s.data.fields??[]).filter(a=>typeof a=="string");if(i.length===0)return r;let o=`[${i.join(", ")}]`;return r.includes(o)?r:r?`${r} ${o}`:o}var C=5;function T(e){let s=(e??[]).map(r=>A(r)).filter(r=>r!==""&&r!=="Unknown error");if(s.length===0)return"Unknown insert error";let t=s.slice(0,C).join("; "),n=s.length-C;return n>0?`${t} (and ${n} more)`:t}function O(e,s){let t=R.safeParse(e);if(!t.success)return[];if((t.data.statusCode??t.data.errorCode)!==m)return[];let n=b.safeParse(t.data.duplicateResult);if(!n.success)return[];let r=[];for(let i of n.data.matchResults??[])for(let{record:o}of i.matchRecords??[]){let a=[i.entityType,o?.attributes?.type].filter(u=>typeof u=="string");a.length===0||a.some(u=>u!==s)||o?.Id&&r.push(o.Id)}return r}function w(e,s){let t=I.safeParse(e);if(!t.success){let i="Salesforce returned a save result of an unexpected shape";return{id:"",success:!1,errors:[i],errorDetails:[y(i)]}}let n=t.data.errors??[],r=n.flatMap(i=>O(i,s));return{id:t.data.id??"",success:t.data.success,...t.data.created!==void 0?{created:t.data.created}:{},errors:n.map(A),errorDetails:n.map(y),...r.length>0?{duplicateMatchIds:r}:{}}}function Z(e,s){return(Array.isArray(e)?e:[e]).map(t=>w(t,s))}function L(e,s){if(e.success||e.errors.length===0)return{kind:"none"};let t=o=>h(o)||z(o);if(!e.errors.every(t))return{kind:"none"};let n=new Set,r=!1;for(let o of e.errors){if(!o.includes(E))continue;let a=v(o),u=a?x(a,s):void 0;u?n.add(u):r=!0}let i=e.duplicateMatchIds??[];e.errors.some(o=>o.includes(m))&&i.length===0&&(r=!0);for(let o of i){let a=x(o,s);a?n.add(a):r=!0}return r||n.size!==1?{kind:"unidentified"}:{kind:"linked",id:[...n][0]}}export{x as a,p as b,y as c,M as d,P as e,A as f,T as g,O as h,w as i,Z as j,L as k};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as N}from"./chunk-
|
|
7
|
+
import{a as N}from"./chunk-SAMWHL22.mjs";import{a as j,h as D}from"./chunk-TZE3Y7IQ.mjs";import{b as J}from"./chunk-CA5NAXSU.mjs";function se(e){return`sync-before-${e.replace(/[^A-Za-z0-9-]+/g,"-")}`.slice(0,200)}var oe=1e3;function he(e){let o=se(e.runId),d=new Map,a=e.everyMs??oe,g=()=>(e.now?.()??new Date).getTime(),S,I=Number.NEGATIVE_INFINITY,k,E=!1,R=h=>{if(S===void 0)return;let t=[...d].map(([l,c])=>({objectApiName:l,recordCount:c,truncated:!1}));e.meta.set(`backup:${o}`,{operationId:o,orgId:e.orgId,...e.organizationId!==void 0?{organizationId:e.organizationId}:{},objects:t,partial:h,timestamp:S,totalRecords:t.reduce((l,c)=>l+c.recordCount,0),origin:"sync",runId:e.runId},"backups")},z=()=>{if(E)return;let h=I+a-g();if(h<=0){k!==void 0&&clearTimeout(k),k=void 0,I=g(),R(!0);return}k??=setTimeout(()=>{if(k=void 0,!E){I=g();try{R(!0)}catch{}}},h),k.unref?.()};return{id:o,keep:async(h,t)=>{t.length!==0&&(d.has(h)||(S??=(e.now?.()??new Date).toISOString(),d.set(h,0),R(!0),await e.files.begin(o,h)),await e.files.append(o,h,t),d.set(h,(d.get(h)??0)+t.length),z())},close:()=>{E=!0,k!==void 0&&clearTimeout(k),k=void 0,R(!1)}}}var F=200,de=["LastModifiedDate","LastModifiedById"],ee=100,te=4e3,ae=20,ne=255;function ce(e=ne){return 2*Math.max(0,e)+2}function ke(e,o){let d=o===void 0||o.creatable.size+4>ee;if(e.toLowerCase()==="id")return{characters:ae,wide:d};let a=o?.fields?.find(g=>g.name.toLowerCase()===e.toLowerCase());return a&&["double","int","long","currency","percent"].includes(a.type??"")?{characters:(a.precision??a.digits??18)+2,wide:d}:{characters:ce(a?.length??ne),wide:d}}function fe(e){let o=e.wide?F/4:F,d=Math.floor((te+2)/(Math.max(1,e.characters)+2));return Math.max(1,Math.min(o,d))}function me(e,o){let d=fe(o),a=e.reduce((g,S)=>g+Math.ceil(Math.max(0,S)/d),0);return a>0?a+1:0}function u(e){return e.slice(0,15)}function U(e,o){if(typeof e=="number"&&Number.isFinite(e))return`#${e}`;if(!(typeof e!="string"||e===""))return o?u(e):e.toLowerCase()}function ue(e){return typeof e=="number"?String(e):`'${j(String(e))}'`}function ge(e,o){let d=[],a=[],g=0;for(let S of e){let I=ue(S);a.length>0&&(a.length>=o||g+I.length>te)&&(d.push(a),a=[],g=0),a.push(I),g+=I.length+2}return a.length>0&&d.push(a),d}function le(e,o,d){return`What these ${o} ${e} record(s) would write over in the target could not be read and kept first (${J(d)}), so none of them was written: a run writes over nothing it cannot put back.`}function Se(e){let o=new Map,d=new Map,a=new Set,g=new Map,S=new Map,I=new Map,k=new Map,E=new Map,R=new Map,z=t=>{let l=e.describe,c=e.viewsEncrypted;if(!l||!c)return Promise.resolve(new Set);let y=I.get(t);return y||(y=l(t).then(async f=>{let m=(f.fields??[]).filter(M=>M.type===N).map(M=>M.name);return m.length>0&&!await c()?new Set(m):new Set},()=>new Set),I.set(t,y)),y},h=t=>{let l=e.describe;if(!l)return Promise.resolve(new Set);let c=S.get(t);return c||(c=l(t).then(y=>new Set((y.fields??[]).filter(f=>f.type==="base64"||f.queryable===!1).map(f=>f.name)),()=>new Set),S.set(t,c)),c};return{before:async(t,l,c,y)=>{if(g.delete(t),l!=="update"&&l!=="upsert"||c.length===0)return;let f=l==="update"?"Id":y??"Id",m=f==="Id";try{D(t),D(f);let M=await h(t),p=await z(t),v=new Set,O=new Set,T=new Map;for(let n of c){let i=U(n[f],m);i!==void 0&&!T.has(i)&&T.set(i,n[f]);for(let[r,s]of Object.entries(n))if(!(r==="Id"||r===f||r==="attributes")&&!M.has(r)&&!(typeof s=="object"&&s!==null)){if(p.has(r)){O.add(r);continue}v.add(D(r))}}if(T.size===0||v.size===0&&O.size===0)return;let x=["Id",...m?[]:[f],...v],V=[...x,...de.filter(n=>!x.includes(n))],re=V.length>ee?F/4:F,$=new Map,P=R.get(t)===!1?x:V;for(let n of ge([...T.values()],re)){let i=s=>`SELECT ${s.join(", ")} FROM ${t} WHERE ${f} IN (${n.join(", ")})`,r;try{r=await e.query(i(P))}catch(s){if(P===x)throw s;P=x,R.set(t,!1),r=await e.query(i(P))}for(let s of r){let w=U(m?s.Id:s[f],m);w===void 0||typeof s.Id!="string"||$.set(w,[...$.get(w)??[],s])}}let K=o.get(t)??new Map,_=[],B=new Map,C=new Map,G=new Map;for(let n of c){let i=U(n[f],m),r=i===void 0?void 0:$.get(i),s=r?.length===1?r[0]:void 0,w=s?.Id;if(_.push(w),!s||w===void 0||a.has(u(w)))continue;typeof s.LastModifiedDate=="string"&&G.set(u(w),{id:w,at:s.LastModifiedDate,...typeof s.LastModifiedById=="string"?{by:s.LastModifiedById}:{}});let ie=K.get(u(w)),q=B.get(u(w))??{Id:w},Q=C.get(u(w))??new Set;for(let b of Object.keys(n))!v.has(b)||ie?.has(b)||b in q||(q[b]=s[b]??null,Q.add(b));Q.size!==0&&(B.set(u(w),q),C.set(u(w),Q))}if(O.size>0&&_.some(n=>n!==void 0&&!a.has(u(n)))){let n=k.get(t)??new Set,i=[...O].filter(r=>!n.has(r));if(i.length>0){for(let r of i)n.add(r);k.set(t,n),e.recorder.unkept?.(t,i)}}if(B.size===0){g.set(t,{reaches:_,named:[],added:new Map});return}let X=[...B.values()],L=d.get(t)??new Map,Y=X.flatMap(n=>{let i=L.get(u(n.Id)),r=Object.entries(n).filter(([s])=>s==="Id"||!i?.has(s));return r.length>1?[Object.fromEntries(r)]:[]});Y.length>0&&await e.backup.keep(t,Y);for(let n of Y){let i=L.get(u(n.Id))??new Set;for(let r of Object.keys(n))r!=="Id"&&i.add(r);L.set(u(n.Id),i)}d.set(t,L);let A=X.map(n=>n.Id),W=E.get(t)??new Set,H=[];for(let n of A){let i=u(n);if(W.has(i))continue;W.add(i);let r=G.get(i);r&&H.push(r)}E.set(t,W),H.length>0?e.recorder.overwriting?.(t,e.backup.id,A,H):e.recorder.overwriting?.(t,e.backup.id,A);let Z=await e.recorder.flush();if(Z!==void 0)throw new Error(`the run's file could not be written: ${Z}`);for(let[n,i]of C){let r=K.get(n)??new Set;for(let s of i)r.add(s);K.set(n,r)}o.set(t,K),g.set(t,{reaches:_,named:A,added:C});return}catch(M){return le(t,c.length,M)}},answered:(t,l,c)=>{if(l==="insert"||l==="upsert")for(let p of c)p.success&&typeof p.id=="string"&&p.id!==""&&(l==="insert"||p.created===!0)&&a.add(u(p.id));let y=g.get(t);if(g.delete(t),!y||y.named.length===0)return;let f=new Set;c.forEach((p,v)=>{let O=y.reaches[v];O!==void 0&&p.success&&p.created!==!0&&f.add(u(O))});let m=y.named.filter(p=>!f.has(u(p))),M=o.get(t);for(let p of m){let v=M?.get(u(p));for(let O of y.added.get(u(p))??[])v?.delete(O)}e.recorder.overwrote?.(t,m)}}}export{se as a,he as b,ae as c,ce as d,ke as e,me as f,Se as g};
|
|
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{c as rr}from"./chunk-ZWZXQTAK.mjs";import"./chunk-WI4HYWV6.mjs";import"./chunk-WM5JI4JI.mjs";import"./chunk-56MPPWLA.mjs";import"./chunk-67CC7RAE.mjs";import"./chunk-OU5W7SCB.mjs";import"./chunk-T3PLRQ2T.mjs";import"./chunk-5WGA5CZB.mjs";import"./chunk-NWVVCZUK.mjs";import"./chunk-HYBH5PFM.mjs";import"./chunk-FSDO4DJA.mjs";import"./chunk-MHW6DV6T.mjs";import"./chunk-QXLZINZB.mjs";import"./chunk-OZNLOV4U.mjs";import"./chunk-2OZG6GRW.mjs";import{q as zt}from"./chunk-MO3N5XVV.mjs";import"./chunk-INIQ23K6.mjs";import"./chunk-TPHXRHOA.mjs";import{b as rn}from"./chunk-TKQQVB2D.mjs";import{a as vo,b as Eo,c as Po,d as Wo,e as Ho,f as Lt,g as Dt,h as $t,i as Ve,j as Ko,k as xe,l as Fe}from"./chunk-XIZ5LMQM.mjs";import"./chunk-AELFEK3G.mjs";import"./chunk-K77NR3UK.mjs";import"./chunk-OVOLG3AL.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-IM2XA6JI.mjs";import"./chunk-K55LH4ZQ.mjs";import"./chunk-5UT2ZBGF.mjs";import"./chunk-YHIOS2PU.mjs";import"./chunk-DHGPDSXS.mjs";import"./chunk-GMY5427L.mjs";import"./chunk-742SSN7I.mjs";import{Wa as qt,a as Co,d as Bt,e as Qo,f as Xo,g as Jo,h as Vo,i as Zo,j as er,k as _t,l as tr,m as nr,q as je}from"./chunk-YJEXE6HZ.mjs";import{a as Io}from"./chunk-FTA5LOVX.mjs";import"./chunk-KNIRA333.mjs";import"./chunk-7DALDJMO.mjs";import{a as Yo}from"./chunk-O7DAFE6M.mjs";import{b as mt,e as sn}from"./chunk-BZ24IAP5.mjs";import{a as ct}from"./chunk-SCKUIE3R.mjs";import{c as cn,d as dn,f as ln}from"./chunk-6FARZYMJ.mjs";import"./chunk-WB2RIVO3.mjs";import"./chunk-VSU74RQ3.mjs";import"./chunk-CAFUNR6D.mjs";import"./chunk-AITNZWLB.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-BOGNK4LV.mjs";import{b as un,c as pn,d as Ue,e as fn,f as Ao,g as ko,h as Ro,i as So,j as Oo,k as To,l as It}from"./chunk-KGYXLSQ5.mjs";import{h as Mo,i as Do,j as $o,k as Bo,l as Nt,m as _o,n as qo}from"./chunk-TEIBWMJM.mjs";import{h as zo,i as Go,k as Uo}from"./chunk-DMBR24CK.mjs";import{a as xo,b as xt,c as Ft,d as Fo,e as jo,f as No,g as Lo,h as jt}from"./chunk-BWWQXU2B.mjs";import{e as ro,f as so,g as io}from"./chunk-4L7FBOJS.mjs";import"./chunk-OXKZ4Y3B.mjs";import"./chunk-MAHZMPMZ.mjs";import"./chunk-M6P5ZZLE.mjs";import{o as to,p as no,q as Tt,r as oo,s as Xe}from"./chunk-UIUPPEFB.mjs";import"./chunk-6SEDOIO3.mjs";import"./chunk-ZWCRWF7E.mjs";import{d as Yn}from"./chunk-T63U4OZJ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import{d as Kn}from"./chunk-QIRO4HTE.mjs";import"./chunk-MNITSYI2.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-NJ3EOEHS.mjs";import"./chunk-ETT5GP4P.mjs";import"./chunk-SW2NUKQL.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-E2YJVSX6.mjs";import{b as ft,c as Ge}from"./chunk-HVC5CYIB.mjs";import{B as Qe,s as Vn,t as Ot,x as Ie,y as Zn,z as eo}from"./chunk-T26C576X.mjs";import"./chunk-BNO5GIJ6.mjs";import"./chunk-5LFSFYFJ.mjs";import{a as ae}from"./chunk-4TLYUZD5.mjs";import{a as pt,b as nn}from"./chunk-SQGP46QS.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-MS4FJDFD.mjs";import{b as Qn,c as Xn,g as Jn}from"./chunk-6IGEASOF.mjs";import{$a as lo,Ac as bo,Bc as Mt,Ma as ao,Pb as mo,Ra as Et,_a as co,ac as ho,bb as uo,bc as go,fb as Pt,fc as yo,hb as Je,ib as po,lb as fo,mc as Te,nc as wo,zb as Ct}from"./chunk-KOQV4WXC.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-CULAOP3U.mjs";import{i as xn}from"./chunk-INIT2UKJ.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-KRNFVAGC.mjs";import"./chunk-SU65Z2BA.mjs";import{q as vt}from"./chunk-2OIRJEYE.mjs";import{b as on,d as an,f as ht,h as or}from"./chunk-LCDPCUXS.mjs";import"./chunk-XEB6HZ34.mjs";import"./chunk-PC247GKX.mjs";import{a as he,j as Me,l as Fn,o as jn,p as Nn,q as Ln,t as Dn,u as $n,v as Bn,w as _n}from"./chunk-ICIYL45C.mjs";import"./chunk-ZUA5BNAO.mjs";import"./chunk-RKALOKAU.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-TQ2TQHTT.mjs";import{a as qn,b as At,c as kt,f as zn,h as Gn,j as Ke,l as Un,m as Wn}from"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import{a as He}from"./chunk-EADHKH3A.mjs";import{$ as vn,Y as Sn,Z as On,_ as Tn,a as mn,b as oe,c as We,d as hn,da as Ce,f as gn,fa as En,g as yn,ia as Pn,ja as Cn,ka as Mn,m as gt,n as wn,o as bn,p as An,q as ce,r as fe,s as yt,t as Pe,u as kn,z as Rn}from"./chunk-55LQD3Y3.mjs";import{a as ge,h as ye}from"./chunk-TZE3Y7IQ.mjs";import{b as Ye,c as Rt,j as St,k as Hn}from"./chunk-3B5H24ZG.mjs";import"./chunk-UNDIBZWG.mjs";import{b as wt,d as bt,e as In}from"./chunk-EAFLDSQ2.mjs";import{b as ee}from"./chunk-CA5NAXSU.mjs";import{$b as Qt,Hd as ze,Lc as tn,Y as dt,Yb as lt,ac as Xt,bc as Jt,fc as Oe,gc as Ae,hc as _e,ic as ve,jc as Vt,lc as ut,mc as qe,nc as Ee,tc as Zt,vc as en}from"./chunk-DPYTG6DM.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";var Ut=so,Wt=ro,ke=200;function Or(l,e){let t=new Set(e?.fields.map(n=>n.name)??[]),o=new Set(l.split(", "));for(let n of[he,Ee])t.has(n)&&o.add(n);return[...o].join(", ")}var Tr=10,vr=new Set([ce]),we="IsPersonAccount",Ze="IsStandard",et=class{maxConcurrent;constructor(e=10){this.maxConcurrent=e}async listObjects(e,t,o){let[n,r]=await Promise.all([e.describeGlobal(),t.describeGlobal()]),s=new Set(n.sobjects.filter(c=>c.createable).map(c=>c.name)),i=bt(r.sobjects.filter(c=>!s.has(c.name)),await this.toolingObjects(t)),a=new Map(r.sobjects.map(c=>[c.name,c.createable!==!1]));return n.sobjects.filter(c=>c.queryable&&(c.createable||a.get(c.name)===!0)).filter(c=>o||c.custom).filter(c=>!wt(c.name,i)).map(c=>({apiName:c.name,label:c.label,custom:c.custom,...a.has(c.name)?a.get(c.name)===!1?{notCreateableInTarget:!0}:{}:{missingInTarget:!0}}))}async countObjects(e,t){return this.countRecords(e,t)}async scan(e,t,o,n,r={}){let s=Gt(r.maxDepth,Ut),i=Gt(r.maxObjects,Wt),a=Gt(r.maxRecordsPerObject,5e4),c=r.onProgress??(()=>{});if(o.length===0)throw new Error("Choose the objects to copy: a scan starts from them, and with none chosen it would describe and count every object of the org.");let d=await e.describeGlobal(),m=[...o],u=await t.describeGlobal(),p=bt(u.sobjects,await this.toolingObjects(t)),g=A=>wt(A,p);m=m.filter(A=>!g(A)),c(`describing ${m.length} selected object(s)\u2026`);let y=await this.describeAll(e,m),f=new Set(y.keys()),R=new Map(d.sobjects.map(A=>[A.name,A.custom])),w=new Map;for(let A of d.sobjects)A.keyPrefix&&w.set(A.keyPrefix,A.name);let C=await this.walkRecords(e,y,f,{isStandard:A=>R.get(A)===!1||!R.has(A)&&!A.includes("__"),includeStandardObjects:n,leftOut:g,keyPrefixes:w,maxDepth:s,maxObjects:i,maxRecords:a,say:c}),v=new Set(u.sobjects.map(A=>A.name)),z=[...y.keys()].filter(A=>!v.has(A)),K=await this.currenciesOf(e,t,y),E=await this.personAccountsOf(e,y,f,C.parentIds,{cutShort:C.cutShort,cutAt:C.cutAt});return{objectDescribes:y,autoDiscoveredObjects:C.added,missingInTarget:z,recordCounts:C.recordCounts,totalObjectsScanned:y.size,parentIds:C.parentIds,personAccounts:E,scope:{maxDepth:s,maxObjects:i,selected:[...f],parents:C.added.map(A=>({objectApiName:A,records:C.parentIds.get(A)?.length??0})),leftEmpty:C.leftEmpty,standardNeeded:C.standardNeeded,...C.followedByDefault.length>0?{followedByDefault:C.followedByDefault}:{},...K?{currencies:K}:{},...C.cutShort.length>0?{cutShort:C.cutShort}:{}}}}async readFitRows(e,t,o=()=>{}){let n=new Set(t.objectDescribes.keys()),r=new Map;for(let s of t.scope.selected){let i=t.objectDescribes.get(s);if(!i)continue;o(`reading the lookups of ${s} to fit it\u2026`);let a=new Set(i.fields.map(u=>u.name)),c=tt(s,i).filter(u=>u.targets.some(p=>n.has(p))),d=["Id",...new Set(c.map(u=>u.field)),...(s===ce||s===fe)&&a.has(we)?[we]:[],...s===Ae&&a.has(Ze)?[Ze]:[]],m=await xn(`SELECT ${d.map(ye).join(", ")} FROM ${ye(s)} ORDER BY Id`,async u=>(await this.readAll(e,u)).records);r.set(s,m.filter(u=>typeof u.Id=="string"))}return r}async walkFrom(e,t,o,n=()=>{}){let r=new Map(t.objectDescribes),s=new Set(r.keys()),i=new Map;for(let[c,d]of r)d.keyPrefix&&i.set(d.keyPrefix,c);let a=await this.walkRecords(e,r,new Set(t.scope.selected),{isStandard:()=>!1,includeStandardObjects:!0,leftOut:c=>!s.has(c),keyPrefixes:i,maxDepth:t.scope.maxDepth,maxObjects:s.size,say:n},o);return{added:a.added,parentIds:a.parentIds,personAccounts:a.personAccounts,leftEmpty:a.leftEmpty,namingSelected:a.namingSelected}}async personAccountsOf(e,t,o,n,r){let s=new Map;for(let i of[ce,fe]){if(!t.get(i)?.fields.some(d=>d.name===we))continue;let c=`SELECT COUNT() FROM ${ye(i)} WHERE ${we} = true`;try{let d=r.cutShort.find(u=>u.objectApiName===i)?.copied;if(o.has(i)&&d!==void 0){let u=r.cutAt.get(i)??await this.lastIdOfTheFirst(e,i,d);s.set(i,u!==void 0?(await e.query(`${c} AND Id <= '${ge(u)}'`)).totalSize:Math.min((await e.query(c)).totalSize,d));continue}if(o.has(i)){s.set(i,(await e.query(c)).totalSize);continue}let m=0;for(let u of this.chunk([...n.get(i)??[]],ke)){let p=u.map(g=>`'${ge(g)}'`).join(", ");m+=(await e.query(`${c} AND Id IN (${p})`)).totalSize}s.set(i,m)}catch(d){ae.warn("Autopilot could not count the person accounts it copies",{objectApiName:i,error:ee(d)})}}return s}async lastIdOfTheFirst(e,t,o){let{records:n}=await this.readAll(e,`SELECT Id FROM ${ye(t)} ORDER BY Id`),r=n.length>=o?n[o-1]?.Id:void 0;return typeof r=="string"?r:void 0}async currenciesOf(e,t,o){let n=[...o.values()].filter(a=>a.fields.some(c=>c.name===he)).map(a=>a.name).sort();if(n.length===0)return;let r=await Me(async a=>(await e.query(a)).records,async a=>(await t.query(a)).records),s=r?.target.corporate;if(!r||s===void 0)return;let i=[...r.source.active].filter(a=>!r.target.active.has(a));return i.length>0?{notInTarget:i.sort(),writtenIn:s,objects:n}:void 0}async walkRecords(e,t,o,n,r){let s=new Set(o),i=new Set,a=n.maxRecords??5e4,c=n.maxObjects,d=n.maxObjects*io,m=new Map,u=[],p=[],g=[],y=new Map,f=[],R=new Map,w=new Map,C=new Map,v=[],z=T=>{let O=t.get(T);return O?tt(T,O).map(D=>({...D,targets:D.targets.filter(S=>!n.leftOut(S)&&!i.has(S))})).filter(D=>D.targets.length>0):[]},K=T=>["Id",...new Set(z(T).map(O=>O.field)),...r&&(T===ce||T===fe)&&t.get(T)?.fields.some(O=>O.name===we)?[we]:[]].map(ye).join(", "),E=(T,O,D)=>{let S=`${T.objectApiName}.${T.field}>${O}`;m.has(S)||m.set(S,{objectApiName:T.objectApiName,fieldApiName:T.field,target:O,reason:D,...T.required?{required:!0}:{}})},A=new Map,j=(T,O,D)=>{let S=z(T);for(let ne of O)for(let N of S){let _=ne[N.field];if(typeof _!="string"||_==="")continue;let V=Er(_,N.targets,n.keyPrefixes,r!==void 0&&N.polymorphic);if(!V)continue;if(o.has(V)){r&&D>0&&v.push({objectApiName:T,field:N.field,required:N.required,target:V,id:_});continue}let B={objectApiName:T,field:N.field,required:N.required};if(D>=n.maxDepth&&!N.required){s.has(V)||E(B,V,"depth");continue}if(w.get(V)?.has(_))continue;let Z=A.get(V)??{ids:new Set,required:!1,via:[]};Z.ids.add(_),Z.required||=N.required,Z.via.some(Y=>Y.objectApiName===T&&Y.field===N.field)||Z.via.push(B),A.set(V,Z)}},M=[];for(let T of o){if(r){j(T,r.get(T)??[],0);continue}let O=z(T).filter(D=>D.targets.some(S=>!o.has(S)));if(O.length===0){M.push(T);continue}n.say(`reading the lookups of ${T}\u2026`);try{let D=["Id",...new Set(O.map(N=>N.field))].map(ye).join(", "),{records:S,truncated:ne}=await this.readAll(e,`SELECT ${D} FROM ${ye(T)} ORDER BY Id`,a);if(R.set(T,S.length),ne){let N=(await this.countRecords(e,[T])).get(T);g.push({objectApiName:T,copied:S.length,...N!==void 0?{total:N}:{}});let _=S[S.length-1]?.Id;typeof _=="string"&&y.set(T,_)}j(T,S,0)}catch(D){ae.warn("Autopilot could not read the lookups of a selected object",{objectApiName:T,error:ee(D)}),M.push(T)}}for(let[T,O]of await this.countRecords(e,M))O>a?(R.set(T,a),g.push({objectApiName:T,copied:a,total:O})):R.set(T,O);let te=n.maxDepth+Tr;for(let T=1;A.size>0&&T<=te;T++){let O=A;A=new Map;let D=[];for(let[S,ne]of O){if(s.has(S))continue;let N=n.isStandard(S)&&!n.includeStandardObjects,_=N&&!ne.required&&vr.has(S),V;if(N&&!ne.required&&!_?V="standard":s.size>=c&&(ne.required&&c<d?c++:V="objects"),V){for(let B of ne.via)E(B,S,V);O.delete(S);continue}if(s.add(S),D.push(S),_)p.push({objectApiName:S,referencedBy:ne.via.map(B=>`${B.objectApiName}.${B.field}`)});else if(N){let B=ne.via[0];u.push({objectApiName:S,neededBy:`${B.objectApiName}.${B.field}`})}}if(D.length>0){let S=D.filter(N=>!t.has(N));S.length>0&&n.say(`describing ${S.length} parent object(s) at depth ${T}\u2026`);let ne=await this.describeAll(e,S);for(let N of D){let _=t.get(N)??ne.get(N);_?(t.set(N,_),f.push(N)):(s.delete(N),i.add(N),O.delete(N))}}for(let[S,ne]of O){let N=[...ne.ids].filter(Y=>!w.get(S)?.has(Y));if(N.length===0)continue;n.say(`reading ${N.length} ${S} record(s) by id\u2026`);let _=w.get(S)??new Set;w.set(S,_);let V=S===Oe,B=V?Or(K(S),t.get(S)):K(S),Z=[];for(let Y of this.chunk(N,ke)){let me=Y.map(x=>`'${ge(x)}'`).join(", "),b=(await e.query(`SELECT ${B} FROM ${ye(S)} WHERE Id IN (${me})`)).records.filter(x=>typeof x.Id=="string");for(let x of b)_.add(x.Id);Z.push(...b);let k=b.filter(x=>x[we]===!0).length;r&&k>0&&C.set(S,(C.get(S)??0)+k),j(S,b,T)}if(V){let Y=await this.standardPricesOf(e,B,Z,_);if(Y.length>0){n.say(`reading ${Y.length} standard price(s) the prices need\u2026`);for(let me of Y)_.add(me.Id);j(S,Y.map(me=>({...me,[_e]:void 0})),T)}}}}let se=new Map;for(let T of f){let O=[...w.get(T)??[]];se.set(T,O),R.set(T,O.length)}return{added:f,leftEmpty:[...m.values()].filter(T=>!s.has(T.target)),standardNeeded:u,followedByDefault:p.filter(T=>s.has(T.objectApiName)),cutShort:g,cutAt:y,recordCounts:R,parentIds:se,personAccounts:C,namingSelected:v}}async standardPricesOf(e,t,o,n){let r=s=>[s[qe],s[he],s[Ee]].map(i=>String(i??"")).join("|");try{let[s]=(await e.query(ve)).records,i=s?.Id;if(typeof i!="string")return[];let a=o.filter(u=>u[_e]!==i),c=[...new Set(a.flatMap(u=>{let p=u[qe];return typeof p=="string"&&p!==""?[p]:[]}))];if(c.length===0)return[];let d=new Set(a.map(r)),m=[];for(let u of this.chunk(c,ke)){let p=u.map(y=>`'${ge(y)}'`).join(", "),g=await e.query(`SELECT ${t} FROM ${Oe} WHERE ${_e} = '${ge(i)}' AND ${qe} IN (${p})`);for(let y of g.records){let f=y.Id;typeof f!="string"||n.has(f)||!d.has(r(y))||m.push(y)}}return m}catch(s){return ae.warn("Autopilot could not read the standard prices its prices need",{error:ee(s)}),[]}}async readAll(e,t,o=5e4){let{queryMore:n}=e;if(!n){let s=await e.query(t);return{records:s.records,truncated:s.done===!1}}let r=await He({query:s=>e.query(s),queryMore:s=>n.call(e,s)},t,o);return r.truncated&&ae.warn("Autopilot read the lookups of a selected object to its bound only",{records:r.records.length}),{records:r.records,truncated:r.truncated}}async toolingObjects(e){if(!e.tooling)return[];try{return(await e.tooling.describeGlobal()).sobjects.map(o=>o.name)}catch(t){return ae.warn("Autopilot could not ask the Tooling API which objects are metadata",{error:ee(t)}),[]}}async describeAll(e,t){let o=new Map,n=this.chunk(t,this.maxConcurrent);for(let r of n){let s=await Promise.allSettled(r.map(i=>e.describe(i)));for(let i of s)i.status==="fulfilled"&&o.set(i.value.name,i.value)}return o}async countRecords(e,t){let o=new Map,n=this.chunk(t,this.maxConcurrent);for(let r of n){let s=await Promise.allSettled(r.map(async i=>{let a=await e.query(`SELECT COUNT() FROM ${ye(i)}`);return{name:i,count:a.totalSize}}));for(let i of s)i.status==="fulfilled"&&o.set(i.value.name,i.value.count)}return o}chunk(e,t){let o=[];for(let n=0;n<e.length;n+=t)o.push(e.slice(n,n+t));return o}};function Gt(l,e){return l!==void 0&&Number.isInteger(l)&&l>0?l:e}function tt(l,e){return e.fields.filter(t=>t.referenceTo.length>0&&Jt(t)).map(t=>({field:t.name,targets:[...t.referenceTo],required:Xt(l,t.name,t.nillable),polymorphic:t.referenceTo.length>1}))}function Er(l,e,t,o=!1){if(e.length===1&&!o)return e[0];let n=t.get(l.slice(0,3));return n!==void 0&&e.includes(n)?n:void 0}var sr=3,Pr="the source changed since the plan: plan again";function dr(l,e){return{holds:[...l.links.filter(t=>t.kind==="holds"),...l.requiredOfParents,...l.outward.filter(t=>t.required)],kept:e}}function ir(l,e){return typeof l!="string"||l===""?!1:e===void 0||e!==null&&l.startsWith(e)}function lr(l,e,t){let o=new Map(t.map((s,i)=>[s,i])),n=new Set(e),r={links:[],outward:[],requiredOfParents:[]};for(let[s,i]of l)for(let a of tt(s,i))for(let c of a.targets.filter(d=>l.has(d))){let d=a.polymorphic?{prefix:l.get(c)?.keyPrefix??null}:{},m={objectApiName:s,field:a.field,parent:c,...d};if(!n.has(s))n.has(c)&&a.required&&r.requiredOfParents.push({...m,kind:"holds"});else if(!n.has(c))r.outward.push({...m,required:a.required});else if(a.required)r.links.push({...m,kind:"holds"});else if(c===s)r.links.push({...m,kind:"selfReference"});else{let u=(o.get(c)??0)<(o.get(s)??0);r.links.push({...m,kind:u?"holds":"owed"})}}return r}function ur(l,e){let t=new Set(l),o=new Set(e.links.filter(n=>n.kind!=="holds").map(n=>n.objectApiName));return(n,r)=>t.has(n)&&(r==="insert"||r==="update"&&(o.has(n)||Ce[n]!==void 0))}function pr(l,e,t){return typeof l.unread=="string"?{perRecord:[],notCounted:[],unread:l.unread}:Ro(ze(l,e,t),t)}function Cr(l){let e=new Map(l.order.map((t,o)=>[t,o]));return l.order.map(t=>{let o=l.rows.get(t)??[],n=l.lookups.links.filter(i=>i.objectApiName===t),r=l.lookups.outward.filter(i=>i.objectApiName===t),s={name:t,rows:o,at:new Map(o.map((i,a)=>[i.Id,a])),heldBefore:[],heldAfter:[],loose:[],named:[],roots:[],followers:[],persons:new Set(t===ce||t===fe?o.flatMap((i,a)=>i[we]===!0?[a]:[]):[])};return o.forEach((i,a)=>{let c=[],d=[],m=[];for(let u of n){let p=i[u.field];if(!ir(p,u.prefix))continue;let g={link:u,id:p};u.kind!=="holds"?m.push(g):(e.get(u.parent)??0)<(e.get(t)??0)?c.push(g):d.push(g)}s.heldBefore.push(c),s.heldAfter.push(d),s.loose.push(m),s.named.push(r.flatMap(u=>{let p=i[u.field];return ir(p,u.prefix)?[{parent:u.parent,id:p}]:[]})),(c.length>0?s.followers:s.roots).push(a)}),s})}function ar(l,e){let t=new Map(l.map(r=>[r.name,r])),o=new Map,n=[...e].flatMap(([r,s])=>[...s].map(i=>({name:r,id:i})));for(let r=n.pop();r;r=n.pop()){let s=t.get(r.name),i=s?.at.get(r.id);if(!s||i===void 0)continue;let a=o.get(r.name)??new Set;if(o.set(r.name,a),!a.has(i)){a.add(i);for(let c of[...s.heldBefore[i],...s.heldAfter[i]])n.push({name:c.link.parent,id:c.id})}}return o}function cr(l){return`${l} record${l===1?"":"s"}`}function Mr(l,e){return[...l.parentIds].every(([t,o])=>{let n=new Set(e.get(t)?.ids??[]);return o.every(r=>n.has(r))})}async function fr(l){let{budget:e,room:t,mode:o,parents:n,maxRecords:r}=l,s=Cr(l),i=b=>{let k=o.caps?.[b]??o.all;return k===void 0?void 0:Math.max(1,Math.floor(k))},a=s.some(b=>b.heldAfter.some(k=>k.length>0)),c=new Map;for(let b of s){if(b.name!==Ae)continue;let k=b.rows.filter(x=>x[Ze]===!0);k.length>0&&c.set(b.name,new Set(k.map(x=>x.Id)))}let d=ar(s,c),m=b=>{let k={kept:new Map,ids:new Map,cut:new Map},x=new Set;for(let $ of s){let L=d.get($.name)??x,X=i($.name),F=$.roots.filter(J=>!L.has(J)),G=F.length===0?0:Math.max(1,Math.round(b*Math.min(F.length,X??1/0))),W=It(F.length,G).map(J=>F[J]),q=new Map;for(let J of $.followers){if(L.has(J))continue;let be=$.heldBefore[J].find(Se=>!k.ids.get(Se.link.parent)?.has(Se.id));be?q.set(J,be.link):W.push(J)}W.sort((J,be)=>J-be);let ie=$.name===fe?W.filter(J=>$.persons.has(J)):[],U=ie.length>0?W.filter(J=>!$.persons.has(J)):W,re=X===void 0?U.length:Math.max(0,X-L.size-ie.length),le=U.length>re?It(U.length,re).map(J=>U[J]):U,ue=new Set([...L,...ie,...le]);k.kept.set($.name,ue),k.ids.set($.name,new Set([...ue].map(J=>$.rows[J].Id))),k.cut.set($.name,q)}if(!a)return k;for(let $=!0;$;){$=!1;for(let L of s){let X=d.get(L.name)??x,F=k.kept.get(L.name)??new Set;for(let G of[...F]){if(X.has(G))continue;let W=[...L.heldAfter[G],...L.heldBefore[G]].find(q=>!k.ids.get(q.link.parent)?.has(q.id));W&&(F.delete(G),k.ids.get(L.name)?.delete(L.rows[G].Id),k.cut.get(L.name)?.set(G,W.link),$=!0)}}}return k},u=b=>{let k=new Map;for(let x of s){let $=0;for(let L of b.kept.get(x.name)??[])x.loose[L].some(F=>b.ids.get(F.link.parent)?.has(F.id))&&$++;$>0&&k.set(x.name,$)}return k},p=(b,k)=>{let x=new Map,$=0;for(let F of s){let G=b.kept.get(F.name)??new Set,W=0;for(let q of G)F.persons.has(q)&&W++;x.set(F.name,G.size),$+=Et(F.name,{rows:G.size,personAccounts:W})}for(let[F,{records:G,personAccounts:W}]of k)x.set(F,(x.get(F)??0)+G),$+=Et(F,{rows:G,...W!==void 0?{personAccounts:W}:{}});let L=u(b),X=So(t,(F,G)=>{let W=x.get(F)??0;return G==="insert"||Ce[F]!==void 0?W:L.get(F)??0});return{records:[...x.values()].reduce((F,G)=>F+G,0),bytes:$,roomBytes:X,requests:uo([...x.values()].map(F=>({rows:F})))}},g=new Map;for(let b of s)for(let k of b.named)for(let{parent:x,id:$}of k){let L=g.get(x)??new Set;g.set(x,L),L.add($)}let y=[...g.values()].reduce((b,k)=>b+k.size,0),f=b=>{let k=new Map,x=0;for(let X of s)for(let F of b.kept.get(X.name)??[])for(let{parent:G,id:W}of X.named[F]){let q=k.get(G)??new Set;k.set(G,q),q.has(W)||x++,q.add(W)}let $=y>0?x/y:0,L=new Map;for(let[X,{ids:F,personAccounts:G}]of n){let W=Math.max(0,F.length-(g.get(X)?.size??0)),q=Math.min(F.length,(k.get(X)?.size??0)+Math.ceil(W*$));q!==0&&L.set(X,{records:q,...G!==void 0?{personAccounts:Math.ceil(G*q/F.length)}:{}})}return L},R=b=>new Map(b.added.map(k=>{let x=b.personAccounts.get(k);return[k,{records:b.parentIds.get(k)?.length??0,...x!==void 0?{personAccounts:x}:{}}]})),w=b=>b.bytes+b.roomBytes<=e.bytes,C=b=>e.runRequests===void 0||b.requests<=e.runRequests,v=b=>r===void 0||b.records<=r,z=b=>w(b)&&C(b)&&v(b),K=b=>w(b)?C(b)?"maxTotal":"apiRequests":e.terms.limitedBy,E=b=>w(b)?C(b)?{bound:"maxTotal",records:b.records,allowed:r??0}:{bound:"apiRequests",requests:b.requests,allowed:e.runRequests??0}:{bound:"storage",takesMB:(b.bytes+b.roomBytes)/1048576,fitsMB:e.bytes/1048576},A=b=>{if(!w(b)){let k=wo((b.bytes+b.roomBytes)/1048576,e.bytes/1048576);return`${k.over} MB`+(b.roomBytes>0?", room for what the org's automation creates under them included":"")+`, past the ${k.bound} MB that fit`}return C(b)?`${cr(b.records)}, past the ${r??0} the run may write`:`about ${b.requests} API requests, past the ${e.runRequests??0} that leave the org a tenth of its daily requests`},j=b=>new Map(s.map(k=>[k.name,[...b.kept.get(k.name)??[]].sort((x,$)=>x-$).map(x=>k.rows[x])])),M=(b,k,x,$,L,X)=>{let F=s.map(q=>{let ie=k.cut.get(q.name)??new Map,U=new Map;for(let le of ie.values()){let ue=`${le.field}
|
|
7
|
+
import{c as rr}from"./chunk-32EUNQT6.mjs";import"./chunk-T7WREYA5.mjs";import"./chunk-H4JUYUSL.mjs";import"./chunk-C2N2TNEU.mjs";import"./chunk-YAJQS3OL.mjs";import"./chunk-Z42PHCVZ.mjs";import"./chunk-DT3T7FRD.mjs";import"./chunk-ZUBBEP75.mjs";import"./chunk-XO5FBOQF.mjs";import"./chunk-KP5G6FUC.mjs";import"./chunk-7EYQYZJP.mjs";import"./chunk-H4OBZIX3.mjs";import"./chunk-V3R45ZWT.mjs";import"./chunk-XSKPYGMT.mjs";import"./chunk-6GQUZ4IP.mjs";import{q as zt}from"./chunk-LAUOSXMN.mjs";import"./chunk-INIQ23K6.mjs";import"./chunk-2UU42PTD.mjs";import{b as rn}from"./chunk-2JZGCCPG.mjs";import{a as vo,b as Eo,c as Po,d as Wo,e as Ho,f as Lt,g as Dt,h as $t,i as Ve,j as Ko,k as xe,l as Fe}from"./chunk-G2JR3F63.mjs";import"./chunk-3CX7GPCR.mjs";import"./chunk-A65ADTCR.mjs";import"./chunk-NWOI25WY.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-A7JJWOLT.mjs";import"./chunk-ZXFL2MSN.mjs";import"./chunk-VYOYXTCU.mjs";import"./chunk-C3LNYAVJ.mjs";import"./chunk-GJ6SZVHT.mjs";import"./chunk-52EXDVPN.mjs";import"./chunk-GMY5427L.mjs";import{Wa as qt,a as Co,d as Bt,e as Qo,f as Xo,g as Jo,h as Vo,i as Zo,j as er,k as _t,l as tr,m as nr,q as je}from"./chunk-3HEMJTAP.mjs";import{a as Io}from"./chunk-BN33LVPQ.mjs";import"./chunk-JKT5YAQ2.mjs";import"./chunk-QAPVKPEC.mjs";import{a as Yo}from"./chunk-BNKT3R3F.mjs";import"./chunk-QROPNEGY.mjs";import{b as mt,e as sn}from"./chunk-BZ24IAP5.mjs";import{a as ct}from"./chunk-SCKUIE3R.mjs";import{c as cn,d as dn,f as ln}from"./chunk-6FARZYMJ.mjs";import"./chunk-WB2RIVO3.mjs";import"./chunk-MUEQRIK7.mjs";import"./chunk-ISSP2FZ5.mjs";import"./chunk-XU25YA46.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-BOGNK4LV.mjs";import{b as un,c as pn,d as Ue,e as fn,f as Ao,g as ko,h as Ro,i as So,j as Oo,k as To,l as It}from"./chunk-P55MKIZX.mjs";import{h as zo,i as Go,k as Uo}from"./chunk-PYRZFUVU.mjs";import"./chunk-O2PUGRNW.mjs";import"./chunk-7SDZR6SR.mjs";import{h as Mo,i as Do,j as $o,k as Bo,l as Nt,m as _o,n as qo}from"./chunk-TEIBWMJM.mjs";import{a as xo,b as xt,c as Ft,d as Fo,e as jo,f as No,g as Lo,h as jt}from"./chunk-BWWQXU2B.mjs";import{d as Yn}from"./chunk-T63U4OZJ.mjs";import{e as ro,f as so,g as io}from"./chunk-YAIIRFKJ.mjs";import"./chunk-Q3DY7TO2.mjs";import"./chunk-3XG25GTF.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-M6P5ZZLE.mjs";import{o as to,p as no,q as Tt,r as oo,s as Xe}from"./chunk-WSUKC2U3.mjs";import{d as Kn}from"./chunk-QIRO4HTE.mjs";import"./chunk-3SKLBRPL.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-JH27IKCO.mjs";import"./chunk-SAMWHL22.mjs";import"./chunk-6KP6WETK.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-J24TIGSI.mjs";import{a as Vn,b as Ot,f as Ie,g as Zn,h as eo,j as Qe}from"./chunk-HKUWHVI7.mjs";import"./chunk-VPDEJGPS.mjs";import"./chunk-5LFSFYFJ.mjs";import{b as ft,c as Ge}from"./chunk-LHU6CPGE.mjs";import"./chunk-PBE44M2Y.mjs";import{a as pt,b as nn}from"./chunk-ZUOPC4W2.mjs";import{b as Qn,c as Xn,g as Jn}from"./chunk-JQZTMFO7.mjs";import{$a as lo,Ac as bo,Bc as Mt,Ma as ao,Pb as mo,Ra as Et,_a as co,ac as ho,bb as uo,bc as go,fb as Pt,fc as yo,hb as Je,ib as po,lb as fo,mc as Te,nc as wo,zb as Ct}from"./chunk-JFNLKHY6.mjs";import{q as vt}from"./chunk-VZVICK7Q.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-VV3B6IC3.mjs";import{a as ae}from"./chunk-4TLYUZD5.mjs";import"./chunk-7PY3VQP3.mjs";import{i as xn}from"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-HFUDCNU5.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-XZISAZA6.mjs";import{b as on,d as an,f as ht,h as or}from"./chunk-LCDPCUXS.mjs";import"./chunk-TQ2TQHTT.mjs";import{a as qn,b as At,c as kt,f as zn,h as Gn,j as Ke,l as Un,m as Wn}from"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import{a as He}from"./chunk-EADHKH3A.mjs";import{b as wt,d as bt,e as In}from"./chunk-L4INJ5TZ.mjs";import{$ as vn,Y as Sn,Z as On,_ as Tn,a as mn,b as oe,c as We,d as hn,da as Ce,f as gn,fa as En,g as yn,ia as Pn,ja as Cn,ka as Mn,m as gt,n as wn,o as bn,p as An,q as ce,r as fe,s as yt,t as Pe,u as kn,z as Rn}from"./chunk-KIMQQ6JQ.mjs";import{a as ge,h as ye}from"./chunk-TZE3Y7IQ.mjs";import{b as ee}from"./chunk-CA5NAXSU.mjs";import{b as Ye,c as Rt,j as St,k as Hn}from"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import{a as he,j as Me,l as Fn,o as jn,p as Nn,q as Ln,t as Dn,u as $n,v as Bn,w as _n}from"./chunk-ICIYL45C.mjs";import"./chunk-PR74GYVI.mjs";import"./chunk-TMA34QMA.mjs";import"./chunk-TUACWKIH.mjs";import{Fc as Zt,Hc as en,Td as ze,Xc as tn,Y as dt,ic as lt,lc as Qt,mc as Xt,nc as Jt,rc as Oe,sc as Ae,tc as _e,uc as ve,vc as Vt,xc as ut,yc as qe,zc as Ee}from"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";var Ut=so,Wt=ro,ke=200;function Or(l,e){let t=new Set(e?.fields.map(n=>n.name)??[]),o=new Set(l.split(", "));for(let n of[he,Ee])t.has(n)&&o.add(n);return[...o].join(", ")}var Tr=10,vr=new Set([ce]),we="IsPersonAccount",Ze="IsStandard",et=class{maxConcurrent;constructor(e=10){this.maxConcurrent=e}async listObjects(e,t,o){let[n,r]=await Promise.all([e.describeGlobal(),t.describeGlobal()]),s=new Set(n.sobjects.filter(c=>c.createable).map(c=>c.name)),i=bt(r.sobjects.filter(c=>!s.has(c.name)),await this.toolingObjects(t)),a=new Map(r.sobjects.map(c=>[c.name,c.createable!==!1]));return n.sobjects.filter(c=>c.queryable&&(c.createable||a.get(c.name)===!0)).filter(c=>o||c.custom).filter(c=>!wt(c.name,i)).map(c=>({apiName:c.name,label:c.label,custom:c.custom,...a.has(c.name)?a.get(c.name)===!1?{notCreateableInTarget:!0}:{}:{missingInTarget:!0}}))}async countObjects(e,t){return this.countRecords(e,t)}async scan(e,t,o,n,r={}){let s=Gt(r.maxDepth,Ut),i=Gt(r.maxObjects,Wt),a=Gt(r.maxRecordsPerObject,5e4),c=r.onProgress??(()=>{});if(o.length===0)throw new Error("Choose the objects to copy: a scan starts from them, and with none chosen it would describe and count every object of the org.");let d=await e.describeGlobal(),m=[...o],u=await t.describeGlobal(),p=bt(u.sobjects,await this.toolingObjects(t)),g=A=>wt(A,p);m=m.filter(A=>!g(A)),c(`describing ${m.length} selected object(s)\u2026`);let y=await this.describeAll(e,m),f=new Set(y.keys()),R=new Map(d.sobjects.map(A=>[A.name,A.custom])),w=new Map;for(let A of d.sobjects)A.keyPrefix&&w.set(A.keyPrefix,A.name);let C=await this.walkRecords(e,y,f,{isStandard:A=>R.get(A)===!1||!R.has(A)&&!A.includes("__"),includeStandardObjects:n,leftOut:g,keyPrefixes:w,maxDepth:s,maxObjects:i,maxRecords:a,say:c}),v=new Set(u.sobjects.map(A=>A.name)),z=[...y.keys()].filter(A=>!v.has(A)),K=await this.currenciesOf(e,t,y),E=await this.personAccountsOf(e,y,f,C.parentIds,{cutShort:C.cutShort,cutAt:C.cutAt});return{objectDescribes:y,autoDiscoveredObjects:C.added,missingInTarget:z,recordCounts:C.recordCounts,totalObjectsScanned:y.size,parentIds:C.parentIds,personAccounts:E,scope:{maxDepth:s,maxObjects:i,selected:[...f],parents:C.added.map(A=>({objectApiName:A,records:C.parentIds.get(A)?.length??0})),leftEmpty:C.leftEmpty,standardNeeded:C.standardNeeded,...C.followedByDefault.length>0?{followedByDefault:C.followedByDefault}:{},...K?{currencies:K}:{},...C.cutShort.length>0?{cutShort:C.cutShort}:{}}}}async readFitRows(e,t,o=()=>{}){let n=new Set(t.objectDescribes.keys()),r=new Map;for(let s of t.scope.selected){let i=t.objectDescribes.get(s);if(!i)continue;o(`reading the lookups of ${s} to fit it\u2026`);let a=new Set(i.fields.map(u=>u.name)),c=tt(s,i).filter(u=>u.targets.some(p=>n.has(p))),d=["Id",...new Set(c.map(u=>u.field)),...(s===ce||s===fe)&&a.has(we)?[we]:[],...s===Ae&&a.has(Ze)?[Ze]:[]],m=await xn(`SELECT ${d.map(ye).join(", ")} FROM ${ye(s)} ORDER BY Id`,async u=>(await this.readAll(e,u)).records);r.set(s,m.filter(u=>typeof u.Id=="string"))}return r}async walkFrom(e,t,o,n=()=>{}){let r=new Map(t.objectDescribes),s=new Set(r.keys()),i=new Map;for(let[c,d]of r)d.keyPrefix&&i.set(d.keyPrefix,c);let a=await this.walkRecords(e,r,new Set(t.scope.selected),{isStandard:()=>!1,includeStandardObjects:!0,leftOut:c=>!s.has(c),keyPrefixes:i,maxDepth:t.scope.maxDepth,maxObjects:s.size,say:n},o);return{added:a.added,parentIds:a.parentIds,personAccounts:a.personAccounts,leftEmpty:a.leftEmpty,namingSelected:a.namingSelected}}async personAccountsOf(e,t,o,n,r){let s=new Map;for(let i of[ce,fe]){if(!t.get(i)?.fields.some(d=>d.name===we))continue;let c=`SELECT COUNT() FROM ${ye(i)} WHERE ${we} = true`;try{let d=r.cutShort.find(u=>u.objectApiName===i)?.copied;if(o.has(i)&&d!==void 0){let u=r.cutAt.get(i)??await this.lastIdOfTheFirst(e,i,d);s.set(i,u!==void 0?(await e.query(`${c} AND Id <= '${ge(u)}'`)).totalSize:Math.min((await e.query(c)).totalSize,d));continue}if(o.has(i)){s.set(i,(await e.query(c)).totalSize);continue}let m=0;for(let u of this.chunk([...n.get(i)??[]],ke)){let p=u.map(g=>`'${ge(g)}'`).join(", ");m+=(await e.query(`${c} AND Id IN (${p})`)).totalSize}s.set(i,m)}catch(d){ae.warn("Autopilot could not count the person accounts it copies",{objectApiName:i,error:ee(d)})}}return s}async lastIdOfTheFirst(e,t,o){let{records:n}=await this.readAll(e,`SELECT Id FROM ${ye(t)} ORDER BY Id`),r=n.length>=o?n[o-1]?.Id:void 0;return typeof r=="string"?r:void 0}async currenciesOf(e,t,o){let n=[...o.values()].filter(a=>a.fields.some(c=>c.name===he)).map(a=>a.name).sort();if(n.length===0)return;let r=await Me(async a=>(await e.query(a)).records,async a=>(await t.query(a)).records),s=r?.target.corporate;if(!r||s===void 0)return;let i=[...r.source.active].filter(a=>!r.target.active.has(a));return i.length>0?{notInTarget:i.sort(),writtenIn:s,objects:n}:void 0}async walkRecords(e,t,o,n,r){let s=new Set(o),i=new Set,a=n.maxRecords??5e4,c=n.maxObjects,d=n.maxObjects*io,m=new Map,u=[],p=[],g=[],y=new Map,f=[],R=new Map,w=new Map,C=new Map,v=[],z=T=>{let O=t.get(T);return O?tt(T,O).map(D=>({...D,targets:D.targets.filter(S=>!n.leftOut(S)&&!i.has(S))})).filter(D=>D.targets.length>0):[]},K=T=>["Id",...new Set(z(T).map(O=>O.field)),...r&&(T===ce||T===fe)&&t.get(T)?.fields.some(O=>O.name===we)?[we]:[]].map(ye).join(", "),E=(T,O,D)=>{let S=`${T.objectApiName}.${T.field}>${O}`;m.has(S)||m.set(S,{objectApiName:T.objectApiName,fieldApiName:T.field,target:O,reason:D,...T.required?{required:!0}:{}})},A=new Map,j=(T,O,D)=>{let S=z(T);for(let ne of O)for(let N of S){let _=ne[N.field];if(typeof _!="string"||_==="")continue;let V=Er(_,N.targets,n.keyPrefixes,r!==void 0&&N.polymorphic);if(!V)continue;if(o.has(V)){r&&D>0&&v.push({objectApiName:T,field:N.field,required:N.required,target:V,id:_});continue}let B={objectApiName:T,field:N.field,required:N.required};if(D>=n.maxDepth&&!N.required){s.has(V)||E(B,V,"depth");continue}if(w.get(V)?.has(_))continue;let Z=A.get(V)??{ids:new Set,required:!1,via:[]};Z.ids.add(_),Z.required||=N.required,Z.via.some(Y=>Y.objectApiName===T&&Y.field===N.field)||Z.via.push(B),A.set(V,Z)}},M=[];for(let T of o){if(r){j(T,r.get(T)??[],0);continue}let O=z(T).filter(D=>D.targets.some(S=>!o.has(S)));if(O.length===0){M.push(T);continue}n.say(`reading the lookups of ${T}\u2026`);try{let D=["Id",...new Set(O.map(N=>N.field))].map(ye).join(", "),{records:S,truncated:ne}=await this.readAll(e,`SELECT ${D} FROM ${ye(T)} ORDER BY Id`,a);if(R.set(T,S.length),ne){let N=(await this.countRecords(e,[T])).get(T);g.push({objectApiName:T,copied:S.length,...N!==void 0?{total:N}:{}});let _=S[S.length-1]?.Id;typeof _=="string"&&y.set(T,_)}j(T,S,0)}catch(D){ae.warn("Autopilot could not read the lookups of a selected object",{objectApiName:T,error:ee(D)}),M.push(T)}}for(let[T,O]of await this.countRecords(e,M))O>a?(R.set(T,a),g.push({objectApiName:T,copied:a,total:O})):R.set(T,O);let te=n.maxDepth+Tr;for(let T=1;A.size>0&&T<=te;T++){let O=A;A=new Map;let D=[];for(let[S,ne]of O){if(s.has(S))continue;let N=n.isStandard(S)&&!n.includeStandardObjects,_=N&&!ne.required&&vr.has(S),V;if(N&&!ne.required&&!_?V="standard":s.size>=c&&(ne.required&&c<d?c++:V="objects"),V){for(let B of ne.via)E(B,S,V);O.delete(S);continue}if(s.add(S),D.push(S),_)p.push({objectApiName:S,referencedBy:ne.via.map(B=>`${B.objectApiName}.${B.field}`)});else if(N){let B=ne.via[0];u.push({objectApiName:S,neededBy:`${B.objectApiName}.${B.field}`})}}if(D.length>0){let S=D.filter(N=>!t.has(N));S.length>0&&n.say(`describing ${S.length} parent object(s) at depth ${T}\u2026`);let ne=await this.describeAll(e,S);for(let N of D){let _=t.get(N)??ne.get(N);_?(t.set(N,_),f.push(N)):(s.delete(N),i.add(N),O.delete(N))}}for(let[S,ne]of O){let N=[...ne.ids].filter(Y=>!w.get(S)?.has(Y));if(N.length===0)continue;n.say(`reading ${N.length} ${S} record(s) by id\u2026`);let _=w.get(S)??new Set;w.set(S,_);let V=S===Oe,B=V?Or(K(S),t.get(S)):K(S),Z=[];for(let Y of this.chunk(N,ke)){let me=Y.map(x=>`'${ge(x)}'`).join(", "),b=(await e.query(`SELECT ${B} FROM ${ye(S)} WHERE Id IN (${me})`)).records.filter(x=>typeof x.Id=="string");for(let x of b)_.add(x.Id);Z.push(...b);let k=b.filter(x=>x[we]===!0).length;r&&k>0&&C.set(S,(C.get(S)??0)+k),j(S,b,T)}if(V){let Y=await this.standardPricesOf(e,B,Z,_);if(Y.length>0){n.say(`reading ${Y.length} standard price(s) the prices need\u2026`);for(let me of Y)_.add(me.Id);j(S,Y.map(me=>({...me,[_e]:void 0})),T)}}}}let se=new Map;for(let T of f){let O=[...w.get(T)??[]];se.set(T,O),R.set(T,O.length)}return{added:f,leftEmpty:[...m.values()].filter(T=>!s.has(T.target)),standardNeeded:u,followedByDefault:p.filter(T=>s.has(T.objectApiName)),cutShort:g,cutAt:y,recordCounts:R,parentIds:se,personAccounts:C,namingSelected:v}}async standardPricesOf(e,t,o,n){let r=s=>[s[qe],s[he],s[Ee]].map(i=>String(i??"")).join("|");try{let[s]=(await e.query(ve)).records,i=s?.Id;if(typeof i!="string")return[];let a=o.filter(u=>u[_e]!==i),c=[...new Set(a.flatMap(u=>{let p=u[qe];return typeof p=="string"&&p!==""?[p]:[]}))];if(c.length===0)return[];let d=new Set(a.map(r)),m=[];for(let u of this.chunk(c,ke)){let p=u.map(y=>`'${ge(y)}'`).join(", "),g=await e.query(`SELECT ${t} FROM ${Oe} WHERE ${_e} = '${ge(i)}' AND ${qe} IN (${p})`);for(let y of g.records){let f=y.Id;typeof f!="string"||n.has(f)||!d.has(r(y))||m.push(y)}}return m}catch(s){return ae.warn("Autopilot could not read the standard prices its prices need",{error:ee(s)}),[]}}async readAll(e,t,o=5e4){let{queryMore:n}=e;if(!n){let s=await e.query(t);return{records:s.records,truncated:s.done===!1}}let r=await He({query:s=>e.query(s),queryMore:s=>n.call(e,s)},t,o);return r.truncated&&ae.warn("Autopilot read the lookups of a selected object to its bound only",{records:r.records.length}),{records:r.records,truncated:r.truncated}}async toolingObjects(e){if(!e.tooling)return[];try{return(await e.tooling.describeGlobal()).sobjects.map(o=>o.name)}catch(t){return ae.warn("Autopilot could not ask the Tooling API which objects are metadata",{error:ee(t)}),[]}}async describeAll(e,t){let o=new Map,n=this.chunk(t,this.maxConcurrent);for(let r of n){let s=await Promise.allSettled(r.map(i=>e.describe(i)));for(let i of s)i.status==="fulfilled"&&o.set(i.value.name,i.value)}return o}async countRecords(e,t){let o=new Map,n=this.chunk(t,this.maxConcurrent);for(let r of n){let s=await Promise.allSettled(r.map(async i=>{let a=await e.query(`SELECT COUNT() FROM ${ye(i)}`);return{name:i,count:a.totalSize}}));for(let i of s)i.status==="fulfilled"&&o.set(i.value.name,i.value.count)}return o}chunk(e,t){let o=[];for(let n=0;n<e.length;n+=t)o.push(e.slice(n,n+t));return o}};function Gt(l,e){return l!==void 0&&Number.isInteger(l)&&l>0?l:e}function tt(l,e){return e.fields.filter(t=>t.referenceTo.length>0&&Jt(t)).map(t=>({field:t.name,targets:[...t.referenceTo],required:Xt(l,t.name,t.nillable),polymorphic:t.referenceTo.length>1}))}function Er(l,e,t,o=!1){if(e.length===1&&!o)return e[0];let n=t.get(l.slice(0,3));return n!==void 0&&e.includes(n)?n:void 0}var sr=3,Pr="the source changed since the plan: plan again";function dr(l,e){return{holds:[...l.links.filter(t=>t.kind==="holds"),...l.requiredOfParents,...l.outward.filter(t=>t.required)],kept:e}}function ir(l,e){return typeof l!="string"||l===""?!1:e===void 0||e!==null&&l.startsWith(e)}function lr(l,e,t){let o=new Map(t.map((s,i)=>[s,i])),n=new Set(e),r={links:[],outward:[],requiredOfParents:[]};for(let[s,i]of l)for(let a of tt(s,i))for(let c of a.targets.filter(d=>l.has(d))){let d=a.polymorphic?{prefix:l.get(c)?.keyPrefix??null}:{},m={objectApiName:s,field:a.field,parent:c,...d};if(!n.has(s))n.has(c)&&a.required&&r.requiredOfParents.push({...m,kind:"holds"});else if(!n.has(c))r.outward.push({...m,required:a.required});else if(a.required)r.links.push({...m,kind:"holds"});else if(c===s)r.links.push({...m,kind:"selfReference"});else{let u=(o.get(c)??0)<(o.get(s)??0);r.links.push({...m,kind:u?"holds":"owed"})}}return r}function ur(l,e){let t=new Set(l),o=new Set(e.links.filter(n=>n.kind!=="holds").map(n=>n.objectApiName));return(n,r)=>t.has(n)&&(r==="insert"||r==="update"&&(o.has(n)||Ce[n]!==void 0))}function pr(l,e,t){return typeof l.unread=="string"?{perRecord:[],notCounted:[],unread:l.unread}:Ro(ze(l,e,t),t)}function Cr(l){let e=new Map(l.order.map((t,o)=>[t,o]));return l.order.map(t=>{let o=l.rows.get(t)??[],n=l.lookups.links.filter(i=>i.objectApiName===t),r=l.lookups.outward.filter(i=>i.objectApiName===t),s={name:t,rows:o,at:new Map(o.map((i,a)=>[i.Id,a])),heldBefore:[],heldAfter:[],loose:[],named:[],roots:[],followers:[],persons:new Set(t===ce||t===fe?o.flatMap((i,a)=>i[we]===!0?[a]:[]):[])};return o.forEach((i,a)=>{let c=[],d=[],m=[];for(let u of n){let p=i[u.field];if(!ir(p,u.prefix))continue;let g={link:u,id:p};u.kind!=="holds"?m.push(g):(e.get(u.parent)??0)<(e.get(t)??0)?c.push(g):d.push(g)}s.heldBefore.push(c),s.heldAfter.push(d),s.loose.push(m),s.named.push(r.flatMap(u=>{let p=i[u.field];return ir(p,u.prefix)?[{parent:u.parent,id:p}]:[]})),(c.length>0?s.followers:s.roots).push(a)}),s})}function ar(l,e){let t=new Map(l.map(r=>[r.name,r])),o=new Map,n=[...e].flatMap(([r,s])=>[...s].map(i=>({name:r,id:i})));for(let r=n.pop();r;r=n.pop()){let s=t.get(r.name),i=s?.at.get(r.id);if(!s||i===void 0)continue;let a=o.get(r.name)??new Set;if(o.set(r.name,a),!a.has(i)){a.add(i);for(let c of[...s.heldBefore[i],...s.heldAfter[i]])n.push({name:c.link.parent,id:c.id})}}return o}function cr(l){return`${l} record${l===1?"":"s"}`}function Mr(l,e){return[...l.parentIds].every(([t,o])=>{let n=new Set(e.get(t)?.ids??[]);return o.every(r=>n.has(r))})}async function fr(l){let{budget:e,room:t,mode:o,parents:n,maxRecords:r}=l,s=Cr(l),i=b=>{let k=o.caps?.[b]??o.all;return k===void 0?void 0:Math.max(1,Math.floor(k))},a=s.some(b=>b.heldAfter.some(k=>k.length>0)),c=new Map;for(let b of s){if(b.name!==Ae)continue;let k=b.rows.filter(x=>x[Ze]===!0);k.length>0&&c.set(b.name,new Set(k.map(x=>x.Id)))}let d=ar(s,c),m=b=>{let k={kept:new Map,ids:new Map,cut:new Map},x=new Set;for(let $ of s){let L=d.get($.name)??x,X=i($.name),F=$.roots.filter(J=>!L.has(J)),G=F.length===0?0:Math.max(1,Math.round(b*Math.min(F.length,X??1/0))),W=It(F.length,G).map(J=>F[J]),q=new Map;for(let J of $.followers){if(L.has(J))continue;let be=$.heldBefore[J].find(Se=>!k.ids.get(Se.link.parent)?.has(Se.id));be?q.set(J,be.link):W.push(J)}W.sort((J,be)=>J-be);let ie=$.name===fe?W.filter(J=>$.persons.has(J)):[],U=ie.length>0?W.filter(J=>!$.persons.has(J)):W,re=X===void 0?U.length:Math.max(0,X-L.size-ie.length),le=U.length>re?It(U.length,re).map(J=>U[J]):U,ue=new Set([...L,...ie,...le]);k.kept.set($.name,ue),k.ids.set($.name,new Set([...ue].map(J=>$.rows[J].Id))),k.cut.set($.name,q)}if(!a)return k;for(let $=!0;$;){$=!1;for(let L of s){let X=d.get(L.name)??x,F=k.kept.get(L.name)??new Set;for(let G of[...F]){if(X.has(G))continue;let W=[...L.heldAfter[G],...L.heldBefore[G]].find(q=>!k.ids.get(q.link.parent)?.has(q.id));W&&(F.delete(G),k.ids.get(L.name)?.delete(L.rows[G].Id),k.cut.get(L.name)?.set(G,W.link),$=!0)}}}return k},u=b=>{let k=new Map;for(let x of s){let $=0;for(let L of b.kept.get(x.name)??[])x.loose[L].some(F=>b.ids.get(F.link.parent)?.has(F.id))&&$++;$>0&&k.set(x.name,$)}return k},p=(b,k)=>{let x=new Map,$=0;for(let F of s){let G=b.kept.get(F.name)??new Set,W=0;for(let q of G)F.persons.has(q)&&W++;x.set(F.name,G.size),$+=Et(F.name,{rows:G.size,personAccounts:W})}for(let[F,{records:G,personAccounts:W}]of k)x.set(F,(x.get(F)??0)+G),$+=Et(F,{rows:G,...W!==void 0?{personAccounts:W}:{}});let L=u(b),X=So(t,(F,G)=>{let W=x.get(F)??0;return G==="insert"||Ce[F]!==void 0?W:L.get(F)??0});return{records:[...x.values()].reduce((F,G)=>F+G,0),bytes:$,roomBytes:X,requests:uo([...x.values()].map(F=>({rows:F})))}},g=new Map;for(let b of s)for(let k of b.named)for(let{parent:x,id:$}of k){let L=g.get(x)??new Set;g.set(x,L),L.add($)}let y=[...g.values()].reduce((b,k)=>b+k.size,0),f=b=>{let k=new Map,x=0;for(let X of s)for(let F of b.kept.get(X.name)??[])for(let{parent:G,id:W}of X.named[F]){let q=k.get(G)??new Set;k.set(G,q),q.has(W)||x++,q.add(W)}let $=y>0?x/y:0,L=new Map;for(let[X,{ids:F,personAccounts:G}]of n){let W=Math.max(0,F.length-(g.get(X)?.size??0)),q=Math.min(F.length,(k.get(X)?.size??0)+Math.ceil(W*$));q!==0&&L.set(X,{records:q,...G!==void 0?{personAccounts:Math.ceil(G*q/F.length)}:{}})}return L},R=b=>new Map(b.added.map(k=>{let x=b.personAccounts.get(k);return[k,{records:b.parentIds.get(k)?.length??0,...x!==void 0?{personAccounts:x}:{}}]})),w=b=>b.bytes+b.roomBytes<=e.bytes,C=b=>e.runRequests===void 0||b.requests<=e.runRequests,v=b=>r===void 0||b.records<=r,z=b=>w(b)&&C(b)&&v(b),K=b=>w(b)?C(b)?"maxTotal":"apiRequests":e.terms.limitedBy,E=b=>w(b)?C(b)?{bound:"maxTotal",records:b.records,allowed:r??0}:{bound:"apiRequests",requests:b.requests,allowed:e.runRequests??0}:{bound:"storage",takesMB:(b.bytes+b.roomBytes)/1048576,fitsMB:e.bytes/1048576},A=b=>{if(!w(b)){let k=wo((b.bytes+b.roomBytes)/1048576,e.bytes/1048576);return`${k.over} MB`+(b.roomBytes>0?", room for what the org's automation creates under them included":"")+`, past the ${k.bound} MB that fit`}return C(b)?`${cr(b.records)}, past the ${r??0} the run may write`:`about ${b.requests} API requests, past the ${e.runRequests??0} that leave the org a tenth of its daily requests`},j=b=>new Map(s.map(k=>[k.name,[...b.kept.get(k.name)??[]].sort((x,$)=>x-$).map(x=>k.rows[x])])),M=(b,k,x,$,L,X)=>{let F=s.map(q=>{let ie=k.cut.get(q.name)??new Map,U=new Map;for(let le of ie.values()){let ue=`${le.field}
|
|
8
8
|
${le.parent}`,J=U.get(ue)??{field:le.field,parent:le.parent,count:0};U.set(ue,{...J,count:J.count+1})}let re=k.kept.get(q.name)?.size??0;return{objectApiName:q.name,inSource:q.rows.length,kept:re,cutSpread:q.rows.length-re-ie.size,cutWithParent:[...U.values()].sort((le,ue)=>ue.count-le.count)}}),G=new Map,W=(q,ie,U)=>{let re=`${q}
|
|
9
9
|
${ie}
|
|
10
10
|
${U}`,le=(G.get(re)?.count??0)+1;G.set(re,{objectApiName:q,field:ie,count:le,why:U})};for(let q of s)for(let ie of k.kept.get(q.name)??[])for(let U of q.loose[ie])k.ids.get(U.link.parent)?.has(U.id)||W(q.name,U.link.field,U.link.kind==="owed"?"owed":"selfReference");for(let q of L?.namingSelected??[])q.required||k.ids.get(q.target)?.has(q.id)||W(q.objectApiName,q.field,"onParent");return{heldBy:$,...X?{cannotFit:X.words}:{},kept:j(k),...L?{walk:L}:{},report:{mode:o,heldBy:$,...X?{cannotFit:X.said}:{},budget:{...Oo(e,x.roomBytes,t),...$==="apiRequests"?{limitedBy:"apiRequests"}:{}},...b!==void 0?{share:b}:{},objects:F,emptied:[...G.values()],parents:L?L.added.map(q=>({objectApiName:q,records:L.parentIds.get(q)?.length??0})):[...n].map(([q,{ids:ie}])=>({objectApiName:q,records:ie.length})),records:x.records,estimateMB:x.bytes/1048576}}},te={words:Pr,said:{why:"sourceChanged"}},se=b=>({words:`with these caps the plan takes ${A(b)}: lower them, or fit by share`,said:{why:"caps",over:E(b)}}),T=Object.keys(o.caps??{}).find(b=>!s.some(k=>k.name===b)),O=s.reduce((b,k)=>Math.max(b,Math.min(k.roots.length,i(k.name)??1/0)),0),D=m(1),S=p(D,f(D));if(T!==void 0)return M(void 0,D,S,"caps",void 0,{words:`the plan selects no ${T}: a cap holds an object it selects`,said:{why:"capNotSelected",object:T}});if(s.some(b=>b.rows.length>(l.planned.get(b.name)??0)))return M(void 0,D,S,e.terms.limitedBy,void 0,te);let ne=o.all!==void 0||Object.keys(o.caps??{}).length>0,N=o.share===!0||!ne,_=b=>{let k=m(b/O);return p(k,f(k))};if(s.every(b=>D.kept.get(b.name)?.size===b.rows.length)&&z(S))return M(N?1:void 0,D,S,"whole",void 0);if(O===0)return M(void 0,D,S,e.terms.limitedBy,void 0,te);let B=O;if(!z(S)){if(!N)return M(void 0,D,S,K(S),void 0,se(S));if(B=To(O,b=>z(_(b))),B===0){let b=m(1/O),k=p(b,f(b));return M(1/O,b,k,K(k),void 0,{words:`the least it can be cut to \u2014 one record of each object with none to follow, and what follows them, ${cr(k.records)} \u2014 takes ${A(k)}`,said:{why:"least",over:E(k)}})}}let Z=B<O?K(_(B+1)):ne?"caps":e.terms.limitedBy,Y=b=>N?b/O:void 0;if(n.size===0){let b=m(B/O);return M(Y(B),b,p(b,new Map),Z,void 0)}for(let b=1;b<=sr;b++){let k=m(B/O),x=await l.walk(j(k));if(!Mr(x,n)){let F=p(k,R(x));return M(Y(B),k,F,Z,void 0,te)}let $=x.namingSelected.filter(F=>F.required&&s.find(G=>G.name===F.target)?.at.has(F.id)===!0&&!k.ids.get(F.target)?.has(F.id));if($.length>0){for(let{target:F,id:G}of $){let W=c.get(F)??new Set;c.set(F,W),W.add(G)}d=ar(s,c);continue}let L=p(k,R(x));if(z(L))return M(Y(B),k,L,Z,x);if(Z=K(L),!N)return M(void 0,k,L,Z,x,se(L));if(B===1)return M(Y(B),k,L,Z,x,{words:"the least it can be cut to, with the parents its records name, takes "+A(L),said:{why:"least",over:E(L)}});let X=Math.max((L.bytes+L.roomBytes)/Math.max(1,e.bytes),e.runRequests!==void 0?L.requests/Math.max(1,e.runRequests):0,r!==void 0?L.records/Math.max(1,r):0);B=Math.max(1,Math.min(B-1,Math.floor(B/X)))}let me=m(B/O),Be=p(me,f(me));return M(Y(B),me,Be,Z,void 0,{words:`could not fit in ${sr} rounds: fit by caps`,said:{why:"rounds"}})}function mr(l,e,t){let{selected:o}=l.scope,n=e.walk?.added??[],r=new Set([...o,...n]),s=new Map(e.walk?.parentIds??[]),i=new Map,a=new Map;for(let f of o){let R=e.kept.get(f)??[];s.set(f,R.map(w=>w.Id)),i.set(f,R.length),l.personAccounts.has(f)&&a.set(f,R.filter(w=>w[we]===!0).length)}for(let f of n)i.set(f,e.walk?.parentIds.get(f)?.length??0),l.personAccounts.has(f)&&a.set(f,e.walk?.personAccounts.get(f)??0);let c=new Map([...l.scope.leftEmpty,...e.walk?.leftEmpty??[]].filter(f=>r.has(f.objectApiName)&&!r.has(f.target)).map(f=>[`${f.objectApiName}.${f.fieldApiName}>${f.target}`,f])),{maxDepth:d,maxObjects:m,followedByDefault:u,currencies:p}=l.scope,g=u?.filter(f=>r.has(f.objectApiName)),y=p?.objects.filter(f=>r.has(f));return{...l,objectDescribes:new Map([...l.objectDescribes].filter(([f])=>r.has(f))),autoDiscoveredObjects:n,missingInTarget:l.missingInTarget.filter(f=>r.has(f)),recordCounts:i,totalObjectsScanned:r.size,parentIds:s,personAccounts:a,scope:{maxDepth:d,maxObjects:m,selected:o,parents:n.map(f=>({objectApiName:f,records:i.get(f)??0})),leftEmpty:[...c.values()],standardNeeded:l.scope.standardNeeded.filter(f=>r.has(f.objectApiName)),...g!==void 0&&g.length>0?{followedByDefault:g}:{},...p&&y!==void 0&&y.length>0?{currencies:{...p,objects:y}}:{},fitted:t}}}var nt=class{deps;eventListeners=[];runningExecutors=[];pendingSkips=new Set;constructor(e){this.deps=e}onEvent(e){return this.eventListeners.push(e),()=>{this.eventListeners=this.eventListeners.filter(t=>t!==e)}}emitEvent(e){for(let t of this.eventListeners)try{t(e)}catch{}}listObjects(e,t,o){return this.deps.schemaScanner.listObjects(e,t,o)}countObjects(e,t){return this.deps.schemaScanner.countObjects(e,t)}async scanSchemas(e,t,o,n){this.emitEvent({type:"scan-started",timestamp:new Date().toISOString()});let r=await this.deps.schemaScanner.scan(e,t,o.selectedObjects,o.includeStandardObjects,{...o.maxDepth!==void 0?{maxDepth:o.maxDepth}:{},...o.maxObjects!==void 0?{maxObjects:o.maxObjects}:{},...o.maxRecordsPerObject!==void 0&&o.maxRecordsPerObject>0?{maxRecordsPerObject:o.maxRecordsPerObject}:{},...n?{onProgress:n}:{}});return this.emitEvent({type:"scan-completed",timestamp:new Date().toISOString()}),r}buildGraph(e,t){let o=new Map;for(let[n,r]of e.objectDescribes){let s=r.fields.map(i=>({name:i.name,type:i.type,nillable:i.nillable,referenceTo:i.referenceTo,relationshipName:i.relationshipName}));o.set(n,{name:r.name,fields:s})}return this.deps.graphBuilder.build(o,e.recordCounts,t)}buildCompliance(e,t,o=[]){let n=this.deps.complianceEngine.buildProfile(e,Eo(o,t)),r=this.deps.complianceEngine.generateRules(n);return{profile:n,rules:r}}generatePlan(e,t,o,n){let r=Po(t,e.nodes.map(c=>c.objectApiName),o),s={...this.deps.complianceEngine.buildSummary(o),...r.length>0?{notCovered:r}:{}},i=this.deps.planGenerator.generate(e,t,s),a=n?{...i,scope:n}:i;return this.emitEvent({type:"plan-generated",timestamp:new Date().toISOString()}),a}async fitPlan(e,t){let{scan:o,graph:n,plan:r,rules:s,mode:i,budget:a,maxRecords:c,onProgress:d}=t,{schemaScanner:m}=this.deps,u=0,p={describe:O=>e.describe(O),describeGlobal:()=>e.describeGlobal(),query:O=>(u++,e.query(O)),...e.queryMore?{queryMore:O=>(u++,e.queryMore.call(e,O))}:{}},g=r.waves.map(O=>O.objects),y=new Map,f=g.flatMap(O=>Ue(O,n.edges).groups.filter(D=>D.length>1));for(let O of new Set(f.flat()))y.set(O,await t.describeLookups?.(O).catch(()=>null)??null);let R=fn(g,n.edges,O=>y.get(O)),{selected:w}=o.scope,C=lr(o.objectDescribes,w,R),v=ur(R,C),z=pr(t.automation,t.mutePlan,v),K=await m.readFitRows(p,o,d),E=await fr({order:R.filter(O=>w.includes(O)),rows:K,planned:o.recordCounts,lookups:C,parents:new Map(o.scope.parents.map(({objectApiName:O})=>{let D=o.personAccounts.get(O);return[O,{ids:o.parentIds.get(O)??[],...D!==void 0?{personAccounts:D}:{}}]})),budget:a,room:z,mode:i,...c!==void 0?{maxRecords:c}:{},walk:O=>m.walkFrom(p,o,O,d)}),A=z.unread!==void 0?{automationUnread:z.unread}:{},j={...E.report,requestsRead:u,...A,...t.mutePlan?{countedMuted:!0}:{},...c!==void 0?{maxTotal:c}:{}},M=new Map([...E.kept].map(([O,D])=>[O,D.map(S=>S.Id)])),te={heldBy:E.heldBy,report:j,keptIds:M,...A};if(E.cannotFit!==void 0)return{...te,cannotFit:E.cannotFit};if(E.heldBy==="whole")return te;let se=mr(o,E,j),T=this.buildGraph(se,t.batchSize);return{...te,fitted:{scan:se,graph:T,plan:this.generatePlan(T,r.complianceFramework,s,se.scope),run:dr(C,se.parentIds)}}}async executePlan(e,t,o,n,r,s,i,a){let c=Array.from(n.values()).reduce((R,w)=>R+w,0),d=this.isGrappeActive(c),m=`autopilot-${Date.now()}`;d&&this.deps.onGrappeEvent?.({type:"grappe:started",payload:{operationId:m,totalPartitions:e.waves.length,totalRecords:c}}),this.emitEvent({type:"execution-started",timestamp:new Date().toISOString()});let u=this.deps.createExecutor(),p=()=>{},g=r?u.on("node-completed",r):p,y=r?u.on("node-failed",r):p;for(let R of this.pendingSkips)u.skip(R);this.pendingSkips.clear(),this.runningExecutors.push(u);let f;try{f=await u.execute(e,t.edges,o,n,s,i,a)}finally{this.runningExecutors.splice(this.runningExecutors.indexOf(u),1),g(),y()}return this.emitEvent({type:"execution-completed",timestamp:new Date().toISOString()}),d&&this.deps.onGrappeEvent?.({type:"grappe:completed",payload:{operationId:m,totalProcessed:f.totalSuccess+f.totalSkipped,totalFailed:f.totalFailure}}),f}isGrappeActive(e){let t=this.deps.grappeConfig;return!!(t?.enabled&&this.deps.grappeAdapter&&e>=t.autoActivateThreshold)}generateReport(e,t,o,n,r,s){return this.deps.complianceEngine.generateReport(e,t,o,n,r,s)}latestRunningExecutor(){return this.runningExecutors[this.runningExecutors.length-1]}pause(){this.latestRunningExecutor()?.pause()}resume(){this.latestRunningExecutor()?.resume()}skip(e){let t=this.latestRunningExecutor();if(t){t.skip(e);return}this.pendingSkips.add(e)}};var ot=class{build(e,t,o=200){let n=this.extractEdges(e),r=Ir(n,new Set(e.keys())),s=this.tarjanSCC(Array.from(e.keys()),r),i=this.resolveCycles(s,r),{order:a,levels:c}=this.topologicalSort(Array.from(e.keys()),r,s),d=this.buildNodes(e,t,a,c,o),m=this.computeStats(d,n,i);return{nodes:d,edges:n,cycles:i,stats:m}}extractEdges(e){let t=[],o=new Set(e.keys());for(let[n,r]of e)for(let s of r.fields){if(s.type!=="reference"||s.referenceTo.length===0)continue;let i=s.referenceTo.filter(d=>o.has(d));if(i.length===0)continue;if(i.length>1){for(let d of i)t.push({from:d,to:n,fieldApiName:s.name,relationshipType:"polymorphic",required:!s.nillable});continue}let a=i[0],c;a===n?c="hierarchical":s.nillable?c="lookup":c="master_detail",t.push({from:a,to:n,fieldApiName:s.name,relationshipType:c,required:!s.nillable})}return t}tarjanSCC(e,t){let o=new Map;for(let s of e)o.set(s,[]);for(let s of t){let i=o.get(s.to);i&&i.push(s.from)}let n={index:0,stack:[],onStack:new Set,indices:new Map,lowLinks:new Map,sccs:[]},r=[...e].sort();for(let s of r)n.indices.has(s)||this.tarjanStrongConnect(s,o,n);return n.sccs}tarjanStrongConnect(e,t,o){o.indices.set(e,o.index),o.lowLinks.set(e,o.index),o.index++,o.stack.push(e),o.onStack.add(e);let n=t.get(e)??[];for(let r of n)if(o.indices.has(r)){if(o.onStack.has(r)){let s=o.lowLinks.get(e)??0,i=o.indices.get(r)??0;o.lowLinks.set(e,Math.min(s,i))}}else{this.tarjanStrongConnect(r,t,o);let s=o.lowLinks.get(e)??0,i=o.lowLinks.get(r)??0;o.lowLinks.set(e,Math.min(s,i))}if(o.lowLinks.get(e)===o.indices.get(e)){let r=[],s;do s=o.stack.pop(),o.onStack.delete(s),r.push(s);while(s!==e);o.sccs.push(r.sort())}}resolveCycles(e,t){let o=[],n=new Set;for(let r of t)r.from===r.to&&r.relationshipType==="hierarchical"&&n.add(r.from);for(let r of n)o.push({objects:[r],strategy:"two_pass",description:`Insert ${r} without self-lookup, update in 2nd pass`});for(let r of e){if(r.length<=1)continue;let s=new Set(r),i=t.filter(d=>s.has(d.from)&&s.has(d.to)&&d.from!==d.to),a,c;r.length===2&&i.some(m=>!m.required)?(a="nullable_lookup",c=`Insert ${r[0]} without ${r[1]} lookup, insert ${r[1]} with ${r[0]} lookup, update ${r[0]}`):(a="upsert_external_id",c="Decompose cycle into waves with upsert + external ID"),o.push({objects:[...r],strategy:a,description:c})}return o}topologicalSort(e,t,o){let n=new Map;for(let p=0;p<o.length;p++)for(let g of o[p])n.set(g,p);let r=o.length,s=new Map;for(let p=0;p<r;p++)s.set(p,new Set);for(let p of t){let g=n.get(p.from),y=n.get(p.to);g!==void 0&&y!==void 0&&g!==y&&s.get(y).add(g)}let i=new Map;for(let[p,g]of s)i.set(p,new Set(g));let a=[],c=new Map;for(;i.size>0;){let p=[];for(let[g,y]of i)y.size===0&&p.push(g);if(p.length===0){for(let g of i.keys())a.push(g),c.has(g)||c.set(g,0);break}p.sort((g,y)=>g-y);for(let g of p){a.push(g);let y=s.get(g)??new Set,f=-1;for(let R of y)f=Math.max(f,c.get(R)??0);c.set(g,y.size===0?0:f+1),i.delete(g);for(let R of i.values())R.delete(g)}}let d=new Map,m=new Map,u=0;for(let p of a){let g=o[p],y=c.get(p)??0,f=[...g].sort();for(let R of f)d.set(R,u),m.set(R,y),u++}for(let p of e)d.has(p)||(d.set(p,u),m.set(p,0),u++);return{order:d,levels:m}}buildNodes(e,t,o,n,r){let s=[];for(let i of e.keys()){let a=t.get(i)??0;s.push({objectApiName:i,recordCount:a,estimatedApiCalls:a===0?0:Math.ceil(a/r),piiFields:[],anonymizationRules:[],status:"pending",progress:0,insertOrder:o.get(i)??0,level:n.get(i)??0,successCount:0,failureCount:0,errors:[],elapsedMs:0,apiCallsUsed:0})}return s.sort((i,a)=>i.insertOrder-a.insertOrder),s}computeStats(e,t,o){return{totalObjects:e.length,totalRelationships:t.length,cycleCount:o.length,maxDepth:Math.max(0,...e.map(n=>n.level)),totalRecords:e.reduce((n,r)=>n+r.recordCount,0),totalEstimatedApiCalls:e.reduce((n,r)=>n+r.estimatedApiCalls,0)}}};function Ir(l,e){let t=wn(e);return t.length===0?[...l]:[...l.filter(o=>!(o.to===oe&&o.fieldApiName==="ActivityId")),...t.map(o=>({from:o.sourceObject,to:o.targetObject,fieldApiName:o.relationshipName,relationshipType:"lookup",required:!0}))]}import{createHash as xr,randomUUID as Fr}from"node:crypto";var jr=["fake","mask","hash","nullify","redact","shuffle","truncate","preserve_format","age_band","generalize"],rt=class{builtInRules;constructor(){this.builtInRules=new Map,this.builtInRules.set("gdpr",this.buildGDPRRules()),this.builtInRules.set("ccpa",this.buildCCPARules()),this.builtInRules.set("hipaa",this.buildHIPAARules()),this.builtInRules.set("pci_dss",this.buildPCIDSSRules())}buildProfile(e,t,o=[]){let n=this.builtInRules.get(e)??[];return{framework:e,rules:n,autoDetectedPII:t,userOverrides:o,auditRequired:e!=="none"&&e!=="custom"}}generateRules(e){if(e.framework==="none")return[];let t=new Map;for(let n of e.userOverrides){let r=`${n.objectApiName}.${n.fieldApiName}`;t.set(r,n)}let o=[];for(let n of e.autoDetectedPII){let r=`${n.objectApiName}.${n.fieldApiName}`,s=t.get(r);if(s){if(s.method==="skip")continue;o.push({objectApiName:n.objectApiName,fieldApiName:n.fieldApiName,method:s.method,piiCategory:n.piiCategory,aiConfidence:n.confidence,userOverridden:!0,fieldType:n.fieldType});continue}let i=this.findMatchingRule(e.rules,n.piiCategory),a=i&&i.requiredMethod!=="any"?i.requiredMethod:n.suggestedMethod;o.push({objectApiName:n.objectApiName,fieldApiName:n.fieldApiName,method:a,piiCategory:n.piiCategory,aiConfidence:n.confidence,userOverridden:!1,fieldType:n.fieldType})}return o}buildSummary(e){let t={};for(let n of jr)t[n]=0;for(let n of e)t[n.method]++;let o=[...new Set(e.map(n=>n.objectApiName))];return{totalPiiFields:e.length,totalFieldsToAnonymize:e.length,methodBreakdown:t,objectsWithPii:o}}generateReport(e,t,o,n,r,s){let i=new Set(e.userOverrides.map(y=>`${y.objectApiName}.${y.fieldApiName}`)),a=t.map(y=>{let f=this.findMatchingRule(e.rules,y.piiCategory),R=f?f.id:"custom",w=o.get(y.objectApiName)??0,C=`${y.objectApiName}.${y.fieldApiName}`;return{objectApiName:y.objectApiName,fieldApiName:y.fieldApiName,piiCategory:y.piiCategory,anonymizationMethod:y.method,recordsAnonymized:w,ruleApplied:R,userOverridden:i.has(C)||y.userOverridden}}),c=this.buildObjectSummaries(t,o,e),d=this.computeOverallStatus(c),m=new Date().toISOString(),u=Fr(),p=JSON.stringify(a),g=xr("sha256").update(p).digest("hex");return{id:u,framework:e.framework,generatedAt:m,sourceOrgId:n,targetOrgId:r,totalFieldsScanned:s,piiFieldsDetected:e.autoDetectedPII.length,piiFieldsAnonymized:t.length,entries:a,objectSummaries:c,overallStatus:d,checksumSha256:g}}findMatchingRule(e,t){return e.find(o=>o.targetPiiCategories.includes(t))}buildObjectSummaries(e,t,o){let n=new Set;for(let s of e)n.add(s.objectApiName);for(let s of o.autoDetectedPII)n.add(s.objectApiName);let r=[];for(let s of n){let i=e.filter(p=>p.objectApiName===s),a=o.autoDetectedPII.filter(p=>p.objectApiName===s),c=[...new Set(i.map(p=>p.method))],d=t.get(s)??0,m=a.length>0&&a.every(p=>i.some(g=>g.fieldApiName===p.fieldApiName)),u=a.length===0||m?"pass":i.length>0?"partial":"fail";r.push({objectApiName:s,recordCount:d,piiFieldCount:a.length,anonymizationMethods:c,status:u})}return r}computeOverallStatus(e){return e.length===0||e.every(n=>n.status==="pass")?"pass":e.every(n=>n.status==="fail")?"fail":"partial"}buildGDPRRules(){return[{id:"gdpr-01",framework:"gdpr",category:"data_minimization",description:"Anonymize personal identifiers (name, email, phone, address)",targetPiiCategories:["PII"],requiredMethod:"fake",articleReference:"GDPR Art. 25"},{id:"gdpr-02",framework:"gdpr",category:"data_protection",description:"Hash sensitive identifiers for pseudonymization",targetPiiCategories:["SENSITIVE"],requiredMethod:"hash",articleReference:"GDPR Art. 32"},{id:"gdpr-03",framework:"gdpr",category:"health_data",description:"Nullify health-related data",targetPiiCategories:["PHI"],requiredMethod:"nullify",articleReference:"GDPR Art. 9"},{id:"gdpr-04",framework:"gdpr",category:"financial_data",description:"Mask payment card data",targetPiiCategories:["PCI"],requiredMethod:"mask",articleReference:"GDPR Art. 32"}]}buildCCPARules(){return[{id:"ccpa-01",framework:"ccpa",category:"personal_info",description:"Anonymize personal information (name, email, phone)",targetPiiCategories:["PII"],requiredMethod:"fake"},{id:"ccpa-02",framework:"ccpa",category:"commercial_info",description:"Mask commercial and financial data",targetPiiCategories:["PCI","SENSITIVE"],requiredMethod:"mask"},{id:"ccpa-03",framework:"ccpa",category:"biometric",description:"Nullify biometric and health data",targetPiiCategories:["PHI"],requiredMethod:"nullify"}]}buildHIPAARules(){return[{id:"hipaa-01",framework:"hipaa",category:"safe_harbor",description:"Anonymize patient identifiers (name, address, phone)",targetPiiCategories:["PII","PHI"],requiredMethod:"fake",articleReference:"HIPAA Safe Harbor \xA7164.514(b)"},{id:"hipaa-02",framework:"hipaa",category:"safe_harbor_dates",description:"Generalize dates to year only",targetPiiCategories:["SENSITIVE"],requiredMethod:"age_band",articleReference:"HIPAA Safe Harbor \xA7164.514(b)"},{id:"hipaa-03",framework:"hipaa",category:"safe_harbor_ids",description:"Hash medical record numbers and SSNs",targetPiiCategories:["PHI"],requiredMethod:"hash",articleReference:"HIPAA Safe Harbor \xA7164.514(b)"}]}buildPCIDSSRules(){return[{id:"pci-01",framework:"pci_dss",category:"card_data",description:"Mask PAN to show only last 4 digits",targetPiiCategories:["PCI"],requiredMethod:"mask",articleReference:"PCI-DSS Requirement 3.3"},{id:"pci-02",framework:"pci_dss",category:"auth_data",description:"Nullify CVV, expiration, and magnetic strip data",targetPiiCategories:["PCI"],requiredMethod:"nullify",articleReference:"PCI-DSS Requirement 3.2"},{id:"pci-03",framework:"pci_dss",category:"cardholder",description:"Anonymize cardholder personal data",targetPiiCategories:["PII"],requiredMethod:"fake",articleReference:"PCI-DSS Requirement 3.4"}]}};var st=class{avgSecondsPerApiCall;batchSize;constructor(e){this.avgSecondsPerApiCall=e?.avgSecondsPerApiCall??.5,this.batchSize=e?.batchSize??200}getBatchSize(){return this.batchSize}generate(e,t,o){let n=this.buildWaves(e),r=e.stats.totalRecords,s=e.stats.totalEstimatedApiCalls,i=this.estimateDuration(n,e);return{waves:n,totalRecords:r,estimatedDurationSec:i,estimatedApiCalls:s,complianceFramework:t,anonymizationSummary:o,cycleResolutions:e.cycles}}buildWaves(e){if(e.nodes.length===0)return[];let t=[...e.nodes].sort((i,a)=>i.insertOrder-a.insertOrder),o=new Map;for(let i of t){let a=o.get(i.level);a?a.push(i.objectApiName):o.set(i.level,[i.objectApiName])}let n=[...o.keys()].sort((i,a)=>i-a),r=new Map;for(let i=0;i<n.length;i++){let a=n[i],c=o.get(a);if(c)for(let d of c)r.set(d,i)}let s=[];for(let i=0;i<n.length;i++){let a=n[i],c=o.get(a)??[],d=new Set;for(let u of c)for(let p of e.edges)if(p.to===u){let g=r.get(p.from);g!==void 0&&g<i&&d.add(g)}let m=[...d].sort((u,p)=>u-p);s.push({order:i,objects:c,dependsOn:m})}return s}estimateDuration(e,t){let o=new Map;for(let s of t.nodes)o.set(s.objectApiName,s.estimatedApiCalls);let n=new Map;t.cycles.forEach((s,i)=>{for(let a of s.objects)n.set(a,i)});let r=0;for(let s of e){let i=new Map;for(let a of s.objects){let c=n.get(a),d=c===void 0?`object:${a}`:`cycle:${c}`;i.set(d,(i.get(d)??0)+(o.get(a)??0))}r+=Math.max(0,...i.values())*this.avgSecondsPerApiCall}return r}};var De=class{idMaps=new Map;registerMappings(e,t){let o=this.idMaps.get(e);o||(o=new Map,this.idMaps.set(e,o));for(let[n,r]of t)o.set(n,r)}remapRecords(e,t,o){let n=t.filter(c=>c.to===o),r=0,s=0,i=0,a=[];for(let[c,d]of e.entries()){let m=new Set,u=new Map;for(let p of n){let g=d[p.fieldApiName];if(g==null||g===""){i++;continue}if(typeof g!="string"){i++;continue}let f=this.idMaps.get(p.from)?.get(g);if(f!==void 0)d[p.fieldApiName]=f,m.add(p.fieldApiName),r++;else{let R=u.get(p.fieldApiName);R?R.parents.push(p.from):u.set(p.fieldApiName,{sourceId:g,parents:[p.from]}),s++}}for(let[p,{sourceId:g,parents:y}]of u)m.has(p)||(d[p]=null,a.push({index:c,fieldApiName:p,sourceId:g,parents:y}))}return{remapped:r,missing:s,skipped:i,unresolved:a}}getTargetId(e,t){return this.idMaps.get(e)?.get(t)}hasObject(e){return this.idMaps.has(e)}getMappingCount(e){return this.idMaps.get(e)?.size??0}get totalMappings(){let e=0;for(let t of this.idMaps.values())e+=t.size;return e}clear(){this.idMaps.clear()}};var Nr=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function Ar(l,e,t){let o=en(l);if(e!==void 0&&!Nr.test(e))throw new Error(`Not a record id to read after: "${e}".`);let n=e===void 0?"":` WHERE Id > '${e}'`;return`SELECT FIELDS(ALL) FROM ${o}${n} ORDER BY Id LIMIT ${Math.trunc(t)}`}var Lr={statusCode:Ye,message:"No result returned for the record",fields:[]},Dr={statusCode:Ye,message:"Refused without a reason",fields:[]},hr="PARENT_REFUSED",gr="PARENT_NOT_WRITTEN",Yt="CUT_WITH_PARENT",yr={skipped:l=>`${l} was skipped in this run`,failed:l=>`the run's write of ${l} failed`},$r="PERSON_ACCOUNT_NOT_WRITTEN",Br="PERSON_CONTACT_NOT_LOOKED_UP",_r=`SELECT Id FROM RecordType WHERE SobjectType = '${ce}' AND IsPersonType = true`;function de(l){return l.slice(0,15)}var Re=class{byReason=new Map;add(e){let t=new Set;for(let o of e){let n=`${o.statusCode}\0${o.fields.join(",")}`;if(t.has(n))continue;t.add(n);let r=this.byReason.get(n);this.byReason.set(n,r?{...r,count:r.count+1}:{statusCode:o.statusCode,fields:[...o.fields],count:1,message:o.message})}}addCounted(e){let t=`${e.statusCode}\0${e.fields.join(",")}`,o=this.byReason.get(t);this.byReason.set(t,o?{...o,count:o.count+e.count}:e)}list(){return[...this.byReason.values()].sort((e,t)=>t.count-e.count)}};function qr(l,e){let[t,...o]=l.errors,[n,...r]=l.errorDetails??[];return{...l,...t===void 0?{}:{errors:[Tt(t,e),...o]},...n===void 0?{}:{errorDetails:[{...n,message:Tt(n.message,e)},...r]}}}function wr(){return{written:0,linked:0,failed:0,errors:[],refusals:new Re,apiCallsUsed:0,defaulted:new Map,cutSinceFit:0,heldForRecordType:new Map,sentAgainForALock:{rows:0,written:0,stillLocked:0}}}function zr(l){return{statusCode:qn,fields:["RecordTypeId"],count:l.recordCount,message:Un(l)}}function Gr(l,e){return{objectApiName:l,rows:e.rows,why:{...e.why},...e.predicted?{predicted:e.predicted}:{},...e.readBack?{readBack:e.readBack}:{}}}function br(l){let e=0;for(let[t,o]of l)Ft(t)&&(e+=o);return e}function Ur(l){let e=new Map;for(let t of l.holds)e.set(t.objectApiName,[...e.get(t.objectApiName)??[],t]);return{holds:e,kept:new Map([...l.kept].map(([t,o])=>[t,new Set(o.map(de))])),stayedOut:new Map}}var $e=class extends Co{deps;batchSize;paused=!1;pausePromise=null;pauseResolve=null;skippedObjects=new Set;signal;contactPoints;creatableByObject=new Map;currencies;currencyChanges=new Bn;pricesSettled=new Map;currencyChangesByWrittenId=new Map;keyPrefixByObject=new Map;lifecycleByObject=new Map;standardPricebook;deferredStatuses=[];lookupsByObject=new Map;recordTypeMappings;targetRecordTypes=[];planned=new Set;parentIds=new Map;owedLookups=[];unmappedRecordTypes=new Set;leftToThePlatform=new gn;taskOfEmail=new Map;emailsAfterTheirTask=[];taskTurnOver=!1;emailsHeldAndNotSent=0;leftByStop=new Map;lookupsLeftEmpty=new Map;refusedRecords=new Map;notWritten=new Map;reached=new Set;personTypes;personContactsLinked=0;recordTypesGiven=new Map;recordTypesUnderTheLease=new Map;givenRules=new Map;lease;fit;async creatableFieldsOf(e){if(!this.deps.describeCreateableFields)return null;let t=this.creatableByObject.get(e);if(t!==void 0)return t;try{let o=await this.deps.describeCreateableFields(e),n=o.size>0?o:null;return this.creatableByObject.set(e,n),n}catch{return this.creatableByObject.set(e,null),null}}lookupsOf(e){let t=this.deps.describeLookups;if(!t)return Promise.resolve(null);let o=this.lookupsByObject.get(e);return o||(o=t(e).catch(()=>null),this.lookupsByObject.set(e,o)),o}keyPrefixOf(e){let t=this.deps.describeKeyPrefix;if(!t)return Promise.resolve(void 0);let o=this.keyPrefixByObject.get(e);return o||(o=t(e).catch(()=>{}),this.keyPrefixByObject.set(e,o)),o}constructor(e){super(),this.deps=e,this.batchSize=e.batchSize??200}async recordTypesHeldBack(e){let{describeRecordTypes:t,countRecordTypes:o}=this.deps;if(!t||!o)return[];let n=await this.creatableFieldsOf(e);if(n&&!n.has("RecordTypeId"))return[];try{let r=await t(e);if(!r.some(i=>!i.available&&!i.master))return[];let s=this.inTargetRecordTypes(await o(e));return zn(e,s,kt(r,this.targetRecordTypes))}catch{return[]}}inTargetRecordTypes(e){let t=new Map;for(let[o,n]of e){if(o===null)continue;let r=this.targetRecordTypeOf(o);t.set(r,(t.get(r)??0)+n)}return t}targetRecordTypeOf(e){return this.recordTypeMappings?.find(t=>t.sourceId===e)?.targetId??e}async recordTypesGivenOf(e,t,o=new Map,n=[]){await this.mapRecordTypes(e);let r=new Map;for(let s of new Set(e.waves.flatMap(i=>i.objects))){let i=t.get(s)??0;if(i===0)continue;let a=await this.givenRuleOf(s);if(!a)continue;let c=await this.creatableFieldsOf(s),d,m="masterInSource";if(c&&!c.has("RecordTypeId"))d=i,m="notRead";else{let u=await this.onMasterInSource(s,o.get(s));if(u===void 0)continue;d=n.find(g=>g.objectApiName===s)?Math.min(u,i):u}d!==0&&r.set(s,{objectApiName:s,rows:d,why:{[m]:d},...a.predicted?{predicted:a.predicted}:{}})}return r}async onMasterInSource(e,t){try{if(t===void 0){let r=this.deps.countRecordTypes;return r?br(await r(e)):void 0}let o=this.deps.querySource;if(!o)return;let n=0;for(let r=0;r<t.length;r+=ke){let s=await o(Nt(e,t.slice(r,r+ke)));n+=br(Ke(s))}return n}catch{return}}givenRuleOf(e){let t=this.givenRules.get(e);return t||(t=(async()=>{let o=this.recordTypesUnderTheLease.get(e)??await this.deps.describeRecordTypes?.(e).catch(()=>{});if(!o?.some(s=>!s.master))return;let n=kt(o,this.targetRecordTypes),r=$o(Do(n));return{types:n,...r?{predicted:r}:{}}})(),this.givenRules.set(e,t)),t}async readAgainUnderTheLease(e,t){let o=this.deps.describeRecordTypesAgain;if(!o||!this.lease||this.lease.assigned===0)return;let n=[...new Set(e.waves.flatMap(r=>r.objects))].filter(r=>(t.get(r)??0)>0);await Promise.all(n.map(async r=>{if((await this.deps.describeRecordTypes?.(r).catch(()=>{}))?.some(i=>!i.master))try{this.recordTypesUnderTheLease.set(r,await o(r))}catch{}}))}countCreatedWithoutRecordType(e,t,o,n){let r=this.recordTypesGiven.get(e);r||(r={...t,rows:0,why:{},ids:[]},this.recordTypesGiven.set(e,r)),r.rows++,r.why[o]=(r.why[o]??0)+1,n&&r.ids.length<Bo&&r.ids.push(n)}async afterTheWrites(e){await this.giveTheLeaseBack(),await this.readBackRecordTypes();for(let[t,o]of this.recordTypesGiven){let n=e[t];n&&(e[t]={...n,recordTypeGiven:Gr(t,o)})}}async giveTheLeaseBack(){let e=this.lease;if(e){this.lease=void 0;try{await e.giveBack()}catch(t){ae.warn(`[autopilot] the mute's lease was not given back as the writes ended: ${ee(t)}`)}}}async readBackRecordTypes(){let e=this.deps.queryTarget;e&&await Promise.all([...this.recordTypesGiven].map(async([t,o])=>{if(o.ids.length!==0)try{let n=await e(Nt(t,o.ids));o.readBack=_o(n,o.types)}catch(n){o.readBack={read:0,types:[],unread:ee(n)}}}))}holdOnClosedRecordTypes(e,t,o){let n=o.closedRecordTypes;if(!n)return t;let r=[];for(let s of t){let i=s.RecordTypeId,a=e===fe&&Pe(s),c=typeof i=="string"&&i.length>=15&&!a?n.get(de(this.targetRecordTypeOf(i))):void 0;if(!c){r.push(s);continue}o.failed++;let d=o.heldForRecordType.get(c.recordTypeId);o.heldForRecordType.set(c.recordTypeId,{...c,recordCount:(d?.recordCount??0)+1});let m=s.Id;typeof m=="string"&&m!==""&&this.refusedRecords.set(de(m),e)}return r}async mapRecordTypes(e){let{querySource:t,queryTarget:o}=this.deps;if(!t||!o)return;let n=[...new Set(e.waves.flatMap(s=>s.objects))];if(n.length===0)return;let r=`${xo} AND SobjectType IN (${n.map(s=>`'${ge(s)}'`).join(", ")})`;try{let[s,i]=await Promise.all([t(r),o(r)]),a=xt(s);this.targetRecordTypes=xt(i),this.recordTypeMappings=new jt().buildMapping(a,this.targetRecordTypes);for(let c of No(a,this.targetRecordTypes))ae.warn(`[autopilot] ${Lo(c)}`)}catch(s){ae.warn("Autopilot could not match the record types of the two orgs",{error:ee(s)})}}async matchStandardPricebooks(e){let{querySource:t,queryTarget:o}=this.deps;if(!t||!o)return;let n=new Set(e.waves.flatMap(r=>r.objects));if(!(!n.has(Ae)&&!n.has(Oe)))try{let[r,s]=await Promise.all([t(ve),o(ve)]),i=r[0]?.Id,a=s[0]?.Id;if(typeof i!="string"||typeof a!="string")return;this.standardPricebook={source:i,target:a},this.deps.remapper.registerMappings(Ae,[[i,a]])}catch(r){ae.warn("Autopilot could not match the standard price books",{error:ee(r)})}}async execute(e,t,o,n,r,s=new Map,i={}){if(!this.deps.queryByIds&&[...s.values()].some(f=>f.length>0))throw new Error("This plan reads the parents its objects reference by id, and the run has no read by id.");this.parentIds=s,this.contactPoints=i.keepContactPoints===!0?void 0:new Mo,this.lease=i.lease,this.fit=i.fit?Ur(i.fit):void 0;let a=Date.now();this.signal=r;let c=()=>this.pauseResolve?.();r?.addEventListener("abort",c,{once:!0});let d={},m={},u={totalSuccess:0,totalFailure:0,totalSkipped:0,totalLinked:0,elapsedMs:0,completedObjects:[],failedObjects:[],skippedObjects:[],nodeErrors:d,objectOutcomes:m},p=[];this.emit("execution-started",this.makeEvent({type:"execution-started",timestamp:""}));let g=async f=>{await y(f),f===We&&await this.writeEmailsAfterTheirTask(t,u)},y=async f=>{if(this.skippedObjects.has(f)){let w=n.get(f)??0;u.skippedObjects.push(f),u.totalSkipped+=w,this.notWritten.set(f,"skipped");return}this.reached.add(f);let R=n.get(f)??0;if(await this.checkPause()){p.push(f),m[f]={written:0,linked:0,failed:0,refusals:[],...R>0?{notSent:R}:{}};return}try{let w=await this.executeObject(f,t,o,R);u.totalSuccess+=w.success,u.totalFailure+=w.failure,u.totalLinked=(u.totalLinked??0)+w.linked,w.cutSinceFit>0&&(u.cutSinceFit=(u.cutSinceFit??0)+w.cutSinceFit);let C=this.leftToThePlatform.counts(f);if(m[f]={written:w.success,linked:w.linked,failed:w.failure,refusals:w.refusals,...w.leftToDefault.length>0?{leftToDefault:w.leftToDefault}:{},...C.length>0?{leftToThePlatform:C}:{},...w.notSent!==void 0&&w.notSent>0?{notSent:w.notSent}:{},...this.currenciesReplacedOf(f),...this.pricesSettledOf(f),...f===fe&&this.personContactsLinked>0?{withTheirPersonAccount:this.personContactsLinked}:{},...w.cutSinceFit>0?{cutSinceFit:w.cutSinceFit}:{},...w.threw!==void 0?{threw:w.threw}:{},...w.sentAgainForALock.rows>0?{sentAgainForALock:w.sentAgainForALock}:{}},w.notSent!==void 0){p.push(f);return}let{threw:v}=w;if(v!==void 0||w.errors.length>0&&w.success+w.linked===0){u.failedObjects.push(f),v!==void 0&&this.notWritten.set(f,"failed");let z=v!==void 0?[v,...w.errors]:w.errors;d[f]=z[0],this.emit("node-failed",this.makeEvent({type:"node-failed",timestamp:"",objectApiName:f,errors:z,partialSuccessCount:w.success,failureCount:w.failure,linkedCount:w.linked,refusals:w.refusals}))}else u.completedObjects.push(f),this.emit("node-completed",this.makeEvent({type:"node-completed",timestamp:"",objectApiName:f,successCount:w.success,failureCount:w.failure,linkedCount:w.linked,refusals:w.refusals,elapsedMs:w.elapsedMs,apiCallsUsed:w.apiCallsUsed}))}catch(w){u.failedObjects.push(f),this.notWritten.set(f,"failed");let C=ee(w);d[f]=C,this.emit("node-failed",this.makeEvent({type:"node-failed",timestamp:"",objectApiName:f,errors:[C],partialSuccessCount:0,failureCount:0,linkedCount:0,refusals:[]}))}};try{await this.matchStandardPricebooks(e),await this.mapRecordTypes(e),await this.readAgainUnderTheLease(e,n),this.planned=new Set(e.waves.flatMap(w=>w.objects));let f={};for(let w of e.waves){if(await this.writeWave(w.objects,t,g),this.stopped())break;await this.fillOwedLookups(f),this.emit("wave-completed",this.makeEvent({type:"wave-completed",timestamp:""}))}if(this.stopped()){let w=new Set([...u.completedObjects,...u.failedObjects,...u.skippedObjects,...p]);for(let C of e.waves.flatMap(v=>v.objects)){if(w.has(C))continue;let v=n.get(C)??0;p.push(C),m[C]={written:0,linked:0,failed:0,refusals:[],...v>0?{notSent:v}:{}}}return u.stopped=!0,u.stoppedObjects=p,this.countEmailsTheStopHeld(u,p,m),this.countWhatTheStopLeft(p,m),await this.sayLookupsLeftOwed(t,f),Object.keys(f).length>0&&(u.lookups=f),await this.afterTheWrites(m),this.reportContactPoints(u),u.elapsedMs=Date.now()-a,u}this.emailsAfterTheirTask.length>0&&(await this.writeEmailsAfterTheirTask(t,u),await this.fillOwedLookups(f)),await this.sayLookupsLeftOwed(t,f);let R=await this.applyDeferredStatuses();return Object.keys(R).length>0&&(u.statuses=R),Object.keys(f).length>0&&(u.lookups=f),await this.afterTheWrites(m),this.stopped()&&(u.stopped=!0,u.stoppedObjects=p,this.countEmailsTheStopHeld(u,p,m),this.countWhatTheStopLeft(p,m)),this.reportContactPoints(u),u.elapsedMs=Date.now()-a,this.emit("execution-completed",this.makeEvent({type:"execution-completed",timestamp:""})),u}catch(f){throw u.elapsedMs=Date.now()-a,u.fatalError=ee(f),ae.error("Autopilot execution crashed",{error:u.fatalError}),this.emit("execution-failed",this.makeEvent({type:"execution-failed",timestamp:"",error:u.fatalError})),f}finally{r?.removeEventListener("abort",c),await this.giveTheLeaseBack()}}async writeWave(e,t,o){let{within:n,deps:r,groups:s}=Ue(e,t),i=new Map;s.forEach((m,u)=>m.forEach(p=>i.set(p,u)));let a=[];for(let[m,u]of s.entries()){let p=new Set;for(let g of u)for(let y of r.get(g)??[]){let f=i.get(y);f!==void 0&&f!==m&&p.add(a[f])}a.push((async()=>{await Promise.all(p);let g=u.length>1?un(u,await this.setAtInsert(u,n)):u;for(let y of g)await o(y)})())}let d=(await Promise.allSettled(a)).find(m=>m.status==="rejected");if(d)throw d.reason}async setAtInsert(e,t){let o=new Set(e),n=new Map;for(let r of t)!o.has(r.to)||!o.has(r.from)||n.has(r.to)||n.set(r.to,await this.lookupsOf(r.to));return pn(e,t,r=>n.get(r))}async fillOwedLookups(e){let t=this.owedLookups.splice(0,this.owedLookups.length),{update:o}=this.deps;if(!o||t.length===0)return;let n=new Io;for(let r of t){let s=r.parents.map(i=>this.deps.remapper.getTargetId(i,r.sourceId)).find(i=>i!==void 0);if(!s){this.owedLookups.push(r);continue}n.add({objectApiName:r.objectApiName,recordId:r.recordId,fieldName:r.fieldApiName,value:s})}for(let[r,s]of n.updates()){let i=e[r],a=i?.filled??0,c=new Re;for(let d of i?.refusals??[])c.addCounted(d);for(let d=0;d<s.length;d+=this.batchSize){if(await this.checkPause()){this.noteLeftByStop(r,"lookups",s.slice(d).map(p=>String(p.Id)));break}let m=s.slice(d,d+this.batchSize),u=await Ht(o,r,m);m.forEach((p,g)=>{let y=u[g];if(y?.success){a++;return}let f=Object.keys(p).filter(R=>R!=="Id");c.add(Kt(y).map(R=>({...R,fields:f}))),this.noteLookupLeftEmpty(r,String(p.Id))})}e[r]=this.lookupOutcome(r,a,c)}}noteLookupLeftEmpty(e,t){let o=this.lookupsLeftEmpty.get(e);o||(o=new Set,this.lookupsLeftEmpty.set(e,o)),o.add(t)}lookupOutcome(e,t,o){let n=this.lookupsLeftEmpty.get(e)?.size??0;return{filled:t,refusals:o.list(),...n>0?{leftEmpty:n}:{}}}async sayLookupsLeftOwed(e,t){let o=new Map;for(let n of this.owedLookups.splice(0,this.owedLookups.length)){let r=await this.whyLeftOwed(n,e);if(!r)continue;let s=o.get(n.objectApiName);if(!s){s=new Re;for(let i of t[n.objectApiName]?.refusals??[])s.addCounted(i);o.set(n.objectApiName,s)}s.add([{...r,fields:[n.fieldApiName]}]),this.noteLookupLeftEmpty(n.objectApiName,n.recordId)}for(let[n,r]of o){let s=t[n]?.filled??0;t[n]=this.lookupOutcome(n,s,r)}}async whyLeftOwed(e,t){let{fieldApiName:o,sourceId:n}=e,r=this.refusedRecords.get(de(n)),s=e.parents.find(c=>c===r);if(s)return{statusCode:hr,message:`the ${s} record its ${o} names was refused in this run, and this record, written before it, keeps its ${o} empty.`};let i=this.fit?.stayedOut.get(de(n)),a=e.parents.find(c=>c===i);if(a)return{statusCode:Yt,message:`the ${a} record its ${o} names stayed out with a record the fit cut, and this record, written before it, keeps its ${o} empty.`};for(let c of e.parents){let d=this.notWrittenOf(c);if(d===void 0)continue;let m=t.find(u=>u.from===c&&u.to===e.objectApiName&&u.fieldApiName===o);if(!(m&&!await this.namesARecordOf(e.objectApiName,m,n,e.parents.length)))return{statusCode:gr,message:`the ${c} record its ${o} names was not written: ${yr[d](c)}, and this record, written before it, keeps its ${o} empty.`}}}async executeObject(e,t,o,n){let r=Date.now(),s=wr(),i=()=>{let a=[...s.heldForRecordType.values()];return{success:s.written,linked:s.linked,failure:s.failed,errors:[...a.map(Wn),...s.errors],refusals:[...s.refusals.list(),...a.map(zr)].sort((c,d)=>d.count-c.count),apiCallsUsed:s.apiCallsUsed,elapsedMs:Date.now()-r,leftToDefault:[...s.defaulted].map(([c,d])=>({field:c,count:d})),...s.notSent!==void 0?{notSent:s.notSent}:{},cutSinceFit:s.cutSinceFit,sentAgainForALock:s.sentAgainForALock}};try{return await this.writeEveryPage(e,t,o,n,s,i)}catch(a){return{...i(),threw:ee(a)}}}async writeEveryPage(e,t,o,n,r,s){let i=n>0?await this.recordTypesHeldBack(e):[];i.length>0&&(r.closedRecordTypes=new Map(i.map(u=>[de(u.recordTypeId),u])));let a=u=>{let p=Math.min(u,n);this.emit("node-progress",this.makeEvent({type:"node-progress",timestamp:"",objectApiName:e,progress:n>0?Math.round(p/n*100):100,recordsProcessed:p,recordsTotal:n,apiCallsUsed:r.apiCallsUsed}))},c=0,d,m=this.standardPricebook;if(Vt(e)&&m){let u=[];for(;c<n;){if(await this.checkPause())return r.notSent=n,s();let{rows:v,advance:z,next:K,last:E}=await this.readPage(e,c,d);if(r.apiCallsUsed++,z===0)break;c+=z,d=K;let A=this.leaveToThePlatform(e,v,t);if(this.deps.anonymizer.anonymize(A,o,e),await this.neutralizeContactPoints(e,A),u.push(...A),E)break}let p=await this.pricesInOneCurrencyEach(u,m.source),{standard:g,custom:y}=ut(p.rows,m.source),f=ut(u.filter(v=>p.standsFor.has(String(v.Id))),m.source);p.said.length>0&&this.pricesSettled.set(e,Go(p.said));let R=0,w=0,C=async v=>{for(let z=0;z<v.length;z+=this.batchSize){if(await this.checkPause())return r.notSent=u.length-R-w,!1;let K=v.slice(z,z+this.batchSize);await this.writeBatch(e,K,t,r),R+=K.length,a(R+w)}return!0};for(let[v,z]of[[g,f.standard],[y,f.custom]]){if(!await C(v))return s();let K=this.linkWhatStoodIn(z,p.standsFor,r);if(w+=z.length-K.length,!await C(K))return s()}return s()}for(;c<n;){if(await this.checkPause()){r.notSent=n-c;break}let{rows:u,advance:p,next:g,last:y}=await this.readPage(e,c,d);if(r.apiCallsUsed++,p===0)break;d=g;let f=this.leaveToThePlatform(e,u,t);if(this.deps.anonymizer.anonymize(f,o,e),await this.neutralizeContactPoints(e,f),await this.writeBatch(e,f,t,r),c+=p,a(c),y)break}return s()}async neutralizeContactPoints(e,t){let{contactPoints:o}=this,n=this.deps.describeFields;if(!o||!n||t.length===0)return;let r=await n(e).catch(()=>{});if(!r)return;let s=o.forObject(e,r);if(s)for(let i of t)s(i)}reportContactPoints(e){this.contactPoints&&(e.contactPoints=this.contactPoints.report())}async readPage(e,t,o){let n=this.parentIds.get(e);if(n&&this.deps.queryByIds){let i=n.slice(t,t+Math.min(this.batchSize,ke));return i.length===0?{rows:[],advance:0,next:o,last:!0}:{rows:await this.deps.queryByIds(e,i),advance:i.length,next:o,last:!1}}let r=await this.deps.query(e,o,this.batchSize),s=r.at(-1)?.Id;return{rows:r,advance:r.length,next:typeof s=="string"?s:o,last:r.length>0&&typeof s!="string"}}leaveToThePlatform(e,t,o){let n=new Set(o.filter(r=>r.to===e&&(r.required||Qt(r.to,r.fieldApiName))).map(r=>r.fieldApiName));return this.leftToThePlatform.keep(e,t,[...n])}async writeBatch(e,t,o,n){let r=[],s=t,i=this.standardPricebook;if(e===Ae&&i&&(s=t.filter(E=>E.Id!==i.source),n.linked+=t.length-s.length),s=this.holdOnClosedRecordTypes(e,s,n),s=await this.holdBehindRefusedParents(e,s,o,n),s=this.holdBehindCutParents(e,s,n),e===oe&&(s=this.holdEmailsForTheirTask(s)),e===fe&&(s=await this.linkPersonContacts(s,n,r)),s.length===0){this.register(e,r);return}let a=this.deps.remapper.remapRecords(s,o,e);await this.leaveToDefault(e,s,n);let c=await this.creatableFieldsOf(e),d=c?s.map(E=>{let A={};for(let j of Object.keys(E))(j==="Id"||j==="attributes"||c.has(j))&&(A[j]=E[j]);return A}):s;d=this.translateRecordTypes(e,d);let m=new Map;d.forEach((E,A)=>{if(E.RecordTypeId!==void 0)return;let j=s[A]?.RecordTypeId,M=!c||c.has("RecordTypeId");m.set(E,M&&Ft(j)?"masterInSource":"notRead")});for(let E of d)for(let A of Zt(e,E))delete E[A];let u=await this.replaceCurrencies(e,s,d,c);e===ce&&await this.leaveOutForAccountKind(s,d);let p=new Map;d.forEach((E,A)=>{let j=gt(e,E);for(let M of j)delete E[M];j.length>0&&p.set(A,j)});let g=await this.lookupsOwed(e,s,a.unresolved.filter(E=>!p.get(E.index)?.includes(E.fieldApiName)),c),y=this.deps.queryTarget,f=y?E=>(n.apiCallsUsed++,y(E)):void 0;if(e===mn&&f){let E=await En(f,d);for(let[A,j]of E){let M=d[A].Id;typeof M=="string"&&r.push([M,j])}n.linked+=E.size,d=d.filter((A,j)=>!E.has(j))}if(Sn[e]!==void 0&&f){let E=await On(f,e,d);for(let[A,j]of E){let M=d[A].Id;typeof M=="string"&&r.push([M,j])}n.linked+=E.size,await this.giveFlagsBack(e,[...E].map(([A,j])=>[d[A],j]),n),d=d.filter((A,j)=>!E.has(j))}if(e===We&&f){let E=await this.tasksWrittenWithTheirEmail(d,f);for(let[A,j]of E)r.push([A,j]);n.linked+=E.size,d=d.filter(A=>!E.has(String(A.Id)))}if(d.length===0){this.register(e,r);return}let R=await this.startAsDrafts(e,d),w=m.size>0?await this.givenRuleOf(e):void 0,C=await this.insertSendingLocksAgain(e,d,n),v=await this.keyPrefixOf(e),z=hn[e],K=[];if(d.forEach((E,A)=>{let j=typeof E.Id=="string"?E.Id:void 0,M=C[A];if(!M){this.refuse(e,j,n,void 0);return}if(M.success){n.written++;let se=w?m.get(E):void 0;w&&se&&this.countCreatedWithoutRecordType(e,w,se,M.id);let T=u.get(E);this.currencyChanges.add(e,T),T&&M.id&&this.currencyChangesByWrittenId.set(M.id,T),j&&M.id&&r.push([j,M.id]);let O=R.get(A);O&&M.id&&this.deferredStatuses.push({objectApiName:e,id:M.id,status:O});let D=j?g.get(j):void 0;for(let S of M.id?D??[]:[])this.owedLookups.push({objectApiName:e,recordId:M.id,fieldApiName:S.fieldApiName,sourceId:S.sourceId,parents:S.parents});return}let te=Hn(M,v);if(te.kind==="linked"){n.linked++,j&&r.push([j,te.id]);return}if(te.kind==="unidentified"&&z&&f){K.push({payload:E,sourceId:j,outcome:M});return}this.refuse(e,j,n,M)}),z&&f&&K.length>0){let E=await Pn(f,e,z,K.map(A=>A.payload));K.forEach((A,j)=>{let M=E[j];if(M&&A.sourceId){n.linked++,r.push([A.sourceId,M]);return}this.refuse(e,A.sourceId,n,A.outcome)})}this.register(e,r)}async insertSendingLocksAgain(e,t,o){let n=async i=>(o.apiCallsUsed++,this.deps.insert(e,i)),r=await n(t),s=await oo({outcomes:r.slice(0,t.length),locked:i=>!i.success&&to(i.errors,i.errorDetails),written:i=>i.success,send:i=>Ht((a,c)=>n(c),e,i.map(a=>t[a])),note:qr,wait:async i=>{await this.wait(i),await this.checkPause()},stopped:()=>this.stopped()});return s.refused===0?r:(o.sentAgainForALock={rows:o.sentAgainForALock.rows+s.sentAgain,written:o.sentAgainForALock.written+s.written,stillLocked:o.sentAgainForALock.stillLocked+s.stillLocked},ae.info(`[autopilot] ${e}: ${Xe("record(s)",s)??""}`),[...s.outcomes,...r.slice(t.length)])}async giveFlagsBack(e,t,o){let n=this.deps.update;if(!n||t.length===0||!Tn[e])return;let r=await this.deps.describeFieldsFixedAtInsert?.(e).catch(()=>{}),s=await vn(e,t,i=>!r?.has(i),async i=>(o.apiCallsUsed++,n(e,i)),()=>this.stopped());s&&ae.warn("Autopilot linked relations without a flag or an answer their rows carried",{objectApiName:e,note:s})}holdEmailsForTheirTask(e){for(let o of e){let n=o.ActivityId;typeof o.Id=="string"&&typeof n=="string"&&n!==""&&this.taskOfEmail.set(o.Id,n)}if(this.taskTurnOver||!this.planned.has(We))return e;let t=[];for(let o of e)bn(o)?this.emailsAfterTheirTask.push(o):t.push(o);return t}async tasksWrittenWithTheirEmail(e,t){let o=new Map;for(let[i,a]of this.taskOfEmail){let c=this.deps.remapper.getTargetId(oe,i);c&&o.set(a,c)}let n=e.map(i=>String(i.Id)).filter(i=>o.has(i));if(n.length===0)return new Map;let r;try{r=await An(t,[...new Set(n.map(i=>o.get(i)??""))])}catch(i){return ae.warn("Autopilot could not look up the tasks written with its emails",{error:ee(i)}),new Map}let s=new Map;for(let i of n){let a=r.get(o.get(i)??"");a&&s.set(i,a)}return s}async writeEmailsAfterTheirTask(e,t){this.taskTurnOver=!0;let o=this.emailsAfterTheirTask.splice(0,this.emailsAfterTheirTask.length);if(o.length===0)return;let n=wr();for(let d=0;d<o.length;d+=this.batchSize){if(await this.checkPause()){this.emailsHeldAndNotSent+=o.length-d;break}await this.writeBatch(oe,o.slice(d,d+this.batchSize),e,n)}t.totalSuccess+=n.written,t.totalFailure+=n.failed,t.totalLinked=(t.totalLinked??0)+n.linked;let r=t.objectOutcomes??{};t.objectOutcomes=r;let s=r[oe],i=new Re;for(let d of[...s?.refusals??[],...n.refusals.list()])i.addCounted(d);let a=new Map((s?.leftToDefault??[]).map(d=>[d.field,d.count]));for(let[d,m]of n.defaulted)a.set(d,(a.get(d)??0)+m);let c={...s,written:(s?.written??0)+n.written,linked:(s?.linked??0)+n.linked,failed:(s?.failed??0)+n.failed,refusals:i.list(),...a.size>0?{leftToDefault:[...a].map(([d,m])=>({field:d,count:m}))}:{}};r[oe]=c,c.written+c.linked>0&&t.failedObjects.includes(oe)&&(t.failedObjects.splice(t.failedObjects.indexOf(oe),1),delete t.nodeErrors?.[oe],t.completedObjects.push(oe)),this.emit("node-completed",this.makeEvent({type:"node-completed",timestamp:"",objectApiName:oe,successCount:c.written,failureCount:c.failed,linkedCount:c.linked,refusals:c.refusals,elapsedMs:0,apiCallsUsed:n.apiCallsUsed}))}async leaveToDefault(e,t,o){let n=await this.lookupsOf(e);if(!n)return;let r=In(n.filter(i=>i.name!=="RecordTypeId"),i=>!this.planned.has(i));if(r.size===0)return;let s=await this.creatableFieldsOf(e);for(let i of t)for(let a of r){let c=i[a];c!=null&&c!==""&&(!s||s.has(a))&&o.defaulted.set(a,(o.defaulted.get(a)??0)+1),delete i[a]}}async replaceCurrencies(e,t,o,n){let r=new Map,{querySource:s,queryTarget:i}=this.deps;if(!s||!i)return r;let a=!n||n.has(he);if(!a&&this.currencyChangesByWrittenId.size===0)return r;let c=p=>typeof p?.[he]=="string"&&p[he]!=="";if(!(a?o.some(c):t.some(c)))return r;this.currencies??=Me(s,i,{source:this.deps.toolingSource,target:this.deps.toolingTarget});let d=await this.currencies;if(!d)return r;let m=await this.deps.describeCurrencyFields?.(e).catch(()=>{})??new Map,u=a?[]:(await this.lookupsOf(e)??[]).map(p=>p.name);return o.forEach((p,g)=>{let y=t[g],f=y?.[he],R=a?Ln(p,{read:f,currencyFields:m,ratesOn:Fn(e,y)},d):$n(p,{read:f,parent:y?Dn(e,y,u,w=>this.currencyChangesByWrittenId.get(w)):void 0,currencyFields:m},d);R&&r.set(p,R)}),r}async pricesInOneCurrencyEach(e,t){let o={rows:e,standsFor:new Map,said:[]},{querySource:n,queryTarget:r}=this.deps;if(!n||!r)return o;let s=d=>typeof d[he]=="string"&&d[he]!=="";if(!e.some(s))return o;this.currencies??=Me(n,r,{source:this.deps.toolingSource,target:this.deps.toolingTarget});let i=await this.currencies;if(!i)return o;let{target:a}=i,c=zo({prices:e,standardBookId:t,sellingModels:e.some(d=>typeof d[Ee]=="string"),writtenIn:d=>a.active.has(d)?d:Nn(void 0,a)?.to,active:a.active},[]);return{rows:c.rows,standsFor:c.standsFor,said:c.said}}linkWhatStoodIn(e,t,o){let n=Oe,r=[],s=[];for(let i of e){let a=String(i.Id),c=t.get(a),d=c===void 0?void 0:this.deps.remapper.getTargetId(n,c);if(d===void 0){s.push(i);continue}r.push([a,d]),o.linked++}return this.register(n,r),s}pricesSettledOf(e){let t=this.pricesSettled.get(e)??[];return t.length>0?{pricesSettled:t}:{}}currenciesReplacedOf(e){let t=this.currencyChanges.list().filter(o=>o.objectApiName===e);return t.length>0?{currenciesReplaced:t}:{}}translateRecordTypes(e,t){let o=this.recordTypeMappings;return!o||!t.some(n=>typeof n.RecordTypeId=="string")?t.map(Fo):new jt().apply(t,o,n=>{this.unmappedRecordTypes.has(n)||(this.unmappedRecordTypes.add(n),jo(e,n,"autopilot"))})}async lookupsOwed(e,t,o,n){let r=new Map;if(!this.deps.update||o.length===0)return r;let s=await this.lookupsOf(e);for(let i of o){if(n&&!n.has(i.fieldApiName))continue;let a=s?.find(d=>d.name===i.fieldApiName);if(a&&!a.updateable)continue;let c=t[i.index]?.Id;typeof c=="string"&&r.set(c,[...r.get(c)??[],i])}return r}refuse(e,t,o,n){o.failed++;let r=Kt(n);o.errors.push(n?.errors[0]??Wr(r[0])),o.refusals.add(r),t&&this.refusedRecords.set(de(t),e)}async holdBehindRefusedParents(e,t,o,n){if(this.refusedRecords.size===0&&this.notWritten.size===0&&this.skippedObjects.size===0)return t;let r=o.filter(a=>a.to===e);if(r.length===0)return t;let s=new Map;for(let a of r)s.set(a.fieldApiName,(s.get(a.fieldApiName)??0)+1);let i=[];for(let a of t){let c=gt(e,a),d;for(let y of r){let f=a[y.fieldApiName];if(typeof f!="string"||f===""||c.includes(y.fieldApiName)||this.deps.remapper.getTargetId(y.from,f)!==void 0)continue;let R=this.refusedRecords.get(de(f))===y.from,w=this.notWrittenOf(y.from);if(!R&&w===void 0)continue;let C=s.get(y.fieldApiName)??0;if(!R&&!await this.namesARecordOf(e,y,f,C))continue;let{from:v,fieldApiName:z}=y;d=R||w===void 0?{edge:y,statusCode:hr,message:`the ${v} record its ${z} names was refused in this run, and written without it this record would stand without its ${v}.`}:{edge:y,statusCode:gr,message:`the ${v} record its ${z} names was not written: ${yr[w](v)}, and written without it this record would stand without its ${v}.`};break}if(!d){i.push(a);continue}let{statusCode:m,message:u,edge:p}=d;n.failed++,n.errors.push(`${m}: ${u}`),n.refusals.add([{statusCode:m,message:u,fields:[p.fieldApiName]}]);let g=a.Id;typeof g=="string"&&g!==""&&this.refusedRecords.set(de(g),e)}return i}holdBehindCutParents(e,t,o){let n=this.fit,r=n?.holds.get(e);return!n||!r?t:t.filter(s=>{if(!r.some(c=>{let d=s[c.field];if(typeof d!="string"||d==="")return!1;let{prefix:m}=c;if(m!==void 0&&(m===null||!d.startsWith(m))||this.deps.remapper.getTargetId(c.parent,d)!==void 0)return!1;let u=de(d);return n.stayedOut.has(u)||n.kept.get(c.parent)?.has(u)!==!0}))return!0;o.cutSinceFit++;let a=s.Id;return typeof a=="string"&&a!==""&&n.stayedOut.set(de(a),e),!1})}notWrittenOf(e){if(!this.planned.has(e))return;let t=this.notWritten.get(e);return t||(this.skippedObjects.has(e)&&!this.reached.has(e)?"skipped":void 0)}async namesARecordOf(e,t,o,n){let r=(await this.lookupsOf(e))?.find(s=>s.name===t.fieldApiName);if(r?.referenceTo.length===1)return r.referenceTo[0]===t.from;if(r&&r.referenceTo.length>1){let s=await this.keyPrefixOf(t.from);return typeof s=="string"&&s!==""&&o.startsWith(s)}return n===1}async linkPersonContacts(e,t,o){let n=e.filter(Pe),r=this.deps.queryTarget;if(n.length===0||!r)return e;let s=await this.lookupsOf(ce);if(s&&!s.some(u=>u.name===yt))return e;let i=new Map;for(let u of n){let p=u.AccountId,g=typeof p=="string"&&p!==""?this.deps.remapper.getTargetId(ce,p):void 0;g&&i.set(u,g)}let a=new Map,c;if(i.size>0)try{t.apiCallsUsed++,a=await Rn(r,[...new Set(i.values())])}catch(u){c=ee(u)}let d=(u,p,g)=>{t.failed++,t.errors.push(`${p}: ${g}`),t.refusals.add([{statusCode:p,message:g,fields:["AccountId"]}]);let y=u.Id;typeof y=="string"&&y!==""&&this.refusedRecords.set(de(y),fe)},m=[];for(let u of e){if(!Pe(u)){m.push(u);continue}let p=i.get(u);if(p===void 0){d(u,$r,"the person account this contact belongs to is not in the target: the platform writes the contact with the account, and sent on its own it would stand as a contact of no account.");continue}if(c!==void 0){d(u,Br,`the contact the platform wrote with its person account could not be looked up (${c}): sent, this one would stand beside it as a second contact.`);continue}let g=a.get(p),y=u.Id;if(g===void 0||typeof y!="string"){m.push(u);continue}o.push([y,g]),t.linked++,this.personContactsLinked++}return m}async leaveOutForAccountKind(e,t){let n=e.some(Pe)?await this.takenAsBusiness(t):()=>!1,r=e.map((s,i)=>kn(s,n(t[i])));t.forEach((s,i)=>{for(let a of Object.keys(s))tn(ce,a,r[i])&&delete s[a]})}async takenAsBusiness(e){let t=await this.lookupsOf(ce);if(t&&!t.some(a=>a.name===yt))return()=>!0;let o=this.deps.queryTarget;if(!o)return()=>!1;this.personTypes??=o(_r).then(a=>new Set(a.flatMap(c=>typeof c.Id=="string"?[de(c.Id)]:[])),()=>{});let n=await this.personTypes;if(!n)return()=>!1;let r=await this.deps.describeRecordTypes?.(ce).catch(()=>{}),s=new Set((r??[]).map(a=>de(a.recordTypeId))),i=e.some(a=>typeof a.RecordTypeId!="string")?qo(r):void 0;return a=>{let c=a.RecordTypeId,d=typeof c=="string"&&c!==""?c:i;if(d===void 0)return!1;let m=de(d);return!n.has(m)&&s.has(m)}}register(e,t){t.length>0&&this.deps.remapper.registerMappings(e,t)}async startAsDrafts(e,t){let o=new Map,n=Ce[e],{queryTarget:r,update:s}=this.deps;if(!n||!r||!s)return o;let i=this.lifecycleByObject.get(e);i||(i=Cn(r,n),this.lifecycleByObject.set(e,i));let a=await i;return a&&t.forEach((c,d)=>{let m=Mn(c.Status,a);m&&(o.set(d,String(c.Status)),c.Status=m)}),o}async applyDeferredStatuses(){let e={},{update:t}=this.deps;if(!t||this.deferredStatuses.length===0)return e;let o=new Map;for(let n of this.deferredStatuses)o.set(n.objectApiName,[...o.get(n.objectApiName)??[],n]);for(let[n,r]of o){let s=0,i=0,a=new Re;for(let c=0;c<r.length;c+=this.batchSize){if(await this.checkPause()){this.noteLeftByStop(n,"statuses",r.slice(c).map(u=>u.id));break}let d=r.slice(c,c+this.batchSize),m=await Ht(t,n,d.map(u=>({Id:u.id,Status:u.status})));d.forEach((u,p)=>{let g=m[p];if(g?.success){s++;return}i++,a.add(Kt(g))})}e[n]={applied:s,refusals:a.list(),...i>0?{leftDraft:i}:{}}}return this.deferredStatuses.length=0,e}noteLeftByStop(e,t,o){if(o.length===0)return;let n=this.leftByStop.get(e);n||(n={lookups:new Set,statuses:new Set},this.leftByStop.set(e,n));for(let r of o)n[t].add(r)}countEmailsTheStopHeld(e,t,o){let n=this.emailsAfterTheirTask.splice(0,this.emailsAfterTheirTask.length),r=this.emailsHeldAndNotSent+n.length;if(this.emailsHeldAndNotSent=0,r===0)return;let s=o[oe]??{written:0,linked:0,failed:0,refusals:[]};o[oe]={...s,notSent:(s.notSent??0)+r,heldForTheirTask:r};for(let d of[e.completedObjects,e.failedObjects]){let m=d.indexOf(oe);m>=0&&d.splice(m,1)}if(t.includes(oe))return;let i=[...this.planned],a=i.indexOf(oe),c=t.findIndex(d=>i.indexOf(d)>a);t.splice(c<0?t.length:c,0,oe)}countWhatTheStopLeft(e,t){let o=new Set(e);for(let r of this.owedLookups.splice(0,this.owedLookups.length))r.parents.some(i=>o.has(i)||this.deps.remapper.getTargetId(i,r.sourceId)!==void 0)?this.noteLeftByStop(r.objectApiName,"lookups",[r.recordId]):this.owedLookups.push(r);let n=this.deferredStatuses.splice(0,this.deferredStatuses.length);for(let r of n)this.noteLeftByStop(r.objectApiName,"statuses",[r.id]);for(let[r,s]of this.leftByStop){let i=t[r]??{written:0,linked:0,failed:0,refusals:[]};t[r]={...i,...s.lookups.size>0?{lookupsLeftEmpty:s.lookups.size}:{},...s.statuses.size>0?{statusesNotGivenBack:s.statuses.size}:{}}}}pause(){this.paused||(this.paused=!0,this.pausePromise=new Promise(e=>{this.pauseResolve=e}),this.emit("paused",this.makeEvent({type:"paused",timestamp:""})))}resume(){this.paused&&(this.paused=!1,this.pauseResolve?.(),this.pausePromise=null,this.pauseResolve=null,this.emit("resumed",this.makeEvent({type:"resumed",timestamp:""})))}skip(e){this.skippedObjects.add(e)}stopped(){return this.signal?.aborted===!0}wait(e){return this.deps.wait?this.deps.wait(e):no(e,this.signal)}async checkPause(){return this.stopped()?!0:(this.paused&&this.pausePromise&&await this.pausePromise,this.stopped())}makeEvent(e){return{...e,timestamp:new Date().toISOString()}}};async function Ht(l,e,t){try{return await l(e,t)}catch(o){let n=ee(o);return t.map(()=>({id:"",success:!1,errors:[n],errorDetails:[Rt(n)]}))}}function Kt(l){return l?l.errorDetails&&l.errorDetails.length>0?l.errorDetails:l.errors.length>0?l.errors.map(e=>Rt(e)):[Dr]:[Lr]}function Wr(l){return l.statusCode===Ye?l.message:`${l.statusCode}: ${l.message}`}var it=class{threshold;partitionSize;constructor(e=5e3,t=2e3){this.threshold=e,this.partitionSize=t}shouldUseGrappe(e){return e>this.threshold}partition(e,t){if(t<=this.partitionSize)return[{id:`${e}-0`,objectApiName:e,offset:0,limit:t,recordCount:t}];let o=[],n=0,r=0;for(;n<t;){let s=Math.min(this.partitionSize,t-n);o.push({id:`${e}-${r}`,objectApiName:e,offset:n,limit:s,recordCount:s}),n+=s,r++}return o}getThreshold(){return this.threshold}getPartitionSize(){return this.partitionSize}};var Hr=`sandforge autopilot \u2014 run an Autopilot copy between two orgs, without the editor.
|
package/lib/sandforge-backup.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as ae}from"./chunk-
|
|
7
|
+
import{a as ae}from"./chunk-GCGHHN4K.mjs";import{a as N,b as ne,c as ie}from"./chunk-5GBO4KD5.mjs";import"./chunk-3HEMJTAP.mjs";import"./chunk-BN33LVPQ.mjs";import"./chunk-JKT5YAQ2.mjs";import"./chunk-QAPVKPEC.mjs";import{a as H}from"./chunk-BNKT3R3F.mjs";import{a as v}from"./chunk-QROPNEGY.mjs";import"./chunk-BZ24IAP5.mjs";import{a as I}from"./chunk-SCKUIE3R.mjs";import{c as _}from"./chunk-6FARZYMJ.mjs";import{a as de}from"./chunk-EEFUE2ES.mjs";import{m as M,p as J}from"./chunk-PE435FVH.mjs";import"./chunk-PWVDNN2C.mjs";import"./chunk-6VSZNZHH.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-WB2RIVO3.mjs";import{a as K,c as V,d as X,e as C,f as Y,g as R,h as q,i as ee,j as te,k as se,l as oe,m as re}from"./chunk-MUEQRIK7.mjs";import{Fc as B,Oc as W}from"./chunk-ISSP2FZ5.mjs";import{h as F,i as G}from"./chunk-XU25YA46.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-IVZJSDJD.mjs";import"./chunk-VZT4E2OJ.mjs";import"./chunk-BOGNK4LV.mjs";import{m as Q}from"./chunk-P55MKIZX.mjs";import"./chunk-PYRZFUVU.mjs";import"./chunk-O2PUGRNW.mjs";import"./chunk-7SDZR6SR.mjs";import"./chunk-TEIBWMJM.mjs";import"./chunk-BWWQXU2B.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YAIIRFKJ.mjs";import"./chunk-Q3DY7TO2.mjs";import"./chunk-3XG25GTF.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-WSUKC2U3.mjs";import"./chunk-QIRO4HTE.mjs";import{h as U}from"./chunk-3SKLBRPL.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-JH27IKCO.mjs";import"./chunk-SAMWHL22.mjs";import"./chunk-6KP6WETK.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-J24TIGSI.mjs";import"./chunk-HKUWHVI7.mjs";import"./chunk-VPDEJGPS.mjs";import"./chunk-5LFSFYFJ.mjs";import{b as E}from"./chunk-LHU6CPGE.mjs";import"./chunk-PBE44M2Y.mjs";import"./chunk-ZUOPC4W2.mjs";import"./chunk-JQZTMFO7.mjs";import"./chunk-JFNLKHY6.mjs";import"./chunk-VZVICK7Q.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-7PY3VQP3.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-HFUDCNU5.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-XZISAZA6.mjs";import{b as T,e as L,f as O,h as Z}from"./chunk-LCDPCUXS.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-L4INJ5TZ.mjs";import"./chunk-KIMQQ6JQ.mjs";import{e as z,g as P}from"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-PR74GYVI.mjs";import"./chunk-TMA34QMA.mjs";import"./chunk-TUACWKIH.mjs";import{Jc as D,x as S}from"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";import{join as ue}from"node:path";var ge=`sandforge backup \u2014 take and restore DataOps snapshots, without the editor.
|
|
8
8
|
|
|
9
9
|
Usage:
|
|
10
10
|
npx sandforge backup --org <alias> [options]
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{A as D,B as E,C as F,D as G,a as d,b as e,c as f,d as g,e as h,f as i,g as j,h as k,i as l,j as m,k as n,l as o,m as p,n as q,o as r,p as s,q as t,r as u,s as v,t as w,u as x,v as y,w as z,x as A,y as B,z as C}from"./chunk-
|
|
7
|
+
import{A as D,B as E,C as F,D as G,a as d,b as e,c as f,d as g,e as h,f as i,g as j,h as k,i as l,j as m,k as n,l as o,m as p,n as q,o as r,p as s,q as t,r as u,s as v,t as w,u as x,v as y,w as z,x as A,y as B,z as C}from"./chunk-KKOA62S4.mjs";import"./chunk-YGJF55VJ.mjs";import"./chunk-HIHCYMSL.mjs";import"./chunk-JESRFE2Z.mjs";import{b as a,c as b,d as c}from"./chunk-CBL42DUU.mjs";import"./chunk-MKTXJCXN.mjs";import"./chunk-RCYEBY42.mjs";import"./chunk-AUS6NFLZ.mjs";import"./chunk-YH4DYI6D.mjs";import"./chunk-SZGGFST2.mjs";import"./chunk-LAUOSXMN.mjs";import"./chunk-INIQ23K6.mjs";import"./chunk-2UU42PTD.mjs";import"./chunk-GCGHHN4K.mjs";import"./chunk-2JZGCCPG.mjs";import"./chunk-HQQVANWQ.mjs";import"./chunk-BXZ73A5M.mjs";import"./chunk-DBBPDSFN.mjs";import"./chunk-GBGHJTPC.mjs";import"./chunk-ZRUDYB7O.mjs";import"./chunk-IRZJU2PG.mjs";import"./chunk-Y4TDVDP2.mjs";import"./chunk-JJITOWZK.mjs";import"./chunk-YMDFF657.mjs";import"./chunk-UV74P4H2.mjs";import"./chunk-5K2I2DMP.mjs";import"./chunk-7WSLT5VX.mjs";import"./chunk-YT22LMF7.mjs";import"./chunk-G2JR3F63.mjs";import"./chunk-3CX7GPCR.mjs";import"./chunk-A65ADTCR.mjs";import"./chunk-NWOI25WY.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-A7JJWOLT.mjs";import"./chunk-ZXFL2MSN.mjs";import"./chunk-VYOYXTCU.mjs";import"./chunk-C3LNYAVJ.mjs";import"./chunk-GJ6SZVHT.mjs";import"./chunk-52EXDVPN.mjs";import"./chunk-GMY5427L.mjs";import"./chunk-TW3N6W5Z.mjs";import"./chunk-3HEMJTAP.mjs";import"./chunk-BN33LVPQ.mjs";import"./chunk-JKT5YAQ2.mjs";import"./chunk-QAPVKPEC.mjs";import"./chunk-BNKT3R3F.mjs";import"./chunk-QROPNEGY.mjs";import"./chunk-BZ24IAP5.mjs";import"./chunk-SCKUIE3R.mjs";import"./chunk-6FARZYMJ.mjs";import"./chunk-EEFUE2ES.mjs";import"./chunk-PE435FVH.mjs";import"./chunk-PWVDNN2C.mjs";import"./chunk-6VSZNZHH.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-WB2RIVO3.mjs";import"./chunk-MUEQRIK7.mjs";import"./chunk-ISSP2FZ5.mjs";import"./chunk-XU25YA46.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-IVZJSDJD.mjs";import"./chunk-VZT4E2OJ.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-P55MKIZX.mjs";import"./chunk-PYRZFUVU.mjs";import"./chunk-O2PUGRNW.mjs";import"./chunk-7SDZR6SR.mjs";import"./chunk-TEIBWMJM.mjs";import"./chunk-BWWQXU2B.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YAIIRFKJ.mjs";import"./chunk-Q3DY7TO2.mjs";import"./chunk-3XG25GTF.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-WSUKC2U3.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-3SKLBRPL.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-JH27IKCO.mjs";import"./chunk-SAMWHL22.mjs";import"./chunk-6KP6WETK.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-J24TIGSI.mjs";import"./chunk-HKUWHVI7.mjs";import"./chunk-VPDEJGPS.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-LHU6CPGE.mjs";import"./chunk-PBE44M2Y.mjs";import"./chunk-ZUOPC4W2.mjs";import"./chunk-JQZTMFO7.mjs";import"./chunk-JFNLKHY6.mjs";import"./chunk-VZVICK7Q.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-7PY3VQP3.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-HFUDCNU5.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-XZISAZA6.mjs";import"./chunk-LCDPCUXS.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-L4INJ5TZ.mjs";import"./chunk-KIMQQ6JQ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-PR74GYVI.mjs";import"./chunk-TMA34QMA.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{z as acceptanceRefusal,f as checkpointsOf,d as defaultName,y as heldObjectsOrStop,h as invalidRefusal,w as keepsOutside,x as keptLines,q as linkWritesOf,k as listEntryJson,j as listLines,F as main,r as orgDiffers,e as parseArgs,u as previewExitCode,t as previewJson,s as previewLines,a as previewTotals,i as replayCommandFor,p as requestsLine,g as resolveCheckpoint,E as resultExitCode,D as resultJson,B as rewindLines,A as rewindQuestion,c as rewindStepsOf,l as scopeJson,n as scopeLines,b as selectionDiff,v as selectionLines,o as takeLines,m as takeRefusalWords,G as undoLine,C as undoLines};
|
|
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{b as k}from"./chunk-
|
|
7
|
+
import{b as k}from"./chunk-2JZGCCPG.mjs";import{a as Z,b as Q,c as K,d as V}from"./chunk-5GBO4KD5.mjs";import{c as I,e as Y}from"./chunk-6FARZYMJ.mjs";import{h as U,i as H,j as B}from"./chunk-IVZJSDJD.mjs";import"./chunk-VZT4E2OJ.mjs";import"./chunk-BOGNK4LV.mjs";import{j as W}from"./chunk-HKUWHVI7.mjs";import"./chunk-VPDEJGPS.mjs";import"./chunk-5LFSFYFJ.mjs";import{b as L,c as P}from"./chunk-LHU6CPGE.mjs";import"./chunk-PBE44M2Y.mjs";import{a as D,b as M}from"./chunk-ZUOPC4W2.mjs";import"./chunk-JQZTMFO7.mjs";import{Ga as J,oa as z}from"./chunk-JFNLKHY6.mjs";import"./chunk-VZVICK7Q.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-7PY3VQP3.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-HFUDCNU5.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-XZISAZA6.mjs";import{b as v,c as N,f as q,h as X}from"./chunk-LCDPCUXS.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import{a as F}from"./chunk-EADHKH3A.mjs";import"./chunk-L4INJ5TZ.mjs";import"./chunk-KIMQQ6JQ.mjs";import{a as j,h as R}from"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-PR74GYVI.mjs";import"./chunk-TMA34QMA.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";var te=/^[A-Za-z0-9]{15}([A-Za-z0-9]{3})?$/,re=/^\d{4}-\d{2}-\d{2}$/,se=["CaseComment","EmailMessage","Asset","Contract","Case","Contact","Account"],ne=`sandforge cleanup \u2014 Bulk delete records you created on a sandbox in the
|
|
8
8
|
--since window, whether or not a clone wrote them. Preview with --dry-run and
|
|
9
9
|
narrow with --objects before deleting.
|
|
10
10
|
|
package/lib/sandforge-clone.mjs
CHANGED
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{$ as M,$a as Ma,$b as Mb,A as l,Aa as la,Ab as lb,B as m,Ba as ma,Bb as mb,C as n,Ca as na,Cb as nb,D as o,Da as oa,Db as ob,E as p,Ea as pa,Eb as pb,F as q,Fa as qa,Fb as qb,G as r,Ga as ra,Gb as rb,H as s,Ha as sa,Hb as sb,I as t,Ia as ta,Ib as tb,J as u,Ja as ua,Jb as ub,K as v,Ka as va,Kb as vb,L as w,La as wa,Lb as wb,M as x,Ma as xa,Mb as xb,N as y,Na as ya,Nb as yb,O as z,Oa as za,Ob as zb,P as A,Pa as Aa,Pb as Ab,Q as B,Qa as Ba,Qb as Bb,R as C,Ra as Ca,Rb as Cb,S as D,Sa as Da,Sb as Db,T as E,Ta as Ea,Tb as Eb,U as F,Ua as Fa,Ub as Fb,V as G,Va as Ga,Vb as Gb,W as H,Wa as Ha,Wb as Hb,X as I,Xa as Ia,Xb as Ib,Y as J,Ya as Ja,Yb as Jb,Z as K,Za as Ka,Zb as Kb,_ as L,_a as La,_b as Lb,aa as N,ab as Na,ac as Nb,ba as O,bb as Oa,bc as Ob,ca as P,cb as Pa,cc as Pb,da as Q,db as Qa,dc as Qb,ea as R,eb as Ra,ec as Rb,fa as S,fb as Sa,fc as Sb,ga as T,gb as Ta,ha as U,hb as Ua,ia as V,ib as Va,ja as W,jb as Wa,ka as X,kb as Xa,la as Y,lb as Ya,ma as Z,mb as Za,na as _,nb as _a,oa as $,ob as $a,pa as aa,pb as ab,q as b,qa as ba,qb as bb,r as c,ra as ca,rb as cb,s as d,sa as da,sb as db,t as e,ta as ea,tb as eb,u as f,ua as fa,ub as fb,v as g,va as ga,vb as gb,w as h,wa as ha,wb as hb,x as i,xa as ia,xb as ib,y as j,ya as ja,yb as jb,z as k,za as ka,zb as kb}from"./chunk-
|
|
7
|
+
import{$ as M,$a as Ma,$b as Mb,A as l,Aa as la,Ab as lb,B as m,Ba as ma,Bb as mb,C as n,Ca as na,Cb as nb,D as o,Da as oa,Db as ob,E as p,Ea as pa,Eb as pb,F as q,Fa as qa,Fb as qb,G as r,Ga as ra,Gb as rb,H as s,Ha as sa,Hb as sb,I as t,Ia as ta,Ib as tb,J as u,Ja as ua,Jb as ub,K as v,Ka as va,Kb as vb,L as w,La as wa,Lb as wb,M as x,Ma as xa,Mb as xb,N as y,Na as ya,Nb as yb,O as z,Oa as za,Ob as zb,P as A,Pa as Aa,Pb as Ab,Q as B,Qa as Ba,Qb as Bb,R as C,Ra as Ca,Rb as Cb,S as D,Sa as Da,Sb as Db,T as E,Ta as Ea,Tb as Eb,U as F,Ua as Fa,Ub as Fb,V as G,Va as Ga,Vb as Gb,W as H,Wa as Ha,Wb as Hb,X as I,Xa as Ia,Xb as Ib,Y as J,Ya as Ja,Yb as Jb,Z as K,Za as Ka,Zb as Kb,_ as L,_a as La,_b as Lb,aa as N,ab as Na,ac as Nb,ba as O,bb as Oa,bc as Ob,ca as P,cb as Pa,cc as Pb,da as Q,db as Qa,dc as Qb,ea as R,eb as Ra,ec as Rb,fa as S,fb as Sa,fc as Sb,ga as T,gb as Ta,ha as U,hb as Ua,ia as V,ib as Va,ja as W,jb as Wa,ka as X,kb as Xa,la as Y,lb as Ya,ma as Z,mb as Za,na as _,nb as _a,oa as $,ob as $a,pa as aa,pb as ab,q as b,qa as ba,qb as bb,r as c,ra as ca,rb as cb,s as d,sa as da,sb as db,t as e,ta as ea,tb as eb,u as f,ua as fa,ub as fb,v as g,va as ga,vb as gb,w as h,wa as ha,wb as hb,x as i,xa as ia,xb as ib,y as j,ya as ja,yb as jb,z as k,za as ka,zb as kb}from"./chunk-3HEMJTAP.mjs";import"./chunk-BN33LVPQ.mjs";import"./chunk-JKT5YAQ2.mjs";import"./chunk-QAPVKPEC.mjs";import{a}from"./chunk-BNKT3R3F.mjs";import"./chunk-QROPNEGY.mjs";import"./chunk-BZ24IAP5.mjs";import"./chunk-SCKUIE3R.mjs";import"./chunk-6FARZYMJ.mjs";import"./chunk-P55MKIZX.mjs";import"./chunk-PYRZFUVU.mjs";import"./chunk-O2PUGRNW.mjs";import"./chunk-7SDZR6SR.mjs";import"./chunk-TEIBWMJM.mjs";import"./chunk-BWWQXU2B.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YAIIRFKJ.mjs";import"./chunk-Q3DY7TO2.mjs";import"./chunk-3XG25GTF.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-WSUKC2U3.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-3SKLBRPL.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-JH27IKCO.mjs";import"./chunk-SAMWHL22.mjs";import"./chunk-6KP6WETK.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-J24TIGSI.mjs";import"./chunk-HKUWHVI7.mjs";import"./chunk-VPDEJGPS.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-LHU6CPGE.mjs";import"./chunk-PBE44M2Y.mjs";import"./chunk-ZUOPC4W2.mjs";import"./chunk-JQZTMFO7.mjs";import"./chunk-JFNLKHY6.mjs";import"./chunk-VZVICK7Q.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-7PY3VQP3.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-HFUDCNU5.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-XZISAZA6.mjs";import"./chunk-LCDPCUXS.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-L4INJ5TZ.mjs";import"./chunk-KIMQQ6JQ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-PR74GYVI.mjs";import"./chunk-TMA34QMA.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{Db as CLONE_PREVIEW_UNREAD,L as FIELD_EXCLUSION_UNMATCHED,Mb as ROOT_NEVER_CREATED,ib as SWEEP_CLASS_FLAGS,Nb as TABLE_NEVER_CLONED,E as adaptDescribe,b as apiRequestsLine,C as auditDepsOf,db as automationHeldLines,V as choicesLines,z as cliRunSetup,hb as cliSweepInput,ga as cloneApiRequestsJson,n as cloneInputLine,m as cloneInputOf,Eb as clonePreviewJson,Fb as clonePreviewLines,o as cloneSubjectOf,pb as commandSweepTies,X as contactPointLines,Gb as datedFromItsJournal,W as decisionLines,H as describeObjectInfo,G as describeOnce,fa as discoveryRequestsLine,_ as dryRunAdminChanges,Ab as earlierOfTheRun,Sb as endOfAThrow,Ca as executeOptions,I as failedOutright,qa as fewerRootsOf,na as fewerRootsWords,M as fieldExclusionUnmatchedWords,N as fieldExclusionsUnmatchedLines,P as fieldExclusionsUnmatchedOf,O as fieldExclusionsUnmatchedRefusal,D as fieldInfosOf,K as fileLines,ka as fitKeyWords,za as graphCounts,ca as graphLine,Kb as interruptedLine,a as journalDirOf,Sa as journalGoneWords,wb as journalPartsOf,$ as jsonResult,Ba as listedObjects,F as loadRecordTypes,Qb as lostJobsBeforeTheMute,Rb as main,$a as maxTotalRefusal,j as missingFlagsWords,Y as neutralizedUpsertKeys,g as neverClonedTableRefusal,Aa as notCountedObjectsOf,aa as objectOutcomeLine,ba as objectOutcomePrinter,Q as orphanParentsCappedLine,fb as otherPartIdsOf,xb as otherPartsOf,gb as otherPartsSweepLines,ob as otherRunsOf,v as parseArgs,Na as parseRemoveArgs,Ta as parseRunSummary,Hb as parseVerifyArgs,vb as partsLeft,Wa as partsLeftLines,la as personAccountsAsBusinessLine,Ya as platformCopiesWords,Ka as productionRefusal,c as queryRootOf,Xa as quoteCopiesLines,s as readChoicesFile,sb as readEarlierRemovals,J as recordTypeGivenLines,Ma as rehearsalLines,La as rehearsalPlanLines,_a as removalLines,Ua as removalPlan,Va as removalPlanLines,tb as removalsAfter,zb as removalsOfParts,qb as removalsPath,Cb as removeMain,B as resumeChangedWords,A as resumeRefusal,y as resumedJournalPath,Ob as rootNeverCreatedRefusal,u as rootsArgsOf,S as rootsAskedJson,Ea as rootsChosenFirst,T as rootsLines,oa as rootsMaxTotalRefusal,Da as rootsOptionsOf,pa as rootsStorageRefusal,ub as runInPartsOf,rb as runKey,Pa as runMuteSchema,yb as runRemovalsAfter,Ra as runSummaryOfFile,Qa as runUserIdOf,t as sampleArgsOf,ra as sampleBudgetOf,ta as sampleJson,sa as sampleLines,wa as sampleReadsLine,ya as sampleRefusalExit,ua as sampleResultJson,va as sampleResultLines,xa as samplingProgressPrinter,U as simulationGapLines,R as summaryLines,jb as sweepClassArgsOf,kb as sweepClassOptions,eb as sweepLines,bb as sweepListingLines,ab as sweepOptionWords,mb as sweepOrgOf,lb as sweepPartsOptions,cb as sweepUnsaid,Oa as sweepUserHint,nb as syncRunSpanOf,l as tablesExecuteOptions,e as tablesLeftOut,f as tablesNotReached,h as tablesNotReachedWords,d as tablesQueryOf,k as tablesRunConfig,Ha as targetAutomationReader,Ia as targetGapReader,i as templateWithoutInputWords,Za as tookAlongLines,Ja as typeOrg,w as uncertainRefusal,x as uncertainRetryAt,Z as upsertKeyLines,Ib as verificationLines,Jb as verifyMain,ea as wholeOrgGateLines,da as wholeOrgGraphLine,r as wholeOrgGraphOf,ma as wholeOrgMaxTotalRefusal,q as wholeOrgOptions,ha as wholeOrgQuestion,ia as wholeOrgQuestionWords,ja as wholeOrgRefusalWords,p as wholeOrgRunConfig,Lb as wholeOrgSweepLine,Pb as wholeOrgWriteDeps,Ga as withTemplateFields,Fa as withTheJournal,Bb as writeWhole};
|
|
@@ -4,7 +4,7 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{q as A}from"./chunk-
|
|
7
|
+
import{q as A}from"./chunk-HQQVANWQ.mjs";import"./chunk-BXZ73A5M.mjs";import"./chunk-DBBPDSFN.mjs";import"./chunk-GBGHJTPC.mjs";import"./chunk-ZRUDYB7O.mjs";import"./chunk-IRZJU2PG.mjs";import"./chunk-Y4TDVDP2.mjs";import"./chunk-JJITOWZK.mjs";import"./chunk-YMDFF657.mjs";import"./chunk-UV74P4H2.mjs";import"./chunk-5K2I2DMP.mjs";import"./chunk-7WSLT5VX.mjs";import"./chunk-YT22LMF7.mjs";import"./chunk-G2JR3F63.mjs";import"./chunk-3CX7GPCR.mjs";import"./chunk-A65ADTCR.mjs";import"./chunk-NWOI25WY.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-A7JJWOLT.mjs";import"./chunk-ZXFL2MSN.mjs";import"./chunk-VYOYXTCU.mjs";import"./chunk-C3LNYAVJ.mjs";import"./chunk-GJ6SZVHT.mjs";import"./chunk-52EXDVPN.mjs";import"./chunk-GMY5427L.mjs";import"./chunk-EEFUE2ES.mjs";import"./chunk-PE435FVH.mjs";import"./chunk-PWVDNN2C.mjs";import"./chunk-6VSZNZHH.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-WB2RIVO3.mjs";import{b as C,c as E}from"./chunk-MUEQRIK7.mjs";import"./chunk-ISSP2FZ5.mjs";import"./chunk-XU25YA46.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-IVZJSDJD.mjs";import"./chunk-VZT4E2OJ.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-P55MKIZX.mjs";import"./chunk-PYRZFUVU.mjs";import"./chunk-O2PUGRNW.mjs";import"./chunk-7SDZR6SR.mjs";import"./chunk-TEIBWMJM.mjs";import"./chunk-BWWQXU2B.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YAIIRFKJ.mjs";import"./chunk-Q3DY7TO2.mjs";import"./chunk-3XG25GTF.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-WSUKC2U3.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-3SKLBRPL.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-JH27IKCO.mjs";import"./chunk-SAMWHL22.mjs";import"./chunk-6KP6WETK.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-J24TIGSI.mjs";import"./chunk-HKUWHVI7.mjs";import"./chunk-VPDEJGPS.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-LHU6CPGE.mjs";import"./chunk-PBE44M2Y.mjs";import"./chunk-ZUOPC4W2.mjs";import"./chunk-JQZTMFO7.mjs";import"./chunk-JFNLKHY6.mjs";import"./chunk-VZVICK7Q.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-7PY3VQP3.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-HFUDCNU5.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-XZISAZA6.mjs";import{b as O,f as R,h as b}from"./chunk-LCDPCUXS.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-L4INJ5TZ.mjs";import"./chunk-KIMQQ6JQ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-PR74GYVI.mjs";import"./chunk-TMA34QMA.mjs";import"./chunk-TUACWKIH.mjs";import{Wb as h,Xb as $,Yb as T,Zb as v}from"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";var L=`sandforge compare \u2014 compare two orgs the way the Compare page does, without the editor.
|
|
8
8
|
|
|
9
9
|
Usage:
|
|
10
10
|
npx sandforge compare --source <alias> --target <alias> [options]
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n}from"./chunk-FOIWWK7G.mjs";import"./chunk-TW3N6W5Z.mjs";import"./chunk-5GBO4KD5.mjs";import"./chunk-3HEMJTAP.mjs";import"./chunk-BN33LVPQ.mjs";import"./chunk-JKT5YAQ2.mjs";import"./chunk-QAPVKPEC.mjs";import"./chunk-BNKT3R3F.mjs";import"./chunk-QROPNEGY.mjs";import"./chunk-BZ24IAP5.mjs";import"./chunk-SCKUIE3R.mjs";import"./chunk-6FARZYMJ.mjs";import"./chunk-EEFUE2ES.mjs";import"./chunk-PE435FVH.mjs";import"./chunk-PWVDNN2C.mjs";import"./chunk-6VSZNZHH.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-WB2RIVO3.mjs";import"./chunk-MUEQRIK7.mjs";import"./chunk-ISSP2FZ5.mjs";import"./chunk-XU25YA46.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-IVZJSDJD.mjs";import"./chunk-VZT4E2OJ.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-P55MKIZX.mjs";import"./chunk-PYRZFUVU.mjs";import"./chunk-O2PUGRNW.mjs";import"./chunk-7SDZR6SR.mjs";import"./chunk-TEIBWMJM.mjs";import"./chunk-BWWQXU2B.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YAIIRFKJ.mjs";import"./chunk-Q3DY7TO2.mjs";import"./chunk-3XG25GTF.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-WSUKC2U3.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-3SKLBRPL.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-JH27IKCO.mjs";import"./chunk-SAMWHL22.mjs";import"./chunk-6KP6WETK.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-J24TIGSI.mjs";import"./chunk-HKUWHVI7.mjs";import"./chunk-VPDEJGPS.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-LHU6CPGE.mjs";import"./chunk-PBE44M2Y.mjs";import"./chunk-ZUOPC4W2.mjs";import"./chunk-JQZTMFO7.mjs";import"./chunk-JFNLKHY6.mjs";import"./chunk-VZVICK7Q.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-7PY3VQP3.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-HFUDCNU5.mjs";import"./chunk-MS4FJDFD.mjs";import"./chunk-XZISAZA6.mjs";import"./chunk-LCDPCUXS.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-L4INJ5TZ.mjs";import"./chunk-KIMQQ6JQ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-PR74GYVI.mjs";import"./chunk-TMA34QMA.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{j as dryRunLines,m as main,l as maskingInterruptedLine,n as maskingQuestion,b as masksObject,e as missingFieldLine,f as notWritableLine,a as parseArgs,k as restoreInterruptedLine,c as resultLines,g as runWouldBeRefused,i as slicePlanLines,h as sliceRefusedLines,d as sliceSetLines};
|