@gooddata/sdk-code-convertors 11.65.0-alpha.8 → 11.65.0-alpha.9
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/sdk-code-convertors.d.ts +3 -1
- package/esm/to/yamlPublisherEntityToDeclarativeV2.d.ts.map +1 -1
- package/esm/to/yamlPublisherEntityToDeclarativeV2.js +17 -7
- package/esm/utils/describeValue.d.ts +7 -0
- package/esm/utils/describeValue.d.ts.map +1 -0
- package/esm/utils/describeValue.js +26 -0
- package/esm/utils/errors.d.ts +3 -1
- package/esm/utils/errors.d.ts.map +1 -1
- package/esm/utils/errors.js +8 -2
- package/esm/utils/publisherFilters.d.ts.map +1 -1
- package/esm/utils/publisherFilters.js +17 -2
- package/esm/utils/publisherPeriodV2.d.ts +7 -2
- package/esm/utils/publisherPeriodV2.d.ts.map +1 -1
- package/esm/utils/publisherPeriodV2.js +15 -2
- package/esm/utils/publisherVersionV2.d.ts.map +1 -1
- package/esm/utils/publisherVersionV2.js +8 -2
- package/package.json +6 -6
|
@@ -1333,7 +1333,9 @@ export declare enum CoreErrorCode {
|
|
|
1333
1333
|
DateFilterWithoutDataSet = "core.dateFilterWithoutDataSet",
|
|
1334
1334
|
FilterSettingNotStorable = "core.filterSettingNotStorable",
|
|
1335
1335
|
PagesAndSectionsMutuallyExclusive = "core.pagesAndSectionsMutuallyExclusive",
|
|
1336
|
-
PagesOrSectionsRequired = "core.pagesOrSectionsRequired"
|
|
1336
|
+
PagesOrSectionsRequired = "core.pagesOrSectionsRequired",
|
|
1337
|
+
MissingRequiredKey = "core.missingRequiredKey",
|
|
1338
|
+
UnsupportedGranularity = "core.unsupportedGranularity"
|
|
1337
1339
|
}
|
|
1338
1340
|
|
|
1339
1341
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yamlPublisherEntityToDeclarativeV2.d.ts","sourceRoot":"","sources":["../../src/to/yamlPublisherEntityToDeclarativeV2.ts"],"names":[],"mappings":"AAUA,OAAO,EAEH,KAAK,8BAA8B,EAEnC,KAAK,sCAAsC,EAE3C,KAAK,kCAAkC,EAO1C,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACH,KAAK,sCAAsC,EAC3C,KAAK,8BAA8B,EACnC,KAAK,kCAAkC,EAC1C,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC3B,KAAK,kCAAkC,EACvC,KAAK,0BAA0B,EAClC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAiB,KAAK,aAAa,EAAgC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"yamlPublisherEntityToDeclarativeV2.d.ts","sourceRoot":"","sources":["../../src/to/yamlPublisherEntityToDeclarativeV2.ts"],"names":[],"mappings":"AAUA,OAAO,EAEH,KAAK,8BAA8B,EAEnC,KAAK,sCAAsC,EAE3C,KAAK,kCAAkC,EAO1C,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACH,KAAK,sCAAsC,EAC3C,KAAK,8BAA8B,EACnC,KAAK,kCAAkC,EAC1C,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC3B,KAAK,kCAAkC,EACvC,KAAK,0BAA0B,EAClC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAiB,KAAK,aAAa,EAAgC,MAAM,oBAAoB,CAAC;AAmOrG;;;;GAIG;AACH,wBAAgB,oCAAoC,CAChD,KAAK,EAAE,sBAAsB,EAC7B,YAAY,CAAC,EAAE,aAAa,GAC7B,8BAA8B,CAEhC;AAED;;;;GAIG;AACH,wBAAgB,4CAA4C,CACxD,KAAK,EAAE,8BAA8B,EACrC,YAAY,CAAC,EAAE,aAAa,GAC7B,sCAAsC,CAExC;AAED;;;;GAIG;AACH,wBAAgB,wCAAwC,CACpD,KAAK,EAAE,0BAA0B,EACjC,YAAY,CAAC,EAAE,aAAa,GAC7B,kCAAkC,CAEpC;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAC/C,KAAK,EAAE,kCAAkC,CAAC,sBAAsB,CAAC,EACjE,YAAY,CAAC,EAAE,aAAa,GAC7B,8BAA8B,CAEhC;AAED,aAAa;AACb,wBAAgB,2CAA2C,CACvD,KAAK,EAAE,kCAAkC,CAAC,8BAA8B,CAAC,EACzE,YAAY,CAAC,EAAE,aAAa,GAC7B,sCAAsC,CAExC;AAED,aAAa;AACb,wBAAgB,uCAAuC,CACnD,KAAK,EAAE,kCAAkC,CAAC,0BAA0B,CAAC,EACrE,YAAY,CAAC,EAAE,aAAa,GAC7B,kCAAkC,CAEpC"}
|
|
@@ -17,6 +17,8 @@ function ignoredFilterToDeclarative(id, errorContext) {
|
|
|
17
17
|
}
|
|
18
18
|
function visualizationToDeclarative(widget, errorContext) {
|
|
19
19
|
const { visualization, date, filters, ignored_filters, ...rest } = widget;
|
|
20
|
+
const widgetContext = updateErrorContext(errorContext, { path: [widget.id] });
|
|
21
|
+
const ignoredContext = updateErrorContext(widgetContext, { path: ["ignored_filters"] });
|
|
20
22
|
return {
|
|
21
23
|
...camelKeys(rest),
|
|
22
24
|
...(visualization === undefined
|
|
@@ -25,11 +27,13 @@ function visualizationToDeclarative(widget, errorContext) {
|
|
|
25
27
|
...(date === undefined ? {} : { dateDataSet: { identifier: date, type: "dataSet" } }),
|
|
26
28
|
...(filters === undefined
|
|
27
29
|
? {}
|
|
28
|
-
: {
|
|
30
|
+
: {
|
|
31
|
+
filters: filtersToDeclarativeV2(filters, "widget", updateErrorContext(widgetContext, { path: ["filters"] })).filters,
|
|
32
|
+
}),
|
|
29
33
|
...(ignored_filters === undefined
|
|
30
34
|
? {}
|
|
31
35
|
: {
|
|
32
|
-
ignoreDocumentFilters: ignored_filters.map((id) => ignoredFilterToDeclarative(id,
|
|
36
|
+
ignoreDocumentFilters: ignored_filters.map((id) => ignoredFilterToDeclarative(id, ignoredContext)),
|
|
33
37
|
}),
|
|
34
38
|
};
|
|
35
39
|
}
|
|
@@ -62,7 +66,9 @@ function pageBodyToDeclarative(body, errorContext) {
|
|
|
62
66
|
layout: layoutNodeToDeclarative(layout, errorContext),
|
|
63
67
|
...(filters === undefined
|
|
64
68
|
? {}
|
|
65
|
-
: {
|
|
69
|
+
: {
|
|
70
|
+
filters: filtersToDeclarativeV2(filters, "page", updateErrorContext(errorContext, { path: ["filters"] })).filters,
|
|
71
|
+
}),
|
|
66
72
|
};
|
|
67
73
|
}
|
|
68
74
|
function documentPageToDeclarative(page, errorContext) {
|
|
@@ -78,10 +84,14 @@ function sectionToDeclarative(section, errorContext) {
|
|
|
78
84
|
const pagesContext = updateErrorContext(errorContext, { path: ["sections", section.id, "pages"] });
|
|
79
85
|
return { ...rest, pages: pages.map((page) => documentPageToDeclarative(page, pagesContext)) };
|
|
80
86
|
}
|
|
81
|
-
function defaultsToDeclarative({ period, ...rest }) {
|
|
87
|
+
function defaultsToDeclarative({ period, ...rest }, errorContext) {
|
|
82
88
|
return {
|
|
83
89
|
...camelKeys(rest),
|
|
84
|
-
...(period === undefined
|
|
90
|
+
...(period === undefined
|
|
91
|
+
? {}
|
|
92
|
+
: {
|
|
93
|
+
period: periodToDeclarativeV2(period, updateErrorContext(errorContext, { path: ["period"] })),
|
|
94
|
+
}),
|
|
85
95
|
};
|
|
86
96
|
}
|
|
87
97
|
function contentToDeclarative(content, errorContext) {
|
|
@@ -96,7 +106,7 @@ function contentToDeclarative(content, errorContext) {
|
|
|
96
106
|
...(defaults === undefined
|
|
97
107
|
? {}
|
|
98
108
|
: {
|
|
99
|
-
defaults: defaultsToDeclarative(defaults),
|
|
109
|
+
defaults: defaultsToDeclarative(defaults, updateErrorContext(errorContext, { path: ["defaults"] })),
|
|
100
110
|
}),
|
|
101
111
|
...declared,
|
|
102
112
|
...camelKeys(rest),
|
|
@@ -122,7 +132,7 @@ function documentBody(input, errorContext) {
|
|
|
122
132
|
assertPublisherContentVersionV2(input, errorContext);
|
|
123
133
|
return {
|
|
124
134
|
...entityFields(input),
|
|
125
|
-
period: periodToDeclarativeV2(input.period),
|
|
135
|
+
period: periodToDeclarativeV2(input.period, updateErrorContext(errorContext, { path: ["period"] })),
|
|
126
136
|
content: contentToDeclarative(input.content, updateErrorContext(errorContext, { path: ["content"] })),
|
|
127
137
|
};
|
|
128
138
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describeValue.d.ts","sourceRoot":"","sources":["../../src/utils/describeValue.ts"],"names":[],"mappings":"AAiBA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKpD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
const maxDescriptionLength = 80;
|
|
3
|
+
function asJson(value) {
|
|
4
|
+
// JSON writes NaN and Infinity as null.
|
|
5
|
+
if (typeof value === "number" && !Number.isFinite(value)) {
|
|
6
|
+
return String(value);
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
return JSON.stringify(value) ?? typeof value;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
// JSON has no BigInt, and an object that refers to itself cannot be written out.
|
|
13
|
+
return typeof value === "bigint" ? "a bigint" : "an object";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Described as validatePublisherEntityV2 describes a value, so the number 2 and the string "2" read apart.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export function describeValue(value) {
|
|
22
|
+
const description = value === null ? "null" : Array.isArray(value) ? "an array" : asJson(value);
|
|
23
|
+
return description.length > maxDescriptionLength
|
|
24
|
+
? `${description.slice(0, maxDescriptionLength - 1)}…`
|
|
25
|
+
: description;
|
|
26
|
+
}
|
package/esm/utils/errors.d.ts
CHANGED
|
@@ -23,7 +23,9 @@ export declare enum CoreErrorCode {
|
|
|
23
23
|
DateFilterWithoutDataSet = "core.dateFilterWithoutDataSet",
|
|
24
24
|
FilterSettingNotStorable = "core.filterSettingNotStorable",
|
|
25
25
|
PagesAndSectionsMutuallyExclusive = "core.pagesAndSectionsMutuallyExclusive",
|
|
26
|
-
PagesOrSectionsRequired = "core.pagesOrSectionsRequired"
|
|
26
|
+
PagesOrSectionsRequired = "core.pagesOrSectionsRequired",
|
|
27
|
+
MissingRequiredKey = "core.missingRequiredKey",
|
|
28
|
+
UnsupportedGranularity = "core.unsupportedGranularity"
|
|
27
29
|
}
|
|
28
30
|
/**
|
|
29
31
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,oBAAY,aAAa;IAErB,0BAA0B,oCAAoC;IAC9D,0BAA0B,oCAAoC;IAC9D,gBAAgB,0BAA0B;IAC1C,yBAAyB,mCAAmC;IAC5D,yBAAyB,mCAAmC;IAC5D,qBAAqB,+BAA+B;IACpD,oBAAoB,8BAA8B;IAClD,yBAAyB,mCAAmC;IAC5D,2BAA2B,qCAAqC;IAChE,yBAAyB,mCAAmC;IAC5D,8BAA8B,wCAAwC;IACtE,kBAAkB,4BAA4B;IAC9C,mBAAmB,6BAA6B;IAChD,wBAAwB,kCAAkC;IAC1D,sBAAsB,gCAAgC;IACtD,mCAAmC,6CAA6C;IAChF,qBAAqB,+BAA+B;IACpD,yBAAyB,mCAAmC;IAC5D,wBAAwB,kCAAkC;IAC1D,wBAAwB,kCAAkC;IAC1D,iCAAiC,2CAA2C;IAC5E,uBAAuB,iCAAiC;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,oBAAY,aAAa;IAErB,0BAA0B,oCAAoC;IAC9D,0BAA0B,oCAAoC;IAC9D,gBAAgB,0BAA0B;IAC1C,yBAAyB,mCAAmC;IAC5D,yBAA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,EAAE,aAAa,cAOhG;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,UAO3F"}
|
package/esm/utils/errors.js
CHANGED
|
@@ -27,6 +27,8 @@ export var CoreErrorCode;
|
|
|
27
27
|
CoreErrorCode["FilterSettingNotStorable"] = "core.filterSettingNotStorable";
|
|
28
28
|
CoreErrorCode["PagesAndSectionsMutuallyExclusive"] = "core.pagesAndSectionsMutuallyExclusive";
|
|
29
29
|
CoreErrorCode["PagesOrSectionsRequired"] = "core.pagesOrSectionsRequired";
|
|
30
|
+
CoreErrorCode["MissingRequiredKey"] = "core.missingRequiredKey";
|
|
31
|
+
CoreErrorCode["UnsupportedGranularity"] = "core.unsupportedGranularity";
|
|
30
32
|
})(CoreErrorCode || (CoreErrorCode = {}));
|
|
31
33
|
/**
|
|
32
34
|
* @public
|
|
@@ -49,11 +51,13 @@ export const CoreErrorMessages = {
|
|
|
49
51
|
[CoreErrorCode.DuplicateTabIdentifier]: `Duplicate tab identifier "{0}". Each tab must have a unique identifier within the dashboard.`,
|
|
50
52
|
[CoreErrorCode.TabsAndRootContentMutuallyExclusive]: `Dashboard "{0}" defines both "tabs" and root-level "sections" or "filters". These are mutually exclusive — keep all content inside tabs or at the root, not both.`,
|
|
51
53
|
[CoreErrorCode.InvalidIanaTimezoneId]: `"{0}" is not a valid IANA timezone ID. Use a real timezone such as Europe/Prague or $browserDetected.`,
|
|
52
|
-
[CoreErrorCode.UnsupportedContentVersion]: `
|
|
54
|
+
[CoreErrorCode.UnsupportedContentVersion]: `Expected "{0}", got {1}.`,
|
|
53
55
|
[CoreErrorCode.DateFilterWithoutDataSet]: `Date filter "{0}" names no date dataset. A document date filter must name the date dataset it applies to.`,
|
|
54
56
|
[CoreErrorCode.FilterSettingNotStorable]: `Filter "{0}" sets "{1}", which a {2} cannot store.`,
|
|
55
57
|
[CoreErrorCode.PagesAndSectionsMutuallyExclusive]: `Content defines both "pages" and "sections". Keep the pages at the top level or inside sections, not both.`,
|
|
56
58
|
[CoreErrorCode.PagesOrSectionsRequired]: `Content defines neither "pages" nor "sections". Add one of them; an empty document has "pages: []".`,
|
|
59
|
+
[CoreErrorCode.MissingRequiredKey]: `Missing required key "{0}".`,
|
|
60
|
+
[CoreErrorCode.UnsupportedGranularity]: `Granularity {0} is not supported. Supported granularities: {1}.`,
|
|
57
61
|
};
|
|
58
62
|
/**
|
|
59
63
|
* @public
|
|
@@ -81,6 +85,8 @@ export const CoreErrorTypes = {
|
|
|
81
85
|
[CoreErrorCode.FilterSettingNotStorable]: "FilterSettingNotStorable",
|
|
82
86
|
[CoreErrorCode.PagesAndSectionsMutuallyExclusive]: "PagesAndSectionsMutuallyExclusive",
|
|
83
87
|
[CoreErrorCode.PagesOrSectionsRequired]: "PagesOrSectionsRequired",
|
|
88
|
+
[CoreErrorCode.MissingRequiredKey]: "MissingRequiredKey",
|
|
89
|
+
[CoreErrorCode.UnsupportedGranularity]: "UnsupportedGranularity",
|
|
84
90
|
};
|
|
85
91
|
/**
|
|
86
92
|
* Update error context with new values
|
|
@@ -107,7 +113,7 @@ export function newError(code, params = [], context) {
|
|
|
107
113
|
return err;
|
|
108
114
|
}
|
|
109
115
|
export function buildMessage(message, params, context) {
|
|
110
|
-
const m =
|
|
116
|
+
const m = message.replace(/\{(\d+)}/g, (match, index) => params[Number(index)] ?? match);
|
|
111
117
|
if (context?.path) {
|
|
112
118
|
return `${m} in: ${context.path.join("/")}`;
|
|
113
119
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publisherFilters.d.ts","sourceRoot":"","sources":["../../src/utils/publisherFilters.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAGpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EACH,KAAK,iBAAiB,EACtB,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,YAAY,CAAC,EAAE,aAAa,GAC7B,IAAI,CASN"}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import { dashboardFilterLocalIdentifier, isDashboardCommonDateFilter, isDashboardDateFilter, isNoopAllTimeDashboardDateFilter, } from "@gooddata/sdk-model";
|
|
3
3
|
import { declarativeFilterContextToYaml, declarativeFiltersConfigToYaml, } from "../from/declarativeDashboardToYaml.js";
|
|
4
4
|
import { yamlFilterContextToDeclarative } from "../to/yamlDashboardToDeclarative.js";
|
|
5
|
-
import { CoreErrorCode, newError } from "./errors.js";
|
|
5
|
+
import { CoreErrorCode, newError, updateErrorContext } from "./errors.js";
|
|
6
6
|
import { referencesAsStored, referencesAsWritten } from "./publisherFilterRefs.js";
|
|
7
|
+
import { assertPublisherGranularityV2 } from "./publisherPeriodV2.js";
|
|
7
8
|
import { createFilterContextItemKeyName } from "./yamlUtils.js";
|
|
8
9
|
/**
|
|
9
10
|
* A document holds its filters the way a dashboard's filter context does, so the same convertor writes
|
|
@@ -57,6 +58,16 @@ function lostSettings(filter, holder) {
|
|
|
57
58
|
: ["mode", "display_as", "selection_type"].filter((key) => changedSetting(filter, key));
|
|
58
59
|
}
|
|
59
60
|
}
|
|
61
|
+
// The dashboard reader stores WEEK as GDC.time.week, which v2 does not store; WEEK_US is the same week.
|
|
62
|
+
function withStoredWeek(filter) {
|
|
63
|
+
if (!isDashboardDateFilter(filter)) {
|
|
64
|
+
return filter;
|
|
65
|
+
}
|
|
66
|
+
const granularity = filter.dateFilter.granularity;
|
|
67
|
+
return granularity === "GDC.time.week"
|
|
68
|
+
? { dateFilter: { ...filter.dateFilter, granularity: "GDC.time.week_us" } }
|
|
69
|
+
: filter;
|
|
70
|
+
}
|
|
60
71
|
/**
|
|
61
72
|
* Reads a v2 filter list. A setting the v2 shape has nowhere to keep throws instead of being dropped.
|
|
62
73
|
*
|
|
@@ -69,9 +80,13 @@ export function filtersToDeclarativeV2(filters, holder, errorContext) {
|
|
|
69
80
|
if (lost !== undefined) {
|
|
70
81
|
throw newError(CoreErrorCode.FilterSettingNotStorable, [key, lost, holder], errorContext);
|
|
71
82
|
}
|
|
83
|
+
const granularity = setting(filter, "granularity");
|
|
84
|
+
if (filter.type === "date_filter" && granularity != null) {
|
|
85
|
+
assertPublisherGranularityV2(granularity, updateErrorContext(errorContext, { path: [key] }));
|
|
86
|
+
}
|
|
72
87
|
}
|
|
73
88
|
const { filterContext, attributeFilterConfigs } = yamlFilterContextToDeclarative("document", filters);
|
|
74
|
-
const read = filterContext.content?.filters ?? [];
|
|
89
|
+
const read = (filterContext.content?.filters ?? []).map(withStoredWeek);
|
|
75
90
|
const missing = entries.find(([key]) => !read.some((filter) => dashboardFilterLocalIdentifier(filter) === key));
|
|
76
91
|
if (missing !== undefined) {
|
|
77
92
|
throw newError(CoreErrorCode.ItemNotSupported, [missing[0]], errorContext);
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import type { PublisherPeriodV2 as AacPublisherPeriodV2 } from "@gooddata/sdk-code-schemas/v1";
|
|
1
|
+
import type { PublisherPeriodV2 as AacPublisherPeriodV2, PublisherRelativePeriodV2 } from "@gooddata/sdk-code-schemas/v1";
|
|
2
2
|
import { type PublisherPeriodV2 } from "@gooddata/sdk-model";
|
|
3
|
+
import { type IErrorContext } from "./errors.js";
|
|
4
|
+
type YamlPeriodGranularity = PublisherRelativePeriodV2["granularity"];
|
|
3
5
|
/** @internal */
|
|
4
|
-
export declare function
|
|
6
|
+
export declare function assertPublisherGranularityV2(granularity: unknown, errorContext: IErrorContext | undefined): asserts granularity is YamlPeriodGranularity;
|
|
7
|
+
/** @internal */
|
|
8
|
+
export declare function periodToDeclarativeV2(period: AacPublisherPeriodV2, errorContext: IErrorContext | undefined): PublisherPeriodV2;
|
|
5
9
|
/** @internal */
|
|
6
10
|
export declare function periodToYamlV2(period: PublisherPeriodV2): AacPublisherPeriodV2;
|
|
11
|
+
export {};
|
|
7
12
|
//# sourceMappingURL=publisherPeriodV2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publisherPeriodV2.d.ts","sourceRoot":"","sources":["../../src/utils/publisherPeriodV2.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,iBAAiB,IAAI,oBAAoB,
|
|
1
|
+
{"version":3,"file":"publisherPeriodV2.d.ts","sourceRoot":"","sources":["../../src/utils/publisherPeriodV2.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,iBAAiB,IAAI,oBAAoB,EACzC,yBAAyB,EAC5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAA8B,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGzF,OAAO,EAAiB,KAAK,aAAa,EAAgC,MAAM,aAAa,CAAC;AAE9F,KAAK,qBAAqB,GAAG,yBAAyB,CAAC,aAAa,CAAC,CAAC;AAuBtE,gBAAgB;AAChB,wBAAgB,4BAA4B,CACxC,WAAW,EAAE,OAAO,EACpB,YAAY,EAAE,aAAa,GAAG,SAAS,GACxC,OAAO,CAAC,WAAW,IAAI,qBAAqB,CAS9C;AAED,gBAAgB;AAChB,wBAAgB,qBAAqB,CACjC,MAAM,EAAE,oBAAoB,EAC5B,YAAY,EAAE,aAAa,GAAG,SAAS,GACxC,iBAAiB,CAWnB;AAED,gBAAgB;AAChB,wBAAgB,cAAc,CAAC,MAAM,EAAE,iBAAiB,GAAG,oBAAoB,CAK9E"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { describeValue } from "./describeValue.js";
|
|
3
|
+
import { CoreErrorCode, newError, updateErrorContext } from "./errors.js";
|
|
2
4
|
const storedGranularities = {
|
|
3
5
|
SECOND: "GDC.time.second",
|
|
4
6
|
MINUTE: "GDC.time.minute",
|
|
5
7
|
HOUR: "GDC.time.hour",
|
|
6
8
|
DAY: "GDC.time.date",
|
|
9
|
+
WEEK: "GDC.time.week_us",
|
|
7
10
|
WEEK_US: "GDC.time.week_us",
|
|
8
11
|
MONTH: "GDC.time.month",
|
|
9
12
|
QUARTER: "GDC.time.quarter",
|
|
@@ -12,10 +15,20 @@ const storedGranularities = {
|
|
|
12
15
|
FISCAL_QUARTER: "GDC.time.fiscal_quarter",
|
|
13
16
|
FISCAL_MONTH: "GDC.time.fiscal_month",
|
|
14
17
|
};
|
|
15
|
-
const yamlGranularities = Object.fromEntries(Object.entries(storedGranularities)
|
|
18
|
+
const yamlGranularities = Object.fromEntries(Object.entries(storedGranularities)
|
|
19
|
+
.filter(([yaml]) => yaml !== "WEEK")
|
|
20
|
+
.map(([yaml, stored]) => [stored, yaml]));
|
|
16
21
|
/** @internal */
|
|
17
|
-
export function
|
|
22
|
+
export function assertPublisherGranularityV2(granularity, errorContext) {
|
|
23
|
+
if (typeof granularity === "string" && Object.hasOwn(storedGranularities, granularity)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
throw newError(CoreErrorCode.UnsupportedGranularity, [describeValue(granularity), Object.keys(storedGranularities).join(", ")], updateErrorContext(errorContext, { path: ["granularity"] }));
|
|
27
|
+
}
|
|
28
|
+
/** @internal */
|
|
29
|
+
export function periodToDeclarativeV2(period, errorContext) {
|
|
18
30
|
if ("granularity" in period) {
|
|
31
|
+
assertPublisherGranularityV2(period.granularity, errorContext);
|
|
19
32
|
return {
|
|
20
33
|
type: "relative",
|
|
21
34
|
granularity: storedGranularities[period.granularity],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publisherVersionV2.d.ts","sourceRoot":"","sources":["../../src/utils/publisherVersionV2.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"publisherVersionV2.d.ts","sourceRoot":"","sources":["../../src/utils/publisherVersionV2.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAGrE,OAAO,EAAiB,KAAK,aAAa,EAAgC,MAAM,aAAa,CAAC;AAE9F,gBAAgB;AAChB,eAAO,MAAM,yBAAyB,EAAE,yBAA+B,CAAC;AAExE,gBAAgB;AAChB,wBAAgB,+BAA+B,CAC3C,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,EACjC,YAAY,EAAE,aAAa,GAAG,SAAS,GACxC,IAAI,CAaN"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { describeValue } from "./describeValue.js";
|
|
2
3
|
import { CoreErrorCode, newError, updateErrorContext } from "./errors.js";
|
|
3
4
|
/** @internal */
|
|
4
5
|
export const publisherContentVersionV2 = "2";
|
|
5
6
|
/** @internal */
|
|
6
7
|
export function assertPublisherContentVersionV2({ version }, errorContext) {
|
|
7
|
-
if (version
|
|
8
|
-
|
|
8
|
+
if (version === publisherContentVersionV2) {
|
|
9
|
+
return;
|
|
9
10
|
}
|
|
11
|
+
const context = updateErrorContext(errorContext, { path: ["version"] });
|
|
12
|
+
if (version === undefined) {
|
|
13
|
+
throw newError(CoreErrorCode.MissingRequiredKey, ["version"], context);
|
|
14
|
+
}
|
|
15
|
+
throw newError(CoreErrorCode.UnsupportedContentVersion, [publisherContentVersionV2, describeValue(version)], context);
|
|
10
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gooddata/sdk-code-convertors",
|
|
3
|
-
"version": "11.65.0-alpha.
|
|
3
|
+
"version": "11.65.0-alpha.9",
|
|
4
4
|
"description": "GoodData AAC declarative converters",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "GoodData",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"uuid": "11.1.1",
|
|
28
28
|
"yaml": "2.8.3",
|
|
29
|
-
"@gooddata/
|
|
30
|
-
"@gooddata/sdk-model": "11.65.0-alpha.
|
|
31
|
-
"@gooddata/
|
|
29
|
+
"@gooddata/sdk-code-schemas": "11.65.0-alpha.9",
|
|
30
|
+
"@gooddata/sdk-model": "11.65.0-alpha.9",
|
|
31
|
+
"@gooddata/api-client-tiger": "11.65.0-alpha.9"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@microsoft/api-extractor": "7.59.2",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"oxlint-tsgolint": "7.0.2001",
|
|
49
49
|
"typescript": "7.0.2",
|
|
50
50
|
"vitest": "5.0.4",
|
|
51
|
-
"@gooddata/eslint-config": "11.65.0-alpha.
|
|
52
|
-
"@gooddata/oxlint-config": "11.65.0-alpha.
|
|
51
|
+
"@gooddata/eslint-config": "11.65.0-alpha.9",
|
|
52
|
+
"@gooddata/oxlint-config": "11.65.0-alpha.9"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"_phase:build": "npm run build",
|