@gooddata/sdk-backend-tiger 11.64.0-alpha.2 → 11.64.0-alpha.4
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/__version.d.ts +1 -1
- package/esm/__version.js +1 -1
- package/esm/backend/dataSources/index.d.ts +5 -1
- package/esm/backend/dataSources/index.d.ts.map +1 -1
- package/esm/backend/dataSources/index.js +42 -3
- package/esm/backend/features/feature.d.ts.map +1 -1
- package/esm/backend/features/feature.js +1 -0
- package/esm/backend/localization/aggregate.d.ts +1 -0
- package/esm/backend/localization/aggregate.d.ts.map +1 -1
- package/esm/backend/localization/aggregate.js +6 -0
- package/esm/backend/localization/fromBackend.js +2 -2
- package/esm/backend/uiFeatures.d.ts +3 -0
- package/esm/backend/uiFeatures.d.ts.map +1 -1
- package/esm/backend/uiFeatures.js +3 -0
- package/esm/backend/workspace/customApplicationSettings/index.d.ts +13 -0
- package/esm/backend/workspace/customApplicationSettings/index.d.ts.map +1 -0
- package/esm/backend/workspace/customApplicationSettings/index.js +53 -0
- package/esm/backend/workspace/index.d.ts +2 -1
- package/esm/backend/workspace/index.d.ts.map +1 -1
- package/esm/backend/workspace/index.js +4 -0
- package/esm/backend/workspace/ldm/index.d.ts +5 -1
- package/esm/backend/workspace/ldm/index.d.ts.map +1 -1
- package/esm/backend/workspace/ldm/index.js +32 -1
- package/esm/backend/workspace/references/index.d.ts +1 -0
- package/esm/backend/workspace/references/index.d.ts.map +1 -1
- package/esm/backend/workspace/references/index.js +28 -11
- package/esm/convertors/fromBackend/DeclarativeModelConverter.d.ts +4 -0
- package/esm/convertors/fromBackend/DeclarativeModelConverter.d.ts.map +1 -0
- package/esm/convertors/fromBackend/DeclarativeModelConverter.js +280 -0
- package/esm/convertors/fromBackend/PhysicalModelConverter.d.ts +5 -0
- package/esm/convertors/fromBackend/PhysicalModelConverter.d.ts.map +1 -0
- package/esm/convertors/fromBackend/PhysicalModelConverter.js +63 -0
- package/esm/convertors/shared/declarativeFields.d.ts +20 -0
- package/esm/convertors/shared/declarativeFields.d.ts.map +1 -0
- package/esm/convertors/shared/declarativeFields.js +23 -0
- package/esm/convertors/toBackend/DeclarativeModelConverter.d.ts +4 -0
- package/esm/convertors/toBackend/DeclarativeModelConverter.d.ts.map +1 -0
- package/esm/convertors/toBackend/DeclarativeModelConverter.js +277 -0
- package/esm/convertors/toBackend/PhysicalModelConverter.d.ts +5 -0
- package/esm/convertors/toBackend/PhysicalModelConverter.d.ts.map +1 -0
- package/esm/convertors/toBackend/PhysicalModelConverter.js +97 -0
- package/package.json +11 -11
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { assertAllFieldsMapped, copyArray, mapArray, mapRecord, withoutUndefined, } from "../shared/declarativeFields.js";
|
|
3
|
+
export function convertDeclarativeLdm(ldm) {
|
|
4
|
+
if (!ldm) {
|
|
5
|
+
return {};
|
|
6
|
+
}
|
|
7
|
+
const { calendars, datasetExtensions, datasets, dateInstances, ...unmapped } = ldm;
|
|
8
|
+
assertAllFieldsMapped(unmapped);
|
|
9
|
+
return withoutUndefined({
|
|
10
|
+
calendars: mapRecord(calendars, convertCalendar),
|
|
11
|
+
datasetExtensions: mapArray(datasetExtensions, convertDatasetExtension),
|
|
12
|
+
datasets: mapArray(datasets, convertDataset),
|
|
13
|
+
dateInstances: mapArray(dateInstances, convertDateDataset),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function convertCalendar(calendar) {
|
|
17
|
+
const { definition, description, enabledGranularities, name, ...unmapped } = calendar;
|
|
18
|
+
assertAllFieldsMapped(unmapped);
|
|
19
|
+
return withoutUndefined({
|
|
20
|
+
definition: convertCalendarDefinition(definition),
|
|
21
|
+
description,
|
|
22
|
+
enabledGranularities: enabledGranularities.map(({ granularity, prefix, ...rest }) => {
|
|
23
|
+
assertAllFieldsMapped(rest);
|
|
24
|
+
return { granularity, prefix };
|
|
25
|
+
}),
|
|
26
|
+
name,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function convertCalendarDefinition(definition) {
|
|
30
|
+
if (definition.type === "fiscalYear") {
|
|
31
|
+
const { type, monthOffset, ...unmapped } = definition;
|
|
32
|
+
assertAllFieldsMapped(unmapped);
|
|
33
|
+
return { type, monthOffset };
|
|
34
|
+
}
|
|
35
|
+
const { type, dataSourceTables, ...unmapped } = definition;
|
|
36
|
+
assertAllFieldsMapped(unmapped);
|
|
37
|
+
return {
|
|
38
|
+
type,
|
|
39
|
+
dataSourceTables: mapRecord(dataSourceTables, ({ path, version, ...rest }) => {
|
|
40
|
+
assertAllFieldsMapped(rest);
|
|
41
|
+
return { path: [...path], version };
|
|
42
|
+
}) ?? {},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function convertDatasetExtension(extension) {
|
|
46
|
+
const { id, workspaceDataFilterReferences, ...unmapped } = extension;
|
|
47
|
+
assertAllFieldsMapped(unmapped);
|
|
48
|
+
return withoutUndefined({
|
|
49
|
+
id,
|
|
50
|
+
workspaceDataFilterReferences: mapArray(workspaceDataFilterReferences, convertWorkspaceDataFilterReference),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function convertWorkspaceDataFilterReference(reference) {
|
|
54
|
+
const { filterColumn, filterColumnDataType, filterId, ...unmapped } = reference;
|
|
55
|
+
assertAllFieldsMapped(unmapped);
|
|
56
|
+
const { id, type, ...unmappedId } = filterId;
|
|
57
|
+
assertAllFieldsMapped(unmappedId);
|
|
58
|
+
return { filterColumn, filterColumnDataType, filterId: { id, type } };
|
|
59
|
+
}
|
|
60
|
+
function convertDataset(dataset) {
|
|
61
|
+
const { aggregatedFacts, attributes, dataSourceTableId, description, facts, grain, id, precedence, references, sql, tags, title, type, workspaceDataFilterColumns, workspaceDataFilterReferences, ...unmapped } = dataset;
|
|
62
|
+
assertAllFieldsMapped(unmapped);
|
|
63
|
+
return withoutUndefined({
|
|
64
|
+
aggregatedFacts: mapArray(aggregatedFacts, convertAggregatedFact),
|
|
65
|
+
attributes: mapArray(attributes, convertAttribute),
|
|
66
|
+
dataSourceTableId: dataSourceTableId && convertDataSourceTableId(dataSourceTableId),
|
|
67
|
+
description,
|
|
68
|
+
facts: mapArray(facts, convertFact),
|
|
69
|
+
grain: mapArray(grain, convertGrainIdentifier),
|
|
70
|
+
id,
|
|
71
|
+
precedence,
|
|
72
|
+
references: mapArray(references, convertReference),
|
|
73
|
+
sql: sql && convertDatasetSql(sql),
|
|
74
|
+
tags: copyArray(tags),
|
|
75
|
+
title,
|
|
76
|
+
type,
|
|
77
|
+
workspaceDataFilterColumns: mapArray(workspaceDataFilterColumns, convertWorkspaceDataFilterColumn),
|
|
78
|
+
workspaceDataFilterReferences: mapArray(workspaceDataFilterReferences, convertWorkspaceDataFilterReference),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function convertAggregatedFact(fact) {
|
|
82
|
+
const { description, id, isNullable, nullValue, sourceColumn, sourceColumnDataType, sourceFactReference, tags, ...unmapped } = fact;
|
|
83
|
+
assertAllFieldsMapped(unmapped);
|
|
84
|
+
const { operation, reference, ...unmappedReference } = sourceFactReference;
|
|
85
|
+
assertAllFieldsMapped(unmappedReference);
|
|
86
|
+
const { id: referenceId, type: referenceType, ...unmappedIdentifier } = reference;
|
|
87
|
+
assertAllFieldsMapped(unmappedIdentifier);
|
|
88
|
+
return withoutUndefined({
|
|
89
|
+
description,
|
|
90
|
+
id,
|
|
91
|
+
isNullable,
|
|
92
|
+
nullValue,
|
|
93
|
+
sourceColumn,
|
|
94
|
+
sourceColumnDataType,
|
|
95
|
+
sourceFactReference: { operation, reference: { id: referenceId, type: referenceType } },
|
|
96
|
+
tags: copyArray(tags),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function convertAttribute(attribute) {
|
|
100
|
+
const { conditionalFormatting, defaultView, description, id, isHidden, isNullable, labels, locale, nullValue, sortColumn, sortDirection, sourceColumn, sourceColumnDataType, tags, title, ...unmapped } = attribute;
|
|
101
|
+
assertAllFieldsMapped(unmapped);
|
|
102
|
+
return withoutUndefined({
|
|
103
|
+
conditionalFormatting: convertConditionalFormatting(conditionalFormatting),
|
|
104
|
+
defaultView: defaultView && convertLabelIdentifier(defaultView),
|
|
105
|
+
description,
|
|
106
|
+
id,
|
|
107
|
+
isHidden,
|
|
108
|
+
isNullable,
|
|
109
|
+
labels: mapArray(labels, convertLabel),
|
|
110
|
+
locale,
|
|
111
|
+
nullValue,
|
|
112
|
+
sortColumn,
|
|
113
|
+
sortDirection,
|
|
114
|
+
sourceColumn,
|
|
115
|
+
sourceColumnDataType,
|
|
116
|
+
tags: copyArray(tags),
|
|
117
|
+
title,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function convertLabel(label) {
|
|
121
|
+
const { conditionalFormatting, description, geoAreaConfig, id, isHidden, isNullable, locale, nullValue, sourceColumn, sourceColumnDataType, tags, title, translations, valueType, ...unmapped } = label;
|
|
122
|
+
assertAllFieldsMapped(unmapped);
|
|
123
|
+
return withoutUndefined({
|
|
124
|
+
conditionalFormatting: convertConditionalFormatting(conditionalFormatting),
|
|
125
|
+
description,
|
|
126
|
+
geoAreaConfig: geoAreaConfig && convertGeoAreaConfig(geoAreaConfig),
|
|
127
|
+
id,
|
|
128
|
+
isHidden,
|
|
129
|
+
isNullable,
|
|
130
|
+
locale,
|
|
131
|
+
nullValue,
|
|
132
|
+
sourceColumn,
|
|
133
|
+
sourceColumnDataType,
|
|
134
|
+
tags: copyArray(tags),
|
|
135
|
+
title,
|
|
136
|
+
translations: mapArray(translations, ({ locale, sourceColumn, ...rest }) => {
|
|
137
|
+
assertAllFieldsMapped(rest);
|
|
138
|
+
return { locale, sourceColumn };
|
|
139
|
+
}),
|
|
140
|
+
valueType,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
function convertConditionalFormatting(conditionalFormatting) {
|
|
144
|
+
if (!conditionalFormatting) {
|
|
145
|
+
return conditionalFormatting;
|
|
146
|
+
}
|
|
147
|
+
const { conditions, enabled, ...unmapped } = conditionalFormatting;
|
|
148
|
+
assertAllFieldsMapped(unmapped);
|
|
149
|
+
return { conditions: conditions.map(convertConditionalFormattingCondition), enabled };
|
|
150
|
+
}
|
|
151
|
+
function convertConditionalFormattingCondition(condition) {
|
|
152
|
+
const { format, id, operator, value, ...unmapped } = condition;
|
|
153
|
+
assertAllFieldsMapped(unmapped);
|
|
154
|
+
const { backgroundColor, color, scope, ...unmappedFormat } = format;
|
|
155
|
+
assertAllFieldsMapped(unmappedFormat);
|
|
156
|
+
return withoutUndefined({
|
|
157
|
+
format: withoutUndefined({ backgroundColor, color, scope }),
|
|
158
|
+
id,
|
|
159
|
+
operator,
|
|
160
|
+
value: convertConditionalFormattingValue(value),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function convertConditionalFormattingValue(value) {
|
|
164
|
+
switch (value.kind) {
|
|
165
|
+
case "none": {
|
|
166
|
+
const { kind, ...unmapped } = value;
|
|
167
|
+
assertAllFieldsMapped(unmapped);
|
|
168
|
+
return { kind };
|
|
169
|
+
}
|
|
170
|
+
case "literal": {
|
|
171
|
+
const { kind, value: literal, ...unmapped } = value;
|
|
172
|
+
assertAllFieldsMapped(unmapped);
|
|
173
|
+
return { kind, value: literal };
|
|
174
|
+
}
|
|
175
|
+
case "literalRange": {
|
|
176
|
+
const { kind, from, to, ...unmapped } = value;
|
|
177
|
+
assertAllFieldsMapped(unmapped);
|
|
178
|
+
return { kind, from, to };
|
|
179
|
+
}
|
|
180
|
+
case "absoluteDate": {
|
|
181
|
+
const { from, to, kind, ...unmapped } = value;
|
|
182
|
+
assertAllFieldsMapped(unmapped);
|
|
183
|
+
return { from, to, kind };
|
|
184
|
+
}
|
|
185
|
+
case "relativeDate": {
|
|
186
|
+
const { kind, granularity, from, to, ...unmapped } = value;
|
|
187
|
+
assertAllFieldsMapped(unmapped);
|
|
188
|
+
return { kind, granularity, from, to };
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function convertDataSourceTableId(tableId) {
|
|
193
|
+
const { dataSourceId, id, path, type, ...unmapped } = tableId;
|
|
194
|
+
assertAllFieldsMapped(unmapped);
|
|
195
|
+
return withoutUndefined({ dataSourceId, id, path: copyArray(path), type });
|
|
196
|
+
}
|
|
197
|
+
function convertFact(fact) {
|
|
198
|
+
const { description, id, isHidden, isNullable, nullValue, sourceColumn, sourceColumnDataType, tags, title, ...unmapped } = fact;
|
|
199
|
+
assertAllFieldsMapped(unmapped);
|
|
200
|
+
return withoutUndefined({
|
|
201
|
+
description,
|
|
202
|
+
id,
|
|
203
|
+
isHidden,
|
|
204
|
+
isNullable,
|
|
205
|
+
nullValue,
|
|
206
|
+
sourceColumn,
|
|
207
|
+
sourceColumnDataType,
|
|
208
|
+
tags: copyArray(tags),
|
|
209
|
+
title,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function convertGrainIdentifier(grain) {
|
|
213
|
+
const { id, type, ...unmapped } = grain;
|
|
214
|
+
assertAllFieldsMapped(unmapped);
|
|
215
|
+
return { id, type };
|
|
216
|
+
}
|
|
217
|
+
function convertReference(reference) {
|
|
218
|
+
const { identifier, multivalue, sourceColumnDataTypes, sourceColumns, sources, ...unmapped } = reference;
|
|
219
|
+
assertAllFieldsMapped(unmapped);
|
|
220
|
+
const { id, type, ...unmappedIdentifier } = identifier;
|
|
221
|
+
assertAllFieldsMapped(unmappedIdentifier);
|
|
222
|
+
return withoutUndefined({
|
|
223
|
+
identifier: { id, type },
|
|
224
|
+
multivalue,
|
|
225
|
+
sourceColumnDataTypes: copyArray(sourceColumnDataTypes),
|
|
226
|
+
sourceColumns: copyArray(sourceColumns),
|
|
227
|
+
sources: mapArray(sources, convertReferenceSource),
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
function convertReferenceSource(source) {
|
|
231
|
+
const { column, dataType, isNullable, nullValue, target, ...unmapped } = source;
|
|
232
|
+
assertAllFieldsMapped(unmapped);
|
|
233
|
+
return withoutUndefined({
|
|
234
|
+
column,
|
|
235
|
+
dataType,
|
|
236
|
+
isNullable,
|
|
237
|
+
nullValue,
|
|
238
|
+
target: convertGrainIdentifier(target),
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
function convertDatasetSql(sql) {
|
|
242
|
+
const { dataSourceId, statement, ...unmapped } = sql;
|
|
243
|
+
assertAllFieldsMapped(unmapped);
|
|
244
|
+
return { dataSourceId, statement };
|
|
245
|
+
}
|
|
246
|
+
function convertWorkspaceDataFilterColumn(column) {
|
|
247
|
+
const { dataType, name, ...unmapped } = column;
|
|
248
|
+
assertAllFieldsMapped(unmapped);
|
|
249
|
+
return { dataType, name };
|
|
250
|
+
}
|
|
251
|
+
function convertDateDataset(dateDataset) {
|
|
252
|
+
const { conditionalFormatting, description, granularities, granularitiesFormatting, id, tags, title, ...unmapped } = dateDataset;
|
|
253
|
+
assertAllFieldsMapped(unmapped);
|
|
254
|
+
const { titleBase, titlePattern, ...unmappedFormatting } = granularitiesFormatting;
|
|
255
|
+
assertAllFieldsMapped(unmappedFormatting);
|
|
256
|
+
return withoutUndefined({
|
|
257
|
+
conditionalFormatting: convertConditionalFormatting(conditionalFormatting),
|
|
258
|
+
description,
|
|
259
|
+
granularities: [...granularities],
|
|
260
|
+
granularitiesFormatting: { titleBase, titlePattern },
|
|
261
|
+
id,
|
|
262
|
+
tags: copyArray(tags),
|
|
263
|
+
title,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
function convertLabelIdentifier(identifier) {
|
|
267
|
+
const { id, type, ...unmapped } = identifier;
|
|
268
|
+
assertAllFieldsMapped(unmapped);
|
|
269
|
+
return { id, type };
|
|
270
|
+
}
|
|
271
|
+
function convertGeoAreaConfig(config) {
|
|
272
|
+
const { collection, ...unmapped } = config;
|
|
273
|
+
assertAllFieldsMapped(unmapped);
|
|
274
|
+
return { collection: convertGeoCollectionIdentifier(collection) };
|
|
275
|
+
}
|
|
276
|
+
function convertGeoCollectionIdentifier(identifier) {
|
|
277
|
+
const { id, kind, ...unmapped } = identifier;
|
|
278
|
+
assertAllFieldsMapped(unmapped);
|
|
279
|
+
return withoutUndefined({ id, kind });
|
|
280
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ScanResultPdm, type ScanSqlResponse } from "@gooddata/api-client-tiger";
|
|
2
|
+
import { type IDataSourceScanResult, type ISqlScanResult } from "@gooddata/sdk-model";
|
|
3
|
+
export declare function convertScanResult(result: ScanResultPdm): IDataSourceScanResult;
|
|
4
|
+
export declare function convertSqlScanResult(result: ScanSqlResponse): ISqlScanResult;
|
|
5
|
+
//# sourceMappingURL=PhysicalModelConverter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhysicalModelConverter.d.ts","sourceRoot":"","sources":["../../../src/convertors/fromBackend/PhysicalModelConverter.ts"],"names":[],"mappings":"AAEA,OAAO,EAIH,KAAK,aAAa,EAClB,KAAK,eAAe,EAEvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,KAAK,qBAAqB,EAK1B,KAAK,cAAc,EACtB,MAAM,qBAAqB,CAAC;AAI7B,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,qBAAqB,CAS9E;AAsDD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,CAO5E"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { assertAllFieldsMapped, mapArray, withoutUndefined } from "../shared/declarativeFields.js";
|
|
3
|
+
export function convertScanResult(result) {
|
|
4
|
+
const { pdm, warnings, ...unmapped } = result;
|
|
5
|
+
assertAllFieldsMapped(unmapped);
|
|
6
|
+
const { tables, ...unmappedPdm } = pdm;
|
|
7
|
+
assertAllFieldsMapped(unmappedPdm);
|
|
8
|
+
return {
|
|
9
|
+
pdm: { tables: tables.map(convertPhysicalTable) },
|
|
10
|
+
warnings: mapArray(warnings, convertTableWarning) ?? [],
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function convertPhysicalTable(table) {
|
|
14
|
+
const { columns, id, namePrefix, path, type, ...unmapped } = table;
|
|
15
|
+
assertAllFieldsMapped(unmapped);
|
|
16
|
+
return withoutUndefined({
|
|
17
|
+
columns: columns.map(convertPhysicalColumn),
|
|
18
|
+
id,
|
|
19
|
+
namePrefix,
|
|
20
|
+
path: [...path],
|
|
21
|
+
type,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function convertPhysicalColumn(column) {
|
|
25
|
+
const { dataType, defaultLabelOf, description, isNullable, isPrimaryKey, name, nullValue, referencedTableColumn, referencedTableId, ...unmapped } = column;
|
|
26
|
+
assertAllFieldsMapped(unmapped);
|
|
27
|
+
return withoutUndefined({
|
|
28
|
+
dataType,
|
|
29
|
+
defaultLabelOf,
|
|
30
|
+
description,
|
|
31
|
+
isNullable,
|
|
32
|
+
isPrimaryKey,
|
|
33
|
+
name,
|
|
34
|
+
nullValue,
|
|
35
|
+
referencedTableColumn,
|
|
36
|
+
referencedTableId,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function convertTableWarning(warning) {
|
|
40
|
+
const { columns, message, name, ...unmapped } = warning;
|
|
41
|
+
assertAllFieldsMapped(unmapped);
|
|
42
|
+
return withoutUndefined({
|
|
43
|
+
columns: columns.map(({ message, name, ...rest }) => {
|
|
44
|
+
assertAllFieldsMapped(rest);
|
|
45
|
+
return { message, name };
|
|
46
|
+
}),
|
|
47
|
+
message,
|
|
48
|
+
name,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
export function convertSqlScanResult(result) {
|
|
52
|
+
const { columns, dataPreview, ...unmapped } = result;
|
|
53
|
+
assertAllFieldsMapped(unmapped);
|
|
54
|
+
return withoutUndefined({
|
|
55
|
+
columns: columns.map(convertSqlColumn),
|
|
56
|
+
dataPreview: mapArray(dataPreview, (row) => [...row]),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function convertSqlColumn(column) {
|
|
60
|
+
const { dataType, description, name, nullValue, ...unmapped } = column;
|
|
61
|
+
assertAllFieldsMapped(unmapped);
|
|
62
|
+
return withoutUndefined({ dataType, description, name, nullValue });
|
|
63
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fails to compile when a converter does not destructure every field of its input.
|
|
3
|
+
* Pass the rest of the destructured input object.
|
|
4
|
+
*/
|
|
5
|
+
export declare function assertAllFieldsMapped(_unmapped: Record<string, never>): void;
|
|
6
|
+
/**
|
|
7
|
+
* Returns the object without the keys whose value is undefined. A key with a null value stays.
|
|
8
|
+
*/
|
|
9
|
+
export declare function withoutUndefined<T extends object>(obj: NoInfer<T>): T;
|
|
10
|
+
export declare function copyArray<T>(array: T[]): T[];
|
|
11
|
+
export declare function copyArray<T>(array: T[] | undefined): T[] | undefined;
|
|
12
|
+
export declare function copyArray<T>(array: T[] | null | undefined): T[] | null | undefined;
|
|
13
|
+
export declare function mapArray<T, R>(array: T[], fn: (item: T) => R): R[];
|
|
14
|
+
export declare function mapArray<T, R>(array: T[] | undefined, fn: (item: T) => R): R[] | undefined;
|
|
15
|
+
export declare function mapRecord<T, R>(record: {
|
|
16
|
+
[key: string]: T;
|
|
17
|
+
} | undefined, fn: (item: T) => R): {
|
|
18
|
+
[key: string]: R;
|
|
19
|
+
} | undefined;
|
|
20
|
+
//# sourceMappingURL=declarativeFields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarativeFields.d.ts","sourceRoot":"","sources":["../../../src/convertors/shared/declarativeFields.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,IAAI,CAAG;AAEhF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAErE;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AAC9C,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,SAAS,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC;AACtE,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;AAKpF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;AACpE,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,SAAS,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC;AAK5F,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAC1B,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAA;CAAE,GAAG,SAAS,EACxC,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GACnB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAA;CAAE,GAAG,SAAS,CAIlC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
/**
|
|
3
|
+
* Fails to compile when a converter does not destructure every field of its input.
|
|
4
|
+
* Pass the rest of the destructured input object.
|
|
5
|
+
*/
|
|
6
|
+
export function assertAllFieldsMapped(_unmapped) { }
|
|
7
|
+
/**
|
|
8
|
+
* Returns the object without the keys whose value is undefined. A key with a null value stays.
|
|
9
|
+
*/
|
|
10
|
+
export function withoutUndefined(obj) {
|
|
11
|
+
return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined));
|
|
12
|
+
}
|
|
13
|
+
export function copyArray(array) {
|
|
14
|
+
return array ? [...array] : array;
|
|
15
|
+
}
|
|
16
|
+
export function mapArray(array, fn) {
|
|
17
|
+
return array?.map((item) => fn(item));
|
|
18
|
+
}
|
|
19
|
+
export function mapRecord(record, fn) {
|
|
20
|
+
return record
|
|
21
|
+
? Object.fromEntries(Object.entries(record).map(([key, value]) => [key, fn(value)]))
|
|
22
|
+
: undefined;
|
|
23
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type DeclarativeLdm } from "@gooddata/api-client-tiger";
|
|
2
|
+
import { type IDeclarativeLogicalModel } from "@gooddata/sdk-model";
|
|
3
|
+
export declare function convertDeclarativeLdmToBackend(ldm: IDeclarativeLogicalModel): DeclarativeLdm;
|
|
4
|
+
//# sourceMappingURL=DeclarativeModelConverter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeclarativeModelConverter.d.ts","sourceRoot":"","sources":["../../../src/convertors/toBackend/DeclarativeModelConverter.ts"],"names":[],"mappings":"AAEA,OAAO,EAcH,KAAK,cAAc,EAUtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAmBH,KAAK,wBAAwB,EAKhC,MAAM,qBAAqB,CAAC;AAU7B,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,wBAAwB,GAAG,cAAc,CAS5F"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { assertAllFieldsMapped, copyArray, mapArray, mapRecord, withoutUndefined, } from "../shared/declarativeFields.js";
|
|
3
|
+
export function convertDeclarativeLdmToBackend(ldm) {
|
|
4
|
+
const { calendars, datasetExtensions, datasets, dateInstances, ...unmapped } = ldm;
|
|
5
|
+
assertAllFieldsMapped(unmapped);
|
|
6
|
+
return withoutUndefined({
|
|
7
|
+
calendars: mapRecord(calendars, convertCalendar),
|
|
8
|
+
datasetExtensions: mapArray(datasetExtensions, convertDatasetExtension),
|
|
9
|
+
datasets: mapArray(datasets, convertDataset),
|
|
10
|
+
dateInstances: mapArray(dateInstances, convertDateDataset),
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function convertCalendar(calendar) {
|
|
14
|
+
const { definition, description, enabledGranularities, name, ...unmapped } = calendar;
|
|
15
|
+
assertAllFieldsMapped(unmapped);
|
|
16
|
+
return withoutUndefined({
|
|
17
|
+
definition: convertCalendarDefinition(definition),
|
|
18
|
+
description,
|
|
19
|
+
enabledGranularities: enabledGranularities.map(({ granularity, prefix, ...rest }) => {
|
|
20
|
+
assertAllFieldsMapped(rest);
|
|
21
|
+
return { granularity, prefix };
|
|
22
|
+
}),
|
|
23
|
+
name,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function convertCalendarDefinition(definition) {
|
|
27
|
+
if (definition.type === "fiscalYear") {
|
|
28
|
+
const { type, monthOffset, ...unmapped } = definition;
|
|
29
|
+
assertAllFieldsMapped(unmapped);
|
|
30
|
+
return { type, monthOffset };
|
|
31
|
+
}
|
|
32
|
+
const { type, dataSourceTables, ...unmapped } = definition;
|
|
33
|
+
assertAllFieldsMapped(unmapped);
|
|
34
|
+
return {
|
|
35
|
+
type,
|
|
36
|
+
dataSourceTables: mapRecord(dataSourceTables, ({ path, version, ...rest }) => {
|
|
37
|
+
assertAllFieldsMapped(rest);
|
|
38
|
+
return { path: [...path], version };
|
|
39
|
+
}) ?? {},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function convertDatasetExtension(extension) {
|
|
43
|
+
const { id, workspaceDataFilterReferences, ...unmapped } = extension;
|
|
44
|
+
assertAllFieldsMapped(unmapped);
|
|
45
|
+
return withoutUndefined({
|
|
46
|
+
id,
|
|
47
|
+
workspaceDataFilterReferences: mapArray(workspaceDataFilterReferences, convertWorkspaceDataFilterReference),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function convertWorkspaceDataFilterReference(reference) {
|
|
51
|
+
const { filterColumn, filterColumnDataType, filterId, ...unmapped } = reference;
|
|
52
|
+
assertAllFieldsMapped(unmapped);
|
|
53
|
+
const { id, type, ...unmappedId } = filterId;
|
|
54
|
+
assertAllFieldsMapped(unmappedId);
|
|
55
|
+
return { filterColumn, filterColumnDataType, filterId: { id, type } };
|
|
56
|
+
}
|
|
57
|
+
function convertDataset(dataset) {
|
|
58
|
+
const { aggregatedFacts, attributes, dataSourceTableId, description, facts, grain, id, precedence, references, sql, tags, title, type, workspaceDataFilterColumns, workspaceDataFilterReferences, ...unmapped } = dataset;
|
|
59
|
+
assertAllFieldsMapped(unmapped);
|
|
60
|
+
return withoutUndefined({
|
|
61
|
+
aggregatedFacts: mapArray(aggregatedFacts, convertAggregatedFact),
|
|
62
|
+
attributes: mapArray(attributes, convertAttribute),
|
|
63
|
+
dataSourceTableId: dataSourceTableId && convertDataSourceTableId(dataSourceTableId),
|
|
64
|
+
description,
|
|
65
|
+
facts: mapArray(facts, convertFact),
|
|
66
|
+
grain: mapArray(grain, convertGrainIdentifier),
|
|
67
|
+
id,
|
|
68
|
+
precedence,
|
|
69
|
+
references: mapArray(references, convertReference),
|
|
70
|
+
sql: sql && convertDatasetSql(sql),
|
|
71
|
+
tags: copyArray(tags),
|
|
72
|
+
title,
|
|
73
|
+
type,
|
|
74
|
+
workspaceDataFilterColumns: mapArray(workspaceDataFilterColumns, convertWorkspaceDataFilterColumn),
|
|
75
|
+
workspaceDataFilterReferences: mapArray(workspaceDataFilterReferences, convertWorkspaceDataFilterReference),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function convertAggregatedFact(fact) {
|
|
79
|
+
const { description, id, isNullable, nullValue, sourceColumn, sourceColumnDataType, sourceFactReference, tags, ...unmapped } = fact;
|
|
80
|
+
assertAllFieldsMapped(unmapped);
|
|
81
|
+
const { operation, reference, ...unmappedReference } = sourceFactReference;
|
|
82
|
+
assertAllFieldsMapped(unmappedReference);
|
|
83
|
+
const { id: referenceId, type: referenceType, ...unmappedIdentifier } = reference;
|
|
84
|
+
assertAllFieldsMapped(unmappedIdentifier);
|
|
85
|
+
return withoutUndefined({
|
|
86
|
+
description,
|
|
87
|
+
id,
|
|
88
|
+
isNullable,
|
|
89
|
+
nullValue,
|
|
90
|
+
sourceColumn,
|
|
91
|
+
sourceColumnDataType,
|
|
92
|
+
sourceFactReference: { operation, reference: { id: referenceId, type: referenceType } },
|
|
93
|
+
tags: copyArray(tags),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function convertAttribute(attribute) {
|
|
97
|
+
const { conditionalFormatting, defaultView, description, id, isHidden, isNullable, labels, locale, nullValue, sortColumn, sortDirection, sourceColumn, sourceColumnDataType, tags, title, ...unmapped } = attribute;
|
|
98
|
+
assertAllFieldsMapped(unmapped);
|
|
99
|
+
return withoutUndefined({
|
|
100
|
+
conditionalFormatting: convertConditionalFormatting(conditionalFormatting),
|
|
101
|
+
defaultView: defaultView && convertLabelIdentifier(defaultView),
|
|
102
|
+
description,
|
|
103
|
+
id,
|
|
104
|
+
isHidden,
|
|
105
|
+
isNullable,
|
|
106
|
+
labels: mapArray(labels, convertLabel),
|
|
107
|
+
locale,
|
|
108
|
+
nullValue,
|
|
109
|
+
sortColumn,
|
|
110
|
+
sortDirection,
|
|
111
|
+
sourceColumn,
|
|
112
|
+
sourceColumnDataType,
|
|
113
|
+
tags: copyArray(tags),
|
|
114
|
+
title,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
function convertLabel(label) {
|
|
118
|
+
const { conditionalFormatting, description, geoAreaConfig, id, isHidden, isNullable, locale, nullValue, sourceColumn, sourceColumnDataType, tags, title, translations, valueType, ...unmapped } = label;
|
|
119
|
+
assertAllFieldsMapped(unmapped);
|
|
120
|
+
return withoutUndefined({
|
|
121
|
+
conditionalFormatting: convertConditionalFormatting(conditionalFormatting),
|
|
122
|
+
description,
|
|
123
|
+
geoAreaConfig: geoAreaConfig && convertGeoAreaConfig(geoAreaConfig),
|
|
124
|
+
id,
|
|
125
|
+
isHidden,
|
|
126
|
+
isNullable,
|
|
127
|
+
locale,
|
|
128
|
+
nullValue,
|
|
129
|
+
sourceColumn,
|
|
130
|
+
sourceColumnDataType,
|
|
131
|
+
tags: copyArray(tags),
|
|
132
|
+
title,
|
|
133
|
+
translations: mapArray(translations, ({ locale, sourceColumn, ...rest }) => {
|
|
134
|
+
assertAllFieldsMapped(rest);
|
|
135
|
+
return { locale, sourceColumn };
|
|
136
|
+
}),
|
|
137
|
+
valueType,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function convertConditionalFormatting(conditionalFormatting) {
|
|
141
|
+
if (!conditionalFormatting) {
|
|
142
|
+
return conditionalFormatting;
|
|
143
|
+
}
|
|
144
|
+
const { conditions, enabled, ...unmapped } = conditionalFormatting;
|
|
145
|
+
assertAllFieldsMapped(unmapped);
|
|
146
|
+
return { conditions: conditions.map(convertConditionalFormattingCondition), enabled };
|
|
147
|
+
}
|
|
148
|
+
function convertConditionalFormattingCondition(condition) {
|
|
149
|
+
const { format, id, operator, value, ...unmapped } = condition;
|
|
150
|
+
assertAllFieldsMapped(unmapped);
|
|
151
|
+
const { backgroundColor, color, scope, ...unmappedFormat } = format;
|
|
152
|
+
assertAllFieldsMapped(unmappedFormat);
|
|
153
|
+
return withoutUndefined({
|
|
154
|
+
format: withoutUndefined({ backgroundColor, color, scope }),
|
|
155
|
+
id,
|
|
156
|
+
operator,
|
|
157
|
+
value: convertConditionalFormattingValue(value),
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function convertConditionalFormattingValue(value) {
|
|
161
|
+
switch (value.kind) {
|
|
162
|
+
case "none": {
|
|
163
|
+
const { kind, ...unmapped } = value;
|
|
164
|
+
assertAllFieldsMapped(unmapped);
|
|
165
|
+
return { kind };
|
|
166
|
+
}
|
|
167
|
+
case "literal": {
|
|
168
|
+
const { kind, value: literal, ...unmapped } = value;
|
|
169
|
+
assertAllFieldsMapped(unmapped);
|
|
170
|
+
return { kind, value: literal };
|
|
171
|
+
}
|
|
172
|
+
case "literalRange": {
|
|
173
|
+
const { kind, from, to, ...unmapped } = value;
|
|
174
|
+
assertAllFieldsMapped(unmapped);
|
|
175
|
+
return { kind, from, to };
|
|
176
|
+
}
|
|
177
|
+
case "absoluteDate": {
|
|
178
|
+
const { from, to, kind, ...unmapped } = value;
|
|
179
|
+
assertAllFieldsMapped(unmapped);
|
|
180
|
+
return { from, to, kind };
|
|
181
|
+
}
|
|
182
|
+
case "relativeDate": {
|
|
183
|
+
const { kind, granularity, from, to, ...unmapped } = value;
|
|
184
|
+
assertAllFieldsMapped(unmapped);
|
|
185
|
+
return { kind, granularity, from, to };
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function convertDataSourceTableId(tableId) {
|
|
190
|
+
const { dataSourceId, id, path, type, ...unmapped } = tableId;
|
|
191
|
+
assertAllFieldsMapped(unmapped);
|
|
192
|
+
return withoutUndefined({ dataSourceId, id, path: copyArray(path), type });
|
|
193
|
+
}
|
|
194
|
+
function convertFact(fact) {
|
|
195
|
+
const { description, id, isHidden, isNullable, nullValue, sourceColumn, sourceColumnDataType, tags, title, ...unmapped } = fact;
|
|
196
|
+
assertAllFieldsMapped(unmapped);
|
|
197
|
+
return withoutUndefined({
|
|
198
|
+
description,
|
|
199
|
+
id,
|
|
200
|
+
isHidden,
|
|
201
|
+
isNullable,
|
|
202
|
+
nullValue,
|
|
203
|
+
sourceColumn,
|
|
204
|
+
sourceColumnDataType,
|
|
205
|
+
tags: copyArray(tags),
|
|
206
|
+
title,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
function convertGrainIdentifier(grain) {
|
|
210
|
+
const { id, type, ...unmapped } = grain;
|
|
211
|
+
assertAllFieldsMapped(unmapped);
|
|
212
|
+
return { id, type };
|
|
213
|
+
}
|
|
214
|
+
function convertReference(reference) {
|
|
215
|
+
const { identifier, multivalue, sourceColumnDataTypes, sourceColumns, sources, ...unmapped } = reference;
|
|
216
|
+
assertAllFieldsMapped(unmapped);
|
|
217
|
+
const { id, type, ...unmappedIdentifier } = identifier;
|
|
218
|
+
assertAllFieldsMapped(unmappedIdentifier);
|
|
219
|
+
return withoutUndefined({
|
|
220
|
+
identifier: { id, type },
|
|
221
|
+
multivalue,
|
|
222
|
+
sourceColumnDataTypes: copyArray(sourceColumnDataTypes),
|
|
223
|
+
sourceColumns: copyArray(sourceColumns),
|
|
224
|
+
sources: mapArray(sources, convertReferenceSource),
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
function convertReferenceSource(source) {
|
|
228
|
+
const { column, dataType, isNullable, nullValue, target, ...unmapped } = source;
|
|
229
|
+
assertAllFieldsMapped(unmapped);
|
|
230
|
+
return withoutUndefined({
|
|
231
|
+
column,
|
|
232
|
+
dataType,
|
|
233
|
+
isNullable,
|
|
234
|
+
nullValue,
|
|
235
|
+
target: convertGrainIdentifier(target),
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function convertDatasetSql(sql) {
|
|
239
|
+
const { dataSourceId, statement, ...unmapped } = sql;
|
|
240
|
+
assertAllFieldsMapped(unmapped);
|
|
241
|
+
return { dataSourceId, statement };
|
|
242
|
+
}
|
|
243
|
+
function convertWorkspaceDataFilterColumn(column) {
|
|
244
|
+
const { dataType, name, ...unmapped } = column;
|
|
245
|
+
assertAllFieldsMapped(unmapped);
|
|
246
|
+
return { dataType, name };
|
|
247
|
+
}
|
|
248
|
+
function convertDateDataset(dateDataset) {
|
|
249
|
+
const { conditionalFormatting, description, granularities, granularitiesFormatting, id, tags, title, ...unmapped } = dateDataset;
|
|
250
|
+
assertAllFieldsMapped(unmapped);
|
|
251
|
+
const { titleBase, titlePattern, ...unmappedFormatting } = granularitiesFormatting;
|
|
252
|
+
assertAllFieldsMapped(unmappedFormatting);
|
|
253
|
+
return withoutUndefined({
|
|
254
|
+
conditionalFormatting: convertConditionalFormatting(conditionalFormatting),
|
|
255
|
+
description,
|
|
256
|
+
granularities: [...granularities],
|
|
257
|
+
granularitiesFormatting: { titleBase, titlePattern },
|
|
258
|
+
id,
|
|
259
|
+
tags: copyArray(tags),
|
|
260
|
+
title,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
function convertLabelIdentifier(identifier) {
|
|
264
|
+
const { id, type, ...unmapped } = identifier;
|
|
265
|
+
assertAllFieldsMapped(unmapped);
|
|
266
|
+
return { id, type };
|
|
267
|
+
}
|
|
268
|
+
function convertGeoAreaConfig(config) {
|
|
269
|
+
const { collection, ...unmapped } = config;
|
|
270
|
+
assertAllFieldsMapped(unmapped);
|
|
271
|
+
return { collection: convertGeoCollectionIdentifier(collection) };
|
|
272
|
+
}
|
|
273
|
+
function convertGeoCollectionIdentifier(identifier) {
|
|
274
|
+
const { id, kind, ...unmapped } = identifier;
|
|
275
|
+
assertAllFieldsMapped(unmapped);
|
|
276
|
+
return withoutUndefined({ id, kind });
|
|
277
|
+
}
|