@uwdata/mosaic-core 0.15.0 → 0.16.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.
Files changed (39) hide show
  1. package/dist/types/Coordinator.d.ts +22 -25
  2. package/dist/types/MosaicClient.d.ts +20 -11
  3. package/dist/types/QueryManager.d.ts +42 -17
  4. package/dist/types/Selection.d.ts +1 -1
  5. package/dist/types/SelectionClause.d.ts +1 -1
  6. package/dist/types/connectors/Connector.d.ts +25 -0
  7. package/dist/types/connectors/rest.d.ts +13 -17
  8. package/dist/types/connectors/socket.d.ts +98 -16
  9. package/dist/types/connectors/wasm.d.ts +133 -14
  10. package/dist/types/index-types.d.ts +1 -0
  11. package/dist/types/preagg/PreAggregator.d.ts +1 -1
  12. package/dist/types/preagg/preagg-columns.d.ts +2 -2
  13. package/dist/types/preagg/sufficient-statistics.d.ts +2 -2
  14. package/dist/types/types.d.ts +21 -0
  15. package/dist/types/util/cache.d.ts +14 -10
  16. package/dist/types/util/decode-ipc.d.ts +9 -4
  17. package/dist/types/util/void-logger.d.ts +3 -0
  18. package/package.json +4 -4
  19. package/src/Coordinator.js +15 -12
  20. package/src/MosaicClient.js +17 -5
  21. package/src/QueryConsolidator.js +2 -1
  22. package/src/QueryManager.js +31 -0
  23. package/src/Selection.js +4 -2
  24. package/src/SelectionClause.js +5 -2
  25. package/src/connectors/Connector.ts +30 -0
  26. package/src/connectors/rest.js +14 -12
  27. package/src/connectors/socket.js +112 -77
  28. package/src/connectors/wasm.js +118 -55
  29. package/src/index-types.ts +1 -0
  30. package/src/make-client.js +0 -4
  31. package/src/preagg/PreAggregator.js +8 -6
  32. package/src/preagg/preagg-columns.js +5 -2
  33. package/src/preagg/sufficient-statistics.js +2 -1
  34. package/src/types.ts +23 -0
  35. package/src/util/cache.js +20 -5
  36. package/src/util/decode-ipc.js +9 -5
  37. package/src/util/field-info.js +2 -1
  38. package/src/util/js-type.js +3 -1
  39. package/src/util/void-logger.js +4 -1
@@ -8,29 +8,23 @@ export function coordinator(instance?: Coordinator): Coordinator;
8
8
  * A Mosaic Coordinator manages all database communication for clients and
9
9
  * handles selection updates. The Coordinator also performs optimizations
10
10
  * including query caching, consolidation, and pre-aggregation.
11
- * @param {*} [db] Database connector. Defaults to a web socket connection.
12
- * @param {object} [options] Coordinator options.
13
- * @param {*} [options.logger=console] The logger to use, defaults to `console`.
14
- * @param {*} [options.manager] The query manager to use.
15
- * @param {boolean} [options.cache=true] Boolean flag to enable/disable query caching.
16
- * @param {boolean} [options.consolidate=true] Boolean flag to enable/disable query consolidation.
17
- * @param {PreAggregateOptions} [options.preagg] Options for the Pre-aggregator.
18
11
  */
19
12
  export class Coordinator {
20
- constructor(db?: {
21
- readonly connected: boolean;
22
- query(query: {
23
- type?: "exec" | "arrow" | "json" | "create-bundle" | "load-bundle";
24
- sql?: string;
25
- queries?: string[];
26
- name?: string;
27
- }): Promise<any>;
28
- }, { logger, manager, cache, consolidate, preagg }?: {
29
- logger?: Console;
13
+ /**
14
+ * @param {Connector} [db] Database connector. Defaults to a web socket connection.
15
+ * @param {object} [options] Coordinator options.
16
+ * @param {Logger} [options.logger=console] The logger to use, defaults to `console`.
17
+ * @param {QueryManager} [options.manager] The query manager to use.
18
+ * @param {boolean} [options.cache=true] Boolean flag to enable/disable query caching.
19
+ * @param {boolean} [options.consolidate=true] Boolean flag to enable/disable query consolidation.
20
+ * @param {PreAggregateOptions} [options.preagg] Options for the Pre-aggregator.
21
+ */
22
+ constructor(db?: Connector, { logger, manager, cache, consolidate, preagg }?: {
23
+ logger?: Logger;
30
24
  manager?: QueryManager;
31
25
  cache?: boolean;
32
26
  consolidate?: boolean;
33
- preagg?: {};
27
+ preagg?: PreAggregateOptions;
34
28
  });
35
29
  /** @type {QueryManager} */
36
30
  manager: QueryManager;
@@ -49,17 +43,17 @@ export class Coordinator {
49
43
  clients: Set<any>;
50
44
  /**
51
45
  * Get or set the database connector.
52
- * @param {*} [db] The database connector to use.
53
- * @returns The current database connector.
46
+ * @param {Connector} [db] The database connector to use.
47
+ * @returns {Connector} The current database connector.
54
48
  */
55
- databaseConnector(db?: any): any;
49
+ databaseConnector(db?: Connector): Connector;
56
50
  /**
57
51
  * Get or set the logger.
58
- * @param {*} logger The logger to use.
59
- * @returns The current logger
52
+ * @param {Logger} [logger] The logger to use.
53
+ * @returns {Logger} The current logger
60
54
  */
61
- logger(logger: any, ...args: any[]): any;
62
- _logger: any;
55
+ logger(logger?: Logger, ...args: any[]): Logger;
56
+ _logger: Logger;
63
57
  /**
64
58
  * Cancel previosuly submitted query requests. These queries will be
65
59
  * canceled if they are queued but have not yet been submitted.
@@ -162,6 +156,9 @@ export class Coordinator {
162
156
  }
163
157
  import { QueryManager } from './QueryManager.js';
164
158
  import { PreAggregator } from './preagg/PreAggregator.js';
159
+ import type { Connector } from './connectors/Connector.js';
160
+ import type { Logger } from './types.js';
165
161
  import type { QueryResult } from './util/query-result.js';
166
162
  import type { QueryType } from './types.js';
167
163
  import type { MosaicClient } from './MosaicClient.js';
164
+ import type { PreAggregateOptions } from './preagg/PreAggregator.js';
@@ -22,27 +22,27 @@ export class MosaicClient {
22
22
  * will re-query and update the client when the selection updates.
23
23
  */
24
24
  constructor(filterSelection?: Selection);
25
- /** @type {Selection} */
26
- _filterBy: Selection;
25
+ /** @type {Selection | undefined} */
26
+ _filterBy: Selection | undefined;
27
27
  _requestUpdate: (event: any) => void;
28
- /** @type {Coordinator} */
29
- _coordinator: Coordinator;
28
+ /** @type {Coordinator | null} */
29
+ _coordinator: Coordinator | null;
30
30
  /** @type {Promise<any>} */
31
31
  _pending: Promise<any>;
32
32
  /** @type {boolean} */
33
33
  _enabled: boolean;
34
34
  /** @type {boolean} */
35
35
  _initialized: boolean;
36
- /** @type {Query | boolean} */
37
- _request: Query | boolean;
36
+ /** @type {Query | boolean | null} */
37
+ _request: Query | boolean | null;
38
38
  /**
39
39
  * Set this client's connected coordinator.
40
40
  */
41
- set coordinator(coordinator: Coordinator);
41
+ set coordinator(coordinator: Coordinator | null);
42
42
  /**
43
- * Return this client's connected coordinator.
43
+ * @returns {Coordinator | null} this client's connected coordinator.
44
44
  */
45
- get coordinator(): Coordinator;
45
+ get coordinator(): Coordinator | null;
46
46
  /**
47
47
  * Set this client's enabled state;
48
48
  */
@@ -56,9 +56,9 @@ export class MosaicClient {
56
56
  */
57
57
  get pending(): Promise<any>;
58
58
  /**
59
- * Return this client's filter selection.
59
+ * @returns {Selection | undefined} this client's filter selection.
60
60
  */
61
- get filterBy(): Selection;
61
+ get filterBy(): Selection | undefined;
62
62
  /**
63
63
  * Return a boolean indicating if the client query can be sped up with
64
64
  * materialized views of pre-aggregated data. Should return true if changes
@@ -122,6 +122,15 @@ export class MosaicClient {
122
122
  * method has no effect if the client is not registered with a coordinator.
123
123
  */
124
124
  initialize(): void;
125
+ /**
126
+ * Remove this client: disconnect from the coordinator and free up any
127
+ * resource use. This method has no effect if the client is not connected
128
+ * to a coordinator.
129
+ *
130
+ * If overriding this method in a client subclass, be sure to also
131
+ * disconnect from the coordinator.
132
+ */
133
+ destroy(): void;
125
134
  /**
126
135
  * Requests a client update, for example to (re-)render an interface
127
136
  * component.
@@ -7,19 +7,16 @@ export class QueryManager {
7
7
  constructor(maxConcurrentRequests?: number);
8
8
  /** @type {PriorityQueue} */
9
9
  queue: PriorityQueue;
10
- db: any;
11
- clientCache: any;
12
- _logger: {
13
- debug(..._: any[]): void;
14
- info(..._: any[]): void;
15
- log(..._: any[]): void;
16
- warn(..._: any[]): void;
17
- error(..._: any[]): void;
18
- };
10
+ /** @type {Connector} */
11
+ db: Connector;
12
+ /** @type {Cache} */
13
+ clientCache: Cache;
14
+ /** @type {Logger} */
15
+ _logger: Logger;
16
+ /** @type {boolean} */
19
17
  _logQueries: boolean;
20
- _consolidate: {
21
- add(entry: any, priority: any): void;
22
- };
18
+ /** @type {ReturnType<typeof consolidator> | null} */
19
+ _consolidate: ReturnType<typeof consolidator> | null;
23
20
  /**
24
21
  * Requests pending with the query manager.
25
22
  * @type {QueryResult[]}
@@ -47,11 +44,35 @@ export class QueryManager {
47
44
  * @param {QueryResult} result The query result.
48
45
  */
49
46
  submit(request: any, result: QueryResult): Promise<void>;
50
- cache(value: any): any;
51
- logger(value: any): any;
52
- logQueries(value: any): boolean;
53
- connector(connector: any): any;
54
- consolidate(flag: any): void;
47
+ /**
48
+ * Get or set the current query cache.
49
+ * @param {Cache | boolean} [value]
50
+ * @returns {Cache}
51
+ */
52
+ cache(value?: Cache | boolean): Cache;
53
+ /**
54
+ * Get or set the current logger.
55
+ * @param {Logger} [value]
56
+ * @returns {Logger}
57
+ */
58
+ logger(value?: Logger): Logger;
59
+ /**
60
+ * Get or set if queries should be logged.
61
+ * @param {boolean} [value]
62
+ * @returns {boolean}
63
+ */
64
+ logQueries(value?: boolean): boolean;
65
+ /**
66
+ * Get or set the database connector.
67
+ * @param {Connector} [connector]
68
+ * @returns {Connector}
69
+ */
70
+ connector(connector?: Connector): Connector;
71
+ /**
72
+ * Indicate if query consolidation should be performed.
73
+ * @param {boolean} flag
74
+ */
75
+ consolidate(flag: boolean): void;
55
76
  /**
56
77
  * Request a query result.
57
78
  * @param {*} request The request.
@@ -63,4 +84,8 @@ export class QueryManager {
63
84
  clear(): void;
64
85
  }
65
86
  import { PriorityQueue } from './util/priority-queue.js';
87
+ import type { Connector } from './connectors/Connector.js';
88
+ import type { Cache } from './types.js';
89
+ import type { Logger } from './types.js';
90
+ import { consolidator } from './QueryConsolidator.js';
66
91
  import { QueryResult } from './util/query-result.js';
@@ -232,4 +232,4 @@ export class SelectionResolver {
232
232
  }
233
233
  import { Param } from './Param.js';
234
234
  import type { SelectionClause } from './util/selection-types.js';
235
- import { MosaicClient } from './MosaicClient.js';
235
+ import type { MosaicClient } from './MosaicClient.js';
@@ -102,4 +102,4 @@ export type Scale = import("./util/selection-types.js").Scale;
102
102
  export type Extent = import("./util/selection-types.js").Extent;
103
103
  export type MatchMethod = import("./util/selection-types.js").MatchMethod;
104
104
  export type BinMethod = import("./util/selection-types.js").BinMethod;
105
- import { MosaicClient } from './MosaicClient.js';
105
+ import type { MosaicClient } from './MosaicClient.js';
@@ -0,0 +1,25 @@
1
+ import type { Table } from '@uwdata/flechette';
2
+ export interface QueryRequest {
3
+ /** The query type. */
4
+ type?: string;
5
+ /** A SQL query string. */
6
+ sql: string;
7
+ }
8
+ export interface ArrowQueryRequest extends QueryRequest {
9
+ /** The query type. */
10
+ type?: 'arrow';
11
+ }
12
+ export interface ExecQueryRequest extends QueryRequest {
13
+ /** The query type. */
14
+ type: 'exec';
15
+ }
16
+ export interface JSONQueryRequest extends QueryRequest {
17
+ /** The query type. */
18
+ type: 'json';
19
+ }
20
+ export interface Connector {
21
+ /** Issue a query and return the result. */
22
+ query(query: ArrowQueryRequest): Promise<Table>;
23
+ query(query: ExecQueryRequest): Promise<void>;
24
+ query(query: JSONQueryRequest): Promise<Record<string, any>[]>;
25
+ }
@@ -1,17 +1,13 @@
1
- export function restConnector(uri?: string): {
2
- /**
3
- * Query the DuckDB server.
4
- * @param {object} query
5
- * @param {'exec' | 'arrow' | 'json' | 'create-bundle' | 'load-bundle'} [query.type] The query type.
6
- * @param {string} [query.sql] A SQL query string.
7
- * @param {string[]} [query.queries] The queries used to create a bundle.
8
- * @param {string} [query.name] The name of a bundle to create or load.
9
- * @returns the query result
10
- */
11
- query(query: {
12
- type?: "exec" | "arrow" | "json" | "create-bundle" | "load-bundle";
13
- sql?: string;
14
- queries?: string[];
15
- name?: string;
16
- }): Promise<any>;
17
- };
1
+ /**
2
+ * Connect to a DuckDB server over an HTTP REST interface.
3
+ * @param {object} [options] Connector options.
4
+ * @param {string} [options.uri] The URI for the DuckDB REST server.
5
+ * @param {ExtractionOptions} [options.ipc] Arrow IPC extraction options.
6
+ * @returns {Connector} A connector instance.
7
+ */
8
+ export function restConnector({ uri, ipc, }?: {
9
+ uri?: string;
10
+ ipc?: ExtractionOptions;
11
+ }): Connector;
12
+ import type { ExtractionOptions } from '@uwdata/flechette';
13
+ import type { Connector } from './Connector.js';
@@ -1,18 +1,100 @@
1
- export function socketConnector(uri?: string): {
2
- readonly connected: boolean;
1
+ /**
2
+ * Connect to a DuckDB server over a WebSocket interface.
3
+ * @param {object} [options] Connector options.
4
+ * @param {string} [options.uri] The URI for the DuckDB REST server.
5
+ * @param {ExtractionOptions} [options.ipc] Arrow IPC extraction options.
6
+ * @returns {SocketConnector} A connector instance.
7
+ */
8
+ export function socketConnector(options?: {
9
+ uri?: string;
10
+ ipc?: ExtractionOptions;
11
+ }): SocketConnector;
12
+ /**
13
+ * DuckDB socket connector.
14
+ * @implements {Connector}
15
+ */
16
+ export class SocketConnector implements Connector {
3
17
  /**
4
- * Query the DuckDB server.
5
- * @param {object} query
6
- * @param {'exec' | 'arrow' | 'json' | 'create-bundle' | 'load-bundle'} [query.type] The query type.
7
- * @param {string} [query.sql] A SQL query string.
8
- * @param {string[]} [query.queries] The queries used to create a bundle.
9
- * @param {string} [query.name] The name of a bundle to create or load.
10
- * @returns the query result
18
+ * @param {object} [options] Connector options.
19
+ * @param {string} [options.uri] The URI for the DuckDB REST server.
20
+ * @param {ExtractionOptions} [options.ipc] Arrow IPC extraction options.
11
21
  */
12
- query(query: {
13
- type?: "exec" | "arrow" | "json" | "create-bundle" | "load-bundle";
14
- sql?: string;
15
- queries?: string[];
16
- name?: string;
17
- }): Promise<any>;
18
- };
22
+ constructor({ uri, ipc, }?: {
23
+ uri?: string;
24
+ ipc?: ExtractionOptions;
25
+ });
26
+ _uri: string;
27
+ _queue: any[];
28
+ _connected: boolean;
29
+ _request: any;
30
+ _ws: WebSocket;
31
+ _events: {
32
+ open(): void;
33
+ close(): void;
34
+ error(event: any): void;
35
+ message({ data }: {
36
+ data: any;
37
+ }): void;
38
+ };
39
+ get connected(): boolean;
40
+ init(): void;
41
+ enqueue(query: any, resolve: any, reject: any): void;
42
+ next(): void;
43
+ /**
44
+ * @overload
45
+ * @param {ArrowQueryRequest} query
46
+ * @returns {Promise<Table>}
47
+ *
48
+ * @overload
49
+ * @param {ExecQueryRequest} query
50
+ * @returns {Promise<void>}
51
+ *
52
+ * @overload
53
+ * @param {JSONQueryRequest} query
54
+ * @returns {Promise<Record<string, any>[]>}
55
+ *
56
+ * @param {ArrowQueryRequest | ExecQueryRequest | JSONQueryRequest} query
57
+ * @returns {Promise<Table | void | Record<string, any>[]>}}
58
+ */
59
+ query(query: ArrowQueryRequest): Promise<Table>;
60
+ /**
61
+ * @overload
62
+ * @param {ArrowQueryRequest} query
63
+ * @returns {Promise<Table>}
64
+ *
65
+ * @overload
66
+ * @param {ExecQueryRequest} query
67
+ * @returns {Promise<void>}
68
+ *
69
+ * @overload
70
+ * @param {JSONQueryRequest} query
71
+ * @returns {Promise<Record<string, any>[]>}
72
+ *
73
+ * @param {ArrowQueryRequest | ExecQueryRequest | JSONQueryRequest} query
74
+ * @returns {Promise<Table | void | Record<string, any>[]>}}
75
+ */
76
+ query(query: ExecQueryRequest): Promise<void>;
77
+ /**
78
+ * @overload
79
+ * @param {ArrowQueryRequest} query
80
+ * @returns {Promise<Table>}
81
+ *
82
+ * @overload
83
+ * @param {ExecQueryRequest} query
84
+ * @returns {Promise<void>}
85
+ *
86
+ * @overload
87
+ * @param {JSONQueryRequest} query
88
+ * @returns {Promise<Record<string, any>[]>}
89
+ *
90
+ * @param {ArrowQueryRequest | ExecQueryRequest | JSONQueryRequest} query
91
+ * @returns {Promise<Table | void | Record<string, any>[]>}}
92
+ */
93
+ query(query: JSONQueryRequest): Promise<Record<string, any>[]>;
94
+ }
95
+ import type { ExtractionOptions } from '@uwdata/flechette';
96
+ import type { Connector } from './Connector.js';
97
+ import type { ArrowQueryRequest } from './Connector.js';
98
+ import type { Table } from '@uwdata/flechette';
99
+ import type { ExecQueryRequest } from './Connector.js';
100
+ import type { JSONQueryRequest } from './Connector.js';
@@ -1,16 +1,135 @@
1
- export function wasmConnector(options?: {}): {
2
- getDuckDB: () => Promise<duckdb.AsyncDuckDB>;
3
- getConnection: () => Promise<duckdb.AsyncDuckDBConnection>;
4
- /**
5
- * Query the DuckDB-WASM instance.
6
- * @param {object} query
7
- * @param {'exec' | 'arrow' | 'json'} [query.type] The query type.
8
- * @param {string} query.sql A SQL query string.
9
- * @returns the query result
10
- */
11
- query: (query: {
12
- type?: "exec" | "arrow" | "json";
13
- sql: string;
14
- }) => Promise<import("@uwdata/flechette").Table | Record<string, any>[]>;
1
+ /**
2
+ * @typedef {object} DuckDBWASMOptions
3
+ * @property {boolean} [log] Flag to enable logging.
4
+ */
5
+ /**
6
+ * @typedef {object} DuckDBWASMConnectorOptions
7
+ * @property {boolean} [log] Flag to enable logging.
8
+ * @property {ExtractionOptions} [ipc]
9
+ * Arrow IPC extraction options.
10
+ * @property {duckdb.AsyncDuckDB} [duckdb]
11
+ * Optional pre-existing DuckDB-WASM instance.
12
+ * @property {duckdb.AsyncDuckDBConnection} [connection]
13
+ * Optional pre-existing DuckDB-WASM connection.
14
+ */
15
+ /**
16
+ * Connect to a DuckDB-WASM instance.
17
+ * @param {DuckDBWASMConnectorOptions} [options] Connector options.
18
+ * @returns {DuckDBWASMConnector} A connector instance.
19
+ */
20
+ export function wasmConnector(options?: DuckDBWASMConnectorOptions): DuckDBWASMConnector;
21
+ /**
22
+ * DuckDB-WASM connector.
23
+ * @implements {Connector}
24
+ */
25
+ export class DuckDBWASMConnector implements Connector {
26
+ /**
27
+ * Create a new DuckDB-WASM connector instance.
28
+ * @param {DuckDBWASMConnectorOptions} [options]
29
+ */
30
+ constructor(options?: DuckDBWASMConnectorOptions);
31
+ /** @type {ExtractionOptions} */
32
+ _ipc: ExtractionOptions;
33
+ /** @type {DuckDBWASMOptions} */
34
+ _options: DuckDBWASMOptions;
35
+ /** @type {duckdb.AsyncDuckDB} */
36
+ _db: duckdb.AsyncDuckDB;
37
+ /** @type {duckdb.AsyncDuckDBConnection} */
38
+ _con: duckdb.AsyncDuckDBConnection;
39
+ /** @type {Promise<unknown>} */
40
+ _loadPromise: Promise<unknown>;
41
+ /**
42
+ * Get the backing DuckDB-WASM instance.
43
+ * Lazily initializes DuckDB-WASM if not already loaded.
44
+ * @returns {Promise<duckdb.AsyncDuckDB>} The DuckDB-WASM instance.
45
+ */
46
+ getDuckDB(): Promise<duckdb.AsyncDuckDB>;
47
+ /**
48
+ * Get the backing DuckDB-WASM connection.
49
+ * Lazily initializes DuckDB-WASM if not already loaded.
50
+ * @returns {Promise<duckdb.AsyncDuckDBConnection>} The DuckDB-WASM connection.
51
+ */
52
+ getConnection(): Promise<duckdb.AsyncDuckDBConnection>;
53
+ /**
54
+ * @overload
55
+ * @param {ArrowQueryRequest} query
56
+ * @returns {Promise<Table>}
57
+ *
58
+ * @overload
59
+ * @param {ExecQueryRequest} query
60
+ * @returns {Promise<void>}
61
+ *
62
+ * @overload
63
+ * @param {JSONQueryRequest} query
64
+ * @returns {Promise<Record<string, any>[]>}
65
+ *
66
+ * @param {ArrowQueryRequest | ExecQueryRequest | JSONQueryRequest} query
67
+ * @returns {Promise<Table | void | Record<string, any>[]>}}
68
+ */
69
+ query(query: ArrowQueryRequest): Promise<Table>;
70
+ /**
71
+ * @overload
72
+ * @param {ArrowQueryRequest} query
73
+ * @returns {Promise<Table>}
74
+ *
75
+ * @overload
76
+ * @param {ExecQueryRequest} query
77
+ * @returns {Promise<void>}
78
+ *
79
+ * @overload
80
+ * @param {JSONQueryRequest} query
81
+ * @returns {Promise<Record<string, any>[]>}
82
+ *
83
+ * @param {ArrowQueryRequest | ExecQueryRequest | JSONQueryRequest} query
84
+ * @returns {Promise<Table | void | Record<string, any>[]>}}
85
+ */
86
+ query(query: ExecQueryRequest): Promise<void>;
87
+ /**
88
+ * @overload
89
+ * @param {ArrowQueryRequest} query
90
+ * @returns {Promise<Table>}
91
+ *
92
+ * @overload
93
+ * @param {ExecQueryRequest} query
94
+ * @returns {Promise<void>}
95
+ *
96
+ * @overload
97
+ * @param {JSONQueryRequest} query
98
+ * @returns {Promise<Record<string, any>[]>}
99
+ *
100
+ * @param {ArrowQueryRequest | ExecQueryRequest | JSONQueryRequest} query
101
+ * @returns {Promise<Table | void | Record<string, any>[]>}}
102
+ */
103
+ query(query: JSONQueryRequest): Promise<Record<string, any>[]>;
104
+ }
105
+ export type DuckDBWASMOptions = {
106
+ /**
107
+ * Flag to enable logging.
108
+ */
109
+ log?: boolean;
110
+ };
111
+ export type DuckDBWASMConnectorOptions = {
112
+ /**
113
+ * Flag to enable logging.
114
+ */
115
+ log?: boolean;
116
+ /**
117
+ * Arrow IPC extraction options.
118
+ */
119
+ ipc?: ExtractionOptions;
120
+ /**
121
+ * Optional pre-existing DuckDB-WASM instance.
122
+ */
123
+ duckdb?: duckdb.AsyncDuckDB;
124
+ /**
125
+ * Optional pre-existing DuckDB-WASM connection.
126
+ */
127
+ connection?: duckdb.AsyncDuckDBConnection;
15
128
  };
129
+ import type { Connector } from './Connector.js';
130
+ import type { ExtractionOptions } from '@uwdata/flechette';
16
131
  import * as duckdb from '@duckdb/duckdb-wasm';
132
+ import type { ArrowQueryRequest } from './Connector.js';
133
+ import type { Table } from '@uwdata/flechette';
134
+ import type { ExecQueryRequest } from './Connector.js';
135
+ import type { JSONQueryRequest } from './Connector.js';
@@ -1,3 +1,4 @@
1
1
  export * from './index.js';
2
2
  export * from './types.js';
3
+ export * from './connectors/Connector.js';
3
4
  export * from './util/selection-types.js';
@@ -176,5 +176,5 @@ import type { MosaicClient } from '../MosaicClient.js';
176
176
  import type { Coordinator } from '../Coordinator.js';
177
177
  import type { Selection } from '../Selection.js';
178
178
  import type { SelectionClause } from '../util/selection-types.js';
179
- import { SelectQuery } from '@uwdata/mosaic-sql';
179
+ import type { SelectQuery } from '@uwdata/mosaic-sql';
180
180
  import type { ExprNode } from '@uwdata/mosaic-sql';
@@ -10,5 +10,5 @@ export function preaggColumns(client: MosaicClient): {
10
10
  preagg: Record<string, ExprNode>;
11
11
  output: Record<string, ExprNode>;
12
12
  };
13
- import { MosaicClient } from '../MosaicClient.js';
14
- import { ExprNode } from '@uwdata/mosaic-sql';
13
+ import type { MosaicClient } from '../MosaicClient.js';
14
+ import type { ExprNode } from '@uwdata/mosaic-sql';
@@ -9,5 +9,5 @@
9
9
  * sufficient statistics to service updates.
10
10
  */
11
11
  export function sufficientStatistics(node: AggregateNode, preagg: Record<string, ExprNode>, avg: any): ExprNode;
12
- import { AggregateNode } from '@uwdata/mosaic-sql';
13
- import { ExprNode } from '@uwdata/mosaic-sql';
12
+ import type { AggregateNode } from '@uwdata/mosaic-sql';
13
+ import type { ExprNode } from '@uwdata/mosaic-sql';
@@ -40,3 +40,24 @@ export interface Activatable {
40
40
  */
41
41
  activate(): void;
42
42
  }
43
+ /**
44
+ * Interface for cache implementations.
45
+ */
46
+ export interface Cache {
47
+ get(key: string): any;
48
+ set(key: string, value: any): any;
49
+ clear(): void;
50
+ }
51
+ /**
52
+ * Interface for logger implementations
53
+ */
54
+ export interface Logger {
55
+ debug(...args: any[]): void;
56
+ info(...args: any[]): void;
57
+ log(...args: any[]): void;
58
+ warn(...args: any[]): void;
59
+ error(...args: any[]): void;
60
+ group(label?: any): void;
61
+ groupCollapsed(label?: any): void;
62
+ groupEnd(): void;
63
+ }
@@ -1,13 +1,17 @@
1
+ /**
2
+ * Create a new cache that ignores all values.
3
+ * @returns {Cache}
4
+ */
5
+ export function voidCache(): Cache;
6
+ /**
7
+ * Create a new cache that uses an LRU eviction policy.
8
+ * @param {object} [options] Cache options.
9
+ * @param {number} [options.max] Maximum number of cache entries.
10
+ * @param {number} [options.ttl] Time-to-live for cache entries.
11
+ * @returns {Cache}
12
+ */
1
13
  export function lruCache({ max, ttl }?: {
2
14
  max?: number;
3
15
  ttl?: number;
4
- }): {
5
- get(key: any): any;
6
- set(key: any, value: any): any;
7
- clear(): void;
8
- };
9
- export function voidCache(): {
10
- get: () => any;
11
- set: (key: any, value: any) => any;
12
- clear: () => void;
13
- };
16
+ }): Cache;
17
+ import type { Cache } from '../types.js';
@@ -1,7 +1,12 @@
1
1
  /**
2
- * Decode Arrow IPC bytes to a table instance, with an option to map date and
3
- * timestamp values to JS Date objects.
2
+ * Decode Arrow IPC bytes to a table instance.
3
+ * The default options map date and timestamp values to JS Date objects.
4
4
  * @param {ArrayBuffer | Uint8Array} data Arrow IPC bytes.
5
- * @returns {import('@uwdata/flechette').Table} A table instance.
5
+ * @param {ExtractionOptions} [options] Arrow IPC extraction options.
6
+ * If unspecified, the default options will extract date and timestamp
7
+ * values to JS Date objects.
8
+ * @returns {Table} A table instance.
6
9
  */
7
- export function decodeIPC(data: ArrayBuffer | Uint8Array): import("@uwdata/flechette").Table;
10
+ export function decodeIPC(data: ArrayBuffer | Uint8Array, options?: ExtractionOptions): Table;
11
+ import type { ExtractionOptions } from '@uwdata/flechette';
12
+ import type { Table } from '@uwdata/flechette';