@xh/hoist 78.0.0-SNAPSHOT.1763737348746 → 79.0.0-SNAPSHOT.1763737948137
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 +4 -3
- package/build/types/core/types/Types.d.ts +2 -0
- package/build/types/data/cube/BucketSpec.d.ts +4 -9
- package/build/types/data/cube/Cube.d.ts +3 -3
- package/build/types/data/cube/Query.d.ts +1 -1
- package/core/types/Types.ts +3 -0
- package/data/cube/BucketSpec.ts +7 -10
- package/data/cube/Cube.ts +3 -3
- package/data/cube/Query.ts +1 -1
- package/data/cube/View.ts +2 -7
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 79.0.0-SNAPSHOT - unreleased
|
|
4
|
+
|
|
5
|
+
## 78.0.0 - 2025-11-21
|
|
4
6
|
|
|
5
7
|
### 💥 Breaking Changes
|
|
6
8
|
|
|
@@ -27,8 +29,7 @@
|
|
|
27
29
|
|
|
28
30
|
### ⚙️ Technical
|
|
29
31
|
|
|
30
|
-
*
|
|
31
|
-
before) or a plain object conforming to the new `BucketSpecConfig` interface.
|
|
32
|
+
* Improved documentation on `BucketSpec` class.
|
|
32
33
|
* Enhanced `FetchService` to recognize variants on the `application/json` content-type when
|
|
33
34
|
processing failed responses and decoding exceptions - e.g. `application/problem+json`.
|
|
34
35
|
|
|
@@ -20,6 +20,8 @@ export type Thunkable<T> = T | (() => T);
|
|
|
20
20
|
export type Awaitable<T> = Promise<T> | T;
|
|
21
21
|
/** Convenience type for a "plain", string-keyed object holding any kind of values. */
|
|
22
22
|
export type PlainObject = Record<string, any>;
|
|
23
|
+
/** Convenience type to make a set of keys optional in a given type. */
|
|
24
|
+
export type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
23
25
|
/**
|
|
24
26
|
* Specification for debouncing in Hoist.
|
|
25
27
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseRow } from './row/BaseRow';
|
|
2
|
+
import { SetOptional } from '@xh/hoist/core';
|
|
2
3
|
/**
|
|
3
4
|
* Spec to define a bucketing level within the hierarchy of data returned by a Query, as identified
|
|
4
5
|
* by a set of rows passed to a {@link BucketSpecFn} configured on that Query (or defaulted from
|
|
@@ -6,7 +7,7 @@ import { BaseRow } from './row/BaseRow';
|
|
|
6
7
|
* spec's `bucketFn` to determine if it should yield a value for the bucket, causing the row to be
|
|
7
8
|
* nested underneath a new {@link BucketRow} created to hold all rows with that value.
|
|
8
9
|
*/
|
|
9
|
-
export
|
|
10
|
+
export declare class BucketSpec {
|
|
10
11
|
/** Name for the bucketing level configured by this spec - equivalent to a dimension name. */
|
|
11
12
|
name: string;
|
|
12
13
|
/**
|
|
@@ -18,19 +19,13 @@ export interface BucketSpecConfig {
|
|
|
18
19
|
* Function returning bucket row label from the bucket value string returned by bucketFn.
|
|
19
20
|
* Defaults to using the value directly.
|
|
20
21
|
*/
|
|
21
|
-
labelFn
|
|
22
|
+
labelFn: (bucket: string) => string;
|
|
22
23
|
/**
|
|
23
24
|
* Fields on which the `bucketFn` depends, to ensure rows are re-bucketed if dependent field
|
|
24
25
|
* values change. If not provided or does not cover all fields potentially accessed by
|
|
25
26
|
* `bucketFn`, an incremental "data only" update that should have changed a row's bucket can
|
|
26
27
|
* fail to do so.
|
|
27
28
|
*/
|
|
28
|
-
dependentFields?: string[];
|
|
29
|
-
}
|
|
30
|
-
export declare class BucketSpec {
|
|
31
|
-
name: string;
|
|
32
|
-
bucketFn: (row: BaseRow) => string;
|
|
33
|
-
labelFn: (bucket: string) => string;
|
|
34
29
|
dependentFields: string[];
|
|
35
|
-
constructor(config:
|
|
30
|
+
constructor(config: SetOptional<BucketSpec, 'labelFn' | 'dependentFields'>);
|
|
36
31
|
}
|
|
@@ -8,7 +8,7 @@ import { StoreRecord } from '../StoreRecord';
|
|
|
8
8
|
import { AggregateRow } from './row/AggregateRow';
|
|
9
9
|
import { BucketRow } from './row/BucketRow';
|
|
10
10
|
import { BaseRow } from './row/BaseRow';
|
|
11
|
-
import { BucketSpec
|
|
11
|
+
import { BucketSpec } from './BucketSpec';
|
|
12
12
|
export interface CubeConfig {
|
|
13
13
|
fields: CubeField[] | CubeFieldSpec[];
|
|
14
14
|
/** Default configs applied to all `CubeField`s constructed internally by this Cube. */
|
|
@@ -60,9 +60,9 @@ export type OmitFn = (row: AggregateRow | BucketRow) => boolean;
|
|
|
60
60
|
* aggregations and create an unwanted "Open" grouping.
|
|
61
61
|
*
|
|
62
62
|
* @param rows - the rows being checked for bucketing
|
|
63
|
-
* @returns {@link
|
|
63
|
+
* @returns {@link BucketSpec} for dynamic sub-aggregations, or null to perform no bucketing.
|
|
64
64
|
*/
|
|
65
|
-
export type BucketSpecFn = (rows: BaseRow[]) =>
|
|
65
|
+
export type BucketSpecFn = (rows: BaseRow[]) => BucketSpec;
|
|
66
66
|
/**
|
|
67
67
|
* A data store that supports grouping, aggregating, and filtering data on multiple dimensions.
|
|
68
68
|
*
|
|
@@ -79,7 +79,7 @@ export interface QueryConfig {
|
|
|
79
79
|
*
|
|
80
80
|
* This can be used to break selected aggregations into sub-groups dynamically, without having
|
|
81
81
|
* to define another dimension in the Cube and have it apply to all aggregations. See the
|
|
82
|
-
* {@link BucketSpecFn} type and {@link
|
|
82
|
+
* {@link BucketSpecFn} type and {@link BucketSpec} interface for additional information.
|
|
83
83
|
*
|
|
84
84
|
* Defaults to {@link Cube.bucketSpecFn}.
|
|
85
85
|
*/
|
package/core/types/Types.ts
CHANGED
|
@@ -34,6 +34,9 @@ export type Awaitable<T> = Promise<T> | T;
|
|
|
34
34
|
/** Convenience type for a "plain", string-keyed object holding any kind of values. */
|
|
35
35
|
export type PlainObject = Record<string, any>;
|
|
36
36
|
|
|
37
|
+
/** Convenience type to make a set of keys optional in a given type. */
|
|
38
|
+
export type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
39
|
+
|
|
37
40
|
/**
|
|
38
41
|
* Specification for debouncing in Hoist.
|
|
39
42
|
*
|
package/data/cube/BucketSpec.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import {BaseRow} from './row/BaseRow';
|
|
9
|
+
import {SetOptional} from '@xh/hoist/core';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Spec to define a bucketing level within the hierarchy of data returned by a Query, as identified
|
|
@@ -14,35 +15,31 @@ import {BaseRow} from './row/BaseRow';
|
|
|
14
15
|
* spec's `bucketFn` to determine if it should yield a value for the bucket, causing the row to be
|
|
15
16
|
* nested underneath a new {@link BucketRow} created to hold all rows with that value.
|
|
16
17
|
*/
|
|
17
|
-
export
|
|
18
|
+
export class BucketSpec {
|
|
18
19
|
/** Name for the bucketing level configured by this spec - equivalent to a dimension name. */
|
|
19
20
|
name: string;
|
|
21
|
+
|
|
20
22
|
/**
|
|
21
23
|
* Function returning the bucketed value (if any) into which the given row should be placed -
|
|
22
24
|
* equivalent to a dimension value. Return null/undefined to exclude the row from bucketing.
|
|
23
25
|
*/
|
|
24
26
|
bucketFn: (row: BaseRow) => string;
|
|
27
|
+
|
|
25
28
|
/**
|
|
26
29
|
* Function returning bucket row label from the bucket value string returned by bucketFn.
|
|
27
30
|
* Defaults to using the value directly.
|
|
28
31
|
*/
|
|
29
|
-
labelFn
|
|
32
|
+
labelFn: (bucket: string) => string;
|
|
33
|
+
|
|
30
34
|
/**
|
|
31
35
|
* Fields on which the `bucketFn` depends, to ensure rows are re-bucketed if dependent field
|
|
32
36
|
* values change. If not provided or does not cover all fields potentially accessed by
|
|
33
37
|
* `bucketFn`, an incremental "data only" update that should have changed a row's bucket can
|
|
34
38
|
* fail to do so.
|
|
35
39
|
*/
|
|
36
|
-
dependentFields?: string[];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export class BucketSpec {
|
|
40
|
-
name: string;
|
|
41
|
-
bucketFn: (row: BaseRow) => string;
|
|
42
|
-
labelFn: (bucket: string) => string;
|
|
43
40
|
dependentFields: string[];
|
|
44
41
|
|
|
45
|
-
constructor(config:
|
|
42
|
+
constructor(config: SetOptional<BucketSpec, 'labelFn' | 'dependentFields'>) {
|
|
46
43
|
this.name = config.name;
|
|
47
44
|
this.bucketFn = config.bucketFn;
|
|
48
45
|
this.labelFn = config.labelFn ?? (b => b);
|
package/data/cube/Cube.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {StoreRecord} from '../StoreRecord';
|
|
|
17
17
|
import {AggregateRow} from './row/AggregateRow';
|
|
18
18
|
import {BucketRow} from './row/BucketRow';
|
|
19
19
|
import {BaseRow} from './row/BaseRow';
|
|
20
|
-
import {BucketSpec
|
|
20
|
+
import {BucketSpec} from './BucketSpec';
|
|
21
21
|
import {defaultsDeep, isEmpty} from 'lodash';
|
|
22
22
|
|
|
23
23
|
export interface CubeConfig {
|
|
@@ -82,9 +82,9 @@ export type OmitFn = (row: AggregateRow | BucketRow) => boolean;
|
|
|
82
82
|
* aggregations and create an unwanted "Open" grouping.
|
|
83
83
|
*
|
|
84
84
|
* @param rows - the rows being checked for bucketing
|
|
85
|
-
* @returns {@link
|
|
85
|
+
* @returns {@link BucketSpec} for dynamic sub-aggregations, or null to perform no bucketing.
|
|
86
86
|
*/
|
|
87
|
-
export type BucketSpecFn = (rows: BaseRow[]) =>
|
|
87
|
+
export type BucketSpecFn = (rows: BaseRow[]) => BucketSpec;
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* A data store that supports grouping, aggregating, and filtering data on multiple dimensions.
|
package/data/cube/Query.ts
CHANGED
|
@@ -107,7 +107,7 @@ export interface QueryConfig {
|
|
|
107
107
|
*
|
|
108
108
|
* This can be used to break selected aggregations into sub-groups dynamically, without having
|
|
109
109
|
* to define another dimension in the Cube and have it apply to all aggregations. See the
|
|
110
|
-
* {@link BucketSpecFn} type and {@link
|
|
110
|
+
* {@link BucketSpecFn} type and {@link BucketSpec} interface for additional information.
|
|
111
111
|
*
|
|
112
112
|
* Defaults to {@link Cube.bucketSpecFn}.
|
|
113
113
|
*/
|
package/data/cube/View.ts
CHANGED
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
StoreRecord,
|
|
19
19
|
StoreRecordId
|
|
20
20
|
} from '@xh/hoist/data';
|
|
21
|
-
import {BucketSpec} from '@xh/hoist/data/cube/BucketSpec';
|
|
22
21
|
import {ViewRowData} from '@xh/hoist/data/cube/ViewRowData';
|
|
23
22
|
import {action, makeObservable, observable} from '@xh/hoist/mobx';
|
|
24
23
|
import {shallowEqualArrays} from '@xh/hoist/utils/impl';
|
|
@@ -365,13 +364,9 @@ export class View extends HoistBase {
|
|
|
365
364
|
if (!query.bucketSpecFn) return rows;
|
|
366
365
|
if (!query.includeLeaves && rows[0]?.isLeaf) return rows;
|
|
367
366
|
|
|
368
|
-
const
|
|
369
|
-
if (!
|
|
367
|
+
const bucketSpec = query.bucketSpecFn(rows);
|
|
368
|
+
if (!bucketSpec) return rows;
|
|
370
369
|
|
|
371
|
-
const bucketSpec =
|
|
372
|
-
bucketSpecOrConf instanceof BucketSpec
|
|
373
|
-
? bucketSpecOrConf
|
|
374
|
-
: new BucketSpec(bucketSpecOrConf);
|
|
375
370
|
const {name: bucketName, bucketFn, dependentFields} = bucketSpec,
|
|
376
371
|
buckets: Record<string, BaseRow[]> = {},
|
|
377
372
|
ret: BaseRow[] = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "79.0.0-SNAPSHOT.1763737948137",
|
|
4
4
|
"description": "Hoist add-on for building and deploying React Applications.",
|
|
5
5
|
"repository": "github:xh/hoist-react",
|
|
6
6
|
"homepage": "https://xh.io",
|