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{a as y,b as g}from"./chunk-
|
|
7
|
+
import{a as y,b as g}from"./chunk-V3R45ZWT.mjs";import{a as S,b as f,c as p}from"./chunk-A65ADTCR.mjs";import{b as u}from"./chunk-CA5NAXSU.mjs";import{Ha as d}from"./chunk-ZQO5PDX5.mjs";var h="SELECT ApiName, MasterLabel, IsClosed, IsDefault, SortOrder FROM CaseStatus ORDER BY SortOrder",w="SELECT MasterLabel, IsClosed, IsDefault, SortOrder FROM CaseStatus ORDER BY SortOrder",A="Closed";async function k(a){let e;try{e=await a(h)}catch{try{e=await a(w)}catch(t){return m(`the org would not read its case statuses: ${u(t)}`)}}let r=e.flatMap(t=>{let n=b(t.ApiName)??b(t.MasterLabel);return n===void 0?[]:[{value:n,closed:t.IsClosed===!0,isDefault:t.IsDefault===!0}]}),o=r.filter(t=>!t.closed),i=r.filter(t=>t.closed);return o.length===0||i.length===0?m(o.length===0?"the org has no case status that leaves a case open":"the org has no case status that closes a case"):{open:(o.find(t=>t.isDefault)??o[0]).value,closed:(i.find(t=>t.value===A)??i[0]).value,from:"org"}}function m(a){return{...d.caseStatus,from:"default",reason:a}}function b(a){return typeof a=="string"&&a.trim()!==""?a:void 0}var c=S;async function E(a,e){let r;try{r=await a(c)}catch{r={access:"createable"}}if(r.access==="absent")return{available:!1,reason:r.reason??`the org has no ${c}`};if(r.access==="readOnly")return{available:!1,reason:r.reason??`the user this seed runs as may read ${c} and not create it`};try{return{available:!0,bodyFields:f(await e(c))}}catch{return{available:!0,bodyFields:[]}}}var P=["Status","Origin","Priority","Type"];async function T(a){let e;try{e=(await a("Case")).fields}catch{return}let r={};for(let o of P){let t=(e.find(n=>n.name===o)?.picklistValues??[]).filter(n=>n.active!==!1).map(n=>n.value);t.length>0&&(r[o]=t)}return r}function v(a,e){let r=e.knowledge.available?e.knowledge.bodyFields:[],o=r.map(s=>s.name),i=e.articleBodyField===void 0?r[0]:r.find(s=>s.name===e.articleBodyField);if(e.articleBodyField!==void 0&&i===void 0)return{issues:[`options.articleBodyField: ${e.articleBodyField} is not a field of ${c} this org lets a body be written to`+(o.length>0?` (${o.join(", ")})`:"")]};let t=e.knowledge.available?{available:!0,bodyFields:o}:e.knowledge,n={seed:e.seed??d.seed,caseStatus:{open:e.caseStatus.open,closed:e.caseStatus.closed},...i!==void 0?p(i):{}},l;try{l=g(a,n)}catch(s){if(s instanceof y)return{issues:s.issues};throw s}return{preparation:{options:n,objects:[...l.template.objects].sort((s,C)=>s.insertOrder-C.insertOrder).map(s=>({objectApiName:s.objectApiName,recordCount:s.recordCount,...s.optional===!0?{optional:!0}:{}})),tests:l.tests.length,caseStatusFrom:e.caseStatus.from==="org"?{from:"org"}:{from:"default",reason:e.caseStatus.reason},knowledge:t}}}function D(a){return async e=>{let r=await a.query(e),o=[...r.records];for(;!r.done&&r.nextRecordsUrl;)r=await a.queryMore(r.nextRecordsUrl),o.push(...r.records);return o}}export{h as a,w as b,k as c,c as d,E as e,T as f,v as g,D as h};
|
|
@@ -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}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-YAJQS3OL.mjs";import"./chunk-Z42PHCVZ.mjs";import"./chunk-H4OBZIX3.mjs";import"./chunk-V3R45ZWT.mjs";import"./chunk-NWOI25WY.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-JKT5YAQ2.mjs";import"./chunk-3SKLBRPL.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{b as AGENT_TEST_RUN_WAIT_MINUTES,a as AGENT_TEST_SPECS_DIR,e as agentTestApiName,f as agentTestCommands,d as agentTestSpecFileName,c as agentTestSpecYaml,g as nodeAgentTestSpecFiles,h as writeAgentTestSpec,i as writeScenarioTestSpec,j as yamlOf};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{
|
|
7
|
+
import{$c as l,_c as c,bd as d,cd as m}from"./chunk-ZQO5PDX5.mjs";var g=class{transform(n,r){let t=n;for(let o of r)t=p(t,o.type,o.config);return t}transformRecord(n,r){let t=d([{objectApiName:r.objectApiName,transformRules:r.transformRules}]);if(t.length>0)throw new Error(m(t));let o={...n},s=(r.externalIdField??"Id").toLowerCase(),R=a=>{let i=a.toLowerCase();return i!==s&&i!=="id"};for(let a of r.transformRules){let i=a.field?.trim();if(!i)throw new Error(l(c([r])));for(let f of h(o,i))R(f)&&(o[f]=p(o[f],a.type,a.config))}return o}};function h(e,n){let r=n.toLowerCase();return Object.keys(e).filter(t=>t.toLowerCase()===r)}function u(e){return(n,r)=>typeof n=="string"?e(n,r):n}function w(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string"||e.trim()==="")return;let n=Number(e);return Number.isNaN(n)?void 0:n}var b={uppercase:u(e=>e.toUpperCase()),lowercase:u(e=>e.toLowerCase()),trim:u(e=>e.trim()),truncate:u((e,n)=>e.slice(0,n.length??e.length)),prefix:u((e,n)=>`${n.prefix??""}${e}`),suffix:u((e,n)=>`${e}${n.suffix??""}`),replace:u((e,n)=>n.search?e.split(n.search).join(n.replace??""):e),regex_replace:u((e,n)=>n.regex?e.replace(y(n.regex),n.replace??""):e),map_value:(e,n)=>{let r=String(e??""),t=n.valueMap??{};return r in t?t[r]:e},default_value:(e,n)=>e==null||e===""?n.defaultValue??"":e,format_date:u((e,n)=>T(e,n.dateFormat??"YYYY-MM-DD")),format_number:(e,n)=>{let r=w(e);if(r===void 0)return e;let t=n.numberFormat??"0";return k(r,t)},custom_formula:(e,n)=>{let r=n.formula??"";return x(e,r)}};function y(e){try{return new RegExp(e,"g")}catch(n){throw new Error(`The pattern "${e}" of a Regex replace rule is no regular expression: `+(n instanceof Error?n.message:String(n)))}}function p(e,n,r){let t=b[n];return t(e,r)}function T(e,n){let r=new Date(e);if(isNaN(r.getTime()))return e;let t=r.getUTCFullYear().toString(),o=(r.getUTCMonth()+1).toString().padStart(2,"0"),s=r.getUTCDate().toString().padStart(2,"0");return n.replace("YYYY",t).replace("MM",o).replace("DD",s)}function k(e,n){let r=n.indexOf(".");if(r===-1)return Math.round(e).toString();let t=n.length-r-1;return e.toFixed(t)}function x(e,n){if(n.includes("VALUE")){let r=w(e);if(r!==void 0){let t=n.replace(/VALUE/g,r.toString());return N(t)??e}}return e}function N(e){let n=e.replace(/\s/g,""),r=/^(-?\d+(?:\.\d+)?)([-+*/])(-?\d+(?:\.\d+)?)$/.exec(n);if(!r)return;let t=Number(r[1]),o=r[2],s=Number(r[3]);switch(o){case"+":return t+s;case"-":return t-s;case"*":return t*s;case"/":return s===0?void 0:t/s;default:return}}export{g 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,b}from"./chunk-
|
|
7
|
+
import{a,b}from"./chunk-V3R45ZWT.mjs";import"./chunk-NWOI25WY.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as ScenarioCompileError,b as compileScenario};
|
|
@@ -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}from"./chunk-
|
|
7
|
+
import{a}from"./chunk-ZUBBEP75.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as ReferenceLinker};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import*as i from"node:fs";import*as t from"node:path";function c(e){let r=t.resolve(e);for(;;){if(i.existsSync(t.join(r,".git"))||i.existsSync(t.join(r,"pnpm-workspace.yaml")))return r;let o=t.dirname(r);if(o===r)throw new Error(`No repository root found above ${e}`);r=o}}function p(e){let r=t.resolve(e);return process.platform==="win32"?r.toLowerCase():r}function h(e){if(!/^[A-Za-z0-9_-]{1,128}$/.test(e))throw new Error(`Not an org id a file of the sas can be named after: "${e}"`);return e}var a=class extends Error{constructor(o,s){super(`Refusing output path inside the repository: ${o} (repo root: ${s}). Frozen-dataset exports, retained-ID lists and working manifests must live in a sas directory OUTSIDE the repo \u2014 versioning them would create a real\u2194anonymized correspondence table.`);this.resolvedPath=o;this.repoRoot=s;this.name="InsideRepoPathError"}resolvedPath;repoRoot},l=class{repoRoot;constructor(r){this.repoRoot=r?t.resolve(r):c(process.cwd())}isInsideRepo(r){let o=p(this.repoRoot),s=p(r);if(s===o)return!0;let n=t.relative(o,s);return n!==""&&!n.startsWith("..")&&!t.isAbsolute(n)}assertOutsideRepo(r){if(this.isInsideRepo(r))throw new a(t.resolve(r),this.repoRoot);return t.resolve(r)}};export{c as a,h as b,a as c,l as d};
|
|
@@ -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 X,e as Y}from"./chunk-
|
|
7
|
+
import{b as X,e as Y}from"./chunk-NWOI25WY.mjs";import{a as G,b as q,e as J,f as Q,j as L}from"./chunk-FQGHL7GR.mjs";import{Ha as A,Ja as N,Ka as Z,La as W}from"./chunk-ZQO5PDX5.mjs";var O=class extends Error{constructor(t){super(`The scenario cannot be compiled: ${t.join("; ")}`);this.issues=t;this.name="ScenarioCompileError"}issues},ee="2026-10-28T00:00:00.000Z",x={subject:255,description:32e3,commentBody:4e3,articleTitle:255,articleSummary:1e3},ie=new Set(["Phone"]);function $e(e,n={}){let t=Z.safeParse(e),a=W.safeParse(n);if(!t.success||!a.success)throw new O([...t.error?.issues.map(i=>te(["pack",...i.path],i))??[],...a.error?.issues.map(i=>te(["options",...i.path],i))??[]]);let r=n.customers??e.customers.count;if(r<e.topics.length)throw new O([`options.customers: ${r} customer(s) for ${e.topics.length} topics: each topic's utterances are said about a customer's open case on it`]);let s=n.seed??A.seed,u=n.historyPerCustomer??A.historyPerCustomer,l=n.caseStatus??A.caseStatus,c=ge(e.language),o=ce(),p=e.id,m=e.topics,f=fe(p,r,c,s),S=f.map((i,d)=>({key:i.key,values:o.row({Name:i.company,Industry:e.customers.industry,Type:"Customer - Direct",Phone:L(c,2*d),Website:`https://www.${se(i.company)}`})})),$=f.map((i,d)=>({key:i.key,parentKey:i.key,values:o.row({FirstName:i.firstName,LastName:i.lastName,Email:i.email,Phone:L(c,2*d+1)})})),T=m.map(()=>0),k=[],M=[],D=[],z=[],F=i=>`${p}-article-${m[i].key}`;for(let[i,d]of f.entries()){let I=[...Array.from({length:u},(g,h)=>({topicIndex:(i+1+h)%m.length,key:`${d.key}-h${h+1}`,open:!1})),{topicIndex:i%m.length,key:`${d.key}-open`,open:!0}];for(let{topicIndex:g,key:h,open:j}of I){let U=m[g].caseTemplates,w=U[T[g]++%U.length],v=o.text(P(w.subject,d),x.subject),V={...d,caseSubject:v};k.push({key:h,parentKey:d.key,values:o.row({Subject:v,Description:o.text(P(w.description,V),x.description),Status:j?l.open:l.closed,Priority:w.priority,Origin:w.origin})}),M.push(...le(h,w,j,V,o)),j?D.push({key:h,subject:v,topicIndex:g,customer:d}):z.push({caseKey:h,articleKey:F(g)})}}let y=ue(n),_=[],oe=m.map((i,d)=>{if(!y)return;let I=i.article.facts.map(h=>o.text(h)),g=me(o.text(i.article.body),I,y);if(typeof g=="string")return g;_.push(`pack.topics[${d}].article.facts[${g.unfit}]: the fact "${i.article.facts[g.unfit]}" does not fit, with the facts before it, in the ${y.max} characters of ${y.name}, the field the article's body goes to in this org: shorten the facts, or give Knowledge a longer field for the body`)});if(_.length>0)throw new O(_);let H=[...m.map((i,d)=>({key:F(d),values:ne(i.article,`${p}-${i.key}-${s}`,e,o,y&&{name:y.name,text:oe[d]??""})})),{key:`${p}-decoy-article`,values:ne(e.decoy,`${p}-${s}-decoy`,e,o,y&&{name:y.name,text:de(o.text(e.decoy.body),o.text(e.decoy.summary),y)})}],ae={id:`scenario-${p}`,name:o.text(e.name),description:o.text(e.businessContext),version:1,strategy:"template",objects:[R("Account",0,S),R("Contact",1,$),R("Case",2,k),R("CaseComment",3,M),{...R("Knowledge__kav",4,H),optional:!0}],relations:[B("Contact","AccountId","Account"),B("Case","ContactId","Contact"),B("CaseComment","ParentId","Case")],tags:["scenario",p],createdAt:ee,updatedAt:ee};return{packId:p,seed:s,template:ae,tests:pe(e,D,F,H,o),closedCaseArticles:z}}function te(e,n){return`${e.reduce((a,r)=>typeof r=="number"?`${a}[${r}]`:`${a}.${String(r)}`,"").replace(/^\./,"")}: ${n.message}`}function ce(){let e=X(),n=new Map,t=r=>{let s=n.get(r);if(s!==void 0)return s;let u=e(r);return n.set(r,u),u},a=(r,s)=>Y(r,s,t);return{text(r,s){let u=a({text:r},new Set).text;return E(typeof u=="string"?u:r,s)},row(r){return a(r,ie)}}}function E(e,n){if(n===void 0||e.length<=n)return e;let t=e.slice(0,n);if(/\s/.test(e.charAt(n)))return t.trimEnd();let a=t.search(/\s\S*$/);return a>0?t.slice(0,a).trimEnd():t}function P(e,n){return e.replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g,(t,a)=>n[a]??t)}function le(e,n,t,a,r){return(t?[n.followUp]:n.resolution).map((u,l)=>({key:`${e}-${l+1}`,parentKey:e,values:{CommentBody:r.text(P(u,a),x.commentBody),IsPublished:!1}}))}function ne(e,n,t,a,r){let s={Title:a.text(e.title,x.articleTitle),UrlName:n,Summary:a.text(e.summary,x.articleSummary),Language:t.language,IsVisibleInPkb:!1,IsVisibleInCsp:!1,IsVisibleInPrm:!1};return r&&(s[r.name]=r.text),s}function ue(e){let n=e.articleBodyField;if(n===void 0)return;let t=e.articleBodyLength??(n==="Summary"?x.articleSummary:void 0);return{name:n,...t!==void 0?{max:t}:{},html:e.articleBodyHtml===!0}}function K(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function C(e,n){return n.html?e.map(t=>`<p>${re(t)}</p>`).join(""):e.join(`
|
|
8
8
|
|
|
9
9
|
`)}function re(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function b(e,n){return n.max===void 0||e.length<=n.max}function me(e,n,t){let a=K(e),r=t.html?C(a,t):e;if(b(r,t))return r;let s=a.filter(c=>n.some(o=>N(c,o)));if(n.every(c=>N(s.join(`
|
|
10
10
|
|
|
@@ -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 A}from"./chunk-5LFSFYFJ.mjs";import{a as z,h as p}from"./chunk-TZE3Y7IQ.mjs";import{b as S}from"./chunk-CA5NAXSU.mjs";import{
|
|
7
|
+
import{a as A}from"./chunk-5LFSFYFJ.mjs";import{a as z,h as p}from"./chunk-TZE3Y7IQ.mjs";import{b as S}from"./chunk-CA5NAXSU.mjs";import{ic as C}from"./chunk-ZQO5PDX5.mjs";import{b as g,f as b,k as w,l as m,o as j}from"./chunk-WZQEK4WT.mjs";function H(r,n){return{describe:e=>r.describe(e),describeGlobal:()=>r.describeGlobal(),query:async e=>{let t=await r.query(e);return A(r.limitInfo,n),{totalSize:t.totalSize,records:t.records}},update:(e,t)=>r.sobject(e).update(t,{headers:C()}),destroy:(e,t)=>r.sobject(e).destroy(t)}}var u=200,P=30,I=100,M=4,y=10,q=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function B(r){return typeof r=="string"&&q.test(r)}function k(r,n=u){let e=[];for(let t=0;t<r.length;t+=n)e.push(r.slice(t,t+n).map(s=>`'${z(s)}'`).join(", "));return e}var L=m({success:b(),id:g().nullish(),errors:w(j([m({message:g()}).loose(),g()])).optional()}).loose(),W=m({name:g(),label:g(),queryable:b().optional(),createable:b().optional(),layoutable:b().optional()}).loose(),_=m({sobjects:w(W)}).loose();async function F(r){let n=_.parse(await r.describeGlobal());return new Map(n.sobjects.filter(e=>e.queryable===!0&&e.createable===!0&&e.layoutable===!0).map(e=>[e.name,e.label]))}async function E(r,n){let e=new Array(r.length),t=0,s=async()=>{for(;t<r.length;){let i=t++;e[i]=await r[i]()}};return await Promise.all(Array.from({length:Math.min(n,r.length)},s)),e}async function Q(r,n,e,t){if(e.length===0)return{related:[],uncounted:[]};let s=(n.childRelationships??[]).filter(o=>o.cascadeDelete===!0&&t.has(o.childSObject)),i=s.slice(0,P),a=new Set(s.slice(P).map(o=>t.get(o.childSObject)??o.childSObject)),l=k(e),h=await E(i.map(o=>async()=>{try{let c=p(o.childSObject),d=p(o.field),O=0;for(let T of l)O+=(await r.query(`SELECT COUNT() FROM ${c} WHERE ${d} IN (${T})`)).totalSize;return{relationship:o,records:O}}catch{return{relationship:o,records:null}}}),M),f=new Map;for(let{relationship:o,records:c}of h){let d=t.get(o.childSObject)??o.childSObject;if(c===null){a.add(d);continue}f.set(o.childSObject,(f.get(o.childSObject)??0)+c)}return{related:[...f].filter(([,o])=>o>0).map(([o,c])=>({objectApiName:o,label:t.get(o)??o,records:c})).sort((o,c)=>c.records-o.records||o.label.localeCompare(c.label)),uncounted:[...a].sort()}}async function Z(r,n,e,t,s=1){let i=p(n),a=[...new Set(["Id",...e])].map(p),l=a.join(", "),h=a.length>I?u/4:u,f=await E(k(t,h).map(o=>()=>r.query(`SELECT ${l} FROM ${i} WHERE Id IN (${o})`)),s),R=[];for(let o of f)for(let c of o.records){if(typeof c!="object"||c===null)continue;let d={...c};delete d.attributes,R.push(d)}return R}function x(r,n,e){let t=Array.isArray(r)?r:[r];for(let s of t){let i=L.safeParse(s);if(i.success&&i.data.success){e.done++;continue}if(e.failed++,e.errors.length<y){let a=i.success?i.data.errors?.[0]:void 0,l=typeof a=="string"?a:a?.message??"The org gave no reason.";e.errors.push({objectApiName:n,message:l})}}}async function J(r,n,e,t){let s={done:0,failed:0,errors:[]};for(let i=0;i<e.length&&!t?.aborted;i+=u){let a=e.slice(i,i+u);try{x(await r.update(n,[...a]),n,s)}catch(l){s.failed+=a.length,s.errors.length<y&&s.errors.push({objectApiName:n,message:S(l)})}}return s}async function V(r,n,e,t){let s={done:0,failed:0,errors:[]};for(let i=0;i<e.length&&!t?.aborted;i+=u){let a=e.slice(i,i+u);try{x(await r.destroy(n,[...a]),n,s)}catch(l){s.failed+=a.length,s.errors.length<y&&s.errors.push({objectApiName:n,message:S(l)})}}return s}function D(r,n){return n===0?"success":r===0?"failure":"partial"}function Y(r){let n=r.reduce((t,s)=>t+s.counts.done,0),e=r.reduce((t,s)=>t+s.counts.failed,0);return{status:D(n,e),done:n,failed:e,objects:r.map(t=>({objectApiName:t.objectApiName,done:t.counts.done,failed:t.counts.failed})),errors:r.flatMap(t=>t.counts.errors).slice(0,y)}}export{H as a,u as b,B as c,k as d,F as e,E as f,Q as g,Z as h,J as i,V as j,Y 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,b,c,d,e,f,g}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e,f,g}from"./chunk-FKK5YBGZ.mjs";import"./chunk-J24TIGSI.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{c as acquireEnvLock,g as checkpointLockRefusal,a as defaultEnvLocksDir,b as envLockFileOf,d as envLockHolder,f as envLockLine,e as envLockRefusal};
|
|
@@ -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{h as M,i as T}from"./chunk-
|
|
7
|
+
import{h as M,i as T}from"./chunk-PYRZFUVU.mjs";import{p as b}from"./chunk-ICIYL45C.mjs";import{Cc as k,rc as _,sc as h,tc as p,uc as R,yc as C,zc as S}from"./chunk-ZQO5PDX5.mjs";async function Y(r,e){try{let[c,i]=await Promise.all([r(R),e(R)]),d=c[0]?.Id,a=i[0]?.Id;return typeof d=="string"&&typeof a=="string"?{source:d,target:a}:void 0}catch{return}}function v(r,e){return r===h||e.some(c=>typeof c[p]=="string")}var K=[p,C,S];function A(r,e,c,i,d=()=>!1){let a={...e,standsFor:new Map,standardFirst:0,standardMatched:!1,prices:[],leftIn:new Map};if(!c)return a;let o=e.records.map((t,s)=>s),m=t=>({records:t.map(s=>e.records[s]),sources:t.map(s=>e.sources[s]),sourceIds:t.map(s=>e.sourceIds[s])});if(r===h){let t=o.filter(s=>e.sourceIds[s]!==c.source);return t.length===o.length?a:{...m(t),standsFor:new Map,standardFirst:0,standardMatched:!0,prices:[],leftIn:new Map}}if(r!==_)return a;let l=o,I=new Map,P=new Map,O=[];if(i){let{target:t}=i,s=e.sources.filter(n=>!K.some(f=>{let u=n[f];return typeof u=="string"&&u!==""&&d(u)})),E=n=>t.active.has(n)?n:b(void 0,t)?.to,g=M({prices:s,standardBookId:c.source,sellingModels:s.some(n=>typeof n[S]=="string"),writtenIn:E,active:t.active},[]),B=new Set(g.standsFor.keys());l=o.filter(n=>{let f=e.sourceIds[n];return f===void 0||!B.has(f)});let D=new Map(s.map(n=>[n.Id,n[k]]));for(let[n,f]of g.standsFor){I.set(n,f);let u=D.get(n),w=typeof u=="string"?E(u):void 0;typeof u=="string"&&w!==void 0&&P.set(n,{from:u,to:w})}O=T(g.said)}let y=t=>e.sources[t][p]===c.source,F=[...l.filter(y),...l.filter(t=>!y(t))];return{...m(F),standsFor:I,standardFirst:l.filter(y).length,standardMatched:!1,prices:O,leftIn:P}}function Q(r,e){let c=r.prices.map(i=>({...i}));for(let i of e){let d=r.leftIn.get(i),a=d&&(c.find(o=>o.from===d.from&&o.to===d.to&&o.how==="replaced"&&!o.forLines)??c.find(o=>o.from===d.from&&o.to===d.to&&o.how==="replaced"));a&&a.prices--}return c.filter(i=>i.prices>0)}function q(r,e){return e===1?`1 ${r} record held back, not sent: read in a currency the target org does not hold active, it stands for the source's own price of its product and price book in the currency written, which this run did not write.`:`${e} ${r} records held back, not sent: read in a currency the target org does not hold active, they stand for the source's own prices of their product and price book in the currency written, which this run did not write.`}var H="The standard price book is matched to the target org's, never written.";function $(r,e){return e.prices.length===0&&!e.standardMatched?r:{...r,...e.prices.length>0?{pricesSettled:[...e.prices]}:{},...e.standardMatched?{standardPricebookMatched:!0}:{}}}export{Y as a,v as b,A as c,Q as d,q as e,H as f,$ as g};
|
|
@@ -4,6 +4,6 @@ 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 B}from"./chunk-BOGNK4LV.mjs";import{d as k,e as A,f as b}from"./chunk-
|
|
7
|
+
import{c as B}from"./chunk-BOGNK4LV.mjs";import{d as k,e as A,f as b}from"./chunk-JQZTMFO7.mjs";import{Rb as D,Sb as P,Tb as O,Yb as S,dc as v,hc as x,kc as L}from"./chunk-JFNLKHY6.mjs";import{da as w}from"./chunk-KIMQQ6JQ.mjs";import{Dd as R,Ed as g,Ld as f,Td as p}from"./chunk-ZQO5PDX5.mjs";var C=["undelete","insert","update","delete"],M={SingleEmail:{one:"single email",more:"single emails"},DailyWorkflowEmails:{one:"workflow email",more:"workflow emails"}};function U(e,t){let n=M[t];return`${e} ${e===1?n.one:n.more}`}var I={rewind:{what:"This rewind",then:"rewind again"},undo:{what:"This undo",then:"undo the rewind again"}};function _(e){return e.toGiveBack.records+e.toBringBack.inBin+e.toBringBack.withParent}var N="Order";function T(e){return e.toDelete.createdSince+e.toDelete.broughtBackSince+e.toDelete.comesBackWithParent+(e.toBringBack.carriers??0)}function $(e){return e.objectApiName===N?T(e):0}function W(e){return e.deleted+e.withParentDeleted+e.nextPassDeleted}function F(e){return e.objectApiName===N?W(e):0}function G(e){return w[e.objectApiName]!==void 0?e.toRecreate??0:0}function j(e){return w[e.objectApiName]!==void 0?e.recreated:0}function K(e){return e.flatMap(t=>h(t.objectApiName,{undelete:t.toBringBack.inBin+t.toBringBack.withParent+t.toBringBack.deletedWhileTaken+(t.toBringBack.carriers??0),insert:t.toRecreate??0,update:_(t)+G(t)+$(t),delete:T(t)}))}function Z(e){return e.flatMap(t=>h(t.objectApiName,{undelete:t.broughtBack+t.backWithParent+(t.carriers??0),insert:t.recreated,update:t.givenBackFirst+t.givenBackAfter+t.givenBackNextPass+j(t)+F(t),delete:W(t)}))}function ee(e,t=[],n=[]){let i=a=>{let o=new Map;for(let{objectApiName:m,count:d}of a)o.set(m,(o.get(m)??0)+d);return o},c=i(t),s=i(n);return[...new Set([...e.map(a=>a.objectApiName),...c.keys(),...s.keys()])].flatMap(a=>{let o=e.find(m=>m.objectApiName===a);return h(a,{undelete:o?.deleted??0,insert:0,update:(o?.givenBack??0)+(s.get(a)??0),delete:(o?.broughtBack??0)+(c.get(a)??0)})})}function h(e,t){return C.filter(n=>t[n]>0).map(n=>({objectApiName:e,write:n,records:t[n]}))}function te(e,t){let n=new Set(e.filter(i=>i.records>0).map(i=>`${i.objectApiName}
|
|
8
8
|
${i.write}`));return S(t,(i,c)=>n.has(`${i}
|
|
9
9
|
${c}`),"the org's")}function ne(e,t){return t===void 0?"":`The emails it sends as the ${e} writes were not counted against its daily limits, as what sends them was not read (${t}). `}function y(e){return typeof e.unread=="string"}function ie(e,t,n){let i=!y(n)&&D(n),c=!y(n)&&P(n),s=new Map;for(let r of C){let a=R(t,r);if(a.length===0)continue;let o=O(a,i,c),m=new Set(a.filter(d=>d.limit==="DailyWorkflowEmails").map(d=>d.objectApiName));for(let{objectApiName:d,records:E}of e.filter(l=>l.write===r))for(let l of o.filter(u=>u.objectApiName===d)){let u=s.get(l.limit)??{limit:l.limit,emails:0,objects:[],verdict:"fits"};u.emails+=E*l.perRecord,u.objects.push({objectApiName:d,write:r,records:E,perRecord:l.perRecord,sentBy:[...l.sentBy]}),i&&l.limit==="SingleEmail"&&m.has(d)&&(u.alertsCounted=!0),s.set(l.limit,u)}}return[...s.values()].map(r=>{if(y(n))return{...r,verdict:"unread",unread:n.unread};let a=n[r.limit];return a?{...r,verdict:r.emails>a.remaining?"exceeds":"fits",remaining:a.remaining,max:a.max}:{...r,verdict:"unread",unread:`the org's limits list no ${r.limit}`}})}function re(e,t,n){let i=t.filter(r=>r.verdict==="exceeds");if(i.length===0)return;let c=i.map(r=>`about ${U(r.emails,r.limit)}`+(r.alertsCounted?" (its email alerts among them, as a Developer Edition counts them)":"")+`, ${r.remaining??0} of ${r.max??0} left today`).join("; "),s=I[e];return{code:"EMAILS",message:`${s.what} would make ${n} send ${c}: past them, each record whose flow fails in the save is refused (CANNOT_EXECUTE_FLOW_TRIGGER), and the org's own emails stop for the rest of the day. Turn off what sends them, or assign the user a bypass that keeps it quiet, then ${s.then}. No record was written.`}}function ae(e){let t=f(e.steps),n=g(p(e.automation,e.plan,t),{writes:t}),i=v(e.automation.unread);return{senders:n,...i!==void 0?{sendersUnread:i}:{}}}function q(e){let t=e.mayMute&&e.plan===void 0&&e.senders.length>0?A(e.automation,{writes:f(e.steps)}):[],n=x({senders:e.senders,...e.sendersUnread!==void 0?{sendersUnread:e.sendersUnread}:{},...e.reading!==void 0?{reading:e.reading}:{},accepted:e.accepted,target:e.orgName,run:e.act,muteQuiets:t,keepsAddresses:!0});return n.stop?{gate:n,refusal:{code:"EMAILS_DELIVERED",message:n.stop.message}}:{gate:n}}async function se(e){let t=f(e.steps),n=await k({running:p(e.automation,e.plan,t),writes:t,read:e.read});return{ofRun:n,...q({...e,senders:n.senders,...n.sendersUnread!==void 0?{sendersUnread:n.sendersUnread}:{},...n.read!==void 0?{reading:n.read.reading}:{}})}}function oe(e){let t=f(e.steps),n=g(p(e.automation,b(e.plan,e.held),t),{writes:t}),i=L({planned:e.planned,held:n,...e.reading!==void 0?{reading:e.reading}:{},accepted:e.accepted,target:e.orgName,run:e.act});return i?{code:"EMAILS_DELIVERED",message:i.message}:void 0}var Q=", or run it again once the lease can assign them",V="--mute-automation keeps quiet";function de(e,t,n){if(e.code!=="EMAILS_DELIVERED")return e;let i=t==="undo"?"Tick the box for these emails in the undo's confirmation to undo all the same":e.message.includes(Q)?"Untick Mute automation to be asked about them and rewind all the same":`Tick "Let ${n} send these emails" in the preview to rewind all the same`;return{...e,message:B(e.message,t,i).replace(V,"Mute automation keeps quiet")}}export{U as a,_ as b,$ as c,F as d,G as e,j as f,K as g,Z as h,ee as i,te as j,ne as k,ie as l,re as m,ae as n,q as o,se as p,oe as q,de as r};
|
|
@@ -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{g as m,h as S,i as E,j as x}from"./chunk-
|
|
7
|
+
import{g as m,h as S,i as E,j as x}from"./chunk-L4INJ5TZ.mjs";import{b as C}from"./chunk-CA5NAXSU.mjs";import{le as T,z as R}from"./chunk-ZQO5PDX5.mjs";import{statfs as q}from"node:fs/promises";var re=["reads","leasePlan","stillRunning","deliverabilityRead","question","checkpointTake","leaseAcquire","afterLeaseCheck","write","leaseRelease","recordTypeReadBack","result"];function ie(e){let t=[],n=s=>e.indexOf(s),r=s=>e.lastIndexOf(s),o=(s,c,d,p=r(s),l=n(c))=>{p>=0&&l>=0&&p>l&&t.push(d)};o("leasePlan","stillRunning","what still runs was computed before the lease was planned"),o("stillRunning","deliverabilityRead","the deliverability was read before what still runs was known"),o("deliverabilityRead","question","the deliverability was read after the question it belongs to",n("deliverabilityRead")),o("question","checkpointTake","the checkpoint was taken before the last question"),o("question","leaseAcquire","the lease was taken before the last question"),o("checkpointTake","leaseAcquire","the lease was taken before the checkpoint"),o("leaseAcquire","afterLeaseCheck","the lease was checked before it was taken"),o("checkpointTake","write","a record was written before the checkpoint was taken"),o("leaseAcquire","write","a record was written before the lease was taken"),o("afterLeaseCheck","write","a record was written before the lease was checked"),o("write","leaseRelease","the lease was given back before the last write"),o("write","recordTypeReadBack","the record types were read back before the last write"),o("leaseRelease","recordTypeReadBack","the record types were read back while the lease was held"),n("leaseAcquire")>=0&&n("leaseRelease")<0&&t.push("the lease was never given back");let i=n("result");return i>=0&&e.slice(i+1).some(s=>s!=="result")&&t.push("the run went on past its result"),t}var W={insert:"go in",update:"are updated",delete:"are deleted",undelete:"come back"},L={flow:"flow",process:"process",workflowRule:"workflow rule",trigger:"Apex trigger"},h=3,v=/__e$/i;function u(e){return e.toLowerCase()}function A(e){let t=new Set,n=[];for(let r of e)t.has(u(r))||(t.add(u(r)),n.push(r));return n}function F(e){let t=e.slice(0,h),n=e.length-t.length,r=`${t.join("; ")}${n>0?`; and ${n} more`:""}`;return`${r.charAt(0).toUpperCase()}${r.slice(1)}.`}function I(e){let t=A(e.written),n=new Set(t.map(u)),r=new Map;for(let i of e.running.firing)if(i.flow!==void 0)for(let s of i.flow.creates??[]){let c=u(s);if(n.has(c)||v.test(s))continue;let d=r.get(c);d===void 0&&(d={objectApiName:s,clauses:[],by:[]},r.set(c,d));let p=`the target's ${L[i.kind]} '${i.name}' creates ${s} records as ${i.objectApiName} records ${W[i.write]}`;d.clauses.includes(p)||(d.clauses.push(p),d.by.push({kind:i.kind,name:i.name,objectApiName:i.objectApiName,write:i.write}))}let o=[...r.values()].map(({objectApiName:i,clauses:s,by:c})=>({objectApiName:i,code:"createdByAutomation",reason:F(s),creators:c.slice(0,h),...c.length>h?{moreCreators:c.length-h}:{}}));return{written:t,added:o,excluded:A(e.request.excluded??[]),picked:[...t,...o.map(({objectApiName:i})=>i)]}}var M={[u(m)]:{code:"files",reason:"Files, which every checkpoint of picked objects holds: a rewind deletes the files added since to the records it holds."},[u(x)]:{code:"attachments",reason:"Attachments, which every checkpoint of picked objects holds: a rewind deletes the attachments added since."}},K="Held as every checkpoint of picked objects holds it.",U={[u("AccountContactRelation")]:"Account contact relations, which the platform writes with each contact: a rewind deletes those made since with their contacts, and keeps no contact for them."},J=new Set([E,S].map(u)),z="A rewind leaves its records as they are.",k="No record was read.";function w(e,t,n){let r=new Map(t.map(a=>[u(a),a])),o=r.has(u(m)),i=a=>r.has(u(a))||o&&J.has(u(a)),s=[],c=a=>{let f=r.get(u(a));f!==void 0&&!s.includes(f)&&s.push(f)};for(let a of e.written)c(a);for(let{objectApiName:a}of e.added)c(a);for(let a of t)c(a);let d=new Set(e.picked.map(u)),p=[...e.added.flatMap(a=>{let f=r.get(u(a.objectApiName));return f===void 0?[]:[{...a,objectApiName:f}]}),...t.filter(a=>!d.has(u(a))).map(a=>({objectApiName:a,...M[u(a)]??{code:"heldUnasked",reason:U[u(a)]??K}}))],l=n.filter(({objectApiName:a})=>!i(a)).map(({objectApiName:a,reason:f,code:b,detail:y,records:O,limit:B})=>({objectApiName:a,...b!==void 0?{code:b}:{},reason:`${f} ${z}`,...y!==void 0?{detail:y}:{},...O!==void 0?{records:O}:{},...B!==void 0?{limit:B}:{}})),H=new Map(n.map(({objectApiName:a,reason:f})=>[u(a),f]));return{objects:s,added:p,notHeld:l,holds:i,why:a=>H.get(u(a))}}function g(e,t,n){return e.written.some(o=>t.holds(o))?void 0:e.written.length===0?{code:"NOTHING_HELD",message:`The run names no object it writes: a checkpoint before it would hold nothing a rewind could take back. ${n}`}:{code:"NOTHING_HELD",message:`The checkpoint before the run would hold none of the objects the run writes, so a rewind to it could take nothing of the run back. ${e.written.map(o=>`${o}: ${t.why(o)??"The take did not hold it."}`).join(" ")} ${n}`}}function G(e,t,n){let r={state:"planned",estimate:t.estimate,keepDays:n};if(t.objects.length===0&&t.leftOut.length===0&&t.refusal!==void 0)return{...r,objects:[],added:[],notHeld:[],refusal:t.refusal};let o=w(e,t.objects.map(({objectApiName:s})=>s),t.leftOut),i=g(e,o,k)??t.refusal;return{...r,objects:o.objects,added:o.added,notHeld:o.notHeld,...i!==void 0?{refusal:i}:{}}}var V=1.1;function N(e){return`${(e/(1024*1024)).toFixed(1)} MB`}function P(e,t){if(!(t===void 0||t>=Math.ceil(e*V)))return{code:"DISK",message:`The checkpoint before the run takes about ${N(e)} on this machine, and its disk has ${N(t)} free, less than that and a tenth more: make room, or leave objects out of the checkpoint. ${k}`}}async function _(e){try{let t=await q(e);return Number(t.bavail)*Number(t.bsize)}catch{return}}var Y={forge:"Forge run",sync:"Sync run",seed:"Seed run",autopilot:"Autopilot run",frozen:"Frozen Dataset load",empty:"emptying",replay:"checkpoint replay"};function Q(e){return`Before ${Y[e]} ${T}`}function se(e,t){let{min:n,max:r}=R,o=i=>typeof i=="number"&&Number.isInteger(i)&&i>=n&&i<=r;if(e!==void 0){if(!o(e))throw new RangeError(`Not a number of days to keep a checkpoint, ${n} to ${r}: ${e}`);return e}return o(t)?t:R.default}function X(e,t){return{mode:"picked",objects:e.picked,...e.excluded.length>0?{excluded:e.excluded}:{},nameWithDate:Q(t.module),keepDays:t.keepDays,unprovenLeftOut:!0,beforeRun:{module:t.module,operationId:t.operationId,tool:t.tool}}}function j(e,t){let{checkpoint:n}=t,r=w(e,n.objects.map(({objectApiName:o})=>o),n.scope.leftOut);return{state:"taken",checkpointId:n.checkpointId,name:n.name,takenAt:n.takenAt,expiresAt:n.expiresAt,objects:r.objects,records:n.objects.reduce((o,i)=>o+i.records,0),bytes:n.bytes,requests:t.requests?.total??t.estimate.apiRequests,added:r.added,notHeld:r.notHeld}}function D(e){return`${e.operation==="take"?"a checkpoint is being taken":e.operation==="rewind"?"a rewind is writing":e.operation==="undo"?"an undo is writing":e.operation==="empty"?"an emptying of its objects is writing":"SandForge is deleting checkpoints"} (process ${e.pid} on ${e.host})`}async function Z(e,t,n){let r=w(t,n.checkpoint.objects.map(({objectApiName:c})=>c),n.checkpoint.scope.leftOut);if(g(t,r,"")===void 0)return{taken:!0,checkpoint:j(t,n)};let o=await e.delete(n.checkpoint.checkpointId),i=o.outcome==="busy"?`It is kept all the same, as ${D(o.holder)}: delete it from the Checkpoints page once that has ended. Nothing was written.`:"It was deleted again; nothing was written.",s=g(t,r,i);return s===void 0?{taken:!0,checkpoint:j(t,n)}:{taken:!1,refusal:s}}function $(e,t,n){return{...e,...X(t,n)}}async function ae(e,t,n){let{scopeCheckpoint:r}=await import("./chunk-FZF23M6R.mjs"),o=I(n),i=await r(e,$(t,o,n)),s=G(o,i,n.keepDays);if(s.refusal!==void 0)return s;let c=P(s.estimate.bytes,await(e.freeBytes??_)(e.store.root));return c===void 0?s:{...s,refusal:c}}async function ce(e,t,n,r){let o=await import("./chunk-FZF23M6R.mjs"),i=I(n);if(r!==void 0){let c=P(r.estimate.bytes,await(e.freeBytes??_)(e.store.root));if(c!==void 0)return{taken:!1,refusal:c}}let s;try{s=await o.takeCheckpoint(e,$(t,i,n))}catch(c){if(c instanceof o.CheckpointTakeStopped)return{taken:!1,stopped:!0};throw c}return s.taken?Z(e.store,i,s):{taken:!1,refusal:s.refusal}}async function ue(e,t,n){if(n)return{info:t};let r=await e.delete(t.checkpointId);return r.outcome==="busy"?{info:t,notDeleted:`The checkpoint '${t.name}' taken before the run is kept, though the run wrote nothing: ${D(r.holder)}. Delete it from the Checkpoints page once that has ended.`}:{info:{state:"deleted",deleted:"nothingWritten"}}}function de(e){return`The checkpoint before the run was refused: ${e.message.endsWith(k)?e.message.slice(0,-k.length).trimEnd():e.message} Nothing was written. Untick Checkpoint first to run without it, or fix what refuses it.`}function fe(e){return`The checkpoint before the run could not be taken: ${C(e).replace(/\.$/,"")}. Nothing was written.`}var pe="The checkpoint taken before the run was deleted: the run wrote nothing.";function le(e){return`Taking the checkpoint first (${Math.round(e)}%)`}export{re as a,ie as b,I as c,G as d,V as e,P as f,_ as g,Q as h,se as i,X as j,j as k,Z as l,ae as m,ce as n,ue as o,de as p,fe as q,pe as r,le as s};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
+
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
+
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
+
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
+
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
+
import{e as a,f as b,g as c,h as d,i as e,j as f,k as g,l as h,m as i,n as j,o as k,p as l,q as m,r as n}from"./chunk-JESRFE2Z.mjs";import"./chunk-CBL42DUU.mjs";import"./chunk-MKTXJCXN.mjs";import"./chunk-RCYEBY42.mjs";import"./chunk-AUS6NFLZ.mjs";import"./chunk-DBBPDSFN.mjs";import"./chunk-GBGHJTPC.mjs";import"./chunk-YMDFF657.mjs";import"./chunk-7WSLT5VX.mjs";import"./chunk-YT22LMF7.mjs";import"./chunk-ZXFL2MSN.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-ISSP2FZ5.mjs";import"./chunk-XU25YA46.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-IVZJSDJD.mjs";import"./chunk-VZT4E2OJ.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-O2PUGRNW.mjs";import"./chunk-7SDZR6SR.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-3SKLBRPL.mjs";import"./chunk-QSRAEUGZ.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-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-XZISAZA6.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{d as NOT_REMADE_WORDS,b as OTHERS_DELETION_WORDS,c as OUT_OF_REACH_WORDS,j as REWIND_AUTOMATION_LIFTED_BY,a as REWIND_RESIDUAL_IDS,i as RewindStopped,k as automationUnread,m as counted,h as heldWhile,l as inRewindWords,g as muteOfSteps,e as notAskedWords,n as rewindOrg,f as rewindOrgOf};
|
|
@@ -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}from"./chunk-
|
|
7
|
+
import{a,b}from"./chunk-XO5FBOQF.mjs";import"./chunk-FQGHL7GR.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as FakerFallback,b as generateByMethod};
|
|
@@ -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{e as R}from"./chunk-
|
|
7
|
+
import{e as R}from"./chunk-ZUTUYBNW.mjs";var h="FIELD_CUSTOM_VALIDATION_EXCEPTION",y="INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST",_="FIELD_FILTER_VALIDATION_EXCEPTION",w="INACTIVE_OWNER_OR_USER",E=/\[(005[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?)\]/,F="005",b=["CreatedById","LastModifiedById"];function A(t,e){if(t.statusCode!==w)return;let r=c(e,"OwnerId"),n=r===void 0?void 0:e[r],o=E.exec(t.message)?.[1];if(!(typeof n!="string"||o===void 0))return n.slice(0,15)===o.slice(0,15)?o.slice(0,15):void 0}function D(t,e,r){let n=c(e,"OwnerId");if(n===void 0||n.toLowerCase()===r?.toLowerCase())return;let o=e[n];if(!(typeof o!="string"||!o.startsWith(F)||t.fields.some(s=>s.toLowerCase()!=="ownerid")||!(E.test(t.message)?A(t,e)!==void 0:b.every(s=>c(e,s)===void 0))))return{field:n,refusedBy:"inactive-owner",reason:R(t)}}var S=new Map([[h,"validation-rule"],[y,"restricted-picklist"],[_,"lookup-filter"]]);function T(t){return t!=null&&t!==""}function c(t,e){let r=e.toLowerCase();return Object.keys(t).find(n=>n.toLowerCase()===r&&T(t[n]))}function P(t,e,r,n,o){if(!t||t.length===0)return;let i=new Map;for(let a of t){let s=S.get(a.statusCode);if(!s){let d=o?.inactiveOwner===!0&&a.statusCode===w?D(a,e,r):void 0;if(!d)return;i.has(d.field)||i.set(d.field,d);continue}let u=a.fields.map(d=>c(e,d)).filter(d=>d!==void 0&&d.toLowerCase()!==r?.toLowerCase());if(u.length===0||s==="lookup-filter"&&!u.every(d=>n?.(d)===!0))return;for(let d of u)i.has(d)||i.set(d,{field:d,refusedBy:s,reason:R(a)})}return[...i.values()]}function K(t){return(t??[]).some(e=>e.statusCode===h&&e.fields.length===0)}function B(t,e){let r=new Set(e.map(n=>n.field));return Object.fromEntries(Object.entries(t).filter(([n])=>!r.has(n)))}function j(t,e){let r=t??{rows:0,fields:[]};r.rows+=e.rows;for(let n of e.fields){let o=r.fields.find(i=>i.field===n.field&&i.reason===n.reason);o?o.rows+=n.rows:r.fields.push({...n})}return r}var k={"validation-rule":"a validation rule of the target refused it","restricted-picklist":"a restricted picklist of the target refused its value","lookup-filter":"a lookup filter of the target refused the record it names","inactive-owner":"the target holds the owner it names inactive"};function x(t){return(t?.fields??[]).map(({field:e,refusedBy:r="validation-rule",reason:n,rows:o,replacedWith:i})=>{let a=i===void 0?`written without ${e}`:`written with ${e} set to "${i}"`;return`, ${o} ${a}: ${k[r]}, ${n}`}).join("")}function V(t){let e=`${t.rows} record(s) written again without the fields the target refused them on${x(t)}`;return e.endsWith(".")?e:`${e}.`}var f=class{config;constructor(e){this.config={maxRetries:e?.maxRetries??3,initialDelay:e?.initialDelay??1e3,maxDelay:e?.maxDelay??3e4,backoffMultiplier:e?.backoffMultiplier??2,jitter:e?.jitter??!0}}calculateDelay(e){let r=this.config.initialDelay*Math.pow(this.config.backoffMultiplier,e),n=Math.min(r,this.config.maxDelay);if(!this.config.jitter)return n;let o=n/2;return Math.floor(o+Math.random()*o)}async execute(e){let r,n=0;for(let o=0;o<=this.config.maxRetries;o++)try{return{success:!0,result:await e(),attempts:o+1,totalDelay:n}}catch(i){if(r=i instanceof Error?i:new Error(String(i)),o<this.config.maxRetries){let a=this.calculateDelay(o);n+=a,await new Promise(s=>setTimeout(s,a))}}return{success:!1,error:r,attempts:this.config.maxRetries+1,totalDelay:n}}shouldRetry(e){return e<this.config.maxRetries}getConfig(){return{...this.config}}};var O="UNABLE_TO_LOCK_ROW",l=3,C=2e3,L=200,Z=`Rows the target refuses for a record lock go again on their own, up to ${l} times each: up to ${l} more requests for every ${L} of them, which no estimate made before the write can count.`,X=`rows the target refuses for a record lock go again, up to ${l} times each: up to ${l} more requests for every ${L} of them, not counted above`,I="CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY",v=/\bfirst error: UNABLE_TO_LOCK_ROW\b/,N=/^([A-Z][A-Z0-9_]*):\s*([\s\S]*)$/;function p(t,e){return t===O||t===I&&v.test(e)}function q(t,e){return e&&e.length>0?e.every(r=>p(r.statusCode,r.message)):t.length>0&&t.every(r=>{let n=N.exec(r.trim());return n!==null&&p(n[1],n[2])})}var $=new f({initialDelay:C});function U(t){return $.calculateDelay(t)}function H(t,e){return new Promise(r=>{if(e?.aborted){r();return}let n=()=>{clearTimeout(o),e?.removeEventListener("abort",n),r()},o=setTimeout(n,t);e?.addEventListener("abort",n,{once:!0})})}function W(t){return`sent again ${t===1?"once":`${t} times`}, waiting longer each time: the target still could not lock a record the write needed`}function J(t,e){return`${t} \u2014 ${W(e)}`}async function Q(t){let e=[...t.outcomes],r=new Map,n=e.flatMap((s,u)=>t.locked(s)?[u]:[]),o=n.length;for(let s=0;n.length>0&&s<l&&(await t.wait(U(s)),!t.stopped());s++){let u=n,d=await t.send(u);if(d.slice(0,u.length).forEach((m,g)=>{e[u[g]]=m,r.set(u[g],(r.get(u[g])??0)+1)}),d.length<u.length)break;n=u.filter(m=>t.locked(e[m]))}let i=0,a=0;for(let[s,u]of r)t.written(e[s])?i++:t.locked(e[s])&&(a++,e[s]=t.note(e[s],u));return{outcomes:e,refused:o,sentAgain:r.size,written:i,stillLocked:a,notSentAgain:o-r.size}}function ee(t,e){if(e.refused===0)return;let r=e.sentAgain-e.written-e.stillLocked,n=[`${e.written} written`,...e.stillLocked>0?[`${e.stillLocked} still refused for the lock`]:[],...r>0?[`${r} refused for another reason`]:[],...e.notSentAgain>0?[`${e.notSentAgain} not sent again: the run was stopped`]:[]];return`${e.refused} ${t} refused because the target could not lock a record their write needed (${O}), sent again up to ${l} times, waiting longer each time: ${n.join(", ")}`}export{y as a,_ as b,w as c,A as d,c as e,P as f,K as g,B as h,j as i,x as j,V as k,f as l,Z as m,X as n,q as o,H as p,J as q,Q as r,ee as s};
|
|
@@ -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{m as a,n as b,o as c,p as d,q as e,r as f,s as g}from"./chunk-
|
|
7
|
+
import{m as a,n as b,o as c,p as d,q as e,r as f,s as g}from"./chunk-52EXDVPN.mjs";import"./chunk-GMY5427L.mjs";import"./chunk-TEIBWMJM.mjs";import"./chunk-BWWQXU2B.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-M6P5ZZLE.mjs";import"./chunk-WSUKC2U3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.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-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as DataSync,f as MAX_RESULT_REFUSALS_PER_OBJECT,g as buildObjectResult,d as linkedRecordOf,c as notReachedOf,b as unsetOf,e as withCurrencies};
|
|
@@ -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}from"./chunk-
|
|
7
|
+
import{a,b,c,d,e,f}from"./chunk-GJ6SZVHT.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-KIMQQ6JQ.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as OPPORTUNITY,c as SeedPlatformRoles,b as rolesNotLookedUpNote,d as rolesOfADryRun,f as seedTargetOf,e as writtenByThePlatformLine};
|
|
@@ -4,4 +4,4 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{A as y,B as z,C as A,D as B,E as C,F as D,G as E,H as F,I as G,J as H,K as I,L as J,M as K,N as L,O as M,P as N,Q as O,c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i,l as j,m as k,n as l,o as m,p as n,q as o,r as p,s as q,t as r,u as s,v as t,w as u,x as v,y as w,z as x}from"./chunk-
|
|
7
|
+
import{A as y,B as z,C as A,D as B,E as C,F as D,G as E,H as F,I as G,J as H,K as I,L as J,M as K,N as L,O as M,P as N,Q as O,c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i,l as j,m as k,n as l,o as m,p as n,q as o,r as p,s as q,t as r,u as s,v as t,w as u,x as v,y as w,z as x}from"./chunk-J24TIGSI.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-ZUTUYBNW.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-ZQO5PDX5.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{a as CHECKPOINT_DIR_MODE,b as CHECKPOINT_FILE_MODE,r as CHECKPOINT_FILE_PATH,F as CheckpointStoreError,c as DEFAULT_KEEP_DAYS,d as EXPIRY_WARNING_DAYS,K as OrgCheckpointStore,f as PREVIEW_KEEP_MS,e as RECYCLE_BIN_DAYS,q as REPLAY_ANNEX_PATH,N as acquireOrgLock,m as binFileOf,C as binReachSince,I as compressedFieldPrints,h as defaultCheckpointLocksDir,g as defaultCheckpointStoreRoot,z as expiresAtFor,B as expiresSoon,u as exportedFileIn,t as exportedFilesOf,n as filesDocumentsFileOf,o as filesLinksFileOf,j as indexFileOf,A as isExpired,s as isExportedPath,L as latestRewindOf,x as makePrivateDir,y as newFolderId,l as notInBinFileOf,J as openCheckpointStore,M as orgLockFileOf,O as orgLockHolder,i as organizationKey,v as previewDirOf,H as readFieldPrints,k as recreatedFileOf,p as replayAnnexFileOf,w as rewindDirOf,D as scratchOrgExpired,E as scratchOrgExpiresSoon,G as storeRefusalWords};
|
|
@@ -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{c as z,d as v,f as A,j as k,k as c,l as R}from"./chunk-FQGHL7GR.mjs";import{Hb as f}from"./chunk-DPYTG6DM.mjs";var L={en_US:[{city:"New York",state:"New York",country:"United States",zipCode:"10001"},{city:"Los Angeles",state:"California",country:"United States",zipCode:"90001"},{city:"Chicago",state:"Illinois",country:"United States",zipCode:"60601"},{city:"Houston",state:"Texas",country:"United States",zipCode:"77001"},{city:"Phoenix",state:"Arizona",country:"United States",zipCode:"85001"},{city:"Philadelphia",state:"Pennsylvania",country:"United States",zipCode:"19101"},{city:"San Antonio",state:"Texas",country:"United States",zipCode:"78201"},{city:"San Diego",state:"California",country:"United States",zipCode:"92101"},{city:"Dallas",state:"Texas",country:"United States",zipCode:"75201"},{city:"Austin",state:"Texas",country:"United States",zipCode:"78701"}],fr_FR:[{city:"Paris",state:"Ile-de-France",country:"France",zipCode:"75001"},{city:"Lyon",state:"Auvergne-Rhone-Alpes",country:"France",zipCode:"69001"},{city:"Marseille",state:"Provence-Alpes-Cote d'Azur",country:"France",zipCode:"13001"},{city:"Toulouse",state:"Occitanie",country:"France",zipCode:"31000"},{city:"Nice",state:"Provence-Alpes-Cote d'Azur",country:"France",zipCode:"06000"},{city:"Bordeaux",state:"Nouvelle-Aquitaine",country:"France",zipCode:"33000"},{city:"Strasbourg",state:"Grand Est",country:"France",zipCode:"67000"},{city:"Nantes",state:"Pays de la Loire",country:"France",zipCode:"44000"},{city:"Lille",state:"Hauts-de-France",country:"France",zipCode:"59000"},{city:"Rennes",state:"Bretagne",country:"France",zipCode:"35000"}],de_DE:[{city:"Berlin",state:"Berlin",country:"Germany",zipCode:"10115"},{city:"Munich",state:"Bavaria",country:"Germany",zipCode:"80331"},{city:"Hamburg",state:"Hamburg",country:"Germany",zipCode:"20095"},{city:"Frankfurt",state:"Hesse",country:"Germany",zipCode:"60311"},{city:"Cologne",state:"North Rhine-Westphalia",country:"Germany",zipCode:"50667"},{city:"Stuttgart",state:"Baden-Wurttemberg",country:"Germany",zipCode:"70173"},{city:"Dusseldorf",state:"North Rhine-Westphalia",country:"Germany",zipCode:"40213"},{city:"Leipzig",state:"Saxony",country:"Germany",zipCode:"04109"},{city:"Dresden",state:"Saxony",country:"Germany",zipCode:"01067"},{city:"Hannover",state:"Lower Saxony",country:"Germany",zipCode:"30159"}],es_ES:[{city:"Madrid",state:"Comunidad de Madrid",country:"Spain",zipCode:"28001"},{city:"Barcelona",state:"Catalonia",country:"Spain",zipCode:"08001"},{city:"Valencia",state:"Comunitat Valenciana",country:"Spain",zipCode:"46001"},{city:"Seville",state:"Andalusia",country:"Spain",zipCode:"41001"},{city:"Zaragoza",state:"Aragon",country:"Spain",zipCode:"50001"},{city:"Malaga",state:"Andalusia",country:"Spain",zipCode:"29001"},{city:"Bilbao",state:"Basque Country",country:"Spain",zipCode:"48001"},{city:"Murcia",state:"Region de Murcia",country:"Spain",zipCode:"30001"},{city:"Palma",state:"Balearic Islands",country:"Spain",zipCode:"07001"},{city:"Granada",state:"Andalusia",country:"Spain",zipCode:"18001"}],ja_JP:[{city:"Tokyo",state:"Tokyo",country:"Japan",zipCode:"100-0001"},{city:"Osaka",state:"Osaka",country:"Japan",zipCode:"530-0001"},{city:"Yokohama",state:"Kanagawa",country:"Japan",zipCode:"220-0011"},{city:"Nagoya",state:"Aichi",country:"Japan",zipCode:"450-0001"},{city:"Sapporo",state:"Hokkaido",country:"Japan",zipCode:"060-0001"},{city:"Fukuoka",state:"Fukuoka",country:"Japan",zipCode:"810-0001"},{city:"Kobe",state:"Hyogo",country:"Japan",zipCode:"650-0001"},{city:"Kyoto",state:"Kyoto",country:"Japan",zipCode:"600-8001"},{city:"Sendai",state:"Miyagi",country:"Japan",zipCode:"980-0001"},{city:"Hiroshima",state:"Hiroshima",country:"Japan",zipCode:"730-0001"}],pt_BR:[{city:"Sao Paulo",state:"Sao Paulo",country:"Brazil",zipCode:"01000-000"},{city:"Rio de Janeiro",state:"Rio de Janeiro",country:"Brazil",zipCode:"20000-000"},{city:"Brasilia",state:"Distrito Federal",country:"Brazil",zipCode:"70000-000"},{city:"Salvador",state:"Bahia",country:"Brazil",zipCode:"40000-000"},{city:"Fortaleza",state:"Ceara",country:"Brazil",zipCode:"60000-000"},{city:"Belo Horizonte",state:"Minas Gerais",country:"Brazil",zipCode:"30000-000"},{city:"Manaus",state:"Amazonas",country:"Brazil",zipCode:"69000-000"},{city:"Curitiba",state:"Parana",country:"Brazil",zipCode:"80000-000"},{city:"Recife",state:"Pernambuco",country:"Brazil",zipCode:"50000-000"},{city:"Porto Alegre",state:"Rio Grande do Sul",country:"Brazil",zipCode:"90000-000"}]},B={en:"en_US",fr:"fr_FR",de:"de_DE",es:"es_ES",ja:"ja_JP",pt:"pt_BR"};function l(i){if(i in L)return i;let e=i.split("_")[0].toLowerCase();return B[e]??"en_US"}var u=class{tuples;resolvedLocale;constructor(e){this.resolvedLocale=l(e??"en_US"),this.tuples=L[this.resolvedLocale]}getAddress(e){return this.tuples[e%this.tuples.length]}getCity(e){return this.getAddress(e).city}getState(e){return this.getAddress(e).state}getCountry(e){return this.getAddress(e).country}getZipCode(e){return this.getAddress(e).zipCode}getLocaleData(){return c(this.resolvedLocale)}};var F={en_US:"US",fr_FR:"FR",de_DE:"DE",es_ES:"ES",ja_JP:"JP",pt_BR:"BR"},$={fr_FR:{country:"FR",bbanLength:23},de_DE:{country:"DE",bbanLength:18},es_ES:{country:"ES",bbanLength:20},en_US:{country:"DE",bbanLength:18},ja_JP:{country:"DE",bbanLength:18},pt_BR:{country:"DE",bbanLength:18}},w="ABCDEFGHIJKLMNPQRSTUVWXYZ",T=["Ergonomic","Handcrafted","Refined","Sleek","Rustic","Compact","Modular","Insulated"],E=["Steel","Wooden","Cotton","Granite","Rubber","Leather","Ceramic"],_=["Chair","Table","Lamp","Keyboard","Backpack","Bottle","Headphones","Gloves","Bench"],M=["Senior","Lead","Junior","Principal","Associate","Chief"],P=["Marketing","Operations","Finance","Sales","Product","Customer Success"],U=["Manager","Analyst","Coordinator","Specialist","Director","Consultant"],G=["Adaptive","Integrated","Customer-focused","Scalable","Secure"],O=["cloud-based","real-time","data-driven","modular","global"],I=["platform","solution","workflow","service","framework","network"],J=["daily use at home or in the office","long days on the move","teams that need something that lasts","small spaces","outdoor work in any weather"],H=["Unable to log in","Invoice discrepancy","Password reset email not received","Order arrived damaged","Request for a refund","Cannot update billing address","Shipment delayed","Error when exporting a report","Product not working as described","Question about my contract","Charged twice for one order","Need help with installation","Account locked after failed logins","Wrong item delivered","Request: edit several records at once","App crashes on startup","Items missing from my order","Cannot download my invoice","Change of delivery address","Warranty claim","Slow since the last update","Question about my subscription renewal","Data not syncing between devices","Cancel my order","Upgrade to a higher plan"],x=["Asked the customer for a screenshot of the error.","Reproduced the issue on our side.","Escalated to the second-level team.","Sent the customer a workaround.","Customer confirmed the fix works.","Waiting for the customer's reply.","Refund approved and processed.","Replacement shipped today.","Called the customer, no answer; left a voicemail.","Linked to a known issue, a fix is planned.","Updated the customer's address on file.","Shared the knowledge article on this topic.","Closed after the customer confirmed.","Reset the account; login works again.","Checked the logs, nothing unusual found."],j=1440*60*1e3,V=365,Y=120,W=30,N=20,K=65,b=class{locale;localeData;geoGenerator;usernameToken=crypto.randomUUID().replace(/-/g,"").slice(0,8);random;today;companyDecks=new Map;companiesDealt=new Map;constructor(e,t={}){this.locale=e??"en_US",this.localeData=c(this.locale),this.geoGenerator=new u(this.locale),this.random=t.random??Math.random,this.today=t.today??(()=>new Date)}setLocale(e){this.locale=e,this.localeData=c(e),this.geoGenerator=new u(e)}generate(e,t,r=0){if(t<=0||e.length===0)return[];let a=[],o=e.filter(n=>f(n.config.fakerMethod??"lorem")==="phone");for(let n=r;n<r+t;n++){let d={},m=new Map,C=(s,p)=>{let y=m.get(s);if(y!==void 0)return y%p;let D=this.below(p);return m.set(s,D),D};for(let s of e){let p=o.indexOf(s),y=p>=0?n*o.length+p:n;d[s.fieldApiName]=this.generateFieldValue(s,y,C)}a.push(d)}return a}dateOf(e){return e==="pastDate"?this.pastDate():this.futureDate()}below(e){return Math.min(e-1,Math.floor(this.random()*e))}pick(e){return e[this.below(e.length)]}generateFieldValue(e,t,r){let a=e.config.fakerMethod??"lorem",o={min:e.config.minValue??0,max:e.config.maxValue??1e3},n=e.config.fakerLocale;if(n&&n!==this.locale){let d=this.locale,m=this.localeData,C=this.geoGenerator;this.locale=n,this.localeData=c(n),this.geoGenerator=new u(n);let s=this.generateByMethodInstance(a,t,o,r);return this.locale=d,this.localeData=m,this.geoGenerator=C,s}return this.generateByMethodInstance(a,t,o,r)}generateByMethodInstance(e,t,r,a){let o=f(e);if(!o)return Z(e);let n=()=>a("geo",1e4);switch(o){case"name":return`${this.firstName(a)} ${this.lastName(a)}`;case"firstName":return this.firstName(a);case"lastName":return this.lastName(a);case"jobTitle":return`${this.pick(M)} ${this.pick(P)} ${this.pick(U)}`;case"email":return this.generateEmail(t,a);case"username":return this.generateUsername(t,a);case"nickname":return this.generateNickname(t,a);case"phone":return this.generatePhone(t);case"address":return`${this.streetAddress()}, ${this.geoGenerator.getCity(n())}`;case"streetAddress":return this.streetAddress();case"city":return this.geoGenerator.getCity(n());case"country":return this.geoGenerator.getCountry(n());case"state":return this.geoGenerator.getState(n());case"company":return this.generateCompany();case"catchPhrase":return`${this.pick(G)} ${this.pick(O)} `+this.pick(I);case"date":case"pastDate":return this.pastDate();case"futureDate":return this.futureDate();case"futureDateTime":return this.futureDateTime();case"birthdate":return this.birthdate();case"number":case"integer":return Math.floor(r.min+this.random()*(r.max-r.min+1));case"float":return Math.round((r.min+this.random()*(r.max-r.min))*100)/100;case"boolean":return t%2===0;case"lorem":case"sentence":return g(t);case"paragraph":return q(t);case"caseSubject":return this.pick(H);case"caseComment":return this.pick(x);case"uuid":return this.uuid();case"url":return`https://example.com/resource/${t}`;case"zipCode":return this.geoGenerator.getZipCode(n());case"productName":return this.productName(a);case"productDescription":return`${this.productName(a)}, made for ${this.pick(J)}.`;case"iban":return this.generateIban(t);case"bic":return this.generateBic(t)}}firstName(e){let t=this.localeData.firstNames;return t[e("first",t.length)]}lastName(e){let t=this.localeData.lastNames;return t[e("last",t.length)]}generateEmail(e,t){let r=this.localeData.emailDomains[e%this.localeData.emailDomains.length];return`${h(this.firstName(t))}.${h(this.lastName(t))}${e}@${r}`}generateUsername(e,t){let r=h(this.firstName(t)),a=h(this.lastName(t)),o=this.localeData.emailDomains[e%this.localeData.emailDomains.length];return`${r}.${a}.${this.usernameToken}${e}@${o}`}generateNickname(e,t){return`${h(this.firstName(t)).slice(0,20)}.${this.usernameToken}${e}`}generatePhone(e){return k(this.locale,e)}streetAddress(){let{names:e,format:t}=z[l(this.locale)];return t.replace("{street}",this.pick(e)).replace("{n}",String(1+this.below(199))).replace("{m}",String(1+this.below(9)))}generateCompany(){let e=l(this.locale),t=A[e].companies.length,r=this.companyDecks.get(e);if(!r||r.length!==t){r=Array.from({length:t},(o,n)=>n);for(let o=r.length-1;o>0;o--){let n=this.below(o+1);[r[o],r[n]]=[r[n],r[o]]}this.companyDecks.set(e,r)}let a=this.companiesDealt.get(e)??0;return this.companiesDealt.set(e,a+1),v(e,r[a%r.length],Math.floor(a/r.length))}productName(e){let t=T[e("productAdjective",T.length)],r=E[e("productMaterial",E.length)],a=_[e("product",_.length)];return`${t} ${r} ${a}`}pastDate(){return S(this.daysFromToday(-(1+this.below(V))))}futureDate(){return S(this.daysFromToday(1+this.below(Y)))}futureDateTime(){let e=this.daysFromToday(1+this.below(W));return e.setUTCHours(8+this.below(9),this.below(2)*30,0,0),e.toISOString()}birthdate(){let e=(K-N)*365;return S(this.daysFromToday(-(N*365+this.below(e))))}daysFromToday(e){return new Date(this.today().getTime()+e*j)}uuid(){let e=Array.from({length:32},()=>this.below(16).toString(16));e[12]="4",e[16]=(this.below(16)&3|8).toString(16);let t=e.join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}generateIban(e){let t=$[l(this.locale)],r=R("#".repeat(t.bbanLength),e);return`${t.country}${X(t.country,r)}${r}`}generateBic(e){let t=Array.from({length:4},(a,o)=>String.fromCharCode(65+(e*5+o*7+3)%26)).join(""),r=Array.from({length:2},(a,o)=>w[(e*3+o*11+2)%w.length]).join("");return`${t}${F[l(this.locale)]}${r}XXX`}};function oe(i,e,t,r,a){let o=new b(r,a),n={fieldApiName:"temp",ruleType:"faker",config:{fakerMethod:i,minValue:t.min,maxValue:t.max}};return o.generate([n],e+1)[e]?.temp}function S(i){return i.toISOString().split("T")[0]}function h(i){return i.normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z]/g,"")}function X(i,e){let t=`${e}${i}00`.replace(/[A-Z]/g,a=>String(a.charCodeAt(0)-55)),r=0;for(let a of t)r=(r*10+Number(a))%97;return String(98-r).padStart(2,"0")}function Z(i){throw new Error(`Faker method "${i}" is not implemented: choose a method SandForge generates, or remove it from the field rule.`)}function g(i){let e=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit"],t=i%e.length,r=[];for(let a=0;a<6;a++)r.push(e[(t+a)%e.length]);return r.join(" ")+"."}function q(i){return[g(i),g(i+1),g(i+2)].join(" ")}export{b as a,oe as b};
|
|
7
|
+
import{c as z,d as v,f as A,j as k,k as c,l as R}from"./chunk-FQGHL7GR.mjs";import{Tb as f}from"./chunk-ZQO5PDX5.mjs";var L={en_US:[{city:"New York",state:"New York",country:"United States",zipCode:"10001"},{city:"Los Angeles",state:"California",country:"United States",zipCode:"90001"},{city:"Chicago",state:"Illinois",country:"United States",zipCode:"60601"},{city:"Houston",state:"Texas",country:"United States",zipCode:"77001"},{city:"Phoenix",state:"Arizona",country:"United States",zipCode:"85001"},{city:"Philadelphia",state:"Pennsylvania",country:"United States",zipCode:"19101"},{city:"San Antonio",state:"Texas",country:"United States",zipCode:"78201"},{city:"San Diego",state:"California",country:"United States",zipCode:"92101"},{city:"Dallas",state:"Texas",country:"United States",zipCode:"75201"},{city:"Austin",state:"Texas",country:"United States",zipCode:"78701"}],fr_FR:[{city:"Paris",state:"Ile-de-France",country:"France",zipCode:"75001"},{city:"Lyon",state:"Auvergne-Rhone-Alpes",country:"France",zipCode:"69001"},{city:"Marseille",state:"Provence-Alpes-Cote d'Azur",country:"France",zipCode:"13001"},{city:"Toulouse",state:"Occitanie",country:"France",zipCode:"31000"},{city:"Nice",state:"Provence-Alpes-Cote d'Azur",country:"France",zipCode:"06000"},{city:"Bordeaux",state:"Nouvelle-Aquitaine",country:"France",zipCode:"33000"},{city:"Strasbourg",state:"Grand Est",country:"France",zipCode:"67000"},{city:"Nantes",state:"Pays de la Loire",country:"France",zipCode:"44000"},{city:"Lille",state:"Hauts-de-France",country:"France",zipCode:"59000"},{city:"Rennes",state:"Bretagne",country:"France",zipCode:"35000"}],de_DE:[{city:"Berlin",state:"Berlin",country:"Germany",zipCode:"10115"},{city:"Munich",state:"Bavaria",country:"Germany",zipCode:"80331"},{city:"Hamburg",state:"Hamburg",country:"Germany",zipCode:"20095"},{city:"Frankfurt",state:"Hesse",country:"Germany",zipCode:"60311"},{city:"Cologne",state:"North Rhine-Westphalia",country:"Germany",zipCode:"50667"},{city:"Stuttgart",state:"Baden-Wurttemberg",country:"Germany",zipCode:"70173"},{city:"Dusseldorf",state:"North Rhine-Westphalia",country:"Germany",zipCode:"40213"},{city:"Leipzig",state:"Saxony",country:"Germany",zipCode:"04109"},{city:"Dresden",state:"Saxony",country:"Germany",zipCode:"01067"},{city:"Hannover",state:"Lower Saxony",country:"Germany",zipCode:"30159"}],es_ES:[{city:"Madrid",state:"Comunidad de Madrid",country:"Spain",zipCode:"28001"},{city:"Barcelona",state:"Catalonia",country:"Spain",zipCode:"08001"},{city:"Valencia",state:"Comunitat Valenciana",country:"Spain",zipCode:"46001"},{city:"Seville",state:"Andalusia",country:"Spain",zipCode:"41001"},{city:"Zaragoza",state:"Aragon",country:"Spain",zipCode:"50001"},{city:"Malaga",state:"Andalusia",country:"Spain",zipCode:"29001"},{city:"Bilbao",state:"Basque Country",country:"Spain",zipCode:"48001"},{city:"Murcia",state:"Region de Murcia",country:"Spain",zipCode:"30001"},{city:"Palma",state:"Balearic Islands",country:"Spain",zipCode:"07001"},{city:"Granada",state:"Andalusia",country:"Spain",zipCode:"18001"}],ja_JP:[{city:"Tokyo",state:"Tokyo",country:"Japan",zipCode:"100-0001"},{city:"Osaka",state:"Osaka",country:"Japan",zipCode:"530-0001"},{city:"Yokohama",state:"Kanagawa",country:"Japan",zipCode:"220-0011"},{city:"Nagoya",state:"Aichi",country:"Japan",zipCode:"450-0001"},{city:"Sapporo",state:"Hokkaido",country:"Japan",zipCode:"060-0001"},{city:"Fukuoka",state:"Fukuoka",country:"Japan",zipCode:"810-0001"},{city:"Kobe",state:"Hyogo",country:"Japan",zipCode:"650-0001"},{city:"Kyoto",state:"Kyoto",country:"Japan",zipCode:"600-8001"},{city:"Sendai",state:"Miyagi",country:"Japan",zipCode:"980-0001"},{city:"Hiroshima",state:"Hiroshima",country:"Japan",zipCode:"730-0001"}],pt_BR:[{city:"Sao Paulo",state:"Sao Paulo",country:"Brazil",zipCode:"01000-000"},{city:"Rio de Janeiro",state:"Rio de Janeiro",country:"Brazil",zipCode:"20000-000"},{city:"Brasilia",state:"Distrito Federal",country:"Brazil",zipCode:"70000-000"},{city:"Salvador",state:"Bahia",country:"Brazil",zipCode:"40000-000"},{city:"Fortaleza",state:"Ceara",country:"Brazil",zipCode:"60000-000"},{city:"Belo Horizonte",state:"Minas Gerais",country:"Brazil",zipCode:"30000-000"},{city:"Manaus",state:"Amazonas",country:"Brazil",zipCode:"69000-000"},{city:"Curitiba",state:"Parana",country:"Brazil",zipCode:"80000-000"},{city:"Recife",state:"Pernambuco",country:"Brazil",zipCode:"50000-000"},{city:"Porto Alegre",state:"Rio Grande do Sul",country:"Brazil",zipCode:"90000-000"}]},B={en:"en_US",fr:"fr_FR",de:"de_DE",es:"es_ES",ja:"ja_JP",pt:"pt_BR"};function l(i){if(i in L)return i;let e=i.split("_")[0].toLowerCase();return B[e]??"en_US"}var u=class{tuples;resolvedLocale;constructor(e){this.resolvedLocale=l(e??"en_US"),this.tuples=L[this.resolvedLocale]}getAddress(e){return this.tuples[e%this.tuples.length]}getCity(e){return this.getAddress(e).city}getState(e){return this.getAddress(e).state}getCountry(e){return this.getAddress(e).country}getZipCode(e){return this.getAddress(e).zipCode}getLocaleData(){return c(this.resolvedLocale)}};var F={en_US:"US",fr_FR:"FR",de_DE:"DE",es_ES:"ES",ja_JP:"JP",pt_BR:"BR"},$={fr_FR:{country:"FR",bbanLength:23},de_DE:{country:"DE",bbanLength:18},es_ES:{country:"ES",bbanLength:20},en_US:{country:"DE",bbanLength:18},ja_JP:{country:"DE",bbanLength:18},pt_BR:{country:"DE",bbanLength:18}},w="ABCDEFGHIJKLMNPQRSTUVWXYZ",T=["Ergonomic","Handcrafted","Refined","Sleek","Rustic","Compact","Modular","Insulated"],E=["Steel","Wooden","Cotton","Granite","Rubber","Leather","Ceramic"],_=["Chair","Table","Lamp","Keyboard","Backpack","Bottle","Headphones","Gloves","Bench"],M=["Senior","Lead","Junior","Principal","Associate","Chief"],P=["Marketing","Operations","Finance","Sales","Product","Customer Success"],U=["Manager","Analyst","Coordinator","Specialist","Director","Consultant"],G=["Adaptive","Integrated","Customer-focused","Scalable","Secure"],O=["cloud-based","real-time","data-driven","modular","global"],I=["platform","solution","workflow","service","framework","network"],J=["daily use at home or in the office","long days on the move","teams that need something that lasts","small spaces","outdoor work in any weather"],H=["Unable to log in","Invoice discrepancy","Password reset email not received","Order arrived damaged","Request for a refund","Cannot update billing address","Shipment delayed","Error when exporting a report","Product not working as described","Question about my contract","Charged twice for one order","Need help with installation","Account locked after failed logins","Wrong item delivered","Request: edit several records at once","App crashes on startup","Items missing from my order","Cannot download my invoice","Change of delivery address","Warranty claim","Slow since the last update","Question about my subscription renewal","Data not syncing between devices","Cancel my order","Upgrade to a higher plan"],x=["Asked the customer for a screenshot of the error.","Reproduced the issue on our side.","Escalated to the second-level team.","Sent the customer a workaround.","Customer confirmed the fix works.","Waiting for the customer's reply.","Refund approved and processed.","Replacement shipped today.","Called the customer, no answer; left a voicemail.","Linked to a known issue, a fix is planned.","Updated the customer's address on file.","Shared the knowledge article on this topic.","Closed after the customer confirmed.","Reset the account; login works again.","Checked the logs, nothing unusual found."],j=1440*60*1e3,V=365,Y=120,W=30,N=20,K=65,b=class{locale;localeData;geoGenerator;usernameToken=crypto.randomUUID().replace(/-/g,"").slice(0,8);random;today;companyDecks=new Map;companiesDealt=new Map;constructor(e,t={}){this.locale=e??"en_US",this.localeData=c(this.locale),this.geoGenerator=new u(this.locale),this.random=t.random??Math.random,this.today=t.today??(()=>new Date)}setLocale(e){this.locale=e,this.localeData=c(e),this.geoGenerator=new u(e)}generate(e,t,r=0){if(t<=0||e.length===0)return[];let a=[],o=e.filter(n=>f(n.config.fakerMethod??"lorem")==="phone");for(let n=r;n<r+t;n++){let d={},m=new Map,C=(s,p)=>{let y=m.get(s);if(y!==void 0)return y%p;let D=this.below(p);return m.set(s,D),D};for(let s of e){let p=o.indexOf(s),y=p>=0?n*o.length+p:n;d[s.fieldApiName]=this.generateFieldValue(s,y,C)}a.push(d)}return a}dateOf(e){return e==="pastDate"?this.pastDate():this.futureDate()}below(e){return Math.min(e-1,Math.floor(this.random()*e))}pick(e){return e[this.below(e.length)]}generateFieldValue(e,t,r){let a=e.config.fakerMethod??"lorem",o={min:e.config.minValue??0,max:e.config.maxValue??1e3},n=e.config.fakerLocale;if(n&&n!==this.locale){let d=this.locale,m=this.localeData,C=this.geoGenerator;this.locale=n,this.localeData=c(n),this.geoGenerator=new u(n);let s=this.generateByMethodInstance(a,t,o,r);return this.locale=d,this.localeData=m,this.geoGenerator=C,s}return this.generateByMethodInstance(a,t,o,r)}generateByMethodInstance(e,t,r,a){let o=f(e);if(!o)return Z(e);let n=()=>a("geo",1e4);switch(o){case"name":return`${this.firstName(a)} ${this.lastName(a)}`;case"firstName":return this.firstName(a);case"lastName":return this.lastName(a);case"jobTitle":return`${this.pick(M)} ${this.pick(P)} ${this.pick(U)}`;case"email":return this.generateEmail(t,a);case"username":return this.generateUsername(t,a);case"nickname":return this.generateNickname(t,a);case"phone":return this.generatePhone(t);case"address":return`${this.streetAddress()}, ${this.geoGenerator.getCity(n())}`;case"streetAddress":return this.streetAddress();case"city":return this.geoGenerator.getCity(n());case"country":return this.geoGenerator.getCountry(n());case"state":return this.geoGenerator.getState(n());case"company":return this.generateCompany();case"catchPhrase":return`${this.pick(G)} ${this.pick(O)} `+this.pick(I);case"date":case"pastDate":return this.pastDate();case"futureDate":return this.futureDate();case"futureDateTime":return this.futureDateTime();case"birthdate":return this.birthdate();case"number":case"integer":return Math.floor(r.min+this.random()*(r.max-r.min+1));case"float":return Math.round((r.min+this.random()*(r.max-r.min))*100)/100;case"boolean":return t%2===0;case"lorem":case"sentence":return g(t);case"paragraph":return q(t);case"caseSubject":return this.pick(H);case"caseComment":return this.pick(x);case"uuid":return this.uuid();case"url":return`https://example.com/resource/${t}`;case"zipCode":return this.geoGenerator.getZipCode(n());case"productName":return this.productName(a);case"productDescription":return`${this.productName(a)}, made for ${this.pick(J)}.`;case"iban":return this.generateIban(t);case"bic":return this.generateBic(t)}}firstName(e){let t=this.localeData.firstNames;return t[e("first",t.length)]}lastName(e){let t=this.localeData.lastNames;return t[e("last",t.length)]}generateEmail(e,t){let r=this.localeData.emailDomains[e%this.localeData.emailDomains.length];return`${h(this.firstName(t))}.${h(this.lastName(t))}${e}@${r}`}generateUsername(e,t){let r=h(this.firstName(t)),a=h(this.lastName(t)),o=this.localeData.emailDomains[e%this.localeData.emailDomains.length];return`${r}.${a}.${this.usernameToken}${e}@${o}`}generateNickname(e,t){return`${h(this.firstName(t)).slice(0,20)}.${this.usernameToken}${e}`}generatePhone(e){return k(this.locale,e)}streetAddress(){let{names:e,format:t}=z[l(this.locale)];return t.replace("{street}",this.pick(e)).replace("{n}",String(1+this.below(199))).replace("{m}",String(1+this.below(9)))}generateCompany(){let e=l(this.locale),t=A[e].companies.length,r=this.companyDecks.get(e);if(!r||r.length!==t){r=Array.from({length:t},(o,n)=>n);for(let o=r.length-1;o>0;o--){let n=this.below(o+1);[r[o],r[n]]=[r[n],r[o]]}this.companyDecks.set(e,r)}let a=this.companiesDealt.get(e)??0;return this.companiesDealt.set(e,a+1),v(e,r[a%r.length],Math.floor(a/r.length))}productName(e){let t=T[e("productAdjective",T.length)],r=E[e("productMaterial",E.length)],a=_[e("product",_.length)];return`${t} ${r} ${a}`}pastDate(){return S(this.daysFromToday(-(1+this.below(V))))}futureDate(){return S(this.daysFromToday(1+this.below(Y)))}futureDateTime(){let e=this.daysFromToday(1+this.below(W));return e.setUTCHours(8+this.below(9),this.below(2)*30,0,0),e.toISOString()}birthdate(){let e=(K-N)*365;return S(this.daysFromToday(-(N*365+this.below(e))))}daysFromToday(e){return new Date(this.today().getTime()+e*j)}uuid(){let e=Array.from({length:32},()=>this.below(16).toString(16));e[12]="4",e[16]=(this.below(16)&3|8).toString(16);let t=e.join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}generateIban(e){let t=$[l(this.locale)],r=R("#".repeat(t.bbanLength),e);return`${t.country}${X(t.country,r)}${r}`}generateBic(e){let t=Array.from({length:4},(a,o)=>String.fromCharCode(65+(e*5+o*7+3)%26)).join(""),r=Array.from({length:2},(a,o)=>w[(e*3+o*11+2)%w.length]).join("");return`${t}${F[l(this.locale)]}${r}XXX`}};function oe(i,e,t,r,a){let o=new b(r,a),n={fieldApiName:"temp",ruleType:"faker",config:{fakerMethod:i,minValue:t.min,maxValue:t.max}};return o.generate([n],e+1)[e]?.temp}function S(i){return i.toISOString().split("T")[0]}function h(i){return i.normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z]/g,"")}function X(i,e){let t=`${e}${i}00`.replace(/[A-Z]/g,a=>String(a.charCodeAt(0)-55)),r=0;for(let a of t)r=(r*10+Number(a))%97;return String(98-r).padStart(2,"0")}function Z(i){throw new Error(`Faker method "${i}" is not implemented: choose a method SandForge generates, or remove it from the field rule.`)}function g(i){let e=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit"],t=i%e.length,r=[];for(let a=0;a<6;a++)r.push(e[(t+a)%e.length]);return r.join(" ")+"."}function q(i){return[g(i),g(i+1),g(i+2)].join(" ")}export{b as a,oe as b};
|
|
@@ -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{i as u,j as f}from"./chunk-
|
|
7
|
+
import{i as u,j as f}from"./chunk-ZQO5PDX5.mjs";var p=1e4,g=150,m=200,l=class{build(o){let t=o.relations??[],c=j(o.objects,t),i=S(c),r=b(c),n=r*g,s=i>p;return{objects:c.map(a=>({objectApiName:a.objectApiName,recordCount:a.recordCount,sampleRecords:C(a,3,u(a.objectApiName,t)),dependsOn:f(a,t)})),totalRecords:i,estimatedApiCalls:r,estimatedDuration:n,grappeRecommended:s}}};function S(e){return e.reduce((o,t)=>o+t.recordCount,0)}function b(e){return e.reduce((o,t)=>{let c=t.batchSize>0?t.batchSize:m;return o+Math.ceil(t.recordCount/c)},0)}function C(e,o,t){let c=Math.min(o,e.recordCount),i=[];for(let r=0;r<c;r++){let n={};for(let d of e.fieldRules)n[d.fieldApiName]=R(d,r);let s=e.rows?.[r];s&&(Object.assign(n,s.values),t?.distribution.mode==="byKey"&&s.parentKey!==void 0&&(n[t.lookupField]=`[key:${s.parentKey}]`)),i.push(n)}return i}function R(e,o){switch(e.ruleType){case"static":return e.config.staticValue??null;case"sequence":{let t=e.config.sequenceStart??1,c=e.config.sequenceStep??1;return`${e.config.sequencePrefix??""}${t+o*c}`}case"picklist_random":return e.config.picklistValues&&e.config.picklistValues.length>0?e.config.picklistValues[o%e.config.picklistValues.length]:null;case"reference":return`[ref:${e.config.referenceObject??"unknown"}]`;case"faker":return`[faker:${e.config.fakerMethod??"lorem"}]`;case"ai_generate":return`[ai:${e.config.aiPrompt??"generated"}]`;case"random":return`sample_${o}`;case"formula":return`[formula:${e.config.formula??""}]`;case"regex":return`[regex:${e.config.regexPattern??""}]`;case"from_csv":return`[csv:${e.config.csvColumn??""}]`;default:return null}}function j(e,o=[]){let t=new Map;for(let n of e)t.set(n.objectApiName,n);let c=new Set,i=[];function r(n){if(c.has(n))return;c.add(n);let s=t.get(n);if(!s)return;let d=f(s,o);for(let a of d)r(a);i.push(s)}for(let n of e)r(n.objectApiName);return i}export{l as a,j as b};
|
|
@@ -4,6 +4,6 @@ import { dirname as __sandforgeDirname } from 'node:path';
|
|
|
4
4
|
const require = __sandforgeRequire(import.meta.url);
|
|
5
5
|
const __filename = __sandforgePath(import.meta.url);
|
|
6
6
|
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{J as H}from"./chunk-ZWCRWF7E.mjs";import{b as R,c as de,d as _}from"./chunk-BNO5GIJ6.mjs";import{i as ae}from"./chunk-INIT2UKJ.mjs";import{h as Y}from"./chunk-TZE3Y7IQ.mjs";import{b as F}from"./chunk-CA5NAXSU.mjs";var ke=5,Ie=100;function m(n){return n.slice(0,15)}function N(n){return n==null||n===""}var ce=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;function Re(n,e){if(N(n)||N(e))return N(n)&&N(e);if(typeof n=="number"||typeof e=="number")return Number(n)===Number(e);if(typeof n=="string"&&typeof e=="string"){if(n===e)return!0;if(ce.test(n)&&ce.test(e)){let s=Date.parse(n);return Number.isFinite(s)&&s===Date.parse(e)}return!1}return JSON.stringify(n)===JSON.stringify(e)}function Ae(n){let e;return()=>(e??=(async()=>{try{let s=await n.userId?.();return typeof s=="string"&&s!==""?m(s):void 0}catch{return}})(),e)}async function fe(n){let e=Date.now();try{let s=Date.parse(await n.serverTime());return Number.isFinite(s)?s-(e+Date.now())/2:0}catch{return 0}}async function Oe(n,e){let s=Date.parse(e??"");return Number.isFinite(s)?s+await fe(n)+H:Number.NEGATIVE_INFINITY}var ve=1e3;function Se(n){let e=Date.parse(n);return Number.isFinite(e)?e-ve:Number.NEGATIVE_INFINITY}function Pe(n,e){let s=Object.hasOwn(n,e)?n[e]:[];return new Map(s.filter(o=>o.toLowerCase()!=="id").map(o=>[o.toLowerCase(),o]))}var Ee={INACTIVE_OWNER_OR_USER:"OwnerId"};function je(n,e){let s=new Set;for(let r of n.errors??[]){if(typeof r=="string")continue;if(Array.isArray(r.fields))for(let g of r.fields)typeof g=="string"&&s.add(g);let c=r.statusCode!==void 0?Ee[r.statusCode]:void 0;c!==void 0&&(!Array.isArray(r.fields)||r.fields.length===0)&&s.add(c)}let o=new Map(Object.keys(e).map(r=>[r.toLowerCase(),r]));return[...s].flatMap(r=>{let c=o.get(r.toLowerCase());return c!==void 0&&c!=="Id"?[c]:[]})}function Fe(n,e){let s=Array.isArray(n)?n:[n];return Array.from({length:e},(o,r)=>s[r]??{success:!1})}function Q(n){let e=n.errors?.[0];if(e===void 0)return{words:"The org gave no reason."};if(typeof e=="string")return{words:e};let s=e.statusCode,o=e.message??"";return{...s?{code:s}:{},words:s&&o?`${s}: ${o}`:s||o}}function C(n,{fields:e,why:s}){return`${e.map(o=>`${n}.${o}`).join(", ")}: the value from before is no longer taken (${s}) \u2014 left as the run wrote it`}async function Le(n,e,s){let o=new Set;try{for(let r of _(s)){let c=await n.query(`SELECT Id FROM ${e} WHERE Id IN (${r})`);for(let g of c.records)typeof g.Id=="string"&&o.add(m(g.Id))}}catch(r){return{unread:F(r)}}return{live:o}}var Z=class{result;said=new Set;constructor(e,s){this.result={objectApiName:e,planned:s,restored:0,keptChanged:0,alreadyGone:0,refused:0,notKept:0,reasons:[]}}without(){this.result.restoredWithout=(this.result.restoredWithout??0)+1}reason(e){this.said.has(e)||this.said.size>=ke||(this.said.add(e),this.result.reasons.push(e))}};async function Qe(n){let{org:e,plan:s}=n,o=[],r=[],c={},g=!1,u=!1;if(s.length===0)return{objects:o,left:r,wrote:g,cancelled:u,stamps:c};let A=n.changedAfter!==void 0?Se(n.changedAfter):await Oe(e,n.lastWriteAt),w=new Map(Object.entries(n.stamps??{}).map(([b,x])=>[m(b),Date.parse(x)])),L=n.ownWriters&&n.ownWriters.length>0?new Set(n.ownWriters.map(m)):void 0,T=n.stampsFor,he=Ae(e);for(let{objectApiName:b,backup:x,ids:D}of s){let l=new Z(b,D.length);o.push(l.result);let W=n.unkept?.find(t=>t.objectApiName===b);if(W&&W.fields.length>0&&l.reason(`${W.fields.map(t=>`${b}.${t}`).join(", ")}: not kept, encrypted \u2014 the run's user cannot view encrypted data, and read their values from before masked; left as the run wrote them`),u||n.signal?.aborted){u=!0,l.result.notReached=D.length,r.push(...D);continue}let G=Y(b),k=new Map(D.map(t=>[m(t),t])),U=n.fields?Pe(n.fields,b):void 0,v=new Map,q=new Set;try{let t=await n.backups.batches(x,b,R);for await(let i of t??[])for(let a of i){if(typeof a.Id!="string"||!k.has(m(a.Id)))continue;let d=v.get(m(a.Id))??{};for(let[h,f]of Object.entries(a)){if(h==="Id")continue;let p=U?U.get(h.toLowerCase()):h;p!==void 0&&!(p in d)&&(d[p]=f)}if(U&&Object.keys(d).length===0){q.add(m(a.Id));continue}v.set(m(a.Id),d)}}catch(t){l.reason(`The values from before the run could not be read: ${F(t)}`),v.clear(),q.clear()}let ee=[...q].filter(t=>!v.has(t)).length;ee>0&&l.reason(`${ee} ${b} record(s) hold no value of a field that may be written back now: left as they are`);for(let t of[...k.keys()])v.has(t)||(l.result.notKept++,k.delete(t));if(k.size===0)continue;let te=new Set;for(let t of v.values())for(let i of Object.keys(t))te.add(Y(i));let ne=["Id","LastModifiedDate",...L?["LastModifiedById"]:[],...te],pe=ne.length>Ie?R/4:R,J=new Map,ye=async t=>{if(n.signal?.aborted)throw new B;return(await e.query(t)).records};try{for(let t of _([...k.values()],pe)){let i=await ae(`SELECT ${ne.join(", ")} FROM ${G} WHERE Id IN (${t})`,ye,{stamp:"LastModifiedDate"});for(let a of i)typeof a.Id=="string"&&J.set(m(a.Id),a)}}catch(t){if(t instanceof B){u=!0,l.result.notReached=k.size,r.push(...k.values());continue}l.result.refused+=k.size,l.reason(F(t)),r.push(...k.values());continue}let $=[],re=new Set,me=T?Date.now()+await fe(e)-H:0;for(let[t,i]of k){let a=J.get(t);if(!a){l.result.alreadyGone++,n.counted?.(i,"alreadyGone");continue}let d=Date.parse(String(a.LastModifiedDate??"")),h=a.LastModifiedById,f=d<=A||d<=(w.get(t)??Number.NaN)||L!==void 0&&typeof h=="string"&&L.has(m(h));if(!f&&!n.includeChanged){l.result.keptChanged++,r.push(i);continue}let p=v.get(t)??{},y={Id:a.Id};for(let[I,O]of Object.entries(p))Re(O,a[I])||(y[I]=N(O)?null:O);if(Object.keys(y).length===1){l.result.restored++,n.counted?.(i,"restored"),f&&T?.(i)&&typeof a.LastModifiedDate=="string"&&(c[a.Id]=a.LastModifiedDate);continue}$.push(y),f&&T?.(i)&&re.add(i)}let P=[],S=[],E=(t,i)=>{l.result.refused++,l.reason(i),r.push(k.get(m(t.Id))??t.Id)},K=t=>{l.result.restored++,n.counted?.(k.get(m(t.Id))??t.Id,"restored")},we=t=>{l.result.alreadyGone++,n.counted?.(k.get(m(t.Id))??t.Id,"alreadyGone")},se=t=>{u=!0,l.result.notReached=(l.result.notReached??0)+t.length,r.push(...t.map(i=>k.get(m(i.Id))??i.Id))},oe=(t,i,a,d)=>{let h=Object.keys(t).filter(y=>y!=="Id"&&!i.includes(y));if(h.length>0){let y={Id:t.Id};for(let I of h)y[I]=t[I];P.push({record:y,leftOut:a});return}if(a.length===0){K(t);return}let[f,...p]=a;d?(l.without(),l.reason(C(b,f))):E(t,C(b,f));for(let y of p)l.reason(C(b,y))},z=async t=>{try{return g=!0,Fe(await e.update(b,[...t]),t.length)}catch(i){let a=F(i);return t.map(()=>({success:!1,errors:[a]}))}},be=async t=>{let i=n.keep;if(!i)return!0;let a=t.map(d=>{let h=J.get(m(d.Id))??{},f={Id:d.Id};for(let p of Object.keys(d))p!=="Id"&&(f[p]=h[p]??null);return f});try{return await i(b,a),!0}catch(d){let h=`What these ${t.length} ${b} record(s) hold now could not be kept before they were written (${F(d)}), so none of them was written: nothing is written over that cannot be put back.`;for(let f of t)E(f,h);return!1}};for(let t=0;t<$.length;t+=R){let i=$.slice(t,t+R);if(n.signal?.aborted){u=!0;let d=$.slice(t);l.result.notReached=(l.result.notReached??0)+d.length,r.push(...d.map(h=>k.get(m(h.Id))??h.Id));break}if(!await be(i))continue;(await z(i)).forEach((d,h)=>{let f=i[h];if(d.success===!0){K(f);return}let p=Q(d),y=je(d,f);if(p.code==="ENTITY_IS_DELETED"&&y.length===0){S.push({record:f,why:p.words});return}let I=Object.keys(f).filter(O=>O!=="Id"&&!y.includes(O));if(y.length>0&&I.length>0){let O={Id:f.Id};for(let ie of I)O[ie]=f[ie];P.push({record:O,leftOut:[{fields:y,why:p.words}]});return}E(f,p.words)})}let j=[];if(S.length>0&&n.signal?.aborted)se(S.map(({record:t})=>t));else if(S.length>0){let t=await Le(e,G,S.map(({record:i})=>i.Id));t.unread!==void 0&&l.reason(`Whether ${S.length} ${b} record(s) refused as deleted are still in the org could not be read (${t.unread}): left to be given back again`);for(let{record:i,why:a}of S){if(t.unread!==void 0){E(i,a);continue}if(!t.live.has(m(i.Id))){we(i);continue}let d=Object.keys(i).filter(h=>h!=="Id"&&de(i[h]));d.length===0?E(i,a):d.length===1?oe(i,d,[{fields:d,why:a}],!1):j.push({record:i,lookups:d,given:[],refusedAlone:[]})}}let V=j.length>0;for(let t=0;V&&j.some(({lookups:i})=>i.length>t);t++){let i=j.filter(({lookups:a})=>a.length>t);for(let a=0;a<i.length;a+=R){if(n.signal?.aborted){se(j.map(({record:f})=>f)),V=!1;break}let d=i.slice(a,a+R);(await z(d.map(({record:f,lookups:p})=>({Id:f.Id,[p[t]]:f[p[t]]})))).forEach((f,p)=>{let y=d[p],I=y.lookups[t];f.success===!0?y.given.push(I):y.refusedAlone.push({field:I,why:Q(f).words})})}}for(let t of V?j:[]){let i=new Map;for(let{field:a,why:d}of t.refusedAlone)i.set(d,[...i.get(d)??[],a]);oe(t.record,t.lookups,[...i].map(([a,d])=>({fields:d,why:a})),t.given.length>0)}for(let t=0;t<P.length;t+=R){let i=P.slice(t,t+R);if(n.signal?.aborted){u=!0,l.result.notReached=(l.result.notReached??0)+P.length-t,r.push(...P.slice(t).map(({record:d})=>k.get(m(d.Id))??d.Id));break}(await z(i.map(({record:d})=>d))).forEach((d,h)=>{let{record:f,leftOut:p}=i[h];if(d.success===!0){if(p.length===0){K(f);return}l.without();for(let y of p)l.reason(C(b,y));return}E(f,Q(d).words)})}Object.assign(c,await Ne(e,G,[...re],me,he))}return{objects:o,left:r,wrote:g,cancelled:u,stamps:c}}async function Ne(n,e,s,o,r){let c={};if(s.length===0)return c;let g=await r();if(g===void 0)return c;for(let u of _(s)){let A;try{A=(await n.query(`SELECT Id, LastModifiedDate, LastModifiedById FROM ${e} WHERE Id IN (${u})`)).records}catch{continue}for(let w of A)typeof w.Id=="string"&&typeof w.LastModifiedDate=="string"&&typeof w.LastModifiedById=="string"&&m(w.LastModifiedById)===g&&Date.parse(w.LastModifiedDate)>=o&&(c[w.Id]=w.LastModifiedDate)}return c}var B=class extends Error{};function Ze(n,e,s=[]){let o=n.map(r=>({...r}));for(let r of s){if(r.undeleted+r.refused===0)continue;let c=o.find(g=>g.objectApiName===r.objectApiName);c?(c.created+=r.undeleted,c.failed+=r.refused):o.push({objectApiName:r.objectApiName,created:r.undeleted,updated:0,deleted:0,failed:r.refused})}for(let r of e){let c=r.restored+(r.restoredWithout??0);if(c+r.refused===0)continue;let g=o.find(u=>u.objectApiName===r.objectApiName);g?(g.updated+=c,g.failed+=r.refused):o.push({objectApiName:r.objectApiName,created:0,updated:c,deleted:0,failed:r.refused})}return o}import{createReadStream as Me}from"node:fs";import{access as De,appendFile as $e,mkdir as _e,readFile as Ce,readdir as Be,rm as Te,stat as xe,writeFile as We}from"node:fs/promises";import*as M from"node:path";import{createInterface as Ge}from"node:readline";var ue=384,Ue=448;function rt(n){return{storagePath:n,readFile:e=>Ce(e,"utf8"),writeFile:(e,s)=>We(e,s,{encoding:"utf8",mode:ue}),appendFile:(e,s)=>$e(e,s,{encoding:"utf8",mode:ue}),exists:e=>De(e).then(()=>!0,()=>!1),readLines:e=>Je(e),mkdir:async e=>{await _e(e,{recursive:!0,mode:Ue})},rm:e=>Te(e,{force:!0}),listFiles:e=>qe(e)}}async function qe(n){let e;try{e=await Be(n,{withFileTypes:!0})}catch(o){if(o.code==="ENOENT")return[];throw o}let s=[];for(let o of e){if(!o.isFile())continue;let r=await xe(M.join(n,o.name)).catch(()=>{});r&&s.push({name:o.name,modifiedMs:r.mtimeMs})}return s}async function*Je(n){let e=Me(n,{encoding:"utf8"}),s=Ge({input:e,crlfDelay:1/0});try{for await(let o of s)yield o}finally{s.close(),e.destroy()}}function X(n){return n.replace(/[^A-Za-z0-9_-]/g,"_")}function le(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var ge=class{constructor(e){this.deps=e;this.dir=M.join(e.storagePath,"backups")}deps;dir;get directory(){return this.dir}filePath(e,s,o="lines"){let r=`${X(e)}__${X(s)}`;return M.join(this.dir,`${r}.${o==="lines"?"ndjson":"json"}`)}async begin(e,s){await this.deps.mkdir(this.dir).catch(()=>{}),await this.deps.writeFile(this.filePath(e,s),"")}async append(e,s,o){if(o.length===0)return;let r=o.map(c=>JSON.stringify(c)).join(`
|
|
7
|
+
import{J as H}from"./chunk-7SDZR6SR.mjs";import{b as R,c as de,d as _}from"./chunk-VPDEJGPS.mjs";import{i as ae}from"./chunk-INIT2UKJ.mjs";import{h as Y}from"./chunk-TZE3Y7IQ.mjs";import{b as F}from"./chunk-CA5NAXSU.mjs";var ke=5,Ie=100;function m(n){return n.slice(0,15)}function N(n){return n==null||n===""}var ce=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;function Re(n,e){if(N(n)||N(e))return N(n)&&N(e);if(typeof n=="number"||typeof e=="number")return Number(n)===Number(e);if(typeof n=="string"&&typeof e=="string"){if(n===e)return!0;if(ce.test(n)&&ce.test(e)){let s=Date.parse(n);return Number.isFinite(s)&&s===Date.parse(e)}return!1}return JSON.stringify(n)===JSON.stringify(e)}function Ae(n){let e;return()=>(e??=(async()=>{try{let s=await n.userId?.();return typeof s=="string"&&s!==""?m(s):void 0}catch{return}})(),e)}async function fe(n){let e=Date.now();try{let s=Date.parse(await n.serverTime());return Number.isFinite(s)?s-(e+Date.now())/2:0}catch{return 0}}async function Oe(n,e){let s=Date.parse(e??"");return Number.isFinite(s)?s+await fe(n)+H:Number.NEGATIVE_INFINITY}var ve=1e3;function Se(n){let e=Date.parse(n);return Number.isFinite(e)?e-ve:Number.NEGATIVE_INFINITY}function Pe(n,e){let s=Object.hasOwn(n,e)?n[e]:[];return new Map(s.filter(o=>o.toLowerCase()!=="id").map(o=>[o.toLowerCase(),o]))}var Ee={INACTIVE_OWNER_OR_USER:"OwnerId"};function je(n,e){let s=new Set;for(let r of n.errors??[]){if(typeof r=="string")continue;if(Array.isArray(r.fields))for(let g of r.fields)typeof g=="string"&&s.add(g);let c=r.statusCode!==void 0?Ee[r.statusCode]:void 0;c!==void 0&&(!Array.isArray(r.fields)||r.fields.length===0)&&s.add(c)}let o=new Map(Object.keys(e).map(r=>[r.toLowerCase(),r]));return[...s].flatMap(r=>{let c=o.get(r.toLowerCase());return c!==void 0&&c!=="Id"?[c]:[]})}function Fe(n,e){let s=Array.isArray(n)?n:[n];return Array.from({length:e},(o,r)=>s[r]??{success:!1})}function Q(n){let e=n.errors?.[0];if(e===void 0)return{words:"The org gave no reason."};if(typeof e=="string")return{words:e};let s=e.statusCode,o=e.message??"";return{...s?{code:s}:{},words:s&&o?`${s}: ${o}`:s||o}}function C(n,{fields:e,why:s}){return`${e.map(o=>`${n}.${o}`).join(", ")}: the value from before is no longer taken (${s}) \u2014 left as the run wrote it`}async function Le(n,e,s){let o=new Set;try{for(let r of _(s)){let c=await n.query(`SELECT Id FROM ${e} WHERE Id IN (${r})`);for(let g of c.records)typeof g.Id=="string"&&o.add(m(g.Id))}}catch(r){return{unread:F(r)}}return{live:o}}var Z=class{result;said=new Set;constructor(e,s){this.result={objectApiName:e,planned:s,restored:0,keptChanged:0,alreadyGone:0,refused:0,notKept:0,reasons:[]}}without(){this.result.restoredWithout=(this.result.restoredWithout??0)+1}reason(e){this.said.has(e)||this.said.size>=ke||(this.said.add(e),this.result.reasons.push(e))}};async function Qe(n){let{org:e,plan:s}=n,o=[],r=[],c={},g=!1,u=!1;if(s.length===0)return{objects:o,left:r,wrote:g,cancelled:u,stamps:c};let A=n.changedAfter!==void 0?Se(n.changedAfter):await Oe(e,n.lastWriteAt),w=new Map(Object.entries(n.stamps??{}).map(([b,x])=>[m(b),Date.parse(x)])),L=n.ownWriters&&n.ownWriters.length>0?new Set(n.ownWriters.map(m)):void 0,T=n.stampsFor,he=Ae(e);for(let{objectApiName:b,backup:x,ids:D}of s){let l=new Z(b,D.length);o.push(l.result);let W=n.unkept?.find(t=>t.objectApiName===b);if(W&&W.fields.length>0&&l.reason(`${W.fields.map(t=>`${b}.${t}`).join(", ")}: not kept, encrypted \u2014 the run's user cannot view encrypted data, and read their values from before masked; left as the run wrote them`),u||n.signal?.aborted){u=!0,l.result.notReached=D.length,r.push(...D);continue}let G=Y(b),k=new Map(D.map(t=>[m(t),t])),U=n.fields?Pe(n.fields,b):void 0,v=new Map,q=new Set;try{let t=await n.backups.batches(x,b,R);for await(let i of t??[])for(let a of i){if(typeof a.Id!="string"||!k.has(m(a.Id)))continue;let d=v.get(m(a.Id))??{};for(let[h,f]of Object.entries(a)){if(h==="Id")continue;let p=U?U.get(h.toLowerCase()):h;p!==void 0&&!(p in d)&&(d[p]=f)}if(U&&Object.keys(d).length===0){q.add(m(a.Id));continue}v.set(m(a.Id),d)}}catch(t){l.reason(`The values from before the run could not be read: ${F(t)}`),v.clear(),q.clear()}let ee=[...q].filter(t=>!v.has(t)).length;ee>0&&l.reason(`${ee} ${b} record(s) hold no value of a field that may be written back now: left as they are`);for(let t of[...k.keys()])v.has(t)||(l.result.notKept++,k.delete(t));if(k.size===0)continue;let te=new Set;for(let t of v.values())for(let i of Object.keys(t))te.add(Y(i));let ne=["Id","LastModifiedDate",...L?["LastModifiedById"]:[],...te],pe=ne.length>Ie?R/4:R,J=new Map,ye=async t=>{if(n.signal?.aborted)throw new B;return(await e.query(t)).records};try{for(let t of _([...k.values()],pe)){let i=await ae(`SELECT ${ne.join(", ")} FROM ${G} WHERE Id IN (${t})`,ye,{stamp:"LastModifiedDate"});for(let a of i)typeof a.Id=="string"&&J.set(m(a.Id),a)}}catch(t){if(t instanceof B){u=!0,l.result.notReached=k.size,r.push(...k.values());continue}l.result.refused+=k.size,l.reason(F(t)),r.push(...k.values());continue}let $=[],re=new Set,me=T?Date.now()+await fe(e)-H:0;for(let[t,i]of k){let a=J.get(t);if(!a){l.result.alreadyGone++,n.counted?.(i,"alreadyGone");continue}let d=Date.parse(String(a.LastModifiedDate??"")),h=a.LastModifiedById,f=d<=A||d<=(w.get(t)??Number.NaN)||L!==void 0&&typeof h=="string"&&L.has(m(h));if(!f&&!n.includeChanged){l.result.keptChanged++,r.push(i);continue}let p=v.get(t)??{},y={Id:a.Id};for(let[I,O]of Object.entries(p))Re(O,a[I])||(y[I]=N(O)?null:O);if(Object.keys(y).length===1){l.result.restored++,n.counted?.(i,"restored"),f&&T?.(i)&&typeof a.LastModifiedDate=="string"&&(c[a.Id]=a.LastModifiedDate);continue}$.push(y),f&&T?.(i)&&re.add(i)}let P=[],S=[],E=(t,i)=>{l.result.refused++,l.reason(i),r.push(k.get(m(t.Id))??t.Id)},K=t=>{l.result.restored++,n.counted?.(k.get(m(t.Id))??t.Id,"restored")},we=t=>{l.result.alreadyGone++,n.counted?.(k.get(m(t.Id))??t.Id,"alreadyGone")},se=t=>{u=!0,l.result.notReached=(l.result.notReached??0)+t.length,r.push(...t.map(i=>k.get(m(i.Id))??i.Id))},oe=(t,i,a,d)=>{let h=Object.keys(t).filter(y=>y!=="Id"&&!i.includes(y));if(h.length>0){let y={Id:t.Id};for(let I of h)y[I]=t[I];P.push({record:y,leftOut:a});return}if(a.length===0){K(t);return}let[f,...p]=a;d?(l.without(),l.reason(C(b,f))):E(t,C(b,f));for(let y of p)l.reason(C(b,y))},z=async t=>{try{return g=!0,Fe(await e.update(b,[...t]),t.length)}catch(i){let a=F(i);return t.map(()=>({success:!1,errors:[a]}))}},be=async t=>{let i=n.keep;if(!i)return!0;let a=t.map(d=>{let h=J.get(m(d.Id))??{},f={Id:d.Id};for(let p of Object.keys(d))p!=="Id"&&(f[p]=h[p]??null);return f});try{return await i(b,a),!0}catch(d){let h=`What these ${t.length} ${b} record(s) hold now could not be kept before they were written (${F(d)}), so none of them was written: nothing is written over that cannot be put back.`;for(let f of t)E(f,h);return!1}};for(let t=0;t<$.length;t+=R){let i=$.slice(t,t+R);if(n.signal?.aborted){u=!0;let d=$.slice(t);l.result.notReached=(l.result.notReached??0)+d.length,r.push(...d.map(h=>k.get(m(h.Id))??h.Id));break}if(!await be(i))continue;(await z(i)).forEach((d,h)=>{let f=i[h];if(d.success===!0){K(f);return}let p=Q(d),y=je(d,f);if(p.code==="ENTITY_IS_DELETED"&&y.length===0){S.push({record:f,why:p.words});return}let I=Object.keys(f).filter(O=>O!=="Id"&&!y.includes(O));if(y.length>0&&I.length>0){let O={Id:f.Id};for(let ie of I)O[ie]=f[ie];P.push({record:O,leftOut:[{fields:y,why:p.words}]});return}E(f,p.words)})}let j=[];if(S.length>0&&n.signal?.aborted)se(S.map(({record:t})=>t));else if(S.length>0){let t=await Le(e,G,S.map(({record:i})=>i.Id));t.unread!==void 0&&l.reason(`Whether ${S.length} ${b} record(s) refused as deleted are still in the org could not be read (${t.unread}): left to be given back again`);for(let{record:i,why:a}of S){if(t.unread!==void 0){E(i,a);continue}if(!t.live.has(m(i.Id))){we(i);continue}let d=Object.keys(i).filter(h=>h!=="Id"&&de(i[h]));d.length===0?E(i,a):d.length===1?oe(i,d,[{fields:d,why:a}],!1):j.push({record:i,lookups:d,given:[],refusedAlone:[]})}}let V=j.length>0;for(let t=0;V&&j.some(({lookups:i})=>i.length>t);t++){let i=j.filter(({lookups:a})=>a.length>t);for(let a=0;a<i.length;a+=R){if(n.signal?.aborted){se(j.map(({record:f})=>f)),V=!1;break}let d=i.slice(a,a+R);(await z(d.map(({record:f,lookups:p})=>({Id:f.Id,[p[t]]:f[p[t]]})))).forEach((f,p)=>{let y=d[p],I=y.lookups[t];f.success===!0?y.given.push(I):y.refusedAlone.push({field:I,why:Q(f).words})})}}for(let t of V?j:[]){let i=new Map;for(let{field:a,why:d}of t.refusedAlone)i.set(d,[...i.get(d)??[],a]);oe(t.record,t.lookups,[...i].map(([a,d])=>({fields:d,why:a})),t.given.length>0)}for(let t=0;t<P.length;t+=R){let i=P.slice(t,t+R);if(n.signal?.aborted){u=!0,l.result.notReached=(l.result.notReached??0)+P.length-t,r.push(...P.slice(t).map(({record:d})=>k.get(m(d.Id))??d.Id));break}(await z(i.map(({record:d})=>d))).forEach((d,h)=>{let{record:f,leftOut:p}=i[h];if(d.success===!0){if(p.length===0){K(f);return}l.without();for(let y of p)l.reason(C(b,y));return}E(f,Q(d).words)})}Object.assign(c,await Ne(e,G,[...re],me,he))}return{objects:o,left:r,wrote:g,cancelled:u,stamps:c}}async function Ne(n,e,s,o,r){let c={};if(s.length===0)return c;let g=await r();if(g===void 0)return c;for(let u of _(s)){let A;try{A=(await n.query(`SELECT Id, LastModifiedDate, LastModifiedById FROM ${e} WHERE Id IN (${u})`)).records}catch{continue}for(let w of A)typeof w.Id=="string"&&typeof w.LastModifiedDate=="string"&&typeof w.LastModifiedById=="string"&&m(w.LastModifiedById)===g&&Date.parse(w.LastModifiedDate)>=o&&(c[w.Id]=w.LastModifiedDate)}return c}var B=class extends Error{};function Ze(n,e,s=[]){let o=n.map(r=>({...r}));for(let r of s){if(r.undeleted+r.refused===0)continue;let c=o.find(g=>g.objectApiName===r.objectApiName);c?(c.created+=r.undeleted,c.failed+=r.refused):o.push({objectApiName:r.objectApiName,created:r.undeleted,updated:0,deleted:0,failed:r.refused})}for(let r of e){let c=r.restored+(r.restoredWithout??0);if(c+r.refused===0)continue;let g=o.find(u=>u.objectApiName===r.objectApiName);g?(g.updated+=c,g.failed+=r.refused):o.push({objectApiName:r.objectApiName,created:0,updated:c,deleted:0,failed:r.refused})}return o}import{createReadStream as Me}from"node:fs";import{access as De,appendFile as $e,mkdir as _e,readFile as Ce,readdir as Be,rm as Te,stat as xe,writeFile as We}from"node:fs/promises";import*as M from"node:path";import{createInterface as Ge}from"node:readline";var ue=384,Ue=448;function rt(n){return{storagePath:n,readFile:e=>Ce(e,"utf8"),writeFile:(e,s)=>We(e,s,{encoding:"utf8",mode:ue}),appendFile:(e,s)=>$e(e,s,{encoding:"utf8",mode:ue}),exists:e=>De(e).then(()=>!0,()=>!1),readLines:e=>Je(e),mkdir:async e=>{await _e(e,{recursive:!0,mode:Ue})},rm:e=>Te(e,{force:!0}),listFiles:e=>qe(e)}}async function qe(n){let e;try{e=await Be(n,{withFileTypes:!0})}catch(o){if(o.code==="ENOENT")return[];throw o}let s=[];for(let o of e){if(!o.isFile())continue;let r=await xe(M.join(n,o.name)).catch(()=>{});r&&s.push({name:o.name,modifiedMs:r.mtimeMs})}return s}async function*Je(n){let e=Me(n,{encoding:"utf8"}),s=Ge({input:e,crlfDelay:1/0});try{for await(let o of s)yield o}finally{s.close(),e.destroy()}}function X(n){return n.replace(/[^A-Za-z0-9_-]/g,"_")}function le(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var ge=class{constructor(e){this.deps=e;this.dir=M.join(e.storagePath,"backups")}deps;dir;get directory(){return this.dir}filePath(e,s,o="lines"){let r=`${X(e)}__${X(s)}`;return M.join(this.dir,`${r}.${o==="lines"?"ndjson":"json"}`)}async begin(e,s){await this.deps.mkdir(this.dir).catch(()=>{}),await this.deps.writeFile(this.filePath(e,s),"")}async append(e,s,o){if(o.length===0)return;let r=o.map(c=>JSON.stringify(c)).join(`
|
|
8
8
|
`);await this.deps.appendFile(this.filePath(e,s),`${r}
|
|
9
9
|
`)}async batches(e,s,o){let r=this.filePath(e,s);if(await this.deps.exists(r))return{[Symbol.asyncIterator]:()=>this.readLineBatches(r,s,o)};let c=this.filePath(e,s,"array");return await this.deps.exists(c)?{[Symbol.asyncIterator]:()=>this.readArrayBatches(c,s,o)}:null}async*readLineBatches(e,s,o){let r=[],c=0;for await(let g of this.deps.readLines(e)){if(c+=1,g.trim()==="")continue;let u;try{u=JSON.parse(g)}catch{u=void 0}if(!le(u))throw new Error(`The backup of ${s} is damaged at line ${c} of its file: it holds no record there.`);r.push(u),r.length===o&&(yield r,r=[])}r.length>0&&(yield r)}async*readArrayBatches(e,s,o){let r=JSON.parse(await this.deps.readFile(e));if(!Array.isArray(r)||!r.every(le))throw new Error(`The backup of ${s} is damaged: its file holds no records.`);for(let c=0;c<r.length;c+=o)yield r.slice(c,c+o)}async delete(e,s){await this.deps.rm(this.filePath(e,s)).catch(()=>{}),await this.deps.rm(this.filePath(e,s,"array")).catch(()=>{})}async sweep(e,s,o){let r=[...e].map(u=>`${X(u)}__`),c=new Map;for(let u of await this.deps.listFiles(this.dir)){if(!/\.(?:ndjson|json)$/.test(u.name))continue;let A=u.name.indexOf("__");if(A<=0||r.some(L=>u.name.startsWith(L)))continue;let w=u.name.slice(0,A);c.set(w,[...c.get(w)??[],u])}let g=[];for(let u of c.values()){let A=Math.max(...u.map(w=>w.modifiedMs));if(!(o-A<s))for(let w of u)await this.deps.rm(M.join(this.dir,w.name)).then(()=>g.push(w.name),()=>{})}return g}};export{Re as a,Ae as b,fe as c,Oe as d,Qe as e,Ne as f,Ze as g,rt as h,ge as i};
|