@aeroswarm/client 0.1.12 → 0.1.13

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.
@@ -0,0 +1,701 @@
1
+ import * as _aeroswarm_core_types from '@aeroswarm/core/types';
2
+ import { FlightPlan, CurrentTrack, SourceStatus, AeroConnectionStatus, AeroRecoverableError, Bbox } from '@aeroswarm/core/types';
3
+ import * as _trpc_client from '@trpc/client';
4
+
5
+ interface SourceRow {
6
+ id: string;
7
+ name: string;
8
+ type: string;
9
+ sourceToken: string;
10
+ createdAt: string;
11
+ /** Airport this source's data belongs to. When set, anything that
12
+ * authenticates with this source's token (WS live/replay, tRPC calls)
13
+ * is scoped to this airport automatically. */
14
+ airportId?: string | null;
15
+ }
16
+
17
+ /** A flight plan plus the live track it currently correlates with (null = not on radar). */
18
+ type FlightPlanRow = FlightPlan & {
19
+ trackId: string | null;
20
+ };
21
+ /** One raw AFTN message from the live log (newest first, capped by the service). */
22
+ interface AftnMessageRow {
23
+ id: string;
24
+ receivedAt: number;
25
+ airportId: string | null;
26
+ feedId: string | null;
27
+ callsign: string | null;
28
+ type: string;
29
+ adep?: string;
30
+ ades?: string;
31
+ raw: string;
32
+ }
33
+ declare class AeroRestClient {
34
+ private readonly endpoint;
35
+ private readonly token;
36
+ constructor(endpoint: string, token: string);
37
+ private req;
38
+ createSource(body: Record<string, unknown>): Promise<{
39
+ ok: boolean;
40
+ data: {
41
+ sourceId: string;
42
+ sourceToken: string;
43
+ airportId?: string | null;
44
+ };
45
+ }>;
46
+ listSources(): Promise<{
47
+ ok: boolean;
48
+ data: {
49
+ sources: SourceRow[];
50
+ };
51
+ }>;
52
+ deleteSource(id: string): Promise<{
53
+ ok: boolean;
54
+ }>;
55
+ createWebhook(body: {
56
+ url: string;
57
+ events: string[];
58
+ secret?: string;
59
+ }): Promise<{
60
+ webhookId: string;
61
+ }>;
62
+ getTracksCurrent(params?: {
63
+ bbox?: [number, number, number, number];
64
+ minConfidence?: number;
65
+ }): Promise<{
66
+ tracks: unknown[];
67
+ count: number;
68
+ }>;
69
+ /** Flight plans received from AFTN feeds (FPL/CHG/DLA/DEP/ARR/CNL folded per flight). */
70
+ listFlightPlans(params?: {
71
+ airportId?: string;
72
+ status?: string;
73
+ callsign?: string;
74
+ limit?: number;
75
+ }): Promise<{
76
+ ok: boolean;
77
+ data: {
78
+ flightPlans: FlightPlanRow[];
79
+ count: number;
80
+ };
81
+ }>;
82
+ getFlightPlan(id: string): Promise<{
83
+ ok: boolean;
84
+ data: {
85
+ flightPlan: FlightPlan;
86
+ };
87
+ }>;
88
+ /** Raw AFTN messages (every parsed ATS message, newest first — the input
89
+ * side of the flight-plan pipeline). */
90
+ listAftnMessages(params?: {
91
+ airportId?: string;
92
+ limit?: number;
93
+ }): Promise<{
94
+ ok: boolean;
95
+ data: {
96
+ messages: AftnMessageRow[];
97
+ count: number;
98
+ };
99
+ }>;
100
+ health(): Promise<{
101
+ status: string;
102
+ }>;
103
+ }
104
+
105
+ type WsEncoding = "json" | "msgpack";
106
+ interface SubscribeOptions {
107
+ bbox?: [number, number, number, number];
108
+ /** Scope the stream to tracks stamped with this ICAO airport code, e.g. "WARR" */
109
+ airportId?: string;
110
+ source?: "fused" | "normalized";
111
+ minConfidence?: number;
112
+ maxTracks?: number;
113
+ mode?: "delta" | "full";
114
+ maxUpdateHz?: number;
115
+ encoding?: WsEncoding;
116
+ staleAfterMs?: number;
117
+ removeAfterMs?: number;
118
+ }
119
+ /** Envelope fields that ride along with a track message. */
120
+ interface StreamMeta {
121
+ /** The server's clock when it sent the message (ms). Lets a client align its own clock with `lastSeenAt`. */
122
+ serverTime: number;
123
+ seq: number;
124
+ }
125
+ interface TrackCallbacks {
126
+ onTrackUpdate?: (track: CurrentTrack, meta?: StreamMeta) => void;
127
+ onTrackRemoved?: (event: {
128
+ trackId: string;
129
+ reason: string;
130
+ }) => void;
131
+ onSnapshot?: (tracks: CurrentTrack[], meta?: StreamMeta) => void;
132
+ onSourceStatus?: (event: {
133
+ sourceId: string;
134
+ status: SourceStatus;
135
+ }) => void;
136
+ onStatusChange?: (status: AeroConnectionStatus) => void;
137
+ onError?: (err: AeroRecoverableError) => void;
138
+ onDegraded?: (reason: string) => void;
139
+ }
140
+ declare class AeroWsClient {
141
+ private readonly url;
142
+ private readonly token;
143
+ private readonly maxReconnectDelay;
144
+ private readonly heartbeatTimeoutMs;
145
+ private ws;
146
+ private attempt;
147
+ private stopped;
148
+ private lastSubscribe;
149
+ private callbacks;
150
+ private lastSeq;
151
+ private lastHeartbeat;
152
+ private heartbeatTimer;
153
+ private reconnectTimer;
154
+ private status;
155
+ constructor(url: string, token: string, maxReconnectDelay?: number, heartbeatTimeoutMs?: number);
156
+ connect(opts: SubscribeOptions, callbacks: TrackCallbacks): void;
157
+ updateFilter(opts: Partial<Pick<SubscribeOptions, 'bbox' | 'minConfidence' | 'maxUpdateHz' | 'maxTracks'>>): void;
158
+ disconnect(): void;
159
+ /**
160
+ * Force a fresh connection now, skipping any backoff wait. Re-subscribes with
161
+ * the last `connect()` options (the server then sends a new snapshot).
162
+ * Also resumes after `disconnect()`. No-op if `connect()` was never called.
163
+ * Returns false in that no-op case.
164
+ */
165
+ reconnect(): boolean;
166
+ getStatus(): AeroConnectionStatus;
167
+ private _setStatus;
168
+ /** Close the current socket without letting its onclose schedule a reconnect. */
169
+ private _dropSocket;
170
+ private _connect;
171
+ private _handleRaw;
172
+ private _requestSnapshot;
173
+ private _resetHeartbeatTimer;
174
+ private _clearHeartbeatTimer;
175
+ private _scheduleReconnect;
176
+ private _clearReconnectTimer;
177
+ }
178
+
179
+ /**
180
+ * Server-paced WS replay client for `/ws/tracks/replay`.
181
+ *
182
+ * The server streams historical `fused_tracks` events at `speed`× real
183
+ * time (paced server-side against a wall-clock anchor), so the client
184
+ * receives replay frames exactly like live traffic: a `snapshot`
185
+ * envelope with the state at `from`, then `track.updated` /
186
+ * `track.removed` envelopes, plus `replay.progress` heartbeats and a
187
+ * final `replay.done`.
188
+ *
189
+ * The wire protocol is plain JSON, so consumers that don't use this SDK
190
+ * can speak it manually:
191
+ *
192
+ * → connect wss://host/ws/tracks/replay?token=TOKEN[&airportId=WARR][&sessionId=ID]
193
+ * → send { "type": "replay.start", "from": ISO, "to": ISO, "speed": 2 }
194
+ * → send { "type": "replay.pause" } · { "type": "replay.resume" }
195
+ * → send { "type": "replay.seek", "at": ISO }
196
+ * → send { "type": "replay.stop" }
197
+ * ← recv { "type": "snapshot", "payload": { "tracks": [...], "sessionId": ID } }
198
+ * ← recv { "type": "track.updated", "payload": { "track": {...} } }
199
+ * ← recv { "type": "track.removed", "payload": { "trackId": ID, "reason": "dropped" } }
200
+ * ← recv { "type": "replay.progress", "payload": { "at": ISO, "pct": 0-100, "sessionId": ID } }
201
+ * ← recv { "type": "replay.done", "payload": { "sessionId": ID } }
202
+ *
203
+ * Reconnecting with the same `sessionId` (within 1 h) resumes a replay
204
+ * from its last saved position.
205
+ */
206
+ interface ReplayStreamOptions {
207
+ from: Date | string;
208
+ to: Date | string;
209
+ /** Playback speed multiplier (1 = realtime). Default 1. */
210
+ speed?: number;
211
+ /** Which airport to replay. Federated airports (with a historyEndpoint)
212
+ * are resolved by AeroSwarm.replay.stream to their own backend; against
213
+ * AeroSwarm's own endpoint this is a row filter on the local DB. */
214
+ airportId?: string;
215
+ /** Resume a previous session instead of starting fresh. */
216
+ sessionId?: string;
217
+ }
218
+ interface ReplayProgress {
219
+ /** Replay-time position (ISO timestamp) */
220
+ at: string;
221
+ /** 0–100 within the requested range */
222
+ pct: number;
223
+ sessionId: string;
224
+ }
225
+ interface ReplayCallbacks {
226
+ /** State at `from` — arrives once per start/seek. */
227
+ onSnapshot?: (tracks: CurrentTrack[], sessionId: string) => void;
228
+ onTrackUpdate?: (track: CurrentTrack) => void;
229
+ onTrackRemoved?: (event: {
230
+ trackId: string;
231
+ reason: string;
232
+ }) => void;
233
+ onProgress?: (progress: ReplayProgress) => void;
234
+ onDone?: (sessionId: string) => void;
235
+ onError?: (error: Error) => void;
236
+ }
237
+ interface ReplayHandle {
238
+ readonly sessionId: string | null;
239
+ pause(): void;
240
+ resume(): void;
241
+ /** Jump to a replay-time position; the server restarts the paced stream there. */
242
+ seek(at: Date | string): void;
243
+ /** End the replay and close the socket. */
244
+ stop(): void;
245
+ }
246
+ declare class AeroReplayClient {
247
+ private readonly wsBase;
248
+ private readonly token;
249
+ /** Default "/ws/tracks/replay" (AeroSwarm's own endpoint). A federated
250
+ * airport backend running @aeroswarm/replay-server's default mount
251
+ * uses "/replay" instead — see AeroSwarm.replay.stream's endpoint
252
+ * resolution. */
253
+ private readonly wsPath;
254
+ constructor(wsBase: string, token: string,
255
+ /** Default "/ws/tracks/replay" (AeroSwarm's own endpoint). A federated
256
+ * airport backend running @aeroswarm/replay-server's default mount
257
+ * uses "/replay" instead — see AeroSwarm.replay.stream's endpoint
258
+ * resolution. */
259
+ wsPath?: string);
260
+ /** Open a replay stream. Returns a handle for transport control. */
261
+ stream(opts: ReplayStreamOptions, callbacks: ReplayCallbacks): ReplayHandle;
262
+ }
263
+
264
+ declare function createAeroTrpcClient(endpoint: string, token: string): _trpc_client.TRPCClient<any>;
265
+ type AeroTrpcClient = ReturnType<typeof createAeroTrpcClient>;
266
+
267
+ declare class AeroGraphQLClient {
268
+ private readonly endpoint;
269
+ private readonly token;
270
+ constructor(endpoint: string, token: string);
271
+ query<T = unknown>(query: string, variables?: Record<string, unknown>): Promise<T>;
272
+ }
273
+
274
+ /**
275
+ * Callsign-label category of a track, in priority order:
276
+ * LOST (track status "lost") > GROUND_VEHICLE > ARRIVAL / DEPARTURE > UNKNOWN.
277
+ * ARRIVAL/DEPARTURE come from the correlated flight plan, relative to the
278
+ * track's airport (`track.flightPlan.phase`).
279
+ */
280
+ type LabelCategory = "ARRIVAL" | "DEPARTURE" | "GROUND_VEHICLE" | "LOST" | "UNKNOWN";
281
+ declare const LABEL_COLORS: Readonly<Record<LabelCategory, string>>;
282
+ /** A track as the client exposes it: the server's track plus derived label fields. */
283
+ type LabeledTrack = CurrentTrack & {
284
+ labelCategory: LabelCategory;
285
+ labelColor: string;
286
+ };
287
+ declare function getLabelCategory(track: Pick<CurrentTrack, "status" | "targetType" | "flightPlan">): LabelCategory;
288
+ /**
289
+ * Attach `labelCategory` / `labelColor`. Always call this on the *merged*
290
+ * track: a delta without `flightPlan` must not downgrade a known category
291
+ * (that is what makes labels flicker).
292
+ */
293
+ declare function withLabel(track: CurrentTrack): LabeledTrack;
294
+
295
+ type Listener<T> = (payload: T) => void;
296
+ declare class TypedEmitter<T extends Record<string, unknown>> {
297
+ private listeners;
298
+ on<K extends keyof T>(event: K, fn: Listener<T[K]>): () => void;
299
+ emit<K extends keyof T>(event: K, payload: T[K]): void;
300
+ }
301
+ declare class TrackCache extends TypedEmitter<{
302
+ update: LabeledTrack;
303
+ removed: {
304
+ trackId: string;
305
+ };
306
+ snapshot: LabeledTrack[];
307
+ status: AeroConnectionStatus;
308
+ degraded: {
309
+ reason: string;
310
+ };
311
+ error: AeroRecoverableError;
312
+ "source.status": {
313
+ sourceId: string;
314
+ status: SourceStatus;
315
+ };
316
+ }> {
317
+ private tracks;
318
+ /** Merges into the cached track and returns the labeled result. A "lost"
319
+ * track is evicted from the cache but still returned (labelCategory LOST). */
320
+ applyUpdate(track: CurrentTrack): LabeledTrack;
321
+ applyRemoved(ev: {
322
+ trackId: string;
323
+ }): void;
324
+ applySnapshot(tracks: CurrentTrack[]): LabeledTrack[];
325
+ getAll(): LabeledTrack[];
326
+ get(id: string): LabeledTrack | undefined;
327
+ get size(): number;
328
+ clear(): void;
329
+ getRenderable(): (LabeledTrack & {
330
+ lat: number;
331
+ lon: number;
332
+ })[];
333
+ }
334
+
335
+ interface AeroSwarmOptions {
336
+ endpoint: string;
337
+ token: string;
338
+ wsEndpoint?: string;
339
+ reconnect?: boolean;
340
+ maxReconnectDelay?: number;
341
+ encoding?: "json" | "msgpack";
342
+ staleAfterMs?: number;
343
+ removeAfterMs?: number;
344
+ onTokenExpired?: () => Promise<string>;
345
+ }
346
+ /** Live callbacks: tracks arrive merged with previous state and carry
347
+ * `status`, `labelCategory` and `labelColor`. */
348
+ interface LiveTrackCallbacks extends Omit<TrackCallbacks, "onTrackUpdate" | "onSnapshot"> {
349
+ /** `meta.serverTime` is the server's clock; pass it to `createTrackMotion().update()`. */
350
+ onTrackUpdate?: (track: LabeledTrack, meta?: StreamMeta) => void;
351
+ onSnapshot?: (tracks: LabeledTrack[], meta?: StreamMeta) => void;
352
+ }
353
+ interface UseAeroTracksResult {
354
+ tracks: CurrentTrack[];
355
+ status: AeroConnectionStatus;
356
+ sourceStatus: Record<string, string>;
357
+ lastUpdateAt: number | null;
358
+ error: AeroRecoverableError | null;
359
+ }
360
+ interface TrackHistoryPoint {
361
+ t: number;
362
+ lat: number | null;
363
+ lon: number | null;
364
+ altFt: number | null;
365
+ speedKt: number | null;
366
+ headingDeg: number | null;
367
+ }
368
+ interface DayAvailability {
369
+ day: string;
370
+ eventCount: number;
371
+ trackCount: number;
372
+ firstAt: string | null;
373
+ lastAt: string | null;
374
+ }
375
+ declare class AeroSwarm {
376
+ private readonly opts;
377
+ readonly trpc: AeroTrpcClient;
378
+ readonly rest: AeroRestClient;
379
+ readonly graphql: AeroGraphQLClient;
380
+ readonly cache: TrackCache;
381
+ private readonly wsClient;
382
+ private _status;
383
+ private _lastUpdateAt;
384
+ private _error;
385
+ private _sourceStatus;
386
+ private airportsCache;
387
+ private static readonly AIRPORTS_CACHE_TTL_MS;
388
+ /** Resolves which base URL (if any) should serve a federated call.
389
+ * Returns null to mean "use AeroSwarm's own endpoint" — the normal,
390
+ * unfederated path, which is also what a lookup failure falls back to
391
+ * (a broken airports.list() call must never brick replay/history for
392
+ * everyone else). */
393
+ private resolveHistoryEndpoint;
394
+ private federatedFetch;
395
+ constructor(opts: AeroSwarmOptions);
396
+ readonly tracks: {
397
+ subscribe: (opts: SubscribeOptions, callbacks: LiveTrackCallbacks) => (() => void);
398
+ updateFilter: (opts: Partial<SubscribeOptions>) => void;
399
+ /** Drop the live socket and reconnect immediately (no backoff wait),
400
+ * re-subscribing with the last options. Returns false if nothing has
401
+ * been subscribed yet. */
402
+ reconnect: () => boolean;
403
+ stream: (opts: SubscribeOptions) => AsyncIterable<LabeledTrack>;
404
+ snapshot: (input?: {
405
+ airportId?: string;
406
+ bbox?: Bbox;
407
+ source?: "fused" | "normalized";
408
+ minConfidence?: number;
409
+ limit?: number;
410
+ offset?: number;
411
+ }) => any;
412
+ /** Persisted position history for one track. If the airport has a
413
+ * `historyEndpoint` (or `endpoint` is passed explicitly), this calls
414
+ * that backend's `@aeroswarm/replay-server` instead of AeroSwarm's
415
+ * own local database — see docs/development/federation/003-*.md. */
416
+ history: (input: {
417
+ trackId: string;
418
+ airportId?: string;
419
+ limit?: number;
420
+ endpoint?: string;
421
+ }) => Promise<TrackHistoryPoint[]>;
422
+ };
423
+ /** Flight plans received from AFTN feeds. Live tracks that correlate with a
424
+ * plan (Mode-S address, else callsign) also carry `track.flightPlan`. */
425
+ readonly flightPlans: {
426
+ list: (input?: {
427
+ airportId?: string;
428
+ status?: string;
429
+ callsign?: string;
430
+ limit?: number;
431
+ }) => Promise<FlightPlanRow[]>;
432
+ get: (id: string) => Promise<_aeroswarm_core_types.FlightPlan>;
433
+ };
434
+ /** Raw AFTN/ATS messages received by AFTN feeds — the input side of the
435
+ * flight-plan pipeline (newest first, capped by the service). */
436
+ readonly aftn: {
437
+ messages: (input?: {
438
+ airportId?: string;
439
+ limit?: number;
440
+ }) => Promise<AftnMessageRow[]>;
441
+ };
442
+ readonly sources: {
443
+ /** Registers a source and returns its token, tied to `airportId` — a
444
+ * source is a sensor physically at one airport, so this is required.
445
+ * Anything that later authenticates with the returned token (WS
446
+ * live/replay, tRPC calls) is scoped to that airport automatically,
447
+ * with no need to keep passing `airportId` on every subsequent call.
448
+ * For access spanning multiple airports, use the viewer/dashboard
449
+ * token instead — it's never auto-scoped. */
450
+ create: (body: {
451
+ name: string;
452
+ airportId: string;
453
+ sourceType?: string;
454
+ location?: {
455
+ lat: number;
456
+ lon: number;
457
+ };
458
+ config?: Record<string, unknown>;
459
+ }) => Promise<{
460
+ ok: boolean;
461
+ data: {
462
+ sourceId: string;
463
+ sourceToken: string;
464
+ airportId?: string | null;
465
+ };
466
+ }>;
467
+ health: (sourceId: string) => any;
468
+ list: (input?: {
469
+ airportId?: string;
470
+ }) => any;
471
+ /** Reassigning `airportId` (including to `null` to clear it) re-caches
472
+ * the source's token immediately, so the new scoping takes effect
473
+ * without waiting out the token cache's TTL. */
474
+ update: (input: {
475
+ id: string;
476
+ name?: string;
477
+ airportId?: string | null;
478
+ location?: {
479
+ lat: number;
480
+ lon: number;
481
+ };
482
+ config?: Record<string, unknown>;
483
+ }) => any;
484
+ delete: (id: string) => any;
485
+ };
486
+ /** Airport registry (multi-airport tenancy). */
487
+ readonly airports: {
488
+ list: () => Promise<{
489
+ airports: {
490
+ id: string;
491
+ name: string;
492
+ city: string | null;
493
+ lat: number;
494
+ lon: number;
495
+ bbox: [number, number, number, number];
496
+ timezone: string;
497
+ /** Set = this airport serves its own replay/history (federated —
498
+ * see docs/development/federation/003-*.md); `replay.*`/
499
+ * `tracks.history` calls for it connect there directly instead of
500
+ * AeroSwarm's own endpoint. null = AeroSwarm serves it (default). */
501
+ historyEndpoint: string | null;
502
+ }[];
503
+ }>;
504
+ create: (input: {
505
+ id: string;
506
+ name: string;
507
+ city?: string;
508
+ lat: number;
509
+ lon: number;
510
+ bbox: [number, number, number, number];
511
+ timezone?: string;
512
+ historyEndpoint?: string;
513
+ }) => Promise<{
514
+ ok: boolean;
515
+ id: string;
516
+ }>;
517
+ update: (input: {
518
+ id: string;
519
+ name?: string;
520
+ city?: string;
521
+ lat?: number;
522
+ lon?: number;
523
+ bbox?: [number, number, number, number];
524
+ timezone?: string;
525
+ /** null clears it (reverts to AeroSwarm's own replay); omit to leave unchanged. */
526
+ historyEndpoint?: string | null;
527
+ }) => Promise<{
528
+ ok: boolean;
529
+ }>;
530
+ delete: (input: {
531
+ id: string;
532
+ }) => Promise<{
533
+ ok: boolean;
534
+ }>;
535
+ /** Surface geometry (runway/taxiway/apron GeoJSON) for the map. */
536
+ surface: (input: {
537
+ id: string;
538
+ }) => Promise<{
539
+ surface: unknown | null;
540
+ }>;
541
+ setSurface: (input: {
542
+ id: string;
543
+ surface: Record<string, unknown>;
544
+ }) => Promise<{
545
+ ok: boolean;
546
+ }>;
547
+ };
548
+ readonly replay: {
549
+ /** Data-availability calendar: which days have recorded tracks.
550
+ * Use this to populate/validate replay date pickers — days not in
551
+ * the list have no data. Federates to the airport's own backend when
552
+ * it has a `historyEndpoint` (or `endpoint` is passed explicitly) —
553
+ * see docs/development/federation/003-*.md. */
554
+ days: (input?: {
555
+ airportId?: string;
556
+ lookbackDays?: number;
557
+ endpoint?: string;
558
+ }) => Promise<{
559
+ days: DayAvailability[];
560
+ }>;
561
+ range: (input: {
562
+ from: string;
563
+ to: string;
564
+ airportId?: string;
565
+ endpoint?: string;
566
+ }) => Promise<{
567
+ earliest: string | null;
568
+ latest: string | null;
569
+ eventCount: number;
570
+ trackCount: number;
571
+ from: string;
572
+ to: string;
573
+ }>;
574
+ /** Server-paced WS playback: streams historical tracks at `speed`× in
575
+ * the same envelope format as the live stream. Returns a transport
576
+ * handle (pause/resume/seek/stop) — a Promise, since resolving which
577
+ * backend serves this airport (see docs/development/federation/003-*.md)
578
+ * is async. See `AeroReplayClient` for the raw wire protocol if you
579
+ * want to speak WS manually instead. */
580
+ stream: (opts: ReplayStreamOptions & {
581
+ endpoint?: string;
582
+ }, callbacks: ReplayCallbacks) => Promise<ReplayHandle>;
583
+ };
584
+ /** Movement analytics: takeoffs/landings per hour + peak hour, recorded
585
+ * by the pipeline's movement detector. */
586
+ readonly analytics: {
587
+ movements: (input?: {
588
+ airportId?: string;
589
+ day?: string;
590
+ }) => Promise<{
591
+ day: string;
592
+ hours: {
593
+ hour: string;
594
+ takeoffs: number;
595
+ landings: number;
596
+ }[];
597
+ totals: {
598
+ takeoffs: number;
599
+ landings: number;
600
+ };
601
+ peak: {
602
+ hour: string;
603
+ count: number;
604
+ } | null;
605
+ }>;
606
+ };
607
+ /** Route conformance: pre-defined ground routes + live track clearances.
608
+ * Assign a route to a track and the safety engine can detect when it
609
+ * strays beyond the route's corridor. */
610
+ readonly routes: {
611
+ list: (input?: {
612
+ airportId?: string;
613
+ }) => Promise<{
614
+ routes: {
615
+ routeId: string;
616
+ airportId: string;
617
+ name: string;
618
+ kind: string;
619
+ points: [number, number][];
620
+ maxDeviationM: number;
621
+ enabled: boolean;
622
+ }[];
623
+ }>;
624
+ create: (input: {
625
+ airportId: string;
626
+ name: string;
627
+ kind?: "taxi" | "departure" | "arrival";
628
+ points: [number, number][];
629
+ maxDeviationM?: number;
630
+ }) => Promise<{
631
+ id: string;
632
+ }>;
633
+ delete: (input: {
634
+ id: string;
635
+ }) => Promise<{
636
+ ok: boolean;
637
+ }>;
638
+ assign: (input: {
639
+ trackId: string;
640
+ routeId: string;
641
+ }) => Promise<{
642
+ ok: boolean;
643
+ }>;
644
+ unassign: (input: {
645
+ trackId: string;
646
+ }) => Promise<{
647
+ ok: boolean;
648
+ }>;
649
+ assignments: () => Promise<{
650
+ assignments: {
651
+ trackId: string;
652
+ routeId: string;
653
+ assignedAt: number;
654
+ }[];
655
+ }>;
656
+ };
657
+ readonly webhooks: {
658
+ list: () => any;
659
+ create: (body: {
660
+ url: string;
661
+ events: string[];
662
+ secret?: string;
663
+ }) => Promise<{
664
+ ok: boolean;
665
+ webhookId: string;
666
+ }>;
667
+ delete: (input: {
668
+ id: string;
669
+ }) => any;
670
+ };
671
+ readonly system: {
672
+ stats: () => any;
673
+ infraHealth: () => any;
674
+ ingestHistory: () => any;
675
+ getConfig: () => Promise<{
676
+ key: string;
677
+ value: string;
678
+ updatedAt: string;
679
+ }[]>;
680
+ setConfig: (input: {
681
+ key: string;
682
+ value: string;
683
+ }) => Promise<{
684
+ ok: boolean;
685
+ }>;
686
+ clearTable: (input: {
687
+ table: "fused_tracks" | "source_health";
688
+ mode: "all" | "range";
689
+ from?: string;
690
+ to?: string;
691
+ }) => any;
692
+ };
693
+ getStatus(): AeroConnectionStatus;
694
+ getLastUpdateAt(): number | null;
695
+ getError(): AeroRecoverableError | null;
696
+ getSourceStatus(): Record<string, string>;
697
+ disconnect(): void;
698
+ reconnect(): boolean;
699
+ }
700
+
701
+ export { AeroReplayClient as A, type DayAvailability as D, type FlightPlanRow as F, LABEL_COLORS as L, type ReplayCallbacks as R, type SourceRow as S, TrackCache as T, type UseAeroTracksResult as U, AeroSwarm as a, type AeroSwarmOptions as b, AeroWsClient as c, type AftnMessageRow as d, type LabelCategory as e, type LabeledTrack as f, type LiveTrackCallbacks as g, type ReplayHandle as h, type ReplayProgress as i, type ReplayStreamOptions as j, type StreamMeta as k, type SubscribeOptions as l, type TrackCallbacks as m, type TrackHistoryPoint as n, getLabelCategory as o, withLabel as w };