@xh/hoist 75.0.0-SNAPSHOT.1754329446115 → 75.0.0-SNAPSHOT.1754347635253
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/CHANGELOG.md +9 -1
- package/admin/tabs/activity/tracking/ActivityTrackingModel.ts +4 -36
- package/build/types/admin/tabs/activity/tracking/ActivityTrackingModel.d.ts +0 -2
- package/build/types/data/Store.d.ts +1 -0
- package/build/types/data/cube/BucketSpec.d.ts +3 -0
- package/build/types/data/cube/Cube.d.ts +42 -41
- package/build/types/data/cube/Query.d.ts +57 -23
- package/build/types/data/cube/View.d.ts +21 -21
- package/build/types/data/cube/ViewRowData.d.ts +40 -0
- package/build/types/data/cube/row/AggregateRow.d.ts +4 -1
- package/build/types/data/cube/row/BaseRow.d.ts +7 -4
- package/build/types/data/cube/row/BucketRow.d.ts +5 -1
- package/build/types/data/cube/row/LeafRow.d.ts +6 -5
- package/build/types/data/index.d.ts +1 -0
- package/data/Store.ts +35 -7
- package/data/cube/BucketSpec.ts +3 -0
- package/data/cube/Cube.ts +48 -47
- package/data/cube/Query.ts +72 -24
- package/data/cube/View.ts +30 -26
- package/data/cube/ViewRowData.ts +66 -0
- package/data/cube/row/AggregateRow.ts +5 -2
- package/data/cube/row/BaseRow.ts +30 -20
- package/data/cube/row/BucketRow.ts +5 -1
- package/data/cube/row/LeafRow.ts +8 -6
- package/data/index.ts +1 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -25,9 +25,15 @@
|
|
|
25
25
|
operation fails. Set to `false` to fail silently (the behavior prior to this change).
|
|
26
26
|
* Added new `Cube.modifyRecordsAsync` for modifying individual field values in a local uncommitted
|
|
27
27
|
state. Additionally enhanced `Store.modifyRecords` to return a `StoreChangeLog` of updates.
|
|
28
|
+
* Cube Views now emit data objects of type `ViewRowData`, rather than an anonymous `PlainObject`.
|
|
29
|
+
This new object supports several documented properties, including a useful `cubeLeaves` property,
|
|
30
|
+
which can be activated via the `Query.provideLeaves` property.
|
|
31
|
+
|
|
32
|
+
|
|
28
33
|
|
|
29
34
|
### 🐞 Bug Fixes
|
|
30
|
-
* Fixed
|
|
35
|
+
* Fixed bugs where `Store.modifyRecords`, `Store.revertRecords` and `Store.revert` were not properly
|
|
36
|
+
handling changes to `SummaryRecords`.
|
|
31
37
|
|
|
32
38
|
### 🐞 Bug Fixes
|
|
33
39
|
|
|
@@ -59,6 +65,8 @@
|
|
|
59
65
|
* Removed deprecated `FetchService.setDefaultHeaders`
|
|
60
66
|
* Removed deprecated `FetchService.setDefaultTimeout`
|
|
61
67
|
* Removed deprecated `IdentityService.logoutAsync`
|
|
68
|
+
* Change to the row objects returned by `View`: the undocumented `_meta` and `buckets` properties
|
|
69
|
+
have been removed. Use the documented properties on the new `ViewRowData` class instead.
|
|
62
70
|
|
|
63
71
|
### ✨ Styles
|
|
64
72
|
|
|
@@ -16,7 +16,7 @@ import {FormModel} from '@xh/hoist/cmp/form';
|
|
|
16
16
|
import {ColumnRenderer, ColumnSpec, GridModel, TreeStyle} from '@xh/hoist/cmp/grid';
|
|
17
17
|
import {GroupingChooserModel} from '@xh/hoist/cmp/grouping';
|
|
18
18
|
import {HoistModel, LoadSpec, managed, PlainObject, XH} from '@xh/hoist/core';
|
|
19
|
-
import {Cube, CubeFieldSpec, FieldSpec,
|
|
19
|
+
import {Cube, CubeFieldSpec, FieldSpec, ViewRowData} from '@xh/hoist/data';
|
|
20
20
|
import {dateRenderer, dateTimeSecRenderer, numberRenderer} from '@xh/hoist/format';
|
|
21
21
|
import {action, computed, makeObservable, observable} from '@xh/hoist/mobx';
|
|
22
22
|
import {LocalDate} from '@xh/hoist/utils/datetime';
|
|
@@ -135,7 +135,8 @@ export class ActivityTrackingModel extends HoistModel implements ActivityDetailP
|
|
|
135
135
|
},
|
|
136
136
|
{
|
|
137
137
|
track: () => this.gridModel.selectedRecords,
|
|
138
|
-
run: recs =>
|
|
138
|
+
run: recs =>
|
|
139
|
+
(this.trackLogs = recs.flatMap(r => (r.raw as ViewRowData).cubeLeaves)),
|
|
139
140
|
debounce: 100
|
|
140
141
|
}
|
|
141
142
|
);
|
|
@@ -231,29 +232,13 @@ export class ActivityTrackingModel extends HoistModel implements ActivityDetailP
|
|
|
231
232
|
data = cube.executeQuery({
|
|
232
233
|
dimensions,
|
|
233
234
|
includeRoot: true,
|
|
234
|
-
|
|
235
|
+
provideLeaves: true
|
|
235
236
|
});
|
|
236
237
|
|
|
237
|
-
data.forEach(node => this.separateLeafRows(node));
|
|
238
238
|
gridModel.loadData(data);
|
|
239
239
|
await gridModel.preSelectFirstAsync();
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
// Cube emits leaves in "children" collection - rename that collection to "leafRows" so we can
|
|
243
|
-
// carry the leaves with the record, but deliberately not show them in the tree grid. We only
|
|
244
|
-
// want the tree grid to show aggregate records.
|
|
245
|
-
private separateLeafRows(node) {
|
|
246
|
-
if (isEmpty(node.children)) return;
|
|
247
|
-
|
|
248
|
-
const childrenAreLeaves = !node.children[0].children;
|
|
249
|
-
if (childrenAreLeaves) {
|
|
250
|
-
node.leafRows = node.children;
|
|
251
|
-
delete node.children;
|
|
252
|
-
} else {
|
|
253
|
-
node.children.forEach(child => this.separateLeafRows(child));
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
242
|
private cubeLabelComparator(valA, valB, sortDir, abs, {recordA, recordB, defaultComparator}) {
|
|
258
243
|
const rawA = recordA?.raw,
|
|
259
244
|
rawB = recordB?.raw,
|
|
@@ -291,23 +276,6 @@ export class ActivityTrackingModel extends HoistModel implements ActivityDetailP
|
|
|
291
276
|
};
|
|
292
277
|
}
|
|
293
278
|
|
|
294
|
-
// Extract all leaf, track-entry-level rows from an aggregate record (at any level).
|
|
295
|
-
private getAllLeafRows(aggRecs: StoreRecord[], ret = []): PlainObject[] {
|
|
296
|
-
if (isEmpty(aggRecs)) return [];
|
|
297
|
-
|
|
298
|
-
aggRecs.forEach(aggRec => {
|
|
299
|
-
if (aggRec.children.length) {
|
|
300
|
-
this.getAllLeafRows(aggRec.children, ret);
|
|
301
|
-
} else if (aggRec.raw.leafRows) {
|
|
302
|
-
aggRec.raw.leafRows.forEach(leaf => {
|
|
303
|
-
ret.push({...leaf});
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
return ret;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
279
|
//------------------------
|
|
312
280
|
// Impl - core data models
|
|
313
281
|
//------------------------
|
|
@@ -49,11 +49,9 @@ export declare class ActivityTrackingModel extends HoistModel implements Activit
|
|
|
49
49
|
getDisplayName(fieldName: string): string;
|
|
50
50
|
private createQueryFormModel;
|
|
51
51
|
private loadGridAsync;
|
|
52
|
-
private separateLeafRows;
|
|
53
52
|
private cubeLabelComparator;
|
|
54
53
|
private getComparableValForDim;
|
|
55
54
|
private get query();
|
|
56
|
-
private getAllLeafRows;
|
|
57
55
|
private createAndSetCoreModels;
|
|
58
56
|
private createCube;
|
|
59
57
|
private createFilterChooserModel;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HoistBase, PlainObject, Some } from '@xh/hoist/core';
|
|
2
2
|
import { CubeField, CubeFieldSpec } from './CubeField';
|
|
3
|
+
import { ViewRowData } from './ViewRowData';
|
|
3
4
|
import { QueryConfig } from './Query';
|
|
4
5
|
import { View } from './View';
|
|
5
6
|
import { Store, StoreRecordIdSpec, StoreTransaction } from '../Store';
|
|
@@ -36,6 +37,32 @@ export interface CubeConfig {
|
|
|
36
37
|
*/
|
|
37
38
|
omitFn?: OmitFn;
|
|
38
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Function to be called for each node to aggregate to determine if it should be "locked",
|
|
42
|
+
* preventing drilldown into its children. If true returned for a node, no drilldown will be
|
|
43
|
+
* allowed, and the row will be marked with a boolean "locked" property.
|
|
44
|
+
*/
|
|
45
|
+
export type LockFn = (row: AggregateRow | BucketRow) => boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Function to be called for each node during row generation to determine if it should be
|
|
48
|
+
* skipped in tree output. Useful for removing aggregates that are degenerate due to context.
|
|
49
|
+
* Note that skipping in this way has no effect on aggregations -- all children of this node are
|
|
50
|
+
* simply promoted to their parent node.
|
|
51
|
+
*/
|
|
52
|
+
export type OmitFn = (row: AggregateRow | BucketRow) => boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Function to be called for rows making up an aggregated dimension to determine if the children of
|
|
55
|
+
* that dimension should be dynamically bucketed into additional sub-groupings.
|
|
56
|
+
*
|
|
57
|
+
* An example use case would be a grouped collection of portfolio positions, where any closed
|
|
58
|
+
* positions are identified as such by this function and bucketed into a "Closed" sub-grouping,
|
|
59
|
+
* without having to add something like an "openClosed" dimension that would apply to all
|
|
60
|
+
* aggregations and create an unwanted "Open" grouping.
|
|
61
|
+
*
|
|
62
|
+
* @param rows - the rows being checked for bucketing
|
|
63
|
+
* @returns BucketSpec for configuring dynamic sub-aggregations, or null to perform no bucketing.
|
|
64
|
+
*/
|
|
65
|
+
export type BucketSpecFn = (rows: BaseRow[]) => BucketSpec;
|
|
39
66
|
/**
|
|
40
67
|
* A data store that supports grouping, aggregating, and filtering data on multiple dimensions.
|
|
41
68
|
*
|
|
@@ -74,41 +101,37 @@ export declare class Cube extends HoistBase {
|
|
|
74
101
|
* @param query - Config for query defining the shape of the view.
|
|
75
102
|
* @returns data containing the results of the query as a hierarchical set of rows.
|
|
76
103
|
*/
|
|
77
|
-
executeQuery(query: QueryConfig):
|
|
104
|
+
executeQuery(query: QueryConfig): ViewRowData[];
|
|
78
105
|
/**
|
|
79
|
-
* Create a View on
|
|
106
|
+
* Create a dynamic {@link View} of the cube data based on a query. Unlike the static snapshot
|
|
107
|
+
* returned by {@link Cube.executeQuery}, a View created with this method can be configured
|
|
108
|
+
* with `connect:true` to automatically update as the underlying data in the Cube changes.
|
|
80
109
|
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
110
|
+
* Provide one or more `stores` to automatically populate them with the aggregated data returned
|
|
111
|
+
* by the query, or read the returned {@link View.result} directly.
|
|
83
112
|
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
113
|
+
* When the returned View is no longer needed, call {@link View.destroy} (or save a reference
|
|
114
|
+
* via an `@managed` model property) to avoid unnecessary processing.
|
|
86
115
|
*
|
|
87
116
|
* @param query - query to be used to construct this view.
|
|
88
|
-
* @param stores - Stores to be loaded/reloaded with
|
|
89
|
-
*
|
|
90
|
-
* @param connect - true to update View automatically when data in
|
|
91
|
-
* the underlying cube is changed. Default false.
|
|
117
|
+
* @param stores - Stores to be automatically loaded/reloaded with View results.
|
|
118
|
+
* @param connect - true to update View automatically when data in the underlying Cube changes.
|
|
92
119
|
*/
|
|
93
120
|
createView({ query, stores, connect }: {
|
|
94
121
|
query: QueryConfig;
|
|
95
122
|
stores?: Store[] | Store;
|
|
96
123
|
connect?: boolean;
|
|
97
124
|
}): View;
|
|
98
|
-
/**
|
|
99
|
-
* True if the provided view is connected to this Cube for live updates.
|
|
100
|
-
*/
|
|
125
|
+
/** True if the provided view is connected to this Cube for live updates. */
|
|
101
126
|
viewIsConnected(view: View): boolean;
|
|
102
|
-
/**
|
|
127
|
+
/** Cease pushing further updates to this Cube's data into a previously connected View. */
|
|
103
128
|
disconnectView(view: View): void;
|
|
104
129
|
/**
|
|
105
130
|
* Populate this cube with a new dataset.
|
|
131
|
+
* This method largely delegates to {@link Store.loadData} - see that method for more info.
|
|
106
132
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* Note that this method will update its views asynchronously, in order to avoid locking
|
|
111
|
-
* up the browser when attached to multiple expensive views.
|
|
133
|
+
* Note that this method will update its views asynchronously in order to avoid locking up the
|
|
134
|
+
* browser when attached to multiple expensive views.
|
|
112
135
|
*
|
|
113
136
|
* @param rawData - flat array of lowest/leaf level data rows.
|
|
114
137
|
* @param info - optional metadata to associate with this cube/dataset.
|
|
@@ -150,25 +173,3 @@ export declare class Cube extends HoistBase {
|
|
|
150
173
|
private parseFields;
|
|
151
174
|
destroy(): void;
|
|
152
175
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Function to be called for each node to aggregate to determine if it should be "locked",
|
|
155
|
-
* preventing drilldown into its children. If true returned for a node, no drilldown will be
|
|
156
|
-
* allowed, and the row will be marked with a boolean "locked" property.
|
|
157
|
-
*/
|
|
158
|
-
export type LockFn = (row: AggregateRow | BucketRow) => boolean;
|
|
159
|
-
/**
|
|
160
|
-
* Function to be called for each node during row generation to determine if it should be
|
|
161
|
-
* skipped in tree output. Useful for removing aggregates that are degenerate due to context.
|
|
162
|
-
* Note that skipping in this way has no effect on aggregations -- all children of this node are
|
|
163
|
-
* simply promoted to their parent node.
|
|
164
|
-
*/
|
|
165
|
-
export type OmitFn = (row: AggregateRow | BucketRow) => boolean;
|
|
166
|
-
/**
|
|
167
|
-
* Function to be called for each dimension to determine if children of said dimension should be
|
|
168
|
-
* bucketed into additional dynamic dimensions.
|
|
169
|
-
*
|
|
170
|
-
* @param rows - the rows being checked for bucketing
|
|
171
|
-
* @returns a BucketSpec for configuring the bucket to place child rows into, or null to perform
|
|
172
|
-
* no bucketing
|
|
173
|
-
*/
|
|
174
|
-
export type BucketSpecFn = (rows: BaseRow[]) => BucketSpec;
|
|
@@ -1,41 +1,68 @@
|
|
|
1
|
-
import { BucketSpecFn, Filter, LockFn, OmitFn, StoreRecord } from '@xh/hoist/data';
|
|
2
|
-
import { FilterLike } from '../filter/Types';
|
|
3
|
-
import { CubeField } from './CubeField';
|
|
1
|
+
import { BucketSpecFn, Filter, FilterLike, LockFn, OmitFn, StoreRecord } from '@xh/hoist/data';
|
|
4
2
|
import { Cube } from './Cube';
|
|
3
|
+
import { CubeField } from './CubeField';
|
|
5
4
|
/**
|
|
6
|
-
* Queries determine what data is extracted
|
|
7
|
-
*
|
|
8
|
-
* Note that if no dimensions are provided, 'includeRoot' or 'includeLeaves' should be true -
|
|
9
|
-
* otherwise no data will be returned!
|
|
5
|
+
* Queries determine what data is extracted, grouped, and aggregated from a {@link Cube}.
|
|
10
6
|
*/
|
|
11
7
|
export interface QueryConfig {
|
|
12
8
|
/**
|
|
13
|
-
*
|
|
14
|
-
* itself on the query config (automatically)
|
|
9
|
+
* The Cube to query. Required, but note that the preferred {@link Cube.executeQuery} API will
|
|
10
|
+
* install a reference to itself on the query config (automatically).
|
|
15
11
|
*/
|
|
16
12
|
cube?: Cube;
|
|
17
13
|
/**
|
|
18
|
-
* Fields or field names. If unspecified will include all available fields
|
|
19
|
-
*
|
|
14
|
+
* Fields or field names. If unspecified will include all available {@link Cube.fields}.
|
|
15
|
+
* Specify a subset to optimize aggregation performance.
|
|
20
16
|
*/
|
|
21
17
|
fields?: string[] | CubeField[];
|
|
22
18
|
/**
|
|
23
|
-
* Fields or field names
|
|
24
|
-
*
|
|
19
|
+
* Fields or field names on which data should be grouped and aggregated. These are the ordered
|
|
20
|
+
* grouping levels in the resulting hierarchy - e.g. ['Country', 'State', 'City'].
|
|
21
|
+
*
|
|
22
|
+
* Any fields provided here must also be included in the `fields` array, if specified.
|
|
23
|
+
*
|
|
24
|
+
* If not provided or empty, the resulting data will not be grouped. Specify 'includeRoot' or
|
|
25
|
+
* 'includeLeaves' in that case, otherwise no data will be returned.
|
|
25
26
|
*/
|
|
26
27
|
dimensions?: string[] | CubeField[];
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
29
|
+
* Filters to apply to leaf data, or configs to create. Note that leaf data will be filtered
|
|
30
|
+
* and then aggregated - i.e. the filters provided here will filter in/out the lowest level
|
|
31
|
+
* facts and _won't_ operate directly on any aggregates.
|
|
32
|
+
*
|
|
33
|
+
* Arrays will be combined into a single 'AND' CompoundFilter.
|
|
30
34
|
*/
|
|
31
35
|
filter?: FilterLike;
|
|
32
36
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
37
|
+
* True to include a synthetic root node in the return with grand totals (aggregations across
|
|
38
|
+
* all data returned by the query). Pairs well with {@link StoreConfig.loadRootAsSummary} and
|
|
39
|
+
* {@link GridConfig.showSummary} to display a docked grand total row for grids rendering
|
|
40
|
+
* Cube results.
|
|
35
41
|
*/
|
|
36
42
|
includeRoot?: boolean;
|
|
37
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* True to include leaf nodes (the "flat" facts originally loaded into the Cube) as the
|
|
45
|
+
* {@link ViewRowData.children} of the lowest level of aggregated `dimensions`.
|
|
46
|
+
*
|
|
47
|
+
* False (the default) to only return aggregate rows based on requested `dimensions`.
|
|
48
|
+
*
|
|
49
|
+
* Useful when you wish to e.g. load Cube results into a tree grid and allow users to expand
|
|
50
|
+
* aggregated groups all the way out to see the source data. See also `provideLeaves`, which
|
|
51
|
+
* will provide access to these nodes without exposing as `children`.
|
|
52
|
+
*/
|
|
38
53
|
includeLeaves?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* True to provide access to leaf nodes via the {@link ViewRowData.cubeLeaves} getter on the
|
|
56
|
+
* lowest level of aggregated `dimensions`. This will allow programmatic access to the leaves
|
|
57
|
+
* used to produce a given aggregation, without exposing them as `children` in a way that would
|
|
58
|
+
* cause them to be rendered in a tree grid.
|
|
59
|
+
*
|
|
60
|
+
* Useful when e.g. a full leaf-level drill-down is not desired, but the app still needs
|
|
61
|
+
* access to those leaves to display in a separate view or for further processing.
|
|
62
|
+
*
|
|
63
|
+
* See also the more common `includeLeaves`.
|
|
64
|
+
*/
|
|
65
|
+
provideLeaves?: boolean;
|
|
39
66
|
/**
|
|
40
67
|
* True (default) to recursively omit single-child parents in the hierarchy.
|
|
41
68
|
* Apps can implement further omit logic using `omitFn`.
|
|
@@ -43,13 +70,20 @@ export interface QueryConfig {
|
|
|
43
70
|
omitRedundantNodes?: boolean;
|
|
44
71
|
/**
|
|
45
72
|
* Optional function to be called for each aggregate node to determine if it should be "locked",
|
|
46
|
-
* preventing drill-down into its children.
|
|
73
|
+
* preventing drill-down into its children.
|
|
74
|
+
*
|
|
75
|
+
* Defaults to {@link Cube.lockFn}.
|
|
47
76
|
*/
|
|
48
77
|
lockFn?: LockFn;
|
|
49
78
|
/**
|
|
50
79
|
* Optional function to be called for each dimension during row generation to determine if the
|
|
51
80
|
* children of that dimension should be bucketed into additional dynamic dimensions.
|
|
52
|
-
*
|
|
81
|
+
*
|
|
82
|
+
* This can be used to break selected aggregations into sub-groups dynamically, without having
|
|
83
|
+
* to define another dimension in the Cube and have it apply to all aggregations. See the
|
|
84
|
+
* {@link BucketSpec} interface for additional information.
|
|
85
|
+
*
|
|
86
|
+
* Defaults to {@link Cube.bucketSpecFn}.
|
|
53
87
|
*/
|
|
54
88
|
bucketSpecFn?: BucketSpecFn;
|
|
55
89
|
/**
|
|
@@ -65,13 +99,14 @@ export declare class Query {
|
|
|
65
99
|
readonly filter: Filter;
|
|
66
100
|
readonly includeRoot: boolean;
|
|
67
101
|
readonly includeLeaves: boolean;
|
|
102
|
+
readonly provideLeaves: boolean;
|
|
68
103
|
readonly omitRedundantNodes: boolean;
|
|
69
104
|
readonly cube: Cube;
|
|
70
105
|
readonly lockFn: LockFn;
|
|
71
106
|
readonly bucketSpecFn: BucketSpecFn;
|
|
72
107
|
readonly omitFn: OmitFn;
|
|
73
108
|
private readonly _testFn;
|
|
74
|
-
constructor({ cube, fields, dimensions, filter, includeRoot, includeLeaves, omitRedundantNodes, lockFn, bucketSpecFn, omitFn }: QueryConfig);
|
|
109
|
+
constructor({ cube, fields, dimensions, filter, includeRoot, includeLeaves, provideLeaves, omitRedundantNodes, lockFn, bucketSpecFn, omitFn }: QueryConfig);
|
|
75
110
|
clone(overrides: Partial<QueryConfig>): Query;
|
|
76
111
|
test(record: StoreRecord): boolean;
|
|
77
112
|
/**
|
|
@@ -79,8 +114,7 @@ export declare class Query {
|
|
|
79
114
|
*/
|
|
80
115
|
equals(other: Query): boolean;
|
|
81
116
|
/**
|
|
82
|
-
* True if the provided other Query is equivalent to this instance,
|
|
83
|
-
* not considering the filter.
|
|
117
|
+
* True if the provided other Query is equivalent to this instance, not considering the filter.
|
|
84
118
|
*/
|
|
85
119
|
equalsExcludingFilter(other: Query): boolean;
|
|
86
120
|
private parseFields;
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import { HoistBase, PlainObject, Some } from '@xh/hoist/core';
|
|
2
2
|
import { Cube, CubeField, Filter, FilterLike, Query, QueryConfig, Store, StoreRecordId } from '@xh/hoist/data';
|
|
3
|
+
import { ViewRowData } from '@xh/hoist/data/cube/ViewRowData';
|
|
3
4
|
import { AggregationContext } from './aggregate/AggregationContext';
|
|
5
|
+
import { BaseRow } from './row/BaseRow';
|
|
4
6
|
import { LeafRow } from './row/LeafRow';
|
|
5
7
|
export interface ViewConfig {
|
|
6
8
|
/** Query to be used to construct this view. */
|
|
7
9
|
query: Query;
|
|
8
10
|
/**
|
|
9
|
-
* Store(s) to be automatically (re)loaded with data from this view.
|
|
10
|
-
*
|
|
11
|
+
* Store(s) to be automatically (re)loaded with data from this view.
|
|
12
|
+
* Optional - read {@link View.result} directly to use without a Store.
|
|
11
13
|
*/
|
|
12
14
|
stores?: Store[] | Store;
|
|
13
15
|
/**
|
|
14
|
-
* True to reactively update the View's
|
|
15
|
-
* underlying Cube
|
|
16
|
-
* a snapshot without further updates
|
|
16
|
+
* True to reactively update the View's {@link View.result} and any connected store(s) when data
|
|
17
|
+
* in the underlying Cube changes. False (default) to have this view run its query once to
|
|
18
|
+
* capture a snapshot without further (automatic) updates.
|
|
17
19
|
*/
|
|
18
20
|
connect?: boolean;
|
|
19
21
|
}
|
|
22
|
+
export interface ViewResult {
|
|
23
|
+
rows: ViewRowData[];
|
|
24
|
+
leafMap: Map<StoreRecordId, LeafRow>;
|
|
25
|
+
}
|
|
20
26
|
export interface DimensionValue {
|
|
21
27
|
/** Dimension field. */
|
|
22
28
|
field: CubeField;
|
|
@@ -29,27 +35,24 @@ export interface DimensionValue {
|
|
|
29
35
|
*/
|
|
30
36
|
export declare class View extends HoistBase {
|
|
31
37
|
get isView(): boolean;
|
|
32
|
-
/** Query defining this View. Update via
|
|
38
|
+
/** Query defining this View. Update via {@link updateQuery}. */
|
|
33
39
|
query: Query;
|
|
34
40
|
/**
|
|
35
|
-
* Results of this view, an observable object with a `rows` property
|
|
36
|
-
*
|
|
41
|
+
* Results of this view, an observable object with a `rows` property containing an array of
|
|
42
|
+
* hierarchical {@link ViewRowData} objects.
|
|
37
43
|
*/
|
|
38
|
-
result:
|
|
39
|
-
rows: PlainObject[];
|
|
40
|
-
leafMap: Map<StoreRecordId, LeafRow>;
|
|
41
|
-
};
|
|
44
|
+
result: ViewResult;
|
|
42
45
|
/** Stores to which results of this view should be (re)loaded. */
|
|
43
46
|
stores: Store[];
|
|
44
|
-
/** Cube
|
|
47
|
+
/** The source {@link Cube.info} as of the last time this View was updated. */
|
|
45
48
|
info: PlainObject;
|
|
46
|
-
/**
|
|
49
|
+
/** Timestamp (ms) of the last time this view's data was changed. */
|
|
47
50
|
lastUpdated: number;
|
|
48
|
-
private
|
|
49
|
-
private _rowCache;
|
|
51
|
+
private _rowDatas;
|
|
50
52
|
private _leafMap;
|
|
51
53
|
private _recordMap;
|
|
52
54
|
_aggContext: AggregationContext;
|
|
55
|
+
_rowCache: Map<string, BaseRow>;
|
|
53
56
|
/** @internal - applications should use {@link Cube.createView} */
|
|
54
57
|
constructor(config: ViewConfig);
|
|
55
58
|
get cube(): Cube;
|
|
@@ -64,13 +67,10 @@ export declare class View extends HoistBase {
|
|
|
64
67
|
* Change the query in some way, re-computing the data in this View to reflect the new query.
|
|
65
68
|
*
|
|
66
69
|
* @param overrides - changes to be applied to the query. May include any arguments to the query
|
|
67
|
-
* constructor except `cube`, which cannot be changed
|
|
68
|
-
* via the initial query.
|
|
70
|
+
* constructor except `cube`, which cannot be changed once set via the initial query.
|
|
69
71
|
*/
|
|
70
72
|
updateQuery(overrides: Partial<QueryConfig>): void;
|
|
71
|
-
/**
|
|
72
|
-
* Gathers all unique values for each dimension field in the query
|
|
73
|
-
*/
|
|
73
|
+
/** Gather all unique values for each dimension field in the query. */
|
|
74
74
|
getDimensionValues(): DimensionValue[];
|
|
75
75
|
/** Get a specific Field by name.*/
|
|
76
76
|
getField(name: string): CubeField;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PlainObject, Some } from '@xh/hoist/core';
|
|
2
|
+
/**
|
|
3
|
+
* Grouped node data, as returned by {@link Cube.executeQuery} or exposed via {@link View.result}.
|
|
4
|
+
* Designed for direct consumption by hierarchical stores and their associated tree grids.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ViewRowData implements PlainObject {
|
|
7
|
+
constructor(id: string);
|
|
8
|
+
/** Unique id. */
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* Label of the row. The dimension value or, for leaf rows. the underlying cubeId.
|
|
12
|
+
* Suitable for display, although apps will typically wish to customize leaf row rendering.
|
|
13
|
+
*/
|
|
14
|
+
cubeLabel: string;
|
|
15
|
+
/** Dimension on which this row was computed, or null for leaf rows. */
|
|
16
|
+
cubeDimension: string;
|
|
17
|
+
/**
|
|
18
|
+
* Buckets this row appears in
|
|
19
|
+
*/
|
|
20
|
+
cubeBuckets: Record<string, any>;
|
|
21
|
+
/**
|
|
22
|
+
* Visible children of this row.
|
|
23
|
+
*
|
|
24
|
+
* Note that this may not be the same as the simple aggregation children of this row. In
|
|
25
|
+
* particular, this property is subject to the semantics of row locking, redundant row omission,
|
|
26
|
+
* and bucketing as defined by the Query.
|
|
27
|
+
*/
|
|
28
|
+
children: ViewRowData[];
|
|
29
|
+
/** True for leaf rows loaded into the cube (i.e. not a grouped aggregation). */
|
|
30
|
+
get isCubeLeaf(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* All visible (i.e. non-locked) cube leaves associated with this row.
|
|
33
|
+
*
|
|
34
|
+
* For this to be populated, either {@link Query.includeLeaves} or {@link Query.provideLeaves}
|
|
35
|
+
* must have been set on the underlying Query.
|
|
36
|
+
*/
|
|
37
|
+
get cubeLeaves(): Some<ViewRowData>;
|
|
38
|
+
/** @internal */
|
|
39
|
+
_cubeLeafChildren: ViewRowData[];
|
|
40
|
+
}
|
|
@@ -3,10 +3,13 @@ import { CubeField } from '../CubeField';
|
|
|
3
3
|
import { View } from '../View';
|
|
4
4
|
import { BaseRow } from './BaseRow';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Row within a dataset produced by a Cube / View representing aggregated data on a dimension.
|
|
7
|
+
*
|
|
8
|
+
* This is an internal data structure - {@link ViewRowData} is the public row-level data API.
|
|
7
9
|
*/
|
|
8
10
|
export declare class AggregateRow extends BaseRow {
|
|
9
11
|
get isAggregate(): boolean;
|
|
12
|
+
/** The dimension for which this row is aggregating data. Null for a top-level summary row. */
|
|
10
13
|
readonly dim: CubeField;
|
|
11
14
|
readonly dimName: string;
|
|
12
15
|
constructor(view: View, id: string, children: BaseRow[], dim: CubeField, val: any, strVal: string, appliedDimensions: PlainObject);
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { PlainObject, Some } from '@xh/hoist/core';
|
|
2
2
|
import { BucketSpec } from '@xh/hoist/data/cube/BucketSpec';
|
|
3
|
+
import { ViewRowData } from '@xh/hoist/data/cube/ViewRowData';
|
|
3
4
|
import { View } from '../View';
|
|
4
5
|
import { RowUpdate } from './RowUpdate';
|
|
5
6
|
/**
|
|
6
|
-
* Base class for a
|
|
7
|
+
* Base class for a row within a dataset produced by a Cube / View.
|
|
8
|
+
*
|
|
9
|
+
* This is an internal data structure - {@link ViewRowData} is the public row-level data API.
|
|
7
10
|
*/
|
|
8
11
|
export declare abstract class BaseRow {
|
|
9
12
|
readonly view: View;
|
|
10
13
|
readonly id: string;
|
|
11
|
-
readonly data:
|
|
14
|
+
readonly data: ViewRowData;
|
|
12
15
|
parent: BaseRow;
|
|
13
16
|
children: BaseRow[];
|
|
14
17
|
locked: boolean;
|
|
@@ -18,8 +21,8 @@ export declare abstract class BaseRow {
|
|
|
18
21
|
get isBucket(): boolean;
|
|
19
22
|
constructor(view: View, id: string);
|
|
20
23
|
noteBucketed(bucketSpec: BucketSpec, bucketVal: any): void;
|
|
21
|
-
getVisibleDatas(): Some<
|
|
22
|
-
private
|
|
24
|
+
getVisibleDatas(): Some<ViewRowData>;
|
|
25
|
+
private getChildrenDatas;
|
|
23
26
|
private isRedundantChild;
|
|
24
27
|
protected initAggregate(children: BaseRow[], dimOrBucketName: string, val: any, appliedDimensions: PlainObject): void;
|
|
25
28
|
applyDataUpdate(childUpdates: RowUpdate[], updatedRowDatas: Set<PlainObject>): void;
|
|
@@ -3,7 +3,11 @@ import { BaseRow } from './BaseRow';
|
|
|
3
3
|
import { BucketSpec } from '../BucketSpec';
|
|
4
4
|
import { View } from '../View';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Row within a dataset produced by a Cube / View representing aggregated data on a dimension that
|
|
7
|
+
* has been further grouped into a dynamic child "bucket" - a subset of the dimension-level
|
|
8
|
+
* {@link AggregateRow} produced as per a specified {@link Query.bucketSpecFn}.
|
|
9
|
+
*
|
|
10
|
+
* This is an internal data structure - {@link ViewRowData} is the public row-level data API.
|
|
7
11
|
*/
|
|
8
12
|
export declare class BucketRow extends BaseRow {
|
|
9
13
|
get isBucket(): boolean;
|
|
@@ -3,15 +3,16 @@ import { StoreRecord, StoreRecordId } from '@xh/hoist/data';
|
|
|
3
3
|
import { View } from '../View';
|
|
4
4
|
import { BaseRow } from './BaseRow';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* not computed aggregates - although the data they contain is a shallow copy of the original and
|
|
6
|
+
* Row within a dataset produced by a Cube or View representing leaf-level data. These rows have a
|
|
7
|
+
* 1-1 relationship with the source records loaded into the Cube's internal store - i.e. they are
|
|
8
|
+
* not computed aggregates, although the data they contain is a shallow copy of the original and
|
|
10
9
|
* limited to the fields requested by the View / Query that produced them.
|
|
10
|
+
*
|
|
11
|
+
* This is an internal data structure - {@link ViewRowData} is the public row-level data API.
|
|
11
12
|
*/
|
|
12
13
|
export declare class LeafRow extends BaseRow {
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
+
* ID of the `StoreRecord` within the Cube that was used to construct this leaf row.
|
|
15
16
|
* Useful if you need to update this leaf's data via {@link Cube.updateDataAsync}.
|
|
16
17
|
*/
|
|
17
18
|
readonly cubeRecordId: StoreRecordId;
|
|
@@ -26,6 +26,7 @@ export * from './cube/Cube';
|
|
|
26
26
|
export * from './cube/CubeField';
|
|
27
27
|
export * from './cube/Query';
|
|
28
28
|
export * from './cube/View';
|
|
29
|
+
export * from './cube/ViewRowData';
|
|
29
30
|
export * from './validation/constraints';
|
|
30
31
|
export * from './validation/Rule';
|
|
31
32
|
export * from './validation/ValidationState';
|