@ngis/plugin-sdk 0.4.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.
Files changed (70) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +31 -0
  3. package/dist/index.cjs +76 -0
  4. package/dist/index.d.ts +77 -0
  5. package/dist/index.mjs +102 -0
  6. package/dist/src/api/analysis.d.ts +140 -0
  7. package/dist/src/api/resources.d.ts +530 -0
  8. package/dist/src/api/scenes.d.ts +251 -0
  9. package/dist/src/api/users.d.ts +22 -0
  10. package/dist/src/domain/algorithms/deck-layer-style.d.ts +34 -0
  11. package/dist/src/domain/algorithms/maplibre-style.d.ts +63 -0
  12. package/dist/src/domain/algorithms/raster-color-ramps.d.ts +37 -0
  13. package/dist/src/domain/algorithms/scene-layer-type.d.ts +25 -0
  14. package/dist/src/domain/algorithms/symbol-compile.d.ts +100 -0
  15. package/dist/src/domain/algorithms/symbol-params.d.ts +90 -0
  16. package/dist/src/domain/map/bounds.d.ts +8 -0
  17. package/dist/src/domain/map/constants.d.ts +40 -0
  18. package/dist/src/domain/map/layer-builders.d.ts +32 -0
  19. package/dist/src/domain/map/rendered-layers.d.ts +30 -0
  20. package/dist/src/domain/map/style-ready.d.ts +24 -0
  21. package/dist/src/domain/map/tile-url.d.ts +20 -0
  22. package/dist/src/domain/map/types.d.ts +128 -0
  23. package/dist/src/domain/models/deck-layer-style.d.ts +211 -0
  24. package/dist/src/domain/models/scene-layer-type.d.ts +23 -0
  25. package/dist/src/domain/models/symbol.d.ts +424 -0
  26. package/dist/src/lib/api.d.ts +82 -0
  27. package/dist/src/lib/auth-session.d.ts +22 -0
  28. package/dist/src/lib/raster-color-layer/RasterColorLayer.d.ts +48 -0
  29. package/dist/src/lib/raster-color-layer/TileGrid.d.ts +31 -0
  30. package/dist/src/lib/raster-color-layer/colorRamp.d.ts +18 -0
  31. package/dist/src/lib/raster-color-layer/shaders/raster-color.frag.d.ts +2 -0
  32. package/dist/src/lib/raster-color-layer/shaders/raster-color.vert.d.ts +2 -0
  33. package/dist/src/lib/raster-color-layer/zoomInterpolate.d.ts +2 -0
  34. package/dist/src/sdk/commands.d.ts +113 -0
  35. package/dist/src/sdk/context/keys.d.ts +148 -0
  36. package/dist/src/sdk/context/publishers.d.ts +198 -0
  37. package/dist/src/sdk/context/store.d.ts +78 -0
  38. package/dist/src/sdk/context/when.d.ts +69 -0
  39. package/dist/src/sdk/contributions/dispatch.d.ts +78 -0
  40. package/dist/src/sdk/contributions/panel-id.d.ts +25 -0
  41. package/dist/src/sdk/contributions/registry.d.ts +199 -0
  42. package/dist/src/sdk/contributions/symbol-renderers.d.ts +107 -0
  43. package/dist/src/sdk/contributions/types.d.ts +288 -0
  44. package/dist/src/sdk/contributions/views-bridge.d.ts +92 -0
  45. package/dist/src/sdk/define-plugin.d.ts +17 -0
  46. package/dist/src/sdk/facets/storage.d.ts +152 -0
  47. package/dist/src/sdk/facets/types.d.ts +370 -0
  48. package/dist/src/sdk/host-api.d.ts +256 -0
  49. package/dist/src/sdk/map-api.d.ts +288 -0
  50. package/dist/src/sdk/panels.d.ts +130 -0
  51. package/dist/src/sdk/plugin.d.ts +145 -0
  52. package/dist/src/sdk/rail-tools.d.ts +58 -0
  53. package/dist/src/sdk/scopes.d.ts +158 -0
  54. package/dist/src/systems/renderer/DeckSceneRenderer.d.ts +26 -0
  55. package/dist/src/systems/renderer/FlowFieldLayer.d.ts +68 -0
  56. package/dist/src/systems/renderer/LayerRendererRegistry.d.ts +132 -0
  57. package/dist/src/systems/renderer/authenticated-deck-load.d.ts +4 -0
  58. package/dist/src/systems/renderer/deck/deck-layer-builders.d.ts +29 -0
  59. package/dist/src/systems/renderer/deck/deck-layer-helpers.d.ts +21 -0
  60. package/dist/src/systems/renderer/deck/mvt-point-aggregation-layer.d.ts +107 -0
  61. package/dist/src/systems/renderer/flow-field/flow-field-resources.d.ts +84 -0
  62. package/dist/src/systems/renderer/flow-field/flow-field-shaders.d.ts +4 -0
  63. package/dist/src/systems/renderer/symbol/SpriteRegistry.d.ts +34 -0
  64. package/dist/src/systems/renderer/symbol/entries.d.ts +67 -0
  65. package/dist/src/types/analysis.d.ts +205 -0
  66. package/dist/src/types/common.d.ts +17 -0
  67. package/dist/src/types/extensions.d.ts +560 -0
  68. package/dist/src/types/gis.d.ts +242 -0
  69. package/dist/src/types/market-social.d.ts +378 -0
  70. package/package.json +47 -0
@@ -0,0 +1,34 @@
1
+ export interface SpriteImageData {
2
+ width: number;
3
+ height: number;
4
+ data: Uint8Array | Uint8ClampedArray;
5
+ }
6
+ export interface SpriteImageOptions {
7
+ /** An SDF sprite is recoloured per feature by `icon-color` (S24-01 finding 14). */
8
+ sdf?: boolean;
9
+ pixelRatio?: number;
10
+ }
11
+ /** The slice of a MapLibre `Map` this registry needs. */
12
+ export interface SpriteImageHost {
13
+ hasImage(id: string): boolean;
14
+ addImage(id: string, image: SpriteImageData, options?: SpriteImageOptions): void;
15
+ removeImage(id: string): void;
16
+ }
17
+ export interface SpriteRegistry {
18
+ /**
19
+ * Register `spriteId` if it is not already on the host, and take a reference.
20
+ * Returns false — without touching the host — for an id this registry did not
21
+ * mint.
22
+ */
23
+ ensure(spriteId: string, image: SpriteImageData, options?: SpriteImageOptions): boolean;
24
+ /** Drop one reference; the image is removed from the host at zero. */
25
+ release(spriteId: string): void;
26
+ has(spriteId: string): boolean;
27
+ /** The ids currently registered — what `buildSymbolMapLibreLayerSpec` filters on. */
28
+ availableIds(): ReadonlySet<string>;
29
+ refCount(spriteId: string): number;
30
+ /** Drop every reference and image (a style swap that discarded the sprite sheet). */
31
+ clear(): void;
32
+ readonly size: number;
33
+ }
34
+ export declare function createSpriteRegistry(host: SpriteImageHost): SpriteRegistry;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * `SceneLayerTypeId` → `LayerRendererEntry` for the three symbol layer types
3
+ * (F24.9). This is where the pure render plan meets the real map.
4
+ *
5
+ * The engine a plan picked decides the shape of the mount:
6
+ *
7
+ * - **maplibre** — a source plus one layer, tracked in `RenderedSceneLayer[]`
8
+ * with `renderMode: "maplibre"` so the existing reconciler prunes, diffs and
9
+ * repositions it exactly as it does a fill/line/circle layer. Nothing new was
10
+ * needed in `rendered-layers.ts` for that, which is the point of reusing the
11
+ * render mode rather than inventing a fourth one.
12
+ * - **deck** — the layer instances go into the per-pass accumulator and the
13
+ * entry tracks nothing, matching the deck family's documented special case.
14
+ * The builder itself is **S24-14's** (`SymbolShaderExtension` and the three
15
+ * harness texts). Until it is injected, a deck plan mounts nothing rather
16
+ * than quietly rendering something that is not the symbol the author
17
+ * published — see `S24-V113`.
18
+ *
19
+ * Resolution is injected too. This session owns no fetching: `resolveSymbol`
20
+ * comes from the scene-binding layer (S24-20), and with no resolver every symbol
21
+ * reference compiles to the `missing` fallback — the host default for the
22
+ * geometry family, with the reason typed and the caller's `styleJson`
23
+ * untouched (F24.9).
24
+ */
25
+ import type { Layer } from "@deck.gl/core";
26
+ import type { SymbolCapabilities, SymbolFallbackReason, SymbolGeometry, SymbolManifest, SymbolRef, SymbolRenderPlan } from "../../../domain/models/symbol";
27
+ import type { LayerRendererEntry, SceneLayerRenderInput } from "../LayerRendererRegistry";
28
+ import type { SpriteRegistry } from "./SpriteRegistry";
29
+ export declare const SYMBOL_SCENE_LAYER_TYPE_IDS: readonly ["SYMBOL_POINT", "SYMBOL_LINE", "SYMBOL_POLYGON"];
30
+ export type SymbolSceneLayerTypeId = (typeof SYMBOL_SCENE_LAYER_TYPE_IDS)[number];
31
+ export declare function isSymbolSceneLayerType(layerType: string | null | undefined): layerType is SymbolSceneLayerTypeId;
32
+ export declare function getSymbolSceneLayerGeometry(typeId: SymbolSceneLayerTypeId): SymbolGeometry;
33
+ /** What a resolved (or refused) symbol reference looks like to the entries. */
34
+ export interface SymbolResolution {
35
+ manifest?: SymbolManifest | null;
36
+ /** The manifest a T0 preset extends, when the reference resolved to one. */
37
+ presetTarget?: SymbolManifest | null;
38
+ /** Set when the reference did not resolve: forbidden, yanked, gone, no extension. */
39
+ reason?: SymbolFallbackReason | null;
40
+ }
41
+ export interface SymbolLayerRendererDeps {
42
+ /** Synchronous by design: a reconcile pass cannot await. The scene-binding
43
+ * layer resolves references ahead of the pass and answers from its cache. */
44
+ resolveSymbol?: (ref: SymbolRef, refKey: string) => SymbolResolution | null;
45
+ /** The sprites currently registered on this map, if a registry is wired. */
46
+ spriteRegistry?: Pick<SpriteRegistry, "availableIds"> | null;
47
+ /**
48
+ * The live scene binding owns asynchronous symbol resources. Until it says a
49
+ * referenced symbol is render-ready, do not mount a host-default substitute:
50
+ * a normal T1/T2 load is not a missing-symbol fallback.
51
+ */
52
+ isSymbolResourcesReady?: (styleJson: string | null | undefined, plan: SymbolRenderPlan) => boolean;
53
+ /** S24-14's deck builder. Absent in W1 — a deck plan then mounts nothing. */
54
+ buildDeckLayers?: (plan: SymbolRenderPlan, input: SceneLayerRenderInput) => Layer[];
55
+ /** Device/user capabilities. Resolved per map by the scene controller. */
56
+ getCapabilities?: () => SymbolCapabilities;
57
+ /** Called with each mounted plan so the map's clock can count animated layers. */
58
+ onPlan?: (sceneLayerId: string, plan: SymbolRenderPlan) => void;
59
+ }
60
+ /**
61
+ * Compile one scene layer's saved style into a plan. Exported because the layer
62
+ * list needs the same answer — including `fallbackReason`, which is what the
63
+ * typed message under `Scene.symbolFallback` is keyed on.
64
+ */
65
+ export declare function planSymbolSceneLayer(typeId: SymbolSceneLayerTypeId, styleJson: string | null | undefined, deps?: SymbolLayerRendererDeps): SymbolRenderPlan;
66
+ /** The three entries `createLayerRendererRegistry` registers (F24.9). */
67
+ export declare function createSymbolLayerRendererEntries(deps?: SymbolLayerRendererDeps): LayerRendererEntry[];
@@ -0,0 +1,205 @@
1
+ /**
2
+ * Analysis types.
3
+ *
4
+ * Two halves, and they are different in kind:
5
+ *
6
+ * 1. **UI-surface types** (`WorkSurface`, `RightDockMode`, …) — pre-existing,
7
+ * local to the analysis workspace.
8
+ * 2. **The Stage 14 UI-schema + validation wire DTOs** — **F14.2 / F14.3
9
+ * verbatim**, authored at the W1 kickoff and **read-only to every W1
10
+ * session** (`docs/components_flow_stage/README.md` → F14.24). YB1 serves
11
+ * these shapes, YB2 serves the validation/search ones, Y3/Y4 consume them.
12
+ * A session that needs a change here **stops and raises it** — YB1's Python
13
+ * tests and Y3's TS tests must round-trip the *same* fixtures
14
+ * (`src/sdk/__fixtures__/ui-schema/` ≡ `ngis-geoanalysis/tests/fixtures/ui_schema/`,
15
+ * byte-identical, divergence is a wave-close blocker).
16
+ *
17
+ * **The wire is snake_case and so is the type.** Any camelCase remap would be a
18
+ * second normalization — the exact thing this stage exists to kill — and would
19
+ * break the byte-identical fixture rule. One spelling, one serializer, two
20
+ * transports (HTTP + the `GetToolUiSchema` gRPC leg).
21
+ *
22
+ * The `import type` of `NgisDataType` from `@/sdk/facets/types` is deliberate
23
+ * and type-only in both directions: that module imports `NgisToolUiSchema` back
24
+ * from here for `NgisModelsFacet.uiSchema`. Both edges are erased at compile
25
+ * time, so there is no runtime cycle. F14.1 fixes the vocabulary's home in
26
+ * `src/sdk/facets/types.ts`; F14.2 fixes the schema family's home here.
27
+ */
28
+ import type { NgisDataType } from "../sdk/facets/types";
29
+ export type WorkSurface = "workflow" | "insight" | "code";
30
+ export type RightDockMode = "none" | "ai";
31
+ export type MapFocusMode = "split" | "map" | "work";
32
+ export type LayerSourcePanelMode = "closed" | "resources" | "style";
33
+ export type NgisUiSchemaValueType = "string" | "number" | "integer" | "boolean";
34
+ export type NgisParamRole = "input" | "option" | "output";
35
+ /**
36
+ * Total, frozen. **There is NO fallback widget:** an unknown key is a
37
+ * render-time error surfaced in place, never a silently-degraded text input.
38
+ * A Y3 widget registry missing any of the twelve is a defect.
39
+ *
40
+ * `field-select`, `extent` and `textarea` are **never emitted by YB1 in v1** —
41
+ * no builtin schema expresses a field, a bbox or a long-text parameter. They
42
+ * are in the union because the registry must be total over it, and because an
43
+ * author's `ParamForm` `widgets` override and a recipe's promoted inputs can
44
+ * select them.
45
+ */
46
+ export type NgisWidgetKey = "resource-select" | "resource-multi" | "select" | "multi-select" | "switch" | "number" | "integer" | "text" | "textarea" | "output-name" | "field-select" | "extent";
47
+ export interface NgisUiSchemaChoice {
48
+ value: string;
49
+ label: string;
50
+ }
51
+ /** Derived from `x-rely-on`. Empty array when the parameter has no declared dependency. */
52
+ export interface NgisUiSchemaDependency {
53
+ /** The `name` of the parameter whose value gates this one. */
54
+ param: string;
55
+ /** Shown only when the parent's value, stringified, is one of these. */
56
+ equals: readonly string[];
57
+ }
58
+ export interface NgisToolUiParam {
59
+ /** The wire name — exactly the key `POST /api/analysis/tasks` takes. */
60
+ name: string;
61
+ /** `x-display-name` -> `title` -> `name`. The generated-reason text source (F14.10). */
62
+ label: string;
63
+ description: string | null;
64
+ role: NgisParamRole;
65
+ value_type: NgisUiSchemaValueType;
66
+ /** Canonical (F14.1). `null` for role "option". */
67
+ data_type: NgisDataType | null;
68
+ widget: NgisWidgetKey;
69
+ /** `name in required[]` OR `x-optional === false`. Both halves, always. */
70
+ required: boolean;
71
+ /** `x-multiple === true`. Multi-valued inputs are comma-joined on submit. */
72
+ multiple: boolean;
73
+ default_value: string | number | boolean | null;
74
+ /** `enum` first, else `x-constraints.choices[].value` with `.label`. `[]` when none. */
75
+ choices: readonly NgisUiSchemaChoice[];
76
+ /** `minimum` first, else `x-constraints.min`. Same for max. */
77
+ minimum: number | null;
78
+ maximum: number | null;
79
+ depends_on: readonly NgisUiSchemaDependency[];
80
+ /** Advisory. `x-vector-geom` canonicalized to "point" | "line" | "polygon", else null. */
81
+ geometry: string | null;
82
+ /** `x-output-ext`. `null` unless role === "output". */
83
+ output_extension: string | null;
84
+ /** Every `x-*` key of the source property, verbatim and unmodified — the escape
85
+ * hatch, and the reason no consumer ever needs the raw endpoint. Includes keys
86
+ * this contract does not name (`x-flags`, `x-grass-element`, `x-required-srid`,
87
+ * `x-required-fields`, `x-primary`, `x-vector-layer`, `x-entry-file`, `x-runtime`). */
88
+ extensions: Readonly<Record<string, unknown>>;
89
+ }
90
+ export interface NgisToolUiSchema {
91
+ /** Literal 1 in this stage. A consumer that reads a version it does not know
92
+ * refuses; it never best-efforts a newer shape. */
93
+ ui_schema_version: 1;
94
+ tool_id: string;
95
+ /** `ngis_model_tool.version`. The value to pass as `expected_tool_version`. */
96
+ tool_version: number;
97
+ /** `owner_id IS NULL`. Never stored; always derived. */
98
+ is_builtin: boolean;
99
+ provider: string;
100
+ name: string;
101
+ description: string | null;
102
+ /** Diagnostic only. Clients MUST NOT branch on it. */
103
+ source_shape: "properties" | "inputs";
104
+ params: readonly NgisToolUiParam[];
105
+ }
106
+ /**
107
+ * The `ui_schema_version` this build understands. A reader that sees anything
108
+ * else **refuses** — it never best-efforts a newer shape (F14.2, and the same
109
+ * rule `recipeVersion` carries in F14.6).
110
+ */
111
+ export declare const NGIS_UI_SCHEMA_VERSION: 1;
112
+ /** `PASS | ADAPTABLE | UNKNOWN | FAIL`, passed through verbatim. */
113
+ export type NgisBindingVerdict = "PASS" | "ADAPTABLE" | "UNKNOWN" | "FAIL";
114
+ /** `READY | NEEDS_CONFIGURATION | NOT_EXECUTABLE`, passed through verbatim. */
115
+ export type NgisExecutionVerdict = "READY" | "NEEDS_CONFIGURATION" | "NOT_EXECUTABLE";
116
+ export type NgisExecutionMode = "DIRECT" | "WORKFLOW";
117
+ export type NgisOutputMode = "ADD_LAYER" | "UPDATE_RESOURCE";
118
+ /** `DatasetBinding` — the wire form. */
119
+ export interface NgisDatasetBindingWire {
120
+ port_name: string;
121
+ file_ids: readonly string[];
122
+ }
123
+ /** `BindingValidation`, field-for-field. */
124
+ export interface NgisBindingValidationEntry {
125
+ port_name: string;
126
+ file_id: string;
127
+ expected_data_type: string;
128
+ actual_dataset_type: string;
129
+ dataset_status: string;
130
+ verdict: NgisBindingVerdict;
131
+ reason: string;
132
+ geometry_type: string;
133
+ srid: number;
134
+ native_srid: number;
135
+ working_srid: number;
136
+ access_mode: string;
137
+ executable: boolean;
138
+ }
139
+ /** `ValidateToolBindingsResponse`, field-for-field. */
140
+ export interface NgisBindingValidation {
141
+ tool_id: string;
142
+ tool_version: number;
143
+ verdict: NgisBindingVerdict;
144
+ bindings: readonly NgisBindingValidationEntry[];
145
+ unresolved_ports: readonly string[];
146
+ errors: readonly string[];
147
+ warnings: readonly string[];
148
+ }
149
+ /** `ValidateToolExecutionResponse`, field-for-field, with `normalized_params_json`
150
+ * replaced by the decoded `normalized_params` object (the one divergence). */
151
+ export interface NgisExecutionValidation {
152
+ tool_id: string;
153
+ tool_version: number;
154
+ verdict: NgisExecutionVerdict;
155
+ binding_validation: NgisBindingValidation | null;
156
+ missing_parameters: readonly string[];
157
+ parameter_errors: readonly string[];
158
+ output_errors: readonly string[];
159
+ warnings: readonly string[];
160
+ direct_executable: boolean;
161
+ execution_mode: NgisExecutionMode;
162
+ /** Decoded. The proto's `normalized_params_json` string is never sent to a browser. */
163
+ normalized_params: Readonly<Record<string, string>>;
164
+ }
165
+ /** `POST /api/analysis/tools/{tool_id}/validate-execution` body. */
166
+ export interface NgisValidateExecutionBody {
167
+ expected_tool_version?: number;
168
+ bindings?: readonly NgisDatasetBindingWire[];
169
+ /** Decoded, not `params_json`. */
170
+ params?: Readonly<Record<string, string>>;
171
+ scene_id?: string;
172
+ expected_scene_generation?: number;
173
+ output_mode?: NgisOutputMode;
174
+ target_resource_id?: string | null;
175
+ target_srid?: number;
176
+ }
177
+ /** `POST /api/analysis/tools/{tool_id}/validate-bindings` body. */
178
+ export interface NgisValidateBindingsBody {
179
+ expected_tool_version?: number;
180
+ bindings?: readonly NgisDatasetBindingWire[];
181
+ }
182
+ /** `ToolSearchResult`, field-for-field. */
183
+ export interface NgisToolSearchResult {
184
+ tool_id: string;
185
+ version: number;
186
+ kind: string;
187
+ name: string;
188
+ provider: string;
189
+ summary: string;
190
+ domains: readonly string[];
191
+ operation_types: readonly string[];
192
+ input_types: readonly string[];
193
+ output_types: readonly string[];
194
+ modelbox_path: string;
195
+ score: number;
196
+ semantic_match: boolean;
197
+ lexical_match: boolean;
198
+ }
199
+ /** `SearchToolsResponse`, field-for-field. `GET /api/analysis/tools/search`.
200
+ * `limit` default 10, server maximum 50. */
201
+ export interface NgisToolSearchResponse {
202
+ tools: readonly NgisToolSearchResult[];
203
+ search_degraded: boolean;
204
+ degradation_reason: string;
205
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Cross-domain API shapes shared by more than one client module.
3
+ *
4
+ * `PageResult<T>` moved here verbatim from `src/api/scenes.ts` (F1 / W1.2) so the
5
+ * extension market does not fork a second pagination interface. `scenes.ts`
6
+ * re-exports it, so every existing `import { PageResult } from "@/api/scenes"`
7
+ * keeps working.
8
+ */
9
+ export interface PageResult<T> {
10
+ content: T[];
11
+ totalElements: number;
12
+ totalPages: number;
13
+ size: number;
14
+ number: number;
15
+ first?: boolean;
16
+ last?: boolean;
17
+ }