@uwdata/mosaic-core 0.16.1 → 0.17.0

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 (41) hide show
  1. package/package.json +7 -11
  2. package/src/Coordinator.js +0 -24
  3. package/src/index-types.ts +1 -0
  4. package/src/preagg/sufficient-statistics.js +1 -0
  5. package/tsconfig.json +6 -8
  6. package/LICENSE +0 -47
  7. package/dist/types/Coordinator.d.ts +0 -164
  8. package/dist/types/MosaicClient.d.ts +0 -143
  9. package/dist/types/Param.d.ts +0 -47
  10. package/dist/types/QueryConsolidator.d.ts +0 -9
  11. package/dist/types/QueryManager.d.ts +0 -91
  12. package/dist/types/Selection.d.ts +0 -235
  13. package/dist/types/SelectionClause.d.ts +0 -105
  14. package/dist/types/connectors/Connector.d.ts +0 -25
  15. package/dist/types/connectors/rest.d.ts +0 -13
  16. package/dist/types/connectors/socket.d.ts +0 -100
  17. package/dist/types/connectors/wasm.d.ts +0 -135
  18. package/dist/types/index-types.d.ts +0 -4
  19. package/dist/types/index.d.ts +0 -19
  20. package/dist/types/make-client.d.ts +0 -78
  21. package/dist/types/preagg/PreAggregator.d.ts +0 -180
  22. package/dist/types/preagg/preagg-columns.d.ts +0 -14
  23. package/dist/types/preagg/sufficient-statistics.d.ts +0 -13
  24. package/dist/types/types.d.ts +0 -63
  25. package/dist/types/util/AsyncDispatch.d.ts +0 -100
  26. package/dist/types/util/cache.d.ts +0 -17
  27. package/dist/types/util/decode-ipc.d.ts +0 -12
  28. package/dist/types/util/distinct.d.ts +0 -2
  29. package/dist/types/util/field-info.d.ts +0 -23
  30. package/dist/types/util/hash.d.ts +0 -1
  31. package/dist/types/util/is-activatable.d.ts +0 -6
  32. package/dist/types/util/is-arrow-table.d.ts +0 -8
  33. package/dist/types/util/js-type.d.ts +0 -7
  34. package/dist/types/util/priority-queue.d.ts +0 -37
  35. package/dist/types/util/query-result.d.ts +0 -44
  36. package/dist/types/util/selection-types.d.ts +0 -114
  37. package/dist/types/util/synchronizer.d.ts +0 -29
  38. package/dist/types/util/throttle.d.ts +0 -13
  39. package/dist/types/util/to-data-columns.d.ts +0 -29
  40. package/dist/types/util/void-logger.d.ts +0 -10
  41. package/jsconfig.json +0 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uwdata/mosaic-core",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "description": "Scalable and extensible linked data views.",
5
5
  "keywords": [
6
6
  "mosaic",
@@ -13,7 +13,7 @@
13
13
  "author": "Jeffrey Heer (https://idl.uw.edu)",
14
14
  "type": "module",
15
15
  "exports": {
16
- "types": "./dist/types/index-types.d.ts",
16
+ "types": "./dist/src/index-types.d.ts",
17
17
  "default": "./src/index.js"
18
18
  },
19
19
  "repository": {
@@ -22,20 +22,16 @@
22
22
  },
23
23
  "scripts": {
24
24
  "prebuild": "rimraf dist && mkdir dist",
25
- "build": "npm run types",
26
- "types": "tsc",
27
25
  "lint": "eslint src test",
28
- "test": "vitest run && npm run tsc",
29
- "tsc": "tsc -p jsconfig.json",
30
- "prepublishOnly": "npm run test && npm run lint && npm run build"
26
+ "test": "vitest run && tsc",
27
+ "prepublishOnly": "npm run test && npm run lint && tsc"
31
28
  },
32
29
  "dependencies": {
33
30
  "@duckdb/duckdb-wasm": "^1.29.0",
34
31
  "@uwdata/flechette": "^2.0.0",
35
- "@uwdata/mosaic-sql": "^0.16.1"
32
+ "@uwdata/mosaic-sql": "^0.17.0"
36
33
  },
37
34
  "devDependencies": {
38
- "@uwdata/mosaic-duckdb": "^0.16.1"
39
- },
40
- "gitHead": "e12af9927b0a35a0e3194850ef569d0d24a022ce"
35
+ "@uwdata/mosaic-duckdb": "^0.17.0"
36
+ }
41
37
  }
@@ -164,30 +164,6 @@ export class Coordinator {
164
164
  return this.query(query, { ...options, cache: true, priority: Priority.Low });
165
165
  }
166
166
 
167
- /**
168
- * Create a bundle of queries that can be loaded into the cache.
169
- *
170
- * @param {string} name The name of the bundle.
171
- * @param {[string | {sql: string}, {alias: string}]} queries The queries to save into the bundle.
172
- * @param {number} priority Request priority.
173
- * @returns {QueryResult} A query result promise.
174
- */
175
- createBundle(name, queries, priority = Priority.Low) {
176
- const options = { name, queries: queries.map(q => typeof q == 'string' ? {sql: q} : q) };
177
- return this.manager.request({ type: 'create-bundle', options }, priority);
178
- }
179
-
180
- /**
181
- * Load a bundle into the cache.
182
- * @param {string} name The name of the bundle.
183
- * @param {number} priority Request priority.
184
- * @returns {QueryResult} A query result promise.
185
- */
186
- loadBundle(name, priority = Priority.High) {
187
- const options = { name };
188
- return this.manager.request({ type: 'load-bundle', options }, priority);
189
- }
190
-
191
167
  // -- Client Management ----
192
168
 
193
169
  /**
@@ -2,3 +2,4 @@ export * from './index.js';
2
2
  export * from './types.js';
3
3
  export * from './connectors/Connector.js';
4
4
  export * from './util/selection-types.js';
5
+ export {QueryResult} from './util/query-result.js';
@@ -15,6 +15,7 @@ import { fnv_hash } from '../util/hash.js';
15
15
  export function sufficientStatistics(node, preagg, avg) {
16
16
  switch (node.name) {
17
17
  case 'count':
18
+ case 'count_star':
18
19
  return sumCountExpr(preagg, node);
19
20
  case 'sum':
20
21
  return sumExpr(preagg, node);
package/tsconfig.json CHANGED
@@ -1,11 +1,9 @@
1
1
  {
2
- "include": ["src/**/*.js", "src/**/*.ts"],
2
+ "extends": "../../tsconfig.base.json",
3
+ "include": ["src/**/*"],
3
4
  "compilerOptions": {
4
- "allowJs": true,
5
- "declaration": true,
6
5
  "emitDeclarationOnly": true,
7
- "outDir": "dist/types",
8
- "module": "node16",
9
- "skipLibCheck": true
10
- }
11
- }
6
+ "outDir": "dist"
7
+ },
8
+ "references": [{ "path": "../sql" }]
9
+ }
package/LICENSE DELETED
@@ -1,47 +0,0 @@
1
- BSD 3-Clause License
2
-
3
- Copyright (c) 2023, UW Interactive Data Lab
4
-
5
- Redistribution and use in source and binary forms, with or without
6
- modification, are permitted provided that the following conditions are met:
7
-
8
- 1. Redistributions of source code must retain the above copyright notice, this
9
- list of conditions and the following disclaimer.
10
-
11
- 2. Redistributions in binary form must reproduce the above copyright notice,
12
- this list of conditions and the following disclaimer in the documentation
13
- and/or other materials provided with the distribution.
14
-
15
- 3. Neither the name of the copyright holder nor the names of its
16
- contributors may be used to endorse or promote products derived from
17
- this software without specific prior written permission.
18
-
19
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
-
30
- ---
31
-
32
- Portions of this software are derived from Observable Plot, which is released
33
- under the ISC license.
34
-
35
- Copyright 2020-2023 Observable, Inc.
36
-
37
- Permission to use, copy, modify, and/or distribute this software for any purpose
38
- with or without fee is hereby granted, provided that the above copyright notice
39
- and this permission notice appear in all copies.
40
-
41
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
42
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
43
- FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
44
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
45
- OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
46
- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
47
- THIS SOFTWARE.
@@ -1,164 +0,0 @@
1
- /**
2
- * Set or retrieve the coordinator instance.
3
- * @param {Coordinator} [instance] the coordinator instance to set
4
- * @returns {Coordinator} the coordinator instance
5
- */
6
- export function coordinator(instance?: Coordinator): Coordinator;
7
- /**
8
- * A Mosaic Coordinator manages all database communication for clients and
9
- * handles selection updates. The Coordinator also performs optimizations
10
- * including query caching, consolidation, and pre-aggregation.
11
- */
12
- export class Coordinator {
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;
24
- manager?: QueryManager;
25
- cache?: boolean;
26
- consolidate?: boolean;
27
- preagg?: PreAggregateOptions;
28
- });
29
- /** @type {QueryManager} */
30
- manager: QueryManager;
31
- preaggregator: PreAggregator;
32
- /**
33
- * Clear the coordinator state.
34
- * @param {object} [options] Options object.
35
- * @param {boolean} [options.clients=true] If true, disconnect all clients.
36
- * @param {boolean} [options.cache=true] If true, clear the query cache.
37
- */
38
- clear({ clients, cache }?: {
39
- clients?: boolean;
40
- cache?: boolean;
41
- }): void;
42
- filterGroups: Map<any, any>;
43
- clients: Set<any>;
44
- /**
45
- * Get or set the database connector.
46
- * @param {Connector} [db] The database connector to use.
47
- * @returns {Connector} The current database connector.
48
- */
49
- databaseConnector(db?: Connector): Connector;
50
- /**
51
- * Get or set the logger.
52
- * @param {Logger} [logger] The logger to use.
53
- * @returns {Logger} The current logger
54
- */
55
- logger(logger?: Logger, ...args: any[]): Logger;
56
- _logger: Logger;
57
- /**
58
- * Cancel previosuly submitted query requests. These queries will be
59
- * canceled if they are queued but have not yet been submitted.
60
- * @param {QueryResult[]} requests An array
61
- * of query result objects, such as those returned by the `query` method.
62
- */
63
- cancel(requests: QueryResult[]): void;
64
- /**
65
- * Issue a query for which no result (return value) is needed.
66
- * @param {QueryType[] | QueryType} query The query or an array of queries.
67
- * Each query should be either a Query builder object or a SQL string.
68
- * @param {object} [options] An options object.
69
- * @param {number} [options.priority] The query priority, defaults to
70
- * `Priority.Normal`.
71
- * @returns {QueryResult} A query result promise.
72
- */
73
- exec(query: QueryType[] | QueryType, { priority }?: {
74
- priority?: number;
75
- }): QueryResult;
76
- /**
77
- * Issue a query to the backing database. The submitted query may be
78
- * consolidate with other queries and its results may be cached.
79
- * @param {QueryType} query The query as either a Query builder objec
80
- * or a SQL string.
81
- * @param {object} [options] An options object.
82
- * @param {'arrow' | 'json'} [options.type] The query result format type.
83
- * @param {boolean} [options.cache=true] If true, cache the query result
84
- * client-side within the QueryManager.
85
- * @param {boolean} [options.persist] If true, request the database
86
- * server to persist a cached query server-side.
87
- * @param {number} [options.priority] The query priority, defaults to
88
- * `Priority.Normal`.
89
- * @returns {QueryResult} A query result promise.
90
- */
91
- query(query: QueryType, { type, cache, priority, ...options }?: {
92
- type?: "arrow" | "json";
93
- cache?: boolean;
94
- persist?: boolean;
95
- priority?: number;
96
- }): QueryResult;
97
- /**
98
- * Issue a query to prefetch data for later use. The query result is cached
99
- * for efficient future access.
100
- * @param {QueryType} query The query as either a Query builder object
101
- * or a SQL string.
102
- * @param {object} [options] An options object.
103
- * @param {'arrow' | 'json'} [options.type] The query result format type.
104
- * @returns {QueryResult} A query result promise.
105
- */
106
- prefetch(query: QueryType, options?: {
107
- type?: "arrow" | "json";
108
- }): QueryResult;
109
- /**
110
- * Create a bundle of queries that can be loaded into the cache.
111
- *
112
- * @param {string} name The name of the bundle.
113
- * @param {[string | {sql: string}, {alias: string}]} queries The queries to save into the bundle.
114
- * @param {number} priority Request priority.
115
- * @returns {QueryResult} A query result promise.
116
- */
117
- createBundle(name: string, queries: [string | {
118
- sql: string;
119
- }, {
120
- alias: string;
121
- }], priority?: number): QueryResult;
122
- /**
123
- * Load a bundle into the cache.
124
- * @param {string} name The name of the bundle.
125
- * @param {number} priority Request priority.
126
- * @returns {QueryResult} A query result promise.
127
- */
128
- loadBundle(name: string, priority?: number): QueryResult;
129
- /**
130
- * Update client data by submitting the given query and returning the
131
- * data (or error) to the client.
132
- * @param {MosaicClient} client A Mosaic client.
133
- * @param {QueryType} query The data query.
134
- * @param {number} [priority] The query priority.
135
- * @returns {Promise} A Promise that resolves upon completion of the update.
136
- */
137
- updateClient(client: MosaicClient, query: QueryType, priority?: number): Promise<any>;
138
- /**
139
- * Issue a query request for a client. If the query is null or undefined,
140
- * the client is simply updated. Otherwise `updateClient` is called. As a
141
- * side effect, this method clears the current preaggregator state.
142
- * @param {MosaicClient} client The client to update.
143
- * @param {QueryType | null} [query] The query to issue.
144
- */
145
- requestQuery(client: MosaicClient, query?: QueryType | null): Promise<any>;
146
- /**
147
- * Connect a client to the coordinator.
148
- * @param {MosaicClient} client The Mosaic client to connect.
149
- */
150
- connect(client: MosaicClient): void;
151
- /**
152
- * Disconnect a client from the coordinator.
153
- * @param {MosaicClient} client The Mosaic client to disconnect.
154
- */
155
- disconnect(client: MosaicClient): void;
156
- }
157
- import { QueryManager } from './QueryManager.js';
158
- import { PreAggregator } from './preagg/PreAggregator.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,143 +0,0 @@
1
- /**
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.
16
- */
17
- export class MosaicClient {
18
- /**
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.
23
- */
24
- constructor(filterSelection?: Selection);
25
- /** @type {Selection | undefined} */
26
- _filterBy: Selection | undefined;
27
- _requestUpdate: (event: any) => void;
28
- /** @type {Coordinator | null} */
29
- _coordinator: Coordinator | null;
30
- /** @type {Promise<any>} */
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;
38
- /**
39
- * Set this client's connected coordinator.
40
- */
41
- set coordinator(coordinator: Coordinator | null);
42
- /**
43
- * @returns {Coordinator | null} this client's connected coordinator.
44
- */
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;
54
- /**
55
- * Return a Promise that resolves once the client has updated.
56
- */
57
- get pending(): Promise<any>;
58
- /**
59
- * @returns {Selection | undefined} this client's filter selection.
60
- */
61
- get filterBy(): Selection | undefined;
62
- /**
63
- * Return a boolean indicating if the client query can be sped up with
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
66
- * query.
67
- */
68
- get filterStable(): boolean;
69
- /**
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.
73
- */
74
- prepare(): Promise<void>;
75
- /**
76
- * Return a query specifying the data needed by this client.
77
- * @param {*} [filter] The filtering criteria to apply in the query.
78
- * @returns {*} The client query
79
- */
80
- query(filter?: any): any;
81
- /**
82
- * Called by the coordinator to inform the client that a query is pending.
83
- * @returns {this}
84
- */
85
- queryPending(): this;
86
- /**
87
- * Called by the coordinator to return a query result.
88
- * @param {*} data The query result.
89
- * @returns {this}
90
- */
91
- queryResult(data: any): this;
92
- /**
93
- * Called by the coordinator to report a query execution error.
94
- * @param {*} error
95
- * @returns {this}
96
- */
97
- queryError(error: any): this;
98
- /**
99
- * Request the coordinator to execute a query for this client.
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.
108
- * @returns {Promise}
109
- */
110
- requestQuery(query?: Query): Promise<any>;
111
- /**
112
- * Request that the coordinator perform a throttled update of this client
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.
118
- */
119
- requestUpdate(): void;
120
- /**
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.
132
- */
133
- destroy(): void;
134
- /**
135
- * Requests a client update, for example to (re-)render an interface
136
- * component.
137
- * @returns {this | Promise<any>}
138
- */
139
- update(): this | Promise<any>;
140
- }
141
- import type { Selection } from './Selection.js';
142
- import type { Coordinator } from './Coordinator.js';
143
- import type { Query } from '@uwdata/mosaic-sql';
@@ -1,47 +0,0 @@
1
- /**
2
- * Test if a value is a Param instance.
3
- * @param {*} x The value to test.
4
- * @returns {x is Param} True if the input is a Param, false otherwise.
5
- */
6
- export function isParam(x: any): x is Param;
7
- /**
8
- * Represents a dynamic parameter that dispatches updates
9
- * upon parameter changes.
10
- */
11
- export class Param extends AsyncDispatch {
12
- /**
13
- * Create a new Param instance with the given initial value.
14
- * @param {*} value The initial value of the Param.
15
- * @returns {Param} The new Param instance.
16
- */
17
- static value(value: any): Param;
18
- /**
19
- * Create a new Param instance over an array of initial values,
20
- * which may contain nested Params.
21
- * @param {*} values The initial values of the Param.
22
- * @returns {Param} The new Param instance.
23
- */
24
- static array(values: any): Param;
25
- /**
26
- * Create a new Param instance.
27
- * @param {*} value The initial value of the Param.
28
- */
29
- constructor(value: any);
30
- _value: any;
31
- /**
32
- * The current value of the Param.
33
- */
34
- get value(): any;
35
- /**
36
- * Update the Param value
37
- * @param {*} value The new value of the Param.
38
- * @param {object} [options] The update options.
39
- * @param {boolean} [options.force] A boolean flag indicating if the Param
40
- * should emit a 'value' event even if the internal value is unchanged.
41
- * @returns {this} This Param instance.
42
- */
43
- update(value: any, { force }?: {
44
- force?: boolean;
45
- }): this;
46
- }
47
- import { AsyncDispatch } from './util/AsyncDispatch.js';
@@ -1,9 +0,0 @@
1
- /**
2
- * Create a consolidator to combine structurally compatible queries.
3
- * @param {*} enqueue Query manager enqueue method
4
- * @param {*} cache Client-side query cache (sql -> data)
5
- * @returns A consolidator object
6
- */
7
- export function consolidator(enqueue: any, cache: any): {
8
- add(entry: any, priority: any): void;
9
- };
@@ -1,91 +0,0 @@
1
- export const Priority: Readonly<{
2
- High: 0;
3
- Normal: 1;
4
- Low: 2;
5
- }>;
6
- export class QueryManager {
7
- constructor(maxConcurrentRequests?: number);
8
- /** @type {PriorityQueue} */
9
- queue: PriorityQueue;
10
- /** @type {Connector} */
11
- db: Connector;
12
- /** @type {Cache} */
13
- clientCache: Cache;
14
- /** @type {Logger} */
15
- _logger: Logger;
16
- /** @type {boolean} */
17
- _logQueries: boolean;
18
- /** @type {ReturnType<typeof consolidator> | null} */
19
- _consolidate: ReturnType<typeof consolidator> | null;
20
- /**
21
- * Requests pending with the query manager.
22
- * @type {QueryResult[]}
23
- */
24
- pendingResults: QueryResult[];
25
- /** @type {number} */
26
- maxConcurrentRequests: number;
27
- /** @type {boolean} */
28
- pendingExec: boolean;
29
- next(): void;
30
- /**
31
- * Add an entry to the query queue with a priority.
32
- * @param {object} entry The entry to add.
33
- * @param {*} [entry.request] The query request.
34
- * @param {QueryResult} [entry.result] The query result.
35
- * @param {number} priority The query priority, defaults to `Priority.Normal`.
36
- */
37
- enqueue(entry: {
38
- request?: any;
39
- result?: QueryResult;
40
- }, priority?: number): void;
41
- /**
42
- * Submit the query to the connector.
43
- * @param {*} request The request.
44
- * @param {QueryResult} result The query result.
45
- */
46
- submit(request: any, result: QueryResult): Promise<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;
76
- /**
77
- * Request a query result.
78
- * @param {*} request The request.
79
- * @param {number} priority The query priority, defaults to `Priority.Normal`.
80
- * @returns {QueryResult} A query result promise.
81
- */
82
- request(request: any, priority?: number): QueryResult;
83
- cancel(requests: any): void;
84
- clear(): void;
85
- }
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';
91
- import { QueryResult } from './util/query-result.js';