@uwdata/mosaic-core 0.17.0 → 0.19.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 (178) hide show
  1. package/LICENSE +47 -0
  2. package/README.md +0 -1
  3. package/dist/src/Coordinator.d.ts +159 -0
  4. package/dist/src/Coordinator.d.ts.map +1 -0
  5. package/dist/src/Coordinator.js +250 -0
  6. package/dist/src/Coordinator.js.map +1 -0
  7. package/dist/src/MosaicClient.d.ts +138 -0
  8. package/dist/src/MosaicClient.d.ts.map +1 -0
  9. package/dist/src/MosaicClient.js +214 -0
  10. package/dist/src/MosaicClient.js.map +1 -0
  11. package/dist/src/Param.d.ts +56 -0
  12. package/dist/src/Param.d.ts.map +1 -0
  13. package/dist/src/Param.js +89 -0
  14. package/dist/src/Param.js.map +1 -0
  15. package/dist/src/QueryConsolidator.d.ts +11 -0
  16. package/dist/src/QueryConsolidator.d.ts.map +1 -0
  17. package/dist/src/QueryConsolidator.js +249 -0
  18. package/dist/src/QueryConsolidator.js.map +1 -0
  19. package/dist/src/QueryManager.d.ts +77 -0
  20. package/dist/src/QueryManager.d.ts.map +1 -0
  21. package/dist/src/QueryManager.js +174 -0
  22. package/dist/src/QueryManager.js.map +1 -0
  23. package/dist/src/Selection.d.ts +222 -0
  24. package/dist/src/Selection.d.ts.map +1 -0
  25. package/dist/src/Selection.js +322 -0
  26. package/dist/src/Selection.js.map +1 -0
  27. package/dist/src/SelectionClause.d.ts +222 -0
  28. package/dist/src/SelectionClause.d.ts.map +1 -0
  29. package/dist/src/SelectionClause.js +168 -0
  30. package/dist/src/SelectionClause.js.map +1 -0
  31. package/dist/src/connectors/Connector.d.ts +26 -0
  32. package/dist/src/connectors/Connector.d.ts.map +1 -0
  33. package/dist/src/connectors/Connector.js +2 -0
  34. package/dist/src/connectors/Connector.js.map +1 -0
  35. package/dist/src/connectors/rest.d.ts +24 -0
  36. package/dist/src/connectors/rest.d.ts.map +1 -0
  37. package/dist/src/connectors/rest.js +37 -0
  38. package/dist/src/connectors/rest.js.map +1 -0
  39. package/dist/src/connectors/socket.d.ts +40 -0
  40. package/dist/src/connectors/socket.d.ts.map +1 -0
  41. package/dist/src/connectors/socket.js +115 -0
  42. package/dist/src/connectors/socket.js.map +1 -0
  43. package/dist/src/connectors/wasm.d.ts +56 -0
  44. package/dist/src/connectors/wasm.d.ts.map +1 -0
  45. package/dist/src/connectors/wasm.js +116 -0
  46. package/dist/src/connectors/wasm.js.map +1 -0
  47. package/dist/src/index.d.ts +28 -0
  48. package/dist/src/index.d.ts.map +1 -0
  49. package/{src → dist/src}/index.js +8 -11
  50. package/dist/src/index.js.map +1 -0
  51. package/dist/src/make-client.d.ts +33 -0
  52. package/dist/src/make-client.d.ts.map +1 -0
  53. package/dist/src/make-client.js +52 -0
  54. package/dist/src/make-client.js.map +1 -0
  55. package/dist/src/preagg/PreAggregator.d.ts +150 -0
  56. package/dist/src/preagg/PreAggregator.d.ts.map +1 -0
  57. package/dist/src/preagg/PreAggregator.js +382 -0
  58. package/dist/src/preagg/PreAggregator.js.map +1 -0
  59. package/dist/src/preagg/preagg-columns.d.ts +16 -0
  60. package/dist/src/preagg/preagg-columns.d.ts.map +1 -0
  61. package/dist/src/preagg/preagg-columns.js +95 -0
  62. package/dist/src/preagg/preagg-columns.js.map +1 -0
  63. package/dist/src/preagg/sufficient-statistics.d.ts +14 -0
  64. package/dist/src/preagg/sufficient-statistics.d.ts.map +1 -0
  65. package/dist/src/preagg/sufficient-statistics.js +446 -0
  66. package/dist/src/preagg/sufficient-statistics.js.map +1 -0
  67. package/dist/src/types.d.ts +77 -0
  68. package/dist/src/types.d.ts.map +1 -0
  69. package/dist/src/types.js +2 -0
  70. package/dist/src/types.js.map +1 -0
  71. package/dist/src/util/AsyncDispatch.d.ts +121 -0
  72. package/dist/src/util/AsyncDispatch.d.ts.map +1 -0
  73. package/dist/src/util/AsyncDispatch.js +188 -0
  74. package/dist/src/util/AsyncDispatch.js.map +1 -0
  75. package/dist/src/util/cache.d.ts +19 -0
  76. package/dist/src/util/cache.d.ts.map +1 -0
  77. package/dist/src/util/cache.js +66 -0
  78. package/dist/src/util/cache.js.map +1 -0
  79. package/dist/src/util/decode-ipc.d.ts +12 -0
  80. package/dist/src/util/decode-ipc.d.ts.map +1 -0
  81. package/{src → dist/src}/util/decode-ipc.js +5 -6
  82. package/dist/src/util/decode-ipc.js.map +1 -0
  83. package/dist/src/util/distinct.d.ts +3 -0
  84. package/dist/src/util/distinct.d.ts.map +1 -0
  85. package/dist/src/util/distinct.js +16 -0
  86. package/dist/src/util/distinct.js.map +1 -0
  87. package/dist/src/util/field-info.d.ts +26 -0
  88. package/dist/src/util/field-info.d.ts.map +1 -0
  89. package/dist/src/util/field-info.js +91 -0
  90. package/dist/src/util/field-info.js.map +1 -0
  91. package/dist/src/util/hash.d.ts +2 -0
  92. package/dist/src/util/hash.d.ts.map +1 -0
  93. package/dist/src/util/hash.js +26 -0
  94. package/dist/src/util/hash.js.map +1 -0
  95. package/dist/src/util/is-activatable.d.ts +8 -0
  96. package/dist/src/util/is-activatable.d.ts.map +1 -0
  97. package/dist/src/util/is-activatable.js +10 -0
  98. package/dist/src/util/is-activatable.js.map +1 -0
  99. package/dist/src/util/is-arrow-table.d.ts +9 -0
  100. package/dist/src/util/is-arrow-table.d.ts.map +1 -0
  101. package/dist/src/util/is-arrow-table.js +11 -0
  102. package/dist/src/util/is-arrow-table.js.map +1 -0
  103. package/dist/src/util/js-type.d.ts +9 -0
  104. package/dist/src/util/js-type.d.ts.map +1 -0
  105. package/dist/src/util/js-type.js +59 -0
  106. package/dist/src/util/js-type.js.map +1 -0
  107. package/dist/src/util/priority-queue.d.ts +35 -0
  108. package/dist/src/util/priority-queue.d.ts.map +1 -0
  109. package/dist/src/util/priority-queue.js +81 -0
  110. package/dist/src/util/priority-queue.js.map +1 -0
  111. package/dist/src/util/query-result.d.ts +47 -0
  112. package/dist/src/util/query-result.d.ts.map +1 -0
  113. package/dist/src/util/query-result.js +83 -0
  114. package/dist/src/util/query-result.js.map +1 -0
  115. package/dist/src/util/synchronizer.d.ts +36 -0
  116. package/dist/src/util/synchronizer.d.ts.map +1 -0
  117. package/dist/src/util/synchronizer.js +52 -0
  118. package/dist/src/util/synchronizer.js.map +1 -0
  119. package/dist/src/util/throttle.d.ts +12 -0
  120. package/dist/src/util/throttle.d.ts.map +1 -0
  121. package/dist/src/util/throttle.js +51 -0
  122. package/dist/src/util/throttle.js.map +1 -0
  123. package/dist/src/util/to-data-columns.d.ts +22 -0
  124. package/dist/src/util/to-data-columns.d.ts.map +1 -0
  125. package/dist/src/util/to-data-columns.js +51 -0
  126. package/dist/src/util/to-data-columns.js.map +1 -0
  127. package/dist/src/util/void-logger.d.ts +13 -0
  128. package/dist/src/util/void-logger.d.ts.map +1 -0
  129. package/dist/src/util/void-logger.js +13 -0
  130. package/dist/src/util/void-logger.js.map +1 -0
  131. package/package.json +17 -11
  132. package/src/Coordinator.ts +396 -0
  133. package/src/{MosaicClient.js → MosaicClient.ts} +50 -43
  134. package/src/{Param.js → Param.ts} +29 -28
  135. package/src/{QueryConsolidator.js → QueryConsolidator.ts} +85 -62
  136. package/src/{QueryManager.js → QueryManager.ts} +61 -54
  137. package/src/Selection.ts +391 -0
  138. package/src/SelectionClause.ts +357 -0
  139. package/src/connectors/Connector.ts +6 -6
  140. package/src/connectors/rest.ts +56 -0
  141. package/src/connectors/{socket.js → socket.ts} +53 -42
  142. package/src/connectors/{wasm.js → wasm.ts} +52 -63
  143. package/src/index.ts +42 -0
  144. package/src/make-client.ts +93 -0
  145. package/src/preagg/{PreAggregator.js → PreAggregator.ts} +164 -145
  146. package/src/preagg/{preagg-columns.js → preagg-columns.ts} +27 -24
  147. package/src/preagg/{sufficient-statistics.js → sufficient-statistics.ts} +160 -110
  148. package/src/types.ts +24 -9
  149. package/src/util/{AsyncDispatch.js → AsyncDispatch.ts} +62 -43
  150. package/src/util/{cache.js → cache.ts} +25 -15
  151. package/src/util/decode-ipc.ts +15 -0
  152. package/src/util/{distinct.js → distinct.ts} +3 -3
  153. package/src/util/{field-info.js → field-info.ts} +30 -31
  154. package/src/util/{hash.js → hash.ts} +4 -4
  155. package/src/util/is-activatable.ts +11 -0
  156. package/src/util/is-arrow-table.ts +12 -0
  157. package/src/util/{js-type.js → js-type.ts} +7 -5
  158. package/src/util/{priority-queue.js → priority-queue.ts} +32 -20
  159. package/src/util/{query-result.js → query-result.ts} +24 -17
  160. package/src/util/synchronizer.ts +56 -0
  161. package/src/util/throttle.ts +59 -0
  162. package/src/util/to-data-columns.ts +65 -0
  163. package/src/util/void-logger.ts +23 -0
  164. package/src/Coordinator.js +0 -313
  165. package/src/Selection.js +0 -380
  166. package/src/SelectionClause.js +0 -159
  167. package/src/connectors/rest.js +0 -38
  168. package/src/index-types.ts +0 -5
  169. package/src/make-client.js +0 -101
  170. package/src/util/is-activatable.js +0 -8
  171. package/src/util/is-arrow-table.js +0 -10
  172. package/src/util/selection-types.ts +0 -137
  173. package/src/util/synchronizer.js +0 -47
  174. package/src/util/throttle.js +0 -54
  175. package/src/util/to-data-columns.js +0 -60
  176. package/src/util/void-logger.js +0 -13
  177. package/tsconfig.json +0 -9
  178. package/vitest.config.ts +0 -3
@@ -1,109 +1,97 @@
1
- /** @import { ExtractionOptions, Table } from '@uwdata/flechette' */
2
- /** @import { ArrowQueryRequest, Connector, ExecQueryRequest, JSONQueryRequest } from './Connector.js' */
1
+ import type { ExtractionOptions, Table } from '@uwdata/flechette';
2
+ import type { ArrowQueryRequest, Connector, ExecQueryRequest, JSONQueryRequest, ConnectorQueryRequest } from './Connector.js';
3
3
  import * as duckdb from '@duckdb/duckdb-wasm';
4
4
  import { decodeIPC } from '../util/decode-ipc.js';
5
5
 
6
- /**
7
- * @typedef {object} DuckDBWASMOptions
8
- * @property {boolean} [log] Flag to enable logging.
9
- */
6
+ interface DuckDBWASMOptions {
7
+ /** Flag to enable logging. */
8
+ log?: boolean;
9
+ }
10
10
 
11
- /**
12
- * @typedef {object} DuckDBWASMConnectorOptions
13
- * @property {boolean} [log] Flag to enable logging.
14
- * @property {ExtractionOptions} [ipc]
15
- * Arrow IPC extraction options.
16
- * @property {duckdb.AsyncDuckDB} [duckdb]
17
- * Optional pre-existing DuckDB-WASM instance.
18
- * @property {duckdb.AsyncDuckDBConnection} [connection]
19
- * Optional pre-existing DuckDB-WASM connection.
20
- */
11
+ interface DuckDBWASMConnectorOptions extends DuckDBWASMOptions {
12
+ /** Arrow IPC extraction options. */
13
+ ipc?: ExtractionOptions;
14
+ /** Optional pre-existing DuckDB-WASM instance. */
15
+ duckdb?: duckdb.AsyncDuckDB;
16
+ /** Optional pre-existing DuckDB-WASM connection. */
17
+ connection?: duckdb.AsyncDuckDBConnection;
18
+ /** Optional database config. */
19
+ config?: duckdb.DuckDBConfig;
20
+ }
21
21
 
22
22
  /**
23
23
  * Connect to a DuckDB-WASM instance.
24
- * @param {DuckDBWASMConnectorOptions} [options] Connector options.
25
- * @returns {DuckDBWASMConnector} A connector instance.
24
+ * @param options Connector options.
25
+ * @returns A connector instance.
26
26
  */
27
- export function wasmConnector(options = {}) {
27
+ export function wasmConnector(options: DuckDBWASMConnectorOptions = {}): DuckDBWASMConnector {
28
28
  return new DuckDBWASMConnector(options);
29
29
  }
30
30
 
31
31
  /**
32
32
  * DuckDB-WASM connector.
33
- * @implements {Connector}
34
33
  */
35
- export class DuckDBWASMConnector {
34
+ export class DuckDBWASMConnector implements Connector {
35
+ private _ipc?: ExtractionOptions;
36
+ public _options: DuckDBWASMOptions;
37
+ public _db?: duckdb.AsyncDuckDB;
38
+ public _con?: duckdb.AsyncDuckDBConnection;
39
+ public _config?: duckdb.DuckDBConfig;
40
+ public _loadPromise?: Promise<unknown>;
41
+
36
42
  /**
37
43
  * Create a new DuckDB-WASM connector instance.
38
- * @param {DuckDBWASMConnectorOptions} [options]
44
+ * @param options Connector options.
39
45
  */
40
- constructor(options = {}) {
41
- const { ipc, duckdb, connection, ...opts } = options;
42
- /** @type {ExtractionOptions} */
46
+ constructor(options: DuckDBWASMConnectorOptions = {}) {
47
+ const { ipc, duckdb, connection, config, ...opts } = options;
43
48
  this._ipc = ipc;
44
- /** @type {DuckDBWASMOptions} */
45
49
  this._options = opts;
46
- /** @type {duckdb.AsyncDuckDB} */
47
50
  this._db = duckdb;
48
- /** @type {duckdb.AsyncDuckDBConnection} */
49
51
  this._con = connection;
50
- /** @type {Promise<unknown>} */
51
- this._loadPromise;
52
+ this._config = config;
52
53
  }
53
54
 
54
55
  /**
55
56
  * Get the backing DuckDB-WASM instance.
56
57
  * Lazily initializes DuckDB-WASM if not already loaded.
57
- * @returns {Promise<duckdb.AsyncDuckDB>} The DuckDB-WASM instance.
58
+ * @returns The DuckDB-WASM instance.
58
59
  */
59
- async getDuckDB() {
60
+ async getDuckDB(): Promise<duckdb.AsyncDuckDB> {
60
61
  if (!this._db) await connect(this);
61
- return this._db;
62
+ return this._db!;
62
63
  }
63
64
 
64
65
  /**
65
66
  * Get the backing DuckDB-WASM connection.
66
67
  * Lazily initializes DuckDB-WASM if not already loaded.
67
- * @returns {Promise<duckdb.AsyncDuckDBConnection>} The DuckDB-WASM connection.
68
+ * @returns The DuckDB-WASM connection.
68
69
  */
69
- async getConnection() {
70
+ async getConnection(): Promise<duckdb.AsyncDuckDBConnection> {
70
71
  if (!this._con) await connect(this);
71
- return this._con;
72
+ return this._con!;
72
73
  }
73
74
 
74
- /**
75
- * @overload
76
- * @param {ArrowQueryRequest} query
77
- * @returns {Promise<Table>}
78
- *
79
- * @overload
80
- * @param {ExecQueryRequest} query
81
- * @returns {Promise<void>}
82
- *
83
- * @overload
84
- * @param {JSONQueryRequest} query
85
- * @returns {Promise<Record<string, any>[]>}
86
- *
87
- * @param {ArrowQueryRequest | ExecQueryRequest | JSONQueryRequest} query
88
- * @returns {Promise<Table | void | Record<string, any>[]>}}
89
- */
90
- async query(query) {
75
+ async query(query: ArrowQueryRequest): Promise<Table>;
76
+ async query(query: ExecQueryRequest): Promise<void>;
77
+ async query(query: JSONQueryRequest): Promise<Record<string, unknown>[]>;
78
+ async query(query: ConnectorQueryRequest): Promise<unknown> {
91
79
  const { type, sql } = query;
92
80
  const con = await this.getConnection();
93
81
  const result = await getArrowIPC(con, sql);
94
82
  return type === 'exec' ? undefined
95
83
  : type === 'arrow' ? decodeIPC(result, this._ipc)
96
84
  : decodeIPC(result).toArray();
97
- };
85
+ }
98
86
  }
99
87
 
100
88
  /**
101
89
  * Bypass duckdb-wasm query method to get Arrow IPC bytes directly.
102
90
  * https://github.com/duckdb/duckdb-wasm/issues/267#issuecomment-2252749509
103
- * @param {duckdb.AsyncDuckDBConnection} con The DuckDB-WASM connection.
104
- * @param {string} query The SQL query to run.
91
+ * @param con The DuckDB-WASM connection.
92
+ * @param query The SQL query to run.
105
93
  */
106
- function getArrowIPC(con, query) {
94
+ function getArrowIPC(con: duckdb.AsyncDuckDBConnection, query: string): Promise<Uint8Array> {
107
95
  return new Promise((resolve, reject) => {
108
96
  con.useUnsafe(async (bindings, conn) => {
109
97
  try {
@@ -118,10 +106,10 @@ function getArrowIPC(con, query) {
118
106
 
119
107
  /**
120
108
  * Establish a new database connection for the given connector.
121
- * @param {DuckDBWASMConnector} c The connector.
122
- * @returns {Promise<unknown>}
109
+ * @param c The connector.
110
+ * @returns Connection promise.
123
111
  */
124
- function connect(c) {
112
+ function connect(c: DuckDBWASMConnector): Promise<unknown> {
125
113
  if (!c._loadPromise) {
126
114
  // use a loading promise to avoid race conditions
127
115
  // synchronizes multiple callees on the same load
@@ -129,6 +117,7 @@ function connect(c) {
129
117
  c._db
130
118
  ? Promise.resolve(c._db)
131
119
  : initDatabase(c._options).then(result => c._db = result))
120
+ .then(db => c._config != undefined ? db.open(c._config).then(() => db) : db)
132
121
  .then(db => db.connect())
133
122
  .then(result => c._con = result);
134
123
  }
@@ -137,11 +126,11 @@ function connect(c) {
137
126
 
138
127
  /**
139
128
  * Initialize a new DuckDB-WASM instance.
140
- * @param {DuckDBWASMOptions} options
129
+ * @param options Database initialization options.
141
130
  */
142
131
  async function initDatabase({
143
132
  log = false
144
- } = {}) {
133
+ }: DuckDBWASMOptions = {}): Promise<duckdb.AsyncDuckDB> {
145
134
  const JSDELIVR_BUNDLES = duckdb.getJsDelivrBundles();
146
135
 
147
136
  // Select a bundle based on browser checks
@@ -151,7 +140,7 @@ async function initDatabase({
151
140
  new Blob([`importScripts("${bundle.mainWorker}");`], {type: 'text/javascript'})
152
141
  );
153
142
 
154
- // Instantiate the asynchronus version of DuckDB-wasm
143
+ // Instantiate the asynchronous version of DuckDB-wasm
155
144
  const worker = new Worker(worker_url);
156
145
  const logger = log ? new duckdb.ConsoleLogger() : new duckdb.VoidLogger();
157
146
  const db = new duckdb.AsyncDuckDB(logger, worker);
package/src/index.ts ADDED
@@ -0,0 +1,42 @@
1
+ export { MosaicClient } from './MosaicClient.js';
2
+ export { makeClient } from './make-client.js';
3
+ export { Coordinator, coordinator } from './Coordinator.js';
4
+ export { Selection, isSelection } from './Selection.js';
5
+ export { Param, isParam } from './Param.js';
6
+ export { Priority } from './QueryManager.js';
7
+
8
+ // deprecated in favor of constructors
9
+ export { restConnector } from './connectors/rest.js';
10
+ export { socketConnector } from './connectors/socket.js';
11
+ export { wasmConnector } from './connectors/wasm.js';
12
+
13
+ export { RestConnector } from './connectors/rest.js';
14
+ export { SocketConnector } from './connectors/socket.js';
15
+ export { DuckDBWASMConnector } from './connectors/wasm.js';
16
+
17
+ export {
18
+ clauseInterval,
19
+ clauseIntervals,
20
+ clauseList,
21
+ clausePoint,
22
+ clausePoints,
23
+ clauseMatch,
24
+ clauseMatchAny
25
+ } from './SelectionClause.js';
26
+
27
+ export { decodeIPC } from './util/decode-ipc.js';
28
+ export { distinct } from './util/distinct.js';
29
+ export { isArrowTable } from './util/is-arrow-table.js';
30
+ export { Synchronizer } from './util/synchronizer.js';
31
+ export { throttle } from './util/throttle.js';
32
+ export { toDataColumns } from './util/to-data-columns.js';
33
+ export { queryFieldInfo } from './util/field-info.js';
34
+ export { jsType } from './util/js-type.js';
35
+ export { isActivatable } from './util/is-activatable.js';
36
+ export type { QueryResult } from './util/query-result.js';
37
+
38
+ export * from './types.js';
39
+
40
+ export type * from './connectors/Connector.js';
41
+ export type * from './Selection.js';
42
+ export type * from './SelectionClause.js';
@@ -0,0 +1,93 @@
1
+ import type { Coordinator } from './Coordinator.js';
2
+ import type { Selection } from './Selection.js';
3
+ import type { FilterExpr } from '@uwdata/mosaic-sql';
4
+ import { type ClientQuery, MosaicClient } from './MosaicClient.js';
5
+ import { coordinator as defaultCoordinator } from './Coordinator.js';
6
+
7
+ export interface MakeClientOptions {
8
+ /** Mosaic coordinator. Defaults to the global coordinator. */
9
+ coordinator?: Coordinator;
10
+ /** A selection whose predicates are fed into the query function to produce the SQL query. */
11
+ selection?: Selection;
12
+ /** A flag (default `true`) indicating if the client should initially be enabled or not. */
13
+ enabled?: boolean;
14
+ /** A flag (default `true`) indicating if client queries can be sped up using pre-aggregated data.
15
+ * Should be set to `false` if filtering changes the groupby domain of the query. */
16
+ filterStable?: boolean;
17
+ /** An async function to prepare the client before running queries. */
18
+ prepare?: () => Promise<void>;
19
+ /** A function that returns a query from a list of selection predicates. */
20
+ query?: (filter: FilterExpr) => ClientQuery;
21
+ /** Called by the coordinator to return a query result. */
22
+ queryResult?: (data: unknown) => void;
23
+ /** Called by the coordinator to inform the client that a query is pending. */
24
+ queryPending?: () => void;
25
+ /** Called by the coordinator to report a query execution error. */
26
+ queryError?: (error: Error) => void;
27
+ }
28
+
29
+ /**
30
+ * Make a new client with the given options, and connect the client to the
31
+ * provided coordinator.
32
+ * @param options The options for making the client.
33
+ * @returns The resulting client.
34
+ */
35
+ export function makeClient(options: MakeClientOptions): MosaicClient {
36
+ const {
37
+ coordinator = defaultCoordinator(),
38
+ ...clientOptions
39
+ } = options;
40
+ const client = new ProxyClient(clientOptions);
41
+ coordinator.connect(client);
42
+ return client;
43
+ }
44
+
45
+ /**
46
+ * An internal class used to implement the makeClient API.
47
+ */
48
+ class ProxyClient extends MosaicClient {
49
+ private readonly _methods: Omit<MakeClientOptions, 'coordinator' | 'selection' | 'enabled' | 'filterStable'>;
50
+ private readonly _filterStable: boolean;
51
+
52
+ /**
53
+ * @param options The options for making the client.
54
+ */
55
+ constructor({
56
+ selection = undefined,
57
+ enabled = true,
58
+ filterStable = true,
59
+ ...methods
60
+ }: Omit<MakeClientOptions, 'coordinator'>) {
61
+ super(selection);
62
+ this.enabled = enabled;
63
+ this._methods = methods;
64
+ this._filterStable = filterStable;
65
+ }
66
+
67
+ get filterStable(): boolean {
68
+ return this._filterStable;
69
+ }
70
+
71
+ async prepare(): Promise<void> {
72
+ await this._methods.prepare?.();
73
+ }
74
+
75
+ query(filter: FilterExpr): ClientQuery {
76
+ return this._methods.query?.(filter) ?? null;
77
+ }
78
+
79
+ queryResult(data: unknown): this {
80
+ this._methods.queryResult?.(data);
81
+ return this;
82
+ }
83
+
84
+ queryPending(): this {
85
+ this._methods.queryPending?.();
86
+ return this;
87
+ }
88
+
89
+ queryError(error: Error): this {
90
+ this._methods.queryError?.(error);
91
+ return this;
92
+ }
93
+ }