@geode/opengeodeweb-front 12.2.0-rc.4 → 12.2.0-rc.5
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/app/components/ClippingPlanes.vue +1 -1
- package/app/components/FactorFilterPanel.vue +1 -1
- package/app/components/Launcher.vue +3 -2
- package/app/components/ThresholdFilter.vue +1 -2
- package/app/components/Viewer/Basemap/CropOptions.vue +7 -8
- package/app/components/Viewer/Basemap/OpacityOptions.vue +7 -8
- package/app/components/Viewer/ContextMenu/CircularItems.vue +6 -43
- package/app/components/Viewer/ContextMenu/ContextMenu.vue +1 -6
- package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +14 -16
- package/app/components/Viewer/EdgedCurve/PointsOptions.vue +5 -4
- package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +10 -13
- package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +8 -11
- package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +16 -13
- package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +28 -31
- package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +9 -11
- package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +8 -11
- package/app/components/Viewer/Generic/Model/BlocksOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/CornersOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/EdgesOptions.vue +7 -8
- package/app/components/Viewer/Generic/Model/LinesOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +5 -7
- package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +5 -7
- package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +5 -7
- package/app/components/Viewer/Generic/Model/ModelStyleOptions.vue +7 -8
- package/app/components/Viewer/Generic/Model/PointsOptions.vue +7 -8
- package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +1 -1
- package/app/components/Viewer/Grid/2D/CellsOptions.vue +6 -4
- package/app/components/Viewer/Grid/2D/EdgesOptions.vue +6 -4
- package/app/components/Viewer/Grid/2D/PointsOptions.vue +5 -4
- package/app/components/Viewer/Grid/3D/CellsOptions.vue +6 -4
- package/app/components/Viewer/Grid/3D/EdgesOptions.vue +6 -4
- package/app/components/Viewer/Grid/3D/FacetsOptions.vue +6 -4
- package/app/components/Viewer/Grid/3D/PointsOptions.vue +5 -4
- package/app/components/Viewer/Image/ImageOptions.vue +10 -13
- package/app/components/Viewer/ObjectTree/Base/CommonTreeView.vue +5 -0
- package/app/components/Viewer/ObjectTree/Base/ComponentRelations.vue +2 -2
- package/app/components/Viewer/ObjectTree/Base/StickyHeader.vue +4 -1
- package/app/components/Viewer/ObjectTree/Base/TreeRow.vue +6 -8
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +10 -15
- package/app/components/Viewer/ObjectTree/Views/ModelTree.vue +3 -0
- package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +28 -31
- package/app/components/Viewer/Scene/BackgroundOptions.vue +4 -7
- package/app/components/Viewer/Scene/OrientationWidgetOptions.vue +4 -7
- package/app/components/Viewer/Scene/TextOptions.vue +4 -7
- package/app/components/Viewer/Solid/EdgesOptions.vue +6 -4
- package/app/components/Viewer/Solid/PointsOptions.vue +5 -4
- package/app/components/Viewer/Solid/PolygonsOptions.vue +6 -4
- package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +8 -11
- package/app/components/Viewer/Surface/EdgesOptions.vue +6 -4
- package/app/components/Viewer/Surface/PointsOptions.vue +6 -4
- package/app/components/Viewer/Surface/PolygonsOptions.vue +8 -11
- package/app/components/Viewer/Surface/Triangulated/TrianglesOptions.vue +5 -4
- package/app/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue +6 -4
- package/app/components/Viewer/TetrahedralSolid/TrianglesOptions.vue +6 -4
- package/app/composables/circular_menu.ts +45 -0
- package/app/composables/hover_highlight.ts +1 -1
- package/app/composables/model_menu_context.ts +7 -11
- package/app/composables/model_tree.ts +3 -3
- package/app/composables/project_manager_helpers/types.ts +2 -3
- package/app/composables/use_overlapping_picker.ts +7 -19
- package/app/composables/viewer_context_menu.ts +2 -1
- package/app/stores/api.ts +6 -59
- package/app/stores/app.ts +21 -55
- package/app/stores/back.ts +86 -145
- package/app/stores/camera_manager.ts +12 -25
- package/app/stores/cloud.ts +21 -101
- package/app/stores/crs.ts +3 -2
- package/app/stores/data.ts +66 -409
- package/app/stores/data_style.ts +99 -93
- package/app/stores/feedback.ts +57 -53
- package/app/stores/infra.ts +61 -101
- package/app/stores/treeview.ts +12 -31
- package/app/stores/viewer.ts +9 -29
- package/app/stores/viewer_helpers/actions.ts +1 -23
- package/app/utils/backend_lifecycle.ts +155 -0
- package/app/utils/import_item.ts +5 -4
- package/app/utils/threshold_sources.ts +3 -2
- package/app/utils/treeview.ts +25 -1
- package/app/utils/viewer_object_type.ts +21 -0
- package/internal/database/base_database.ts +2 -1
- package/internal/database/database.ts +90 -7
- package/internal/database/queries.ts +45 -0
- package/internal/database/tables/camera_positions.ts +11 -1
- package/internal/database/tables/data.ts +20 -1
- package/internal/database/tables/data_style.ts +3 -1
- package/internal/database/tables/model_component_datastyle.ts +3 -1
- package/internal/database/tables/model_component_type_datastyle.ts +3 -1
- package/internal/database/tables/model_components.ts +12 -1
- package/internal/database/tables/model_components_relation.ts +11 -1
- package/internal/database/tables/scene_style.ts +3 -1
- package/internal/database/tables/treeview_config.ts +31 -0
- package/internal/stores/data/items.ts +110 -0
- package/internal/stores/data/model/collections.ts +107 -0
- package/internal/stores/data/model/components.ts +129 -0
- package/internal/stores/data/model/mesh_components.ts +134 -0
- package/internal/stores/data/model/relations.ts +76 -0
- package/internal/stores/data/model/types.ts +14 -0
- package/internal/stores/data/registration.ts +54 -0
- package/internal/stores/data/snapshot.ts +83 -0
- package/internal/stores/data/types.ts +26 -0
- package/internal/stores/data_style/model/common_mutations.ts +47 -77
- package/internal/stores/data_style/model/selection.ts +3 -10
- package/internal/stores/data_style/scene.ts +2 -2
- package/internal/stores/data_style/state.ts +10 -8
- package/internal/stores/data_style/state_shared.ts +10 -7
- package/internal/stores/hybrid_viewer/highlight.ts +9 -14
- package/internal/stores/hybrid_viewer/scene.ts +1 -1
- package/internal/stores/microservice.ts +192 -0
- package/package.json +1 -1
- package/tests/browser/helpers/data/helpers/attribute.ts +2 -1
- package/app/stores/data_helpers/collections.ts +0 -122
- package/app/stores/data_helpers/mesh.ts +0 -167
- package/app/stores/data_helpers/relations.ts +0 -94
package/app/stores/data.ts
CHANGED
|
@@ -1,423 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {
|
|
2
|
+
type DataSnapshot,
|
|
3
|
+
clearTables,
|
|
4
|
+
deleteItem,
|
|
5
|
+
exportStores,
|
|
6
|
+
importTables,
|
|
7
|
+
} from "@ogw_internal/stores/data/snapshot";
|
|
8
|
+
import {
|
|
9
|
+
addComponentRelations,
|
|
10
|
+
addComponents,
|
|
11
|
+
getAllModelComponentsViewerIds,
|
|
12
|
+
getComponentByViewerId,
|
|
13
|
+
getComponentsByViewerIds,
|
|
14
|
+
getMeshComponentsViewerIds,
|
|
15
|
+
meshComponentType,
|
|
16
|
+
} from "@ogw_internal/stores/data/model/components";
|
|
17
|
+
import {
|
|
18
|
+
addItem,
|
|
19
|
+
allItems,
|
|
20
|
+
fetchIsViewable,
|
|
21
|
+
item,
|
|
22
|
+
refItem,
|
|
23
|
+
updateItem,
|
|
24
|
+
useDataItems,
|
|
25
|
+
} from "@ogw_internal/stores/data/items";
|
|
26
|
+
import {
|
|
27
|
+
fetchAllCollectionComponents,
|
|
28
|
+
formatedCollectionComponents,
|
|
29
|
+
getAllCollectionComponents,
|
|
30
|
+
hasCollectionComponents,
|
|
31
|
+
refFormatedCollectionComponents,
|
|
32
|
+
} from "@ogw_internal/stores/data/model/collections";
|
|
33
|
+
import {
|
|
34
|
+
fetchAllComponentRelations,
|
|
35
|
+
getComponentRelations,
|
|
36
|
+
} from "@ogw_internal/stores/data/model/relations";
|
|
37
|
+
import {
|
|
38
|
+
fetchAllMeshComponents,
|
|
39
|
+
formatedMeshComponents,
|
|
40
|
+
getAllMeshComponents,
|
|
41
|
+
getBlocksGeodeIds,
|
|
42
|
+
getCornersGeodeIds,
|
|
43
|
+
getLinesGeodeIds,
|
|
44
|
+
getMeshComponentGeodeIds,
|
|
45
|
+
getMeshComponentsByType,
|
|
46
|
+
getSurfacesGeodeIds,
|
|
47
|
+
refFormatedMeshComponents,
|
|
48
|
+
} from "@ogw_internal/stores/data/model/mesh_components";
|
|
49
|
+
import { useDataRegistration } from "@ogw_internal/stores/data/registration";
|
|
7
50
|
|
|
8
|
-
//
|
|
9
|
-
import type { DataId, GeodeId } from "@geode/opengeodeweb-microservice/schema_types";
|
|
10
|
-
import type {
|
|
11
|
-
DataIdentified,
|
|
12
|
-
GeodeIdentified,
|
|
13
|
-
GeodeObjectTyped,
|
|
14
|
-
ModelId,
|
|
15
|
-
ViewerObjectTyped,
|
|
16
|
-
} from "@ogw_front/types/identifiers";
|
|
17
|
-
import { type LegacyDataId, fromLegacyDataId } from "@ogw_front/utils/legacy_data_id";
|
|
18
|
-
import { type ModelComponentRecord, useDataMesh } from "./data_helpers/mesh.js";
|
|
19
|
-
import { type ModelComponentRelationRecord, useDataRelations } from "./data_helpers/relations.js";
|
|
20
|
-
import { database } from "@ogw_internal/database/database.js";
|
|
21
|
-
import { liveObservable } from "@ogw_front/utils/live_observable";
|
|
22
|
-
import { useDataCollections } from "./data_helpers/collections.js";
|
|
23
|
-
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
24
|
-
|
|
25
|
-
interface DataItem extends DataIdentified, GeodeIdentified, GeodeObjectTyped, ViewerObjectTyped {
|
|
26
|
-
name: string;
|
|
27
|
-
visible: boolean;
|
|
28
|
-
created_at: string;
|
|
29
|
-
is_viewable?: boolean;
|
|
30
|
-
binary_light_viewable?: string;
|
|
31
|
-
crs?: CRS;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// What the CRS features read of a data: light to copy on each change
|
|
35
|
-
type CrsItem = Pick<DataItem, "data_id" | "name" | "crs" | "created_at">;
|
|
36
|
-
|
|
37
|
-
interface ModelComponentInput extends GeodeIdentified {
|
|
38
|
-
type: string;
|
|
39
|
-
viewer_id: string | number;
|
|
40
|
-
name: string;
|
|
41
|
-
is_active: boolean;
|
|
42
|
-
boundaries?: string[];
|
|
43
|
-
internals?: string[];
|
|
44
|
-
items?: string[];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface NewDataItem extends DataIdentified, GeodeIdentified, GeodeObjectTyped, ViewerObjectTyped {
|
|
48
|
-
name?: string;
|
|
49
|
-
is_viewable?: boolean;
|
|
50
|
-
binary_light_viewable?: string;
|
|
51
|
-
crs?: CRS;
|
|
52
|
-
// Set on saved data: kept by the project snapshot
|
|
53
|
-
created_at?: string;
|
|
54
|
-
mesh_components?: ModelComponentInput[];
|
|
55
|
-
collection_components?: ModelComponentInput[];
|
|
56
|
-
nb_vertices?: number;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
interface ViewableItemLike extends Partial<GeodeObjectTyped> {
|
|
60
|
-
is_viewable?: boolean;
|
|
61
|
-
binary_light_viewable?: string;
|
|
62
|
-
data_id?: DataId;
|
|
63
|
-
title?: string;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const viewer_generic_schemas = viewer_schemas.opengeodeweb_viewer.generic;
|
|
67
|
-
// The database's table map is dynamically assembled at runtime (see internal/database/database.ts), so its exported type is a loose `{}`; cast it to the shape it actually has at runtime rather than widening every call site.
|
|
68
|
-
type DatabaseTables = Record<string, unknown>;
|
|
69
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- see comment above.
|
|
70
|
-
const typedDatabase = database as unknown as DatabaseTables;
|
|
71
|
-
function checkItemViewable(item: ViewableItemLike | undefined | null): boolean {
|
|
72
|
-
if (!item || typeof item !== "object") {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
if (item.is_viewable !== undefined) {
|
|
76
|
-
return item.is_viewable;
|
|
77
|
-
}
|
|
78
|
-
if (item.binary_light_viewable !== undefined) {
|
|
79
|
-
return item.binary_light_viewable !== "not_viewable";
|
|
80
|
-
}
|
|
81
|
-
if (
|
|
82
|
-
item.geode_object_type === "HorizonStack3D" ||
|
|
83
|
-
item.data_id === "HorizonStack3D" ||
|
|
84
|
-
item.title === "HorizonStack3D"
|
|
85
|
-
) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
function isItemViewable(itemOrId: string | ViewableItemLike): boolean | Promise<boolean> {
|
|
91
|
-
if (typeof itemOrId === "string") {
|
|
92
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- database's table map is dynamically typed at runtime; see comment above.
|
|
93
|
-
return (typedDatabase.data as Table<DataItem, string>).get(itemOrId).then(checkItemViewable);
|
|
94
|
-
}
|
|
95
|
-
return checkItemViewable(itemOrId);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// oxlint-disable-next-line max-lines-per-function, max-statements
|
|
51
|
+
// oxlint-disable-next-line max-lines-per-function
|
|
99
52
|
export const useDataStore = defineStore("data", () => {
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- database's table map is dynamically typed at runtime; see comment above.
|
|
104
|
-
const model_components_db = typedDatabase.model_components as Table<ModelComponentRecord, string>;
|
|
105
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- database's table map is dynamically typed at runtime; see comment above.
|
|
106
|
-
const model_components_relation_db = typedDatabase.model_components_relation as Table<
|
|
107
|
-
ModelComponentRelationRecord,
|
|
108
|
-
string
|
|
109
|
-
>;
|
|
110
|
-
const {
|
|
111
|
-
formatedMeshComponents,
|
|
112
|
-
refFormatedMeshComponents,
|
|
113
|
-
getMeshComponentsByType,
|
|
114
|
-
getAllMeshComponents,
|
|
115
|
-
fetchAllMeshComponents,
|
|
116
|
-
getMeshComponentGeodeIds,
|
|
117
|
-
getCornersGeodeIds,
|
|
118
|
-
getLinesGeodeIds,
|
|
119
|
-
getSurfacesGeodeIds,
|
|
120
|
-
getBlocksGeodeIds,
|
|
121
|
-
} = useDataMesh();
|
|
122
|
-
const {
|
|
123
|
-
hasCollectionComponents,
|
|
124
|
-
getAllCollectionComponents,
|
|
125
|
-
fetchAllCollectionComponents,
|
|
126
|
-
formatedCollectionComponents,
|
|
127
|
-
refFormatedCollectionComponents,
|
|
128
|
-
} = useDataCollections();
|
|
129
|
-
const { getComponentRelations, fetchAllComponentRelations } = 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>());
|
|
132
|
-
async function item(dataId: DataId): Promise<DataItem> {
|
|
133
|
-
const data_item = await data_db.get(dataId);
|
|
134
|
-
if (!data_item) {
|
|
135
|
-
throw new Error(`Item not found: ${dataId}`);
|
|
136
|
-
}
|
|
137
|
-
return data_item;
|
|
138
|
-
}
|
|
139
|
-
async function allItems(): Promise<DataItem[]> {
|
|
140
|
-
const items = await data_db.toArray();
|
|
141
|
-
return items;
|
|
142
|
-
}
|
|
143
|
-
function refItem(dataId: DataId): Ref<DataItem | undefined> {
|
|
144
|
-
return useObservable(
|
|
145
|
-
liveObservable(async () => {
|
|
146
|
-
const data_item = await data_db.get(dataId);
|
|
147
|
-
return data_item;
|
|
148
|
-
}),
|
|
149
|
-
{
|
|
150
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- placeholder until the live query resolves; consumers must treat this as possibly incomplete.
|
|
151
|
-
initialValue: {} as DataItem,
|
|
152
|
-
},
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
// The CRS features only need these fields: the geometry stays out of the copies made on each change
|
|
156
|
-
function refCrsItems(): Ref<CrsItem[]> {
|
|
157
|
-
return useObservable(
|
|
158
|
-
liveObservable(async () => {
|
|
159
|
-
const items = await data_db.toArray();
|
|
160
|
-
return items.map(({ data_id, name, crs, created_at }) => ({
|
|
161
|
-
data_id,
|
|
162
|
-
name,
|
|
163
|
-
crs,
|
|
164
|
-
created_at,
|
|
165
|
-
}));
|
|
166
|
-
}),
|
|
167
|
-
{ initialValue: [] as CrsItem[] },
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function refAllItems(): Ref<DataItem[]> {
|
|
172
|
-
return useObservable(
|
|
173
|
-
liveObservable(async () => {
|
|
174
|
-
const items = await data_db.toArray();
|
|
175
|
-
return items;
|
|
176
|
-
}),
|
|
177
|
-
{
|
|
178
|
-
initialValue: [] as DataItem[],
|
|
179
|
-
},
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
function isRegistered(dataId: DataId): boolean {
|
|
183
|
-
return registeredIds.has(dataId);
|
|
184
|
-
}
|
|
185
|
-
function refRegisteredItems(): ComputedRef<DataItem[]> {
|
|
186
|
-
const items = refAllItems();
|
|
187
|
-
return computed(() => items.value.filter((data_item) => isRegistered(data_item.data_id)));
|
|
188
|
-
}
|
|
189
|
-
async function meshComponentType(
|
|
190
|
-
modelId: ModelId,
|
|
191
|
-
geode_id: GeodeId,
|
|
192
|
-
): Promise<string | undefined> {
|
|
193
|
-
const component = await model_components_db
|
|
194
|
-
.where("[data_id+geode_id]")
|
|
195
|
-
.equals([modelId, geode_id])
|
|
196
|
-
.first();
|
|
197
|
-
return component?.type;
|
|
198
|
-
}
|
|
199
|
-
async function registerObject(dataId: DataId, name: string): Promise<unknown> {
|
|
200
|
-
const schema = viewer_generic_schemas.register;
|
|
201
|
-
const params = {
|
|
202
|
-
id: dataId,
|
|
203
|
-
name,
|
|
204
|
-
};
|
|
205
|
-
const result = await viewerStore.request({
|
|
206
|
-
schema,
|
|
207
|
-
params,
|
|
208
|
-
timeout: 0,
|
|
209
|
-
});
|
|
210
|
-
registeredIds.add(dataId);
|
|
211
|
-
return result;
|
|
212
|
-
}
|
|
213
|
-
async function deregisterObject(dataId: DataId): Promise<unknown> {
|
|
214
|
-
const schema = viewer_generic_schemas.deregister;
|
|
215
|
-
const params = {
|
|
216
|
-
id: dataId,
|
|
217
|
-
};
|
|
218
|
-
registeredIds.delete(dataId);
|
|
219
|
-
const result = await viewerStore.request({
|
|
220
|
-
schema,
|
|
221
|
-
params,
|
|
222
|
-
});
|
|
223
|
-
return result;
|
|
224
|
-
}
|
|
225
|
-
// NewDataItem has mutable array fields (mesh_components, collection_components), so it can't
|
|
226
|
-
// Satisfy prefer-readonly-parameter-types deeply; same pattern as app/utils/import_workflow.ts.
|
|
227
|
-
async function addItem(new_item: NewDataItem): Promise<string> {
|
|
228
|
-
const itemData: DataItem = {
|
|
229
|
-
data_id: new_item.data_id,
|
|
230
|
-
geode_id: new_item.geode_id,
|
|
231
|
-
name: new_item.name ?? new_item.data_id,
|
|
232
|
-
viewer_object_type: new_item.viewer_object_type,
|
|
233
|
-
geode_object_type: new_item.geode_object_type,
|
|
234
|
-
visible: true,
|
|
235
|
-
created_at: new Date().toISOString(),
|
|
236
|
-
is_viewable: new_item.is_viewable,
|
|
237
|
-
};
|
|
238
|
-
if (new_item.binary_light_viewable !== undefined && new_item.binary_light_viewable !== null) {
|
|
239
|
-
itemData.binary_light_viewable = new_item.binary_light_viewable;
|
|
240
|
-
}
|
|
241
|
-
if (new_item.crs !== undefined) {
|
|
242
|
-
itemData.crs = new_item.crs;
|
|
243
|
-
}
|
|
244
|
-
const dataId = await data_db.put(itemData);
|
|
245
|
-
return dataId;
|
|
246
|
-
}
|
|
247
|
-
// NewDataItem has mutable array fields (mesh_components, collection_components), so it can't
|
|
248
|
-
// Satisfy prefer-readonly-parameter-types deeply; same pattern as app/utils/import_workflow.ts.
|
|
249
|
-
async function addComponents(new_item: NewDataItem): Promise<string> {
|
|
250
|
-
const allComponents: ModelComponentRecord[] = [];
|
|
251
|
-
// ModelComponentInput has mutable array fields (boundaries, internals, items), so a readonly
|
|
252
|
-
// Array of it can't satisfy prefer-readonly-parameter-types deeply; same limitation as above.
|
|
253
|
-
function addModelComponents(components: readonly ModelComponentInput[]): void {
|
|
254
|
-
for (const component of components) {
|
|
255
|
-
allComponents.push({
|
|
256
|
-
data_id: new_item.data_id,
|
|
257
|
-
geode_id: component.geode_id,
|
|
258
|
-
type: component.type,
|
|
259
|
-
viewer_id: component.viewer_id,
|
|
260
|
-
name: component.name,
|
|
261
|
-
is_active: component.is_active,
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
if (new_item.mesh_components) {
|
|
266
|
-
addModelComponents(new_item.mesh_components);
|
|
267
|
-
}
|
|
268
|
-
if (new_item.collection_components) {
|
|
269
|
-
addModelComponents(new_item.collection_components);
|
|
270
|
-
}
|
|
271
|
-
const lastKey = await model_components_db.bulkPut(allComponents);
|
|
272
|
-
return lastKey;
|
|
273
|
-
}
|
|
274
|
-
// NewDataItem has mutable array fields (mesh_components, collection_components), so it can't
|
|
275
|
-
// Satisfy prefer-readonly-parameter-types deeply; same pattern as app/utils/import_workflow.ts.
|
|
276
|
-
async function addComponentRelations(new_item: NewDataItem): Promise<string> {
|
|
277
|
-
const relations: ModelComponentRelationRecord[] = [];
|
|
278
|
-
function addModelComponentRelations(
|
|
279
|
-
components: readonly string[],
|
|
280
|
-
parent: string,
|
|
281
|
-
type: string,
|
|
282
|
-
): void {
|
|
283
|
-
for (const child of components) {
|
|
284
|
-
relations.push({
|
|
285
|
-
data_id: new_item.data_id,
|
|
286
|
-
parent,
|
|
287
|
-
child,
|
|
288
|
-
type,
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
if (new_item.mesh_components) {
|
|
293
|
-
for (const component of new_item.mesh_components) {
|
|
294
|
-
if (component.boundaries) {
|
|
295
|
-
addModelComponentRelations(component.boundaries, component.geode_id, "boundary");
|
|
296
|
-
}
|
|
297
|
-
if (component.internals) {
|
|
298
|
-
addModelComponentRelations(component.internals, component.geode_id, "internal");
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
if (new_item.collection_components) {
|
|
303
|
-
for (const component of new_item.collection_components) {
|
|
304
|
-
if (component.items) {
|
|
305
|
-
addModelComponentRelations(component.items, component.geode_id, "collection");
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
const lastKey = await model_components_relation_db.bulkPut(relations);
|
|
310
|
-
return lastKey;
|
|
311
|
-
}
|
|
312
|
-
async function getComponentByViewerId(
|
|
313
|
-
modelId: ModelId,
|
|
314
|
-
viewer_id: string | number,
|
|
315
|
-
): Promise<ModelComponentRecord | undefined> {
|
|
316
|
-
const component = await model_components_db
|
|
317
|
-
.where("viewer_id")
|
|
318
|
-
.equals(Number(viewer_id))
|
|
319
|
-
.and((model_component: ModelComponentRecord) => model_component.data_id === modelId)
|
|
320
|
-
.first();
|
|
321
|
-
return component;
|
|
322
|
-
}
|
|
323
|
-
async function getComponentsByViewerIds(
|
|
324
|
-
modelId: ModelId,
|
|
325
|
-
viewer_ids: number[],
|
|
326
|
-
): Promise<ModelComponentRecord[]> {
|
|
327
|
-
const components = await model_components_db
|
|
328
|
-
.where("viewer_id")
|
|
329
|
-
.anyOf(viewer_ids)
|
|
330
|
-
.and((model_component: ModelComponentRecord) => model_component.data_id === modelId)
|
|
331
|
-
.toArray();
|
|
332
|
-
return components;
|
|
333
|
-
}
|
|
334
|
-
async function deleteModelComponents(modelId: ModelId): Promise<void> {
|
|
335
|
-
await model_components_db.where("data_id").equals(modelId).delete();
|
|
336
|
-
await model_components_relation_db.where("data_id").equals(modelId).delete();
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
async function deleteItem(dataId: DataId): Promise<void> {
|
|
340
|
-
await data_db.delete(dataId);
|
|
341
|
-
await deleteModelComponents(dataId);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
async function updateItem(dataId: DataId, changes: Partial<DataItem>): Promise<void> {
|
|
345
|
-
await data_db.update(dataId, changes);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
async function getAllModelComponentsViewerIds(modelId: ModelId): Promise<number[]> {
|
|
349
|
-
const components = await model_components_db.where("data_id").equals(modelId).toArray();
|
|
350
|
-
return components.map((component: ModelComponentRecord) =>
|
|
351
|
-
Math.trunc(Number(component.viewer_id)),
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
async function getMeshComponentsViewerIds(
|
|
355
|
-
modelId: ModelId,
|
|
356
|
-
meshComponentGeodeIds: readonly string[],
|
|
357
|
-
): Promise<number[]> {
|
|
358
|
-
const components = await model_components_db
|
|
359
|
-
.where("[data_id+geode_id]")
|
|
360
|
-
.anyOf(meshComponentGeodeIds.map((geode_id) => [modelId, geode_id]))
|
|
361
|
-
.toArray();
|
|
362
|
-
return components.map((component: ModelComponentRecord) =>
|
|
363
|
-
Math.trunc(Number(component.viewer_id)),
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
async function exportStores(): Promise<{
|
|
367
|
-
items: DataItem[];
|
|
368
|
-
modelComponents: ModelComponentRecord[];
|
|
369
|
-
modelComponentsRelations: ModelComponentRelationRecord[];
|
|
370
|
-
}> {
|
|
371
|
-
const items = await data_db.toArray();
|
|
372
|
-
const modelComponents = await model_components_db.toArray();
|
|
373
|
-
const modelComponentsRelations = await model_components_relation_db.toArray();
|
|
374
|
-
return {
|
|
375
|
-
items,
|
|
376
|
-
modelComponents,
|
|
377
|
-
modelComponentsRelations,
|
|
378
|
-
};
|
|
379
|
-
}
|
|
53
|
+
const { items, isViewable } = useDataItems();
|
|
54
|
+
const { registeredItems, isRegistered, registerObject, deregisterObject, clearRegistrations } =
|
|
55
|
+
useDataRegistration(items);
|
|
380
56
|
|
|
381
57
|
async function clear(): Promise<void> {
|
|
382
|
-
|
|
383
|
-
await
|
|
384
|
-
await model_components_db.clear();
|
|
385
|
-
await model_components_relation_db.clear();
|
|
58
|
+
clearRegistrations();
|
|
59
|
+
await clearTables();
|
|
386
60
|
}
|
|
387
61
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
readonly modelComponents: readonly (
|
|
392
|
-
| LegacyDataId<ModelComponentRecord>
|
|
393
|
-
| ModelComponentRecord
|
|
394
|
-
)[];
|
|
395
|
-
readonly modelComponentsRelations: readonly (
|
|
396
|
-
| LegacyDataId<ModelComponentRelationRecord>
|
|
397
|
-
| ModelComponentRelationRecord
|
|
398
|
-
)[];
|
|
399
|
-
}): Promise<void> {
|
|
400
|
-
await clear();
|
|
401
|
-
await model_components_db.bulkPut(
|
|
402
|
-
snapshot.modelComponents.map((component) =>
|
|
403
|
-
fromLegacyDataId<ModelComponentRecord>(component),
|
|
404
|
-
),
|
|
405
|
-
);
|
|
406
|
-
await model_components_relation_db.bulkPut(
|
|
407
|
-
snapshot.modelComponentsRelations.map((relation) =>
|
|
408
|
-
fromLegacyDataId<ModelComponentRelationRecord>(relation),
|
|
409
|
-
),
|
|
410
|
-
);
|
|
62
|
+
async function importStores(snapshot: DataSnapshot): Promise<void> {
|
|
63
|
+
clearRegistrations();
|
|
64
|
+
await importTables(snapshot);
|
|
411
65
|
}
|
|
66
|
+
|
|
412
67
|
return {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
refRegisteredItems,
|
|
68
|
+
items,
|
|
69
|
+
registeredItems,
|
|
416
70
|
isRegistered,
|
|
417
71
|
item,
|
|
418
72
|
allItems,
|
|
419
73
|
refItem,
|
|
420
|
-
|
|
74
|
+
isViewable,
|
|
75
|
+
fetchIsViewable,
|
|
421
76
|
meshComponentType,
|
|
422
77
|
registerObject,
|
|
423
78
|
deregisterObject,
|
|
@@ -453,4 +108,6 @@ export const useDataStore = defineStore("data", () => {
|
|
|
453
108
|
};
|
|
454
109
|
});
|
|
455
110
|
|
|
456
|
-
export type { CrsItem,
|
|
111
|
+
export type { CrsItem, NewDataItem } from "@ogw_internal/stores/data/types";
|
|
112
|
+
export type { ModelComponentInput } from "@ogw_internal/stores/data/model/types";
|
|
113
|
+
export type { DataItem } from "@ogw_internal/database/tables/data";
|