@gooddata/sdk-ui-kit 11.58.0-alpha.0 → 11.58.0-alpha.1
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.
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import { type IExecutionConfig, type IFilter, type IMeasure, type IResultHeader, type ObjRef } from "@gooddata/sdk-model";
|
|
2
2
|
import { type DataPoint } from "@gooddata/sdk-ui";
|
|
3
3
|
import { type ReferenceMap } from "../helpers/references.js";
|
|
4
|
-
/**
|
|
5
|
-
* How a reference's "is there more than one value?" question is answered, per value measure.
|
|
6
|
-
*
|
|
7
|
-
* `count` is a DISTINCT count, so `> 1` means several values. `min` answers the same question by
|
|
8
|
-
* comparison - used where the backend cannot count the item, see {@link getLabels}.
|
|
9
|
-
*/
|
|
10
|
-
type MultiplicityProbes = Record<string, {
|
|
11
|
-
localId: string;
|
|
12
|
-
kind: "count" | "min";
|
|
13
|
-
}>;
|
|
14
4
|
export type EvaluatedMetric = {
|
|
15
5
|
def: IMeasure;
|
|
16
6
|
header: IResultHeader;
|
|
@@ -31,14 +21,15 @@ export declare function useEvaluatedMetricsAndAttributes(references: ReferenceMa
|
|
|
31
21
|
* The measures resolving attribute-shaped references: `max` for the value, and `count` alongside it
|
|
32
22
|
* to tell a single value from several.
|
|
33
23
|
*
|
|
34
|
-
* A computed attribute is referenced like any other attribute - its ref goes on the display
|
|
35
|
-
* slot, typed `computedAttribute` -
|
|
24
|
+
* A computed attribute is referenced exactly like any other attribute - its ref goes on the display
|
|
25
|
+
* form slot, typed `computedAttribute` - and is aggregated the same way. Where the backend cannot
|
|
26
|
+
* resolve the context an aggregation over one needs, it rejects the execution and every reference
|
|
27
|
+
* in the widget renders as unretrievable; see {@link useEvaluatedMetricsAndAttributes}.
|
|
36
28
|
*
|
|
37
29
|
* @internal
|
|
38
30
|
*/
|
|
39
31
|
export declare function getLabels(references: ReferenceMap): {
|
|
40
|
-
|
|
32
|
+
countMap: Record<string, string>;
|
|
41
33
|
metrics: IMeasure<import("@gooddata/sdk-model").IMeasureDefinitionType>[];
|
|
42
34
|
};
|
|
43
|
-
export {};
|
|
44
35
|
//# sourceMappingURL=useEvaluatedMetricsAndAttributes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEvaluatedMetricsAndAttributes.d.ts","sourceRoot":"","sources":["../../../src/RichText/hooks/useEvaluatedMetricsAndAttributes.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"useEvaluatedMetricsAndAttributes.d.ts","sourceRoot":"","sources":["../../../src/RichText/hooks/useEvaluatedMetricsAndAttributes.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,MAAM,EAId,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACH,KAAK,SAAS,EAKjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,MAAM,eAAe,GAAG;IAC1B,GAAG,EAAE,QAAQ,CAAC;IACd,MAAM,EAAE,aAAa,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,gCAAgC,CAC5C,UAAU,EAAE,YAAY,EACxB,OAAO,EAAE,OAAO,EAAE,EAClB,MAAM,EAAE,gBAAgB,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE;IAqGvE,OAAO;IAKP,KAAK;IACL,MAAM;EAEb;AAeD;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,YAAY;;;EAuCjD"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// (C) 2022-2026 GoodData Corporation
|
|
2
|
-
import {
|
|
2
|
+
import { isMeasureDefinition, newAttribute, newMeasure, } from "@gooddata/sdk-model";
|
|
3
3
|
import { useBackend, useCancelablePromise, useExecutionDataView, useWorkspace, } from "@gooddata/sdk-ui";
|
|
4
4
|
export function useEvaluatedMetricsAndAttributes(references, filters, config) {
|
|
5
5
|
const workspace = useWorkspace();
|
|
6
6
|
const backend = useBackend();
|
|
7
7
|
const metrics = getMeasures(references);
|
|
8
|
-
const { metrics: labels,
|
|
8
|
+
const { metrics: labels, countMap } = getLabels(references);
|
|
9
9
|
const items = [...metrics, ...labels];
|
|
10
10
|
const { enabled, isFiltersLoading, ...execConfig } = config;
|
|
11
11
|
const { status: executionStatus, result: executionResult, error: executionError, } = useExecutionDataView({
|
|
@@ -26,8 +26,8 @@ export function useEvaluatedMetricsAndAttributes(references, filters, config) {
|
|
|
26
26
|
const dataSeries = executionResult.data().series().toArray();
|
|
27
27
|
const definition = executionResult.definition;
|
|
28
28
|
const items = [];
|
|
29
|
-
const skippedLocalIds = Object.values(
|
|
30
|
-
const valueLocalIds = Object.keys(
|
|
29
|
+
const skippedLocalIds = Object.values(countMap);
|
|
30
|
+
const valueLocalIds = Object.keys(countMap);
|
|
31
31
|
const relatedHeaders = headerItems[0][0];
|
|
32
32
|
relatedHeaders.forEach((header, i) => {
|
|
33
33
|
const data = dataSeries[i].dataPoints()[0];
|
|
@@ -49,25 +49,18 @@ export function useEvaluatedMetricsAndAttributes(references, filters, config) {
|
|
|
49
49
|
ref: def.measure.definition.measureDefinition.item,
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
// Attribute measure
|
|
52
|
+
// Attribute measure with count as next
|
|
53
53
|
if (isMeasureDefinition(def.measure.definition) &&
|
|
54
54
|
valueLocalIds.includes(def.measure.localIdentifier)) {
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
55
|
+
const countLocalId = countMap[def.measure.localIdentifier];
|
|
56
|
+
const countIndex = definition.measures.findIndex((d) => d.measure.localIdentifier === countLocalId);
|
|
57
|
+
const countData = dataSeries[countIndex]?.dataPoints()[0] ?? undefined;
|
|
58
58
|
items.push({
|
|
59
59
|
def,
|
|
60
60
|
data,
|
|
61
61
|
header,
|
|
62
62
|
format: descriptor.measureHeaderItem.format,
|
|
63
|
-
|
|
64
|
-
// probe cannot see "none" - an absent value already surfaces as an
|
|
65
|
-
// empty raw value - so it only distinguishes one from several.
|
|
66
|
-
count: probe.kind === "count"
|
|
67
|
-
? parseInt((probeData?.rawValue ?? "0").toString())
|
|
68
|
-
: probeData?.rawValue === data.rawValue
|
|
69
|
-
? 1
|
|
70
|
-
: 2,
|
|
63
|
+
count: parseInt((countData?.rawValue ?? "0").toString()),
|
|
71
64
|
ref: def.measure.definition.measureDefinition.item,
|
|
72
65
|
});
|
|
73
66
|
}
|
|
@@ -99,8 +92,10 @@ function getMeasures(references) {
|
|
|
99
92
|
* The measures resolving attribute-shaped references: `max` for the value, and `count` alongside it
|
|
100
93
|
* to tell a single value from several.
|
|
101
94
|
*
|
|
102
|
-
* A computed attribute is referenced like any other attribute - its ref goes on the display
|
|
103
|
-
* slot, typed `computedAttribute` -
|
|
95
|
+
* A computed attribute is referenced exactly like any other attribute - its ref goes on the display
|
|
96
|
+
* form slot, typed `computedAttribute` - and is aggregated the same way. Where the backend cannot
|
|
97
|
+
* resolve the context an aggregation over one needs, it rejects the execution and every reference
|
|
98
|
+
* in the widget renders as unretrievable; see {@link useEvaluatedMetricsAndAttributes}.
|
|
104
99
|
*
|
|
105
100
|
* @internal
|
|
106
101
|
*/
|
|
@@ -114,35 +109,27 @@ export function getLabels(references) {
|
|
|
114
109
|
return m;
|
|
115
110
|
});
|
|
116
111
|
});
|
|
117
|
-
const
|
|
112
|
+
const countMap = {};
|
|
118
113
|
const metrics = items.reduce((acc, attr, i) => {
|
|
119
114
|
const valueLocalId = `m_max_${i}`;
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
m.aggregation("max");
|
|
123
|
-
return m;
|
|
124
|
-
});
|
|
125
|
-
// A computed attribute cannot be counted without a slicing context: it is functionally
|
|
126
|
-
// determined by the attributes it is computed on, and its own dataset is synthetic, so
|
|
127
|
-
// the backend has no single witness to count over and rejects the whole execution with
|
|
128
|
-
// "Ambiguous context for count" - which would take every other reference in the widget
|
|
129
|
-
// with it. Its minimum answers the same question: `count` here compiles to a DISTINCT
|
|
130
|
-
// count, so "more than one value" is precisely "the smallest differs from the largest".
|
|
131
|
-
const useMin = isComputedAttributeRef(attr.attribute.displayForm);
|
|
132
|
-
const probeLocalId = useMin ? `m_min_${i}` : `m_count_${i}`;
|
|
133
|
-
probes[valueLocalId] = { localId: probeLocalId, kind: useMin ? "min" : "count" };
|
|
115
|
+
const countLocalId = `m_count_${i}`;
|
|
116
|
+
countMap[valueLocalId] = countLocalId;
|
|
134
117
|
return [
|
|
135
118
|
...acc,
|
|
136
|
-
value,
|
|
137
119
|
newMeasure(attr.attribute.displayForm, (m) => {
|
|
138
|
-
m.localId(
|
|
139
|
-
m.aggregation(
|
|
120
|
+
m.localId(valueLocalId);
|
|
121
|
+
m.aggregation("max");
|
|
122
|
+
return m;
|
|
123
|
+
}),
|
|
124
|
+
newMeasure(attr.attribute.displayForm, (m) => {
|
|
125
|
+
m.localId(countLocalId);
|
|
126
|
+
m.aggregation("count");
|
|
140
127
|
return m;
|
|
141
128
|
}),
|
|
142
129
|
];
|
|
143
130
|
}, []);
|
|
144
131
|
return {
|
|
145
|
-
|
|
132
|
+
countMap,
|
|
146
133
|
metrics,
|
|
147
134
|
};
|
|
148
135
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gooddata/sdk-ui-kit",
|
|
3
|
-
"version": "11.58.0-alpha.
|
|
3
|
+
"version": "11.58.0-alpha.1",
|
|
4
4
|
"description": "GoodData SDK - UI Building Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "GoodData Corporation",
|
|
@@ -79,11 +79,11 @@
|
|
|
79
79
|
"unified": "^11.0.5",
|
|
80
80
|
"uuid": "11.1.1",
|
|
81
81
|
"yaml": "2.8.3",
|
|
82
|
-
"@gooddata/sdk-backend-spi": "11.58.0-alpha.
|
|
83
|
-
"@gooddata/sdk-model": "11.58.0-alpha.
|
|
84
|
-
"@gooddata/sdk-ui": "11.58.0-alpha.
|
|
85
|
-
"@gooddata/
|
|
86
|
-
"@gooddata/
|
|
82
|
+
"@gooddata/sdk-backend-spi": "11.58.0-alpha.1",
|
|
83
|
+
"@gooddata/sdk-model": "11.58.0-alpha.1",
|
|
84
|
+
"@gooddata/sdk-ui": "11.58.0-alpha.1",
|
|
85
|
+
"@gooddata/sdk-ui-theme-provider": "11.58.0-alpha.1",
|
|
86
|
+
"@gooddata/util": "11.58.0-alpha.1"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
89
|
"@microsoft/api-documenter": "7.30.10",
|
|
@@ -128,11 +128,11 @@
|
|
|
128
128
|
"typescript": "7.0.2",
|
|
129
129
|
"vitest": "4.1.8",
|
|
130
130
|
"vitest-dom": "0.1.1",
|
|
131
|
-
"@gooddata/
|
|
132
|
-
"@gooddata/
|
|
133
|
-
"@gooddata/
|
|
134
|
-
"@gooddata/
|
|
135
|
-
"@gooddata/stylelint-config": "11.58.0-alpha.
|
|
131
|
+
"@gooddata/oxlint-config": "11.58.0-alpha.1",
|
|
132
|
+
"@gooddata/reference-workspace": "11.58.0-alpha.1",
|
|
133
|
+
"@gooddata/sdk-backend-mockingbird": "11.58.0-alpha.1",
|
|
134
|
+
"@gooddata/eslint-config": "11.58.0-alpha.1",
|
|
135
|
+
"@gooddata/stylelint-config": "11.58.0-alpha.1"
|
|
136
136
|
},
|
|
137
137
|
"peerDependencies": {
|
|
138
138
|
"react": "^18.0.0 || ^19.0.0",
|