@geode/opengeodeweb-front 10.34.0-rc.8 → 10.34.0
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/{server → .build/server}/utils/app_config.js +10 -9
- package/{server → .build/server}/utils/cleanup.js +31 -17
- package/{server → .build/server}/utils/cloud.js +1 -4
- package/{server → .build/server}/utils/microservices.js +21 -9
- package/{server → .build/server}/utils/path.js +4 -4
- package/{server → .build/server}/utils/scripts.js +9 -9
- package/.build/server/utils/server_config.js +51 -0
- package/.build/server/utils/stream.js +6 -0
- package/{server → .build/server}/utils/ws_client.js +18 -3
- package/{shared → .build/shared}/scripts.js +10 -10
- package/.build/shared/utils/call_raw.js +31 -0
- package/{shared → .build/shared}/utils/call_schema.js +2 -2
- package/.build/shared/utils/fetch_raw.js +52 -0
- package/{shared → .build/shared}/utils/fetch_schema.js +2 -2
- package/{shared → .build/shared}/utils/file.js +3 -1
- package/{shared → .build/shared}/utils/response_handlers/load.js +10 -7
- package/{shared → .build/shared}/utils/validate_schema.js +1 -1
- package/app/components/ActionButton.vue +6 -6
- package/app/components/CameraManager/List.vue +5 -5
- package/app/components/CameraManager/Saver.vue +3 -5
- package/app/components/CameraManager.vue +6 -4
- package/app/components/CameraOrientation.vue +12 -12
- package/app/components/ClippingPlaneCard.vue +4 -2
- package/app/components/ClippingPlanes.vue +8 -8
- package/app/components/CrsSelector.vue +9 -10
- package/app/components/DeleteDialog.vue +4 -2
- package/app/components/DragAndDrop.vue +10 -12
- package/app/components/DragAndDropInternal/DragAndDropInline.vue +4 -2
- package/app/components/ExtensionSelector.vue +4 -4
- package/app/components/FeedBack/ErrorBanner.vue +3 -1
- package/app/components/FeedBack/Snackers.vue +4 -3
- package/app/components/FileSelector.vue +10 -8
- package/app/components/FileUploader.vue +11 -11
- package/app/components/GlassCard.vue +1 -1
- package/app/components/HybridRenderingView.vue +7 -5
- package/app/components/HybridViewerTooltip.vue +7 -7
- package/app/components/Launcher.vue +1 -1
- package/app/components/Loading/EcoMessages.vue +9 -3
- package/app/components/Loading.vue +2 -2
- package/app/components/MissingFilesSelector.vue +12 -10
- package/app/components/ObjectSelector.vue +10 -9
- package/app/components/PackagesVersions.vue +6 -5
- package/app/components/Recaptcha.vue +3 -3
- package/app/components/RemoteRenderingView.vue +6 -7
- package/app/components/Ruler.vue +3 -3
- package/app/components/Screenshot.vue +6 -6
- package/app/components/SearchBar.vue +4 -2
- package/app/components/ShrinkFilter.vue +7 -7
- package/app/components/Step.vue +6 -5
- package/app/components/Stepper.vue +4 -3
- package/app/components/ToolPanel.vue +6 -3
- package/app/components/ViewToolbar.vue +25 -28
- package/app/components/Viewer/ContextMenu/CenterButton.vue +7 -5
- package/app/components/Viewer/ContextMenu/CircularItems.vue +3 -3
- package/app/components/Viewer/ContextMenu/ContextMenu.vue +22 -19
- package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +10 -8
- package/app/components/Viewer/ContextMenu/InfoCard.vue +11 -12
- package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +13 -17
- package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +11 -15
- package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +12 -16
- package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +8 -12
- package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +11 -15
- package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +11 -15
- package/app/components/Viewer/Generic/Model/BlocksOptions.vue +67 -38
- package/app/components/Viewer/Generic/Model/CornersOptions.vue +53 -23
- package/app/components/Viewer/Generic/Model/EdgesOptions.vue +1 -3
- package/app/components/Viewer/Generic/Model/LinesOptions.vue +67 -38
- package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +31 -15
- package/app/components/Viewer/Generic/Model/ModelStyleOptions.vue +2 -3
- package/app/components/Viewer/Generic/Model/PointsOptions.vue +6 -6
- package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +69 -38
- package/app/components/Viewer/ObjectTree/Base/CommonTreeView.vue +64 -46
- package/app/components/Viewer/ObjectTree/Base/Controls.vue +5 -5
- package/app/components/Viewer/ObjectTree/Base/ItemLabel.vue +13 -9
- package/app/components/Viewer/ObjectTree/Base/StickyHeader.vue +5 -5
- package/app/components/Viewer/ObjectTree/Base/TreeRow.vue +10 -10
- package/app/components/Viewer/ObjectTree/Box.vue +6 -4
- package/app/components/Viewer/ObjectTree/Layout.vue +23 -21
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +14 -14
- package/app/components/Viewer/ObjectTree/Views/{ModelCollections.vue → ModelTree.vue} +59 -24
- package/app/components/Viewer/Options/AttributeColorBar.vue +4 -2
- package/app/components/Viewer/Options/AttributeRangeSelector.vue +4 -2
- package/app/components/Viewer/Options/AttributeSelector.vue +7 -9
- package/app/components/Viewer/Options/ColorMapList.vue +15 -13
- package/app/components/Viewer/Options/ColorMapPicker.vue +4 -4
- package/app/components/Viewer/Options/ColorPicker.vue +223 -41
- package/app/components/Viewer/Options/ColoringTypeSelector.vue +16 -16
- package/app/components/Viewer/Options/ColormapQuickPicker.vue +7 -5
- package/app/components/Viewer/Options/OptionsSection.vue +1 -1
- package/app/components/Viewer/Options/TextureItem.vue +8 -6
- package/app/components/Viewer/Options/TexturesSelector.vue +1 -1
- package/app/components/Viewer/OverlappingObjectsPicker.vue +8 -9
- package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +2 -6
- package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +12 -16
- package/app/components/Viewer/Surface/PolygonsOptions.vue +12 -16
- package/app/components/Viewer/Ui.vue +2 -2
- package/app/components/Wrapper.vue +1 -4
- package/app/components/ZScaling.vue +5 -3
- package/app/components/csv-preview/CsvPreviewer.vue +38 -37
- package/app/components/csv-preview/CsvSettings.vue +6 -4
- package/app/components/csv-preview/CsvTable.vue +1 -1
- package/app/composables/batch_style.ts +5 -6
- package/app/composables/clipping_planes_widget.ts +73 -181
- package/app/composables/clipping_planes_widget_entries.ts +189 -0
- package/app/composables/copy_to_clipboard.ts +7 -0
- package/app/composables/global_attribute_style.ts +163 -83
- package/app/composables/hover_highlight.ts +46 -14
- package/app/composables/model_collections.ts +26 -13
- package/app/composables/model_components.ts +26 -13
- package/app/composables/project_manager.ts +76 -19
- package/app/composables/responsive_middle_truncate.ts +13 -13
- package/app/composables/stepper_tree.ts +34 -11
- package/app/composables/tree_filter.ts +66 -44
- package/app/composables/tree_keyboard_nav.ts +25 -11
- package/app/composables/tree_scroll.ts +44 -14
- package/app/composables/use_adaptive_styles.ts +66 -23
- package/app/composables/use_overlapping_picker.ts +66 -16
- package/app/composables/use_quick_colormap.ts +16 -5
- package/app/composables/virtual_tree.ts +75 -43
- package/app/composables/vtk_implicit_plane_widget.d.ts +2 -0
- package/app/plugins/auto_store_register.ts +2 -7
- package/app/plugins/click_outside_ignore_snackbars.client.ts +39 -0
- package/app/stores/app.ts +57 -192
- package/app/stores/app_helpers/extension.ts +179 -0
- package/app/stores/back.ts +37 -21
- package/app/stores/camera_manager.ts +22 -20
- package/app/stores/cloud.ts +17 -13
- package/app/stores/data.ts +88 -47
- package/app/stores/data_helpers/collections.ts +36 -38
- package/app/stores/data_helpers/mesh.ts +45 -36
- package/app/stores/data_style.ts +50 -28
- package/app/stores/feedback.ts +6 -6
- package/app/stores/hybrid_viewer.ts +41 -52
- package/app/stores/infra.ts +39 -37
- package/app/stores/menu.ts +23 -14
- package/app/stores/treeview.ts +72 -42
- package/app/stores/viewer.ts +39 -27
- package/app/utils/attributes.ts +3 -3
- package/app/utils/clipping_planes.ts +111 -14
- package/app/utils/color_picker.ts +57 -0
- package/app/utils/colormap.ts +58 -35
- package/app/utils/default_styles/index.ts +2 -2
- package/app/utils/default_styles/meshes.ts +107 -13
- package/app/utils/default_styles/models.ts +83 -14
- package/app/utils/extension.ts +47 -20
- package/app/utils/import_workflow.ts +21 -13
- package/app/utils/name_cleaner.ts +1 -1
- package/app/utils/string.ts +1 -1
- package/app/utils/treeview.ts +2 -2
- package/internal/database/base_database.ts +7 -3
- package/internal/database/database.ts +36 -26
- package/internal/database/extended_database.ts +1 -1
- package/internal/stores/data_style/mesh/cells/cell.ts +70 -34
- package/internal/stores/data_style/mesh/cells/color.ts +12 -6
- package/internal/stores/data_style/mesh/cells/common.ts +18 -8
- package/internal/stores/data_style/mesh/cells/index.ts +122 -42
- package/internal/stores/data_style/mesh/cells/textures.ts +12 -6
- package/internal/stores/data_style/mesh/cells/vertex.ts +75 -34
- package/internal/stores/data_style/mesh/cells/visibility.ts +15 -4
- package/internal/stores/data_style/mesh/edges/color.ts +12 -6
- package/internal/stores/data_style/mesh/edges/common.ts +14 -6
- package/internal/stores/data_style/mesh/edges/edge.ts +71 -39
- package/internal/stores/data_style/mesh/edges/index.ts +117 -42
- package/internal/stores/data_style/mesh/edges/vertex.ts +76 -39
- package/internal/stores/data_style/mesh/edges/visibility.ts +15 -4
- package/internal/stores/data_style/mesh/edges/width.ts +12 -4
- package/internal/stores/data_style/mesh/index.ts +30 -11
- package/internal/stores/data_style/mesh/points/color.ts +12 -6
- package/internal/stores/data_style/mesh/points/common.ts +21 -8
- package/internal/stores/data_style/mesh/points/index.ts +101 -50
- package/internal/stores/data_style/mesh/points/size.ts +12 -4
- package/internal/stores/data_style/mesh/points/vertex.ts +75 -34
- package/internal/stores/data_style/mesh/points/visibility.ts +17 -7
- package/internal/stores/data_style/mesh/polygons/color.ts +12 -6
- package/internal/stores/data_style/mesh/polygons/common.ts +23 -6
- package/internal/stores/data_style/mesh/polygons/index.ts +130 -70
- package/internal/stores/data_style/mesh/polygons/polygon.ts +77 -43
- package/internal/stores/data_style/mesh/polygons/textures.ts +12 -6
- package/internal/stores/data_style/mesh/polygons/vertex.ts +79 -39
- package/internal/stores/data_style/mesh/polygons/visibility.ts +16 -6
- package/internal/stores/data_style/mesh/polyhedra/color.ts +12 -6
- package/internal/stores/data_style/mesh/polyhedra/common.ts +14 -6
- package/internal/stores/data_style/mesh/polyhedra/index.ts +115 -56
- package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +80 -39
- package/internal/stores/data_style/mesh/polyhedra/vertex.ts +79 -39
- package/internal/stores/data_style/mesh/polyhedra/visibility.ts +16 -6
- package/internal/stores/data_style/model/blocks/color.ts +43 -13
- package/internal/stores/data_style/model/blocks/common.ts +21 -6
- package/internal/stores/data_style/model/blocks/index.ts +89 -59
- package/internal/stores/data_style/model/blocks/polyhedron.ts +101 -44
- package/internal/stores/data_style/model/blocks/vertex.ts +107 -42
- package/internal/stores/data_style/model/blocks/visibility.ts +17 -4
- package/internal/stores/data_style/model/color.ts +171 -83
- package/internal/stores/data_style/model/common.ts +70 -21
- package/internal/stores/data_style/model/corners/color.ts +43 -11
- package/internal/stores/data_style/model/corners/common.ts +25 -6
- package/internal/stores/data_style/model/corners/index.ts +66 -41
- package/internal/stores/data_style/model/corners/vertex.ts +105 -74
- package/internal/stores/data_style/model/corners/visibility.ts +19 -4
- package/internal/stores/data_style/model/edges/common.ts +12 -4
- package/internal/stores/data_style/model/edges/index.ts +2 -1
- package/internal/stores/data_style/model/edges/visibility.ts +24 -7
- package/internal/stores/data_style/model/index.ts +24 -11
- package/internal/stores/data_style/model/lines/color.ts +41 -11
- package/internal/stores/data_style/model/lines/common.ts +17 -6
- package/internal/stores/data_style/model/lines/edge.ts +105 -42
- package/internal/stores/data_style/model/lines/index.ts +86 -59
- package/internal/stores/data_style/model/lines/vertex.ts +105 -42
- package/internal/stores/data_style/model/lines/visibility.ts +17 -4
- package/internal/stores/data_style/model/points/common.ts +8 -4
- package/internal/stores/data_style/model/points/index.ts +10 -3
- package/internal/stores/data_style/model/points/size.ts +12 -4
- package/internal/stores/data_style/model/points/visibility.ts +16 -6
- package/internal/stores/data_style/model/selection.ts +80 -58
- package/internal/stores/data_style/model/surfaces/color.ts +41 -11
- package/internal/stores/data_style/model/surfaces/common.ts +23 -6
- package/internal/stores/data_style/model/surfaces/index.ts +89 -59
- package/internal/stores/data_style/model/surfaces/polygon.ts +107 -67
- package/internal/stores/data_style/model/surfaces/vertex.ts +111 -67
- package/internal/stores/data_style/model/surfaces/visibility.ts +18 -5
- package/internal/stores/data_style/model/visibility.ts +82 -20
- package/internal/stores/data_style/state.ts +77 -65
- package/internal/stores/hybrid_viewer/brightness.ts +49 -31
- package/internal/stores/hybrid_viewer/camera.ts +191 -177
- package/internal/stores/hybrid_viewer/camera_animation.ts +11 -10
- package/internal/stores/hybrid_viewer/core.ts +64 -0
- package/internal/stores/hybrid_viewer/filters.ts +10 -16
- package/internal/stores/hybrid_viewer/highlight.ts +91 -130
- package/internal/stores/hybrid_viewer/ruler.ts +24 -15
- package/internal/stores/hybrid_viewer/scene.ts +96 -117
- package/internal/stores/hybrid_viewer/viewport.ts +74 -65
- package/internal/stores/hybrid_viewer/vtk_types.ts +13 -29
- package/internal/utils/api_fetch.ts +54 -23
- package/internal/utils/upload_file.ts +74 -53
- package/internal/utils/viewer_call.ts +22 -13
- package/internal/utils/ws_client.ts +24 -13
- package/nuxt.config.ts +58 -1
- package/package.json +20 -8
- package/server/api/cloud/extensions/run.post.ts +6 -10
- package/server/api/local/app/project_folder_path.post.ts +4 -4
- package/server/api/local/app/run_back.post.ts +5 -7
- package/server/api/local/app/run_viewer.post.ts +5 -7
- package/server/api/local/extensions/kill.post.ts +4 -3
- package/server/api/local/extensions/run.post.ts +7 -10
- package/server/api/local/extensions/upload.put.ts +44 -54
- package/server/api/microservice/app/get_is_app_ready.get.ts +4 -5
- package/server/api/microservice/app/set_app_base_url.post.ts +5 -6
- package/server/api/microservice/app/set_back_base_url.post.ts +5 -6
- package/server/api/microservice/app/set_is_app_ready.post.ts +5 -6
- package/server/api/microservice/app/set_viewer_base_url.post.ts +5 -6
- package/server/api/microservice/extensions/download.post.ts +5 -4
- package/server/api/serverless/run_cloud.post.ts +53 -11
- package/server/utils/app_config.ts +29 -22
- package/server/utils/cleanup.ts +60 -30
- package/server/utils/cloud.ts +9 -8
- package/server/utils/extension.ts +23 -9
- package/server/utils/microservices.ts +33 -24
- package/server/utils/path.ts +4 -4
- package/server/utils/scripts.ts +26 -23
- package/server/utils/server.ts +2 -2
- package/server/utils/server_config.ts +41 -27
- package/server/utils/stream.ts +6 -0
- package/server/utils/ws_client.ts +42 -8
- package/shared/scripts.ts +15 -10
- package/shared/utils/call_raw.ts +23 -16
- package/shared/utils/call_schema.ts +5 -8
- package/shared/utils/fetch_raw.ts +87 -47
- package/shared/utils/fetch_schema.ts +6 -9
- package/shared/utils/file.ts +8 -2
- package/shared/utils/response_handlers/load.ts +26 -11
- package/shared/utils/types.ts +9 -9
- package/shared/utils/validate_schema.ts +1 -1
- package/app/components/Viewer/ObjectTree/Views/ModelComponents.vue +0 -276
- package/server/types/vendor.d.ts +0 -64
- package/server/utils/server_config.js +0 -43
- package/shared/utils/call_raw.js +0 -30
- package/shared/utils/fetch_raw.js +0 -40
- /package/{opengeodeweb_front_schemas.js → .build/opengeodeweb_front_schemas.js} +0 -0
- /package/{server → .build/server}/utils/server.js +0 -0
- /package/{shared → .build/shared}/app_mode.js +0 -0
- /package/{shared → .build/shared}/utils/parse_boolean.js +0 -0
- /package/{shared → .build/shared}/utils/types.js +0 -0
package/shared/utils/call_raw.ts
CHANGED
|
@@ -6,35 +6,40 @@ import pTimeout from "p-timeout";
|
|
|
6
6
|
import type { RequestHandlers } from "./types.js";
|
|
7
7
|
|
|
8
8
|
interface RpcSession {
|
|
9
|
-
call: (rpc: string, params: [Record<string, unknown>]) => Promise<unknown>;
|
|
9
|
+
readonly call: (rpc: string, params: readonly [Record<string, unknown>]) => Promise<unknown>;
|
|
10
10
|
}
|
|
11
11
|
interface RpcConnection {
|
|
12
|
-
getSession: () => RpcSession;
|
|
12
|
+
readonly getSession: () => RpcSession;
|
|
13
13
|
}
|
|
14
14
|
interface RpcClient {
|
|
15
|
-
call: (rpc: string, params: Record<string, unknown>) => Promise<unknown>;
|
|
16
|
-
getConnection: () => RpcConnection;
|
|
15
|
+
readonly call: (rpc: string, params: Record<string, unknown>) => Promise<unknown>;
|
|
16
|
+
readonly getConnection: () => RpcConnection;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
interface
|
|
19
|
+
interface CallClientOptions {
|
|
20
20
|
rpc: string;
|
|
21
21
|
params?: Record<string, unknown>;
|
|
22
22
|
client: RpcClient;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface CallRawOptions extends CallClientOptions {
|
|
23
26
|
timeout?: number;
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
function callClient({ rpc, params = {}, client }:
|
|
29
|
+
async function callClient({ rpc, params = {}, client }: CallClientOptions): Promise<unknown> {
|
|
27
30
|
if (globalThis.window !== undefined) {
|
|
28
|
-
|
|
31
|
+
const response = await client.getConnection().getSession().call(rpc, [params]);
|
|
32
|
+
return response;
|
|
29
33
|
}
|
|
30
|
-
|
|
34
|
+
const response = await client.call(rpc, params);
|
|
35
|
+
return response;
|
|
31
36
|
}
|
|
32
37
|
|
|
33
|
-
function callRaw(
|
|
38
|
+
async function callRaw(
|
|
34
39
|
{ rpc, params = {}, client, timeout }: CallRawOptions,
|
|
35
40
|
{ request_error_function, response_function, response_error_function }: RequestHandlers = {},
|
|
36
|
-
) {
|
|
37
|
-
async function performCall() {
|
|
41
|
+
): Promise<unknown> {
|
|
42
|
+
async function performCall(): Promise<unknown> {
|
|
38
43
|
try {
|
|
39
44
|
const response = await callClient({ rpc, params, client });
|
|
40
45
|
if (response_function) {
|
|
@@ -43,23 +48,25 @@ function callRaw(
|
|
|
43
48
|
return response;
|
|
44
49
|
} catch (error) {
|
|
45
50
|
if (request_error_function) {
|
|
46
|
-
request_error_function(error);
|
|
51
|
+
await request_error_function(error);
|
|
47
52
|
}
|
|
48
53
|
if (response_error_function) {
|
|
49
|
-
response_error_function(error);
|
|
54
|
+
await response_error_function(error);
|
|
50
55
|
}
|
|
51
56
|
throw error;
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
59
|
|
|
55
|
-
if (timeout && timeout > 0) {
|
|
56
|
-
|
|
60
|
+
if (timeout !== undefined && timeout > 0) {
|
|
61
|
+
const result = await pTimeout(performCall(), {
|
|
57
62
|
milliseconds: timeout,
|
|
58
63
|
message: `${rpc}: Timed out after ${timeout}ms`,
|
|
59
64
|
});
|
|
65
|
+
return result;
|
|
60
66
|
}
|
|
61
67
|
|
|
62
|
-
|
|
68
|
+
const result = await performCall();
|
|
69
|
+
return result;
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
export { callRaw };
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
// Not auto-fixable (eslint's sort-imports core rule has no autofixer) and this file's import order doesn't match its syntax-kind-then-alphabetical requirement - left as-is rather than manually reordered across the codebase for a purely cosmetic rule.
|
|
2
|
-
// oxlint-disable eslint/sort-imports
|
|
3
1
|
// Third party imports
|
|
4
2
|
|
|
5
3
|
// Local imports
|
|
6
|
-
import { callRaw } from "./call_raw.js";
|
|
7
|
-
// oxlint-disable-next-line eslint/no-duplicate-imports
|
|
8
|
-
import type { RpcClient } from "./call_raw.js";
|
|
9
4
|
import type { JsonRpcSchema, RequestHandlersWithValidation } from "./types.js";
|
|
5
|
+
import { type RpcClient, callRaw } from "./call_raw.js";
|
|
10
6
|
import { validateSchema } from "./validate_schema.js";
|
|
11
7
|
|
|
12
8
|
const ERROR_400 = 400;
|
|
@@ -18,7 +14,7 @@ interface CallSchemaOptions {
|
|
|
18
14
|
timeout?: number;
|
|
19
15
|
}
|
|
20
16
|
|
|
21
|
-
function callSchema(
|
|
17
|
+
async function callSchema(
|
|
22
18
|
{ schema, params = {}, client, timeout }: CallSchemaOptions,
|
|
23
19
|
{
|
|
24
20
|
request_error_function,
|
|
@@ -26,7 +22,7 @@ function callSchema(
|
|
|
26
22
|
response_error_function,
|
|
27
23
|
validation_error_function,
|
|
28
24
|
}: RequestHandlersWithValidation = {},
|
|
29
|
-
) {
|
|
25
|
+
): Promise<unknown> {
|
|
30
26
|
const { valid, error: schema_error } = validateSchema(schema, params);
|
|
31
27
|
|
|
32
28
|
if (!valid) {
|
|
@@ -39,7 +35,7 @@ function callSchema(
|
|
|
39
35
|
throw new Error(`${schema.$id}: ${schema_error}`);
|
|
40
36
|
}
|
|
41
37
|
|
|
42
|
-
|
|
38
|
+
const result = await callRaw(
|
|
43
39
|
{
|
|
44
40
|
rpc: schema.$id,
|
|
45
41
|
params,
|
|
@@ -52,6 +48,7 @@ function callSchema(
|
|
|
52
48
|
response_error_function,
|
|
53
49
|
},
|
|
54
50
|
);
|
|
51
|
+
return result;
|
|
55
52
|
}
|
|
56
53
|
|
|
57
54
|
export { callSchema };
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
// Not auto-fixable (eslint's sort-imports core rule has no autofixer) and this file's import order doesn't match its syntax-kind-then-alphabetical requirement - left as-is rather than manually reordered across the codebase for a purely cosmetic rule.
|
|
2
|
-
// oxlint-disable eslint/sort-imports
|
|
3
1
|
// Third party imports
|
|
4
2
|
import { $fetch } from "ofetch";
|
|
5
3
|
import _ from "lodash";
|
|
6
4
|
import pTimeout from "p-timeout";
|
|
7
5
|
|
|
8
6
|
// Local imports
|
|
9
|
-
import { hasBody } from "./file.js";
|
|
10
7
|
import type { RequestHandlers } from "./types.js";
|
|
8
|
+
import { hasBody } from "./file.js";
|
|
11
9
|
|
|
12
10
|
interface FetchRawOptions {
|
|
13
11
|
route: string;
|
|
@@ -20,7 +18,75 @@ interface FetchRawOptions {
|
|
|
20
18
|
expectEvent?: boolean;
|
|
21
19
|
}
|
|
22
20
|
|
|
23
|
-
function
|
|
21
|
+
function resolveHeaders(
|
|
22
|
+
headers: Record<string, string>,
|
|
23
|
+
expectEvent: boolean,
|
|
24
|
+
): Record<string, string> {
|
|
25
|
+
const resolvedHeaders: Record<string, string> = { ...headers };
|
|
26
|
+
if (expectEvent) {
|
|
27
|
+
const value = "text/event-stream";
|
|
28
|
+
if (_.isEmpty(resolvedHeaders)) {
|
|
29
|
+
resolvedHeaders.Accept = value;
|
|
30
|
+
} else {
|
|
31
|
+
resolvedHeaders.Accept = `${resolvedHeaders.Accept}, ${value}`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return resolvedHeaders;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface PerformFetchOptions extends RequestHandlers {
|
|
38
|
+
route: string;
|
|
39
|
+
method?: string;
|
|
40
|
+
params?: unknown;
|
|
41
|
+
baseURL?: string;
|
|
42
|
+
headers: Record<string, string>;
|
|
43
|
+
max_retry?: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function performFetch({
|
|
47
|
+
route,
|
|
48
|
+
method,
|
|
49
|
+
params,
|
|
50
|
+
baseURL,
|
|
51
|
+
headers,
|
|
52
|
+
max_retry,
|
|
53
|
+
request_error_function,
|
|
54
|
+
response_function,
|
|
55
|
+
response_error_function,
|
|
56
|
+
}: PerformFetchOptions): Promise<unknown> {
|
|
57
|
+
const fetchResult = await $fetch<unknown>(route, {
|
|
58
|
+
baseURL,
|
|
59
|
+
method,
|
|
60
|
+
headers,
|
|
61
|
+
...(hasBody(params) ? { body: params } : {}),
|
|
62
|
+
...(max_retry === undefined ? {} : { retry: max_retry }),
|
|
63
|
+
async onRequestError({ error }: { error: unknown }) {
|
|
64
|
+
if (request_error_function) {
|
|
65
|
+
await request_error_function(error);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
async onResponse({
|
|
69
|
+
response,
|
|
70
|
+
}: {
|
|
71
|
+
// oxlint-disable-next-line eslint/id-length -- mirrors the real ofetch/vitest API field name (`ok`/`fn`)
|
|
72
|
+
response: { ok: boolean; _data?: unknown };
|
|
73
|
+
}) {
|
|
74
|
+
if (response.ok && response_function) {
|
|
75
|
+
// Ofetch awaits whatever this hook returns; without awaiting here, callers relying on
|
|
76
|
+
// An async response_function (e.g. store patches) race the resolution of this $fetch call.
|
|
77
|
+
await response_function(response._data);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
async onResponseError({ response }: { response: unknown }) {
|
|
81
|
+
if (response_error_function) {
|
|
82
|
+
await response_error_function(response);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
return fetchResult;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function fetchRaw(
|
|
24
90
|
{
|
|
25
91
|
route,
|
|
26
92
|
method,
|
|
@@ -32,54 +98,28 @@ function fetchRaw(
|
|
|
32
98
|
expectEvent = false,
|
|
33
99
|
}: FetchRawOptions,
|
|
34
100
|
{ request_error_function, response_function, response_error_function }: RequestHandlers = {},
|
|
35
|
-
) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
request_options.body = params;
|
|
48
|
-
}
|
|
49
|
-
if (max_retry) {
|
|
50
|
-
request_options.max_retry = max_retry;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function doFetch() {
|
|
54
|
-
return $fetch(route, {
|
|
55
|
-
baseURL,
|
|
56
|
-
...request_options,
|
|
57
|
-
onRequestError({ error }: { error: unknown }) {
|
|
58
|
-
if (request_error_function) {
|
|
59
|
-
request_error_function(error);
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
// oxlint-disable-next-line eslint/id-length -- mirrors the real ofetch/vitest API field name (`ok`/`fn`)
|
|
63
|
-
onResponse({ response }: { response: { ok: boolean; _data: unknown } }) {
|
|
64
|
-
if (response.ok && response_function) {
|
|
65
|
-
response_function(response._data);
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
onResponseError({ response }: { response: unknown }) {
|
|
69
|
-
if (response_error_function) {
|
|
70
|
-
response_error_function(response);
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
} as Parameters<typeof $fetch>[1]);
|
|
74
|
-
}
|
|
101
|
+
): Promise<unknown> {
|
|
102
|
+
const fetchOptions: PerformFetchOptions = {
|
|
103
|
+
route,
|
|
104
|
+
method,
|
|
105
|
+
params,
|
|
106
|
+
baseURL,
|
|
107
|
+
headers: resolveHeaders(headers, expectEvent),
|
|
108
|
+
max_retry,
|
|
109
|
+
request_error_function,
|
|
110
|
+
response_function,
|
|
111
|
+
response_error_function,
|
|
112
|
+
};
|
|
75
113
|
|
|
76
|
-
if (timeout && timeout > 0) {
|
|
77
|
-
|
|
114
|
+
if (timeout !== undefined && timeout > 0) {
|
|
115
|
+
const result = await pTimeout(performFetch(fetchOptions), {
|
|
78
116
|
milliseconds: timeout,
|
|
79
117
|
message: `${route}: Timed out after ${timeout}ms`,
|
|
80
118
|
});
|
|
119
|
+
return result;
|
|
81
120
|
}
|
|
82
|
-
|
|
121
|
+
const result = await performFetch(fetchOptions);
|
|
122
|
+
return result;
|
|
83
123
|
}
|
|
84
124
|
|
|
85
125
|
export { fetchRaw };
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
// Not auto-fixable (eslint's sort-imports core rule has no autofixer) and this file's import order doesn't match its syntax-kind-then-alphabetical requirement - left as-is rather than manually reordered across the codebase for a purely cosmetic rule.
|
|
2
|
-
// oxlint-disable eslint/sort-imports
|
|
3
|
-
// Third party imports
|
|
4
|
-
|
|
5
1
|
// Local imports
|
|
6
|
-
import { fetchRaw } from "./fetch_raw.js";
|
|
7
2
|
import type { JsonRpcSchema, RequestHandlersWithValidation } from "./types.js";
|
|
3
|
+
import { fetchRaw } from "./fetch_raw.js";
|
|
8
4
|
import { validateSchema } from "./validate_schema.js";
|
|
9
5
|
|
|
10
6
|
const ERROR_400 = 400;
|
|
11
7
|
|
|
12
8
|
interface FetchSchemaOptions {
|
|
13
|
-
schema: JsonRpcSchema & { methods: string[] };
|
|
9
|
+
schema: JsonRpcSchema & { methods: readonly string[] };
|
|
14
10
|
params?: unknown;
|
|
15
11
|
baseURL?: string;
|
|
16
12
|
headers?: Record<string, string>;
|
|
@@ -18,7 +14,7 @@ interface FetchSchemaOptions {
|
|
|
18
14
|
expectEvent?: boolean;
|
|
19
15
|
}
|
|
20
16
|
|
|
21
|
-
function fetchSchema(
|
|
17
|
+
async function fetchSchema(
|
|
22
18
|
{ schema, params = {}, baseURL, headers, timeout, expectEvent = false }: FetchSchemaOptions,
|
|
23
19
|
{
|
|
24
20
|
request_error_function,
|
|
@@ -26,7 +22,7 @@ function fetchSchema(
|
|
|
26
22
|
response_error_function,
|
|
27
23
|
validation_error_function,
|
|
28
24
|
}: RequestHandlersWithValidation = {},
|
|
29
|
-
) {
|
|
25
|
+
): Promise<unknown> {
|
|
30
26
|
const { valid, error: schema_error } = validateSchema(schema, params);
|
|
31
27
|
|
|
32
28
|
if (!valid) {
|
|
@@ -39,7 +35,7 @@ function fetchSchema(
|
|
|
39
35
|
throw new Error(`${schema.$id}: ${schema_error}`);
|
|
40
36
|
}
|
|
41
37
|
|
|
42
|
-
|
|
38
|
+
const result = await fetchRaw(
|
|
43
39
|
{
|
|
44
40
|
route: schema.$id,
|
|
45
41
|
method: schema.methods.find((method) => method !== "OPTIONS"),
|
|
@@ -56,6 +52,7 @@ function fetchSchema(
|
|
|
56
52
|
response_error_function,
|
|
57
53
|
},
|
|
58
54
|
);
|
|
55
|
+
return result;
|
|
59
56
|
}
|
|
60
57
|
|
|
61
58
|
export { fetchSchema };
|
package/shared/utils/file.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
2
|
|
|
3
|
+
const BYTES_PER_KIBIBYTE = 1024;
|
|
4
|
+
const KIBIBYTES_PER_MEBIBYTE = 1024;
|
|
5
|
+
const CHUNK_SIZE_MEBIBYTES = 8;
|
|
6
|
+
// Cloud hosting in front of the upload routes (Cloud Run/Firebase Hosting) enforces a hard ~32MB request body limit that no amount of server-side streaming can bypass, so uploads are always split into chunks comfortably under that cap. The single source of truth here keeps every uploader (OpenGeodeWeb-Front, Vease) and the routes that assemble the chunks in agreement.
|
|
7
|
+
const CHUNK_SIZE_BYTES = CHUNK_SIZE_MEBIBYTES * KIBIBYTES_PER_MEBIBYTE * BYTES_PER_KIBIBYTE;
|
|
8
|
+
|
|
3
9
|
function assertFile(file: unknown): asserts file is File {
|
|
4
10
|
console.log("[ASSERT_FILE] Asserting file", { file });
|
|
5
11
|
if (!(file instanceof File)) {
|
|
@@ -7,10 +13,10 @@ function assertFile(file: unknown): asserts file is File {
|
|
|
7
13
|
}
|
|
8
14
|
}
|
|
9
15
|
|
|
10
|
-
function hasBody(params: unknown):
|
|
16
|
+
function hasBody(params: unknown): params is Blob | FormData | Record<string, unknown> {
|
|
11
17
|
if (params instanceof FormData || params instanceof Blob) {
|
|
12
18
|
return true;
|
|
13
19
|
}
|
|
14
20
|
return !_.isEmpty(params);
|
|
15
21
|
}
|
|
16
|
-
export { assertFile, hasBody };
|
|
22
|
+
export { assertFile, BYTES_PER_KIBIBYTE, CHUNK_SIZE_BYTES, hasBody };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
interface AllowedObject {
|
|
2
|
-
is_loadable: number;
|
|
3
|
-
object_priority?: number;
|
|
2
|
+
readonly is_loadable: number;
|
|
3
|
+
readonly object_priority?: number;
|
|
4
4
|
}
|
|
5
5
|
type AllowedObjectMap = Record<string, AllowedObject>;
|
|
6
6
|
|
|
@@ -21,8 +21,13 @@ function selectGeodeObject(objectMap: AllowedObjectMap): string | undefined {
|
|
|
21
21
|
if (objectKeys.length === 0) {
|
|
22
22
|
return undefined;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const [firstKey] = objectKeys;
|
|
25
|
+
if (
|
|
26
|
+
objectKeys.length === 1 &&
|
|
27
|
+
firstKey !== undefined &&
|
|
28
|
+
getObject(objectMap, firstKey).is_loadable > 0
|
|
29
|
+
) {
|
|
30
|
+
return firstKey;
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
const highestLoadScore = Math.max(
|
|
@@ -52,7 +57,7 @@ function selectGeodeObject(objectMap: AllowedObjectMap): string | undefined {
|
|
|
52
57
|
return undefined;
|
|
53
58
|
}
|
|
54
59
|
|
|
55
|
-
function intersectAllowedObjects(allowedObjectsList: AllowedObjectMap[]): {
|
|
60
|
+
function intersectAllowedObjects(allowedObjectsList: readonly AllowedObjectMap[]): {
|
|
56
61
|
commonKeys: string[];
|
|
57
62
|
allKeys: string[];
|
|
58
63
|
mergedAllowedObjects: AllowedObjectMap;
|
|
@@ -60,23 +65,33 @@ function intersectAllowedObjects(allowedObjectsList: AllowedObjectMap[]): {
|
|
|
60
65
|
const allKeys = [...new Set(allowedObjectsList.flatMap((object) => Object.keys(object)))];
|
|
61
66
|
const commonKeys = allKeys.filter((key) => allowedObjectsList.every((object) => key in object));
|
|
62
67
|
|
|
63
|
-
const
|
|
64
|
-
for (const key of commonKeys) {
|
|
68
|
+
const mergedEntries = commonKeys.map((key): [string, AllowedObject] => {
|
|
65
69
|
const loadScores = allowedObjectsList.map((object) => getObject(object, key).is_loadable);
|
|
66
70
|
const priorities = allowedObjectsList
|
|
67
71
|
.map((object) => getObject(object, key).object_priority)
|
|
68
72
|
.filter((priority): priority is number => priority !== undefined);
|
|
69
73
|
|
|
70
|
-
mergedAllowedObjects[key] = { is_loadable: Math.min(...loadScores) };
|
|
71
74
|
if (priorities.length > 0) {
|
|
72
|
-
|
|
75
|
+
return [
|
|
76
|
+
key,
|
|
77
|
+
{ is_loadable: Math.min(...loadScores), object_priority: Math.max(...priorities) },
|
|
78
|
+
];
|
|
73
79
|
}
|
|
74
|
-
|
|
80
|
+
return [key, { is_loadable: Math.min(...loadScores) }];
|
|
81
|
+
});
|
|
82
|
+
const mergedAllowedObjects: AllowedObjectMap = Object.fromEntries(mergedEntries);
|
|
75
83
|
|
|
76
84
|
return { commonKeys, allKeys, mergedAllowedObjects };
|
|
77
85
|
}
|
|
78
86
|
|
|
79
|
-
function resolveAllowedObjects(
|
|
87
|
+
function resolveAllowedObjects(
|
|
88
|
+
filenames: readonly string[],
|
|
89
|
+
allowedObjectsList: readonly AllowedObjectMap[],
|
|
90
|
+
): {
|
|
91
|
+
mergedAllowedObjects: AllowedObjectMap;
|
|
92
|
+
multipleFilesNoCommon: boolean;
|
|
93
|
+
selectedGeodeObject: string | undefined;
|
|
94
|
+
} {
|
|
80
95
|
const { commonKeys, allKeys, mergedAllowedObjects } = intersectAllowedObjects(allowedObjectsList);
|
|
81
96
|
|
|
82
97
|
const multipleFilesNoCommon =
|
package/shared/utils/types.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Covers both flavors of schema used across this codebase: HTTP ("front") schemas carry a `methods` array, websocket RPC ("viewer"/"back") schemas carry `rpc` instead. Neither field is required here since call sites that need one specifically (e.g. fetchSchema needing `methods`) narrow it themselves.
|
|
2
2
|
interface JsonRpcSchema {
|
|
3
|
-
$id: string;
|
|
4
|
-
methods?: string[];
|
|
5
|
-
rpc?: string;
|
|
6
|
-
max_retry?: number;
|
|
7
|
-
[key: string]: unknown;
|
|
3
|
+
readonly $id: string;
|
|
4
|
+
readonly methods?: readonly string[];
|
|
5
|
+
readonly rpc?: string;
|
|
6
|
+
readonly max_retry?: number;
|
|
7
|
+
readonly [key: string]: unknown;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
interface ValidationError {
|
|
@@ -14,14 +14,14 @@ interface ValidationError {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
interface RequestHandlers {
|
|
17
|
-
request_error_function?: (error: unknown) => void
|
|
17
|
+
readonly request_error_function?: (error: unknown) => void | Promise<void>;
|
|
18
18
|
// Return value is intentionally untyped: callers commonly return the Promise of a downstream call (e.g. a Dexie `.put()`, which resolves to a primary key) that this code chains/awaits but never inspects the resolved value of.
|
|
19
|
-
response_function?: (response: unknown) => unknown;
|
|
20
|
-
response_error_function?: (response: unknown) => void
|
|
19
|
+
readonly response_function?: (response: unknown) => unknown;
|
|
20
|
+
readonly response_error_function?: (response: unknown) => void | Promise<void>;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
interface RequestHandlersWithValidation extends RequestHandlers {
|
|
24
|
-
validation_error_function?: (error: ValidationError) => void;
|
|
24
|
+
readonly validation_error_function?: (error: ValidationError) => void;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export type { JsonRpcSchema, RequestHandlers, RequestHandlersWithValidation, ValidationError };
|
|
@@ -8,7 +8,7 @@ function validateSchema(schema: JsonRpcSchema, body: unknown): { valid: boolean;
|
|
|
8
8
|
for (const keyword of list_keywords) {
|
|
9
9
|
ajv.addKeyword(keyword);
|
|
10
10
|
}
|
|
11
|
-
const valid =
|
|
11
|
+
const valid = ajv.validate(schema, body);
|
|
12
12
|
return { valid, error: ajv.errorsText() };
|
|
13
13
|
}
|
|
14
14
|
|