@geode/opengeodeweb-front 10.43.2 → 10.44.0-rc.10
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/.build/server/utils/cleanup.js +7 -2
- package/.build/server/utils/microservices.js +9 -81
- package/.build/server/utils/microservices_process.js +85 -0
- package/.build/server/utils/scripts.js +34 -23
- package/.build/server/utils/typed_handler.js +5 -1
- package/.build/server/utils/ws_client.js +7 -2
- package/.build/shared/utils/fetch_raw.js +2 -2
- package/.build/shared/utils/parse_boolean.js +2 -1
- package/app/assets/geode_objects.ts +1 -0
- package/app/components/BasemapAttribution.vue +28 -0
- package/app/components/ClippingPlanes.vue +22 -78
- package/app/components/CrsSelector.vue +53 -46
- package/app/components/DragAndDrop.vue +16 -79
- package/app/components/FeedBack/Snackers.vue +27 -0
- package/app/components/FileSelector.vue +9 -6
- package/app/components/HybridViewerTooltip.vue +8 -2
- package/app/components/MissingFilesSelector.vue +40 -23
- package/app/components/ObjectSelector.vue +34 -20
- package/app/components/ProjectCrs.vue +37 -0
- package/app/components/Screenshot.vue +17 -59
- package/app/components/ThresholdCard.vue +205 -0
- package/app/components/ThresholdFilter.vue +81 -216
- package/app/components/ViewToolbar.vue +15 -231
- package/app/components/Viewer/Basemap/CropOptions.vue +50 -0
- package/app/components/Viewer/Basemap/OpacityOptions.vue +52 -0
- package/app/components/Viewer/ContextMenu/CircularItems.vue +1 -2
- package/app/components/Viewer/ContextMenu/ContextMenu.vue +11 -6
- package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +10 -7
- package/app/components/Viewer/ContextMenu/InfoCard.vue +30 -0
- package/app/components/Viewer/EdgedCurve/SpecificEdgesColoring.vue +209 -0
- package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +3 -191
- package/app/components/Viewer/Generic/Mesh/CellsColoring.vue +221 -0
- package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +3 -210
- package/app/components/Viewer/Generic/Mesh/EdgesColoring.vue +211 -0
- package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +3 -192
- package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +13 -0
- package/app/components/Viewer/Generic/Mesh/PolygonsColoring.vue +227 -0
- package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +3 -215
- package/app/components/Viewer/Generic/Mesh/PolyhedraColoring.vue +221 -0
- package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +3 -203
- package/app/components/Viewer/Generic/Model/BlocksOptions.vue +14 -12
- package/app/components/Viewer/Generic/Model/ComponentPointsOptions.vue +2 -18
- package/app/components/Viewer/Generic/Model/CornerComponentOptions.vue +145 -0
- package/app/components/Viewer/Generic/Model/CornersOptions.vue +15 -294
- package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +173 -0
- package/app/components/Viewer/Generic/Model/LineComponentOptions.vue +218 -0
- package/app/components/Viewer/Generic/Model/LinesOptions.vue +15 -427
- package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +229 -0
- package/app/components/Viewer/Generic/Model/ModelCardTabs.vue +35 -0
- package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +34 -25
- package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +34 -25
- package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +17 -5
- package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +16 -12
- package/app/components/Viewer/ObjectTree/Base/ComponentRelations.vue +4 -1
- package/app/components/Viewer/ObjectTree/Base/ItemLabel.vue +71 -1
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +55 -10
- package/app/components/Viewer/Options/AttributeRangeSelector.vue +11 -4
- package/app/components/Viewer/Options/AttributeSelector.vue +40 -136
- package/app/components/Viewer/Options/ColorPicker.vue +4 -1
- package/app/components/Viewer/Options/ColoringTypeSelector.vue +48 -74
- package/app/components/Viewer/Options/ColormapQuickPicker.vue +13 -7
- package/app/components/Viewer/Options/NoDataColorInfo.vue +56 -0
- package/app/components/Viewer/Options/Sliders/Opacity.vue +22 -0
- package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +13 -0
- package/app/components/Viewer/Scene/BackgroundOptions.vue +37 -0
- package/app/components/Viewer/Scene/OrientationWidgetOptions.vue +48 -0
- package/app/components/Viewer/Scene/TextOptions.vue +63 -0
- package/app/components/Viewer/Solid/SpecificPolyhedraColoring.vue +217 -0
- package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +4 -199
- package/app/components/Viewer/Surface/PolygonsColoring.vue +224 -0
- package/app/components/Viewer/Surface/PolygonsOptions.vue +3 -213
- package/app/components/Viewer/Ui.vue +9 -0
- package/app/components/csv-preview/CsvPreviewer.vue +4 -1
- package/app/composables/attribute_coloring_style.ts +8 -2
- package/app/composables/attribute_selector.ts +126 -0
- package/app/composables/batch_style_model.ts +34 -0
- package/app/composables/clipping_slices.ts +166 -0
- package/app/composables/global_attribute_style.ts +4 -3
- package/app/composables/hover_highlight.ts +19 -18
- package/app/composables/live_data_item.ts +39 -0
- package/app/composables/model_tabs.ts +86 -0
- package/app/composables/overlapping_picker_menu.ts +43 -0
- package/app/composables/project_manager.ts +5 -81
- package/app/composables/project_manager_helpers/reset.ts +34 -0
- package/app/composables/project_manager_helpers/restore.ts +67 -0
- package/app/composables/project_manager_helpers/types.ts +24 -0
- package/app/composables/project_manager_helpers/viewer_session.ts +25 -0
- package/app/composables/stepper_tree.ts +10 -2
- package/app/composables/tree_filter.ts +11 -2
- package/app/composables/tree_keyboard_nav.ts +4 -2
- package/app/composables/use_overlapping_picker.ts +30 -42
- package/app/composables/view_toolbar_options.ts +126 -0
- package/app/composables/view_toolbar_tool_options.ts +115 -0
- package/app/composables/view_toolbar_tools.ts +108 -0
- package/app/composables/viewer_context_menu.ts +19 -1
- package/app/composables/virtual_tree.ts +20 -131
- package/app/composables/virtual_tree_flatten.ts +109 -0
- package/app/composables/virtual_tree_types.ts +81 -0
- package/app/stores/app.ts +8 -55
- package/app/stores/app_helpers/extension.ts +90 -51
- package/app/stores/app_helpers/registry.ts +69 -0
- package/app/stores/basemap.ts +52 -0
- package/app/stores/basemap_detail.ts +51 -0
- package/app/stores/basemap_helpers/builds.ts +158 -0
- package/app/stores/basemap_helpers/detail_layers.ts +72 -0
- package/app/stores/basemap_helpers/detail_map.ts +62 -0
- package/app/stores/basemap_helpers/detail_refresh.ts +134 -0
- package/app/stores/basemap_helpers/detail_view.ts +94 -0
- package/app/stores/basemap_helpers/extent.ts +40 -0
- package/app/stores/basemap_helpers/georeferenced.ts +50 -0
- package/app/stores/basemap_helpers/layers.ts +66 -0
- package/app/stores/basemap_helpers/settings.ts +87 -0
- package/app/stores/basemap_helpers/viewer.ts +114 -0
- package/app/stores/crs.ts +136 -0
- package/app/stores/data.ts +24 -1
- package/app/stores/data_style.ts +8 -0
- package/app/stores/feedback.ts +12 -2
- package/app/stores/hybrid_viewer.ts +1 -1
- package/app/stores/infra.ts +26 -21
- package/app/stores/menu.ts +8 -124
- package/app/stores/menu_helpers/basemap.ts +10 -0
- package/app/stores/menu_helpers/menus_data.ts +27 -0
- package/app/stores/menu_helpers/mesh/edged_curve.ts +12 -0
- package/app/stores/menu_helpers/mesh/grid.ts +24 -0
- package/app/stores/menu_helpers/mesh/point_set.ts +11 -0
- package/app/stores/menu_helpers/mesh/solid.ts +29 -0
- package/app/stores/menu_helpers/mesh/surface.ts +22 -0
- package/app/stores/menu_helpers/model.ts +25 -0
- package/app/stores/menu_helpers/scene.ts +10 -0
- package/app/stores/menu_helpers/types.ts +5 -0
- package/app/stores/treeview.ts +17 -10
- package/app/stores/viewer.ts +17 -79
- package/app/stores/viewer_helpers/actions.ts +68 -0
- package/app/stores/viewer_helpers/request.ts +61 -0
- package/app/utils/basemap_tree.ts +76 -0
- package/app/utils/clipping_planes.ts +4 -131
- package/app/utils/clipping_planes_scene.ts +131 -0
- package/app/utils/color_picker.ts +18 -15
- package/app/utils/coloring_styles.ts +101 -0
- package/app/utils/crs.ts +38 -0
- package/app/utils/default_styles/constants.ts +10 -0
- package/app/utils/default_styles/index.ts +17 -1
- package/app/utils/default_styles/mesh_components.ts +168 -0
- package/app/utils/default_styles/meshes.ts +13 -153
- package/app/utils/default_styles/model_components.ts +170 -0
- package/app/utils/default_styles/models.ts +16 -153
- package/app/utils/drag_and_drop.ts +80 -0
- package/app/utils/extension.ts +1 -1
- package/app/utils/import_workflow.ts +26 -11
- package/app/utils/model_component_coloring.ts +46 -0
- package/app/utils/threshold.ts +33 -0
- package/app/utils/threshold_sources.ts +51 -0
- package/app/utils/treeview.ts +12 -1
- package/app/utils/upload_path.ts +15 -9
- package/app/utils/visible_map_area.ts +129 -0
- package/internal/database/base_database.ts +2 -0
- package/internal/database/database.ts +47 -29
- package/internal/database/tables/scene_style.ts +6 -0
- package/internal/stores/data_style/mesh/base_style.ts +74 -0
- package/internal/stores/data_style/mesh/cells/cell.ts +27 -150
- package/internal/stores/data_style/mesh/cells/cell_attribute.ts +74 -0
- package/internal/stores/data_style/mesh/cells/cell_config.ts +152 -0
- package/internal/stores/data_style/mesh/cells/color.ts +3 -1
- package/internal/stores/data_style/mesh/cells/index.ts +17 -1
- package/internal/stores/data_style/mesh/cells/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/cells/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/cells/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/cells/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/edges/color.ts +3 -1
- package/internal/stores/data_style/mesh/edges/edge.ts +27 -150
- package/internal/stores/data_style/mesh/edges/edge_attribute.ts +74 -0
- package/internal/stores/data_style/mesh/edges/edge_config.ts +152 -0
- package/internal/stores/data_style/mesh/edges/index.ts +17 -1
- package/internal/stores/data_style/mesh/edges/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/edges/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/edges/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/edges/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/index.ts +2 -57
- package/internal/stores/data_style/mesh/points/color.ts +3 -1
- package/internal/stores/data_style/mesh/points/index.ts +17 -1
- package/internal/stores/data_style/mesh/points/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/points/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/points/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/points/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/polygons/color.ts +3 -1
- package/internal/stores/data_style/mesh/polygons/index.ts +17 -1
- package/internal/stores/data_style/mesh/polygons/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/polygons/polygon.ts +27 -152
- package/internal/stores/data_style/mesh/polygons/polygon_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polygons/polygon_config.ts +148 -0
- package/internal/stores/data_style/mesh/polygons/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/polygons/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polygons/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/polyhedra/color.ts +3 -1
- package/internal/stores/data_style/mesh/polyhedra/index.ts +17 -1
- package/internal/stores/data_style/mesh/polyhedra/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +27 -160
- package/internal/stores/data_style/mesh/polyhedra/polyhedron_attribute.ts +82 -0
- package/internal/stores/data_style/mesh/polyhedra/polyhedron_config.ts +157 -0
- package/internal/stores/data_style/mesh/polyhedra/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/polyhedra/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polyhedra/vertex_config.ts +152 -0
- package/internal/stores/data_style/model/blocks/apply_coloring.ts +173 -0
- package/internal/stores/data_style/model/blocks/color.ts +58 -57
- package/internal/stores/data_style/model/blocks/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/blocks/index.ts +12 -140
- package/internal/stores/data_style/model/blocks/polyhedron.ts +102 -54
- package/internal/stores/data_style/model/blocks/vertex.ts +102 -54
- package/internal/stores/data_style/model/color.ts +25 -26
- package/internal/stores/data_style/model/common.ts +10 -119
- package/internal/stores/data_style/model/common_mutations.ts +184 -0
- package/internal/stores/data_style/model/corners/index.ts +85 -78
- package/internal/stores/data_style/model/corners/vertex.ts +97 -49
- package/internal/stores/data_style/model/lines/apply_coloring.ts +154 -0
- package/internal/stores/data_style/model/lines/color.ts +53 -40
- package/internal/stores/data_style/model/lines/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/lines/edge.ts +102 -54
- package/internal/stores/data_style/model/lines/index.ts +10 -134
- package/internal/stores/data_style/model/lines/vertex.ts +102 -54
- package/internal/stores/data_style/model/surfaces/apply_coloring.ts +186 -0
- package/internal/stores/data_style/model/surfaces/color.ts +68 -56
- package/internal/stores/data_style/model/surfaces/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/surfaces/index.ts +16 -160
- package/internal/stores/data_style/model/surfaces/polygon.ts +94 -46
- package/internal/stores/data_style/model/surfaces/vertex.ts +94 -46
- package/internal/stores/data_style/model/visibility.ts +3 -156
- package/internal/stores/data_style/model/visibility_dispatch.ts +110 -0
- package/internal/stores/data_style/scene.ts +118 -0
- package/internal/stores/data_style/state.ts +5 -181
- package/internal/stores/data_style/state_shared.ts +199 -0
- package/internal/stores/data_style/types.ts +24 -1
- package/internal/stores/hybrid_viewer/brightness.ts +8 -2
- package/internal/stores/hybrid_viewer/camera.ts +7 -161
- package/internal/stores/hybrid_viewer/camera_animation.ts +4 -3
- package/internal/stores/hybrid_viewer/camera_helpers.ts +120 -0
- package/internal/stores/hybrid_viewer/camera_orientation.ts +60 -0
- package/internal/stores/hybrid_viewer/filters.ts +54 -11
- package/internal/stores/hybrid_viewer/highlight.ts +80 -63
- package/internal/stores/hybrid_viewer/ruler.ts +4 -3
- package/internal/stores/hybrid_viewer/scene.ts +34 -26
- package/internal/stores/hybrid_viewer/vtk_types.ts +2 -1
- package/internal/utils/ws_client.ts +8 -1
- package/package.json +5 -5
- package/server/api/local/extensions/run.post.ts +6 -4
- package/server/api/local/extensions/upload.put.ts +47 -20
- package/server/utils/cleanup.ts +12 -2
- package/server/utils/microservices.ts +10 -102
- package/server/utils/microservices_process.ts +127 -0
- package/server/utils/scripts.ts +35 -30
- package/server/utils/typed_handler.ts +8 -1
- package/server/utils/ws_client.ts +15 -2
- package/shared/utils/fetch_raw.ts +2 -2
- package/shared/utils/parse_boolean.ts +4 -1
- package/app/components/Viewer/Options/OptionsSection.vue +0 -76
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ACTOR_COLOR, RGB_MAX } from "./constants";
|
|
2
|
-
import type { HybridDb, vtkActor as VtkActorInstance, vtkCamera } from "./vtk_types";
|
|
2
|
+
import type { HybridDb, HybridDbEntry, vtkActor as VtkActorInstance, vtkCamera } from "./vtk_types";
|
|
3
3
|
import { requireRenderWindow, useHybridViewerCore } from "./core";
|
|
4
4
|
import viewer_schemas, {
|
|
5
5
|
type ViewerSetBackgroundColorParams,
|
|
@@ -40,6 +40,31 @@ function followZScaling(camera: vtkCamera, ratio: number): void {
|
|
|
40
40
|
camera.setPosition(positionX, positionY, positionZ + offset);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
async function fetchBinaryLightViewable(id: string): Promise<string | undefined> {
|
|
44
|
+
const dataStore = useDataStore();
|
|
45
|
+
const isViewable = await dataStore.isItemViewable(id);
|
|
46
|
+
if (!isViewable) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
const value = await dataStore.item(id);
|
|
50
|
+
return value.binary_light_viewable;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function createHybridDbEntry(binaryLightViewable: string, zScale: number): HybridDbEntry {
|
|
54
|
+
const reader = vtkXMLPolyDataReader();
|
|
55
|
+
reader.parseAsArrayBuffer(base64ToArrayBuffer(binaryLightViewable));
|
|
56
|
+
const actor = vtkActor();
|
|
57
|
+
const mapper = vtkMapper();
|
|
58
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- vtk.js's algorithm interface types getOutputData as `any`; this reader always produces polydata.
|
|
59
|
+
const polydata = reader.getOutputData(0) as unknown as vtkPolyData;
|
|
60
|
+
mapper.setInputData(polydata);
|
|
61
|
+
const property = actor.getProperty();
|
|
62
|
+
property.setColor(ACTOR_COLOR);
|
|
63
|
+
actor.setMapper(mapper);
|
|
64
|
+
actor.setScale(1, 1, zScale);
|
|
65
|
+
return { actor, polydata, mapper };
|
|
66
|
+
}
|
|
67
|
+
|
|
43
68
|
// Shared via createSharedComposable (rather than merged into the parent hybridViewer store) so sibling slices, e.g. camera.ts and ruler.ts, can read hybridDb/setZScaling directly without importing the parent store and creating a cycle. A Pinia store would work too but its $id/$patch/... properties would leak into the composed store's spread and collapse its inferred type.
|
|
44
69
|
const useHybridViewerScene = createSharedComposable(() => {
|
|
45
70
|
const hybridDb = reactive<HybridDb>({});
|
|
@@ -50,40 +75,23 @@ const useHybridViewerScene = createSharedComposable(() => {
|
|
|
50
75
|
if (!genericRenderWindow.value) {
|
|
51
76
|
return;
|
|
52
77
|
}
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
if (!isViewable) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const value = await dataStore.item(id);
|
|
59
|
-
if (value.binary_light_viewable === undefined) {
|
|
78
|
+
const binaryLightViewable = await fetchBinaryLightViewable(id);
|
|
79
|
+
if (binaryLightViewable === undefined) {
|
|
60
80
|
return;
|
|
61
81
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const actor = vtkActor();
|
|
65
|
-
const mapper = vtkMapper();
|
|
66
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- vtk.js's algorithm interface types getOutputData as `any`; this reader always produces polydata.
|
|
67
|
-
const polydata = reader.getOutputData(0) as unknown as vtkPolyData;
|
|
68
|
-
mapper.setInputData(polydata);
|
|
69
|
-
const property = actor.getProperty();
|
|
70
|
-
property.setColor(ACTOR_COLOR);
|
|
71
|
-
actor.setMapper(mapper);
|
|
82
|
+
// The scene z-scaling also applies to actors added after it was set
|
|
83
|
+
const entry = createHybridDbEntry(binaryLightViewable, zScale.value);
|
|
72
84
|
const renderer = genericRenderWindow.value.getRenderer();
|
|
85
|
+
// Replacing an actor keeps the camera where the user left it
|
|
86
|
+
const isFirst = !hybridDb[id] && renderer.getActors().length === 0;
|
|
73
87
|
if (hybridDb[id]) {
|
|
74
88
|
renderer.removeActor(hybridDb[id].actor);
|
|
75
89
|
}
|
|
76
|
-
|
|
77
|
-
const isFirst = actors.length === 0;
|
|
78
|
-
renderer.addActor(actor);
|
|
90
|
+
renderer.addActor(entry.actor);
|
|
79
91
|
if (isFirst) {
|
|
80
92
|
renderer.resetCamera();
|
|
81
93
|
}
|
|
82
|
-
hybridDb[id] =
|
|
83
|
-
actor,
|
|
84
|
-
polydata,
|
|
85
|
-
mapper,
|
|
86
|
-
};
|
|
94
|
+
hybridDb[id] = entry;
|
|
87
95
|
}
|
|
88
96
|
|
|
89
97
|
function removeItem(id: string): void {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Vector3 } from "@kitware/vtk.js/types";
|
|
2
2
|
import type vtkActor from "@kitware/vtk.js/Rendering/Core/Actor";
|
|
3
|
+
import type vtkPolyData from "@kitware/vtk.js/Common/DataModel/PolyData";
|
|
3
4
|
|
|
4
5
|
// The camera state as exchanged with the viewer microservice (snake_case field names, plain arrays) - distinct from vtk.js's own vtkCamera object.
|
|
5
6
|
interface CameraOptions {
|
|
@@ -13,7 +14,7 @@ interface CameraOptions {
|
|
|
13
14
|
|
|
14
15
|
interface HybridDbEntry {
|
|
15
16
|
actor: vtkActor;
|
|
16
|
-
polydata:
|
|
17
|
+
polydata: vtkPolyData;
|
|
17
18
|
mapper: unknown;
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -25,13 +25,20 @@ function isVtkWSLinkClient(value: unknown): value is VtkWSLinkClient {
|
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
function resolveClient(initialClient: unknown): VtkWSLinkClient {
|
|
29
|
+
if (isVtkWSLinkClient(initialClient)) {
|
|
30
|
+
return initialClient;
|
|
31
|
+
}
|
|
32
|
+
return newInstance();
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
async function initWebSocketClient(
|
|
29
36
|
baseUrl: string,
|
|
30
37
|
initialClient: unknown = {},
|
|
31
38
|
{ onConnectionClose }: WsClientCallbacks = {},
|
|
32
39
|
): Promise<VtkWSLinkClient> {
|
|
33
40
|
vtkWSLinkClient.setSmartConnectClass(SmartConnect);
|
|
34
|
-
const client =
|
|
41
|
+
const client = resolveClient(initialClient);
|
|
35
42
|
|
|
36
43
|
client.onConnectionError((httpReq: WsConnectionEvent) => {
|
|
37
44
|
const message = httpReq.response?.error ?? "Connection error";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geode/opengeodeweb-front",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.44.0-rc.10",
|
|
4
4
|
"description": "OpenSource Vue/Nuxt/Pinia/Vuetify framework for web applications",
|
|
5
5
|
"homepage": "https://github.com/Geode-solutions/OpenGeodeWeb-Front",
|
|
6
6
|
"bugs": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"lint": "oxlint --fix .",
|
|
53
|
-
"prepare:types": "cross-env MODE=BROWSER nuxi prepare",
|
|
53
|
+
"prepare:types": "cross-env MODE=BROWSER npx nuxi prepare",
|
|
54
54
|
"build:back": "npx opengeodeweb-microservice-pyinstaller ../OpenGeodeWeb-Back",
|
|
55
55
|
"build:viewer": "npx opengeodeweb-microservice-pyinstaller ../OpenGeodeWeb-Viewer",
|
|
56
56
|
"build:microservices": "concurrently \"npm run build:back\" \"npm run build:viewer\"",
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"prepublishOnly": "npm run build"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@geode/cloud-api": "
|
|
68
|
-
"@geode/opengeodeweb-back": "
|
|
69
|
-
"@geode/opengeodeweb-viewer": "
|
|
67
|
+
"@geode/cloud-api": "next",
|
|
68
|
+
"@geode/opengeodeweb-back": "next",
|
|
69
|
+
"@geode/opengeodeweb-viewer": "next",
|
|
70
70
|
"@kitware/vtk.js": "33.3.0",
|
|
71
71
|
"@mdi/font": "7.4.47",
|
|
72
72
|
"@msgpack/msgpack": "2.8.0",
|
|
@@ -55,10 +55,12 @@ async function runSingleExtension(
|
|
|
55
55
|
port,
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
let serverPort: number | undefined = undefined;
|
|
59
|
+
if (server !== undefined) {
|
|
60
|
+
serverPort = await runExtensionServer(
|
|
61
|
+
extensionServerEntryPath(unzippedExtensionPath, server.entry),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
62
64
|
if (serverPort !== undefined) {
|
|
63
65
|
setExtensionServerPort(id, serverPort);
|
|
64
66
|
}
|
|
@@ -40,33 +40,60 @@ function requiredQueryInt(event: H3Event, key: string): number {
|
|
|
40
40
|
return parsed;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
interface UploadQuery {
|
|
44
|
+
projectName: string;
|
|
45
|
+
filename: string;
|
|
46
|
+
totalChunks: number;
|
|
47
|
+
chunkIndex: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function parseUploadQuery(event: H3Event): UploadQuery {
|
|
51
|
+
const projectName = requiredQueryString(event, "projectName");
|
|
52
|
+
const filename = requiredQueryString(event, "filename");
|
|
53
|
+
const totalChunks = requiredQueryInt(event, "total_chunks");
|
|
54
|
+
const chunkIndex = requiredQueryInt(event, "chunk_index");
|
|
55
|
+
if (chunkIndex >= totalChunks) {
|
|
56
|
+
throw createError({ statusCode: 400, message: "chunk_index must be less than total_chunks" });
|
|
57
|
+
}
|
|
58
|
+
return { projectName, filename, totalChunks, chunkIndex };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function requiredBodyStream(event: H3Event): ReadableStream<unknown> {
|
|
62
|
+
const webStream = getRequestWebStream(event);
|
|
63
|
+
if (!webStream) {
|
|
64
|
+
throw createError({ statusCode: 400, message: "No request body received" });
|
|
65
|
+
}
|
|
66
|
+
return webStream;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function writeChunk(
|
|
70
|
+
webStream: ReadableStream<unknown>,
|
|
71
|
+
partPath: string,
|
|
72
|
+
chunkIndex: number,
|
|
73
|
+
): Promise<void> {
|
|
74
|
+
const writeStream = fs.createWriteStream(partPath, { flags: chunkIndex === 0 ? "w" : "a" });
|
|
75
|
+
await pipeline(Readable.fromWeb(toNodeWebStream(webStream)), writeStream);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function enforceSizeLimit(partPath: string): Promise<void> {
|
|
79
|
+
const { size } = await fs.promises.stat(partPath);
|
|
80
|
+
if (size > FILE_SIZE_LIMIT) {
|
|
81
|
+
await fs.promises.unlink(partPath);
|
|
82
|
+
throw createError({ statusCode: 400, message: "File too large" });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
43
86
|
// The file is sent as a raw (non-multipart) body, split into sequential chunks the client uploads in order (see OpenGeodeWeb-Front's upload_file.ts and OpenGeodeWeb-Back's upload_file route, which use the same protocol). Each chunk is appended to a `.part` file; the last one triggers the existing zip-metadata registration.
|
|
44
87
|
export default defineRawEventHandler(
|
|
45
88
|
schemas.api.local.extensions.upload,
|
|
46
89
|
async (event: H3Event): Promise<LocalExtensionsUploadResponse> => {
|
|
47
|
-
const projectName =
|
|
48
|
-
const
|
|
49
|
-
const totalChunks = requiredQueryInt(event, "total_chunks");
|
|
50
|
-
const chunkIndex = requiredQueryInt(event, "chunk_index");
|
|
51
|
-
if (chunkIndex >= totalChunks) {
|
|
52
|
-
throw createError({ statusCode: 400, message: "chunk_index must be less than total_chunks" });
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const webStream = getRequestWebStream(event);
|
|
56
|
-
if (!webStream) {
|
|
57
|
-
throw createError({ statusCode: 400, message: "No request body received" });
|
|
58
|
-
}
|
|
90
|
+
const { projectName, filename, totalChunks, chunkIndex } = parseUploadQuery(event);
|
|
91
|
+
const webStream = requiredBodyStream(event);
|
|
59
92
|
|
|
60
93
|
const targetPath = targetExtensionFilePath(projectName, filename);
|
|
61
94
|
const partPath = `${targetPath}.part`;
|
|
62
|
-
|
|
63
|
-
await
|
|
64
|
-
|
|
65
|
-
const { size } = await fs.promises.stat(partPath);
|
|
66
|
-
if (size > FILE_SIZE_LIMIT) {
|
|
67
|
-
await fs.promises.unlink(partPath);
|
|
68
|
-
throw createError({ statusCode: 400, message: "File too large" });
|
|
69
|
-
}
|
|
95
|
+
await writeChunk(webStream, partPath, chunkIndex);
|
|
96
|
+
await enforceSizeLimit(partPath);
|
|
70
97
|
|
|
71
98
|
if (chunkIndex < totalChunks - 1) {
|
|
72
99
|
return { statusCode: CODE_200 };
|
package/server/utils/cleanup.ts
CHANGED
|
@@ -56,6 +56,13 @@ function isErrorWithMessage(error: unknown): error is { message: string } {
|
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
function describeError(error: unknown): string {
|
|
60
|
+
if (isErrorWithMessage(error)) {
|
|
61
|
+
return error.message;
|
|
62
|
+
}
|
|
63
|
+
return String(error);
|
|
64
|
+
}
|
|
65
|
+
|
|
59
66
|
async function killHttpMicroservice(microservice: Microservice): Promise<void> {
|
|
60
67
|
consola.debug("killHttpMicroservice", {
|
|
61
68
|
...microservice,
|
|
@@ -70,7 +77,7 @@ async function killHttpMicroservice(microservice: Microservice): Promise<void> {
|
|
|
70
77
|
method: microservice.method,
|
|
71
78
|
});
|
|
72
79
|
} catch (error) {
|
|
73
|
-
const message =
|
|
80
|
+
const message = describeError(error);
|
|
74
81
|
consola.info(`Expected error during kill of ${microservice.name}:`, message);
|
|
75
82
|
}
|
|
76
83
|
}
|
|
@@ -180,7 +187,10 @@ function getMicroserviceByName(
|
|
|
180
187
|
name: string,
|
|
181
188
|
): Microservice | undefined {
|
|
182
189
|
const found = microservices.find((microservice) => microservice.name === name);
|
|
183
|
-
|
|
190
|
+
if (found === undefined) {
|
|
191
|
+
return undefined;
|
|
192
|
+
}
|
|
193
|
+
return { ...found };
|
|
184
194
|
}
|
|
185
195
|
|
|
186
196
|
export {
|
|
@@ -1,94 +1,25 @@
|
|
|
1
1
|
// Node imports
|
|
2
2
|
import child_process from "node:child_process";
|
|
3
3
|
import fs from "node:fs";
|
|
4
|
-
import path from "node:path";
|
|
5
4
|
|
|
6
5
|
// Third party imports
|
|
7
6
|
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json" with { type: "json" };
|
|
8
7
|
import { consola } from "consola";
|
|
9
8
|
|
|
10
9
|
// Local imports
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_RUN_ARGS,
|
|
12
|
+
MAX_PORT_RETRIES,
|
|
13
|
+
type RunArgs,
|
|
14
|
+
backArgs,
|
|
15
|
+
isPortInUseError,
|
|
16
|
+
runScript,
|
|
17
|
+
waitUntilListening,
|
|
18
|
+
} from "./microservices_process.js";
|
|
11
19
|
import { type Microservice, microservicesMetadatasPath, projectMicroservices } from "./cleanup.js";
|
|
12
|
-
import { type NamedChildProcess, getAvailablePort, waitForReady } from "./scripts.js";
|
|
13
20
|
import { addNginxLocation, addSupervisorProgram } from "./cloud.js";
|
|
14
21
|
import { executablePath } from "./path.js";
|
|
15
|
-
|
|
16
|
-
interface RunArgs {
|
|
17
|
-
projectFolderPath: string;
|
|
18
|
-
uploadFolderPath?: string;
|
|
19
|
-
[key: string]: unknown;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const MILLISECONDS_PER_SECOND = 1000;
|
|
23
|
-
const DEFAULT_TIMEOUT_SECONDS = 120;
|
|
24
|
-
const MAX_PORT_RETRIES = 1;
|
|
25
|
-
const DEFAULT_RUN_ARGS: RunArgs = { projectFolderPath: "" };
|
|
26
|
-
const LISTENING_LOG_PATTERN = /^Listening on https?:\/\/.+:\d+\/?\s*$/mu;
|
|
27
|
-
|
|
28
|
-
async function runScript(
|
|
29
|
-
execPath: string,
|
|
30
|
-
execName: string,
|
|
31
|
-
args: readonly string[],
|
|
32
|
-
expectedResponse: string,
|
|
33
|
-
timeoutSeconds = DEFAULT_TIMEOUT_SECONDS,
|
|
34
|
-
): Promise<NamedChildProcess> {
|
|
35
|
-
const command = executablePath(execPath, execName);
|
|
36
|
-
consola.debug("runScript", command, args);
|
|
37
|
-
const child = child_process.spawn(command, args, {
|
|
38
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
39
|
-
}) as NamedChildProcess;
|
|
40
|
-
child.name = command.replace(/^.*[\\/]/u, "");
|
|
41
|
-
child.on("spawn", () => {
|
|
42
|
-
consola.info(`[${child.name}] spawned, pid=${child.pid}`);
|
|
43
|
-
});
|
|
44
|
-
const controller = new AbortController();
|
|
45
|
-
const timer = setTimeout(() => {
|
|
46
|
-
controller.abort();
|
|
47
|
-
}, timeoutSeconds * MILLISECONDS_PER_SECOND);
|
|
48
|
-
if (typeof timer.unref === "function") {
|
|
49
|
-
timer.unref();
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
const result = await waitForReady(child, expectedResponse, controller.signal);
|
|
53
|
-
clearTimeout(timer);
|
|
54
|
-
return result;
|
|
55
|
-
} catch (error) {
|
|
56
|
-
clearTimeout(timer);
|
|
57
|
-
child.kill();
|
|
58
|
-
throw error;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function isPortInUseError(error: unknown): boolean {
|
|
63
|
-
return /EADDRINUSE|address already in use|port already in use/iu.test(String(error));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function backArgs(args: RunArgs, port: number): string[] {
|
|
67
|
-
const { projectFolderPath } = args;
|
|
68
|
-
if (!projectFolderPath) {
|
|
69
|
-
throw new Error("projectFolderPath is required");
|
|
70
|
-
}
|
|
71
|
-
const uploadFolderPath =
|
|
72
|
-
args.uploadFolderPath !== undefined && args.uploadFolderPath !== ""
|
|
73
|
-
? args.uploadFolderPath
|
|
74
|
-
: path.join(projectFolderPath, "uploads");
|
|
75
|
-
const executableArgs = [
|
|
76
|
-
"--port",
|
|
77
|
-
String(port),
|
|
78
|
-
"--project_folder_path",
|
|
79
|
-
projectFolderPath,
|
|
80
|
-
"--upload_folder_path",
|
|
81
|
-
uploadFolderPath,
|
|
82
|
-
"--allowed_origins",
|
|
83
|
-
"http://localhost:*",
|
|
84
|
-
"--timeout",
|
|
85
|
-
"0",
|
|
86
|
-
];
|
|
87
|
-
if (process.env.NODE_ENV === undefined || process.env.NODE_ENV === "development") {
|
|
88
|
-
executableArgs.push("--debug");
|
|
89
|
-
}
|
|
90
|
-
return executableArgs;
|
|
91
|
-
}
|
|
22
|
+
import { getAvailablePort } from "./scripts.js";
|
|
92
23
|
|
|
93
24
|
async function runBack(
|
|
94
25
|
execName: string,
|
|
@@ -184,29 +115,6 @@ async function runExtension(
|
|
|
184
115
|
}
|
|
185
116
|
throw new Error(`runExtension failed to run ${extensionId}`);
|
|
186
117
|
}
|
|
187
|
-
async function waitUntilListening(
|
|
188
|
-
child: child_process.ChildProcessWithoutNullStreams,
|
|
189
|
-
): Promise<void> {
|
|
190
|
-
child.stderr.on("data", (data: Buffer) => {
|
|
191
|
-
consola.info(`[${child.spawnfile}] STDERR:`, data.toString().trim());
|
|
192
|
-
});
|
|
193
|
-
child.on("close", (code) => {
|
|
194
|
-
consola.info(`[${child.spawnfile}] exited with code ${code}`);
|
|
195
|
-
});
|
|
196
|
-
// oxlint-disable-next-line typescript/no-unnecessary-condition
|
|
197
|
-
for await (const chunk of child.stdout) {
|
|
198
|
-
const output = String(chunk);
|
|
199
|
-
consola.info(`[${child.spawnfile}] STDOUT:`, output.trim());
|
|
200
|
-
if (LISTENING_LOG_PATTERN.test(output)) {
|
|
201
|
-
child.stdout.on("data", (data: Buffer) => {
|
|
202
|
-
consola.info(`[${child.spawnfile}] STDOUT:`, data.toString().trim());
|
|
203
|
-
});
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
throw new Error(`${child.spawnfile} exited before becoming ready`);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
118
|
async function runExtensionServer(entryPath: string, attempts = 0): Promise<number> {
|
|
211
119
|
let port: number | undefined = undefined;
|
|
212
120
|
try {
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Node imports
|
|
2
|
+
import child_process from "node:child_process";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
// Third party imports
|
|
6
|
+
import { consola } from "consola";
|
|
7
|
+
|
|
8
|
+
// Local imports
|
|
9
|
+
import { type NamedChildProcess, waitForReady } from "./scripts.js";
|
|
10
|
+
import { executablePath } from "./path.js";
|
|
11
|
+
|
|
12
|
+
interface RunArgs {
|
|
13
|
+
projectFolderPath: string;
|
|
14
|
+
uploadFolderPath?: string;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const MILLISECONDS_PER_SECOND = 1000;
|
|
19
|
+
const DEFAULT_TIMEOUT_SECONDS = 120;
|
|
20
|
+
const MAX_PORT_RETRIES = 1;
|
|
21
|
+
const DEFAULT_RUN_ARGS: RunArgs = { projectFolderPath: "" };
|
|
22
|
+
const LISTENING_LOG_PATTERN = /^Listening on https?:\/\/.+:\d+\/?\s*$/mu;
|
|
23
|
+
|
|
24
|
+
async function runScript(
|
|
25
|
+
execPath: string,
|
|
26
|
+
execName: string,
|
|
27
|
+
args: readonly string[],
|
|
28
|
+
expectedResponse: string,
|
|
29
|
+
timeoutSeconds = DEFAULT_TIMEOUT_SECONDS,
|
|
30
|
+
): Promise<NamedChildProcess> {
|
|
31
|
+
const command = executablePath(execPath, execName);
|
|
32
|
+
consola.debug("runScript", command, args);
|
|
33
|
+
const child = child_process.spawn(command, args, {
|
|
34
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
35
|
+
}) as NamedChildProcess;
|
|
36
|
+
child.name = command.replace(/^.*[\\/]/u, "");
|
|
37
|
+
child.on("spawn", () => {
|
|
38
|
+
consola.info(`[${child.name}] spawned, pid=${child.pid}`);
|
|
39
|
+
});
|
|
40
|
+
const controller = new AbortController();
|
|
41
|
+
const timer = setTimeout(() => {
|
|
42
|
+
controller.abort();
|
|
43
|
+
}, timeoutSeconds * MILLISECONDS_PER_SECOND);
|
|
44
|
+
if (typeof timer.unref === "function") {
|
|
45
|
+
timer.unref();
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const result = await waitForReady(child, expectedResponse, controller.signal);
|
|
49
|
+
clearTimeout(timer);
|
|
50
|
+
return result;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
clearTimeout(timer);
|
|
53
|
+
child.kill();
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function isPortInUseError(error: unknown): boolean {
|
|
59
|
+
return /EADDRINUSE|address already in use|port already in use/iu.test(String(error));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function resolveUploadFolderPath(
|
|
63
|
+
projectFolderPath: string,
|
|
64
|
+
uploadFolderPath: string | undefined,
|
|
65
|
+
): string {
|
|
66
|
+
if (uploadFolderPath !== undefined && uploadFolderPath !== "") {
|
|
67
|
+
return uploadFolderPath;
|
|
68
|
+
}
|
|
69
|
+
return path.join(projectFolderPath, "uploads");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function backArgs(args: RunArgs, port: number): string[] {
|
|
73
|
+
const { projectFolderPath } = args;
|
|
74
|
+
if (!projectFolderPath) {
|
|
75
|
+
throw new Error("projectFolderPath is required");
|
|
76
|
+
}
|
|
77
|
+
const uploadFolderPath = resolveUploadFolderPath(projectFolderPath, args.uploadFolderPath);
|
|
78
|
+
const executableArgs = [
|
|
79
|
+
"--port",
|
|
80
|
+
String(port),
|
|
81
|
+
"--project_folder_path",
|
|
82
|
+
projectFolderPath,
|
|
83
|
+
"--upload_folder_path",
|
|
84
|
+
uploadFolderPath,
|
|
85
|
+
"--allowed_origins",
|
|
86
|
+
"http://localhost:*",
|
|
87
|
+
"--timeout",
|
|
88
|
+
"0",
|
|
89
|
+
];
|
|
90
|
+
if (process.env.NODE_ENV === undefined || process.env.NODE_ENV === "development") {
|
|
91
|
+
executableArgs.push("--debug");
|
|
92
|
+
}
|
|
93
|
+
return executableArgs;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function waitUntilListening(
|
|
97
|
+
child: child_process.ChildProcessWithoutNullStreams,
|
|
98
|
+
): Promise<void> {
|
|
99
|
+
child.stderr.on("data", (data: Buffer) => {
|
|
100
|
+
consola.info(`[${child.spawnfile}] STDERR:`, data.toString().trim());
|
|
101
|
+
});
|
|
102
|
+
child.on("close", (code) => {
|
|
103
|
+
consola.info(`[${child.spawnfile}] exited with code ${code}`);
|
|
104
|
+
});
|
|
105
|
+
// oxlint-disable-next-line typescript/no-unnecessary-condition
|
|
106
|
+
for await (const chunk of child.stdout) {
|
|
107
|
+
const output = String(chunk);
|
|
108
|
+
consola.info(`[${child.spawnfile}] STDOUT:`, output.trim());
|
|
109
|
+
if (LISTENING_LOG_PATTERN.test(output)) {
|
|
110
|
+
child.stdout.on("data", (data: Buffer) => {
|
|
111
|
+
consola.info(`[${child.spawnfile}] STDOUT:`, data.toString().trim());
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
throw new Error(`${child.spawnfile} exited before becoming ready`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
DEFAULT_RUN_ARGS,
|
|
121
|
+
MAX_PORT_RETRIES,
|
|
122
|
+
backArgs,
|
|
123
|
+
isPortInUseError,
|
|
124
|
+
runScript,
|
|
125
|
+
waitUntilListening,
|
|
126
|
+
};
|
|
127
|
+
export type { RunArgs };
|
package/server/utils/scripts.ts
CHANGED
|
@@ -43,6 +43,36 @@ interface NamedChildProcess extends child_process.ChildProcessByStdio<null, Read
|
|
|
43
43
|
name?: string;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
function truncateLine(lineOutput: string): string {
|
|
47
|
+
const halfBuffer = MAX_ERROR_BUFFER_BYTES / 2;
|
|
48
|
+
return byteLength(lineOutput) > halfBuffer
|
|
49
|
+
? `${lineOutput.slice(0, halfBuffer)}…[truncated]`
|
|
50
|
+
: lineOutput;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function trimOutputBuffer(output: string): string {
|
|
54
|
+
let trimmed = output;
|
|
55
|
+
while (byteLength(trimmed) > MAX_ERROR_BUFFER_BYTES) {
|
|
56
|
+
const newline = trimmed.indexOf("\n");
|
|
57
|
+
if (newline === -1) {
|
|
58
|
+
return "";
|
|
59
|
+
}
|
|
60
|
+
trimmed = trimmed.slice(newline + 1);
|
|
61
|
+
}
|
|
62
|
+
return trimmed;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function createOutputRecorder(): { record: (lineOutput: string) => void; read: () => string } {
|
|
66
|
+
let recentOutput = "";
|
|
67
|
+
function record(lineOutput: string): void {
|
|
68
|
+
recentOutput = trimOutputBuffer(`${recentOutput} ${truncateLine(lineOutput)}\n`);
|
|
69
|
+
}
|
|
70
|
+
function read(): string {
|
|
71
|
+
return recentOutput;
|
|
72
|
+
}
|
|
73
|
+
return { record, read };
|
|
74
|
+
}
|
|
75
|
+
|
|
46
76
|
// oxlint-disable-next-line max-lines-per-function typescript/prefer-readonly-parameter-types eslint/require-await
|
|
47
77
|
async function waitForReady(
|
|
48
78
|
child: NamedChildProcess,
|
|
@@ -57,24 +87,8 @@ async function waitForReady(
|
|
|
57
87
|
const readlineStderr = readline.createInterface({
|
|
58
88
|
input: child.stderr,
|
|
59
89
|
});
|
|
60
|
-
|
|
61
|
-
function recordOutput(lineOutput: string): void {
|
|
62
|
-
const safeLine =
|
|
63
|
-
byteLength(lineOutput) > MAX_ERROR_BUFFER_BYTES / 2
|
|
64
|
-
? `${lineOutput.slice(0, MAX_ERROR_BUFFER_BYTES / 2)}…[truncated]`
|
|
65
|
-
: lineOutput;
|
|
66
|
-
recentOutput = `${recentOutput} ${safeLine}\n`;
|
|
67
|
-
while (byteLength(recentOutput) > MAX_ERROR_BUFFER_BYTES) {
|
|
68
|
-
const newline = recentOutput.indexOf("\n");
|
|
69
|
-
if (newline === -1) {
|
|
70
|
-
recentOutput = "";
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
recentOutput = recentOutput.slice(newline + 1);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
90
|
+
const recorder = createOutputRecorder();
|
|
76
91
|
let onLine: ((line: string) => void) | undefined = undefined;
|
|
77
|
-
let onErrLine: ((line: string) => void) | undefined = undefined;
|
|
78
92
|
let onError: ((err: Error) => void) | undefined = undefined;
|
|
79
93
|
let onClose: ((code: number | null) => void) | undefined = undefined;
|
|
80
94
|
let onAbort: (() => void) | undefined = undefined;
|
|
@@ -82,9 +96,7 @@ async function waitForReady(
|
|
|
82
96
|
function cleanup(): void {
|
|
83
97
|
if (onLine) {
|
|
84
98
|
readlineStdout.removeListener("line", onLine);
|
|
85
|
-
|
|
86
|
-
if (onErrLine) {
|
|
87
|
-
readlineStderr.removeListener("line", onErrLine);
|
|
99
|
+
readlineStderr.removeListener("line", onLine);
|
|
88
100
|
}
|
|
89
101
|
if (onError) {
|
|
90
102
|
child.removeListener("error", onError);
|
|
@@ -113,20 +125,12 @@ async function waitForReady(
|
|
|
113
125
|
|
|
114
126
|
onLine = (lineOutput): void => {
|
|
115
127
|
consola.info(`[${child.name}] ${lineOutput}`);
|
|
116
|
-
|
|
128
|
+
recorder.record(lineOutput);
|
|
117
129
|
if (lineOutput.includes(expectedResponse)) {
|
|
118
130
|
becomeReady();
|
|
119
131
|
}
|
|
120
132
|
};
|
|
121
133
|
|
|
122
|
-
onErrLine = (line): void => {
|
|
123
|
-
consola.info(`[${child.name}] ${line}`);
|
|
124
|
-
recordOutput(line);
|
|
125
|
-
if (line.includes(expectedResponse)) {
|
|
126
|
-
becomeReady();
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
|
|
130
134
|
onError = (err): void => {
|
|
131
135
|
cleanup();
|
|
132
136
|
reject(err);
|
|
@@ -135,6 +139,7 @@ async function waitForReady(
|
|
|
135
139
|
onClose = (code): void => {
|
|
136
140
|
consola.info(`[${child.name}] exited with code ${code}`);
|
|
137
141
|
cleanup();
|
|
142
|
+
const recentOutput = recorder.read();
|
|
138
143
|
reject(
|
|
139
144
|
new Error(
|
|
140
145
|
`[${child.name}] exited with code ${code} before becoming ready.${recentOutput ? `\nRecent output:\n${recentOutput}` : ""}`,
|
|
@@ -147,7 +152,7 @@ async function waitForReady(
|
|
|
147
152
|
reject(new Error(`[${child.name}] timed out waiting for "${expectedResponse}"`));
|
|
148
153
|
};
|
|
149
154
|
readlineStdout.on("line", onLine);
|
|
150
|
-
readlineStderr.on("line",
|
|
155
|
+
readlineStderr.on("line", onLine);
|
|
151
156
|
child.once("error", onError);
|
|
152
157
|
child.once("close", onClose);
|
|
153
158
|
if (signal) {
|
|
@@ -27,6 +27,13 @@ const INTERNAL_SERVER_ERROR = 500;
|
|
|
27
27
|
type RouteSchema = JsonRpcSchema & { readonly response?: object };
|
|
28
28
|
|
|
29
29
|
// Same body as the Flask microservices' errors, so the client reads every error the same way
|
|
30
|
+
function describeError(error: unknown): string {
|
|
31
|
+
if (error instanceof Error) {
|
|
32
|
+
return error.message;
|
|
33
|
+
}
|
|
34
|
+
return String(error);
|
|
35
|
+
}
|
|
36
|
+
|
|
30
37
|
function toErrorResponse(error: unknown): ErrorResponse {
|
|
31
38
|
if (isError(error)) {
|
|
32
39
|
return {
|
|
@@ -38,7 +45,7 @@ function toErrorResponse(error: unknown): ErrorResponse {
|
|
|
38
45
|
return {
|
|
39
46
|
code: INTERNAL_SERVER_ERROR,
|
|
40
47
|
name: "Internal Server Error",
|
|
41
|
-
description:
|
|
48
|
+
description: describeError(error),
|
|
42
49
|
};
|
|
43
50
|
}
|
|
44
51
|
|