@signalk/tracks-plugin 3.0.1 → 3.0.2

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.
@@ -1,6 +1,8 @@
1
1
  import { TrackQuery } from './timeWindow.js';
2
2
  import { TrackStore } from './store.js';
3
3
  import { Context, Debug, LatLngTuple, TimedPosition, TimedTrackCollection, TimeWindow, TrackCollection, TrackParams } from './types.js';
4
+ export declare class TransactionStateError extends Error {
5
+ }
4
6
  export interface SqliteStoreConfig {
5
7
  /** Absolute path to the database file, or ':memory:'. */
6
8
  file: string;
@@ -102,7 +104,15 @@ export declare class SqliteTrackStore implements TrackStore {
102
104
  segments(context: Context, window?: TimeWindow): LatLngTuple[][];
103
105
  recordName(context: Context, name: string, timestamp?: number): void;
104
106
  nameFor(context: Context): string | undefined;
105
- prune(maxAge: number, keep?: Context): void;
107
+ prune(maxAge: number, keep?: Context, now?: number): void;
108
+ /** Worker startup snapshot; queries and name lookups must not open a second database. */
109
+ storedNames(): {
110
+ context: string;
111
+ name: string;
112
+ timestamp: number;
113
+ }[];
114
+ /** A failed batch stops writes in its worker; reads remain available. */
115
+ transaction(write: () => void): void;
106
116
  close(): void;
107
117
  /** Unsigned round-trip check, used by the tests. */
108
118
  cellIdsFor(context: Context): bigint[];
package/dist/store.d.ts CHANGED
@@ -93,5 +93,5 @@ export interface TrackStore {
93
93
  * store holding file handles must implement it and the plugin calls it from
94
94
  * `stop()`.
95
95
  */
96
- close?(): void;
96
+ close?(): void | Promise<void>;
97
97
  }
@@ -0,0 +1,38 @@
1
+ import { SqliteTrackStore } from './sqliteStore.js';
2
+ export type StoreMethod = 'newPosition' | 'recordName' | 'initialTrack' | 'prune' | 'get' | 'getTimed' | 'getAllTracks' | 'getFilteredTracks' | 'getFilteredTimedTracks' | 'close';
3
+ export type Operation = {
4
+ [K in StoreMethod]: {
5
+ id: number;
6
+ method: K;
7
+ args: Parameters<SqliteTrackStore[K]>;
8
+ };
9
+ }[StoreMethod];
10
+ export interface StoredName {
11
+ context: string;
12
+ name: string;
13
+ timestamp: number;
14
+ }
15
+ export type WorkerMessage = {
16
+ kind: 'ready';
17
+ names: StoredName[];
18
+ } | {
19
+ kind: 'debug';
20
+ text: string;
21
+ } | {
22
+ kind: 'fatal';
23
+ error: string;
24
+ } | {
25
+ kind: 'result';
26
+ results: {
27
+ id: number;
28
+ value?: unknown;
29
+ error?: string;
30
+ writeFailed?: boolean;
31
+ selfPositionUnavailable?: boolean;
32
+ name?: {
33
+ context: string;
34
+ value: string | undefined;
35
+ };
36
+ names?: string[];
37
+ }[];
38
+ };
@@ -0,0 +1 @@
1
+ export {};