import type { Position, SpatialObject, SpatialQuery, TimeRange, Track, TrackPoint, Unsubscribe } from '../core/types.js'; import type { AuthAware, AuthContext, DataCapabilities, DatasetCatalog, DatasetInfo, JournalEntry, JournalProvider, Link, LinkProvider, RealtimeProvider, SpatialPatch, TrackProvider, WritableSpatialProvider } from '../data/contracts.js'; export interface MockRecord { object: SpatialObject; ontologyType?: string; } export interface MockProviderOptions { /** Simulated network latency per call. */ latencyMs?: number; capabilities?: Partial; } /** * In-memory provider for tests and io-maps. It plays the role of an already-authorized server runtime * (it does no authorization itself), including realtime: every write notifies the subscriptions it affects, * asynchronously, like a stream would. */ export declare class MockSpatialProvider implements WritableSpatialProvider, RealtimeProvider, TrackProvider, DatasetCatalog, LinkProvider, JournalProvider, AuthAware { readonly capabilities: DataCapabilities; private readonly records; private latencyMs; private failures; /** Every query received, for assertions. */ readonly queries: SpatialQuery[]; private readonly subscriptions; private readonly datasetMeta; /** * Every write as a journal entry (doc 29 §7), so replay can rebuild whole objects — per object, the newest * JOURNAL_CAP kept. Writing is cheap (the stored object is shared, changes are worked out when read): live * feeds write thousands of times a second. */ private readonly journal; private readonly linkList; /** The identity the engine handed over (doc 28 G13). */ auth: AuthContext | null; private deniedTypes; private redaction; /** Position history per object (kept after removal, so replay can still show it). */ private readonly history; constructor(records?: Array, options?: MockProviderOptions); setAuth(auth: AuthContext | null): void; /** Test and demo hook: queries for these types are refused (ACCESS_DENIED), as a server would for this user. */ denyTypes(types: string[]): void; /** Test and demo hook: these properties are removed (and listed in `redacted`) unless the user has the role. */ redactFields(fields: string[], unlessRole?: string): void; private visible; private refuse; setLatency(ms: number): void; /** The next query (or getCurrentState) rejects with this error. */ failNext(error?: Error): void; query(query: SpatialQuery, signal?: AbortSignal): Promise; private matches; getCurrentState(objectIds: string[], signal?: AbortSignal): Promise; upsert(object: SpatialObject, meta?: { ontologyType?: string; }): Promise; remove(objectId: string): Promise; /** The stored record is a private copy and is replaced (never changed) on the next write, so it is shared here. */ private write; private addEntry; /** Adds journal entries (demos and tests): past states and changes, merged with what writes recorded. */ seedJournal(entries: Array): void; getJournal(query: SpatialQuery, range: TimeRange, signal?: AbortSignal): Promise; /** Adds links between objects (demos and tests). */ seedLinks(links: Link[]): void; getLinks(objectIds: string[], types: string[] | undefined, signal?: AbortSignal): Promise; /** Labels a dataset for the catalog, or hides it (e.g. app-internal draft types). */ describeDataset(ontologyType: string, meta: { label?: string; source?: string; hidden?: boolean; altitude?: DatasetInfo['altitude']; }): void; /** Every ontology type held, with geometry, count and property schema — discovered from the records. */ listDatasets(signal?: AbortSignal): Promise; /** Replaces every object of a type (an import, a re-sync). Subscribers see the removals and upserts. */ setDataset(ontologyType: string, objects: SpatialObject[]): Promise; removeDataset(ontologyType: string): Promise; /** Convenience for simulations: move a point and stamp the observation time. */ move(objectId: string, position: Position, observedAt?: string): Promise; subscribe(query: SpatialQuery, onPatch: (p: SpatialPatch) => void, onError?: (e: Error) => void): Unsubscribe; /** Test hook: break every open stream (the engine should reconnect with a fresh snapshot). */ failStreams(error?: Error): void; subscriptionCount(): number; private notify; /** Adds past positions for an object (demos and tests). Points merge with recorded history by time. */ seedHistory(objectId: string, points: TrackPoint[], meta?: { ontologyType?: string; properties?: Record; }): void; getTracks(query: SpatialQuery, range: TimeRange, signal?: AbortSignal): Promise; /** Every point position with a timestamp becomes history. */ private record; /** Synchronous view for tests. Not part of any provider contract. */ size(): number; }