@qaecy/cue-sdk 0.0.53 → 0.0.54
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/browser.js +7840 -7577
- package/{document-filter-CBrY09DH.js → document-filter-BSiwWQ5L.js} +1184 -891
- package/index.js +1 -1
- package/lib/blob-storage.d.ts +12 -0
- package/lib/cache.d.ts +3 -3
- package/lib/cue.d.ts +5 -3
- package/lib/models.d.ts +21 -5
- package/lib/semantic-template.d.ts +7 -1
- package/node.js +2 -2
- package/package.json +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { getApps as
|
|
2
|
-
import {
|
|
3
|
-
import { Writer as
|
|
4
|
-
import { getAuth as
|
|
5
|
-
import { Client as
|
|
6
|
-
import { StreamableHTTPClientTransport as
|
|
7
|
-
import { v5 as
|
|
1
|
+
import { getApps as Ye, initializeApp as Je } from "firebase/app";
|
|
2
|
+
import { getDownloadURL as At, ref as x, getMetadata as $t, getBlob as Qe, updateMetadata as Ke, uploadBytesResumable as Ze, uploadString as to, listAll as ot, deleteObject as eo, getStorage as oo, connectStorageEmulator as so } from "firebase/storage";
|
|
3
|
+
import { Writer as ro } from "n3";
|
|
4
|
+
import { getAuth as ao, connectAuthEmulator as io, onIdTokenChanged as no, getIdTokenResult as Q, signInWithEmailAndPassword as co, GoogleAuthProvider as wt, OAuthProvider as ft, signInWithPopup as po, signInWithRedirect as lo, getRedirectResult as ho, signOut as st, signInWithCustomToken as Pt, onAuthStateChanged as uo, fetchSignInMethodsForEmail as go, linkWithPopup as mo, unlink as wo, reauthenticateWithCredential as Dt, EmailAuthProvider as rt, updatePassword as fo, linkWithCredential as yo, verifyBeforeUpdateEmail as bo, sendEmailVerification as vo } from "firebase/auth";
|
|
5
|
+
import { Client as _o } from "@modelcontextprotocol/sdk/client/index.js";
|
|
6
|
+
import { StreamableHTTPClientTransport as Eo } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
7
|
+
import { v5 as To } from "uuid";
|
|
8
8
|
import "spark-md5";
|
|
9
|
-
const
|
|
10
|
-
class
|
|
9
|
+
const So = [423, 429, 503];
|
|
10
|
+
class Ae extends Error {
|
|
11
11
|
constructor(t, e, o) {
|
|
12
12
|
super(`QLever throttled the request (HTTP ${e}): ${t}`), this.status = e, this.retryAfterSeconds = o, this.name = "QLeverThrottledError";
|
|
13
13
|
}
|
|
14
14
|
status;
|
|
15
15
|
retryAfterSeconds;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function Io(r) {
|
|
18
18
|
const t = r.headers.get("retry-after");
|
|
19
19
|
if (!t) return;
|
|
20
20
|
const e = Number(t);
|
|
@@ -22,13 +22,13 @@ function xo(r) {
|
|
|
22
22
|
const o = Date.parse(t);
|
|
23
23
|
if (!Number.isNaN(o)) return Math.max(0, (o - Date.now()) / 1e3);
|
|
24
24
|
}
|
|
25
|
-
async function
|
|
25
|
+
async function z(r) {
|
|
26
26
|
const t = await r.text();
|
|
27
|
-
if (
|
|
28
|
-
throw new
|
|
27
|
+
if (So.includes(r.status))
|
|
28
|
+
throw new Ae(t, r.status, Io(r));
|
|
29
29
|
return t;
|
|
30
30
|
}
|
|
31
|
-
class
|
|
31
|
+
class k {
|
|
32
32
|
queryEndpoint;
|
|
33
33
|
updateEndpoint;
|
|
34
34
|
dataEndpoint;
|
|
@@ -71,16 +71,16 @@ class O {
|
|
|
71
71
|
* the exact second the server nominated.
|
|
72
72
|
*/
|
|
73
73
|
static async _retryOnLocked(t) {
|
|
74
|
-
const e =
|
|
74
|
+
const e = k.LOCKED_MAX_RETRIES, o = k.LOCKED_BASE_DELAY_MS;
|
|
75
75
|
let s;
|
|
76
76
|
for (let a = 0; a <= e; a++)
|
|
77
77
|
try {
|
|
78
78
|
return await t();
|
|
79
79
|
} catch (i) {
|
|
80
|
-
if (s = i, i instanceof
|
|
80
|
+
if (s = i, i instanceof Ae && a < e) {
|
|
81
81
|
const n = i.retryAfterSeconds !== void 0 ? i.retryAfterSeconds * 1e3 : void 0, c = Math.min(
|
|
82
82
|
n ?? o * Math.pow(2, a),
|
|
83
|
-
|
|
83
|
+
k.LOCKED_MAX_DELAY_MS
|
|
84
84
|
);
|
|
85
85
|
await new Promise((p) => setTimeout(p, Math.random() * c));
|
|
86
86
|
continue;
|
|
@@ -92,7 +92,7 @@ class O {
|
|
|
92
92
|
constructor(t) {
|
|
93
93
|
this.queryEndpoint = t.queryEndpoint, this.updateEndpoint = t.updateEndpoint, this.dataEndpoint = this.updateEndpoint.replace(/\/update$/, "/data"), this.baseHeaders = Object.fromEntries(
|
|
94
94
|
Object.entries(t.originalHeaders || {}).filter(
|
|
95
|
-
([e]) =>
|
|
95
|
+
([e]) => k.RELEVANT_HEADER_KEYS.includes(e)
|
|
96
96
|
)
|
|
97
97
|
), this.baseHeaders["x-user-roles"] = "admin";
|
|
98
98
|
}
|
|
@@ -100,7 +100,7 @@ class O {
|
|
|
100
100
|
return (await this.query("ASK { }")).boolean;
|
|
101
101
|
}
|
|
102
102
|
async query(t, e = "application/sparql-results+json") {
|
|
103
|
-
return
|
|
103
|
+
return k._retryOnLocked(async () => {
|
|
104
104
|
let o;
|
|
105
105
|
try {
|
|
106
106
|
o = await fetch(this.queryEndpoint, {
|
|
@@ -118,14 +118,14 @@ class O {
|
|
|
118
118
|
);
|
|
119
119
|
}
|
|
120
120
|
if (!o.ok) {
|
|
121
|
-
const s = await
|
|
121
|
+
const s = await z(o);
|
|
122
122
|
throw new Error(`QLever query failed (HTTP ${o.status}): ${s}`);
|
|
123
123
|
}
|
|
124
124
|
return await o.json();
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
async subset(t, e = "text/turtle") {
|
|
128
|
-
return
|
|
128
|
+
return k._retryOnLocked(async () => {
|
|
129
129
|
const o = await fetch(this.queryEndpoint, {
|
|
130
130
|
headers: {
|
|
131
131
|
...this.baseHeaders,
|
|
@@ -136,14 +136,14 @@ class O {
|
|
|
136
136
|
body: new URLSearchParams({ query: t })
|
|
137
137
|
});
|
|
138
138
|
if (!o.ok) {
|
|
139
|
-
const s = await
|
|
139
|
+
const s = await z(o);
|
|
140
140
|
throw new Error(`QLever subset failed (HTTP ${o.status}): ${s}`);
|
|
141
141
|
}
|
|
142
142
|
return await o.text();
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
145
|
async update(t) {
|
|
146
|
-
return
|
|
146
|
+
return k._retryOnLocked(async () => {
|
|
147
147
|
const e = await fetch(this.updateEndpoint, {
|
|
148
148
|
headers: {
|
|
149
149
|
...this.baseHeaders,
|
|
@@ -153,7 +153,7 @@ class O {
|
|
|
153
153
|
body: new URLSearchParams({ update: t })
|
|
154
154
|
});
|
|
155
155
|
if (!e.ok) {
|
|
156
|
-
const o = await
|
|
156
|
+
const o = await z(e);
|
|
157
157
|
throw new Error(`SPARQL update failed (HTTP ${e.status}): ${o}`);
|
|
158
158
|
}
|
|
159
159
|
return await e.json();
|
|
@@ -197,15 +197,15 @@ class O {
|
|
|
197
197
|
* to prevent.
|
|
198
198
|
*/
|
|
199
199
|
async _postToDataEndpoint(t, e) {
|
|
200
|
-
await
|
|
200
|
+
await k._retryOnLocked(async () => {
|
|
201
201
|
const o = {
|
|
202
202
|
...this.baseHeaders,
|
|
203
203
|
"Content-Type": "application/n-quads",
|
|
204
204
|
"Content-Encoding": "gzip"
|
|
205
|
-
}, s =
|
|
205
|
+
}, s = ko() ? {
|
|
206
206
|
method: "POST",
|
|
207
207
|
headers: o,
|
|
208
|
-
body:
|
|
208
|
+
body: xo(t).pipeThrough(new CompressionStream("gzip")),
|
|
209
209
|
// Required for a streaming body; also switches the request to
|
|
210
210
|
// chunked transfer encoding, which the service handles because it
|
|
211
211
|
// never buffers the body itself.
|
|
@@ -213,23 +213,23 @@ class O {
|
|
|
213
213
|
} : {
|
|
214
214
|
method: "POST",
|
|
215
215
|
headers: o,
|
|
216
|
-
body: await
|
|
216
|
+
body: await Oo(Buffer.from(await $e(t), "utf-8"))
|
|
217
217
|
}, a = await fetch(e, s);
|
|
218
218
|
if (!a.ok) {
|
|
219
|
-
const i = await
|
|
219
|
+
const i = await z(a);
|
|
220
220
|
throw new Error(`QLever data POST failed (HTTP ${a.status}): ${i}`);
|
|
221
221
|
}
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function $e(r) {
|
|
226
226
|
return new Promise((t, e) => {
|
|
227
|
-
const o = new
|
|
227
|
+
const o = new ro({ format: "application/n-quads" });
|
|
228
228
|
o.addQuads(r), o.end((s, a) => s ? e(s) : t(a));
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
|
-
const
|
|
232
|
-
function
|
|
231
|
+
const Co = 5e3;
|
|
232
|
+
function xo(r) {
|
|
233
233
|
const t = new TextEncoder();
|
|
234
234
|
let e = 0;
|
|
235
235
|
return new ReadableStream({
|
|
@@ -238,16 +238,16 @@ function Ro(r) {
|
|
|
238
238
|
o.close();
|
|
239
239
|
return;
|
|
240
240
|
}
|
|
241
|
-
const s = r.slice(e, e +
|
|
242
|
-
e += s.length, o.enqueue(t.encode(await
|
|
241
|
+
const s = r.slice(e, e + Co);
|
|
242
|
+
e += s.length, o.enqueue(t.encode(await $e(s)));
|
|
243
243
|
}
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
|
-
let
|
|
247
|
-
function
|
|
248
|
-
if (
|
|
246
|
+
let A;
|
|
247
|
+
function ko() {
|
|
248
|
+
if (A !== void 0) return A;
|
|
249
249
|
if (typeof process < "u" && process.env?.QLEVER_DISABLE_REQUEST_STREAMING === "true" || typeof CompressionStream > "u" || typeof ReadableStream > "u")
|
|
250
|
-
return
|
|
250
|
+
return A = !1;
|
|
251
251
|
try {
|
|
252
252
|
let r = !1;
|
|
253
253
|
const t = new Request("https://a.invalid/", {
|
|
@@ -257,13 +257,13 @@ function Oo() {
|
|
|
257
257
|
return r = !0, "half";
|
|
258
258
|
}
|
|
259
259
|
}).headers.has("Content-Type");
|
|
260
|
-
|
|
260
|
+
A = r && !t;
|
|
261
261
|
} catch {
|
|
262
|
-
|
|
262
|
+
A = !1;
|
|
263
263
|
}
|
|
264
|
-
return
|
|
264
|
+
return A;
|
|
265
265
|
}
|
|
266
|
-
async function
|
|
266
|
+
async function Oo(r) {
|
|
267
267
|
const t = new CompressionStream("gzip"), e = t.writable.getWriter();
|
|
268
268
|
e.write(new Uint8Array(r)), e.close();
|
|
269
269
|
const o = [], s = t.readable.getReader();
|
|
@@ -278,11 +278,11 @@ async function Ao(r) {
|
|
|
278
278
|
i.set(c, n), n += c.byteLength;
|
|
279
279
|
return i.buffer;
|
|
280
280
|
}
|
|
281
|
-
class
|
|
281
|
+
class Ro {
|
|
282
282
|
constructor(t) {
|
|
283
283
|
if (this.options = t, this.options.graphType !== "qlever")
|
|
284
284
|
throw new Error(`Unsupported graph type: ${this.options.graphType}`);
|
|
285
|
-
this._db = new
|
|
285
|
+
this._db = new k(this.options);
|
|
286
286
|
}
|
|
287
287
|
options;
|
|
288
288
|
_db;
|
|
@@ -315,13 +315,370 @@ class $o {
|
|
|
315
315
|
return this._db.deleteData(t);
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
-
|
|
318
|
+
function B(r) {
|
|
319
|
+
const t = r;
|
|
320
|
+
return t?.code === "storage/object-not-found" || t?.status === 404;
|
|
321
|
+
}
|
|
322
|
+
class Ao {
|
|
323
|
+
constructor(t) {
|
|
324
|
+
this.storage = t;
|
|
325
|
+
}
|
|
326
|
+
storage;
|
|
327
|
+
async getDownloadURL(t) {
|
|
328
|
+
try {
|
|
329
|
+
return await At(x(this.storage, t));
|
|
330
|
+
} catch (e) {
|
|
331
|
+
if (B(e)) return;
|
|
332
|
+
throw e;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
async getCacheBustedUrl(t) {
|
|
336
|
+
const e = x(this.storage, t);
|
|
337
|
+
try {
|
|
338
|
+
const o = await $t(e);
|
|
339
|
+
return `${await At(e)}&t=${encodeURIComponent(o.updated)}`;
|
|
340
|
+
} catch (o) {
|
|
341
|
+
if (B(o)) return;
|
|
342
|
+
throw o;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
async getFile(t) {
|
|
346
|
+
try {
|
|
347
|
+
return await Qe(x(this.storage, t));
|
|
348
|
+
} catch (e) {
|
|
349
|
+
if (B(e)) return;
|
|
350
|
+
throw e;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
async getMetadata(t) {
|
|
354
|
+
try {
|
|
355
|
+
const e = await $t(x(this.storage, t));
|
|
356
|
+
return { updated: e.updated, contentType: e.contentType, size: e.size, customMetadata: e.customMetadata };
|
|
357
|
+
} catch (e) {
|
|
358
|
+
if (B(e)) return;
|
|
359
|
+
throw e;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
async setMetadata(t, e) {
|
|
363
|
+
await Ke(x(this.storage, t), { customMetadata: e });
|
|
364
|
+
}
|
|
365
|
+
upload(t, e, o = {}) {
|
|
366
|
+
const s = {};
|
|
367
|
+
o.contentType && (s.contentType = o.contentType), o.contentEncoding && (s.contentEncoding = o.contentEncoding), o.customMetadata && (s.customMetadata = o.customMetadata);
|
|
368
|
+
const a = Ze(x(this.storage, t), e, Object.keys(s).length ? s : void 0);
|
|
369
|
+
return {
|
|
370
|
+
complete: () => new Promise((i, n) => {
|
|
371
|
+
a.on("state_changed", void 0, n, () => i());
|
|
372
|
+
}),
|
|
373
|
+
pause: () => a.pause(),
|
|
374
|
+
resume: () => a.resume(),
|
|
375
|
+
cancel: () => a.cancel(),
|
|
376
|
+
onProgress: (i) => a.on("state_changed", (n) => i(n.bytesTransferred, n.totalBytes))
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
async uploadString(t, e, o, s) {
|
|
380
|
+
await to(x(this.storage, t), e, o, s ? { customMetadata: s } : void 0);
|
|
381
|
+
}
|
|
382
|
+
async listFiles(t) {
|
|
383
|
+
return (await ot(x(this.storage, t))).items.map((o) => o.name);
|
|
384
|
+
}
|
|
385
|
+
async listFilesRecursive(t) {
|
|
386
|
+
const e = async (o) => {
|
|
387
|
+
const s = await ot(x(this.storage, o));
|
|
388
|
+
let a = s.items.map((i) => i.fullPath);
|
|
389
|
+
for (const i of s.prefixes) a = a.concat(await e(i.fullPath));
|
|
390
|
+
return a;
|
|
391
|
+
};
|
|
392
|
+
return e(t);
|
|
393
|
+
}
|
|
394
|
+
async deleteDirectory(t) {
|
|
395
|
+
let e = 0;
|
|
396
|
+
const o = async (s) => {
|
|
397
|
+
const a = await ot(x(this.storage, s));
|
|
398
|
+
for (const i of a.items)
|
|
399
|
+
await eo(i), e++;
|
|
400
|
+
for (const i of a.prefixes) await o(i.fullPath);
|
|
401
|
+
};
|
|
402
|
+
return await o(t), e;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
const $o = 3, Po = 3, Do = 50;
|
|
406
|
+
class No {
|
|
407
|
+
constructor(t) {
|
|
408
|
+
this.init = t, this.done = this.run().then(
|
|
409
|
+
() => {
|
|
410
|
+
this.state = "done";
|
|
411
|
+
},
|
|
412
|
+
(e) => {
|
|
413
|
+
throw this.state !== "canceled" && (this.state = "failed"), e;
|
|
414
|
+
}
|
|
415
|
+
), this.done.catch(() => {
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
init;
|
|
419
|
+
state = "running";
|
|
420
|
+
done;
|
|
421
|
+
listeners = /* @__PURE__ */ new Set();
|
|
422
|
+
finished = /* @__PURE__ */ new Map();
|
|
423
|
+
inFlight = /* @__PURE__ */ new Set();
|
|
424
|
+
urls = /* @__PURE__ */ new Map();
|
|
425
|
+
created;
|
|
426
|
+
resumed = !1;
|
|
427
|
+
wake;
|
|
428
|
+
complete() {
|
|
429
|
+
return this.done;
|
|
430
|
+
}
|
|
431
|
+
pause() {
|
|
432
|
+
return this.state !== "running" ? !1 : (this.state = "paused", this.abortInFlight(), !0);
|
|
433
|
+
}
|
|
434
|
+
resume() {
|
|
435
|
+
return this.state !== "paused" ? !1 : (this.state = "running", this.resumed = !0, this.wake?.(), !0);
|
|
436
|
+
}
|
|
437
|
+
cancel() {
|
|
438
|
+
return this.state === "done" || this.state === "canceled" || this.state === "failed" ? !1 : (this.state = "canceled", this.abortInFlight(), this.wake?.(), !0);
|
|
439
|
+
}
|
|
440
|
+
onProgress(t) {
|
|
441
|
+
return this.listeners.add(t), () => this.listeners.delete(t);
|
|
442
|
+
}
|
|
443
|
+
// ─── The upload ───────────────────────────────────────────────────────────
|
|
444
|
+
async run() {
|
|
445
|
+
const { bucket: t, path: e, body: o, options: s } = this.init, a = await G(
|
|
446
|
+
await this.init.call("POST", "uploads", void 0, {
|
|
447
|
+
bucket: t,
|
|
448
|
+
path: e,
|
|
449
|
+
size: o.size,
|
|
450
|
+
...s.contentType ? { contentType: s.contentType } : {},
|
|
451
|
+
...s.contentEncoding ? { contentEncoding: s.contentEncoding } : {},
|
|
452
|
+
...s.customMetadata ? { metadata: s.customMetadata } : {}
|
|
453
|
+
})
|
|
454
|
+
);
|
|
455
|
+
if (this.created = a, a.mode === "done") {
|
|
456
|
+
this.emit();
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
try {
|
|
460
|
+
for (this.emit(); ; ) {
|
|
461
|
+
await this.untilRunning(), this.resumed && await this.syncFinished();
|
|
462
|
+
const i = this.partNumbers().filter((n) => !this.finished.has(n));
|
|
463
|
+
if (i.length === 0) break;
|
|
464
|
+
await this.sendParts(i);
|
|
465
|
+
}
|
|
466
|
+
await this.untilRunning(), await G(await this.init.call("POST", "uploads/complete", void 0, this.ref()));
|
|
467
|
+
} catch (i) {
|
|
468
|
+
throw await this.init.call("DELETE", "uploads", this.ref()).catch(() => {
|
|
469
|
+
}), i;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
async sendParts(t) {
|
|
473
|
+
const e = [...t], o = async () => {
|
|
474
|
+
for (; this.state === "running" && e.length; )
|
|
475
|
+
await this.sendPart(e.shift());
|
|
476
|
+
};
|
|
477
|
+
await Promise.all(Array.from({ length: Math.min($o, e.length) }, o));
|
|
478
|
+
}
|
|
479
|
+
async sendPart(t) {
|
|
480
|
+
const { partSize: e } = this.created, o = this.init.body.slice((t - 1) * e, t * e);
|
|
481
|
+
for (let s = 1; ; s++) {
|
|
482
|
+
if (this.state !== "running") return;
|
|
483
|
+
const a = new AbortController();
|
|
484
|
+
this.inFlight.add(a);
|
|
485
|
+
try {
|
|
486
|
+
const i = this.created?.mode === "presign" ? await this.init.plainFetch(await this.partUrl(t), { method: "PUT", body: o, signal: a.signal }) : await this.init.call("PUT", `uploads/parts/${t}`, this.ref(), void 0, o, a.signal);
|
|
487
|
+
if (!i.ok) throw new Error(`Part ${t} failed: HTTP ${i.status}`);
|
|
488
|
+
this.finished.set(t, o.size), this.emit();
|
|
489
|
+
return;
|
|
490
|
+
} catch (i) {
|
|
491
|
+
if (a.signal.aborted) return;
|
|
492
|
+
if (s >= Po) throw i;
|
|
493
|
+
this.urls.delete(t), await new Promise((n) => setTimeout(n, 500 * 2 ** s));
|
|
494
|
+
} finally {
|
|
495
|
+
this.inFlight.delete(a);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
/** A signed URL for part `n`, asking for the next batch when it is not at hand. */
|
|
500
|
+
async partUrl(t) {
|
|
501
|
+
const e = this.urls.get(t);
|
|
502
|
+
if (e) return e;
|
|
503
|
+
const o = this.partNumbers().filter((n) => n >= t && !this.finished.has(n)).slice(0, Do), s = await this.init.call("POST", "uploads/parts", void 0, { ...this.ref(), partNumbers: o }), { urls: a } = await G(s);
|
|
504
|
+
for (const [n, c] of Object.entries(a)) this.urls.set(Number(n), c);
|
|
505
|
+
const i = this.urls.get(t);
|
|
506
|
+
if (!i) throw new Error(`No URL for part ${t}`);
|
|
507
|
+
return i;
|
|
508
|
+
}
|
|
509
|
+
/** After a pause, trust the service's record of what arrived, and refresh URLs that may have expired. */
|
|
510
|
+
async syncFinished() {
|
|
511
|
+
this.resumed = !1, this.urls.clear();
|
|
512
|
+
const { parts: t } = await G(await this.init.call("GET", "uploads/parts", this.ref()));
|
|
513
|
+
this.finished.clear();
|
|
514
|
+
for (const e of t) this.finished.set(e.partNumber, e.size);
|
|
515
|
+
this.emit();
|
|
516
|
+
}
|
|
517
|
+
async untilRunning() {
|
|
518
|
+
for (; this.state === "paused"; )
|
|
519
|
+
await new Promise((t) => this.wake = t);
|
|
520
|
+
if (this.state === "canceled") throw new DOMException("Upload cancelled", "AbortError");
|
|
521
|
+
}
|
|
522
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────
|
|
523
|
+
ref() {
|
|
524
|
+
return { bucket: this.init.bucket, path: this.init.path, uploadId: this.created?.uploadId ?? "" };
|
|
525
|
+
}
|
|
526
|
+
partNumbers() {
|
|
527
|
+
return Array.from({ length: this.created?.partCount ?? 0 }, (t, e) => e + 1);
|
|
528
|
+
}
|
|
529
|
+
abortInFlight() {
|
|
530
|
+
for (const t of this.inFlight) t.abort();
|
|
531
|
+
}
|
|
532
|
+
emit() {
|
|
533
|
+
const t = this.init.body.size, e = this.created?.mode === "done" ? t : [...this.finished.values()].reduce((o, s) => o + s, 0);
|
|
534
|
+
for (const o of this.listeners) o(e, t);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
async function G(r) {
|
|
538
|
+
if (!r.ok) {
|
|
539
|
+
const t = new Error(`Storage request failed: HTTP ${r.status}`);
|
|
540
|
+
throw t.status = r.status, t;
|
|
541
|
+
}
|
|
542
|
+
return r.status === 204 ? void 0 : r.json();
|
|
543
|
+
}
|
|
544
|
+
const jo = "/commands/storage";
|
|
545
|
+
class Lo {
|
|
546
|
+
constructor(t, e) {
|
|
547
|
+
this.bucket = t, this.options = e, this.base = `${e.gatewayUrl.replace(/\/$/, "")}${jo}`, this.plainFetch = e.plainFetch ?? ((o, s) => fetch(o, s));
|
|
548
|
+
}
|
|
549
|
+
bucket;
|
|
550
|
+
options;
|
|
551
|
+
base;
|
|
552
|
+
plainFetch;
|
|
553
|
+
async getDownloadURL(t) {
|
|
554
|
+
return (await this.signedUrl(t))?.url;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Every signed URL is minted fresh and differs from the last, so it already
|
|
558
|
+
* misses every cache. Nothing may be appended to it: a signature covers the
|
|
559
|
+
* query string, and an extra `t=` parameter would invalidate it.
|
|
560
|
+
*/
|
|
561
|
+
async getCacheBustedUrl(t) {
|
|
562
|
+
return this.getDownloadURL(t);
|
|
563
|
+
}
|
|
564
|
+
async getFile(t) {
|
|
565
|
+
const e = await this.signedUrl(t);
|
|
566
|
+
if (!e) return;
|
|
567
|
+
const o = await this.plainFetch(e.url);
|
|
568
|
+
if (o.status !== 404) {
|
|
569
|
+
if (!o.ok) throw new Error(`Download of ${this.bucket}/${t} failed: HTTP ${o.status}`);
|
|
570
|
+
return o.blob();
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
async getMetadata(t) {
|
|
574
|
+
const e = await this.call("GET", "objects/metadata", t, { bucket: this.bucket, path: t });
|
|
575
|
+
if (e.status !== 404)
|
|
576
|
+
return (await j(e)).json();
|
|
577
|
+
}
|
|
578
|
+
async setMetadata(t, e) {
|
|
579
|
+
await j(
|
|
580
|
+
await this.call("PATCH", "objects/metadata", t, void 0, {
|
|
581
|
+
bucket: this.bucket,
|
|
582
|
+
path: t,
|
|
583
|
+
metadata: e
|
|
584
|
+
})
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
upload(t, e, o = {}) {
|
|
588
|
+
const s = e instanceof Blob ? e : new Blob([e]);
|
|
589
|
+
return new No({
|
|
590
|
+
bucket: this.bucket,
|
|
591
|
+
path: t,
|
|
592
|
+
body: s,
|
|
593
|
+
options: o,
|
|
594
|
+
call: (a, i, n, c, p, h) => this.call(a, i, t, n, c, p, h),
|
|
595
|
+
plainFetch: this.plainFetch
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
async uploadString(t, e, o, s) {
|
|
599
|
+
const { bytes: a, contentType: i } = Mo(e, o);
|
|
600
|
+
await this.upload(t, a, { customMetadata: s, contentType: i }).complete();
|
|
601
|
+
}
|
|
602
|
+
async listFiles(t) {
|
|
603
|
+
const e = t.endsWith("/") ? t : `${t}/`;
|
|
604
|
+
return (await this.listFilesRecursive(t)).filter((o) => !o.slice(e.length).includes("/")).map((o) => o.slice(e.length));
|
|
605
|
+
}
|
|
606
|
+
async listFilesRecursive(t) {
|
|
607
|
+
const e = await this.call("GET", "objects", t, { bucket: this.bucket, prefix: t });
|
|
608
|
+
return (await (await j(e)).json()).names;
|
|
609
|
+
}
|
|
610
|
+
async deleteDirectory(t) {
|
|
611
|
+
const e = await this.call("DELETE", "objects", t, { bucket: this.bucket, prefix: t });
|
|
612
|
+
return (await (await j(e)).json()).deleted;
|
|
613
|
+
}
|
|
614
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────
|
|
615
|
+
async signedUrl(t) {
|
|
616
|
+
const e = this.bucket === "public" ? await this.plainFetch(`${this.base}/public/url?${new URLSearchParams({ path: t })}`) : await this.call("GET", "objects/url", t, { bucket: this.bucket, path: t });
|
|
617
|
+
if (e.status !== 404)
|
|
618
|
+
return (await j(e)).json();
|
|
619
|
+
}
|
|
620
|
+
/** One request to the storage module, scoped to the project `path` names. */
|
|
621
|
+
call(t, e, o, s, a, i, n) {
|
|
622
|
+
const c = `${this.base}/${e}${s ? `?${new URLSearchParams(s)}` : ""}`, p = { "cue-project-id": Uo(this.bucket, o) };
|
|
623
|
+
let h;
|
|
624
|
+
return a !== void 0 ? (p["Content-Type"] = "application/json", h = JSON.stringify(a)) : i !== void 0 && (p["Content-Type"] = "application/octet-stream", h = i), this.options.fetch(c, { method: t, headers: p, body: h, ...n ? { signal: n } : {} });
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
function Uo(r, t) {
|
|
628
|
+
const e = t.split("/");
|
|
629
|
+
return r === "persistence" && e[0] === "portal" && e[1] === "projects" ? e[2] ?? "" : e[0];
|
|
630
|
+
}
|
|
631
|
+
async function j(r) {
|
|
632
|
+
if (r.ok) return r;
|
|
633
|
+
let t = "";
|
|
634
|
+
try {
|
|
635
|
+
t = (await r.json()).message ?? "";
|
|
636
|
+
} catch {
|
|
637
|
+
}
|
|
638
|
+
const e = new Error(`Storage request failed: HTTP ${r.status}${t ? ` — ${t}` : ""}`);
|
|
639
|
+
throw e.status = r.status, e;
|
|
640
|
+
}
|
|
641
|
+
function Mo(r, t) {
|
|
642
|
+
switch (t) {
|
|
643
|
+
case "raw":
|
|
644
|
+
return { bytes: new TextEncoder().encode(r) };
|
|
645
|
+
case "base64":
|
|
646
|
+
return { bytes: at(r) };
|
|
647
|
+
case "base64url":
|
|
648
|
+
return { bytes: at(r.replace(/-/g, "+").replace(/_/g, "/")) };
|
|
649
|
+
case "data_url": {
|
|
650
|
+
const e = r.match(/^data:([^;,]*)(;base64)?,(.*)$/s);
|
|
651
|
+
if (!e) throw new Error("Invalid data URL");
|
|
652
|
+
const [, o, s, a] = e;
|
|
653
|
+
return {
|
|
654
|
+
bytes: s ? at(a) : new TextEncoder().encode(decodeURIComponent(a)),
|
|
655
|
+
...o ? { contentType: o } : {}
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
function at(r) {
|
|
661
|
+
const t = r + "=".repeat((4 - r.length % 4) % 4), e = atob(t), o = new Uint8Array(e.length);
|
|
662
|
+
for (let s = 0; s < e.length; s++) o[s] = e.charCodeAt(s);
|
|
663
|
+
return o;
|
|
664
|
+
}
|
|
665
|
+
const Fo = {
|
|
666
|
+
raw: "storageRaw",
|
|
667
|
+
processed: "storageProcessed",
|
|
668
|
+
logs: "storageLogs",
|
|
669
|
+
chatSessions: "storageChatSessions",
|
|
670
|
+
public: "storagePublic",
|
|
671
|
+
persistence: "storagePersistence",
|
|
672
|
+
sessions: "storageSessions"
|
|
673
|
+
};
|
|
674
|
+
class K {
|
|
319
675
|
constructor(t) {
|
|
320
676
|
this.options = t;
|
|
321
677
|
}
|
|
322
678
|
options;
|
|
323
679
|
/** Paths known to be absent, keyed as `bucket:path`. Avoids repeat 404 requests. */
|
|
324
680
|
_knownMissing = /* @__PURE__ */ new Set();
|
|
681
|
+
_drivers = /* @__PURE__ */ new Map();
|
|
325
682
|
/**
|
|
326
683
|
* Suffixes worth gzip-compressing on upload, picked from real
|
|
327
684
|
* compression-ratio numbers (see `libs/js/cue-sdk/plan.md` design
|
|
@@ -350,118 +707,79 @@ class F {
|
|
|
350
707
|
c.set(h, p), p += h.length;
|
|
351
708
|
return c;
|
|
352
709
|
}
|
|
353
|
-
// ───
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
case "sessions":
|
|
369
|
-
return this.options.storageSessions;
|
|
710
|
+
// ─── Driver resolution ────────────────────────────────────────────────────
|
|
711
|
+
/** Which driver serves `bucket`. */
|
|
712
|
+
driverKind(t) {
|
|
713
|
+
return this.options.drivers?.[t] ?? "firebase";
|
|
714
|
+
}
|
|
715
|
+
_driver(t) {
|
|
716
|
+
let e = this._drivers.get(t);
|
|
717
|
+
if (e) return e;
|
|
718
|
+
if (this.driverKind(t) === "gateway") {
|
|
719
|
+
if (!this.options.gateway) throw new Error(`Bucket ${t} is on the gateway driver, but no gateway is configured`);
|
|
720
|
+
e = new Lo(t, this.options.gateway);
|
|
721
|
+
} else {
|
|
722
|
+
const o = this.options[Fo[t]];
|
|
723
|
+
if (!o) throw new Error(`Bucket ${t} is on the firebase driver, but has no FirebaseStorage`);
|
|
724
|
+
e = new Ao(o);
|
|
370
725
|
}
|
|
726
|
+
return this._drivers.set(t, e), e;
|
|
371
727
|
}
|
|
372
728
|
// ─── Downloads ────────────────────────────────────────────────────────────
|
|
373
|
-
/** Get
|
|
729
|
+
/** Get a download URL that needs no further credentials. Returns undefined if the file does not exist. */
|
|
374
730
|
async getDownloadURL(t, e) {
|
|
375
|
-
|
|
376
|
-
try {
|
|
377
|
-
return await st(o);
|
|
378
|
-
} catch (s) {
|
|
379
|
-
if (s?.code === "storage/object-not-found") return;
|
|
380
|
-
throw s;
|
|
381
|
-
}
|
|
731
|
+
return this._driver(t).getDownloadURL(e);
|
|
382
732
|
}
|
|
383
|
-
/**
|
|
384
|
-
* Download URL with a `?t=<updated>` suffix, bypassing caches.
|
|
385
|
-
* Returns undefined if the file does not exist.
|
|
386
|
-
*/
|
|
733
|
+
/** Download URL that bypasses caches. Returns undefined if the file does not exist. */
|
|
387
734
|
async getCacheBustedUrl(t, e) {
|
|
388
735
|
const o = `${t}:${e}`;
|
|
389
736
|
if (this._knownMissing.has(o)) return;
|
|
390
|
-
const s =
|
|
391
|
-
|
|
392
|
-
const a = await G(s);
|
|
393
|
-
return `${await st(s)}&t=${encodeURIComponent(a.updated)}`;
|
|
394
|
-
} catch (a) {
|
|
395
|
-
if (a?.code === "storage/object-not-found" || a?.status === 404) {
|
|
396
|
-
this._knownMissing.add(o), console.debug(`[CueBlobStorage] ${e} not found (404 OK — optional cache file)`);
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
|
-
throw a;
|
|
400
|
-
}
|
|
737
|
+
const s = await this._driver(t).getCacheBustedUrl(e);
|
|
738
|
+
return s === void 0 && (this._knownMissing.add(o), console.debug(`[CueBlobStorage] ${e} not found (404 OK — optional cache file)`)), s;
|
|
401
739
|
}
|
|
402
740
|
/** Download a file as a Blob. Returns undefined if the file does not exist. */
|
|
403
741
|
async getFile(t, e) {
|
|
404
|
-
|
|
405
|
-
try {
|
|
406
|
-
return await je(o);
|
|
407
|
-
} catch (s) {
|
|
408
|
-
if (s?.code === "storage/object-not-found") return;
|
|
409
|
-
throw s;
|
|
410
|
-
}
|
|
742
|
+
return this._driver(t).getFile(e);
|
|
411
743
|
}
|
|
412
744
|
/** Returns true if the file exists. */
|
|
413
745
|
async fileExists(t, e) {
|
|
414
|
-
return await this.
|
|
746
|
+
return await this.getMetadata(t, e) !== void 0;
|
|
415
747
|
}
|
|
416
748
|
/**
|
|
417
749
|
* Download a file from the public bucket and return its contents as a string.
|
|
418
750
|
* Uses a cache-busted URL to ensure the latest version is fetched.
|
|
419
751
|
*/
|
|
420
752
|
async downloadPublic(t) {
|
|
421
|
-
const e =
|
|
422
|
-
|
|
423
|
-
new Promise((
|
|
424
|
-
|
|
753
|
+
const e = new AbortController(), o = setTimeout(() => e.abort(), 1e4), s = (a) => Promise.race([
|
|
754
|
+
a,
|
|
755
|
+
new Promise((i, n) => {
|
|
756
|
+
e.signal.addEventListener(
|
|
425
757
|
"abort",
|
|
426
|
-
() =>
|
|
758
|
+
() => n(new DOMException(`Download timed out: ${t}`, "AbortError"))
|
|
427
759
|
);
|
|
428
760
|
})
|
|
429
761
|
]);
|
|
430
762
|
try {
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
throw new Error(n ? `Download timed out: ${t}` : i instanceof Error ? i.message : String(i));
|
|
763
|
+
const a = await s(this._driver("public").getCacheBustedUrl(t));
|
|
764
|
+
if (!a) throw new Error(`Not found: ${t}`);
|
|
765
|
+
const i = await fetch(a, { signal: e.signal });
|
|
766
|
+
if (!i.ok) throw new Error(`HTTP ${i.status}`);
|
|
767
|
+
return i.text();
|
|
768
|
+
} catch (a) {
|
|
769
|
+
const i = a instanceof Error && a.name === "AbortError";
|
|
770
|
+
throw new Error(i ? `Download timed out: ${t}` : a instanceof Error ? a.message : String(a));
|
|
440
771
|
} finally {
|
|
441
|
-
clearTimeout(
|
|
772
|
+
clearTimeout(o);
|
|
442
773
|
}
|
|
443
774
|
}
|
|
444
775
|
// ─── Metadata ─────────────────────────────────────────────────────────────
|
|
445
776
|
/** Read file metadata. Returns undefined if the file does not exist. */
|
|
446
777
|
async getMetadata(t, e) {
|
|
447
|
-
|
|
448
|
-
try {
|
|
449
|
-
const s = await G(o);
|
|
450
|
-
return {
|
|
451
|
-
updated: s.updated,
|
|
452
|
-
contentType: s.contentType,
|
|
453
|
-
size: s.size,
|
|
454
|
-
customMetadata: s.customMetadata
|
|
455
|
-
};
|
|
456
|
-
} catch (s) {
|
|
457
|
-
if (s?.code === "storage/object-not-found") return;
|
|
458
|
-
throw s;
|
|
459
|
-
}
|
|
778
|
+
return this._driver(t).getMetadata(e);
|
|
460
779
|
}
|
|
461
780
|
/** Update custom metadata on an existing file. */
|
|
462
781
|
async setMetadata(t, e, o) {
|
|
463
|
-
|
|
464
|
-
await so(s, { customMetadata: o });
|
|
782
|
+
await this._driver(t).setMetadata(e, o);
|
|
465
783
|
}
|
|
466
784
|
// ─── Uploads ──────────────────────────────────────────────────────────────
|
|
467
785
|
/**
|
|
@@ -470,68 +788,40 @@ class F {
|
|
|
470
788
|
* upload progress needs to be surfaced in the UI.
|
|
471
789
|
*/
|
|
472
790
|
uploadResumable(t, e, o, s) {
|
|
473
|
-
|
|
474
|
-
return {
|
|
475
|
-
complete: () => new Promise((n, c) => i.then(() => n(), c)),
|
|
476
|
-
pause: () => i.pause(),
|
|
477
|
-
resume: () => i.resume(),
|
|
478
|
-
cancel: () => i.cancel(),
|
|
479
|
-
onProgress: (n) => {
|
|
480
|
-
const c = i.on("state_changed", (p) => {
|
|
481
|
-
n(p.bytesTransferred, p.totalBytes);
|
|
482
|
-
});
|
|
483
|
-
return () => c();
|
|
484
|
-
}
|
|
485
|
-
};
|
|
791
|
+
return this._driver(t).upload(e, o, s ? { customMetadata: s } : void 0);
|
|
486
792
|
}
|
|
487
793
|
/**
|
|
488
794
|
* Simple one-shot upload. Waits for completion before resolving.
|
|
489
795
|
* Use for small files where progress feedback is not needed.
|
|
490
796
|
*/
|
|
491
|
-
async uploadBytes(t, e, o, s) {
|
|
492
|
-
|
|
493
|
-
|
|
797
|
+
async uploadBytes(t, e, o, s, a) {
|
|
798
|
+
await this._driver(t).upload(e, o, {
|
|
799
|
+
...s ? { customMetadata: s } : {},
|
|
800
|
+
...a ? { contentType: a } : {}
|
|
801
|
+
}).complete();
|
|
494
802
|
}
|
|
495
803
|
/** Upload a string or base64-encoded value. */
|
|
496
|
-
async uploadString(t, e, o, s =
|
|
497
|
-
|
|
498
|
-
await ao(i, o, s, a ? { customMetadata: a } : void 0);
|
|
804
|
+
async uploadString(t, e, o, s = "raw", a) {
|
|
805
|
+
await this._driver(t).uploadString(e, o, s, a);
|
|
499
806
|
}
|
|
500
807
|
// ─── Listing ──────────────────────────────────────────────────────────────
|
|
501
808
|
/** List all item names directly under `prefix` in the given bucket. */
|
|
502
809
|
async listFiles(t, e) {
|
|
503
|
-
|
|
504
|
-
return (await H(o)).items.map((a) => a.name);
|
|
810
|
+
return this._driver(t).listFiles(e);
|
|
505
811
|
}
|
|
506
812
|
/**
|
|
507
813
|
* Recursively list all file full-paths under `prefix` in the given bucket.
|
|
508
814
|
* Returns full storage paths (not just names).
|
|
509
815
|
*/
|
|
510
816
|
async listFilesRecursive(t, e) {
|
|
511
|
-
|
|
512
|
-
const i = await H(S(o, a));
|
|
513
|
-
let n = i.items.map((c) => c.fullPath);
|
|
514
|
-
for (const c of i.prefixes)
|
|
515
|
-
n = n.concat(await s(c.fullPath));
|
|
516
|
-
return n;
|
|
517
|
-
};
|
|
518
|
-
return s(e);
|
|
817
|
+
return this._driver(t).listFilesRecursive(e);
|
|
519
818
|
}
|
|
520
819
|
/**
|
|
521
820
|
* Delete all files under `prefix` recursively.
|
|
522
821
|
* Returns the number of files deleted.
|
|
523
822
|
*/
|
|
524
823
|
async deleteDirectory(t, e) {
|
|
525
|
-
|
|
526
|
-
let a = 0;
|
|
527
|
-
const i = async (n) => {
|
|
528
|
-
const c = await H(S(s, n));
|
|
529
|
-
for (const p of c.items)
|
|
530
|
-
await o(p), a++;
|
|
531
|
-
for (const p of c.prefixes)
|
|
532
|
-
await i(p.fullPath);
|
|
533
|
-
};
|
|
534
|
-
return await i(e), a;
|
|
824
|
+
return this._driver(t).deleteDirectory(e);
|
|
535
825
|
}
|
|
536
826
|
// ─── Legacy helpers kept for CueBlobStorage consumers ────────────────────
|
|
537
827
|
// (used by loaders / processors that were already depending on CueBlobStorage)
|
|
@@ -546,57 +836,77 @@ class F {
|
|
|
546
836
|
* other suffixes upload uncompressed exactly as before, flag or not.
|
|
547
837
|
*/
|
|
548
838
|
async uploadRaw(t, e, o, s = 3, a, i, n = !1) {
|
|
549
|
-
const c =
|
|
550
|
-
let
|
|
551
|
-
for (;
|
|
839
|
+
const c = n && K._GZIP_SUFFIXES.has((o.suffix ?? "").toLowerCase()), p = c ? await K._gzipEncode(e) : e, h = c ? { contentEncoding: "gzip", customMetadata: { ...o, content_encoding: "gzip" } } : { customMetadata: o };
|
|
840
|
+
let d = 0, u;
|
|
841
|
+
for (; d < s; )
|
|
552
842
|
try {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
(_) => {
|
|
564
|
-
if (i) {
|
|
565
|
-
const I = Math.round(_.bytesTransferred / _.totalBytes * 100);
|
|
566
|
-
i(I);
|
|
567
|
-
}
|
|
568
|
-
},
|
|
569
|
-
(_) => {
|
|
570
|
-
a?.removeEventListener("abort", g), f(_);
|
|
571
|
-
},
|
|
572
|
-
() => {
|
|
573
|
-
a?.removeEventListener("abort", g), w();
|
|
574
|
-
}
|
|
575
|
-
);
|
|
576
|
-
});
|
|
843
|
+
if (a?.aborted) throw new DOMException("Upload cancelled", "AbortError");
|
|
844
|
+
const m = this._driver("raw").upload(t, p, h), w = () => m.cancel();
|
|
845
|
+
a?.addEventListener("abort", w, { once: !0 });
|
|
846
|
+
const f = i ? m.onProgress((y, g) => i(g ? Math.round(y / g * 100) : 100)) : void 0;
|
|
847
|
+
try {
|
|
848
|
+
await m.complete();
|
|
849
|
+
} finally {
|
|
850
|
+
a?.removeEventListener("abort", w), f?.();
|
|
851
|
+
}
|
|
852
|
+
if (a?.aborted) throw new DOMException("Upload cancelled", "AbortError");
|
|
577
853
|
return;
|
|
578
|
-
} catch (
|
|
579
|
-
if (a?.aborted ||
|
|
580
|
-
throw
|
|
581
|
-
|
|
854
|
+
} catch (m) {
|
|
855
|
+
if (a?.aborted || m instanceof DOMException && m.name === "AbortError")
|
|
856
|
+
throw a?.aborted ? new DOMException("Upload cancelled", "AbortError") : m;
|
|
857
|
+
u = m, d++, d < s && await new Promise((w) => setTimeout(w, 1e3 * d));
|
|
582
858
|
}
|
|
583
|
-
throw
|
|
859
|
+
throw u;
|
|
584
860
|
}
|
|
585
861
|
/**
|
|
586
862
|
* Upload data to the processed bucket.
|
|
587
863
|
* Skips upload and returns `false` if the blob already exists.
|
|
588
864
|
*/
|
|
589
865
|
async uploadProcessed(t, e, o) {
|
|
590
|
-
|
|
591
|
-
return await G(s).catch(() => null) ? !1 : (await wt(s, e, { customMetadata: o }), !0);
|
|
866
|
+
return await this.fileExists("processed", t) ? !1 : (await this.uploadBytes("processed", t, e, o), !0);
|
|
592
867
|
}
|
|
593
868
|
/** List all blob names directly under `prefix` in the raw bucket. */
|
|
594
869
|
async listRaw(t) {
|
|
595
|
-
|
|
596
|
-
|
|
870
|
+
return this.listFiles("raw", t);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
const it = {
|
|
874
|
+
apiKey: "AIzaSyAiW42QBx9HS4Khu88pCW7MV66IhBAQul0",
|
|
875
|
+
appId: "1:151132927589:web:d2ffdb377dfadfd23ab88c",
|
|
876
|
+
measurementId: "G-YT4PK6HGZD"
|
|
877
|
+
}, Nt = "qaecy-mvp-406413", qo = "734737865998", zo = "sessions_eu_west6", Bo = "spaces_chats_eu_west6", Go = "spaces_raw_eu_west6", Ho = "spaces_processed_eu_west6", Wo = "logs_eu_west6", Vo = "cue_public_eu_west6", Xo = "db_persistence_eu_west6", Yo = "/data-views/admin/consumption", Jo = "/data-views/admin/profile/organizations", jt = "/data-views/admin/profile/api-keys", Lt = "/commands/admin/profile/api-keys", Qo = "/commands/admin/profile/terms", Ko = "/commands/admin/profile/sso-sign-in", Zo = "/commands/admin/profile/analytics-notice", ts = "/commands/admin/usage/view", es = (r) => `/data-views/admin/organizations/${r}/members`, os = (r) => `/data-views/admin/organizations/${r}/admins`, Ut = (r) => `/data-views/admin/organizations/${r}/credits`, ss = (r) => `/data-views/admin/organizations/${r}/credits/report`, rs = (r, t) => `/data-views/admin/organizations/${r}/credits/report/${t}/by-file-type`, as = (r, t) => `/data-views/admin/organizations/${r}/traffic/report/${t}`, is = (r, t) => `/data-views/admin/organizations/${r}/usage/report/${t}`, ns = "/commands/admin/user/signup", cs = "/commands/admin/user/signup/resend", ps = "/commands/admin/user/settings", ls = "/data-views/admin/users/settings", hs = "/commands/admin/organization/signup", ds = (r) => `/commands/admin/organization/${r}/credits`, us = (r) => `/commands/admin/organization/${r}/plan`, gs = (r) => `/commands/admin/organization/${r}/checkout`, ms = (r) => `/commands/admin/organization/${r}/billing-portal`, ws = (r) => `/commands/admin/organization/${r}/members`, fs = (r, t) => `/commands/admin/organization/${r}/members/${t}/role`, ys = (r, t) => `/commands/admin/organization/${r}/members/${t}`, Mt = "/data-views/admin/projects", bs = "/data-views/admin/organizations", vs = "/data-views/admin/organizations/search", _s = (r) => `/data-views/admin/organizations/${r}/projects`, Es = "/data-views/admin/projects/search", Ts = "/data-views/admin/users/search", Ss = (r) => `/data-views/admin/users/${r}/detail`, Is = "/data-views/admin/users/superadmins", Cs = "/data-views/admin/users/deleted", xs = (r) => `/commands/admin/user/${r}`, ks = (r) => `/commands/admin/user/${r}/restore`, Ft = (r) => `/commands/admin/user/${r}/superadmin`, Os = "/commands/admin/user", Rs = "/commands/admin/organization", As = (r) => `/commands/admin/organization/${r}`, $s = (r) => `/commands/admin/organization/${r}/restore`, Ps = (r) => `/commands/admin/organization/${r}/domains`, Ds = "/data-views/admin/organizations/deleted", Ns = "/data-views/admin/users/without-org", js = "/data-views/admin/users/without-project", Ls = "/data-views/admin/projects/without-users", Us = "/data-views/admin/projects/without-admins", Ms = "/data-views/admin/organizations/without-users", Fs = "/data-views/admin/organizations/without-admins", qs = "/commands/admin/project", zs = (r) => `/commands/admin/project/${r}`, Bs = (r) => `/commands/admin/project/${r}`, Gs = (r) => `/commands/admin/project/${r}/restore`, Hs = (r) => `/commands/admin/project/${r}/members`, Ws = (r, t) => `/commands/admin/project/${r}/members/${t}/role`, Vs = (r, t) => `/commands/admin/project/${r}/members/${t}`, Xs = (r) => `/data-views/admin/projects/${r}/metadata`, Ys = (r) => `/commands/admin/project/${r}/metadata`, Js = "/assistant/search", Qs = "/mcp", Ks = "/index/search", Zs = "/index/lookup", tr = "/index/available-filters", Pe = "/cue/qlever/query", er = "/cue/qlever/update", or = "/cue/qlever/shacl", sr = "/cue/qlever/admin/rebuild", qt = "/cue/qlever/admin/migrate", rr = "/cue-db/admin/stats", ar = "/cue-db/admin/stats/refresh", ir = "/cue-db/warm-up", zt = "/commands/file-system-structure/batch", nr = (r) => `/commands/document/${r}/alternative-representation`, cr = "/commands/dms-sync/providers", pr = (r) => `/commands/dms-sync/${r}/preview`, lr = (r) => `/commands/dms-sync/${r}/sync`, hr = "/storage/sessions", dr = "/storage/raw", De = "/storage/processed", ur = "/data-views/processing-status", gr = "/data-views/processing-status/mine", Bt = "microsoft.com", Gt = "superadmin", Tt = "https://cue.qaecy.com/r/", Ht = {
|
|
878
|
+
raw: Go,
|
|
879
|
+
processed: Ho,
|
|
880
|
+
public: Vo,
|
|
881
|
+
logs: Wo,
|
|
882
|
+
chatSessions: Bo,
|
|
883
|
+
persistence: Xo,
|
|
884
|
+
sessions: zo
|
|
885
|
+
}, mr = {
|
|
886
|
+
raw: "storageRaw",
|
|
887
|
+
processed: "storageProcessed",
|
|
888
|
+
public: "storagePublic",
|
|
889
|
+
logs: "storageLogs",
|
|
890
|
+
chatSessions: "storageChatSessions",
|
|
891
|
+
persistence: "storagePersistence",
|
|
892
|
+
sessions: "storageSessions"
|
|
893
|
+
}, wr = ["raw", "processed", "public", "persistence"];
|
|
894
|
+
function Wt(r, t, e, o = {}, s = !1) {
|
|
895
|
+
const a = o.drivers ?? {}, i = {
|
|
896
|
+
drivers: a,
|
|
897
|
+
gateway: {
|
|
898
|
+
gatewayUrl: e.gatewayUrl,
|
|
899
|
+
fetch: (n, c) => t.authenticatedFetch(n, c)
|
|
900
|
+
}
|
|
901
|
+
};
|
|
902
|
+
for (const n of Object.keys(Ht)) {
|
|
903
|
+
if ((a[n] ?? "firebase") !== "firebase") continue;
|
|
904
|
+
const c = oo(r, o.buckets?.[n] ?? Ht[n]);
|
|
905
|
+
s && wr.includes(n) && so(c, e.storageEmulatorHost, e.storageEmulatorPort), i[mr[n]] = c;
|
|
597
906
|
}
|
|
907
|
+
return new K(i);
|
|
598
908
|
}
|
|
599
|
-
class
|
|
909
|
+
class E {
|
|
600
910
|
_value;
|
|
601
911
|
_listeners = /* @__PURE__ */ new Set();
|
|
602
912
|
constructor(t) {
|
|
@@ -639,17 +949,12 @@ function St(r, t) {
|
|
|
639
949
|
}
|
|
640
950
|
};
|
|
641
951
|
}
|
|
642
|
-
|
|
643
|
-
apiKey: "AIzaSyAiW42QBx9HS4Khu88pCW7MV66IhBAQul0",
|
|
644
|
-
appId: "1:151132927589:web:d2ffdb377dfadfd23ab88c",
|
|
645
|
-
measurementId: "G-YT4PK6HGZD"
|
|
646
|
-
}, Nt = "qaecy-mvp-406413", Po = "734737865998", jt = "sessions_eu_west6", Lt = "spaces_chats_eu_west6", Ut = "spaces_raw_eu_west6", Mt = "spaces_processed_eu_west6", qt = "logs_eu_west6", Ft = "cue_public_eu_west6", zt = "db_persistence_eu_west6", Do = "/data-views/admin/consumption", No = "/data-views/admin/profile/organizations", Bt = "/data-views/admin/profile/api-keys", Gt = "/commands/admin/profile/api-keys", jo = "/commands/admin/profile/terms", Lo = "/commands/admin/profile/sso-sign-in", Uo = "/commands/admin/profile/analytics-notice", Mo = "/commands/admin/usage/view", qo = (r) => `/data-views/admin/organizations/${r}/members`, Fo = (r) => `/data-views/admin/organizations/${r}/admins`, Ht = (r) => `/data-views/admin/organizations/${r}/credits`, zo = (r) => `/data-views/admin/organizations/${r}/credits/report`, Bo = (r, t) => `/data-views/admin/organizations/${r}/credits/report/${t}/by-file-type`, Go = (r, t) => `/data-views/admin/organizations/${r}/traffic/report/${t}`, Ho = (r, t) => `/data-views/admin/organizations/${r}/usage/report/${t}`, Wo = "/commands/admin/user/signup", Vo = "/commands/admin/user/signup/resend", Xo = "/commands/admin/user/settings", Yo = "/data-views/admin/users/settings", Jo = "/commands/admin/organization/signup", Qo = (r) => `/commands/admin/organization/${r}/credits`, Ko = (r) => `/commands/admin/organization/${r}/plan`, Zo = (r) => `/commands/admin/organization/${r}/checkout`, ts = (r) => `/commands/admin/organization/${r}/billing-portal`, es = (r) => `/commands/admin/organization/${r}/members`, os = (r, t) => `/commands/admin/organization/${r}/members/${t}/role`, ss = (r, t) => `/commands/admin/organization/${r}/members/${t}`, Wt = "/data-views/admin/projects", rs = "/data-views/admin/organizations", as = "/data-views/admin/organizations/search", is = (r) => `/data-views/admin/organizations/${r}/projects`, ns = "/data-views/admin/projects/search", cs = "/data-views/admin/users/search", ps = (r) => `/data-views/admin/users/${r}/detail`, ls = "/data-views/admin/users/superadmins", hs = "/data-views/admin/users/deleted", ds = (r) => `/commands/admin/user/${r}`, us = (r) => `/commands/admin/user/${r}/restore`, Vt = (r) => `/commands/admin/user/${r}/superadmin`, gs = "/commands/admin/user", ms = "/commands/admin/organization", ws = (r) => `/commands/admin/organization/${r}`, fs = (r) => `/commands/admin/organization/${r}/restore`, ys = (r) => `/commands/admin/organization/${r}/domains`, bs = "/data-views/admin/organizations/deleted", _s = "/data-views/admin/users/without-org", vs = "/data-views/admin/users/without-project", Es = "/data-views/admin/projects/without-users", Ts = "/data-views/admin/projects/without-admins", Ss = "/data-views/admin/organizations/without-users", Is = "/data-views/admin/organizations/without-admins", Cs = "/commands/admin/project", xs = (r) => `/commands/admin/project/${r}`, ks = (r) => `/commands/admin/project/${r}`, Rs = (r) => `/commands/admin/project/${r}/restore`, Os = (r) => `/commands/admin/project/${r}/members`, As = (r, t) => `/commands/admin/project/${r}/members/${t}/role`, $s = (r, t) => `/commands/admin/project/${r}/members/${t}`, Ps = (r) => `/data-views/admin/projects/${r}/metadata`, Ds = (r) => `/commands/admin/project/${r}/metadata`, Ns = "/assistant/search", js = "/mcp", Ls = "/index/search", Us = "/index/lookup", Ms = "/index/available-filters", Me = "/cue/qlever/query", qs = "/cue/qlever/update", Fs = "/cue/qlever/shacl", zs = "/cue/qlever/admin/rebuild", Xt = "/cue/qlever/admin/migrate", Bs = "/cue-db/admin/stats", Gs = "/cue-db/admin/stats/refresh", Hs = "/cue-db/warm-up", Yt = "/commands/file-system-structure/batch", Ws = (r) => `/commands/document/${r}/alternative-representation`, Vs = "/commands/dms-sync/providers", Xs = (r) => `/commands/dms-sync/${r}/preview`, Ys = (r) => `/commands/dms-sync/${r}/sync`, Js = "/storage/sessions", Qs = "/storage/raw", qe = "/storage/processed", Ks = "/data-views/processing-status", Zs = "/data-views/processing-status/mine", Jt = "microsoft.com", Qt = "superadmin", It = "https://cue.qaecy.com/r/";
|
|
647
|
-
class Kt {
|
|
952
|
+
class Vt {
|
|
648
953
|
_auth;
|
|
649
954
|
_endpoints;
|
|
650
|
-
_userSignal = new
|
|
651
|
-
_tokenSignal = new
|
|
652
|
-
_isSuperAdminSignal = new
|
|
955
|
+
_userSignal = new E(null);
|
|
956
|
+
_tokenSignal = new E(null);
|
|
957
|
+
_isSuperAdminSignal = new E(!1);
|
|
653
958
|
_userIdsSignal;
|
|
654
959
|
_stopTokenListener;
|
|
655
960
|
_ssoPending = !1;
|
|
@@ -662,14 +967,14 @@ class Kt {
|
|
|
662
967
|
/** All unique UIDs for the current user (Firebase UID + linked provider UIDs). */
|
|
663
968
|
userIds;
|
|
664
969
|
constructor(t, e = !1, o) {
|
|
665
|
-
this._auth =
|
|
970
|
+
this._auth = ao(t), this._endpoints = o, e && io(this._auth, o.authEmulatorUrl, {
|
|
666
971
|
disableWarnings: !0
|
|
667
972
|
}), this.user = this._userSignal.asReadonly(), this.token = this._tokenSignal.asReadonly(), this.isSuperAdmin = this._isSuperAdminSignal.asReadonly(), this._userIdsSignal = St([this._userSignal], () => {
|
|
668
973
|
const s = this._userSignal.get();
|
|
669
974
|
if (!s) return [];
|
|
670
975
|
const a = /* @__PURE__ */ new Set([s.uid]);
|
|
671
976
|
return s.providerData.forEach((i) => a.add(i.uid)), Array.from(a);
|
|
672
|
-
}), this.userIds = this._userIdsSignal, this._stopTokenListener =
|
|
977
|
+
}), this.userIds = this._userIdsSignal, this._stopTokenListener = no(this._auth, async (s) => {
|
|
673
978
|
s && this._ssoPending || await this._publish(s);
|
|
674
979
|
});
|
|
675
980
|
}
|
|
@@ -677,8 +982,8 @@ class Kt {
|
|
|
677
982
|
if (this._userSignal.set(t), t) {
|
|
678
983
|
const e = await t.getIdToken();
|
|
679
984
|
this._tokenSignal.set(e);
|
|
680
|
-
const o = await
|
|
681
|
-
this._isSuperAdminSignal.set(o.claims.role ===
|
|
985
|
+
const o = await Q(t);
|
|
986
|
+
this._isSuperAdminSignal.set(o.claims.role === Gt);
|
|
682
987
|
} else
|
|
683
988
|
this._tokenSignal.set(null), this._isSuperAdminSignal.set(!1);
|
|
684
989
|
}
|
|
@@ -690,16 +995,16 @@ class Kt {
|
|
|
690
995
|
if (t === "password") {
|
|
691
996
|
if (!e)
|
|
692
997
|
throw new Error("credentials are required for password sign-in");
|
|
693
|
-
return (await
|
|
998
|
+
return (await co(
|
|
694
999
|
this._auth,
|
|
695
1000
|
e.email,
|
|
696
1001
|
e.password
|
|
697
1002
|
)).user;
|
|
698
1003
|
}
|
|
699
|
-
const o = t === "google" ? new
|
|
1004
|
+
const o = t === "google" ? new wt() : new ft(Bt);
|
|
700
1005
|
this._ssoPending = !0;
|
|
701
1006
|
try {
|
|
702
|
-
const s = await
|
|
1007
|
+
const s = await po(this._auth, o);
|
|
703
1008
|
return await this._confirmSsoSignIn(), s.user;
|
|
704
1009
|
} finally {
|
|
705
1010
|
this._ssoPending = !1, await this._publish(this._auth.currentUser);
|
|
@@ -711,8 +1016,8 @@ class Kt {
|
|
|
711
1016
|
* retrieve the result.
|
|
712
1017
|
*/
|
|
713
1018
|
async signInWithRedirect(t) {
|
|
714
|
-
const e = t === "google" ? new
|
|
715
|
-
await
|
|
1019
|
+
const e = t === "google" ? new wt() : new ft(Bt);
|
|
1020
|
+
await lo(this._auth, e);
|
|
716
1021
|
}
|
|
717
1022
|
/**
|
|
718
1023
|
* Retrieve the result of a redirect sign-in. Returns the signed-in `User`
|
|
@@ -720,7 +1025,7 @@ class Kt {
|
|
|
720
1025
|
* Call this once on app startup before showing a sign-in UI.
|
|
721
1026
|
*/
|
|
722
1027
|
async checkRedirectResult() {
|
|
723
|
-
const t = await
|
|
1028
|
+
const t = await ho(this._auth);
|
|
724
1029
|
return t ? (await this._confirmSsoSignIn(), t.user) : null;
|
|
725
1030
|
}
|
|
726
1031
|
/**
|
|
@@ -731,13 +1036,13 @@ class Kt {
|
|
|
731
1036
|
*/
|
|
732
1037
|
async _confirmSsoSignIn() {
|
|
733
1038
|
const t = await this.authenticatedFetch(
|
|
734
|
-
`${this._endpoints.gatewayUrl}${
|
|
1039
|
+
`${this._endpoints.gatewayUrl}${Ko}`,
|
|
735
1040
|
{ method: "POST" }
|
|
736
1041
|
).catch(async (o) => {
|
|
737
|
-
throw await
|
|
1042
|
+
throw await st(this._auth), o;
|
|
738
1043
|
});
|
|
739
1044
|
if (t.ok) return;
|
|
740
|
-
await
|
|
1045
|
+
await st(this._auth);
|
|
741
1046
|
const e = t.status === 403 ? "SSO sign-in is only allowed for existing users." : `SSO sign-in could not be confirmed: ${t.status}`;
|
|
742
1047
|
throw new Error(e);
|
|
743
1048
|
}
|
|
@@ -748,7 +1053,7 @@ class Kt {
|
|
|
748
1053
|
*/
|
|
749
1054
|
async checkSuperAdmin() {
|
|
750
1055
|
const t = this._auth.currentUser;
|
|
751
|
-
return t ? (await
|
|
1056
|
+
return t ? (await Q(t)).claims.role === Gt : !1;
|
|
752
1057
|
}
|
|
753
1058
|
/** Sign in with a Cue API key. `projectId` is optional — omit it when no project context is available (e.g. admin flows). */
|
|
754
1059
|
async signInWithApiKey(t, e) {
|
|
@@ -790,7 +1095,7 @@ class Kt {
|
|
|
790
1095
|
}
|
|
791
1096
|
/** Sign out the current user */
|
|
792
1097
|
async signOut() {
|
|
793
|
-
await
|
|
1098
|
+
await st(this._auth);
|
|
794
1099
|
}
|
|
795
1100
|
/** Currently signed-in user, or null if not authenticated */
|
|
796
1101
|
get currentUser() {
|
|
@@ -798,7 +1103,7 @@ class Kt {
|
|
|
798
1103
|
}
|
|
799
1104
|
/** Subscribe to authentication state changes. Returns an unsubscribe function. */
|
|
800
1105
|
onAuthStateChanged(t) {
|
|
801
|
-
return
|
|
1106
|
+
return uo(this._auth, t);
|
|
802
1107
|
}
|
|
803
1108
|
/** Get the Firebase ID token for the current user, or null if not authenticated */
|
|
804
1109
|
async getToken(t = !1) {
|
|
@@ -830,14 +1135,14 @@ class Kt {
|
|
|
830
1135
|
return this._auth;
|
|
831
1136
|
}
|
|
832
1137
|
}
|
|
833
|
-
class
|
|
1138
|
+
class fr extends Error {
|
|
834
1139
|
constructor(t, e, o) {
|
|
835
1140
|
super(t), this.status = e, this.code = o;
|
|
836
1141
|
}
|
|
837
1142
|
status;
|
|
838
1143
|
code;
|
|
839
1144
|
}
|
|
840
|
-
class
|
|
1145
|
+
class Xt {
|
|
841
1146
|
constructor(t) {
|
|
842
1147
|
this._gatewayUrl = t;
|
|
843
1148
|
}
|
|
@@ -853,7 +1158,7 @@ class Zt {
|
|
|
853
1158
|
*/
|
|
854
1159
|
async signUp(t, e, o, s) {
|
|
855
1160
|
return this._publicPost(
|
|
856
|
-
|
|
1161
|
+
ns,
|
|
857
1162
|
{ name: t, email: e, password: o, termsVersion: s },
|
|
858
1163
|
"Sign-up failed"
|
|
859
1164
|
);
|
|
@@ -867,11 +1172,11 @@ class Zt {
|
|
|
867
1172
|
* 'domainBlocked' for the mappable failure modes.
|
|
868
1173
|
*/
|
|
869
1174
|
async signUpWithOrganization(t) {
|
|
870
|
-
return this._publicPost(
|
|
1175
|
+
return this._publicPost(hs, t, "Organisation sign-up failed");
|
|
871
1176
|
}
|
|
872
1177
|
/** Re-send the verification + set-password emails after a sign-up. */
|
|
873
1178
|
async resendSignUpEmails(t) {
|
|
874
|
-
return this._publicPost(
|
|
1179
|
+
return this._publicPost(cs, { email: t }, "Resend failed");
|
|
875
1180
|
}
|
|
876
1181
|
async _publicPost(t, e, o) {
|
|
877
1182
|
const s = await fetch(`${this._gatewayUrl}${t}`, {
|
|
@@ -881,7 +1186,7 @@ class Zt {
|
|
|
881
1186
|
});
|
|
882
1187
|
if (!s.ok) {
|
|
883
1188
|
const a = await s.json().catch(() => ({}));
|
|
884
|
-
throw new
|
|
1189
|
+
throw new fr(
|
|
885
1190
|
a?.message ?? `${o} (${s.status})`,
|
|
886
1191
|
s.status,
|
|
887
1192
|
a?.code
|
|
@@ -890,11 +1195,11 @@ class Zt {
|
|
|
890
1195
|
return s.json();
|
|
891
1196
|
}
|
|
892
1197
|
}
|
|
893
|
-
const
|
|
894
|
-
raw:
|
|
895
|
-
processed:
|
|
1198
|
+
const yr = {
|
|
1199
|
+
raw: dr,
|
|
1200
|
+
processed: De
|
|
896
1201
|
};
|
|
897
|
-
class
|
|
1202
|
+
class Yt {
|
|
898
1203
|
constructor(t, e) {
|
|
899
1204
|
this._auth = t, this._gatewayUrl = e;
|
|
900
1205
|
}
|
|
@@ -912,7 +1217,7 @@ class te {
|
|
|
912
1217
|
* @param bucket - `'raw'` (default, original uploads) or `'processed'` (derived artefacts).
|
|
913
1218
|
*/
|
|
914
1219
|
getDownloadUrl(t, e, o, s = "raw") {
|
|
915
|
-
return `${this._gatewayUrl}${
|
|
1220
|
+
return `${this._gatewayUrl}${yr[s]}/${t}/${e}${o}`;
|
|
916
1221
|
}
|
|
917
1222
|
/**
|
|
918
1223
|
* Returns a gateway download URL for an alternative representation using its
|
|
@@ -925,7 +1230,7 @@ class te {
|
|
|
925
1230
|
* e.g. `{projectId}/fragments/{uuid}.fragments`.
|
|
926
1231
|
*/
|
|
927
1232
|
getAltRepDownloadUrl(t) {
|
|
928
|
-
return `${this._gatewayUrl}${
|
|
1233
|
+
return `${this._gatewayUrl}${De}/${t}`;
|
|
929
1234
|
}
|
|
930
1235
|
/**
|
|
931
1236
|
* Fetch a file through the gateway and return it as a Blob.
|
|
@@ -940,8 +1245,8 @@ class te {
|
|
|
940
1245
|
return i.blob();
|
|
941
1246
|
}
|
|
942
1247
|
}
|
|
943
|
-
const
|
|
944
|
-
class
|
|
1248
|
+
const br = "/data-views/tables", vr = "/commands/tables";
|
|
1249
|
+
class _r {
|
|
945
1250
|
constructor(t, e) {
|
|
946
1251
|
this._auth = t, this._gatewayUrl = e;
|
|
947
1252
|
}
|
|
@@ -949,7 +1254,7 @@ class rr {
|
|
|
949
1254
|
_gatewayUrl;
|
|
950
1255
|
async listTables(t) {
|
|
951
1256
|
const e = await this._auth.authenticatedFetch(
|
|
952
|
-
`${this._gatewayUrl}${
|
|
1257
|
+
`${this._gatewayUrl}${br}`,
|
|
953
1258
|
{
|
|
954
1259
|
headers: {
|
|
955
1260
|
"Content-Type": "application/json",
|
|
@@ -964,7 +1269,7 @@ class rr {
|
|
|
964
1269
|
}
|
|
965
1270
|
async saveTables(t, e) {
|
|
966
1271
|
const o = await this._auth.authenticatedFetch(
|
|
967
|
-
`${this._gatewayUrl}${
|
|
1272
|
+
`${this._gatewayUrl}${vr}`,
|
|
968
1273
|
{
|
|
969
1274
|
method: "PUT",
|
|
970
1275
|
headers: {
|
|
@@ -979,8 +1284,8 @@ class rr {
|
|
|
979
1284
|
throw new Error(`Failed to save tables: ${o.status} ${o.statusText}`);
|
|
980
1285
|
}
|
|
981
1286
|
}
|
|
982
|
-
const
|
|
983
|
-
class
|
|
1287
|
+
const Er = "/semantic-extraction/extract";
|
|
1288
|
+
class Tr {
|
|
984
1289
|
constructor(t, e) {
|
|
985
1290
|
this._auth = t, this._gatewayUrl = e;
|
|
986
1291
|
}
|
|
@@ -997,7 +1302,7 @@ class ir {
|
|
|
997
1302
|
const e = t.rdfFormat ?? "json-ld", o = new FormData();
|
|
998
1303
|
o.append("file", t.image, "page.png"), o.append("project_schema", JSON.stringify(t.projectSchema)), o.append("space_id", t.projectId), o.append("rdf_format", e), t.category && o.append("category", t.category), t.text && o.append("text", t.text);
|
|
999
1304
|
const s = await this._auth.authenticatedFetch(
|
|
1000
|
-
`${this._gatewayUrl}${
|
|
1305
|
+
`${this._gatewayUrl}${Er}`,
|
|
1001
1306
|
{
|
|
1002
1307
|
method: "POST",
|
|
1003
1308
|
// Do NOT set Content-Type; browser sets it with the correct boundary.
|
|
@@ -1018,7 +1323,7 @@ class ir {
|
|
|
1018
1323
|
return { jsonld: await s.json() };
|
|
1019
1324
|
}
|
|
1020
1325
|
}
|
|
1021
|
-
class
|
|
1326
|
+
class Sr {
|
|
1022
1327
|
constructor(t, e) {
|
|
1023
1328
|
this._auth = t, this._gatewayUrl = e;
|
|
1024
1329
|
}
|
|
@@ -1034,7 +1339,7 @@ class nr {
|
|
|
1034
1339
|
* @param contextId - The context document ID (without the `.json.gz` suffix).
|
|
1035
1340
|
*/
|
|
1036
1341
|
async getContext(t, e) {
|
|
1037
|
-
const o = `${this._gatewayUrl}${
|
|
1342
|
+
const o = `${this._gatewayUrl}${hr}/${t}/contexts/${e}.json.gz`, s = await this._auth.authenticatedFetch(o, {
|
|
1038
1343
|
headers: {
|
|
1039
1344
|
"cue-project-id": t,
|
|
1040
1345
|
// Prevent the HTTP layer from auto-decompressing so we can handle it explicitly.
|
|
@@ -1047,7 +1352,7 @@ class nr {
|
|
|
1047
1352
|
return JSON.parse(await new Response(i).text());
|
|
1048
1353
|
}
|
|
1049
1354
|
}
|
|
1050
|
-
function
|
|
1355
|
+
function Ir(r) {
|
|
1051
1356
|
const t = r.graph?.datasets?.[0] ?? { sizeInBytes: null };
|
|
1052
1357
|
return {
|
|
1053
1358
|
created: t.created ?? null,
|
|
@@ -1077,7 +1382,7 @@ function cr(r) {
|
|
|
1077
1382
|
history: (t.history ?? []).map(({ sizeInBytes: e, ...o }) => ({ ...o, graphSizeInBytes: e ?? null }))
|
|
1078
1383
|
};
|
|
1079
1384
|
}
|
|
1080
|
-
class
|
|
1385
|
+
class Cr {
|
|
1081
1386
|
constructor(t, e) {
|
|
1082
1387
|
this._auth = t, this._gatewayUrl = e;
|
|
1083
1388
|
}
|
|
@@ -1085,7 +1390,7 @@ class pr {
|
|
|
1085
1390
|
_gatewayUrl;
|
|
1086
1391
|
async search(t, e, o) {
|
|
1087
1392
|
const s = await this._auth.authenticatedFetch(
|
|
1088
|
-
`${this._gatewayUrl}${
|
|
1393
|
+
`${this._gatewayUrl}${Ks}`,
|
|
1089
1394
|
{
|
|
1090
1395
|
method: "POST",
|
|
1091
1396
|
headers: { "Content-Type": "application/json", "x-project-id": e },
|
|
@@ -1098,7 +1403,7 @@ class pr {
|
|
|
1098
1403
|
async lookup(t, e, o) {
|
|
1099
1404
|
console.log(`CueIndexApi.lookup: input=${t}, projectId=${e}, opts=${JSON.stringify(o)}`);
|
|
1100
1405
|
const s = await this._auth.authenticatedFetch(
|
|
1101
|
-
`${this._gatewayUrl}${
|
|
1406
|
+
`${this._gatewayUrl}${Zs}`,
|
|
1102
1407
|
{
|
|
1103
1408
|
method: "POST",
|
|
1104
1409
|
headers: { "Content-Type": "application/json", "x-project-id": e },
|
|
@@ -1122,7 +1427,7 @@ class pr {
|
|
|
1122
1427
|
async availableFilters(t, e) {
|
|
1123
1428
|
console.log(`CueIndexApi.availableFilters(projectId=${t}, applied=${JSON.stringify(e)})`);
|
|
1124
1429
|
const o = await this._auth.authenticatedFetch(
|
|
1125
|
-
`${this._gatewayUrl}${
|
|
1430
|
+
`${this._gatewayUrl}${tr}`,
|
|
1126
1431
|
{
|
|
1127
1432
|
method: "POST",
|
|
1128
1433
|
headers: { "Content-Type": "application/json", "x-project-id": t },
|
|
@@ -1144,7 +1449,7 @@ class pr {
|
|
|
1144
1449
|
*/
|
|
1145
1450
|
async rebuild(t, e) {
|
|
1146
1451
|
const o = await this._auth.authenticatedFetch(
|
|
1147
|
-
`${this._gatewayUrl}${
|
|
1452
|
+
`${this._gatewayUrl}${sr}`,
|
|
1148
1453
|
{ method: "POST", headers: { "x-project-id": t } }
|
|
1149
1454
|
);
|
|
1150
1455
|
if (!o.ok || !o.body)
|
|
@@ -1173,7 +1478,7 @@ class pr {
|
|
|
1173
1478
|
*/
|
|
1174
1479
|
async migrate(t, e) {
|
|
1175
1480
|
const o = await this._auth.authenticatedFetch(
|
|
1176
|
-
`${this._gatewayUrl}${
|
|
1481
|
+
`${this._gatewayUrl}${qt}`,
|
|
1177
1482
|
{
|
|
1178
1483
|
method: "POST",
|
|
1179
1484
|
headers: { "x-project-id": t, "Content-Type": "application/json" },
|
|
@@ -1215,7 +1520,7 @@ class pr {
|
|
|
1215
1520
|
*/
|
|
1216
1521
|
async migrateAll(t, e, o = !1) {
|
|
1217
1522
|
const s = await this._auth.authenticatedFetch(
|
|
1218
|
-
`${this._gatewayUrl}${
|
|
1523
|
+
`${this._gatewayUrl}${qt}`,
|
|
1219
1524
|
{
|
|
1220
1525
|
method: "POST",
|
|
1221
1526
|
headers: { "x-project-id": t, "Content-Type": "application/json" },
|
|
@@ -1247,11 +1552,11 @@ class pr {
|
|
|
1247
1552
|
*/
|
|
1248
1553
|
async stats(t) {
|
|
1249
1554
|
const e = await this._auth.authenticatedFetch(
|
|
1250
|
-
`${this._gatewayUrl}${
|
|
1555
|
+
`${this._gatewayUrl}${rr}`,
|
|
1251
1556
|
{ headers: { "x-project-id": t } }
|
|
1252
1557
|
);
|
|
1253
1558
|
if (!e.ok) throw new Error(`Index stats failed: ${e.status} ${e.statusText}`);
|
|
1254
|
-
return
|
|
1559
|
+
return Ir(await e.json());
|
|
1255
1560
|
}
|
|
1256
1561
|
/**
|
|
1257
1562
|
* Recomputes the graph engine's stats aggregate (document count, index size,
|
|
@@ -1265,7 +1570,7 @@ class pr {
|
|
|
1265
1570
|
*/
|
|
1266
1571
|
async refreshStats(t) {
|
|
1267
1572
|
const e = await this._auth.authenticatedFetch(
|
|
1268
|
-
`${this._gatewayUrl}${
|
|
1573
|
+
`${this._gatewayUrl}${ar}`,
|
|
1269
1574
|
{ method: "POST", headers: t ? { "x-project-id": t } : {} }
|
|
1270
1575
|
);
|
|
1271
1576
|
if (!e.ok)
|
|
@@ -1281,53 +1586,53 @@ class pr {
|
|
|
1281
1586
|
*/
|
|
1282
1587
|
async warmUp(t) {
|
|
1283
1588
|
const e = await this._auth.authenticatedFetch(
|
|
1284
|
-
`${this._gatewayUrl}${
|
|
1589
|
+
`${this._gatewayUrl}${ir}`,
|
|
1285
1590
|
{ method: "POST", headers: { "x-project-id": t } }
|
|
1286
1591
|
);
|
|
1287
1592
|
if (!e.ok) throw new Error(`Wake-up failed: ${e.status} ${e.statusText}`);
|
|
1288
1593
|
return "Project woken up.";
|
|
1289
1594
|
}
|
|
1290
1595
|
}
|
|
1291
|
-
const
|
|
1292
|
-
function
|
|
1596
|
+
const xr = "@qaecy/cue-sdk", kr = "0.0.34";
|
|
1597
|
+
function Or(r) {
|
|
1293
1598
|
const t = {};
|
|
1294
1599
|
return new Headers(r).forEach((e, o) => {
|
|
1295
1600
|
t[o] = e;
|
|
1296
1601
|
}), t;
|
|
1297
1602
|
}
|
|
1298
|
-
function
|
|
1603
|
+
function Ne(r) {
|
|
1299
1604
|
return r.filter((t) => t.type === "text").map((t) => t.text).join(`
|
|
1300
1605
|
`);
|
|
1301
1606
|
}
|
|
1302
|
-
function
|
|
1607
|
+
function Rr(r) {
|
|
1303
1608
|
return typeof r == "object" && r !== null && typeof r.error == "string" && !("id" in r);
|
|
1304
1609
|
}
|
|
1305
|
-
function
|
|
1610
|
+
function Ar(r) {
|
|
1306
1611
|
const t = r.structuredContent;
|
|
1307
1612
|
if (t != null) return t;
|
|
1308
|
-
const e =
|
|
1613
|
+
const e = Ne(r.content);
|
|
1309
1614
|
try {
|
|
1310
1615
|
return JSON.parse(e);
|
|
1311
1616
|
} catch {
|
|
1312
1617
|
return e;
|
|
1313
1618
|
}
|
|
1314
1619
|
}
|
|
1315
|
-
class
|
|
1620
|
+
class $r {
|
|
1316
1621
|
constructor(t, e) {
|
|
1317
1622
|
this._auth = t, this._gatewayUrl = e;
|
|
1318
1623
|
}
|
|
1319
1624
|
_auth;
|
|
1320
1625
|
_gatewayUrl;
|
|
1321
1626
|
async callTool(t, e, o) {
|
|
1322
|
-
const s = new
|
|
1323
|
-
new URL(`${this._gatewayUrl}${
|
|
1627
|
+
const s = new _o({ name: xr, version: kr }), a = new Eo(
|
|
1628
|
+
new URL(`${this._gatewayUrl}${Qs}`),
|
|
1324
1629
|
{
|
|
1325
1630
|
// Route every MCP HTTP request through the SDK's authenticated fetch so
|
|
1326
1631
|
// the gateway sees a Firebase Bearer token (and 401s trigger a refresh).
|
|
1327
1632
|
// The transport passes headers as a `Headers` instance; authenticatedFetch
|
|
1328
1633
|
// merges via object spread, which drops a `Headers` object — so flatten to
|
|
1329
1634
|
// a plain record first to preserve content-type/accept/session headers.
|
|
1330
|
-
fetch: (i, n) => this._auth.authenticatedFetch(i.toString(), { ...n, headers:
|
|
1635
|
+
fetch: (i, n) => this._auth.authenticatedFetch(i.toString(), { ...n, headers: Or(n?.headers) })
|
|
1331
1636
|
}
|
|
1332
1637
|
);
|
|
1333
1638
|
try {
|
|
@@ -1338,9 +1643,9 @@ class mr {
|
|
|
1338
1643
|
o?.signal ? { signal: o.signal } : void 0
|
|
1339
1644
|
);
|
|
1340
1645
|
if (i.isError)
|
|
1341
|
-
throw new Error(`MCP tool '${t}' failed: ${
|
|
1342
|
-
const n =
|
|
1343
|
-
if (
|
|
1646
|
+
throw new Error(`MCP tool '${t}' failed: ${Ne(i.content) || "unknown error"}`);
|
|
1647
|
+
const n = Ar(i);
|
|
1648
|
+
if (Rr(n))
|
|
1344
1649
|
throw new Error(`MCP tool '${t}' failed: ${n.error}`);
|
|
1345
1650
|
return n;
|
|
1346
1651
|
} finally {
|
|
@@ -1349,8 +1654,8 @@ class mr {
|
|
|
1349
1654
|
}
|
|
1350
1655
|
}
|
|
1351
1656
|
}
|
|
1352
|
-
const
|
|
1353
|
-
class
|
|
1657
|
+
const Pr = "/data-views/app-data", Dr = "/commands/app-data";
|
|
1658
|
+
class Nr {
|
|
1354
1659
|
constructor(t, e) {
|
|
1355
1660
|
this._auth = t, this._gatewayUrl = e;
|
|
1356
1661
|
}
|
|
@@ -1362,7 +1667,7 @@ class yr {
|
|
|
1362
1667
|
*/
|
|
1363
1668
|
async get(t) {
|
|
1364
1669
|
const e = await this._auth.authenticatedFetch(
|
|
1365
|
-
`${this._gatewayUrl}${
|
|
1670
|
+
`${this._gatewayUrl}${Pr}/${encodeURIComponent(t)}`,
|
|
1366
1671
|
{ headers: { "Content-Type": "application/json" } }
|
|
1367
1672
|
);
|
|
1368
1673
|
if (!e.ok)
|
|
@@ -1376,7 +1681,7 @@ class yr {
|
|
|
1376
1681
|
*/
|
|
1377
1682
|
async set(t, e) {
|
|
1378
1683
|
const o = await this._auth.authenticatedFetch(
|
|
1379
|
-
`${this._gatewayUrl}${
|
|
1684
|
+
`${this._gatewayUrl}${Dr}/${encodeURIComponent(t)}`,
|
|
1380
1685
|
{
|
|
1381
1686
|
method: "PUT",
|
|
1382
1687
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1395,8 +1700,8 @@ class yr {
|
|
|
1395
1700
|
}
|
|
1396
1701
|
}
|
|
1397
1702
|
}
|
|
1398
|
-
const
|
|
1399
|
-
class
|
|
1703
|
+
const Jt = "/data-views/custom-apps", nt = "/commands/custom-apps";
|
|
1704
|
+
class jr {
|
|
1400
1705
|
constructor(t, e) {
|
|
1401
1706
|
this._auth = t, this._gatewayUrl = e;
|
|
1402
1707
|
}
|
|
@@ -1405,7 +1710,7 @@ class br {
|
|
|
1405
1710
|
/** List every custom app shared within the given organization (metadata only, no HTML). */
|
|
1406
1711
|
async list(t) {
|
|
1407
1712
|
const e = await this._auth.authenticatedFetch(
|
|
1408
|
-
`${this._gatewayUrl}${
|
|
1713
|
+
`${this._gatewayUrl}${Jt}?organizationId=${encodeURIComponent(t)}`
|
|
1409
1714
|
);
|
|
1410
1715
|
if (!e.ok)
|
|
1411
1716
|
throw new Error(`Failed to list custom apps: ${e.status} ${e.statusText}`);
|
|
@@ -1414,7 +1719,7 @@ class br {
|
|
|
1414
1719
|
/** Fetch a single custom app's full record, including its HTML body. */
|
|
1415
1720
|
async get(t) {
|
|
1416
1721
|
const e = await this._auth.authenticatedFetch(
|
|
1417
|
-
`${this._gatewayUrl}${
|
|
1722
|
+
`${this._gatewayUrl}${Jt}/${encodeURIComponent(t)}`
|
|
1418
1723
|
);
|
|
1419
1724
|
if (!e.ok)
|
|
1420
1725
|
throw new Error(`Failed to fetch custom app: ${e.status} ${e.statusText}`);
|
|
@@ -1455,7 +1760,7 @@ class br {
|
|
|
1455
1760
|
throw new Error(`Failed to delete custom app: ${e.status} ${e.statusText}`);
|
|
1456
1761
|
}
|
|
1457
1762
|
}
|
|
1458
|
-
class
|
|
1763
|
+
class Lr {
|
|
1459
1764
|
constructor(t, e) {
|
|
1460
1765
|
this._auth = t, this._gatewayUrl = e;
|
|
1461
1766
|
}
|
|
@@ -1467,7 +1772,7 @@ class _r {
|
|
|
1467
1772
|
*/
|
|
1468
1773
|
async get() {
|
|
1469
1774
|
const t = await this._auth.authenticatedFetch(
|
|
1470
|
-
`${this._gatewayUrl}${
|
|
1775
|
+
`${this._gatewayUrl}${ls}`,
|
|
1471
1776
|
{ headers: { "Content-Type": "application/json" } }
|
|
1472
1777
|
);
|
|
1473
1778
|
if (!t.ok)
|
|
@@ -1481,7 +1786,7 @@ class _r {
|
|
|
1481
1786
|
*/
|
|
1482
1787
|
async set(t) {
|
|
1483
1788
|
const e = await this._auth.authenticatedFetch(
|
|
1484
|
-
`${this._gatewayUrl}${
|
|
1789
|
+
`${this._gatewayUrl}${ps}`,
|
|
1485
1790
|
{
|
|
1486
1791
|
method: "PUT",
|
|
1487
1792
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1501,7 +1806,7 @@ class _r {
|
|
|
1501
1806
|
}
|
|
1502
1807
|
}
|
|
1503
1808
|
const ct = 3e3;
|
|
1504
|
-
class
|
|
1809
|
+
class Ur {
|
|
1505
1810
|
constructor(t, e) {
|
|
1506
1811
|
this._auth = t, this._gatewayUrl = e;
|
|
1507
1812
|
}
|
|
@@ -1514,7 +1819,7 @@ class vr {
|
|
|
1514
1819
|
*/
|
|
1515
1820
|
watchStatus(t) {
|
|
1516
1821
|
const { signal: e, close: o } = this._open(
|
|
1517
|
-
|
|
1822
|
+
ur,
|
|
1518
1823
|
{ projectId: t },
|
|
1519
1824
|
`project "${t}"`
|
|
1520
1825
|
);
|
|
@@ -1534,7 +1839,7 @@ class vr {
|
|
|
1534
1839
|
*/
|
|
1535
1840
|
watchMyStatus() {
|
|
1536
1841
|
const { signal: t, close: e } = this._open(
|
|
1537
|
-
|
|
1842
|
+
gr,
|
|
1538
1843
|
{},
|
|
1539
1844
|
"current user"
|
|
1540
1845
|
);
|
|
@@ -1547,7 +1852,7 @@ class vr {
|
|
|
1547
1852
|
* query string because browsers cannot set headers on a WebSocket handshake.
|
|
1548
1853
|
*/
|
|
1549
1854
|
_open(t, e, o) {
|
|
1550
|
-
const s = new
|
|
1855
|
+
const s = new E(void 0);
|
|
1551
1856
|
let a = null, i = null, n = !1;
|
|
1552
1857
|
const c = async () => {
|
|
1553
1858
|
if (n) return;
|
|
@@ -1580,7 +1885,7 @@ class vr {
|
|
|
1580
1885
|
};
|
|
1581
1886
|
}
|
|
1582
1887
|
}
|
|
1583
|
-
class
|
|
1888
|
+
class Mr {
|
|
1584
1889
|
constructor(t, e) {
|
|
1585
1890
|
this._auth = t, this._gatewayUrl = e;
|
|
1586
1891
|
}
|
|
@@ -1589,7 +1894,7 @@ class Er {
|
|
|
1589
1894
|
/** Lists the DMS providers this project can sync from. */
|
|
1590
1895
|
async listSupportedProviders() {
|
|
1591
1896
|
const t = await this._auth.authenticatedFetch(
|
|
1592
|
-
`${this._gatewayUrl}${
|
|
1897
|
+
`${this._gatewayUrl}${cr}`,
|
|
1593
1898
|
{ headers: { "Content-Type": "application/json" } }
|
|
1594
1899
|
);
|
|
1595
1900
|
if (!t.ok)
|
|
@@ -1603,7 +1908,7 @@ class Er {
|
|
|
1603
1908
|
*/
|
|
1604
1909
|
async previewSync(t, e, o) {
|
|
1605
1910
|
const s = await this._auth.authenticatedFetch(
|
|
1606
|
-
`${this._gatewayUrl}${
|
|
1911
|
+
`${this._gatewayUrl}${pr(t)}`,
|
|
1607
1912
|
{
|
|
1608
1913
|
method: "POST",
|
|
1609
1914
|
headers: {
|
|
@@ -1624,7 +1929,7 @@ class Er {
|
|
|
1624
1929
|
*/
|
|
1625
1930
|
async confirmSync(t, e, o) {
|
|
1626
1931
|
const s = await this._auth.authenticatedFetch(
|
|
1627
|
-
`${this._gatewayUrl}${
|
|
1932
|
+
`${this._gatewayUrl}${lr(t)}`,
|
|
1628
1933
|
{
|
|
1629
1934
|
method: "POST",
|
|
1630
1935
|
headers: {
|
|
@@ -1640,8 +1945,8 @@ class Er {
|
|
|
1640
1945
|
return s.json();
|
|
1641
1946
|
}
|
|
1642
1947
|
}
|
|
1643
|
-
const
|
|
1644
|
-
class
|
|
1948
|
+
const Fr = "/llm-tools/wrangling-schema/generate", qr = "/llm-tools/wrangling-schema/refine", zr = "/llm-tools/entity-category-suggestion/suggest", Br = "/llm-tools/entity-category-suggestion/suggest-batch", Gr = "/llm-tools/schema-suggestion/from-prose", Hr = "/llm-tools/schema-suggestion/from-images", Wr = "/llm-tools/schema-suggestion/parse-coding-scheme", Vr = "/llm-tools/schema-suggestion/from-coding-scheme", Xr = "/llm-tools/schema-suggestion/from-columns", Yr = "/llm-tools/schema-suggestion/prompt", Jr = "/llm-tools/schema-suggestion/translate";
|
|
1949
|
+
class Qr {
|
|
1645
1950
|
constructor(t, e) {
|
|
1646
1951
|
this._auth = t, this._gatewayUrl = e;
|
|
1647
1952
|
}
|
|
@@ -1654,7 +1959,7 @@ class Dr {
|
|
|
1654
1959
|
*/
|
|
1655
1960
|
async generateWranglingSchema(t) {
|
|
1656
1961
|
const e = await this._auth.authenticatedFetch(
|
|
1657
|
-
`${this._gatewayUrl}${
|
|
1962
|
+
`${this._gatewayUrl}${Fr}`,
|
|
1658
1963
|
{
|
|
1659
1964
|
method: "POST",
|
|
1660
1965
|
headers: {
|
|
@@ -1685,7 +1990,7 @@ class Dr {
|
|
|
1685
1990
|
*/
|
|
1686
1991
|
async refineWranglingSchema(t) {
|
|
1687
1992
|
const e = await this._auth.authenticatedFetch(
|
|
1688
|
-
`${this._gatewayUrl}${
|
|
1993
|
+
`${this._gatewayUrl}${qr}`,
|
|
1689
1994
|
{
|
|
1690
1995
|
method: "POST",
|
|
1691
1996
|
headers: {
|
|
@@ -1719,7 +2024,7 @@ class Dr {
|
|
|
1719
2024
|
*/
|
|
1720
2025
|
async suggestEntityCategory(t) {
|
|
1721
2026
|
const e = await this._auth.authenticatedFetch(
|
|
1722
|
-
`${this._gatewayUrl}${
|
|
2027
|
+
`${this._gatewayUrl}${zr}`,
|
|
1723
2028
|
{
|
|
1724
2029
|
method: "POST",
|
|
1725
2030
|
headers: {
|
|
@@ -1753,7 +2058,7 @@ class Dr {
|
|
|
1753
2058
|
*/
|
|
1754
2059
|
async suggestEntityCategoryBatch(t) {
|
|
1755
2060
|
const e = await this._auth.authenticatedFetch(
|
|
1756
|
-
`${this._gatewayUrl}${
|
|
2061
|
+
`${this._gatewayUrl}${Br}`,
|
|
1757
2062
|
{
|
|
1758
2063
|
method: "POST",
|
|
1759
2064
|
headers: {
|
|
@@ -1782,7 +2087,7 @@ class Dr {
|
|
|
1782
2087
|
*/
|
|
1783
2088
|
async suggestFromProse(t) {
|
|
1784
2089
|
const e = await this._auth.authenticatedFetch(
|
|
1785
|
-
`${this._gatewayUrl}${
|
|
2090
|
+
`${this._gatewayUrl}${Gr}`,
|
|
1786
2091
|
{
|
|
1787
2092
|
method: "POST",
|
|
1788
2093
|
headers: {
|
|
@@ -1812,7 +2117,7 @@ class Dr {
|
|
|
1812
2117
|
*/
|
|
1813
2118
|
async suggestFromImages(t) {
|
|
1814
2119
|
const e = await this._auth.authenticatedFetch(
|
|
1815
|
-
`${this._gatewayUrl}${
|
|
2120
|
+
`${this._gatewayUrl}${Hr}`,
|
|
1816
2121
|
{
|
|
1817
2122
|
method: "POST",
|
|
1818
2123
|
headers: {
|
|
@@ -1841,7 +2146,7 @@ class Dr {
|
|
|
1841
2146
|
*/
|
|
1842
2147
|
async parseCodingScheme(t) {
|
|
1843
2148
|
const e = await this._auth.authenticatedFetch(
|
|
1844
|
-
`${this._gatewayUrl}${
|
|
2149
|
+
`${this._gatewayUrl}${Wr}`,
|
|
1845
2150
|
{
|
|
1846
2151
|
method: "POST",
|
|
1847
2152
|
headers: {
|
|
@@ -1871,7 +2176,7 @@ class Dr {
|
|
|
1871
2176
|
*/
|
|
1872
2177
|
async suggestFromCodingScheme(t) {
|
|
1873
2178
|
const e = await this._auth.authenticatedFetch(
|
|
1874
|
-
`${this._gatewayUrl}${
|
|
2179
|
+
`${this._gatewayUrl}${Vr}`,
|
|
1875
2180
|
{
|
|
1876
2181
|
method: "POST",
|
|
1877
2182
|
headers: {
|
|
@@ -1907,7 +2212,7 @@ class Dr {
|
|
|
1907
2212
|
*/
|
|
1908
2213
|
async suggestFromColumns(t) {
|
|
1909
2214
|
const e = await this._auth.authenticatedFetch(
|
|
1910
|
-
`${this._gatewayUrl}${
|
|
2215
|
+
`${this._gatewayUrl}${Xr}`,
|
|
1911
2216
|
{
|
|
1912
2217
|
method: "POST",
|
|
1913
2218
|
headers: {
|
|
@@ -1938,7 +2243,7 @@ class Dr {
|
|
|
1938
2243
|
*/
|
|
1939
2244
|
async suggestPrompt(t) {
|
|
1940
2245
|
const e = await this._auth.authenticatedFetch(
|
|
1941
|
-
`${this._gatewayUrl}${
|
|
2246
|
+
`${this._gatewayUrl}${Yr}`,
|
|
1942
2247
|
{
|
|
1943
2248
|
method: "POST",
|
|
1944
2249
|
headers: {
|
|
@@ -1970,7 +2275,7 @@ class Dr {
|
|
|
1970
2275
|
*/
|
|
1971
2276
|
async translate(t) {
|
|
1972
2277
|
const e = await this._auth.authenticatedFetch(
|
|
1973
|
-
`${this._gatewayUrl}${
|
|
2278
|
+
`${this._gatewayUrl}${Jr}`,
|
|
1974
2279
|
{
|
|
1975
2280
|
method: "POST",
|
|
1976
2281
|
headers: {
|
|
@@ -1993,8 +2298,8 @@ class Dr {
|
|
|
1993
2298
|
return e.json();
|
|
1994
2299
|
}
|
|
1995
2300
|
}
|
|
1996
|
-
const
|
|
1997
|
-
class
|
|
2301
|
+
const $ = "/commands/data-sources", Qt = "/data-views/data-sources", Kr = 18e4;
|
|
2302
|
+
class Zr {
|
|
1998
2303
|
constructor(t, e, o) {
|
|
1999
2304
|
this._auth = t, this._gatewayUrl = e, this._blob = o;
|
|
2000
2305
|
}
|
|
@@ -2002,7 +2307,7 @@ class jr {
|
|
|
2002
2307
|
_gatewayUrl;
|
|
2003
2308
|
_blob;
|
|
2004
2309
|
async createDataSource(t, e, o) {
|
|
2005
|
-
const s = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
2310
|
+
const s = await this._auth.authenticatedFetch(`${this._gatewayUrl}${$}`, {
|
|
2006
2311
|
method: "POST",
|
|
2007
2312
|
headers: { "Content-Type": "application/json", "x-project-id": t, "cue-project-id": t },
|
|
2008
2313
|
body: JSON.stringify({ name: e, config: o })
|
|
@@ -2012,7 +2317,7 @@ class jr {
|
|
|
2012
2317
|
return s.json();
|
|
2013
2318
|
}
|
|
2014
2319
|
async updateDataSource(t, e, o) {
|
|
2015
|
-
const s = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
2320
|
+
const s = await this._auth.authenticatedFetch(`${this._gatewayUrl}${$}/${e}`, {
|
|
2016
2321
|
method: "PATCH",
|
|
2017
2322
|
headers: { "Content-Type": "application/json", "x-project-id": t, "cue-project-id": t },
|
|
2018
2323
|
body: JSON.stringify(o)
|
|
@@ -2031,10 +2336,10 @@ class jr {
|
|
|
2031
2336
|
* with no further progress.
|
|
2032
2337
|
*/
|
|
2033
2338
|
async deleteDataSource(t, e, o) {
|
|
2034
|
-
const s = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
2339
|
+
const s = await this._auth.authenticatedFetch(`${this._gatewayUrl}${$}/${e}`, {
|
|
2035
2340
|
method: "DELETE",
|
|
2036
2341
|
headers: { "x-project-id": t, "cue-project-id": t },
|
|
2037
|
-
signal: AbortSignal.timeout(
|
|
2342
|
+
signal: AbortSignal.timeout(Kr)
|
|
2038
2343
|
});
|
|
2039
2344
|
if (!s.ok)
|
|
2040
2345
|
throw new Error(await this._errorMessage("Delete data source failed", s));
|
|
@@ -2060,7 +2365,7 @@ class jr {
|
|
|
2060
2365
|
async uploadData(t, e, o, s, a) {
|
|
2061
2366
|
const i = await this._stageFiles(t, o, a);
|
|
2062
2367
|
a?.({ phase: "processing", message: "Upload complete, starting processing…" });
|
|
2063
|
-
const n = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
2368
|
+
const n = await this._auth.authenticatedFetch(`${this._gatewayUrl}${$}/${e}/data/from-storage`, {
|
|
2064
2369
|
method: "POST",
|
|
2065
2370
|
headers: { "Content-Type": "application/json", "x-project-id": t, "cue-project-id": t },
|
|
2066
2371
|
body: JSON.stringify({ files: i, mode: s })
|
|
@@ -2081,7 +2386,7 @@ class jr {
|
|
|
2081
2386
|
* would quietly empty its graph.
|
|
2082
2387
|
*/
|
|
2083
2388
|
async refreshDataSource(t, e, o) {
|
|
2084
|
-
const s = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
2389
|
+
const s = await this._auth.authenticatedFetch(`${this._gatewayUrl}${$}/${e}/refresh`, {
|
|
2085
2390
|
method: "POST",
|
|
2086
2391
|
headers: { "Content-Type": "application/json", "x-project-id": t, "cue-project-id": t },
|
|
2087
2392
|
body: "{}"
|
|
@@ -2102,7 +2407,7 @@ class jr {
|
|
|
2102
2407
|
async previewTransform(t, e, o, s) {
|
|
2103
2408
|
const a = await this._stageFiles(t, o, s);
|
|
2104
2409
|
s?.({ phase: "processing", message: "Upload complete, starting processing…" });
|
|
2105
|
-
const i = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
2410
|
+
const i = await this._auth.authenticatedFetch(`${this._gatewayUrl}${$}/preview/from-storage`, {
|
|
2106
2411
|
method: "POST",
|
|
2107
2412
|
headers: { "Content-Type": "application/json", "x-project-id": t, "cue-project-id": t },
|
|
2108
2413
|
body: JSON.stringify({ files: a, config: e })
|
|
@@ -2184,7 +2489,7 @@ class jr {
|
|
|
2184
2489
|
return s;
|
|
2185
2490
|
}
|
|
2186
2491
|
async listDataSources(t) {
|
|
2187
|
-
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
2492
|
+
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${Qt}`, {
|
|
2188
2493
|
headers: { "x-project-id": t, "cue-project-id": t }
|
|
2189
2494
|
});
|
|
2190
2495
|
if (!e.ok)
|
|
@@ -2192,7 +2497,7 @@ class jr {
|
|
|
2192
2497
|
return e.json();
|
|
2193
2498
|
}
|
|
2194
2499
|
async getDataSource(t, e) {
|
|
2195
|
-
const o = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
2500
|
+
const o = await this._auth.authenticatedFetch(`${this._gatewayUrl}${Qt}/${e}`, {
|
|
2196
2501
|
headers: { "x-project-id": t, "cue-project-id": t }
|
|
2197
2502
|
});
|
|
2198
2503
|
if (!o.ok)
|
|
@@ -2204,15 +2509,15 @@ class jr {
|
|
|
2204
2509
|
return `${t}: ${e.status} ${e.statusText}${o ? " — " + o.slice(0, 300) : ""}`;
|
|
2205
2510
|
}
|
|
2206
2511
|
}
|
|
2207
|
-
const pt = "/commands/gis-sources",
|
|
2208
|
-
class
|
|
2512
|
+
const pt = "/commands/gis-sources", Kt = "/data-views/gis-sources";
|
|
2513
|
+
class ta {
|
|
2209
2514
|
constructor(t, e) {
|
|
2210
2515
|
this._auth = t, this._gatewayUrl = e;
|
|
2211
2516
|
}
|
|
2212
2517
|
_auth;
|
|
2213
2518
|
_gatewayUrl;
|
|
2214
2519
|
async listGisSources(t) {
|
|
2215
|
-
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
2520
|
+
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${Kt}`, {
|
|
2216
2521
|
headers: { "x-project-id": t, "cue-project-id": t }
|
|
2217
2522
|
});
|
|
2218
2523
|
if (!e.ok)
|
|
@@ -2220,7 +2525,7 @@ class Lr {
|
|
|
2220
2525
|
return e.json();
|
|
2221
2526
|
}
|
|
2222
2527
|
async getGisSource(t, e) {
|
|
2223
|
-
const o = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
2528
|
+
const o = await this._auth.authenticatedFetch(`${this._gatewayUrl}${Kt}/${e}`, {
|
|
2224
2529
|
headers: { "x-project-id": t, "cue-project-id": t }
|
|
2225
2530
|
});
|
|
2226
2531
|
if (!o.ok)
|
|
@@ -2269,8 +2574,8 @@ class Lr {
|
|
|
2269
2574
|
return `${t}: ${e.status} ${e.statusText}${o ? " — " + o.slice(0, 300) : ""}`;
|
|
2270
2575
|
}
|
|
2271
2576
|
}
|
|
2272
|
-
const
|
|
2273
|
-
class
|
|
2577
|
+
const ea = "/llm-tools/schema-suggestion/from-prose", oa = "/llm-tools/schema-suggestion/catalogs";
|
|
2578
|
+
class sa {
|
|
2274
2579
|
constructor(t, e) {
|
|
2275
2580
|
this._auth = t, this._gatewayUrl = e;
|
|
2276
2581
|
}
|
|
@@ -2286,7 +2591,7 @@ class qr {
|
|
|
2286
2591
|
*/
|
|
2287
2592
|
async fromProse(t) {
|
|
2288
2593
|
const e = await this._auth.authenticatedFetch(
|
|
2289
|
-
`${this._gatewayUrl}${
|
|
2594
|
+
`${this._gatewayUrl}${ea}`,
|
|
2290
2595
|
{
|
|
2291
2596
|
method: "POST",
|
|
2292
2597
|
headers: {
|
|
@@ -2316,7 +2621,7 @@ class qr {
|
|
|
2316
2621
|
*/
|
|
2317
2622
|
async catalogs(t) {
|
|
2318
2623
|
const e = await this._auth.authenticatedFetch(
|
|
2319
|
-
`${this._gatewayUrl}${
|
|
2624
|
+
`${this._gatewayUrl}${oa}`,
|
|
2320
2625
|
{
|
|
2321
2626
|
method: "GET",
|
|
2322
2627
|
headers: { "x-project-id": t, "cue-project-id": t }
|
|
@@ -2331,8 +2636,8 @@ class qr {
|
|
|
2331
2636
|
return `${t}: ${e.status} ${e.statusText}${o ? " — " + o.slice(0, 300) : ""}`;
|
|
2332
2637
|
}
|
|
2333
2638
|
}
|
|
2334
|
-
const
|
|
2335
|
-
class
|
|
2639
|
+
const H = "/commands/semantic-template";
|
|
2640
|
+
class ra {
|
|
2336
2641
|
constructor(t, e) {
|
|
2337
2642
|
this._auth = t, this._gatewayUrl = e;
|
|
2338
2643
|
}
|
|
@@ -2424,6 +2729,14 @@ class Fr {
|
|
|
2424
2729
|
getDefaultEntities(t) {
|
|
2425
2730
|
return this._get(t, "schema/default-entities");
|
|
2426
2731
|
}
|
|
2732
|
+
/**
|
|
2733
|
+
* The QAECY catalogues' content categories — the document types a term can be limited to —
|
|
2734
|
+
* with pinned IRIs stripped, so each is referenced by its bare `key`. The same list for every
|
|
2735
|
+
* caller.
|
|
2736
|
+
*/
|
|
2737
|
+
getDefaultContentCategories(t) {
|
|
2738
|
+
return this._get(t, "schema/default-content-categories");
|
|
2739
|
+
}
|
|
2427
2740
|
// ─── Schema graph reload ─────────────────────────────────────────────────
|
|
2428
2741
|
/** Re-pushes the project's currently stored template into its `databases-cue` schema graph, without mutating it. */
|
|
2429
2742
|
reloadSchema(t) {
|
|
@@ -2432,7 +2745,7 @@ class Fr {
|
|
|
2432
2745
|
// ─── Private helpers ─────────────────────────────────────────────────────
|
|
2433
2746
|
async _get(t, e) {
|
|
2434
2747
|
const o = await this._auth.authenticatedFetch(
|
|
2435
|
-
`${this._gatewayUrl}${
|
|
2748
|
+
`${this._gatewayUrl}${H}/${e}`,
|
|
2436
2749
|
{
|
|
2437
2750
|
method: "GET",
|
|
2438
2751
|
headers: { "x-project-id": t, "cue-project-id": t }
|
|
@@ -2444,7 +2757,7 @@ class Fr {
|
|
|
2444
2757
|
}
|
|
2445
2758
|
async _send(t, e, o, s) {
|
|
2446
2759
|
const a = await this._auth.authenticatedFetch(
|
|
2447
|
-
`${this._gatewayUrl}${
|
|
2760
|
+
`${this._gatewayUrl}${H}/${o}`,
|
|
2448
2761
|
{
|
|
2449
2762
|
method: t,
|
|
2450
2763
|
headers: { "Content-Type": "application/json", "x-project-id": e, "cue-project-id": e },
|
|
@@ -2457,7 +2770,7 @@ class Fr {
|
|
|
2457
2770
|
}
|
|
2458
2771
|
async _post(t, e, o) {
|
|
2459
2772
|
const s = await this._auth.authenticatedFetch(
|
|
2460
|
-
`${this._gatewayUrl}${
|
|
2773
|
+
`${this._gatewayUrl}${H}/${e}`,
|
|
2461
2774
|
{
|
|
2462
2775
|
method: "POST",
|
|
2463
2776
|
headers: { "Content-Type": "application/json", "x-project-id": t, "cue-project-id": t },
|
|
@@ -2470,7 +2783,7 @@ class Fr {
|
|
|
2470
2783
|
}
|
|
2471
2784
|
async _delete(t, e, o) {
|
|
2472
2785
|
const s = await this._auth.authenticatedFetch(
|
|
2473
|
-
`${this._gatewayUrl}${
|
|
2786
|
+
`${this._gatewayUrl}${H}/${e}`,
|
|
2474
2787
|
{
|
|
2475
2788
|
method: "DELETE",
|
|
2476
2789
|
headers: { "Content-Type": "application/json", "x-project-id": t, "cue-project-id": t },
|
|
@@ -2486,9 +2799,9 @@ class Fr {
|
|
|
2486
2799
|
return `${t}: ${e.status} ${e.statusText}${o ? " — " + o.slice(0, 300) : ""}`;
|
|
2487
2800
|
}
|
|
2488
2801
|
}
|
|
2489
|
-
class
|
|
2802
|
+
class Zt {
|
|
2490
2803
|
constructor(t, e, o, s, a) {
|
|
2491
|
-
this._auth = t, this._gatewayUrl = e, this.projects = o, this.sync = s, this.tables = new
|
|
2804
|
+
this._auth = t, this._gatewayUrl = e, this.projects = o, this.sync = s, this.tables = new _r(t, e), this.extraction = new Tr(t, e), this.contexts = new Sr(t, e), this.index = new Cr(t, e), this.mcp = new $r(t, e), this.appData = new Nr(t, e), this.apps = new jr(t, e), this.userSettings = new Lr(t, e), this.processing = new Ur(t, e), this.dms = new Mr(t, e), this.llmTools = new Qr(t, e), this.dataSources = new Zr(t, e, a), this.gisSources = new ta(t, e), this.semanticTemplate = new ra(t, e), this.schemaSuggestion = new sa(t, e);
|
|
2492
2805
|
}
|
|
2493
2806
|
_auth;
|
|
2494
2807
|
_gatewayUrl;
|
|
@@ -2550,7 +2863,7 @@ class re {
|
|
|
2550
2863
|
*/
|
|
2551
2864
|
async search(t) {
|
|
2552
2865
|
const e = await this._auth.authenticatedFetch(
|
|
2553
|
-
`${this._gatewayUrl}${
|
|
2866
|
+
`${this._gatewayUrl}${Js}`,
|
|
2554
2867
|
{
|
|
2555
2868
|
method: "POST",
|
|
2556
2869
|
headers: { "Content-Type": "application/json", "cue-project-id": t.projectId },
|
|
@@ -2585,7 +2898,7 @@ class re {
|
|
|
2585
2898
|
* n-triples).
|
|
2586
2899
|
*/
|
|
2587
2900
|
async sparql(t, e, o, s) {
|
|
2588
|
-
const a =
|
|
2901
|
+
const a = Pe, i = new URLSearchParams();
|
|
2589
2902
|
i.append("query", t);
|
|
2590
2903
|
const n = await this._auth.authenticatedFetch(
|
|
2591
2904
|
`${this._gatewayUrl}${a}`,
|
|
@@ -2628,7 +2941,7 @@ class re {
|
|
|
2628
2941
|
* Returns a {@link ShaclValidationReport} for JSON-LD, or a Turtle string.
|
|
2629
2942
|
*/
|
|
2630
2943
|
async shacl(t, e, o) {
|
|
2631
|
-
const s = o?.format ?? "json-ld", a = s === "turtle" ? "text/turtle" : "application/ld+json", i = `${this._gatewayUrl}${
|
|
2944
|
+
const s = o?.format ?? "json-ld", a = s === "turtle" ? "text/turtle" : "application/ld+json", i = `${this._gatewayUrl}${or}${o?.verbose ? "?verbose=true" : ""}`, n = new URLSearchParams({ shape: t }), c = await this._auth.authenticatedFetch(i, {
|
|
2632
2945
|
method: "POST",
|
|
2633
2946
|
headers: {
|
|
2634
2947
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
@@ -2656,7 +2969,7 @@ class re {
|
|
|
2656
2969
|
}
|
|
2657
2970
|
async getConsumption(t) {
|
|
2658
2971
|
const e = await this._auth.authenticatedFetch(
|
|
2659
|
-
`${this._gatewayUrl}${
|
|
2972
|
+
`${this._gatewayUrl}${Yo}`,
|
|
2660
2973
|
{
|
|
2661
2974
|
headers: {
|
|
2662
2975
|
"Content-Type": "application/json",
|
|
@@ -2685,7 +2998,7 @@ class re {
|
|
|
2685
2998
|
const a = new FormData();
|
|
2686
2999
|
a.append("location", s.location), a.append("suffix", s.suffix), s.fileContentClasses && a.append("fileContentClasses", JSON.stringify(s.fileContentClasses)), s.processorId && a.append("processorId", s.processorId), s.comment && a.append("comment", s.comment), a.append("file", o, `alt-rep${s.suffix}`);
|
|
2687
3000
|
const i = await this._auth.authenticatedFetch(
|
|
2688
|
-
`${this._gatewayUrl}${
|
|
3001
|
+
`${this._gatewayUrl}${nr(e)}`,
|
|
2689
3002
|
{
|
|
2690
3003
|
method: "POST",
|
|
2691
3004
|
// Do NOT set Content-Type; the runtime sets it with the correct multipart boundary.
|
|
@@ -2702,7 +3015,7 @@ class re {
|
|
|
2702
3015
|
return i.json();
|
|
2703
3016
|
}
|
|
2704
3017
|
}
|
|
2705
|
-
const
|
|
3018
|
+
const yt = [
|
|
2706
3019
|
"building",
|
|
2707
3020
|
"cadastre",
|
|
2708
3021
|
"zone",
|
|
@@ -2714,13 +3027,13 @@ const bt = [
|
|
|
2714
3027
|
"natural",
|
|
2715
3028
|
"manmade",
|
|
2716
3029
|
"custom"
|
|
2717
|
-
],
|
|
3030
|
+
], bt = [
|
|
2718
3031
|
"address",
|
|
2719
3032
|
"poi",
|
|
2720
3033
|
"railway",
|
|
2721
3034
|
"natural",
|
|
2722
3035
|
"manmade"
|
|
2723
|
-
],
|
|
3036
|
+
], aa = {
|
|
2724
3037
|
address: {
|
|
2725
3038
|
category: "address",
|
|
2726
3039
|
label: "Address",
|
|
@@ -2788,10 +3101,10 @@ const bt = [
|
|
|
2788
3101
|
preferredColor: "#0d9488"
|
|
2789
3102
|
}
|
|
2790
3103
|
};
|
|
2791
|
-
function
|
|
2792
|
-
return
|
|
3104
|
+
function C(r) {
|
|
3105
|
+
return aa[r];
|
|
2793
3106
|
}
|
|
2794
|
-
const
|
|
3107
|
+
const ia = {
|
|
2795
3108
|
"land-use-plan": "#f59e0b",
|
|
2796
3109
|
// amber – primary zoning
|
|
2797
3110
|
"local-plan": "#ec4899",
|
|
@@ -2819,10 +3132,10 @@ const Br = {
|
|
|
2819
3132
|
"nature-landscape-plan": "#16a34a"
|
|
2820
3133
|
// dark-green – Natur- und Landschaftsschutz
|
|
2821
3134
|
};
|
|
2822
|
-
function
|
|
3135
|
+
function P(r, t) {
|
|
2823
3136
|
return r[0] < t[2] && r[2] > t[0] && r[1] < t[3] && r[3] > t[1];
|
|
2824
3137
|
}
|
|
2825
|
-
const
|
|
3138
|
+
const na = "https://nominatim.openstreetmap.org", ca = "cue-gis/0.0.1", pa = {
|
|
2826
3139
|
address: "street",
|
|
2827
3140
|
poi: "shop",
|
|
2828
3141
|
railway: "station",
|
|
@@ -2836,62 +3149,62 @@ const Gr = "https://nominatim.openstreetmap.org", Hr = "cue-gis/0.0.1", Wr = {
|
|
|
2836
3149
|
// Never actually probed — 'custom' (user-uploaded GIS sources) isn't in
|
|
2837
3150
|
// NOMINATIM_FEATURE_CATEGORIES, so this entry only exists to satisfy the Record type.
|
|
2838
3151
|
custom: "place"
|
|
2839
|
-
},
|
|
2840
|
-
function
|
|
2841
|
-
return `${
|
|
3152
|
+
}, M = "nominatim";
|
|
3153
|
+
function X(r) {
|
|
3154
|
+
return `${M}:${r}`;
|
|
2842
3155
|
}
|
|
2843
|
-
function
|
|
2844
|
-
const t =
|
|
3156
|
+
function la(r) {
|
|
3157
|
+
const t = C(r);
|
|
2845
3158
|
return {
|
|
2846
|
-
id:
|
|
2847
|
-
sourceId:
|
|
3159
|
+
id: X(r),
|
|
3160
|
+
sourceId: M,
|
|
2848
3161
|
sourceLayerId: r,
|
|
2849
3162
|
category: r,
|
|
2850
3163
|
preferredColor: t.preferredColor,
|
|
2851
3164
|
tier: "raw",
|
|
2852
3165
|
label: t.label,
|
|
2853
3166
|
description: `Nominatim ${r} layer`,
|
|
2854
|
-
labelKey: `gis.layer.${
|
|
2855
|
-
descriptionKey: `gis.layer.${
|
|
3167
|
+
labelKey: `gis.layer.${M}.${r}.label`,
|
|
3168
|
+
descriptionKey: `gis.layer.${M}.${r}.description`
|
|
2856
3169
|
};
|
|
2857
3170
|
}
|
|
2858
|
-
class
|
|
3171
|
+
class ha {
|
|
2859
3172
|
baseUrl;
|
|
2860
3173
|
userAgent;
|
|
2861
3174
|
email;
|
|
2862
3175
|
limit;
|
|
2863
3176
|
constructor(t = {}) {
|
|
2864
|
-
this.baseUrl = t.baseUrl ??
|
|
3177
|
+
this.baseUrl = t.baseUrl ?? na, this.userAgent = t.userAgent ?? ca, this.email = t.email, this.limit = Math.min(t.limit ?? 40, 40);
|
|
2865
3178
|
}
|
|
2866
3179
|
async listFeatureCategoryDescriptors(t) {
|
|
2867
3180
|
return (await Promise.allSettled(
|
|
2868
|
-
|
|
3181
|
+
bt.map(async (o) => {
|
|
2869
3182
|
const s = await this.search(t, o);
|
|
2870
3183
|
return { category: o, hasResults: s.length > 0 };
|
|
2871
3184
|
})
|
|
2872
3185
|
)).filter(
|
|
2873
3186
|
(o) => o.status === "fulfilled" && o.value.hasResults
|
|
2874
|
-
).map((o) =>
|
|
3187
|
+
).map((o) => C(o.value.category));
|
|
2875
3188
|
}
|
|
2876
3189
|
async listAvailableLayers(t) {
|
|
2877
|
-
return (await this.listFeatureCategoryDescriptors(t)).map((o) =>
|
|
3190
|
+
return (await this.listFeatureCategoryDescriptors(t)).map((o) => la(o.category));
|
|
2878
3191
|
}
|
|
2879
3192
|
async getFeaturesForLayer(t, e) {
|
|
2880
|
-
const o =
|
|
3193
|
+
const o = yt.find((s) => X(s) === e);
|
|
2881
3194
|
return o ? this.search(t, o) : [];
|
|
2882
3195
|
}
|
|
2883
3196
|
async listFeatureCategories(t) {
|
|
2884
3197
|
return (await this.listFeatureCategoryDescriptors(t)).map((o) => o.category);
|
|
2885
3198
|
}
|
|
2886
3199
|
async getFeaturesOfCategory(t, e) {
|
|
2887
|
-
return this.getFeaturesForLayer(t,
|
|
3200
|
+
return this.getFeaturesForLayer(t, X(e));
|
|
2888
3201
|
}
|
|
2889
3202
|
/**
|
|
2890
3203
|
* Low-level search against the Nominatim API. Uses a per-layer probe query
|
|
2891
3204
|
* so bounded viewbox searches return meaningful results.
|
|
2892
3205
|
*/
|
|
2893
3206
|
async search(t, e) {
|
|
2894
|
-
const [o, s, a, i] = t, n = e ?
|
|
3207
|
+
const [o, s, a, i] = t, n = e ? pa[e] : "place", c = new URLSearchParams({
|
|
2895
3208
|
q: n,
|
|
2896
3209
|
format: "jsonv2",
|
|
2897
3210
|
viewbox: `${o},${i},${a},${s}`,
|
|
@@ -2901,7 +3214,7 @@ class Xr {
|
|
|
2901
3214
|
extratags: "1",
|
|
2902
3215
|
dedupe: "1"
|
|
2903
3216
|
});
|
|
2904
|
-
e &&
|
|
3217
|
+
e && bt.includes(e) && c.set("layer", e), this.email && c.set("email", this.email);
|
|
2905
3218
|
const p = `${this.baseUrl}/search?${c.toString()}`, h = await fetch(p, {
|
|
2906
3219
|
headers: {
|
|
2907
3220
|
"User-Agent": this.userAgent,
|
|
@@ -2915,12 +3228,12 @@ class Xr {
|
|
|
2915
3228
|
return (await h.json()).map((u) => this.toGisFeature(u, e));
|
|
2916
3229
|
}
|
|
2917
3230
|
toGisFeature(t, e) {
|
|
2918
|
-
const [o, s, a, i] = t.boundingbox, n = e ?? t.category, c =
|
|
3231
|
+
const [o, s, a, i] = t.boundingbox, n = e ?? t.category, c = C(n);
|
|
2919
3232
|
return {
|
|
2920
3233
|
id: `${t.osm_type}/${t.osm_id}`,
|
|
2921
|
-
sourceId:
|
|
3234
|
+
sourceId: M,
|
|
2922
3235
|
sourceFeatureId: `${t.osm_type}/${t.osm_id}`,
|
|
2923
|
-
layerId:
|
|
3236
|
+
layerId: X(n),
|
|
2924
3237
|
name: t.name ?? t.display_name.split(",")[0].trim(),
|
|
2925
3238
|
category: n,
|
|
2926
3239
|
preferredColor: c.preferredColor,
|
|
@@ -2934,7 +3247,7 @@ class Xr {
|
|
|
2934
3247
|
};
|
|
2935
3248
|
}
|
|
2936
3249
|
}
|
|
2937
|
-
const
|
|
3250
|
+
const te = {
|
|
2938
3251
|
// 100s – Residential
|
|
2939
3252
|
110: "residential",
|
|
2940
3253
|
120: "residential",
|
|
@@ -3013,7 +3326,7 @@ const ae = {
|
|
|
3013
3326
|
960: "agricultural",
|
|
3014
3327
|
970: "agricultural",
|
|
3015
3328
|
990: "other"
|
|
3016
|
-
},
|
|
3329
|
+
}, ee = {
|
|
3017
3330
|
1010: "residential",
|
|
3018
3331
|
1020: "mixed",
|
|
3019
3332
|
1030: "residential",
|
|
@@ -3043,7 +3356,7 @@ const ae = {
|
|
|
3043
3356
|
1281: "infrastructure",
|
|
3044
3357
|
1282: "infrastructure",
|
|
3045
3358
|
9999: "other"
|
|
3046
|
-
},
|
|
3359
|
+
}, da = {
|
|
3047
3360
|
// Residential
|
|
3048
3361
|
1110: "residential",
|
|
3049
3362
|
// Einfamilienhaus
|
|
@@ -3105,7 +3418,7 @@ const ae = {
|
|
|
3105
3418
|
// Empfangsgebäude Bahn/Bus
|
|
3106
3419
|
1282: "infrastructure"
|
|
3107
3420
|
// Parkhaus, Garage
|
|
3108
|
-
},
|
|
3421
|
+
}, ua = [
|
|
3109
3422
|
// "Gebäude" is the Swiss AV BoFlaeche land-cover label for a building footprint.
|
|
3110
3423
|
// It does not encode the actual use type, so map it to 'other' as a safe fallback.
|
|
3111
3424
|
[/^geb[äa]ude$/i, "other"],
|
|
@@ -3118,23 +3431,23 @@ const ae = {
|
|
|
3118
3431
|
[/infrastruktur|verkehr|transport|energy|energie|forsyning|teknik|teknisk/i, "infrastructure"],
|
|
3119
3432
|
[/gemischt|mixed|blandet/i, "mixed"]
|
|
3120
3433
|
];
|
|
3121
|
-
function
|
|
3122
|
-
for (const [t, e] of
|
|
3434
|
+
function U(r) {
|
|
3435
|
+
for (const [t, e] of ua)
|
|
3123
3436
|
if (t.test(r)) return e;
|
|
3124
3437
|
}
|
|
3125
|
-
function
|
|
3438
|
+
function ga(r, t) {
|
|
3126
3439
|
if (r == null) return;
|
|
3127
3440
|
const e = String(r).trim();
|
|
3128
|
-
return t === "swiss-gwr" ?
|
|
3441
|
+
return t === "swiss-gwr" ? da[e] ?? U(e) : t === "danish-matrikel" ? te[e] ?? U(e) : t === "zurich-wfs" || t === "swiss-av-wfs" ? ee[e] ?? U(e) : ee[e] ?? te[e] ?? U(e);
|
|
3129
3442
|
}
|
|
3130
|
-
function
|
|
3443
|
+
function ma(r, t) {
|
|
3131
3444
|
if (r != null)
|
|
3132
|
-
return
|
|
3445
|
+
return U(String(r).trim());
|
|
3133
3446
|
}
|
|
3134
|
-
function
|
|
3447
|
+
function je(r) {
|
|
3135
3448
|
return r.trim().toLowerCase().replace(/[\s_\-]/g, "");
|
|
3136
3449
|
}
|
|
3137
|
-
const
|
|
3450
|
+
const wa = {
|
|
3138
3451
|
// Swiss ÖREB rechtsstatus
|
|
3139
3452
|
inkraft: "in-force",
|
|
3140
3453
|
laufendeanderung: "amendment-pending",
|
|
@@ -3153,11 +3466,11 @@ const Zr = {
|
|
|
3153
3466
|
forslag: "proposed",
|
|
3154
3467
|
aflyst: "repealed"
|
|
3155
3468
|
};
|
|
3156
|
-
function
|
|
3469
|
+
function Le(r) {
|
|
3157
3470
|
if (r)
|
|
3158
|
-
return
|
|
3471
|
+
return wa[je(r)];
|
|
3159
3472
|
}
|
|
3160
|
-
const
|
|
3473
|
+
const oe = {
|
|
3161
3474
|
// Swiss Nutzungsplanung (typ_gde_bezeichnung and common variants)
|
|
3162
3475
|
grundnutzungszonenplan: "land-use-plan",
|
|
3163
3476
|
nutzungszonenplan: "land-use-plan",
|
|
@@ -3211,7 +3524,7 @@ const ne = {
|
|
|
3211
3524
|
// Danish plandata.dk
|
|
3212
3525
|
lokalplan: "local-plan",
|
|
3213
3526
|
kommuneplanramme: "municipal-plan-framework"
|
|
3214
|
-
},
|
|
3527
|
+
}, fa = [
|
|
3215
3528
|
[/quartiererhalt/i, "neighbourhood-conservation-plan"],
|
|
3216
3529
|
[/lärmempfindlich|laermempfindlich/i, "noise-sensitivity-plan"],
|
|
3217
3530
|
[/gewässerschutz|grundwasserschutz/i, "water-protection-plan"],
|
|
@@ -3251,17 +3564,17 @@ const ne = {
|
|
|
3251
3564
|
// Catch-all: any remaining Xzone / Xareal designation from the Grundnutzungszonenplan
|
|
3252
3565
|
[/zone$|areal$/i, "land-use-plan"]
|
|
3253
3566
|
];
|
|
3254
|
-
function
|
|
3567
|
+
function Ue(r) {
|
|
3255
3568
|
if (!r) return;
|
|
3256
|
-
const t =
|
|
3257
|
-
if (t in
|
|
3258
|
-
for (const [e, o] of
|
|
3569
|
+
const t = je(r);
|
|
3570
|
+
if (t in oe) return oe[t];
|
|
3571
|
+
for (const [e, o] of fa)
|
|
3259
3572
|
if (e.test(r)) return o;
|
|
3260
3573
|
console.warn(
|
|
3261
3574
|
`[cue-gis] Unknown zone plan type — add "${r}" to classifyZonePlanType: no ZonePlanType mapping found.`
|
|
3262
3575
|
);
|
|
3263
3576
|
}
|
|
3264
|
-
function
|
|
3577
|
+
function Z(r, t) {
|
|
3265
3578
|
const e = (t * 3600 - 169028.66) / 1e4, o = (r * 3600 - 26782.5) / 1e4, s = 260007237e-2 + 211455.93 * o - 10938.51 * o * e - 0.36 * o * e ** 2 - 44.54 * o ** 3, a = 120014707e-2 + 308807.95 * e + 3745.25 * o ** 2 + 76.63 * e ** 2 - 194.56 * o ** 2 * e + 119.79 * e ** 3;
|
|
3266
3579
|
return [Math.round(s), Math.round(a)];
|
|
3267
3580
|
}
|
|
@@ -3269,14 +3582,14 @@ function vt(r, t) {
|
|
|
3269
3582
|
const e = (r - 26e5) / 1e6, o = (t - 12e5) / 1e6, s = 2.6779094 + 4.728982 * e + 0.791484 * e * o + 0.1306 * e * o ** 2 - 0.0436 * e ** 3, a = 16.9023892 + 3.238272 * o - 0.270978 * e ** 2 - 2528e-6 * o ** 2 - 0.0447 * e ** 2 * o - 0.014 * o ** 3;
|
|
3270
3583
|
return [s * 100 / 36, a * 100 / 36];
|
|
3271
3584
|
}
|
|
3272
|
-
const
|
|
3585
|
+
const ya = "https://maps.zh.ch/wfs/OGDZHWFS", ba = "zurich-wfs", va = "geometry", _a = [8.35, 47.15, 8.95, 47.7], Ea = [5.9, 45.7, 10.55, 47.85];
|
|
3273
3586
|
function lt(r) {
|
|
3274
3587
|
return typeof r == "string" ? r : r.typeName;
|
|
3275
3588
|
}
|
|
3276
3589
|
function ht(r) {
|
|
3277
3590
|
return typeof r == "string" ? void 0 : r.cqlFilter;
|
|
3278
3591
|
}
|
|
3279
|
-
function
|
|
3592
|
+
function Ta(r) {
|
|
3280
3593
|
if (!r) return [0, 0];
|
|
3281
3594
|
const t = r.coordinates;
|
|
3282
3595
|
switch (r.type) {
|
|
@@ -3294,26 +3607,26 @@ function ia(r) {
|
|
|
3294
3607
|
return [0, 0];
|
|
3295
3608
|
}
|
|
3296
3609
|
}
|
|
3297
|
-
function
|
|
3298
|
-
return Array.isArray(r) && typeof r[0] == "number" ? t(r[0], r[1]) : r.map((e) =>
|
|
3610
|
+
function Me(r, t) {
|
|
3611
|
+
return Array.isArray(r) && typeof r[0] == "number" ? t(r[0], r[1]) : r.map((e) => Me(e, t));
|
|
3299
3612
|
}
|
|
3300
|
-
function
|
|
3301
|
-
return r && { ...r, coordinates:
|
|
3613
|
+
function Sa(r) {
|
|
3614
|
+
return r && { ...r, coordinates: Me(r.coordinates, vt) };
|
|
3302
3615
|
}
|
|
3303
|
-
function
|
|
3616
|
+
function Ia(r, t) {
|
|
3304
3617
|
if (!r) return t;
|
|
3305
3618
|
for (const e of ["plannavn", "bezeichnung", "name", "strassenname", "objektname", "title", "label"])
|
|
3306
3619
|
if (typeof r[e] == "string" && r[e]) return r[e];
|
|
3307
3620
|
return t;
|
|
3308
3621
|
}
|
|
3309
|
-
function
|
|
3622
|
+
function Ca(r, t, e) {
|
|
3310
3623
|
return e ? `${r}:${t}[${e}]` : `${r}:${t}`;
|
|
3311
3624
|
}
|
|
3312
|
-
const
|
|
3625
|
+
const xa = /* @__PURE__ */ new Set(["building", "cadastre", "greenspace", "paved", "zone"]);
|
|
3313
3626
|
function dt(r, t, e, o) {
|
|
3314
|
-
const s = e.replace(/^ms:/, ""), a =
|
|
3627
|
+
const s = e.replace(/^ms:/, ""), a = C(t), i = xa.has(t) ? "priority" : "raw";
|
|
3315
3628
|
return {
|
|
3316
|
-
id:
|
|
3629
|
+
id: Ca(r, e, o),
|
|
3317
3630
|
sourceId: r,
|
|
3318
3631
|
sourceLayerId: e,
|
|
3319
3632
|
category: t,
|
|
@@ -3325,32 +3638,32 @@ function dt(r, t, e, o) {
|
|
|
3325
3638
|
descriptionKey: `gis.layer.${r}.${s}.description`
|
|
3326
3639
|
};
|
|
3327
3640
|
}
|
|
3328
|
-
function
|
|
3641
|
+
function ka(r, t) {
|
|
3329
3642
|
if (!r) return { featureType: "building" };
|
|
3330
3643
|
const e = r.grundflaeche ?? r.gbf ?? r.gebaeudegrundrissflaeche ?? r.flaeche ?? void 0, o = r.vollgeschosse ?? r.geschossanzahl ?? r.anzahl_geschosse ?? void 0, s = r.gebaeudefunktion ?? r.gfkode ?? r.art ?? r.objektart ?? void 0, a = r.baujahr ?? r.bauperiode ?? void 0, i = String(r.egid ?? r.gwr_egid ?? r.egris_egid ?? "").trim() || void 0;
|
|
3331
3644
|
return {
|
|
3332
3645
|
featureType: "building",
|
|
3333
3646
|
areaM2: typeof e == "number" ? e : void 0,
|
|
3334
3647
|
buildingUse: s ? String(s) : void 0,
|
|
3335
|
-
buildingUseGeneric:
|
|
3648
|
+
buildingUseGeneric: ga(s, t),
|
|
3336
3649
|
floors: typeof o == "number" ? o : void 0,
|
|
3337
3650
|
yearBuilt: typeof a == "number" ? a : void 0,
|
|
3338
3651
|
registryId: i
|
|
3339
3652
|
};
|
|
3340
3653
|
}
|
|
3341
|
-
function
|
|
3654
|
+
function Oa(r, t) {
|
|
3342
3655
|
if (!r) return { featureType: "plot" };
|
|
3343
3656
|
const e = r.egris_egrid ?? r.egrid ?? void 0, o = r.nummer ?? void 0, s = r.nbident ?? void 0, a = o && s ? `${o}, ${s}` : o ?? void 0, i = r.flaechenmass ?? r.flaeche ?? void 0, n = r.art ?? r.nutzungsart ?? void 0;
|
|
3344
3657
|
return {
|
|
3345
3658
|
featureType: "plot",
|
|
3346
3659
|
areaM2: typeof i == "number" ? i : void 0,
|
|
3347
3660
|
plotUse: n ? String(n) : void 0,
|
|
3348
|
-
plotUseGeneric:
|
|
3661
|
+
plotUseGeneric: ma(n),
|
|
3349
3662
|
plotId: a,
|
|
3350
3663
|
registryId: e
|
|
3351
3664
|
};
|
|
3352
3665
|
}
|
|
3353
|
-
function
|
|
3666
|
+
function Ra(r) {
|
|
3354
3667
|
if (!r) return { featureType: "greenspace" };
|
|
3355
3668
|
const t = r.flaeche ?? void 0, e = r.art ?? void 0;
|
|
3356
3669
|
return {
|
|
@@ -3359,7 +3672,7 @@ function ua(r) {
|
|
|
3359
3672
|
surfaceType: e ? String(e) : void 0
|
|
3360
3673
|
};
|
|
3361
3674
|
}
|
|
3362
|
-
function
|
|
3675
|
+
function Aa(r) {
|
|
3363
3676
|
if (!r) return { featureType: "paved" };
|
|
3364
3677
|
const t = r.flaeche ?? void 0, e = r.art ?? void 0;
|
|
3365
3678
|
return {
|
|
@@ -3368,9 +3681,9 @@ function ga(r) {
|
|
|
3368
3681
|
surfaceType: e ? String(e) : void 0
|
|
3369
3682
|
};
|
|
3370
3683
|
}
|
|
3371
|
-
function
|
|
3684
|
+
function $a(r) {
|
|
3372
3685
|
if (!r) return { featureType: "zone" };
|
|
3373
|
-
const t = r.plannavn ?? r.bezeichnung ?? r.typ_bezeichnung ?? r.art ?? void 0, e = r.planid ?? r.plannummer ?? void 0, o = r.artcode ?? r.typ_code ?? r.abkuerzung ?? e ?? void 0, s = r.rechtsstatus ?? r.status ?? void 0, a =
|
|
3686
|
+
const t = r.plannavn ?? r.bezeichnung ?? r.typ_bezeichnung ?? r.art ?? void 0, e = r.planid ?? r.plannummer ?? void 0, o = r.artcode ?? r.typ_code ?? r.abkuerzung ?? e ?? void 0, s = r.rechtsstatus ?? r.status ?? void 0, a = Le(s), i = r.typ_gde_bezeichnung ?? void 0, n = Ue(i), c = r.dagsordenpunkt_url ?? r.dokument_url ?? r.link ?? void 0, p = r.auflagedatum ?? void 0, h = r.festsetzungsdatum ?? void 0, d = r.genehmigungsdatum ?? void 0, u = r.inkraftsetzungsdatum ?? void 0, m = r.flaeche ?? r.flaeche_m2 ?? void 0;
|
|
3374
3687
|
return {
|
|
3375
3688
|
featureType: "zone",
|
|
3376
3689
|
zoneType: t ? String(t) : void 0,
|
|
@@ -3386,7 +3699,7 @@ function ma(r) {
|
|
|
3386
3699
|
areaM2: typeof m == "number" ? m : void 0
|
|
3387
3700
|
};
|
|
3388
3701
|
}
|
|
3389
|
-
function
|
|
3702
|
+
function Pa(r) {
|
|
3390
3703
|
const t = r.match(/^(\w+)\s*=\s*'([^']+)'$/);
|
|
3391
3704
|
if (t) {
|
|
3392
3705
|
const [, o, s] = t;
|
|
@@ -3401,35 +3714,35 @@ function wa(r) {
|
|
|
3401
3714
|
}
|
|
3402
3715
|
return () => !0;
|
|
3403
3716
|
}
|
|
3404
|
-
function
|
|
3717
|
+
function Da(r) {
|
|
3405
3718
|
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
3406
3719
|
}
|
|
3407
|
-
function
|
|
3408
|
-
return `<fes:PropertyIsEqualTo><fes:ValueReference>${r}</fes:ValueReference><fes:Literal>${
|
|
3720
|
+
function se(r, t) {
|
|
3721
|
+
return `<fes:PropertyIsEqualTo><fes:ValueReference>${r}</fes:ValueReference><fes:Literal>${Da(t)}</fes:Literal></fes:PropertyIsEqualTo>`;
|
|
3409
3722
|
}
|
|
3410
|
-
function
|
|
3723
|
+
function Na(r) {
|
|
3411
3724
|
const t = r.match(/^(\w+)\s*=\s*'([^']+)'$/);
|
|
3412
3725
|
if (t) {
|
|
3413
3726
|
const [, o, s] = t;
|
|
3414
|
-
return
|
|
3727
|
+
return se(o, s);
|
|
3415
3728
|
}
|
|
3416
3729
|
const e = r.match(/^(\w+)\s+IN\s*\(([^)]+)\)$/i);
|
|
3417
3730
|
if (e) {
|
|
3418
3731
|
const [, o, s] = e;
|
|
3419
|
-
return `<fes:Or>${s.split(",").map((i) => i.trim().replace(/^'|'$/g, "")).map((i) =>
|
|
3732
|
+
return `<fes:Or>${s.split(",").map((i) => i.trim().replace(/^'|'$/g, "")).map((i) => se(o, i)).join("")}</fes:Or>`;
|
|
3420
3733
|
}
|
|
3421
3734
|
throw new Error(`Unsupported CQL filter pattern for FES translation: ${r}`);
|
|
3422
3735
|
}
|
|
3423
|
-
function
|
|
3736
|
+
function ja(r, t) {
|
|
3424
3737
|
const [e, o, s, a] = r, [i, n, c] = t === "EPSG:2056" ? (() => {
|
|
3425
|
-
const [p, h] =
|
|
3738
|
+
const [p, h] = Z(e, o), [d, u] = Z(s, a);
|
|
3426
3739
|
return ["urn:ogc:def:crs:EPSG::2056", `${p} ${h}`, `${d} ${u}`];
|
|
3427
3740
|
})() : ["urn:ogc:def:crs:EPSG::4326", `${o} ${e}`, `${a} ${s}`];
|
|
3428
|
-
return `<fes:BBOX><fes:ValueReference>${
|
|
3741
|
+
return `<fes:BBOX><fes:ValueReference>${va}</fes:ValueReference><gml:Envelope srsName="${i}"><gml:lowerCorner>${n}</gml:lowerCorner><gml:upperCorner>${c}</gml:upperCorner></gml:Envelope></fes:BBOX>`;
|
|
3429
3742
|
}
|
|
3430
|
-
function
|
|
3431
|
-
const o =
|
|
3432
|
-
return `<fes:Filter xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:gml="http://www.opengis.net/gml/3.2">${e ? `<fes:And>${
|
|
3743
|
+
function La(r, t, e) {
|
|
3744
|
+
const o = ja(r, t);
|
|
3745
|
+
return `<fes:Filter xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:gml="http://www.opengis.net/gml/3.2">${e ? `<fes:And>${Na(e)}${o}</fes:And>` : o}</fes:Filter>`;
|
|
3433
3746
|
}
|
|
3434
3747
|
class ut {
|
|
3435
3748
|
categoryMap;
|
|
@@ -3438,11 +3751,11 @@ class ut {
|
|
|
3438
3751
|
outputFormat;
|
|
3439
3752
|
nativeCrs;
|
|
3440
3753
|
constructor(t) {
|
|
3441
|
-
this.categoryMap = t.categoryMap, this.baseUrl = t.baseUrl ??
|
|
3754
|
+
this.categoryMap = t.categoryMap, this.baseUrl = t.baseUrl ?? ya, this.sourceId = t.sourceId ?? ba, this.outputFormat = t.outputFormat ?? "application/json; subtype=geojson", this.nativeCrs = t.nativeCrs;
|
|
3442
3755
|
}
|
|
3443
3756
|
async listFeatureCategoryDescriptors(t) {
|
|
3444
3757
|
const e = await this.listAvailableLayers(t);
|
|
3445
|
-
return [...new Map(e.map((o) => [o.category,
|
|
3758
|
+
return [...new Map(e.map((o) => [o.category, C(o.category)])).values()];
|
|
3446
3759
|
}
|
|
3447
3760
|
async listAvailableLayers(t) {
|
|
3448
3761
|
const e = Object.entries(this.categoryMap);
|
|
@@ -3462,7 +3775,7 @@ class ut {
|
|
|
3462
3775
|
return o ? this._fetchAndConvert(t, o.descriptor, o.cqlFilter) : [];
|
|
3463
3776
|
}
|
|
3464
3777
|
async _fetchAndConvert(t, e, o) {
|
|
3465
|
-
const s = await this._fetchFeatures(t, e.sourceLayerId, void 0, o), a = o ?
|
|
3778
|
+
const s = await this._fetchFeatures(t, e.sourceLayerId, void 0, o), a = o ? Pa(o) : void 0;
|
|
3466
3779
|
return (a ? s.features.filter((n) => a(n.properties)) : s.features).map((n, c) => this.toGisFeature(n, e, c));
|
|
3467
3780
|
}
|
|
3468
3781
|
/**
|
|
@@ -3502,10 +3815,10 @@ class ut {
|
|
|
3502
3815
|
outputFormat: this.outputFormat
|
|
3503
3816
|
});
|
|
3504
3817
|
if (o !== void 0 && a.set("count", String(o)), s !== void 0)
|
|
3505
|
-
a.set("filter",
|
|
3818
|
+
a.set("filter", La(t, this.nativeCrs, s));
|
|
3506
3819
|
else {
|
|
3507
3820
|
const [c, p, h, d] = t, u = this.nativeCrs === "EPSG:2056" ? (() => {
|
|
3508
|
-
const [m, w] =
|
|
3821
|
+
const [m, w] = Z(c, p), [f, y] = Z(h, d);
|
|
3509
3822
|
return `${m},${w},${f},${y},urn:ogc:def:crs:EPSG::2056`;
|
|
3510
3823
|
})() : `${p},${c},${d},${h},urn:ogc:def:crs:EPSG::4326`;
|
|
3511
3824
|
a.set("bbox", u);
|
|
@@ -3518,7 +3831,7 @@ class ut {
|
|
|
3518
3831
|
return n.json();
|
|
3519
3832
|
}
|
|
3520
3833
|
toGisFeature(t, e, o) {
|
|
3521
|
-
const s = this.nativeCrs === "EPSG:2056" ?
|
|
3834
|
+
const s = this.nativeCrs === "EPSG:2056" ? Sa(t.geometry) : t.geometry, [a, i] = Ta(s), n = Ia(t.properties, `${e.sourceLayerId}[${o}]`), c = t.bbox ? this.nativeCrs === "EPSG:2056" ? [...vt(t.bbox[0], t.bbox[1]), ...vt(t.bbox[2], t.bbox[3])] : [t.bbox[0], t.bbox[1], t.bbox[2], t.bbox[3]] : void 0, p = e.tier, h = p === "priority" ? this._extractNormalisedProperties(t, e) : void 0;
|
|
3522
3835
|
return {
|
|
3523
3836
|
id: t.id ?? `${e.sourceLayerId}/${o}`,
|
|
3524
3837
|
preferredColor: e.preferredColor,
|
|
@@ -3539,10 +3852,10 @@ class ut {
|
|
|
3539
3852
|
};
|
|
3540
3853
|
}
|
|
3541
3854
|
_extractNormalisedProperties(t, e) {
|
|
3542
|
-
return e.category === "building" ?
|
|
3855
|
+
return e.category === "building" ? ka(t.properties, this.sourceId) : e.category === "greenspace" ? Ra(t.properties) : e.category === "paved" ? Aa(t.properties) : e.category === "zone" ? $a(t.properties) : Oa(t.properties, this.sourceId);
|
|
3543
3856
|
}
|
|
3544
3857
|
}
|
|
3545
|
-
const
|
|
3858
|
+
const Fe = [8, 54.5, 15.2, 57.8], qe = {
|
|
3546
3859
|
building: [
|
|
3547
3860
|
{ source: "danish-matrikel", typename: "geodkv_v001:bygning_current" },
|
|
3548
3861
|
// Footprint polygons (GeoDanmark Vektor)
|
|
@@ -3554,7 +3867,7 @@ const We = [8, 54.5, 15.2, 57.8], Ve = {
|
|
|
3554
3867
|
{ source: "danish-matrikel", typename: "mat_v001:samletfastejendom_current" }
|
|
3555
3868
|
]
|
|
3556
3869
|
};
|
|
3557
|
-
function
|
|
3870
|
+
function Ua(r) {
|
|
3558
3871
|
if (!r) return [0, 0];
|
|
3559
3872
|
const t = r.coordinates;
|
|
3560
3873
|
switch (r.type) {
|
|
@@ -3572,7 +3885,7 @@ function va(r) {
|
|
|
3572
3885
|
return [0, 0];
|
|
3573
3886
|
}
|
|
3574
3887
|
}
|
|
3575
|
-
function
|
|
3888
|
+
function Ma(r, t) {
|
|
3576
3889
|
if (!r) return t;
|
|
3577
3890
|
for (const e of [
|
|
3578
3891
|
"mat:matrikelnummer",
|
|
@@ -3588,14 +3901,14 @@ function Ea(r, t) {
|
|
|
3588
3901
|
if (typeof r[e] == "string" && r[e]) return r[e];
|
|
3589
3902
|
return t;
|
|
3590
3903
|
}
|
|
3591
|
-
function
|
|
3904
|
+
function Fa(r, t, e) {
|
|
3592
3905
|
return `${r}:${t}:${e}`;
|
|
3593
3906
|
}
|
|
3594
|
-
const
|
|
3907
|
+
const qa = /* @__PURE__ */ new Set(["building", "cadastre", "zone"]);
|
|
3595
3908
|
function gt(r, t, e) {
|
|
3596
|
-
const o = e.typename.replace(/^[^:]+:/, ""), s =
|
|
3909
|
+
const o = e.typename.replace(/^[^:]+:/, ""), s = C(t), a = qa.has(t) ? "priority" : "raw";
|
|
3597
3910
|
return {
|
|
3598
|
-
id:
|
|
3911
|
+
id: Fa(r, e.source, e.typename),
|
|
3599
3912
|
sourceId: r,
|
|
3600
3913
|
sourceLayerId: e.typename,
|
|
3601
3914
|
category: t,
|
|
@@ -3607,7 +3920,7 @@ function gt(r, t, e) {
|
|
|
3607
3920
|
descriptionKey: `gis.layer.${r}.${e.source}.${o}.description`
|
|
3608
3921
|
};
|
|
3609
3922
|
}
|
|
3610
|
-
function
|
|
3923
|
+
function za(r, t) {
|
|
3611
3924
|
if (t === "building") {
|
|
3612
3925
|
const i = r?.byg041BebyggetAreal ?? r?.byg038SamletBygningsareal, n = r?.byg021BygningensAnvendelse, c = r?.id_lokalId, p = r?.byg026Opførelsesår;
|
|
3613
3926
|
return {
|
|
@@ -3624,8 +3937,8 @@ function Ia(r, t) {
|
|
|
3624
3937
|
featureType: "zone",
|
|
3625
3938
|
zoneType: i ?? void 0,
|
|
3626
3939
|
zoneCode: c ?? void 0,
|
|
3627
|
-
legalStatus:
|
|
3628
|
-
planType:
|
|
3940
|
+
legalStatus: Le(p),
|
|
3941
|
+
planType: Ue(r?.typ_gde_bezeichnung),
|
|
3629
3942
|
planId: n ?? void 0,
|
|
3630
3943
|
planDocumentLink: h ?? void 0,
|
|
3631
3944
|
publicationDate: r?.auflagedatum ?? void 0,
|
|
@@ -3643,19 +3956,19 @@ function Ia(r, t) {
|
|
|
3643
3956
|
registryId: a ?? void 0
|
|
3644
3957
|
};
|
|
3645
3958
|
}
|
|
3646
|
-
class
|
|
3959
|
+
class Ba {
|
|
3647
3960
|
categoryMap;
|
|
3648
3961
|
dataViewsBaseUrl;
|
|
3649
3962
|
getHeaders;
|
|
3650
3963
|
sourceId;
|
|
3651
3964
|
constructor(t) {
|
|
3652
|
-
this.dataViewsBaseUrl = t.dataViewsBaseUrl.replace(/\/$/, ""), this.getHeaders = t.getHeaders, this.categoryMap = t.categoryMap ??
|
|
3965
|
+
this.dataViewsBaseUrl = t.dataViewsBaseUrl.replace(/\/$/, ""), this.getHeaders = t.getHeaders, this.categoryMap = t.categoryMap ?? qe, this.sourceId = t.sourceId ?? "cue-sdk-gis";
|
|
3653
3966
|
}
|
|
3654
3967
|
async listFeatureCategoryDescriptors(t) {
|
|
3655
3968
|
const e = await this.listAvailableLayers(t);
|
|
3656
3969
|
return [
|
|
3657
3970
|
...new Map(
|
|
3658
|
-
e.map((o) => [o.category,
|
|
3971
|
+
e.map((o) => [o.category, C(o.category)])
|
|
3659
3972
|
).values()
|
|
3660
3973
|
];
|
|
3661
3974
|
}
|
|
@@ -3715,7 +4028,7 @@ class Ca {
|
|
|
3715
4028
|
return d.json();
|
|
3716
4029
|
}
|
|
3717
4030
|
_toGisFeature(t, e, o) {
|
|
3718
|
-
const [s, a] =
|
|
4031
|
+
const [s, a] = Ua(t.geometry), i = t.id ?? `${e.sourceLayerId}/${o}`, n = Ma(t.properties, i), c = t.bbox ? [t.bbox[0], t.bbox[1], t.bbox[2], t.bbox[3]] : void 0, p = e.tier, h = p === "priority" ? za(t.properties, e.category) : void 0;
|
|
3719
4032
|
return {
|
|
3720
4033
|
id: i,
|
|
3721
4034
|
sourceId: this.sourceId,
|
|
@@ -3736,39 +4049,39 @@ class Ca {
|
|
|
3736
4049
|
};
|
|
3737
4050
|
}
|
|
3738
4051
|
}
|
|
3739
|
-
function
|
|
4052
|
+
function It(r, t) {
|
|
3740
4053
|
if (Array.isArray(r)) {
|
|
3741
4054
|
if (typeof r[0] == "number" && typeof r[1] == "number") {
|
|
3742
4055
|
t([r[0], r[1]]);
|
|
3743
4056
|
return;
|
|
3744
4057
|
}
|
|
3745
|
-
for (const e of r)
|
|
4058
|
+
for (const e of r) It(e, t);
|
|
3746
4059
|
}
|
|
3747
4060
|
}
|
|
3748
|
-
function
|
|
3749
|
-
return r ? r.type === "GeometryCollection" ? (r.geometries ?? []).flatMap((t) =>
|
|
4061
|
+
function Ct(r) {
|
|
4062
|
+
return r ? r.type === "GeometryCollection" ? (r.geometries ?? []).flatMap((t) => Ct(t)) : [r.coordinates] : [];
|
|
3750
4063
|
}
|
|
3751
|
-
function
|
|
4064
|
+
function Ga(r) {
|
|
3752
4065
|
let t = 1 / 0, e = 1 / 0, o = -1 / 0, s = -1 / 0;
|
|
3753
4066
|
const a = (i) => {
|
|
3754
4067
|
i[0] < t && (t = i[0]), i[1] < e && (e = i[1]), i[0] > o && (o = i[0]), i[1] > s && (s = i[1]);
|
|
3755
4068
|
};
|
|
3756
|
-
return
|
|
4069
|
+
return Ct(r).forEach((i) => It(i, a)), t === 1 / 0 ? null : [t, e, o, s];
|
|
3757
4070
|
}
|
|
3758
|
-
function
|
|
4071
|
+
function Ha(r) {
|
|
3759
4072
|
let t = null;
|
|
3760
|
-
for (const e of
|
|
3761
|
-
if (
|
|
4073
|
+
for (const e of Ct(r))
|
|
4074
|
+
if (It(e, (o) => t ??= o), t) break;
|
|
3762
4075
|
return t ?? [0, 0];
|
|
3763
4076
|
}
|
|
3764
|
-
function
|
|
4077
|
+
function Wa(r, t) {
|
|
3765
4078
|
if (r) {
|
|
3766
4079
|
for (const e of ["name", "Name", "title", "Title", "label", "Label"])
|
|
3767
4080
|
if (typeof r[e] == "string" && r[e]) return r[e];
|
|
3768
4081
|
}
|
|
3769
4082
|
return t;
|
|
3770
4083
|
}
|
|
3771
|
-
class
|
|
4084
|
+
class xt {
|
|
3772
4085
|
static _LIST_CACHE_TTL_MS = 5e3;
|
|
3773
4086
|
dataViewsBaseUrl;
|
|
3774
4087
|
getHeaders;
|
|
@@ -3778,19 +4091,19 @@ class kt {
|
|
|
3778
4091
|
this.dataViewsBaseUrl = t.dataViewsBaseUrl.replace(/\/$/, ""), this.getHeaders = t.getHeaders, this.sourceId = t.sourceId ?? "cue-gis-sources";
|
|
3779
4092
|
}
|
|
3780
4093
|
async listFeatureCategoryDescriptors(t) {
|
|
3781
|
-
return (await this.listAvailableLayers(t)).length > 0 ? [
|
|
4094
|
+
return (await this.listAvailableLayers(t)).length > 0 ? [C("custom")] : [];
|
|
3782
4095
|
}
|
|
3783
4096
|
async listFeatureCategories(t) {
|
|
3784
4097
|
return (await this.listAvailableLayers(t)).length > 0 ? ["custom"] : [];
|
|
3785
4098
|
}
|
|
3786
4099
|
async listAvailableLayers(t) {
|
|
3787
|
-
return (await this._listSources()).filter((o) => o.bbox !== null &&
|
|
4100
|
+
return (await this._listSources()).filter((o) => o.bbox !== null && P(o.bbox, t)).map((o) => this._toLayerDescriptor(o));
|
|
3788
4101
|
}
|
|
3789
4102
|
async getFeaturesForLayer(t, e) {
|
|
3790
4103
|
const o = this._idFromLayerId(e);
|
|
3791
4104
|
if (!o) return [];
|
|
3792
4105
|
const s = await this._getSource(o);
|
|
3793
|
-
return s ? s.featureCollection.features.map((a, i) => ({ feature: a, index: i, bbox:
|
|
4106
|
+
return s ? s.featureCollection.features.map((a, i) => ({ feature: a, index: i, bbox: Ga(a.geometry) })).filter((a) => a.bbox !== null && P(a.bbox, t)).map((a) => this._toGisFeature(a.feature, s, a.index)) : [];
|
|
3794
4107
|
}
|
|
3795
4108
|
async getFeaturesOfCategory(t, e) {
|
|
3796
4109
|
if (e !== "custom") return [];
|
|
@@ -3799,7 +4112,7 @@ class kt {
|
|
|
3799
4112
|
}
|
|
3800
4113
|
// ─── Private helpers ────────────────────────────────────────────────────────
|
|
3801
4114
|
_toLayerDescriptor(t) {
|
|
3802
|
-
const e =
|
|
4115
|
+
const e = C("custom");
|
|
3803
4116
|
return {
|
|
3804
4117
|
id: `${this.sourceId}:${t.id}`,
|
|
3805
4118
|
sourceId: this.sourceId,
|
|
@@ -3816,7 +4129,7 @@ class kt {
|
|
|
3816
4129
|
return t.startsWith(e) ? t.slice(e.length) : null;
|
|
3817
4130
|
}
|
|
3818
4131
|
_toGisFeature(t, e, o) {
|
|
3819
|
-
const [s, a] =
|
|
4132
|
+
const [s, a] = Ha(t.geometry), i = t.id !== void 0 ? String(t.id) : `${e.id}/${o}`, n = t.properties ?? {}, c = Wa(n, `${e.name} #${o + 1}`);
|
|
3820
4133
|
return {
|
|
3821
4134
|
id: `${this.sourceId}:${e.id}:${i}`,
|
|
3822
4135
|
sourceId: this.sourceId,
|
|
@@ -3824,7 +4137,7 @@ class kt {
|
|
|
3824
4137
|
layerId: `${this.sourceId}:${e.id}`,
|
|
3825
4138
|
name: c,
|
|
3826
4139
|
category: "custom",
|
|
3827
|
-
preferredColor:
|
|
4140
|
+
preferredColor: C("custom").preferredColor,
|
|
3828
4141
|
type: "custom",
|
|
3829
4142
|
lat: a,
|
|
3830
4143
|
lon: s,
|
|
@@ -3836,7 +4149,7 @@ class kt {
|
|
|
3836
4149
|
}
|
|
3837
4150
|
async _listSources() {
|
|
3838
4151
|
const t = Date.now();
|
|
3839
|
-
if (this._listCache && t - this._listCache.at <
|
|
4152
|
+
if (this._listCache && t - this._listCache.at < xt._LIST_CACHE_TTL_MS)
|
|
3840
4153
|
return this._listCache.sources;
|
|
3841
4154
|
const e = await this.getHeaders(), o = await fetch(`${this.dataViewsBaseUrl}/gis-sources`, { headers: e });
|
|
3842
4155
|
if (!o.ok)
|
|
@@ -3854,7 +4167,7 @@ class kt {
|
|
|
3854
4167
|
return await s.json();
|
|
3855
4168
|
}
|
|
3856
4169
|
}
|
|
3857
|
-
const
|
|
4170
|
+
const Va = {
|
|
3858
4171
|
address: [
|
|
3859
4172
|
"ms:ogd-0406_arv_basis_avzh_hausnummer_pos_p",
|
|
3860
4173
|
"ms:ogd-0571_afv_gv_strat_strassennetz_l"
|
|
@@ -3902,21 +4215,21 @@ const Oa = {
|
|
|
3902
4215
|
// ÖREB Überlagernde Festlegungen (Flächen) – overlaying planning constraints
|
|
3903
4216
|
"ms:ogd-0155_arv_basis_np_ul_flaeche_f"
|
|
3904
4217
|
]
|
|
3905
|
-
},
|
|
4218
|
+
}, ze = [
|
|
3906
4219
|
{
|
|
3907
4220
|
name: "Canton of Zürich",
|
|
3908
|
-
coverageBBox:
|
|
4221
|
+
coverageBBox: _a,
|
|
3909
4222
|
supportedCategories: ["address", "poi", "railway", "natural", "manmade", "building", "cadastre", "greenspace", "paved", "zone"],
|
|
3910
4223
|
priority: 10,
|
|
3911
4224
|
adapter: new ut({
|
|
3912
|
-
categoryMap:
|
|
4225
|
+
categoryMap: Va,
|
|
3913
4226
|
// maps.zh.ch (MapServer) ignores srsName and always operates in LV95.
|
|
3914
4227
|
nativeCrs: "EPSG:2056"
|
|
3915
4228
|
})
|
|
3916
4229
|
},
|
|
3917
4230
|
{
|
|
3918
4231
|
name: "Switzerland (national AV cadastre)",
|
|
3919
|
-
coverageBBox:
|
|
4232
|
+
coverageBBox: Ea,
|
|
3920
4233
|
supportedCategories: ["cadastre"],
|
|
3921
4234
|
priority: 5,
|
|
3922
4235
|
// Lower priority than canton-specific adapters. For ZH, the canton adapter (priority 10) wins.
|
|
@@ -3944,7 +4257,7 @@ const Oa = {
|
|
|
3944
4257
|
* - `pdk:kommuneplanramme_vedtaget` – adopted municipal plan frameworks
|
|
3945
4258
|
*/
|
|
3946
4259
|
name: "Denmark (Plandata.dk – planning zones)",
|
|
3947
|
-
coverageBBox:
|
|
4260
|
+
coverageBBox: Fe,
|
|
3948
4261
|
supportedCategories: ["zone"],
|
|
3949
4262
|
priority: 10,
|
|
3950
4263
|
adapter: new ut({
|
|
@@ -3962,12 +4275,12 @@ const Oa = {
|
|
|
3962
4275
|
})
|
|
3963
4276
|
}
|
|
3964
4277
|
];
|
|
3965
|
-
function
|
|
4278
|
+
function re(r) {
|
|
3966
4279
|
return [...r].sort(
|
|
3967
|
-
(t, e) =>
|
|
4280
|
+
(t, e) => yt.indexOf(t.category) - yt.indexOf(e.category)
|
|
3968
4281
|
);
|
|
3969
4282
|
}
|
|
3970
|
-
class
|
|
4283
|
+
class Xa {
|
|
3971
4284
|
nominatim;
|
|
3972
4285
|
regions;
|
|
3973
4286
|
/**
|
|
@@ -3982,9 +4295,9 @@ class Aa {
|
|
|
3982
4295
|
zonePlanTypeColors: s,
|
|
3983
4296
|
...a
|
|
3984
4297
|
} = t;
|
|
3985
|
-
this.nominatim = new
|
|
3986
|
-
const i = o ?
|
|
3987
|
-
this.regions = e ?? i, this.zonePlanTypeColors = { ...
|
|
4298
|
+
this.nominatim = new ha(a);
|
|
4299
|
+
const i = o ? ze : [];
|
|
4300
|
+
this.regions = e ?? i, this.zonePlanTypeColors = { ...ia, ...s };
|
|
3988
4301
|
}
|
|
3989
4302
|
/**
|
|
3990
4303
|
* Return the available feature categories together with UI metadata such as
|
|
@@ -3997,18 +4310,18 @@ class Aa {
|
|
|
3997
4310
|
* @param bbox [west, south, east, north] in WGS-84 decimal degrees
|
|
3998
4311
|
*/
|
|
3999
4312
|
async listFeatureCategoryDescriptors(t) {
|
|
4000
|
-
const e = this.regions.filter((s) =>
|
|
4313
|
+
const e = this.regions.filter((s) => P(s.coverageBBox, t) && s.supportedCategories).sort((s, a) => (a.priority ?? 0) - (s.priority ?? 0));
|
|
4001
4314
|
if (e.length > 0) {
|
|
4002
4315
|
const s = /* @__PURE__ */ new Set(), a = [];
|
|
4003
4316
|
for (const i of e)
|
|
4004
4317
|
for (const n of i.supportedCategories ?? [])
|
|
4005
|
-
s.has(n) || (s.add(n), a.push(
|
|
4006
|
-
for (const i of
|
|
4007
|
-
s.has(i) || a.push(
|
|
4008
|
-
return
|
|
4318
|
+
s.has(n) || (s.add(n), a.push(C(n)));
|
|
4319
|
+
for (const i of bt)
|
|
4320
|
+
s.has(i) || a.push(C(i));
|
|
4321
|
+
return re(a);
|
|
4009
4322
|
}
|
|
4010
4323
|
const o = await this._adapterFor(t).listFeatureCategoryDescriptors(t);
|
|
4011
|
-
return
|
|
4324
|
+
return re(o);
|
|
4012
4325
|
}
|
|
4013
4326
|
/**
|
|
4014
4327
|
* Return the feature categories that have at least one result within the
|
|
@@ -4058,7 +4371,7 @@ class Aa {
|
|
|
4058
4371
|
console.log(" • Nominatim (OSM) bbox=[global] priority=-1");
|
|
4059
4372
|
const s = [
|
|
4060
4373
|
...this.regions.filter(
|
|
4061
|
-
(n) =>
|
|
4374
|
+
(n) => P(n.coverageBBox, t) && (!n.supportedCategories || n.supportedCategories.includes(e))
|
|
4062
4375
|
).map((n) => ({
|
|
4063
4376
|
name: n.name,
|
|
4064
4377
|
adapter: n.adapter,
|
|
@@ -4081,7 +4394,7 @@ class Aa {
|
|
|
4081
4394
|
const { features: n, idx: c } = await Promise.race(i.values());
|
|
4082
4395
|
i.delete(c);
|
|
4083
4396
|
for (const p of n) {
|
|
4084
|
-
const h =
|
|
4397
|
+
const h = ae(p), d = tt(p), u = a.get(h);
|
|
4085
4398
|
(u === void 0 || d > u) && (a.set(h, d), yield p);
|
|
4086
4399
|
}
|
|
4087
4400
|
}
|
|
@@ -4102,7 +4415,7 @@ class Aa {
|
|
|
4102
4415
|
async getFeaturesOfCategory(t, e) {
|
|
4103
4416
|
const s = [
|
|
4104
4417
|
...this.regions.filter(
|
|
4105
|
-
(d) =>
|
|
4418
|
+
(d) => P(d.coverageBBox, t) && (!d.supportedCategories || d.supportedCategories.includes(e))
|
|
4106
4419
|
).map((d) => ({ name: d.name, adapter: d.adapter, isNominatim: !1 })),
|
|
4107
4420
|
{ name: "Nominatim (OSM)", adapter: this.nominatim, isNominatim: !0 }
|
|
4108
4421
|
], a = await Promise.allSettled(
|
|
@@ -4115,9 +4428,9 @@ class Aa {
|
|
|
4115
4428
|
), i = [], n = [];
|
|
4116
4429
|
for (const d of a)
|
|
4117
4430
|
d.status === "fulfilled" && (d.value.isNominatim ? n.push(...d.value.features) : i.push(...d.value.features));
|
|
4118
|
-
const c =
|
|
4431
|
+
const c = Qa(i, n), p = /* @__PURE__ */ new Map(), h = [];
|
|
4119
4432
|
for (const d of c) {
|
|
4120
|
-
const u =
|
|
4433
|
+
const u = ae(d), m = tt(d), w = p.get(u);
|
|
4121
4434
|
(w === void 0 || m > w) && (p.set(u, m), h.push(d));
|
|
4122
4435
|
}
|
|
4123
4436
|
return h;
|
|
@@ -4128,29 +4441,29 @@ class Aa {
|
|
|
4128
4441
|
}
|
|
4129
4442
|
/** Resolve the best adapter for a query bbox (legacy single-adapter routing). */
|
|
4130
4443
|
_adapterFor(t) {
|
|
4131
|
-
return this.regions.filter((o) =>
|
|
4444
|
+
return this.regions.filter((o) => P(o.coverageBBox, t)).sort((o, s) => (s.priority ?? 0) - (o.priority ?? 0))[0]?.adapter ?? this.nominatim;
|
|
4132
4445
|
}
|
|
4133
4446
|
}
|
|
4134
|
-
function
|
|
4447
|
+
function tt(r) {
|
|
4135
4448
|
const t = r.geometry?.type;
|
|
4136
4449
|
return t === "Polygon" || t === "MultiPolygon" ? 3 : t === "LineString" || t === "MultiLineString" ? 2 : 1;
|
|
4137
4450
|
}
|
|
4138
|
-
function
|
|
4451
|
+
function ae(r) {
|
|
4139
4452
|
const t = Math.round(r.lat * 1e3) / 1e3, e = Math.round(r.lon * 1e3) / 1e3;
|
|
4140
4453
|
return `${(r.name ?? r.id ?? "").toLowerCase().trim()}|${t}|${e}`;
|
|
4141
4454
|
}
|
|
4142
|
-
const
|
|
4143
|
-
function
|
|
4455
|
+
const Ya = 1e-3;
|
|
4456
|
+
function Ja(r, t) {
|
|
4144
4457
|
const e = r.lat - t.lat, o = r.lon - t.lon;
|
|
4145
4458
|
return Math.sqrt(e * e + o * o);
|
|
4146
4459
|
}
|
|
4147
|
-
function
|
|
4460
|
+
function Qa(r, t) {
|
|
4148
4461
|
if (t.length === 0) return r;
|
|
4149
|
-
const e = r.filter((i) =>
|
|
4462
|
+
const e = r.filter((i) => tt(i) === 3), o = r.filter((i) => tt(i) !== 3), s = e.map((i) => ({ feature: { ...i, originalData: { ...i.originalData } }, matched: !1 })), a = [];
|
|
4150
4463
|
for (const i of t) {
|
|
4151
|
-
let n = -1, c =
|
|
4464
|
+
let n = -1, c = Ya;
|
|
4152
4465
|
for (let p = 0; p < s.length; p++) {
|
|
4153
|
-
const h =
|
|
4466
|
+
const h = Ja(i, s[p].feature);
|
|
4154
4467
|
h < c && (c = h, n = p);
|
|
4155
4468
|
}
|
|
4156
4469
|
n >= 0 ? (s[n].feature.originalData = {
|
|
@@ -4164,8 +4477,8 @@ function Da(r, t) {
|
|
|
4164
4477
|
...a
|
|
4165
4478
|
];
|
|
4166
4479
|
}
|
|
4167
|
-
const
|
|
4168
|
-
class
|
|
4480
|
+
const ie = "/data-views", Ka = 1500, Za = [-180, -90, 180, 90];
|
|
4481
|
+
class ti {
|
|
4169
4482
|
// undefined = not yet built
|
|
4170
4483
|
/** @internal — construct via `cue.gis`, not directly. */
|
|
4171
4484
|
constructor(t, e) {
|
|
@@ -4248,12 +4561,12 @@ class La {
|
|
|
4248
4561
|
}
|
|
4249
4562
|
// ── Private ───────────────────────────────────────────────────────────────
|
|
4250
4563
|
_scheduleDebouncedQuery() {
|
|
4251
|
-
this._debounceTimer !== null && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => this._queryLayers(),
|
|
4564
|
+
this._debounceTimer !== null && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => this._queryLayers(), Ka);
|
|
4252
4565
|
}
|
|
4253
4566
|
_getGateway() {
|
|
4254
4567
|
if (this._gatewayCache !== null && this._gatewayProjectId === this._projectId)
|
|
4255
4568
|
return this._gatewayCache;
|
|
4256
|
-
const t = this._projectId, e = [...
|
|
4569
|
+
const t = this._projectId, e = [...ze];
|
|
4257
4570
|
if (t) {
|
|
4258
4571
|
const o = async () => ({
|
|
4259
4572
|
...await this._getAuthHeaders(),
|
|
@@ -4262,27 +4575,27 @@ class La {
|
|
|
4262
4575
|
e.unshift(
|
|
4263
4576
|
{
|
|
4264
4577
|
name: "Cue SDK (authenticated)",
|
|
4265
|
-
coverageBBox:
|
|
4266
|
-
supportedCategories: Object.keys(
|
|
4578
|
+
coverageBBox: Fe,
|
|
4579
|
+
supportedCategories: Object.keys(qe),
|
|
4267
4580
|
priority: 10,
|
|
4268
|
-
adapter: new
|
|
4269
|
-
dataViewsBaseUrl: `${this._gatewayUrl}${
|
|
4581
|
+
adapter: new Ba({
|
|
4582
|
+
dataViewsBaseUrl: `${this._gatewayUrl}${ie}`,
|
|
4270
4583
|
getHeaders: o
|
|
4271
4584
|
})
|
|
4272
4585
|
},
|
|
4273
4586
|
{
|
|
4274
4587
|
name: "Cue SDK (GIS sources)",
|
|
4275
|
-
coverageBBox:
|
|
4588
|
+
coverageBBox: Za,
|
|
4276
4589
|
supportedCategories: ["custom"],
|
|
4277
4590
|
priority: 10,
|
|
4278
|
-
adapter: new
|
|
4279
|
-
dataViewsBaseUrl: `${this._gatewayUrl}${
|
|
4591
|
+
adapter: new xt({
|
|
4592
|
+
dataViewsBaseUrl: `${this._gatewayUrl}${ie}`,
|
|
4280
4593
|
getHeaders: o
|
|
4281
4594
|
})
|
|
4282
4595
|
}
|
|
4283
4596
|
);
|
|
4284
4597
|
}
|
|
4285
|
-
return this._gatewayCache = new
|
|
4598
|
+
return this._gatewayCache = new Xa({ regions: e }), this._gatewayProjectId = t, this._gatewayCache;
|
|
4286
4599
|
}
|
|
4287
4600
|
async _queryLayers() {
|
|
4288
4601
|
const t = this._bbox;
|
|
@@ -4326,13 +4639,13 @@ class La {
|
|
|
4326
4639
|
this._loadListeners.forEach((e) => e(t));
|
|
4327
4640
|
}
|
|
4328
4641
|
}
|
|
4329
|
-
class
|
|
4642
|
+
class ne {
|
|
4330
4643
|
constructor(t, e) {
|
|
4331
4644
|
this._auth = t, this._gatewayUrl = e?.gatewayUrl ?? "";
|
|
4332
4645
|
}
|
|
4333
4646
|
_auth;
|
|
4334
4647
|
_gatewayUrl;
|
|
4335
|
-
_projects = new
|
|
4648
|
+
_projects = new E(void 0);
|
|
4336
4649
|
/**
|
|
4337
4650
|
* Live cache of the current user's projects, refreshed on every `listProjects()`
|
|
4338
4651
|
* call and patched in place by `getProject()` — lets consumers reflect changes
|
|
@@ -4344,7 +4657,7 @@ class de {
|
|
|
4344
4657
|
* Throws if a project with the given ID already exists.
|
|
4345
4658
|
*/
|
|
4346
4659
|
async createProject(t) {
|
|
4347
|
-
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
4660
|
+
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${qs}`, {
|
|
4348
4661
|
method: "POST",
|
|
4349
4662
|
headers: { "Content-Type": "application/json" },
|
|
4350
4663
|
body: JSON.stringify(t)
|
|
@@ -4357,7 +4670,7 @@ class de {
|
|
|
4357
4670
|
}
|
|
4358
4671
|
/** List all projects where the authenticated user appears in the members array. */
|
|
4359
4672
|
async listProjects() {
|
|
4360
|
-
const t = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
4673
|
+
const t = await this._auth.authenticatedFetch(`${this._gatewayUrl}${Mt}`);
|
|
4361
4674
|
if (!t.ok) {
|
|
4362
4675
|
const o = await t.text().catch(() => "");
|
|
4363
4676
|
throw new Error(`Failed to list projects: ${t.status} ${t.statusText}${o ? ` — ${o}` : ""}`);
|
|
@@ -4368,7 +4681,7 @@ class de {
|
|
|
4368
4681
|
/** Fetch a single project by ID. Returns null if not found or user lacks access. */
|
|
4369
4682
|
async getProject(t) {
|
|
4370
4683
|
const e = await this._auth.authenticatedFetch(
|
|
4371
|
-
`${this._gatewayUrl}${
|
|
4684
|
+
`${this._gatewayUrl}${Mt}?projectId=${encodeURIComponent(t)}`
|
|
4372
4685
|
);
|
|
4373
4686
|
if (!e.ok) {
|
|
4374
4687
|
if (e.status === 404) return null;
|
|
@@ -4395,7 +4708,7 @@ class de {
|
|
|
4395
4708
|
*/
|
|
4396
4709
|
async inviteUserToProject(t, e, o) {
|
|
4397
4710
|
const s = await this._auth.authenticatedFetch(
|
|
4398
|
-
`${this._gatewayUrl}${
|
|
4711
|
+
`${this._gatewayUrl}${Hs(e)}`,
|
|
4399
4712
|
{
|
|
4400
4713
|
method: "POST",
|
|
4401
4714
|
headers: { "Content-Type": "application/json" },
|
|
@@ -4414,7 +4727,7 @@ class de {
|
|
|
4414
4727
|
/** Change an existing member's role on a project. */
|
|
4415
4728
|
async changeUserRoleOnProject(t, e, o) {
|
|
4416
4729
|
const s = await this._auth.authenticatedFetch(
|
|
4417
|
-
`${this._gatewayUrl}${
|
|
4730
|
+
`${this._gatewayUrl}${Ws(e, t)}`,
|
|
4418
4731
|
{
|
|
4419
4732
|
method: "PUT",
|
|
4420
4733
|
headers: { "Content-Type": "application/json" },
|
|
@@ -4429,7 +4742,7 @@ class de {
|
|
|
4429
4742
|
/** Remove a member from a project. */
|
|
4430
4743
|
async removeUserFromProject(t, e) {
|
|
4431
4744
|
const o = await this._auth.authenticatedFetch(
|
|
4432
|
-
`${this._gatewayUrl}${
|
|
4745
|
+
`${this._gatewayUrl}${Vs(e, t)}`,
|
|
4433
4746
|
{ method: "DELETE" }
|
|
4434
4747
|
);
|
|
4435
4748
|
if (!o.ok) {
|
|
@@ -4445,7 +4758,7 @@ class de {
|
|
|
4445
4758
|
*/
|
|
4446
4759
|
async deleteProject(t, e = !1) {
|
|
4447
4760
|
const o = e ? "?hard=true" : "", s = await this._auth.authenticatedFetch(
|
|
4448
|
-
`${this._gatewayUrl}${
|
|
4761
|
+
`${this._gatewayUrl}${zs(t)}${o}`,
|
|
4449
4762
|
{ method: "DELETE" }
|
|
4450
4763
|
);
|
|
4451
4764
|
if (!s.ok) {
|
|
@@ -4459,7 +4772,7 @@ class de {
|
|
|
4459
4772
|
*/
|
|
4460
4773
|
async restoreProject(t) {
|
|
4461
4774
|
const e = await this._auth.authenticatedFetch(
|
|
4462
|
-
`${this._gatewayUrl}${
|
|
4775
|
+
`${this._gatewayUrl}${Gs(t)}`,
|
|
4463
4776
|
{ method: "POST" }
|
|
4464
4777
|
);
|
|
4465
4778
|
if (!e.ok) {
|
|
@@ -4476,7 +4789,7 @@ class de {
|
|
|
4476
4789
|
*/
|
|
4477
4790
|
async getProjectMetadata(t) {
|
|
4478
4791
|
const e = await this._auth.authenticatedFetch(
|
|
4479
|
-
`${this._gatewayUrl}${
|
|
4792
|
+
`${this._gatewayUrl}${Xs(t)}`
|
|
4480
4793
|
);
|
|
4481
4794
|
if (!e.ok) {
|
|
4482
4795
|
const o = await e.text().catch(() => "");
|
|
@@ -4499,7 +4812,7 @@ class de {
|
|
|
4499
4812
|
*/
|
|
4500
4813
|
async updateProject(t, e) {
|
|
4501
4814
|
const o = await this._auth.authenticatedFetch(
|
|
4502
|
-
`${this._gatewayUrl}${
|
|
4815
|
+
`${this._gatewayUrl}${Bs(t)}`,
|
|
4503
4816
|
{
|
|
4504
4817
|
method: "PUT",
|
|
4505
4818
|
headers: { "Content-Type": "application/json" },
|
|
@@ -4515,7 +4828,7 @@ class de {
|
|
|
4515
4828
|
/** Sets a project's portal-only metadata. Omit a field to leave it untouched, `null` to clear it. */
|
|
4516
4829
|
async setProjectMetadata(t, e) {
|
|
4517
4830
|
const o = await this._auth.authenticatedFetch(
|
|
4518
|
-
`${this._gatewayUrl}${
|
|
4831
|
+
`${this._gatewayUrl}${Ys(t)}`,
|
|
4519
4832
|
{
|
|
4520
4833
|
method: "PUT",
|
|
4521
4834
|
headers: { "Content-Type": "application/json" },
|
|
@@ -4528,13 +4841,13 @@ class de {
|
|
|
4528
4841
|
}
|
|
4529
4842
|
}
|
|
4530
4843
|
}
|
|
4531
|
-
class
|
|
4844
|
+
class ce {
|
|
4532
4845
|
constructor(t, e) {
|
|
4533
4846
|
this._auth = t, this._gatewayUrl = e;
|
|
4534
4847
|
}
|
|
4535
4848
|
_auth;
|
|
4536
4849
|
_gatewayUrl;
|
|
4537
|
-
_orgCredits = new
|
|
4850
|
+
_orgCredits = new E(void 0);
|
|
4538
4851
|
/**
|
|
4539
4852
|
* Reactive view of the last-fetched org credit pool. Updated automatically
|
|
4540
4853
|
* by `getOrgCredits()` and by the sync layer after every `previewSync`/
|
|
@@ -4556,13 +4869,13 @@ class ue {
|
|
|
4556
4869
|
}
|
|
4557
4870
|
/** Whether the current user has an active API key. */
|
|
4558
4871
|
async hasAPIKey() {
|
|
4559
|
-
return await this._fetch(
|
|
4872
|
+
return await this._fetch(jt) !== null;
|
|
4560
4873
|
}
|
|
4561
4874
|
/** Returns the sign-in methods registered for the current user's email. */
|
|
4562
4875
|
async getSignInMethods() {
|
|
4563
4876
|
const t = this._auth.currentUser;
|
|
4564
4877
|
if (!t?.email) throw new Error("User has no e-mail");
|
|
4565
|
-
return
|
|
4878
|
+
return go(this._auth.firebaseAuth, t.email);
|
|
4566
4879
|
}
|
|
4567
4880
|
/** Builds a human-readable label from a Firebase UserInfo provider entry. */
|
|
4568
4881
|
buildProviderLabel(t) {
|
|
@@ -4575,14 +4888,14 @@ class ue {
|
|
|
4575
4888
|
}
|
|
4576
4889
|
/** Links a Google or Microsoft provider to the current account via popup. Returns the new provider label. */
|
|
4577
4890
|
async linkProvider(t) {
|
|
4578
|
-
const e = this._requireUser(), o = t === "google.com" ? new
|
|
4891
|
+
const e = this._requireUser(), o = t === "google.com" ? new wt() : new ft(t), a = (await mo(e, o)).user.providerData.find(
|
|
4579
4892
|
(i) => i.providerId === t
|
|
4580
4893
|
);
|
|
4581
4894
|
return a ? this.buildProviderLabel(a) : "-";
|
|
4582
4895
|
}
|
|
4583
4896
|
/** Unlinks a provider from the current account. */
|
|
4584
4897
|
async unlinkProvider(t) {
|
|
4585
|
-
await
|
|
4898
|
+
await wo(this._requireUser(), t);
|
|
4586
4899
|
}
|
|
4587
4900
|
/** Changes the password. Reauthenticates first. */
|
|
4588
4901
|
async updatePassword(t, e) {
|
|
@@ -4590,14 +4903,14 @@ class ue {
|
|
|
4590
4903
|
if (!o.email) throw new Error("User has no e-mail");
|
|
4591
4904
|
await Dt(
|
|
4592
4905
|
o,
|
|
4593
|
-
|
|
4594
|
-
), await
|
|
4906
|
+
rt.credential(o.email, t)
|
|
4907
|
+
), await fo(o, e);
|
|
4595
4908
|
}
|
|
4596
4909
|
/** Adds (sets) a password for an account that currently only uses SSO. */
|
|
4597
4910
|
async addPassword(t) {
|
|
4598
4911
|
const e = this._requireUser();
|
|
4599
4912
|
if (!e.email) throw new Error("User has no e-mail");
|
|
4600
|
-
await
|
|
4913
|
+
await yo(e, rt.credential(e.email, t));
|
|
4601
4914
|
}
|
|
4602
4915
|
/** Requests an e-mail change. Sends a verification e-mail to the new address. */
|
|
4603
4916
|
async updateEmail(t, e) {
|
|
@@ -4605,12 +4918,12 @@ class ue {
|
|
|
4605
4918
|
if (!o.email) throw new Error("User e-mail not available");
|
|
4606
4919
|
await Dt(
|
|
4607
4920
|
o,
|
|
4608
|
-
|
|
4609
|
-
), await
|
|
4921
|
+
rt.credential(o.email, e)
|
|
4922
|
+
), await bo(o, t), await vo(o);
|
|
4610
4923
|
}
|
|
4611
4924
|
/** Creates a new API key for the current user. */
|
|
4612
4925
|
async createAPIKey(t) {
|
|
4613
|
-
return this._fetch(
|
|
4926
|
+
return this._fetch(Lt, {
|
|
4614
4927
|
method: "POST",
|
|
4615
4928
|
headers: { "Content-Type": "application/json" },
|
|
4616
4929
|
body: JSON.stringify({ expiration: t })
|
|
@@ -4619,7 +4932,7 @@ class ue {
|
|
|
4619
4932
|
/** Revokes the current user's API key. */
|
|
4620
4933
|
async revokeAPIKey() {
|
|
4621
4934
|
const t = await this._auth.authenticatedFetch(
|
|
4622
|
-
this._url(
|
|
4935
|
+
this._url(Lt),
|
|
4623
4936
|
{ method: "DELETE" }
|
|
4624
4937
|
);
|
|
4625
4938
|
if (!t.ok)
|
|
@@ -4627,25 +4940,25 @@ class ue {
|
|
|
4627
4940
|
}
|
|
4628
4941
|
/** Fetches the current user's existing API key. */
|
|
4629
4942
|
async requestAPIKey() {
|
|
4630
|
-
const t = await this._fetch(
|
|
4943
|
+
const t = await this._fetch(jt);
|
|
4631
4944
|
if (!t) throw new Error("No API key found");
|
|
4632
4945
|
return t;
|
|
4633
4946
|
}
|
|
4634
4947
|
/** Returns organizations the current user is a member of. */
|
|
4635
4948
|
async listOrganizations() {
|
|
4636
|
-
return this._fetch(
|
|
4949
|
+
return this._fetch(Jo);
|
|
4637
4950
|
}
|
|
4638
4951
|
/** Returns all members of the given organisation. Caller must be an org admin or superadmin. */
|
|
4639
4952
|
async getOrgMembers(t) {
|
|
4640
|
-
return this._fetch(
|
|
4953
|
+
return this._fetch(es(t));
|
|
4641
4954
|
}
|
|
4642
4955
|
/** Returns just the given organisation's admins. Caller must be a member (or admin/superadmin). */
|
|
4643
4956
|
async getOrgAdmins(t) {
|
|
4644
|
-
return this._fetch(
|
|
4957
|
+
return this._fetch(os(t));
|
|
4645
4958
|
}
|
|
4646
4959
|
/** Adds a new member to the organisation. Caller must be an org admin or superadmin. */
|
|
4647
4960
|
async addOrgMember(t, e) {
|
|
4648
|
-
await this._fetch(
|
|
4961
|
+
await this._fetch(ws(t), {
|
|
4649
4962
|
method: "POST",
|
|
4650
4963
|
headers: { "Content-Type": "application/json" },
|
|
4651
4964
|
body: JSON.stringify(e)
|
|
@@ -4653,7 +4966,7 @@ class ue {
|
|
|
4653
4966
|
}
|
|
4654
4967
|
/** Changes an existing member's role within the organisation. Caller must be an org admin or superadmin. */
|
|
4655
4968
|
async setOrgUserRole(t, e, o) {
|
|
4656
|
-
await this._fetch(
|
|
4969
|
+
await this._fetch(fs(t, e), {
|
|
4657
4970
|
method: "PUT",
|
|
4658
4971
|
headers: { "Content-Type": "application/json" },
|
|
4659
4972
|
body: JSON.stringify({ role: o })
|
|
@@ -4661,7 +4974,7 @@ class ue {
|
|
|
4661
4974
|
}
|
|
4662
4975
|
/** Removes a member from the organisation, optionally also removing them from every project they belong to. Caller must be an org admin or superadmin. */
|
|
4663
4976
|
async removeOrgMember(t, e, o) {
|
|
4664
|
-
await this._fetch(
|
|
4977
|
+
await this._fetch(ys(t, e), {
|
|
4665
4978
|
method: "DELETE",
|
|
4666
4979
|
headers: { "Content-Type": "application/json" },
|
|
4667
4980
|
body: JSON.stringify({ removeFromProjects: o })
|
|
@@ -4678,7 +4991,7 @@ class ue {
|
|
|
4678
4991
|
* and accept that the call then takes as long as the computation does.
|
|
4679
4992
|
*/
|
|
4680
4993
|
async getOrgCredits(t, e) {
|
|
4681
|
-
const o = e?.refresh ? `${
|
|
4994
|
+
const o = e?.refresh ? `${Ut(t)}?refresh=true` : Ut(t), s = await this._fetch(o);
|
|
4682
4995
|
return this._orgCredits.set(s), s;
|
|
4683
4996
|
}
|
|
4684
4997
|
/**
|
|
@@ -4687,7 +5000,7 @@ class ue {
|
|
|
4687
5000
|
* or superadmin.
|
|
4688
5001
|
*/
|
|
4689
5002
|
async getOrgConsumptionReport(t) {
|
|
4690
|
-
return this._fetch(
|
|
5003
|
+
return this._fetch(ss(t));
|
|
4691
5004
|
}
|
|
4692
5005
|
/**
|
|
4693
5006
|
* Per-file-extension credit/unit breakdown for one project within `[from, to)` (UTC ISO 8601,
|
|
@@ -4700,7 +5013,7 @@ class ue {
|
|
|
4700
5013
|
async getProjectFileTypeBreakdown(t, e, o, s) {
|
|
4701
5014
|
const a = new URLSearchParams({ from: o, to: s });
|
|
4702
5015
|
return this._fetch(
|
|
4703
|
-
`${
|
|
5016
|
+
`${rs(t, e)}?${a}`
|
|
4704
5017
|
);
|
|
4705
5018
|
}
|
|
4706
5019
|
/**
|
|
@@ -4713,7 +5026,7 @@ class ue {
|
|
|
4713
5026
|
*/
|
|
4714
5027
|
async getProjectTrafficReport(t, e, o, s) {
|
|
4715
5028
|
return this._fetch(
|
|
4716
|
-
`${
|
|
5029
|
+
`${as(t, e)}${this._rangeQuery(o, s)}`
|
|
4717
5030
|
);
|
|
4718
5031
|
}
|
|
4719
5032
|
/**
|
|
@@ -4723,7 +5036,7 @@ class ue {
|
|
|
4723
5036
|
*/
|
|
4724
5037
|
async getProjectUsageReport(t, e, o, s) {
|
|
4725
5038
|
return this._fetch(
|
|
4726
|
-
`${
|
|
5039
|
+
`${is(t, e)}${this._rangeQuery(o, s)}`
|
|
4727
5040
|
);
|
|
4728
5041
|
}
|
|
4729
5042
|
/** `?from=…&to=…`, or `''` when unbounded — the backend treats missing bounds as "everything". */
|
|
@@ -4735,7 +5048,7 @@ class ue {
|
|
|
4735
5048
|
}
|
|
4736
5049
|
/** Manual/support credit grant to an organisation's shared pool. Superadmins only — org admins self-serve via `startOrgCheckout`. */
|
|
4737
5050
|
async topUpOrgCredits(t, e) {
|
|
4738
|
-
await this._fetch(
|
|
5051
|
+
await this._fetch(ds(t), {
|
|
4739
5052
|
method: "POST",
|
|
4740
5053
|
headers: { "Content-Type": "application/json" },
|
|
4741
5054
|
body: JSON.stringify({ amount: e })
|
|
@@ -4751,7 +5064,7 @@ class ue {
|
|
|
4751
5064
|
* granted by the backend webhook once payment completes.
|
|
4752
5065
|
*/
|
|
4753
5066
|
async startOrgCheckout(t, e) {
|
|
4754
|
-
return this._fetch(
|
|
5067
|
+
return this._fetch(gs(t), {
|
|
4755
5068
|
method: "POST",
|
|
4756
5069
|
headers: { "Content-Type": "application/json" },
|
|
4757
5070
|
body: JSON.stringify({ credits: e })
|
|
@@ -4763,7 +5076,7 @@ class ue {
|
|
|
4763
5076
|
* an org admin; requires the org to have a Stripe customer.
|
|
4764
5077
|
*/
|
|
4765
5078
|
async startOrgBillingPortal(t) {
|
|
4766
|
-
return this._fetch(
|
|
5079
|
+
return this._fetch(ms(t), { method: "POST" });
|
|
4767
5080
|
}
|
|
4768
5081
|
/**
|
|
4769
5082
|
* Change an organisation's plan — freemium → custom (first paid plan), or
|
|
@@ -4776,7 +5089,7 @@ class ue {
|
|
|
4776
5089
|
* {@link startOrgBillingPortal} instead — this throws if called on one.
|
|
4777
5090
|
*/
|
|
4778
5091
|
async changeOrgPlan(t, e) {
|
|
4779
|
-
return this._fetch(
|
|
5092
|
+
return this._fetch(us(t), {
|
|
4780
5093
|
method: "POST",
|
|
4781
5094
|
headers: { "Content-Type": "application/json" },
|
|
4782
5095
|
body: JSON.stringify(e)
|
|
@@ -4789,7 +5102,7 @@ class ue {
|
|
|
4789
5102
|
}
|
|
4790
5103
|
/** Record that the current user has accepted the terms of service. Sets a `terms` custom claim on the token. */
|
|
4791
5104
|
async acceptTerms(t) {
|
|
4792
|
-
await this._fetch(
|
|
5105
|
+
await this._fetch(Qo, {
|
|
4793
5106
|
method: "POST",
|
|
4794
5107
|
headers: { "Content-Type": "application/json" },
|
|
4795
5108
|
body: JSON.stringify({ version: t })
|
|
@@ -4803,7 +5116,7 @@ class ue {
|
|
|
4803
5116
|
*/
|
|
4804
5117
|
async latestTermsAccepted() {
|
|
4805
5118
|
const t = this._auth.currentUser;
|
|
4806
|
-
return t ? (await
|
|
5119
|
+
return t ? (await Q(t)).claims.terms ?? null : null;
|
|
4807
5120
|
}
|
|
4808
5121
|
/**
|
|
4809
5122
|
* Record that the current user has been shown (and dismissed) the usage-analytics
|
|
@@ -4811,7 +5124,7 @@ class ue {
|
|
|
4811
5124
|
* `terms`, since this is a lightweight acknowledgement, not a blocking agreement.
|
|
4812
5125
|
*/
|
|
4813
5126
|
async acceptAnalyticsNotice(t) {
|
|
4814
|
-
await this._fetch(
|
|
5127
|
+
await this._fetch(Zo, {
|
|
4815
5128
|
method: "POST",
|
|
4816
5129
|
headers: { "Content-Type": "application/json" },
|
|
4817
5130
|
body: JSON.stringify({ version: t })
|
|
@@ -4826,10 +5139,10 @@ class ue {
|
|
|
4826
5139
|
*/
|
|
4827
5140
|
async latestAnalyticsNoticeAccepted() {
|
|
4828
5141
|
const t = this._auth.currentUser;
|
|
4829
|
-
return t ? (await
|
|
5142
|
+
return t ? (await Q(t)).claims.analyticsNotice ?? null : null;
|
|
4830
5143
|
}
|
|
4831
5144
|
}
|
|
4832
|
-
class
|
|
5145
|
+
class pe {
|
|
4833
5146
|
constructor(t, e) {
|
|
4834
5147
|
this._auth = t, this._gatewayUrl = e;
|
|
4835
5148
|
}
|
|
@@ -4842,14 +5155,14 @@ class ge {
|
|
|
4842
5155
|
* break navigation; failures are only logged.
|
|
4843
5156
|
*/
|
|
4844
5157
|
recordView(t, e) {
|
|
4845
|
-
this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
5158
|
+
this._auth.authenticatedFetch(`${this._gatewayUrl}${ts}`, {
|
|
4846
5159
|
method: "POST",
|
|
4847
5160
|
headers: { "Content-Type": "application/json" },
|
|
4848
5161
|
body: JSON.stringify({ view: t, projectId: e })
|
|
4849
5162
|
}).catch((o) => console.warn("Failed to record usage view", o));
|
|
4850
5163
|
}
|
|
4851
5164
|
}
|
|
4852
|
-
class
|
|
5165
|
+
class le {
|
|
4853
5166
|
constructor(t, e) {
|
|
4854
5167
|
this._auth = t, this._gatewayUrl = e;
|
|
4855
5168
|
}
|
|
@@ -4868,11 +5181,11 @@ class me {
|
|
|
4868
5181
|
}
|
|
4869
5182
|
/** Matches organisations on name, id or any alternative id. */
|
|
4870
5183
|
searchOrganizations(t) {
|
|
4871
|
-
return this._search(
|
|
5184
|
+
return this._search(vs, t);
|
|
4872
5185
|
}
|
|
4873
5186
|
/** Matches users on display name, e-mail, or an exact uid. */
|
|
4874
5187
|
searchUsers(t) {
|
|
4875
|
-
return this._search(
|
|
5188
|
+
return this._search(Ts, t);
|
|
4876
5189
|
}
|
|
4877
5190
|
/**
|
|
4878
5191
|
* Matches projects on name, id or any alternative id, across every organisation.
|
|
@@ -4880,18 +5193,18 @@ class me {
|
|
|
4880
5193
|
*/
|
|
4881
5194
|
searchProjects(t, e = !1) {
|
|
4882
5195
|
return this._search(
|
|
4883
|
-
|
|
5196
|
+
Es,
|
|
4884
5197
|
t,
|
|
4885
5198
|
e ? { includeDeleted: "true" } : void 0
|
|
4886
5199
|
);
|
|
4887
5200
|
}
|
|
4888
5201
|
/** Full profile for one user: auth record, orgs and projects they belong to. */
|
|
4889
5202
|
getUserDetail(t) {
|
|
4890
|
-
return this._fetch(
|
|
5203
|
+
return this._fetch(Ss(t));
|
|
4891
5204
|
}
|
|
4892
5205
|
/** Every organisation on the platform. Unpaginated — prefer `searchOrganizations`. */
|
|
4893
5206
|
listOrganizations() {
|
|
4894
|
-
return this._fetch(
|
|
5207
|
+
return this._fetch(bs);
|
|
4895
5208
|
}
|
|
4896
5209
|
/**
|
|
4897
5210
|
* Every project owned by `orgId`, regardless of the caller's membership.
|
|
@@ -4899,11 +5212,11 @@ class me {
|
|
|
4899
5212
|
* membership) this is what lets a superadmin open a foreign org's projects.
|
|
4900
5213
|
*/
|
|
4901
5214
|
listOrgProjects(t) {
|
|
4902
|
-
return this._fetch(
|
|
5215
|
+
return this._fetch(_s(t));
|
|
4903
5216
|
}
|
|
4904
5217
|
/** Every user holding the `superadmin` custom claim. */
|
|
4905
5218
|
listSuperadmins() {
|
|
4906
|
-
return this._fetch(
|
|
5219
|
+
return this._fetch(Is);
|
|
4907
5220
|
}
|
|
4908
5221
|
/**
|
|
4909
5222
|
* Deletes the Auth account and profile doc, and scrubs every org/project
|
|
@@ -4912,22 +5225,22 @@ class me {
|
|
|
4912
5225
|
* teardown, not normal superadmin use, since a hard delete cannot be undone.
|
|
4913
5226
|
*/
|
|
4914
5227
|
deleteUser(t, e = !1) {
|
|
4915
|
-
return this._fetch(`${
|
|
5228
|
+
return this._fetch(`${xs(t)}${e ? "?hard=true" : ""}`, { method: "DELETE" });
|
|
4916
5229
|
}
|
|
4917
5230
|
/**
|
|
4918
5231
|
* Undoes `deleteUser`: recreates the Auth account (same uid) and profile doc,
|
|
4919
5232
|
* and re-grants the recorded org/project roles where those still exist.
|
|
4920
5233
|
*/
|
|
4921
5234
|
restoreUser(t) {
|
|
4922
|
-
return this._fetch(
|
|
5235
|
+
return this._fetch(ks(t), { method: "POST" });
|
|
4923
5236
|
}
|
|
4924
5237
|
/** Every archived deletion, restored or not — newest first. */
|
|
4925
5238
|
listDeletedUsers() {
|
|
4926
|
-
return this._fetch(
|
|
5239
|
+
return this._fetch(Cs);
|
|
4927
5240
|
}
|
|
4928
5241
|
/** Creates a Firebase Auth account with no organisation — for picking as a new org's initial admin. */
|
|
4929
5242
|
createAdminUser(t) {
|
|
4930
|
-
return this._fetch(
|
|
5243
|
+
return this._fetch(Os, {
|
|
4931
5244
|
method: "POST",
|
|
4932
5245
|
headers: { "Content-Type": "application/json" },
|
|
4933
5246
|
body: JSON.stringify(t)
|
|
@@ -4935,15 +5248,15 @@ class me {
|
|
|
4935
5248
|
}
|
|
4936
5249
|
/** Grants the `superadmin` custom claim. The user must sign in again for it to take effect. */
|
|
4937
5250
|
grantSuperadmin(t) {
|
|
4938
|
-
return this._fetch(
|
|
5251
|
+
return this._fetch(Ft(t), { method: "PUT" });
|
|
4939
5252
|
}
|
|
4940
5253
|
/** Revokes the `superadmin` custom claim. */
|
|
4941
5254
|
revokeSuperadmin(t) {
|
|
4942
|
-
return this._fetch(
|
|
5255
|
+
return this._fetch(Ft(t), { method: "DELETE" });
|
|
4943
5256
|
}
|
|
4944
5257
|
/** Creates a new organisation with `adminUserId` as its sole admin/member. */
|
|
4945
5258
|
createOrganization(t) {
|
|
4946
|
-
return this._fetch(
|
|
5259
|
+
return this._fetch(Rs, {
|
|
4947
5260
|
method: "POST",
|
|
4948
5261
|
headers: { "Content-Type": "application/json" },
|
|
4949
5262
|
body: JSON.stringify(t)
|
|
@@ -4951,7 +5264,7 @@ class me {
|
|
|
4951
5264
|
}
|
|
4952
5265
|
/** Sets an organisation's allowed email domains for auto-join sign-up. */
|
|
4953
5266
|
setOrgDomains(t, e) {
|
|
4954
|
-
return this._fetch(
|
|
5267
|
+
return this._fetch(Ps(t), {
|
|
4955
5268
|
method: "PUT",
|
|
4956
5269
|
headers: { "Content-Type": "application/json" },
|
|
4957
5270
|
body: JSON.stringify({ domains: e })
|
|
@@ -4965,42 +5278,42 @@ class me {
|
|
|
4965
5278
|
* snapshot, same as a direct `deleteUser`).
|
|
4966
5279
|
*/
|
|
4967
5280
|
deleteOrganization(t) {
|
|
4968
|
-
return this._fetch(
|
|
5281
|
+
return this._fetch(As(t), { method: "DELETE" });
|
|
4969
5282
|
}
|
|
4970
5283
|
/** Undoes `deleteOrganization`: restores cascaded projects/users where they still can be, then un-flags the org. */
|
|
4971
5284
|
restoreOrganization(t) {
|
|
4972
|
-
return this._fetch(
|
|
5285
|
+
return this._fetch($s(t), { method: "POST" });
|
|
4973
5286
|
}
|
|
4974
5287
|
/** Every soft-deleted organisation, restored or not — newest first. */
|
|
4975
5288
|
listDeletedOrganizations() {
|
|
4976
|
-
return this._fetch(
|
|
5289
|
+
return this._fetch(Ds);
|
|
4977
5290
|
}
|
|
4978
5291
|
/** Users belonging to no organisation — a data-health diagnostic, not paginated. */
|
|
4979
5292
|
listUsersWithoutOrg() {
|
|
4980
|
-
return this._fetch(
|
|
5293
|
+
return this._fetch(Ns);
|
|
4981
5294
|
}
|
|
4982
5295
|
/** Users belonging to no project — a data-health diagnostic, not paginated. */
|
|
4983
5296
|
listUsersWithoutProject() {
|
|
4984
|
-
return this._fetch(
|
|
5297
|
+
return this._fetch(js);
|
|
4985
5298
|
}
|
|
4986
5299
|
/** Projects with no members, syncers, or admins — a data-health diagnostic. */
|
|
4987
5300
|
listProjectsWithoutUsers() {
|
|
4988
|
-
return this._fetch(
|
|
5301
|
+
return this._fetch(Ls);
|
|
4989
5302
|
}
|
|
4990
5303
|
/** Projects with no admin (may still have members/syncers) — a data-health diagnostic. */
|
|
4991
5304
|
listProjectsWithoutAdmins() {
|
|
4992
|
-
return this._fetch(
|
|
5305
|
+
return this._fetch(Us);
|
|
4993
5306
|
}
|
|
4994
5307
|
/** Organisations with no members — a data-health diagnostic. */
|
|
4995
5308
|
listOrgsWithoutUsers() {
|
|
4996
|
-
return this._fetch(
|
|
5309
|
+
return this._fetch(Ms);
|
|
4997
5310
|
}
|
|
4998
5311
|
/** Organisations with no admin (may still have members) — a data-health diagnostic. */
|
|
4999
5312
|
listOrgsWithoutAdmins() {
|
|
5000
|
-
return this._fetch(
|
|
5313
|
+
return this._fetch(Fs);
|
|
5001
5314
|
}
|
|
5002
5315
|
}
|
|
5003
|
-
const
|
|
5316
|
+
const he = ["superadmin", "admin", "syncer", "member"], de = {
|
|
5004
5317
|
createEntities: "admin",
|
|
5005
5318
|
createProvider: "superadmin",
|
|
5006
5319
|
changeContentCategories: "syncer",
|
|
@@ -5025,7 +5338,7 @@ const we = ["superadmin", "admin", "syncer", "member"], fe = {
|
|
|
5025
5338
|
viewUsageStats: "superadmin",
|
|
5026
5339
|
viewEntities: "member"
|
|
5027
5340
|
};
|
|
5028
|
-
function
|
|
5341
|
+
function ei() {
|
|
5029
5342
|
return {
|
|
5030
5343
|
changeContentCategories: !1,
|
|
5031
5344
|
createEntities: !1,
|
|
@@ -5053,9 +5366,9 @@ function Ua() {
|
|
|
5053
5366
|
viewEntities: !1
|
|
5054
5367
|
};
|
|
5055
5368
|
}
|
|
5056
|
-
class
|
|
5369
|
+
class ue {
|
|
5057
5370
|
constructor(t) {
|
|
5058
|
-
this._isSuperAdmin = t, this._projectRoles = new
|
|
5371
|
+
this._isSuperAdmin = t, this._projectRoles = new E([]), this._orgRole = new E(null), this.privileges = St(
|
|
5059
5372
|
[this._projectRoles, this._orgRole, t],
|
|
5060
5373
|
() => this._compute()
|
|
5061
5374
|
);
|
|
@@ -5092,21 +5405,21 @@ class ye {
|
|
|
5092
5405
|
_expand(t) {
|
|
5093
5406
|
if (this._isSuperAdmin.get())
|
|
5094
5407
|
return ["superadmin", "admin", "syncer", "member"];
|
|
5095
|
-
const e =
|
|
5096
|
-
return e === -1 ? [] : Array.from(
|
|
5408
|
+
const e = he.findIndex((o) => t.includes(o));
|
|
5409
|
+
return e === -1 ? [] : Array.from(he.slice(e));
|
|
5097
5410
|
}
|
|
5098
5411
|
_compute() {
|
|
5099
|
-
const t = this._projectRoles.get(), e = this._isSuperAdmin.get(), o =
|
|
5100
|
-
for (const s of Object.keys(
|
|
5101
|
-
o[s] = t.includes(
|
|
5412
|
+
const t = this._projectRoles.get(), e = this._isSuperAdmin.get(), o = ei();
|
|
5413
|
+
for (const s of Object.keys(de))
|
|
5414
|
+
o[s] = t.includes(de[s]);
|
|
5102
5415
|
return o.createProject = e || this._orgRole.get() === "admin", o;
|
|
5103
5416
|
}
|
|
5104
5417
|
}
|
|
5105
|
-
class
|
|
5418
|
+
class ge {
|
|
5106
5419
|
constructor(t) {
|
|
5107
|
-
this.
|
|
5420
|
+
this._blob = t;
|
|
5108
5421
|
}
|
|
5109
|
-
|
|
5422
|
+
_blob;
|
|
5110
5423
|
// ── Query cache ────────────────────────────────────────────────────────────
|
|
5111
5424
|
async getQueryCache(t, e) {
|
|
5112
5425
|
return this._get(`portal/projects/${t}/queries`, e);
|
|
@@ -5134,22 +5447,19 @@ class be {
|
|
|
5134
5447
|
}
|
|
5135
5448
|
// ── Internal helpers ───────────────────────────────────────────────────────
|
|
5136
5449
|
async _get(t, e) {
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
if (Ma(o)) return;
|
|
5151
|
-
throw o;
|
|
5152
|
-
}
|
|
5450
|
+
const o = await this._blob.getFile("persistence", `${t}/${e}.json.gz`);
|
|
5451
|
+
if (!o) return;
|
|
5452
|
+
const s = await o.arrayBuffer(), a = new DecompressionStream("gzip"), i = a.writable.getWriter(), n = a.readable.getReader();
|
|
5453
|
+
i.write(new Uint8Array(s)), i.close();
|
|
5454
|
+
const c = [];
|
|
5455
|
+
let p = await n.read();
|
|
5456
|
+
for (; !p.done; )
|
|
5457
|
+
c.push(p.value), p = await n.read();
|
|
5458
|
+
const h = c.reduce((m, w) => m + w.length, 0), d = new Uint8Array(h);
|
|
5459
|
+
let u = 0;
|
|
5460
|
+
for (const m of c)
|
|
5461
|
+
d.set(m, u), u += m.length;
|
|
5462
|
+
return JSON.parse(new TextDecoder().decode(d));
|
|
5153
5463
|
}
|
|
5154
5464
|
async _set(t, e, o) {
|
|
5155
5465
|
const s = new TextEncoder().encode(JSON.stringify(o)), a = new CompressionStream("gzip"), i = a.writable.getWriter(), n = a.readable.getReader();
|
|
@@ -5162,18 +5472,17 @@ class be {
|
|
|
5162
5472
|
let u = 0;
|
|
5163
5473
|
for (const m of c)
|
|
5164
5474
|
d.set(m, u), u += m.length;
|
|
5165
|
-
await
|
|
5166
|
-
|
|
5475
|
+
await this._blob.uploadBytes(
|
|
5476
|
+
"persistence",
|
|
5477
|
+
`${t}/${e}.json.gz`,
|
|
5167
5478
|
d,
|
|
5168
|
-
|
|
5479
|
+
void 0,
|
|
5480
|
+
"application/gzip"
|
|
5169
5481
|
);
|
|
5170
5482
|
}
|
|
5171
5483
|
}
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
}
|
|
5175
|
-
const vi = ["CHF", "DKK", "EUR"], Ei = "CHF", qa = 3600 * 1e3, Fa = "https://api.frankfurter.dev/v1/latest?from=CHF&to=DKK,EUR";
|
|
5176
|
-
class _e {
|
|
5484
|
+
const Li = ["CHF", "DKK", "EUR"], Ui = "CHF", oi = 3600 * 1e3, si = "https://api.frankfurter.dev/v1/latest?from=CHF&to=DKK,EUR";
|
|
5485
|
+
class me {
|
|
5177
5486
|
_cached = null;
|
|
5178
5487
|
_pending = null;
|
|
5179
5488
|
/**
|
|
@@ -5183,7 +5492,7 @@ class _e {
|
|
|
5183
5492
|
* throwing — a transient network blip shouldn't break the pricing UI.
|
|
5184
5493
|
*/
|
|
5185
5494
|
async getRates(t = !1) {
|
|
5186
|
-
return !t && this._cached && Date.now() - this._cached.fetchedAt <
|
|
5495
|
+
return !t && this._cached && Date.now() - this._cached.fetchedAt < oi ? this._cached : this._pending ? this._pending : (this._pending = this._fetchRates().then((e) => (this._cached = e, e)).catch((e) => {
|
|
5187
5496
|
if (this._cached) return this._cached;
|
|
5188
5497
|
throw e;
|
|
5189
5498
|
}).finally(() => {
|
|
@@ -5191,7 +5500,7 @@ class _e {
|
|
|
5191
5500
|
}), this._pending);
|
|
5192
5501
|
}
|
|
5193
5502
|
async _fetchRates() {
|
|
5194
|
-
const t = await fetch(
|
|
5503
|
+
const t = await fetch(si);
|
|
5195
5504
|
if (!t.ok)
|
|
5196
5505
|
throw new Error(`Failed to fetch exchange rates: ${t.status} ${t.statusText}`);
|
|
5197
5506
|
const e = await t.json();
|
|
@@ -5231,7 +5540,7 @@ const b = {
|
|
|
5231
5540
|
dicu: "https://w3id.org/digitalconstruction/0.5/Units#",
|
|
5232
5541
|
diclvl: "https://w3id.org/digitalconstruction/0.5/Levels#",
|
|
5233
5542
|
dicstg: "https://w3id.org/digitalconstruction/0.5/Stages#"
|
|
5234
|
-
},
|
|
5543
|
+
}, O = {
|
|
5235
5544
|
madsrdf: "http://www.loc.gov/mads/rdf/v1#",
|
|
5236
5545
|
bflc: "http://id.loc.gov/ontologies/bflc/",
|
|
5237
5546
|
foaf: "http://xmlns.com/foaf/0.1/",
|
|
@@ -8459,12 +8768,12 @@ const b = {
|
|
|
8459
8768
|
fbsp: "http://purl.obolibrary.org/obo/FBSP_",
|
|
8460
8769
|
rex: "http://purl.obolibrary.org/obo/REX_"
|
|
8461
8770
|
};
|
|
8462
|
-
class
|
|
8771
|
+
class D {
|
|
8463
8772
|
static _instance;
|
|
8464
8773
|
// Opposite map is built once
|
|
8465
8774
|
_nsMap;
|
|
8466
8775
|
static getInstance() {
|
|
8467
|
-
return this._instance ? this._instance : (this._instance = new
|
|
8776
|
+
return this._instance ? this._instance : (this._instance = new D(), this._instance);
|
|
8468
8777
|
}
|
|
8469
8778
|
compactIRI(t) {
|
|
8470
8779
|
let e = this._nsMap;
|
|
@@ -8480,17 +8789,17 @@ class j {
|
|
|
8480
8789
|
return s === void 0 ? t : t.replace(o, `${s}:`);
|
|
8481
8790
|
}
|
|
8482
8791
|
expandIRI(t) {
|
|
8483
|
-
const e = t.split(":")[0], o =
|
|
8792
|
+
const e = t.split(":")[0], o = O[e] ?? b[e];
|
|
8484
8793
|
return t.replace(`${e}:`, o);
|
|
8485
8794
|
}
|
|
8486
8795
|
_buildNSMap() {
|
|
8487
8796
|
const t = {};
|
|
8488
|
-
return Object.keys(
|
|
8797
|
+
return Object.keys(O).forEach((e) => t[O[e]] = e), Object.keys(b).forEach(
|
|
8489
8798
|
(e) => t[b[e]] = e
|
|
8490
8799
|
), this._nsMap = t, t;
|
|
8491
8800
|
}
|
|
8492
8801
|
}
|
|
8493
|
-
const
|
|
8802
|
+
const we = `${b.qcy}ContentCategory`, fe = `${b.qcy}EntityCategory`, ye = `${b.qcy}relatedEntity`, ri = `PREFIX view: <https://qlever.cs.uni-freiburg.de/materializedView/>
|
|
8494
8803
|
SELECT ?iri ?type ?parent ?deprecated ?label ?definition
|
|
8495
8804
|
WHERE {
|
|
8496
8805
|
SERVICE view:schemas {
|
|
@@ -8502,9 +8811,9 @@ WHERE {
|
|
|
8502
8811
|
view:column-definition ?definition .
|
|
8503
8812
|
}
|
|
8504
8813
|
}`;
|
|
8505
|
-
class
|
|
8814
|
+
class ai {
|
|
8506
8815
|
constructor(t, e, o, s, a) {
|
|
8507
|
-
this._api = t, this._projectId = e, this._graphType = s, this._verbose = a ?? !1, this._currentLang = o, this._api.setLanguage(o), this._contentCategories = new
|
|
8816
|
+
this._api = t, this._projectId = e, this._graphType = s, this._verbose = a ?? !1, this._currentLang = o, this._api.setLanguage(o), this._contentCategories = new E([]), this._entityCategories = new E([]), this._relationships = new E([]), this.availableContentCategories = this._contentCategories.asReadonly(), this.availableEntityCategories = this._entityCategories.asReadonly(), this.availableEntityRelationships = this._relationships.asReadonly(), this.ready = this._load().catch(
|
|
8508
8817
|
(i) => console.error("[CueProjectSchema] Initial load failed:", i)
|
|
8509
8818
|
);
|
|
8510
8819
|
}
|
|
@@ -8563,7 +8872,7 @@ class Ba {
|
|
|
8563
8872
|
*/
|
|
8564
8873
|
async createContentCategory(t) {
|
|
8565
8874
|
const e = await this._api.semanticTemplate.createContentCategory(this._projectId, t);
|
|
8566
|
-
return this._appendCreated("contentCategories", this._contentCategories,
|
|
8875
|
+
return this._appendCreated("contentCategories", this._contentCategories, we, t, e);
|
|
8567
8876
|
}
|
|
8568
8877
|
/**
|
|
8569
8878
|
* Creates a new entity category via `cue.api.semanticTemplate` and, on success,
|
|
@@ -8572,7 +8881,7 @@ class Ba {
|
|
|
8572
8881
|
*/
|
|
8573
8882
|
async createEntityCategory(t) {
|
|
8574
8883
|
const e = await this._api.semanticTemplate.createEntityCategory(this._projectId, t);
|
|
8575
|
-
return this._appendCreated("entityCategories", this._entityCategories,
|
|
8884
|
+
return this._appendCreated("entityCategories", this._entityCategories, fe, t, e);
|
|
8576
8885
|
}
|
|
8577
8886
|
/**
|
|
8578
8887
|
* Creates a new entity relationship via `cue.api.semanticTemplate` and, on
|
|
@@ -8581,7 +8890,7 @@ class Ba {
|
|
|
8581
8890
|
*/
|
|
8582
8891
|
async createEntityRelationship(t) {
|
|
8583
8892
|
const e = await this._api.semanticTemplate.createEntityRelationship(this._projectId, t);
|
|
8584
|
-
return this._appendCreated("relationships", this._relationships,
|
|
8893
|
+
return this._appendCreated("relationships", this._relationships, ye, t, e);
|
|
8585
8894
|
}
|
|
8586
8895
|
// ── Private helpers ─────────────────────────────────────────────────────────
|
|
8587
8896
|
/**
|
|
@@ -8595,9 +8904,9 @@ class Ba {
|
|
|
8595
8904
|
_appendCreated(t, e, o, s, a) {
|
|
8596
8905
|
if (!a.success || !a.iri) return null;
|
|
8597
8906
|
const i = s.label ? { ...s.label } : {};
|
|
8598
|
-
|
|
8907
|
+
W(i);
|
|
8599
8908
|
const n = s.definition ? { ...s.definition } : s.description ? { default: s.description } : {};
|
|
8600
|
-
|
|
8909
|
+
W(n);
|
|
8601
8910
|
const c = {
|
|
8602
8911
|
iri: a.iri,
|
|
8603
8912
|
type: o,
|
|
@@ -8634,7 +8943,7 @@ class Ba {
|
|
|
8634
8943
|
*/
|
|
8635
8944
|
async _fetchSnapshot() {
|
|
8636
8945
|
if (this._graphType !== "fuseki") {
|
|
8637
|
-
const e = await this._runSchemaQuery(
|
|
8946
|
+
const e = await this._runSchemaQuery(ri);
|
|
8638
8947
|
if (e.contentCategories.length + e.entityCategories.length + e.relationships.length > 0) return e;
|
|
8639
8948
|
console.warn(
|
|
8640
8949
|
`[CueProjectSchema] Materialized view "schemas" returned no rows for project ${this._projectId} — falling back to the live schema query.`
|
|
@@ -8654,7 +8963,7 @@ class Ba {
|
|
|
8654
8963
|
}
|
|
8655
8964
|
/** Projects a language-independent {@link SchemaNode} into a {@link CategoryDef}. */
|
|
8656
8965
|
_toDef(t, e) {
|
|
8657
|
-
const o =
|
|
8966
|
+
const o = ve(t.labels, e) ?? t.iri.split("#").at(-1) ?? t.iri, s = ve(t.definitions, e), a = Object.keys(t.definitions).length > 0;
|
|
8658
8967
|
return {
|
|
8659
8968
|
iri: t.iri,
|
|
8660
8969
|
label: o,
|
|
@@ -8672,9 +8981,9 @@ class Ba {
|
|
|
8672
8981
|
*/
|
|
8673
8982
|
_buildSchemaQuery() {
|
|
8674
8983
|
return `PREFIX qcy: <${b.qcy}>
|
|
8675
|
-
PREFIX skos: <${
|
|
8676
|
-
PREFIX rdfs: <${
|
|
8677
|
-
PREFIX owl: <${
|
|
8984
|
+
PREFIX skos: <${O.skos}>
|
|
8985
|
+
PREFIX rdfs: <${O.rdfs}>
|
|
8986
|
+
PREFIX owl: <${O.owl}>
|
|
8678
8987
|
SELECT ?iri ?type ?parent ?deprecated ?label ?definition
|
|
8679
8988
|
WHERE {
|
|
8680
8989
|
{
|
|
@@ -8709,7 +9018,7 @@ WHERE {
|
|
|
8709
9018
|
let c = o.get(i);
|
|
8710
9019
|
c || (c = { iri: i, type: n, labels: {}, definitions: {} }, o.set(i, c)), c.parent === void 0 && a.parent?.value && (c.parent = a.parent.value);
|
|
8711
9020
|
const p = a.deprecated?.value;
|
|
8712
|
-
p !== void 0 && (c.deprecated = p === "true" || p === "1"),
|
|
9021
|
+
p !== void 0 && (c.deprecated = p === "true" || p === "1"), be(c.labels, a.label), be(c.definitions, a.definition);
|
|
8713
9022
|
}
|
|
8714
9023
|
const s = {
|
|
8715
9024
|
contentCategories: [],
|
|
@@ -8717,16 +9026,16 @@ WHERE {
|
|
|
8717
9026
|
relationships: []
|
|
8718
9027
|
};
|
|
8719
9028
|
for (const a of o.values())
|
|
8720
|
-
|
|
9029
|
+
W(a.labels), W(a.definitions), a.type === we ? s.contentCategories.push(a) : a.type === fe ? s.entityCategories.push(a) : a.type === ye && s.relationships.push(a);
|
|
8721
9030
|
return s;
|
|
8722
9031
|
}
|
|
8723
9032
|
}
|
|
8724
|
-
function
|
|
9033
|
+
function be(r, t) {
|
|
8725
9034
|
if (!t || t.value === void 0) return;
|
|
8726
9035
|
const e = t["xml:lang"], o = e && e.length > 0 ? e : "default";
|
|
8727
9036
|
r[o] === void 0 && (r[o] = t.value);
|
|
8728
9037
|
}
|
|
8729
|
-
function
|
|
9038
|
+
function W(r) {
|
|
8730
9039
|
if (r.en !== void 0) {
|
|
8731
9040
|
r.default = r.en;
|
|
8732
9041
|
return;
|
|
@@ -8735,12 +9044,12 @@ function Y(r) {
|
|
|
8735
9044
|
const t = Object.values(r)[0];
|
|
8736
9045
|
t !== void 0 && (r.default = t);
|
|
8737
9046
|
}
|
|
8738
|
-
function
|
|
9047
|
+
function ve(r, t) {
|
|
8739
9048
|
return r[t] ?? r.default;
|
|
8740
9049
|
}
|
|
8741
|
-
const
|
|
8742
|
-
class
|
|
8743
|
-
constructor(t, e, o =
|
|
9050
|
+
const ii = "https://qlever.dev/api/osm-planet";
|
|
9051
|
+
class Be {
|
|
9052
|
+
constructor(t, e, o = Tt, s, a = !1) {
|
|
8744
9053
|
this._api = t, this._projectId = e, this._graphType = s, this._verbose = a, this.baseURL = `${o}${e}/`, this.entityInfoMap = this._entityInfoMapComputed, this.entityGraph = this._entityGraph.asReadonly(), this._entityOSMMap.subscribe(() => this._checkPendingOSMFetches()), this._fetchEntityGraph().catch(
|
|
8745
9054
|
(i) => console.error("[CueProjectEntities] Entity graph fetch failed:", i)
|
|
8746
9055
|
);
|
|
@@ -8752,17 +9061,17 @@ class Ye {
|
|
|
8752
9061
|
/** Full RDF base URL for this project, e.g. `https://cue.qaecy.com/r/{pid}/` */
|
|
8753
9062
|
baseURL;
|
|
8754
9063
|
// ── Internal writable slices ───────────────────────────────────────────────
|
|
8755
|
-
_entityDetails = new
|
|
8756
|
-
_entityDocuments = new
|
|
9064
|
+
_entityDetails = new E({});
|
|
9065
|
+
_entityDocuments = new E(
|
|
8757
9066
|
{}
|
|
8758
9067
|
);
|
|
8759
|
-
_entityRelationships = new
|
|
8760
|
-
_entityOSMMap = new
|
|
8761
|
-
_osmWKTMap = new
|
|
9068
|
+
_entityRelationships = new E({});
|
|
9069
|
+
_entityOSMMap = new E({});
|
|
9070
|
+
_osmWKTMap = new E({});
|
|
8762
9071
|
_fetchingOSMIds = /* @__PURE__ */ new Set();
|
|
8763
9072
|
/** Cumulative unique entity UUIDs ever passed to request methods (survives cache hits). */
|
|
8764
9073
|
_seenIds = /* @__PURE__ */ new Set();
|
|
8765
|
-
_entityGraph = new
|
|
9074
|
+
_entityGraph = new E(void 0);
|
|
8766
9075
|
/**
|
|
8767
9076
|
* Memoizes the raw category-summary rows per neighbourhood (keyed by the
|
|
8768
9077
|
* expanded `entityIRI`, or `''` for the full graph) so that repeat/concurrent
|
|
@@ -8971,7 +9280,7 @@ WHERE {
|
|
|
8971
9280
|
*/
|
|
8972
9281
|
async contentCategoriesInProject(t = !0) {
|
|
8973
9282
|
const e = this._api.language, o = `PREFIX qcy: <${b.qcy}>
|
|
8974
|
-
PREFIX skos: <${
|
|
9283
|
+
PREFIX skos: <${O.skos}>
|
|
8975
9284
|
SELECT ?iri (SAMPLE(?l) AS ?label) ?count
|
|
8976
9285
|
WHERE {
|
|
8977
9286
|
?iri a qcy:EntityCategory .
|
|
@@ -8996,7 +9305,7 @@ ORDER BY ${t ? "DESC(?count)" : "ASC(?label)"}`;
|
|
|
8996
9305
|
}
|
|
8997
9306
|
async entitiesByCategory(t, e = !1) {
|
|
8998
9307
|
if (t.length === 0) return [];
|
|
8999
|
-
const o =
|
|
9308
|
+
const o = D.getInstance(), s = (c) => c.startsWith("http://") || c.startsWith("https://") ? c : o.expandIRI(c), a = t.map((c) => `<${s(c)}>`).join(" "), i = e ? `PREFIX qcy: <${b.qcy}>
|
|
9000
9309
|
SELECT ?id (SAMPLE(?val) AS ?value) (GROUP_CONCAT(DISTINCT STR(?allCat); SEPARATOR=";") AS ?categories)
|
|
9001
9310
|
WHERE {
|
|
9002
9311
|
VALUES ?filterCat { ${a} }
|
|
@@ -9050,7 +9359,7 @@ WHERE {
|
|
|
9050
9359
|
*/
|
|
9051
9360
|
async prototypeCategories() {
|
|
9052
9361
|
const t = this._api.language, e = `PREFIX qcy: <${b.qcy}>
|
|
9053
|
-
PREFIX skos: <${
|
|
9362
|
+
PREFIX skos: <${O.skos}>
|
|
9054
9363
|
SELECT ?iri ?count (SAMPLE(?l) AS ?label)
|
|
9055
9364
|
WHERE {
|
|
9056
9365
|
{ SELECT ?iri (COUNT(DISTINCT ?prototype) AS ?count)
|
|
@@ -9084,7 +9393,7 @@ ORDER BY DESC(?count)`;
|
|
|
9084
9393
|
* Accepts both a full HTTP IRI and a prefixed form (`qcy-e:Door`).
|
|
9085
9394
|
*/
|
|
9086
9395
|
async prototypesByCategory(t) {
|
|
9087
|
-
const e =
|
|
9396
|
+
const e = D.getInstance(), o = t.includes("://") ? t : e.expandIRI(t), s = `PREFIX qcy: <${b.qcy}>
|
|
9088
9397
|
SELECT ?iri (SAMPLE(?val) AS ?value) (COUNT(DISTINCT ?occurrence) AS ?instanceCount)
|
|
9089
9398
|
WHERE {
|
|
9090
9399
|
?iri a qcy:EntityPrototype ;
|
|
@@ -9337,7 +9646,7 @@ LIMIT 1`, a = (await this._api.sparql(
|
|
|
9337
9646
|
* ```
|
|
9338
9647
|
*/
|
|
9339
9648
|
async categoryExpressIds(t) {
|
|
9340
|
-
const e =
|
|
9649
|
+
const e = D.getInstance(), o = t.includes("://") ? t : e.expandIRI(t), s = `PREFIX qcy: <${b.qcy}>
|
|
9341
9650
|
SELECT DISTINCT ?prototype ?entity ?model ?expressId
|
|
9342
9651
|
WHERE {
|
|
9343
9652
|
?prototype a qcy:EntityPrototype ;
|
|
@@ -9370,7 +9679,7 @@ WHERE {
|
|
|
9370
9679
|
}).sort((n, c) => c.expressIds.length - n.expressIds.length);
|
|
9371
9680
|
}
|
|
9372
9681
|
async buildSummaryGraph(t, e, o) {
|
|
9373
|
-
const s =
|
|
9682
|
+
const s = D.getInstance(), a = e ? e.includes("://") ? e : s.expandIRI(e) : void 0, i = a ? ` FILTER(?sourceCat = <${a}> || ?targetCat = <${a}>)` : "", n = ` ?s a qcy:CanonicalEntity ;
|
|
9374
9683
|
qcy:hasEntityCategory ?sourceCat .
|
|
9375
9684
|
?o a qcy:CanonicalEntity ;
|
|
9376
9685
|
qcy:hasEntityCategory ?targetCat .
|
|
@@ -9404,8 +9713,8 @@ ORDER BY DESC(?weight)`, p = `${a ?? ""}|${o ?? ""}`;
|
|
|
9404
9713
|
if (t === "graph") {
|
|
9405
9714
|
const m = /* @__PURE__ */ new Set(), w = [];
|
|
9406
9715
|
for (const y of u) {
|
|
9407
|
-
const g = y.sourceCat.value, _ = y.predicate.value,
|
|
9408
|
-
m.add(g), m.add(
|
|
9716
|
+
const g = y.sourceCat.value, _ = y.predicate.value, S = y.targetCat.value, v = parseInt(y.weight.value, 10);
|
|
9717
|
+
m.add(g), m.add(S), w.push({ sourceID: g, predicate: _, targetID: S, weight: v });
|
|
9409
9718
|
}
|
|
9410
9719
|
let f;
|
|
9411
9720
|
if (!o)
|
|
@@ -9565,9 +9874,9 @@ ORDER BY DESC(?weight)`;
|
|
|
9565
9874
|
for (const { osm: f, viaRels: y, entityUUID: g } of h.indirect) {
|
|
9566
9875
|
const _ = a[f];
|
|
9567
9876
|
if (_)
|
|
9568
|
-
for (const
|
|
9569
|
-
const v = `${
|
|
9570
|
-
|
|
9877
|
+
for (const S of y) {
|
|
9878
|
+
const v = `${S}:${g}`, I = w.get(v) ?? { geometries: [], entityUUID: g };
|
|
9879
|
+
I.geometries.some((N) => N.osmIRI === f) || (I.geometries.push({ osmIRI: f, wkt: _ }), w.set(v, I));
|
|
9571
9880
|
}
|
|
9572
9881
|
}
|
|
9573
9882
|
w.size > 0 && (u = Array.from(w.entries()).map(
|
|
@@ -9711,10 +10020,10 @@ GROUP BY ?e1Cat ?e2Cat`, e = await this._api.sparql(
|
|
|
9711
10020
|
async _fetchOSMLocations(t) {
|
|
9712
10021
|
const e = t.filter((n) => !n.includes("/relation/"));
|
|
9713
10022
|
if (e.length === 0) return;
|
|
9714
|
-
const o = e.map((n) => `<${n}>`).join(" "), s = `PREFIX geo: <${
|
|
10023
|
+
const o = e.map((n) => `<${n}>`).join(" "), s = `PREFIX geo: <${O.geo}>
|
|
9715
10024
|
SELECT * WHERE {
|
|
9716
10025
|
VALUES ?s { ${o} }
|
|
9717
|
-
SERVICE <${
|
|
10026
|
+
SERVICE <${ii}> {
|
|
9718
10027
|
?s geo:hasGeometry/geo:asWKT ?wkt
|
|
9719
10028
|
}
|
|
9720
10029
|
}`, a = await this._api.sparql(
|
|
@@ -9728,7 +10037,7 @@ SELECT * WHERE {
|
|
|
9728
10037
|
}
|
|
9729
10038
|
}
|
|
9730
10039
|
var l = /* @__PURE__ */ ((r) => (r.AUTOMATION = "automation", r.ARCHIVE = "archive", r.AUDIO = "audio", r.BACKUP = "backup", r.BINARY = "binary", r.BIM = "bim", r.CAD = "cad", r.DATA = "data", r.EMAIL = "email", r.FONT = "font", r.GEOSPATIAL = "geospatial", r.IMAGE = "image", r.INSTALLER = "installer", r.MARKUP = "markup", r.MULTIMEDIA = "multimedia", r.PLANNING = "planning", r.PRESENTATION = "presentation", r.SCRIPT = "script", r.SPREADSHEET = "spreadsheet", r.TEXT = "text", r.THREE_D = "3d", r.UNKNOWN = "unknown", r.VIDEO = "video", r))(l || {});
|
|
9731
|
-
const
|
|
10040
|
+
const _t = {
|
|
9732
10041
|
".aac": {
|
|
9733
10042
|
type: l.AUDIO,
|
|
9734
10043
|
open: !0,
|
|
@@ -10589,15 +10898,15 @@ const Et = {
|
|
|
10589
10898
|
}
|
|
10590
10899
|
};
|
|
10591
10900
|
l.AUDIO + "", l.VIDEO + "", l.IMAGE + "", l.TEXT + "", l.MARKUP + "", l.SCRIPT + "", l.DATA + "", l.ARCHIVE + "", l.INSTALLER + "", l.BINARY + "", l.BACKUP + "", l.AUTOMATION + "", l.PRESENTATION + "", l.SPREADSHEET + "", l.FONT + "", l.GEOSPATIAL + "", l.THREE_D + "", l.CAD + "", l.BIM + "", l.PLANNING + "", l.EMAIL + "", l.MULTIMEDIA + "", l.UNKNOWN + "";
|
|
10592
|
-
var
|
|
10593
|
-
const
|
|
10901
|
+
var ni = /* @__PURE__ */ ((r) => (r.ENTITY = "e", r.CONTENT = "c", r.RELATION = "p", r.MIME = "m", r))(ni || {}), ci = /* @__PURE__ */ ((r) => (r.ENTITY = "entity", r.CONTENT = "content", r.RELATION = "relation", r.MIME = "mime", r))(ci || {}), pi = /* @__PURE__ */ ((r) => (r.CATALOG = "catalog", r.PARSER = "parser", r.PROJECT = "project", r.CODING_SCHEME = "coding_scheme", r.SUGGESTED = "suggested", r))(pi || {}), li = /* @__PURE__ */ ((r) => (r.OPEN = "open", r.SEEDED = "seeded", r.CLOSED = "closed", r))(li || {}), hi = /* @__PURE__ */ ((r) => (r.VALUE_TYPED = "value_typed", r.NAME_TYPED = "name_typed", r.EXPLICIT_ONLY = "explicit_only", r))(hi || {}), di = /* @__PURE__ */ ((r) => (r.IDENTIFIER = "identifier", r.ATTRIBUTE = "attribute", r.IGNORE = "ignore", r))(di || {}), ui = /* @__PURE__ */ ((r) => (r.VALUE = "value", r.VALUE_AND_CONTEXT = "value_and_context", r.CONTEXT = "context", r))(ui || {});
|
|
10902
|
+
const kt = "https://cue.qaecy.com/", gi = {
|
|
10594
10903
|
qcy: "https://dev.qaecy.com/ont#",
|
|
10595
10904
|
"qcy-e": "https://dev.qaecy.com/enum#"
|
|
10596
|
-
},
|
|
10597
|
-
const t = r.indexOf(":"), e =
|
|
10905
|
+
}, mi = (r) => r.includes(":"), Ge = (r, t, e, o = kt) => `${o}${t}/${e}/${r}`, wi = (r) => {
|
|
10906
|
+
const t = r.indexOf(":"), e = gi[r.slice(0, t)];
|
|
10598
10907
|
if (!e) throw new Error(`\`${r}\` is not a reference into a core prefix`);
|
|
10599
10908
|
return `${e}${r.slice(t + 1)}`;
|
|
10600
|
-
},
|
|
10909
|
+
}, Mi = (r, t, e, o = kt) => mi(r) ? wi(r) : Ge(r, t, e, o), Fi = (r, t, e, o = kt) => r.iri ?? Ge(r.key, t, e, o), fi = (r) => `${r.base}r/`, qi = (r) => `${fi(r)}${r.projectId}/schema`, yi = `PREFIX view: <https://qlever.cs.uni-freiburg.de/materializedView/>
|
|
10601
10910
|
SELECT ?ext ?totalSize ?docCount
|
|
10602
10911
|
WHERE {
|
|
10603
10912
|
SERVICE view:docs-by-suffix {
|
|
@@ -10605,7 +10914,7 @@ WHERE {
|
|
|
10605
10914
|
view:column-totalSize ?totalSize ;
|
|
10606
10915
|
view:column-docCount ?docCount .
|
|
10607
10916
|
}
|
|
10608
|
-
}`,
|
|
10917
|
+
}`, bi = `PREFIX view: <https://qlever.cs.uni-freiburg.de/materializedView/>
|
|
10609
10918
|
SELECT ?cat ?totalSize ?docCount
|
|
10610
10919
|
WHERE {
|
|
10611
10920
|
SERVICE view:docs-by-category {
|
|
@@ -10613,15 +10922,15 @@ WHERE {
|
|
|
10613
10922
|
view:column-totalSize ?totalSize ;
|
|
10614
10923
|
view:column-docCount ?docCount .
|
|
10615
10924
|
}
|
|
10616
|
-
}`,
|
|
10925
|
+
}`, vi = `PREFIX view: <https://qlever.cs.uni-freiburg.de/materializedView/>
|
|
10617
10926
|
SELECT ?count
|
|
10618
10927
|
WHERE {
|
|
10619
10928
|
SERVICE view:doc-duplicates {
|
|
10620
10929
|
_:cfg view:column-count ?count .
|
|
10621
10930
|
}
|
|
10622
10931
|
}`;
|
|
10623
|
-
class
|
|
10624
|
-
constructor(t, e, o, s =
|
|
10932
|
+
class Et {
|
|
10933
|
+
constructor(t, e, o, s = Tt, a, i = !1) {
|
|
10625
10934
|
this._api = t, this._projectId = e, this._graphType = a, this._verbose = i, this.baseURL = `${s}${e}/`, this._currentLang = o ?? this._api.language, this.documentInfoMap = this._documentInfoMap.asReadonly(), this.projectDocumentsData = this._projectDocumentsData.asReadonly();
|
|
10626
10935
|
}
|
|
10627
10936
|
_api;
|
|
@@ -10632,10 +10941,10 @@ class Tt {
|
|
|
10632
10941
|
baseURL;
|
|
10633
10942
|
/** Tracks the language for which `_documentInfoMap` is currently populated. */
|
|
10634
10943
|
_currentLang;
|
|
10635
|
-
_documentInfoMap = new
|
|
10944
|
+
_documentInfoMap = new E({});
|
|
10636
10945
|
/** Cumulative unique document UUIDs ever passed to request methods (survives cache hits). */
|
|
10637
10946
|
_seenIds = /* @__PURE__ */ new Set();
|
|
10638
|
-
_projectDocumentsData = new
|
|
10947
|
+
_projectDocumentsData = new E({
|
|
10639
10948
|
duplicateCount: 0,
|
|
10640
10949
|
documentsBySuffix: {},
|
|
10641
10950
|
documentsByContentCategory: {}
|
|
@@ -10834,7 +11143,7 @@ WHERE {
|
|
|
10834
11143
|
});
|
|
10835
11144
|
}
|
|
10836
11145
|
documentsByFileType(t, e = !1) {
|
|
10837
|
-
const o = new Set(t), s = Object.values(
|
|
11146
|
+
const o = new Set(t), s = Object.values(_t).filter((a) => o.has(a.type)).map((a) => a.suffix);
|
|
10838
11147
|
return this.documentsBySuffix(s, e);
|
|
10839
11148
|
}
|
|
10840
11149
|
async documentsByContentCategory(t, e = !1) {
|
|
@@ -10872,7 +11181,7 @@ WHERE {
|
|
|
10872
11181
|
});
|
|
10873
11182
|
}
|
|
10874
11183
|
documentsByMime(t, e = !1) {
|
|
10875
|
-
const o = new Set(t), s = Object.values(
|
|
11184
|
+
const o = new Set(t), s = Object.values(_t).filter((a) => o.has(a.mime)).map((a) => a.suffix);
|
|
10876
11185
|
return this.documentsBySuffix(s, e);
|
|
10877
11186
|
}
|
|
10878
11187
|
// ── Private helpers ────────────────────────────────────────────────────────
|
|
@@ -10964,7 +11273,7 @@ GROUP BY ?id ?suffix ?size`, s = await this._api.sparql(o, this._projectId, this
|
|
|
10964
11273
|
}
|
|
10965
11274
|
async _fetchDocumentsBySuffix() {
|
|
10966
11275
|
if (this._graphType !== "fuseki") {
|
|
10967
|
-
const e = await this._runDocumentsBySuffixQuery(
|
|
11276
|
+
const e = await this._runDocumentsBySuffixQuery(yi);
|
|
10968
11277
|
if (Object.keys(e).length > 0) return e;
|
|
10969
11278
|
console.warn(`[CueProjectDocuments] Materialized view "docs-by-suffix" returned no rows for project ${this._projectId} — falling back to live query.`);
|
|
10970
11279
|
}
|
|
@@ -10998,7 +11307,7 @@ ORDER BY DESC(?docCount)`;
|
|
|
10998
11307
|
}
|
|
10999
11308
|
async _fetchDocumentsByContentCategory() {
|
|
11000
11309
|
if (this._graphType !== "fuseki") {
|
|
11001
|
-
const e = await this._runDocumentsByContentCategoryQuery(
|
|
11310
|
+
const e = await this._runDocumentsByContentCategoryQuery(bi);
|
|
11002
11311
|
if (Object.keys(e).length > 0) return e;
|
|
11003
11312
|
console.warn(`[CueProjectDocuments] Materialized view "docs-by-category" returned no rows for project ${this._projectId} — falling back to live query.`);
|
|
11004
11313
|
}
|
|
@@ -11032,7 +11341,7 @@ ORDER BY DESC(?docCount)`;
|
|
|
11032
11341
|
}
|
|
11033
11342
|
async _fetchDuplicateCount() {
|
|
11034
11343
|
if (this._graphType !== "fuseki") {
|
|
11035
|
-
const e = await this._api.sparql(
|
|
11344
|
+
const e = await this._api.sparql(vi, this._projectId, this._graphType);
|
|
11036
11345
|
if (e.results.bindings.length > 0) {
|
|
11037
11346
|
const o = e.results.bindings[0];
|
|
11038
11347
|
return o?.count ? parseInt(o.count.value, 10) : 0;
|
|
@@ -11060,9 +11369,9 @@ WHERE {
|
|
|
11060
11369
|
return o?.count ? parseInt(o.count.value, 10) : 0;
|
|
11061
11370
|
}
|
|
11062
11371
|
}
|
|
11063
|
-
class
|
|
11064
|
-
constructor(t, e, { language: o, rdfBase: s =
|
|
11065
|
-
this._api = t, this._projectId = e, this.schema = new
|
|
11372
|
+
class _i {
|
|
11373
|
+
constructor(t, e, { language: o, rdfBase: s = Tt, graphType: a, verbose: i }) {
|
|
11374
|
+
this._api = t, this._projectId = e, this.schema = new ai(t, e, o, a, i), this.entities = new Be(t, e, s, a, i), this.documents = new Et(t, e, o, s, a, i), this.availableContentCategories = this.schema.availableContentCategories, this.availableEntityCategories = this.schema.availableEntityCategories, this.availableEntityRelationships = this.schema.availableEntityRelationships, this.schemaReady = this.schema.ready, this.entityInfoMap = this.entities.entityInfoMap, this.entityGraph = this.entities.entityGraph, this.documentInfoMap = this.documents.documentInfoMap, this.projectDocumentsData = this.documents.projectDocumentsData, this.searchResults = this._searchResults.asReadonly(), this.documents.fetchOverview().catch((n) => console.error("[CueProjectView] fetchOverview failed:", n));
|
|
11066
11375
|
}
|
|
11067
11376
|
_api;
|
|
11068
11377
|
_projectId;
|
|
@@ -11093,7 +11402,7 @@ class ai {
|
|
|
11093
11402
|
/** Project document overview (counts by suffix and category). Fetched on init. */
|
|
11094
11403
|
projectDocumentsData;
|
|
11095
11404
|
// ── Search state ───────────────────────────────────────────────────────────
|
|
11096
|
-
_searchResults = new
|
|
11405
|
+
_searchResults = new E(void 0);
|
|
11097
11406
|
/** The result of the most recent `search()` call. `undefined` before first search. */
|
|
11098
11407
|
searchResults;
|
|
11099
11408
|
_destroyed = !1;
|
|
@@ -11193,7 +11502,7 @@ class ai {
|
|
|
11193
11502
|
this._destroyed = !0, this._searchResults.set(void 0);
|
|
11194
11503
|
}
|
|
11195
11504
|
}
|
|
11196
|
-
function
|
|
11505
|
+
function _e(r, t) {
|
|
11197
11506
|
return new Promise((e) => {
|
|
11198
11507
|
const o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
11199
11508
|
for (const g of r)
|
|
@@ -11228,7 +11537,7 @@ function Ce(r, t) {
|
|
|
11228
11537
|
});
|
|
11229
11538
|
});
|
|
11230
11539
|
}
|
|
11231
|
-
const
|
|
11540
|
+
const Ee = {
|
|
11232
11541
|
ä: "ae",
|
|
11233
11542
|
ä: "ae",
|
|
11234
11543
|
Ä: "AE",
|
|
@@ -11262,27 +11571,27 @@ const xe = {
|
|
|
11262
11571
|
þ: "th",
|
|
11263
11572
|
Þ: "Th"
|
|
11264
11573
|
};
|
|
11265
|
-
function
|
|
11574
|
+
function He(r, t = !1) {
|
|
11266
11575
|
const e = "daca0510-72b5-48ba-9091-b918ca18136b";
|
|
11267
|
-
return r =
|
|
11576
|
+
return r = Ei(r, t), To(r, e);
|
|
11268
11577
|
}
|
|
11269
|
-
function
|
|
11578
|
+
function Ei(r, t = !1) {
|
|
11270
11579
|
let e = r;
|
|
11271
|
-
for (const o in
|
|
11272
|
-
e = e.replace(new RegExp(o, "g"),
|
|
11580
|
+
for (const o in Ee)
|
|
11581
|
+
e = e.replace(new RegExp(o, "g"), Ee[o]);
|
|
11273
11582
|
return t && e !== r && console.info(`${r} -> ${e}`), e;
|
|
11274
11583
|
}
|
|
11275
|
-
function
|
|
11276
|
-
return
|
|
11584
|
+
function Ti(r, t = "") {
|
|
11585
|
+
return He(`${t}${r}`);
|
|
11277
11586
|
}
|
|
11278
|
-
function
|
|
11587
|
+
function Si(r) {
|
|
11279
11588
|
const t = r.split(".");
|
|
11280
11589
|
return t.length > 1 ? "." + t.pop()?.toLowerCase() : "";
|
|
11281
11590
|
}
|
|
11282
|
-
function
|
|
11283
|
-
const p =
|
|
11284
|
-
i === void 0 && (i =
|
|
11285
|
-
const u =
|
|
11591
|
+
function Te(r, t, e, o, s, a, i, n = !1, c = !1) {
|
|
11592
|
+
const p = Si(r), h = He(o), d = `${t}/${h}${p}`;
|
|
11593
|
+
i === void 0 && (i = _t[p]?.mime ?? "application/octet-stream");
|
|
11594
|
+
const u = Ti(r, s);
|
|
11286
11595
|
return {
|
|
11287
11596
|
name: r,
|
|
11288
11597
|
blob_name: d,
|
|
@@ -11302,48 +11611,48 @@ function ke(r, t, e, o, s, a, i, n = !1, c = !1) {
|
|
|
11302
11611
|
})
|
|
11303
11612
|
};
|
|
11304
11613
|
}
|
|
11305
|
-
async function
|
|
11614
|
+
async function q() {
|
|
11306
11615
|
return import(
|
|
11307
11616
|
/* webpackIgnore: true */
|
|
11308
11617
|
"fs/promises"
|
|
11309
11618
|
);
|
|
11310
11619
|
}
|
|
11311
|
-
async function
|
|
11620
|
+
async function Se(r) {
|
|
11312
11621
|
if (typeof window < "u")
|
|
11313
11622
|
throw new Error(
|
|
11314
11623
|
`Cannot read file from path "${r}" in a browser environment. Provide file.data (Uint8Array) instead.`
|
|
11315
11624
|
);
|
|
11316
|
-
const { readFile: t } = await
|
|
11625
|
+
const { readFile: t } = await q();
|
|
11317
11626
|
return t(r);
|
|
11318
11627
|
}
|
|
11319
|
-
let
|
|
11320
|
-
function
|
|
11321
|
-
|
|
11628
|
+
let F = null, Y = null, J = null;
|
|
11629
|
+
function zi(r) {
|
|
11630
|
+
J = r, Y = null, F = null;
|
|
11322
11631
|
}
|
|
11323
|
-
async function
|
|
11632
|
+
async function Ii() {
|
|
11324
11633
|
if (typeof window < "u") {
|
|
11325
|
-
if (!
|
|
11634
|
+
if (!J)
|
|
11326
11635
|
throw new Error(
|
|
11327
11636
|
"WASM scanner is not configured for browser use. Call configureScanWasm(baseUrl) during app initialisation."
|
|
11328
11637
|
);
|
|
11329
|
-
const r = await fetch(`${
|
|
11638
|
+
const r = await fetch(`${J}/dir_scanner_wasm_bg.wasm`);
|
|
11330
11639
|
if (!r.ok)
|
|
11331
11640
|
throw new Error(`Failed to fetch WASM binary: ${r.status} ${r.statusText}`);
|
|
11332
|
-
const t = new Uint8Array(await r.arrayBuffer()), o = await import(`${
|
|
11333
|
-
await o.default({ module_or_path: t }),
|
|
11641
|
+
const t = new Uint8Array(await r.arrayBuffer()), o = await import(`${J}/dir_scanner_wasm.mjs`);
|
|
11642
|
+
await o.default({ module_or_path: t }), F = o.scan;
|
|
11334
11643
|
} else {
|
|
11335
|
-
const { readFile: r } = await
|
|
11644
|
+
const { readFile: r } = await q(), { join: t } = await import(
|
|
11336
11645
|
/* webpackIgnore: true */
|
|
11337
11646
|
"path"
|
|
11338
11647
|
), { pathToFileURL: e } = await import(
|
|
11339
11648
|
/* webpackIgnore: true */
|
|
11340
11649
|
"url"
|
|
11341
11650
|
), o = t(__dirname, "assets", "wasm"), s = await r(t(o, "dir_scanner_wasm_bg.wasm")), i = await import(e(t(o, "dir_scanner_wasm.mjs")).href);
|
|
11342
|
-
await i.default({ module_or_path: s }),
|
|
11651
|
+
await i.default({ module_or_path: s }), F = i.scan;
|
|
11343
11652
|
}
|
|
11344
11653
|
}
|
|
11345
|
-
const
|
|
11346
|
-
async function
|
|
11654
|
+
const Ci = "qlever", V = 1e3, Ot = "cue:pending:";
|
|
11655
|
+
async function Rt(r) {
|
|
11347
11656
|
const { tmpdir: t } = await import(
|
|
11348
11657
|
/* webpackIgnore: true */
|
|
11349
11658
|
"os"
|
|
@@ -11353,37 +11662,37 @@ async function At(r) {
|
|
|
11353
11662
|
);
|
|
11354
11663
|
return e(t(), `cue-sync-pending-${r}.json`);
|
|
11355
11664
|
}
|
|
11356
|
-
async function
|
|
11665
|
+
async function Ie(r) {
|
|
11357
11666
|
if (typeof window < "u") {
|
|
11358
11667
|
const t = window.localStorage.getItem(`${Ot}${r}`);
|
|
11359
11668
|
return t ? JSON.parse(t) : null;
|
|
11360
11669
|
}
|
|
11361
11670
|
try {
|
|
11362
|
-
const t = await (await
|
|
11671
|
+
const t = await (await q()).readFile(await Rt(r), "utf-8");
|
|
11363
11672
|
return JSON.parse(t);
|
|
11364
11673
|
} catch {
|
|
11365
11674
|
return null;
|
|
11366
11675
|
}
|
|
11367
11676
|
}
|
|
11368
|
-
async function
|
|
11677
|
+
async function Ce(r) {
|
|
11369
11678
|
const t = JSON.stringify(r);
|
|
11370
11679
|
if (typeof window < "u") {
|
|
11371
11680
|
window.localStorage.setItem(`${Ot}${r.spaceId}`, t);
|
|
11372
11681
|
return;
|
|
11373
11682
|
}
|
|
11374
|
-
await (await
|
|
11683
|
+
await (await q()).writeFile(await Rt(r.spaceId), t, "utf-8");
|
|
11375
11684
|
}
|
|
11376
|
-
async function
|
|
11685
|
+
async function xi(r) {
|
|
11377
11686
|
if (typeof window < "u") {
|
|
11378
11687
|
window.localStorage.removeItem(`${Ot}${r}`);
|
|
11379
11688
|
return;
|
|
11380
11689
|
}
|
|
11381
11690
|
try {
|
|
11382
|
-
await (await
|
|
11691
|
+
await (await q()).unlink(await Rt(r));
|
|
11383
11692
|
} catch {
|
|
11384
11693
|
}
|
|
11385
11694
|
}
|
|
11386
|
-
class
|
|
11695
|
+
class xe {
|
|
11387
11696
|
constructor(t, e, o, s) {
|
|
11388
11697
|
this._auth = t, this._projects = e, this._blob = o, this._gatewayUrl = s;
|
|
11389
11698
|
}
|
|
@@ -11458,8 +11767,8 @@ class $e {
|
|
|
11458
11767
|
providerId: e.providerId,
|
|
11459
11768
|
fileContentExists: !1
|
|
11460
11769
|
}));
|
|
11461
|
-
for (let s = 0; s < o.length; s +=
|
|
11462
|
-
await this._postFssBatch(o.slice(s, s +
|
|
11770
|
+
for (let s = 0; s < o.length; s += V)
|
|
11771
|
+
await this._postFssBatch(o.slice(s, s + V), e.spaceId);
|
|
11463
11772
|
e.verbose && console.info(`Pushed metadata for ${o.length} file(s) ✅`);
|
|
11464
11773
|
}
|
|
11465
11774
|
/**
|
|
@@ -11469,7 +11778,7 @@ class $e {
|
|
|
11469
11778
|
*/
|
|
11470
11779
|
async flushPendingMetadata(t, e, o) {
|
|
11471
11780
|
this._legacy = o ?? !1;
|
|
11472
|
-
const s = await
|
|
11781
|
+
const s = await Ie(t);
|
|
11473
11782
|
if (!(!s || s.items.length === 0)) {
|
|
11474
11783
|
console.info(`Trying to upload metadata (${s.items.length} item(s))...`), e && console.info(`Flushing ${s.items.length} pending file location(s) from previous sync ⏳`);
|
|
11475
11784
|
try {
|
|
@@ -11492,20 +11801,20 @@ class $e {
|
|
|
11492
11801
|
this._getAvailableCredits(c?.organizationID),
|
|
11493
11802
|
this._fetchUnitCreditMap(a),
|
|
11494
11803
|
this._fetchTierNames()
|
|
11495
|
-
]), w = await
|
|
11804
|
+
]), w = await _e(t, h), f = w.localNotOnRemote ?? [], y = f.length > 0 ? await this.scanCost(f) : [];
|
|
11496
11805
|
let g = 0, _ = 0;
|
|
11497
11806
|
for (const v of y) {
|
|
11498
11807
|
g += v.units;
|
|
11499
|
-
const
|
|
11500
|
-
a &&
|
|
11501
|
-
const
|
|
11502
|
-
_ +=
|
|
11808
|
+
const I = u[p], N = I?.[v.ext] ?? 1;
|
|
11809
|
+
a && I && !(v.ext in I) && console.info(` Unknown format: .${v.ext} (using default rate of 1 credit/unit)`);
|
|
11810
|
+
const T = v.units * N;
|
|
11811
|
+
_ += T, v.credits = Math.round(T);
|
|
11503
11812
|
}
|
|
11504
|
-
const
|
|
11813
|
+
const S = m[p] ?? p;
|
|
11505
11814
|
return {
|
|
11506
11815
|
costRecords: y,
|
|
11507
11816
|
tier: p,
|
|
11508
|
-
tierName:
|
|
11817
|
+
tierName: S,
|
|
11509
11818
|
unitsToConsume: g,
|
|
11510
11819
|
creditsToConsume: Math.round(_),
|
|
11511
11820
|
creditsAvailable: d.creditsAvailable,
|
|
@@ -11525,77 +11834,77 @@ class $e {
|
|
|
11525
11834
|
const [m, w] = await Promise.all([
|
|
11526
11835
|
this._listRemoteFiles(h, o, s, i),
|
|
11527
11836
|
this._getAvailableCredits(d?.organizationID)
|
|
11528
|
-
]), { unitsAvailable: f } = w, y = await
|
|
11837
|
+
]), { unitsAvailable: f } = w, y = await _e(t, m);
|
|
11529
11838
|
i && (console.info(`Total local files: ${t.length}`), console.info(`Total remote files: ${m.length}`), console.info(
|
|
11530
11839
|
`Total files to sync: ${(y.localNotOnRemote?.length ?? 0) + y.localNotOnRemotePathOnly.length}`
|
|
11531
11840
|
));
|
|
11532
|
-
let g = y.syncCount, _ = y.syncSize,
|
|
11533
|
-
const
|
|
11534
|
-
if (
|
|
11535
|
-
const R = (await this.scanCost(
|
|
11841
|
+
let g = y.syncCount, _ = y.syncSize, S = 0, v = !1;
|
|
11842
|
+
const I = y.localNotOnRemote ?? [];
|
|
11843
|
+
if (I.length > 0) {
|
|
11844
|
+
const R = (await this.scanCost(I)).reduce((et, Xe) => et + Xe.units, 0);
|
|
11536
11845
|
if (R > f)
|
|
11537
11846
|
throw new Error(
|
|
11538
11847
|
`Insufficient units: ${R} units required but only ${f} available.`
|
|
11539
11848
|
);
|
|
11540
11849
|
}
|
|
11541
|
-
await this._initPendingBatch(o, i), i &&
|
|
11542
|
-
for (const
|
|
11850
|
+
await this._initPendingBatch(o, i), i && I.length && console.info("Syncing missing files ⏳");
|
|
11851
|
+
for (const T of I)
|
|
11543
11852
|
try {
|
|
11544
|
-
const R =
|
|
11545
|
-
|
|
11853
|
+
const R = Te(
|
|
11854
|
+
T.relativePath,
|
|
11546
11855
|
o,
|
|
11547
11856
|
a,
|
|
11548
|
-
|
|
11857
|
+
T.md5,
|
|
11549
11858
|
s
|
|
11550
11859
|
);
|
|
11551
|
-
if (!R.blob_name) throw new Error(`blob_name missing for ${
|
|
11552
|
-
const
|
|
11860
|
+
if (!R.blob_name) throw new Error(`blob_name missing for ${T.relativePath}`);
|
|
11861
|
+
const et = T.data ?? new Uint8Array(await Se(T.fullPath));
|
|
11553
11862
|
await this._blob.uploadRaw(
|
|
11554
11863
|
R.blob_name,
|
|
11555
|
-
|
|
11864
|
+
et,
|
|
11556
11865
|
R,
|
|
11557
11866
|
3,
|
|
11558
11867
|
void 0,
|
|
11559
11868
|
void 0,
|
|
11560
11869
|
u
|
|
11561
11870
|
), await this._queueFileLocation({
|
|
11562
|
-
relativePath:
|
|
11563
|
-
md5:
|
|
11564
|
-
size:
|
|
11871
|
+
relativePath: T.relativePath,
|
|
11872
|
+
md5: T.md5,
|
|
11873
|
+
size: T.size,
|
|
11565
11874
|
providerId: s,
|
|
11566
11875
|
fileContentExists: !1
|
|
11567
|
-
}), v = !0, g += 1, _ +=
|
|
11876
|
+
}), v = !0, g += 1, _ += T.size || 0, this._logProgress(g, y.totalCount, _, y.totalSize, n);
|
|
11568
11877
|
} catch (R) {
|
|
11569
|
-
|
|
11878
|
+
S += 1, console.error(`[CueSyncApi] Failed to upload file: ${T.fullPath}`), i && console.error("[CueSyncApi] Upload error details:", R);
|
|
11570
11879
|
}
|
|
11571
11880
|
i && y.localNotOnRemotePathOnly.length && console.info(`Syncing missing file locations (on provider "${s}") ⏳`);
|
|
11572
|
-
for (const
|
|
11881
|
+
for (const T of y.localNotOnRemotePathOnly)
|
|
11573
11882
|
await this._queueFileLocation({
|
|
11574
|
-
relativePath:
|
|
11575
|
-
md5:
|
|
11576
|
-
size:
|
|
11883
|
+
relativePath: T.relativePath,
|
|
11884
|
+
md5: T.md5,
|
|
11885
|
+
size: T.size,
|
|
11577
11886
|
providerId: s,
|
|
11578
11887
|
fileContentExists: !0
|
|
11579
|
-
}), v = !0, g += 1, _ +=
|
|
11888
|
+
}), v = !0, g += 1, _ += T.size || 0, this._logProgress(g, y.totalCount, _, y.totalSize, n);
|
|
11580
11889
|
await this._drainPending(i), this._stopFlushTimer();
|
|
11581
|
-
const
|
|
11890
|
+
const N = await this._getAvailableCredits(d?.organizationID);
|
|
11582
11891
|
return {
|
|
11583
11892
|
syncCount: g,
|
|
11584
11893
|
syncSize: _,
|
|
11585
|
-
failedUploads:
|
|
11894
|
+
failedUploads: S,
|
|
11586
11895
|
totalCount: y.totalCount,
|
|
11587
11896
|
totalSize: y.totalSize,
|
|
11588
11897
|
rdfWritten: v,
|
|
11589
|
-
creditsAvailable:
|
|
11898
|
+
creditsAvailable: N.creditsAvailable
|
|
11590
11899
|
};
|
|
11591
11900
|
}
|
|
11592
11901
|
async _getOrCreateGraph(t, e) {
|
|
11593
11902
|
const o = this._graphMap.get(t);
|
|
11594
11903
|
if (o) return o;
|
|
11595
|
-
const s = new
|
|
11596
|
-
graphType:
|
|
11597
|
-
queryEndpoint: `${this._gatewayUrl}${
|
|
11598
|
-
updateEndpoint: `${this._gatewayUrl}${
|
|
11904
|
+
const s = new Ro({
|
|
11905
|
+
graphType: Ci,
|
|
11906
|
+
queryEndpoint: `${this._gatewayUrl}${Pe}`,
|
|
11907
|
+
updateEndpoint: `${this._gatewayUrl}${er}`,
|
|
11599
11908
|
originalHeaders: {
|
|
11600
11909
|
"x-project-id": t,
|
|
11601
11910
|
authorization: `Bearer ${e}`
|
|
@@ -11658,7 +11967,7 @@ WHERE {
|
|
|
11658
11967
|
}
|
|
11659
11968
|
async _initPendingBatch(t, e) {
|
|
11660
11969
|
this._flushTimer !== null && (clearInterval(this._flushTimer), this._flushTimer = null), this._pendingSpaceId = t, this._pendingItems = [];
|
|
11661
|
-
const o = await
|
|
11970
|
+
const o = await Ie(t);
|
|
11662
11971
|
if (o && o.items.length > 0) {
|
|
11663
11972
|
console.info(`Trying to upload metadata from interrupted sync (${o.items.length} item(s))...`), e && console.info(`Flushing ${o.items.length} pending file location(s) from previous sync ⏳`);
|
|
11664
11973
|
try {
|
|
@@ -11679,7 +11988,7 @@ WHERE {
|
|
|
11679
11988
|
typeof s == "object" && typeof s.unref == "function" && s.unref(), this._flushTimer = s;
|
|
11680
11989
|
}
|
|
11681
11990
|
async _queueFileLocation(t) {
|
|
11682
|
-
this._pendingItems.push(t), this._pendingSpaceId && await
|
|
11991
|
+
this._pendingItems.push(t), this._pendingSpaceId && await Ce({ spaceId: this._pendingSpaceId, items: this._pendingItems });
|
|
11683
11992
|
}
|
|
11684
11993
|
/**
|
|
11685
11994
|
* Flush all queued file-location items to the commands API in a single batch.
|
|
@@ -11704,18 +12013,18 @@ WHERE {
|
|
|
11704
12013
|
}
|
|
11705
12014
|
async _flushBatch(t, e, o) {
|
|
11706
12015
|
const s = [...t];
|
|
11707
|
-
this._pendingSpaceId === e && (this._pendingItems = []), await
|
|
12016
|
+
this._pendingSpaceId === e && (this._pendingItems = []), await xi(e);
|
|
11708
12017
|
try {
|
|
11709
|
-
for (let a = 0; a < s.length; a +=
|
|
11710
|
-
await this._postFssBatch(s.slice(a, a +
|
|
12018
|
+
for (let a = 0; a < s.length; a += V)
|
|
12019
|
+
await this._postFssBatch(s.slice(a, a + V), e);
|
|
11711
12020
|
o && console.info(`Wrote ${s.length} file location(s) to commands API ✅`);
|
|
11712
12021
|
} catch (a) {
|
|
11713
12022
|
const i = [...s, ...this._pendingItems];
|
|
11714
|
-
throw this._pendingItems = i, await
|
|
12023
|
+
throw this._pendingItems = i, await Ce({ spaceId: e, items: i }), a;
|
|
11715
12024
|
}
|
|
11716
12025
|
}
|
|
11717
12026
|
async _postFssBatch(t, e) {
|
|
11718
|
-
const o = this._legacy ? `${this._gatewayUrl}${
|
|
12027
|
+
const o = this._legacy ? `${this._gatewayUrl}${zt}?blob=true` : `${this._gatewayUrl}${zt}`;
|
|
11719
12028
|
let s;
|
|
11720
12029
|
try {
|
|
11721
12030
|
s = await this._auth.authenticatedFetch(o, {
|
|
@@ -11745,16 +12054,16 @@ WHERE {
|
|
|
11745
12054
|
* shown to the user before or after calling {@link sync}.
|
|
11746
12055
|
*/
|
|
11747
12056
|
async scanCost(t) {
|
|
11748
|
-
if (
|
|
12057
|
+
if (Y || (Y = Ii()), await Y, !F) throw new Error("WASM scan function not initialised");
|
|
11749
12058
|
const e = 200, o = /* @__PURE__ */ new Map();
|
|
11750
12059
|
for (let s = 0; s < t.length; s += e) {
|
|
11751
12060
|
const a = t.slice(s, s + e), i = await Promise.all(
|
|
11752
12061
|
a.map(async (c) => ({
|
|
11753
12062
|
originalPath: c.relativePath,
|
|
11754
12063
|
// Use pre-loaded data if available (browser), otherwise read from disk (Node.js).
|
|
11755
|
-
data: c.data ?? new Uint8Array(await
|
|
12064
|
+
data: c.data ?? new Uint8Array(await Se(c.fullPath))
|
|
11756
12065
|
}))
|
|
11757
|
-
), n =
|
|
12066
|
+
), n = F(i);
|
|
11758
12067
|
for (const c of n) {
|
|
11759
12068
|
const p = o.get(c.ext);
|
|
11760
12069
|
p ? (p.count += c.count, p.units += c.units, p.sizeMb += c.sizeMb) : o.set(c.ext, { ...c });
|
|
@@ -11817,7 +12126,7 @@ WHERE {
|
|
|
11817
12126
|
const { spaceId: o, providerId: s, userId: a, signal: i, onProgress: n, skipProcessing: c = !1 } = e;
|
|
11818
12127
|
if (!t.data)
|
|
11819
12128
|
throw new Error("syncBrowserFile requires file.data (Uint8Array). Read the file with File.arrayBuffer() first.");
|
|
11820
|
-
const p =
|
|
12129
|
+
const p = Te(
|
|
11821
12130
|
t.relativePath,
|
|
11822
12131
|
o,
|
|
11823
12132
|
a,
|
|
@@ -11886,7 +12195,7 @@ WHERE {
|
|
|
11886
12195
|
a({ percent: i, syncCount: t, totalCount: e, syncSize: o, totalSize: s });
|
|
11887
12196
|
}
|
|
11888
12197
|
}
|
|
11889
|
-
const
|
|
12198
|
+
const ke = {
|
|
11890
12199
|
production: {
|
|
11891
12200
|
gatewayUrl: "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app",
|
|
11892
12201
|
tokenUrl: "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app/token",
|
|
@@ -11902,7 +12211,7 @@ const Pe = {
|
|
|
11902
12211
|
storageEmulatorPort: 9199
|
|
11903
12212
|
}
|
|
11904
12213
|
};
|
|
11905
|
-
class
|
|
12214
|
+
class We {
|
|
11906
12215
|
auth;
|
|
11907
12216
|
signup;
|
|
11908
12217
|
api;
|
|
@@ -11914,12 +12223,15 @@ class Ke {
|
|
|
11914
12223
|
privileges;
|
|
11915
12224
|
cache;
|
|
11916
12225
|
storage;
|
|
11917
|
-
currency = new
|
|
12226
|
+
currency = new me();
|
|
11918
12227
|
_app;
|
|
11919
12228
|
_endpoints;
|
|
11920
12229
|
_isEmulator;
|
|
11921
|
-
|
|
11922
|
-
|
|
12230
|
+
/**
|
|
12231
|
+
* Object storage, per bucket on Firebase Storage or the gateway (see
|
|
12232
|
+
* `CueSdkConfig.storage`). What sync, data sources and the cache use.
|
|
12233
|
+
*/
|
|
12234
|
+
blob;
|
|
11923
12235
|
_gis = null;
|
|
11924
12236
|
_projectDocuments = /* @__PURE__ */ new Map();
|
|
11925
12237
|
_verbose;
|
|
@@ -11935,7 +12247,7 @@ class Ke {
|
|
|
11935
12247
|
* ```
|
|
11936
12248
|
*/
|
|
11937
12249
|
get gis() {
|
|
11938
|
-
return this._gis || (this._gis = new
|
|
12250
|
+
return this._gis || (this._gis = new ti(
|
|
11939
12251
|
() => this.api.getAuthHeaders(),
|
|
11940
12252
|
this._endpoints.gatewayUrl
|
|
11941
12253
|
)), this._gis;
|
|
@@ -11945,28 +12257,18 @@ class Ke {
|
|
|
11945
12257
|
"Using default SDK app settings. Contact QAECY for your own configuration for any production code."
|
|
11946
12258
|
);
|
|
11947
12259
|
const o = t.apiKey ?? it.apiKey, s = t.appId ?? it.appId, a = t.measurementId ?? it.measurementId, i = t.environment ?? "production";
|
|
11948
|
-
this._endpoints = { ...
|
|
12260
|
+
this._endpoints = { ...ke[i], ...t.endpoints }, this._isEmulator = i === "emulator", this._verbose = t.verbose ?? !1;
|
|
11949
12261
|
const n = i === "production" ? "[DEFAULT]" : `cue-${i}`;
|
|
11950
|
-
this._app =
|
|
12262
|
+
this._app = Ye().find((p) => p.name === n) ?? Je({
|
|
11951
12263
|
apiKey: o,
|
|
11952
12264
|
appId: s,
|
|
11953
12265
|
measurementId: a,
|
|
11954
12266
|
authDomain: `${Nt}.firebaseapp.com`,
|
|
11955
12267
|
projectId: Nt,
|
|
11956
|
-
messagingSenderId:
|
|
11957
|
-
}, n), this.auth = new
|
|
11958
|
-
const c =
|
|
11959
|
-
this.
|
|
11960
|
-
const m = new F({
|
|
11961
|
-
storageRaw: this._storageRaw,
|
|
11962
|
-
storageProcessed: this._storageProcessed,
|
|
11963
|
-
storagePublic: c,
|
|
11964
|
-
storageLogs: p,
|
|
11965
|
-
storageChatSessions: h,
|
|
11966
|
-
storagePersistence: d,
|
|
11967
|
-
storageSessions: u
|
|
11968
|
-
});
|
|
11969
|
-
this.api = this._buildApi(this.projects, m), this.storage = new te(this.auth, this._endpoints.gatewayUrl), this.profile = new ue(this.auth, this._endpoints.gatewayUrl), this.usageStats = new ge(this.auth, this._endpoints.gatewayUrl), this.api.sync?._bindProfile(this.profile), this.admin = new me(this.auth, this._endpoints.gatewayUrl), this.privileges = new ye(this.auth.isSuperAdmin), this._isEmulator && W(d, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), this.cache = new be(d);
|
|
12268
|
+
messagingSenderId: qo
|
|
12269
|
+
}, n), this.auth = new Vt(this._app, this._isEmulator, this._endpoints), this.signup = new Xt(this._endpoints.gatewayUrl), this.projects = new ne(this.auth, this._endpoints);
|
|
12270
|
+
const c = Wt(this._app, this.auth, this._endpoints, t.storage, this._isEmulator);
|
|
12271
|
+
this.blob = c, this.api = this._buildApi(this.projects, c), this.storage = new Yt(this.auth, this._endpoints.gatewayUrl), this.profile = new ce(this.auth, this._endpoints.gatewayUrl), this.usageStats = new pe(this.auth, this._endpoints.gatewayUrl), this.api.sync?._bindProfile(this.profile), this.admin = new le(this.auth, this._endpoints.gatewayUrl), this.privileges = new ue(this.auth.isSuperAdmin), this.cache = new ge(c);
|
|
11970
12272
|
}
|
|
11971
12273
|
/**
|
|
11972
12274
|
* Create a `Cue` instance from an already-initialized Firebase app.
|
|
@@ -11985,40 +12287,31 @@ class Ke {
|
|
|
11985
12287
|
* });
|
|
11986
12288
|
*/
|
|
11987
12289
|
static fromApp(t, e = {}) {
|
|
11988
|
-
const o = e.environment ?? "production", s = { ...
|
|
11989
|
-
|
|
11990
|
-
|
|
11991
|
-
|
|
11992
|
-
|
|
11993
|
-
|
|
11994
|
-
storagePersistence: m,
|
|
11995
|
-
storageSessions: w
|
|
11996
|
-
}), y = new $e(a, n, f, s.gatewayUrl), g = new re(a, s.gatewayUrl, n, y, f);
|
|
11997
|
-
y._bindApi(g);
|
|
11998
|
-
const _ = new ue(a, s.gatewayUrl);
|
|
11999
|
-
y._bindProfile(_);
|
|
12000
|
-
const I = new ge(a, s.gatewayUrl), v = new me(a, s.gatewayUrl), C = Object.create(Ke.prototype), $ = new ye(a.isSuperAdmin), E = new be(m), R = new te(a, s.gatewayUrl), L = new _e();
|
|
12001
|
-
return Object.assign(C, {
|
|
12290
|
+
const o = e.environment ?? "production", s = { ...ke[o], ...e.endpoints }, a = new Vt(t, !1, s), i = new Xt(s.gatewayUrl), n = new ne(a, s), c = Wt(t, a, s, e.storage), p = new xe(a, n, c, s.gatewayUrl), h = new Zt(a, s.gatewayUrl, n, p, c);
|
|
12291
|
+
p._bindApi(h);
|
|
12292
|
+
const d = new ce(a, s.gatewayUrl);
|
|
12293
|
+
p._bindProfile(d);
|
|
12294
|
+
const u = new pe(a, s.gatewayUrl), m = new le(a, s.gatewayUrl), w = Object.create(We.prototype), f = new ue(a.isSuperAdmin), y = new ge(c), g = new Yt(a, s.gatewayUrl), _ = new me();
|
|
12295
|
+
return Object.assign(w, {
|
|
12002
12296
|
_app: t,
|
|
12003
12297
|
_endpoints: s,
|
|
12004
12298
|
_isEmulator: o === "emulator",
|
|
12005
|
-
|
|
12006
|
-
_storageProcessed: p,
|
|
12299
|
+
blob: c,
|
|
12007
12300
|
auth: a,
|
|
12008
12301
|
signup: i,
|
|
12009
|
-
api:
|
|
12302
|
+
api: h,
|
|
12010
12303
|
projects: n,
|
|
12011
|
-
profile:
|
|
12012
|
-
usageStats:
|
|
12013
|
-
admin:
|
|
12014
|
-
privileges:
|
|
12015
|
-
cache:
|
|
12016
|
-
storage:
|
|
12017
|
-
currency:
|
|
12018
|
-
}),
|
|
12304
|
+
profile: d,
|
|
12305
|
+
usageStats: u,
|
|
12306
|
+
admin: m,
|
|
12307
|
+
privileges: f,
|
|
12308
|
+
cache: y,
|
|
12309
|
+
storage: g,
|
|
12310
|
+
currency: _
|
|
12311
|
+
}), w;
|
|
12019
12312
|
}
|
|
12020
12313
|
_buildApi(t, e) {
|
|
12021
|
-
const o = new
|
|
12314
|
+
const o = new xe(this.auth, t, e, this._endpoints.gatewayUrl), s = new Zt(this.auth, this._endpoints.gatewayUrl, t, o, e);
|
|
12022
12315
|
return o._bindApi(s), s;
|
|
12023
12316
|
}
|
|
12024
12317
|
/** Convenience: get the current user's Firebase ID token */
|
|
@@ -12040,7 +12333,7 @@ class Ke {
|
|
|
12040
12333
|
* ```
|
|
12041
12334
|
*/
|
|
12042
12335
|
createProjectView(t, e) {
|
|
12043
|
-
return new
|
|
12336
|
+
return new _i(this.api, t, { verbose: this._verbose, ...e });
|
|
12044
12337
|
}
|
|
12045
12338
|
/**
|
|
12046
12339
|
* Creates a `CueProjectEntities` instance for the given project, bound to the
|
|
@@ -12057,7 +12350,7 @@ class Ke {
|
|
|
12057
12350
|
* ```
|
|
12058
12351
|
*/
|
|
12059
12352
|
createProjectEntities(t, e) {
|
|
12060
|
-
return new
|
|
12353
|
+
return new Be(
|
|
12061
12354
|
this.api,
|
|
12062
12355
|
t,
|
|
12063
12356
|
e?.rdfBase,
|
|
@@ -12081,7 +12374,7 @@ class Ke {
|
|
|
12081
12374
|
const s = this._projectDocuments.get(t);
|
|
12082
12375
|
if (s)
|
|
12083
12376
|
return s.setLanguage(this.api.language), s;
|
|
12084
|
-
const a = new
|
|
12377
|
+
const a = new Et(
|
|
12085
12378
|
this.api,
|
|
12086
12379
|
t,
|
|
12087
12380
|
this.api.language,
|
|
@@ -12091,7 +12384,7 @@ class Ke {
|
|
|
12091
12384
|
);
|
|
12092
12385
|
return this._projectDocuments.set(t, a), a;
|
|
12093
12386
|
}
|
|
12094
|
-
return new
|
|
12387
|
+
return new Et(
|
|
12095
12388
|
this.api,
|
|
12096
12389
|
t,
|
|
12097
12390
|
e?.language ?? this.api.language,
|
|
@@ -12101,8 +12394,8 @@ class Ke {
|
|
|
12101
12394
|
);
|
|
12102
12395
|
}
|
|
12103
12396
|
}
|
|
12104
|
-
const mt = "https://qlever.cs.uni-freiburg.de/materializedView/",
|
|
12105
|
-
class
|
|
12397
|
+
const mt = "https://qlever.cs.uni-freiburg.de/materializedView/", L = b.qcy;
|
|
12398
|
+
class Bi {
|
|
12106
12399
|
constructor(t, e, o) {
|
|
12107
12400
|
this._api = t, this._projectId = e, this._graphType = o;
|
|
12108
12401
|
}
|
|
@@ -12126,7 +12419,7 @@ class xi {
|
|
|
12126
12419
|
this._api.sparql(this._buildViewDimQuery("mime", e), this._projectId, this._graphType),
|
|
12127
12420
|
this._api.sparql(this._buildViewDimQuery("content", e), this._projectId, this._graphType),
|
|
12128
12421
|
this._api.sparql(this._buildViewDimQuery("entity", e), this._projectId, this._graphType)
|
|
12129
|
-
]), h =
|
|
12422
|
+
]), h = Re(n, c, p);
|
|
12130
12423
|
if (h.mimes.length + h.contents.length + h.entityCategories.length > 0)
|
|
12131
12424
|
return h;
|
|
12132
12425
|
console.warn(
|
|
@@ -12139,7 +12432,7 @@ class xi {
|
|
|
12139
12432
|
this._api.sparql(this._buildLiveDimQuery("content", e), this._projectId, this._graphType),
|
|
12140
12433
|
this._api.sparql(this._buildLiveDimQuery("entity", e), this._projectId, this._graphType)
|
|
12141
12434
|
]);
|
|
12142
|
-
return
|
|
12435
|
+
return Re(s, a, i);
|
|
12143
12436
|
}
|
|
12144
12437
|
/**
|
|
12145
12438
|
* Lists the *specific* entities (e.g. "John Doe") of a given entity category
|
|
@@ -12151,8 +12444,8 @@ class xi {
|
|
|
12151
12444
|
* list shrinks as other filters are added.
|
|
12152
12445
|
*/
|
|
12153
12446
|
async availableEntities(t, e) {
|
|
12154
|
-
const s =
|
|
12155
|
-
`), a = `PREFIX qcy: <${
|
|
12447
|
+
const s = Oe(e ?? {}).join(`
|
|
12448
|
+
`), a = `PREFIX qcy: <${L}>
|
|
12156
12449
|
SELECT DISTINCT ?entity ?val
|
|
12157
12450
|
WHERE {
|
|
12158
12451
|
{
|
|
@@ -12169,7 +12462,7 @@ WHERE {
|
|
|
12169
12462
|
ORDER BY ?val`, i = await this._api.sparql(a, this._projectId, this._graphType), n = /* @__PURE__ */ new Set(), c = [];
|
|
12170
12463
|
for (const p of i.results.bindings) {
|
|
12171
12464
|
const h = p.entity?.value;
|
|
12172
|
-
!h || n.has(h) || (n.add(h), c.push({ iri: h, label: p.val?.value ??
|
|
12465
|
+
!h || n.has(h) || (n.add(h), c.push({ iri: h, label: p.val?.value ?? Ve(h) }));
|
|
12173
12466
|
}
|
|
12174
12467
|
return c;
|
|
12175
12468
|
}
|
|
@@ -12195,7 +12488,7 @@ ORDER BY ?val`, i = await this._api.sparql(a, this._projectId, this._graphType),
|
|
|
12195
12488
|
// ── Private query builders ──────────────────────────────────────────────────
|
|
12196
12489
|
/** Single-dimension available-filters query using the dimension-specific views. */
|
|
12197
12490
|
_buildViewDimQuery(t, e) {
|
|
12198
|
-
const o = t === "mime" ? "doc-mime-cats" : t === "content" ? "doc-content-cats" : "doc-entity-cats", s = t === "mime" ? "?mimeCat" : t === "content" ? "?contentCat" : "?entityCat", a =
|
|
12491
|
+
const o = t === "mime" ? "doc-mime-cats" : t === "content" ? "doc-content-cats" : "doc-entity-cats", s = t === "mime" ? "?mimeCat" : t === "content" ? "?contentCat" : "?entityCat", a = ki(e);
|
|
12199
12492
|
return a.length === 0 ? `PREFIX view: <${mt}>
|
|
12200
12493
|
SELECT DISTINCT ${s}
|
|
12201
12494
|
WHERE {
|
|
@@ -12204,7 +12497,7 @@ WHERE {
|
|
|
12204
12497
|
view:column-cat ${s} .
|
|
12205
12498
|
}
|
|
12206
12499
|
}` : `PREFIX view: <${mt}>
|
|
12207
|
-
PREFIX qcy: <${
|
|
12500
|
+
PREFIX qcy: <${L}>
|
|
12208
12501
|
SELECT DISTINCT ${s}
|
|
12209
12502
|
WHERE {
|
|
12210
12503
|
{
|
|
@@ -12221,9 +12514,9 @@ WHERE {
|
|
|
12221
12514
|
}
|
|
12222
12515
|
/** Single-dimension available-filters query using live triple patterns. */
|
|
12223
12516
|
_buildLiveDimQuery(t, e) {
|
|
12224
|
-
const s =
|
|
12517
|
+
const s = Oe(e).join(`
|
|
12225
12518
|
`);
|
|
12226
|
-
return `PREFIX qcy: <${
|
|
12519
|
+
return `PREFIX qcy: <${L}>
|
|
12227
12520
|
SELECT DISTINCT ${t === "mime" ? "?mimeCat" : t === "content" ? "?contentCat" : "?entityCat"}
|
|
12228
12521
|
WHERE {
|
|
12229
12522
|
{
|
|
@@ -12260,7 +12553,7 @@ WHERE {
|
|
|
12260
12553
|
}
|
|
12261
12554
|
if (e.length === 0) throw new Error("no view filter clauses");
|
|
12262
12555
|
return `PREFIX view: <${mt}>
|
|
12263
|
-
PREFIX qcy: <${
|
|
12556
|
+
PREFIX qcy: <${L}>
|
|
12264
12557
|
SELECT DISTINCT ?id
|
|
12265
12558
|
WHERE {
|
|
12266
12559
|
${e.join(`
|
|
@@ -12312,7 +12605,7 @@ WHERE {
|
|
|
12312
12605
|
e.push(`FILTER NOT EXISTS { ?doc qcy:hasContentCategory <${s}> }`);
|
|
12313
12606
|
}
|
|
12314
12607
|
}
|
|
12315
|
-
return `PREFIX qcy: <${
|
|
12608
|
+
return `PREFIX qcy: <${L}>
|
|
12316
12609
|
SELECT DISTINCT ?id
|
|
12317
12610
|
WHERE {
|
|
12318
12611
|
?doc a qcy:FileContent .
|
|
@@ -12323,7 +12616,7 @@ WHERE {
|
|
|
12323
12616
|
}`;
|
|
12324
12617
|
}
|
|
12325
12618
|
}
|
|
12326
|
-
function
|
|
12619
|
+
function ki(r) {
|
|
12327
12620
|
const t = [];
|
|
12328
12621
|
for (const e of r.entities ?? [])
|
|
12329
12622
|
t.push(`?doc qcy:about <${e}> .`);
|
|
@@ -12341,7 +12634,7 @@ function di(r) {
|
|
|
12341
12634
|
}
|
|
12342
12635
|
return t;
|
|
12343
12636
|
}
|
|
12344
|
-
function
|
|
12637
|
+
function Oe(r) {
|
|
12345
12638
|
const t = [];
|
|
12346
12639
|
for (const e of r.entities ?? [])
|
|
12347
12640
|
t.push(`?doc qcy:about <${e}> .`);
|
|
@@ -12368,15 +12661,15 @@ function De(r) {
|
|
|
12368
12661
|
}
|
|
12369
12662
|
return t;
|
|
12370
12663
|
}
|
|
12371
|
-
function
|
|
12664
|
+
function Ve(r) {
|
|
12372
12665
|
return r.split("#").pop()?.split("/").pop() ?? r;
|
|
12373
12666
|
}
|
|
12374
|
-
function
|
|
12667
|
+
function Re(r, t, e) {
|
|
12375
12668
|
const o = (s, a) => {
|
|
12376
12669
|
const i = /* @__PURE__ */ new Set(), n = [];
|
|
12377
12670
|
for (const c of s) {
|
|
12378
12671
|
const p = c[a]?.value;
|
|
12379
|
-
p && !i.has(p) && (i.add(p), n.push({ iri: p, label:
|
|
12672
|
+
p && !i.has(p) && (i.add(p), n.push({ iri: p, label: Ve(p) }));
|
|
12380
12673
|
}
|
|
12381
12674
|
return n;
|
|
12382
12675
|
};
|
|
@@ -12387,62 +12680,62 @@ function Ne(r, t, e) {
|
|
|
12387
12680
|
};
|
|
12388
12681
|
}
|
|
12389
12682
|
export {
|
|
12390
|
-
|
|
12391
|
-
|
|
12392
|
-
|
|
12393
|
-
|
|
12394
|
-
|
|
12395
|
-
|
|
12396
|
-
|
|
12397
|
-
|
|
12398
|
-
|
|
12399
|
-
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
|
|
12403
|
-
|
|
12404
|
-
|
|
12405
|
-
|
|
12406
|
-
|
|
12407
|
-
|
|
12408
|
-
|
|
12409
|
-
|
|
12410
|
-
|
|
12411
|
-
|
|
12412
|
-
|
|
12413
|
-
|
|
12414
|
-
|
|
12683
|
+
mi as $,
|
|
12684
|
+
_i as A,
|
|
12685
|
+
Ui as B,
|
|
12686
|
+
gi as C,
|
|
12687
|
+
ne as D,
|
|
12688
|
+
fr as E,
|
|
12689
|
+
sa as F,
|
|
12690
|
+
ra as G,
|
|
12691
|
+
Xt as H,
|
|
12692
|
+
E as I,
|
|
12693
|
+
Yt as J,
|
|
12694
|
+
xe as K,
|
|
12695
|
+
_r as L,
|
|
12696
|
+
Lr as M,
|
|
12697
|
+
kt as N,
|
|
12698
|
+
oa as O,
|
|
12699
|
+
ea as P,
|
|
12700
|
+
ui as Q,
|
|
12701
|
+
di as R,
|
|
12702
|
+
pi as S,
|
|
12703
|
+
de as T,
|
|
12704
|
+
hi as U,
|
|
12705
|
+
Li as V,
|
|
12706
|
+
ni as W,
|
|
12707
|
+
zi as X,
|
|
12415
12708
|
St as Y,
|
|
12416
|
-
|
|
12417
|
-
|
|
12418
|
-
|
|
12419
|
-
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
|
|
12423
|
-
|
|
12424
|
-
|
|
12425
|
-
|
|
12426
|
-
|
|
12427
|
-
|
|
12428
|
-
|
|
12429
|
-
|
|
12430
|
-
|
|
12431
|
-
|
|
12432
|
-
|
|
12433
|
-
|
|
12434
|
-
|
|
12435
|
-
|
|
12436
|
-
|
|
12437
|
-
|
|
12438
|
-
|
|
12439
|
-
|
|
12440
|
-
|
|
12441
|
-
|
|
12442
|
-
|
|
12443
|
-
|
|
12444
|
-
|
|
12445
|
-
|
|
12446
|
-
|
|
12447
|
-
|
|
12709
|
+
Ge as Z,
|
|
12710
|
+
wi as _,
|
|
12711
|
+
li as a,
|
|
12712
|
+
fi as a0,
|
|
12713
|
+
Fi as a1,
|
|
12714
|
+
Mi as a2,
|
|
12715
|
+
qi as a3,
|
|
12716
|
+
ci as b,
|
|
12717
|
+
We as c,
|
|
12718
|
+
le as d,
|
|
12719
|
+
Zt as e,
|
|
12720
|
+
Nr as f,
|
|
12721
|
+
jr as g,
|
|
12722
|
+
Vt as h,
|
|
12723
|
+
ge as i,
|
|
12724
|
+
Sr as j,
|
|
12725
|
+
me as k,
|
|
12726
|
+
Zr as l,
|
|
12727
|
+
Mr as m,
|
|
12728
|
+
Bi as n,
|
|
12729
|
+
Tr as o,
|
|
12730
|
+
ti as p,
|
|
12731
|
+
ta as q,
|
|
12732
|
+
Cr as r,
|
|
12733
|
+
Qr as s,
|
|
12734
|
+
$r as t,
|
|
12735
|
+
ue as u,
|
|
12736
|
+
Ur as v,
|
|
12737
|
+
ce as w,
|
|
12738
|
+
Et as x,
|
|
12739
|
+
Be as y,
|
|
12740
|
+
ai as z
|
|
12448
12741
|
};
|