@geode/opengeodeweb-front 10.44.0 → 10.44.1-rc.1

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.
Files changed (218) hide show
  1. package/app/components/ClippingPlanes.vue +7 -5
  2. package/app/components/CrsSelector.vue +2 -1
  3. package/app/components/ExtensionSelector.vue +8 -7
  4. package/app/components/FactorFilterPanel.vue +4 -4
  5. package/app/components/MissingFilesSelector.vue +2 -1
  6. package/app/components/ObjectSelector.vue +4 -3
  7. package/app/components/ThresholdCard.vue +6 -5
  8. package/app/components/ThresholdFilter.vue +11 -10
  9. package/app/components/TimeSeriesTargetSelector.vue +10 -7
  10. package/app/components/Viewer/ContextMenu/InfoCard.vue +12 -10
  11. package/app/components/Viewer/EdgedCurve/SpecificEdgesColoring.vue +72 -63
  12. package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +12 -10
  13. package/app/components/Viewer/Generic/Mesh/CellsColoring.vue +76 -71
  14. package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +8 -6
  15. package/app/components/Viewer/Generic/Mesh/EdgesColoring.vue +72 -63
  16. package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +12 -10
  17. package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +54 -45
  18. package/app/components/Viewer/Generic/Mesh/PolygonsColoring.vue +76 -73
  19. package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +8 -6
  20. package/app/components/Viewer/Generic/Mesh/PolyhedraColoring.vue +72 -67
  21. package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +8 -6
  22. package/app/components/Viewer/Generic/Model/BlocksOptions.vue +29 -21
  23. package/app/components/Viewer/Generic/Model/ComponentEdgesOptions.vue +8 -6
  24. package/app/components/Viewer/Generic/Model/ComponentPointsOptions.vue +8 -6
  25. package/app/components/Viewer/Generic/Model/CornerComponentOptions.vue +15 -7
  26. package/app/components/Viewer/Generic/Model/CornersOptions.vue +2 -1
  27. package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +13 -6
  28. package/app/components/Viewer/Generic/Model/LineComponentOptions.vue +19 -11
  29. package/app/components/Viewer/Generic/Model/LinesOptions.vue +2 -1
  30. package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +17 -10
  31. package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +3 -2
  32. package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +2 -1
  33. package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +3 -2
  34. package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +29 -21
  35. package/app/components/Viewer/ObjectTree/Base/ItemLabel.vue +2 -2
  36. package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +2 -3
  37. package/app/components/Viewer/Options/AttributeSelector.vue +11 -7
  38. package/app/components/Viewer/Options/ColoringTypeSelector.vue +10 -13
  39. package/app/components/Viewer/Options/TextureItem.vue +5 -4
  40. package/app/components/Viewer/Options/TexturesSelector.vue +5 -8
  41. package/app/components/Viewer/Options/TimeStepSlider.vue +3 -1
  42. package/app/components/Viewer/OverlappingObjectsPicker.vue +6 -13
  43. package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +40 -38
  44. package/app/components/Viewer/Solid/SpecificPolyhedraColoring.vue +69 -65
  45. package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +8 -6
  46. package/app/components/Viewer/Surface/PolygonsColoring.vue +73 -71
  47. package/app/components/Viewer/Surface/PolygonsOptions.vue +8 -6
  48. package/app/composables/attribute_coloring_style.ts +17 -12
  49. package/app/composables/attribute_selector.ts +9 -15
  50. package/app/composables/batch_style.ts +25 -16
  51. package/app/composables/batch_style_model.ts +6 -5
  52. package/app/composables/clipping_planes_widget.ts +2 -5
  53. package/app/composables/clipping_slices.ts +2 -1
  54. package/app/composables/hover_highlight.ts +17 -16
  55. package/app/composables/live_data_item.ts +3 -2
  56. package/app/composables/model_attribute_style.ts +2 -1
  57. package/app/composables/model_menu_context.ts +3 -4
  58. package/app/composables/model_tree.ts +3 -2
  59. package/app/composables/project_manager_helpers/types.ts +10 -4
  60. package/app/composables/tree_filter.ts +3 -3
  61. package/app/composables/tree_keyboard_nav.ts +1 -6
  62. package/app/composables/tree_scroll.ts +2 -0
  63. package/app/composables/use_overlapping_picker.ts +9 -9
  64. package/app/stores/basemap_helpers/georeferenced.ts +1 -1
  65. package/app/stores/basemap_helpers/viewer.ts +2 -1
  66. package/app/stores/crs.ts +6 -5
  67. package/app/stores/data.ts +84 -69
  68. package/app/stores/data_helpers/collections.ts +13 -21
  69. package/app/stores/data_helpers/mesh.ts +19 -24
  70. package/app/stores/data_helpers/relations.ts +12 -12
  71. package/app/stores/data_style.ts +26 -20
  72. package/app/stores/menu.ts +17 -11
  73. package/app/stores/treeview.ts +28 -27
  74. package/app/types/attribute.ts +37 -0
  75. package/app/types/identifiers.ts +72 -0
  76. package/app/types/style.ts +13 -0
  77. package/app/types/texture.ts +6 -0
  78. package/app/types/tree.ts +17 -0
  79. package/app/utils/attribute_range.ts +2 -1
  80. package/app/utils/attributes.ts +13 -4
  81. package/app/utils/basemap_tree.ts +3 -5
  82. package/app/utils/clipping_planes.ts +6 -4
  83. package/app/utils/clipping_planes_scene.ts +4 -3
  84. package/app/utils/crs.ts +4 -1
  85. package/app/utils/default_styles/constants.ts +8 -1
  86. package/app/utils/default_styles/mesh_components.ts +21 -25
  87. package/app/utils/default_styles/meshes.ts +7 -22
  88. package/app/utils/default_styles/model_components.ts +22 -26
  89. package/app/utils/default_styles/models.ts +11 -13
  90. package/app/utils/import_workflow.ts +37 -29
  91. package/app/utils/legacy_data_id.ts +16 -0
  92. package/app/utils/slice.ts +7 -2
  93. package/app/utils/threshold.ts +1 -8
  94. package/app/utils/threshold_sources.ts +8 -5
  95. package/app/utils/treeview.ts +3 -2
  96. package/internal/database/tables/data.ts +1 -1
  97. package/internal/database/tables/data_style.ts +1 -1
  98. package/internal/database/tables/model_components.ts +1 -1
  99. package/internal/database/tables/model_components_relation.ts +1 -1
  100. package/internal/stores/data_style/attribute_default.ts +14 -0
  101. package/internal/stores/data_style/attribute_types.ts +59 -0
  102. package/internal/stores/data_style/attribute_valid.ts +16 -0
  103. package/internal/stores/data_style/mesh/base_style.ts +17 -15
  104. package/internal/stores/data_style/mesh/cells/cell.ts +64 -49
  105. package/internal/stores/data_style/mesh/cells/cell_attribute.ts +42 -66
  106. package/internal/stores/data_style/mesh/cells/cell_config.ts +59 -53
  107. package/internal/stores/data_style/mesh/cells/color.ts +8 -7
  108. package/internal/stores/data_style/mesh/cells/common.ts +16 -15
  109. package/internal/stores/data_style/mesh/cells/index.ts +49 -47
  110. package/internal/stores/data_style/mesh/cells/opacity.ts +12 -10
  111. package/internal/stores/data_style/mesh/cells/textures.ts +8 -7
  112. package/internal/stores/data_style/mesh/cells/vertex.ts +66 -50
  113. package/internal/stores/data_style/mesh/cells/vertex_attribute.ts +37 -67
  114. package/internal/stores/data_style/mesh/cells/vertex_config.ts +62 -53
  115. package/internal/stores/data_style/mesh/cells/visibility.ts +11 -7
  116. package/internal/stores/data_style/mesh/edges/color.ts +8 -7
  117. package/internal/stores/data_style/mesh/edges/common.ts +13 -12
  118. package/internal/stores/data_style/mesh/edges/edge.ts +64 -49
  119. package/internal/stores/data_style/mesh/edges/edge_attribute.ts +42 -66
  120. package/internal/stores/data_style/mesh/edges/edge_config.ts +59 -53
  121. package/internal/stores/data_style/mesh/edges/index.ts +49 -47
  122. package/internal/stores/data_style/mesh/edges/opacity.ts +12 -10
  123. package/internal/stores/data_style/mesh/edges/vertex.ts +66 -50
  124. package/internal/stores/data_style/mesh/edges/vertex_attribute.ts +37 -67
  125. package/internal/stores/data_style/mesh/edges/vertex_config.ts +62 -53
  126. package/internal/stores/data_style/mesh/edges/visibility.ts +11 -7
  127. package/internal/stores/data_style/mesh/edges/width.ts +9 -7
  128. package/internal/stores/data_style/mesh/index.ts +27 -24
  129. package/internal/stores/data_style/mesh/points/color.ts +8 -7
  130. package/internal/stores/data_style/mesh/points/common.ts +16 -14
  131. package/internal/stores/data_style/mesh/points/index.ts +39 -37
  132. package/internal/stores/data_style/mesh/points/opacity.ts +12 -10
  133. package/internal/stores/data_style/mesh/points/size.ts +9 -7
  134. package/internal/stores/data_style/mesh/points/vertex.ts +66 -50
  135. package/internal/stores/data_style/mesh/points/vertex_attribute.ts +37 -67
  136. package/internal/stores/data_style/mesh/points/vertex_config.ts +62 -53
  137. package/internal/stores/data_style/mesh/points/visibility.ts +8 -6
  138. package/internal/stores/data_style/mesh/polygons/color.ts +8 -7
  139. package/internal/stores/data_style/mesh/polygons/common.ts +19 -15
  140. package/internal/stores/data_style/mesh/polygons/index.ts +49 -50
  141. package/internal/stores/data_style/mesh/polygons/opacity.ts +12 -10
  142. package/internal/stores/data_style/mesh/polygons/polygon.ts +66 -50
  143. package/internal/stores/data_style/mesh/polygons/polygon_attribute.ts +37 -67
  144. package/internal/stores/data_style/mesh/polygons/polygon_config.ts +65 -53
  145. package/internal/stores/data_style/mesh/polygons/textures.ts +8 -7
  146. package/internal/stores/data_style/mesh/polygons/vertex.ts +66 -50
  147. package/internal/stores/data_style/mesh/polygons/vertex_attribute.ts +37 -67
  148. package/internal/stores/data_style/mesh/polygons/vertex_config.ts +65 -53
  149. package/internal/stores/data_style/mesh/polygons/visibility.ts +12 -7
  150. package/internal/stores/data_style/mesh/polyhedra/color.ts +13 -9
  151. package/internal/stores/data_style/mesh/polyhedra/common.ts +13 -12
  152. package/internal/stores/data_style/mesh/polyhedra/index.ts +51 -51
  153. package/internal/stores/data_style/mesh/polyhedra/opacity.ts +12 -10
  154. package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +59 -53
  155. package/internal/stores/data_style/mesh/polyhedra/polyhedron_attribute.ts +46 -69
  156. package/internal/stores/data_style/mesh/polyhedra/polyhedron_config.ts +65 -55
  157. package/internal/stores/data_style/mesh/polyhedra/vertex.ts +66 -50
  158. package/internal/stores/data_style/mesh/polyhedra/vertex_attribute.ts +37 -67
  159. package/internal/stores/data_style/mesh/polyhedra/vertex_config.ts +65 -53
  160. package/internal/stores/data_style/mesh/polyhedra/visibility.ts +12 -7
  161. package/internal/stores/data_style/model/blocks/apply_coloring.ts +11 -12
  162. package/internal/stores/data_style/model/blocks/color.ts +25 -26
  163. package/internal/stores/data_style/model/blocks/coloring_groups.ts +5 -9
  164. package/internal/stores/data_style/model/blocks/common.ts +26 -22
  165. package/internal/stores/data_style/model/blocks/index.ts +8 -7
  166. package/internal/stores/data_style/model/blocks/polyhedron.ts +114 -135
  167. package/internal/stores/data_style/model/blocks/vertex.ts +110 -132
  168. package/internal/stores/data_style/model/blocks/visibility.ts +11 -9
  169. package/internal/stores/data_style/model/color.ts +55 -41
  170. package/internal/stores/data_style/model/common.ts +16 -14
  171. package/internal/stores/data_style/model/component_style.ts +0 -16
  172. package/internal/stores/data_style/model/corners/color.ts +21 -19
  173. package/internal/stores/data_style/model/corners/common.ts +26 -22
  174. package/internal/stores/data_style/model/corners/index.ts +21 -24
  175. package/internal/stores/data_style/model/corners/vertex.ts +103 -122
  176. package/internal/stores/data_style/model/corners/visibility.ts +11 -9
  177. package/internal/stores/data_style/model/edges/common.ts +7 -6
  178. package/internal/stores/data_style/model/edges/component.ts +63 -55
  179. package/internal/stores/data_style/model/edges/visibility.ts +24 -16
  180. package/internal/stores/data_style/model/edges/width.ts +10 -8
  181. package/internal/stores/data_style/model/index.ts +7 -6
  182. package/internal/stores/data_style/model/lines/apply_coloring.ts +11 -9
  183. package/internal/stores/data_style/model/lines/color.ts +25 -23
  184. package/internal/stores/data_style/model/lines/coloring_groups.ts +5 -9
  185. package/internal/stores/data_style/model/lines/common.ts +29 -21
  186. package/internal/stores/data_style/model/lines/edge.ts +109 -128
  187. package/internal/stores/data_style/model/lines/index.ts +8 -7
  188. package/internal/stores/data_style/model/lines/vertex.ts +109 -128
  189. package/internal/stores/data_style/model/lines/visibility.ts +11 -9
  190. package/internal/stores/data_style/model/points/common.ts +7 -6
  191. package/internal/stores/data_style/model/points/component.ts +62 -54
  192. package/internal/stores/data_style/model/points/index.ts +12 -7
  193. package/internal/stores/data_style/model/points/size.ts +10 -8
  194. package/internal/stores/data_style/model/points/visibility.ts +13 -8
  195. package/internal/stores/data_style/model/selection.ts +6 -11
  196. package/internal/stores/data_style/model/surfaces/apply_coloring.ts +11 -15
  197. package/internal/stores/data_style/model/surfaces/color.ts +31 -23
  198. package/internal/stores/data_style/model/surfaces/coloring_groups.ts +5 -9
  199. package/internal/stores/data_style/model/surfaces/common.ts +26 -22
  200. package/internal/stores/data_style/model/surfaces/index.ts +8 -7
  201. package/internal/stores/data_style/model/surfaces/polygon.ts +113 -138
  202. package/internal/stores/data_style/model/surfaces/vertex.ts +117 -133
  203. package/internal/stores/data_style/model/surfaces/visibility.ts +11 -9
  204. package/internal/stores/data_style/model/visibility.ts +18 -16
  205. package/internal/stores/data_style/model/visibility_dispatch.ts +4 -4
  206. package/internal/stores/data_style/state.ts +7 -6
  207. package/internal/stores/data_style/state_shared.ts +11 -10
  208. package/internal/stores/data_style/time_step.ts +21 -15
  209. package/internal/stores/data_style/types.ts +4 -3
  210. package/internal/stores/hybrid_viewer/camera.ts +11 -6
  211. package/internal/stores/hybrid_viewer/filters.ts +16 -14
  212. package/internal/stores/hybrid_viewer/highlight.ts +6 -5
  213. package/internal/stores/hybrid_viewer/scene.ts +20 -18
  214. package/internal/stores/hybrid_viewer/vtk_types.ts +2 -2
  215. package/internal/utils/api_fetch.ts +1 -1
  216. package/internal/utils/upload_file.ts +1 -7
  217. package/package.json +4 -4
  218. package/shared/utils/fetch_raw.ts +7 -8
@@ -2,6 +2,7 @@ import back_schemas, {
2
2
  type BasemapBuildResponse,
3
3
  } from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
4
4
  import type { MapStyle } from "@ogw_front/utils/basemap_tree";
5
+ import type { Opacity } from "@ogw_front/types/style";
5
6
  import { useBackStore } from "@ogw_front/stores/back";
6
7
  import { useDataStore } from "@ogw_front/stores/data";
7
8
  import { useViewerStore } from "@ogw_front/stores/viewer";
@@ -10,7 +11,7 @@ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed
10
11
  interface Layer {
11
12
  map: MapStyle;
12
13
  visible: boolean;
13
- opacity: number;
14
+ opacity: Opacity;
14
15
  crop: boolean;
15
16
  }
16
17
 
package/app/stores/crs.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { DataId, GeodeObjectType } from "@ogw_front/types/identifiers";
1
2
  import back_schemas, {
2
3
  type CRSList,
3
4
  } from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
@@ -46,13 +47,13 @@ export const useCrsStore = defineStore("crs", () => {
46
47
  const mismatched = new Map<string, CRSList | undefined>();
47
48
  for (const item of crsItems.value) {
48
49
  if (project !== undefined && !sameCrs(item.crs, project)) {
49
- mismatched.set(item.id, item.crs);
50
+ mismatched.set(item.data_id, item.crs);
50
51
  }
51
52
  }
52
53
  return mismatched;
53
54
  });
54
55
 
55
- async function fetchGeographicList(geodeObjectType: string): Promise<CRSList[]> {
56
+ async function fetchGeographicList(geodeObjectType: GeodeObjectType): Promise<CRSList[]> {
56
57
  try {
57
58
  const response = await backStore.request({
58
59
  schema: back_schemas.opengeodeweb_back.crs.geographic_list,
@@ -69,7 +70,7 @@ export const useCrsStore = defineStore("crs", () => {
69
70
  return [];
70
71
  }
71
72
 
72
- async function geographicList(geodeObjectType: string): Promise<CRSList[]> {
73
+ async function geographicList(geodeObjectType: GeodeObjectType): Promise<CRSList[]> {
73
74
  // The promise is cached, so dialogs opened together share a single request.
74
75
  // The back still checks each CRS against the list of the data dimension
75
76
  geographicListPromise ??= fetchGeographicList(geodeObjectType);
@@ -81,8 +82,8 @@ export const useCrsStore = defineStore("crs", () => {
81
82
  crsEditEnabled.value = true;
82
83
  }
83
84
 
84
- function requestCrsEdit(id: string): void {
85
- crsEditRequest.value = id;
85
+ function requestCrsEdit(dataId: DataId): void {
86
+ crsEditRequest.value = dataId;
86
87
  }
87
88
 
88
89
  function clearCrsEditRequest(): void {
@@ -6,19 +6,25 @@ import { useObservable } from "@vueuse/rxjs";
6
6
  import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
7
7
 
8
8
  // Local imports
9
+ import type {
10
+ DataId,
11
+ DataIdentified,
12
+ GeodeId,
13
+ GeodeIdentified,
14
+ GeodeObjectTyped,
15
+ ModelId,
16
+ ViewerTyped,
17
+ } from "@ogw_front/types/identifiers";
18
+ import { type LegacyDataId, fromLegacyDataId } from "@ogw_front/utils/legacy_data_id";
9
19
  import { type ModelComponentRecord, useDataMesh } from "./data_helpers/mesh.js";
20
+ import { type ModelComponentRelationRecord, useDataRelations } from "./data_helpers/relations.js";
10
21
  import { database } from "@ogw_internal/database/database.js";
11
22
  import { liveObservable } from "@ogw_front/utils/live_observable";
12
23
  import { useDataCollections } from "./data_helpers/collections.js";
13
- import { useDataRelations } from "./data_helpers/relations.js";
14
24
  import { useViewerStore } from "@ogw_front/stores/viewer";
15
25
 
16
- interface DataItem {
17
- id: string;
18
- geode_id: string;
26
+ interface DataItem extends DataIdentified, GeodeIdentified, GeodeObjectTyped, ViewerTyped {
19
27
  name: string;
20
- viewer_type: string;
21
- geode_object_type: string;
22
28
  visible: boolean;
23
29
  created_at: string;
24
30
  is_viewable?: boolean;
@@ -27,10 +33,9 @@ interface DataItem {
27
33
  }
28
34
 
29
35
  // What the CRS features read of a data: light to copy on each change
30
- type CrsItem = Pick<DataItem, "id" | "name" | "crs" | "created_at">;
36
+ type CrsItem = Pick<DataItem, "data_id" | "name" | "crs" | "created_at">;
31
37
 
32
- interface ModelComponentInput {
33
- geode_id: string;
38
+ interface ModelComponentInput extends GeodeIdentified {
34
39
  type: string;
35
40
  viewer_id: string | number;
36
41
  name: string;
@@ -40,12 +45,8 @@ interface ModelComponentInput {
40
45
  items?: string[];
41
46
  }
42
47
 
43
- interface NewDataItem {
44
- id: string;
45
- geode_id: string;
48
+ interface NewDataItem extends DataIdentified, GeodeIdentified, GeodeObjectTyped, ViewerTyped {
46
49
  name?: string;
47
- viewer_type: string;
48
- geode_object_type: string;
49
50
  is_viewable?: boolean;
50
51
  binary_light_viewable?: string;
51
52
  crs?: CRSList;
@@ -56,18 +57,10 @@ interface NewDataItem {
56
57
  nb_vertices?: number;
57
58
  }
58
59
 
59
- interface ModelComponentRelationRecord {
60
- id: string;
61
- parent: string;
62
- child: string;
63
- type: string;
64
- }
65
-
66
- interface ViewableItemLike {
60
+ interface ViewableItemLike extends Partial<GeodeObjectTyped> {
67
61
  is_viewable?: boolean;
68
62
  binary_light_viewable?: string;
69
- geode_object_type?: string;
70
- id?: string;
63
+ data_id?: DataId;
71
64
  title?: string;
72
65
  }
73
66
 
@@ -88,7 +81,7 @@ function checkItemViewable(item: ViewableItemLike | undefined | null): boolean {
88
81
  }
89
82
  if (
90
83
  item.geode_object_type === "HorizonStack3D" ||
91
- item.id === "HorizonStack3D" ||
84
+ item.data_id === "HorizonStack3D" ||
92
85
  item.title === "HorizonStack3D"
93
86
  ) {
94
87
  return false;
@@ -137,10 +130,10 @@ export const useDataStore = defineStore("data", () => {
137
130
  const { getComponentRelations } = useDataRelations();
138
131
  // Ids the viewer holds a pipeline for: an item is stored before it is registered, and non viewable items never are
139
132
  const registeredIds = reactive(new Set<string>());
140
- async function item(id: string): Promise<DataItem> {
141
- const data_item = await data_db.get(id);
133
+ async function item(dataId: DataId): Promise<DataItem> {
134
+ const data_item = await data_db.get(dataId);
142
135
  if (!data_item) {
143
- throw new Error(`Item not found: ${id}`);
136
+ throw new Error(`Item not found: ${dataId}`);
144
137
  }
145
138
  return data_item;
146
139
  }
@@ -148,10 +141,10 @@ export const useDataStore = defineStore("data", () => {
148
141
  const items = await data_db.toArray();
149
142
  return items;
150
143
  }
151
- function refItem(id: string): Ref<DataItem | undefined> {
144
+ function refItem(dataId: DataId): Ref<DataItem | undefined> {
152
145
  return useObservable(
153
146
  liveObservable(async () => {
154
- const data_item = await data_db.get(id);
147
+ const data_item = await data_db.get(dataId);
155
148
  return data_item;
156
149
  }),
157
150
  {
@@ -165,7 +158,12 @@ export const useDataStore = defineStore("data", () => {
165
158
  return useObservable(
166
159
  liveObservable(async () => {
167
160
  const items = await data_db.toArray();
168
- return items.map(({ id, name, crs, created_at }) => ({ id, name, crs, created_at }));
161
+ return items.map(({ data_id, name, crs, created_at }) => ({
162
+ data_id,
163
+ name,
164
+ crs,
165
+ created_at,
166
+ }));
169
167
  }),
170
168
  { initialValue: [] as CrsItem[] },
171
169
  );
@@ -182,24 +180,27 @@ export const useDataStore = defineStore("data", () => {
182
180
  },
183
181
  );
184
182
  }
185
- function isRegistered(id: string): boolean {
186
- return registeredIds.has(id);
183
+ function isRegistered(dataId: DataId): boolean {
184
+ return registeredIds.has(dataId);
187
185
  }
188
186
  function refRegisteredItems(): ComputedRef<DataItem[]> {
189
187
  const items = refAllItems();
190
- return computed(() => items.value.filter((data_item) => isRegistered(data_item.id)));
188
+ return computed(() => items.value.filter((data_item) => isRegistered(data_item.data_id)));
191
189
  }
192
- async function meshComponentType(modelId: string, geode_id: string): Promise<string | undefined> {
190
+ async function meshComponentType(
191
+ modelId: ModelId,
192
+ geode_id: GeodeId,
193
+ ): Promise<string | undefined> {
193
194
  const component = await model_components_db
194
- .where("[id+geode_id]")
195
+ .where("[data_id+geode_id]")
195
196
  .equals([modelId, geode_id])
196
197
  .first();
197
198
  return component?.type;
198
199
  }
199
- async function registerObject(id: string, name: string): Promise<unknown> {
200
+ async function registerObject(dataId: DataId, name: string): Promise<unknown> {
200
201
  const schema = viewer_generic_schemas.register;
201
202
  const params = {
202
- id,
203
+ id: dataId,
203
204
  name,
204
205
  };
205
206
  const result = await viewerStore.request({
@@ -207,15 +208,15 @@ export const useDataStore = defineStore("data", () => {
207
208
  params,
208
209
  timeout: 0,
209
210
  });
210
- registeredIds.add(id);
211
+ registeredIds.add(dataId);
211
212
  return result;
212
213
  }
213
- async function deregisterObject(id: string): Promise<unknown> {
214
+ async function deregisterObject(dataId: DataId): Promise<unknown> {
214
215
  const schema = viewer_generic_schemas.deregister;
215
216
  const params = {
216
- id,
217
+ id: dataId,
217
218
  };
218
- registeredIds.delete(id);
219
+ registeredIds.delete(dataId);
219
220
  const result = await viewerStore.request({
220
221
  schema,
221
222
  params,
@@ -226,9 +227,9 @@ export const useDataStore = defineStore("data", () => {
226
227
  // Satisfy prefer-readonly-parameter-types deeply; same pattern as app/utils/import_workflow.ts.
227
228
  async function addItem(new_item: NewDataItem): Promise<string> {
228
229
  const itemData: DataItem = {
229
- id: new_item.id,
230
+ data_id: new_item.data_id,
230
231
  geode_id: new_item.geode_id,
231
- name: new_item.name ?? new_item.id,
232
+ name: new_item.name ?? new_item.data_id,
232
233
  viewer_type: new_item.viewer_type,
233
234
  geode_object_type: new_item.geode_object_type,
234
235
  visible: true,
@@ -241,8 +242,8 @@ export const useDataStore = defineStore("data", () => {
241
242
  if (new_item.crs !== undefined) {
242
243
  itemData.crs = new_item.crs;
243
244
  }
244
- const id = await data_db.put(itemData);
245
- return id;
245
+ const dataId = await data_db.put(itemData);
246
+ return dataId;
246
247
  }
247
248
  // NewDataItem has mutable array fields (mesh_components, collection_components), so it can't
248
249
  // Satisfy prefer-readonly-parameter-types deeply; same pattern as app/utils/import_workflow.ts.
@@ -253,7 +254,7 @@ export const useDataStore = defineStore("data", () => {
253
254
  function addModelComponents(components: readonly ModelComponentInput[]): void {
254
255
  for (const component of components) {
255
256
  allComponents.push({
256
- id: new_item.id,
257
+ data_id: new_item.data_id,
257
258
  geode_id: component.geode_id,
258
259
  type: component.type,
259
260
  viewer_id: component.viewer_id,
@@ -282,7 +283,7 @@ export const useDataStore = defineStore("data", () => {
282
283
  ): void {
283
284
  for (const child of components) {
284
285
  relations.push({
285
- id: new_item.id,
286
+ data_id: new_item.data_id,
286
287
  parent,
287
288
  child,
288
289
  type,
@@ -310,53 +311,53 @@ export const useDataStore = defineStore("data", () => {
310
311
  return lastKey;
311
312
  }
312
313
  async function getComponentByViewerId(
313
- modelId: string,
314
+ modelId: ModelId,
314
315
  viewer_id: string | number,
315
316
  ): Promise<ModelComponentRecord | undefined> {
316
317
  const component = await model_components_db
317
318
  .where("viewer_id")
318
319
  .equals(Number(viewer_id))
319
- .and((model_component: ModelComponentRecord) => model_component.id === modelId)
320
+ .and((model_component: ModelComponentRecord) => model_component.data_id === modelId)
320
321
  .first();
321
322
  return component;
322
323
  }
323
324
  async function getComponentsByViewerIds(
324
- modelId: string,
325
+ modelId: ModelId,
325
326
  viewer_ids: number[],
326
327
  ): Promise<ModelComponentRecord[]> {
327
328
  const components = await model_components_db
328
329
  .where("viewer_id")
329
330
  .anyOf(viewer_ids)
330
- .and((model_component: ModelComponentRecord) => model_component.id === modelId)
331
+ .and((model_component: ModelComponentRecord) => model_component.data_id === modelId)
331
332
  .toArray();
332
333
  return components;
333
334
  }
334
- async function deleteModelComponents(modelId: string): Promise<void> {
335
- await model_components_db.where("id").equals(modelId).delete();
336
- await model_components_relation_db.where("id").equals(modelId).delete();
335
+ async function deleteModelComponents(modelId: ModelId): Promise<void> {
336
+ await model_components_db.where("data_id").equals(modelId).delete();
337
+ await model_components_relation_db.where("data_id").equals(modelId).delete();
337
338
  }
338
339
 
339
- async function deleteItem(id: string): Promise<void> {
340
- await data_db.delete(id);
341
- await deleteModelComponents(id);
340
+ async function deleteItem(dataId: DataId): Promise<void> {
341
+ await data_db.delete(dataId);
342
+ await deleteModelComponents(dataId);
342
343
  }
343
344
 
344
- async function updateItem(id: string, changes: Partial<DataItem>): Promise<void> {
345
- await data_db.update(id, changes);
345
+ async function updateItem(dataId: DataId, changes: Partial<DataItem>): Promise<void> {
346
+ await data_db.update(dataId, changes);
346
347
  }
347
348
 
348
- async function getAllModelComponentsViewerIds(modelId: string): Promise<number[]> {
349
- const components = await model_components_db.where("id").equals(modelId).toArray();
349
+ async function getAllModelComponentsViewerIds(modelId: ModelId): Promise<number[]> {
350
+ const components = await model_components_db.where("data_id").equals(modelId).toArray();
350
351
  return components.map((component: ModelComponentRecord) =>
351
352
  Math.trunc(Number(component.viewer_id)),
352
353
  );
353
354
  }
354
355
  async function getMeshComponentsViewerIds(
355
- modelId: string,
356
+ modelId: ModelId,
356
357
  meshComponentGeodeIds: readonly string[],
357
358
  ): Promise<number[]> {
358
359
  const components = await model_components_db
359
- .where("[id+geode_id]")
360
+ .where("[data_id+geode_id]")
360
361
  .anyOf(meshComponentGeodeIds.map((geode_id) => [modelId, geode_id]))
361
362
  .toArray();
362
363
  return components.map((component: ModelComponentRecord) =>
@@ -388,12 +389,26 @@ export const useDataStore = defineStore("data", () => {
388
389
  // Dexie's bulkPut expects mutable arrays, so this snapshot parameter can't deeply satisfy
389
390
  // The prefer-readonly-parameter-types rule; same pattern as app/utils/import_workflow.ts.
390
391
  async function importStores(snapshot: {
391
- readonly modelComponents: readonly ModelComponentRecord[];
392
- readonly modelComponentsRelations: readonly ModelComponentRelationRecord[];
392
+ readonly modelComponents: readonly (
393
+ | LegacyDataId<ModelComponentRecord>
394
+ | ModelComponentRecord
395
+ )[];
396
+ readonly modelComponentsRelations: readonly (
397
+ | LegacyDataId<ModelComponentRelationRecord>
398
+ | ModelComponentRelationRecord
399
+ )[];
393
400
  }): Promise<void> {
394
401
  await clear();
395
- await model_components_db.bulkPut(snapshot.modelComponents);
396
- await model_components_relation_db.bulkPut(snapshot.modelComponentsRelations);
402
+ await model_components_db.bulkPut(
403
+ snapshot.modelComponents.map((component) =>
404
+ fromLegacyDataId<ModelComponentRecord>(component),
405
+ ),
406
+ );
407
+ await model_components_relation_db.bulkPut(
408
+ snapshot.modelComponentsRelations.map((relation) =>
409
+ fromLegacyDataId<ModelComponentRelationRecord>(relation),
410
+ ),
411
+ );
397
412
  }
398
413
  return {
399
414
  refAllItems,
@@ -438,4 +453,4 @@ export const useDataStore = defineStore("data", () => {
438
453
  };
439
454
  });
440
455
 
441
- export type { CrsItem, DataItem, NewDataItem, ModelComponentInput, ModelComponentRelationRecord };
456
+ export type { CrsItem, DataItem, NewDataItem, ModelComponentInput };
@@ -1,27 +1,19 @@
1
1
  import { type FormattedComponent, type ModelComponentRecord, useDataMesh } from "./mesh.js";
2
2
  import { MESH_COMPONENT_TYPES } from "@ogw_front/utils/default_styles";
3
+ import type { ModelComponentRelationRecord } from "./relations.js";
4
+ import type { ModelId } from "@ogw_front/types/identifiers";
5
+ import type { ReadonlyTreeGroup } from "@ogw_front/types/tree";
3
6
  import type { Ref } from "vue";
4
7
  import { getTable } from "@ogw_internal/database/database.js";
5
8
  import { liveObservable } from "@ogw_front/utils/live_observable";
6
9
  import { pluralize } from "@ogw_front/utils/string";
7
10
  import { useObservable } from "@vueuse/rxjs";
8
11
 
9
- interface ModelComponentRelationRecord {
10
- id: string;
11
- parent: string;
12
- child: string;
13
- type: string;
14
- }
15
-
16
12
  interface CollectionComponent extends FormattedComponent {
17
13
  readonly children: readonly FormattedComponent[];
18
14
  }
19
15
 
20
- interface CollectionComponentGroup {
21
- id: string;
22
- title: string;
23
- readonly children: readonly CollectionComponent[];
24
- }
16
+ type CollectionComponentGroup = ReadonlyTreeGroup<CollectionComponent>;
25
17
 
26
18
  // oxlint-disable-next-line eslint/max-lines-per-function
27
19
  export function useDataCollections(): {
@@ -37,17 +29,17 @@ export function useDataCollections(): {
37
29
  );
38
30
  const { getAllMeshComponents } = useDataMesh();
39
31
 
40
- async function hasCollectionComponents(modelId: string): Promise<boolean> {
32
+ async function hasCollectionComponents(modelId: ModelId): Promise<boolean> {
41
33
  const count = await model_components_db
42
- .where("id")
34
+ .where("data_id")
43
35
  .equals(modelId)
44
36
  .and((component: ModelComponentRecord) => !MESH_COMPONENT_TYPES.includes(component.type))
45
37
  .count();
46
38
  return count > 0;
47
39
  }
48
40
 
49
- async function getAllCollectionComponents(modelId: string): Promise<FormattedComponent[]> {
50
- const items = await model_components_db.where("id").equals(modelId).toArray();
41
+ async function getAllCollectionComponents(modelId: ModelId): Promise<FormattedComponent[]> {
42
+ const items = await model_components_db.where("data_id").equals(modelId).toArray();
51
43
  return items
52
44
  .filter((component: ModelComponentRecord) => !MESH_COMPONENT_TYPES.includes(component.type))
53
45
  .map((component: ModelComponentRecord) => ({
@@ -61,10 +53,10 @@ export function useDataCollections(): {
61
53
  }
62
54
 
63
55
  async function fetchAllCollectionComponents(
64
- modelId: string,
56
+ modelId: ModelId,
65
57
  ): Promise<Record<string, CollectionComponent[]>> {
66
58
  const components = await getAllCollectionComponents(modelId);
67
- const relations = await model_components_relation_db.where("id").equals(modelId).toArray();
59
+ const relations = await model_components_relation_db.where("data_id").equals(modelId).toArray();
68
60
  const allMeshComponents = await getAllMeshComponents(modelId);
69
61
  const meshComponentsById: Record<string, FormattedComponent> = {};
70
62
  for (const meshComponent of allMeshComponents) {
@@ -90,7 +82,7 @@ export function useDataCollections(): {
90
82
  }
91
83
 
92
84
  async function formatedCollectionComponents(
93
- modelId: string,
85
+ modelId: ModelId,
94
86
  ): Promise<CollectionComponentGroup[]> {
95
87
  const byType = await fetchAllCollectionComponents(modelId);
96
88
  const collectionTypes = Object.keys(byType);
@@ -105,7 +97,7 @@ export function useDataCollections(): {
105
97
  }
106
98
 
107
99
  function refFormatedCollectionComponents(
108
- modelId: string,
100
+ modelId: ModelId,
109
101
  ): Ref<CollectionComponentGroup[] | undefined> {
110
102
  return useObservable(
111
103
  liveObservable(async () => {
@@ -127,4 +119,4 @@ export function useDataCollections(): {
127
119
  };
128
120
  }
129
121
 
130
- export type { CollectionComponent, CollectionComponentGroup, ModelComponentRelationRecord };
122
+ export type { CollectionComponent, CollectionComponentGroup };
@@ -1,31 +1,26 @@
1
+ import type { DataIdentified, GeodeIdentified, ModelId } from "@ogw_front/types/identifiers";
2
+ import type { ReadonlyTreeGroup } from "@ogw_front/types/tree";
1
3
  import type { Table } from "dexie";
2
4
  import { database } from "@ogw_internal/database/database.js";
3
5
  import { liveObservable } from "@ogw_front/utils/live_observable";
4
6
  import { useObservable } from "@vueuse/rxjs";
5
7
 
6
- interface ModelComponentRecord {
7
- id: string;
8
- geode_id: string;
8
+ interface ModelComponentRecord extends DataIdentified, GeodeIdentified {
9
9
  type: string;
10
10
  viewer_id: string | number;
11
11
  name: string;
12
12
  is_active: boolean;
13
13
  }
14
14
 
15
- interface FormattedComponent {
15
+ interface FormattedComponent extends Readonly<GeodeIdentified> {
16
16
  readonly id: string;
17
- readonly geode_id: string;
18
17
  readonly title: string;
19
18
  readonly category: string;
20
19
  readonly viewer_id: number;
21
20
  readonly is_active: boolean;
22
21
  }
23
22
 
24
- interface FormattedComponentGroup {
25
- id: string;
26
- title: string;
27
- readonly children: readonly FormattedComponent[];
28
- }
23
+ type FormattedComponentGroup = ReadonlyTreeGroup<FormattedComponent>;
29
24
 
30
25
  function toFormattedComponent(meshComponent: ModelComponentRecord): FormattedComponent {
31
26
  return {
@@ -57,8 +52,8 @@ function useDataMesh(): {
57
52
  string
58
53
  >;
59
54
 
60
- async function formatedMeshComponents(modelId: string): Promise<FormattedComponentGroup[]> {
61
- const items = await model_components_db.where("id").equals(modelId).toArray();
55
+ async function formatedMeshComponents(modelId: ModelId): Promise<FormattedComponentGroup[]> {
56
+ const items = await model_components_db.where("data_id").equals(modelId).toArray();
62
57
  const componentTitles: Record<string, string> = {
63
58
  Corner: "Corners",
64
59
  Line: "Lines",
@@ -85,7 +80,7 @@ function useDataMesh(): {
85
80
  }));
86
81
  }
87
82
 
88
- function refFormatedMeshComponents(modelId: string): Ref<FormattedComponentGroup[] | undefined> {
83
+ function refFormatedMeshComponents(modelId: ModelId): Ref<FormattedComponentGroup[] | undefined> {
89
84
  return useObservable(
90
85
  liveObservable(async () => {
91
86
  const components = await formatedMeshComponents(modelId);
@@ -98,23 +93,23 @@ function useDataMesh(): {
98
93
  }
99
94
 
100
95
  async function getMeshComponentsByType(
101
- modelId: string,
96
+ modelId: ModelId,
102
97
  type: string,
103
98
  ): Promise<FormattedComponent[]> {
104
99
  const components = await model_components_db
105
- .where("[id+type]")
100
+ .where("[data_id+type]")
106
101
  .equals([modelId, type])
107
102
  .toArray();
108
103
  return components.map((item: ModelComponentRecord) => toFormattedComponent(item));
109
104
  }
110
105
 
111
- async function getAllMeshComponents(modelId: string): Promise<FormattedComponent[]> {
112
- const items = await model_components_db.where("id").equals(modelId).toArray();
106
+ async function getAllMeshComponents(modelId: ModelId): Promise<FormattedComponent[]> {
107
+ const items = await model_components_db.where("data_id").equals(modelId).toArray();
113
108
  return items.map((item: ModelComponentRecord) => toFormattedComponent(item));
114
109
  }
115
110
 
116
111
  async function fetchAllMeshComponents(
117
- modelId: string,
112
+ modelId: ModelId,
118
113
  ): Promise<Record<string, FormattedComponent[]>> {
119
114
  const components = await getAllMeshComponents(modelId);
120
115
  const byType: Record<string, FormattedComponent[]> = {};
@@ -125,30 +120,30 @@ function useDataMesh(): {
125
120
  return byType;
126
121
  }
127
122
 
128
- async function getMeshComponentGeodeIds(modelId: string, type: string): Promise<string[]> {
123
+ async function getMeshComponentGeodeIds(modelId: ModelId, type: string): Promise<string[]> {
129
124
  const components = await model_components_db
130
- .where("[id+type]")
125
+ .where("[data_id+type]")
131
126
  .equals([modelId, type])
132
127
  .toArray();
133
128
  return components.map((component: ModelComponentRecord) => component.geode_id);
134
129
  }
135
130
 
136
- async function getCornersGeodeIds(modelId: string): Promise<string[]> {
131
+ async function getCornersGeodeIds(modelId: ModelId): Promise<string[]> {
137
132
  const geodeIds = await getMeshComponentGeodeIds(modelId, "Corner");
138
133
  return geodeIds;
139
134
  }
140
135
 
141
- async function getLinesGeodeIds(modelId: string): Promise<string[]> {
136
+ async function getLinesGeodeIds(modelId: ModelId): Promise<string[]> {
142
137
  const geodeIds = await getMeshComponentGeodeIds(modelId, "Line");
143
138
  return geodeIds;
144
139
  }
145
140
 
146
- async function getSurfacesGeodeIds(modelId: string): Promise<string[]> {
141
+ async function getSurfacesGeodeIds(modelId: ModelId): Promise<string[]> {
147
142
  const geodeIds = await getMeshComponentGeodeIds(modelId, "Surface");
148
143
  return geodeIds;
149
144
  }
150
145
 
151
- async function getBlocksGeodeIds(modelId: string): Promise<string[]> {
146
+ async function getBlocksGeodeIds(modelId: ModelId): Promise<string[]> {
152
147
  const geodeIds = await getMeshComponentGeodeIds(modelId, "Block");
153
148
  return geodeIds;
154
149
  }
@@ -1,3 +1,4 @@
1
+ import type { DataIdentified, ModelId } from "@ogw_front/types/identifiers";
1
2
  import {
2
3
  type FormattedComponent,
3
4
  type ModelComponentRecord,
@@ -6,18 +7,17 @@ import {
6
7
  import { Dexie } from "dexie";
7
8
  import { getTable } from "@ogw_internal/database/database.js";
8
9
 
9
- interface ModelComponentRelationRecord {
10
- id: string;
11
- parent: string;
12
- child: string;
13
- type: string;
14
- }
15
-
16
10
  interface ComponentRelations {
17
11
  readonly boundaries: readonly FormattedComponent[];
18
12
  readonly internals: readonly FormattedComponent[];
19
13
  }
20
14
 
15
+ interface ModelComponentRelationRecord extends DataIdentified {
16
+ parent: string;
17
+ child: string;
18
+ type: string;
19
+ }
20
+
21
21
  export function useDataRelations(): {
22
22
  getComponentRelations: typeof getComponentRelations;
23
23
  } {
@@ -27,23 +27,23 @@ export function useDataRelations(): {
27
27
  );
28
28
 
29
29
  async function getRelatedComponents(
30
- modelId: string,
30
+ modelId: ModelId,
31
31
  relations: readonly ModelComponentRelationRecord[],
32
32
  type: string,
33
33
  ): Promise<FormattedComponent[]> {
34
34
  const keys = relations
35
35
  .filter((relation) => relation.type === type)
36
36
  .map((relation) => [modelId, relation.child]);
37
- const components = await model_components_db.where("[id+geode_id]").anyOf(keys).toArray();
37
+ const components = await model_components_db.where("[data_id+geode_id]").anyOf(keys).toArray();
38
38
  return components.map((component) => toFormattedComponent(component));
39
39
  }
40
40
 
41
41
  async function getComponentRelations(
42
- modelId: string,
42
+ modelId: ModelId,
43
43
  componentId: string,
44
44
  ): Promise<ComponentRelations> {
45
45
  const relations = await model_components_relation_db
46
- .where("[id+parent+child]")
46
+ .where("[data_id+parent+child]")
47
47
  .between([modelId, componentId, Dexie.minKey], [modelId, componentId, Dexie.maxKey])
48
48
  .toArray();
49
49
  const [boundaries, internals] = await Promise.all([
@@ -56,4 +56,4 @@ export function useDataRelations(): {
56
56
  return { getComponentRelations };
57
57
  }
58
58
 
59
- export type { ComponentRelations };
59
+ export type { ComponentRelations, ModelComponentRelationRecord };