@gooddata/sdk-code-convertors 11.67.0-alpha.3 → 11.67.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/esm/execution/buildAfmExecution.d.ts.map +1 -1
- package/esm/execution/buildAfmExecution.js +4 -2
- package/esm/schemas/types.d.ts +1 -1
- package/esm/to/yamlVisualisationToDeclarative.d.ts.map +1 -1
- package/esm/to/yamlVisualisationToDeclarative.js +6 -2
- package/esm/utils/filterUtils.d.ts +12 -0
- package/esm/utils/filterUtils.d.ts.map +1 -1
- package/esm/utils/filterUtils.js +47 -0
- package/package.json +8 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildAfmExecution.d.ts","sourceRoot":"","sources":["../../src/execution/buildAfmExecution.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAGR,KAAK,EAIR,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"buildAfmExecution.d.ts","sourceRoot":"","sources":["../../src/execution/buildAfmExecution.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAGR,KAAK,EAIR,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAgD3E,cAAc;AACd,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,GAAG,kBAAkB,CAkB5F"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// (C) 2024-2026 GoodData Corporation
|
|
2
2
|
import { convertBucketToTitle } from "../utils/convertBucketToTitle.js";
|
|
3
3
|
import { mapDateAttribute, mapDateDataset } from "../utils/dateUtils.js";
|
|
4
|
-
import { parseDateValues, yamlConditionToMatch } from "../utils/filterUtils.js";
|
|
4
|
+
import { foldLegacyEmptyValuesWithFilter, parseDateValues, yamlConditionToMatch, } from "../utils/filterUtils.js";
|
|
5
5
|
import { getFullField } from "../utils/sharedUtils.js";
|
|
6
6
|
import { isAbsoluteDateFilter, isAllTimeDateFilter, isArbitraryTextFilter, isArithmeticMetricField, isAttributeField, isAttributeSort, isCalculatedMetricField, isComputedAttributeReference, isDateFilter, isInlineMetricField, isMatchTextFilter, isMetricAllValueFilter, isMetricComparisonValueFilter, isMetricField, isMetricRangeValueFilter, isMetricValueFilterWithConditions, isNegativeAttributeFilter, isPoPMetricField, isPositiveAttributeFilter, isPreviousPeriodField, isRankingFilter, isRelativeDateFilter, isSimpleMetricSort, } from "../utils/typeGuards.js";
|
|
7
7
|
import { createIdentifier, createLocalIdentifier } from "../utils/yamlUtils.js";
|
|
@@ -206,7 +206,9 @@ function buildFilters(entities, filters_by) {
|
|
|
206
206
|
}
|
|
207
207
|
const filters = [];
|
|
208
208
|
Object.keys(filters_by ?? {}).forEach((key) => {
|
|
209
|
-
const
|
|
209
|
+
const queryFilter = filters_by[key];
|
|
210
|
+
// The same for the insight-level and the metric-level date filter, as in deploy
|
|
211
|
+
const filter = isDateFilter(queryFilter) ? foldLegacyEmptyValuesWithFilter(queryFilter) : queryFilter;
|
|
210
212
|
if (isAbsoluteDateFilter(filter)) {
|
|
211
213
|
filters.push({
|
|
212
214
|
absoluteDateFilter: {
|
package/esm/schemas/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Hand-curated public types from the AAC schema provided by
|
|
2
|
+
* Hand-curated public types from the AAC schema provided by `@gooddata/sdk-code-schemas`.
|
|
3
3
|
* This file isolates api-extractor from the generated metadata.ts internals
|
|
4
4
|
* (which contain anonymous union members like Visualisation1-22, Id4-16, etc.).
|
|
5
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yamlVisualisationToDeclarative.d.ts","sourceRoot":"","sources":["../../src/to/yamlVisualisationToDeclarative.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EACrC,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EASR,MAAM,EAMN,YAAY,EAIZ,KAAK,EAEL,KAAK,EACL,aAAa,EAEhB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGH,KAAK,uBAAuB,EAE5B,KAAK,OAAO,EACZ,KAAK,QAAQ,EAIb,KAAK,SAAS,EACd,KAAK,MAAM,EAKd,MAAM,qBAAqB,CAAC;AAyB7B,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"yamlVisualisationToDeclarative.d.ts","sourceRoot":"","sources":["../../src/to/yamlVisualisationToDeclarative.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EACrC,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EASR,MAAM,EAMN,YAAY,EAIZ,KAAK,EAEL,KAAK,EACL,aAAa,EAEhB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGH,KAAK,uBAAuB,EAE5B,KAAK,OAAO,EACZ,KAAK,QAAQ,EAIb,KAAK,SAAS,EACd,KAAK,MAAM,EAKd,MAAM,qBAAqB,CAAC;AAyB7B,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAuC/D,gBAAgB;AAChB,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACtC,QAAQ,CAAC,SAAS,CAAC,EACnB,kBAAkB,GAAG,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,wBAAwB,GAAG,QAAQ,CAC5G,GAAG;IACA,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAGF,cAAc;AACd,wBAAgB,8BAA8B,CAC1C,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,aAAa,GACrB,8BAA8B,CAoChC;AAED,cAAc;AACd,wBAAgB,iCAAiC,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AAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1D,gBAAgB,EAAE,uBAAuB,CAAC;CAC7C,CAuDA"}
|
|
@@ -27,11 +27,11 @@ import { BucketsType } from "../types.js";
|
|
|
27
27
|
import { convertBucketToTitle } from "../utils/convertBucketToTitle.js";
|
|
28
28
|
import { mapDateAttribute, mapDateDataset } from "../utils/dateUtils.js";
|
|
29
29
|
import { CoreErrorCode, newError } from "../utils/errors.js";
|
|
30
|
-
import { parseDateValues, yamlConditionToMatch } from "../utils/filterUtils.js";
|
|
30
|
+
import { foldLegacyEmptyValuesWithFilter, parseDateValues, yamlConditionToMatch, } from "../utils/filterUtils.js";
|
|
31
31
|
import { convertGranularity } from "../utils/granularityUtils.js";
|
|
32
32
|
import { mapLocationLabel } from "../utils/locationUtils.js";
|
|
33
33
|
import { assertUnreachable, convertIdToTitle, getFullBucket, getFullField } from "../utils/sharedUtils.js";
|
|
34
|
-
import { isAbsoluteDateFilter, isArbitraryTextFilter, isArithmeticMetricField, isAttributeField, isAttributeSort, isCalculatedMetricField, isInlineMetricField, isMatchTextFilter, isMetricAllValueFilter, isMetricComparisonValueFilter, isMetricField, isMetricRangeValueFilter, isMetricSort, isMetricValueFilterWithConditions, isNegativeAttributeFilter, isPoPMetricField, isPositiveAttributeFilter, isPreviousPeriodField, isRankingFilter, isRelativeDateFilter, parseReferenceObject, } from "../utils/typeGuards.js";
|
|
34
|
+
import { isAbsoluteDateFilter, isArbitraryTextFilter, isArithmeticMetricField, isAttributeField, isAttributeSort, isCalculatedMetricField, isDateFilter, isInlineMetricField, isMatchTextFilter, isMetricAllValueFilter, isMetricComparisonValueFilter, isMetricField, isMetricRangeValueFilter, isMetricSort, isMetricValueFilterWithConditions, isNegativeAttributeFilter, isPoPMetricField, isPositiveAttributeFilter, isPreviousPeriodField, isRankingFilter, isRelativeDateFilter, parseReferenceObject, } from "../utils/typeGuards.js";
|
|
35
35
|
import { yamlVisTypeToVisualizationUrl } from "../utils/visualisationTypeMap.js";
|
|
36
36
|
import { createIdentifier, createLocalIdentifier } from "../utils/yamlUtils.js";
|
|
37
37
|
/** @public */
|
|
@@ -769,6 +769,10 @@ function yamlFilterToDeclarative(entities, key, filter,
|
|
|
769
769
|
// Only view-level (report/layer) filters need a localIdentifier so their displayAsLabel can be
|
|
770
770
|
// correlated via attributeFilterConfigs. Measure-scoped filters must NOT carry one.
|
|
771
771
|
assignFilterLocalId) {
|
|
772
|
+
// The same for the insight-level and the metric-level date filter
|
|
773
|
+
if (isDateFilter(filter)) {
|
|
774
|
+
filter = foldLegacyEmptyValuesWithFilter(filter);
|
|
775
|
+
}
|
|
772
776
|
if (isAbsoluteDateFilter(filter)) {
|
|
773
777
|
return yamlAbsoluteDateFilterToDeclarative(entities, filter, assignFilterLocalId);
|
|
774
778
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DateFilter } from "@gooddata/sdk-code-schemas/v1";
|
|
1
2
|
import type { MatchFilterOperator } from "@gooddata/sdk-model";
|
|
2
3
|
import { type ExportEntities, type FromEntities } from "../types.js";
|
|
3
4
|
import type { TextFilterCondition } from "./typeGuards.js";
|
|
@@ -7,4 +8,15 @@ export declare function yamlConditionToMatch(condition: TextFilterCondition): {
|
|
|
7
8
|
operator: MatchFilterOperator;
|
|
8
9
|
negativeSelection: boolean;
|
|
9
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Before the date filter carried its own `empty_values`, the mode was stored as an attribute filter on the
|
|
13
|
+
* date label with the single value `""`: `include` meant "only", `exclude` meant "exclude". Pull and AD
|
|
14
|
+
* still read that shape; deploy must not write it, because the backend executes it next to the date
|
|
15
|
+
* filter's default of excluding empty values, and the two cancel out.
|
|
16
|
+
*
|
|
17
|
+
* Returns the date filter with such a `with:` entry folded into `empty_values` and removed. An explicit
|
|
18
|
+
* `empty_values` wins, the entry is dropped either way. A `""` mixed with other values, or on a label
|
|
19
|
+
* that is not of the date filter's dataset, or several `""` markers, is an ordinary filter and stays.
|
|
20
|
+
*/
|
|
21
|
+
export declare function foldLegacyEmptyValuesWithFilter(filter: DateFilter): DateFilter;
|
|
10
22
|
//# sourceMappingURL=filterUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterUtils.d.ts","sourceRoot":"","sources":["../../src/utils/filterUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filterUtils.d.ts","sourceRoot":"","sources":["../../src/utils/filterUtils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgC,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC9F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAGrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,wBAAgB,eAAe,CAC3B,QAAQ,EAAE,YAAY,GAAG,cAAc,EACvC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,SAkBxC;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,mBAAmB,EAAE,iBAAiB,CAAC,EAAE,OAAO,GAAG,MAAM,CAYvG;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,mBAAmB,GAAG;IAClE,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,iBAAiB,EAAE,OAAO,CAAC;CAC9B,CAkBA;AAUD;;;;;;;;;GASG;AACH,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAyB9E"}
|
package/esm/utils/filterUtils.js
CHANGED
|
@@ -49,3 +49,50 @@ function convertDateValues(gran, values) {
|
|
|
49
49
|
.map((v) => parseGranularityValue(granularity, v))
|
|
50
50
|
.filter((v) => v !== null && v !== undefined);
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Before the date filter carried its own `empty_values`, the mode was stored as an attribute filter on the
|
|
54
|
+
* date label with the single value `""`: `include` meant "only", `exclude` meant "exclude". Pull and AD
|
|
55
|
+
* still read that shape; deploy must not write it, because the backend executes it next to the date
|
|
56
|
+
* filter's default of excluding empty values, and the two cancel out.
|
|
57
|
+
*
|
|
58
|
+
* Returns the date filter with such a `with:` entry folded into `empty_values` and removed. An explicit
|
|
59
|
+
* `empty_values` wins, the entry is dropped either way. A `""` mixed with other values, or on a label
|
|
60
|
+
* that is not of the date filter's dataset, or several `""` markers, is an ordinary filter and stays.
|
|
61
|
+
*/
|
|
62
|
+
export function foldLegacyEmptyValuesWithFilter(filter) {
|
|
63
|
+
const withFilters = filter.with;
|
|
64
|
+
if (!withFilters) {
|
|
65
|
+
return filter;
|
|
66
|
+
}
|
|
67
|
+
const datasetId = filter.using.split("/").pop();
|
|
68
|
+
const legacy = Object.entries(withFilters).flatMap(([key, withFilter]) => {
|
|
69
|
+
const mode = legacyEmptyValuesMode(withFilter, datasetId);
|
|
70
|
+
return mode ? [{ key, mode }] : [];
|
|
71
|
+
});
|
|
72
|
+
// Two markers on one date filter have no single mode to fold into, so none is folded
|
|
73
|
+
if (legacy.length !== 1) {
|
|
74
|
+
return filter;
|
|
75
|
+
}
|
|
76
|
+
const legacyKeys = new Set(legacy.map(({ key }) => key));
|
|
77
|
+
const remaining = Object.fromEntries(Object.entries(withFilters).filter(([key]) => !legacyKeys.has(key)));
|
|
78
|
+
const { with: _with, ...rest } = filter;
|
|
79
|
+
return {
|
|
80
|
+
...rest,
|
|
81
|
+
...(Object.keys(remaining).length > 0 ? { with: remaining } : {}),
|
|
82
|
+
...(filter.empty_values ? {} : { empty_values: legacy[0].mode }),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function legacyEmptyValuesMode(filter, datasetId) {
|
|
86
|
+
// A date label id is `<dataset id>.<granularity>`; the dataset id may itself contain dots, so compare
|
|
87
|
+
// it whole rather than up to the first dot.
|
|
88
|
+
const labelId = filter.using.split("/").pop() ?? "";
|
|
89
|
+
const granularity = datasetId && labelId.startsWith(`${datasetId}.`) ? labelId.slice(datasetId.length + 1) : "";
|
|
90
|
+
if (!granularity || granularity.includes(".")) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
const isOnlyEmpty = (values) => values?.length === 1 && values[0] === "";
|
|
94
|
+
if (isOnlyEmpty(filter.state?.include)) {
|
|
95
|
+
return "only";
|
|
96
|
+
}
|
|
97
|
+
return isOnlyEmpty(filter.state?.exclude) ? "exclude" : undefined;
|
|
98
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gooddata/sdk-code-convertors",
|
|
3
|
-
"version": "11.67.0
|
|
3
|
+
"version": "11.67.0",
|
|
4
4
|
"description": "GoodData AAC declarative converters",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "GoodData",
|
|
@@ -26,21 +26,22 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"uuid": "11.1.1",
|
|
28
28
|
"yaml": "2.9.1",
|
|
29
|
-
"@gooddata/api-client-tiger": "11.67.0
|
|
30
|
-
"@gooddata/sdk-
|
|
31
|
-
"@gooddata/sdk-
|
|
29
|
+
"@gooddata/api-client-tiger": "11.67.0",
|
|
30
|
+
"@gooddata/sdk-model": "11.67.0",
|
|
31
|
+
"@gooddata/sdk-code-schemas": "11.67.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@microsoft/api-extractor": "7.59.2",
|
|
35
35
|
"@typescript-eslint/eslint-plugin": "8.58.0",
|
|
36
36
|
"@typescript-eslint/parser": "8.58.0",
|
|
37
37
|
"dependency-cruiser": "17.3.10",
|
|
38
|
-
"eslint": "^
|
|
38
|
+
"eslint": "^10.14.0",
|
|
39
39
|
"eslint-plugin-headers": "1.3.3",
|
|
40
40
|
"eslint-plugin-import-esm": "3.0.1",
|
|
41
41
|
"eslint-plugin-jsdoc": "65.4.2",
|
|
42
42
|
"eslint-plugin-no-barrel-files": "1.2.2",
|
|
43
43
|
"eslint-plugin-sonarjs": "4.2.2",
|
|
44
|
+
"eslint-plugin-tsdoc": "0.5.4",
|
|
44
45
|
"npm-run-all": "4.1.5",
|
|
45
46
|
"oxfmt": "0.68.0",
|
|
46
47
|
"oxlint": "1.83.0",
|
|
@@ -48,8 +49,8 @@
|
|
|
48
49
|
"oxlint-tsgolint": "7.0.2001",
|
|
49
50
|
"typescript": "7.0.2",
|
|
50
51
|
"vitest": "5.0.4",
|
|
51
|
-
"@gooddata/oxlint-config": "11.67.0
|
|
52
|
-
"@gooddata/eslint-config": "11.67.0
|
|
52
|
+
"@gooddata/oxlint-config": "11.67.0",
|
|
53
|
+
"@gooddata/eslint-config": "11.67.0"
|
|
53
54
|
},
|
|
54
55
|
"scripts": {
|
|
55
56
|
"_phase:build": "npm run build",
|