@trilogy-data/trilogy-studio-components 0.1.25 → 0.1.26
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/dist/AssetAutoImporter-CBzvBaOt.js +405 -0
- package/dist/ChatCreatorModal-CL-jBnc3.js +218 -0
- package/dist/ChatModelSelect-Do-VRUFc.js +40 -0
- package/dist/{CommunityModels-D7zWnHgG.js → CommunityModels-Cmro0hV3.js} +101 -70
- package/dist/{Dashboard-D1ZCTw5r.js → Dashboard-BH9ZwMVJ.js} +8 -8
- package/dist/{DashboardCreatorInline-LWvf--2x.js → DashboardCreatorInline-CDU7kLy3.js} +3 -3
- package/dist/{DashboardImportSelector-CNxibXlS.js → DashboardImportSelector-DQSvu9T-.js} +1 -1
- package/dist/{DashboardMobile-D_m0xv17.js → DashboardMobile-BUPtdN2V.js} +4 -4
- package/dist/{Editor-DhsP18KE.js → Editor-DQsYpkwl.js} +6 -6
- package/dist/{GlobalChatPanel-DFx9A4yP.js → GlobalChatPanel-DhnOaige.js} +155 -119
- package/dist/{IDE-BRMLxTfP.js → IDE-HLa8vybk.js} +9 -9
- package/dist/{JobsView-C9PYS6pZ.js → JobsView-B97HBoIE.js} +8 -8
- package/dist/{LLMChat-Cqg6pTgC.js → LLMChat-CxJcPLEG.js} +1 -1
- package/dist/{LLMView-VkJpP-49.js → LLMView-C1MUf0c2.js} +21 -21
- package/dist/{MobileIDE-CHGJoh05.js → MobileIDE-BpqXoaMR.js} +258 -253
- package/dist/{ModelCard-D8tKkK9-.js → ModelCard-BhN25jaV.js} +10 -10
- package/dist/{ModelCreator-DrxLxeyH.js → ModelCreator-CCdC7EXt.js} +1 -1
- package/dist/{ModelView-rAurf9n8.js → ModelView-DUDA_PtZ.js} +3 -3
- package/dist/{PageLoading-I6mr-7NB.js → PageLoading-BzniJM0C.js} +622 -619
- package/dist/{ResultComponent-_-1qZCfv.js → ResultComponent-CAn_r3BL.js} +3 -3
- package/dist/{Results-CQGpFmPQ.js → Results-BJtlwebY.js} +3 -3
- package/dist/{SymbolsPane-BpmL___H.js → SymbolsPane-KYSwN9Sv.js} +1 -1
- package/dist/{TutorialPage-CZGBRJdq.js → TutorialPage-NRcee6Dx.js} +8 -8
- package/dist/{VegaLiteChart-CmkOw6yD.js → VegaLiteChart-D1slfOUY.js} +11227 -11195
- package/dist/{WelcomePage-CLKvAvk-.js → WelcomePage-D5mU2x1L.js} +1 -1
- package/dist/components/AssetAutoImporter.vue.d.ts.map +1 -1
- package/dist/components/TipsCTA.vue.d.ts +1 -1
- package/dist/components/VegaLiteChart.vue.d.ts.map +1 -1
- package/dist/components/chartHelpers.d.ts +9 -1
- package/dist/components/chartHelpers.d.ts.map +1 -1
- package/dist/components/chartRenderManager.d.ts +4 -1
- package/dist/components/chartRenderManager.d.ts.map +1 -1
- package/dist/components/community/AddStoreModal.vue.d.ts +1 -1
- package/dist/components/community/AddStoreModal.vue.d.ts.map +1 -1
- package/dist/components/community/CommunityModelCard.vue.d.ts.map +1 -1
- package/dist/components/editor/Editor.vue.d.ts.map +1 -1
- package/dist/components/jobs/JobsAddStoreModal.vue.d.ts.map +1 -1
- package/dist/components/llm/ChatCreatorModal.vue.d.ts +17 -1
- package/dist/components/llm/ChatCreatorModal.vue.d.ts.map +1 -1
- package/dist/components/llm/ChatModelSelect.vue.d.ts +13 -0
- package/dist/components/llm/ChatModelSelect.vue.d.ts.map +1 -0
- package/dist/components/llm/GlobalChatPanel.vue.d.ts.map +1 -1
- package/dist/components/sidebar/CommunityModelList.vue.d.ts +33 -50
- package/dist/components/sidebar/CommunityModelList.vue.d.ts.map +1 -1
- package/dist/components/sidebar/CommunityModelListItem.vue.d.ts.map +1 -1
- package/dist/components/sidebar/EditorList.vue.d.ts +32 -49
- package/dist/components/sidebar/EditorList.vue.d.ts.map +1 -1
- package/dist/components/sidebar/Sidebar.vue.d.ts +65 -99
- package/dist/components/sidebar/Sidebar.vue.d.ts.map +1 -1
- package/dist/dashboard.js +52 -52
- package/dist/{dashboardStore-CNkWQ4r7.js → dashboardStore-ppM6nGks.js} +33 -33
- package/dist/dashboards/layerSpec.d.ts +38 -4
- package/dist/dashboards/layerSpec.d.ts.map +1 -1
- package/dist/dashboards/lineAreaSpec.d.ts +8 -80
- package/dist/dashboards/lineAreaSpec.d.ts.map +1 -1
- package/dist/dashboards/mapSpec.d.ts +1 -0
- package/dist/dashboards/mapSpec.d.ts.map +1 -1
- package/dist/dashboards/spec.d.ts.map +1 -1
- package/dist/data/tutorial/documentation.d.ts.map +1 -1
- package/dist/data/tutorial/startupScripts.d.ts +3 -0
- package/dist/data/tutorial/startupScripts.d.ts.map +1 -0
- package/dist/{demoSetup-DiW3ROFQ.js → demoSetup-mwa-RDC6.js} +19 -18
- package/dist/{editorRefinementRuntime-C_YmXRy4.js → editorRefinementRuntime-DoP9P5J2.js} +892 -871
- package/dist/{editorRefinementToolExecutor-mX8ClQ63.js → editorRefinementToolExecutor-CVY3FA7k.js} +389 -263
- package/dist/{editorStore-Ch7k-gse.js → editorStore-BhhmXbi-.js} +230 -183
- package/dist/entry.dashboard.d.ts +1 -0
- package/dist/entry.dashboard.d.ts.map +1 -1
- package/dist/{globalChatRuntime-oMLiPLNC.js → globalChatRuntime-DWZxeS57.js} +13 -13
- package/dist/{helpers-DcWCa6bX.js → helpers-BLQAgX3C.js} +17 -16
- package/dist/llm/data/constants.d.ts +1 -1
- package/dist/llm/data/constants.d.ts.map +1 -1
- package/dist/llm/data/trilogySyntax.generated.d.ts +7 -1
- package/dist/llm/data/trilogySyntax.generated.d.ts.map +1 -1
- package/dist/llm/docsIndex.d.ts.map +1 -1
- package/dist/llm/openai.d.ts +2 -1
- package/dist/llm/openai.d.ts.map +1 -1
- package/dist/{llm-_807I79k.js → llm-BBOVWb-F.js} +7 -5
- package/dist/llm.js +3 -3
- package/dist/{llmStore-CSzM1IZd.js → llmStore-DJM2JhzY.js} +2 -2
- package/dist/{localStorage-CSuYS7QE.js → localStorage-D9uyOFEO.js} +14 -14
- package/dist/models/helpers.d.ts.map +1 -1
- package/dist/monaco.js +1 -1
- package/dist/{reconcile-Bk7M797_.js → reconcile-Dyf4UZmj.js} +1 -1
- package/dist/{remoteStoreSync-CLvZJrTK.js → remoteStoreSync-Z-yjlYtI.js} +1 -1
- package/dist/remotes/displayHelpers.d.ts.map +1 -1
- package/dist/remotes/genericStoreMetadata.d.ts +1 -0
- package/dist/remotes/genericStoreMetadata.d.ts.map +1 -1
- package/dist/remotes/models.d.ts +37 -5
- package/dist/remotes/models.d.ts.map +1 -1
- package/dist/remotes/staticStorePresets.d.ts +22 -0
- package/dist/remotes/staticStorePresets.d.ts.map +1 -0
- package/dist/remotes/storeService.d.ts +25 -4
- package/dist/remotes/storeService.d.ts.map +1 -1
- package/dist/stores/communityApiStore.d.ts +32 -60
- package/dist/stores/communityApiStore.d.ts.map +1 -1
- package/dist/stores/connectionStore.d.ts.map +1 -1
- package/dist/stores/resolver.d.ts +5 -0
- package/dist/stores/resolver.d.ts.map +1 -1
- package/dist/stores/urlStore.d.ts +1 -0
- package/dist/stores/urlStore.d.ts.map +1 -1
- package/dist/{stores-C1wUWiFm.js → stores-BT9hTLny.js} +47 -47
- package/dist/stores.js +7 -7
- package/dist/trilogy-studio-components.css +1 -1
- package/dist/{urlStore-Dgmwx1YI.js → urlStore-52HG6lsX.js} +1 -0
- package/dist/{useChatWithTools-GV1ufcqw.js → useChatWithTools-B0HZ_DVh.js} +1 -1
- package/dist/{useDashboard-OoBKkkuQ.js → useDashboard-CdSnPe_6.js} +186 -186
- package/dist/{useGlobalChatPanel-CIeUyZba.js → useGlobalChatPanel-D_0luajQ.js} +2 -2
- package/dist/views/MobileIDE.vue.d.ts.map +1 -1
- package/dist/views/TutorialPage.vue.d.ts +32 -49
- package/dist/views/TutorialPage.vue.d.ts.map +1 -1
- package/dist/views.js +16 -16
- package/package.json +1 -1
- package/dist/AssetAutoImporter-DfMd_DSk.js +0 -403
- package/dist/ChatCreatorModal-BTqY06B6.js +0 -177
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as n, D as r, M as i, S as a, i as o, t as s, w as c, x as l } from "./editorRefinementRuntime-
|
|
1
|
+
import { cn as e, ln as t } from "./editorRefinementToolExecutor-CVY3FA7k.js";
|
|
2
|
+
import { C as n, D as r, M as i, S as a, i as o, t as s, w as c, x as l } from "./editorRefinementRuntime-DoP9P5J2.js";
|
|
3
3
|
import { s as u } from "./base-C8IuZWqY.js";
|
|
4
4
|
import { r as d, t as f } from "./connections-CJSb1TZl.js";
|
|
5
5
|
import { a as p, i as m, o as h, s as g, t as _ } from "./remoteWorker-Dkv3TJ0j.js";
|
|
6
|
-
import "./llm-
|
|
6
|
+
import "./llm-BBOVWb-F.js";
|
|
7
7
|
import { reactive as v } from "vue";
|
|
8
8
|
import { defineStore as y } from "pinia";
|
|
9
9
|
//#region stores/modelStore.ts
|
|
@@ -73,17 +73,17 @@ var b = y("models", {
|
|
|
73
73
|
}
|
|
74
74
|
async deleteProject(e) {}
|
|
75
75
|
async clearProjects() {}
|
|
76
|
-
}, S = (e) => new Promise((t) => setTimeout(t, e)), ee = /* @__PURE__ */ new Set(),
|
|
76
|
+
}, S = (e) => new Promise((t) => setTimeout(t, e)), ee = /* @__PURE__ */ new Set(), C = /* @__PURE__ */ new Set(), te = (e) => {
|
|
77
77
|
if (ee.has(e)) return !0;
|
|
78
78
|
let t = e;
|
|
79
79
|
e.includes("://") || (t = `http://${e}`);
|
|
80
80
|
try {
|
|
81
81
|
let e = new URL(t), n = e.host, r = e.hostname;
|
|
82
|
-
if (
|
|
82
|
+
if (C.has(n) || C.has(r)) return !0;
|
|
83
83
|
} catch {}
|
|
84
84
|
return !1;
|
|
85
|
-
},
|
|
86
|
-
if (
|
|
85
|
+
}, w = async (e, t, n = 5, r = 1e3) => {
|
|
86
|
+
if (te(e)) throw Error(`Cannot connect to ${e} - blocked by Content Security Policy. This URL is not allowed by the browser's security settings.`);
|
|
87
87
|
let i = 0, a = r;
|
|
88
88
|
for (;;) try {
|
|
89
89
|
let r = await fetch(e, t);
|
|
@@ -94,41 +94,41 @@ var b = y("models", {
|
|
|
94
94
|
}
|
|
95
95
|
return r;
|
|
96
96
|
} catch (t) {
|
|
97
|
-
if (
|
|
97
|
+
if (te(e)) throw Error(`Cannot connect to ${e} - blocked by Content Security Policy. This URL is not allowed by the browser's security settings.`);
|
|
98
98
|
let r = t instanceof Error ? t.message : String(t);
|
|
99
99
|
if (t instanceof TypeError || r.includes("Failed to fetch") || r.includes("NetworkError") || r.includes("ERR_CONNECTION_REFUSED") || r.includes("Load failed") || r.includes("network connection was lost") || r.includes("Could not connect to the server") || r.includes("fetch failed") || i >= n) throw t;
|
|
100
100
|
console.log(`Network error, retrying after ${a}ms (Attempt ${i + 1}/${n})`), await S(a), a = a * 2 * (.8 + Math.random() * .4), i++;
|
|
101
101
|
}
|
|
102
|
-
},
|
|
102
|
+
}, ne = (e, t, n, r, i) => e.filter((e) => {
|
|
103
103
|
let a = e.name.toLowerCase().includes(t.toLowerCase()), o = !n || e.engine === n, s = !0;
|
|
104
104
|
if (r !== "all") {
|
|
105
105
|
let t = i(e.name);
|
|
106
106
|
s = r === "imported" && t || r === "not-imported" && !t;
|
|
107
107
|
}
|
|
108
108
|
return a && o && s;
|
|
109
|
-
}),
|
|
109
|
+
}), re = (e) => {
|
|
110
110
|
switch (e) {
|
|
111
111
|
case "bigquery": return "new-bigquery-oauth";
|
|
112
112
|
case "duckdb": return "new-duckdb";
|
|
113
113
|
default: return `new-${e}`;
|
|
114
114
|
}
|
|
115
|
-
},
|
|
115
|
+
}, ie = (e) => {
|
|
116
116
|
let t = /* @__PURE__ */ new Set();
|
|
117
117
|
return e.forEach((e) => {
|
|
118
118
|
e.engine && t.add(e.engine);
|
|
119
119
|
}), Array.from(t).sort();
|
|
120
|
-
},
|
|
120
|
+
}, T = (e) => {
|
|
121
121
|
if (e) return { headers: { "X-Trilogy-Token": e } };
|
|
122
|
-
},
|
|
123
|
-
let t = await
|
|
122
|
+
}, E = async (e) => {
|
|
123
|
+
let t = await w(`${e.baseUrl}/index.json`, T(e.token));
|
|
124
124
|
if (!t.ok) throw Error(`Failed to fetch store index: ${t.status} ${t.statusText}`);
|
|
125
125
|
return t.json();
|
|
126
|
-
},
|
|
126
|
+
}, ae = async (e) => {
|
|
127
127
|
let t = null, n = [];
|
|
128
128
|
try {
|
|
129
|
-
let t = (await
|
|
129
|
+
let t = (await E(e)).models.map(async (t) => {
|
|
130
130
|
try {
|
|
131
|
-
let n = await
|
|
131
|
+
let n = await w(t.url, T(e.token));
|
|
132
132
|
if (!n.ok) return console.warn(`Failed to fetch model ${t.name}: ${n.statusText}`), null;
|
|
133
133
|
let r = await n.json();
|
|
134
134
|
return r.downloadUrl = t.url, r.store = e, r;
|
|
@@ -144,38 +144,60 @@ var b = y("models", {
|
|
|
144
144
|
files: n,
|
|
145
145
|
error: t
|
|
146
146
|
};
|
|
147
|
-
},
|
|
147
|
+
}, D = (e, t) => {
|
|
148
|
+
try {
|
|
149
|
+
return new URL(e, t).toString();
|
|
150
|
+
} catch {
|
|
151
|
+
return e;
|
|
152
|
+
}
|
|
153
|
+
}, oe = (e, t) => {
|
|
154
|
+
if (!e || typeof e != "object") throw Error("Store index is not a JSON object");
|
|
155
|
+
let n = e, r;
|
|
156
|
+
if (Array.isArray(n.models)) r = n.models;
|
|
157
|
+
else if (Array.isArray(n.files)) r = n.files.filter((e) => typeof e.filename == "string" && e.filename.endsWith(".json")).map((e) => ({
|
|
158
|
+
name: e.name || e.filename.replace(/\.json$/, ""),
|
|
159
|
+
url: e.filename,
|
|
160
|
+
engine: e.engine,
|
|
161
|
+
description: e.description,
|
|
162
|
+
tags: e.tags
|
|
163
|
+
}));
|
|
164
|
+
else throw Error("Store index has neither `models` nor `files`");
|
|
165
|
+
return {
|
|
166
|
+
name: typeof n.name == "string" ? n.name : void 0,
|
|
167
|
+
updated_at: typeof n.updated_at == "string" ? n.updated_at : void 0,
|
|
168
|
+
generation: typeof n.generation == "number" ? n.generation : void 0,
|
|
169
|
+
models: r.filter((e) => e && typeof e.url == "string").map((e) => ({
|
|
170
|
+
...e,
|
|
171
|
+
url: D(e.url, t)
|
|
172
|
+
}))
|
|
173
|
+
};
|
|
174
|
+
}, O = (e, t) => (Array.isArray(e.components) && (e.components = e.components.map((e) => ({
|
|
175
|
+
...e,
|
|
176
|
+
url: D(e.url, t)
|
|
177
|
+
}))), e), se = (e) => `${e.baseUrl.replace(/\/$/, "")}/index.json`, ce = async (e) => {
|
|
148
178
|
let t = null, n = [];
|
|
149
179
|
try {
|
|
150
|
-
let t, r;
|
|
151
|
-
|
|
152
|
-
let i = await
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
let e = await i.json();
|
|
158
|
-
a = JSON.parse(atob(e.content));
|
|
159
|
-
}
|
|
160
|
-
let o = a.files.filter((e) => e.filename.endsWith(".json")).map(async (t) => {
|
|
161
|
-
let n = `${r}${t.filename}`, i = await C(n);
|
|
162
|
-
if (!i.ok) throw Error(`Error fetching file ${t.filename}: ${i.statusText}`);
|
|
163
|
-
let a = await i.json();
|
|
164
|
-
return a.downloadUrl = n, a.store = e, a;
|
|
180
|
+
let t = se(e), r = await w(t);
|
|
181
|
+
if (!r.ok) throw Error(`Failed to fetch store index: ${r.status} ${r.statusText}`);
|
|
182
|
+
let i = oe(await r.json(), t).models.map(async (t) => {
|
|
183
|
+
let n = await w(t.url);
|
|
184
|
+
if (!n.ok) throw Error(`Error fetching model ${t.name}: ${n.statusText}`);
|
|
185
|
+
let r = O(await n.json(), t.url);
|
|
186
|
+
return r.downloadUrl = t.url, r.store = e, r;
|
|
165
187
|
});
|
|
166
|
-
n = await Promise.all(
|
|
188
|
+
n = await Promise.all(i);
|
|
167
189
|
} catch (e) {
|
|
168
|
-
t = e instanceof Error ? e.message : "Error fetching files", console.error("Error fetching from
|
|
190
|
+
t = e instanceof Error ? e.message : "Error fetching files", console.error("Error fetching from static store:", e);
|
|
169
191
|
}
|
|
170
192
|
return {
|
|
171
193
|
files: n,
|
|
172
194
|
error: t
|
|
173
195
|
};
|
|
174
|
-
},
|
|
196
|
+
}, k = async (e) => e.type === "static" ? ce(e) : ae(e), le = async (e, t) => {
|
|
175
197
|
let n = {}, r = {};
|
|
176
198
|
return await Promise.all(e.map(async (e) => {
|
|
177
199
|
try {
|
|
178
|
-
let { files: i, error: a } = await
|
|
200
|
+
let { files: i, error: a } = await k(e);
|
|
179
201
|
n[e.id] = i, a && (r[e.id] = a), t && t(e.id, {
|
|
180
202
|
files: i,
|
|
181
203
|
error: a
|
|
@@ -191,17 +213,17 @@ var b = y("models", {
|
|
|
191
213
|
filesByStore: n,
|
|
192
214
|
errors: r
|
|
193
215
|
};
|
|
194
|
-
},
|
|
216
|
+
}, ue = {
|
|
195
217
|
stale: 3,
|
|
196
218
|
unknown: 2,
|
|
197
219
|
fresh: 1
|
|
198
|
-
},
|
|
199
|
-
let t = e.datasources.reduce((e, t) => !e ||
|
|
200
|
-
return t &&
|
|
201
|
-
},
|
|
220
|
+
}, A = (e) => ue[e] ?? 0, de = (e) => e.observed_watermarks.reduce((e, t) => e ? t.probed_at > e.probed_at ? t : e : t, null), j = (e) => {
|
|
221
|
+
let t = e.datasources.reduce((e, t) => !e || A(t.status) > A(e) ? t.status : e, null);
|
|
222
|
+
return t && A(t) > A(e.status) ? t : e.status;
|
|
223
|
+
}, fe = (e) => e.partition_by.map((e) => e.column), pe = (e) => {
|
|
202
224
|
let t = Object.entries(e.values).map(([e, t]) => `${e}=${t ?? "—"}`);
|
|
203
225
|
return t.length ? t.join(", ") : e.partition_id;
|
|
204
|
-
},
|
|
226
|
+
}, me = (e) => {
|
|
205
227
|
let t = {
|
|
206
228
|
total: e.partitions.length,
|
|
207
229
|
fresh: 0,
|
|
@@ -214,35 +236,35 @@ var b = y("models", {
|
|
|
214
236
|
return e.partitions.forEach((e) => {
|
|
215
237
|
e.status === "fresh" ? t.fresh += 1 : e.status === "stale" ? t.stale += 1 : t.unknown += 1, e.expected && !e.observed && (t.missing += 1), typeof e.row_count == "number" && (t.rowCount = (t.rowCount ?? 0) + e.row_count);
|
|
216
238
|
}), t;
|
|
217
|
-
},
|
|
218
|
-
let n =
|
|
239
|
+
}, he = (e) => [...e].sort((e, t) => {
|
|
240
|
+
let n = A(t.status) - A(e.status);
|
|
219
241
|
if (n !== 0) return n;
|
|
220
242
|
let r = Number(!e.observed) - Number(!t.observed);
|
|
221
243
|
return r === 0 ? e.partition_id.localeCompare(t.partition_id) : -r;
|
|
222
|
-
}),
|
|
223
|
-
let n =
|
|
244
|
+
}), ge = (e) => [...e].sort((e, t) => {
|
|
245
|
+
let n = A(j(t)) - A(j(e));
|
|
224
246
|
return n === 0 ? e.address.localeCompare(t.address) : n;
|
|
225
|
-
}),
|
|
226
|
-
let t = e.indexOf(
|
|
247
|
+
}), M = "::", _e = (e, t) => `${e}${M}${t || "."}`, ve = (e) => {
|
|
248
|
+
let t = e.indexOf(M);
|
|
227
249
|
return t === -1 ? null : {
|
|
228
250
|
storeId: e.slice(0, t),
|
|
229
251
|
target: e.slice(t + 2)
|
|
230
252
|
};
|
|
231
|
-
},
|
|
232
|
-
let n =
|
|
253
|
+
}, N = (e) => e || ".", ye = (e, t) => {
|
|
254
|
+
let n = N(e), r = N(t);
|
|
233
255
|
return n === r || n === "." || r.startsWith(`${n}/`);
|
|
234
|
-
},
|
|
256
|
+
}, P = class extends Error {
|
|
235
257
|
status;
|
|
236
258
|
constructor(e, t) {
|
|
237
259
|
super(e), this.name = "JobsServiceError", this.status = t;
|
|
238
260
|
}
|
|
239
|
-
},
|
|
261
|
+
}, F = (e, t = {}) => {
|
|
240
262
|
let n = new Headers(t.headers);
|
|
241
263
|
return e && n.set("X-Trilogy-Token", e), {
|
|
242
264
|
...t,
|
|
243
265
|
headers: n
|
|
244
266
|
};
|
|
245
|
-
},
|
|
267
|
+
}, I = (e) => e.split("/").filter(Boolean).map((e) => encodeURIComponent(e)).join("/"), L = async (e, t) => {
|
|
246
268
|
if (e.ok) return e;
|
|
247
269
|
let n = "";
|
|
248
270
|
try {
|
|
@@ -253,15 +275,15 @@ var b = y("models", {
|
|
|
253
275
|
} catch {
|
|
254
276
|
n = "";
|
|
255
277
|
}
|
|
256
|
-
throw new
|
|
257
|
-
},
|
|
258
|
-
let t = await fetch(`${e.baseUrl}/files`,
|
|
259
|
-
return await
|
|
260
|
-
},
|
|
261
|
-
let n =
|
|
262
|
-
return await
|
|
263
|
-
},
|
|
264
|
-
let r = await fetch(`${e.baseUrl}/files`,
|
|
278
|
+
throw new P(n || t, e.status);
|
|
279
|
+
}, R = async (e) => {
|
|
280
|
+
let t = await fetch(`${e.baseUrl}/files`, F(e.token, { method: "GET" }));
|
|
281
|
+
return await L(t, `Failed to fetch files for ${e.name}`), t.json();
|
|
282
|
+
}, be = async (e, t) => {
|
|
283
|
+
let n = I(t), r = await fetch(`${e.baseUrl}/files/${n}`, F(e.token, { method: "GET" }));
|
|
284
|
+
return await L(r, `Failed to fetch ${t}`), r.text();
|
|
285
|
+
}, z = async (e, t, n) => {
|
|
286
|
+
let r = await fetch(`${e.baseUrl}/files`, F(e.token, {
|
|
265
287
|
method: "POST",
|
|
266
288
|
headers: { "Content-Type": "application/json" },
|
|
267
289
|
body: JSON.stringify({
|
|
@@ -270,18 +292,18 @@ var b = y("models", {
|
|
|
270
292
|
})
|
|
271
293
|
}));
|
|
272
294
|
if (r.status === 409) {
|
|
273
|
-
await
|
|
295
|
+
await B(e, t, n);
|
|
274
296
|
return;
|
|
275
297
|
}
|
|
276
|
-
await
|
|
277
|
-
},
|
|
278
|
-
let r = await fetch(`${e.baseUrl}/files/${
|
|
298
|
+
await L(r, `Failed to create ${t}`);
|
|
299
|
+
}, B = async (e, t, n) => {
|
|
300
|
+
let r = await fetch(`${e.baseUrl}/files/${I(t)}`, F(e.token, {
|
|
279
301
|
method: "PUT",
|
|
280
302
|
headers: { "Content-Type": "application/json" },
|
|
281
303
|
body: JSON.stringify({ content: n })
|
|
282
304
|
}));
|
|
283
305
|
if (r.status === 404) {
|
|
284
|
-
await
|
|
306
|
+
await L(await fetch(`${e.baseUrl}/files`, F(e.token, {
|
|
285
307
|
method: "POST",
|
|
286
308
|
headers: { "Content-Type": "application/json" },
|
|
287
309
|
body: JSON.stringify({
|
|
@@ -291,42 +313,51 @@ var b = y("models", {
|
|
|
291
313
|
})), `Failed to update ${t}`);
|
|
292
314
|
return;
|
|
293
315
|
}
|
|
294
|
-
await
|
|
295
|
-
},
|
|
296
|
-
let n = await fetch(`${e.baseUrl}/files/${
|
|
297
|
-
n.status !== 404 && await
|
|
298
|
-
},
|
|
299
|
-
let r = new URLSearchParams({ target:
|
|
316
|
+
await L(r, `Failed to update ${t}`);
|
|
317
|
+
}, V = async (e, t) => {
|
|
318
|
+
let n = await fetch(`${e.baseUrl}/files/${I(t)}`, F(e.token, { method: "DELETE" }));
|
|
319
|
+
n.status !== 404 && await L(n, `Failed to delete ${t}`);
|
|
320
|
+
}, xe = async (e, t, n = !1) => {
|
|
321
|
+
let r = new URLSearchParams({ target: N(t) });
|
|
300
322
|
n && r.set("refresh", "true");
|
|
301
|
-
let i = await fetch(`${e.baseUrl}/state?${r.toString()}`,
|
|
302
|
-
await
|
|
323
|
+
let i = await fetch(`${e.baseUrl}/state?${r.toString()}`, F(e.token, { method: "GET" }));
|
|
324
|
+
await L(i, `Failed to fetch state for ${N(t)}`);
|
|
303
325
|
let a = i.headers.get("X-Trilogy-Cached");
|
|
304
326
|
return {
|
|
305
327
|
snapshot: await i.json(),
|
|
306
328
|
cached: a === null ? null : a.toLowerCase() === "true",
|
|
307
329
|
computedAt: i.headers.get("X-Trilogy-Computed-At")
|
|
308
330
|
};
|
|
309
|
-
},
|
|
310
|
-
let r = await fetch(`${e.baseUrl}/${t}`,
|
|
331
|
+
}, Se = async (e, t, n) => {
|
|
332
|
+
let r = await fetch(`${e.baseUrl}/${t}`, F(e.token, {
|
|
311
333
|
method: "POST",
|
|
312
334
|
headers: { "Content-Type": "application/json" },
|
|
313
335
|
body: JSON.stringify({ target: n })
|
|
314
336
|
}));
|
|
315
|
-
return await
|
|
316
|
-
}, Se = async (e, t) => {
|
|
317
|
-
let n = await fetch(`${e.baseUrl}/jobs/${t}`, M(e.token, { method: "GET" }));
|
|
318
|
-
return await P(n, `Failed to fetch job ${t}`), n.json();
|
|
337
|
+
return await L(r, `Failed to ${t} ${n}`), r.json();
|
|
319
338
|
}, Ce = async (e, t) => {
|
|
320
|
-
let n = await fetch(`${e.baseUrl}/jobs/${t}
|
|
321
|
-
return await
|
|
322
|
-
},
|
|
339
|
+
let n = await fetch(`${e.baseUrl}/jobs/${t}`, F(e.token, { method: "GET" }));
|
|
340
|
+
return await L(n, `Failed to fetch job ${t}`), n.json();
|
|
341
|
+
}, we = async (e, t) => {
|
|
342
|
+
let n = await fetch(`${e.baseUrl}/jobs/${t}/cancel`, F(e.token, { method: "POST" }));
|
|
343
|
+
return await L(n, `Failed to cancel job ${t}`), n.json();
|
|
344
|
+
}, H = (e) => e.trim().replace(/[\\/:*?"<>|]+/g, "-").replace(/\s+/g, " "), U = (e) => e.replace(/\/$/, ""), W = (e) => U(e).replace(/^https?:\/\//, "").replace(/\//g, "-"), G = (e) => {
|
|
323
345
|
try {
|
|
324
|
-
let t = new URL(
|
|
325
|
-
return
|
|
346
|
+
let t = new URL(U(e));
|
|
347
|
+
return H(t.hostname + (t.port ? `:${t.port}` : "") || t.host || e);
|
|
326
348
|
} catch {
|
|
327
|
-
return
|
|
349
|
+
return H(U(e));
|
|
328
350
|
}
|
|
329
|
-
},
|
|
351
|
+
}, Te = (e, t, n) => {
|
|
352
|
+
let r = U(e.trim());
|
|
353
|
+
return {
|
|
354
|
+
type: "generic",
|
|
355
|
+
id: W(r),
|
|
356
|
+
name: t || G(r),
|
|
357
|
+
baseUrl: r,
|
|
358
|
+
token: n || void 0
|
|
359
|
+
};
|
|
360
|
+
}, K = (e) => H(e.name || G(e.baseUrl)), Ee = (e) => `${K(e)}-connection`, De = (e) => K(e), Oe = (e) => e.replace(/\.[^.]+$/, ""), ke = (e) => e.flatMap((e) => e.files.map((t) => e.directory ? `${e.directory}/${t}` : t)), Ae = class extends x {
|
|
330
361
|
type;
|
|
331
362
|
communityStore;
|
|
332
363
|
constructor(e) {
|
|
@@ -343,7 +374,7 @@ var b = y("models", {
|
|
|
343
374
|
}
|
|
344
375
|
async detectEngineForFallback(e) {
|
|
345
376
|
try {
|
|
346
|
-
return (await
|
|
377
|
+
return (await k(e)).files[0]?.engine || "duck_db";
|
|
347
378
|
} catch {
|
|
348
379
|
return "duck_db";
|
|
349
380
|
}
|
|
@@ -390,10 +421,10 @@ var b = y("models", {
|
|
|
390
421
|
editors: {},
|
|
391
422
|
connections: {},
|
|
392
423
|
models: {}
|
|
393
|
-
}, [u, d] = await Promise.all([
|
|
424
|
+
}, [u, d] = await Promise.all([E(o).catch((e) => (console.warn(`Failed to fetch /index.json for store "${o.name}":`, e), null)), R(o)]), f = u?.connection ?? null, p = Ee(o), h = De(o), g = new Set(u?.startup_scripts ?? []), _ = ke(d.directories), y = _.filter((e) => n(e) !== null);
|
|
394
425
|
(await Promise.all(y.map(async (e) => ({
|
|
395
426
|
path: e,
|
|
396
|
-
content: await
|
|
427
|
+
content: await be(o, e)
|
|
397
428
|
})))).forEach(({ path: e, content: t }) => {
|
|
398
429
|
let r = n(e);
|
|
399
430
|
if (!r) return;
|
|
@@ -424,8 +455,8 @@ var b = y("models", {
|
|
|
424
455
|
let S = v(new e({
|
|
425
456
|
name: h,
|
|
426
457
|
storage: "remote",
|
|
427
|
-
description: `${
|
|
428
|
-
sources: _.filter((e) => c(e) === ".preql").map((e) => new t(this.buildEditorId(o, e),
|
|
458
|
+
description: `${K(o)} remote project`,
|
|
459
|
+
sources: _.filter((e) => c(e) === ".preql").map((e) => new t(this.buildEditorId(o, e), Oe(e), [], []))
|
|
429
460
|
}));
|
|
430
461
|
return S.changed = !1, s.models[S.name] = S, s;
|
|
431
462
|
}
|
|
@@ -439,10 +470,10 @@ var b = y("models", {
|
|
|
439
470
|
if (!e) continue;
|
|
440
471
|
let n = t.remotePath || t.name, r = t.remoteOriginalPath;
|
|
441
472
|
if (t.deleted) {
|
|
442
|
-
(t.remotePersisted || r) && await
|
|
473
|
+
(t.remotePersisted || r) && await V(e, r || n), t.changed = !1;
|
|
443
474
|
continue;
|
|
444
475
|
}
|
|
445
|
-
t.changed &&= (r && r !== n ? (await
|
|
476
|
+
t.changed &&= (r && r !== n ? (await z(e, n, t.contents), await V(e, r)) : t.remotePersisted ? await B(e, n, t.contents) : await z(e, n, t.contents), t.remotePath = n, t.remoteOriginalPath = null, t.remotePersisted = !0, !1);
|
|
446
477
|
}
|
|
447
478
|
}
|
|
448
479
|
async loadEditors() {
|
|
@@ -494,35 +525,83 @@ var b = y("models", {
|
|
|
494
525
|
}
|
|
495
526
|
async deleteChat(e) {}
|
|
496
527
|
async clearChats() {}
|
|
497
|
-
},
|
|
498
|
-
type: "
|
|
528
|
+
}, q = {
|
|
529
|
+
type: "static",
|
|
499
530
|
id: "trilogy-data-trilogy-public-models-main",
|
|
500
531
|
name: "Trilogy Public Models",
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
532
|
+
baseUrl: "https://trilogy-data.github.io/trilogy-public-models/studio",
|
|
533
|
+
origin: {
|
|
534
|
+
kind: "github",
|
|
535
|
+
owner: "trilogy-data",
|
|
536
|
+
repo: "trilogy-public-models",
|
|
537
|
+
branch: "main"
|
|
538
|
+
}
|
|
539
|
+
}, je = "trilogy-data", Me = "trilogy-public-models", Ne = (e, t, n) => e === je && t === Me ? `https://${je}.github.io/${Me}/studio` : `https://raw.githubusercontent.com/${e}/${t}/${n}/studio`, Pe = (e, t, n) => `${e}-${t}-${n}`, Fe = (e, t, n, r) => {
|
|
540
|
+
let i = {
|
|
541
|
+
kind: "github",
|
|
542
|
+
owner: e,
|
|
543
|
+
repo: t,
|
|
544
|
+
branch: n
|
|
545
|
+
};
|
|
546
|
+
return {
|
|
547
|
+
type: "static",
|
|
548
|
+
id: Pe(e, t, n),
|
|
549
|
+
name: r || `${e}/${t}`,
|
|
550
|
+
baseUrl: Ne(e, t, n),
|
|
551
|
+
origin: i
|
|
552
|
+
};
|
|
553
|
+
}, Ie = (e, t) => {
|
|
554
|
+
let n = U(e.trim());
|
|
555
|
+
return {
|
|
556
|
+
type: "static",
|
|
557
|
+
id: W(n),
|
|
558
|
+
name: t || G(n),
|
|
559
|
+
baseUrl: n
|
|
560
|
+
};
|
|
561
|
+
}, Le = (e) => {
|
|
562
|
+
if (!e || typeof e != "object") return null;
|
|
563
|
+
let t = e;
|
|
564
|
+
if (t.type === "github") {
|
|
565
|
+
let e = Fe(t.owner, t.repo, t.branch, t.name);
|
|
566
|
+
return {
|
|
567
|
+
...e,
|
|
568
|
+
id: t.id || e.id
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
return t.type === "static" || t.type === "generic" ? t : null;
|
|
572
|
+
}, Re = (e) => {
|
|
573
|
+
if (e.type === "static" && e.origin?.kind === "github") return `${e.origin.owner}/${e.origin.repo}@${e.origin.branch}`;
|
|
574
|
+
try {
|
|
575
|
+
return new URL(e.baseUrl).host;
|
|
576
|
+
} catch {
|
|
577
|
+
return e.baseUrl;
|
|
578
|
+
}
|
|
579
|
+
}, ze = "trilogy-community-stores", Be = (e) => {
|
|
505
580
|
let t = new URLSearchParams(window.location.search), n = t.get("store"), r = t.get("token");
|
|
506
581
|
if (!n || !r) return;
|
|
507
|
-
let i =
|
|
582
|
+
let i = U(n), a = e.find((e) => e.type === "generic" && U(e.baseUrl) === i);
|
|
508
583
|
a && !a.token && (a.token = r);
|
|
509
|
-
},
|
|
584
|
+
}, Ve = (e) => {
|
|
585
|
+
let t = new URLSearchParams(window.location.search), n = t.get("store");
|
|
586
|
+
if (!n || t.get("kind") !== "static") return null;
|
|
587
|
+
let r;
|
|
588
|
+
try {
|
|
589
|
+
let e = new URL(n);
|
|
590
|
+
if (e.protocol !== "https:" && e.protocol !== "http:") return null;
|
|
591
|
+
r = Ie(n);
|
|
592
|
+
} catch {
|
|
593
|
+
return null;
|
|
594
|
+
}
|
|
595
|
+
return e.some((e) => e.id === r.id || U(e.baseUrl) === r.baseUrl) ? null : r;
|
|
596
|
+
}, He = y("communityApi", {
|
|
510
597
|
state: () => ({
|
|
511
|
-
stores: [
|
|
598
|
+
stores: [q],
|
|
512
599
|
filesByStore: {},
|
|
513
600
|
errors: {},
|
|
514
|
-
storeStatus: { [
|
|
601
|
+
storeStatus: { [q.id]: "idle" },
|
|
515
602
|
loading: !1,
|
|
516
603
|
showAddStoreModal: !1,
|
|
517
|
-
addingStore: !1
|
|
518
|
-
newStore: {
|
|
519
|
-
type: "generic",
|
|
520
|
-
name: "",
|
|
521
|
-
baseUrl: "",
|
|
522
|
-
owner: "",
|
|
523
|
-
repo: "",
|
|
524
|
-
branch: "main"
|
|
525
|
-
}
|
|
604
|
+
addingStore: !1
|
|
526
605
|
}),
|
|
527
606
|
getters: {
|
|
528
607
|
allFiles: (e) => {
|
|
@@ -535,7 +614,7 @@ var b = y("models", {
|
|
|
535
614
|
let t = [];
|
|
536
615
|
return Object.values(e.filesByStore).forEach((e) => {
|
|
537
616
|
t.push(...e);
|
|
538
|
-
}),
|
|
617
|
+
}), ie(t);
|
|
539
618
|
},
|
|
540
619
|
hasErrors: (e) => Object.keys(e.errors).length > 0,
|
|
541
620
|
errorList: (e) => Object.entries(e.errors).map(([t, n]) => ({
|
|
@@ -547,10 +626,12 @@ var b = y("models", {
|
|
|
547
626
|
actions: {
|
|
548
627
|
loadStoresFromStorage() {
|
|
549
628
|
try {
|
|
550
|
-
let e = localStorage.getItem(
|
|
629
|
+
let e = localStorage.getItem(ze), t = !1;
|
|
551
630
|
if (e) {
|
|
552
|
-
let
|
|
553
|
-
|
|
631
|
+
let n = JSON.parse(e), r = Array.isArray(n) ? n : [], i = r.map((e) => Le(e)).filter((e) => e !== null);
|
|
632
|
+
t = r.length !== i.length || r.some((e) => e?.type === "github");
|
|
633
|
+
let a = new Map(this.stores.map((e) => [e.id, e])), o = [q, ...i.map((e) => {
|
|
634
|
+
let t = a.get(e.id);
|
|
554
635
|
if (!t || t.type !== e.type) return e;
|
|
555
636
|
if (e.type === "generic") {
|
|
556
637
|
let n = t.type === "generic" ? t : null;
|
|
@@ -565,19 +646,21 @@ var b = y("models", {
|
|
|
565
646
|
...t
|
|
566
647
|
};
|
|
567
648
|
})].filter((e, t, n) => t === n.findIndex((t) => t.id === e.id));
|
|
568
|
-
|
|
649
|
+
Be(o), this.stores = o, o.forEach((e) => {
|
|
569
650
|
this.storeStatus[e.id] || (this.storeStatus[e.id] = "idle");
|
|
570
651
|
});
|
|
571
652
|
}
|
|
572
|
-
e ||
|
|
653
|
+
e || Be(this.stores);
|
|
654
|
+
let n = Ve(this.stores);
|
|
655
|
+
n && (this.stores.push(n), this.storeStatus[n.id] = "idle", t = !0), t && this.saveStoresToStorage();
|
|
573
656
|
} catch (e) {
|
|
574
657
|
console.error("Error loading stores from localStorage:", e);
|
|
575
658
|
}
|
|
576
659
|
},
|
|
577
660
|
saveStoresToStorage() {
|
|
578
661
|
try {
|
|
579
|
-
let e = this.stores.filter((e) => e.id !==
|
|
580
|
-
localStorage.setItem(
|
|
662
|
+
let e = this.stores.filter((e) => e.id !== q.id);
|
|
663
|
+
localStorage.setItem(ze, JSON.stringify(e));
|
|
581
664
|
} catch (e) {
|
|
582
665
|
console.error("Error saving stores to localStorage:", e);
|
|
583
666
|
}
|
|
@@ -587,7 +670,7 @@ var b = y("models", {
|
|
|
587
670
|
for (let e of this.stores) this.storeStatus[e.id] = "idle";
|
|
588
671
|
try {
|
|
589
672
|
console.log(`Fetching community model files from ${this.stores.map((e) => e.id).join(", ")}...`);
|
|
590
|
-
let e = await
|
|
673
|
+
let e = await le(this.stores, (e, t) => {
|
|
591
674
|
this.filesByStore[e] = t.files, t.error ? (this.errors[e] = t.error, this.storeStatus[e] = "failed") : this.storeStatus[e] = "connected", console.log(`Store ${e} completed: ${t.error ? "failed" : "success"}`);
|
|
592
675
|
});
|
|
593
676
|
console.log("All stores fetched:", e);
|
|
@@ -605,7 +688,7 @@ var b = y("models", {
|
|
|
605
688
|
if (t) {
|
|
606
689
|
this.loading = !0, this.storeStatus[e] = "idle";
|
|
607
690
|
try {
|
|
608
|
-
let n = await
|
|
691
|
+
let n = await k(t);
|
|
609
692
|
this.filesByStore[e] = n.files, n.error ? (this.errors[e] = n.error, this.storeStatus[e] = "failed") : (delete this.errors[e], this.storeStatus[e] = "connected");
|
|
610
693
|
} finally {
|
|
611
694
|
this.loading = !1;
|
|
@@ -614,7 +697,7 @@ var b = y("models", {
|
|
|
614
697
|
},
|
|
615
698
|
filteredFiles(e, t, n, r, i = null) {
|
|
616
699
|
let a = (e) => e in r.models, o = this.allFiles;
|
|
617
|
-
return i && (o = this.filesByStore[i]), o ?
|
|
700
|
+
return i && (o = this.filesByStore[i]), o ? ne(o, e, t, n, a) : [];
|
|
618
701
|
},
|
|
619
702
|
getFilesByStore(e) {
|
|
620
703
|
return this.filesByStore[e] || [];
|
|
@@ -623,11 +706,8 @@ var b = y("models", {
|
|
|
623
706
|
this.loadStoresFromStorage(), await this.fetchAllFiles();
|
|
624
707
|
},
|
|
625
708
|
async addStore(e) {
|
|
626
|
-
if (e.
|
|
627
|
-
|
|
628
|
-
e.baseUrl = B(e.baseUrl), e.id = e.id || V(e.baseUrl), e.name = e.name || H(e.baseUrl);
|
|
629
|
-
} else if (e.type === "github" && (!e.owner || !e.repo || !e.branch)) throw Error("Owner, repo, and branch are required for GitHub stores");
|
|
630
|
-
if (this.stores.some((t) => t.id === e.id)) throw Error("This store is already added");
|
|
709
|
+
if (!e.baseUrl) throw Error("Base URL is required");
|
|
710
|
+
if (e.baseUrl = U(e.baseUrl), e.id = e.id || W(e.baseUrl), e.name = e.name || G(e.baseUrl), this.stores.some((t) => t.id === e.id)) throw Error("This store is already added");
|
|
631
711
|
this.addingStore = !0;
|
|
632
712
|
try {
|
|
633
713
|
return this.stores.push(e), this.saveStoresToStorage(), await this.fetchAllFiles(), !0;
|
|
@@ -648,49 +728,10 @@ var b = y("models", {
|
|
|
648
728
|
!n || n.type !== "generic" || (n.token = t || void 0, this.saveStoresToStorage());
|
|
649
729
|
},
|
|
650
730
|
openAddStoreModal() {
|
|
651
|
-
this.showAddStoreModal = !0
|
|
652
|
-
type: "generic",
|
|
653
|
-
name: "",
|
|
654
|
-
baseUrl: "",
|
|
655
|
-
owner: "",
|
|
656
|
-
repo: "",
|
|
657
|
-
branch: "main"
|
|
658
|
-
};
|
|
731
|
+
this.showAddStoreModal = !0;
|
|
659
732
|
},
|
|
660
733
|
closeAddStoreModal() {
|
|
661
|
-
this.showAddStoreModal = !1
|
|
662
|
-
type: "generic",
|
|
663
|
-
name: "",
|
|
664
|
-
baseUrl: "",
|
|
665
|
-
owner: "",
|
|
666
|
-
repo: "",
|
|
667
|
-
branch: "main"
|
|
668
|
-
};
|
|
669
|
-
},
|
|
670
|
-
async handleAddStore() {
|
|
671
|
-
let { type: e, name: t, baseUrl: n, owner: r, repo: i, branch: a } = this.newStore;
|
|
672
|
-
if (e === "generic") {
|
|
673
|
-
if (!n) throw Error("Please fill in all required fields");
|
|
674
|
-
let e = B(n), r = {
|
|
675
|
-
type: "generic",
|
|
676
|
-
id: V(e),
|
|
677
|
-
name: t || H(e),
|
|
678
|
-
baseUrl: e
|
|
679
|
-
};
|
|
680
|
-
await this.addStore(r);
|
|
681
|
-
} else {
|
|
682
|
-
if (!t || !r || !i || !a) throw Error("Please fill in all required fields");
|
|
683
|
-
let e = {
|
|
684
|
-
type: "github",
|
|
685
|
-
id: `${r}-${i}-${a}`,
|
|
686
|
-
name: t,
|
|
687
|
-
owner: r,
|
|
688
|
-
repo: i,
|
|
689
|
-
branch: a
|
|
690
|
-
};
|
|
691
|
-
await this.addStore(e);
|
|
692
|
-
}
|
|
693
|
-
this.closeAddStoreModal();
|
|
734
|
+
this.showAddStoreModal = !1;
|
|
694
735
|
},
|
|
695
736
|
clearErrors() {
|
|
696
737
|
this.errors = {};
|
|
@@ -703,18 +744,18 @@ var b = y("models", {
|
|
|
703
744
|
}
|
|
704
745
|
}
|
|
705
746
|
}), J = /* @__PURE__ */ new Map();
|
|
706
|
-
async function
|
|
747
|
+
async function Ue(e) {
|
|
707
748
|
let t = b();
|
|
708
749
|
if (t.models[e]) return !0;
|
|
709
750
|
let n = J.get(e);
|
|
710
751
|
if (n) return n;
|
|
711
|
-
let r =
|
|
752
|
+
let r = He();
|
|
712
753
|
r.stores.length <= 1 && r.loadStoresFromStorage();
|
|
713
|
-
let i = r.stores.find((t) => t.type === "generic" &&
|
|
754
|
+
let i = r.stores.find((t) => t.type === "generic" && De(t) === e);
|
|
714
755
|
if (!i) return !1;
|
|
715
756
|
let a = (async () => {
|
|
716
757
|
try {
|
|
717
|
-
let n = await new
|
|
758
|
+
let n = await new Ae(r).loadStore(i.id), a = $();
|
|
718
759
|
for (let e of Object.values(n.editors)) a.editors[e.id] || a.addEditor(e);
|
|
719
760
|
for (let e of Object.values(n.models)) t.models[e.name] || t.addModelConfig(e);
|
|
720
761
|
return !!t.models[e];
|
|
@@ -729,16 +770,22 @@ async function ke(e) {
|
|
|
729
770
|
//#endregion
|
|
730
771
|
//#region stores/connectionStore.ts
|
|
731
772
|
var Y = /* @__PURE__ */ new Map(), X = 6e4;
|
|
732
|
-
async function
|
|
773
|
+
async function We(e) {
|
|
733
774
|
let t = $().getConnectionEditors(e.id, [a.STARTUP_SCRIPT]);
|
|
734
775
|
await Promise.all(t.map(async (t) => {
|
|
735
|
-
console.log(`running startup script ${t.name}`)
|
|
776
|
+
console.log(`running startup script ${t.name}`);
|
|
777
|
+
try {
|
|
778
|
+
await e.runScript(t.contents);
|
|
779
|
+
} catch (n) {
|
|
780
|
+
let r = t.remotePath || t.name, i = n instanceof Error ? n.message : String(n);
|
|
781
|
+
throw Error(`Startup script "${r}" failed on connection "${e.name}":\n${i}`, { cause: n });
|
|
782
|
+
}
|
|
736
783
|
}));
|
|
737
784
|
}
|
|
738
785
|
function Z(e) {
|
|
739
|
-
if (e.model && !b().models[e.model]) return
|
|
786
|
+
if (e.model && !b().models[e.model]) return Ue(e.model);
|
|
740
787
|
}
|
|
741
|
-
var
|
|
788
|
+
var Ge = [
|
|
742
789
|
{
|
|
743
790
|
label: "DuckDB",
|
|
744
791
|
value: "duckdb"
|
|
@@ -789,7 +836,7 @@ var je = [
|
|
|
789
836
|
setTimeout(() => t(/* @__PURE__ */ Error(`Connection timed out after ${X / 1e3} seconds`)), X);
|
|
790
837
|
}), r = Promise.race([(async () => {
|
|
791
838
|
let t = Z(this.connections[e]);
|
|
792
|
-
t && await t, await this.connections[e].reset(), await
|
|
839
|
+
t && await t, await this.connections[e].reset(), await We(this.connections[e]);
|
|
793
840
|
})(), n]).catch((t) => {
|
|
794
841
|
throw this.connections[e]?.setError?.(t instanceof Error ? t.message : String(t)), t;
|
|
795
842
|
}).finally(() => {
|
|
@@ -803,7 +850,7 @@ var je = [
|
|
|
803
850
|
if (Y.has(t)) return Y.get(t);
|
|
804
851
|
let n = new Promise((e, t) => {
|
|
805
852
|
setTimeout(() => t(/* @__PURE__ */ Error(`Reset operation timed out after ${X / 1e3} seconds`)), X);
|
|
806
|
-
}), r = Z(this.connections[e]), i = (r ? r.then(() => this.connections[e].reset()) : this.connections[e].reset()).then(() =>
|
|
853
|
+
}), r = Z(this.connections[e]), i = (r ? r.then(() => this.connections[e].reset()) : this.connections[e].reset()).then(() => We(this.connections[e])), a = Promise.race([i, n]).catch((t) => {
|
|
807
854
|
throw this.connections[e]?.setError?.(t instanceof Error ? t.message : String(t)), t;
|
|
808
855
|
}).finally(() => {
|
|
809
856
|
Y.delete(t);
|
|
@@ -969,4 +1016,4 @@ var je = [
|
|
|
969
1016
|
}
|
|
970
1017
|
});
|
|
971
1018
|
//#endregion
|
|
972
|
-
export {
|
|
1019
|
+
export { O as A, ve as C, he as D, ge as E, x as M, b as N, ye as O, de as S, j as T, Ce as _, Fe as a, _e as b, q as c, Ee as d, W as f, R as g, we as h, He as i, re as j, me as k, Ae as l, P as m, Ge as n, Ie as o, U as p, Q as r, Re as s, $ as t, Te as u, xe as v, fe as w, pe as x, Se as y };
|