@uwdata/mosaic-core 0.14.1 → 0.16.1

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 (40) hide show
  1. package/dist/types/Coordinator.d.ts +37 -42
  2. package/dist/types/MosaicClient.d.ts +76 -44
  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/make-client.d.ts +51 -21
  12. package/dist/types/preagg/PreAggregator.d.ts +18 -16
  13. package/dist/types/preagg/preagg-columns.d.ts +2 -2
  14. package/dist/types/preagg/sufficient-statistics.d.ts +2 -2
  15. package/dist/types/types.d.ts +21 -0
  16. package/dist/types/util/cache.d.ts +14 -10
  17. package/dist/types/util/decode-ipc.d.ts +9 -4
  18. package/dist/types/util/void-logger.d.ts +3 -0
  19. package/package.json +4 -4
  20. package/src/Coordinator.js +36 -44
  21. package/src/MosaicClient.js +110 -46
  22. package/src/QueryConsolidator.js +2 -1
  23. package/src/QueryManager.js +31 -0
  24. package/src/Selection.js +4 -2
  25. package/src/SelectionClause.js +5 -2
  26. package/src/connectors/Connector.ts +30 -0
  27. package/src/connectors/rest.js +14 -12
  28. package/src/connectors/socket.js +112 -77
  29. package/src/connectors/wasm.js +118 -55
  30. package/src/index-types.ts +1 -0
  31. package/src/make-client.js +68 -31
  32. package/src/preagg/PreAggregator.js +20 -17
  33. package/src/preagg/preagg-columns.js +5 -2
  34. package/src/preagg/sufficient-statistics.js +2 -1
  35. package/src/types.ts +23 -0
  36. package/src/util/cache.js +20 -5
  37. package/src/util/decode-ipc.js +9 -5
  38. package/src/util/field-info.js +2 -1
  39. package/src/util/js-type.js +3 -1
  40. package/src/util/void-logger.js +4 -1
@@ -8,30 +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 {import('./preagg/PreAggregator.js').PreAggregateOptions} [options.preagg]
18
- * Options for the Pre-aggregator.
19
11
  */
20
12
  export class Coordinator {
21
- constructor(db?: {
22
- readonly connected: boolean;
23
- query(query: {
24
- type?: "exec" | "arrow" | "json" | "create-bundle" | "load-bundle";
25
- sql?: string;
26
- queries?: string[];
27
- name?: string;
28
- }): Promise<any>;
29
- }, { logger, manager, cache, consolidate, preagg }?: {
30
- 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;
31
24
  manager?: QueryManager;
32
25
  cache?: boolean;
33
26
  consolidate?: boolean;
34
- preagg?: {};
27
+ preagg?: PreAggregateOptions;
35
28
  });
36
29
  /** @type {QueryManager} */
37
30
  manager: QueryManager;
@@ -50,17 +43,17 @@ export class Coordinator {
50
43
  clients: Set<any>;
51
44
  /**
52
45
  * Get or set the database connector.
53
- * @param {*} [db] The database connector to use.
54
- * @returns The current database connector.
46
+ * @param {Connector} [db] The database connector to use.
47
+ * @returns {Connector} The current database connector.
55
48
  */
56
- databaseConnector(db?: any): any;
49
+ databaseConnector(db?: Connector): Connector;
57
50
  /**
58
51
  * Get or set the logger.
59
- * @param {*} logger The logger to use.
60
- * @returns The current logger
52
+ * @param {Logger} [logger] The logger to use.
53
+ * @returns {Logger} The current logger
61
54
  */
62
- logger(logger: any, ...args: any[]): any;
63
- _logger: any;
55
+ logger(logger?: Logger, ...args: any[]): Logger;
56
+ _logger: Logger;
64
57
  /**
65
58
  * Cancel previosuly submitted query requests. These queries will be
66
59
  * canceled if they are queued but have not yet been submitted.
@@ -70,22 +63,21 @@ export class Coordinator {
70
63
  cancel(requests: QueryResult[]): void;
71
64
  /**
72
65
  * Issue a query for which no result (return value) is needed.
73
- * @param { import('./types.js').QueryType[] |
74
- * import('./types.js').QueryType} query The query or an array of queries.
66
+ * @param {QueryType[] | QueryType} query The query or an array of queries.
75
67
  * Each query should be either a Query builder object or a SQL string.
76
68
  * @param {object} [options] An options object.
77
69
  * @param {number} [options.priority] The query priority, defaults to
78
70
  * `Priority.Normal`.
79
71
  * @returns {QueryResult} A query result promise.
80
72
  */
81
- exec(query: import("./types.js").QueryType[] | import("./types.js").QueryType, { priority }?: {
73
+ exec(query: QueryType[] | QueryType, { priority }?: {
82
74
  priority?: number;
83
75
  }): QueryResult;
84
76
  /**
85
77
  * Issue a query to the backing database. The submitted query may be
86
78
  * consolidate with other queries and its results may be cached.
87
- * @param {import('./types.js').QueryType} query The query as either a Query
88
- * builder object or a SQL string.
79
+ * @param {QueryType} query The query as either a Query builder objec
80
+ * or a SQL string.
89
81
  * @param {object} [options] An options object.
90
82
  * @param {'arrow' | 'json'} [options.type] The query result format type.
91
83
  * @param {boolean} [options.cache=true] If true, cache the query result
@@ -96,7 +88,7 @@ export class Coordinator {
96
88
  * `Priority.Normal`.
97
89
  * @returns {QueryResult} A query result promise.
98
90
  */
99
- query(query: import("./types.js").QueryType, { type, cache, priority, ...options }?: {
91
+ query(query: QueryType, { type, cache, priority, ...options }?: {
100
92
  type?: "arrow" | "json";
101
93
  cache?: boolean;
102
94
  persist?: boolean;
@@ -105,13 +97,13 @@ export class Coordinator {
105
97
  /**
106
98
  * Issue a query to prefetch data for later use. The query result is cached
107
99
  * for efficient future access.
108
- * @param {import('./types.js').QueryType} query The query as either a Query
109
- * builder object or a SQL string.
100
+ * @param {QueryType} query The query as either a Query builder object
101
+ * or a SQL string.
110
102
  * @param {object} [options] An options object.
111
103
  * @param {'arrow' | 'json'} [options.type] The query result format type.
112
104
  * @returns {QueryResult} A query result promise.
113
105
  */
114
- prefetch(query: import("./types.js").QueryType, options?: {
106
+ prefetch(query: QueryType, options?: {
115
107
  type?: "arrow" | "json";
116
108
  }): QueryResult;
117
109
  /**
@@ -138,25 +130,24 @@ export class Coordinator {
138
130
  * Update client data by submitting the given query and returning the
139
131
  * data (or error) to the client.
140
132
  * @param {MosaicClient} client A Mosaic client.
141
- * @param {import('./types.js').QueryType} query The data query.
133
+ * @param {QueryType} query The data query.
142
134
  * @param {number} [priority] The query priority.
143
135
  * @returns {Promise} A Promise that resolves upon completion of the update.
144
136
  */
145
- updateClient(client: MosaicClient, query: import("./types.js").QueryType, priority?: number): Promise<any>;
137
+ updateClient(client: MosaicClient, query: QueryType, priority?: number): Promise<any>;
146
138
  /**
147
139
  * Issue a query request for a client. If the query is null or undefined,
148
140
  * the client is simply updated. Otherwise `updateClient` is called. As a
149
141
  * side effect, this method clears the current preaggregator state.
150
142
  * @param {MosaicClient} client The client to update.
151
- * @param {import('./types.js').QueryType | null} [query] The query to issue.
143
+ * @param {QueryType | null} [query] The query to issue.
152
144
  */
153
- requestQuery(client: MosaicClient, query?: import("./types.js").QueryType | null): Promise<any>;
145
+ requestQuery(client: MosaicClient, query?: QueryType | null): Promise<any>;
154
146
  /**
155
147
  * Connect a client to the coordinator.
156
148
  * @param {MosaicClient} client The Mosaic client to connect.
157
149
  */
158
150
  connect(client: MosaicClient): void;
159
- initializeClient(client: any): Promise<any>;
160
151
  /**
161
152
  * Disconnect a client from the coordinator.
162
153
  * @param {MosaicClient} client The Mosaic client to disconnect.
@@ -165,5 +156,9 @@ export class Coordinator {
165
156
  }
166
157
  import { QueryManager } from './QueryManager.js';
167
158
  import { PreAggregator } from './preagg/PreAggregator.js';
168
- import { QueryResult } from './util/query-result.js';
169
- import { MosaicClient } from './MosaicClient.js';
159
+ import type { Connector } from './connectors/Connector.js';
160
+ import type { Logger } from './types.js';
161
+ import type { QueryResult } from './util/query-result.js';
162
+ import type { QueryType } from './types.js';
163
+ import type { MosaicClient } from './MosaicClient.js';
164
+ import type { PreAggregateOptions } from './preagg/PreAggregator.js';
@@ -1,58 +1,75 @@
1
1
  /**
2
- * Base class for Mosaic clients.
2
+ * A Mosaic client is a data consumer that indicates its data needs to a
3
+ * Mosaic coordinator via the query method. The coordinator is responsible
4
+ * for issuing queries and returning results to the client.
5
+ *
6
+ * The client life-cycle consists of connection to a coordinator,
7
+ * initialization (potentially involving queries for data schema and summary
8
+ * statistic information), and then interactive queries that may be driven by
9
+ * an associated selection. When no longer needed, a client should be
10
+ * disconnected from the coordinator.
11
+ *
12
+ * When enabled, a client will initialize and respond to query update requests.
13
+ * If disabled, the client will delay initialization and not respond to queries
14
+ * until enabled again. Disabling a client can improve system performance when
15
+ * associated interface elements are offscreen or disabled.
3
16
  */
4
17
  export class MosaicClient {
5
18
  /**
6
- * Constructor.
7
- * @param {*} filterSelection An optional selection to interactively filter
8
- * this client's data. If provided, a coordinator will re-query and update
9
- * the client when the selection updates.
19
+ * Create a new client instance.
20
+ * @param {Selection} [filterSelection] An optional selection to
21
+ * interactively filter this client's data. If provided, a coordinator
22
+ * will re-query and update the client when the selection updates.
10
23
  */
11
- constructor(filterSelection: any);
12
- /** @type {Selection} */
13
- _filterBy: Selection;
24
+ constructor(filterSelection?: Selection);
25
+ /** @type {Selection | undefined} */
26
+ _filterBy: Selection | undefined;
14
27
  _requestUpdate: (event: any) => void;
15
- /** @type {Coordinator} */
16
- _coordinator: Coordinator;
28
+ /** @type {Coordinator | null} */
29
+ _coordinator: Coordinator | null;
17
30
  /** @type {Promise<any>} */
18
31
  _pending: Promise<any>;
32
+ /** @type {boolean} */
33
+ _enabled: boolean;
34
+ /** @type {boolean} */
35
+ _initialized: boolean;
36
+ /** @type {Query | boolean | null} */
37
+ _request: Query | boolean | null;
19
38
  /**
20
39
  * Set this client's connected coordinator.
21
40
  */
22
- set coordinator(coordinator: Coordinator);
41
+ set coordinator(coordinator: Coordinator | null);
23
42
  /**
24
- * Return this client's connected coordinator.
43
+ * @returns {Coordinator | null} this client's connected coordinator.
25
44
  */
26
- get coordinator(): Coordinator;
45
+ get coordinator(): Coordinator | null;
46
+ /**
47
+ * Set this client's enabled state;
48
+ */
49
+ set enabled(state: boolean);
50
+ /**
51
+ * Return this client's enabled state.
52
+ */
53
+ get enabled(): boolean;
27
54
  /**
28
55
  * Return a Promise that resolves once the client has updated.
29
56
  */
30
57
  get pending(): Promise<any>;
31
58
  /**
32
- * Return this client's filter selection.
59
+ * @returns {Selection | undefined} this client's filter selection.
33
60
  */
34
- get filterBy(): Selection;
61
+ get filterBy(): Selection | undefined;
35
62
  /**
36
63
  * Return a boolean indicating if the client query can be sped up with
37
- * materialized views of pre-aggregated data. Should return true if changes to
38
- * the filterBy selection does not change the groupby domain of the client
64
+ * materialized views of pre-aggregated data. Should return true if changes
65
+ * to the filterBy selection do not change the groupby domain of the client
39
66
  * query.
40
67
  */
41
68
  get filterStable(): boolean;
42
69
  /**
43
- * Return an array of fields queried by this client.
44
- * @returns {import('./types.js').FieldInfoRequest[] | null}
45
- * The fields to retrieve info for.
46
- */
47
- fields(): import("./types.js").FieldInfoRequest[] | null;
48
- /**
49
- * Called by the coordinator to set the field info for this client.
50
- * @param {import('./types.js').FieldInfo[]} info The field info result.
51
- * @returns {this}
52
- */
53
- fieldInfo(info: import("./types.js").FieldInfo[]): this;
54
- /**
55
- * Prepare the client before the query() method is called.
70
+ * Prepare the client before the `query()` method is called. Subclasses
71
+ * should override this method as needed, potentially issuing one or more
72
+ * queries to gather data or metadata needed prior to `query` calls.
56
73
  */
57
74
  prepare(): Promise<void>;
58
75
  /**
@@ -80,26 +97,40 @@ export class MosaicClient {
80
97
  queryError(error: any): this;
81
98
  /**
82
99
  * Request the coordinator to execute a query for this client.
83
- * If an explicit query is not provided, the client query method will
84
- * be called, filtered by the current filterBy selection. This method
85
- * has no effect if the client is not registered with a coordinator.
100
+ * If an explicit query is not provided, the client `query` method will
101
+ * be called, filtered by the current `filterBy` selection. This method has
102
+ * no effect if the client is not connected to a coordinator. If the client
103
+ * is connected by currently disabled, the request will be serviced if the
104
+ * client is later enabled.
105
+ * @param {Query} [query] The query to request. If unspecified, the query
106
+ * will be determind by the client's `query` method and the current
107
+ * `filterBy` selection state.
86
108
  * @returns {Promise}
87
109
  */
88
- requestQuery(query: any): Promise<any>;
110
+ requestQuery(query?: Query): Promise<any>;
89
111
  /**
90
112
  * Request that the coordinator perform a throttled update of this client
91
- * using the default query. Unlike requestQuery, for which every call will
92
- * result in an executed query, multiple calls to requestUpdate may be
93
- * consolidated into a single update.
113
+ * using the default query. Unlike requestQuery, for which every call results
114
+ * in an executed query, multiple calls to requestUpdate may be consolidated
115
+ * into a single update. This method has no effect if the client is not
116
+ * connected to a coordinator. If the client is connected but currently
117
+ * disabled, the request will be serviced if the client is later enabled.
94
118
  */
95
119
  requestUpdate(): void;
96
120
  /**
97
- * Reset this client, initiating new field info, call the prepare method,
98
- * and query requests. This method has no effect if the client is not
99
- * registered with a coordinator.
100
- * @returns {Promise}
121
+ * Reset this client, calling the prepare method and query requests. This
122
+ * method has no effect if the client is not registered with a coordinator.
123
+ */
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.
101
132
  */
102
- initialize(): Promise<any>;
133
+ destroy(): void;
103
134
  /**
104
135
  * Requests a client update, for example to (re-)render an interface
105
136
  * component.
@@ -107,5 +138,6 @@ export class MosaicClient {
107
138
  */
108
139
  update(): this | Promise<any>;
109
140
  }
110
- import { Selection } from './Selection.js';
111
- import { Coordinator } from './Coordinator.js';
141
+ import type { Selection } from './Selection.js';
142
+ import type { Coordinator } from './Coordinator.js';
143
+ import type { Query } from '@uwdata/mosaic-sql';
@@ -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';