@qaecy/cue-sdk 0.0.40 → 0.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/browser.js +7473 -6895
- package/{document-filter-Ccb84D3H.js → document-filter-Cj0Yql1C.js} +1422 -844
- package/index.d.ts +5 -1
- package/index.js +28 -26
- package/lib/api.d.ts +18 -3
- package/lib/cue.d.ts +2 -2
- package/lib/data-sources.d.ts +77 -11
- package/lib/document-filter.d.ts +1 -1
- package/lib/documents.d.ts +1 -1
- package/lib/entities.d.ts +1 -1
- package/lib/gis-sources.d.ts +57 -0
- package/lib/llm-tools.d.ts +83 -0
- package/lib/models.d.ts +34 -0
- package/lib/project-view.d.ts +10 -2
- package/lib/schema.d.ts +29 -1
- package/lib/semantic-template.d.ts +63 -0
- package/lib/sync.d.ts +7 -0
- package/node.js +26 -24
- package/package.json +1 -1
- package/variables.d.ts +5 -5
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { getApps as
|
|
2
|
-
import { ref as
|
|
3
|
-
import { Writer as
|
|
4
|
-
import { getFirestore as
|
|
5
|
-
import { getAuth as
|
|
6
|
-
import { Client as
|
|
7
|
-
import { StreamableHTTPClientTransport as
|
|
8
|
-
import { getFunctions as
|
|
9
|
-
import { v5 as
|
|
1
|
+
import { getApps as Je, initializeApp as Ze } from "firebase/app";
|
|
2
|
+
import { ref as S, getDownloadURL as ot, getMetadata as B, getBlob as De, updateMetadata as to, uploadBytesResumable as At, uploadBytes as gt, StringFormat as eo, uploadString as oo, listAll as G, getStorage as k, connectStorageEmulator as H } from "firebase/storage";
|
|
3
|
+
import { Writer as ro } from "n3";
|
|
4
|
+
import { getFirestore as so, connectFirestoreEmulator as ao, doc as io, setDoc as no, serverTimestamp as po, increment as co } from "firebase/firestore";
|
|
5
|
+
import { getAuth as lo, connectAuthEmulator as ho, onIdTokenChanged as uo, getIdTokenResult as J, signInWithEmailAndPassword as go, GoogleAuthProvider as mt, OAuthProvider as wt, signInWithPopup as mo, signInWithRedirect as wo, getRedirectResult as fo, signInWithCustomToken as Ot, signOut as yo, onAuthStateChanged as bo, fetchSignInMethodsForEmail as _o, linkWithPopup as vo, unlink as Eo, reauthenticateWithCredential as $t, EmailAuthProvider as rt, updatePassword as To, linkWithCredential as So, verifyBeforeUpdateEmail as Co, sendEmailVerification as ko } from "firebase/auth";
|
|
6
|
+
import { Client as Io } from "@modelcontextprotocol/sdk/client/index.js";
|
|
7
|
+
import { StreamableHTTPClientTransport as xo } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
8
|
+
import { getFunctions as Ro, connectFunctionsEmulator as Ao, httpsCallable as Oo } from "firebase/functions";
|
|
9
|
+
import { v5 as $o } from "uuid";
|
|
10
10
|
import "spark-md5";
|
|
11
|
-
class
|
|
11
|
+
class Et {
|
|
12
12
|
queryEndpoint;
|
|
13
13
|
updateEndpoint;
|
|
14
14
|
baseHeaders;
|
|
@@ -20,7 +20,7 @@ class yt {
|
|
|
20
20
|
constructor(t) {
|
|
21
21
|
this.queryEndpoint = t.queryEndpoint, this.updateEndpoint = t.updateEndpoint, this.baseHeaders = Object.fromEntries(
|
|
22
22
|
Object.entries(t.originalHeaders || {}).filter(
|
|
23
|
-
([e]) =>
|
|
23
|
+
([e]) => Et.RELEVANT_HEADER_KEYS.includes(e)
|
|
24
24
|
)
|
|
25
25
|
), t.authHeader !== void 0 && (this.baseHeaders.Authorization = t.authHeader);
|
|
26
26
|
}
|
|
@@ -83,15 +83,15 @@ class yt {
|
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
const
|
|
87
|
-
class
|
|
86
|
+
const Po = [423, 429, 503];
|
|
87
|
+
class Ne extends Error {
|
|
88
88
|
constructor(t, e, o) {
|
|
89
89
|
super(`QLever throttled the request (HTTP ${e}): ${t}`), this.status = e, this.retryAfterSeconds = o, this.name = "QLeverThrottledError";
|
|
90
90
|
}
|
|
91
91
|
status;
|
|
92
92
|
retryAfterSeconds;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function Do(s) {
|
|
95
95
|
const t = s.headers.get("retry-after");
|
|
96
96
|
if (!t) return;
|
|
97
97
|
const e = Number(t);
|
|
@@ -99,13 +99,13 @@ function _o(s) {
|
|
|
99
99
|
const o = Date.parse(t);
|
|
100
100
|
if (!Number.isNaN(o)) return Math.max(0, (o - Date.now()) / 1e3);
|
|
101
101
|
}
|
|
102
|
-
async function
|
|
102
|
+
async function W(s) {
|
|
103
103
|
const t = await s.text();
|
|
104
|
-
if (
|
|
105
|
-
throw new
|
|
104
|
+
if (Po.includes(s.status))
|
|
105
|
+
throw new Ne(t, s.status, Do(s));
|
|
106
106
|
return t;
|
|
107
107
|
}
|
|
108
|
-
class
|
|
108
|
+
class A {
|
|
109
109
|
queryEndpoint;
|
|
110
110
|
updateEndpoint;
|
|
111
111
|
dataEndpoint;
|
|
@@ -148,16 +148,16 @@ class R {
|
|
|
148
148
|
* the exact second the server nominated.
|
|
149
149
|
*/
|
|
150
150
|
static async _retryOnLocked(t) {
|
|
151
|
-
const e =
|
|
151
|
+
const e = A.LOCKED_MAX_RETRIES, o = A.LOCKED_BASE_DELAY_MS;
|
|
152
152
|
let r;
|
|
153
153
|
for (let a = 0; a <= e; a++)
|
|
154
154
|
try {
|
|
155
155
|
return await t();
|
|
156
156
|
} catch (i) {
|
|
157
|
-
if (r = i, i instanceof
|
|
157
|
+
if (r = i, i instanceof Ne && a < e) {
|
|
158
158
|
const n = i.retryAfterSeconds !== void 0 ? i.retryAfterSeconds * 1e3 : void 0, p = Math.min(
|
|
159
159
|
n ?? o * Math.pow(2, a),
|
|
160
|
-
|
|
160
|
+
A.LOCKED_MAX_DELAY_MS
|
|
161
161
|
);
|
|
162
162
|
await new Promise((c) => setTimeout(c, Math.random() * p));
|
|
163
163
|
continue;
|
|
@@ -169,7 +169,7 @@ class R {
|
|
|
169
169
|
constructor(t) {
|
|
170
170
|
this.queryEndpoint = t.queryEndpoint, this.updateEndpoint = t.updateEndpoint, this.dataEndpoint = this.updateEndpoint.replace(/\/update$/, "/data"), this.baseHeaders = Object.fromEntries(
|
|
171
171
|
Object.entries(t.originalHeaders || {}).filter(
|
|
172
|
-
([e]) =>
|
|
172
|
+
([e]) => A.RELEVANT_HEADER_KEYS.includes(e)
|
|
173
173
|
)
|
|
174
174
|
), this.baseHeaders["x-user-roles"] = "admin";
|
|
175
175
|
}
|
|
@@ -177,7 +177,7 @@ class R {
|
|
|
177
177
|
return (await this.query("ASK { }")).boolean;
|
|
178
178
|
}
|
|
179
179
|
async query(t, e = "application/sparql-results+json") {
|
|
180
|
-
return
|
|
180
|
+
return A._retryOnLocked(async () => {
|
|
181
181
|
let o;
|
|
182
182
|
try {
|
|
183
183
|
o = await fetch(this.queryEndpoint, {
|
|
@@ -195,14 +195,14 @@ class R {
|
|
|
195
195
|
);
|
|
196
196
|
}
|
|
197
197
|
if (!o.ok) {
|
|
198
|
-
const r = await
|
|
198
|
+
const r = await W(o);
|
|
199
199
|
throw new Error(`QLever query failed (HTTP ${o.status}): ${r}`);
|
|
200
200
|
}
|
|
201
201
|
return await o.json();
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
204
|
async subset(t, e = "text/turtle") {
|
|
205
|
-
return
|
|
205
|
+
return A._retryOnLocked(async () => {
|
|
206
206
|
const o = await fetch(this.queryEndpoint, {
|
|
207
207
|
headers: {
|
|
208
208
|
...this.baseHeaders,
|
|
@@ -213,14 +213,14 @@ class R {
|
|
|
213
213
|
body: new URLSearchParams({ query: t })
|
|
214
214
|
});
|
|
215
215
|
if (!o.ok) {
|
|
216
|
-
const r = await
|
|
216
|
+
const r = await W(o);
|
|
217
217
|
throw new Error(`QLever subset failed (HTTP ${o.status}): ${r}`);
|
|
218
218
|
}
|
|
219
219
|
return await o.text();
|
|
220
220
|
});
|
|
221
221
|
}
|
|
222
222
|
async update(t) {
|
|
223
|
-
return
|
|
223
|
+
return A._retryOnLocked(async () => {
|
|
224
224
|
const e = await fetch(this.updateEndpoint, {
|
|
225
225
|
headers: {
|
|
226
226
|
...this.baseHeaders,
|
|
@@ -230,7 +230,7 @@ class R {
|
|
|
230
230
|
body: new URLSearchParams({ update: t })
|
|
231
231
|
});
|
|
232
232
|
if (!e.ok) {
|
|
233
|
-
const o = await
|
|
233
|
+
const o = await W(e);
|
|
234
234
|
throw new Error(`SPARQL update failed (HTTP ${e.status}): ${o}`);
|
|
235
235
|
}
|
|
236
236
|
return await e.json();
|
|
@@ -274,15 +274,15 @@ class R {
|
|
|
274
274
|
* to prevent.
|
|
275
275
|
*/
|
|
276
276
|
async _postToDataEndpoint(t, e) {
|
|
277
|
-
await
|
|
277
|
+
await A._retryOnLocked(async () => {
|
|
278
278
|
const o = {
|
|
279
279
|
...this.baseHeaders,
|
|
280
280
|
"Content-Type": "application/n-quads",
|
|
281
281
|
"Content-Encoding": "gzip"
|
|
282
|
-
}, r =
|
|
282
|
+
}, r = Lo() ? {
|
|
283
283
|
method: "POST",
|
|
284
284
|
headers: o,
|
|
285
|
-
body:
|
|
285
|
+
body: jo(t).pipeThrough(new CompressionStream("gzip")),
|
|
286
286
|
// Required for a streaming body; also switches the request to
|
|
287
287
|
// chunked transfer encoding, which the service handles because it
|
|
288
288
|
// never buffers the body itself.
|
|
@@ -290,23 +290,23 @@ class R {
|
|
|
290
290
|
} : {
|
|
291
291
|
method: "POST",
|
|
292
292
|
headers: o,
|
|
293
|
-
body: await
|
|
293
|
+
body: await Uo(Buffer.from(await je(t), "utf-8"))
|
|
294
294
|
}, a = await fetch(e, r);
|
|
295
295
|
if (!a.ok) {
|
|
296
|
-
const i = await
|
|
296
|
+
const i = await W(a);
|
|
297
297
|
throw new Error(`QLever data POST failed (HTTP ${a.status}): ${i}`);
|
|
298
298
|
}
|
|
299
299
|
});
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
|
-
function
|
|
302
|
+
function je(s) {
|
|
303
303
|
return new Promise((t, e) => {
|
|
304
|
-
const o = new
|
|
304
|
+
const o = new ro({ format: "application/n-quads" });
|
|
305
305
|
o.addQuads(s), o.end((r, a) => r ? e(r) : t(a));
|
|
306
306
|
});
|
|
307
307
|
}
|
|
308
|
-
const
|
|
309
|
-
function
|
|
308
|
+
const No = 5e3;
|
|
309
|
+
function jo(s) {
|
|
310
310
|
const t = new TextEncoder();
|
|
311
311
|
let e = 0;
|
|
312
312
|
return new ReadableStream({
|
|
@@ -315,13 +315,13 @@ function To(s) {
|
|
|
315
315
|
o.close();
|
|
316
316
|
return;
|
|
317
317
|
}
|
|
318
|
-
const r = s.slice(e, e +
|
|
319
|
-
e += r.length, o.enqueue(t.encode(await
|
|
318
|
+
const r = s.slice(e, e + No);
|
|
319
|
+
e += r.length, o.enqueue(t.encode(await je(r)));
|
|
320
320
|
}
|
|
321
321
|
});
|
|
322
322
|
}
|
|
323
323
|
let P;
|
|
324
|
-
function
|
|
324
|
+
function Lo() {
|
|
325
325
|
if (P !== void 0) return P;
|
|
326
326
|
if (typeof process < "u" && process.env?.QLEVER_DISABLE_REQUEST_STREAMING === "true" || typeof CompressionStream > "u" || typeof ReadableStream > "u")
|
|
327
327
|
return P = !1;
|
|
@@ -340,7 +340,7 @@ function ko() {
|
|
|
340
340
|
}
|
|
341
341
|
return P;
|
|
342
342
|
}
|
|
343
|
-
async function
|
|
343
|
+
async function Uo(s) {
|
|
344
344
|
const t = new CompressionStream("gzip"), e = t.writable.getWriter();
|
|
345
345
|
e.write(new Uint8Array(s)), e.close();
|
|
346
346
|
const o = [], r = t.readable.getReader();
|
|
@@ -355,14 +355,14 @@ async function So(s) {
|
|
|
355
355
|
i.set(p, n), n += p.byteLength;
|
|
356
356
|
return i.buffer;
|
|
357
357
|
}
|
|
358
|
-
class
|
|
358
|
+
class Mo {
|
|
359
359
|
constructor(t) {
|
|
360
360
|
switch (this.options = t, this.options.graphType) {
|
|
361
361
|
case "qlever":
|
|
362
|
-
this._db = new
|
|
362
|
+
this._db = new A(this.options);
|
|
363
363
|
break;
|
|
364
364
|
case "fuseki":
|
|
365
|
-
this._db = new
|
|
365
|
+
this._db = new Et(this.options);
|
|
366
366
|
break;
|
|
367
367
|
default:
|
|
368
368
|
throw new Error(`Unsupported graph type: ${this.options.graphType}`);
|
|
@@ -410,13 +410,41 @@ class Io {
|
|
|
410
410
|
return this.options.graphType === "qlever" ? this._db.deleteData(t) : Promise.reject(new Error("deleteData not supported for Fuseki — use update() with SPARQL DELETE DATA"));
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
|
-
class
|
|
413
|
+
class q {
|
|
414
414
|
constructor(t) {
|
|
415
415
|
this.options = t;
|
|
416
416
|
}
|
|
417
417
|
options;
|
|
418
418
|
/** Paths known to be absent, keyed as `bucket:path`. Avoids repeat 404 requests. */
|
|
419
419
|
_knownMissing = /* @__PURE__ */ new Set();
|
|
420
|
+
/**
|
|
421
|
+
* Suffixes worth gzip-compressing on upload, picked from real
|
|
422
|
+
* compression-ratio numbers (see `libs/js/cue-sdk/plan.md` design
|
|
423
|
+
* decision 3) — binary/already-compressed formats like `.pdf`/`.dwg`/
|
|
424
|
+
* `.png` are excluded because gzip saves ≤12% on them.
|
|
425
|
+
*/
|
|
426
|
+
static _GZIP_SUFFIXES = /* @__PURE__ */ new Set([
|
|
427
|
+
".ifc",
|
|
428
|
+
".dxf",
|
|
429
|
+
".ttl",
|
|
430
|
+
".nt",
|
|
431
|
+
".jelly",
|
|
432
|
+
".json",
|
|
433
|
+
".txt"
|
|
434
|
+
]);
|
|
435
|
+
static async _gzipEncode(t) {
|
|
436
|
+
const e = new CompressionStream("gzip"), o = e.writable.getWriter(), r = e.readable.getReader();
|
|
437
|
+
o.write(new Uint8Array(t)), o.close();
|
|
438
|
+
const a = [];
|
|
439
|
+
let i = 0, n = await r.read();
|
|
440
|
+
for (; !n.done; )
|
|
441
|
+
a.push(n.value), i += n.value.length, n = await r.read();
|
|
442
|
+
const p = new Uint8Array(i);
|
|
443
|
+
let c = 0;
|
|
444
|
+
for (const h of a)
|
|
445
|
+
p.set(h, c), c += h.length;
|
|
446
|
+
return p;
|
|
447
|
+
}
|
|
420
448
|
// ─── Storage bucket resolution ────────────────────────────────────────────
|
|
421
449
|
_bucket(t) {
|
|
422
450
|
switch (t) {
|
|
@@ -439,9 +467,9 @@ class It {
|
|
|
439
467
|
// ─── Downloads ────────────────────────────────────────────────────────────
|
|
440
468
|
/** Get an authenticated download URL. Returns undefined if the file does not exist. */
|
|
441
469
|
async getDownloadURL(t, e) {
|
|
442
|
-
const o =
|
|
470
|
+
const o = S(this._bucket(t), e);
|
|
443
471
|
try {
|
|
444
|
-
return await
|
|
472
|
+
return await ot(o);
|
|
445
473
|
} catch (r) {
|
|
446
474
|
if (r?.code === "storage/object-not-found") return;
|
|
447
475
|
throw r;
|
|
@@ -454,10 +482,10 @@ class It {
|
|
|
454
482
|
async getCacheBustedUrl(t, e) {
|
|
455
483
|
const o = `${t}:${e}`;
|
|
456
484
|
if (this._knownMissing.has(o)) return;
|
|
457
|
-
const r =
|
|
485
|
+
const r = S(this._bucket(t), e);
|
|
458
486
|
try {
|
|
459
|
-
const a = await
|
|
460
|
-
return `${await
|
|
487
|
+
const a = await B(r);
|
|
488
|
+
return `${await ot(r)}&t=${encodeURIComponent(a.updated)}`;
|
|
461
489
|
} catch (a) {
|
|
462
490
|
if (a?.code === "storage/object-not-found" || a?.status === 404) {
|
|
463
491
|
this._knownMissing.add(o), console.debug(`[CueBlobStorage] ${e} not found (404 OK — optional cache file)`);
|
|
@@ -468,9 +496,9 @@ class It {
|
|
|
468
496
|
}
|
|
469
497
|
/** Download a file as a Blob. Returns undefined if the file does not exist. */
|
|
470
498
|
async getFile(t, e) {
|
|
471
|
-
const o =
|
|
499
|
+
const o = S(this._bucket(t), e);
|
|
472
500
|
try {
|
|
473
|
-
return await
|
|
501
|
+
return await De(o);
|
|
474
502
|
} catch (r) {
|
|
475
503
|
if (r?.code === "storage/object-not-found") return;
|
|
476
504
|
throw r;
|
|
@@ -485,7 +513,7 @@ class It {
|
|
|
485
513
|
* Uses a cache-busted URL to ensure the latest version is fetched.
|
|
486
514
|
*/
|
|
487
515
|
async downloadPublic(t) {
|
|
488
|
-
const e =
|
|
516
|
+
const e = S(this.options.storagePublic, t), o = new AbortController(), r = setTimeout(() => o.abort(), 1e4), a = (i) => Promise.race([
|
|
489
517
|
i,
|
|
490
518
|
new Promise((n, p) => {
|
|
491
519
|
o.signal.addEventListener(
|
|
@@ -496,8 +524,8 @@ class It {
|
|
|
496
524
|
]);
|
|
497
525
|
try {
|
|
498
526
|
const [i, n] = await Promise.all([
|
|
499
|
-
a(
|
|
500
|
-
a(
|
|
527
|
+
a(ot(e)),
|
|
528
|
+
a(B(e))
|
|
501
529
|
]), p = `${i}&t=${encodeURIComponent(n.updated)}`, c = await fetch(p, { signal: o.signal });
|
|
502
530
|
if (!c.ok) throw new Error(`HTTP ${c.status}`);
|
|
503
531
|
return c.text();
|
|
@@ -511,9 +539,9 @@ class It {
|
|
|
511
539
|
// ─── Metadata ─────────────────────────────────────────────────────────────
|
|
512
540
|
/** Read file metadata. Returns undefined if the file does not exist. */
|
|
513
541
|
async getMetadata(t, e) {
|
|
514
|
-
const o =
|
|
542
|
+
const o = S(this._bucket(t), e);
|
|
515
543
|
try {
|
|
516
|
-
const r = await
|
|
544
|
+
const r = await B(o);
|
|
517
545
|
return {
|
|
518
546
|
updated: r.updated,
|
|
519
547
|
contentType: r.contentType,
|
|
@@ -527,8 +555,8 @@ class It {
|
|
|
527
555
|
}
|
|
528
556
|
/** Update custom metadata on an existing file. */
|
|
529
557
|
async setMetadata(t, e, o) {
|
|
530
|
-
const r =
|
|
531
|
-
await
|
|
558
|
+
const r = S(this._bucket(t), e);
|
|
559
|
+
await to(r, { customMetadata: o });
|
|
532
560
|
}
|
|
533
561
|
// ─── Uploads ──────────────────────────────────────────────────────────────
|
|
534
562
|
/**
|
|
@@ -537,7 +565,7 @@ class It {
|
|
|
537
565
|
* upload progress needs to be surfaced in the UI.
|
|
538
566
|
*/
|
|
539
567
|
uploadResumable(t, e, o, r) {
|
|
540
|
-
const a =
|
|
568
|
+
const a = S(this._bucket(t), e), i = At(a, o, r ? { customMetadata: r } : void 0);
|
|
541
569
|
return {
|
|
542
570
|
complete: () => new Promise((n, p) => i.then(() => n(), p)),
|
|
543
571
|
pause: () => i.pause(),
|
|
@@ -556,19 +584,19 @@ class It {
|
|
|
556
584
|
* Use for small files where progress feedback is not needed.
|
|
557
585
|
*/
|
|
558
586
|
async uploadBytes(t, e, o, r) {
|
|
559
|
-
const a =
|
|
560
|
-
await
|
|
587
|
+
const a = S(this._bucket(t), e);
|
|
588
|
+
await gt(a, o, r ? { customMetadata: r } : void 0);
|
|
561
589
|
}
|
|
562
590
|
/** Upload a string or base64-encoded value. */
|
|
563
|
-
async uploadString(t, e, o, r =
|
|
564
|
-
const i =
|
|
565
|
-
await
|
|
591
|
+
async uploadString(t, e, o, r = eo.RAW, a) {
|
|
592
|
+
const i = S(this._bucket(t), e);
|
|
593
|
+
await oo(i, o, r, a ? { customMetadata: a } : void 0);
|
|
566
594
|
}
|
|
567
595
|
// ─── Listing ──────────────────────────────────────────────────────────────
|
|
568
596
|
/** List all item names directly under `prefix` in the given bucket. */
|
|
569
597
|
async listFiles(t, e) {
|
|
570
|
-
const o =
|
|
571
|
-
return (await
|
|
598
|
+
const o = S(this._bucket(t), e);
|
|
599
|
+
return (await G(o)).items.map((a) => a.name);
|
|
572
600
|
}
|
|
573
601
|
/**
|
|
574
602
|
* Recursively list all file full-paths under `prefix` in the given bucket.
|
|
@@ -576,7 +604,7 @@ class It {
|
|
|
576
604
|
*/
|
|
577
605
|
async listFilesRecursive(t, e) {
|
|
578
606
|
const o = this._bucket(t), r = async (a) => {
|
|
579
|
-
const i = await
|
|
607
|
+
const i = await G(S(o, a));
|
|
580
608
|
let n = i.items.map((p) => p.fullPath);
|
|
581
609
|
for (const p of i.prefixes)
|
|
582
610
|
n = n.concat(await r(p.fullPath));
|
|
@@ -592,7 +620,7 @@ class It {
|
|
|
592
620
|
const { deleteObject: o } = await import("firebase/storage"), r = this._bucket(t);
|
|
593
621
|
let a = 0;
|
|
594
622
|
const i = async (n) => {
|
|
595
|
-
const p = await
|
|
623
|
+
const p = await G(S(r, n));
|
|
596
624
|
for (const c of p.items)
|
|
597
625
|
await o(c), a++;
|
|
598
626
|
for (const c of p.prefixes)
|
|
@@ -602,59 +630,68 @@ class It {
|
|
|
602
630
|
}
|
|
603
631
|
// ─── Legacy helpers kept for CueBlobStorage consumers ────────────────────
|
|
604
632
|
// (used by loaders / processors that were already depending on CueBlobStorage)
|
|
605
|
-
/**
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
633
|
+
/**
|
|
634
|
+
* Upload binary data to the raw bucket with retry logic.
|
|
635
|
+
*
|
|
636
|
+
* `gzip` defaults to off (Phase 2: land inert). When `true`, the body is
|
|
637
|
+
* gzip-compressed and marked with both the native `contentEncoding: gzip`
|
|
638
|
+
* (so GCS/Firebase transparently decompress it on every read path) and
|
|
639
|
+
* `content_encoding: gzip` in `customMetadata` (so it's visible without
|
|
640
|
+
* downloading the object) — but only for suffixes in `_GZIP_SUFFIXES`;
|
|
641
|
+
* other suffixes upload uncompressed exactly as before, flag or not.
|
|
642
|
+
*/
|
|
643
|
+
async uploadRaw(t, e, o, r = 3, a, i, n = !1) {
|
|
644
|
+
const p = S(this.options.storageRaw, t), c = n && q._GZIP_SUFFIXES.has((o.suffix ?? "").toLowerCase()), h = c ? await q._gzipEncode(e) : e, d = c ? { contentEncoding: "gzip", customMetadata: { ...o, content_encoding: "gzip" } } : { customMetadata: o };
|
|
645
|
+
let u = 0, w;
|
|
646
|
+
for (; u < r; )
|
|
610
647
|
try {
|
|
611
|
-
await new Promise((
|
|
648
|
+
await new Promise((m, g) => {
|
|
612
649
|
if (a?.aborted) {
|
|
613
|
-
|
|
650
|
+
g(new DOMException("Upload cancelled", "AbortError"));
|
|
614
651
|
return;
|
|
615
652
|
}
|
|
616
|
-
const
|
|
617
|
-
|
|
653
|
+
const y = At(p, h, d), f = () => {
|
|
654
|
+
y.cancel(), g(new DOMException("Upload cancelled", "AbortError"));
|
|
618
655
|
};
|
|
619
|
-
a?.addEventListener("abort",
|
|
656
|
+
a?.addEventListener("abort", f, { once: !0 }), y.on(
|
|
620
657
|
"state_changed",
|
|
621
|
-
(
|
|
658
|
+
(_) => {
|
|
622
659
|
if (i) {
|
|
623
|
-
const
|
|
624
|
-
i(
|
|
660
|
+
const I = Math.round(_.bytesTransferred / _.totalBytes * 100);
|
|
661
|
+
i(I);
|
|
625
662
|
}
|
|
626
663
|
},
|
|
627
|
-
(
|
|
628
|
-
a?.removeEventListener("abort",
|
|
664
|
+
(_) => {
|
|
665
|
+
a?.removeEventListener("abort", f), g(_);
|
|
629
666
|
},
|
|
630
667
|
() => {
|
|
631
|
-
a?.removeEventListener("abort",
|
|
668
|
+
a?.removeEventListener("abort", f), m();
|
|
632
669
|
}
|
|
633
670
|
);
|
|
634
671
|
});
|
|
635
672
|
return;
|
|
636
|
-
} catch (
|
|
637
|
-
if (a?.aborted ||
|
|
638
|
-
throw
|
|
639
|
-
|
|
673
|
+
} catch (m) {
|
|
674
|
+
if (a?.aborted || m instanceof DOMException && m.name === "AbortError")
|
|
675
|
+
throw m;
|
|
676
|
+
w = m, u++, u < r && await new Promise((g) => setTimeout(g, 1e3 * u));
|
|
640
677
|
}
|
|
641
|
-
throw
|
|
678
|
+
throw w;
|
|
642
679
|
}
|
|
643
680
|
/**
|
|
644
681
|
* Upload data to the processed bucket.
|
|
645
682
|
* Skips upload and returns `false` if the blob already exists.
|
|
646
683
|
*/
|
|
647
684
|
async uploadProcessed(t, e, o) {
|
|
648
|
-
const r =
|
|
649
|
-
return await
|
|
685
|
+
const r = S(this.options.storageProcessed, t);
|
|
686
|
+
return await B(r).catch(() => null) ? !1 : (await gt(r, e, { customMetadata: o }), !0);
|
|
650
687
|
}
|
|
651
688
|
/** List all blob names directly under `prefix` in the raw bucket. */
|
|
652
689
|
async listRaw(t) {
|
|
653
|
-
const e =
|
|
654
|
-
return (await
|
|
690
|
+
const e = S(this.options.storageRaw, t);
|
|
691
|
+
return (await G(e)).items.map((r) => r.name);
|
|
655
692
|
}
|
|
656
693
|
}
|
|
657
|
-
class
|
|
694
|
+
class T {
|
|
658
695
|
_value;
|
|
659
696
|
_listeners = /* @__PURE__ */ new Set();
|
|
660
697
|
constructor(t) {
|
|
@@ -675,7 +712,7 @@ class E {
|
|
|
675
712
|
return this;
|
|
676
713
|
}
|
|
677
714
|
}
|
|
678
|
-
function
|
|
715
|
+
function Tt(s, t) {
|
|
679
716
|
const e = /* @__PURE__ */ new Set();
|
|
680
717
|
let o = t(), r = !1;
|
|
681
718
|
const a = [], i = () => {
|
|
@@ -697,17 +734,17 @@ function bt(s, t) {
|
|
|
697
734
|
}
|
|
698
735
|
};
|
|
699
736
|
}
|
|
700
|
-
const
|
|
737
|
+
const st = {
|
|
701
738
|
apiKey: "AIzaSyAiW42QBx9HS4Khu88pCW7MV66IhBAQul0",
|
|
702
739
|
appId: "1:151132927589:web:d2ffdb377dfadfd23ab88c",
|
|
703
740
|
measurementId: "G-YT4PK6HGZD"
|
|
704
|
-
},
|
|
705
|
-
class
|
|
741
|
+
}, Pt = "qaecy-mvp-406413", qo = "734737865998", Fo = "europe-west6", Dt = "sessions_eu_west6", Nt = "spaces_chats_eu_west6", jt = "spaces_raw_eu_west6", Lt = "spaces_processed_eu_west6", Ut = "logs_eu_west6", Mt = "cue_public_eu_west6", qt = "db_persistence_eu_west6", zo = "/data-views/admin/consumption", Bo = "/data-views/admin/profile/organizations", Ft = "/data-views/admin/profile/api-keys", zt = "/commands/admin/profile/api-keys", Go = "/commands/admin/profile/terms", Ho = "/commands/admin/profile/analytics-notice", Wo = "/commands/admin/usage/view", Vo = (s) => `/data-views/admin/organizations/${s}/members`, Xo = (s) => `/data-views/admin/organizations/${s}/admins`, Bt = (s) => `/data-views/admin/organizations/${s}/credits`, Ko = (s) => `/data-views/admin/organizations/${s}/credits/report`, Yo = (s, t) => `/data-views/admin/organizations/${s}/credits/report/${t}/by-file-type`, Qo = (s, t) => `/data-views/admin/organizations/${s}/traffic/report/${t}`, Jo = (s, t) => `/data-views/admin/organizations/${s}/usage/report/${t}`, Zo = "/commands/admin/user/signup", tr = "/commands/admin/user/signup/resend", er = "/commands/admin/user/settings", or = "/data-views/admin/users/settings", rr = "/commands/admin/organization/signup", sr = (s) => `/commands/admin/organization/${s}/credits`, ar = (s) => `/commands/admin/organization/${s}/plan`, ir = (s) => `/commands/admin/organization/${s}/checkout`, nr = (s) => `/commands/admin/organization/${s}/billing-portal`, pr = (s) => `/commands/admin/organization/${s}/members`, cr = (s, t) => `/commands/admin/organization/${s}/members/${t}/role`, lr = (s, t) => `/commands/admin/organization/${s}/members/${t}`, Gt = "/data-views/admin/projects", hr = "/data-views/admin/organizations", dr = "/data-views/admin/organizations/search", ur = (s) => `/data-views/admin/organizations/${s}/projects`, gr = "/data-views/admin/projects/search", mr = "/data-views/admin/users/search", wr = (s) => `/data-views/admin/users/${s}/detail`, fr = "/data-views/admin/users/superadmins", yr = "/data-views/admin/users/deleted", br = (s) => `/commands/admin/user/${s}`, _r = (s) => `/commands/admin/user/${s}/restore`, Ht = (s) => `/commands/admin/user/${s}/superadmin`, vr = "/commands/admin/user", Er = "/commands/admin/organization", Tr = (s) => `/commands/admin/organization/${s}`, Sr = (s) => `/commands/admin/organization/${s}/restore`, Cr = (s) => `/commands/admin/organization/${s}/domains`, kr = "/data-views/admin/organizations/deleted", Ir = "/data-views/admin/users/without-org", xr = "/data-views/admin/users/without-project", Rr = "/data-views/admin/projects/without-users", Ar = "/data-views/admin/projects/without-admins", Or = "/data-views/admin/organizations/without-users", $r = "/data-views/admin/organizations/without-admins", Pr = "/commands/admin/project", Dr = (s) => `/commands/admin/project/${s}`, Nr = (s) => `/commands/admin/project/${s}/restore`, jr = (s) => `/commands/admin/project/${s}/members`, Lr = (s, t) => `/commands/admin/project/${s}/members/${t}/role`, Ur = (s, t) => `/commands/admin/project/${s}/members/${t}`, Mr = (s) => `/data-views/admin/projects/${s}/metadata`, qr = (s) => `/commands/admin/project/${s}/metadata`, Fr = "/assistant/search", zr = "/mcp", Br = "/index/search", Gr = "/index/lookup", Hr = "/index/available-filters", Wr = "/triplestore/query", Vr = "/triplestore/shacl", Le = "/cue/qlever/query", Xr = "/cue/qlever/update", Kr = "/cue/qlever/shacl", Yr = "/cue/qlever/admin/rebuild", Qr = "/cue/admin/stats/refresh", Wt = "/commands/file-system-structure/batch", Jr = "/commands/dms-sync/providers", Zr = (s) => `/commands/dms-sync/${s}/preview`, ts = (s) => `/commands/dms-sync/${s}/sync`, es = "/storage/sessions", os = "/storage/raw", Ue = "/storage/processed", rs = "/data-views/processing-status", ss = "/data-views/processing-status/mine", Vt = "microsoft.com", Xt = "superadmin", St = "https://cue.qaecy.com/r/";
|
|
742
|
+
class Kt {
|
|
706
743
|
_auth;
|
|
707
744
|
_endpoints;
|
|
708
|
-
_userSignal = new
|
|
709
|
-
_tokenSignal = new
|
|
710
|
-
_isSuperAdminSignal = new
|
|
745
|
+
_userSignal = new T(null);
|
|
746
|
+
_tokenSignal = new T(null);
|
|
747
|
+
_isSuperAdminSignal = new T(!1);
|
|
711
748
|
_userIdsSignal;
|
|
712
749
|
_stopTokenListener;
|
|
713
750
|
/** Reactive auth state — emits the signed-in `User`, or `null` when signed out. */
|
|
@@ -719,19 +756,19 @@ class Bt {
|
|
|
719
756
|
/** All unique UIDs for the current user (Firebase UID + linked provider UIDs). */
|
|
720
757
|
userIds;
|
|
721
758
|
constructor(t, e = !1, o) {
|
|
722
|
-
this._auth =
|
|
759
|
+
this._auth = lo(t), this._endpoints = o, e && ho(this._auth, o.authEmulatorUrl, {
|
|
723
760
|
disableWarnings: !0
|
|
724
|
-
}), this.user = this._userSignal.asReadonly(), this.token = this._tokenSignal.asReadonly(), this.isSuperAdmin = this._isSuperAdminSignal.asReadonly(), this._userIdsSignal =
|
|
761
|
+
}), this.user = this._userSignal.asReadonly(), this.token = this._tokenSignal.asReadonly(), this.isSuperAdmin = this._isSuperAdminSignal.asReadonly(), this._userIdsSignal = Tt([this._userSignal], () => {
|
|
725
762
|
const r = this._userSignal.get();
|
|
726
763
|
if (!r) return [];
|
|
727
764
|
const a = /* @__PURE__ */ new Set([r.uid]);
|
|
728
765
|
return r.providerData.forEach((i) => a.add(i.uid)), Array.from(a);
|
|
729
|
-
}), this.userIds = this._userIdsSignal, this._stopTokenListener =
|
|
766
|
+
}), this.userIds = this._userIdsSignal, this._stopTokenListener = uo(this._auth, async (r) => {
|
|
730
767
|
if (this._userSignal.set(r), r) {
|
|
731
768
|
const a = await r.getIdToken();
|
|
732
769
|
this._tokenSignal.set(a);
|
|
733
|
-
const i = await
|
|
734
|
-
this._isSuperAdminSignal.set(i.claims.role ===
|
|
770
|
+
const i = await J(r);
|
|
771
|
+
this._isSuperAdminSignal.set(i.claims.role === Xt);
|
|
735
772
|
} else
|
|
736
773
|
this._tokenSignal.set(null), this._isSuperAdminSignal.set(!1);
|
|
737
774
|
});
|
|
@@ -744,14 +781,14 @@ class Bt {
|
|
|
744
781
|
if (t === "password") {
|
|
745
782
|
if (!e)
|
|
746
783
|
throw new Error("credentials are required for password sign-in");
|
|
747
|
-
return (await
|
|
784
|
+
return (await go(
|
|
748
785
|
this._auth,
|
|
749
786
|
e.email,
|
|
750
787
|
e.password
|
|
751
788
|
)).user;
|
|
752
789
|
}
|
|
753
|
-
const o = t === "google" ? new
|
|
754
|
-
return (await
|
|
790
|
+
const o = t === "google" ? new mt() : new wt(Vt);
|
|
791
|
+
return (await mo(this._auth, o)).user;
|
|
755
792
|
}
|
|
756
793
|
/**
|
|
757
794
|
* Initiate a redirect-based sign-in (mobile / iframe contexts where popups
|
|
@@ -759,8 +796,8 @@ class Bt {
|
|
|
759
796
|
* retrieve the result.
|
|
760
797
|
*/
|
|
761
798
|
async signInWithRedirect(t) {
|
|
762
|
-
const e = t === "google" ? new
|
|
763
|
-
await
|
|
799
|
+
const e = t === "google" ? new mt() : new wt(Vt);
|
|
800
|
+
await wo(this._auth, e);
|
|
764
801
|
}
|
|
765
802
|
/**
|
|
766
803
|
* Retrieve the result of a redirect sign-in. Returns the signed-in `User`
|
|
@@ -768,7 +805,7 @@ class Bt {
|
|
|
768
805
|
* Call this once on app startup before showing a sign-in UI.
|
|
769
806
|
*/
|
|
770
807
|
async checkRedirectResult() {
|
|
771
|
-
return (await
|
|
808
|
+
return (await fo(this._auth))?.user ?? null;
|
|
772
809
|
}
|
|
773
810
|
/**
|
|
774
811
|
* One-shot async check — returns `true` if the current user has the
|
|
@@ -777,7 +814,7 @@ class Bt {
|
|
|
777
814
|
*/
|
|
778
815
|
async checkSuperAdmin() {
|
|
779
816
|
const t = this._auth.currentUser;
|
|
780
|
-
return t ? (await
|
|
817
|
+
return t ? (await J(t)).claims.role === Xt : !1;
|
|
781
818
|
}
|
|
782
819
|
/** Sign in with a Cue API key. `projectId` is optional — omit it when no project context is available (e.g. admin flows). */
|
|
783
820
|
async signInWithApiKey(t, e) {
|
|
@@ -790,11 +827,11 @@ class Bt {
|
|
|
790
827
|
if (!r.ok)
|
|
791
828
|
throw new Error(`Failed to fetch custom token: ${r.statusText}`);
|
|
792
829
|
const { token: a } = await r.json();
|
|
793
|
-
return (await
|
|
830
|
+
return (await Ot(this._auth, a)).user;
|
|
794
831
|
}
|
|
795
832
|
/** Sign in with a Firebase custom token (e.g. minted server-side for MCP/OAuth flows). */
|
|
796
833
|
async signInWithCustomToken(t) {
|
|
797
|
-
return (await
|
|
834
|
+
return (await Ot(this._auth, t)).user;
|
|
798
835
|
}
|
|
799
836
|
/**
|
|
800
837
|
* Mint a short-lived Firebase custom token for the current user, scoped to
|
|
@@ -819,7 +856,7 @@ class Bt {
|
|
|
819
856
|
}
|
|
820
857
|
/** Sign out the current user */
|
|
821
858
|
async signOut() {
|
|
822
|
-
await
|
|
859
|
+
await yo(this._auth);
|
|
823
860
|
}
|
|
824
861
|
/** Currently signed-in user, or null if not authenticated */
|
|
825
862
|
get currentUser() {
|
|
@@ -827,7 +864,7 @@ class Bt {
|
|
|
827
864
|
}
|
|
828
865
|
/** Subscribe to authentication state changes. Returns an unsubscribe function. */
|
|
829
866
|
onAuthStateChanged(t) {
|
|
830
|
-
return
|
|
867
|
+
return bo(this._auth, t);
|
|
831
868
|
}
|
|
832
869
|
/** Get the Firebase ID token for the current user, or null if not authenticated */
|
|
833
870
|
async getToken(t = !1) {
|
|
@@ -859,14 +896,14 @@ class Bt {
|
|
|
859
896
|
return this._auth;
|
|
860
897
|
}
|
|
861
898
|
}
|
|
862
|
-
class
|
|
899
|
+
class as extends Error {
|
|
863
900
|
constructor(t, e, o) {
|
|
864
901
|
super(t), this.status = e, this.code = o;
|
|
865
902
|
}
|
|
866
903
|
status;
|
|
867
904
|
code;
|
|
868
905
|
}
|
|
869
|
-
class
|
|
906
|
+
class Yt {
|
|
870
907
|
constructor(t) {
|
|
871
908
|
this._gatewayUrl = t;
|
|
872
909
|
}
|
|
@@ -882,7 +919,7 @@ class Gt {
|
|
|
882
919
|
*/
|
|
883
920
|
async signUp(t, e, o, r) {
|
|
884
921
|
return this._publicPost(
|
|
885
|
-
|
|
922
|
+
Zo,
|
|
886
923
|
{ name: t, email: e, password: o, termsVersion: r },
|
|
887
924
|
"Sign-up failed"
|
|
888
925
|
);
|
|
@@ -896,11 +933,11 @@ class Gt {
|
|
|
896
933
|
* 'domainBlocked' for the mappable failure modes.
|
|
897
934
|
*/
|
|
898
935
|
async signUpWithOrganization(t) {
|
|
899
|
-
return this._publicPost(
|
|
936
|
+
return this._publicPost(rr, t, "Organisation sign-up failed");
|
|
900
937
|
}
|
|
901
938
|
/** Re-send the verification + set-password emails after a sign-up. */
|
|
902
939
|
async resendSignUpEmails(t) {
|
|
903
|
-
return this._publicPost(
|
|
940
|
+
return this._publicPost(tr, { email: t }, "Resend failed");
|
|
904
941
|
}
|
|
905
942
|
async _publicPost(t, e, o) {
|
|
906
943
|
const r = await fetch(`${this._gatewayUrl}${t}`, {
|
|
@@ -910,7 +947,7 @@ class Gt {
|
|
|
910
947
|
});
|
|
911
948
|
if (!r.ok) {
|
|
912
949
|
const a = await r.json().catch(() => ({}));
|
|
913
|
-
throw new
|
|
950
|
+
throw new as(
|
|
914
951
|
a?.message ?? `${o} (${r.status})`,
|
|
915
952
|
r.status,
|
|
916
953
|
a?.code
|
|
@@ -919,11 +956,11 @@ class Gt {
|
|
|
919
956
|
return r.json();
|
|
920
957
|
}
|
|
921
958
|
}
|
|
922
|
-
const
|
|
923
|
-
raw:
|
|
924
|
-
processed:
|
|
959
|
+
const is = {
|
|
960
|
+
raw: os,
|
|
961
|
+
processed: Ue
|
|
925
962
|
};
|
|
926
|
-
class
|
|
963
|
+
class Qt {
|
|
927
964
|
constructor(t, e) {
|
|
928
965
|
this._auth = t, this._gatewayUrl = e;
|
|
929
966
|
}
|
|
@@ -941,7 +978,7 @@ class Ht {
|
|
|
941
978
|
* @param bucket - `'raw'` (default, original uploads) or `'processed'` (derived artefacts).
|
|
942
979
|
*/
|
|
943
980
|
getDownloadUrl(t, e, o, r = "raw") {
|
|
944
|
-
return `${this._gatewayUrl}${
|
|
981
|
+
return `${this._gatewayUrl}${is[r]}/${t}/${e}${o}`;
|
|
945
982
|
}
|
|
946
983
|
/**
|
|
947
984
|
* Returns a gateway download URL for an alternative representation using its
|
|
@@ -954,7 +991,7 @@ class Ht {
|
|
|
954
991
|
* e.g. `{projectId}/fragments/{uuid}.fragments`.
|
|
955
992
|
*/
|
|
956
993
|
getAltRepDownloadUrl(t) {
|
|
957
|
-
return `${this._gatewayUrl}${
|
|
994
|
+
return `${this._gatewayUrl}${Ue}/${t}`;
|
|
958
995
|
}
|
|
959
996
|
/**
|
|
960
997
|
* Fetch a file through the gateway and return it as a Blob.
|
|
@@ -969,8 +1006,8 @@ class Ht {
|
|
|
969
1006
|
return i.blob();
|
|
970
1007
|
}
|
|
971
1008
|
}
|
|
972
|
-
const
|
|
973
|
-
class
|
|
1009
|
+
const ns = "/data-views/tables", ps = "/commands/tables";
|
|
1010
|
+
class cs {
|
|
974
1011
|
constructor(t, e) {
|
|
975
1012
|
this._auth = t, this._gatewayUrl = e;
|
|
976
1013
|
}
|
|
@@ -978,7 +1015,7 @@ class Kr {
|
|
|
978
1015
|
_gatewayUrl;
|
|
979
1016
|
async listTables(t) {
|
|
980
1017
|
const e = await this._auth.authenticatedFetch(
|
|
981
|
-
`${this._gatewayUrl}${
|
|
1018
|
+
`${this._gatewayUrl}${ns}`,
|
|
982
1019
|
{
|
|
983
1020
|
headers: {
|
|
984
1021
|
"Content-Type": "application/json",
|
|
@@ -993,7 +1030,7 @@ class Kr {
|
|
|
993
1030
|
}
|
|
994
1031
|
async saveTables(t, e) {
|
|
995
1032
|
const o = await this._auth.authenticatedFetch(
|
|
996
|
-
`${this._gatewayUrl}${
|
|
1033
|
+
`${this._gatewayUrl}${ps}`,
|
|
997
1034
|
{
|
|
998
1035
|
method: "PUT",
|
|
999
1036
|
headers: {
|
|
@@ -1008,8 +1045,8 @@ class Kr {
|
|
|
1008
1045
|
throw new Error(`Failed to save tables: ${o.status} ${o.statusText}`);
|
|
1009
1046
|
}
|
|
1010
1047
|
}
|
|
1011
|
-
const
|
|
1012
|
-
class
|
|
1048
|
+
const ls = "/semantic-extraction/extract";
|
|
1049
|
+
class hs {
|
|
1013
1050
|
constructor(t, e) {
|
|
1014
1051
|
this._auth = t, this._gatewayUrl = e;
|
|
1015
1052
|
}
|
|
@@ -1026,7 +1063,7 @@ class Jr {
|
|
|
1026
1063
|
const e = t.rdfFormat ?? "json-ld", o = new FormData();
|
|
1027
1064
|
o.append("file", t.image, "page.png"), o.append("template", JSON.stringify(t.template)), 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);
|
|
1028
1065
|
const r = await this._auth.authenticatedFetch(
|
|
1029
|
-
`${this._gatewayUrl}${
|
|
1066
|
+
`${this._gatewayUrl}${ls}`,
|
|
1030
1067
|
{
|
|
1031
1068
|
method: "POST",
|
|
1032
1069
|
// Do NOT set Content-Type; browser sets it with the correct boundary.
|
|
@@ -1047,7 +1084,7 @@ class Jr {
|
|
|
1047
1084
|
return { jsonld: await r.json() };
|
|
1048
1085
|
}
|
|
1049
1086
|
}
|
|
1050
|
-
class
|
|
1087
|
+
class ds {
|
|
1051
1088
|
constructor(t, e) {
|
|
1052
1089
|
this._auth = t, this._gatewayUrl = e;
|
|
1053
1090
|
}
|
|
@@ -1063,7 +1100,7 @@ class Zr {
|
|
|
1063
1100
|
* @param contextId - The context document ID (without the `.json.gz` suffix).
|
|
1064
1101
|
*/
|
|
1065
1102
|
async getContext(t, e) {
|
|
1066
|
-
const o = `${this._gatewayUrl}${
|
|
1103
|
+
const o = `${this._gatewayUrl}${es}/${t}/contexts/${e}.json.gz`, r = await this._auth.authenticatedFetch(o, {
|
|
1067
1104
|
headers: {
|
|
1068
1105
|
"cue-project-id": t,
|
|
1069
1106
|
// Prevent the HTTP layer from auto-decompressing so we can handle it explicitly.
|
|
@@ -1076,7 +1113,7 @@ class Zr {
|
|
|
1076
1113
|
return JSON.parse(await new Response(i).text());
|
|
1077
1114
|
}
|
|
1078
1115
|
}
|
|
1079
|
-
class
|
|
1116
|
+
class us {
|
|
1080
1117
|
constructor(t, e) {
|
|
1081
1118
|
this._auth = t, this._gatewayUrl = e;
|
|
1082
1119
|
}
|
|
@@ -1084,7 +1121,7 @@ class ts {
|
|
|
1084
1121
|
_gatewayUrl;
|
|
1085
1122
|
async search(t, e, o) {
|
|
1086
1123
|
const r = await this._auth.authenticatedFetch(
|
|
1087
|
-
`${this._gatewayUrl}${
|
|
1124
|
+
`${this._gatewayUrl}${Br}`,
|
|
1088
1125
|
{
|
|
1089
1126
|
method: "POST",
|
|
1090
1127
|
headers: { "Content-Type": "application/json", "x-project-id": e },
|
|
@@ -1097,7 +1134,7 @@ class ts {
|
|
|
1097
1134
|
async lookup(t, e, o) {
|
|
1098
1135
|
console.log(`CueIndexApi.lookup: input=${t}, projectId=${e}, opts=${JSON.stringify(o)}`);
|
|
1099
1136
|
const r = await this._auth.authenticatedFetch(
|
|
1100
|
-
`${this._gatewayUrl}${
|
|
1137
|
+
`${this._gatewayUrl}${Gr}`,
|
|
1101
1138
|
{
|
|
1102
1139
|
method: "POST",
|
|
1103
1140
|
headers: { "Content-Type": "application/json", "x-project-id": e },
|
|
@@ -1121,7 +1158,7 @@ class ts {
|
|
|
1121
1158
|
async availableFilters(t, e) {
|
|
1122
1159
|
console.log(`CueIndexApi.availableFilters(projectId=${t}, applied=${JSON.stringify(e)})`);
|
|
1123
1160
|
const o = await this._auth.authenticatedFetch(
|
|
1124
|
-
`${this._gatewayUrl}${
|
|
1161
|
+
`${this._gatewayUrl}${Hr}`,
|
|
1125
1162
|
{
|
|
1126
1163
|
method: "POST",
|
|
1127
1164
|
headers: { "Content-Type": "application/json", "x-project-id": t },
|
|
@@ -1143,7 +1180,7 @@ class ts {
|
|
|
1143
1180
|
*/
|
|
1144
1181
|
async rebuild(t, e) {
|
|
1145
1182
|
const o = await this._auth.authenticatedFetch(
|
|
1146
|
-
`${this._gatewayUrl}${
|
|
1183
|
+
`${this._gatewayUrl}${Yr}`,
|
|
1147
1184
|
{ method: "POST", headers: { "x-project-id": t } }
|
|
1148
1185
|
);
|
|
1149
1186
|
if (!o.ok || !o.body)
|
|
@@ -1175,7 +1212,7 @@ class ts {
|
|
|
1175
1212
|
*/
|
|
1176
1213
|
async refreshStats(t) {
|
|
1177
1214
|
const e = t ? `?projectId=${encodeURIComponent(t)}` : "", o = await this._auth.authenticatedFetch(
|
|
1178
|
-
`${this._gatewayUrl}${
|
|
1215
|
+
`${this._gatewayUrl}${Qr}${e}`,
|
|
1179
1216
|
{ method: "POST" }
|
|
1180
1217
|
);
|
|
1181
1218
|
if (!o.ok)
|
|
@@ -1184,46 +1221,46 @@ class ts {
|
|
|
1184
1221
|
return t ? "Refreshed stats for this project." : `Refreshed stats for ${r.totalDatasets} project(s).`;
|
|
1185
1222
|
}
|
|
1186
1223
|
}
|
|
1187
|
-
const
|
|
1188
|
-
function
|
|
1224
|
+
const gs = "@qaecy/cue-sdk", ms = "0.0.34";
|
|
1225
|
+
function ws(s) {
|
|
1189
1226
|
const t = {};
|
|
1190
1227
|
return new Headers(s).forEach((e, o) => {
|
|
1191
1228
|
t[o] = e;
|
|
1192
1229
|
}), t;
|
|
1193
1230
|
}
|
|
1194
|
-
function
|
|
1231
|
+
function Me(s) {
|
|
1195
1232
|
return s.filter((t) => t.type === "text").map((t) => t.text).join(`
|
|
1196
1233
|
`);
|
|
1197
1234
|
}
|
|
1198
|
-
function
|
|
1235
|
+
function fs(s) {
|
|
1199
1236
|
return typeof s == "object" && s !== null && typeof s.error == "string" && !("id" in s);
|
|
1200
1237
|
}
|
|
1201
|
-
function
|
|
1238
|
+
function ys(s) {
|
|
1202
1239
|
const t = s.structuredContent;
|
|
1203
1240
|
if (t != null) return t;
|
|
1204
|
-
const e =
|
|
1241
|
+
const e = Me(s.content);
|
|
1205
1242
|
try {
|
|
1206
1243
|
return JSON.parse(e);
|
|
1207
1244
|
} catch {
|
|
1208
1245
|
return e;
|
|
1209
1246
|
}
|
|
1210
1247
|
}
|
|
1211
|
-
class
|
|
1248
|
+
class bs {
|
|
1212
1249
|
constructor(t, e) {
|
|
1213
1250
|
this._auth = t, this._gatewayUrl = e;
|
|
1214
1251
|
}
|
|
1215
1252
|
_auth;
|
|
1216
1253
|
_gatewayUrl;
|
|
1217
1254
|
async callTool(t, e, o) {
|
|
1218
|
-
const r = new
|
|
1219
|
-
new URL(`${this._gatewayUrl}${
|
|
1255
|
+
const r = new Io({ name: gs, version: ms }), a = new xo(
|
|
1256
|
+
new URL(`${this._gatewayUrl}${zr}`),
|
|
1220
1257
|
{
|
|
1221
1258
|
// Route every MCP HTTP request through the SDK's authenticated fetch so
|
|
1222
1259
|
// the gateway sees a Firebase Bearer token (and 401s trigger a refresh).
|
|
1223
1260
|
// The transport passes headers as a `Headers` instance; authenticatedFetch
|
|
1224
1261
|
// merges via object spread, which drops a `Headers` object — so flatten to
|
|
1225
1262
|
// a plain record first to preserve content-type/accept/session headers.
|
|
1226
|
-
fetch: (i, n) => this._auth.authenticatedFetch(i.toString(), { ...n, headers:
|
|
1263
|
+
fetch: (i, n) => this._auth.authenticatedFetch(i.toString(), { ...n, headers: ws(n?.headers) })
|
|
1227
1264
|
}
|
|
1228
1265
|
);
|
|
1229
1266
|
try {
|
|
@@ -1234,9 +1271,9 @@ class is {
|
|
|
1234
1271
|
o?.signal ? { signal: o.signal } : void 0
|
|
1235
1272
|
);
|
|
1236
1273
|
if (i.isError)
|
|
1237
|
-
throw new Error(`MCP tool '${t}' failed: ${
|
|
1238
|
-
const n =
|
|
1239
|
-
if (
|
|
1274
|
+
throw new Error(`MCP tool '${t}' failed: ${Me(i.content) || "unknown error"}`);
|
|
1275
|
+
const n = ys(i);
|
|
1276
|
+
if (fs(n))
|
|
1240
1277
|
throw new Error(`MCP tool '${t}' failed: ${n.error}`);
|
|
1241
1278
|
return n;
|
|
1242
1279
|
} finally {
|
|
@@ -1245,8 +1282,8 @@ class is {
|
|
|
1245
1282
|
}
|
|
1246
1283
|
}
|
|
1247
1284
|
}
|
|
1248
|
-
const
|
|
1249
|
-
class
|
|
1285
|
+
const _s = "/data-views/app-data", vs = "/commands/app-data";
|
|
1286
|
+
class Es {
|
|
1250
1287
|
constructor(t, e) {
|
|
1251
1288
|
this._auth = t, this._gatewayUrl = e;
|
|
1252
1289
|
}
|
|
@@ -1258,7 +1295,7 @@ class cs {
|
|
|
1258
1295
|
*/
|
|
1259
1296
|
async get(t) {
|
|
1260
1297
|
const e = await this._auth.authenticatedFetch(
|
|
1261
|
-
`${this._gatewayUrl}${
|
|
1298
|
+
`${this._gatewayUrl}${_s}/${encodeURIComponent(t)}`,
|
|
1262
1299
|
{ headers: { "Content-Type": "application/json" } }
|
|
1263
1300
|
);
|
|
1264
1301
|
if (!e.ok)
|
|
@@ -1272,7 +1309,7 @@ class cs {
|
|
|
1272
1309
|
*/
|
|
1273
1310
|
async set(t, e) {
|
|
1274
1311
|
const o = await this._auth.authenticatedFetch(
|
|
1275
|
-
`${this._gatewayUrl}${
|
|
1312
|
+
`${this._gatewayUrl}${vs}/${encodeURIComponent(t)}`,
|
|
1276
1313
|
{
|
|
1277
1314
|
method: "PUT",
|
|
1278
1315
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1291,8 +1328,8 @@ class cs {
|
|
|
1291
1328
|
}
|
|
1292
1329
|
}
|
|
1293
1330
|
}
|
|
1294
|
-
const
|
|
1295
|
-
class
|
|
1331
|
+
const Jt = "/data-views/custom-apps", at = "/commands/custom-apps";
|
|
1332
|
+
class Ts {
|
|
1296
1333
|
constructor(t, e) {
|
|
1297
1334
|
this._auth = t, this._gatewayUrl = e;
|
|
1298
1335
|
}
|
|
@@ -1301,7 +1338,7 @@ class ls {
|
|
|
1301
1338
|
/** List every custom app shared within the given organization (metadata only, no HTML). */
|
|
1302
1339
|
async list(t) {
|
|
1303
1340
|
const e = await this._auth.authenticatedFetch(
|
|
1304
|
-
`${this._gatewayUrl}${
|
|
1341
|
+
`${this._gatewayUrl}${Jt}?organizationId=${encodeURIComponent(t)}`
|
|
1305
1342
|
);
|
|
1306
1343
|
if (!e.ok)
|
|
1307
1344
|
throw new Error(`Failed to list custom apps: ${e.status} ${e.statusText}`);
|
|
@@ -1310,7 +1347,7 @@ class ls {
|
|
|
1310
1347
|
/** Fetch a single custom app's full record, including its HTML body. */
|
|
1311
1348
|
async get(t) {
|
|
1312
1349
|
const e = await this._auth.authenticatedFetch(
|
|
1313
|
-
`${this._gatewayUrl}${
|
|
1350
|
+
`${this._gatewayUrl}${Jt}/${encodeURIComponent(t)}`
|
|
1314
1351
|
);
|
|
1315
1352
|
if (!e.ok)
|
|
1316
1353
|
throw new Error(`Failed to fetch custom app: ${e.status} ${e.statusText}`);
|
|
@@ -1318,7 +1355,7 @@ class ls {
|
|
|
1318
1355
|
}
|
|
1319
1356
|
/** Save a new custom app, shared with every member of `organizationID`. Any org member may create one. */
|
|
1320
1357
|
async create(t) {
|
|
1321
|
-
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
1358
|
+
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${at}`, {
|
|
1322
1359
|
method: "POST",
|
|
1323
1360
|
headers: { "Content-Type": "application/json" },
|
|
1324
1361
|
body: JSON.stringify(t)
|
|
@@ -1330,7 +1367,7 @@ class ls {
|
|
|
1330
1367
|
/** Update an existing custom app. Only the original author or an organization admin may do this. */
|
|
1331
1368
|
async update(t, e) {
|
|
1332
1369
|
const o = await this._auth.authenticatedFetch(
|
|
1333
|
-
`${this._gatewayUrl}${
|
|
1370
|
+
`${this._gatewayUrl}${at}/${encodeURIComponent(t)}`,
|
|
1334
1371
|
{
|
|
1335
1372
|
method: "PUT",
|
|
1336
1373
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1344,14 +1381,14 @@ class ls {
|
|
|
1344
1381
|
/** Delete a custom app. Only the original author or an organization admin may do this. */
|
|
1345
1382
|
async remove(t) {
|
|
1346
1383
|
const e = await this._auth.authenticatedFetch(
|
|
1347
|
-
`${this._gatewayUrl}${
|
|
1384
|
+
`${this._gatewayUrl}${at}/${encodeURIComponent(t)}`,
|
|
1348
1385
|
{ method: "DELETE" }
|
|
1349
1386
|
);
|
|
1350
1387
|
if (!e.ok)
|
|
1351
1388
|
throw new Error(`Failed to delete custom app: ${e.status} ${e.statusText}`);
|
|
1352
1389
|
}
|
|
1353
1390
|
}
|
|
1354
|
-
class
|
|
1391
|
+
class Ss {
|
|
1355
1392
|
constructor(t, e) {
|
|
1356
1393
|
this._auth = t, this._gatewayUrl = e;
|
|
1357
1394
|
}
|
|
@@ -1363,7 +1400,7 @@ class hs {
|
|
|
1363
1400
|
*/
|
|
1364
1401
|
async get() {
|
|
1365
1402
|
const t = await this._auth.authenticatedFetch(
|
|
1366
|
-
`${this._gatewayUrl}${
|
|
1403
|
+
`${this._gatewayUrl}${or}`,
|
|
1367
1404
|
{ headers: { "Content-Type": "application/json" } }
|
|
1368
1405
|
);
|
|
1369
1406
|
if (!t.ok)
|
|
@@ -1377,7 +1414,7 @@ class hs {
|
|
|
1377
1414
|
*/
|
|
1378
1415
|
async set(t) {
|
|
1379
1416
|
const e = await this._auth.authenticatedFetch(
|
|
1380
|
-
`${this._gatewayUrl}${
|
|
1417
|
+
`${this._gatewayUrl}${er}`,
|
|
1381
1418
|
{
|
|
1382
1419
|
method: "PUT",
|
|
1383
1420
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1396,8 +1433,8 @@ class hs {
|
|
|
1396
1433
|
}
|
|
1397
1434
|
}
|
|
1398
1435
|
}
|
|
1399
|
-
const
|
|
1400
|
-
class
|
|
1436
|
+
const it = 3e3;
|
|
1437
|
+
class Cs {
|
|
1401
1438
|
constructor(t, e) {
|
|
1402
1439
|
this._auth = t, this._gatewayUrl = e;
|
|
1403
1440
|
}
|
|
@@ -1410,7 +1447,7 @@ class ds {
|
|
|
1410
1447
|
*/
|
|
1411
1448
|
watchStatus(t) {
|
|
1412
1449
|
const { signal: e, close: o } = this._open(
|
|
1413
|
-
|
|
1450
|
+
rs,
|
|
1414
1451
|
{ projectId: t },
|
|
1415
1452
|
`project "${t}"`
|
|
1416
1453
|
);
|
|
@@ -1430,7 +1467,7 @@ class ds {
|
|
|
1430
1467
|
*/
|
|
1431
1468
|
watchMyStatus() {
|
|
1432
1469
|
const { signal: t, close: e } = this._open(
|
|
1433
|
-
|
|
1470
|
+
ss,
|
|
1434
1471
|
{},
|
|
1435
1472
|
"current user"
|
|
1436
1473
|
);
|
|
@@ -1443,27 +1480,27 @@ class ds {
|
|
|
1443
1480
|
* query string because browsers cannot set headers on a WebSocket handshake.
|
|
1444
1481
|
*/
|
|
1445
1482
|
_open(t, e, o) {
|
|
1446
|
-
const r = new
|
|
1483
|
+
const r = new T(void 0);
|
|
1447
1484
|
let a = null, i = null, n = !1;
|
|
1448
1485
|
const p = async () => {
|
|
1449
1486
|
if (n) return;
|
|
1450
1487
|
const c = await this._auth.getToken();
|
|
1451
1488
|
if (n) return;
|
|
1452
1489
|
if (!c) {
|
|
1453
|
-
i = setTimeout(p,
|
|
1490
|
+
i = setTimeout(p, it);
|
|
1454
1491
|
return;
|
|
1455
1492
|
}
|
|
1456
1493
|
const h = `${this._gatewayUrl.replace(/^http/, "ws")}${t}`, d = new URLSearchParams({ ...e, token: c }), u = `${h}?${d.toString()}`;
|
|
1457
|
-
a = new WebSocket(u), a.onopen = () => console.info(`[CueProcessingApi] connected for ${o}`), a.onmessage = (
|
|
1494
|
+
a = new WebSocket(u), a.onopen = () => console.info(`[CueProcessingApi] connected for ${o}`), a.onmessage = (w) => {
|
|
1458
1495
|
try {
|
|
1459
|
-
r.set(JSON.parse(
|
|
1460
|
-
} catch (
|
|
1461
|
-
console.warn("[CueProcessingApi] failed to parse status payload",
|
|
1496
|
+
r.set(JSON.parse(w.data));
|
|
1497
|
+
} catch (m) {
|
|
1498
|
+
console.warn("[CueProcessingApi] failed to parse status payload", m);
|
|
1462
1499
|
}
|
|
1463
|
-
}, a.onclose = (
|
|
1500
|
+
}, a.onclose = (w) => {
|
|
1464
1501
|
n || (console.warn(
|
|
1465
|
-
`[CueProcessingApi] connection closed (code=${
|
|
1466
|
-
), i = setTimeout(p,
|
|
1502
|
+
`[CueProcessingApi] connection closed (code=${w.code}${w.reason ? `, reason=${w.reason}` : ""}), reconnecting in ${it}ms`
|
|
1503
|
+
), i = setTimeout(p, it));
|
|
1467
1504
|
}, a.onerror = () => {
|
|
1468
1505
|
console.warn(`[CueProcessingApi] WebSocket error for ${o} (url=${u})`);
|
|
1469
1506
|
};
|
|
@@ -1476,7 +1513,7 @@ class ds {
|
|
|
1476
1513
|
};
|
|
1477
1514
|
}
|
|
1478
1515
|
}
|
|
1479
|
-
class
|
|
1516
|
+
class ks {
|
|
1480
1517
|
constructor(t, e) {
|
|
1481
1518
|
this._auth = t, this._gatewayUrl = e;
|
|
1482
1519
|
}
|
|
@@ -1485,7 +1522,7 @@ class us {
|
|
|
1485
1522
|
/** Lists the DMS providers this project can sync from. */
|
|
1486
1523
|
async listSupportedProviders() {
|
|
1487
1524
|
const t = await this._auth.authenticatedFetch(
|
|
1488
|
-
`${this._gatewayUrl}${
|
|
1525
|
+
`${this._gatewayUrl}${Jr}`,
|
|
1489
1526
|
{ headers: { "Content-Type": "application/json" } }
|
|
1490
1527
|
);
|
|
1491
1528
|
if (!t.ok)
|
|
@@ -1499,7 +1536,7 @@ class us {
|
|
|
1499
1536
|
*/
|
|
1500
1537
|
async previewSync(t, e, o) {
|
|
1501
1538
|
const r = await this._auth.authenticatedFetch(
|
|
1502
|
-
`${this._gatewayUrl}${
|
|
1539
|
+
`${this._gatewayUrl}${Zr(t)}`,
|
|
1503
1540
|
{
|
|
1504
1541
|
method: "POST",
|
|
1505
1542
|
headers: {
|
|
@@ -1520,7 +1557,7 @@ class us {
|
|
|
1520
1557
|
*/
|
|
1521
1558
|
async confirmSync(t, e, o) {
|
|
1522
1559
|
const r = await this._auth.authenticatedFetch(
|
|
1523
|
-
`${this._gatewayUrl}${
|
|
1560
|
+
`${this._gatewayUrl}${ts(t)}`,
|
|
1524
1561
|
{
|
|
1525
1562
|
method: "POST",
|
|
1526
1563
|
headers: {
|
|
@@ -1536,8 +1573,8 @@ class us {
|
|
|
1536
1573
|
return r.json();
|
|
1537
1574
|
}
|
|
1538
1575
|
}
|
|
1539
|
-
const
|
|
1540
|
-
class
|
|
1576
|
+
const Is = "/llm-tools/wrangling-schema/generate", xs = "/llm-tools/wrangling-schema/refine", Rs = "/llm-tools/entity-category-suggestion/suggest", As = "/llm-tools/entity-category-suggestion/suggest-batch";
|
|
1577
|
+
class Os {
|
|
1541
1578
|
constructor(t, e) {
|
|
1542
1579
|
this._auth = t, this._gatewayUrl = e;
|
|
1543
1580
|
}
|
|
@@ -1550,7 +1587,7 @@ class ws {
|
|
|
1550
1587
|
*/
|
|
1551
1588
|
async generateWranglingSchema(t) {
|
|
1552
1589
|
const e = await this._auth.authenticatedFetch(
|
|
1553
|
-
`${this._gatewayUrl}${
|
|
1590
|
+
`${this._gatewayUrl}${Is}`,
|
|
1554
1591
|
{
|
|
1555
1592
|
method: "POST",
|
|
1556
1593
|
headers: {
|
|
@@ -1581,7 +1618,7 @@ class ws {
|
|
|
1581
1618
|
*/
|
|
1582
1619
|
async refineWranglingSchema(t) {
|
|
1583
1620
|
const e = await this._auth.authenticatedFetch(
|
|
1584
|
-
`${this._gatewayUrl}${
|
|
1621
|
+
`${this._gatewayUrl}${xs}`,
|
|
1585
1622
|
{
|
|
1586
1623
|
method: "POST",
|
|
1587
1624
|
headers: {
|
|
@@ -1593,6 +1630,7 @@ class ws {
|
|
|
1593
1630
|
previousPrompt: t.previousPrompt,
|
|
1594
1631
|
currentRules: t.currentRules,
|
|
1595
1632
|
prompt: t.prompt,
|
|
1633
|
+
mode: t.mode,
|
|
1596
1634
|
columns: t.columns,
|
|
1597
1635
|
exampleRows: t.exampleRows
|
|
1598
1636
|
})
|
|
@@ -1606,16 +1644,80 @@ class ws {
|
|
|
1606
1644
|
}
|
|
1607
1645
|
return e.json();
|
|
1608
1646
|
}
|
|
1647
|
+
/**
|
|
1648
|
+
* Given a label (and optional description) for a new entity category or relationship, decides
|
|
1649
|
+
* whether it already exists in the project's ontology under a different name/wording — so a
|
|
1650
|
+
* person doesn't have to eyeball a long list themselves — or suggests a well-formed new one,
|
|
1651
|
+
* including a parent nested under an existing category/relationship when that fits.
|
|
1652
|
+
*/
|
|
1653
|
+
async suggestEntityCategory(t) {
|
|
1654
|
+
const e = await this._auth.authenticatedFetch(
|
|
1655
|
+
`${this._gatewayUrl}${Rs}`,
|
|
1656
|
+
{
|
|
1657
|
+
method: "POST",
|
|
1658
|
+
headers: {
|
|
1659
|
+
"Content-Type": "application/json",
|
|
1660
|
+
"x-project-id": t.projectId,
|
|
1661
|
+
"cue-project-id": t.projectId
|
|
1662
|
+
},
|
|
1663
|
+
body: JSON.stringify({
|
|
1664
|
+
label: t.label,
|
|
1665
|
+
description: t.description,
|
|
1666
|
+
kind: t.kind,
|
|
1667
|
+
existingCategories: t.existingCategories
|
|
1668
|
+
})
|
|
1669
|
+
}
|
|
1670
|
+
);
|
|
1671
|
+
if (!e.ok) {
|
|
1672
|
+
const o = await e.text().catch(() => "");
|
|
1673
|
+
throw new Error(
|
|
1674
|
+
`Entity category suggestion failed: ${e.status} ${e.statusText}${o ? " — " + o.slice(0, 300) : ""}`
|
|
1675
|
+
);
|
|
1676
|
+
}
|
|
1677
|
+
return e.json();
|
|
1678
|
+
}
|
|
1679
|
+
/**
|
|
1680
|
+
* Given every currently-unmapped column in a sheet (name plus a few real values) and the
|
|
1681
|
+
* project's existing entity categories, decides for each one whether it should stay unmapped,
|
|
1682
|
+
* map to an existing category, or become a well-formed new one — one call covering every
|
|
1683
|
+
* column at once, so the model can also stay consistent across them (e.g. not suggesting the
|
|
1684
|
+
* same new category twice under different names).
|
|
1685
|
+
*/
|
|
1686
|
+
async suggestEntityCategoryBatch(t) {
|
|
1687
|
+
const e = await this._auth.authenticatedFetch(
|
|
1688
|
+
`${this._gatewayUrl}${As}`,
|
|
1689
|
+
{
|
|
1690
|
+
method: "POST",
|
|
1691
|
+
headers: {
|
|
1692
|
+
"Content-Type": "application/json",
|
|
1693
|
+
"x-project-id": t.projectId,
|
|
1694
|
+
"cue-project-id": t.projectId
|
|
1695
|
+
},
|
|
1696
|
+
body: JSON.stringify({
|
|
1697
|
+
columns: t.columns,
|
|
1698
|
+
existingCategories: t.existingCategories
|
|
1699
|
+
})
|
|
1700
|
+
}
|
|
1701
|
+
);
|
|
1702
|
+
if (!e.ok) {
|
|
1703
|
+
const o = await e.text().catch(() => "");
|
|
1704
|
+
throw new Error(
|
|
1705
|
+
`Entity category batch suggestion failed: ${e.status} ${e.statusText}${o ? " — " + o.slice(0, 300) : ""}`
|
|
1706
|
+
);
|
|
1707
|
+
}
|
|
1708
|
+
return e.json();
|
|
1709
|
+
}
|
|
1609
1710
|
}
|
|
1610
|
-
const
|
|
1611
|
-
class
|
|
1612
|
-
constructor(t, e) {
|
|
1613
|
-
this._auth = t, this._gatewayUrl = e;
|
|
1711
|
+
const j = "/commands/data-sources", Zt = "/data-views/data-sources", $s = 18e4;
|
|
1712
|
+
class Ps {
|
|
1713
|
+
constructor(t, e, o) {
|
|
1714
|
+
this._auth = t, this._gatewayUrl = e, this._blob = o;
|
|
1614
1715
|
}
|
|
1615
1716
|
_auth;
|
|
1616
1717
|
_gatewayUrl;
|
|
1718
|
+
_blob;
|
|
1617
1719
|
async createDataSource(t, e, o) {
|
|
1618
|
-
const r = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
1720
|
+
const r = await this._auth.authenticatedFetch(`${this._gatewayUrl}${j}`, {
|
|
1619
1721
|
method: "POST",
|
|
1620
1722
|
headers: { "Content-Type": "application/json", "x-project-id": t, "cue-project-id": t },
|
|
1621
1723
|
body: JSON.stringify({ name: e, config: o })
|
|
@@ -1625,7 +1727,7 @@ class fs {
|
|
|
1625
1727
|
return r.json();
|
|
1626
1728
|
}
|
|
1627
1729
|
async updateDataSource(t, e, o) {
|
|
1628
|
-
const r = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
1730
|
+
const r = await this._auth.authenticatedFetch(`${this._gatewayUrl}${j}/${e}`, {
|
|
1629
1731
|
method: "PATCH",
|
|
1630
1732
|
headers: { "Content-Type": "application/json", "x-project-id": t, "cue-project-id": t },
|
|
1631
1733
|
body: JSON.stringify(o)
|
|
@@ -1634,14 +1736,24 @@ class fs {
|
|
|
1634
1736
|
throw new Error(await this._errorMessage("Update data source failed", r));
|
|
1635
1737
|
return r.json();
|
|
1636
1738
|
}
|
|
1637
|
-
/**
|
|
1638
|
-
|
|
1639
|
-
|
|
1739
|
+
/**
|
|
1740
|
+
* Hard delete — also removes the data source's triples from the graph/ledger. This fetches the
|
|
1741
|
+
* whole named graph and round-trips to the ledger/graph store, which can take tens of seconds;
|
|
1742
|
+
* the endpoint streams NDJSON progress while that's in flight — pass `onProgress` to receive it
|
|
1743
|
+
* (see `uploadData`'s doc comment for the wire format). Still bounded by a client-side timeout
|
|
1744
|
+
* covering the server's own bounded retries against the ledger/graph store (30s x up to 3
|
|
1745
|
+
* retries each, for both) plus normal request/response overhead, in case the stream stalls
|
|
1746
|
+
* with no further progress.
|
|
1747
|
+
*/
|
|
1748
|
+
async deleteDataSource(t, e, o) {
|
|
1749
|
+
const r = await this._auth.authenticatedFetch(`${this._gatewayUrl}${j}/${e}`, {
|
|
1640
1750
|
method: "DELETE",
|
|
1641
|
-
headers: { "x-project-id": t, "cue-project-id": t }
|
|
1751
|
+
headers: { "x-project-id": t, "cue-project-id": t },
|
|
1752
|
+
signal: AbortSignal.timeout($s)
|
|
1642
1753
|
});
|
|
1643
|
-
if (!
|
|
1644
|
-
throw new Error(await this._errorMessage("Delete data source failed",
|
|
1754
|
+
if (!r.ok)
|
|
1755
|
+
throw new Error(await this._errorMessage("Delete data source failed", r));
|
|
1756
|
+
return this._consumeNdjsonResult(r, o, "Delete data source");
|
|
1645
1757
|
}
|
|
1646
1758
|
/**
|
|
1647
1759
|
* Uploads new data to be transformed by the data source's stored config and
|
|
@@ -1652,20 +1764,21 @@ class fs {
|
|
|
1652
1764
|
* they're all loaded into one shared graph server-side before the stored
|
|
1653
1765
|
* CONSTRUCT query runs against it. `type: 'rml'` configs expect exactly one.
|
|
1654
1766
|
*
|
|
1655
|
-
*
|
|
1656
|
-
*
|
|
1657
|
-
*
|
|
1658
|
-
*
|
|
1659
|
-
*
|
|
1767
|
+
* Each file is uploaded straight to storage first (see `_stageFiles`) — the request that
|
|
1768
|
+
* follows carries only small file references, never the bytes, so file size never runs into
|
|
1769
|
+
* Cloud Run's request-size limit. `onProgress` receives `phase: 'uploading'` events for that
|
|
1770
|
+
* step, then the endpoint's usual NDJSON processing-progress events once the notify request is
|
|
1771
|
+
* in flight. The call still resolves/rejects only once, with the final result or an `Error`
|
|
1772
|
+
* built from the stream's `error` line (a non-2xx HTTP status, e.g. an auth/guard rejection
|
|
1773
|
+
* before the handler even runs, is still thrown from `response.ok` as before).
|
|
1660
1774
|
*/
|
|
1661
1775
|
async uploadData(t, e, o, r, a) {
|
|
1662
|
-
const i =
|
|
1663
|
-
|
|
1664
|
-
const n = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
1776
|
+
const i = await this._stageFiles(t, o, a);
|
|
1777
|
+
a?.({ phase: "processing", message: "Upload complete, starting processing…" });
|
|
1778
|
+
const n = await this._auth.authenticatedFetch(`${this._gatewayUrl}${j}/${e}/data/from-storage`, {
|
|
1665
1779
|
method: "POST",
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
body: i
|
|
1780
|
+
headers: { "Content-Type": "application/json", "x-project-id": t, "cue-project-id": t },
|
|
1781
|
+
body: JSON.stringify({ files: i, mode: r })
|
|
1669
1782
|
});
|
|
1670
1783
|
if (!n.ok)
|
|
1671
1784
|
throw new Error(await this._errorMessage("Data source upload failed", n));
|
|
@@ -1676,22 +1789,56 @@ class fs {
|
|
|
1676
1789
|
* without creating a data source or writing anything to the graph/ledger —
|
|
1677
1790
|
* for previewing a transform (e.g. while building a CONSTRUCT query or RML
|
|
1678
1791
|
* mapping) before saving it. Same transform code as `uploadData`, so a
|
|
1679
|
-
* preview never drifts from what an actual upload would produce.
|
|
1680
|
-
* progress the same way — see
|
|
1792
|
+
* preview never drifts from what an actual upload would produce. Uploads
|
|
1793
|
+
* `files` to storage first and streams progress the same way — see
|
|
1794
|
+
* `uploadData`'s doc comment.
|
|
1681
1795
|
*/
|
|
1682
1796
|
async previewTransform(t, e, o, r) {
|
|
1683
|
-
const a =
|
|
1684
|
-
|
|
1685
|
-
const i = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
1797
|
+
const a = await this._stageFiles(t, o, r);
|
|
1798
|
+
r?.({ phase: "processing", message: "Upload complete, starting processing…" });
|
|
1799
|
+
const i = await this._auth.authenticatedFetch(`${this._gatewayUrl}${j}/preview/from-storage`, {
|
|
1686
1800
|
method: "POST",
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
body: a
|
|
1801
|
+
headers: { "Content-Type": "application/json", "x-project-id": t, "cue-project-id": t },
|
|
1802
|
+
body: JSON.stringify({ files: a, config: e })
|
|
1690
1803
|
});
|
|
1691
1804
|
if (!i.ok)
|
|
1692
1805
|
throw new Error(await this._errorMessage("Data source preview failed", i));
|
|
1693
1806
|
return this._consumeNdjsonResult(i, r, "Data source preview");
|
|
1694
1807
|
}
|
|
1808
|
+
/**
|
|
1809
|
+
* Uploads every file straight to the raw bucket's `${projectId}/_tmp-uploads/` prefix (server
|
|
1810
|
+
* deletes each one right after processing it — see writers-commands' `_withTempFiles`), so
|
|
1811
|
+
* `uploadData`/`previewTransform`'s own request only ever carries small JSON references —
|
|
1812
|
+
* bytes never cross Cloud Run's request-size cap, no matter how large the file. Reports
|
|
1813
|
+
* upload-byte progress through `onProgress` as `phase: 'uploading'`, aggregated across every
|
|
1814
|
+
* file in the batch (not most-recent-file-wins) since callers pass everything to `uploadData`
|
|
1815
|
+
* in one call.
|
|
1816
|
+
*/
|
|
1817
|
+
async _stageFiles(t, e, o) {
|
|
1818
|
+
if (!this._blob)
|
|
1819
|
+
throw new Error("Uploading data-source files requires the SDK to be constructed with blob storage access.");
|
|
1820
|
+
const r = this._blob, a = e.reduce((p, c) => p + c.size, 0), i = new Array(e.length).fill(0), n = () => {
|
|
1821
|
+
const p = i.reduce((c, h) => c + h, 0);
|
|
1822
|
+
o?.({
|
|
1823
|
+
phase: "uploading",
|
|
1824
|
+
message: e.length === 1 ? "Uploading file" : `Uploading ${e.length} files`,
|
|
1825
|
+
pct: a > 0 ? Math.round(p / a * 100) : void 0
|
|
1826
|
+
});
|
|
1827
|
+
};
|
|
1828
|
+
return Promise.all(
|
|
1829
|
+
e.map(async (p, c) => {
|
|
1830
|
+
const h = typeof p.name == "string" ? p.name : "upload", d = h.lastIndexOf("."), u = d > 0 ? h.slice(d) : "", w = crypto.randomUUID(), m = `${t}/_tmp-uploads/${w}${u}`, g = r.uploadResumable("raw", m, p), y = g.onProgress((f) => {
|
|
1831
|
+
i[c] = f, n();
|
|
1832
|
+
});
|
|
1833
|
+
try {
|
|
1834
|
+
await g.complete();
|
|
1835
|
+
} finally {
|
|
1836
|
+
y();
|
|
1837
|
+
}
|
|
1838
|
+
return { tempId: w, suffix: u, originalname: h };
|
|
1839
|
+
})
|
|
1840
|
+
);
|
|
1841
|
+
}
|
|
1695
1842
|
/** Reads an NDJSON response (`{type:'progress',...}` lines, then one `{type:'result',...}`
|
|
1696
1843
|
* or `{type:'error',...}` line), forwarding progress events to `onProgress` and
|
|
1697
1844
|
* resolving/rejecting with the terminal event. The HTTP status alone can't signal
|
|
@@ -1715,11 +1862,11 @@ class fs {
|
|
|
1715
1862
|
for (; ; ) {
|
|
1716
1863
|
const { done: d, value: u } = await n.read();
|
|
1717
1864
|
u && (c += p.decode(u, { stream: !0 }));
|
|
1718
|
-
let
|
|
1719
|
-
for (; (
|
|
1865
|
+
let w;
|
|
1866
|
+
for (; (w = c.indexOf(`
|
|
1720
1867
|
`)) >= 0; ) {
|
|
1721
|
-
const
|
|
1722
|
-
c = c.slice(
|
|
1868
|
+
const m = c.slice(0, w).trim();
|
|
1869
|
+
c = c.slice(w + 1), m && i(JSON.parse(m));
|
|
1723
1870
|
}
|
|
1724
1871
|
if (d) break;
|
|
1725
1872
|
}
|
|
@@ -1731,7 +1878,7 @@ class fs {
|
|
|
1731
1878
|
return r;
|
|
1732
1879
|
}
|
|
1733
1880
|
async listDataSources(t) {
|
|
1734
|
-
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
1881
|
+
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${Zt}`, {
|
|
1735
1882
|
headers: { "x-project-id": t, "cue-project-id": t }
|
|
1736
1883
|
});
|
|
1737
1884
|
if (!e.ok)
|
|
@@ -1739,7 +1886,7 @@ class fs {
|
|
|
1739
1886
|
return e.json();
|
|
1740
1887
|
}
|
|
1741
1888
|
async getDataSource(t, e) {
|
|
1742
|
-
const o = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
1889
|
+
const o = await this._auth.authenticatedFetch(`${this._gatewayUrl}${Zt}/${e}`, {
|
|
1743
1890
|
headers: { "x-project-id": t, "cue-project-id": t }
|
|
1744
1891
|
});
|
|
1745
1892
|
if (!o.ok)
|
|
@@ -1751,9 +1898,157 @@ class fs {
|
|
|
1751
1898
|
return `${t}: ${e.status} ${e.statusText}${o ? " — " + o.slice(0, 300) : ""}`;
|
|
1752
1899
|
}
|
|
1753
1900
|
}
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1901
|
+
const nt = "/commands/gis-sources", te = "/data-views/gis-sources";
|
|
1902
|
+
class Ds {
|
|
1903
|
+
constructor(t, e) {
|
|
1904
|
+
this._auth = t, this._gatewayUrl = e;
|
|
1905
|
+
}
|
|
1906
|
+
_auth;
|
|
1907
|
+
_gatewayUrl;
|
|
1908
|
+
async listGisSources(t) {
|
|
1909
|
+
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${te}`, {
|
|
1910
|
+
headers: { "x-project-id": t, "cue-project-id": t }
|
|
1911
|
+
});
|
|
1912
|
+
if (!e.ok)
|
|
1913
|
+
throw new Error(await this._errorMessage("List GIS sources failed", e));
|
|
1914
|
+
return e.json();
|
|
1915
|
+
}
|
|
1916
|
+
async getGisSource(t, e) {
|
|
1917
|
+
const o = await this._auth.authenticatedFetch(`${this._gatewayUrl}${te}/${e}`, {
|
|
1918
|
+
headers: { "x-project-id": t, "cue-project-id": t }
|
|
1919
|
+
});
|
|
1920
|
+
if (!o.ok)
|
|
1921
|
+
throw new Error(await this._errorMessage("Get GIS source failed", o));
|
|
1922
|
+
return o.json();
|
|
1923
|
+
}
|
|
1924
|
+
/** `filename`'s extension (`.geojson`/`.json`/`.kml`/`.zip`) tells the server which parser to
|
|
1925
|
+
* use — pass it explicitly since `file` may not carry a usable `name` (e.g. a `Blob`). */
|
|
1926
|
+
async createGisSource(t, e, o, r, a = "auto") {
|
|
1927
|
+
const i = new FormData();
|
|
1928
|
+
i.append("name", e), i.append("crs", a), i.append("file", o, r);
|
|
1929
|
+
const n = await this._auth.authenticatedFetch(`${this._gatewayUrl}${nt}`, {
|
|
1930
|
+
method: "POST",
|
|
1931
|
+
// Do NOT set Content-Type; the runtime sets it with the correct multipart boundary.
|
|
1932
|
+
headers: { "x-project-id": t, "cue-project-id": t },
|
|
1933
|
+
body: i
|
|
1934
|
+
});
|
|
1935
|
+
if (!n.ok)
|
|
1936
|
+
throw new Error(await this._errorMessage("Create GIS source failed", n));
|
|
1937
|
+
return n.json();
|
|
1938
|
+
}
|
|
1939
|
+
/** Omitting `file` renames the source without touching its stored features. */
|
|
1940
|
+
async updateGisSource(t, e, o) {
|
|
1941
|
+
const r = new FormData();
|
|
1942
|
+
o.name !== void 0 && r.append("name", o.name), o.crs !== void 0 && r.append("crs", o.crs), o.file !== void 0 && r.append("file", o.file, o.filename ?? "upload");
|
|
1943
|
+
const a = await this._auth.authenticatedFetch(`${this._gatewayUrl}${nt}/${e}`, {
|
|
1944
|
+
method: "PATCH",
|
|
1945
|
+
// Do NOT set Content-Type; the runtime sets it with the correct multipart boundary.
|
|
1946
|
+
headers: { "x-project-id": t, "cue-project-id": t },
|
|
1947
|
+
body: r
|
|
1948
|
+
});
|
|
1949
|
+
if (!a.ok)
|
|
1950
|
+
throw new Error(await this._errorMessage("Update GIS source failed", a));
|
|
1951
|
+
return a.json();
|
|
1952
|
+
}
|
|
1953
|
+
async deleteGisSource(t, e) {
|
|
1954
|
+
const o = await this._auth.authenticatedFetch(`${this._gatewayUrl}${nt}/${e}`, {
|
|
1955
|
+
method: "DELETE",
|
|
1956
|
+
headers: { "x-project-id": t, "cue-project-id": t }
|
|
1957
|
+
});
|
|
1958
|
+
if (!o.ok)
|
|
1959
|
+
throw new Error(await this._errorMessage("Delete GIS source failed", o));
|
|
1960
|
+
}
|
|
1961
|
+
async _errorMessage(t, e) {
|
|
1962
|
+
const o = await e.text().catch(() => "");
|
|
1963
|
+
return `${t}: ${e.status} ${e.statusText}${o ? " — " + o.slice(0, 300) : ""}`;
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
const ee = "/commands/semantic-template";
|
|
1967
|
+
class Ns {
|
|
1968
|
+
constructor(t, e) {
|
|
1969
|
+
this._auth = t, this._gatewayUrl = e;
|
|
1970
|
+
}
|
|
1971
|
+
_auth;
|
|
1972
|
+
_gatewayUrl;
|
|
1973
|
+
// ─── Content Category ────────────────────────────────────────────────────
|
|
1974
|
+
createContentCategory(t, e) {
|
|
1975
|
+
return this._post(t, "content-category", e);
|
|
1976
|
+
}
|
|
1977
|
+
createContentCategoryBatch(t, e) {
|
|
1978
|
+
return this._post(t, "content-category/batch", { items: e });
|
|
1979
|
+
}
|
|
1980
|
+
deleteContentCategory(t, e) {
|
|
1981
|
+
return this._delete(t, "content-category", { value: e });
|
|
1982
|
+
}
|
|
1983
|
+
deleteContentCategoryBatch(t, e) {
|
|
1984
|
+
return this._delete(t, "content-category/batch", { items: e.map((o) => ({ value: o })) });
|
|
1985
|
+
}
|
|
1986
|
+
// ─── Entity Category ─────────────────────────────────────────────────────
|
|
1987
|
+
createEntityCategory(t, e) {
|
|
1988
|
+
return this._post(t, "entity-category", e);
|
|
1989
|
+
}
|
|
1990
|
+
createEntityCategoryBatch(t, e) {
|
|
1991
|
+
return this._post(t, "entity-category/batch", { items: e });
|
|
1992
|
+
}
|
|
1993
|
+
deleteEntityCategory(t, e) {
|
|
1994
|
+
return this._delete(t, "entity-category", { value: e });
|
|
1995
|
+
}
|
|
1996
|
+
deleteEntityCategoryBatch(t, e) {
|
|
1997
|
+
return this._delete(t, "entity-category/batch", { items: e.map((o) => ({ value: o })) });
|
|
1998
|
+
}
|
|
1999
|
+
// ─── Entity Relationship ─────────────────────────────────────────────────
|
|
2000
|
+
createEntityRelationship(t, e) {
|
|
2001
|
+
return this._post(t, "entity-relationship", e);
|
|
2002
|
+
}
|
|
2003
|
+
createEntityRelationshipBatch(t, e) {
|
|
2004
|
+
return this._post(t, "entity-relationship/batch", { items: e });
|
|
2005
|
+
}
|
|
2006
|
+
deleteEntityRelationship(t, e) {
|
|
2007
|
+
return this._delete(t, "entity-relationship", { value: e });
|
|
2008
|
+
}
|
|
2009
|
+
deleteEntityRelationshipBatch(t, e) {
|
|
2010
|
+
return this._delete(t, "entity-relationship/batch", { items: e.map((o) => ({ value: o })) });
|
|
2011
|
+
}
|
|
2012
|
+
// ─── Schema graph reload ─────────────────────────────────────────────────
|
|
2013
|
+
/** Re-pushes the project's currently stored template into its `databases-cue` schema graph, without mutating it. */
|
|
2014
|
+
reloadSchema(t) {
|
|
2015
|
+
return this._post(t, "reload", {});
|
|
2016
|
+
}
|
|
2017
|
+
// ─── Private helpers ─────────────────────────────────────────────────────
|
|
2018
|
+
async _post(t, e, o) {
|
|
2019
|
+
const r = await this._auth.authenticatedFetch(
|
|
2020
|
+
`${this._gatewayUrl}${ee}/${e}`,
|
|
2021
|
+
{
|
|
2022
|
+
method: "POST",
|
|
2023
|
+
headers: { "Content-Type": "application/json", "x-project-id": t, "cue-project-id": t },
|
|
2024
|
+
body: JSON.stringify(o)
|
|
2025
|
+
}
|
|
2026
|
+
);
|
|
2027
|
+
if (!r.ok)
|
|
2028
|
+
throw new Error(await this._errorMessage(`POST ${e} failed`, r));
|
|
2029
|
+
return r.json();
|
|
2030
|
+
}
|
|
2031
|
+
async _delete(t, e, o) {
|
|
2032
|
+
const r = await this._auth.authenticatedFetch(
|
|
2033
|
+
`${this._gatewayUrl}${ee}/${e}`,
|
|
2034
|
+
{
|
|
2035
|
+
method: "DELETE",
|
|
2036
|
+
headers: { "Content-Type": "application/json", "x-project-id": t, "cue-project-id": t },
|
|
2037
|
+
body: JSON.stringify(o)
|
|
2038
|
+
}
|
|
2039
|
+
);
|
|
2040
|
+
if (!r.ok)
|
|
2041
|
+
throw new Error(await this._errorMessage(`DELETE ${e} failed`, r));
|
|
2042
|
+
return r.json();
|
|
2043
|
+
}
|
|
2044
|
+
async _errorMessage(t, e) {
|
|
2045
|
+
const o = await e.text().catch(() => "");
|
|
2046
|
+
return `${t}: ${e.status} ${e.statusText}${o ? " — " + o.slice(0, 300) : ""}`;
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
class oe {
|
|
2050
|
+
constructor(t, e, o, r, a) {
|
|
2051
|
+
this._auth = t, this._gatewayUrl = e, this.projects = o, this.sync = r, this.tables = new cs(t, e), this.extraction = new hs(t, e), this.contexts = new ds(t, e), this.index = new us(t, e), this.mcp = new bs(t, e), this.appData = new Es(t, e), this.apps = new Ts(t, e), this.userSettings = new Ss(t, e), this.processing = new Cs(t, e), this.dms = new ks(t, e), this.llmTools = new Os(t, e), this.dataSources = new Ps(t, e, a), this.gisSources = new Ds(t, e), this.semanticTemplate = new Ns(t, e);
|
|
1757
2052
|
}
|
|
1758
2053
|
_auth;
|
|
1759
2054
|
_gatewayUrl;
|
|
@@ -1782,6 +2077,12 @@ class Xt {
|
|
|
1782
2077
|
llmTools;
|
|
1783
2078
|
/** Project-scoped data sources — reusable raw-data-to-RDF pipelines writing into their own named graph. */
|
|
1784
2079
|
dataSources;
|
|
2080
|
+
/** Project-scoped GIS sources — user-uploaded GeoJSON/KML/Shapefile feature sets, returned by
|
|
2081
|
+
* `cue.gis` under the 'custom' category alongside every other GIS category. */
|
|
2082
|
+
gisSources;
|
|
2083
|
+
/** Mutates a project's custom extraction/classification schema (content categories, entity
|
|
2084
|
+
* categories, entity relationships) and reloads its `databases-cue` schema graph. */
|
|
2085
|
+
semanticTemplate;
|
|
1785
2086
|
/** Active language used for language-sensitive SPARQL queries across all project classes. */
|
|
1786
2087
|
language = "en";
|
|
1787
2088
|
/** Updates the active language. All project classes (`CueProjectSchema`, `CueProjectDocuments`, `CueProjectEntities`) read this at query time. */
|
|
@@ -1807,7 +2108,7 @@ class Xt {
|
|
|
1807
2108
|
*/
|
|
1808
2109
|
async search(t) {
|
|
1809
2110
|
const e = await this._auth.authenticatedFetch(
|
|
1810
|
-
`${this._gatewayUrl}${
|
|
2111
|
+
`${this._gatewayUrl}${Fr}`,
|
|
1811
2112
|
{
|
|
1812
2113
|
method: "POST",
|
|
1813
2114
|
headers: { "Content-Type": "application/json", "cue-project-id": t.projectId },
|
|
@@ -1827,12 +2128,16 @@ class Xt {
|
|
|
1827
2128
|
/**
|
|
1828
2129
|
* Execute a SPARQL query against the project's triplestore.
|
|
1829
2130
|
* The user must be authenticated before calling this.
|
|
2131
|
+
*
|
|
2132
|
+
* The gateway resolves which graph backend (qlever, cue, …) actually serves
|
|
2133
|
+
* the query per-project — `graphType` here only needs to distinguish legacy
|
|
2134
|
+
* Fuseki, which lives on its own static Kong route rather than that
|
|
2135
|
+
* per-project routing. Pass it explicitly if the caller already knows;
|
|
2136
|
+
* otherwise it's looked up from the project's own settings.
|
|
1830
2137
|
*/
|
|
1831
2138
|
async sparql(t, e, o) {
|
|
1832
|
-
o || (o =
|
|
1833
|
-
const r = o === "fuseki" ?
|
|
1834
|
-
console.log(`Executing SPARQL query against ${r} for project ${e} with graph type ${o}`);
|
|
1835
|
-
const a = new URLSearchParams();
|
|
2139
|
+
o || (o = "qlever");
|
|
2140
|
+
const r = o === "fuseki" ? Wr : Le, a = new URLSearchParams();
|
|
1836
2141
|
a.append("query", t);
|
|
1837
2142
|
const i = await this._auth.authenticatedFetch(
|
|
1838
2143
|
`${this._gatewayUrl}${r}`,
|
|
@@ -1878,7 +2183,7 @@ class Xt {
|
|
|
1878
2183
|
const r = o?.format ?? "json-ld", a = r === "turtle" ? "text/turtle" : "application/ld+json";
|
|
1879
2184
|
if (o?.graphType === "fuseki") {
|
|
1880
2185
|
const c = await this._auth.authenticatedFetch(
|
|
1881
|
-
`${this._gatewayUrl}${
|
|
2186
|
+
`${this._gatewayUrl}${Vr}`,
|
|
1882
2187
|
{
|
|
1883
2188
|
method: "POST",
|
|
1884
2189
|
headers: {
|
|
@@ -1896,7 +2201,7 @@ class Xt {
|
|
|
1896
2201
|
}
|
|
1897
2202
|
return r === "turtle" ? c.text() : c.json();
|
|
1898
2203
|
}
|
|
1899
|
-
const i = `${this._gatewayUrl}${
|
|
2204
|
+
const i = `${this._gatewayUrl}${Kr}${o?.verbose ? "?verbose=true" : ""}`, n = new URLSearchParams({ shape: t }), p = await this._auth.authenticatedFetch(i, {
|
|
1900
2205
|
method: "POST",
|
|
1901
2206
|
headers: {
|
|
1902
2207
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
@@ -1924,7 +2229,7 @@ class Xt {
|
|
|
1924
2229
|
}
|
|
1925
2230
|
async getConsumption(t) {
|
|
1926
2231
|
const e = await this._auth.authenticatedFetch(
|
|
1927
|
-
`${this._gatewayUrl}${
|
|
2232
|
+
`${this._gatewayUrl}${zo}`,
|
|
1928
2233
|
{
|
|
1929
2234
|
headers: {
|
|
1930
2235
|
"Content-Type": "application/json",
|
|
@@ -1940,7 +2245,7 @@ class Xt {
|
|
|
1940
2245
|
return e.json();
|
|
1941
2246
|
}
|
|
1942
2247
|
}
|
|
1943
|
-
const
|
|
2248
|
+
const ft = [
|
|
1944
2249
|
"building",
|
|
1945
2250
|
"cadastre",
|
|
1946
2251
|
"zone",
|
|
@@ -1950,14 +2255,15 @@ const gt = [
|
|
|
1950
2255
|
"paved",
|
|
1951
2256
|
"railway",
|
|
1952
2257
|
"natural",
|
|
1953
|
-
"manmade"
|
|
1954
|
-
|
|
2258
|
+
"manmade",
|
|
2259
|
+
"custom"
|
|
2260
|
+
], yt = [
|
|
1955
2261
|
"address",
|
|
1956
2262
|
"poi",
|
|
1957
2263
|
"railway",
|
|
1958
2264
|
"natural",
|
|
1959
2265
|
"manmade"
|
|
1960
|
-
],
|
|
2266
|
+
], js = {
|
|
1961
2267
|
address: {
|
|
1962
2268
|
category: "address",
|
|
1963
2269
|
label: "Address",
|
|
@@ -2017,12 +2323,18 @@ const gt = [
|
|
|
2017
2323
|
label: "Planning zones",
|
|
2018
2324
|
description: "Land-use zones, local plans, and public-law planning constraints (Nutzungsplanung / Lokalplan).",
|
|
2019
2325
|
preferredColor: "#db2777"
|
|
2326
|
+
},
|
|
2327
|
+
custom: {
|
|
2328
|
+
category: "custom",
|
|
2329
|
+
label: "Custom",
|
|
2330
|
+
description: "Features uploaded to this project (GeoJSON, KML, or Shapefile).",
|
|
2331
|
+
preferredColor: "#0d9488"
|
|
2020
2332
|
}
|
|
2021
2333
|
};
|
|
2022
|
-
function
|
|
2023
|
-
return
|
|
2334
|
+
function x(s) {
|
|
2335
|
+
return js[s];
|
|
2024
2336
|
}
|
|
2025
|
-
const
|
|
2337
|
+
const Ls = {
|
|
2026
2338
|
"land-use-plan": "#f59e0b",
|
|
2027
2339
|
// amber – primary zoning
|
|
2028
2340
|
"local-plan": "#ec4899",
|
|
@@ -2050,10 +2362,10 @@ const bs = {
|
|
|
2050
2362
|
"nature-landscape-plan": "#16a34a"
|
|
2051
2363
|
// dark-green – Natur- und Landschaftsschutz
|
|
2052
2364
|
};
|
|
2053
|
-
function
|
|
2365
|
+
function D(s, t) {
|
|
2054
2366
|
return s[0] < t[2] && s[2] > t[0] && s[1] < t[3] && s[3] > t[1];
|
|
2055
2367
|
}
|
|
2056
|
-
const
|
|
2368
|
+
const Us = "https://nominatim.openstreetmap.org", Ms = "cue-gis/0.0.1", qs = {
|
|
2057
2369
|
address: "street",
|
|
2058
2370
|
poi: "shop",
|
|
2059
2371
|
railway: "station",
|
|
@@ -2063,63 +2375,66 @@ const vs = "https://nominatim.openstreetmap.org", _s = "cue-gis/0.0.1", Es = {
|
|
|
2063
2375
|
building: "building",
|
|
2064
2376
|
greenspace: "park",
|
|
2065
2377
|
paved: "road",
|
|
2066
|
-
zone: "boundary"
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2378
|
+
zone: "boundary",
|
|
2379
|
+
// Never actually probed — 'custom' (user-uploaded GIS sources) isn't in
|
|
2380
|
+
// NOMINATIM_FEATURE_CATEGORIES, so this entry only exists to satisfy the Record type.
|
|
2381
|
+
custom: "place"
|
|
2382
|
+
}, M = "nominatim";
|
|
2383
|
+
function K(s) {
|
|
2384
|
+
return `${M}:${s}`;
|
|
2070
2385
|
}
|
|
2071
|
-
function
|
|
2072
|
-
const t =
|
|
2386
|
+
function Fs(s) {
|
|
2387
|
+
const t = x(s);
|
|
2073
2388
|
return {
|
|
2074
|
-
id:
|
|
2075
|
-
sourceId:
|
|
2389
|
+
id: K(s),
|
|
2390
|
+
sourceId: M,
|
|
2076
2391
|
sourceLayerId: s,
|
|
2077
2392
|
category: s,
|
|
2078
2393
|
preferredColor: t.preferredColor,
|
|
2079
2394
|
tier: "raw",
|
|
2080
2395
|
label: t.label,
|
|
2081
2396
|
description: `Nominatim ${s} layer`,
|
|
2082
|
-
labelKey: `gis.layer.${
|
|
2083
|
-
descriptionKey: `gis.layer.${
|
|
2397
|
+
labelKey: `gis.layer.${M}.${s}.label`,
|
|
2398
|
+
descriptionKey: `gis.layer.${M}.${s}.description`
|
|
2084
2399
|
};
|
|
2085
2400
|
}
|
|
2086
|
-
class
|
|
2401
|
+
class zs {
|
|
2087
2402
|
baseUrl;
|
|
2088
2403
|
userAgent;
|
|
2089
2404
|
email;
|
|
2090
2405
|
limit;
|
|
2091
2406
|
constructor(t = {}) {
|
|
2092
|
-
this.baseUrl = t.baseUrl ??
|
|
2407
|
+
this.baseUrl = t.baseUrl ?? Us, this.userAgent = t.userAgent ?? Ms, this.email = t.email, this.limit = Math.min(t.limit ?? 40, 40);
|
|
2093
2408
|
}
|
|
2094
2409
|
async listFeatureCategoryDescriptors(t) {
|
|
2095
2410
|
return (await Promise.allSettled(
|
|
2096
|
-
|
|
2411
|
+
yt.map(async (o) => {
|
|
2097
2412
|
const r = await this.search(t, o);
|
|
2098
2413
|
return { category: o, hasResults: r.length > 0 };
|
|
2099
2414
|
})
|
|
2100
2415
|
)).filter(
|
|
2101
2416
|
(o) => o.status === "fulfilled" && o.value.hasResults
|
|
2102
|
-
).map((o) =>
|
|
2417
|
+
).map((o) => x(o.value.category));
|
|
2103
2418
|
}
|
|
2104
2419
|
async listAvailableLayers(t) {
|
|
2105
|
-
return (await this.listFeatureCategoryDescriptors(t)).map((o) =>
|
|
2420
|
+
return (await this.listFeatureCategoryDescriptors(t)).map((o) => Fs(o.category));
|
|
2106
2421
|
}
|
|
2107
2422
|
async getFeaturesForLayer(t, e) {
|
|
2108
|
-
const o =
|
|
2423
|
+
const o = ft.find((r) => K(r) === e);
|
|
2109
2424
|
return o ? this.search(t, o) : [];
|
|
2110
2425
|
}
|
|
2111
2426
|
async listFeatureCategories(t) {
|
|
2112
2427
|
return (await this.listFeatureCategoryDescriptors(t)).map((o) => o.category);
|
|
2113
2428
|
}
|
|
2114
2429
|
async getFeaturesOfCategory(t, e) {
|
|
2115
|
-
return this.getFeaturesForLayer(t,
|
|
2430
|
+
return this.getFeaturesForLayer(t, K(e));
|
|
2116
2431
|
}
|
|
2117
2432
|
/**
|
|
2118
2433
|
* Low-level search against the Nominatim API. Uses a per-layer probe query
|
|
2119
2434
|
* so bounded viewbox searches return meaningful results.
|
|
2120
2435
|
*/
|
|
2121
2436
|
async search(t, e) {
|
|
2122
|
-
const [o, r, a, i] = t, n = e ?
|
|
2437
|
+
const [o, r, a, i] = t, n = e ? qs[e] : "place", p = new URLSearchParams({
|
|
2123
2438
|
q: n,
|
|
2124
2439
|
format: "jsonv2",
|
|
2125
2440
|
viewbox: `${o},${i},${a},${r}`,
|
|
@@ -2129,7 +2444,7 @@ class ks {
|
|
|
2129
2444
|
extratags: "1",
|
|
2130
2445
|
dedupe: "1"
|
|
2131
2446
|
});
|
|
2132
|
-
e &&
|
|
2447
|
+
e && yt.includes(e) && p.set("layer", e), this.email && p.set("email", this.email);
|
|
2133
2448
|
const c = `${this.baseUrl}/search?${p.toString()}`, h = await fetch(c, {
|
|
2134
2449
|
headers: {
|
|
2135
2450
|
"User-Agent": this.userAgent,
|
|
@@ -2143,12 +2458,12 @@ class ks {
|
|
|
2143
2458
|
return (await h.json()).map((u) => this.toGisFeature(u, e));
|
|
2144
2459
|
}
|
|
2145
2460
|
toGisFeature(t, e) {
|
|
2146
|
-
const [o, r, a, i] = t.boundingbox, n = e ?? t.category, p =
|
|
2461
|
+
const [o, r, a, i] = t.boundingbox, n = e ?? t.category, p = x(n);
|
|
2147
2462
|
return {
|
|
2148
2463
|
id: `${t.osm_type}/${t.osm_id}`,
|
|
2149
|
-
sourceId:
|
|
2464
|
+
sourceId: M,
|
|
2150
2465
|
sourceFeatureId: `${t.osm_type}/${t.osm_id}`,
|
|
2151
|
-
layerId:
|
|
2466
|
+
layerId: K(n),
|
|
2152
2467
|
name: t.name ?? t.display_name.split(",")[0].trim(),
|
|
2153
2468
|
category: n,
|
|
2154
2469
|
preferredColor: p.preferredColor,
|
|
@@ -2162,7 +2477,7 @@ class ks {
|
|
|
2162
2477
|
};
|
|
2163
2478
|
}
|
|
2164
2479
|
}
|
|
2165
|
-
const
|
|
2480
|
+
const re = {
|
|
2166
2481
|
// 100s – Residential
|
|
2167
2482
|
110: "residential",
|
|
2168
2483
|
120: "residential",
|
|
@@ -2241,7 +2556,7 @@ const Qt = {
|
|
|
2241
2556
|
960: "agricultural",
|
|
2242
2557
|
970: "agricultural",
|
|
2243
2558
|
990: "other"
|
|
2244
|
-
},
|
|
2559
|
+
}, se = {
|
|
2245
2560
|
1010: "residential",
|
|
2246
2561
|
1020: "mixed",
|
|
2247
2562
|
1030: "residential",
|
|
@@ -2271,7 +2586,7 @@ const Qt = {
|
|
|
2271
2586
|
1281: "infrastructure",
|
|
2272
2587
|
1282: "infrastructure",
|
|
2273
2588
|
9999: "other"
|
|
2274
|
-
},
|
|
2589
|
+
}, Bs = {
|
|
2275
2590
|
// Residential
|
|
2276
2591
|
1110: "residential",
|
|
2277
2592
|
// Einfamilienhaus
|
|
@@ -2333,7 +2648,7 @@ const Qt = {
|
|
|
2333
2648
|
// Empfangsgebäude Bahn/Bus
|
|
2334
2649
|
1282: "infrastructure"
|
|
2335
2650
|
// Parkhaus, Garage
|
|
2336
|
-
},
|
|
2651
|
+
}, Gs = [
|
|
2337
2652
|
// "Gebäude" is the Swiss AV BoFlaeche land-cover label for a building footprint.
|
|
2338
2653
|
// It does not encode the actual use type, so map it to 'other' as a safe fallback.
|
|
2339
2654
|
[/^geb[äa]ude$/i, "other"],
|
|
@@ -2346,23 +2661,23 @@ const Qt = {
|
|
|
2346
2661
|
[/infrastruktur|verkehr|transport|energy|energie|forsyning|teknik|teknisk/i, "infrastructure"],
|
|
2347
2662
|
[/gemischt|mixed|blandet/i, "mixed"]
|
|
2348
2663
|
];
|
|
2349
|
-
function
|
|
2350
|
-
for (const [t, e] of
|
|
2664
|
+
function U(s) {
|
|
2665
|
+
for (const [t, e] of Gs)
|
|
2351
2666
|
if (t.test(s)) return e;
|
|
2352
2667
|
}
|
|
2353
|
-
function
|
|
2668
|
+
function Hs(s, t) {
|
|
2354
2669
|
if (s == null) return;
|
|
2355
2670
|
const e = String(s).trim();
|
|
2356
|
-
return t === "swiss-gwr" ?
|
|
2671
|
+
return t === "swiss-gwr" ? Bs[e] ?? U(e) : t === "danish-matrikel" ? re[e] ?? U(e) : t === "zurich-wfs" || t === "swiss-av-wfs" ? se[e] ?? U(e) : se[e] ?? re[e] ?? U(e);
|
|
2357
2672
|
}
|
|
2358
|
-
function
|
|
2673
|
+
function Ws(s, t) {
|
|
2359
2674
|
if (s != null)
|
|
2360
|
-
return
|
|
2675
|
+
return U(String(s).trim());
|
|
2361
2676
|
}
|
|
2362
|
-
function
|
|
2677
|
+
function qe(s) {
|
|
2363
2678
|
return s.trim().toLowerCase().replace(/[\s_\-]/g, "");
|
|
2364
2679
|
}
|
|
2365
|
-
const
|
|
2680
|
+
const Vs = {
|
|
2366
2681
|
// Swiss ÖREB rechtsstatus
|
|
2367
2682
|
inkraft: "in-force",
|
|
2368
2683
|
laufendeanderung: "amendment-pending",
|
|
@@ -2381,11 +2696,11 @@ const Rs = {
|
|
|
2381
2696
|
forslag: "proposed",
|
|
2382
2697
|
aflyst: "repealed"
|
|
2383
2698
|
};
|
|
2384
|
-
function
|
|
2699
|
+
function Fe(s) {
|
|
2385
2700
|
if (s)
|
|
2386
|
-
return
|
|
2701
|
+
return Vs[qe(s)];
|
|
2387
2702
|
}
|
|
2388
|
-
const
|
|
2703
|
+
const ae = {
|
|
2389
2704
|
// Swiss Nutzungsplanung (typ_gde_bezeichnung and common variants)
|
|
2390
2705
|
grundnutzungszonenplan: "land-use-plan",
|
|
2391
2706
|
nutzungszonenplan: "land-use-plan",
|
|
@@ -2439,7 +2754,7 @@ const Yt = {
|
|
|
2439
2754
|
// Danish plandata.dk
|
|
2440
2755
|
lokalplan: "local-plan",
|
|
2441
2756
|
kommuneplanramme: "municipal-plan-framework"
|
|
2442
|
-
},
|
|
2757
|
+
}, Xs = [
|
|
2443
2758
|
[/quartiererhalt/i, "neighbourhood-conservation-plan"],
|
|
2444
2759
|
[/lärmempfindlich|laermempfindlich/i, "noise-sensitivity-plan"],
|
|
2445
2760
|
[/gewässerschutz|grundwasserschutz/i, "water-protection-plan"],
|
|
@@ -2479,24 +2794,32 @@ const Yt = {
|
|
|
2479
2794
|
// Catch-all: any remaining Xzone / Xareal designation from the Grundnutzungszonenplan
|
|
2480
2795
|
[/zone$|areal$/i, "land-use-plan"]
|
|
2481
2796
|
];
|
|
2482
|
-
function
|
|
2797
|
+
function ze(s) {
|
|
2483
2798
|
if (!s) return;
|
|
2484
|
-
const t =
|
|
2485
|
-
if (t in
|
|
2486
|
-
for (const [e, o] of
|
|
2799
|
+
const t = qe(s);
|
|
2800
|
+
if (t in ae) return ae[t];
|
|
2801
|
+
for (const [e, o] of Xs)
|
|
2487
2802
|
if (e.test(s)) return o;
|
|
2488
2803
|
console.warn(
|
|
2489
2804
|
`[cue-gis] Unknown zone plan type — add "${s}" to classifyZonePlanType: no ZonePlanType mapping found.`
|
|
2490
2805
|
);
|
|
2491
2806
|
}
|
|
2492
|
-
|
|
2493
|
-
|
|
2807
|
+
function Z(s, t) {
|
|
2808
|
+
const e = (t * 3600 - 169028.66) / 1e4, o = (s * 3600 - 26782.5) / 1e4, r = 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;
|
|
2809
|
+
return [Math.round(r), Math.round(a)];
|
|
2810
|
+
}
|
|
2811
|
+
function bt(s, t) {
|
|
2812
|
+
const e = (s - 26e5) / 1e6, o = (t - 12e5) / 1e6, r = 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;
|
|
2813
|
+
return [r * 100 / 36, a * 100 / 36];
|
|
2814
|
+
}
|
|
2815
|
+
const Ks = "https://maps.zh.ch/wfs/OGDZHWFS", Ys = "zurich-wfs", Qs = "geometry", Js = [8.35, 47.15, 8.95, 47.7], Zs = [5.9, 45.7, 10.55, 47.85];
|
|
2816
|
+
function pt(s) {
|
|
2494
2817
|
return typeof s == "string" ? s : s.typeName;
|
|
2495
2818
|
}
|
|
2496
|
-
function
|
|
2819
|
+
function ct(s) {
|
|
2497
2820
|
return typeof s == "string" ? void 0 : s.cqlFilter;
|
|
2498
2821
|
}
|
|
2499
|
-
function
|
|
2822
|
+
function ta(s) {
|
|
2500
2823
|
if (!s) return [0, 0];
|
|
2501
2824
|
const t = s.coordinates;
|
|
2502
2825
|
switch (s.type) {
|
|
@@ -2514,20 +2837,26 @@ function Ns(s) {
|
|
|
2514
2837
|
return [0, 0];
|
|
2515
2838
|
}
|
|
2516
2839
|
}
|
|
2517
|
-
function
|
|
2840
|
+
function Be(s, t) {
|
|
2841
|
+
return Array.isArray(s) && typeof s[0] == "number" ? t(s[0], s[1]) : s.map((e) => Be(e, t));
|
|
2842
|
+
}
|
|
2843
|
+
function ea(s) {
|
|
2844
|
+
return s && { ...s, coordinates: Be(s.coordinates, bt) };
|
|
2845
|
+
}
|
|
2846
|
+
function oa(s, t) {
|
|
2518
2847
|
if (!s) return t;
|
|
2519
2848
|
for (const e of ["plannavn", "bezeichnung", "name", "strassenname", "objektname", "title", "label"])
|
|
2520
2849
|
if (typeof s[e] == "string" && s[e]) return s[e];
|
|
2521
2850
|
return t;
|
|
2522
2851
|
}
|
|
2523
|
-
function
|
|
2852
|
+
function ra(s, t, e) {
|
|
2524
2853
|
return e ? `${s}:${t}[${e}]` : `${s}:${t}`;
|
|
2525
2854
|
}
|
|
2526
|
-
const
|
|
2527
|
-
function
|
|
2528
|
-
const r = e.replace(/^ms:/, ""), a =
|
|
2855
|
+
const sa = /* @__PURE__ */ new Set(["building", "cadastre", "greenspace", "paved", "zone"]);
|
|
2856
|
+
function lt(s, t, e, o) {
|
|
2857
|
+
const r = e.replace(/^ms:/, ""), a = x(t), i = sa.has(t) ? "priority" : "raw";
|
|
2529
2858
|
return {
|
|
2530
|
-
id:
|
|
2859
|
+
id: ra(s, e, o),
|
|
2531
2860
|
sourceId: s,
|
|
2532
2861
|
sourceLayerId: e,
|
|
2533
2862
|
category: t,
|
|
@@ -2539,32 +2868,32 @@ function nt(s, t, e, o) {
|
|
|
2539
2868
|
descriptionKey: `gis.layer.${s}.${r}.description`
|
|
2540
2869
|
};
|
|
2541
2870
|
}
|
|
2542
|
-
function
|
|
2871
|
+
function aa(s, t) {
|
|
2543
2872
|
if (!s) return { featureType: "building" };
|
|
2544
2873
|
const e = s.grundflaeche ?? s.gbf ?? s.gebaeudegrundrissflaeche ?? s.flaeche ?? void 0, o = s.vollgeschosse ?? s.geschossanzahl ?? s.anzahl_geschosse ?? void 0, r = s.gebaeudefunktion ?? s.gfkode ?? s.art ?? s.objektart ?? void 0, a = s.baujahr ?? s.bauperiode ?? void 0, i = String(s.egid ?? s.gwr_egid ?? s.egris_egid ?? "").trim() || void 0;
|
|
2545
2874
|
return {
|
|
2546
2875
|
featureType: "building",
|
|
2547
2876
|
areaM2: typeof e == "number" ? e : void 0,
|
|
2548
2877
|
buildingUse: r ? String(r) : void 0,
|
|
2549
|
-
buildingUseGeneric:
|
|
2878
|
+
buildingUseGeneric: Hs(r, t),
|
|
2550
2879
|
floors: typeof o == "number" ? o : void 0,
|
|
2551
2880
|
yearBuilt: typeof a == "number" ? a : void 0,
|
|
2552
2881
|
registryId: i
|
|
2553
2882
|
};
|
|
2554
2883
|
}
|
|
2555
|
-
function
|
|
2884
|
+
function ia(s, t) {
|
|
2556
2885
|
if (!s) return { featureType: "plot" };
|
|
2557
2886
|
const e = s.egris_egrid ?? s.egrid ?? void 0, o = s.nummer ?? void 0, r = s.nbident ?? void 0, a = o && r ? `${o}, ${r}` : o ?? void 0, i = s.flaechenmass ?? s.flaeche ?? void 0, n = s.art ?? s.nutzungsart ?? void 0;
|
|
2558
2887
|
return {
|
|
2559
2888
|
featureType: "plot",
|
|
2560
2889
|
areaM2: typeof i == "number" ? i : void 0,
|
|
2561
2890
|
plotUse: n ? String(n) : void 0,
|
|
2562
|
-
plotUseGeneric:
|
|
2891
|
+
plotUseGeneric: Ws(n),
|
|
2563
2892
|
plotId: a,
|
|
2564
2893
|
registryId: e
|
|
2565
2894
|
};
|
|
2566
2895
|
}
|
|
2567
|
-
function
|
|
2896
|
+
function na(s) {
|
|
2568
2897
|
if (!s) return { featureType: "greenspace" };
|
|
2569
2898
|
const t = s.flaeche ?? void 0, e = s.art ?? void 0;
|
|
2570
2899
|
return {
|
|
@@ -2573,7 +2902,7 @@ function zs(s) {
|
|
|
2573
2902
|
surfaceType: e ? String(e) : void 0
|
|
2574
2903
|
};
|
|
2575
2904
|
}
|
|
2576
|
-
function
|
|
2905
|
+
function pa(s) {
|
|
2577
2906
|
if (!s) return { featureType: "paved" };
|
|
2578
2907
|
const t = s.flaeche ?? void 0, e = s.art ?? void 0;
|
|
2579
2908
|
return {
|
|
@@ -2582,9 +2911,9 @@ function Fs(s) {
|
|
|
2582
2911
|
surfaceType: e ? String(e) : void 0
|
|
2583
2912
|
};
|
|
2584
2913
|
}
|
|
2585
|
-
function
|
|
2914
|
+
function ca(s) {
|
|
2586
2915
|
if (!s) return { featureType: "zone" };
|
|
2587
|
-
const t = s.plannavn ?? s.bezeichnung ?? s.typ_bezeichnung ?? s.art ?? void 0, e = s.planid ?? s.plannummer ?? void 0, o = s.artcode ?? s.typ_code ?? s.abkuerzung ?? e ?? void 0, r = s.rechtsstatus ?? s.status ?? void 0, a =
|
|
2916
|
+
const t = s.plannavn ?? s.bezeichnung ?? s.typ_bezeichnung ?? s.art ?? void 0, e = s.planid ?? s.plannummer ?? void 0, o = s.artcode ?? s.typ_code ?? s.abkuerzung ?? e ?? void 0, r = s.rechtsstatus ?? s.status ?? void 0, a = Fe(r), i = s.typ_gde_bezeichnung ?? void 0, n = ze(i), p = s.dagsordenpunkt_url ?? s.dokument_url ?? s.link ?? void 0, c = s.auflagedatum ?? void 0, h = s.festsetzungsdatum ?? void 0, d = s.genehmigungsdatum ?? void 0, u = s.inkraftsetzungsdatum ?? void 0, w = s.flaeche ?? s.flaeche_m2 ?? void 0;
|
|
2588
2917
|
return {
|
|
2589
2918
|
featureType: "zone",
|
|
2590
2919
|
zoneType: t ? String(t) : void 0,
|
|
@@ -2597,10 +2926,10 @@ function Bs(s) {
|
|
|
2597
2926
|
fixingDate: h ?? void 0,
|
|
2598
2927
|
approvalDate: d ?? void 0,
|
|
2599
2928
|
effectiveFrom: u ?? void 0,
|
|
2600
|
-
areaM2: typeof
|
|
2929
|
+
areaM2: typeof w == "number" ? w : void 0
|
|
2601
2930
|
};
|
|
2602
2931
|
}
|
|
2603
|
-
function
|
|
2932
|
+
function la(s) {
|
|
2604
2933
|
const t = s.match(/^(\w+)\s*=\s*'([^']+)'$/);
|
|
2605
2934
|
if (t) {
|
|
2606
2935
|
const [, o, r] = t;
|
|
@@ -2615,37 +2944,68 @@ function Gs(s) {
|
|
|
2615
2944
|
}
|
|
2616
2945
|
return () => !0;
|
|
2617
2946
|
}
|
|
2618
|
-
|
|
2947
|
+
function ha(s) {
|
|
2948
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
2949
|
+
}
|
|
2950
|
+
function ie(s, t) {
|
|
2951
|
+
return `<fes:PropertyIsEqualTo><fes:ValueReference>${s}</fes:ValueReference><fes:Literal>${ha(t)}</fes:Literal></fes:PropertyIsEqualTo>`;
|
|
2952
|
+
}
|
|
2953
|
+
function da(s) {
|
|
2954
|
+
const t = s.match(/^(\w+)\s*=\s*'([^']+)'$/);
|
|
2955
|
+
if (t) {
|
|
2956
|
+
const [, o, r] = t;
|
|
2957
|
+
return ie(o, r);
|
|
2958
|
+
}
|
|
2959
|
+
const e = s.match(/^(\w+)\s+IN\s*\(([^)]+)\)$/i);
|
|
2960
|
+
if (e) {
|
|
2961
|
+
const [, o, r] = e;
|
|
2962
|
+
return `<fes:Or>${r.split(",").map((i) => i.trim().replace(/^'|'$/g, "")).map((i) => ie(o, i)).join("")}</fes:Or>`;
|
|
2963
|
+
}
|
|
2964
|
+
throw new Error(`Unsupported CQL filter pattern for FES translation: ${s}`);
|
|
2965
|
+
}
|
|
2966
|
+
function ua(s, t) {
|
|
2967
|
+
const [e, o, r, a] = s, [i, n, p] = t === "EPSG:2056" ? (() => {
|
|
2968
|
+
const [c, h] = Z(e, o), [d, u] = Z(r, a);
|
|
2969
|
+
return ["urn:ogc:def:crs:EPSG::2056", `${c} ${h}`, `${d} ${u}`];
|
|
2970
|
+
})() : ["urn:ogc:def:crs:EPSG::4326", `${o} ${e}`, `${a} ${r}`];
|
|
2971
|
+
return `<fes:BBOX><fes:ValueReference>${Qs}</fes:ValueReference><gml:Envelope srsName="${i}"><gml:lowerCorner>${n}</gml:lowerCorner><gml:upperCorner>${p}</gml:upperCorner></gml:Envelope></fes:BBOX>`;
|
|
2972
|
+
}
|
|
2973
|
+
function ga(s, t, e) {
|
|
2974
|
+
const o = ua(s, t);
|
|
2975
|
+
return `<fes:Filter xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:gml="http://www.opengis.net/gml/3.2">${e ? `<fes:And>${da(e)}${o}</fes:And>` : o}</fes:Filter>`;
|
|
2976
|
+
}
|
|
2977
|
+
class ht {
|
|
2619
2978
|
categoryMap;
|
|
2620
2979
|
baseUrl;
|
|
2621
2980
|
sourceId;
|
|
2622
2981
|
outputFormat;
|
|
2982
|
+
nativeCrs;
|
|
2623
2983
|
constructor(t) {
|
|
2624
|
-
this.categoryMap = t.categoryMap, this.baseUrl = t.baseUrl ??
|
|
2984
|
+
this.categoryMap = t.categoryMap, this.baseUrl = t.baseUrl ?? Ks, this.sourceId = t.sourceId ?? Ys, this.outputFormat = t.outputFormat ?? "application/json; subtype=geojson", this.nativeCrs = t.nativeCrs;
|
|
2625
2985
|
}
|
|
2626
2986
|
async listFeatureCategoryDescriptors(t) {
|
|
2627
2987
|
const e = await this.listAvailableLayers(t);
|
|
2628
|
-
return [...new Map(e.map((o) => [o.category,
|
|
2988
|
+
return [...new Map(e.map((o) => [o.category, x(o.category)])).values()];
|
|
2629
2989
|
}
|
|
2630
2990
|
async listAvailableLayers(t) {
|
|
2631
2991
|
const e = Object.entries(this.categoryMap);
|
|
2632
2992
|
return (await Promise.allSettled(
|
|
2633
2993
|
e.flatMap(
|
|
2634
2994
|
([r, a]) => a.map(async (i) => {
|
|
2635
|
-
const n =
|
|
2995
|
+
const n = pt(i), p = ct(i), c = await this._fetchFeatures(t, n, 1, p);
|
|
2636
2996
|
return { category: r, typeName: n, cqlFilter: p, hasResults: c.features.length > 0 };
|
|
2637
2997
|
})
|
|
2638
2998
|
)
|
|
2639
2999
|
)).filter(
|
|
2640
3000
|
(r) => r.status === "fulfilled" && r.value.hasResults
|
|
2641
|
-
).map((r) =>
|
|
3001
|
+
).map((r) => lt(this.sourceId, r.value.category, r.value.typeName, r.value.cqlFilter));
|
|
2642
3002
|
}
|
|
2643
3003
|
async getFeaturesForLayer(t, e) {
|
|
2644
3004
|
const o = this._findLayerById(e);
|
|
2645
3005
|
return o ? this._fetchAndConvert(t, o.descriptor, o.cqlFilter) : [];
|
|
2646
3006
|
}
|
|
2647
3007
|
async _fetchAndConvert(t, e, o) {
|
|
2648
|
-
const r = await this._fetchFeatures(t, e.sourceLayerId, void 0, o), a = o ?
|
|
3008
|
+
const r = await this._fetchFeatures(t, e.sourceLayerId, void 0, o), a = o ? la(o) : void 0;
|
|
2649
3009
|
return (a ? r.features.filter((n) => a(n.properties)) : r.features).map((n, p) => this.toGisFeature(n, e, p));
|
|
2650
3010
|
}
|
|
2651
3011
|
/**
|
|
@@ -2658,67 +3018,74 @@ class pt {
|
|
|
2658
3018
|
}
|
|
2659
3019
|
async getFeaturesOfCategory(t, e) {
|
|
2660
3020
|
const o = this.categoryMap[e] ?? [];
|
|
2661
|
-
return (await Promise.
|
|
3021
|
+
return (await Promise.allSettled(
|
|
2662
3022
|
o.map((a) => {
|
|
2663
|
-
const i =
|
|
3023
|
+
const i = pt(a), n = ct(a), p = lt(this.sourceId, e, i);
|
|
2664
3024
|
return this._fetchAndConvert(t, p, n);
|
|
2665
3025
|
})
|
|
2666
|
-
)).
|
|
3026
|
+
)).flatMap((a) => a.status === "fulfilled" ? a.value : (console.warn(`[ZurichMapsAdapter] "${e}" layer failed (${this.sourceId}):`, a.reason), []));
|
|
2667
3027
|
}
|
|
2668
3028
|
// ─── Private helpers ────────────────────────────────────────────────────────
|
|
2669
3029
|
_findLayerById(t) {
|
|
2670
3030
|
const e = Object.entries(this.categoryMap);
|
|
2671
3031
|
for (const [o, r] of e)
|
|
2672
3032
|
for (const a of r) {
|
|
2673
|
-
const i =
|
|
3033
|
+
const i = pt(a), n = ct(a), p = lt(this.sourceId, o, i, n);
|
|
2674
3034
|
if (p.id === t)
|
|
2675
3035
|
return { descriptor: p, cqlFilter: n };
|
|
2676
3036
|
}
|
|
2677
3037
|
}
|
|
2678
3038
|
async _fetchFeatures(t, e, o, r) {
|
|
2679
|
-
const
|
|
3039
|
+
const a = new URLSearchParams({
|
|
2680
3040
|
service: "WFS",
|
|
2681
3041
|
version: "2.0.0",
|
|
2682
3042
|
request: "GetFeature",
|
|
2683
3043
|
typename: e,
|
|
2684
|
-
|
|
2685
|
-
srsName: "EPSG:4326",
|
|
3044
|
+
srsName: this.nativeCrs ?? "EPSG:4326",
|
|
2686
3045
|
outputFormat: this.outputFormat
|
|
2687
3046
|
});
|
|
2688
|
-
o !== void 0 &&
|
|
2689
|
-
|
|
2690
|
-
|
|
3047
|
+
if (o !== void 0 && a.set("count", String(o)), r !== void 0)
|
|
3048
|
+
a.set("filter", ga(t, this.nativeCrs, r));
|
|
3049
|
+
else {
|
|
3050
|
+
const [p, c, h, d] = t, u = this.nativeCrs === "EPSG:2056" ? (() => {
|
|
3051
|
+
const [w, m] = Z(p, c), [g, y] = Z(h, d);
|
|
3052
|
+
return `${w},${m},${g},${y},urn:ogc:def:crs:EPSG::2056`;
|
|
3053
|
+
})() : `${c},${p},${d},${h},urn:ogc:def:crs:EPSG::4326`;
|
|
3054
|
+
a.set("bbox", u);
|
|
3055
|
+
}
|
|
3056
|
+
const i = `${this.baseUrl}?${a.toString()}`, n = await fetch(i);
|
|
3057
|
+
if (!n.ok)
|
|
2691
3058
|
throw new Error(
|
|
2692
|
-
`WFS request failed for ${e} (${this.sourceId}): ${
|
|
3059
|
+
`WFS request failed for ${e} (${this.sourceId}): ${n.status} ${n.statusText}`
|
|
2693
3060
|
);
|
|
2694
|
-
return
|
|
3061
|
+
return n.json();
|
|
2695
3062
|
}
|
|
2696
3063
|
toGisFeature(t, e, o) {
|
|
2697
|
-
const
|
|
3064
|
+
const r = this.nativeCrs === "EPSG:2056" ? ea(t.geometry) : t.geometry, [a, i] = ta(r), n = oa(t.properties, `${e.sourceLayerId}[${o}]`), p = t.bbox ? this.nativeCrs === "EPSG:2056" ? [...bt(t.bbox[0], t.bbox[1]), ...bt(t.bbox[2], t.bbox[3])] : [t.bbox[0], t.bbox[1], t.bbox[2], t.bbox[3]] : void 0, c = e.tier, h = c === "priority" ? this._extractNormalisedProperties(t, e) : void 0;
|
|
2698
3065
|
return {
|
|
2699
3066
|
id: t.id ?? `${e.sourceLayerId}/${o}`,
|
|
2700
3067
|
preferredColor: e.preferredColor,
|
|
2701
3068
|
sourceId: this.sourceId,
|
|
2702
3069
|
sourceFeatureId: t.id ?? `${e.sourceLayerId}/${o}`,
|
|
2703
3070
|
layerId: e.id,
|
|
2704
|
-
name:
|
|
3071
|
+
name: n,
|
|
2705
3072
|
category: e.category,
|
|
2706
3073
|
type: e.sourceLayerId.replace(/^ms:/, ""),
|
|
2707
|
-
lat:
|
|
2708
|
-
lon:
|
|
2709
|
-
displayName:
|
|
2710
|
-
bbox:
|
|
2711
|
-
geometry:
|
|
2712
|
-
tier:
|
|
2713
|
-
properties:
|
|
3074
|
+
lat: i,
|
|
3075
|
+
lon: a,
|
|
3076
|
+
displayName: n,
|
|
3077
|
+
bbox: p,
|
|
3078
|
+
geometry: r ?? void 0,
|
|
3079
|
+
tier: c,
|
|
3080
|
+
properties: h,
|
|
2714
3081
|
originalData: t.properties ?? {}
|
|
2715
3082
|
};
|
|
2716
3083
|
}
|
|
2717
3084
|
_extractNormalisedProperties(t, e) {
|
|
2718
|
-
return e.category === "building" ?
|
|
3085
|
+
return e.category === "building" ? aa(t.properties, this.sourceId) : e.category === "greenspace" ? na(t.properties) : e.category === "paved" ? pa(t.properties) : e.category === "zone" ? ca(t.properties) : ia(t.properties, this.sourceId);
|
|
2719
3086
|
}
|
|
2720
3087
|
}
|
|
2721
|
-
const
|
|
3088
|
+
const Ge = [8, 54.5, 15.2, 57.8], He = {
|
|
2722
3089
|
building: [
|
|
2723
3090
|
{ source: "danish-matrikel", typename: "geodkv_v001:bygning_current" },
|
|
2724
3091
|
// Footprint polygons (GeoDanmark Vektor)
|
|
@@ -2730,7 +3097,7 @@ const Pe = [8, 54.5, 15.2, 57.8], De = {
|
|
|
2730
3097
|
{ source: "danish-matrikel", typename: "mat_v001:samletfastejendom_current" }
|
|
2731
3098
|
]
|
|
2732
3099
|
};
|
|
2733
|
-
function
|
|
3100
|
+
function ma(s) {
|
|
2734
3101
|
if (!s) return [0, 0];
|
|
2735
3102
|
const t = s.coordinates;
|
|
2736
3103
|
switch (s.type) {
|
|
@@ -2748,7 +3115,7 @@ function Hs(s) {
|
|
|
2748
3115
|
return [0, 0];
|
|
2749
3116
|
}
|
|
2750
3117
|
}
|
|
2751
|
-
function
|
|
3118
|
+
function wa(s, t) {
|
|
2752
3119
|
if (!s) return t;
|
|
2753
3120
|
for (const e of [
|
|
2754
3121
|
"mat:matrikelnummer",
|
|
@@ -2764,14 +3131,14 @@ function Ws(s, t) {
|
|
|
2764
3131
|
if (typeof s[e] == "string" && s[e]) return s[e];
|
|
2765
3132
|
return t;
|
|
2766
3133
|
}
|
|
2767
|
-
function
|
|
3134
|
+
function fa(s, t, e) {
|
|
2768
3135
|
return `${s}:${t}:${e}`;
|
|
2769
3136
|
}
|
|
2770
|
-
const
|
|
2771
|
-
function
|
|
2772
|
-
const o = e.typename.replace(/^[^:]+:/, ""), r =
|
|
3137
|
+
const ya = /* @__PURE__ */ new Set(["building", "cadastre", "zone"]);
|
|
3138
|
+
function dt(s, t, e) {
|
|
3139
|
+
const o = e.typename.replace(/^[^:]+:/, ""), r = x(t), a = ya.has(t) ? "priority" : "raw";
|
|
2773
3140
|
return {
|
|
2774
|
-
id:
|
|
3141
|
+
id: fa(s, e.source, e.typename),
|
|
2775
3142
|
sourceId: s,
|
|
2776
3143
|
sourceLayerId: e.typename,
|
|
2777
3144
|
category: t,
|
|
@@ -2783,7 +3150,7 @@ function ct(s, t, e) {
|
|
|
2783
3150
|
descriptionKey: `gis.layer.${s}.${e.source}.${o}.description`
|
|
2784
3151
|
};
|
|
2785
3152
|
}
|
|
2786
|
-
function
|
|
3153
|
+
function ba(s, t) {
|
|
2787
3154
|
if (t === "building") {
|
|
2788
3155
|
const i = s?.byg041BebyggetAreal ?? s?.byg038SamletBygningsareal, n = s?.byg021BygningensAnvendelse, p = s?.id_lokalId, c = s?.byg026Opførelsesår;
|
|
2789
3156
|
return {
|
|
@@ -2800,8 +3167,8 @@ function Qs(s, t) {
|
|
|
2800
3167
|
featureType: "zone",
|
|
2801
3168
|
zoneType: i ?? void 0,
|
|
2802
3169
|
zoneCode: p ?? void 0,
|
|
2803
|
-
legalStatus:
|
|
2804
|
-
planType:
|
|
3170
|
+
legalStatus: Fe(c),
|
|
3171
|
+
planType: ze(s?.typ_gde_bezeichnung),
|
|
2805
3172
|
planId: n ?? void 0,
|
|
2806
3173
|
planDocumentLink: h ?? void 0,
|
|
2807
3174
|
publicationDate: s?.auflagedatum ?? void 0,
|
|
@@ -2819,19 +3186,19 @@ function Qs(s, t) {
|
|
|
2819
3186
|
registryId: a ?? void 0
|
|
2820
3187
|
};
|
|
2821
3188
|
}
|
|
2822
|
-
class
|
|
3189
|
+
class _a {
|
|
2823
3190
|
categoryMap;
|
|
2824
3191
|
dataViewsBaseUrl;
|
|
2825
3192
|
getHeaders;
|
|
2826
3193
|
sourceId;
|
|
2827
3194
|
constructor(t) {
|
|
2828
|
-
this.dataViewsBaseUrl = t.dataViewsBaseUrl.replace(/\/$/, ""), this.getHeaders = t.getHeaders, this.categoryMap = t.categoryMap ??
|
|
3195
|
+
this.dataViewsBaseUrl = t.dataViewsBaseUrl.replace(/\/$/, ""), this.getHeaders = t.getHeaders, this.categoryMap = t.categoryMap ?? He, this.sourceId = t.sourceId ?? "cue-sdk-gis";
|
|
2829
3196
|
}
|
|
2830
3197
|
async listFeatureCategoryDescriptors(t) {
|
|
2831
3198
|
const e = await this.listAvailableLayers(t);
|
|
2832
3199
|
return [
|
|
2833
3200
|
...new Map(
|
|
2834
|
-
e.map((o) => [o.category,
|
|
3201
|
+
e.map((o) => [o.category, x(o.category)])
|
|
2835
3202
|
).values()
|
|
2836
3203
|
];
|
|
2837
3204
|
}
|
|
@@ -2846,7 +3213,7 @@ class Ks {
|
|
|
2846
3213
|
)
|
|
2847
3214
|
)).filter(
|
|
2848
3215
|
(r) => r.status === "fulfilled" && r.value.hasResults
|
|
2849
|
-
).map((r) =>
|
|
3216
|
+
).map((r) => dt(this.sourceId, r.value.category, r.value.entry));
|
|
2850
3217
|
}
|
|
2851
3218
|
async getFeaturesForLayer(t, e) {
|
|
2852
3219
|
const o = this._findLayerById(e);
|
|
@@ -2860,7 +3227,7 @@ class Ks {
|
|
|
2860
3227
|
const o = this.categoryMap[e] ?? [];
|
|
2861
3228
|
return (await Promise.allSettled(
|
|
2862
3229
|
o.map((a) => {
|
|
2863
|
-
const i =
|
|
3230
|
+
const i = dt(this.sourceId, e, a);
|
|
2864
3231
|
return this.getFeaturesForLayer(t, i.id);
|
|
2865
3232
|
})
|
|
2866
3233
|
)).flatMap((a, i) => a.status === "fulfilled" ? a.value : (console.warn(
|
|
@@ -2872,7 +3239,7 @@ class Ks {
|
|
|
2872
3239
|
_findLayerById(t) {
|
|
2873
3240
|
for (const [e, o] of Object.entries(this.categoryMap))
|
|
2874
3241
|
for (const r of o) {
|
|
2875
|
-
const a =
|
|
3242
|
+
const a = dt(this.sourceId, e, r);
|
|
2876
3243
|
if (a.id === t) return { entry: r, descriptor: a };
|
|
2877
3244
|
}
|
|
2878
3245
|
}
|
|
@@ -2891,7 +3258,7 @@ class Ks {
|
|
|
2891
3258
|
return d.json();
|
|
2892
3259
|
}
|
|
2893
3260
|
_toGisFeature(t, e, o) {
|
|
2894
|
-
const [r, a] =
|
|
3261
|
+
const [r, a] = ma(t.geometry), i = t.id ?? `${e.sourceLayerId}/${o}`, n = wa(t.properties, i), p = t.bbox ? [t.bbox[0], t.bbox[1], t.bbox[2], t.bbox[3]] : void 0, c = e.tier, h = c === "priority" ? ba(t.properties, e.category) : void 0;
|
|
2895
3262
|
return {
|
|
2896
3263
|
id: i,
|
|
2897
3264
|
sourceId: this.sourceId,
|
|
@@ -2912,7 +3279,125 @@ class Ks {
|
|
|
2912
3279
|
};
|
|
2913
3280
|
}
|
|
2914
3281
|
}
|
|
2915
|
-
|
|
3282
|
+
function Ct(s, t) {
|
|
3283
|
+
if (Array.isArray(s)) {
|
|
3284
|
+
if (typeof s[0] == "number" && typeof s[1] == "number") {
|
|
3285
|
+
t([s[0], s[1]]);
|
|
3286
|
+
return;
|
|
3287
|
+
}
|
|
3288
|
+
for (const e of s) Ct(e, t);
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
function kt(s) {
|
|
3292
|
+
return s ? s.type === "GeometryCollection" ? (s.geometries ?? []).flatMap((t) => kt(t)) : [s.coordinates] : [];
|
|
3293
|
+
}
|
|
3294
|
+
function va(s) {
|
|
3295
|
+
let t = 1 / 0, e = 1 / 0, o = -1 / 0, r = -1 / 0;
|
|
3296
|
+
const a = (i) => {
|
|
3297
|
+
i[0] < t && (t = i[0]), i[1] < e && (e = i[1]), i[0] > o && (o = i[0]), i[1] > r && (r = i[1]);
|
|
3298
|
+
};
|
|
3299
|
+
return kt(s).forEach((i) => Ct(i, a)), t === 1 / 0 ? null : [t, e, o, r];
|
|
3300
|
+
}
|
|
3301
|
+
function Ea(s) {
|
|
3302
|
+
let t = null;
|
|
3303
|
+
for (const e of kt(s))
|
|
3304
|
+
if (Ct(e, (o) => t ??= o), t) break;
|
|
3305
|
+
return t ?? [0, 0];
|
|
3306
|
+
}
|
|
3307
|
+
function Ta(s, t) {
|
|
3308
|
+
if (s) {
|
|
3309
|
+
for (const e of ["name", "Name", "title", "Title", "label", "Label"])
|
|
3310
|
+
if (typeof s[e] == "string" && s[e]) return s[e];
|
|
3311
|
+
}
|
|
3312
|
+
return t;
|
|
3313
|
+
}
|
|
3314
|
+
class It {
|
|
3315
|
+
static _LIST_CACHE_TTL_MS = 5e3;
|
|
3316
|
+
dataViewsBaseUrl;
|
|
3317
|
+
getHeaders;
|
|
3318
|
+
sourceId;
|
|
3319
|
+
_listCache = null;
|
|
3320
|
+
constructor(t) {
|
|
3321
|
+
this.dataViewsBaseUrl = t.dataViewsBaseUrl.replace(/\/$/, ""), this.getHeaders = t.getHeaders, this.sourceId = t.sourceId ?? "cue-gis-sources";
|
|
3322
|
+
}
|
|
3323
|
+
async listFeatureCategoryDescriptors(t) {
|
|
3324
|
+
return (await this.listAvailableLayers(t)).length > 0 ? [x("custom")] : [];
|
|
3325
|
+
}
|
|
3326
|
+
async listFeatureCategories(t) {
|
|
3327
|
+
return (await this.listAvailableLayers(t)).length > 0 ? ["custom"] : [];
|
|
3328
|
+
}
|
|
3329
|
+
async listAvailableLayers(t) {
|
|
3330
|
+
return (await this._listSources()).filter((o) => o.bbox !== null && D(o.bbox, t)).map((o) => this._toLayerDescriptor(o));
|
|
3331
|
+
}
|
|
3332
|
+
async getFeaturesForLayer(t, e) {
|
|
3333
|
+
const o = this._idFromLayerId(e);
|
|
3334
|
+
if (!o) return [];
|
|
3335
|
+
const r = await this._getSource(o);
|
|
3336
|
+
return r ? r.featureCollection.features.map((a, i) => ({ feature: a, index: i, bbox: va(a.geometry) })).filter((a) => a.bbox !== null && D(a.bbox, t)).map((a) => this._toGisFeature(a.feature, r, a.index)) : [];
|
|
3337
|
+
}
|
|
3338
|
+
async getFeaturesOfCategory(t, e) {
|
|
3339
|
+
if (e !== "custom") return [];
|
|
3340
|
+
const o = await this.listAvailableLayers(t);
|
|
3341
|
+
return (await Promise.allSettled(o.map((a) => this.getFeaturesForLayer(t, a.id)))).flatMap((a, i) => a.status === "fulfilled" ? a.value : (console.warn(`[GisSourcesAdapter] Source "${o[i].label}" failed:`, a.reason), []));
|
|
3342
|
+
}
|
|
3343
|
+
// ─── Private helpers ────────────────────────────────────────────────────────
|
|
3344
|
+
_toLayerDescriptor(t) {
|
|
3345
|
+
const e = x("custom");
|
|
3346
|
+
return {
|
|
3347
|
+
id: `${this.sourceId}:${t.id}`,
|
|
3348
|
+
sourceId: this.sourceId,
|
|
3349
|
+
sourceLayerId: t.id,
|
|
3350
|
+
category: "custom",
|
|
3351
|
+
preferredColor: e.preferredColor,
|
|
3352
|
+
tier: "raw",
|
|
3353
|
+
label: t.name,
|
|
3354
|
+
description: `${t.featureCount} uploaded feature${t.featureCount === 1 ? "" : "s"}`
|
|
3355
|
+
};
|
|
3356
|
+
}
|
|
3357
|
+
_idFromLayerId(t) {
|
|
3358
|
+
const e = `${this.sourceId}:`;
|
|
3359
|
+
return t.startsWith(e) ? t.slice(e.length) : null;
|
|
3360
|
+
}
|
|
3361
|
+
_toGisFeature(t, e, o) {
|
|
3362
|
+
const [r, a] = Ea(t.geometry), i = t.id !== void 0 ? String(t.id) : `${e.id}/${o}`, n = t.properties ?? {}, p = Ta(n, `${e.name} #${o + 1}`);
|
|
3363
|
+
return {
|
|
3364
|
+
id: `${this.sourceId}:${e.id}:${i}`,
|
|
3365
|
+
sourceId: this.sourceId,
|
|
3366
|
+
sourceFeatureId: i,
|
|
3367
|
+
layerId: `${this.sourceId}:${e.id}`,
|
|
3368
|
+
name: p,
|
|
3369
|
+
category: "custom",
|
|
3370
|
+
preferredColor: x("custom").preferredColor,
|
|
3371
|
+
type: "custom",
|
|
3372
|
+
lat: a,
|
|
3373
|
+
lon: r,
|
|
3374
|
+
displayName: p,
|
|
3375
|
+
geometry: t.geometry ?? void 0,
|
|
3376
|
+
tier: "raw",
|
|
3377
|
+
originalData: n
|
|
3378
|
+
};
|
|
3379
|
+
}
|
|
3380
|
+
async _listSources() {
|
|
3381
|
+
const t = Date.now();
|
|
3382
|
+
if (this._listCache && t - this._listCache.at < It._LIST_CACHE_TTL_MS)
|
|
3383
|
+
return this._listCache.sources;
|
|
3384
|
+
const e = await this.getHeaders(), o = await fetch(`${this.dataViewsBaseUrl}/gis-sources`, { headers: e });
|
|
3385
|
+
if (!o.ok)
|
|
3386
|
+
throw new Error(`GisSourcesAdapter: list request failed: ${o.status} ${o.statusText}`);
|
|
3387
|
+
const r = await o.json();
|
|
3388
|
+
return this._listCache = { at: t, sources: r }, r;
|
|
3389
|
+
}
|
|
3390
|
+
async _getSource(t) {
|
|
3391
|
+
const e = this._listCache?.sources.find((a) => a.id === t);
|
|
3392
|
+
if (e) return e;
|
|
3393
|
+
const o = await this.getHeaders(), r = await fetch(`${this.dataViewsBaseUrl}/gis-sources/${t}`, { headers: o });
|
|
3394
|
+
if (r.status === 404) return null;
|
|
3395
|
+
if (!r.ok)
|
|
3396
|
+
throw new Error(`GisSourcesAdapter: get request failed for "${t}": ${r.status} ${r.statusText}`);
|
|
3397
|
+
return await r.json();
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
const Sa = {
|
|
2916
3401
|
address: [
|
|
2917
3402
|
"ms:ogd-0406_arv_basis_avzh_hausnummer_pos_p",
|
|
2918
3403
|
"ms:ogd-0571_afv_gv_strat_strassennetz_l"
|
|
@@ -2960,23 +3445,25 @@ const Ys = {
|
|
|
2960
3445
|
// ÖREB Überlagernde Festlegungen (Flächen) – overlaying planning constraints
|
|
2961
3446
|
"ms:ogd-0155_arv_basis_np_ul_flaeche_f"
|
|
2962
3447
|
]
|
|
2963
|
-
},
|
|
3448
|
+
}, We = [
|
|
2964
3449
|
{
|
|
2965
3450
|
name: "Canton of Zürich",
|
|
2966
|
-
coverageBBox:
|
|
3451
|
+
coverageBBox: Js,
|
|
2967
3452
|
supportedCategories: ["address", "poi", "railway", "natural", "manmade", "building", "cadastre", "greenspace", "paved", "zone"],
|
|
2968
3453
|
priority: 10,
|
|
2969
|
-
adapter: new
|
|
2970
|
-
categoryMap:
|
|
3454
|
+
adapter: new ht({
|
|
3455
|
+
categoryMap: Sa,
|
|
3456
|
+
// maps.zh.ch (MapServer) ignores srsName and always operates in LV95.
|
|
3457
|
+
nativeCrs: "EPSG:2056"
|
|
2971
3458
|
})
|
|
2972
3459
|
},
|
|
2973
3460
|
{
|
|
2974
3461
|
name: "Switzerland (national AV cadastre)",
|
|
2975
|
-
coverageBBox:
|
|
3462
|
+
coverageBBox: Zs,
|
|
2976
3463
|
supportedCategories: ["cadastre"],
|
|
2977
3464
|
priority: 5,
|
|
2978
3465
|
// Lower priority than canton-specific adapters. For ZH, the canton adapter (priority 10) wins.
|
|
2979
|
-
adapter: new
|
|
3466
|
+
adapter: new ht({
|
|
2980
3467
|
sourceId: "swiss-av-wfs",
|
|
2981
3468
|
baseUrl: "https://wfs.geodienste.ch/av_0/deu",
|
|
2982
3469
|
categoryMap: {
|
|
@@ -3000,10 +3487,10 @@ const Ys = {
|
|
|
3000
3487
|
* - `pdk:kommuneplanramme_vedtaget` – adopted municipal plan frameworks
|
|
3001
3488
|
*/
|
|
3002
3489
|
name: "Denmark (Plandata.dk – planning zones)",
|
|
3003
|
-
coverageBBox:
|
|
3490
|
+
coverageBBox: Ge,
|
|
3004
3491
|
supportedCategories: ["zone"],
|
|
3005
3492
|
priority: 10,
|
|
3006
|
-
adapter: new
|
|
3493
|
+
adapter: new ht({
|
|
3007
3494
|
sourceId: "danish-plandata",
|
|
3008
3495
|
baseUrl: "https://wfs.plandata.dk/geoserver/pdk/wfs",
|
|
3009
3496
|
outputFormat: "application/json",
|
|
@@ -3018,12 +3505,12 @@ const Ys = {
|
|
|
3018
3505
|
})
|
|
3019
3506
|
}
|
|
3020
3507
|
];
|
|
3021
|
-
function
|
|
3508
|
+
function ne(s) {
|
|
3022
3509
|
return [...s].sort(
|
|
3023
|
-
(t, e) =>
|
|
3510
|
+
(t, e) => ft.indexOf(t.category) - ft.indexOf(e.category)
|
|
3024
3511
|
);
|
|
3025
3512
|
}
|
|
3026
|
-
class
|
|
3513
|
+
class Ca {
|
|
3027
3514
|
nominatim;
|
|
3028
3515
|
regions;
|
|
3029
3516
|
/**
|
|
@@ -3038,9 +3525,9 @@ class Js {
|
|
|
3038
3525
|
zonePlanTypeColors: r,
|
|
3039
3526
|
...a
|
|
3040
3527
|
} = t;
|
|
3041
|
-
this.nominatim = new
|
|
3042
|
-
const i = o ?
|
|
3043
|
-
this.regions = e ?? i, this.zonePlanTypeColors = { ...
|
|
3528
|
+
this.nominatim = new zs(a);
|
|
3529
|
+
const i = o ? We : [];
|
|
3530
|
+
this.regions = e ?? i, this.zonePlanTypeColors = { ...Ls, ...r };
|
|
3044
3531
|
}
|
|
3045
3532
|
/**
|
|
3046
3533
|
* Return the available feature categories together with UI metadata such as
|
|
@@ -3053,18 +3540,18 @@ class Js {
|
|
|
3053
3540
|
* @param bbox [west, south, east, north] in WGS-84 decimal degrees
|
|
3054
3541
|
*/
|
|
3055
3542
|
async listFeatureCategoryDescriptors(t) {
|
|
3056
|
-
const e = this.regions.filter((r) =>
|
|
3543
|
+
const e = this.regions.filter((r) => D(r.coverageBBox, t) && r.supportedCategories).sort((r, a) => (a.priority ?? 0) - (r.priority ?? 0));
|
|
3057
3544
|
if (e.length > 0) {
|
|
3058
3545
|
const r = /* @__PURE__ */ new Set(), a = [];
|
|
3059
3546
|
for (const i of e)
|
|
3060
3547
|
for (const n of i.supportedCategories ?? [])
|
|
3061
|
-
r.has(n) || (r.add(n), a.push(
|
|
3062
|
-
for (const i of
|
|
3063
|
-
r.has(i) || a.push(
|
|
3064
|
-
return
|
|
3548
|
+
r.has(n) || (r.add(n), a.push(x(n)));
|
|
3549
|
+
for (const i of yt)
|
|
3550
|
+
r.has(i) || a.push(x(i));
|
|
3551
|
+
return ne(a);
|
|
3065
3552
|
}
|
|
3066
3553
|
const o = await this._adapterFor(t).listFeatureCategoryDescriptors(t);
|
|
3067
|
-
return
|
|
3554
|
+
return ne(o);
|
|
3068
3555
|
}
|
|
3069
3556
|
/**
|
|
3070
3557
|
* Return the feature categories that have at least one result within the
|
|
@@ -3114,7 +3601,7 @@ class Js {
|
|
|
3114
3601
|
console.log(" • Nominatim (OSM) bbox=[global] priority=-1");
|
|
3115
3602
|
const r = [
|
|
3116
3603
|
...this.regions.filter(
|
|
3117
|
-
(n) =>
|
|
3604
|
+
(n) => D(n.coverageBBox, t) && (!n.supportedCategories || n.supportedCategories.includes(e))
|
|
3118
3605
|
).map((n) => ({
|
|
3119
3606
|
name: n.name,
|
|
3120
3607
|
adapter: n.adapter,
|
|
@@ -3137,7 +3624,7 @@ class Js {
|
|
|
3137
3624
|
const { features: n, idx: p } = await Promise.race(i.values());
|
|
3138
3625
|
i.delete(p);
|
|
3139
3626
|
for (const c of n) {
|
|
3140
|
-
const h =
|
|
3627
|
+
const h = pe(c), d = tt(c), u = a.get(h);
|
|
3141
3628
|
(u === void 0 || d > u) && (a.set(h, d), yield c);
|
|
3142
3629
|
}
|
|
3143
3630
|
}
|
|
@@ -3158,7 +3645,7 @@ class Js {
|
|
|
3158
3645
|
async getFeaturesOfCategory(t, e) {
|
|
3159
3646
|
const r = [
|
|
3160
3647
|
...this.regions.filter(
|
|
3161
|
-
(d) =>
|
|
3648
|
+
(d) => D(d.coverageBBox, t) && (!d.supportedCategories || d.supportedCategories.includes(e))
|
|
3162
3649
|
).map((d) => ({ name: d.name, adapter: d.adapter, isNominatim: !1 })),
|
|
3163
3650
|
{ name: "Nominatim (OSM)", adapter: this.nominatim, isNominatim: !0 }
|
|
3164
3651
|
], a = await Promise.allSettled(
|
|
@@ -3171,10 +3658,10 @@ class Js {
|
|
|
3171
3658
|
), i = [], n = [];
|
|
3172
3659
|
for (const d of a)
|
|
3173
3660
|
d.status === "fulfilled" && (d.value.isNominatim ? n.push(...d.value.features) : i.push(...d.value.features));
|
|
3174
|
-
const p =
|
|
3661
|
+
const p = xa(i, n), c = /* @__PURE__ */ new Map(), h = [];
|
|
3175
3662
|
for (const d of p) {
|
|
3176
|
-
const u =
|
|
3177
|
-
(
|
|
3663
|
+
const u = pe(d), w = tt(d), m = c.get(u);
|
|
3664
|
+
(m === void 0 || w > m) && (c.set(u, w), h.push(d));
|
|
3178
3665
|
}
|
|
3179
3666
|
return h;
|
|
3180
3667
|
}
|
|
@@ -3184,29 +3671,29 @@ class Js {
|
|
|
3184
3671
|
}
|
|
3185
3672
|
/** Resolve the best adapter for a query bbox (legacy single-adapter routing). */
|
|
3186
3673
|
_adapterFor(t) {
|
|
3187
|
-
return this.regions.filter((o) =>
|
|
3674
|
+
return this.regions.filter((o) => D(o.coverageBBox, t)).sort((o, r) => (r.priority ?? 0) - (o.priority ?? 0))[0]?.adapter ?? this.nominatim;
|
|
3188
3675
|
}
|
|
3189
3676
|
}
|
|
3190
|
-
function
|
|
3677
|
+
function tt(s) {
|
|
3191
3678
|
const t = s.geometry?.type;
|
|
3192
3679
|
return t === "Polygon" || t === "MultiPolygon" ? 3 : t === "LineString" || t === "MultiLineString" ? 2 : 1;
|
|
3193
3680
|
}
|
|
3194
|
-
function
|
|
3681
|
+
function pe(s) {
|
|
3195
3682
|
const t = Math.round(s.lat * 1e3) / 1e3, e = Math.round(s.lon * 1e3) / 1e3;
|
|
3196
3683
|
return `${(s.name ?? s.id ?? "").toLowerCase().trim()}|${t}|${e}`;
|
|
3197
3684
|
}
|
|
3198
|
-
const
|
|
3199
|
-
function
|
|
3685
|
+
const ka = 1e-3;
|
|
3686
|
+
function Ia(s, t) {
|
|
3200
3687
|
const e = s.lat - t.lat, o = s.lon - t.lon;
|
|
3201
3688
|
return Math.sqrt(e * e + o * o);
|
|
3202
3689
|
}
|
|
3203
|
-
function
|
|
3690
|
+
function xa(s, t) {
|
|
3204
3691
|
if (t.length === 0) return s;
|
|
3205
|
-
const e = s.filter((i) =>
|
|
3692
|
+
const e = s.filter((i) => tt(i) === 3), o = s.filter((i) => tt(i) !== 3), r = e.map((i) => ({ feature: { ...i, originalData: { ...i.originalData } }, matched: !1 })), a = [];
|
|
3206
3693
|
for (const i of t) {
|
|
3207
|
-
let n = -1, p =
|
|
3694
|
+
let n = -1, p = ka;
|
|
3208
3695
|
for (let c = 0; c < r.length; c++) {
|
|
3209
|
-
const h =
|
|
3696
|
+
const h = Ia(i, r[c].feature);
|
|
3210
3697
|
h < p && (p = h, n = c);
|
|
3211
3698
|
}
|
|
3212
3699
|
n >= 0 ? (r[n].feature.originalData = {
|
|
@@ -3220,8 +3707,8 @@ function ea(s, t) {
|
|
|
3220
3707
|
...a
|
|
3221
3708
|
];
|
|
3222
3709
|
}
|
|
3223
|
-
const
|
|
3224
|
-
class
|
|
3710
|
+
const ce = "/data-views", Ra = 1500, Aa = [-180, -90, 180, 90];
|
|
3711
|
+
class Oa {
|
|
3225
3712
|
// undefined = not yet built
|
|
3226
3713
|
/** @internal — construct via `cue.gis`, not directly. */
|
|
3227
3714
|
constructor(t, e) {
|
|
@@ -3304,25 +3791,41 @@ class sa {
|
|
|
3304
3791
|
}
|
|
3305
3792
|
// ── Private ───────────────────────────────────────────────────────────────
|
|
3306
3793
|
_scheduleDebouncedQuery() {
|
|
3307
|
-
this._debounceTimer !== null && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => this._queryLayers(),
|
|
3794
|
+
this._debounceTimer !== null && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => this._queryLayers(), Ra);
|
|
3308
3795
|
}
|
|
3309
3796
|
_getGateway() {
|
|
3310
3797
|
if (this._gatewayCache !== null && this._gatewayProjectId === this._projectId)
|
|
3311
3798
|
return this._gatewayCache;
|
|
3312
|
-
const t = this._projectId, e = [
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3799
|
+
const t = this._projectId, e = [...We];
|
|
3800
|
+
if (t) {
|
|
3801
|
+
const o = async () => ({
|
|
3802
|
+
...await this._getAuthHeaders(),
|
|
3803
|
+
"x-project-id": t
|
|
3804
|
+
});
|
|
3805
|
+
e.unshift(
|
|
3806
|
+
{
|
|
3807
|
+
name: "Cue SDK (authenticated)",
|
|
3808
|
+
coverageBBox: Ge,
|
|
3809
|
+
supportedCategories: Object.keys(He),
|
|
3810
|
+
priority: 10,
|
|
3811
|
+
adapter: new _a({
|
|
3812
|
+
dataViewsBaseUrl: `${this._gatewayUrl}${ce}`,
|
|
3813
|
+
getHeaders: o
|
|
3814
|
+
})
|
|
3815
|
+
},
|
|
3816
|
+
{
|
|
3817
|
+
name: "Cue SDK (GIS sources)",
|
|
3818
|
+
coverageBBox: Aa,
|
|
3819
|
+
supportedCategories: ["custom"],
|
|
3820
|
+
priority: 10,
|
|
3821
|
+
adapter: new It({
|
|
3822
|
+
dataViewsBaseUrl: `${this._gatewayUrl}${ce}`,
|
|
3823
|
+
getHeaders: o
|
|
3824
|
+
})
|
|
3825
|
+
}
|
|
3826
|
+
);
|
|
3827
|
+
}
|
|
3828
|
+
return this._gatewayCache = new Ca({ regions: e }), this._gatewayProjectId = t, this._gatewayCache;
|
|
3326
3829
|
}
|
|
3327
3830
|
async _queryLayers() {
|
|
3328
3831
|
const t = this._bbox;
|
|
@@ -3366,17 +3869,17 @@ class sa {
|
|
|
3366
3869
|
this._loadListeners.forEach((e) => e(t));
|
|
3367
3870
|
}
|
|
3368
3871
|
}
|
|
3369
|
-
class
|
|
3872
|
+
class le {
|
|
3370
3873
|
constructor(t, e, o = !1, r) {
|
|
3371
|
-
if (this._auth = t, this._db =
|
|
3874
|
+
if (this._auth = t, this._db = so(e), this._gatewayUrl = r?.gatewayUrl ?? "", o) {
|
|
3372
3875
|
const a = r?.firestoreEmulatorHost ?? "localhost", i = r?.firestoreEmulatorPort ?? 8080;
|
|
3373
|
-
|
|
3876
|
+
ao(this._db, a, i);
|
|
3374
3877
|
}
|
|
3375
3878
|
}
|
|
3376
3879
|
_auth;
|
|
3377
3880
|
_db;
|
|
3378
3881
|
_gatewayUrl;
|
|
3379
|
-
_projects = new
|
|
3882
|
+
_projects = new T(void 0);
|
|
3380
3883
|
/**
|
|
3381
3884
|
* Live cache of the current user's projects, refreshed on every `listProjects()`
|
|
3382
3885
|
* call and patched in place by `getProject()` — lets consumers reflect changes
|
|
@@ -3388,7 +3891,7 @@ class te {
|
|
|
3388
3891
|
* Throws if a project with the given ID already exists.
|
|
3389
3892
|
*/
|
|
3390
3893
|
async createProject(t) {
|
|
3391
|
-
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
3894
|
+
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${Pr}`, {
|
|
3392
3895
|
method: "POST",
|
|
3393
3896
|
headers: { "Content-Type": "application/json" },
|
|
3394
3897
|
body: JSON.stringify(t)
|
|
@@ -3401,7 +3904,7 @@ class te {
|
|
|
3401
3904
|
}
|
|
3402
3905
|
/** List all projects where the authenticated user appears in the members array. */
|
|
3403
3906
|
async listProjects() {
|
|
3404
|
-
const t = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
3907
|
+
const t = await this._auth.authenticatedFetch(`${this._gatewayUrl}${Gt}`);
|
|
3405
3908
|
if (!t.ok) {
|
|
3406
3909
|
const o = await t.text().catch(() => "");
|
|
3407
3910
|
throw new Error(`Failed to list projects: ${t.status} ${t.statusText}${o ? ` — ${o}` : ""}`);
|
|
@@ -3412,7 +3915,7 @@ class te {
|
|
|
3412
3915
|
/** Fetch a single project by ID. Returns null if not found or user lacks access. */
|
|
3413
3916
|
async getProject(t) {
|
|
3414
3917
|
const e = await this._auth.authenticatedFetch(
|
|
3415
|
-
`${this._gatewayUrl}${
|
|
3918
|
+
`${this._gatewayUrl}${Gt}?projectId=${encodeURIComponent(t)}`
|
|
3416
3919
|
);
|
|
3417
3920
|
if (!e.ok) {
|
|
3418
3921
|
if (e.status === 404) return null;
|
|
@@ -3438,10 +3941,10 @@ class te {
|
|
|
3438
3941
|
*/
|
|
3439
3942
|
async incrementUnitsConsumed(t, e, o) {
|
|
3440
3943
|
if (e <= 0) return;
|
|
3441
|
-
const r =
|
|
3442
|
-
await
|
|
3443
|
-
unitsConsumed:
|
|
3444
|
-
lastUpdated:
|
|
3944
|
+
const r = io(this._db, "clientSync", t);
|
|
3945
|
+
await no(r, {
|
|
3946
|
+
unitsConsumed: co(e),
|
|
3947
|
+
lastUpdated: po(),
|
|
3445
3948
|
lastUserId: o
|
|
3446
3949
|
}, { merge: !0 });
|
|
3447
3950
|
}
|
|
@@ -3452,7 +3955,7 @@ class te {
|
|
|
3452
3955
|
*/
|
|
3453
3956
|
async inviteUserToProject(t, e, o) {
|
|
3454
3957
|
const r = await this._auth.authenticatedFetch(
|
|
3455
|
-
`${this._gatewayUrl}${
|
|
3958
|
+
`${this._gatewayUrl}${jr(e)}`,
|
|
3456
3959
|
{
|
|
3457
3960
|
method: "POST",
|
|
3458
3961
|
headers: { "Content-Type": "application/json" },
|
|
@@ -3471,7 +3974,7 @@ class te {
|
|
|
3471
3974
|
/** Change an existing member's role on a project. */
|
|
3472
3975
|
async changeUserRoleOnProject(t, e, o) {
|
|
3473
3976
|
const r = await this._auth.authenticatedFetch(
|
|
3474
|
-
`${this._gatewayUrl}${
|
|
3977
|
+
`${this._gatewayUrl}${Lr(e, t)}`,
|
|
3475
3978
|
{
|
|
3476
3979
|
method: "PUT",
|
|
3477
3980
|
headers: { "Content-Type": "application/json" },
|
|
@@ -3486,7 +3989,7 @@ class te {
|
|
|
3486
3989
|
/** Remove a member from a project. */
|
|
3487
3990
|
async removeUserFromProject(t, e) {
|
|
3488
3991
|
const o = await this._auth.authenticatedFetch(
|
|
3489
|
-
`${this._gatewayUrl}${
|
|
3992
|
+
`${this._gatewayUrl}${Ur(e, t)}`,
|
|
3490
3993
|
{ method: "DELETE" }
|
|
3491
3994
|
);
|
|
3492
3995
|
if (!o.ok) {
|
|
@@ -3502,7 +4005,7 @@ class te {
|
|
|
3502
4005
|
*/
|
|
3503
4006
|
async deleteProject(t, e = !1) {
|
|
3504
4007
|
const o = e ? "?hard=true" : "", r = await this._auth.authenticatedFetch(
|
|
3505
|
-
`${this._gatewayUrl}${
|
|
4008
|
+
`${this._gatewayUrl}${Dr(t)}${o}`,
|
|
3506
4009
|
{ method: "DELETE" }
|
|
3507
4010
|
);
|
|
3508
4011
|
if (!r.ok) {
|
|
@@ -3516,7 +4019,7 @@ class te {
|
|
|
3516
4019
|
*/
|
|
3517
4020
|
async restoreProject(t) {
|
|
3518
4021
|
const e = await this._auth.authenticatedFetch(
|
|
3519
|
-
`${this._gatewayUrl}${
|
|
4022
|
+
`${this._gatewayUrl}${Nr(t)}`,
|
|
3520
4023
|
{ method: "POST" }
|
|
3521
4024
|
);
|
|
3522
4025
|
if (!e.ok) {
|
|
@@ -3533,7 +4036,7 @@ class te {
|
|
|
3533
4036
|
*/
|
|
3534
4037
|
async getProjectMetadata(t) {
|
|
3535
4038
|
const e = await this._auth.authenticatedFetch(
|
|
3536
|
-
`${this._gatewayUrl}${
|
|
4039
|
+
`${this._gatewayUrl}${Mr(t)}`
|
|
3537
4040
|
);
|
|
3538
4041
|
if (!e.ok) {
|
|
3539
4042
|
const o = await e.text().catch(() => "");
|
|
@@ -3544,7 +4047,7 @@ class te {
|
|
|
3544
4047
|
/** Sets a project's portal-only metadata. Omit a field to leave it untouched, `null` to clear it. */
|
|
3545
4048
|
async setProjectMetadata(t, e) {
|
|
3546
4049
|
const o = await this._auth.authenticatedFetch(
|
|
3547
|
-
`${this._gatewayUrl}${
|
|
4050
|
+
`${this._gatewayUrl}${qr(t)}`,
|
|
3548
4051
|
{
|
|
3549
4052
|
method: "PUT",
|
|
3550
4053
|
headers: { "Content-Type": "application/json" },
|
|
@@ -3557,14 +4060,14 @@ class te {
|
|
|
3557
4060
|
}
|
|
3558
4061
|
}
|
|
3559
4062
|
}
|
|
3560
|
-
class
|
|
4063
|
+
class he {
|
|
3561
4064
|
constructor(t, e, o, r) {
|
|
3562
|
-
this._auth = t, this._gatewayUrl = r, this._functions =
|
|
4065
|
+
this._auth = t, this._gatewayUrl = r, this._functions = Ro(e, Fo), o && Ao(this._functions, "localhost", 5001);
|
|
3563
4066
|
}
|
|
3564
4067
|
_auth;
|
|
3565
4068
|
_gatewayUrl;
|
|
3566
4069
|
_functions;
|
|
3567
|
-
_orgCredits = new
|
|
4070
|
+
_orgCredits = new T(void 0);
|
|
3568
4071
|
/**
|
|
3569
4072
|
* Reactive view of the last-fetched org credit pool. Updated automatically
|
|
3570
4073
|
* by `getOrgCredits()` and by the sync layer after every `previewSync`/
|
|
@@ -3586,13 +4089,13 @@ class ee {
|
|
|
3586
4089
|
}
|
|
3587
4090
|
/** Whether the current user has an active API key. */
|
|
3588
4091
|
async hasAPIKey() {
|
|
3589
|
-
return await this._fetch(
|
|
4092
|
+
return await this._fetch(Ft) !== null;
|
|
3590
4093
|
}
|
|
3591
4094
|
/** Returns the sign-in methods registered for the current user's email. */
|
|
3592
4095
|
async getSignInMethods() {
|
|
3593
4096
|
const t = this._auth.currentUser;
|
|
3594
4097
|
if (!t?.email) throw new Error("User has no e-mail");
|
|
3595
|
-
return
|
|
4098
|
+
return _o(this._auth.firebaseAuth, t.email);
|
|
3596
4099
|
}
|
|
3597
4100
|
/** Builds a human-readable label from a Firebase UserInfo provider entry. */
|
|
3598
4101
|
buildProviderLabel(t) {
|
|
@@ -3605,42 +4108,42 @@ class ee {
|
|
|
3605
4108
|
}
|
|
3606
4109
|
/** Links a Google or Microsoft provider to the current account via popup. Returns the new provider label. */
|
|
3607
4110
|
async linkProvider(t) {
|
|
3608
|
-
const e = this._requireUser(), o = t === "google.com" ? new
|
|
4111
|
+
const e = this._requireUser(), o = t === "google.com" ? new mt() : new wt(t), a = (await vo(e, o)).user.providerData.find(
|
|
3609
4112
|
(i) => i.providerId === t
|
|
3610
4113
|
);
|
|
3611
4114
|
return a ? this.buildProviderLabel(a) : "-";
|
|
3612
4115
|
}
|
|
3613
4116
|
/** Unlinks a provider from the current account. */
|
|
3614
4117
|
async unlinkProvider(t) {
|
|
3615
|
-
await
|
|
4118
|
+
await Eo(this._requireUser(), t);
|
|
3616
4119
|
}
|
|
3617
4120
|
/** Changes the password. Reauthenticates first. */
|
|
3618
4121
|
async updatePassword(t, e) {
|
|
3619
4122
|
const o = this._requireUser();
|
|
3620
4123
|
if (!o.email) throw new Error("User has no e-mail");
|
|
3621
|
-
await
|
|
4124
|
+
await $t(
|
|
3622
4125
|
o,
|
|
3623
|
-
|
|
3624
|
-
), await
|
|
4126
|
+
rt.credential(o.email, t)
|
|
4127
|
+
), await To(o, e);
|
|
3625
4128
|
}
|
|
3626
4129
|
/** Adds (sets) a password for an account that currently only uses SSO. */
|
|
3627
4130
|
async addPassword(t) {
|
|
3628
4131
|
const e = this._requireUser();
|
|
3629
4132
|
if (!e.email) throw new Error("User has no e-mail");
|
|
3630
|
-
await
|
|
4133
|
+
await So(e, rt.credential(e.email, t));
|
|
3631
4134
|
}
|
|
3632
4135
|
/** Requests an e-mail change. Sends a verification e-mail to the new address. */
|
|
3633
4136
|
async updateEmail(t, e) {
|
|
3634
4137
|
const o = this._requireUser();
|
|
3635
4138
|
if (!o.email) throw new Error("User e-mail not available");
|
|
3636
|
-
await
|
|
4139
|
+
await $t(
|
|
3637
4140
|
o,
|
|
3638
|
-
|
|
3639
|
-
), await
|
|
4141
|
+
rt.credential(o.email, e)
|
|
4142
|
+
), await Co(o, t), await ko(o);
|
|
3640
4143
|
}
|
|
3641
4144
|
/** Creates a new API key for the current user. */
|
|
3642
4145
|
async createAPIKey(t) {
|
|
3643
|
-
return this._fetch(
|
|
4146
|
+
return this._fetch(zt, {
|
|
3644
4147
|
method: "POST",
|
|
3645
4148
|
headers: { "Content-Type": "application/json" },
|
|
3646
4149
|
body: JSON.stringify({ expiration: t })
|
|
@@ -3649,7 +4152,7 @@ class ee {
|
|
|
3649
4152
|
/** Revokes the current user's API key. */
|
|
3650
4153
|
async revokeAPIKey() {
|
|
3651
4154
|
const t = await this._auth.authenticatedFetch(
|
|
3652
|
-
this._url(
|
|
4155
|
+
this._url(zt),
|
|
3653
4156
|
{ method: "DELETE" }
|
|
3654
4157
|
);
|
|
3655
4158
|
if (!t.ok)
|
|
@@ -3657,25 +4160,25 @@ class ee {
|
|
|
3657
4160
|
}
|
|
3658
4161
|
/** Fetches the current user's existing API key. */
|
|
3659
4162
|
async requestAPIKey() {
|
|
3660
|
-
const t = await this._fetch(
|
|
4163
|
+
const t = await this._fetch(Ft);
|
|
3661
4164
|
if (!t) throw new Error("No API key found");
|
|
3662
4165
|
return t;
|
|
3663
4166
|
}
|
|
3664
4167
|
/** Returns organizations the current user is a member of. */
|
|
3665
4168
|
async listOrganizations() {
|
|
3666
|
-
return this._fetch(
|
|
4169
|
+
return this._fetch(Bo);
|
|
3667
4170
|
}
|
|
3668
4171
|
/** Returns all members of the given organisation. Caller must be an org admin or superadmin. */
|
|
3669
4172
|
async getOrgMembers(t) {
|
|
3670
|
-
return this._fetch(
|
|
4173
|
+
return this._fetch(Vo(t));
|
|
3671
4174
|
}
|
|
3672
4175
|
/** Returns just the given organisation's admins. Caller must be a member (or admin/superadmin). */
|
|
3673
4176
|
async getOrgAdmins(t) {
|
|
3674
|
-
return this._fetch(
|
|
4177
|
+
return this._fetch(Xo(t));
|
|
3675
4178
|
}
|
|
3676
4179
|
/** Adds a new member to the organisation. Caller must be an org admin or superadmin. */
|
|
3677
4180
|
async addOrgMember(t, e) {
|
|
3678
|
-
await this._fetch(
|
|
4181
|
+
await this._fetch(pr(t), {
|
|
3679
4182
|
method: "POST",
|
|
3680
4183
|
headers: { "Content-Type": "application/json" },
|
|
3681
4184
|
body: JSON.stringify(e)
|
|
@@ -3683,7 +4186,7 @@ class ee {
|
|
|
3683
4186
|
}
|
|
3684
4187
|
/** Changes an existing member's role within the organisation. Caller must be an org admin or superadmin. */
|
|
3685
4188
|
async setOrgUserRole(t, e, o) {
|
|
3686
|
-
await this._fetch(
|
|
4189
|
+
await this._fetch(cr(t, e), {
|
|
3687
4190
|
method: "PUT",
|
|
3688
4191
|
headers: { "Content-Type": "application/json" },
|
|
3689
4192
|
body: JSON.stringify({ role: o })
|
|
@@ -3691,7 +4194,7 @@ class ee {
|
|
|
3691
4194
|
}
|
|
3692
4195
|
/** Removes a member from the organisation, optionally also removing them from every project they belong to. Caller must be an org admin or superadmin. */
|
|
3693
4196
|
async removeOrgMember(t, e, o) {
|
|
3694
|
-
await this._fetch(
|
|
4197
|
+
await this._fetch(lr(t, e), {
|
|
3695
4198
|
method: "DELETE",
|
|
3696
4199
|
headers: { "Content-Type": "application/json" },
|
|
3697
4200
|
body: JSON.stringify({ removeFromProjects: o })
|
|
@@ -3708,7 +4211,7 @@ class ee {
|
|
|
3708
4211
|
* and accept that the call then takes as long as the computation does.
|
|
3709
4212
|
*/
|
|
3710
4213
|
async getOrgCredits(t, e) {
|
|
3711
|
-
const o = e?.refresh ? `${
|
|
4214
|
+
const o = e?.refresh ? `${Bt(t)}?refresh=true` : Bt(t), r = await this._fetch(o);
|
|
3712
4215
|
return this._orgCredits.set(r), r;
|
|
3713
4216
|
}
|
|
3714
4217
|
/**
|
|
@@ -3717,7 +4220,7 @@ class ee {
|
|
|
3717
4220
|
* or superadmin.
|
|
3718
4221
|
*/
|
|
3719
4222
|
async getOrgConsumptionReport(t) {
|
|
3720
|
-
return this._fetch(
|
|
4223
|
+
return this._fetch(Ko(t));
|
|
3721
4224
|
}
|
|
3722
4225
|
/**
|
|
3723
4226
|
* Per-file-extension credit/unit breakdown for one project within `[from, to)` (UTC ISO 8601,
|
|
@@ -3730,7 +4233,7 @@ class ee {
|
|
|
3730
4233
|
async getProjectFileTypeBreakdown(t, e, o, r) {
|
|
3731
4234
|
const a = new URLSearchParams({ from: o, to: r });
|
|
3732
4235
|
return this._fetch(
|
|
3733
|
-
`${
|
|
4236
|
+
`${Yo(t, e)}?${a}`
|
|
3734
4237
|
);
|
|
3735
4238
|
}
|
|
3736
4239
|
/**
|
|
@@ -3743,7 +4246,7 @@ class ee {
|
|
|
3743
4246
|
*/
|
|
3744
4247
|
async getProjectTrafficReport(t, e, o, r) {
|
|
3745
4248
|
return this._fetch(
|
|
3746
|
-
`${
|
|
4249
|
+
`${Qo(t, e)}${this._rangeQuery(o, r)}`
|
|
3747
4250
|
);
|
|
3748
4251
|
}
|
|
3749
4252
|
/**
|
|
@@ -3753,7 +4256,7 @@ class ee {
|
|
|
3753
4256
|
*/
|
|
3754
4257
|
async getProjectUsageReport(t, e, o, r) {
|
|
3755
4258
|
return this._fetch(
|
|
3756
|
-
`${
|
|
4259
|
+
`${Jo(t, e)}${this._rangeQuery(o, r)}`
|
|
3757
4260
|
);
|
|
3758
4261
|
}
|
|
3759
4262
|
/** `?from=…&to=…`, or `''` when unbounded — the backend treats missing bounds as "everything". */
|
|
@@ -3765,7 +4268,7 @@ class ee {
|
|
|
3765
4268
|
}
|
|
3766
4269
|
/** Manual/support credit grant to an organisation's shared pool. Superadmins only — org admins self-serve via `startOrgCheckout`. */
|
|
3767
4270
|
async topUpOrgCredits(t, e) {
|
|
3768
|
-
await this._fetch(
|
|
4271
|
+
await this._fetch(sr(t), {
|
|
3769
4272
|
method: "POST",
|
|
3770
4273
|
headers: { "Content-Type": "application/json" },
|
|
3771
4274
|
body: JSON.stringify({ amount: e })
|
|
@@ -3781,7 +4284,7 @@ class ee {
|
|
|
3781
4284
|
* granted by the backend webhook once payment completes.
|
|
3782
4285
|
*/
|
|
3783
4286
|
async startOrgCheckout(t, e) {
|
|
3784
|
-
return this._fetch(
|
|
4287
|
+
return this._fetch(ir(t), {
|
|
3785
4288
|
method: "POST",
|
|
3786
4289
|
headers: { "Content-Type": "application/json" },
|
|
3787
4290
|
body: JSON.stringify({ credits: e })
|
|
@@ -3793,7 +4296,7 @@ class ee {
|
|
|
3793
4296
|
* an org admin; requires the org to have a Stripe customer.
|
|
3794
4297
|
*/
|
|
3795
4298
|
async startOrgBillingPortal(t) {
|
|
3796
|
-
return this._fetch(
|
|
4299
|
+
return this._fetch(nr(t), { method: "POST" });
|
|
3797
4300
|
}
|
|
3798
4301
|
/**
|
|
3799
4302
|
* Change an organisation's plan — freemium → custom (first paid plan), or
|
|
@@ -3806,7 +4309,7 @@ class ee {
|
|
|
3806
4309
|
* {@link startOrgBillingPortal} instead — this throws if called on one.
|
|
3807
4310
|
*/
|
|
3808
4311
|
async changeOrgPlan(t, e) {
|
|
3809
|
-
return this._fetch(
|
|
4312
|
+
return this._fetch(ar(t), {
|
|
3810
4313
|
method: "POST",
|
|
3811
4314
|
headers: { "Content-Type": "application/json" },
|
|
3812
4315
|
body: JSON.stringify(e)
|
|
@@ -3822,11 +4325,11 @@ class ee {
|
|
|
3822
4325
|
* Uses the `getUserInfo` Firebase callable function.
|
|
3823
4326
|
*/
|
|
3824
4327
|
async getUserInfo(t) {
|
|
3825
|
-
return (await
|
|
4328
|
+
return (await Oo(this._functions, "getUserInfo")({ uids: t })).data;
|
|
3826
4329
|
}
|
|
3827
4330
|
/** Record that the current user has accepted the terms of service. Sets a `terms` custom claim on the token. */
|
|
3828
4331
|
async acceptTerms(t) {
|
|
3829
|
-
await this._fetch(
|
|
4332
|
+
await this._fetch(Go, {
|
|
3830
4333
|
method: "POST",
|
|
3831
4334
|
headers: { "Content-Type": "application/json" },
|
|
3832
4335
|
body: JSON.stringify({ version: t })
|
|
@@ -3840,7 +4343,7 @@ class ee {
|
|
|
3840
4343
|
*/
|
|
3841
4344
|
async latestTermsAccepted() {
|
|
3842
4345
|
const t = this._auth.currentUser;
|
|
3843
|
-
return t ? (await
|
|
4346
|
+
return t ? (await J(t)).claims.terms ?? null : null;
|
|
3844
4347
|
}
|
|
3845
4348
|
/**
|
|
3846
4349
|
* Record that the current user has been shown (and dismissed) the usage-analytics
|
|
@@ -3848,7 +4351,7 @@ class ee {
|
|
|
3848
4351
|
* `terms`, since this is a lightweight acknowledgement, not a blocking agreement.
|
|
3849
4352
|
*/
|
|
3850
4353
|
async acceptAnalyticsNotice(t) {
|
|
3851
|
-
await this._fetch(
|
|
4354
|
+
await this._fetch(Ho, {
|
|
3852
4355
|
method: "POST",
|
|
3853
4356
|
headers: { "Content-Type": "application/json" },
|
|
3854
4357
|
body: JSON.stringify({ version: t })
|
|
@@ -3863,10 +4366,10 @@ class ee {
|
|
|
3863
4366
|
*/
|
|
3864
4367
|
async latestAnalyticsNoticeAccepted() {
|
|
3865
4368
|
const t = this._auth.currentUser;
|
|
3866
|
-
return t ? (await
|
|
4369
|
+
return t ? (await J(t)).claims.analyticsNotice ?? null : null;
|
|
3867
4370
|
}
|
|
3868
4371
|
}
|
|
3869
|
-
class
|
|
4372
|
+
class de {
|
|
3870
4373
|
constructor(t, e) {
|
|
3871
4374
|
this._auth = t, this._gatewayUrl = e;
|
|
3872
4375
|
}
|
|
@@ -3879,14 +4382,14 @@ class oe {
|
|
|
3879
4382
|
* break navigation; failures are only logged.
|
|
3880
4383
|
*/
|
|
3881
4384
|
recordView(t, e) {
|
|
3882
|
-
this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
4385
|
+
this._auth.authenticatedFetch(`${this._gatewayUrl}${Wo}`, {
|
|
3883
4386
|
method: "POST",
|
|
3884
4387
|
headers: { "Content-Type": "application/json" },
|
|
3885
4388
|
body: JSON.stringify({ view: t, projectId: e })
|
|
3886
4389
|
}).catch((o) => console.warn("Failed to record usage view", o));
|
|
3887
4390
|
}
|
|
3888
4391
|
}
|
|
3889
|
-
class
|
|
4392
|
+
class ue {
|
|
3890
4393
|
constructor(t, e) {
|
|
3891
4394
|
this._auth = t, this._gatewayUrl = e;
|
|
3892
4395
|
}
|
|
@@ -3905,11 +4408,11 @@ class re {
|
|
|
3905
4408
|
}
|
|
3906
4409
|
/** Matches organisations on name, id or any alternative id. */
|
|
3907
4410
|
searchOrganizations(t) {
|
|
3908
|
-
return this._search(
|
|
4411
|
+
return this._search(dr, t);
|
|
3909
4412
|
}
|
|
3910
4413
|
/** Matches users on display name, e-mail, or an exact uid. */
|
|
3911
4414
|
searchUsers(t) {
|
|
3912
|
-
return this._search(
|
|
4415
|
+
return this._search(mr, t);
|
|
3913
4416
|
}
|
|
3914
4417
|
/**
|
|
3915
4418
|
* Matches projects on name, id or any alternative id, across every organisation.
|
|
@@ -3917,18 +4420,18 @@ class re {
|
|
|
3917
4420
|
*/
|
|
3918
4421
|
searchProjects(t, e = !1) {
|
|
3919
4422
|
return this._search(
|
|
3920
|
-
|
|
4423
|
+
gr,
|
|
3921
4424
|
t,
|
|
3922
4425
|
e ? { includeDeleted: "true" } : void 0
|
|
3923
4426
|
);
|
|
3924
4427
|
}
|
|
3925
4428
|
/** Full profile for one user: auth record, orgs and projects they belong to. */
|
|
3926
4429
|
getUserDetail(t) {
|
|
3927
|
-
return this._fetch(
|
|
4430
|
+
return this._fetch(wr(t));
|
|
3928
4431
|
}
|
|
3929
4432
|
/** Every organisation on the platform. Unpaginated — prefer `searchOrganizations`. */
|
|
3930
4433
|
listOrganizations() {
|
|
3931
|
-
return this._fetch(
|
|
4434
|
+
return this._fetch(hr);
|
|
3932
4435
|
}
|
|
3933
4436
|
/**
|
|
3934
4437
|
* Every project owned by `orgId`, regardless of the caller's membership.
|
|
@@ -3936,11 +4439,11 @@ class re {
|
|
|
3936
4439
|
* membership) this is what lets a superadmin open a foreign org's projects.
|
|
3937
4440
|
*/
|
|
3938
4441
|
listOrgProjects(t) {
|
|
3939
|
-
return this._fetch(
|
|
4442
|
+
return this._fetch(ur(t));
|
|
3940
4443
|
}
|
|
3941
4444
|
/** Every user holding the `superadmin` custom claim. */
|
|
3942
4445
|
listSuperadmins() {
|
|
3943
|
-
return this._fetch(
|
|
4446
|
+
return this._fetch(fr);
|
|
3944
4447
|
}
|
|
3945
4448
|
/**
|
|
3946
4449
|
* Deletes the Auth account and profile doc, and scrubs every org/project
|
|
@@ -3949,22 +4452,22 @@ class re {
|
|
|
3949
4452
|
* teardown, not normal superadmin use, since a hard delete cannot be undone.
|
|
3950
4453
|
*/
|
|
3951
4454
|
deleteUser(t, e = !1) {
|
|
3952
|
-
return this._fetch(`${
|
|
4455
|
+
return this._fetch(`${br(t)}${e ? "?hard=true" : ""}`, { method: "DELETE" });
|
|
3953
4456
|
}
|
|
3954
4457
|
/**
|
|
3955
4458
|
* Undoes `deleteUser`: recreates the Auth account (same uid) and profile doc,
|
|
3956
4459
|
* and re-grants the recorded org/project roles where those still exist.
|
|
3957
4460
|
*/
|
|
3958
4461
|
restoreUser(t) {
|
|
3959
|
-
return this._fetch(
|
|
4462
|
+
return this._fetch(_r(t), { method: "POST" });
|
|
3960
4463
|
}
|
|
3961
4464
|
/** Every archived deletion, restored or not — newest first. */
|
|
3962
4465
|
listDeletedUsers() {
|
|
3963
|
-
return this._fetch(
|
|
4466
|
+
return this._fetch(yr);
|
|
3964
4467
|
}
|
|
3965
4468
|
/** Creates a Firebase Auth account with no organisation — for picking as a new org's initial admin. */
|
|
3966
4469
|
createAdminUser(t) {
|
|
3967
|
-
return this._fetch(
|
|
4470
|
+
return this._fetch(vr, {
|
|
3968
4471
|
method: "POST",
|
|
3969
4472
|
headers: { "Content-Type": "application/json" },
|
|
3970
4473
|
body: JSON.stringify(t)
|
|
@@ -3972,15 +4475,15 @@ class re {
|
|
|
3972
4475
|
}
|
|
3973
4476
|
/** Grants the `superadmin` custom claim. The user must sign in again for it to take effect. */
|
|
3974
4477
|
grantSuperadmin(t) {
|
|
3975
|
-
return this._fetch(
|
|
4478
|
+
return this._fetch(Ht(t), { method: "PUT" });
|
|
3976
4479
|
}
|
|
3977
4480
|
/** Revokes the `superadmin` custom claim. */
|
|
3978
4481
|
revokeSuperadmin(t) {
|
|
3979
|
-
return this._fetch(
|
|
4482
|
+
return this._fetch(Ht(t), { method: "DELETE" });
|
|
3980
4483
|
}
|
|
3981
4484
|
/** Creates a new organisation with `adminUserId` as its sole admin/member. */
|
|
3982
4485
|
createOrganization(t) {
|
|
3983
|
-
return this._fetch(
|
|
4486
|
+
return this._fetch(Er, {
|
|
3984
4487
|
method: "POST",
|
|
3985
4488
|
headers: { "Content-Type": "application/json" },
|
|
3986
4489
|
body: JSON.stringify(t)
|
|
@@ -3988,7 +4491,7 @@ class re {
|
|
|
3988
4491
|
}
|
|
3989
4492
|
/** Sets an organisation's allowed email domains for auto-join sign-up. */
|
|
3990
4493
|
setOrgDomains(t, e) {
|
|
3991
|
-
return this._fetch(
|
|
4494
|
+
return this._fetch(Cr(t), {
|
|
3992
4495
|
method: "PUT",
|
|
3993
4496
|
headers: { "Content-Type": "application/json" },
|
|
3994
4497
|
body: JSON.stringify({ domains: e })
|
|
@@ -4002,42 +4505,42 @@ class re {
|
|
|
4002
4505
|
* snapshot, same as a direct `deleteUser`).
|
|
4003
4506
|
*/
|
|
4004
4507
|
deleteOrganization(t) {
|
|
4005
|
-
return this._fetch(
|
|
4508
|
+
return this._fetch(Tr(t), { method: "DELETE" });
|
|
4006
4509
|
}
|
|
4007
4510
|
/** Undoes `deleteOrganization`: restores cascaded projects/users where they still can be, then un-flags the org. */
|
|
4008
4511
|
restoreOrganization(t) {
|
|
4009
|
-
return this._fetch(
|
|
4512
|
+
return this._fetch(Sr(t), { method: "POST" });
|
|
4010
4513
|
}
|
|
4011
4514
|
/** Every soft-deleted organisation, restored or not — newest first. */
|
|
4012
4515
|
listDeletedOrganizations() {
|
|
4013
|
-
return this._fetch(
|
|
4516
|
+
return this._fetch(kr);
|
|
4014
4517
|
}
|
|
4015
4518
|
/** Users belonging to no organisation — a data-health diagnostic, not paginated. */
|
|
4016
4519
|
listUsersWithoutOrg() {
|
|
4017
|
-
return this._fetch(
|
|
4520
|
+
return this._fetch(Ir);
|
|
4018
4521
|
}
|
|
4019
4522
|
/** Users belonging to no project — a data-health diagnostic, not paginated. */
|
|
4020
4523
|
listUsersWithoutProject() {
|
|
4021
|
-
return this._fetch(
|
|
4524
|
+
return this._fetch(xr);
|
|
4022
4525
|
}
|
|
4023
4526
|
/** Projects with no members, syncers, or admins — a data-health diagnostic. */
|
|
4024
4527
|
listProjectsWithoutUsers() {
|
|
4025
|
-
return this._fetch(
|
|
4528
|
+
return this._fetch(Rr);
|
|
4026
4529
|
}
|
|
4027
4530
|
/** Projects with no admin (may still have members/syncers) — a data-health diagnostic. */
|
|
4028
4531
|
listProjectsWithoutAdmins() {
|
|
4029
|
-
return this._fetch(
|
|
4532
|
+
return this._fetch(Ar);
|
|
4030
4533
|
}
|
|
4031
4534
|
/** Organisations with no members — a data-health diagnostic. */
|
|
4032
4535
|
listOrgsWithoutUsers() {
|
|
4033
|
-
return this._fetch(
|
|
4536
|
+
return this._fetch(Or);
|
|
4034
4537
|
}
|
|
4035
4538
|
/** Organisations with no admin (may still have members) — a data-health diagnostic. */
|
|
4036
4539
|
listOrgsWithoutAdmins() {
|
|
4037
|
-
return this._fetch(
|
|
4540
|
+
return this._fetch($r);
|
|
4038
4541
|
}
|
|
4039
4542
|
}
|
|
4040
|
-
const
|
|
4543
|
+
const ge = ["superadmin", "admin", "syncer", "member"], me = {
|
|
4041
4544
|
createEntities: "admin",
|
|
4042
4545
|
createProvider: "superadmin",
|
|
4043
4546
|
changeContentCategories: "syncer",
|
|
@@ -4061,7 +4564,7 @@ const se = ["superadmin", "admin", "syncer", "member"], ae = {
|
|
|
4061
4564
|
viewUsageStats: "superadmin",
|
|
4062
4565
|
viewEntities: "member"
|
|
4063
4566
|
};
|
|
4064
|
-
function
|
|
4567
|
+
function $a() {
|
|
4065
4568
|
return {
|
|
4066
4569
|
changeContentCategories: !1,
|
|
4067
4570
|
createEntities: !1,
|
|
@@ -4088,9 +4591,9 @@ function aa() {
|
|
|
4088
4591
|
viewEntities: !1
|
|
4089
4592
|
};
|
|
4090
4593
|
}
|
|
4091
|
-
class
|
|
4594
|
+
class we {
|
|
4092
4595
|
constructor(t) {
|
|
4093
|
-
this._isSuperAdmin = t, this._projectRoles = new
|
|
4596
|
+
this._isSuperAdmin = t, this._projectRoles = new T([]), this._orgRole = new T(null), this.privileges = Tt(
|
|
4094
4597
|
[this._projectRoles, this._orgRole, t],
|
|
4095
4598
|
() => this._compute()
|
|
4096
4599
|
);
|
|
@@ -4127,17 +4630,17 @@ class ie {
|
|
|
4127
4630
|
_expand(t) {
|
|
4128
4631
|
if (this._isSuperAdmin.get())
|
|
4129
4632
|
return ["superadmin", "admin", "syncer", "member"];
|
|
4130
|
-
const e =
|
|
4131
|
-
return e === -1 ? [] : Array.from(
|
|
4633
|
+
const e = ge.findIndex((o) => t.includes(o));
|
|
4634
|
+
return e === -1 ? [] : Array.from(ge.slice(e));
|
|
4132
4635
|
}
|
|
4133
4636
|
_compute() {
|
|
4134
|
-
const t = this._projectRoles.get(), e = this._isSuperAdmin.get(), o =
|
|
4135
|
-
for (const r of Object.keys(
|
|
4136
|
-
o[r] = t.includes(
|
|
4637
|
+
const t = this._projectRoles.get(), e = this._isSuperAdmin.get(), o = $a();
|
|
4638
|
+
for (const r of Object.keys(me))
|
|
4639
|
+
o[r] = t.includes(me[r]);
|
|
4137
4640
|
return o.createProject = e || this._orgRole.get() === "admin", o;
|
|
4138
4641
|
}
|
|
4139
4642
|
}
|
|
4140
|
-
class
|
|
4643
|
+
class fe {
|
|
4141
4644
|
constructor(t) {
|
|
4142
4645
|
this._storage = t;
|
|
4143
4646
|
}
|
|
@@ -4170,19 +4673,19 @@ class ne {
|
|
|
4170
4673
|
// ── Internal helpers ───────────────────────────────────────────────────────
|
|
4171
4674
|
async _get(t, e) {
|
|
4172
4675
|
try {
|
|
4173
|
-
const r = await (await
|
|
4676
|
+
const r = await (await De(S(this._storage, `${t}/${e}.json.gz`))).arrayBuffer(), a = new DecompressionStream("gzip"), i = a.writable.getWriter(), n = a.readable.getReader();
|
|
4174
4677
|
i.write(new Uint8Array(r)), i.close();
|
|
4175
4678
|
const p = [];
|
|
4176
4679
|
let c = await n.read();
|
|
4177
4680
|
for (; !c.done; )
|
|
4178
4681
|
p.push(c.value), c = await n.read();
|
|
4179
|
-
const h = p.reduce((
|
|
4682
|
+
const h = p.reduce((w, m) => w + m.length, 0), d = new Uint8Array(h);
|
|
4180
4683
|
let u = 0;
|
|
4181
|
-
for (const
|
|
4182
|
-
d.set(
|
|
4684
|
+
for (const w of p)
|
|
4685
|
+
d.set(w, u), u += w.length;
|
|
4183
4686
|
return JSON.parse(new TextDecoder().decode(d));
|
|
4184
4687
|
} catch (o) {
|
|
4185
|
-
if (
|
|
4688
|
+
if (Pa(o)) return;
|
|
4186
4689
|
throw o;
|
|
4187
4690
|
}
|
|
4188
4691
|
}
|
|
@@ -4193,22 +4696,22 @@ class ne {
|
|
|
4193
4696
|
let c = await n.read();
|
|
4194
4697
|
for (; !c.done; )
|
|
4195
4698
|
p.push(c.value), c = await n.read();
|
|
4196
|
-
const h = p.reduce((
|
|
4699
|
+
const h = p.reduce((w, m) => w + m.length, 0), d = new Uint8Array(h);
|
|
4197
4700
|
let u = 0;
|
|
4198
|
-
for (const
|
|
4199
|
-
d.set(
|
|
4200
|
-
await
|
|
4201
|
-
|
|
4701
|
+
for (const w of p)
|
|
4702
|
+
d.set(w, u), u += w.length;
|
|
4703
|
+
await gt(
|
|
4704
|
+
S(this._storage, `${t}/${e}.json.gz`),
|
|
4202
4705
|
d,
|
|
4203
4706
|
{ contentType: "application/gzip" }
|
|
4204
4707
|
);
|
|
4205
4708
|
}
|
|
4206
4709
|
}
|
|
4207
|
-
function
|
|
4710
|
+
function Pa(s) {
|
|
4208
4711
|
return typeof s == "object" && s !== null && "code" in s && s.code === "storage/object-not-found";
|
|
4209
4712
|
}
|
|
4210
|
-
const
|
|
4211
|
-
class
|
|
4713
|
+
const ii = ["CHF", "DKK", "EUR"], ni = "CHF", Da = 3600 * 1e3, Na = "https://api.frankfurter.dev/v1/latest?from=CHF&to=DKK,EUR";
|
|
4714
|
+
class ye {
|
|
4212
4715
|
_cached = null;
|
|
4213
4716
|
_pending = null;
|
|
4214
4717
|
/**
|
|
@@ -4218,7 +4721,7 @@ class pe {
|
|
|
4218
4721
|
* throwing — a transient network blip shouldn't break the pricing UI.
|
|
4219
4722
|
*/
|
|
4220
4723
|
async getRates(t = !1) {
|
|
4221
|
-
return !t && this._cached && Date.now() - this._cached.fetchedAt <
|
|
4724
|
+
return !t && this._cached && Date.now() - this._cached.fetchedAt < Da ? this._cached : this._pending ? this._pending : (this._pending = this._fetchRates().then((e) => (this._cached = e, e)).catch((e) => {
|
|
4222
4725
|
if (this._cached) return this._cached;
|
|
4223
4726
|
throw e;
|
|
4224
4727
|
}).finally(() => {
|
|
@@ -4226,7 +4729,7 @@ class pe {
|
|
|
4226
4729
|
}), this._pending);
|
|
4227
4730
|
}
|
|
4228
4731
|
async _fetchRates() {
|
|
4229
|
-
const t = await fetch(
|
|
4732
|
+
const t = await fetch(Na);
|
|
4230
4733
|
if (!t.ok)
|
|
4231
4734
|
throw new Error(`Failed to fetch exchange rates: ${t.status} ${t.statusText}`);
|
|
4232
4735
|
const e = await t.json();
|
|
@@ -4245,7 +4748,7 @@ class pe {
|
|
|
4245
4748
|
return t / o.rates[e];
|
|
4246
4749
|
}
|
|
4247
4750
|
}
|
|
4248
|
-
const
|
|
4751
|
+
const b = {
|
|
4249
4752
|
qcy: "https://dev.qaecy.com/ont#",
|
|
4250
4753
|
"qcy-e": "https://dev.qaecy.com/enum#",
|
|
4251
4754
|
"qcy-l": "https://dev.qaecy.com/logs#",
|
|
@@ -7493,12 +7996,12 @@ const y = {
|
|
|
7493
7996
|
fbsp: "http://purl.obolibrary.org/obo/FBSP_",
|
|
7494
7997
|
rex: "http://purl.obolibrary.org/obo/REX_"
|
|
7495
7998
|
};
|
|
7496
|
-
class
|
|
7999
|
+
class et {
|
|
7497
8000
|
static _instance;
|
|
7498
8001
|
// Opposite map is built once
|
|
7499
8002
|
_nsMap;
|
|
7500
8003
|
static getInstance() {
|
|
7501
|
-
return this._instance ? this._instance : (this._instance = new
|
|
8004
|
+
return this._instance ? this._instance : (this._instance = new et(), this._instance);
|
|
7502
8005
|
}
|
|
7503
8006
|
compactIRI(t) {
|
|
7504
8007
|
let e = this._nsMap;
|
|
@@ -7514,17 +8017,17 @@ class J {
|
|
|
7514
8017
|
return r === void 0 ? t : t.replace(o, `${r}:`);
|
|
7515
8018
|
}
|
|
7516
8019
|
expandIRI(t) {
|
|
7517
|
-
const e = t.split(":")[0], o = O[e] ??
|
|
8020
|
+
const e = t.split(":")[0], o = O[e] ?? b[e];
|
|
7518
8021
|
return t.replace(`${e}:`, o);
|
|
7519
8022
|
}
|
|
7520
8023
|
_buildNSMap() {
|
|
7521
8024
|
const t = {};
|
|
7522
|
-
return Object.keys(O).forEach((e) => t[O[e]] = e), Object.keys(
|
|
7523
|
-
(e) => t[
|
|
8025
|
+
return Object.keys(O).forEach((e) => t[O[e]] = e), Object.keys(b).forEach(
|
|
8026
|
+
(e) => t[b[e]] = e
|
|
7524
8027
|
), this._nsMap = t, t;
|
|
7525
8028
|
}
|
|
7526
8029
|
}
|
|
7527
|
-
const
|
|
8030
|
+
const be = `${b.qcy}ContentCategory`, _e = `${b.qcy}EntityCategory`, ve = `${b.qcy}relatedEntity`, ja = `PREFIX view: <https://qlever.cs.uni-freiburg.de/materializedView/>
|
|
7528
8031
|
SELECT ?iri ?type ?parent ?deprecated ?label ?definition
|
|
7529
8032
|
WHERE {
|
|
7530
8033
|
SERVICE view:schemas {
|
|
@@ -7536,9 +8039,9 @@ WHERE {
|
|
|
7536
8039
|
view:column-definition ?definition .
|
|
7537
8040
|
}
|
|
7538
8041
|
}`;
|
|
7539
|
-
class
|
|
8042
|
+
class La {
|
|
7540
8043
|
constructor(t, e, o, r, a) {
|
|
7541
|
-
this._api = t, this._projectId = e, this._graphType = r, this._verbose = a ?? !1, this._currentLang = o, this._api.setLanguage(o), this._contentCategories = new
|
|
8044
|
+
this._api = t, this._projectId = e, this._graphType = r, this._verbose = a ?? !1, this._currentLang = o, this._api.setLanguage(o), this._contentCategories = new T([]), this._entityCategories = new T([]), this._relationships = new T([]), this.availableContentCategories = this._contentCategories.asReadonly(), this.availableEntityCategories = this._entityCategories.asReadonly(), this.availableEntityRelationships = this._relationships.asReadonly(), this.ready = this._load().catch(
|
|
7542
8045
|
(i) => console.error("[CueProjectSchema] Initial load failed:", i)
|
|
7543
8046
|
);
|
|
7544
8047
|
}
|
|
@@ -7590,7 +8093,59 @@ class ua {
|
|
|
7590
8093
|
async refresh() {
|
|
7591
8094
|
this._snapshot = void 0, await this._load();
|
|
7592
8095
|
}
|
|
8096
|
+
/**
|
|
8097
|
+
* Creates a new content category via `cue.api.semanticTemplate` and, on success,
|
|
8098
|
+
* appends it to {@link availableContentCategories} in place — no `refresh()`
|
|
8099
|
+
* needed for it to show up in every subscriber.
|
|
8100
|
+
*/
|
|
8101
|
+
async createContentCategory(t) {
|
|
8102
|
+
const e = await this._api.semanticTemplate.createContentCategory(this._projectId, t);
|
|
8103
|
+
return this._appendCreated("contentCategories", this._contentCategories, be, t, e);
|
|
8104
|
+
}
|
|
8105
|
+
/**
|
|
8106
|
+
* Creates a new entity category via `cue.api.semanticTemplate` and, on success,
|
|
8107
|
+
* appends it to {@link availableEntityCategories} in place — no `refresh()`
|
|
8108
|
+
* needed for it to show up in every subscriber.
|
|
8109
|
+
*/
|
|
8110
|
+
async createEntityCategory(t) {
|
|
8111
|
+
const e = await this._api.semanticTemplate.createEntityCategory(this._projectId, t);
|
|
8112
|
+
return this._appendCreated("entityCategories", this._entityCategories, _e, t, e);
|
|
8113
|
+
}
|
|
8114
|
+
/**
|
|
8115
|
+
* Creates a new entity relationship via `cue.api.semanticTemplate` and, on
|
|
8116
|
+
* success, appends it to {@link availableEntityRelationships} in place — no
|
|
8117
|
+
* `refresh()` needed for it to show up in every subscriber.
|
|
8118
|
+
*/
|
|
8119
|
+
async createEntityRelationship(t) {
|
|
8120
|
+
const e = await this._api.semanticTemplate.createEntityRelationship(this._projectId, t);
|
|
8121
|
+
return this._appendCreated("relationships", this._relationships, ve, t, e);
|
|
8122
|
+
}
|
|
7593
8123
|
// ── Private helpers ─────────────────────────────────────────────────────────
|
|
8124
|
+
/**
|
|
8125
|
+
* Turns a successful create-mutation result into a {@link CategoryDef} and
|
|
8126
|
+
* appends it to both the cached language-independent snapshot and the live
|
|
8127
|
+
* signal. Updating `_snapshot` too (not just the signal) matters: it's what
|
|
8128
|
+
* `setLanguage()`/`_apply()` re-derive from, so skipping it would make the
|
|
8129
|
+
* appended item vanish on the next language switch. Returns `null` when the
|
|
8130
|
+
* mutation failed (no IRI was assigned).
|
|
8131
|
+
*/
|
|
8132
|
+
_appendCreated(t, e, o, r, a) {
|
|
8133
|
+
if (!a.success || !a.iri) return null;
|
|
8134
|
+
const i = r.label ? { ...r.label } : {};
|
|
8135
|
+
V(i);
|
|
8136
|
+
const n = r.definition ? { ...r.definition } : r.description ? { default: r.description } : {};
|
|
8137
|
+
V(n);
|
|
8138
|
+
const p = {
|
|
8139
|
+
iri: a.iri,
|
|
8140
|
+
type: o,
|
|
8141
|
+
labels: i,
|
|
8142
|
+
definitions: n,
|
|
8143
|
+
...r.parent ? { parent: r.parent } : {}
|
|
8144
|
+
};
|
|
8145
|
+
this._snapshot?.[t]?.push(p);
|
|
8146
|
+
const c = this._toDef(p, this._currentLang);
|
|
8147
|
+
return e.set([...e.get(), c]), c;
|
|
8148
|
+
}
|
|
7594
8149
|
async _load() {
|
|
7595
8150
|
if (this._snapshot) {
|
|
7596
8151
|
this._apply(this._snapshot);
|
|
@@ -7616,7 +8171,7 @@ class ua {
|
|
|
7616
8171
|
*/
|
|
7617
8172
|
async _fetchSnapshot() {
|
|
7618
8173
|
if (this._graphType !== "fuseki") {
|
|
7619
|
-
const e = await this._runSchemaQuery(
|
|
8174
|
+
const e = await this._runSchemaQuery(ja);
|
|
7620
8175
|
if (e.contentCategories.length + e.entityCategories.length + e.relationships.length > 0) return e;
|
|
7621
8176
|
console.warn(
|
|
7622
8177
|
`[CueProjectSchema] Materialized view "schemas" returned no rows for project ${this._projectId} — falling back to the live schema query.`
|
|
@@ -7636,7 +8191,7 @@ class ua {
|
|
|
7636
8191
|
}
|
|
7637
8192
|
/** Projects a language-independent {@link SchemaNode} into a {@link CategoryDef}. */
|
|
7638
8193
|
_toDef(t, e) {
|
|
7639
|
-
const o =
|
|
8194
|
+
const o = Te(t.labels, e) ?? t.iri.split("#").at(-1) ?? t.iri, r = Te(t.definitions, e), a = Object.keys(t.definitions).length > 0;
|
|
7640
8195
|
return {
|
|
7641
8196
|
iri: t.iri,
|
|
7642
8197
|
label: o,
|
|
@@ -7653,7 +8208,7 @@ class ua {
|
|
|
7653
8208
|
* language tags) so they can be grouped into {@link LangMap}s client-side.
|
|
7654
8209
|
*/
|
|
7655
8210
|
_buildSchemaQuery() {
|
|
7656
|
-
return `PREFIX qcy: <${
|
|
8211
|
+
return `PREFIX qcy: <${b.qcy}>
|
|
7657
8212
|
PREFIX skos: <${O.skos}>
|
|
7658
8213
|
PREFIX rdfs: <${O.rdfs}>
|
|
7659
8214
|
PREFIX owl: <${O.owl}>
|
|
@@ -7691,7 +8246,7 @@ WHERE {
|
|
|
7691
8246
|
let p = o.get(i);
|
|
7692
8247
|
p || (p = { iri: i, type: n, labels: {}, definitions: {} }, o.set(i, p)), p.parent === void 0 && a.parent?.value && (p.parent = a.parent.value);
|
|
7693
8248
|
const c = a.deprecated?.value;
|
|
7694
|
-
c !== void 0 && (p.deprecated = c === "true" || c === "1"),
|
|
8249
|
+
c !== void 0 && (p.deprecated = c === "true" || c === "1"), Ee(p.labels, a.label), Ee(p.definitions, a.definition);
|
|
7695
8250
|
}
|
|
7696
8251
|
const r = {
|
|
7697
8252
|
contentCategories: [],
|
|
@@ -7699,16 +8254,16 @@ WHERE {
|
|
|
7699
8254
|
relationships: []
|
|
7700
8255
|
};
|
|
7701
8256
|
for (const a of o.values())
|
|
7702
|
-
|
|
8257
|
+
V(a.labels), V(a.definitions), a.type === be ? r.contentCategories.push(a) : a.type === _e ? r.entityCategories.push(a) : a.type === ve && r.relationships.push(a);
|
|
7703
8258
|
return r;
|
|
7704
8259
|
}
|
|
7705
8260
|
}
|
|
7706
|
-
function
|
|
8261
|
+
function Ee(s, t) {
|
|
7707
8262
|
if (!t || t.value === void 0) return;
|
|
7708
8263
|
const e = t["xml:lang"], o = e && e.length > 0 ? e : "default";
|
|
7709
8264
|
s[o] === void 0 && (s[o] = t.value);
|
|
7710
8265
|
}
|
|
7711
|
-
function
|
|
8266
|
+
function V(s) {
|
|
7712
8267
|
if (s.en !== void 0) {
|
|
7713
8268
|
s.default = s.en;
|
|
7714
8269
|
return;
|
|
@@ -7717,12 +8272,12 @@ function le(s) {
|
|
|
7717
8272
|
const t = Object.values(s)[0];
|
|
7718
8273
|
t !== void 0 && (s.default = t);
|
|
7719
8274
|
}
|
|
7720
|
-
function
|
|
8275
|
+
function Te(s, t) {
|
|
7721
8276
|
return s[t] ?? s.default;
|
|
7722
8277
|
}
|
|
7723
|
-
const
|
|
7724
|
-
class
|
|
7725
|
-
constructor(t, e, o =
|
|
8278
|
+
const Ua = "https://qlever.dev/api/osm-planet";
|
|
8279
|
+
class Ve {
|
|
8280
|
+
constructor(t, e, o = St, r, a = !1) {
|
|
7726
8281
|
this._api = t, this._projectId = e, this._graphType = r, this._verbose = a, this.baseURL = `${o}${e}/`, this.entityInfoMap = this._entityInfoMapComputed, this.entityGraph = this._entityGraph.asReadonly(), this._entityOSMMap.subscribe(() => this._checkPendingOSMFetches()), this._fetchEntityGraph().catch(
|
|
7727
8282
|
(i) => console.error("[CueProjectEntities] Entity graph fetch failed:", i)
|
|
7728
8283
|
);
|
|
@@ -7734,17 +8289,17 @@ class Ne {
|
|
|
7734
8289
|
/** Full RDF base URL for this project, e.g. `https://cue.qaecy.com/r/{pid}/` */
|
|
7735
8290
|
baseURL;
|
|
7736
8291
|
// ── Internal writable slices ───────────────────────────────────────────────
|
|
7737
|
-
_entityDetails = new
|
|
7738
|
-
_entityDocuments = new
|
|
8292
|
+
_entityDetails = new T({});
|
|
8293
|
+
_entityDocuments = new T(
|
|
7739
8294
|
{}
|
|
7740
8295
|
);
|
|
7741
|
-
_entityRelationships = new
|
|
7742
|
-
_entityOSMMap = new
|
|
7743
|
-
_osmWKTMap = new
|
|
8296
|
+
_entityRelationships = new T({});
|
|
8297
|
+
_entityOSMMap = new T({});
|
|
8298
|
+
_osmWKTMap = new T({});
|
|
7744
8299
|
_fetchingOSMIds = /* @__PURE__ */ new Set();
|
|
7745
8300
|
/** Cumulative unique entity UUIDs ever passed to request methods (survives cache hits). */
|
|
7746
8301
|
_seenIds = /* @__PURE__ */ new Set();
|
|
7747
|
-
_entityGraph = new
|
|
8302
|
+
_entityGraph = new T(void 0);
|
|
7748
8303
|
/**
|
|
7749
8304
|
* Memoizes the raw category-summary rows per neighbourhood (keyed by the
|
|
7750
8305
|
* expanded `entityIRI`, or `''` for the full graph) so that repeat/concurrent
|
|
@@ -7760,7 +8315,7 @@ class Ne {
|
|
|
7760
8315
|
*/
|
|
7761
8316
|
_categoryCountsCache;
|
|
7762
8317
|
// ── Derived signals ────────────────────────────────────────────────────────
|
|
7763
|
-
_entityInfoMapComputed =
|
|
8318
|
+
_entityInfoMapComputed = Tt(
|
|
7764
8319
|
[
|
|
7765
8320
|
this._entityDetails,
|
|
7766
8321
|
this._entityDocuments,
|
|
@@ -7815,7 +8370,7 @@ class Ne {
|
|
|
7815
8370
|
);
|
|
7816
8371
|
if (o.length === 0) return;
|
|
7817
8372
|
this._log(`requestEntityData: ${o.length} new / ${t.length} requested | cumulative: ${this._seenIds.size} seen`);
|
|
7818
|
-
const r = o.map((i) => `r:${i}`).join(" "), a = `PREFIX qcy: <${
|
|
8373
|
+
const r = o.map((i) => `r:${i}`).join(" "), a = `PREFIX qcy: <${b.qcy}>
|
|
7819
8374
|
PREFIX r: <${this.baseURL}>
|
|
7820
8375
|
SELECT ?id (SAMPLE(?val) AS ?value) (GROUP_CONCAT(DISTINCT STR(?cat); SEPARATOR=";") AS ?categories) ?mentionCount
|
|
7821
8376
|
WHERE {
|
|
@@ -7861,7 +8416,7 @@ GROUP BY ?id ?mentionCount`;
|
|
|
7861
8416
|
const o = { ...this._entityOSMMap.get() };
|
|
7862
8417
|
for (const p of e) o[p] = { direct: [], indirect: [] };
|
|
7863
8418
|
this._entityOSMMap.set(o);
|
|
7864
|
-
const r = e.map((p) => `r:${p}`).join(" "), a = `PREFIX qcy: <${
|
|
8419
|
+
const r = e.map((p) => `r:${p}`).join(" "), a = `PREFIX qcy: <${b.qcy}>
|
|
7865
8420
|
PREFIX r: <${this.baseURL}>
|
|
7866
8421
|
SELECT ?id ?osm ?direct ?rels ?entityUUID
|
|
7867
8422
|
WHERE {
|
|
@@ -7895,8 +8450,8 @@ WHERE {
|
|
|
7895
8450
|
), n = { ...this._entityOSMMap.get() };
|
|
7896
8451
|
i.results.bindings.forEach((p) => {
|
|
7897
8452
|
if (!p.id || !p.osm) return;
|
|
7898
|
-
const c = p.id.value, h = p.osm.value, d = p.direct?.value === "true", u = p.rels?.value?.split(";").filter(Boolean) ?? [],
|
|
7899
|
-
d ?
|
|
8453
|
+
const c = p.id.value, h = p.osm.value, d = p.direct?.value === "true", u = p.rels?.value?.split(";").filter(Boolean) ?? [], w = p.entityUUID?.value, m = n[c] ?? { direct: [], indirect: [] };
|
|
8454
|
+
d ? m.direct.push(h) : w && m.indirect.push({ osm: h, viaRels: u, entityUUID: w }), n[c] = m;
|
|
7900
8455
|
}), this._entityOSMMap.set(n), this._log(`entityOSMMap: ${Object.keys(n).length} with OSM / ${this._seenIds.size} seen (cumulative)`);
|
|
7901
8456
|
}
|
|
7902
8457
|
/**
|
|
@@ -7932,7 +8487,7 @@ WHERE {
|
|
|
7932
8487
|
async fetchEntityDocuments(t) {
|
|
7933
8488
|
const e = t.replace(/^.*\/([^/]*)$/, "$1");
|
|
7934
8489
|
this._entityDocuments.set({ ...this._entityDocuments.get(), [e]: [] }), this._entityDetails.get()[e] === void 0 && this.requestEntityData([e]);
|
|
7935
|
-
const o = `PREFIX qcy: <${
|
|
8490
|
+
const o = `PREFIX qcy: <${b.qcy}>
|
|
7936
8491
|
SELECT DISTINCT ?id
|
|
7937
8492
|
WHERE {
|
|
7938
8493
|
BIND(<${t}> AS ?iri)
|
|
@@ -7952,7 +8507,7 @@ WHERE {
|
|
|
7952
8507
|
* falls back to an untagged label when no match is found.
|
|
7953
8508
|
*/
|
|
7954
8509
|
async contentCategoriesInProject(t = !0) {
|
|
7955
|
-
const e = this._api.language, o = `PREFIX qcy: <${
|
|
8510
|
+
const e = this._api.language, o = `PREFIX qcy: <${b.qcy}>
|
|
7956
8511
|
PREFIX skos: <${O.skos}>
|
|
7957
8512
|
SELECT ?iri (SAMPLE(?l) AS ?label) ?count
|
|
7958
8513
|
WHERE {
|
|
@@ -7978,7 +8533,7 @@ ORDER BY ${t ? "DESC(?count)" : "ASC(?label)"}`;
|
|
|
7978
8533
|
}
|
|
7979
8534
|
async entitiesByCategory(t, e = !1) {
|
|
7980
8535
|
if (t.length === 0) return [];
|
|
7981
|
-
const o =
|
|
8536
|
+
const o = et.getInstance(), r = (p) => p.startsWith("http://") || p.startsWith("https://") ? p : o.expandIRI(p), a = t.map((p) => `<${r(p)}>`).join(" "), i = e ? `PREFIX qcy: <${b.qcy}>
|
|
7982
8537
|
SELECT ?id (SAMPLE(?val) AS ?value) (GROUP_CONCAT(DISTINCT STR(?allCat); SEPARATOR=";") AS ?categories)
|
|
7983
8538
|
WHERE {
|
|
7984
8539
|
VALUES ?filterCat { ${a} }
|
|
@@ -7988,7 +8543,7 @@ WHERE {
|
|
|
7988
8543
|
qcy:hasEntityCategory ?allCat .
|
|
7989
8544
|
BIND(REPLACE(STR(?iri), "^.*/", "") AS ?id)
|
|
7990
8545
|
}
|
|
7991
|
-
GROUP BY ?id` : `PREFIX qcy: <${
|
|
8546
|
+
GROUP BY ?id` : `PREFIX qcy: <${b.qcy}>
|
|
7992
8547
|
SELECT DISTINCT ?id
|
|
7993
8548
|
WHERE {
|
|
7994
8549
|
VALUES ?filterCat { ${a} }
|
|
@@ -8010,7 +8565,7 @@ WHERE {
|
|
|
8010
8565
|
});
|
|
8011
8566
|
}
|
|
8012
8567
|
async buildSummaryGraph(t, e) {
|
|
8013
|
-
const o =
|
|
8568
|
+
const o = et.getInstance(), r = e ? e.includes("://") ? e : o.expandIRI(e) : void 0, a = r ? ` FILTER(?sourceCat = <${r}> || ?targetCat = <${r}>)` : "", i = `PREFIX qcy: <${b.qcy}>
|
|
8014
8569
|
SELECT
|
|
8015
8570
|
?sourceCat
|
|
8016
8571
|
?predicate
|
|
@@ -8035,20 +8590,20 @@ ORDER BY DESC(?weight)`, n = r ?? "";
|
|
|
8035
8590
|
);
|
|
8036
8591
|
if (t === "graph") {
|
|
8037
8592
|
const d = /* @__PURE__ */ new Set(), u = [];
|
|
8038
|
-
for (const
|
|
8039
|
-
const g =
|
|
8040
|
-
d.add(g), d.add(f), u.push({ sourceID: g, predicate:
|
|
8593
|
+
for (const m of h) {
|
|
8594
|
+
const g = m.sourceCat.value, y = m.predicate.value, f = m.targetCat.value, _ = parseInt(m.weight.value, 10);
|
|
8595
|
+
d.add(g), d.add(f), u.push({ sourceID: g, predicate: y, targetID: f, weight: _ });
|
|
8041
8596
|
}
|
|
8042
|
-
let
|
|
8597
|
+
let w;
|
|
8043
8598
|
try {
|
|
8044
|
-
|
|
8045
|
-
} catch (
|
|
8046
|
-
console.warn("[CueProjectEntities] Failed to fetch entity category counts:",
|
|
8599
|
+
w = await this._fetchCategoryCounts();
|
|
8600
|
+
} catch (m) {
|
|
8601
|
+
console.warn("[CueProjectEntities] Failed to fetch entity category counts:", m);
|
|
8047
8602
|
}
|
|
8048
8603
|
return {
|
|
8049
|
-
entities: Array.from(d).map((
|
|
8050
|
-
const g =
|
|
8051
|
-
return g !== void 0 ? { iri:
|
|
8604
|
+
entities: Array.from(d).map((m) => {
|
|
8605
|
+
const g = w?.get(m);
|
|
8606
|
+
return g !== void 0 ? { iri: m, weight: g } : { iri: m };
|
|
8052
8607
|
}),
|
|
8053
8608
|
relations: u
|
|
8054
8609
|
};
|
|
@@ -8061,9 +8616,9 @@ ORDER BY DESC(?weight)`, n = r ?? "";
|
|
|
8061
8616
|
weight: parseInt(g.weight.value, 10)
|
|
8062
8617
|
}));
|
|
8063
8618
|
if (d.length === 0) return "(no results)";
|
|
8064
|
-
const u = Math.max(...d.map((g) => g.src.length)),
|
|
8619
|
+
const u = Math.max(...d.map((g) => g.src.length)), w = Math.max(...d.map((g) => g.pred.length)), m = Math.max(...d.map((g) => g.tgt.length));
|
|
8065
8620
|
return d.map(
|
|
8066
|
-
(g) => `${g.src.padEnd(u)} -> ${g.pred.padEnd(
|
|
8621
|
+
(g) => `${g.src.padEnd(u)} -> ${g.pred.padEnd(w)} -> ${g.tgt.padEnd(m)} (${g.weight})`
|
|
8067
8622
|
).join(`
|
|
8068
8623
|
`);
|
|
8069
8624
|
}
|
|
@@ -8098,7 +8653,7 @@ ORDER BY DESC(?weight)`;
|
|
|
8098
8653
|
*/
|
|
8099
8654
|
async _fetchCategoryCounts() {
|
|
8100
8655
|
if (!this._categoryCountsCache) {
|
|
8101
|
-
const t = `PREFIX qcy: <${
|
|
8656
|
+
const t = `PREFIX qcy: <${b.qcy}>
|
|
8102
8657
|
SELECT ?cat (COUNT(*) AS ?weight) WHERE {
|
|
8103
8658
|
?e a qcy:CanonicalEntity ;
|
|
8104
8659
|
qcy:hasEntityCategory ?cat .
|
|
@@ -8164,23 +8719,23 @@ ORDER BY DESC(?weight)`;
|
|
|
8164
8719
|
const c = t[p], h = r[p];
|
|
8165
8720
|
let d, u;
|
|
8166
8721
|
if (h) {
|
|
8167
|
-
const
|
|
8722
|
+
const w = /* @__PURE__ */ new Set();
|
|
8168
8723
|
d = h.direct.filter(
|
|
8169
|
-
(g) => a[g] !== void 0 && !
|
|
8724
|
+
(g) => a[g] !== void 0 && !w.has(g) && !!w.add(g)
|
|
8170
8725
|
).map((g) => ({ osmIRI: g, wkt: a[g] }));
|
|
8171
|
-
const
|
|
8172
|
-
for (const { osm: g, viaRels:
|
|
8173
|
-
const
|
|
8174
|
-
if (
|
|
8175
|
-
for (const
|
|
8176
|
-
const
|
|
8177
|
-
|
|
8726
|
+
const m = /* @__PURE__ */ new Map();
|
|
8727
|
+
for (const { osm: g, viaRels: y, entityUUID: f } of h.indirect) {
|
|
8728
|
+
const _ = a[g];
|
|
8729
|
+
if (_)
|
|
8730
|
+
for (const I of y) {
|
|
8731
|
+
const v = `${I}:${f}`, C = m.get(v) ?? { geometries: [], entityUUID: f };
|
|
8732
|
+
C.geometries.some(($) => $.osmIRI === g) || (C.geometries.push({ osmIRI: g, wkt: _ }), m.set(v, C));
|
|
8178
8733
|
}
|
|
8179
8734
|
}
|
|
8180
|
-
|
|
8181
|
-
([g, { geometries:
|
|
8735
|
+
m.size > 0 && (u = Array.from(m.entries()).map(
|
|
8736
|
+
([g, { geometries: y, entityUUID: f }]) => ({
|
|
8182
8737
|
rel: g.split(":")[0],
|
|
8183
|
-
geometries:
|
|
8738
|
+
geometries: y,
|
|
8184
8739
|
entityUUID: f
|
|
8185
8740
|
})
|
|
8186
8741
|
));
|
|
@@ -8198,7 +8753,7 @@ ORDER BY DESC(?weight)`;
|
|
|
8198
8753
|
return n;
|
|
8199
8754
|
}
|
|
8200
8755
|
async _fetchOutgoingRelationships(t) {
|
|
8201
|
-
const e = `PREFIX qcy: <${
|
|
8756
|
+
const e = `PREFIX qcy: <${b.qcy}>
|
|
8202
8757
|
SELECT ?rel ?related (SAMPLE(?val) AS ?nodeValue) (GROUP_CONCAT(STR(?cat); SEPARATOR=";") AS ?categories)
|
|
8203
8758
|
WHERE {
|
|
8204
8759
|
BIND(<${t}> AS ?s)
|
|
@@ -8230,7 +8785,7 @@ GROUP BY ?rel ?related`, o = await this._api.sparql(
|
|
|
8230
8785
|
}), this._entityDetails.set(a), r;
|
|
8231
8786
|
}
|
|
8232
8787
|
async _fetchIncomingRelationships(t) {
|
|
8233
|
-
const e = `PREFIX qcy: <${
|
|
8788
|
+
const e = `PREFIX qcy: <${b.qcy}>
|
|
8234
8789
|
SELECT ?rel ?relating (SAMPLE(?val) AS ?nodeValue) (GROUP_CONCAT(STR(?cat); SEPARATOR=";") AS ?categories)
|
|
8235
8790
|
WHERE {
|
|
8236
8791
|
BIND(<${t}> AS ?s)
|
|
@@ -8262,7 +8817,7 @@ GROUP BY ?rel ?relating`, o = await this._api.sparql(
|
|
|
8262
8817
|
}), this._entityDetails.set(a), r;
|
|
8263
8818
|
}
|
|
8264
8819
|
async _fetchEntityGraph() {
|
|
8265
|
-
const t = `PREFIX qcy: <${
|
|
8820
|
+
const t = `PREFIX qcy: <${b.qcy}>
|
|
8266
8821
|
SELECT ?e1Cat ?e2Cat (COUNT(?e1) AS ?e1Count) (COUNT(?e2) AS ?e2Count)
|
|
8267
8822
|
WHERE {
|
|
8268
8823
|
?e1 a qcy:CanonicalEntity ;
|
|
@@ -8303,7 +8858,7 @@ GROUP BY ?e1Cat ?e2Cat`, e = await this._api.sparql(
|
|
|
8303
8858
|
const o = e.map((n) => `<${n}>`).join(" "), r = `PREFIX geo: <${O.geo}>
|
|
8304
8859
|
SELECT * WHERE {
|
|
8305
8860
|
VALUES ?s { ${o} }
|
|
8306
|
-
SERVICE <${
|
|
8861
|
+
SERVICE <${Ua}> {
|
|
8307
8862
|
?s geo:hasGeometry/geo:asWKT ?wkt
|
|
8308
8863
|
}
|
|
8309
8864
|
}`, a = await this._api.sparql(
|
|
@@ -8317,7 +8872,7 @@ SELECT * WHERE {
|
|
|
8317
8872
|
}
|
|
8318
8873
|
}
|
|
8319
8874
|
var l = /* @__PURE__ */ ((s) => (s.AUTOMATION = "automation", s.ARCHIVE = "archive", s.AUDIO = "audio", s.BACKUP = "backup", s.BINARY = "binary", s.BIM = "bim", s.CAD = "cad", s.DATA = "data", s.EMAIL = "email", s.FONT = "font", s.GEOSPATIAL = "geospatial", s.IMAGE = "image", s.INSTALLER = "installer", s.MARKUP = "markup", s.MULTIMEDIA = "multimedia", s.PLANNING = "planning", s.PRESENTATION = "presentation", s.SCRIPT = "script", s.SPREADSHEET = "spreadsheet", s.TEXT = "text", s.THREE_D = "3d", s.UNKNOWN = "unknown", s.VIDEO = "video", s))(l || {});
|
|
8320
|
-
const
|
|
8875
|
+
const _t = {
|
|
8321
8876
|
".aac": {
|
|
8322
8877
|
type: l.AUDIO,
|
|
8323
8878
|
open: !0,
|
|
@@ -9178,7 +9733,7 @@ const wt = {
|
|
|
9178
9733
|
}
|
|
9179
9734
|
};
|
|
9180
9735
|
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 + "";
|
|
9181
|
-
const
|
|
9736
|
+
const Ma = `PREFIX view: <https://qlever.cs.uni-freiburg.de/materializedView/>
|
|
9182
9737
|
SELECT ?ext ?totalSize ?docCount
|
|
9183
9738
|
WHERE {
|
|
9184
9739
|
SERVICE view:docs-by-suffix {
|
|
@@ -9186,7 +9741,7 @@ WHERE {
|
|
|
9186
9741
|
view:column-totalSize ?totalSize ;
|
|
9187
9742
|
view:column-docCount ?docCount .
|
|
9188
9743
|
}
|
|
9189
|
-
}`,
|
|
9744
|
+
}`, qa = `PREFIX view: <https://qlever.cs.uni-freiburg.de/materializedView/>
|
|
9190
9745
|
SELECT ?cat ?totalSize ?docCount
|
|
9191
9746
|
WHERE {
|
|
9192
9747
|
SERVICE view:docs-by-category {
|
|
@@ -9194,15 +9749,15 @@ WHERE {
|
|
|
9194
9749
|
view:column-totalSize ?totalSize ;
|
|
9195
9750
|
view:column-docCount ?docCount .
|
|
9196
9751
|
}
|
|
9197
|
-
}`,
|
|
9752
|
+
}`, Fa = `PREFIX view: <https://qlever.cs.uni-freiburg.de/materializedView/>
|
|
9198
9753
|
SELECT ?count
|
|
9199
9754
|
WHERE {
|
|
9200
9755
|
SERVICE view:doc-duplicates {
|
|
9201
9756
|
_:cfg view:column-count ?count .
|
|
9202
9757
|
}
|
|
9203
9758
|
}`;
|
|
9204
|
-
class
|
|
9205
|
-
constructor(t, e, o, r =
|
|
9759
|
+
class vt {
|
|
9760
|
+
constructor(t, e, o, r = St, a, i = !1) {
|
|
9206
9761
|
this._api = t, this._projectId = e, this._graphType = a, this._verbose = i, this.baseURL = `${r}${e}/`, this._currentLang = o ?? this._api.language, this.documentInfoMap = this._documentInfoMap.asReadonly(), this.projectDocumentsData = this._projectDocumentsData.asReadonly();
|
|
9207
9762
|
}
|
|
9208
9763
|
_api;
|
|
@@ -9213,10 +9768,10 @@ class ft {
|
|
|
9213
9768
|
baseURL;
|
|
9214
9769
|
/** Tracks the language for which `_documentInfoMap` is currently populated. */
|
|
9215
9770
|
_currentLang;
|
|
9216
|
-
_documentInfoMap = new
|
|
9771
|
+
_documentInfoMap = new T({});
|
|
9217
9772
|
/** Cumulative unique document UUIDs ever passed to request methods (survives cache hits). */
|
|
9218
9773
|
_seenIds = /* @__PURE__ */ new Set();
|
|
9219
|
-
_projectDocumentsData = new
|
|
9774
|
+
_projectDocumentsData = new T({
|
|
9220
9775
|
duplicateCount: 0,
|
|
9221
9776
|
documentsBySuffix: {},
|
|
9222
9777
|
documentsByContentCategory: {}
|
|
@@ -9340,7 +9895,7 @@ class ft {
|
|
|
9340
9895
|
* ```
|
|
9341
9896
|
*/
|
|
9342
9897
|
async fetchAlternativeRepresentations(t) {
|
|
9343
|
-
const e = `PREFIX qcy: <${
|
|
9898
|
+
const e = `PREFIX qcy: <${b.qcy}>
|
|
9344
9899
|
PREFIX r: <${this.baseURL}>
|
|
9345
9900
|
SELECT ?altId ?contentIRI ?suffix ?rrp
|
|
9346
9901
|
WHERE {
|
|
@@ -9370,7 +9925,7 @@ WHERE {
|
|
|
9370
9925
|
* Useful for pre-filling path-based query inputs with a realistic example.
|
|
9371
9926
|
*/
|
|
9372
9927
|
async randomFilePath() {
|
|
9373
|
-
const t = `PREFIX qcy: <${
|
|
9928
|
+
const t = `PREFIX qcy: <${b.qcy}>
|
|
9374
9929
|
SELECT ?path
|
|
9375
9930
|
WHERE {
|
|
9376
9931
|
?fl a qcy:FileLocation ;
|
|
@@ -9383,7 +9938,7 @@ LIMIT 1`;
|
|
|
9383
9938
|
if (t.length === 0) return [];
|
|
9384
9939
|
const r = t.map(
|
|
9385
9940
|
(n) => (n.startsWith(".") ? n : `.${n}`).toLowerCase()
|
|
9386
|
-
).map((n) => `"${n}"`).join(" "), a = e ? `PREFIX qcy: <${
|
|
9941
|
+
).map((n) => `"${n}"`).join(" "), a = e ? `PREFIX qcy: <${b.qcy}>
|
|
9387
9942
|
SELECT ?id (SAMPLE(?fp) AS ?path) ?suffix (MAX(?sz) AS ?size)
|
|
9388
9943
|
WHERE {
|
|
9389
9944
|
VALUES ?suffix { ${r} }
|
|
@@ -9395,7 +9950,7 @@ WHERE {
|
|
|
9395
9950
|
FILTER NOT EXISTS { ?x qcy:alternativeRepresentation ?iri }
|
|
9396
9951
|
BIND(REPLACE(STR(?iri), "^.*/", "") AS ?id)
|
|
9397
9952
|
}
|
|
9398
|
-
GROUP BY ?id ?suffix` : `PREFIX qcy: <${
|
|
9953
|
+
GROUP BY ?id ?suffix` : `PREFIX qcy: <${b.qcy}>
|
|
9399
9954
|
SELECT DISTINCT ?id
|
|
9400
9955
|
WHERE {
|
|
9401
9956
|
VALUES ?suffix { ${r} }
|
|
@@ -9415,12 +9970,12 @@ WHERE {
|
|
|
9415
9970
|
});
|
|
9416
9971
|
}
|
|
9417
9972
|
documentsByFileType(t, e = !1) {
|
|
9418
|
-
const o = new Set(t), r = Object.values(
|
|
9973
|
+
const o = new Set(t), r = Object.values(_t).filter((a) => o.has(a.type)).map((a) => a.suffix);
|
|
9419
9974
|
return this.documentsBySuffix(r, e);
|
|
9420
9975
|
}
|
|
9421
9976
|
async documentsByContentCategory(t, e = !1) {
|
|
9422
9977
|
if (t.length === 0) return [];
|
|
9423
|
-
const o = t.map((i) => `<${i}>`).join(" "), r = e ? `PREFIX qcy: <${
|
|
9978
|
+
const o = t.map((i) => `<${i}>`).join(" "), r = e ? `PREFIX qcy: <${b.qcy}>
|
|
9424
9979
|
SELECT ?id (SAMPLE(?fp) AS ?path) ?suffix (MAX(?sz) AS ?size)
|
|
9425
9980
|
WHERE {
|
|
9426
9981
|
VALUES ?cat { ${o} }
|
|
@@ -9433,7 +9988,7 @@ WHERE {
|
|
|
9433
9988
|
FILTER NOT EXISTS { ?x qcy:alternativeRepresentation ?iri }
|
|
9434
9989
|
BIND(REPLACE(STR(?iri), "^.*/", "") AS ?id)
|
|
9435
9990
|
}
|
|
9436
|
-
GROUP BY ?id ?suffix` : `PREFIX qcy: <${
|
|
9991
|
+
GROUP BY ?id ?suffix` : `PREFIX qcy: <${b.qcy}>
|
|
9437
9992
|
SELECT DISTINCT ?id
|
|
9438
9993
|
WHERE {
|
|
9439
9994
|
VALUES ?cat { ${o} }
|
|
@@ -9453,7 +10008,7 @@ WHERE {
|
|
|
9453
10008
|
});
|
|
9454
10009
|
}
|
|
9455
10010
|
documentsByMime(t, e = !1) {
|
|
9456
|
-
const o = new Set(t), r = Object.values(
|
|
10011
|
+
const o = new Set(t), r = Object.values(_t).filter((a) => o.has(a.mime)).map((a) => a.suffix);
|
|
9457
10012
|
return this.documentsBySuffix(r, e);
|
|
9458
10013
|
}
|
|
9459
10014
|
// ── Private helpers ────────────────────────────────────────────────────────
|
|
@@ -9467,7 +10022,7 @@ WHERE {
|
|
|
9467
10022
|
/** Executes the document-info SPARQL query for the given UUIDs, merges results
|
|
9468
10023
|
* into `documentInfoMap`, and returns the newly fetched entries. */
|
|
9469
10024
|
async _fetchDocumentInfoBatch(t) {
|
|
9470
|
-
const e = t.map((p) => `r:${p}`).join(" "), o = this._api.language, r = `PREFIX qcy: <${
|
|
10025
|
+
const e = t.map((p) => `r:${p}`).join(" "), o = this._api.language, r = `PREFIX qcy: <${b.qcy}>
|
|
9471
10026
|
PREFIX r: <${this.baseURL}>
|
|
9472
10027
|
SELECT ?id ?suffix ?size ?subject ?summary
|
|
9473
10028
|
(SAMPLE(?fp) AS ?path)
|
|
@@ -9514,7 +10069,7 @@ GROUP BY ?id ?suffix ?size ?subject ?summary`, a = await this._api.sparql(r, thi
|
|
|
9514
10069
|
/** Executes a reduced document-info query (id/path/suffix/size only), merges
|
|
9515
10070
|
* into `documentInfoMap`, and returns newly fetched entries. */
|
|
9516
10071
|
async _fetchSimpleDocumentInfoBatch(t) {
|
|
9517
|
-
const e = t.map((n) => `r:${n}`).join(" "), o = `PREFIX qcy: <${
|
|
10072
|
+
const e = t.map((n) => `r:${n}`).join(" "), o = `PREFIX qcy: <${b.qcy}>
|
|
9518
10073
|
PREFIX r: <${this.baseURL}>
|
|
9519
10074
|
SELECT ?id ?suffix ?size (SAMPLE(?fp) AS ?path)
|
|
9520
10075
|
WHERE {
|
|
@@ -9545,14 +10100,14 @@ GROUP BY ?id ?suffix ?size`, r = await this._api.sparql(o, this._projectId, this
|
|
|
9545
10100
|
}
|
|
9546
10101
|
async _fetchDocumentsBySuffix() {
|
|
9547
10102
|
if (this._graphType !== "fuseki") {
|
|
9548
|
-
const e = await this._runDocumentsBySuffixQuery(
|
|
10103
|
+
const e = await this._runDocumentsBySuffixQuery(Ma);
|
|
9549
10104
|
if (Object.keys(e).length > 0) return e;
|
|
9550
10105
|
console.warn(`[CueProjectDocuments] Materialized view "docs-by-suffix" returned no rows for project ${this._projectId} — falling back to live query.`);
|
|
9551
10106
|
}
|
|
9552
10107
|
return this._runDocumentsBySuffixQuery(this._buildDocumentsBySuffixQuery());
|
|
9553
10108
|
}
|
|
9554
10109
|
_buildDocumentsBySuffixQuery() {
|
|
9555
|
-
return `PREFIX qcy: <${
|
|
10110
|
+
return `PREFIX qcy: <${b.qcy}>
|
|
9556
10111
|
SELECT ?ext (SUM(?size) AS ?totalSize) (COUNT(*) AS ?docCount)
|
|
9557
10112
|
WHERE {
|
|
9558
10113
|
{
|
|
@@ -9579,14 +10134,14 @@ ORDER BY DESC(?docCount)`;
|
|
|
9579
10134
|
}
|
|
9580
10135
|
async _fetchDocumentsByContentCategory() {
|
|
9581
10136
|
if (this._graphType !== "fuseki") {
|
|
9582
|
-
const e = await this._runDocumentsByContentCategoryQuery(
|
|
10137
|
+
const e = await this._runDocumentsByContentCategoryQuery(qa);
|
|
9583
10138
|
if (Object.keys(e).length > 0) return e;
|
|
9584
10139
|
console.warn(`[CueProjectDocuments] Materialized view "docs-by-category" returned no rows for project ${this._projectId} — falling back to live query.`);
|
|
9585
10140
|
}
|
|
9586
10141
|
return this._runDocumentsByContentCategoryQuery(this._buildDocumentsByContentCategoryQuery());
|
|
9587
10142
|
}
|
|
9588
10143
|
_buildDocumentsByContentCategoryQuery() {
|
|
9589
|
-
return `PREFIX qcy: <${
|
|
10144
|
+
return `PREFIX qcy: <${b.qcy}>
|
|
9590
10145
|
SELECT ?cat (SUM(?size) AS ?totalSize) (COUNT(*) AS ?docCount)
|
|
9591
10146
|
WHERE {
|
|
9592
10147
|
{
|
|
@@ -9613,7 +10168,7 @@ ORDER BY DESC(?docCount)`;
|
|
|
9613
10168
|
}
|
|
9614
10169
|
async _fetchDuplicateCount() {
|
|
9615
10170
|
if (this._graphType !== "fuseki") {
|
|
9616
|
-
const e = await this._api.sparql(
|
|
10171
|
+
const e = await this._api.sparql(Fa, this._projectId, this._graphType);
|
|
9617
10172
|
if (e.results.bindings.length > 0) {
|
|
9618
10173
|
const o = e.results.bindings[0];
|
|
9619
10174
|
return o?.count ? parseInt(o.count.value, 10) : 0;
|
|
@@ -9623,7 +10178,7 @@ ORDER BY DESC(?docCount)`;
|
|
|
9623
10178
|
return this._runDuplicateCountQuery(this._buildDuplicateCountQuery());
|
|
9624
10179
|
}
|
|
9625
10180
|
_buildDuplicateCountQuery() {
|
|
9626
|
-
return `PREFIX qcy: <${
|
|
10181
|
+
return `PREFIX qcy: <${b.qcy}>
|
|
9627
10182
|
SELECT (COUNT(*) AS ?count)
|
|
9628
10183
|
WHERE {
|
|
9629
10184
|
SELECT ?fc
|
|
@@ -9641,9 +10196,9 @@ WHERE {
|
|
|
9641
10196
|
return o?.count ? parseInt(o.count.value, 10) : 0;
|
|
9642
10197
|
}
|
|
9643
10198
|
}
|
|
9644
|
-
class
|
|
9645
|
-
constructor(t, e, { language: o, rdfBase: r =
|
|
9646
|
-
this._api = t, this._projectId = e, this.schema = new
|
|
10199
|
+
class za {
|
|
10200
|
+
constructor(t, e, { language: o, rdfBase: r = St, graphType: a, verbose: i }) {
|
|
10201
|
+
this._api = t, this._projectId = e, this.schema = new La(t, e, o, a, i), this.entities = new Ve(t, e, r, a, i), this.documents = new vt(t, e, o, r, 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));
|
|
9647
10202
|
}
|
|
9648
10203
|
_api;
|
|
9649
10204
|
_projectId;
|
|
@@ -9674,10 +10229,23 @@ class ya {
|
|
|
9674
10229
|
/** Project document overview (counts by suffix and category). Fetched on init. */
|
|
9675
10230
|
projectDocumentsData;
|
|
9676
10231
|
// ── Search state ───────────────────────────────────────────────────────────
|
|
9677
|
-
_searchResults = new
|
|
10232
|
+
_searchResults = new T(void 0);
|
|
9678
10233
|
/** The result of the most recent `search()` call. `undefined` before first search. */
|
|
9679
10234
|
searchResults;
|
|
9680
10235
|
_destroyed = !1;
|
|
10236
|
+
// ── Schema methods ──────────────────────────────────────────────────────────
|
|
10237
|
+
/** Creates a new content category, appending it to `availableContentCategories` on success. */
|
|
10238
|
+
async createContentCategory(t) {
|
|
10239
|
+
return this._destroyed ? null : this.schema.createContentCategory(t);
|
|
10240
|
+
}
|
|
10241
|
+
/** Creates a new entity category, appending it to `availableEntityCategories` on success. */
|
|
10242
|
+
async createEntityCategory(t) {
|
|
10243
|
+
return this._destroyed ? null : this.schema.createEntityCategory(t);
|
|
10244
|
+
}
|
|
10245
|
+
/** Creates a new entity relationship, appending it to `availableEntityRelationships` on success. */
|
|
10246
|
+
async createEntityRelationship(t) {
|
|
10247
|
+
return this._destroyed ? null : this.schema.createEntityRelationship(t);
|
|
10248
|
+
}
|
|
9681
10249
|
// ── Entity methods ─────────────────────────────────────────────────────────
|
|
9682
10250
|
/**
|
|
9683
10251
|
* Lazily batch-fetch core data (label + categories) for the given entity UUIDs.
|
|
@@ -9761,7 +10329,7 @@ class ya {
|
|
|
9761
10329
|
this._destroyed = !0, this._searchResults.set(void 0);
|
|
9762
10330
|
}
|
|
9763
10331
|
}
|
|
9764
|
-
function
|
|
10332
|
+
function Se(s, t) {
|
|
9765
10333
|
return new Promise((e) => {
|
|
9766
10334
|
const o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
9767
10335
|
for (const f of s)
|
|
@@ -9771,17 +10339,17 @@ function de(s, t) {
|
|
|
9771
10339
|
a.has(f.contentUUID) || a.set(f.contentUUID, []), a.get(f.contentUUID)?.push(f), f.locationUUID && i.set(f.locationUUID, f);
|
|
9772
10340
|
const n = [], p = [];
|
|
9773
10341
|
for (const f of s)
|
|
9774
|
-
a.has(f.contentUUID) ? (a.get(f.contentUUID) || []).some((
|
|
10342
|
+
a.has(f.contentUUID) ? (a.get(f.contentUUID) || []).some((v) => v.locationUUID === f.locationUUID) || p.push(f) : n.push(f);
|
|
9775
10343
|
const c = [], h = [];
|
|
9776
10344
|
for (const f of t) {
|
|
9777
|
-
const
|
|
9778
|
-
|
|
10345
|
+
const _ = o.get(f.contentUUID);
|
|
10346
|
+
_ ? _.some((v) => v.locationUUID === f.locationUUID) || h.push(f) : c.push(f);
|
|
9779
10347
|
}
|
|
9780
|
-
const d = s.length - n.length - p.length, u = s.length,
|
|
9781
|
-
let
|
|
10348
|
+
const d = s.length - n.length - p.length, u = s.length, w = u > 0 ? d / u : 1;
|
|
10349
|
+
let m = 0, g = 0;
|
|
9782
10350
|
for (const f of s)
|
|
9783
|
-
g += f.size || 0, (a.get(f.contentUUID) || []).some((
|
|
9784
|
-
const
|
|
10351
|
+
g += f.size || 0, (a.get(f.contentUUID) || []).some((v) => v.locationUUID === f.locationUUID) && (m += f.size || 0);
|
|
10352
|
+
const y = g > 0 ? m / g : 1;
|
|
9785
10353
|
e({
|
|
9786
10354
|
localNotOnRemote: n,
|
|
9787
10355
|
localNotOnRemotePathOnly: p,
|
|
@@ -9789,14 +10357,14 @@ function de(s, t) {
|
|
|
9789
10357
|
remoteNotOnLocalPathOnly: h,
|
|
9790
10358
|
syncCount: d,
|
|
9791
10359
|
totalCount: u,
|
|
9792
|
-
syncSize:
|
|
10360
|
+
syncSize: m,
|
|
9793
10361
|
totalSize: g,
|
|
9794
|
-
synctPctSize:
|
|
9795
|
-
synctPctCount:
|
|
10362
|
+
synctPctSize: y,
|
|
10363
|
+
synctPctCount: w
|
|
9796
10364
|
});
|
|
9797
10365
|
});
|
|
9798
10366
|
}
|
|
9799
|
-
const
|
|
10367
|
+
const Ce = {
|
|
9800
10368
|
ä: "ae",
|
|
9801
10369
|
ä: "ae",
|
|
9802
10370
|
Ä: "AE",
|
|
@@ -9830,35 +10398,27 @@ const ue = {
|
|
|
9830
10398
|
þ: "th",
|
|
9831
10399
|
Þ: "Th"
|
|
9832
10400
|
};
|
|
9833
|
-
function
|
|
10401
|
+
function Xe(s, t = !1) {
|
|
9834
10402
|
const e = "daca0510-72b5-48ba-9091-b918ca18136b";
|
|
9835
|
-
return s =
|
|
10403
|
+
return s = Ba(s, t), $o(s, e);
|
|
9836
10404
|
}
|
|
9837
|
-
function
|
|
10405
|
+
function Ba(s, t = !1) {
|
|
9838
10406
|
let e = s;
|
|
9839
|
-
for (const o in
|
|
9840
|
-
e = e.replace(new RegExp(o, "g"),
|
|
10407
|
+
for (const o in Ce)
|
|
10408
|
+
e = e.replace(new RegExp(o, "g"), Ce[o]);
|
|
9841
10409
|
return t && e !== s && console.info(`${s} -> ${e}`), e;
|
|
9842
10410
|
}
|
|
9843
|
-
function
|
|
9844
|
-
return
|
|
10411
|
+
function Ga(s, t = "") {
|
|
10412
|
+
return Xe(`${t}${s}`);
|
|
9845
10413
|
}
|
|
9846
|
-
|
|
9847
|
-
_a("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
9848
|
-
const { namedNode: Ba } = M, { namedNode: Ea, literal: Ga } = M;
|
|
9849
|
-
Ea("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
9850
|
-
function Ta(s) {
|
|
10414
|
+
function Ha(s) {
|
|
9851
10415
|
const t = s.split(".");
|
|
9852
10416
|
return t.length > 1 ? "." + t.pop()?.toLowerCase() : "";
|
|
9853
10417
|
}
|
|
9854
|
-
|
|
9855
|
-
|
|
9856
|
-
|
|
9857
|
-
|
|
9858
|
-
function ge(s, t, e, o, r, a, i, n = !1, p = !1) {
|
|
9859
|
-
const c = Ta(s), h = je(o), d = `${t}/${h}${c}`;
|
|
9860
|
-
i === void 0 && (i = wt[c]?.mime ?? "application/octet-stream");
|
|
9861
|
-
const u = va(s, r);
|
|
10418
|
+
function ke(s, t, e, o, r, a, i, n = !1, p = !1) {
|
|
10419
|
+
const c = Ha(s), h = Xe(o), d = `${t}/${h}${c}`;
|
|
10420
|
+
i === void 0 && (i = _t[c]?.mime ?? "application/octet-stream");
|
|
10421
|
+
const u = Ga(s, r);
|
|
9862
10422
|
return {
|
|
9863
10423
|
name: s,
|
|
9864
10424
|
blob_name: d,
|
|
@@ -9878,25 +10438,25 @@ function ge(s, t, e, o, r, a, i, n = !1, p = !1) {
|
|
|
9878
10438
|
})
|
|
9879
10439
|
};
|
|
9880
10440
|
}
|
|
9881
|
-
async function
|
|
10441
|
+
async function z() {
|
|
9882
10442
|
return import(
|
|
9883
10443
|
/* webpackIgnore: true */
|
|
9884
10444
|
"fs/promises"
|
|
9885
10445
|
);
|
|
9886
10446
|
}
|
|
9887
|
-
async function
|
|
10447
|
+
async function Ie(s) {
|
|
9888
10448
|
if (typeof window < "u")
|
|
9889
10449
|
throw new Error(
|
|
9890
10450
|
`Cannot read file from path "${s}" in a browser environment. Provide file.data (Uint8Array) instead.`
|
|
9891
10451
|
);
|
|
9892
|
-
const { readFile: t } = await
|
|
10452
|
+
const { readFile: t } = await z();
|
|
9893
10453
|
return t(s);
|
|
9894
10454
|
}
|
|
9895
|
-
let
|
|
9896
|
-
function
|
|
9897
|
-
Q = s,
|
|
10455
|
+
let F = null, Y = null, Q = null;
|
|
10456
|
+
function pi(s) {
|
|
10457
|
+
Q = s, Y = null, F = null;
|
|
9898
10458
|
}
|
|
9899
|
-
async function
|
|
10459
|
+
async function Wa() {
|
|
9900
10460
|
if (typeof window < "u") {
|
|
9901
10461
|
if (!Q)
|
|
9902
10462
|
throw new Error(
|
|
@@ -9906,20 +10466,20 @@ async function Ia() {
|
|
|
9906
10466
|
if (!s.ok)
|
|
9907
10467
|
throw new Error(`Failed to fetch WASM binary: ${s.status} ${s.statusText}`);
|
|
9908
10468
|
const t = new Uint8Array(await s.arrayBuffer()), o = await import(`${Q}/dir_scanner_wasm.mjs`);
|
|
9909
|
-
await o.default({ module_or_path: t }),
|
|
10469
|
+
await o.default({ module_or_path: t }), F = o.scan;
|
|
9910
10470
|
} else {
|
|
9911
|
-
const { readFile: s } = await
|
|
10471
|
+
const { readFile: s } = await z(), { join: t } = await import(
|
|
9912
10472
|
/* webpackIgnore: true */
|
|
9913
10473
|
"path"
|
|
9914
10474
|
), { pathToFileURL: e } = await import(
|
|
9915
10475
|
/* webpackIgnore: true */
|
|
9916
10476
|
"url"
|
|
9917
10477
|
), o = t(__dirname, "assets", "wasm"), r = await s(t(o, "dir_scanner_wasm_bg.wasm")), i = await import(e(t(o, "dir_scanner_wasm.mjs")).href);
|
|
9918
|
-
await i.default({ module_or_path: r }),
|
|
10478
|
+
await i.default({ module_or_path: r }), F = i.scan;
|
|
9919
10479
|
}
|
|
9920
10480
|
}
|
|
9921
|
-
const
|
|
9922
|
-
async function
|
|
10481
|
+
const Va = "qlever", X = 1e3, xt = "cue:pending:";
|
|
10482
|
+
async function Rt(s) {
|
|
9923
10483
|
const { tmpdir: t } = await import(
|
|
9924
10484
|
/* webpackIgnore: true */
|
|
9925
10485
|
"os"
|
|
@@ -9929,37 +10489,37 @@ async function Et(s) {
|
|
|
9929
10489
|
);
|
|
9930
10490
|
return e(t(), `cue-sync-pending-${s}.json`);
|
|
9931
10491
|
}
|
|
9932
|
-
async function
|
|
10492
|
+
async function xe(s) {
|
|
9933
10493
|
if (typeof window < "u") {
|
|
9934
|
-
const t = window.localStorage.getItem(`${
|
|
10494
|
+
const t = window.localStorage.getItem(`${xt}${s}`);
|
|
9935
10495
|
return t ? JSON.parse(t) : null;
|
|
9936
10496
|
}
|
|
9937
10497
|
try {
|
|
9938
|
-
const t = await (await
|
|
10498
|
+
const t = await (await z()).readFile(await Rt(s), "utf-8");
|
|
9939
10499
|
return JSON.parse(t);
|
|
9940
10500
|
} catch {
|
|
9941
10501
|
return null;
|
|
9942
10502
|
}
|
|
9943
10503
|
}
|
|
9944
|
-
async function
|
|
10504
|
+
async function Re(s) {
|
|
9945
10505
|
const t = JSON.stringify(s);
|
|
9946
10506
|
if (typeof window < "u") {
|
|
9947
|
-
window.localStorage.setItem(`${
|
|
10507
|
+
window.localStorage.setItem(`${xt}${s.spaceId}`, t);
|
|
9948
10508
|
return;
|
|
9949
10509
|
}
|
|
9950
|
-
await (await
|
|
10510
|
+
await (await z()).writeFile(await Rt(s.spaceId), t, "utf-8");
|
|
9951
10511
|
}
|
|
9952
|
-
async function
|
|
10512
|
+
async function Xa(s) {
|
|
9953
10513
|
if (typeof window < "u") {
|
|
9954
|
-
window.localStorage.removeItem(`${
|
|
10514
|
+
window.localStorage.removeItem(`${xt}${s}`);
|
|
9955
10515
|
return;
|
|
9956
10516
|
}
|
|
9957
10517
|
try {
|
|
9958
|
-
await (await
|
|
10518
|
+
await (await z()).unlink(await Rt(s));
|
|
9959
10519
|
} catch {
|
|
9960
10520
|
}
|
|
9961
10521
|
}
|
|
9962
|
-
class
|
|
10522
|
+
class Ae {
|
|
9963
10523
|
constructor(t, e, o, r) {
|
|
9964
10524
|
this._auth = t, this._projects = e, this._blob = o, this._gatewayUrl = r;
|
|
9965
10525
|
}
|
|
@@ -9974,6 +10534,13 @@ class ye {
|
|
|
9974
10534
|
_pendingSpaceId = null;
|
|
9975
10535
|
_flushTimer = null;
|
|
9976
10536
|
_legacy = !1;
|
|
10537
|
+
/**
|
|
10538
|
+
* `projectSettings.gzipEnabled` per space, populated once by
|
|
10539
|
+
* `initBrowserSync` so `syncBrowserFile` (called once per dropped file,
|
|
10540
|
+
* often dozens concurrently) doesn't re-fetch the project over the gateway
|
|
10541
|
+
* on every single file.
|
|
10542
|
+
*/
|
|
10543
|
+
_gzipEnabledBySpace = /* @__PURE__ */ new Map();
|
|
9977
10544
|
/** @internal Injected by CueApi after construction to avoid circular dependency. */
|
|
9978
10545
|
_bindApi(t) {
|
|
9979
10546
|
this._api = t;
|
|
@@ -10009,7 +10576,8 @@ class ye {
|
|
|
10009
10576
|
* project changes) so that interrupted uploads are recovered immediately.
|
|
10010
10577
|
*/
|
|
10011
10578
|
async initBrowserSync(t) {
|
|
10012
|
-
await this.
|
|
10579
|
+
const e = await this._projects.getProject(t);
|
|
10580
|
+
this._gzipEnabledBySpace.set(t, e?.projectSettings?.gzipEnabled ?? !1), await this._initPendingBatch(t);
|
|
10013
10581
|
}
|
|
10014
10582
|
/**
|
|
10015
10583
|
* Pushes filesystem-structure metadata for all provided files directly to the
|
|
@@ -10026,8 +10594,8 @@ class ye {
|
|
|
10026
10594
|
providerId: e.providerId,
|
|
10027
10595
|
fileContentExists: !1
|
|
10028
10596
|
}));
|
|
10029
|
-
for (let r = 0; r < o.length; r +=
|
|
10030
|
-
await this._postFssBatch(o.slice(r, r +
|
|
10597
|
+
for (let r = 0; r < o.length; r += X)
|
|
10598
|
+
await this._postFssBatch(o.slice(r, r + X), e.spaceId);
|
|
10031
10599
|
e.verbose && console.info(`Pushed metadata for ${o.length} file(s) ✅`);
|
|
10032
10600
|
}
|
|
10033
10601
|
/**
|
|
@@ -10037,7 +10605,7 @@ class ye {
|
|
|
10037
10605
|
*/
|
|
10038
10606
|
async flushPendingMetadata(t, e, o) {
|
|
10039
10607
|
this._legacy = o ?? !1;
|
|
10040
|
-
const r = await
|
|
10608
|
+
const r = await xe(t);
|
|
10041
10609
|
if (!(!r || r.items.length === 0)) {
|
|
10042
10610
|
console.info(`Trying to upload metadata (${r.items.length} item(s))...`), e && console.info(`Flushing ${r.items.length} pending file location(s) from previous sync ⏳`);
|
|
10043
10611
|
try {
|
|
@@ -10055,32 +10623,32 @@ class ye {
|
|
|
10055
10623
|
async previewSync(t, e) {
|
|
10056
10624
|
const { spaceId: o, providerId: r, verbose: a } = e, i = await this._auth.getToken();
|
|
10057
10625
|
if (!i) throw new Error("Not authenticated. Call cue.auth.signIn() first.");
|
|
10058
|
-
const n = await this._getOrCreateGraph(o, i), p = await this._projects.getProject(o), c = p?.projectSettings?.tier ?? "l", [h, d, u,
|
|
10626
|
+
const n = await this._getOrCreateGraph(o, i), p = await this._projects.getProject(o), c = p?.projectSettings?.tier ?? "l", [h, d, u, w] = await Promise.all([
|
|
10059
10627
|
this._listRemoteFiles(n, o, r, a),
|
|
10060
10628
|
this._getAvailableCredits(p?.organizationID),
|
|
10061
10629
|
this._fetchUnitCreditMap(a),
|
|
10062
10630
|
this._fetchTierNames()
|
|
10063
|
-
]),
|
|
10064
|
-
let f = 0,
|
|
10065
|
-
for (const
|
|
10066
|
-
f +=
|
|
10067
|
-
const
|
|
10068
|
-
a &&
|
|
10069
|
-
const
|
|
10070
|
-
|
|
10631
|
+
]), m = await Se(t, h), g = m.localNotOnRemote ?? [], y = g.length > 0 ? await this.scanCost(g) : [];
|
|
10632
|
+
let f = 0, _ = 0;
|
|
10633
|
+
for (const v of y) {
|
|
10634
|
+
f += v.units;
|
|
10635
|
+
const C = u[c], $ = C?.[v.ext] ?? 1;
|
|
10636
|
+
a && C && !(v.ext in C) && console.info(` Unknown format: .${v.ext} (using default rate of 1 credit/unit)`);
|
|
10637
|
+
const E = v.units * $;
|
|
10638
|
+
_ += E, v.credits = Math.round(E);
|
|
10071
10639
|
}
|
|
10072
|
-
const
|
|
10640
|
+
const I = w[c] ?? c;
|
|
10073
10641
|
return {
|
|
10074
|
-
costRecords:
|
|
10642
|
+
costRecords: y,
|
|
10075
10643
|
tier: c,
|
|
10076
|
-
tierName:
|
|
10644
|
+
tierName: I,
|
|
10077
10645
|
unitsToConsume: f,
|
|
10078
|
-
creditsToConsume: Math.round(
|
|
10646
|
+
creditsToConsume: Math.round(_),
|
|
10079
10647
|
creditsAvailable: d.creditsAvailable,
|
|
10080
10648
|
unitsAvailable: d.unitsAvailable,
|
|
10081
10649
|
filesToUpload: g.length,
|
|
10082
10650
|
totalLocalFiles: t.length,
|
|
10083
|
-
report:
|
|
10651
|
+
report: m
|
|
10084
10652
|
};
|
|
10085
10653
|
}
|
|
10086
10654
|
async sync(t, e) {
|
|
@@ -10088,84 +10656,88 @@ class ye {
|
|
|
10088
10656
|
this._legacy = p ?? !1;
|
|
10089
10657
|
const c = await this._auth.getToken();
|
|
10090
10658
|
if (!c) throw new Error("Not authenticated. Call cue.auth.signIn() first.");
|
|
10091
|
-
const h = await this._getOrCreateGraph(o, c), d = await this._projects.getProject(o);
|
|
10659
|
+
const h = await this._getOrCreateGraph(o, c), d = await this._projects.getProject(o), u = d?.projectSettings?.gzipEnabled ?? !1;
|
|
10092
10660
|
i && console.info("Listing remote files ⏳");
|
|
10093
|
-
const [
|
|
10661
|
+
const [w, m] = await Promise.all([
|
|
10094
10662
|
this._listRemoteFiles(h, o, r, i),
|
|
10095
10663
|
this._getAvailableCredits(d?.organizationID)
|
|
10096
|
-
]), { unitsAvailable:
|
|
10097
|
-
i && (console.info(`Total local files: ${t.length}`), console.info(`Total remote files: ${
|
|
10098
|
-
`Total files to sync: ${(
|
|
10664
|
+
]), { unitsAvailable: g } = m, y = await Se(t, w);
|
|
10665
|
+
i && (console.info(`Total local files: ${t.length}`), console.info(`Total remote files: ${w.length}`), console.info(
|
|
10666
|
+
`Total files to sync: ${(y.localNotOnRemote?.length ?? 0) + y.localNotOnRemotePathOnly.length}`
|
|
10099
10667
|
));
|
|
10100
|
-
let
|
|
10101
|
-
const
|
|
10102
|
-
if (
|
|
10103
|
-
const
|
|
10104
|
-
if (
|
|
10668
|
+
let f = y.syncCount, _ = y.syncSize, I = 0, v = !1;
|
|
10669
|
+
const C = y.localNotOnRemote ?? [];
|
|
10670
|
+
if (C.length > 0) {
|
|
10671
|
+
const R = (await this.scanCost(C)).reduce((N, Qe) => N + Qe.units, 0);
|
|
10672
|
+
if (R > g)
|
|
10105
10673
|
throw new Error(
|
|
10106
|
-
`Insufficient units: ${
|
|
10674
|
+
`Insufficient units: ${R} units required but only ${g} available.`
|
|
10107
10675
|
);
|
|
10108
10676
|
}
|
|
10109
|
-
await this._initPendingBatch(o, i), i &&
|
|
10110
|
-
for (const
|
|
10677
|
+
await this._initPendingBatch(o, i), i && C.length && console.info("Syncing missing files ⏳");
|
|
10678
|
+
for (const E of C)
|
|
10111
10679
|
try {
|
|
10112
|
-
const
|
|
10113
|
-
|
|
10680
|
+
const R = ke(
|
|
10681
|
+
E.relativePath,
|
|
10114
10682
|
o,
|
|
10115
10683
|
a,
|
|
10116
|
-
|
|
10684
|
+
E.md5,
|
|
10117
10685
|
r
|
|
10118
10686
|
);
|
|
10119
|
-
if (!
|
|
10120
|
-
const
|
|
10687
|
+
if (!R.blob_name) throw new Error(`blob_name missing for ${E.relativePath}`);
|
|
10688
|
+
const N = E.data ?? new Uint8Array(await Ie(E.fullPath));
|
|
10121
10689
|
await this._blob.uploadRaw(
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10690
|
+
R.blob_name,
|
|
10691
|
+
N,
|
|
10692
|
+
R,
|
|
10693
|
+
3,
|
|
10694
|
+
void 0,
|
|
10695
|
+
void 0,
|
|
10696
|
+
u
|
|
10125
10697
|
), await this._queueFileLocation({
|
|
10126
|
-
relativePath:
|
|
10127
|
-
md5:
|
|
10128
|
-
size:
|
|
10698
|
+
relativePath: E.relativePath,
|
|
10699
|
+
md5: E.md5,
|
|
10700
|
+
size: E.size,
|
|
10129
10701
|
providerId: r,
|
|
10130
10702
|
fileContentExists: !1
|
|
10131
|
-
}),
|
|
10132
|
-
} catch (
|
|
10133
|
-
|
|
10703
|
+
}), v = !0, f += 1, _ += E.size || 0, this._logProgress(f, y.totalCount, _, y.totalSize, n);
|
|
10704
|
+
} catch (R) {
|
|
10705
|
+
I += 1, console.error(`[CueSyncApi] Failed to upload file: ${E.fullPath}`), i && console.error("[CueSyncApi] Upload error details:", R);
|
|
10134
10706
|
}
|
|
10135
|
-
i &&
|
|
10136
|
-
for (const
|
|
10707
|
+
i && y.localNotOnRemotePathOnly.length && console.info(`Syncing missing file locations (on provider "${r}") ⏳`);
|
|
10708
|
+
for (const E of y.localNotOnRemotePathOnly)
|
|
10137
10709
|
await this._queueFileLocation({
|
|
10138
|
-
relativePath:
|
|
10139
|
-
md5:
|
|
10140
|
-
size:
|
|
10710
|
+
relativePath: E.relativePath,
|
|
10711
|
+
md5: E.md5,
|
|
10712
|
+
size: E.size,
|
|
10141
10713
|
providerId: r,
|
|
10142
10714
|
fileContentExists: !0
|
|
10143
|
-
}),
|
|
10715
|
+
}), v = !0, f += 1, _ += E.size || 0, this._logProgress(f, y.totalCount, _, y.totalSize, n);
|
|
10144
10716
|
await this._drainPending(i), this._stopFlushTimer();
|
|
10145
|
-
const
|
|
10717
|
+
const $ = await this._getAvailableCredits(d?.organizationID);
|
|
10146
10718
|
return {
|
|
10147
|
-
syncCount:
|
|
10148
|
-
syncSize:
|
|
10149
|
-
failedUploads:
|
|
10150
|
-
totalCount:
|
|
10151
|
-
totalSize:
|
|
10152
|
-
rdfWritten:
|
|
10153
|
-
creditsAvailable:
|
|
10719
|
+
syncCount: f,
|
|
10720
|
+
syncSize: _,
|
|
10721
|
+
failedUploads: I,
|
|
10722
|
+
totalCount: y.totalCount,
|
|
10723
|
+
totalSize: y.totalSize,
|
|
10724
|
+
rdfWritten: v,
|
|
10725
|
+
creditsAvailable: $.creditsAvailable
|
|
10154
10726
|
};
|
|
10155
10727
|
}
|
|
10156
10728
|
async _getOrCreateGraph(t, e) {
|
|
10157
10729
|
const o = this._graphMap.get(t);
|
|
10158
10730
|
if (o) return o;
|
|
10159
|
-
const
|
|
10160
|
-
graphType:
|
|
10161
|
-
queryEndpoint:
|
|
10162
|
-
updateEndpoint:
|
|
10731
|
+
const r = Va, a = `${this._gatewayUrl}${Le}`, i = `${this._gatewayUrl}${Xr}`, n = new Mo({
|
|
10732
|
+
graphType: r,
|
|
10733
|
+
queryEndpoint: a,
|
|
10734
|
+
updateEndpoint: i,
|
|
10163
10735
|
originalHeaders: {
|
|
10164
10736
|
"x-project-id": t,
|
|
10165
10737
|
authorization: `Bearer ${e}`
|
|
10166
10738
|
}
|
|
10167
10739
|
});
|
|
10168
|
-
return this._graphMap.set(t,
|
|
10740
|
+
return this._graphMap.set(t, n), n;
|
|
10169
10741
|
}
|
|
10170
10742
|
async _listRemoteFiles(t, e, o, r) {
|
|
10171
10743
|
r && console.info(`Listing files in raw space: ${e}`);
|
|
@@ -10196,7 +10768,7 @@ class ye {
|
|
|
10196
10768
|
return p;
|
|
10197
10769
|
}
|
|
10198
10770
|
async _getGraphFiles(t, e) {
|
|
10199
|
-
const o = `PREFIX qcy: <${
|
|
10771
|
+
const o = `PREFIX qcy: <${b.qcy}>
|
|
10200
10772
|
SELECT ?fc ?loc ?created ?fp ?size
|
|
10201
10773
|
WHERE {
|
|
10202
10774
|
?fc a qcy:FileContent ;
|
|
@@ -10222,7 +10794,7 @@ WHERE {
|
|
|
10222
10794
|
}
|
|
10223
10795
|
async _initPendingBatch(t, e) {
|
|
10224
10796
|
this._flushTimer !== null && (clearInterval(this._flushTimer), this._flushTimer = null), this._pendingSpaceId = t, this._pendingItems = [];
|
|
10225
|
-
const o = await
|
|
10797
|
+
const o = await xe(t);
|
|
10226
10798
|
if (o && o.items.length > 0) {
|
|
10227
10799
|
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 ⏳`);
|
|
10228
10800
|
try {
|
|
@@ -10243,7 +10815,7 @@ WHERE {
|
|
|
10243
10815
|
typeof r == "object" && typeof r.unref == "function" && r.unref(), this._flushTimer = r;
|
|
10244
10816
|
}
|
|
10245
10817
|
async _queueFileLocation(t) {
|
|
10246
|
-
this._pendingItems.push(t), this._pendingSpaceId && await
|
|
10818
|
+
this._pendingItems.push(t), this._pendingSpaceId && await Re({ spaceId: this._pendingSpaceId, items: this._pendingItems });
|
|
10247
10819
|
}
|
|
10248
10820
|
/**
|
|
10249
10821
|
* Flush all queued file-location items to the commands API in a single batch.
|
|
@@ -10268,18 +10840,18 @@ WHERE {
|
|
|
10268
10840
|
}
|
|
10269
10841
|
async _flushBatch(t, e, o) {
|
|
10270
10842
|
const r = [...t];
|
|
10271
|
-
this._pendingSpaceId === e && (this._pendingItems = []), await
|
|
10843
|
+
this._pendingSpaceId === e && (this._pendingItems = []), await Xa(e);
|
|
10272
10844
|
try {
|
|
10273
|
-
for (let a = 0; a < r.length; a +=
|
|
10274
|
-
await this._postFssBatch(r.slice(a, a +
|
|
10845
|
+
for (let a = 0; a < r.length; a += X)
|
|
10846
|
+
await this._postFssBatch(r.slice(a, a + X), e);
|
|
10275
10847
|
o && console.info(`Wrote ${r.length} file location(s) to commands API ✅`);
|
|
10276
10848
|
} catch (a) {
|
|
10277
10849
|
const i = [...r, ...this._pendingItems];
|
|
10278
|
-
throw this._pendingItems = i, await
|
|
10850
|
+
throw this._pendingItems = i, await Re({ spaceId: e, items: i }), a;
|
|
10279
10851
|
}
|
|
10280
10852
|
}
|
|
10281
10853
|
async _postFssBatch(t, e) {
|
|
10282
|
-
const o = this._legacy ? `${this._gatewayUrl}${
|
|
10854
|
+
const o = this._legacy ? `${this._gatewayUrl}${Wt}?blob=true` : `${this._gatewayUrl}${Wt}`;
|
|
10283
10855
|
let r;
|
|
10284
10856
|
try {
|
|
10285
10857
|
r = await this._auth.authenticatedFetch(o, {
|
|
@@ -10309,16 +10881,16 @@ WHERE {
|
|
|
10309
10881
|
* shown to the user before or after calling {@link sync}.
|
|
10310
10882
|
*/
|
|
10311
10883
|
async scanCost(t) {
|
|
10312
|
-
if (
|
|
10884
|
+
if (Y || (Y = Wa()), await Y, !F) throw new Error("WASM scan function not initialised");
|
|
10313
10885
|
const e = 200, o = /* @__PURE__ */ new Map();
|
|
10314
10886
|
for (let r = 0; r < t.length; r += e) {
|
|
10315
10887
|
const a = t.slice(r, r + e), i = await Promise.all(
|
|
10316
10888
|
a.map(async (p) => ({
|
|
10317
10889
|
originalPath: p.relativePath,
|
|
10318
10890
|
// Use pre-loaded data if available (browser), otherwise read from disk (Node.js).
|
|
10319
|
-
data: p.data ?? new Uint8Array(await
|
|
10891
|
+
data: p.data ?? new Uint8Array(await Ie(p.fullPath))
|
|
10320
10892
|
}))
|
|
10321
|
-
), n =
|
|
10893
|
+
), n = F(i);
|
|
10322
10894
|
for (const p of n) {
|
|
10323
10895
|
const c = o.get(p.ext);
|
|
10324
10896
|
c ? (c.count += p.count, c.units += p.units, c.sizeMb += p.sizeMb) : o.set(p.ext, { ...p });
|
|
@@ -10348,7 +10920,7 @@ WHERE {
|
|
|
10348
10920
|
console.info(`[computeCredits] all resolved — ${p.length} ext(s), creditsAvailable: ${h.creditsAvailable}`);
|
|
10349
10921
|
let d = 0;
|
|
10350
10922
|
for (const u of p) {
|
|
10351
|
-
const
|
|
10923
|
+
const m = c[r]?.[u.ext] ?? 1, g = u.units * m;
|
|
10352
10924
|
d += g, u.credits = Math.round(g);
|
|
10353
10925
|
}
|
|
10354
10926
|
return {
|
|
@@ -10376,15 +10948,17 @@ WHERE {
|
|
|
10376
10948
|
const { spaceId: o, providerId: r, userId: a, signal: i, onProgress: n } = e;
|
|
10377
10949
|
if (!t.data)
|
|
10378
10950
|
throw new Error("syncBrowserFile requires file.data (Uint8Array). Read the file with File.arrayBuffer() first.");
|
|
10379
|
-
const p =
|
|
10951
|
+
const p = ke(t.relativePath, o, a, t.md5, r);
|
|
10380
10952
|
if (!p.blob_name) throw new Error(`blob_name missing for ${t.relativePath}`);
|
|
10381
|
-
|
|
10953
|
+
let c = this._gzipEnabledBySpace.get(o);
|
|
10954
|
+
c === void 0 && (c = (await this._projects.getProject(o))?.projectSettings?.gzipEnabled ?? !1), await this._blob.uploadRaw(
|
|
10382
10955
|
p.blob_name,
|
|
10383
10956
|
t.data,
|
|
10384
10957
|
p,
|
|
10385
10958
|
3,
|
|
10386
10959
|
i,
|
|
10387
|
-
n
|
|
10960
|
+
n,
|
|
10961
|
+
c
|
|
10388
10962
|
), await this._queueFileLocation(
|
|
10389
10963
|
{ relativePath: t.relativePath, md5: t.md5, size: t.size, providerId: r, fileContentExists: !1 }
|
|
10390
10964
|
);
|
|
@@ -10429,7 +11003,7 @@ WHERE {
|
|
|
10429
11003
|
a({ percent: i, syncCount: t, totalCount: e, syncSize: o, totalSize: r });
|
|
10430
11004
|
}
|
|
10431
11005
|
}
|
|
10432
|
-
const
|
|
11006
|
+
const Oe = {
|
|
10433
11007
|
production: {
|
|
10434
11008
|
gatewayUrl: "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app",
|
|
10435
11009
|
tokenUrl: "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app/token",
|
|
@@ -10449,7 +11023,7 @@ const be = {
|
|
|
10449
11023
|
firestoreEmulatorPort: 8080
|
|
10450
11024
|
}
|
|
10451
11025
|
};
|
|
10452
|
-
class
|
|
11026
|
+
class Ke {
|
|
10453
11027
|
auth;
|
|
10454
11028
|
signup;
|
|
10455
11029
|
api;
|
|
@@ -10461,7 +11035,7 @@ class Le {
|
|
|
10461
11035
|
privileges;
|
|
10462
11036
|
cache;
|
|
10463
11037
|
storage;
|
|
10464
|
-
currency = new
|
|
11038
|
+
currency = new ye();
|
|
10465
11039
|
_app;
|
|
10466
11040
|
_endpoints;
|
|
10467
11041
|
_isEmulator;
|
|
@@ -10482,7 +11056,7 @@ class Le {
|
|
|
10482
11056
|
* ```
|
|
10483
11057
|
*/
|
|
10484
11058
|
get gis() {
|
|
10485
|
-
return this._gis || (this._gis = new
|
|
11059
|
+
return this._gis || (this._gis = new Oa(
|
|
10486
11060
|
() => this.api.getAuthHeaders(),
|
|
10487
11061
|
this._endpoints.gatewayUrl
|
|
10488
11062
|
)), this._gis;
|
|
@@ -10491,32 +11065,34 @@ class Le {
|
|
|
10491
11065
|
!t.apiKey && !t.appId && !t.measurementId && console.warn(
|
|
10492
11066
|
"Using default SDK app settings. Contact QAECY for your own configuration for any production code."
|
|
10493
11067
|
);
|
|
10494
|
-
const o = t.apiKey ??
|
|
10495
|
-
this._endpoints = { ...
|
|
11068
|
+
const o = t.apiKey ?? st.apiKey, r = t.appId ?? st.appId, a = t.measurementId ?? st.measurementId, i = t.environment ?? "production";
|
|
11069
|
+
this._endpoints = { ...Oe[i], ...t.endpoints }, this._isEmulator = i === "emulator", this._verbose = t.verbose ?? !1;
|
|
11070
|
+
const n = i === "production" ? "[DEFAULT]" : `cue-${i}`;
|
|
11071
|
+
this._app = Je().find((m) => m.name === n) ?? Ze({
|
|
10496
11072
|
apiKey: o,
|
|
10497
11073
|
appId: r,
|
|
10498
11074
|
measurementId: a,
|
|
10499
|
-
authDomain: `${
|
|
10500
|
-
projectId:
|
|
10501
|
-
messagingSenderId:
|
|
10502
|
-
}), this.auth = new
|
|
10503
|
-
const
|
|
10504
|
-
this._isEmulator && (
|
|
10505
|
-
const
|
|
11075
|
+
authDomain: `${Pt}.firebaseapp.com`,
|
|
11076
|
+
projectId: Pt,
|
|
11077
|
+
messagingSenderId: qo
|
|
11078
|
+
}, n), this.auth = new Kt(this._app, this._isEmulator, this._endpoints), this.signup = new Yt(this._endpoints.gatewayUrl), this.projects = new le(this.auth, this._app, this._isEmulator, this._endpoints), this._storageRaw = k(this._app, jt), this._storageProcessed = k(this._app, Lt);
|
|
11079
|
+
const p = k(this._app, Mt), c = k(this._app, Ut), h = k(this._app, Nt), d = k(this._app, qt), u = k(this._app, Dt);
|
|
11080
|
+
this._isEmulator && (H(this._storageRaw, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), H(this._storageProcessed, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), H(p, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort));
|
|
11081
|
+
const w = new q({
|
|
10506
11082
|
storageRaw: this._storageRaw,
|
|
10507
11083
|
storageProcessed: this._storageProcessed,
|
|
10508
|
-
storagePublic:
|
|
10509
|
-
storageLogs:
|
|
10510
|
-
storageChatSessions:
|
|
10511
|
-
storagePersistence:
|
|
10512
|
-
storageSessions:
|
|
11084
|
+
storagePublic: p,
|
|
11085
|
+
storageLogs: c,
|
|
11086
|
+
storageChatSessions: h,
|
|
11087
|
+
storagePersistence: d,
|
|
11088
|
+
storageSessions: u
|
|
10513
11089
|
});
|
|
10514
|
-
this.api = this._buildApi(this.projects,
|
|
11090
|
+
this.api = this._buildApi(this.projects, w), this.storage = new Qt(this.auth, this._endpoints.gatewayUrl), this.profile = new he(
|
|
10515
11091
|
this.auth,
|
|
10516
11092
|
this._app,
|
|
10517
11093
|
this._isEmulator,
|
|
10518
11094
|
this._endpoints.gatewayUrl
|
|
10519
|
-
), this.usageStats = new
|
|
11095
|
+
), this.usageStats = new de(this.auth, this._endpoints.gatewayUrl), this.api.sync?._bindProfile(this.profile), this.admin = new ue(this.auth, this._endpoints.gatewayUrl), this.privileges = new we(this.auth.isSuperAdmin), this._isEmulator && H(d, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), this.cache = new fe(d);
|
|
10520
11096
|
}
|
|
10521
11097
|
/**
|
|
10522
11098
|
* Create a `Cue` instance from an already-initialized Firebase app.
|
|
@@ -10535,20 +11111,20 @@ class Le {
|
|
|
10535
11111
|
* });
|
|
10536
11112
|
*/
|
|
10537
11113
|
static fromApp(t, e = {}) {
|
|
10538
|
-
const o = e.environment ?? "production", r = { ...
|
|
11114
|
+
const o = e.environment ?? "production", r = { ...Oe[o], ...e.endpoints }, a = new Kt(t, !1, r), i = new Yt(r.gatewayUrl), n = new le(a, t, !1, r), p = k(t, jt), c = k(t, Lt), h = k(t, Mt), d = k(t, Ut), u = k(t, Nt), w = k(t, qt), m = k(t, Dt), g = new q({
|
|
10539
11115
|
storageRaw: p,
|
|
10540
11116
|
storageProcessed: c,
|
|
10541
11117
|
storagePublic: h,
|
|
10542
11118
|
storageLogs: d,
|
|
10543
11119
|
storageChatSessions: u,
|
|
10544
|
-
storagePersistence:
|
|
10545
|
-
storageSessions:
|
|
10546
|
-
}),
|
|
10547
|
-
|
|
10548
|
-
const
|
|
10549
|
-
|
|
10550
|
-
const
|
|
10551
|
-
return Object.assign(
|
|
11120
|
+
storagePersistence: w,
|
|
11121
|
+
storageSessions: m
|
|
11122
|
+
}), y = new Ae(a, n, g, r.gatewayUrl), f = new oe(a, r.gatewayUrl, n, y, g);
|
|
11123
|
+
y._bindApi(f);
|
|
11124
|
+
const _ = new he(a, t, !1, r.gatewayUrl);
|
|
11125
|
+
y._bindProfile(_);
|
|
11126
|
+
const I = new de(a, r.gatewayUrl), v = new ue(a, r.gatewayUrl), C = Object.create(Ke.prototype), $ = new we(a.isSuperAdmin), E = new fe(w), R = new Qt(a, r.gatewayUrl), N = new ye();
|
|
11127
|
+
return Object.assign(C, {
|
|
10552
11128
|
_app: t,
|
|
10553
11129
|
_endpoints: r,
|
|
10554
11130
|
_isEmulator: o === "emulator",
|
|
@@ -10558,17 +11134,17 @@ class Le {
|
|
|
10558
11134
|
signup: i,
|
|
10559
11135
|
api: f,
|
|
10560
11136
|
projects: n,
|
|
10561
|
-
profile:
|
|
10562
|
-
usageStats:
|
|
10563
|
-
admin:
|
|
10564
|
-
privileges:
|
|
10565
|
-
cache:
|
|
10566
|
-
storage:
|
|
10567
|
-
currency:
|
|
10568
|
-
}),
|
|
11137
|
+
profile: _,
|
|
11138
|
+
usageStats: I,
|
|
11139
|
+
admin: v,
|
|
11140
|
+
privileges: $,
|
|
11141
|
+
cache: E,
|
|
11142
|
+
storage: R,
|
|
11143
|
+
currency: N
|
|
11144
|
+
}), C;
|
|
10569
11145
|
}
|
|
10570
11146
|
_buildApi(t, e) {
|
|
10571
|
-
const o = new
|
|
11147
|
+
const o = new Ae(this.auth, t, e, this._endpoints.gatewayUrl), r = new oe(this.auth, this._endpoints.gatewayUrl, t, o, e);
|
|
10572
11148
|
return o._bindApi(r), r;
|
|
10573
11149
|
}
|
|
10574
11150
|
/** Convenience: get the current user's Firebase ID token */
|
|
@@ -10590,7 +11166,7 @@ class Le {
|
|
|
10590
11166
|
* ```
|
|
10591
11167
|
*/
|
|
10592
11168
|
createProjectView(t, e) {
|
|
10593
|
-
return new
|
|
11169
|
+
return new za(this.api, t, { verbose: this._verbose, ...e });
|
|
10594
11170
|
}
|
|
10595
11171
|
/**
|
|
10596
11172
|
* Creates a `CueProjectEntities` instance for the given project, bound to the
|
|
@@ -10607,7 +11183,7 @@ class Le {
|
|
|
10607
11183
|
* ```
|
|
10608
11184
|
*/
|
|
10609
11185
|
createProjectEntities(t, e) {
|
|
10610
|
-
return new
|
|
11186
|
+
return new Ve(
|
|
10611
11187
|
this.api,
|
|
10612
11188
|
t,
|
|
10613
11189
|
e?.rdfBase,
|
|
@@ -10631,7 +11207,7 @@ class Le {
|
|
|
10631
11207
|
const r = this._projectDocuments.get(t);
|
|
10632
11208
|
if (r)
|
|
10633
11209
|
return r.setLanguage(this.api.language), r;
|
|
10634
|
-
const a = new
|
|
11210
|
+
const a = new vt(
|
|
10635
11211
|
this.api,
|
|
10636
11212
|
t,
|
|
10637
11213
|
this.api.language,
|
|
@@ -10641,7 +11217,7 @@ class Le {
|
|
|
10641
11217
|
);
|
|
10642
11218
|
return this._projectDocuments.set(t, a), a;
|
|
10643
11219
|
}
|
|
10644
|
-
return new
|
|
11220
|
+
return new vt(
|
|
10645
11221
|
this.api,
|
|
10646
11222
|
t,
|
|
10647
11223
|
e?.language ?? this.api.language,
|
|
@@ -10651,8 +11227,8 @@ class Le {
|
|
|
10651
11227
|
);
|
|
10652
11228
|
}
|
|
10653
11229
|
}
|
|
10654
|
-
const
|
|
10655
|
-
class
|
|
11230
|
+
const ut = "https://qlever.cs.uni-freiburg.de/materializedView/", L = b.qcy;
|
|
11231
|
+
class ci {
|
|
10656
11232
|
constructor(t, e, o) {
|
|
10657
11233
|
this._api = t, this._projectId = e, this._graphType = o;
|
|
10658
11234
|
}
|
|
@@ -10676,7 +11252,7 @@ class Xa {
|
|
|
10676
11252
|
this._api.sparql(this._buildViewDimQuery("mime", e), this._projectId, this._graphType),
|
|
10677
11253
|
this._api.sparql(this._buildViewDimQuery("content", e), this._projectId, this._graphType),
|
|
10678
11254
|
this._api.sparql(this._buildViewDimQuery("entity", e), this._projectId, this._graphType)
|
|
10679
|
-
]), h =
|
|
11255
|
+
]), h = Pe(n, p, c);
|
|
10680
11256
|
if (h.mimes.length + h.contents.length + h.entityCategories.length > 0)
|
|
10681
11257
|
return h;
|
|
10682
11258
|
console.warn(
|
|
@@ -10689,7 +11265,7 @@ class Xa {
|
|
|
10689
11265
|
this._api.sparql(this._buildLiveDimQuery("content", e), this._projectId, this._graphType),
|
|
10690
11266
|
this._api.sparql(this._buildLiveDimQuery("entity", e), this._projectId, this._graphType)
|
|
10691
11267
|
]);
|
|
10692
|
-
return
|
|
11268
|
+
return Pe(r, a, i);
|
|
10693
11269
|
}
|
|
10694
11270
|
/**
|
|
10695
11271
|
* Lists the *specific* entities (e.g. "John Doe") of a given entity category
|
|
@@ -10701,8 +11277,8 @@ class Xa {
|
|
|
10701
11277
|
* list shrinks as other filters are added.
|
|
10702
11278
|
*/
|
|
10703
11279
|
async availableEntities(t, e) {
|
|
10704
|
-
const r =
|
|
10705
|
-
`), a = `PREFIX qcy: <${
|
|
11280
|
+
const r = $e(e ?? {}).join(`
|
|
11281
|
+
`), a = `PREFIX qcy: <${L}>
|
|
10706
11282
|
SELECT DISTINCT ?entity ?val
|
|
10707
11283
|
WHERE {
|
|
10708
11284
|
{
|
|
@@ -10719,7 +11295,7 @@ WHERE {
|
|
|
10719
11295
|
ORDER BY ?val`, i = await this._api.sparql(a, this._projectId, this._graphType), n = /* @__PURE__ */ new Set(), p = [];
|
|
10720
11296
|
for (const c of i.results.bindings) {
|
|
10721
11297
|
const h = c.entity?.value;
|
|
10722
|
-
!h || n.has(h) || (n.add(h), p.push({ iri: h, label: c.val?.value ??
|
|
11298
|
+
!h || n.has(h) || (n.add(h), p.push({ iri: h, label: c.val?.value ?? Ye(h) }));
|
|
10723
11299
|
}
|
|
10724
11300
|
return p;
|
|
10725
11301
|
}
|
|
@@ -10745,16 +11321,16 @@ ORDER BY ?val`, i = await this._api.sparql(a, this._projectId, this._graphType),
|
|
|
10745
11321
|
// ── Private query builders ──────────────────────────────────────────────────
|
|
10746
11322
|
/** Single-dimension available-filters query using the dimension-specific views. */
|
|
10747
11323
|
_buildViewDimQuery(t, e) {
|
|
10748
|
-
const o = t === "mime" ? "doc-mime-cats" : t === "content" ? "doc-content-cats" : "doc-entity-cats", r = t === "mime" ? "?mimeCat" : t === "content" ? "?contentCat" : "?entityCat", a =
|
|
10749
|
-
return a.length === 0 ? `PREFIX view: <${
|
|
11324
|
+
const o = t === "mime" ? "doc-mime-cats" : t === "content" ? "doc-content-cats" : "doc-entity-cats", r = t === "mime" ? "?mimeCat" : t === "content" ? "?contentCat" : "?entityCat", a = Ka(e);
|
|
11325
|
+
return a.length === 0 ? `PREFIX view: <${ut}>
|
|
10750
11326
|
SELECT DISTINCT ${r}
|
|
10751
11327
|
WHERE {
|
|
10752
11328
|
SERVICE view:${o} {
|
|
10753
11329
|
_:cfg view:column-doc ?doc ;
|
|
10754
11330
|
view:column-cat ${r} .
|
|
10755
11331
|
}
|
|
10756
|
-
}` : `PREFIX view: <${
|
|
10757
|
-
PREFIX qcy: <${
|
|
11332
|
+
}` : `PREFIX view: <${ut}>
|
|
11333
|
+
PREFIX qcy: <${L}>
|
|
10758
11334
|
SELECT DISTINCT ${r}
|
|
10759
11335
|
WHERE {
|
|
10760
11336
|
{
|
|
@@ -10771,9 +11347,9 @@ WHERE {
|
|
|
10771
11347
|
}
|
|
10772
11348
|
/** Single-dimension available-filters query using live triple patterns. */
|
|
10773
11349
|
_buildLiveDimQuery(t, e) {
|
|
10774
|
-
const r =
|
|
11350
|
+
const r = $e(e).join(`
|
|
10775
11351
|
`);
|
|
10776
|
-
return `PREFIX qcy: <${
|
|
11352
|
+
return `PREFIX qcy: <${L}>
|
|
10777
11353
|
SELECT DISTINCT ${t === "mime" ? "?mimeCat" : t === "content" ? "?contentCat" : "?entityCat"}
|
|
10778
11354
|
WHERE {
|
|
10779
11355
|
{
|
|
@@ -10809,8 +11385,8 @@ WHERE {
|
|
|
10809
11385
|
o.type === "entity" ? e.push(`FILTER NOT EXISTS { ?doc qcy:about ?excE . ?excE qcy:hasEntityCategory <${i}> }`) : o.type === "mime" ? e.push(`FILTER NOT EXISTS { ?doc qcy:hasMimeCategory <${i}> }`) : e.push(`FILTER NOT EXISTS { ?doc qcy:hasContentCategory <${i}> }`);
|
|
10810
11386
|
}
|
|
10811
11387
|
if (e.length === 0) throw new Error("no view filter clauses");
|
|
10812
|
-
return `PREFIX view: <${
|
|
10813
|
-
PREFIX qcy: <${
|
|
11388
|
+
return `PREFIX view: <${ut}>
|
|
11389
|
+
PREFIX qcy: <${L}>
|
|
10814
11390
|
SELECT DISTINCT ?id
|
|
10815
11391
|
WHERE {
|
|
10816
11392
|
${e.join(`
|
|
@@ -10862,7 +11438,7 @@ WHERE {
|
|
|
10862
11438
|
e.push(`FILTER NOT EXISTS { ?doc qcy:hasContentCategory <${r}> }`);
|
|
10863
11439
|
}
|
|
10864
11440
|
}
|
|
10865
|
-
return `PREFIX qcy: <${
|
|
11441
|
+
return `PREFIX qcy: <${L}>
|
|
10866
11442
|
SELECT DISTINCT ?id
|
|
10867
11443
|
WHERE {
|
|
10868
11444
|
?doc a qcy:FileContent .
|
|
@@ -10873,7 +11449,7 @@ WHERE {
|
|
|
10873
11449
|
}`;
|
|
10874
11450
|
}
|
|
10875
11451
|
}
|
|
10876
|
-
function
|
|
11452
|
+
function Ka(s) {
|
|
10877
11453
|
const t = [];
|
|
10878
11454
|
for (const e of s.entities ?? [])
|
|
10879
11455
|
t.push(`?doc qcy:about <${e}> .`);
|
|
@@ -10891,7 +11467,7 @@ function Ra(s) {
|
|
|
10891
11467
|
}
|
|
10892
11468
|
return t;
|
|
10893
11469
|
}
|
|
10894
|
-
function
|
|
11470
|
+
function $e(s) {
|
|
10895
11471
|
const t = [];
|
|
10896
11472
|
for (const e of s.entities ?? [])
|
|
10897
11473
|
t.push(`?doc qcy:about <${e}> .`);
|
|
@@ -10918,15 +11494,15 @@ function ve(s) {
|
|
|
10918
11494
|
}
|
|
10919
11495
|
return t;
|
|
10920
11496
|
}
|
|
10921
|
-
function
|
|
11497
|
+
function Ye(s) {
|
|
10922
11498
|
return s.split("#").pop()?.split("/").pop() ?? s;
|
|
10923
11499
|
}
|
|
10924
|
-
function
|
|
11500
|
+
function Pe(s, t, e) {
|
|
10925
11501
|
const o = (r, a) => {
|
|
10926
11502
|
const i = /* @__PURE__ */ new Set(), n = [];
|
|
10927
11503
|
for (const p of r) {
|
|
10928
11504
|
const c = p[a]?.value;
|
|
10929
|
-
c && !i.has(c) && (i.add(c), n.push({ iri: c, label:
|
|
11505
|
+
c && !i.has(c) && (i.add(c), n.push({ iri: c, label: Ye(c) }));
|
|
10930
11506
|
}
|
|
10931
11507
|
return n;
|
|
10932
11508
|
};
|
|
@@ -10937,41 +11513,43 @@ function _e(s, t, e) {
|
|
|
10937
11513
|
};
|
|
10938
11514
|
}
|
|
10939
11515
|
export {
|
|
10940
|
-
|
|
10941
|
-
|
|
10942
|
-
|
|
10943
|
-
|
|
10944
|
-
|
|
10945
|
-
|
|
10946
|
-
|
|
10947
|
-
|
|
10948
|
-
|
|
10949
|
-
|
|
10950
|
-
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
|
|
10955
|
-
|
|
10956
|
-
|
|
10957
|
-
|
|
10958
|
-
|
|
10959
|
-
|
|
10960
|
-
|
|
10961
|
-
|
|
10962
|
-
|
|
10963
|
-
|
|
10964
|
-
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
10969
|
-
|
|
10970
|
-
|
|
10971
|
-
|
|
10972
|
-
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
|
|
11516
|
+
Ns as A,
|
|
11517
|
+
ni as B,
|
|
11518
|
+
Ke as C,
|
|
11519
|
+
Yt as D,
|
|
11520
|
+
T as E,
|
|
11521
|
+
Qt as F,
|
|
11522
|
+
Ae as G,
|
|
11523
|
+
cs as H,
|
|
11524
|
+
Ss as I,
|
|
11525
|
+
pi as J,
|
|
11526
|
+
Tt as K,
|
|
11527
|
+
me as R,
|
|
11528
|
+
ii as S,
|
|
11529
|
+
ue as a,
|
|
11530
|
+
oe as b,
|
|
11531
|
+
Es as c,
|
|
11532
|
+
Ts as d,
|
|
11533
|
+
Kt as e,
|
|
11534
|
+
fe as f,
|
|
11535
|
+
ds as g,
|
|
11536
|
+
ye as h,
|
|
11537
|
+
Ps as i,
|
|
11538
|
+
ks as j,
|
|
11539
|
+
ci as k,
|
|
11540
|
+
hs as l,
|
|
11541
|
+
Oa as m,
|
|
11542
|
+
Ds as n,
|
|
11543
|
+
us as o,
|
|
11544
|
+
Os as p,
|
|
11545
|
+
bs as q,
|
|
11546
|
+
we as r,
|
|
11547
|
+
Cs as s,
|
|
11548
|
+
he as t,
|
|
11549
|
+
vt as u,
|
|
11550
|
+
Ve as v,
|
|
11551
|
+
La as w,
|
|
11552
|
+
za as x,
|
|
11553
|
+
le as y,
|
|
11554
|
+
as as z
|
|
10977
11555
|
};
|