@qaecy/cue-sdk 0.0.26 → 0.0.27
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 +31 -0
- package/{cue-BjbRXItA.js → cue-CzxsQ6aP.js} +284 -238
- package/index.d.ts +2 -0
- package/index.js +17 -16
- package/lib/api.d.ts +3 -0
- package/lib/auth.d.ts +2 -0
- package/lib/extraction.d.ts +48 -0
- package/node.js +19 -18
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getApps as
|
|
2
|
-
import { ref as _, getDownloadURL as V, getMetadata as M, getBlob as
|
|
3
|
-
import { Writer as
|
|
4
|
-
import { getFirestore as
|
|
5
|
-
import { getAuth as
|
|
1
|
+
import { getApps as ye, initializeApp as be } from "firebase/app";
|
|
2
|
+
import { ref as _, getDownloadURL as V, getMetadata as M, getBlob as oe, updateMetadata as ve, uploadBytesResumable as wt, uploadBytes as rt, StringFormat as _e, uploadString as ke, listAll as z, getStorage as T, connectStorageEmulator as K } from "firebase/storage";
|
|
3
|
+
import { Writer as Ee, DataFactory as j } from "n3";
|
|
4
|
+
import { getFirestore as xe, connectFirestoreEmulator as Ie, collection as ft, getDocs as Ce, query as Te, where as Se, limit as Re, doc as yt, getDoc as Ae, setDoc as Pe, serverTimestamp as Oe, increment as De } from "firebase/firestore";
|
|
5
|
+
import { getAuth as Le, connectAuthEmulator as qe, onIdTokenChanged as je, getIdTokenResult as st, signInWithEmailAndPassword as Ue, GoogleAuthProvider as at, OAuthProvider as it, signInWithPopup as Me, signInWithRedirect as ze, getRedirectResult as Ne, signInWithCustomToken as bt, signOut as $e, onAuthStateChanged as Fe, fetchSignInMethodsForEmail as Be, linkWithPopup as Ge, unlink as He, reauthenticateWithCredential as vt, EmailAuthProvider as Q, updatePassword as We, linkWithCredential as Ve, verifyBeforeUpdateEmail as Ke, sendEmailVerification as Qe } from "firebase/auth";
|
|
6
6
|
import { v5 as Xe } from "uuid";
|
|
7
7
|
import "spark-md5";
|
|
8
|
-
import { getFunctions as
|
|
8
|
+
import { getFunctions as re, connectFunctionsEmulator as se, httpsCallable as F } from "firebase/functions";
|
|
9
9
|
class lt {
|
|
10
10
|
queryEndpoint;
|
|
11
11
|
updateEndpoint;
|
|
@@ -223,7 +223,7 @@ class R {
|
|
|
223
223
|
}
|
|
224
224
|
_quadsToNQuads(t) {
|
|
225
225
|
return new Promise((e, o) => {
|
|
226
|
-
const r = new
|
|
226
|
+
const r = new Ee({ format: "application/n-quads" });
|
|
227
227
|
r.addQuads(t), r.end((s, a) => s ? o(s) : e(a));
|
|
228
228
|
});
|
|
229
229
|
}
|
|
@@ -298,7 +298,7 @@ class Ze {
|
|
|
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 _t {
|
|
302
302
|
constructor(t) {
|
|
303
303
|
this.options = t;
|
|
304
304
|
}
|
|
@@ -356,7 +356,7 @@ class vt {
|
|
|
356
356
|
async getFile(t, e) {
|
|
357
357
|
const o = _(this._bucket(t), e);
|
|
358
358
|
try {
|
|
359
|
-
return await
|
|
359
|
+
return await oe(o);
|
|
360
360
|
} catch (r) {
|
|
361
361
|
if (r?.code === "storage/object-not-found") return;
|
|
362
362
|
throw r;
|
|
@@ -414,7 +414,7 @@ class vt {
|
|
|
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 ve(r, { customMetadata: o });
|
|
418
418
|
}
|
|
419
419
|
// ─── Uploads ──────────────────────────────────────────────────────────────
|
|
420
420
|
/**
|
|
@@ -446,9 +446,9 @@ class vt {
|
|
|
446
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 = _e.RAW, s) {
|
|
450
450
|
const a = _(this._bucket(t), e);
|
|
451
|
-
await
|
|
451
|
+
await ke(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. */
|
|
@@ -540,7 +540,7 @@ class vt {
|
|
|
540
540
|
return (await z(e)).items.map((r) => r.name);
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
|
-
const
|
|
543
|
+
const kt = {
|
|
544
544
|
ä: "ae",
|
|
545
545
|
ä: "ae",
|
|
546
546
|
Ä: "AE",
|
|
@@ -580,8 +580,8 @@ function D(i, t = !1) {
|
|
|
580
580
|
}
|
|
581
581
|
function Je(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 kt)
|
|
584
|
+
e = e.replace(new RegExp(o, "g"), kt[o]);
|
|
585
585
|
return t && e !== i && console.info(`${i} -> ${e}`), e;
|
|
586
586
|
}
|
|
587
587
|
function to(i, t = "") {
|
|
@@ -646,8 +646,8 @@ const Y = {
|
|
|
646
646
|
apiKey: "AIzaSyAiW42QBx9HS4Khu88pCW7MV66IhBAQul0",
|
|
647
647
|
appId: "1:151132927589:web:d2ffdb377dfadfd23ab88c",
|
|
648
648
|
measurementId: "G-YT4PK6HGZD"
|
|
649
|
-
},
|
|
650
|
-
class
|
|
649
|
+
}, Et = "qaecy-mvp-406413", eo = "734737865998", ae = "europe-west6", xt = "projects", It = "spaces_chats_eu_west6", Ct = "spaces_raw_eu_west6", Tt = "spaces_processed_eu_west6", St = "spaces_logs_eu_west6", Rt = "cue_public_eu_west6", At = "db_persistence_eu_west6", oo = "/data-views/admin/consumption", ro = "/data-views/admin/profile/organizations", Pt = "/data-views/admin/profile/api-keys", Ot = "/commands/admin/profile/api-keys", so = "/commands/admin/profile/terms", ao = (i) => `/data-views/admin/organizations/${i}/members`, io = "/commands/admin/project", no = (i) => `/commands/admin/project/${i}`, po = "/assistant/search", ie = "/triplestore/query", lo = "/triplestore/update", co = "/triplestore/shacl", ne = "/qlever-server/qlever/query", ho = "/qlever-server/qlever/update", go = "/qlever-server/qlever/shacl", Dt = "/commands/file-system-structure/batch", Lt = "microsoft.com", qt = "superadmin", dt = "https://cue.qaecy.com/r/";
|
|
650
|
+
class jt {
|
|
651
651
|
_auth;
|
|
652
652
|
_endpoints;
|
|
653
653
|
_userSignal = new k(null);
|
|
@@ -664,19 +664,19 @@ class qt {
|
|
|
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 = Le(t), this._endpoints = o, e && qe(this._auth, o.authEmulatorUrl, {
|
|
668
668
|
disableWarnings: !0
|
|
669
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 = je(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
678
|
const a = await st(r);
|
|
679
|
-
this._isSuperAdminSignal.set(a.claims.role ===
|
|
679
|
+
this._isSuperAdminSignal.set(a.claims.role === qt);
|
|
680
680
|
} else
|
|
681
681
|
this._tokenSignal.set(null), this._isSuperAdminSignal.set(!1);
|
|
682
682
|
});
|
|
@@ -689,14 +689,14 @@ class qt {
|
|
|
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 Ue(
|
|
693
693
|
this._auth,
|
|
694
694
|
e.email,
|
|
695
695
|
e.password
|
|
696
696
|
)).user;
|
|
697
697
|
}
|
|
698
|
-
const o = t === "google" ? new at() : new it(
|
|
699
|
-
return (await
|
|
698
|
+
const o = t === "google" ? new at() : new it(Lt);
|
|
699
|
+
return (await Me(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 qt {
|
|
|
704
704
|
* retrieve the result.
|
|
705
705
|
*/
|
|
706
706
|
async signInWithRedirect(t) {
|
|
707
|
-
const e = t === "google" ? new at() : new it(
|
|
708
|
-
await
|
|
707
|
+
const e = t === "google" ? new at() : new it(Lt);
|
|
708
|
+
await ze(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 qt {
|
|
|
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
|
|
@@ -722,7 +722,7 @@ class qt {
|
|
|
722
722
|
*/
|
|
723
723
|
async checkSuperAdmin() {
|
|
724
724
|
const t = this._auth.currentUser;
|
|
725
|
-
return t ? (await st(t)).claims.role ===
|
|
725
|
+
return t ? (await st(t)).claims.role === qt : !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,7 +735,11 @@ class qt {
|
|
|
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 bt(this._auth, s)).user;
|
|
739
|
+
}
|
|
740
|
+
/** Sign in with a Firebase custom token (e.g. minted server-side for MCP/OAuth flows). */
|
|
741
|
+
async signInWithCustomToken(t) {
|
|
742
|
+
return (await bt(this._auth, t)).user;
|
|
739
743
|
}
|
|
740
744
|
/** Sign out the current user */
|
|
741
745
|
async signOut() {
|
|
@@ -801,7 +805,7 @@ class qt {
|
|
|
801
805
|
return this._auth;
|
|
802
806
|
}
|
|
803
807
|
}
|
|
804
|
-
class
|
|
808
|
+
class Ut {
|
|
805
809
|
constructor(t) {
|
|
806
810
|
this._blob = t;
|
|
807
811
|
}
|
|
@@ -876,15 +880,56 @@ class wo {
|
|
|
876
880
|
throw new Error(`Failed to save tables: ${o.status} ${o.statusText}`);
|
|
877
881
|
}
|
|
878
882
|
}
|
|
879
|
-
|
|
883
|
+
const fo = "/semantic-extraction/extract";
|
|
884
|
+
class yo {
|
|
885
|
+
constructor(t, e) {
|
|
886
|
+
this._auth = t, this._gatewayUrl = e;
|
|
887
|
+
}
|
|
888
|
+
_auth;
|
|
889
|
+
_gatewayUrl;
|
|
890
|
+
/**
|
|
891
|
+
* Run semantic extraction on a document page image.
|
|
892
|
+
*
|
|
893
|
+
* Sends a multipart/form-data POST to `/semantic-extraction/extract`.
|
|
894
|
+
* Always requests JSON-LD so the result can be displayed directly in
|
|
895
|
+
* `cue-rdf-graph` without any further parsing.
|
|
896
|
+
*/
|
|
897
|
+
async extract(t) {
|
|
898
|
+
const e = t.rdfFormat ?? "json-ld", o = new FormData();
|
|
899
|
+
o.append("file", t.image, "page.png"), o.append("template", JSON.stringify(t.template)), o.append("space_id", t.projectId), o.append("rdf_format", e), t.category && o.append("category", t.category), t.text && o.append("text", t.text);
|
|
900
|
+
const r = await this._auth.authenticatedFetch(
|
|
901
|
+
`${this._gatewayUrl}${fo}`,
|
|
902
|
+
{
|
|
903
|
+
method: "POST",
|
|
904
|
+
// Do NOT set Content-Type; browser sets it with the correct boundary.
|
|
905
|
+
headers: {
|
|
906
|
+
Accept: "application/ld+json",
|
|
907
|
+
"x-project-id": t.projectId,
|
|
908
|
+
"cue-project-id": t.projectId
|
|
909
|
+
},
|
|
910
|
+
body: o
|
|
911
|
+
}
|
|
912
|
+
);
|
|
913
|
+
if (!r.ok) {
|
|
914
|
+
const a = await r.text().catch(() => "");
|
|
915
|
+
throw new Error(
|
|
916
|
+
`Extraction failed: ${r.status} ${r.statusText}${a ? " — " + a.slice(0, 300) : ""}`
|
|
917
|
+
);
|
|
918
|
+
}
|
|
919
|
+
return { jsonld: await r.json() };
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
class Mt {
|
|
880
923
|
constructor(t, e, o, r) {
|
|
881
|
-
this._auth = t, this._gatewayUrl = e, this.projects = o, this.sync = r, this.tables = new wo(t, e);
|
|
924
|
+
this._auth = t, this._gatewayUrl = e, this.projects = o, this.sync = r, this.tables = new wo(t, e), this.extraction = new yo(t, e);
|
|
882
925
|
}
|
|
883
926
|
_auth;
|
|
884
927
|
_gatewayUrl;
|
|
885
928
|
projects;
|
|
886
929
|
sync;
|
|
887
930
|
tables;
|
|
931
|
+
/** Semantic extraction client — call document pages against a SemanticTemplate. */
|
|
932
|
+
extraction;
|
|
888
933
|
/** Active language used for language-sensitive SPARQL queries across all project classes. */
|
|
889
934
|
language = "en";
|
|
890
935
|
/** Updates the active language. All project classes (`CueProjectSchema`, `CueProjectDocuments`, `CueProjectEntities`) read this at query time. */
|
|
@@ -933,7 +978,7 @@ class Ut {
|
|
|
933
978
|
*/
|
|
934
979
|
async sparql(t, e, o) {
|
|
935
980
|
o || (o = (await this.projects.getProject(e))?.projectSettings?.graph?.type ?? "qlever");
|
|
936
|
-
const r = o === "fuseki" ?
|
|
981
|
+
const r = o === "fuseki" ? ie : ne;
|
|
937
982
|
console.log(`Executing SPARQL query against ${r} for project ${e} with graph type ${o}`);
|
|
938
983
|
const s = new URLSearchParams();
|
|
939
984
|
s.append("query", t);
|
|
@@ -1033,13 +1078,13 @@ const nt = [
|
|
|
1033
1078
|
"railway",
|
|
1034
1079
|
"natural",
|
|
1035
1080
|
"manmade"
|
|
1036
|
-
],
|
|
1081
|
+
], pe = [
|
|
1037
1082
|
"address",
|
|
1038
1083
|
"poi",
|
|
1039
1084
|
"railway",
|
|
1040
1085
|
"natural",
|
|
1041
1086
|
"manmade"
|
|
1042
|
-
],
|
|
1087
|
+
], bo = {
|
|
1043
1088
|
address: {
|
|
1044
1089
|
category: "address",
|
|
1045
1090
|
label: "Address",
|
|
@@ -1102,9 +1147,9 @@ const nt = [
|
|
|
1102
1147
|
}
|
|
1103
1148
|
};
|
|
1104
1149
|
function S(i) {
|
|
1105
|
-
return
|
|
1150
|
+
return bo[i];
|
|
1106
1151
|
}
|
|
1107
|
-
const
|
|
1152
|
+
const vo = {
|
|
1108
1153
|
"land-use-plan": "#f59e0b",
|
|
1109
1154
|
// amber – primary zoning
|
|
1110
1155
|
"local-plan": "#ec4899",
|
|
@@ -1135,7 +1180,7 @@ const yo = {
|
|
|
1135
1180
|
function N(i, t) {
|
|
1136
1181
|
return i[0] < t[2] && i[2] > t[0] && i[1] < t[3] && i[3] > t[1];
|
|
1137
1182
|
}
|
|
1138
|
-
const
|
|
1183
|
+
const _o = "https://nominatim.openstreetmap.org", ko = "cue-gis/0.0.1", Eo = {
|
|
1139
1184
|
address: "street",
|
|
1140
1185
|
poi: "shop",
|
|
1141
1186
|
railway: "station",
|
|
@@ -1150,7 +1195,7 @@ const bo = "https://nominatim.openstreetmap.org", vo = "cue-gis/0.0.1", _o = {
|
|
|
1150
1195
|
function B(i) {
|
|
1151
1196
|
return `${L}:${i}`;
|
|
1152
1197
|
}
|
|
1153
|
-
function
|
|
1198
|
+
function xo(i) {
|
|
1154
1199
|
const t = S(i);
|
|
1155
1200
|
return {
|
|
1156
1201
|
id: B(i),
|
|
@@ -1165,17 +1210,17 @@ function ko(i) {
|
|
|
1165
1210
|
descriptionKey: `gis.layer.${L}.${i}.description`
|
|
1166
1211
|
};
|
|
1167
1212
|
}
|
|
1168
|
-
class
|
|
1213
|
+
class Io {
|
|
1169
1214
|
baseUrl;
|
|
1170
1215
|
userAgent;
|
|
1171
1216
|
email;
|
|
1172
1217
|
limit;
|
|
1173
1218
|
constructor(t = {}) {
|
|
1174
|
-
this.baseUrl = t.baseUrl ??
|
|
1219
|
+
this.baseUrl = t.baseUrl ?? _o, this.userAgent = t.userAgent ?? ko, this.email = t.email, this.limit = Math.min(t.limit ?? 40, 40);
|
|
1175
1220
|
}
|
|
1176
1221
|
async listFeatureCategoryDescriptors(t) {
|
|
1177
1222
|
return (await Promise.allSettled(
|
|
1178
|
-
|
|
1223
|
+
pe.map(async (o) => {
|
|
1179
1224
|
const r = await this.search(t, o);
|
|
1180
1225
|
return { category: o, hasResults: r.length > 0 };
|
|
1181
1226
|
})
|
|
@@ -1184,7 +1229,7 @@ class Eo {
|
|
|
1184
1229
|
).map((o) => S(o.value.category));
|
|
1185
1230
|
}
|
|
1186
1231
|
async listAvailableLayers(t) {
|
|
1187
|
-
return (await this.listFeatureCategoryDescriptors(t)).map((o) =>
|
|
1232
|
+
return (await this.listFeatureCategoryDescriptors(t)).map((o) => xo(o.category));
|
|
1188
1233
|
}
|
|
1189
1234
|
async getFeaturesForLayer(t, e) {
|
|
1190
1235
|
const o = nt.find((r) => B(r) === e);
|
|
@@ -1201,7 +1246,7 @@ class Eo {
|
|
|
1201
1246
|
* so bounded viewbox searches return meaningful results.
|
|
1202
1247
|
*/
|
|
1203
1248
|
async search(t, e) {
|
|
1204
|
-
const [o, r, s, a] = t, n = e ?
|
|
1249
|
+
const [o, r, s, a] = t, n = e ? Eo[e] : "place", p = new URLSearchParams({
|
|
1205
1250
|
q: n,
|
|
1206
1251
|
format: "jsonv2",
|
|
1207
1252
|
viewbox: `${o},${a},${s},${r}`,
|
|
@@ -1244,7 +1289,7 @@ class Eo {
|
|
|
1244
1289
|
};
|
|
1245
1290
|
}
|
|
1246
1291
|
}
|
|
1247
|
-
const
|
|
1292
|
+
const zt = {
|
|
1248
1293
|
// 100s – Residential
|
|
1249
1294
|
110: "residential",
|
|
1250
1295
|
120: "residential",
|
|
@@ -1323,7 +1368,7 @@ const Mt = {
|
|
|
1323
1368
|
960: "agricultural",
|
|
1324
1369
|
970: "agricultural",
|
|
1325
1370
|
990: "other"
|
|
1326
|
-
},
|
|
1371
|
+
}, Nt = {
|
|
1327
1372
|
1010: "residential",
|
|
1328
1373
|
1020: "mixed",
|
|
1329
1374
|
1030: "residential",
|
|
@@ -1353,7 +1398,7 @@ const Mt = {
|
|
|
1353
1398
|
1281: "infrastructure",
|
|
1354
1399
|
1282: "infrastructure",
|
|
1355
1400
|
9999: "other"
|
|
1356
|
-
},
|
|
1401
|
+
}, Co = {
|
|
1357
1402
|
// Residential
|
|
1358
1403
|
1110: "residential",
|
|
1359
1404
|
// Einfamilienhaus
|
|
@@ -1415,7 +1460,7 @@ const Mt = {
|
|
|
1415
1460
|
// Empfangsgebäude Bahn/Bus
|
|
1416
1461
|
1282: "infrastructure"
|
|
1417
1462
|
// Parkhaus, Garage
|
|
1418
|
-
},
|
|
1463
|
+
}, To = [
|
|
1419
1464
|
// "Gebäude" is the Swiss AV BoFlaeche land-cover label for a building footprint.
|
|
1420
1465
|
// It does not encode the actual use type, so map it to 'other' as a safe fallback.
|
|
1421
1466
|
[/^geb[äa]ude$/i, "other"],
|
|
@@ -1429,22 +1474,22 @@ const Mt = {
|
|
|
1429
1474
|
[/gemischt|mixed|blandet/i, "mixed"]
|
|
1430
1475
|
];
|
|
1431
1476
|
function O(i) {
|
|
1432
|
-
for (const [t, e] of
|
|
1477
|
+
for (const [t, e] of To)
|
|
1433
1478
|
if (t.test(i)) return e;
|
|
1434
1479
|
}
|
|
1435
|
-
function
|
|
1480
|
+
function So(i, t) {
|
|
1436
1481
|
if (i == null) return;
|
|
1437
1482
|
const e = String(i).trim();
|
|
1438
|
-
return t === "swiss-gwr" ?
|
|
1483
|
+
return t === "swiss-gwr" ? Co[e] ?? O(e) : t === "danish-matrikel" ? zt[e] ?? O(e) : t === "zurich-wfs" || t === "swiss-av-wfs" ? Nt[e] ?? O(e) : Nt[e] ?? zt[e] ?? O(e);
|
|
1439
1484
|
}
|
|
1440
|
-
function
|
|
1485
|
+
function Ro(i, t) {
|
|
1441
1486
|
if (i != null)
|
|
1442
1487
|
return O(String(i).trim());
|
|
1443
1488
|
}
|
|
1444
|
-
function
|
|
1489
|
+
function le(i) {
|
|
1445
1490
|
return i.trim().toLowerCase().replace(/[\s_\-]/g, "");
|
|
1446
1491
|
}
|
|
1447
|
-
const
|
|
1492
|
+
const Ao = {
|
|
1448
1493
|
// Swiss ÖREB rechtsstatus
|
|
1449
1494
|
inkraft: "in-force",
|
|
1450
1495
|
laufendeanderung: "amendment-pending",
|
|
@@ -1463,11 +1508,11 @@ const So = {
|
|
|
1463
1508
|
forslag: "proposed",
|
|
1464
1509
|
aflyst: "repealed"
|
|
1465
1510
|
};
|
|
1466
|
-
function
|
|
1511
|
+
function ce(i) {
|
|
1467
1512
|
if (i)
|
|
1468
|
-
return
|
|
1513
|
+
return Ao[le(i)];
|
|
1469
1514
|
}
|
|
1470
|
-
const
|
|
1515
|
+
const $t = {
|
|
1471
1516
|
// Swiss Nutzungsplanung (typ_gde_bezeichnung and common variants)
|
|
1472
1517
|
grundnutzungszonenplan: "land-use-plan",
|
|
1473
1518
|
nutzungszonenplan: "land-use-plan",
|
|
@@ -1521,7 +1566,7 @@ const Nt = {
|
|
|
1521
1566
|
// Danish plandata.dk
|
|
1522
1567
|
lokalplan: "local-plan",
|
|
1523
1568
|
kommuneplanramme: "municipal-plan-framework"
|
|
1524
|
-
},
|
|
1569
|
+
}, Po = [
|
|
1525
1570
|
[/quartiererhalt/i, "neighbourhood-conservation-plan"],
|
|
1526
1571
|
[/lärmempfindlich|laermempfindlich/i, "noise-sensitivity-plan"],
|
|
1527
1572
|
[/gewässerschutz|grundwasserschutz/i, "water-protection-plan"],
|
|
@@ -1561,24 +1606,24 @@ const Nt = {
|
|
|
1561
1606
|
// Catch-all: any remaining Xzone / Xareal designation from the Grundnutzungszonenplan
|
|
1562
1607
|
[/zone$|areal$/i, "land-use-plan"]
|
|
1563
1608
|
];
|
|
1564
|
-
function
|
|
1609
|
+
function he(i) {
|
|
1565
1610
|
if (!i) return;
|
|
1566
|
-
const t =
|
|
1567
|
-
if (t in
|
|
1568
|
-
for (const [e, o] of
|
|
1611
|
+
const t = le(i);
|
|
1612
|
+
if (t in $t) return $t[t];
|
|
1613
|
+
for (const [e, o] of Po)
|
|
1569
1614
|
if (e.test(i)) return o;
|
|
1570
1615
|
console.warn(
|
|
1571
1616
|
`[cue-gis] Unknown zone plan type — add "${i}" to classifyZonePlanType: no ZonePlanType mapping found.`
|
|
1572
1617
|
);
|
|
1573
1618
|
}
|
|
1574
|
-
const
|
|
1619
|
+
const Oo = "https://maps.zh.ch/wfs/OGDZHWFS", Do = "zurich-wfs", Lo = [8.35, 47.15, 8.95, 47.7], qo = [5.9, 45.7, 10.55, 47.85];
|
|
1575
1620
|
function Z(i) {
|
|
1576
1621
|
return typeof i == "string" ? i : i.typeName;
|
|
1577
1622
|
}
|
|
1578
1623
|
function J(i) {
|
|
1579
1624
|
return typeof i == "string" ? void 0 : i.cqlFilter;
|
|
1580
1625
|
}
|
|
1581
|
-
function
|
|
1626
|
+
function jo(i) {
|
|
1582
1627
|
if (!i) return [0, 0];
|
|
1583
1628
|
const t = i.coordinates;
|
|
1584
1629
|
switch (i.type) {
|
|
@@ -1596,20 +1641,20 @@ function Lo(i) {
|
|
|
1596
1641
|
return [0, 0];
|
|
1597
1642
|
}
|
|
1598
1643
|
}
|
|
1599
|
-
function
|
|
1644
|
+
function Uo(i, t) {
|
|
1600
1645
|
if (!i) return t;
|
|
1601
1646
|
for (const e of ["plannavn", "bezeichnung", "name", "strassenname", "objektname", "title", "label"])
|
|
1602
1647
|
if (typeof i[e] == "string" && i[e]) return i[e];
|
|
1603
1648
|
return t;
|
|
1604
1649
|
}
|
|
1605
|
-
function
|
|
1650
|
+
function Mo(i, t, e) {
|
|
1606
1651
|
return e ? `${i}:${t}[${e}]` : `${i}:${t}`;
|
|
1607
1652
|
}
|
|
1608
|
-
const
|
|
1653
|
+
const zo = /* @__PURE__ */ new Set(["building", "cadastre", "greenspace", "paved", "zone"]);
|
|
1609
1654
|
function tt(i, t, e, o) {
|
|
1610
|
-
const r = e.replace(/^ms:/, ""), s = S(t), a =
|
|
1655
|
+
const r = e.replace(/^ms:/, ""), s = S(t), a = zo.has(t) ? "priority" : "raw";
|
|
1611
1656
|
return {
|
|
1612
|
-
id:
|
|
1657
|
+
id: Mo(i, e, o),
|
|
1613
1658
|
sourceId: i,
|
|
1614
1659
|
sourceLayerId: e,
|
|
1615
1660
|
category: t,
|
|
@@ -1621,32 +1666,32 @@ function tt(i, t, e, o) {
|
|
|
1621
1666
|
descriptionKey: `gis.layer.${i}.${r}.description`
|
|
1622
1667
|
};
|
|
1623
1668
|
}
|
|
1624
|
-
function
|
|
1669
|
+
function No(i, t) {
|
|
1625
1670
|
if (!i) return { featureType: "building" };
|
|
1626
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;
|
|
1627
1672
|
return {
|
|
1628
1673
|
featureType: "building",
|
|
1629
1674
|
areaM2: typeof e == "number" ? e : void 0,
|
|
1630
1675
|
buildingUse: r ? String(r) : void 0,
|
|
1631
|
-
buildingUseGeneric:
|
|
1676
|
+
buildingUseGeneric: So(r, t),
|
|
1632
1677
|
floors: typeof o == "number" ? o : void 0,
|
|
1633
1678
|
yearBuilt: typeof s == "number" ? s : void 0,
|
|
1634
1679
|
registryId: a
|
|
1635
1680
|
};
|
|
1636
1681
|
}
|
|
1637
|
-
function
|
|
1682
|
+
function $o(i, t) {
|
|
1638
1683
|
if (!i) return { featureType: "plot" };
|
|
1639
1684
|
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;
|
|
1640
1685
|
return {
|
|
1641
1686
|
featureType: "plot",
|
|
1642
1687
|
areaM2: typeof a == "number" ? a : void 0,
|
|
1643
1688
|
plotUse: n ? String(n) : void 0,
|
|
1644
|
-
plotUseGeneric:
|
|
1689
|
+
plotUseGeneric: Ro(n),
|
|
1645
1690
|
plotId: s,
|
|
1646
1691
|
registryId: e
|
|
1647
1692
|
};
|
|
1648
1693
|
}
|
|
1649
|
-
function
|
|
1694
|
+
function Fo(i) {
|
|
1650
1695
|
if (!i) return { featureType: "greenspace" };
|
|
1651
1696
|
const t = i.flaeche ?? void 0, e = i.art ?? void 0;
|
|
1652
1697
|
return {
|
|
@@ -1655,7 +1700,7 @@ function No(i) {
|
|
|
1655
1700
|
surfaceType: e ? String(e) : void 0
|
|
1656
1701
|
};
|
|
1657
1702
|
}
|
|
1658
|
-
function
|
|
1703
|
+
function Bo(i) {
|
|
1659
1704
|
if (!i) return { featureType: "paved" };
|
|
1660
1705
|
const t = i.flaeche ?? void 0, e = i.art ?? void 0;
|
|
1661
1706
|
return {
|
|
@@ -1664,9 +1709,9 @@ function $o(i) {
|
|
|
1664
1709
|
surfaceType: e ? String(e) : void 0
|
|
1665
1710
|
};
|
|
1666
1711
|
}
|
|
1667
|
-
function
|
|
1712
|
+
function Go(i) {
|
|
1668
1713
|
if (!i) return { featureType: "zone" };
|
|
1669
|
-
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 =
|
|
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 = ce(r), a = i.typ_gde_bezeichnung ?? void 0, n = he(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;
|
|
1670
1715
|
return {
|
|
1671
1716
|
featureType: "zone",
|
|
1672
1717
|
zoneType: t ? String(t) : void 0,
|
|
@@ -1682,7 +1727,7 @@ function Fo(i) {
|
|
|
1682
1727
|
areaM2: typeof w == "number" ? w : void 0
|
|
1683
1728
|
};
|
|
1684
1729
|
}
|
|
1685
|
-
function
|
|
1730
|
+
function Ho(i) {
|
|
1686
1731
|
const t = i.match(/^(\w+)\s*=\s*'([^']+)'$/);
|
|
1687
1732
|
if (t) {
|
|
1688
1733
|
const [, o, r] = t;
|
|
@@ -1703,7 +1748,7 @@ class et {
|
|
|
1703
1748
|
sourceId;
|
|
1704
1749
|
outputFormat;
|
|
1705
1750
|
constructor(t) {
|
|
1706
|
-
this.categoryMap = t.categoryMap, this.baseUrl = t.baseUrl ??
|
|
1751
|
+
this.categoryMap = t.categoryMap, this.baseUrl = t.baseUrl ?? Oo, this.sourceId = t.sourceId ?? Do, this.outputFormat = t.outputFormat ?? "application/json; subtype=geojson";
|
|
1707
1752
|
}
|
|
1708
1753
|
async listFeatureCategoryDescriptors(t) {
|
|
1709
1754
|
const e = await this.listAvailableLayers(t);
|
|
@@ -1727,7 +1772,7 @@ class et {
|
|
|
1727
1772
|
return o ? this._fetchAndConvert(t, o.descriptor, o.cqlFilter) : [];
|
|
1728
1773
|
}
|
|
1729
1774
|
async _fetchAndConvert(t, e, o) {
|
|
1730
|
-
const r = await this._fetchFeatures(t, e.sourceLayerId, void 0, o), s = o ?
|
|
1775
|
+
const r = await this._fetchFeatures(t, e.sourceLayerId, void 0, o), s = o ? Ho(o) : void 0;
|
|
1731
1776
|
return (s ? r.features.filter((n) => s(n.properties)) : r.features).map((n, p) => this.toGisFeature(n, e, p));
|
|
1732
1777
|
}
|
|
1733
1778
|
/**
|
|
@@ -1776,7 +1821,7 @@ class et {
|
|
|
1776
1821
|
return g.json();
|
|
1777
1822
|
}
|
|
1778
1823
|
toGisFeature(t, e, o) {
|
|
1779
|
-
const [r, s] =
|
|
1824
|
+
const [r, s] = jo(t.geometry), a = Uo(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;
|
|
1780
1825
|
return {
|
|
1781
1826
|
id: t.id ?? `${e.sourceLayerId}/${o}`,
|
|
1782
1827
|
preferredColor: e.preferredColor,
|
|
@@ -1797,10 +1842,10 @@ class et {
|
|
|
1797
1842
|
};
|
|
1798
1843
|
}
|
|
1799
1844
|
_extractNormalisedProperties(t, e) {
|
|
1800
|
-
return e.category === "building" ?
|
|
1845
|
+
return e.category === "building" ? No(t.properties, this.sourceId) : e.category === "greenspace" ? Fo(t.properties) : e.category === "paved" ? Bo(t.properties) : e.category === "zone" ? Go(t.properties) : $o(t.properties, this.sourceId);
|
|
1801
1846
|
}
|
|
1802
1847
|
}
|
|
1803
|
-
const
|
|
1848
|
+
const de = [8, 54.5, 15.2, 57.8], ge = {
|
|
1804
1849
|
building: [
|
|
1805
1850
|
{ source: "danish-matrikel", typename: "bbr_v001:bygning_current" }
|
|
1806
1851
|
],
|
|
@@ -1809,7 +1854,7 @@ const he = [8, 54.5, 15.2, 57.8], de = {
|
|
|
1809
1854
|
{ source: "danish-matrikel", typename: "mat_v001:samletfastejendom_current" }
|
|
1810
1855
|
]
|
|
1811
1856
|
};
|
|
1812
|
-
function
|
|
1857
|
+
function Wo(i) {
|
|
1813
1858
|
if (!i) return [0, 0];
|
|
1814
1859
|
const t = i.coordinates;
|
|
1815
1860
|
switch (i.type) {
|
|
@@ -1827,7 +1872,7 @@ function Go(i) {
|
|
|
1827
1872
|
return [0, 0];
|
|
1828
1873
|
}
|
|
1829
1874
|
}
|
|
1830
|
-
function
|
|
1875
|
+
function Vo(i, t) {
|
|
1831
1876
|
if (!i) return t;
|
|
1832
1877
|
for (const e of [
|
|
1833
1878
|
"mat:matrikelnummer",
|
|
@@ -1843,14 +1888,14 @@ function Ho(i, t) {
|
|
|
1843
1888
|
if (typeof i[e] == "string" && i[e]) return i[e];
|
|
1844
1889
|
return t;
|
|
1845
1890
|
}
|
|
1846
|
-
function
|
|
1891
|
+
function Ko(i, t, e) {
|
|
1847
1892
|
return `${i}:${t}:${e}`;
|
|
1848
1893
|
}
|
|
1849
|
-
const
|
|
1894
|
+
const Qo = /* @__PURE__ */ new Set(["building", "cadastre", "zone"]);
|
|
1850
1895
|
function ot(i, t, e) {
|
|
1851
|
-
const o = e.typename.replace(/^[^:]+:/, ""), r = S(t), s =
|
|
1896
|
+
const o = e.typename.replace(/^[^:]+:/, ""), r = S(t), s = Qo.has(t) ? "priority" : "raw";
|
|
1852
1897
|
return {
|
|
1853
|
-
id:
|
|
1898
|
+
id: Ko(i, e.source, e.typename),
|
|
1854
1899
|
sourceId: i,
|
|
1855
1900
|
sourceLayerId: e.typename,
|
|
1856
1901
|
category: t,
|
|
@@ -1862,7 +1907,7 @@ function ot(i, t, e) {
|
|
|
1862
1907
|
descriptionKey: `gis.layer.${i}.${e.source}.${o}.description`
|
|
1863
1908
|
};
|
|
1864
1909
|
}
|
|
1865
|
-
function
|
|
1910
|
+
function Xo(i, t) {
|
|
1866
1911
|
if (t === "building") {
|
|
1867
1912
|
const a = i?.byg041BebyggetAreal ?? i?.byg038SamletBygningsareal, n = i?.byg021BygningensAnvendelse, p = i?.id_lokalId, c = i?.byg026Opførelsesår;
|
|
1868
1913
|
return {
|
|
@@ -1879,8 +1924,8 @@ function Ko(i, t) {
|
|
|
1879
1924
|
featureType: "zone",
|
|
1880
1925
|
zoneType: a ?? void 0,
|
|
1881
1926
|
zoneCode: p ?? void 0,
|
|
1882
|
-
legalStatus:
|
|
1883
|
-
planType:
|
|
1927
|
+
legalStatus: ce(c),
|
|
1928
|
+
planType: he(i?.typ_gde_bezeichnung),
|
|
1884
1929
|
planId: n ?? void 0,
|
|
1885
1930
|
planDocumentLink: h ?? void 0,
|
|
1886
1931
|
publicationDate: i?.auflagedatum ?? void 0,
|
|
@@ -1898,13 +1943,13 @@ function Ko(i, t) {
|
|
|
1898
1943
|
registryId: s ?? void 0
|
|
1899
1944
|
};
|
|
1900
1945
|
}
|
|
1901
|
-
class
|
|
1946
|
+
class Yo {
|
|
1902
1947
|
categoryMap;
|
|
1903
1948
|
dataViewsBaseUrl;
|
|
1904
1949
|
getHeaders;
|
|
1905
1950
|
sourceId;
|
|
1906
1951
|
constructor(t) {
|
|
1907
|
-
this.dataViewsBaseUrl = t.dataViewsBaseUrl.replace(/\/$/, ""), this.getHeaders = t.getHeaders, this.categoryMap = t.categoryMap ??
|
|
1952
|
+
this.dataViewsBaseUrl = t.dataViewsBaseUrl.replace(/\/$/, ""), this.getHeaders = t.getHeaders, this.categoryMap = t.categoryMap ?? ge, this.sourceId = t.sourceId ?? "cue-sdk-gis";
|
|
1908
1953
|
}
|
|
1909
1954
|
async listFeatureCategoryDescriptors(t) {
|
|
1910
1955
|
const e = await this.listAvailableLayers(t);
|
|
@@ -1967,7 +2012,7 @@ class Qo {
|
|
|
1967
2012
|
return d.json();
|
|
1968
2013
|
}
|
|
1969
2014
|
_toGisFeature(t, e, o) {
|
|
1970
|
-
const [r, s] =
|
|
2015
|
+
const [r, s] = Wo(t.geometry), a = t.id ?? `${e.sourceLayerId}/${o}`, n = Vo(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" ? Xo(t.properties, e.category) : void 0;
|
|
1971
2016
|
return {
|
|
1972
2017
|
id: a,
|
|
1973
2018
|
sourceId: this.sourceId,
|
|
@@ -1988,7 +2033,7 @@ class Qo {
|
|
|
1988
2033
|
};
|
|
1989
2034
|
}
|
|
1990
2035
|
}
|
|
1991
|
-
const
|
|
2036
|
+
const Zo = {
|
|
1992
2037
|
address: [
|
|
1993
2038
|
"ms:ogd-0406_arv_basis_avzh_hausnummer_pos_p",
|
|
1994
2039
|
"ms:ogd-0571_afv_gv_strat_strassennetz_l"
|
|
@@ -2036,19 +2081,19 @@ const Xo = {
|
|
|
2036
2081
|
// ÖREB Überlagernde Festlegungen (Flächen) – overlaying planning constraints
|
|
2037
2082
|
"ms:ogd-0155_arv_basis_np_ul_flaeche_f"
|
|
2038
2083
|
]
|
|
2039
|
-
},
|
|
2084
|
+
}, ue = [
|
|
2040
2085
|
{
|
|
2041
2086
|
name: "Canton of Zürich",
|
|
2042
|
-
coverageBBox:
|
|
2087
|
+
coverageBBox: Lo,
|
|
2043
2088
|
supportedCategories: ["address", "poi", "railway", "natural", "manmade", "building", "cadastre", "greenspace", "paved", "zone"],
|
|
2044
2089
|
priority: 10,
|
|
2045
2090
|
adapter: new et({
|
|
2046
|
-
categoryMap:
|
|
2091
|
+
categoryMap: Zo
|
|
2047
2092
|
})
|
|
2048
2093
|
},
|
|
2049
2094
|
{
|
|
2050
2095
|
name: "Switzerland (national AV cadastre)",
|
|
2051
|
-
coverageBBox:
|
|
2096
|
+
coverageBBox: qo,
|
|
2052
2097
|
supportedCategories: ["cadastre"],
|
|
2053
2098
|
priority: 5,
|
|
2054
2099
|
// Lower priority than canton-specific adapters. For ZH, the canton adapter (priority 10) wins.
|
|
@@ -2076,7 +2121,7 @@ const Xo = {
|
|
|
2076
2121
|
* - `pdk:kommuneplanramme_vedtaget` – adopted municipal plan frameworks
|
|
2077
2122
|
*/
|
|
2078
2123
|
name: "Denmark (Plandata.dk – planning zones)",
|
|
2079
|
-
coverageBBox:
|
|
2124
|
+
coverageBBox: de,
|
|
2080
2125
|
supportedCategories: ["zone"],
|
|
2081
2126
|
priority: 10,
|
|
2082
2127
|
adapter: new et({
|
|
@@ -2094,12 +2139,12 @@ const Xo = {
|
|
|
2094
2139
|
})
|
|
2095
2140
|
}
|
|
2096
2141
|
];
|
|
2097
|
-
function
|
|
2142
|
+
function Ft(i) {
|
|
2098
2143
|
return [...i].sort(
|
|
2099
2144
|
(t, e) => nt.indexOf(t.category) - nt.indexOf(e.category)
|
|
2100
2145
|
);
|
|
2101
2146
|
}
|
|
2102
|
-
class
|
|
2147
|
+
class Jo {
|
|
2103
2148
|
nominatim;
|
|
2104
2149
|
regions;
|
|
2105
2150
|
/**
|
|
@@ -2114,9 +2159,9 @@ class Yo {
|
|
|
2114
2159
|
zonePlanTypeColors: r,
|
|
2115
2160
|
...s
|
|
2116
2161
|
} = t;
|
|
2117
|
-
this.nominatim = new
|
|
2118
|
-
const a = o ?
|
|
2119
|
-
this.regions = e ?? a, this.zonePlanTypeColors = { ...
|
|
2162
|
+
this.nominatim = new Io(s);
|
|
2163
|
+
const a = o ? ue : [];
|
|
2164
|
+
this.regions = e ?? a, this.zonePlanTypeColors = { ...vo, ...r };
|
|
2120
2165
|
}
|
|
2121
2166
|
/**
|
|
2122
2167
|
* Return the available feature categories together with UI metadata such as
|
|
@@ -2135,12 +2180,12 @@ class Yo {
|
|
|
2135
2180
|
for (const a of e)
|
|
2136
2181
|
for (const n of a.supportedCategories ?? [])
|
|
2137
2182
|
r.has(n) || (r.add(n), s.push(S(n)));
|
|
2138
|
-
for (const a of
|
|
2183
|
+
for (const a of pe)
|
|
2139
2184
|
r.has(a) || s.push(S(a));
|
|
2140
|
-
return
|
|
2185
|
+
return Ft(s);
|
|
2141
2186
|
}
|
|
2142
2187
|
const o = await this._adapterFor(t).listFeatureCategoryDescriptors(t);
|
|
2143
|
-
return
|
|
2188
|
+
return Ft(o);
|
|
2144
2189
|
}
|
|
2145
2190
|
/**
|
|
2146
2191
|
* Return the feature categories that have at least one result within the
|
|
@@ -2213,7 +2258,7 @@ class Yo {
|
|
|
2213
2258
|
const { features: n, idx: p } = await Promise.race(a.values());
|
|
2214
2259
|
a.delete(p);
|
|
2215
2260
|
for (const c of n) {
|
|
2216
|
-
const h =
|
|
2261
|
+
const h = Bt(c), d = W(c), g = s.get(h);
|
|
2217
2262
|
(g === void 0 || d > g) && (s.set(h, d), yield c);
|
|
2218
2263
|
}
|
|
2219
2264
|
}
|
|
@@ -2247,9 +2292,9 @@ class Yo {
|
|
|
2247
2292
|
), a = [], n = [];
|
|
2248
2293
|
for (const d of s)
|
|
2249
2294
|
d.status === "fulfilled" && (d.value.isNominatim ? n.push(...d.value.features) : a.push(...d.value.features));
|
|
2250
|
-
const p =
|
|
2295
|
+
const p = or(a, n), c = /* @__PURE__ */ new Map(), h = [];
|
|
2251
2296
|
for (const d of p) {
|
|
2252
|
-
const g =
|
|
2297
|
+
const g = Bt(d), w = W(d), u = c.get(g);
|
|
2253
2298
|
(u === void 0 || w > u) && (c.set(g, w), h.push(d));
|
|
2254
2299
|
}
|
|
2255
2300
|
return h;
|
|
@@ -2267,22 +2312,22 @@ function W(i) {
|
|
|
2267
2312
|
const t = i.geometry?.type;
|
|
2268
2313
|
return t === "Polygon" || t === "MultiPolygon" ? 3 : t === "LineString" || t === "MultiLineString" ? 2 : 1;
|
|
2269
2314
|
}
|
|
2270
|
-
function
|
|
2315
|
+
function Bt(i) {
|
|
2271
2316
|
const t = Math.round(i.lat * 1e3) / 1e3, e = Math.round(i.lon * 1e3) / 1e3;
|
|
2272
2317
|
return `${(i.name ?? i.id ?? "").toLowerCase().trim()}|${t}|${e}`;
|
|
2273
2318
|
}
|
|
2274
|
-
const
|
|
2275
|
-
function
|
|
2319
|
+
const tr = 1e-3;
|
|
2320
|
+
function er(i, t) {
|
|
2276
2321
|
const e = i.lat - t.lat, o = i.lon - t.lon;
|
|
2277
2322
|
return Math.sqrt(e * e + o * o);
|
|
2278
2323
|
}
|
|
2279
|
-
function
|
|
2324
|
+
function or(i, t) {
|
|
2280
2325
|
if (t.length === 0) return i;
|
|
2281
2326
|
const e = i.filter((a) => W(a) === 3), o = i.filter((a) => W(a) !== 3), r = e.map((a) => ({ feature: { ...a, originalData: { ...a.originalData } }, matched: !1 })), s = [];
|
|
2282
2327
|
for (const a of t) {
|
|
2283
|
-
let n = -1, p =
|
|
2328
|
+
let n = -1, p = tr;
|
|
2284
2329
|
for (let c = 0; c < r.length; c++) {
|
|
2285
|
-
const h =
|
|
2330
|
+
const h = er(a, r[c].feature);
|
|
2286
2331
|
h < p && (p = h, n = c);
|
|
2287
2332
|
}
|
|
2288
2333
|
n >= 0 ? (r[n].feature.originalData = {
|
|
@@ -2296,8 +2341,8 @@ function tr(i, t) {
|
|
|
2296
2341
|
...s
|
|
2297
2342
|
];
|
|
2298
2343
|
}
|
|
2299
|
-
const
|
|
2300
|
-
class
|
|
2344
|
+
const rr = "/data-views", sr = 1500;
|
|
2345
|
+
class ar {
|
|
2301
2346
|
// undefined = not yet built
|
|
2302
2347
|
/** @internal — construct via `cue.gis`, not directly. */
|
|
2303
2348
|
constructor(t, e) {
|
|
@@ -2380,25 +2425,25 @@ class rr {
|
|
|
2380
2425
|
}
|
|
2381
2426
|
// ── Private ───────────────────────────────────────────────────────────────
|
|
2382
2427
|
_scheduleDebouncedQuery() {
|
|
2383
|
-
this._debounceTimer !== null && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => this._queryLayers(),
|
|
2428
|
+
this._debounceTimer !== null && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => this._queryLayers(), sr);
|
|
2384
2429
|
}
|
|
2385
2430
|
_getGateway() {
|
|
2386
2431
|
if (this._gatewayCache !== null && this._gatewayProjectId === this._projectId)
|
|
2387
2432
|
return this._gatewayCache;
|
|
2388
|
-
const t = this._projectId, e = [...
|
|
2433
|
+
const t = this._projectId, e = [...ue];
|
|
2389
2434
|
return t && e.unshift({
|
|
2390
2435
|
name: "Cue SDK (authenticated)",
|
|
2391
|
-
coverageBBox:
|
|
2392
|
-
supportedCategories: Object.keys(
|
|
2436
|
+
coverageBBox: de,
|
|
2437
|
+
supportedCategories: Object.keys(ge),
|
|
2393
2438
|
priority: 10,
|
|
2394
|
-
adapter: new
|
|
2395
|
-
dataViewsBaseUrl: `${this._gatewayUrl}${
|
|
2439
|
+
adapter: new Yo({
|
|
2440
|
+
dataViewsBaseUrl: `${this._gatewayUrl}${rr}`,
|
|
2396
2441
|
getHeaders: async () => ({
|
|
2397
2442
|
...await this._getAuthHeaders(),
|
|
2398
2443
|
"x-project-id": t
|
|
2399
2444
|
})
|
|
2400
2445
|
})
|
|
2401
|
-
}), this._gatewayCache = new
|
|
2446
|
+
}), this._gatewayCache = new Jo({ regions: e }), this._gatewayProjectId = t, this._gatewayCache;
|
|
2402
2447
|
}
|
|
2403
2448
|
async _queryLayers() {
|
|
2404
2449
|
const t = this._bbox;
|
|
@@ -2442,11 +2487,11 @@ class rr {
|
|
|
2442
2487
|
this._loadListeners.forEach((e) => e(t));
|
|
2443
2488
|
}
|
|
2444
2489
|
}
|
|
2445
|
-
class
|
|
2490
|
+
class Gt {
|
|
2446
2491
|
constructor(t, e, o = !1, r) {
|
|
2447
|
-
if (this._auth = t, this._db =
|
|
2492
|
+
if (this._auth = t, this._db = xe(e), this._functions = re(e, ae), this._gatewayUrl = r?.gatewayUrl ?? "", o) {
|
|
2448
2493
|
const s = r?.firestoreEmulatorHost ?? "localhost", a = r?.firestoreEmulatorPort ?? 8080;
|
|
2449
|
-
|
|
2494
|
+
Ie(this._db, s, a), se(this._functions, "localhost", 5001);
|
|
2450
2495
|
}
|
|
2451
2496
|
}
|
|
2452
2497
|
_auth;
|
|
@@ -2479,12 +2524,12 @@ class Bt {
|
|
|
2479
2524
|
* Access is gated by Firestore rules which check membership.
|
|
2480
2525
|
*/
|
|
2481
2526
|
async listProjects() {
|
|
2482
|
-
const t = this._requireUser(), e = ft(this._db,
|
|
2483
|
-
return (await
|
|
2527
|
+
const t = this._requireUser(), e = ft(this._db, xt);
|
|
2528
|
+
return (await Ce(Te(e, Se("members", "array-contains", t), Re(100)))).docs.map((r) => r.data());
|
|
2484
2529
|
}
|
|
2485
2530
|
/** Fetch a single project by ID. Returns null if not found. */
|
|
2486
2531
|
async getProject(t) {
|
|
2487
|
-
const e = yt(ft(this._db,
|
|
2532
|
+
const e = yt(ft(this._db, xt), t), o = await Ae(e);
|
|
2488
2533
|
return o.exists() ? o.data() : null;
|
|
2489
2534
|
}
|
|
2490
2535
|
/**
|
|
@@ -2494,9 +2539,9 @@ class Bt {
|
|
|
2494
2539
|
async incrementUnitsConsumed(t, e, o) {
|
|
2495
2540
|
if (e <= 0) return;
|
|
2496
2541
|
const r = yt(this._db, "clientSync", t);
|
|
2497
|
-
await
|
|
2498
|
-
unitsConsumed:
|
|
2499
|
-
lastUpdated:
|
|
2542
|
+
await Pe(r, {
|
|
2543
|
+
unitsConsumed: De(e),
|
|
2544
|
+
lastUpdated: Oe(),
|
|
2500
2545
|
lastUserId: o
|
|
2501
2546
|
}, { merge: !0 });
|
|
2502
2547
|
}
|
|
@@ -2528,9 +2573,9 @@ class Bt {
|
|
|
2528
2573
|
}
|
|
2529
2574
|
}
|
|
2530
2575
|
}
|
|
2531
|
-
class
|
|
2576
|
+
class Ht {
|
|
2532
2577
|
constructor(t, e, o, r) {
|
|
2533
|
-
this._auth = t, this._gatewayUrl = r, this._functions =
|
|
2578
|
+
this._auth = t, this._gatewayUrl = r, this._functions = re(e, ae), o && se(this._functions, "localhost", 5001);
|
|
2534
2579
|
}
|
|
2535
2580
|
_auth;
|
|
2536
2581
|
_gatewayUrl;
|
|
@@ -2547,7 +2592,7 @@ class Gt {
|
|
|
2547
2592
|
}
|
|
2548
2593
|
/** Whether the current user has an active API key. */
|
|
2549
2594
|
async hasAPIKey() {
|
|
2550
|
-
return await this._fetch(
|
|
2595
|
+
return await this._fetch(Pt) !== null;
|
|
2551
2596
|
}
|
|
2552
2597
|
/** Returns the sign-in methods registered for the current user's email. */
|
|
2553
2598
|
async getSignInMethods() {
|
|
@@ -2579,7 +2624,7 @@ class Gt {
|
|
|
2579
2624
|
async updatePassword(t, e) {
|
|
2580
2625
|
const o = this._requireUser();
|
|
2581
2626
|
if (!o.email) throw new Error("User has no e-mail");
|
|
2582
|
-
await
|
|
2627
|
+
await vt(
|
|
2583
2628
|
o,
|
|
2584
2629
|
Q.credential(o.email, t)
|
|
2585
2630
|
), await We(o, e);
|
|
@@ -2594,14 +2639,14 @@ class Gt {
|
|
|
2594
2639
|
async updateEmail(t, e) {
|
|
2595
2640
|
const o = this._requireUser();
|
|
2596
2641
|
if (!o.email) throw new Error("User e-mail not available");
|
|
2597
|
-
await
|
|
2642
|
+
await vt(
|
|
2598
2643
|
o,
|
|
2599
2644
|
Q.credential(o.email, e)
|
|
2600
2645
|
), await Ke(o, t), await Qe(o);
|
|
2601
2646
|
}
|
|
2602
2647
|
/** Creates a new API key for the current user. */
|
|
2603
2648
|
async createAPIKey(t) {
|
|
2604
|
-
return this._fetch(
|
|
2649
|
+
return this._fetch(Ot, {
|
|
2605
2650
|
method: "POST",
|
|
2606
2651
|
headers: { "Content-Type": "application/json" },
|
|
2607
2652
|
body: JSON.stringify({ expiration: t })
|
|
@@ -2610,7 +2655,7 @@ class Gt {
|
|
|
2610
2655
|
/** Revokes the current user's API key. */
|
|
2611
2656
|
async revokeAPIKey() {
|
|
2612
2657
|
const t = await this._auth.authenticatedFetch(
|
|
2613
|
-
this._url(
|
|
2658
|
+
this._url(Ot),
|
|
2614
2659
|
{ method: "DELETE" }
|
|
2615
2660
|
);
|
|
2616
2661
|
if (!t.ok)
|
|
@@ -2618,7 +2663,7 @@ class Gt {
|
|
|
2618
2663
|
}
|
|
2619
2664
|
/** Fetches the current user's existing API key. */
|
|
2620
2665
|
async requestAPIKey() {
|
|
2621
|
-
const t = await this._fetch(
|
|
2666
|
+
const t = await this._fetch(Pt);
|
|
2622
2667
|
if (!t) throw new Error("No API key found");
|
|
2623
2668
|
return t;
|
|
2624
2669
|
}
|
|
@@ -2661,7 +2706,7 @@ class Gt {
|
|
|
2661
2706
|
return t ? (await st(t)).claims.terms ?? null : null;
|
|
2662
2707
|
}
|
|
2663
2708
|
}
|
|
2664
|
-
const
|
|
2709
|
+
const Wt = ["superadmin", "admin", "syncer", "member"], Vt = {
|
|
2665
2710
|
createEntities: "admin",
|
|
2666
2711
|
createProvider: "superadmin",
|
|
2667
2712
|
changeContentCategories: "syncer",
|
|
@@ -2677,7 +2722,7 @@ const Ht = ["superadmin", "admin", "syncer", "member"], Wt = {
|
|
|
2677
2722
|
uploadDocuments: "syncer",
|
|
2678
2723
|
viewEntities: "member"
|
|
2679
2724
|
};
|
|
2680
|
-
function
|
|
2725
|
+
function ir() {
|
|
2681
2726
|
return {
|
|
2682
2727
|
changeContentCategories: !1,
|
|
2683
2728
|
createEntities: !1,
|
|
@@ -2696,7 +2741,7 @@ function sr() {
|
|
|
2696
2741
|
viewEntities: !1
|
|
2697
2742
|
};
|
|
2698
2743
|
}
|
|
2699
|
-
class
|
|
2744
|
+
class Kt {
|
|
2700
2745
|
constructor(t) {
|
|
2701
2746
|
this._isSuperAdmin = t, this._projectRoles = new k([]), this._orgRole = new k(null), this.privileges = ct(
|
|
2702
2747
|
[this._projectRoles, this._orgRole, t],
|
|
@@ -2735,17 +2780,17 @@ class Vt {
|
|
|
2735
2780
|
_expand(t) {
|
|
2736
2781
|
if (this._isSuperAdmin.get())
|
|
2737
2782
|
return ["superadmin", "admin", "syncer", "member"];
|
|
2738
|
-
const e =
|
|
2739
|
-
return e === -1 ? [] : Array.from(
|
|
2783
|
+
const e = Wt.findIndex((o) => t.includes(o));
|
|
2784
|
+
return e === -1 ? [] : Array.from(Wt.slice(e));
|
|
2740
2785
|
}
|
|
2741
2786
|
_compute() {
|
|
2742
|
-
const t = this._projectRoles.get(), e = this._isSuperAdmin.get(), o =
|
|
2743
|
-
for (const r of Object.keys(
|
|
2744
|
-
o[r] = t.includes(
|
|
2787
|
+
const t = this._projectRoles.get(), e = this._isSuperAdmin.get(), o = ir();
|
|
2788
|
+
for (const r of Object.keys(Vt))
|
|
2789
|
+
o[r] = t.includes(Vt[r]);
|
|
2745
2790
|
return o.createProject = e || this._orgRole.get() === "admin", o;
|
|
2746
2791
|
}
|
|
2747
2792
|
}
|
|
2748
|
-
class
|
|
2793
|
+
class Qt {
|
|
2749
2794
|
constructor(t) {
|
|
2750
2795
|
this._storage = t;
|
|
2751
2796
|
}
|
|
@@ -2778,7 +2823,7 @@ class Kt {
|
|
|
2778
2823
|
// ── Internal helpers ───────────────────────────────────────────────────────
|
|
2779
2824
|
async _get(t, e) {
|
|
2780
2825
|
try {
|
|
2781
|
-
const r = await (await
|
|
2826
|
+
const r = await (await oe(_(this._storage, `${t}/${e}.json.gz`))).arrayBuffer(), s = new DecompressionStream("gzip"), a = s.writable.getWriter(), n = s.readable.getReader();
|
|
2782
2827
|
a.write(new Uint8Array(r)), a.close();
|
|
2783
2828
|
const p = [];
|
|
2784
2829
|
let c = await n.read();
|
|
@@ -2790,7 +2835,7 @@ class Kt {
|
|
|
2790
2835
|
d.set(w, g), g += w.length;
|
|
2791
2836
|
return JSON.parse(new TextDecoder().decode(d));
|
|
2792
2837
|
} catch (o) {
|
|
2793
|
-
if (
|
|
2838
|
+
if (nr(o)) return;
|
|
2794
2839
|
throw o;
|
|
2795
2840
|
}
|
|
2796
2841
|
}
|
|
@@ -2812,7 +2857,7 @@ class Kt {
|
|
|
2812
2857
|
);
|
|
2813
2858
|
}
|
|
2814
2859
|
}
|
|
2815
|
-
function
|
|
2860
|
+
function nr(i) {
|
|
2816
2861
|
return typeof i == "object" && i !== null && "code" in i && i.code === "storage/object-not-found";
|
|
2817
2862
|
}
|
|
2818
2863
|
const b = {
|
|
@@ -6094,7 +6139,7 @@ class gt {
|
|
|
6094
6139
|
), this._nsMap = t, t;
|
|
6095
6140
|
}
|
|
6096
6141
|
}
|
|
6097
|
-
class
|
|
6142
|
+
class pr {
|
|
6098
6143
|
constructor(t, e, o, r, s) {
|
|
6099
6144
|
this._api = t, this._projectId = e, this._queryCache = r, this._graphType = s, this._currentLang = o, this._api.setLanguage(o), this._contentCategories = new k([]), this._entityCategories = new k([]), this._relationships = new k([]), this.availableContentCategories = this._contentCategories.asReadonly(), this.availableEntityCategories = this._entityCategories.asReadonly(), this.availableEntityRelationships = this._relationships.asReadonly(), this.ready = this._load(o).catch(
|
|
6100
6145
|
(a) => console.error("[CueProjectSchema] Initial load failed:", a)
|
|
@@ -6223,8 +6268,8 @@ GROUP BY ?iri ?parent`;
|
|
|
6223
6268
|
});
|
|
6224
6269
|
}
|
|
6225
6270
|
}
|
|
6226
|
-
const
|
|
6227
|
-
class
|
|
6271
|
+
const lr = "https://qlever.dev/api/osm-planet";
|
|
6272
|
+
class me {
|
|
6228
6273
|
constructor(t, e, o = dt, r, s) {
|
|
6229
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(
|
|
6230
6275
|
(a) => console.error("[CueProjectEntities] Entity graph fetch failed:", a)
|
|
@@ -6663,7 +6708,7 @@ GROUP BY ?e1Cat ?e2Cat`;
|
|
|
6663
6708
|
const o = e.map((n) => `<${n}>`).join(" "), r = `PREFIX geo: <${A.geo}>
|
|
6664
6709
|
SELECT * WHERE {
|
|
6665
6710
|
VALUES ?s { ${o} }
|
|
6666
|
-
SERVICE <${
|
|
6711
|
+
SERVICE <${lr}> {
|
|
6667
6712
|
?s geo:hasGeometry/geo:asWKT ?wkt
|
|
6668
6713
|
}
|
|
6669
6714
|
}`, s = await this._api.sparql(
|
|
@@ -7013,9 +7058,9 @@ WHERE {
|
|
|
7013
7058
|
return o?.count ? parseInt(o.count.value, 10) : 0;
|
|
7014
7059
|
}
|
|
7015
7060
|
}
|
|
7016
|
-
class
|
|
7061
|
+
class cr {
|
|
7017
7062
|
constructor(t, e, { language: o, queryCache: r, rdfBase: s = dt, graphType: a }) {
|
|
7018
|
-
this._api = t, this._projectId = e, this.schema = new
|
|
7063
|
+
this._api = t, this._projectId = e, this.schema = new pr(t, e, o, r, a), this.entities = new me(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));
|
|
7019
7064
|
}
|
|
7020
7065
|
_api;
|
|
7021
7066
|
_projectId;
|
|
@@ -7133,7 +7178,7 @@ class pr {
|
|
|
7133
7178
|
this._destroyed = !0, this._searchResults.set(void 0);
|
|
7134
7179
|
}
|
|
7135
7180
|
}
|
|
7136
|
-
function
|
|
7181
|
+
function Xt(i, t) {
|
|
7137
7182
|
return new Promise((e) => {
|
|
7138
7183
|
const o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
7139
7184
|
for (const m of i)
|
|
@@ -7169,7 +7214,7 @@ function Qt(i, t) {
|
|
|
7169
7214
|
});
|
|
7170
7215
|
}
|
|
7171
7216
|
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 || {});
|
|
7172
|
-
const
|
|
7217
|
+
const hr = {
|
|
7173
7218
|
".aac": {
|
|
7174
7219
|
type: l.AUDIO,
|
|
7175
7220
|
open: !0,
|
|
@@ -8030,21 +8075,21 @@ const lr = {
|
|
|
8030
8075
|
}
|
|
8031
8076
|
};
|
|
8032
8077
|
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 + "";
|
|
8033
|
-
const { namedNode:
|
|
8034
|
-
|
|
8035
|
-
const { namedNode:
|
|
8036
|
-
|
|
8037
|
-
function
|
|
8078
|
+
const { namedNode: dr, literal: Rr } = j;
|
|
8079
|
+
dr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
8080
|
+
const { namedNode: Ar } = j, { namedNode: gr, literal: Pr } = j;
|
|
8081
|
+
gr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
8082
|
+
function ur(i) {
|
|
8038
8083
|
const t = i.split(".");
|
|
8039
8084
|
return t.length > 1 ? "." + t.pop()?.toLowerCase() : "";
|
|
8040
8085
|
}
|
|
8041
|
-
const { namedNode:
|
|
8042
|
-
|
|
8043
|
-
const { namedNode:
|
|
8044
|
-
|
|
8045
|
-
function
|
|
8046
|
-
const c =
|
|
8047
|
-
a === void 0 && (a =
|
|
8086
|
+
const { namedNode: mr, literal: Or } = j;
|
|
8087
|
+
mr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
8088
|
+
const { namedNode: wr, literal: Dr } = j;
|
|
8089
|
+
wr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
|
|
8090
|
+
function Yt(i, t, e, o, r, s, a, n = !1, p = !1) {
|
|
8091
|
+
const c = ur(i), h = D(o), d = `${t}/${h}${c}`;
|
|
8092
|
+
a === void 0 && (a = hr[c]?.mime ?? "application/octet-stream");
|
|
8048
8093
|
const g = to(i, r);
|
|
8049
8094
|
return {
|
|
8050
8095
|
name: i,
|
|
@@ -8071,7 +8116,7 @@ async function U() {
|
|
|
8071
8116
|
"fs/promises"
|
|
8072
8117
|
);
|
|
8073
8118
|
}
|
|
8074
|
-
async function
|
|
8119
|
+
async function Zt(i) {
|
|
8075
8120
|
if (typeof window < "u")
|
|
8076
8121
|
throw new Error(
|
|
8077
8122
|
`Cannot read file from path "${i}" in a browser environment. Provide file.data (Uint8Array) instead.`
|
|
@@ -8080,10 +8125,10 @@ async function Yt(i) {
|
|
|
8080
8125
|
return t(i);
|
|
8081
8126
|
}
|
|
8082
8127
|
let q = null, G = null, H = null;
|
|
8083
|
-
function
|
|
8128
|
+
function Lr(i) {
|
|
8084
8129
|
H = i, G = null, q = null;
|
|
8085
8130
|
}
|
|
8086
|
-
async function
|
|
8131
|
+
async function fr() {
|
|
8087
8132
|
if (typeof window < "u") {
|
|
8088
8133
|
if (!H)
|
|
8089
8134
|
throw new Error(
|
|
@@ -8105,7 +8150,7 @@ async function mr() {
|
|
|
8105
8150
|
await a.default({ module_or_path: r }), q = a.scan;
|
|
8106
8151
|
}
|
|
8107
8152
|
}
|
|
8108
|
-
const
|
|
8153
|
+
const yr = "qlever", $ = 1e3, ut = "cue:pending:";
|
|
8109
8154
|
async function mt(i) {
|
|
8110
8155
|
const { tmpdir: t } = await import(
|
|
8111
8156
|
/* webpackIgnore: true */
|
|
@@ -8116,7 +8161,7 @@ async function mt(i) {
|
|
|
8116
8161
|
);
|
|
8117
8162
|
return e(t(), `cue-sync-pending-${i}.json`);
|
|
8118
8163
|
}
|
|
8119
|
-
async function
|
|
8164
|
+
async function Jt(i) {
|
|
8120
8165
|
if (typeof window < "u") {
|
|
8121
8166
|
const t = window.localStorage.getItem(`${ut}${i}`);
|
|
8122
8167
|
return t ? JSON.parse(t) : null;
|
|
@@ -8128,7 +8173,7 @@ async function Zt(i) {
|
|
|
8128
8173
|
return null;
|
|
8129
8174
|
}
|
|
8130
8175
|
}
|
|
8131
|
-
async function
|
|
8176
|
+
async function te(i) {
|
|
8132
8177
|
const t = JSON.stringify(i);
|
|
8133
8178
|
if (typeof window < "u") {
|
|
8134
8179
|
window.localStorage.setItem(`${ut}${i.spaceId}`, t);
|
|
@@ -8136,7 +8181,7 @@ async function Jt(i) {
|
|
|
8136
8181
|
}
|
|
8137
8182
|
await (await U()).writeFile(await mt(i.spaceId), t, "utf-8");
|
|
8138
8183
|
}
|
|
8139
|
-
async function
|
|
8184
|
+
async function br(i) {
|
|
8140
8185
|
if (typeof window < "u") {
|
|
8141
8186
|
window.localStorage.removeItem(`${ut}${i}`);
|
|
8142
8187
|
return;
|
|
@@ -8146,7 +8191,7 @@ async function fr(i) {
|
|
|
8146
8191
|
} catch {
|
|
8147
8192
|
}
|
|
8148
8193
|
}
|
|
8149
|
-
class
|
|
8194
|
+
class vr {
|
|
8150
8195
|
constructor(t, e, o, r) {
|
|
8151
8196
|
this._auth = t, this._projects = e, this._blob = o, this._gatewayUrl = r;
|
|
8152
8197
|
}
|
|
@@ -8202,7 +8247,7 @@ class yr {
|
|
|
8202
8247
|
*/
|
|
8203
8248
|
async flushPendingMetadata(t, e, o) {
|
|
8204
8249
|
this._legacy = o ?? !1;
|
|
8205
|
-
const r = await
|
|
8250
|
+
const r = await Jt(t);
|
|
8206
8251
|
if (!(!r || r.items.length === 0)) {
|
|
8207
8252
|
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 ⏳`);
|
|
8208
8253
|
try {
|
|
@@ -8225,7 +8270,7 @@ class yr {
|
|
|
8225
8270
|
this._api?.getConsumption(o) ?? Promise.reject(new Error("CueSyncApi is not bound to a CueApi instance")),
|
|
8226
8271
|
this._fetchUnitCreditMap(s),
|
|
8227
8272
|
this._fetchTierNames()
|
|
8228
|
-
]), f = (await
|
|
8273
|
+
]), f = (await Xt(t, h)).localNotOnRemote ?? [], E = f.length > 0 ? await this.scanCost(f) : [];
|
|
8229
8274
|
let m = 0, x = 0;
|
|
8230
8275
|
for (const v of E) {
|
|
8231
8276
|
m += v.units;
|
|
@@ -8257,14 +8302,14 @@ class yr {
|
|
|
8257
8302
|
const [d, g] = await Promise.all([
|
|
8258
8303
|
this._listRemoteFiles(h, o, r, a),
|
|
8259
8304
|
this._api?.getConsumption(o) ?? Promise.reject(new Error("CueSyncApi is not bound to a CueApi instance"))
|
|
8260
|
-
]), { unitsAvailable: w } = g, u = await
|
|
8305
|
+
]), { unitsAvailable: w } = g, u = await Xt(t, d);
|
|
8261
8306
|
a && (console.info(`Total local files: ${t.length}`), console.info(`Total remote files: ${d.length}`), console.info(
|
|
8262
8307
|
`Total files to sync: ${(u.localNotOnRemote?.length ?? 0) + u.localNotOnRemotePathOnly.length}`
|
|
8263
8308
|
));
|
|
8264
8309
|
let f = u.syncCount, E = u.syncSize, m = 0, x = !1;
|
|
8265
8310
|
const I = u.localNotOnRemote ?? [];
|
|
8266
8311
|
if (I.length > 0) {
|
|
8267
|
-
const C = (await this.scanCost(I)).reduce((P,
|
|
8312
|
+
const C = (await this.scanCost(I)).reduce((P, fe) => P + fe.units, 0);
|
|
8268
8313
|
if (C > w)
|
|
8269
8314
|
throw new Error(
|
|
8270
8315
|
`Insufficient units: ${C} units required but only ${w} available.`
|
|
@@ -8273,7 +8318,7 @@ class yr {
|
|
|
8273
8318
|
await this._initPendingBatch(o, a), a && I.length && console.info("Syncing missing files ⏳");
|
|
8274
8319
|
for (const y of I)
|
|
8275
8320
|
try {
|
|
8276
|
-
const C =
|
|
8321
|
+
const C = Yt(
|
|
8277
8322
|
y.relativePath,
|
|
8278
8323
|
o,
|
|
8279
8324
|
s,
|
|
@@ -8281,7 +8326,7 @@ class yr {
|
|
|
8281
8326
|
r
|
|
8282
8327
|
);
|
|
8283
8328
|
if (!C.blob_name) throw new Error(`blob_name missing for ${y.relativePath}`);
|
|
8284
|
-
const P = y.data ?? new Uint8Array(await
|
|
8329
|
+
const P = y.data ?? new Uint8Array(await Zt(y.fullPath));
|
|
8285
8330
|
await this._blob.uploadRaw(
|
|
8286
8331
|
C.blob_name,
|
|
8287
8332
|
P,
|
|
@@ -8320,7 +8365,7 @@ class yr {
|
|
|
8320
8365
|
async _getOrCreateGraph(t, e) {
|
|
8321
8366
|
const o = this._graphMap.get(t);
|
|
8322
8367
|
if (o) return o;
|
|
8323
|
-
const s = (await this._projects.getProject(t))?.projectSettings?.graph?.type ??
|
|
8368
|
+
const s = (await this._projects.getProject(t))?.projectSettings?.graph?.type ?? yr, a = s === "qlever" ? `${this._gatewayUrl}${ne}` : `${this._gatewayUrl}${ie}`, n = s === "qlever" ? `${this._gatewayUrl}${ho}` : `${this._gatewayUrl}${lo}`, p = new Ze({
|
|
8324
8369
|
graphType: s,
|
|
8325
8370
|
queryEndpoint: a,
|
|
8326
8371
|
updateEndpoint: n,
|
|
@@ -8386,7 +8431,7 @@ WHERE {
|
|
|
8386
8431
|
}
|
|
8387
8432
|
async _initPendingBatch(t, e) {
|
|
8388
8433
|
this._flushTimer !== null && (clearInterval(this._flushTimer), this._flushTimer = null), this._pendingSpaceId = t, this._pendingItems = [];
|
|
8389
|
-
const o = await
|
|
8434
|
+
const o = await Jt(t);
|
|
8390
8435
|
if (o && o.items.length > 0) {
|
|
8391
8436
|
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 ⏳`);
|
|
8392
8437
|
try {
|
|
@@ -8407,7 +8452,7 @@ WHERE {
|
|
|
8407
8452
|
typeof r == "object" && typeof r.unref == "function" && r.unref(), this._flushTimer = r;
|
|
8408
8453
|
}
|
|
8409
8454
|
async _queueFileLocation(t) {
|
|
8410
|
-
this._pendingItems.push(t), this._pendingSpaceId && await
|
|
8455
|
+
this._pendingItems.push(t), this._pendingSpaceId && await te({ spaceId: this._pendingSpaceId, items: this._pendingItems });
|
|
8411
8456
|
}
|
|
8412
8457
|
/**
|
|
8413
8458
|
* Flush all queued file-location items to the commands API in a single batch.
|
|
@@ -8422,18 +8467,18 @@ WHERE {
|
|
|
8422
8467
|
}
|
|
8423
8468
|
async _flushBatch(t, e, o) {
|
|
8424
8469
|
const r = [...t];
|
|
8425
|
-
this._pendingSpaceId === e && (this._pendingItems = []), await
|
|
8470
|
+
this._pendingSpaceId === e && (this._pendingItems = []), await br(e);
|
|
8426
8471
|
try {
|
|
8427
8472
|
for (let s = 0; s < r.length; s += $)
|
|
8428
8473
|
await this._postFssBatch(r.slice(s, s + $), e);
|
|
8429
8474
|
o && console.info(`Wrote ${r.length} file location(s) to commands API ✅`);
|
|
8430
8475
|
} catch (s) {
|
|
8431
8476
|
const a = [...r, ...this._pendingItems];
|
|
8432
|
-
throw this._pendingItems = a, await
|
|
8477
|
+
throw this._pendingItems = a, await te({ spaceId: e, items: a }), s;
|
|
8433
8478
|
}
|
|
8434
8479
|
}
|
|
8435
8480
|
async _postFssBatch(t, e) {
|
|
8436
|
-
const o = this._legacy ? `${this._gatewayUrl}${
|
|
8481
|
+
const o = this._legacy ? `${this._gatewayUrl}${Dt}?blob=true` : `${this._gatewayUrl}${Dt}`;
|
|
8437
8482
|
let r;
|
|
8438
8483
|
try {
|
|
8439
8484
|
r = await this._auth.authenticatedFetch(o, {
|
|
@@ -8463,14 +8508,14 @@ WHERE {
|
|
|
8463
8508
|
* shown to the user before or after calling {@link sync}.
|
|
8464
8509
|
*/
|
|
8465
8510
|
async scanCost(t) {
|
|
8466
|
-
if (G || (G =
|
|
8511
|
+
if (G || (G = fr()), await G, !q) throw new Error("WASM scan function not initialised");
|
|
8467
8512
|
const e = 200, o = /* @__PURE__ */ new Map();
|
|
8468
8513
|
for (let r = 0; r < t.length; r += e) {
|
|
8469
8514
|
const s = t.slice(r, r + e), a = await Promise.all(
|
|
8470
8515
|
s.map(async (p) => ({
|
|
8471
8516
|
originalPath: p.relativePath,
|
|
8472
8517
|
// Use pre-loaded data if available (browser), otherwise read from disk (Node.js).
|
|
8473
|
-
data: p.data ?? new Uint8Array(await
|
|
8518
|
+
data: p.data ?? new Uint8Array(await Zt(p.fullPath))
|
|
8474
8519
|
}))
|
|
8475
8520
|
), n = q(a);
|
|
8476
8521
|
for (const p of n) {
|
|
@@ -8530,7 +8575,7 @@ WHERE {
|
|
|
8530
8575
|
const { spaceId: o, providerId: r, userId: s, signal: a, onProgress: n } = e;
|
|
8531
8576
|
if (!t.data)
|
|
8532
8577
|
throw new Error("syncBrowserFile requires file.data (Uint8Array). Read the file with File.arrayBuffer() first.");
|
|
8533
|
-
const p =
|
|
8578
|
+
const p = Yt(t.relativePath, o, s, t.md5, r);
|
|
8534
8579
|
if (!p.blob_name) throw new Error(`blob_name missing for ${t.relativePath}`);
|
|
8535
8580
|
await this._blob.uploadRaw(
|
|
8536
8581
|
p.blob_name,
|
|
@@ -8574,7 +8619,7 @@ WHERE {
|
|
|
8574
8619
|
s({ percent: a, syncCount: t, totalCount: e, syncSize: o, totalSize: r });
|
|
8575
8620
|
}
|
|
8576
8621
|
}
|
|
8577
|
-
const
|
|
8622
|
+
const ee = {
|
|
8578
8623
|
production: {
|
|
8579
8624
|
gatewayUrl: "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app",
|
|
8580
8625
|
tokenUrl: "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app/token",
|
|
@@ -8594,7 +8639,7 @@ const te = {
|
|
|
8594
8639
|
firestoreEmulatorPort: 8080
|
|
8595
8640
|
}
|
|
8596
8641
|
};
|
|
8597
|
-
class
|
|
8642
|
+
class we {
|
|
8598
8643
|
auth;
|
|
8599
8644
|
api;
|
|
8600
8645
|
projects;
|
|
@@ -8621,7 +8666,7 @@ class me {
|
|
|
8621
8666
|
* ```
|
|
8622
8667
|
*/
|
|
8623
8668
|
get gis() {
|
|
8624
|
-
return this._gis || (this._gis = new
|
|
8669
|
+
return this._gis || (this._gis = new ar(
|
|
8625
8670
|
() => this.api.getAuthHeaders(),
|
|
8626
8671
|
this._endpoints.gatewayUrl
|
|
8627
8672
|
)), this._gis;
|
|
@@ -8631,17 +8676,17 @@ class me {
|
|
|
8631
8676
|
"Using default SDK app settings. Contact QAECY for your own configuration for any production code."
|
|
8632
8677
|
);
|
|
8633
8678
|
const o = t.apiKey ?? Y.apiKey, r = t.appId ?? Y.appId, s = t.measurementId ?? Y.measurementId, a = t.environment ?? "production";
|
|
8634
|
-
this._endpoints = { ...
|
|
8679
|
+
this._endpoints = { ...ee[a], ...t.endpoints }, this._isEmulator = a === "emulator", this._app = ye().find((g) => g.name === "[DEFAULT]") ?? be({
|
|
8635
8680
|
apiKey: o,
|
|
8636
8681
|
appId: r,
|
|
8637
8682
|
measurementId: s,
|
|
8638
|
-
authDomain: `${
|
|
8639
|
-
projectId:
|
|
8683
|
+
authDomain: `${Et}.firebaseapp.com`,
|
|
8684
|
+
projectId: Et,
|
|
8640
8685
|
messagingSenderId: eo
|
|
8641
|
-
}), this.auth = new
|
|
8642
|
-
const n = T(this._app,
|
|
8686
|
+
}), this.auth = new jt(this._app, this._isEmulator, this._endpoints), this.projects = new Gt(this.auth, this._app, this._isEmulator, this._endpoints), this._storageRaw = T(this._app, Ct), this._storageProcessed = T(this._app, Tt);
|
|
8687
|
+
const n = T(this._app, Rt), p = T(this._app, St), c = T(this._app, It), h = T(this._app, At);
|
|
8643
8688
|
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);
|
|
8644
|
-
const d = new
|
|
8689
|
+
const d = new _t({
|
|
8645
8690
|
storageRaw: this._storageRaw,
|
|
8646
8691
|
storageProcessed: this._storageProcessed,
|
|
8647
8692
|
storagePublic: n,
|
|
@@ -8649,12 +8694,12 @@ class me {
|
|
|
8649
8694
|
storageChatSessions: c,
|
|
8650
8695
|
storagePersistence: h
|
|
8651
8696
|
});
|
|
8652
|
-
this.storage = new
|
|
8697
|
+
this.storage = new Ut(d), this.profile = new Ht(
|
|
8653
8698
|
this.auth,
|
|
8654
8699
|
this._app,
|
|
8655
8700
|
this._isEmulator,
|
|
8656
8701
|
this._endpoints.gatewayUrl
|
|
8657
|
-
), this.privileges = new
|
|
8702
|
+
), this.privileges = new Kt(this.auth.isSuperAdmin), this._isEmulator && K(h, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), this.cache = new Qt(h);
|
|
8658
8703
|
}
|
|
8659
8704
|
/**
|
|
8660
8705
|
* Create a `Cue` instance from an already-initialized Firebase app.
|
|
@@ -8673,16 +8718,16 @@ class me {
|
|
|
8673
8718
|
* });
|
|
8674
8719
|
*/
|
|
8675
8720
|
static fromApp(t, e = {}) {
|
|
8676
|
-
const o = e.environment ?? "production", r = { ...
|
|
8721
|
+
const o = e.environment ?? "production", r = { ...ee[o], ...e.endpoints }, s = new jt(t, !1, r), a = new Gt(s, t, !1, r), n = T(t, Ct), p = T(t, Tt), c = T(t, Rt), h = T(t, St), d = T(t, It), g = T(t, At), w = new _t({
|
|
8677
8722
|
storageRaw: n,
|
|
8678
8723
|
storageProcessed: p,
|
|
8679
8724
|
storagePublic: c,
|
|
8680
8725
|
storageLogs: h,
|
|
8681
8726
|
storageChatSessions: d,
|
|
8682
8727
|
storagePersistence: g
|
|
8683
|
-
}), u = new
|
|
8728
|
+
}), u = new vr(s, a, w, r.gatewayUrl), f = new Mt(s, r.gatewayUrl, a, u);
|
|
8684
8729
|
u._bindApi(f);
|
|
8685
|
-
const E = new
|
|
8730
|
+
const E = new Ht(s, t, !1, r.gatewayUrl), m = Object.create(we.prototype), x = new Kt(s.isSuperAdmin), I = new Qt(g), v = new Ut(w);
|
|
8686
8731
|
return Object.assign(m, {
|
|
8687
8732
|
_app: t,
|
|
8688
8733
|
_endpoints: r,
|
|
@@ -8700,7 +8745,7 @@ class me {
|
|
|
8700
8745
|
}
|
|
8701
8746
|
/** Override in subclasses to provide a custom CueApi (e.g. with sync). */
|
|
8702
8747
|
_buildApi(t) {
|
|
8703
|
-
return new
|
|
8748
|
+
return new Mt(this.auth, this._endpoints.gatewayUrl, t);
|
|
8704
8749
|
}
|
|
8705
8750
|
/** Convenience: get the current user's Firebase ID token */
|
|
8706
8751
|
getToken(t = !1) {
|
|
@@ -8725,7 +8770,7 @@ class me {
|
|
|
8725
8770
|
get: (r) => this.cache.getQueryCache(t, r).then((s) => s?.results),
|
|
8726
8771
|
set: (r, s) => this.cache.setQueryCache(t, r, { query: r, results: s })
|
|
8727
8772
|
};
|
|
8728
|
-
return new
|
|
8773
|
+
return new cr(this.api, t, { ...e, queryCache: o });
|
|
8729
8774
|
}
|
|
8730
8775
|
/**
|
|
8731
8776
|
* Creates a `CueProjectEntities` instance for the given project, with the
|
|
@@ -8749,7 +8794,7 @@ class me {
|
|
|
8749
8794
|
get: (r) => this.cache.getQueryCache(t, r).then((s) => s?.results),
|
|
8750
8795
|
set: (r, s) => this.cache.setQueryCache(t, r, { query: r, results: s })
|
|
8751
8796
|
};
|
|
8752
|
-
return new
|
|
8797
|
+
return new me(
|
|
8753
8798
|
this.api,
|
|
8754
8799
|
t,
|
|
8755
8800
|
e?.rdfBase,
|
|
@@ -8804,29 +8849,30 @@ class me {
|
|
|
8804
8849
|
}
|
|
8805
8850
|
}
|
|
8806
8851
|
export {
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8852
|
+
It as B,
|
|
8853
|
+
we as C,
|
|
8854
|
+
Vt as R,
|
|
8855
|
+
Mt as a,
|
|
8856
|
+
jt as b,
|
|
8857
|
+
Qt as c,
|
|
8858
|
+
yo as d,
|
|
8859
|
+
ar as e,
|
|
8860
|
+
Kt as f,
|
|
8861
|
+
Ht as g,
|
|
8862
|
+
pt as h,
|
|
8863
|
+
me as i,
|
|
8819
8864
|
pr as j,
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8865
|
+
cr as k,
|
|
8866
|
+
Gt as l,
|
|
8867
|
+
k as m,
|
|
8868
|
+
Ut as n,
|
|
8869
|
+
vr as o,
|
|
8870
|
+
wo as p,
|
|
8871
|
+
Lr as q,
|
|
8872
|
+
ct as r,
|
|
8828
8873
|
ht as s,
|
|
8829
|
-
|
|
8830
|
-
|
|
8831
|
-
|
|
8874
|
+
St as t,
|
|
8875
|
+
At as u,
|
|
8876
|
+
Rt as v,
|
|
8877
|
+
_t as w
|
|
8832
8878
|
};
|