@gooddata/sdk-code-convertors 11.30.0-alpha.2 → 11.30.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/from/declarativeAttributeHierarchyToYaml.d.ts +2 -1
- package/esm/from/declarativeAttributeHierarchyToYaml.d.ts.map +1 -1
- package/esm/from/declarativeAttributeHierarchyToYaml.js +8 -2
- package/esm/from/declarativeAttributeHierarchyToYaml.js.map +1 -1
- package/esm/from/declarativeDashboardToYaml.d.ts +14 -13
- package/esm/from/declarativeDashboardToYaml.d.ts.map +1 -1
- package/esm/from/declarativeDashboardToYaml.js +129 -99
- package/esm/from/declarativeDashboardToYaml.js.map +1 -1
- package/esm/from/declarativeVisualisationToYaml.d.ts +19 -18
- package/esm/from/declarativeVisualisationToYaml.d.ts.map +1 -1
- package/esm/from/declarativeVisualisationToYaml.js +239 -140
- package/esm/from/declarativeVisualisationToYaml.js.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/sdk-code-convertors.d.ts +71 -25
- package/esm/utils/dateUtils.js +4 -4
- package/esm/utils/dateUtils.js.map +1 -1
- package/esm/utils/errors.d.ts +15 -2
- package/esm/utils/errors.d.ts.map +1 -1
- package/esm/utils/errors.js +26 -4
- package/esm/utils/errors.js.map +1 -1
- package/esm/utils/yamlUtils.d.ts +4 -3
- package/esm/utils/yamlUtils.d.ts.map +1 -1
- package/esm/utils/yamlUtils.js +22 -21
- package/esm/utils/yamlUtils.js.map +1 -1
- package/package.json +6 -6
|
@@ -24,18 +24,23 @@ import { table } from "../configs/table.js";
|
|
|
24
24
|
import { treemapChart } from "../configs/treemapChart.js";
|
|
25
25
|
import { waterfallChart } from "../configs/waterfallChart.js";
|
|
26
26
|
import { BucketsType } from "../types.js";
|
|
27
|
-
import { CoreErrorCode, newError } from "../utils/errors.js";
|
|
27
|
+
import { CoreErrorCode, newError, updateErrorContext } from "../utils/errors.js";
|
|
28
28
|
import { matchConditionToYaml, parseDateValues } from "../utils/filterUtils.js";
|
|
29
29
|
import { parseGranularity } from "../utils/granularityUtils.js";
|
|
30
30
|
import { remapLocationAttribute } from "../utils/locationUtils.js";
|
|
31
31
|
import { VISUALISATION_COMMENT } from "../utils/texts.js";
|
|
32
32
|
import { cleanUpItems, createFilterItemKeyName, entryWithSpace, fillOptionalMetaFields, getIdentifier, } from "../utils/yamlUtils.js";
|
|
33
33
|
/** @public */
|
|
34
|
-
export function declarativeVisualisationToYaml(entities, visualisation) {
|
|
34
|
+
export function declarativeVisualisationToYaml(entities, visualisation, context) {
|
|
35
|
+
const errorContext = updateErrorContext(context, {
|
|
36
|
+
type: "visualisation",
|
|
37
|
+
path: ["visualisation", visualisation.id],
|
|
38
|
+
data: {},
|
|
39
|
+
});
|
|
35
40
|
// Build visualisation object
|
|
36
41
|
const insight = { insight: visualisation.content };
|
|
37
42
|
if (!isInsight(insight)) {
|
|
38
|
-
throw newError(CoreErrorCode.VisualizationNotSupported, [JSON.stringify(insight)]);
|
|
43
|
+
throw newError(CoreErrorCode.VisualizationNotSupported, [JSON.stringify(insight)], errorContext);
|
|
39
44
|
}
|
|
40
45
|
// Load type
|
|
41
46
|
const type = declarativeVisTypeToYaml(insight.insight);
|
|
@@ -57,9 +62,13 @@ export function declarativeVisualisationToYaml(entities, visualisation) {
|
|
|
57
62
|
if (visualisation.isHidden === true) {
|
|
58
63
|
doc.add(doc.createPair("show_in_ai_results", false));
|
|
59
64
|
}
|
|
60
|
-
const report = declarativeReportToYaml(entities, insight.insight
|
|
65
|
+
const report = declarativeReportToYaml(entities, insight.insight, updateErrorContext(errorContext, {
|
|
66
|
+
path: ["insight"],
|
|
67
|
+
}));
|
|
61
68
|
doc.add(entryWithSpace("query", report.report));
|
|
62
|
-
declarativeVisToYaml(doc, insight.insight, report, entities
|
|
69
|
+
declarativeVisToYaml(doc, insight.insight, report, entities, updateErrorContext(errorContext, {
|
|
70
|
+
path: ["insight"],
|
|
71
|
+
}));
|
|
63
72
|
return {
|
|
64
73
|
content: doc.toString({
|
|
65
74
|
lineWidth: 0,
|
|
@@ -67,25 +76,39 @@ export function declarativeVisualisationToYaml(entities, visualisation) {
|
|
|
67
76
|
json: doc.toJSON(),
|
|
68
77
|
};
|
|
69
78
|
}
|
|
70
|
-
function declarativeReportToYaml(entities, def) {
|
|
79
|
+
function declarativeReportToYaml(entities, def, errorContext) {
|
|
71
80
|
const report = new YAMLMap();
|
|
72
|
-
const { fieldsMap, postProcessors, groups: derivedBuckets, } = declarativeBucketsToYaml(entities, def.buckets
|
|
73
|
-
|
|
81
|
+
const { fieldsMap, postProcessors, groups: derivedBuckets, } = declarativeBucketsToYaml(entities, def.buckets, updateErrorContext(errorContext, {
|
|
82
|
+
path: ["buckets"],
|
|
83
|
+
}));
|
|
84
|
+
appendLayerFieldsToReport(fieldsMap, postProcessors, entities, def.layers, updateErrorContext(errorContext, {
|
|
85
|
+
path: ["layers"],
|
|
86
|
+
}));
|
|
74
87
|
if (fieldsMap.items.length > 0) {
|
|
75
88
|
report.add(new Pair("fields", fieldsMap));
|
|
76
89
|
}
|
|
77
|
-
const { filtersArray, filtersMap } = declarativeFiltersToYaml(entities, def.filters ?? []
|
|
78
|
-
|
|
90
|
+
const { filtersArray, filtersMap } = declarativeFiltersToYaml(entities, def.filters ?? [], updateErrorContext(errorContext, {
|
|
91
|
+
path: ["filters"],
|
|
92
|
+
}));
|
|
93
|
+
declarativeFiltersConfigToYaml(def, filtersMap, updateErrorContext(errorContext, {
|
|
94
|
+
path: ["filters"],
|
|
95
|
+
}));
|
|
79
96
|
if (filtersArray.items.length > 0) {
|
|
80
97
|
report.add(entryWithSpace("filter_by", filtersArray));
|
|
81
98
|
}
|
|
82
|
-
const { sortsArray } = declarativeSortsToYaml(def.sorts ?? []
|
|
99
|
+
const { sortsArray } = declarativeSortsToYaml(def.sorts ?? [], updateErrorContext(errorContext, {
|
|
100
|
+
path: ["sorts"],
|
|
101
|
+
}));
|
|
83
102
|
if (sortsArray.length > 0) {
|
|
84
103
|
report.add(entryWithSpace("sort_by", sortsArray));
|
|
85
104
|
}
|
|
86
|
-
postProcessors.filters?.forEach(({ filters, item }) => {
|
|
87
|
-
const { filtersArray, filtersMap } = declarativeFiltersToYaml(entities, filters
|
|
88
|
-
|
|
105
|
+
postProcessors.filters?.forEach(({ filters, item }, i) => {
|
|
106
|
+
const { filtersArray, filtersMap } = declarativeFiltersToYaml(entities, filters, updateErrorContext(errorContext, {
|
|
107
|
+
path: ["filters", i.toString()],
|
|
108
|
+
}));
|
|
109
|
+
declarativeFiltersConfigToYaml(def, filtersMap, updateErrorContext(errorContext, {
|
|
110
|
+
path: ["filters", i.toString()],
|
|
111
|
+
}));
|
|
89
112
|
if (filtersArray.items.length > 0) {
|
|
90
113
|
item.add(new Pair("filter_by", filtersArray));
|
|
91
114
|
}
|
|
@@ -95,15 +118,17 @@ function declarativeReportToYaml(entities, def) {
|
|
|
95
118
|
derivedBuckets,
|
|
96
119
|
};
|
|
97
120
|
}
|
|
98
|
-
function appendLayerFieldsToReport(fieldsMap, postProcessors, entities, layers) {
|
|
121
|
+
function appendLayerFieldsToReport(fieldsMap, postProcessors, entities, layers, errorContext) {
|
|
99
122
|
if (!layers || layers.length === 0) {
|
|
100
123
|
return;
|
|
101
124
|
}
|
|
102
125
|
const knownKeys = new Set(fieldsMap.items
|
|
103
126
|
.map((pair) => getPairKeyValue(pair))
|
|
104
127
|
.filter((key) => typeof key === "string" && key.length > 0));
|
|
105
|
-
layers.forEach((layer) => {
|
|
106
|
-
const { fieldsMap: layerFieldsMap, postProcessors: layerPostProcessors } = declarativeBucketsToYaml(entities, layer.buckets ?? []
|
|
128
|
+
layers.forEach((layer, li) => {
|
|
129
|
+
const { fieldsMap: layerFieldsMap, postProcessors: layerPostProcessors } = declarativeBucketsToYaml(entities, layer.buckets ?? [], updateErrorContext(errorContext, {
|
|
130
|
+
path: [li.toString(), "buckets"],
|
|
131
|
+
}));
|
|
107
132
|
const valueMapping = new Map();
|
|
108
133
|
layerFieldsMap.items.forEach((pair) => {
|
|
109
134
|
const keyValue = getPairKeyValue(pair);
|
|
@@ -148,14 +173,16 @@ function getPairKeyValue(pair) {
|
|
|
148
173
|
}
|
|
149
174
|
return undefined;
|
|
150
175
|
}
|
|
151
|
-
export function declarativeFiltersConfigToYaml(insight, filtersMap) {
|
|
176
|
+
export function declarativeFiltersConfigToYaml(insight, filtersMap, errorContext) {
|
|
152
177
|
Object.keys(insight.attributeFilterConfigs ?? {}).forEach((key) => {
|
|
153
178
|
const filter = filtersMap[key];
|
|
154
179
|
if (filter) {
|
|
155
180
|
const localIdentifier = filterLocalIdentifier(filter.filter);
|
|
156
181
|
if (localIdentifier) {
|
|
157
182
|
if (insight.attributeFilterConfigs[localIdentifier].displayAsLabel) {
|
|
158
|
-
filter.yaml.add(new Pair("display_as", getIdentifier(insight.attributeFilterConfigs[localIdentifier].displayAsLabel
|
|
183
|
+
filter.yaml.add(new Pair("display_as", getIdentifier(insight.attributeFilterConfigs[localIdentifier].displayAsLabel, undefined, updateErrorContext(errorContext, {
|
|
184
|
+
path: ["attributeFilterConfigs", key, "displayAsLabel"],
|
|
185
|
+
}))));
|
|
159
186
|
}
|
|
160
187
|
}
|
|
161
188
|
}
|
|
@@ -211,79 +238,85 @@ export function declarativeVisTypeToYaml(def) {
|
|
|
211
238
|
return null;
|
|
212
239
|
}
|
|
213
240
|
}
|
|
214
|
-
function declarativeVisToYaml(doc, def, report, entities) {
|
|
241
|
+
function declarativeVisToYaml(doc, def, report, entities, errorContext) {
|
|
242
|
+
const context = updateErrorContext(errorContext, {
|
|
243
|
+
data: {
|
|
244
|
+
...(errorContext?.data ?? {}),
|
|
245
|
+
type: def.visualizationUrl,
|
|
246
|
+
},
|
|
247
|
+
});
|
|
215
248
|
switch (def.visualizationUrl) {
|
|
216
249
|
case "local:table":
|
|
217
|
-
declarativeVisTableToYaml(doc, def, report);
|
|
250
|
+
declarativeVisTableToYaml(doc, def, report, context);
|
|
218
251
|
break;
|
|
219
252
|
case "local:bar":
|
|
220
|
-
declarativeVisBarToYaml(doc, def, report);
|
|
253
|
+
declarativeVisBarToYaml(doc, def, report, context);
|
|
221
254
|
break;
|
|
222
255
|
case "local:column":
|
|
223
|
-
declarativeVisColumnToYaml(doc, def, report);
|
|
256
|
+
declarativeVisColumnToYaml(doc, def, report, context);
|
|
224
257
|
break;
|
|
225
258
|
case "local:line":
|
|
226
|
-
declarativeVisLineToYaml(doc, def, report);
|
|
259
|
+
declarativeVisLineToYaml(doc, def, report, context);
|
|
227
260
|
break;
|
|
228
261
|
case "local:area":
|
|
229
|
-
declarativeVisAreaToYaml(doc, def, report);
|
|
262
|
+
declarativeVisAreaToYaml(doc, def, report, context);
|
|
230
263
|
break;
|
|
231
264
|
case "local:scatter":
|
|
232
|
-
declarativeVisScatterToYaml(doc, def, report);
|
|
265
|
+
declarativeVisScatterToYaml(doc, def, report, context);
|
|
233
266
|
break;
|
|
234
267
|
case "local:bubble":
|
|
235
|
-
declarativeVisBubbleToYaml(doc, def, report);
|
|
268
|
+
declarativeVisBubbleToYaml(doc, def, report, context);
|
|
236
269
|
break;
|
|
237
270
|
case "local:pie":
|
|
238
|
-
declarativeVisPieToYaml(doc, def, report);
|
|
271
|
+
declarativeVisPieToYaml(doc, def, report, context);
|
|
239
272
|
break;
|
|
240
273
|
case "local:donut":
|
|
241
|
-
declarativeVisDonutToYaml(doc, def, report);
|
|
274
|
+
declarativeVisDonutToYaml(doc, def, report, context);
|
|
242
275
|
break;
|
|
243
276
|
case "local:treemap":
|
|
244
|
-
declarativeVisTreemapToYaml(doc, def, report);
|
|
277
|
+
declarativeVisTreemapToYaml(doc, def, report, context);
|
|
245
278
|
break;
|
|
246
279
|
case "local:pyramid":
|
|
247
|
-
declarativeVisPyramidToYaml(doc, def, report);
|
|
280
|
+
declarativeVisPyramidToYaml(doc, def, report, context);
|
|
248
281
|
break;
|
|
249
282
|
case "local:funnel":
|
|
250
|
-
declarativeVisFunnelToYaml(doc, def, report);
|
|
283
|
+
declarativeVisFunnelToYaml(doc, def, report, context);
|
|
251
284
|
break;
|
|
252
285
|
case "local:heatmap":
|
|
253
|
-
declarativeVisHeatmapToYaml(doc, def, report);
|
|
286
|
+
declarativeVisHeatmapToYaml(doc, def, report, context);
|
|
254
287
|
break;
|
|
255
288
|
case "local:bullet":
|
|
256
|
-
declarativeVisBulletToYaml(doc, def, report);
|
|
289
|
+
declarativeVisBulletToYaml(doc, def, report, context);
|
|
257
290
|
break;
|
|
258
291
|
case "local:waterfall":
|
|
259
|
-
declarativeVisWaterfallToYaml(doc, def, report);
|
|
292
|
+
declarativeVisWaterfallToYaml(doc, def, report, context);
|
|
260
293
|
break;
|
|
261
294
|
case "local:dependencywheel":
|
|
262
|
-
declarativeVisDependencyWheelToYaml(doc, def, report);
|
|
295
|
+
declarativeVisDependencyWheelToYaml(doc, def, report, context);
|
|
263
296
|
break;
|
|
264
297
|
case "local:sankey":
|
|
265
|
-
declarativeVisSankeyToYaml(doc, def, report);
|
|
298
|
+
declarativeVisSankeyToYaml(doc, def, report, context);
|
|
266
299
|
break;
|
|
267
300
|
case "local:headline":
|
|
268
|
-
declarativeVisHeadlineToYaml(doc, def, report);
|
|
301
|
+
declarativeVisHeadlineToYaml(doc, def, report, context);
|
|
269
302
|
break;
|
|
270
303
|
case "local:combo2":
|
|
271
|
-
declarativeVisComboToYaml(doc, def, report);
|
|
304
|
+
declarativeVisComboToYaml(doc, def, report, context);
|
|
272
305
|
break;
|
|
273
306
|
case "local:pushpin":
|
|
274
|
-
declarativeVisGeoToYaml(doc, def, report, entities);
|
|
307
|
+
declarativeVisGeoToYaml(doc, def, report, entities, context);
|
|
275
308
|
break;
|
|
276
309
|
case "local:choropleth":
|
|
277
|
-
declarativeVisGeoAreaToYaml(doc, def, report, entities);
|
|
310
|
+
declarativeVisGeoAreaToYaml(doc, def, report, entities, context);
|
|
278
311
|
break;
|
|
279
312
|
case "local:repeater":
|
|
280
|
-
declarativeVisRepeaterToYaml(doc, def, report);
|
|
313
|
+
declarativeVisRepeaterToYaml(doc, def, report, context);
|
|
281
314
|
break;
|
|
282
315
|
default:
|
|
283
316
|
break;
|
|
284
317
|
}
|
|
285
318
|
}
|
|
286
|
-
export function declarativeBucketsToYaml(entities, buckets) {
|
|
319
|
+
export function declarativeBucketsToYaml(entities, buckets, errorContext) {
|
|
287
320
|
const fullFieldsMap = new YAMLMap();
|
|
288
321
|
const groups = [];
|
|
289
322
|
const postProcessors = {
|
|
@@ -294,22 +327,29 @@ export function declarativeBucketsToYaml(entities, buckets) {
|
|
|
294
327
|
group.items.push(createBucketGroupItem(local, format, axis));
|
|
295
328
|
};
|
|
296
329
|
//create buckets
|
|
297
|
-
buckets.forEach((bucket) => {
|
|
330
|
+
buckets.forEach((bucket, bi) => {
|
|
298
331
|
if (isBucket(bucket)) {
|
|
299
332
|
const group = { items: [], type: bucket.localIdentifier };
|
|
300
333
|
const attributesMap = {};
|
|
301
334
|
const isLocation = bucket.localIdentifier === BucketsType.Location;
|
|
302
335
|
//items
|
|
303
|
-
bucket.items.forEach((item) => {
|
|
336
|
+
bucket.items.forEach((item, ii) => {
|
|
337
|
+
const bucketItemErrorContext = updateErrorContext(errorContext, {
|
|
338
|
+
path: [bi.toString(), "items", ii.toString()],
|
|
339
|
+
});
|
|
304
340
|
if (isAttribute(item) && isLocation) {
|
|
305
341
|
const remapped = remapLocationAttribute(entities, item);
|
|
306
|
-
const def = declarativeAttributeToYaml(remapped.attribute
|
|
342
|
+
const def = declarativeAttributeToYaml(remapped.attribute, updateErrorContext(bucketItemErrorContext, {
|
|
343
|
+
path: ["attribute"],
|
|
344
|
+
}));
|
|
307
345
|
addField(item.attribute.localIdentifier, def, group);
|
|
308
346
|
attributesMap[item.attribute.localIdentifier] = def;
|
|
309
347
|
return;
|
|
310
348
|
}
|
|
311
349
|
if (isAttribute(item)) {
|
|
312
|
-
const def = declarativeAttributeToYaml(item.attribute
|
|
350
|
+
const def = declarativeAttributeToYaml(item.attribute, updateErrorContext(bucketItemErrorContext, {
|
|
351
|
+
path: ["attribute"],
|
|
352
|
+
}));
|
|
313
353
|
addField(item.attribute.localIdentifier, def, group);
|
|
314
354
|
attributesMap[item.attribute.localIdentifier] = def;
|
|
315
355
|
return;
|
|
@@ -321,7 +361,9 @@ export function declarativeBucketsToYaml(entities, buckets) {
|
|
|
321
361
|
return;
|
|
322
362
|
}
|
|
323
363
|
if (isMeasure(item) && isMeasureDefinition(item.measure.definition)) {
|
|
324
|
-
const def = declarativeNormalMetricToYaml(item.measure, item.measure.definition, postProcessors
|
|
364
|
+
const def = declarativeNormalMetricToYaml(item.measure, item.measure.definition, postProcessors, updateErrorContext(bucketItemErrorContext, {
|
|
365
|
+
path: ["measure"],
|
|
366
|
+
}));
|
|
325
367
|
addField(item.measure.localIdentifier, def, group, { format: item.measure.format });
|
|
326
368
|
attributesMap[item.measure.localIdentifier] = def;
|
|
327
369
|
return;
|
|
@@ -333,22 +375,29 @@ export function declarativeBucketsToYaml(entities, buckets) {
|
|
|
333
375
|
return;
|
|
334
376
|
}
|
|
335
377
|
if (isMeasure(item) && isPoPMeasureDefinition(item.measure.definition)) {
|
|
336
|
-
const def = declarativePoPMetricToYaml(item.measure, item.measure.definition
|
|
378
|
+
const def = declarativePoPMetricToYaml(item.measure, item.measure.definition, updateErrorContext(bucketItemErrorContext, {
|
|
379
|
+
path: ["measure"],
|
|
380
|
+
}));
|
|
337
381
|
addField(item.measure.localIdentifier, def, group, { format: item.measure.format });
|
|
338
382
|
attributesMap[item.measure.localIdentifier] = def;
|
|
339
383
|
return;
|
|
340
384
|
}
|
|
341
385
|
if (isMeasure(item) && isPreviousPeriodMeasureDefinition(item.measure.definition)) {
|
|
342
|
-
const def = declarativePreviousPeriodMetricToYaml(item.measure, item.measure.definition
|
|
386
|
+
const def = declarativePreviousPeriodMetricToYaml(item.measure, item.measure.definition, updateErrorContext(bucketItemErrorContext, {
|
|
387
|
+
path: ["measure"],
|
|
388
|
+
}));
|
|
343
389
|
addField(item.measure.localIdentifier, def, group, { format: item.measure.format });
|
|
344
390
|
attributesMap[item.measure.localIdentifier] = def;
|
|
345
391
|
return;
|
|
346
392
|
}
|
|
347
|
-
throw newError(CoreErrorCode.BucketItemTypeNotSupported, [JSON.stringify(item)]);
|
|
393
|
+
throw newError(CoreErrorCode.BucketItemTypeNotSupported, [JSON.stringify(item)], bucketItemErrorContext);
|
|
348
394
|
});
|
|
349
395
|
//totals
|
|
350
|
-
bucket.totals?.forEach((total) => {
|
|
351
|
-
const
|
|
396
|
+
bucket.totals?.forEach((total, ti) => {
|
|
397
|
+
const totalItemErrorContext = updateErrorContext(errorContext, {
|
|
398
|
+
path: [bi.toString(), "totals", ti.toString()],
|
|
399
|
+
});
|
|
400
|
+
const { totalMap, attribute } = declarativeTotalToYaml(total, totalItemErrorContext);
|
|
352
401
|
const item = group.items.find((item) => item?.field === attribute);
|
|
353
402
|
if (item) {
|
|
354
403
|
item.totals = [...(item.totals ?? []), totalMap];
|
|
@@ -377,12 +426,14 @@ export function declarativeBucketsToYaml(entities, buckets) {
|
|
|
377
426
|
postProcessors,
|
|
378
427
|
};
|
|
379
428
|
}
|
|
380
|
-
export function declarativeAttributeToYaml(def) {
|
|
429
|
+
export function declarativeAttributeToYaml(def, errorContext) {
|
|
381
430
|
const map = new YAMLMap();
|
|
382
431
|
if (def.alias) {
|
|
383
432
|
map.add(new Pair("title", def.alias));
|
|
384
433
|
}
|
|
385
|
-
const id = getIdentifier(def.displayForm
|
|
434
|
+
const id = getIdentifier(def.displayForm, undefined, updateErrorContext(errorContext, {
|
|
435
|
+
path: ["displayForm"],
|
|
436
|
+
}));
|
|
386
437
|
map.add(new Pair("using", id));
|
|
387
438
|
if (def.showAllValues) {
|
|
388
439
|
map.add(new Pair("show_all_values", true));
|
|
@@ -396,7 +447,7 @@ export function declarativeInlineMetricToYaml(def, inlineDef) {
|
|
|
396
447
|
map.add(new Pair("maql", id.maql));
|
|
397
448
|
return map;
|
|
398
449
|
}
|
|
399
|
-
export function declarativeNormalMetricToYaml(def, metricDefinition, postProcessors) {
|
|
450
|
+
export function declarativeNormalMetricToYaml(def, metricDefinition, postProcessors, errorContext) {
|
|
400
451
|
const map = new YAMLMap();
|
|
401
452
|
fillDefaultMetricProperties(map, def);
|
|
402
453
|
const md = metricDefinition.measureDefinition;
|
|
@@ -409,7 +460,9 @@ export function declarativeNormalMetricToYaml(def, metricDefinition, postProcess
|
|
|
409
460
|
if (md.filters && md.filters.length > 0) {
|
|
410
461
|
postProcessors.filters.push({ item: map, filters: md.filters });
|
|
411
462
|
}
|
|
412
|
-
const id = getIdentifier(md.item
|
|
463
|
+
const id = getIdentifier(md.item, undefined, updateErrorContext(errorContext, {
|
|
464
|
+
path: ["item"],
|
|
465
|
+
}));
|
|
413
466
|
map.add(new Pair("using", id));
|
|
414
467
|
return map;
|
|
415
468
|
}
|
|
@@ -421,26 +474,32 @@ export function declarativeArithmeticMetricToYaml(def, arithmeticDefinition) {
|
|
|
421
474
|
map.add(new Pair("using", ad.measureIdentifiers));
|
|
422
475
|
return map;
|
|
423
476
|
}
|
|
424
|
-
export function declarativePoPMetricToYaml(def, popDefinition) {
|
|
477
|
+
export function declarativePoPMetricToYaml(def, popDefinition, errorContext) {
|
|
425
478
|
const map = new YAMLMap();
|
|
426
479
|
fillDefaultMetricProperties(map, def);
|
|
427
480
|
const pop = popDefinition.popMeasureDefinition;
|
|
428
|
-
const id = getIdentifier(pop.popAttribute, true
|
|
481
|
+
const id = getIdentifier(pop.popAttribute, true, updateErrorContext(errorContext, {
|
|
482
|
+
path: ["popAttribute"],
|
|
483
|
+
}));
|
|
429
484
|
const [date] = id.split(".");
|
|
430
485
|
map.add(new Pair("type", "PREVIOUS_YEAR"));
|
|
431
486
|
map.add(new Pair("date_filter", date));
|
|
432
487
|
map.add(new Pair("using", pop.measureIdentifier));
|
|
433
488
|
return map;
|
|
434
489
|
}
|
|
435
|
-
export function declarativePreviousPeriodMetricToYaml(def, previousDefinition) {
|
|
490
|
+
export function declarativePreviousPeriodMetricToYaml(def, previousDefinition, errorContext) {
|
|
436
491
|
const map = new YAMLMap();
|
|
437
492
|
fillDefaultMetricProperties(map, def);
|
|
438
493
|
const previous = previousDefinition.previousPeriodMeasure;
|
|
439
494
|
if (previous.dateDataSets.length > 1) {
|
|
440
|
-
throw newError(CoreErrorCode.MultipleDateDataSets, [JSON.stringify(previous)]
|
|
495
|
+
throw newError(CoreErrorCode.MultipleDateDataSets, [JSON.stringify(previous)], updateErrorContext(errorContext, {
|
|
496
|
+
path: ["previousPeriodMeasure", "dateDataSets"],
|
|
497
|
+
}));
|
|
441
498
|
}
|
|
442
499
|
const prev = previous.dateDataSets[0];
|
|
443
|
-
const id = getIdentifier(prev.dataSet, true
|
|
500
|
+
const id = getIdentifier(prev.dataSet, true, updateErrorContext(errorContext, {
|
|
501
|
+
path: ["dateSet"],
|
|
502
|
+
}));
|
|
444
503
|
const [date] = id.split(".");
|
|
445
504
|
map.add(new Pair("type", "PREVIOUS_PERIOD"));
|
|
446
505
|
if (prev.periodsAgo > 1) {
|
|
@@ -533,35 +592,37 @@ function groupFiltersByDateFilter(filters) {
|
|
|
533
592
|
};
|
|
534
593
|
dateFilters.forEach((dateFilter) => {
|
|
535
594
|
const { filterRef: datasetId } = getFilterRefDetails(dateFilter);
|
|
595
|
+
const fi = filters.indexOf(dateFilter);
|
|
536
596
|
if (datasetId === undefined) {
|
|
537
|
-
result.rest.push(dateFilter);
|
|
597
|
+
result.rest.push([dateFilter, fi]);
|
|
538
598
|
return;
|
|
539
599
|
}
|
|
540
600
|
if (result.grouped[datasetId]) {
|
|
541
|
-
result.rest.push(dateFilter);
|
|
601
|
+
result.rest.push([dateFilter, fi]);
|
|
542
602
|
}
|
|
543
603
|
else {
|
|
544
|
-
result.grouped[datasetId] = { dateFilter, attributeFilters: [] };
|
|
604
|
+
result.grouped[datasetId] = { dateFilter: [dateFilter, fi], attributeFilters: [] };
|
|
545
605
|
}
|
|
546
606
|
});
|
|
547
607
|
nonDateFilters.forEach((filter) => {
|
|
548
608
|
const { filterRef: filterId } = getFilterRefDetails(filter);
|
|
609
|
+
const fi = filters.indexOf(filter);
|
|
549
610
|
if (filterId === undefined) {
|
|
550
|
-
result.rest.push(filter);
|
|
611
|
+
result.rest.push([filter, fi]);
|
|
551
612
|
return;
|
|
552
613
|
}
|
|
553
614
|
const datasetId = filterId.split(".")[0];
|
|
554
615
|
const group = result.grouped[datasetId];
|
|
555
616
|
if (group) {
|
|
556
|
-
group.attributeFilters.push(filter);
|
|
617
|
+
group.attributeFilters.push([filter, fi]);
|
|
557
618
|
}
|
|
558
619
|
else {
|
|
559
|
-
result.rest.push(filter);
|
|
620
|
+
result.rest.push([filter, fi]);
|
|
560
621
|
}
|
|
561
622
|
});
|
|
562
623
|
return result;
|
|
563
624
|
}
|
|
564
|
-
export function declarativeFiltersToYaml(entities, filters) {
|
|
625
|
+
export function declarativeFiltersToYaml(entities, filters, errorContext) {
|
|
565
626
|
const filtersArray = [];
|
|
566
627
|
const filtersMap = {};
|
|
567
628
|
const usedKeys = new Set();
|
|
@@ -576,8 +637,10 @@ export function declarativeFiltersToYaml(entities, filters) {
|
|
|
576
637
|
return key;
|
|
577
638
|
};
|
|
578
639
|
const filtersGroupedByDateFilter = groupFiltersByDateFilter(filters);
|
|
579
|
-
filtersGroupedByDateFilter.rest.forEach((filter) => {
|
|
580
|
-
const result = declarativeFilterToYaml(entities, filter, getUniqueKey
|
|
640
|
+
filtersGroupedByDateFilter.rest.forEach(([filter, fi]) => {
|
|
641
|
+
const result = declarativeFilterToYaml(entities, filter, getUniqueKey, undefined, updateErrorContext(errorContext, {
|
|
642
|
+
path: [fi.toString()],
|
|
643
|
+
}));
|
|
581
644
|
if (!result) {
|
|
582
645
|
return;
|
|
583
646
|
}
|
|
@@ -589,7 +652,9 @@ export function declarativeFiltersToYaml(entities, filters) {
|
|
|
589
652
|
};
|
|
590
653
|
});
|
|
591
654
|
Object.values(filtersGroupedByDateFilter.grouped).forEach(({ dateFilter, attributeFilters }) => {
|
|
592
|
-
const result = declarativeFilterToYaml(entities, dateFilter, getUniqueKey, attributeFilters)
|
|
655
|
+
const result = declarativeFilterToYaml(entities, dateFilter[0], getUniqueKey, attributeFilters.map(([f]) => f), updateErrorContext(errorContext, {
|
|
656
|
+
path: [dateFilter[1].toString()],
|
|
657
|
+
}));
|
|
593
658
|
if (!result) {
|
|
594
659
|
return;
|
|
595
660
|
}
|
|
@@ -608,73 +673,91 @@ export function declarativeFiltersToYaml(entities, filters) {
|
|
|
608
673
|
}, new YAMLMap()),
|
|
609
674
|
};
|
|
610
675
|
}
|
|
611
|
-
function declarativeFilterToYaml(entities, filter, getUniqueKey, connectedAttributeFilters) {
|
|
676
|
+
function declarativeFilterToYaml(entities, filter, getUniqueKey, connectedAttributeFilters, errorContext) {
|
|
612
677
|
if (!isFilter(filter)) {
|
|
613
678
|
return null;
|
|
614
679
|
}
|
|
615
|
-
const key = getUniqueKey(createFilterItemKeyName(filter
|
|
680
|
+
const key = getUniqueKey(createFilterItemKeyName(filter, "date", updateErrorContext(errorContext, {
|
|
681
|
+
path: ["date"],
|
|
682
|
+
})));
|
|
616
683
|
if (isAbsoluteDateFilter(filter)) {
|
|
617
684
|
return {
|
|
618
685
|
key,
|
|
619
|
-
yaml: declarativeAbsoluteDateFilterToYaml(filter.absoluteDateFilter, connectedAttributeFilters, entities, getUniqueKey
|
|
686
|
+
yaml: declarativeAbsoluteDateFilterToYaml(filter.absoluteDateFilter, connectedAttributeFilters, entities, getUniqueKey, updateErrorContext(errorContext, {
|
|
687
|
+
path: ["absoluteDateFilter"],
|
|
688
|
+
})),
|
|
620
689
|
filter,
|
|
621
690
|
};
|
|
622
691
|
}
|
|
623
692
|
if (isRelativeDateFilter(filter)) {
|
|
624
693
|
return {
|
|
625
694
|
key,
|
|
626
|
-
yaml: declarativeRelativeDateFilterToYaml(filter.relativeDateFilter, connectedAttributeFilters, entities, getUniqueKey
|
|
695
|
+
yaml: declarativeRelativeDateFilterToYaml(filter.relativeDateFilter, connectedAttributeFilters, entities, getUniqueKey, updateErrorContext(errorContext, {
|
|
696
|
+
path: ["relativeDateFilter"],
|
|
697
|
+
})),
|
|
627
698
|
filter,
|
|
628
699
|
};
|
|
629
700
|
}
|
|
630
701
|
if (isPositiveAttributeFilter(filter)) {
|
|
631
702
|
return {
|
|
632
703
|
key,
|
|
633
|
-
yaml: declarativePositiveAttributeFilterToYaml(entities, filter.positiveAttributeFilter
|
|
704
|
+
yaml: declarativePositiveAttributeFilterToYaml(entities, filter.positiveAttributeFilter, updateErrorContext(errorContext, {
|
|
705
|
+
path: ["positiveAttributeFilter"],
|
|
706
|
+
})),
|
|
634
707
|
filter,
|
|
635
708
|
};
|
|
636
709
|
}
|
|
637
710
|
if (isNegativeAttributeFilter(filter)) {
|
|
638
711
|
return {
|
|
639
712
|
key,
|
|
640
|
-
yaml: declarativeNegativeAttributeFilterToYaml(entities, filter.negativeAttributeFilter
|
|
713
|
+
yaml: declarativeNegativeAttributeFilterToYaml(entities, filter.negativeAttributeFilter, updateErrorContext(errorContext, {
|
|
714
|
+
path: ["negativeAttributeFilter"],
|
|
715
|
+
})),
|
|
641
716
|
filter,
|
|
642
717
|
};
|
|
643
718
|
}
|
|
644
719
|
if (isArbitraryAttributeFilter(filter)) {
|
|
645
720
|
return {
|
|
646
721
|
key,
|
|
647
|
-
yaml: declarativeArbitraryAttributeFilterToYaml(filter.arbitraryAttributeFilter
|
|
722
|
+
yaml: declarativeArbitraryAttributeFilterToYaml(filter.arbitraryAttributeFilter, updateErrorContext(errorContext, {
|
|
723
|
+
path: ["arbitraryAttributeFilter"],
|
|
724
|
+
})),
|
|
648
725
|
filter,
|
|
649
726
|
};
|
|
650
727
|
}
|
|
651
728
|
if (isMatchAttributeFilter(filter)) {
|
|
652
729
|
return {
|
|
653
730
|
key,
|
|
654
|
-
yaml: declarativeMatchAttributeFilterToYaml(filter.matchAttributeFilter
|
|
731
|
+
yaml: declarativeMatchAttributeFilterToYaml(filter.matchAttributeFilter, updateErrorContext(errorContext, {
|
|
732
|
+
path: ["matchAttributeFilter"],
|
|
733
|
+
})),
|
|
655
734
|
filter,
|
|
656
735
|
};
|
|
657
736
|
}
|
|
658
737
|
if (isMeasureValueFilter(filter)) {
|
|
659
738
|
return {
|
|
660
739
|
key,
|
|
661
|
-
yaml: declarativeMeasureValueFilterToYaml(filter.measureValueFilter
|
|
740
|
+
yaml: declarativeMeasureValueFilterToYaml(filter.measureValueFilter, updateErrorContext(errorContext, {
|
|
741
|
+
path: ["measureValueFilter"],
|
|
742
|
+
})),
|
|
662
743
|
filter,
|
|
663
744
|
};
|
|
664
745
|
}
|
|
665
746
|
if (isRankingFilter(filter)) {
|
|
666
747
|
return {
|
|
667
748
|
key,
|
|
668
|
-
yaml: declarativeRankingFilterToYaml(filter.rankingFilter
|
|
749
|
+
yaml: declarativeRankingFilterToYaml(filter.rankingFilter, updateErrorContext(errorContext, {
|
|
750
|
+
path: ["rankingFilter"],
|
|
751
|
+
})),
|
|
669
752
|
filter,
|
|
670
753
|
};
|
|
671
754
|
}
|
|
672
|
-
throw newError(CoreErrorCode.FilterItemTypeNotSupported, [JSON.stringify(filter)]);
|
|
755
|
+
throw newError(CoreErrorCode.FilterItemTypeNotSupported, [JSON.stringify(filter)], errorContext);
|
|
673
756
|
}
|
|
674
757
|
/**
|
|
675
758
|
* Modifies `map`, adding `empty_filters` and `with` keys, populated from connectedAttributeFilters.
|
|
676
759
|
*/
|
|
677
|
-
function processConnectedAttributeFilters(map, connectedAttributeFilters, entities, getUniqueKey) {
|
|
760
|
+
function processConnectedAttributeFilters(map, connectedAttributeFilters, entities, getUniqueKey, errorContext) {
|
|
678
761
|
// empty values filter
|
|
679
762
|
const emptyValuesFilter = connectedAttributeFilters.find((filter) => detectEmptyValuesFilterType(filter));
|
|
680
763
|
if (emptyValuesFilter) {
|
|
@@ -688,23 +771,25 @@ function processConnectedAttributeFilters(map, connectedAttributeFilters, entiti
|
|
|
688
771
|
const withMap = new YAMLMap();
|
|
689
772
|
map.add(new Pair("with", withMap));
|
|
690
773
|
additionalAttributeFilters?.forEach((filter) => {
|
|
691
|
-
const converted = declarativeFilterToYaml(entities, filter, getUniqueKey);
|
|
774
|
+
const converted = declarativeFilterToYaml(entities, filter, getUniqueKey, undefined, errorContext);
|
|
692
775
|
if (!converted) {
|
|
693
776
|
return;
|
|
694
777
|
}
|
|
695
778
|
withMap.add(new Pair(converted.key, converted.yaml));
|
|
696
779
|
});
|
|
697
780
|
}
|
|
698
|
-
export function declarativeAbsoluteDateFilterToYaml(absoluteDateFilter, connectedAttributeFilters = [], entities, getUniqueKey) {
|
|
781
|
+
export function declarativeAbsoluteDateFilterToYaml(absoluteDateFilter, connectedAttributeFilters = [], entities, getUniqueKey, errorContext) {
|
|
699
782
|
const map = new YAMLMap();
|
|
700
783
|
// base date filter attributes
|
|
701
784
|
map.add(new Pair("type", "date_filter"));
|
|
702
785
|
map.add(new Pair("from", absoluteDateFilter.from));
|
|
703
786
|
map.add(new Pair("to", absoluteDateFilter.to));
|
|
704
|
-
const id = getIdentifier(absoluteDateFilter.dataSet, true
|
|
787
|
+
const id = getIdentifier(absoluteDateFilter.dataSet, true, updateErrorContext(errorContext, {
|
|
788
|
+
path: ["dateSet"],
|
|
789
|
+
}));
|
|
705
790
|
map.add(new Pair("using", id));
|
|
706
791
|
// connected attribute filters
|
|
707
|
-
processConnectedAttributeFilters(map, connectedAttributeFilters, entities, getUniqueKey);
|
|
792
|
+
processConnectedAttributeFilters(map, connectedAttributeFilters, entities, getUniqueKey, errorContext);
|
|
708
793
|
return map;
|
|
709
794
|
}
|
|
710
795
|
function isRelativeDateFilterAllTime(relativeDateFilter) {
|
|
@@ -716,7 +801,7 @@ function isRelativeDateFilterAllTime(relativeDateFilter) {
|
|
|
716
801
|
// But unfortunately AD emits granularity as GDC.time.year for an all time date filter, so we need this check as well
|
|
717
802
|
return granularity === "GDC.time.year" && from === undefined && to === undefined;
|
|
718
803
|
}
|
|
719
|
-
export function declarativeRelativeDateFilterToYaml(relativeDateFilter, connectedAttributeFilters = [], entities, getUniqueKey) {
|
|
804
|
+
export function declarativeRelativeDateFilterToYaml(relativeDateFilter, connectedAttributeFilters = [], entities, getUniqueKey, errorContext) {
|
|
720
805
|
const map = new YAMLMap();
|
|
721
806
|
map.add(new Pair("type", "date_filter"));
|
|
722
807
|
if (isRelativeDateFilterAllTime(relativeDateFilter)) {
|
|
@@ -733,15 +818,19 @@ export function declarativeRelativeDateFilterToYaml(relativeDateFilter, connecte
|
|
|
733
818
|
map.add(new Pair("to", relativeDateFilter.to));
|
|
734
819
|
}
|
|
735
820
|
}
|
|
736
|
-
const id = getIdentifier(relativeDateFilter.dataSet, true
|
|
821
|
+
const id = getIdentifier(relativeDateFilter.dataSet, true, updateErrorContext(errorContext, {
|
|
822
|
+
path: ["dataSet"],
|
|
823
|
+
}));
|
|
737
824
|
map.add(new Pair("using", id));
|
|
738
|
-
processConnectedAttributeFilters(map, connectedAttributeFilters, entities, getUniqueKey);
|
|
825
|
+
processConnectedAttributeFilters(map, connectedAttributeFilters, entities, getUniqueKey, errorContext);
|
|
739
826
|
return map;
|
|
740
827
|
}
|
|
741
|
-
export function declarativePositiveAttributeFilterToYaml(entities, attributeFilter) {
|
|
828
|
+
export function declarativePositiveAttributeFilterToYaml(entities, attributeFilter, errorContext) {
|
|
742
829
|
const map = new YAMLMap();
|
|
743
830
|
map.add(new Pair("type", "attribute_filter"));
|
|
744
|
-
const id = getIdentifier(attributeFilter.displayForm
|
|
831
|
+
const id = getIdentifier(attributeFilter.displayForm, undefined, updateErrorContext(errorContext, {
|
|
832
|
+
path: ["displayForm"],
|
|
833
|
+
}));
|
|
745
834
|
map.add(new Pair("using", id));
|
|
746
835
|
if (isAttributeElementsByValue(attributeFilter.in)) {
|
|
747
836
|
const ind = attributeFilter.in;
|
|
@@ -751,10 +840,12 @@ export function declarativePositiveAttributeFilterToYaml(entities, attributeFilt
|
|
|
751
840
|
}
|
|
752
841
|
return map;
|
|
753
842
|
}
|
|
754
|
-
export function declarativeNegativeAttributeFilterToYaml(entities, attributeFilter) {
|
|
843
|
+
export function declarativeNegativeAttributeFilterToYaml(entities, attributeFilter, errorContext) {
|
|
755
844
|
const map = new YAMLMap();
|
|
756
845
|
map.add(new Pair("type", "attribute_filter"));
|
|
757
|
-
const id = getIdentifier(attributeFilter.displayForm
|
|
846
|
+
const id = getIdentifier(attributeFilter.displayForm, undefined, updateErrorContext(errorContext, {
|
|
847
|
+
path: ["displayForm"],
|
|
848
|
+
}));
|
|
758
849
|
map.add(new Pair("using", id));
|
|
759
850
|
if (isAttributeElementsByValue(attributeFilter.notIn)) {
|
|
760
851
|
const ind = attributeFilter.notIn;
|
|
@@ -766,18 +857,22 @@ export function declarativeNegativeAttributeFilterToYaml(entities, attributeFilt
|
|
|
766
857
|
}
|
|
767
858
|
return map;
|
|
768
859
|
}
|
|
769
|
-
export function declarativeArbitraryAttributeFilterToYaml(attributeFilter) {
|
|
860
|
+
export function declarativeArbitraryAttributeFilterToYaml(attributeFilter, errorContext) {
|
|
770
861
|
const map = new YAMLMap();
|
|
771
862
|
map.add(new Pair("type", "text_filter"));
|
|
772
|
-
map.add(new Pair("using", getIdentifier(attributeFilter.label
|
|
863
|
+
map.add(new Pair("using", getIdentifier(attributeFilter.label, undefined, updateErrorContext(errorContext, {
|
|
864
|
+
path: ["label"],
|
|
865
|
+
}))));
|
|
773
866
|
map.add(new Pair("condition", attributeFilter.negativeSelection ? "isNot" : "is"));
|
|
774
867
|
map.add(new Pair("values", attributeFilter.values));
|
|
775
868
|
return map;
|
|
776
869
|
}
|
|
777
|
-
export function declarativeMatchAttributeFilterToYaml(attributeFilter) {
|
|
870
|
+
export function declarativeMatchAttributeFilterToYaml(attributeFilter, errorContext) {
|
|
778
871
|
const map = new YAMLMap();
|
|
779
872
|
map.add(new Pair("type", "text_filter"));
|
|
780
|
-
map.add(new Pair("using", getIdentifier(attributeFilter.label
|
|
873
|
+
map.add(new Pair("using", getIdentifier(attributeFilter.label, undefined, updateErrorContext(errorContext, {
|
|
874
|
+
path: ["label"],
|
|
875
|
+
}))));
|
|
781
876
|
map.add(new Pair("condition", matchConditionToYaml(attributeFilter.operator, attributeFilter.negativeSelection)));
|
|
782
877
|
map.add(new Pair("value", attributeFilter.literal));
|
|
783
878
|
if (attributeFilter.caseSensitive !== undefined) {
|
|
@@ -821,14 +916,16 @@ function addConditionToYamlMap(conditionMap, condition) {
|
|
|
821
916
|
}
|
|
822
917
|
return hasTreatNullValues;
|
|
823
918
|
}
|
|
824
|
-
export function declarativeMeasureValueFilterToYaml(measureValueFilter) {
|
|
919
|
+
export function declarativeMeasureValueFilterToYaml(measureValueFilter, errorContext) {
|
|
825
920
|
const map = new YAMLMap();
|
|
826
921
|
map.add(new Pair("type", "metric_value_filter"));
|
|
827
922
|
if (isLocalIdRef(measureValueFilter.measure)) {
|
|
828
923
|
map.add(new Pair("using", measureValueFilter.measure.localIdentifier));
|
|
829
924
|
}
|
|
830
925
|
else {
|
|
831
|
-
map.add(new Pair("using", getIdentifier(measureValueFilter.measure
|
|
926
|
+
map.add(new Pair("using", getIdentifier(measureValueFilter.measure, undefined, updateErrorContext(errorContext, {
|
|
927
|
+
path: ["measure"],
|
|
928
|
+
}))));
|
|
832
929
|
}
|
|
833
930
|
// Handle multiple conditions (new SDK model feature)
|
|
834
931
|
if (measureValueFilter.conditions && measureValueFilter.conditions.length > 1) {
|
|
@@ -870,14 +967,16 @@ export function declarativeMeasureValueFilterToYaml(measureValueFilter) {
|
|
|
870
967
|
}
|
|
871
968
|
return map;
|
|
872
969
|
}
|
|
873
|
-
export function declarativeRankingFilterToYaml(rankingFilter) {
|
|
970
|
+
export function declarativeRankingFilterToYaml(rankingFilter, errorContext) {
|
|
874
971
|
const map = new YAMLMap();
|
|
875
972
|
map.add(new Pair("type", "ranking_filter"));
|
|
876
973
|
if (isLocalIdRef(rankingFilter.measure)) {
|
|
877
974
|
map.add(new Pair("using", rankingFilter.measure.localIdentifier));
|
|
878
975
|
}
|
|
879
976
|
else {
|
|
880
|
-
map.add(new Pair("using", getIdentifier(rankingFilter.measure
|
|
977
|
+
map.add(new Pair("using", getIdentifier(rankingFilter.measure, undefined, updateErrorContext(errorContext, {
|
|
978
|
+
path: ["measure"],
|
|
979
|
+
}))));
|
|
881
980
|
}
|
|
882
981
|
if (rankingFilter.operator === "TOP") {
|
|
883
982
|
map.add(new Pair("top", rankingFilter.value));
|
|
@@ -897,7 +996,7 @@ export function declarativeRankingFilterToYaml(rankingFilter) {
|
|
|
897
996
|
}
|
|
898
997
|
return map;
|
|
899
998
|
}
|
|
900
|
-
export function declarativeSortsToYaml(sorts) {
|
|
999
|
+
export function declarativeSortsToYaml(sorts, _errorContext) {
|
|
901
1000
|
const sortsArray = [];
|
|
902
1001
|
sorts.forEach((sort) => {
|
|
903
1002
|
if (isAttributeSort(sort)) {
|
|
@@ -953,7 +1052,7 @@ export function declarativeMeasureSortToYaml(sort) {
|
|
|
953
1052
|
return map;
|
|
954
1053
|
}
|
|
955
1054
|
//visualisations
|
|
956
|
-
function declarativeVisTableToYaml(doc, def, report) {
|
|
1055
|
+
function declarativeVisTableToYaml(doc, def, report, _context) {
|
|
957
1056
|
//buckets
|
|
958
1057
|
const metrics = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
959
1058
|
if (metrics && metrics.items.length > 0) {
|
|
@@ -972,7 +1071,7 @@ function declarativeVisTableToYaml(doc, def, report) {
|
|
|
972
1071
|
doc.add(config);
|
|
973
1072
|
}
|
|
974
1073
|
}
|
|
975
|
-
function declarativeVisBarToYaml(doc, def, report) {
|
|
1074
|
+
function declarativeVisBarToYaml(doc, def, report, _errorContext) {
|
|
976
1075
|
//buckets
|
|
977
1076
|
const metrics = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
978
1077
|
if (metrics && metrics.items.length > 0) {
|
|
@@ -991,7 +1090,7 @@ function declarativeVisBarToYaml(doc, def, report) {
|
|
|
991
1090
|
doc.add(config);
|
|
992
1091
|
}
|
|
993
1092
|
}
|
|
994
|
-
function declarativeVisColumnToYaml(doc, def, report) {
|
|
1093
|
+
function declarativeVisColumnToYaml(doc, def, report, _errorContext) {
|
|
995
1094
|
//buckets
|
|
996
1095
|
const metrics = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
997
1096
|
if (metrics && metrics.items.length > 0) {
|
|
@@ -1010,7 +1109,7 @@ function declarativeVisColumnToYaml(doc, def, report) {
|
|
|
1010
1109
|
doc.add(config);
|
|
1011
1110
|
}
|
|
1012
1111
|
}
|
|
1013
|
-
function declarativeVisLineToYaml(doc, def, report) {
|
|
1112
|
+
function declarativeVisLineToYaml(doc, def, report, _errorContext) {
|
|
1014
1113
|
//buckets
|
|
1015
1114
|
const metrics = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
1016
1115
|
if (metrics && metrics.items.length > 0) {
|
|
@@ -1029,7 +1128,7 @@ function declarativeVisLineToYaml(doc, def, report) {
|
|
|
1029
1128
|
doc.add(config);
|
|
1030
1129
|
}
|
|
1031
1130
|
}
|
|
1032
|
-
function declarativeVisAreaToYaml(doc, def, report) {
|
|
1131
|
+
function declarativeVisAreaToYaml(doc, def, report, _errorContext) {
|
|
1033
1132
|
//buckets
|
|
1034
1133
|
const metrics = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
1035
1134
|
if (metrics && metrics.items.length > 0) {
|
|
@@ -1048,7 +1147,7 @@ function declarativeVisAreaToYaml(doc, def, report) {
|
|
|
1048
1147
|
doc.add(config);
|
|
1049
1148
|
}
|
|
1050
1149
|
}
|
|
1051
|
-
function declarativeVisScatterToYaml(doc, def, report) {
|
|
1150
|
+
function declarativeVisScatterToYaml(doc, def, report, _errorContext) {
|
|
1052
1151
|
//buckets
|
|
1053
1152
|
const metrics1 = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
1054
1153
|
const metrics2 = report.derivedBuckets.find((item) => item.type === BucketsType.SecondaryMeasures);
|
|
@@ -1075,7 +1174,7 @@ function declarativeVisScatterToYaml(doc, def, report) {
|
|
|
1075
1174
|
doc.add(config);
|
|
1076
1175
|
}
|
|
1077
1176
|
}
|
|
1078
|
-
function declarativeVisBubbleToYaml(doc, def, report) {
|
|
1177
|
+
function declarativeVisBubbleToYaml(doc, def, report, _errorContext) {
|
|
1079
1178
|
//buckets
|
|
1080
1179
|
const metrics1 = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
1081
1180
|
const metrics2 = report.derivedBuckets.find((item) => item.type === BucketsType.SecondaryMeasures);
|
|
@@ -1102,7 +1201,7 @@ function declarativeVisBubbleToYaml(doc, def, report) {
|
|
|
1102
1201
|
doc.add(config);
|
|
1103
1202
|
}
|
|
1104
1203
|
}
|
|
1105
|
-
function declarativeVisPieToYaml(doc, def, report) {
|
|
1204
|
+
function declarativeVisPieToYaml(doc, def, report, _errorContext) {
|
|
1106
1205
|
//buckets
|
|
1107
1206
|
const metrics = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
1108
1207
|
if (metrics && metrics.items.length > 0) {
|
|
@@ -1117,7 +1216,7 @@ function declarativeVisPieToYaml(doc, def, report) {
|
|
|
1117
1216
|
doc.add(config);
|
|
1118
1217
|
}
|
|
1119
1218
|
}
|
|
1120
|
-
function declarativeVisDonutToYaml(doc, def, report) {
|
|
1219
|
+
function declarativeVisDonutToYaml(doc, def, report, _errorContext) {
|
|
1121
1220
|
//buckets
|
|
1122
1221
|
const metrics = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
1123
1222
|
if (metrics && metrics.items.length > 0) {
|
|
@@ -1132,7 +1231,7 @@ function declarativeVisDonutToYaml(doc, def, report) {
|
|
|
1132
1231
|
doc.add(config);
|
|
1133
1232
|
}
|
|
1134
1233
|
}
|
|
1135
|
-
function declarativeVisTreemapToYaml(doc, def, report) {
|
|
1234
|
+
function declarativeVisTreemapToYaml(doc, def, report, _errorContext) {
|
|
1136
1235
|
//buckets
|
|
1137
1236
|
const metrics = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
1138
1237
|
if (metrics && metrics.items.length > 0) {
|
|
@@ -1151,7 +1250,7 @@ function declarativeVisTreemapToYaml(doc, def, report) {
|
|
|
1151
1250
|
doc.add(config);
|
|
1152
1251
|
}
|
|
1153
1252
|
}
|
|
1154
|
-
function declarativeVisPyramidToYaml(doc, def, report) {
|
|
1253
|
+
function declarativeVisPyramidToYaml(doc, def, report, _errorContext) {
|
|
1155
1254
|
//buckets
|
|
1156
1255
|
const metrics = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
1157
1256
|
if (metrics && metrics.items.length > 0) {
|
|
@@ -1166,7 +1265,7 @@ function declarativeVisPyramidToYaml(doc, def, report) {
|
|
|
1166
1265
|
doc.add(config);
|
|
1167
1266
|
}
|
|
1168
1267
|
}
|
|
1169
|
-
function declarativeVisFunnelToYaml(doc, def, report) {
|
|
1268
|
+
function declarativeVisFunnelToYaml(doc, def, report, _errorContext) {
|
|
1170
1269
|
//buckets
|
|
1171
1270
|
const metrics = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
1172
1271
|
if (metrics && metrics.items.length > 0) {
|
|
@@ -1181,7 +1280,7 @@ function declarativeVisFunnelToYaml(doc, def, report) {
|
|
|
1181
1280
|
doc.add(config);
|
|
1182
1281
|
}
|
|
1183
1282
|
}
|
|
1184
|
-
function declarativeVisHeatmapToYaml(doc, def, report) {
|
|
1283
|
+
function declarativeVisHeatmapToYaml(doc, def, report, _errorContext) {
|
|
1185
1284
|
//buckets
|
|
1186
1285
|
const metrics = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
1187
1286
|
if (metrics && metrics.items.length > 0) {
|
|
@@ -1200,7 +1299,7 @@ function declarativeVisHeatmapToYaml(doc, def, report) {
|
|
|
1200
1299
|
doc.add(config);
|
|
1201
1300
|
}
|
|
1202
1301
|
}
|
|
1203
|
-
function declarativeVisBulletToYaml(doc, def, report) {
|
|
1302
|
+
function declarativeVisBulletToYaml(doc, def, report, _errorContext) {
|
|
1204
1303
|
//buckets
|
|
1205
1304
|
const metrics1 = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
1206
1305
|
const metrics2 = report.derivedBuckets.find((item) => item.type === BucketsType.SecondaryMeasures);
|
|
@@ -1225,7 +1324,7 @@ function declarativeVisBulletToYaml(doc, def, report) {
|
|
|
1225
1324
|
doc.add(config);
|
|
1226
1325
|
}
|
|
1227
1326
|
}
|
|
1228
|
-
function declarativeVisWaterfallToYaml(doc, def, report) {
|
|
1327
|
+
function declarativeVisWaterfallToYaml(doc, def, report, _errorContext) {
|
|
1229
1328
|
//buckets
|
|
1230
1329
|
const metrics = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
1231
1330
|
if (metrics && metrics.items.length > 0) {
|
|
@@ -1240,7 +1339,7 @@ function declarativeVisWaterfallToYaml(doc, def, report) {
|
|
|
1240
1339
|
doc.add(config);
|
|
1241
1340
|
}
|
|
1242
1341
|
}
|
|
1243
|
-
function declarativeVisDependencyWheelToYaml(doc, def, report) {
|
|
1342
|
+
function declarativeVisDependencyWheelToYaml(doc, def, report, _errorContext) {
|
|
1244
1343
|
//buckets
|
|
1245
1344
|
const metrics = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
1246
1345
|
if (metrics && metrics.items.length > 0) {
|
|
@@ -1263,7 +1362,7 @@ function declarativeVisDependencyWheelToYaml(doc, def, report) {
|
|
|
1263
1362
|
doc.add(config);
|
|
1264
1363
|
}
|
|
1265
1364
|
}
|
|
1266
|
-
function declarativeVisSankeyToYaml(doc, def, report) {
|
|
1365
|
+
function declarativeVisSankeyToYaml(doc, def, report, _errorContext) {
|
|
1267
1366
|
//buckets
|
|
1268
1367
|
const metrics = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
1269
1368
|
if (metrics && metrics.items.length > 0) {
|
|
@@ -1286,7 +1385,7 @@ function declarativeVisSankeyToYaml(doc, def, report) {
|
|
|
1286
1385
|
doc.add(config);
|
|
1287
1386
|
}
|
|
1288
1387
|
}
|
|
1289
|
-
function declarativeVisHeadlineToYaml(doc, def, report) {
|
|
1388
|
+
function declarativeVisHeadlineToYaml(doc, def, report, _errorContext) {
|
|
1290
1389
|
//buckets
|
|
1291
1390
|
const metrics1 = report.derivedBuckets.find((item) => item.type === BucketsType.Measures);
|
|
1292
1391
|
const metrics2 = report.derivedBuckets.find((item) => item.type === BucketsType.SecondaryMeasures);
|
|
@@ -1302,7 +1401,7 @@ function declarativeVisHeadlineToYaml(doc, def, report) {
|
|
|
1302
1401
|
doc.add(config);
|
|
1303
1402
|
}
|
|
1304
1403
|
}
|
|
1305
|
-
function declarativeVisComboToYaml(doc, def, report) {
|
|
1404
|
+
function declarativeVisComboToYaml(doc, def, report, _errorContext) {
|
|
1306
1405
|
//buckets
|
|
1307
1406
|
const metrics1 = addAxisTypeToGroup(report.derivedBuckets.find((item) => item.type === BucketsType.Measures), "primary");
|
|
1308
1407
|
const metrics2 = addAxisTypeToGroup(report.derivedBuckets.find((item) => item.type === BucketsType.SecondaryMeasures), "secondary");
|
|
@@ -1362,35 +1461,35 @@ function addGeoAreaBucketsToYaml(target, groups) {
|
|
|
1362
1461
|
target.add(entryWithSpace("segment_by", groupToYaml(segment)));
|
|
1363
1462
|
}
|
|
1364
1463
|
}
|
|
1365
|
-
function declarativeVisGeoToYaml(doc, def, report, entities) {
|
|
1464
|
+
function declarativeVisGeoToYaml(doc, def, report, entities, errorContext) {
|
|
1366
1465
|
//buckets
|
|
1367
1466
|
addPushpinBucketsToYaml(doc, report.derivedBuckets);
|
|
1368
1467
|
const config = geoChart.load(def.properties);
|
|
1369
1468
|
if (config) {
|
|
1370
1469
|
doc.add(config);
|
|
1371
1470
|
}
|
|
1372
|
-
appendLayers(doc, def, entities);
|
|
1471
|
+
appendLayers(doc, def, entities, errorContext);
|
|
1373
1472
|
}
|
|
1374
|
-
function declarativeVisGeoAreaToYaml(doc, def, report, entities) {
|
|
1473
|
+
function declarativeVisGeoAreaToYaml(doc, def, report, entities, errorContext) {
|
|
1375
1474
|
//buckets
|
|
1376
1475
|
addGeoAreaBucketsToYaml(doc, report.derivedBuckets);
|
|
1377
1476
|
const config = geoAreaChart.load(def.properties);
|
|
1378
1477
|
if (config) {
|
|
1379
1478
|
doc.add(config);
|
|
1380
1479
|
}
|
|
1381
|
-
appendLayers(doc, def, entities);
|
|
1480
|
+
appendLayers(doc, def, entities, errorContext);
|
|
1382
1481
|
}
|
|
1383
|
-
function appendLayers(doc, def, entities) {
|
|
1482
|
+
function appendLayers(doc, def, entities, errorContext) {
|
|
1384
1483
|
const layersDefinition = def.layers ?? [];
|
|
1385
1484
|
if (layersDefinition.length === 0) {
|
|
1386
1485
|
return;
|
|
1387
1486
|
}
|
|
1388
|
-
const layers = declarativeLayersToYaml(entities, layersDefinition);
|
|
1487
|
+
const layers = declarativeLayersToYaml(entities, layersDefinition, updateErrorContext(errorContext, { path: ["layers"] }));
|
|
1389
1488
|
if (layers.items.length > 0) {
|
|
1390
1489
|
doc.add(entryWithSpace("layers", layers));
|
|
1391
1490
|
}
|
|
1392
1491
|
}
|
|
1393
|
-
function declarativeVisRepeaterToYaml(doc, def, report) {
|
|
1492
|
+
function declarativeVisRepeaterToYaml(doc, def, report, _errorContext) {
|
|
1394
1493
|
const columns = report.derivedBuckets.find((item) => item.type === BucketsType.Columns);
|
|
1395
1494
|
const columnsMapped = addChartTypeToGroup(columns, def.properties);
|
|
1396
1495
|
if (columnsMapped && columnsMapped.items.length > 0) {
|
|
@@ -1410,7 +1509,7 @@ function declarativeVisRepeaterToYaml(doc, def, report) {
|
|
|
1410
1509
|
}
|
|
1411
1510
|
}
|
|
1412
1511
|
//TOTALS
|
|
1413
|
-
export function declarativeTotalToYaml(total) {
|
|
1512
|
+
export function declarativeTotalToYaml(total, _errorContext) {
|
|
1414
1513
|
const map = new YAMLMap();
|
|
1415
1514
|
if (total.alias) {
|
|
1416
1515
|
map.add(new Pair("title", total.alias));
|
|
@@ -1486,11 +1585,11 @@ function addChartTypeToGroup(group, config) {
|
|
|
1486
1585
|
}),
|
|
1487
1586
|
};
|
|
1488
1587
|
}
|
|
1489
|
-
function declarativeLayersToYaml(entities, layersDefinition) {
|
|
1588
|
+
function declarativeLayersToYaml(entities, layersDefinition, errorContext) {
|
|
1490
1589
|
const layers = new YAMLSeq();
|
|
1491
|
-
layersDefinition.forEach((layer) => {
|
|
1492
|
-
const { groups } = declarativeBucketsToYaml(entities, layer.buckets ?? []);
|
|
1493
|
-
const layerKind = resolveLayerExportKind(layer.type);
|
|
1590
|
+
layersDefinition.forEach((layer, li) => {
|
|
1591
|
+
const { groups } = declarativeBucketsToYaml(entities, layer.buckets ?? [], updateErrorContext(errorContext, { path: [li.toString(), "buckets"] }));
|
|
1592
|
+
const layerKind = resolveLayerExportKind(layer.type, updateErrorContext(errorContext, { path: [li.toString(), "type"] }));
|
|
1494
1593
|
const layerMap = new YAMLMap();
|
|
1495
1594
|
layerMap.add(new Pair("id", layer.id));
|
|
1496
1595
|
if (layer.name) {
|
|
@@ -1499,22 +1598,22 @@ function declarativeLayersToYaml(entities, layersDefinition) {
|
|
|
1499
1598
|
if (layer.type) {
|
|
1500
1599
|
layerMap.add(new Pair("type", layer.type));
|
|
1501
1600
|
}
|
|
1502
|
-
appendLayerBucketsForKind(layerMap, groups, layerKind);
|
|
1601
|
+
appendLayerBucketsForKind(layerMap, groups, layerKind, updateErrorContext(errorContext, { path: [li.toString()] }));
|
|
1503
1602
|
addLayerConfig(layerMap, layerKind, layer.properties);
|
|
1504
1603
|
layers.add(layerMap);
|
|
1505
1604
|
});
|
|
1506
1605
|
return layers;
|
|
1507
1606
|
}
|
|
1508
|
-
function resolveLayerExportKind(rawLayerType) {
|
|
1607
|
+
function resolveLayerExportKind(rawLayerType, errorContext) {
|
|
1509
1608
|
if (rawLayerType === "pushpin") {
|
|
1510
1609
|
return "pushpin";
|
|
1511
1610
|
}
|
|
1512
1611
|
if (rawLayerType === "area") {
|
|
1513
1612
|
return "area";
|
|
1514
1613
|
}
|
|
1515
|
-
throw newError(CoreErrorCode.LayerTypeNotSupported, [rawLayerType ?? "<missing>"]);
|
|
1614
|
+
throw newError(CoreErrorCode.LayerTypeNotSupported, [rawLayerType ?? "<missing>"], errorContext);
|
|
1516
1615
|
}
|
|
1517
|
-
function appendLayerBucketsForKind(layerMap, groups, kind) {
|
|
1616
|
+
function appendLayerBucketsForKind(layerMap, groups, kind, errorContext) {
|
|
1518
1617
|
if (kind === "pushpin") {
|
|
1519
1618
|
addPushpinBucketsToYaml(layerMap, groups);
|
|
1520
1619
|
return;
|
|
@@ -1523,7 +1622,7 @@ function appendLayerBucketsForKind(layerMap, groups, kind) {
|
|
|
1523
1622
|
addGeoAreaBucketsToYaml(layerMap, groups);
|
|
1524
1623
|
return;
|
|
1525
1624
|
}
|
|
1526
|
-
throw newError(CoreErrorCode.LayerTypeNotSupported, [kind]);
|
|
1625
|
+
throw newError(CoreErrorCode.LayerTypeNotSupported, [kind], errorContext);
|
|
1527
1626
|
}
|
|
1528
1627
|
function addLayerConfig(layerMap, layerKind, properties) {
|
|
1529
1628
|
if (!properties) {
|