@geode/opengeodeweb-front 10.43.0 → 10.43.1-rc.2

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.
@@ -1,6 +1,10 @@
1
1
  import Ajv from "ajv";
2
2
  //#region shared/utils/validate_schema.ts
3
3
  function validateSchema(schema, body) {
4
+ if (body instanceof FormData) return {
5
+ valid: true,
6
+ error: "No errors"
7
+ };
4
8
  const ajv = new Ajv();
5
9
  for (const keyword of [
6
10
  "methods",
@@ -32,7 +32,7 @@ function newItemId(): number {
32
32
  return lastItemId;
33
33
  }
34
34
  const planes = ref<ClippingPlane[]>([{ id: newItemId(), origin: undefined, normal: [1, 0, 0] }]);
35
- const allItems = dataStore.refAllItems();
35
+ const allItems = dataStore.refRegisteredItems();
36
36
  const sliceEnabled = ref<boolean>(false);
37
37
  const slices = ref<{ id: number; axis: SliceAxis; index: number }[]>([
38
38
  { id: newItemId(), axis: DEFAULT_SLICE_AXIS, index: 0 },
@@ -43,7 +43,7 @@ const targetAllVisible = ref<boolean>(true);
43
43
  const selectedDatasetIds = ref<string[]>([]);
44
44
  const factor = ref<number>(factorRange.defaultValue);
45
45
 
46
- const allItems = dataStore.refAllItems();
46
+ const allItems = dataStore.refRegisteredItems();
47
47
  const availableDatasets = computed<{ title: string; value: string }[]>(() =>
48
48
  allItems.value.map((item) => ({
49
49
  title: item.name || item.id,
@@ -8,7 +8,6 @@ import { type TreeviewSnapshot, useTreeviewStore } from "@ogw_front/stores/treev
8
8
  import type { CameraSnapshot } from "@ogw_internal/stores/hybrid_viewer/camera";
9
9
  import type { ModelComponentRecord } from "@ogw_front/stores/data_helpers/mesh.js";
10
10
  import type { ModelComponentRelationRecord } from "@ogw_front/stores/data.js";
11
- import { fetchRaw } from "@ogw_shared/utils/fetch_raw";
12
11
  import { importWorkflowFromSnapshot } from "@ogw_front/utils/import_workflow";
13
12
  import { useAppStore } from "@ogw_front/stores/app";
14
13
  import { useBackStore } from "@ogw_front/stores/back";
@@ -29,23 +28,7 @@ interface ProjectSnapshot {
29
28
  dataStyle?: DataStyleSnapshot;
30
29
  }
31
30
 
32
- // The backend response is an untyped network payload; this is the one place its shape is asserted.
33
- function isImportSnapshotResponse(value: unknown): value is { snapshot?: ProjectSnapshot } {
34
- return typeof value === "object" && value !== null;
35
- }
36
-
37
- function isFileDownloadData(
38
- value: unknown,
39
- ): value is string | ArrayBuffer | ArrayBufferView | Blob {
40
- return (
41
- typeof value === "string" ||
42
- value instanceof ArrayBuffer ||
43
- ArrayBuffer.isView(value) ||
44
- value instanceof Blob
45
- );
46
- }
47
-
48
- async function exportProject(): Promise<{ result: unknown }> {
31
+ async function exportProject(): Promise<{ result: Blob }> {
49
32
  const appStore = useAppStore();
50
33
  const backStore = useBackStore();
51
34
  const feedbackStore = useFeedbackStore();
@@ -53,16 +36,7 @@ async function exportProject(): Promise<{ result: unknown }> {
53
36
  const schema = back_schemas.opengeodeweb_back.export_project;
54
37
  const defaultName = "project.vease";
55
38
  const params = { snapshot, filename: defaultName };
56
- const result = await fetchRaw({
57
- route: schema.$id,
58
- params,
59
- method: schema.methods[0],
60
- baseURL: backStore.base_url,
61
- });
62
-
63
- if (!isFileDownloadData(result)) {
64
- throw new Error("Unexpected export_project response type");
65
- }
39
+ const result = await backStore.request({ schema, params });
66
40
  fileDownload(result, defaultName);
67
41
  feedbackStore.add_success("Project exported successfully");
68
42
  return { result };
@@ -119,13 +93,8 @@ async function importProject(file: File): Promise<void> {
119
93
  }
120
94
  form.append("file", file, originalFileName);
121
95
 
122
- const result = await fetchRaw({
123
- route: importProjectSchema.$id,
124
- params: form,
125
- method: importProjectSchema.methods[0],
126
- baseURL: backStore.base_url,
127
- });
128
- const snapshot = (isImportSnapshotResponse(result) ? result.snapshot : undefined) ?? {};
96
+ const result = await backStore.request({ schema: importProjectSchema, params: form });
97
+ const snapshot: ProjectSnapshot = result.snapshot;
129
98
 
130
99
  treeviewStore.isImporting = true;
131
100
 
@@ -127,6 +127,8 @@ export const useDataStore = defineStore("data", () => {
127
127
  refFormatedCollectionComponents,
128
128
  } = useDataCollections();
129
129
  const { getComponentRelations } = useDataRelations();
130
+ // Ids the viewer holds a pipeline for: an item is stored before it is registered, and non viewable items never are
131
+ const registeredIds = reactive(new Set<string>());
130
132
  async function item(id: string): Promise<DataItem> {
131
133
  const data_item = await data_db.get(id);
132
134
  if (!data_item) {
@@ -161,6 +163,13 @@ export const useDataStore = defineStore("data", () => {
161
163
  },
162
164
  );
163
165
  }
166
+ function isRegistered(id: string): boolean {
167
+ return registeredIds.has(id);
168
+ }
169
+ function refRegisteredItems(): ComputedRef<DataItem[]> {
170
+ const items = refAllItems();
171
+ return computed(() => items.value.filter((data_item) => isRegistered(data_item.id)));
172
+ }
164
173
  async function meshComponentType(modelId: string, geode_id: string): Promise<string | undefined> {
165
174
  const component = await model_components_db
166
175
  .where("[id+geode_id]")
@@ -179,6 +188,7 @@ export const useDataStore = defineStore("data", () => {
179
188
  params,
180
189
  timeout: 0,
181
190
  });
191
+ registeredIds.add(id);
182
192
  return result;
183
193
  }
184
194
  async function deregisterObject(id: string): Promise<unknown> {
@@ -186,6 +196,7 @@ export const useDataStore = defineStore("data", () => {
186
196
  const params = {
187
197
  id,
188
198
  };
199
+ registeredIds.delete(id);
189
200
  const result = await viewerStore.request({
190
201
  schema,
191
202
  params,
@@ -346,6 +357,7 @@ export const useDataStore = defineStore("data", () => {
346
357
  }
347
358
 
348
359
  async function clear(): Promise<void> {
360
+ registeredIds.clear();
349
361
  await data_db.clear();
350
362
  await model_components_db.clear();
351
363
  await model_components_relation_db.clear();
@@ -363,6 +375,8 @@ export const useDataStore = defineStore("data", () => {
363
375
  }
364
376
  return {
365
377
  refAllItems,
378
+ refRegisteredItems,
379
+ isRegistered,
366
380
  item,
367
381
  allItems,
368
382
  refItem,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geode/opengeodeweb-front",
3
- "version": "10.43.0",
3
+ "version": "10.43.1-rc.2",
4
4
  "description": "OpenSource Vue/Nuxt/Pinia/Vuetify framework for web applications",
5
5
  "homepage": "https://github.com/Geode-solutions/OpenGeodeWeb-Front",
6
6
  "bugs": {
@@ -64,9 +64,9 @@
64
64
  "prepublishOnly": "npm run build"
65
65
  },
66
66
  "dependencies": {
67
- "@geode/cloud-api": "latest",
68
- "@geode/opengeodeweb-back": "latest",
69
- "@geode/opengeodeweb-viewer": "latest",
67
+ "@geode/cloud-api": "next",
68
+ "@geode/opengeodeweb-back": "next",
69
+ "@geode/opengeodeweb-viewer": "next",
70
70
  "@kitware/vtk.js": "33.3.0",
71
71
  "@mdi/font": "7.4.47",
72
72
  "@msgpack/msgpack": "2.8.0",
@@ -3,6 +3,10 @@ import Ajv from "ajv";
3
3
  import type { JsonRpcSchema } from "./types.js";
4
4
 
5
5
  function validateSchema(schema: JsonRpcSchema, body: unknown): { valid: boolean; error: string } {
6
+ // A multipart body carries files, not the JSON params the schema describes; the route validates it itself.
7
+ if (body instanceof FormData) {
8
+ return { valid: true, error: "No errors" };
9
+ }
6
10
  const ajv = new Ajv();
7
11
  const list_keywords = ["methods", "route", "max_retry", "rpc", "response"];
8
12
  for (const keyword of list_keywords) {