/** * The UNS as a Map Engine data source (requirement §26–28, §52). UNS ONLY: nodes come from the workspace tree, * live values from `/timeseries/latest`, history from `/timeseries/range` — always by UNS node id. Legacy device / * sensor identifiers in metadata (deviceId, sensorId, latitudeSensor, …) are deprecated and never used. * * Spatiality is a capability (§9), declared on the node as `metadata.spatial`: * - `SpatialGeometry` → an area: `spatial.geometry` (GeoJSON, EPSG:4326) * - `SpatialPoint` → a point: `spatial.geometry` or `spatial.latitude/longitude` * - `MovingSpatial` → a point whose position comes from the node's child tags whose `metadata.spatialRole` is * `latitude` / `longitude` (heading, speed, altitude roles enrich it) * - `SpatialTrack` → history; served through getTracks() from the moving nodes' position tags * Every other child tag becomes a live property named by its `metadata.semantic` (else its name). * * The visual plane (docs 28/29) from what the UNS states, never guessed: provenance (workspace, node path, times, * version and marking from metadata, a time per property), confidence and an accuracy radius from tags with those * spatialRoles, a validity window from metadata, links from `metadata.links` and the spatial parent/child tree, and * an event journal from each node's tag history. */ import { MapEngineError } from '../map-engine/index.js'; import type { AltitudeReference, AuthAware, AuthContext, JournalEntry, JournalProvider, Link, LinkProvider, DataCapabilities, DatasetCatalog, DatasetInfo, Geometry, OntologySpatialResolver, RealtimeProvider, SpatialDataProvider, SpatialObject, SpatialPatch, SpatialQuery, TimeRange, Track, TrackProvider, Unsubscribe } from '../map-engine/index.js'; import type { UnsClient, UnsNode } from './client.js'; type Kind = 'area' | 'fixed' | 'moving' | 'point'; interface TagInfo { id: string; key: string; /** The tag's UNS path, for provenance. */ path?: string; unit?: string; role?: string; enumValues?: string[]; valueType?: string; /** For heights: what they are measured from, as the UNS states it (metadata.datum). */ datum?: string; } /** A UNS datum as an engine altitude reference (ADR-028); unknown datums give none — never guessed. */ export declare function referenceOf(datum: string | undefined): AltitudeReference | undefined; /** One spatial UNS node and what it takes to draw it. */ export interface SpatialNode { node: UnsNode; ontologyType: string; kind: Kind; /** Areas and fixed points. */ geometry?: Geometry; tags: TagInfo[]; latTag?: TagInfo; lngTag?: TagInfo; /** The tag with `spatialRole: altitude`, used only when its datum gives a reference. */ altTag?: TagInfo; altitudeReference?: AltitudeReference; /** Static properties from metadata (no legacy identifiers). */ props: Record; /** A time the node itself carries (detections, observations…). */ timestamp?: string; } export interface UnsProviderOptions { client: UnsClient; workspace: string; /** Shown as the datasets' source. */ workspaceName?: string; /** How often live values are read for subscribers. Default 3000 ms. */ pollMs?: number; /** Re-read the tree after this long. Default 5 min. */ discoveryTtlMs?: number; /** Latest values are shared between calls for this long. Default 1500 ms. */ latestTtlMs?: number; now?: () => number; /** Timer for polling (tests). */ setInterval?: (fn: () => void, ms: number) => unknown; clearInterval?: (handle: unknown) => void; } /** "AirPlatform" → "Air platforms", "RFStation" → "RF stations" (acronyms keep their capitals). */ export declare const pluralLabel: (cls: string) => string; /** Builds the spatial index of a workspace from its full node rows. Exported for tests. */ export declare function indexSpatialNodes(rows: UnsNode[]): SpatialNode[]; export declare class UnsSpatialProvider implements SpatialDataProvider, RealtimeProvider, TrackProvider, DatasetCatalog, JournalProvider, LinkProvider, AuthAware { private readonly opts; readonly capabilities: DataCapabilities; private nodes; private nodesAt; private latestCache; /** A read in flight, shared by every caller that needs any of its tags (the UNS answers in seconds). */ private latestInFlight; private readonly subs; private timer; private readonly now; constructor(opts: UnsProviderOptions); /** * Who is looking (doc 28 G13): the token goes with every UNS call and everything cached is read again, since * another user may see other nodes and values. A refused read (HTTP 403) reaches the map as a denied layer. */ setAuth(auth: AuthContext | null): void; /** The spatial nodes of the workspace (cached; re-read after discoveryTtlMs). */ discover(signal?: AbortSignal): Promise; private readTree; /** * Latest values for tags. The UNS answers a batch in seconds, so a cold read fetches EVERY live tag of the * workspace at once (in parallel chunks) and every layer's query is served from that one round; a read already * in flight is shared rather than repeated. */ private latest; /** One spatial node as a SpatialObject, with its live values. Null when a moving node has no position yet. */ private toObject; private liveTagIds; private select; query(query: SpatialQuery, signal?: AbortSignal): Promise; getCurrentState(objectIds: string[], signal?: AbortSignal): Promise; subscribe(query: SpatialQuery, onPatch: (p: SpatialPatch) => void, onError?: (e: Error) => void): Unsubscribe; /** One polling round for every subscriber. Exposed for tests. */ poll(): Promise; getTracks(query: SpatialQuery, range: TimeRange, signal?: AbortSignal): Promise; /** * The event journal from the UNS's own history: each node's property tags over the range, merged by time into * a snapshot at the range start and one entry per change. Positions are left to tracks; areas and fixed points * without tags have no history (they are static). A node created inside the range (metadata.createdAt) is not * there before it. */ getJournal(query: SpatialQuery, range: TimeRange, signal?: AbortSignal): Promise; /** * Links the UNS states: `metadata.links` (or `relations`) entries `{ to, type }` naming another node by id or path, * and the tree itself — a spatial node under another spatial node is `part-of` it. */ getLinks(objectIds: string[], types: string[] | undefined, signal?: AbortSignal): Promise; listDatasets(signal?: AbortSignal): Promise; /** Ontology binding from the declared capabilities (§9, §12): what each class is drawn as. */ readonly ontology: OntologySpatialResolver; /** Stops polling. */ dispose(): void; } /** Thrown shape for callers that want a typed failure. */ export declare const unsError: (message: string, cause?: unknown) => MapEngineError; export {};