@uwdata/mosaic-core 0.11.0 → 0.12.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.
- package/README.md +1 -1
- package/dist/mosaic-core.js +11612 -10855
- package/dist/mosaic-core.min.js +7 -7
- package/dist/types/Coordinator.d.ts +169 -0
- package/dist/types/MosaicClient.d.ts +94 -0
- package/dist/types/Param.d.ts +47 -0
- package/dist/types/QueryConsolidator.d.ts +9 -0
- package/dist/types/QueryManager.d.ts +64 -0
- package/dist/types/Selection.d.ts +224 -0
- package/dist/types/SelectionClause.d.ts +105 -0
- package/dist/types/connectors/rest.d.ts +17 -0
- package/dist/types/connectors/socket.d.ts +18 -0
- package/dist/types/connectors/wasm.d.ts +16 -0
- package/dist/types/index.d.ts +25 -0
- package/dist/types/preagg/PreAggregator.d.ts +178 -0
- package/dist/types/preagg/preagg-columns.d.ts +14 -0
- package/dist/types/preagg/sufficient-statistics.d.ts +13 -0
- package/dist/types/util/AsyncDispatch.d.ts +100 -0
- package/dist/types/util/cache.d.ts +13 -0
- package/dist/types/util/decode-ipc.d.ts +7 -0
- package/dist/types/util/distinct.d.ts +2 -0
- package/dist/types/util/field-info.d.ts +13 -0
- package/dist/types/util/hash.d.ts +1 -0
- package/dist/types/util/is-arrow-table.d.ts +8 -0
- package/dist/types/util/js-type.d.ts +1 -0
- package/dist/types/util/priority-queue.d.ts +37 -0
- package/dist/types/util/query-result.d.ts +44 -0
- package/dist/types/util/selection-types.d.ts +114 -0
- package/dist/types/util/synchronizer.d.ts +29 -0
- package/dist/types/util/throttle.d.ts +11 -0
- package/dist/types/util/to-data-columns.d.ts +29 -0
- package/dist/types/util/void-logger.d.ts +7 -0
- package/jsconfig.json +11 -0
- package/package.json +10 -8
- package/src/Coordinator.js +14 -14
- package/src/MosaicClient.js +5 -4
- package/src/QueryConsolidator.js +22 -33
- package/src/QueryManager.js +76 -45
- package/src/Selection.js +8 -5
- package/src/SelectionClause.js +19 -22
- package/src/connectors/rest.js +3 -1
- package/src/connectors/socket.js +3 -1
- package/src/connectors/wasm.js +1 -1
- package/src/index.js +13 -0
- package/src/preagg/PreAggregator.js +407 -0
- package/src/preagg/preagg-columns.js +103 -0
- package/src/preagg/sufficient-statistics.js +439 -0
- package/src/util/field-info.js +16 -5
- package/src/util/hash.js +1 -1
- package/src/util/query-result.js +44 -2
- package/src/util/selection-types.ts +3 -3
- package/src/util/throttle.js +11 -9
- package/src/util/void-logger.js +6 -5
- package/tsconfig.json +11 -0
- package/src/DataCubeIndexer.js +0 -378
- package/src/util/index-columns.js +0 -537
|
@@ -0,0 +1,169 @@
|
|
|
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
|
+
* @typedef {import('@uwdata/mosaic-sql').Query | string} QueryType
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* A Mosaic Coordinator manages all database communication for clients and
|
|
12
|
+
* handles selection updates. The Coordinator also performs optimizations
|
|
13
|
+
* including query caching, consolidation, and pre-aggregation.
|
|
14
|
+
* @param {*} [db] Database connector. Defaults to a web socket connection.
|
|
15
|
+
* @param {object} [options] Coordinator options.
|
|
16
|
+
* @param {*} [options.logger=console] The logger to use, defaults to `console`.
|
|
17
|
+
* @param {*} [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 {import('./preagg/PreAggregator.js').PreAggregateOptions} [options.preagg]
|
|
21
|
+
* Options for the Pre-aggregator.
|
|
22
|
+
*/
|
|
23
|
+
export class Coordinator {
|
|
24
|
+
constructor(db?: {
|
|
25
|
+
readonly connected: boolean;
|
|
26
|
+
query(query: {
|
|
27
|
+
type?: "exec" | "arrow" | "json" | "create-bundle" | "load-bundle";
|
|
28
|
+
sql?: string;
|
|
29
|
+
queries?: string[];
|
|
30
|
+
name?: string;
|
|
31
|
+
}): Promise<any>;
|
|
32
|
+
}, { logger, manager, cache, consolidate, preagg }?: {
|
|
33
|
+
logger?: Console;
|
|
34
|
+
manager?: QueryManager;
|
|
35
|
+
cache?: boolean;
|
|
36
|
+
consolidate?: boolean;
|
|
37
|
+
preagg?: {};
|
|
38
|
+
});
|
|
39
|
+
/** @type {QueryManager} */
|
|
40
|
+
manager: QueryManager;
|
|
41
|
+
preaggregator: PreAggregator;
|
|
42
|
+
/**
|
|
43
|
+
* Clear the coordinator state.
|
|
44
|
+
* @param {object} [options] Options object.
|
|
45
|
+
* @param {boolean} [options.clients=true] If true, disconnect all clients.
|
|
46
|
+
* @param {boolean} [options.cache=true] If true, clear the query cache.
|
|
47
|
+
*/
|
|
48
|
+
clear({ clients, cache }?: {
|
|
49
|
+
clients?: boolean;
|
|
50
|
+
cache?: boolean;
|
|
51
|
+
}): void;
|
|
52
|
+
filterGroups: Map<any, any>;
|
|
53
|
+
clients: Set<any>;
|
|
54
|
+
/**
|
|
55
|
+
* Get or set the database connector.
|
|
56
|
+
* @param {*} [db] The database connector to use.
|
|
57
|
+
* @returns The current database connector.
|
|
58
|
+
*/
|
|
59
|
+
databaseConnector(db?: any): any;
|
|
60
|
+
/**
|
|
61
|
+
* Get or set the logger.
|
|
62
|
+
* @param {*} logger The logger to use.
|
|
63
|
+
* @returns The current logger
|
|
64
|
+
*/
|
|
65
|
+
logger(logger: any, ...args: any[]): any;
|
|
66
|
+
_logger: any;
|
|
67
|
+
/**
|
|
68
|
+
* Cancel previosuly submitted query requests. These queries will be
|
|
69
|
+
* canceled if they are queued but have not yet been submitted.
|
|
70
|
+
* @param {QueryResult[]} requests An array
|
|
71
|
+
* of query result objects, such as those returned by the `query` method.
|
|
72
|
+
*/
|
|
73
|
+
cancel(requests: QueryResult[]): void;
|
|
74
|
+
/**
|
|
75
|
+
* Issue a query for which no result (return value) is needed.
|
|
76
|
+
* @param {QueryType | QueryType[]} query The query or an array of queries.
|
|
77
|
+
* Each query should be either a Query builder object or a SQL string.
|
|
78
|
+
* @param {object} [options] An options object.
|
|
79
|
+
* @param {number} [options.priority] The query priority, defaults to
|
|
80
|
+
* `Priority.Normal`.
|
|
81
|
+
* @returns {QueryResult} A query result
|
|
82
|
+
* promise.
|
|
83
|
+
*/
|
|
84
|
+
exec(query: QueryType | QueryType[], { priority }?: {
|
|
85
|
+
priority?: number;
|
|
86
|
+
}): QueryResult;
|
|
87
|
+
/**
|
|
88
|
+
* Issue a query to the backing database. The submitted query may be
|
|
89
|
+
* consolidate with other queries and its results may be cached.
|
|
90
|
+
* @param {QueryType} query The query as either a Query builder object
|
|
91
|
+
* or a SQL string.
|
|
92
|
+
* @param {object} [options] An options object.
|
|
93
|
+
* @param {'arrow' | 'json'} [options.type] The query result format type.
|
|
94
|
+
* @param {boolean} [options.cache=true] If true, cache the query result.
|
|
95
|
+
* @param {number} [options.priority] The query priority, defaults to
|
|
96
|
+
* `Priority.Normal`.
|
|
97
|
+
* @returns {QueryResult} A query result promise.
|
|
98
|
+
*/
|
|
99
|
+
query(query: QueryType, { type, cache, priority, ...options }?: {
|
|
100
|
+
type?: "arrow" | "json";
|
|
101
|
+
cache?: boolean;
|
|
102
|
+
priority?: number;
|
|
103
|
+
}): QueryResult;
|
|
104
|
+
/**
|
|
105
|
+
* Issue a query to prefetch data for later use. The query result is cached
|
|
106
|
+
* for efficient future access.
|
|
107
|
+
* @param {QueryType} query The query as either a Query builder object
|
|
108
|
+
* or a SQL string.
|
|
109
|
+
* @param {object} [options] An options object.
|
|
110
|
+
* @param {'arrow' | 'json'} [options.type] The query result format type.
|
|
111
|
+
* @returns {QueryResult} A query result promise.
|
|
112
|
+
*/
|
|
113
|
+
prefetch(query: QueryType, options?: {
|
|
114
|
+
type?: "arrow" | "json";
|
|
115
|
+
}): QueryResult;
|
|
116
|
+
/**
|
|
117
|
+
* Create a bundle of queries that can be loaded into the cache.
|
|
118
|
+
*
|
|
119
|
+
* @param {string} name The name of the bundle.
|
|
120
|
+
* @param {[string | {sql: string}, {alias: string}]} queries The queries to save into the bundle.
|
|
121
|
+
* @param {number} priority Request priority.
|
|
122
|
+
* @returns {QueryResult} A query result promise.
|
|
123
|
+
*/
|
|
124
|
+
createBundle(name: string, queries: [string | {
|
|
125
|
+
sql: string;
|
|
126
|
+
}, {
|
|
127
|
+
alias: string;
|
|
128
|
+
}], priority?: number): QueryResult;
|
|
129
|
+
/**
|
|
130
|
+
* Load a bundle into the cache.
|
|
131
|
+
* @param {string} name The name of the bundle.
|
|
132
|
+
* @param {number} priority Request priority.
|
|
133
|
+
* @returns {QueryResult} A query result promise.
|
|
134
|
+
*/
|
|
135
|
+
loadBundle(name: string, priority?: number): QueryResult;
|
|
136
|
+
/**
|
|
137
|
+
* Update client data by submitting the given query and returning the
|
|
138
|
+
* data (or error) to the client.
|
|
139
|
+
* @param {MosaicClient} client A Mosaic client.
|
|
140
|
+
* @param {QueryType} query The data query.
|
|
141
|
+
* @param {number} [priority] The query priority.
|
|
142
|
+
* @returns {Promise} A Promise that resolves upon completion of the update.
|
|
143
|
+
*/
|
|
144
|
+
updateClient(client: MosaicClient, query: QueryType, priority?: number): Promise<any>;
|
|
145
|
+
/**
|
|
146
|
+
* Issue a query request for a client. If the query is null or undefined,
|
|
147
|
+
* the client is simply updated. Otherwise `updateClient` is called. As a
|
|
148
|
+
* side effect, this method clears the current preaggregator state.
|
|
149
|
+
* @param {MosaicClient} client The client to update.
|
|
150
|
+
* @param {QueryType | null} [query] The query to issue.
|
|
151
|
+
*/
|
|
152
|
+
requestQuery(client: MosaicClient, query?: QueryType | null): Promise<any>;
|
|
153
|
+
/**
|
|
154
|
+
* Connect a client to the coordinator.
|
|
155
|
+
* @param {MosaicClient} client The Mosaic client to connect.
|
|
156
|
+
*/
|
|
157
|
+
connect(client: MosaicClient): Promise<void>;
|
|
158
|
+
initializeClient(client: any): Promise<any>;
|
|
159
|
+
/**
|
|
160
|
+
* Disconnect a client from the coordinator.
|
|
161
|
+
* @param {MosaicClient} client The Mosaic client to disconnect.
|
|
162
|
+
*/
|
|
163
|
+
disconnect(client: MosaicClient): void;
|
|
164
|
+
}
|
|
165
|
+
export type QueryType = import("@uwdata/mosaic-sql").Query | string;
|
|
166
|
+
import { QueryManager } from './QueryManager.js';
|
|
167
|
+
import { PreAggregator } from './preagg/PreAggregator.js';
|
|
168
|
+
import { QueryResult } from './util/query-result.js';
|
|
169
|
+
import { MosaicClient } from './MosaicClient.js';
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for Mosaic clients.
|
|
3
|
+
*/
|
|
4
|
+
export class MosaicClient {
|
|
5
|
+
/**
|
|
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.
|
|
10
|
+
*/
|
|
11
|
+
constructor(filterSelection: any);
|
|
12
|
+
_filterBy: any;
|
|
13
|
+
_requestUpdate: (event: any) => void;
|
|
14
|
+
_coordinator: any;
|
|
15
|
+
/**
|
|
16
|
+
* Set this client's connected coordinator.
|
|
17
|
+
*/
|
|
18
|
+
set coordinator(coordinator: any);
|
|
19
|
+
/**
|
|
20
|
+
* Return this client's connected coordinator.
|
|
21
|
+
*/
|
|
22
|
+
get coordinator(): any;
|
|
23
|
+
/**
|
|
24
|
+
* Return this client's filter selection.
|
|
25
|
+
*/
|
|
26
|
+
get filterBy(): any;
|
|
27
|
+
/**
|
|
28
|
+
* Return a boolean indicating if the client query can be sped up with
|
|
29
|
+
* materialized views of pre-aggregated data. Should return true if changes to
|
|
30
|
+
* the filterBy selection does not change the groupby domain of the client
|
|
31
|
+
* query.
|
|
32
|
+
*/
|
|
33
|
+
get filterStable(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Return an array of fields queried by this client.
|
|
36
|
+
* @returns {object[]|null} The fields to retrieve info for.
|
|
37
|
+
*/
|
|
38
|
+
fields(): object[] | null;
|
|
39
|
+
/**
|
|
40
|
+
* Called by the coordinator to set the field info for this client.
|
|
41
|
+
* @param {*} info The field info result.
|
|
42
|
+
* @returns {this}
|
|
43
|
+
*/
|
|
44
|
+
fieldInfo(info: any): this;
|
|
45
|
+
/**
|
|
46
|
+
* Return a query specifying the data needed by this client.
|
|
47
|
+
* @param {*} [filter] The filtering criteria to apply in the query.
|
|
48
|
+
* @returns {*} The client query
|
|
49
|
+
*/
|
|
50
|
+
query(filter?: any): any;
|
|
51
|
+
/**
|
|
52
|
+
* Called by the coordinator to inform the client that a query is pending.
|
|
53
|
+
* @returns {this}
|
|
54
|
+
*/
|
|
55
|
+
queryPending(): this;
|
|
56
|
+
/**
|
|
57
|
+
* Called by the coordinator to return a query result.
|
|
58
|
+
* @param {*} data The query result.
|
|
59
|
+
* @returns {this}
|
|
60
|
+
*/
|
|
61
|
+
queryResult(data: any): this;
|
|
62
|
+
/**
|
|
63
|
+
* Called by the coordinator to report a query execution error.
|
|
64
|
+
* @param {*} error
|
|
65
|
+
* @returns {this}
|
|
66
|
+
*/
|
|
67
|
+
queryError(error: any): this;
|
|
68
|
+
/**
|
|
69
|
+
* Request the coordinator to execute a query for this client.
|
|
70
|
+
* If an explicit query is not provided, the client query method will
|
|
71
|
+
* be called, filtered by the current filterBy selection.
|
|
72
|
+
* @returns {Promise}
|
|
73
|
+
*/
|
|
74
|
+
requestQuery(query: any): Promise<any>;
|
|
75
|
+
/**
|
|
76
|
+
* Request that the coordinator perform a throttled update of this client
|
|
77
|
+
* using the default query. Unlike requestQuery, for which every call will
|
|
78
|
+
* result in an executed query, multiple calls to requestUpdate may be
|
|
79
|
+
* consolidated into a single update.
|
|
80
|
+
*/
|
|
81
|
+
requestUpdate(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Reset this client, initiating new field info and query requests.
|
|
84
|
+
* @returns {Promise}
|
|
85
|
+
*/
|
|
86
|
+
initialize(): Promise<any>;
|
|
87
|
+
/**
|
|
88
|
+
* Requests a client update.
|
|
89
|
+
* For example to (re-)render an interface component.
|
|
90
|
+
*
|
|
91
|
+
* @returns {this | Promise<any>}
|
|
92
|
+
*/
|
|
93
|
+
update(): this | Promise<any>;
|
|
94
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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';
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export const Priority: Readonly<{
|
|
2
|
+
High: 0;
|
|
3
|
+
Normal: 1;
|
|
4
|
+
Low: 2;
|
|
5
|
+
}>;
|
|
6
|
+
export class QueryManager {
|
|
7
|
+
constructor(maxConcurrentRequests?: number);
|
|
8
|
+
queue: PriorityQueue;
|
|
9
|
+
db: any;
|
|
10
|
+
clientCache: any;
|
|
11
|
+
_logger: {
|
|
12
|
+
debug(..._: any[]): void;
|
|
13
|
+
info(..._: any[]): void;
|
|
14
|
+
log(..._: any[]): void;
|
|
15
|
+
warn(..._: any[]): void;
|
|
16
|
+
error(..._: any[]): void;
|
|
17
|
+
};
|
|
18
|
+
_logQueries: boolean;
|
|
19
|
+
_consolidate: {
|
|
20
|
+
add(entry: any, priority: any): void;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Requests pending with the query manager.
|
|
24
|
+
*
|
|
25
|
+
* @type {QueryResult[]}
|
|
26
|
+
*/
|
|
27
|
+
pendingResults: QueryResult[];
|
|
28
|
+
maxConcurrentRequests: number;
|
|
29
|
+
pendingExec: boolean;
|
|
30
|
+
next(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Add an entry to the query queue with a priority.
|
|
33
|
+
* @param {object} entry The entry to add.
|
|
34
|
+
* @param {*} [entry.request] The query request.
|
|
35
|
+
* @param {QueryResult} [entry.result] The query result.
|
|
36
|
+
* @param {number} priority The query priority, defaults to `Priority.Normal`.
|
|
37
|
+
*/
|
|
38
|
+
enqueue(entry: {
|
|
39
|
+
request?: any;
|
|
40
|
+
result?: QueryResult;
|
|
41
|
+
}, priority?: number): void;
|
|
42
|
+
/**
|
|
43
|
+
* Submit the query to the connector.
|
|
44
|
+
* @param {*} request The request.
|
|
45
|
+
* @param {QueryResult} result The query result.
|
|
46
|
+
*/
|
|
47
|
+
submit(request: any, result: QueryResult): Promise<void>;
|
|
48
|
+
cache(value: any): any;
|
|
49
|
+
logger(value: any): any;
|
|
50
|
+
logQueries(value: any): boolean;
|
|
51
|
+
connector(connector: any): any;
|
|
52
|
+
consolidate(flag: any): void;
|
|
53
|
+
/**
|
|
54
|
+
* Request a query result.
|
|
55
|
+
* @param {*} request The request.
|
|
56
|
+
* @param {number} priority The query priority, defaults to `Priority.Normal`.
|
|
57
|
+
* @returns {QueryResult} A query result promise.
|
|
58
|
+
*/
|
|
59
|
+
request(request: any, priority?: number): QueryResult;
|
|
60
|
+
cancel(requests: any): void;
|
|
61
|
+
clear(): void;
|
|
62
|
+
}
|
|
63
|
+
import { PriorityQueue } from './util/priority-queue.js';
|
|
64
|
+
import { QueryResult } from './util/query-result.js';
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test if a value is a Selection instance.
|
|
3
|
+
* @param {*} x The value to test.
|
|
4
|
+
* @returns {x is Selection} True if the input is a Selection, false otherwise.
|
|
5
|
+
*/
|
|
6
|
+
export function isSelection(x: any): x is Selection;
|
|
7
|
+
/**
|
|
8
|
+
* Represents a dynamic set of query filter predicates.
|
|
9
|
+
*/
|
|
10
|
+
export class Selection extends Param {
|
|
11
|
+
/**
|
|
12
|
+
* Create a new Selection instance with an
|
|
13
|
+
* intersect (conjunction) resolution strategy.
|
|
14
|
+
* @param {object} [options] The selection options.
|
|
15
|
+
* @param {boolean} [options.cross=false] Boolean flag indicating
|
|
16
|
+
* cross-filtered resolution. If true, selection clauses will not
|
|
17
|
+
* be applied to the clients they are associated with.
|
|
18
|
+
* @param {boolean} [options.empty=false] Boolean flag indicating if a lack
|
|
19
|
+
* of clauses should correspond to an empty selection with no records. This
|
|
20
|
+
* setting determines the default selection state.
|
|
21
|
+
* @param {Selection|Selection[]} [options.include] Upstream selections whose
|
|
22
|
+
* clauses should be included as part of the new selection. Any clauses
|
|
23
|
+
* published to upstream selections will be relayed to the new selection.
|
|
24
|
+
* @returns {Selection} The new Selection instance.
|
|
25
|
+
*/
|
|
26
|
+
static intersect({ cross, empty, include }?: {
|
|
27
|
+
cross?: boolean;
|
|
28
|
+
empty?: boolean;
|
|
29
|
+
include?: Selection | Selection[];
|
|
30
|
+
}): Selection;
|
|
31
|
+
/**
|
|
32
|
+
* Create a new Selection instance with a
|
|
33
|
+
* union (disjunction) resolution strategy.
|
|
34
|
+
* @param {object} [options] The selection options.
|
|
35
|
+
* @param {boolean} [options.cross=false] Boolean flag indicating
|
|
36
|
+
* cross-filtered resolution. If true, selection clauses will not
|
|
37
|
+
* be applied to the clients they are associated with.
|
|
38
|
+
* @param {boolean} [options.empty=false] Boolean flag indicating if a lack
|
|
39
|
+
* of clauses should correspond to an empty selection with no records. This
|
|
40
|
+
* setting determines the default selection state.
|
|
41
|
+
* @param {Selection|Selection[]} [options.include] Upstream selections whose
|
|
42
|
+
* clauses should be included as part of the new selection. Any clauses
|
|
43
|
+
* published to upstream selections will be relayed to the new selection.
|
|
44
|
+
* @returns {Selection} The new Selection instance.
|
|
45
|
+
*/
|
|
46
|
+
static union({ cross, empty, include }?: {
|
|
47
|
+
cross?: boolean;
|
|
48
|
+
empty?: boolean;
|
|
49
|
+
include?: Selection | Selection[];
|
|
50
|
+
}): Selection;
|
|
51
|
+
/**
|
|
52
|
+
* Create a new Selection instance with a singular resolution strategy
|
|
53
|
+
* that keeps only the most recent selection clause.
|
|
54
|
+
* @param {object} [options] The selection options.
|
|
55
|
+
* @param {boolean} [options.cross=false] Boolean flag indicating
|
|
56
|
+
* cross-filtered resolution. If true, selection clauses will not
|
|
57
|
+
* be applied to the clients they are associated with.
|
|
58
|
+
* @param {boolean} [options.empty=false] Boolean flag indicating if a lack
|
|
59
|
+
* of clauses should correspond to an empty selection with no records. This
|
|
60
|
+
* setting determines the default selection state.
|
|
61
|
+
* @param {Selection|Selection[]} [options.include] Upstream selections whose
|
|
62
|
+
* clauses should be included as part of the new selection. Any clauses
|
|
63
|
+
* published to upstream selections will be relayed to the new selection.
|
|
64
|
+
* @returns {Selection} The new Selection instance.
|
|
65
|
+
*/
|
|
66
|
+
static single({ cross, empty, include }?: {
|
|
67
|
+
cross?: boolean;
|
|
68
|
+
empty?: boolean;
|
|
69
|
+
include?: Selection | Selection[];
|
|
70
|
+
}): Selection;
|
|
71
|
+
/**
|
|
72
|
+
* Create a new Selection instance with a
|
|
73
|
+
* cross-filtered intersect resolution strategy.
|
|
74
|
+
* @param {object} [options] The selection options.
|
|
75
|
+
* @param {boolean} [options.empty=false] Boolean flag indicating if a lack
|
|
76
|
+
* of clauses should correspond to an empty selection with no records. This
|
|
77
|
+
* setting determines the default selection state.
|
|
78
|
+
* @param {Selection|Selection[]} [options.include] Upstream selections whose
|
|
79
|
+
* clauses should be included as part of the new selection. Any clauses
|
|
80
|
+
* published to upstream selections will be relayed to the new selection.
|
|
81
|
+
* @returns {Selection} The new Selection instance.
|
|
82
|
+
*/
|
|
83
|
+
static crossfilter({ empty, include }?: {
|
|
84
|
+
empty?: boolean;
|
|
85
|
+
include?: Selection | Selection[];
|
|
86
|
+
}): Selection;
|
|
87
|
+
/**
|
|
88
|
+
* Create a new Selection instance.
|
|
89
|
+
* @param {SelectionResolver} [resolver] The selection resolution
|
|
90
|
+
* strategy to apply.
|
|
91
|
+
* @param {Selection[]} [include] Upstream selections whose clauses
|
|
92
|
+
* should be included as part of this selection. Any clauses published
|
|
93
|
+
* to these upstream selections will be relayed to this selection.
|
|
94
|
+
*/
|
|
95
|
+
constructor(resolver?: SelectionResolver, include?: Selection[]);
|
|
96
|
+
_resolved: any;
|
|
97
|
+
_resolver: SelectionResolver;
|
|
98
|
+
/** @type {Set<Selection>} */
|
|
99
|
+
_relay: Set<Selection>;
|
|
100
|
+
/**
|
|
101
|
+
* Create a cloned copy of this Selection instance.
|
|
102
|
+
* @returns {Selection} A clone of this selection.
|
|
103
|
+
*/
|
|
104
|
+
clone(): Selection;
|
|
105
|
+
/**
|
|
106
|
+
* Create a clone of this Selection with clauses corresponding
|
|
107
|
+
* to the provided source removed.
|
|
108
|
+
* @param {*} source The clause source to remove.
|
|
109
|
+
* @returns {Selection} A cloned and updated Selection.
|
|
110
|
+
*/
|
|
111
|
+
remove(source: any): Selection;
|
|
112
|
+
/**
|
|
113
|
+
* The selection clause resolver.
|
|
114
|
+
*/
|
|
115
|
+
get resolver(): SelectionResolver;
|
|
116
|
+
/**
|
|
117
|
+
* Indicate if this selection has a single resolution strategy.
|
|
118
|
+
*/
|
|
119
|
+
get single(): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* The current array of selection clauses.
|
|
122
|
+
*/
|
|
123
|
+
get clauses(): any;
|
|
124
|
+
/**
|
|
125
|
+
* The current active (most recently updated) selection clause.
|
|
126
|
+
*/
|
|
127
|
+
get active(): any;
|
|
128
|
+
/**
|
|
129
|
+
* The value corresponding to a given source. Returns undefined if
|
|
130
|
+
* this selection does not include a clause from this source.
|
|
131
|
+
* @param {*} source The clause source to look up the value for.
|
|
132
|
+
*/
|
|
133
|
+
valueFor(source: any): any;
|
|
134
|
+
/**
|
|
135
|
+
* Emit an activate event with the given selection clause.
|
|
136
|
+
* @param {*} clause The clause repesenting the potential activation.
|
|
137
|
+
*/
|
|
138
|
+
activate(clause: any): void;
|
|
139
|
+
/**
|
|
140
|
+
* Update the selection with a new selection clause.
|
|
141
|
+
* @param {*} clause The selection clause to add.
|
|
142
|
+
* @returns {this} This Selection instance.
|
|
143
|
+
*/
|
|
144
|
+
update(clause: any): this;
|
|
145
|
+
/**
|
|
146
|
+
* Indicates if a selection clause should not be applied to a given client.
|
|
147
|
+
* The return value depends on the selection resolution strategy.
|
|
148
|
+
* @param {*} client The selection clause.
|
|
149
|
+
* @param {*} clause The client to test.
|
|
150
|
+
* @returns True if the client should be skipped, false otherwise.
|
|
151
|
+
*/
|
|
152
|
+
skip(client: any, clause: any): any;
|
|
153
|
+
/**
|
|
154
|
+
* Return a selection query predicate for the given client.
|
|
155
|
+
* @param {*} client The client whose data may be filtered.
|
|
156
|
+
* @param {boolean} [noSkip=false] Disable skipping of active
|
|
157
|
+
* cross-filtered sources. If set true, the source of the active
|
|
158
|
+
* clause in a cross-filtered selection will not be skipped.
|
|
159
|
+
* @returns {*} The query predicate for filtering client data,
|
|
160
|
+
* based on the current state of this selection.
|
|
161
|
+
*/
|
|
162
|
+
predicate(client: any, noSkip?: boolean): any;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Implements selection clause resolution strategies.
|
|
166
|
+
*/
|
|
167
|
+
export class SelectionResolver {
|
|
168
|
+
/**
|
|
169
|
+
* Create a new selection resolved instance.
|
|
170
|
+
* @param {object} [options] The resolution strategy options.
|
|
171
|
+
* @param {boolean} [options.union=false] Boolean flag to indicate a union strategy.
|
|
172
|
+
* If false, an intersection strategy is used.
|
|
173
|
+
* @param {boolean} [options.cross=false] Boolean flag to indicate cross-filtering.
|
|
174
|
+
* @param {boolean} [options.single=false] Boolean flag to indicate single clauses only.
|
|
175
|
+
* @param {boolean} [options.empty=false] Boolean flag indicating if a lack
|
|
176
|
+
* of clauses should correspond to an empty selection with no records. This
|
|
177
|
+
* setting determines the default selection state.
|
|
178
|
+
*/
|
|
179
|
+
constructor({ union, cross, single, empty }?: {
|
|
180
|
+
union?: boolean;
|
|
181
|
+
cross?: boolean;
|
|
182
|
+
single?: boolean;
|
|
183
|
+
empty?: boolean;
|
|
184
|
+
});
|
|
185
|
+
union: boolean;
|
|
186
|
+
cross: boolean;
|
|
187
|
+
single: boolean;
|
|
188
|
+
empty: boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Resolve a list of selection clauses according to the resolution strategy.
|
|
191
|
+
* @param {*[]} clauseList An array of selection clauses.
|
|
192
|
+
* @param {*} clause A new selection clause to add.
|
|
193
|
+
* @returns {*[]} An updated array of selection clauses.
|
|
194
|
+
*/
|
|
195
|
+
resolve(clauseList: any[], clause: any, reset?: boolean): any[];
|
|
196
|
+
/**
|
|
197
|
+
* Indicates if a selection clause should not be applied to a given client.
|
|
198
|
+
* The return value depends on the resolution strategy.
|
|
199
|
+
* @param {*} client The selection clause.
|
|
200
|
+
* @param {*} clause The client to test.
|
|
201
|
+
* @returns True if the client should be skipped, false otherwise.
|
|
202
|
+
*/
|
|
203
|
+
skip(client: any, clause: any): any;
|
|
204
|
+
/**
|
|
205
|
+
* Return a selection query predicate for the given client.
|
|
206
|
+
* @param {import('./util/selection-types.js').SelectionClause[]} clauseList
|
|
207
|
+
* An array of selection clauses.
|
|
208
|
+
* @param {import('./util/selection-types.js').SelectionClause} active
|
|
209
|
+
* The current active selection clause.
|
|
210
|
+
* @param {MosaicClient} client The client whose data may be filtered.
|
|
211
|
+
* @returns {*} The query predicate for filtering client data,
|
|
212
|
+
* based on the current state of this selection.
|
|
213
|
+
*/
|
|
214
|
+
predicate(clauseList: import("./util/selection-types.js").SelectionClause[], active: import("./util/selection-types.js").SelectionClause, client: MosaicClient): any;
|
|
215
|
+
/**
|
|
216
|
+
* Returns a filter function for queued selection updates.
|
|
217
|
+
* @param {*} value The new event value that will be enqueued.
|
|
218
|
+
* @returns {(value: *) => boolean|null} A dispatch queue filter
|
|
219
|
+
* function, or null if all unemitted event values should be filtered.
|
|
220
|
+
*/
|
|
221
|
+
queueFilter(value: any): (value: any) => boolean | null;
|
|
222
|
+
}
|
|
223
|
+
import { Param } from './Param.js';
|
|
224
|
+
import { MosaicClient } from './MosaicClient.js';
|