@qaecy/cue-sdk 0.0.16 → 0.0.18
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/{cue-DiFnK22Q.js → cue-D52ik-Oy.js} +639 -407
- package/index.d.ts +2 -0
- package/index.js +9 -8
- package/lib/cue.d.ts +50 -0
- package/lib/documents.d.ts +50 -0
- package/lib/storage.d.ts +26 -0
- package/node.js +43 -42
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { getApps as
|
|
2
|
-
import { ref as _, getDownloadURL as
|
|
3
|
-
import { Writer as
|
|
4
|
-
import { getFirestore as
|
|
5
|
-
import { getAuth as
|
|
6
|
-
import { v5 as
|
|
1
|
+
import { getApps as ge, initializeApp as ue } from "firebase/app";
|
|
2
|
+
import { ref as _, getDownloadURL as F, getMetadata as U, getBlob as Yt, updateMetadata as me, uploadBytesResumable as wt, uploadBytes as rt, StringFormat as we, uploadString as fe, listAll as z, getStorage as T, connectStorageEmulator as K } from "firebase/storage";
|
|
3
|
+
import { Writer as ye, DataFactory as j } from "n3";
|
|
4
|
+
import { getFirestore as be, connectFirestoreEmulator as ve, collection as ft, getDocs as _e, query as ke, where as Ee, limit as xe, doc as yt, getDoc as Ie, setDoc as Ce, serverTimestamp as Te, increment as Se } from "firebase/firestore";
|
|
5
|
+
import { getAuth as Ae, connectAuthEmulator as Re, onIdTokenChanged as Oe, getIdTokenResult as st, signInWithEmailAndPassword as Pe, GoogleAuthProvider as at, OAuthProvider as it, signInWithPopup as De, signInWithRedirect as Le, getRedirectResult as qe, signInWithCustomToken as je, signOut as Me, onAuthStateChanged as Ue, fetchSignInMethodsForEmail as ze, linkWithPopup as Ne, unlink as $e, reauthenticateWithCredential as bt, EmailAuthProvider as Q, updatePassword as Fe, linkWithCredential as Be, verifyBeforeUpdateEmail as Ge, sendEmailVerification as He } from "firebase/auth";
|
|
6
|
+
import { v5 as We } from "uuid";
|
|
7
7
|
import "spark-md5";
|
|
8
|
-
import { getFunctions as
|
|
9
|
-
class
|
|
8
|
+
import { getFunctions as Zt, connectFunctionsEmulator as Jt, httpsCallable as B } from "firebase/functions";
|
|
9
|
+
class lt {
|
|
10
10
|
queryEndpoint;
|
|
11
11
|
updateEndpoint;
|
|
12
12
|
baseHeaders;
|
|
@@ -18,7 +18,7 @@ class nt {
|
|
|
18
18
|
constructor(t) {
|
|
19
19
|
this.queryEndpoint = t.queryEndpoint, this.updateEndpoint = t.updateEndpoint, this.baseHeaders = Object.fromEntries(
|
|
20
20
|
Object.entries(t.originalHeaders || {}).filter(
|
|
21
|
-
([e]) =>
|
|
21
|
+
([e]) => lt.RELEVANT_HEADER_KEYS.includes(e)
|
|
22
22
|
)
|
|
23
23
|
), t.authHeader !== void 0 && (this.baseHeaders.Authorization = t.authHeader);
|
|
24
24
|
}
|
|
@@ -81,7 +81,7 @@ class nt {
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
class
|
|
84
|
+
class X extends Error {
|
|
85
85
|
constructor(t) {
|
|
86
86
|
super(`QLever is locked (rebuild in progress): ${t}`), this.name = "QLeverLockedError";
|
|
87
87
|
}
|
|
@@ -119,7 +119,7 @@ class A {
|
|
|
119
119
|
try {
|
|
120
120
|
return await t();
|
|
121
121
|
} catch (a) {
|
|
122
|
-
if (r = a, a instanceof
|
|
122
|
+
if (r = a, a instanceof X && s < e) {
|
|
123
123
|
const n = 0.5 + Math.random(), p = o * Math.pow(2, s) * n;
|
|
124
124
|
await new Promise((c) => setTimeout(c, p));
|
|
125
125
|
continue;
|
|
@@ -184,7 +184,7 @@ class A {
|
|
|
184
184
|
});
|
|
185
185
|
if (!e.ok) {
|
|
186
186
|
const o = await e.text();
|
|
187
|
-
throw e.status === 423 ? new
|
|
187
|
+
throw e.status === 423 ? new X(o) : new Error(`SPARQL update failed (HTTP ${e.status}): ${o}`);
|
|
188
188
|
}
|
|
189
189
|
return await e.json();
|
|
190
190
|
});
|
|
@@ -204,7 +204,7 @@ class A {
|
|
|
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
|
|
207
|
+
const o = await this._quadsToNQuads(t), r = await Ve(Buffer.from(o, "utf-8"));
|
|
208
208
|
await A._retryOnLocked(async () => {
|
|
209
209
|
const s = await fetch(e, {
|
|
210
210
|
method: "POST",
|
|
@@ -217,18 +217,18 @@ class A {
|
|
|
217
217
|
});
|
|
218
218
|
if (!s.ok) {
|
|
219
219
|
const a = await s.text();
|
|
220
|
-
throw s.status === 423 ? new
|
|
220
|
+
throw s.status === 423 ? new X(a) : new Error(`QLever data POST failed (HTTP ${s.status}): ${a}`);
|
|
221
221
|
}
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
224
|
_quadsToNQuads(t) {
|
|
225
225
|
return new Promise((e, o) => {
|
|
226
|
-
const r = new
|
|
226
|
+
const r = new ye({ 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 Ve(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,14 +243,14 @@ async function Fe(i) {
|
|
|
243
243
|
a.set(p, n), n += p.byteLength;
|
|
244
244
|
return a.buffer;
|
|
245
245
|
}
|
|
246
|
-
class
|
|
246
|
+
class Ke {
|
|
247
247
|
constructor(t) {
|
|
248
248
|
switch (this.options = t, this.options.graphType) {
|
|
249
249
|
case "qlever":
|
|
250
250
|
this._db = new A(this.options);
|
|
251
251
|
break;
|
|
252
252
|
case "fuseki":
|
|
253
|
-
this._db = new
|
|
253
|
+
this._db = new lt(this.options);
|
|
254
254
|
break;
|
|
255
255
|
default:
|
|
256
256
|
throw new Error(`Unsupported graph type: ${this.options.graphType}`);
|
|
@@ -298,7 +298,7 @@ class Be {
|
|
|
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 Qe {
|
|
302
302
|
constructor(t) {
|
|
303
303
|
this.options = t;
|
|
304
304
|
}
|
|
@@ -327,7 +327,7 @@ class Ge {
|
|
|
327
327
|
async getDownloadURL(t, e) {
|
|
328
328
|
const o = _(this._bucket(t), e);
|
|
329
329
|
try {
|
|
330
|
-
return await
|
|
330
|
+
return await F(o);
|
|
331
331
|
} catch (r) {
|
|
332
332
|
if (r?.code === "storage/object-not-found") return;
|
|
333
333
|
throw r;
|
|
@@ -343,7 +343,7 @@ class Ge {
|
|
|
343
343
|
const r = _(this._bucket(t), e);
|
|
344
344
|
try {
|
|
345
345
|
const s = await U(r);
|
|
346
|
-
return `${await
|
|
346
|
+
return `${await F(r)}&t=${encodeURIComponent(s.updated)}`;
|
|
347
347
|
} catch (s) {
|
|
348
348
|
if (s?.code === "storage/object-not-found" || s?.status === 404) {
|
|
349
349
|
this._knownMissing.add(o), console.debug(`[CueBlobStorage] ${e} not found (404 OK — optional cache file)`);
|
|
@@ -356,7 +356,7 @@ class Ge {
|
|
|
356
356
|
async getFile(t, e) {
|
|
357
357
|
const o = _(this._bucket(t), e);
|
|
358
358
|
try {
|
|
359
|
-
return await
|
|
359
|
+
return await Yt(o);
|
|
360
360
|
} catch (r) {
|
|
361
361
|
if (r?.code === "storage/object-not-found") return;
|
|
362
362
|
throw r;
|
|
@@ -382,7 +382,7 @@ class Ge {
|
|
|
382
382
|
]);
|
|
383
383
|
try {
|
|
384
384
|
const [a, n] = await Promise.all([
|
|
385
|
-
s(
|
|
385
|
+
s(F(e)),
|
|
386
386
|
s(U(e))
|
|
387
387
|
]), p = `${a}&t=${encodeURIComponent(n.updated)}`, c = await fetch(p, { signal: o.signal });
|
|
388
388
|
if (!c.ok) throw new Error(`HTTP ${c.status}`);
|
|
@@ -414,7 +414,7 @@ class Ge {
|
|
|
414
414
|
/** Update custom metadata on an existing file. */
|
|
415
415
|
async setMetadata(t, e, o) {
|
|
416
416
|
const r = _(this._bucket(t), e);
|
|
417
|
-
await
|
|
417
|
+
await me(r, { customMetadata: o });
|
|
418
418
|
}
|
|
419
419
|
// ─── Uploads ──────────────────────────────────────────────────────────────
|
|
420
420
|
/**
|
|
@@ -423,7 +423,7 @@ class Ge {
|
|
|
423
423
|
* upload progress needs to be surfaced in the UI.
|
|
424
424
|
*/
|
|
425
425
|
uploadResumable(t, e, o, r) {
|
|
426
|
-
const s = _(this._bucket(t), e), a =
|
|
426
|
+
const s = _(this._bucket(t), e), a = wt(s, o, r ? { customMetadata: r } : void 0);
|
|
427
427
|
return {
|
|
428
428
|
complete: () => new Promise((n, p) => a.then(() => n(), p)),
|
|
429
429
|
pause: () => a.pause(),
|
|
@@ -443,12 +443,12 @@ class Ge {
|
|
|
443
443
|
*/
|
|
444
444
|
async uploadBytes(t, e, o, r) {
|
|
445
445
|
const s = _(this._bucket(t), e);
|
|
446
|
-
await
|
|
446
|
+
await rt(s, o, r ? { customMetadata: r } : void 0);
|
|
447
447
|
}
|
|
448
448
|
/** Upload a string or base64-encoded value. */
|
|
449
|
-
async uploadString(t, e, o, r =
|
|
449
|
+
async uploadString(t, e, o, r = we.RAW, s) {
|
|
450
450
|
const a = _(this._bucket(t), e);
|
|
451
|
-
await
|
|
451
|
+
await fe(a, o, r, s ? { customMetadata: s } : void 0);
|
|
452
452
|
}
|
|
453
453
|
// ─── Listing ──────────────────────────────────────────────────────────────
|
|
454
454
|
/** List all item names directly under `prefix` in the given bucket. */
|
|
@@ -499,7 +499,7 @@ class Ge {
|
|
|
499
499
|
d(new DOMException("Upload cancelled", "AbortError"));
|
|
500
500
|
return;
|
|
501
501
|
}
|
|
502
|
-
const g =
|
|
502
|
+
const g = wt(n, e, { customMetadata: o }), w = () => {
|
|
503
503
|
g.cancel(), d(new DOMException("Upload cancelled", "AbortError"));
|
|
504
504
|
};
|
|
505
505
|
s?.addEventListener("abort", w, { once: !0 }), g.on(
|
|
@@ -532,7 +532,7 @@ class Ge {
|
|
|
532
532
|
*/
|
|
533
533
|
async uploadProcessed(t, e, o) {
|
|
534
534
|
const r = _(this.options.storageProcessed, t);
|
|
535
|
-
return await U(r).catch(() => null) ? !1 : (await
|
|
535
|
+
return await U(r).catch(() => null) ? !1 : (await rt(r, e, { customMetadata: o }), !0);
|
|
536
536
|
}
|
|
537
537
|
/** List all blob names directly under `prefix` in the raw bucket. */
|
|
538
538
|
async listRaw(t) {
|
|
@@ -540,7 +540,7 @@ class Ge {
|
|
|
540
540
|
return (await z(e)).items.map((r) => r.name);
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
|
-
const
|
|
543
|
+
const vt = {
|
|
544
544
|
ä: "ae",
|
|
545
545
|
ä: "ae",
|
|
546
546
|
Ä: "AE",
|
|
@@ -576,15 +576,15 @@ const yt = {
|
|
|
576
576
|
};
|
|
577
577
|
function D(i, t = !1) {
|
|
578
578
|
const e = "daca0510-72b5-48ba-9091-b918ca18136b";
|
|
579
|
-
return i =
|
|
579
|
+
return i = Xe(i, t), We(i, e);
|
|
580
580
|
}
|
|
581
|
-
function
|
|
581
|
+
function Xe(i, t = !1) {
|
|
582
582
|
let e = i;
|
|
583
|
-
for (const o in
|
|
584
|
-
e = e.replace(new RegExp(o, "g"),
|
|
583
|
+
for (const o in vt)
|
|
584
|
+
e = e.replace(new RegExp(o, "g"), vt[o]);
|
|
585
585
|
return t && e !== i && console.info(`${i} -> ${e}`), e;
|
|
586
586
|
}
|
|
587
|
-
function
|
|
587
|
+
function Ye(i, t = "") {
|
|
588
588
|
return D(`${t}${i}`);
|
|
589
589
|
}
|
|
590
590
|
class x {
|
|
@@ -608,7 +608,7 @@ class x {
|
|
|
608
608
|
return this;
|
|
609
609
|
}
|
|
610
610
|
}
|
|
611
|
-
function
|
|
611
|
+
function ct(i, t) {
|
|
612
612
|
const e = /* @__PURE__ */ new Set();
|
|
613
613
|
let o = t(), r = !1;
|
|
614
614
|
const s = [], a = () => {
|
|
@@ -630,7 +630,7 @@ function pt(i, t) {
|
|
|
630
630
|
}
|
|
631
631
|
};
|
|
632
632
|
}
|
|
633
|
-
async function
|
|
633
|
+
async function ht(i, t, e, o) {
|
|
634
634
|
const r = D(i);
|
|
635
635
|
let s;
|
|
636
636
|
if (o) {
|
|
@@ -642,12 +642,12 @@ async function lt(i, t, e, o) {
|
|
|
642
642
|
(p) => console.error("[staleWhileRevalidate] Cache write failed:", p)
|
|
643
643
|
), a;
|
|
644
644
|
}
|
|
645
|
-
const
|
|
645
|
+
const Y = {
|
|
646
646
|
apiKey: "AIzaSyAiW42QBx9HS4Khu88pCW7MV66IhBAQul0",
|
|
647
647
|
appId: "1:151132927589:web:d2ffdb377dfadfd23ab88c",
|
|
648
648
|
measurementId: "G-YT4PK6HGZD"
|
|
649
|
-
},
|
|
650
|
-
class
|
|
649
|
+
}, _t = "qaecy-mvp-406413", Ze = "734737865998", te = "europe-west6", kt = "projects", Je = "spaces_chats_eu_west6", Et = "spaces_raw_eu_west6", xt = "spaces_processed_eu_west6", to = "spaces_logs_eu_west6", eo = "cue_public_eu_west6", It = "db_persistence_eu_west6", oo = "/data-views/admin/consumption", ro = "/data-views/admin/profile/organizations", Ct = "/data-views/admin/profile/api-keys", Tt = "/commands/admin/profile/api-keys", so = "/commands/admin/profile/terms", ao = (i) => `/data-views/admin/organizations/${i}/members`, io = "/commands/admin/project", no = "/assistant/search", ee = "/triplestore/query", po = "/triplestore/update", lo = "/triplestore/shacl", oe = "/qlever-server/qlever/query", co = "/qlever-server/qlever/update", ho = "/qlever-server/qlever/shacl", St = "/commands/file-system-structure/batch", At = "microsoft.com", Rt = "superadmin", dt = "https://cue.qaecy.com/r/";
|
|
650
|
+
class Ot {
|
|
651
651
|
_auth;
|
|
652
652
|
_endpoints;
|
|
653
653
|
_userSignal = new x(null);
|
|
@@ -664,19 +664,19 @@ class Tt {
|
|
|
664
664
|
/** All unique UIDs for the current user (Firebase UID + linked provider UIDs). */
|
|
665
665
|
userIds;
|
|
666
666
|
constructor(t, e = !1, o) {
|
|
667
|
-
this._auth =
|
|
667
|
+
this._auth = Ae(t), this._endpoints = o, e && Re(this._auth, o.authEmulatorUrl, {
|
|
668
668
|
disableWarnings: !0
|
|
669
|
-
}), this.user = this._userSignal.asReadonly(), this.token = this._tokenSignal.asReadonly(), this.isSuperAdmin = this._isSuperAdminSignal.asReadonly(), this._userIdsSignal =
|
|
669
|
+
}), this.user = this._userSignal.asReadonly(), this.token = this._tokenSignal.asReadonly(), this.isSuperAdmin = this._isSuperAdminSignal.asReadonly(), this._userIdsSignal = ct([this._userSignal], () => {
|
|
670
670
|
const r = this._userSignal.get();
|
|
671
671
|
if (!r) return [];
|
|
672
672
|
const s = /* @__PURE__ */ new Set([r.uid]);
|
|
673
673
|
return r.providerData.forEach((a) => s.add(a.uid)), Array.from(s);
|
|
674
|
-
}), this.userIds = this._userIdsSignal, this._stopTokenListener =
|
|
674
|
+
}), this.userIds = this._userIdsSignal, this._stopTokenListener = Oe(this._auth, async (r) => {
|
|
675
675
|
if (this._userSignal.set(r), r) {
|
|
676
676
|
const s = await r.getIdToken();
|
|
677
677
|
this._tokenSignal.set(s);
|
|
678
|
-
const a = await
|
|
679
|
-
this._isSuperAdminSignal.set(a.claims.role ===
|
|
678
|
+
const a = await st(r);
|
|
679
|
+
this._isSuperAdminSignal.set(a.claims.role === Rt);
|
|
680
680
|
} else
|
|
681
681
|
this._tokenSignal.set(null), this._isSuperAdminSignal.set(!1);
|
|
682
682
|
});
|
|
@@ -689,14 +689,14 @@ class Tt {
|
|
|
689
689
|
if (t === "password") {
|
|
690
690
|
if (!e)
|
|
691
691
|
throw new Error("credentials are required for password sign-in");
|
|
692
|
-
return (await
|
|
692
|
+
return (await Pe(
|
|
693
693
|
this._auth,
|
|
694
694
|
e.email,
|
|
695
695
|
e.password
|
|
696
696
|
)).user;
|
|
697
697
|
}
|
|
698
|
-
const o = t === "google" ? new
|
|
699
|
-
return (await
|
|
698
|
+
const o = t === "google" ? new at() : new it(At);
|
|
699
|
+
return (await De(this._auth, o)).user;
|
|
700
700
|
}
|
|
701
701
|
/**
|
|
702
702
|
* Initiate a redirect-based sign-in (mobile / iframe contexts where popups
|
|
@@ -704,8 +704,8 @@ class Tt {
|
|
|
704
704
|
* retrieve the result.
|
|
705
705
|
*/
|
|
706
706
|
async signInWithRedirect(t) {
|
|
707
|
-
const e = t === "google" ? new
|
|
708
|
-
await
|
|
707
|
+
const e = t === "google" ? new at() : new it(At);
|
|
708
|
+
await Le(this._auth, e);
|
|
709
709
|
}
|
|
710
710
|
/**
|
|
711
711
|
* Retrieve the result of a redirect sign-in. Returns the signed-in `User`
|
|
@@ -713,7 +713,7 @@ class Tt {
|
|
|
713
713
|
* Call this once on app startup before showing a sign-in UI.
|
|
714
714
|
*/
|
|
715
715
|
async checkRedirectResult() {
|
|
716
|
-
return (await
|
|
716
|
+
return (await qe(this._auth))?.user ?? null;
|
|
717
717
|
}
|
|
718
718
|
/**
|
|
719
719
|
* One-shot async check — returns `true` if the current user has the
|
|
@@ -722,7 +722,7 @@ class Tt {
|
|
|
722
722
|
*/
|
|
723
723
|
async checkSuperAdmin() {
|
|
724
724
|
const t = this._auth.currentUser;
|
|
725
|
-
return t ? (await
|
|
725
|
+
return t ? (await st(t)).claims.role === Rt : !1;
|
|
726
726
|
}
|
|
727
727
|
/** Sign in with a Cue API key. `projectId` is optional — omit it when no project context is available (e.g. admin flows). */
|
|
728
728
|
async signInWithApiKey(t, e) {
|
|
@@ -735,11 +735,11 @@ class Tt {
|
|
|
735
735
|
if (!r.ok)
|
|
736
736
|
throw new Error(`Failed to fetch custom token: ${r.statusText}`);
|
|
737
737
|
const { token: s } = await r.json();
|
|
738
|
-
return (await
|
|
738
|
+
return (await je(this._auth, s)).user;
|
|
739
739
|
}
|
|
740
740
|
/** Sign out the current user */
|
|
741
741
|
async signOut() {
|
|
742
|
-
await
|
|
742
|
+
await Me(this._auth);
|
|
743
743
|
}
|
|
744
744
|
/**
|
|
745
745
|
* Register a new user by name and email.
|
|
@@ -769,7 +769,7 @@ class Tt {
|
|
|
769
769
|
}
|
|
770
770
|
/** Subscribe to authentication state changes. Returns an unsubscribe function. */
|
|
771
771
|
onAuthStateChanged(t) {
|
|
772
|
-
return
|
|
772
|
+
return Ue(this._auth, t);
|
|
773
773
|
}
|
|
774
774
|
/** Get the Firebase ID token for the current user, or null if not authenticated */
|
|
775
775
|
async getToken(t = !1) {
|
|
@@ -801,8 +801,29 @@ class Tt {
|
|
|
801
801
|
return this._auth;
|
|
802
802
|
}
|
|
803
803
|
}
|
|
804
|
-
|
|
805
|
-
|
|
804
|
+
class Pt {
|
|
805
|
+
constructor(t, e) {
|
|
806
|
+
this._storageRaw = t, this._storageProcessed = e;
|
|
807
|
+
}
|
|
808
|
+
_storageRaw;
|
|
809
|
+
_storageProcessed;
|
|
810
|
+
/**
|
|
811
|
+
* Returns a Firebase authenticated download URL for a document stored in Cue.
|
|
812
|
+
*
|
|
813
|
+
* The storage path is `{projectId}/{uuid}{suffix}`, e.g. `my-project/abc-123.pdf`.
|
|
814
|
+
*
|
|
815
|
+
* @param projectId - The Cue project (space) ID.
|
|
816
|
+
* @param uuid - The document UUID.
|
|
817
|
+
* @param suffix - File suffix including the leading dot, e.g. `'.pdf'`, `'.ifc'`.
|
|
818
|
+
* @param bucket - `'raw'` (default, original uploads) or `'processed'` (derived artefacts).
|
|
819
|
+
*/
|
|
820
|
+
async getDownloadUrl(t, e, o, r = "raw") {
|
|
821
|
+
const s = r === "processed" ? this._storageProcessed : this._storageRaw, a = _(s, `${t}/${e}${o}`);
|
|
822
|
+
return F(a);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
const go = "/data-views/tables", uo = "/commands/tables";
|
|
826
|
+
class mo {
|
|
806
827
|
constructor(t, e) {
|
|
807
828
|
this._auth = t, this._gatewayUrl = e;
|
|
808
829
|
}
|
|
@@ -810,7 +831,7 @@ class ho {
|
|
|
810
831
|
_gatewayUrl;
|
|
811
832
|
async listTables(t) {
|
|
812
833
|
const e = await this._auth.authenticatedFetch(
|
|
813
|
-
`${this._gatewayUrl}${
|
|
834
|
+
`${this._gatewayUrl}${go}`,
|
|
814
835
|
{
|
|
815
836
|
headers: {
|
|
816
837
|
"Content-Type": "application/json",
|
|
@@ -825,7 +846,7 @@ class ho {
|
|
|
825
846
|
}
|
|
826
847
|
async saveTables(t, e) {
|
|
827
848
|
const o = await this._auth.authenticatedFetch(
|
|
828
|
-
`${this._gatewayUrl}${
|
|
849
|
+
`${this._gatewayUrl}${uo}`,
|
|
829
850
|
{
|
|
830
851
|
method: "PUT",
|
|
831
852
|
headers: {
|
|
@@ -840,9 +861,9 @@ class ho {
|
|
|
840
861
|
throw new Error(`Failed to save tables: ${o.status} ${o.statusText}`);
|
|
841
862
|
}
|
|
842
863
|
}
|
|
843
|
-
class
|
|
864
|
+
class Dt {
|
|
844
865
|
constructor(t, e, o, r) {
|
|
845
|
-
this._auth = t, this._gatewayUrl = e, this.projects = o, this.sync = r, this.tables = new
|
|
866
|
+
this._auth = t, this._gatewayUrl = e, this.projects = o, this.sync = r, this.tables = new mo(t, e);
|
|
846
867
|
}
|
|
847
868
|
_auth;
|
|
848
869
|
_gatewayUrl;
|
|
@@ -874,7 +895,7 @@ class St {
|
|
|
874
895
|
*/
|
|
875
896
|
async search(t) {
|
|
876
897
|
const e = await this._auth.authenticatedFetch(
|
|
877
|
-
`${this._gatewayUrl}${
|
|
898
|
+
`${this._gatewayUrl}${no}`,
|
|
878
899
|
{
|
|
879
900
|
method: "POST",
|
|
880
901
|
headers: { "Content-Type": "application/json", "cue-project-id": t.projectId },
|
|
@@ -897,7 +918,7 @@ class St {
|
|
|
897
918
|
*/
|
|
898
919
|
async sparql(t, e, o) {
|
|
899
920
|
o || (o = (await this.projects.getProject(e))?.projectSettings?.graph?.type ?? "qlever");
|
|
900
|
-
const r = o === "fuseki" ?
|
|
921
|
+
const r = o === "fuseki" ? ee : oe;
|
|
901
922
|
console.log(`Executing SPARQL query against ${r} for project ${e} with graph type ${o}`);
|
|
902
923
|
const s = new URLSearchParams();
|
|
903
924
|
s.append("query", t);
|
|
@@ -934,7 +955,7 @@ class St {
|
|
|
934
955
|
const r = o?.format ?? "json-ld", s = r === "turtle" ? "text/turtle" : "application/ld+json";
|
|
935
956
|
if (o?.graphType === "fuseki") {
|
|
936
957
|
const c = await this._auth.authenticatedFetch(
|
|
937
|
-
`${this._gatewayUrl}${
|
|
958
|
+
`${this._gatewayUrl}${lo}`,
|
|
938
959
|
{
|
|
939
960
|
method: "POST",
|
|
940
961
|
headers: {
|
|
@@ -952,7 +973,7 @@ class St {
|
|
|
952
973
|
}
|
|
953
974
|
return r === "turtle" ? c.text() : c.json();
|
|
954
975
|
}
|
|
955
|
-
const a = `${this._gatewayUrl}${
|
|
976
|
+
const a = `${this._gatewayUrl}${ho}${o?.verbose ? "?verbose=true" : ""}`, n = new URLSearchParams({ shape: t }), p = await this._auth.authenticatedFetch(a, {
|
|
956
977
|
method: "POST",
|
|
957
978
|
headers: {
|
|
958
979
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
@@ -970,7 +991,7 @@ class St {
|
|
|
970
991
|
}
|
|
971
992
|
async getConsumption(t) {
|
|
972
993
|
const e = await this._auth.authenticatedFetch(
|
|
973
|
-
`${this._gatewayUrl}${
|
|
994
|
+
`${this._gatewayUrl}${oo}`,
|
|
974
995
|
{
|
|
975
996
|
headers: {
|
|
976
997
|
"Content-Type": "application/json",
|
|
@@ -986,7 +1007,7 @@ class St {
|
|
|
986
1007
|
return e.json();
|
|
987
1008
|
}
|
|
988
1009
|
}
|
|
989
|
-
const
|
|
1010
|
+
const nt = [
|
|
990
1011
|
"building",
|
|
991
1012
|
"cadastre",
|
|
992
1013
|
"zone",
|
|
@@ -997,13 +1018,13 @@ const it = [
|
|
|
997
1018
|
"railway",
|
|
998
1019
|
"natural",
|
|
999
1020
|
"manmade"
|
|
1000
|
-
],
|
|
1021
|
+
], re = [
|
|
1001
1022
|
"address",
|
|
1002
1023
|
"poi",
|
|
1003
1024
|
"railway",
|
|
1004
1025
|
"natural",
|
|
1005
1026
|
"manmade"
|
|
1006
|
-
],
|
|
1027
|
+
], wo = {
|
|
1007
1028
|
address: {
|
|
1008
1029
|
category: "address",
|
|
1009
1030
|
label: "Address",
|
|
@@ -1065,10 +1086,10 @@ const it = [
|
|
|
1065
1086
|
preferredColor: "#db2777"
|
|
1066
1087
|
}
|
|
1067
1088
|
};
|
|
1068
|
-
function
|
|
1069
|
-
return
|
|
1089
|
+
function S(i) {
|
|
1090
|
+
return wo[i];
|
|
1070
1091
|
}
|
|
1071
|
-
const
|
|
1092
|
+
const fo = {
|
|
1072
1093
|
"land-use-plan": "#f59e0b",
|
|
1073
1094
|
// amber – primary zoning
|
|
1074
1095
|
"local-plan": "#ec4899",
|
|
@@ -1099,7 +1120,7 @@ const uo = {
|
|
|
1099
1120
|
function N(i, t) {
|
|
1100
1121
|
return i[0] < t[2] && i[2] > t[0] && i[1] < t[3] && i[3] > t[1];
|
|
1101
1122
|
}
|
|
1102
|
-
const
|
|
1123
|
+
const yo = "https://nominatim.openstreetmap.org", bo = "cue-gis/0.0.1", vo = {
|
|
1103
1124
|
address: "street",
|
|
1104
1125
|
poi: "shop",
|
|
1105
1126
|
railway: "station",
|
|
@@ -1111,13 +1132,13 @@ const mo = "https://nominatim.openstreetmap.org", wo = "cue-gis/0.0.1", fo = {
|
|
|
1111
1132
|
paved: "road",
|
|
1112
1133
|
zone: "boundary"
|
|
1113
1134
|
}, L = "nominatim";
|
|
1114
|
-
function
|
|
1135
|
+
function G(i) {
|
|
1115
1136
|
return `${L}:${i}`;
|
|
1116
1137
|
}
|
|
1117
|
-
function
|
|
1118
|
-
const t =
|
|
1138
|
+
function _o(i) {
|
|
1139
|
+
const t = S(i);
|
|
1119
1140
|
return {
|
|
1120
|
-
id:
|
|
1141
|
+
id: G(i),
|
|
1121
1142
|
sourceId: L,
|
|
1122
1143
|
sourceLayerId: i,
|
|
1123
1144
|
category: i,
|
|
@@ -1129,43 +1150,43 @@ function yo(i) {
|
|
|
1129
1150
|
descriptionKey: `gis.layer.${L}.${i}.description`
|
|
1130
1151
|
};
|
|
1131
1152
|
}
|
|
1132
|
-
class
|
|
1153
|
+
class ko {
|
|
1133
1154
|
baseUrl;
|
|
1134
1155
|
userAgent;
|
|
1135
1156
|
email;
|
|
1136
1157
|
limit;
|
|
1137
1158
|
constructor(t = {}) {
|
|
1138
|
-
this.baseUrl = t.baseUrl ??
|
|
1159
|
+
this.baseUrl = t.baseUrl ?? yo, this.userAgent = t.userAgent ?? bo, this.email = t.email, this.limit = Math.min(t.limit ?? 40, 40);
|
|
1139
1160
|
}
|
|
1140
1161
|
async listFeatureCategoryDescriptors(t) {
|
|
1141
1162
|
return (await Promise.allSettled(
|
|
1142
|
-
|
|
1163
|
+
re.map(async (o) => {
|
|
1143
1164
|
const r = await this.search(t, o);
|
|
1144
1165
|
return { category: o, hasResults: r.length > 0 };
|
|
1145
1166
|
})
|
|
1146
1167
|
)).filter(
|
|
1147
1168
|
(o) => o.status === "fulfilled" && o.value.hasResults
|
|
1148
|
-
).map((o) =>
|
|
1169
|
+
).map((o) => S(o.value.category));
|
|
1149
1170
|
}
|
|
1150
1171
|
async listAvailableLayers(t) {
|
|
1151
|
-
return (await this.listFeatureCategoryDescriptors(t)).map((o) =>
|
|
1172
|
+
return (await this.listFeatureCategoryDescriptors(t)).map((o) => _o(o.category));
|
|
1152
1173
|
}
|
|
1153
1174
|
async getFeaturesForLayer(t, e) {
|
|
1154
|
-
const o =
|
|
1175
|
+
const o = nt.find((r) => G(r) === e);
|
|
1155
1176
|
return o ? this.search(t, o) : [];
|
|
1156
1177
|
}
|
|
1157
1178
|
async listFeatureCategories(t) {
|
|
1158
1179
|
return (await this.listFeatureCategoryDescriptors(t)).map((o) => o.category);
|
|
1159
1180
|
}
|
|
1160
1181
|
async getFeaturesOfCategory(t, e) {
|
|
1161
|
-
return this.getFeaturesForLayer(t,
|
|
1182
|
+
return this.getFeaturesForLayer(t, G(e));
|
|
1162
1183
|
}
|
|
1163
1184
|
/**
|
|
1164
1185
|
* Low-level search against the Nominatim API. Uses a per-layer probe query
|
|
1165
1186
|
* so bounded viewbox searches return meaningful results.
|
|
1166
1187
|
*/
|
|
1167
1188
|
async search(t, e) {
|
|
1168
|
-
const [o, r, s, a] = t, n = e ?
|
|
1189
|
+
const [o, r, s, a] = t, n = e ? vo[e] : "place", p = new URLSearchParams({
|
|
1169
1190
|
q: n,
|
|
1170
1191
|
format: "jsonv2",
|
|
1171
1192
|
viewbox: `${o},${a},${s},${r}`,
|
|
@@ -1189,12 +1210,12 @@ class bo {
|
|
|
1189
1210
|
return (await h.json()).map((g) => this.toGisFeature(g, e));
|
|
1190
1211
|
}
|
|
1191
1212
|
toGisFeature(t, e) {
|
|
1192
|
-
const [o, r, s, a] = t.boundingbox, n = e ?? t.category, p =
|
|
1213
|
+
const [o, r, s, a] = t.boundingbox, n = e ?? t.category, p = S(n);
|
|
1193
1214
|
return {
|
|
1194
1215
|
id: `${t.osm_type}/${t.osm_id}`,
|
|
1195
1216
|
sourceId: L,
|
|
1196
1217
|
sourceFeatureId: `${t.osm_type}/${t.osm_id}`,
|
|
1197
|
-
layerId:
|
|
1218
|
+
layerId: G(n),
|
|
1198
1219
|
name: t.name ?? t.display_name.split(",")[0].trim(),
|
|
1199
1220
|
category: n,
|
|
1200
1221
|
preferredColor: p.preferredColor,
|
|
@@ -1208,7 +1229,7 @@ class bo {
|
|
|
1208
1229
|
};
|
|
1209
1230
|
}
|
|
1210
1231
|
}
|
|
1211
|
-
const
|
|
1232
|
+
const Lt = {
|
|
1212
1233
|
// 100s – Residential
|
|
1213
1234
|
110: "residential",
|
|
1214
1235
|
120: "residential",
|
|
@@ -1287,7 +1308,7 @@ const At = {
|
|
|
1287
1308
|
960: "agricultural",
|
|
1288
1309
|
970: "agricultural",
|
|
1289
1310
|
990: "other"
|
|
1290
|
-
},
|
|
1311
|
+
}, qt = {
|
|
1291
1312
|
1010: "residential",
|
|
1292
1313
|
1020: "mixed",
|
|
1293
1314
|
1030: "residential",
|
|
@@ -1317,7 +1338,7 @@ const At = {
|
|
|
1317
1338
|
1281: "infrastructure",
|
|
1318
1339
|
1282: "infrastructure",
|
|
1319
1340
|
9999: "other"
|
|
1320
|
-
},
|
|
1341
|
+
}, Eo = {
|
|
1321
1342
|
// Residential
|
|
1322
1343
|
1110: "residential",
|
|
1323
1344
|
// Einfamilienhaus
|
|
@@ -1379,7 +1400,7 @@ const At = {
|
|
|
1379
1400
|
// Empfangsgebäude Bahn/Bus
|
|
1380
1401
|
1282: "infrastructure"
|
|
1381
1402
|
// Parkhaus, Garage
|
|
1382
|
-
},
|
|
1403
|
+
}, xo = [
|
|
1383
1404
|
// "Gebäude" is the Swiss AV BoFlaeche land-cover label for a building footprint.
|
|
1384
1405
|
// It does not encode the actual use type, so map it to 'other' as a safe fallback.
|
|
1385
1406
|
[/^geb[äa]ude$/i, "other"],
|
|
@@ -1393,22 +1414,22 @@ const At = {
|
|
|
1393
1414
|
[/gemischt|mixed|blandet/i, "mixed"]
|
|
1394
1415
|
];
|
|
1395
1416
|
function P(i) {
|
|
1396
|
-
for (const [t, e] of
|
|
1417
|
+
for (const [t, e] of xo)
|
|
1397
1418
|
if (t.test(i)) return e;
|
|
1398
1419
|
}
|
|
1399
|
-
function
|
|
1420
|
+
function Io(i, t) {
|
|
1400
1421
|
if (i == null) return;
|
|
1401
1422
|
const e = String(i).trim();
|
|
1402
|
-
return t === "swiss-gwr" ?
|
|
1423
|
+
return t === "swiss-gwr" ? Eo[e] ?? P(e) : t === "danish-matrikel" ? Lt[e] ?? P(e) : t === "zurich-wfs" || t === "swiss-av-wfs" ? qt[e] ?? P(e) : qt[e] ?? Lt[e] ?? P(e);
|
|
1403
1424
|
}
|
|
1404
|
-
function
|
|
1425
|
+
function Co(i, t) {
|
|
1405
1426
|
if (i != null)
|
|
1406
1427
|
return P(String(i).trim());
|
|
1407
1428
|
}
|
|
1408
|
-
function
|
|
1429
|
+
function se(i) {
|
|
1409
1430
|
return i.trim().toLowerCase().replace(/[\s_\-]/g, "");
|
|
1410
1431
|
}
|
|
1411
|
-
const
|
|
1432
|
+
const To = {
|
|
1412
1433
|
// Swiss ÖREB rechtsstatus
|
|
1413
1434
|
inkraft: "in-force",
|
|
1414
1435
|
laufendeanderung: "amendment-pending",
|
|
@@ -1427,11 +1448,11 @@ const xo = {
|
|
|
1427
1448
|
forslag: "proposed",
|
|
1428
1449
|
aflyst: "repealed"
|
|
1429
1450
|
};
|
|
1430
|
-
function
|
|
1451
|
+
function ae(i) {
|
|
1431
1452
|
if (i)
|
|
1432
|
-
return
|
|
1453
|
+
return To[se(i)];
|
|
1433
1454
|
}
|
|
1434
|
-
const
|
|
1455
|
+
const jt = {
|
|
1435
1456
|
// Swiss Nutzungsplanung (typ_gde_bezeichnung and common variants)
|
|
1436
1457
|
grundnutzungszonenplan: "land-use-plan",
|
|
1437
1458
|
nutzungszonenplan: "land-use-plan",
|
|
@@ -1485,7 +1506,7 @@ const Ot = {
|
|
|
1485
1506
|
// Danish plandata.dk
|
|
1486
1507
|
lokalplan: "local-plan",
|
|
1487
1508
|
kommuneplanramme: "municipal-plan-framework"
|
|
1488
|
-
},
|
|
1509
|
+
}, So = [
|
|
1489
1510
|
[/quartiererhalt/i, "neighbourhood-conservation-plan"],
|
|
1490
1511
|
[/lärmempfindlich|laermempfindlich/i, "noise-sensitivity-plan"],
|
|
1491
1512
|
[/gewässerschutz|grundwasserschutz/i, "water-protection-plan"],
|
|
@@ -1525,24 +1546,24 @@ const Ot = {
|
|
|
1525
1546
|
// Catch-all: any remaining Xzone / Xareal designation from the Grundnutzungszonenplan
|
|
1526
1547
|
[/zone$|areal$/i, "land-use-plan"]
|
|
1527
1548
|
];
|
|
1528
|
-
function
|
|
1549
|
+
function ie(i) {
|
|
1529
1550
|
if (!i) return;
|
|
1530
|
-
const t =
|
|
1531
|
-
if (t in
|
|
1532
|
-
for (const [e, o] of
|
|
1551
|
+
const t = se(i);
|
|
1552
|
+
if (t in jt) return jt[t];
|
|
1553
|
+
for (const [e, o] of So)
|
|
1533
1554
|
if (e.test(i)) return o;
|
|
1534
1555
|
console.warn(
|
|
1535
1556
|
`[cue-gis] Unknown zone plan type — add "${i}" to classifyZonePlanType: no ZonePlanType mapping found.`
|
|
1536
1557
|
);
|
|
1537
1558
|
}
|
|
1538
|
-
const
|
|
1539
|
-
function
|
|
1559
|
+
const Ao = "https://maps.zh.ch/wfs/OGDZHWFS", Ro = "zurich-wfs", Oo = [8.35, 47.15, 8.95, 47.7], Po = [5.9, 45.7, 10.55, 47.85];
|
|
1560
|
+
function Z(i) {
|
|
1540
1561
|
return typeof i == "string" ? i : i.typeName;
|
|
1541
1562
|
}
|
|
1542
|
-
function
|
|
1563
|
+
function J(i) {
|
|
1543
1564
|
return typeof i == "string" ? void 0 : i.cqlFilter;
|
|
1544
1565
|
}
|
|
1545
|
-
function
|
|
1566
|
+
function Do(i) {
|
|
1546
1567
|
if (!i) return [0, 0];
|
|
1547
1568
|
const t = i.coordinates;
|
|
1548
1569
|
switch (i.type) {
|
|
@@ -1560,20 +1581,20 @@ function Ro(i) {
|
|
|
1560
1581
|
return [0, 0];
|
|
1561
1582
|
}
|
|
1562
1583
|
}
|
|
1563
|
-
function
|
|
1584
|
+
function Lo(i, t) {
|
|
1564
1585
|
if (!i) return t;
|
|
1565
1586
|
for (const e of ["plannavn", "bezeichnung", "name", "strassenname", "objektname", "title", "label"])
|
|
1566
1587
|
if (typeof i[e] == "string" && i[e]) return i[e];
|
|
1567
1588
|
return t;
|
|
1568
1589
|
}
|
|
1569
|
-
function
|
|
1590
|
+
function qo(i, t, e) {
|
|
1570
1591
|
return e ? `${i}:${t}[${e}]` : `${i}:${t}`;
|
|
1571
1592
|
}
|
|
1572
|
-
const
|
|
1573
|
-
function
|
|
1574
|
-
const r = e.replace(/^ms:/, ""), s =
|
|
1593
|
+
const jo = /* @__PURE__ */ new Set(["building", "cadastre", "greenspace", "paved", "zone"]);
|
|
1594
|
+
function tt(i, t, e, o) {
|
|
1595
|
+
const r = e.replace(/^ms:/, ""), s = S(t), a = jo.has(t) ? "priority" : "raw";
|
|
1575
1596
|
return {
|
|
1576
|
-
id:
|
|
1597
|
+
id: qo(i, e, o),
|
|
1577
1598
|
sourceId: i,
|
|
1578
1599
|
sourceLayerId: e,
|
|
1579
1600
|
category: t,
|
|
@@ -1585,32 +1606,32 @@ function J(i, t, e, o) {
|
|
|
1585
1606
|
descriptionKey: `gis.layer.${i}.${r}.description`
|
|
1586
1607
|
};
|
|
1587
1608
|
}
|
|
1588
|
-
function
|
|
1609
|
+
function Mo(i, t) {
|
|
1589
1610
|
if (!i) return { featureType: "building" };
|
|
1590
1611
|
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;
|
|
1591
1612
|
return {
|
|
1592
1613
|
featureType: "building",
|
|
1593
1614
|
areaM2: typeof e == "number" ? e : void 0,
|
|
1594
1615
|
buildingUse: r ? String(r) : void 0,
|
|
1595
|
-
buildingUseGeneric:
|
|
1616
|
+
buildingUseGeneric: Io(r, t),
|
|
1596
1617
|
floors: typeof o == "number" ? o : void 0,
|
|
1597
1618
|
yearBuilt: typeof s == "number" ? s : void 0,
|
|
1598
1619
|
registryId: a
|
|
1599
1620
|
};
|
|
1600
1621
|
}
|
|
1601
|
-
function
|
|
1622
|
+
function Uo(i, t) {
|
|
1602
1623
|
if (!i) return { featureType: "plot" };
|
|
1603
1624
|
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;
|
|
1604
1625
|
return {
|
|
1605
1626
|
featureType: "plot",
|
|
1606
1627
|
areaM2: typeof a == "number" ? a : void 0,
|
|
1607
1628
|
plotUse: n ? String(n) : void 0,
|
|
1608
|
-
plotUseGeneric:
|
|
1629
|
+
plotUseGeneric: Co(n),
|
|
1609
1630
|
plotId: s,
|
|
1610
1631
|
registryId: e
|
|
1611
1632
|
};
|
|
1612
1633
|
}
|
|
1613
|
-
function
|
|
1634
|
+
function zo(i) {
|
|
1614
1635
|
if (!i) return { featureType: "greenspace" };
|
|
1615
1636
|
const t = i.flaeche ?? void 0, e = i.art ?? void 0;
|
|
1616
1637
|
return {
|
|
@@ -1619,7 +1640,7 @@ function jo(i) {
|
|
|
1619
1640
|
surfaceType: e ? String(e) : void 0
|
|
1620
1641
|
};
|
|
1621
1642
|
}
|
|
1622
|
-
function
|
|
1643
|
+
function No(i) {
|
|
1623
1644
|
if (!i) return { featureType: "paved" };
|
|
1624
1645
|
const t = i.flaeche ?? void 0, e = i.art ?? void 0;
|
|
1625
1646
|
return {
|
|
@@ -1628,9 +1649,9 @@ function Mo(i) {
|
|
|
1628
1649
|
surfaceType: e ? String(e) : void 0
|
|
1629
1650
|
};
|
|
1630
1651
|
}
|
|
1631
|
-
function
|
|
1652
|
+
function $o(i) {
|
|
1632
1653
|
if (!i) return { featureType: "zone" };
|
|
1633
|
-
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 =
|
|
1654
|
+
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 = ae(r), a = i.typ_gde_bezeichnung ?? void 0, n = ie(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, w = i.flaeche ?? i.flaeche_m2 ?? void 0;
|
|
1634
1655
|
return {
|
|
1635
1656
|
featureType: "zone",
|
|
1636
1657
|
zoneType: t ? String(t) : void 0,
|
|
@@ -1646,7 +1667,7 @@ function Uo(i) {
|
|
|
1646
1667
|
areaM2: typeof w == "number" ? w : void 0
|
|
1647
1668
|
};
|
|
1648
1669
|
}
|
|
1649
|
-
function
|
|
1670
|
+
function Fo(i) {
|
|
1650
1671
|
const t = i.match(/^(\w+)\s*=\s*'([^']+)'$/);
|
|
1651
1672
|
if (t) {
|
|
1652
1673
|
const [, o, r] = t;
|
|
@@ -1661,37 +1682,37 @@ function zo(i) {
|
|
|
1661
1682
|
}
|
|
1662
1683
|
return () => !0;
|
|
1663
1684
|
}
|
|
1664
|
-
class
|
|
1685
|
+
class et {
|
|
1665
1686
|
categoryMap;
|
|
1666
1687
|
baseUrl;
|
|
1667
1688
|
sourceId;
|
|
1668
1689
|
outputFormat;
|
|
1669
1690
|
constructor(t) {
|
|
1670
|
-
this.categoryMap = t.categoryMap, this.baseUrl = t.baseUrl ??
|
|
1691
|
+
this.categoryMap = t.categoryMap, this.baseUrl = t.baseUrl ?? Ao, this.sourceId = t.sourceId ?? Ro, this.outputFormat = t.outputFormat ?? "application/json; subtype=geojson";
|
|
1671
1692
|
}
|
|
1672
1693
|
async listFeatureCategoryDescriptors(t) {
|
|
1673
1694
|
const e = await this.listAvailableLayers(t);
|
|
1674
|
-
return [...new Map(e.map((o) => [o.category,
|
|
1695
|
+
return [...new Map(e.map((o) => [o.category, S(o.category)])).values()];
|
|
1675
1696
|
}
|
|
1676
1697
|
async listAvailableLayers(t) {
|
|
1677
1698
|
const e = Object.entries(this.categoryMap);
|
|
1678
1699
|
return (await Promise.allSettled(
|
|
1679
1700
|
e.flatMap(
|
|
1680
1701
|
([r, s]) => s.map(async (a) => {
|
|
1681
|
-
const n =
|
|
1702
|
+
const n = Z(a), p = J(a), c = await this._fetchFeatures(t, n, 1, p);
|
|
1682
1703
|
return { category: r, typeName: n, cqlFilter: p, hasResults: c.features.length > 0 };
|
|
1683
1704
|
})
|
|
1684
1705
|
)
|
|
1685
1706
|
)).filter(
|
|
1686
1707
|
(r) => r.status === "fulfilled" && r.value.hasResults
|
|
1687
|
-
).map((r) =>
|
|
1708
|
+
).map((r) => tt(this.sourceId, r.value.category, r.value.typeName, r.value.cqlFilter));
|
|
1688
1709
|
}
|
|
1689
1710
|
async getFeaturesForLayer(t, e) {
|
|
1690
1711
|
const o = this._findLayerById(e);
|
|
1691
1712
|
return o ? this._fetchAndConvert(t, o.descriptor, o.cqlFilter) : [];
|
|
1692
1713
|
}
|
|
1693
1714
|
async _fetchAndConvert(t, e, o) {
|
|
1694
|
-
const r = await this._fetchFeatures(t, e.sourceLayerId, void 0, o), s = o ?
|
|
1715
|
+
const r = await this._fetchFeatures(t, e.sourceLayerId, void 0, o), s = o ? Fo(o) : void 0;
|
|
1695
1716
|
return (s ? r.features.filter((n) => s(n.properties)) : r.features).map((n, p) => this.toGisFeature(n, e, p));
|
|
1696
1717
|
}
|
|
1697
1718
|
/**
|
|
@@ -1706,7 +1727,7 @@ class tt {
|
|
|
1706
1727
|
const o = this.categoryMap[e] ?? [];
|
|
1707
1728
|
return (await Promise.all(
|
|
1708
1729
|
o.map((s) => {
|
|
1709
|
-
const a =
|
|
1730
|
+
const a = Z(s), n = J(s), p = tt(this.sourceId, e, a);
|
|
1710
1731
|
return this._fetchAndConvert(t, p, n);
|
|
1711
1732
|
})
|
|
1712
1733
|
)).flat();
|
|
@@ -1716,7 +1737,7 @@ class tt {
|
|
|
1716
1737
|
const e = Object.entries(this.categoryMap);
|
|
1717
1738
|
for (const [o, r] of e)
|
|
1718
1739
|
for (const s of r) {
|
|
1719
|
-
const a =
|
|
1740
|
+
const a = Z(s), n = J(s), p = tt(this.sourceId, o, a, n);
|
|
1720
1741
|
if (p.id === t)
|
|
1721
1742
|
return { descriptor: p, cqlFilter: n };
|
|
1722
1743
|
}
|
|
@@ -1740,7 +1761,7 @@ class tt {
|
|
|
1740
1761
|
return g.json();
|
|
1741
1762
|
}
|
|
1742
1763
|
toGisFeature(t, e, o) {
|
|
1743
|
-
const [r, s] =
|
|
1764
|
+
const [r, s] = Do(t.geometry), a = Lo(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;
|
|
1744
1765
|
return {
|
|
1745
1766
|
id: t.id ?? `${e.sourceLayerId}/${o}`,
|
|
1746
1767
|
preferredColor: e.preferredColor,
|
|
@@ -1761,10 +1782,10 @@ class tt {
|
|
|
1761
1782
|
};
|
|
1762
1783
|
}
|
|
1763
1784
|
_extractNormalisedProperties(t, e) {
|
|
1764
|
-
return e.category === "building" ?
|
|
1785
|
+
return e.category === "building" ? Mo(t.properties, this.sourceId) : e.category === "greenspace" ? zo(t.properties) : e.category === "paved" ? No(t.properties) : e.category === "zone" ? $o(t.properties) : Uo(t.properties, this.sourceId);
|
|
1765
1786
|
}
|
|
1766
1787
|
}
|
|
1767
|
-
const
|
|
1788
|
+
const ne = [8, 54.5, 15.2, 57.8], pe = {
|
|
1768
1789
|
building: [
|
|
1769
1790
|
{ source: "danish-matrikel", typename: "bbr_v001:bygning_current" }
|
|
1770
1791
|
],
|
|
@@ -1773,7 +1794,7 @@ const oe = [8, 54.5, 15.2, 57.8], re = {
|
|
|
1773
1794
|
{ source: "danish-matrikel", typename: "mat_v001:samletfastejendom_current" }
|
|
1774
1795
|
]
|
|
1775
1796
|
};
|
|
1776
|
-
function
|
|
1797
|
+
function Bo(i) {
|
|
1777
1798
|
if (!i) return [0, 0];
|
|
1778
1799
|
const t = i.coordinates;
|
|
1779
1800
|
switch (i.type) {
|
|
@@ -1791,7 +1812,7 @@ function No(i) {
|
|
|
1791
1812
|
return [0, 0];
|
|
1792
1813
|
}
|
|
1793
1814
|
}
|
|
1794
|
-
function
|
|
1815
|
+
function Go(i, t) {
|
|
1795
1816
|
if (!i) return t;
|
|
1796
1817
|
for (const e of [
|
|
1797
1818
|
"mat:matrikelnummer",
|
|
@@ -1807,14 +1828,14 @@ function $o(i, t) {
|
|
|
1807
1828
|
if (typeof i[e] == "string" && i[e]) return i[e];
|
|
1808
1829
|
return t;
|
|
1809
1830
|
}
|
|
1810
|
-
function
|
|
1831
|
+
function Ho(i, t, e) {
|
|
1811
1832
|
return `${i}:${t}:${e}`;
|
|
1812
1833
|
}
|
|
1813
|
-
const
|
|
1814
|
-
function
|
|
1815
|
-
const o = e.typename.replace(/^[^:]+:/, ""), r =
|
|
1834
|
+
const Wo = /* @__PURE__ */ new Set(["building", "cadastre", "zone"]);
|
|
1835
|
+
function ot(i, t, e) {
|
|
1836
|
+
const o = e.typename.replace(/^[^:]+:/, ""), r = S(t), s = Wo.has(t) ? "priority" : "raw";
|
|
1816
1837
|
return {
|
|
1817
|
-
id:
|
|
1838
|
+
id: Ho(i, e.source, e.typename),
|
|
1818
1839
|
sourceId: i,
|
|
1819
1840
|
sourceLayerId: e.typename,
|
|
1820
1841
|
category: t,
|
|
@@ -1826,7 +1847,7 @@ function et(i, t, e) {
|
|
|
1826
1847
|
descriptionKey: `gis.layer.${i}.${e.source}.${o}.description`
|
|
1827
1848
|
};
|
|
1828
1849
|
}
|
|
1829
|
-
function
|
|
1850
|
+
function Vo(i, t) {
|
|
1830
1851
|
if (t === "building") {
|
|
1831
1852
|
const a = i?.byg041BebyggetAreal ?? i?.byg038SamletBygningsareal, n = i?.byg021BygningensAnvendelse, p = i?.id_lokalId, c = i?.byg026Opførelsesår;
|
|
1832
1853
|
return {
|
|
@@ -1843,8 +1864,8 @@ function Go(i, t) {
|
|
|
1843
1864
|
featureType: "zone",
|
|
1844
1865
|
zoneType: a ?? void 0,
|
|
1845
1866
|
zoneCode: p ?? void 0,
|
|
1846
|
-
legalStatus:
|
|
1847
|
-
planType:
|
|
1867
|
+
legalStatus: ae(c),
|
|
1868
|
+
planType: ie(i?.typ_gde_bezeichnung),
|
|
1848
1869
|
planId: n ?? void 0,
|
|
1849
1870
|
planDocumentLink: h ?? void 0,
|
|
1850
1871
|
publicationDate: i?.auflagedatum ?? void 0,
|
|
@@ -1862,19 +1883,19 @@ function Go(i, t) {
|
|
|
1862
1883
|
registryId: s ?? void 0
|
|
1863
1884
|
};
|
|
1864
1885
|
}
|
|
1865
|
-
class
|
|
1886
|
+
class Ko {
|
|
1866
1887
|
categoryMap;
|
|
1867
1888
|
dataViewsBaseUrl;
|
|
1868
1889
|
getHeaders;
|
|
1869
1890
|
sourceId;
|
|
1870
1891
|
constructor(t) {
|
|
1871
|
-
this.dataViewsBaseUrl = t.dataViewsBaseUrl.replace(/\/$/, ""), this.getHeaders = t.getHeaders, this.categoryMap = t.categoryMap ??
|
|
1892
|
+
this.dataViewsBaseUrl = t.dataViewsBaseUrl.replace(/\/$/, ""), this.getHeaders = t.getHeaders, this.categoryMap = t.categoryMap ?? pe, this.sourceId = t.sourceId ?? "cue-sdk-gis";
|
|
1872
1893
|
}
|
|
1873
1894
|
async listFeatureCategoryDescriptors(t) {
|
|
1874
1895
|
const e = await this.listAvailableLayers(t);
|
|
1875
1896
|
return [
|
|
1876
1897
|
...new Map(
|
|
1877
|
-
e.map((o) => [o.category,
|
|
1898
|
+
e.map((o) => [o.category, S(o.category)])
|
|
1878
1899
|
).values()
|
|
1879
1900
|
];
|
|
1880
1901
|
}
|
|
@@ -1889,7 +1910,7 @@ class Ho {
|
|
|
1889
1910
|
)
|
|
1890
1911
|
)).filter(
|
|
1891
1912
|
(r) => r.status === "fulfilled" && r.value.hasResults
|
|
1892
|
-
).map((r) =>
|
|
1913
|
+
).map((r) => ot(this.sourceId, r.value.category, r.value.entry));
|
|
1893
1914
|
}
|
|
1894
1915
|
async getFeaturesForLayer(t, e) {
|
|
1895
1916
|
const o = this._findLayerById(e);
|
|
@@ -1903,7 +1924,7 @@ class Ho {
|
|
|
1903
1924
|
const o = this.categoryMap[e] ?? [];
|
|
1904
1925
|
return (await Promise.all(
|
|
1905
1926
|
o.map((s) => {
|
|
1906
|
-
const a =
|
|
1927
|
+
const a = ot(this.sourceId, e, s);
|
|
1907
1928
|
return this.getFeaturesForLayer(t, a.id);
|
|
1908
1929
|
})
|
|
1909
1930
|
)).flat();
|
|
@@ -1912,7 +1933,7 @@ class Ho {
|
|
|
1912
1933
|
_findLayerById(t) {
|
|
1913
1934
|
for (const [e, o] of Object.entries(this.categoryMap))
|
|
1914
1935
|
for (const r of o) {
|
|
1915
|
-
const s =
|
|
1936
|
+
const s = ot(this.sourceId, e, r);
|
|
1916
1937
|
if (s.id === t) return { entry: r, descriptor: s };
|
|
1917
1938
|
}
|
|
1918
1939
|
}
|
|
@@ -1931,7 +1952,7 @@ class Ho {
|
|
|
1931
1952
|
return d.json();
|
|
1932
1953
|
}
|
|
1933
1954
|
_toGisFeature(t, e, o) {
|
|
1934
|
-
const [r, s] =
|
|
1955
|
+
const [r, s] = Bo(t.geometry), a = t.id ?? `${e.sourceLayerId}/${o}`, n = Go(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" ? Vo(t.properties, e.category) : void 0;
|
|
1935
1956
|
return {
|
|
1936
1957
|
id: a,
|
|
1937
1958
|
sourceId: this.sourceId,
|
|
@@ -1952,7 +1973,7 @@ class Ho {
|
|
|
1952
1973
|
};
|
|
1953
1974
|
}
|
|
1954
1975
|
}
|
|
1955
|
-
const
|
|
1976
|
+
const Qo = {
|
|
1956
1977
|
address: [
|
|
1957
1978
|
"ms:ogd-0406_arv_basis_avzh_hausnummer_pos_p",
|
|
1958
1979
|
"ms:ogd-0571_afv_gv_strat_strassennetz_l"
|
|
@@ -2000,23 +2021,23 @@ const Wo = {
|
|
|
2000
2021
|
// ÖREB Überlagernde Festlegungen (Flächen) – overlaying planning constraints
|
|
2001
2022
|
"ms:ogd-0155_arv_basis_np_ul_flaeche_f"
|
|
2002
2023
|
]
|
|
2003
|
-
},
|
|
2024
|
+
}, le = [
|
|
2004
2025
|
{
|
|
2005
2026
|
name: "Canton of Zürich",
|
|
2006
|
-
coverageBBox:
|
|
2027
|
+
coverageBBox: Oo,
|
|
2007
2028
|
supportedCategories: ["address", "poi", "railway", "natural", "manmade", "building", "cadastre", "greenspace", "paved", "zone"],
|
|
2008
2029
|
priority: 10,
|
|
2009
|
-
adapter: new
|
|
2010
|
-
categoryMap:
|
|
2030
|
+
adapter: new et({
|
|
2031
|
+
categoryMap: Qo
|
|
2011
2032
|
})
|
|
2012
2033
|
},
|
|
2013
2034
|
{
|
|
2014
2035
|
name: "Switzerland (national AV cadastre)",
|
|
2015
|
-
coverageBBox:
|
|
2036
|
+
coverageBBox: Po,
|
|
2016
2037
|
supportedCategories: ["cadastre"],
|
|
2017
2038
|
priority: 5,
|
|
2018
2039
|
// Lower priority than canton-specific adapters. For ZH, the canton adapter (priority 10) wins.
|
|
2019
|
-
adapter: new
|
|
2040
|
+
adapter: new et({
|
|
2020
2041
|
sourceId: "swiss-av-wfs",
|
|
2021
2042
|
baseUrl: "https://wfs.geodienste.ch/av_0/deu",
|
|
2022
2043
|
categoryMap: {
|
|
@@ -2040,10 +2061,10 @@ const Wo = {
|
|
|
2040
2061
|
* - `pdk:kommuneplanramme_vedtaget` – adopted municipal plan frameworks
|
|
2041
2062
|
*/
|
|
2042
2063
|
name: "Denmark (Plandata.dk – planning zones)",
|
|
2043
|
-
coverageBBox:
|
|
2064
|
+
coverageBBox: ne,
|
|
2044
2065
|
supportedCategories: ["zone"],
|
|
2045
2066
|
priority: 10,
|
|
2046
|
-
adapter: new
|
|
2067
|
+
adapter: new et({
|
|
2047
2068
|
sourceId: "danish-plandata",
|
|
2048
2069
|
baseUrl: "https://wfs.plandata.dk/geoserver/pdk/wfs",
|
|
2049
2070
|
outputFormat: "application/json",
|
|
@@ -2058,12 +2079,12 @@ const Wo = {
|
|
|
2058
2079
|
})
|
|
2059
2080
|
}
|
|
2060
2081
|
];
|
|
2061
|
-
function
|
|
2082
|
+
function Mt(i) {
|
|
2062
2083
|
return [...i].sort(
|
|
2063
|
-
(t, e) =>
|
|
2084
|
+
(t, e) => nt.indexOf(t.category) - nt.indexOf(e.category)
|
|
2064
2085
|
);
|
|
2065
2086
|
}
|
|
2066
|
-
class
|
|
2087
|
+
class Xo {
|
|
2067
2088
|
nominatim;
|
|
2068
2089
|
regions;
|
|
2069
2090
|
/**
|
|
@@ -2078,9 +2099,9 @@ class Vo {
|
|
|
2078
2099
|
zonePlanTypeColors: r,
|
|
2079
2100
|
...s
|
|
2080
2101
|
} = t;
|
|
2081
|
-
this.nominatim = new
|
|
2082
|
-
const a = o ?
|
|
2083
|
-
this.regions = e ?? a, this.zonePlanTypeColors = { ...
|
|
2102
|
+
this.nominatim = new ko(s);
|
|
2103
|
+
const a = o ? le : [];
|
|
2104
|
+
this.regions = e ?? a, this.zonePlanTypeColors = { ...fo, ...r };
|
|
2084
2105
|
}
|
|
2085
2106
|
/**
|
|
2086
2107
|
* Return the available feature categories together with UI metadata such as
|
|
@@ -2098,13 +2119,13 @@ class Vo {
|
|
|
2098
2119
|
const r = /* @__PURE__ */ new Set(), s = [];
|
|
2099
2120
|
for (const a of e)
|
|
2100
2121
|
for (const n of a.supportedCategories ?? [])
|
|
2101
|
-
r.has(n) || (r.add(n), s.push(
|
|
2102
|
-
for (const a of
|
|
2103
|
-
r.has(a) || s.push(
|
|
2104
|
-
return
|
|
2122
|
+
r.has(n) || (r.add(n), s.push(S(n)));
|
|
2123
|
+
for (const a of re)
|
|
2124
|
+
r.has(a) || s.push(S(a));
|
|
2125
|
+
return Mt(s);
|
|
2105
2126
|
}
|
|
2106
2127
|
const o = await this._adapterFor(t).listFeatureCategoryDescriptors(t);
|
|
2107
|
-
return
|
|
2128
|
+
return Mt(o);
|
|
2108
2129
|
}
|
|
2109
2130
|
/**
|
|
2110
2131
|
* Return the feature categories that have at least one result within the
|
|
@@ -2177,7 +2198,7 @@ class Vo {
|
|
|
2177
2198
|
const { features: n, idx: p } = await Promise.race(a.values());
|
|
2178
2199
|
a.delete(p);
|
|
2179
2200
|
for (const c of n) {
|
|
2180
|
-
const h =
|
|
2201
|
+
const h = Ut(c), d = V(c), g = s.get(h);
|
|
2181
2202
|
(g === void 0 || d > g) && (s.set(h, d), yield c);
|
|
2182
2203
|
}
|
|
2183
2204
|
}
|
|
@@ -2211,9 +2232,9 @@ class Vo {
|
|
|
2211
2232
|
), a = [], n = [];
|
|
2212
2233
|
for (const d of s)
|
|
2213
2234
|
d.status === "fulfilled" && (d.value.isNominatim ? n.push(...d.value.features) : a.push(...d.value.features));
|
|
2214
|
-
const p =
|
|
2235
|
+
const p = Jo(a, n), c = /* @__PURE__ */ new Map(), h = [];
|
|
2215
2236
|
for (const d of p) {
|
|
2216
|
-
const g =
|
|
2237
|
+
const g = Ut(d), w = V(d), u = c.get(g);
|
|
2217
2238
|
(u === void 0 || w > u) && (c.set(g, w), h.push(d));
|
|
2218
2239
|
}
|
|
2219
2240
|
return h;
|
|
@@ -2227,26 +2248,26 @@ class Vo {
|
|
|
2227
2248
|
return this.regions.filter((o) => N(o.coverageBBox, t)).sort((o, r) => (r.priority ?? 0) - (o.priority ?? 0))[0]?.adapter ?? this.nominatim;
|
|
2228
2249
|
}
|
|
2229
2250
|
}
|
|
2230
|
-
function
|
|
2251
|
+
function V(i) {
|
|
2231
2252
|
const t = i.geometry?.type;
|
|
2232
2253
|
return t === "Polygon" || t === "MultiPolygon" ? 3 : t === "LineString" || t === "MultiLineString" ? 2 : 1;
|
|
2233
2254
|
}
|
|
2234
|
-
function
|
|
2255
|
+
function Ut(i) {
|
|
2235
2256
|
const t = Math.round(i.lat * 1e3) / 1e3, e = Math.round(i.lon * 1e3) / 1e3;
|
|
2236
2257
|
return `${(i.name ?? i.id ?? "").toLowerCase().trim()}|${t}|${e}`;
|
|
2237
2258
|
}
|
|
2238
|
-
const
|
|
2239
|
-
function
|
|
2259
|
+
const Yo = 1e-3;
|
|
2260
|
+
function Zo(i, t) {
|
|
2240
2261
|
const e = i.lat - t.lat, o = i.lon - t.lon;
|
|
2241
2262
|
return Math.sqrt(e * e + o * o);
|
|
2242
2263
|
}
|
|
2243
|
-
function
|
|
2264
|
+
function Jo(i, t) {
|
|
2244
2265
|
if (t.length === 0) return i;
|
|
2245
|
-
const e = i.filter((a) =>
|
|
2266
|
+
const e = i.filter((a) => V(a) === 3), o = i.filter((a) => V(a) !== 3), r = e.map((a) => ({ feature: { ...a, originalData: { ...a.originalData } }, matched: !1 })), s = [];
|
|
2246
2267
|
for (const a of t) {
|
|
2247
|
-
let n = -1, p =
|
|
2268
|
+
let n = -1, p = Yo;
|
|
2248
2269
|
for (let c = 0; c < r.length; c++) {
|
|
2249
|
-
const h =
|
|
2270
|
+
const h = Zo(a, r[c].feature);
|
|
2250
2271
|
h < p && (p = h, n = c);
|
|
2251
2272
|
}
|
|
2252
2273
|
n >= 0 ? (r[n].feature.originalData = {
|
|
@@ -2260,8 +2281,8 @@ function Xo(i, t) {
|
|
|
2260
2281
|
...s
|
|
2261
2282
|
];
|
|
2262
2283
|
}
|
|
2263
|
-
const
|
|
2264
|
-
class
|
|
2284
|
+
const tr = "/data-views", er = 1500;
|
|
2285
|
+
class or {
|
|
2265
2286
|
// undefined = not yet built
|
|
2266
2287
|
/** @internal — construct via `cue.gis`, not directly. */
|
|
2267
2288
|
constructor(t, e) {
|
|
@@ -2344,25 +2365,25 @@ class Jo {
|
|
|
2344
2365
|
}
|
|
2345
2366
|
// ── Private ───────────────────────────────────────────────────────────────
|
|
2346
2367
|
_scheduleDebouncedQuery() {
|
|
2347
|
-
this._debounceTimer !== null && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => this._queryLayers(),
|
|
2368
|
+
this._debounceTimer !== null && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => this._queryLayers(), er);
|
|
2348
2369
|
}
|
|
2349
2370
|
_getGateway() {
|
|
2350
2371
|
if (this._gatewayCache !== null && this._gatewayProjectId === this._projectId)
|
|
2351
2372
|
return this._gatewayCache;
|
|
2352
|
-
const t = this._projectId, e = [...
|
|
2373
|
+
const t = this._projectId, e = [...le];
|
|
2353
2374
|
return t && e.unshift({
|
|
2354
2375
|
name: "Cue SDK (authenticated)",
|
|
2355
|
-
coverageBBox:
|
|
2356
|
-
supportedCategories: Object.keys(
|
|
2376
|
+
coverageBBox: ne,
|
|
2377
|
+
supportedCategories: Object.keys(pe),
|
|
2357
2378
|
priority: 10,
|
|
2358
|
-
adapter: new
|
|
2359
|
-
dataViewsBaseUrl: `${this._gatewayUrl}${
|
|
2379
|
+
adapter: new Ko({
|
|
2380
|
+
dataViewsBaseUrl: `${this._gatewayUrl}${tr}`,
|
|
2360
2381
|
getHeaders: async () => ({
|
|
2361
2382
|
...await this._getAuthHeaders(),
|
|
2362
2383
|
"x-project-id": t
|
|
2363
2384
|
})
|
|
2364
2385
|
})
|
|
2365
|
-
}), this._gatewayCache = new
|
|
2386
|
+
}), this._gatewayCache = new Xo({ regions: e }), this._gatewayProjectId = t, this._gatewayCache;
|
|
2366
2387
|
}
|
|
2367
2388
|
async _queryLayers() {
|
|
2368
2389
|
const t = this._bbox;
|
|
@@ -2406,11 +2427,11 @@ class Jo {
|
|
|
2406
2427
|
this._loadListeners.forEach((e) => e(t));
|
|
2407
2428
|
}
|
|
2408
2429
|
}
|
|
2409
|
-
class
|
|
2430
|
+
class zt {
|
|
2410
2431
|
constructor(t, e, o = !1, r) {
|
|
2411
|
-
if (this._auth = t, this._db =
|
|
2432
|
+
if (this._auth = t, this._db = be(e), this._functions = Zt(e, te), this._gatewayUrl = r?.gatewayUrl ?? "", o) {
|
|
2412
2433
|
const s = r?.firestoreEmulatorHost ?? "localhost", a = r?.firestoreEmulatorPort ?? 8080;
|
|
2413
|
-
|
|
2434
|
+
ve(this._db, s, a), Jt(this._functions, "localhost", 5001);
|
|
2414
2435
|
}
|
|
2415
2436
|
}
|
|
2416
2437
|
_auth;
|
|
@@ -2427,7 +2448,7 @@ class Lt {
|
|
|
2427
2448
|
* Throws if a project with the given ID already exists.
|
|
2428
2449
|
*/
|
|
2429
2450
|
async createProject(t) {
|
|
2430
|
-
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${
|
|
2451
|
+
const e = await this._auth.authenticatedFetch(`${this._gatewayUrl}${io}`, {
|
|
2431
2452
|
method: "POST",
|
|
2432
2453
|
headers: { "Content-Type": "application/json" },
|
|
2433
2454
|
body: JSON.stringify(t)
|
|
@@ -2443,12 +2464,12 @@ class Lt {
|
|
|
2443
2464
|
* Access is gated by Firestore rules which check membership.
|
|
2444
2465
|
*/
|
|
2445
2466
|
async listProjects() {
|
|
2446
|
-
const t = this._requireUser(), e =
|
|
2447
|
-
return (await
|
|
2467
|
+
const t = this._requireUser(), e = ft(this._db, kt);
|
|
2468
|
+
return (await _e(ke(e, Ee("members", "array-contains", t), xe(100)))).docs.map((r) => r.data());
|
|
2448
2469
|
}
|
|
2449
2470
|
/** Fetch a single project by ID. Returns null if not found. */
|
|
2450
2471
|
async getProject(t) {
|
|
2451
|
-
const e =
|
|
2472
|
+
const e = yt(ft(this._db, kt), t), o = await Ie(e);
|
|
2452
2473
|
return o.exists() ? o.data() : null;
|
|
2453
2474
|
}
|
|
2454
2475
|
/**
|
|
@@ -2457,10 +2478,10 @@ class Lt {
|
|
|
2457
2478
|
*/
|
|
2458
2479
|
async incrementUnitsConsumed(t, e, o) {
|
|
2459
2480
|
if (e <= 0) return;
|
|
2460
|
-
const r =
|
|
2461
|
-
await
|
|
2462
|
-
unitsConsumed:
|
|
2463
|
-
lastUpdated:
|
|
2481
|
+
const r = yt(this._db, "clientSync", t);
|
|
2482
|
+
await Ce(r, {
|
|
2483
|
+
unitsConsumed: Se(e),
|
|
2484
|
+
lastUpdated: Te(),
|
|
2464
2485
|
lastUserId: o
|
|
2465
2486
|
}, { merge: !0 });
|
|
2466
2487
|
}
|
|
@@ -2468,20 +2489,20 @@ class Lt {
|
|
|
2468
2489
|
* Invite a user to a project by email. Returns the invited user's uid and display name.
|
|
2469
2490
|
*/
|
|
2470
2491
|
async inviteUserToProject(t, e, o) {
|
|
2471
|
-
return (await
|
|
2492
|
+
return (await B(this._functions, "inviteUserToProject")({ email: t, spaceId: e, role: o })).data;
|
|
2472
2493
|
}
|
|
2473
2494
|
/** Change an existing member's role on a project. */
|
|
2474
2495
|
async changeUserRoleOnProject(t, e, o) {
|
|
2475
|
-
await
|
|
2496
|
+
await B(this._functions, "changeUserRoleOnProject")({ uid: t, spaceId: e, role: o });
|
|
2476
2497
|
}
|
|
2477
2498
|
/** Remove a member from a project. */
|
|
2478
2499
|
async removeUserFromProject(t, e) {
|
|
2479
|
-
await
|
|
2500
|
+
await B(this._functions, "removeUserFromProject")({ uid: t, spaceId: e });
|
|
2480
2501
|
}
|
|
2481
2502
|
}
|
|
2482
|
-
class
|
|
2503
|
+
class Nt {
|
|
2483
2504
|
constructor(t, e, o, r) {
|
|
2484
|
-
this._auth = t, this._gatewayUrl = r, this._functions =
|
|
2505
|
+
this._auth = t, this._gatewayUrl = r, this._functions = Zt(e, te), o && Jt(this._functions, "localhost", 5001);
|
|
2485
2506
|
}
|
|
2486
2507
|
_auth;
|
|
2487
2508
|
_gatewayUrl;
|
|
@@ -2498,13 +2519,13 @@ class qt {
|
|
|
2498
2519
|
}
|
|
2499
2520
|
/** Whether the current user has an active API key. */
|
|
2500
2521
|
async hasAPIKey() {
|
|
2501
|
-
return await this._fetch(
|
|
2522
|
+
return await this._fetch(Ct) !== null;
|
|
2502
2523
|
}
|
|
2503
2524
|
/** Returns the sign-in methods registered for the current user's email. */
|
|
2504
2525
|
async getSignInMethods() {
|
|
2505
2526
|
const t = this._auth.currentUser;
|
|
2506
2527
|
if (!t?.email) throw new Error("User has no e-mail");
|
|
2507
|
-
return
|
|
2528
|
+
return ze(this._auth.firebaseAuth, t.email);
|
|
2508
2529
|
}
|
|
2509
2530
|
/** Builds a human-readable label from a Firebase UserInfo provider entry. */
|
|
2510
2531
|
buildProviderLabel(t) {
|
|
@@ -2517,42 +2538,42 @@ class qt {
|
|
|
2517
2538
|
}
|
|
2518
2539
|
/** Links a Google or Microsoft provider to the current account via popup. Returns the new provider label. */
|
|
2519
2540
|
async linkProvider(t) {
|
|
2520
|
-
const e = this._requireUser(), o = t === "google.com" ? new
|
|
2541
|
+
const e = this._requireUser(), o = t === "google.com" ? new at() : new it(t), s = (await Ne(e, o)).user.providerData.find(
|
|
2521
2542
|
(a) => a.providerId === t
|
|
2522
2543
|
);
|
|
2523
2544
|
return s ? this.buildProviderLabel(s) : "-";
|
|
2524
2545
|
}
|
|
2525
2546
|
/** Unlinks a provider from the current account. */
|
|
2526
2547
|
async unlinkProvider(t) {
|
|
2527
|
-
await
|
|
2548
|
+
await $e(this._requireUser(), t);
|
|
2528
2549
|
}
|
|
2529
2550
|
/** Changes the password. Reauthenticates first. */
|
|
2530
2551
|
async updatePassword(t, e) {
|
|
2531
2552
|
const o = this._requireUser();
|
|
2532
2553
|
if (!o.email) throw new Error("User has no e-mail");
|
|
2533
|
-
await
|
|
2554
|
+
await bt(
|
|
2534
2555
|
o,
|
|
2535
|
-
|
|
2536
|
-
), await
|
|
2556
|
+
Q.credential(o.email, t)
|
|
2557
|
+
), await Fe(o, e);
|
|
2537
2558
|
}
|
|
2538
2559
|
/** Adds (sets) a password for an account that currently only uses SSO. */
|
|
2539
2560
|
async addPassword(t) {
|
|
2540
2561
|
const e = this._requireUser();
|
|
2541
2562
|
if (!e.email) throw new Error("User has no e-mail");
|
|
2542
|
-
await
|
|
2563
|
+
await Be(e, Q.credential(e.email, t));
|
|
2543
2564
|
}
|
|
2544
2565
|
/** Requests an e-mail change. Sends a verification e-mail to the new address. */
|
|
2545
2566
|
async updateEmail(t, e) {
|
|
2546
2567
|
const o = this._requireUser();
|
|
2547
2568
|
if (!o.email) throw new Error("User e-mail not available");
|
|
2548
|
-
await
|
|
2569
|
+
await bt(
|
|
2549
2570
|
o,
|
|
2550
|
-
|
|
2551
|
-
), await
|
|
2571
|
+
Q.credential(o.email, e)
|
|
2572
|
+
), await Ge(o, t), await He(o);
|
|
2552
2573
|
}
|
|
2553
2574
|
/** Creates a new API key for the current user. */
|
|
2554
2575
|
async createAPIKey(t) {
|
|
2555
|
-
return this._fetch(
|
|
2576
|
+
return this._fetch(Tt, {
|
|
2556
2577
|
method: "POST",
|
|
2557
2578
|
headers: { "Content-Type": "application/json" },
|
|
2558
2579
|
body: JSON.stringify({ expiration: t })
|
|
@@ -2561,7 +2582,7 @@ class qt {
|
|
|
2561
2582
|
/** Revokes the current user's API key. */
|
|
2562
2583
|
async revokeAPIKey() {
|
|
2563
2584
|
const t = await this._auth.authenticatedFetch(
|
|
2564
|
-
this._url(
|
|
2585
|
+
this._url(Tt),
|
|
2565
2586
|
{ method: "DELETE" }
|
|
2566
2587
|
);
|
|
2567
2588
|
if (!t.ok)
|
|
@@ -2569,17 +2590,17 @@ class qt {
|
|
|
2569
2590
|
}
|
|
2570
2591
|
/** Fetches the current user's existing API key. */
|
|
2571
2592
|
async requestAPIKey() {
|
|
2572
|
-
const t = await this._fetch(
|
|
2593
|
+
const t = await this._fetch(Ct);
|
|
2573
2594
|
if (!t) throw new Error("No API key found");
|
|
2574
2595
|
return t;
|
|
2575
2596
|
}
|
|
2576
2597
|
/** Returns organizations the current user is a member of. */
|
|
2577
2598
|
async listOrganizations() {
|
|
2578
|
-
return this._fetch(
|
|
2599
|
+
return this._fetch(ro);
|
|
2579
2600
|
}
|
|
2580
2601
|
/** Returns all members of the given organisation. Caller must be an org admin or superadmin. */
|
|
2581
2602
|
async getOrgMembers(t) {
|
|
2582
|
-
return this._fetch(
|
|
2603
|
+
return this._fetch(ao(t));
|
|
2583
2604
|
}
|
|
2584
2605
|
_requireUser() {
|
|
2585
2606
|
const t = this._auth.currentUser;
|
|
@@ -2591,11 +2612,11 @@ class qt {
|
|
|
2591
2612
|
* Uses the `getUserInfo` Firebase callable function.
|
|
2592
2613
|
*/
|
|
2593
2614
|
async getUserInfo(t) {
|
|
2594
|
-
return (await
|
|
2615
|
+
return (await B(this._functions, "getUserInfo")({ uids: t })).data;
|
|
2595
2616
|
}
|
|
2596
2617
|
/** Record that the current user has accepted the terms of service. Sets a `terms` custom claim on the token. */
|
|
2597
2618
|
async acceptTerms(t) {
|
|
2598
|
-
await this._fetch(
|
|
2619
|
+
await this._fetch(so, {
|
|
2599
2620
|
method: "POST",
|
|
2600
2621
|
headers: { "Content-Type": "application/json" },
|
|
2601
2622
|
body: JSON.stringify({ version: t })
|
|
@@ -2609,10 +2630,10 @@ class qt {
|
|
|
2609
2630
|
*/
|
|
2610
2631
|
async latestTermsAccepted() {
|
|
2611
2632
|
const t = this._auth.currentUser;
|
|
2612
|
-
return t ? (await
|
|
2633
|
+
return t ? (await st(t)).claims.terms ?? null : null;
|
|
2613
2634
|
}
|
|
2614
2635
|
}
|
|
2615
|
-
const
|
|
2636
|
+
const $t = ["superadmin", "admin", "syncer", "member"], Ft = {
|
|
2616
2637
|
createEntities: "admin",
|
|
2617
2638
|
createProvider: "superadmin",
|
|
2618
2639
|
changeContentCategories: "syncer",
|
|
@@ -2627,7 +2648,7 @@ const jt = ["superadmin", "admin", "syncer", "member"], Mt = {
|
|
|
2627
2648
|
uploadDocuments: "syncer",
|
|
2628
2649
|
viewEntities: "member"
|
|
2629
2650
|
};
|
|
2630
|
-
function
|
|
2651
|
+
function rr() {
|
|
2631
2652
|
return {
|
|
2632
2653
|
changeContentCategories: !1,
|
|
2633
2654
|
createEntities: !1,
|
|
@@ -2644,9 +2665,9 @@ function tr() {
|
|
|
2644
2665
|
viewEntities: !1
|
|
2645
2666
|
};
|
|
2646
2667
|
}
|
|
2647
|
-
class
|
|
2668
|
+
class Bt {
|
|
2648
2669
|
constructor(t) {
|
|
2649
|
-
this._isSuperAdmin = t, this._projectRoles = new x([]), this.privileges =
|
|
2670
|
+
this._isSuperAdmin = t, this._projectRoles = new x([]), this.privileges = ct(
|
|
2650
2671
|
[this._projectRoles, t],
|
|
2651
2672
|
() => this._compute()
|
|
2652
2673
|
);
|
|
@@ -2673,17 +2694,17 @@ class Ut {
|
|
|
2673
2694
|
_expand(t) {
|
|
2674
2695
|
if (this._isSuperAdmin.get())
|
|
2675
2696
|
return ["superadmin", "admin", "syncer", "member"];
|
|
2676
|
-
const e =
|
|
2677
|
-
return e === -1 ? [] : Array.from(
|
|
2697
|
+
const e = $t.findIndex((o) => t.includes(o));
|
|
2698
|
+
return e === -1 ? [] : Array.from($t.slice(e));
|
|
2678
2699
|
}
|
|
2679
2700
|
_compute() {
|
|
2680
|
-
const t = this._projectRoles.get(), e =
|
|
2681
|
-
for (const o of Object.keys(
|
|
2682
|
-
e[o] = t.includes(
|
|
2701
|
+
const t = this._projectRoles.get(), e = rr();
|
|
2702
|
+
for (const o of Object.keys(Ft))
|
|
2703
|
+
e[o] = t.includes(Ft[o]);
|
|
2683
2704
|
return e;
|
|
2684
2705
|
}
|
|
2685
2706
|
}
|
|
2686
|
-
class
|
|
2707
|
+
class Gt {
|
|
2687
2708
|
constructor(t) {
|
|
2688
2709
|
this._storage = t;
|
|
2689
2710
|
}
|
|
@@ -2716,7 +2737,7 @@ class zt {
|
|
|
2716
2737
|
// ── Internal helpers ───────────────────────────────────────────────────────
|
|
2717
2738
|
async _get(t, e) {
|
|
2718
2739
|
try {
|
|
2719
|
-
const r = await (await
|
|
2740
|
+
const r = await (await Yt(_(this._storage, `${t}/${e}.json.gz`))).arrayBuffer(), s = new DecompressionStream("gzip"), a = s.writable.getWriter(), n = s.readable.getReader();
|
|
2720
2741
|
a.write(new Uint8Array(r)), a.close();
|
|
2721
2742
|
const p = [];
|
|
2722
2743
|
let c = await n.read();
|
|
@@ -2728,7 +2749,7 @@ class zt {
|
|
|
2728
2749
|
d.set(w, g), g += w.length;
|
|
2729
2750
|
return JSON.parse(new TextDecoder().decode(d));
|
|
2730
2751
|
} catch (o) {
|
|
2731
|
-
if (
|
|
2752
|
+
if (sr(o)) return;
|
|
2732
2753
|
throw o;
|
|
2733
2754
|
}
|
|
2734
2755
|
}
|
|
@@ -2743,14 +2764,14 @@ class zt {
|
|
|
2743
2764
|
let g = 0;
|
|
2744
2765
|
for (const w of p)
|
|
2745
2766
|
d.set(w, g), g += w.length;
|
|
2746
|
-
await
|
|
2767
|
+
await rt(
|
|
2747
2768
|
_(this._storage, `${t}/${e}.json.gz`),
|
|
2748
2769
|
d,
|
|
2749
2770
|
{ contentType: "application/gzip" }
|
|
2750
2771
|
);
|
|
2751
2772
|
}
|
|
2752
2773
|
}
|
|
2753
|
-
function
|
|
2774
|
+
function sr(i) {
|
|
2754
2775
|
return typeof i == "object" && i !== null && "code" in i && i.code === "storage/object-not-found";
|
|
2755
2776
|
}
|
|
2756
2777
|
const b = {
|
|
@@ -6001,12 +6022,12 @@ const b = {
|
|
|
6001
6022
|
fbsp: "http://purl.obolibrary.org/obo/FBSP_",
|
|
6002
6023
|
rex: "http://purl.obolibrary.org/obo/REX_"
|
|
6003
6024
|
};
|
|
6004
|
-
class
|
|
6025
|
+
class gt {
|
|
6005
6026
|
static _instance;
|
|
6006
6027
|
// Opposite map is built once
|
|
6007
6028
|
_nsMap;
|
|
6008
6029
|
static getInstance() {
|
|
6009
|
-
return this._instance ? this._instance : (this._instance = new
|
|
6030
|
+
return this._instance ? this._instance : (this._instance = new gt(), this._instance);
|
|
6010
6031
|
}
|
|
6011
6032
|
compactIRI(t) {
|
|
6012
6033
|
let e = this._nsMap;
|
|
@@ -6032,7 +6053,7 @@ class ht {
|
|
|
6032
6053
|
), this._nsMap = t, t;
|
|
6033
6054
|
}
|
|
6034
6055
|
}
|
|
6035
|
-
class
|
|
6056
|
+
class ar {
|
|
6036
6057
|
constructor(t, e, o, r, s) {
|
|
6037
6058
|
this._api = t, this._projectId = e, this._queryCache = r, this._graphType = s, 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(o).catch(
|
|
6038
6059
|
(a) => console.error("[CueProjectSchema] Initial load failed:", a)
|
|
@@ -6088,7 +6109,7 @@ class or {
|
|
|
6088
6109
|
return;
|
|
6089
6110
|
}
|
|
6090
6111
|
const o = this._buildCategoriesQuery(t, "ContentCategory"), r = this._buildCategoriesQuery(t, "EntityCategory"), s = this._buildRelationshipsQuery(t);
|
|
6091
|
-
await
|
|
6112
|
+
await ht(
|
|
6092
6113
|
o + r + s,
|
|
6093
6114
|
async () => {
|
|
6094
6115
|
const [a, n, p] = await Promise.all([
|
|
@@ -6161,9 +6182,9 @@ GROUP BY ?iri ?parent`;
|
|
|
6161
6182
|
});
|
|
6162
6183
|
}
|
|
6163
6184
|
}
|
|
6164
|
-
const
|
|
6165
|
-
class
|
|
6166
|
-
constructor(t, e, o =
|
|
6185
|
+
const ir = "https://qlever.dev/api/osm-planet";
|
|
6186
|
+
class ce {
|
|
6187
|
+
constructor(t, e, o = dt, r, s) {
|
|
6167
6188
|
this._api = t, this._projectId = e, this._queryCache = r, this._graphType = s, this.baseURL = `${o}${e}/`, this.entityInfoMap = this._entityInfoMapComputed, this.entityGraph = this._entityGraph.asReadonly(), this._entityOSMMap.subscribe(() => this._checkPendingOSMFetches()), this._fetchEntityGraph().catch(
|
|
6168
6189
|
(a) => console.error("[CueProjectEntities] Entity graph fetch failed:", a)
|
|
6169
6190
|
);
|
|
@@ -6185,7 +6206,7 @@ class sr {
|
|
|
6185
6206
|
_fetchingOSMIds = /* @__PURE__ */ new Set();
|
|
6186
6207
|
_entityGraph = new x(void 0);
|
|
6187
6208
|
// ── Derived signals ────────────────────────────────────────────────────────
|
|
6188
|
-
_entityInfoMapComputed =
|
|
6209
|
+
_entityInfoMapComputed = ct(
|
|
6189
6210
|
[
|
|
6190
6211
|
this._entityDetails,
|
|
6191
6212
|
this._entityDocuments,
|
|
@@ -6426,7 +6447,7 @@ ORDER BY DESC(?weight)`, o = await this._api.sparql(
|
|
|
6426
6447
|
};
|
|
6427
6448
|
}
|
|
6428
6449
|
if (t === "md") {
|
|
6429
|
-
const s =
|
|
6450
|
+
const s = gt.getInstance(), a = r.map((h) => ({
|
|
6430
6451
|
src: s.compactIRI(h.sourceCat.value),
|
|
6431
6452
|
pred: s.compactIRI(h.predicate.value),
|
|
6432
6453
|
tgt: s.compactIRI(h.targetCat.value),
|
|
@@ -6462,9 +6483,9 @@ ORDER BY DESC(?weight)`, o = await this._api.sparql(
|
|
|
6462
6483
|
for (const { osm: f, viaRels: k, entityUUID: m } of h.indirect) {
|
|
6463
6484
|
const E = s[f];
|
|
6464
6485
|
if (E)
|
|
6465
|
-
for (const
|
|
6466
|
-
const v = `${
|
|
6467
|
-
y.geometries.some((
|
|
6486
|
+
for (const I of k) {
|
|
6487
|
+
const v = `${I}:${m}`, y = u.get(v) ?? { geometries: [], entityUUID: m };
|
|
6488
|
+
y.geometries.some((C) => C.osmIRI === f) || (y.geometries.push({ osmIRI: f, wkt: E }), u.set(v, y));
|
|
6468
6489
|
}
|
|
6469
6490
|
}
|
|
6470
6491
|
u.size > 0 && (g = Array.from(u.entries()).map(
|
|
@@ -6561,7 +6582,7 @@ WHERE {
|
|
|
6561
6582
|
?e2 qcy:hasEntityCategory ?e2Cat
|
|
6562
6583
|
}
|
|
6563
6584
|
GROUP BY ?e1Cat ?e2Cat`;
|
|
6564
|
-
await
|
|
6585
|
+
await ht(
|
|
6565
6586
|
t,
|
|
6566
6587
|
async () => {
|
|
6567
6588
|
const e = await this._api.sparql(
|
|
@@ -6601,7 +6622,7 @@ GROUP BY ?e1Cat ?e2Cat`;
|
|
|
6601
6622
|
const o = e.map((n) => `<${n}>`).join(" "), r = `PREFIX geo: <${R.geo}>
|
|
6602
6623
|
SELECT * WHERE {
|
|
6603
6624
|
VALUES ?s { ${o} }
|
|
6604
|
-
SERVICE <${
|
|
6625
|
+
SERVICE <${ir}> {
|
|
6605
6626
|
?s geo:hasGeometry/geo:asWKT ?wkt
|
|
6606
6627
|
}
|
|
6607
6628
|
}`, s = await this._api.sparql(
|
|
@@ -6614,8 +6635,8 @@ SELECT * WHERE {
|
|
|
6614
6635
|
}), this._osmWKTMap.set(a);
|
|
6615
6636
|
}
|
|
6616
6637
|
}
|
|
6617
|
-
class
|
|
6618
|
-
constructor(t, e, o, r =
|
|
6638
|
+
class pt {
|
|
6639
|
+
constructor(t, e, o, r = dt, s, a) {
|
|
6619
6640
|
this._api = t, this._projectId = e, this._queryCache = s, this._graphType = a, this.baseURL = `${r}${e}/`, this._currentLang = o ?? this._api.language, this.documentInfoMap = this._documentInfoMap.asReadonly(), this.projectDocumentsData = this._projectDocumentsData.asReadonly();
|
|
6620
6641
|
}
|
|
6621
6642
|
_api;
|
|
@@ -6669,7 +6690,7 @@ class ar {
|
|
|
6669
6690
|
documentsByContentCategory: {}
|
|
6670
6691
|
});
|
|
6671
6692
|
const t = this._buildDocumentsBySuffixQuery(), e = this._buildDocumentsByContentCategoryQuery(), o = this._buildDuplicateCountQuery();
|
|
6672
|
-
await
|
|
6693
|
+
await ht(
|
|
6673
6694
|
t + e + o,
|
|
6674
6695
|
async () => {
|
|
6675
6696
|
const [r, s, a] = await Promise.all([
|
|
@@ -6689,16 +6710,134 @@ class ar {
|
|
|
6689
6710
|
* once the SPARQL response arrives.
|
|
6690
6711
|
*/
|
|
6691
6712
|
requestDocumentData(t) {
|
|
6692
|
-
const e = t.filter((
|
|
6693
|
-
|
|
6694
|
-
|
|
6713
|
+
const e = t.filter((o) => this._documentInfoMap.get()[o] === void 0);
|
|
6714
|
+
e.length !== 0 && this._fetchDocumentInfoBatch(e).catch(
|
|
6715
|
+
(o) => console.error("[CueProjectDocuments] requestDocumentData failed:", o)
|
|
6716
|
+
);
|
|
6717
|
+
}
|
|
6718
|
+
/**
|
|
6719
|
+
* Promise-based alternative to {@link requestDocumentData} for non-reactive contexts.
|
|
6720
|
+
*
|
|
6721
|
+
* Resolves with the `DocumentInfo` entries for every requested UUID once the
|
|
6722
|
+
* SPARQL response arrives. UUIDs already present in the cache are returned
|
|
6723
|
+
* immediately without a network request. The result is also written into
|
|
6724
|
+
* `documentInfoMap` so reactive consumers stay in sync.
|
|
6725
|
+
*
|
|
6726
|
+
* UUIDs not found in the triplestore are omitted from the returned map.
|
|
6727
|
+
*
|
|
6728
|
+
* @example
|
|
6729
|
+
* ```ts
|
|
6730
|
+
* const docs = await cueProjectDocs.fetchDocumentData(['uuid1', 'uuid2']);
|
|
6731
|
+
* console.log(docs['uuid1'].subject);
|
|
6732
|
+
* ```
|
|
6733
|
+
*/
|
|
6734
|
+
async fetchDocumentData(t) {
|
|
6735
|
+
const e = this._documentInfoMap.get(), o = t.filter((s) => e[s] === void 0);
|
|
6736
|
+
o.length > 0 && await this._fetchDocumentInfoBatch(o);
|
|
6737
|
+
const r = this._documentInfoMap.get();
|
|
6738
|
+
return Object.fromEntries(
|
|
6739
|
+
t.filter((s) => r[s] !== void 0).map((s) => [s, r[s]])
|
|
6740
|
+
);
|
|
6741
|
+
}
|
|
6742
|
+
/**
|
|
6743
|
+
* Fetches a lightweight document metadata shape (id/path/suffix/size) for
|
|
6744
|
+
* the given UUIDs and merges the results into `documentInfoMap`.
|
|
6745
|
+
*
|
|
6746
|
+
* This is useful for list/table contexts that do not need language-tagged
|
|
6747
|
+
* fields (`subject`, `summary`) or category/tag enrichment.
|
|
6748
|
+
*
|
|
6749
|
+
* UUIDs already present in `documentInfoMap` are skipped.
|
|
6750
|
+
*/
|
|
6751
|
+
async fetchDocumentDataSimple(t) {
|
|
6752
|
+
const e = this._documentInfoMap.get(), o = t.filter((s) => e[s] === void 0);
|
|
6753
|
+
o.length > 0 && await this._fetchSimpleDocumentInfoBatch(o);
|
|
6754
|
+
const r = this._documentInfoMap.get();
|
|
6755
|
+
return Object.fromEntries(
|
|
6756
|
+
t.filter((s) => r[s] !== void 0).map((s) => [s, r[s]])
|
|
6757
|
+
);
|
|
6758
|
+
}
|
|
6759
|
+
/**
|
|
6760
|
+
* Returns the alternative representations of the given document UUID.
|
|
6761
|
+
*
|
|
6762
|
+
* Alternative representations are derived artefacts stored under
|
|
6763
|
+
* `qcy:alternativeRepresentation` in the triplestore — for example a
|
|
6764
|
+
* `.fragments` BIM tile derived from an `.ifc` source file.
|
|
6765
|
+
*
|
|
6766
|
+
* The returned `DocumentInfo` entries are also merged into
|
|
6767
|
+
* `documentInfoMap` so reactive consumers stay in sync.
|
|
6768
|
+
*
|
|
6769
|
+
* @example
|
|
6770
|
+
* ```ts
|
|
6771
|
+
* const alts = await docs.fetchAlternativeRepresentations('abc-123');
|
|
6772
|
+
* // alts[0].suffix => '.fragments'
|
|
6773
|
+
* ```
|
|
6774
|
+
*/
|
|
6775
|
+
async fetchAlternativeRepresentations(t) {
|
|
6776
|
+
const e = this._api.language, o = `PREFIX qcy: <${b.qcy}>
|
|
6777
|
+
PREFIX r: <${this.baseURL}>
|
|
6778
|
+
SELECT ?altId ?contentIRI ?suffix ?size ?subject ?summary
|
|
6779
|
+
(SAMPLE(?fp) AS ?path)
|
|
6780
|
+
(GROUP_CONCAT(DISTINCT ?tag; SEPARATOR=";") AS ?tags)
|
|
6781
|
+
(GROUP_CONCAT(DISTINCT STR(?cat); SEPARATOR=";") AS ?categories)
|
|
6782
|
+
WHERE {
|
|
6783
|
+
r:${t} qcy:alternativeRepresentation ?contentIRI .
|
|
6784
|
+
BIND(REPLACE(STR(?contentIRI), "^.*/([^/]*)$", "$1") AS ?altId)
|
|
6785
|
+
?contentIRI qcy:sizeBytes ?size ;
|
|
6786
|
+
qcy:hasFileLocation ?loc .
|
|
6787
|
+
?loc qcy:filePath ?fp ;
|
|
6788
|
+
qcy:suffix ?suffix .
|
|
6789
|
+
OPTIONAL { ?contentIRI qcy:hasContentCategory ?cat }
|
|
6790
|
+
OPTIONAL { ?contentIRI qcy:tag ?tag }
|
|
6791
|
+
OPTIONAL { ?contentIRI qcy:subject ?lang_subj FILTER(LANG(?lang_subj) = "${e}") }
|
|
6792
|
+
OPTIONAL { ?contentIRI qcy:subject ?no_lang_subj }
|
|
6793
|
+
BIND(COALESCE(?lang_subj, ?no_lang_subj) AS ?subject)
|
|
6794
|
+
OPTIONAL { ?contentIRI qcy:textSummary ?lang_summary FILTER(LANG(?lang_summary) = "${e}") }
|
|
6795
|
+
OPTIONAL { ?contentIRI qcy:textSummary ?no_lang_summary }
|
|
6796
|
+
BIND(COALESCE(?lang_summary, ?no_lang_summary) AS ?summary)
|
|
6797
|
+
}
|
|
6798
|
+
GROUP BY ?altId ?contentIRI ?suffix ?size ?subject ?summary`, r = await this._api.sparql(o, this._projectId, this._graphType), s = { ...this._documentInfoMap.get() }, a = [];
|
|
6799
|
+
return r.results.bindings.forEach((n) => {
|
|
6800
|
+
if (!n.altId || !n.contentIRI) return;
|
|
6801
|
+
const p = n.altId.value, c = {
|
|
6802
|
+
id: p,
|
|
6803
|
+
contentIRI: n.contentIRI.value,
|
|
6804
|
+
path: n.path?.value ?? "",
|
|
6805
|
+
suffix: n.suffix?.value ?? "",
|
|
6806
|
+
size: n.size ? parseInt(n.size.value, 10) : 0,
|
|
6807
|
+
tags: n.tags?.value?.split(";").filter(Boolean) ?? [],
|
|
6808
|
+
categories: n.categories?.value?.split(";").filter(Boolean) ?? [],
|
|
6809
|
+
subject: n.subject?.value,
|
|
6810
|
+
summary: n.summary?.value
|
|
6811
|
+
};
|
|
6812
|
+
s[p] = c, a.push(c);
|
|
6813
|
+
}), this._documentInfoMap.set(s), a;
|
|
6814
|
+
}
|
|
6815
|
+
/**
|
|
6816
|
+
* Returns a single arbitrary file path from the project's triplestore.
|
|
6817
|
+
* Useful for pre-filling path-based query inputs with a realistic example.
|
|
6818
|
+
*/
|
|
6819
|
+
async randomFilePath() {
|
|
6820
|
+
const t = `PREFIX qcy: <${b.qcy}>
|
|
6821
|
+
SELECT ?path
|
|
6822
|
+
WHERE {
|
|
6823
|
+
?fl a qcy:FileLocation ;
|
|
6824
|
+
qcy:filePath ?path .
|
|
6825
|
+
}
|
|
6826
|
+
LIMIT 1`;
|
|
6827
|
+
return (await this._api.sparql(t, this._projectId, this._graphType)).results.bindings[0]?.path?.value ?? null;
|
|
6828
|
+
}
|
|
6829
|
+
// ── Private helpers ────────────────────────────────────────────────────────
|
|
6830
|
+
/** Executes the document-info SPARQL query for the given UUIDs, merges results
|
|
6831
|
+
* into `documentInfoMap`, and returns the newly fetched entries. */
|
|
6832
|
+
async _fetchDocumentInfoBatch(t) {
|
|
6833
|
+
const e = t.map((p) => `r:${p}`).join(" "), o = this._api.language, r = `PREFIX qcy: <${b.qcy}>
|
|
6695
6834
|
PREFIX r: <${this.baseURL}>
|
|
6696
6835
|
SELECT ?id ?contentIRI ?suffix ?size ?subject ?summary
|
|
6697
6836
|
(SAMPLE(?fp) AS ?path)
|
|
6698
6837
|
(GROUP_CONCAT(DISTINCT ?tag; SEPARATOR=";") AS ?tags)
|
|
6699
6838
|
(GROUP_CONCAT(DISTINCT STR(?cat); SEPARATOR=";") AS ?categories)
|
|
6700
6839
|
WHERE {
|
|
6701
|
-
VALUES ?contentIRI { ${
|
|
6840
|
+
VALUES ?contentIRI { ${e} }
|
|
6702
6841
|
?contentIRI qcy:sizeBytes ?size ;
|
|
6703
6842
|
qcy:hasFileLocation ?loc .
|
|
6704
6843
|
?loc qcy:filePath ?fp ;
|
|
@@ -6707,54 +6846,66 @@ WHERE {
|
|
|
6707
6846
|
OPTIONAL { ?contentIRI qcy:tag ?tag }
|
|
6708
6847
|
OPTIONAL { ?loc qcy:remoteProviderId ?pid }
|
|
6709
6848
|
|
|
6710
|
-
OPTIONAL { ?contentIRI qcy:subject ?lang_subj FILTER(LANG(?lang_subj) = "${
|
|
6849
|
+
OPTIONAL { ?contentIRI qcy:subject ?lang_subj FILTER(LANG(?lang_subj) = "${o}") }
|
|
6711
6850
|
OPTIONAL { ?contentIRI qcy:subject ?no_lang_subj }
|
|
6712
6851
|
BIND(COALESCE(?lang_subj, ?no_lang_subj) AS ?subject)
|
|
6713
6852
|
|
|
6714
|
-
OPTIONAL { ?contentIRI qcy:textSummary ?lang_summary FILTER(LANG(?lang_summary) = "${
|
|
6853
|
+
OPTIONAL { ?contentIRI qcy:textSummary ?lang_summary FILTER(LANG(?lang_summary) = "${o}") }
|
|
6715
6854
|
OPTIONAL { ?contentIRI qcy:textSummary ?no_lang_summary }
|
|
6716
6855
|
BIND(COALESCE(?lang_summary, ?no_lang_summary) AS ?summary)
|
|
6717
6856
|
|
|
6718
6857
|
BIND(REPLACE(STR(?contentIRI), "^.*/([^/]*)$", "$1") AS ?id)
|
|
6719
6858
|
}
|
|
6720
|
-
GROUP BY ?id ?contentIRI ?suffix ?size ?subject ?summary
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
p
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
};
|
|
6738
|
-
}), this._documentInfoMap.set(p);
|
|
6739
|
-
}).catch(
|
|
6740
|
-
(a) => console.error("[CueProjectDocuments] requestDocumentData failed:", a)
|
|
6741
|
-
);
|
|
6859
|
+
GROUP BY ?id ?contentIRI ?suffix ?size ?subject ?summary`, s = await this._api.sparql(r, this._projectId), a = { ...this._documentInfoMap.get() }, n = {};
|
|
6860
|
+
return s.results.bindings.forEach((p) => {
|
|
6861
|
+
if (!p.id || !p.contentIRI) return;
|
|
6862
|
+
const c = p.id.value, h = {
|
|
6863
|
+
id: c,
|
|
6864
|
+
contentIRI: p.contentIRI.value,
|
|
6865
|
+
path: p.path?.value ?? "",
|
|
6866
|
+
suffix: p.suffix?.value ?? "",
|
|
6867
|
+
size: p.size ? parseInt(p.size.value, 10) : 0,
|
|
6868
|
+
tags: p.tags?.value?.split(";").filter(Boolean) ?? [],
|
|
6869
|
+
categories: p.categories?.value?.split(";").filter(Boolean) ?? [],
|
|
6870
|
+
subject: p.subject?.value,
|
|
6871
|
+
summary: p.summary?.value,
|
|
6872
|
+
providerId: p.pid?.value
|
|
6873
|
+
};
|
|
6874
|
+
a[c] = h, n[c] = h;
|
|
6875
|
+
}), this._documentInfoMap.set(a), n;
|
|
6742
6876
|
}
|
|
6743
|
-
/**
|
|
6744
|
-
*
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
SELECT ?path
|
|
6877
|
+
/** Executes a reduced document-info query (id/path/suffix/size only), merges
|
|
6878
|
+
* into `documentInfoMap`, and returns newly fetched entries. */
|
|
6879
|
+
async _fetchSimpleDocumentInfoBatch(t) {
|
|
6880
|
+
const e = t.map((n) => `r:${n}`).join(" "), o = `PREFIX qcy: <${b.qcy}>
|
|
6881
|
+
PREFIX r: <${this.baseURL}>
|
|
6882
|
+
SELECT ?id ?contentIRI ?suffix ?size (SAMPLE(?fp) AS ?path)
|
|
6750
6883
|
WHERE {
|
|
6751
|
-
?
|
|
6752
|
-
|
|
6884
|
+
VALUES ?contentIRI { ${e} }
|
|
6885
|
+
?contentIRI qcy:sizeBytes ?size ;
|
|
6886
|
+
qcy:hasFileLocation ?loc .
|
|
6887
|
+
?loc qcy:filePath ?fp ;
|
|
6888
|
+
qcy:suffix ?suffix .
|
|
6889
|
+
BIND(REPLACE(STR(?contentIRI), "^.*/([^/]*)$", "$1") AS ?id)
|
|
6753
6890
|
}
|
|
6754
|
-
|
|
6755
|
-
return
|
|
6891
|
+
GROUP BY ?id ?contentIRI ?suffix ?size`, r = await this._api.sparql(o, this._projectId, this._graphType), s = { ...this._documentInfoMap.get() }, a = {};
|
|
6892
|
+
return r.results.bindings.forEach((n) => {
|
|
6893
|
+
if (!n.id) return;
|
|
6894
|
+
const p = n.id.value, c = s[p], h = {
|
|
6895
|
+
id: p,
|
|
6896
|
+
contentIRI: n.contentIRI?.value ?? c?.contentIRI ?? p,
|
|
6897
|
+
path: n.path?.value ?? c?.path ?? p,
|
|
6898
|
+
suffix: n.suffix?.value ?? c?.suffix ?? "",
|
|
6899
|
+
size: n.size ? parseInt(n.size.value, 10) : c?.size ?? 0,
|
|
6900
|
+
tags: c?.tags ?? [],
|
|
6901
|
+
categories: c?.categories ?? [],
|
|
6902
|
+
subject: c?.subject,
|
|
6903
|
+
summary: c?.summary,
|
|
6904
|
+
providerId: c?.providerId
|
|
6905
|
+
};
|
|
6906
|
+
s[p] = h, a[p] = h;
|
|
6907
|
+
}), this._documentInfoMap.set(s), a;
|
|
6756
6908
|
}
|
|
6757
|
-
// ── Private helpers ────────────────────────────────────────────────────────
|
|
6758
6909
|
async _fetchDocumentsBySuffix() {
|
|
6759
6910
|
return this._runDocumentsBySuffixQuery(this._buildDocumentsBySuffixQuery());
|
|
6760
6911
|
}
|
|
@@ -6835,9 +6986,9 @@ WHERE {
|
|
|
6835
6986
|
return o?.count ? parseInt(o.count.value, 10) : 0;
|
|
6836
6987
|
}
|
|
6837
6988
|
}
|
|
6838
|
-
class
|
|
6839
|
-
constructor(t, e, { language: o, queryCache: r, rdfBase: s =
|
|
6840
|
-
this._api = t, this._projectId = e, this.schema = new
|
|
6989
|
+
class nr {
|
|
6990
|
+
constructor(t, e, { language: o, queryCache: r, rdfBase: s = dt, graphType: a }) {
|
|
6991
|
+
this._api = t, this._projectId = e, this.schema = new ar(t, e, o, r, a), this.entities = new ce(t, e, s, r, a), this.documents = new pt(t, e, o, s, r, a), this.availableContentCategories = this.schema.availableContentCategories, this.availableEntityCategories = this.schema.availableEntityCategories, this.availableEntityRelationships = this.schema.availableEntityRelationships, this.schemaReady = this.schema.ready, this.entityInfoMap = this.entities.entityInfoMap, this.entityGraph = this.entities.entityGraph, this.documentInfoMap = this.documents.documentInfoMap, this.projectDocumentsData = this.documents.projectDocumentsData, this.searchResults = this._searchResults.asReadonly(), this.documents.fetchOverview().catch((n) => console.error("[CueProjectView] fetchOverview failed:", n));
|
|
6841
6992
|
}
|
|
6842
6993
|
_api;
|
|
6843
6994
|
_projectId;
|
|
@@ -6955,7 +7106,7 @@ class ir {
|
|
|
6955
7106
|
this._destroyed = !0, this._searchResults.set(void 0);
|
|
6956
7107
|
}
|
|
6957
7108
|
}
|
|
6958
|
-
function
|
|
7109
|
+
function Ht(i, t) {
|
|
6959
7110
|
return new Promise((e) => {
|
|
6960
7111
|
const o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
6961
7112
|
for (const m of i)
|
|
@@ -6991,7 +7142,7 @@ function Nt(i, t) {
|
|
|
6991
7142
|
});
|
|
6992
7143
|
}
|
|
6993
7144
|
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 || {});
|
|
6994
|
-
const
|
|
7145
|
+
const pr = {
|
|
6995
7146
|
".aac": {
|
|
6996
7147
|
type: l.AUDIO,
|
|
6997
7148
|
open: !0,
|
|
@@ -7852,22 +8003,22 @@ const nr = {
|
|
|
7852
8003
|
}
|
|
7853
8004
|
};
|
|
7854
8005
|
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 + "";
|
|
7855
|
-
const { namedNode:
|
|
7856
|
-
pr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
7857
|
-
const { namedNode: Ir } = j, { namedNode: lr, literal: Tr } = j;
|
|
8006
|
+
const { namedNode: lr, literal: Cr } = j;
|
|
7858
8007
|
lr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
7859
|
-
|
|
8008
|
+
const { namedNode: Tr } = j, { namedNode: cr, literal: Sr } = j;
|
|
8009
|
+
cr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
8010
|
+
function hr(i) {
|
|
7860
8011
|
const t = i.split(".");
|
|
7861
8012
|
return t.length > 1 ? "." + t.pop()?.toLowerCase() : "";
|
|
7862
8013
|
}
|
|
7863
|
-
const { namedNode: hr, literal: Sr } = j;
|
|
7864
|
-
hr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
7865
8014
|
const { namedNode: dr, literal: Ar } = j;
|
|
7866
8015
|
dr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
const
|
|
8016
|
+
const { namedNode: gr, literal: Rr } = j;
|
|
8017
|
+
gr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
8018
|
+
function Wt(i, t, e, o, r, s, a, n = !1, p = !1) {
|
|
8019
|
+
const c = hr(i), h = D(o), d = `${t}/${h}${c}`;
|
|
8020
|
+
a === void 0 && (a = pr[c]?.mime ?? "application/octet-stream");
|
|
8021
|
+
const g = Ye(i, r);
|
|
7871
8022
|
return {
|
|
7872
8023
|
name: i,
|
|
7873
8024
|
blob_name: d,
|
|
@@ -7893,7 +8044,7 @@ async function M() {
|
|
|
7893
8044
|
"fs/promises"
|
|
7894
8045
|
);
|
|
7895
8046
|
}
|
|
7896
|
-
async function
|
|
8047
|
+
async function Vt(i) {
|
|
7897
8048
|
if (typeof window < "u")
|
|
7898
8049
|
throw new Error(
|
|
7899
8050
|
`Cannot read file from path "${i}" in a browser environment. Provide file.data (Uint8Array) instead.`
|
|
@@ -7901,20 +8052,20 @@ async function Ft(i) {
|
|
|
7901
8052
|
const { readFile: t } = await M();
|
|
7902
8053
|
return t(i);
|
|
7903
8054
|
}
|
|
7904
|
-
let q = null,
|
|
7905
|
-
function
|
|
7906
|
-
|
|
8055
|
+
let q = null, H = null, W = null;
|
|
8056
|
+
function Or(i) {
|
|
8057
|
+
W = i, H = null, q = null;
|
|
7907
8058
|
}
|
|
7908
|
-
async function
|
|
8059
|
+
async function ur() {
|
|
7909
8060
|
if (typeof window < "u") {
|
|
7910
|
-
if (!
|
|
8061
|
+
if (!W)
|
|
7911
8062
|
throw new Error(
|
|
7912
8063
|
"WASM scanner is not configured for browser use. Call configureScanWasm(baseUrl) during app initialisation."
|
|
7913
8064
|
);
|
|
7914
|
-
const i = await fetch(`${
|
|
8065
|
+
const i = await fetch(`${W}/dir_scanner_wasm_bg.wasm`);
|
|
7915
8066
|
if (!i.ok)
|
|
7916
8067
|
throw new Error(`Failed to fetch WASM binary: ${i.status} ${i.statusText}`);
|
|
7917
|
-
const t = new Uint8Array(await i.arrayBuffer()), o = await import(`${
|
|
8068
|
+
const t = new Uint8Array(await i.arrayBuffer()), o = await import(`${W}/dir_scanner_wasm.mjs`);
|
|
7918
8069
|
await o.default({ module_or_path: t }), q = o.scan;
|
|
7919
8070
|
} else {
|
|
7920
8071
|
const { readFile: i } = await M(), { join: t } = await import(
|
|
@@ -7927,8 +8078,8 @@ async function gr() {
|
|
|
7927
8078
|
await a.default({ module_or_path: r }), q = a.scan;
|
|
7928
8079
|
}
|
|
7929
8080
|
}
|
|
7930
|
-
const
|
|
7931
|
-
async function
|
|
8081
|
+
const mr = "qlever", $ = 1e3, ut = "cue:pending:";
|
|
8082
|
+
async function mt(i) {
|
|
7932
8083
|
const { tmpdir: t } = await import(
|
|
7933
8084
|
/* webpackIgnore: true */
|
|
7934
8085
|
"os"
|
|
@@ -7938,37 +8089,37 @@ async function gt(i) {
|
|
|
7938
8089
|
);
|
|
7939
8090
|
return e(t(), `cue-sync-pending-${i}.json`);
|
|
7940
8091
|
}
|
|
7941
|
-
async function
|
|
8092
|
+
async function Kt(i) {
|
|
7942
8093
|
if (typeof window < "u") {
|
|
7943
|
-
const t = window.localStorage.getItem(`${
|
|
8094
|
+
const t = window.localStorage.getItem(`${ut}${i}`);
|
|
7944
8095
|
return t ? JSON.parse(t) : null;
|
|
7945
8096
|
}
|
|
7946
8097
|
try {
|
|
7947
|
-
const t = await (await M()).readFile(await
|
|
8098
|
+
const t = await (await M()).readFile(await mt(i), "utf-8");
|
|
7948
8099
|
return JSON.parse(t);
|
|
7949
8100
|
} catch {
|
|
7950
8101
|
return null;
|
|
7951
8102
|
}
|
|
7952
8103
|
}
|
|
7953
|
-
async function
|
|
8104
|
+
async function Qt(i) {
|
|
7954
8105
|
const t = JSON.stringify(i);
|
|
7955
8106
|
if (typeof window < "u") {
|
|
7956
|
-
window.localStorage.setItem(`${
|
|
8107
|
+
window.localStorage.setItem(`${ut}${i.spaceId}`, t);
|
|
7957
8108
|
return;
|
|
7958
8109
|
}
|
|
7959
|
-
await (await M()).writeFile(await
|
|
8110
|
+
await (await M()).writeFile(await mt(i.spaceId), t, "utf-8");
|
|
7960
8111
|
}
|
|
7961
|
-
async function
|
|
8112
|
+
async function wr(i) {
|
|
7962
8113
|
if (typeof window < "u") {
|
|
7963
|
-
window.localStorage.removeItem(`${
|
|
8114
|
+
window.localStorage.removeItem(`${ut}${i}`);
|
|
7964
8115
|
return;
|
|
7965
8116
|
}
|
|
7966
8117
|
try {
|
|
7967
|
-
await (await M()).unlink(await
|
|
8118
|
+
await (await M()).unlink(await mt(i));
|
|
7968
8119
|
} catch {
|
|
7969
8120
|
}
|
|
7970
8121
|
}
|
|
7971
|
-
class
|
|
8122
|
+
class fr {
|
|
7972
8123
|
constructor(t, e, o, r) {
|
|
7973
8124
|
this._auth = t, this._projects = e, this._blob = o, this._gatewayUrl = r;
|
|
7974
8125
|
}
|
|
@@ -8024,7 +8175,7 @@ class wr {
|
|
|
8024
8175
|
*/
|
|
8025
8176
|
async flushPendingMetadata(t, e, o) {
|
|
8026
8177
|
this._legacy = o ?? !1;
|
|
8027
|
-
const r = await
|
|
8178
|
+
const r = await Kt(t);
|
|
8028
8179
|
if (!(!r || r.items.length === 0)) {
|
|
8029
8180
|
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 ⏳`);
|
|
8030
8181
|
try {
|
|
@@ -8047,20 +8198,20 @@ class wr {
|
|
|
8047
8198
|
this._api?.getConsumption(o) ?? Promise.reject(new Error("CueSyncApi is not bound to a CueApi instance")),
|
|
8048
8199
|
this._fetchUnitCreditMap(s),
|
|
8049
8200
|
this._fetchTierNames()
|
|
8050
|
-
]), f = (await
|
|
8201
|
+
]), f = (await Ht(t, h)).localNotOnRemote ?? [], k = f.length > 0 ? await this.scanCost(f) : [];
|
|
8051
8202
|
let m = 0, E = 0;
|
|
8052
8203
|
for (const v of k) {
|
|
8053
8204
|
m += v.units;
|
|
8054
|
-
const y = g[c],
|
|
8205
|
+
const y = g[c], C = y?.[v.ext] ?? 1;
|
|
8055
8206
|
s && y && !(v.ext in y) && console.info(` Unknown format: .${v.ext} (using default rate of 1 credit/unit)`);
|
|
8056
|
-
const O = v.units *
|
|
8207
|
+
const O = v.units * C;
|
|
8057
8208
|
E += O, v.credits = Math.round(O);
|
|
8058
8209
|
}
|
|
8059
|
-
const
|
|
8210
|
+
const I = w[c] ?? c;
|
|
8060
8211
|
return {
|
|
8061
8212
|
costRecords: k,
|
|
8062
8213
|
tier: c,
|
|
8063
|
-
tierName:
|
|
8214
|
+
tierName: I,
|
|
8064
8215
|
unitsToConsume: m,
|
|
8065
8216
|
creditsToConsume: Math.round(E),
|
|
8066
8217
|
creditsAvailable: d.creditsAvailable,
|
|
@@ -8079,35 +8230,35 @@ class wr {
|
|
|
8079
8230
|
const [d, g] = await Promise.all([
|
|
8080
8231
|
this._listRemoteFiles(h, o, r, a),
|
|
8081
8232
|
this._api?.getConsumption(o) ?? Promise.reject(new Error("CueSyncApi is not bound to a CueApi instance"))
|
|
8082
|
-
]), { unitsAvailable: w } = g, u = await
|
|
8233
|
+
]), { unitsAvailable: w } = g, u = await Ht(t, d);
|
|
8083
8234
|
a && (console.info(`Total local files: ${t.length}`), console.info(`Total remote files: ${d.length}`), console.info(
|
|
8084
8235
|
`Total files to sync: ${(u.localNotOnRemote?.length ?? 0) + u.localNotOnRemotePathOnly.length}`
|
|
8085
8236
|
));
|
|
8086
8237
|
let f = u.syncCount, k = u.syncSize, m = 0, E = !1;
|
|
8087
|
-
const
|
|
8088
|
-
if (
|
|
8089
|
-
const
|
|
8090
|
-
if (
|
|
8238
|
+
const I = u.localNotOnRemote ?? [];
|
|
8239
|
+
if (I.length > 0) {
|
|
8240
|
+
const C = (await this.scanCost(I)).reduce((O, de) => O + de.units, 0);
|
|
8241
|
+
if (C > w)
|
|
8091
8242
|
throw new Error(
|
|
8092
|
-
`Insufficient units: ${
|
|
8243
|
+
`Insufficient units: ${C} units required but only ${w} available.`
|
|
8093
8244
|
);
|
|
8094
8245
|
}
|
|
8095
|
-
await this._initPendingBatch(o, a), a &&
|
|
8096
|
-
for (const y of
|
|
8246
|
+
await this._initPendingBatch(o, a), a && I.length && console.info("Syncing missing files ⏳");
|
|
8247
|
+
for (const y of I)
|
|
8097
8248
|
try {
|
|
8098
|
-
const
|
|
8249
|
+
const C = Wt(
|
|
8099
8250
|
y.relativePath,
|
|
8100
8251
|
o,
|
|
8101
8252
|
s,
|
|
8102
8253
|
y.md5,
|
|
8103
8254
|
r
|
|
8104
8255
|
);
|
|
8105
|
-
if (!
|
|
8106
|
-
const O = y.data ?? new Uint8Array(await
|
|
8256
|
+
if (!C.blob_name) throw new Error(`blob_name missing for ${y.relativePath}`);
|
|
8257
|
+
const O = y.data ?? new Uint8Array(await Vt(y.fullPath));
|
|
8107
8258
|
await this._blob.uploadRaw(
|
|
8108
|
-
|
|
8259
|
+
C.blob_name,
|
|
8109
8260
|
O,
|
|
8110
|
-
|
|
8261
|
+
C
|
|
8111
8262
|
), await this._queueFileLocation({
|
|
8112
8263
|
relativePath: y.relativePath,
|
|
8113
8264
|
md5: y.md5,
|
|
@@ -8115,8 +8266,8 @@ class wr {
|
|
|
8115
8266
|
providerId: r,
|
|
8116
8267
|
fileContentExists: !1
|
|
8117
8268
|
}), E = !0, f += 1, k += y.size || 0, this._logProgress(f, u.totalCount, k, u.totalSize, n);
|
|
8118
|
-
} catch (
|
|
8119
|
-
m += 1, console.error(`[CueSyncApi] Failed to upload file: ${y.fullPath}`), a && console.error("[CueSyncApi] Upload error details:",
|
|
8269
|
+
} catch (C) {
|
|
8270
|
+
m += 1, console.error(`[CueSyncApi] Failed to upload file: ${y.fullPath}`), a && console.error("[CueSyncApi] Upload error details:", C);
|
|
8120
8271
|
}
|
|
8121
8272
|
a && u.localNotOnRemotePathOnly.length && console.info(`Syncing missing file locations (on provider "${r}") ⏳`);
|
|
8122
8273
|
for (const y of u.localNotOnRemotePathOnly)
|
|
@@ -8142,7 +8293,7 @@ class wr {
|
|
|
8142
8293
|
async _getOrCreateGraph(t, e) {
|
|
8143
8294
|
const o = this._graphMap.get(t);
|
|
8144
8295
|
if (o) return o;
|
|
8145
|
-
const s = (await this._projects.getProject(t))?.projectSettings?.graph?.type ??
|
|
8296
|
+
const s = (await this._projects.getProject(t))?.projectSettings?.graph?.type ?? mr, a = s === "qlever" ? `${this._gatewayUrl}${oe}` : `${this._gatewayUrl}${ee}`, n = s === "qlever" ? `${this._gatewayUrl}${co}` : `${this._gatewayUrl}${po}`, p = new Ke({
|
|
8146
8297
|
graphType: s,
|
|
8147
8298
|
queryEndpoint: a,
|
|
8148
8299
|
updateEndpoint: n,
|
|
@@ -8208,7 +8359,7 @@ WHERE {
|
|
|
8208
8359
|
}
|
|
8209
8360
|
async _initPendingBatch(t, e) {
|
|
8210
8361
|
this._flushTimer !== null && (clearInterval(this._flushTimer), this._flushTimer = null), this._pendingSpaceId = t, this._pendingItems = [];
|
|
8211
|
-
const o = await
|
|
8362
|
+
const o = await Kt(t);
|
|
8212
8363
|
if (o && o.items.length > 0) {
|
|
8213
8364
|
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 ⏳`);
|
|
8214
8365
|
try {
|
|
@@ -8229,7 +8380,7 @@ WHERE {
|
|
|
8229
8380
|
typeof r == "object" && typeof r.unref == "function" && r.unref(), this._flushTimer = r;
|
|
8230
8381
|
}
|
|
8231
8382
|
async _queueFileLocation(t) {
|
|
8232
|
-
this._pendingItems.push(t), this._pendingSpaceId && await
|
|
8383
|
+
this._pendingItems.push(t), this._pendingSpaceId && await Qt({ spaceId: this._pendingSpaceId, items: this._pendingItems });
|
|
8233
8384
|
}
|
|
8234
8385
|
/**
|
|
8235
8386
|
* Flush all queued file-location items to the commands API in a single batch.
|
|
@@ -8244,18 +8395,18 @@ WHERE {
|
|
|
8244
8395
|
}
|
|
8245
8396
|
async _flushBatch(t, e, o) {
|
|
8246
8397
|
const r = [...t];
|
|
8247
|
-
this._pendingSpaceId === e && (this._pendingItems = []), await
|
|
8398
|
+
this._pendingSpaceId === e && (this._pendingItems = []), await wr(e);
|
|
8248
8399
|
try {
|
|
8249
8400
|
for (let s = 0; s < r.length; s += $)
|
|
8250
8401
|
await this._postFssBatch(r.slice(s, s + $), e);
|
|
8251
8402
|
o && console.info(`Wrote ${r.length} file location(s) to commands API ✅`);
|
|
8252
8403
|
} catch (s) {
|
|
8253
8404
|
const a = [...r, ...this._pendingItems];
|
|
8254
|
-
throw this._pendingItems = a, await
|
|
8405
|
+
throw this._pendingItems = a, await Qt({ spaceId: e, items: a }), s;
|
|
8255
8406
|
}
|
|
8256
8407
|
}
|
|
8257
8408
|
async _postFssBatch(t, e) {
|
|
8258
|
-
const o = this._legacy ? `${this._gatewayUrl}${
|
|
8409
|
+
const o = this._legacy ? `${this._gatewayUrl}${St}?blob=true` : `${this._gatewayUrl}${St}`;
|
|
8259
8410
|
let r;
|
|
8260
8411
|
try {
|
|
8261
8412
|
r = await this._auth.authenticatedFetch(o, {
|
|
@@ -8285,14 +8436,14 @@ WHERE {
|
|
|
8285
8436
|
* shown to the user before or after calling {@link sync}.
|
|
8286
8437
|
*/
|
|
8287
8438
|
async scanCost(t) {
|
|
8288
|
-
if (
|
|
8439
|
+
if (H || (H = ur()), await H, !q) throw new Error("WASM scan function not initialised");
|
|
8289
8440
|
const e = 200, o = /* @__PURE__ */ new Map();
|
|
8290
8441
|
for (let r = 0; r < t.length; r += e) {
|
|
8291
8442
|
const s = t.slice(r, r + e), a = await Promise.all(
|
|
8292
8443
|
s.map(async (p) => ({
|
|
8293
8444
|
originalPath: p.relativePath,
|
|
8294
8445
|
// Use pre-loaded data if available (browser), otherwise read from disk (Node.js).
|
|
8295
|
-
data: p.data ?? new Uint8Array(await
|
|
8446
|
+
data: p.data ?? new Uint8Array(await Vt(p.fullPath))
|
|
8296
8447
|
}))
|
|
8297
8448
|
), n = q(a);
|
|
8298
8449
|
for (const p of n) {
|
|
@@ -8352,7 +8503,7 @@ WHERE {
|
|
|
8352
8503
|
const { spaceId: o, providerId: r, userId: s, signal: a, onProgress: n } = e;
|
|
8353
8504
|
if (!t.data)
|
|
8354
8505
|
throw new Error("syncBrowserFile requires file.data (Uint8Array). Read the file with File.arrayBuffer() first.");
|
|
8355
|
-
const p =
|
|
8506
|
+
const p = Wt(t.relativePath, o, s, t.md5, r);
|
|
8356
8507
|
if (!p.blob_name) throw new Error(`blob_name missing for ${t.relativePath}`);
|
|
8357
8508
|
await this._blob.uploadRaw(
|
|
8358
8509
|
p.blob_name,
|
|
@@ -8396,7 +8547,7 @@ WHERE {
|
|
|
8396
8547
|
s({ percent: a, syncCount: t, totalCount: e, syncSize: o, totalSize: r });
|
|
8397
8548
|
}
|
|
8398
8549
|
}
|
|
8399
|
-
const
|
|
8550
|
+
const Xt = {
|
|
8400
8551
|
production: {
|
|
8401
8552
|
gatewayUrl: "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app",
|
|
8402
8553
|
tokenUrl: "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app/token",
|
|
@@ -8416,17 +8567,21 @@ const Ht = {
|
|
|
8416
8567
|
firestoreEmulatorPort: 8080
|
|
8417
8568
|
}
|
|
8418
8569
|
};
|
|
8419
|
-
class
|
|
8570
|
+
class he {
|
|
8420
8571
|
auth;
|
|
8421
8572
|
api;
|
|
8422
8573
|
projects;
|
|
8423
8574
|
profile;
|
|
8424
8575
|
privileges;
|
|
8425
8576
|
cache;
|
|
8577
|
+
storage;
|
|
8426
8578
|
_app;
|
|
8427
8579
|
_endpoints;
|
|
8428
8580
|
_isEmulator;
|
|
8581
|
+
_storageRaw;
|
|
8582
|
+
_storageProcessed;
|
|
8429
8583
|
_gis = null;
|
|
8584
|
+
_projectDocuments = /* @__PURE__ */ new Map();
|
|
8430
8585
|
/**
|
|
8431
8586
|
* Reactive GIS service. Lazily constructed on first access.
|
|
8432
8587
|
*
|
|
@@ -8439,7 +8594,7 @@ class ae {
|
|
|
8439
8594
|
* ```
|
|
8440
8595
|
*/
|
|
8441
8596
|
get gis() {
|
|
8442
|
-
return this._gis || (this._gis = new
|
|
8597
|
+
return this._gis || (this._gis = new or(
|
|
8443
8598
|
() => this.api.getAuthHeaders(),
|
|
8444
8599
|
this._endpoints.gatewayUrl
|
|
8445
8600
|
)), this._gis;
|
|
@@ -8448,22 +8603,22 @@ class ae {
|
|
|
8448
8603
|
!t.apiKey && !t.appId && !t.measurementId && console.warn(
|
|
8449
8604
|
"Using default SDK app settings. Contact QAECY for your own configuration for any production code."
|
|
8450
8605
|
);
|
|
8451
|
-
const o = t.apiKey ??
|
|
8452
|
-
this._endpoints = { ...
|
|
8606
|
+
const o = t.apiKey ?? Y.apiKey, r = t.appId ?? Y.appId, s = t.measurementId ?? Y.measurementId, a = t.environment ?? "production";
|
|
8607
|
+
this._endpoints = { ...Xt[a], ...t.endpoints }, this._isEmulator = a === "emulator", this._app = ge().find((p) => p.name === "[DEFAULT]") ?? ue({
|
|
8453
8608
|
apiKey: o,
|
|
8454
8609
|
appId: r,
|
|
8455
8610
|
measurementId: s,
|
|
8456
|
-
authDomain: `${
|
|
8457
|
-
projectId:
|
|
8458
|
-
messagingSenderId:
|
|
8459
|
-
}), this.auth = new
|
|
8611
|
+
authDomain: `${_t}.firebaseapp.com`,
|
|
8612
|
+
projectId: _t,
|
|
8613
|
+
messagingSenderId: Ze
|
|
8614
|
+
}), this.auth = new Ot(this._app, this._isEmulator, this._endpoints), this.projects = new zt(this.auth, this._app, this._isEmulator, this._endpoints), this._storageRaw = T(this._app, Et), this._storageProcessed = T(this._app, xt), 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), this.storage = new Pt(this._storageRaw, this._storageProcessed), this.profile = new Nt(
|
|
8460
8615
|
this.auth,
|
|
8461
8616
|
this._app,
|
|
8462
8617
|
this._isEmulator,
|
|
8463
8618
|
this._endpoints.gatewayUrl
|
|
8464
|
-
), this.privileges = new
|
|
8465
|
-
const n =
|
|
8466
|
-
this._isEmulator &&
|
|
8619
|
+
), this.privileges = new Bt(this.auth.isSuperAdmin);
|
|
8620
|
+
const n = T(this._app, It);
|
|
8621
|
+
this._isEmulator && K(n, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), this.cache = new Gt(n);
|
|
8467
8622
|
}
|
|
8468
8623
|
/**
|
|
8469
8624
|
* Create a `Cue` instance from an already-initialized Firebase app.
|
|
@@ -8482,31 +8637,34 @@ class ae {
|
|
|
8482
8637
|
* });
|
|
8483
8638
|
*/
|
|
8484
8639
|
static fromApp(t, e = {}) {
|
|
8485
|
-
const o = e.environment ?? "production", r = { ...
|
|
8640
|
+
const o = e.environment ?? "production", r = { ...Xt[o], ...e.endpoints }, s = new Ot(t, !1, r), a = new zt(s, t, !1, r), n = T(t, Et), p = T(t, xt), c = T(t, eo), h = T(t, to), d = T(t, Je), g = T(t, It), w = new Qe({
|
|
8486
8641
|
storageRaw: n,
|
|
8487
8642
|
storageProcessed: p,
|
|
8488
8643
|
storagePublic: c,
|
|
8489
8644
|
storageLogs: h,
|
|
8490
8645
|
storageChatSessions: d,
|
|
8491
8646
|
storagePersistence: g
|
|
8492
|
-
}), u = new
|
|
8647
|
+
}), u = new fr(s, a, w, r.gatewayUrl), f = new Dt(s, r.gatewayUrl, a, u);
|
|
8493
8648
|
u._bindApi(f);
|
|
8494
|
-
const k = new
|
|
8649
|
+
const k = new Nt(s, t, !1, r.gatewayUrl), m = Object.create(he.prototype), E = new Bt(s.isSuperAdmin), I = new Gt(g), v = new Pt(n, p);
|
|
8495
8650
|
return Object.assign(m, {
|
|
8496
8651
|
_app: t,
|
|
8497
8652
|
_endpoints: r,
|
|
8498
8653
|
_isEmulator: o === "emulator",
|
|
8654
|
+
_storageRaw: n,
|
|
8655
|
+
_storageProcessed: p,
|
|
8499
8656
|
auth: s,
|
|
8500
8657
|
api: f,
|
|
8501
8658
|
projects: a,
|
|
8502
8659
|
profile: k,
|
|
8503
8660
|
privileges: E,
|
|
8504
|
-
cache:
|
|
8661
|
+
cache: I,
|
|
8662
|
+
storage: v
|
|
8505
8663
|
}), m;
|
|
8506
8664
|
}
|
|
8507
8665
|
/** Override in subclasses to provide a custom CueApi (e.g. with sync). */
|
|
8508
8666
|
_buildApi(t) {
|
|
8509
|
-
return new
|
|
8667
|
+
return new Dt(this.auth, this._endpoints.gatewayUrl, t);
|
|
8510
8668
|
}
|
|
8511
8669
|
/** Convenience: get the current user's Firebase ID token */
|
|
8512
8670
|
getToken(t = !1) {
|
|
@@ -8531,34 +8689,108 @@ class ae {
|
|
|
8531
8689
|
get: (r) => this.cache.getQueryCache(t, r).then((s) => s?.results),
|
|
8532
8690
|
set: (r, s) => this.cache.setQueryCache(t, r, { query: r, results: s })
|
|
8533
8691
|
};
|
|
8534
|
-
return new
|
|
8692
|
+
return new nr(this.api, t, { ...e, queryCache: o });
|
|
8693
|
+
}
|
|
8694
|
+
/**
|
|
8695
|
+
* Creates a `CueProjectEntities` instance for the given project, with the
|
|
8696
|
+
* SDK query cache wired automatically.
|
|
8697
|
+
*
|
|
8698
|
+
* Prefer this over `new CueProjectEntities(cue.api, projectId)` — it avoids
|
|
8699
|
+
* the manual cache setup and keeps the instance bound to the correct API.
|
|
8700
|
+
*
|
|
8701
|
+
* @example
|
|
8702
|
+
* ```ts
|
|
8703
|
+
* const entities = cue.createProjectEntities('my-project');
|
|
8704
|
+
* entities.requestEntityData(['uuid1']);
|
|
8705
|
+
* const info = entities.entityInfoMap.get()['uuid1'];
|
|
8706
|
+
*
|
|
8707
|
+
* // Promise-based (no signal polling needed):
|
|
8708
|
+
* const graph = await entities.buildSummaryGraph('graph');
|
|
8709
|
+
* ```
|
|
8710
|
+
*/
|
|
8711
|
+
createProjectEntities(t, e) {
|
|
8712
|
+
const o = e?.queryCache ?? {
|
|
8713
|
+
get: (r) => this.cache.getQueryCache(t, r).then((s) => s?.results),
|
|
8714
|
+
set: (r, s) => this.cache.setQueryCache(t, r, { query: r, results: s })
|
|
8715
|
+
};
|
|
8716
|
+
return new ce(
|
|
8717
|
+
this.api,
|
|
8718
|
+
t,
|
|
8719
|
+
e?.rdfBase,
|
|
8720
|
+
o,
|
|
8721
|
+
e?.graphType
|
|
8722
|
+
);
|
|
8723
|
+
}
|
|
8724
|
+
/**
|
|
8725
|
+
* Creates a `CueProjectDocuments` instance for the given project, with the
|
|
8726
|
+
* SDK query cache wired automatically.
|
|
8727
|
+
*
|
|
8728
|
+
* Prefer this over `new CueProjectDocuments(cue.api, projectId)` — it avoids
|
|
8729
|
+
* the manual cache setup and keeps the instance bound to the correct API.
|
|
8730
|
+
*
|
|
8731
|
+
* @example
|
|
8732
|
+
* ```ts
|
|
8733
|
+
* const docs = cue.createProjectDocuments('my-project');
|
|
8734
|
+
* await docs.fetchOverview();
|
|
8735
|
+
* const data = await docs.fetchDocumentData(['uuid1', 'uuid2']);
|
|
8736
|
+
* ```
|
|
8737
|
+
*/
|
|
8738
|
+
createProjectDocuments(t, e) {
|
|
8739
|
+
if (!(e?.language !== void 0 || e?.rdfBase !== void 0 || e?.graphType !== void 0 || e?.queryCache !== void 0)) {
|
|
8740
|
+
const s = this._projectDocuments.get(t);
|
|
8741
|
+
if (s)
|
|
8742
|
+
return s.setLanguage(this.api.language), s;
|
|
8743
|
+
const a = {
|
|
8744
|
+
get: (p) => this.cache.getQueryCache(t, p).then((c) => c?.results),
|
|
8745
|
+
set: (p, c) => this.cache.setQueryCache(t, p, { query: p, results: c })
|
|
8746
|
+
}, n = new pt(
|
|
8747
|
+
this.api,
|
|
8748
|
+
t,
|
|
8749
|
+
this.api.language,
|
|
8750
|
+
void 0,
|
|
8751
|
+
a,
|
|
8752
|
+
void 0
|
|
8753
|
+
);
|
|
8754
|
+
return this._projectDocuments.set(t, n), n;
|
|
8755
|
+
}
|
|
8756
|
+
const r = e?.queryCache ?? {
|
|
8757
|
+
get: (s) => this.cache.getQueryCache(t, s).then((a) => a?.results),
|
|
8758
|
+
set: (s, a) => this.cache.setQueryCache(t, s, { query: s, results: a })
|
|
8759
|
+
};
|
|
8760
|
+
return new pt(
|
|
8761
|
+
this.api,
|
|
8762
|
+
t,
|
|
8763
|
+
e?.language ?? this.api.language,
|
|
8764
|
+
e?.rdfBase,
|
|
8765
|
+
r,
|
|
8766
|
+
e?.graphType
|
|
8767
|
+
);
|
|
8535
8768
|
}
|
|
8536
8769
|
}
|
|
8537
8770
|
export {
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
|
|
8771
|
+
Je as B,
|
|
8772
|
+
he as C,
|
|
8773
|
+
Ft as R,
|
|
8774
|
+
Dt as a,
|
|
8775
|
+
Ot as b,
|
|
8776
|
+
Gt as c,
|
|
8777
|
+
or as d,
|
|
8778
|
+
Bt as e,
|
|
8779
|
+
Nt as f,
|
|
8780
|
+
pt as g,
|
|
8781
|
+
ce as h,
|
|
8782
|
+
ar as i,
|
|
8783
|
+
nr as j,
|
|
8784
|
+
zt as k,
|
|
8552
8785
|
x as l,
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
Ge as w
|
|
8786
|
+
Pt as m,
|
|
8787
|
+
fr as n,
|
|
8788
|
+
mo as o,
|
|
8789
|
+
Or as p,
|
|
8790
|
+
ct as q,
|
|
8791
|
+
to as r,
|
|
8792
|
+
ht as s,
|
|
8793
|
+
It as t,
|
|
8794
|
+
eo as u,
|
|
8795
|
+
Qe as v
|
|
8564
8796
|
};
|