@qaecy/cue-sdk 0.0.30 → 0.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser.js +37643 -0
- package/{cue-DWCLcFvj.js → cue-C7sbHLj4.js} +693 -464
- package/index.d.ts +5 -1
- package/index.js +19 -17
- package/lib/api.d.ts +6 -0
- package/lib/contexts.d.ts +17 -0
- package/lib/entities.d.ts +7 -0
- package/lib/index-api.d.ts +11 -0
- package/lib/models.d.ts +63 -0
- package/lib/schema.d.ts +30 -16
- package/lib/storage.d.ts +26 -10
- package/node.js +41 -38
- package/package.json +1 -1
- package/variables.d.ts +6 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getApps as
|
|
2
|
-
import { ref as
|
|
3
|
-
import { Writer as
|
|
4
|
-
import { getFirestore as
|
|
5
|
-
import { getAuth as
|
|
6
|
-
import { v5 as
|
|
1
|
+
import { getApps as xe, initializeApp as Ce } from "firebase/app";
|
|
2
|
+
import { ref as k, getDownloadURL as X, getMetadata as z, getBlob as ne, updateMetadata as Ie, uploadBytesResumable as ft, uploadBytes as st, StringFormat as Se, uploadString as Te, listAll as U, getStorage as C, connectStorageEmulator as K } from "firebase/storage";
|
|
3
|
+
import { Writer as Re, DataFactory as j } from "n3";
|
|
4
|
+
import { getFirestore as Ae, connectFirestoreEmulator as Pe, collection as yt, getDocs as Oe, query as De, where as Le, limit as qe, doc as bt, getDoc as je, setDoc as $e, serverTimestamp as ze, increment as Ue } from "firebase/firestore";
|
|
5
|
+
import { getAuth as Me, connectAuthEmulator as Ne, onIdTokenChanged as Fe, getIdTokenResult as at, signInWithEmailAndPassword as Be, GoogleAuthProvider as it, OAuthProvider as nt, signInWithPopup as Ge, signInWithRedirect as He, getRedirectResult as We, signInWithCustomToken as vt, signOut as Ve, onAuthStateChanged as Xe, fetchSignInMethodsForEmail as Ke, linkWithPopup as Qe, unlink as Ye, reauthenticateWithCredential as _t, EmailAuthProvider as Q, updatePassword as Ze, linkWithCredential as Je, verifyBeforeUpdateEmail as to, sendEmailVerification as eo } from "firebase/auth";
|
|
6
|
+
import { v5 as oo } from "uuid";
|
|
7
7
|
import "spark-md5";
|
|
8
|
-
import { getFunctions as
|
|
8
|
+
import { getFunctions as pe, connectFunctionsEmulator as ce, httpsCallable as F } from "firebase/functions";
|
|
9
9
|
class ht {
|
|
10
10
|
queryEndpoint;
|
|
11
11
|
updateEndpoint;
|
|
@@ -86,7 +86,7 @@ class Y extends Error {
|
|
|
86
86
|
super(`QLever is locked (rebuild in progress): ${t}`), this.name = "QLeverLockedError";
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
class
|
|
89
|
+
class A {
|
|
90
90
|
queryEndpoint;
|
|
91
91
|
updateEndpoint;
|
|
92
92
|
dataEndpoint;
|
|
@@ -113,7 +113,7 @@ class R {
|
|
|
113
113
|
* 423 means qlever accessor has an ongoing rebuild; we should wait and retry.
|
|
114
114
|
*/
|
|
115
115
|
static async _retryOnLocked(t) {
|
|
116
|
-
const e =
|
|
116
|
+
const e = A.LOCKED_MAX_RETRIES, o = A.LOCKED_BASE_DELAY_MS;
|
|
117
117
|
let r;
|
|
118
118
|
for (let s = 0; s <= e; s++)
|
|
119
119
|
try {
|
|
@@ -131,7 +131,7 @@ class R {
|
|
|
131
131
|
constructor(t) {
|
|
132
132
|
this.queryEndpoint = t.queryEndpoint, this.updateEndpoint = t.updateEndpoint, this.dataEndpoint = this.updateEndpoint.replace(/\/update$/, "/data"), this.baseHeaders = Object.fromEntries(
|
|
133
133
|
Object.entries(t.originalHeaders || {}).filter(
|
|
134
|
-
([e]) =>
|
|
134
|
+
([e]) => A.RELEVANT_HEADER_KEYS.includes(e)
|
|
135
135
|
)
|
|
136
136
|
), this.baseHeaders["x-user-roles"] = "admin";
|
|
137
137
|
}
|
|
@@ -173,7 +173,7 @@ class R {
|
|
|
173
173
|
})).text();
|
|
174
174
|
}
|
|
175
175
|
async update(t) {
|
|
176
|
-
return
|
|
176
|
+
return A._retryOnLocked(async () => {
|
|
177
177
|
const e = await fetch(this.updateEndpoint, {
|
|
178
178
|
headers: {
|
|
179
179
|
...this.baseHeaders,
|
|
@@ -204,8 +204,8 @@ class R {
|
|
|
204
204
|
await this._postToDataEndpoint(t, `${this.dataEndpoint}/delete`);
|
|
205
205
|
}
|
|
206
206
|
async _postToDataEndpoint(t, e) {
|
|
207
|
-
const o = await this._quadsToNQuads(t), r = await
|
|
208
|
-
await
|
|
207
|
+
const o = await this._quadsToNQuads(t), r = await ro(Buffer.from(o, "utf-8"));
|
|
208
|
+
await A._retryOnLocked(async () => {
|
|
209
209
|
const s = await fetch(e, {
|
|
210
210
|
method: "POST",
|
|
211
211
|
headers: {
|
|
@@ -223,12 +223,12 @@ class R {
|
|
|
223
223
|
}
|
|
224
224
|
_quadsToNQuads(t) {
|
|
225
225
|
return new Promise((e, o) => {
|
|
226
|
-
const r = new
|
|
226
|
+
const r = new Re({ format: "application/n-quads" });
|
|
227
227
|
r.addQuads(t), r.end((s, a) => s ? o(s) : e(a));
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
async function
|
|
231
|
+
async function ro(i) {
|
|
232
232
|
const t = new CompressionStream("gzip"), e = t.writable.getWriter();
|
|
233
233
|
e.write(new Uint8Array(i)), e.close();
|
|
234
234
|
const o = [], r = t.readable.getReader();
|
|
@@ -243,11 +243,11 @@ async function Ze(i) {
|
|
|
243
243
|
a.set(p, n), n += p.byteLength;
|
|
244
244
|
return a.buffer;
|
|
245
245
|
}
|
|
246
|
-
class
|
|
246
|
+
class so {
|
|
247
247
|
constructor(t) {
|
|
248
248
|
switch (this.options = t, this.options.graphType) {
|
|
249
249
|
case "qlever":
|
|
250
|
-
this._db = new
|
|
250
|
+
this._db = new A(this.options);
|
|
251
251
|
break;
|
|
252
252
|
case "fuseki":
|
|
253
253
|
this._db = new ht(this.options);
|
|
@@ -298,7 +298,7 @@ class Je {
|
|
|
298
298
|
return this.options.graphType === "qlever" ? this._db.deleteData(t) : Promise.reject(new Error("deleteData not supported for Fuseki — use update() with SPARQL DELETE DATA"));
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
|
-
class
|
|
301
|
+
class Et {
|
|
302
302
|
constructor(t) {
|
|
303
303
|
this.options = t;
|
|
304
304
|
}
|
|
@@ -320,14 +320,16 @@ class kt {
|
|
|
320
320
|
return this.options.storagePublic;
|
|
321
321
|
case "persistence":
|
|
322
322
|
return this.options.storagePersistence;
|
|
323
|
+
case "sessions":
|
|
324
|
+
return this.options.storageSessions;
|
|
323
325
|
}
|
|
324
326
|
}
|
|
325
327
|
// ─── Downloads ────────────────────────────────────────────────────────────
|
|
326
328
|
/** Get an authenticated download URL. Returns undefined if the file does not exist. */
|
|
327
329
|
async getDownloadURL(t, e) {
|
|
328
|
-
const o =
|
|
330
|
+
const o = k(this._bucket(t), e);
|
|
329
331
|
try {
|
|
330
|
-
return await
|
|
332
|
+
return await X(o);
|
|
331
333
|
} catch (r) {
|
|
332
334
|
if (r?.code === "storage/object-not-found") return;
|
|
333
335
|
throw r;
|
|
@@ -340,10 +342,10 @@ class kt {
|
|
|
340
342
|
async getCacheBustedUrl(t, e) {
|
|
341
343
|
const o = `${t}:${e}`;
|
|
342
344
|
if (this._knownMissing.has(o)) return;
|
|
343
|
-
const r =
|
|
345
|
+
const r = k(this._bucket(t), e);
|
|
344
346
|
try {
|
|
345
347
|
const s = await z(r);
|
|
346
|
-
return `${await
|
|
348
|
+
return `${await X(r)}&t=${encodeURIComponent(s.updated)}`;
|
|
347
349
|
} catch (s) {
|
|
348
350
|
if (s?.code === "storage/object-not-found" || s?.status === 404) {
|
|
349
351
|
this._knownMissing.add(o), console.debug(`[CueBlobStorage] ${e} not found (404 OK — optional cache file)`);
|
|
@@ -354,9 +356,9 @@ class kt {
|
|
|
354
356
|
}
|
|
355
357
|
/** Download a file as a Blob. Returns undefined if the file does not exist. */
|
|
356
358
|
async getFile(t, e) {
|
|
357
|
-
const o =
|
|
359
|
+
const o = k(this._bucket(t), e);
|
|
358
360
|
try {
|
|
359
|
-
return await
|
|
361
|
+
return await ne(o);
|
|
360
362
|
} catch (r) {
|
|
361
363
|
if (r?.code === "storage/object-not-found") return;
|
|
362
364
|
throw r;
|
|
@@ -371,7 +373,7 @@ class kt {
|
|
|
371
373
|
* Uses a cache-busted URL to ensure the latest version is fetched.
|
|
372
374
|
*/
|
|
373
375
|
async downloadPublic(t) {
|
|
374
|
-
const e =
|
|
376
|
+
const e = k(this.options.storagePublic, t), o = new AbortController(), r = setTimeout(() => o.abort(), 1e4), s = (a) => Promise.race([
|
|
375
377
|
a,
|
|
376
378
|
new Promise((n, p) => {
|
|
377
379
|
o.signal.addEventListener(
|
|
@@ -382,7 +384,7 @@ class kt {
|
|
|
382
384
|
]);
|
|
383
385
|
try {
|
|
384
386
|
const [a, n] = await Promise.all([
|
|
385
|
-
s(
|
|
387
|
+
s(X(e)),
|
|
386
388
|
s(z(e))
|
|
387
389
|
]), p = `${a}&t=${encodeURIComponent(n.updated)}`, c = await fetch(p, { signal: o.signal });
|
|
388
390
|
if (!c.ok) throw new Error(`HTTP ${c.status}`);
|
|
@@ -397,7 +399,7 @@ class kt {
|
|
|
397
399
|
// ─── Metadata ─────────────────────────────────────────────────────────────
|
|
398
400
|
/** Read file metadata. Returns undefined if the file does not exist. */
|
|
399
401
|
async getMetadata(t, e) {
|
|
400
|
-
const o =
|
|
402
|
+
const o = k(this._bucket(t), e);
|
|
401
403
|
try {
|
|
402
404
|
const r = await z(o);
|
|
403
405
|
return {
|
|
@@ -413,8 +415,8 @@ class kt {
|
|
|
413
415
|
}
|
|
414
416
|
/** Update custom metadata on an existing file. */
|
|
415
417
|
async setMetadata(t, e, o) {
|
|
416
|
-
const r =
|
|
417
|
-
await
|
|
418
|
+
const r = k(this._bucket(t), e);
|
|
419
|
+
await Ie(r, { customMetadata: o });
|
|
418
420
|
}
|
|
419
421
|
// ─── Uploads ──────────────────────────────────────────────────────────────
|
|
420
422
|
/**
|
|
@@ -423,7 +425,7 @@ class kt {
|
|
|
423
425
|
* upload progress needs to be surfaced in the UI.
|
|
424
426
|
*/
|
|
425
427
|
uploadResumable(t, e, o, r) {
|
|
426
|
-
const s =
|
|
428
|
+
const s = k(this._bucket(t), e), a = ft(s, o, r ? { customMetadata: r } : void 0);
|
|
427
429
|
return {
|
|
428
430
|
complete: () => new Promise((n, p) => a.then(() => n(), p)),
|
|
429
431
|
pause: () => a.pause(),
|
|
@@ -442,19 +444,19 @@ class kt {
|
|
|
442
444
|
* Use for small files where progress feedback is not needed.
|
|
443
445
|
*/
|
|
444
446
|
async uploadBytes(t, e, o, r) {
|
|
445
|
-
const s =
|
|
447
|
+
const s = k(this._bucket(t), e);
|
|
446
448
|
await st(s, o, r ? { customMetadata: r } : void 0);
|
|
447
449
|
}
|
|
448
450
|
/** Upload a string or base64-encoded value. */
|
|
449
|
-
async uploadString(t, e, o, r =
|
|
450
|
-
const a =
|
|
451
|
-
await
|
|
451
|
+
async uploadString(t, e, o, r = Se.RAW, s) {
|
|
452
|
+
const a = k(this._bucket(t), e);
|
|
453
|
+
await Te(a, o, r, s ? { customMetadata: s } : void 0);
|
|
452
454
|
}
|
|
453
455
|
// ─── Listing ──────────────────────────────────────────────────────────────
|
|
454
456
|
/** List all item names directly under `prefix` in the given bucket. */
|
|
455
457
|
async listFiles(t, e) {
|
|
456
|
-
const o =
|
|
457
|
-
return (await
|
|
458
|
+
const o = k(this._bucket(t), e);
|
|
459
|
+
return (await U(o)).items.map((s) => s.name);
|
|
458
460
|
}
|
|
459
461
|
/**
|
|
460
462
|
* Recursively list all file full-paths under `prefix` in the given bucket.
|
|
@@ -462,7 +464,7 @@ class kt {
|
|
|
462
464
|
*/
|
|
463
465
|
async listFilesRecursive(t, e) {
|
|
464
466
|
const o = this._bucket(t), r = async (s) => {
|
|
465
|
-
const a = await
|
|
467
|
+
const a = await U(k(o, s));
|
|
466
468
|
let n = a.items.map((p) => p.fullPath);
|
|
467
469
|
for (const p of a.prefixes)
|
|
468
470
|
n = n.concat(await r(p.fullPath));
|
|
@@ -478,7 +480,7 @@ class kt {
|
|
|
478
480
|
const { deleteObject: o } = await import("firebase/storage"), r = this._bucket(t);
|
|
479
481
|
let s = 0;
|
|
480
482
|
const a = async (n) => {
|
|
481
|
-
const p = await
|
|
483
|
+
const p = await U(k(r, n));
|
|
482
484
|
for (const c of p.items)
|
|
483
485
|
await o(c), s++;
|
|
484
486
|
for (const c of p.prefixes)
|
|
@@ -490,7 +492,7 @@ class kt {
|
|
|
490
492
|
// (used by loaders / processors that were already depending on CueBlobStorage)
|
|
491
493
|
/** Upload binary data to the raw bucket with retry logic. */
|
|
492
494
|
async uploadRaw(t, e, o, r = 3, s, a) {
|
|
493
|
-
const n =
|
|
495
|
+
const n = k(this.options.storageRaw, t);
|
|
494
496
|
let p = 0, c;
|
|
495
497
|
for (; p < r; )
|
|
496
498
|
try {
|
|
@@ -531,16 +533,16 @@ class kt {
|
|
|
531
533
|
* Skips upload and returns `false` if the blob already exists.
|
|
532
534
|
*/
|
|
533
535
|
async uploadProcessed(t, e, o) {
|
|
534
|
-
const r =
|
|
536
|
+
const r = k(this.options.storageProcessed, t);
|
|
535
537
|
return await z(r).catch(() => null) ? !1 : (await st(r, e, { customMetadata: o }), !0);
|
|
536
538
|
}
|
|
537
539
|
/** List all blob names directly under `prefix` in the raw bucket. */
|
|
538
540
|
async listRaw(t) {
|
|
539
|
-
const e =
|
|
540
|
-
return (await
|
|
541
|
+
const e = k(this.options.storageRaw, t);
|
|
542
|
+
return (await U(e)).items.map((r) => r.name);
|
|
541
543
|
}
|
|
542
544
|
}
|
|
543
|
-
const
|
|
545
|
+
const kt = {
|
|
544
546
|
ä: "ae",
|
|
545
547
|
ä: "ae",
|
|
546
548
|
Ä: "AE",
|
|
@@ -576,18 +578,18 @@ const Et = {
|
|
|
576
578
|
};
|
|
577
579
|
function D(i, t = !1) {
|
|
578
580
|
const e = "daca0510-72b5-48ba-9091-b918ca18136b";
|
|
579
|
-
return i =
|
|
581
|
+
return i = ao(i, t), oo(i, e);
|
|
580
582
|
}
|
|
581
|
-
function
|
|
583
|
+
function ao(i, t = !1) {
|
|
582
584
|
let e = i;
|
|
583
|
-
for (const o in
|
|
584
|
-
e = e.replace(new RegExp(o, "g"),
|
|
585
|
+
for (const o in kt)
|
|
586
|
+
e = e.replace(new RegExp(o, "g"), kt[o]);
|
|
585
587
|
return t && e !== i && console.info(`${i} -> ${e}`), e;
|
|
586
588
|
}
|
|
587
|
-
function
|
|
589
|
+
function io(i, t = "") {
|
|
588
590
|
return D(`${t}${i}`);
|
|
589
591
|
}
|
|
590
|
-
class
|
|
592
|
+
class x {
|
|
591
593
|
_value;
|
|
592
594
|
_listeners = /* @__PURE__ */ new Set();
|
|
593
595
|
constructor(t) {
|
|
@@ -646,13 +648,13 @@ const Z = {
|
|
|
646
648
|
apiKey: "AIzaSyAiW42QBx9HS4Khu88pCW7MV66IhBAQul0",
|
|
647
649
|
appId: "1:151132927589:web:d2ffdb377dfadfd23ab88c",
|
|
648
650
|
measurementId: "G-YT4PK6HGZD"
|
|
649
|
-
}, xt = "qaecy-mvp-406413",
|
|
650
|
-
class
|
|
651
|
+
}, xt = "qaecy-mvp-406413", no = "734737865998", le = "europe-west6", Ct = "projects", It = "sessions_eu_west6", St = "spaces_chats_eu_west6", Tt = "spaces_raw_eu_west6", Rt = "spaces_processed_eu_west6", At = "spaces_logs_eu_west6", Pt = "cue_public_eu_west6", Ot = "db_persistence_eu_west6", po = "/data-views/admin/consumption", co = "/data-views/admin/profile/organizations", Dt = "/data-views/admin/profile/api-keys", Lt = "/commands/admin/profile/api-keys", lo = "/commands/admin/profile/terms", ho = (i) => `/data-views/admin/organizations/${i}/members`, go = "/commands/admin/project", uo = (i) => `/commands/admin/project/${i}`, mo = "/assistant/search", wo = "/index/search", fo = "/index/lookup", he = "/triplestore/query", yo = "/triplestore/update", bo = "/triplestore/shacl", de = "/qlever-server/qlever/query", vo = "/qlever-server/qlever/update", _o = "/qlever-server/qlever/shacl", qt = "/commands/file-system-structure/batch", Eo = "/storage/sessions", ko = "/storage/raw", ge = "/storage/processed", jt = "microsoft.com", $t = "superadmin", ut = "https://cue.qaecy.com/r/";
|
|
652
|
+
class zt {
|
|
651
653
|
_auth;
|
|
652
654
|
_endpoints;
|
|
653
|
-
_userSignal = new
|
|
654
|
-
_tokenSignal = new
|
|
655
|
-
_isSuperAdminSignal = new
|
|
655
|
+
_userSignal = new x(null);
|
|
656
|
+
_tokenSignal = new x(null);
|
|
657
|
+
_isSuperAdminSignal = new x(!1);
|
|
656
658
|
_userIdsSignal;
|
|
657
659
|
_stopTokenListener;
|
|
658
660
|
/** Reactive auth state — emits the signed-in `User`, or `null` when signed out. */
|
|
@@ -664,19 +666,19 @@ class Ut {
|
|
|
664
666
|
/** All unique UIDs for the current user (Firebase UID + linked provider UIDs). */
|
|
665
667
|
userIds;
|
|
666
668
|
constructor(t, e = !1, o) {
|
|
667
|
-
this._auth =
|
|
669
|
+
this._auth = Me(t), this._endpoints = o, e && Ne(this._auth, o.authEmulatorUrl, {
|
|
668
670
|
disableWarnings: !0
|
|
669
671
|
}), this.user = this._userSignal.asReadonly(), this.token = this._tokenSignal.asReadonly(), this.isSuperAdmin = this._isSuperAdminSignal.asReadonly(), this._userIdsSignal = dt([this._userSignal], () => {
|
|
670
672
|
const r = this._userSignal.get();
|
|
671
673
|
if (!r) return [];
|
|
672
674
|
const s = /* @__PURE__ */ new Set([r.uid]);
|
|
673
675
|
return r.providerData.forEach((a) => s.add(a.uid)), Array.from(s);
|
|
674
|
-
}), this.userIds = this._userIdsSignal, this._stopTokenListener =
|
|
676
|
+
}), this.userIds = this._userIdsSignal, this._stopTokenListener = Fe(this._auth, async (r) => {
|
|
675
677
|
if (this._userSignal.set(r), r) {
|
|
676
678
|
const s = await r.getIdToken();
|
|
677
679
|
this._tokenSignal.set(s);
|
|
678
680
|
const a = await at(r);
|
|
679
|
-
this._isSuperAdminSignal.set(a.claims.role ===
|
|
681
|
+
this._isSuperAdminSignal.set(a.claims.role === $t);
|
|
680
682
|
} else
|
|
681
683
|
this._tokenSignal.set(null), this._isSuperAdminSignal.set(!1);
|
|
682
684
|
});
|
|
@@ -689,14 +691,14 @@ class Ut {
|
|
|
689
691
|
if (t === "password") {
|
|
690
692
|
if (!e)
|
|
691
693
|
throw new Error("credentials are required for password sign-in");
|
|
692
|
-
return (await
|
|
694
|
+
return (await Be(
|
|
693
695
|
this._auth,
|
|
694
696
|
e.email,
|
|
695
697
|
e.password
|
|
696
698
|
)).user;
|
|
697
699
|
}
|
|
698
|
-
const o = t === "google" ? new it() : new nt(
|
|
699
|
-
return (await
|
|
700
|
+
const o = t === "google" ? new it() : new nt(jt);
|
|
701
|
+
return (await Ge(this._auth, o)).user;
|
|
700
702
|
}
|
|
701
703
|
/**
|
|
702
704
|
* Initiate a redirect-based sign-in (mobile / iframe contexts where popups
|
|
@@ -704,8 +706,8 @@ class Ut {
|
|
|
704
706
|
* retrieve the result.
|
|
705
707
|
*/
|
|
706
708
|
async signInWithRedirect(t) {
|
|
707
|
-
const e = t === "google" ? new it() : new nt(
|
|
708
|
-
await
|
|
709
|
+
const e = t === "google" ? new it() : new nt(jt);
|
|
710
|
+
await He(this._auth, e);
|
|
709
711
|
}
|
|
710
712
|
/**
|
|
711
713
|
* Retrieve the result of a redirect sign-in. Returns the signed-in `User`
|
|
@@ -713,7 +715,7 @@ class Ut {
|
|
|
713
715
|
* Call this once on app startup before showing a sign-in UI.
|
|
714
716
|
*/
|
|
715
717
|
async checkRedirectResult() {
|
|
716
|
-
return (await
|
|
718
|
+
return (await We(this._auth))?.user ?? null;
|
|
717
719
|
}
|
|
718
720
|
/**
|
|
719
721
|
* One-shot async check — returns `true` if the current user has the
|
|
@@ -722,7 +724,7 @@ class Ut {
|
|
|
722
724
|
*/
|
|
723
725
|
async checkSuperAdmin() {
|
|
724
726
|
const t = this._auth.currentUser;
|
|
725
|
-
return t ? (await at(t)).claims.role ===
|
|
727
|
+
return t ? (await at(t)).claims.role === $t : !1;
|
|
726
728
|
}
|
|
727
729
|
/** Sign in with a Cue API key. `projectId` is optional — omit it when no project context is available (e.g. admin flows). */
|
|
728
730
|
async signInWithApiKey(t, e) {
|
|
@@ -743,7 +745,7 @@ class Ut {
|
|
|
743
745
|
}
|
|
744
746
|
/** Sign out the current user */
|
|
745
747
|
async signOut() {
|
|
746
|
-
await
|
|
748
|
+
await Ve(this._auth);
|
|
747
749
|
}
|
|
748
750
|
/**
|
|
749
751
|
* Register a new user by name and email.
|
|
@@ -773,7 +775,7 @@ class Ut {
|
|
|
773
775
|
}
|
|
774
776
|
/** Subscribe to authentication state changes. Returns an unsubscribe function. */
|
|
775
777
|
onAuthStateChanged(t) {
|
|
776
|
-
return
|
|
778
|
+
return Xe(this._auth, t);
|
|
777
779
|
}
|
|
778
780
|
/** Get the Firebase ID token for the current user, or null if not authenticated */
|
|
779
781
|
async getToken(t = !1) {
|
|
@@ -805,29 +807,33 @@ class Ut {
|
|
|
805
807
|
return this._auth;
|
|
806
808
|
}
|
|
807
809
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
810
|
+
const xo = {
|
|
811
|
+
raw: ko,
|
|
812
|
+
processed: ge
|
|
813
|
+
};
|
|
814
|
+
class Ut {
|
|
815
|
+
constructor(t, e) {
|
|
816
|
+
this._auth = t, this._gatewayUrl = e;
|
|
811
817
|
}
|
|
812
|
-
|
|
818
|
+
_auth;
|
|
819
|
+
_gatewayUrl;
|
|
813
820
|
/**
|
|
814
|
-
* Returns a
|
|
821
|
+
* Returns a gateway download URL for a document stored in Cue.
|
|
815
822
|
*
|
|
816
823
|
* The storage path is `{projectId}/{uuid}{suffix}`, e.g. `my-project/abc-123.pdf`.
|
|
824
|
+
* The returned URL must be fetched with an Authorization header.
|
|
817
825
|
*
|
|
818
826
|
* @param projectId - The Cue project (space) ID.
|
|
819
827
|
* @param uuid - The document UUID.
|
|
820
828
|
* @param suffix - File suffix including the leading dot, e.g. `'.pdf'`, `'.ifc'`.
|
|
821
829
|
* @param bucket - `'raw'` (default, original uploads) or `'processed'` (derived artefacts).
|
|
822
830
|
*/
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
if (!a) throw new Error(`File not found in storage: ${s} (bucket: ${r})`);
|
|
826
|
-
return a;
|
|
831
|
+
getDownloadUrl(t, e, o, r = "raw") {
|
|
832
|
+
return `${this._gatewayUrl}${xo[r]}/${t}/${e}${o}`;
|
|
827
833
|
}
|
|
828
834
|
/**
|
|
829
|
-
* Returns a
|
|
830
|
-
*
|
|
835
|
+
* Returns a gateway download URL for an alternative representation using its
|
|
836
|
+
* full `qcy:remoteRelativePath` stored in the processed bucket.
|
|
831
837
|
*
|
|
832
838
|
* Use this instead of `getDownloadUrl` when the document info was obtained via
|
|
833
839
|
* `fetchAlternativeRepresentations` and carries a `remoteRelativePath`.
|
|
@@ -835,14 +841,24 @@ class zt {
|
|
|
835
841
|
* @param remoteRelativePath - The full path in the processed bucket,
|
|
836
842
|
* e.g. `{projectId}/fragments/{uuid}.fragments`.
|
|
837
843
|
*/
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
844
|
+
getAltRepDownloadUrl(t) {
|
|
845
|
+
return `${this._gatewayUrl}${ge}/${t}`;
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Fetch a file through the gateway and return it as a Blob.
|
|
849
|
+
* Convenience wrapper around `getDownloadUrl` + `authenticatedFetch`.
|
|
850
|
+
*/
|
|
851
|
+
async downloadBlob(t, e, o, r = "raw") {
|
|
852
|
+
const s = this.getDownloadUrl(t, e, o, r), a = await this._auth.authenticatedFetch(s, {
|
|
853
|
+
headers: { "cue-project-id": t }
|
|
854
|
+
});
|
|
855
|
+
if (!a.ok)
|
|
856
|
+
throw new Error(`Failed to download file: ${a.status} ${a.statusText}`);
|
|
857
|
+
return a.blob();
|
|
842
858
|
}
|
|
843
859
|
}
|
|
844
|
-
const
|
|
845
|
-
class
|
|
860
|
+
const Co = "/data-views/tables", Io = "/commands/tables";
|
|
861
|
+
class So {
|
|
846
862
|
constructor(t, e) {
|
|
847
863
|
this._auth = t, this._gatewayUrl = e;
|
|
848
864
|
}
|
|
@@ -850,7 +866,7 @@ class fo {
|
|
|
850
866
|
_gatewayUrl;
|
|
851
867
|
async listTables(t) {
|
|
852
868
|
const e = await this._auth.authenticatedFetch(
|
|
853
|
-
`${this._gatewayUrl}${
|
|
869
|
+
`${this._gatewayUrl}${Co}`,
|
|
854
870
|
{
|
|
855
871
|
headers: {
|
|
856
872
|
"Content-Type": "application/json",
|
|
@@ -865,7 +881,7 @@ class fo {
|
|
|
865
881
|
}
|
|
866
882
|
async saveTables(t, e) {
|
|
867
883
|
const o = await this._auth.authenticatedFetch(
|
|
868
|
-
`${this._gatewayUrl}${
|
|
884
|
+
`${this._gatewayUrl}${Io}`,
|
|
869
885
|
{
|
|
870
886
|
method: "PUT",
|
|
871
887
|
headers: {
|
|
@@ -880,8 +896,8 @@ class fo {
|
|
|
880
896
|
throw new Error(`Failed to save tables: ${o.status} ${o.statusText}`);
|
|
881
897
|
}
|
|
882
898
|
}
|
|
883
|
-
const
|
|
884
|
-
class
|
|
899
|
+
const To = "/semantic-extraction/extract";
|
|
900
|
+
class Ro {
|
|
885
901
|
constructor(t, e) {
|
|
886
902
|
this._auth = t, this._gatewayUrl = e;
|
|
887
903
|
}
|
|
@@ -898,7 +914,7 @@ class bo {
|
|
|
898
914
|
const e = t.rdfFormat ?? "json-ld", o = new FormData();
|
|
899
915
|
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);
|
|
900
916
|
const r = await this._auth.authenticatedFetch(
|
|
901
|
-
`${this._gatewayUrl}${
|
|
917
|
+
`${this._gatewayUrl}${To}`,
|
|
902
918
|
{
|
|
903
919
|
method: "POST",
|
|
904
920
|
// Do NOT set Content-Type; browser sets it with the correct boundary.
|
|
@@ -919,9 +935,69 @@ class bo {
|
|
|
919
935
|
return { jsonld: await r.json() };
|
|
920
936
|
}
|
|
921
937
|
}
|
|
922
|
-
class
|
|
938
|
+
class Ao {
|
|
939
|
+
constructor(t, e) {
|
|
940
|
+
this._auth = t, this._gatewayUrl = e;
|
|
941
|
+
}
|
|
942
|
+
_auth;
|
|
943
|
+
_gatewayUrl;
|
|
944
|
+
/**
|
|
945
|
+
* Fetch and decompress a session context document.
|
|
946
|
+
*
|
|
947
|
+
* Context files are stored as `sessions_eu_west6/{projectId}/contexts/{contextId}.json.gz`
|
|
948
|
+
* and served via the gateway at `GET /storage/sessions/{projectId}/contexts/{contextId}.json.gz`.
|
|
949
|
+
*
|
|
950
|
+
* @param projectId - The project the context belongs to.
|
|
951
|
+
* @param contextId - The context document ID (without the `.json.gz` suffix).
|
|
952
|
+
*/
|
|
953
|
+
async getContext(t, e) {
|
|
954
|
+
const o = `${this._gatewayUrl}${Eo}/${t}/contexts/${e}.json.gz`, r = await this._auth.authenticatedFetch(o, {
|
|
955
|
+
headers: {
|
|
956
|
+
"cue-project-id": t,
|
|
957
|
+
// Prevent the HTTP layer from auto-decompressing so we can handle it explicitly.
|
|
958
|
+
"Accept-Encoding": "identity"
|
|
959
|
+
}
|
|
960
|
+
});
|
|
961
|
+
if (!r.ok)
|
|
962
|
+
throw new Error(`Failed to fetch context ${e}: ${r.status} ${r.statusText}`);
|
|
963
|
+
const s = new DecompressionStream("gzip"), a = r.body.pipeThrough(s);
|
|
964
|
+
return JSON.parse(await new Response(a).text());
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
class Po {
|
|
968
|
+
constructor(t, e) {
|
|
969
|
+
this._auth = t, this._gatewayUrl = e;
|
|
970
|
+
}
|
|
971
|
+
_auth;
|
|
972
|
+
_gatewayUrl;
|
|
973
|
+
async search(t, e, o) {
|
|
974
|
+
const r = await this._auth.authenticatedFetch(
|
|
975
|
+
`${this._gatewayUrl}${wo}`,
|
|
976
|
+
{
|
|
977
|
+
method: "POST",
|
|
978
|
+
headers: { "Content-Type": "application/json", "x-project-id": e },
|
|
979
|
+
body: JSON.stringify({ input: t, ...o })
|
|
980
|
+
}
|
|
981
|
+
);
|
|
982
|
+
if (!r.ok) throw new Error(`Index search failed: ${r.status} ${r.statusText}`);
|
|
983
|
+
return r.json();
|
|
984
|
+
}
|
|
985
|
+
async lookup(t, e, o) {
|
|
986
|
+
const r = await this._auth.authenticatedFetch(
|
|
987
|
+
`${this._gatewayUrl}${fo}`,
|
|
988
|
+
{
|
|
989
|
+
method: "POST",
|
|
990
|
+
headers: { "Content-Type": "application/json", "x-project-id": e },
|
|
991
|
+
body: JSON.stringify({ input: t, ...o })
|
|
992
|
+
}
|
|
993
|
+
);
|
|
994
|
+
if (!r.ok) throw new Error(`Index lookup failed: ${r.status} ${r.statusText}`);
|
|
995
|
+
return r.json();
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
class Mt {
|
|
923
999
|
constructor(t, e, o, r) {
|
|
924
|
-
this._auth = t, this._gatewayUrl = e, this.projects = o, this.sync = r, this.tables = new
|
|
1000
|
+
this._auth = t, this._gatewayUrl = e, this.projects = o, this.sync = r, this.tables = new So(t, e), this.extraction = new Ro(t, e), this.contexts = new Ao(t, e), this.index = new Po(t, e);
|
|
925
1001
|
}
|
|
926
1002
|
_auth;
|
|
927
1003
|
_gatewayUrl;
|
|
@@ -930,6 +1006,10 @@ class $t {
|
|
|
930
1006
|
tables;
|
|
931
1007
|
/** Semantic extraction client — call document pages against a SemanticTemplate. */
|
|
932
1008
|
extraction;
|
|
1009
|
+
/** Session context file client — fetch and decompress context documents. */
|
|
1010
|
+
contexts;
|
|
1011
|
+
/** Direct interface to the Cue Index accessor — search and lookup. */
|
|
1012
|
+
index;
|
|
933
1013
|
/** Active language used for language-sensitive SPARQL queries across all project classes. */
|
|
934
1014
|
language = "en";
|
|
935
1015
|
/** Updates the active language. All project classes (`CueProjectSchema`, `CueProjectDocuments`, `CueProjectEntities`) read this at query time. */
|
|
@@ -955,7 +1035,7 @@ class $t {
|
|
|
955
1035
|
*/
|
|
956
1036
|
async search(t) {
|
|
957
1037
|
const e = await this._auth.authenticatedFetch(
|
|
958
|
-
`${this._gatewayUrl}${
|
|
1038
|
+
`${this._gatewayUrl}${mo}`,
|
|
959
1039
|
{
|
|
960
1040
|
method: "POST",
|
|
961
1041
|
headers: { "Content-Type": "application/json", "cue-project-id": t.projectId },
|
|
@@ -978,7 +1058,7 @@ class $t {
|
|
|
978
1058
|
*/
|
|
979
1059
|
async sparql(t, e, o) {
|
|
980
1060
|
o || (o = (await this.projects.getProject(e))?.projectSettings?.graph?.type ?? "qlever");
|
|
981
|
-
const r = o === "fuseki" ?
|
|
1061
|
+
const r = o === "fuseki" ? he : de;
|
|
982
1062
|
console.log(`Executing SPARQL query against ${r} for project ${e} with graph type ${o}`);
|
|
983
1063
|
const s = new URLSearchParams();
|
|
984
1064
|
s.append("query", t);
|
|
@@ -1015,7 +1095,7 @@ class $t {
|
|
|
1015
1095
|
const r = o?.format ?? "json-ld", s = r === "turtle" ? "text/turtle" : "application/ld+json";
|
|
1016
1096
|
if (o?.graphType === "fuseki") {
|
|
1017
1097
|
const c = await this._auth.authenticatedFetch(
|
|
1018
|
-
`${this._gatewayUrl}${
|
|
1098
|
+
`${this._gatewayUrl}${bo}`,
|
|
1019
1099
|
{
|
|
1020
1100
|
method: "POST",
|
|
1021
1101
|
headers: {
|
|
@@ -1033,7 +1113,7 @@ class $t {
|
|
|
1033
1113
|
}
|
|
1034
1114
|
return r === "turtle" ? c.text() : c.json();
|
|
1035
1115
|
}
|
|
1036
|
-
const a = `${this._gatewayUrl}${
|
|
1116
|
+
const a = `${this._gatewayUrl}${_o}${o?.verbose ? "?verbose=true" : ""}`, n = new URLSearchParams({ shape: t }), p = await this._auth.authenticatedFetch(a, {
|
|
1037
1117
|
method: "POST",
|
|
1038
1118
|
headers: {
|
|
1039
1119
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
@@ -1051,7 +1131,7 @@ class $t {
|
|
|
1051
1131
|
}
|
|
1052
1132
|
async getConsumption(t) {
|
|
1053
1133
|
const e = await this._auth.authenticatedFetch(
|
|
1054
|
-
`${this._gatewayUrl}${
|
|
1134
|
+
`${this._gatewayUrl}${po}`,
|
|
1055
1135
|
{
|
|
1056
1136
|
headers: {
|
|
1057
1137
|
"Content-Type": "application/json",
|
|
@@ -1078,13 +1158,13 @@ const pt = [
|
|
|
1078
1158
|
"railway",
|
|
1079
1159
|
"natural",
|
|
1080
1160
|
"manmade"
|
|
1081
|
-
],
|
|
1161
|
+
], ue = [
|
|
1082
1162
|
"address",
|
|
1083
1163
|
"poi",
|
|
1084
1164
|
"railway",
|
|
1085
1165
|
"natural",
|
|
1086
1166
|
"manmade"
|
|
1087
|
-
],
|
|
1167
|
+
], Oo = {
|
|
1088
1168
|
address: {
|
|
1089
1169
|
category: "address",
|
|
1090
1170
|
label: "Address",
|
|
@@ -1147,9 +1227,9 @@ const pt = [
|
|
|
1147
1227
|
}
|
|
1148
1228
|
};
|
|
1149
1229
|
function T(i) {
|
|
1150
|
-
return
|
|
1230
|
+
return Oo[i];
|
|
1151
1231
|
}
|
|
1152
|
-
const
|
|
1232
|
+
const Do = {
|
|
1153
1233
|
"land-use-plan": "#f59e0b",
|
|
1154
1234
|
// amber – primary zoning
|
|
1155
1235
|
"local-plan": "#ec4899",
|
|
@@ -1180,7 +1260,7 @@ const _o = {
|
|
|
1180
1260
|
function M(i, t) {
|
|
1181
1261
|
return i[0] < t[2] && i[2] > t[0] && i[1] < t[3] && i[3] > t[1];
|
|
1182
1262
|
}
|
|
1183
|
-
const
|
|
1263
|
+
const Lo = "https://nominatim.openstreetmap.org", qo = "cue-gis/0.0.1", jo = {
|
|
1184
1264
|
address: "street",
|
|
1185
1265
|
poi: "shop",
|
|
1186
1266
|
railway: "station",
|
|
@@ -1195,7 +1275,7 @@ const ko = "https://nominatim.openstreetmap.org", Eo = "cue-gis/0.0.1", xo = {
|
|
|
1195
1275
|
function B(i) {
|
|
1196
1276
|
return `${L}:${i}`;
|
|
1197
1277
|
}
|
|
1198
|
-
function
|
|
1278
|
+
function $o(i) {
|
|
1199
1279
|
const t = T(i);
|
|
1200
1280
|
return {
|
|
1201
1281
|
id: B(i),
|
|
@@ -1210,17 +1290,17 @@ function Io(i) {
|
|
|
1210
1290
|
descriptionKey: `gis.layer.${L}.${i}.description`
|
|
1211
1291
|
};
|
|
1212
1292
|
}
|
|
1213
|
-
class
|
|
1293
|
+
class zo {
|
|
1214
1294
|
baseUrl;
|
|
1215
1295
|
userAgent;
|
|
1216
1296
|
email;
|
|
1217
1297
|
limit;
|
|
1218
1298
|
constructor(t = {}) {
|
|
1219
|
-
this.baseUrl = t.baseUrl ??
|
|
1299
|
+
this.baseUrl = t.baseUrl ?? Lo, this.userAgent = t.userAgent ?? qo, this.email = t.email, this.limit = Math.min(t.limit ?? 40, 40);
|
|
1220
1300
|
}
|
|
1221
1301
|
async listFeatureCategoryDescriptors(t) {
|
|
1222
1302
|
return (await Promise.allSettled(
|
|
1223
|
-
|
|
1303
|
+
ue.map(async (o) => {
|
|
1224
1304
|
const r = await this.search(t, o);
|
|
1225
1305
|
return { category: o, hasResults: r.length > 0 };
|
|
1226
1306
|
})
|
|
@@ -1229,7 +1309,7 @@ class Co {
|
|
|
1229
1309
|
).map((o) => T(o.value.category));
|
|
1230
1310
|
}
|
|
1231
1311
|
async listAvailableLayers(t) {
|
|
1232
|
-
return (await this.listFeatureCategoryDescriptors(t)).map((o) =>
|
|
1312
|
+
return (await this.listFeatureCategoryDescriptors(t)).map((o) => $o(o.category));
|
|
1233
1313
|
}
|
|
1234
1314
|
async getFeaturesForLayer(t, e) {
|
|
1235
1315
|
const o = pt.find((r) => B(r) === e);
|
|
@@ -1246,7 +1326,7 @@ class Co {
|
|
|
1246
1326
|
* so bounded viewbox searches return meaningful results.
|
|
1247
1327
|
*/
|
|
1248
1328
|
async search(t, e) {
|
|
1249
|
-
const [o, r, s, a] = t, n = e ?
|
|
1329
|
+
const [o, r, s, a] = t, n = e ? jo[e] : "place", p = new URLSearchParams({
|
|
1250
1330
|
q: n,
|
|
1251
1331
|
format: "jsonv2",
|
|
1252
1332
|
viewbox: `${o},${a},${s},${r}`,
|
|
@@ -1289,7 +1369,7 @@ class Co {
|
|
|
1289
1369
|
};
|
|
1290
1370
|
}
|
|
1291
1371
|
}
|
|
1292
|
-
const
|
|
1372
|
+
const Nt = {
|
|
1293
1373
|
// 100s – Residential
|
|
1294
1374
|
110: "residential",
|
|
1295
1375
|
120: "residential",
|
|
@@ -1368,7 +1448,7 @@ const Mt = {
|
|
|
1368
1448
|
960: "agricultural",
|
|
1369
1449
|
970: "agricultural",
|
|
1370
1450
|
990: "other"
|
|
1371
|
-
},
|
|
1451
|
+
}, Ft = {
|
|
1372
1452
|
1010: "residential",
|
|
1373
1453
|
1020: "mixed",
|
|
1374
1454
|
1030: "residential",
|
|
@@ -1398,7 +1478,7 @@ const Mt = {
|
|
|
1398
1478
|
1281: "infrastructure",
|
|
1399
1479
|
1282: "infrastructure",
|
|
1400
1480
|
9999: "other"
|
|
1401
|
-
},
|
|
1481
|
+
}, Uo = {
|
|
1402
1482
|
// Residential
|
|
1403
1483
|
1110: "residential",
|
|
1404
1484
|
// Einfamilienhaus
|
|
@@ -1460,7 +1540,7 @@ const Mt = {
|
|
|
1460
1540
|
// Empfangsgebäude Bahn/Bus
|
|
1461
1541
|
1282: "infrastructure"
|
|
1462
1542
|
// Parkhaus, Garage
|
|
1463
|
-
},
|
|
1543
|
+
}, Mo = [
|
|
1464
1544
|
// "Gebäude" is the Swiss AV BoFlaeche land-cover label for a building footprint.
|
|
1465
1545
|
// It does not encode the actual use type, so map it to 'other' as a safe fallback.
|
|
1466
1546
|
[/^geb[äa]ude$/i, "other"],
|
|
@@ -1474,22 +1554,22 @@ const Mt = {
|
|
|
1474
1554
|
[/gemischt|mixed|blandet/i, "mixed"]
|
|
1475
1555
|
];
|
|
1476
1556
|
function O(i) {
|
|
1477
|
-
for (const [t, e] of
|
|
1557
|
+
for (const [t, e] of Mo)
|
|
1478
1558
|
if (t.test(i)) return e;
|
|
1479
1559
|
}
|
|
1480
|
-
function
|
|
1560
|
+
function No(i, t) {
|
|
1481
1561
|
if (i == null) return;
|
|
1482
1562
|
const e = String(i).trim();
|
|
1483
|
-
return t === "swiss-gwr" ?
|
|
1563
|
+
return t === "swiss-gwr" ? Uo[e] ?? O(e) : t === "danish-matrikel" ? Nt[e] ?? O(e) : t === "zurich-wfs" || t === "swiss-av-wfs" ? Ft[e] ?? O(e) : Ft[e] ?? Nt[e] ?? O(e);
|
|
1484
1564
|
}
|
|
1485
|
-
function
|
|
1565
|
+
function Fo(i, t) {
|
|
1486
1566
|
if (i != null)
|
|
1487
1567
|
return O(String(i).trim());
|
|
1488
1568
|
}
|
|
1489
|
-
function
|
|
1569
|
+
function me(i) {
|
|
1490
1570
|
return i.trim().toLowerCase().replace(/[\s_\-]/g, "");
|
|
1491
1571
|
}
|
|
1492
|
-
const
|
|
1572
|
+
const Bo = {
|
|
1493
1573
|
// Swiss ÖREB rechtsstatus
|
|
1494
1574
|
inkraft: "in-force",
|
|
1495
1575
|
laufendeanderung: "amendment-pending",
|
|
@@ -1508,11 +1588,11 @@ const Po = {
|
|
|
1508
1588
|
forslag: "proposed",
|
|
1509
1589
|
aflyst: "repealed"
|
|
1510
1590
|
};
|
|
1511
|
-
function
|
|
1591
|
+
function we(i) {
|
|
1512
1592
|
if (i)
|
|
1513
|
-
return
|
|
1593
|
+
return Bo[me(i)];
|
|
1514
1594
|
}
|
|
1515
|
-
const
|
|
1595
|
+
const Bt = {
|
|
1516
1596
|
// Swiss Nutzungsplanung (typ_gde_bezeichnung and common variants)
|
|
1517
1597
|
grundnutzungszonenplan: "land-use-plan",
|
|
1518
1598
|
nutzungszonenplan: "land-use-plan",
|
|
@@ -1566,7 +1646,7 @@ const Ft = {
|
|
|
1566
1646
|
// Danish plandata.dk
|
|
1567
1647
|
lokalplan: "local-plan",
|
|
1568
1648
|
kommuneplanramme: "municipal-plan-framework"
|
|
1569
|
-
},
|
|
1649
|
+
}, Go = [
|
|
1570
1650
|
[/quartiererhalt/i, "neighbourhood-conservation-plan"],
|
|
1571
1651
|
[/lärmempfindlich|laermempfindlich/i, "noise-sensitivity-plan"],
|
|
1572
1652
|
[/gewässerschutz|grundwasserschutz/i, "water-protection-plan"],
|
|
@@ -1606,24 +1686,24 @@ const Ft = {
|
|
|
1606
1686
|
// Catch-all: any remaining Xzone / Xareal designation from the Grundnutzungszonenplan
|
|
1607
1687
|
[/zone$|areal$/i, "land-use-plan"]
|
|
1608
1688
|
];
|
|
1609
|
-
function
|
|
1689
|
+
function fe(i) {
|
|
1610
1690
|
if (!i) return;
|
|
1611
|
-
const t =
|
|
1612
|
-
if (t in
|
|
1613
|
-
for (const [e, o] of
|
|
1691
|
+
const t = me(i);
|
|
1692
|
+
if (t in Bt) return Bt[t];
|
|
1693
|
+
for (const [e, o] of Go)
|
|
1614
1694
|
if (e.test(i)) return o;
|
|
1615
1695
|
console.warn(
|
|
1616
1696
|
`[cue-gis] Unknown zone plan type — add "${i}" to classifyZonePlanType: no ZonePlanType mapping found.`
|
|
1617
1697
|
);
|
|
1618
1698
|
}
|
|
1619
|
-
const
|
|
1699
|
+
const Ho = "https://maps.zh.ch/wfs/OGDZHWFS", Wo = "zurich-wfs", Vo = [8.35, 47.15, 8.95, 47.7], Xo = [5.9, 45.7, 10.55, 47.85];
|
|
1620
1700
|
function J(i) {
|
|
1621
1701
|
return typeof i == "string" ? i : i.typeName;
|
|
1622
1702
|
}
|
|
1623
1703
|
function tt(i) {
|
|
1624
1704
|
return typeof i == "string" ? void 0 : i.cqlFilter;
|
|
1625
1705
|
}
|
|
1626
|
-
function
|
|
1706
|
+
function Ko(i) {
|
|
1627
1707
|
if (!i) return [0, 0];
|
|
1628
1708
|
const t = i.coordinates;
|
|
1629
1709
|
switch (i.type) {
|
|
@@ -1641,20 +1721,20 @@ function Uo(i) {
|
|
|
1641
1721
|
return [0, 0];
|
|
1642
1722
|
}
|
|
1643
1723
|
}
|
|
1644
|
-
function
|
|
1724
|
+
function Qo(i, t) {
|
|
1645
1725
|
if (!i) return t;
|
|
1646
1726
|
for (const e of ["plannavn", "bezeichnung", "name", "strassenname", "objektname", "title", "label"])
|
|
1647
1727
|
if (typeof i[e] == "string" && i[e]) return i[e];
|
|
1648
1728
|
return t;
|
|
1649
1729
|
}
|
|
1650
|
-
function
|
|
1730
|
+
function Yo(i, t, e) {
|
|
1651
1731
|
return e ? `${i}:${t}[${e}]` : `${i}:${t}`;
|
|
1652
1732
|
}
|
|
1653
|
-
const
|
|
1733
|
+
const Zo = /* @__PURE__ */ new Set(["building", "cadastre", "greenspace", "paved", "zone"]);
|
|
1654
1734
|
function et(i, t, e, o) {
|
|
1655
|
-
const r = e.replace(/^ms:/, ""), s = T(t), a =
|
|
1735
|
+
const r = e.replace(/^ms:/, ""), s = T(t), a = Zo.has(t) ? "priority" : "raw";
|
|
1656
1736
|
return {
|
|
1657
|
-
id:
|
|
1737
|
+
id: Yo(i, e, o),
|
|
1658
1738
|
sourceId: i,
|
|
1659
1739
|
sourceLayerId: e,
|
|
1660
1740
|
category: t,
|
|
@@ -1666,32 +1746,32 @@ function et(i, t, e, o) {
|
|
|
1666
1746
|
descriptionKey: `gis.layer.${i}.${r}.description`
|
|
1667
1747
|
};
|
|
1668
1748
|
}
|
|
1669
|
-
function
|
|
1749
|
+
function Jo(i, t) {
|
|
1670
1750
|
if (!i) return { featureType: "building" };
|
|
1671
1751
|
const e = i.grundflaeche ?? i.gbf ?? i.gebaeudegrundrissflaeche ?? i.flaeche ?? void 0, o = i.vollgeschosse ?? i.geschossanzahl ?? i.anzahl_geschosse ?? void 0, r = i.gebaeudefunktion ?? i.gfkode ?? i.art ?? i.objektart ?? void 0, s = i.baujahr ?? i.bauperiode ?? void 0, a = String(i.egid ?? i.gwr_egid ?? i.egris_egid ?? "").trim() || void 0;
|
|
1672
1752
|
return {
|
|
1673
1753
|
featureType: "building",
|
|
1674
1754
|
areaM2: typeof e == "number" ? e : void 0,
|
|
1675
1755
|
buildingUse: r ? String(r) : void 0,
|
|
1676
|
-
buildingUseGeneric:
|
|
1756
|
+
buildingUseGeneric: No(r, t),
|
|
1677
1757
|
floors: typeof o == "number" ? o : void 0,
|
|
1678
1758
|
yearBuilt: typeof s == "number" ? s : void 0,
|
|
1679
1759
|
registryId: a
|
|
1680
1760
|
};
|
|
1681
1761
|
}
|
|
1682
|
-
function
|
|
1762
|
+
function tr(i, t) {
|
|
1683
1763
|
if (!i) return { featureType: "plot" };
|
|
1684
1764
|
const e = i.egris_egrid ?? i.egrid ?? void 0, o = i.nummer ?? void 0, r = i.nbident ?? void 0, s = o && r ? `${o}, ${r}` : o ?? void 0, a = i.flaechenmass ?? i.flaeche ?? void 0, n = i.art ?? i.nutzungsart ?? void 0;
|
|
1685
1765
|
return {
|
|
1686
1766
|
featureType: "plot",
|
|
1687
1767
|
areaM2: typeof a == "number" ? a : void 0,
|
|
1688
1768
|
plotUse: n ? String(n) : void 0,
|
|
1689
|
-
plotUseGeneric:
|
|
1769
|
+
plotUseGeneric: Fo(n),
|
|
1690
1770
|
plotId: s,
|
|
1691
1771
|
registryId: e
|
|
1692
1772
|
};
|
|
1693
1773
|
}
|
|
1694
|
-
function
|
|
1774
|
+
function er(i) {
|
|
1695
1775
|
if (!i) return { featureType: "greenspace" };
|
|
1696
1776
|
const t = i.flaeche ?? void 0, e = i.art ?? void 0;
|
|
1697
1777
|
return {
|
|
@@ -1700,7 +1780,7 @@ function Bo(i) {
|
|
|
1700
1780
|
surfaceType: e ? String(e) : void 0
|
|
1701
1781
|
};
|
|
1702
1782
|
}
|
|
1703
|
-
function
|
|
1783
|
+
function or(i) {
|
|
1704
1784
|
if (!i) return { featureType: "paved" };
|
|
1705
1785
|
const t = i.flaeche ?? void 0, e = i.art ?? void 0;
|
|
1706
1786
|
return {
|
|
@@ -1709,9 +1789,9 @@ function Go(i) {
|
|
|
1709
1789
|
surfaceType: e ? String(e) : void 0
|
|
1710
1790
|
};
|
|
1711
1791
|
}
|
|
1712
|
-
function
|
|
1792
|
+
function rr(i) {
|
|
1713
1793
|
if (!i) return { featureType: "zone" };
|
|
1714
|
-
const t = i.plannavn ?? i.bezeichnung ?? i.typ_bezeichnung ?? i.art ?? void 0, e = i.planid ?? i.plannummer ?? void 0, o = i.artcode ?? i.typ_code ?? i.abkuerzung ?? e ?? void 0, r = i.rechtsstatus ?? i.status ?? void 0, s =
|
|
1794
|
+
const t = i.plannavn ?? i.bezeichnung ?? i.typ_bezeichnung ?? i.art ?? void 0, e = i.planid ?? i.plannummer ?? void 0, o = i.artcode ?? i.typ_code ?? i.abkuerzung ?? e ?? void 0, r = i.rechtsstatus ?? i.status ?? void 0, s = we(r), a = i.typ_gde_bezeichnung ?? void 0, n = fe(a), p = i.dagsordenpunkt_url ?? i.dokument_url ?? i.link ?? void 0, c = i.auflagedatum ?? void 0, h = i.festsetzungsdatum ?? void 0, d = i.genehmigungsdatum ?? void 0, g = i.inkraftsetzungsdatum ?? void 0, u = i.flaeche ?? i.flaeche_m2 ?? void 0;
|
|
1715
1795
|
return {
|
|
1716
1796
|
featureType: "zone",
|
|
1717
1797
|
zoneType: t ? String(t) : void 0,
|
|
@@ -1727,7 +1807,7 @@ function Ho(i) {
|
|
|
1727
1807
|
areaM2: typeof u == "number" ? u : void 0
|
|
1728
1808
|
};
|
|
1729
1809
|
}
|
|
1730
|
-
function
|
|
1810
|
+
function sr(i) {
|
|
1731
1811
|
const t = i.match(/^(\w+)\s*=\s*'([^']+)'$/);
|
|
1732
1812
|
if (t) {
|
|
1733
1813
|
const [, o, r] = t;
|
|
@@ -1748,7 +1828,7 @@ class ot {
|
|
|
1748
1828
|
sourceId;
|
|
1749
1829
|
outputFormat;
|
|
1750
1830
|
constructor(t) {
|
|
1751
|
-
this.categoryMap = t.categoryMap, this.baseUrl = t.baseUrl ??
|
|
1831
|
+
this.categoryMap = t.categoryMap, this.baseUrl = t.baseUrl ?? Ho, this.sourceId = t.sourceId ?? Wo, this.outputFormat = t.outputFormat ?? "application/json; subtype=geojson";
|
|
1752
1832
|
}
|
|
1753
1833
|
async listFeatureCategoryDescriptors(t) {
|
|
1754
1834
|
const e = await this.listAvailableLayers(t);
|
|
@@ -1772,7 +1852,7 @@ class ot {
|
|
|
1772
1852
|
return o ? this._fetchAndConvert(t, o.descriptor, o.cqlFilter) : [];
|
|
1773
1853
|
}
|
|
1774
1854
|
async _fetchAndConvert(t, e, o) {
|
|
1775
|
-
const r = await this._fetchFeatures(t, e.sourceLayerId, void 0, o), s = o ?
|
|
1855
|
+
const r = await this._fetchFeatures(t, e.sourceLayerId, void 0, o), s = o ? sr(o) : void 0;
|
|
1776
1856
|
return (s ? r.features.filter((n) => s(n.properties)) : r.features).map((n, p) => this.toGisFeature(n, e, p));
|
|
1777
1857
|
}
|
|
1778
1858
|
/**
|
|
@@ -1821,7 +1901,7 @@ class ot {
|
|
|
1821
1901
|
return g.json();
|
|
1822
1902
|
}
|
|
1823
1903
|
toGisFeature(t, e, o) {
|
|
1824
|
-
const [r, s] =
|
|
1904
|
+
const [r, s] = Ko(t.geometry), a = Qo(t.properties, `${e.sourceLayerId}[${o}]`), n = t.bbox ? [t.bbox[0], t.bbox[1], t.bbox[2], t.bbox[3]] : void 0, p = e.tier, c = p === "priority" ? this._extractNormalisedProperties(t, e) : void 0;
|
|
1825
1905
|
return {
|
|
1826
1906
|
id: t.id ?? `${e.sourceLayerId}/${o}`,
|
|
1827
1907
|
preferredColor: e.preferredColor,
|
|
@@ -1842,10 +1922,10 @@ class ot {
|
|
|
1842
1922
|
};
|
|
1843
1923
|
}
|
|
1844
1924
|
_extractNormalisedProperties(t, e) {
|
|
1845
|
-
return e.category === "building" ?
|
|
1925
|
+
return e.category === "building" ? Jo(t.properties, this.sourceId) : e.category === "greenspace" ? er(t.properties) : e.category === "paved" ? or(t.properties) : e.category === "zone" ? rr(t.properties) : tr(t.properties, this.sourceId);
|
|
1846
1926
|
}
|
|
1847
1927
|
}
|
|
1848
|
-
const
|
|
1928
|
+
const ye = [8, 54.5, 15.2, 57.8], be = {
|
|
1849
1929
|
building: [
|
|
1850
1930
|
{ source: "danish-matrikel", typename: "bbr_v001:bygning_current" }
|
|
1851
1931
|
],
|
|
@@ -1854,7 +1934,7 @@ const ge = [8, 54.5, 15.2, 57.8], ue = {
|
|
|
1854
1934
|
{ source: "danish-matrikel", typename: "mat_v001:samletfastejendom_current" }
|
|
1855
1935
|
]
|
|
1856
1936
|
};
|
|
1857
|
-
function
|
|
1937
|
+
function ar(i) {
|
|
1858
1938
|
if (!i) return [0, 0];
|
|
1859
1939
|
const t = i.coordinates;
|
|
1860
1940
|
switch (i.type) {
|
|
@@ -1872,7 +1952,7 @@ function Vo(i) {
|
|
|
1872
1952
|
return [0, 0];
|
|
1873
1953
|
}
|
|
1874
1954
|
}
|
|
1875
|
-
function
|
|
1955
|
+
function ir(i, t) {
|
|
1876
1956
|
if (!i) return t;
|
|
1877
1957
|
for (const e of [
|
|
1878
1958
|
"mat:matrikelnummer",
|
|
@@ -1888,14 +1968,14 @@ function Ko(i, t) {
|
|
|
1888
1968
|
if (typeof i[e] == "string" && i[e]) return i[e];
|
|
1889
1969
|
return t;
|
|
1890
1970
|
}
|
|
1891
|
-
function
|
|
1971
|
+
function nr(i, t, e) {
|
|
1892
1972
|
return `${i}:${t}:${e}`;
|
|
1893
1973
|
}
|
|
1894
|
-
const
|
|
1974
|
+
const pr = /* @__PURE__ */ new Set(["building", "cadastre", "zone"]);
|
|
1895
1975
|
function rt(i, t, e) {
|
|
1896
|
-
const o = e.typename.replace(/^[^:]+:/, ""), r = T(t), s =
|
|
1976
|
+
const o = e.typename.replace(/^[^:]+:/, ""), r = T(t), s = pr.has(t) ? "priority" : "raw";
|
|
1897
1977
|
return {
|
|
1898
|
-
id:
|
|
1978
|
+
id: nr(i, e.source, e.typename),
|
|
1899
1979
|
sourceId: i,
|
|
1900
1980
|
sourceLayerId: e.typename,
|
|
1901
1981
|
category: t,
|
|
@@ -1907,7 +1987,7 @@ function rt(i, t, e) {
|
|
|
1907
1987
|
descriptionKey: `gis.layer.${i}.${e.source}.${o}.description`
|
|
1908
1988
|
};
|
|
1909
1989
|
}
|
|
1910
|
-
function
|
|
1990
|
+
function cr(i, t) {
|
|
1911
1991
|
if (t === "building") {
|
|
1912
1992
|
const a = i?.byg041BebyggetAreal ?? i?.byg038SamletBygningsareal, n = i?.byg021BygningensAnvendelse, p = i?.id_lokalId, c = i?.byg026Opførelsesår;
|
|
1913
1993
|
return {
|
|
@@ -1924,8 +2004,8 @@ function Yo(i, t) {
|
|
|
1924
2004
|
featureType: "zone",
|
|
1925
2005
|
zoneType: a ?? void 0,
|
|
1926
2006
|
zoneCode: p ?? void 0,
|
|
1927
|
-
legalStatus:
|
|
1928
|
-
planType:
|
|
2007
|
+
legalStatus: we(c),
|
|
2008
|
+
planType: fe(i?.typ_gde_bezeichnung),
|
|
1929
2009
|
planId: n ?? void 0,
|
|
1930
2010
|
planDocumentLink: h ?? void 0,
|
|
1931
2011
|
publicationDate: i?.auflagedatum ?? void 0,
|
|
@@ -1943,13 +2023,13 @@ function Yo(i, t) {
|
|
|
1943
2023
|
registryId: s ?? void 0
|
|
1944
2024
|
};
|
|
1945
2025
|
}
|
|
1946
|
-
class
|
|
2026
|
+
class lr {
|
|
1947
2027
|
categoryMap;
|
|
1948
2028
|
dataViewsBaseUrl;
|
|
1949
2029
|
getHeaders;
|
|
1950
2030
|
sourceId;
|
|
1951
2031
|
constructor(t) {
|
|
1952
|
-
this.dataViewsBaseUrl = t.dataViewsBaseUrl.replace(/\/$/, ""), this.getHeaders = t.getHeaders, this.categoryMap = t.categoryMap ??
|
|
2032
|
+
this.dataViewsBaseUrl = t.dataViewsBaseUrl.replace(/\/$/, ""), this.getHeaders = t.getHeaders, this.categoryMap = t.categoryMap ?? be, this.sourceId = t.sourceId ?? "cue-sdk-gis";
|
|
1953
2033
|
}
|
|
1954
2034
|
async listFeatureCategoryDescriptors(t) {
|
|
1955
2035
|
const e = await this.listAvailableLayers(t);
|
|
@@ -2012,7 +2092,7 @@ class Zo {
|
|
|
2012
2092
|
return d.json();
|
|
2013
2093
|
}
|
|
2014
2094
|
_toGisFeature(t, e, o) {
|
|
2015
|
-
const [r, s] =
|
|
2095
|
+
const [r, s] = ar(t.geometry), a = t.id ?? `${e.sourceLayerId}/${o}`, n = ir(t.properties, a), p = t.bbox ? [t.bbox[0], t.bbox[1], t.bbox[2], t.bbox[3]] : void 0, c = e.tier, h = c === "priority" ? cr(t.properties, e.category) : void 0;
|
|
2016
2096
|
return {
|
|
2017
2097
|
id: a,
|
|
2018
2098
|
sourceId: this.sourceId,
|
|
@@ -2033,7 +2113,7 @@ class Zo {
|
|
|
2033
2113
|
};
|
|
2034
2114
|
}
|
|
2035
2115
|
}
|
|
2036
|
-
const
|
|
2116
|
+
const hr = {
|
|
2037
2117
|
address: [
|
|
2038
2118
|
"ms:ogd-0406_arv_basis_avzh_hausnummer_pos_p",
|
|
2039
2119
|
"ms:ogd-0571_afv_gv_strat_strassennetz_l"
|
|
@@ -2081,19 +2161,19 @@ const Jo = {
|
|
|
2081
2161
|
// ÖREB Überlagernde Festlegungen (Flächen) – overlaying planning constraints
|
|
2082
2162
|
"ms:ogd-0155_arv_basis_np_ul_flaeche_f"
|
|
2083
2163
|
]
|
|
2084
|
-
},
|
|
2164
|
+
}, ve = [
|
|
2085
2165
|
{
|
|
2086
2166
|
name: "Canton of Zürich",
|
|
2087
|
-
coverageBBox:
|
|
2167
|
+
coverageBBox: Vo,
|
|
2088
2168
|
supportedCategories: ["address", "poi", "railway", "natural", "manmade", "building", "cadastre", "greenspace", "paved", "zone"],
|
|
2089
2169
|
priority: 10,
|
|
2090
2170
|
adapter: new ot({
|
|
2091
|
-
categoryMap:
|
|
2171
|
+
categoryMap: hr
|
|
2092
2172
|
})
|
|
2093
2173
|
},
|
|
2094
2174
|
{
|
|
2095
2175
|
name: "Switzerland (national AV cadastre)",
|
|
2096
|
-
coverageBBox:
|
|
2176
|
+
coverageBBox: Xo,
|
|
2097
2177
|
supportedCategories: ["cadastre"],
|
|
2098
2178
|
priority: 5,
|
|
2099
2179
|
// Lower priority than canton-specific adapters. For ZH, the canton adapter (priority 10) wins.
|
|
@@ -2121,7 +2201,7 @@ const Jo = {
|
|
|
2121
2201
|
* - `pdk:kommuneplanramme_vedtaget` – adopted municipal plan frameworks
|
|
2122
2202
|
*/
|
|
2123
2203
|
name: "Denmark (Plandata.dk – planning zones)",
|
|
2124
|
-
coverageBBox:
|
|
2204
|
+
coverageBBox: ye,
|
|
2125
2205
|
supportedCategories: ["zone"],
|
|
2126
2206
|
priority: 10,
|
|
2127
2207
|
adapter: new ot({
|
|
@@ -2139,12 +2219,12 @@ const Jo = {
|
|
|
2139
2219
|
})
|
|
2140
2220
|
}
|
|
2141
2221
|
];
|
|
2142
|
-
function
|
|
2222
|
+
function Gt(i) {
|
|
2143
2223
|
return [...i].sort(
|
|
2144
2224
|
(t, e) => pt.indexOf(t.category) - pt.indexOf(e.category)
|
|
2145
2225
|
);
|
|
2146
2226
|
}
|
|
2147
|
-
class
|
|
2227
|
+
class dr {
|
|
2148
2228
|
nominatim;
|
|
2149
2229
|
regions;
|
|
2150
2230
|
/**
|
|
@@ -2159,9 +2239,9 @@ class tr {
|
|
|
2159
2239
|
zonePlanTypeColors: r,
|
|
2160
2240
|
...s
|
|
2161
2241
|
} = t;
|
|
2162
|
-
this.nominatim = new
|
|
2163
|
-
const a = o ?
|
|
2164
|
-
this.regions = e ?? a, this.zonePlanTypeColors = { ...
|
|
2242
|
+
this.nominatim = new zo(s);
|
|
2243
|
+
const a = o ? ve : [];
|
|
2244
|
+
this.regions = e ?? a, this.zonePlanTypeColors = { ...Do, ...r };
|
|
2165
2245
|
}
|
|
2166
2246
|
/**
|
|
2167
2247
|
* Return the available feature categories together with UI metadata such as
|
|
@@ -2180,12 +2260,12 @@ class tr {
|
|
|
2180
2260
|
for (const a of e)
|
|
2181
2261
|
for (const n of a.supportedCategories ?? [])
|
|
2182
2262
|
r.has(n) || (r.add(n), s.push(T(n)));
|
|
2183
|
-
for (const a of
|
|
2263
|
+
for (const a of ue)
|
|
2184
2264
|
r.has(a) || s.push(T(a));
|
|
2185
|
-
return
|
|
2265
|
+
return Gt(s);
|
|
2186
2266
|
}
|
|
2187
2267
|
const o = await this._adapterFor(t).listFeatureCategoryDescriptors(t);
|
|
2188
|
-
return
|
|
2268
|
+
return Gt(o);
|
|
2189
2269
|
}
|
|
2190
2270
|
/**
|
|
2191
2271
|
* Return the feature categories that have at least one result within the
|
|
@@ -2258,7 +2338,7 @@ class tr {
|
|
|
2258
2338
|
const { features: n, idx: p } = await Promise.race(a.values());
|
|
2259
2339
|
a.delete(p);
|
|
2260
2340
|
for (const c of n) {
|
|
2261
|
-
const h =
|
|
2341
|
+
const h = Ht(c), d = W(c), g = s.get(h);
|
|
2262
2342
|
(g === void 0 || d > g) && (s.set(h, d), yield c);
|
|
2263
2343
|
}
|
|
2264
2344
|
}
|
|
@@ -2292,9 +2372,9 @@ class tr {
|
|
|
2292
2372
|
), a = [], n = [];
|
|
2293
2373
|
for (const d of s)
|
|
2294
2374
|
d.status === "fulfilled" && (d.value.isNominatim ? n.push(...d.value.features) : a.push(...d.value.features));
|
|
2295
|
-
const p =
|
|
2375
|
+
const p = mr(a, n), c = /* @__PURE__ */ new Map(), h = [];
|
|
2296
2376
|
for (const d of p) {
|
|
2297
|
-
const g =
|
|
2377
|
+
const g = Ht(d), u = W(d), m = c.get(g);
|
|
2298
2378
|
(m === void 0 || u > m) && (c.set(g, u), h.push(d));
|
|
2299
2379
|
}
|
|
2300
2380
|
return h;
|
|
@@ -2312,22 +2392,22 @@ function W(i) {
|
|
|
2312
2392
|
const t = i.geometry?.type;
|
|
2313
2393
|
return t === "Polygon" || t === "MultiPolygon" ? 3 : t === "LineString" || t === "MultiLineString" ? 2 : 1;
|
|
2314
2394
|
}
|
|
2315
|
-
function
|
|
2395
|
+
function Ht(i) {
|
|
2316
2396
|
const t = Math.round(i.lat * 1e3) / 1e3, e = Math.round(i.lon * 1e3) / 1e3;
|
|
2317
2397
|
return `${(i.name ?? i.id ?? "").toLowerCase().trim()}|${t}|${e}`;
|
|
2318
2398
|
}
|
|
2319
|
-
const
|
|
2320
|
-
function
|
|
2399
|
+
const gr = 1e-3;
|
|
2400
|
+
function ur(i, t) {
|
|
2321
2401
|
const e = i.lat - t.lat, o = i.lon - t.lon;
|
|
2322
2402
|
return Math.sqrt(e * e + o * o);
|
|
2323
2403
|
}
|
|
2324
|
-
function
|
|
2404
|
+
function mr(i, t) {
|
|
2325
2405
|
if (t.length === 0) return i;
|
|
2326
2406
|
const e = i.filter((a) => W(a) === 3), o = i.filter((a) => W(a) !== 3), r = e.map((a) => ({ feature: { ...a, originalData: { ...a.originalData } }, matched: !1 })), s = [];
|
|
2327
2407
|
for (const a of t) {
|
|
2328
|
-
let n = -1, p =
|
|
2408
|
+
let n = -1, p = gr;
|
|
2329
2409
|
for (let c = 0; c < r.length; c++) {
|
|
2330
|
-
const h =
|
|
2410
|
+
const h = ur(a, r[c].feature);
|
|
2331
2411
|
h < p && (p = h, n = c);
|
|
2332
2412
|
}
|
|
2333
2413
|
n >= 0 ? (r[n].feature.originalData = {
|
|
@@ -2341,8 +2421,8 @@ function rr(i, t) {
|
|
|
2341
2421
|
...s
|
|
2342
2422
|
];
|
|
2343
2423
|
}
|
|
2344
|
-
const
|
|
2345
|
-
class
|
|
2424
|
+
const wr = "/data-views", fr = 1500;
|
|
2425
|
+
class yr {
|
|
2346
2426
|
// undefined = not yet built
|
|
2347
2427
|
/** @internal — construct via `cue.gis`, not directly. */
|
|
2348
2428
|
constructor(t, e) {
|
|
@@ -2425,25 +2505,25 @@ class ir {
|
|
|
2425
2505
|
}
|
|
2426
2506
|
// ── Private ───────────────────────────────────────────────────────────────
|
|
2427
2507
|
_scheduleDebouncedQuery() {
|
|
2428
|
-
this._debounceTimer !== null && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => this._queryLayers(),
|
|
2508
|
+
this._debounceTimer !== null && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => this._queryLayers(), fr);
|
|
2429
2509
|
}
|
|
2430
2510
|
_getGateway() {
|
|
2431
2511
|
if (this._gatewayCache !== null && this._gatewayProjectId === this._projectId)
|
|
2432
2512
|
return this._gatewayCache;
|
|
2433
|
-
const t = this._projectId, e = [...
|
|
2513
|
+
const t = this._projectId, e = [...ve];
|
|
2434
2514
|
return t && e.unshift({
|
|
2435
2515
|
name: "Cue SDK (authenticated)",
|
|
2436
|
-
coverageBBox:
|
|
2437
|
-
supportedCategories: Object.keys(
|
|
2516
|
+
coverageBBox: ye,
|
|
2517
|
+
supportedCategories: Object.keys(be),
|
|
2438
2518
|
priority: 10,
|
|
2439
|
-
adapter: new
|
|
2440
|
-
dataViewsBaseUrl: `${this._gatewayUrl}${
|
|
2519
|
+
adapter: new lr({
|
|
2520
|
+
dataViewsBaseUrl: `${this._gatewayUrl}${wr}`,
|
|
2441
2521
|
getHeaders: async () => ({
|
|
2442
2522
|
...await this._getAuthHeaders(),
|
|
2443
2523
|
"x-project-id": t
|
|
2444
2524
|
})
|
|
2445
2525
|
})
|
|
2446
|
-
}), this._gatewayCache = new
|
|
2526
|
+
}), this._gatewayCache = new dr({ regions: e }), this._gatewayProjectId = t, this._gatewayCache;
|
|
2447
2527
|
}
|
|
2448
2528
|
async _queryLayers() {
|
|
2449
2529
|
const t = this._bbox;
|
|
@@ -2487,11 +2567,11 @@ class ir {
|
|
|
2487
2567
|
this._loadListeners.forEach((e) => e(t));
|
|
2488
2568
|
}
|
|
2489
2569
|
}
|
|
2490
|
-
class
|
|
2570
|
+
class Wt {
|
|
2491
2571
|
constructor(t, e, o = !1, r) {
|
|
2492
|
-
if (this._auth = t, this._db =
|
|
2572
|
+
if (this._auth = t, this._db = Ae(e), this._functions = pe(e, le), this._gatewayUrl = r?.gatewayUrl ?? "", o) {
|
|
2493
2573
|
const s = r?.firestoreEmulatorHost ?? "localhost", a = r?.firestoreEmulatorPort ?? 8080;
|
|
2494
|
-
|
|
2574
|
+
Pe(this._db, s, a), ce(this._functions, "localhost", 5001);
|
|
2495
2575
|
}
|
|
2496
2576
|
}
|
|
2497
2577
|
_auth;
|
|
@@ -2508,7 +2588,7 @@ class Ht {
|
|
|
2508
2588
|
* Throws if a project with the given ID already exists.
|
|
2509
2589
|
*/
|
|
2510
2590
|
async createProject(t) {
|
|
2511
|
-
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
2591
|
+
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${go}`, {
|
|
2512
2592
|
method: "POST",
|
|
2513
2593
|
headers: { "Content-Type": "application/json" },
|
|
2514
2594
|
body: JSON.stringify(t)
|
|
@@ -2524,12 +2604,12 @@ class Ht {
|
|
|
2524
2604
|
* Access is gated by Firestore rules which check membership.
|
|
2525
2605
|
*/
|
|
2526
2606
|
async listProjects() {
|
|
2527
|
-
const t = this._requireUser(), e = yt(this._db,
|
|
2528
|
-
return (await
|
|
2607
|
+
const t = this._requireUser(), e = yt(this._db, Ct);
|
|
2608
|
+
return (await Oe(De(e, Le("members", "array-contains", t), qe(100)))).docs.map((r) => r.data());
|
|
2529
2609
|
}
|
|
2530
2610
|
/** Fetch a single project by ID. Returns null if not found. */
|
|
2531
2611
|
async getProject(t) {
|
|
2532
|
-
const e = bt(yt(this._db,
|
|
2612
|
+
const e = bt(yt(this._db, Ct), t), o = await je(e);
|
|
2533
2613
|
return o.exists() ? o.data() : null;
|
|
2534
2614
|
}
|
|
2535
2615
|
/**
|
|
@@ -2539,9 +2619,9 @@ class Ht {
|
|
|
2539
2619
|
async incrementUnitsConsumed(t, e, o) {
|
|
2540
2620
|
if (e <= 0) return;
|
|
2541
2621
|
const r = bt(this._db, "clientSync", t);
|
|
2542
|
-
await
|
|
2543
|
-
unitsConsumed:
|
|
2544
|
-
lastUpdated:
|
|
2622
|
+
await $e(r, {
|
|
2623
|
+
unitsConsumed: Ue(e),
|
|
2624
|
+
lastUpdated: ze(),
|
|
2545
2625
|
lastUserId: o
|
|
2546
2626
|
}, { merge: !0 });
|
|
2547
2627
|
}
|
|
@@ -2564,7 +2644,7 @@ class Ht {
|
|
|
2564
2644
|
*/
|
|
2565
2645
|
async deleteProject(t) {
|
|
2566
2646
|
const e = await this._auth.authenticatedFetch(
|
|
2567
|
-
`${this._gatewayUrl}${
|
|
2647
|
+
`${this._gatewayUrl}${uo(t)}`,
|
|
2568
2648
|
{ method: "DELETE" }
|
|
2569
2649
|
);
|
|
2570
2650
|
if (!e.ok) {
|
|
@@ -2573,9 +2653,9 @@ class Ht {
|
|
|
2573
2653
|
}
|
|
2574
2654
|
}
|
|
2575
2655
|
}
|
|
2576
|
-
class
|
|
2656
|
+
class Vt {
|
|
2577
2657
|
constructor(t, e, o, r) {
|
|
2578
|
-
this._auth = t, this._gatewayUrl = r, this._functions =
|
|
2658
|
+
this._auth = t, this._gatewayUrl = r, this._functions = pe(e, le), o && ce(this._functions, "localhost", 5001);
|
|
2579
2659
|
}
|
|
2580
2660
|
_auth;
|
|
2581
2661
|
_gatewayUrl;
|
|
@@ -2592,13 +2672,13 @@ class Wt {
|
|
|
2592
2672
|
}
|
|
2593
2673
|
/** Whether the current user has an active API key. */
|
|
2594
2674
|
async hasAPIKey() {
|
|
2595
|
-
return await this._fetch(
|
|
2675
|
+
return await this._fetch(Dt) !== null;
|
|
2596
2676
|
}
|
|
2597
2677
|
/** Returns the sign-in methods registered for the current user's email. */
|
|
2598
2678
|
async getSignInMethods() {
|
|
2599
2679
|
const t = this._auth.currentUser;
|
|
2600
2680
|
if (!t?.email) throw new Error("User has no e-mail");
|
|
2601
|
-
return
|
|
2681
|
+
return Ke(this._auth.firebaseAuth, t.email);
|
|
2602
2682
|
}
|
|
2603
2683
|
/** Builds a human-readable label from a Firebase UserInfo provider entry. */
|
|
2604
2684
|
buildProviderLabel(t) {
|
|
@@ -2611,14 +2691,14 @@ class Wt {
|
|
|
2611
2691
|
}
|
|
2612
2692
|
/** Links a Google or Microsoft provider to the current account via popup. Returns the new provider label. */
|
|
2613
2693
|
async linkProvider(t) {
|
|
2614
|
-
const e = this._requireUser(), o = t === "google.com" ? new it() : new nt(t), s = (await
|
|
2694
|
+
const e = this._requireUser(), o = t === "google.com" ? new it() : new nt(t), s = (await Qe(e, o)).user.providerData.find(
|
|
2615
2695
|
(a) => a.providerId === t
|
|
2616
2696
|
);
|
|
2617
2697
|
return s ? this.buildProviderLabel(s) : "-";
|
|
2618
2698
|
}
|
|
2619
2699
|
/** Unlinks a provider from the current account. */
|
|
2620
2700
|
async unlinkProvider(t) {
|
|
2621
|
-
await
|
|
2701
|
+
await Ye(this._requireUser(), t);
|
|
2622
2702
|
}
|
|
2623
2703
|
/** Changes the password. Reauthenticates first. */
|
|
2624
2704
|
async updatePassword(t, e) {
|
|
@@ -2627,13 +2707,13 @@ class Wt {
|
|
|
2627
2707
|
await _t(
|
|
2628
2708
|
o,
|
|
2629
2709
|
Q.credential(o.email, t)
|
|
2630
|
-
), await
|
|
2710
|
+
), await Ze(o, e);
|
|
2631
2711
|
}
|
|
2632
2712
|
/** Adds (sets) a password for an account that currently only uses SSO. */
|
|
2633
2713
|
async addPassword(t) {
|
|
2634
2714
|
const e = this._requireUser();
|
|
2635
2715
|
if (!e.email) throw new Error("User has no e-mail");
|
|
2636
|
-
await
|
|
2716
|
+
await Je(e, Q.credential(e.email, t));
|
|
2637
2717
|
}
|
|
2638
2718
|
/** Requests an e-mail change. Sends a verification e-mail to the new address. */
|
|
2639
2719
|
async updateEmail(t, e) {
|
|
@@ -2642,11 +2722,11 @@ class Wt {
|
|
|
2642
2722
|
await _t(
|
|
2643
2723
|
o,
|
|
2644
2724
|
Q.credential(o.email, e)
|
|
2645
|
-
), await
|
|
2725
|
+
), await to(o, t), await eo(o);
|
|
2646
2726
|
}
|
|
2647
2727
|
/** Creates a new API key for the current user. */
|
|
2648
2728
|
async createAPIKey(t) {
|
|
2649
|
-
return this._fetch(
|
|
2729
|
+
return this._fetch(Lt, {
|
|
2650
2730
|
method: "POST",
|
|
2651
2731
|
headers: { "Content-Type": "application/json" },
|
|
2652
2732
|
body: JSON.stringify({ expiration: t })
|
|
@@ -2655,7 +2735,7 @@ class Wt {
|
|
|
2655
2735
|
/** Revokes the current user's API key. */
|
|
2656
2736
|
async revokeAPIKey() {
|
|
2657
2737
|
const t = await this._auth.authenticatedFetch(
|
|
2658
|
-
this._url(
|
|
2738
|
+
this._url(Lt),
|
|
2659
2739
|
{ method: "DELETE" }
|
|
2660
2740
|
);
|
|
2661
2741
|
if (!t.ok)
|
|
@@ -2663,17 +2743,17 @@ class Wt {
|
|
|
2663
2743
|
}
|
|
2664
2744
|
/** Fetches the current user's existing API key. */
|
|
2665
2745
|
async requestAPIKey() {
|
|
2666
|
-
const t = await this._fetch(
|
|
2746
|
+
const t = await this._fetch(Dt);
|
|
2667
2747
|
if (!t) throw new Error("No API key found");
|
|
2668
2748
|
return t;
|
|
2669
2749
|
}
|
|
2670
2750
|
/** Returns organizations the current user is a member of. */
|
|
2671
2751
|
async listOrganizations() {
|
|
2672
|
-
return this._fetch(
|
|
2752
|
+
return this._fetch(co);
|
|
2673
2753
|
}
|
|
2674
2754
|
/** Returns all members of the given organisation. Caller must be an org admin or superadmin. */
|
|
2675
2755
|
async getOrgMembers(t) {
|
|
2676
|
-
return this._fetch(
|
|
2756
|
+
return this._fetch(ho(t));
|
|
2677
2757
|
}
|
|
2678
2758
|
_requireUser() {
|
|
2679
2759
|
const t = this._auth.currentUser;
|
|
@@ -2689,7 +2769,7 @@ class Wt {
|
|
|
2689
2769
|
}
|
|
2690
2770
|
/** Record that the current user has accepted the terms of service. Sets a `terms` custom claim on the token. */
|
|
2691
2771
|
async acceptTerms(t) {
|
|
2692
|
-
await this._fetch(
|
|
2772
|
+
await this._fetch(lo, {
|
|
2693
2773
|
method: "POST",
|
|
2694
2774
|
headers: { "Content-Type": "application/json" },
|
|
2695
2775
|
body: JSON.stringify({ version: t })
|
|
@@ -2706,7 +2786,7 @@ class Wt {
|
|
|
2706
2786
|
return t ? (await at(t)).claims.terms ?? null : null;
|
|
2707
2787
|
}
|
|
2708
2788
|
}
|
|
2709
|
-
const
|
|
2789
|
+
const Xt = ["superadmin", "admin", "syncer", "member"], Kt = {
|
|
2710
2790
|
createEntities: "admin",
|
|
2711
2791
|
createProvider: "superadmin",
|
|
2712
2792
|
changeContentCategories: "syncer",
|
|
@@ -2722,7 +2802,7 @@ const Vt = ["superadmin", "admin", "syncer", "member"], Kt = {
|
|
|
2722
2802
|
uploadDocuments: "syncer",
|
|
2723
2803
|
viewEntities: "member"
|
|
2724
2804
|
};
|
|
2725
|
-
function
|
|
2805
|
+
function br() {
|
|
2726
2806
|
return {
|
|
2727
2807
|
changeContentCategories: !1,
|
|
2728
2808
|
createEntities: !1,
|
|
@@ -2741,9 +2821,9 @@ function nr() {
|
|
|
2741
2821
|
viewEntities: !1
|
|
2742
2822
|
};
|
|
2743
2823
|
}
|
|
2744
|
-
class
|
|
2824
|
+
class Qt {
|
|
2745
2825
|
constructor(t) {
|
|
2746
|
-
this._isSuperAdmin = t, this._projectRoles = new
|
|
2826
|
+
this._isSuperAdmin = t, this._projectRoles = new x([]), this._orgRole = new x(null), this.privileges = dt(
|
|
2747
2827
|
[this._projectRoles, this._orgRole, t],
|
|
2748
2828
|
() => this._compute()
|
|
2749
2829
|
);
|
|
@@ -2780,17 +2860,17 @@ class Xt {
|
|
|
2780
2860
|
_expand(t) {
|
|
2781
2861
|
if (this._isSuperAdmin.get())
|
|
2782
2862
|
return ["superadmin", "admin", "syncer", "member"];
|
|
2783
|
-
const e =
|
|
2784
|
-
return e === -1 ? [] : Array.from(
|
|
2863
|
+
const e = Xt.findIndex((o) => t.includes(o));
|
|
2864
|
+
return e === -1 ? [] : Array.from(Xt.slice(e));
|
|
2785
2865
|
}
|
|
2786
2866
|
_compute() {
|
|
2787
|
-
const t = this._projectRoles.get(), e = this._isSuperAdmin.get(), o =
|
|
2867
|
+
const t = this._projectRoles.get(), e = this._isSuperAdmin.get(), o = br();
|
|
2788
2868
|
for (const r of Object.keys(Kt))
|
|
2789
2869
|
o[r] = t.includes(Kt[r]);
|
|
2790
2870
|
return o.createProject = e || this._orgRole.get() === "admin", o;
|
|
2791
2871
|
}
|
|
2792
2872
|
}
|
|
2793
|
-
class
|
|
2873
|
+
class Yt {
|
|
2794
2874
|
constructor(t) {
|
|
2795
2875
|
this._storage = t;
|
|
2796
2876
|
}
|
|
@@ -2823,7 +2903,7 @@ class Qt {
|
|
|
2823
2903
|
// ── Internal helpers ───────────────────────────────────────────────────────
|
|
2824
2904
|
async _get(t, e) {
|
|
2825
2905
|
try {
|
|
2826
|
-
const r = await (await
|
|
2906
|
+
const r = await (await ne(k(this._storage, `${t}/${e}.json.gz`))).arrayBuffer(), s = new DecompressionStream("gzip"), a = s.writable.getWriter(), n = s.readable.getReader();
|
|
2827
2907
|
a.write(new Uint8Array(r)), a.close();
|
|
2828
2908
|
const p = [];
|
|
2829
2909
|
let c = await n.read();
|
|
@@ -2835,7 +2915,7 @@ class Qt {
|
|
|
2835
2915
|
d.set(u, g), g += u.length;
|
|
2836
2916
|
return JSON.parse(new TextDecoder().decode(d));
|
|
2837
2917
|
} catch (o) {
|
|
2838
|
-
if (
|
|
2918
|
+
if (vr(o)) return;
|
|
2839
2919
|
throw o;
|
|
2840
2920
|
}
|
|
2841
2921
|
}
|
|
@@ -2851,13 +2931,13 @@ class Qt {
|
|
|
2851
2931
|
for (const u of p)
|
|
2852
2932
|
d.set(u, g), g += u.length;
|
|
2853
2933
|
await st(
|
|
2854
|
-
|
|
2934
|
+
k(this._storage, `${t}/${e}.json.gz`),
|
|
2855
2935
|
d,
|
|
2856
2936
|
{ contentType: "application/gzip" }
|
|
2857
2937
|
);
|
|
2858
2938
|
}
|
|
2859
2939
|
}
|
|
2860
|
-
function
|
|
2940
|
+
function vr(i) {
|
|
2861
2941
|
return typeof i == "object" && i !== null && "code" in i && i.code === "storage/object-not-found";
|
|
2862
2942
|
}
|
|
2863
2943
|
const y = {
|
|
@@ -2880,7 +2960,7 @@ const y = {
|
|
|
2880
2960
|
dicu: "https://w3id.org/digitalconstruction/0.5/Units#",
|
|
2881
2961
|
diclvl: "https://w3id.org/digitalconstruction/0.5/Levels#",
|
|
2882
2962
|
dicstg: "https://w3id.org/digitalconstruction/0.5/Stages#"
|
|
2883
|
-
},
|
|
2963
|
+
}, R = {
|
|
2884
2964
|
madsrdf: "http://www.loc.gov/mads/rdf/v1#",
|
|
2885
2965
|
bflc: "http://id.loc.gov/ontologies/bflc/",
|
|
2886
2966
|
foaf: "http://xmlns.com/foaf/0.1/",
|
|
@@ -6129,28 +6209,42 @@ class V {
|
|
|
6129
6209
|
return r === void 0 ? t : t.replace(o, `${r}:`);
|
|
6130
6210
|
}
|
|
6131
6211
|
expandIRI(t) {
|
|
6132
|
-
const e = t.split(":")[0], o =
|
|
6212
|
+
const e = t.split(":")[0], o = R[e] ?? y[e];
|
|
6133
6213
|
return t.replace(`${e}:`, o);
|
|
6134
6214
|
}
|
|
6135
6215
|
_buildNSMap() {
|
|
6136
6216
|
const t = {};
|
|
6137
|
-
return Object.keys(
|
|
6217
|
+
return Object.keys(R).forEach((e) => t[R[e]] = e), Object.keys(y).forEach(
|
|
6138
6218
|
(e) => t[y[e]] = e
|
|
6139
6219
|
), this._nsMap = t, t;
|
|
6140
6220
|
}
|
|
6141
6221
|
}
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6222
|
+
const _r = `${y.qcy}ContentCategory`, Er = `${y.qcy}EntityCategory`, kr = `${y.qcy}relatedEntity`, xr = `PREFIX view: <https://qlever.cs.uni-freiburg.de/materializedView/>
|
|
6223
|
+
SELECT ?iri ?type ?parent ?deprecated ?label ?definition
|
|
6224
|
+
WHERE {
|
|
6225
|
+
SERVICE view:schemas {
|
|
6226
|
+
_:cfg view:column-iri ?iri ;
|
|
6227
|
+
view:column-type ?type ;
|
|
6228
|
+
view:column-parent ?parent ;
|
|
6229
|
+
view:column-deprecated ?deprecated ;
|
|
6230
|
+
view:column-label ?label ;
|
|
6231
|
+
view:column-definition ?definition .
|
|
6232
|
+
}
|
|
6233
|
+
}`;
|
|
6234
|
+
class Cr {
|
|
6235
|
+
constructor(t, e, o, r, s, a) {
|
|
6236
|
+
this._api = t, this._projectId = e, this._queryCache = r, this._graphType = s, this._verbose = a ?? !1, this._currentLang = o, this._api.setLanguage(o), this._contentCategories = new x([]), this._entityCategories = new x([]), this._relationships = new x([]), this.availableContentCategories = this._contentCategories.asReadonly(), this.availableEntityCategories = this._entityCategories.asReadonly(), this.availableEntityRelationships = this._relationships.asReadonly(), this.ready = this._load().catch(
|
|
6237
|
+
(n) => console.error("[CueProjectSchema] Initial load failed:", n)
|
|
6146
6238
|
);
|
|
6147
6239
|
}
|
|
6148
6240
|
_api;
|
|
6149
6241
|
_projectId;
|
|
6150
6242
|
_queryCache;
|
|
6151
6243
|
_graphType;
|
|
6152
|
-
|
|
6244
|
+
_snapshot;
|
|
6245
|
+
_inflight;
|
|
6153
6246
|
_currentLang;
|
|
6247
|
+
_verbose;
|
|
6154
6248
|
_contentCategories;
|
|
6155
6249
|
_entityCategories;
|
|
6156
6250
|
_relationships;
|
|
@@ -6170,106 +6264,166 @@ class lr {
|
|
|
6170
6264
|
return this._api.language;
|
|
6171
6265
|
}
|
|
6172
6266
|
/**
|
|
6173
|
-
* Switch the active language.
|
|
6174
|
-
*
|
|
6175
|
-
*
|
|
6267
|
+
* Switch the active language. Re-projects the already-fetched schema for the
|
|
6268
|
+
* new language without re-querying; only triggers a fetch if nothing has been
|
|
6269
|
+
* loaded yet.
|
|
6176
6270
|
*/
|
|
6177
6271
|
setLanguage(t) {
|
|
6178
|
-
|
|
6179
|
-
(
|
|
6180
|
-
|
|
6272
|
+
if (this._currentLang !== t) {
|
|
6273
|
+
if (this._currentLang = t, this._api.setLanguage(t), this._snapshot) {
|
|
6274
|
+
this._apply(this._snapshot);
|
|
6275
|
+
return;
|
|
6276
|
+
}
|
|
6277
|
+
this._load().catch(
|
|
6278
|
+
(e) => console.error("[CueProjectSchema] Language switch failed:", e)
|
|
6279
|
+
);
|
|
6280
|
+
}
|
|
6181
6281
|
}
|
|
6182
6282
|
/**
|
|
6183
|
-
* Force a re-fetch
|
|
6283
|
+
* Force a re-fetch of the schema, bypassing the cache.
|
|
6184
6284
|
* Useful when the triplestore data has changed.
|
|
6185
6285
|
*/
|
|
6186
6286
|
async refresh() {
|
|
6187
|
-
|
|
6188
|
-
this._cache.delete(t), await this._load(t);
|
|
6287
|
+
this._snapshot = void 0, await this._load();
|
|
6189
6288
|
}
|
|
6190
6289
|
// ── Private helpers ─────────────────────────────────────────────────────────
|
|
6191
|
-
async _load(
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
this._apply(e);
|
|
6290
|
+
async _load() {
|
|
6291
|
+
if (this._snapshot) {
|
|
6292
|
+
this._apply(this._snapshot);
|
|
6195
6293
|
return;
|
|
6196
6294
|
}
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
(a) => {
|
|
6209
|
-
this._cache.set(t, a), this._currentLang === t && this._apply(a);
|
|
6295
|
+
if (this._inflight) return this._inflight;
|
|
6296
|
+
this._verbose && console.log(
|
|
6297
|
+
`[CueProjectSchema] Fetching schema — project: ${this._projectId}, graphType: ${this._graphType ?? "default"}`
|
|
6298
|
+
);
|
|
6299
|
+
const t = `cue-schema:${this._projectId}:${this._graphType ?? "default"}`, e = gt(
|
|
6300
|
+
t,
|
|
6301
|
+
() => this._fetchSnapshot(),
|
|
6302
|
+
(o, r) => {
|
|
6303
|
+
this._verbose && console.log(
|
|
6304
|
+
`[CueProjectSchema] Applying ${r ? "stale (cached)" : "fresh"} snapshot — contentCategories: ${o.contentCategories.length}, entityCategories: ${o.entityCategories.length}, relationships: ${o.relationships.length}`
|
|
6305
|
+
), this._snapshot = o, this._apply(o);
|
|
6210
6306
|
},
|
|
6211
6307
|
this._queryCache
|
|
6212
|
-
)
|
|
6308
|
+
).then(() => {
|
|
6309
|
+
}).finally(() => {
|
|
6310
|
+
this._inflight = void 0;
|
|
6311
|
+
});
|
|
6312
|
+
return this._inflight = e, e;
|
|
6313
|
+
}
|
|
6314
|
+
/**
|
|
6315
|
+
* Fetches the schema once. On QLever the pre-computed `schemas` materialized
|
|
6316
|
+
* view is tried first; if it yields no rows we warn and fall back to the live
|
|
6317
|
+
* schema query.
|
|
6318
|
+
*/
|
|
6319
|
+
async _fetchSnapshot() {
|
|
6320
|
+
if (this._graphType !== "fuseki") {
|
|
6321
|
+
const e = await this._runSchemaQuery(xr);
|
|
6322
|
+
if (e.contentCategories.length + e.entityCategories.length + e.relationships.length > 0) return e;
|
|
6323
|
+
console.warn(
|
|
6324
|
+
`[CueProjectSchema] Materialized view "schemas" returned no rows for project ${this._projectId} — falling back to the live schema query.`
|
|
6325
|
+
);
|
|
6326
|
+
}
|
|
6327
|
+
return this._runSchemaQuery(this._buildSchemaQuery());
|
|
6213
6328
|
}
|
|
6214
6329
|
_apply(t) {
|
|
6215
|
-
|
|
6330
|
+
const e = this._currentLang;
|
|
6331
|
+
this._contentCategories.set(
|
|
6332
|
+
t.contentCategories.map((o) => this._toDef(o, e))
|
|
6333
|
+
), this._entityCategories.set(
|
|
6334
|
+
t.entityCategories.map((o) => this._toDef(o, e))
|
|
6335
|
+
), this._relationships.set(
|
|
6336
|
+
t.relationships.map((o) => this._toDef(o, e))
|
|
6337
|
+
);
|
|
6216
6338
|
}
|
|
6217
|
-
|
|
6218
|
-
|
|
6339
|
+
/** Projects a language-independent {@link SchemaNode} into a {@link CategoryDef}. */
|
|
6340
|
+
_toDef(t, e) {
|
|
6341
|
+
const o = te(t.labels, e) ?? t.iri.split("#").at(-1) ?? t.iri, r = te(t.definitions, e), s = Object.keys(t.definitions).length > 0;
|
|
6342
|
+
return {
|
|
6343
|
+
iri: t.iri,
|
|
6344
|
+
label: o,
|
|
6345
|
+
labels: t.labels,
|
|
6346
|
+
...r !== void 0 ? { definition: r } : {},
|
|
6347
|
+
...s ? { definitions: t.definitions } : {},
|
|
6348
|
+
...t.parent !== void 0 ? { parent: t.parent } : {},
|
|
6349
|
+
...t.deprecated !== void 0 ? { deprecated: t.deprecated } : {}
|
|
6350
|
+
};
|
|
6219
6351
|
}
|
|
6220
|
-
|
|
6352
|
+
/**
|
|
6353
|
+
* Single query covering content categories, entity categories and entity
|
|
6354
|
+
* relationship types. Labels/definitions are returned untouched (with their
|
|
6355
|
+
* language tags) so they can be grouped into {@link LangMap}s client-side.
|
|
6356
|
+
*/
|
|
6357
|
+
_buildSchemaQuery() {
|
|
6221
6358
|
return `PREFIX qcy: <${y.qcy}>
|
|
6222
|
-
PREFIX skos: <${
|
|
6223
|
-
|
|
6359
|
+
PREFIX skos: <${R.skos}>
|
|
6360
|
+
PREFIX rdfs: <${R.rdfs}>
|
|
6361
|
+
PREFIX owl: <${R.owl}>
|
|
6362
|
+
SELECT ?iri ?type ?parent ?deprecated ?label ?definition
|
|
6224
6363
|
WHERE {
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
}
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
}
|
|
6364
|
+
{
|
|
6365
|
+
VALUES ?type { qcy:ContentCategory qcy:EntityCategory }
|
|
6366
|
+
?iri a ?type ;
|
|
6367
|
+
skos:prefLabel ?label ;
|
|
6368
|
+
skos:definition ?definition .
|
|
6369
|
+
OPTIONAL { ?iri skos:broader ?parent }
|
|
6370
|
+
OPTIONAL { ?iri owl:deprecated ?deprecated }
|
|
6371
|
+
}
|
|
6372
|
+
UNION
|
|
6373
|
+
{
|
|
6374
|
+
?iri rdfs:subPropertyOf+ qcy:relatedEntity .
|
|
6375
|
+
?iri rdfs:label ?label ;
|
|
6376
|
+
rdfs:comment ?definition .
|
|
6377
|
+
OPTIONAL { ?iri rdfs:subPropertyOf ?parent }
|
|
6378
|
+
OPTIONAL { ?iri owl:deprecated ?deprecated }
|
|
6379
|
+
BIND(qcy:relatedEntity AS ?type)
|
|
6380
|
+
}
|
|
6381
|
+
}`;
|
|
6242
6382
|
}
|
|
6243
|
-
|
|
6244
|
-
|
|
6383
|
+
/** Runs a schema query and groups the flat rows into a {@link SchemaSnapshot}. */
|
|
6384
|
+
async _runSchemaQuery(t) {
|
|
6385
|
+
const e = await this._api.sparql(
|
|
6386
|
+
t,
|
|
6387
|
+
this._projectId,
|
|
6388
|
+
this._graphType
|
|
6389
|
+
), o = /* @__PURE__ */ new Map();
|
|
6390
|
+
for (const s of e.results.bindings) {
|
|
6391
|
+
const a = s.iri?.value, n = s.type?.value;
|
|
6392
|
+
if (!a || !n) continue;
|
|
6393
|
+
let p = o.get(a);
|
|
6394
|
+
p || (p = { iri: a, type: n, labels: {}, definitions: {} }, o.set(a, p)), p.parent === void 0 && s.parent?.value && (p.parent = s.parent.value);
|
|
6395
|
+
const c = s.deprecated?.value;
|
|
6396
|
+
c !== void 0 && (p.deprecated = c === "true" || c === "1"), Zt(p.labels, s.label), Zt(p.definitions, s.definition);
|
|
6397
|
+
}
|
|
6398
|
+
const r = {
|
|
6399
|
+
contentCategories: [],
|
|
6400
|
+
entityCategories: [],
|
|
6401
|
+
relationships: []
|
|
6402
|
+
};
|
|
6403
|
+
for (const s of o.values())
|
|
6404
|
+
Jt(s.labels), Jt(s.definitions), s.type === _r ? r.contentCategories.push(s) : s.type === Er ? r.entityCategories.push(s) : s.type === kr && r.relationships.push(s);
|
|
6405
|
+
return r;
|
|
6245
6406
|
}
|
|
6246
|
-
_buildRelationshipsQuery(t) {
|
|
6247
|
-
return `PREFIX qcy: <${y.qcy}>
|
|
6248
|
-
PREFIX rdfs: <${A.rdfs}>
|
|
6249
|
-
SELECT ?iri ?parent (SAMPLE(?l) AS ?label)
|
|
6250
|
-
WHERE {
|
|
6251
|
-
?x qcy:relatedEntity ?y ;
|
|
6252
|
-
?iri ?y .
|
|
6253
|
-
OPTIONAL { ?iri rdfs:label ?lang_label FILTER(LANG(?lang_label) = "${t}") }
|
|
6254
|
-
OPTIONAL { ?iri rdfs:label ?no_lang_label }
|
|
6255
|
-
BIND(COALESCE(?lang_label, ?no_lang_label) AS ?l)
|
|
6256
|
-
OPTIONAL { ?iri rdfs:subPropertyOf ?parent }
|
|
6257
6407
|
}
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
};
|
|
6268
|
-
});
|
|
6408
|
+
function Zt(i, t) {
|
|
6409
|
+
if (!t || t.value === void 0) return;
|
|
6410
|
+
const e = t["xml:lang"], o = e && e.length > 0 ? e : "default";
|
|
6411
|
+
i[o] === void 0 && (i[o] = t.value);
|
|
6412
|
+
}
|
|
6413
|
+
function Jt(i) {
|
|
6414
|
+
if (i.en !== void 0) {
|
|
6415
|
+
i.default = i.en;
|
|
6416
|
+
return;
|
|
6269
6417
|
}
|
|
6418
|
+
if (i.default !== void 0) return;
|
|
6419
|
+
const t = Object.values(i)[0];
|
|
6420
|
+
t !== void 0 && (i.default = t);
|
|
6270
6421
|
}
|
|
6271
|
-
|
|
6272
|
-
|
|
6422
|
+
function te(i, t) {
|
|
6423
|
+
return i[t] ?? i.default;
|
|
6424
|
+
}
|
|
6425
|
+
const Ir = "https://qlever.dev/api/osm-planet";
|
|
6426
|
+
class _e {
|
|
6273
6427
|
constructor(t, e, o = ut, r, s, a = !1) {
|
|
6274
6428
|
this._api = t, this._projectId = e, this._queryCache = r, this._graphType = s, this._verbose = a, this.baseURL = `${o}${e}/`, this.entityInfoMap = this._entityInfoMapComputed, this.entityGraph = this._entityGraph.asReadonly(), this._entityOSMMap.subscribe(() => this._checkPendingOSMFetches()), this._fetchEntityGraph().catch(
|
|
6275
6429
|
(n) => console.error("[CueProjectEntities] Entity graph fetch failed:", n)
|
|
@@ -6283,17 +6437,17 @@ class we {
|
|
|
6283
6437
|
/** Full RDF base URL for this project, e.g. `https://cue.qaecy.com/r/{pid}/` */
|
|
6284
6438
|
baseURL;
|
|
6285
6439
|
// ── Internal writable slices ───────────────────────────────────────────────
|
|
6286
|
-
_entityDetails = new
|
|
6287
|
-
_entityDocuments = new
|
|
6440
|
+
_entityDetails = new x({});
|
|
6441
|
+
_entityDocuments = new x(
|
|
6288
6442
|
{}
|
|
6289
6443
|
);
|
|
6290
|
-
_entityRelationships = new
|
|
6291
|
-
_entityOSMMap = new
|
|
6292
|
-
_osmWKTMap = new
|
|
6444
|
+
_entityRelationships = new x({});
|
|
6445
|
+
_entityOSMMap = new x({});
|
|
6446
|
+
_osmWKTMap = new x({});
|
|
6293
6447
|
_fetchingOSMIds = /* @__PURE__ */ new Set();
|
|
6294
6448
|
/** Cumulative unique entity UUIDs ever passed to request methods (survives cache hits). */
|
|
6295
6449
|
_seenIds = /* @__PURE__ */ new Set();
|
|
6296
|
-
_entityGraph = new
|
|
6450
|
+
_entityGraph = new x(void 0);
|
|
6297
6451
|
// ── Derived signals ────────────────────────────────────────────────────────
|
|
6298
6452
|
_entityInfoMapComputed = dt(
|
|
6299
6453
|
[
|
|
@@ -6488,7 +6642,7 @@ WHERE {
|
|
|
6488
6642
|
*/
|
|
6489
6643
|
async contentCategoriesInProject(t = !0) {
|
|
6490
6644
|
const e = this._api.language, o = `PREFIX qcy: <${y.qcy}>
|
|
6491
|
-
PREFIX skos: <${
|
|
6645
|
+
PREFIX skos: <${R.skos}>
|
|
6492
6646
|
SELECT ?iri (SAMPLE(?l) AS ?label) ?count
|
|
6493
6647
|
WHERE {
|
|
6494
6648
|
?iri a qcy:EntityCategory .
|
|
@@ -6562,11 +6716,7 @@ WHERE {
|
|
|
6562
6716
|
${s}
|
|
6563
6717
|
}
|
|
6564
6718
|
GROUP BY ?sourceCat ?predicate ?targetCat
|
|
6565
|
-
ORDER BY DESC(?weight)`, n = await this.
|
|
6566
|
-
a,
|
|
6567
|
-
this._projectId,
|
|
6568
|
-
this._graphType
|
|
6569
|
-
), p = n.results.bindings.filter(
|
|
6719
|
+
ORDER BY DESC(?weight)`, n = await this._fetchSummaryData(a, s), p = n.results.bindings.filter(
|
|
6570
6720
|
(c) => c.sourceCat && c.predicate && c.targetCat
|
|
6571
6721
|
);
|
|
6572
6722
|
if (t === "graph") {
|
|
@@ -6597,6 +6747,41 @@ ORDER BY DESC(?weight)`, n = await this._api.sparql(
|
|
|
6597
6747
|
return n;
|
|
6598
6748
|
}
|
|
6599
6749
|
// ── Private helpers ────────────────────────────────────────────────────────
|
|
6750
|
+
/**
|
|
6751
|
+
* Fetches the category-summary rows. On QLever the pre-computed
|
|
6752
|
+
* `entity-summary` materialized view is tried first; if it yields no rows we
|
|
6753
|
+
* warn and fall back to the live aggregation query. Fuseki always uses the
|
|
6754
|
+
* live query.
|
|
6755
|
+
*/
|
|
6756
|
+
async _fetchSummaryData(t, e) {
|
|
6757
|
+
if (this._graphType !== "fuseki") {
|
|
6758
|
+
const r = `PREFIX view: <https://qlever.cs.uni-freiburg.de/materializedView/>
|
|
6759
|
+
SELECT ?sourceCat ?predicate ?targetCat ?weight
|
|
6760
|
+
WHERE {
|
|
6761
|
+
SERVICE view:entity-summary {
|
|
6762
|
+
_:cfg view:column-sourceCat ?sourceCat ;
|
|
6763
|
+
view:column-predicate ?predicate ;
|
|
6764
|
+
view:column-targetCat ?targetCat ;
|
|
6765
|
+
view:column-weight ?weight .
|
|
6766
|
+
}
|
|
6767
|
+
${e}
|
|
6768
|
+
}
|
|
6769
|
+
ORDER BY DESC(?weight)`, s = await this._api.sparql(
|
|
6770
|
+
r,
|
|
6771
|
+
this._projectId,
|
|
6772
|
+
this._graphType
|
|
6773
|
+
);
|
|
6774
|
+
if (s?.results?.bindings?.length) return s;
|
|
6775
|
+
console.warn(
|
|
6776
|
+
'[CueProjectEntities] Materialized view "entity-summary" returned no rows — falling back to the live query.'
|
|
6777
|
+
);
|
|
6778
|
+
}
|
|
6779
|
+
return await this._api.sparql(
|
|
6780
|
+
t,
|
|
6781
|
+
this._projectId,
|
|
6782
|
+
this._graphType
|
|
6783
|
+
);
|
|
6784
|
+
}
|
|
6600
6785
|
_computeEntityInfoMap() {
|
|
6601
6786
|
const t = this._entityDetails.get(), e = this._entityDocuments.get(), o = this._entityRelationships.get(), r = this._entityOSMMap.get(), s = this._osmWKTMap.get(), a = /* @__PURE__ */ new Set([
|
|
6602
6787
|
...Object.keys(t),
|
|
@@ -6614,18 +6799,18 @@ ORDER BY DESC(?weight)`, n = await this._api.sparql(
|
|
|
6614
6799
|
(f) => s[f] !== void 0 && !u.has(f) && !!u.add(f)
|
|
6615
6800
|
).map((f) => ({ osmIRI: f, wkt: s[f] }));
|
|
6616
6801
|
const m = /* @__PURE__ */ new Map();
|
|
6617
|
-
for (const { osm: f, viaRels:
|
|
6618
|
-
const
|
|
6619
|
-
if (
|
|
6620
|
-
for (const I of
|
|
6802
|
+
for (const { osm: f, viaRels: _, entityUUID: w } of h.indirect) {
|
|
6803
|
+
const E = s[f];
|
|
6804
|
+
if (E)
|
|
6805
|
+
for (const I of _) {
|
|
6621
6806
|
const v = `${I}:${w}`, b = m.get(v) ?? { geometries: [], entityUUID: w };
|
|
6622
|
-
b.geometries.some((
|
|
6807
|
+
b.geometries.some((S) => S.osmIRI === f) || (b.geometries.push({ osmIRI: f, wkt: E }), m.set(v, b));
|
|
6623
6808
|
}
|
|
6624
6809
|
}
|
|
6625
6810
|
m.size > 0 && (g = Array.from(m.entries()).map(
|
|
6626
|
-
([f, { geometries:
|
|
6811
|
+
([f, { geometries: _, entityUUID: w }]) => ({
|
|
6627
6812
|
rel: f.split(":")[0],
|
|
6628
|
-
geometries:
|
|
6813
|
+
geometries: _,
|
|
6629
6814
|
entityUUID: w
|
|
6630
6815
|
})
|
|
6631
6816
|
));
|
|
@@ -6753,10 +6938,10 @@ GROUP BY ?e1Cat ?e2Cat`;
|
|
|
6753
6938
|
async _fetchOSMLocations(t) {
|
|
6754
6939
|
const e = t.filter((n) => !n.includes("/relation/"));
|
|
6755
6940
|
if (e.length === 0) return;
|
|
6756
|
-
const o = e.map((n) => `<${n}>`).join(" "), r = `PREFIX geo: <${
|
|
6941
|
+
const o = e.map((n) => `<${n}>`).join(" "), r = `PREFIX geo: <${R.geo}>
|
|
6757
6942
|
SELECT * WHERE {
|
|
6758
6943
|
VALUES ?s { ${o} }
|
|
6759
|
-
SERVICE <${
|
|
6944
|
+
SERVICE <${Ir}> {
|
|
6760
6945
|
?s geo:hasGeometry/geo:asWKT ?wkt
|
|
6761
6946
|
}
|
|
6762
6947
|
}`, s = await this._api.sparql(
|
|
@@ -6770,7 +6955,7 @@ SELECT * WHERE {
|
|
|
6770
6955
|
}
|
|
6771
6956
|
}
|
|
6772
6957
|
var l = /* @__PURE__ */ ((i) => (i.AUTOMATION = "automation", i.ARCHIVE = "archive", i.AUDIO = "audio", i.BACKUP = "backup", i.BINARY = "binary", i.BIM = "bim", i.CAD = "cad", i.DATA = "data", i.EMAIL = "email", i.FONT = "font", i.GEOSPATIAL = "geospatial", i.IMAGE = "image", i.INSTALLER = "installer", i.MARKUP = "markup", i.MULTIMEDIA = "multimedia", i.PLANNING = "planning", i.PRESENTATION = "presentation", i.SCRIPT = "script", i.SPREADSHEET = "spreadsheet", i.TEXT = "text", i.THREE_D = "3d", i.UNKNOWN = "unknown", i.VIDEO = "video", i))(l || {});
|
|
6773
|
-
const
|
|
6958
|
+
const ct = {
|
|
6774
6959
|
".aac": {
|
|
6775
6960
|
type: l.AUDIO,
|
|
6776
6961
|
open: !0,
|
|
@@ -7631,7 +7816,30 @@ const lt = {
|
|
|
7631
7816
|
}
|
|
7632
7817
|
};
|
|
7633
7818
|
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 + "";
|
|
7634
|
-
|
|
7819
|
+
const Sr = `PREFIX view: <https://qlever.cs.uni-freiburg.de/materializedView/>
|
|
7820
|
+
SELECT ?ext ?totalSize ?docCount
|
|
7821
|
+
WHERE {
|
|
7822
|
+
SERVICE view:docs-by-suffix {
|
|
7823
|
+
_:cfg view:column-ext ?ext ;
|
|
7824
|
+
view:column-totalSize ?totalSize ;
|
|
7825
|
+
view:column-docCount ?docCount .
|
|
7826
|
+
}
|
|
7827
|
+
}`, Tr = `PREFIX view: <https://qlever.cs.uni-freiburg.de/materializedView/>
|
|
7828
|
+
SELECT ?cat ?totalSize ?docCount
|
|
7829
|
+
WHERE {
|
|
7830
|
+
SERVICE view:docs-by-category {
|
|
7831
|
+
_:cfg view:column-cat ?cat ;
|
|
7832
|
+
view:column-totalSize ?totalSize ;
|
|
7833
|
+
view:column-docCount ?docCount .
|
|
7834
|
+
}
|
|
7835
|
+
}`, Rr = `PREFIX view: <https://qlever.cs.uni-freiburg.de/materializedView/>
|
|
7836
|
+
SELECT ?count
|
|
7837
|
+
WHERE {
|
|
7838
|
+
SERVICE view:doc-duplicates {
|
|
7839
|
+
_:cfg view:column-count ?count .
|
|
7840
|
+
}
|
|
7841
|
+
}`;
|
|
7842
|
+
class lt {
|
|
7635
7843
|
constructor(t, e, o, r = ut, s, a, n = !1) {
|
|
7636
7844
|
this._api = t, this._projectId = e, this._queryCache = s, this._graphType = a, this._verbose = n, this.baseURL = `${r}${e}/`, this._currentLang = o ?? this._api.language, this.documentInfoMap = this._documentInfoMap.asReadonly(), this.projectDocumentsData = this._projectDocumentsData.asReadonly();
|
|
7637
7845
|
}
|
|
@@ -7644,10 +7852,10 @@ class ct {
|
|
|
7644
7852
|
baseURL;
|
|
7645
7853
|
/** Tracks the language for which `_documentInfoMap` is currently populated. */
|
|
7646
7854
|
_currentLang;
|
|
7647
|
-
_documentInfoMap = new
|
|
7855
|
+
_documentInfoMap = new x({});
|
|
7648
7856
|
/** Cumulative unique document UUIDs ever passed to request methods (survives cache hits). */
|
|
7649
7857
|
_seenIds = /* @__PURE__ */ new Set();
|
|
7650
|
-
_projectDocumentsData = new
|
|
7858
|
+
_projectDocumentsData = new x({
|
|
7651
7859
|
duplicateCount: 0,
|
|
7652
7860
|
documentsBySuffix: {},
|
|
7653
7861
|
documentsByContentCategory: {}
|
|
@@ -7693,9 +7901,9 @@ class ct {
|
|
|
7693
7901
|
t + e + o,
|
|
7694
7902
|
async () => {
|
|
7695
7903
|
const [r, s, a] = await Promise.all([
|
|
7696
|
-
this.
|
|
7697
|
-
this.
|
|
7698
|
-
this.
|
|
7904
|
+
this._fetchDocumentsBySuffix(),
|
|
7905
|
+
this._fetchDocumentsByContentCategory(),
|
|
7906
|
+
this._fetchDuplicateCount()
|
|
7699
7907
|
]);
|
|
7700
7908
|
return { duplicateCount: a, documentsBySuffix: r, documentsByContentCategory: s };
|
|
7701
7909
|
},
|
|
@@ -7850,7 +8058,7 @@ WHERE {
|
|
|
7850
8058
|
});
|
|
7851
8059
|
}
|
|
7852
8060
|
documentsByFileType(t, e = !1) {
|
|
7853
|
-
const o = new Set(t), r = Object.values(
|
|
8061
|
+
const o = new Set(t), r = Object.values(ct).filter((s) => o.has(s.type)).map((s) => s.suffix);
|
|
7854
8062
|
return this.documentsBySuffix(r, e);
|
|
7855
8063
|
}
|
|
7856
8064
|
async documentsByContentCategory(t, e = !1) {
|
|
@@ -7888,7 +8096,7 @@ WHERE {
|
|
|
7888
8096
|
});
|
|
7889
8097
|
}
|
|
7890
8098
|
documentsByMime(t, e = !1) {
|
|
7891
|
-
const o = new Set(t), r = Object.values(
|
|
8099
|
+
const o = new Set(t), r = Object.values(ct).filter((s) => o.has(s.mime)).map((s) => s.suffix);
|
|
7892
8100
|
return this.documentsBySuffix(r, e);
|
|
7893
8101
|
}
|
|
7894
8102
|
// ── Private helpers ────────────────────────────────────────────────────────
|
|
@@ -7979,6 +8187,11 @@ GROUP BY ?id ?suffix ?size`, r = await this._api.sparql(o, this._projectId, this
|
|
|
7979
8187
|
}), this._documentInfoMap.set(s), this._log(`fetchSimpleDocumentInfoBatch: ${Object.keys(a).length} fetched | cumulative: ${Object.keys(s).length} with metadata / ${this._seenIds.size} seen`), a;
|
|
7980
8188
|
}
|
|
7981
8189
|
async _fetchDocumentsBySuffix() {
|
|
8190
|
+
if (this._graphType !== "fuseki") {
|
|
8191
|
+
const e = await this._runDocumentsBySuffixQuery(Sr);
|
|
8192
|
+
if (Object.keys(e).length > 0) return e;
|
|
8193
|
+
console.warn(`[CueProjectDocuments] Materialized view "docs-by-suffix" returned no rows for project ${this._projectId} — falling back to live query.`);
|
|
8194
|
+
}
|
|
7982
8195
|
return this._runDocumentsBySuffixQuery(this._buildDocumentsBySuffixQuery());
|
|
7983
8196
|
}
|
|
7984
8197
|
_buildDocumentsBySuffixQuery() {
|
|
@@ -8008,6 +8221,11 @@ ORDER BY DESC(?docCount)`;
|
|
|
8008
8221
|
}), o;
|
|
8009
8222
|
}
|
|
8010
8223
|
async _fetchDocumentsByContentCategory() {
|
|
8224
|
+
if (this._graphType !== "fuseki") {
|
|
8225
|
+
const e = await this._runDocumentsByContentCategoryQuery(Tr);
|
|
8226
|
+
if (Object.keys(e).length > 0) return e;
|
|
8227
|
+
console.warn(`[CueProjectDocuments] Materialized view "docs-by-category" returned no rows for project ${this._projectId} — falling back to live query.`);
|
|
8228
|
+
}
|
|
8011
8229
|
return this._runDocumentsByContentCategoryQuery(this._buildDocumentsByContentCategoryQuery());
|
|
8012
8230
|
}
|
|
8013
8231
|
_buildDocumentsByContentCategoryQuery() {
|
|
@@ -8037,6 +8255,14 @@ ORDER BY DESC(?docCount)`;
|
|
|
8037
8255
|
}), o;
|
|
8038
8256
|
}
|
|
8039
8257
|
async _fetchDuplicateCount() {
|
|
8258
|
+
if (this._graphType !== "fuseki") {
|
|
8259
|
+
const e = await this._api.sparql(Rr, this._projectId, this._graphType);
|
|
8260
|
+
if (e.results.bindings.length > 0) {
|
|
8261
|
+
const o = e.results.bindings[0];
|
|
8262
|
+
return o?.count ? parseInt(o.count.value, 10) : 0;
|
|
8263
|
+
}
|
|
8264
|
+
console.warn(`[CueProjectDocuments] Materialized view "doc-duplicates" returned no rows for project ${this._projectId} — falling back to live query.`);
|
|
8265
|
+
}
|
|
8040
8266
|
return this._runDuplicateCountQuery(this._buildDuplicateCountQuery());
|
|
8041
8267
|
}
|
|
8042
8268
|
_buildDuplicateCountQuery() {
|
|
@@ -8058,9 +8284,9 @@ WHERE {
|
|
|
8058
8284
|
return o?.count ? parseInt(o.count.value, 10) : 0;
|
|
8059
8285
|
}
|
|
8060
8286
|
}
|
|
8061
|
-
class
|
|
8287
|
+
class Ar {
|
|
8062
8288
|
constructor(t, e, { language: o, queryCache: r, rdfBase: s = ut, graphType: a, verbose: n }) {
|
|
8063
|
-
this._api = t, this._projectId = e, this.schema = new
|
|
8289
|
+
this._api = t, this._projectId = e, this.schema = new Cr(t, e, o, r, a, n), this.entities = new _e(t, e, s, r, a, n), this.documents = new lt(t, e, o, s, r, a, n), 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((p) => console.error("[CueProjectView] fetchOverview failed:", p));
|
|
8064
8290
|
}
|
|
8065
8291
|
_api;
|
|
8066
8292
|
_projectId;
|
|
@@ -8091,7 +8317,7 @@ class hr {
|
|
|
8091
8317
|
/** Project document overview (counts by suffix and category). Fetched on init. */
|
|
8092
8318
|
projectDocumentsData;
|
|
8093
8319
|
// ── Search state ───────────────────────────────────────────────────────────
|
|
8094
|
-
_searchResults = new
|
|
8320
|
+
_searchResults = new x(void 0);
|
|
8095
8321
|
/** The result of the most recent `search()` call. `undefined` before first search. */
|
|
8096
8322
|
searchResults;
|
|
8097
8323
|
_destroyed = !1;
|
|
@@ -8178,7 +8404,7 @@ class hr {
|
|
|
8178
8404
|
this._destroyed = !0, this._searchResults.set(void 0);
|
|
8179
8405
|
}
|
|
8180
8406
|
}
|
|
8181
|
-
function
|
|
8407
|
+
function ee(i, t) {
|
|
8182
8408
|
return new Promise((e) => {
|
|
8183
8409
|
const o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
8184
8410
|
for (const w of i)
|
|
@@ -8191,14 +8417,14 @@ function Yt(i, t) {
|
|
|
8191
8417
|
s.has(w.contentUUID) ? (s.get(w.contentUUID) || []).some((v) => v.locationUUID === w.locationUUID) || p.push(w) : n.push(w);
|
|
8192
8418
|
const c = [], h = [];
|
|
8193
8419
|
for (const w of t) {
|
|
8194
|
-
const
|
|
8195
|
-
|
|
8420
|
+
const E = o.get(w.contentUUID);
|
|
8421
|
+
E ? E.some((v) => v.locationUUID === w.locationUUID) || h.push(w) : c.push(w);
|
|
8196
8422
|
}
|
|
8197
8423
|
const d = i.length - n.length - p.length, g = i.length, u = g > 0 ? d / g : 1;
|
|
8198
8424
|
let m = 0, f = 0;
|
|
8199
8425
|
for (const w of i)
|
|
8200
8426
|
f += w.size || 0, (s.get(w.contentUUID) || []).some((v) => v.locationUUID === w.locationUUID) && (m += w.size || 0);
|
|
8201
|
-
const
|
|
8427
|
+
const _ = f > 0 ? m / f : 1;
|
|
8202
8428
|
e({
|
|
8203
8429
|
localNotOnRemote: n,
|
|
8204
8430
|
localNotOnRemotePathOnly: p,
|
|
@@ -8208,27 +8434,27 @@ function Yt(i, t) {
|
|
|
8208
8434
|
totalCount: g,
|
|
8209
8435
|
syncSize: m,
|
|
8210
8436
|
totalSize: f,
|
|
8211
|
-
synctPctSize:
|
|
8437
|
+
synctPctSize: _,
|
|
8212
8438
|
synctPctCount: u
|
|
8213
8439
|
});
|
|
8214
8440
|
});
|
|
8215
8441
|
}
|
|
8216
|
-
const { namedNode:
|
|
8217
|
-
|
|
8218
|
-
const { namedNode:
|
|
8219
|
-
|
|
8220
|
-
function
|
|
8442
|
+
const { namedNode: Pr, literal: Xr } = j;
|
|
8443
|
+
Pr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
8444
|
+
const { namedNode: Kr } = j, { namedNode: Or, literal: Qr } = j;
|
|
8445
|
+
Or("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
8446
|
+
function Dr(i) {
|
|
8221
8447
|
const t = i.split(".");
|
|
8222
8448
|
return t.length > 1 ? "." + t.pop()?.toLowerCase() : "";
|
|
8223
8449
|
}
|
|
8224
|
-
const { namedNode:
|
|
8225
|
-
|
|
8226
|
-
const { namedNode:
|
|
8227
|
-
|
|
8228
|
-
function
|
|
8229
|
-
const c =
|
|
8230
|
-
a === void 0 && (a =
|
|
8231
|
-
const g =
|
|
8450
|
+
const { namedNode: Lr, literal: Yr } = j;
|
|
8451
|
+
Lr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
8452
|
+
const { namedNode: qr, literal: Zr } = j;
|
|
8453
|
+
qr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
8454
|
+
function oe(i, t, e, o, r, s, a, n = !1, p = !1) {
|
|
8455
|
+
const c = Dr(i), h = D(o), d = `${t}/${h}${c}`;
|
|
8456
|
+
a === void 0 && (a = ct[c]?.mime ?? "application/octet-stream");
|
|
8457
|
+
const g = io(i, r);
|
|
8232
8458
|
return {
|
|
8233
8459
|
name: i,
|
|
8234
8460
|
blob_name: d,
|
|
@@ -8248,25 +8474,25 @@ function Zt(i, t, e, o, r, s, a, n = !1, p = !1) {
|
|
|
8248
8474
|
})
|
|
8249
8475
|
};
|
|
8250
8476
|
}
|
|
8251
|
-
async function
|
|
8477
|
+
async function $() {
|
|
8252
8478
|
return import(
|
|
8253
8479
|
/* webpackIgnore: true */
|
|
8254
8480
|
"fs/promises"
|
|
8255
8481
|
);
|
|
8256
8482
|
}
|
|
8257
|
-
async function
|
|
8483
|
+
async function re(i) {
|
|
8258
8484
|
if (typeof window < "u")
|
|
8259
8485
|
throw new Error(
|
|
8260
8486
|
`Cannot read file from path "${i}" in a browser environment. Provide file.data (Uint8Array) instead.`
|
|
8261
8487
|
);
|
|
8262
|
-
const { readFile: t } = await
|
|
8488
|
+
const { readFile: t } = await $();
|
|
8263
8489
|
return t(i);
|
|
8264
8490
|
}
|
|
8265
8491
|
let q = null, G = null, H = null;
|
|
8266
|
-
function
|
|
8492
|
+
function Jr(i) {
|
|
8267
8493
|
H = i, G = null, q = null;
|
|
8268
8494
|
}
|
|
8269
|
-
async function
|
|
8495
|
+
async function jr() {
|
|
8270
8496
|
if (typeof window < "u") {
|
|
8271
8497
|
if (!H)
|
|
8272
8498
|
throw new Error(
|
|
@@ -8278,7 +8504,7 @@ async function fr() {
|
|
|
8278
8504
|
const t = new Uint8Array(await i.arrayBuffer()), o = await import(`${H}/dir_scanner_wasm.mjs`);
|
|
8279
8505
|
await o.default({ module_or_path: t }), q = o.scan;
|
|
8280
8506
|
} else {
|
|
8281
|
-
const { readFile: i } = await
|
|
8507
|
+
const { readFile: i } = await $(), { join: t } = await import(
|
|
8282
8508
|
/* webpackIgnore: true */
|
|
8283
8509
|
"path"
|
|
8284
8510
|
), { pathToFileURL: e } = await import(
|
|
@@ -8288,7 +8514,7 @@ async function fr() {
|
|
|
8288
8514
|
await a.default({ module_or_path: r }), q = a.scan;
|
|
8289
8515
|
}
|
|
8290
8516
|
}
|
|
8291
|
-
const
|
|
8517
|
+
const $r = "qlever", N = 1e3, mt = "cue:pending:";
|
|
8292
8518
|
async function wt(i) {
|
|
8293
8519
|
const { tmpdir: t } = await import(
|
|
8294
8520
|
/* webpackIgnore: true */
|
|
@@ -8299,37 +8525,37 @@ async function wt(i) {
|
|
|
8299
8525
|
);
|
|
8300
8526
|
return e(t(), `cue-sync-pending-${i}.json`);
|
|
8301
8527
|
}
|
|
8302
|
-
async function
|
|
8528
|
+
async function se(i) {
|
|
8303
8529
|
if (typeof window < "u") {
|
|
8304
8530
|
const t = window.localStorage.getItem(`${mt}${i}`);
|
|
8305
8531
|
return t ? JSON.parse(t) : null;
|
|
8306
8532
|
}
|
|
8307
8533
|
try {
|
|
8308
|
-
const t = await (await
|
|
8534
|
+
const t = await (await $()).readFile(await wt(i), "utf-8");
|
|
8309
8535
|
return JSON.parse(t);
|
|
8310
8536
|
} catch {
|
|
8311
8537
|
return null;
|
|
8312
8538
|
}
|
|
8313
8539
|
}
|
|
8314
|
-
async function
|
|
8540
|
+
async function ae(i) {
|
|
8315
8541
|
const t = JSON.stringify(i);
|
|
8316
8542
|
if (typeof window < "u") {
|
|
8317
8543
|
window.localStorage.setItem(`${mt}${i.spaceId}`, t);
|
|
8318
8544
|
return;
|
|
8319
8545
|
}
|
|
8320
|
-
await (await
|
|
8546
|
+
await (await $()).writeFile(await wt(i.spaceId), t, "utf-8");
|
|
8321
8547
|
}
|
|
8322
|
-
async function
|
|
8548
|
+
async function zr(i) {
|
|
8323
8549
|
if (typeof window < "u") {
|
|
8324
8550
|
window.localStorage.removeItem(`${mt}${i}`);
|
|
8325
8551
|
return;
|
|
8326
8552
|
}
|
|
8327
8553
|
try {
|
|
8328
|
-
await (await
|
|
8554
|
+
await (await $()).unlink(await wt(i));
|
|
8329
8555
|
} catch {
|
|
8330
8556
|
}
|
|
8331
8557
|
}
|
|
8332
|
-
class
|
|
8558
|
+
class Ur {
|
|
8333
8559
|
constructor(t, e, o, r) {
|
|
8334
8560
|
this._auth = t, this._projects = e, this._blob = o, this._gatewayUrl = r;
|
|
8335
8561
|
}
|
|
@@ -8385,7 +8611,7 @@ class vr {
|
|
|
8385
8611
|
*/
|
|
8386
8612
|
async flushPendingMetadata(t, e, o) {
|
|
8387
8613
|
this._legacy = o ?? !1;
|
|
8388
|
-
const r = await
|
|
8614
|
+
const r = await se(t);
|
|
8389
8615
|
if (!(!r || r.items.length === 0)) {
|
|
8390
8616
|
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 ⏳`);
|
|
8391
8617
|
try {
|
|
@@ -8408,22 +8634,22 @@ class vr {
|
|
|
8408
8634
|
this._api?.getConsumption(o) ?? Promise.reject(new Error("CueSyncApi is not bound to a CueApi instance")),
|
|
8409
8635
|
this._fetchUnitCreditMap(s),
|
|
8410
8636
|
this._fetchTierNames()
|
|
8411
|
-
]), f = (await
|
|
8412
|
-
let w = 0,
|
|
8413
|
-
for (const v of
|
|
8637
|
+
]), f = (await ee(t, h)).localNotOnRemote ?? [], _ = f.length > 0 ? await this.scanCost(f) : [];
|
|
8638
|
+
let w = 0, E = 0;
|
|
8639
|
+
for (const v of _) {
|
|
8414
8640
|
w += v.units;
|
|
8415
|
-
const b = g[c],
|
|
8641
|
+
const b = g[c], S = b?.[v.ext] ?? 1;
|
|
8416
8642
|
s && b && !(v.ext in b) && console.info(` Unknown format: .${v.ext} (using default rate of 1 credit/unit)`);
|
|
8417
|
-
const P = v.units *
|
|
8418
|
-
|
|
8643
|
+
const P = v.units * S;
|
|
8644
|
+
E += P, v.credits = Math.round(P);
|
|
8419
8645
|
}
|
|
8420
8646
|
const I = u[c] ?? c;
|
|
8421
8647
|
return {
|
|
8422
|
-
costRecords:
|
|
8648
|
+
costRecords: _,
|
|
8423
8649
|
tier: c,
|
|
8424
8650
|
tierName: I,
|
|
8425
8651
|
unitsToConsume: w,
|
|
8426
|
-
creditsToConsume: Math.round(
|
|
8652
|
+
creditsToConsume: Math.round(E),
|
|
8427
8653
|
creditsAvailable: d.creditsAvailable,
|
|
8428
8654
|
unitsAvailable: d.unitsAvailable,
|
|
8429
8655
|
filesToUpload: f.length,
|
|
@@ -8440,44 +8666,44 @@ class vr {
|
|
|
8440
8666
|
const [d, g] = await Promise.all([
|
|
8441
8667
|
this._listRemoteFiles(h, o, r, a),
|
|
8442
8668
|
this._api?.getConsumption(o) ?? Promise.reject(new Error("CueSyncApi is not bound to a CueApi instance"))
|
|
8443
|
-
]), { unitsAvailable: u } = g, m = await
|
|
8669
|
+
]), { unitsAvailable: u } = g, m = await ee(t, d);
|
|
8444
8670
|
a && (console.info(`Total local files: ${t.length}`), console.info(`Total remote files: ${d.length}`), console.info(
|
|
8445
8671
|
`Total files to sync: ${(m.localNotOnRemote?.length ?? 0) + m.localNotOnRemotePathOnly.length}`
|
|
8446
8672
|
));
|
|
8447
|
-
let f = m.syncCount,
|
|
8673
|
+
let f = m.syncCount, _ = m.syncSize, w = 0, E = !1;
|
|
8448
8674
|
const I = m.localNotOnRemote ?? [];
|
|
8449
8675
|
if (I.length > 0) {
|
|
8450
|
-
const
|
|
8451
|
-
if (
|
|
8676
|
+
const S = (await this.scanCost(I)).reduce((P, ke) => P + ke.units, 0);
|
|
8677
|
+
if (S > u)
|
|
8452
8678
|
throw new Error(
|
|
8453
|
-
`Insufficient units: ${
|
|
8679
|
+
`Insufficient units: ${S} units required but only ${u} available.`
|
|
8454
8680
|
);
|
|
8455
8681
|
}
|
|
8456
8682
|
await this._initPendingBatch(o, a), a && I.length && console.info("Syncing missing files ⏳");
|
|
8457
8683
|
for (const b of I)
|
|
8458
8684
|
try {
|
|
8459
|
-
const
|
|
8685
|
+
const S = oe(
|
|
8460
8686
|
b.relativePath,
|
|
8461
8687
|
o,
|
|
8462
8688
|
s,
|
|
8463
8689
|
b.md5,
|
|
8464
8690
|
r
|
|
8465
8691
|
);
|
|
8466
|
-
if (!
|
|
8467
|
-
const P = b.data ?? new Uint8Array(await
|
|
8692
|
+
if (!S.blob_name) throw new Error(`blob_name missing for ${b.relativePath}`);
|
|
8693
|
+
const P = b.data ?? new Uint8Array(await re(b.fullPath));
|
|
8468
8694
|
await this._blob.uploadRaw(
|
|
8469
|
-
|
|
8695
|
+
S.blob_name,
|
|
8470
8696
|
P,
|
|
8471
|
-
|
|
8697
|
+
S
|
|
8472
8698
|
), await this._queueFileLocation({
|
|
8473
8699
|
relativePath: b.relativePath,
|
|
8474
8700
|
md5: b.md5,
|
|
8475
8701
|
size: b.size,
|
|
8476
8702
|
providerId: r,
|
|
8477
8703
|
fileContentExists: !1
|
|
8478
|
-
}),
|
|
8479
|
-
} catch (
|
|
8480
|
-
w += 1, console.error(`[CueSyncApi] Failed to upload file: ${b.fullPath}`), a && console.error("[CueSyncApi] Upload error details:",
|
|
8704
|
+
}), E = !0, f += 1, _ += b.size || 0, this._logProgress(f, m.totalCount, _, m.totalSize, n);
|
|
8705
|
+
} catch (S) {
|
|
8706
|
+
w += 1, console.error(`[CueSyncApi] Failed to upload file: ${b.fullPath}`), a && console.error("[CueSyncApi] Upload error details:", S);
|
|
8481
8707
|
}
|
|
8482
8708
|
a && m.localNotOnRemotePathOnly.length && console.info(`Syncing missing file locations (on provider "${r}") ⏳`);
|
|
8483
8709
|
for (const b of m.localNotOnRemotePathOnly)
|
|
@@ -8487,23 +8713,23 @@ class vr {
|
|
|
8487
8713
|
size: b.size,
|
|
8488
8714
|
providerId: r,
|
|
8489
8715
|
fileContentExists: !0
|
|
8490
|
-
}),
|
|
8716
|
+
}), E = !0, f += 1, _ += b.size || 0, this._logProgress(f, m.totalCount, _, m.totalSize, n);
|
|
8491
8717
|
await this._drainPending(a), this._stopFlushTimer();
|
|
8492
8718
|
const v = await (this._api?.getConsumption(o) ?? Promise.resolve({ creditsAvailable: 0 }));
|
|
8493
8719
|
return {
|
|
8494
8720
|
syncCount: f,
|
|
8495
|
-
syncSize:
|
|
8721
|
+
syncSize: _,
|
|
8496
8722
|
failedUploads: w,
|
|
8497
8723
|
totalCount: m.totalCount,
|
|
8498
8724
|
totalSize: m.totalSize,
|
|
8499
|
-
rdfWritten:
|
|
8725
|
+
rdfWritten: E,
|
|
8500
8726
|
creditsAvailable: v.creditsAvailable
|
|
8501
8727
|
};
|
|
8502
8728
|
}
|
|
8503
8729
|
async _getOrCreateGraph(t, e) {
|
|
8504
8730
|
const o = this._graphMap.get(t);
|
|
8505
8731
|
if (o) return o;
|
|
8506
|
-
const s = (await this._projects.getProject(t))?.projectSettings?.graph?.type ??
|
|
8732
|
+
const s = (await this._projects.getProject(t))?.projectSettings?.graph?.type ?? $r, a = s === "qlever" ? `${this._gatewayUrl}${de}` : `${this._gatewayUrl}${he}`, n = s === "qlever" ? `${this._gatewayUrl}${vo}` : `${this._gatewayUrl}${yo}`, p = new so({
|
|
8507
8733
|
graphType: s,
|
|
8508
8734
|
queryEndpoint: a,
|
|
8509
8735
|
updateEndpoint: n,
|
|
@@ -8569,7 +8795,7 @@ WHERE {
|
|
|
8569
8795
|
}
|
|
8570
8796
|
async _initPendingBatch(t, e) {
|
|
8571
8797
|
this._flushTimer !== null && (clearInterval(this._flushTimer), this._flushTimer = null), this._pendingSpaceId = t, this._pendingItems = [];
|
|
8572
|
-
const o = await
|
|
8798
|
+
const o = await se(t);
|
|
8573
8799
|
if (o && o.items.length > 0) {
|
|
8574
8800
|
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 ⏳`);
|
|
8575
8801
|
try {
|
|
@@ -8590,7 +8816,7 @@ WHERE {
|
|
|
8590
8816
|
typeof r == "object" && typeof r.unref == "function" && r.unref(), this._flushTimer = r;
|
|
8591
8817
|
}
|
|
8592
8818
|
async _queueFileLocation(t) {
|
|
8593
|
-
this._pendingItems.push(t), this._pendingSpaceId && await
|
|
8819
|
+
this._pendingItems.push(t), this._pendingSpaceId && await ae({ spaceId: this._pendingSpaceId, items: this._pendingItems });
|
|
8594
8820
|
}
|
|
8595
8821
|
/**
|
|
8596
8822
|
* Flush all queued file-location items to the commands API in a single batch.
|
|
@@ -8605,18 +8831,18 @@ WHERE {
|
|
|
8605
8831
|
}
|
|
8606
8832
|
async _flushBatch(t, e, o) {
|
|
8607
8833
|
const r = [...t];
|
|
8608
|
-
this._pendingSpaceId === e && (this._pendingItems = []), await
|
|
8834
|
+
this._pendingSpaceId === e && (this._pendingItems = []), await zr(e);
|
|
8609
8835
|
try {
|
|
8610
8836
|
for (let s = 0; s < r.length; s += N)
|
|
8611
8837
|
await this._postFssBatch(r.slice(s, s + N), e);
|
|
8612
8838
|
o && console.info(`Wrote ${r.length} file location(s) to commands API ✅`);
|
|
8613
8839
|
} catch (s) {
|
|
8614
8840
|
const a = [...r, ...this._pendingItems];
|
|
8615
|
-
throw this._pendingItems = a, await
|
|
8841
|
+
throw this._pendingItems = a, await ae({ spaceId: e, items: a }), s;
|
|
8616
8842
|
}
|
|
8617
8843
|
}
|
|
8618
8844
|
async _postFssBatch(t, e) {
|
|
8619
|
-
const o = this._legacy ? `${this._gatewayUrl}${
|
|
8845
|
+
const o = this._legacy ? `${this._gatewayUrl}${qt}?blob=true` : `${this._gatewayUrl}${qt}`;
|
|
8620
8846
|
let r;
|
|
8621
8847
|
try {
|
|
8622
8848
|
r = await this._auth.authenticatedFetch(o, {
|
|
@@ -8646,14 +8872,14 @@ WHERE {
|
|
|
8646
8872
|
* shown to the user before or after calling {@link sync}.
|
|
8647
8873
|
*/
|
|
8648
8874
|
async scanCost(t) {
|
|
8649
|
-
if (G || (G =
|
|
8875
|
+
if (G || (G = jr()), await G, !q) throw new Error("WASM scan function not initialised");
|
|
8650
8876
|
const e = 200, o = /* @__PURE__ */ new Map();
|
|
8651
8877
|
for (let r = 0; r < t.length; r += e) {
|
|
8652
8878
|
const s = t.slice(r, r + e), a = await Promise.all(
|
|
8653
8879
|
s.map(async (p) => ({
|
|
8654
8880
|
originalPath: p.relativePath,
|
|
8655
8881
|
// Use pre-loaded data if available (browser), otherwise read from disk (Node.js).
|
|
8656
|
-
data: p.data ?? new Uint8Array(await
|
|
8882
|
+
data: p.data ?? new Uint8Array(await re(p.fullPath))
|
|
8657
8883
|
}))
|
|
8658
8884
|
), n = q(a);
|
|
8659
8885
|
for (const p of n) {
|
|
@@ -8713,7 +8939,7 @@ WHERE {
|
|
|
8713
8939
|
const { spaceId: o, providerId: r, userId: s, signal: a, onProgress: n } = e;
|
|
8714
8940
|
if (!t.data)
|
|
8715
8941
|
throw new Error("syncBrowserFile requires file.data (Uint8Array). Read the file with File.arrayBuffer() first.");
|
|
8716
|
-
const p =
|
|
8942
|
+
const p = oe(t.relativePath, o, s, t.md5, r);
|
|
8717
8943
|
if (!p.blob_name) throw new Error(`blob_name missing for ${t.relativePath}`);
|
|
8718
8944
|
await this._blob.uploadRaw(
|
|
8719
8945
|
p.blob_name,
|
|
@@ -8757,7 +8983,7 @@ WHERE {
|
|
|
8757
8983
|
s({ percent: a, syncCount: t, totalCount: e, syncSize: o, totalSize: r });
|
|
8758
8984
|
}
|
|
8759
8985
|
}
|
|
8760
|
-
const
|
|
8986
|
+
const ie = {
|
|
8761
8987
|
production: {
|
|
8762
8988
|
gatewayUrl: "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app",
|
|
8763
8989
|
tokenUrl: "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app/token",
|
|
@@ -8777,7 +9003,7 @@ const oe = {
|
|
|
8777
9003
|
firestoreEmulatorPort: 8080
|
|
8778
9004
|
}
|
|
8779
9005
|
};
|
|
8780
|
-
class
|
|
9006
|
+
class Ee {
|
|
8781
9007
|
auth;
|
|
8782
9008
|
api;
|
|
8783
9009
|
projects;
|
|
@@ -8805,7 +9031,7 @@ class fe {
|
|
|
8805
9031
|
* ```
|
|
8806
9032
|
*/
|
|
8807
9033
|
get gis() {
|
|
8808
|
-
return this._gis || (this._gis = new
|
|
9034
|
+
return this._gis || (this._gis = new yr(
|
|
8809
9035
|
() => this.api.getAuthHeaders(),
|
|
8810
9036
|
this._endpoints.gatewayUrl
|
|
8811
9037
|
)), this._gis;
|
|
@@ -8815,30 +9041,29 @@ class fe {
|
|
|
8815
9041
|
"Using default SDK app settings. Contact QAECY for your own configuration for any production code."
|
|
8816
9042
|
);
|
|
8817
9043
|
const o = t.apiKey ?? Z.apiKey, r = t.appId ?? Z.appId, s = t.measurementId ?? Z.measurementId, a = t.environment ?? "production";
|
|
8818
|
-
this._endpoints = { ...
|
|
9044
|
+
this._endpoints = { ...ie[a], ...t.endpoints }, this._isEmulator = a === "emulator", this._verbose = t.verbose ?? !1, this._app = xe().find((g) => g.name === "[DEFAULT]") ?? Ce({
|
|
8819
9045
|
apiKey: o,
|
|
8820
9046
|
appId: r,
|
|
8821
9047
|
measurementId: s,
|
|
8822
9048
|
authDomain: `${xt}.firebaseapp.com`,
|
|
8823
9049
|
projectId: xt,
|
|
8824
|
-
messagingSenderId:
|
|
8825
|
-
}), this.auth = new
|
|
8826
|
-
const n =
|
|
8827
|
-
this._isEmulator && (
|
|
8828
|
-
const d = new kt({
|
|
9050
|
+
messagingSenderId: no
|
|
9051
|
+
}), this.auth = new zt(this._app, this._isEmulator, this._endpoints), this.projects = new Wt(this.auth, this._app, this._isEmulator, this._endpoints), this._storageRaw = C(this._app, Tt), this._storageProcessed = C(this._app, Rt);
|
|
9052
|
+
const n = C(this._app, Pt), p = C(this._app, At), c = C(this._app, St), h = C(this._app, Ot), d = C(this._app, It);
|
|
9053
|
+
this._isEmulator && (K(this._storageRaw, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), K(this._storageProcessed, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort)), this.api = this._buildApi(this.projects), new Et({
|
|
8829
9054
|
storageRaw: this._storageRaw,
|
|
8830
9055
|
storageProcessed: this._storageProcessed,
|
|
8831
9056
|
storagePublic: n,
|
|
8832
9057
|
storageLogs: p,
|
|
8833
9058
|
storageChatSessions: c,
|
|
8834
|
-
storagePersistence: h
|
|
8835
|
-
|
|
8836
|
-
this.storage = new
|
|
9059
|
+
storagePersistence: h,
|
|
9060
|
+
storageSessions: d
|
|
9061
|
+
}), this.storage = new Ut(this.auth, this._endpoints.gatewayUrl), this.profile = new Vt(
|
|
8837
9062
|
this.auth,
|
|
8838
9063
|
this._app,
|
|
8839
9064
|
this._isEmulator,
|
|
8840
9065
|
this._endpoints.gatewayUrl
|
|
8841
|
-
), this.privileges = new
|
|
9066
|
+
), this.privileges = new Qt(this.auth.isSuperAdmin), this._isEmulator && K(h, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), this.cache = new Yt(h);
|
|
8842
9067
|
}
|
|
8843
9068
|
/**
|
|
8844
9069
|
* Create a `Cue` instance from an already-initialized Firebase app.
|
|
@@ -8857,34 +9082,35 @@ class fe {
|
|
|
8857
9082
|
* });
|
|
8858
9083
|
*/
|
|
8859
9084
|
static fromApp(t, e = {}) {
|
|
8860
|
-
const o = e.environment ?? "production", r = { ...
|
|
9085
|
+
const o = e.environment ?? "production", r = { ...ie[o], ...e.endpoints }, s = new zt(t, !1, r), a = new Wt(s, t, !1, r), n = C(t, Tt), p = C(t, Rt), c = C(t, Pt), h = C(t, At), d = C(t, St), g = C(t, Ot), u = C(t, It), m = new Et({
|
|
8861
9086
|
storageRaw: n,
|
|
8862
9087
|
storageProcessed: p,
|
|
8863
9088
|
storagePublic: c,
|
|
8864
9089
|
storageLogs: h,
|
|
8865
9090
|
storageChatSessions: d,
|
|
8866
|
-
storagePersistence: g
|
|
8867
|
-
|
|
8868
|
-
m.
|
|
8869
|
-
|
|
8870
|
-
|
|
9091
|
+
storagePersistence: g,
|
|
9092
|
+
storageSessions: u
|
|
9093
|
+
}), f = new Ur(s, a, m, r.gatewayUrl), _ = new Mt(s, r.gatewayUrl, a, f);
|
|
9094
|
+
f._bindApi(_);
|
|
9095
|
+
const w = new Vt(s, t, !1, r.gatewayUrl), E = Object.create(Ee.prototype), I = new Qt(s.isSuperAdmin), v = new Yt(g), b = new Ut(s, r.gatewayUrl);
|
|
9096
|
+
return Object.assign(E, {
|
|
8871
9097
|
_app: t,
|
|
8872
9098
|
_endpoints: r,
|
|
8873
9099
|
_isEmulator: o === "emulator",
|
|
8874
9100
|
_storageRaw: n,
|
|
8875
9101
|
_storageProcessed: p,
|
|
8876
9102
|
auth: s,
|
|
8877
|
-
api:
|
|
9103
|
+
api: _,
|
|
8878
9104
|
projects: a,
|
|
8879
|
-
profile:
|
|
8880
|
-
privileges:
|
|
8881
|
-
cache:
|
|
8882
|
-
storage:
|
|
8883
|
-
}),
|
|
9105
|
+
profile: w,
|
|
9106
|
+
privileges: I,
|
|
9107
|
+
cache: v,
|
|
9108
|
+
storage: b
|
|
9109
|
+
}), E;
|
|
8884
9110
|
}
|
|
8885
9111
|
/** Override in subclasses to provide a custom CueApi (e.g. with sync). */
|
|
8886
9112
|
_buildApi(t) {
|
|
8887
|
-
return new
|
|
9113
|
+
return new Mt(this.auth, this._endpoints.gatewayUrl, t);
|
|
8888
9114
|
}
|
|
8889
9115
|
/** Convenience: get the current user's Firebase ID token */
|
|
8890
9116
|
getToken(t = !1) {
|
|
@@ -8909,7 +9135,7 @@ class fe {
|
|
|
8909
9135
|
get: (r) => this.cache.getQueryCache(t, r).then((s) => s?.results),
|
|
8910
9136
|
set: (r, s) => this.cache.setQueryCache(t, r, { query: r, results: s })
|
|
8911
9137
|
};
|
|
8912
|
-
return new
|
|
9138
|
+
return new Ar(this.api, t, { verbose: this._verbose, ...e, queryCache: o });
|
|
8913
9139
|
}
|
|
8914
9140
|
/**
|
|
8915
9141
|
* Creates a `CueProjectEntities` instance for the given project, with the
|
|
@@ -8933,7 +9159,7 @@ class fe {
|
|
|
8933
9159
|
get: (r) => this.cache.getQueryCache(t, r).then((s) => s?.results),
|
|
8934
9160
|
set: (r, s) => this.cache.setQueryCache(t, r, { query: r, results: s })
|
|
8935
9161
|
};
|
|
8936
|
-
return new
|
|
9162
|
+
return new _e(
|
|
8937
9163
|
this.api,
|
|
8938
9164
|
t,
|
|
8939
9165
|
e?.rdfBase,
|
|
@@ -8964,7 +9190,7 @@ class fe {
|
|
|
8964
9190
|
const a = {
|
|
8965
9191
|
get: (p) => this.cache.getQueryCache(t, p).then((c) => c?.results),
|
|
8966
9192
|
set: (p, c) => this.cache.setQueryCache(t, p, { query: p, results: c })
|
|
8967
|
-
}, n = new
|
|
9193
|
+
}, n = new lt(
|
|
8968
9194
|
this.api,
|
|
8969
9195
|
t,
|
|
8970
9196
|
this.api.language,
|
|
@@ -8979,7 +9205,7 @@ class fe {
|
|
|
8979
9205
|
get: (s) => this.cache.getQueryCache(t, s).then((a) => a?.results),
|
|
8980
9206
|
set: (s, a) => this.cache.setQueryCache(t, s, { query: s, results: a })
|
|
8981
9207
|
};
|
|
8982
|
-
return new
|
|
9208
|
+
return new lt(
|
|
8983
9209
|
this.api,
|
|
8984
9210
|
t,
|
|
8985
9211
|
e?.language ?? this.api.language,
|
|
@@ -8991,30 +9217,33 @@ class fe {
|
|
|
8991
9217
|
}
|
|
8992
9218
|
}
|
|
8993
9219
|
export {
|
|
8994
|
-
|
|
8995
|
-
|
|
9220
|
+
St as B,
|
|
9221
|
+
Ee as C,
|
|
8996
9222
|
Kt as R,
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
|
|
9012
|
-
|
|
9013
|
-
|
|
9014
|
-
|
|
9015
|
-
|
|
9016
|
-
|
|
9017
|
-
|
|
9223
|
+
Mt as a,
|
|
9224
|
+
zt as b,
|
|
9225
|
+
Yt as c,
|
|
9226
|
+
Ao as d,
|
|
9227
|
+
Ro as e,
|
|
9228
|
+
yr as f,
|
|
9229
|
+
Po as g,
|
|
9230
|
+
Qt as h,
|
|
9231
|
+
Vt as i,
|
|
9232
|
+
lt as j,
|
|
9233
|
+
_e as k,
|
|
9234
|
+
Cr as l,
|
|
9235
|
+
Ar as m,
|
|
9236
|
+
Wt as n,
|
|
9237
|
+
x as o,
|
|
9238
|
+
Ut as p,
|
|
9239
|
+
Ur as q,
|
|
9240
|
+
So as r,
|
|
9241
|
+
Jr as s,
|
|
9242
|
+
dt as t,
|
|
9243
|
+
gt as u,
|
|
9018
9244
|
At as v,
|
|
9019
|
-
|
|
9245
|
+
Ot as w,
|
|
9246
|
+
Pt as x,
|
|
9247
|
+
It as y,
|
|
9248
|
+
Et as z
|
|
9020
9249
|
};
|