@qaecy/cue-sdk 0.0.29 → 0.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -16
- package/{cue-CnZyGMRG.js → cue-DWCLcFvj.js} +283 -213
- package/index.js +1 -1
- package/lib/cue.d.ts +3 -0
- package/lib/documents.d.ts +38 -4
- package/lib/entities.d.ts +25 -7
- package/lib/models.d.ts +2 -0
- package/lib/project-view.d.ts +3 -1
- package/node.js +2 -2
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getApps as be, initializeApp as ve } from "firebase/app";
|
|
2
|
-
import { ref as _, getDownloadURL as K, getMetadata as
|
|
2
|
+
import { ref as _, getDownloadURL as K, getMetadata as z, getBlob as re, updateMetadata as _e, uploadBytesResumable as ft, uploadBytes as st, StringFormat as ke, uploadString as Ee, listAll as $, getStorage as S, connectStorageEmulator as X } from "firebase/storage";
|
|
3
3
|
import { Writer as xe, DataFactory as j } from "n3";
|
|
4
|
-
import { getFirestore as Ie, connectFirestoreEmulator as Ce, collection as yt, getDocs as
|
|
5
|
-
import { getAuth as qe, connectAuthEmulator as je, onIdTokenChanged as Ue, getIdTokenResult as at, signInWithEmailAndPassword as
|
|
4
|
+
import { getFirestore as Ie, connectFirestoreEmulator as Ce, collection as yt, getDocs as Se, query as Te, where as Re, limit as Ae, doc as bt, getDoc as Pe, setDoc as Oe, serverTimestamp as De, increment as Le } from "firebase/firestore";
|
|
5
|
+
import { getAuth as qe, connectAuthEmulator as je, onIdTokenChanged as Ue, getIdTokenResult as at, signInWithEmailAndPassword as ze, GoogleAuthProvider as it, OAuthProvider as nt, signInWithPopup as $e, signInWithRedirect as Me, getRedirectResult as Ne, signInWithCustomToken as vt, signOut as Fe, onAuthStateChanged as Be, fetchSignInMethodsForEmail as Ge, linkWithPopup as He, unlink as We, reauthenticateWithCredential as _t, EmailAuthProvider as Q, updatePassword as Ve, linkWithCredential as Ke, verifyBeforeUpdateEmail as Xe, sendEmailVerification as Qe } from "firebase/auth";
|
|
6
6
|
import { v5 as Ye } from "uuid";
|
|
7
7
|
import "spark-md5";
|
|
8
8
|
import { getFunctions as se, connectFunctionsEmulator as ae, httpsCallable as F } from "firebase/functions";
|
|
@@ -342,7 +342,7 @@ class kt {
|
|
|
342
342
|
if (this._knownMissing.has(o)) return;
|
|
343
343
|
const r = _(this._bucket(t), e);
|
|
344
344
|
try {
|
|
345
|
-
const s = await
|
|
345
|
+
const s = await z(r);
|
|
346
346
|
return `${await K(r)}&t=${encodeURIComponent(s.updated)}`;
|
|
347
347
|
} catch (s) {
|
|
348
348
|
if (s?.code === "storage/object-not-found" || s?.status === 404) {
|
|
@@ -383,7 +383,7 @@ class kt {
|
|
|
383
383
|
try {
|
|
384
384
|
const [a, n] = await Promise.all([
|
|
385
385
|
s(K(e)),
|
|
386
|
-
s(
|
|
386
|
+
s(z(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}`);
|
|
389
389
|
return c.text();
|
|
@@ -399,7 +399,7 @@ class kt {
|
|
|
399
399
|
async getMetadata(t, e) {
|
|
400
400
|
const o = _(this._bucket(t), e);
|
|
401
401
|
try {
|
|
402
|
-
const r = await
|
|
402
|
+
const r = await z(o);
|
|
403
403
|
return {
|
|
404
404
|
updated: r.updated,
|
|
405
405
|
contentType: r.contentType,
|
|
@@ -454,7 +454,7 @@ class kt {
|
|
|
454
454
|
/** List all item names directly under `prefix` in the given bucket. */
|
|
455
455
|
async listFiles(t, e) {
|
|
456
456
|
const o = _(this._bucket(t), e);
|
|
457
|
-
return (await
|
|
457
|
+
return (await $(o)).items.map((s) => s.name);
|
|
458
458
|
}
|
|
459
459
|
/**
|
|
460
460
|
* Recursively list all file full-paths under `prefix` in the given bucket.
|
|
@@ -462,7 +462,7 @@ class kt {
|
|
|
462
462
|
*/
|
|
463
463
|
async listFilesRecursive(t, e) {
|
|
464
464
|
const o = this._bucket(t), r = async (s) => {
|
|
465
|
-
const a = await
|
|
465
|
+
const a = await $(_(o, s));
|
|
466
466
|
let n = a.items.map((p) => p.fullPath);
|
|
467
467
|
for (const p of a.prefixes)
|
|
468
468
|
n = n.concat(await r(p.fullPath));
|
|
@@ -478,7 +478,7 @@ class kt {
|
|
|
478
478
|
const { deleteObject: o } = await import("firebase/storage"), r = this._bucket(t);
|
|
479
479
|
let s = 0;
|
|
480
480
|
const a = async (n) => {
|
|
481
|
-
const p = await
|
|
481
|
+
const p = await $(_(r, n));
|
|
482
482
|
for (const c of p.items)
|
|
483
483
|
await o(c), s++;
|
|
484
484
|
for (const c of p.prefixes)
|
|
@@ -499,22 +499,22 @@ class kt {
|
|
|
499
499
|
d(new DOMException("Upload cancelled", "AbortError"));
|
|
500
500
|
return;
|
|
501
501
|
}
|
|
502
|
-
const g = ft(n, e, { customMetadata: o }),
|
|
502
|
+
const g = ft(n, e, { customMetadata: o }), u = () => {
|
|
503
503
|
g.cancel(), d(new DOMException("Upload cancelled", "AbortError"));
|
|
504
504
|
};
|
|
505
|
-
s?.addEventListener("abort",
|
|
505
|
+
s?.addEventListener("abort", u, { once: !0 }), g.on(
|
|
506
506
|
"state_changed",
|
|
507
|
-
(
|
|
507
|
+
(m) => {
|
|
508
508
|
if (a) {
|
|
509
|
-
const f = Math.round(
|
|
509
|
+
const f = Math.round(m.bytesTransferred / m.totalBytes * 100);
|
|
510
510
|
a(f);
|
|
511
511
|
}
|
|
512
512
|
},
|
|
513
|
-
(
|
|
514
|
-
s?.removeEventListener("abort",
|
|
513
|
+
(m) => {
|
|
514
|
+
s?.removeEventListener("abort", u), d(m);
|
|
515
515
|
},
|
|
516
516
|
() => {
|
|
517
|
-
s?.removeEventListener("abort",
|
|
517
|
+
s?.removeEventListener("abort", u), h();
|
|
518
518
|
}
|
|
519
519
|
);
|
|
520
520
|
});
|
|
@@ -532,12 +532,12 @@ class kt {
|
|
|
532
532
|
*/
|
|
533
533
|
async uploadProcessed(t, e, o) {
|
|
534
534
|
const r = _(this.options.storageProcessed, t);
|
|
535
|
-
return await
|
|
535
|
+
return await z(r).catch(() => null) ? !1 : (await st(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) {
|
|
539
539
|
const e = _(this.options.storageRaw, t);
|
|
540
|
-
return (await
|
|
540
|
+
return (await $(e)).items.map((r) => r.name);
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
543
|
const Et = {
|
|
@@ -646,7 +646,7 @@ const Z = {
|
|
|
646
646
|
apiKey: "AIzaSyAiW42QBx9HS4Khu88pCW7MV66IhBAQul0",
|
|
647
647
|
appId: "1:151132927589:web:d2ffdb377dfadfd23ab88c",
|
|
648
648
|
measurementId: "G-YT4PK6HGZD"
|
|
649
|
-
}, xt = "qaecy-mvp-406413", oo = "734737865998", ie = "europe-west6", It = "projects", Ct = "spaces_chats_eu_west6",
|
|
649
|
+
}, xt = "qaecy-mvp-406413", oo = "734737865998", ie = "europe-west6", It = "projects", Ct = "spaces_chats_eu_west6", St = "spaces_raw_eu_west6", Tt = "spaces_processed_eu_west6", Rt = "spaces_logs_eu_west6", At = "cue_public_eu_west6", Pt = "db_persistence_eu_west6", ro = "/data-views/admin/consumption", so = "/data-views/admin/profile/organizations", Ot = "/data-views/admin/profile/api-keys", Dt = "/commands/admin/profile/api-keys", ao = "/commands/admin/profile/terms", io = (i) => `/data-views/admin/organizations/${i}/members`, no = "/commands/admin/project", po = (i) => `/commands/admin/project/${i}`, lo = "/assistant/search", ne = "/triplestore/query", co = "/triplestore/update", ho = "/triplestore/shacl", pe = "/qlever-server/qlever/query", go = "/qlever-server/qlever/update", uo = "/qlever-server/qlever/shacl", Lt = "/commands/file-system-structure/batch", qt = "microsoft.com", jt = "superadmin", ut = "https://cue.qaecy.com/r/";
|
|
650
650
|
class Ut {
|
|
651
651
|
_auth;
|
|
652
652
|
_endpoints;
|
|
@@ -689,14 +689,14 @@ class Ut {
|
|
|
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 ze(
|
|
693
693
|
this._auth,
|
|
694
694
|
e.email,
|
|
695
695
|
e.password
|
|
696
696
|
)).user;
|
|
697
697
|
}
|
|
698
698
|
const o = t === "google" ? new it() : new nt(qt);
|
|
699
|
-
return (await
|
|
699
|
+
return (await $e(this._auth, o)).user;
|
|
700
700
|
}
|
|
701
701
|
/**
|
|
702
702
|
* Initiate a redirect-based sign-in (mobile / iframe contexts where popups
|
|
@@ -705,7 +705,7 @@ class Ut {
|
|
|
705
705
|
*/
|
|
706
706
|
async signInWithRedirect(t) {
|
|
707
707
|
const e = t === "google" ? new it() : new nt(qt);
|
|
708
|
-
await
|
|
708
|
+
await Me(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 Ut {
|
|
|
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 Ne(this._auth))?.user ?? null;
|
|
717
717
|
}
|
|
718
718
|
/**
|
|
719
719
|
* One-shot async check — returns `true` if the current user has the
|
|
@@ -805,7 +805,7 @@ class Ut {
|
|
|
805
805
|
return this._auth;
|
|
806
806
|
}
|
|
807
807
|
}
|
|
808
|
-
class
|
|
808
|
+
class zt {
|
|
809
809
|
constructor(t) {
|
|
810
810
|
this._blob = t;
|
|
811
811
|
}
|
|
@@ -919,7 +919,7 @@ class bo {
|
|
|
919
919
|
return { jsonld: await r.json() };
|
|
920
920
|
}
|
|
921
921
|
}
|
|
922
|
-
class
|
|
922
|
+
class $t {
|
|
923
923
|
constructor(t, e, o, r) {
|
|
924
924
|
this._auth = t, this._gatewayUrl = e, this.projects = o, this.sync = r, this.tables = new fo(t, e), this.extraction = new bo(t, e);
|
|
925
925
|
}
|
|
@@ -1146,7 +1146,7 @@ const pt = [
|
|
|
1146
1146
|
preferredColor: "#db2777"
|
|
1147
1147
|
}
|
|
1148
1148
|
};
|
|
1149
|
-
function
|
|
1149
|
+
function T(i) {
|
|
1150
1150
|
return vo[i];
|
|
1151
1151
|
}
|
|
1152
1152
|
const _o = {
|
|
@@ -1177,7 +1177,7 @@ const _o = {
|
|
|
1177
1177
|
"nature-landscape-plan": "#16a34a"
|
|
1178
1178
|
// dark-green – Natur- und Landschaftsschutz
|
|
1179
1179
|
};
|
|
1180
|
-
function
|
|
1180
|
+
function M(i, t) {
|
|
1181
1181
|
return i[0] < t[2] && i[2] > t[0] && i[1] < t[3] && i[3] > t[1];
|
|
1182
1182
|
}
|
|
1183
1183
|
const ko = "https://nominatim.openstreetmap.org", Eo = "cue-gis/0.0.1", xo = {
|
|
@@ -1196,7 +1196,7 @@ function B(i) {
|
|
|
1196
1196
|
return `${L}:${i}`;
|
|
1197
1197
|
}
|
|
1198
1198
|
function Io(i) {
|
|
1199
|
-
const t =
|
|
1199
|
+
const t = T(i);
|
|
1200
1200
|
return {
|
|
1201
1201
|
id: B(i),
|
|
1202
1202
|
sourceId: L,
|
|
@@ -1226,7 +1226,7 @@ class Co {
|
|
|
1226
1226
|
})
|
|
1227
1227
|
)).filter(
|
|
1228
1228
|
(o) => o.status === "fulfilled" && o.value.hasResults
|
|
1229
|
-
).map((o) =>
|
|
1229
|
+
).map((o) => T(o.value.category));
|
|
1230
1230
|
}
|
|
1231
1231
|
async listAvailableLayers(t) {
|
|
1232
1232
|
return (await this.listFeatureCategoryDescriptors(t)).map((o) => Io(o.category));
|
|
@@ -1270,7 +1270,7 @@ class Co {
|
|
|
1270
1270
|
return (await h.json()).map((g) => this.toGisFeature(g, e));
|
|
1271
1271
|
}
|
|
1272
1272
|
toGisFeature(t, e) {
|
|
1273
|
-
const [o, r, s, a] = t.boundingbox, n = e ?? t.category, p =
|
|
1273
|
+
const [o, r, s, a] = t.boundingbox, n = e ?? t.category, p = T(n);
|
|
1274
1274
|
return {
|
|
1275
1275
|
id: `${t.osm_type}/${t.osm_id}`,
|
|
1276
1276
|
sourceId: L,
|
|
@@ -1289,7 +1289,7 @@ class Co {
|
|
|
1289
1289
|
};
|
|
1290
1290
|
}
|
|
1291
1291
|
}
|
|
1292
|
-
const
|
|
1292
|
+
const Mt = {
|
|
1293
1293
|
// 100s – Residential
|
|
1294
1294
|
110: "residential",
|
|
1295
1295
|
120: "residential",
|
|
@@ -1368,7 +1368,7 @@ const Nt = {
|
|
|
1368
1368
|
960: "agricultural",
|
|
1369
1369
|
970: "agricultural",
|
|
1370
1370
|
990: "other"
|
|
1371
|
-
},
|
|
1371
|
+
}, Nt = {
|
|
1372
1372
|
1010: "residential",
|
|
1373
1373
|
1020: "mixed",
|
|
1374
1374
|
1030: "residential",
|
|
@@ -1398,7 +1398,7 @@ const Nt = {
|
|
|
1398
1398
|
1281: "infrastructure",
|
|
1399
1399
|
1282: "infrastructure",
|
|
1400
1400
|
9999: "other"
|
|
1401
|
-
},
|
|
1401
|
+
}, So = {
|
|
1402
1402
|
// Residential
|
|
1403
1403
|
1110: "residential",
|
|
1404
1404
|
// Einfamilienhaus
|
|
@@ -1460,7 +1460,7 @@ const Nt = {
|
|
|
1460
1460
|
// Empfangsgebäude Bahn/Bus
|
|
1461
1461
|
1282: "infrastructure"
|
|
1462
1462
|
// Parkhaus, Garage
|
|
1463
|
-
},
|
|
1463
|
+
}, To = [
|
|
1464
1464
|
// "Gebäude" is the Swiss AV BoFlaeche land-cover label for a building footprint.
|
|
1465
1465
|
// It does not encode the actual use type, so map it to 'other' as a safe fallback.
|
|
1466
1466
|
[/^geb[äa]ude$/i, "other"],
|
|
@@ -1474,13 +1474,13 @@ const Nt = {
|
|
|
1474
1474
|
[/gemischt|mixed|blandet/i, "mixed"]
|
|
1475
1475
|
];
|
|
1476
1476
|
function O(i) {
|
|
1477
|
-
for (const [t, e] of
|
|
1477
|
+
for (const [t, e] of To)
|
|
1478
1478
|
if (t.test(i)) return e;
|
|
1479
1479
|
}
|
|
1480
1480
|
function Ro(i, t) {
|
|
1481
1481
|
if (i == null) return;
|
|
1482
1482
|
const e = String(i).trim();
|
|
1483
|
-
return t === "swiss-gwr" ?
|
|
1483
|
+
return t === "swiss-gwr" ? So[e] ?? O(e) : t === "danish-matrikel" ? Mt[e] ?? O(e) : t === "zurich-wfs" || t === "swiss-av-wfs" ? Nt[e] ?? O(e) : Nt[e] ?? Mt[e] ?? O(e);
|
|
1484
1484
|
}
|
|
1485
1485
|
function Ao(i, t) {
|
|
1486
1486
|
if (i != null)
|
|
@@ -1641,20 +1641,20 @@ function Uo(i) {
|
|
|
1641
1641
|
return [0, 0];
|
|
1642
1642
|
}
|
|
1643
1643
|
}
|
|
1644
|
-
function
|
|
1644
|
+
function zo(i, t) {
|
|
1645
1645
|
if (!i) return t;
|
|
1646
1646
|
for (const e of ["plannavn", "bezeichnung", "name", "strassenname", "objektname", "title", "label"])
|
|
1647
1647
|
if (typeof i[e] == "string" && i[e]) return i[e];
|
|
1648
1648
|
return t;
|
|
1649
1649
|
}
|
|
1650
|
-
function
|
|
1650
|
+
function $o(i, t, e) {
|
|
1651
1651
|
return e ? `${i}:${t}[${e}]` : `${i}:${t}`;
|
|
1652
1652
|
}
|
|
1653
|
-
const
|
|
1653
|
+
const Mo = /* @__PURE__ */ new Set(["building", "cadastre", "greenspace", "paved", "zone"]);
|
|
1654
1654
|
function et(i, t, e, o) {
|
|
1655
|
-
const r = e.replace(/^ms:/, ""), s =
|
|
1655
|
+
const r = e.replace(/^ms:/, ""), s = T(t), a = Mo.has(t) ? "priority" : "raw";
|
|
1656
1656
|
return {
|
|
1657
|
-
id:
|
|
1657
|
+
id: $o(i, e, o),
|
|
1658
1658
|
sourceId: i,
|
|
1659
1659
|
sourceLayerId: e,
|
|
1660
1660
|
category: t,
|
|
@@ -1666,7 +1666,7 @@ function et(i, t, e, o) {
|
|
|
1666
1666
|
descriptionKey: `gis.layer.${i}.${r}.description`
|
|
1667
1667
|
};
|
|
1668
1668
|
}
|
|
1669
|
-
function
|
|
1669
|
+
function No(i, t) {
|
|
1670
1670
|
if (!i) return { featureType: "building" };
|
|
1671
1671
|
const e = i.grundflaeche ?? i.gbf ?? i.gebaeudegrundrissflaeche ?? i.flaeche ?? void 0, o = i.vollgeschosse ?? i.geschossanzahl ?? i.anzahl_geschosse ?? void 0, r = i.gebaeudefunktion ?? i.gfkode ?? i.art ?? i.objektart ?? void 0, s = i.baujahr ?? i.bauperiode ?? void 0, a = String(i.egid ?? i.gwr_egid ?? i.egris_egid ?? "").trim() || void 0;
|
|
1672
1672
|
return {
|
|
@@ -1711,7 +1711,7 @@ function Go(i) {
|
|
|
1711
1711
|
}
|
|
1712
1712
|
function Ho(i) {
|
|
1713
1713
|
if (!i) return { featureType: "zone" };
|
|
1714
|
-
const t = i.plannavn ?? i.bezeichnung ?? i.typ_bezeichnung ?? i.art ?? void 0, e = i.planid ?? i.plannummer ?? void 0, o = i.artcode ?? i.typ_code ?? i.abkuerzung ?? e ?? void 0, r = i.rechtsstatus ?? i.status ?? void 0, s = he(r), a = i.typ_gde_bezeichnung ?? void 0, n = de(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,
|
|
1714
|
+
const t = i.plannavn ?? i.bezeichnung ?? i.typ_bezeichnung ?? i.art ?? void 0, e = i.planid ?? i.plannummer ?? void 0, o = i.artcode ?? i.typ_code ?? i.abkuerzung ?? e ?? void 0, r = i.rechtsstatus ?? i.status ?? void 0, s = he(r), a = i.typ_gde_bezeichnung ?? void 0, n = de(a), p = i.dagsordenpunkt_url ?? i.dokument_url ?? i.link ?? void 0, c = i.auflagedatum ?? void 0, h = i.festsetzungsdatum ?? void 0, d = i.genehmigungsdatum ?? void 0, g = i.inkraftsetzungsdatum ?? void 0, u = i.flaeche ?? i.flaeche_m2 ?? void 0;
|
|
1715
1715
|
return {
|
|
1716
1716
|
featureType: "zone",
|
|
1717
1717
|
zoneType: t ? String(t) : void 0,
|
|
@@ -1724,7 +1724,7 @@ function Ho(i) {
|
|
|
1724
1724
|
fixingDate: h ?? void 0,
|
|
1725
1725
|
approvalDate: d ?? void 0,
|
|
1726
1726
|
effectiveFrom: g ?? void 0,
|
|
1727
|
-
areaM2: typeof
|
|
1727
|
+
areaM2: typeof u == "number" ? u : void 0
|
|
1728
1728
|
};
|
|
1729
1729
|
}
|
|
1730
1730
|
function Wo(i) {
|
|
@@ -1752,7 +1752,7 @@ class ot {
|
|
|
1752
1752
|
}
|
|
1753
1753
|
async listFeatureCategoryDescriptors(t) {
|
|
1754
1754
|
const e = await this.listAvailableLayers(t);
|
|
1755
|
-
return [...new Map(e.map((o) => [o.category,
|
|
1755
|
+
return [...new Map(e.map((o) => [o.category, T(o.category)])).values()];
|
|
1756
1756
|
}
|
|
1757
1757
|
async listAvailableLayers(t) {
|
|
1758
1758
|
const e = Object.entries(this.categoryMap);
|
|
@@ -1821,7 +1821,7 @@ class ot {
|
|
|
1821
1821
|
return g.json();
|
|
1822
1822
|
}
|
|
1823
1823
|
toGisFeature(t, e, o) {
|
|
1824
|
-
const [r, s] = Uo(t.geometry), a =
|
|
1824
|
+
const [r, s] = Uo(t.geometry), a = zo(t.properties, `${e.sourceLayerId}[${o}]`), n = t.bbox ? [t.bbox[0], t.bbox[1], t.bbox[2], t.bbox[3]] : void 0, p = e.tier, c = p === "priority" ? this._extractNormalisedProperties(t, e) : void 0;
|
|
1825
1825
|
return {
|
|
1826
1826
|
id: t.id ?? `${e.sourceLayerId}/${o}`,
|
|
1827
1827
|
preferredColor: e.preferredColor,
|
|
@@ -1842,7 +1842,7 @@ class ot {
|
|
|
1842
1842
|
};
|
|
1843
1843
|
}
|
|
1844
1844
|
_extractNormalisedProperties(t, e) {
|
|
1845
|
-
return e.category === "building" ?
|
|
1845
|
+
return e.category === "building" ? No(t.properties, this.sourceId) : e.category === "greenspace" ? Bo(t.properties) : e.category === "paved" ? Go(t.properties) : e.category === "zone" ? Ho(t.properties) : Fo(t.properties, this.sourceId);
|
|
1846
1846
|
}
|
|
1847
1847
|
}
|
|
1848
1848
|
const ge = [8, 54.5, 15.2, 57.8], ue = {
|
|
@@ -1888,14 +1888,14 @@ function Ko(i, t) {
|
|
|
1888
1888
|
if (typeof i[e] == "string" && i[e]) return i[e];
|
|
1889
1889
|
return t;
|
|
1890
1890
|
}
|
|
1891
|
-
function
|
|
1891
|
+
function Xo(i, t, e) {
|
|
1892
1892
|
return `${i}:${t}:${e}`;
|
|
1893
1893
|
}
|
|
1894
|
-
const
|
|
1894
|
+
const Qo = /* @__PURE__ */ new Set(["building", "cadastre", "zone"]);
|
|
1895
1895
|
function rt(i, t, e) {
|
|
1896
|
-
const o = e.typename.replace(/^[^:]+:/, ""), r =
|
|
1896
|
+
const o = e.typename.replace(/^[^:]+:/, ""), r = T(t), s = Qo.has(t) ? "priority" : "raw";
|
|
1897
1897
|
return {
|
|
1898
|
-
id:
|
|
1898
|
+
id: Xo(i, e.source, e.typename),
|
|
1899
1899
|
sourceId: i,
|
|
1900
1900
|
sourceLayerId: e.typename,
|
|
1901
1901
|
category: t,
|
|
@@ -1955,7 +1955,7 @@ class Zo {
|
|
|
1955
1955
|
const e = await this.listAvailableLayers(t);
|
|
1956
1956
|
return [
|
|
1957
1957
|
...new Map(
|
|
1958
|
-
e.map((o) => [o.category,
|
|
1958
|
+
e.map((o) => [o.category, T(o.category)])
|
|
1959
1959
|
).values()
|
|
1960
1960
|
];
|
|
1961
1961
|
}
|
|
@@ -2174,14 +2174,14 @@ class tr {
|
|
|
2174
2174
|
* @param bbox [west, south, east, north] in WGS-84 decimal degrees
|
|
2175
2175
|
*/
|
|
2176
2176
|
async listFeatureCategoryDescriptors(t) {
|
|
2177
|
-
const e = this.regions.filter((r) =>
|
|
2177
|
+
const e = this.regions.filter((r) => M(r.coverageBBox, t) && r.supportedCategories).sort((r, s) => (s.priority ?? 0) - (r.priority ?? 0));
|
|
2178
2178
|
if (e.length > 0) {
|
|
2179
2179
|
const r = /* @__PURE__ */ new Set(), s = [];
|
|
2180
2180
|
for (const a of e)
|
|
2181
2181
|
for (const n of a.supportedCategories ?? [])
|
|
2182
|
-
r.has(n) || (r.add(n), s.push(
|
|
2182
|
+
r.has(n) || (r.add(n), s.push(T(n)));
|
|
2183
2183
|
for (const a of le)
|
|
2184
|
-
r.has(a) || s.push(
|
|
2184
|
+
r.has(a) || s.push(T(a));
|
|
2185
2185
|
return Bt(s);
|
|
2186
2186
|
}
|
|
2187
2187
|
const o = await this._adapterFor(t).listFeatureCategoryDescriptors(t);
|
|
@@ -2235,7 +2235,7 @@ class tr {
|
|
|
2235
2235
|
console.log(" • Nominatim (OSM) bbox=[global] priority=-1");
|
|
2236
2236
|
const r = [
|
|
2237
2237
|
...this.regions.filter(
|
|
2238
|
-
(n) =>
|
|
2238
|
+
(n) => M(n.coverageBBox, t) && (!n.supportedCategories || n.supportedCategories.includes(e))
|
|
2239
2239
|
).map((n) => ({
|
|
2240
2240
|
name: n.name,
|
|
2241
2241
|
adapter: n.adapter,
|
|
@@ -2279,7 +2279,7 @@ class tr {
|
|
|
2279
2279
|
async getFeaturesOfCategory(t, e) {
|
|
2280
2280
|
const r = [
|
|
2281
2281
|
...this.regions.filter(
|
|
2282
|
-
(d) =>
|
|
2282
|
+
(d) => M(d.coverageBBox, t) && (!d.supportedCategories || d.supportedCategories.includes(e))
|
|
2283
2283
|
).map((d) => ({ name: d.name, adapter: d.adapter, isNominatim: !1 })),
|
|
2284
2284
|
{ name: "Nominatim (OSM)", adapter: this.nominatim, isNominatim: !0 }
|
|
2285
2285
|
], s = await Promise.allSettled(
|
|
@@ -2294,8 +2294,8 @@ class tr {
|
|
|
2294
2294
|
d.status === "fulfilled" && (d.value.isNominatim ? n.push(...d.value.features) : a.push(...d.value.features));
|
|
2295
2295
|
const p = rr(a, n), c = /* @__PURE__ */ new Map(), h = [];
|
|
2296
2296
|
for (const d of p) {
|
|
2297
|
-
const g = Gt(d),
|
|
2298
|
-
(
|
|
2297
|
+
const g = Gt(d), u = W(d), m = c.get(g);
|
|
2298
|
+
(m === void 0 || u > m) && (c.set(g, u), h.push(d));
|
|
2299
2299
|
}
|
|
2300
2300
|
return h;
|
|
2301
2301
|
}
|
|
@@ -2305,7 +2305,7 @@ class tr {
|
|
|
2305
2305
|
}
|
|
2306
2306
|
/** Resolve the best adapter for a query bbox (legacy single-adapter routing). */
|
|
2307
2307
|
_adapterFor(t) {
|
|
2308
|
-
return this.regions.filter((o) =>
|
|
2308
|
+
return this.regions.filter((o) => M(o.coverageBBox, t)).sort((o, r) => (r.priority ?? 0) - (o.priority ?? 0))[0]?.adapter ?? this.nominatim;
|
|
2309
2309
|
}
|
|
2310
2310
|
}
|
|
2311
2311
|
function W(i) {
|
|
@@ -2525,7 +2525,7 @@ class Ht {
|
|
|
2525
2525
|
*/
|
|
2526
2526
|
async listProjects() {
|
|
2527
2527
|
const t = this._requireUser(), e = yt(this._db, It);
|
|
2528
|
-
return (await Te(
|
|
2528
|
+
return (await Se(Te(e, Re("members", "array-contains", t), Ae(100)))).docs.map((r) => r.data());
|
|
2529
2529
|
}
|
|
2530
2530
|
/** Fetch a single project by ID. Returns null if not found. */
|
|
2531
2531
|
async getProject(t) {
|
|
@@ -2626,14 +2626,14 @@ class Wt {
|
|
|
2626
2626
|
if (!o.email) throw new Error("User has no e-mail");
|
|
2627
2627
|
await _t(
|
|
2628
2628
|
o,
|
|
2629
|
-
|
|
2629
|
+
Q.credential(o.email, t)
|
|
2630
2630
|
), await Ve(o, e);
|
|
2631
2631
|
}
|
|
2632
2632
|
/** Adds (sets) a password for an account that currently only uses SSO. */
|
|
2633
2633
|
async addPassword(t) {
|
|
2634
2634
|
const e = this._requireUser();
|
|
2635
2635
|
if (!e.email) throw new Error("User has no e-mail");
|
|
2636
|
-
await Ke(e,
|
|
2636
|
+
await Ke(e, Q.credential(e.email, t));
|
|
2637
2637
|
}
|
|
2638
2638
|
/** Requests an e-mail change. Sends a verification e-mail to the new address. */
|
|
2639
2639
|
async updateEmail(t, e) {
|
|
@@ -2641,8 +2641,8 @@ class Wt {
|
|
|
2641
2641
|
if (!o.email) throw new Error("User e-mail not available");
|
|
2642
2642
|
await _t(
|
|
2643
2643
|
o,
|
|
2644
|
-
|
|
2645
|
-
), await
|
|
2644
|
+
Q.credential(o.email, e)
|
|
2645
|
+
), await Xe(o, t), await Qe(o);
|
|
2646
2646
|
}
|
|
2647
2647
|
/** Creates a new API key for the current user. */
|
|
2648
2648
|
async createAPIKey(t) {
|
|
@@ -2741,7 +2741,7 @@ function nr() {
|
|
|
2741
2741
|
viewEntities: !1
|
|
2742
2742
|
};
|
|
2743
2743
|
}
|
|
2744
|
-
class
|
|
2744
|
+
class Xt {
|
|
2745
2745
|
constructor(t) {
|
|
2746
2746
|
this._isSuperAdmin = t, this._projectRoles = new k([]), this._orgRole = new k(null), this.privileges = dt(
|
|
2747
2747
|
[this._projectRoles, this._orgRole, t],
|
|
@@ -2790,7 +2790,7 @@ class Qt {
|
|
|
2790
2790
|
return o.createProject = e || this._orgRole.get() === "admin", o;
|
|
2791
2791
|
}
|
|
2792
2792
|
}
|
|
2793
|
-
class
|
|
2793
|
+
class Qt {
|
|
2794
2794
|
constructor(t) {
|
|
2795
2795
|
this._storage = t;
|
|
2796
2796
|
}
|
|
@@ -2829,10 +2829,10 @@ class Xt {
|
|
|
2829
2829
|
let c = await n.read();
|
|
2830
2830
|
for (; !c.done; )
|
|
2831
2831
|
p.push(c.value), c = await n.read();
|
|
2832
|
-
const h = p.reduce((
|
|
2832
|
+
const h = p.reduce((u, m) => u + m.length, 0), d = new Uint8Array(h);
|
|
2833
2833
|
let g = 0;
|
|
2834
|
-
for (const
|
|
2835
|
-
d.set(
|
|
2834
|
+
for (const u of p)
|
|
2835
|
+
d.set(u, g), g += u.length;
|
|
2836
2836
|
return JSON.parse(new TextDecoder().decode(d));
|
|
2837
2837
|
} catch (o) {
|
|
2838
2838
|
if (pr(o)) return;
|
|
@@ -2846,10 +2846,10 @@ class Xt {
|
|
|
2846
2846
|
let c = await n.read();
|
|
2847
2847
|
for (; !c.done; )
|
|
2848
2848
|
p.push(c.value), c = await n.read();
|
|
2849
|
-
const h = p.reduce((
|
|
2849
|
+
const h = p.reduce((u, m) => u + m.length, 0), d = new Uint8Array(h);
|
|
2850
2850
|
let g = 0;
|
|
2851
|
-
for (const
|
|
2852
|
-
d.set(
|
|
2851
|
+
for (const u of p)
|
|
2852
|
+
d.set(u, g), g += u.length;
|
|
2853
2853
|
await st(
|
|
2854
2854
|
_(this._storage, `${t}/${e}.json.gz`),
|
|
2855
2855
|
d,
|
|
@@ -6270,15 +6270,16 @@ GROUP BY ?iri ?parent`;
|
|
|
6270
6270
|
}
|
|
6271
6271
|
const cr = "https://qlever.dev/api/osm-planet";
|
|
6272
6272
|
class we {
|
|
6273
|
-
constructor(t, e, o = ut, r, s) {
|
|
6274
|
-
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(
|
|
6275
|
-
(
|
|
6273
|
+
constructor(t, e, o = ut, r, s, a = !1) {
|
|
6274
|
+
this._api = t, this._projectId = e, this._queryCache = r, this._graphType = s, this._verbose = a, this.baseURL = `${o}${e}/`, this.entityInfoMap = this._entityInfoMapComputed, this.entityGraph = this._entityGraph.asReadonly(), this._entityOSMMap.subscribe(() => this._checkPendingOSMFetches()), this._fetchEntityGraph().catch(
|
|
6275
|
+
(n) => console.error("[CueProjectEntities] Entity graph fetch failed:", n)
|
|
6276
6276
|
);
|
|
6277
6277
|
}
|
|
6278
6278
|
_api;
|
|
6279
6279
|
_projectId;
|
|
6280
6280
|
_queryCache;
|
|
6281
6281
|
_graphType;
|
|
6282
|
+
_verbose;
|
|
6282
6283
|
/** Full RDF base URL for this project, e.g. `https://cue.qaecy.com/r/{pid}/` */
|
|
6283
6284
|
baseURL;
|
|
6284
6285
|
// ── Internal writable slices ───────────────────────────────────────────────
|
|
@@ -6290,6 +6291,8 @@ class we {
|
|
|
6290
6291
|
_entityOSMMap = new k({});
|
|
6291
6292
|
_osmWKTMap = new k({});
|
|
6292
6293
|
_fetchingOSMIds = /* @__PURE__ */ new Set();
|
|
6294
|
+
/** Cumulative unique entity UUIDs ever passed to request methods (survives cache hits). */
|
|
6295
|
+
_seenIds = /* @__PURE__ */ new Set();
|
|
6293
6296
|
_entityGraph = new k(void 0);
|
|
6294
6297
|
// ── Derived signals ────────────────────────────────────────────────────────
|
|
6295
6298
|
_entityInfoMapComputed = dt(
|
|
@@ -6314,12 +6317,19 @@ class we {
|
|
|
6314
6317
|
entityIri(t) {
|
|
6315
6318
|
return `${this.baseURL}${t}`;
|
|
6316
6319
|
}
|
|
6320
|
+
/** @internal Builds a full resource IRI from a UUID without a SPARQL round-trip. */
|
|
6321
|
+
_resourceIri(t) {
|
|
6322
|
+
return `${this.baseURL}${t}`;
|
|
6323
|
+
}
|
|
6324
|
+
_log(t) {
|
|
6325
|
+
this._verbose && console.debug(`[CueProjectEntities pid=${this._projectId}] ${t}`);
|
|
6326
|
+
}
|
|
6317
6327
|
/**
|
|
6318
6328
|
* Resets all entity state and re-fetches the entity graph.
|
|
6319
6329
|
* Call when the active project changes.
|
|
6320
6330
|
*/
|
|
6321
6331
|
reset() {
|
|
6322
|
-
this._entityDetails.set({}), this._entityDocuments.set({}), this._entityRelationships.set({}), this._entityOSMMap.set({}), this._osmWKTMap.set({}), this._entityGraph.set(void 0), this._fetchingOSMIds.clear(), this._fetchEntityGraph().catch(
|
|
6332
|
+
this._entityDetails.set({}), this._entityDocuments.set({}), this._entityRelationships.set({}), this._entityOSMMap.set({}), this._osmWKTMap.set({}), this._entityGraph.set(void 0), this._fetchingOSMIds.clear(), this._seenIds.clear(), this._fetchEntityGraph().catch(
|
|
6323
6333
|
(t) => console.error(
|
|
6324
6334
|
"[CueProjectEntities] Entity graph fetch failed after reset:",
|
|
6325
6335
|
t
|
|
@@ -6334,10 +6344,12 @@ class we {
|
|
|
6334
6344
|
* Data is merged into `entityInfoMap` once the SPARQL response arrives.
|
|
6335
6345
|
*/
|
|
6336
6346
|
requestEntityData(t, e = !1) {
|
|
6347
|
+
for (const a of t) this._seenIds.add(a);
|
|
6337
6348
|
const o = t.filter(
|
|
6338
6349
|
(a) => this._entityDetails.get()[a] === void 0
|
|
6339
6350
|
);
|
|
6340
6351
|
if (o.length === 0) return;
|
|
6352
|
+
this._log(`requestEntityData: ${o.length} new / ${t.length} requested | cumulative: ${this._seenIds.size} seen`);
|
|
6341
6353
|
const r = o.map((a) => `r:${a}`).join(" "), s = `PREFIX qcy: <${y.qcy}>
|
|
6342
6354
|
PREFIX r: <${this.baseURL}>
|
|
6343
6355
|
SELECT ?id (SAMPLE(?val) AS ?value) (GROUP_CONCAT(DISTINCT STR(?cat); SEPARATOR=";") AS ?categories) ?mentionCount
|
|
@@ -6362,7 +6374,7 @@ GROUP BY ?id ?mentionCount`;
|
|
|
6362
6374
|
categories: c.categories?.value?.split(";").filter(Boolean) ?? [],
|
|
6363
6375
|
mentionCount: c.mentionCount ? parseInt(c.mentionCount.value, 10) : void 0
|
|
6364
6376
|
};
|
|
6365
|
-
}), this._entityDetails.set(p);
|
|
6377
|
+
}), this._entityDetails.set(p), this._log(`entityDetails: ${Object.keys(p).length} with metadata / ${this._seenIds.size} seen (cumulative)`);
|
|
6366
6378
|
}).catch(
|
|
6367
6379
|
(a) => console.error("[CueProjectEntities] requestEntityData failed:", a)
|
|
6368
6380
|
);
|
|
@@ -6379,6 +6391,8 @@ GROUP BY ?id ?mentionCount`;
|
|
|
6379
6391
|
(p) => this._entityOSMMap.get()[p] === void 0
|
|
6380
6392
|
);
|
|
6381
6393
|
if (e.length === 0) return;
|
|
6394
|
+
for (const p of t) this._seenIds.add(p);
|
|
6395
|
+
this._log(`requestEntityLocations: ${e.length} new / ${t.length} requested | cumulative: ${this._seenIds.size} seen`);
|
|
6382
6396
|
const o = { ...this._entityOSMMap.get() };
|
|
6383
6397
|
for (const p of e) o[p] = { direct: [], indirect: [] };
|
|
6384
6398
|
this._entityOSMMap.set(o);
|
|
@@ -6416,9 +6430,9 @@ WHERE {
|
|
|
6416
6430
|
), n = { ...this._entityOSMMap.get() };
|
|
6417
6431
|
a.results.bindings.forEach((p) => {
|
|
6418
6432
|
if (!p.id || !p.osm) return;
|
|
6419
|
-
const c = p.id.value, h = p.osm.value, d = p.direct?.value === "true", g = p.rels?.value?.split(";").filter(Boolean) ?? [],
|
|
6420
|
-
d ?
|
|
6421
|
-
}), this._entityOSMMap.set(n);
|
|
6433
|
+
const c = p.id.value, h = p.osm.value, d = p.direct?.value === "true", g = p.rels?.value?.split(";").filter(Boolean) ?? [], u = p.entityUUID?.value, m = n[c] ?? { direct: [], indirect: [] };
|
|
6434
|
+
d ? m.direct.push(h) : u && m.indirect.push({ osm: h, viaRels: g, entityUUID: u }), n[c] = m;
|
|
6435
|
+
}), this._entityOSMMap.set(n), this._log(`entityOSMMap: ${Object.keys(n).length} with OSM / ${this._seenIds.size} seen (cumulative)`);
|
|
6422
6436
|
}
|
|
6423
6437
|
/**
|
|
6424
6438
|
* Fetches incoming and outgoing relationships for a single entity IRI.
|
|
@@ -6500,7 +6514,7 @@ ORDER BY ${t ? "DESC(?count)" : "ASC(?label)"}`;
|
|
|
6500
6514
|
async entitiesByCategory(t, e = !1) {
|
|
6501
6515
|
if (t.length === 0) return [];
|
|
6502
6516
|
const o = V.getInstance(), r = (p) => p.startsWith("http://") || p.startsWith("https://") ? p : o.expandIRI(p), s = t.map((p) => `<${r(p)}>`).join(" "), a = e ? `PREFIX qcy: <${y.qcy}>
|
|
6503
|
-
SELECT ?
|
|
6517
|
+
SELECT ?id (SAMPLE(?val) AS ?value) (GROUP_CONCAT(DISTINCT STR(?allCat); SEPARATOR=";") AS ?categories)
|
|
6504
6518
|
WHERE {
|
|
6505
6519
|
VALUES ?filterCat { ${s} }
|
|
6506
6520
|
?iri a qcy:CanonicalEntity ;
|
|
@@ -6509,27 +6523,29 @@ WHERE {
|
|
|
6509
6523
|
qcy:hasEntityCategory ?allCat .
|
|
6510
6524
|
BIND(REPLACE(STR(?iri), "^.*/", "") AS ?id)
|
|
6511
6525
|
}
|
|
6512
|
-
GROUP BY ?
|
|
6526
|
+
GROUP BY ?id` : `PREFIX qcy: <${y.qcy}>
|
|
6513
6527
|
SELECT DISTINCT ?id
|
|
6514
6528
|
WHERE {
|
|
6515
6529
|
VALUES ?filterCat { ${s} }
|
|
6516
6530
|
?iri a qcy:CanonicalEntity ;
|
|
6517
6531
|
qcy:hasEntityCategory ?filterCat .
|
|
6518
6532
|
BIND(REPLACE(STR(?iri), "^.*/", "") AS ?id)
|
|
6519
|
-
}
|
|
6533
|
+
}`;
|
|
6534
|
+
return (await this._api.sparql(
|
|
6520
6535
|
a,
|
|
6521
6536
|
this._projectId,
|
|
6522
6537
|
this._graphType
|
|
6523
|
-
)
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6538
|
+
)).results.bindings.filter((p) => p.id).map((p) => {
|
|
6539
|
+
const c = p.id.value, h = { iri: this._resourceIri(c), uuid: c };
|
|
6540
|
+
return e ? {
|
|
6541
|
+
...h,
|
|
6542
|
+
value: p.value?.value ?? "",
|
|
6543
|
+
categories: p.categories?.value?.split(";").filter(Boolean) ?? []
|
|
6544
|
+
} : h;
|
|
6545
|
+
});
|
|
6546
|
+
}
|
|
6547
|
+
async buildSummaryGraph(t, e) {
|
|
6548
|
+
const o = V.getInstance(), r = e ? e.includes("://") ? e : o.expandIRI(e) : void 0, s = r ? ` FILTER(?sourceCat = <${r}> || ?targetCat = <${r}>)` : "", a = `PREFIX qcy: <${y.qcy}>
|
|
6533
6549
|
SELECT
|
|
6534
6550
|
?sourceCat
|
|
6535
6551
|
?predicate
|
|
@@ -6543,41 +6559,42 @@ WHERE {
|
|
|
6543
6559
|
?s ?predicate ?o .
|
|
6544
6560
|
FILTER(isIRI(?s) && isIRI(?o))
|
|
6545
6561
|
FILTER(?predicate != qcy:relatedEntity)
|
|
6562
|
+
${s}
|
|
6546
6563
|
}
|
|
6547
6564
|
GROUP BY ?sourceCat ?predicate ?targetCat
|
|
6548
|
-
ORDER BY DESC(?weight)`,
|
|
6549
|
-
|
|
6565
|
+
ORDER BY DESC(?weight)`, n = await this._api.sparql(
|
|
6566
|
+
a,
|
|
6550
6567
|
this._projectId,
|
|
6551
6568
|
this._graphType
|
|
6552
|
-
),
|
|
6553
|
-
(
|
|
6569
|
+
), p = n.results.bindings.filter(
|
|
6570
|
+
(c) => c.sourceCat && c.predicate && c.targetCat
|
|
6554
6571
|
);
|
|
6555
6572
|
if (t === "graph") {
|
|
6556
|
-
const
|
|
6557
|
-
for (const
|
|
6558
|
-
const
|
|
6559
|
-
|
|
6573
|
+
const c = /* @__PURE__ */ new Set(), h = [];
|
|
6574
|
+
for (const d of p) {
|
|
6575
|
+
const g = d.sourceCat.value, u = d.predicate.value, m = d.targetCat.value, f = parseInt(d.weight.value, 10);
|
|
6576
|
+
c.add(g), c.add(m), h.push({ sourceID: g, predicate: u, targetID: m, weight: f });
|
|
6560
6577
|
}
|
|
6561
6578
|
return {
|
|
6562
|
-
entities: Array.from(
|
|
6563
|
-
relations:
|
|
6579
|
+
entities: Array.from(c).map((d) => ({ iri: d })),
|
|
6580
|
+
relations: h
|
|
6564
6581
|
};
|
|
6565
6582
|
}
|
|
6566
6583
|
if (t === "md") {
|
|
6567
|
-
const
|
|
6568
|
-
src:
|
|
6569
|
-
pred:
|
|
6570
|
-
tgt:
|
|
6571
|
-
weight: parseInt(
|
|
6584
|
+
const c = p.map((u) => ({
|
|
6585
|
+
src: o.compactIRI(u.sourceCat.value),
|
|
6586
|
+
pred: o.compactIRI(u.predicate.value),
|
|
6587
|
+
tgt: o.compactIRI(u.targetCat.value),
|
|
6588
|
+
weight: parseInt(u.weight.value, 10)
|
|
6572
6589
|
}));
|
|
6573
|
-
if (
|
|
6574
|
-
const
|
|
6575
|
-
return
|
|
6576
|
-
(
|
|
6590
|
+
if (c.length === 0) return "(no results)";
|
|
6591
|
+
const h = Math.max(...c.map((u) => u.src.length)), d = Math.max(...c.map((u) => u.pred.length)), g = Math.max(...c.map((u) => u.tgt.length));
|
|
6592
|
+
return c.map(
|
|
6593
|
+
(u) => `${u.src.padEnd(h)} -> ${u.pred.padEnd(d)} -> ${u.tgt.padEnd(g)} (${u.weight})`
|
|
6577
6594
|
).join(`
|
|
6578
6595
|
`);
|
|
6579
6596
|
}
|
|
6580
|
-
return
|
|
6597
|
+
return n;
|
|
6581
6598
|
}
|
|
6582
6599
|
// ── Private helpers ────────────────────────────────────────────────────────
|
|
6583
6600
|
_computeEntityInfoMap() {
|
|
@@ -6592,24 +6609,24 @@ ORDER BY DESC(?weight)`, o = await this._api.sparql(
|
|
|
6592
6609
|
const c = t[p], h = r[p];
|
|
6593
6610
|
let d, g;
|
|
6594
6611
|
if (h) {
|
|
6595
|
-
const
|
|
6612
|
+
const u = /* @__PURE__ */ new Set();
|
|
6596
6613
|
d = h.direct.filter(
|
|
6597
|
-
(f) => s[f] !== void 0 && !
|
|
6614
|
+
(f) => s[f] !== void 0 && !u.has(f) && !!u.add(f)
|
|
6598
6615
|
).map((f) => ({ osmIRI: f, wkt: s[f] }));
|
|
6599
|
-
const
|
|
6600
|
-
for (const { osm: f, viaRels: E, entityUUID:
|
|
6616
|
+
const m = /* @__PURE__ */ new Map();
|
|
6617
|
+
for (const { osm: f, viaRels: E, entityUUID: w } of h.indirect) {
|
|
6601
6618
|
const x = s[f];
|
|
6602
6619
|
if (x)
|
|
6603
6620
|
for (const I of E) {
|
|
6604
|
-
const v = `${I}:${
|
|
6605
|
-
b.geometries.some((C) => C.osmIRI === f) || (b.geometries.push({ osmIRI: f, wkt: x }),
|
|
6621
|
+
const v = `${I}:${w}`, b = m.get(v) ?? { geometries: [], entityUUID: w };
|
|
6622
|
+
b.geometries.some((C) => C.osmIRI === f) || (b.geometries.push({ osmIRI: f, wkt: x }), m.set(v, b));
|
|
6606
6623
|
}
|
|
6607
6624
|
}
|
|
6608
|
-
|
|
6609
|
-
([f, { geometries: E, entityUUID:
|
|
6625
|
+
m.size > 0 && (g = Array.from(m.entries()).map(
|
|
6626
|
+
([f, { geometries: E, entityUUID: w }]) => ({
|
|
6610
6627
|
rel: f.split(":")[0],
|
|
6611
6628
|
geometries: E,
|
|
6612
|
-
entityUUID:
|
|
6629
|
+
entityUUID: w
|
|
6613
6630
|
})
|
|
6614
6631
|
));
|
|
6615
6632
|
}
|
|
@@ -7615,18 +7632,21 @@ const lt = {
|
|
|
7615
7632
|
};
|
|
7616
7633
|
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 + "";
|
|
7617
7634
|
class ct {
|
|
7618
|
-
constructor(t, e, o, r = ut, s, a) {
|
|
7619
|
-
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();
|
|
7635
|
+
constructor(t, e, o, r = ut, s, a, n = !1) {
|
|
7636
|
+
this._api = t, this._projectId = e, this._queryCache = s, this._graphType = a, this._verbose = n, this.baseURL = `${r}${e}/`, this._currentLang = o ?? this._api.language, this.documentInfoMap = this._documentInfoMap.asReadonly(), this.projectDocumentsData = this._projectDocumentsData.asReadonly();
|
|
7620
7637
|
}
|
|
7621
7638
|
_api;
|
|
7622
7639
|
_projectId;
|
|
7623
7640
|
_queryCache;
|
|
7624
7641
|
_graphType;
|
|
7642
|
+
_verbose;
|
|
7625
7643
|
/** Full RDF base URL for this project, e.g. `https://cue.qaecy.com/r/{pid}/` */
|
|
7626
7644
|
baseURL;
|
|
7627
7645
|
/** Tracks the language for which `_documentInfoMap` is currently populated. */
|
|
7628
7646
|
_currentLang;
|
|
7629
7647
|
_documentInfoMap = new k({});
|
|
7648
|
+
/** Cumulative unique document UUIDs ever passed to request methods (survives cache hits). */
|
|
7649
|
+
_seenIds = /* @__PURE__ */ new Set();
|
|
7630
7650
|
_projectDocumentsData = new k({
|
|
7631
7651
|
duplicateCount: 0,
|
|
7632
7652
|
documentsBySuffix: {},
|
|
@@ -7642,7 +7662,7 @@ class ct {
|
|
|
7642
7662
|
* Follow with `fetchOverview()` once the triplestore is ready.
|
|
7643
7663
|
*/
|
|
7644
7664
|
reset() {
|
|
7645
|
-
this._documentInfoMap.set({}), this._projectDocumentsData.set({
|
|
7665
|
+
this._documentInfoMap.set({}), this._seenIds.clear(), this._projectDocumentsData.set({
|
|
7646
7666
|
duplicateCount: 0,
|
|
7647
7667
|
documentsBySuffix: {},
|
|
7648
7668
|
documentsByContentCategory: {}
|
|
@@ -7689,10 +7709,11 @@ class ct {
|
|
|
7689
7709
|
* once the SPARQL response arrives.
|
|
7690
7710
|
*/
|
|
7691
7711
|
requestDocumentData(t) {
|
|
7712
|
+
for (const o of t) this._seenIds.add(o);
|
|
7692
7713
|
const e = t.filter((o) => this._documentInfoMap.get()[o] === void 0);
|
|
7693
|
-
e.length !== 0 && this._fetchDocumentInfoBatch(e).catch(
|
|
7714
|
+
e.length !== 0 && (this._log(`requestDocumentData: ${e.length} new / ${t.length} requested | cumulative: ${this._seenIds.size} seen`), this._fetchDocumentInfoBatch(e).catch(
|
|
7694
7715
|
(o) => console.error("[CueProjectDocuments] requestDocumentData failed:", o)
|
|
7695
|
-
);
|
|
7716
|
+
));
|
|
7696
7717
|
}
|
|
7697
7718
|
/**
|
|
7698
7719
|
* Promise-based alternative to {@link requestDocumentData} for non-reactive contexts.
|
|
@@ -7712,6 +7733,7 @@ class ct {
|
|
|
7712
7733
|
*/
|
|
7713
7734
|
async fetchDocumentData(t) {
|
|
7714
7735
|
const e = this._documentInfoMap.get(), o = t.filter((s) => e[s] === void 0);
|
|
7736
|
+
for (const s of t) this._seenIds.add(s);
|
|
7715
7737
|
o.length > 0 && await this._fetchDocumentInfoBatch(o);
|
|
7716
7738
|
const r = this._documentInfoMap.get();
|
|
7717
7739
|
return Object.fromEntries(
|
|
@@ -7729,6 +7751,7 @@ class ct {
|
|
|
7729
7751
|
*/
|
|
7730
7752
|
async fetchDocumentDataSimple(t) {
|
|
7731
7753
|
const e = this._documentInfoMap.get(), o = t.filter((s) => e[s] === void 0);
|
|
7754
|
+
for (const s of t) this._seenIds.add(s);
|
|
7732
7755
|
o.length > 0 && await this._fetchSimpleDocumentInfoBatch(o);
|
|
7733
7756
|
const r = this._documentInfoMap.get();
|
|
7734
7757
|
return Object.fromEntries(
|
|
@@ -7796,7 +7819,7 @@ LIMIT 1`;
|
|
|
7796
7819
|
const r = t.map(
|
|
7797
7820
|
(n) => (n.startsWith(".") ? n : `.${n}`).toLowerCase()
|
|
7798
7821
|
).map((n) => `"${n}"`).join(" "), s = e ? `PREFIX qcy: <${y.qcy}>
|
|
7799
|
-
SELECT ?
|
|
7822
|
+
SELECT ?id (SAMPLE(?fp) AS ?path) ?suffix (MAX(?sz) AS ?size)
|
|
7800
7823
|
WHERE {
|
|
7801
7824
|
VALUES ?suffix { ${r} }
|
|
7802
7825
|
?iri a qcy:FileContent ;
|
|
@@ -7807,7 +7830,7 @@ WHERE {
|
|
|
7807
7830
|
FILTER NOT EXISTS { ?x qcy:alternativeRepresentation ?iri }
|
|
7808
7831
|
BIND(REPLACE(STR(?iri), "^.*/", "") AS ?id)
|
|
7809
7832
|
}
|
|
7810
|
-
GROUP BY ?
|
|
7833
|
+
GROUP BY ?id ?suffix` : `PREFIX qcy: <${y.qcy}>
|
|
7811
7834
|
SELECT DISTINCT ?id
|
|
7812
7835
|
WHERE {
|
|
7813
7836
|
VALUES ?suffix { ${r} }
|
|
@@ -7815,30 +7838,73 @@ WHERE {
|
|
|
7815
7838
|
qcy:hasFileLocation/qcy:suffix ?suffix .
|
|
7816
7839
|
FILTER NOT EXISTS { ?x qcy:alternativeRepresentation ?iri }
|
|
7817
7840
|
BIND(REPLACE(STR(?iri), "^.*/", "") AS ?id)
|
|
7818
|
-
}
|
|
7819
|
-
return
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7841
|
+
}`;
|
|
7842
|
+
return (await this._api.sparql(s, this._projectId, this._graphType)).results.bindings.filter((n) => n.id).map((n) => {
|
|
7843
|
+
const p = n.id.value, c = { iri: this._resourceIri(p), uuid: p };
|
|
7844
|
+
return e ? {
|
|
7845
|
+
...c,
|
|
7846
|
+
path: n.path?.value ?? "",
|
|
7847
|
+
suffix: n.suffix?.value ?? "",
|
|
7848
|
+
size: n.size ? parseInt(n.size.value, 10) : 0
|
|
7849
|
+
} : c;
|
|
7850
|
+
});
|
|
7826
7851
|
}
|
|
7827
7852
|
documentsByFileType(t, e = !1) {
|
|
7828
7853
|
const o = new Set(t), r = Object.values(lt).filter((s) => o.has(s.type)).map((s) => s.suffix);
|
|
7829
7854
|
return this.documentsBySuffix(r, e);
|
|
7830
7855
|
}
|
|
7856
|
+
async documentsByContentCategory(t, e = !1) {
|
|
7857
|
+
if (t.length === 0) return [];
|
|
7858
|
+
const o = t.map((a) => `<${a}>`).join(" "), r = e ? `PREFIX qcy: <${y.qcy}>
|
|
7859
|
+
SELECT ?id (SAMPLE(?fp) AS ?path) ?suffix (MAX(?sz) AS ?size)
|
|
7860
|
+
WHERE {
|
|
7861
|
+
VALUES ?cat { ${o} }
|
|
7862
|
+
?iri a qcy:FileContent ;
|
|
7863
|
+
qcy:hasContentCategory ?cat ;
|
|
7864
|
+
qcy:sizeBytes ?sz ;
|
|
7865
|
+
qcy:hasFileLocation ?loc .
|
|
7866
|
+
?loc qcy:suffix ?suffix ;
|
|
7867
|
+
qcy:filePath ?fp .
|
|
7868
|
+
FILTER NOT EXISTS { ?x qcy:alternativeRepresentation ?iri }
|
|
7869
|
+
BIND(REPLACE(STR(?iri), "^.*/", "") AS ?id)
|
|
7870
|
+
}
|
|
7871
|
+
GROUP BY ?id ?suffix` : `PREFIX qcy: <${y.qcy}>
|
|
7872
|
+
SELECT DISTINCT ?id
|
|
7873
|
+
WHERE {
|
|
7874
|
+
VALUES ?cat { ${o} }
|
|
7875
|
+
?iri a qcy:FileContent ;
|
|
7876
|
+
qcy:hasContentCategory ?cat .
|
|
7877
|
+
FILTER NOT EXISTS { ?x qcy:alternativeRepresentation ?iri }
|
|
7878
|
+
BIND(REPLACE(STR(?iri), "^.*/", "") AS ?id)
|
|
7879
|
+
}`;
|
|
7880
|
+
return (await this._api.sparql(r, this._projectId, this._graphType)).results.bindings.filter((a) => a.id).map((a) => {
|
|
7881
|
+
const n = a.id.value, p = { iri: this._resourceIri(n), uuid: n };
|
|
7882
|
+
return e ? {
|
|
7883
|
+
...p,
|
|
7884
|
+
path: a.path?.value ?? "",
|
|
7885
|
+
suffix: a.suffix?.value ?? "",
|
|
7886
|
+
size: a.size ? parseInt(a.size.value, 10) : 0
|
|
7887
|
+
} : p;
|
|
7888
|
+
});
|
|
7889
|
+
}
|
|
7831
7890
|
documentsByMime(t, e = !1) {
|
|
7832
7891
|
const o = new Set(t), r = Object.values(lt).filter((s) => o.has(s.mime)).map((s) => s.suffix);
|
|
7833
7892
|
return this.documentsBySuffix(r, e);
|
|
7834
7893
|
}
|
|
7835
7894
|
// ── Private helpers ────────────────────────────────────────────────────────
|
|
7895
|
+
/** Builds a full resource IRI from a UUID without a SPARQL round-trip. */
|
|
7896
|
+
_resourceIri(t) {
|
|
7897
|
+
return `${this.baseURL}${t}`;
|
|
7898
|
+
}
|
|
7899
|
+
_log(t) {
|
|
7900
|
+
this._verbose && console.debug(`[CueProjectDocuments pid=${this._projectId}] ${t}`);
|
|
7901
|
+
}
|
|
7836
7902
|
/** Executes the document-info SPARQL query for the given UUIDs, merges results
|
|
7837
7903
|
* into `documentInfoMap`, and returns the newly fetched entries. */
|
|
7838
7904
|
async _fetchDocumentInfoBatch(t) {
|
|
7839
7905
|
const e = t.map((p) => `r:${p}`).join(" "), o = this._api.language, r = `PREFIX qcy: <${y.qcy}>
|
|
7840
7906
|
PREFIX r: <${this.baseURL}>
|
|
7841
|
-
SELECT ?id ?
|
|
7907
|
+
SELECT ?id ?suffix ?size ?subject ?summary
|
|
7842
7908
|
(SAMPLE(?fp) AS ?path)
|
|
7843
7909
|
(GROUP_CONCAT(DISTINCT ?tag; SEPARATOR=";") AS ?tags)
|
|
7844
7910
|
(GROUP_CONCAT(DISTINCT STR(?cat); SEPARATOR=";") AS ?categories)
|
|
@@ -7860,14 +7926,14 @@ WHERE {
|
|
|
7860
7926
|
OPTIONAL { ?contentIRI qcy:textSummary ?no_lang_summary }
|
|
7861
7927
|
BIND(COALESCE(?lang_summary, ?no_lang_summary) AS ?summary)
|
|
7862
7928
|
|
|
7863
|
-
BIND(REPLACE(STR(?contentIRI), "^.*/
|
|
7929
|
+
BIND(REPLACE(STR(?contentIRI), "^.*/", "") AS ?id)
|
|
7864
7930
|
}
|
|
7865
|
-
GROUP BY ?id ?
|
|
7931
|
+
GROUP BY ?id ?suffix ?size ?subject ?summary`, s = await this._api.sparql(r, this._projectId), a = { ...this._documentInfoMap.get() }, n = {};
|
|
7866
7932
|
return s.results.bindings.forEach((p) => {
|
|
7867
|
-
if (!p.id
|
|
7933
|
+
if (!p.id) return;
|
|
7868
7934
|
const c = p.id.value, h = {
|
|
7869
7935
|
id: c,
|
|
7870
|
-
contentIRI:
|
|
7936
|
+
contentIRI: this._resourceIri(c),
|
|
7871
7937
|
path: p.path?.value ?? "",
|
|
7872
7938
|
suffix: p.suffix?.value ?? "",
|
|
7873
7939
|
size: p.size ? parseInt(p.size.value, 10) : 0,
|
|
@@ -7878,28 +7944,28 @@ GROUP BY ?id ?contentIRI ?suffix ?size ?subject ?summary`, s = await this._api.s
|
|
|
7878
7944
|
providerId: p.pid?.value
|
|
7879
7945
|
};
|
|
7880
7946
|
a[c] = h, n[c] = h;
|
|
7881
|
-
}), this._documentInfoMap.set(a), n;
|
|
7947
|
+
}), this._documentInfoMap.set(a), this._log(`fetchDocumentInfoBatch: ${Object.keys(n).length} fetched | cumulative: ${Object.keys(a).length} with metadata / ${this._seenIds.size} seen`), n;
|
|
7882
7948
|
}
|
|
7883
7949
|
/** Executes a reduced document-info query (id/path/suffix/size only), merges
|
|
7884
7950
|
* into `documentInfoMap`, and returns newly fetched entries. */
|
|
7885
7951
|
async _fetchSimpleDocumentInfoBatch(t) {
|
|
7886
7952
|
const e = t.map((n) => `r:${n}`).join(" "), o = `PREFIX qcy: <${y.qcy}>
|
|
7887
7953
|
PREFIX r: <${this.baseURL}>
|
|
7888
|
-
SELECT ?id ?
|
|
7954
|
+
SELECT ?id ?suffix ?size (SAMPLE(?fp) AS ?path)
|
|
7889
7955
|
WHERE {
|
|
7890
7956
|
VALUES ?contentIRI { ${e} }
|
|
7891
7957
|
?contentIRI qcy:sizeBytes ?size ;
|
|
7892
7958
|
qcy:hasFileLocation ?loc .
|
|
7893
7959
|
?loc qcy:filePath ?fp ;
|
|
7894
7960
|
qcy:suffix ?suffix .
|
|
7895
|
-
BIND(REPLACE(STR(?contentIRI), "^.*/
|
|
7961
|
+
BIND(REPLACE(STR(?contentIRI), "^.*/", "") AS ?id)
|
|
7896
7962
|
}
|
|
7897
|
-
GROUP BY ?id ?
|
|
7963
|
+
GROUP BY ?id ?suffix ?size`, r = await this._api.sparql(o, this._projectId, this._graphType), s = { ...this._documentInfoMap.get() }, a = {};
|
|
7898
7964
|
return r.results.bindings.forEach((n) => {
|
|
7899
7965
|
if (!n.id) return;
|
|
7900
7966
|
const p = n.id.value, c = s[p], h = {
|
|
7901
7967
|
id: p,
|
|
7902
|
-
contentIRI:
|
|
7968
|
+
contentIRI: this._resourceIri(p),
|
|
7903
7969
|
path: n.path?.value ?? c?.path ?? p,
|
|
7904
7970
|
suffix: n.suffix?.value ?? c?.suffix ?? "",
|
|
7905
7971
|
size: n.size ? parseInt(n.size.value, 10) : c?.size ?? 0,
|
|
@@ -7910,7 +7976,7 @@ GROUP BY ?id ?contentIRI ?suffix ?size`, r = await this._api.sparql(o, this._pro
|
|
|
7910
7976
|
providerId: c?.providerId
|
|
7911
7977
|
};
|
|
7912
7978
|
s[p] = h, a[p] = h;
|
|
7913
|
-
}), this._documentInfoMap.set(s), a;
|
|
7979
|
+
}), this._documentInfoMap.set(s), this._log(`fetchSimpleDocumentInfoBatch: ${Object.keys(a).length} fetched | cumulative: ${Object.keys(s).length} with metadata / ${this._seenIds.size} seen`), a;
|
|
7914
7980
|
}
|
|
7915
7981
|
async _fetchDocumentsBySuffix() {
|
|
7916
7982
|
return this._runDocumentsBySuffixQuery(this._buildDocumentsBySuffixQuery());
|
|
@@ -7993,8 +8059,8 @@ WHERE {
|
|
|
7993
8059
|
}
|
|
7994
8060
|
}
|
|
7995
8061
|
class hr {
|
|
7996
|
-
constructor(t, e, { language: o, queryCache: r, rdfBase: s = ut, graphType: a }) {
|
|
7997
|
-
this._api = t, this._projectId = e, this.schema = new lr(t, e, o, r, a), this.entities = new we(t, e, s, r, a), this.documents = new ct(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((
|
|
8062
|
+
constructor(t, e, { language: o, queryCache: r, rdfBase: s = ut, graphType: a, verbose: n }) {
|
|
8063
|
+
this._api = t, this._projectId = e, this.schema = new lr(t, e, o, r, a), this.entities = new we(t, e, s, r, a, n), this.documents = new ct(t, e, o, s, r, a, n), this.availableContentCategories = this.schema.availableContentCategories, this.availableEntityCategories = this.schema.availableEntityCategories, this.availableEntityRelationships = this.schema.availableEntityRelationships, this.schemaReady = this.schema.ready, this.entityInfoMap = this.entities.entityInfoMap, this.entityGraph = this.entities.entityGraph, this.documentInfoMap = this.documents.documentInfoMap, this.projectDocumentsData = this.documents.projectDocumentsData, this.searchResults = this._searchResults.asReadonly(), this.documents.fetchOverview().catch((p) => console.error("[CueProjectView] fetchOverview failed:", p));
|
|
7998
8064
|
}
|
|
7999
8065
|
_api;
|
|
8000
8066
|
_projectId;
|
|
@@ -8115,24 +8181,24 @@ class hr {
|
|
|
8115
8181
|
function Yt(i, t) {
|
|
8116
8182
|
return new Promise((e) => {
|
|
8117
8183
|
const o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
8118
|
-
for (const
|
|
8119
|
-
o.has(
|
|
8184
|
+
for (const w of i)
|
|
8185
|
+
o.has(w.contentUUID) || o.set(w.contentUUID, []), o.get(w.contentUUID)?.push(w), r.set(w.locationUUID, w);
|
|
8120
8186
|
const s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
8121
|
-
for (const
|
|
8122
|
-
s.has(
|
|
8187
|
+
for (const w of t)
|
|
8188
|
+
s.has(w.contentUUID) || s.set(w.contentUUID, []), s.get(w.contentUUID)?.push(w), w.locationUUID && a.set(w.locationUUID, w);
|
|
8123
8189
|
const n = [], p = [];
|
|
8124
|
-
for (const
|
|
8125
|
-
s.has(
|
|
8190
|
+
for (const w of i)
|
|
8191
|
+
s.has(w.contentUUID) ? (s.get(w.contentUUID) || []).some((v) => v.locationUUID === w.locationUUID) || p.push(w) : n.push(w);
|
|
8126
8192
|
const c = [], h = [];
|
|
8127
|
-
for (const
|
|
8128
|
-
const x = o.get(
|
|
8129
|
-
x ? x.some((v) => v.locationUUID ===
|
|
8193
|
+
for (const w of t) {
|
|
8194
|
+
const x = o.get(w.contentUUID);
|
|
8195
|
+
x ? x.some((v) => v.locationUUID === w.locationUUID) || h.push(w) : c.push(w);
|
|
8130
8196
|
}
|
|
8131
|
-
const d = i.length - n.length - p.length, g = i.length,
|
|
8132
|
-
let
|
|
8133
|
-
for (const
|
|
8134
|
-
f +=
|
|
8135
|
-
const E = f > 0 ?
|
|
8197
|
+
const d = i.length - n.length - p.length, g = i.length, u = g > 0 ? d / g : 1;
|
|
8198
|
+
let m = 0, f = 0;
|
|
8199
|
+
for (const w of i)
|
|
8200
|
+
f += w.size || 0, (s.get(w.contentUUID) || []).some((v) => v.locationUUID === w.locationUUID) && (m += w.size || 0);
|
|
8201
|
+
const E = f > 0 ? m / f : 1;
|
|
8136
8202
|
e({
|
|
8137
8203
|
localNotOnRemote: n,
|
|
8138
8204
|
localNotOnRemotePathOnly: p,
|
|
@@ -8140,10 +8206,10 @@ function Yt(i, t) {
|
|
|
8140
8206
|
remoteNotOnLocalPathOnly: h,
|
|
8141
8207
|
syncCount: d,
|
|
8142
8208
|
totalCount: g,
|
|
8143
|
-
syncSize:
|
|
8209
|
+
syncSize: m,
|
|
8144
8210
|
totalSize: f,
|
|
8145
8211
|
synctPctSize: E,
|
|
8146
|
-
synctPctCount:
|
|
8212
|
+
synctPctCount: u
|
|
8147
8213
|
});
|
|
8148
8214
|
});
|
|
8149
8215
|
}
|
|
@@ -8222,7 +8288,7 @@ async function fr() {
|
|
|
8222
8288
|
await a.default({ module_or_path: r }), q = a.scan;
|
|
8223
8289
|
}
|
|
8224
8290
|
}
|
|
8225
|
-
const yr = "qlever",
|
|
8291
|
+
const yr = "qlever", N = 1e3, mt = "cue:pending:";
|
|
8226
8292
|
async function wt(i) {
|
|
8227
8293
|
const { tmpdir: t } = await import(
|
|
8228
8294
|
/* webpackIgnore: true */
|
|
@@ -8308,8 +8374,8 @@ class vr {
|
|
|
8308
8374
|
providerId: e.providerId,
|
|
8309
8375
|
fileContentExists: !1
|
|
8310
8376
|
}));
|
|
8311
|
-
for (let r = 0; r < o.length; r +=
|
|
8312
|
-
await this._postFssBatch(o.slice(r, r +
|
|
8377
|
+
for (let r = 0; r < o.length; r += N)
|
|
8378
|
+
await this._postFssBatch(o.slice(r, r + N), e.spaceId);
|
|
8313
8379
|
e.verbose && console.info(`Pushed metadata for ${o.length} file(s) ✅`);
|
|
8314
8380
|
}
|
|
8315
8381
|
/**
|
|
@@ -8337,26 +8403,26 @@ class vr {
|
|
|
8337
8403
|
async previewSync(t, e) {
|
|
8338
8404
|
const { spaceId: o, providerId: r, verbose: s } = e, a = await this._auth.getToken();
|
|
8339
8405
|
if (!a) throw new Error("Not authenticated. Call cue.auth.signIn() first.");
|
|
8340
|
-
const n = await this._getOrCreateGraph(o, a), c = (await this._projects.getProject(o))?.projectSettings?.tier ?? "l", [h, d, g,
|
|
8406
|
+
const n = await this._getOrCreateGraph(o, a), c = (await this._projects.getProject(o))?.projectSettings?.tier ?? "l", [h, d, g, u] = await Promise.all([
|
|
8341
8407
|
this._listRemoteFiles(n, o, r, s),
|
|
8342
8408
|
this._api?.getConsumption(o) ?? Promise.reject(new Error("CueSyncApi is not bound to a CueApi instance")),
|
|
8343
8409
|
this._fetchUnitCreditMap(s),
|
|
8344
8410
|
this._fetchTierNames()
|
|
8345
8411
|
]), f = (await Yt(t, h)).localNotOnRemote ?? [], E = f.length > 0 ? await this.scanCost(f) : [];
|
|
8346
|
-
let
|
|
8412
|
+
let w = 0, x = 0;
|
|
8347
8413
|
for (const v of E) {
|
|
8348
|
-
|
|
8414
|
+
w += v.units;
|
|
8349
8415
|
const b = g[c], C = b?.[v.ext] ?? 1;
|
|
8350
8416
|
s && b && !(v.ext in b) && console.info(` Unknown format: .${v.ext} (using default rate of 1 credit/unit)`);
|
|
8351
8417
|
const P = v.units * C;
|
|
8352
8418
|
x += P, v.credits = Math.round(P);
|
|
8353
8419
|
}
|
|
8354
|
-
const I =
|
|
8420
|
+
const I = u[c] ?? c;
|
|
8355
8421
|
return {
|
|
8356
8422
|
costRecords: E,
|
|
8357
8423
|
tier: c,
|
|
8358
8424
|
tierName: I,
|
|
8359
|
-
unitsToConsume:
|
|
8425
|
+
unitsToConsume: w,
|
|
8360
8426
|
creditsToConsume: Math.round(x),
|
|
8361
8427
|
creditsAvailable: d.creditsAvailable,
|
|
8362
8428
|
unitsAvailable: d.unitsAvailable,
|
|
@@ -8374,17 +8440,17 @@ class vr {
|
|
|
8374
8440
|
const [d, g] = await Promise.all([
|
|
8375
8441
|
this._listRemoteFiles(h, o, r, a),
|
|
8376
8442
|
this._api?.getConsumption(o) ?? Promise.reject(new Error("CueSyncApi is not bound to a CueApi instance"))
|
|
8377
|
-
]), { unitsAvailable:
|
|
8443
|
+
]), { unitsAvailable: u } = g, m = await Yt(t, d);
|
|
8378
8444
|
a && (console.info(`Total local files: ${t.length}`), console.info(`Total remote files: ${d.length}`), console.info(
|
|
8379
|
-
`Total files to sync: ${(
|
|
8445
|
+
`Total files to sync: ${(m.localNotOnRemote?.length ?? 0) + m.localNotOnRemotePathOnly.length}`
|
|
8380
8446
|
));
|
|
8381
|
-
let f =
|
|
8382
|
-
const I =
|
|
8447
|
+
let f = m.syncCount, E = m.syncSize, w = 0, x = !1;
|
|
8448
|
+
const I = m.localNotOnRemote ?? [];
|
|
8383
8449
|
if (I.length > 0) {
|
|
8384
8450
|
const C = (await this.scanCost(I)).reduce((P, ye) => P + ye.units, 0);
|
|
8385
|
-
if (C >
|
|
8451
|
+
if (C > u)
|
|
8386
8452
|
throw new Error(
|
|
8387
|
-
`Insufficient units: ${C} units required but only ${
|
|
8453
|
+
`Insufficient units: ${C} units required but only ${u} available.`
|
|
8388
8454
|
);
|
|
8389
8455
|
}
|
|
8390
8456
|
await this._initPendingBatch(o, a), a && I.length && console.info("Syncing missing files ⏳");
|
|
@@ -8409,27 +8475,27 @@ class vr {
|
|
|
8409
8475
|
size: b.size,
|
|
8410
8476
|
providerId: r,
|
|
8411
8477
|
fileContentExists: !1
|
|
8412
|
-
}), x = !0, f += 1, E += b.size || 0, this._logProgress(f,
|
|
8478
|
+
}), x = !0, f += 1, E += b.size || 0, this._logProgress(f, m.totalCount, E, m.totalSize, n);
|
|
8413
8479
|
} catch (C) {
|
|
8414
|
-
|
|
8480
|
+
w += 1, console.error(`[CueSyncApi] Failed to upload file: ${b.fullPath}`), a && console.error("[CueSyncApi] Upload error details:", C);
|
|
8415
8481
|
}
|
|
8416
|
-
a &&
|
|
8417
|
-
for (const b of
|
|
8482
|
+
a && m.localNotOnRemotePathOnly.length && console.info(`Syncing missing file locations (on provider "${r}") ⏳`);
|
|
8483
|
+
for (const b of m.localNotOnRemotePathOnly)
|
|
8418
8484
|
await this._queueFileLocation({
|
|
8419
8485
|
relativePath: b.relativePath,
|
|
8420
8486
|
md5: b.md5,
|
|
8421
8487
|
size: b.size,
|
|
8422
8488
|
providerId: r,
|
|
8423
8489
|
fileContentExists: !0
|
|
8424
|
-
}), x = !0, f += 1, E += b.size || 0, this._logProgress(f,
|
|
8490
|
+
}), x = !0, f += 1, E += b.size || 0, this._logProgress(f, m.totalCount, E, m.totalSize, n);
|
|
8425
8491
|
await this._drainPending(a), this._stopFlushTimer();
|
|
8426
8492
|
const v = await (this._api?.getConsumption(o) ?? Promise.resolve({ creditsAvailable: 0 }));
|
|
8427
8493
|
return {
|
|
8428
8494
|
syncCount: f,
|
|
8429
8495
|
syncSize: E,
|
|
8430
|
-
failedUploads:
|
|
8431
|
-
totalCount:
|
|
8432
|
-
totalSize:
|
|
8496
|
+
failedUploads: w,
|
|
8497
|
+
totalCount: m.totalCount,
|
|
8498
|
+
totalSize: m.totalSize,
|
|
8433
8499
|
rdfWritten: x,
|
|
8434
8500
|
creditsAvailable: v.creditsAvailable
|
|
8435
8501
|
};
|
|
@@ -8541,8 +8607,8 @@ WHERE {
|
|
|
8541
8607
|
const r = [...t];
|
|
8542
8608
|
this._pendingSpaceId === e && (this._pendingItems = []), await br(e);
|
|
8543
8609
|
try {
|
|
8544
|
-
for (let s = 0; s < r.length; s +=
|
|
8545
|
-
await this._postFssBatch(r.slice(s, s +
|
|
8610
|
+
for (let s = 0; s < r.length; s += N)
|
|
8611
|
+
await this._postFssBatch(r.slice(s, s + N), e);
|
|
8546
8612
|
o && console.info(`Wrote ${r.length} file location(s) to commands API ✅`);
|
|
8547
8613
|
} catch (s) {
|
|
8548
8614
|
const a = [...r, ...this._pendingItems];
|
|
@@ -8619,7 +8685,7 @@ WHERE {
|
|
|
8619
8685
|
console.info(`[computeCredits] all resolved — ${p.length} ext(s), creditsAvailable: ${h.creditsAvailable}`);
|
|
8620
8686
|
let d = 0;
|
|
8621
8687
|
for (const g of p) {
|
|
8622
|
-
const
|
|
8688
|
+
const m = c[r]?.[g.ext] ?? 1, f = g.units * m;
|
|
8623
8689
|
d += f, g.credits = Math.round(f);
|
|
8624
8690
|
}
|
|
8625
8691
|
return {
|
|
@@ -8726,6 +8792,7 @@ class fe {
|
|
|
8726
8792
|
_storageProcessed;
|
|
8727
8793
|
_gis = null;
|
|
8728
8794
|
_projectDocuments = /* @__PURE__ */ new Map();
|
|
8795
|
+
_verbose;
|
|
8729
8796
|
/**
|
|
8730
8797
|
* Reactive GIS service. Lazily constructed on first access.
|
|
8731
8798
|
*
|
|
@@ -8748,16 +8815,16 @@ class fe {
|
|
|
8748
8815
|
"Using default SDK app settings. Contact QAECY for your own configuration for any production code."
|
|
8749
8816
|
);
|
|
8750
8817
|
const o = t.apiKey ?? Z.apiKey, r = t.appId ?? Z.appId, s = t.measurementId ?? Z.measurementId, a = t.environment ?? "production";
|
|
8751
|
-
this._endpoints = { ...oe[a], ...t.endpoints }, this._isEmulator = a === "emulator", this._app = be().find((g) => g.name === "[DEFAULT]") ?? ve({
|
|
8818
|
+
this._endpoints = { ...oe[a], ...t.endpoints }, this._isEmulator = a === "emulator", this._verbose = t.verbose ?? !1, this._app = be().find((g) => g.name === "[DEFAULT]") ?? ve({
|
|
8752
8819
|
apiKey: o,
|
|
8753
8820
|
appId: r,
|
|
8754
8821
|
measurementId: s,
|
|
8755
8822
|
authDomain: `${xt}.firebaseapp.com`,
|
|
8756
8823
|
projectId: xt,
|
|
8757
8824
|
messagingSenderId: oo
|
|
8758
|
-
}), this.auth = new Ut(this._app, this._isEmulator, this._endpoints), this.projects = new Ht(this.auth, this._app, this._isEmulator, this._endpoints), this._storageRaw =
|
|
8759
|
-
const n =
|
|
8760
|
-
this._isEmulator && (
|
|
8825
|
+
}), this.auth = new Ut(this._app, this._isEmulator, this._endpoints), this.projects = new Ht(this.auth, this._app, this._isEmulator, this._endpoints), this._storageRaw = S(this._app, St), this._storageProcessed = S(this._app, Tt);
|
|
8826
|
+
const n = S(this._app, At), p = S(this._app, Rt), c = S(this._app, Ct), h = S(this._app, Pt);
|
|
8827
|
+
this._isEmulator && (X(this._storageRaw, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), X(this._storageProcessed, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort)), this.api = this._buildApi(this.projects);
|
|
8761
8828
|
const d = new kt({
|
|
8762
8829
|
storageRaw: this._storageRaw,
|
|
8763
8830
|
storageProcessed: this._storageProcessed,
|
|
@@ -8766,12 +8833,12 @@ class fe {
|
|
|
8766
8833
|
storageChatSessions: c,
|
|
8767
8834
|
storagePersistence: h
|
|
8768
8835
|
});
|
|
8769
|
-
this.storage = new
|
|
8836
|
+
this.storage = new zt(d), this.profile = new Wt(
|
|
8770
8837
|
this.auth,
|
|
8771
8838
|
this._app,
|
|
8772
8839
|
this._isEmulator,
|
|
8773
8840
|
this._endpoints.gatewayUrl
|
|
8774
|
-
), this.privileges = new
|
|
8841
|
+
), this.privileges = new Xt(this.auth.isSuperAdmin), this._isEmulator && X(h, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), this.cache = new Qt(h);
|
|
8775
8842
|
}
|
|
8776
8843
|
/**
|
|
8777
8844
|
* Create a `Cue` instance from an already-initialized Firebase app.
|
|
@@ -8790,17 +8857,17 @@ class fe {
|
|
|
8790
8857
|
* });
|
|
8791
8858
|
*/
|
|
8792
8859
|
static fromApp(t, e = {}) {
|
|
8793
|
-
const o = e.environment ?? "production", r = { ...oe[o], ...e.endpoints }, s = new Ut(t, !1, r), a = new Ht(s, t, !1, r), n =
|
|
8860
|
+
const o = e.environment ?? "production", r = { ...oe[o], ...e.endpoints }, s = new Ut(t, !1, r), a = new Ht(s, t, !1, r), n = S(t, St), p = S(t, Tt), c = S(t, At), h = S(t, Rt), d = S(t, Ct), g = S(t, Pt), u = new kt({
|
|
8794
8861
|
storageRaw: n,
|
|
8795
8862
|
storageProcessed: p,
|
|
8796
8863
|
storagePublic: c,
|
|
8797
8864
|
storageLogs: h,
|
|
8798
8865
|
storageChatSessions: d,
|
|
8799
8866
|
storagePersistence: g
|
|
8800
|
-
}),
|
|
8801
|
-
|
|
8802
|
-
const E = new Wt(s, t, !1, r.gatewayUrl),
|
|
8803
|
-
return Object.assign(
|
|
8867
|
+
}), m = new vr(s, a, u, r.gatewayUrl), f = new $t(s, r.gatewayUrl, a, m);
|
|
8868
|
+
m._bindApi(f);
|
|
8869
|
+
const E = new Wt(s, t, !1, r.gatewayUrl), w = Object.create(fe.prototype), x = new Xt(s.isSuperAdmin), I = new Qt(g), v = new zt(u);
|
|
8870
|
+
return Object.assign(w, {
|
|
8804
8871
|
_app: t,
|
|
8805
8872
|
_endpoints: r,
|
|
8806
8873
|
_isEmulator: o === "emulator",
|
|
@@ -8813,11 +8880,11 @@ class fe {
|
|
|
8813
8880
|
privileges: x,
|
|
8814
8881
|
cache: I,
|
|
8815
8882
|
storage: v
|
|
8816
|
-
}),
|
|
8883
|
+
}), w;
|
|
8817
8884
|
}
|
|
8818
8885
|
/** Override in subclasses to provide a custom CueApi (e.g. with sync). */
|
|
8819
8886
|
_buildApi(t) {
|
|
8820
|
-
return new
|
|
8887
|
+
return new $t(this.auth, this._endpoints.gatewayUrl, t);
|
|
8821
8888
|
}
|
|
8822
8889
|
/** Convenience: get the current user's Firebase ID token */
|
|
8823
8890
|
getToken(t = !1) {
|
|
@@ -8842,7 +8909,7 @@ class fe {
|
|
|
8842
8909
|
get: (r) => this.cache.getQueryCache(t, r).then((s) => s?.results),
|
|
8843
8910
|
set: (r, s) => this.cache.setQueryCache(t, r, { query: r, results: s })
|
|
8844
8911
|
};
|
|
8845
|
-
return new hr(this.api, t, { ...e, queryCache: o });
|
|
8912
|
+
return new hr(this.api, t, { verbose: this._verbose, ...e, queryCache: o });
|
|
8846
8913
|
}
|
|
8847
8914
|
/**
|
|
8848
8915
|
* Creates a `CueProjectEntities` instance for the given project, with the
|
|
@@ -8871,7 +8938,8 @@ class fe {
|
|
|
8871
8938
|
t,
|
|
8872
8939
|
e?.rdfBase,
|
|
8873
8940
|
o,
|
|
8874
|
-
e?.graphType
|
|
8941
|
+
e?.graphType,
|
|
8942
|
+
e?.verbose ?? this._verbose
|
|
8875
8943
|
);
|
|
8876
8944
|
}
|
|
8877
8945
|
/**
|
|
@@ -8902,7 +8970,8 @@ class fe {
|
|
|
8902
8970
|
this.api.language,
|
|
8903
8971
|
void 0,
|
|
8904
8972
|
a,
|
|
8905
|
-
void 0
|
|
8973
|
+
void 0,
|
|
8974
|
+
e?.verbose ?? this._verbose
|
|
8906
8975
|
);
|
|
8907
8976
|
return this._projectDocuments.set(t, n), n;
|
|
8908
8977
|
}
|
|
@@ -8916,7 +8985,8 @@ class fe {
|
|
|
8916
8985
|
e?.language ?? this.api.language,
|
|
8917
8986
|
e?.rdfBase,
|
|
8918
8987
|
r,
|
|
8919
|
-
e?.graphType
|
|
8988
|
+
e?.graphType,
|
|
8989
|
+
e?.verbose ?? this._verbose
|
|
8920
8990
|
);
|
|
8921
8991
|
}
|
|
8922
8992
|
}
|
|
@@ -8924,12 +8994,12 @@ export {
|
|
|
8924
8994
|
Ct as B,
|
|
8925
8995
|
fe as C,
|
|
8926
8996
|
Kt as R,
|
|
8927
|
-
|
|
8997
|
+
$t as a,
|
|
8928
8998
|
Ut as b,
|
|
8929
|
-
|
|
8999
|
+
Qt as c,
|
|
8930
9000
|
bo as d,
|
|
8931
9001
|
ir as e,
|
|
8932
|
-
|
|
9002
|
+
Xt as f,
|
|
8933
9003
|
Wt as g,
|
|
8934
9004
|
ct as h,
|
|
8935
9005
|
we as i,
|
|
@@ -8937,7 +9007,7 @@ export {
|
|
|
8937
9007
|
hr as k,
|
|
8938
9008
|
Ht as l,
|
|
8939
9009
|
k as m,
|
|
8940
|
-
|
|
9010
|
+
zt as n,
|
|
8941
9011
|
vr as o,
|
|
8942
9012
|
fo as p,
|
|
8943
9013
|
Lr as q,
|